svseeds 0.4.11 → 0.5.0
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.
- package/_svseeds/ToggleGroupField.svelte +5 -5
- package/_svseeds/ToggleGroupField.svelte.d.ts +3 -3
- package/_svseeds/_Drawer.svelte +123 -0
- package/_svseeds/_Drawer.svelte.d.ts +41 -0
- package/_svseeds/_Modal.svelte +34 -21
- package/_svseeds/_Modal.svelte.d.ts +6 -3
- package/_svseeds/_ProgressTracker.svelte +23 -29
- package/_svseeds/_ProgressTracker.svelte.d.ts +6 -4
- package/_svseeds/_Slider.svelte +2 -2
- package/_svseeds/_Slider.svelte.d.ts +2 -2
- package/_svseeds/_Sortable.svelte +20 -20
- package/_svseeds/_Sortable.svelte.d.ts +12 -12
- package/_svseeds/_TagsInput.svelte +1 -1
- package/_svseeds/_TagsInput.svelte.d.ts +1 -1
- package/_svseeds/_Toggle.svelte +18 -39
- package/_svseeds/_Toggle.svelte.d.ts +5 -5
- package/_svseeds/_ToggleGroup.svelte +16 -20
- package/_svseeds/_ToggleGroup.svelte.d.ts +6 -4
- package/_svseeds/_Tooltip.svelte +2 -2
- package/_svseeds/_Tooltip.svelte.d.ts +2 -2
- package/_svseeds/core.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
multiple?: boolean; // (true)
|
|
16
16
|
validations?: ToggleGroupFieldValidation[];
|
|
17
17
|
name?: string;
|
|
18
|
+
elements?: HTMLButtonElement[];
|
|
18
19
|
styling?: SVSClass;
|
|
19
20
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
20
21
|
deps?: ToggleGroupFieldDeps;
|
|
21
|
-
[key: string]: unknown | Snippet;
|
|
22
22
|
}
|
|
23
23
|
interface ToggleGroupFieldDeps {
|
|
24
24
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
multiple?: boolean; // (true)
|
|
41
41
|
validations?: ToggleGroupFieldValidation[];
|
|
42
42
|
name?: string;
|
|
43
|
+
elements?: HTMLButtonElement[]; // bindable
|
|
43
44
|
styling?: SVSClass;
|
|
44
45
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
45
46
|
deps?: ToggleGroupFieldDeps;
|
|
46
|
-
[key: string]: unknown | Snippet;
|
|
47
47
|
}
|
|
48
48
|
export interface ToggleGroupFieldDeps {
|
|
49
49
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
64
|
<script lang="ts">
|
|
65
|
-
let { options, label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), multiple = true, validations = [], name, styling, variant = $bindable(""), deps
|
|
65
|
+
let { options, label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), multiple = true, validations = [], name, elements = $bindable([]), styling, variant = $bindable(""), deps }: ToggleGroupFieldProps = $props();
|
|
66
66
|
|
|
67
67
|
// *** Initialize *** //
|
|
68
68
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
// *** Initialize Deps *** //
|
|
77
77
|
const svsToggleGroup = {
|
|
78
|
-
|
|
78
|
+
children: deps?.svsToggleGroup?.children,
|
|
79
79
|
ariaDescId: idDesc,
|
|
80
80
|
styling: deps?.svsToggleGroup?.styling as SVSClass ?? `${preset} svs-toggle-group`,
|
|
81
81
|
action: deps?.svsToggleGroup?.action as Action,
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
<div class={cls(PARTS.MIDDLE, variant)}>
|
|
135
135
|
{@render side(PARTS.LEFT, left)}
|
|
136
136
|
{@render fnForm()}
|
|
137
|
-
<ToggleGroup bind:values bind:ariaErrMsgId={idMsg} bind:variant={neutral} {options} {multiple} {...svsToggleGroup} />
|
|
137
|
+
<ToggleGroup bind:values bind:elements bind:ariaErrMsgId={idMsg} bind:variant={neutral} {options} {multiple} {...svsToggleGroup} />
|
|
138
138
|
{@render side(PARTS.RIGHT, right)}
|
|
139
139
|
</div>
|
|
140
140
|
{@render desc(!descFirst)}
|
|
@@ -11,10 +11,10 @@ export interface ToggleGroupFieldProps {
|
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
validations?: ToggleGroupFieldValidation[];
|
|
13
13
|
name?: string;
|
|
14
|
+
elements?: HTMLButtonElement[];
|
|
14
15
|
styling?: SVSClass;
|
|
15
16
|
variant?: string;
|
|
16
17
|
deps?: ToggleGroupFieldDeps;
|
|
17
|
-
[key: string]: unknown | Snippet;
|
|
18
18
|
}
|
|
19
19
|
export interface ToggleGroupFieldDeps {
|
|
20
20
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
@@ -42,10 +42,10 @@ import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindP
|
|
|
42
42
|
* multiple?: boolean; // (true)
|
|
43
43
|
* validations?: ToggleGroupFieldValidation[];
|
|
44
44
|
* name?: string;
|
|
45
|
+
* elements?: HTMLButtonElement[];
|
|
45
46
|
* styling?: SVSClass;
|
|
46
47
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
47
48
|
* deps?: ToggleGroupFieldDeps;
|
|
48
|
-
* [key: string]: unknown | Snippet;
|
|
49
49
|
* }
|
|
50
50
|
* interface ToggleGroupFieldDeps {
|
|
51
51
|
* svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
@@ -53,6 +53,6 @@ import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindP
|
|
|
53
53
|
* type ToggleGroupFieldValidation = (values: string[]) => string | undefined;
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
declare const ToggleGroupField: import("svelte").Component<ToggleGroupFieldProps, {}, "variant" | "values">;
|
|
56
|
+
declare const ToggleGroupField: import("svelte").Component<ToggleGroupFieldProps, {}, "variant" | "elements" | "values">;
|
|
57
57
|
type ToggleGroupField = ReturnType<typeof ToggleGroupField>;
|
|
58
58
|
export default ToggleGroupField;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `(value)`
|
|
4
|
+
```ts
|
|
5
|
+
interface DrawerProps {
|
|
6
|
+
children: Snippet<[string]>; // Snippet<[variant]>
|
|
7
|
+
open?: boolean; // bindable (false)
|
|
8
|
+
position?: Position; // ("left")
|
|
9
|
+
size?: string; // ("auto")
|
|
10
|
+
duration?: number; // (200)
|
|
11
|
+
closable?: boolean; // (true)
|
|
12
|
+
id?: string;
|
|
13
|
+
attributes?: HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
element?: HTMLDivElement; // bindable
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
17
|
+
}
|
|
18
|
+
type Position = "top" | "right" | "bottom" | "left";
|
|
19
|
+
```
|
|
20
|
+
-->
|
|
21
|
+
<script module lang="ts">
|
|
22
|
+
export interface DrawerProps {
|
|
23
|
+
children: Snippet<[string]>; // Snippet<[variant]>
|
|
24
|
+
open?: boolean; // bindable (false)
|
|
25
|
+
position?: Position; // ("left")
|
|
26
|
+
size?: string; // ("auto")
|
|
27
|
+
duration?: number; // (200)
|
|
28
|
+
closable?: boolean; // (true)
|
|
29
|
+
id?: string;
|
|
30
|
+
attributes?: HTMLAttributes<HTMLDivElement>;
|
|
31
|
+
element?: HTMLDivElement; // bindable
|
|
32
|
+
styling?: SVSClass;
|
|
33
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
34
|
+
}
|
|
35
|
+
export type Position = "top" | "right" | "bottom" | "left";
|
|
36
|
+
export type DrawerReqdProps = "children";
|
|
37
|
+
export type DrawerBindProps = "open" | "variant" | "element";
|
|
38
|
+
|
|
39
|
+
const preset = "svs-drawer";
|
|
40
|
+
|
|
41
|
+
const sleep = (msec: number) => new Promise(resolve => setTimeout(resolve, msec));
|
|
42
|
+
function getPositionProp(position: Position): string {
|
|
43
|
+
switch (position) {
|
|
44
|
+
case "top":
|
|
45
|
+
case "left": return "--top:0;--left:0;--bottom:auto;--right:auto;";
|
|
46
|
+
case "bottom": return "--top:auto;--left:0;--bottom:0;--right:auto;";
|
|
47
|
+
case "right": return "--top:0;--left:auto;--bottom:auto;--right:0;";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function getSizeProp(position: Position, size: string): string {
|
|
51
|
+
const interpolate = ["auto", "min-content", "max-content", "fit-content", "content"].includes(size) ? "interpolate-size:allow-keywords;" : "";
|
|
52
|
+
return ["top", "bottom"].includes(position)
|
|
53
|
+
? `--width-from:100dvw;--width-to:100dvw;--height-from:0;--height-to:${size};${interpolate}`
|
|
54
|
+
: `--width-from:0;--width-to:${size};--height-from:100dvh;--height-to:100dvh;${interpolate}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
import { type Snippet, untrack } from "svelte";
|
|
58
|
+
import { type HTMLAttributes } from "svelte/elements";
|
|
59
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<script lang="ts">
|
|
63
|
+
let { children, open = $bindable(false), position = "left", size = "auto", duration = 200, closable = true, id, attributes, element = $bindable(), styling, variant = $bindable("") }: DrawerProps = $props();
|
|
64
|
+
|
|
65
|
+
// *** Initialize *** //
|
|
66
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
67
|
+
const cls = fnClass(preset, styling);
|
|
68
|
+
const attrs = omit(attributes, "class", "id", "style", "popover", "ontoggle");
|
|
69
|
+
const popover = closable ? "auto" : "manual";
|
|
70
|
+
const baseStyle = `${getPositionProp(position)}${getSizeProp(position, size)}--duration:${duration}ms;margin:initial;padding:initial;`;
|
|
71
|
+
let style = $state(baseStyle);
|
|
72
|
+
|
|
73
|
+
// *** Bind Handlers *** //
|
|
74
|
+
$effect.pre(() => {
|
|
75
|
+
open;
|
|
76
|
+
untrack(() => toggle());
|
|
77
|
+
});
|
|
78
|
+
function toggle() {
|
|
79
|
+
if (open) {
|
|
80
|
+
element?.showPopover();
|
|
81
|
+
} else {
|
|
82
|
+
element?.hidePopover();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// *** Event Handlers *** //
|
|
87
|
+
function ontoggle(ev: ToggleEvent) {
|
|
88
|
+
attributes?.["ontoggle"]?.(ev as any);
|
|
89
|
+
open = ev.newState === "open";
|
|
90
|
+
style = baseStyle + "overflow:hidden;";
|
|
91
|
+
sleep(duration).finally(() => style = baseStyle);
|
|
92
|
+
}
|
|
93
|
+
$effect(() => untrack(() => { if (open) element?.showPopover(); }));
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<!---------------------------------------->
|
|
97
|
+
|
|
98
|
+
<div bind:this={element} class={cls(PARTS.WHOLE, variant)} {id} {style} {popover} {ontoggle} {...attrs}>
|
|
99
|
+
{@render children(variant)}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<style>
|
|
103
|
+
[popover] {
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: var(--top);
|
|
106
|
+
left: var(--left);
|
|
107
|
+
bottom: var(--bottom);
|
|
108
|
+
right: var(--right);
|
|
109
|
+
width: var(--width-from);
|
|
110
|
+
height: var(--height-from);
|
|
111
|
+
transition-property: display, width, height;
|
|
112
|
+
transition-behavior: allow-discrete;
|
|
113
|
+
transition-duration: var(--duration);
|
|
114
|
+
}
|
|
115
|
+
[popover]:popover-open {
|
|
116
|
+
width: var(--width-to);
|
|
117
|
+
height: var(--height-to);
|
|
118
|
+
@starting-style {
|
|
119
|
+
width: var(--width-from);
|
|
120
|
+
height: var(--height-from);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface DrawerProps {
|
|
2
|
+
children: Snippet<[string]>;
|
|
3
|
+
open?: boolean;
|
|
4
|
+
position?: Position;
|
|
5
|
+
size?: string;
|
|
6
|
+
duration?: number;
|
|
7
|
+
closable?: boolean;
|
|
8
|
+
id?: string;
|
|
9
|
+
attributes?: HTMLAttributes<HTMLDivElement>;
|
|
10
|
+
element?: HTMLDivElement;
|
|
11
|
+
styling?: SVSClass;
|
|
12
|
+
variant?: string;
|
|
13
|
+
}
|
|
14
|
+
export type Position = "top" | "right" | "bottom" | "left";
|
|
15
|
+
export type DrawerReqdProps = "children";
|
|
16
|
+
export type DrawerBindProps = "open" | "variant" | "element";
|
|
17
|
+
import { type Snippet } from "svelte";
|
|
18
|
+
import { type HTMLAttributes } from "svelte/elements";
|
|
19
|
+
import { type SVSClass } from "./core";
|
|
20
|
+
/**
|
|
21
|
+
* default value: `(value)`
|
|
22
|
+
* ```ts
|
|
23
|
+
* interface DrawerProps {
|
|
24
|
+
* children: Snippet<[string]>; // Snippet<[variant]>
|
|
25
|
+
* open?: boolean; // bindable (false)
|
|
26
|
+
* position?: Position; // ("left")
|
|
27
|
+
* size?: string; // ("auto")
|
|
28
|
+
* duration?: number; // (200)
|
|
29
|
+
* closable?: boolean; // (true)
|
|
30
|
+
* id?: string;
|
|
31
|
+
* attributes?: HTMLAttributes<HTMLDivElement>;
|
|
32
|
+
* element?: HTMLDivElement; // bindable
|
|
33
|
+
* styling?: SVSClass;
|
|
34
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
35
|
+
* }
|
|
36
|
+
* type Position = "top" | "right" | "bottom" | "left";
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const Drawer: import("svelte").Component<DrawerProps, {}, "variant" | "open" | "element">;
|
|
40
|
+
type Drawer = ReturnType<typeof Drawer>;
|
|
41
|
+
export default Drawer;
|
package/_svseeds/_Modal.svelte
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
children: Snippet<[string]>; // Snippet<[variant]>
|
|
7
7
|
open?: boolean; // bindable (false)
|
|
8
8
|
closable?: boolean; // (true)
|
|
9
|
-
|
|
9
|
+
id?: string;
|
|
10
10
|
ariaLabel?: string;
|
|
11
|
+
attributes?: HTMLDialogAttributes;
|
|
11
12
|
element?: HTMLDialogElement; // bindable
|
|
12
13
|
styling?: SVSClass;
|
|
13
14
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
@@ -19,8 +20,9 @@
|
|
|
19
20
|
children: Snippet<[string]>; // Snippet<[variant]>
|
|
20
21
|
open?: boolean; // bindable (false)
|
|
21
22
|
closable?: boolean; // (true)
|
|
22
|
-
|
|
23
|
+
id?: string;
|
|
23
24
|
ariaLabel?: string;
|
|
25
|
+
attributes?: HTMLDialogAttributes;
|
|
24
26
|
element?: HTMLDialogElement; // bindable
|
|
25
27
|
styling?: SVSClass;
|
|
26
28
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
@@ -28,26 +30,25 @@
|
|
|
28
30
|
export type ModalReqdProps = "children";
|
|
29
31
|
export type ModalBindProps = "open" | "variant" | "element";
|
|
30
32
|
|
|
33
|
+
const duration = 200;
|
|
31
34
|
const preset = "svs-modal";
|
|
32
35
|
|
|
33
36
|
import { type Snippet, untrack } from "svelte";
|
|
34
|
-
import { type
|
|
37
|
+
import { type HTMLDialogAttributes } from "svelte/elements";
|
|
38
|
+
import { fade } from "svelte/transition";
|
|
39
|
+
import { cubicOut } from "svelte/easing";
|
|
40
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
|
|
35
41
|
</script>
|
|
36
42
|
|
|
37
43
|
<script lang="ts">
|
|
38
|
-
let { children, open = $bindable(false), closable = true,
|
|
44
|
+
let { children, open = $bindable(false), closable = true, id, ariaLabel, attributes, element = $bindable(), styling, variant = $bindable("") }: ModalProps = $props();
|
|
39
45
|
|
|
40
46
|
// *** Initialize *** //
|
|
41
47
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
42
48
|
const cls = fnClass(preset, styling);
|
|
49
|
+
const attrs = omit(attributes, "class", "id", "autofocus", "aria-label", "onclick", "onkeydown", "ontoggle");
|
|
43
50
|
|
|
44
51
|
// *** Bind Handlers *** //
|
|
45
|
-
$effect(() => {
|
|
46
|
-
open;
|
|
47
|
-
untrack(() => {
|
|
48
|
-
if (!open) trigger?.focus();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
52
|
$effect.pre(() => {
|
|
52
53
|
open;
|
|
53
54
|
untrack(() => toggle());
|
|
@@ -61,25 +62,37 @@
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
// *** Event Handlers *** //
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
function click(ev: MouseEvent) {
|
|
66
|
+
attributes?.["onclick"]?.(ev as any);
|
|
67
|
+
if (ev.target === element) open = false;
|
|
68
|
+
}
|
|
69
|
+
function keydown(ev: KeyboardEvent) {
|
|
70
|
+
attributes?.["onkeydown"]?.(ev as any);
|
|
71
|
+
if (ev.key === "Escape") ev.preventDefault();
|
|
72
|
+
}
|
|
73
|
+
const onclick = closable ? click : attributes?.["onclick"];
|
|
74
|
+
const onkeydown = closable ? attributes?.["onkeydown"] : keydown;
|
|
75
|
+
function ontoggle(ev: Event) {
|
|
76
|
+
attributes?.["ontoggle"]?.(ev as any);
|
|
77
|
+
open = element?.open ?? false;
|
|
68
78
|
}
|
|
69
79
|
$effect(() => untrack(() => { if (open) element?.showModal(); }));
|
|
70
80
|
</script>
|
|
71
81
|
|
|
72
82
|
<!---------------------------------------->
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
<dialog bind:this={element} class={cls(PARTS.WHOLE, variant)} aria-label={ariaLabel} {id} {onclick} {onkeydown} {ontoggle} autofocus={true} {...attrs} style="margin:auto;background-color:transparent;">
|
|
85
|
+
{#if open}
|
|
86
|
+
<div class={cls(PARTS.MAIN, variant)} transition:fade={{ duration, easing: cubicOut }}>
|
|
87
|
+
{@render children(variant)}
|
|
88
|
+
</div>
|
|
89
|
+
{/if}
|
|
79
90
|
</dialog>
|
|
80
91
|
|
|
81
92
|
<style>
|
|
82
|
-
:global
|
|
83
|
-
|
|
93
|
+
:global {
|
|
94
|
+
:root:has(dialog[open]) {
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
}
|
|
84
97
|
}
|
|
85
98
|
</style>
|
|
@@ -2,8 +2,9 @@ export interface ModalProps {
|
|
|
2
2
|
children: Snippet<[string]>;
|
|
3
3
|
open?: boolean;
|
|
4
4
|
closable?: boolean;
|
|
5
|
-
|
|
5
|
+
id?: string;
|
|
6
6
|
ariaLabel?: string;
|
|
7
|
+
attributes?: HTMLDialogAttributes;
|
|
7
8
|
element?: HTMLDialogElement;
|
|
8
9
|
styling?: SVSClass;
|
|
9
10
|
variant?: string;
|
|
@@ -11,6 +12,7 @@ export interface ModalProps {
|
|
|
11
12
|
export type ModalReqdProps = "children";
|
|
12
13
|
export type ModalBindProps = "open" | "variant" | "element";
|
|
13
14
|
import { type Snippet } from "svelte";
|
|
15
|
+
import { type HTMLDialogAttributes } from "svelte/elements";
|
|
14
16
|
import { type SVSClass } from "./core";
|
|
15
17
|
/**
|
|
16
18
|
* default value: `(value)`
|
|
@@ -19,14 +21,15 @@ import { type SVSClass } from "./core";
|
|
|
19
21
|
* children: Snippet<[string]>; // Snippet<[variant]>
|
|
20
22
|
* open?: boolean; // bindable (false)
|
|
21
23
|
* closable?: boolean; // (true)
|
|
22
|
-
*
|
|
24
|
+
* id?: string;
|
|
23
25
|
* ariaLabel?: string;
|
|
26
|
+
* attributes?: HTMLDialogAttributes;
|
|
24
27
|
* element?: HTMLDialogElement; // bindable
|
|
25
28
|
* styling?: SVSClass;
|
|
26
29
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
27
30
|
* }
|
|
28
31
|
* ```
|
|
29
32
|
*/
|
|
30
|
-
declare const Modal: import("svelte").Component<ModalProps, {}, "variant" | "open" | "element"
|
|
33
|
+
declare const Modal: import("svelte").Component<ModalProps, {}, "variant" | "open" | "element">;
|
|
31
34
|
type Modal = ReturnType<typeof Modal>;
|
|
32
35
|
export default Modal;
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
interface ProgressTrackerProps {
|
|
6
6
|
current: number; // bindable (0)
|
|
7
7
|
labels: string[];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
children?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
9
|
+
aux?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
10
|
+
extra?: boolean | Snippet<[number, string, string]>; // (true) Snippet<[index,label,variant]>
|
|
10
11
|
styling?: SVSClass;
|
|
11
12
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
12
13
|
eachVariant?: SvelteMap<number, string> | Map<number, string>;
|
|
@@ -17,8 +18,9 @@
|
|
|
17
18
|
export interface ProgressTrackerProps {
|
|
18
19
|
current: number; // bindable (0)
|
|
19
20
|
labels: string[];
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
children?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
22
|
+
aux?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
23
|
+
extra?: boolean | Snippet<[number, string, string]>; // (true) Snippet<[index,label,variant]>
|
|
22
24
|
styling?: SVSClass;
|
|
23
25
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
24
26
|
eachVariant?: SvelteMap<number, string> | Map<number, string>;
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
</script>
|
|
35
37
|
|
|
36
38
|
<script lang="ts">
|
|
37
|
-
let { current = $bindable(-1), labels, aux, extra, styling, variant = $bindable(""), eachVariant }: ProgressTrackerProps = $props();
|
|
39
|
+
let { current = $bindable(-1), labels, children, aux, extra = true, styling, variant = $bindable(""), eachVariant }: ProgressTrackerProps = $props();
|
|
38
40
|
|
|
39
41
|
// *** Initialize *** //
|
|
40
42
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
@@ -56,37 +58,29 @@
|
|
|
56
58
|
<ol class={cls(PARTS.WHOLE, variant)}>
|
|
57
59
|
{#each labels as label, i}
|
|
58
60
|
{@const stat = getEachVariant(i)}
|
|
59
|
-
<li class={cls(PARTS.
|
|
60
|
-
{
|
|
61
|
-
{
|
|
62
|
-
{/if}
|
|
63
|
-
{#if aux}
|
|
64
|
-
<div class={cls(PARTS.MIDDLE, stat)}>
|
|
61
|
+
<li class={cls(PARTS.MIDDLE, stat)} aria-current={i === current ? "step" : false} style={i < labels.length - 1 ? "flex-grow:1;" : undefined}>
|
|
62
|
+
<div class={cls(PARTS.MAIN, stat)}>
|
|
63
|
+
{#if aux}
|
|
65
64
|
<div class={cls(PARTS.AUX, stat)}>
|
|
66
|
-
{@render aux(i, stat)}
|
|
65
|
+
{@render aux(i, label, stat)}
|
|
67
66
|
</div>
|
|
68
|
-
|
|
67
|
+
{/if}
|
|
68
|
+
<div class={cls(PARTS.LABEL, stat)}>
|
|
69
|
+
{#if children}
|
|
70
|
+
{@render children(i, label, stat)}
|
|
71
|
+
{:else}
|
|
69
72
|
{label}
|
|
70
|
-
|
|
73
|
+
{/if}
|
|
71
74
|
</div>
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
</div>
|
|
76
|
+
{#if extra !== false && i < labels.length - 1 }
|
|
77
|
+
<div class={cls(PARTS.EXTRA, stat)} role="separator">
|
|
78
|
+
{#if typeof extra === "function"}
|
|
79
|
+
{@render extra(i, label, stat)}
|
|
80
|
+
{/if}
|
|
75
81
|
</div>
|
|
76
82
|
{/if}
|
|
77
83
|
</li>
|
|
78
|
-
{#if i < current}
|
|
79
|
-
{@render separator(i)}
|
|
80
|
-
{/if}
|
|
81
84
|
{/each}
|
|
82
85
|
</ol>
|
|
83
86
|
{/if}
|
|
84
|
-
|
|
85
|
-
{#snippet separator(i: number)}
|
|
86
|
-
{#if extra}
|
|
87
|
-
{@const stat = i < current ? VARIANT.ACTIVE : VARIANT.INACTIVE}
|
|
88
|
-
<div class={cls(PARTS.EXTRA, stat)} role="separator">
|
|
89
|
-
{@render extra(i, stat)}
|
|
90
|
-
</div>
|
|
91
|
-
{/if}
|
|
92
|
-
{/snippet}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export interface ProgressTrackerProps {
|
|
2
2
|
current: number;
|
|
3
3
|
labels: string[];
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
children?: Snippet<[number, string, string]>;
|
|
5
|
+
aux?: Snippet<[number, string, string]>;
|
|
6
|
+
extra?: boolean | Snippet<[number, string, string]>;
|
|
6
7
|
styling?: SVSClass;
|
|
7
8
|
variant?: string;
|
|
8
9
|
eachVariant?: SvelteMap<number, string> | Map<number, string>;
|
|
@@ -18,8 +19,9 @@ import { type SVSClass } from "./core";
|
|
|
18
19
|
* interface ProgressTrackerProps {
|
|
19
20
|
* current: number; // bindable (0)
|
|
20
21
|
* labels: string[];
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* children?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
23
|
+
* aux?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
|
|
24
|
+
* extra?: boolean | Snippet<[number, string, string]>; // (true) Snippet<[index,label,variant]>
|
|
23
25
|
* styling?: SVSClass;
|
|
24
26
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
25
27
|
* eachVariant?: SvelteMap<number, string> | Map<number, string>;
|
package/_svseeds/_Slider.svelte
CHANGED
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
styling?: SVSClass;
|
|
35
35
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
36
36
|
}
|
|
37
|
-
export type SliderReqdProps = "
|
|
38
|
-
export type SliderBindProps = "
|
|
37
|
+
export type SliderReqdProps = "range";
|
|
38
|
+
export type SliderBindProps = "range" | "value" | "element" | "variant";
|
|
39
39
|
export type Range = { min: number, max: number };
|
|
40
40
|
|
|
41
41
|
const preset = "svs-slider";
|
|
@@ -12,8 +12,8 @@ export interface SliderProps {
|
|
|
12
12
|
styling?: SVSClass;
|
|
13
13
|
variant?: string;
|
|
14
14
|
}
|
|
15
|
-
export type SliderReqdProps = "
|
|
16
|
-
export type SliderBindProps = "
|
|
15
|
+
export type SliderReqdProps = "range";
|
|
16
|
+
export type SliderBindProps = "range" | "value" | "element" | "variant";
|
|
17
17
|
export type Range = {
|
|
18
18
|
min: number;
|
|
19
19
|
max: number;
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
default value: `(value)`
|
|
4
4
|
```ts
|
|
5
5
|
interface SortableProps {
|
|
6
|
-
items: SortableItems; // wrapper
|
|
6
|
+
items: SortableItems; // wrapper around string array to handle drag and drop
|
|
7
7
|
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
8
|
-
ghost?: Snippet<[string]>; // custom
|
|
8
|
+
ghost?: Snippet<[string]>; // custom ghost element while dragging (translucent item); Snippet<[value]>
|
|
9
9
|
name?: string; // name of this group (random string)
|
|
10
|
-
mode?:
|
|
11
|
-
accept?: string[]; // list of
|
|
12
|
-
sort?: boolean; // enable
|
|
13
|
-
multiple?: boolean; // enable multiple
|
|
10
|
+
mode?: "std" | "clone" | "swap"; // sort mode ("std")
|
|
11
|
+
accept?: string[]; // list of accepted group names (undefined); undefined=any,[]=none
|
|
12
|
+
sort?: boolean; // enable sorting within the same group (true)
|
|
13
|
+
multiple?: boolean; // enable multiple selection and dragging (false)
|
|
14
14
|
draggable?: boolean; // enable default pointerdown handler (true)
|
|
15
|
-
appendable?: boolean; // enable
|
|
16
|
-
confirm?: boolean // enable
|
|
15
|
+
appendable?: boolean; // enable appending when entering group area (false)
|
|
16
|
+
confirm?: boolean // enable confirmation delay before moving items (false)
|
|
17
17
|
styling?: SVSClass;
|
|
18
18
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
class SortableItems {
|
|
20
|
+
// Methods have the same functionality as standard array methods
|
|
21
|
+
class SortableItems {
|
|
22
22
|
constructor(values: string[])
|
|
23
23
|
at(index: number): string | undefined
|
|
24
24
|
replace(index: number, value: string): boolean
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
pop(): string | undefined
|
|
27
27
|
unshift(value: string)
|
|
28
28
|
shift(): string | undefined
|
|
29
|
-
insert(index: number, value: string) //
|
|
30
|
-
extract(index: number): string | undefined //
|
|
29
|
+
insert(index: number, value: string) // alternative to splice
|
|
30
|
+
extract(index: number): string | undefined // alternative to splice
|
|
31
31
|
isEmpty(): boolean
|
|
32
32
|
clear(): void
|
|
33
33
|
get length(): number
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
|
|
51
51
|
type SortableMode = "std" | "clone" | "swap";
|
|
52
52
|
export interface SortableProps {
|
|
53
|
-
items: SortableItems; // wrapper
|
|
53
|
+
items: SortableItems; // wrapper around string array to handle drag and drop
|
|
54
54
|
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
55
|
-
ghost?: Snippet<[string]>; // custom
|
|
55
|
+
ghost?: Snippet<[string]>; // custom ghost element while dragging (translucent item); Snippet<[value]>
|
|
56
56
|
name?: string; // name of this group (random string)
|
|
57
57
|
mode?: SortableMode; // sort mode ("std")
|
|
58
|
-
accept?: string[]; // list of
|
|
59
|
-
sort?: boolean; // enable
|
|
60
|
-
multiple?: boolean; // enable multiple
|
|
58
|
+
accept?: string[]; // list of accepted group names (undefined); undefined=any,[]=none
|
|
59
|
+
sort?: boolean; // enable sorting within the same group (true)
|
|
60
|
+
multiple?: boolean; // enable multiple selection and dragging (false)
|
|
61
61
|
draggable?: boolean; // enable default pointerdown handler (true)
|
|
62
|
-
appendable?: boolean; // enable
|
|
63
|
-
confirm?: boolean // enable
|
|
62
|
+
appendable?: boolean; // enable appending when entering group area (false)
|
|
63
|
+
confirm?: boolean // enable confirmation delay before moving items (false)
|
|
64
64
|
styling?: SVSClass;
|
|
65
65
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
66
66
|
}
|
|
@@ -651,7 +651,7 @@
|
|
|
651
651
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
652
652
|
const cls = fnClass(preset, styling);
|
|
653
653
|
const group: KeyValue = SortableItems._newItem(name);
|
|
654
|
-
const elems: HTMLElement[] = [];
|
|
654
|
+
const elems: HTMLElement[] = $state([]);
|
|
655
655
|
const shadow = new Shadow(ghost);
|
|
656
656
|
const selector = new MultiSelect(items, multiple, triggerSelect);
|
|
657
657
|
const listener = new ListenerHandler();
|
|
@@ -61,22 +61,22 @@ import { type SVSClass } from "./core";
|
|
|
61
61
|
* default value: `(value)`
|
|
62
62
|
* ```ts
|
|
63
63
|
* interface SortableProps {
|
|
64
|
-
* items: SortableItems; // wrapper
|
|
64
|
+
* items: SortableItems; // wrapper around string array to handle drag and drop
|
|
65
65
|
* item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
66
|
-
* ghost?: Snippet<[string]>; // custom
|
|
66
|
+
* ghost?: Snippet<[string]>; // custom ghost element while dragging (translucent item); Snippet<[value]>
|
|
67
67
|
* name?: string; // name of this group (random string)
|
|
68
|
-
* mode?:
|
|
69
|
-
* accept?: string[]; // list of
|
|
70
|
-
* sort?: boolean; // enable
|
|
71
|
-
* multiple?: boolean; // enable multiple
|
|
68
|
+
* mode?: "std" | "clone" | "swap"; // sort mode ("std")
|
|
69
|
+
* accept?: string[]; // list of accepted group names (undefined); undefined=any,[]=none
|
|
70
|
+
* sort?: boolean; // enable sorting within the same group (true)
|
|
71
|
+
* multiple?: boolean; // enable multiple selection and dragging (false)
|
|
72
72
|
* draggable?: boolean; // enable default pointerdown handler (true)
|
|
73
|
-
* appendable?: boolean; // enable
|
|
74
|
-
* confirm?: boolean // enable
|
|
73
|
+
* appendable?: boolean; // enable appending when entering group area (false)
|
|
74
|
+
* confirm?: boolean // enable confirmation delay before moving items (false)
|
|
75
75
|
* styling?: SVSClass;
|
|
76
76
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
77
77
|
* }
|
|
78
|
-
*
|
|
79
|
-
* class SortableItems {
|
|
78
|
+
* // Methods have the same functionality as standard array methods
|
|
79
|
+
* class SortableItems {
|
|
80
80
|
* constructor(values: string[])
|
|
81
81
|
* at(index: number): string | undefined
|
|
82
82
|
* replace(index: number, value: string): boolean
|
|
@@ -84,8 +84,8 @@ import { type SVSClass } from "./core";
|
|
|
84
84
|
* pop(): string | undefined
|
|
85
85
|
* unshift(value: string)
|
|
86
86
|
* shift(): string | undefined
|
|
87
|
-
* insert(index: number, value: string) //
|
|
88
|
-
* extract(index: number): string | undefined //
|
|
87
|
+
* insert(index: number, value: string) // alternative to splice
|
|
88
|
+
* extract(index: number): string | undefined // alternative to splice
|
|
89
89
|
* isEmpty(): boolean
|
|
90
90
|
* clear(): void
|
|
91
91
|
* get length(): number
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
styling?: SVSClass;
|
|
20
20
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
21
21
|
}
|
|
22
|
-
interface TagsInputEvents { // cancel if true
|
|
22
|
+
interface TagsInputEvents { // cancel if returns true
|
|
23
23
|
onadd?: (values: string[], value: string) => void | boolean;
|
|
24
24
|
onremove?: (values: string[], value: string, index: number) => void | boolean;
|
|
25
25
|
}
|
|
@@ -45,7 +45,7 @@ import { type SVSClass } from "./core";
|
|
|
45
45
|
* styling?: SVSClass;
|
|
46
46
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
47
47
|
* }
|
|
48
|
-
* interface TagsInputEvents { // cancel if true
|
|
48
|
+
* interface TagsInputEvents { // cancel if returns true
|
|
49
49
|
* onadd?: (values: string[], value: string) => void | boolean;
|
|
50
50
|
* onremove?: (values: string[], value: string, index: number) => void | boolean;
|
|
51
51
|
* }
|
package/_svseeds/_Toggle.svelte
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
default value: `(value)`
|
|
4
4
|
```ts
|
|
5
5
|
interface ToggleProps {
|
|
6
|
-
children
|
|
6
|
+
children: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
7
7
|
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
8
8
|
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
9
9
|
value?: boolean; // bindable (false)
|
|
10
|
-
|
|
10
|
+
role?: "button" | "switch"; // ("button")
|
|
11
11
|
ariaLabel?: string;
|
|
12
12
|
attributes?: HTMLButtonAttributes;
|
|
13
13
|
action?: Action;
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
-->
|
|
20
20
|
<script module lang="ts">
|
|
21
21
|
export interface ToggleProps {
|
|
22
|
-
children
|
|
22
|
+
children: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
23
23
|
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
24
24
|
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
25
25
|
value?: boolean; // bindable (false)
|
|
26
|
-
|
|
26
|
+
role?: "button" | "switch"; // ("button")
|
|
27
27
|
ariaLabel?: string;
|
|
28
28
|
attributes?: HTMLButtonAttributes;
|
|
29
29
|
action?: Action;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
styling?: SVSClass;
|
|
32
32
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
33
33
|
}
|
|
34
|
-
export type ToggleReqdProps =
|
|
34
|
+
export type ToggleReqdProps = "children";
|
|
35
35
|
export type ToggleBindProps = "value" | "variant" | "element";
|
|
36
36
|
|
|
37
37
|
type ToggleTarget = { currentTarget: EventTarget & HTMLButtonElement };
|
|
@@ -44,13 +44,14 @@
|
|
|
44
44
|
</script>
|
|
45
45
|
|
|
46
46
|
<script lang="ts">
|
|
47
|
-
let { children, left, right, value = $bindable(false),
|
|
47
|
+
let { children, left, right, value = $bindable(false), role = "button", ariaLabel, attributes, action, element = $bindable(), styling, variant = $bindable("") }: ToggleProps = $props();
|
|
48
48
|
|
|
49
49
|
// *** Initialize *** //
|
|
50
50
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
51
51
|
const cls = fnClass(preset, styling);
|
|
52
52
|
const attrs = omit(attributes, "class", "type", "role", "aria-checked", "aria-pressed", "onclick");
|
|
53
53
|
let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
|
|
54
|
+
let state = $derived(role === "button" ? { "aria-pressed": value } : { "aria-checked": value });
|
|
54
55
|
|
|
55
56
|
// *** Bind Handlers *** //
|
|
56
57
|
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
@@ -73,11 +74,11 @@
|
|
|
73
74
|
{#if left || right}
|
|
74
75
|
<span class={cls(PARTS.WHOLE, variant)} role="group">
|
|
75
76
|
{@render side(PARTS.LEFT, left)}
|
|
76
|
-
{@render button(
|
|
77
|
+
{@render button()}
|
|
77
78
|
{@render side(PARTS.RIGHT, right)}
|
|
78
79
|
</span>
|
|
79
80
|
{:else}
|
|
80
|
-
{@render button(
|
|
81
|
+
{@render button()}
|
|
81
82
|
{/if}
|
|
82
83
|
|
|
83
84
|
{#snippet side(area: string, body?: Snippet<[boolean, string, HTMLButtonElement | undefined]>)}
|
|
@@ -85,38 +86,16 @@
|
|
|
85
86
|
<span class={cls(area, variant)}>{@render body(value, variant, element)}</span>
|
|
86
87
|
{/if}
|
|
87
88
|
{/snippet}
|
|
88
|
-
{#snippet
|
|
89
|
-
{
|
|
90
|
-
{@render children(value, variant, element)}
|
|
91
|
-
{/if}
|
|
92
|
-
{/snippet}
|
|
93
|
-
{#snippet button(role: string)}
|
|
89
|
+
{#snippet button()}
|
|
90
|
+
{@const r = role === "button" ? undefined : role}
|
|
94
91
|
{@const c = cls(PARTS.MAIN, variant)}
|
|
95
|
-
{#if
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</button>
|
|
100
|
-
{:else}
|
|
101
|
-
<button bind:this={element} class={c} type="button" aria-pressed={value} aria-label={ariaLabel} {onclick} {...attrs}>
|
|
102
|
-
{@render contents()}
|
|
103
|
-
</button>
|
|
104
|
-
{/if}
|
|
92
|
+
{#if action}
|
|
93
|
+
<button bind:this={element} class={c} type="button" role={r} aria-label={ariaLabel} {onclick} {...state} {...attrs} use:action>
|
|
94
|
+
{@render children(value, variant, element)}
|
|
95
|
+
</button>
|
|
105
96
|
{:else}
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
{@render thumb()}
|
|
110
|
-
</button>
|
|
111
|
-
{:else}
|
|
112
|
-
<button bind:this={element} class={c} {style} type="button" {role} aria-checked={value} aria-label={ariaLabel} {onclick} {...attrs}>
|
|
113
|
-
{@render thumb()}
|
|
114
|
-
</button>
|
|
115
|
-
{/if}
|
|
97
|
+
<button bind:this={element} class={c} type="button" role={r} aria-label={ariaLabel} {onclick} {...state} {...attrs}>
|
|
98
|
+
{@render children(value, variant, element)}
|
|
99
|
+
</button>
|
|
116
100
|
{/if}
|
|
117
101
|
{/snippet}
|
|
118
|
-
{#snippet thumb()}
|
|
119
|
-
<span class={cls(PARTS.AUX, variant)} style="position: absolute;">
|
|
120
|
-
{@render contents()}
|
|
121
|
-
</span>
|
|
122
|
-
{/snippet}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface ToggleProps {
|
|
2
|
-
children
|
|
2
|
+
children: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
3
3
|
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
4
4
|
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
5
5
|
value?: boolean;
|
|
6
|
-
|
|
6
|
+
role?: "button" | "switch";
|
|
7
7
|
ariaLabel?: string;
|
|
8
8
|
attributes?: HTMLButtonAttributes;
|
|
9
9
|
action?: Action;
|
|
@@ -11,7 +11,7 @@ export interface ToggleProps {
|
|
|
11
11
|
styling?: SVSClass;
|
|
12
12
|
variant?: string;
|
|
13
13
|
}
|
|
14
|
-
export type ToggleReqdProps =
|
|
14
|
+
export type ToggleReqdProps = "children";
|
|
15
15
|
export type ToggleBindProps = "value" | "variant" | "element";
|
|
16
16
|
import { type Snippet } from "svelte";
|
|
17
17
|
import { type Action } from "svelte/action";
|
|
@@ -21,11 +21,11 @@ import { type SVSClass } from "./core";
|
|
|
21
21
|
* default value: `(value)`
|
|
22
22
|
* ```ts
|
|
23
23
|
* interface ToggleProps {
|
|
24
|
-
* children
|
|
24
|
+
* children: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
25
25
|
* left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
26
26
|
* right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
27
27
|
* value?: boolean; // bindable (false)
|
|
28
|
-
*
|
|
28
|
+
* role?: "button" | "switch"; // ("button")
|
|
29
29
|
* ariaLabel?: string;
|
|
30
30
|
* attributes?: HTMLButtonAttributes;
|
|
31
31
|
* action?: Action;
|
|
@@ -4,40 +4,36 @@
|
|
|
4
4
|
```ts
|
|
5
5
|
interface ToggleGroupProps {
|
|
6
6
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
7
|
+
children?: Snippet<[string, string, string]>; // Snippet<[value,text,variant]>
|
|
7
8
|
values?: string[]; // bindable
|
|
8
9
|
multiple?: boolean; // (true)
|
|
9
10
|
ariaDescId?: string;
|
|
10
11
|
ariaErrMsgId?: string; // bindable
|
|
11
12
|
action?: Action;
|
|
13
|
+
elements?: HTMLButtonElement[]; // bindable
|
|
12
14
|
styling?: SVSClass;
|
|
13
15
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
14
|
-
[key: string]: unknown | Snippet<[string]>; // contents instead of the text
|
|
15
16
|
}
|
|
16
17
|
```
|
|
17
18
|
-->
|
|
18
19
|
<script module lang="ts">
|
|
19
20
|
export interface ToggleGroupProps {
|
|
20
21
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
22
|
+
children?: Snippet<[string, string, string]>; // Snippet<[value,text,variant]>
|
|
21
23
|
values?: string[]; // bindable
|
|
22
24
|
multiple?: boolean; // (true)
|
|
23
25
|
ariaDescId?: string;
|
|
24
26
|
ariaErrMsgId?: string; // bindable
|
|
25
27
|
action?: Action;
|
|
28
|
+
elements?: HTMLButtonElement[]; // bindable
|
|
26
29
|
styling?: SVSClass;
|
|
27
30
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
28
|
-
[key: string]: unknown | Snippet<[string]>; // contents instead of the text
|
|
29
31
|
}
|
|
30
32
|
export type ToggleGroupReqdProps = "options";
|
|
31
|
-
export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "variant";
|
|
33
|
+
export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "elements" | "variant";
|
|
32
34
|
|
|
33
35
|
const preset = "svs-toggle-group";
|
|
34
36
|
|
|
35
|
-
function getSnippet(text: string, rest: Record<string, unknown>): Snippet<[string]> | undefined {
|
|
36
|
-
if (!Object.hasOwn(rest, text)) return;
|
|
37
|
-
if (typeof rest[text] !== "function") return;
|
|
38
|
-
return rest[text] as Snippet<[string]>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
import { type Snippet } from "svelte";
|
|
42
38
|
import { type Action } from "svelte/action";
|
|
43
39
|
import { type SvelteMap } from "svelte/reactivity";
|
|
@@ -45,7 +41,7 @@
|
|
|
45
41
|
</script>
|
|
46
42
|
|
|
47
43
|
<script lang="ts">
|
|
48
|
-
let { options, values = $bindable([]), multiple = true, ariaDescId, ariaErrMsgId = $bindable(),
|
|
44
|
+
let { options, children, values = $bindable([]), multiple = true, ariaDescId, ariaErrMsgId = $bindable(), action, elements = $bindable([]), styling, variant = $bindable("") }: ToggleGroupProps = $props();
|
|
49
45
|
|
|
50
46
|
// *** Initialize *** //
|
|
51
47
|
if (!variant) variant = VARIANT.NEUTRAL;
|
|
@@ -70,25 +66,25 @@
|
|
|
70
66
|
|
|
71
67
|
{#if opts.length}
|
|
72
68
|
<span class={cls(PARTS.WHOLE, variant)} role={roleGroup} aria-describedby={ariaDescId} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple ? ariaErrMsgId : undefined}>
|
|
73
|
-
{#each opts as { value, text, checked } (value)}
|
|
74
|
-
{@const
|
|
69
|
+
{#each opts as { value, text, checked }, i (value)}
|
|
70
|
+
{@const v = checked ? VARIANT.ACTIVE : variant}
|
|
71
|
+
{@const c = cls(PARTS.MAIN, v)}
|
|
75
72
|
{#if action}
|
|
76
|
-
<button class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? ariaErrMsgId : undefined} onclick={updateValues(value)} type="button" {role} use:action>
|
|
77
|
-
{@render content(value, text)}
|
|
73
|
+
<button bind:this={elements[i]} class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? ariaErrMsgId : undefined} onclick={updateValues(value)} type="button" {role} use:action>
|
|
74
|
+
{@render content(value, text, v)}
|
|
78
75
|
</button>
|
|
79
76
|
{:else}
|
|
80
|
-
<button class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? ariaErrMsgId : undefined} onclick={updateValues(value)} type="button" {role}>
|
|
81
|
-
{@render content(value, text)}
|
|
77
|
+
<button bind:this={elements[i]} class={c} aria-checked={checked} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? ariaErrMsgId : undefined} onclick={updateValues(value)} type="button" {role}>
|
|
78
|
+
{@render content(value, text, v)}
|
|
82
79
|
</button>
|
|
83
80
|
{/if}
|
|
84
81
|
{/each}
|
|
85
82
|
</span>
|
|
86
83
|
{/if}
|
|
87
84
|
|
|
88
|
-
{#snippet content(value: string, text: string)}
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
{@render snippet(value)}
|
|
85
|
+
{#snippet content(value: string, text: string, variant: string)}
|
|
86
|
+
{#if children}
|
|
87
|
+
{@render children(value, text, variant)}
|
|
92
88
|
{:else}
|
|
93
89
|
{text}
|
|
94
90
|
{/if}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
export interface ToggleGroupProps {
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
|
+
children?: Snippet<[string, string, string]>;
|
|
3
4
|
values?: string[];
|
|
4
5
|
multiple?: boolean;
|
|
5
6
|
ariaDescId?: string;
|
|
6
7
|
ariaErrMsgId?: string;
|
|
7
8
|
action?: Action;
|
|
9
|
+
elements?: HTMLButtonElement[];
|
|
8
10
|
styling?: SVSClass;
|
|
9
11
|
variant?: string;
|
|
10
|
-
[key: string]: unknown | Snippet<[string]>;
|
|
11
12
|
}
|
|
12
13
|
export type ToggleGroupReqdProps = "options";
|
|
13
|
-
export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "variant";
|
|
14
|
+
export type ToggleGroupBindProps = "values" | "ariaErrMsgId" | "elements" | "variant";
|
|
14
15
|
import { type Snippet } from "svelte";
|
|
15
16
|
import { type Action } from "svelte/action";
|
|
16
17
|
import { type SvelteMap } from "svelte/reactivity";
|
|
@@ -20,17 +21,18 @@ import { type SVSClass } from "./core";
|
|
|
20
21
|
* ```ts
|
|
21
22
|
* interface ToggleGroupProps {
|
|
22
23
|
* options: SvelteMap<string, string> | Map<string, string>;
|
|
24
|
+
* children?: Snippet<[string, string, string]>; // Snippet<[value,text,variant]>
|
|
23
25
|
* values?: string[]; // bindable
|
|
24
26
|
* multiple?: boolean; // (true)
|
|
25
27
|
* ariaDescId?: string;
|
|
26
28
|
* ariaErrMsgId?: string; // bindable
|
|
27
29
|
* action?: Action;
|
|
30
|
+
* elements?: HTMLButtonElement[]; // bindable
|
|
28
31
|
* styling?: SVSClass;
|
|
29
32
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
30
|
-
* [key: string]: unknown | Snippet<[string]>; // contents instead of the text
|
|
31
33
|
* }
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
34
|
-
declare const ToggleGroup: import("svelte").Component<ToggleGroupProps, {}, "variant" | "values" | "ariaErrMsgId">;
|
|
36
|
+
declare const ToggleGroup: import("svelte").Component<ToggleGroupProps, {}, "variant" | "elements" | "values" | "ariaErrMsgId">;
|
|
35
37
|
type ToggleGroup = ReturnType<typeof ToggleGroup>;
|
|
36
38
|
export default ToggleGroup;
|
package/_svseeds/_Tooltip.svelte
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
14
14
|
}
|
|
15
15
|
type Vector = { x: number, y: number };
|
|
16
|
-
type Position = "top" | "
|
|
16
|
+
type Position = "top" | "right" | "bottom" | "left";
|
|
17
17
|
type Align = "start" | "center" | "end";
|
|
18
18
|
```
|
|
19
19
|
-->
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
return (node) => { return core.action(node, text, delay, cursor, name); };
|
|
38
38
|
}
|
|
39
39
|
export type Vector = { x: number, y: number };
|
|
40
|
-
export type Position = "top" | "
|
|
40
|
+
export type Position = "top" | "right" | "bottom" | "left";
|
|
41
41
|
export type Align = "start" | "center" | "end";
|
|
42
42
|
|
|
43
43
|
type valueof<T> = T[keyof T];
|
|
@@ -21,7 +21,7 @@ export type Vector = {
|
|
|
21
21
|
x: number;
|
|
22
22
|
y: number;
|
|
23
23
|
};
|
|
24
|
-
export type Position = "top" | "
|
|
24
|
+
export type Position = "top" | "right" | "bottom" | "left";
|
|
25
25
|
export type Align = "start" | "center" | "end";
|
|
26
26
|
import { type Snippet } from "svelte";
|
|
27
27
|
import { type Action, type ActionReturn } from "svelte/action";
|
|
@@ -40,7 +40,7 @@ import { type SVSClass } from "./core";
|
|
|
40
40
|
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
41
41
|
* }
|
|
42
42
|
* type Vector = { x: number, y: number };
|
|
43
|
-
* type Position = "top" | "
|
|
43
|
+
* type Position = "top" | "right" | "bottom" | "left";
|
|
44
44
|
* type Align = "start" | "center" | "end";
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
package/_svseeds/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as BASE,e as VARIANT,r as PARTS,s as elemId,n as fnClass,u as isNeutral,a as isUnsignedInteger,c as omit,l as debounce,h as throttle,o as UniqueId};const t="base",e=Object.freeze({NEUTRAL:"neutral",ACTIVE:"active",INACTIVE:"inactive"}),r=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"});function n(r,n){const o=i(n)??i(r);return null==o?(t,e)=>{}:"string"==typeof o?(t,e)=>`${o} ${t} ${e}`:(r,n)=>function(r,n,i){const o=r[n]?.[t]??"",s=r[n]?.[i]??r[n]?.[e.NEUTRAL]??"";if(!o&&!s)return;return o&&s?[o,s]:o||s}(o,r,n)}function i(t){if(null==t)return;if("string"==typeof t)return t.trim()?t:void 0;const e=Object.entries(t);return e.length?Object.fromEntries(e.map((
|
|
1
|
+
export{t as BASE,e as VARIANT,r as PARTS,s as elemId,n as fnClass,u as isNeutral,a as isUnsignedInteger,c as omit,l as debounce,h as throttle,o as UniqueId};const t="base",e=Object.freeze({NEUTRAL:"neutral",ACTIVE:"active",INACTIVE:"inactive"}),r=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"});function n(r,n){const o=i(n)??i(r);return null==o?(t,e)=>{}:"string"==typeof o?(t,e)=>`${o} ${t} ${e}`:(r,n)=>function(r,n,i){const o=r[n]?.[t]??"",s=r[n]?.[i]??r[n]?.[e.NEUTRAL]??"";if(!o&&!s)return;return o&&s?[o,s]:o||s}(o,r,n)}function i(t){if(null==t)return;if("string"==typeof t)return t.trim()?t:void 0;const e=Object.entries(t);return e.length?Object.fromEntries(e.map(([t,e])=>null===e||"object"!=typeof e||Array.isArray(e)?[t,{base:e}]:[t,e])):void 0}class o{static#t=[...Array.from(Array(25).keys(),t=>t+65),...Array.from(Array(25).keys(),t=>t+97)];#e=new Set;#r=3;#n=1e5;get id(){return this.get(!0)}constructor(t=3,e=1e5){t>2&&(this.#r=t),(e=Math.trunc(e))>0&&e<Math.min(Math.pow(50,this.#r),Number.MAX_SAFE_INTEGER)&&(this.#n=e)}get(t){if(t)return this.#e.size>this.#n&&this.#e.clear(),this.#i()}#o(){return o.#t[Math.trunc(Math.random()*o.#t.length)]}#s(){return String.fromCharCode(...Array(this.#r).fill(null).map(()=>this.#o()))}#i(){let t=this.#s();for(;this.#e.has(t);)t=this.#s();return this.#e.add(t),t}}const s=new o;function u(t){return t!==e.ACTIVE&&t!==e.INACTIVE}function a(t){return Number.isInteger(t)&&t>=0}function c(t,...e){if(!t)return{};const r={...t};return e.forEach(t=>delete r[t]),r}function l(t,e){let r;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{e.call(null,...n)},t)}}function h(t,e){let r,n=0;const i=()=>Date.now()-n,o=t=>{e.call(null,...t),n=Date.now()};return(...e)=>{if(!n)return o(e);clearTimeout(r),r=setTimeout(()=>{i()>=t&&o(e)},t-i())}}
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as ColorPicker, type ColorPickerProps, type ColorPickerReqdProp
|
|
|
5
5
|
export { default as ComboBox, type ComboBoxProps, type ComboBoxReqdProps, type ComboBoxBindProps } from "./_svseeds/_ComboBox.svelte";
|
|
6
6
|
export { default as ContextMenu, type ContextMenuProps, type ContextMenuReqdProps, type ContextMenuBindProps } from "./_svseeds/_ContextMenu.svelte";
|
|
7
7
|
export { default as Disclosure, type DisclosureProps, type DisclosureReqdProps, type DisclosureBindProps } from "./_svseeds/_Disclosure.svelte";
|
|
8
|
+
export { default as Drawer, type DrawerProps, type Position, type DrawerReqdProps, type DrawerBindProps } from "./_svseeds/_Drawer.svelte";
|
|
8
9
|
export { default as HotkeyCapture, type HotkeyCaptureProps, type HotkeyCaptureReqdProps, type HotkeyCaptureBindProps } from "./_svseeds/_HotkeyCapture.svelte";
|
|
9
10
|
export { default as Modal, type ModalProps, type ModalReqdProps, type ModalBindProps } from "./_svseeds/_Modal.svelte";
|
|
10
11
|
export { default as ProgressTracker, type ProgressTrackerProps, type ProgressTrackerReqdProps, type ProgressTrackerBindProps } from "./_svseeds/_ProgressTracker.svelte";
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as ColorPicker, getHex } from "./_svseeds/_ColorPicker.svelte";
|
|
|
5
5
|
export { default as ComboBox } from "./_svseeds/_ComboBox.svelte";
|
|
6
6
|
export { default as ContextMenu } from "./_svseeds/_ContextMenu.svelte";
|
|
7
7
|
export { default as Disclosure } from "./_svseeds/_Disclosure.svelte";
|
|
8
|
+
export { default as Drawer } from "./_svseeds/_Drawer.svelte";
|
|
8
9
|
export { default as HotkeyCapture } from "./_svseeds/_HotkeyCapture.svelte";
|
|
9
10
|
export { default as Modal } from "./_svseeds/_Modal.svelte";
|
|
10
11
|
export { default as ProgressTracker } from "./_svseeds/_ProgressTracker.svelte";
|