simplesvelte 2.4.3 → 2.4.5
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 +23 -27
- package/package.json +1 -1
package/dist/Select.svelte
CHANGED
|
@@ -354,12 +354,25 @@
|
|
|
354
354
|
|
|
355
355
|
function openDropdown() {
|
|
356
356
|
if (!popoverEl) return
|
|
357
|
-
|
|
357
|
+
try {
|
|
358
|
+
if (!popoverEl.matches(':popover-open')) {
|
|
359
|
+
popoverEl.showPopover()
|
|
360
|
+
}
|
|
361
|
+
} catch {
|
|
362
|
+
// Ignore errors if popover is in an invalid state
|
|
363
|
+
}
|
|
358
364
|
}
|
|
359
365
|
|
|
360
366
|
function closeDropdown() {
|
|
361
367
|
if (!popoverEl) return
|
|
362
|
-
|
|
368
|
+
try {
|
|
369
|
+
// Check if open before hiding
|
|
370
|
+
if (popoverEl.matches(':popover-open')) {
|
|
371
|
+
popoverEl.hidePopover()
|
|
372
|
+
}
|
|
373
|
+
} catch {
|
|
374
|
+
// Ignore errors if popover is in an invalid state
|
|
375
|
+
}
|
|
363
376
|
}
|
|
364
377
|
|
|
365
378
|
// Handle popover toggle event to sync state
|
|
@@ -392,6 +405,7 @@
|
|
|
392
405
|
aria-expanded={dropdownOpen}
|
|
393
406
|
aria-haspopup="listbox"
|
|
394
407
|
aria-controls={popoverId}
|
|
408
|
+
tabindex="-1"
|
|
395
409
|
class="select relative h-max min-h-10 w-full min-w-12 cursor-pointer bg-none! pr-1 text-left"
|
|
396
410
|
style="anchor-name: {anchorName}"
|
|
397
411
|
title={tooltipText}
|
|
@@ -414,18 +428,11 @@
|
|
|
414
428
|
<span class="max-w-[200px] truncate">{selectedItems[0].label}</span>
|
|
415
429
|
<span
|
|
416
430
|
role="button"
|
|
417
|
-
tabindex="
|
|
431
|
+
tabindex="-1"
|
|
418
432
|
class="btn btn-xs btn-circle btn-ghost hover:bg-base-300"
|
|
419
433
|
onclick={(e) => {
|
|
420
434
|
e.stopPropagation()
|
|
421
435
|
removeSelectedItem(selectedItems[0].value)
|
|
422
|
-
}}
|
|
423
|
-
onkeydown={(e) => {
|
|
424
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
425
|
-
e.preventDefault()
|
|
426
|
-
e.stopPropagation()
|
|
427
|
-
removeSelectedItem(selectedItems[0].value)
|
|
428
|
-
}
|
|
429
436
|
}}>
|
|
430
437
|
✕
|
|
431
438
|
</span>
|
|
@@ -444,10 +451,7 @@
|
|
|
444
451
|
class="h-full min-w-[120px] flex-1 outline-0 {dropdownOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
445
452
|
bind:this={searchEL}
|
|
446
453
|
bind:value={filterInput}
|
|
447
|
-
onclick={(
|
|
448
|
-
e.stopPropagation()
|
|
449
|
-
openDropdown()
|
|
450
|
-
}}
|
|
454
|
+
onclick={() => openDropdown()}
|
|
451
455
|
placeholder="Search..."
|
|
452
456
|
required={required && (!Array.isArray(normalizedValue) || normalizedValue.length === 0)} />
|
|
453
457
|
</div>
|
|
@@ -459,9 +463,7 @@
|
|
|
459
463
|
bind:this={searchEL}
|
|
460
464
|
value={filter}
|
|
461
465
|
oninput={(e) => (filterInput = e.currentTarget.value)}
|
|
462
|
-
onclick={(
|
|
463
|
-
e.stopPropagation()
|
|
464
|
-
// Clear filter when opening dropdown so all options are visible
|
|
466
|
+
onclick={() => {
|
|
465
467
|
filterInput = ''
|
|
466
468
|
openDropdown()
|
|
467
469
|
}}
|
|
@@ -471,19 +473,12 @@
|
|
|
471
473
|
{#if !required && ((multiple && Array.isArray(normalizedValue) && normalizedValue.length > 0) || (!multiple && normalizedValue))}
|
|
472
474
|
<span
|
|
473
475
|
role="button"
|
|
474
|
-
tabindex="
|
|
476
|
+
tabindex="-1"
|
|
475
477
|
class="btn btn-sm btn-circle btn-ghost bg-base-100 absolute top-1 right-1"
|
|
476
478
|
onclick={(e) => {
|
|
477
479
|
e.preventDefault()
|
|
478
480
|
e.stopPropagation()
|
|
479
481
|
clearAll()
|
|
480
|
-
}}
|
|
481
|
-
onkeydown={(e) => {
|
|
482
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
483
|
-
e.preventDefault()
|
|
484
|
-
e.stopPropagation()
|
|
485
|
-
clearAll()
|
|
486
|
-
}
|
|
487
482
|
}}>
|
|
488
483
|
✕
|
|
489
484
|
</span>
|
|
@@ -496,8 +491,9 @@
|
|
|
496
491
|
id={popoverId}
|
|
497
492
|
popover
|
|
498
493
|
role="listbox"
|
|
499
|
-
|
|
500
|
-
|
|
494
|
+
inert={!dropdownOpen}
|
|
495
|
+
class="dropdown menu bg-base-100 rounded-box z-50 flex flex-col flex-nowrap gap-1 p-2 shadow outline m-0"
|
|
496
|
+
style="position-anchor: {anchorName}; position: fixed; top: anchor(bottom); left: anchor(left); width: anchor-size(width); margin-block: 0.5rem; position-try-fallbacks: flip-block;"
|
|
501
497
|
ontoggle={handlePopoverToggle}>
|
|
502
498
|
{#if multiple && filteredItems.length > 1}
|
|
503
499
|
<!-- Select All / Clear All options for multi-select -->
|