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,17 +2,17 @@ export interface ToggleGroupFieldProps {
|
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
3
|
label?: string;
|
|
4
4
|
extra?: string;
|
|
5
|
-
aux?: Snippet<[string, string
|
|
6
|
-
left?: Snippet<[string, string
|
|
7
|
-
right?: Snippet<[string, string
|
|
5
|
+
aux?: Snippet<[string[], string]>;
|
|
6
|
+
left?: Snippet<[string[], string]>;
|
|
7
|
+
right?: Snippet<[string[], string]>;
|
|
8
8
|
bottom?: string;
|
|
9
9
|
descFirst?: boolean;
|
|
10
10
|
values?: string[];
|
|
11
11
|
multiple?: boolean;
|
|
12
12
|
validations?: ToggleGroupFieldValidation[];
|
|
13
|
-
status?: string;
|
|
14
|
-
style?: SVSStyle;
|
|
15
13
|
name?: string;
|
|
14
|
+
styling?: SVSClass;
|
|
15
|
+
variant?: string;
|
|
16
16
|
deps?: ToggleGroupFieldDeps;
|
|
17
17
|
[key: string]: unknown | Snippet;
|
|
18
18
|
}
|
|
@@ -20,11 +20,11 @@ export interface ToggleGroupFieldDeps {
|
|
|
20
20
|
svsToggleGroup?: Omit<ToggleGroupProps, ToggleGroupReqdProps | ToggleGroupBindProps | "ariaDescId" | "multiple">;
|
|
21
21
|
}
|
|
22
22
|
export type ToggleGroupFieldReqdProps = "options";
|
|
23
|
-
export type ToggleGroupFieldBindProps = "values" | "
|
|
23
|
+
export type ToggleGroupFieldBindProps = "values" | "variant";
|
|
24
24
|
export type ToggleGroupFieldValidation = (values: string[]) => string | undefined;
|
|
25
25
|
import { type Snippet } from "svelte";
|
|
26
26
|
import { type SvelteMap } from "svelte/reactivity";
|
|
27
|
-
import { type
|
|
27
|
+
import { type SVSClass } from "./core";
|
|
28
28
|
import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindProps } from "./_ToggleGroup.svelte";
|
|
29
29
|
/**
|
|
30
30
|
* default value: `(value)`
|
|
@@ -33,17 +33,17 @@ import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindP
|
|
|
33
33
|
* options: SvelteMap<string, string> | Map<string, string>;
|
|
34
34
|
* label?: string;
|
|
35
35
|
* extra?: string;
|
|
36
|
-
* aux?: Snippet<[string, string
|
|
37
|
-
* left?: Snippet<[string, string
|
|
38
|
-
* right?: Snippet<[string, string
|
|
36
|
+
* aux?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
37
|
+
* left?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
38
|
+
* right?: Snippet<[string[], string]>; // Snippet<[values,variant]>
|
|
39
39
|
* bottom?: string;
|
|
40
40
|
* descFirst?: boolean; // (false)
|
|
41
41
|
* values?: string[]; // bindable
|
|
42
42
|
* multiple?: boolean; // (true)
|
|
43
43
|
* validations?: ToggleGroupFieldValidation[];
|
|
44
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
45
|
-
* style?: SVSStyle;
|
|
46
44
|
* name?: string;
|
|
45
|
+
* styling?: SVSClass;
|
|
46
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
47
47
|
* deps?: ToggleGroupFieldDeps;
|
|
48
48
|
* [key: string]: unknown | Snippet;
|
|
49
49
|
* }
|
|
@@ -53,6 +53,6 @@ import { type ToggleGroupProps, type ToggleGroupReqdProps, type ToggleGroupBindP
|
|
|
53
53
|
* type ToggleGroupFieldValidation = (values: string[]) => string | undefined;
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
declare const ToggleGroupField: import("svelte").Component<ToggleGroupFieldProps, {}, "
|
|
56
|
+
declare const ToggleGroupField: import("svelte").Component<ToggleGroupFieldProps, {}, "variant" | "values">;
|
|
57
57
|
type ToggleGroupField = ReturnType<typeof ToggleGroupField>;
|
|
58
58
|
export default ToggleGroupField;
|
package/_svseeds/_Button.svelte
CHANGED
|
@@ -3,50 +3,51 @@
|
|
|
3
3
|
default value: `(value)`
|
|
4
4
|
```ts
|
|
5
5
|
interface ButtonProps {
|
|
6
|
-
children: Snippet
|
|
7
|
-
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
8
|
-
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
6
|
+
children: Snippet<[string]>; // Snippet<[variant]>
|
|
7
|
+
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
8
|
+
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
9
9
|
type?: "submit" | "reset" | "button"; // ("button")
|
|
10
10
|
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
11
11
|
form?: HTMLFormElement; // bindable
|
|
12
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
13
|
-
style?: SVSStyle;
|
|
14
12
|
attributes?: HTMLButtonAttributes;
|
|
15
13
|
action?: Action;
|
|
16
14
|
element?: HTMLButtonElement; // bindable
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
17
17
|
}
|
|
18
18
|
```
|
|
19
19
|
-->
|
|
20
20
|
<script module lang="ts">
|
|
21
21
|
export interface ButtonProps {
|
|
22
|
-
children: Snippet
|
|
23
|
-
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
24
|
-
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
22
|
+
children: Snippet<[string]>; // Snippet<[variant]>
|
|
23
|
+
left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
24
|
+
right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
25
25
|
type?: "submit" | "reset" | "button"; // ("button")
|
|
26
26
|
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
27
27
|
form?: HTMLFormElement; // bindable
|
|
28
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
29
|
-
style?: SVSStyle;
|
|
30
28
|
attributes?: HTMLButtonAttributes;
|
|
31
29
|
action?: Action;
|
|
32
30
|
element?: HTMLButtonElement; // bindable
|
|
31
|
+
styling?: SVSClass;
|
|
32
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
33
33
|
}
|
|
34
34
|
export type ButtonReqdProps = "children";
|
|
35
|
-
export type ButtonBindProps = "form" | "
|
|
35
|
+
export type ButtonBindProps = "form" | "variant" | "element";
|
|
36
36
|
|
|
37
37
|
const preset = "svs-button";
|
|
38
38
|
|
|
39
39
|
import { type Snippet } from "svelte";
|
|
40
40
|
import { type Action } from "svelte/action";
|
|
41
41
|
import { type HTMLButtonAttributes, type MouseEventHandler } from "svelte/elements";
|
|
42
|
-
import { type
|
|
42
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
45
|
<script lang="ts">
|
|
46
|
-
let { children, left, right, type = "button", onclick, form = $bindable(),
|
|
46
|
+
let { children, left, right, type = "button", onclick, form = $bindable(), attributes, action, element = $bindable(), styling, variant = $bindable("") }: ButtonProps = $props();
|
|
47
47
|
|
|
48
48
|
// *** Initialize *** //
|
|
49
|
-
|
|
49
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
50
|
+
const cls = fnClass(preset, styling);
|
|
50
51
|
const click = onclick ?? attributes?.["onclick"];
|
|
51
52
|
const attrs = omit(attributes, "class", "type", "onclick");
|
|
52
53
|
|
|
@@ -59,24 +60,24 @@
|
|
|
59
60
|
<!---------------------------------------->
|
|
60
61
|
|
|
61
62
|
{#if action}
|
|
62
|
-
<button bind:this={element} class={cls(PARTS.WHOLE,
|
|
63
|
+
<button bind:this={element} class={cls(PARTS.WHOLE, variant)} {type} {onclick} {...attrs} use:action>
|
|
63
64
|
{@render whole()}
|
|
64
65
|
</button>
|
|
65
66
|
{:else}
|
|
66
|
-
<button bind:this={element} class={cls(PARTS.WHOLE,
|
|
67
|
+
<button bind:this={element} class={cls(PARTS.WHOLE, variant)} {type} {onclick} {...attrs}>
|
|
67
68
|
{@render whole()}
|
|
68
69
|
</button>
|
|
69
70
|
{/if}
|
|
70
71
|
|
|
71
72
|
{#snippet side(area: string, body?: Snippet<[string, HTMLButtonElement | undefined]>)}
|
|
72
73
|
{#if body}
|
|
73
|
-
<span class={cls(area,
|
|
74
|
+
<span class={cls(area, variant)}>{@render body(variant, element)}</span>
|
|
74
75
|
{/if}
|
|
75
76
|
{/snippet}
|
|
76
77
|
{#snippet whole()}
|
|
77
78
|
{@render side(PARTS.LEFT, left)}
|
|
78
|
-
<span class={cls(PARTS.MAIN,
|
|
79
|
-
{@render children()}
|
|
79
|
+
<span class={cls(PARTS.MAIN, variant)}>
|
|
80
|
+
{@render children(variant)}
|
|
80
81
|
</span>
|
|
81
82
|
{@render side(PARTS.RIGHT, right)}
|
|
82
83
|
{/snippet}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
export interface ButtonProps {
|
|
2
|
-
children: Snippet
|
|
2
|
+
children: Snippet<[string]>;
|
|
3
3
|
left?: Snippet<[string, HTMLButtonElement | undefined]>;
|
|
4
4
|
right?: Snippet<[string, HTMLButtonElement | undefined]>;
|
|
5
5
|
type?: "submit" | "reset" | "button";
|
|
6
6
|
onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
7
7
|
form?: HTMLFormElement;
|
|
8
|
-
status?: string;
|
|
9
|
-
style?: SVSStyle;
|
|
10
8
|
attributes?: HTMLButtonAttributes;
|
|
11
9
|
action?: Action;
|
|
12
10
|
element?: HTMLButtonElement;
|
|
11
|
+
styling?: SVSClass;
|
|
12
|
+
variant?: string;
|
|
13
13
|
}
|
|
14
14
|
export type ButtonReqdProps = "children";
|
|
15
|
-
export type ButtonBindProps = "form" | "
|
|
15
|
+
export type ButtonBindProps = "form" | "variant" | "element";
|
|
16
16
|
import { type Snippet } from "svelte";
|
|
17
17
|
import { type Action } from "svelte/action";
|
|
18
18
|
import { type HTMLButtonAttributes, type MouseEventHandler } from "svelte/elements";
|
|
19
|
-
import { type
|
|
19
|
+
import { type SVSClass } from "./core";
|
|
20
20
|
/**
|
|
21
21
|
* default value: `(value)`
|
|
22
22
|
* ```ts
|
|
23
23
|
* interface ButtonProps {
|
|
24
|
-
* children: Snippet
|
|
25
|
-
* left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
26
|
-
* right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[
|
|
24
|
+
* children: Snippet<[string]>; // Snippet<[variant]>
|
|
25
|
+
* left?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
26
|
+
* right?: Snippet<[string, HTMLButtonElement | undefined]>; // Snippet<[variant,element]>
|
|
27
27
|
* type?: "submit" | "reset" | "button"; // ("button")
|
|
28
28
|
* onclick?: MouseEventHandler<HTMLButtonElement> | null;
|
|
29
29
|
* form?: HTMLFormElement; // bindable
|
|
30
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
31
|
-
* style?: SVSStyle;
|
|
32
30
|
* attributes?: HTMLButtonAttributes;
|
|
33
31
|
* action?: Action;
|
|
34
32
|
* element?: HTMLButtonElement; // bindable
|
|
33
|
+
* styling?: SVSClass;
|
|
34
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
35
35
|
* }
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
declare const Button: import("svelte").Component<ButtonProps, {}, "
|
|
38
|
+
declare const Button: import("svelte").Component<ButtonProps, {}, "variant" | "form" | "element">;
|
|
39
39
|
type Button = ReturnType<typeof Button>;
|
|
40
40
|
export default Button;
|
|
@@ -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
|
|
9
|
+
aux?: Snippet<[string[], string, HTMLInputElement[]]>; // Snippet<[values,variant,elements]>
|
|
10
10
|
bottom?: string;
|
|
11
11
|
descFirst?: boolean; // (false)
|
|
12
12
|
values?: string[]; // bindable
|
|
13
13
|
multiple?: boolean; // (true)
|
|
14
14
|
validations?: CheckFieldValidation[];
|
|
15
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
16
|
-
style?: SVSStyle;
|
|
17
15
|
attributes?: HTMLInputAttributes;
|
|
18
16
|
action?: Action;
|
|
19
17
|
elements?: HTMLInputElement[]; // bindable
|
|
18
|
+
styling?: SVSClass;
|
|
19
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
20
20
|
}
|
|
21
21
|
type CheckFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
22
22
|
```
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
27
27
|
label?: string;
|
|
28
28
|
extra?: string;
|
|
29
|
-
aux?: Snippet<[string, string
|
|
29
|
+
aux?: Snippet<[string[], string, HTMLInputElement[]]>; // Snippet<[values,variant,elements]>
|
|
30
30
|
bottom?: string;
|
|
31
31
|
descFirst?: boolean; // (false)
|
|
32
32
|
values?: string[]; // bindable
|
|
33
33
|
multiple?: boolean; // (true)
|
|
34
34
|
validations?: CheckFieldValidation[];
|
|
35
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
36
|
-
style?: SVSStyle;
|
|
37
35
|
attributes?: HTMLInputAttributes;
|
|
38
36
|
action?: Action;
|
|
39
37
|
elements?: HTMLInputElement[]; // bindable
|
|
38
|
+
styling?: SVSClass;
|
|
39
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
40
40
|
}
|
|
41
41
|
export type CheckFieldReqdProps = "options";
|
|
42
|
-
export type CheckFieldBindProps = "values" | "
|
|
42
|
+
export type CheckFieldBindProps = "values" | "variant" | "elements";
|
|
43
43
|
export type CheckFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
44
44
|
|
|
45
45
|
const preset = "svs-check-field";
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
import { type Action } from "svelte/action";
|
|
49
49
|
import { type SvelteMap } from "svelte/reactivity";
|
|
50
50
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
51
|
-
import { type
|
|
51
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isNeutral, omit } from "./core";
|
|
52
52
|
</script>
|
|
53
53
|
|
|
54
54
|
<script lang="ts">
|
|
55
|
-
let { options, label, extra, aux, bottom, values = $bindable([]), multiple = true, descFirst = false, validations = [],
|
|
55
|
+
let { options, label, extra, aux, bottom, values = $bindable([]), multiple = true, descFirst = false, validations = [], attributes, action, elements = $bindable([]), styling, variant = $bindable("") }: CheckFieldProps = $props();
|
|
56
56
|
|
|
57
57
|
// *** Initialize *** //
|
|
58
|
-
if (!
|
|
59
|
-
const cls = fnClass(preset,
|
|
58
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
59
|
+
const cls = fnClass(preset, styling);
|
|
60
60
|
const type = multiple ? "checkbox" : "radio";
|
|
61
61
|
const name = attributes?.["name"] ? attributes?.["name"] : elemId.id;
|
|
62
62
|
const idLabel = elemId.get(label?.trim());
|
|
@@ -67,15 +67,15 @@
|
|
|
67
67
|
let message = $state(bottom);
|
|
68
68
|
|
|
69
69
|
// *** Status *** //
|
|
70
|
-
let neutral = $state(isNeutral(
|
|
71
|
-
$effect(() => { neutral = isNeutral(
|
|
72
|
-
let live = $derived(
|
|
73
|
-
let invalid = $derived(
|
|
74
|
-
let idMsg = $derived(
|
|
70
|
+
let neutral = $state(isNeutral(variant) ? variant : VARIANT.NEUTRAL);
|
|
71
|
+
$effect(() => { neutral = isNeutral(variant) ? variant : neutral });
|
|
72
|
+
let live = $derived(variant === VARIANT.INACTIVE ? "alert" : "status");
|
|
73
|
+
let invalid = $derived(variant === VARIANT.INACTIVE ? true : undefined);
|
|
74
|
+
let idMsg = $derived(variant === VARIANT.INACTIVE && message?.trim() ? idErr : undefined);
|
|
75
75
|
function shift(oninvalid?: boolean) {
|
|
76
76
|
const vmsg = elements[0]?.validationMessage ?? "";
|
|
77
|
-
|
|
78
|
-
message =
|
|
77
|
+
variant = oninvalid && vmsg ? VARIANT.INACTIVE : (!values.length || vmsg) ? neutral : VARIANT.ACTIVE;
|
|
78
|
+
message = variant === VARIANT.INACTIVE ? vmsg ? vmsg : bottom : bottom;
|
|
79
79
|
}
|
|
80
80
|
function verify() {
|
|
81
81
|
if (!elements[0]) return;
|
|
@@ -113,11 +113,11 @@
|
|
|
113
113
|
<!---------------------------------------->
|
|
114
114
|
|
|
115
115
|
{#if opts.length}
|
|
116
|
-
<div class={cls(PARTS.WHOLE,
|
|
116
|
+
<div class={cls(PARTS.WHOLE, variant)} role="group" aria-labelledby={idLabel}>
|
|
117
117
|
{#if aux}
|
|
118
|
-
<div class={cls(PARTS.TOP,
|
|
118
|
+
<div class={cls(PARTS.TOP, variant)}>
|
|
119
119
|
{@render lbl()}
|
|
120
|
-
<span class={cls(PARTS.AUX,
|
|
120
|
+
<span class={cls(PARTS.AUX, variant)}>{@render aux(values, variant, elements)}</span>
|
|
121
121
|
</div>
|
|
122
122
|
{:else}
|
|
123
123
|
{@render lbl()}
|
|
@@ -130,18 +130,18 @@
|
|
|
130
130
|
|
|
131
131
|
{#snippet lbl()}
|
|
132
132
|
{#if label?.trim()}
|
|
133
|
-
<span class={cls(PARTS.LABEL,
|
|
133
|
+
<span class={cls(PARTS.LABEL, variant)} id={idLabel}>
|
|
134
134
|
{label}
|
|
135
135
|
{#if extra?.trim()}
|
|
136
|
-
<span class={cls(PARTS.EXTRA,
|
|
136
|
+
<span class={cls(PARTS.EXTRA, variant)}>{extra}</span>
|
|
137
137
|
{/if}
|
|
138
138
|
</span>
|
|
139
139
|
{/if}
|
|
140
140
|
{/snippet}
|
|
141
141
|
{#snippet main()}
|
|
142
|
-
<div class={cls(PARTS.MIDDLE,
|
|
142
|
+
<div class={cls(PARTS.MIDDLE, variant)} role={roleGroup} aria-describedby={idDesc} aria-invalid={!multiple ? invalid : undefined} aria-errormessage={!multiple ? idMsg : undefined}>
|
|
143
143
|
{#each opts as {value, text, checked}, i (value)}
|
|
144
|
-
{@const stat = checked ?
|
|
144
|
+
{@const stat = checked ? VARIANT.ACTIVE : neutral}
|
|
145
145
|
<label class={cls(PARTS.MAIN, stat)}>
|
|
146
146
|
{#if action}
|
|
147
147
|
<input bind:this={elements[i]} class={cls(PARTS.LEFT, stat)} aria-invalid={multiple ? invalid : undefined} aria-errormessage={multiple ? idMsg : undefined} {value} {name} {type} {checked} {onchange} {oninvalid} {...attrs} use:action />
|
|
@@ -155,6 +155,6 @@
|
|
|
155
155
|
{/snippet}
|
|
156
156
|
{#snippet desc(show: boolean)}
|
|
157
157
|
{#if show && message?.trim()}
|
|
158
|
-
<div class={cls(PARTS.BOTTOM,
|
|
158
|
+
<div class={cls(PARTS.BOTTOM, variant)} id={idDesc ?? idErr} role={live}>{message}</div>
|
|
159
159
|
{/if}
|
|
160
160
|
{/snippet}
|
|
@@ -2,26 +2,26 @@ export interface CheckFieldProps {
|
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
3
|
label?: string;
|
|
4
4
|
extra?: string;
|
|
5
|
-
aux?: Snippet<[string, string
|
|
5
|
+
aux?: Snippet<[string[], string, HTMLInputElement[]]>;
|
|
6
6
|
bottom?: string;
|
|
7
7
|
descFirst?: boolean;
|
|
8
8
|
values?: string[];
|
|
9
9
|
multiple?: boolean;
|
|
10
10
|
validations?: CheckFieldValidation[];
|
|
11
|
-
status?: string;
|
|
12
|
-
style?: SVSStyle;
|
|
13
11
|
attributes?: HTMLInputAttributes;
|
|
14
12
|
action?: Action;
|
|
15
13
|
elements?: HTMLInputElement[];
|
|
14
|
+
styling?: SVSClass;
|
|
15
|
+
variant?: string;
|
|
16
16
|
}
|
|
17
17
|
export type CheckFieldReqdProps = "options";
|
|
18
|
-
export type CheckFieldBindProps = "values" | "
|
|
18
|
+
export type CheckFieldBindProps = "values" | "variant" | "elements";
|
|
19
19
|
export type CheckFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
20
20
|
import { type Snippet } from "svelte";
|
|
21
21
|
import { type Action } from "svelte/action";
|
|
22
22
|
import { type SvelteMap } from "svelte/reactivity";
|
|
23
23
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
24
|
-
import { type
|
|
24
|
+
import { type SVSClass } from "./core";
|
|
25
25
|
/**
|
|
26
26
|
* default value: `(value)`
|
|
27
27
|
* ```ts
|
|
@@ -29,21 +29,21 @@ import { type SVSStyle } from "./core";
|
|
|
29
29
|
* options: SvelteMap<string, string> | Map<string, string>;
|
|
30
30
|
* label?: string;
|
|
31
31
|
* extra?: string;
|
|
32
|
-
* aux?: Snippet<[string, string
|
|
32
|
+
* aux?: Snippet<[string[], string, HTMLInputElement[]]>; // Snippet<[values,variant,elements]>
|
|
33
33
|
* bottom?: string;
|
|
34
34
|
* descFirst?: boolean; // (false)
|
|
35
35
|
* values?: string[]; // bindable
|
|
36
36
|
* multiple?: boolean; // (true)
|
|
37
37
|
* validations?: CheckFieldValidation[];
|
|
38
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
39
|
-
* style?: SVSStyle;
|
|
40
38
|
* attributes?: HTMLInputAttributes;
|
|
41
39
|
* action?: Action;
|
|
42
40
|
* elements?: HTMLInputElement[]; // bindable
|
|
41
|
+
* styling?: SVSClass;
|
|
42
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
43
43
|
* }
|
|
44
44
|
* type CheckFieldValidation = (values: string[], validity: ValidityState) => string | undefined;
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
declare const CheckField: import("svelte").Component<CheckFieldProps, {}, "
|
|
47
|
+
declare const CheckField: import("svelte").Component<CheckFieldProps, {}, "variant" | "elements" | "values">;
|
|
48
48
|
type CheckField = ReturnType<typeof CheckField>;
|
|
49
49
|
export default CheckField;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
interface ColorPickerProps {
|
|
6
6
|
value?: string; // bindable ("#000000")
|
|
7
7
|
alpha?: number; // bindable (1)
|
|
8
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
9
|
-
style?: SVSStyle;
|
|
10
8
|
attributes?: HTMLInputAttributes;
|
|
11
9
|
action?: Action;
|
|
12
10
|
element?: HTMLInputElement; // bindable
|
|
11
|
+
styling?: SVSClass;
|
|
12
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
13
13
|
}
|
|
14
14
|
```
|
|
15
15
|
```ts
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
export interface ColorPickerProps {
|
|
23
23
|
value?: string; // bindable ("#000000")
|
|
24
24
|
alpha?: number; // bindable (1)
|
|
25
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
26
|
-
style?: SVSStyle;
|
|
27
25
|
attributes?: HTMLInputAttributes;
|
|
28
26
|
action?: Action;
|
|
29
27
|
element?: HTMLInputElement; // bindable
|
|
28
|
+
styling?: SVSClass;
|
|
29
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
30
30
|
}
|
|
31
31
|
export type ColorPickerReqdProps = never;
|
|
32
|
-
export type ColorPickerBindProps = "value" | "alpha" | "
|
|
32
|
+
export type ColorPickerBindProps = "value" | "alpha" | "variant" | "element";
|
|
33
33
|
export function getHex(rgb: RgbColor): string {
|
|
34
34
|
if (!isValidRgb(rgb)) return DEFAULT_COLOR;
|
|
35
35
|
return "#" + (1 << 24 | rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16).slice(1);
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
|
|
63
63
|
import { type Action } from "svelte/action";
|
|
64
64
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
65
|
-
import { type
|
|
65
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, omit } from "./core";
|
|
66
66
|
</script>
|
|
67
67
|
|
|
68
68
|
<script lang="ts">
|
|
69
|
-
let { value = $bindable(DEFAULT_COLOR), alpha = $bindable(1),
|
|
69
|
+
let { value = $bindable(DEFAULT_COLOR), alpha = $bindable(1), attributes, action, element = $bindable(), styling, variant = $bindable("") }: ColorPickerProps = $props();
|
|
70
70
|
|
|
71
71
|
// *** Initialize *** //
|
|
72
|
-
if (!
|
|
73
|
-
const cls = fnClass(preset,
|
|
72
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
73
|
+
const cls = fnClass(preset, styling);
|
|
74
74
|
const attrs = omit(attributes, "type");
|
|
75
75
|
value = castValidHex(value) ?? DEFAULT_COLOR;
|
|
76
76
|
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
|
|
82
82
|
<!---------------------------------------->
|
|
83
83
|
|
|
84
|
-
<label class={cls(PARTS.WHOLE,
|
|
84
|
+
<label class={cls(PARTS.WHOLE, variant)}>
|
|
85
85
|
<div style="display: inline-block; background-image: linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0px;">
|
|
86
|
-
<div class={cls(PARTS.MAIN,
|
|
86
|
+
<div class={cls(PARTS.MAIN, variant)} style={`background-color: rgba(${rgb[0]},${rgb[1]},${rgb[2]},${alp})`}>
|
|
87
87
|
{#if action}
|
|
88
88
|
<input bind:value bind:this={element} type="color" style="visibility: hidden;" {...attrs} use:action />
|
|
89
89
|
{:else}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
export interface ColorPickerProps {
|
|
2
2
|
value?: string;
|
|
3
3
|
alpha?: number;
|
|
4
|
-
status?: string;
|
|
5
|
-
style?: SVSStyle;
|
|
6
4
|
attributes?: HTMLInputAttributes;
|
|
7
5
|
action?: Action;
|
|
8
6
|
element?: HTMLInputElement;
|
|
7
|
+
styling?: SVSClass;
|
|
8
|
+
variant?: string;
|
|
9
9
|
}
|
|
10
10
|
export type ColorPickerReqdProps = never;
|
|
11
|
-
export type ColorPickerBindProps = "value" | "alpha" | "
|
|
11
|
+
export type ColorPickerBindProps = "value" | "alpha" | "variant" | "element";
|
|
12
12
|
export declare function getHex(rgb: RgbColor): string;
|
|
13
13
|
type RgbColor = [number, number, number];
|
|
14
14
|
import { type Action } from "svelte/action";
|
|
15
15
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
16
|
-
import { type
|
|
16
|
+
import { type SVSClass } from "./core";
|
|
17
17
|
/**
|
|
18
18
|
* default value: `(value)`
|
|
19
19
|
* ```ts
|
|
20
20
|
* interface ColorPickerProps {
|
|
21
21
|
* value?: string; // bindable ("#000000")
|
|
22
22
|
* alpha?: number; // bindable (1)
|
|
23
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
24
|
-
* style?: SVSStyle;
|
|
25
23
|
* attributes?: HTMLInputAttributes;
|
|
26
24
|
* action?: Action;
|
|
27
25
|
* element?: HTMLInputElement; // bindable
|
|
26
|
+
* styling?: SVSClass;
|
|
27
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
28
28
|
* }
|
|
29
29
|
* ```
|
|
30
30
|
* ```ts
|
|
@@ -33,6 +33,6 @@ import { type SVSStyle } from "./core";
|
|
|
33
33
|
* // getHex([255, 123, 34]) => "#ff7b22"
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "
|
|
36
|
+
declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "variant" | "alpha" | "value" | "element">;
|
|
37
37
|
type ColorPicker = ReturnType<typeof ColorPicker>;
|
|
38
38
|
export default ColorPicker;
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
options: SvelteSet<string> | Set<string>;
|
|
7
7
|
value?: string; // bindable
|
|
8
8
|
expanded?: boolean; // bindable
|
|
9
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
10
|
-
style?: SVSStyle;
|
|
11
9
|
attributes?: HTMLInputAttributes;
|
|
12
10
|
action?: Action;
|
|
13
11
|
element?: HTMLInputElement; // bindable
|
|
12
|
+
styling?: SVSClass;
|
|
13
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
14
14
|
}
|
|
15
15
|
```
|
|
16
16
|
-->
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
options: SvelteSet<string> | Set<string>;
|
|
20
20
|
value?: string; // bindable
|
|
21
21
|
expanded?: boolean; // bindable
|
|
22
|
-
status?: string; // bindable (STATE.NEUTRAL)
|
|
23
|
-
style?: SVSStyle;
|
|
24
22
|
attributes?: HTMLInputAttributes;
|
|
25
23
|
action?: Action;
|
|
26
24
|
element?: HTMLInputElement; // bindable
|
|
25
|
+
styling?: SVSClass;
|
|
26
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
27
27
|
}
|
|
28
28
|
export type ComboBoxReqdProps = "options";
|
|
29
|
-
export type ComboBoxBindProps = "value" | "expanded" | "
|
|
29
|
+
export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
|
|
30
30
|
|
|
31
31
|
const preset = "svs-combo-box";
|
|
32
32
|
const NA = -1;
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
import { type Action } from "svelte/action";
|
|
37
37
|
import { type SvelteSet } from "svelte/reactivity";
|
|
38
38
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
39
|
-
import { type
|
|
39
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, omit } from "./core";
|
|
40
40
|
</script>
|
|
41
41
|
|
|
42
42
|
<script lang="ts">
|
|
43
|
-
let { options, value = $bindable(""), expanded = $bindable(false),
|
|
43
|
+
let { options, value = $bindable(""), expanded = $bindable(false), attributes, action, element = $bindable(), styling, variant = $bindable("") }: ComboBoxProps = $props();
|
|
44
44
|
|
|
45
45
|
// *** Initialize *** //
|
|
46
|
-
if (!
|
|
47
|
-
const cls = fnClass(preset,
|
|
46
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
47
|
+
const cls = fnClass(preset, styling);
|
|
48
48
|
const idList = elemId.id;
|
|
49
49
|
const attrs = omit(attributes, "class", "type", "value", "list", "role", "aria-haspopup", "aria-autocomplete", "aria-controls", "aria-expanded");
|
|
50
50
|
let selected = $state(NA);
|
|
@@ -110,17 +110,17 @@
|
|
|
110
110
|
<!---------------------------------------->
|
|
111
111
|
|
|
112
112
|
{#if options.size}
|
|
113
|
-
<div class={cls(PARTS.WHOLE,
|
|
113
|
+
<div class={cls(PARTS.WHOLE, variant)}>
|
|
114
114
|
<div style="position: relative; width: fit-content; height: fit-content;">
|
|
115
115
|
{#if action}
|
|
116
|
-
<input bind:value bind:this={element} class={cls(PARTS.MAIN,
|
|
116
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} use:action />
|
|
117
117
|
{:else}
|
|
118
|
-
<input bind:value bind:this={element} class={cls(PARTS.MAIN,
|
|
118
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, variant)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} />
|
|
119
119
|
{/if}
|
|
120
|
-
<ul bind:this={listElem} class={cls(PARTS.BOTTOM,
|
|
120
|
+
<ul bind:this={listElem} class={cls(PARTS.BOTTOM, variant)} id={idList} role="listbox" style={listboxStyle}>
|
|
121
121
|
{#each opts as opt, i (opt)}
|
|
122
122
|
{@const isSelected = i === selected}
|
|
123
|
-
{@const labelStatus = isSelected ?
|
|
123
|
+
{@const labelStatus = isSelected ? VARIANT.ACTIVE : variant}
|
|
124
124
|
{@const onpointerenter = () => selected = i}
|
|
125
125
|
<li class={cls(PARTS.LABEL, labelStatus)} aria-selected={isSelected} role="option" style={optionStyle} onpointerdown={apply} {onpointerenter}>
|
|
126
126
|
{opt}
|
|
@@ -2,18 +2,18 @@ export interface ComboBoxProps {
|
|
|
2
2
|
options: SvelteSet<string> | Set<string>;
|
|
3
3
|
value?: string;
|
|
4
4
|
expanded?: boolean;
|
|
5
|
-
status?: string;
|
|
6
|
-
style?: SVSStyle;
|
|
7
5
|
attributes?: HTMLInputAttributes;
|
|
8
6
|
action?: Action;
|
|
9
7
|
element?: HTMLInputElement;
|
|
8
|
+
styling?: SVSClass;
|
|
9
|
+
variant?: string;
|
|
10
10
|
}
|
|
11
11
|
export type ComboBoxReqdProps = "options";
|
|
12
|
-
export type ComboBoxBindProps = "value" | "expanded" | "
|
|
12
|
+
export type ComboBoxBindProps = "value" | "expanded" | "variant" | "element";
|
|
13
13
|
import { type Action } from "svelte/action";
|
|
14
14
|
import { type SvelteSet } from "svelte/reactivity";
|
|
15
15
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
16
|
-
import { type
|
|
16
|
+
import { type SVSClass } from "./core";
|
|
17
17
|
/**
|
|
18
18
|
* default value: `(value)`
|
|
19
19
|
* ```ts
|
|
@@ -21,14 +21,14 @@ import { type SVSStyle } from "./core";
|
|
|
21
21
|
* options: SvelteSet<string> | Set<string>;
|
|
22
22
|
* value?: string; // bindable
|
|
23
23
|
* expanded?: boolean; // bindable
|
|
24
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
25
|
-
* style?: SVSStyle;
|
|
26
24
|
* attributes?: HTMLInputAttributes;
|
|
27
25
|
* action?: Action;
|
|
28
26
|
* element?: HTMLInputElement; // bindable
|
|
27
|
+
* styling?: SVSClass;
|
|
28
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "
|
|
32
|
+
declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "variant" | "expanded" | "value" | "element">;
|
|
33
33
|
type ComboBox = ReturnType<typeof ComboBox>;
|
|
34
34
|
export default ComboBox;
|