@juspay/svelte-ui-components 4.55.4 → 4.57.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/Accordion/Accordion.svelte +66 -34
- package/dist/Accordion/Accordion.svelte.d.ts +1 -1
- package/dist/Accordion/properties.d.ts +11 -0
- package/dist/Avatar/Avatar.svelte +20 -6
- package/dist/Button/Button.svelte +34 -19
- package/dist/Button/Button.svelte.d.ts +1 -1
- package/dist/Button/properties.d.ts +10 -0
- package/dist/Card/Card.svelte +31 -18
- package/dist/Card/properties.d.ts +7 -0
- package/dist/Dialog/Dialog.svelte +186 -0
- package/dist/Dialog/Dialog.svelte.d.ts +4 -0
- package/dist/Dialog/properties.d.ts +23 -0
- package/dist/Dialog/properties.js +1 -0
- package/dist/DockPanel/DockPanel.svelte.d.ts +1 -1
- package/dist/EmptyState/EmptyState.svelte +58 -33
- package/dist/EmptyState/properties.d.ts +4 -0
- package/dist/FileInput/FileInput.svelte +130 -31
- package/dist/FileInput/FileInput.svelte.d.ts +1 -1
- package/dist/FileInput/properties.d.ts +9 -0
- package/dist/Icon/Icon.svelte +99 -21
- package/dist/Icon/properties.d.ts +8 -0
- package/dist/IframeViewer/IframeViewer.svelte +29 -5
- package/dist/IframeViewer/IframeViewer.svelte.d.ts +1 -1
- package/dist/IframeViewer/properties.d.ts +9 -0
- package/dist/Img/Img.svelte +31 -11
- package/dist/Img/Img.svelte.d.ts +1 -1
- package/dist/Img/properties.d.ts +13 -0
- package/dist/Input/Input.svelte +260 -170
- package/dist/Input/Input.svelte.d.ts +1 -1
- package/dist/Input/properties.d.ts +10 -0
- package/dist/Link/Link.svelte +33 -0
- package/dist/Link/Link.svelte.d.ts +4 -0
- package/dist/Link/properties.d.ts +14 -0
- package/dist/Link/properties.js +1 -0
- package/dist/Loader/Loader.svelte +50 -5
- package/dist/Loader/properties.d.ts +4 -0
- package/dist/MediaPlayer/MediaPlayer.svelte +223 -161
- package/dist/MediaPlayer/MediaPlayer.svelte.d.ts +1 -1
- package/dist/MediaPlayer/properties.d.ts +13 -0
- package/dist/Modal/Modal.svelte +52 -3
- package/dist/Modal/properties.d.ts +11 -0
- package/dist/NativeFileInput/NativeFileInput.svelte +52 -0
- package/dist/NativeFileInput/NativeFileInput.svelte.d.ts +6 -0
- package/dist/NativeFileInput/properties.d.ts +6 -0
- package/dist/NativeFileInput/properties.js +1 -0
- package/dist/Pill/Pill.svelte +7 -3
- package/dist/Pill/properties.d.ts +4 -0
- package/dist/Progress/Progress.svelte +46 -7
- package/dist/Progress/properties.d.ts +4 -0
- package/dist/Resizable/Resizable.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +535 -354
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/dropdownPosition.d.ts +2 -0
- package/dist/Select/dropdownPosition.js +3 -2
- package/dist/Select/properties.d.ts +11 -0
- package/dist/ThemeSwitcher/ThemeSwitcher.svelte +5 -0
- package/dist/_chart/ChartContainer.svelte.d.ts +1 -1
- package/dist/_field/form-reset.d.ts +2 -0
- package/dist/_field/form-reset.js +34 -0
- package/dist/_interaction/dismissal.d.ts +2 -0
- package/dist/_interaction/dismissal.js +7 -1
- package/dist/_interaction/focus.d.ts +1 -1
- package/dist/_interaction/focus.js +66 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/styles/theme-dark.css +4 -0
- package/dist-codemod/codemod/migration-assets/legacy-display.css +5 -2
- package/dist-codemod/codemod/migration-assets/legacy-palette.css +4 -1
- package/dist-codemod/codemod/migration-assets/wc-display.json +15 -0
- package/dist-wc/index.js +5301 -3252
- package/package.json +2 -2
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
import checkmarkSvg from '../assets/checkmark.svg?raw';
|
|
12
12
|
|
|
13
13
|
let {
|
|
14
|
+
native = false,
|
|
15
|
+
children,
|
|
16
|
+
required = false,
|
|
17
|
+
id,
|
|
18
|
+
nativeAttrs,
|
|
19
|
+
element = $bindable(),
|
|
14
20
|
items: rawItems,
|
|
15
21
|
value = $bindable([]),
|
|
16
22
|
multiple = false,
|
|
@@ -63,6 +69,8 @@
|
|
|
63
69
|
// Portal placement reads untracked DOM (trigger rect, viewport size); bump on
|
|
64
70
|
// scroll/resize so the derived style re-runs while the dropdown is open.
|
|
65
71
|
let portalTick = $state(0);
|
|
72
|
+
let portalTheme = $state('');
|
|
73
|
+
let portalCustomWidth = $state(false);
|
|
66
74
|
|
|
67
75
|
// Gap between trigger and portaled panel, matching the --select-dropdown-gap
|
|
68
76
|
// default. The in-flow panel still honours the CSS var via its margin-top.
|
|
@@ -247,6 +255,11 @@
|
|
|
247
255
|
return getLabel(firstId);
|
|
248
256
|
});
|
|
249
257
|
|
|
258
|
+
let triggerText = $derived.by(() => {
|
|
259
|
+
const compact = items.find((item) => item.id === value.at(0))?.displayLabel;
|
|
260
|
+
return typeof compact === 'string' && compact.trim().length > 0 ? compact : displayText;
|
|
261
|
+
});
|
|
262
|
+
|
|
250
263
|
let highlightedOptionId: string | null = $derived(
|
|
251
264
|
highlightedIndex >= 0 ? `${listboxId}-option-${highlightedIndex}` : null
|
|
252
265
|
);
|
|
@@ -295,6 +308,12 @@
|
|
|
295
308
|
* overflow/scroll ancestor between the two.
|
|
296
309
|
*/
|
|
297
310
|
const portalTarget = (node: Node): Node => {
|
|
311
|
+
// A native modal makes everything outside its subtree inert, regardless of
|
|
312
|
+
// z-index. Keep its popup in the same top layer, including mode changes.
|
|
313
|
+
const dialog = node instanceof Element ? node.closest('dialog') : null;
|
|
314
|
+
if (dialog) {
|
|
315
|
+
return dialog;
|
|
316
|
+
}
|
|
298
317
|
const root = node.getRootNode();
|
|
299
318
|
return root instanceof ShadowRoot ? root : document.body;
|
|
300
319
|
};
|
|
@@ -308,8 +327,68 @@
|
|
|
308
327
|
if (!usePortal) {
|
|
309
328
|
return;
|
|
310
329
|
}
|
|
330
|
+
const owner = containerEl ?? node.parentElement;
|
|
331
|
+
const widthProperties = new Set([
|
|
332
|
+
'--select-dropdown-width',
|
|
333
|
+
'--select-dropdown-min-width',
|
|
334
|
+
'--select-dropdown-max-width'
|
|
335
|
+
]);
|
|
336
|
+
const refreshTheme = () => {
|
|
337
|
+
if (!owner) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const style = getComputedStyle(owner);
|
|
341
|
+
portalCustomWidth = ['--select-dropdown-width', '--select-dropdown-min-width'].some(
|
|
342
|
+
(property) => {
|
|
343
|
+
const value = style.getPropertyValue(property).trim();
|
|
344
|
+
return value !== '' && value !== 'auto';
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
const declarations: string[] = [];
|
|
348
|
+
const triggerWidth =
|
|
349
|
+
triggerEl?.getBoundingClientRect().width ?? owner.getBoundingClientRect().width;
|
|
350
|
+
for (let index = 0; index < style.length; index++) {
|
|
351
|
+
const property = style.item(index);
|
|
352
|
+
if (property.startsWith('--select-')) {
|
|
353
|
+
const value = style.getPropertyValue(property);
|
|
354
|
+
// Percentages meant the select's containing block before portal adoption.
|
|
355
|
+
// Resolve those widths against its trigger, never the viewport/body.
|
|
356
|
+
const resolved = widthProperties.has(property)
|
|
357
|
+
? value.replace(
|
|
358
|
+
/([-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)%/gi,
|
|
359
|
+
(_match, percentage: string) => `${(Number(percentage) * triggerWidth) / 100}px`
|
|
360
|
+
)
|
|
361
|
+
: value;
|
|
362
|
+
declarations.push(`${property}:${resolved};`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
declarations.push(
|
|
366
|
+
`font-family:${style.fontFamily};font-size:${style.fontSize};font-weight:${style.fontWeight};line-height:${style.lineHeight};letter-spacing:${style.letterSpacing};color:${style.color};direction:${style.direction};text-align:${style.textAlign};`
|
|
367
|
+
);
|
|
368
|
+
portalTheme = declarations.join('');
|
|
369
|
+
};
|
|
370
|
+
refreshTheme();
|
|
371
|
+
const observer = new MutationObserver(refreshTheme);
|
|
372
|
+
let ancestor: Element | null = owner;
|
|
373
|
+
while (ancestor) {
|
|
374
|
+
observer.observe(ancestor, {
|
|
375
|
+
attributes: true,
|
|
376
|
+
attributeFilter: ['class', 'style', 'data-theme', 'dir']
|
|
377
|
+
});
|
|
378
|
+
const root = ancestor.getRootNode();
|
|
379
|
+
ancestor = ancestor.parentElement ?? (root instanceof ShadowRoot ? root.host : null);
|
|
380
|
+
}
|
|
381
|
+
window.addEventListener('resize', refreshTheme);
|
|
311
382
|
portalTarget(node).appendChild(node);
|
|
312
|
-
return {
|
|
383
|
+
return {
|
|
384
|
+
destroy: () => {
|
|
385
|
+
observer.disconnect();
|
|
386
|
+
window.removeEventListener('resize', refreshTheme);
|
|
387
|
+
portalTheme = '';
|
|
388
|
+
portalCustomWidth = false;
|
|
389
|
+
node.remove();
|
|
390
|
+
}
|
|
391
|
+
};
|
|
313
392
|
};
|
|
314
393
|
|
|
315
394
|
let portalPlacement = $derived.by(() => {
|
|
@@ -331,6 +410,7 @@
|
|
|
331
410
|
width: rect.width
|
|
332
411
|
},
|
|
333
412
|
dropdown: { width: dropdownWidth, height: dropdownHeight },
|
|
413
|
+
matchTriggerWidth: !portalCustomWidth,
|
|
334
414
|
viewport,
|
|
335
415
|
align: placementAlign,
|
|
336
416
|
/* Unset and explicit 'auto' placements keep the fit-based flip and viewport
|
|
@@ -351,7 +431,8 @@
|
|
|
351
431
|
return '';
|
|
352
432
|
}
|
|
353
433
|
const widthRule = placement.width === null ? '' : `width:${placement.width}px;`;
|
|
354
|
-
|
|
434
|
+
const minimumRule = `min-width:max(${placement.minWidth}px,var(--select-dropdown-min-width,0px));`;
|
|
435
|
+
return `top:${placement.top}px;left:${placement.left}px;${minimumRule}${widthRule}${portalTheme}`;
|
|
355
436
|
});
|
|
356
437
|
|
|
357
438
|
/* A portaled panel's side comes from the geometry, which still flips on fit
|
|
@@ -766,386 +847,476 @@
|
|
|
766
847
|
});
|
|
767
848
|
</script>
|
|
768
849
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
850
|
+
{#snippet nativeOptions()}
|
|
851
|
+
{#if children}
|
|
852
|
+
{@render children()}
|
|
853
|
+
{:else}
|
|
854
|
+
{#if placeholder}
|
|
855
|
+
<option value="" disabled selected={value.length === 0}>{placeholder}</option>
|
|
856
|
+
{/if}
|
|
857
|
+
{#each items as item (item.id)}
|
|
858
|
+
<option value={item.id} disabled={item.disabled} selected={value.includes(item.id)}
|
|
859
|
+
>{item.label}</option
|
|
860
|
+
>
|
|
861
|
+
{/each}
|
|
862
|
+
{/if}
|
|
863
|
+
{/snippet}
|
|
864
|
+
|
|
865
|
+
{#if native}
|
|
866
|
+
{#if multiple}
|
|
867
|
+
<select
|
|
868
|
+
class:select-native={true}
|
|
869
|
+
{...nativeAttrs}
|
|
870
|
+
bind:this={element}
|
|
871
|
+
{id}
|
|
872
|
+
{name}
|
|
873
|
+
multiple
|
|
874
|
+
{required}
|
|
875
|
+
{disabled}
|
|
876
|
+
class={classes ?? ''}
|
|
877
|
+
aria-label={ariaLabel ?? null}
|
|
878
|
+
aria-labelledby={ariaLabelledby ?? null}
|
|
879
|
+
data-pw={testId}
|
|
880
|
+
bind:value={
|
|
881
|
+
() => value,
|
|
882
|
+
(selected) => {
|
|
883
|
+
value = typeof selected === 'string' ? [selected] : selected;
|
|
884
|
+
onchange?.(value);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
>
|
|
888
|
+
{@render nativeOptions()}
|
|
889
|
+
</select>
|
|
890
|
+
{:else}
|
|
891
|
+
<select
|
|
892
|
+
class:select-native={true}
|
|
893
|
+
{...nativeAttrs}
|
|
894
|
+
bind:this={element}
|
|
895
|
+
{id}
|
|
896
|
+
{name}
|
|
897
|
+
{required}
|
|
898
|
+
{disabled}
|
|
899
|
+
class={classes ?? ''}
|
|
900
|
+
aria-label={ariaLabel ?? null}
|
|
901
|
+
aria-labelledby={ariaLabelledby ?? null}
|
|
902
|
+
data-pw={testId}
|
|
903
|
+
bind:value={
|
|
904
|
+
() => value[0] ?? '',
|
|
905
|
+
(selected) => {
|
|
906
|
+
value = typeof selected === 'string' ? [selected] : selected;
|
|
907
|
+
onchange?.(value);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
>
|
|
911
|
+
{@render nativeOptions()}
|
|
912
|
+
</select>
|
|
913
|
+
{/if}
|
|
914
|
+
{:else}
|
|
915
|
+
<div
|
|
916
|
+
class="select {classes ?? ''}"
|
|
917
|
+
class:open
|
|
918
|
+
class:disabled
|
|
919
|
+
class:error
|
|
920
|
+
class:ghost={hierarchy === 'ghost'}
|
|
921
|
+
bind:this={containerEl}
|
|
922
|
+
{...typeof testId === 'string' ? { 'data-pw': testId, testID: testId } : {}}
|
|
923
|
+
>
|
|
924
|
+
{#if typeof name === 'string' && name.length > 0}
|
|
925
|
+
<!-- No native <select> exists to carry `name`/`value` -- this is a custom
|
|
780
926
|
combobox/listbox. One hidden input per selected id mirrors a native
|
|
781
927
|
`<select multiple>`, which likewise submits one FormData entry per
|
|
782
928
|
selected <option> under the same name; `disabled` matches native
|
|
783
929
|
behaviour by excluding all of them from the submission. -->
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
930
|
+
{#each value as id (id)}
|
|
931
|
+
<input type="hidden" {name} value={id} {disabled} />
|
|
932
|
+
{/each}
|
|
933
|
+
{/if}
|
|
934
|
+
<div class="select-control" class:has-clear={showClearButton}>
|
|
935
|
+
<div
|
|
936
|
+
class="select-trigger"
|
|
937
|
+
bind:this={triggerEl}
|
|
938
|
+
onclick={handleTriggerClick}
|
|
939
|
+
onkeydown={handleKeydown}
|
|
940
|
+
role="combobox"
|
|
941
|
+
aria-expanded={open}
|
|
942
|
+
aria-haspopup="listbox"
|
|
943
|
+
aria-controls={listboxId}
|
|
944
|
+
aria-label={accessibleName}
|
|
945
|
+
aria-labelledby={accessibleLabelledby}
|
|
946
|
+
aria-disabled={disabled ? 'true' : null}
|
|
947
|
+
aria-invalid={field.ariaInvalid}
|
|
948
|
+
aria-describedby={field.describedBy}
|
|
949
|
+
{...highlightedOptionId !== null ? { 'aria-activedescendant': highlightedOptionId } : {}}
|
|
950
|
+
tabindex={disabled ? -1 : searchInTrigger ? -1 : 0}
|
|
951
|
+
>
|
|
952
|
+
{#if typeof leftIcon === 'string' && leftIcon.length > 0}
|
|
953
|
+
<Img
|
|
954
|
+
inlineSvg
|
|
955
|
+
src={leftIcon}
|
|
956
|
+
alt=""
|
|
957
|
+
fallback=""
|
|
958
|
+
classes="select-left-icon"
|
|
959
|
+
{...typeof leftIconTestId === 'string' ? { testId: leftIconTestId } : {}}
|
|
960
|
+
/>
|
|
961
|
+
{/if}
|
|
962
|
+
{#if multiple}
|
|
963
|
+
{#if typeof triggerSummary === 'function'}
|
|
964
|
+
{@render triggerSummary({ value, items })}
|
|
965
|
+
{#if searchInTrigger}
|
|
966
|
+
<input
|
|
967
|
+
class="select-search"
|
|
968
|
+
type="text"
|
|
969
|
+
value={query}
|
|
970
|
+
oninput={handleSearchInput}
|
|
971
|
+
onfocus={handleSearchFocus}
|
|
972
|
+
bind:this={searchInputEl}
|
|
973
|
+
placeholder={value.length === 0 ? placeholder : ''}
|
|
974
|
+
{disabled}
|
|
975
|
+
aria-label={accessibleName}
|
|
976
|
+
aria-labelledby={accessibleLabelledby}
|
|
977
|
+
aria-invalid={field.ariaInvalid}
|
|
978
|
+
aria-describedby={field.describedBy}
|
|
979
|
+
autocomplete="off"
|
|
980
|
+
tabindex={disabled ? -1 : 0}
|
|
981
|
+
data-pw={typeof testId === 'string' ? `${testId}-search` : null}
|
|
982
|
+
testID={typeof testId === 'string' ? `${testId}-search` : null}
|
|
983
|
+
/>
|
|
984
|
+
{/if}
|
|
985
|
+
{:else}
|
|
986
|
+
{#each value as id (id)}
|
|
987
|
+
<Pill
|
|
988
|
+
text={getLabel(id)}
|
|
989
|
+
dismissible
|
|
990
|
+
{disabled}
|
|
991
|
+
ondismiss={() => removeItem(id)}
|
|
992
|
+
{...typeof testId === 'string' ? { testId: `${testId}-pill-${id}` } : {}}
|
|
993
|
+
/>
|
|
994
|
+
{/each}
|
|
995
|
+
{#if searchInTrigger}
|
|
996
|
+
<input
|
|
997
|
+
class="select-search"
|
|
998
|
+
type="text"
|
|
999
|
+
value={query}
|
|
1000
|
+
oninput={handleSearchInput}
|
|
1001
|
+
onfocus={handleSearchFocus}
|
|
1002
|
+
bind:this={searchInputEl}
|
|
1003
|
+
placeholder={value.length === 0 ? placeholder : ''}
|
|
1004
|
+
{disabled}
|
|
1005
|
+
aria-label={accessibleName}
|
|
1006
|
+
aria-labelledby={accessibleLabelledby}
|
|
1007
|
+
aria-invalid={field.ariaInvalid}
|
|
1008
|
+
aria-describedby={field.describedBy}
|
|
1009
|
+
autocomplete="off"
|
|
1010
|
+
tabindex={disabled ? -1 : 0}
|
|
1011
|
+
data-pw={typeof testId === 'string' ? `${testId}-search` : null}
|
|
1012
|
+
testID={typeof testId === 'string' ? `${testId}-search` : null}
|
|
1013
|
+
/>
|
|
1014
|
+
{:else if value.length === 0}
|
|
1015
|
+
<span class="select-placeholder">{placeholder}</span>
|
|
1016
|
+
{/if}
|
|
838
1017
|
{/if}
|
|
1018
|
+
{:else if searchInTrigger}
|
|
1019
|
+
<input
|
|
1020
|
+
class="select-search"
|
|
1021
|
+
type="text"
|
|
1022
|
+
value={open ? query : displayText}
|
|
1023
|
+
oninput={handleSearchInput}
|
|
1024
|
+
onfocus={handleSearchFocus}
|
|
1025
|
+
bind:this={searchInputEl}
|
|
1026
|
+
placeholder={searchPlaceholder}
|
|
1027
|
+
{disabled}
|
|
1028
|
+
aria-label={accessibleName}
|
|
1029
|
+
aria-labelledby={accessibleLabelledby}
|
|
1030
|
+
aria-invalid={field.ariaInvalid}
|
|
1031
|
+
aria-describedby={field.describedBy}
|
|
1032
|
+
autocomplete="off"
|
|
1033
|
+
tabindex={disabled ? -1 : 0}
|
|
1034
|
+
data-pw={typeof testId === 'string' ? `${testId}-search` : null}
|
|
1035
|
+
testID={typeof testId === 'string' ? `${testId}-search` : null}
|
|
1036
|
+
/>
|
|
839
1037
|
{:else}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
<input
|
|
851
|
-
class="select-search"
|
|
852
|
-
type="text"
|
|
853
|
-
value={query}
|
|
854
|
-
oninput={handleSearchInput}
|
|
855
|
-
onfocus={handleSearchFocus}
|
|
856
|
-
bind:this={searchInputEl}
|
|
857
|
-
placeholder={value.length === 0 ? placeholder : ''}
|
|
858
|
-
{disabled}
|
|
859
|
-
aria-label={accessibleName}
|
|
860
|
-
aria-labelledby={accessibleLabelledby}
|
|
861
|
-
aria-invalid={field.ariaInvalid}
|
|
862
|
-
aria-describedby={field.describedBy}
|
|
863
|
-
autocomplete="off"
|
|
864
|
-
tabindex={disabled ? -1 : 0}
|
|
865
|
-
data-pw={typeof testId === 'string' ? `${testId}-search` : null}
|
|
866
|
-
testID={typeof testId === 'string' ? `${testId}-search` : null}
|
|
867
|
-
/>
|
|
868
|
-
{:else if value.length === 0}
|
|
869
|
-
<span class="select-placeholder">{placeholder}</span>
|
|
870
|
-
{/if}
|
|
1038
|
+
<span
|
|
1039
|
+
class={displayText.length > 0 ? 'select-value' : 'select-placeholder'}
|
|
1040
|
+
title={triggerText !== displayText ? displayText : void 0}
|
|
1041
|
+
>
|
|
1042
|
+
{#if displayText.length > 0 && triggerText !== displayText}
|
|
1043
|
+
<span aria-hidden="true">{triggerText}</span><span class="select-a11y-value"
|
|
1044
|
+
>{displayText}</span
|
|
1045
|
+
>
|
|
1046
|
+
{:else}{displayText.length > 0 ? displayText : placeholder}{/if}
|
|
1047
|
+
</span>
|
|
871
1048
|
{/if}
|
|
872
|
-
|
|
873
|
-
<
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
{:else}
|
|
892
|
-
<span class={displayText.length > 0 ? 'select-value' : 'select-placeholder'}>
|
|
893
|
-
{displayText.length > 0 ? displayText : placeholder}
|
|
894
|
-
</span>
|
|
1049
|
+
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
1050
|
+
<span class="select-arrow">{@html chevronDownSvg}</span>
|
|
1051
|
+
</div>
|
|
1052
|
+
{#if showClearButton}
|
|
1053
|
+
<button
|
|
1054
|
+
type="button"
|
|
1055
|
+
class="select-clear"
|
|
1056
|
+
aria-label="Clear selection"
|
|
1057
|
+
onkeydown={(event) => {
|
|
1058
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1059
|
+
event.stopPropagation();
|
|
1060
|
+
}
|
|
1061
|
+
}}
|
|
1062
|
+
onclick={handleClear}
|
|
1063
|
+
data-pw={typeof testId === 'string' ? `${testId}-clear` : null}
|
|
1064
|
+
testID={typeof testId === 'string' ? `${testId}-clear` : null}
|
|
1065
|
+
>
|
|
1066
|
+
<span aria-hidden="true">×</span>
|
|
1067
|
+
</button>
|
|
895
1068
|
{/if}
|
|
896
|
-
<!-- eslint-disable svelte/no-at-html-tags -->
|
|
897
|
-
<span class="select-arrow">{@html chevronDownSvg}</span>
|
|
898
1069
|
</div>
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
}}
|
|
909
|
-
onclick={handleClear}
|
|
910
|
-
data-pw={typeof testId === 'string' ? `${testId}-clear` : null}
|
|
911
|
-
testID={typeof testId === 'string' ? `${testId}-clear` : null}
|
|
1070
|
+
|
|
1071
|
+
{#if field.showsError}
|
|
1072
|
+
<div
|
|
1073
|
+
id={field.errorId}
|
|
1074
|
+
role="alert"
|
|
1075
|
+
class="select-error-message"
|
|
1076
|
+
data-pw={typeof testId === 'string' ? `${testId}-error-message` : null}
|
|
1077
|
+
testID={typeof testId === 'string' ? `${testId}-error-message` : null}
|
|
912
1078
|
>
|
|
913
|
-
|
|
914
|
-
</
|
|
1079
|
+
{errorMessage}
|
|
1080
|
+
</div>
|
|
915
1081
|
{/if}
|
|
916
|
-
</div>
|
|
917
1082
|
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
id={`${listboxId}-option-${index}`}
|
|
943
|
-
aria-selected={allFilteredSelected}
|
|
944
|
-
aria-label={selectAllIndeterminate
|
|
945
|
-
? `${selectAllLabel}, ${selectedFilteredCount} of ${filteredItems.length} selected`
|
|
946
|
-
: selectAllLabel}
|
|
947
|
-
tabindex="-1"
|
|
948
|
-
{...typeof testId === 'string'
|
|
949
|
-
? { 'data-pw': `${testId}-select-all`, testID: `${testId}-select-all` }
|
|
950
|
-
: {}}
|
|
951
|
-
onclick={toggleSelectAll}
|
|
952
|
-
onmouseenter={() => (highlightedIndex = index)}
|
|
953
|
-
>
|
|
954
|
-
{#if typeof optionIndicator === 'function'}
|
|
955
|
-
{@render optionIndicator({
|
|
956
|
-
checked: allFilteredSelected,
|
|
957
|
-
indeterminate: selectAllIndeterminate
|
|
958
|
-
})}
|
|
959
|
-
{:else}
|
|
960
|
-
<span
|
|
961
|
-
class="select-option-indicator"
|
|
962
|
-
class:checked={allFilteredSelected}
|
|
963
|
-
class:indeterminate={selectAllIndeterminate}
|
|
964
|
-
aria-hidden="true"
|
|
965
|
-
data-checked={allFilteredSelected ? 'true' : 'false'}
|
|
966
|
-
data-pw={typeof testId === 'string' ? `${testId}-select-all-indicator` : null}
|
|
967
|
-
testID={typeof testId === 'string' ? `${testId}-select-all-indicator` : null}
|
|
968
|
-
>
|
|
969
|
-
{#if allFilteredSelected}
|
|
970
|
-
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
971
|
-
<span class="select-option-check">{@html checkmarkSvg}</span>
|
|
972
|
-
{:else if selectAllIndeterminate}
|
|
973
|
-
<span
|
|
974
|
-
class="select-option-dash"
|
|
975
|
-
data-pw={typeof testId === 'string' ? `${testId}-select-all-dash` : null}
|
|
976
|
-
testID={typeof testId === 'string' ? `${testId}-select-all-dash` : null}
|
|
977
|
-
></span>
|
|
978
|
-
{/if}
|
|
979
|
-
</span>
|
|
980
|
-
{/if}
|
|
981
|
-
{selectAllLabel}
|
|
982
|
-
</div>
|
|
983
|
-
{:else}
|
|
984
|
-
<div
|
|
985
|
-
class="select-option"
|
|
986
|
-
class:multi={multiple}
|
|
987
|
-
class:tickable={showSelectedTick && !multiple}
|
|
988
|
-
class:selected={value.includes(row.item.id)}
|
|
989
|
-
class:highlighted={index === highlightedIndex}
|
|
990
|
-
class:select-option-disabled={row.item.disabled === true}
|
|
991
|
-
role="option"
|
|
992
|
-
id={`${listboxId}-option-${index}`}
|
|
993
|
-
aria-selected={value.includes(row.item.id)}
|
|
994
|
-
aria-disabled={row.item.disabled === true ? 'true' : null}
|
|
995
|
-
tabindex="-1"
|
|
996
|
-
{...typeof row.item.testId === 'string'
|
|
997
|
-
? { 'data-pw': row.item.testId, testID: row.item.testId }
|
|
998
|
-
: typeof itemTestId === 'string'
|
|
999
|
-
? {
|
|
1000
|
-
'data-pw': `${itemTestId}-${row.item.id}`,
|
|
1001
|
-
testID: `${itemTestId}-${row.item.id}`
|
|
1002
|
-
}
|
|
1003
|
-
: typeof testId === 'string'
|
|
1004
|
-
? { 'data-pw': `${testId}-${row.item.id}`, testID: `${testId}-${row.item.id}` }
|
|
1005
|
-
: {}}
|
|
1006
|
-
onclick={() => selectItem(row.item.id)}
|
|
1007
|
-
onmouseenter={() => {
|
|
1008
|
-
if (row.item.disabled !== true) {
|
|
1009
|
-
highlightedIndex = index;
|
|
1010
|
-
}
|
|
1011
|
-
}}
|
|
1012
|
-
>
|
|
1013
|
-
{#if multiple}
|
|
1083
|
+
{#snippet menuOptions()}
|
|
1084
|
+
{#if filteredItems.length === 0}
|
|
1085
|
+
<div class="select-empty">No results</div>
|
|
1086
|
+
{:else}
|
|
1087
|
+
{#each optionRows as row, index (row.kind === 'select-all' ? 'select-all' : row.item.id)}
|
|
1088
|
+
{#if row.kind === 'select-all'}
|
|
1089
|
+
<div
|
|
1090
|
+
class="select-option select-all"
|
|
1091
|
+
class:multi={multiple}
|
|
1092
|
+
class:selected={allFilteredSelected}
|
|
1093
|
+
class:highlighted={index === highlightedIndex}
|
|
1094
|
+
role="option"
|
|
1095
|
+
id={`${listboxId}-option-${index}`}
|
|
1096
|
+
aria-selected={allFilteredSelected}
|
|
1097
|
+
aria-label={selectAllIndeterminate
|
|
1098
|
+
? `${selectAllLabel}, ${selectedFilteredCount} of ${filteredItems.length} selected`
|
|
1099
|
+
: selectAllLabel}
|
|
1100
|
+
tabindex="-1"
|
|
1101
|
+
{...typeof testId === 'string'
|
|
1102
|
+
? { 'data-pw': `${testId}-select-all`, testID: `${testId}-select-all` }
|
|
1103
|
+
: {}}
|
|
1104
|
+
onclick={toggleSelectAll}
|
|
1105
|
+
onmouseenter={() => (highlightedIndex = index)}
|
|
1106
|
+
>
|
|
1014
1107
|
{#if typeof optionIndicator === 'function'}
|
|
1015
1108
|
{@render optionIndicator({
|
|
1016
|
-
checked:
|
|
1017
|
-
indeterminate:
|
|
1109
|
+
checked: allFilteredSelected,
|
|
1110
|
+
indeterminate: selectAllIndeterminate
|
|
1018
1111
|
})}
|
|
1019
1112
|
{:else}
|
|
1020
1113
|
<span
|
|
1021
1114
|
class="select-option-indicator"
|
|
1022
|
-
class:checked={
|
|
1115
|
+
class:checked={allFilteredSelected}
|
|
1116
|
+
class:indeterminate={selectAllIndeterminate}
|
|
1023
1117
|
aria-hidden="true"
|
|
1024
|
-
data-checked={
|
|
1025
|
-
data-pw={typeof testId === 'string'
|
|
1026
|
-
|
|
1027
|
-
: null}
|
|
1028
|
-
testID={typeof testId === 'string'
|
|
1029
|
-
? `${testId}-option-indicator-${row.item.id}`
|
|
1030
|
-
: null}
|
|
1118
|
+
data-checked={allFilteredSelected ? 'true' : 'false'}
|
|
1119
|
+
data-pw={typeof testId === 'string' ? `${testId}-select-all-indicator` : null}
|
|
1120
|
+
testID={typeof testId === 'string' ? `${testId}-select-all-indicator` : null}
|
|
1031
1121
|
>
|
|
1032
|
-
{#if
|
|
1122
|
+
{#if allFilteredSelected}
|
|
1033
1123
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
1034
1124
|
<span class="select-option-check">{@html checkmarkSvg}</span>
|
|
1125
|
+
{:else if selectAllIndeterminate}
|
|
1126
|
+
<span
|
|
1127
|
+
class="select-option-dash"
|
|
1128
|
+
data-pw={typeof testId === 'string' ? `${testId}-select-all-dash` : null}
|
|
1129
|
+
testID={typeof testId === 'string' ? `${testId}-select-all-dash` : null}
|
|
1130
|
+
></span>
|
|
1035
1131
|
{/if}
|
|
1036
1132
|
</span>
|
|
1037
1133
|
{/if}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1134
|
+
{selectAllLabel}
|
|
1135
|
+
</div>
|
|
1136
|
+
{:else}
|
|
1137
|
+
<div
|
|
1138
|
+
class="select-option"
|
|
1139
|
+
class:multi={multiple}
|
|
1140
|
+
class:tickable={showSelectedTick && !multiple}
|
|
1141
|
+
class:selected={value.includes(row.item.id)}
|
|
1142
|
+
class:highlighted={index === highlightedIndex}
|
|
1143
|
+
class:select-option-disabled={row.item.disabled === true}
|
|
1144
|
+
role="option"
|
|
1145
|
+
id={`${listboxId}-option-${index}`}
|
|
1146
|
+
aria-selected={value.includes(row.item.id)}
|
|
1147
|
+
aria-disabled={row.item.disabled === true ? 'true' : null}
|
|
1148
|
+
tabindex="-1"
|
|
1149
|
+
{...typeof row.item.testId === 'string'
|
|
1150
|
+
? { 'data-pw': row.item.testId, testID: row.item.testId }
|
|
1151
|
+
: typeof itemTestId === 'string'
|
|
1152
|
+
? {
|
|
1153
|
+
'data-pw': `${itemTestId}-${row.item.id}`,
|
|
1154
|
+
testID: `${itemTestId}-${row.item.id}`
|
|
1155
|
+
}
|
|
1156
|
+
: typeof testId === 'string'
|
|
1157
|
+
? { 'data-pw': `${testId}-${row.item.id}`, testID: `${testId}-${row.item.id}` }
|
|
1158
|
+
: {}}
|
|
1159
|
+
onclick={() => selectItem(row.item.id)}
|
|
1160
|
+
onmouseenter={() => {
|
|
1161
|
+
if (row.item.disabled !== true) {
|
|
1162
|
+
highlightedIndex = index;
|
|
1163
|
+
}
|
|
1164
|
+
}}
|
|
1165
|
+
>
|
|
1166
|
+
{#if multiple}
|
|
1167
|
+
{#if typeof optionIndicator === 'function'}
|
|
1168
|
+
{@render optionIndicator({
|
|
1169
|
+
checked: value.includes(row.item.id),
|
|
1170
|
+
indeterminate: false
|
|
1171
|
+
})}
|
|
1172
|
+
{:else}
|
|
1173
|
+
<span
|
|
1174
|
+
class="select-option-indicator"
|
|
1175
|
+
class:checked={value.includes(row.item.id)}
|
|
1176
|
+
aria-hidden="true"
|
|
1177
|
+
data-checked={value.includes(row.item.id) ? 'true' : 'false'}
|
|
1178
|
+
data-pw={typeof testId === 'string'
|
|
1179
|
+
? `${testId}-option-indicator-${row.item.id}`
|
|
1180
|
+
: null}
|
|
1181
|
+
testID={typeof testId === 'string'
|
|
1182
|
+
? `${testId}-option-indicator-${row.item.id}`
|
|
1183
|
+
: null}
|
|
1184
|
+
>
|
|
1185
|
+
{#if value.includes(row.item.id)}
|
|
1186
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
1187
|
+
<span class="select-option-check">{@html checkmarkSvg}</span>
|
|
1188
|
+
{/if}
|
|
1189
|
+
</span>
|
|
1190
|
+
{/if}
|
|
1191
|
+
{/if}
|
|
1192
|
+
{#if typeof row.item.icon === 'string' && row.item.icon.length > 0}
|
|
1193
|
+
<Img
|
|
1194
|
+
inlineSvg
|
|
1195
|
+
src={row.item.icon}
|
|
1196
|
+
alt=""
|
|
1197
|
+
fallback=""
|
|
1198
|
+
classes="select-option-icon"
|
|
1199
|
+
/>
|
|
1200
|
+
{/if}
|
|
1201
|
+
<span class="select-option-label">{row.item.label}</span>
|
|
1202
|
+
{#if showSelectedTick && !multiple && value.includes(row.item.id)}
|
|
1203
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
1204
|
+
<span class="select-option-tick" aria-hidden="true">{@html checkmarkSvg}</span>
|
|
1205
|
+
{/if}
|
|
1206
|
+
</div>
|
|
1207
|
+
{/if}
|
|
1208
|
+
{/each}
|
|
1209
|
+
{/if}
|
|
1210
|
+
{#if typeof bottomContent === 'function' && !searchInMenu}
|
|
1211
|
+
<div class="select-bottom-content">
|
|
1212
|
+
{@render bottomContent()}
|
|
1213
|
+
</div>
|
|
1214
|
+
{/if}
|
|
1215
|
+
{/snippet}
|
|
1057
1216
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1217
|
+
{#if open && !disabled}
|
|
1218
|
+
{#if searchInMenu}
|
|
1219
|
+
<!-- The panel itself carries no role here: a listbox may only contain
|
|
1061
1220
|
options, so the search box has to be a SIBLING of the listbox rather
|
|
1062
1221
|
than a child of it. `aria-controls` on the trigger still points at
|
|
1063
1222
|
the inner element that actually holds the options. -->
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1223
|
+
<div
|
|
1224
|
+
class="select-dropdown"
|
|
1225
|
+
class:select-dropdown-right={placementAlign === 'right'}
|
|
1226
|
+
class:select-dropdown-up={!usePortal &&
|
|
1227
|
+
(effectivePlacement === 'top-left' || effectivePlacement === 'top-right')}
|
|
1228
|
+
class:select-dropdown-measuring={measuringPlacement}
|
|
1229
|
+
class:select-dropdown-portal={usePortal}
|
|
1230
|
+
data-placement={effectivePlacement}
|
|
1231
|
+
use:resolveAutoPlacementOnMount
|
|
1232
|
+
bind:this={dropdownEl}
|
|
1233
|
+
bind:clientWidth={dropdownWidth}
|
|
1234
|
+
bind:clientHeight={dropdownHeight}
|
|
1235
|
+
style={portalStyle}
|
|
1236
|
+
use:menuKeys
|
|
1237
|
+
use:portalToRoot
|
|
1238
|
+
use:dismissalAction
|
|
1239
|
+
>
|
|
1240
|
+
<input
|
|
1241
|
+
class="select-menu-search"
|
|
1242
|
+
type="search"
|
|
1243
|
+
value={query}
|
|
1244
|
+
oninput={handleSearchInput}
|
|
1245
|
+
onkeydown={handleKeydown}
|
|
1246
|
+
bind:this={searchInputEl}
|
|
1247
|
+
placeholder={placeholder.length > 0 ? placeholder : 'Search'}
|
|
1248
|
+
aria-label="Search options"
|
|
1249
|
+
aria-controls={listboxId}
|
|
1250
|
+
autocomplete="off"
|
|
1251
|
+
data-pw={typeof testId === 'string' ? `${testId}-menu-search` : null}
|
|
1252
|
+
testID={typeof testId === 'string' ? `${testId}-menu-search` : null}
|
|
1253
|
+
/>
|
|
1254
|
+
<!-- tabindex="-1" because the list scrolls, and a scroll container is
|
|
1096
1255
|
a tab stop of its own in Chromium -- which swallowed the Tab that
|
|
1097
1256
|
should reach the pinned bottom actions. The options are navigated
|
|
1098
1257
|
from the search box via aria-activedescendant, so the list itself
|
|
1099
1258
|
never needs to hold focus. -->
|
|
1259
|
+
<div
|
|
1260
|
+
class="select-menu-list"
|
|
1261
|
+
role="listbox"
|
|
1262
|
+
id={listboxId}
|
|
1263
|
+
aria-label={accessibleName}
|
|
1264
|
+
aria-labelledby={accessibleLabelledby}
|
|
1265
|
+
aria-multiselectable={multiple}
|
|
1266
|
+
tabindex="-1"
|
|
1267
|
+
>
|
|
1268
|
+
{@render menuOptions()}
|
|
1269
|
+
</div>
|
|
1270
|
+
{#if typeof bottomContent === 'function'}
|
|
1271
|
+
<!-- Outside the listbox: a listbox may only contain options, so
|
|
1272
|
+
pinned actions (clear-all, apply) would be invalid children and
|
|
1273
|
+
assistive tech would announce them as options. -->
|
|
1274
|
+
<div class="select-bottom-content">
|
|
1275
|
+
{@render bottomContent()}
|
|
1276
|
+
</div>
|
|
1277
|
+
{/if}
|
|
1278
|
+
</div>
|
|
1279
|
+
{:else}
|
|
1100
1280
|
<div
|
|
1101
|
-
class="select-
|
|
1281
|
+
class="select-dropdown"
|
|
1282
|
+
class:select-dropdown-right={placementAlign === 'right'}
|
|
1283
|
+
class:select-dropdown-up={!usePortal &&
|
|
1284
|
+
(effectivePlacement === 'top-left' || effectivePlacement === 'top-right')}
|
|
1285
|
+
class:select-dropdown-measuring={measuringPlacement}
|
|
1286
|
+
class:select-dropdown-portal={usePortal}
|
|
1287
|
+
data-placement={effectivePlacement}
|
|
1288
|
+
use:resolveAutoPlacementOnMount
|
|
1289
|
+
bind:this={dropdownEl}
|
|
1290
|
+
bind:clientWidth={dropdownWidth}
|
|
1291
|
+
bind:clientHeight={dropdownHeight}
|
|
1102
1292
|
role="listbox"
|
|
1103
1293
|
id={listboxId}
|
|
1104
1294
|
aria-label={accessibleName}
|
|
1105
1295
|
aria-labelledby={accessibleLabelledby}
|
|
1106
1296
|
aria-multiselectable={multiple}
|
|
1107
|
-
|
|
1297
|
+
style={portalStyle}
|
|
1298
|
+
use:portalToRoot
|
|
1299
|
+
use:dismissalAction
|
|
1108
1300
|
>
|
|
1109
1301
|
{@render menuOptions()}
|
|
1110
1302
|
</div>
|
|
1111
|
-
|
|
1112
|
-
<!-- Outside the listbox: a listbox may only contain options, so
|
|
1113
|
-
pinned actions (clear-all, apply) would be invalid children and
|
|
1114
|
-
assistive tech would announce them as options. -->
|
|
1115
|
-
<div class="select-bottom-content">
|
|
1116
|
-
{@render bottomContent()}
|
|
1117
|
-
</div>
|
|
1118
|
-
{/if}
|
|
1119
|
-
</div>
|
|
1120
|
-
{:else}
|
|
1121
|
-
<div
|
|
1122
|
-
class="select-dropdown"
|
|
1123
|
-
class:select-dropdown-right={placementAlign === 'right'}
|
|
1124
|
-
class:select-dropdown-up={!usePortal &&
|
|
1125
|
-
(effectivePlacement === 'top-left' || effectivePlacement === 'top-right')}
|
|
1126
|
-
class:select-dropdown-measuring={measuringPlacement}
|
|
1127
|
-
class:select-dropdown-portal={usePortal}
|
|
1128
|
-
data-placement={effectivePlacement}
|
|
1129
|
-
use:resolveAutoPlacementOnMount
|
|
1130
|
-
bind:this={dropdownEl}
|
|
1131
|
-
bind:clientWidth={dropdownWidth}
|
|
1132
|
-
bind:clientHeight={dropdownHeight}
|
|
1133
|
-
role="listbox"
|
|
1134
|
-
id={listboxId}
|
|
1135
|
-
aria-label={accessibleName}
|
|
1136
|
-
aria-labelledby={accessibleLabelledby}
|
|
1137
|
-
aria-multiselectable={multiple}
|
|
1138
|
-
style={portalStyle}
|
|
1139
|
-
use:portalToRoot
|
|
1140
|
-
use:dismissalAction
|
|
1141
|
-
>
|
|
1142
|
-
{@render menuOptions()}
|
|
1143
|
-
</div>
|
|
1303
|
+
{/if}
|
|
1144
1304
|
{/if}
|
|
1145
|
-
|
|
1146
|
-
|
|
1305
|
+
</div>
|
|
1306
|
+
{/if}
|
|
1147
1307
|
|
|
1148
1308
|
<style>
|
|
1309
|
+
.select-a11y-value {
|
|
1310
|
+
position: absolute;
|
|
1311
|
+
width: 1px;
|
|
1312
|
+
height: 1px;
|
|
1313
|
+
padding: 0;
|
|
1314
|
+
margin: -1px;
|
|
1315
|
+
overflow: hidden;
|
|
1316
|
+
clip-path: inset(50%);
|
|
1317
|
+
white-space: nowrap;
|
|
1318
|
+
border: 0;
|
|
1319
|
+
}
|
|
1149
1320
|
.select {
|
|
1150
1321
|
position: relative;
|
|
1151
1322
|
width: var(--select-width, 100%);
|
|
@@ -1160,7 +1331,7 @@
|
|
|
1160
1331
|
pointer-events: none;
|
|
1161
1332
|
}
|
|
1162
1333
|
|
|
1163
|
-
.select-trigger {
|
|
1334
|
+
.select-trigger:where(:not(.select-native)) {
|
|
1164
1335
|
display: flex;
|
|
1165
1336
|
flex-wrap: wrap;
|
|
1166
1337
|
align-items: center;
|
|
@@ -1190,7 +1361,7 @@
|
|
|
1190
1361
|
);
|
|
1191
1362
|
}
|
|
1192
1363
|
|
|
1193
|
-
.select-trigger :global(.select-left-icon) {
|
|
1364
|
+
.select-trigger:where(:not(.select-native)) :global(.select-left-icon) {
|
|
1194
1365
|
--image-width: var(--select-left-icon-size, 16px);
|
|
1195
1366
|
--image-height: var(--select-left-icon-size, 16px);
|
|
1196
1367
|
--image-object-fit: contain;
|
|
@@ -1204,12 +1375,14 @@
|
|
|
1204
1375
|
flex: none;
|
|
1205
1376
|
}
|
|
1206
1377
|
|
|
1207
|
-
.select-trigger:
|
|
1378
|
+
.select-trigger:where(:not(.select-native)):hover:not(
|
|
1379
|
+
.disabled .select-trigger:where(:not(.select-native))
|
|
1380
|
+
) {
|
|
1208
1381
|
border-color: var(--select-trigger-hover-border-color, #999999);
|
|
1209
1382
|
}
|
|
1210
1383
|
|
|
1211
|
-
.select-trigger:focus-within,
|
|
1212
|
-
.select.open .select-trigger {
|
|
1384
|
+
.select-trigger:where(:not(.select-native)):focus-within,
|
|
1385
|
+
.select.open .select-trigger:where(:not(.select-native)) {
|
|
1213
1386
|
border-color: var(--select-trigger-focus-border-color, #2563eb);
|
|
1214
1387
|
box-shadow: var(--select-trigger-focus-shadow, 0 0 0 2px rgba(37, 99, 235, 0.2));
|
|
1215
1388
|
}
|
|
@@ -1217,7 +1390,7 @@
|
|
|
1217
1390
|
/* Pressed feedback on the trigger. `:active` only, so it lasts exactly as
|
|
1218
1391
|
long as the pointer is down and never lingers as a stuck state the way a
|
|
1219
1392
|
class-driven one can. */
|
|
1220
|
-
.select:not(.disabled) .select-trigger:active {
|
|
1393
|
+
.select:not(.disabled) .select-trigger:where(:not(.select-native)):active {
|
|
1221
1394
|
background: var(--select-trigger-pressed-background, #ededed);
|
|
1222
1395
|
}
|
|
1223
1396
|
|
|
@@ -1225,15 +1398,15 @@
|
|
|
1225
1398
|
stops reading as invalid the moment the user enters it -- which is the one
|
|
1226
1399
|
moment they most need to see it. Listed after them, at equal or higher
|
|
1227
1400
|
specificity, rather than reached for with !important. */
|
|
1228
|
-
.select.error .select-trigger,
|
|
1229
|
-
.select.error .select-trigger:hover,
|
|
1230
|
-
.select.error .select-trigger:focus-within,
|
|
1231
|
-
.select.error.open .select-trigger {
|
|
1401
|
+
.select.error .select-trigger:where(:not(.select-native)),
|
|
1402
|
+
.select.error .select-trigger:where(:not(.select-native)):hover,
|
|
1403
|
+
.select.error .select-trigger:where(:not(.select-native)):focus-within,
|
|
1404
|
+
.select.error.open .select-trigger:where(:not(.select-native)) {
|
|
1232
1405
|
border-color: var(--select-trigger-error-border-color, #dc2626);
|
|
1233
1406
|
}
|
|
1234
1407
|
|
|
1235
|
-
.select.error .select-trigger:focus-within,
|
|
1236
|
-
.select.error.open .select-trigger {
|
|
1408
|
+
.select.error .select-trigger:where(:not(.select-native)):focus-within,
|
|
1409
|
+
.select.error.open .select-trigger:where(:not(.select-native)) {
|
|
1237
1410
|
box-shadow: var(--select-trigger-error-shadow, 0 0 0 2px rgba(220, 38, 38, 0.2));
|
|
1238
1411
|
}
|
|
1239
1412
|
|
|
@@ -1247,7 +1420,7 @@
|
|
|
1247
1420
|
position: relative;
|
|
1248
1421
|
}
|
|
1249
1422
|
|
|
1250
|
-
.select-control.has-clear .select-trigger {
|
|
1423
|
+
.select-control.has-clear .select-trigger:where(:not(.select-native)) {
|
|
1251
1424
|
padding-inline-end: calc(var(--select-clear-size, 18px) + 36px);
|
|
1252
1425
|
}
|
|
1253
1426
|
|
|
@@ -1400,6 +1573,11 @@
|
|
|
1400
1573
|
overflow-y: auto;
|
|
1401
1574
|
}
|
|
1402
1575
|
|
|
1576
|
+
.select-menu-search::placeholder {
|
|
1577
|
+
color: var(--select-placeholder-color, #6b7280);
|
|
1578
|
+
opacity: 1;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1403
1581
|
.select-menu-search {
|
|
1404
1582
|
flex: none;
|
|
1405
1583
|
margin: var(--select-menu-search-margin, 6px);
|
|
@@ -1577,7 +1755,7 @@
|
|
|
1577
1755
|
padding: var(--select-bottom-content-padding, 8px 12px);
|
|
1578
1756
|
}
|
|
1579
1757
|
|
|
1580
|
-
.select-trigger :global(.pill) {
|
|
1758
|
+
.select-trigger:where(:not(.select-native)) :global(.pill) {
|
|
1581
1759
|
--pill-background: var(--select-pill-background, #e0e0e0);
|
|
1582
1760
|
--pill-color: var(--select-pill-color, #333333);
|
|
1583
1761
|
--pill-border-radius: var(--select-pill-border-radius, 999px);
|
|
@@ -1586,18 +1764,21 @@
|
|
|
1586
1764
|
}
|
|
1587
1765
|
|
|
1588
1766
|
/* Ghost hierarchy: transparent, borderless trigger */
|
|
1589
|
-
.select.ghost .select-trigger {
|
|
1767
|
+
.select.ghost .select-trigger:where(:not(.select-native)) {
|
|
1590
1768
|
background: var(--select-ghost-trigger-background, transparent);
|
|
1591
1769
|
border-color: var(--select-ghost-trigger-border-color, transparent);
|
|
1592
1770
|
box-shadow: none;
|
|
1593
1771
|
}
|
|
1594
1772
|
|
|
1595
|
-
.select.ghost
|
|
1773
|
+
.select.ghost
|
|
1774
|
+
.select-trigger:where(:not(.select-native)):hover:not(
|
|
1775
|
+
.disabled .select-trigger:where(:not(.select-native))
|
|
1776
|
+
) {
|
|
1596
1777
|
border-color: var(--select-ghost-trigger-hover-border-color, transparent);
|
|
1597
1778
|
background: var(--select-ghost-trigger-hover-background, rgba(0, 0, 0, 0.04));
|
|
1598
1779
|
}
|
|
1599
1780
|
|
|
1600
|
-
.select.ghost.open .select-trigger {
|
|
1781
|
+
.select.ghost.open .select-trigger:where(:not(.select-native)) {
|
|
1601
1782
|
border-color: var(--select-ghost-trigger-open-border-color, transparent);
|
|
1602
1783
|
background: var(--select-ghost-trigger-open-background, rgba(0, 0, 0, 0.06));
|
|
1603
1784
|
box-shadow: none;
|