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