@juspay/svelte-ui-components 2.41.0 → 2.42.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.
@@ -17,9 +17,12 @@
17
17
  testId,
18
18
  itemTestId,
19
19
  onchange,
20
+ onopen,
21
+ onclose,
20
22
  classes,
21
23
  open = $bindable(false),
22
- dropdownAlign = 'left'
24
+ dropdownAlign = 'left',
25
+ hierarchy = 'default'
23
26
  }: SelectProperties = $props();
24
27
 
25
28
  function normalizeItems(source: SelectItem[] | string[]): SelectItem[] {
@@ -65,6 +68,7 @@
65
68
  return;
66
69
  }
67
70
  open = true;
71
+ onopen?.();
68
72
  highlightedIndex = -1;
69
73
  query = '';
70
74
  if (searchable) {
@@ -77,6 +81,7 @@
77
81
 
78
82
  function close(): void {
79
83
  open = false;
84
+ onclose?.();
80
85
  query = '';
81
86
  highlightedIndex = -1;
82
87
  }
@@ -208,7 +213,7 @@
208
213
  }
209
214
  query = event.target.value;
210
215
  if (!open) {
211
- open = true;
216
+ openDropdown();
212
217
  }
213
218
  highlightedIndex = -1;
214
219
  }
@@ -233,6 +238,9 @@
233
238
  document.addEventListener('click', handleClickOutside);
234
239
  return () => {
235
240
  document.removeEventListener('click', handleClickOutside);
241
+ if (open) {
242
+ onclose?.();
243
+ }
236
244
  };
237
245
  });
238
246
  </script>
@@ -241,6 +249,7 @@
241
249
  class="select {classes ?? ''}"
242
250
  class:open
243
251
  class:disabled
252
+ class:ghost={hierarchy === 'ghost'}
244
253
  bind:this={containerEl}
245
254
  {...typeof testId === 'string' ? { 'data-pw': testId } : {}}
246
255
  >
@@ -552,4 +561,22 @@
552
561
  --pill-padding: var(--select-pill-padding, 2px 8px);
553
562
  --pill-font-size: var(--select-pill-font-size, 13px);
554
563
  }
564
+
565
+ /* Ghost hierarchy: transparent, borderless trigger */
566
+ .select.ghost .select-trigger {
567
+ background: var(--select-ghost-trigger-background, transparent);
568
+ border-color: var(--select-ghost-trigger-border-color, transparent);
569
+ box-shadow: none;
570
+ }
571
+
572
+ .select.ghost .select-trigger:hover:not(.disabled .select-trigger) {
573
+ border-color: var(--select-ghost-trigger-hover-border-color, transparent);
574
+ background: var(--select-ghost-trigger-hover-background, rgba(0, 0, 0, 0.04));
575
+ }
576
+
577
+ .select.ghost.open .select-trigger {
578
+ border-color: var(--select-ghost-trigger-open-border-color, transparent);
579
+ background: var(--select-ghost-trigger-open-background, rgba(0, 0, 0, 0.06));
580
+ box-shadow: none;
581
+ }
555
582
  </style>
@@ -9,6 +9,7 @@ export type SelectItem = {
9
9
  export type MandatorySelectProperties = {
10
10
  items: SelectItem[] | string[];
11
11
  };
12
+ export type SelectHierarchy = 'default' | 'ghost';
12
13
  export type OptionalSelectProperties = {
13
14
  value?: string[];
14
15
  multiple?: boolean;
@@ -32,7 +33,11 @@ export type OptionalSelectProperties = {
32
33
  value: string[];
33
34
  items: SelectItem[];
34
35
  }]>;
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
+ hierarchy?: SelectHierarchy;
35
38
  };
36
39
  export type SelectEventProperties = {
37
40
  onchange?: (value: string[]) => void;
41
+ onopen?: () => void;
42
+ onclose?: () => void;
38
43
  };
@@ -1,20 +1,33 @@
1
1
  <script lang="ts">
2
2
  import type { ToggleProperties } from './properties';
3
3
 
4
- let { checked = false, text = '', classes, onclick }: ToggleProperties = $props();
4
+ let {
5
+ checked = false,
6
+ text = '',
7
+ disabled = false,
8
+ testId,
9
+ classes,
10
+ onclick
11
+ }: ToggleProperties = $props();
5
12
 
6
- function handleCheckboxClick(e: MouseEvent): void {
13
+ const handleCheckboxClick = (e: MouseEvent): void => {
7
14
  if (e.target instanceof HTMLInputElement && typeof e.target.checked === 'boolean') {
8
15
  checked = e.target.checked;
9
16
  }
10
17
  onclick?.(checked);
11
- }
18
+ };
12
19
  </script>
13
20
 
14
- <div class="container {classes ?? ''}">
21
+ <div class="container {classes ?? ''}" class:disabled aria-disabled={disabled} data-pw={testId}>
15
22
  <div class="text" hidden={text.length === 0}>{text}</div>
16
23
  <label class="switch">
17
- <input class="input-checkbox" type="checkbox" {checked} onclick={handleCheckboxClick} />
24
+ <input
25
+ class="input-checkbox"
26
+ type="checkbox"
27
+ {checked}
28
+ {disabled}
29
+ onclick={handleCheckboxClick}
30
+ />
18
31
  <span class="slider round"></span>
19
32
  </label>
20
33
  </div>
@@ -26,6 +39,12 @@
26
39
  gap: var(--toggle-container-gap, 8px);
27
40
  }
28
41
 
42
+ .container.disabled {
43
+ opacity: var(--toggle-disabled-opacity, 0.4);
44
+ cursor: not-allowed;
45
+ pointer-events: none;
46
+ }
47
+
29
48
  .text {
30
49
  font-size: var(--toggle-text-font-size, 14px);
31
50
  font-weight: var(--toggle-text-font-weight, 400);
@@ -1,6 +1,9 @@
1
- export type ToggleProperties = ToggleEventProperties & {
1
+ export type ToggleProperties = OptionalToggleProperties & ToggleEventProperties;
2
+ export type OptionalToggleProperties = {
3
+ text?: string;
2
4
  checked?: boolean;
3
- text: string;
5
+ disabled?: boolean;
6
+ testId?: string;
4
7
  classes?: string;
5
8
  };
6
9
  export type ToggleEventProperties = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",