svseeds 0.4.7 → 0.4.8

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 (49) hide show
  1. package/_svseeds/Accordion.svelte +14 -14
  2. package/_svseeds/Accordion.svelte.d.ts +8 -8
  3. package/_svseeds/DarkToggle.svelte +12 -12
  4. package/_svseeds/DarkToggle.svelte.d.ts +4 -4
  5. package/_svseeds/TagsInputField.svelte +38 -39
  6. package/_svseeds/TagsInputField.svelte.d.ts +13 -13
  7. package/_svseeds/ToggleGroupField.svelte +32 -32
  8. package/_svseeds/ToggleGroupField.svelte.d.ts +13 -13
  9. package/_svseeds/_Button.svelte +20 -19
  10. package/_svseeds/_Button.svelte.d.ts +11 -11
  11. package/_svseeds/_CheckField.svelte +26 -26
  12. package/_svseeds/_CheckField.svelte.d.ts +9 -9
  13. package/_svseeds/_ColorPicker.svelte +11 -11
  14. package/_svseeds/_ColorPicker.svelte.d.ts +7 -7
  15. package/_svseeds/_ComboBox.svelte +14 -14
  16. package/_svseeds/_ComboBox.svelte.d.ts +7 -7
  17. package/_svseeds/_ContextMenu.svelte +13 -13
  18. package/_svseeds/_ContextMenu.svelte.d.ts +9 -9
  19. package/_svseeds/_Disclosure.svelte +26 -24
  20. package/_svseeds/_Disclosure.svelte.d.ts +10 -10
  21. package/_svseeds/_HotkeyCapture.svelte +14 -14
  22. package/_svseeds/_HotkeyCapture.svelte.d.ts +7 -7
  23. package/_svseeds/_Modal.svelte +14 -14
  24. package/_svseeds/_Modal.svelte.d.ts +9 -9
  25. package/_svseeds/_ProgressTracker.svelte +24 -23
  26. package/_svseeds/_ProgressTracker.svelte.d.ts +13 -13
  27. package/_svseeds/_SelectField.svelte +31 -31
  28. package/_svseeds/_SelectField.svelte.d.ts +10 -10
  29. package/_svseeds/_Slider.svelte +21 -20
  30. package/_svseeds/_Slider.svelte.d.ts +12 -12
  31. package/_svseeds/_Sortable.svelte +18 -18
  32. package/_svseeds/_Sortable.svelte.d.ts +9 -9
  33. package/_svseeds/_Tabs.svelte +20 -20
  34. package/_svseeds/_Tabs.svelte.d.ts +8 -8
  35. package/_svseeds/_TagsInput.svelte +21 -21
  36. package/_svseeds/_TagsInput.svelte.d.ts +9 -9
  37. package/_svseeds/_TextField.svelte +32 -32
  38. package/_svseeds/_TextField.svelte.d.ts +10 -10
  39. package/_svseeds/_Toggle.svelte +25 -29
  40. package/_svseeds/_Toggle.svelte.d.ts +13 -15
  41. package/_svseeds/_ToggleGroup.svelte +13 -13
  42. package/_svseeds/_ToggleGroup.svelte.d.ts +8 -8
  43. package/_svseeds/_Tooltip.svelte +14 -14
  44. package/_svseeds/_Tooltip.svelte.d.ts +9 -9
  45. package/_svseeds/core.d.ts +33 -16
  46. package/_svseeds/core.js +1 -1
  47. package/index.d.ts +1 -1
  48. package/index.js +1 -1
  49. package/package.json +1 -1
@@ -3,41 +3,41 @@
3
3
  default value: `(value)`
4
4
  ```ts
5
5
  interface ContextMenuProps {
6
- children: Snippet;
6
+ children: Snippet<[string]>; // Snippet<[variant]>
7
7
  open?: boolean; // bindable (false); to observe state, not to control
8
8
  lock?: boolean; // bindable (false)
9
- status?: string; // bindable (STATE.NEUTRAL)
10
- style?: SVSStyle;
11
9
  element?: HTMLElement; // bindable
10
+ styling?: SVSClass;
11
+ variant?: string; // bindable (VARIANT.NEUTRAL)
12
12
  }
13
13
  ```
14
14
  -->
15
15
  <script module lang="ts">
16
16
  export interface ContextMenuProps {
17
- children: Snippet;
17
+ children: Snippet<[string]>; // Snippet<[variant]>
18
18
  open?: boolean; // bindable (false); to observe state, not to control
19
19
  lock?: boolean; // bindable (false)
20
- status?: string; // bindable (STATE.NEUTRAL)
21
- style?: SVSStyle;
22
20
  element?: HTMLElement; // bindable
21
+ styling?: SVSClass;
22
+ variant?: string; // bindable (VARIANT.NEUTRAL)
23
23
  }
24
24
  export type ContextMenuReqdProps = "children";
25
- export type ContextMenuBindProps = "open" | "lock" | "status" | "element";
25
+ export type ContextMenuBindProps = "open" | "lock" | "variant" | "element";
26
26
 
27
27
  const preset = "svs-context-menu";
28
28
 
29
29
  import { type Snippet } from "svelte";
30
- import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
30
+ import { type SVSClass, VARIANT, PARTS, fnClass } from "./core";
31
31
  </script>
32
32
 
33
33
  <!---------------------------------------->
34
34
 
35
35
  <script lang="ts">
36
- let { children, open = $bindable(false), lock = $bindable(false), status = $bindable(""), style, element = $bindable() }: ContextMenuProps = $props();
36
+ let { children, open = $bindable(false), lock = $bindable(false), element = $bindable(), styling, variant = $bindable("") }: ContextMenuProps = $props();
37
37
 
38
38
  // *** Initialize *** //
39
- if (!status) status = STATE.NEUTRAL;
40
- const cls = fnClass(preset, style);
39
+ if (!variant) variant = VARIANT.NEUTRAL;
40
+ const cls = fnClass(preset, styling);
41
41
  let position = $state({ x: 0, y: 0 });
42
42
 
43
43
  // *** Bind Handlers *** //
@@ -60,6 +60,6 @@
60
60
  <!---------------------------------------->
61
61
  <svelte:document oncontextmenu={show} onclick={hide} />
62
62
 
63
- <nav class={cls(PARTS.WHOLE, status)} style={dynStyle} bind:this={element}>
64
- {@render children()}
63
+ <nav class={cls(PARTS.WHOLE, variant)} style={dynStyle} bind:this={element}>
64
+ {@render children(variant)}
65
65
  </nav>
@@ -1,28 +1,28 @@
1
1
  export interface ContextMenuProps {
2
- children: Snippet;
2
+ children: Snippet<[string]>;
3
3
  open?: boolean;
4
4
  lock?: boolean;
5
- status?: string;
6
- style?: SVSStyle;
7
5
  element?: HTMLElement;
6
+ styling?: SVSClass;
7
+ variant?: string;
8
8
  }
9
9
  export type ContextMenuReqdProps = "children";
10
- export type ContextMenuBindProps = "open" | "lock" | "status" | "element";
10
+ export type ContextMenuBindProps = "open" | "lock" | "variant" | "element";
11
11
  import { type Snippet } from "svelte";
12
- import { type SVSStyle } from "./core";
12
+ import { type SVSClass } from "./core";
13
13
  /**
14
14
  * default value: `(value)`
15
15
  * ```ts
16
16
  * interface ContextMenuProps {
17
- * children: Snippet;
17
+ * children: Snippet<[string]>; // Snippet<[variant]>
18
18
  * open?: boolean; // bindable (false); to observe state, not to control
19
19
  * lock?: boolean; // bindable (false)
20
- * status?: string; // bindable (STATE.NEUTRAL)
21
- * style?: SVSStyle;
22
20
  * element?: HTMLElement; // bindable
21
+ * styling?: SVSClass;
22
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
23
23
  * }
24
24
  * ```
25
25
  */
26
- declare const ContextMenu: import("svelte").Component<ContextMenuProps, {}, "open" | "status" | "element" | "lock">;
26
+ declare const ContextMenu: import("svelte").Component<ContextMenuProps, {}, "variant" | "open" | "element" | "lock">;
27
27
  type ContextMenu = ReturnType<typeof ContextMenu>;
28
28
  export default ContextMenu;
@@ -3,34 +3,35 @@
3
3
  default value: `(value)`
4
4
  ```ts
5
5
  interface DisclosureProps {
6
- label: string | Snippet<[boolean,string]>; // Snippet<[open,status]>
7
- children: Snippet;
6
+ label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
7
+ children: Snippet<[string]>; // Snippet<[variant]>
8
8
  open?: boolean; // bindable (false)
9
9
  duration?: number; // (400)
10
- status?: string; // bindable (STATE.NEUTRAL)
11
- style?: SVSStyle;
12
10
  attributes?: HTMLDetailsAttributes;
13
11
  action?: Action;
14
12
  element?: HTMLDetailsElement; // bindable
13
+ styling?: SVSClass;
14
+ variant?: string; // bindable (VARIANT.NEUTRAL)
15
15
  }
16
16
  ```
17
17
  -->
18
18
  <script module lang="ts">
19
19
  export interface DisclosureProps {
20
- label: string | Snippet<[boolean,string]>; // Snippet<[open,status]>
21
- children: Snippet;
20
+ label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
21
+ children: Snippet<[string]>; // Snippet<[variant]>
22
22
  open?: boolean; // bindable (false)
23
23
  duration?: number; // (400)
24
- status?: string; // bindable (STATE.NEUTRAL)
25
- style?: SVSStyle;
26
24
  attributes?: HTMLDetailsAttributes;
27
25
  action?: Action;
28
26
  element?: HTMLDetailsElement; // bindable
27
+ styling?: SVSClass;
28
+ variant?: string; // bindable (VARIANT.NEUTRAL)
29
29
  }
30
30
  export type DisclosureReqdProps = "label" | "children";
31
- export type DisclosureBindProps = "open" | "status" | "element";
31
+ export type DisclosureBindProps = "open" | "variant" | "element";
32
32
 
33
33
  type DisclosureTarget = { currentTarget: EventTarget & HTMLDetailsElement };
34
+ const DEFAULT_DURATION = 400;
34
35
  const preset = "svs-disclosure";
35
36
 
36
37
  const sleep = (msec: number) => new Promise(resolve => setTimeout(resolve, msec));
@@ -49,22 +50,23 @@
49
50
  import { type Action } from "svelte/action";
50
51
  import { type HTMLDetailsAttributes } from "svelte/elements";
51
52
  import { slide } from "svelte/transition";
52
- import { type SVSStyle, STATE, PARTS, fnClass, isNeutral, omit } from "./core";
53
+ import { type SVSClass, VARIANT, PARTS, fnClass, isNeutral, isUnsignedInteger, omit } from "./core";
53
54
  </script>
54
55
 
55
56
  <script lang="ts">
56
- let { label, children, open = $bindable(false), duration = 400, status = $bindable(""), style, attributes, action, element = $bindable() }: DisclosureProps = $props();
57
+ let { label, children, open = $bindable(false), duration = -1, attributes, action, element = $bindable(), styling, variant = $bindable("") }: DisclosureProps = $props();
57
58
 
58
59
  // *** Initialize *** //
59
- if (!status) status = STATE.NEUTRAL;
60
- const cls = fnClass(preset, style);
60
+ if (!variant) variant = VARIANT.NEUTRAL;
61
+ if (!isUnsignedInteger(duration)) duration = DEFAULT_DURATION;
62
+ const cls = fnClass(preset, styling);
61
63
  const attrs = omit(attributes, "class", "open", "ontoggle");
62
64
  const guard = new ToggleGurad();
63
65
  let hidden = $state(!open);
64
- let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
66
+ let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
65
67
 
66
68
  // *** Bind Handlers *** //
67
- $effect(() => { neutral = isNeutral(status) ? status : neutral });
69
+ $effect(() => { neutral = isNeutral(variant) ? variant : neutral });
68
70
  $effect.pre(() => {
69
71
  open;
70
72
  untrack(() => toggleOpen());
@@ -81,7 +83,7 @@
81
83
  if (!element) return;
82
84
  element.open = bool;
83
85
  hidden = !element.open;
84
- status = bool ? STATE.ACTIVE : neutral;
86
+ variant = bool ? VARIANT.ACTIVE : neutral;
85
87
  }
86
88
 
87
89
  // *** Event Handlers *** //
@@ -104,31 +106,31 @@
104
106
  <!---------------------------------------->
105
107
 
106
108
  {#if action}
107
- <details bind:this={element} class={cls(PARTS.WHOLE, status)} {ontoggle} {...attrs} use:action>
109
+ <details bind:this={element} class={cls(PARTS.WHOLE, variant)} {ontoggle} {...attrs} use:action>
108
110
  {@render inner()}
109
111
  </details>
110
112
  {:else}
111
- <details bind:this={element} class={cls(PARTS.WHOLE, status)} {ontoggle} {...attrs}>
113
+ <details bind:this={element} class={cls(PARTS.WHOLE, variant)} {ontoggle} {...attrs}>
112
114
  {@render inner()}
113
115
  </details>
114
116
  {/if}
115
117
 
116
118
  {#snippet inner()}
117
- <summary class={cls(PARTS.LABEL, status)} {onclick}>
119
+ <summary class={cls(PARTS.LABEL, variant)} {onclick}>
118
120
  {#if typeof label === "string"}
119
121
  {label}
120
122
  {:else if typeof label === "function"}
121
- {@render label(open, status)}
123
+ {@render label(open, variant)}
122
124
  {/if}
123
125
  </summary>
124
126
  {#if open}
125
- <div class={cls(PARTS.MAIN, status)} transition:slide={{ duration }}>
126
- {@render children()}
127
+ <div class={cls(PARTS.MAIN, variant)} transition:slide={{ duration }}>
128
+ {@render children(variant)}
127
129
  </div>
128
130
  {/if}
129
131
  {#if hidden}
130
- <div class={cls(PARTS.MAIN, status)}>
131
- {@render children()}
132
+ <div class={cls(PARTS.MAIN, variant)}>
133
+ {@render children(variant)}
132
134
  </div>
133
135
  {/if}
134
136
  {/snippet}
@@ -1,36 +1,36 @@
1
1
  export interface DisclosureProps {
2
2
  label: string | Snippet<[boolean, string]>;
3
- children: Snippet;
3
+ children: Snippet<[string]>;
4
4
  open?: boolean;
5
5
  duration?: number;
6
- status?: string;
7
- style?: SVSStyle;
8
6
  attributes?: HTMLDetailsAttributes;
9
7
  action?: Action;
10
8
  element?: HTMLDetailsElement;
9
+ styling?: SVSClass;
10
+ variant?: string;
11
11
  }
12
12
  export type DisclosureReqdProps = "label" | "children";
13
- export type DisclosureBindProps = "open" | "status" | "element";
13
+ export type DisclosureBindProps = "open" | "variant" | "element";
14
14
  import { type Snippet } from "svelte";
15
15
  import { type Action } from "svelte/action";
16
16
  import { type HTMLDetailsAttributes } from "svelte/elements";
17
- import { type SVSStyle } from "./core";
17
+ import { type SVSClass } from "./core";
18
18
  /**
19
19
  * default value: `(value)`
20
20
  * ```ts
21
21
  * interface DisclosureProps {
22
- * label: string | Snippet<[boolean,string]>; // Snippet<[open,status]>
23
- * children: Snippet;
22
+ * label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
23
+ * children: Snippet<[string]>; // Snippet<[variant]>
24
24
  * open?: boolean; // bindable (false)
25
25
  * duration?: number; // (400)
26
- * status?: string; // bindable (STATE.NEUTRAL)
27
- * style?: SVSStyle;
28
26
  * attributes?: HTMLDetailsAttributes;
29
27
  * action?: Action;
30
28
  * element?: HTMLDetailsElement; // bindable
29
+ * styling?: SVSClass;
30
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
31
31
  * }
32
32
  * ```
33
33
  */
34
- declare const Disclosure: import("svelte").Component<DisclosureProps, {}, "open" | "status" | "element">;
34
+ declare const Disclosure: import("svelte").Component<DisclosureProps, {}, "variant" | "open" | "element">;
35
35
  type Disclosure = ReturnType<typeof Disclosure>;
36
36
  export default Disclosure;
@@ -7,9 +7,9 @@
7
7
  placeholder?: string;
8
8
  active?: boolean; // bindable, (false)
9
9
  disabled?: boolean; // bindable, (false)
10
- status?: string; // bindable (STATE.NEUTRAL)
11
- style?: SVSStyle;
12
10
  element?: HTMLInputElement; // bindable
11
+ styling?: SVSClass;
12
+ variant?: string; // bindable (VARIANT.NEUTRAL)
13
13
  }
14
14
  ```
15
15
  -->
@@ -19,12 +19,12 @@
19
19
  placeholder?: string;
20
20
  active?: boolean; // bindable, (false)
21
21
  disabled?: boolean; // bindable, (false)
22
- status?: string; // bindable (STATE.NEUTRAL)
23
- style?: SVSStyle;
24
22
  element?: HTMLInputElement; // bindable
23
+ styling?: SVSClass;
24
+ variant?: string; // bindable (VARIANT.NEUTRAL)
25
25
  }
26
26
  export type HotkeyCaptureReqdProps = never;
27
- export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "status" | "element";
27
+ export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "variant" | "element";
28
28
 
29
29
  const preset = "svs-hotkey-capture";
30
30
  const KEY_MODIFIER = new Set(["Control", "Alt", "Shift", "Meta"]);
@@ -36,19 +36,19 @@
36
36
  }
37
37
 
38
38
  import { untrack } from "svelte";
39
- import { type SVSStyle, STATE, PARTS, fnClass, isNeutral } from "./core";
39
+ import { type SVSClass, VARIANT, PARTS, fnClass, isNeutral } from "./core";
40
40
  </script>
41
41
 
42
42
  <script lang="ts">
43
- let { value = $bindable(""), placeholder, active = $bindable(false), disabled = $bindable(false), status = $bindable(""), style, element = $bindable() }: HotkeyCaptureProps = $props();
43
+ let { value = $bindable(""), placeholder, active = $bindable(false), disabled = $bindable(false), element = $bindable(), styling, variant = $bindable("") }: HotkeyCaptureProps = $props();
44
44
 
45
45
  // *** Initialize *** //
46
- if (!status) status = STATE.NEUTRAL;
47
- const cls = fnClass(preset, style);
48
- let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
46
+ if (!variant) variant = VARIANT.NEUTRAL;
47
+ const cls = fnClass(preset, styling);
48
+ let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
49
49
 
50
50
  // *** Bind Handlers *** //
51
- $effect(() => { neutral = isNeutral(status) ? status : neutral });
51
+ $effect(() => { neutral = isNeutral(variant) ? variant : neutral });
52
52
  $effect.pre(() => {
53
53
  disabled;
54
54
  untrack(() => shiftStatus());
@@ -67,8 +67,8 @@
67
67
  }
68
68
  }
69
69
  function shiftStatus() {
70
- if (disabled) return status = STATE.INACTIVE;
71
- status = active ? STATE.ACTIVE : neutral;
70
+ if (disabled) return variant = VARIANT.INACTIVE;
71
+ variant = active ? VARIANT.ACTIVE : neutral;
72
72
  }
73
73
 
74
74
  // *** Event Handlers *** //
@@ -105,4 +105,4 @@
105
105
 
106
106
  <!---------------------------------------->
107
107
 
108
- <input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" readonly={true} {placeholder} {disabled} {onkeydown} {onpointerdown} {onwheel} {oncontextmenu} {onfocus} {onblur} />
108
+ <input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" readonly={true} {placeholder} {disabled} {onkeydown} {onpointerdown} {onwheel} {oncontextmenu} {onfocus} {onblur} />
@@ -3,13 +3,13 @@ export interface HotkeyCaptureProps {
3
3
  placeholder?: string;
4
4
  active?: boolean;
5
5
  disabled?: boolean;
6
- status?: string;
7
- style?: SVSStyle;
8
6
  element?: HTMLInputElement;
7
+ styling?: SVSClass;
8
+ variant?: string;
9
9
  }
10
10
  export type HotkeyCaptureReqdProps = never;
11
- export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "status" | "element";
12
- import { type SVSStyle } from "./core";
11
+ export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "variant" | "element";
12
+ import { type SVSClass } from "./core";
13
13
  /**
14
14
  * default value: `(value)`
15
15
  * ```ts
@@ -18,12 +18,12 @@ import { type SVSStyle } from "./core";
18
18
  * placeholder?: string;
19
19
  * active?: boolean; // bindable, (false)
20
20
  * disabled?: boolean; // bindable, (false)
21
- * status?: string; // bindable (STATE.NEUTRAL)
22
- * style?: SVSStyle;
23
21
  * element?: HTMLInputElement; // bindable
22
+ * styling?: SVSClass;
23
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
24
24
  * }
25
25
  * ```
26
26
  */
27
- declare const HotkeyCapture: import("svelte").Component<HotkeyCaptureProps, {}, "active" | "value" | "disabled" | "status" | "element">;
27
+ declare const HotkeyCapture: import("svelte").Component<HotkeyCaptureProps, {}, "variant" | "active" | "value" | "disabled" | "element">;
28
28
  type HotkeyCapture = ReturnType<typeof HotkeyCapture>;
29
29
  export default HotkeyCapture;
@@ -3,43 +3,43 @@
3
3
  default value: `(value)`
4
4
  ```ts
5
5
  interface ModalProps {
6
- children: Snippet;
6
+ children: Snippet<[string]>; // Snippet<[variant]>
7
7
  open?: boolean; // bindable (false)
8
8
  closable?: boolean; // (true)
9
9
  trigger?: HTMLElement; // bindable
10
10
  ariaLabel?: string;
11
- status?: string; // bindable (STATE.NEUTRAL)
12
- style?: SVSStyle;
11
+ variant?: string; // bindable (VARIANT.NEUTRAL)
12
+ styling?: SVSClass;
13
13
  element?: HTMLDialogElement; // bindable
14
14
  }
15
15
  ```
16
16
  -->
17
17
  <script module lang="ts">
18
18
  export interface ModalProps {
19
- children: Snippet;
19
+ children: Snippet<[string]>; // Snippet<[variant]>
20
20
  open?: boolean; // bindable (false)
21
21
  closable?: boolean; // (true)
22
22
  trigger?: HTMLElement; // bindable
23
23
  ariaLabel?: string;
24
- status?: string; // bindable (STATE.NEUTRAL)
25
- style?: SVSStyle;
26
24
  element?: HTMLDialogElement; // bindable
25
+ styling?: SVSClass;
26
+ variant?: string; // bindable (VARIANT.NEUTRAL)
27
27
  }
28
28
  export type ModalReqdProps = "children";
29
- export type ModalBindProps = "open" | "status" | "element";
29
+ export type ModalBindProps = "open" | "variant" | "element";
30
30
 
31
31
  const preset = "svs-modal";
32
32
 
33
33
  import { type Snippet, untrack } from "svelte";
34
- import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
34
+ import { type SVSClass, VARIANT, PARTS, fnClass } from "./core";
35
35
  </script>
36
36
 
37
37
  <script lang="ts">
38
- let { children, open = $bindable(false), closable = true, trigger = $bindable(), ariaLabel, status = $bindable(""), style, element = $bindable() }: ModalProps = $props();
38
+ let { children, open = $bindable(false), closable = true, trigger = $bindable(), ariaLabel, element = $bindable(), styling, variant = $bindable("") }: ModalProps = $props();
39
39
 
40
40
  // *** Initialize *** //
41
- if (!status) status = STATE.NEUTRAL;
42
- const cls = fnClass(preset, style);
41
+ if (!variant) variant = VARIANT.NEUTRAL;
42
+ const cls = fnClass(preset, styling);
43
43
 
44
44
  // *** Bind Handlers *** //
45
45
  $effect(() => {
@@ -70,9 +70,9 @@
70
70
  <!---------------------------------------->
71
71
 
72
72
  <!-- svelte-ignore a11y_autofocus -->
73
- <dialog bind:this={element} class={cls(PARTS.WHOLE, status)} aria-label={ariaLabel} {onclick} {onkeydown} {onclose} autofocus={true}>
74
- <div class={cls(PARTS.MAIN, status)}>
75
- {@render children()}
73
+ <dialog bind:this={element} class={cls(PARTS.WHOLE, variant)} aria-label={ariaLabel} {onclick} {onkeydown} {onclose} autofocus={true}>
74
+ <div class={cls(PARTS.MAIN, variant)}>
75
+ {@render children(variant)}
76
76
  </div>
77
77
  </dialog>
78
78
 
@@ -1,32 +1,32 @@
1
1
  export interface ModalProps {
2
- children: Snippet;
2
+ children: Snippet<[string]>;
3
3
  open?: boolean;
4
4
  closable?: boolean;
5
5
  trigger?: HTMLElement;
6
6
  ariaLabel?: string;
7
- status?: string;
8
- style?: SVSStyle;
9
7
  element?: HTMLDialogElement;
8
+ styling?: SVSClass;
9
+ variant?: string;
10
10
  }
11
11
  export type ModalReqdProps = "children";
12
- export type ModalBindProps = "open" | "status" | "element";
12
+ export type ModalBindProps = "open" | "variant" | "element";
13
13
  import { type Snippet } from "svelte";
14
- import { type SVSStyle } from "./core";
14
+ import { type SVSClass } from "./core";
15
15
  /**
16
16
  * default value: `(value)`
17
17
  * ```ts
18
18
  * interface ModalProps {
19
- * children: Snippet;
19
+ * children: Snippet<[string]>; // Snippet<[variant]>
20
20
  * open?: boolean; // bindable (false)
21
21
  * closable?: boolean; // (true)
22
22
  * trigger?: HTMLElement; // bindable
23
23
  * ariaLabel?: string;
24
- * status?: string; // bindable (STATE.NEUTRAL)
25
- * style?: SVSStyle;
24
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
25
+ * styling?: SVSClass;
26
26
  * element?: HTMLDialogElement; // bindable
27
27
  * }
28
28
  * ```
29
29
  */
30
- declare const Modal: import("svelte").Component<ModalProps, {}, "open" | "status" | "element" | "trigger">;
30
+ declare const Modal: import("svelte").Component<ModalProps, {}, "variant" | "open" | "element" | "trigger">;
31
31
  type Modal = ReturnType<typeof Modal>;
32
32
  export default Modal;
@@ -5,11 +5,11 @@
5
5
  interface ProgressTrackerProps {
6
6
  current: number; // bindable (0)
7
7
  labels: string[];
8
- aux?: Snippet<[string, number]>; // Snippet<[status,index]>
9
- extra?: Snippet<[string, number]>; // Snippet<[status,index]>
10
- status?: string; // bindable (STATE.NEUTRAL)
11
- eachStatus?: SvelteMap<number, string> | Map<number, string>;
12
- style?: SVSStyle;
8
+ aux?: Snippet<[string, number]>; // Snippet<[variant,index]>
9
+ extra?: Snippet<[string, number]>; // Snippet<[variant,index]>
10
+ variant?: string; // bindable (VARIANT.NEUTRAL)
11
+ eachVariant?: SvelteMap<number, string> | Map<number, string>;
12
+ styling?: SVSClass;
13
13
  }
14
14
  ```
15
15
  -->
@@ -17,42 +17,43 @@
17
17
  export interface ProgressTrackerProps {
18
18
  current: number; // bindable (0)
19
19
  labels: string[];
20
- aux?: Snippet<[string, number]>; // Snippet<[status,index]>
21
- extra?: Snippet<[string, number]>; // Snippet<[status,index]>
22
- status?: string; // bindable (STATE.NEUTRAL)
23
- eachStatus?: SvelteMap<number, string> | Map<number, string>;
24
- style?: SVSStyle;
20
+ aux?: Snippet<[number, string]>; // Snippet<[index,variant]>
21
+ extra?: Snippet<[number, string]>; // Snippet<[index,variant]>
22
+ styling?: SVSClass;
23
+ variant?: string; // bindable (VARIANT.NEUTRAL)
24
+ eachVariant?: SvelteMap<number, string> | Map<number, string>;
25
25
  }
26
26
  export type ProgressTrackerReqdProps = "current" | "labels";
27
- export type ProgressTrackerBindProps = "current" | "status";
27
+ export type ProgressTrackerBindProps = "current" | "variant";
28
28
 
29
29
  const preset = "svs-progress-tracker";
30
30
 
31
31
  import { type Snippet } from "svelte";
32
32
  import { type SvelteMap } from "svelte/reactivity";
33
- import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
33
+ import { type SVSClass, VARIANT, PARTS, fnClass, isUnsignedInteger } from "./core";
34
34
  </script>
35
35
 
36
36
  <script lang="ts">
37
- let { current = $bindable(0), labels, aux, extra, status = $bindable(""), eachStatus, style }: ProgressTrackerProps = $props();
37
+ let { current = $bindable(-1), labels, aux, extra, styling, variant = $bindable(""), eachVariant }: ProgressTrackerProps = $props();
38
38
 
39
39
  // *** Initialize *** //
40
- if (!status) status = STATE.NEUTRAL;
41
- const cls = fnClass(preset, style);
40
+ if (!variant) variant = VARIANT.NEUTRAL;
41
+ if (!isUnsignedInteger(current)) current = 0;
42
+ const cls = fnClass(preset, styling);
42
43
 
43
44
  // *** Status *** //
44
45
  function getEachStatus(index: number): string {
45
- if (eachStatus?.has(index)) return eachStatus.get(index)!;
46
- if (index < current) return STATE.ACTIVE;
47
- if (index > current) return STATE.INACTIVE;
48
- return status;
46
+ if (eachVariant?.has(index)) return eachVariant.get(index)!;
47
+ if (index < current) return VARIANT.ACTIVE;
48
+ if (index > current) return VARIANT.INACTIVE;
49
+ return variant;
49
50
  }
50
51
  </script>
51
52
 
52
53
  <!---------------------------------------->
53
54
 
54
55
  {#if labels.length}
55
- <ol class={cls(PARTS.WHOLE, status)}>
56
+ <ol class={cls(PARTS.WHOLE, variant)}>
56
57
  {#each labels as label, i}
57
58
  {@const stat = getEachStatus(i)}
58
59
  {#if i > current}
@@ -61,7 +62,7 @@
61
62
  <li class={cls(PARTS.MAIN, stat)} aria-current={i === current ? "step" : false}>
62
63
  {#if aux}
63
64
  <div class={cls(PARTS.AUX, stat)}>
64
- {@render aux(stat, i)}
65
+ {@render aux(i, stat)}
65
66
  </div>
66
67
  {/if}
67
68
  <div class={cls(PARTS.LABEL, stat)}>
@@ -77,9 +78,9 @@
77
78
 
78
79
  {#snippet separator(i: number)}
79
80
  {#if extra}
80
- {@const stat = i < current ? STATE.ACTIVE : STATE.INACTIVE}
81
+ {@const stat = i < current ? VARIANT.ACTIVE : VARIANT.INACTIVE}
81
82
  <li class={cls(PARTS.EXTRA, stat)} role="separator">
82
- {@render extra(stat, i)}
83
+ {@render extra(i, stat)}
83
84
  </li>
84
85
  {/if}
85
86
  {/snippet}
@@ -1,31 +1,31 @@
1
1
  export interface ProgressTrackerProps {
2
2
  current: number;
3
3
  labels: string[];
4
- aux?: Snippet<[string, number]>;
5
- extra?: Snippet<[string, number]>;
6
- status?: string;
7
- eachStatus?: SvelteMap<number, string> | Map<number, string>;
8
- style?: SVSStyle;
4
+ aux?: Snippet<[number, string]>;
5
+ extra?: Snippet<[number, string]>;
6
+ styling?: SVSClass;
7
+ variant?: string;
8
+ eachVariant?: SvelteMap<number, string> | Map<number, string>;
9
9
  }
10
10
  export type ProgressTrackerReqdProps = "current" | "labels";
11
- export type ProgressTrackerBindProps = "current" | "status";
11
+ export type ProgressTrackerBindProps = "current" | "variant";
12
12
  import { type Snippet } from "svelte";
13
13
  import { type SvelteMap } from "svelte/reactivity";
14
- import { type SVSStyle } from "./core";
14
+ import { type SVSClass } from "./core";
15
15
  /**
16
16
  * default value: `(value)`
17
17
  * ```ts
18
18
  * interface ProgressTrackerProps {
19
19
  * current: number; // bindable (0)
20
20
  * labels: string[];
21
- * aux?: Snippet<[string, number]>; // Snippet<[status,index]>
22
- * extra?: Snippet<[string, number]>; // Snippet<[status,index]>
23
- * status?: string; // bindable (STATE.NEUTRAL)
24
- * eachStatus?: SvelteMap<number, string> | Map<number, string>;
25
- * style?: SVSStyle;
21
+ * aux?: Snippet<[string, number]>; // Snippet<[variant,index]>
22
+ * extra?: Snippet<[string, number]>; // Snippet<[variant,index]>
23
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
24
+ * eachVariant?: SvelteMap<number, string> | Map<number, string>;
25
+ * styling?: SVSClass;
26
26
  * }
27
27
  * ```
28
28
  */
29
- declare const ProgressTracker: import("svelte").Component<ProgressTrackerProps, {}, "status" | "current">;
29
+ declare const ProgressTracker: import("svelte").Component<ProgressTrackerProps, {}, "variant" | "current">;
30
30
  type ProgressTracker = ReturnType<typeof ProgressTracker>;
31
31
  export default ProgressTracker;