svseeds 0.4.1 → 0.4.3
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 +31 -14
- package/_svseeds/Accordion.svelte.d.ts +20 -4
- package/_svseeds/DarkToggle.svelte +76 -40
- package/_svseeds/DarkToggle.svelte.d.ts +23 -4
- package/_svseeds/TagsInput.svelte +58 -28
- package/_svseeds/TagsInput.svelte.d.ts +34 -6
- package/_svseeds/TagsInputField.svelte +66 -33
- package/_svseeds/TagsInputField.svelte.d.ts +36 -4
- package/_svseeds/ToggleGroupField.svelte +59 -32
- package/_svseeds/ToggleGroupField.svelte.d.ts +30 -4
- package/_svseeds/_Badge.svelte +33 -17
- package/_svseeds/_Badge.svelte.d.ts +17 -2
- package/_svseeds/_Button.svelte +39 -20
- package/_svseeds/_Button.svelte.d.ts +20 -2
- package/_svseeds/_CheckField.svelte +54 -30
- package/_svseeds/_CheckField.svelte.d.ts +24 -2
- package/_svseeds/_ColorPicker.svelte +38 -17
- package/_svseeds/_ColorPicker.svelte.d.ts +21 -2
- package/_svseeds/_ComboBox.svelte +38 -20
- package/_svseeds/_ComboBox.svelte.d.ts +17 -2
- package/_svseeds/_ContextMenu.svelte +26 -12
- package/_svseeds/_ContextMenu.svelte.d.ts +15 -2
- package/_svseeds/_Disclosure.svelte +37 -21
- package/_svseeds/_Disclosure.svelte.d.ts +19 -3
- package/_svseeds/_HotkeyCapture.svelte +28 -13
- package/_svseeds/_HotkeyCapture.svelte.d.ts +16 -2
- package/_svseeds/_Modal.svelte +32 -15
- package/_svseeds/_Modal.svelte.d.ts +18 -3
- package/_svseeds/_ProgressTracker.svelte +31 -16
- package/_svseeds/_ProgressTracker.svelte.d.ts +16 -2
- package/_svseeds/_SelectField.svelte +53 -29
- package/_svseeds/_SelectField.svelte.d.ts +25 -2
- package/_svseeds/_Slider.svelte +43 -22
- package/_svseeds/_Slider.svelte.d.ts +22 -2
- package/_svseeds/_Sortable.svelte +57 -19
- package/_svseeds/_Sortable.svelte.d.ts +39 -2
- package/_svseeds/_Tabs.svelte +31 -17
- package/_svseeds/_Tabs.svelte.d.ts +16 -3
- package/_svseeds/_TextField.svelte +56 -31
- package/_svseeds/_TextField.svelte.d.ts +26 -2
- package/_svseeds/_Toggle.svelte +45 -25
- package/_svseeds/_Toggle.svelte.d.ts +21 -2
- package/_svseeds/_ToggleGroup.svelte +32 -15
- package/_svseeds/_ToggleGroup.svelte.d.ts +18 -2
- package/_svseeds/_Tooltip.svelte +32 -13
- package/_svseeds/_Tooltip.svelte.d.ts +20 -2
- package/_svseeds/core.d.ts +186 -8
- package/_svseeds/core.js +1 -1
- package/index.d.ts +24 -24
- package/index.js +3 -3
- package/package.json +1 -1
package/_svseeds/_Modal.svelte
CHANGED
|
@@ -1,28 +1,44 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ModalProps {
|
|
6
|
+
children: Snippet;
|
|
7
|
+
open?: boolean; // bindable <false>
|
|
8
|
+
closable?: boolean; // <true>
|
|
9
|
+
trigger?: HTMLElement; // bindable
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
12
|
+
style?: SVSStyle;
|
|
13
|
+
element?: HTMLDialogElement; // bindable
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
-->
|
|
1
17
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
children: Snippet
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
status?: string
|
|
9
|
-
style?: SVSStyle
|
|
10
|
-
element?: HTMLDialogElement
|
|
11
|
-
}
|
|
18
|
+
export interface ModalProps {
|
|
19
|
+
children: Snippet;
|
|
20
|
+
open?: boolean; // bindable <false>
|
|
21
|
+
closable?: boolean; // <true>
|
|
22
|
+
trigger?: HTMLElement; // bindable
|
|
23
|
+
ariaLabel?: string;
|
|
24
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
25
|
+
style?: SVSStyle;
|
|
26
|
+
element?: HTMLDialogElement; // bindable
|
|
27
|
+
}
|
|
12
28
|
export type ModalReqdProps = "children";
|
|
13
29
|
export type ModalBindProps = "open" | "status" | "element";
|
|
14
30
|
|
|
15
31
|
const preset = "svs-modal";
|
|
16
32
|
|
|
17
33
|
import { type Snippet, untrack } from "svelte";
|
|
18
|
-
import { type SVSStyle, STATE,
|
|
34
|
+
import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
|
|
19
35
|
</script>
|
|
20
36
|
|
|
21
37
|
<script lang="ts">
|
|
22
|
-
let { children,
|
|
38
|
+
let { children, open = $bindable(false), closable = true, trigger = $bindable(), ariaLabel, status = $bindable(""), style, element = $bindable() }: ModalProps = $props();
|
|
23
39
|
|
|
24
40
|
// *** Initialize *** //
|
|
25
|
-
if (!status) status = STATE.
|
|
41
|
+
if (!status) status = STATE.NEUTRAL;
|
|
26
42
|
const cls = fnClass(preset, style);
|
|
27
43
|
|
|
28
44
|
// *** Bind Handlers *** //
|
|
@@ -48,13 +64,14 @@
|
|
|
48
64
|
function onclose() {
|
|
49
65
|
open = false;
|
|
50
66
|
}
|
|
67
|
+
$effect(() => untrack(() => { if (open) element?.showModal(); }));
|
|
51
68
|
</script>
|
|
52
69
|
|
|
53
70
|
<!---------------------------------------->
|
|
54
71
|
|
|
55
72
|
<!-- svelte-ignore a11y_autofocus -->
|
|
56
|
-
<dialog bind:this={element} class={cls(
|
|
57
|
-
<div class={cls(
|
|
73
|
+
<dialog bind:this={element} class={cls(PARTS.WHOLE, status)} aria-label={ariaLabel} {onclick} {onkeydown} {onclose} autofocus={true}>
|
|
74
|
+
<div class={cls(PARTS.MAIN, status)}>
|
|
58
75
|
{@render children()}
|
|
59
76
|
</div>
|
|
60
77
|
</dialog>
|
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ModalProps {
|
|
2
2
|
children: Snippet;
|
|
3
|
-
label?: string;
|
|
4
3
|
open?: boolean;
|
|
5
4
|
closable?: boolean;
|
|
6
5
|
trigger?: HTMLElement;
|
|
6
|
+
ariaLabel?: string;
|
|
7
7
|
status?: string;
|
|
8
8
|
style?: SVSStyle;
|
|
9
9
|
element?: HTMLDialogElement;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export type ModalReqdProps = "children";
|
|
12
12
|
export type ModalBindProps = "open" | "status" | "element";
|
|
13
13
|
import { type Snippet } from "svelte";
|
|
14
14
|
import { type SVSStyle } from "./core";
|
|
15
|
+
/**
|
|
16
|
+
* default value: `<value>`
|
|
17
|
+
* ```ts
|
|
18
|
+
* interface ModalProps {
|
|
19
|
+
* children: Snippet;
|
|
20
|
+
* open?: boolean; // bindable <false>
|
|
21
|
+
* closable?: boolean; // <true>
|
|
22
|
+
* trigger?: HTMLElement; // bindable
|
|
23
|
+
* ariaLabel?: string;
|
|
24
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
25
|
+
* style?: SVSStyle;
|
|
26
|
+
* element?: HTMLDialogElement; // bindable
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
15
30
|
declare const Modal: import("svelte").Component<ModalProps, {}, "open" | "status" | "element" | "trigger">;
|
|
16
31
|
type Modal = ReturnType<typeof Modal>;
|
|
17
32
|
export default Modal;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ProgressTrackerProps {
|
|
6
|
+
current: number; // bindable <0>
|
|
7
|
+
labels: string[];
|
|
8
|
+
aux?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
9
|
+
extra?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
10
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
11
|
+
eachStatus?: SvelteMap<number, string> | Map<number, string>;
|
|
12
|
+
style?: SVSStyle;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
-->
|
|
1
16
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
current: number
|
|
4
|
-
labels: string[]
|
|
5
|
-
aux?: Snippet<[string, number]
|
|
6
|
-
extra?: Snippet<[string, number]
|
|
7
|
-
status?: string
|
|
8
|
-
eachStatus?: SvelteMap<number, string> | Map<number, string
|
|
9
|
-
style?: SVSStyle
|
|
10
|
-
}
|
|
17
|
+
export interface ProgressTrackerProps {
|
|
18
|
+
current: number; // bindable <0>
|
|
19
|
+
labels: string[];
|
|
20
|
+
aux?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
21
|
+
extra?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
22
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
23
|
+
eachStatus?: SvelteMap<number, string> | Map<number, string>;
|
|
24
|
+
style?: SVSStyle;
|
|
25
|
+
}
|
|
11
26
|
export type ProgressTrackerReqdProps = "current" | "labels";
|
|
12
27
|
export type ProgressTrackerBindProps = "current" | "status";
|
|
13
28
|
|
|
@@ -15,14 +30,14 @@
|
|
|
15
30
|
|
|
16
31
|
import { type Snippet } from "svelte";
|
|
17
32
|
import { type SvelteMap } from "svelte/reactivity";
|
|
18
|
-
import { type SVSStyle, STATE,
|
|
33
|
+
import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
|
|
19
34
|
</script>
|
|
20
35
|
|
|
21
36
|
<script lang="ts">
|
|
22
37
|
let { current = $bindable(0), labels, aux, extra, status = $bindable(""), eachStatus, style }: ProgressTrackerProps = $props();
|
|
23
38
|
|
|
24
39
|
// *** Initialize *** //
|
|
25
|
-
if (!status) status = STATE.
|
|
40
|
+
if (!status) status = STATE.NEUTRAL;
|
|
26
41
|
const cls = fnClass(preset, style);
|
|
27
42
|
|
|
28
43
|
// *** Status *** //
|
|
@@ -37,19 +52,19 @@
|
|
|
37
52
|
<!---------------------------------------->
|
|
38
53
|
|
|
39
54
|
{#if labels.length}
|
|
40
|
-
<ol class={cls(
|
|
55
|
+
<ol class={cls(PARTS.WHOLE, status)}>
|
|
41
56
|
{#each labels as label, i}
|
|
42
57
|
{@const stat = getEachStatus(i)}
|
|
43
58
|
{#if i > current}
|
|
44
59
|
{@render separator(i)}
|
|
45
60
|
{/if}
|
|
46
|
-
<li class={cls(
|
|
61
|
+
<li class={cls(PARTS.MAIN, stat)} aria-current={i === current ? "step" : false}>
|
|
47
62
|
{#if aux}
|
|
48
|
-
<div class={cls(
|
|
63
|
+
<div class={cls(PARTS.AUX, stat)}>
|
|
49
64
|
{@render aux(stat, i)}
|
|
50
65
|
</div>
|
|
51
66
|
{/if}
|
|
52
|
-
<div class={cls(
|
|
67
|
+
<div class={cls(PARTS.LABEL, stat)}>
|
|
53
68
|
{label}
|
|
54
69
|
</div>
|
|
55
70
|
</li>
|
|
@@ -63,7 +78,7 @@
|
|
|
63
78
|
{#snippet separator(i: number)}
|
|
64
79
|
{#if extra}
|
|
65
80
|
{@const stat = i < current ? STATE.ACTIVE : STATE.INACTIVE}
|
|
66
|
-
<li class={cls(
|
|
81
|
+
<li class={cls(PARTS.EXTRA, stat)} role="separator">
|
|
67
82
|
{@render extra(stat, i)}
|
|
68
83
|
</li>
|
|
69
84
|
{/if}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ProgressTrackerProps {
|
|
2
2
|
current: number;
|
|
3
3
|
labels: string[];
|
|
4
4
|
aux?: Snippet<[string, number]>;
|
|
@@ -6,12 +6,26 @@ export type ProgressTrackerProps = {
|
|
|
6
6
|
status?: string;
|
|
7
7
|
eachStatus?: SvelteMap<number, string> | Map<number, string>;
|
|
8
8
|
style?: SVSStyle;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
export type ProgressTrackerReqdProps = "current" | "labels";
|
|
11
11
|
export type ProgressTrackerBindProps = "current" | "status";
|
|
12
12
|
import { type Snippet } from "svelte";
|
|
13
13
|
import { type SvelteMap } from "svelte/reactivity";
|
|
14
14
|
import { type SVSStyle } from "./core";
|
|
15
|
+
/**
|
|
16
|
+
* default value: `<value>`
|
|
17
|
+
* ```ts
|
|
18
|
+
* interface ProgressTrackerProps {
|
|
19
|
+
* current: number; // bindable <0>
|
|
20
|
+
* labels: string[];
|
|
21
|
+
* aux?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
22
|
+
* extra?: Snippet<[string, number]>; // Snippet<[status,index]>
|
|
23
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
24
|
+
* eachStatus?: SvelteMap<number, string> | Map<number, string>;
|
|
25
|
+
* style?: SVSStyle;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
15
29
|
declare const ProgressTracker: import("svelte").Component<ProgressTrackerProps, {}, "status" | "current">;
|
|
16
30
|
type ProgressTracker = ReturnType<typeof ProgressTracker>;
|
|
17
31
|
export default ProgressTracker;
|
|
@@ -1,21 +1,45 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface SelectFieldProps {
|
|
6
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
7
|
+
label?: string;
|
|
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]>
|
|
12
|
+
bottom?: string;
|
|
13
|
+
descFirst?: boolean; // <false>
|
|
14
|
+
value?: string; // bindable
|
|
15
|
+
validations?: SelectFieldValidation[];
|
|
16
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
17
|
+
style?: SVSStyle;
|
|
18
|
+
attributes?: HTMLSelectAttributes;
|
|
19
|
+
action?: Action;
|
|
20
|
+
element?: HTMLSelectElement; // bindable
|
|
21
|
+
}
|
|
22
|
+
type SelectFieldValidation = (value: string, validity: ValidityState) => string;
|
|
23
|
+
```
|
|
24
|
+
-->
|
|
1
25
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
options: SvelteMap<string, string> | Map<string, string
|
|
4
|
-
label?: string
|
|
5
|
-
extra?: string
|
|
6
|
-
aux?: Snippet<[string, string, HTMLSelectElement | undefined]
|
|
7
|
-
left?: Snippet<[string, string, HTMLSelectElement | undefined]
|
|
8
|
-
right?: Snippet<[string, string, HTMLSelectElement | undefined]
|
|
9
|
-
bottom?: string
|
|
10
|
-
descFirst?: boolean
|
|
11
|
-
value?: string
|
|
12
|
-
validations?: SelectFieldValidation[]
|
|
13
|
-
status?: string
|
|
14
|
-
style?: SVSStyle
|
|
26
|
+
export interface SelectFieldProps {
|
|
27
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
28
|
+
label?: string;
|
|
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]>
|
|
33
|
+
bottom?: string;
|
|
34
|
+
descFirst?: boolean; // <false>
|
|
35
|
+
value?: string; // bindable
|
|
36
|
+
validations?: SelectFieldValidation[];
|
|
37
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
38
|
+
style?: SVSStyle;
|
|
15
39
|
attributes?: HTMLSelectAttributes;
|
|
16
|
-
action?: Action
|
|
17
|
-
element?: HTMLSelectElement
|
|
18
|
-
}
|
|
40
|
+
action?: Action;
|
|
41
|
+
element?: HTMLSelectElement; // bindable
|
|
42
|
+
}
|
|
19
43
|
export type SelectFieldReqdProps = "options";
|
|
20
44
|
export type SelectFieldBindProps = "value" | "status" | "element";
|
|
21
45
|
export type SelectFieldValidation = (value: string, validity: ValidityState) => string;
|
|
@@ -26,14 +50,14 @@
|
|
|
26
50
|
import { type Action } from "svelte/action";
|
|
27
51
|
import { type SvelteMap } from "svelte/reactivity";
|
|
28
52
|
import { type HTMLSelectAttributes } from "svelte/elements";
|
|
29
|
-
import { type SVSStyle, STATE,
|
|
53
|
+
import { type SVSStyle, STATE, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
30
54
|
</script>
|
|
31
55
|
|
|
32
56
|
<script lang="ts">
|
|
33
57
|
let { options, label, extra, aux, left, right, bottom, descFirst = false, value = $bindable(""), validations = [], status = $bindable(""), style, attributes, action, element = $bindable() }: SelectFieldProps = $props();
|
|
34
58
|
|
|
35
59
|
// *** Initialize *** //
|
|
36
|
-
if (!status) status = STATE.
|
|
60
|
+
if (!status) status = STATE.NEUTRAL;
|
|
37
61
|
const cls = fnClass(preset, style);
|
|
38
62
|
const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
|
|
39
63
|
const idLabel = elemId.get(label?.trim());
|
|
@@ -43,7 +67,7 @@
|
|
|
43
67
|
let message = $state(bottom);
|
|
44
68
|
|
|
45
69
|
// *** Status *** //
|
|
46
|
-
let neutral = isNeutral(status) ? status : STATE.
|
|
70
|
+
let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
|
|
47
71
|
$effect(() => { neutral = isNeutral(status) ? status : neutral; });
|
|
48
72
|
let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
|
|
49
73
|
let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
|
|
@@ -85,20 +109,20 @@
|
|
|
85
109
|
<!---------------------------------------->
|
|
86
110
|
|
|
87
111
|
{#if opts.length}
|
|
88
|
-
<div class={cls(
|
|
112
|
+
<div class={cls(PARTS.WHOLE, status)} role="group" aria-labelledby={idLabel}>
|
|
89
113
|
{#if aux}
|
|
90
|
-
<div class={cls(
|
|
114
|
+
<div class={cls(PARTS.TOP, status)}>
|
|
91
115
|
{@render lbl()}
|
|
92
|
-
<span class={cls(
|
|
116
|
+
<span class={cls(PARTS.AUX, status)}>{@render aux(status, value, element)}</span>
|
|
93
117
|
</div>
|
|
94
118
|
{:else}
|
|
95
119
|
{@render lbl()}
|
|
96
120
|
{/if}
|
|
97
121
|
{@render desc(descFirst)}
|
|
98
|
-
<div class={cls(
|
|
99
|
-
{@render side(
|
|
122
|
+
<div class={cls(PARTS.MIDDLE, status)}>
|
|
123
|
+
{@render side(PARTS.LEFT, left)}
|
|
100
124
|
{@render main()}
|
|
101
|
-
{@render side(
|
|
125
|
+
{@render side(PARTS.RIGHT, right)}
|
|
102
126
|
</div>
|
|
103
127
|
{@render desc(!descFirst)}
|
|
104
128
|
</div>
|
|
@@ -106,10 +130,10 @@
|
|
|
106
130
|
|
|
107
131
|
{#snippet lbl()}
|
|
108
132
|
{#if label?.trim()}
|
|
109
|
-
<span class={cls(
|
|
133
|
+
<span class={cls(PARTS.LABEL, status)} id={idLabel}>
|
|
110
134
|
{label}
|
|
111
135
|
{#if extra?.trim()}
|
|
112
|
-
<span class={cls(
|
|
136
|
+
<span class={cls(PARTS.EXTRA, status)}>{extra}</span>
|
|
113
137
|
{/if}
|
|
114
138
|
</span>
|
|
115
139
|
{/if}
|
|
@@ -120,7 +144,7 @@
|
|
|
120
144
|
{/if}
|
|
121
145
|
{/snippet}
|
|
122
146
|
{#snippet main()}
|
|
123
|
-
{@const c = cls(
|
|
147
|
+
{@const c = cls(PARTS.MAIN, status)}
|
|
124
148
|
{#if action}
|
|
125
149
|
<select bind:value bind:this={element} class={c} {id} {oninvalid} {...attrs} aria-describedby={idDesc} aria-invalid={invalid} aria-errormessage={idMsg} use:action>
|
|
126
150
|
{@render option()}
|
|
@@ -138,6 +162,6 @@
|
|
|
138
162
|
{/snippet}
|
|
139
163
|
{#snippet desc(show: boolean)}
|
|
140
164
|
{#if show && message?.trim()}
|
|
141
|
-
<div class={cls(
|
|
165
|
+
<div class={cls(PARTS.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
142
166
|
{/if}
|
|
143
167
|
{/snippet}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface SelectFieldProps {
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
3
|
label?: string;
|
|
4
4
|
extra?: string;
|
|
@@ -14,7 +14,7 @@ export type SelectFieldProps = {
|
|
|
14
14
|
attributes?: HTMLSelectAttributes;
|
|
15
15
|
action?: Action;
|
|
16
16
|
element?: HTMLSelectElement;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
export type SelectFieldReqdProps = "options";
|
|
19
19
|
export type SelectFieldBindProps = "value" | "status" | "element";
|
|
20
20
|
export type SelectFieldValidation = (value: string, validity: ValidityState) => string;
|
|
@@ -23,6 +23,29 @@ import { type Action } from "svelte/action";
|
|
|
23
23
|
import { type SvelteMap } from "svelte/reactivity";
|
|
24
24
|
import { type HTMLSelectAttributes } from "svelte/elements";
|
|
25
25
|
import { type SVSStyle } from "./core";
|
|
26
|
+
/**
|
|
27
|
+
* default value: `<value>`
|
|
28
|
+
* ```ts
|
|
29
|
+
* interface SelectFieldProps {
|
|
30
|
+
* options: SvelteMap<string, string> | Map<string, string>;
|
|
31
|
+
* label?: string;
|
|
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]>
|
|
36
|
+
* bottom?: string;
|
|
37
|
+
* descFirst?: boolean; // <false>
|
|
38
|
+
* value?: string; // bindable
|
|
39
|
+
* validations?: SelectFieldValidation[];
|
|
40
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
41
|
+
* style?: SVSStyle;
|
|
42
|
+
* attributes?: HTMLSelectAttributes;
|
|
43
|
+
* action?: Action;
|
|
44
|
+
* element?: HTMLSelectElement; // bindable
|
|
45
|
+
* }
|
|
46
|
+
* type SelectFieldValidation = (value: string, validity: ValidityState) => string;
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
26
49
|
declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "value" | "status" | "element">;
|
|
27
50
|
type SelectField = ReturnType<typeof SelectField>;
|
|
28
51
|
export default SelectField;
|
package/_svseeds/_Slider.svelte
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface SliderProps {
|
|
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]>
|
|
9
|
+
value?: number; // bindable <min+((max-min)/2)>
|
|
10
|
+
step?: number | "any"; // <1>
|
|
11
|
+
options?: SvelteSet<number> | Set<number>;
|
|
12
|
+
background?: Range; // <{ min: 5, max: 95 }>
|
|
13
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
14
|
+
style?: SVSStyle;
|
|
15
|
+
attributes?: HTMLInputAttributes;
|
|
16
|
+
action?: Action;
|
|
17
|
+
element?: HTMLInputElement; // bindable
|
|
18
|
+
}
|
|
19
|
+
type Range = { min: number, max: number };
|
|
20
|
+
```
|
|
21
|
+
-->
|
|
1
22
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
range: Range
|
|
4
|
-
left?: Snippet<[string, number, HTMLInputElement | undefined]
|
|
5
|
-
right?: Snippet<[string, number, HTMLInputElement | undefined]
|
|
6
|
-
value?: number
|
|
7
|
-
step?: number | "any"
|
|
8
|
-
options?: SvelteSet<number> | Set<number
|
|
9
|
-
background?: Range
|
|
10
|
-
status?: string
|
|
11
|
-
style?: SVSStyle
|
|
12
|
-
attributes?: HTMLInputAttributes
|
|
13
|
-
action?: Action
|
|
14
|
-
element?: HTMLInputElement
|
|
15
|
-
}
|
|
23
|
+
export interface SliderProps {
|
|
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]>
|
|
27
|
+
value?: number; // bindable <min+((max-min)/2)>
|
|
28
|
+
step?: number | "any"; // <1>
|
|
29
|
+
options?: SvelteSet<number> | Set<number>;
|
|
30
|
+
background?: Range; // <{ min: 5, max: 95 }>
|
|
31
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
32
|
+
style?: SVSStyle;
|
|
33
|
+
attributes?: HTMLInputAttributes;
|
|
34
|
+
action?: Action;
|
|
35
|
+
element?: HTMLInputElement; // bindable
|
|
36
|
+
}
|
|
16
37
|
export type SliderReqdProps = "min" | "max";
|
|
17
38
|
export type SliderBindProps = "min" | "max" | "value" | "status" | "element";
|
|
18
39
|
export type Range = { min: number, max: number };
|
|
@@ -23,14 +44,14 @@
|
|
|
23
44
|
import { type Action } from "svelte/action";
|
|
24
45
|
import { type SvelteSet } from "svelte/reactivity";
|
|
25
46
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
26
|
-
import { type SVSStyle, STATE,
|
|
47
|
+
import { type SVSStyle, STATE, PARTS, elemId, fnClass, omit } from "./core";
|
|
27
48
|
</script>
|
|
28
49
|
|
|
29
50
|
<script lang="ts">
|
|
30
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();
|
|
31
52
|
|
|
32
53
|
// *** Initialize *** //
|
|
33
|
-
if (!status) status = STATE.
|
|
54
|
+
if (!status) status = STATE.NEUTRAL;
|
|
34
55
|
const cls = fnClass(preset, style);
|
|
35
56
|
const idList = elemId.get(options?.size);
|
|
36
57
|
const attrs = omit(attributes, "class", "type", "value", "min", "max", "step", "list");
|
|
@@ -39,17 +60,17 @@
|
|
|
39
60
|
|
|
40
61
|
// *** Bind Handlers *** //
|
|
41
62
|
let rate = $derived(Math.trunc(background.min + ((value - range.min) / (range.max - range.min)) * (background.max - background.min)));
|
|
42
|
-
let dynStyle = $derived(`background:linear-gradient(to right, var(--color-active) ${rate}%, var(--color-inactive) ${rate}%);`);
|
|
63
|
+
let dynStyle = $derived(`background: linear-gradient(to right, var(--color-active) ${rate}%, var(--color-inactive) ${rate}%);`);
|
|
43
64
|
</script>
|
|
44
65
|
|
|
45
66
|
<!---------------------------------------->
|
|
46
67
|
|
|
47
|
-
<span class={cls(
|
|
48
|
-
{@render side(
|
|
68
|
+
<span class={cls(PARTS.WHOLE, status)}>
|
|
69
|
+
{@render side(PARTS.LEFT, left)}
|
|
49
70
|
{#if action}
|
|
50
|
-
<input bind:value bind:this={element} class={cls(
|
|
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 />
|
|
51
72
|
{:else}
|
|
52
|
-
<input bind:value bind:this={element} class={cls(
|
|
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} />
|
|
53
74
|
{/if}
|
|
54
75
|
{#if options?.size}
|
|
55
76
|
<datalist id={idList}>
|
|
@@ -58,7 +79,7 @@
|
|
|
58
79
|
{/each}
|
|
59
80
|
</datalist>
|
|
60
81
|
{/if}
|
|
61
|
-
{@render side(
|
|
82
|
+
{@render side(PARTS.RIGHT, right)}
|
|
62
83
|
</span>
|
|
63
84
|
|
|
64
85
|
{#snippet side(area: string, body?: Snippet<[string, number, HTMLInputElement | undefined]>)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface SliderProps {
|
|
2
2
|
range: Range;
|
|
3
3
|
left?: Snippet<[string, number, HTMLInputElement | undefined]>;
|
|
4
4
|
right?: Snippet<[string, number, HTMLInputElement | undefined]>;
|
|
@@ -11,7 +11,7 @@ export type SliderProps = {
|
|
|
11
11
|
attributes?: HTMLInputAttributes;
|
|
12
12
|
action?: Action;
|
|
13
13
|
element?: HTMLInputElement;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
export type SliderReqdProps = "min" | "max";
|
|
16
16
|
export type SliderBindProps = "min" | "max" | "value" | "status" | "element";
|
|
17
17
|
export type Range = {
|
|
@@ -23,6 +23,26 @@ import { type Action } from "svelte/action";
|
|
|
23
23
|
import { type SvelteSet } from "svelte/reactivity";
|
|
24
24
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
25
25
|
import { type SVSStyle } from "./core";
|
|
26
|
+
/**
|
|
27
|
+
* default value: `<value>`
|
|
28
|
+
* ```ts
|
|
29
|
+
* interface SliderProps {
|
|
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]>
|
|
33
|
+
* value?: number; // bindable <min+((max-min)/2)>
|
|
34
|
+
* step?: number | "any"; // <1>
|
|
35
|
+
* options?: SvelteSet<number> | Set<number>;
|
|
36
|
+
* background?: Range; // <{ min: 5, max: 95 }>
|
|
37
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
38
|
+
* style?: SVSStyle;
|
|
39
|
+
* attributes?: HTMLInputAttributes;
|
|
40
|
+
* action?: Action;
|
|
41
|
+
* element?: HTMLInputElement; // bindable
|
|
42
|
+
* }
|
|
43
|
+
* type Range = { min: number, max: number };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
26
46
|
declare const Slider: import("svelte").Component<SliderProps, {}, "value" | "status" | "range" | "element">;
|
|
27
47
|
type Slider = ReturnType<typeof Slider>;
|
|
28
48
|
export default Slider;
|