@juspay/svelte-ui-components 2.9.0 → 2.11.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.
Files changed (189) hide show
  1. package/README.md +337 -77
  2. package/dist/Accordion/Accordion.svelte +4 -2
  3. package/dist/Accordion/Accordion.svelte.d.ts +2 -4
  4. package/dist/Accordion/properties.d.ts +6 -0
  5. package/dist/Accordion/properties.js +1 -0
  6. package/dist/Animations/ModalAnimation.svelte +11 -9
  7. package/dist/Avatar/Avatar.svelte +122 -0
  8. package/dist/Avatar/Avatar.svelte.d.ts +4 -0
  9. package/dist/Avatar/properties.d.ts +15 -0
  10. package/dist/Avatar/properties.js +1 -0
  11. package/dist/Badge/Badge.svelte +2 -2
  12. package/dist/Badge/properties.d.ts +1 -0
  13. package/dist/Banner/Banner.svelte +132 -48
  14. package/dist/Banner/Banner.svelte.d.ts +1 -1
  15. package/dist/Banner/properties.d.ts +8 -3
  16. package/dist/Book/Book.svelte +281 -0
  17. package/dist/Book/Book.svelte.d.ts +4 -0
  18. package/dist/Book/properties.d.ts +24 -0
  19. package/dist/Book/properties.js +1 -0
  20. package/dist/BrandLoader/BrandLoader.svelte +3 -3
  21. package/dist/BrandLoader/properties.d.ts +1 -0
  22. package/dist/Browser/Browser.svelte +193 -0
  23. package/dist/Browser/Browser.svelte.d.ts +3 -0
  24. package/dist/Browser/properties.d.ts +16 -0
  25. package/dist/Browser/properties.js +1 -0
  26. package/dist/Button/Button.svelte +20 -7
  27. package/dist/Button/properties.d.ts +7 -4
  28. package/dist/Calendar/Calendar.svelte +476 -0
  29. package/dist/Calendar/Calendar.svelte.d.ts +4 -0
  30. package/dist/Calendar/properties.d.ts +30 -0
  31. package/dist/Calendar/properties.js +1 -0
  32. package/dist/Carousel/Carousel.svelte +19 -16
  33. package/dist/Carousel/properties.d.ts +1 -0
  34. package/dist/CheckListItem/CheckListItem.svelte +31 -26
  35. package/dist/CheckListItem/properties.d.ts +4 -1
  36. package/dist/Checkbox/Checkbox.svelte +157 -0
  37. package/dist/Checkbox/Checkbox.svelte.d.ts +4 -0
  38. package/dist/Checkbox/properties.d.ts +17 -0
  39. package/dist/Checkbox/properties.js +1 -0
  40. package/dist/Choicebox/Choicebox.svelte +85 -0
  41. package/dist/Choicebox/Choicebox.svelte.d.ts +4 -0
  42. package/dist/Choicebox/properties.d.ts +14 -0
  43. package/dist/Choicebox/properties.js +1 -0
  44. package/dist/CommandMenu/CommandMenu.svelte +452 -0
  45. package/dist/CommandMenu/CommandMenu.svelte.d.ts +4 -0
  46. package/dist/CommandMenu/properties.d.ts +26 -0
  47. package/dist/CommandMenu/properties.js +1 -0
  48. package/dist/ContextMenu/ContextMenu.svelte +308 -0
  49. package/dist/ContextMenu/ContextMenu.svelte.d.ts +4 -0
  50. package/dist/ContextMenu/properties.d.ts +26 -0
  51. package/dist/ContextMenu/properties.js +1 -0
  52. package/dist/Gauge/Gauge.svelte +70 -0
  53. package/dist/Gauge/Gauge.svelte.d.ts +4 -0
  54. package/dist/Gauge/properties.d.ts +9 -0
  55. package/dist/Gauge/properties.js +1 -0
  56. package/dist/GridItem/GridItem.svelte +5 -4
  57. package/dist/GridItem/properties.d.ts +1 -0
  58. package/dist/Icon/Icon.svelte +3 -3
  59. package/dist/Icon/properties.d.ts +1 -0
  60. package/dist/IconStack/IconStack.svelte +3 -3
  61. package/dist/IconStack/properties.d.ts +1 -0
  62. package/dist/Img/Img.svelte +5 -3
  63. package/dist/Img/properties.d.ts +5 -1
  64. package/dist/Input/Input.svelte +12 -6
  65. package/dist/Input/properties.d.ts +1 -0
  66. package/dist/InputButton/InputButton.svelte +4 -3
  67. package/dist/InputButton/properties.d.ts +5 -6
  68. package/dist/KeyboardInput/KeyboardInput.svelte +93 -0
  69. package/dist/KeyboardInput/KeyboardInput.svelte.d.ts +4 -0
  70. package/dist/KeyboardInput/properties.d.ts +12 -0
  71. package/dist/KeyboardInput/properties.js +1 -0
  72. package/dist/ListItem/ListItem.svelte +31 -28
  73. package/dist/ListItem/properties.d.ts +1 -0
  74. package/dist/Loader/Loader.svelte +10 -6
  75. package/dist/Loader/Loader.svelte.d.ts +3 -25
  76. package/dist/Loader/properties.d.ts +3 -0
  77. package/dist/Loader/properties.js +1 -0
  78. package/dist/LoadingDots/LoadingDots.svelte +64 -0
  79. package/dist/LoadingDots/LoadingDots.svelte.d.ts +3 -0
  80. package/dist/LoadingDots/properties.d.ts +8 -0
  81. package/dist/LoadingDots/properties.js +1 -0
  82. package/dist/Menu/Menu.svelte +349 -0
  83. package/dist/Menu/Menu.svelte.d.ts +4 -0
  84. package/dist/Menu/properties.d.ts +24 -0
  85. package/dist/Menu/properties.js +1 -0
  86. package/dist/Modal/Modal.svelte +10 -9
  87. package/dist/Modal/properties.d.ts +1 -0
  88. package/dist/Pagination/Pagination.svelte +152 -0
  89. package/dist/Pagination/Pagination.svelte.d.ts +4 -0
  90. package/dist/Pagination/properties.d.ts +14 -0
  91. package/dist/Pagination/properties.js +1 -0
  92. package/dist/Phone/Phone.svelte +234 -0
  93. package/dist/Phone/Phone.svelte.d.ts +3 -0
  94. package/dist/Phone/properties.d.ts +11 -0
  95. package/dist/Phone/properties.js +1 -0
  96. package/dist/Pill/Pill.svelte +130 -0
  97. package/dist/Pill/Pill.svelte.d.ts +4 -0
  98. package/dist/Pill/properties.d.ts +16 -0
  99. package/dist/Pill/properties.js +1 -0
  100. package/dist/Progress/Progress.svelte +68 -0
  101. package/dist/Progress/Progress.svelte.d.ts +4 -0
  102. package/dist/Progress/properties.d.ts +10 -0
  103. package/dist/Progress/properties.js +1 -0
  104. package/dist/Radio/Radio.svelte +128 -0
  105. package/dist/Radio/Radio.svelte.d.ts +4 -0
  106. package/dist/Radio/properties.d.ts +15 -0
  107. package/dist/Radio/properties.js +1 -0
  108. package/dist/RelativeTime/RelativeTime.svelte +117 -0
  109. package/dist/RelativeTime/RelativeTime.svelte.d.ts +4 -0
  110. package/dist/RelativeTime/properties.d.ts +13 -0
  111. package/dist/RelativeTime/properties.js +1 -0
  112. package/dist/Scroller/Scroller.svelte +389 -0
  113. package/dist/Scroller/Scroller.svelte.d.ts +4 -0
  114. package/dist/Scroller/properties.d.ts +30 -0
  115. package/dist/Scroller/properties.js +1 -0
  116. package/dist/Select/Select.svelte +382 -344
  117. package/dist/Select/Select.svelte.d.ts +1 -1
  118. package/dist/Select/properties.d.ts +16 -26
  119. package/dist/Sheet/Sheet.svelte +264 -0
  120. package/dist/Sheet/Sheet.svelte.d.ts +4 -0
  121. package/dist/Sheet/properties.d.ts +19 -0
  122. package/dist/Sheet/properties.js +1 -0
  123. package/dist/Shimmer/Shimmer.svelte +44 -0
  124. package/dist/Shimmer/Shimmer.svelte.d.ts +4 -0
  125. package/dist/Shimmer/properties.d.ts +4 -0
  126. package/dist/Shimmer/properties.js +1 -0
  127. package/dist/Slider/Slider.svelte +144 -0
  128. package/dist/Slider/Slider.svelte.d.ts +4 -0
  129. package/dist/Slider/properties.d.ts +17 -0
  130. package/dist/Slider/properties.js +1 -0
  131. package/dist/Snippet/Snippet.svelte +123 -0
  132. package/dist/Snippet/Snippet.svelte.d.ts +4 -0
  133. package/dist/Snippet/properties.d.ts +15 -0
  134. package/dist/Snippet/properties.js +1 -0
  135. package/dist/SplitButton/SplitButton.svelte +135 -0
  136. package/dist/SplitButton/SplitButton.svelte.d.ts +4 -0
  137. package/dist/SplitButton/properties.d.ts +17 -0
  138. package/dist/SplitButton/properties.js +1 -0
  139. package/dist/Status/Status.svelte +5 -3
  140. package/dist/Status/properties.d.ts +1 -0
  141. package/dist/Stepper/Step.svelte +3 -3
  142. package/dist/Stepper/Stepper.svelte +3 -3
  143. package/dist/Stepper/properties.d.ts +2 -0
  144. package/dist/Table/Table.svelte +15 -8
  145. package/dist/Table/properties.d.ts +1 -0
  146. package/dist/Tabs/Tabs.svelte +240 -0
  147. package/dist/Tabs/Tabs.svelte.d.ts +4 -0
  148. package/dist/Tabs/properties.d.ts +16 -0
  149. package/dist/Tabs/properties.js +1 -0
  150. package/dist/ThemeSwitcher/ThemeSwitcher.svelte +249 -0
  151. package/dist/ThemeSwitcher/ThemeSwitcher.svelte.d.ts +4 -0
  152. package/dist/ThemeSwitcher/properties.d.ts +19 -0
  153. package/dist/ThemeSwitcher/properties.js +1 -0
  154. package/dist/Toast/Toast.svelte +25 -30
  155. package/dist/Toast/properties.d.ts +1 -0
  156. package/dist/Toggle/Toggle.svelte +2 -2
  157. package/dist/Toggle/properties.d.ts +1 -0
  158. package/dist/Toolbar/Toolbar.svelte +8 -7
  159. package/dist/Toolbar/properties.d.ts +1 -0
  160. package/dist/Tooltip/Tooltip.svelte +153 -0
  161. package/dist/Tooltip/Tooltip.svelte.d.ts +4 -0
  162. package/dist/Tooltip/properties.d.ts +13 -0
  163. package/dist/Tooltip/properties.js +1 -0
  164. package/dist/assets/battery.svg +5 -0
  165. package/dist/assets/checkmark.svg +3 -0
  166. package/dist/assets/chevron-down-sm.svg +3 -0
  167. package/dist/assets/chevron-down.svg +3 -0
  168. package/dist/assets/chevron-left-lg.svg +3 -0
  169. package/dist/assets/chevron-left.svg +3 -0
  170. package/dist/assets/chevron-right-lg.svg +3 -0
  171. package/dist/assets/chevron-right.svg +3 -0
  172. package/dist/assets/chevron-up.svg +3 -0
  173. package/dist/assets/close.svg +4 -0
  174. package/dist/assets/copy.svg +4 -0
  175. package/dist/assets/error-circle.svg +5 -0
  176. package/dist/assets/lock.svg +3 -0
  177. package/dist/assets/minus.svg +3 -0
  178. package/dist/assets/monitor.svg +5 -0
  179. package/dist/assets/moon.svg +3 -0
  180. package/dist/assets/palette.svg +7 -0
  181. package/dist/assets/search.svg +4 -0
  182. package/dist/assets/signal.svg +6 -0
  183. package/dist/assets/sun.svg +11 -0
  184. package/dist/assets/wifi.svg +3 -0
  185. package/dist/index.d.ts +55 -0
  186. package/dist/index.js +27 -0
  187. package/dist/utils.d.ts +2 -0
  188. package/dist/utils.js +18 -4
  189. package/package.json +26 -1
@@ -0,0 +1,308 @@
1
+ <script lang="ts">
2
+ import { onMount, onDestroy } from 'svelte';
3
+ import type { ContextMenuProperties, ContextMenuItem } from './properties';
4
+
5
+ let {
6
+ items,
7
+ open = $bindable(false),
8
+ maxHeight = '240px',
9
+ testId,
10
+ children,
11
+ onselect,
12
+ onopen,
13
+ onclose,
14
+ classes
15
+ }: ContextMenuProperties = $props();
16
+
17
+ let menuEl: HTMLDivElement | null = $state(null);
18
+ let containerEl: HTMLDivElement | null = $state(null);
19
+ let focusedIndex: number = $state(-1);
20
+ let posX: number = $state(0);
21
+ let posY: number = $state(0);
22
+
23
+ let selectableItems: ContextMenuItem[] = $derived(
24
+ items.filter((item) => !item.separator && !item.disabled)
25
+ );
26
+
27
+ function openMenu(x: number, y: number) {
28
+ posX = x;
29
+ posY = y;
30
+ open = true;
31
+ focusedIndex = 0;
32
+ onopen?.();
33
+ requestAnimationFrame(() => {
34
+ adjustPosition();
35
+ focusItem(0);
36
+ });
37
+ }
38
+
39
+ function close() {
40
+ open = false;
41
+ focusedIndex = -1;
42
+ onclose?.();
43
+ }
44
+
45
+ function selectMenuItem(item: ContextMenuItem) {
46
+ if (item.disabled) {
47
+ return;
48
+ }
49
+ onselect?.(item);
50
+ close();
51
+ }
52
+
53
+ function adjustPosition() {
54
+ if (menuEl === null) {
55
+ return;
56
+ }
57
+ const rect = menuEl.getBoundingClientRect();
58
+ const viewportWidth = window.innerWidth;
59
+ const viewportHeight = window.innerHeight;
60
+
61
+ if (posX + rect.width > viewportWidth) {
62
+ posX = viewportWidth - rect.width - 4;
63
+ }
64
+ if (posY + rect.height > viewportHeight) {
65
+ posY = viewportHeight - rect.height - 4;
66
+ }
67
+ if (posX < 0) {
68
+ posX = 4;
69
+ }
70
+ if (posY < 0) {
71
+ posY = 4;
72
+ }
73
+ }
74
+
75
+ function focusItem(index: number) {
76
+ if (menuEl === null) {
77
+ return;
78
+ }
79
+ const focusableItems = menuEl.querySelectorAll<HTMLElement>(
80
+ '[role="menuitem"]:not([aria-disabled="true"])'
81
+ );
82
+ if (index >= 0 && index < focusableItems.length) {
83
+ focusableItems[index].focus();
84
+ }
85
+ }
86
+
87
+ function getSelectableIndex(item: ContextMenuItem): number {
88
+ return selectableItems.indexOf(item);
89
+ }
90
+
91
+ function handleContextMenu(event: MouseEvent) {
92
+ event.preventDefault();
93
+ openMenu(event.clientX, event.clientY);
94
+ }
95
+
96
+ function handleMenuKeydown(event: KeyboardEvent) {
97
+ switch (event.key) {
98
+ case 'ArrowDown': {
99
+ event.preventDefault();
100
+ const next = focusedIndex + 1;
101
+ focusedIndex = next >= selectableItems.length ? 0 : next;
102
+ focusItem(focusedIndex);
103
+ break;
104
+ }
105
+ case 'ArrowUp': {
106
+ event.preventDefault();
107
+ const prev = focusedIndex - 1;
108
+ focusedIndex = prev < 0 ? selectableItems.length - 1 : prev;
109
+ focusItem(focusedIndex);
110
+ break;
111
+ }
112
+ case 'Home': {
113
+ event.preventDefault();
114
+ focusedIndex = 0;
115
+ focusItem(focusedIndex);
116
+ break;
117
+ }
118
+ case 'End': {
119
+ event.preventDefault();
120
+ focusedIndex = selectableItems.length - 1;
121
+ focusItem(focusedIndex);
122
+ break;
123
+ }
124
+ case 'Enter':
125
+ case ' ': {
126
+ event.preventDefault();
127
+ if (focusedIndex >= 0 && focusedIndex < selectableItems.length) {
128
+ selectMenuItem(selectableItems[focusedIndex]);
129
+ }
130
+ break;
131
+ }
132
+ case 'Escape': {
133
+ event.preventDefault();
134
+ close();
135
+ break;
136
+ }
137
+ case 'Tab': {
138
+ close();
139
+ break;
140
+ }
141
+ }
142
+ }
143
+
144
+ function handleClickOutside(event: Event) {
145
+ if (event.target instanceof Node && menuEl && !menuEl.contains(event.target)) {
146
+ close();
147
+ }
148
+ }
149
+
150
+ onMount(() => {
151
+ document.addEventListener('click', handleClickOutside);
152
+ });
153
+
154
+ onDestroy(() => {
155
+ if (typeof window !== 'undefined') {
156
+ document.removeEventListener('click', handleClickOutside);
157
+ }
158
+ });
159
+ </script>
160
+
161
+ <div
162
+ class="context-menu-container {classes ?? ''}"
163
+ bind:this={containerEl}
164
+ oncontextmenu={handleContextMenu}
165
+ role="application"
166
+ data-pw={testId}
167
+ >
168
+ {#if typeof children === 'function'}
169
+ {@render children()}
170
+ {/if}
171
+ </div>
172
+
173
+ {#if open}
174
+ <div
175
+ class="context-menu-dropdown"
176
+ style="left: {posX}px; top: {posY}px; --context-menu-max-height: {maxHeight};"
177
+ bind:this={menuEl}
178
+ role="menu"
179
+ tabindex="-1"
180
+ onkeydown={handleMenuKeydown}
181
+ >
182
+ {#each items as item (item.value)}
183
+ {#if item.separator}
184
+ <div class="context-menu-separator" role="separator"></div>
185
+ {:else}
186
+ <div
187
+ class="context-menu-item"
188
+ class:context-menu-item-danger={item.danger}
189
+ class:context-menu-item-disabled={item.disabled}
190
+ role="menuitem"
191
+ tabindex={item.disabled ? -1 : 0}
192
+ aria-disabled={item.disabled ? 'true' : null}
193
+ onclick={() => selectMenuItem(item)}
194
+ onkeydown={(e) => {
195
+ if (e.key === 'Enter' || e.key === ' ') {
196
+ e.preventDefault();
197
+ selectMenuItem(item);
198
+ }
199
+ }}
200
+ onfocus={() => {
201
+ if (!item.disabled) {
202
+ focusedIndex = getSelectableIndex(item);
203
+ }
204
+ }}
205
+ data-pw={testId ? `${testId}-item-${item.value}` : null}
206
+ >
207
+ {#if item.icon}
208
+ <img class="context-menu-item-icon" src={item.icon} alt="" />
209
+ {/if}
210
+ <span class="context-menu-item-label">{item.label}</span>
211
+ {#if item.shortcut}
212
+ <span class="context-menu-item-shortcut">{item.shortcut}</span>
213
+ {/if}
214
+ </div>
215
+ {/if}
216
+ {/each}
217
+ </div>
218
+ {/if}
219
+
220
+ <style>
221
+ .context-menu-container {
222
+ display: var(--context-menu-container-display, contents);
223
+ }
224
+
225
+ .context-menu-dropdown {
226
+ position: fixed;
227
+ z-index: var(--context-menu-z-index, 1000);
228
+ background-color: var(--context-menu-background-color, #ffffff);
229
+ border: var(--context-menu-border, 1px solid #e0e0e0);
230
+ border-radius: var(--context-menu-border-radius, 6px);
231
+ box-shadow: var(--context-menu-box-shadow, 0px 4px 16px rgba(0, 0, 0, 0.12));
232
+ min-width: var(--context-menu-min-width, 160px);
233
+ max-height: var(--context-menu-max-height, 240px);
234
+ overflow-y: auto;
235
+ padding: var(--context-menu-padding, 4px 0);
236
+ font-family: var(--context-menu-font-family, inherit);
237
+ font-size: var(--context-menu-font-size, 14px);
238
+ }
239
+
240
+ .context-menu-item {
241
+ display: flex;
242
+ align-items: center;
243
+ padding: var(--context-menu-item-padding, 8px 12px);
244
+ cursor: pointer;
245
+ color: var(--context-menu-item-color, #333333);
246
+ background-color: var(--context-menu-item-background-color, transparent);
247
+ gap: var(--context-menu-item-gap, 8px);
248
+ white-space: var(--context-menu-item-white-space, nowrap);
249
+ -webkit-tap-highlight-color: transparent;
250
+ }
251
+
252
+ .context-menu-item:hover {
253
+ background-color: var(--context-menu-item-hover-background-color, #f5f5f5);
254
+ color: var(--context-menu-item-hover-color, var(--context-menu-item-color, #333333));
255
+ }
256
+
257
+ .context-menu-item:focus {
258
+ background-color: var(--context-menu-item-focus-background-color, #f0f0f0);
259
+ outline: var(--context-menu-item-focus-outline, none);
260
+ }
261
+
262
+ .context-menu-item-danger {
263
+ color: var(--context-menu-item-danger-color, #dc3545);
264
+ }
265
+
266
+ .context-menu-item-danger:hover {
267
+ background-color: var(--context-menu-item-danger-hover-background-color, #fff0f0);
268
+ color: var(
269
+ --context-menu-item-danger-hover-color,
270
+ var(--context-menu-item-danger-color, #dc3545)
271
+ );
272
+ }
273
+
274
+ .context-menu-item-danger:focus {
275
+ background-color: var(--context-menu-item-danger-focus-background-color, #fff0f0);
276
+ }
277
+
278
+ .context-menu-item-disabled {
279
+ opacity: var(--context-menu-item-disabled-opacity, 0.4);
280
+ cursor: var(--context-menu-item-disabled-cursor, not-allowed);
281
+ pointer-events: none;
282
+ }
283
+
284
+ .context-menu-separator {
285
+ height: var(--context-menu-separator-height, 1px);
286
+ background-color: var(--context-menu-separator-color, #e0e0e0);
287
+ margin: var(--context-menu-separator-margin, 4px 0);
288
+ }
289
+
290
+ .context-menu-item-icon {
291
+ height: var(--context-menu-item-icon-height, 16px);
292
+ width: var(--context-menu-item-icon-width, 16px);
293
+ flex-shrink: 0;
294
+ }
295
+
296
+ .context-menu-item-label {
297
+ flex: 1;
298
+ font-weight: var(--context-menu-item-font-weight, 400);
299
+ line-height: var(--context-menu-item-line-height, 1.4);
300
+ }
301
+
302
+ .context-menu-item-shortcut {
303
+ color: var(--context-menu-item-shortcut-color, #999999);
304
+ font-size: var(--context-menu-item-shortcut-font-size, 12px);
305
+ font-weight: var(--context-menu-item-shortcut-font-weight, 400);
306
+ margin-left: var(--context-menu-item-shortcut-margin-left, 16px);
307
+ }
308
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { ContextMenuProperties } from './properties';
2
+ declare const ContextMenu: import("svelte").Component<ContextMenuProperties, {}, "open">;
3
+ type ContextMenu = ReturnType<typeof ContextMenu>;
4
+ export default ContextMenu;
@@ -0,0 +1,26 @@
1
+ import type { Snippet } from 'svelte';
2
+ export type ContextMenuItem = {
3
+ label: string;
4
+ value: string;
5
+ icon?: string;
6
+ shortcut?: string;
7
+ disabled?: boolean;
8
+ danger?: boolean;
9
+ separator?: boolean;
10
+ };
11
+ export type ContextMenuProperties = MandatoryContextMenuProperties & OptionalContextMenuProperties & ContextMenuEventProperties;
12
+ export type MandatoryContextMenuProperties = {
13
+ items: ContextMenuItem[];
14
+ };
15
+ export type OptionalContextMenuProperties = {
16
+ open?: boolean;
17
+ maxHeight?: string;
18
+ testId?: string;
19
+ children?: Snippet;
20
+ classes?: string;
21
+ };
22
+ export type ContextMenuEventProperties = {
23
+ onselect?: (item: ContextMenuItem) => void;
24
+ onopen?: () => void;
25
+ onclose?: () => void;
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ <script lang="ts">
2
+ import type { GaugeProperties } from './properties';
3
+
4
+ let { value, showLabel = true, testId, classes }: GaugeProperties = $props();
5
+
6
+ const VIEW_BOX = 100;
7
+ const CENTER = VIEW_BOX / 2;
8
+ const STROKE = 8;
9
+ const RADIUS = (VIEW_BOX - STROKE) / 2;
10
+ const CIRCUMFERENCE = 2 * Math.PI * RADIUS;
11
+
12
+ let clamped = $derived(Math.min(100, Math.max(0, value)));
13
+ let offset = $derived(CIRCUMFERENCE - (clamped / 100) * CIRCUMFERENCE);
14
+ </script>
15
+
16
+ <div class="gauge {classes ?? ''}" data-pw={typeof testId === 'string' ? testId : null}>
17
+ <svg viewBox="0 0 {VIEW_BOX} {VIEW_BOX}">
18
+ <circle class="track" cx={CENTER} cy={CENTER} r={RADIUS} fill="none" />
19
+ <circle
20
+ class="bar"
21
+ cx={CENTER}
22
+ cy={CENTER}
23
+ r={RADIUS}
24
+ fill="none"
25
+ stroke-dasharray={CIRCUMFERENCE}
26
+ stroke-dashoffset={offset}
27
+ stroke-linecap="round"
28
+ transform="rotate(-90 {CENTER} {CENTER})"
29
+ />
30
+ </svg>
31
+ {#if showLabel}
32
+ <div class="label">{Math.round(clamped)}%</div>
33
+ {/if}
34
+ </div>
35
+
36
+ <style>
37
+ .gauge {
38
+ position: relative;
39
+ display: inline-flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ width: var(--gauge-size, 120px);
43
+ height: var(--gauge-size, 120px);
44
+ }
45
+
46
+ svg {
47
+ display: block;
48
+ width: 100%;
49
+ height: 100%;
50
+ }
51
+
52
+ .track {
53
+ stroke: var(--gauge-track-color, #e0e0e0);
54
+ stroke-width: var(--gauge-stroke-width, 8);
55
+ }
56
+
57
+ .bar {
58
+ stroke: var(--gauge-bar-color, #2196f3);
59
+ stroke-width: var(--gauge-stroke-width, 8);
60
+ transition: stroke-dashoffset var(--gauge-transition-duration, 0.3s) ease;
61
+ }
62
+
63
+ .label {
64
+ position: absolute;
65
+ font-size: var(--gauge-label-font-size, 24px);
66
+ font-weight: var(--gauge-label-font-weight, 600);
67
+ font-family: var(--gauge-label-font-family, inherit);
68
+ color: var(--gauge-label-color, #333);
69
+ }
70
+ </style>
@@ -0,0 +1,4 @@
1
+ import type { GaugeProperties } from './properties';
2
+ declare const Gauge: import("svelte").Component<GaugeProperties, {}, "">;
3
+ type Gauge = ReturnType<typeof Gauge>;
4
+ export default Gauge;
@@ -0,0 +1,9 @@
1
+ export type GaugeProperties = MandatoryGaugeProperties & OptionalGaugeProperties;
2
+ export type MandatoryGaugeProperties = {
3
+ value: number;
4
+ };
5
+ export type OptionalGaugeProperties = {
6
+ showLabel?: boolean;
7
+ testId?: string;
8
+ classes?: string;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -7,7 +7,8 @@
7
7
  headerIcon = '',
8
8
  showLoader = $bindable(false),
9
9
  onclick,
10
- onkeydown
10
+ onkeydown,
11
+ classes
11
12
  }: GridItemProperties = $props();
12
13
 
13
14
  function handleClick(event: MouseEvent) {
@@ -16,7 +17,7 @@
16
17
  }
17
18
  </script>
18
19
 
19
- <div class="container" onclick={handleClick} {onkeydown} role="button" tabindex="0">
20
+ <div class="container {classes ?? ''}" onclick={handleClick} {onkeydown} role="button" tabindex="0">
20
21
  <div class="grid-header">
21
22
  <img src={headerIcon} alt="" class="grid-item-header-icon" />
22
23
  </div>
@@ -54,7 +55,7 @@
54
55
 
55
56
  .grid-item-header-icon {
56
57
  height: var(--grid-item-header-icon-height, 16px);
57
- width: var(--grid-item-header-icon-width, auto);
58
+ width: var(--grid-item-header-icon-width, fit-content);
58
59
  object-fit: var(--grid-item-header-icon-object-fit, contain);
59
60
  z-index: var(--grid-item-header-icon-z-index, 2);
60
61
  }
@@ -73,7 +74,7 @@
73
74
 
74
75
  .grid-item-icon {
75
76
  height: var(--grid-item-icon-height, 32px);
76
- width: var(--grid-item-icon-width, auto);
77
+ width: var(--grid-item-icon-width, fit-content);
77
78
  object-fit: var(--grid-item-icon-object-fit, contain);
78
79
  z-index: var(--grid-item-icon-z-index, 100);
79
80
  }
@@ -6,6 +6,7 @@ export type MandatoryGridItemProperties = {
6
6
  export type OptionalGridItemProperties = {
7
7
  headerIcon?: string | null;
8
8
  showLoader?: boolean;
9
+ classes?: string;
9
10
  };
10
11
  export type GridItemEventProperties = {
11
12
  onclick?: (event: MouseEvent) => void;
@@ -1,12 +1,12 @@
1
1
  <script lang="ts">
2
2
  import type { IconProperties } from './properties';
3
3
 
4
- let { icon, text, onclick, onkeydown }: IconProperties = $props();
4
+ let { icon, text, onclick, onkeydown, classes }: IconProperties = $props();
5
5
  </script>
6
6
 
7
- <div class="icon-container" {onclick} {onkeydown} role="button" tabindex="0">
7
+ <div class="icon-container {classes ?? ''}" {onclick} {onkeydown} role="button" tabindex="0">
8
8
  <img src={icon} alt="" />
9
- {#if text}
9
+ {#if typeof text === 'string' && text.length > 0}
10
10
  <div class="icon-text">{text}</div>
11
11
  {/if}
12
12
  </div>
@@ -4,6 +4,7 @@ export type MandatoryIconProperties = {
4
4
  };
5
5
  export type OptionalIconProperties = {
6
6
  text?: string | null;
7
+ classes?: string;
7
8
  };
8
9
  export type IconEventProperties = {
9
10
  onclick?: (event: MouseEvent) => void;
@@ -1,11 +1,11 @@
1
1
  <script lang="ts">
2
2
  import type { IconStackProperties } from './properties';
3
3
 
4
- let { icons }: IconStackProperties = $props();
4
+ let { icons, classes }: IconStackProperties = $props();
5
5
  </script>
6
6
 
7
- <div class="stack-container">
8
- {#each icons as icon, i}
7
+ <div class="stack-container {classes ?? ''}">
8
+ {#each icons as icon, i (i)}
9
9
  <div class="stack-icon" style:z-index={icons.length - i}>
10
10
  {#if icon.type === 'image'}
11
11
  <img src={icon.content} alt="icon" />
@@ -4,4 +4,5 @@ export type IconStackItem = {
4
4
  };
5
5
  export type IconStackProperties = {
6
6
  icons: IconStackItem[];
7
+ classes?: string;
7
8
  };
@@ -1,18 +1,20 @@
1
1
  <script lang="ts">
2
2
  import type { ImgProperties } from './properties';
3
3
 
4
- let { src, alt, fallback }: ImgProperties = $props();
4
+ let { src, alt, fallback, onerror, classes }: ImgProperties = $props();
5
5
 
6
6
  let currentSrc = $derived(src);
7
7
 
8
8
  function handleFallback(): void {
9
- if (fallback && currentSrc !== fallback) {
9
+ if (typeof fallback === 'string' && fallback.length > 0 && currentSrc !== fallback) {
10
10
  currentSrc = fallback;
11
+ } else {
12
+ onerror?.();
11
13
  }
12
14
  }
13
15
  </script>
14
16
 
15
- <img src={currentSrc} {alt} onerror={handleFallback} />
17
+ <img class={classes ?? ''} src={currentSrc} {alt} onerror={handleFallback} />
16
18
 
17
19
  <style>
18
20
  img {
@@ -1,8 +1,12 @@
1
- export type ImgProperties = OptionalImgProperties & MandatoryImgProperties;
1
+ export type ImgProperties = MandatoryImgProperties & OptionalImgProperties & ImgEventProperties;
2
2
  export type MandatoryImgProperties = {
3
3
  src: string;
4
4
  alt: string;
5
5
  };
6
6
  export type OptionalImgProperties = {
7
7
  fallback?: string | null;
8
+ classes?: string;
9
+ };
10
+ export type ImgEventProperties = {
11
+ onerror?: () => void;
8
12
  };
@@ -30,7 +30,8 @@
30
30
  onPaste = () => {},
31
31
  onStateChange = () => {},
32
32
  onClick = () => {},
33
- onKeyDown = () => {}
33
+ onKeyDown = () => {},
34
+ classes
34
35
  }: InputProperties = $props();
35
36
 
36
37
  export function focus() {
@@ -164,12 +165,17 @@
164
165
  onFocusout(event);
165
166
  }
166
167
 
167
- $effect(() => {
168
- onStateChange(validationState);
168
+ let _validationStateForCallback = $derived.by(() => {
169
+ const state = validationState;
170
+ onStateChange(state);
171
+ return state;
169
172
  });
170
173
  </script>
171
174
 
172
- <div class="input-container" class:input-error={validationState === 'Invalid' && !actionInput}>
175
+ <div
176
+ class="input-container {classes ?? ''}"
177
+ class:input-error={validationState === 'Invalid' && !actionInput}
178
+ >
173
179
  {#if typeof label === 'string' && label !== '' && !actionInput}
174
180
  <label class="label" for={name}>
175
181
  {label}
@@ -193,7 +199,7 @@
193
199
  style="--focus-border: {addFocusColor ? 1 : 0}px;"
194
200
  disabled={disable}
195
201
  bind:this={inputElement}
196
- maxlength={dataType === 'tel' ? undefined : maxLength}
202
+ maxlength={dataType === 'tel' ? null : maxLength}
197
203
  minlength={minLength}
198
204
  />
199
205
  {:else}
@@ -213,7 +219,7 @@
213
219
  class:action-input={actionInput}
214
220
  disabled={disable}
215
221
  bind:this={inputElement}
216
- maxlength={dataType === 'tel' ? undefined : maxLength}
222
+ maxlength={dataType === 'tel' ? null : maxLength}
217
223
  minlength={minLength}
218
224
  />
219
225
  {/if}
@@ -23,6 +23,7 @@ export type OptionalInputProperties = {
23
23
  textTransformers?: TextTransformer[];
24
24
  textViewPresentation?: TextTransformer[];
25
25
  testId?: string;
26
+ classes?: string;
26
27
  };
27
28
  export type InputEventProperties = {
28
29
  onInput?: (value: string, event: Event) => void;
@@ -16,7 +16,8 @@
16
16
  leftButtonEventProperties,
17
17
  bottomButtonEventProperties,
18
18
  leftIcon,
19
- rightIcon
19
+ rightIcon,
20
+ classes
20
21
  }: InputButtonProperties = $props();
21
22
 
22
23
  let validationState = $state<ValidationState>('InProgress');
@@ -54,7 +55,7 @@
54
55
  }
55
56
  </script>
56
57
 
57
- <div class="container">
58
+ <div class="container {classes ?? ''}">
58
59
  {#if inputProperties.label && inputProperties.label !== ''}
59
60
  <label class="label" for={inputProperties.name}>
60
61
  {inputProperties.label}
@@ -121,7 +122,7 @@
121
122
  --input-focus-border: none;
122
123
  --input-box-shadow: none;
123
124
  --input-margin: none;
124
- --input-width: auto;
125
+ --input-width: fit-content;
125
126
  height: var(--input-height, fit-content);
126
127
  font-size: var(--input-font-size, 16px) !important;
127
128
  font-weight: 500;
@@ -1,17 +1,17 @@
1
- import type { ButtonEventProperties, MandatoryButtonProperties, OptionalButtonProperties } from '../Button/properties';
1
+ import type { ButtonEventProperties, OptionalButtonProperties } from '../Button/properties';
2
2
  import type { InputEventProperties, OptionalInputProperties } from '../Input/properties';
3
3
  import type { Snippet } from 'svelte';
4
4
  export type InputButtonProperties = OptionalInputButtonProperties & InputButtonEventProperties & {
5
5
  value: string;
6
6
  };
7
- type _ButtonProperties = OptionalButtonProperties & MandatoryButtonProperties;
8
7
  export type OptionalInputButtonProperties = {
9
8
  inputProperties: OptionalInputProperties;
10
- rightButtonProperties?: _ButtonProperties | null;
11
- leftButtonProperties?: _ButtonProperties | null;
12
- bottomButtonProperties?: _ButtonProperties | null;
9
+ rightButtonProperties?: OptionalButtonProperties | null;
10
+ leftButtonProperties?: OptionalButtonProperties | null;
11
+ bottomButtonProperties?: OptionalButtonProperties | null;
13
12
  leftIcon?: Snippet;
14
13
  rightIcon?: Snippet;
14
+ classes?: string;
15
15
  };
16
16
  export type InputButtonEventProperties = {
17
17
  inputEventProperties?: InputEventProperties;
@@ -19,4 +19,3 @@ export type InputButtonEventProperties = {
19
19
  leftButtonEventProperties?: ButtonEventProperties | null;
20
20
  bottomButtonEventProperties?: ButtonEventProperties | null;
21
21
  };
22
- export {};