svseeds 0.4.0 → 0.4.3

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 (51) hide show
  1. package/_svseeds/Accordion.svelte +31 -14
  2. package/_svseeds/Accordion.svelte.d.ts +20 -4
  3. package/_svseeds/DarkToggle.svelte +81 -41
  4. package/_svseeds/DarkToggle.svelte.d.ts +23 -4
  5. package/_svseeds/TagsInput.svelte +58 -28
  6. package/_svseeds/TagsInput.svelte.d.ts +34 -6
  7. package/_svseeds/TagsInputField.svelte +66 -33
  8. package/_svseeds/TagsInputField.svelte.d.ts +36 -4
  9. package/_svseeds/ToggleGroupField.svelte +59 -32
  10. package/_svseeds/ToggleGroupField.svelte.d.ts +30 -4
  11. package/_svseeds/_Badge.svelte +33 -17
  12. package/_svseeds/_Badge.svelte.d.ts +17 -2
  13. package/_svseeds/_Button.svelte +39 -20
  14. package/_svseeds/_Button.svelte.d.ts +20 -2
  15. package/_svseeds/_CheckField.svelte +54 -30
  16. package/_svseeds/_CheckField.svelte.d.ts +24 -2
  17. package/_svseeds/_ColorPicker.svelte +38 -17
  18. package/_svseeds/_ColorPicker.svelte.d.ts +21 -2
  19. package/_svseeds/_ComboBox.svelte +38 -20
  20. package/_svseeds/_ComboBox.svelte.d.ts +17 -2
  21. package/_svseeds/_ContextMenu.svelte +26 -12
  22. package/_svseeds/_ContextMenu.svelte.d.ts +15 -2
  23. package/_svseeds/_Disclosure.svelte +37 -21
  24. package/_svseeds/_Disclosure.svelte.d.ts +19 -3
  25. package/_svseeds/_HotkeyCapture.svelte +28 -13
  26. package/_svseeds/_HotkeyCapture.svelte.d.ts +16 -2
  27. package/_svseeds/_Modal.svelte +32 -15
  28. package/_svseeds/_Modal.svelte.d.ts +18 -3
  29. package/_svseeds/_ProgressTracker.svelte +31 -16
  30. package/_svseeds/_ProgressTracker.svelte.d.ts +16 -2
  31. package/_svseeds/_SelectField.svelte +53 -29
  32. package/_svseeds/_SelectField.svelte.d.ts +25 -2
  33. package/_svseeds/_Slider.svelte +43 -22
  34. package/_svseeds/_Slider.svelte.d.ts +22 -2
  35. package/_svseeds/_Sortable.svelte +57 -19
  36. package/_svseeds/_Sortable.svelte.d.ts +39 -2
  37. package/_svseeds/_Tabs.svelte +31 -17
  38. package/_svseeds/_Tabs.svelte.d.ts +16 -3
  39. package/_svseeds/_TextField.svelte +56 -31
  40. package/_svseeds/_TextField.svelte.d.ts +26 -2
  41. package/_svseeds/_Toggle.svelte +45 -25
  42. package/_svseeds/_Toggle.svelte.d.ts +21 -2
  43. package/_svseeds/_ToggleGroup.svelte +32 -15
  44. package/_svseeds/_ToggleGroup.svelte.d.ts +18 -2
  45. package/_svseeds/_Tooltip.svelte +32 -13
  46. package/_svseeds/_Tooltip.svelte.d.ts +20 -2
  47. package/_svseeds/core.d.ts +186 -8
  48. package/_svseeds/core.js +1 -1
  49. package/index.d.ts +24 -24
  50. package/index.js +3 -3
  51. package/package.json +1 -1
@@ -1,21 +1,40 @@
1
- export type ToggleProps = {
1
+ export interface ToggleProps {
2
2
  main?: Snippet<[string, boolean, HTMLButtonElement | undefined]>;
3
3
  left?: Snippet<[string, boolean, HTMLButtonElement | undefined]>;
4
4
  right?: Snippet<[string, boolean, HTMLButtonElement | undefined]>;
5
5
  value?: boolean;
6
6
  type?: "button" | "switch";
7
+ ariaLabel?: string;
7
8
  status?: string;
8
9
  style?: SVSStyle;
9
10
  attributes?: HTMLButtonAttributes;
10
11
  action?: Action;
11
12
  element?: HTMLButtonElement;
12
- };
13
+ }
13
14
  export type ToggleReqdProps = never;
14
15
  export type ToggleBindProps = "value" | "status" | "element";
15
16
  import { type Snippet } from "svelte";
16
17
  import { type Action } from "svelte/action";
17
18
  import { type HTMLButtonAttributes } from "svelte/elements";
18
19
  import { type SVSStyle } from "./core";
20
+ /**
21
+ * default value: `<value>`
22
+ * ```ts
23
+ * interface ToggleProps {
24
+ * main?: Snippet<[string, boolean, HTMLButtonElement | undefined]>; // Snippet<[status,value,element]>
25
+ * left?: Snippet<[string, boolean, HTMLButtonElement | undefined]>; // Snippet<[status,value,element]>
26
+ * right?: Snippet<[string, boolean, HTMLButtonElement | undefined]>; // Snippet<[status,value,element]>
27
+ * value?: boolean; // bindable <false>
28
+ * type?: "button" | "switch"; // <"button">
29
+ * ariaLabel?: string;
30
+ * status?: string; // bindable <STATE.NEUTRAL>
31
+ * style?: SVSStyle;
32
+ * attributes?: HTMLButtonAttributes;
33
+ * action?: Action;
34
+ * element?: HTMLButtonElement; // bindable
35
+ * }
36
+ * ```
37
+ */
19
38
  declare const Toggle: import("svelte").Component<ToggleProps, {}, "value" | "status" | "element">;
20
39
  type Toggle = ReturnType<typeof Toggle>;
21
40
  export default Toggle;
@@ -1,15 +1,32 @@
1
+ <!--
2
+ @component
3
+ default value: `<value>`
4
+ ```ts
5
+ interface ToggleGroupProps {
6
+ options: SvelteMap<string, string> | Map<string, string>;
7
+ values?: string[]; // bindable
8
+ multiple?: boolean; // <true>
9
+ ariaDescId?: string;
10
+ ariaErrMsgId?: string; // bindable
11
+ status?: string; // bindable <STATE.NEUTRAL>
12
+ style?: SVSStyle;
13
+ action?: Action;
14
+ [key: string]: unknown | Snippet<[string]>;
15
+ }
16
+ ```
17
+ -->
1
18
  <script module lang="ts">
2
- export type ToggleGroupProps = {
3
- options: SvelteMap<string, string> | Map<string, string>,
4
- values?: string[], // bindable
5
- multiple?: boolean, // <true>
6
- ariaDescId?: string,
7
- ariaErrMsgId?: string, // bindable
8
- status?: string, // bindable <STATE.DEFAULT>
9
- style?: SVSStyle,
10
- action?: Action,
11
- [key: string]: unknown | Snippet<[string]>,
12
- };
19
+ export interface ToggleGroupProps {
20
+ options: SvelteMap<string, string> | Map<string, string>;
21
+ values?: string[]; // bindable
22
+ multiple?: boolean; // <true>
23
+ ariaDescId?: string;
24
+ ariaErrMsgId?: string; // bindable
25
+ status?: string; // bindable <STATE.NEUTRAL>
26
+ style?: SVSStyle;
27
+ action?: Action;
28
+ [key: string]: unknown | Snippet<[string]>;
29
+ }
13
30
  export type ToggleGroupReqdProps = "options";
14
31
  export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "status";
15
32
 
@@ -24,14 +41,14 @@
24
41
  import { type Snippet } from "svelte";
25
42
  import { type Action } from "svelte/action";
26
43
  import { type SvelteMap } from "svelte/reactivity";
27
- import { type SVSStyle, STATE, AREA, fnClass } from "./core";
44
+ import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
28
45
  </script>
29
46
 
30
47
  <script lang="ts">
31
48
  let { options, values = $bindable([]), multiple = true, ariaDescId, ariaErrMsgId = $bindable(), status = $bindable(""), style, attributes, action, ...rest }: ToggleGroupProps = $props();
32
49
 
33
50
  // *** Initialize *** //
34
- if (!status) status = STATE.DEFAULT;
51
+ if (!status) status = STATE.NEUTRAL;
35
52
  const cls = fnClass(preset, style);
36
53
  const role = multiple ? "checkbox" : "radio";
37
54
  const roleGroup = multiple ? "group" : "radiogroup";
@@ -52,9 +69,9 @@
52
69
  <!---------------------------------------->
53
70
 
54
71
  {#if opts.length}
55
- <span class={cls(AREA.WHOLE, status)} role={roleGroup} aria-describedby={ariaDescId} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple ? ariaErrMsgId : undefined}>
72
+ <span class={cls(PARTS.WHOLE, status)} role={roleGroup} aria-describedby={ariaDescId} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple ? ariaErrMsgId : undefined}>
56
73
  {#each opts as { value, text, checked } (value)}
57
- {@const c = cls(AREA.MAIN, checked ? STATE.ACTIVE : status)}
74
+ {@const c = cls(PARTS.MAIN, checked ? STATE.ACTIVE : status)}
58
75
  {#if action}
59
76
  <button class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? ariaErrMsgId : undefined} onclick={updateValues(value)} type="button" {role} use:action>
60
77
  {@render content(value, text)}
@@ -1,4 +1,4 @@
1
- export type ToggleGroupProps = {
1
+ export interface ToggleGroupProps {
2
2
  options: SvelteMap<string, string> | Map<string, string>;
3
3
  values?: string[];
4
4
  multiple?: boolean;
@@ -8,13 +8,29 @@ export type ToggleGroupProps = {
8
8
  style?: SVSStyle;
9
9
  action?: Action;
10
10
  [key: string]: unknown | Snippet<[string]>;
11
- };
11
+ }
12
12
  export type ToggleGroupReqdProps = "options";
13
13
  export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "status";
14
14
  import { type Snippet } from "svelte";
15
15
  import { type Action } from "svelte/action";
16
16
  import { type SvelteMap } from "svelte/reactivity";
17
17
  import { type SVSStyle } from "./core";
18
+ /**
19
+ * default value: `<value>`
20
+ * ```ts
21
+ * interface ToggleGroupProps {
22
+ * options: SvelteMap<string, string> | Map<string, string>;
23
+ * values?: string[]; // bindable
24
+ * multiple?: boolean; // <true>
25
+ * ariaDescId?: string;
26
+ * ariaErrMsgId?: string; // bindable
27
+ * status?: string; // bindable <STATE.NEUTRAL>
28
+ * style?: SVSStyle;
29
+ * action?: Action;
30
+ * [key: string]: unknown | Snippet<[string]>;
31
+ * }
32
+ * ```
33
+ */
18
34
  declare const ToggleGroup: import("svelte").Component<ToggleGroupProps, {}, "status" | "values" | "ariaErrMsgId">;
19
35
  type ToggleGroup = ReturnType<typeof ToggleGroup>;
20
36
  export default ToggleGroup;
@@ -1,14 +1,33 @@
1
+ <!--
2
+ @component
3
+ default value: `<value>`
4
+ ```ts
5
+ interface TooltipProps {
6
+ main?: Snippet<[string, string, boolean]>; // Snippet<[status,text,isFlipped]>
7
+ name?: string;
8
+ position?: Position; // "top"
9
+ align?: Align; // "center"
10
+ offset?: Vector; // <{ x: 0, y: 0 }>
11
+ status?: string; // bindable <STATE.NEUTRAL>
12
+ style?: SVSStyle;
13
+ element?: HTMLDivElement; // bindable
14
+ }
15
+ type Vector = { x: number, y: number };
16
+ type Position = "top" | "left" | "bottom" | "right";
17
+ type Align = "start" | "center" | "end";
18
+ ```
19
+ -->
1
20
  <script module lang="ts">
2
- export type TooltipProps = {
3
- main?: Snippet<[string, string, boolean]>, // Snippet<[status,text,isFlipped]>
4
- name?: string,
5
- position?: Position, // "top"
6
- align?: Align, // "center"
7
- offset?: Vector, // <{ x: 0, y: 0 }>
8
- status?: string, // bindable <STATE.DEFAULT>
9
- style?: SVSStyle,
10
- element?: HTMLDivElement, // bindable
11
- };
21
+ export interface TooltipProps {
22
+ main?: Snippet<[string, string, boolean]>; // Snippet<[status,text,isFlipped]>
23
+ name?: string;
24
+ position?: Position; // "top"
25
+ align?: Align; // "center"
26
+ offset?: Vector; // <{ x: 0, y: 0 }>
27
+ status?: string; // bindable <STATE.NEUTRAL>
28
+ style?: SVSStyle;
29
+ element?: HTMLDivElement; // bindable
30
+ }
12
31
  export type TooltipReqdProps = never;
13
32
  export type TooltipBindProps = "status" | "element";
14
33
  export function tooltip(node: HTMLElement, params: { text: string, delay?: number, cursor?: boolean, name?: string }): ActionReturn {
@@ -228,14 +247,14 @@
228
247
  import { type Snippet, untrack } from "svelte";
229
248
  import { on } from "svelte/events";
230
249
  import { type Action, type ActionReturn } from "svelte/action";
231
- import { type SVSStyle, STATE, AREA, elemId, fnClass, throttle } from "./core";
250
+ import { type SVSStyle, STATE, PARTS, elemId, fnClass, throttle } from "./core";
232
251
  </script>
233
252
 
234
253
  <script lang="ts">
235
254
  let { main, name, position = "top", align = "center", offset = { ...INIT_VEC }, status = $bindable(""), style, element = $bindable() }: TooltipProps = $props();
236
255
 
237
256
  // *** Initialize *** //
238
- if (!status) status = STATE.DEFAULT;
257
+ if (!status) status = STATE.NEUTRAL;
239
258
  const cls = fnClass(preset, style);
240
259
  const id = core.register(name);
241
260
  let point: Vector = $state.raw(INIT_VEC);
@@ -256,7 +275,7 @@
256
275
  <!---------------------------------------->
257
276
 
258
277
  {#if core.mount(id)}
259
- <div bind:this={element} class={cls(AREA.WHOLE, status)} style={dynStyle} {id} role="tooltip">
278
+ <div bind:this={element} class={cls(PARTS.WHOLE, status)} style={dynStyle} {id} role="tooltip">
260
279
  {#if main}
261
280
  {@render main(status, core.text, core.flipped)}
262
281
  {:else}
@@ -1,4 +1,4 @@
1
- export type TooltipProps = {
1
+ export interface TooltipProps {
2
2
  main?: Snippet<[string, string, boolean]>;
3
3
  name?: string;
4
4
  position?: Position;
@@ -7,7 +7,7 @@ export type TooltipProps = {
7
7
  status?: string;
8
8
  style?: SVSStyle;
9
9
  element?: HTMLDivElement;
10
- };
10
+ }
11
11
  export type TooltipReqdProps = never;
12
12
  export type TooltipBindProps = "status" | "element";
13
13
  export declare function tooltip(node: HTMLElement, params: {
@@ -26,6 +26,24 @@ export type Align = "start" | "center" | "end";
26
26
  import { type Snippet } from "svelte";
27
27
  import { type Action, type ActionReturn } from "svelte/action";
28
28
  import { type SVSStyle } from "./core";
29
+ /**
30
+ * default value: `<value>`
31
+ * ```ts
32
+ * interface TooltipProps {
33
+ * main?: Snippet<[string, string, boolean]>; // Snippet<[status,text,isFlipped]>
34
+ * name?: string;
35
+ * position?: Position; // "top"
36
+ * align?: Align; // "center"
37
+ * offset?: Vector; // <{ x: 0, y: 0 }>
38
+ * status?: string; // bindable <STATE.NEUTRAL>
39
+ * style?: SVSStyle;
40
+ * element?: HTMLDivElement; // bindable
41
+ * }
42
+ * type Vector = { x: number, y: number };
43
+ * type Position = "top" | "left" | "bottom" | "right";
44
+ * type Align = "start" | "center" | "end";
45
+ * ```
46
+ */
29
47
  declare const Tooltip: import("svelte").Component<TooltipProps, {}, "status" | "element">;
30
48
  type Tooltip = ReturnType<typeof Tooltip>;
31
49
  export default Tooltip;
@@ -1,13 +1,18 @@
1
- export { type SVSStyle, CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId, };
2
- type ClassRule = Record<string, string> | string;
1
+ export { type SVSStyle, BASE, STATE, PARTS, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId, };
2
+ type ClassDictionary = Record<string, unknown>;
3
+ type ClassArray = (ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined)[];
4
+ type ClassPartialValue = string | ClassArray;
5
+ type ClassValue = ClassPartialValue | ClassDictionary;
6
+ type ClassRule = Record<string, ClassValue> | ClassPartialValue;
3
7
  type SVSStyle = Record<string, ClassRule> | string;
4
- declare const CONST = "const";
8
+ type ClassFn = (part: string, status: string) => ClassValue | undefined;
9
+ declare const BASE = "base";
5
10
  declare const STATE: Readonly<{
6
- DEFAULT: "default";
11
+ NEUTRAL: "neutral";
7
12
  ACTIVE: "active";
8
13
  INACTIVE: "inactive";
9
14
  }>;
10
- declare const AREA: Readonly<{
15
+ declare const PARTS: Readonly<{
11
16
  WHOLE: "whole";
12
17
  MIDDLE: "middle";
13
18
  MAIN: "main";
@@ -19,16 +24,189 @@ declare const AREA: Readonly<{
19
24
  AUX: "aux";
20
25
  EXTRA: "extra";
21
26
  }>;
27
+ /**
28
+ * Creates a function that dynamically generates CSS classes based on component parts and status.
29
+ *
30
+ * Compatible with ClassValue type available in Svelte 5.16+ class attributes,
31
+ * this function generates a ClassFn that returns appropriate CSS classes
32
+ * based on the combination of component parts and their states.
33
+ *
34
+ * @param preset - Preset style definition. Can be a string or style rule object
35
+ * @param style - Optional style definition. Takes precedence over preset when provided
36
+ *
37
+ * @returns Function that takes part and status parameters and returns ClassValue
38
+ *
39
+ * @example
40
+ * // String preset case
41
+ * const classFn = fnClass("my-preset");
42
+ * classFn("whole", "active"); // "my-preset whole active"
43
+ *
44
+ * @example
45
+ * // Rule-based case
46
+ * const rules = {
47
+ * whole: {
48
+ * base: "container",
49
+ * active: "container-active"
50
+ * },
51
+ * main: {
52
+ * base: "main-content"
53
+ * }
54
+ * };
55
+ * const classFn = fnClass(rules);
56
+ * classFn("whole", "neutral"); // "container"
57
+ * classFn("whole", "active"); // ["container", "container-active"]
58
+ * classFn("main", "neutral"); // "main-content"
59
+ * classFn("unknown", "active"); // undefined
60
+ *
61
+ * @example
62
+ * // Overriding preset with style
63
+ * const preset = "default-style";
64
+ * const customStyle = {
65
+ * button: {
66
+ * base: "btn",
67
+ * active: "btn-active"
68
+ * }
69
+ * };
70
+ * const classFn = fnClass(preset, customStyle);
71
+ * classFn("button", "active"); // ["btn", "btn-active"]
72
+ */
73
+ declare function fnClass(preset: SVSStyle, style?: SVSStyle): ClassFn;
74
+ /**
75
+ * Generates unique random alphabetic ID strings with collision detection.
76
+ * Uses a carefully selected character set of 50 letters (A-Y, a-y) to ensure
77
+ * uniform distribution when using Math.random(), and provides a reserved
78
+ * character space (Z, z) for manual ID injection without conflicts.
79
+ *
80
+ * In default, internal store for detecting collision is automatically cleared
81
+ * when it exceeds 100,000 entries to manage memory usage in long-running.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const idGen = new UniqueId(5);
86
+ * const id1 = idGen.id; // "AbCdE"
87
+ * const id2 = idGen.id; // "XyaBc" (guaranteed to be different from id1)
88
+ *
89
+ * // Conditional generation
90
+ * const conditionalId = idGen.get(someCondition); // string | undefined
91
+ *
92
+ * // Manual injection with reserved characters
93
+ * const manualId = "zTest"; // Will never conflict with generated IDs
94
+ * ```
95
+ */
22
96
  declare class UniqueId {
23
97
  #private;
98
+ /**
99
+ * Gets a new unique ID string. Always returns a string (never undefined).
100
+ *
101
+ * @returns A unique alphabetic ID string
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const generator = new UniqueId();
106
+ * const myId = generator.id; // "AbC"
107
+ * ```
108
+ */
24
109
  get id(): string;
25
- constructor(len?: number);
110
+ /**
111
+ * Creates a new UniqueId generator instance.
112
+ *
113
+ * @param len - The length of generated ID strings (minimum 3, defaults to 3)
114
+ * @param limit - Maximum number of IDs to store before clearing the internal store (defaults to 100,000)
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const shortIds = new UniqueId(4); // Generates 4-character IDs
119
+ * const longIds = new UniqueId(8); // Generates 8-character IDs
120
+ * ```
121
+ */
122
+ constructor(len?: number, limit?: number);
123
+ /**
124
+ * Conditionally generates a unique ID string based on the provided value.
125
+ * Returns undefined if the value is falsy. The internal store is automatically
126
+ * cleared if it exceeds 100,000 entries to prevent excessive memory usage.
127
+ *
128
+ * @param v - A value to check for truthiness
129
+ * @returns A unique ID string if the value is truthy, undefined otherwise
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const generator = new UniqueId();
134
+ * const id1 = generator.get(true); // "AbCd"
135
+ * const id2 = generator.get(false); // undefined
136
+ * const id3 = generator.get("hello"); // "XyAb"
137
+ * const id4 = generator.get(null); // undefined
138
+ * ```
139
+ */
26
140
  get(v: unknown): string | undefined;
27
141
  }
28
142
  declare const elemId: UniqueId;
29
- type ClassFn = (area: string, status: string) => string | undefined;
30
- declare function fnClass(preset: SVSStyle, style?: SVSStyle): ClassFn;
143
+ /**
144
+ * Determines whether a status is in a neutral state (neither ACTIVE nor INACTIVE).
145
+ *
146
+ * @param status - The status string to check
147
+ * @returns false if the status is ACTIVE or INACTIVE, true otherwise
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * isNeutral(STATE.NEUTRAL); // true
152
+ * isNeutral("custom state"); // true
153
+ * isNeutral(STATE.ACTIVE); // false
154
+ * isNeutral(STATE.INACTIVE); // false
155
+ * ```
156
+ */
31
157
  declare function isNeutral(status: string): boolean;
158
+ /**
159
+ * Creates a new object with specified keys omitted from the original object.
160
+ * Returns an empty object if the input object is undefined or null.
161
+ *
162
+ * @param obj - The source object to omit keys from
163
+ * @param keys - The keys to omit from the object
164
+ * @returns A new object with the specified keys removed, or an empty object if input is falsy
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const user = { id: 1, name: "John", email: "john@example.com" };
169
+ * const publicUser = omit(user, "email"); // { id: 1, name: "John" }
170
+ * const empty = omit(undefined, "key"); // {}
171
+ * ```
172
+ */
32
173
  declare function omit<T extends object, K extends keyof T>(obj?: T, ...keys: K[]): Omit<T, K> | Record<string, never>;
174
+ /**
175
+ * Creates a debounced function that delays invoking the provided function until after
176
+ * the specified delay has elapsed since the last time it was invoked.
177
+ *
178
+ * @param delay - The number of milliseconds to delay
179
+ * @param fn - The function to debounce
180
+ * @returns A debounced version of the function
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const debouncedSearch = debounce(300, (query: string) => {
185
+ * console.log("Searching for:", query);
186
+ * });
187
+ *
188
+ * debouncedSearch("hello"); // Will only execute after 300ms of no further calls
189
+ * debouncedSearch("hello world"); // Cancels previous call, waits another 300ms
190
+ * ```
191
+ */
33
192
  declare function debounce<Args extends unknown[], R>(delay: number, fn: (...args: Args) => R): (...args: Args) => void;
193
+ /**
194
+ * Creates a throttled function that only invokes the provided function at most once
195
+ * per specified interval. Subsequent calls within the interval are queued and executed
196
+ * at the next available interval boundary.
197
+ *
198
+ * @param interval - The number of milliseconds to throttle invocations to
199
+ * @param fn - The function to throttle
200
+ * @returns A throttled version of the function
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * const throttledScroll = throttle(100, (event: Event) => {
205
+ * console.log("Scroll event handled");
206
+ * });
207
+ *
208
+ * window.addEventListener("scroll", throttledScroll);
209
+ * // Will execute at most once every 100ms, even if scroll events fire more frequently
210
+ * ```
211
+ */
34
212
  declare function throttle<Args extends unknown[], R>(interval: number, fn: (...args: Args) => R): (...args: Args) => void;
package/_svseeds/core.js CHANGED
@@ -1 +1 @@
1
- var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var r,n=1,e=arguments.length;n<e;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t},t.apply(this,arguments)},r=this&&this.__classPrivateFieldSet||function(t,r,n,e,i){if("m"===e)throw new TypeError("Private method is not writable");if("a"===e&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!i:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===e?i.call(t,n):i?i.value=n:r.set(t,n),n},n=this&&this.__classPrivateFieldGet||function(t,r,n,e){if("a"===n&&!e)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!e:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?e:"a"===n?e.call(t):e?e.value:r.get(t)},e=this&&this.__spreadArray||function(t,r,n){if(n||2===arguments.length)for(var e,i=0,o=r.length;i<o;i++)!e&&i in r||(e||(e=Array.prototype.slice.call(r,0,i)),e[i]=r[i]);return t.concat(e||Array.prototype.slice.call(r))};export{i as CONST,o as STATE,a as AREA,u as elemId,l as fnClass,s as isNeutral,h as omit,v as debounce,d as throttle,c as UniqueId};var i="const",o=Object.freeze({DEFAULT:"default",ACTIVE:"active",INACTIVE:"inactive"}),a=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"}),c=function(){function t(t){void 0===t&&(t=4),i.add(this),c.set(this,new Set),u.set(this,4),t>2&&r(this,u,t,"f")}var i,o,a,c,u,l,f,s;return Object.defineProperty(t.prototype,"id",{get:function(){return this.get(!0)},enumerable:!1,configurable:!0}),t.prototype.get=function(t){if(t)return n(this,c,"f").size>1e4&&n(this,c,"f").clear(),n(this,i,"m",s).call(this)},o=t,c=new WeakMap,u=new WeakMap,i=new WeakSet,l=function(){return n(o,o,"f",a)[Math.trunc(Math.random()*n(o,o,"f",a).length)]},f=function(){var t=this;return String.fromCharCode.apply(String,Array(n(this,u,"f")).fill(null).map((function(){return n(t,i,"m",l).call(t)})))},s=function(){for(var t=n(this,i,"m",f).call(this);n(this,c,"f").has(t);)t=n(this,i,"m",f).call(this);return n(this,c,"f").add(t),t},a={value:e(e([],Array.from(Array(25).keys(),(function(t){return t+65})),!0),Array.from(Array(25).keys(),(function(t){return t+97})),!0)},t}(),u=new c;function l(t,r){var n,e=null!==(n=f(r))&&void 0!==n?n:f(t);return null==e?function(t,r){}:"string"==typeof e?function(t,r){return"".concat(e," ").concat(t," ").concat(r)}:function(t,r){return function(t,r,n){var e,a,c,u,l,f,s=null!==(a=null===(e=t[r])||void 0===e?void 0:e[i])&&void 0!==a?a:"",h=null!==(f=null!==(u=null===(c=t[r])||void 0===c?void 0:c[n])&&void 0!==u?u:null===(l=t[r])||void 0===l?void 0:l[o.DEFAULT])&&void 0!==f?f:"";if(!s&&!h)return;return"".concat(s).concat(s&&h?" ":"").concat(h)}(e,t,r)}}function f(t){if(null!=t){if("string"==typeof t)return t.trim()?t:void 0;var r=Object.entries(t);if(r.length)return Object.fromEntries(r.map((function(t){var r=t[0],n=t[1];return"string"==typeof n?[r,{const:n}]:[r,n]})))}}function s(t){return t!==o.ACTIVE&&t!==o.INACTIVE}function h(r){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];if(!r)return{};var i=t({},r);return n.forEach((function(t){return delete i[t]})),i}function v(t,r){var n;return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];n&&clearTimeout(n),n=setTimeout((function(){r.call.apply(r,e([null],i,!1))}),t)}}function d(t,r){var n,i=0,o=function(){return Date.now()-i},a=function(t){r.call.apply(r,e([null],t,!1)),i=Date.now()};return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return a(r);clearTimeout(n),n=setTimeout((function(){o()>=t&&a(r)}),t-o())}}
1
+ export{t as BASE,e as STATE,r as PARTS,s as elemId,n as fnClass,a as isNeutral,u as omit,c as debounce,l as throttle,o as UniqueId};const t="base",e=Object.freeze({NEUTRAL:"neutral",ACTIVE:"active",INACTIVE:"inactive"}),r=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"});function n(r,n){const o=i(n)??i(r);return null==o?(t,e)=>{}:"string"==typeof o?(t,e)=>`${o} ${t} ${e}`:(r,n)=>function(r,n,i){const o=r[n]?.[t]??"",s=r[n]?.[i]??r[n]?.[e.NEUTRAL]??"";if(!o&&!s)return;return o&&s?[o,s]:o||s}(o,r,n)}function i(t){if(null==t)return;if("string"==typeof t)return t.trim()?t:void 0;const e=Object.entries(t);return e.length?Object.fromEntries(e.map((([t,e])=>null===e||"object"!=typeof e||Array.isArray(e)?[t,{base:e}]:[t,e]))):void 0}class o{static#t=[...Array.from(Array(25).keys(),(t=>t+65)),...Array.from(Array(25).keys(),(t=>t+97))];#e=new Set;#r=3;#n=1e5;get id(){return this.get(!0)}constructor(t=3,e=1e5){t>2&&(this.#r=t),(e=Math.trunc(e))>0&&e<Math.min(Math.pow(50,this.#r),Number.MAX_SAFE_INTEGER)&&(this.#n=e)}get(t){if(t)return this.#e.size>this.#n&&this.#e.clear(),this.#i()}#o(){return o.#t[Math.trunc(Math.random()*o.#t.length)]}#s(){return String.fromCharCode(...Array(this.#r).fill(null).map((()=>this.#o())))}#i(){let t=this.#s();for(;this.#e.has(t);)t=this.#s();return this.#e.add(t),t}}const s=new o;function a(t){return t!==e.ACTIVE&&t!==e.INACTIVE}function u(t,...e){if(!t)return{};const r={...t};return e.forEach((t=>delete r[t])),r}function c(t,e){let r;return(...n)=>{r&&clearTimeout(r),r=setTimeout((()=>{e.call(null,...n)}),t)}}function l(t,e){let r,n=0;const i=()=>Date.now()-n,o=t=>{e.call(null,...t),n=Date.now()};return(...e)=>{if(!n)return o(e);clearTimeout(r),r=setTimeout((()=>{i()>=t&&o(e)}),t-i())}}
package/index.d.ts CHANGED
@@ -1,24 +1,24 @@
1
- export { type SVSStyle, CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
2
- export { default as Badge, type BadgeProps, type BadgeReqdProps, type BadgeBindProps } from "./_svseeds/_Badge.svelte";
3
- export { default as Button, type ButtonProps, type ButtonReqdProps, type ButtonBindProps } from "./_svseeds/_Button.svelte";
4
- export { default as CheckField, type CheckFieldProps, type CheckFieldReqdProps, type CheckFieldBindProps, type CheckFieldValidation } from "./_svseeds/_CheckField.svelte";
5
- export { default as ColorPicker, type ColorPickerProps, type ColorPickerReqdProps, type ColorPickerBindProps, getHex } from "./_svseeds/_ColorPicker.svelte";
6
- export { default as ComboBox, type ComboBoxProps, type ComboBoxReqdProps, type ComboBoxBindProps } from "./_svseeds/_ComboBox.svelte";
7
- export { default as ContextMenu, type ContextMenuProps, type ContextMenuReqdProps, type ContextMenuBindProps } from "./_svseeds/_ContextMenu.svelte";
8
- export { default as Disclosure, type DisclosureProps, type DisclosureReqdProps, type DisclosureBindProps } from "./_svseeds/_Disclosure.svelte";
9
- export { default as HotkeyCapture, type HotkeyCaptureProps, type HotkeyCaptureReqdProps, type HotkeyCaptureBindProps } from "./_svseeds/_HotkeyCapture.svelte";
10
- export { default as Modal, type ModalProps, type ModalReqdProps, type ModalBindProps } from "./_svseeds/_Modal.svelte";
11
- export { default as ProgressTracker, type ProgressTrackerProps, type ProgressTrackerReqdProps, type ProgressTrackerBindProps } from "./_svseeds/_ProgressTracker.svelte";
12
- export { default as SelectField, type SelectFieldProps, type SelectFieldReqdProps, type SelectFieldBindProps, type SelectFieldValidation } from "./_svseeds/_SelectField.svelte";
13
- export { default as Slider, type SliderProps, type SliderReqdProps, type SliderBindProps, type Range } from "./_svseeds/_Slider.svelte";
14
- export { default as Sortable, type SortableProps, type SortableReqdProps, type SortableBindProps, SortableItems } from "./_svseeds/_Sortable.svelte";
15
- export { default as Tabs, type TabsProps, type TabsReqdProps, type TabsBindProps } from "./_svseeds/_Tabs.svelte";
16
- export { default as TextField, type TextFieldProps, type TextFieldReqdProps, type TextFieldBindProps, type TextFieldValidation } from "./_svseeds/_TextField.svelte";
17
- export { default as Toggle, type ToggleProps, type ToggleReqdProps, type ToggleBindProps } from "./_svseeds/_Toggle.svelte";
18
- export { default as ToggleGroup, type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_svseeds/_ToggleGroup.svelte";
19
- export { default as Tooltip, type TooltipProps, type TooltipReqdProps, type TooltipBindProps, type Vector, type Position, type Align, tooltip, tooltipAction } from "./_svseeds/_Tooltip.svelte";
20
- export { default as Accordion, type AccordionProps, type AccordionDeps, type AccordionReqdProps, type AccordionBindProps } from "./_svseeds/Accordion.svelte";
21
- export { default as DarkToggle, type DarkToggleProps, type DarkToggleDeps, type DarkToggleReqdProps, type DarkToggleBindProps } from "./_svseeds/DarkToggle.svelte";
22
- export { default as TagsInput, type TagsInputProps, type TagsInputDeps, type TagsInputReqdProps, type TagsInputBindProps, type TagsInputEvents } from "./_svseeds/TagsInput.svelte";
23
- export { default as TagsInputField, type TagsInputFieldProps, type TagsInputFieldDeps, type TagsInputFieldReqdProps, type TagsInputFieldBindProps, type TagsInputFieldConstraint, type TagsInputFieldValidation, type TagsInputFieldCountValidation } from "./_svseeds/TagsInputField.svelte";
24
- export { default as ToggleGroupField, type ToggleGroupFieldProps, type ToggleGroupFieldDeps, type ToggleGroupFieldReqdProps, type ToggleGroupFieldBindProps, type ToggleGroupFieldValidation } from "./_svseeds/ToggleGroupField.svelte";
1
+ export { type SVSStyle, BASE, STATE, PARTS, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
2
+ export { default as Badge, type BadgeReqdProps, type BadgeBindProps } from "./_svseeds/_Badge.svelte";
3
+ export { default as Button, type ButtonReqdProps, type ButtonBindProps } from "./_svseeds/_Button.svelte";
4
+ export { default as CheckField, type CheckFieldReqdProps, type CheckFieldBindProps, type CheckFieldValidation } from "./_svseeds/_CheckField.svelte";
5
+ export { default as ColorPicker, type ColorPickerReqdProps, type ColorPickerBindProps, getHex, getHex } from "./_svseeds/_ColorPicker.svelte";
6
+ export { default as ComboBox, type ComboBoxReqdProps, type ComboBoxBindProps } from "./_svseeds/_ComboBox.svelte";
7
+ export { default as ContextMenu, type ContextMenuReqdProps, type ContextMenuBindProps } from "./_svseeds/_ContextMenu.svelte";
8
+ export { default as Disclosure, type DisclosureReqdProps, type DisclosureBindProps } from "./_svseeds/_Disclosure.svelte";
9
+ export { default as HotkeyCapture, type HotkeyCaptureReqdProps, type HotkeyCaptureBindProps } from "./_svseeds/_HotkeyCapture.svelte";
10
+ export { default as Modal, type ModalReqdProps, type ModalBindProps } from "./_svseeds/_Modal.svelte";
11
+ export { default as ProgressTracker, type ProgressTrackerReqdProps, type ProgressTrackerBindProps } from "./_svseeds/_ProgressTracker.svelte";
12
+ export { default as SelectField, type SelectFieldReqdProps, type SelectFieldBindProps, type SelectFieldValidation } from "./_svseeds/_SelectField.svelte";
13
+ export { default as Slider, type SliderReqdProps, type SliderBindProps, type Range } from "./_svseeds/_Slider.svelte";
14
+ export { default as Sortable, type SortableReqdProps, type SortableBindProps, SortableItems } from "./_svseeds/_Sortable.svelte";
15
+ export { default as Tabs, type TabsReqdProps, type TabsBindProps } from "./_svseeds/_Tabs.svelte";
16
+ export { default as TextField, type TextFieldReqdProps, type TextFieldBindProps, type TextFieldValidation } from "./_svseeds/_TextField.svelte";
17
+ export { default as Toggle, type ToggleReqdProps, type ToggleBindProps } from "./_svseeds/_Toggle.svelte";
18
+ export { default as ToggleGroup, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_svseeds/_ToggleGroup.svelte";
19
+ export { default as Tooltip, type TooltipReqdProps, type TooltipBindProps, type Vector, type Position, type Align, tooltip, tooltipAction } from "./_svseeds/_Tooltip.svelte";
20
+ export { default as Accordion, type AccordionReqdProps, type AccordionBindProps } from "./_svseeds/Accordion.svelte";
21
+ export { default as DarkToggle, type DarkToggleReqdProps, type DarkToggleBindProps, THEME, setThemeToRoot } from "./_svseeds/DarkToggle.svelte";
22
+ export { default as TagsInput, type TagsInputReqdProps, type TagsInputBindProps } from "./_svseeds/TagsInput.svelte";
23
+ export { default as TagsInputField, type TagsInputFieldReqdProps, type TagsInputFieldBindProps, type TagsInputFieldConstraint, type TagsInputFieldValidation, type TagsInputFieldCountValidation } from "./_svseeds/TagsInputField.svelte";
24
+ export { default as ToggleGroupField, type ToggleGroupFieldReqdProps, type ToggleGroupFieldBindProps, type ToggleGroupFieldValidation } from "./_svseeds/ToggleGroupField.svelte";
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
1
+ export { BASE, STATE, PARTS, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId } from "./_svseeds/core";
2
2
  export { default as Badge } from "./_svseeds/_Badge.svelte";
3
3
  export { default as Button } from "./_svseeds/_Button.svelte";
4
4
  export { default as CheckField } from "./_svseeds/_CheckField.svelte";
5
- export { default as ColorPicker, getHex } from "./_svseeds/_ColorPicker.svelte";
5
+ export { default as ColorPicker, getHex, getHex } from "./_svseeds/_ColorPicker.svelte";
6
6
  export { default as ComboBox } from "./_svseeds/_ComboBox.svelte";
7
7
  export { default as ContextMenu } from "./_svseeds/_ContextMenu.svelte";
8
8
  export { default as Disclosure } from "./_svseeds/_Disclosure.svelte";
@@ -18,7 +18,7 @@ export { default as Toggle } from "./_svseeds/_Toggle.svelte";
18
18
  export { default as ToggleGroup } from "./_svseeds/_ToggleGroup.svelte";
19
19
  export { default as Tooltip, tooltip, tooltipAction } from "./_svseeds/_Tooltip.svelte";
20
20
  export { default as Accordion } from "./_svseeds/Accordion.svelte";
21
- export { default as DarkToggle } from "./_svseeds/DarkToggle.svelte";
21
+ export { default as DarkToggle, THEME, setThemeToRoot } from "./_svseeds/DarkToggle.svelte";
22
22
  export { default as TagsInput } from "./_svseeds/TagsInput.svelte";
23
23
  export { default as TagsInputField } from "./_svseeds/TagsInputField.svelte";
24
24
  export { default as ToggleGroupField } from "./_svseeds/ToggleGroupField.svelte";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svseeds",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Simple components for Svelte.",
5
5
  "type": "module",
6
6
  "main": "./index.js",