@juspay/svelte-ui-components 2.14.0 → 2.18.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 (41) hide show
  1. package/dist/Button/Button.svelte +14 -0
  2. package/dist/Button/properties.d.ts +2 -0
  3. package/dist/Card/Card.svelte +51 -0
  4. package/dist/Card/Card.svelte.d.ts +4 -0
  5. package/dist/Card/properties.d.ts +10 -0
  6. package/dist/Card/properties.js +1 -0
  7. package/dist/ColorPicker/ColorPicker.svelte +583 -0
  8. package/dist/ColorPicker/ColorPicker.svelte.d.ts +4 -0
  9. package/dist/ColorPicker/properties.d.ts +15 -0
  10. package/dist/ColorPicker/properties.js +1 -0
  11. package/dist/Combobox/Combobox.svelte +432 -0
  12. package/dist/Combobox/Combobox.svelte.d.ts +6 -0
  13. package/dist/Combobox/properties.d.ts +42 -0
  14. package/dist/Combobox/properties.js +1 -0
  15. package/dist/EmptyState/EmptyState.svelte +66 -0
  16. package/dist/EmptyState/EmptyState.svelte.d.ts +4 -0
  17. package/dist/EmptyState/properties.d.ts +11 -0
  18. package/dist/EmptyState/properties.js +1 -0
  19. package/dist/Icon/Icon.svelte +22 -2
  20. package/dist/Icon/properties.d.ts +3 -4
  21. package/dist/Input/Input.svelte +30 -5
  22. package/dist/Input/Input.svelte.d.ts +1 -0
  23. package/dist/Input/properties.d.ts +11 -2
  24. package/dist/ListItem/ListItem.svelte +9 -3
  25. package/dist/ListItem/properties.d.ts +3 -0
  26. package/dist/Menu/Menu.svelte +17 -6
  27. package/dist/Menu/properties.d.ts +4 -0
  28. package/dist/Slider/Slider.svelte +9 -6
  29. package/dist/SplitInput/SplitInput.svelte +225 -0
  30. package/dist/SplitInput/SplitInput.svelte.d.ts +7 -0
  31. package/dist/SplitInput/properties.d.ts +20 -0
  32. package/dist/SplitInput/properties.js +1 -0
  33. package/dist/Tabs/Tabs.svelte +22 -6
  34. package/dist/Tabs/properties.d.ts +5 -0
  35. package/dist/assets/swap-vertical.svg +6 -0
  36. package/dist/index.d.ts +10 -0
  37. package/dist/index.js +5 -0
  38. package/dist/types.d.ts +15 -1
  39. package/dist/utils.d.ts +10 -1
  40. package/dist/utils.js +118 -0
  41. package/package.json +1 -1
package/dist/types.d.ts CHANGED
@@ -5,7 +5,6 @@ import type { FlyParams } from 'svelte/transition';
5
5
  */
6
6
  export type InputDataType = 'text' | 'tel' | 'password' | 'email' | 'number';
7
7
  export type ModalTransition = 'IN' | 'ALL';
8
- export type AutoCompleteType = 'tel' | 'name' | 'email' | 'one-time-code' | 'postal-code' | 'street-address' | 'on' | 'address-level1';
9
8
  /**
10
9
  * @name CustomValidator
11
10
  * @description Function type for taking input parameter and returning a boolean denoting if the value is valid or not
@@ -26,3 +25,18 @@ export type FlyAnimationConfig = {
26
25
  in: FlyParams;
27
26
  out: FlyParams;
28
27
  };
28
+ export type Rgb = {
29
+ r: number;
30
+ g: number;
31
+ b: number;
32
+ };
33
+ export type Hsv = {
34
+ h: number;
35
+ s: number;
36
+ v: number;
37
+ };
38
+ export type Hsl = {
39
+ h: number;
40
+ s: number;
41
+ l: number;
42
+ };
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CustomValidator, InputDataType, ValidationState } from './types';
1
+ import type { CustomValidator, Hsv, Hsl, InputDataType, Rgb, ValidationState } from './types';
2
2
  /**
3
3
  * @description A common function to validate value provided inside the input component
4
4
  * @param inputValue String value coming from input field
@@ -16,4 +16,13 @@ export declare function validateInput(inputValue: string, dataType: InputDataTyp
16
16
  */
17
17
  export declare function getStorageItem(key: string): string | null;
18
18
  export declare function setStorageItem(key: string, value: string): void;
19
+ export declare function hexToRgb(hex: string): Rgb | null;
20
+ export declare function rgbToHsv(r: number, g: number, b: number): Hsv;
21
+ export declare function hsvToRgb(h: number, s: number, v: number): Rgb;
22
+ export declare function hsvToHex(h: number, s: number, v: number): string;
23
+ export declare function hexToHsv(hex: string): Hsv | null;
24
+ export declare function hsvToHsl(h: number, s: number, v: number): Hsl;
25
+ export declare function hslToHsv(hDeg: number, sPct: number, lPct: number): Hsv;
26
+ export declare function isValidHex(hex: string): boolean;
27
+ export declare function clampInt(v: string, min: number, max: number): number;
19
28
  export declare function createDebouncer(delay: number): <T extends unknown[]>(callback: (...args: T) => void, ...args: T) => void;
package/dist/utils.js CHANGED
@@ -164,6 +164,124 @@ export function setStorageItem(key, value) {
164
164
  // localStorage unavailable (SSR, private browsing, storage full)
165
165
  }
166
166
  }
167
+ // ── Color conversions ───────────────────────────────────────────
168
+ const HEX_COLOR_PATTERN = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;
169
+ export function hexToRgb(hex) {
170
+ const m = hex.match(HEX_COLOR_PATTERN);
171
+ if (m === null) {
172
+ return null;
173
+ }
174
+ const rStr = m.at(1);
175
+ const gStr = m.at(2);
176
+ const bStr = m.at(3);
177
+ if (typeof rStr !== 'string' || typeof gStr !== 'string' || typeof bStr !== 'string') {
178
+ return null;
179
+ }
180
+ return { r: parseInt(rStr, 16), g: parseInt(gStr, 16), b: parseInt(bStr, 16) };
181
+ }
182
+ export function rgbToHsv(r, g, b) {
183
+ r /= 255;
184
+ g /= 255;
185
+ b /= 255;
186
+ const max = Math.max(r, g, b);
187
+ const min = Math.min(r, g, b);
188
+ const d = max - min;
189
+ let h = 0;
190
+ const s = max === 0 ? 0 : d / max;
191
+ const v = max;
192
+ if (d !== 0) {
193
+ if (max === r) {
194
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
195
+ }
196
+ else if (max === g) {
197
+ h = ((b - r) / d + 2) / 6;
198
+ }
199
+ else {
200
+ h = ((r - g) / d + 4) / 6;
201
+ }
202
+ }
203
+ return { h, s, v };
204
+ }
205
+ export function hsvToRgb(h, s, v) {
206
+ const i = Math.floor(h * 6);
207
+ const f = h * 6 - i;
208
+ const p = v * (1 - s);
209
+ const q = v * (1 - f * s);
210
+ const t = v * (1 - (1 - f) * s);
211
+ let r, g, b;
212
+ switch (i % 6) {
213
+ case 0:
214
+ r = v;
215
+ g = t;
216
+ b = p;
217
+ break;
218
+ case 1:
219
+ r = q;
220
+ g = v;
221
+ b = p;
222
+ break;
223
+ case 2:
224
+ r = p;
225
+ g = v;
226
+ b = t;
227
+ break;
228
+ case 3:
229
+ r = p;
230
+ g = q;
231
+ b = v;
232
+ break;
233
+ case 4:
234
+ r = t;
235
+ g = p;
236
+ b = v;
237
+ break;
238
+ default:
239
+ r = v;
240
+ g = p;
241
+ b = q;
242
+ break;
243
+ }
244
+ return { r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255) };
245
+ }
246
+ export function hsvToHex(h, s, v) {
247
+ const rgb = hsvToRgb(h, s, v);
248
+ const toHex = (n) => n.toString(16).padStart(2, '0');
249
+ return `#${toHex(rgb.r)}${toHex(rgb.g)}${toHex(rgb.b)}`;
250
+ }
251
+ export function hexToHsv(hex) {
252
+ const rgb = hexToRgb(hex);
253
+ if (rgb === null) {
254
+ return null;
255
+ }
256
+ return rgbToHsv(rgb.r, rgb.g, rgb.b);
257
+ }
258
+ export function hsvToHsl(h, s, v) {
259
+ const l = v * (1 - s / 2);
260
+ let sl = 0;
261
+ if (l > 0 && l < 1) {
262
+ sl = (v - l) / Math.min(l, 1 - l);
263
+ }
264
+ return { h: Math.round(h * 360), s: Math.round(sl * 100), l: Math.round(l * 100) };
265
+ }
266
+ export function hslToHsv(hDeg, sPct, lPct) {
267
+ const h = hDeg / 360;
268
+ const sl = sPct / 100;
269
+ const l = lPct / 100;
270
+ const v = l + sl * Math.min(l, 1 - l);
271
+ const sv = v === 0 ? 0 : 2 * (1 - l / v);
272
+ return { h, s: sv, v };
273
+ }
274
+ export function isValidHex(hex) {
275
+ return HEX_COLOR_PATTERN.test(hex);
276
+ }
277
+ export function clampInt(v, min, max) {
278
+ const n = parseInt(v, 10);
279
+ if (Number.isNaN(n)) {
280
+ return min;
281
+ }
282
+ return Math.max(min, Math.min(max, n));
283
+ }
284
+ // ── Misc ────────────────────────────────────────────────────────
167
285
  export function createDebouncer(delay) {
168
286
  let lastCallTime = 0;
169
287
  return function (callback, ...args) {
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.18.0",
4
4
  "description": "A themeable Svelte 5 UI component library with CSS custom property driven styling",
5
5
  "keywords": [
6
6
  "svelte",