svseeds 0.3.3 → 0.3.5
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 +11 -7
- package/_svseeds/Accordion.svelte.d.ts +2 -2
- package/_svseeds/DarkToggle.svelte +10 -3
- package/_svseeds/TagsInput.svelte +21 -22
- package/_svseeds/TagsInput.svelte.d.ts +3 -3
- package/_svseeds/_Badge.svelte +4 -5
- package/_svseeds/_Badge.svelte.d.ts +2 -2
- package/_svseeds/_Button.svelte +4 -5
- package/_svseeds/_Button.svelte.d.ts +2 -2
- package/_svseeds/_CheckField.svelte +7 -7
- package/_svseeds/_CheckField.svelte.d.ts +2 -2
- package/_svseeds/_ColorPicker.svelte +4 -5
- package/_svseeds/_ColorPicker.svelte.d.ts +2 -2
- package/_svseeds/_ComboBox.svelte +4 -5
- package/_svseeds/_ComboBox.svelte.d.ts +2 -2
- package/_svseeds/_ContextMenu.svelte +4 -5
- package/_svseeds/_ContextMenu.svelte.d.ts +2 -2
- package/_svseeds/_Disclosure.svelte +4 -5
- package/_svseeds/_Disclosure.svelte.d.ts +2 -2
- package/_svseeds/_HotkeyCapture.svelte +4 -5
- package/_svseeds/_HotkeyCapture.svelte.d.ts +2 -2
- package/_svseeds/_Modal.svelte +4 -5
- package/_svseeds/_Modal.svelte.d.ts +2 -2
- package/_svseeds/_ProgressTracker.svelte +4 -5
- package/_svseeds/_ProgressTracker.svelte.d.ts +2 -2
- package/_svseeds/_SelectField.svelte +7 -8
- package/_svseeds/_SelectField.svelte.d.ts +2 -2
- package/_svseeds/_Slider.svelte +4 -5
- package/_svseeds/_Slider.svelte.d.ts +2 -2
- package/_svseeds/_Sortable.svelte +4 -5
- package/_svseeds/_Sortable.svelte.d.ts +2 -2
- package/_svseeds/_Tabs.svelte +4 -5
- package/_svseeds/_Tabs.svelte.d.ts +2 -2
- package/_svseeds/_TextField.svelte +7 -8
- package/_svseeds/_TextField.svelte.d.ts +2 -2
- package/_svseeds/_Toggle.svelte +4 -5
- package/_svseeds/_Toggle.svelte.d.ts +2 -2
- package/_svseeds/_TogglesField.svelte +7 -7
- package/_svseeds/_TogglesField.svelte.d.ts +2 -2
- package/_svseeds/_Tooltip.svelte +4 -5
- package/_svseeds/_Tooltip.svelte.d.ts +2 -2
- package/_svseeds/core.d.ts +4 -3
- package/_svseeds/core.js +1 -1
- package/index.d.ts +5 -5
- package/index.js +5 -5
- package/package.json +1 -1
|
@@ -4,12 +4,12 @@ export type HotkeyCaptureProps = {
|
|
|
4
4
|
active?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
status?: string;
|
|
7
|
-
style?:
|
|
7
|
+
style?: SVSStyle;
|
|
8
8
|
element?: HTMLInputElement;
|
|
9
9
|
};
|
|
10
10
|
export type HotkeyCaptureReqdProps = never;
|
|
11
11
|
export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "status" | "element";
|
|
12
|
-
import { type
|
|
12
|
+
import { type SVSStyle } from "./core";
|
|
13
13
|
declare const HotkeyCapture: import("svelte").Component<HotkeyCaptureProps, {}, "active" | "value" | "disabled" | "status" | "element">;
|
|
14
14
|
type HotkeyCapture = ReturnType<typeof HotkeyCapture>;
|
|
15
15
|
export default HotkeyCapture;
|
package/_svseeds/_Modal.svelte
CHANGED
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
closable?: boolean, // <true>
|
|
7
7
|
trigger?: HTMLElement, // bindable
|
|
8
8
|
status?: string, // bindable <STATE.DEFAULT>
|
|
9
|
-
style?:
|
|
9
|
+
style?: SVSStyle,
|
|
10
10
|
element?: HTMLDialogElement, // bindable
|
|
11
11
|
};
|
|
12
12
|
export type ModalReqdProps = "children";
|
|
13
13
|
export type ModalBindProps = "open" | "status" | "element";
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
const preset: ClassRuleSet = {};
|
|
15
|
+
const preset = "svs-modal";
|
|
17
16
|
|
|
18
17
|
import { type Snippet, untrack } from "svelte";
|
|
19
|
-
import { type
|
|
18
|
+
import { type SVSStyle, STATE, AREA, fnClass } from "./core";
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
21
|
<script lang="ts">
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
|
|
25
24
|
// *** Initialize *** //
|
|
26
25
|
if (!status) status = STATE.DEFAULT;
|
|
27
|
-
const cls = fnClass(
|
|
26
|
+
const cls = fnClass(preset, style);
|
|
28
27
|
|
|
29
28
|
// *** Bind Handlers *** //
|
|
30
29
|
$effect(() => {
|
|
@@ -5,13 +5,13 @@ export type ModalProps = {
|
|
|
5
5
|
closable?: boolean;
|
|
6
6
|
trigger?: HTMLElement;
|
|
7
7
|
status?: string;
|
|
8
|
-
style?:
|
|
8
|
+
style?: SVSStyle;
|
|
9
9
|
element?: HTMLDialogElement;
|
|
10
10
|
};
|
|
11
11
|
export type ModalReqdProps = "children";
|
|
12
12
|
export type ModalBindProps = "open" | "status" | "element";
|
|
13
13
|
import { type Snippet } from "svelte";
|
|
14
|
-
import { type
|
|
14
|
+
import { type SVSStyle } from "./core";
|
|
15
15
|
declare const Modal: import("svelte").Component<ModalProps, {}, "open" | "status" | "element" | "trigger">;
|
|
16
16
|
type Modal = ReturnType<typeof Modal>;
|
|
17
17
|
export default Modal;
|
|
@@ -6,17 +6,16 @@
|
|
|
6
6
|
extra?: Snippet<[string, number]>, // Snippet<[status,index]>
|
|
7
7
|
status?: string, // bindable <STATE.DEFAULT>
|
|
8
8
|
eachStatus?: SvelteMap<number, string> | Map<number, string>,
|
|
9
|
-
style?:
|
|
9
|
+
style?: SVSStyle,
|
|
10
10
|
};
|
|
11
11
|
export type ProgressTrackerReqdProps = "current" | "labels";
|
|
12
12
|
export type ProgressTrackerBindProps = "current" | "status";
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
const preset: ClassRuleSet = {};
|
|
14
|
+
const preset = "svs-progress-tracker";
|
|
16
15
|
|
|
17
16
|
import { type Snippet } from "svelte";
|
|
18
17
|
import { type SvelteMap } from "svelte/reactivity";
|
|
19
|
-
import { type
|
|
18
|
+
import { type SVSStyle, STATE, AREA, fnClass } from "./core";
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
21
|
<script lang="ts">
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
|
|
25
24
|
// *** Initialize *** //
|
|
26
25
|
if (!status) status = STATE.DEFAULT;
|
|
27
|
-
const cls = fnClass(
|
|
26
|
+
const cls = fnClass(preset, style);
|
|
28
27
|
|
|
29
28
|
// *** Status *** //
|
|
30
29
|
function getEachStatus(index: number): string {
|
|
@@ -5,13 +5,13 @@ export type ProgressTrackerProps = {
|
|
|
5
5
|
extra?: Snippet<[string, number]>;
|
|
6
6
|
status?: string;
|
|
7
7
|
eachStatus?: SvelteMap<number, string> | Map<number, string>;
|
|
8
|
-
style?:
|
|
8
|
+
style?: SVSStyle;
|
|
9
9
|
};
|
|
10
10
|
export type ProgressTrackerReqdProps = "current" | "labels";
|
|
11
11
|
export type ProgressTrackerBindProps = "current" | "status";
|
|
12
12
|
import { type Snippet } from "svelte";
|
|
13
13
|
import { type SvelteMap } from "svelte/reactivity";
|
|
14
|
-
import { type
|
|
14
|
+
import { type SVSStyle } from "./core";
|
|
15
15
|
declare const ProgressTracker: import("svelte").Component<ProgressTrackerProps, {}, "status" | "current">;
|
|
16
16
|
type ProgressTracker = ReturnType<typeof ProgressTracker>;
|
|
17
17
|
export default ProgressTracker;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
descFirst?: boolean, // <false>
|
|
12
12
|
validations?: ((value: string, validity?: ValidityState) => string)[],
|
|
13
13
|
status?: string, // bindable <STATE.DEFAULT>
|
|
14
|
-
style?:
|
|
14
|
+
style?: SVSStyle,
|
|
15
15
|
attributes?: HTMLSelectAttributes;
|
|
16
16
|
action?: Action,
|
|
17
17
|
element?: HTMLSelectElement, // bindable
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
export type SelectFieldBindProps = "value" | "status" | "element";
|
|
21
21
|
|
|
22
22
|
type SelectFieldTarget = { currentTarget: EventTarget & HTMLSelectElement };
|
|
23
|
-
const
|
|
24
|
-
const preset: ClassRuleSet = {};
|
|
23
|
+
const preset = "svs-select-field";
|
|
25
24
|
|
|
26
25
|
import { type Snippet, untrack } from "svelte";
|
|
27
26
|
import { type Action } from "svelte/action";
|
|
28
27
|
import { type SvelteMap } from "svelte/reactivity";
|
|
29
28
|
import { type HTMLSelectAttributes } from "svelte/elements";
|
|
30
|
-
import { type
|
|
29
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass, isNeutral, omit } from "./core";
|
|
31
30
|
</script>
|
|
32
31
|
|
|
33
32
|
<script lang="ts">
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
|
|
36
35
|
// *** Initialize *** //
|
|
37
36
|
if (!status) status = STATE.DEFAULT;
|
|
38
|
-
const cls = fnClass(
|
|
37
|
+
const cls = fnClass(preset, style);
|
|
39
38
|
const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
|
|
40
39
|
const idLabel = elemId.get(label?.trim());
|
|
41
40
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -56,8 +55,8 @@
|
|
|
56
55
|
message = msg ?? bottom;
|
|
57
56
|
element?.setCustomValidity(msg ?? "");
|
|
58
57
|
}
|
|
59
|
-
function validate() {
|
|
60
|
-
if (!value) return toNonInvalid(neutral);
|
|
58
|
+
function validate(oninvalid?: boolean) {
|
|
59
|
+
if (!value && !oninvalid) return toNonInvalid(neutral);
|
|
61
60
|
for (const v of validations) {
|
|
62
61
|
const msg = v(value, element?.validity);
|
|
63
62
|
if (msg) return toInvalid(msg);
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
function oninvalid(ev: Event & SelectFieldTarget) {
|
|
77
76
|
attributes?.oninvalid?.(ev);
|
|
78
77
|
ev.preventDefault();
|
|
79
|
-
validate();
|
|
78
|
+
validate(true);
|
|
80
79
|
if (status !== STATE.INACTIVE) toInvalid(element?.validationMessage);
|
|
81
80
|
}
|
|
82
81
|
</script>
|
|
@@ -10,7 +10,7 @@ export type SelectFieldProps = {
|
|
|
10
10
|
descFirst?: boolean;
|
|
11
11
|
validations?: ((value: string, validity?: ValidityState) => string)[];
|
|
12
12
|
status?: string;
|
|
13
|
-
style?:
|
|
13
|
+
style?: SVSStyle;
|
|
14
14
|
attributes?: HTMLSelectAttributes;
|
|
15
15
|
action?: Action;
|
|
16
16
|
element?: HTMLSelectElement;
|
|
@@ -21,7 +21,7 @@ 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 HTMLSelectAttributes } from "svelte/elements";
|
|
24
|
-
import { type
|
|
24
|
+
import { type SVSStyle } from "./core";
|
|
25
25
|
declare const SelectField: import("svelte").Component<SelectFieldProps, {}, "value" | "status" | "element">;
|
|
26
26
|
type SelectField = ReturnType<typeof SelectField>;
|
|
27
27
|
export default SelectField;
|
package/_svseeds/_Slider.svelte
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
options?: SvelteSet<number> | Set<number>,
|
|
9
9
|
background?: Range, // <{ min: 5, max: 95 }>
|
|
10
10
|
status?: string, // bindable <STATE.DEFAULT>
|
|
11
|
-
style?:
|
|
11
|
+
style?: SVSStyle,
|
|
12
12
|
attributes?: HTMLInputAttributes,
|
|
13
13
|
action?: Action,
|
|
14
14
|
element?: HTMLInputElement, // bindable
|
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
export type SliderBindProps = "min" | "max" | "value" | "status" | "element";
|
|
18
18
|
export type Range = { min: number, max: number };
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
const preset: ClassRuleSet = {};
|
|
20
|
+
const preset = "svs-slider";
|
|
22
21
|
|
|
23
22
|
import { type Snippet } from "svelte";
|
|
24
23
|
import { type Action } from "svelte/action";
|
|
25
24
|
import { type SvelteSet } from "svelte/reactivity";
|
|
26
25
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
27
|
-
import { type
|
|
26
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass, omit } from "./core";
|
|
28
27
|
</script>
|
|
29
28
|
|
|
30
29
|
<script lang="ts">
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
|
|
33
32
|
// *** Initialize *** //
|
|
34
33
|
if (!status) status = STATE.DEFAULT;
|
|
35
|
-
const cls = fnClass(
|
|
34
|
+
const cls = fnClass(preset, style);
|
|
36
35
|
const idList = elemId.get(options?.size);
|
|
37
36
|
const attrs = omit(attributes, "class", "type", "value", "min", "max", "step", "list");
|
|
38
37
|
if (range.min > range.max) range = { min: range.max, max: range.min };
|
|
@@ -7,7 +7,7 @@ export type SliderProps = {
|
|
|
7
7
|
options?: SvelteSet<number> | Set<number>;
|
|
8
8
|
background?: Range;
|
|
9
9
|
status?: string;
|
|
10
|
-
style?:
|
|
10
|
+
style?: SVSStyle;
|
|
11
11
|
attributes?: HTMLInputAttributes;
|
|
12
12
|
action?: Action;
|
|
13
13
|
element?: HTMLInputElement;
|
|
@@ -22,7 +22,7 @@ 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 SVSStyle } from "./core";
|
|
26
26
|
declare const Slider: import("svelte").Component<SliderProps, {}, "value" | "status" | "range" | "element">;
|
|
27
27
|
type Slider = ReturnType<typeof Slider>;
|
|
28
28
|
export default Slider;
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
const confirmTime = 500 // (ms) define how long to hover on item to confirm
|
|
7
7
|
const triggerDrag: TriggerButton[] = ["main"]; // define draggable by which buttons
|
|
8
8
|
const triggerSelect: TriggerButton[] = ["main"]; // define selectable by which buttons (for multi select)
|
|
9
|
-
const
|
|
10
|
-
const preset: ClassRuleSet = {};
|
|
9
|
+
const preset = "svs-sortable";
|
|
11
10
|
|
|
12
11
|
/***************************************************************/
|
|
13
12
|
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
appendable?: boolean, // enable append when enter group area <false>
|
|
26
25
|
confirm?: boolean // enable confirm interval time to move items <false>
|
|
27
26
|
status?: string, // bindable <STATE.DEFAULT>
|
|
28
|
-
style?:
|
|
27
|
+
style?: SVSStyle,
|
|
29
28
|
};
|
|
30
29
|
export type SortableReqdProps = "items" | "item";
|
|
31
30
|
export type SortableBindProps = "status";
|
|
@@ -604,7 +603,7 @@
|
|
|
604
603
|
import { on } from "svelte/events";
|
|
605
604
|
import { type EasingFunction, crossfade } from "svelte/transition";
|
|
606
605
|
import { flip } from "svelte/animate";
|
|
607
|
-
import { type
|
|
606
|
+
import { type SVSStyle, STATE, AREA, fnClass, throttle } from "./core";
|
|
608
607
|
</script>
|
|
609
608
|
|
|
610
609
|
<script lang="ts">
|
|
@@ -612,7 +611,7 @@
|
|
|
612
611
|
|
|
613
612
|
// *** Initialize *** //
|
|
614
613
|
if (!status) status = STATE.DEFAULT;
|
|
615
|
-
const cls = fnClass(
|
|
614
|
+
const cls = fnClass(preset, style);
|
|
616
615
|
const group: KeyValue = SortableItems._newItem(name);
|
|
617
616
|
const elems: HTMLElement[] = [];
|
|
618
617
|
const shadow = new Shadow(ghost);
|
|
@@ -13,7 +13,7 @@ export type SortableProps = {
|
|
|
13
13
|
appendable?: boolean;
|
|
14
14
|
confirm?: boolean;
|
|
15
15
|
status?: string;
|
|
16
|
-
style?:
|
|
16
|
+
style?: SVSStyle;
|
|
17
17
|
};
|
|
18
18
|
export type SortableReqdProps = "items" | "item";
|
|
19
19
|
export type SortableBindProps = "status";
|
|
@@ -56,7 +56,7 @@ type KeyValue = {
|
|
|
56
56
|
};
|
|
57
57
|
type DragState = "ready" | "dragging" | "idle";
|
|
58
58
|
import { type Snippet } from "svelte";
|
|
59
|
-
import { type
|
|
59
|
+
import { type SVSStyle } from "./core";
|
|
60
60
|
declare const Sortable: import("svelte").Component<SortableProps, {}, "status">;
|
|
61
61
|
type Sortable = ReturnType<typeof Sortable>;
|
|
62
62
|
export default Sortable;
|
package/_svseeds/_Tabs.svelte
CHANGED
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
labels?: string[],
|
|
5
5
|
current?: number, // bindable <0>
|
|
6
6
|
status?: string, // bindable <STATE.DEFAULT>
|
|
7
|
-
style?:
|
|
7
|
+
style?: SVSStyle,
|
|
8
8
|
[key: string]: unknown | Snippet,
|
|
9
9
|
};
|
|
10
10
|
export type TabsReqdProps = never;
|
|
11
11
|
export type TabsBindProps = "current" | "status";
|
|
12
12
|
|
|
13
13
|
type NamedId = { id: string, name: string };
|
|
14
|
-
const
|
|
15
|
-
const preset: ClassRuleSet = {};
|
|
14
|
+
const preset = "svs-tabs";
|
|
16
15
|
const roleLabel = "label";
|
|
17
16
|
const rolePanel = "panel";
|
|
18
17
|
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
import { type Snippet } from "svelte";
|
|
34
|
-
import { type
|
|
33
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass } from "./core";
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
36
|
<script lang="ts">
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
|
|
40
39
|
// *** Initialize *** //
|
|
41
40
|
if (!status) status = STATE.DEFAULT;
|
|
42
|
-
const cls = fnClass(
|
|
41
|
+
const cls = fnClass(preset, style);
|
|
43
42
|
const isStrLabel = labels.length > 0;
|
|
44
43
|
const tabs = toNamedId(isStrLabel ? labels : getSnippetNames(roleLabel, rest));
|
|
45
44
|
const panels = toNamedId(getSnippetNames(rolePanel, rest));
|
|
@@ -3,13 +3,13 @@ export type TabsProps = {
|
|
|
3
3
|
labels?: string[];
|
|
4
4
|
current?: number;
|
|
5
5
|
status?: string;
|
|
6
|
-
style?:
|
|
6
|
+
style?: SVSStyle;
|
|
7
7
|
[key: string]: unknown | Snippet;
|
|
8
8
|
};
|
|
9
9
|
export type TabsReqdProps = never;
|
|
10
10
|
export type TabsBindProps = "current" | "status";
|
|
11
11
|
import { type Snippet } from "svelte";
|
|
12
|
-
import { type
|
|
12
|
+
import { type SVSStyle } from "./core";
|
|
13
13
|
declare const Tabs: import("svelte").Component<TabsProps, {}, "status" | "current">;
|
|
14
14
|
type Tabs = ReturnType<typeof Tabs>;
|
|
15
15
|
export default Tabs;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
descFirst?: boolean, // <false>
|
|
13
13
|
validations?: ((value: string, validity?: ValidityState) => string)[],
|
|
14
14
|
status?: string, // bindable <STATE.DEFAULT>
|
|
15
|
-
style?:
|
|
15
|
+
style?: SVSStyle,
|
|
16
16
|
attributes?: HTMLInputAttributes | HTMLTextareaAttributes,
|
|
17
17
|
action?: Action,
|
|
18
18
|
element?: HTMLInputElement | HTMLTextAreaElement, // bindable
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
export type TextFieldReqdProps = never;
|
|
21
21
|
export type TextFieldBindProps = "value" | "type" | "status" | "element";
|
|
22
22
|
|
|
23
|
-
const
|
|
24
|
-
const preset: ClassRuleSet = {};
|
|
23
|
+
const preset = "svs-text-field";
|
|
25
24
|
|
|
26
25
|
import { type Snippet, untrack } from "svelte";
|
|
27
26
|
import { type Action } from "svelte/action";
|
|
28
27
|
import { type SvelteSet } from "svelte/reactivity";
|
|
29
28
|
import { type HTMLInputAttributes, type HTMLTextareaAttributes } from "svelte/elements";
|
|
30
|
-
import { type
|
|
29
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass, isNeutral, omit } from "./core";
|
|
31
30
|
</script>
|
|
32
31
|
|
|
33
32
|
<script lang="ts">
|
|
@@ -35,7 +34,7 @@
|
|
|
35
34
|
|
|
36
35
|
// *** Initialize *** //
|
|
37
36
|
if (!status) status = STATE.DEFAULT;
|
|
38
|
-
const cls = fnClass(
|
|
37
|
+
const cls = fnClass(preset, style);
|
|
39
38
|
const id = attributes?.id ? attributes.id : elemId.get(label?.trim());
|
|
40
39
|
const idLabel = elemId.get(label?.trim());
|
|
41
40
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -57,8 +56,8 @@
|
|
|
57
56
|
message = msg ?? bottom;
|
|
58
57
|
element?.setCustomValidity(msg ?? "");
|
|
59
58
|
}
|
|
60
|
-
function validate() {
|
|
61
|
-
if (!value) return toNonInvalid(neutral);
|
|
59
|
+
function validate(oninvalid?: boolean) {
|
|
60
|
+
if (!value && !oninvalid) return toNonInvalid(neutral);
|
|
62
61
|
for (const v of validations) {
|
|
63
62
|
const msg = v(value, element?.validity);
|
|
64
63
|
if (msg) return toInvalid(msg);
|
|
@@ -84,7 +83,7 @@
|
|
|
84
83
|
function oninvalid(ev: Event) {
|
|
85
84
|
attributes?.oninvalid?.(ev as any);
|
|
86
85
|
ev.preventDefault();
|
|
87
|
-
validate();
|
|
86
|
+
validate(true);
|
|
88
87
|
if (status !== STATE.INACTIVE) toInvalid(element?.validationMessage);
|
|
89
88
|
}
|
|
90
89
|
</script>
|
|
@@ -11,7 +11,7 @@ export type TextFieldProps = {
|
|
|
11
11
|
descFirst?: boolean;
|
|
12
12
|
validations?: ((value: string, validity?: ValidityState) => string)[];
|
|
13
13
|
status?: string;
|
|
14
|
-
style?:
|
|
14
|
+
style?: SVSStyle;
|
|
15
15
|
attributes?: HTMLInputAttributes | HTMLTextareaAttributes;
|
|
16
16
|
action?: Action;
|
|
17
17
|
element?: HTMLInputElement | HTMLTextAreaElement;
|
|
@@ -22,7 +22,7 @@ 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, type HTMLTextareaAttributes } from "svelte/elements";
|
|
25
|
-
import { type
|
|
25
|
+
import { type SVSStyle } from "./core";
|
|
26
26
|
declare const TextField: import("svelte").Component<TextFieldProps, {}, "type" | "value" | "status" | "element">;
|
|
27
27
|
type TextField = ReturnType<typeof TextField>;
|
|
28
28
|
export default TextField;
|
package/_svseeds/_Toggle.svelte
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
value?: boolean, // bindable <true>
|
|
8
8
|
type?: "button" | "switch", // <"button">
|
|
9
9
|
status?: string, // bindable <STATE.DEFAULT>
|
|
10
|
-
style?:
|
|
10
|
+
style?: SVSStyle,
|
|
11
11
|
attributes?: HTMLButtonAttributes;
|
|
12
12
|
action?: Action,
|
|
13
13
|
element?: HTMLButtonElement, // bindable
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
export type ToggleBindProps = "value" | "status" | "element";
|
|
17
17
|
|
|
18
18
|
type ToggleTarget = { currentTarget: EventTarget & HTMLButtonElement };
|
|
19
|
-
const
|
|
20
|
-
const preset: ClassRuleSet = {};
|
|
19
|
+
const preset = "svs-toggle";
|
|
21
20
|
|
|
22
21
|
import { type Snippet, untrack } from "svelte";
|
|
23
22
|
import { type Action } from "svelte/action";
|
|
24
23
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
25
|
-
import { type
|
|
24
|
+
import { type SVSStyle, STATE, AREA, fnClass, isNeutral, omit } from "./core";
|
|
26
25
|
</script>
|
|
27
26
|
|
|
28
27
|
<script lang="ts">
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
|
|
31
30
|
// *** Initialize *** //
|
|
32
31
|
if (!status) status = STATE.DEFAULT;
|
|
33
|
-
const cls = fnClass(
|
|
32
|
+
const cls = fnClass(preset, style);
|
|
34
33
|
const attrs = omit(attributes, "class", "id", "type", "role", "aria-checked", "onclick");
|
|
35
34
|
let neutral = isNeutral(status) ? status : STATE.DEFAULT;
|
|
36
35
|
|
|
@@ -6,7 +6,7 @@ export type ToggleProps = {
|
|
|
6
6
|
value?: boolean;
|
|
7
7
|
type?: "button" | "switch";
|
|
8
8
|
status?: string;
|
|
9
|
-
style?:
|
|
9
|
+
style?: SVSStyle;
|
|
10
10
|
attributes?: HTMLButtonAttributes;
|
|
11
11
|
action?: Action;
|
|
12
12
|
element?: HTMLButtonElement;
|
|
@@ -16,7 +16,7 @@ export type ToggleBindProps = "value" | "status" | "element";
|
|
|
16
16
|
import { type Snippet } from "svelte";
|
|
17
17
|
import { type Action } from "svelte/action";
|
|
18
18
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
19
|
-
import { type
|
|
19
|
+
import { type SVSStyle } from "./core";
|
|
20
20
|
declare const Toggle: import("svelte").Component<ToggleProps, {}, "value" | "status" | "element">;
|
|
21
21
|
type Toggle = ReturnType<typeof Toggle>;
|
|
22
22
|
export default Toggle;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
descFirst?: boolean, // <false>
|
|
11
11
|
validations?: ((values: string[], validities?: ValidityState[]) => string)[],
|
|
12
12
|
status?: string, // bindable <STATE.DEFAULT>
|
|
13
|
-
style?:
|
|
13
|
+
style?: SVSStyle,
|
|
14
14
|
attributes?: HTMLButtonAttributes;
|
|
15
15
|
action?: Action,
|
|
16
16
|
elements?: HTMLButtonElement[], // bindable
|
|
@@ -19,14 +19,13 @@
|
|
|
19
19
|
export type TogglesFieldBindProps = "values" | "status" | "elements";
|
|
20
20
|
|
|
21
21
|
type TogglesFieldTarget = { currentTarget: EventTarget & HTMLButtonElement };
|
|
22
|
-
const
|
|
23
|
-
const preset: ClassRuleSet = {};
|
|
22
|
+
const preset = "svs-toggles-field";
|
|
24
23
|
|
|
25
24
|
import { type Snippet, untrack } from "svelte";
|
|
26
25
|
import { type Action } from "svelte/action";
|
|
27
26
|
import { type SvelteMap } from "svelte/reactivity";
|
|
28
27
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
29
|
-
import { type
|
|
28
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass, isNeutral, omit } from "./core";
|
|
30
29
|
</script>
|
|
31
30
|
|
|
32
31
|
<script lang="ts">
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
|
|
35
34
|
// *** Initialize *** //
|
|
36
35
|
if (!status) status = STATE.DEFAULT;
|
|
37
|
-
const cls = fnClass(
|
|
36
|
+
const cls = fnClass(preset, style);
|
|
38
37
|
const role = multiple ? "checkbox" : "radio";
|
|
39
38
|
const idLabel = elemId.get(label?.trim());
|
|
40
39
|
const idDesc = elemId.get(bottom?.trim());
|
|
@@ -58,8 +57,8 @@
|
|
|
58
57
|
message = stat === STATE.INACTIVE ? msg ?? bottom : bottom;
|
|
59
58
|
elem?.setCustomValidity(msg ?? "");
|
|
60
59
|
}
|
|
61
|
-
function validate() {
|
|
62
|
-
if (!values.length) return toNonInvalid();
|
|
60
|
+
function validate(oninvalid?: boolean) {
|
|
61
|
+
if (!values.length && !oninvalid) return toNonInvalid();
|
|
63
62
|
const validities = elements.map((x) => x.validity);
|
|
64
63
|
for (const v of validations) {
|
|
65
64
|
const msg = v(values, validities);
|
|
@@ -88,6 +87,7 @@
|
|
|
88
87
|
attributes?.oninvalid?.(ev as any);
|
|
89
88
|
ev.preventDefault();
|
|
90
89
|
phase.submit = true;
|
|
90
|
+
validate(true);
|
|
91
91
|
if (status !== STATE.INACTIVE) toInvalid(elem?.validationMessage);
|
|
92
92
|
}
|
|
93
93
|
</script>
|
|
@@ -9,7 +9,7 @@ export type TogglesFieldProps = {
|
|
|
9
9
|
descFirst?: boolean;
|
|
10
10
|
validations?: ((values: string[], validities?: ValidityState[]) => string)[];
|
|
11
11
|
status?: string;
|
|
12
|
-
style?:
|
|
12
|
+
style?: SVSStyle;
|
|
13
13
|
attributes?: HTMLButtonAttributes;
|
|
14
14
|
action?: Action;
|
|
15
15
|
elements?: HTMLButtonElement[];
|
|
@@ -20,7 +20,7 @@ import { type Snippet } from "svelte";
|
|
|
20
20
|
import { type Action } from "svelte/action";
|
|
21
21
|
import { type SvelteMap } from "svelte/reactivity";
|
|
22
22
|
import { type HTMLButtonAttributes } from "svelte/elements";
|
|
23
|
-
import { type
|
|
23
|
+
import { type SVSStyle } from "./core";
|
|
24
24
|
declare const TogglesField: import("svelte").Component<TogglesFieldProps, {}, "elements" | "status" | "values">;
|
|
25
25
|
type TogglesField = ReturnType<typeof TogglesField>;
|
|
26
26
|
export default TogglesField;
|
package/_svseeds/_Tooltip.svelte
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
align?: Align, // "center"
|
|
7
7
|
offset?: Vector, // <{ x: 0, y: 0 }>
|
|
8
8
|
status?: string, // bindable <STATE.DEFAULT>
|
|
9
|
-
style?:
|
|
9
|
+
style?: SVSStyle,
|
|
10
10
|
element?: HTMLDivElement, // bindable
|
|
11
11
|
};
|
|
12
12
|
export type TooltipReqdProps = never;
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
type valueof<T> = T[keyof T];
|
|
25
25
|
type Unlisten = () => void;
|
|
26
|
-
const
|
|
27
|
-
const preset: ClassRuleSet = {};
|
|
26
|
+
const preset = "svs-tooltip";
|
|
28
27
|
const INIT_VEC = { x: 0, y: 0 };
|
|
29
28
|
const VISIBLE = {
|
|
30
29
|
NONE: 0,
|
|
@@ -229,7 +228,7 @@
|
|
|
229
228
|
import { type Snippet, untrack } from "svelte";
|
|
230
229
|
import { on } from "svelte/events";
|
|
231
230
|
import { type Action, type ActionReturn } from "svelte/action";
|
|
232
|
-
import { type
|
|
231
|
+
import { type SVSStyle, STATE, AREA, elemId, fnClass, throttle } from "./core";
|
|
233
232
|
</script>
|
|
234
233
|
|
|
235
234
|
<script lang="ts">
|
|
@@ -237,7 +236,7 @@
|
|
|
237
236
|
|
|
238
237
|
// *** Initialize *** //
|
|
239
238
|
if (!status) status = STATE.DEFAULT;
|
|
240
|
-
const cls = fnClass(
|
|
239
|
+
const cls = fnClass(preset, style);
|
|
241
240
|
const id = core.register(name);
|
|
242
241
|
let point: Vector = $state.raw(INIT_VEC);
|
|
243
242
|
|
|
@@ -5,7 +5,7 @@ export type TooltipProps = {
|
|
|
5
5
|
align?: Align;
|
|
6
6
|
offset?: Vector;
|
|
7
7
|
status?: string;
|
|
8
|
-
style?:
|
|
8
|
+
style?: SVSStyle;
|
|
9
9
|
element?: HTMLDivElement;
|
|
10
10
|
};
|
|
11
11
|
export type TooltipReqdProps = never;
|
|
@@ -25,7 +25,7 @@ export type Position = "top" | "left" | "bottom" | "right";
|
|
|
25
25
|
export type Align = "start" | "center" | "end";
|
|
26
26
|
import { type Snippet } from "svelte";
|
|
27
27
|
import { type Action, type ActionReturn } from "svelte/action";
|
|
28
|
-
import { type
|
|
28
|
+
import { type SVSStyle } from "./core";
|
|
29
29
|
declare const Tooltip: import("svelte").Component<TooltipProps, {}, "status" | "element">;
|
|
30
30
|
type Tooltip = ReturnType<typeof Tooltip>;
|
|
31
31
|
export default Tooltip;
|
package/_svseeds/core.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { type
|
|
2
|
-
type ClassRule =
|
|
1
|
+
export { type SVSStyle, CONST, STATE, AREA, elemId, fnClass, isNeutral, omit, debounce, throttle, UniqueId, };
|
|
2
|
+
type ClassRule = Record<string, string>;
|
|
3
3
|
type ClassRuleSet = Partial<Record<string, ClassRule>>;
|
|
4
|
+
type SVSStyle = ClassRuleSet | ClassRule | string;
|
|
4
5
|
declare const CONST = "const";
|
|
5
6
|
declare const STATE: Readonly<{
|
|
6
7
|
DEFAULT: "default";
|
|
@@ -27,7 +28,7 @@ declare class UniqueId {
|
|
|
27
28
|
}
|
|
28
29
|
declare const elemId: UniqueId;
|
|
29
30
|
type ClassFn = (area: string, status: string) => string | undefined;
|
|
30
|
-
declare function fnClass(
|
|
31
|
+
declare function fnClass(preset: SVSStyle, style?: SVSStyle): ClassFn;
|
|
31
32
|
declare function isNeutral(status: string): boolean;
|
|
32
33
|
declare function omit<T extends object, K extends keyof T>(obj?: T, ...keys: K[]): Omit<T, K> | Record<string, never>;
|
|
33
34
|
declare function debounce<Args extends unknown[], R>(delay: number, fn: (...args: Args) => R): (...args: Args) => void;
|
package/_svseeds/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var i in r=arguments[e])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t},t.apply(this,arguments)},r=this&&this.__classPrivateFieldSet||function(t,r,e,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!i:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,e):i?i.value=e:r.set(t,e),e},e=this&&this.__classPrivateFieldGet||function(t,r,e,n){if("a"===e&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!n:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?n:"a"===e?n.call(t):n?n.value:r.get(t)},n=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,i=0,o=r.length;i<o;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return t.concat(n||Array.prototype.slice.call(r))};export{i as CONST,o as STATE,a as AREA,u as elemId,l as fnClass,
|
|
1
|
+
var t=this&&this.__assign||function(){return t=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var i in r=arguments[e])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t},t.apply(this,arguments)},r=this&&this.__classPrivateFieldSet||function(t,r,e,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?t!==r||!i:!r.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,e):i?i.value=e:r.set(t,e),e},e=this&&this.__classPrivateFieldGet||function(t,r,e,n){if("a"===e&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?t!==r||!n:!r.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?n:"a"===e?n.call(t):n?n.value:r.get(t)},n=this&&this.__spreadArray||function(t,r,e){if(e||2===arguments.length)for(var n,i=0,o=r.length;i<o;i++)!n&&i in r||(n||(n=Array.prototype.slice.call(r,0,i)),n[i]=r[i]);return t.concat(n||Array.prototype.slice.call(r))};export{i as CONST,o as STATE,a as AREA,u as elemId,l as fnClass,s as isNeutral,h as omit,v as debounce,d as throttle,c as UniqueId};var i="const",o=Object.freeze({DEFAULT:"default",ACTIVE:"active",INACTIVE:"inactive"}),a=Object.freeze({WHOLE:"whole",MIDDLE:"middle",MAIN:"main",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",LABEL:"label",AUX:"aux",EXTRA:"extra"}),c=function(){function t(t){void 0===t&&(t=4),i.add(this),c.set(this,new Set),u.set(this,4),t>2&&r(this,u,t,"f")}var i,o,a,c,u,l,f,s;return Object.defineProperty(t.prototype,"id",{get:function(){return this.get(!0)},enumerable:!1,configurable:!0}),t.prototype.get=function(t){if(t)return e(this,c,"f").size>1e4&&e(this,c,"f").clear(),e(this,i,"m",s).call(this)},o=t,c=new WeakMap,u=new WeakMap,i=new WeakSet,l=function(){return e(o,o,"f",a)[Math.trunc(Math.random()*e(o,o,"f",a).length)]},f=function(){var t=this;return String.fromCharCode.apply(String,Array(e(this,u,"f")).fill(null).map((function(){return e(t,i,"m",l).call(t)})))},s=function(){for(var t=e(this,i,"m",f).call(this);e(this,c,"f").has(t);)t=e(this,i,"m",f).call(this);return e(this,c,"f").add(t),t},a={value:n(n([],Array.from(Array(25).keys(),(function(t){return t+65})),!0),Array.from(Array(25).keys(),(function(t){return t+97})),!0)},t}(),u=new c;function l(t,r){var e,n=null!==(e=f(r))&&void 0!==e?e:f(t);return null==n?function(t,r){}:"string"==typeof n?function(t,r){return"".concat(n," ").concat(t," ").concat(r)}:function(t,r){return function(t,r,e){var n,a,c,u,l,f,s=null!==(a=null===(n=t[r])||void 0===n?void 0:n[i])&&void 0!==a?a:"",h=null!==(f=null!==(u=null===(c=t[r])||void 0===c?void 0:c[e])&&void 0!==u?u:null===(l=t[r])||void 0===l?void 0:l[o.DEFAULT])&&void 0!==f?f:"";if(!s&&!h)return;return"".concat(s).concat(s&&h?" ":"").concat(h)}(n,t,r)}}function f(t){if(null!=t){if("string"==typeof t)return t.trim()?t:void 0;var r=Object.values(t);if(r.length)return"string"!=typeof r[0]?t:Object.fromEntries(Object.entries(t).map((function(t){return[t[0],{const:t[1]}]})))}}function s(t){return t!==o.ACTIVE&&t!==o.INACTIVE}function h(r){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(!r)return{};var i=t({},r);return e.forEach((function(t){return delete i[t]})),i}function v(t,r){var e;return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];e&&clearTimeout(e),e=setTimeout((function(){r.call.apply(r,n([null],i,!1))}),t)}}function d(t,r){var e,i=0,o=function(){return Date.now()-i},a=function(t){r.call.apply(r,n([null],t,!1)),i=Date.now()};return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(!i)return a(r);clearTimeout(e),e=setTimeout((function(){o()>=t&&a(r)}),t-o())}}
|