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
@@ -6,18 +6,18 @@
6
6
  options: SvelteMap<string, string> | Map<string, string>;
7
7
  label?: string;
8
8
  extra?: string;
9
- aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
10
- left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
11
- right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
9
+ aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
10
+ left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
11
+ right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
12
12
  bottom?: string;
13
13
  descFirst?: boolean; // (false)
14
14
  value?: string; // bindable
15
15
  validations?: SelectFieldValidation[];
16
- status?: string; // bindable (STATE.NEUTRAL)
17
- style?: SVSStyle;
18
16
  attributes?: HTMLSelectAttributes;
19
17
  action?: Action;
20
18
  element?: HTMLSelectElement; // bindable
19
+ styling?: SVSClass;
20
+ variant?: string; // bindable (VARIANT.NEUTRAL)
21
21
  }
22
22
  type SelectFieldValidation = (value: string, validity: ValidityState) => string | undefined;
23
23
  ```
@@ -27,21 +27,21 @@
27
27
  options: SvelteMap<string, string> | Map<string, string>;
28
28
  label?: string;
29
29
  extra?: string;
30
- aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
31
- left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
32
- right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
30
+ aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
31
+ left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
32
+ right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
33
33
  bottom?: string;
34
34
  descFirst?: boolean; // (false)
35
35
  value?: string; // bindable
36
36
  validations?: SelectFieldValidation[];
37
- status?: string; // bindable (STATE.NEUTRAL)
38
- style?: SVSStyle;
39
37
  attributes?: HTMLSelectAttributes;
40
38
  action?: Action;
41
39
  element?: HTMLSelectElement; // bindable
40
+ styling?: SVSClass;
41
+ variant?: string; // bindable (VARIANT.NEUTRAL)
42
42
  }
43
43
  export type SelectFieldReqdProps = "options";
44
- export type SelectFieldBindProps = "value" | "status" | "element";
44
+ export type SelectFieldBindProps = "value" | "variant" | "element";
45
45
  export type SelectFieldValidation = (value: string, validity: ValidityState) => string | undefined;
46
46
 
47
47
  const preset = "svs-select-field";
@@ -50,15 +50,15 @@
50
50
  import { type Action } from "svelte/action";
51
51
  import { type SvelteMap } from "svelte/reactivity";
52
52
  import { type HTMLSelectAttributes } from "svelte/elements";
53
- import { type SVSStyle, STATE, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
53
+ import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
54
54
  </script>
55
55
 
56
56
  <script lang="ts">
57
- let { options, label, extra, aux, left, right, bottom, descFirst = false, value = $bindable(""), validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: SelectFieldProps = $props();
57
+ let { options, label, extra, aux, left, right, bottom, descFirst = false, value = $bindable(""), validations = [], attributes, action, element = $bindable(), styling, variant = $bindable("") }: SelectFieldProps = $props();
58
58
 
59
59
  // *** Initialize *** //
60
- if (!status) status = STATE.NEUTRAL;
61
- const cls = fnClass(preset, style);
60
+ if (!variant) variant = VARIANT.NEUTRAL;
61
+ const cls = fnClass(preset, styling);
62
62
  const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
63
63
  const idLabel = elemId.get(label?.trim());
64
64
  const idDesc = elemId.get(bottom?.trim());
@@ -67,15 +67,15 @@
67
67
  let message = $state(bottom);
68
68
 
69
69
  // *** Status *** //
70
- let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
71
- $effect(() => { neutral = isNeutral(status) ? status : neutral; });
72
- let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
73
- let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
74
- let idMsg = $derived(status === STATE.INACTIVE && message?.trim() ? idErr : undefined);
70
+ let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
71
+ $effect(() => { neutral = isNeutral(variant) ? variant : neutral; });
72
+ let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
73
+ let invalid = $derived(variant === VARIANT.INACTIVE ? true : undefined);
74
+ let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
75
75
  function shift(oninvalid?: boolean) {
76
76
  const vmsg = element?.validationMessage ?? "";
77
- status = !value && !oninvalid ? neutral : vmsg ? STATE.INACTIVE : STATE.ACTIVE;
78
- message = status === STATE.INACTIVE ? vmsg ? vmsg : bottom : bottom;
77
+ variant = !value && !oninvalid ? neutral : vmsg ? VARIANT.INACTIVE : VARIANT.ACTIVE;
78
+ message = variant === VARIANT.INACTIVE ? vmsg ? vmsg : bottom : bottom;
79
79
  }
80
80
  function verify() {
81
81
  if (!element) return;
@@ -109,17 +109,17 @@
109
109
  <!---------------------------------------->
110
110
 
111
111
  {#if opts.length}
112
- <div class={cls(PARTS.WHOLE, status)} role="group" aria-labelledby={idLabel}>
112
+ <div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
113
113
  {#if aux}
114
- <div class={cls(PARTS.TOP, status)}>
114
+ <div class={cls(PARTS.TOP, variant)}>
115
115
  {@render lbl()}
116
- <span class={cls(PARTS.AUX, status)}>{@render aux(status, value, element)}</span>
116
+ <span class={cls(PARTS.AUX, variant)}>{@render aux(value, variant, element)}</span>
117
117
  </div>
118
118
  {:else}
119
119
  {@render lbl()}
120
120
  {/if}
121
121
  {@render desc(descFirst)}
122
- <div class={cls(PARTS.MIDDLE, status)}>
122
+ <div class={cls(PARTS.MIDDLE, variant)}>
123
123
  {@render side(PARTS.LEFT, left)}
124
124
  {@render main()}
125
125
  {@render side(PARTS.RIGHT, right)}
@@ -130,21 +130,21 @@
130
130
 
131
131
  {#snippet lbl()}
132
132
  {#if label?.trim()}
133
- <span class={cls(PARTS.LABEL, status)} id={idLabel}>
133
+ <span class={cls(PARTS.LABEL, variant)} id={idLabel}>
134
134
  {label}
135
135
  {#if extra?.trim()}
136
- <span class={cls(PARTS.EXTRA, status)}>{extra}</span>
136
+ <span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
137
137
  {/if}
138
138
  </span>
139
139
  {/if}
140
140
  {/snippet}
141
141
  {#snippet side(area: string, body?: Snippet<[string, string, HTMLSelectElement | undefined]>)}
142
142
  {#if body}
143
- <span class={cls(area, status)}>{@render body(status, value, element)}</span>
143
+ <span class={cls(area, variant)}>{@render body(value, variant, element)}</span>
144
144
  {/if}
145
145
  {/snippet}
146
146
  {#snippet main()}
147
- {@const c = cls(PARTS.MAIN, status)}
147
+ {@const c = cls(PARTS.MAIN, variant)}
148
148
  {#if action}
149
149
  <select bind:value bind:this={element} class={c} {id} {oninvalid} {...attrs} aria-describedby={idDesc} aria-invalid={invalid} aria-errormessage={idMsg} use:action>
150
150
  {@render option()}
@@ -162,6 +162,6 @@
162
162
  {/snippet}
163
163
  {#snippet desc(show: boolean)}
164
164
  {#if show && message?.trim()}
165
- <div class={cls(PARTS.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
165
+ <div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
166
166
  {/if}
167
167
  {/snippet}
@@ -9,20 +9,20 @@ export interface SelectFieldProps {
9
9
  descFirst?: boolean;
10
10
  value?: string;
11
11
  validations?: SelectFieldValidation[];
12
- status?: string;
13
- style?: SVSStyle;
14
12
  attributes?: HTMLSelectAttributes;
15
13
  action?: Action;
16
14
  element?: HTMLSelectElement;
15
+ styling?: SVSClass;
16
+ variant?: string;
17
17
  }
18
18
  export type SelectFieldReqdProps = "options";
19
- export type SelectFieldBindProps = "value" | "status" | "element";
19
+ export type SelectFieldBindProps = "value" | "variant" | "element";
20
20
  export type SelectFieldValidation = (value: string, validity: ValidityState) => string | undefined;
21
21
  import { type Snippet } from "svelte";
22
22
  import { type Action } from "svelte/action";
23
23
  import { type SvelteMap } from "svelte/reactivity";
24
24
  import { type HTMLSelectAttributes } from "svelte/elements";
25
- import { type SVSStyle } from "./core";
25
+ import { type SVSClass } from "./core";
26
26
  /**
27
27
  * default value: `(value)`
28
28
  * ```ts
@@ -30,22 +30,22 @@ import { type SVSStyle } from "./core";
30
30
  * options: SvelteMap<string, string> | Map<string, string>;
31
31
  * label?: string;
32
32
  * extra?: string;
33
- * aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
34
- * left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
35
- * right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[status,value,element]>
33
+ * aux?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
34
+ * left?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
35
+ * right?: Snippet<[string, string, HTMLSelectElement | undefined]>; // Snippet<[value,variant,element]>
36
36
  * bottom?: string;
37
37
  * descFirst?: boolean; // (false)
38
38
  * value?: string; // bindable
39
39
  * validations?: SelectFieldValidation[];
40
- * status?: string; // bindable (STATE.NEUTRAL)
41
- * style?: SVSStyle;
42
40
  * attributes?: HTMLSelectAttributes;
43
41
  * action?: Action;
44
42
  * element?: HTMLSelectElement; // bindable
43
+ * styling?: SVSClass;
44
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
45
45
  * }
46
46
  * type SelectFieldValidation = (value: string, validity: ValidityState) => string | undefined;
47
47
  * ```
48
48
  */
49
- declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "value" | "status" | "element">;
49
+ declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "variant" | "value" | "element">;
50
50
  type SelectField = ReturnType<typeof SelectField>;
51
51
  export default SelectField;
@@ -4,17 +4,17 @@
4
4
  ```ts
5
5
  interface SliderProps {
6
6
  range: Range; // bindable
7
- left?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
8
- right?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
7
+ left?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
8
+ right?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
9
9
  value?: number; // bindable (min+((max-min)/2))
10
10
  step?: number | "any"; // (1)
11
11
  options?: SvelteSet<number> | Set<number>;
12
- background?: Range; // ({ min: 5, max: 95 })
13
- status?: string; // bindable (STATE.NEUTRAL)
14
- style?: SVSStyle;
12
+ background?: Range; // ({ min: 5, max: 95 }); linear-gradient rate limit of slider's track
15
13
  attributes?: HTMLInputAttributes;
16
14
  action?: Action;
17
15
  element?: HTMLInputElement; // bindable
16
+ styling?: SVSClass;
17
+ variant?: string; // bindable (VARIANT.NEUTRAL)
18
18
  }
19
19
  type Range = { min: number, max: number };
20
20
  ```
@@ -22,20 +22,20 @@
22
22
  <script module lang="ts">
23
23
  export interface SliderProps {
24
24
  range: Range; // bindable
25
- left?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
26
- right?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
25
+ left?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
26
+ right?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
27
27
  value?: number; // bindable (min+((max-min)/2))
28
28
  step?: number | "any"; // (1)
29
29
  options?: SvelteSet<number> | Set<number>;
30
- background?: Range; // ({ min: 5, max: 95 })
31
- status?: string; // bindable (STATE.NEUTRAL)
32
- style?: SVSStyle;
30
+ background?: Range; // ({ min: 5, max: 95 }); linear-gradient rate limit of slider's track
33
31
  attributes?: HTMLInputAttributes;
34
32
  action?: Action;
35
33
  element?: HTMLInputElement; // bindable
34
+ styling?: SVSClass;
35
+ variant?: string; // bindable (VARIANT.NEUTRAL)
36
36
  }
37
37
  export type SliderReqdProps = "min" | "max";
38
- export type SliderBindProps = "min" | "max" | "value" | "status" | "element";
38
+ export type SliderBindProps = "min" | "max" | "value" | "variant" | "element";
39
39
  export type Range = { min: number, max: number };
40
40
 
41
41
  const preset = "svs-slider";
@@ -44,18 +44,19 @@
44
44
  import { type Action } from "svelte/action";
45
45
  import { type SvelteSet } from "svelte/reactivity";
46
46
  import { type HTMLInputAttributes } from "svelte/elements";
47
- import { type SVSStyle, STATE, PARTS, elemId, fnClass, omit } from "./core";
47
+ import { type SVSClass, VARIANT, PARTS, elemId, fnClass, omit } from "./core";
48
48
  </script>
49
49
 
50
50
  <script lang="ts">
51
- let { range = $bindable(), left, right, value = $bindable(), step = 1, options, background = { min: 5, max: 95 }, status = $bindable(""), style, attributes, action, element = $bindable()}: SliderProps = $props();
51
+ let { range = $bindable(), left, right, value = $bindable(), step = 1, options, background = { min: 5, max: 95 }, attributes, action, element = $bindable(), styling, variant = $bindable("") }: SliderProps = $props();
52
52
 
53
53
  // *** Initialize *** //
54
- if (!status) status = STATE.NEUTRAL;
55
- const cls = fnClass(preset, style);
54
+ if (!variant) variant = VARIANT.NEUTRAL;
55
+ const cls = fnClass(preset, styling);
56
56
  const idList = elemId.get(options?.size);
57
57
  const attrs = omit(attributes, "class", "type", "value", "min", "max", "step", "list");
58
58
  if (range.min > range.max) range = { min: range.max, max: range.min };
59
+ if (background.min > background.max) background = { min: background.max, max: background.min };
59
60
  if (value === undefined || value < range.min || value > range.max) value = range.min + ((range.max - range.min) / 2);
60
61
 
61
62
  // *** Bind Handlers *** //
@@ -65,12 +66,12 @@
65
66
 
66
67
  <!---------------------------------------->
67
68
 
68
- <span class={cls(PARTS.WHOLE, status)}>
69
+ <span class={cls(PARTS.WHOLE, variant)}>
69
70
  {@render side(PARTS.LEFT, left)}
70
71
  {#if action}
71
- <input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} style={dynStyle} list={idList} type="range" min={range.min} max={range.max} {step} {...attrs} use:action />
72
+ <input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} style={dynStyle} list={idList} type="range" min={range.min} max={range.max} {step} {...attrs} use:action />
72
73
  {:else}
73
- <input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} style={dynStyle} list={idList} type="range" min={range.min} max={range.max} {step} {...attrs} />
74
+ <input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} style={dynStyle} list={idList} type="range" min={range.min} max={range.max} {step} {...attrs} />
74
75
  {/if}
75
76
  {#if options?.size}
76
77
  <datalist id={idList}>
@@ -82,8 +83,8 @@
82
83
  {@render side(PARTS.RIGHT, right)}
83
84
  </span>
84
85
 
85
- {#snippet side(area: string, body?: Snippet<[string, number, HTMLInputElement | undefined]>)}
86
+ {#snippet side(area: string, body?: Snippet<[number, string, HTMLInputElement | undefined]>)}
86
87
  {#if body}
87
- <span class={cls(area, status)}>{@render body(status, value!, element)}</span>
88
+ <span class={cls(area, variant)}>{@render body(value!, variant, element)}</span>
88
89
  {/if}
89
90
  {/snippet}
@@ -1,19 +1,19 @@
1
1
  export interface SliderProps {
2
2
  range: Range;
3
- left?: Snippet<[string, number, HTMLInputElement | undefined]>;
4
- right?: Snippet<[string, number, HTMLInputElement | undefined]>;
3
+ left?: Snippet<[number, string, HTMLInputElement | undefined]>;
4
+ right?: Snippet<[number, string, HTMLInputElement | undefined]>;
5
5
  value?: number;
6
6
  step?: number | "any";
7
7
  options?: SvelteSet<number> | Set<number>;
8
8
  background?: Range;
9
- status?: string;
10
- style?: SVSStyle;
11
9
  attributes?: HTMLInputAttributes;
12
10
  action?: Action;
13
11
  element?: HTMLInputElement;
12
+ styling?: SVSClass;
13
+ variant?: string;
14
14
  }
15
15
  export type SliderReqdProps = "min" | "max";
16
- export type SliderBindProps = "min" | "max" | "value" | "status" | "element";
16
+ export type SliderBindProps = "min" | "max" | "value" | "variant" | "element";
17
17
  export type Range = {
18
18
  min: number;
19
19
  max: number;
@@ -22,27 +22,27 @@ import { type Snippet } from "svelte";
22
22
  import { type Action } from "svelte/action";
23
23
  import { type SvelteSet } from "svelte/reactivity";
24
24
  import { type HTMLInputAttributes } from "svelte/elements";
25
- import { type SVSStyle } from "./core";
25
+ import { type SVSClass } from "./core";
26
26
  /**
27
27
  * default value: `(value)`
28
28
  * ```ts
29
29
  * interface SliderProps {
30
30
  * range: Range; // bindable
31
- * left?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
32
- * right?: Snippet<[string, number, HTMLInputElement | undefined]>; // Snippet<[status,value,element]>
31
+ * left?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
32
+ * right?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
33
33
  * value?: number; // bindable (min+((max-min)/2))
34
34
  * step?: number | "any"; // (1)
35
35
  * options?: SvelteSet<number> | Set<number>;
36
- * background?: Range; // ({ min: 5, max: 95 })
37
- * status?: string; // bindable (STATE.NEUTRAL)
38
- * style?: SVSStyle;
36
+ * background?: Range; // ({ min: 5, max: 95 }); linear-gradient rate limit of slider's track
39
37
  * attributes?: HTMLInputAttributes;
40
38
  * action?: Action;
41
39
  * element?: HTMLInputElement; // bindable
40
+ * styling?: SVSClass;
41
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
42
42
  * }
43
43
  * type Range = { min: number, max: number };
44
44
  * ```
45
45
  */
46
- declare const Slider: import("svelte").Component<SliderProps, {}, "value" | "status" | "range" | "element">;
46
+ declare const Slider: import("svelte").Component<SliderProps, {}, "variant" | "value" | "range" | "element">;
47
47
  type Slider = ReturnType<typeof Slider>;
48
48
  export default Slider;
@@ -4,18 +4,18 @@
4
4
  ```ts
5
5
  interface SortableProps {
6
6
  items: SortableItems; // wrapper of string array as items to handle DnD
7
- item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[status, value, onpointerdown]>
7
+ item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
8
8
  ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
9
9
  name?: string; // name of this group (random string)
10
- mode?: SortableMode; // sort mode ("std"); "std","clone","swap"
10
+ mode?: SortableMode; // sort mode ("std")
11
11
  accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
12
12
  sort?: boolean; // enable sort within same group (true)
13
13
  multiple?: boolean; // enable multiple select & drag with them (false)
14
14
  draggable?: boolean; // enable default pointerdown handler (true)
15
15
  appendable?: boolean; // enable append when enter group area (false)
16
16
  confirm?: boolean // enable confirm interval time to move items (false)
17
- status?: string; // bindable (STATE.NEUTRAL)
18
- style?: SVSStyle;
17
+ styling?: SVSClass;
18
+ variant?: string; // bindable (VARIANT.NEUTRAL)
19
19
  }
20
20
  type SortableMode = "std" | "clone" | "swap";
21
21
  class SortableItems { // methods are same with array's
@@ -51,21 +51,21 @@
51
51
  type SortableMode = "std" | "clone" | "swap";
52
52
  export interface SortableProps {
53
53
  items: SortableItems; // wrapper of string array as items to handle DnD
54
- item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[status, value, onpointerdown]>
54
+ item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
55
55
  ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
56
56
  name?: string; // name of this group (random string)
57
- mode?: SortableMode; // sort mode ("std"); "std","clone","swap"
57
+ mode?: SortableMode; // sort mode ("std")
58
58
  accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
59
59
  sort?: boolean; // enable sort within same group (true)
60
60
  multiple?: boolean; // enable multiple select & drag with them (false)
61
61
  draggable?: boolean; // enable default pointerdown handler (true)
62
62
  appendable?: boolean; // enable append when enter group area (false)
63
63
  confirm?: boolean // enable confirm interval time to move items (false)
64
- status?: string; // bindable (STATE.NEUTRAL)
65
- style?: SVSStyle;
64
+ styling?: SVSClass;
65
+ variant?: string; // bindable (VARIANT.NEUTRAL)
66
66
  }
67
67
  export type SortableReqdProps = "items" | "item";
68
- export type SortableBindProps = "status";
68
+ export type SortableBindProps = "variant";
69
69
 
70
70
  export class SortableItems {
71
71
  #inner: KeyValue[] = $state([]);
@@ -641,15 +641,15 @@
641
641
  import { on } from "svelte/events";
642
642
  import { type EasingFunction, crossfade } from "svelte/transition";
643
643
  import { flip } from "svelte/animate";
644
- import { type SVSStyle, STATE, PARTS, fnClass, throttle } from "./core";
644
+ import { type SVSClass, VARIANT, PARTS, fnClass, throttle } from "./core";
645
645
  </script>
646
646
 
647
647
  <script lang="ts">
648
- let { items, item, ghost, name, mode = "std", accept, sort = true, multiple = false, draggable = true, appendable = false, confirm = false, status = $bindable(""), style }: SortableProps = $props();
648
+ let { items, item, ghost, name, mode = "std", accept, sort = true, multiple = false, draggable = true, appendable = false, confirm = false, styling, variant = $bindable("") }: SortableProps = $props();
649
649
 
650
650
  // *** Initialize *** //
651
- if (!status) status = STATE.NEUTRAL;
652
- const cls = fnClass(preset, style);
651
+ if (!variant) variant = VARIANT.NEUTRAL;
652
+ const cls = fnClass(preset, styling);
653
653
  const group: KeyValue = SortableItems._newItem(name);
654
654
  const elems: HTMLElement[] = [];
655
655
  const shadow = new Shadow(ghost);
@@ -757,26 +757,26 @@
757
757
 
758
758
  <!---------------------------------------->
759
759
 
760
- <ul class={cls(PARTS.WHOLE, status)} onpointerenter={drag.active ? groupenter : undefined} onpointerleave={drag.active ? groupleave : undefined}>
760
+ <ul class={cls(PARTS.WHOLE, variant)} onpointerenter={drag.active ? groupenter : undefined} onpointerleave={drag.active ? groupleave : undefined}>
761
761
  {#each items._inner as {key, value}, i (key)}
762
762
  {@const style = "touch-action:none;"}
763
- {@const itemStatus = isSelected(key) ? STATE.ACTIVE : status}
763
+ {@const itemStatus = isSelected(key) ? VARIANT.ACTIVE : variant}
764
764
  {@const onpointerdown = draggable ? downF(key, elems[i]) : undefined}
765
765
  {@const onpointerenter = drag.active ? enterF(key) : undefined}
766
766
  {@const onpointerleave = drag.active ? leave : undefined}
767
767
  <li bind:this={elems[i]} class={cls(PARTS.MAIN, itemStatus)} in:s={{key}} out:r={{key}} animate:flip={tp} {style} {onpointerdown} {onpointerenter} {onpointerleave} {ondragstart}>
768
- {@render item(itemStatus, value, downF(key, elems[i]))}
768
+ {@render item(value, itemStatus, downF(key, elems[i]))}
769
769
  </li>
770
770
  {/each}
771
771
  </ul>
772
772
  {#if shadow.rendering}
773
773
  {@const style = `opacity: 0.5; pointer-events: none; position: fixed; left: ${shadow.pt.x}px; top: ${shadow.pt.y}px; ${shadow.cssVisibility} ${shadow.cssSize}`}
774
774
  <ul style="display: contents;">
775
- <li bind:this={shadow.elem} class={shadow.isGhost ? undefined : cls(PARTS.MAIN, status)} {style}>
775
+ <li bind:this={shadow.elem} class={shadow.isGhost ? undefined : cls(PARTS.MAIN, variant)} {style}>
776
776
  {#if shadow.isGhost}
777
777
  {@render ghost!(items._value(drag.key))}
778
778
  {:else}
779
- {@render item(status, items._value(drag.key), ()=>cleanup())}
779
+ {@render item(items._value(drag.key), variant, ()=>cleanup())}
780
780
  {/if}
781
781
  </li>
782
782
  </ul>
@@ -12,11 +12,11 @@ export interface SortableProps {
12
12
  draggable?: boolean;
13
13
  appendable?: boolean;
14
14
  confirm?: boolean;
15
- status?: string;
16
- style?: SVSStyle;
15
+ styling?: SVSClass;
16
+ variant?: string;
17
17
  }
18
18
  export type SortableReqdProps = "items" | "item";
19
- export type SortableBindProps = "status";
19
+ export type SortableBindProps = "variant";
20
20
  export declare class SortableItems {
21
21
  #private;
22
22
  constructor(values: string[]);
@@ -56,24 +56,24 @@ type KeyValue = {
56
56
  };
57
57
  type DragState = "ready" | "dragging" | "idle";
58
58
  import { type Snippet } from "svelte";
59
- import { type SVSStyle } from "./core";
59
+ import { type SVSClass } from "./core";
60
60
  /**
61
61
  * default value: `(value)`
62
62
  * ```ts
63
63
  * interface SortableProps {
64
64
  * items: SortableItems; // wrapper of string array as items to handle DnD
65
- * item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[status, value, onpointerdown]>
65
+ * item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
66
66
  * ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
67
67
  * name?: string; // name of this group (random string)
68
- * mode?: SortableMode; // sort mode ("std"); "std","clone","swap"
68
+ * mode?: SortableMode; // sort mode ("std")
69
69
  * accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
70
70
  * sort?: boolean; // enable sort within same group (true)
71
71
  * multiple?: boolean; // enable multiple select & drag with them (false)
72
72
  * draggable?: boolean; // enable default pointerdown handler (true)
73
73
  * appendable?: boolean; // enable append when enter group area (false)
74
74
  * confirm?: boolean // enable confirm interval time to move items (false)
75
- * status?: string; // bindable (STATE.NEUTRAL)
76
- * style?: SVSStyle;
75
+ * styling?: SVSClass;
76
+ * variant?: string; // bindable (VARIANT.NEUTRAL)
77
77
  * }
78
78
  * type SortableMode = "std" | "clone" | "swap";
79
79
  * class SortableItems { // methods are same with array's
@@ -94,6 +94,6 @@ import { type SVSStyle } from "./core";
94
94
  * }
95
95
  * ```
96
96
  */
97
- declare const Sortable: import("svelte").Component<SortableProps, {}, "status">;
97
+ declare const Sortable: import("svelte").Component<SortableProps, {}, "variant">;
98
98
  type Sortable = ReturnType<typeof Sortable>;
99
99
  export default Sortable;
@@ -6,9 +6,9 @@
6
6
  labels?: string[];
7
7
  current?: number; // bindable (0)
8
8
  ariaOrientation?: "horizontal" | "vertical";
9
- status?: string; // bindable (STATE.NEUTRAL)
10
- style?: SVSStyle;
11
- [key: string]: unknown | Snippet;
9
+ styling?: SVSClass;
10
+ variant?: string; // bindable (VARIANT.NEUTRAL)
11
+ [key: string]: unknown | Snippet; // labels or contents of each tab
12
12
  }
13
13
  ```
14
14
  -->
@@ -17,12 +17,12 @@
17
17
  labels?: string[];
18
18
  current?: number; // bindable (0)
19
19
  ariaOrientation?: "horizontal" | "vertical";
20
- status?: string; // bindable (STATE.NEUTRAL)
21
- style?: SVSStyle;
22
- [key: string]: unknown | Snippet;
20
+ styling?: SVSClass;
21
+ variant?: string; // bindable (VARIANT.NEUTRAL)
22
+ [key: string]: unknown | Snippet; // labels or contents of each tab
23
23
  }
24
24
  export type TabsReqdProps = never;
25
- export type TabsBindProps = "current" | "status";
25
+ export type TabsBindProps = "current" | "variant";
26
26
 
27
27
  type NamedId = { id: string, name: string };
28
28
  const preset = "svs-tabs";
@@ -37,27 +37,27 @@
37
37
  function toNamedId(names: string[]): NamedId[] {
38
38
  return names.map((x) => ({ id: elemId.id, name: x }));
39
39
  }
40
- function correctCurrent(active: number, labels: string[]): number {
41
- if (active <= 0) return 0;
42
- if (active >= labels.length) return labels.length - 1;
43
- return active;
40
+ function correctCurrent(current: number, tabs: NamedId[]): number {
41
+ if (!isUnsignedInteger(current)) return 0;
42
+ if (current >= tabs.length) return tabs.length - 1;
43
+ return current;
44
44
  }
45
45
 
46
46
  import { type Snippet } from "svelte";
47
- import { type SVSStyle, STATE, PARTS, elemId, fnClass } from "./core";
47
+ import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isUnsignedInteger } from "./core";
48
48
  </script>
49
49
 
50
50
  <script lang="ts">
51
- let { labels = [], current = $bindable(0), ariaOrientation, status = $bindable(""), style, ...rest }: TabsProps = $props();
51
+ let { labels = [], current = $bindable(0), ariaOrientation, styling, variant = $bindable(""), ...rest }: TabsProps = $props();
52
52
 
53
53
  // *** Initialize *** //
54
- if (!status) status = STATE.NEUTRAL;
55
- const cls = fnClass(preset, style);
54
+ if (!variant) variant = VARIANT.NEUTRAL;
55
+ const cls = fnClass(preset, styling);
56
56
  const isStrLabel = labels.length > 0;
57
57
  const tabs = toNamedId(isStrLabel ? labels : getSnippetNames(roleLabel, rest));
58
58
  const panels = toNamedId(getSnippetNames(rolePanel, rest));
59
59
  const elems: HTMLButtonElement[] = [];
60
- current = correctCurrent(current, labels);
60
+ current = correctCurrent(current, tabs);
61
61
  const isValidTabs = $derived(tabs.length && panels.length && tabs.length === panels.length);
62
62
 
63
63
  // *** Event Handlers *** //
@@ -79,11 +79,11 @@
79
79
  <!---------------------------------------->
80
80
 
81
81
  {#if isValidTabs}
82
- <div class={cls(PARTS.WHOLE, status)}>
83
- <div class={cls(PARTS.TOP, status)} role="tablist" aria-orientation={ariaOrientation}>
82
+ <div class={cls(PARTS.WHOLE, variant)}>
83
+ <div class={cls(PARTS.TOP, variant)} role="tablist" aria-orientation={ariaOrientation}>
84
84
  {#each tabs as { id, name }, i (id)}
85
85
  {@const selected = i === current}
86
- {@const tabStatus = selected ? STATE.ACTIVE : status}
86
+ {@const tabStatus = selected ? VARIANT.ACTIVE : variant}
87
87
  <button bind:this={elems[i]} class={cls(PARTS.LABEL, tabStatus)} onclick={activate(i)} onkeydown={moveFocus(i)} tabindex={selected ? 0 : -1} aria-selected={selected} aria-controls={panels[i].id} type="button" role="tab" {id}>
88
88
  {#if isStrLabel}
89
89
  {name}
@@ -96,7 +96,7 @@
96
96
  {#each panels as { id, name }, i (id)}
97
97
  {@const selected = i === current}
98
98
  {@const style = selected ? undefined : "display: none;"}
99
- <div class={cls(PARTS.MAIN, status)} aria-labelledby={tabs[i].id} role="tabpanel" tabindex={0} hidden={!selected} {id} {style}>
99
+ <div class={cls(PARTS.MAIN, variant)} aria-labelledby={tabs[i].id} role="tabpanel" tabindex={0} hidden={!selected} {id} {style}>
100
100
  {@render (rest[name] as Snippet)()}
101
101
  </div>
102
102
  {/each}