@spectrum-web-components/menu 0.36.0 → 0.37.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/custom-elements.json +451 -155
- package/package.json +9 -9
- package/src/Menu.d.ts +16 -6
- package/src/Menu.dev.js +178 -64
- package/src/Menu.dev.js.map +2 -2
- package/src/Menu.js +7 -3
- package/src/Menu.js.map +3 -3
- package/src/MenuGroup.d.ts +0 -2
- package/src/MenuGroup.dev.js +8 -12
- package/src/MenuGroup.dev.js.map +2 -2
- package/src/MenuGroup.js +3 -5
- package/src/MenuGroup.js.map +3 -3
- package/src/MenuItem.d.ts +29 -23
- package/src/MenuItem.dev.js +204 -212
- package/src/MenuItem.dev.js.map +3 -3
- package/src/MenuItem.js +35 -18
- package/src/MenuItem.js.map +3 -3
- package/src/menu-item.css.dev.js +1 -1
- package/src/menu-item.css.dev.js.map +1 -1
- package/src/menu-item.css.js +1 -1
- package/src/menu-item.css.js.map +1 -1
- package/src/menu.css.dev.js +1 -1
- package/src/menu.css.dev.js.map +1 -1
- package/src/menu.css.js +1 -1
- package/src/menu.css.js.map +1 -1
- package/stories/index.js +4 -0
- package/stories/index.js.map +2 -2
- package/stories/submenu.stories.js +117 -104
- package/stories/submenu.stories.js.map +3 -3
- package/test/menu-group.test.js +14 -1
- package/test/menu-group.test.js.map +2 -2
- package/test/menu-item.test.js +22 -0
- package/test/menu-item.test.js.map +2 -2
- package/test/menu-selects.test.js +3 -1
- package/test/menu-selects.test.js.map +2 -2
- package/test/menu.test.js +9 -1
- package/test/menu.test.js.map +2 -2
- package/test/submenu.test.js +208 -84
- package/test/submenu.test.js.map +2 -2
package/src/MenuGroup.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["MenuGroup.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n queryAssignedNodes,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { Menu } from './Menu.js';\n// Leveraged in build systems that use aliasing to prevent multiple registrations: https://github.com/adobe/spectrum-web-components/pull/3225\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport menuGroupStyles from './menu-group.css.js';\n\n/**\n * @element sp-menu-group\n *\n * @slot header - headline of the menu group\n * @slot - menu items to be listed in the group\n */\nexport class MenuGroup extends Menu {\n public static override get styles(): CSSResultArray {\n return [...super.styles, menuGroupStyles];\n }\n\n private
|
|
5
|
-
"mappings": "qNAYA,OAEI,QAAAA,MAEG,gCACP,OACI,sBAAAC,EACA,SAAAC,MACG,kDAEP,OAAS,QAAAC,MAAY,YAErB,MAAO,2CACP,OAAOC,MAAqB,sBAQrB,
|
|
6
|
-
"names": ["html", "queryAssignedNodes", "state", "Menu", "menuGroupStyles", "
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n queryAssignedNodes,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { Menu } from './Menu.js';\n// Leveraged in build systems that use aliasing to prevent multiple registrations: https://github.com/adobe/spectrum-web-components/pull/3225\nimport '@spectrum-web-components/menu/sp-menu.js';\nimport menuGroupStyles from './menu-group.css.js';\n\n/**\n * @element sp-menu-group\n *\n * @slot header - headline of the menu group\n * @slot - menu items to be listed in the group\n */\nexport class MenuGroup extends Menu {\n public static override get styles(): CSSResultArray {\n return [...super.styles, menuGroupStyles];\n }\n\n private headerId = '';\n\n @queryAssignedNodes({\n slot: 'header',\n flatten: true,\n })\n private headerElements!: NodeListOf<HTMLElement>;\n\n @state()\n private headerElement?: HTMLElement;\n\n protected override get ownRole(): string {\n switch (this.selects) {\n case 'multiple':\n case 'single':\n case 'inherit':\n return 'group';\n default:\n return 'menu';\n }\n }\n\n protected updateLabel(): void {\n const headerElement = this.headerElements.length\n ? this.headerElements[0]\n : undefined;\n if (headerElement !== this.headerElement) {\n if (this.headerElement && this.headerElement.id === this.headerId) {\n this.headerElement.removeAttribute('id');\n }\n if (headerElement) {\n this.headerId =\n this.headerId ||\n `sp-menu-group-label-${crypto.randomUUID().slice(0, 8)}`;\n const headerId = headerElement.id || this.headerId;\n if (!headerElement.id) {\n headerElement.id = headerId;\n }\n this.setAttribute('aria-labelledby', headerId);\n } else {\n this.removeAttribute('aria-labelledby');\n }\n }\n this.headerElement = headerElement;\n }\n\n public override render(): TemplateResult {\n return html`\n <span class=\"header\" ?hidden=${!this.headerElement}>\n <slot name=\"header\" @slotchange=${this.updateLabel}></slot>\n </span>\n <sp-menu ignore>${this.renderMenuItemSlot()}</sp-menu>\n `;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEI,QAAAA,MAEG,gCACP,OACI,sBAAAC,EACA,SAAAC,MACG,kDAEP,OAAS,QAAAC,MAAY,YAErB,MAAO,2CACP,OAAOC,MAAqB,sBAQrB,aAAM,kBAAkBD,CAAK,CAA7B,kCAKH,KAAQ,SAAW,GAJnB,WAA2B,QAAyB,CAChD,MAAO,CAAC,GAAG,MAAM,OAAQC,CAAe,CAC5C,CAaA,IAAuB,SAAkB,CACrC,OAAQ,KAAK,QAAS,CAClB,IAAK,WACL,IAAK,SACL,IAAK,UACD,MAAO,QACX,QACI,MAAO,MACf,CACJ,CAEU,aAAoB,CAC1B,MAAMC,EAAgB,KAAK,eAAe,OACpC,KAAK,eAAe,CAAC,EACrB,OACN,GAAIA,IAAkB,KAAK,cAIvB,GAHI,KAAK,eAAiB,KAAK,cAAc,KAAO,KAAK,UACrD,KAAK,cAAc,gBAAgB,IAAI,EAEvCA,EAAe,CACf,KAAK,SACD,KAAK,UACL,uBAAuB,OAAO,WAAW,EAAE,MAAM,EAAG,CAAC,CAAC,GAC1D,MAAMC,EAAWD,EAAc,IAAM,KAAK,SACrCA,EAAc,KACfA,EAAc,GAAKC,GAEvB,KAAK,aAAa,kBAAmBA,CAAQ,CACjD,MACI,KAAK,gBAAgB,iBAAiB,EAG9C,KAAK,cAAgBD,CACzB,CAEgB,QAAyB,CACrC,OAAOL;AAAA,2CAC4B,CAAC,KAAK,aAAa;AAAA,kDACZ,KAAK,WAAW;AAAA;AAAA,8BAEpC,KAAK,mBAAmB,CAAC;AAAA,SAEnD,CACJ,CAhDYO,EAAA,CAJPN,EAAmB,CAChB,KAAM,SACN,QAAS,EACb,CAAC,GAVQ,UAWD,8BAGAM,EAAA,CADPL,EAAM,GAbE,UAcD",
|
|
6
|
+
"names": ["html", "queryAssignedNodes", "state", "Menu", "menuGroupStyles", "headerElement", "headerId", "__decorateClass"]
|
|
7
7
|
}
|
package/src/MenuItem.d.ts
CHANGED
|
@@ -3,23 +3,18 @@ import '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';
|
|
|
3
3
|
import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
|
|
4
4
|
import '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';
|
|
5
5
|
import type { Menu } from './Menu.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
reset(item: MenuItem): void;
|
|
12
|
-
}
|
|
6
|
+
import type { Overlay } from 'overlay/src/Overlay.js';
|
|
7
|
+
declare type MenuCascadeItem = {
|
|
8
|
+
hadFocusRoot: boolean;
|
|
9
|
+
ancestorWithSelects?: HTMLElement;
|
|
10
|
+
};
|
|
13
11
|
export declare class MenuItemAddedOrUpdatedEvent extends Event {
|
|
14
|
-
constructor();
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
constructor(item: MenuItem);
|
|
13
|
+
clear(item: MenuItem): void;
|
|
14
|
+
menuCascade: WeakMap<HTMLElement, MenuCascadeItem>;
|
|
17
15
|
get item(): MenuItem;
|
|
18
|
-
_item
|
|
19
|
-
|
|
20
|
-
get currentAncestorWithSelects(): Menu | undefined;
|
|
21
|
-
_currentAncestorWithSelects?: Menu;
|
|
22
|
-
reset(item: MenuItem): void;
|
|
16
|
+
private _item;
|
|
17
|
+
currentAncestorWithSelects?: Menu;
|
|
23
18
|
}
|
|
24
19
|
export declare type MenuItemChildren = {
|
|
25
20
|
icon: Element[];
|
|
@@ -43,12 +38,11 @@ declare const MenuItem_base: typeof Focusable & {
|
|
|
43
38
|
* @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.
|
|
44
39
|
* @slot submenu - content placed in a submenu
|
|
45
40
|
* @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships
|
|
46
|
-
* @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state
|
|
47
41
|
*/
|
|
48
42
|
export declare class MenuItem extends MenuItem_base {
|
|
49
43
|
static get styles(): CSSResultArray;
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
abortControllerPointer: AbortController;
|
|
45
|
+
abortControllerSubmenu: AbortController;
|
|
52
46
|
active: boolean;
|
|
53
47
|
focused: boolean;
|
|
54
48
|
selected: boolean;
|
|
@@ -60,8 +54,11 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
60
54
|
*/
|
|
61
55
|
get itemText(): string;
|
|
62
56
|
hasSubmenu: boolean;
|
|
57
|
+
contentSlot: HTMLSlotElement;
|
|
58
|
+
iconSlot: HTMLSlotElement;
|
|
63
59
|
noWrap: boolean;
|
|
64
60
|
private anchorElement;
|
|
61
|
+
overlayElement: Overlay;
|
|
65
62
|
get focusElement(): HTMLElement;
|
|
66
63
|
protected get hasIcon(): boolean;
|
|
67
64
|
get itemChildren(): MenuItemChildren;
|
|
@@ -73,6 +70,7 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
73
70
|
private proxyFocus;
|
|
74
71
|
private shouldProxyClick;
|
|
75
72
|
protected breakItemChildrenCache(): void;
|
|
73
|
+
protected renderSubmenu(): TemplateResult;
|
|
76
74
|
protected render(): TemplateResult;
|
|
77
75
|
protected manageSubmenu(event: Event & {
|
|
78
76
|
target: HTMLSlotElement;
|
|
@@ -81,10 +79,12 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
81
79
|
private handlePointerdown;
|
|
82
80
|
protected firstUpdated(changes: PropertyValues): void;
|
|
83
81
|
protected closeOverlaysForRoot(): void;
|
|
84
|
-
|
|
85
|
-
protected
|
|
82
|
+
protected handleSubmenuClick(event: Event): void;
|
|
83
|
+
protected handleSubmenuFocus(): void;
|
|
84
|
+
protected handleBeforetoggle: (event: Event) => void;
|
|
86
85
|
protected handlePointerenter(): void;
|
|
87
86
|
protected leaveTimeout?: ReturnType<typeof setTimeout>;
|
|
87
|
+
protected recentlyLeftChild: boolean;
|
|
88
88
|
protected handlePointerleave(): void;
|
|
89
89
|
/**
|
|
90
90
|
* When there is a `change` event in the submenu for this item
|
|
@@ -93,8 +93,11 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
93
93
|
* and the root of the tree to have their selection changes and
|
|
94
94
|
* be closed.
|
|
95
95
|
*/
|
|
96
|
-
protected handleSubmenuChange:
|
|
97
|
-
protected handleSubmenuPointerenter
|
|
96
|
+
protected handleSubmenuChange(event: Event): void;
|
|
97
|
+
protected handleSubmenuPointerenter(): void;
|
|
98
|
+
protected handleSubmenuPointerleave(): Promise<void>;
|
|
99
|
+
protected handleSubmenuOpen(event: Event): void;
|
|
100
|
+
protected cleanup(): void;
|
|
98
101
|
openOverlay(): Promise<void>;
|
|
99
102
|
updateAriaSelected(): void;
|
|
100
103
|
setRole(role: string): void;
|
|
@@ -102,16 +105,19 @@ export declare class MenuItem extends MenuItem_base {
|
|
|
102
105
|
connectedCallback(): void;
|
|
103
106
|
_parentElement: HTMLElement;
|
|
104
107
|
disconnectedCallback(): void;
|
|
108
|
+
private willDispatchUpdate;
|
|
105
109
|
triggerUpdate(): Promise<void>;
|
|
110
|
+
dispatchUpdate(): void;
|
|
106
111
|
menuData: {
|
|
107
112
|
focusRoot?: Menu;
|
|
113
|
+
parentMenu?: Menu;
|
|
108
114
|
selectionRoot?: Menu;
|
|
115
|
+
cleanupSteps: ((item: MenuItem) => void)[];
|
|
109
116
|
};
|
|
110
117
|
}
|
|
111
118
|
declare global {
|
|
112
119
|
interface GlobalEventHandlersEventMap {
|
|
113
120
|
'sp-menu-item-added-or-updated': MenuItemAddedOrUpdatedEvent;
|
|
114
|
-
'sp-menu-item-removed': MenuItemRemovedEvent;
|
|
115
121
|
}
|
|
116
122
|
}
|
|
117
123
|
export {};
|