svseeds 0.4.1 → 0.4.4
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 +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface TagsInputFieldProps {
|
|
2
2
|
label?: string;
|
|
3
3
|
extra?: string;
|
|
4
4
|
aux?: Snippet<[string, string[], HTMLInputElement | undefined]>;
|
|
@@ -15,10 +15,10 @@ export type TagsInputFieldProps = {
|
|
|
15
15
|
style?: SVSStyle;
|
|
16
16
|
element?: HTMLInputElement;
|
|
17
17
|
deps?: TagsInputFieldDeps;
|
|
18
|
-
}
|
|
19
|
-
export
|
|
18
|
+
}
|
|
19
|
+
export interface TagsInputFieldDeps extends TagsInputDeps {
|
|
20
20
|
svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps | "deps">;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
export type TagsInputFieldReqdProps = never;
|
|
23
23
|
export type TagsInputFieldBindProps = "values" | "status" | "element";
|
|
24
24
|
export type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string;
|
|
@@ -30,6 +30,38 @@ export type TagsInputFieldCountValidation = {
|
|
|
30
30
|
import { type Snippet } from "svelte";
|
|
31
31
|
import { type SVSStyle } from "./core";
|
|
32
32
|
import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps, type TagsInputDeps } from "./TagsInput.svelte";
|
|
33
|
+
/**
|
|
34
|
+
* default value: `<value>`
|
|
35
|
+
* ```ts
|
|
36
|
+
* interface TagsInputFieldProps {
|
|
37
|
+
* label?: string;
|
|
38
|
+
* extra?: string;
|
|
39
|
+
* aux?: Snippet<[string, string[], HTMLInputElement | undefined]>; // Snippet<[status,values,element]>
|
|
40
|
+
* left?: Snippet<[string, string[], HTMLInputElement | undefined]>; // Snippet<[status,values,element]>
|
|
41
|
+
* right?: Snippet<[string, string[], HTMLInputElement | undefined]>; // Snippet<[status,values,element]>
|
|
42
|
+
* bottom?: string;
|
|
43
|
+
* descFirst?: boolean; // <false>
|
|
44
|
+
* values?: string[]; // bindable
|
|
45
|
+
* min?: TagsInputFieldCountValidation;
|
|
46
|
+
* max?: TagsInputFieldCountValidation;
|
|
47
|
+
* constraints?: TagsInputFieldConstraint[];
|
|
48
|
+
* validations?: TagsInputFieldValidation[];
|
|
49
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
50
|
+
* style?: SVSStyle;
|
|
51
|
+
* element?: HTMLInputElement; // bindable
|
|
52
|
+
* deps?: TagsInputFieldDeps;
|
|
53
|
+
* }
|
|
54
|
+
* interface TagsInputFieldDeps extends TagsInputDeps {
|
|
55
|
+
* svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps | "deps">;
|
|
56
|
+
* }
|
|
57
|
+
* type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string;
|
|
58
|
+
* type TagsInputFieldValidation = (values: string[], validity: ValidityState) => string;
|
|
59
|
+
* type TagsInputFieldCountValidation = {
|
|
60
|
+
* value: number;
|
|
61
|
+
* message: string;
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
33
65
|
declare const TagsInputField: import("svelte").Component<TagsInputFieldProps, {}, "status" | "element" | "values">;
|
|
34
66
|
type TagsInputField = ReturnType<typeof TagsInputField>;
|
|
35
67
|
export default TagsInputField;
|
|
@@ -1,24 +1,51 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ToggleGroupFieldProps {
|
|
6
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
7
|
+
label?: string;
|
|
8
|
+
extra?: string;
|
|
9
|
+
aux?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
10
|
+
left?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
11
|
+
right?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
12
|
+
bottom?: string;
|
|
13
|
+
descFirst?: boolean; // <false>
|
|
14
|
+
values?: string[]; // bindable
|
|
15
|
+
multiple?: boolean; // <true>
|
|
16
|
+
validations?: ToggleGroupFieldValidation[];
|
|
17
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
18
|
+
style?: SVSStyle;
|
|
19
|
+
deps?: ToggleGroupFieldDeps;
|
|
20
|
+
[key: string]: unknown | Snippet;
|
|
21
|
+
}
|
|
22
|
+
interface ToggleGroupFieldDeps {
|
|
23
|
+
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
24
|
+
}
|
|
25
|
+
type ToggleGroupFieldValidation = (values: string[]) => string;
|
|
26
|
+
```
|
|
27
|
+
-->
|
|
1
28
|
<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[]]
|
|
7
|
-
left?: Snippet<[string, string[]]
|
|
8
|
-
right?: Snippet<[string, string[]]
|
|
9
|
-
bottom?: string
|
|
10
|
-
descFirst?: boolean
|
|
11
|
-
values?: string[]
|
|
12
|
-
multiple?: boolean
|
|
13
|
-
validations?: ToggleGroupFieldValidation[]
|
|
14
|
-
status?: string
|
|
15
|
-
style?: SVSStyle
|
|
16
|
-
deps?: ToggleGroupFieldDeps
|
|
17
|
-
[key: string]: unknown | Snippet
|
|
18
|
-
}
|
|
19
|
-
export
|
|
20
|
-
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple"
|
|
21
|
-
}
|
|
29
|
+
export interface ToggleGroupFieldProps {
|
|
30
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
31
|
+
label?: string;
|
|
32
|
+
extra?: string;
|
|
33
|
+
aux?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
34
|
+
left?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
35
|
+
right?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
36
|
+
bottom?: string;
|
|
37
|
+
descFirst?: boolean; // <false>
|
|
38
|
+
values?: string[]; // bindable
|
|
39
|
+
multiple?: boolean; // <true>
|
|
40
|
+
validations?: ToggleGroupFieldValidation[];
|
|
41
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
42
|
+
style?: SVSStyle;
|
|
43
|
+
deps?: ToggleGroupFieldDeps;
|
|
44
|
+
[key: string]: unknown | Snippet;
|
|
45
|
+
}
|
|
46
|
+
export interface ToggleGroupFieldDeps {
|
|
47
|
+
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
48
|
+
}
|
|
22
49
|
export type ToggleGroupFieldReqdProps = "options";
|
|
23
50
|
export type ToggleGroupFieldBindProps = "values" | "status";
|
|
24
51
|
export type ToggleGroupFieldValidation = (values: string[]) => string;
|
|
@@ -28,7 +55,7 @@
|
|
|
28
55
|
import { type Snippet, untrack } from "svelte";
|
|
29
56
|
import { type Action } from "svelte/action";
|
|
30
57
|
import { type SvelteMap } from "svelte/reactivity";
|
|
31
|
-
import { type SVSStyle, STATE,
|
|
58
|
+
import { type SVSStyle, STATE, PARTS, elemId, fnClass, isNeutral } from "./core";
|
|
32
59
|
import ToggleGroup, { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_ToggleGroup.svelte";
|
|
33
60
|
</script>
|
|
34
61
|
|
|
@@ -36,7 +63,7 @@
|
|
|
36
63
|
let { options, label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), multiple = true, validations = [], status = $bindable(""), style, attributes, elements = $bindable([]), deps, ...rest }: ToggleGroupFieldProps = $props();
|
|
37
64
|
|
|
38
65
|
// *** Initialize *** //
|
|
39
|
-
if (!status) status = STATE.
|
|
66
|
+
if (!status) status = STATE.NEUTRAL;
|
|
40
67
|
const cls = fnClass(preset, style);
|
|
41
68
|
const idLabel = elemId.get(label?.trim());
|
|
42
69
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -53,7 +80,7 @@
|
|
|
53
80
|
};
|
|
54
81
|
|
|
55
82
|
// *** Status *** //
|
|
56
|
-
let neutral = $state(isNeutral(status) ? status : STATE.
|
|
83
|
+
let neutral = $state(isNeutral(status) ? status : STATE.NEUTRAL);
|
|
57
84
|
$effect(() => { neutral = isNeutral(status) ? status : neutral });
|
|
58
85
|
let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
|
|
59
86
|
let idMsg = $derived(status === STATE.INACTIVE && message?.trim() ? idErr : undefined);
|
|
@@ -92,21 +119,21 @@
|
|
|
92
119
|
<!---------------------------------------->
|
|
93
120
|
|
|
94
121
|
{#if options.size}
|
|
95
|
-
<div class={cls(
|
|
122
|
+
<div class={cls(PARTS.WHOLE, status)} role="group" aria-labelledby={idLabel}>
|
|
96
123
|
{#if aux}
|
|
97
|
-
<div class={cls(
|
|
124
|
+
<div class={cls(PARTS.TOP, status)}>
|
|
98
125
|
{@render lbl()}
|
|
99
|
-
<span class={cls(
|
|
126
|
+
<span class={cls(PARTS.AUX, status)}>{@render aux(status, values)}</span>
|
|
100
127
|
</div>
|
|
101
128
|
{:else}
|
|
102
129
|
{@render lbl()}
|
|
103
130
|
{/if}
|
|
104
131
|
{@render desc(descFirst)}
|
|
105
|
-
<div class={cls(
|
|
106
|
-
{@render side(
|
|
132
|
+
<div class={cls(PARTS.MIDDLE, status)}>
|
|
133
|
+
{@render side(PARTS.LEFT, left)}
|
|
107
134
|
<input bind:this={element} style="display: none;" aria-hidden="true" {oninvalid} />
|
|
108
135
|
<ToggleGroup bind:values bind:ariaErrMsgId={idMsg} bind:status={neutral} {options} {multiple} {...svsToggleGroup} />
|
|
109
|
-
{@render side(
|
|
136
|
+
{@render side(PARTS.RIGHT, right)}
|
|
110
137
|
</div>
|
|
111
138
|
{@render desc(!descFirst)}
|
|
112
139
|
</div>
|
|
@@ -114,10 +141,10 @@
|
|
|
114
141
|
|
|
115
142
|
{#snippet lbl()}
|
|
116
143
|
{#if label?.trim()}
|
|
117
|
-
<span class={cls(
|
|
144
|
+
<span class={cls(PARTS.LABEL, status)} id={idLabel}>
|
|
118
145
|
{label}
|
|
119
146
|
{#if extra?.trim()}
|
|
120
|
-
<span class={cls(
|
|
147
|
+
<span class={cls(PARTS.EXTRA, status)}>{extra}</span>
|
|
121
148
|
{/if}
|
|
122
149
|
</span>
|
|
123
150
|
{/if}
|
|
@@ -129,6 +156,6 @@
|
|
|
129
156
|
{/snippet}
|
|
130
157
|
{#snippet desc(show: boolean)}
|
|
131
158
|
{#if show && message?.trim()}
|
|
132
|
-
<div class={cls(
|
|
159
|
+
<div class={cls(PARTS.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
133
160
|
{/if}
|
|
134
161
|
{/snippet}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ToggleGroupFieldProps {
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
3
|
label?: string;
|
|
4
4
|
extra?: string;
|
|
@@ -14,10 +14,10 @@ export type ToggleGroupFieldProps = {
|
|
|
14
14
|
style?: SVSStyle;
|
|
15
15
|
deps?: ToggleGroupFieldDeps;
|
|
16
16
|
[key: string]: unknown | Snippet;
|
|
17
|
-
}
|
|
18
|
-
export
|
|
17
|
+
}
|
|
18
|
+
export interface ToggleGroupFieldDeps {
|
|
19
19
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
export type ToggleGroupFieldReqdProps = "options";
|
|
22
22
|
export type ToggleGroupFieldBindProps = "values" | "status";
|
|
23
23
|
export type ToggleGroupFieldValidation = (values: string[]) => string;
|
|
@@ -25,6 +25,32 @@ import { type Snippet } from "svelte";
|
|
|
25
25
|
import { type SvelteMap } from "svelte/reactivity";
|
|
26
26
|
import { type SVSStyle } from "./core";
|
|
27
27
|
import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_ToggleGroup.svelte";
|
|
28
|
+
/**
|
|
29
|
+
* default value: `<value>`
|
|
30
|
+
* ```ts
|
|
31
|
+
* interface ToggleGroupFieldProps {
|
|
32
|
+
* options: SvelteMap<string, string> | Map<string, string>;
|
|
33
|
+
* label?: string;
|
|
34
|
+
* extra?: string;
|
|
35
|
+
* aux?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
36
|
+
* left?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
37
|
+
* right?: Snippet<[string, string[]]>; // Snippet<[status,values]>
|
|
38
|
+
* bottom?: string;
|
|
39
|
+
* descFirst?: boolean; // <false>
|
|
40
|
+
* values?: string[]; // bindable
|
|
41
|
+
* multiple?: boolean; // <true>
|
|
42
|
+
* validations?: ToggleGroupFieldValidation[];
|
|
43
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
44
|
+
* style?: SVSStyle;
|
|
45
|
+
* deps?: ToggleGroupFieldDeps;
|
|
46
|
+
* [key: string]: unknown | Snippet;
|
|
47
|
+
* }
|
|
48
|
+
* interface ToggleGroupFieldDeps {
|
|
49
|
+
* svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
50
|
+
* }
|
|
51
|
+
* type ToggleGroupFieldValidation = (values: string[]) => string;
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
28
54
|
declare const ToggleGroupField: import("svelte").Component<ToggleGroupFieldProps, {}, "elements" | "status" | "values">;
|
|
29
55
|
type ToggleGroupField = ReturnType<typeof ToggleGroupField>;
|
|
30
56
|
export default ToggleGroupField;
|
package/_svseeds/_Badge.svelte
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface BadgeProps {
|
|
6
|
+
children: Snippet;
|
|
7
|
+
left?: Snippet<[string]>; // Snippet<[status]>
|
|
8
|
+
right?: Snippet<[string]>; // Snippet<[status]>
|
|
9
|
+
type?: "plain" | "link" | "left" | "right"; // <"plain">
|
|
10
|
+
href?: string;
|
|
11
|
+
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
12
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
13
|
+
style?: SVSStyle;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
-->
|
|
1
17
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
children: Snippet
|
|
4
|
-
left?: Snippet<[string]
|
|
5
|
-
right?: Snippet<[string]
|
|
6
|
-
type?: "plain" | "link" | "left" | "right"
|
|
7
|
-
href?: string
|
|
8
|
-
onclick?: MouseEventHandler<HTMLButtonElement> | null
|
|
9
|
-
status?: string
|
|
10
|
-
style?: SVSStyle
|
|
11
|
-
}
|
|
18
|
+
export interface BadgeProps {
|
|
19
|
+
children: Snippet;
|
|
20
|
+
left?: Snippet<[string]>; // Snippet<[status]>
|
|
21
|
+
right?: Snippet<[string]>; // Snippet<[status]>
|
|
22
|
+
type?: "plain" | "link" | "left" | "right"; // <"plain">
|
|
23
|
+
href?: string;
|
|
24
|
+
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
25
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
26
|
+
style?: SVSStyle;
|
|
27
|
+
}
|
|
12
28
|
export type BadgeReqdProps = "children";
|
|
13
29
|
export type BadgeBindProps = "status";
|
|
14
30
|
|
|
@@ -16,25 +32,25 @@
|
|
|
16
32
|
|
|
17
33
|
import { type Snippet } from "svelte";
|
|
18
34
|
import { type MouseEventHandler } from "svelte/elements";
|
|
19
|
-
import { type SVSStyle, STATE,
|
|
35
|
+
import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
|
|
20
36
|
</script>
|
|
21
37
|
|
|
22
38
|
<script lang="ts">
|
|
23
39
|
let { children, left, right, type = "plain", href = "", onclick, status = $bindable(""), style }: BadgeProps = $props();
|
|
24
40
|
|
|
25
41
|
// *** Initialize *** //
|
|
26
|
-
if (!status) status = STATE.
|
|
42
|
+
if (!status) status = STATE.NEUTRAL;
|
|
27
43
|
const cls = fnClass(preset, style);
|
|
28
44
|
</script>
|
|
29
45
|
|
|
30
46
|
<!---------------------------------------->
|
|
31
47
|
|
|
32
48
|
{#if type === "link"}
|
|
33
|
-
<a class={cls(
|
|
49
|
+
<a class={cls(PARTS.WHOLE, status)} {href}>
|
|
34
50
|
{@render whole()}
|
|
35
51
|
</a>
|
|
36
52
|
{:else}
|
|
37
|
-
<span class={cls(
|
|
53
|
+
<span class={cls(PARTS.WHOLE, status)}>
|
|
38
54
|
{@render whole()}
|
|
39
55
|
</span>
|
|
40
56
|
{/if}
|
|
@@ -49,9 +65,9 @@
|
|
|
49
65
|
{/if}
|
|
50
66
|
{/snippet}
|
|
51
67
|
{#snippet whole()}
|
|
52
|
-
{@render side(
|
|
53
|
-
<span class={cls(
|
|
68
|
+
{@render side(PARTS.LEFT, type === "left", left)}
|
|
69
|
+
<span class={cls(PARTS.MAIN, status)}>
|
|
54
70
|
{@render children()}
|
|
55
71
|
</span>
|
|
56
|
-
{@render side(
|
|
72
|
+
{@render side(PARTS.RIGHT, type === "right", right)}
|
|
57
73
|
{/snippet}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface BadgeProps {
|
|
2
2
|
children: Snippet;
|
|
3
3
|
left?: Snippet<[string]>;
|
|
4
4
|
right?: Snippet<[string]>;
|
|
@@ -7,12 +7,27 @@ export type BadgeProps = {
|
|
|
7
7
|
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
8
8
|
status?: string;
|
|
9
9
|
style?: SVSStyle;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export type BadgeReqdProps = "children";
|
|
12
12
|
export type BadgeBindProps = "status";
|
|
13
13
|
import { type Snippet } from "svelte";
|
|
14
14
|
import { type MouseEventHandler } from "svelte/elements";
|
|
15
15
|
import { type SVSStyle } from "./core";
|
|
16
|
+
/**
|
|
17
|
+
* default value: `<value>`
|
|
18
|
+
* ```ts
|
|
19
|
+
* interface BadgeProps {
|
|
20
|
+
* children: Snippet;
|
|
21
|
+
* left?: Snippet<[string]>; // Snippet<[status]>
|
|
22
|
+
* right?: Snippet<[string]>; // Snippet<[status]>
|
|
23
|
+
* type?: "plain" | "link" | "left" | "right"; // <"plain">
|
|
24
|
+
* href?: string;
|
|
25
|
+
* onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
26
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
27
|
+
* style?: SVSStyle;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
16
31
|
declare const Badge: import("svelte").Component<BadgeProps, {}, "status">;
|
|
17
32
|
type Badge = ReturnType<typeof Badge>;
|
|
18
33
|
export default Badge;
|
package/_svseeds/_Button.svelte
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ButtonProps {
|
|
6
|
+
children: Snippet;
|
|
7
|
+
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
8
|
+
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
9
|
+
type?: "submit" | "reset" | "button"; // <"button">
|
|
10
|
+
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
11
|
+
form?: HTMLFormElement; // bindable
|
|
12
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
13
|
+
style?: SVSStyle;
|
|
14
|
+
attributes?: HTMLButtonAttributes;
|
|
15
|
+
action?: Action;
|
|
16
|
+
element?: HTMLButtonElement; // bindable
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
-->
|
|
1
20
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
children: Snippet
|
|
4
|
-
left?: Snippet<[string, HTMLButtonElement | undefined]
|
|
5
|
-
right?: Snippet<[string, HTMLButtonElement | undefined]
|
|
6
|
-
type?: "submit" | "reset" | "button"
|
|
7
|
-
onclick?: MouseEventHandler<HTMLButtonElement> | null
|
|
8
|
-
form?: HTMLFormElement
|
|
9
|
-
status?: string
|
|
10
|
-
style?: SVSStyle
|
|
11
|
-
attributes?: HTMLButtonAttributes
|
|
12
|
-
action?: Action
|
|
13
|
-
element?: HTMLButtonElement
|
|
14
|
-
}
|
|
21
|
+
export interface ButtonProps {
|
|
22
|
+
children: Snippet;
|
|
23
|
+
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
24
|
+
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
25
|
+
type?: "submit" | "reset" | "button"; // <"button">
|
|
26
|
+
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
27
|
+
form?: HTMLFormElement; // bindable
|
|
28
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
29
|
+
style?: SVSStyle;
|
|
30
|
+
attributes?: HTMLButtonAttributes;
|
|
31
|
+
action?: Action;
|
|
32
|
+
element?: HTMLButtonElement; // bindable
|
|
33
|
+
}
|
|
15
34
|
export type ButtonReqdProps = "children";
|
|
16
35
|
export type ButtonBindProps = "form" | "status" | "element";
|
|
17
36
|
|
|
@@ -20,11 +39,11 @@
|
|
|
20
39
|
import { type Snippet } from "svelte";
|
|
21
40
|
import { type Action } from "svelte/action";
|
|
22
41
|
import { type HTMLButtonAttributes, type MouseEventHandler } from "svelte/elements";
|
|
23
|
-
import { type SVSStyle, STATE,
|
|
42
|
+
import { type SVSStyle, STATE, PARTS, fnClass, omit } from "./core";
|
|
24
43
|
</script>
|
|
25
44
|
|
|
26
45
|
<script lang="ts">
|
|
27
|
-
let { children, left, right, type = "button", onclick, form = $bindable(), status = $bindable(STATE.
|
|
46
|
+
let { children, left, right, type = "button", onclick, form = $bindable(), status = $bindable(STATE.NEUTRAL), style, attributes, action, element = $bindable()}: ButtonProps = $props();
|
|
28
47
|
|
|
29
48
|
// *** Initialize *** //
|
|
30
49
|
const cls = fnClass(preset, style);
|
|
@@ -40,11 +59,11 @@
|
|
|
40
59
|
<!---------------------------------------->
|
|
41
60
|
|
|
42
61
|
{#if action}
|
|
43
|
-
<button bind:this={element} class={cls(
|
|
62
|
+
<button bind:this={element} class={cls(PARTS.WHOLE, status)} {type} {onclick} {...attrs} use:action>
|
|
44
63
|
{@render whole()}
|
|
45
64
|
</button>
|
|
46
65
|
{:else}
|
|
47
|
-
<button bind:this={element} class={cls(
|
|
66
|
+
<button bind:this={element} class={cls(PARTS.WHOLE, status)} {type} {onclick} {...attrs}>
|
|
48
67
|
{@render whole()}
|
|
49
68
|
</button>
|
|
50
69
|
{/if}
|
|
@@ -55,9 +74,9 @@
|
|
|
55
74
|
{/if}
|
|
56
75
|
{/snippet}
|
|
57
76
|
{#snippet whole()}
|
|
58
|
-
{@render side(
|
|
59
|
-
<span class={cls(
|
|
77
|
+
{@render side(PARTS.LEFT, left)}
|
|
78
|
+
<span class={cls(PARTS.MAIN, status)}>
|
|
60
79
|
{@render children()}
|
|
61
80
|
</span>
|
|
62
|
-
{@render side(
|
|
81
|
+
{@render side(PARTS.RIGHT, right)}
|
|
63
82
|
{/snippet}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ButtonProps {
|
|
2
2
|
children: Snippet;
|
|
3
3
|
left?: Snippet<[string, HTMLButtonElement | undefined]>;
|
|
4
4
|
right?: Snippet<[string, HTMLButtonElement | undefined]>;
|
|
@@ -10,13 +10,31 @@ export type ButtonProps = {
|
|
|
10
10
|
attributes?: HTMLButtonAttributes;
|
|
11
11
|
action?: Action;
|
|
12
12
|
element?: HTMLButtonElement;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
export type ButtonReqdProps = "children";
|
|
15
15
|
export type ButtonBindProps = "form" | "status" | "element";
|
|
16
16
|
import { type Snippet } from "svelte";
|
|
17
17
|
import { type Action } from "svelte/action";
|
|
18
18
|
import { type HTMLButtonAttributes, type MouseEventHandler } from "svelte/elements";
|
|
19
19
|
import { type SVSStyle } from "./core";
|
|
20
|
+
/**
|
|
21
|
+
* default value: `<value>`
|
|
22
|
+
* ```ts
|
|
23
|
+
* interface ButtonProps {
|
|
24
|
+
* children: Snippet;
|
|
25
|
+
* left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
26
|
+
* right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[status,element]>
|
|
27
|
+
* type?: "submit" | "reset" | "button"; // <"button">
|
|
28
|
+
* onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
29
|
+
* form?: HTMLFormElement; // bindable
|
|
30
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
31
|
+
* style?: SVSStyle;
|
|
32
|
+
* attributes?: HTMLButtonAttributes;
|
|
33
|
+
* action?: Action;
|
|
34
|
+
* element?: HTMLButtonElement; // bindable
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
20
38
|
declare const Button: import("svelte").Component<ButtonProps, {}, "form" | "status" | "element">;
|
|
21
39
|
type Button = ReturnType<typeof Button>;
|
|
22
40
|
export default Button;
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface CheckFieldProps {
|
|
6
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
7
|
+
label?: string;
|
|
8
|
+
extra?: string;
|
|
9
|
+
aux?: Snippet<[string, string[], HTMLInputElement[]]>; // Snippet<[status,values,elements]>
|
|
10
|
+
bottom?: string;
|
|
11
|
+
descFirst?: boolean; // <false>
|
|
12
|
+
values?: string[]; // bindable
|
|
13
|
+
multiple?: boolean; // <true>
|
|
14
|
+
validations?: CheckFieldValidation[];
|
|
15
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
16
|
+
style?: SVSStyle;
|
|
17
|
+
attributes?: HTMLInputAttributes;
|
|
18
|
+
action?: Action;
|
|
19
|
+
elements?: HTMLInputElement[]; // bindable
|
|
20
|
+
}
|
|
21
|
+
type CheckFieldValidation = (values: string[], validity: ValidityState) => string;
|
|
22
|
+
```
|
|
23
|
+
-->
|
|
1
24
|
<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[], HTMLInputElement[]]
|
|
7
|
-
bottom?: string
|
|
8
|
-
descFirst?: boolean
|
|
9
|
-
values?: string[]
|
|
10
|
-
multiple?: boolean
|
|
11
|
-
validations?: CheckFieldValidation[]
|
|
12
|
-
status?: string
|
|
13
|
-
style?: SVSStyle
|
|
14
|
-
attributes?: HTMLInputAttributes
|
|
15
|
-
action?: Action
|
|
16
|
-
elements?: HTMLInputElement[]
|
|
17
|
-
}
|
|
25
|
+
export interface CheckFieldProps {
|
|
26
|
+
options: SvelteMap<string, string> | Map<string, string>;
|
|
27
|
+
label?: string;
|
|
28
|
+
extra?: string;
|
|
29
|
+
aux?: Snippet<[string, string[], HTMLInputElement[]]>; // Snippet<[status,values,elements]>
|
|
30
|
+
bottom?: string;
|
|
31
|
+
descFirst?: boolean; // <false>
|
|
32
|
+
values?: string[]; // bindable
|
|
33
|
+
multiple?: boolean; // <true>
|
|
34
|
+
validations?: CheckFieldValidation[];
|
|
35
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
36
|
+
style?: SVSStyle;
|
|
37
|
+
attributes?: HTMLInputAttributes;
|
|
38
|
+
action?: Action;
|
|
39
|
+
elements?: HTMLInputElement[]; // bindable
|
|
40
|
+
}
|
|
18
41
|
export type CheckFieldReqdProps = "options";
|
|
19
42
|
export type CheckFieldBindProps = "values" | "status" | "elements";
|
|
20
43
|
export type CheckFieldValidation = (values: string[], validity: ValidityState) => string;
|
|
@@ -25,14 +48,14 @@
|
|
|
25
48
|
import { type Action } from "svelte/action";
|
|
26
49
|
import { type SvelteMap } from "svelte/reactivity";
|
|
27
50
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
28
|
-
import { type SVSStyle, STATE,
|
|
51
|
+
import { type SVSStyle, STATE, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
29
52
|
</script>
|
|
30
53
|
|
|
31
54
|
<script lang="ts">
|
|
32
55
|
let { options, label, extra, aux, bottom, values = $bindable([]), multiple = true, descFirst = false, validations = [], status = $bindable(""), style, attributes, action, elements = $bindable([])}: CheckFieldProps = $props();
|
|
33
56
|
|
|
34
57
|
// *** Initialize *** //
|
|
35
|
-
if (!status) status = STATE.
|
|
58
|
+
if (!status) status = STATE.NEUTRAL;
|
|
36
59
|
const cls = fnClass(preset, style);
|
|
37
60
|
const type = multiple ? "checkbox" : "radio";
|
|
38
61
|
const name = attributes?.["name"] ? attributes?.["name"] : elemId.id;
|
|
@@ -44,7 +67,7 @@
|
|
|
44
67
|
let message = $state(bottom);
|
|
45
68
|
|
|
46
69
|
// *** Status *** //
|
|
47
|
-
let neutral = $state(isNeutral(status) ? status : STATE.
|
|
70
|
+
let neutral = $state(isNeutral(status) ? status : STATE.NEUTRAL);
|
|
48
71
|
$effect(() => { neutral = isNeutral(status) ? status : neutral });
|
|
49
72
|
let live = $derived(status === STATE.INACTIVE ? "alert" : "status");
|
|
50
73
|
let invalid = $derived(status === STATE.INACTIVE ? true : undefined);
|
|
@@ -84,16 +107,17 @@
|
|
|
84
107
|
ev.preventDefault();
|
|
85
108
|
shift(true);
|
|
86
109
|
}
|
|
110
|
+
$effect(() => untrack(() => verify()));
|
|
87
111
|
</script>
|
|
88
112
|
|
|
89
113
|
<!---------------------------------------->
|
|
90
114
|
|
|
91
115
|
{#if opts.length}
|
|
92
|
-
<div class={cls(
|
|
116
|
+
<div class={cls(PARTS.WHOLE, status)} role="group" aria-labelledby={idLabel}>
|
|
93
117
|
{#if aux}
|
|
94
|
-
<div class={cls(
|
|
118
|
+
<div class={cls(PARTS.TOP, status)}>
|
|
95
119
|
{@render lbl()}
|
|
96
|
-
<span class={cls(
|
|
120
|
+
<span class={cls(PARTS.AUX, status)}>{@render aux(status, values, elements)}</span>
|
|
97
121
|
</div>
|
|
98
122
|
{:else}
|
|
99
123
|
{@render lbl()}
|
|
@@ -106,31 +130,31 @@
|
|
|
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}
|
|
116
140
|
{/snippet}
|
|
117
141
|
{#snippet main()}
|
|
118
|
-
<div class={cls(
|
|
142
|
+
<div class={cls(PARTS.MIDDLE, status)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple ? idMsg : undefined}>
|
|
119
143
|
{#each opts as {value, text, checked}, i (value)}
|
|
120
144
|
{@const stat = checked ? STATE.ACTIVE : neutral}
|
|
121
|
-
<label class={cls(
|
|
145
|
+
<label class={cls(PARTS.MAIN, stat)}>
|
|
122
146
|
{#if action}
|
|
123
|
-
<input bind:this={elements[i]} class={cls(
|
|
147
|
+
<input bind:this={elements[i]} class={cls(PARTS.LEFT, stat)} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? idMsg : undefined} {value} {name} {type} {checked} {onchange} {oninvalid} {...attrs} use:action />
|
|
124
148
|
{:else}
|
|
125
|
-
<input bind:this={elements[i]} class={cls(
|
|
149
|
+
<input bind:this={elements[i]} class={cls(PARTS.LEFT, stat)} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? idMsg : undefined} {value} {name} {type} {checked} {onchange} {oninvalid} {...attrs} />
|
|
126
150
|
{/if}
|
|
127
|
-
<span class={cls(
|
|
151
|
+
<span class={cls(PARTS.RIGHT, stat)}>{text}</span>
|
|
128
152
|
</label>
|
|
129
153
|
{/each}
|
|
130
154
|
</div>
|
|
131
155
|
{/snippet}
|
|
132
156
|
{#snippet desc(show: boolean)}
|
|
133
157
|
{#if show && message?.trim()}
|
|
134
|
-
<div class={cls(
|
|
158
|
+
<div class={cls(PARTS.BOTTOM, status)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
135
159
|
{/if}
|
|
136
160
|
{/snippet}
|