|
21 | 21 | oninput?: (input: string) => void | undefined; |
22 | 22 | } |
23 | 23 |
|
| 24 | + const id = $props.id(); |
| 25 | + const inputId = id + '-input'; |
| 26 | + const validationId = id + '-validation'; |
24 | 27 | let { |
25 | 28 | type = 'text', |
26 | 29 | label, |
|
42 | 45 | } |
43 | 46 | </script> |
44 | 47 |
|
45 | | -<label class="label w-full"> |
| 48 | +<label for={inputId} class="label w-full"> |
46 | 49 | <span>{label}</span> |
47 | | - <div class="flex flex-row items-center gap-2"> |
48 | | - <div class="input-group input-group-divider flex grow flex-row gap-2"> |
49 | | - {#if Icon} |
50 | | - <Icon /> |
51 | | - {/if} |
52 | | - <Input |
53 | | - {type} |
54 | | - class="input grow" |
55 | | - title={label} |
56 | | - {placeholder} |
57 | | - {autocomplete} |
58 | | - {value} |
59 | | - oninput={handleInput} |
60 | | - /> |
61 | | - {#if button} |
62 | | - <Button |
63 | | - type="button" |
64 | | - class={button.class ?? 'variant-filled-primary disabled:opacity-50'} |
65 | | - onclick={button.onClick} |
66 | | - disabled={button.submits && |
67 | | - (validationResult === null || (validationResult && !validationResult.valid))} |
68 | | - > |
69 | | - {#if 'Icon' in button} |
70 | | - <button.Icon /> |
71 | | - {:else if 'text' in button} |
72 | | - {button.text} |
73 | | - {/if} |
74 | | - </Button> |
75 | | - {/if} |
76 | | - </div> |
| 50 | + <div class="input-group input-group-divider flex grow flex-row items-center gap-2"> |
| 51 | + {#if Icon} |
| 52 | + <Icon /> |
| 53 | + {/if} |
| 54 | + <Input |
| 55 | + id={inputId} |
| 56 | + {type} |
| 57 | + class="input grow" |
| 58 | + title={label} |
| 59 | + {placeholder} |
| 60 | + {autocomplete} |
| 61 | + {value} |
| 62 | + oninput={handleInput} |
| 63 | + aria-invalid={validationResult ? !validationResult.valid : undefined} |
| 64 | + aria-describedby={validationResult ? validationId : undefined} |
| 65 | + /> |
| 66 | + {#if button} |
| 67 | + <Button |
| 68 | + type="button" |
| 69 | + class={button.class ?? 'variant-filled-primary disabled:opacity-50'} |
| 70 | + onclick={button.onClick} |
| 71 | + disabled={button.submits && |
| 72 | + (validationResult === null || (validationResult && !validationResult.valid))} |
| 73 | + > |
| 74 | + {#if 'Icon' in button} |
| 75 | + <button.Icon /> |
| 76 | + {:else if 'text' in button} |
| 77 | + {button.text} |
| 78 | + {/if} |
| 79 | + </Button> |
| 80 | + {/if} |
77 | 81 | </div> |
78 | 82 | {#if validationResult?.message} |
79 | | - <p class="text-xs text-{GetValResColor(validationResult)} mt-0!"> |
| 83 | + <p id={validationId} class="text-xs text-{GetValResColor(validationResult)} mt-0! h-4 truncate"> |
80 | 84 | {validationResult.message} |
81 | 85 | {#if validationResult.link} |
82 | 86 | <a |
83 | 87 | href={validationResult.link.href} |
84 | 88 | target="_blank" |
85 | 89 | rel="noreferrer" |
86 | | - class="text-xs text-blue-500 underline" |
| 90 | + class="text-blue-500 underline" |
87 | 91 | > |
88 | 92 | {validationResult.link.text} |
89 | 93 | </a> |
90 | 94 | {/if} |
91 | 95 | </p> |
92 | 96 | {:else} |
93 | | - <div class="h-3"></div> |
| 97 | + <div class="h-4"></div> |
94 | 98 | {/if} |
95 | 99 | {#if popup} |
96 | 100 | <Popover.Root> |
|
0 commit comments