|
1 | 1 | <script lang="ts">
|
2 |
| - import classNames from 'classnames'; |
| 2 | + import classNames from 'classnames'; |
3 | 3 |
|
4 |
| - export let value: string = ''; |
5 |
| - export let size: 'sm' | 'md' | 'lg' = 'md'; |
6 |
| - export let noBorder: boolean = false; |
7 |
| - export let inputClass: string = |
8 |
| - 'rounded-none rounded-r-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'; |
9 |
| - export let spanClass: string = |
10 |
| - 'inline-flex items-center px-3 text-sm text-gray-900 bg-gray-200 rounded-l-md border border-r-0 border-gray-300 dark:bg-gray-600 dark:text-gray-400 dark:border-gray-600'; |
11 |
| - export let noBorderInputClass: string = |
12 |
| - 'bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'; |
13 |
| - export let pointerEvent: boolean = false; |
14 |
| - export let noBorderDivClass: string = 'flex absolute inset-y-0 left-0 items-center pl-3'; |
| 4 | + export let value: string = ''; |
| 5 | + export let size: 'sm' | 'md' | 'lg' = 'md'; |
| 6 | + export let noBorder: boolean = false; |
| 7 | + export let inputClass: string = |
| 8 | + 'rounded-none rounded-r-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full border-gray-300 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'; |
| 9 | + export let spanClass: string = |
| 10 | + 'inline-flex items-center px-3 text-sm text-gray-900 bg-gray-200 rounded-l-md border border-r-0 border-gray-300 dark:bg-gray-600 dark:text-gray-400 dark:border-gray-600'; |
| 11 | + export let noBorderInputClass: string = |
| 12 | + 'bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500'; |
| 13 | + export let pointerEvent: boolean = false; |
| 14 | + export let noBorderDivClass: string = 'flex absolute inset-y-0 left-0 items-center pl-3'; |
15 | 15 | </script>
|
16 | 16 |
|
17 | 17 | {#if noBorder}
|
18 |
| - <div class="relative"> |
19 |
| - <div |
20 |
| - class={classNames( |
21 |
| - noBorderDivClass, |
22 |
| - { |
23 |
| - 'p-2 sm:text-xs': size === 'sm', |
24 |
| - 'p-2.5 text-sm': size === 'md', |
25 |
| - 'sm:text-md p-4': size === 'lg' |
26 |
| - }, |
27 |
| - pointerEvent ? 'cursor-pointer' : 'pointer-events-none' |
28 |
| - )}> |
29 |
| - <slot /> |
30 |
| - </div> |
31 |
| - <input |
32 |
| - {...$$restProps} |
33 |
| - bind:value |
34 |
| - class={classNames( |
35 |
| - noBorderInputClass, |
36 |
| - { |
37 |
| - 'p-2 sm:text-xs pl-9': size === 'sm', |
38 |
| - 'p-2.5 text-sm pl-10': size === 'md', |
39 |
| - 'sm:text-md p-4 pl-11': size === 'lg' |
40 |
| - }, |
41 |
| - $$props.class |
42 |
| - )} /> |
43 |
| - </div> |
| 18 | + <div class="relative"> |
| 19 | + <div |
| 20 | + class={classNames( |
| 21 | + noBorderDivClass, |
| 22 | + { |
| 23 | + 'p-2 sm:text-xs': size === 'sm', |
| 24 | + 'p-2.5 text-sm': size === 'md', |
| 25 | + 'sm:text-md p-4': size === 'lg' |
| 26 | + }, |
| 27 | + pointerEvent ? 'cursor-pointer' : 'pointer-events-none' |
| 28 | + )}> |
| 29 | + <slot /> |
| 30 | + </div> |
| 31 | + <input |
| 32 | + {...$$restProps} |
| 33 | + bind:value |
| 34 | + on:blur |
| 35 | + on:change |
| 36 | + on:click |
| 37 | + on:focus |
| 38 | + on:keydown |
| 39 | + on:keypress |
| 40 | + on:keyup |
| 41 | + on:mouseover |
| 42 | + on:mouseenter |
| 43 | + on:mouseleave |
| 44 | + on:paste |
| 45 | + on:input |
| 46 | + class={classNames( |
| 47 | + noBorderInputClass, |
| 48 | + { |
| 49 | + 'p-2 sm:text-xs pl-9': size === 'sm', |
| 50 | + 'p-2.5 text-sm pl-10': size === 'md', |
| 51 | + 'sm:text-md p-4 pl-11': size === 'lg' |
| 52 | + }, |
| 53 | + $$props.class |
| 54 | + )} /> |
| 55 | + </div> |
44 | 56 | {:else}
|
45 |
| - <div class="flex"> |
46 |
| - <span class={spanClass}> |
47 |
| - <slot /> |
48 |
| - </span> |
49 |
| - <input |
50 |
| - {...$$restProps} |
51 |
| - bind:value |
52 |
| - class={classNames( |
53 |
| - inputClass, |
54 |
| - { |
55 |
| - 'p-2 sm:text-xs': size === 'sm', |
56 |
| - 'p-2.5 text-sm': size === 'md', |
57 |
| - 'sm:text-md p-4': size === 'lg' |
58 |
| - }, |
59 |
| - $$props.class |
60 |
| - )} /> |
61 |
| - </div> |
| 57 | + <div class="flex"> |
| 58 | + <span class={spanClass}> |
| 59 | + <slot /> |
| 60 | + </span> |
| 61 | + <input |
| 62 | + {...$$restProps} |
| 63 | + bind:value |
| 64 | + on:blur |
| 65 | + on:change |
| 66 | + on:click |
| 67 | + on:focus |
| 68 | + on:keydown |
| 69 | + on:keypress |
| 70 | + on:keyup |
| 71 | + on:mouseover |
| 72 | + on:mouseenter |
| 73 | + on:mouseleave |
| 74 | + on:paste |
| 75 | + on:input |
| 76 | + class={classNames( |
| 77 | + inputClass, |
| 78 | + { |
| 79 | + 'p-2 sm:text-xs': size === 'sm', |
| 80 | + 'p-2.5 text-sm': size === 'md', |
| 81 | + 'sm:text-md p-4': size === 'lg' |
| 82 | + }, |
| 83 | + $$props.class |
| 84 | + )} /> |
| 85 | + </div> |
62 | 86 | {/if}
|
0 commit comments