simplesvelte 2.2.14 → 2.2.16
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.
- package/dist/Select.svelte +4 -40
- package/package.json +1 -1
package/dist/Select.svelte
CHANGED
|
@@ -92,7 +92,6 @@
|
|
|
92
92
|
// Close dropdown and update filter immediately
|
|
93
93
|
filter = items.find((item) => item.value === itemValue)?.label || ''
|
|
94
94
|
detailsOpen = false
|
|
95
|
-
filterMode = 'auto'
|
|
96
95
|
|
|
97
96
|
// Wait for DOM update so details closes properly
|
|
98
97
|
await tick()
|
|
@@ -133,11 +132,10 @@
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
let filter = $state('')
|
|
136
|
-
let filterMode = $state<'user' | 'auto'>('user') // Track if filter is user-controlled or auto-synced
|
|
137
135
|
|
|
138
|
-
// Auto-sync filter for single select when
|
|
136
|
+
// Auto-sync filter for single select when dropdown is closed
|
|
139
137
|
$effect(() => {
|
|
140
|
-
if (!multiple && !detailsOpen
|
|
138
|
+
if (!multiple && !detailsOpen) {
|
|
141
139
|
if (selectedItem) {
|
|
142
140
|
filter = selectedItem.label
|
|
143
141
|
} else {
|
|
@@ -146,18 +144,6 @@
|
|
|
146
144
|
}
|
|
147
145
|
})
|
|
148
146
|
|
|
149
|
-
// Reset filter mode when user starts typing
|
|
150
|
-
function handleFilterInput() {
|
|
151
|
-
filterMode = 'user'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Set filter mode to auto when closing dropdown
|
|
155
|
-
function handleDropdownClose() {
|
|
156
|
-
if (!multiple) {
|
|
157
|
-
filterMode = 'auto'
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
147
|
let filteredItems = $derived.by(() => {
|
|
162
148
|
if (filter.length === 0) return items
|
|
163
149
|
return items.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase()))
|
|
@@ -190,18 +176,7 @@
|
|
|
190
176
|
}
|
|
191
177
|
return result
|
|
192
178
|
})
|
|
193
|
-
|
|
194
|
-
// Using $state.eager to ensure immediate UI feedback when selection changes
|
|
195
|
-
let displayText = $derived.by(() => {
|
|
196
|
-
if (multiple) {
|
|
197
|
-
const count = $state.eager(selectedItems.length)
|
|
198
|
-
if (count === 0) return placeholder
|
|
199
|
-
if (count === 1) return selectedItems[0].label
|
|
200
|
-
return `${count} items selected`
|
|
201
|
-
}
|
|
202
|
-
const item = $state.eager(selectedItem)
|
|
203
|
-
return item ? item.label : placeholder
|
|
204
|
-
})
|
|
179
|
+
|
|
205
180
|
let searchEL: HTMLInputElement | undefined = $state(undefined)
|
|
206
181
|
|
|
207
182
|
// Virtual list implementation
|
|
@@ -295,21 +270,13 @@
|
|
|
295
270
|
bind:open={detailsOpen}
|
|
296
271
|
use:clickOutside={() => {
|
|
297
272
|
if (!detailsOpen) return
|
|
298
|
-
if (!multiple) {
|
|
299
|
-
filter = selectedItem?.label ?? ''
|
|
300
|
-
} else {
|
|
301
|
-
filter = ''
|
|
302
|
-
}
|
|
303
|
-
console.log('clickOutside')
|
|
304
273
|
detailsOpen = false
|
|
305
|
-
handleDropdownClose()
|
|
306
274
|
}}>
|
|
307
275
|
<summary
|
|
308
276
|
class="select h-max min-h-10 w-full min-w-12 cursor-pointer !bg-none pr-1"
|
|
309
277
|
onclick={() => {
|
|
310
278
|
searchEL?.focus()
|
|
311
279
|
filter = ''
|
|
312
|
-
filterMode = 'user'
|
|
313
280
|
}}>
|
|
314
281
|
{#if multiple}
|
|
315
282
|
<!-- Multi-select display with chips -->
|
|
@@ -334,7 +301,6 @@
|
|
|
334
301
|
class="h-full outline-0 {detailsOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
335
302
|
bind:this={searchEL}
|
|
336
303
|
bind:value={filter}
|
|
337
|
-
oninput={handleFilterInput}
|
|
338
304
|
onclick={() => {
|
|
339
305
|
detailsOpen = true
|
|
340
306
|
}}
|
|
@@ -348,14 +314,12 @@
|
|
|
348
314
|
class="h-full w-full outline-0 {detailsOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
349
315
|
bind:this={searchEL}
|
|
350
316
|
bind:value={filter}
|
|
351
|
-
oninput={handleFilterInput}
|
|
352
317
|
onclick={() => {
|
|
353
318
|
detailsOpen = true
|
|
354
319
|
}}
|
|
355
|
-
placeholder
|
|
320
|
+
{placeholder}
|
|
356
321
|
required={required && !normalizedValue} />
|
|
357
322
|
{/if}
|
|
358
|
-
|
|
359
323
|
{#if !required && ((multiple && Array.isArray(normalizedValue) && normalizedValue.length > 0) || (!multiple && normalizedValue))}
|
|
360
324
|
<button
|
|
361
325
|
type="button"
|