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
|
@@ -2,14 +2,14 @@ export interface TabsProps {
|
|
|
2
2
|
labels?: string[];
|
|
3
3
|
current?: number;
|
|
4
4
|
ariaOrientation?: "horizontal" | "vertical";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
styling?: SVSClass;
|
|
6
|
+
variant?: string;
|
|
7
7
|
[key: string]: unknown | Snippet;
|
|
8
8
|
}
|
|
9
9
|
export type TabsReqdProps = never;
|
|
10
|
-
export type TabsBindProps = "current" | "
|
|
10
|
+
export type TabsBindProps = "current" | "variant";
|
|
11
11
|
import { type Snippet } from "svelte";
|
|
12
|
-
import { type
|
|
12
|
+
import { type SVSClass } from "./core";
|
|
13
13
|
/**
|
|
14
14
|
* default value: `(value)`
|
|
15
15
|
* ```ts
|
|
@@ -17,12 +17,12 @@ import { type SVSStyle } from "./core";
|
|
|
17
17
|
* labels?: string[];
|
|
18
18
|
* current?: number; // bindable (0)
|
|
19
19
|
* ariaOrientation?: "horizontal" | "vertical";
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* [key: string]: unknown | Snippet;
|
|
20
|
+
* styling?: SVSClass;
|
|
21
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
22
|
+
* [key: string]: unknown | Snippet; // labels or contents of each tab
|
|
23
23
|
* }
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
declare const Tabs: import("svelte").Component<TabsProps, {}, "
|
|
26
|
+
declare const Tabs: import("svelte").Component<TabsProps, {}, "variant" | "current">;
|
|
27
27
|
type Tabs = ReturnType<typeof Tabs>;
|
|
28
28
|
export default Tabs;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
default value: `(value)`
|
|
4
4
|
```ts
|
|
5
5
|
interface TagsInputProps {
|
|
6
|
-
label?: Snippet<[string, string]>; // Snippet<[value,
|
|
7
|
-
aux?: Snippet<[string, string]>; // Snippet<[value,
|
|
6
|
+
label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
7
|
+
aux?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
8
8
|
values?: string[]; // bindable
|
|
9
9
|
value?: string; // bindable
|
|
10
10
|
type?: "left" | "right"; // ("left")
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
unique?: boolean; // (true)
|
|
14
14
|
ariaErrMsgId?: string; // bindable
|
|
15
15
|
events?: TagsInputEvents;
|
|
16
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
17
|
-
style?: SVSStyle;
|
|
18
16
|
attributes?: HTMLInputAttributes;
|
|
19
17
|
action?: Action;
|
|
20
18
|
element?: HTMLInputElement; // bindable
|
|
19
|
+
styling?: SVSClass;
|
|
20
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
21
21
|
}
|
|
22
22
|
interface TagsInputEvents { // cancel if true
|
|
23
23
|
onadd?: (values: string[], value: string) => void | boolean;
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
-->
|
|
28
28
|
<script module lang="ts">
|
|
29
29
|
export interface TagsInputProps {
|
|
30
|
-
label?: Snippet<[string, string]>; // Snippet<[value,
|
|
31
|
-
aux?: Snippet<[string, string]>; // Snippet<[value,
|
|
30
|
+
label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
31
|
+
aux?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
32
32
|
values?: string[]; // bindable
|
|
33
33
|
value?: string; // bindable
|
|
34
34
|
type?: "left" | "right"; // ("left")
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
unique?: boolean; // (true)
|
|
38
38
|
ariaErrMsgId?: string; // bindable
|
|
39
39
|
events?: TagsInputEvents;
|
|
40
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
41
|
-
style?: SVSStyle;
|
|
42
40
|
attributes?: HTMLInputAttributes;
|
|
43
41
|
action?: Action;
|
|
44
42
|
element?: HTMLInputElement; // bindable
|
|
43
|
+
styling?: SVSClass;
|
|
44
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
45
45
|
}
|
|
46
46
|
export type TagsInputReqdProps = never;
|
|
47
|
-
export type TagsInputBindProps = "values" | "value" | "ariaErrMsgId" | "
|
|
47
|
+
export type TagsInputBindProps = "values" | "value" | "ariaErrMsgId" | "variant" | "element";
|
|
48
48
|
export interface TagsInputEvents { // cancel if true
|
|
49
49
|
onadd?: (values: string[], value: string) => void | boolean;
|
|
50
50
|
onremove?: (values: string[], value: string, index: number) => void | boolean;
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
import { type Snippet } from "svelte";
|
|
59
59
|
import { type Action } from "svelte/action";
|
|
60
60
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
61
|
-
import { type
|
|
61
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
64
|
<script lang="ts">
|
|
65
|
-
let { label, aux, values = $bindable([]), value = $bindable(""), type = "left", confirm = [], trim = true, unique = true, ariaErrMsgId = $bindable(), events,
|
|
65
|
+
let { label, aux, values = $bindable([]), value = $bindable(""), type = "left", confirm = [], trim = true, unique = true, ariaErrMsgId = $bindable(), events, attributes, action, element = $bindable(), styling, variant = $bindable("") }: TagsInputProps = $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 attrs = omit(attributes, "class", "type", "onkeydown");
|
|
71
71
|
const confirmKeys = new Set([CONFIRM_KEY, ...confirm]);
|
|
72
72
|
let invalid = $derived(ariaErrMsgId ? true : undefined);
|
|
@@ -96,29 +96,29 @@
|
|
|
96
96
|
|
|
97
97
|
<!---------------------------------------->
|
|
98
98
|
|
|
99
|
-
<div class={cls(PARTS.WHOLE,
|
|
99
|
+
<div class={cls(PARTS.WHOLE, variant)}>
|
|
100
100
|
{@render tags(type === "left")}
|
|
101
101
|
{#if action}
|
|
102
|
-
<input bind:value bind:this={element} class={cls(PARTS.MAIN,
|
|
102
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" {onkeydown} aria-invalid={invalid} aria-errormessage={ariaErrMsgId} {...attrs} use:action />
|
|
103
103
|
{:else}
|
|
104
|
-
<input bind:value bind:this={element} class={cls(PARTS.MAIN,
|
|
104
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" {onkeydown} aria-invalid={invalid} aria-errormessage={ariaErrMsgId} {...attrs} />
|
|
105
105
|
{/if}
|
|
106
106
|
{@render tags(type === "right")}
|
|
107
107
|
</div>
|
|
108
108
|
|
|
109
109
|
{#snippet tags(render: boolean)}
|
|
110
110
|
{#if render}
|
|
111
|
-
<span class={cls(type,
|
|
111
|
+
<span class={cls(type, variant)}>
|
|
112
112
|
{#each values as value, i}
|
|
113
|
-
<span class={cls(PARTS.LABEL,
|
|
113
|
+
<span class={cls(PARTS.LABEL, variant)}>
|
|
114
114
|
{#if label}
|
|
115
|
-
{@render label(value,
|
|
115
|
+
{@render label(value, variant)}
|
|
116
116
|
{:else}
|
|
117
117
|
{value}
|
|
118
118
|
{/if}
|
|
119
|
-
<button class={cls(PARTS.AUX,
|
|
119
|
+
<button class={cls(PARTS.AUX, variant)} onclick={remove(i)}>
|
|
120
120
|
{#if aux}
|
|
121
|
-
{@render aux(value,
|
|
121
|
+
{@render aux(value, variant)}
|
|
122
122
|
{:else}
|
|
123
123
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="10" height="10"><path d="M511.998 70.682 441.315 0 256.002 185.313 70.685 0 .002 70.692l185.314 185.314L.002 441.318 70.69 512l185.312-185.312L441.315 512l70.683-70.682-185.314-185.312z" /></svg>
|
|
124
124
|
{/if}
|
|
@@ -9,14 +9,14 @@ export interface TagsInputProps {
|
|
|
9
9
|
unique?: boolean;
|
|
10
10
|
ariaErrMsgId?: string;
|
|
11
11
|
events?: TagsInputEvents;
|
|
12
|
-
status?: string;
|
|
13
|
-
style?: SVSStyle;
|
|
14
12
|
attributes?: HTMLInputAttributes;
|
|
15
13
|
action?: Action;
|
|
16
14
|
element?: HTMLInputElement;
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string;
|
|
17
17
|
}
|
|
18
18
|
export type TagsInputReqdProps = never;
|
|
19
|
-
export type TagsInputBindProps = "values" | "value" | "ariaErrMsgId" | "
|
|
19
|
+
export type TagsInputBindProps = "values" | "value" | "ariaErrMsgId" | "variant" | "element";
|
|
20
20
|
export interface TagsInputEvents {
|
|
21
21
|
onadd?: (values: string[], value: string) => void | boolean;
|
|
22
22
|
onremove?: (values: string[], value: string, index: number) => void | boolean;
|
|
@@ -24,13 +24,13 @@ export interface TagsInputEvents {
|
|
|
24
24
|
import { type Snippet } from "svelte";
|
|
25
25
|
import { type Action } from "svelte/action";
|
|
26
26
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
27
|
-
import { type
|
|
27
|
+
import { type SVSClass } from "./core";
|
|
28
28
|
/**
|
|
29
29
|
* default value: `(value)`
|
|
30
30
|
* ```ts
|
|
31
31
|
* interface TagsInputProps {
|
|
32
|
-
* label?: Snippet<[string, string]>; // Snippet<[value,
|
|
33
|
-
* aux?: Snippet<[string, string]>; // Snippet<[value,
|
|
32
|
+
* label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
33
|
+
* aux?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
34
34
|
* values?: string[]; // bindable
|
|
35
35
|
* value?: string; // bindable
|
|
36
36
|
* type?: "left" | "right"; // ("left")
|
|
@@ -39,11 +39,11 @@ import { type SVSStyle } from "./core";
|
|
|
39
39
|
* unique?: boolean; // (true)
|
|
40
40
|
* ariaErrMsgId?: string; // bindable
|
|
41
41
|
* events?: TagsInputEvents;
|
|
42
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
43
|
-
* style?: SVSStyle;
|
|
44
42
|
* attributes?: HTMLInputAttributes;
|
|
45
43
|
* action?: Action;
|
|
46
44
|
* element?: HTMLInputElement; // bindable
|
|
45
|
+
* styling?: SVSClass;
|
|
46
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
47
47
|
* }
|
|
48
48
|
* interface TagsInputEvents { // cancel if true
|
|
49
49
|
* onadd?: (values: string[], value: string) => void | boolean;
|
|
@@ -51,6 +51,6 @@ import { type SVSStyle } from "./core";
|
|
|
51
51
|
* }
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
|
-
declare const TagsInput: import("svelte").Component<TagsInputProps, {}, "
|
|
54
|
+
declare const TagsInput: import("svelte").Component<TagsInputProps, {}, "variant" | "value" | "element" | "values" | "ariaErrMsgId">;
|
|
55
55
|
type TagsInput = ReturnType<typeof TagsInput>;
|
|
56
56
|
export default TagsInput;
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
interface TextFieldProps {
|
|
6
6
|
label?: string;
|
|
7
7
|
extra?: string;
|
|
8
|
-
aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
9
|
-
left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
10
|
-
right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
8
|
+
aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
9
|
+
left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
10
|
+
right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
11
11
|
bottom?: string;
|
|
12
12
|
descFirst?: boolean; // (false)
|
|
13
13
|
value?: string; // bindable
|
|
14
14
|
type?: "text" | "area" | "email" | "password" | "search" | "tel" | "url"; // bindable ("text")
|
|
15
15
|
options?: SvelteSet<string> | Set<string>;
|
|
16
16
|
validations?: TextFieldValidation[];
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
18
|
+
styling?: SVSClass;
|
|
19
19
|
attributes?: HTMLInputAttributes | HTMLTextareaAttributes;
|
|
20
20
|
action?: Action;
|
|
21
21
|
element?: HTMLInputElement | HTMLTextAreaElement; // bindable
|
|
@@ -27,23 +27,23 @@
|
|
|
27
27
|
export interface TextFieldProps {
|
|
28
28
|
label?: string;
|
|
29
29
|
extra?: string;
|
|
30
|
-
aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
31
|
-
left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
32
|
-
right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
30
|
+
aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[value,variant,element]>
|
|
31
|
+
left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[value,variant,element]>
|
|
32
|
+
right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[value,variant,element]>
|
|
33
33
|
bottom?: string;
|
|
34
34
|
descFirst?: boolean; // (false)
|
|
35
35
|
value?: string; // bindable
|
|
36
36
|
type?: "text" | "area" | "email" | "password" | "search" | "tel" | "url"; // bindable ("text")
|
|
37
37
|
options?: SvelteSet<string> | Set<string>;
|
|
38
38
|
validations?: TextFieldValidation[];
|
|
39
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
40
|
-
style?: SVSStyle;
|
|
41
39
|
attributes?: HTMLInputAttributes | HTMLTextareaAttributes;
|
|
42
40
|
action?: Action;
|
|
43
41
|
element?: HTMLInputElement | HTMLTextAreaElement; // bindable
|
|
42
|
+
styling?: SVSClass;
|
|
43
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
44
44
|
}
|
|
45
45
|
export type TextFieldReqdProps = never;
|
|
46
|
-
export type TextFieldBindProps = "value" | "type" | "
|
|
46
|
+
export type TextFieldBindProps = "value" | "type" | "variant" | "element";
|
|
47
47
|
export type TextFieldValidation = (value: string, validity: ValidityState) => string | undefined;
|
|
48
48
|
|
|
49
49
|
const preset = "svs-text-field";
|
|
@@ -52,15 +52,15 @@
|
|
|
52
52
|
import { type Action } from "svelte/action";
|
|
53
53
|
import { type SvelteSet } from "svelte/reactivity";
|
|
54
54
|
import { type HTMLInputAttributes, type HTMLTextareaAttributes } from "svelte/elements";
|
|
55
|
-
import { type
|
|
55
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
56
56
|
</script>
|
|
57
57
|
|
|
58
58
|
<script lang="ts">
|
|
59
|
-
let { label, extra, aux, left, right, bottom, descFirst = false, value = $bindable(""), type = $bindable("text"), options, validations = [],
|
|
59
|
+
let { label, extra, aux, left, right, bottom, descFirst = false, value = $bindable(""), type = $bindable("text"), options, validations = [], attributes, action, element = $bindable(), styling, variant = $bindable("") }: TextFieldProps = $props();
|
|
60
60
|
|
|
61
61
|
// *** Initialize *** //
|
|
62
|
-
if (!
|
|
63
|
-
const cls = fnClass(preset,
|
|
62
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
63
|
+
const cls = fnClass(preset, styling);
|
|
64
64
|
const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
|
|
65
65
|
const idLabel = elemId.get(label?.trim());
|
|
66
66
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -70,15 +70,15 @@
|
|
|
70
70
|
let message = $state(bottom);
|
|
71
71
|
|
|
72
72
|
// *** Status *** //
|
|
73
|
-
let neutral = isNeutral(
|
|
74
|
-
$effect(() => { neutral = isNeutral(
|
|
75
|
-
let live = $derived(
|
|
76
|
-
let invalid = $derived(
|
|
77
|
-
let idMsg = $derived(
|
|
73
|
+
let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
|
|
74
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
75
|
+
let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
|
|
76
|
+
let invalid = $derived(variant === VARIANT.INACTIVE ? true : undefined);
|
|
77
|
+
let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
|
|
78
78
|
function shift(oninvalid?: boolean) {
|
|
79
79
|
const vmsg = element?.validationMessage ?? "";
|
|
80
|
-
|
|
81
|
-
message =
|
|
80
|
+
variant = !value && !oninvalid ? neutral : vmsg ? VARIANT.INACTIVE : VARIANT.ACTIVE;
|
|
81
|
+
message = variant === VARIANT.INACTIVE ? vmsg ? vmsg : bottom : bottom;
|
|
82
82
|
}
|
|
83
83
|
function verify() {
|
|
84
84
|
if (!element) return;
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
untrack(() => validate(true));
|
|
96
96
|
});
|
|
97
97
|
function validate(effect?: boolean) {
|
|
98
|
-
if (effect && isNeutral(
|
|
98
|
+
if (effect && isNeutral(variant)) return;
|
|
99
99
|
verify();
|
|
100
100
|
shift();
|
|
101
101
|
}
|
|
@@ -115,17 +115,17 @@
|
|
|
115
115
|
|
|
116
116
|
<!---------------------------------------->
|
|
117
117
|
|
|
118
|
-
<div class={cls(PARTS.WHOLE,
|
|
118
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
|
|
119
119
|
{#if aux}
|
|
120
|
-
<div class={cls(PARTS.TOP,
|
|
120
|
+
<div class={cls(PARTS.TOP, variant)}>
|
|
121
121
|
{@render lbl()}
|
|
122
|
-
<span class={cls(PARTS.AUX,
|
|
122
|
+
<span class={cls(PARTS.AUX, variant)}>{@render aux(value, variant, element)}</span>
|
|
123
123
|
</div>
|
|
124
124
|
{:else}
|
|
125
125
|
{@render lbl()}
|
|
126
126
|
{/if}
|
|
127
127
|
{@render desc(descFirst)}
|
|
128
|
-
<div class={cls(PARTS.MIDDLE,
|
|
128
|
+
<div class={cls(PARTS.MIDDLE, variant)}>
|
|
129
129
|
{@render side(PARTS.LEFT, left)}
|
|
130
130
|
{@render main()}
|
|
131
131
|
{@render side(PARTS.RIGHT, right)}
|
|
@@ -135,21 +135,21 @@
|
|
|
135
135
|
|
|
136
136
|
{#snippet lbl()}
|
|
137
137
|
{#if label?.trim()}
|
|
138
|
-
<label class={cls(PARTS.LABEL,
|
|
138
|
+
<label class={cls(PARTS.LABEL, variant)} for={id} id={idLabel}>
|
|
139
139
|
{label}
|
|
140
140
|
{#if extra?.trim()}
|
|
141
|
-
<span class={cls(PARTS.EXTRA,
|
|
141
|
+
<span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
|
|
142
142
|
{/if}
|
|
143
143
|
</label>
|
|
144
144
|
{/if}
|
|
145
145
|
{/snippet}
|
|
146
146
|
{#snippet side(area: string, body?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>)}
|
|
147
147
|
{#if body}
|
|
148
|
-
<span class={cls(area,
|
|
148
|
+
<span class={cls(area, variant)}>{@render body(value, variant, element)}</span>
|
|
149
149
|
{/if}
|
|
150
150
|
{/snippet}
|
|
151
151
|
{#snippet main()}
|
|
152
|
-
{@const c = cls(PARTS.MAIN,
|
|
152
|
+
{@const c = cls(PARTS.MAIN, variant)}
|
|
153
153
|
{#if type === "area"}
|
|
154
154
|
{#if action}
|
|
155
155
|
<textarea bind:value bind:this={element} class={c} {id} {onchange} {oninvalid} {...attrs} aria-describedby={idDesc} aria-invalid={invalid} aria-errormessage={idMsg} use:action></textarea>
|
|
@@ -173,6 +173,6 @@
|
|
|
173
173
|
{/snippet}
|
|
174
174
|
{#snippet desc(show: boolean)}
|
|
175
175
|
{#if show && message?.trim()}
|
|
176
|
-
<div class={cls(PARTS.BOTTOM,
|
|
176
|
+
<div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
177
177
|
{/if}
|
|
178
178
|
{/snippet}
|
|
@@ -10,37 +10,37 @@ export interface TextFieldProps {
|
|
|
10
10
|
type?: "text" | "area" | "email" | "password" | "search" | "tel" | "url";
|
|
11
11
|
options?: SvelteSet<string> | Set<string>;
|
|
12
12
|
validations?: TextFieldValidation[];
|
|
13
|
-
status?: string;
|
|
14
|
-
style?: SVSStyle;
|
|
15
13
|
attributes?: HTMLInputAttributes | HTMLTextareaAttributes;
|
|
16
14
|
action?: Action;
|
|
17
15
|
element?: HTMLInputElement | HTMLTextAreaElement;
|
|
16
|
+
styling?: SVSClass;
|
|
17
|
+
variant?: string;
|
|
18
18
|
}
|
|
19
19
|
export type TextFieldReqdProps = never;
|
|
20
|
-
export type TextFieldBindProps = "value" | "type" | "
|
|
20
|
+
export type TextFieldBindProps = "value" | "type" | "variant" | "element";
|
|
21
21
|
export type TextFieldValidation = (value: string, validity: ValidityState) => string | undefined;
|
|
22
22
|
import { type Snippet } from "svelte";
|
|
23
23
|
import { type Action } from "svelte/action";
|
|
24
24
|
import { type SvelteSet } from "svelte/reactivity";
|
|
25
25
|
import { type HTMLInputAttributes, type HTMLTextareaAttributes } from "svelte/elements";
|
|
26
|
-
import { type
|
|
26
|
+
import { type SVSClass } from "./core";
|
|
27
27
|
/**
|
|
28
28
|
* default value: `(value)`
|
|
29
29
|
* ```ts
|
|
30
30
|
* interface TextFieldProps {
|
|
31
31
|
* label?: string;
|
|
32
32
|
* extra?: string;
|
|
33
|
-
* aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
34
|
-
* left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
35
|
-
* right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[
|
|
33
|
+
* aux?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
34
|
+
* left?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
35
|
+
* right?: Snippet<[string, string, HTMLInputElement | HTMLTextAreaElement | undefined]>; // Snippet<[variant,value,element]>
|
|
36
36
|
* bottom?: string;
|
|
37
37
|
* descFirst?: boolean; // (false)
|
|
38
38
|
* value?: string; // bindable
|
|
39
39
|
* type?: "text" | "area" | "email" | "password" | "search" | "tel" | "url"; // bindable ("text")
|
|
40
40
|
* options?: SvelteSet<string> | Set<string>;
|
|
41
41
|
* validations?: TextFieldValidation[];
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
43
|
+
* styling?: SVSClass;
|
|
44
44
|
* attributes?: HTMLInputAttributes | HTMLTextareaAttributes;
|
|
45
45
|
* action?: Action;
|
|
46
46
|
* element?: HTMLInputElement | HTMLTextAreaElement; // bindable
|
|
@@ -48,6 +48,6 @@ import { type SVSStyle } from "./core";
|
|
|
48
48
|
* type TextFieldValidation = (value: string, validity: ValidityState) => string | undefined;
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare const TextField: import("svelte").Component<TextFieldProps, {}, "
|
|
51
|
+
declare const TextField: import("svelte").Component<TextFieldProps, {}, "variant" | "type" | "value" | "element">;
|
|
52
52
|
type TextField = ReturnType<typeof TextField>;
|
|
53
53
|
export default TextField;
|
package/_svseeds/_Toggle.svelte
CHANGED
|
@@ -3,38 +3,36 @@
|
|
|
3
3
|
default value: `(value)`
|
|
4
4
|
```ts
|
|
5
5
|
interface ToggleProps {
|
|
6
|
-
|
|
7
|
-
left?: Snippet<[
|
|
8
|
-
right?: Snippet<[
|
|
6
|
+
children?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
7
|
+
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
8
|
+
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
9
9
|
value?: boolean; // bindable (false)
|
|
10
10
|
type?: "button" | "switch"; // ("button")
|
|
11
11
|
ariaLabel?: string;
|
|
12
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
13
|
-
style?: SVSStyle;
|
|
14
12
|
attributes?: HTMLButtonAttributes;
|
|
15
13
|
action?: Action;
|
|
16
14
|
element?: HTMLButtonElement; // bindable
|
|
17
|
-
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
18
17
|
}
|
|
19
18
|
```
|
|
20
19
|
-->
|
|
21
20
|
<script module lang="ts">
|
|
22
21
|
export interface ToggleProps {
|
|
23
|
-
|
|
24
|
-
left?: Snippet<[
|
|
25
|
-
right?: Snippet<[
|
|
22
|
+
children?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
23
|
+
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
24
|
+
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
26
25
|
value?: boolean; // bindable (false)
|
|
27
26
|
type?: "button" | "switch"; // ("button")
|
|
28
27
|
ariaLabel?: string;
|
|
29
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
30
|
-
style?: SVSStyle;
|
|
31
28
|
attributes?: HTMLButtonAttributes;
|
|
32
29
|
action?: Action;
|
|
33
30
|
element?: HTMLButtonElement; // bindable
|
|
34
|
-
|
|
31
|
+
styling?: SVSClass;
|
|
32
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
35
33
|
}
|
|
36
34
|
export type ToggleReqdProps = never;
|
|
37
|
-
export type ToggleBindProps = "value" | "
|
|
35
|
+
export type ToggleBindProps = "value" | "variant" | "element";
|
|
38
36
|
|
|
39
37
|
type ToggleTarget = { currentTarget: EventTarget & HTMLButtonElement };
|
|
40
38
|
const preset = "svs-toggle";
|
|
@@ -42,25 +40,25 @@
|
|
|
42
40
|
import { type Snippet, untrack } from "svelte";
|
|
43
41
|
import { type Action } from "svelte/action";
|
|
44
42
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
45
|
-
import { type
|
|
43
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, isNeutral, omit } from "./core";
|
|
46
44
|
</script>
|
|
47
45
|
|
|
48
46
|
<script lang="ts">
|
|
49
|
-
let {
|
|
47
|
+
let { children, left, right, value = $bindable(false), type = "button", ariaLabel, attributes, action, element = $bindable(), styling, variant = $bindable("") }: ToggleProps = $props();
|
|
50
48
|
|
|
51
49
|
// *** Initialize *** //
|
|
52
|
-
if (!
|
|
53
|
-
const cls = fnClass(preset,
|
|
50
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
51
|
+
const cls = fnClass(preset, styling);
|
|
54
52
|
const attrs = omit(attributes, "class", "type", "role", "aria-checked", "aria-pressed", "onclick");
|
|
55
|
-
let neutral = isNeutral(
|
|
53
|
+
let neutral = isNeutral(variant) ? variant : VARIANT.NEUTRAL;
|
|
56
54
|
|
|
57
55
|
// *** Bind Handlers *** //
|
|
58
|
-
$effect(() => { neutral = isNeutral(
|
|
56
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
59
57
|
$effect.pre(() => { value;
|
|
60
58
|
untrack(() => toggle());
|
|
61
59
|
});
|
|
62
60
|
function toggle() {
|
|
63
|
-
|
|
61
|
+
variant = value ? VARIANT.ACTIVE : neutral;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
// *** Event Handlers *** //
|
|
@@ -73,7 +71,7 @@
|
|
|
73
71
|
<!---------------------------------------->
|
|
74
72
|
|
|
75
73
|
{#if left || right}
|
|
76
|
-
<span class={cls(PARTS.WHOLE,
|
|
74
|
+
<span class={cls(PARTS.WHOLE, variant)} role="group">
|
|
77
75
|
{@render side(PARTS.LEFT, left)}
|
|
78
76
|
{@render button(type)}
|
|
79
77
|
{@render side(PARTS.RIGHT, right)}
|
|
@@ -82,20 +80,18 @@
|
|
|
82
80
|
{@render button(type)}
|
|
83
81
|
{/if}
|
|
84
82
|
|
|
85
|
-
{#snippet side(area: string, body?: Snippet<[
|
|
83
|
+
{#snippet side(area: string, body?: Snippet<[boolean, string, HTMLButtonElement | undefined]>)}
|
|
86
84
|
{#if body}
|
|
87
|
-
<span class={cls(area,
|
|
85
|
+
<span class={cls(area, variant)}>{@render body(value, variant, element)}</span>
|
|
88
86
|
{/if}
|
|
89
87
|
{/snippet}
|
|
90
88
|
{#snippet contents()}
|
|
91
|
-
{#if
|
|
92
|
-
{@render
|
|
93
|
-
{:else if children}
|
|
94
|
-
{@render children()}
|
|
89
|
+
{#if children}
|
|
90
|
+
{@render children(value, variant, element)}
|
|
95
91
|
{/if}
|
|
96
92
|
{/snippet}
|
|
97
93
|
{#snippet button(role: string)}
|
|
98
|
-
{@const c = cls(PARTS.MAIN,
|
|
94
|
+
{@const c = cls(PARTS.MAIN, variant)}
|
|
99
95
|
{#if role === "button"}
|
|
100
96
|
{#if action}
|
|
101
97
|
<button bind:this={element} class={c} type="button" aria-pressed={value} aria-label={ariaLabel} {onclick} {...attrs} use:action>
|
|
@@ -120,7 +116,7 @@
|
|
|
120
116
|
{/if}
|
|
121
117
|
{/snippet}
|
|
122
118
|
{#snippet thumb()}
|
|
123
|
-
<span class={cls(PARTS.AUX,
|
|
119
|
+
<span class={cls(PARTS.AUX, variant)} style="position: absolute;">
|
|
124
120
|
{@render contents()}
|
|
125
121
|
</span>
|
|
126
122
|
{/snippet}
|
|
@@ -1,42 +1,40 @@
|
|
|
1
1
|
export interface ToggleProps {
|
|
2
|
-
|
|
3
|
-
left?: Snippet<[
|
|
4
|
-
right?: Snippet<[
|
|
2
|
+
children?: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
3
|
+
left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
4
|
+
right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>;
|
|
5
5
|
value?: boolean;
|
|
6
6
|
type?: "button" | "switch";
|
|
7
7
|
ariaLabel?: string;
|
|
8
|
-
status?: string;
|
|
9
|
-
style?: SVSStyle;
|
|
10
8
|
attributes?: HTMLButtonAttributes;
|
|
11
9
|
action?: Action;
|
|
12
10
|
element?: HTMLButtonElement;
|
|
13
|
-
|
|
11
|
+
styling?: SVSClass;
|
|
12
|
+
variant?: string;
|
|
14
13
|
}
|
|
15
14
|
export type ToggleReqdProps = never;
|
|
16
|
-
export type ToggleBindProps = "value" | "
|
|
15
|
+
export type ToggleBindProps = "value" | "variant" | "element";
|
|
17
16
|
import { type Snippet } from "svelte";
|
|
18
17
|
import { type Action } from "svelte/action";
|
|
19
18
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
20
|
-
import { type
|
|
19
|
+
import { type SVSClass } from "./core";
|
|
21
20
|
/**
|
|
22
21
|
* default value: `(value)`
|
|
23
22
|
* ```ts
|
|
24
23
|
* interface ToggleProps {
|
|
25
|
-
*
|
|
26
|
-
* left?: Snippet<[
|
|
27
|
-
* right?: Snippet<[
|
|
24
|
+
* children?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
25
|
+
* left?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
26
|
+
* right?: Snippet<[boolean, string, HTMLButtonElement | undefined]>; // Snippet<[value,variant,element]>
|
|
28
27
|
* value?: boolean; // bindable (false)
|
|
29
28
|
* type?: "button" | "switch"; // ("button")
|
|
30
29
|
* ariaLabel?: string;
|
|
31
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
32
|
-
* style?: SVSStyle;
|
|
33
30
|
* attributes?: HTMLButtonAttributes;
|
|
34
31
|
* action?: Action;
|
|
35
32
|
* element?: HTMLButtonElement; // bindable
|
|
36
|
-
*
|
|
33
|
+
* styling?: SVSClass;
|
|
34
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
37
35
|
* }
|
|
38
36
|
* ```
|
|
39
37
|
*/
|
|
40
|
-
declare const Toggle: import("svelte").Component<ToggleProps, {}, "
|
|
38
|
+
declare const Toggle: import("svelte").Component<ToggleProps, {}, "variant" | "value" | "element">;
|
|
41
39
|
type Toggle = ReturnType<typeof Toggle>;
|
|
42
40
|
export default Toggle;
|