simplesvelte 2.5.2 → 2.6.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.
- package/dist/Select.svelte +27 -4
- package/dist/Select.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/Select.svelte
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
error?: string
|
|
29
29
|
hideOptional?: boolean
|
|
30
30
|
dropdownMinWidth?: string
|
|
31
|
+
pending?: boolean
|
|
31
32
|
zodErrors?: {
|
|
32
33
|
expected: string
|
|
33
34
|
code: string
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
error,
|
|
53
54
|
hideOptional,
|
|
54
55
|
dropdownMinWidth,
|
|
56
|
+
pending = false,
|
|
55
57
|
zodErrors,
|
|
56
58
|
onchange,
|
|
57
59
|
}: Props = $props()
|
|
@@ -179,6 +181,7 @@
|
|
|
179
181
|
return filterInput
|
|
180
182
|
})
|
|
181
183
|
|
|
184
|
+
|
|
182
185
|
let filteredItems = $derived.by(() => {
|
|
183
186
|
// When using async fetch, server handles filtering - return items as-is
|
|
184
187
|
if (fetchOptions) return items
|
|
@@ -543,9 +546,9 @@
|
|
|
543
546
|
<!-- Single-select display -->
|
|
544
547
|
<input
|
|
545
548
|
type="text"
|
|
546
|
-
class="h-full w-full outline-0 {dropdownOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
549
|
+
class="h-full w-full pr-8 outline-0 {dropdownOpen ? 'cursor-text' : 'cursor-pointer'}"
|
|
547
550
|
bind:this={searchEL}
|
|
548
|
-
value={filter}
|
|
551
|
+
value={$state.eager(filter)}
|
|
549
552
|
oninput={(e) => (filterInput = e.currentTarget.value)}
|
|
550
553
|
onclick={() => {
|
|
551
554
|
filterInput = ''
|
|
@@ -555,12 +558,23 @@
|
|
|
555
558
|
{placeholder}
|
|
556
559
|
required={required && !normalizedValue} />
|
|
557
560
|
{/if}
|
|
558
|
-
|
|
561
|
+
<!-- Spinner: always in DOM so hidden attribute can be updated eagerly via $state.eager -->
|
|
562
|
+
{#if !multiple}
|
|
563
|
+
<span
|
|
564
|
+
aria-hidden="true"
|
|
565
|
+
class="loading loading-spinner loading-xs pointer-events-none absolute top-1/2 right-3 -translate-y-1/2"
|
|
566
|
+
hidden={!$state.eager(pending)}
|
|
567
|
+
></span>
|
|
568
|
+
{/if}
|
|
569
|
+
<!-- Clear button: hidden attribute updated eagerly so spinner and ✕ never overlap -->
|
|
570
|
+
{#if !required}
|
|
559
571
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
560
572
|
<span
|
|
561
573
|
role="button"
|
|
562
574
|
tabindex="-1"
|
|
563
575
|
class="btn btn-sm btn-circle btn-ghost bg-base-100 absolute top-1 right-1"
|
|
576
|
+
hidden={!((multiple && Array.isArray(normalizedValue) && normalizedValue.length > 0) || (!multiple && normalizedValue)) ||
|
|
577
|
+
$state.eager(pending)}
|
|
564
578
|
onclick={(e) => {
|
|
565
579
|
e.preventDefault()
|
|
566
580
|
e.stopPropagation()
|
|
@@ -578,7 +592,7 @@
|
|
|
578
592
|
popover
|
|
579
593
|
role="listbox"
|
|
580
594
|
inert={!dropdownOpen}
|
|
581
|
-
class="
|
|
595
|
+
class="menu bg-base-100 rounded-box z-50 m-0 flex flex-col flex-nowrap gap-1 p-2 shadow outline"
|
|
582
596
|
style="position-anchor: {anchorName}; position: fixed; top: anchor(bottom); left: anchor(left); width: anchor-size(width);{dropdownMinWidth ? ` min-width: ${dropdownMinWidth};` : ''} margin-block: 0.5rem; position-try-fallbacks: flip-block;"
|
|
583
597
|
ontoggle={handlePopoverToggle}>
|
|
584
598
|
{#if multiple && filteredItems.length > 1}
|
|
@@ -695,3 +709,12 @@
|
|
|
695
709
|
{/if}
|
|
696
710
|
{/if}
|
|
697
711
|
</Label>
|
|
712
|
+
|
|
713
|
+
<style>
|
|
714
|
+
/* The `menu` DaisyUI class applies display:flex as an author style, which has higher
|
|
715
|
+
cascade priority than the UA stylesheet's display:none for closed [popover] elements.
|
|
716
|
+
This rule restores the correct hide behavior without relying on UA defaults. */
|
|
717
|
+
ul[popover]:not(:popover-open) {
|
|
718
|
+
display: none !important;
|
|
719
|
+
}
|
|
720
|
+
</style>
|
package/dist/Select.svelte.d.ts
CHANGED