@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/ListItem.svelte
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
<script>import { getContext } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { LIST_CONTEXT_KEY } from "./List.constants";
|
|
3
3
|
export let disabled = false;
|
|
4
4
|
export let value;
|
|
5
5
|
const {
|
|
6
6
|
disabled: listDisabled,
|
|
7
7
|
selectedValue,
|
|
8
8
|
horizontal
|
|
9
|
-
} = getContext(
|
|
9
|
+
} = getContext(LIST_CONTEXT_KEY);
|
|
10
10
|
let itemRef;
|
|
11
11
|
$:
|
|
12
12
|
_disabled = disabled || $listDisabled;
|
|
13
13
|
$:
|
|
14
14
|
selected = $selectedValue === value;
|
|
15
|
+
export const click = () => {
|
|
16
|
+
itemRef?.click();
|
|
17
|
+
};
|
|
18
|
+
export const blur = () => {
|
|
19
|
+
itemRef?.blur();
|
|
20
|
+
};
|
|
21
|
+
export const focus = (options) => {
|
|
22
|
+
itemRef?.focus(options);
|
|
23
|
+
};
|
|
15
24
|
</script>
|
|
16
25
|
|
|
17
26
|
<div
|
package/ListItem.svelte.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
disabled?: boolean | undefined;
|
|
6
6
|
value: string;
|
|
7
|
+
click?: (() => void) | undefined;
|
|
8
|
+
blur?: (() => void) | undefined;
|
|
9
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
7
10
|
};
|
|
8
11
|
events: {
|
|
9
12
|
blur: FocusEvent;
|
|
@@ -47,5 +50,8 @@ export type ListItemProps = typeof __propDef.props;
|
|
|
47
50
|
export type ListItemEvents = typeof __propDef.events;
|
|
48
51
|
export type ListItemSlots = typeof __propDef.slots;
|
|
49
52
|
export default class ListItem extends SvelteComponentTyped<ListItemProps, ListItemEvents, ListItemSlots> {
|
|
53
|
+
get click(): () => void;
|
|
54
|
+
get blur(): () => void;
|
|
55
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
50
56
|
}
|
|
51
57
|
export {};
|
package/Menu.svelte
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
<script>import { getContext, onMount } from "svelte";
|
|
2
2
|
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
3
3
|
import { portal } from "./actions/portal";
|
|
4
|
-
import {
|
|
4
|
+
import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
|
|
5
5
|
export let reference;
|
|
6
6
|
export let open = false;
|
|
7
7
|
let menuRef;
|
|
8
8
|
let menuPosition = { x: 0, y: 0 };
|
|
9
|
-
const { rootValue, depth = 0 } = getContext(
|
|
9
|
+
const { rootValue, depth = 0 } = getContext(MENU_ITEM_CONTEXT_KEY) || {};
|
|
10
|
+
export const blur = () => {
|
|
11
|
+
menuRef?.blur();
|
|
12
|
+
};
|
|
13
|
+
export const focus = (options) => {
|
|
14
|
+
menuRef?.focus(options);
|
|
15
|
+
};
|
|
10
16
|
const ensurePortalHost = () => {
|
|
11
17
|
let host = document.querySelector("#SterlingMenuPortal");
|
|
12
18
|
if (!host) {
|
|
@@ -60,19 +66,42 @@ onMount(() => {
|
|
|
60
66
|
|
|
61
67
|
{#if open}
|
|
62
68
|
<div
|
|
69
|
+
use:portal={{ target: portalTarget }}
|
|
63
70
|
class="sterling-menu-portal"
|
|
64
71
|
data-root-value={rootValue}
|
|
65
|
-
use:portal={{ target: portalTarget }}
|
|
66
72
|
>
|
|
67
73
|
<div
|
|
68
74
|
bind:this={menuRef}
|
|
69
75
|
class="sterling-menu"
|
|
70
76
|
role="menu"
|
|
71
77
|
class:open
|
|
78
|
+
on:blur
|
|
79
|
+
on:click
|
|
80
|
+
on:copy
|
|
81
|
+
on:cut
|
|
82
|
+
on:dblclick
|
|
83
|
+
on:focus
|
|
84
|
+
on:focusin
|
|
85
|
+
on:focusout
|
|
86
|
+
on:keydown
|
|
87
|
+
on:keypress
|
|
88
|
+
on:keyup
|
|
89
|
+
on:mousedown
|
|
90
|
+
on:mouseenter
|
|
91
|
+
on:mouseleave
|
|
92
|
+
on:mousemove
|
|
93
|
+
on:mouseover
|
|
94
|
+
on:mouseout
|
|
95
|
+
on:mouseup
|
|
96
|
+
on:scroll
|
|
97
|
+
on:wheel
|
|
98
|
+
on:paste
|
|
72
99
|
{...$$restProps}
|
|
73
100
|
style="left:{menuPosition.x}px; top:{menuPosition.y}px"
|
|
74
101
|
>
|
|
75
|
-
<
|
|
102
|
+
<div class="sterling-menu-content">
|
|
103
|
+
<slot />
|
|
104
|
+
</div>
|
|
76
105
|
</div>
|
|
77
106
|
</div>
|
|
78
107
|
{/if}
|
|
@@ -90,26 +119,31 @@ onMount(() => {
|
|
|
90
119
|
border-radius: var(--stsv-Common__border-radius);
|
|
91
120
|
border-style: var(--stsv-Common__border-style);
|
|
92
121
|
border-width: var(--stsv-Common__border-width);
|
|
122
|
+
box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
|
|
93
123
|
box-sizing: border-box;
|
|
124
|
+
display: grid;
|
|
125
|
+
grid-template-columns: 1fr;
|
|
126
|
+
grid-template-rows: 1fr;
|
|
127
|
+
height: fit-content;
|
|
128
|
+
left: 0;
|
|
129
|
+
max-height: calc(50vh);
|
|
130
|
+
overflow: scroll;
|
|
131
|
+
overscroll-behavior: contain;
|
|
132
|
+
padding: 0.25em;
|
|
94
133
|
position: absolute;
|
|
95
|
-
|
|
96
|
-
overflow: hidden;
|
|
134
|
+
top: 0;
|
|
97
135
|
width: max-content;
|
|
98
|
-
height: fit-content;
|
|
99
136
|
z-index: 1;
|
|
100
|
-
|
|
101
|
-
left: 0;
|
|
137
|
+
}
|
|
102
138
|
|
|
139
|
+
.sterling-menu-content {
|
|
103
140
|
display: grid;
|
|
104
141
|
grid-template-columns: 1fr;
|
|
105
142
|
grid-template-rows: auto;
|
|
106
143
|
row-gap: calc(2 * var(--stsv-Common__outline-width));
|
|
107
|
-
padding: 0.25em;
|
|
108
144
|
}
|
|
109
145
|
|
|
110
146
|
.sterling-menu.open {
|
|
111
147
|
display: grid;
|
|
112
|
-
grid-template-columns: 1fr;
|
|
113
|
-
grid-template-rows: 1fr;
|
|
114
148
|
}
|
|
115
149
|
</style>
|
package/Menu.svelte.d.ts
CHANGED
|
@@ -4,8 +4,32 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
reference: HTMLElement;
|
|
6
6
|
open?: boolean | undefined;
|
|
7
|
+
blur?: (() => void) | undefined;
|
|
8
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
7
9
|
};
|
|
8
10
|
events: {
|
|
11
|
+
blur: FocusEvent;
|
|
12
|
+
click: MouseEvent;
|
|
13
|
+
copy: ClipboardEvent;
|
|
14
|
+
cut: ClipboardEvent;
|
|
15
|
+
dblclick: MouseEvent;
|
|
16
|
+
focus: FocusEvent;
|
|
17
|
+
focusin: FocusEvent;
|
|
18
|
+
focusout: FocusEvent;
|
|
19
|
+
keydown: KeyboardEvent;
|
|
20
|
+
keypress: KeyboardEvent;
|
|
21
|
+
keyup: KeyboardEvent;
|
|
22
|
+
mousedown: MouseEvent;
|
|
23
|
+
mouseenter: MouseEvent;
|
|
24
|
+
mouseleave: MouseEvent;
|
|
25
|
+
mousemove: MouseEvent;
|
|
26
|
+
mouseover: MouseEvent;
|
|
27
|
+
mouseout: MouseEvent;
|
|
28
|
+
mouseup: MouseEvent;
|
|
29
|
+
scroll: Event;
|
|
30
|
+
wheel: WheelEvent;
|
|
31
|
+
paste: ClipboardEvent;
|
|
32
|
+
} & {
|
|
9
33
|
[evt: string]: CustomEvent<any>;
|
|
10
34
|
};
|
|
11
35
|
slots: {
|
|
@@ -16,5 +40,7 @@ export type MenuProps = typeof __propDef.props;
|
|
|
16
40
|
export type MenuEvents = typeof __propDef.events;
|
|
17
41
|
export type MenuSlots = typeof __propDef.slots;
|
|
18
42
|
export default class Menu extends SvelteComponentTyped<MenuProps, MenuEvents, MenuSlots> {
|
|
43
|
+
get blur(): () => void;
|
|
44
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
19
45
|
}
|
|
20
46
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MENU_BAR_CONTEXT_KEY = "sterlingMenuBar";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MENU_BAR_CONTEXT_KEY = 'sterlingMenuBar';
|
package/MenuBar.svelte
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script>import { createEventDispatcher, setContext } from "svelte";
|
|
2
|
-
import {
|
|
2
|
+
import { MENU_BAR_CONTEXT_KEY } from "./MenuBar.constants";
|
|
3
|
+
import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
|
|
3
4
|
import { writable } from "svelte/store";
|
|
5
|
+
let menuBarRef;
|
|
4
6
|
const dispatch = createEventDispatcher();
|
|
5
7
|
const raiseClose = (value) => {
|
|
6
8
|
dispatch("close", { value });
|
|
@@ -11,6 +13,12 @@ const raiseOpen = (value) => {
|
|
|
11
13
|
const raiseSelect = (value) => {
|
|
12
14
|
dispatch("select", { value });
|
|
13
15
|
};
|
|
16
|
+
export const blur = () => {
|
|
17
|
+
menuBarRef?.blur();
|
|
18
|
+
};
|
|
19
|
+
export const focus = (options) => {
|
|
20
|
+
menuBarRef?.focus(options);
|
|
21
|
+
};
|
|
14
22
|
const children = writable([]);
|
|
15
23
|
const openPreviousChild = (currentValue) => {
|
|
16
24
|
const index = $children?.findIndex((menuItem) => menuItem.value === currentValue);
|
|
@@ -34,7 +42,7 @@ const focusChild = (value) => {
|
|
|
34
42
|
$children[focusIndex].focus();
|
|
35
43
|
}
|
|
36
44
|
};
|
|
37
|
-
setContext(
|
|
45
|
+
setContext(MENU_ITEM_CONTEXT_KEY, {
|
|
38
46
|
register: (menuItem) => {
|
|
39
47
|
children.set([...$children, menuItem]);
|
|
40
48
|
},
|
|
@@ -49,13 +57,14 @@ setContext(menuItemContextKey, {
|
|
|
49
57
|
onOpen: raiseOpen,
|
|
50
58
|
onSelect: raiseSelect
|
|
51
59
|
});
|
|
52
|
-
setContext(
|
|
60
|
+
setContext(MENU_BAR_CONTEXT_KEY, {
|
|
53
61
|
openPreviousMenu: openPreviousChild,
|
|
54
62
|
openNextMenu: openNextChild
|
|
55
63
|
});
|
|
56
64
|
</script>
|
|
57
65
|
|
|
58
66
|
<div
|
|
67
|
+
bind:this={menuBarRef}
|
|
59
68
|
class="sterling-menu-bar"
|
|
60
69
|
role="menubar"
|
|
61
70
|
on:blur
|
package/MenuBar.svelte.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
[x: string]:
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
blur?: (() => void) | undefined;
|
|
6
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
5
7
|
};
|
|
6
8
|
events: {
|
|
7
9
|
blur: FocusEvent;
|
|
@@ -39,5 +41,7 @@ export type MenuBarProps = typeof __propDef.props;
|
|
|
39
41
|
export type MenuBarEvents = typeof __propDef.events;
|
|
40
42
|
export type MenuBarSlots = typeof __propDef.slots;
|
|
41
43
|
export default class MenuBar extends SvelteComponentTyped<MenuBarProps, MenuBarEvents, MenuBarSlots> {
|
|
44
|
+
get blur(): () => void;
|
|
45
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
42
46
|
}
|
|
43
47
|
export {};
|
package/MenuButton.svelte
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import { createEventDispatcher, getContext, setContext } from "svelte";
|
|
1
|
+
<script>import { createEventDispatcher, getContext, setContext } from "svelte";
|
|
3
2
|
import { writable } from "svelte/store";
|
|
4
3
|
import Button from "./Button.svelte";
|
|
5
4
|
import Menu from "./Menu.svelte";
|
|
6
|
-
import {
|
|
7
|
-
import { focusFirstChild, focusNextChild, focusPreviousChild } from "./
|
|
5
|
+
import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
|
|
6
|
+
import { focusFirstChild, focusNextChild, focusPreviousChild } from "./MenuItem.utils";
|
|
7
|
+
import { idGenerator } from "./idGenerator";
|
|
8
8
|
export let open = false;
|
|
9
9
|
export let shape = "rounded";
|
|
10
10
|
export let value;
|
|
11
11
|
export let variant = "regular";
|
|
12
|
-
const instanceId =
|
|
12
|
+
const instanceId = idGenerator.nextId("MenuButton");
|
|
13
|
+
let buttonRef;
|
|
13
14
|
let reference;
|
|
15
|
+
let prevOpen = open;
|
|
14
16
|
$:
|
|
15
17
|
menuId = `${value}-menu-${instanceId}`;
|
|
16
18
|
$:
|
|
@@ -32,7 +34,22 @@ const onClick = () => {
|
|
|
32
34
|
setTimeout(() => focusFirstChild($children), 10);
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
|
-
|
|
37
|
+
$: {
|
|
38
|
+
if (!open && open !== prevOpen) {
|
|
39
|
+
focus();
|
|
40
|
+
}
|
|
41
|
+
prevOpen = open;
|
|
42
|
+
}
|
|
43
|
+
export const click = () => {
|
|
44
|
+
buttonRef?.click();
|
|
45
|
+
};
|
|
46
|
+
export const blur = () => {
|
|
47
|
+
buttonRef?.blur();
|
|
48
|
+
};
|
|
49
|
+
export const focus = (options) => {
|
|
50
|
+
buttonRef?.focus(options);
|
|
51
|
+
};
|
|
52
|
+
setContext(MENU_ITEM_CONTEXT_KEY, {
|
|
36
53
|
rootValue: value,
|
|
37
54
|
depth: 1,
|
|
38
55
|
register: (menuItem) => {
|
|
@@ -57,6 +74,7 @@ setContext(menuItemContextKey, {
|
|
|
57
74
|
A Button that displays a context menu when clicked.
|
|
58
75
|
-->
|
|
59
76
|
<Button
|
|
77
|
+
bind:this={buttonRef}
|
|
60
78
|
aria-controls={menuId}
|
|
61
79
|
aria-expanded={open}
|
|
62
80
|
aria-haspopup={hasChildren}
|
|
@@ -93,10 +111,26 @@ setContext(menuItemContextKey, {
|
|
|
93
111
|
on:wheel
|
|
94
112
|
{...$$restProps}
|
|
95
113
|
>
|
|
96
|
-
<div bind:this={reference}>
|
|
97
|
-
<slot />
|
|
98
|
-
<Menu id={menuId} {reference} {open}>
|
|
99
|
-
<slot name="items" />
|
|
100
|
-
</Menu>
|
|
114
|
+
<div class="reference" bind:this={reference}>
|
|
115
|
+
<slot {shape} {variant} />
|
|
101
116
|
</div>
|
|
117
|
+
<Menu id={menuId} {reference} {open}>
|
|
118
|
+
<slot name="items" />
|
|
119
|
+
</Menu>
|
|
102
120
|
</Button>
|
|
121
|
+
|
|
122
|
+
<style>
|
|
123
|
+
.reference {
|
|
124
|
+
align-content: center;
|
|
125
|
+
align-items: center;
|
|
126
|
+
box-sizing: border-box;
|
|
127
|
+
display: inline-flex;
|
|
128
|
+
flex-direction: row;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
justify-items: center;
|
|
131
|
+
column-gap: 0.25em;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
text-overflow: ellipsis;
|
|
134
|
+
white-space: nowrap;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
package/MenuButton.svelte.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { ButtonShape, ButtonVariant } from './Button.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
6
5
|
open?: boolean | undefined;
|
|
7
|
-
shape?:
|
|
6
|
+
shape?: "circular" | "rounded" | "square" | undefined;
|
|
8
7
|
value: string;
|
|
9
|
-
variant?:
|
|
8
|
+
variant?: "regular" | "outline" | "ghost" | undefined;
|
|
9
|
+
click?: (() => void) | undefined;
|
|
10
|
+
blur?: (() => void) | undefined;
|
|
11
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
10
12
|
};
|
|
11
13
|
events: {
|
|
12
14
|
blur: FocusEvent;
|
|
@@ -41,7 +43,10 @@ declare const __propDef: {
|
|
|
41
43
|
[evt: string]: CustomEvent<any>;
|
|
42
44
|
};
|
|
43
45
|
slots: {
|
|
44
|
-
default: {
|
|
46
|
+
default: {
|
|
47
|
+
shape: "circular" | "rounded" | "square";
|
|
48
|
+
variant: "regular" | "outline" | "ghost";
|
|
49
|
+
};
|
|
45
50
|
items: {};
|
|
46
51
|
};
|
|
47
52
|
};
|
|
@@ -50,5 +55,8 @@ export type MenuButtonEvents = typeof __propDef.events;
|
|
|
50
55
|
export type MenuButtonSlots = typeof __propDef.slots;
|
|
51
56
|
/** A Button that displays a context menu when clicked. */
|
|
52
57
|
export default class MenuButton extends SvelteComponentTyped<MenuButtonProps, MenuButtonEvents, MenuButtonSlots> {
|
|
58
|
+
get click(): () => void;
|
|
59
|
+
get blur(): () => void;
|
|
60
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
53
61
|
}
|
|
54
62
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MENU_ITEM_CONTEXT_KEY = "sterlingMenuItem";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MENU_ITEM_CONTEXT_KEY = 'sterlingMenuItem';
|
package/MenuItem.svelte
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<script>import { createKeyborg } from "keyborg";
|
|
2
|
-
import { v4 as uuid } from "uuid";
|
|
3
2
|
import { getContext, onMount, setContext } from "svelte";
|
|
4
3
|
import { writable } from "svelte/store";
|
|
5
4
|
import { clickOutside } from "./actions/clickOutside";
|
|
6
5
|
import { afterUpdate, createEventDispatcher } from "svelte/internal";
|
|
7
6
|
import MenuItemDisplay from "./MenuItemDisplay.svelte";
|
|
8
|
-
import {
|
|
7
|
+
import { MENU_BAR_CONTEXT_KEY } from "./MenuBar.constants";
|
|
8
|
+
import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
|
|
9
9
|
import Menu from "./Menu.svelte";
|
|
10
10
|
import {
|
|
11
11
|
focusFirstChild,
|
|
12
12
|
focusLastChild,
|
|
13
13
|
focusNextChild,
|
|
14
14
|
focusPreviousChild
|
|
15
|
-
} from "./
|
|
15
|
+
} from "./MenuItem.utils";
|
|
16
|
+
import { idGenerator } from "./idGenerator";
|
|
16
17
|
export let checked = false;
|
|
17
18
|
export let composed = false;
|
|
18
19
|
export let disabled = false;
|
|
@@ -31,9 +32,9 @@ const {
|
|
|
31
32
|
onOpen = void 0,
|
|
32
33
|
onClose = void 0,
|
|
33
34
|
onSelect = void 0
|
|
34
|
-
} = getContext(
|
|
35
|
-
const { openPreviousMenu = void 0, openNextMenu = void 0 } = getContext(
|
|
36
|
-
const instanceId =
|
|
35
|
+
} = getContext(MENU_ITEM_CONTEXT_KEY) || {};
|
|
36
|
+
const { openPreviousMenu = void 0, openNextMenu = void 0 } = getContext(MENU_BAR_CONTEXT_KEY) || {};
|
|
37
|
+
const instanceId = idGenerator.nextId("MenuItem");
|
|
37
38
|
$:
|
|
38
39
|
displayId = `${value}-display-${instanceId}`;
|
|
39
40
|
$:
|
|
@@ -75,6 +76,15 @@ const autoFocusFirstChild = (open2, insideMenu) => {
|
|
|
75
76
|
};
|
|
76
77
|
$:
|
|
77
78
|
autoFocusFirstChild(open, depth > 0);
|
|
79
|
+
export const click = () => {
|
|
80
|
+
menuItemRef?.click();
|
|
81
|
+
};
|
|
82
|
+
export const blur = () => {
|
|
83
|
+
menuItemRef?.blur();
|
|
84
|
+
};
|
|
85
|
+
export const focus = (options) => {
|
|
86
|
+
menuItemRef?.focus(options);
|
|
87
|
+
};
|
|
78
88
|
onMount(() => {
|
|
79
89
|
mounted = true;
|
|
80
90
|
keyborg.subscribe(keyborgHandler);
|
|
@@ -185,7 +195,7 @@ const onClickOutside = (event) => {
|
|
|
185
195
|
}
|
|
186
196
|
closeMenu?.(true);
|
|
187
197
|
};
|
|
188
|
-
setContext(
|
|
198
|
+
setContext(MENU_ITEM_CONTEXT_KEY, {
|
|
189
199
|
rootValue,
|
|
190
200
|
depth: depth + 1,
|
|
191
201
|
register: (menuItem) => {
|
|
@@ -260,15 +270,15 @@ setContext(menuItemContextKey, {
|
|
|
260
270
|
{...$$restProps}
|
|
261
271
|
>
|
|
262
272
|
<div class="item" id={displayId}>
|
|
263
|
-
<slot name="item" {checked} {
|
|
273
|
+
<slot name="item" {checked} {depth} {disabled} {hasChildren} {open} {role} {text} {value}>
|
|
264
274
|
<MenuItemDisplay {checked} hasChildren={depth > 0 && hasChildren} menuItemRole={role}
|
|
265
275
|
>{text}</MenuItemDisplay
|
|
266
276
|
>
|
|
267
277
|
</slot>
|
|
268
278
|
</div>
|
|
269
|
-
{#if menuItemRef && open &&
|
|
279
|
+
{#if menuItemRef && open && hasChildren}
|
|
270
280
|
<Menu id={menuId} {open} reference={menuItemRef}>
|
|
271
|
-
<slot />
|
|
281
|
+
<slot {depth} {disabled} />
|
|
272
282
|
</Menu>
|
|
273
283
|
{/if}
|
|
274
284
|
</button>
|
package/MenuItem.svelte.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ declare const __propDef: {
|
|
|
9
9
|
value: string;
|
|
10
10
|
role?: "menuitem" | "menuitemcheckbox" | "menuitemradio" | undefined;
|
|
11
11
|
text?: string | undefined;
|
|
12
|
+
click?: (() => void) | undefined;
|
|
13
|
+
blur?: (() => void) | undefined;
|
|
14
|
+
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
12
15
|
};
|
|
13
16
|
events: {
|
|
14
17
|
blur: FocusEvent;
|
|
@@ -42,20 +45,26 @@ declare const __propDef: {
|
|
|
42
45
|
slots: {
|
|
43
46
|
item: {
|
|
44
47
|
checked: boolean;
|
|
48
|
+
depth: number;
|
|
45
49
|
disabled: boolean;
|
|
46
50
|
hasChildren: boolean;
|
|
47
|
-
depth: number;
|
|
48
|
-
value: string;
|
|
49
51
|
open: boolean;
|
|
50
52
|
role: "menuitem" | "menuitemcheckbox" | "menuitemradio";
|
|
51
53
|
text: string | undefined;
|
|
54
|
+
value: string;
|
|
55
|
+
};
|
|
56
|
+
default: {
|
|
57
|
+
depth: number;
|
|
58
|
+
disabled: boolean;
|
|
52
59
|
};
|
|
53
|
-
default: {};
|
|
54
60
|
};
|
|
55
61
|
};
|
|
56
62
|
export type MenuItemProps = typeof __propDef.props;
|
|
57
63
|
export type MenuItemEvents = typeof __propDef.events;
|
|
58
64
|
export type MenuItemSlots = typeof __propDef.slots;
|
|
59
65
|
export default class MenuItem extends SvelteComponentTyped<MenuItemProps, MenuItemEvents, MenuItemSlots> {
|
|
66
|
+
get click(): () => void;
|
|
67
|
+
get blur(): () => void;
|
|
68
|
+
get focus(): (options?: FocusOptions | undefined) => void;
|
|
60
69
|
}
|
|
61
70
|
export {};
|
|
@@ -4,10 +4,6 @@ export type MenuItemRegistration = {
|
|
|
4
4
|
close: () => void;
|
|
5
5
|
focus: () => void;
|
|
6
6
|
};
|
|
7
|
-
export type MenuBarContext = {
|
|
8
|
-
openPreviousMenu?: (currentValue: string) => void;
|
|
9
|
-
openNextMenu?: (currentValue: string) => void;
|
|
10
|
-
};
|
|
11
7
|
export type MenuItemContext = {
|
|
12
8
|
rootValue?: string;
|
|
13
9
|
depth?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MenuItemRegistration } from './
|
|
1
|
+
import type { MenuItemRegistration } from './MenuItem.types';
|
|
2
2
|
export declare const focusPreviousChild: (children: MenuItemRegistration[], currentValue: string) => void;
|
|
3
3
|
export declare const focusNextChild: (children: MenuItemRegistration[], currentValue: string) => void;
|
|
4
4
|
export declare const focusFirstChild: (children: MenuItemRegistration[]) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PROGRESS_COLORFULS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PROGRESS_COLORFULS = ['none', 'auto', 'info', 'success', 'warning', 'error'];
|
package/Progress.svelte
CHANGED
|
@@ -37,10 +37,15 @@ $:
|
|
|
37
37
|
class:disabled
|
|
38
38
|
class:vertical
|
|
39
39
|
role="progressbar"
|
|
40
|
+
on:blur
|
|
40
41
|
on:click
|
|
41
42
|
on:dblclick
|
|
42
43
|
on:focus
|
|
43
|
-
on:
|
|
44
|
+
on:focusin
|
|
45
|
+
on:focusout
|
|
46
|
+
on:keydown
|
|
47
|
+
on:keypress
|
|
48
|
+
on:keyup
|
|
44
49
|
on:mousedown
|
|
45
50
|
on:mouseenter
|
|
46
51
|
on:mouseleave
|
|
@@ -48,6 +53,14 @@ $:
|
|
|
48
53
|
on:mouseover
|
|
49
54
|
on:mouseout
|
|
50
55
|
on:mouseup
|
|
56
|
+
on:pointercancel
|
|
57
|
+
on:pointerdown
|
|
58
|
+
on:pointerenter
|
|
59
|
+
on:pointerleave
|
|
60
|
+
on:pointermove
|
|
61
|
+
on:pointerover
|
|
62
|
+
on:pointerout
|
|
63
|
+
on:pointerup
|
|
51
64
|
on:wheel
|
|
52
65
|
{...$$restProps}
|
|
53
66
|
>
|
|
@@ -65,7 +78,7 @@ $:
|
|
|
65
78
|
|
|
66
79
|
<style>
|
|
67
80
|
.sterling-progress {
|
|
68
|
-
display: flex;
|
|
81
|
+
display: inline-flex;
|
|
69
82
|
flex-direction: column;
|
|
70
83
|
align-content: flex-start;
|
|
71
84
|
align-items: flex-start;
|
|
@@ -73,7 +86,7 @@ $:
|
|
|
73
86
|
background: var(--stsv-Common__background-color);
|
|
74
87
|
box-sizing: border-box;
|
|
75
88
|
height: 1em;
|
|
76
|
-
padding: 0.
|
|
89
|
+
padding: 0.25em;
|
|
77
90
|
border-width: var(--stsv-Common__border-width);
|
|
78
91
|
border-style: var(--stsv-Common__border-style);
|
|
79
92
|
border-color: var(--stsv-Common__border-color);
|
package/Progress.svelte.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { ProgressColorful } from './Progress.types';
|
|
3
2
|
declare const __propDef: {
|
|
4
3
|
props: {
|
|
5
4
|
[x: string]: any;
|
|
@@ -7,14 +6,19 @@ declare const __propDef: {
|
|
|
7
6
|
max?: number | undefined;
|
|
8
7
|
percent?: number | undefined;
|
|
9
8
|
vertical?: boolean | undefined;
|
|
10
|
-
colorful?:
|
|
9
|
+
colorful?: string | undefined;
|
|
11
10
|
disabled?: boolean | undefined;
|
|
12
11
|
};
|
|
13
12
|
events: {
|
|
13
|
+
blur: FocusEvent;
|
|
14
14
|
click: MouseEvent;
|
|
15
15
|
dblclick: MouseEvent;
|
|
16
16
|
focus: FocusEvent;
|
|
17
|
-
|
|
17
|
+
focusin: FocusEvent;
|
|
18
|
+
focusout: FocusEvent;
|
|
19
|
+
keydown: KeyboardEvent;
|
|
20
|
+
keypress: KeyboardEvent;
|
|
21
|
+
keyup: KeyboardEvent;
|
|
18
22
|
mousedown: MouseEvent;
|
|
19
23
|
mouseenter: MouseEvent;
|
|
20
24
|
mouseleave: MouseEvent;
|
|
@@ -22,6 +26,14 @@ declare const __propDef: {
|
|
|
22
26
|
mouseover: MouseEvent;
|
|
23
27
|
mouseout: MouseEvent;
|
|
24
28
|
mouseup: MouseEvent;
|
|
29
|
+
pointercancel: PointerEvent;
|
|
30
|
+
pointerdown: PointerEvent;
|
|
31
|
+
pointerenter: PointerEvent;
|
|
32
|
+
pointerleave: PointerEvent;
|
|
33
|
+
pointermove: PointerEvent;
|
|
34
|
+
pointerover: PointerEvent;
|
|
35
|
+
pointerout: PointerEvent;
|
|
36
|
+
pointerup: PointerEvent;
|
|
25
37
|
wheel: WheelEvent;
|
|
26
38
|
} & {
|
|
27
39
|
[evt: string]: CustomEvent<any>;
|
package/Progress.types.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PROGRESS_COLORFULS } from './Progress.constants';
|
|
2
|
+
type ProgressColorfulTuple = typeof PROGRESS_COLORFULS;
|
|
3
|
+
export type ProgressColorful = ProgressColorfulTuple[number];
|
|
4
|
+
export {};
|