svelte-5-select 1.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +255 -115
  2. package/dist/ChevronIcon.svelte +14 -13
  3. package/dist/ChevronIcon.svelte.d.ts +6 -14
  4. package/dist/ClearIcon.svelte +9 -11
  5. package/dist/ClearIcon.svelte.d.ts +6 -14
  6. package/dist/LoadingIcon.svelte +15 -2
  7. package/dist/LoadingIcon.svelte.d.ts +6 -14
  8. package/dist/Select.svelte +1048 -442
  9. package/dist/Select.svelte.d.ts +37 -5
  10. package/dist/aria-handlers.svelte.d.ts +5 -2
  11. package/dist/aria-handlers.svelte.js +30 -8
  12. package/dist/filter.d.ts +10 -2
  13. package/dist/filter.js +15 -8
  14. package/dist/index.d.ts +3 -4
  15. package/dist/index.js +2 -3
  16. package/dist/keyboard-navigation.svelte.d.ts +7 -2
  17. package/dist/keyboard-navigation.svelte.js +293 -47
  18. package/dist/no-styles/ChevronIcon.svelte +17 -0
  19. package/dist/no-styles/ChevronIcon.svelte.d.ts +18 -0
  20. package/dist/no-styles/ClearIcon.svelte +14 -0
  21. package/dist/no-styles/ClearIcon.svelte.d.ts +18 -0
  22. package/dist/no-styles/LoadingIcon.svelte +19 -0
  23. package/dist/no-styles/LoadingIcon.svelte.d.ts +18 -0
  24. package/dist/no-styles/Select.svelte +1452 -0
  25. package/dist/no-styles/Select.svelte.d.ts +38 -0
  26. package/dist/select-state.svelte.d.ts +15 -0
  27. package/dist/select-state.svelte.js +161 -0
  28. package/dist/styles/default.css +131 -71
  29. package/dist/tailwind.css +139 -17
  30. package/dist/types.d.ts +488 -129
  31. package/dist/use-hover.svelte.d.ts +3 -7
  32. package/dist/use-hover.svelte.js +110 -36
  33. package/dist/use-load-options.svelte.d.ts +18 -3
  34. package/dist/use-load-options.svelte.js +362 -42
  35. package/dist/use-value.svelte.d.ts +2 -11
  36. package/dist/use-value.svelte.js +334 -111
  37. package/dist/utils.d.ts +19 -8
  38. package/dist/utils.js +52 -8
  39. package/package.json +121 -94
package/dist/tailwind.css CHANGED
@@ -2,16 +2,25 @@
2
2
 
3
3
  .svelte-select {
4
4
  @apply border rounded box-border h-10 relative flex items-center px-4 py-0 bg-white m-0 w-full
5
- hover:border-gray-400;
5
+ hover:border-gray-500;
6
+ /* gray-500 (~4.8:1 on white), not gray-400 (~2.5:1): preflight defaults the
7
+ border to currentColor, so a gray-400 hover *lightened* the control's
8
+ boundary below the 3:1 non-text bar (WCAG 1.4.11) at the moment of
9
+ interaction — mirrors --border-hover (#67727d) in styles/default.css. */
6
10
  }
7
11
 
8
12
  .svelte-select input {
9
- @apply cursor-default border-none text-gray-600 h-10 leading-10 px-4 py-0 bg-transparent text-sm absolute left-0 m-0 w-full
10
- focus:outline-none hover:border-gray-400;
13
+ @apply cursor-default border-none text-gray-600 h-10 leading-10 px-4 py-0 bg-transparent text-sm absolute left-0 m-0 w-full
14
+ focus:outline-none
15
+ placeholder:text-gray-500 placeholder:opacity-100;
16
+ /* Without an explicit placeholder color, Tailwind v4 preflight's 50%-alpha
17
+ currentColor ::placeholder applies — ~2.3:1 on white, a WCAG 1.4.3
18
+ failure on the control's primary prompt. gray-500 mirrors the default
19
+ theme's #67727d (~4.9:1); the disabled rule below still overrides. */
11
20
  }
12
21
 
13
22
  .svelte-select.focused {
14
- @apply border-blue-600;
23
+ @apply border-blue-600 ring-2 ring-blue-600/40;
15
24
  }
16
25
 
17
26
  .svelte-select.disabled {
@@ -27,11 +36,11 @@
27
36
  focus:outline-none;
28
37
  }
29
38
 
30
- .svelte-select .icons {
31
- @apply absolute flex items-center right-0 translate-y-0 text-gray-200 pointer-events-none top-0 bottom-0;
39
+ .svelte-select .indicators {
40
+ @apply absolute flex items-center right-0 translate-y-0 text-gray-500 pointer-events-none top-0 bottom-0;
32
41
  }
33
42
 
34
- .svelte-select .icons > * {
43
+ .svelte-select .indicators > * {
35
44
  @apply transition-colors ease-in-out duration-200;
36
45
  }
37
46
 
@@ -39,18 +48,20 @@
39
48
  @apply pointer-events-auto;
40
49
  }
41
50
 
42
- .svelte-select.focused .icons,
51
+ .svelte-select.focused .indicators,
43
52
  .svelte-select .chevron:hover,
44
53
  .svelte-select .clear-select:hover {
45
54
  @apply text-gray-600;
46
55
  }
47
56
 
48
57
  .svelte-select .clear-select {
49
- @apply px-2 h-5 text-gray-300 flex-none w-9;
58
+ /* h-6: 24px minimum in both dimensions (WCAG 2.2 2.5.8 target size)
59
+ h-5 left the activation target 20px tall */
60
+ @apply px-2 h-6 text-gray-500 flex-none w-9;
50
61
  }
51
62
 
52
63
  .svelte-select .chevron {
53
- @apply flex pt-0 pr-2 pl-2 border-l-2 w-9 h-5 text-gray-300;
64
+ @apply flex pt-0 pr-2 pl-2 border-l-2 w-9 h-5 text-gray-500;
54
65
  }
55
66
 
56
67
  .svelte-select.multi {
@@ -69,15 +80,19 @@
69
80
  @apply sr-only;
70
81
  }
71
82
 
72
- .list {
83
+ .svelte-select-list {
73
84
  @apply shadow-md rounded-sm max-h-64 overflow-y-auto bg-white border-none absolute z-10 w-full left-0 right-0;
74
85
  }
75
86
 
76
- .list .list-group-title {
87
+ .svelte-select-list.prefloat {
88
+ @apply opacity-0 pointer-events-none;
89
+ }
90
+
91
+ .svelte-select-list .list-group-title {
77
92
  @apply text-slate-800 cursor-default text-sm font-medium h-10 leading-10 px-5 text-ellipsis whitespace-nowrap uppercase;
78
93
  }
79
94
 
80
- .list .empty {
95
+ .svelte-select-list .empty {
81
96
  @apply text-center py-5 text-gray-500;
82
97
  }
83
98
 
@@ -97,16 +112,47 @@
97
112
  @apply bg-blue-600 text-white;
98
113
  }
99
114
 
100
- .item.not-selectable {
101
- @apply text-gray-300;
115
+ /* Disabled options are not actionable, so they must not show the hover/active
116
+ affordances (background or the keyboard-cursor outline). gray-400 tracks the
117
+ default theme's #999 (2.84:1 — allowed by WCAG 1.4.3's inactive-component
118
+ exemption). */
119
+ .item.not-selectable,
120
+ .item.hover.item.not-selectable,
121
+ .item.active.item.not-selectable,
122
+ .item.not-selectable:active {
123
+ @apply text-gray-400 bg-transparent;
124
+ outline: none;
125
+ }
126
+
127
+ /* Group titles are informative text, not disabled controls, so WCAG 1.4.3's
128
+ inactive-component exemption does not apply to them: the not-selectable
129
+ dimming above must not reach a header. Keep them at the group-title color,
130
+ including during the transient first frame where the keyboard cursor parks
131
+ on index 0 before the keep-hover effect moves it off a header. (Mirrors
132
+ styles/default.css — keep the two themes in sync.) */
133
+ .item.list-group-title.not-selectable,
134
+ .item.hover.item.list-group-title.not-selectable {
135
+ @apply text-slate-800;
102
136
  }
103
137
 
104
138
  .item.first {
105
139
  @apply rounded-t-sm;
106
140
  }
107
141
 
142
+ .item.last {
143
+ @apply rounded-b-sm;
144
+ }
145
+
146
+ .item.first.last {
147
+ @apply rounded-sm;
148
+ }
149
+
108
150
  .item.hover:not(.active) {
109
151
  @apply bg-blue-100;
152
+ /* The background alone is a colour-only cue for the keyboard cursor
153
+ (WCAG 1.4.11) — blue-600 is >=3:1 on white and on blue-100 */
154
+ outline: 2px solid #2563eb;
155
+ outline-offset: -2px;
110
156
  }
111
157
 
112
158
  .multi input {
@@ -114,15 +160,91 @@
114
160
  }
115
161
 
116
162
  .multi-item {
117
- @apply bg-gray-100 mt-1 mr-1 border border-gray-200 rounded-sm h-8 leading-8 flex cursor-default pr-1 pl-1 max-w-full items-center mr-1 overflow-hidden text-ellipsis whitespace-nowrap;
163
+ @apply bg-gray-100 mt-1 mr-1 border border-gray-200 rounded-sm h-8 leading-8 flex cursor-default pr-1 pl-1 max-w-full items-center overflow-hidden text-ellipsis whitespace-nowrap;
118
164
  }
119
165
 
120
166
  .multi-item.disabled {
121
167
  @apply hover:bg-gray-300 hover:text-gray-500;
122
168
  }
123
169
 
170
+ /* Keyboard-focused chip (multiFullItemClearable): explicit ring in the theme
171
+ accent (mirrors styles/default.css). Distinct from .multi-item.active below,
172
+ which is the arrow-key tag cursor, not DOM focus. */
173
+ .multi-item:focus-visible {
174
+ outline: 2px solid #2563eb;
175
+ outline-offset: -1px;
176
+ }
177
+
178
+ /* ArrowLeft/ArrowRight park a virtual cursor on a tag before Backspace removes
179
+ it; without a visible indicator a sighted keyboard user deletes a chip they
180
+ cannot see targeted (WCAG 1.4.11 non-text contrast: blue-600 is >=3:1 on
181
+ white and on the gray-100 chip). */
182
+ .multi-item.active {
183
+ outline: 1px solid #2563eb;
184
+ }
185
+
124
186
  .multi-item-clear {
125
- @apply flex items-center justify-center w-5;
187
+ /* w-6 + self-stretch: a 24x32px activation target (WCAG 2.2 2.5.8) —
188
+ w-5 alone left the remove button 20x20px */
189
+ @apply flex items-center justify-center w-6 self-stretch;
190
+ }
191
+
192
+ @media (prefers-reduced-motion: reduce) {
193
+ .svelte-select .indicators > * {
194
+ @apply transition-none;
195
+ }
196
+ }
197
+
198
+ @media (forced-colors: active) {
199
+ /* The ring above uses box-shadow, which forced-colors mode drops; restore a
200
+ real outline, and distinguish selected (filled) from cursor (outlined). */
201
+ .svelte-select.focused {
202
+ outline: 2px solid Highlight;
203
+ outline-offset: 1px;
204
+ }
205
+
206
+ .item.active {
207
+ background: Highlight;
208
+ color: HighlightText;
209
+ }
210
+
211
+ .item.hover:not(.active) {
212
+ outline: 2px solid Highlight;
213
+ outline-offset: -2px;
214
+ }
215
+
216
+ /* The chip's focus ring is an author colour, which is flattened here */
217
+ .multi-item:focus-visible {
218
+ outline: 2px solid Highlight;
219
+ }
220
+
221
+ /* The arrow-key tag cursor (the normal-mode .multi-item.active rule above)
222
+ differs from an ordinary chip only by an author outline colour, which is
223
+ flattened here — width + style survive the forced palette, so the
224
+ Backspace target stays visible. */
225
+ .multi-item.active {
226
+ outline: 2px dashed Highlight;
227
+ outline-offset: -2px;
228
+ }
229
+
230
+ /* The error state is conveyed only by an author border colour, which is
231
+ flattened to the standard border — border width + style survive the
232
+ forced palette, so a double border keeps the state visible. */
233
+ .svelte-select.error {
234
+ border: 3px double CanvasText;
235
+ }
236
+
237
+ /* Disabled is aria-disabled + readonly, not :disabled, so the UA never
238
+ applies its own GrayText treatment — do it explicitly. */
239
+ .svelte-select.disabled,
240
+ .svelte-select.disabled input,
241
+ .svelte-select.disabled input::placeholder {
242
+ color: GrayText;
243
+ }
244
+
245
+ .svelte-select.disabled {
246
+ border-color: GrayText;
247
+ }
126
248
  }
127
249
 
128
250
  .list-item {