@geoffcox/sterling-svelte 0.0.20 → 0.0.22
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/Button.constants.d.ts +2 -0
- package/Button.constants.js +2 -0
- package/Button.svelte +11 -0
- package/Button.svelte.d.ts +10 -5
- package/Button.types.d.ts +6 -2
- package/Checkbox.svelte +16 -3
- package/Checkbox.svelte.d.ts +8 -0
- package/Dialog.svelte +2 -3
- package/Dropdown.svelte +11 -2
- package/Dropdown.svelte.d.ts +6 -0
- package/Field.constants.d.ts +1 -0
- package/Field.constants.js +1 -0
- package/Field.svelte +25 -10
- package/Field.svelte.d.ts +10 -4
- package/Field.types.d.ts +4 -1
- package/Input.svelte +27 -3
- package/Input.svelte.d.ts +12 -0
- package/Label.svelte +12 -2
- package/Label.svelte.d.ts +9 -1
- package/Link.constants.d.ts +1 -0
- package/Link.constants.js +1 -0
- package/Link.svelte +11 -0
- package/Link.svelte.d.ts +8 -3
- package/Link.types.d.ts +4 -1
- package/List.constants.d.ts +1 -1
- package/List.constants.js +1 -1
- package/List.svelte +13 -10
- package/List.svelte.d.ts +6 -2
- package/ListItem.svelte +11 -2
- package/ListItem.svelte.d.ts +6 -0
- package/Menu.svelte +46 -12
- package/Menu.svelte.d.ts +26 -0
- package/MenuBar.constants.d.ts +1 -0
- package/MenuBar.constants.js +1 -0
- package/MenuBar.svelte +12 -3
- package/MenuBar.svelte.d.ts +5 -1
- package/MenuBar.types.d.ts +4 -0
- package/MenuButton.svelte +45 -11
- package/MenuButton.svelte.d.ts +12 -4
- package/MenuItem.constants.d.ts +1 -0
- package/MenuItem.constants.js +1 -0
- package/MenuItem.svelte +20 -10
- package/MenuItem.svelte.d.ts +12 -3
- package/{Menus.types.d.ts → MenuItem.types.d.ts} +0 -4
- package/MenuItem.types.js +1 -0
- package/{Menus.utils.d.ts → MenuItem.utils.d.ts} +1 -1
- package/Progress.constants.d.ts +1 -0
- package/Progress.constants.js +1 -0
- package/Progress.svelte +16 -3
- package/Progress.svelte.d.ts +15 -3
- package/Progress.types.d.ts +4 -1
- package/Radio.svelte +16 -3
- package/Radio.svelte.d.ts +8 -0
- package/Select.svelte +17 -3
- package/Select.svelte.d.ts +10 -0
- package/Slider.svelte +9 -0
- package/Slider.svelte.d.ts +6 -0
- package/Switch.svelte +14 -3
- package/Switch.svelte.d.ts +6 -0
- package/Tab.svelte +11 -2
- package/Tab.svelte.d.ts +6 -0
- package/TabList.constants.d.ts +1 -1
- package/TabList.constants.js +1 -1
- package/TabList.svelte +8 -2
- package/TabList.svelte.d.ts +4 -0
- package/TextArea.constants.d.ts +1 -0
- package/TextArea.constants.js +1 -0
- package/TextArea.svelte +22 -0
- package/TextArea.svelte.d.ts +13 -2
- package/TextArea.types.d.ts +4 -1
- package/Tooltip.constants.d.ts +1 -0
- package/Tooltip.constants.js +1 -0
- package/Tooltip.svelte +26 -10
- package/Tooltip.svelte.d.ts +7 -3
- package/Tooltip.types.d.ts +4 -3
- package/Tree.constants.d.ts +2 -2
- package/Tree.constants.js +2 -2
- package/Tree.svelte +41 -7
- package/Tree.svelte.d.ts +34 -1
- package/Tree.types.d.ts +4 -16
- package/TreeChevron.svelte +33 -2
- package/TreeChevron.svelte.d.ts +27 -0
- package/TreeItem.svelte +76 -52
- package/TreeItem.svelte.d.ts +26 -3
- package/TreeItem.types.d.ts +13 -0
- package/TreeItem.types.js +1 -0
- package/TreeItemDisplay.svelte +12 -0
- package/TreeItemDisplay.svelte.d.ts +6 -0
- package/floating-ui.constants.d.ts +1 -0
- package/floating-ui.constants.js +14 -0
- package/floating-ui.types.d.ts +2 -0
- package/floating-ui.types.js +1 -0
- package/idGenerator.d.ts +4 -0
- package/idGenerator.js +10 -0
- package/index.d.ts +19 -7
- package/index.js +14 -5
- package/package.json +21 -11
- package/theme/toggleDarkTheme.d.ts +1 -1
- package/theme/toggleDarkTheme.js +1 -1
- package/Menus.constants.d.ts +0 -2
- package/Menus.constants.js +0 -2
- /package/{Menus.types.js → MenuBar.types.js} +0 -0
- /package/{Menus.utils.js → MenuItem.utils.js} +0 -0
package/Radio.svelte
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script>import { onMount } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { idGenerator } from "./idGenerator";
|
|
3
3
|
import Label from "./Label.svelte";
|
|
4
4
|
export let checked = false;
|
|
5
5
|
export let disabled = false;
|
|
6
6
|
export let group = void 0;
|
|
7
7
|
export let id = void 0;
|
|
8
8
|
let mounted = false;
|
|
9
|
+
let radioRef;
|
|
9
10
|
$: {
|
|
10
11
|
if ($$slots.default && id === void 0) {
|
|
11
|
-
id =
|
|
12
|
+
id = idGenerator.nextId("Radio");
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
$: {
|
|
@@ -21,6 +22,15 @@ const onChange = (e) => {
|
|
|
21
22
|
group = $$restProps.value;
|
|
22
23
|
}
|
|
23
24
|
};
|
|
25
|
+
export const blur = () => {
|
|
26
|
+
radioRef?.blur();
|
|
27
|
+
};
|
|
28
|
+
export const click = () => {
|
|
29
|
+
radioRef?.click();
|
|
30
|
+
};
|
|
31
|
+
export const focus = (options) => {
|
|
32
|
+
radioRef?.focus(options);
|
|
33
|
+
};
|
|
24
34
|
onMount(() => {
|
|
25
35
|
if (checked) {
|
|
26
36
|
group = $$restProps.value;
|
|
@@ -36,6 +46,7 @@ onMount(() => {
|
|
|
36
46
|
<div class="sterling-radio">
|
|
37
47
|
<div class="container">
|
|
38
48
|
<input
|
|
49
|
+
bind:this={radioRef}
|
|
39
50
|
checked={group === $$restProps.value}
|
|
40
51
|
{disabled}
|
|
41
52
|
{id}
|
|
@@ -68,7 +79,9 @@ onMount(() => {
|
|
|
68
79
|
{#if $$slots.default}
|
|
69
80
|
<div class="label">
|
|
70
81
|
<Label {disabled} for={id}>
|
|
71
|
-
<slot {checked} {disabled} {group}
|
|
82
|
+
<slot {checked} {disabled} {group} inputId={id} value={$$restProps.value}>
|
|
83
|
+
{$$restProps.value}
|
|
84
|
+
</slot>
|
|
72
85
|
</Label>
|
|
73
86
|
</div>
|
|
74
87
|
{/if}
|
package/Radio.svelte.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
group?: any | undefined | null;
|
|
8
8
|
id?: string | undefined;
|
|
9
|
+
blur?: (() => void) | undefined;
|
|
10
|
+
click?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
9
12
|
};
|
|
10
13
|
events: {
|
|
11
14
|
blur: FocusEvent;
|
|
@@ -36,6 +39,8 @@ declare const __propDef: {
|
|
|
36
39
|
checked: boolean;
|
|
37
40
|
disabled: boolean;
|
|
38
41
|
group: any;
|
|
42
|
+
inputId: string | undefined;
|
|
43
|
+
value: any;
|
|
39
44
|
};
|
|
40
45
|
};
|
|
41
46
|
};
|
|
@@ -44,5 +49,8 @@ export type RadioEvents = typeof __propDef.events;
|
|
|
44
49
|
export type RadioSlots = typeof __propDef.slots;
|
|
45
50
|
/** A styled HTML input type=radio element with optional label. */
|
|
46
51
|
export default class Radio extends SvelteComponentTyped<RadioProps, RadioEvents, RadioSlots> {
|
|
52
|
+
get blur(): () => void;
|
|
53
|
+
get click(): () => void;
|
|
54
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
47
55
|
}
|
|
48
56
|
export {};
|
package/Select.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>import { computePosition, flip, offset, shift, autoUpdate } from "@floating-ui/dom";
|
|
2
2
|
import { createEventDispatcher, onMount, tick } from "svelte";
|
|
3
|
-
import { v4 as uuid } from "uuid";
|
|
4
3
|
import { clickOutside } from "./actions/clickOutside";
|
|
4
|
+
import { idGenerator } from "./idGenerator";
|
|
5
5
|
import List from "./List.svelte";
|
|
6
|
-
const popupId =
|
|
6
|
+
const popupId = idGenerator.nextId("Select-popup");
|
|
7
7
|
export let composed = false;
|
|
8
8
|
export let disabled = false;
|
|
9
9
|
export let open = false;
|
|
@@ -47,6 +47,20 @@ $: {
|
|
|
47
47
|
tick().then(() => selectRef?.focus());
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
export const blur = () => {
|
|
51
|
+
selectRef?.blur();
|
|
52
|
+
};
|
|
53
|
+
export const click = () => {
|
|
54
|
+
selectRef?.click();
|
|
55
|
+
};
|
|
56
|
+
export const focus = (options) => {
|
|
57
|
+
selectRef?.focus();
|
|
58
|
+
};
|
|
59
|
+
export const scrollToSelectedItem = () => {
|
|
60
|
+
if (open) {
|
|
61
|
+
listRef?.scrollToSelectedItem();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
50
64
|
let mounted = false;
|
|
51
65
|
onMount(() => {
|
|
52
66
|
mounted = true;
|
|
@@ -192,7 +206,7 @@ const onListSelect = (event) => {
|
|
|
192
206
|
</slot>
|
|
193
207
|
</div>
|
|
194
208
|
<div class="button">
|
|
195
|
-
<slot name="button" {open}>
|
|
209
|
+
<slot name="button" {disabled} {open} {selectedValue}>
|
|
196
210
|
<div class="chevron" />
|
|
197
211
|
</slot>
|
|
198
212
|
</div>
|
package/Select.svelte.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ declare const __propDef: {
|
|
|
6
6
|
disabled?: boolean | undefined;
|
|
7
7
|
open?: boolean | undefined;
|
|
8
8
|
selectedValue?: string | undefined;
|
|
9
|
+
blur?: (() => void) | undefined;
|
|
10
|
+
click?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
12
|
+
scrollToSelectedItem?: (() => void) | undefined;
|
|
9
13
|
};
|
|
10
14
|
events: {
|
|
11
15
|
blur: FocusEvent;
|
|
@@ -40,7 +44,9 @@ declare const __propDef: {
|
|
|
40
44
|
selectedValue: string | undefined;
|
|
41
45
|
};
|
|
42
46
|
button: {
|
|
47
|
+
disabled: boolean;
|
|
43
48
|
open: boolean;
|
|
49
|
+
selectedValue: string | undefined;
|
|
44
50
|
};
|
|
45
51
|
default: {};
|
|
46
52
|
};
|
|
@@ -49,5 +55,9 @@ export type SelectProps = typeof __propDef.props;
|
|
|
49
55
|
export type SelectEvents = typeof __propDef.events;
|
|
50
56
|
export type SelectSlots = typeof __propDef.slots;
|
|
51
57
|
export default class Select extends SvelteComponentTyped<SelectProps, SelectEvents, SelectSlots> {
|
|
58
|
+
get blur(): () => void;
|
|
59
|
+
get click(): () => void;
|
|
60
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
61
|
+
get scrollToSelectedItem(): () => void;
|
|
52
62
|
}
|
|
53
63
|
export {};
|
package/Slider.svelte
CHANGED
|
@@ -9,6 +9,15 @@ export let step = void 0;
|
|
|
9
9
|
export let value = 0;
|
|
10
10
|
export let vertical = false;
|
|
11
11
|
let sliderRef;
|
|
12
|
+
export const blur = () => {
|
|
13
|
+
sliderRef?.blur();
|
|
14
|
+
};
|
|
15
|
+
export const click = () => {
|
|
16
|
+
sliderRef?.click();
|
|
17
|
+
};
|
|
18
|
+
export const focus = (options) => {
|
|
19
|
+
sliderRef?.focus();
|
|
20
|
+
};
|
|
12
21
|
const dispatch = createEventDispatcher();
|
|
13
22
|
const raiseChange = (newValue) => {
|
|
14
23
|
dispatch("change", { value: newValue });
|
package/Slider.svelte.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ declare const __propDef: {
|
|
|
10
10
|
step?: number | undefined;
|
|
11
11
|
value?: number | undefined;
|
|
12
12
|
vertical?: boolean | undefined;
|
|
13
|
+
blur?: (() => void) | undefined;
|
|
14
|
+
click?: (() => void) | undefined;
|
|
15
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
13
16
|
};
|
|
14
17
|
events: {
|
|
15
18
|
blur: FocusEvent;
|
|
@@ -48,5 +51,8 @@ export type SliderEvents = typeof __propDef.events;
|
|
|
48
51
|
export type SliderSlots = typeof __propDef.slots;
|
|
49
52
|
/** Slider lets the user chose a value within a min/max range by dragging a thumb button. */
|
|
50
53
|
export default class Slider extends SvelteComponentTyped<SliderProps, SliderEvents, SliderSlots> {
|
|
54
|
+
get blur(): () => void;
|
|
55
|
+
get click(): () => void;
|
|
56
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
51
57
|
}
|
|
52
58
|
export {};
|
package/Switch.svelte
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
import
|
|
1
|
+
<script>import Label from "./Label.svelte";
|
|
2
|
+
import { idGenerator } from "./idGenerator";
|
|
3
3
|
export let checked = false;
|
|
4
4
|
export let disabled = false;
|
|
5
5
|
export let vertical = false;
|
|
6
6
|
export let onText = void 0;
|
|
7
7
|
export let offText = void 0;
|
|
8
|
-
const inputId =
|
|
8
|
+
const inputId = idGenerator.nextId("Switch");
|
|
9
|
+
let inputRef;
|
|
9
10
|
let switchWidth = 0;
|
|
10
11
|
let switchHeight = 0;
|
|
11
12
|
let thumbWidth = 0;
|
|
@@ -22,6 +23,15 @@ $:
|
|
|
22
23
|
hasOffLabel = $$slots.offLabel || offText !== void 0 && offText.length > 0;
|
|
23
24
|
$:
|
|
24
25
|
hasOnLabel = $$slots.onLabel || onText !== void 0 && onText.length > 0;
|
|
26
|
+
export const blur = () => {
|
|
27
|
+
inputRef?.blur();
|
|
28
|
+
};
|
|
29
|
+
export const click = () => {
|
|
30
|
+
inputRef?.click();
|
|
31
|
+
};
|
|
32
|
+
export const focus = (options) => {
|
|
33
|
+
inputRef?.focus(options);
|
|
34
|
+
};
|
|
25
35
|
</script>
|
|
26
36
|
|
|
27
37
|
<!--
|
|
@@ -30,6 +40,7 @@ $:
|
|
|
30
40
|
-->
|
|
31
41
|
<div class="sterling-switch" class:vertical class:disabled>
|
|
32
42
|
<input
|
|
43
|
+
bind:this={inputRef}
|
|
33
44
|
bind:checked
|
|
34
45
|
{disabled}
|
|
35
46
|
id={inputId}
|
package/Switch.svelte.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ declare const __propDef: {
|
|
|
7
7
|
vertical?: boolean | undefined;
|
|
8
8
|
onText?: string | undefined;
|
|
9
9
|
offText?: string | undefined;
|
|
10
|
+
blur?: (() => void) | undefined;
|
|
11
|
+
click?: (() => void) | undefined;
|
|
12
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
10
13
|
};
|
|
11
14
|
events: {
|
|
12
15
|
blur: FocusEvent;
|
|
@@ -54,5 +57,8 @@ export type SwitchEvents = typeof __propDef.events;
|
|
|
54
57
|
export type SwitchSlots = typeof __propDef.slots;
|
|
55
58
|
/** A styled HTML input type=checkbox element. */
|
|
56
59
|
export default class Switch extends SvelteComponentTyped<SwitchProps, SwitchEvents, SwitchSlots> {
|
|
60
|
+
get blur(): () => void;
|
|
61
|
+
get click(): () => void;
|
|
62
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
57
63
|
}
|
|
58
64
|
export {};
|
package/Tab.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { getContext } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { TAB_LIST_CONTEXT_KEY } from "./TabList.constants";
|
|
3
3
|
export let disabled = false;
|
|
4
4
|
export let selected = false;
|
|
5
5
|
export let text = void 0;
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
selectedValue,
|
|
11
11
|
usingKeyboard,
|
|
12
12
|
vertical
|
|
13
|
-
} = getContext(
|
|
13
|
+
} = getContext(TAB_LIST_CONTEXT_KEY);
|
|
14
14
|
$:
|
|
15
15
|
_disabled = $tabListDisabled || disabled;
|
|
16
16
|
$: {
|
|
@@ -21,6 +21,15 @@ $: {
|
|
|
21
21
|
selectedValue.set(value);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
export const click = () => {
|
|
25
|
+
tabRef?.click();
|
|
26
|
+
};
|
|
27
|
+
export const blur = () => {
|
|
28
|
+
tabRef?.blur();
|
|
29
|
+
};
|
|
30
|
+
export const focus = (options) => {
|
|
31
|
+
tabRef?.focus(options);
|
|
32
|
+
};
|
|
24
33
|
</script>
|
|
25
34
|
|
|
26
35
|
<button
|
package/Tab.svelte.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ declare const __propDef: {
|
|
|
5
5
|
selected?: boolean | undefined;
|
|
6
6
|
text?: string | undefined;
|
|
7
7
|
value: string;
|
|
8
|
+
click?: (() => void) | undefined;
|
|
9
|
+
blur?: (() => void) | undefined;
|
|
10
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
8
11
|
};
|
|
9
12
|
events: {
|
|
10
13
|
blur: FocusEvent;
|
|
@@ -48,5 +51,8 @@ export type TabProps = typeof __propDef.props;
|
|
|
48
51
|
export type TabEvents = typeof __propDef.events;
|
|
49
52
|
export type TabSlots = typeof __propDef.slots;
|
|
50
53
|
export default class Tab extends SvelteComponentTyped<TabProps, TabEvents, TabSlots> {
|
|
54
|
+
get click(): () => void;
|
|
55
|
+
get blur(): () => void;
|
|
56
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
51
57
|
}
|
|
52
58
|
export {};
|
package/TabList.constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const TAB_LIST_CONTEXT_KEY = "sterlingTabList";
|
package/TabList.constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const TAB_LIST_CONTEXT_KEY = 'sterlingTabList';
|
package/TabList.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>import { createKeyborg } from "keyborg";
|
|
2
2
|
import { createEventDispatcher, onMount, setContext } from "svelte";
|
|
3
3
|
import { writable } from "svelte/store";
|
|
4
|
-
import {
|
|
4
|
+
import { TAB_LIST_CONTEXT_KEY } from "./TabList.constants";
|
|
5
5
|
export let disabled = false;
|
|
6
6
|
export let vertical = false;
|
|
7
7
|
export let selectedValue = void 0;
|
|
@@ -34,6 +34,12 @@ const raiseSelect = (value) => {
|
|
|
34
34
|
$: {
|
|
35
35
|
raiseSelect(selectedValue);
|
|
36
36
|
}
|
|
37
|
+
export const blur = () => {
|
|
38
|
+
tabListRef?.blur();
|
|
39
|
+
};
|
|
40
|
+
export const focus = (options) => {
|
|
41
|
+
tabListRef?.focus(options);
|
|
42
|
+
};
|
|
37
43
|
const isElementTab = (candidate) => {
|
|
38
44
|
return candidate && candidate.getAttribute("data-value") !== null && candidate.getAttribute("data-value") !== void 0 && candidate.getAttribute("role") === "tab";
|
|
39
45
|
};
|
|
@@ -166,7 +172,7 @@ const onKeydown = (event) => {
|
|
|
166
172
|
}
|
|
167
173
|
}
|
|
168
174
|
};
|
|
169
|
-
setContext(
|
|
175
|
+
setContext(TAB_LIST_CONTEXT_KEY, {
|
|
170
176
|
disabled: disabledStore,
|
|
171
177
|
selectedValue: selectedValueStore,
|
|
172
178
|
usingKeyboard: usingKeyboardStore,
|
package/TabList.svelte.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ declare const __propDef: {
|
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
vertical?: boolean | undefined;
|
|
7
7
|
selectedValue?: string | undefined;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
8
10
|
selectFirstTab?: (() => boolean) | undefined;
|
|
9
11
|
selectPreviousTab?: (() => boolean) | undefined;
|
|
10
12
|
selectNextTab?: (() => boolean) | undefined;
|
|
@@ -48,6 +50,8 @@ export type TabListProps = typeof __propDef.props;
|
|
|
48
50
|
export type TabListEvents = typeof __propDef.events;
|
|
49
51
|
export type TabListSlots = typeof __propDef.slots;
|
|
50
52
|
export default class TabList extends SvelteComponentTyped<TabListProps, TabListEvents, TabListSlots> {
|
|
53
|
+
get blur(): () => void;
|
|
54
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
51
55
|
get selectFirstTab(): () => boolean;
|
|
52
56
|
get selectPreviousTab(): () => boolean;
|
|
53
57
|
get selectNextTab(): () => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TEXT_AREA_RESIZES: readonly ["none", "horizontal", "vertical", "both"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TEXT_AREA_RESIZES = ['none', 'horizontal', 'vertical', 'both'];
|
package/TextArea.svelte
CHANGED
|
@@ -13,6 +13,28 @@ const onInput = () => {
|
|
|
13
13
|
};
|
|
14
14
|
$:
|
|
15
15
|
autoHeight, autoSetHeight();
|
|
16
|
+
export const blur = () => {
|
|
17
|
+
textAreaRef?.blur();
|
|
18
|
+
};
|
|
19
|
+
export const click = () => {
|
|
20
|
+
textAreaRef?.click();
|
|
21
|
+
};
|
|
22
|
+
export const focus = (options) => {
|
|
23
|
+
textAreaRef?.focus();
|
|
24
|
+
};
|
|
25
|
+
export const select = () => {
|
|
26
|
+
textAreaRef?.select();
|
|
27
|
+
};
|
|
28
|
+
export const setSelectionRange = (start, end, direction) => {
|
|
29
|
+
textAreaRef?.setSelectionRange(start, end, direction);
|
|
30
|
+
};
|
|
31
|
+
export const setRangeText = (replacement, start, end, selectionMode) => {
|
|
32
|
+
if (start && end) {
|
|
33
|
+
textAreaRef?.setRangeText(replacement, start, end, selectionMode);
|
|
34
|
+
} else {
|
|
35
|
+
textAreaRef?.setRangeText(replacement);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
16
38
|
</script>
|
|
17
39
|
|
|
18
40
|
<textarea
|
package/TextArea.svelte.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { TextAreaResize } from './TextArea.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
5
|
autoHeight?: boolean | undefined;
|
|
7
|
-
resize?:
|
|
6
|
+
resize?: "none" | "horizontal" | "vertical" | "both" | undefined;
|
|
8
7
|
value: string;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
click?: (() => void) | undefined;
|
|
10
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
11
|
+
select?: (() => void) | undefined;
|
|
12
|
+
setSelectionRange?: ((start: number | null, end: number | null, direction?: 'forward' | 'backward' | 'none') => void) | undefined;
|
|
13
|
+
setRangeText?: ((replacement: string, start?: number, end?: number, selectionMode?: SelectionMode) => void) | undefined;
|
|
9
14
|
};
|
|
10
15
|
events: {
|
|
11
16
|
blur: FocusEvent;
|
|
@@ -43,5 +48,11 @@ export type TextAreaProps = typeof __propDef.props;
|
|
|
43
48
|
export type TextAreaEvents = typeof __propDef.events;
|
|
44
49
|
export type TextAreaSlots = typeof __propDef.slots;
|
|
45
50
|
export default class TextArea extends SvelteComponentTyped<TextAreaProps, TextAreaEvents, TextAreaSlots> {
|
|
51
|
+
get blur(): () => void;
|
|
52
|
+
get click(): () => void;
|
|
53
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
54
|
+
get select(): () => void;
|
|
55
|
+
get setSelectionRange(): (start: number | null, end: number | null, direction?: "none" | "forward" | "backward" | undefined) => void;
|
|
56
|
+
get setRangeText(): (replacement: string, start?: number | undefined, end?: number | undefined, selectionMode?: SelectionMode | undefined) => void;
|
|
46
57
|
}
|
|
47
58
|
export {};
|
package/TextArea.types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TOOLTIP_SHOW_ONS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TOOLTIP_SHOW_ONS = ['hover', 'click'];
|
package/Tooltip.svelte
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
import { arrow, autoUpdate, computePosition, flip, offset } from "@floating-ui/dom";
|
|
3
3
|
import { onMount } from "svelte";
|
|
4
4
|
import { fade } from "svelte/transition";
|
|
5
|
-
export let
|
|
5
|
+
export let disabled = false;
|
|
6
|
+
export let showOn = void 0;
|
|
6
7
|
export let hoverDelayMilliseconds = 1e3;
|
|
7
8
|
export let open = false;
|
|
8
9
|
export let placement = "top";
|
|
9
10
|
export let portalTarget = void 0;
|
|
10
|
-
let
|
|
11
|
+
let originRef;
|
|
11
12
|
let tooltipRef;
|
|
12
13
|
let arrowRef;
|
|
13
14
|
let position = void 0;
|
|
14
15
|
$:
|
|
15
|
-
reference = $$slots.default ?
|
|
16
|
+
reference = $$slots.default ? originRef?.previousElementSibling : void 0;
|
|
16
17
|
const computeTooltipPosition = async () => {
|
|
17
18
|
if (reference && tooltipRef && arrowRef) {
|
|
18
19
|
const floatingOffset = Math.sqrt(2 * arrowRef.offsetWidth ** 2) / 2;
|
|
@@ -84,14 +85,29 @@ const getArrowOffsetStyle = (position2) => {
|
|
|
84
85
|
};
|
|
85
86
|
$:
|
|
86
87
|
arrowStyle = getArrowPlacementStyle(position) + getArrowOffsetStyle(position);
|
|
87
|
-
const show = () =>
|
|
88
|
+
const show = () => {
|
|
89
|
+
if (!disabled) {
|
|
90
|
+
open = true;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
88
93
|
const hide = () => open = false;
|
|
89
|
-
const toggle = () =>
|
|
94
|
+
const toggle = () => {
|
|
95
|
+
if (!disabled) {
|
|
96
|
+
open = !open;
|
|
97
|
+
} else {
|
|
98
|
+
open = false;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
90
101
|
const delayShow = () => {
|
|
91
102
|
hoverDelayMilliseconds === 0 ? show() : setTimeout(() => {
|
|
92
103
|
show();
|
|
93
104
|
}, hoverDelayMilliseconds);
|
|
94
105
|
};
|
|
106
|
+
$: {
|
|
107
|
+
if (disabled) {
|
|
108
|
+
hide();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
95
111
|
let cleanupAutoShowUpdate = () => {
|
|
96
112
|
};
|
|
97
113
|
const autoShowUpdate = () => {
|
|
@@ -100,7 +116,7 @@ const autoShowUpdate = () => {
|
|
|
100
116
|
};
|
|
101
117
|
const element = reference;
|
|
102
118
|
if (element) {
|
|
103
|
-
switch (
|
|
119
|
+
switch (showOn) {
|
|
104
120
|
case "click":
|
|
105
121
|
element.addEventListener("click", toggle);
|
|
106
122
|
cleanupAutoShowUpdate = () => element.removeEventListener("click", toggle);
|
|
@@ -116,7 +132,7 @@ const autoShowUpdate = () => {
|
|
|
116
132
|
}
|
|
117
133
|
};
|
|
118
134
|
$:
|
|
119
|
-
reference,
|
|
135
|
+
reference, showOn, autoShowUpdate();
|
|
120
136
|
let mounted = false;
|
|
121
137
|
onMount(() => {
|
|
122
138
|
mounted = true;
|
|
@@ -127,8 +143,8 @@ onMount(() => {
|
|
|
127
143
|
});
|
|
128
144
|
</script>
|
|
129
145
|
|
|
130
|
-
<slot />
|
|
131
|
-
<div class="sterling-tooltip-
|
|
146
|
+
<slot {disabled} {open} />
|
|
147
|
+
<div class="sterling-tooltip-origin" bind:this={originRef} />
|
|
132
148
|
|
|
133
149
|
{#if open}
|
|
134
150
|
<div
|
|
@@ -144,7 +160,7 @@ onMount(() => {
|
|
|
144
160
|
{/if}
|
|
145
161
|
|
|
146
162
|
<style>
|
|
147
|
-
.sterling-tooltip-
|
|
163
|
+
.sterling-tooltip-origin {
|
|
148
164
|
display: none;
|
|
149
165
|
width: 0;
|
|
150
166
|
height: 0;
|
package/Tooltip.svelte.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TooltipShowOn } from './Tooltip.types';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
|
|
5
|
+
disabled?: boolean | undefined;
|
|
6
|
+
showOn?: TooltipShowOn | undefined;
|
|
6
7
|
hoverDelayMilliseconds?: number | undefined;
|
|
7
8
|
open?: boolean | undefined;
|
|
8
9
|
placement?: import("@floating-ui/core").Placement | undefined;
|
|
@@ -12,7 +13,10 @@ declare const __propDef: {
|
|
|
12
13
|
[evt: string]: CustomEvent<any>;
|
|
13
14
|
};
|
|
14
15
|
slots: {
|
|
15
|
-
default: {
|
|
16
|
+
default: {
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
open: boolean;
|
|
19
|
+
};
|
|
16
20
|
tip: {};
|
|
17
21
|
};
|
|
18
22
|
};
|
package/Tooltip.types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export type
|
|
1
|
+
import type { TOOLTIP_SHOW_ONS } from './Tooltip.constants';
|
|
2
|
+
type TooltipShowOnTuple = typeof TOOLTIP_SHOW_ONS;
|
|
3
|
+
export type TooltipShowOn = TooltipShowOnTuple[number];
|
|
4
|
+
export {};
|
package/Tree.constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const
|
|
1
|
+
export declare const TREE_CONTEXT_KEY = "sterlingTree";
|
|
2
|
+
export declare const TREE_ITEM_CONTEXT_KEY = "sterlingTreeItem";
|
package/Tree.constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
1
|
+
export const TREE_CONTEXT_KEY = 'sterlingTree';
|
|
2
|
+
export const TREE_ITEM_CONTEXT_KEY = 'sterlingTreeItem';
|
package/Tree.svelte
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<script>import { createKeyborg } from "keyborg";
|
|
2
2
|
import { createEventDispatcher, onMount, setContext } from "svelte";
|
|
3
3
|
import { writable } from "svelte/store";
|
|
4
|
-
import {
|
|
4
|
+
import { TREE_CONTEXT_KEY } from "./Tree.constants";
|
|
5
5
|
export let composed = false;
|
|
6
6
|
export let disabled = false;
|
|
7
7
|
export let selectedValue = void 0;
|
|
8
8
|
export let expandedValues = [];
|
|
9
|
+
let treeRef;
|
|
9
10
|
const selectedValueStore = writable(selectedValue);
|
|
10
11
|
const expandedValuesStore = writable(expandedValues);
|
|
11
12
|
const disabledStore = writable(disabled);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
export const blur = () => {
|
|
14
|
+
treeRef?.blur();
|
|
15
|
+
};
|
|
16
|
+
export const focus = (options) => {
|
|
17
|
+
treeRef?.focus(options);
|
|
18
|
+
};
|
|
17
19
|
const dispatch = createEventDispatcher();
|
|
18
20
|
const raiseExpandCollapse = (expandedValues2) => {
|
|
19
21
|
dispatch("expandCollapse", { expandedValues: expandedValues2 });
|
|
@@ -49,18 +51,50 @@ onMount(() => {
|
|
|
49
51
|
keyborg.unsubscribe(keyborgHandler);
|
|
50
52
|
};
|
|
51
53
|
});
|
|
54
|
+
setContext(TREE_CONTEXT_KEY, {
|
|
55
|
+
expandedValues: expandedValuesStore,
|
|
56
|
+
selectedValue: selectedValueStore,
|
|
57
|
+
disabled: disabledStore
|
|
58
|
+
});
|
|
52
59
|
</script>
|
|
53
60
|
|
|
54
61
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
|
55
62
|
<div
|
|
63
|
+
bind:this={treeRef}
|
|
56
64
|
aria-disabled={disabled}
|
|
57
65
|
class="sterling-tree"
|
|
58
66
|
class:composed
|
|
59
67
|
class:disabled
|
|
60
68
|
class:using-keyboard={usingKeyboard}
|
|
61
69
|
role="tree"
|
|
70
|
+
on:blur
|
|
71
|
+
on:click
|
|
72
|
+
on:dblclick
|
|
73
|
+
on:focus
|
|
74
|
+
on:focusin
|
|
75
|
+
on:focusout
|
|
76
|
+
on:keydown
|
|
77
|
+
on:keypress
|
|
78
|
+
on:keyup
|
|
79
|
+
on:mousedown
|
|
80
|
+
on:mouseenter
|
|
81
|
+
on:mouseleave
|
|
82
|
+
on:mousemove
|
|
83
|
+
on:mouseover
|
|
84
|
+
on:mouseout
|
|
85
|
+
on:mouseup
|
|
86
|
+
on:pointercancel
|
|
87
|
+
on:pointerdown
|
|
88
|
+
on:pointerenter
|
|
89
|
+
on:pointerleave
|
|
90
|
+
on:pointermove
|
|
91
|
+
on:pointerover
|
|
92
|
+
on:pointerout
|
|
93
|
+
on:pointerup
|
|
94
|
+
on:wheel
|
|
95
|
+
{...$$restProps}
|
|
62
96
|
>
|
|
63
|
-
<slot />
|
|
97
|
+
<slot {composed} {disabled} />
|
|
64
98
|
</div>
|
|
65
99
|
|
|
66
100
|
<style>
|