2020-10-23 19:36:12 +02:00
|
|
|
<script>
|
|
|
|
import Icon from './Icon.svelte';
|
|
|
|
|
2021-01-08 09:30:14 +01:00
|
|
|
export let className = '';
|
2020-10-30 00:44:51 +01:00
|
|
|
export let icon = null;
|
2020-11-08 20:57:56 +01:00
|
|
|
export let placeholder = '';
|
2021-02-03 16:21:10 +01:00
|
|
|
export let step = undefined;
|
2020-10-30 00:44:51 +01:00
|
|
|
export let type = 'text';
|
2021-04-04 17:24:54 +02:00
|
|
|
export let pattern = undefined;
|
2020-11-08 20:57:56 +01:00
|
|
|
export let min = Math.min();
|
|
|
|
export let max = Math.max();
|
2020-10-23 19:36:12 +02:00
|
|
|
|
|
|
|
export let value = '';
|
2020-10-30 00:44:51 +01:00
|
|
|
|
|
|
|
const handleInput = (event) => {
|
|
|
|
if (type === 'number') {
|
|
|
|
value = Number(event.target.value);
|
|
|
|
} else {
|
|
|
|
value = event.target.value;
|
|
|
|
}
|
|
|
|
};
|
2020-10-23 19:36:12 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
2021-04-24 03:06:44 +02:00
|
|
|
class="flex flex-1 relative items-center bg-background rounded-2xl h-14
|
|
|
|
focus-within:border-primary border-2 border-transparent ease-in duration-100 {className}"
|
|
|
|
style="min-height: 3.5rem;"
|
|
|
|
>
|
2020-10-23 19:36:12 +02:00
|
|
|
{#if icon}
|
|
|
|
<Icon path={icon} color="white" className="absolute ml-4 w-6 h-6" />
|
|
|
|
{/if}
|
|
|
|
<input
|
|
|
|
{placeholder}
|
2020-10-30 00:44:51 +01:00
|
|
|
{type}
|
|
|
|
{value}
|
|
|
|
{min}
|
|
|
|
{max}
|
2021-02-03 16:21:10 +01:00
|
|
|
{step}
|
2021-04-04 17:24:54 +02:00
|
|
|
{pattern}
|
2020-10-30 00:44:51 +01:00
|
|
|
on:change
|
|
|
|
on:input={handleInput}
|
2021-04-24 03:06:44 +02:00
|
|
|
class={`w-full ${
|
|
|
|
icon ? 'pl-12' : 'pl-4'
|
|
|
|
} min-h-full pr-4 text-white placeholder-gray-500 leading-none bg-transparent border-none focus:outline-none`}
|
|
|
|
/>
|
2020-10-23 19:36:12 +02:00
|
|
|
</div>
|