@juspay/svelte-ui-components 2.54.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.
package/dist/Card/Card.svelte
CHANGED
|
@@ -11,11 +11,20 @@
|
|
|
11
11
|
headerRight,
|
|
12
12
|
footer,
|
|
13
13
|
stretch = false,
|
|
14
|
-
scrollable = false
|
|
14
|
+
scrollable = false,
|
|
15
|
+
cssVars
|
|
15
16
|
}: CardProperties = $props();
|
|
16
17
|
|
|
17
18
|
const isInteractive = $derived(typeof onclick === 'function');
|
|
18
19
|
|
|
20
|
+
const styleAttr = $derived(
|
|
21
|
+
cssVars
|
|
22
|
+
? Object.entries(cssVars)
|
|
23
|
+
.map(([name, value]) => `${name}: ${value}`)
|
|
24
|
+
.join('; ')
|
|
25
|
+
: null
|
|
26
|
+
);
|
|
27
|
+
|
|
19
28
|
const handleKeydown = (event: KeyboardEvent): void => {
|
|
20
29
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
21
30
|
if (event.key === ' ') {
|
|
@@ -34,6 +43,7 @@
|
|
|
34
43
|
class:card-interactive={isInteractive}
|
|
35
44
|
class:card-stretch={stretch}
|
|
36
45
|
class:card-has-scroll={scrollable}
|
|
46
|
+
style={styleAttr}
|
|
37
47
|
data-pw={typeof testId === 'string' ? testId : null}
|
|
38
48
|
role={isInteractive ? 'button' : null}
|
|
39
49
|
tabindex={isInteractive ? 0 : null}
|
|
@@ -41,4 +41,13 @@ export type OptionalCardProperties = {
|
|
|
41
41
|
* Defaults to false.
|
|
42
42
|
*/
|
|
43
43
|
scrollable?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Per-instance CSS custom properties applied as inline style on the root `.card`.
|
|
46
|
+
* Keys must be CSS variable names (e.g. `--bottom-sections-count`); values are
|
|
47
|
+
* emitted verbatim. This lets a consumer feed a dynamic, per-instance value into a
|
|
48
|
+
* recipe class whose selectors or media queries read that variable — something a
|
|
49
|
+
* static `classes` string cannot express. When omitted, no `style` attribute is
|
|
50
|
+
* rendered, so existing consumers are unchanged.
|
|
51
|
+
*/
|
|
52
|
+
cssVars?: Record<string, string | number>;
|
|
44
53
|
};
|
|
@@ -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;
|