svseeds 0.4.7 → 0.4.9

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 +51 -41
  6. package/_svseeds/TagsInputField.svelte.d.ts +15 -13
  7. package/_svseeds/ToggleGroupField.svelte +38 -36
  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 +27 -27
  12. package/_svseeds/_CheckField.svelte.d.ts +9 -9
  13. package/_svseeds/_ColorPicker.svelte +14 -13
  14. package/_svseeds/_ColorPicker.svelte.d.ts +9 -8
  15. package/_svseeds/_ComboBox.svelte +63 -44
  16. package/_svseeds/_ComboBox.svelte.d.ts +12 -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 +17 -15
  24. package/_svseeds/_Modal.svelte.d.ts +9 -9
  25. package/_svseeds/_ProgressTracker.svelte +42 -35
  26. package/_svseeds/_ProgressTracker.svelte.d.ts +13 -13
  27. package/_svseeds/_SelectField.svelte +33 -33
  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 +22 -22
  36. package/_svseeds/_TagsInput.svelte.d.ts +10 -10
  37. package/_svseeds/_TextField.svelte +33 -33
  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
@@ -1,38 +1,39 @@
1
1
  export interface ColorPickerProps {
2
2
  value?: string;
3
3
  alpha?: number;
4
- status?: string;
5
- style?: SVSStyle;
6
4
  attributes?: HTMLInputAttributes;
7
5
  action?: Action;
8
6
  element?: HTMLInputElement;
7
+ styling?: SVSClass;
8
+ variant?: string;
9
9
  }
10
10
  export type ColorPickerReqdProps = never;
11
- export type ColorPickerBindProps = "value" | "alpha" | "status" | "element";
11
+ export type ColorPickerBindProps = "value" | "alpha" | "variant" | "element";
12
12
  export declare function getHex(rgb: RgbColor): string;
13
13
  type RgbColor = [number, number, number];
14
14
  import { type Action } from "svelte/action";
15
15
  import { type HTMLInputAttributes } from "svelte/elements";
16
- import { type SVSStyle } from "./core";
16
+ import { type SVSClass } from "./core";
17
17
  /**
18
18
  * default value: `(value)`
19
19
  * ```ts
20
20
  * interface ColorPickerProps {
21
21
  * value?: string; // bindable ("#000000")
22
22
  * alpha?: number; // bindable (1)
23
- * status?: string; // bindable (STATE.NEUTRAL)
24
- * style?: SVSStyle;
25
23
  * attributes?: HTMLInputAttributes;
26
24
  * action?: Action;
27
25
  * element?: HTMLInputElement; // bindable
26
+ * styling?: SVSClass;
27
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
28
28
  * }
29
29
  * ```
30
30
  * ```ts
31
31
  * type RgbColor = [number, number, number];
32
32
  * function getHex(rgb: RgbColor): string
33
- * // getHex([255, 123, 34]) => "#ff7b22"
33
+ * // getHex([255, 123, 34]) => "#ff7b22"
34
+ * // getHex([255, 255, 255]) => "#ffffff"
34
35
  * ```
35
36
  */
36
- declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "alpha" | "value" | "status" | "element">;
37
+ declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "variant" | "alpha" | "value" | "element">;
37
38
  type ColorPicker = ReturnType<typeof ColorPicker>;
38
39
  export default ColorPicker;
@@ -4,47 +4,51 @@
4
4
  ```ts
5
5
  interface ComboBoxProps {
6
6
  options: SvelteSet<string> | Set<string>;
7
+ extra?: Snippet<[boolean, string]>; // Snippet<[expanded,variant]>
7
8
  value?: string; // bindable
8
9
  expanded?: boolean; // bindable
9
- status?: string; // bindable (STATE.NEUTRAL)
10
- style?: SVSStyle;
10
+ search?: boolean // (true)
11
11
  attributes?: HTMLInputAttributes;
12
12
  action?: Action;
13
13
  element?: HTMLInputElement; // bindable
14
+ styling?: SVSClass;
15
+ variant?: string; // bindable (VARIANT.NEUTRAL)
14
16
  }
15
17
  ```
16
18
  -->
17
19
  <script module lang="ts">
18
20
  export interface ComboBoxProps {
19
21
  options: SvelteSet<string> | Set<string>;
22
+ extra?: Snippet<[boolean, string]>; // Snippet<[expanded,variant]>
20
23
  value?: string; // bindable
21
24
  expanded?: boolean; // bindable
22
- status?: string; // bindable (STATE.NEUTRAL)
23
- style?: SVSStyle;
25
+ search?: boolean // (true)
24
26
  attributes?: HTMLInputAttributes;
25
27
  action?: Action;
26
28
  element?: HTMLInputElement; // bindable
29
+ styling?: SVSClass;
30
+ variant?: string; // bindable (VARIANT.NEUTRAL)
27
31
  }
28
32
  export type ComboBoxReqdProps = "options";
29
- export type ComboBoxBindProps = "value" | "expanded" | "status" | "element";
33
+ export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
30
34
 
31
35
  const preset = "svs-combo-box";
32
36
  const NA = -1;
33
37
  const optionStyle = "cursor: default; user-select: none;";
34
38
 
35
- import { untrack } from "svelte";
39
+ import { type Snippet } from "svelte";
36
40
  import { type Action } from "svelte/action";
37
41
  import { type SvelteSet } from "svelte/reactivity";
38
42
  import { type HTMLInputAttributes } from "svelte/elements";
39
- import { type SVSStyle, STATE, PARTS, elemId, fnClass, omit } from "./core";
43
+ import { type SVSClass, VARIANT, PARTS, elemId, fnClass, omit } from "./core";
40
44
  </script>
41
45
 
42
46
  <script lang="ts">
43
- let { options, value = $bindable(""), expanded = $bindable(false), status = $bindable(""), style, attributes, action, element = $bindable() }: ComboBoxProps = $props();
47
+ let { options, extra, value = $bindable(""), expanded = $bindable(false), search = true, attributes, action, element = $bindable(), styling, variant = $bindable("") }: ComboBoxProps = $props();
44
48
 
45
49
  // *** Initialize *** //
46
- if (!status) status = STATE.NEUTRAL;
47
- const cls = fnClass(preset, style);
50
+ if (!variant) variant = VARIANT.NEUTRAL;
51
+ const cls = fnClass(preset, styling);
48
52
  const idList = elemId.id;
49
53
  const attrs = omit(attributes, "class", "type", "value", "list", "role", "aria-haspopup", "aria-autocomplete", "aria-controls", "aria-expanded");
50
54
  let selected = $state(NA);
@@ -52,25 +56,24 @@
52
56
  let listElem: HTMLUListElement | undefined = $state();
53
57
 
54
58
  // *** Bind Handlers *** //
55
- let listboxStyle = $derived(`position: absolute;visibility: ${expanded ? "visible" : "hidden"};${overflow.x ? "right: 0%;" : ""}${overflow.y ? "bottom: 100%;" : ""}`);
59
+ let listboxStyle = $derived(`position:absolute;visibility: ${expanded ? "visible" : "hidden"};${overflow.x ? "right:0%;" : ""}${overflow.y ? "bottom:100%;" : ""}`);
56
60
  let opts = $derived([...options.keys()]);
57
- $effect(() => { options;
58
- untrack(() => observeOverflow());
59
- });
60
- function observeOverflow() {
61
- if (!listElem || !window) return;
62
- const rect = listElem.getBoundingClientRect();
63
- overflow.x = window.innerWidth < rect.right;
64
- overflow.y = window.innerHeight < rect.bottom;
65
- }
61
+ let maxlen = $derived(opts.reduce((max, x) => Math.max(max, [...x].length), 0));
66
62
 
67
63
  // *** Event Handlers *** //
68
64
  function open(activate: boolean = false, bottom: boolean = false) {
69
65
  if (expanded) return;
70
66
  selected = opts.indexOf(value);
71
67
  if (activate && selected === NA) selected = bottom ? opts.length - 1 : 0;
68
+ observeOverflow();
72
69
  expanded = true;
73
70
  }
71
+ function observeOverflow() {
72
+ if (!listElem || !window) return;
73
+ const rect = listElem.getBoundingClientRect();
74
+ overflow.x = window.innerWidth < rect.right;
75
+ overflow.y = window.innerHeight < rect.bottom;
76
+ }
74
77
  function apply() {
75
78
  if (!expanded) return;
76
79
  value = opts[selected];
@@ -81,25 +84,37 @@
81
84
  expanded = false;
82
85
  selected = NA;
83
86
  }
87
+ function oninput(ev: Event) {
88
+ if ((ev as InputEvent).isComposing) return;
89
+ if ([...value].length > maxlen) return;
90
+ if (options.has(value)) {
91
+ selected = opts.indexOf(value);
92
+ return;
93
+ }
94
+ if (!search) return;
95
+ selected = opts.findIndex((x) => x.startsWith(value));
96
+ }
84
97
  function onkeydown(ev: KeyboardEvent) {
85
98
  if (ev.isComposing) return;
86
99
  if (ev.ctrlKey || ev.shiftKey || ev.metaKey) return;
87
100
  switch (ev.key) {
88
101
  case "Escape": if (!ev.altKey && expanded) close(); break;
89
102
  case "Enter": if (!ev.altKey && expanded && selected > NA) apply(); break;
90
- case "ArrowDown": caseArrowDown(ev.altKey); break;
91
- case "ArrowUp": caseArrowUp(ev.altKey); break;
103
+ case "ArrowDown": caseArrowDown(ev, ev.altKey); break;
104
+ case "ArrowUp": caseArrowUp(ev, ev.altKey); break;
92
105
  }
93
106
  }
94
- function caseArrowDown(alt: boolean) {
95
- if (alt && !expanded) return open();
107
+ function caseArrowDown(ev: KeyboardEvent, alt: boolean) {
96
108
  if (alt && expanded) return;
109
+ ev.preventDefault();
110
+ if (alt && !expanded) return open();
97
111
  if (!alt && !expanded) return open(true);
98
112
  if (selected < opts.length - 1) selected++;
99
113
  if (selected === NA) selected = 0;
100
114
  }
101
- function caseArrowUp(alt: boolean) {
115
+ function caseArrowUp(ev: KeyboardEvent, alt: boolean) {
102
116
  if (alt && !expanded) return;
117
+ ev.preventDefault();
103
118
  if (alt && expanded) return close();
104
119
  if (!alt && !expanded) return open(true, true);
105
120
  if (selected > 0) selected--;
@@ -108,25 +123,29 @@
108
123
  </script>
109
124
 
110
125
  <!---------------------------------------->
126
+ <svelte:document onscroll={() => close()} />
111
127
 
112
128
  {#if options.size}
113
- <div class={cls(PARTS.WHOLE, status)}>
114
- <div style="position: relative; width: fit-content; height: fit-content;">
115
- {#if action}
116
- <input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} use:action />
117
- {:else}
118
- <input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} />
119
- {/if}
120
- <ul bind:this={listElem} class={cls(PARTS.BOTTOM, status)} id={idList} role="listbox" style={listboxStyle}>
121
- {#each opts as opt, i (opt)}
122
- {@const isSelected = i === selected}
123
- {@const labelStatus = isSelected ? STATE.ACTIVE : status}
124
- {@const onpointerenter = () => selected = i}
125
- <li class={cls(PARTS.LABEL, labelStatus)} aria-selected={isSelected} role="option" style={optionStyle} onpointerdown={apply} {onpointerenter}>
126
- {opt}
127
- </li>
128
- {/each}
129
- </ul>
130
- </div>
131
- </div>
129
+ <span class={cls(PARTS.WHOLE, variant)} style="position:relative;">
130
+ {#if action}
131
+ <input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {oninput} {...attrs} use:action />
132
+ {:else}
133
+ <input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {oninput} {...attrs} />
134
+ {/if}
135
+ {#if extra}
136
+ <div class={cls(PARTS.EXTRA, variant)} style="position:absolute;margin:auto 0;top:0%;right:0%;">
137
+ {@render extra(expanded, variant)}
138
+ </div>
139
+ {/if}
140
+ <ul bind:this={listElem} class={cls(PARTS.BOTTOM, expanded ? VARIANT.ACTIVE : variant)} id={idList} role="listbox" style={listboxStyle}>
141
+ {#each opts as opt, i (opt)}
142
+ {@const isSelected = i === selected}
143
+ {@const labelStatus = isSelected ? VARIANT.ACTIVE : variant}
144
+ {@const onpointerenter = () => selected = i}
145
+ <li class={cls(PARTS.LABEL, labelStatus)} aria-selected={isSelected} role="option" style={optionStyle} onpointerdown={apply} {onpointerenter}>
146
+ {opt}
147
+ </li>
148
+ {/each}
149
+ </ul>
150
+ </span>
132
151
  {/if}
@@ -1,34 +1,39 @@
1
1
  export interface ComboBoxProps {
2
2
  options: SvelteSet<string> | Set<string>;
3
+ extra?: Snippet<[boolean, string]>;
3
4
  value?: string;
4
5
  expanded?: boolean;
5
- status?: string;
6
- style?: SVSStyle;
6
+ search?: boolean;
7
7
  attributes?: HTMLInputAttributes;
8
8
  action?: Action;
9
9
  element?: HTMLInputElement;
10
+ styling?: SVSClass;
11
+ variant?: string;
10
12
  }
11
13
  export type ComboBoxReqdProps = "options";
12
- export type ComboBoxBindProps = "value" | "expanded" | "status" | "element";
14
+ export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
15
+ import { type Snippet } from "svelte";
13
16
  import { type Action } from "svelte/action";
14
17
  import { type SvelteSet } from "svelte/reactivity";
15
18
  import { type HTMLInputAttributes } from "svelte/elements";
16
- import { type SVSStyle } from "./core";
19
+ import { type SVSClass } from "./core";
17
20
  /**
18
21
  * default value: `(value)`
19
22
  * ```ts
20
23
  * interface ComboBoxProps {
21
24
  * options: SvelteSet<string> | Set<string>;
25
+ * extra?: Snippet<[boolean, string]>; // Snippet<[expanded,variant]>
22
26
  * value?: string; // bindable
23
27
  * expanded?: boolean; // bindable
24
- * status?: string; // bindable (STATE.NEUTRAL)
25
- * style?: SVSStyle;
28
+ * search?: boolean // (true)
26
29
  * attributes?: HTMLInputAttributes;
27
30
  * action?: Action;
28
31
  * element?: HTMLInputElement; // bindable
32
+ * styling?: SVSClass;
33
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
29
34
  * }
30
35
  * ```
31
36
  */
32
- declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "expanded" | "value" | "status" | "element">;
37
+ declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "variant" | "expanded" | "value" | "element">;
33
38
  type ComboBox = ReturnType<typeof ComboBox>;
34
39
  export default ComboBox;
@@ -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} />