@geoffcox/sterling-svelte 0.0.19 → 0.0.21

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.
Files changed (97) hide show
  1. package/Button.constants.d.ts +2 -0
  2. package/Button.constants.js +2 -0
  3. package/Button.svelte +11 -0
  4. package/Button.svelte.d.ts +10 -5
  5. package/Button.types.d.ts +6 -2
  6. package/Checkbox.svelte +14 -1
  7. package/Checkbox.svelte.d.ts +8 -0
  8. package/Dialog.svelte +2 -3
  9. package/Dropdown.svelte +9 -0
  10. package/Dropdown.svelte.d.ts +6 -0
  11. package/Field.constants.d.ts +1 -0
  12. package/Field.constants.js +1 -0
  13. package/Field.svelte +22 -7
  14. package/Field.svelte.d.ts +9 -3
  15. package/Field.types.d.ts +4 -1
  16. package/Input.svelte +25 -1
  17. package/Input.svelte.d.ts +12 -0
  18. package/Label.svelte +12 -2
  19. package/Label.svelte.d.ts +9 -1
  20. package/Link.constants.d.ts +1 -0
  21. package/Link.constants.js +1 -0
  22. package/Link.svelte +102 -0
  23. package/Link.svelte.d.ts +57 -0
  24. package/Link.types.d.ts +4 -0
  25. package/List.constants.d.ts +1 -1
  26. package/List.constants.js +1 -1
  27. package/List.svelte +13 -7
  28. package/List.svelte.d.ts +6 -2
  29. package/ListItem.svelte +11 -2
  30. package/ListItem.svelte.d.ts +6 -0
  31. package/Menu.svelte +46 -12
  32. package/Menu.svelte.d.ts +26 -0
  33. package/MenuBar.constants.d.ts +1 -0
  34. package/MenuBar.constants.js +1 -0
  35. package/MenuBar.svelte +12 -3
  36. package/MenuBar.svelte.d.ts +5 -1
  37. package/MenuBar.types.d.ts +4 -0
  38. package/MenuBar.types.js +1 -0
  39. package/MenuButton.svelte +42 -8
  40. package/MenuButton.svelte.d.ts +12 -4
  41. package/MenuItem.constants.d.ts +1 -0
  42. package/MenuItem.constants.js +1 -0
  43. package/MenuItem.svelte +18 -8
  44. package/MenuItem.svelte.d.ts +12 -3
  45. package/{Menus.types.d.ts → MenuItem.types.d.ts} +0 -4
  46. package/MenuItem.types.js +1 -0
  47. package/{Menus.utils.d.ts → MenuItem.utils.d.ts} +1 -1
  48. package/Progress.constants.d.ts +1 -0
  49. package/Progress.constants.js +1 -0
  50. package/Progress.svelte +16 -3
  51. package/Progress.svelte.d.ts +15 -3
  52. package/Progress.types.d.ts +4 -1
  53. package/Radio.svelte +14 -1
  54. package/Radio.svelte.d.ts +8 -0
  55. package/Select.svelte +15 -1
  56. package/Select.svelte.d.ts +10 -0
  57. package/Slider.svelte +9 -0
  58. package/Slider.svelte.d.ts +6 -0
  59. package/Switch.svelte +11 -0
  60. package/Switch.svelte.d.ts +6 -0
  61. package/Tab.svelte +11 -2
  62. package/Tab.svelte.d.ts +6 -0
  63. package/TabList.constants.d.ts +1 -1
  64. package/TabList.constants.js +1 -1
  65. package/TabList.svelte +8 -2
  66. package/TabList.svelte.d.ts +4 -0
  67. package/TextArea.constants.d.ts +1 -0
  68. package/TextArea.constants.js +1 -0
  69. package/TextArea.svelte +22 -0
  70. package/TextArea.svelte.d.ts +13 -2
  71. package/TextArea.types.d.ts +4 -1
  72. package/Tooltip.constants.d.ts +1 -0
  73. package/Tooltip.constants.js +1 -0
  74. package/Tooltip.svelte +26 -10
  75. package/Tooltip.svelte.d.ts +7 -3
  76. package/Tooltip.types.d.ts +4 -3
  77. package/Tree.constants.d.ts +2 -2
  78. package/Tree.constants.js +2 -2
  79. package/Tree.svelte +41 -7
  80. package/Tree.svelte.d.ts +34 -1
  81. package/Tree.types.d.ts +4 -4
  82. package/TreeChevron.svelte +1 -1
  83. package/TreeItem.svelte +76 -52
  84. package/TreeItem.svelte.d.ts +26 -3
  85. package/TreeItemDisplay.svelte +11 -0
  86. package/TreeItemDisplay.svelte.d.ts +6 -0
  87. package/floating-ui.constants.d.ts +1 -0
  88. package/floating-ui.constants.js +14 -0
  89. package/floating-ui.types.d.ts +2 -0
  90. package/floating-ui.types.js +1 -0
  91. package/index.d.ts +19 -7
  92. package/index.js +14 -6
  93. package/package.json +16 -4
  94. package/Menus.constants.d.ts +0 -2
  95. package/Menus.constants.js +0 -2
  96. /package/{Menus.types.js → Link.types.js} +0 -0
  97. /package/{Menus.utils.js → MenuItem.utils.js} +0 -0
package/List.svelte CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createEventDispatcher, onMount, setContext } from "svelte";
3
3
  import { writable } from "svelte/store";
4
4
  import { v4 as uuid } from "uuid";
5
- import { listContextKey } from "./List.constants";
5
+ import { LIST_CONTEXT_KEY } from "./List.constants";
6
6
  export let composed = false;
7
7
  export let disabled = false;
8
8
  export let horizontal = false;
@@ -32,18 +32,24 @@ const raiseSelect = (value) => {
32
32
  $: {
33
33
  raiseSelect(selectedValue);
34
34
  }
35
- let keyborg = createKeyborg(window);
36
- let usingKeyboard = keyborg.isNavigatingWithKeyboard();
37
- const keyborgHandler = (value) => {
38
- usingKeyboard = value;
35
+ export const blur = () => {
36
+ listRef?.blur();
37
+ };
38
+ export const click = () => {
39
+ listRef?.click();
39
40
  };
40
- export const focus = () => {
41
+ export const focus = (options) => {
41
42
  listRef?.focus();
42
43
  };
43
44
  export const scrollToSelectedItem = () => {
44
45
  const element = getSelectedItemElement();
45
46
  element?.scrollIntoView({ block: "nearest", inline: "nearest" });
46
47
  };
48
+ let keyborg = createKeyborg(window);
49
+ let usingKeyboard = keyborg.isNavigatingWithKeyboard();
50
+ const keyborgHandler = (value) => {
51
+ usingKeyboard = value;
52
+ };
47
53
  const isElementListItem = (candidate) => {
48
54
  return candidate && candidate.getAttribute("data-value") !== null && candidate.getAttribute("data-value") !== void 0 && candidate.getAttribute("role") === "listitem";
49
55
  };
@@ -172,7 +178,7 @@ const onKeydown = (event) => {
172
178
  }
173
179
  }
174
180
  };
175
- setContext(listContextKey, {
181
+ setContext(LIST_CONTEXT_KEY, {
176
182
  disabled: disabledStore,
177
183
  selectedValue: selectedValueStore,
178
184
  horizontal: horizontalStore
package/List.svelte.d.ts CHANGED
@@ -6,7 +6,9 @@ declare const __propDef: {
6
6
  disabled?: boolean | undefined;
7
7
  horizontal?: boolean | undefined;
8
8
  selectedValue?: string | undefined;
9
- focus?: (() => void) | undefined;
9
+ blur?: (() => void) | undefined;
10
+ click?: (() => void) | undefined;
11
+ focus?: ((options?: FocusOptions) => void) | undefined;
10
12
  scrollToSelectedItem?: (() => void) | undefined;
11
13
  selectFirstItem?: (() => boolean) | undefined;
12
14
  selectPreviousItem?: (() => boolean) | undefined;
@@ -53,7 +55,9 @@ export type ListEvents = typeof __propDef.events;
53
55
  export type ListSlots = typeof __propDef.slots;
54
56
  /** A list of items where a single item can be selected. */
55
57
  export default class List extends SvelteComponentTyped<ListProps, ListEvents, ListSlots> {
56
- get focus(): () => void;
58
+ get blur(): () => void;
59
+ get click(): () => void;
60
+ get focus(): (options?: FocusOptions | undefined) => void;
57
61
  get scrollToSelectedItem(): () => void;
58
62
  get selectFirstItem(): () => boolean;
59
63
  get selectPreviousItem(): () => boolean;
package/ListItem.svelte CHANGED
@@ -1,17 +1,26 @@
1
1
  <script>import { getContext } from "svelte";
2
- import { listContextKey } from "./List.constants";
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(listContextKey);
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
@@ -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 { menuItemContextKey } from "./Menus.constants";
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(menuItemContextKey) || {};
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
- <slot />
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
- box-shadow: rgba(0, 0, 0, 0.4) 2px 2px 4px -1px;
96
- overflow: hidden;
134
+ top: 0;
97
135
  width: max-content;
98
- height: fit-content;
99
136
  z-index: 1;
100
- top: 0;
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 { menuBarContextKey, menuItemContextKey } from "./Menus.constants";
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(menuItemContextKey, {
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(menuBarContextKey, {
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
@@ -1,7 +1,9 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- [x: string]: never;
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 {};
@@ -0,0 +1,4 @@
1
+ export type MenuBarContext = {
2
+ openPreviousMenu?: (currentValue: string) => void;
3
+ openNextMenu?: (currentValue: string) => void;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
package/MenuButton.svelte CHANGED
@@ -3,14 +3,16 @@ import { createEventDispatcher, getContext, setContext } from "svelte";
3
3
  import { writable } from "svelte/store";
4
4
  import Button from "./Button.svelte";
5
5
  import Menu from "./Menu.svelte";
6
- import { menuItemContextKey } from "./Menus.constants";
7
- import { focusFirstChild, focusNextChild, focusPreviousChild } from "./Menus.utils";
6
+ import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
7
+ import { focusFirstChild, focusNextChild, focusPreviousChild } from "./MenuItem.utils";
8
8
  export let open = false;
9
9
  export let shape = "rounded";
10
10
  export let value;
11
11
  export let variant = "regular";
12
12
  const instanceId = uuid();
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
- setContext(menuItemContextKey, {
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>
@@ -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?: ButtonShape | undefined;
6
+ shape?: "circular" | "rounded" | "square" | undefined;
8
7
  value: string;
9
- variant?: ButtonVariant | undefined;
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
@@ -5,14 +5,15 @@ import { writable } from "svelte/store";
5
5
  import { clickOutside } from "./actions/clickOutside";
6
6
  import { afterUpdate, createEventDispatcher } from "svelte/internal";
7
7
  import MenuItemDisplay from "./MenuItemDisplay.svelte";
8
- import { menuBarContextKey, menuItemContextKey } from "./Menus.constants";
8
+ import { MENU_BAR_CONTEXT_KEY } from "./MenuBar.constants";
9
+ import { MENU_ITEM_CONTEXT_KEY } from "./MenuItem.constants";
9
10
  import Menu from "./Menu.svelte";
10
11
  import {
11
12
  focusFirstChild,
12
13
  focusLastChild,
13
14
  focusNextChild,
14
15
  focusPreviousChild
15
- } from "./Menus.utils";
16
+ } from "./MenuItem.utils";
16
17
  export let checked = false;
17
18
  export let composed = false;
18
19
  export let disabled = false;
@@ -31,8 +32,8 @@ const {
31
32
  onOpen = void 0,
32
33
  onClose = void 0,
33
34
  onSelect = void 0
34
- } = getContext(menuItemContextKey) || {};
35
- const { openPreviousMenu = void 0, openNextMenu = void 0 } = getContext(menuBarContextKey) || {};
35
+ } = getContext(MENU_ITEM_CONTEXT_KEY) || {};
36
+ const { openPreviousMenu = void 0, openNextMenu = void 0 } = getContext(MENU_BAR_CONTEXT_KEY) || {};
36
37
  const instanceId = uuid();
37
38
  $:
38
39
  displayId = `${value}-display-${instanceId}`;
@@ -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(menuItemContextKey, {
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} {disabled} {hasChildren} {depth} {value} {open} {role} {text}>
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 && $$slots.default}
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>
@@ -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 './Menus.types';
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:blur
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.2em;
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);