@marianmeres/stuic 2.3.2 → 2.4.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 (89) hide show
  1. package/README.md +0 -1
  2. package/dist/README.md +17 -11
  3. package/dist/actions/autogrow.svelte.js +4 -4
  4. package/dist/actions/autoscroll.d.ts +2 -2
  5. package/dist/actions/autoscroll.js +17 -8
  6. package/dist/actions/file-dropzone.svelte.d.ts +1 -1
  7. package/dist/actions/file-dropzone.svelte.js +1 -1
  8. package/dist/actions/focus-trap.js +33 -24
  9. package/dist/actions/highlight-dragover.svelte.js +6 -5
  10. package/dist/actions/on-submit-validity-check.svelte.js +2 -2
  11. package/dist/actions/resizable-width.svelte.d.ts +1 -1
  12. package/dist/actions/resizable-width.svelte.js +7 -5
  13. package/dist/actions/tooltip/index.css +2 -7
  14. package/dist/actions/tooltip/tooltip.svelte.js +5 -4
  15. package/dist/actions/trim.svelte.d.ts +1 -1
  16. package/dist/actions/trim.svelte.js +2 -2
  17. package/dist/actions/validate.svelte.d.ts +4 -4
  18. package/dist/actions/validate.svelte.js +9 -9
  19. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.d.ts +7 -6
  20. package/dist/components/AlertConfirmPrompt/alert-confirm-prompt-stack.svelte.js +1 -2
  21. package/dist/components/AlertConfirmPrompt/index.d.ts +1 -1
  22. package/dist/components/AlertConfirmPrompt/index.js +1 -1
  23. package/dist/components/AnimatedElipsis/index.d.ts +1 -1
  24. package/dist/components/AnimatedElipsis/index.js +1 -1
  25. package/dist/components/Button/index.d.ts +1 -1
  26. package/dist/components/Button/index.js +1 -1
  27. package/dist/components/ButtonGroupRadio/ButtonGroupRadio.svelte +4 -1
  28. package/dist/components/ButtonGroupRadio/index.d.ts +1 -1
  29. package/dist/components/ButtonGroupRadio/index.js +1 -1
  30. package/dist/components/ColorScheme/index.d.ts +2 -2
  31. package/dist/components/ColorScheme/index.js +2 -2
  32. package/dist/components/CommandMenu/index.d.ts +1 -1
  33. package/dist/components/CommandMenu/index.js +1 -1
  34. package/dist/components/DismissibleMessage/index.d.ts +1 -1
  35. package/dist/components/DismissibleMessage/index.js +1 -1
  36. package/dist/components/HoverExpandableWidth/index.d.ts +1 -1
  37. package/dist/components/HoverExpandableWidth/index.js +1 -1
  38. package/dist/components/Input/FieldAssets.svelte +7 -3
  39. package/dist/components/Input/FieldLikeButton.svelte +1 -1
  40. package/dist/components/Input/FieldOptions.svelte +1 -1
  41. package/dist/components/Input/index.d.ts +7 -7
  42. package/dist/components/Input/index.js +7 -7
  43. package/dist/components/KbdShortcut/index.d.ts +1 -1
  44. package/dist/components/KbdShortcut/index.js +1 -1
  45. package/dist/components/ModalDialog/index.d.ts +1 -1
  46. package/dist/components/ModalDialog/index.js +1 -1
  47. package/dist/components/Notifications/index.d.ts +1 -1
  48. package/dist/components/Notifications/index.js +1 -1
  49. package/dist/components/Notifications/notifications-stack.svelte.d.ts +5 -5
  50. package/dist/components/Notifications/notifications-stack.svelte.js +8 -7
  51. package/dist/components/SlidingPanels/index.d.ts +1 -1
  52. package/dist/components/SlidingPanels/index.js +1 -1
  53. package/dist/components/Spinner/index.d.ts +1 -1
  54. package/dist/components/Spinner/index.js +1 -1
  55. package/dist/components/Switch/Switch.svelte +5 -2
  56. package/dist/components/Switch/index.d.ts +1 -1
  57. package/dist/components/Switch/index.js +1 -1
  58. package/dist/components/TypeaheadInput/index.d.ts +1 -1
  59. package/dist/components/TypeaheadInput/index.js +1 -1
  60. package/dist/utils/body-scroll-locker.js +4 -3
  61. package/dist/utils/breakpoint.svelte.js +0 -2
  62. package/dist/utils/colors.js +3 -3
  63. package/dist/utils/debounce.d.ts +1 -1
  64. package/dist/utils/debounce.js +1 -2
  65. package/dist/utils/escape-regex.js +1 -1
  66. package/dist/utils/event-emitter.d.ts +2 -3
  67. package/dist/utils/event-emitter.js +1 -2
  68. package/dist/utils/event-modifiers.d.ts +4 -4
  69. package/dist/utils/event-modifiers.js +4 -6
  70. package/dist/utils/get-file-type-label.js +1 -1
  71. package/dist/utils/is-image.js +2 -2
  72. package/dist/utils/is-nullish.d.ts +1 -1
  73. package/dist/utils/is-plain-object.d.ts +1 -1
  74. package/dist/utils/is-plain-object.js +4 -1
  75. package/dist/utils/maybe-json-parse.d.ts +1 -1
  76. package/dist/utils/maybe-json-parse.js +1 -1
  77. package/dist/utils/maybe-json-stringify.d.ts +1 -1
  78. package/dist/utils/move-array-item.d.ts +1 -1
  79. package/dist/utils/preload-img.js +2 -1
  80. package/dist/utils/sleep.d.ts +1 -1
  81. package/dist/utils/storage-abstraction.d.ts +13 -13
  82. package/dist/utils/storage-abstraction.js +2 -0
  83. package/dist/utils/svg-circle.js +2 -1
  84. package/dist/utils/switch.svelte.d.ts +1 -1
  85. package/dist/utils/switch.svelte.js +1 -1
  86. package/dist/utils/throttle.d.ts +1 -1
  87. package/dist/utils/throttle.js +7 -8
  88. package/dist/utils/to-integer.d.ts +1 -1
  89. package/package.json +6 -2
@@ -5,7 +5,7 @@
5
5
  */
6
6
  export declare class MemoryStorage {
7
7
  #private;
8
- setItem(key: string, value: any): void;
8
+ setItem(key: string, value: unknown): void;
9
9
  getItem(key: string): any;
10
10
  removeItem(key: string): void;
11
11
  clear(): void;
@@ -27,9 +27,9 @@ export declare class MemoryStorage {
27
27
  */
28
28
  export declare class StorageAbstraction {
29
29
  #private;
30
- constructor(storageType?: "local" | "session" | "memory", serializer?: (v: any) => string, deserializer?: (v: string) => any);
31
- set(key: string, value: any): this;
32
- get(key: string): any;
30
+ constructor(storageType?: "local" | "session" | "memory", serializer?: (v: unknown) => string, deserializer?: (v: string) => unknown);
31
+ set(key: string, value: unknown): this;
32
+ get(key: string): unknown;
33
33
  remove(key: string): boolean;
34
34
  clear(): boolean;
35
35
  has(key: string): boolean;
@@ -50,9 +50,9 @@ export declare class StorageAbstraction {
50
50
  * theme.set('dark'); // Persists to localStorage
51
51
  * ```
52
52
  */
53
- export declare function localStorageValue(key: string, initial: any): {
54
- get(): any;
55
- set(v: any): StorageAbstraction;
53
+ export declare function localStorageValue<T>(key: string, initial: T): {
54
+ get(): T;
55
+ set(v: T): StorageAbstraction;
56
56
  remove(): void;
57
57
  };
58
58
  /**
@@ -68,9 +68,9 @@ export declare function localStorageValue(key: string, initial: any): {
68
68
  * token.set('abc123');
69
69
  * ```
70
70
  */
71
- export declare function sessionStorageValue(key: string, initial: any): {
72
- get(): any;
73
- set(v: any): StorageAbstraction;
71
+ export declare function sessionStorageValue<T>(key: string, initial: T): {
72
+ get(): T;
73
+ set(v: T): StorageAbstraction;
74
74
  remove(): void;
75
75
  };
76
76
  /**
@@ -82,8 +82,8 @@ export declare function sessionStorageValue(key: string, initial: any): {
82
82
  * @param initial - Initial value if key doesn't exist
83
83
  * @returns An object with `get()`, `set()`, and `remove()` methods
84
84
  */
85
- export declare function memoryStorageValue(key: string, initial: any): {
86
- get(): any;
87
- set(v: any): StorageAbstraction;
85
+ export declare function memoryStorageValue<T>(key: string, initial: T): {
86
+ get(): T;
87
+ set(v: T): StorageAbstraction;
88
88
  remove(): void;
89
89
  };
@@ -64,6 +64,8 @@ export class StorageAbstraction {
64
64
  }
65
65
  #deserialize(value) {
66
66
  try {
67
+ if (value === null)
68
+ return null;
67
69
  return this.#deserializer(value);
68
70
  }
69
71
  catch (e) {
@@ -46,7 +46,8 @@ function _normalize_cls(v) {
46
46
  * ```
47
47
  */
48
48
  export function svgCircle(options = {}) {
49
- let { strokeWidth = 10, completeness = 1, bgStrokeColor = "", class: classProp = "", roundedEdges = true, rotate = 0, strokeWidthRatio = 0, circleStyle, } = options ?? {};
49
+ const { strokeWidth = 10, completeness: completenessInput = 1, bgStrokeColor = "", class: classProp = "", roundedEdges = true, rotate = 0, strokeWidthRatio = 0, circleStyle, } = options ?? {};
50
+ let completeness = completenessInput;
50
51
  completeness = _normalize_completness(completeness);
51
52
  // calculate radius based on viewBox, leaving room for stroke
52
53
  let actualStrokeWidth = strokeWidth;
@@ -34,7 +34,7 @@ export declare class SwitchState<T> {
34
34
  readonly key: string;
35
35
  readonly storageType: "memory" | "local" | "session";
36
36
  onOff: ((data: T, self: SwitchState<T>) => void) | undefined | null;
37
- constructor(key: string, initial?: boolean | null, storageType?: "memory" | "local" | "session", initialData?: any);
37
+ constructor(key: string, initial?: boolean | null, storageType?: "memory" | "local" | "session", initialData?: T | null);
38
38
  __set(value: boolean | null, data?: T | null | undefined): void;
39
39
  on(data?: T | null | undefined): void;
40
40
  off(data?: T | null | undefined): void;
@@ -68,7 +68,7 @@ export class SwitchState {
68
68
  if (data !== undefined)
69
69
  this.#data = data;
70
70
  // mirror to storage
71
- this.#storage?.set({ value, data });
71
+ this.#storage?.set({ value, data: data ?? null });
72
72
  // if we're closing fire (once) onOff if exists
73
73
  if (!value) {
74
74
  this.onOff?.(this.data, this);
@@ -17,4 +17,4 @@
17
17
  * // handleScroll will be called at most once every 300ms
18
18
  * ```
19
19
  */
20
- export declare function throttle<T extends (...args: any[]) => any>(func: T, limit: number): (...args: Parameters<T>) => void;
20
+ export declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, limit: number): (...args: Parameters<T>) => void;
@@ -20,9 +20,8 @@
20
20
  export function throttle(func, limit) {
21
21
  let lastCall = 0;
22
22
  let timeout = null;
23
- let lastArgs = null;
23
+ let pendingCall = null;
24
24
  return function (...args) {
25
- const context = this;
26
25
  const now = Date.now();
27
26
  // If enough time has passed since the last call
28
27
  if (now - lastCall >= limit) {
@@ -31,19 +30,19 @@ export function throttle(func, limit) {
31
30
  timeout = null;
32
31
  }
33
32
  lastCall = now;
34
- func.apply(context, args);
33
+ func.apply(this, args);
35
34
  }
36
35
  else {
37
- // Save the latest arguments
38
- lastArgs = args;
36
+ // Save the latest arguments and context
37
+ pendingCall = { args, context: this };
39
38
  // If there's no pending execution scheduled
40
39
  if (timeout === null) {
41
40
  timeout = setTimeout(() => {
42
41
  lastCall = Date.now();
43
42
  timeout = null;
44
- if (lastArgs !== null) {
45
- func.apply(context, lastArgs);
46
- lastArgs = null;
43
+ if (pendingCall !== null) {
44
+ func.apply(pendingCall.context, pendingCall.args);
45
+ pendingCall = null;
47
46
  }
48
47
  }, limit - (now - lastCall));
49
48
  }
@@ -16,4 +16,4 @@
16
16
  * toInteger('abc', 0); // 0 (custom fallback)
17
17
  * ```
18
18
  */
19
- export declare function toInteger(value: any, fallback?: number): number;
19
+ export declare function toInteger(value: unknown, fallback?: number): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -22,6 +22,7 @@
22
22
  "svelte": "^5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
+ "@eslint/js": "^9.39.2",
25
26
  "@marianmeres/icons-fns": "^4.4.0",
26
27
  "@marianmeres/random-human-readable": "^1.6.1",
27
28
  "@sveltejs/adapter-auto": "^4.0.0",
@@ -34,6 +35,8 @@
34
35
  "@tailwindcss/vite": "^4.1.18",
35
36
  "@types/node": "^25.0.3",
36
37
  "dotenv": "^16.6.1",
38
+ "eslint": "^9.39.2",
39
+ "globals": "^16.5.0",
37
40
  "prettier": "^3.7.4",
38
41
  "prettier-plugin-svelte": "^3.4.1",
39
42
  "publint": "^0.3.16",
@@ -41,6 +44,7 @@
41
44
  "svelte-check": "^4.3.5",
42
45
  "tailwindcss": "^4.1.18",
43
46
  "typescript": "^5.9.3",
47
+ "typescript-eslint": "^8.51.0",
44
48
  "vite": "^6.4.1",
45
49
  "vitest": "^3.2.4"
46
50
  },
@@ -62,7 +66,7 @@
62
66
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
63
67
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
64
68
  "format": "prettier --write .",
65
- "lint": "prettier --check .",
69
+ "lint": "eslint . && prettier --check .",
66
70
  "test": "vitest --dir src/",
67
71
  "svelte-check": "svelte-check",
68
72
  "svelte-package": "svelte-package"