@spectrum-web-components/menu 1.2.0-beta.8 → 1.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/menu",
3
- "version": "1.2.0-beta.8",
3
+ "version": "1.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -90,15 +90,15 @@
90
90
  ],
91
91
  "dependencies": {
92
92
  "@lit-labs/observers": "^2.0.2",
93
- "@spectrum-web-components/action-button": "^1.2.0-beta.8",
94
- "@spectrum-web-components/base": "^1.2.0-beta.8",
95
- "@spectrum-web-components/divider": "^1.2.0-beta.8",
96
- "@spectrum-web-components/icon": "^1.2.0-beta.8",
97
- "@spectrum-web-components/icons-ui": "^1.2.0-beta.8",
98
- "@spectrum-web-components/overlay": "^1.2.0-beta.8",
99
- "@spectrum-web-components/popover": "^1.2.0-beta.8",
100
- "@spectrum-web-components/reactive-controllers": "^1.2.0-beta.8",
101
- "@spectrum-web-components/shared": "^1.2.0-beta.8"
93
+ "@spectrum-web-components/action-button": "^1.2.0",
94
+ "@spectrum-web-components/base": "^1.2.0",
95
+ "@spectrum-web-components/divider": "^1.2.0",
96
+ "@spectrum-web-components/icon": "^1.2.0",
97
+ "@spectrum-web-components/icons-ui": "^1.2.0",
98
+ "@spectrum-web-components/overlay": "^1.2.0",
99
+ "@spectrum-web-components/popover": "^1.2.0",
100
+ "@spectrum-web-components/reactive-controllers": "^1.2.0",
101
+ "@spectrum-web-components/shared": "^1.2.0"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@spectrum-css/menu": "8.0.0-s2-foundations.17"
@@ -109,5 +109,5 @@
109
109
  "./sp-*.js",
110
110
  "./**/*.dev.js"
111
111
  ],
112
- "gitHead": "740377aa5f17e15650d4871e3034bd9c9a2f5c35"
112
+ "gitHead": "e4aec7b389e6209984e4df74f9b86b3ee0c485dd"
113
113
  }
package/src/Menu.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { CSSResultArray, PropertyValues, SpectrumElement, TemplateResult } from '@spectrum-web-components/base';
2
2
  import { MenuItem } from './MenuItem.js';
3
+ import type { MenuItemKeydownEvent } from './MenuItem.js';
4
+ import { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';
3
5
  export interface MenuChildItem {
4
6
  menuItem: MenuItem;
5
7
  managed: boolean;
@@ -26,21 +28,54 @@ declare const Menu_base: typeof SpectrumElement & {
26
28
  */
27
29
  export declare class Menu extends Menu_base {
28
30
  static get styles(): CSSResultArray;
31
+ static shadowRootOptions: {
32
+ delegatesFocus: boolean;
33
+ mode: ShadowRootMode;
34
+ slotAssignment?: SlotAssignmentMode | undefined;
35
+ };
29
36
  private get isSubmenu();
37
+ protected rovingTabindexController?: RovingTabindexController<MenuItem>;
38
+ /**
39
+ * label of the menu
40
+ */
30
41
  label: string;
42
+ /**
43
+ * whether menu should be ignored by roving tabindex controller
44
+ */
31
45
  ignore: boolean;
46
+ /**
47
+ * how the menu allows selection of its items:
48
+ * - `undefined` (default): no selection is allowed
49
+ * - `"inherit"`: the selection behavior is managed from an ancestor
50
+ * - `"single"`: only one item can be selected at a time
51
+ * - `"multiple"`: multiple items can be selected
52
+ */
32
53
  selects: undefined | 'inherit' | 'single' | 'multiple';
54
+ /**
55
+ * value of the selected item(s)
56
+ */
33
57
  value: string;
34
58
  valueSeparator: string;
59
+ /**
60
+ * selected items values as string
61
+ */
35
62
  get selected(): string[];
36
63
  set selected(selected: string[]);
37
64
  protected _selected: string[];
65
+ /**
66
+ * array of selected menu items
67
+ */
38
68
  selectedItems: MenuItem[];
39
69
  menuSlot: HTMLSlotElement;
40
70
  private childItemSet;
41
71
  focusedItemIndex: number;
42
72
  focusInItemIndex: number;
73
+ get focusInItem(): MenuItem | undefined;
74
+ protected get controlsRovingTabindex(): boolean;
43
75
  private selectedItemsMap;
76
+ /**
77
+ * child items managed by menu
78
+ */
44
79
  get childItems(): MenuItem[];
45
80
  private cachedChildItems;
46
81
  private updateCachedMenuItems;
@@ -53,7 +88,13 @@ export declare class Menu extends Menu_base {
53
88
  */
54
89
  get childRole(): string;
55
90
  protected get ownRole(): string;
91
+ /**
92
+ * menuitem role based on selection type
93
+ */
56
94
  private resolvedSelects?;
95
+ /**
96
+ * menu role based on selection type
97
+ */
57
98
  private resolvedRole?;
58
99
  /**
59
100
  * When a descendant `<sp-menu-item>` element is added or updated it will dispatch
@@ -74,34 +115,44 @@ export declare class Menu extends Menu_base {
74
115
  private addChildItem;
75
116
  private removeChildItem;
76
117
  constructor();
118
+ /**
119
+ * for picker elements, will set focus on first selected item
120
+ */
121
+ focusOnFirstSelectedItem({ preventScroll, }?: FocusOptions): void;
77
122
  focus({ preventScroll }?: FocusOptions): void;
78
123
  private pointerUpTarget;
124
+ private handleFocusout;
79
125
  private handleClick;
80
126
  private handlePointerup;
81
127
  private handlePointerBasedSelection;
82
- handleFocusin(event: FocusEvent): void;
83
- startListeningToKeyboard(): void;
84
- handleBlur(event: FocusEvent): void;
85
- stopListeningToKeyboard(): void;
86
128
  private descendentOverlays;
87
129
  protected handleDescendentOverlayOpened(event: Event): void;
88
130
  protected handleDescendentOverlayClosed(event: Event): void;
89
131
  handleSubmenuClosed: (event: Event) => void;
132
+ /**
133
+ * given a menu item, returns the next focusable menu item before or after it;
134
+ * if no menu item is provided, returns the first focusable menu item
135
+ * @param menuItem {MenuItem}
136
+ * @param before {boolean} return the item before; default is false
137
+ * @returns {MenuItem}
138
+ */
139
+ getNeighboringFocusableElement(menuItem?: MenuItem, before?: boolean): MenuItem;
90
140
  handleSubmenuOpened: (event: Event) => void;
91
141
  selectOrToggleItem(targetItem: MenuItem): Promise<void>;
92
- protected navigateWithinMenu(event: KeyboardEvent): void;
93
- protected navigateBetweenRelatedMenus(event: KeyboardEvent): void;
94
- handleKeydown(event: KeyboardEvent): void;
95
- focusMenuItemByOffset(offset: number): MenuItem;
96
- private prepareToCleanUp;
142
+ protected navigateBetweenRelatedMenus(event: MenuItemKeydownEvent): void;
143
+ handleKeydown(event: Event): void;
97
144
  private _hasUpdatedSelectedItemIndex;
145
+ /**
146
+ * on focus, removes focus from focus styling item, and updates the selected item index
147
+ */
148
+ private prepareToCleanUp;
98
149
  updateSelectedItemIndex(): void;
99
150
  private _willUpdateItems;
151
+ private _updateFocus?;
100
152
  private handleItemsChanged;
101
153
  private updateCache;
102
154
  private updateItemFocus;
103
155
  closeDescendentOverlays(): void;
104
- private forwardFocusVisibleToItem;
105
156
  private handleSlotchange;
106
157
  protected renderMenuItemSlot(): TemplateResult;
107
158
  render(): TemplateResult;
@@ -109,6 +160,7 @@ export declare class Menu extends Menu_base {
109
160
  protected updated(changes: PropertyValues<this>): void;
110
161
  protected selectsChanged(): void;
111
162
  connectedCallback(): void;
163
+ private isFocusableElement;
112
164
  disconnectedCallback(): void;
113
165
  protected childItemsUpdated: Promise<unknown[]>;
114
166
  protected cacheUpdated: Promise<void>;