svseeds 0.4.7 → 0.4.9
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 +51 -41
- package/_svseeds/TagsInputField.svelte.d.ts +15 -13
- package/_svseeds/ToggleGroupField.svelte +38 -36
- 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 +27 -27
- package/_svseeds/_CheckField.svelte.d.ts +9 -9
- package/_svseeds/_ColorPicker.svelte +14 -13
- package/_svseeds/_ColorPicker.svelte.d.ts +9 -8
- package/_svseeds/_ComboBox.svelte +63 -44
- package/_svseeds/_ComboBox.svelte.d.ts +12 -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 +17 -15
- package/_svseeds/_Modal.svelte.d.ts +9 -9
- package/_svseeds/_ProgressTracker.svelte +42 -35
- package/_svseeds/_ProgressTracker.svelte.d.ts +13 -13
- package/_svseeds/_SelectField.svelte +33 -33
- 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 +22 -22
- package/_svseeds/_TagsInput.svelte.d.ts +10 -10
- package/_svseeds/_TextField.svelte +33 -33
- 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,10 @@
|
|
|
15
15
|
max?: TagsInputFieldCountValidation;
|
|
16
16
|
constraints?: TagsInputFieldConstraint[];
|
|
17
17
|
validations?: TagsInputFieldValidation[];
|
|
18
|
-
|
|
19
|
-
style?: SVSStyle;
|
|
18
|
+
name?: string;
|
|
20
19
|
element?: HTMLInputElement; // bindable
|
|
20
|
+
styling?: SVSClass;
|
|
21
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
21
22
|
deps?: TagsInputFieldDeps;
|
|
22
23
|
}
|
|
23
24
|
interface TagsInputFieldDeps extends TagsInputDeps {
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
export interface TagsInputFieldProps {
|
|
36
37
|
label?: string;
|
|
37
38
|
extra?: string;
|
|
38
|
-
aux?: Snippet<[string, string
|
|
39
|
-
left?: Snippet<[string, string
|
|
40
|
-
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]>
|
|
41
42
|
bottom?: string;
|
|
42
43
|
descFirst?: boolean; // (false)
|
|
43
44
|
values?: string[]; // bindable
|
|
@@ -45,16 +46,17 @@
|
|
|
45
46
|
max?: TagsInputFieldCountValidation;
|
|
46
47
|
constraints?: TagsInputFieldConstraint[];
|
|
47
48
|
validations?: TagsInputFieldValidation[];
|
|
48
|
-
|
|
49
|
-
style?: SVSStyle;
|
|
49
|
+
name?: string;
|
|
50
50
|
element?: HTMLInputElement; // bindable
|
|
51
|
+
styling?: SVSClass;
|
|
52
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
51
53
|
deps?: TagsInputFieldDeps;
|
|
52
54
|
}
|
|
53
55
|
export interface TagsInputFieldDeps {
|
|
54
56
|
svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps>;
|
|
55
57
|
}
|
|
56
58
|
export type TagsInputFieldReqdProps = never;
|
|
57
|
-
export type TagsInputFieldBindProps = "values" | "
|
|
59
|
+
export type TagsInputFieldBindProps = "values" | "variant" | "element";
|
|
58
60
|
export type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string | undefined;
|
|
59
61
|
export type TagsInputFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
60
62
|
export type TagsInputFieldCountValidation = { value: number, message: string };
|
|
@@ -62,32 +64,33 @@
|
|
|
62
64
|
const preset = "svs-tags-input-field";
|
|
63
65
|
|
|
64
66
|
import { type Snippet, untrack } from "svelte";
|
|
65
|
-
import { type
|
|
67
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
66
68
|
import TagsInput, { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps } from "./_TagsInput.svelte";
|
|
67
69
|
</script>
|
|
68
70
|
|
|
69
71
|
<script lang="ts">
|
|
70
|
-
let { label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), min, max, constraints = [], validations = [],
|
|
72
|
+
let { label, extra, aux, left, right, bottom, descFirst = false, values = $bindable([]), min, max, constraints = [], validations = [], name, element = $bindable(), styling, variant = $bindable(""), deps }: TagsInputFieldProps = $props();
|
|
71
73
|
|
|
72
74
|
// *** Initialize *** //
|
|
73
|
-
if (!
|
|
74
|
-
const cls = fnClass(preset,
|
|
75
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
76
|
+
const cls = fnClass(preset, styling);
|
|
75
77
|
const id = deps?.svsTagsInput?.attributes?.id ? deps.svsTagsInput.attributes.id : elemId.get(label?.trim());
|
|
76
78
|
const idLabel = elemId.get(label?.trim());
|
|
77
79
|
const idDesc = elemId.get(bottom?.trim());
|
|
78
80
|
const idErr = idDesc ?? elemId.id;
|
|
79
81
|
let message = $state(bottom);
|
|
80
82
|
let value = $state("");
|
|
83
|
+
if (!name) name = deps?.svsTagsInput?.attributes?.name as string | undefined;
|
|
81
84
|
if (max) constraints.unshift(() => values.length >= max.value ? max.message : "");
|
|
82
85
|
if (min) validations.unshift(() => values.length < min.value ? min.message : "");
|
|
83
86
|
|
|
84
87
|
// *** Initialize Deps *** //
|
|
85
88
|
const svsTagsInput = {
|
|
86
|
-
...omit(deps?.svsTagsInput, "
|
|
89
|
+
...omit(deps?.svsTagsInput, "styling", "attributes"),
|
|
87
90
|
events: { onadd, onremove: deps?.svsTagsInput?.events?.onremove },
|
|
88
|
-
|
|
91
|
+
styling: deps?.svsTagsInput?.styling ?? `${preset} svs-tags-input`,
|
|
89
92
|
attributes: {
|
|
90
|
-
...omit(deps?.svsTagsInput?.attributes, "id", "onchange", "oninvalid", "aria-describedby"),
|
|
93
|
+
...omit(deps?.svsTagsInput?.attributes, "id", "name", "onchange", "oninvalid", "aria-describedby"),
|
|
91
94
|
id,
|
|
92
95
|
onchange,
|
|
93
96
|
oninvalid,
|
|
@@ -95,20 +98,20 @@
|
|
|
95
98
|
},
|
|
96
99
|
};
|
|
97
100
|
|
|
98
|
-
// ***
|
|
99
|
-
let neutral = isNeutral(
|
|
100
|
-
$effect(() => { neutral = isNeutral(
|
|
101
|
-
let live = $derived(
|
|
102
|
-
let idMsg = $derived(
|
|
101
|
+
// *** States *** //
|
|
102
|
+
let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
|
|
103
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
104
|
+
let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
|
|
105
|
+
let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
|
|
103
106
|
function shift(oninvalid: boolean = false, msg?: string) {
|
|
104
107
|
const vmsg = element?.validationMessage ?? "";
|
|
105
|
-
|
|
106
|
-
message =
|
|
108
|
+
variant = getStatus(oninvalid, vmsg, msg);
|
|
109
|
+
message = variant === VARIANT.INACTIVE ? msg ? msg : vmsg ? vmsg : bottom : bottom;
|
|
107
110
|
}
|
|
108
111
|
function getStatus(oninvalid: boolean, vmsg: string, msg?: string): string {
|
|
109
|
-
if (msg || (oninvalid && vmsg)) return
|
|
112
|
+
if (msg || (oninvalid && vmsg)) return VARIANT.INACTIVE;
|
|
110
113
|
if (!values.length || vmsg) return neutral;
|
|
111
|
-
return
|
|
114
|
+
return VARIANT.ACTIVE;
|
|
112
115
|
}
|
|
113
116
|
function verify() {
|
|
114
117
|
if (!element) return;
|
|
@@ -132,9 +135,9 @@
|
|
|
132
135
|
// *** Event Handlers *** //
|
|
133
136
|
function onadd(values: string[], value: string): void | boolean {
|
|
134
137
|
if (deps?.svsTagsInput?.events?.onadd?.(values, value)) return true;
|
|
135
|
-
|
|
138
|
+
variant = neutral;
|
|
136
139
|
shift(false, check());
|
|
137
|
-
return
|
|
140
|
+
return variant === VARIANT.INACTIVE;
|
|
138
141
|
}
|
|
139
142
|
function check(): string | undefined {
|
|
140
143
|
if (!element) return;
|
|
@@ -145,7 +148,7 @@
|
|
|
145
148
|
}
|
|
146
149
|
function onchange(ev: Event) {
|
|
147
150
|
deps?.svsTagsInput?.attributes?.onchange?.(ev as any);
|
|
148
|
-
if (!isNeutral(
|
|
151
|
+
if (!isNeutral(variant)) shift();
|
|
149
152
|
}
|
|
150
153
|
function oninvalid(ev: Event) {
|
|
151
154
|
deps?.svsTagsInput?.attributes?.oninvalid?.(ev as any);
|
|
@@ -157,19 +160,20 @@
|
|
|
157
160
|
|
|
158
161
|
<!---------------------------------------->
|
|
159
162
|
|
|
160
|
-
<div class={cls(PARTS.WHOLE,
|
|
163
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
|
|
161
164
|
{#if aux}
|
|
162
|
-
<div class={cls(PARTS.TOP,
|
|
165
|
+
<div class={cls(PARTS.TOP, variant)}>
|
|
163
166
|
{@render lbl()}
|
|
164
|
-
<span class={cls(PARTS.AUX,
|
|
167
|
+
<span class={cls(PARTS.AUX, variant)}>{@render aux(values, variant, element)}</span>
|
|
165
168
|
</div>
|
|
166
169
|
{:else}
|
|
167
170
|
{@render lbl()}
|
|
168
171
|
{/if}
|
|
169
172
|
{@render desc(descFirst)}
|
|
170
|
-
<div class={cls(PARTS.MIDDLE,
|
|
173
|
+
<div class={cls(PARTS.MIDDLE, variant)}>
|
|
171
174
|
{@render side(PARTS.LEFT, left)}
|
|
172
|
-
|
|
175
|
+
{@render fnForm()}
|
|
176
|
+
<TagsInput bind:values bind:value bind:variant bind:element bind:ariaErrMsgId={idMsg} {...svsTagsInput} />
|
|
173
177
|
{@render side(PARTS.RIGHT, right)}
|
|
174
178
|
</div>
|
|
175
179
|
{@render desc(!descFirst)}
|
|
@@ -177,22 +181,28 @@
|
|
|
177
181
|
|
|
178
182
|
{#snippet lbl()}
|
|
179
183
|
{#if label?.trim()}
|
|
180
|
-
<label class={cls(PARTS.LABEL,
|
|
184
|
+
<label class={cls(PARTS.LABEL, variant)} for={id} id={idLabel}>
|
|
181
185
|
{label}
|
|
182
186
|
{#if extra?.trim()}
|
|
183
|
-
<span class={cls(PARTS.EXTRA,
|
|
187
|
+
<span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
|
|
184
188
|
{/if}
|
|
185
189
|
</label>
|
|
186
190
|
{/if}
|
|
187
191
|
{/snippet}
|
|
188
|
-
{#snippet side(area: string, body?: Snippet<[string, string
|
|
192
|
+
{#snippet side(area: string, body?: Snippet<[string[], string, HTMLInputElement | undefined]>)}
|
|
189
193
|
{#if body}
|
|
190
|
-
<span class={cls(area,
|
|
194
|
+
<span class={cls(area, variant)}>{@render body(values, variant, element)}</span>
|
|
191
195
|
{/if}
|
|
192
196
|
{/snippet}
|
|
193
197
|
{#snippet desc(show: boolean)}
|
|
194
198
|
{#if show && message?.trim()}
|
|
195
|
-
<div class={cls(PARTS.BOTTOM,
|
|
199
|
+
<div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
200
|
+
{/if}
|
|
201
|
+
{/snippet}
|
|
202
|
+
{#snippet fnForm()}
|
|
203
|
+
{#if name}
|
|
204
|
+
{#each values as value}
|
|
205
|
+
<input type="hidden" {name} {value} />
|
|
206
|
+
{/each}
|
|
196
207
|
{/if}
|
|
197
208
|
{/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,17 @@ export interface TagsInputFieldProps {
|
|
|
11
11
|
max?: TagsInputFieldCountValidation;
|
|
12
12
|
constraints?: TagsInputFieldConstraint[];
|
|
13
13
|
validations?: TagsInputFieldValidation[];
|
|
14
|
-
|
|
15
|
-
style?: SVSStyle;
|
|
14
|
+
name?: string;
|
|
16
15
|
element?: HTMLInputElement;
|
|
16
|
+
styling?: SVSClass;
|
|
17
|
+
variant?: string;
|
|
17
18
|
deps?: TagsInputFieldDeps;
|
|
18
19
|
}
|
|
19
20
|
export interface TagsInputFieldDeps {
|
|
20
21
|
svsTagsInput?: Omit<TagsInputProps, TagsInputReqdProps | TagsInputBindProps>;
|
|
21
22
|
}
|
|
22
23
|
export type TagsInputFieldReqdProps = never;
|
|
23
|
-
export type TagsInputFieldBindProps = "values" | "
|
|
24
|
+
export type TagsInputFieldBindProps = "values" | "variant" | "element";
|
|
24
25
|
export type TagsInputFieldConstraint = (value: string, validity: ValidityState) => string | undefined;
|
|
25
26
|
export type TagsInputFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
26
27
|
export type TagsInputFieldCountValidation = {
|
|
@@ -28,7 +29,7 @@ export type TagsInputFieldCountValidation = {
|
|
|
28
29
|
message: string;
|
|
29
30
|
};
|
|
30
31
|
import { type Snippet } from "svelte";
|
|
31
|
-
import { type
|
|
32
|
+
import { type SVSClass } from "./core";
|
|
32
33
|
import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps } from "./_TagsInput.svelte";
|
|
33
34
|
/**
|
|
34
35
|
* default value: `(value)`
|
|
@@ -36,9 +37,9 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
36
37
|
* interface TagsInputFieldProps {
|
|
37
38
|
* label?: string;
|
|
38
39
|
* extra?: string;
|
|
39
|
-
* aux?: Snippet<[string, string
|
|
40
|
-
* left?: Snippet<[string, string
|
|
41
|
-
* right?: Snippet<[string, string
|
|
40
|
+
* aux?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
41
|
+
* left?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
42
|
+
* right?: Snippet<[string[], string, HTMLInputElement | undefined]>; // Snippet<[values,variant,element]>
|
|
42
43
|
* bottom?: string;
|
|
43
44
|
* descFirst?: boolean; // (false)
|
|
44
45
|
* values?: string[]; // bindable
|
|
@@ -46,9 +47,10 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
46
47
|
* max?: TagsInputFieldCountValidation;
|
|
47
48
|
* constraints?: TagsInputFieldConstraint[];
|
|
48
49
|
* validations?: TagsInputFieldValidation[];
|
|
49
|
-
*
|
|
50
|
-
* style?: SVSStyle;
|
|
50
|
+
* name?: string;
|
|
51
51
|
* element?: HTMLInputElement; // bindable
|
|
52
|
+
* styling?: SVSClass;
|
|
53
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
52
54
|
* deps?: TagsInputFieldDeps;
|
|
53
55
|
* }
|
|
54
56
|
* interface TagsInputFieldDeps extends TagsInputDeps {
|
|
@@ -62,6 +64,6 @@ import { type TagsInputProps, type TagsInputReqdProps, type TagsInputBindProps }
|
|
|
62
64
|
* };
|
|
63
65
|
* ```
|
|
64
66
|
*/
|
|
65
|
-
declare const TagsInputField: import("svelte").Component<TagsInputFieldProps, {}, "
|
|
67
|
+
declare const TagsInputField: import("svelte").Component<TagsInputFieldProps, {}, "variant" | "element" | "values">;
|
|
66
68
|
type TagsInputField = ReturnType<typeof TagsInputField>;
|
|
67
69
|
export default TagsInputField;
|