svseeds 0.4.0 → 0.4.3
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 +31 -14
- package/_svseeds/Accordion.svelte.d.ts +20 -4
- package/_svseeds/DarkToggle.svelte +81 -41
- package/_svseeds/DarkToggle.svelte.d.ts +23 -4
- package/_svseeds/TagsInput.svelte +58 -28
- package/_svseeds/TagsInput.svelte.d.ts +34 -6
- package/_svseeds/TagsInputField.svelte +66 -33
- package/_svseeds/TagsInputField.svelte.d.ts +36 -4
- package/_svseeds/ToggleGroupField.svelte +59 -32
- package/_svseeds/ToggleGroupField.svelte.d.ts +30 -4
- package/_svseeds/_Badge.svelte +33 -17
- package/_svseeds/_Badge.svelte.d.ts +17 -2
- package/_svseeds/_Button.svelte +39 -20
- package/_svseeds/_Button.svelte.d.ts +20 -2
- package/_svseeds/_CheckField.svelte +54 -30
- package/_svseeds/_CheckField.svelte.d.ts +24 -2
- package/_svseeds/_ColorPicker.svelte +38 -17
- package/_svseeds/_ColorPicker.svelte.d.ts +21 -2
- package/_svseeds/_ComboBox.svelte +38 -20
- package/_svseeds/_ComboBox.svelte.d.ts +17 -2
- package/_svseeds/_ContextMenu.svelte +26 -12
- package/_svseeds/_ContextMenu.svelte.d.ts +15 -2
- package/_svseeds/_Disclosure.svelte +37 -21
- package/_svseeds/_Disclosure.svelte.d.ts +19 -3
- package/_svseeds/_HotkeyCapture.svelte +28 -13
- package/_svseeds/_HotkeyCapture.svelte.d.ts +16 -2
- package/_svseeds/_Modal.svelte +32 -15
- package/_svseeds/_Modal.svelte.d.ts +18 -3
- package/_svseeds/_ProgressTracker.svelte +31 -16
- package/_svseeds/_ProgressTracker.svelte.d.ts +16 -2
- package/_svseeds/_SelectField.svelte +53 -29
- package/_svseeds/_SelectField.svelte.d.ts +25 -2
- package/_svseeds/_Slider.svelte +43 -22
- package/_svseeds/_Slider.svelte.d.ts +22 -2
- package/_svseeds/_Sortable.svelte +57 -19
- package/_svseeds/_Sortable.svelte.d.ts +39 -2
- package/_svseeds/_Tabs.svelte +31 -17
- package/_svseeds/_Tabs.svelte.d.ts +16 -3
- package/_svseeds/_TextField.svelte +56 -31
- package/_svseeds/_TextField.svelte.d.ts +26 -2
- package/_svseeds/_Toggle.svelte +45 -25
- package/_svseeds/_Toggle.svelte.d.ts +21 -2
- package/_svseeds/_ToggleGroup.svelte +32 -15
- package/_svseeds/_ToggleGroup.svelte.d.ts +18 -2
- package/_svseeds/_Tooltip.svelte +32 -13
- package/_svseeds/_Tooltip.svelte.d.ts +20 -2
- package/_svseeds/core.d.ts +186 -8
- package/_svseeds/core.js +1 -1
- package/index.d.ts +24 -24
- package/index.js +3 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface CheckFieldProps {
|
|
2
2
|
options: SvelteMap<string, string> | Map<string, string>;
|
|
3
3
|
label?: string;
|
|
4
4
|
extra?: string;
|
|
@@ -13,7 +13,7 @@ export type CheckFieldProps = {
|
|
|
13
13
|
attributes?: HTMLInputAttributes;
|
|
14
14
|
action?: Action;
|
|
15
15
|
elements?: HTMLInputElement[];
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
17
|
export type CheckFieldReqdProps = "options";
|
|
18
18
|
export type CheckFieldBindProps = "values" | "status" | "elements";
|
|
19
19
|
export type CheckFieldValidation = (values: string[], validity: ValidityState) => string;
|
|
@@ -22,6 +22,28 @@ import { type Action } from "svelte/action";
|
|
|
22
22
|
import { type SvelteMap } from "svelte/reactivity";
|
|
23
23
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
24
24
|
import { type SVSStyle } from "./core";
|
|
25
|
+
/**
|
|
26
|
+
* default value: `<value>`
|
|
27
|
+
* ```ts
|
|
28
|
+
* interface CheckFieldProps {
|
|
29
|
+
* options: SvelteMap<string, string> | Map<string, string>;
|
|
30
|
+
* label?: string;
|
|
31
|
+
* extra?: string;
|
|
32
|
+
* aux?: Snippet<[string, string[], HTMLInputElement[]]>; // Snippet<[status,values,elements]>
|
|
33
|
+
* bottom?: string;
|
|
34
|
+
* descFirst?: boolean; // <false>
|
|
35
|
+
* values?: string[]; // bindable
|
|
36
|
+
* multiple?: boolean; // <true>
|
|
37
|
+
* validations?: CheckFieldValidation[];
|
|
38
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
39
|
+
* style?: SVSStyle;
|
|
40
|
+
* attributes?: HTMLInputAttributes;
|
|
41
|
+
* action?: Action;
|
|
42
|
+
* elements?: HTMLInputElement[]; // bindable
|
|
43
|
+
* }
|
|
44
|
+
* type CheckFieldValidation = (values: string[], validity: ValidityState) => string;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
25
47
|
declare const CheckField: import("svelte").Component<CheckFieldProps, {}, "elements" | "status" | "values">;
|
|
26
48
|
type CheckField = ReturnType<typeof CheckField>;
|
|
27
49
|
export default CheckField;
|
|
@@ -1,25 +1,46 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ColorPickerProps {
|
|
6
|
+
value?: string; // bindable <"#000000">
|
|
7
|
+
alpha?: number; // bindable <1>
|
|
8
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
9
|
+
style?: SVSStyle;
|
|
10
|
+
attributes?: HTMLInputAttributes;
|
|
11
|
+
action?: Action;
|
|
12
|
+
element?: HTMLInputElement; // bindable
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
```ts
|
|
16
|
+
type RgbColor = [number, number, number];
|
|
17
|
+
export function getHex(rgb: RgbColor): string
|
|
18
|
+
// getHex([255, 123, 34]) => "#ff7b22"
|
|
19
|
+
```
|
|
20
|
+
-->
|
|
1
21
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
value?: string
|
|
4
|
-
alpha?: number
|
|
5
|
-
status?: string
|
|
6
|
-
style?: SVSStyle
|
|
22
|
+
export interface ColorPickerProps {
|
|
23
|
+
value?: string; // bindable <"#000000">
|
|
24
|
+
alpha?: number; // bindable <1>
|
|
25
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
26
|
+
style?: SVSStyle;
|
|
7
27
|
attributes?: HTMLInputAttributes;
|
|
8
|
-
action?: Action
|
|
9
|
-
element?: HTMLInputElement
|
|
10
|
-
}
|
|
28
|
+
action?: Action;
|
|
29
|
+
element?: HTMLInputElement; // bindable
|
|
30
|
+
}
|
|
11
31
|
export type ColorPickerReqdProps = never;
|
|
12
32
|
export type ColorPickerBindProps = "value" | "alpha" | "status" | "element";
|
|
13
33
|
export function getHex(rgb: RgbColor): string {
|
|
14
|
-
if (!isValidRgb(rgb)) return
|
|
34
|
+
if (!isValidRgb(rgb)) return DEFAULT_COLOR;
|
|
15
35
|
return "#" + (1 << 24 | rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16).slice(1);
|
|
16
36
|
}
|
|
17
37
|
|
|
18
38
|
type RgbColor = [number, number, number];
|
|
39
|
+
const DEFAULT_COLOR = "#000000";
|
|
19
40
|
const preset = "svs-color-picker";
|
|
20
41
|
|
|
21
|
-
function
|
|
22
|
-
return
|
|
42
|
+
function castValidHex(hex: string): string | undefined {
|
|
43
|
+
return `#${formatHex(hex)?.filter((x) => x.length === 2).join("")}`;
|
|
23
44
|
}
|
|
24
45
|
function castHexToRgb(hex: string): RgbColor {
|
|
25
46
|
const rgb = formatHex(hex)?.filter((x) => x.length === 2);
|
|
@@ -41,17 +62,17 @@
|
|
|
41
62
|
|
|
42
63
|
import { type Action } from "svelte/action";
|
|
43
64
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
44
|
-
import { type SVSStyle, STATE,
|
|
65
|
+
import { type SVSStyle, STATE, PARTS, fnClass, omit } from "./core";
|
|
45
66
|
</script>
|
|
46
67
|
|
|
47
68
|
<script lang="ts">
|
|
48
|
-
let { value = $bindable(
|
|
69
|
+
let { value = $bindable(DEFAULT_COLOR), alpha = $bindable(1), status = $bindable(""), style, attributes, action, element = $bindable() }: ColorPickerProps = $props();
|
|
49
70
|
|
|
50
71
|
// *** Initialize *** //
|
|
51
|
-
if (!status) status = STATE.
|
|
72
|
+
if (!status) status = STATE.NEUTRAL;
|
|
52
73
|
const cls = fnClass(preset, style);
|
|
53
74
|
const attrs = omit(attributes, "type");
|
|
54
|
-
|
|
75
|
+
value = castValidHex(value) ?? DEFAULT_COLOR;
|
|
55
76
|
|
|
56
77
|
// *** Bind Handlers *** //
|
|
57
78
|
let rgb = $derived(castHexToRgb(value));
|
|
@@ -60,9 +81,9 @@
|
|
|
60
81
|
|
|
61
82
|
<!---------------------------------------->
|
|
62
83
|
|
|
63
|
-
<label class={cls(
|
|
84
|
+
<label class={cls(PARTS.WHOLE, status)}>
|
|
64
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;">
|
|
65
|
-
<div class={cls(
|
|
86
|
+
<div class={cls(PARTS.MAIN, status)} style={`background-color: rgba(${rgb[0]},${rgb[1]},${rgb[2]},${alp})`}>
|
|
66
87
|
{#if action}
|
|
67
88
|
<input bind:value bind:this={element} type="color" style="visibility: hidden;" {...attrs} use:action />
|
|
68
89
|
{:else}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ColorPickerProps {
|
|
2
2
|
value?: string;
|
|
3
3
|
alpha?: number;
|
|
4
4
|
status?: string;
|
|
@@ -6,7 +6,7 @@ export type ColorPickerProps = {
|
|
|
6
6
|
attributes?: HTMLInputAttributes;
|
|
7
7
|
action?: Action;
|
|
8
8
|
element?: HTMLInputElement;
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
export type ColorPickerReqdProps = never;
|
|
11
11
|
export type ColorPickerBindProps = "value" | "alpha" | "status" | "element";
|
|
12
12
|
export declare function getHex(rgb: RgbColor): string;
|
|
@@ -14,6 +14,25 @@ type RgbColor = [number, number, number];
|
|
|
14
14
|
import { type Action } from "svelte/action";
|
|
15
15
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
16
16
|
import { type SVSStyle } from "./core";
|
|
17
|
+
/**
|
|
18
|
+
* default value: `<value>`
|
|
19
|
+
* ```ts
|
|
20
|
+
* interface ColorPickerProps {
|
|
21
|
+
* value?: string; // bindable <"#000000">
|
|
22
|
+
* alpha?: number; // bindable <1>
|
|
23
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
24
|
+
* style?: SVSStyle;
|
|
25
|
+
* attributes?: HTMLInputAttributes;
|
|
26
|
+
* action?: Action;
|
|
27
|
+
* element?: HTMLInputElement; // bindable
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
* ```ts
|
|
31
|
+
* type RgbColor = [number, number, number];
|
|
32
|
+
* export function getHex(rgb: RgbColor): string
|
|
33
|
+
* // getHex([255, 123, 34]) => "#ff7b22"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
17
36
|
declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "alpha" | "value" | "status" | "element">;
|
|
18
37
|
type ColorPicker = ReturnType<typeof ColorPicker>;
|
|
19
38
|
export default ColorPicker;
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ComboBoxProps {
|
|
6
|
+
options: SvelteSet<string> | Set<string>;
|
|
7
|
+
value?: string; // bindable
|
|
8
|
+
expanded?: boolean; // bindable
|
|
9
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
10
|
+
style?: SVSStyle;
|
|
11
|
+
attributes?: HTMLInputAttributes;
|
|
12
|
+
action?: Action;
|
|
13
|
+
element?: HTMLInputElement; // bindable
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
-->
|
|
1
17
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
options: SvelteSet<string> | Set<string
|
|
4
|
-
value?: string
|
|
5
|
-
expanded?: boolean
|
|
6
|
-
status?: string
|
|
7
|
-
style?: SVSStyle
|
|
8
|
-
attributes?: HTMLInputAttributes
|
|
9
|
-
action?: Action
|
|
10
|
-
element?: HTMLInputElement
|
|
11
|
-
}
|
|
18
|
+
export interface ComboBoxProps {
|
|
19
|
+
options: SvelteSet<string> | Set<string>;
|
|
20
|
+
value?: string; // bindable
|
|
21
|
+
expanded?: boolean; // bindable
|
|
22
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
23
|
+
style?: SVSStyle;
|
|
24
|
+
attributes?: HTMLInputAttributes;
|
|
25
|
+
action?: Action;
|
|
26
|
+
element?: HTMLInputElement; // bindable
|
|
27
|
+
}
|
|
12
28
|
export type ComboBoxReqdProps = "options";
|
|
13
29
|
export type ComboBoxBindProps = "value" | "expanded" | "status" | "element";
|
|
14
30
|
|
|
@@ -20,14 +36,14 @@
|
|
|
20
36
|
import { type Action } from "svelte/action";
|
|
21
37
|
import { type SvelteSet } from "svelte/reactivity";
|
|
22
38
|
import { type HTMLInputAttributes } from "svelte/elements";
|
|
23
|
-
import { type SVSStyle, STATE,
|
|
39
|
+
import { type SVSStyle, STATE, PARTS, elemId, fnClass, omit } from "./core";
|
|
24
40
|
</script>
|
|
25
41
|
|
|
26
42
|
<script lang="ts">
|
|
27
43
|
let { options, value = $bindable(""), expanded = $bindable(false), status = $bindable(""), style, attributes, action, element = $bindable() }: ComboBoxProps = $props();
|
|
28
44
|
|
|
29
45
|
// *** Initialize *** //
|
|
30
|
-
if (!status) status = STATE.
|
|
46
|
+
if (!status) status = STATE.NEUTRAL;
|
|
31
47
|
const cls = fnClass(preset, style);
|
|
32
48
|
const idList = elemId.id;
|
|
33
49
|
const attrs = omit(attributes, "class", "type", "value", "list", "role", "aria-haspopup", "aria-autocomplete", "aria-controls", "aria-expanded");
|
|
@@ -52,7 +68,7 @@
|
|
|
52
68
|
function open(activate: boolean = false, bottom: boolean = false) {
|
|
53
69
|
if (expanded) return;
|
|
54
70
|
selected = opts.indexOf(value);
|
|
55
|
-
if (activate && selected === NA) selected = bottom ? opts.length
|
|
71
|
+
if (activate && selected === NA) selected = bottom ? opts.length - 1 : 0;
|
|
56
72
|
expanded = true;
|
|
57
73
|
}
|
|
58
74
|
function apply() {
|
|
@@ -79,32 +95,34 @@
|
|
|
79
95
|
if (alt && !expanded) return open();
|
|
80
96
|
if (alt && expanded) return;
|
|
81
97
|
if (!alt && !expanded) return open(true);
|
|
82
|
-
if (selected
|
|
98
|
+
if (selected < opts.length - 1) selected++;
|
|
99
|
+
if (selected === NA) selected = 0;
|
|
83
100
|
}
|
|
84
101
|
function caseArrowUp(alt: boolean) {
|
|
85
102
|
if (alt && !expanded) return;
|
|
86
103
|
if (alt && expanded) return close();
|
|
87
104
|
if (!alt && !expanded) return open(true, true);
|
|
88
|
-
if (selected
|
|
105
|
+
if (selected > 0) selected--;
|
|
106
|
+
if (selected === NA) selected = opts.length - 1;
|
|
89
107
|
}
|
|
90
108
|
</script>
|
|
91
109
|
|
|
92
110
|
<!---------------------------------------->
|
|
93
111
|
|
|
94
112
|
{#if options.size}
|
|
95
|
-
<div class={cls(
|
|
113
|
+
<div class={cls(PARTS.WHOLE, status)}>
|
|
96
114
|
<div style="position: relative; width: fit-content; height: fit-content;">
|
|
97
115
|
{#if action}
|
|
98
|
-
<input bind:value bind:this={element} class={cls(
|
|
116
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} use:action />
|
|
99
117
|
{:else}
|
|
100
|
-
<input bind:value bind:this={element} class={cls(
|
|
118
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" role="combobox" aria-haspopup="listbox" aria-autocomplete="none" aria-controls={idList} aria-expanded={expanded} onfocus={() => open()} onblur={close} {onkeydown} {...attrs} />
|
|
101
119
|
{/if}
|
|
102
|
-
<ul bind:this={listElem} class={cls(
|
|
120
|
+
<ul bind:this={listElem} class={cls(PARTS.BOTTOM, status)} id={idList} role="listbox" style={listboxStyle}>
|
|
103
121
|
{#each opts as opt, i (opt)}
|
|
104
122
|
{@const isSelected = i === selected}
|
|
105
123
|
{@const labelStatus = isSelected ? STATE.ACTIVE : status}
|
|
106
124
|
{@const onpointerenter = () => selected = i}
|
|
107
|
-
<li class={cls(
|
|
125
|
+
<li class={cls(PARTS.LABEL, labelStatus)} aria-selected={isSelected} role="option" style={optionStyle} onpointerdown={apply} {onpointerenter}>
|
|
108
126
|
{opt}
|
|
109
127
|
</li>
|
|
110
128
|
{/each}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ComboBoxProps {
|
|
2
2
|
options: SvelteSet<string> | Set<string>;
|
|
3
3
|
value?: string;
|
|
4
4
|
expanded?: boolean;
|
|
@@ -7,13 +7,28 @@ export type ComboBoxProps = {
|
|
|
7
7
|
attributes?: HTMLInputAttributes;
|
|
8
8
|
action?: Action;
|
|
9
9
|
element?: HTMLInputElement;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export type ComboBoxReqdProps = "options";
|
|
12
12
|
export type ComboBoxBindProps = "value" | "expanded" | "status" | "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
16
|
import { type SVSStyle } from "./core";
|
|
17
|
+
/**
|
|
18
|
+
* default value: `<value>`
|
|
19
|
+
* ```ts
|
|
20
|
+
* interface ComboBoxProps {
|
|
21
|
+
* options: SvelteSet<string> | Set<string>;
|
|
22
|
+
* value?: string; // bindable
|
|
23
|
+
* expanded?: boolean; // bindable
|
|
24
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
25
|
+
* style?: SVSStyle;
|
|
26
|
+
* attributes?: HTMLInputAttributes;
|
|
27
|
+
* action?: Action;
|
|
28
|
+
* element?: HTMLInputElement; // bindable
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
17
32
|
declare const ComboBox: import("svelte").Component<ComboBoxProps, {}, "expanded" | "value" | "status" | "element">;
|
|
18
33
|
type ComboBox = ReturnType<typeof ComboBox>;
|
|
19
34
|
export default ComboBox;
|
|
@@ -1,19 +1,33 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface ContextMenuProps {
|
|
6
|
+
children: Snippet;
|
|
7
|
+
open?: boolean; // bindable <false>; to observe state, not to control
|
|
8
|
+
lock?: boolean; // bindable <false>
|
|
9
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
10
|
+
style?: SVSStyle;
|
|
11
|
+
element?: HTMLElement; // bindable
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
-->
|
|
1
15
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
children: Snippet
|
|
4
|
-
open?: boolean
|
|
5
|
-
lock?: boolean
|
|
6
|
-
status?: string
|
|
7
|
-
style?: SVSStyle
|
|
8
|
-
element?: HTMLElement
|
|
9
|
-
}
|
|
16
|
+
export interface ContextMenuProps {
|
|
17
|
+
children: Snippet;
|
|
18
|
+
open?: boolean; // bindable <false>; to observe state, not to control
|
|
19
|
+
lock?: boolean; // bindable <false>
|
|
20
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
21
|
+
style?: SVSStyle;
|
|
22
|
+
element?: HTMLElement; // bindable
|
|
23
|
+
}
|
|
10
24
|
export type ContextMenuReqdProps = "children";
|
|
11
25
|
export type ContextMenuBindProps = "open" | "lock" | "status" | "element";
|
|
12
26
|
|
|
13
27
|
const preset = "svs-context-menu";
|
|
14
28
|
|
|
15
29
|
import { type Snippet } from "svelte";
|
|
16
|
-
import { type SVSStyle, STATE,
|
|
30
|
+
import { type SVSStyle, STATE, PARTS, fnClass } from "./core";
|
|
17
31
|
</script>
|
|
18
32
|
|
|
19
33
|
<!---------------------------------------->
|
|
@@ -22,12 +36,12 @@
|
|
|
22
36
|
let { children, open = $bindable(false), lock = $bindable(false), status = $bindable(""), style, element = $bindable() }: ContextMenuProps = $props();
|
|
23
37
|
|
|
24
38
|
// *** Initialize *** //
|
|
25
|
-
if (!status) status = STATE.
|
|
39
|
+
if (!status) status = STATE.NEUTRAL;
|
|
26
40
|
const cls = fnClass(preset, style);
|
|
27
41
|
let position = $state({ x: 0, y: 0 });
|
|
28
42
|
|
|
29
43
|
// *** Bind Handlers *** //
|
|
30
|
-
let visibility = $derived(open ? "visibility:
|
|
44
|
+
let visibility = $derived(open ? "visibility: visible;" : "visibility: hidden; z-index: -9999;");
|
|
31
45
|
let dynStyle = $derived(`position: fixed; left:${position.x}px; top:${position.y}px; ${visibility}`);
|
|
32
46
|
|
|
33
47
|
// *** Event Handlers *** //
|
|
@@ -46,6 +60,6 @@
|
|
|
46
60
|
<!---------------------------------------->
|
|
47
61
|
<svelte:document oncontextmenu={show} onclick={hide} />
|
|
48
62
|
|
|
49
|
-
<nav class={cls(
|
|
63
|
+
<nav class={cls(PARTS.WHOLE, status)} style={dynStyle} bind:this={element}>
|
|
50
64
|
{@render children()}
|
|
51
65
|
</nav>
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ContextMenuProps {
|
|
2
2
|
children: Snippet;
|
|
3
3
|
open?: boolean;
|
|
4
4
|
lock?: boolean;
|
|
5
5
|
status?: string;
|
|
6
6
|
style?: SVSStyle;
|
|
7
7
|
element?: HTMLElement;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export type ContextMenuReqdProps = "children";
|
|
10
10
|
export type ContextMenuBindProps = "open" | "lock" | "status" | "element";
|
|
11
11
|
import { type Snippet } from "svelte";
|
|
12
12
|
import { type SVSStyle } from "./core";
|
|
13
|
+
/**
|
|
14
|
+
* default value: `<value>`
|
|
15
|
+
* ```ts
|
|
16
|
+
* interface ContextMenuProps {
|
|
17
|
+
* children: Snippet;
|
|
18
|
+
* open?: boolean; // bindable <false>; to observe state, not to control
|
|
19
|
+
* lock?: boolean; // bindable <false>
|
|
20
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
21
|
+
* style?: SVSStyle;
|
|
22
|
+
* element?: HTMLElement; // bindable
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
13
26
|
declare const ContextMenu: import("svelte").Component<ContextMenuProps, {}, "open" | "status" | "element" | "lock">;
|
|
14
27
|
type ContextMenu = ReturnType<typeof ContextMenu>;
|
|
15
28
|
export default ContextMenu;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface DisclosureProps {
|
|
6
|
+
label: string | Snippet<[string]>; // Snippet<[status]>
|
|
7
|
+
children: Snippet;
|
|
8
|
+
open?: boolean; // bindable <false>
|
|
9
|
+
duration?: number; // <400>
|
|
10
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
11
|
+
style?: SVSStyle;
|
|
12
|
+
attributes?: HTMLDetailsAttributes;
|
|
13
|
+
action?: Action;
|
|
14
|
+
element?: HTMLDetailsElement; // bindable
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
-->
|
|
1
18
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
label: string | Snippet<[string]
|
|
4
|
-
children: Snippet
|
|
5
|
-
open?: boolean
|
|
6
|
-
duration?: number
|
|
7
|
-
status?: string
|
|
8
|
-
style?: SVSStyle
|
|
19
|
+
export interface DisclosureProps {
|
|
20
|
+
label: string | Snippet<[string]>; // Snippet<[status]>
|
|
21
|
+
children: Snippet;
|
|
22
|
+
open?: boolean; // bindable <false>
|
|
23
|
+
duration?: number; // <400>
|
|
24
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
25
|
+
style?: SVSStyle;
|
|
9
26
|
attributes?: HTMLDetailsAttributes;
|
|
10
|
-
action?: Action
|
|
11
|
-
element?: HTMLDetailsElement
|
|
12
|
-
}
|
|
27
|
+
action?: Action;
|
|
28
|
+
element?: HTMLDetailsElement; // bindable
|
|
29
|
+
}
|
|
13
30
|
export type DisclosureReqdProps = "label" | "children";
|
|
14
|
-
export type DisclosureBindProps = "open" | "status" | "
|
|
31
|
+
export type DisclosureBindProps = "open" | "status" | "element";
|
|
15
32
|
|
|
16
33
|
type DisclosureTarget = { currentTarget: EventTarget & HTMLDetailsElement };
|
|
17
34
|
const preset = "svs-disclosure";
|
|
@@ -32,21 +49,19 @@
|
|
|
32
49
|
import { type Action } from "svelte/action";
|
|
33
50
|
import { type HTMLDetailsAttributes } from "svelte/elements";
|
|
34
51
|
import { slide } from "svelte/transition";
|
|
35
|
-
import { type SVSStyle, STATE,
|
|
52
|
+
import { type SVSStyle, STATE, PARTS, fnClass, isNeutral, omit } from "./core";
|
|
36
53
|
</script>
|
|
37
54
|
|
|
38
55
|
<script lang="ts">
|
|
39
56
|
let { label, children, open = $bindable(false), duration = 400, status = $bindable(""), style, attributes, action, element = $bindable() }: DisclosureProps = $props();
|
|
40
57
|
|
|
41
58
|
// *** Initialize *** //
|
|
42
|
-
if (!status) status = STATE.
|
|
59
|
+
if (!status) status = STATE.NEUTRAL;
|
|
43
60
|
const cls = fnClass(preset, style);
|
|
44
61
|
const attrs = omit(attributes, "class", "open", "ontoggle");
|
|
45
62
|
const guard = new ToggleGurad();
|
|
46
63
|
let hidden = $state(!open);
|
|
47
|
-
let neutral = isNeutral(status) ? status : STATE.
|
|
48
|
-
const initOpen = () => { if (element) element.open = open };
|
|
49
|
-
$effect(() => untrack(() => initOpen()));
|
|
64
|
+
let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
|
|
50
65
|
|
|
51
66
|
// *** Bind Handlers *** //
|
|
52
67
|
$effect(() => { neutral = isNeutral(status) ? status : neutral });
|
|
@@ -83,22 +98,23 @@
|
|
|
83
98
|
open = true;
|
|
84
99
|
}
|
|
85
100
|
}
|
|
101
|
+
$effect(() => untrack(() => toggle(open)));
|
|
86
102
|
</script>
|
|
87
103
|
|
|
88
104
|
<!---------------------------------------->
|
|
89
105
|
|
|
90
106
|
{#if action}
|
|
91
|
-
<details bind:this={element} class={cls(
|
|
107
|
+
<details bind:this={element} class={cls(PARTS.WHOLE, status)} {ontoggle} {...attrs} use:action>
|
|
92
108
|
{@render inner()}
|
|
93
109
|
</details>
|
|
94
110
|
{:else}
|
|
95
|
-
<details bind:this={element} class={cls(
|
|
111
|
+
<details bind:this={element} class={cls(PARTS.WHOLE, status)} {ontoggle} {...attrs}>
|
|
96
112
|
{@render inner()}
|
|
97
113
|
</details>
|
|
98
114
|
{/if}
|
|
99
115
|
|
|
100
116
|
{#snippet inner()}
|
|
101
|
-
<summary class={cls(
|
|
117
|
+
<summary class={cls(PARTS.LABEL, status)} {onclick}>
|
|
102
118
|
{#if typeof label === "string"}
|
|
103
119
|
{label}
|
|
104
120
|
{:else if typeof label === "function"}
|
|
@@ -106,12 +122,12 @@
|
|
|
106
122
|
{/if}
|
|
107
123
|
</summary>
|
|
108
124
|
{#if open}
|
|
109
|
-
<div class={cls(
|
|
125
|
+
<div class={cls(PARTS.MAIN, status)} transition:slide={{ duration }}>
|
|
110
126
|
{@render children()}
|
|
111
127
|
</div>
|
|
112
128
|
{/if}
|
|
113
129
|
{#if hidden}
|
|
114
|
-
<div class={cls(
|
|
130
|
+
<div class={cls(PARTS.MAIN, status)}>
|
|
115
131
|
{@render children()}
|
|
116
132
|
</div>
|
|
117
133
|
{/if}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface DisclosureProps {
|
|
2
2
|
label: string | Snippet<[string]>;
|
|
3
3
|
children: Snippet;
|
|
4
4
|
open?: boolean;
|
|
@@ -8,13 +8,29 @@ export type DisclosureProps = {
|
|
|
8
8
|
attributes?: HTMLDetailsAttributes;
|
|
9
9
|
action?: Action;
|
|
10
10
|
element?: HTMLDetailsElement;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
export type DisclosureReqdProps = "label" | "children";
|
|
13
|
-
export type DisclosureBindProps = "open" | "status" | "
|
|
13
|
+
export type DisclosureBindProps = "open" | "status" | "element";
|
|
14
14
|
import { type Snippet } from "svelte";
|
|
15
15
|
import { type Action } from "svelte/action";
|
|
16
16
|
import { type HTMLDetailsAttributes } from "svelte/elements";
|
|
17
17
|
import { type SVSStyle } from "./core";
|
|
18
|
+
/**
|
|
19
|
+
* default value: `<value>`
|
|
20
|
+
* ```ts
|
|
21
|
+
* interface DisclosureProps {
|
|
22
|
+
* label: string | Snippet<[string]>; // Snippet<[status]>
|
|
23
|
+
* children: Snippet;
|
|
24
|
+
* open?: boolean; // bindable <false>
|
|
25
|
+
* duration?: number; // <400>
|
|
26
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
27
|
+
* style?: SVSStyle;
|
|
28
|
+
* attributes?: HTMLDetailsAttributes;
|
|
29
|
+
* action?: Action;
|
|
30
|
+
* element?: HTMLDetailsElement; // bindable
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
18
34
|
declare const Disclosure: import("svelte").Component<DisclosureProps, {}, "open" | "status" | "element">;
|
|
19
35
|
type Disclosure = ReturnType<typeof Disclosure>;
|
|
20
36
|
export default Disclosure;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
default value: `<value>`
|
|
4
|
+
```ts
|
|
5
|
+
interface HotkeyCaptureProps {
|
|
6
|
+
value?: string; // bindable
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
active?: boolean; // bindable, <false>
|
|
9
|
+
disabled?: boolean; // bindable, <false>
|
|
10
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
11
|
+
style?: SVSStyle;
|
|
12
|
+
element?: HTMLInputElement; // bindable
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
-->
|
|
1
16
|
<script module lang="ts">
|
|
2
|
-
export
|
|
3
|
-
value?: string
|
|
4
|
-
placeholder?: string
|
|
5
|
-
active?: boolean
|
|
6
|
-
disabled?: boolean
|
|
7
|
-
status?: string
|
|
8
|
-
style?: SVSStyle
|
|
9
|
-
element?: HTMLInputElement
|
|
10
|
-
}
|
|
17
|
+
export interface HotkeyCaptureProps {
|
|
18
|
+
value?: string; // bindable
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
active?: boolean; // bindable, <false>
|
|
21
|
+
disabled?: boolean; // bindable, <false>
|
|
22
|
+
status?: string; // bindable <STATE.NEUTRAL>
|
|
23
|
+
style?: SVSStyle;
|
|
24
|
+
element?: HTMLInputElement; // bindable
|
|
25
|
+
}
|
|
11
26
|
export type HotkeyCaptureReqdProps = never;
|
|
12
27
|
export type HotkeyCaptureBindProps = "value" | "active" | "disable" | "status" | "element";
|
|
13
28
|
|
|
@@ -21,16 +36,16 @@
|
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
import { untrack } from "svelte";
|
|
24
|
-
import { type SVSStyle, STATE,
|
|
39
|
+
import { type SVSStyle, STATE, PARTS, fnClass, isNeutral } from "./core";
|
|
25
40
|
</script>
|
|
26
41
|
|
|
27
42
|
<script lang="ts">
|
|
28
43
|
let { value = $bindable(""), placeholder, active = $bindable(false), disabled = $bindable(false), status = $bindable(""), style, element = $bindable() }: HotkeyCaptureProps = $props();
|
|
29
44
|
|
|
30
45
|
// *** Initialize *** //
|
|
31
|
-
if (!status) status = STATE.
|
|
46
|
+
if (!status) status = STATE.NEUTRAL;
|
|
32
47
|
const cls = fnClass(preset, style);
|
|
33
|
-
let neutral = isNeutral(status) ? status : STATE.
|
|
48
|
+
let neutral = isNeutral(status) ? status : STATE.NEUTRAL;
|
|
34
49
|
|
|
35
50
|
// *** Bind Handlers *** //
|
|
36
51
|
$effect(() => { neutral = isNeutral(status) ? status : neutral });
|
|
@@ -90,4 +105,4 @@
|
|
|
90
105
|
|
|
91
106
|
<!---------------------------------------->
|
|
92
107
|
|
|
93
|
-
<input bind:value bind:this={element} class={cls(
|
|
108
|
+
<input bind:value bind:this={element} class={cls(PARTS.MAIN, status)} type="text" readonly={true} {placeholder} {disabled} {onkeydown} {onpointerdown} {onwheel} {oncontextmenu} {onfocus} {onblur} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface HotkeyCaptureProps {
|
|
2
2
|
value?: string;
|
|
3
3
|
placeholder?: string;
|
|
4
4
|
active?: boolean;
|
|
@@ -6,10 +6,24 @@ export type HotkeyCaptureProps = {
|
|
|
6
6
|
status?: string;
|
|
7
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
12
|
import { type SVSStyle } from "./core";
|
|
13
|
+
/**
|
|
14
|
+
* default value: `<value>`
|
|
15
|
+
* ```ts
|
|
16
|
+
* interface HotkeyCaptureProps {
|
|
17
|
+
* value?: string; // bindable
|
|
18
|
+
* placeholder?: string;
|
|
19
|
+
* active?: boolean; // bindable, <false>
|
|
20
|
+
* disabled?: boolean; // bindable, <false>
|
|
21
|
+
* status?: string; // bindable <STATE.NEUTRAL>
|
|
22
|
+
* style?: SVSStyle;
|
|
23
|
+
* element?: HTMLInputElement; // bindable
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
13
27
|
declare const HotkeyCapture: import("svelte").Component<HotkeyCaptureProps, {}, "active" | "value" | "disabled" | "status" | "element">;
|
|
14
28
|
type HotkeyCapture = ReturnType<typeof HotkeyCapture>;
|
|
15
29
|
export default HotkeyCapture;
|