@juspay/svelte-ui-components 2.55.0 → 2.56.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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onMount, tick } from 'svelte';
|
|
3
3
|
import type { SelectItem, SelectProperties } from './properties';
|
|
4
4
|
import Pill from '../Pill/Pill.svelte';
|
|
5
|
+
import Img from '../Img/Img.svelte';
|
|
5
6
|
import chevronDownSvg from '../assets/chevron-down.svg?raw';
|
|
6
7
|
|
|
7
8
|
let {
|
|
@@ -22,7 +23,9 @@
|
|
|
22
23
|
classes,
|
|
23
24
|
open = $bindable(false),
|
|
24
25
|
dropdownAlign = 'left',
|
|
25
|
-
hierarchy = 'default'
|
|
26
|
+
hierarchy = 'default',
|
|
27
|
+
leftIcon,
|
|
28
|
+
leftIconTestId
|
|
26
29
|
}: SelectProperties = $props();
|
|
27
30
|
|
|
28
31
|
function normalizeItems(source: SelectItem[] | string[]): SelectItem[] {
|
|
@@ -266,6 +269,14 @@
|
|
|
266
269
|
{...highlightedOptionId !== null ? { 'aria-activedescendant': highlightedOptionId } : {}}
|
|
267
270
|
tabindex={disabled ? -1 : searchable ? -1 : 0}
|
|
268
271
|
>
|
|
272
|
+
{#if typeof leftIcon === 'string' && leftIcon.length > 0}
|
|
273
|
+
<Img
|
|
274
|
+
src={leftIcon}
|
|
275
|
+
alt=""
|
|
276
|
+
classes="select-left-icon"
|
|
277
|
+
{...typeof leftIconTestId === 'string' ? { testId: leftIconTestId } : {}}
|
|
278
|
+
/>
|
|
279
|
+
{/if}
|
|
269
280
|
{#if multiple}
|
|
270
281
|
{#if typeof triggerSummary === 'function'}
|
|
271
282
|
{@render triggerSummary({ value, items })}
|
|
@@ -416,6 +427,13 @@
|
|
|
416
427
|
transition: var(--select-trigger-transition, border-color 0.15s, box-shadow 0.15s);
|
|
417
428
|
}
|
|
418
429
|
|
|
430
|
+
.select-trigger :global(.select-left-icon) {
|
|
431
|
+
--image-width: var(--select-left-icon-size, 16px);
|
|
432
|
+
--image-height: var(--select-left-icon-size, 16px);
|
|
433
|
+
--image-object-fit: contain;
|
|
434
|
+
flex: none;
|
|
435
|
+
}
|
|
436
|
+
|
|
419
437
|
.select-trigger:hover:not(.disabled .select-trigger) {
|
|
420
438
|
border-color: var(--select-trigger-hover-border-color, #999999);
|
|
421
439
|
}
|
|
@@ -35,6 +35,10 @@ export type OptionalSelectProperties = {
|
|
|
35
35
|
}]>;
|
|
36
36
|
/** Visual hierarchy of the trigger. `'ghost'` renders a transparent, borderless trigger — useful when the Select is embedded in a toolbar or header where a full bordered input would be visually heavy. Defaults to `'default'`. */
|
|
37
37
|
hierarchy?: SelectHierarchy;
|
|
38
|
+
/** Optional image src (URL or data URI) rendered at the left of the trigger. Size is controlled by the `--select-left-icon-size` CSS variable (default 16px). */
|
|
39
|
+
leftIcon?: string;
|
|
40
|
+
/** `data-pw` test id forwarded to the leading icon `<Img>` element. */
|
|
41
|
+
leftIconTestId?: string;
|
|
38
42
|
};
|
|
39
43
|
export type SelectEventProperties = {
|
|
40
44
|
onchange?: (value: string[]) => void;
|