@juspay/svelte-ui-components 2.14.0 → 2.14.1

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.
@@ -10,6 +10,7 @@
10
10
  testId,
11
11
  scrollLeftIcon,
12
12
  scrollRightIcon,
13
+ tab,
13
14
  classes,
14
15
  onchange
15
16
  }: TabsProperties = $props();
@@ -46,6 +47,13 @@
46
47
  onchange?.(index, items[index]);
47
48
  }
48
49
 
50
+ function handleKeydown(event: KeyboardEvent, index: number): void {
51
+ if (event.key === 'Enter' || event.key === ' ') {
52
+ event.preventDefault();
53
+ handleTabClick(index);
54
+ }
55
+ }
56
+
49
57
  function initOverflow(node: HTMLDivElement): { destroy: () => void } {
50
58
  scrollContainer = node;
51
59
  updateOverflow();
@@ -83,20 +91,25 @@
83
91
  onscroll={updateOverflow}
84
92
  >
85
93
  {#each items as label, index (index)}
86
- <button
94
+ <div
87
95
  class="tabs-item"
88
96
  class:active={index === activeIndex}
89
97
  role="tab"
90
98
  aria-selected={index === activeIndex}
99
+ aria-disabled={disabled ? true : null}
91
100
  tabindex={index === activeIndex ? 0 : -1}
92
- {disabled}
93
101
  onclick={() => handleTabClick(index)}
102
+ onkeydown={(e) => handleKeydown(e, index)}
94
103
  >
95
- {label}
104
+ {#if tab}
105
+ {@render tab({ label, index, active: index === activeIndex })}
106
+ {:else}
107
+ {label}
108
+ {/if}
96
109
  {#if index === activeIndex}
97
110
  <span class="tabs-indicator"></span>
98
111
  {/if}
99
- </button>
112
+ </div>
100
113
  {/each}
101
114
  </div>
102
115
  {#if canScrollRight}
@@ -197,6 +210,8 @@
197
210
  }
198
211
 
199
212
  .tabs-item {
213
+ display: flex;
214
+ align-items: center;
200
215
  position: relative;
201
216
  padding: var(--tabs-item-padding, 12px 16px);
202
217
  font-size: var(--tabs-item-font-size, 14px);
@@ -210,10 +225,11 @@
210
225
  outline: none;
211
226
  white-space: nowrap;
212
227
  flex-shrink: 0;
228
+ user-select: none;
213
229
  transition: var(--tabs-transition, color 0.2s ease, background 0.2s ease);
214
230
  }
215
231
 
216
- .tabs-item:hover:not(.active):not(:disabled) {
232
+ .tabs-item:hover:not(.active):not([aria-disabled]) {
217
233
  color: var(--tabs-hover-color, #333333);
218
234
  background: var(--tabs-hover-background, #f5f5f5);
219
235
  }
@@ -224,7 +240,7 @@
224
240
  background: var(--tabs-active-background, transparent);
225
241
  }
226
242
 
227
- .tabs-item:disabled {
243
+ .tabs-item[aria-disabled] {
228
244
  cursor: var(--tabs-disabled-cursor, not-allowed);
229
245
  }
230
246
 
@@ -9,6 +9,11 @@ export type OptionalTabsProperties = {
9
9
  testId?: string;
10
10
  scrollLeftIcon?: Snippet;
11
11
  scrollRightIcon?: Snippet;
12
+ tab?: Snippet<[{
13
+ label: string;
14
+ index: number;
15
+ active: boolean;
16
+ }]>;
12
17
  classes?: string;
13
18
  };
14
19
  export type TabsEventProperties = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/svelte-ui-components",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",