@spectrum-web-components/menu 0.12.0 → 0.12.2

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 (68) hide show
  1. package/custom-elements.json +463 -4
  2. package/package.json +9 -8
  3. package/sp-menu-divider.d.ts +0 -6
  4. package/sp-menu-divider.js +0 -14
  5. package/sp-menu-divider.js.map +0 -1
  6. package/sp-menu-group.d.ts +0 -6
  7. package/sp-menu-group.js +0 -14
  8. package/sp-menu-group.js.map +0 -1
  9. package/sp-menu-item.d.ts +0 -6
  10. package/sp-menu-item.js +0 -14
  11. package/sp-menu-item.js.map +0 -1
  12. package/sp-menu.d.ts +0 -6
  13. package/sp-menu.js +0 -14
  14. package/sp-menu.js.map +0 -1
  15. package/src/Menu.d.ts +0 -93
  16. package/src/Menu.js +0 -544
  17. package/src/Menu.js.map +0 -1
  18. package/src/MenuDivider.d.ts +0 -8
  19. package/src/MenuDivider.js +0 -25
  20. package/src/MenuDivider.js.map +0 -1
  21. package/src/MenuGroup.d.ts +0 -20
  22. package/src/MenuGroup.js +0 -79
  23. package/src/MenuGroup.js.map +0 -1
  24. package/src/MenuItem.d.ts +0 -86
  25. package/src/MenuItem.js +0 -295
  26. package/src/MenuItem.js.map +0 -1
  27. package/src/index.d.ts +0 -4
  28. package/src/index.js +0 -16
  29. package/src/index.js.map +0 -1
  30. package/src/menu-divider.css.d.ts +0 -2
  31. package/src/menu-divider.css.js +0 -19
  32. package/src/menu-divider.css.js.map +0 -1
  33. package/src/menu-group.css.d.ts +0 -2
  34. package/src/menu-group.css.js +0 -19
  35. package/src/menu-group.css.js.map +0 -1
  36. package/src/menu-item.css.d.ts +0 -2
  37. package/src/menu-item.css.js +0 -76
  38. package/src/menu-item.css.js.map +0 -1
  39. package/src/menu.css.d.ts +0 -2
  40. package/src/menu.css.js +0 -74
  41. package/src/menu.css.js.map +0 -1
  42. package/src/spectrum-checkmark.css.d.ts +0 -2
  43. package/src/spectrum-checkmark.css.js +0 -21
  44. package/src/spectrum-checkmark.css.js.map +0 -1
  45. package/src/spectrum-chevron.css.d.ts +0 -2
  46. package/src/spectrum-chevron.css.js +0 -21
  47. package/src/spectrum-chevron.css.js.map +0 -1
  48. package/src/spectrum-itemLabel.css.d.ts +0 -2
  49. package/src/spectrum-itemLabel.css.js +0 -17
  50. package/src/spectrum-itemLabel.css.js.map +0 -1
  51. package/src/spectrum-menu-divider.css.d.ts +0 -2
  52. package/src/spectrum-menu-divider.css.js +0 -19
  53. package/src/spectrum-menu-divider.css.js.map +0 -1
  54. package/src/spectrum-menu-item.css.d.ts +0 -2
  55. package/src/spectrum-menu-item.css.js +0 -68
  56. package/src/spectrum-menu-item.css.js.map +0 -1
  57. package/src/spectrum-menu-sectionHeading.css.d.ts +0 -2
  58. package/src/spectrum-menu-sectionHeading.css.js +0 -19
  59. package/src/spectrum-menu-sectionHeading.css.js.map +0 -1
  60. package/src/spectrum-menu.css.d.ts +0 -2
  61. package/src/spectrum-menu.css.js +0 -74
  62. package/src/spectrum-menu.css.js.map +0 -1
  63. package/stories/menu-group.stories.js +0 -136
  64. package/stories/menu-group.stories.js.map +0 -1
  65. package/stories/menu-item.stories.js +0 -82
  66. package/stories/menu-item.stories.js.map +0 -1
  67. package/stories/menu.stories.js +0 -246
  68. package/stories/menu.stories.js.map +0 -1
@@ -1,20 +0,0 @@
1
- import { CSSResultArray, TemplateResult } from '@spectrum-web-components/base';
2
- import { Menu } from './Menu.js';
3
- import '../sp-menu.js';
4
- /**
5
- * @element sp-menu-group
6
- *
7
- * @slot header - headline of the menu group
8
- * @slot - menu items to be listed in the group
9
- */
10
- export declare class MenuGroup extends Menu {
11
- static get styles(): CSSResultArray;
12
- private static instances;
13
- private headerId;
14
- constructor();
15
- private headerElements;
16
- private headerElement?;
17
- protected get ownRole(): string;
18
- protected updateLabel(): void;
19
- render(): TemplateResult;
20
- }
package/src/MenuGroup.js DELETED
@@ -1,79 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { __decorate } from "tslib";
13
- import { html, } from '@spectrum-web-components/base';
14
- import { queryAssignedNodes } from '@spectrum-web-components/base/src/decorators.js';
15
- import { Menu } from './Menu.js';
16
- import '../sp-menu.js';
17
- import menuGroupStyles from './menu-group.css.js';
18
- /**
19
- * @element sp-menu-group
20
- *
21
- * @slot header - headline of the menu group
22
- * @slot - menu items to be listed in the group
23
- */
24
- export class MenuGroup extends Menu {
25
- constructor() {
26
- super();
27
- MenuGroup.instances += 1;
28
- this.headerId = `sp-menu-group-label-${MenuGroup.instances}`;
29
- }
30
- static get styles() {
31
- return [...super.styles, menuGroupStyles];
32
- }
33
- get ownRole() {
34
- switch (this.selects) {
35
- case 'multiple':
36
- case 'single':
37
- case 'inherit':
38
- return 'group';
39
- default:
40
- return 'menu';
41
- }
42
- }
43
- updateLabel() {
44
- const headerElement = this.headerElements.length
45
- ? this.headerElements[0]
46
- : undefined;
47
- if (headerElement !== this.headerElement) {
48
- if (this.headerElement && this.headerElement.id === this.headerId) {
49
- this.headerElement.removeAttribute('id');
50
- }
51
- if (headerElement) {
52
- const headerId = headerElement.id || this.headerId;
53
- if (!headerElement.id) {
54
- headerElement.id = headerId;
55
- }
56
- this.setAttribute('aria-labelledby', headerId);
57
- }
58
- else {
59
- this.removeAttribute('aria-labelledby');
60
- }
61
- }
62
- this.headerElement = headerElement;
63
- }
64
- render() {
65
- return html `
66
- <span class="header" aria-hidden="true">
67
- <slot name="header" @slotchange=${this.updateLabel}></slot>
68
- </span>
69
- <sp-menu role="none">
70
- <slot></slot>
71
- </sp-menu>
72
- `;
73
- }
74
- }
75
- MenuGroup.instances = 0;
76
- __decorate([
77
- queryAssignedNodes('header', true)
78
- ], MenuGroup.prototype, "headerElements", void 0);
79
- //# sourceMappingURL=MenuGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MenuGroup.js","sourceRoot":"","sources":["MenuGroup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAEP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAErF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,eAAe,CAAC;AACvB,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,SAAU,SAAQ,IAAI;IAS/B;QACI,KAAK,EAAE,CAAC;QACR,SAAS,CAAC,SAAS,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,uBAAuB,SAAS,CAAC,SAAS,EAAE,CAAC;IACjE,CAAC;IAZM,MAAM,KAAK,MAAM;QACpB,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC9C,CAAC;IAiBD,IAAc,OAAO;QACjB,QAAQ,IAAI,CAAC,OAAO,EAAE;YAClB,KAAK,UAAU,CAAC;YAChB,KAAK,QAAQ,CAAC;YACd,KAAK,SAAS;gBACV,OAAO,OAAO,CAAC;YACnB;gBACI,OAAO,MAAM,CAAC;SACrB;IACL,CAAC;IAES,WAAW;QACjB,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM;YAC5C,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;YACxB,CAAC,CAAC,SAAS,CAAC;QAChB,IAAI,aAAa,KAAK,IAAI,CAAC,aAAa,EAAE;YACtC,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE;gBAC/D,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;aAC5C;YACD,IAAI,aAAa,EAAE;gBACf,MAAM,QAAQ,GAAG,aAAa,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC;gBACnD,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE;oBACnB,aAAa,CAAC,EAAE,GAAG,QAAQ,CAAC;iBAC/B;gBACD,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;aAClD;iBAAM;gBACH,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;aAC3C;SACJ;QACD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAEM,MAAM;QACT,OAAO,IAAI,CAAA;;kDAE+B,IAAI,CAAC,WAAW;;;;;SAKzD,CAAC;IACN,CAAC;;AAxDc,mBAAS,GAAG,CAAC,CAAC;AAW7B;IADC,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC;iDACc","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 { queryAssignedNodes } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { Menu } from './Menu.js';\nimport '../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 get styles(): CSSResultArray {\n return [...super.styles, menuGroupStyles];\n }\n\n private static instances = 0;\n\n private headerId!: string;\n\n public constructor() {\n super();\n MenuGroup.instances += 1;\n this.headerId = `sp-menu-group-label-${MenuGroup.instances}`;\n }\n\n @queryAssignedNodes('header', true)\n private headerElements!: NodeListOf<HTMLElement>;\n\n private headerElement?: HTMLElement;\n\n protected 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 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 render(): TemplateResult {\n return html`\n <span class=\"header\" aria-hidden=\"true\">\n <slot name=\"header\" @slotchange=${this.updateLabel}></slot>\n </span>\n <sp-menu role=\"none\">\n <slot></slot>\n </sp-menu>\n `;\n }\n}\n"]}
package/src/MenuItem.d.ts DELETED
@@ -1,86 +0,0 @@
1
- import { CSSResultArray, PropertyValues, TemplateResult } from '@spectrum-web-components/base';
2
- import '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';
3
- import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
4
- import { Menu } from './Menu.js';
5
- export declare class MenuItemRemovedEvent extends Event {
6
- constructor();
7
- get item(): MenuItem;
8
- _item: MenuItem;
9
- focused: boolean;
10
- reset(item: MenuItem): void;
11
- }
12
- export declare class MenuItemAddedOrUpdatedEvent extends Event {
13
- constructor();
14
- set focusRoot(root: Menu);
15
- set selectionRoot(root: Menu);
16
- get item(): MenuItem;
17
- _item: MenuItem;
18
- set currentAncestorWithSelects(ancestor: Menu | undefined);
19
- get currentAncestorWithSelects(): Menu | undefined;
20
- _currentAncestorWithSelects?: Menu;
21
- reset(item: MenuItem): void;
22
- }
23
- export declare type MenuItemChildren = {
24
- icon: Element[];
25
- content: Node[];
26
- };
27
- declare const MenuItem_base: typeof Focusable & {
28
- new (...args: any[]): import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
29
- prototype: import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
30
- };
31
- /**
32
- * @element sp-menu-item
33
- *
34
- * @slot - text content to display within the Menu Item
35
- * @slot icon - icon element to be placed at the start of the Menu Item
36
- * @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.
37
- * @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships
38
- * @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state
39
- */
40
- export declare class MenuItem extends MenuItem_base {
41
- static get styles(): CSSResultArray;
42
- static instanceCount: number;
43
- active: boolean;
44
- focused: boolean;
45
- selected: boolean;
46
- get value(): string;
47
- set value(value: string);
48
- private _value;
49
- /**
50
- * @private
51
- */
52
- get itemText(): string;
53
- noWrap: boolean;
54
- private anchorElement;
55
- get focusElement(): HTMLElement;
56
- get itemChildren(): MenuItemChildren;
57
- private _itemChildren?;
58
- constructor();
59
- click(): void;
60
- private handleClickCapture;
61
- private proxyFocus;
62
- private shouldProxyClick;
63
- protected breakItemChildrenCache(): void;
64
- protected render(): TemplateResult;
65
- private handleRemoveActive;
66
- private handlePointerdown;
67
- protected firstUpdated(changes: PropertyValues): void;
68
- updateAriaSelected(): void;
69
- setRole(role: string): void;
70
- protected updated(changes: PropertyValues<this>): void;
71
- connectedCallback(): void;
72
- _parentElement: HTMLElement;
73
- disconnectedCallback(): void;
74
- triggerUpdate(): Promise<void>;
75
- menuData: {
76
- focusRoot?: Menu;
77
- selectionRoot?: Menu;
78
- };
79
- }
80
- declare global {
81
- interface GlobalEventHandlersEventMap {
82
- 'sp-menu-item-added-or-updated': MenuItemAddedOrUpdatedEvent;
83
- 'sp-menu-item-removed': MenuItemRemovedEvent;
84
- }
85
- }
86
- export {};
package/src/MenuItem.js DELETED
@@ -1,295 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { __decorate } from "tslib";
13
- import { html, } from '@spectrum-web-components/base';
14
- import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
15
- import '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';
16
- import { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';
17
- import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
18
- import menuItemStyles from './menu-item.css.js';
19
- import checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';
20
- export class MenuItemRemovedEvent extends Event {
21
- constructor() {
22
- super('sp-menu-item-removed', {
23
- bubbles: true,
24
- composed: true,
25
- });
26
- this.focused = false;
27
- }
28
- get item() {
29
- return this._item;
30
- }
31
- reset(item) {
32
- this._item = item;
33
- }
34
- }
35
- export class MenuItemAddedOrUpdatedEvent extends Event {
36
- constructor() {
37
- super('sp-menu-item-added-or-updated', {
38
- bubbles: true,
39
- composed: true,
40
- });
41
- }
42
- set focusRoot(root) {
43
- this.item.menuData.focusRoot = this.item.menuData.focusRoot || root;
44
- }
45
- set selectionRoot(root) {
46
- this.item.menuData.selectionRoot =
47
- this.item.menuData.selectionRoot || root;
48
- }
49
- get item() {
50
- return this._item;
51
- }
52
- set currentAncestorWithSelects(ancestor) {
53
- this._currentAncestorWithSelects = ancestor;
54
- }
55
- get currentAncestorWithSelects() {
56
- return this._currentAncestorWithSelects;
57
- }
58
- reset(item) {
59
- this._item = item;
60
- this._currentAncestorWithSelects = undefined;
61
- item.menuData = {
62
- focusRoot: undefined,
63
- selectionRoot: undefined,
64
- };
65
- }
66
- }
67
- const addOrUpdateEvent = new MenuItemAddedOrUpdatedEvent();
68
- const removeEvent = new MenuItemRemovedEvent();
69
- /**
70
- * @element sp-menu-item
71
- *
72
- * @slot - text content to display within the Menu Item
73
- * @slot icon - icon element to be placed at the start of the Menu Item
74
- * @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.
75
- * @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships
76
- * @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state
77
- */
78
- export class MenuItem extends LikeAnchor(Focusable) {
79
- constructor() {
80
- super();
81
- this.active = false;
82
- this.focused = false;
83
- this.selected = false;
84
- this._value = '';
85
- this.noWrap = false;
86
- this.menuData = {
87
- focusRoot: undefined,
88
- selectionRoot: undefined,
89
- };
90
- this.proxyFocus = this.proxyFocus.bind(this);
91
- this.addEventListener('click', this.handleClickCapture, {
92
- capture: true,
93
- });
94
- }
95
- static get styles() {
96
- return [menuItemStyles, checkmarkStyles];
97
- }
98
- get value() {
99
- return this._value || this.itemText;
100
- }
101
- set value(value) {
102
- if (value === this._value) {
103
- return;
104
- }
105
- this._value = value || '';
106
- if (this._value) {
107
- this.setAttribute('value', this._value);
108
- }
109
- else {
110
- this.removeAttribute('value');
111
- }
112
- }
113
- /**
114
- * @private
115
- */
116
- get itemText() {
117
- return (this.textContent || /* c8 ignore next */ '').trim();
118
- }
119
- get focusElement() {
120
- return this;
121
- }
122
- get itemChildren() {
123
- if (this._itemChildren) {
124
- return this._itemChildren;
125
- }
126
- const iconSlot = this.shadowRoot.querySelector('slot[name="icon"]');
127
- const icon = !iconSlot
128
- ? []
129
- : iconSlot.assignedElements().map((element) => {
130
- const newElement = element.cloneNode(true);
131
- newElement.removeAttribute('slot');
132
- newElement.classList.toggle('icon');
133
- return newElement;
134
- });
135
- const contentSlot = this.shadowRoot.querySelector('slot:not([name])');
136
- const content = !contentSlot
137
- ? []
138
- : contentSlot.assignedNodes().map((node) => node.cloneNode(true));
139
- this._itemChildren = { icon, content };
140
- return this._itemChildren;
141
- }
142
- click() {
143
- if (this.disabled) {
144
- return;
145
- }
146
- if (this.shouldProxyClick()) {
147
- return;
148
- }
149
- super.click();
150
- }
151
- handleClickCapture(event) {
152
- if (this.disabled) {
153
- event.preventDefault();
154
- event.stopImmediatePropagation();
155
- event.stopPropagation();
156
- return false;
157
- }
158
- }
159
- proxyFocus() {
160
- this.focus();
161
- }
162
- shouldProxyClick() {
163
- let handled = false;
164
- if (this.anchorElement) {
165
- this.anchorElement.click();
166
- handled = true;
167
- }
168
- return handled;
169
- }
170
- breakItemChildrenCache() {
171
- this._itemChildren = undefined;
172
- this.triggerUpdate();
173
- }
174
- render() {
175
- return html `
176
- <slot name="icon" @slotchange=${this.breakItemChildrenCache}></slot>
177
- <div id="label">
178
- <slot
179
- id="slot"
180
- @slotchange=${this.breakItemChildrenCache}
181
- ></slot>
182
- </div>
183
- <slot name="value"></slot>
184
- ${this.selected
185
- ? html `
186
- <sp-icon-checkmark100
187
- id="selected"
188
- class="spectrum-UIIcon-Checkmark100 icon checkmark"
189
- ></sp-icon-checkmark100>
190
- `
191
- : html ``}
192
- ${this.href && this.href.length > 0
193
- ? super.renderAnchor({
194
- id: 'button',
195
- ariaHidden: true,
196
- className: 'button anchor hidden',
197
- })
198
- : html ``}
199
- `;
200
- }
201
- handleRemoveActive() {
202
- this.active = false;
203
- }
204
- handlePointerdown() {
205
- this.active = true;
206
- }
207
- firstUpdated(changes) {
208
- super.firstUpdated(changes);
209
- this.setAttribute('tabindex', '-1');
210
- this.addEventListener('pointerdown', this.handlePointerdown);
211
- if (!this.hasAttribute('id')) {
212
- this.id = `sp-menu-item-${MenuItem.instanceCount++}`;
213
- }
214
- }
215
- updateAriaSelected() {
216
- const role = this.getAttribute('role');
217
- if (role === 'option') {
218
- this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
219
- }
220
- else if (role === 'menuitemcheckbox' || role === 'menuitemradio') {
221
- this.setAttribute('aria-checked', this.selected ? 'true' : 'false');
222
- }
223
- }
224
- setRole(role) {
225
- this.setAttribute('role', role);
226
- this.updateAriaSelected();
227
- }
228
- updated(changes) {
229
- super.updated(changes);
230
- if (changes.has('label')) {
231
- this.setAttribute('aria-label', this.label || '');
232
- }
233
- if (changes.has('active')) {
234
- if (this.active) {
235
- this.addEventListener('pointerup', this.handleRemoveActive);
236
- this.addEventListener('pointerleave', this.handleRemoveActive);
237
- }
238
- else {
239
- this.removeEventListener('pointerup', this.handleRemoveActive);
240
- this.removeEventListener('pointerleave', this.handleRemoveActive);
241
- }
242
- }
243
- if (this.anchorElement) {
244
- this.anchorElement.addEventListener('focus', this.proxyFocus);
245
- this.anchorElement.tabIndex = -1;
246
- }
247
- if (changes.has('selected')) {
248
- this.updateAriaSelected();
249
- }
250
- }
251
- connectedCallback() {
252
- super.connectedCallback();
253
- addOrUpdateEvent.reset(this);
254
- this.dispatchEvent(addOrUpdateEvent);
255
- this._parentElement = this.parentElement;
256
- }
257
- disconnectedCallback() {
258
- var _a;
259
- removeEvent.reset(this);
260
- (_a = this._parentElement) === null || _a === void 0 ? void 0 : _a.dispatchEvent(removeEvent);
261
- super.disconnectedCallback();
262
- }
263
- async triggerUpdate() {
264
- await new Promise((ready) => requestAnimationFrame(ready));
265
- addOrUpdateEvent.reset(this);
266
- this.dispatchEvent(addOrUpdateEvent);
267
- }
268
- }
269
- MenuItem.instanceCount = 0;
270
- __decorate([
271
- property({ type: Boolean, reflect: true })
272
- ], MenuItem.prototype, "active", void 0);
273
- __decorate([
274
- property({ type: Boolean, reflect: true })
275
- ], MenuItem.prototype, "focused", void 0);
276
- __decorate([
277
- property({ type: Boolean, reflect: true })
278
- ], MenuItem.prototype, "selected", void 0);
279
- __decorate([
280
- property({ type: String })
281
- ], MenuItem.prototype, "value", null);
282
- __decorate([
283
- property({
284
- type: Boolean,
285
- reflect: true,
286
- attribute: 'no-wrap',
287
- hasChanged() {
288
- return false;
289
- },
290
- })
291
- ], MenuItem.prototype, "noWrap", void 0);
292
- __decorate([
293
- query('.anchor')
294
- ], MenuItem.prototype, "anchorElement", void 0);
295
- //# sourceMappingURL=MenuItem.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["MenuItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAGP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AAEzD,OAAO,iEAAiE,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAE7E,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAChD,OAAO,eAAe,MAAM,kEAAkE,CAAC;AAG/F,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC3C;QACI,KAAK,CAAC,sBAAsB,EAAE;YAC1B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QAMP,YAAO,GAAG,KAAK,CAAC;IALhB,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAGD,KAAK,CAAC,IAAc;QAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ;AAED,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAClD;QACI,KAAK,CAAC,+BAA+B,EAAE;YACnC,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC;IACD,IAAI,SAAS,CAAC,IAAU;QACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,I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,CAAC;KACJ,CAAC;wCACoB;AAGtB;IADC,KAAK,CAAC,SAAS,CAAC;+CACyB","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 PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\n\nimport menuItemStyles from './menu-item.css.js';\nimport checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';\nimport { Menu } from './Menu.js';\n\nexport class MenuItemRemovedEvent extends Event {\n constructor() {\n super('sp-menu-item-removed', {\n bubbles: true,\n composed: true,\n });\n }\n get item(): MenuItem {\n return this._item;\n }\n _item!: MenuItem;\n focused = false;\n reset(item: MenuItem): void {\n this._item = item;\n }\n}\n\nexport class MenuItemAddedOrUpdatedEvent extends Event {\n constructor() {\n super('sp-menu-item-added-or-updated', {\n bubbles: true,\n composed: true,\n });\n }\n set focusRoot(root: Menu) {\n this.item.menuData.focusRoot = this.item.menuData.focusRoot || root;\n }\n set selectionRoot(root: Menu) {\n this.item.menuData.selectionRoot =\n this.item.menuData.selectionRoot || root;\n }\n get item(): MenuItem {\n return this._item;\n }\n _item!: MenuItem;\n set currentAncestorWithSelects(ancestor: Menu | undefined) {\n this._currentAncestorWithSelects = ancestor;\n }\n get currentAncestorWithSelects(): Menu | undefined {\n return this._currentAncestorWithSelects;\n }\n _currentAncestorWithSelects?: Menu;\n reset(item: MenuItem): void {\n this._item = item;\n this._currentAncestorWithSelects = undefined;\n item.menuData = {\n focusRoot: undefined,\n selectionRoot: undefined,\n };\n }\n}\n\nexport type MenuItemChildren = { icon: Element[]; content: Node[] };\n\nconst addOrUpdateEvent = new MenuItemAddedOrUpdatedEvent();\nconst removeEvent = new MenuItemRemovedEvent();\n\n/**\n * @element sp-menu-item\n *\n * @slot - text content to display within the Menu Item\n * @slot icon - icon element to be placed at the start of the Menu Item\n * @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.\n * @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships\n * @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state\n */\nexport class MenuItem extends LikeAnchor(Focusable) {\n public static get styles(): CSSResultArray {\n return [menuItemStyles, checkmarkStyles];\n }\n\n static instanceCount = 0;\n\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ type: String })\n public get value(): string {\n return this._value || this.itemText;\n }\n\n public set value(value: string) {\n if (value === this._value) {\n return;\n }\n this._value = value || '';\n if (this._value) {\n this.setAttribute('value', this._value);\n } else {\n this.removeAttribute('value');\n }\n }\n\n private _value = '';\n\n /**\n * @private\n */\n public get itemText(): string {\n return (this.textContent || /* c8 ignore next */ '').trim();\n }\n\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'no-wrap',\n hasChanged() {\n return false;\n },\n })\n public noWrap = false;\n\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public get focusElement(): HTMLElement {\n return this;\n }\n\n public get itemChildren(): MenuItemChildren {\n if (this._itemChildren) {\n return this._itemChildren;\n }\n\n const iconSlot = this.shadowRoot.querySelector(\n 'slot[name=\"icon\"]'\n ) as HTMLSlotElement;\n const icon = !iconSlot\n ? []\n : iconSlot.assignedElements().map((element) => {\n const newElement = element.cloneNode(true) as HTMLElement;\n newElement.removeAttribute('slot');\n newElement.classList.toggle('icon');\n return newElement;\n });\n const contentSlot = this.shadowRoot.querySelector(\n 'slot:not([name])'\n ) as HTMLSlotElement;\n const content = !contentSlot\n ? []\n : contentSlot.assignedNodes().map((node) => node.cloneNode(true));\n this._itemChildren = { icon, content };\n\n return this._itemChildren;\n }\n\n private _itemChildren?: MenuItemChildren;\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n public click(): void {\n if (this.disabled) {\n return;\n }\n\n if (this.shouldProxyClick()) {\n return;\n }\n\n super.click();\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n event.stopPropagation();\n return false;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(): boolean {\n let handled = false;\n if (this.anchorElement) {\n this.anchorElement.click();\n handled = true;\n }\n return handled;\n }\n\n protected breakItemChildrenCache(): void {\n this._itemChildren = undefined;\n this.triggerUpdate();\n }\n\n protected render(): TemplateResult {\n return html`\n <slot name=\"icon\" @slotchange=${this.breakItemChildrenCache}></slot>\n <div id=\"label\">\n <slot\n id=\"slot\"\n @slotchange=${this.breakItemChildrenCache}\n ></slot>\n </div>\n <slot name=\"value\"></slot>\n ${this.selected\n ? html`\n <sp-icon-checkmark100\n id=\"selected\"\n class=\"spectrum-UIIcon-Checkmark100 icon checkmark\"\n ></sp-icon-checkmark100>\n `\n : html``}\n ${this.href && this.href.length > 0\n ? super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor hidden',\n })\n : html``}\n `;\n }\n\n private handleRemoveActive(): void {\n this.active = false;\n }\n\n private handlePointerdown(): void {\n this.active = true;\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('tabindex', '-1');\n this.addEventListener('pointerdown', this.handlePointerdown);\n if (!this.hasAttribute('id')) {\n this.id = `sp-menu-item-${MenuItem.instanceCount++}`;\n }\n }\n\n updateAriaSelected(): void {\n const role = this.getAttribute('role');\n if (role === 'option') {\n this.setAttribute(\n 'aria-selected',\n this.selected ? 'true' : 'false'\n );\n } else if (role === 'menuitemcheckbox' || role === 'menuitemradio') {\n this.setAttribute('aria-checked', this.selected ? 'true' : 'false');\n }\n }\n\n public setRole(role: string): void {\n this.setAttribute('role', role);\n this.updateAriaSelected();\n }\n\n protected updated(changes: PropertyValues<this>): void {\n super.updated(changes);\n if (changes.has('label')) {\n this.setAttribute('aria-label', this.label || '');\n }\n if (changes.has('active')) {\n if (this.active) {\n this.addEventListener('pointerup', this.handleRemoveActive);\n this.addEventListener('pointerleave', this.handleRemoveActive);\n } else {\n this.removeEventListener('pointerup', this.handleRemoveActive);\n this.removeEventListener(\n 'pointerleave',\n this.handleRemoveActive\n );\n }\n }\n if (this.anchorElement) {\n this.anchorElement.addEventListener('focus', this.proxyFocus);\n this.anchorElement.tabIndex = -1;\n }\n if (changes.has('selected')) {\n this.updateAriaSelected();\n }\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n addOrUpdateEvent.reset(this);\n this.dispatchEvent(addOrUpdateEvent);\n this._parentElement = this.parentElement as HTMLElement;\n }\n\n _parentElement!: HTMLElement;\n\n public disconnectedCallback(): void {\n removeEvent.reset(this);\n this._parentElement?.dispatchEvent(removeEvent);\n super.disconnectedCallback();\n }\n\n public async triggerUpdate(): Promise<void> {\n await new Promise((ready) => requestAnimationFrame(ready));\n addOrUpdateEvent.reset(this);\n this.dispatchEvent(addOrUpdateEvent);\n }\n\n public menuData: {\n focusRoot?: Menu;\n selectionRoot?: Menu;\n } = {\n focusRoot: undefined,\n selectionRoot: undefined,\n };\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-menu-item-added-or-updated': MenuItemAddedOrUpdatedEvent;\n 'sp-menu-item-removed': MenuItemRemovedEvent;\n }\n}\n"]}
package/src/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Menu.js';
2
- export * from './MenuDivider.js';
3
- export * from './MenuGroup.js';
4
- export * from './MenuItem.js';
package/src/index.js DELETED
@@ -1,16 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- export * from './Menu.js';
13
- export * from './MenuDivider.js';
14
- export * from './MenuGroup.js';
15
- export * from './MenuItem.js';
16
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC","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*/\nexport * from './Menu.js';\nexport * from './MenuDivider.js';\nexport * from './MenuGroup.js';\nexport * from './MenuItem.js';\n"]}
@@ -1,2 +0,0 @@
1
- declare const styles: import("@spectrum-web-components/base").CSSResult;
2
- export default styles;
@@ -1,19 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { css } from '@spectrum-web-components/base';
13
- const styles = css `
14
- :host{border:none;box-sizing:content-box;height:var(--spectrum-listitem-texticon-divider-size);margin:calc(var(--spectrum-listitem-texticon-divider-padding)/2) var(--spectrum-listitem-texticon-padding-y);overflow:visible;padding:0}:host{background-color:var(
15
- --spectrum-listitem-m-texticon-divider-color,var(--spectrum-alias-border-color-extralight)
16
- )}:host{display:block}
17
- `;
18
- export default styles;
19
- //# sourceMappingURL=menu-divider.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu-divider.css.js","sourceRoot":"","sources":["menu-divider.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIjB,CAAC;AACF,eAAe,MAAM,CAAC","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*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{border:none;box-sizing:content-box;height:var(--spectrum-listitem-texticon-divider-size);margin:calc(var(--spectrum-listitem-texticon-divider-padding)/2) var(--spectrum-listitem-texticon-padding-y);overflow:visible;padding:0}:host{background-color:var(\n--spectrum-listitem-m-texticon-divider-color,var(--spectrum-alias-border-color-extralight)\n)}:host{display:block}\n`;\nexport default styles;"]}
@@ -1,2 +0,0 @@
1
- declare const styles: import("@spectrum-web-components/base").CSSResult;
2
- export default styles;
@@ -1,19 +0,0 @@
1
- /*
2
- Copyright 2020 Adobe. All rights reserved.
3
- This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License. You may obtain a copy
5
- of the License at http://www.apache.org/licenses/LICENSE-2.0
6
-
7
- Unless required by applicable law or agreed to in writing, software distributed under
8
- the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- OF ANY KIND, either express or implied. See the License for the specific language
10
- governing permissions and limitations under the License.
11
- */
12
- import { css } from '@spectrum-web-components/base';
13
- const styles = css `
14
- .header{color:var(--spectrum-listheading-text-color);display:block;font-size:var(--spectrum-listitem-texticon-heading-text-size);font-weight:var(--spectrum-listitem-texticon-heading-text-font-weight);letter-spacing:var(
15
- --spectrum-listitem-texticon-heading-letter-spacing
16
- );line-height:var(--spectrum-listitem-texticon-heading-line-height);margin:var(--spectrum-listitem-texticon-heading-margin);padding:var(--spectrum-listitem-texticon-heading-padding);text-transform:var(--spectrum-listitem-texticon-heading-text-transform)}:host{display:inline;margin:0;overflow:visible}:host([dir=ltr]) .header{padding:0 var(--spectrum-global-dimension-size-450) 0 var(--spectrum-global-dimension-size-150)}:host([dir=rtl]) .header{padding:0 var(--spectrum-global-dimension-size-150) 0 var(--spectrum-global-dimension-size-450)}sp-menu{display:block}
17
- `;
18
- export default styles;
19
- //# sourceMappingURL=menu-group.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu-group.css.js","sourceRoot":"","sources":["menu-group.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIjB,CAAC;AACF,eAAe,MAAM,CAAC","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*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n.header{color:var(--spectrum-listheading-text-color);display:block;font-size:var(--spectrum-listitem-texticon-heading-text-size);font-weight:var(--spectrum-listitem-texticon-heading-text-font-weight);letter-spacing:var(\n--spectrum-listitem-texticon-heading-letter-spacing\n);line-height:var(--spectrum-listitem-texticon-heading-line-height);margin:var(--spectrum-listitem-texticon-heading-margin);padding:var(--spectrum-listitem-texticon-heading-padding);text-transform:var(--spectrum-listitem-texticon-heading-text-transform)}:host{display:inline;margin:0;overflow:visible}:host([dir=ltr]) .header{padding:0 var(--spectrum-global-dimension-size-450) 0 var(--spectrum-global-dimension-size-150)}:host([dir=rtl]) .header{padding:0 var(--spectrum-global-dimension-size-150) 0 var(--spectrum-global-dimension-size-450)}sp-menu{display:block}\n`;\nexport default styles;"]}
@@ -1,2 +0,0 @@
1
- declare const styles: import("@spectrum-web-components/base").CSSResult;
2
- export default styles;