svseeds 0.4.6 → 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 (51) hide show
  1. package/_svseeds/Accordion.svelte +17 -17
  2. package/_svseeds/Accordion.svelte.d.ts +10 -10
  3. package/_svseeds/DarkToggle.svelte +15 -15
  4. package/_svseeds/DarkToggle.svelte.d.ts +6 -6
  5. package/_svseeds/TagsInputField.svelte +48 -53
  6. package/_svseeds/TagsInputField.svelte.d.ts +22 -22
  7. package/_svseeds/ToggleGroupField.svelte +39 -39
  8. package/_svseeds/ToggleGroupField.svelte.d.ts +18 -18
  9. package/_svseeds/_Button.svelte +23 -22
  10. package/_svseeds/_Button.svelte.d.ts +13 -13
  11. package/_svseeds/_CheckField.svelte +33 -33
  12. package/_svseeds/_CheckField.svelte.d.ts +14 -14
  13. package/_svseeds/_ColorPicker.svelte +16 -16
  14. package/_svseeds/_ColorPicker.svelte.d.ts +10 -10
  15. package/_svseeds/_ComboBox.svelte +15 -15
  16. package/_svseeds/_ComboBox.svelte.d.ts +8 -8
  17. package/_svseeds/_ContextMenu.svelte +18 -18
  18. package/_svseeds/_ContextMenu.svelte.d.ts +12 -12
  19. package/_svseeds/_Disclosure.svelte +31 -29
  20. package/_svseeds/_Disclosure.svelte.d.ts +14 -14
  21. package/_svseeds/_HotkeyCapture.svelte +19 -19
  22. package/_svseeds/_HotkeyCapture.svelte.d.ts +10 -10
  23. package/_svseeds/_Modal.svelte +19 -19
  24. package/_svseeds/_Modal.svelte.d.ts +12 -12
  25. package/_svseeds/_ProgressTracker.svelte +27 -26
  26. package/_svseeds/_ProgressTracker.svelte.d.ts +15 -15
  27. package/_svseeds/_SelectField.svelte +36 -36
  28. package/_svseeds/_SelectField.svelte.d.ts +14 -14
  29. package/_svseeds/_Slider.svelte +26 -25
  30. package/_svseeds/_Slider.svelte.d.ts +15 -15
  31. package/_svseeds/_Sortable.svelte +35 -35
  32. package/_svseeds/_Sortable.svelte.d.ts +18 -18
  33. package/_svseeds/_Tabs.svelte +23 -23
  34. package/_svseeds/_Tabs.svelte.d.ts +10 -10
  35. package/_svseeds/{TagsInput.svelte → _TagsInput.svelte} +40 -47
  36. package/_svseeds/{TagsInput.svelte.d.ts → _TagsInput.svelte.d.ts} +17 -21
  37. package/_svseeds/_TextField.svelte +39 -39
  38. package/_svseeds/_TextField.svelte.d.ts +16 -16
  39. package/_svseeds/_Toggle.svelte +30 -34
  40. package/_svseeds/_Toggle.svelte.d.ts +16 -18
  41. package/_svseeds/_ToggleGroup.svelte +16 -16
  42. package/_svseeds/_ToggleGroup.svelte.d.ts +10 -10
  43. package/_svseeds/_Tooltip.svelte +21 -21
  44. package/_svseeds/_Tooltip.svelte.d.ts +13 -13
  45. package/_svseeds/core.d.ts +34 -17
  46. package/_svseeds/core.js +1 -1
  47. package/index.d.ts +3 -4
  48. package/index.js +2 -3
  49. package/package.json +1 -1
  50. package/_svseeds/_Badge.svelte +0 -73
  51. package/_svseeds/_Badge.svelte.d.ts +0 -33
@@ -1,15 +1,15 @@
1
1
  <!--
2
2
  @component
3
- default value: `<value>`
3
+ default value: `(value)`
4
4
  ```ts
5
5
  interface ColorPickerProps {
6
- value?: string; // bindable <"#000000">
7
- alpha?: number; // bindable <1>
8
- status?: string; // bindable <STATE.NEUTRAL>
9
- style?: SVSStyle;
6
+ value?: string; // bindable ("#000000")
7
+ alpha?: number; // bindable (1)
10
8
  attributes?: HTMLInputAttributes;
11
9
  action?: Action;
12
10
  element?: HTMLInputElement; // bindable
11
+ styling?: SVSClass;
12
+ variant?: string; // bindable (VARIANT.NEUTRAL)
13
13
  }
14
14
  ```
15
15
  ```ts
@@ -20,16 +20,16 @@
20
20
  -->
21
21
  <script module lang="ts">
22
22
  export interface ColorPickerProps {
23
- value?: string; // bindable <"#000000">
24
- alpha?: number; // bindable <1>
25
- status?: string; // bindable <STATE.NEUTRAL>
26
- style?: SVSStyle;
23
+ value?: string; // bindable ("#000000")
24
+ alpha?: number; // bindable (1)
27
25
  attributes?: HTMLInputAttributes;
28
26
  action?: Action;
29
27
  element?: HTMLInputElement; // bindable
28
+ styling?: SVSClass;
29
+ variant?: string; // bindable (VARIANT.NEUTRAL)
30
30
  }
31
31
  export type ColorPickerReqdProps = never;
32
- export type ColorPickerBindProps = "value" | "alpha" | "status" | "element";
32
+ export type ColorPickerBindProps = "value" | "alpha" | "variant" | "element";
33
33
  export function getHex(rgb: RgbColor): string {
34
34
  if (!isValidRgb(rgb)) return DEFAULT_COLOR;
35
35
  return "#" + (1 << 24 | rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16).slice(1);
@@ -62,15 +62,15 @@
62
62
 
63
63
  import { type Action } from "svelte/action";
64
64
  import { type HTMLInputAttributes } from "svelte/elements";
65
- import { type SVSStyle, STATE, PARTS, fnClass, omit } from "./core";
65
+ import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
66
66
  </script>
67
67
 
68
68
  <script lang="ts">
69
- let { value = $bindable(DEFAULT_COLOR), alpha = $bindable(1), status = $bindable(""), style, attributes, action, element = $bindable() }: ColorPickerProps = $props();
69
+ let { value = $bindable(DEFAULT_COLOR), alpha = $bindable(1), attributes, action, element = $bindable(), styling, variant = $bindable("") }: ColorPickerProps = $props();
70
70
 
71
71
  // *** Initialize *** //
72
- if (!status) status = STATE.NEUTRAL;
73
- const cls = fnClass(preset, style);
72
+ if (!variant) variant = VARIANT.NEUTRAL;
73
+ const cls = fnClass(preset, styling);
74
74
  const attrs = omit(attributes, "type");
75
75
  value = castValidHex(value) ?? DEFAULT_COLOR;
76
76
 
@@ -81,9 +81,9 @@
81
81
 
82
82
  <!---------------------------------------->
83
83
 
84
- <label class={cls(PARTS.WHOLE, status)}>
84
+ <label class={cls(PARTS.WHOLE, variant)}>
85
85
  <div style="display: inline-block; background-image: linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0px;">
86
- <div class={cls(PARTS.MAIN, status)} style={`background-color: rgba(${rgb[0]},${rgb[1]},${rgb[2]},${alp})`}>
86
+ <div class={cls(PARTS.MAIN, variant)} style={`background-color: rgba(${rgb[0]},${rgb[1]},${rgb[2]},${alp})`}>
87
87
  {#if action}
88
88
  <input bind:value bind:this={element} type="color" style="visibility: hidden;" {...attrs} use:action />
89
89
  {:else}
@@ -1,30 +1,30 @@
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
- * default value: `<value>`
18
+ * default value: `(value)`
19
19
  * ```ts
20
20
  * interface ColorPickerProps {
21
- * value?: string; // bindable <"#000000">
22
- * alpha?: number; // bindable <1>
23
- * status?: string; // bindable <STATE.NEUTRAL>
24
- * style?: SVSStyle;
21
+ * value?: string; // bindable ("#000000")
22
+ * alpha?: number; // bindable (1)
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
@@ -33,6 +33,6 @@ import { type SVSStyle } from "./core";
33
33
  * // getHex([255, 123, 34]) => "#ff7b22"
34
34
  * ```
35
35
  */
36
- declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "alpha" | "value" | "status" | "element">;
36
+ declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "variant" | "alpha" | "value" | "element">;
37
37
  type ColorPicker = ReturnType<typeof ColorPicker>;
38
38
  export default ColorPicker;
@@ -1,16 +1,16 @@
1
1
  <!--
2
2
  @component
3
- default value: `<value>`
3
+ default value: `(value)`
4
4
  ```ts
5
5
  interface ComboBoxProps {
6
6
  options: SvelteSet<string> | Set<string>;
7
7
  value?: string; // bindable
8
8
  expanded?: boolean; // bindable
9
- status?: string; // bindable <STATE.NEUTRAL>
10
- style?: SVSStyle;
11
9
  attributes?: HTMLInputAttributes;
12
10
  action?: Action;
13
11
  element?: HTMLInputElement; // bindable
12
+ styling?: SVSClass;
13
+ variant?: string; // bindable (VARIANT.NEUTRAL)
14
14
  }
15
15
  ```
16
16
  -->
@@ -19,14 +19,14 @@
19
19
  options: SvelteSet<string> | Set<string>;
20
20
  value?: string; // bindable
21
21
  expanded?: boolean; // bindable
22
- status?: string; // bindable <STATE.NEUTRAL>
23
- style?: SVSStyle;
24
22
  attributes?: HTMLInputAttributes;
25
23
  action?: Action;
26
24
  element?: HTMLInputElement; // bindable
25
+ styling?: SVSClass;
26
+ variant?: string; // bindable (VARIANT.NEUTRAL)
27
27
  }
28
28
  export type ComboBoxReqdProps = "options";
29
- export type ComboBoxBindProps = "value" | "expanded" | "status" | "element";
29
+ export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
30
30
 
31
31
  const preset = "svs-combo-box";
32
32
  const NA = -1;
@@ -36,15 +36,15 @@
36
36
  import { type Action } from "svelte/action";
37
37
  import { type SvelteSet } from "svelte/reactivity";
38
38
  import { type HTMLInputAttributes } from "svelte/elements";
39
- import { type SVSStyle, STATE, PARTS, elemId, fnClass, omit } from "./core";
39
+ import { type SVSClass, VARIANT, PARTS, elemId, fnClass, omit } from "./core";
40
40
  </script>
41
41
 
42
42
  <script lang="ts">
43
- let { options, value = $bindable(""), expanded = $bindable(false), status = $bindable(""), style, attributes, action, element = $bindable() }: ComboBoxProps = $props();
43
+ let { options, value = $bindable(""), expanded = $bindable(false), attributes, action, element = $bindable(), styling, variant = $bindable("") }: ComboBoxProps = $props();
44
44
 
45
45
  // *** Initialize *** //
46
- if (!status) status = STATE.NEUTRAL;
47
- const cls = fnClass(preset, style);
46
+ if (!variant) variant = VARIANT.NEUTRAL;
47
+ const cls = fnClass(preset, styling);
48
48
  const idList = elemId.id;
49
49
  const attrs = omit(attributes, "class", "type", "value", "list", "role", "aria-haspopup", "aria-autocomplete", "aria-controls", "aria-expanded");
50
50
  let selected = $state(NA);
@@ -110,17 +110,17 @@
110
110
  <!---------------------------------------->
111
111
 
112
112
  {#if options.size}
113
- <div class={cls(PARTS.WHOLE, status)}>
113
+ <div class={cls(PARTS.WHOLE, variant)}>
114
114
  <div style="position: relative; width: fit-content; height: fit-content;">
115
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 />
116
+ <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} {...attrs} use:action />
117
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} />
118
+ <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} {...attrs} />
119
119
  {/if}
120
- <ul bind:this={listElem} class={cls(PARTS.BOTTOM, status)} id={idList} role="listbox" style={listboxStyle}>
120
+ <ul bind:this={listElem} class={cls(PARTS.BOTTOM, variant)} id={idList} role="listbox" style={listboxStyle}>
121
121
  {#each opts as opt, i (opt)}
122
122
  {@const isSelected = i === selected}
123
- {@const labelStatus = isSelected ? STATE.ACTIVE : status}
123
+ {@const labelStatus = isSelected ? VARIANT.ACTIVE : variant}
124
124
  {@const onpointerenter = () => selected = i}
125
125
  <li class={cls(PARTS.LABEL, labelStatus)} aria-selected={isSelected} role="option" style={optionStyle} onpointerdown={apply} {onpointerenter}>
126
126
  {opt}
@@ -2,33 +2,33 @@ export interface ComboBoxProps {
2
2
  options: SvelteSet<string> | Set<string>;
3
3
  value?: string;
4
4
  expanded?: boolean;
5
- status?: string;
6
- style?: SVSStyle;
7
5
  attributes?: HTMLInputAttributes;
8
6
  action?: Action;
9
7
  element?: HTMLInputElement;
8
+ styling?: SVSClass;
9
+ variant?: string;
10
10
  }
11
11
  export type ComboBoxReqdProps = "options";
12
- export type ComboBoxBindProps = "value" | "expanded" | "status" | "element";
12
+ export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
13
13
  import { type Action } from "svelte/action";
14
14
  import { type SvelteSet } from "svelte/reactivity";
15
15
  import { type HTMLInputAttributes } from "svelte/elements";
16
- import { type SVSStyle } from "./core";
16
+ import { type SVSClass } from "./core";
17
17
  /**
18
- * default value: `<value>`
18
+ * default value: `(value)`
19
19
  * ```ts
20
20
  * interface ComboBoxProps {
21
21
  * options: SvelteSet<string> | Set<string>;
22
22
  * value?: string; // bindable
23
23
  * expanded?: boolean; // bindable
24
- * status?: string; // bindable <STATE.NEUTRAL>
25
- * style?: SVSStyle;
26
24
  * attributes?: HTMLInputAttributes;
27
25
  * action?: Action;
28
26
  * element?: HTMLInputElement; // bindable
27
+ * styling?: SVSClass;
28
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
29
29
  * }
30
30
  * ```
31
31
  */
32
- declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "expanded" | "value" | "status" | "element">;
32
+ declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "variant" | "expanded" | "value" | "element">;
33
33
  type ComboBox = ReturnType<typeof ComboBox>;
34
34
  export default ComboBox;
@@ -1,43 +1,43 @@
1
1
  <!--
2
2
  @component
3
- default value: `<value>`
3
+ default value: `(value)`
4
4
  ```ts
5
5
  interface ContextMenuProps {
6
- children: Snippet;
7
- open?: boolean; // bindable <false>; to observe state, not to control
8
- lock?: boolean; // bindable <false>
9
- status?: string; // bindable <STATE.NEUTRAL>
10
- style?: SVSStyle;
6
+ children: Snippet<[string]>; // Snippet<[variant]>
7
+ open?: boolean; // bindable (false); to observe state, not to control
8
+ lock?: boolean; // bindable (false)
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;
18
- open?: boolean; // bindable <false>; to observe state, not to control
19
- lock?: boolean; // bindable <false>
20
- status?: string; // bindable <STATE.NEUTRAL>
21
- style?: SVSStyle;
17
+ children: Snippet<[string]>; // Snippet<[variant]>
18
+ open?: boolean; // bindable (false); to observe state, not to control
19
+ lock?: boolean; // bindable (false)
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
- * default value: `<value>`
14
+ * default value: `(value)`
15
15
  * ```ts
16
16
  * interface ContextMenuProps {
17
- * children: Snippet;
18
- * open?: boolean; // bindable <false>; to observe state, not to control
19
- * lock?: boolean; // bindable <false>
20
- * status?: string; // bindable <STATE.NEUTRAL>
21
- * style?: SVSStyle;
17
+ * children: Snippet<[string]>; // Snippet<[variant]>
18
+ * open?: boolean; // bindable (false); to observe state, not to control
19
+ * lock?: boolean; // bindable (false)
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;
@@ -1,36 +1,37 @@
1
1
  <!--
2
2
  @component
3
- default value: `<value>`
3
+ default value: `(value)`
4
4
  ```ts
5
5
  interface DisclosureProps {
6
- label: string | Snippet<[string]>; // Snippet<[status]>
7
- children: Snippet;
8
- open?: boolean; // bindable <false>
9
- duration?: number; // <400>
10
- status?: string; // bindable <STATE.NEUTRAL>
11
- style?: SVSStyle;
6
+ label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
7
+ children: Snippet<[string]>; // Snippet<[variant]>
8
+ open?: boolean; // bindable (false)
9
+ duration?: number; // (400)
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<[string]>; // Snippet<[status]>
21
- children: Snippet;
22
- open?: boolean; // bindable <false>
23
- duration?: number; // <400>
24
- status?: string; // bindable <STATE.NEUTRAL>
25
- style?: SVSStyle;
20
+ label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
21
+ children: Snippet<[string]>; // Snippet<[variant]>
22
+ open?: boolean; // bindable (false)
23
+ duration?: number; // (400)
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(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
- label: string | Snippet<[string]>;
3
- children: Snippet;
2
+ label: string | Snippet<[boolean, string]>;
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
- * default value: `<value>`
19
+ * default value: `(value)`
20
20
  * ```ts
21
21
  * interface DisclosureProps {
22
- * label: string | Snippet<[string]>; // Snippet<[status]>
23
- * children: Snippet;
24
- * open?: boolean; // bindable <false>
25
- * duration?: number; // <400>
26
- * status?: string; // bindable <STATE.NEUTRAL>
27
- * style?: SVSStyle;
22
+ * label: string | Snippet<[boolean, string]>; // Snippet<[open,variant]>
23
+ * children: Snippet<[string]>; // Snippet<[variant]>
24
+ * open?: boolean; // bindable (false)
25
+ * duration?: number; // (400)
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;
@@ -1,15 +1,15 @@
1
1
  <!--
2
2
  @component
3
- default value: `<value>`
3
+ default value: `(value)`
4
4
  ```ts
5
5
  interface HotkeyCaptureProps {
6
6
  value?: string; // bindable
7
7
  placeholder?: string;
8
- active?: boolean; // bindable, <false>
9
- disabled?: boolean; // bindable, <false>
10
- status?: string; // bindable <STATE.NEUTRAL>
11
- style?: SVSStyle;
8
+ active?: boolean; // bindable, (false)
9
+ disabled?: boolean; // bindable, (false)
12
10
  element?: HTMLInputElement; // bindable
11
+ styling?: SVSClass;
12
+ variant?: string; // bindable (VARIANT.NEUTRAL)
13
13
  }
14
14
  ```
15
15
  -->
@@ -17,14 +17,14 @@
17
17
  export interface HotkeyCaptureProps {
18
18
  value?: string; // bindable
19
19
  placeholder?: string;
20
- active?: boolean; // bindable, <false>
21
- disabled?: boolean; // bindable, <false>
22
- status?: string; // bindable <STATE.NEUTRAL>
23
- style?: SVSStyle;
20
+ active?: boolean; // bindable, (false)
21
+ disabled?: boolean; // bindable, (false)
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} />