@spectrum-web-components/menu 0.11.0 → 0.11.1

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.
@@ -1679,10 +1679,18 @@
1679
1679
  "kind": "field",
1680
1680
  "name": "itemChildren",
1681
1681
  "type": {
1682
- "text": "{ icon: Element[]; content: Node[] }"
1682
+ "text": "MenuItemChildren"
1683
1683
  },
1684
1684
  "privacy": "public"
1685
1685
  },
1686
+ {
1687
+ "kind": "field",
1688
+ "name": "_itemChildren",
1689
+ "type": {
1690
+ "text": "MenuItemChildren | undefined"
1691
+ },
1692
+ "privacy": "private"
1693
+ },
1686
1694
  {
1687
1695
  "kind": "method",
1688
1696
  "name": "click",
@@ -1731,6 +1739,16 @@
1731
1739
  }
1732
1740
  }
1733
1741
  },
1742
+ {
1743
+ "kind": "method",
1744
+ "name": "breakItemChildrenCache",
1745
+ "privacy": "protected",
1746
+ "return": {
1747
+ "type": {
1748
+ "text": "void"
1749
+ }
1750
+ }
1751
+ },
1734
1752
  {
1735
1753
  "kind": "method",
1736
1754
  "name": "handleRemoveActive",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/menu",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -50,20 +50,20 @@
50
50
  "lit-html"
51
51
  ],
52
52
  "dependencies": {
53
- "@spectrum-web-components/action-button": "^0.7.0",
54
- "@spectrum-web-components/base": "^0.5.0",
55
- "@spectrum-web-components/icon": "^0.11.0",
56
- "@spectrum-web-components/icons-ui": "^0.8.0",
57
- "@spectrum-web-components/shared": "^0.13.0",
53
+ "@spectrum-web-components/action-button": "^0.7.1",
54
+ "@spectrum-web-components/base": "^0.5.1",
55
+ "@spectrum-web-components/icon": "^0.11.1",
56
+ "@spectrum-web-components/icons-ui": "^0.8.1",
57
+ "@spectrum-web-components/shared": "^0.13.1",
58
58
  "tslib": "^2.0.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@spectrum-css/menu": "^3.0.5"
61
+ "@spectrum-css/menu": "^3.0.10"
62
62
  },
63
63
  "types": "./src/index.d.ts",
64
64
  "customElements": "custom-elements.json",
65
65
  "sideEffects": [
66
66
  "./sp-*.js"
67
67
  ],
68
- "gitHead": "7ce77352f6894043bceac9ef92b21e5f85420969"
68
+ "gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b"
69
69
  }
package/src/MenuItem.d.ts CHANGED
@@ -20,6 +20,10 @@ export declare class MenuItemAddedOrUpdatedEvent extends Event {
20
20
  _currentAncestorWithSelects?: Menu;
21
21
  reset(item: MenuItem): void;
22
22
  }
23
+ export declare type MenuItemChildren = {
24
+ icon: Element[];
25
+ content: Node[];
26
+ };
23
27
  declare const MenuItem_base: typeof Focusable & {
24
28
  new (...args: any[]): import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
25
29
  prototype: import("@spectrum-web-components/shared/src/like-anchor.js").LikeAnchorInterface;
@@ -49,15 +53,14 @@ export declare class MenuItem extends MenuItem_base {
49
53
  noWrap: boolean;
50
54
  private anchorElement;
51
55
  get focusElement(): HTMLElement;
52
- get itemChildren(): {
53
- icon: Element[];
54
- content: Node[];
55
- };
56
+ get itemChildren(): MenuItemChildren;
57
+ private _itemChildren?;
56
58
  constructor();
57
59
  click(): void;
58
60
  private handleClickCapture;
59
61
  private proxyFocus;
60
62
  private shouldProxyClick;
63
+ protected breakItemChildrenCache(): void;
61
64
  protected render(): TemplateResult;
62
65
  private handleRemoveActive;
63
66
  private handlePointerdown;
package/src/MenuItem.js CHANGED
@@ -120,6 +120,9 @@ export class MenuItem extends LikeAnchor(Focusable) {
120
120
  return this;
121
121
  }
122
122
  get itemChildren() {
123
+ if (this._itemChildren) {
124
+ return this._itemChildren;
125
+ }
123
126
  const iconSlot = this.shadowRoot.querySelector('slot[name="icon"]');
124
127
  const icon = !iconSlot
125
128
  ? []
@@ -133,7 +136,8 @@ export class MenuItem extends LikeAnchor(Focusable) {
133
136
  const content = !contentSlot
134
137
  ? []
135
138
  : contentSlot.assignedNodes().map((node) => node.cloneNode(true));
136
- return { icon, content };
139
+ this._itemChildren = { icon, content };
140
+ return this._itemChildren;
137
141
  }
138
142
  click() {
139
143
  if (this.disabled) {
@@ -163,11 +167,18 @@ export class MenuItem extends LikeAnchor(Focusable) {
163
167
  }
164
168
  return handled;
165
169
  }
170
+ breakItemChildrenCache() {
171
+ this._itemChildren = undefined;
172
+ this.triggerUpdate();
173
+ }
166
174
  render() {
167
175
  return html `
168
- <slot name="icon"></slot>
176
+ <slot name="icon" @slotchange=${this.breakItemChildrenCache}></slot>
169
177
  <div id="label">
170
- <slot id="slot"></slot>
178
+ <slot
179
+ id="slot"
180
+ @slotchange=${this.breakItemChildrenCache}
181
+ ></slot>
171
182
  </div>
172
183
  <slot name="value"></slot>
173
184
  ${this.selected
@@ -1 +1 @@
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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U;YACN,OAAO,KAAK,CAAC;QACjB,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\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(): { icon: Element[]; content: Node[] } {\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 return { icon, content };\n }\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 render(): TemplateResult {\n return html`\n <slot name=\"icon\"></slot>\n <div id=\"label\">\n <slot id=\"slot\"></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"]}
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,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QAChD,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,aAAa;QACtB,MAAM,IAAI,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACzC,CAAC;;AA9OM,sBAAa,GAAG,CAAC,CAAC;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCACrB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCACpB;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACnB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qCAG1B;AA+BD;IARC,QAAQ,CAAC;QACN,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,SAAS;QACpB,UAAU;YACN,OAAO,KAAK,CAAC;QACjB,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"]}
@@ -1,15 +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 * as stories from '../stories/menu-group.stories.js';
13
- import { regressVisuals } from '../../../test/visual/test.js';
14
- regressVisuals('MenuGroupStories', stories);
15
- //# sourceMappingURL=menu-group.test-vrt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu-group.test-vrt.js","sourceRoot":"","sources":["menu-group.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,kBAAkB,EAAE,OAAO,CAAC,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*/\n\nimport * as stories from '../stories/menu-group.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('MenuGroupStories', stories);\n"]}
@@ -1,226 +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 '../sp-menu-group.js';
13
- import '../sp-menu.js';
14
- import '../sp-menu-item.js';
15
- import '../sp-menu-divider.js';
16
- import { elementUpdated, expect, fixture, html, oneEvent, waitUntil, } from '@open-wc/testing';
17
- const managedItems = (menu) => {
18
- return menu.childItems.filter((item) => item.menuData.selectionRoot === menu);
19
- };
20
- describe('Menu group', () => {
21
- it('renders', async () => {
22
- const el = await fixture(html `
23
- <sp-menu selects="single">
24
- <sp-menu-group selects="inherit">
25
- <span slot="header">Section Heading</span>
26
- <sp-menu-item>Action 1</sp-menu-item>
27
- <sp-menu-item>Action 2</sp-menu-item>
28
- <sp-menu-item>Action 3</sp-menu-item>
29
- </sp-menu-group>
30
- <sp-menu-divider></sp-menu-divider>
31
- <sp-menu-group selects="inherit">
32
- <span slot="header">Section Heading</span>
33
- <sp-menu-item>Save</sp-menu-item>
34
- <sp-menu-item disabled>Download</sp-menu-item>
35
- </sp-menu-group>
36
- </sp-menu>
37
- `);
38
- await waitUntil(() => {
39
- return managedItems(el).length === 5;
40
- }, `expected menu group to manage 5 children, received ${managedItems(el).length} of ${el.childItems.length}`);
41
- await elementUpdated(el);
42
- await expect(el).to.be.accessible();
43
- });
44
- it('manages [slot="header"] content', async () => {
45
- const el = await fixture(html `
46
- <sp-menu-group></sp-menu-group>
47
- `);
48
- await elementUpdated(el);
49
- const slot = el.shadowRoot.querySelector('[name="header"');
50
- const header = document.createElement('span');
51
- header.textContent = 'Header';
52
- header.slot = 'header';
53
- expect(header.id).to.equal('');
54
- let slotchanged = oneEvent(slot, 'slotchange');
55
- el.append(header);
56
- await slotchanged;
57
- expect(header.id).to.equal(el.headerId);
58
- slotchanged = oneEvent(slot, 'slotchange');
59
- header.remove();
60
- await slotchanged;
61
- expect(header.id).to.equal('');
62
- });
63
- it('handles selects for nested menu groups', async () => {
64
- const el = await fixture(html `
65
- <sp-menu selects="single">
66
- <sp-menu-item selected>First</sp-menu-item>
67
- <sp-menu-item>Second</sp-menu-item>
68
- <sp-menu-group id="mg-multi" selects="multiple">
69
- <sp-menu-item selected>Multi1</sp-menu-item>
70
- <sp-menu-item>Multi2</sp-menu-item>
71
- <sp-menu-group id="mg-sub-inherit" selects="inherit">
72
- <sp-menu-item>SubInherit1</sp-menu-item>
73
- <sp-menu-item>SubInherit2</sp-menu-item>
74
- </sp-menu-group>
75
- </sp-menu-group>
76
- <sp-menu-group id="mg-single" selects="single">
77
- <sp-menu-item selected>Single1</sp-menu-item>
78
- <sp-menu-item>Single2</sp-menu-item>
79
- </sp-menu-group>
80
- <sp-menu-group id="mg-none">
81
- <sp-menu-item>Inherit1</sp-menu-item>
82
- <sp-menu-item>Inherit2</sp-menu-item>
83
- </sp-menu-group>
84
- <sp-menu-group id="mg-inherit" selects="inherit">
85
- <sp-menu-item>Inherit1</sp-menu-item>
86
- <sp-menu-item>Inherit2</sp-menu-item>
87
- </sp-menu-group>
88
- </sp-menu>
89
- `);
90
- await waitUntil(() => managedItems(el).length === 4, `expected outer menu to manage 4 items (2 are inherited), got ${managedItems(el).length}, with ${el.childItems.length} total`);
91
- await waitUntil(() => el.selectedItems.length === 1, 'expected 1 selected item');
92
- await elementUpdated(el);
93
- const firstItem = el.querySelector('sp-menu-item:nth-of-type(1)');
94
- const secondItem = el.querySelector('sp-menu-item:nth-of-type(2)');
95
- const multiGroup = el.querySelector('sp-menu-group#mg-multi');
96
- const multiItem1 = multiGroup.querySelector('sp-menu-item:nth-of-type(1)');
97
- const multiItem2 = multiGroup.querySelector('sp-menu-item:nth-of-type(2)');
98
- await waitUntil(() => managedItems(multiGroup).length === 4, `selects="#mg-multi should manage 4 items (2 are inherited), received ${managedItems(multiGroup).length}`);
99
- const singleGroup = el.querySelector('sp-menu-group#mg-single');
100
- const singleItem1 = singleGroup.querySelector('sp-menu-item:nth-of-type(1)');
101
- const singleItem2 = singleGroup.querySelector('sp-menu-item:nth-of-type(2)');
102
- await waitUntil(() => managedItems(singleGroup).length === 2, 'selects="#mg-none should manage 4 items (2 are inherited)');
103
- const noneGroup = el.querySelector('sp-menu-group#mg-none');
104
- const noneItem1 = noneGroup.querySelector('sp-menu-item:nth-of-type(1)');
105
- const noneItem2 = noneGroup.querySelector('sp-menu-item:nth-of-type(2)');
106
- await waitUntil(() => managedItems(noneGroup).length === 2, `selects="#mg-none" should manage 2 items, received ${managedItems(noneGroup).length}`);
107
- const inheritGroup = el.querySelector('sp-menu-group#mg-inherit');
108
- const inheritItem1 = inheritGroup.querySelector('sp-menu-item:nth-of-type(1)');
109
- const inheritItem2 = inheritGroup.querySelector('sp-menu-item:nth-of-type(2)');
110
- expect(firstItem.getAttribute('role')).to.equal('menuitemradio');
111
- expect(secondItem.getAttribute('role')).to.equal('menuitemradio');
112
- expect(multiItem1.getAttribute('role')).to.equal('menuitemcheckbox');
113
- expect(multiItem2.getAttribute('role')).to.equal('menuitemcheckbox');
114
- expect(singleItem1.getAttribute('role')).to.equal('menuitemradio');
115
- expect(singleItem2.getAttribute('role')).to.equal('menuitemradio');
116
- expect(noneItem1.getAttribute('role')).to.equal('menuitem');
117
- expect(noneItem2.getAttribute('role')).to.equal('menuitem');
118
- expect(inheritItem1.getAttribute('role')).to.equal('menuitemradio');
119
- expect(inheritItem2.getAttribute('role')).to.equal('menuitemradio');
120
- await elementUpdated(firstItem);
121
- expect(singleItem1.selected).to.be.true;
122
- expect(firstItem.selected).to.be.true;
123
- expect(secondItem.selected, 'second item not selected').to.be.false;
124
- expect(el.value).to.equal('First');
125
- expect(el.selectedItems.length).to.equal(1);
126
- expect(firstItem.getAttribute('aria-checked')).to.equal('true');
127
- expect(secondItem.getAttribute('aria-checked')).to.equal('false');
128
- secondItem.click();
129
- await elementUpdated(el);
130
- await elementUpdated(firstItem);
131
- await elementUpdated(secondItem);
132
- expect(firstItem.selected, 'first item not selected').to.be.false;
133
- expect(secondItem.selected).to.be.true;
134
- expect(firstItem.getAttribute('aria-checked')).to.equal('false');
135
- expect(secondItem.getAttribute('aria-checked')).to.equal('true');
136
- expect(el.value).to.equal('Second');
137
- expect(el.selectedItems.length).to.equal(1);
138
- inheritItem1.click();
139
- await elementUpdated(el);
140
- await elementUpdated(inheritItem1);
141
- await elementUpdated(secondItem);
142
- expect(secondItem.selected, 'second item not selected again').to.be
143
- .false;
144
- expect(inheritItem1.selected).to.be.true;
145
- expect(secondItem.getAttribute('aria-checked')).to.equal('false');
146
- expect(inheritItem1.getAttribute('aria-checked')).to.equal('true');
147
- expect(el.value).to.equal('Inherit1');
148
- expect(el.selectedItems.length).to.equal(1);
149
- noneItem2.click();
150
- await elementUpdated(noneGroup);
151
- await elementUpdated(noneItem2);
152
- expect(inheritItem1.selected).to.be.true;
153
- expect(noneItem2.selected, 'none item not selected').to.be.false;
154
- expect(el.value).to.equal('Inherit1');
155
- expect(el.selectedItems.length).to.equal(1);
156
- singleItem2.click();
157
- await elementUpdated(singleGroup);
158
- await elementUpdated(singleItem1);
159
- await elementUpdated(singleItem2);
160
- expect(singleItem1.selected, 'first item not selected').to.be.false;
161
- expect(singleItem2.selected).to.be.true;
162
- expect(inheritItem1.selected).to.be.true;
163
- expect(singleItem1.getAttribute('aria-checked')).to.equal('false');
164
- expect(singleItem2.getAttribute('aria-checked')).to.equal('true');
165
- expect(el.value).to.equal('Inherit1');
166
- expect(el.selectedItems.length).to.equal(1);
167
- //expect(singleGroup.value).to.equal('Inherit1')
168
- expect(singleGroup.selectedItems.length).to.equal(1);
169
- multiItem2.click();
170
- await elementUpdated(el);
171
- await elementUpdated(multiItem2);
172
- expect(multiItem1.selected).to.be.true;
173
- expect(multiItem2.selected).to.be.true;
174
- expect(inheritItem1.selected).to.be.true;
175
- expect(multiItem1.getAttribute('aria-checked')).to.equal('true');
176
- expect(multiItem2.getAttribute('aria-checked')).to.equal('true');
177
- //expect(multiGroup.value).to.equal('Inherit1')
178
- expect(multiGroup.selectedItems.length).to.equal(2);
179
- });
180
- it('handles changing managed items for selects changes', async () => {
181
- const el = await fixture(html `
182
- <sp-menu selects="multiple" value-separator="--">
183
- <sp-menu-item selected>First</sp-menu-item>
184
- <sp-menu-item>Second</sp-menu-item>
185
- <sp-menu-group id="mg-inherit" selects="inherit">
186
- <sp-menu-item>Inherit1</sp-menu-item>
187
- <sp-menu-item>Inherit2</sp-menu-item>
188
- <sp-menu-group id="mg-sub-inherit" selects="inherit">
189
- <sp-menu-item>SubInherit1</sp-menu-item>
190
- <sp-menu-item selected>SubInherit2</sp-menu-item>
191
- </sp-menu-group>
192
- </sp-menu-group>
193
- </sp-menu>
194
- `);
195
- await waitUntil(() => managedItems(el).length == 6, `expected outer menu to manage 6 items, manages ${managedItems(el).length}`);
196
- await waitUntil(() => el.selectedItems.length == 2, 'expected 2 selected item');
197
- await elementUpdated(el);
198
- const inheritGroup = el.querySelector('sp-menu-group#mg-inherit');
199
- const inheritItem1 = inheritGroup.querySelector('sp-menu-item:nth-of-type(1)');
200
- const inheritItem2 = inheritGroup.querySelector('sp-menu-item:nth-of-type(2)');
201
- const subInheritGroup = el.querySelector('sp-menu-group#mg-sub-inherit');
202
- const subInheritItem1 = subInheritGroup.querySelector('sp-menu-item:nth-of-type(1)');
203
- const subInheritItem2 = subInheritGroup.querySelector('sp-menu-item:nth-of-type(2)');
204
- expect(inheritItem1.getAttribute('role')).to.equal('menuitemcheckbox');
205
- expect(inheritItem2.getAttribute('role')).to.equal('menuitemcheckbox');
206
- expect(subInheritItem1.getAttribute('role')).to.equal('menuitemcheckbox');
207
- expect(subInheritItem2.getAttribute('role')).to.equal('menuitemcheckbox');
208
- expect(el.value).to.equal('First--SubInherit2');
209
- expect(el.selectedItems.length).to.equal(2);
210
- inheritGroup.setAttribute('selects', 'single');
211
- await elementUpdated(inheritGroup);
212
- await elementUpdated(el);
213
- await waitUntil(() => {
214
- return managedItems(inheritGroup).length === 4;
215
- }, `expected new single sub-group to manage 4 items, received ${managedItems(inheritGroup).length} because "selects === ${inheritGroup.selects}`);
216
- await waitUntil(() => managedItems(el).length === 2, `expected outer menu to manage 2 items with none inherited, received ${managedItems(el).length}`);
217
- expect(inheritGroup.value).to.equal('SubInherit2');
218
- expect(inheritGroup.selectedItems.length).to.equal(1);
219
- expect(el.value).to.equal('First');
220
- expect(inheritItem1.getAttribute('role')).to.equal('menuitemradio');
221
- expect(inheritItem2.getAttribute('role')).to.equal('menuitemradio');
222
- expect(subInheritItem1.getAttribute('role')).to.equal('menuitemradio');
223
- expect(subInheritItem2.getAttribute('role')).to.equal('menuitemradio');
224
- });
225
- });
226
- //# sourceMappingURL=menu-group.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu-group.test.js","sourceRoot":"","sources":["menu-group.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,qBAAqB,CAAC;AAC7B,OAAO,eAAe,CAAC;AACvB,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EACH,cAAc,EACd,MAAM,EACN,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,SAAS,GACZ,MAAM,kBAAkB,CAAC;AAE1B,MAAM,YAAY,GAAG,CAAC,IAAsB,EAAc,EAAE;IACxD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CACzB,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,KAAK,IAAI,CAC3D,CAAC;AACN,CAAC,CAAC;AAEF,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACrB,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;;;;;;;;;;;;;;aAeH,CACJ,CAAC;QAEF,MAAM,SAAS,CAAC,GAAG,EAAE;YACjB,OAAO,YAAY,CAAC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;QACzC,CAAC,EAAE,sDAAsD,YAAY,CAAC,EAAE,CAAC,CAAC,MAAM,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/G,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA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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 '../sp-menu-group.js';\nimport '../sp-menu.js';\nimport '../sp-menu-item.js';\nimport '../sp-menu-divider.js';\nimport { Menu, MenuGroup, MenuItem } from '../';\nimport {\n elementUpdated,\n expect,\n fixture,\n html,\n oneEvent,\n waitUntil,\n} from '@open-wc/testing';\n\nconst managedItems = (menu: Menu | MenuGroup): MenuItem[] => {\n return menu.childItems.filter(\n (item: MenuItem) => item.menuData.selectionRoot === menu\n );\n};\n\ndescribe('Menu group', () => {\n it('renders', async () => {\n const el = await fixture<Menu>(\n html`\n <sp-menu selects=\"single\">\n <sp-menu-group selects=\"inherit\">\n <span slot=\"header\">Section Heading</span>\n <sp-menu-item>Action 1</sp-menu-item>\n <sp-menu-item>Action 2</sp-menu-item>\n <sp-menu-item>Action 3</sp-menu-item>\n </sp-menu-group>\n <sp-menu-divider></sp-menu-divider>\n <sp-menu-group selects=\"inherit\">\n <span slot=\"header\">Section Heading</span>\n <sp-menu-item>Save</sp-menu-item>\n <sp-menu-item disabled>Download</sp-menu-item>\n </sp-menu-group>\n </sp-menu>\n `\n );\n\n await waitUntil(() => {\n return managedItems(el).length === 5;\n }, `expected menu group to manage 5 children, received ${managedItems(el).length} of ${el.childItems.length}`);\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n });\n it('manages [slot=\"header\"] content', async () => {\n const el = await fixture<MenuGroup>(\n html`\n <sp-menu-group></sp-menu-group>\n `\n );\n await elementUpdated(el);\n const slot = el.shadowRoot.querySelector(\n '[name=\"header\"'\n ) as HTMLSlotElement;\n const header = document.createElement('span');\n header.textContent = 'Header';\n header.slot = 'header';\n expect(header.id).to.equal('');\n let slotchanged = oneEvent(slot, 'slotchange');\n el.append(header);\n await slotchanged;\n expect(header.id).to.equal(\n (el as unknown as { headerId: string }).headerId\n );\n\n slotchanged = oneEvent(slot, 'slotchange');\n header.remove();\n await slotchanged;\n expect(header.id).to.equal('');\n });\n it('handles selects for nested menu groups', async () => {\n const el = await fixture<Menu>(\n html`\n <sp-menu selects=\"single\">\n <sp-menu-item selected>First</sp-menu-item>\n <sp-menu-item>Second</sp-menu-item>\n <sp-menu-group id=\"mg-multi\" selects=\"multiple\">\n <sp-menu-item selected>Multi1</sp-menu-item>\n <sp-menu-item>Multi2</sp-menu-item>\n <sp-menu-group id=\"mg-sub-inherit\" selects=\"inherit\">\n <sp-menu-item>SubInherit1</sp-menu-item>\n <sp-menu-item>SubInherit2</sp-menu-item>\n </sp-menu-group>\n </sp-menu-group>\n <sp-menu-group id=\"mg-single\" selects=\"single\">\n <sp-menu-item selected>Single1</sp-menu-item>\n <sp-menu-item>Single2</sp-menu-item>\n </sp-menu-group>\n <sp-menu-group id=\"mg-none\">\n <sp-menu-item>Inherit1</sp-menu-item>\n <sp-menu-item>Inherit2</sp-menu-item>\n </sp-menu-group>\n <sp-menu-group id=\"mg-inherit\" selects=\"inherit\">\n <sp-menu-item>Inherit1</sp-menu-item>\n <sp-menu-item>Inherit2</sp-menu-item>\n </sp-menu-group>\n </sp-menu>\n `\n );\n\n await waitUntil(\n () => managedItems(el).length === 4,\n `expected outer menu to manage 4 items (2 are inherited), got ${\n managedItems(el).length\n }, with ${el.childItems.length} total`\n );\n await waitUntil(\n () => el.selectedItems.length === 1,\n 'expected 1 selected item'\n );\n await elementUpdated(el);\n\n const firstItem = el.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n\n const secondItem = el.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n\n const multiGroup = el.querySelector(\n 'sp-menu-group#mg-multi'\n ) as MenuGroup;\n const multiItem1 = multiGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const multiItem2 = multiGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n await waitUntil(\n () => managedItems(multiGroup).length === 4,\n `selects=\"#mg-multi should manage 4 items (2 are inherited), received ${\n managedItems(multiGroup).length\n }`\n );\n\n const singleGroup = el.querySelector(\n 'sp-menu-group#mg-single'\n ) as MenuGroup;\n\n const singleItem1 = singleGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const singleItem2 = singleGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n await waitUntil(\n () => managedItems(singleGroup).length === 2,\n 'selects=\"#mg-none should manage 4 items (2 are inherited)'\n );\n\n const noneGroup = el.querySelector(\n 'sp-menu-group#mg-none'\n ) as MenuGroup;\n const noneItem1 = noneGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const noneItem2 = noneGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n await waitUntil(\n () => managedItems(noneGroup).length === 2,\n `selects=\"#mg-none\" should manage 2 items, received ${\n managedItems(noneGroup).length\n }`\n );\n\n const inheritGroup = el.querySelector(\n 'sp-menu-group#mg-inherit'\n ) as MenuGroup;\n const inheritItem1 = inheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const inheritItem2 = inheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n\n expect(firstItem.getAttribute('role')).to.equal('menuitemradio');\n expect(secondItem.getAttribute('role')).to.equal('menuitemradio');\n expect(multiItem1.getAttribute('role')).to.equal('menuitemcheckbox');\n expect(multiItem2.getAttribute('role')).to.equal('menuitemcheckbox');\n expect(singleItem1.getAttribute('role')).to.equal('menuitemradio');\n expect(singleItem2.getAttribute('role')).to.equal('menuitemradio');\n expect(noneItem1.getAttribute('role')).to.equal('menuitem');\n expect(noneItem2.getAttribute('role')).to.equal('menuitem');\n expect(inheritItem1.getAttribute('role')).to.equal('menuitemradio');\n expect(inheritItem2.getAttribute('role')).to.equal('menuitemradio');\n\n await elementUpdated(firstItem);\n expect(singleItem1.selected).to.be.true;\n expect(firstItem.selected).to.be.true;\n expect(secondItem.selected, 'second item not selected').to.be.false;\n expect(el.value).to.equal('First');\n expect(el.selectedItems.length).to.equal(1);\n\n expect(firstItem.getAttribute('aria-checked')).to.equal('true');\n expect(secondItem.getAttribute('aria-checked')).to.equal('false');\n\n secondItem.click();\n await elementUpdated(el);\n await elementUpdated(firstItem);\n await elementUpdated(secondItem);\n expect(firstItem.selected, 'first item not selected').to.be.false;\n expect(secondItem.selected).to.be.true;\n expect(firstItem.getAttribute('aria-checked')).to.equal('false');\n expect(secondItem.getAttribute('aria-checked')).to.equal('true');\n expect(el.value).to.equal('Second');\n expect(el.selectedItems.length).to.equal(1);\n\n inheritItem1.click();\n await elementUpdated(el);\n await elementUpdated(inheritItem1);\n await elementUpdated(secondItem);\n expect(secondItem.selected, 'second item not selected again').to.be\n .false;\n expect(inheritItem1.selected).to.be.true;\n expect(secondItem.getAttribute('aria-checked')).to.equal('false');\n expect(inheritItem1.getAttribute('aria-checked')).to.equal('true');\n expect(el.value).to.equal('Inherit1');\n expect(el.selectedItems.length).to.equal(1);\n\n noneItem2.click();\n await elementUpdated(noneGroup);\n await elementUpdated(noneItem2);\n expect(inheritItem1.selected).to.be.true;\n expect(noneItem2.selected, 'none item not selected').to.be.false;\n expect(el.value).to.equal('Inherit1');\n expect(el.selectedItems.length).to.equal(1);\n\n singleItem2.click();\n await elementUpdated(singleGroup);\n await elementUpdated(singleItem1);\n await elementUpdated(singleItem2);\n expect(singleItem1.selected, 'first item not selected').to.be.false;\n expect(singleItem2.selected).to.be.true;\n expect(inheritItem1.selected).to.be.true;\n expect(singleItem1.getAttribute('aria-checked')).to.equal('false');\n expect(singleItem2.getAttribute('aria-checked')).to.equal('true');\n expect(el.value).to.equal('Inherit1');\n expect(el.selectedItems.length).to.equal(1);\n //expect(singleGroup.value).to.equal('Inherit1')\n expect(singleGroup.selectedItems.length).to.equal(1);\n\n multiItem2.click();\n await elementUpdated(el);\n await elementUpdated(multiItem2);\n expect(multiItem1.selected).to.be.true;\n expect(multiItem2.selected).to.be.true;\n expect(inheritItem1.selected).to.be.true;\n expect(multiItem1.getAttribute('aria-checked')).to.equal('true');\n expect(multiItem2.getAttribute('aria-checked')).to.equal('true');\n //expect(multiGroup.value).to.equal('Inherit1')\n expect(multiGroup.selectedItems.length).to.equal(2);\n });\n\n it('handles changing managed items for selects changes', async () => {\n const el = await fixture<Menu>(\n html`\n <sp-menu selects=\"multiple\" value-separator=\"--\">\n <sp-menu-item selected>First</sp-menu-item>\n <sp-menu-item>Second</sp-menu-item>\n <sp-menu-group id=\"mg-inherit\" selects=\"inherit\">\n <sp-menu-item>Inherit1</sp-menu-item>\n <sp-menu-item>Inherit2</sp-menu-item>\n <sp-menu-group id=\"mg-sub-inherit\" selects=\"inherit\">\n <sp-menu-item>SubInherit1</sp-menu-item>\n <sp-menu-item selected>SubInherit2</sp-menu-item>\n </sp-menu-group>\n </sp-menu-group>\n </sp-menu>\n `\n );\n\n await waitUntil(\n () => managedItems(el).length == 6,\n `expected outer menu to manage 6 items, manages ${\n managedItems(el).length\n }`\n );\n await waitUntil(\n () => el.selectedItems.length == 2,\n 'expected 2 selected item'\n );\n await elementUpdated(el);\n\n const inheritGroup = el.querySelector(\n 'sp-menu-group#mg-inherit'\n ) as MenuGroup;\n const inheritItem1 = inheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const inheritItem2 = inheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n\n const subInheritGroup = el.querySelector(\n 'sp-menu-group#mg-sub-inherit'\n ) as MenuGroup;\n const subInheritItem1 = subInheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(1)'\n ) as MenuItem;\n const subInheritItem2 = subInheritGroup.querySelector(\n 'sp-menu-item:nth-of-type(2)'\n ) as MenuItem;\n\n expect(inheritItem1.getAttribute('role')).to.equal('menuitemcheckbox');\n expect(inheritItem2.getAttribute('role')).to.equal('menuitemcheckbox');\n expect(subInheritItem1.getAttribute('role')).to.equal(\n 'menuitemcheckbox'\n );\n expect(subInheritItem2.getAttribute('role')).to.equal(\n 'menuitemcheckbox'\n );\n expect(el.value).to.equal('First--SubInherit2');\n expect(el.selectedItems.length).to.equal(2);\n inheritGroup.setAttribute('selects', 'single');\n\n await elementUpdated(inheritGroup);\n await elementUpdated(el);\n\n await waitUntil(() => {\n return managedItems(inheritGroup).length === 4;\n }, `expected new single sub-group to manage 4 items, received ${managedItems(inheritGroup).length} because \"selects === ${inheritGroup.selects}`);\n\n await waitUntil(\n () => managedItems(el).length === 2,\n `expected outer menu to manage 2 items with none inherited, received ${\n managedItems(el).length\n }`\n );\n expect(inheritGroup.value).to.equal('SubInherit2');\n expect(inheritGroup.selectedItems.length).to.equal(1);\n expect(el.value).to.equal('First');\n expect(inheritItem1.getAttribute('role')).to.equal('menuitemradio');\n expect(inheritItem2.getAttribute('role')).to.equal('menuitemradio');\n expect(subInheritItem1.getAttribute('role')).to.equal('menuitemradio');\n expect(subInheritItem2.getAttribute('role')).to.equal('menuitemradio');\n });\n});\n"]}
@@ -1,15 +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 * as stories from '../stories/menu-item.stories.js';
13
- import { regressVisuals } from '../../../test/visual/test.js';
14
- regressVisuals('MenuItemStories', stories);
15
- //# sourceMappingURL=menu-item.test-vrt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"menu-item.test-vrt.js","sourceRoot":"","sources":["menu-item.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,iBAAiB,EAAE,OAAO,CAAC,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*/\n\nimport * as stories from '../stories/menu-item.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('MenuItemStories', stories);\n"]}