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
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
export interface SliderProps {
|
|
2
2
|
range: Range;
|
|
3
|
-
left?: Snippet<[
|
|
4
|
-
right?: Snippet<[
|
|
3
|
+
left?: Snippet<[number, string, HTMLInputElement | undefined]>;
|
|
4
|
+
right?: Snippet<[number, string, HTMLInputElement | undefined]>;
|
|
5
5
|
value?: number;
|
|
6
6
|
step?: number | "any";
|
|
7
7
|
options?: SvelteSet<number> | Set<number>;
|
|
8
8
|
background?: Range;
|
|
9
|
-
status?: string;
|
|
10
|
-
style?: SVSStyle;
|
|
11
9
|
attributes?: HTMLInputAttributes;
|
|
12
10
|
action?: Action;
|
|
13
11
|
element?: HTMLInputElement;
|
|
12
|
+
styling?: SVSClass;
|
|
13
|
+
variant?: string;
|
|
14
14
|
}
|
|
15
15
|
export type SliderReqdProps = "min" | "max";
|
|
16
|
-
export type SliderBindProps = "min" | "max" | "value" | "
|
|
16
|
+
export type SliderBindProps = "min" | "max" | "value" | "variant" | "element";
|
|
17
17
|
export type Range = {
|
|
18
18
|
min: number;
|
|
19
19
|
max: number;
|
|
@@ -22,27 +22,27 @@ import { type Snippet } from "svelte";
|
|
|
22
22
|
import { type Action } from "svelte/action";
|
|
23
23
|
import { type SvelteSet } from "svelte/reactivity";
|
|
24
24
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
25
|
-
import { type
|
|
25
|
+
import { type SVSClass } from "./core";
|
|
26
26
|
/**
|
|
27
27
|
* default value: `(value)`
|
|
28
28
|
* ```ts
|
|
29
29
|
* interface SliderProps {
|
|
30
30
|
* range: Range; // bindable
|
|
31
|
-
* left?: Snippet<[
|
|
32
|
-
* right?: Snippet<[
|
|
31
|
+
* left?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
|
|
32
|
+
* right?: Snippet<[number, string, HTMLInputElement | undefined]>; // Snippet<[value,variant,element]>
|
|
33
33
|
* value?: number; // bindable (min+((max-min)/2))
|
|
34
34
|
* step?: number | "any"; // (1)
|
|
35
35
|
* options?: SvelteSet<number> | Set<number>;
|
|
36
|
-
* background?: Range; // ({ min: 5, max: 95 })
|
|
37
|
-
* status?: string; // bindable (STATE.NEUTRAL)
|
|
38
|
-
* style?: SVSStyle;
|
|
36
|
+
* background?: Range; // ({ min: 5, max: 95 }); linear-gradient rate limit of slider's track
|
|
39
37
|
* attributes?: HTMLInputAttributes;
|
|
40
38
|
* action?: Action;
|
|
41
39
|
* element?: HTMLInputElement; // bindable
|
|
40
|
+
* styling?: SVSClass;
|
|
41
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
42
42
|
* }
|
|
43
43
|
* type Range = { min: number, max: number };
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare const Slider: import("svelte").Component<SliderProps, {}, "
|
|
46
|
+
declare const Slider: import("svelte").Component<SliderProps, {}, "variant" | "value" | "range" | "element">;
|
|
47
47
|
type Slider = ReturnType<typeof Slider>;
|
|
48
48
|
export default Slider;
|
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
```ts
|
|
5
5
|
interface SortableProps {
|
|
6
6
|
items: SortableItems; // wrapper of string array as items to handle DnD
|
|
7
|
-
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[
|
|
7
|
+
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
8
8
|
ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
|
|
9
9
|
name?: string; // name of this group (random string)
|
|
10
|
-
mode?: SortableMode; // sort mode ("std")
|
|
10
|
+
mode?: SortableMode; // sort mode ("std")
|
|
11
11
|
accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
|
|
12
12
|
sort?: boolean; // enable sort within same group (true)
|
|
13
13
|
multiple?: boolean; // enable multiple select & drag with them (false)
|
|
14
14
|
draggable?: boolean; // enable default pointerdown handler (true)
|
|
15
15
|
appendable?: boolean; // enable append when enter group area (false)
|
|
16
16
|
confirm?: boolean // enable confirm interval time to move items (false)
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
styling?: SVSClass;
|
|
18
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
19
19
|
}
|
|
20
20
|
type SortableMode = "std" | "clone" | "swap";
|
|
21
21
|
class SortableItems { // methods are same with array's
|
|
@@ -51,21 +51,21 @@
|
|
|
51
51
|
type SortableMode = "std" | "clone" | "swap";
|
|
52
52
|
export interface SortableProps {
|
|
53
53
|
items: SortableItems; // wrapper of string array as items to handle DnD
|
|
54
|
-
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[
|
|
54
|
+
item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
55
55
|
ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
|
|
56
56
|
name?: string; // name of this group (random string)
|
|
57
|
-
mode?: SortableMode; // sort mode ("std")
|
|
57
|
+
mode?: SortableMode; // sort mode ("std")
|
|
58
58
|
accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
|
|
59
59
|
sort?: boolean; // enable sort within same group (true)
|
|
60
60
|
multiple?: boolean; // enable multiple select & drag with them (false)
|
|
61
61
|
draggable?: boolean; // enable default pointerdown handler (true)
|
|
62
62
|
appendable?: boolean; // enable append when enter group area (false)
|
|
63
63
|
confirm?: boolean // enable confirm interval time to move items (false)
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
styling?: SVSClass;
|
|
65
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
66
66
|
}
|
|
67
67
|
export type SortableReqdProps = "items" | "item";
|
|
68
|
-
export type SortableBindProps = "
|
|
68
|
+
export type SortableBindProps = "variant";
|
|
69
69
|
|
|
70
70
|
export class SortableItems {
|
|
71
71
|
#inner: KeyValue[] = $state([]);
|
|
@@ -641,15 +641,15 @@
|
|
|
641
641
|
import { on } from "svelte/events";
|
|
642
642
|
import { type EasingFunction, crossfade } from "svelte/transition";
|
|
643
643
|
import { flip } from "svelte/animate";
|
|
644
|
-
import { type
|
|
644
|
+
import { type SVSClass, VARIANT, PARTS, fnClass, throttle } from "./core";
|
|
645
645
|
</script>
|
|
646
646
|
|
|
647
647
|
<script lang="ts">
|
|
648
|
-
let { items, item, ghost, name, mode = "std", accept, sort = true, multiple = false, draggable = true, appendable = false, confirm = false,
|
|
648
|
+
let { items, item, ghost, name, mode = "std", accept, sort = true, multiple = false, draggable = true, appendable = false, confirm = false, styling, variant = $bindable("") }: SortableProps = $props();
|
|
649
649
|
|
|
650
650
|
// *** Initialize *** //
|
|
651
|
-
if (!
|
|
652
|
-
const cls = fnClass(preset,
|
|
651
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
652
|
+
const cls = fnClass(preset, styling);
|
|
653
653
|
const group: KeyValue = SortableItems._newItem(name);
|
|
654
654
|
const elems: HTMLElement[] = [];
|
|
655
655
|
const shadow = new Shadow(ghost);
|
|
@@ -757,26 +757,26 @@
|
|
|
757
757
|
|
|
758
758
|
<!---------------------------------------->
|
|
759
759
|
|
|
760
|
-
<ul class={cls(PARTS.WHOLE,
|
|
760
|
+
<ul class={cls(PARTS.WHOLE, variant)} onpointerenter={drag.active ? groupenter : undefined} onpointerleave={drag.active ? groupleave : undefined}>
|
|
761
761
|
{#each items._inner as {key, value}, i (key)}
|
|
762
762
|
{@const style = "touch-action:none;"}
|
|
763
|
-
{@const itemStatus = isSelected(key) ?
|
|
763
|
+
{@const itemStatus = isSelected(key) ? VARIANT.ACTIVE : variant}
|
|
764
764
|
{@const onpointerdown = draggable ? downF(key, elems[i]) : undefined}
|
|
765
765
|
{@const onpointerenter = drag.active ? enterF(key) : undefined}
|
|
766
766
|
{@const onpointerleave = drag.active ? leave : undefined}
|
|
767
767
|
<li bind:this={elems[i]} class={cls(PARTS.MAIN, itemStatus)} in:s={{key}} out:r={{key}} animate:flip={tp} {style} {onpointerdown} {onpointerenter} {onpointerleave} {ondragstart}>
|
|
768
|
-
{@render item(
|
|
768
|
+
{@render item(value, itemStatus, downF(key, elems[i]))}
|
|
769
769
|
</li>
|
|
770
770
|
{/each}
|
|
771
771
|
</ul>
|
|
772
772
|
{#if shadow.rendering}
|
|
773
773
|
{@const style = `opacity: 0.5; pointer-events: none; position: fixed; left: ${shadow.pt.x}px; top: ${shadow.pt.y}px; ${shadow.cssVisibility} ${shadow.cssSize}`}
|
|
774
774
|
<ul style="display: contents;">
|
|
775
|
-
<li bind:this={shadow.elem} class={shadow.isGhost ? undefined : cls(PARTS.MAIN,
|
|
775
|
+
<li bind:this={shadow.elem} class={shadow.isGhost ? undefined : cls(PARTS.MAIN, variant)} {style}>
|
|
776
776
|
{#if shadow.isGhost}
|
|
777
777
|
{@render ghost!(items._value(drag.key))}
|
|
778
778
|
{:else}
|
|
779
|
-
{@render item(
|
|
779
|
+
{@render item(items._value(drag.key), variant, ()=>cleanup())}
|
|
780
780
|
{/if}
|
|
781
781
|
</li>
|
|
782
782
|
</ul>
|
|
@@ -12,11 +12,11 @@ export interface SortableProps {
|
|
|
12
12
|
draggable?: boolean;
|
|
13
13
|
appendable?: boolean;
|
|
14
14
|
confirm?: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
styling?: SVSClass;
|
|
16
|
+
variant?: string;
|
|
17
17
|
}
|
|
18
18
|
export type SortableReqdProps = "items" | "item";
|
|
19
|
-
export type SortableBindProps = "
|
|
19
|
+
export type SortableBindProps = "variant";
|
|
20
20
|
export declare class SortableItems {
|
|
21
21
|
#private;
|
|
22
22
|
constructor(values: string[]);
|
|
@@ -56,24 +56,24 @@ type KeyValue = {
|
|
|
56
56
|
};
|
|
57
57
|
type DragState = "ready" | "dragging" | "idle";
|
|
58
58
|
import { type Snippet } from "svelte";
|
|
59
|
-
import { type
|
|
59
|
+
import { type SVSClass } from "./core";
|
|
60
60
|
/**
|
|
61
61
|
* default value: `(value)`
|
|
62
62
|
* ```ts
|
|
63
63
|
* interface SortableProps {
|
|
64
64
|
* items: SortableItems; // wrapper of string array as items to handle DnD
|
|
65
|
-
* item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[
|
|
65
|
+
* item: Snippet<[string, string, PointerEventHandler]>; // Snippet<[value, variant, onpointerdown]>
|
|
66
66
|
* ghost?: Snippet<[string]>; // custom shadow while dragging (the translucent item); Snippet<[value]>
|
|
67
67
|
* name?: string; // name of this group (random string)
|
|
68
|
-
* mode?: SortableMode; // sort mode ("std")
|
|
68
|
+
* mode?: SortableMode; // sort mode ("std")
|
|
69
69
|
* accept?: string[]; // list of accept group names (undefined); undefined=any,[]=none
|
|
70
70
|
* sort?: boolean; // enable sort within same group (true)
|
|
71
71
|
* multiple?: boolean; // enable multiple select & drag with them (false)
|
|
72
72
|
* draggable?: boolean; // enable default pointerdown handler (true)
|
|
73
73
|
* appendable?: boolean; // enable append when enter group area (false)
|
|
74
74
|
* confirm?: boolean // enable confirm interval time to move items (false)
|
|
75
|
-
*
|
|
76
|
-
*
|
|
75
|
+
* styling?: SVSClass;
|
|
76
|
+
* variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
77
77
|
* }
|
|
78
78
|
* type SortableMode = "std" | "clone" | "swap";
|
|
79
79
|
* class SortableItems { // methods are same with array's
|
|
@@ -94,6 +94,6 @@ import { type SVSStyle } from "./core";
|
|
|
94
94
|
* }
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
|
-
declare const Sortable: import("svelte").Component<SortableProps, {}, "
|
|
97
|
+
declare const Sortable: import("svelte").Component<SortableProps, {}, "variant">;
|
|
98
98
|
type Sortable = ReturnType<typeof Sortable>;
|
|
99
99
|
export default Sortable;
|
package/_svseeds/_Tabs.svelte
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
labels?: string[];
|
|
7
7
|
current?: number; // bindable (0)
|
|
8
8
|
ariaOrientation?: "horizontal" | "vertical";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[key: string]: unknown | Snippet;
|
|
9
|
+
styling?: SVSClass;
|
|
10
|
+
variant?: string; // bindable (VARIANT.NEUTRAL)
|
|
11
|
+
[key: string]: unknown | Snippet; // labels or contents of each tab
|
|
12
12
|
}
|
|
13
13
|
```
|
|
14
14
|
-->
|
|
@@ -17,12 +17,12 @@
|
|
|
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
|
export type TabsReqdProps = never;
|
|
25
|
-
export type TabsBindProps = "current" | "
|
|
25
|
+
export type TabsBindProps = "current" | "variant";
|
|
26
26
|
|
|
27
27
|
type NamedId = { id: string, name: string };
|
|
28
28
|
const preset = "svs-tabs";
|
|
@@ -37,27 +37,27 @@
|
|
|
37
37
|
function toNamedId(names: string[]): NamedId[] {
|
|
38
38
|
return names.map((x) => ({ id: elemId.id, name: x }));
|
|
39
39
|
}
|
|
40
|
-
function correctCurrent(
|
|
41
|
-
if (
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
40
|
+
function correctCurrent(current: number, tabs: NamedId[]): number {
|
|
41
|
+
if (!isUnsignedInteger(current)) return 0;
|
|
42
|
+
if (current >= tabs.length) return tabs.length - 1;
|
|
43
|
+
return current;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
import { type Snippet } from "svelte";
|
|
47
|
-
import { type
|
|
47
|
+
import { type SVSClass, VARIANT, PARTS, elemId, fnClass, isUnsignedInteger } from "./core";
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
50
|
<script lang="ts">
|
|
51
|
-
let { labels = [], current = $bindable(0), ariaOrientation,
|
|
51
|
+
let { labels = [], current = $bindable(0), ariaOrientation, styling, variant = $bindable(""), ...rest }: TabsProps = $props();
|
|
52
52
|
|
|
53
53
|
// *** Initialize *** //
|
|
54
|
-
if (!
|
|
55
|
-
const cls = fnClass(preset,
|
|
54
|
+
if (!variant) variant = VARIANT.NEUTRAL;
|
|
55
|
+
const cls = fnClass(preset, styling);
|
|
56
56
|
const isStrLabel = labels.length > 0;
|
|
57
57
|
const tabs = toNamedId(isStrLabel ? labels : getSnippetNames(roleLabel, rest));
|
|
58
58
|
const panels = toNamedId(getSnippetNames(rolePanel, rest));
|
|
59
59
|
const elems: HTMLButtonElement[] = [];
|
|
60
|
-
current = correctCurrent(current,
|
|
60
|
+
current = correctCurrent(current, tabs);
|
|
61
61
|
const isValidTabs = $derived(tabs.length && panels.length && tabs.length === panels.length);
|
|
62
62
|
|
|
63
63
|
// *** Event Handlers *** //
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
<!---------------------------------------->
|
|
80
80
|
|
|
81
81
|
{#if isValidTabs}
|
|
82
|
-
<div class={cls(PARTS.WHOLE,
|
|
83
|
-
<div class={cls(PARTS.TOP,
|
|
82
|
+
<div class={cls(PARTS.WHOLE, variant)}>
|
|
83
|
+
<div class={cls(PARTS.TOP, variant)} role="tablist" aria-orientation={ariaOrientation}>
|
|
84
84
|
{#each tabs as { id, name }, i (id)}
|
|
85
85
|
{@const selected = i === current}
|
|
86
|
-
{@const tabStatus = selected ?
|
|
86
|
+
{@const tabStatus = selected ? VARIANT.ACTIVE : variant}
|
|
87
87
|
<button bind:this={elems[i]} class={cls(PARTS.LABEL, tabStatus)} onclick={activate(i)} onkeydown={moveFocus(i)} tabindex={selected ? 0 : -1} aria-selected={selected} aria-controls={panels[i].id} type="button" role="tab" {id}>
|
|
88
88
|
{#if isStrLabel}
|
|
89
89
|
{name}
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
{#each panels as { id, name }, i (id)}
|
|
97
97
|
{@const selected = i === current}
|
|
98
98
|
{@const style = selected ? undefined : "display: none;"}
|
|
99
|
-
<div class={cls(PARTS.MAIN,
|
|
99
|
+
<div class={cls(PARTS.MAIN, variant)} aria-labelledby={tabs[i].id} role="tabpanel" tabindex={0} hidden={!selected} {id} {style}>
|
|
100
100
|
{@render (rest[name] as Snippet)()}
|
|
101
101
|
</div>
|
|
102
102
|
{/each}
|
|
@@ -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
|
-
|
|
6
|
+
label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
7
|
+
extra?: 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
|
-
|
|
30
|
+
label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
31
|
+
extra?: 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,
|
|
65
|
+
let { label, extra, 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(
|
|
111
|
+
<span class={cls(PARTS.AUX, 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.
|
|
120
|
-
{#if
|
|
121
|
-
{@render
|
|
119
|
+
<button class={cls(PARTS.EXTRA, variant)} onclick={remove(i)}>
|
|
120
|
+
{#if extra}
|
|
121
|
+
{@render extra(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}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface TagsInputProps {
|
|
2
2
|
label?: Snippet<[string, string]>;
|
|
3
|
-
|
|
3
|
+
extra?: Snippet<[string, string]>;
|
|
4
4
|
values?: string[];
|
|
5
5
|
value?: string;
|
|
6
6
|
type?: "left" | "right";
|
|
@@ -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
|
-
*
|
|
32
|
+
* label?: Snippet<[string, string]>; // Snippet<[value,variant]>
|
|
33
|
+
* extra?: 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;
|