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
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
interface AccordionProps {
|
|
6
6
|
labels?: string[];
|
|
7
7
|
current?: number; // bindable (-1)
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
styling?: SVSClass;
|
|
9
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
10
10
|
deps?: AccordionDeps;
|
|
11
|
-
[key: string]: unknown | Snippet; // contents of each disclosure
|
|
11
|
+
[key: string]: unknown | Snippet; // labels or contents of each disclosure
|
|
12
12
|
}
|
|
13
13
|
interface AccordionDeps {
|
|
14
14
|
svsDisclosure?: Omit<DisclosureProps, DisclosureReqdProps | DisclosureBindProps>;
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
export interface AccordionProps {
|
|
20
20
|
labels?: string[];
|
|
21
21
|
current?: number; // bindable (-1)
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
styling?: SVSClass;
|
|
23
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
24
24
|
deps?: AccordionDeps;
|
|
25
|
-
[key: string]: unknown | Snippet; // contents of each disclosure
|
|
25
|
+
[key: string]: unknown | Snippet; // labels or contents of each disclosure
|
|
26
26
|
}
|
|
27
27
|
export interface AccordionDeps {
|
|
28
28
|
svsDisclosure?: Omit<DisclosureProps, DisclosureReqdProps | DisclosureBindProps>;
|
|
29
29
|
}
|
|
30
30
|
export type AccordionReqdProps = never;
|
|
31
|
-
export type AccordionBindProps = "current" | "
|
|
31
|
+
export type AccordionBindProps = "current" | "variant";
|
|
32
32
|
|
|
33
33
|
type NamedId = { id: string, name: string };
|
|
34
34
|
const preset = "svs-accordion";
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
import { type Snippet, untrack } from "svelte";
|
|
48
|
-
import { type
|
|
48
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, omit } from "./core";
|
|
49
49
|
import Disclosure, { type DisclosureProps, type DisclosureReqdProps, type DisclosureBindProps } from "./_Disclosure.svelte";
|
|
50
50
|
</script>
|
|
51
51
|
|
|
52
52
|
<script lang="ts">
|
|
53
|
-
let { labels = [], current = $bindable(-1),
|
|
53
|
+
let { labels = [], current = $bindable(-1), styling, variant = $bindable(""), deps, ...rest }: AccordionProps = $props();
|
|
54
54
|
|
|
55
55
|
// *** Initialize *** //
|
|
56
|
-
if (!
|
|
57
|
-
const cls = fnClass(preset,
|
|
56
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
57
|
+
const cls = fnClass(preset, styling);
|
|
58
58
|
const isStrLabel = labels.length > 0;
|
|
59
59
|
const lbls = toNamedId(isStrLabel ? labels : getSnippetNames(roleLabel, rest));
|
|
60
60
|
const panels = getSnippetNames(rolePanel, rest);
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
|
|
67
67
|
// *** Initialize Deps *** //
|
|
68
68
|
const svsDisclosure = {
|
|
69
|
-
...omit(deps?.svsDisclosure, "attributes", "
|
|
70
|
-
|
|
69
|
+
...omit(deps?.svsDisclosure, "attributes", "styling"),
|
|
70
|
+
styling: deps?.svsDisclosure?.styling ?? `${preset} svs-disclosure`,
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
// *** Bind Handlers *** //
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<!---------------------------------------->
|
|
102
102
|
|
|
103
103
|
{#if isValidAccordion}
|
|
104
|
-
<div class={cls(PARTS.WHOLE,
|
|
104
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group">
|
|
105
105
|
{#each lbls as { id, name }, i (id)}
|
|
106
106
|
{@const ontoggle = exclusiveToggle(i)}
|
|
107
107
|
<Disclosure bind:open={opens[i]} bind:element={elems[i]} label={isStrLabel ? name : (rest[name] as Snippet)} attributes={{...deps?.svsDisclosure?.attributes, ontoggle}} {...svsDisclosure}>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface AccordionProps {
|
|
2
2
|
labels?: string[];
|
|
3
3
|
current?: number;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
styling?: SVSClass;
|
|
5
|
+
variant?: string;
|
|
6
6
|
deps?: AccordionDeps;
|
|
7
7
|
[key: string]: unknown | Snippet;
|
|
8
8
|
}
|
|
@@ -10,9 +10,9 @@ export interface AccordionDeps {
|
|
|
10
10
|
svsDisclosure?: Omit<DisclosureProps, DisclosureReqdProps | DisclosureBindProps>;
|
|
11
11
|
}
|
|
12
12
|
export type AccordionReqdProps = never;
|
|
13
|
-
export type AccordionBindProps = "current" | "
|
|
13
|
+
export type AccordionBindProps = "current" | "variant";
|
|
14
14
|
import { type Snippet } from "svelte";
|
|
15
|
-
import { type
|
|
15
|
+
import { type SVSClass } from "./core";
|
|
16
16
|
import { type DisclosureProps, type DisclosureReqdProps, type DisclosureBindProps } from "./_Disclosure.svelte";
|
|
17
17
|
/**
|
|
18
18
|
* default value: `(value)`
|
|
@@ -20,16 +20,16 @@ import { type DisclosureProps, type DisclosureReqdProps, type DisclosureBindProp
|
|
|
20
20
|
* interface AccordionProps {
|
|
21
21
|
* labels?: string[];
|
|
22
22
|
* current?: number; // bindable (-1)
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* styling?: SVSClass;
|
|
24
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
25
25
|
* deps?: AccordionDeps;
|
|
26
|
-
* [key: string]: unknown | Snippet; // contents of each disclosure
|
|
26
|
+
* [key: string]: unknown | Snippet; // labels or contents of each disclosure
|
|
27
27
|
* }
|
|
28
28
|
* interface AccordionDeps {
|
|
29
29
|
* svsDisclosure?: Omit<DisclosureProps, DisclosureReqdProps | DisclosureBindProps>;
|
|
30
30
|
* }
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
declare const Accordion: import("svelte").Component<AccordionProps, {}, "
|
|
33
|
+
declare const Accordion: import("svelte").Component<AccordionProps, {}, "variant" | "current">;
|
|
34
34
|
type Accordion = ReturnType<typeof Accordion>;
|
|
35
35
|
export default Accordion;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
```ts
|
|
5
5
|
interface DarkToggleProps {
|
|
6
6
|
dark?: boolean; // bindable (prefers-color-scheme)
|
|
7
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
8
7
|
element?: HTMLButtonElement; // bindable
|
|
8
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
9
9
|
deps?: DarkToggleDeps;
|
|
10
10
|
}
|
|
11
11
|
interface DarkToggleDeps {
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
<script module lang="ts">
|
|
17
17
|
export interface DarkToggleProps {
|
|
18
18
|
dark?: boolean; // bindable (prefers-color-scheme)
|
|
19
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
20
19
|
element?: HTMLButtonElement; // bindable
|
|
20
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
21
21
|
deps?: DarkToggleDeps;
|
|
22
22
|
}
|
|
23
23
|
export interface DarkToggleDeps {
|
|
24
24
|
svsToggle?: Omit<ToggleProps, ToggleReqdProps | ToggleBindProps>;
|
|
25
25
|
}
|
|
26
26
|
export type DarkToggleReqdProps = never;
|
|
27
|
-
export type DarkToggleBindProps = "dark" | "
|
|
27
|
+
export type DarkToggleBindProps = "dark" | "variant" | "element";
|
|
28
28
|
|
|
29
29
|
export const THEME = { LIGHT: "light", DARK: "dark" } as const;
|
|
30
30
|
export function setThemeToRoot(theme?: string) {
|
|
@@ -137,22 +137,22 @@
|
|
|
137
137
|
}
|
|
138
138
|
const theme = new Theme();
|
|
139
139
|
|
|
140
|
-
import {
|
|
140
|
+
import { VARIANT, omit } from "./core";
|
|
141
141
|
import Toggle, { type ToggleProps, type ToggleReqdProps, type ToggleBindProps } from "./_Toggle.svelte";
|
|
142
142
|
</script>
|
|
143
143
|
|
|
144
144
|
<script lang="ts">
|
|
145
|
-
let { dark = $bindable(),
|
|
145
|
+
let { dark = $bindable(), variant = $bindable(""), element = $bindable(), deps }: DarkToggleProps = $props();
|
|
146
146
|
|
|
147
147
|
// *** Initialize *** //
|
|
148
|
-
if (!
|
|
148
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
149
149
|
if (dark === undefined) dark = theme.dark;
|
|
150
150
|
theme.dark = dark;
|
|
151
151
|
|
|
152
152
|
// *** Initialize Deps *** //
|
|
153
153
|
const svsToggle = {
|
|
154
|
-
...omit(deps?.svsToggle, "
|
|
155
|
-
|
|
154
|
+
...omit(deps?.svsToggle, "children", "styling", "attributes"),
|
|
155
|
+
styling: deps?.svsToggle?.styling ?? `${preset} svs-toggle`,
|
|
156
156
|
ariaLabel,
|
|
157
157
|
attributes: {
|
|
158
158
|
...deps?.svsToggle?.attributes,
|
|
@@ -165,10 +165,10 @@
|
|
|
165
165
|
|
|
166
166
|
<!---------------------------------------->
|
|
167
167
|
|
|
168
|
-
<Toggle bind:value={dark} bind:
|
|
169
|
-
{#snippet
|
|
170
|
-
{#if deps?.svsToggle?.
|
|
171
|
-
{@render deps.svsToggle.
|
|
168
|
+
<Toggle bind:value={dark} bind:variant bind:element {...svsToggle}>
|
|
169
|
+
{#snippet children(value: boolean, variant: string, element: HTMLButtonElement | undefined)}
|
|
170
|
+
{#if deps?.svsToggle?.children}
|
|
171
|
+
{@render deps.svsToggle.children(value, variant, element)}
|
|
172
172
|
{:else}
|
|
173
173
|
{#if value}
|
|
174
174
|
{@render svgDark()}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export interface DarkToggleProps {
|
|
2
2
|
dark?: boolean;
|
|
3
|
-
status?: string;
|
|
4
3
|
element?: HTMLButtonElement;
|
|
4
|
+
variant?: string;
|
|
5
5
|
deps?: DarkToggleDeps;
|
|
6
6
|
}
|
|
7
7
|
export interface DarkToggleDeps {
|
|
8
8
|
svsToggle?: Omit<ToggleProps, ToggleReqdProps | ToggleBindProps>;
|
|
9
9
|
}
|
|
10
10
|
export type DarkToggleReqdProps = never;
|
|
11
|
-
export type DarkToggleBindProps = "dark" | "
|
|
11
|
+
export type DarkToggleBindProps = "dark" | "variant" | "element";
|
|
12
12
|
export declare const THEME: {
|
|
13
13
|
readonly LIGHT: "light";
|
|
14
14
|
readonly DARK: "dark";
|
|
@@ -20,8 +20,8 @@ import { type ToggleProps, type ToggleReqdProps, type ToggleBindProps } from "./
|
|
|
20
20
|
* ```ts
|
|
21
21
|
* interface DarkToggleProps {
|
|
22
22
|
* dark?: boolean; // bindable (prefers-color-scheme)
|
|
23
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
24
23
|
* element?: HTMLButtonElement; // bindable
|
|
24
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
25
25
|
* deps?: DarkToggleDeps;
|
|
26
26
|
* }
|
|
27
27
|
* interface DarkToggleDeps {
|
|
@@ -29,6 +29,6 @@ import { type ToggleProps, type ToggleReqdProps, type ToggleBindProps } from "./
|
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const DarkToggle: import("svelte").Component<DarkToggleProps, {}, "
|
|
32
|
+
declare const DarkToggle: import("svelte").Component<DarkToggleProps, {}, "variant" | "element" | "dark">;
|
|
33
33
|
type DarkToggle = ReturnType<typeof DarkToggle>;
|
|
34
34
|
export default DarkToggle;
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
interface TagsInputFieldProps {
|
|
6
6
|
label?: string;
|
|
7
7
|
extra?: string;
|
|
8
|
-
aux?: Snippet<[string, string
|
|
9
|
-
left?: Snippet<[string, string
|
|
10
|
-
right?: Snippet<[string, string
|
|
8
|
+
aux?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
9
|
+
left?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
10
|
+
right?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
11
11
|
bottom?: string;
|
|
12
12
|
descFirst?: boolean; // (false)
|
|
13
13
|
values?: string[]; // bindable
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
max?: TagsInputFieldCountValidation;
|
|
16
16
|
constraints?: TagsInputFieldConstraint[];
|
|
17
17
|
validations?: TagsInputFieldValidation[];
|
|
18
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
19
|
-
style?: SVSStyle;
|
|
20
18
|
element?: HTMLInputElement; // bindable
|
|
19
|
+
styling?: SVSClass;
|
|
20
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
21
21
|
deps?: TagsInputFieldDeps;
|
|
22
22
|
}
|
|
23
23
|
interface TagsInputFieldDeps extends TagsInputDeps {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
export interface TagsInputFieldProps {
|
|
36
36
|
label?: string;
|
|
37
37
|
extra?: string;
|
|
38
|
-
aux?: Snippet<[string, string
|
|
39
|
-
left?: Snippet<[string, string
|
|
40
|
-
right?: Snippet<[string, string
|
|
38
|
+
aux?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
39
|
+
left?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
40
|
+
right?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
41
41
|
bottom?: string;
|
|
42
42
|
descFirst?: boolean; // (false)
|
|
43
43
|
values?: string[]; // bindable
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
max?: TagsInputFieldCountValidation;
|
|
46
46
|
constraints?: TagsInputFieldConstraint[];
|
|
47
47
|
validations?: TagsInputFieldValidation[];
|
|
48
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
49
|
-
style?: SVSStyle;
|
|
50
48
|
element?: HTMLInputElement; // bindable
|
|
49
|
+
styling?: SVSClass;
|
|
50
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
51
51
|
deps?: TagsInputFieldDeps;
|
|
52
52
|
}
|
|
53
53
|
export interface TagsInputFieldDeps {
|
|
54
54
|
svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps>;
|
|
55
55
|
}
|
|
56
56
|
export type TagsInputFieldReqdProps = never;
|
|
57
|
-
export type TagsInputFieldBindProps = "values" | "
|
|
57
|
+
export type TagsInputFieldBindProps = "values" | "variant" | "element";
|
|
58
58
|
export type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string | undefined;
|
|
59
59
|
export type TagsInputFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
60
60
|
export type TagsInputFieldCountValidation = { value: number, message: string };
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
const preset = "svs-tags-input-field";
|
|
63
63
|
|
|
64
64
|
import { type Snippet, untrack } from "svelte";
|
|
65
|
-
import { type
|
|
65
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
66
66
|
import TagsInput, { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps } from "./_TagsInput.svelte";
|
|
67
67
|
</script>
|
|
68
68
|
|
|
69
69
|
<script lang="ts">
|
|
70
|
-
let { label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), min, max, constraints = [], validations = [],
|
|
70
|
+
let { label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), min, max, constraints = [], validations = [], element = $bindable(), styling, variant = $bindable(""), deps }: TagsInputFieldProps = $props();
|
|
71
71
|
|
|
72
72
|
// *** Initialize *** //
|
|
73
|
-
if (!
|
|
74
|
-
const cls = fnClass(preset,
|
|
73
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
74
|
+
const cls = fnClass(preset, styling);
|
|
75
75
|
const id = deps?.svsTagsInput?.attributes?.id ? deps.svsTagsInput.attributes.id : elemId.get(label?.trim());
|
|
76
76
|
const idLabel = elemId.get(label?.trim());
|
|
77
77
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
|
|
84
84
|
// *** Initialize Deps *** //
|
|
85
85
|
const svsTagsInput = {
|
|
86
|
-
...omit(deps?.svsTagsInput, "
|
|
86
|
+
...omit(deps?.svsTagsInput, "styling", "attributes"),
|
|
87
87
|
events: { onadd, onremove: deps?.svsTagsInput?.events?.onremove },
|
|
88
|
-
|
|
88
|
+
styling: deps?.svsTagsInput?.styling ?? `${preset} svs-tags-input`,
|
|
89
89
|
attributes: {
|
|
90
90
|
...omit(deps?.svsTagsInput?.attributes, "id", "onchange", "oninvalid", "aria-describedby"),
|
|
91
91
|
id,
|
|
@@ -96,19 +96,19 @@
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
// *** Status *** //
|
|
99
|
-
let neutral = isNeutral(
|
|
100
|
-
$effect(() => { neutral = isNeutral(
|
|
101
|
-
let live = $derived(
|
|
102
|
-
let idMsg = $derived(
|
|
99
|
+
let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
|
|
100
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
101
|
+
let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
|
|
102
|
+
let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
|
|
103
103
|
function shift(oninvalid: boolean = false, msg?: string) {
|
|
104
104
|
const vmsg = element?.validationMessage ?? "";
|
|
105
|
-
|
|
106
|
-
message =
|
|
105
|
+
variant = getStatus(oninvalid, vmsg, msg);
|
|
106
|
+
message = variant === VARIANT.INACTIVE ? msg ? msg : vmsg ? vmsg : bottom : bottom;
|
|
107
107
|
}
|
|
108
108
|
function getStatus(oninvalid: boolean, vmsg: string, msg?: string): string {
|
|
109
|
-
if (msg || (oninvalid && vmsg)) return
|
|
109
|
+
if (msg || (oninvalid && vmsg)) return VARIANT.INACTIVE;
|
|
110
110
|
if (!values.length || vmsg) return neutral;
|
|
111
|
-
return
|
|
111
|
+
return VARIANT.ACTIVE;
|
|
112
112
|
}
|
|
113
113
|
function verify() {
|
|
114
114
|
if (!element) return;
|
|
@@ -132,9 +132,9 @@
|
|
|
132
132
|
// *** Event Handlers *** //
|
|
133
133
|
function onadd(values: string[], value: string): void | boolean {
|
|
134
134
|
if (deps?.svsTagsInput?.events?.onadd?.(values, value)) return true;
|
|
135
|
-
|
|
135
|
+
variant = neutral;
|
|
136
136
|
shift(false, check());
|
|
137
|
-
return
|
|
137
|
+
return variant === VARIANT.INACTIVE;
|
|
138
138
|
}
|
|
139
139
|
function check(): string | undefined {
|
|
140
140
|
if (!element) return;
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
}
|
|
146
146
|
function onchange(ev: Event) {
|
|
147
147
|
deps?.svsTagsInput?.attributes?.onchange?.(ev as any);
|
|
148
|
-
if (!isNeutral(
|
|
148
|
+
if (!isNeutral(variant)) shift();
|
|
149
149
|
}
|
|
150
150
|
function oninvalid(ev: Event) {
|
|
151
151
|
deps?.svsTagsInput?.attributes?.oninvalid?.(ev as any);
|
|
@@ -157,19 +157,19 @@
|
|
|
157
157
|
|
|
158
158
|
<!---------------------------------------->
|
|
159
159
|
|
|
160
|
-
<div class={cls(PARTS.WHOLE,
|
|
160
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
|
|
161
161
|
{#if aux}
|
|
162
|
-
<div class={cls(PARTS.TOP,
|
|
162
|
+
<div class={cls(PARTS.TOP, variant)}>
|
|
163
163
|
{@render lbl()}
|
|
164
|
-
<span class={cls(PARTS.AUX,
|
|
164
|
+
<span class={cls(PARTS.AUX, variant)}>{@render aux(values, variant, element)}</span>
|
|
165
165
|
</div>
|
|
166
166
|
{:else}
|
|
167
167
|
{@render lbl()}
|
|
168
168
|
{/if}
|
|
169
169
|
{@render desc(descFirst)}
|
|
170
|
-
<div class={cls(PARTS.MIDDLE,
|
|
170
|
+
<div class={cls(PARTS.MIDDLE, variant)}>
|
|
171
171
|
{@render side(PARTS.LEFT, left)}
|
|
172
|
-
<TagsInput bind:values bind:value bind:
|
|
172
|
+
<TagsInput bind:values bind:value bind:variant bind:element bind:ariaErrMsgId={idMsg} {...svsTagsInput} />
|
|
173
173
|
{@render side(PARTS.RIGHT, right)}
|
|
174
174
|
</div>
|
|
175
175
|
{@render desc(!descFirst)}
|
|
@@ -177,22 +177,21 @@
|
|
|
177
177
|
|
|
178
178
|
{#snippet lbl()}
|
|
179
179
|
{#if label?.trim()}
|
|
180
|
-
<label class={cls(PARTS.LABEL,
|
|
180
|
+
<label class={cls(PARTS.LABEL, variant)} for={id} id={idLabel}>
|
|
181
181
|
{label}
|
|
182
182
|
{#if extra?.trim()}
|
|
183
|
-
<span class={cls(PARTS.EXTRA,
|
|
183
|
+
<span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
|
|
184
184
|
{/if}
|
|
185
185
|
</label>
|
|
186
186
|
{/if}
|
|
187
187
|
{/snippet}
|
|
188
|
-
{#snippet side(area: string, body?: Snippet<[string, string
|
|
188
|
+
{#snippet side(area: string, body?: Snippet<[string[], string, HTMLInputElement | undefined]>)}
|
|
189
189
|
{#if body}
|
|
190
|
-
<span class={cls(area,
|
|
190
|
+
<span class={cls(area, variant)}>{@render body(values, variant, element)}</span>
|
|
191
191
|
{/if}
|
|
192
192
|
{/snippet}
|
|
193
193
|
{#snippet desc(show: boolean)}
|
|
194
194
|
{#if show && message?.trim()}
|
|
195
|
-
<div class={cls(PARTS.BOTTOM,
|
|
195
|
+
<div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
196
196
|
{/if}
|
|
197
197
|
{/snippet}
|
|
198
|
-
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export interface TagsInputFieldProps {
|
|
2
2
|
label?: string;
|
|
3
3
|
extra?: string;
|
|
4
|
-
aux?: Snippet<[string, string
|
|
5
|
-
left?: Snippet<[string, string
|
|
6
|
-
right?: Snippet<[string, string
|
|
4
|
+
aux?: Snippet<[string[], string, HTMLInputElement | undefined]>;
|
|
5
|
+
left?: Snippet<[string[], string, HTMLInputElement | undefined]>;
|
|
6
|
+
right?: Snippet<[string[], string, HTMLInputElement | undefined]>;
|
|
7
7
|
bottom?: string;
|
|
8
8
|
descFirst?: boolean;
|
|
9
9
|
values?: string[];
|
|
@@ -11,16 +11,16 @@ export interface TagsInputFieldProps {
|
|
|
11
11
|
max?: TagsInputFieldCountValidation;
|
|
12
12
|
constraints?: TagsInputFieldConstraint[];
|
|
13
13
|
validations?: TagsInputFieldValidation[];
|
|
14
|
-
status?: string;
|
|
15
|
-
style?: SVSStyle;
|
|
16
14
|
element?: HTMLInputElement;
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string;
|
|
17
17
|
deps?: TagsInputFieldDeps;
|
|
18
18
|
}
|
|
19
19
|
export interface TagsInputFieldDeps {
|
|
20
20
|
svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps>;
|
|
21
21
|
}
|
|
22
22
|
export type TagsInputFieldReqdProps = never;
|
|
23
|
-
export type TagsInputFieldBindProps = "values" | "
|
|
23
|
+
export type TagsInputFieldBindProps = "values" | "variant" | "element";
|
|
24
24
|
export type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string | undefined;
|
|
25
25
|
export type TagsInputFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
26
26
|
export type TagsInputFieldCountValidation = {
|
|
@@ -28,7 +28,7 @@ export type TagsInputFieldCountValidation = {
|
|
|
28
28
|
message: string;
|
|
29
29
|
};
|
|
30
30
|
import { type Snippet } from "svelte";
|
|
31
|
-
import { type
|
|
31
|
+
import { type SVSClass } from "./core";
|
|
32
32
|
import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps } from "./_TagsInput.svelte";
|
|
33
33
|
/**
|
|
34
34
|
* default value: `(value)`
|
|
@@ -36,9 +36,9 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
36
36
|
* interface TagsInputFieldProps {
|
|
37
37
|
* label?: string;
|
|
38
38
|
* extra?: string;
|
|
39
|
-
* aux?: Snippet<[string, string
|
|
40
|
-
* left?: Snippet<[string, string
|
|
41
|
-
* right?: Snippet<[string, string
|
|
39
|
+
* aux?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
40
|
+
* left?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
41
|
+
* right?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
42
42
|
* bottom?: string;
|
|
43
43
|
* descFirst?: boolean; // (false)
|
|
44
44
|
* values?: string[]; // bindable
|
|
@@ -46,9 +46,9 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
46
46
|
* max?: TagsInputFieldCountValidation;
|
|
47
47
|
* constraints?: TagsInputFieldConstraint[];
|
|
48
48
|
* validations?: TagsInputFieldValidation[];
|
|
49
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
50
|
-
* style?: SVSStyle;
|
|
51
49
|
* element?: HTMLInputElement; // bindable
|
|
50
|
+
* styling?: SVSClass;
|
|
51
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
52
52
|
* deps?: TagsInputFieldDeps;
|
|
53
53
|
* }
|
|
54
54
|
* interface TagsInputFieldDeps extends TagsInputDeps {
|
|
@@ -62,6 +62,6 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
62
62
|
* };
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
declare const TagsInputField: import("svelte").Component<TagsInputFieldProps, {}, "
|
|
65
|
+
declare const TagsInputField: import("svelte").Component<TagsInputFieldProps, {}, "variant" | "element" | "values">;
|
|
66
66
|
type TagsInputField = ReturnType<typeof TagsInputField>;
|
|
67
67
|
export default TagsInputField;
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
7
7
|
label?: string;
|
|
8
8
|
extra?: string;
|
|
9
|
-
aux?: Snippet<[string, string
|
|
10
|
-
left?: Snippet<[string, string
|
|
11
|
-
right?: Snippet<[string, string
|
|
9
|
+
aux?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
10
|
+
left?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
11
|
+
right?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
12
12
|
bottom?: string;
|
|
13
13
|
descFirst?: boolean; // (false)
|
|
14
14
|
values?: string[]; // bindable
|
|
15
15
|
multiple?: boolean; // (true)
|
|
16
16
|
validations?: ToggleGroupFieldValidation[];
|
|
17
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
18
|
-
style?: SVSStyle;
|
|
19
17
|
name?: string;
|
|
18
|
+
styling?: SVSClass;
|
|
19
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
20
20
|
deps?: ToggleGroupFieldDeps;
|
|
21
21
|
[key: string]: unknown | Snippet;
|
|
22
22
|
}
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
32
32
|
label?: string;
|
|
33
33
|
extra?: string;
|
|
34
|
-
aux?: Snippet<[string, string
|
|
35
|
-
left?: Snippet<[string, string
|
|
36
|
-
right?: Snippet<[string, string
|
|
34
|
+
aux?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
35
|
+
left?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
36
|
+
right?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
37
37
|
bottom?: string;
|
|
38
38
|
descFirst?: boolean; // (false)
|
|
39
39
|
values?: string[]; // bindable
|
|
40
40
|
multiple?: boolean; // (true)
|
|
41
41
|
validations?: ToggleGroupFieldValidation[];
|
|
42
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
43
|
-
style?: SVSStyle;
|
|
44
42
|
name?: string;
|
|
43
|
+
styling?: SVSClass;
|
|
44
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
45
45
|
deps?: ToggleGroupFieldDeps;
|
|
46
46
|
[key: string]: unknown | Snippet;
|
|
47
47
|
}
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
50
50
|
}
|
|
51
51
|
export type ToggleGroupFieldReqdProps = "options";
|
|
52
|
-
export type ToggleGroupFieldBindProps = "values" | "
|
|
52
|
+
export type ToggleGroupFieldBindProps = "values" | "variant";
|
|
53
53
|
export type ToggleGroupFieldValidation = (values: string[]) => string | undefined;
|
|
54
54
|
|
|
55
55
|
const preset = "svs-toggle-group-field";
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
import { type Snippet, untrack } from "svelte";
|
|
58
58
|
import { type Action } from "svelte/action";
|
|
59
59
|
import { type SvelteMap } from "svelte/reactivity";
|
|
60
|
-
import { type
|
|
60
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral } from "./core";
|
|
61
61
|
import ToggleGroup, { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_ToggleGroup.svelte";
|
|
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 = [],
|
|
65
|
+
let { options, label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), multiple = true, validations = [], name, styling, variant = $bindable(""), deps, ...rest }: ToggleGroupFieldProps = $props();
|
|
66
66
|
|
|
67
67
|
// *** Initialize *** //
|
|
68
|
-
if (!
|
|
69
|
-
const cls = fnClass(preset,
|
|
68
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
69
|
+
const cls = fnClass(preset, styling);
|
|
70
70
|
const idLabel = elemId.get(label?.trim());
|
|
71
71
|
const idDesc = elemId.get(bottom?.trim());
|
|
72
72
|
const idErr = idDesc ?? elemId.id;
|
|
@@ -77,19 +77,19 @@
|
|
|
77
77
|
const svsToggleGroup = {
|
|
78
78
|
...Object.fromEntries(Object.entries(rest).filter(([_, v]) => typeof v === "function")),
|
|
79
79
|
ariaDescId: idDesc,
|
|
80
|
-
|
|
80
|
+
styling: deps?.svsToggleGroup?.styling as SVSClass ?? `${preset} svs-toggle-group`,
|
|
81
81
|
action: deps?.svsToggleGroup?.action as Action,
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
// *** Status *** //
|
|
85
|
-
let neutral = $state(isNeutral(
|
|
86
|
-
$effect(() => { neutral = isNeutral(
|
|
87
|
-
let live = $derived(
|
|
88
|
-
let idMsg = $derived(
|
|
85
|
+
let neutral = $state(isNeutral(variant) ? variant : VARIANT.NEUTRAL);
|
|
86
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
87
|
+
let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
|
|
88
|
+
let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
|
|
89
89
|
function shift(oninvalid?: boolean) {
|
|
90
90
|
const vmsg = element?.validationMessage ?? "";
|
|
91
|
-
|
|
92
|
-
message =
|
|
91
|
+
variant = oninvalid && vmsg ? VARIANT.INACTIVE : (!values.length || vmsg) ? neutral : VARIANT.ACTIVE;
|
|
92
|
+
message = variant === VARIANT.INACTIVE ? vmsg ? vmsg : bottom : bottom;
|
|
93
93
|
}
|
|
94
94
|
function verify() {
|
|
95
95
|
if (!element) return;
|
|
@@ -121,20 +121,20 @@
|
|
|
121
121
|
<!---------------------------------------->
|
|
122
122
|
|
|
123
123
|
{#if options.size}
|
|
124
|
-
<div class={cls(PARTS.WHOLE,
|
|
124
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
|
|
125
125
|
{#if aux}
|
|
126
|
-
<div class={cls(PARTS.TOP,
|
|
126
|
+
<div class={cls(PARTS.TOP, variant)}>
|
|
127
127
|
{@render lbl()}
|
|
128
|
-
<span class={cls(PARTS.AUX,
|
|
128
|
+
<span class={cls(PARTS.AUX, variant)}>{@render aux(values, variant)}</span>
|
|
129
129
|
</div>
|
|
130
130
|
{:else}
|
|
131
131
|
{@render lbl()}
|
|
132
132
|
{/if}
|
|
133
133
|
{@render desc(descFirst)}
|
|
134
|
-
<div class={cls(PARTS.MIDDLE,
|
|
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:
|
|
137
|
+
<ToggleGroup bind:values bind:ariaErrMsgId={idMsg} bind:variant={neutral} {options} {multiple} {...svsToggleGroup} />
|
|
138
138
|
{@render side(PARTS.RIGHT, right)}
|
|
139
139
|
</div>
|
|
140
140
|
{@render desc(!descFirst)}
|
|
@@ -143,22 +143,22 @@
|
|
|
143
143
|
|
|
144
144
|
{#snippet lbl()}
|
|
145
145
|
{#if label?.trim()}
|
|
146
|
-
<span class={cls(PARTS.LABEL,
|
|
146
|
+
<span class={cls(PARTS.LABEL, variant)} id={idLabel}>
|
|
147
147
|
{label}
|
|
148
148
|
{#if extra?.trim()}
|
|
149
|
-
<span class={cls(PARTS.EXTRA,
|
|
149
|
+
<span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
|
|
150
150
|
{/if}
|
|
151
151
|
</span>
|
|
152
152
|
{/if}
|
|
153
153
|
{/snippet}
|
|
154
|
-
{#snippet side(area: string, body?: Snippet<[string, string
|
|
154
|
+
{#snippet side(area: string, body?: Snippet<[string[], string]>)}
|
|
155
155
|
{#if body}
|
|
156
|
-
<span class={cls(area,
|
|
156
|
+
<span class={cls(area, variant)}>{@render body(values, variant)}</span>
|
|
157
157
|
{/if}
|
|
158
158
|
{/snippet}
|
|
159
159
|
{#snippet desc(show: boolean)}
|
|
160
160
|
{#if show && message?.trim()}
|
|
161
|
-
<div class={cls(PARTS.BOTTOM,
|
|
161
|
+
<div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
162
162
|
{/if}
|
|
163
163
|
{/snippet}
|
|
164
164
|
{#snippet fnForm()}
|