@material/web 2.2.0 → 2.2.1-nightly.045fe94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/elevated-button.js +2 -1
- package/button/elevated-button.js.map +1 -1
- package/button/filled-button.js +2 -1
- package/button/filled-button.js.map +1 -1
- package/button/filled-tonal-button.js +2 -1
- package/button/filled-tonal-button.js.map +1 -1
- package/button/internal/button.js.map +1 -1
- package/button/outlined-button.js +2 -1
- package/button/outlined-button.js.map +1 -1
- package/button/text-button.js +2 -1
- package/button/text-button.js.map +1 -1
- package/checkbox/checkbox.js +2 -1
- package/checkbox/checkbox.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +1 -0
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/assist-chip.js +2 -1
- package/chips/assist-chip.js.map +1 -1
- package/chips/chip-set.js +2 -1
- package/chips/chip-set.js.map +1 -1
- package/chips/filter-chip.js +2 -1
- package/chips/filter-chip.js.map +1 -1
- package/chips/harness.js.map +1 -1
- package/chips/input-chip.js +2 -1
- package/chips/input-chip.js.map +1 -1
- package/chips/internal/assist-chip.js.map +1 -1
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.d.ts +1 -0
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/input-chip.js.map +1 -1
- package/chips/internal/multi-action-chip.js.map +1 -1
- package/chips/internal/trailing-icons.js.map +1 -1
- package/chips/suggestion-chip.js +2 -1
- package/chips/suggestion-chip.js.map +1 -1
- package/dialog/dialog.js +2 -1
- package/dialog/dialog.js.map +1 -1
- package/dialog/internal/dialog.js.map +1 -1
- package/divider/divider.js +2 -1
- package/divider/divider.js.map +1 -1
- package/elevation/elevation.js +2 -1
- package/elevation/elevation.js.map +1 -1
- package/fab/branded-fab.js +2 -1
- package/fab/branded-fab.js.map +1 -1
- package/fab/fab.js +2 -1
- package/fab/fab.js.map +1 -1
- package/field/filled-field.js +2 -1
- package/field/filled-field.js.map +1 -1
- package/field/internal/field.js.map +1 -1
- package/field/outlined-field.js +2 -1
- package/field/outlined-field.js.map +1 -1
- package/focus/internal/focus-ring.js.map +1 -1
- package/focus/md-focus-ring.js +2 -1
- package/focus/md-focus-ring.js.map +1 -1
- package/icon/icon.js +2 -1
- package/icon/icon.js.map +1 -1
- package/icon/internal/icon.js.map +1 -1
- package/iconbutton/filled-icon-button.js +2 -1
- package/iconbutton/filled-icon-button.js.map +1 -1
- package/iconbutton/filled-tonal-icon-button.js +2 -1
- package/iconbutton/filled-tonal-icon-button.js.map +1 -1
- package/iconbutton/harness.js.map +1 -1
- package/iconbutton/icon-button.js +2 -1
- package/iconbutton/icon-button.js.map +1 -1
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/iconbutton/outlined-icon-button.js +2 -1
- package/iconbutton/outlined-icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +1 -1
- package/internal/aria/delegate.js.map +1 -1
- package/internal/controller/attachable-controller.js.map +1 -1
- package/internal/controller/form-submitter.js.map +1 -1
- package/internal/events/dispatch-hooks.js.map +1 -1
- package/internal/events/form-label-activation.js.map +1 -1
- package/internal/events/redispatch-event.js.map +1 -1
- package/internal/motion/animation.js.map +1 -1
- package/labs/badge/badge.js +2 -1
- package/labs/badge/badge.js.map +1 -1
- package/labs/behaviors/constraint-validation.js.map +1 -1
- package/labs/behaviors/custom-state-set.d.ts +107 -0
- package/labs/behaviors/custom-state-set.js +121 -0
- package/labs/behaviors/custom-state-set.js.map +1 -0
- package/labs/behaviors/element-internals.js.map +1 -1
- package/labs/behaviors/focusable.js.map +1 -1
- package/labs/behaviors/form-associated.js.map +1 -1
- package/labs/behaviors/on-report-validity.js.map +1 -1
- package/labs/behaviors/validators/checkbox-validator.js.map +1 -1
- package/labs/behaviors/validators/radio-validator.js.map +1 -1
- package/labs/behaviors/validators/select-validator.js.map +1 -1
- package/labs/behaviors/validators/text-field-validator.js.map +1 -1
- package/labs/behaviors/validators/validator.js.map +1 -1
- package/labs/card/elevated-card.js +2 -1
- package/labs/card/elevated-card.js.map +1 -1
- package/labs/card/filled-card.js +2 -1
- package/labs/card/filled-card.js.map +1 -1
- package/labs/card/outlined-card.js +2 -1
- package/labs/card/outlined-card.js.map +1 -1
- package/labs/item/internal/item.js.map +1 -1
- package/labs/item/item.js +2 -1
- package/labs/item/item.js.map +1 -1
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationbar/navigation-bar.js +2 -1
- package/labs/navigationbar/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationdrawer/navigation-drawer-modal.js +2 -1
- package/labs/navigationdrawer/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/navigation-drawer.js +2 -1
- package/labs/navigationdrawer/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/navigationtab/navigation-tab.js +2 -1
- package/labs/navigationtab/navigation-tab.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbutton/outlined-segmented-button.js +2 -1
- package/labs/segmentedbutton/outlined-segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/labs/segmentedbuttonset/outlined-segmented-button-set.js +2 -1
- package/labs/segmentedbuttonset/outlined-segmented-button-set.js.map +1 -1
- package/list/internal/list-controller.js.map +1 -1
- package/list/internal/list-navigation-helpers.js.map +1 -1
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +1 -0
- package/list/internal/listitem/list-item.js.map +1 -1
- package/list/list-item.js +2 -1
- package/list/list-item.js.map +1 -1
- package/list/list.js +2 -1
- package/list/list.js.map +1 -1
- package/menu/harness.js.map +1 -1
- package/menu/internal/controllers/menuItemController.js.map +1 -1
- package/menu/internal/controllers/surfacePositionController.js.map +1 -1
- package/menu/internal/controllers/typeaheadController.js.map +1 -1
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +1 -0
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/menu/internal/submenu/sub-menu.js.map +1 -1
- package/menu/menu-item.js +2 -1
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.js +2 -1
- package/menu/menu.js.map +1 -1
- package/menu/sub-menu.js +2 -1
- package/menu/sub-menu.js.map +1 -1
- package/migrations/v2/query-selector-aria.js.map +1 -1
- package/package.json +5 -3
- package/progress/circular-progress.js +2 -1
- package/progress/circular-progress.js.map +1 -1
- package/progress/internal/circular-progress.js.map +1 -1
- package/progress/linear-progress.js +2 -1
- package/progress/linear-progress.js.map +1 -1
- package/radio/internal/radio.js.map +1 -1
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/radio/radio.js +2 -1
- package/radio/radio.js.map +1 -1
- package/ripple/internal/ripple.js.map +1 -1
- package/ripple/ripple.js +2 -1
- package/ripple/ripple.js.map +1 -1
- package/select/filled-select.js +2 -1
- package/select/filled-select.js.map +1 -1
- package/select/harness.js.map +1 -1
- package/select/internal/select.d.ts +1 -0
- package/select/internal/select.js +2 -1
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +1 -0
- package/select/internal/selectoption/selectOptionController.js.map +1 -1
- package/select/internal/shared.js.map +1 -1
- package/select/outlined-select.js +2 -1
- package/select/outlined-select.js.map +1 -1
- package/select/select-option.js +2 -1
- package/select/select-option.js.map +1 -1
- package/slider/harness.js.map +1 -1
- package/slider/internal/slider.js.map +1 -1
- package/slider/slider.js +2 -1
- package/slider/slider.js.map +1 -1
- package/switch/internal/switch.js.map +1 -1
- package/switch/switch.js +2 -1
- package/switch/switch.js.map +1 -1
- package/tabs/harness.js.map +1 -1
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.js.map +1 -1
- package/tabs/primary-tab.js +2 -1
- package/tabs/primary-tab.js.map +1 -1
- package/tabs/secondary-tab.js +2 -1
- package/tabs/secondary-tab.js.map +1 -1
- package/tabs/tabs.js +2 -1
- package/tabs/tabs.js.map +1 -1
- package/testing/harness.js.map +1 -1
- package/testing/transform-pseudo-classes.js.map +1 -1
- package/textfield/filled-text-field.js +2 -1
- package/textfield/filled-text-field.js.map +1 -1
- package/textfield/harness.js.map +1 -1
- package/textfield/internal/text-field.js.map +1 -1
- package/textfield/outlined-text-field.js +2 -1
- package/textfield/outlined-text-field.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,mBAAmB;IAsB9B;;;;;;;;;OASG;IACH,YACmB,aAAkD;QAAlD,kBAAa,GAAb,aAAa,CAAqC;QAhCrE;;WAEG;QACK,qBAAgB,GAAsB,EAAE,CAAC;QACjD;;WAEG;QACK,mBAAc,GAAG,EAAE,CAAC;QAC5B;;WAEG;QACK,2BAAsB,GAAG,CAAC,CAAC;QACnC;;WAEG;QACH,kBAAa,GAAG,KAAK,CAAC;QACtB;;WAEG;QACH,qBAAgB,GAA2B,IAAI,CAAC;QAwBhD;;;;;WAKG;QACM,cAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,aAAa,EAAE;gBACtB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;aACvB;iBAAM;gBACL,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC;QAsLF;;WAEG;QACc,iBAAY,GAAG,GAAG,EAAE;YACnC,IAAI,CAAC,a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IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC/C,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './menuItemController.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n/**\n * Indicies to access the TypeaheadRecord tuple type.\n */\nexport const TYPEAHEAD_RECORD = {\n INDEX: 0,\n ITEM: 1,\n TEXT: 2,\n} as const;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n private typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n private typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n private cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n lastActiveRecord: TypeaheadRecord | null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n private readonly getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n private get items() {\n return this.getProperties().getItems();\n }\n\n private get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param event The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (event: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(event);\n } else {\n this.beginTypeahead(event);\n }\n };\n\n /**\n * Sets up typingahead\n */\n private beginTypeahead(event: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (\n event.code === 'Space' ||\n event.code === 'Enter' ||\n event.code.startsWith('Arrow') ||\n event.code === 'Escape'\n ) {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map((el, index) => [\n index,\n el,\n el.typeaheadText.trim().toLowerCase(),\n ]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(\n (record) => record[TYPEAHEAD_RECORD.ITEM].tabIndex === 0,\n ) ?? null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n this.typeahead(event);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n private typeahead(event: KeyboardEvent) {\n if (event.defaultPrevented) return;\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (\n event.code === 'Enter' ||\n event.code.startsWith('Arrow') ||\n event.code === 'Escape'\n ) {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (event.code === 'Space') {\n event.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout = setTimeout(\n this.endTypeahead,\n this.getProperties().typeaheadBufferTime,\n );\n\n this.typaheadBuffer += event.key.toLowerCase();\n\n const lastActiveIndex = this.lastActiveRecord\n ? this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX]\n : -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (\n (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %\n numRecords\n );\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords = this.typeaheadRecords\n .filter(\n (record) =>\n !record[TYPEAHEAD_RECORD.ITEM].disabled &&\n record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer),\n )\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = 0;\n nextRecord[TYPEAHEAD_RECORD.ITEM].focus();\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n private readonly endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,mBAAmB;IAsB9B;;;;;;;;;OASG;IACH,YACmB,aAAkD;QAAlD,kBAAa,GAAb,aAAa,CAAqC;QAhCrE;;WAEG;QACK,qBAAgB,GAAsB,EAAE,CAAC;QACjD;;WAEG;QACK,mBAAc,GAAG,EAAE,CAAC;QAC5B;;WAEG;QACK,2BAAsB,GAAG,CAAC,CAAC;QACnC;;WAEG;QACH,kBAAa,GAAG,KAAK,CAAC;QACtB;;WAEG;QACH,qBAAgB,GAA2B,IAAI,CAAC;QAwBhD;;;;;WAKG;QACM,cAAS,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC5C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC;QAsLF;;WAEG;QACc,iBAAY,GAAG,GAAG,EAAE;YACnC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC7B,CAAC,CAAC;IAnNC,CAAC;IAEJ,IAAY,KAAK;QACf,OAA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AAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC/C,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './menuItemController.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n/**\n * Indicies to access the TypeaheadRecord tuple type.\n */\nexport const TYPEAHEAD_RECORD = {\n INDEX: 0,\n ITEM: 1,\n TEXT: 2,\n} as const;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n private typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n private typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n private cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n lastActiveRecord: TypeaheadRecord | null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n private readonly getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n private get items() {\n return this.getProperties().getItems();\n }\n\n private get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param event The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (event: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(event);\n } else {\n this.beginTypeahead(event);\n }\n };\n\n /**\n * Sets up typingahead\n */\n private beginTypeahead(event: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (\n event.code === 'Space' ||\n event.code === 'Enter' ||\n event.code.startsWith('Arrow') ||\n event.code === 'Escape'\n ) {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map((el, index) => [\n index,\n el,\n el.typeaheadText.trim().toLowerCase(),\n ]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(\n (record) => record[TYPEAHEAD_RECORD.ITEM].tabIndex === 0,\n ) ?? null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n this.typeahead(event);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n private typeahead(event: KeyboardEvent) {\n if (event.defaultPrevented) return;\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (\n event.code === 'Enter' ||\n event.code.startsWith('Arrow') ||\n event.code === 'Escape'\n ) {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (event.code === 'Space') {\n event.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout = setTimeout(\n this.endTypeahead,\n this.getProperties().typeaheadBufferTime,\n );\n\n this.typaheadBuffer += event.key.toLowerCase();\n\n const lastActiveIndex = this.lastActiveRecord\n ? this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX]\n : -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (\n (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %\n numRecords\n );\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords = this.typeaheadRecords\n .filter(\n (record) =>\n !record[TYPEAHEAD_RECORD.ITEM].disabled &&\n record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer),\n )\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = -1;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_RECORD.ITEM].tabIndex = 0;\n nextRecord[TYPEAHEAD_RECORD.ITEM].focus();\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n private readonly endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAkB,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,MAAM,EAAE,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACjF,OAAO,EACL,cAAc,EACd,aAAa,GACd,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAGL,UAAU,EACV,aAAa,EACb,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,MAAM,EACN,yBAAyB,GAE1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAC,mBAAmB,EAAC,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAC,MAAM,EAAC,MAAM,4CAA4C,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAEjD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS;IACrC,aAAa,CAAC,SAAS;IACvB,aAAa,CAAC,OAAO;IACrB,aAAa,CAAC,IAAI;IAClB,aAAa,CAAC,GAAG;CAClB,CAAC,CAAC;AAEH,MAAM,WAAW,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C,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CACnD;AAKkD;IAAzD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;4CACjD;AAMR;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAC,CAAC;4CACR;AAU/C;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;0CACC;AASF;IAArC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;wCAAyC;AAQ9E;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4BAA4B,EAAC,CAAC;oDACpC;AAQ/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAC,CAAC;gDACnC;AAM3B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CAClC;AASzB;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;0CACU;AAQjD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CAClC;AAEyB;IAAjD,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;uCAAqC;AAC3D;IAAhB,KAAK,EAAE;6CAAgC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../elevation/elevation.js';\nimport '../../focus/md-focus-ring.js';\n\nimport {LitElement, PropertyValues, html, isServer, nothing} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {styleMap} from 'lit/directives/style-map.js';\n\nimport {EASING, createAnimationSignal} from '../../internal/motion/animation.js';\nimport {\n ListController,\n NavigableKeys,\n} from '../../list/internal/list-controller.js';\nimport {\n getActiveItem,\n getFirstActivatableItem,\n getLastActivatableItem,\n} from '../../list/internal/list-navigation-helpers.js';\n\nimport {MenuItem} from './controllers/menuItemController.js';\nimport {\n ActivateTypeaheadEvent,\n DeactivateTypeaheadEvent,\n FocusState,\n isClosableKey,\n isElementInSubtree,\n} from './controllers/shared.js';\nimport {\n Corner,\n SurfacePositionController,\n SurfacePositionTarget,\n} from './controllers/surfacePositionController.js';\nimport {TypeaheadController} from './controllers/typeaheadController.js';\n\nexport {Corner} from './controllers/surfacePositionController.js';\n\n/**\n * The default value for the typeahead buffer time in Milliseconds.\n */\nexport const DEFAULT_TYPEAHEAD_BUFFER_TIME = 200;\n\nconst submenuNavKeys = new Set<string>([\n NavigableKeys.ArrowDown,\n NavigableKeys.ArrowUp,\n NavigableKeys.Home,\n NavigableKeys.End,\n]);\n\nconst menuNavKeys = new Set<string>([\n NavigableKeys.ArrowLeft,\n NavigableKeys.ArrowRight,\n ...submenuNavKeys,\n]);\n\n/**\n * Gets the currently focused element on the page.\n *\n * @param activeDoc The document or shadowroot from which to start the search.\n * Defaults to `window.document`\n * @return Returns the currently deeply focused element or `null` if none.\n */\nfunction getFocusedElement(\n activeDoc: Document | ShadowRoot = document,\n): HTMLElement | null {\n let activeEl = activeDoc.activeElement as HTMLElement | null;\n\n // Check for activeElement in the case that an element with a shadow root host\n // is currently focused.\n while (activeEl && activeEl?.shadowRoot?.activeElement) {\n activeEl = activeEl.shadowRoot.activeElement as HTMLElement | null;\n }\n\n return activeEl;\n}\n\n/**\n * @fires opening {Event} Fired before the opening animation begins\n * @fires opened {Event} Fired once the menu is open, after any animations\n * @fires closing {Event} Fired before the closing animation begins\n * @fires closed {Event} Fired once the menu is closed, after any animations\n */\nexport abstract class Menu extends LitElement {\n @query('.menu') private readonly surfaceEl!: HTMLElement | null;\n @query('slot') private readonly slotEl!: HTMLSlotElement | null;\n\n /**\n * The ID of the element in the same root node in which the menu should align\n * to. Overrides setting `anchorElement = elementReference`.\n *\n * __NOTE__: anchor or anchorElement must either be an HTMLElement or resolve\n * to an HTMLElement in order for menu to open.\n */\n @property() anchor = '';\n /**\n * Whether the positioning algorithm should calculate relative to the parent\n * of the anchor element (`absolute`), relative to the window (`fixed`), or\n * relative to the document (`document`). `popover` will use the popover API\n * to render the menu in the top-layer. If your browser does not support the\n * popover API, it will fall back to `fixed`.\n *\n * __Examples for `position = 'fixed'`:__\n *\n * - If there is no `position:relative` in the given parent tree and the\n * surface is `position:absolute`\n * - If the surface is `position:fixed`\n * - If the surface is in the \"top layer\"\n * - The anchor and the surface do not share a common `position:relative`\n * ancestor\n *\n * When using `positioning=fixed`, in most cases, the menu should position\n * itself above most other `position:absolute` or `position:fixed` elements\n * when placed inside of them. e.g. using a menu inside of an `md-dialog`.\n *\n * __NOTE__: Fixed menus will not scroll with the page and will be fixed to\n * the window instead.\n *\n * __Examples for `position = 'document'`:__\n *\n * - There is no parent that creates a relative positioning context e.g.\n * `position: relative`, `position: absolute`, `transform: translate(x, y)`,\n * etc.\n * - You put the effort into hoisting the menu to the top of the DOM like the\n * end of the `<body>` to render over everything or in a top-layer.\n * - You are reusing a single `md-menu` element that dynamically renders\n * content.\n *\n * __Examples for `position = 'popover'`:__\n *\n * - Your browser supports `popover`.\n * - Most cases. Once popover is in browsers, this will become the default.\n */\n @property() positioning: 'absolute' | 'fixed' | 'document' | 'popover' =\n 'absolute';\n /**\n * Skips the opening and closing animations.\n */\n @property({type: Boolean}) quick = false;\n /**\n * Displays overflow content like a submenu. Not required in most cases when\n * using `positioning=\"popover\"`.\n *\n * __NOTE__: This may cause adverse effects if you set\n * `md-menu {max-height:...}`\n * and have items overflowing items in the \"y\" direction.\n */\n @property({type: Boolean, attribute: 'has-overflow'}) hasOverflow = false;\n /**\n * Opens the menu and makes it visible. Alternative to the `.show()` and\n * `.close()` methods\n */\n @property({type: Boolean, reflect: true}) open = false;\n /**\n * Offsets the menu's inline alignment from the anchor by the given number in\n * pixels. This value is direction aware and will follow the LTR / RTL\n * direction.\n *\n * e.g. LTR: positive -> right, negative -> left\n * RTL: positive -> left, negative -> right\n */\n @property({type: Number, attribute: 'x-offset'}) xOffset = 0;\n /**\n * Offsets the menu's block alignment from the anchor by the given number in\n * pixels.\n *\n * e.g. positive -> down, negative -> up\n */\n @property({type: Number, attribute: 'y-offset'}) yOffset = 0;\n /**\n * Disable the `flip` behavior that usually happens on the horizontal axis\n * when the surface would render outside the viewport.\n */\n @property({type: Boolean, attribute: 'no-horizontal-flip'}) noHorizontalFlip =\n false;\n /**\n * Disable the `flip` behavior that usually happens on the vertical axis when\n * the surface would render outside the viewport.\n */\n @property({type: Boolean, attribute: 'no-vertical-flip'}) noVerticalFlip =\n false;\n /**\n * The max time between the keystrokes of the typeahead menu behavior before\n * it clears the typeahead buffer.\n */\n @property({type: Number, attribute: 'typeahead-delay'})\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n /**\n * The corner of the anchor which to align the menu in the standard logical\n * property style of <block>-<inline> e.g. `'end-start'`.\n *\n * NOTE: This value may not be respected by the menu positioning algorithm\n * if the menu would render outisde the viewport.\n * Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value\n */\n @property({attribute: 'anchor-corner'})\n anchorCorner: Corner = Corner.END_START;\n /**\n * The corner of the menu which to align the anchor in the standard logical\n * property style of <block>-<inline> e.g. `'start-start'`.\n *\n * NOTE: This value may not be respected by the menu positioning algorithm\n * if the menu would render outisde the viewport.\n * Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = Corner.START_START;\n /**\n * Keeps the user clicks outside the menu.\n *\n * NOTE: clicking outside may still cause focusout to close the menu so see\n * `stayOpenOnFocusout`.\n */\n @property({type: Boolean, attribute: 'stay-open-on-outside-click'})\n stayOpenOnOutsideClick = false;\n /**\n * Keeps the menu open when focus leaves the menu's composed subtree.\n *\n * NOTE: Focusout behavior will stop propagation of the focusout event. Set\n * this property to true to opt-out of menu's focusout handling altogether.\n */\n @property({type: Boolean, attribute: 'stay-open-on-focusout'})\n stayOpenOnFocusout = false;\n /**\n * After closing, does not restore focus to the last focused element before\n * the menu was opened.\n */\n @property({type: Boolean, attribute: 'skip-restore-focus'})\n skipRestoreFocus = false;\n /**\n * The element that should be focused by default once opened.\n *\n * NOTE: When setting default focus to 'LIST_ROOT', remember to change\n * `tabindex` to `0` and change md-menu's display to something other than\n * `display: contents` when necessary.\n */\n @property({attribute: 'default-focus'})\n defaultFocus: FocusState = FocusState.FIRST_ITEM;\n\n /**\n * Turns off navigation wrapping. By default, navigating past the end of the\n * menu items will wrap focus back to the beginning and vice versa. Use this\n * for ARIA patterns that do not wrap focus, like combobox.\n */\n @property({type: Boolean, attribute: 'no-navigation-wrap'})\n noNavigationWrap = false;\n\n @queryAssignedElements({flatten: true}) protected slotItems!: HTMLElement[];\n @state() private typeaheadActive = true;\n\n /**\n * Whether or not the current menu is a submenu and should not handle specific\n * navigation keys.\n *\n * @export\n */\n isSubmenu = false;\n\n /**\n * The event path of the last window pointerdown event.\n */\n private pointerPath: EventTarget[] = [];\n\n /**\n * Whether or not the menu is repositoining due to window / document resize\n */\n private isRepositioning = false;\n private readonly openCloseAnimationSignal = createAnimationSignal();\n\n private readonly listController = new ListController<MenuItem>({\n isItem: (maybeItem: HTMLElement): maybeItem is MenuItem => {\n return maybeItem.hasAttribute('md-menu-item');\n },\n getPossibleItems: () => this.slotItems,\n isRtl: () => getComputedStyle(this).direction === 'rtl',\n deactivateItem: (item: MenuItem) => {\n item.selected = false;\n item.tabIndex = -1;\n },\n activateItem: (item: MenuItem) => {\n item.selected = true;\n item.tabIndex = 0;\n },\n isNavigableKey: (key: string) => {\n if (!this.isSubmenu) {\n return menuNavKeys.has(key);\n }\n\n const isRtl = getComputedStyle(this).direction === 'rtl';\n // we want md-submenu to handle the submenu's left/right arrow exit\n // key so it can close the menu instead of navigate the list.\n // Therefore we need to include all keys but left/right arrow close\n // key\n const arrowOpen = isRtl\n ? NavigableKeys.ArrowLeft\n : NavigableKeys.ArrowRight;\n\n if (key === arrowOpen) {\n return true;\n }\n\n return submenuNavKeys.has(key);\n },\n wrapNavigation: () => !this.noNavigationWrap,\n });\n\n /**\n * Whether the menu is animating upwards or downwards when opening. This is\n * helpful for calculating some animation calculations.\n */\n private get openDirection(): 'UP' | 'DOWN' {\n const menuCornerBlock = this.menuCorner.split('-')[0];\n return menuCornerBlock === 'start' ? 'DOWN' : 'UP';\n }\n\n /**\n * The element that was focused before the menu opened.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Handles typeahead navigation through the menu.\n */\n typeaheadController = new TypeaheadController(() => {\n return {\n getItems: () => this.items,\n typeaheadBufferTime: this.typeaheadDelay,\n active: this.typeaheadActive,\n };\n });\n\n private currentAnchorElement: HTMLElement | null = null;\n\n /**\n * The element which the menu should align to. If `anchor` is set to a\n * non-empty idref string, then `anchorEl` will resolve to the element with\n * the given id in the same root node. Otherwise, `null`.\n */\n get anchorElement(): (HTMLElement & Partial<SurfacePositionTarget>) | null {\n if (this.anchor) {\n return (this.getRootNode() as Document | ShadowRoot).querySelector(\n `#${this.anchor}`,\n );\n }\n\n return this.currentAnchorElement;\n }\n\n set anchorElement(\n element: (HTMLElement & Partial<SurfacePositionTarget>) | null,\n ) {\n this.currentAnchorElement = element;\n this.requestUpdate('anchorElement');\n }\n\n private readonly internals =\n // Cast needed for closure\n (this as HTMLElement).attachInternals();\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'menu';\n this.addEventListener('keydown', this.handleKeydown);\n // Capture so that we can grab the event before it reaches the menu item\n // istelf. Specifically useful for the case where typeahead encounters a\n // space and we don't want the menu item to close the menu.\n this.addEventListener('keydown', this.captureKeydown, {capture: true});\n this.addEventListener('focusout', this.handleFocusout);\n }\n }\n\n /**\n * Handles positioning the surface and aligning it to the anchor as well as\n * keeping it in the viewport.\n */\n private readonly menuPositionController = new SurfacePositionController(\n this,\n () => {\n return {\n anchorCorner: this.anchorCorner,\n surfaceCorner: this.menuCorner,\n surfaceEl: this.surfaceEl,\n anchorEl: this.anchorElement,\n positioning:\n this.positioning === 'popover' ? 'document' : this.positioning,\n isOpen: this.open,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n disableBlockFlip: this.noVerticalFlip,\n disableInlineFlip: this.noHorizontalFlip,\n onOpen: this.onOpened,\n beforeClose: this.beforeClose,\n onClose: this.onClosed,\n // We can't resize components that have overflow like menus with\n // submenus because the overflow-y will show menu items / content\n // outside the bounds of the menu. Popover API fixes this because each\n // submenu is hoisted to the top-layer and are not considered overflow\n // content.\n repositionStrategy:\n this.hasOverflow && this.positioning !== 'popover'\n ? 'move'\n : 'resize',\n };\n },\n );\n\n /**\n * The menu items associated with this menu. The items must be `MenuItem`s and\n * have both the `md-menu-item` and `md-list-item` attributes.\n */\n get items(): MenuItem[] {\n return this.listController.items;\n }\n\n protected override willUpdate(changed: PropertyValues<Menu>) {\n if (!changed.has('open')) {\n return;\n }\n\n if (this.open) {\n this.removeAttribute('aria-hidden');\n return;\n }\n\n this.setAttribute('aria-hidden', 'true');\n }\n\n override update(changed: PropertyValues<Menu>) {\n if (changed.has('open')) {\n if (this.open) {\n this.setUpGlobalEventListeners();\n } else {\n this.cleanUpGlobalEventListeners();\n }\n }\n\n // Firefox does not support popover. Fall-back to using fixed.\n if (\n changed.has('positioning') &&\n this.positioning === 'popover' &&\n // type required for Google JS conformance\n !(this as unknown as {showPopover?: () => void}).showPopover\n ) {\n this.positioning = 'fixed';\n }\n\n super.update(changed);\n }\n\n private readonly onWindowResize = () => {\n if (\n this.isRepositioning ||\n (this.positioning !== 'document' &&\n this.positioning !== 'fixed' &&\n this.positioning !== 'popover')\n ) {\n return;\n }\n this.isRepositioning = true;\n this.reposition();\n this.isRepositioning = false;\n };\n\n override connectedCallback() {\n super.connectedCallback();\n if (this.open) {\n this.setUpGlobalEventListeners();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.cleanUpGlobalEventListeners();\n }\n\n override getBoundingClientRect() {\n if (!this.surfaceEl) {\n return super.getBoundingClientRect();\n }\n return this.surfaceEl.getBoundingClientRect();\n }\n\n override getClientRects() {\n if (!this.surfaceEl) {\n return super.getClientRects();\n }\n return this.surfaceEl.getClientRects();\n }\n\n protected override render() {\n return this.renderSurface();\n }\n\n /**\n * Renders the positionable surface element and its contents.\n */\n private renderSurface() {\n return html`\n <div\n class=\"menu ${classMap(this.getSurfaceClasses())}\"\n style=${styleMap(this.menuPositionController.surfaceStyles)}\n popover=${this.positioning === 'popover' ? 'manual' : nothing}>\n ${this.renderElevation()}\n <div class=\"items\">\n <div class=\"item-padding\"> ${this.renderMenuItems()} </div>\n </div>\n </div>\n `;\n }\n\n /**\n * Renders the menu items' slot\n */\n private renderMenuItems() {\n return html`<slot\n @close-menu=${this.onCloseMenu}\n @deactivate-items=${this.onDeactivateItems}\n @request-activation=${this.onRequestActivation}\n @deactivate-typeahead=${this.handleDeactivateTypeahead}\n @activate-typeahead=${this.handleActivateTypeahead}\n @stay-open-on-focusout=${this.handleStayOpenOnFocusout}\n @close-on-focusout=${this.handleCloseOnFocusout}\n @slotchange=${this.listController.onSlotchange}></slot>`;\n }\n\n /**\n * Renders the elevation component.\n */\n private renderElevation() {\n return html`<md-elevation part=\"elevation\"></md-elevation>`;\n }\n\n private getSurfaceClasses(): ClassInfo {\n return {\n open: this.open,\n fixed: this.positioning === 'fixed',\n 'has-overflow': this.hasOverflow,\n };\n }\n\n private readonly handleFocusout = async (event: FocusEvent) => {\n const anchorEl = this.anchorElement!;\n // Do not close if we focused out by clicking on the anchor element. We\n // can't assume anchor buttons can be the related target because of iOS does\n // not focus buttons.\n if (\n this.stayOpenOnFocusout ||\n !this.open ||\n this.pointerPath.includes(anchorEl)\n ) {\n return;\n }\n\n if (event.relatedTarget) {\n // Don't close the menu if we are switching focus between menu,\n // md-menu-item, and md-list or if the anchor was click focused, but check\n // if length of pointerPath is 0 because that means something was at least\n // clicked (shift+tab case).\n if (\n isElementInSubtree(event.relatedTarget, this) ||\n (this.pointerPath.length !== 0 &&\n isElementInSubtree(event.relatedTarget, anchorEl))\n ) {\n return;\n }\n } else if (this.pointerPath.includes(this)) {\n // If menu tabindex == -1 and the user clicks on the menu or a divider, we\n // want to keep the menu open.\n return;\n }\n\n const oldRestoreFocus = this.skipRestoreFocus;\n // allow focus to continue to the next focused object rather than returning\n this.skipRestoreFocus = true;\n this.close();\n // await for close\n await this.updateComplete;\n // return to previous behavior\n this.skipRestoreFocus = oldRestoreFocus;\n };\n\n private captureKeydown(event: KeyboardEvent) {\n if (\n event.target === this &&\n !event.defaultPrevented &&\n isClosableKey(event.code)\n ) {\n event.preventDefault();\n this.close();\n }\n\n this.typeaheadController.onKeydown(event);\n }\n\n /**\n * Saves the last focused element focuses the new element based on\n * `defaultFocus`, and animates open.\n */\n private readonly onOpened = async () => {\n this.lastFocusedElement = getFocusedElement();\n\n const items = this.items;\n const activeItemRecord = getActiveItem(items);\n\n if (activeItemRecord && this.defaultFocus !== FocusState.NONE) {\n activeItemRecord.item.tabIndex = -1;\n }\n\n let animationAborted = !this.quick;\n\n if (this.quick) {\n this.dispatchEvent(new Event('opening'));\n } else {\n animationAborted = !!(await this.animateOpen());\n }\n\n // This must come after the opening animation or else it may focus one of\n // the items before the animation has begun and causes the list to slide\n // (block-padding-of-the-menu)px at the end of the animation\n switch (this.defaultFocus) {\n case FocusState.FIRST_ITEM:\n const first = getFirstActivatableItem(items);\n if (first) {\n first.tabIndex = 0;\n first.focus();\n await (first as LitElement & MenuItem).updateComplete;\n }\n break;\n case FocusState.LAST_ITEM:\n const last = getLastActivatableItem(items);\n if (last) {\n last.tabIndex = 0;\n last.focus();\n await (last as LitElement & MenuItem).updateComplete;\n }\n break;\n case FocusState.LIST_ROOT:\n this.focus();\n break;\n default:\n case FocusState.NONE:\n // Do nothing.\n break;\n }\n\n if (!animationAborted) {\n this.dispatchEvent(new Event('opened'));\n }\n };\n\n /**\n * Animates closed.\n */\n private readonly beforeClose = async () => {\n this.open = false;\n\n if (!this.skipRestoreFocus) {\n this.lastFocusedElement?.focus?.();\n }\n\n if (!this.quick) {\n await this.animateClose();\n }\n };\n\n /**\n * Focuses the last focused element.\n */\n private readonly onClosed = () => {\n if (this.quick) {\n this.dispatchEvent(new Event('closing'));\n this.dispatchEvent(new Event('closed'));\n }\n };\n\n /**\n * Performs the opening animation:\n *\n * https://direct.googleplex.com/#/spec/295000003+271060003\n *\n * @return A promise that resolve to `true` if the animation was aborted,\n * `false` if it was not aborted.\n */\n private async animateOpen() {\n const surfaceEl = this.surfaceEl;\n const slotEl = this.slotEl;\n\n if (!surfaceEl || !slotEl) return true;\n\n const openDirection = this.openDirection;\n this.dispatchEvent(new Event('opening'));\n // needs to be imperative because we don't want to mix animation and Lit\n // render timing\n surfaceEl.classList.toggle('animating', true);\n\n const signal = this.openCloseAnimationSignal.start();\n const height = surfaceEl.offsetHeight;\n const openingUpwards = openDirection === 'UP';\n const children = this.items;\n const FULL_DURATION = 500;\n const SURFACE_OPACITY_DURATION = 50;\n const ITEM_OPACITY_DURATION = 250;\n // We want to fit every child fade-in animation within the full duration of\n // the animation.\n const DELAY_BETWEEN_ITEMS =\n (FULL_DURATION - ITEM_OPACITY_DURATION) / children.length;\n\n const surfaceHeightAnimation = surfaceEl.animate(\n [{height: '0px'}, {height: `${height}px`}],\n {\n duration: FULL_DURATION,\n easing: EASING.EMPHASIZED,\n },\n );\n // When we are opening upwards, we want to make sure the last item is always\n // in view, so we need to translate it upwards the opposite direction of the\n // height animation\n const upPositionCorrectionAnimation = slotEl.animate(\n [\n {transform: openingUpwards ? `translateY(-${height}px)` : ''},\n {transform: ''},\n ],\n {duration: FULL_DURATION, easing: EASING.EMPHASIZED},\n );\n\n const surfaceOpacityAnimation = surfaceEl.animate(\n [{opacity: 0}, {opacity: 1}],\n SURFACE_OPACITY_DURATION,\n );\n\n const childrenAnimations: Array<[HTMLElement, Animation]> = [];\n\n for (let i = 0; i < children.length; i++) {\n // If we are animating upwards, then reverse the children list.\n const directionalIndex = openingUpwards ? children.length - 1 - i : i;\n const child = children[directionalIndex];\n const animation = child.animate([{opacity: 0}, {opacity: 1}], {\n duration: ITEM_OPACITY_DURATION,\n delay: DELAY_BETWEEN_ITEMS * i,\n });\n\n // Make them all initially hidden and then clean up at the end of each\n // animation.\n child.classList.toggle('md-menu-hidden', true);\n animation.addEventListener('finish', () => {\n child.classList.toggle('md-menu-hidden', false);\n });\n\n childrenAnimations.push([child, animation]);\n }\n\n let resolveAnimation = (value: boolean) => {};\n const animationFinished = new Promise<boolean>((resolve) => {\n resolveAnimation = resolve;\n });\n\n signal.addEventListener('abort', () => {\n surfaceHeightAnimation.cancel();\n upPositionCorrectionAnimation.cancel();\n surfaceOpacityAnimation.cancel();\n childrenAnimations.forEach(([child, animation]) => {\n child.classList.toggle('md-menu-hidden', false);\n animation.cancel();\n });\n\n resolveAnimation(true);\n });\n\n surfaceHeightAnimation.addEventListener('finish', () => {\n surfaceEl.classList.toggle('animating', false);\n this.openCloseAnimationSignal.finish();\n resolveAnimation(false);\n });\n\n return await animationFinished;\n }\n\n /**\n * Performs the closing animation:\n *\n * https://direct.googleplex.com/#/spec/295000003+271060003\n */\n private animateClose() {\n let resolve!: (value: unknown) => void;\n\n // This promise blocks the surface position controller from setting\n // display: none on the surface which will interfere with this animation.\n const animationEnded = new Promise((res) => {\n resolve = res;\n });\n\n const surfaceEl = this.surfaceEl;\n const slotEl = this.slotEl;\n\n if (!surfaceEl || !slotEl) {\n resolve(false);\n return animationEnded;\n }\n\n const openDirection = this.openDirection;\n const closingDownwards = openDirection === 'UP';\n this.dispatchEvent(new Event('closing'));\n // needs to be imperative because we don't want to mix animation and Lit\n // render timing\n surfaceEl.classList.toggle('animating', true);\n const signal = this.openCloseAnimationSignal.start();\n const height = surfaceEl.offsetHeight;\n const children = this.items;\n const FULL_DURATION = 150;\n const SURFACE_OPACITY_DURATION = 50;\n // The surface fades away at the very end\n const SURFACE_OPACITY_DELAY = FULL_DURATION - SURFACE_OPACITY_DURATION;\n const ITEM_OPACITY_DURATION = 50;\n const ITEM_OPACITY_INITIAL_DELAY = 50;\n const END_HEIGHT_PERCENTAGE = 0.35;\n\n // We want to fit every child fade-out animation within the full duration of\n // the animation.\n const DELAY_BETWEEN_ITEMS =\n (FULL_DURATION - ITEM_OPACITY_INITIAL_DELAY - ITEM_OPACITY_DURATION) /\n children.length;\n\n // The mock has the animation shrink to 35%\n const surfaceHeightAnimation = surfaceEl.animate(\n [\n {height: `${height}px`},\n {height: `${height * END_HEIGHT_PERCENTAGE}px`},\n ],\n {\n duration: FULL_DURATION,\n easing: EASING.EMPHASIZED_ACCELERATE,\n },\n );\n\n // When we are closing downwards, we want to make sure the last item is\n // always in view, so we need to translate it upwards the opposite direction\n // of the height animation\n const downPositionCorrectionAnimation = slotEl.animate(\n [\n {transform: ''},\n {\n transform: closingDownwards\n ? `translateY(-${height * (1 - END_HEIGHT_PERCENTAGE)}px)`\n : '',\n },\n ],\n {duration: FULL_DURATION, easing: EASING.EMPHASIZED_ACCELERATE},\n );\n\n const surfaceOpacityAnimation = surfaceEl.animate(\n [{opacity: 1}, {opacity: 0}],\n {duration: SURFACE_OPACITY_DURATION, delay: SURFACE_OPACITY_DELAY},\n );\n\n const childrenAnimations: Array<[HTMLElement, Animation]> = [];\n\n for (let i = 0; i < children.length; i++) {\n // If the animation is closing upwards, then reverse the list of\n // children so that we animate in the opposite direction.\n const directionalIndex = closingDownwards ? i : children.length - 1 - i;\n const child = children[directionalIndex];\n const animation = child.animate([{opacity: 1}, {opacity: 0}], {\n duration: ITEM_OPACITY_DURATION,\n delay: ITEM_OPACITY_INITIAL_DELAY + DELAY_BETWEEN_ITEMS * i,\n });\n\n // Make sure the items stay hidden at the end of each child animation.\n // We clean this up at the end of the overall animation.\n animation.addEventListener('finish', () => {\n child.classList.toggle('md-menu-hidden', true);\n });\n childrenAnimations.push([child, animation]);\n }\n\n signal.addEventListener('abort', () => {\n surfaceHeightAnimation.cancel();\n downPositionCorrectionAnimation.cancel();\n surfaceOpacityAnimation.cancel();\n childrenAnimations.forEach(([child, animation]) => {\n animation.cancel();\n child.classList.toggle('md-menu-hidden', false);\n });\n resolve(false);\n });\n\n surfaceHeightAnimation.addEventListener('finish', () => {\n surfaceEl.classList.toggle('animating', false);\n childrenAnimations.forEach(([child]) => {\n child.classList.toggle('md-menu-hidden', false);\n });\n this.openCloseAnimationSignal.finish();\n this.dispatchEvent(new Event('closed'));\n resolve(true);\n });\n\n return animationEnded;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n // At any key event, the pointer interaction is done so we need to clear our\n // cached pointerpath. This handles the case where the user clicks on the\n // anchor, and then hits shift+tab\n this.pointerPath = [];\n this.listController.handleKeydown(event);\n }\n\n private setUpGlobalEventListeners() {\n document.addEventListener('click', this.onDocumentClick, {capture: true});\n window.addEventListener('pointerdown', this.onWindowPointerdown);\n document.addEventListener('resize', this.onWindowResize, {passive: true});\n window.addEventListener('resize', this.onWindowResize, {passive: true});\n }\n\n private cleanUpGlobalEventListeners() {\n document.removeEventListener('click', this.onDocumentClick, {\n capture: true,\n });\n window.removeEventListener('pointerdown', this.onWindowPointerdown);\n document.removeEventListener('resize', this.onWindowResize);\n window.removeEventListener('resize', this.onWindowResize);\n }\n\n private readonly onWindowPointerdown = (event: PointerEvent) => {\n this.pointerPath = event.composedPath();\n };\n\n /**\n * We cannot listen to window click because Safari on iOS will not bubble a\n * click event on window if the item clicked is not a \"clickable\" item such as\n * <body>\n */\n private readonly onDocumentClick = (event: Event) => {\n if (!this.open) {\n return;\n }\n\n const path = event.composedPath();\n\n if (\n !this.stayOpenOnOutsideClick &&\n !path.includes(this) &&\n !path.includes(this.anchorElement!)\n ) {\n this.open = false;\n }\n };\n\n private onCloseMenu() {\n this.close();\n }\n\n private onDeactivateItems(event: Event) {\n event.stopPropagation();\n this.listController.onDeactivateItems();\n }\n\n private onRequestActivation(event: Event) {\n event.stopPropagation();\n this.listController.onRequestActivation(event);\n }\n\n private handleDeactivateTypeahead(event: DeactivateTypeaheadEvent) {\n // stopPropagation so that this does not deactivate any typeaheads in menus\n // nested above it e.g. md-sub-menu\n event.stopPropagation();\n this.typeaheadActive = false;\n }\n\n private handleActivateTypeahead(event: ActivateTypeaheadEvent) {\n // stopPropagation so that this does not activate any typeaheads in menus\n // nested above it e.g. md-sub-menu\n event.stopPropagation();\n this.typeaheadActive = true;\n }\n\n private handleStayOpenOnFocusout(event: Event) {\n event.stopPropagation();\n this.stayOpenOnFocusout = true;\n }\n\n private handleCloseOnFocusout(event: Event) {\n event.stopPropagation();\n this.stayOpenOnFocusout = false;\n }\n\n close() {\n this.open = false;\n const maybeSubmenu = this.slotItems as Array<\n HTMLElement & {close?: () => void}\n >;\n maybeSubmenu.forEach((item) => {\n item.close?.();\n });\n }\n\n show() {\n this.open = true;\n }\n\n /**\n * Activates the next item in the menu. If at the end of the menu, the first\n * item will be activated.\n *\n * @return The activated menu item or `null` if there are no items.\n */\n activateNextItem() {\n return this.listController.activateNextItem() ?? null;\n }\n\n /**\n * Activates the previous item in the menu. If at the start of the menu, the\n * last item will be activated.\n *\n * @return The activated menu item or `null` if there are no items.\n */\n activatePreviousItem() {\n return this.listController.activatePreviousItem() ?? null;\n }\n\n /**\n * Repositions the menu if it is open.\n *\n * Useful for the case where document or window-positioned menus have their\n * anchors moved while open.\n */\n reposition() {\n if (this.open) {\n this.menuPositionController.position();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AACtC,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,UAAU,EAAkB,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AACxE,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,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AAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CACnD;AAKkD;IAAzD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;4CACjD;AAMR;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAC,CAAC;4CACR;AAU/C;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;0CACC;AASF;IAArC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;wCAAyC;AAQ9E;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4BAA4B,EAAC,CAAC;oDACpC;AAQ/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAC,CAAC;gDACnC;AAM3B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CAClC;AASzB;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;0CACU;AAQjD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAC,CAAC;8CAClC;AAEyB;IAAjD,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;uCAAqC;AAC3D;IAAhB,KAAK,EAAE;6CAAgC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../elevation/elevation.js';\nimport '../../focus/md-focus-ring.js';\n\nimport {LitElement, PropertyValues, html, isServer, nothing} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {styleMap} from 'lit/directives/style-map.js';\n\nimport {EASING, createAnimationSignal} from '../../internal/motion/animation.js';\nimport {\n ListController,\n NavigableKeys,\n} from '../../list/internal/list-controller.js';\nimport {\n getActiveItem,\n getFirstActivatableItem,\n getLastActivatableItem,\n} from '../../list/internal/list-navigation-helpers.js';\n\nimport {MenuItem} from './controllers/menuItemController.js';\nimport {\n ActivateTypeaheadEvent,\n DeactivateTypeaheadEvent,\n FocusState,\n isClosableKey,\n isElementInSubtree,\n} from './controllers/shared.js';\nimport {\n Corner,\n SurfacePositionController,\n SurfacePositionTarget,\n} from './controllers/surfacePositionController.js';\nimport {TypeaheadController} from './controllers/typeaheadController.js';\n\nexport {Corner} from './controllers/surfacePositionController.js';\n\n/**\n * The default value for the typeahead buffer time in Milliseconds.\n */\nexport const DEFAULT_TYPEAHEAD_BUFFER_TIME = 200;\n\nconst submenuNavKeys = new Set<string>([\n NavigableKeys.ArrowDown,\n NavigableKeys.ArrowUp,\n NavigableKeys.Home,\n NavigableKeys.End,\n]);\n\nconst menuNavKeys = new Set<string>([\n NavigableKeys.ArrowLeft,\n NavigableKeys.ArrowRight,\n ...submenuNavKeys,\n]);\n\n/**\n * Gets the currently focused element on the page.\n *\n * @param activeDoc The document or shadowroot from which to start the search.\n * Defaults to `window.document`\n * @return Returns the currently deeply focused element or `null` if none.\n */\nfunction getFocusedElement(\n activeDoc: Document | ShadowRoot = document,\n): HTMLElement | null {\n let activeEl = activeDoc.activeElement as HTMLElement | null;\n\n // Check for activeElement in the case that an element with a shadow root host\n // is currently focused.\n while (activeEl && activeEl?.shadowRoot?.activeElement) {\n activeEl = activeEl.shadowRoot.activeElement as HTMLElement | null;\n }\n\n return activeEl;\n}\n\n/**\n * @fires opening {Event} Fired before the opening animation begins\n * @fires opened {Event} Fired once the menu is open, after any animations\n * @fires closing {Event} Fired before the closing animation begins\n * @fires closed {Event} Fired once the menu is closed, after any animations\n */\nexport abstract class Menu extends LitElement {\n @query('.menu') private readonly surfaceEl!: HTMLElement | null;\n @query('slot') private readonly slotEl!: HTMLSlotElement | null;\n\n /**\n * The ID of the element in the same root node in which the menu should align\n * to. Overrides setting `anchorElement = elementReference`.\n *\n * __NOTE__: anchor or anchorElement must either be an HTMLElement or resolve\n * to an HTMLElement in order for menu to open.\n */\n @property() anchor = '';\n /**\n * Whether the positioning algorithm should calculate relative to the parent\n * of the anchor element (`absolute`), relative to the window (`fixed`), or\n * relative to the document (`document`). `popover` will use the popover API\n * to render the menu in the top-layer. If your browser does not support the\n * popover API, it will fall back to `fixed`.\n *\n * __Examples for `position = 'fixed'`:__\n *\n * - If there is no `position:relative` in the given parent tree and the\n * surface is `position:absolute`\n * - If the surface is `position:fixed`\n * - If the surface is in the \"top layer\"\n * - The anchor and the surface do not share a common `position:relative`\n * ancestor\n *\n * When using `positioning=fixed`, in most cases, the menu should position\n * itself above most other `position:absolute` or `position:fixed` elements\n * when placed inside of them. e.g. using a menu inside of an `md-dialog`.\n *\n * __NOTE__: Fixed menus will not scroll with the page and will be fixed to\n * the window instead.\n *\n * __Examples for `position = 'document'`:__\n *\n * - There is no parent that creates a relative positioning context e.g.\n * `position: relative`, `position: absolute`, `transform: translate(x, y)`,\n * etc.\n * - You put the effort into hoisting the menu to the top of the DOM like the\n * end of the `<body>` to render over everything or in a top-layer.\n * - You are reusing a single `md-menu` element that dynamically renders\n * content.\n *\n * __Examples for `position = 'popover'`:__\n *\n * - Your browser supports `popover`.\n * - Most cases. Once popover is in browsers, this will become the default.\n */\n @property() positioning: 'absolute' | 'fixed' | 'document' | 'popover' =\n 'absolute';\n /**\n * Skips the opening and closing animations.\n */\n @property({type: Boolean}) quick = false;\n /**\n * Displays overflow content like a submenu. Not required in most cases when\n * using `positioning=\"popover\"`.\n *\n * __NOTE__: This may cause adverse effects if you set\n * `md-menu {max-height:...}`\n * and have items overflowing items in the \"y\" direction.\n */\n @property({type: Boolean, attribute: 'has-overflow'}) hasOverflow = false;\n /**\n * Opens the menu and makes it visible. Alternative to the `.show()` and\n * `.close()` methods\n */\n @property({type: Boolean, reflect: true}) open = false;\n /**\n * Offsets the menu's inline alignment from the anchor by the given number in\n * pixels. This value is direction aware and will follow the LTR / RTL\n * direction.\n *\n * e.g. LTR: positive -> right, negative -> left\n * RTL: positive -> left, negative -> right\n */\n @property({type: Number, attribute: 'x-offset'}) xOffset = 0;\n /**\n * Offsets the menu's block alignment from the anchor by the given number in\n * pixels.\n *\n * e.g. positive -> down, negative -> up\n */\n @property({type: Number, attribute: 'y-offset'}) yOffset = 0;\n /**\n * Disable the `flip` behavior that usually happens on the horizontal axis\n * when the surface would render outside the viewport.\n */\n @property({type: Boolean, attribute: 'no-horizontal-flip'}) noHorizontalFlip =\n false;\n /**\n * Disable the `flip` behavior that usually happens on the vertical axis when\n * the surface would render outside the viewport.\n */\n @property({type: Boolean, attribute: 'no-vertical-flip'}) noVerticalFlip =\n false;\n /**\n * The max time between the keystrokes of the typeahead menu behavior before\n * it clears the typeahead buffer.\n */\n @property({type: Number, attribute: 'typeahead-delay'})\n typeaheadDelay = DEFAULT_TYPEAHEAD_BUFFER_TIME;\n /**\n * The corner of the anchor which to align the menu in the standard logical\n * property style of <block>-<inline> e.g. `'end-start'`.\n *\n * NOTE: This value may not be respected by the menu positioning algorithm\n * if the menu would render outisde the viewport.\n * Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value\n */\n @property({attribute: 'anchor-corner'})\n anchorCorner: Corner = Corner.END_START;\n /**\n * The corner of the menu which to align the anchor in the standard logical\n * property style of <block>-<inline> e.g. `'start-start'`.\n *\n * NOTE: This value may not be respected by the menu positioning algorithm\n * if the menu would render outisde the viewport.\n * Use `no-horizontal-flip` or `no-vertical-flip` to force the usage of the value\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = Corner.START_START;\n /**\n * Keeps the user clicks outside the menu.\n *\n * NOTE: clicking outside may still cause focusout to close the menu so see\n * `stayOpenOnFocusout`.\n */\n @property({type: Boolean, attribute: 'stay-open-on-outside-click'})\n stayOpenOnOutsideClick = false;\n /**\n * Keeps the menu open when focus leaves the menu's composed subtree.\n *\n * NOTE: Focusout behavior will stop propagation of the focusout event. Set\n * this property to true to opt-out of menu's focusout handling altogether.\n */\n @property({type: Boolean, attribute: 'stay-open-on-focusout'})\n stayOpenOnFocusout = false;\n /**\n * After closing, does not restore focus to the last focused element before\n * the menu was opened.\n */\n @property({type: Boolean, attribute: 'skip-restore-focus'})\n skipRestoreFocus = false;\n /**\n * The element that should be focused by default once opened.\n *\n * NOTE: When setting default focus to 'LIST_ROOT', remember to change\n * `tabindex` to `0` and change md-menu's display to something other than\n * `display: contents` when necessary.\n */\n @property({attribute: 'default-focus'})\n defaultFocus: FocusState = FocusState.FIRST_ITEM;\n\n /**\n * Turns off navigation wrapping. By default, navigating past the end of the\n * menu items will wrap focus back to the beginning and vice versa. Use this\n * for ARIA patterns that do not wrap focus, like combobox.\n */\n @property({type: Boolean, attribute: 'no-navigation-wrap'})\n noNavigationWrap = false;\n\n @queryAssignedElements({flatten: true}) protected slotItems!: HTMLElement[];\n @state() private typeaheadActive = true;\n\n /**\n * Whether or not the current menu is a submenu and should not handle specific\n * navigation keys.\n *\n * @export\n */\n isSubmenu = false;\n\n /**\n * The event path of the last window pointerdown event.\n */\n private pointerPath: EventTarget[] = [];\n\n /**\n * Whether or not the menu is repositoining due to window / document resize\n */\n private isRepositioning = false;\n private readonly openCloseAnimationSignal = createAnimationSignal();\n\n private readonly listController = new ListController<MenuItem>({\n isItem: (maybeItem: HTMLElement): maybeItem is MenuItem => {\n return maybeItem.hasAttribute('md-menu-item');\n },\n getPossibleItems: () => this.slotItems,\n isRtl: () => getComputedStyle(this).direction === 'rtl',\n deactivateItem: (item: MenuItem) => {\n item.selected = false;\n item.tabIndex = -1;\n },\n activateItem: (item: MenuItem) => {\n item.selected = true;\n item.tabIndex = 0;\n },\n isNavigableKey: (key: string) => {\n if (!this.isSubmenu) {\n return menuNavKeys.has(key);\n }\n\n const isRtl = getComputedStyle(this).direction === 'rtl';\n // we want md-submenu to handle the submenu's left/right arrow exit\n // key so it can close the menu instead of navigate the list.\n // Therefore we need to include all keys but left/right arrow close\n // key\n const arrowOpen = isRtl\n ? NavigableKeys.ArrowLeft\n : NavigableKeys.ArrowRight;\n\n if (key === arrowOpen) {\n return true;\n }\n\n return submenuNavKeys.has(key);\n },\n wrapNavigation: () => !this.noNavigationWrap,\n });\n\n /**\n * Whether the menu is animating upwards or downwards when opening. This is\n * helpful for calculating some animation calculations.\n */\n private get openDirection(): 'UP' | 'DOWN' {\n const menuCornerBlock = this.menuCorner.split('-')[0];\n return menuCornerBlock === 'start' ? 'DOWN' : 'UP';\n }\n\n /**\n * The element that was focused before the menu opened.\n */\n private lastFocusedElement: HTMLElement | null = null;\n\n /**\n * Handles typeahead navigation through the menu.\n */\n typeaheadController = new TypeaheadController(() => {\n return {\n getItems: () => this.items,\n typeaheadBufferTime: this.typeaheadDelay,\n active: this.typeaheadActive,\n };\n });\n\n private currentAnchorElement: HTMLElement | null = null;\n\n /**\n * The element which the menu should align to. If `anchor` is set to a\n * non-empty idref string, then `anchorEl` will resolve to the element with\n * the given id in the same root node. Otherwise, `null`.\n */\n get anchorElement(): (HTMLElement & Partial<SurfacePositionTarget>) | null {\n if (this.anchor) {\n return (this.getRootNode() as Document | ShadowRoot).querySelector(\n `#${this.anchor}`,\n );\n }\n\n return this.currentAnchorElement;\n }\n\n set anchorElement(\n element: (HTMLElement & Partial<SurfacePositionTarget>) | null,\n ) {\n this.currentAnchorElement = element;\n this.requestUpdate('anchorElement');\n }\n\n private readonly internals =\n // Cast needed for closure\n (this as HTMLElement).attachInternals();\n\n constructor() {\n super();\n if (!isServer) {\n this.internals.role = 'menu';\n this.addEventListener('keydown', this.handleKeydown);\n // Capture so that we can grab the event before it reaches the menu item\n // istelf. Specifically useful for the case where typeahead encounters a\n // space and we don't want the menu item to close the menu.\n this.addEventListener('keydown', this.captureKeydown, {capture: true});\n this.addEventListener('focusout', this.handleFocusout);\n }\n }\n\n /**\n * Handles positioning the surface and aligning it to the anchor as well as\n * keeping it in the viewport.\n */\n private readonly menuPositionController = new SurfacePositionController(\n this,\n () => {\n return {\n anchorCorner: this.anchorCorner,\n surfaceCorner: this.menuCorner,\n surfaceEl: this.surfaceEl,\n anchorEl: this.anchorElement,\n positioning:\n this.positioning === 'popover' ? 'document' : this.positioning,\n isOpen: this.open,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n disableBlockFlip: this.noVerticalFlip,\n disableInlineFlip: this.noHorizontalFlip,\n onOpen: this.onOpened,\n beforeClose: this.beforeClose,\n onClose: this.onClosed,\n // We can't resize components that have overflow like menus with\n // submenus because the overflow-y will show menu items / content\n // outside the bounds of the menu. Popover API fixes this because each\n // submenu is hoisted to the top-layer and are not considered overflow\n // content.\n repositionStrategy:\n this.hasOverflow && this.positioning !== 'popover'\n ? 'move'\n : 'resize',\n };\n },\n );\n\n /**\n * The menu items associated with this menu. The items must be `MenuItem`s and\n * have both the `md-menu-item` and `md-list-item` attributes.\n */\n get items(): MenuItem[] {\n return this.listController.items;\n }\n\n protected override willUpdate(changed: PropertyValues<Menu>) {\n if (!changed.has('open')) {\n return;\n }\n\n if (this.open) {\n this.removeAttribute('aria-hidden');\n return;\n }\n\n this.setAttribute('aria-hidden', 'true');\n }\n\n override update(changed: PropertyValues<Menu>) {\n if (changed.has('open')) {\n if (this.open) {\n this.setUpGlobalEventListeners();\n } else {\n this.cleanUpGlobalEventListeners();\n }\n }\n\n // Firefox does not support popover. Fall-back to using fixed.\n if (\n changed.has('positioning') &&\n this.positioning === 'popover' &&\n // type required for Google JS conformance\n !(this as unknown as {showPopover?: () => void}).showPopover\n ) {\n this.positioning = 'fixed';\n }\n\n super.update(changed);\n }\n\n private readonly onWindowResize = () => {\n if (\n this.isRepositioning ||\n (this.positioning !== 'document' &&\n this.positioning !== 'fixed' &&\n this.positioning !== 'popover')\n ) {\n return;\n }\n this.isRepositioning = true;\n this.reposition();\n this.isRepositioning = false;\n };\n\n override connectedCallback() {\n super.connectedCallback();\n if (this.open) {\n this.setUpGlobalEventListeners();\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.cleanUpGlobalEventListeners();\n }\n\n override getBoundingClientRect() {\n if (!this.surfaceEl) {\n return super.getBoundingClientRect();\n }\n return this.surfaceEl.getBoundingClientRect();\n }\n\n override getClientRects() {\n if (!this.surfaceEl) {\n return super.getClientRects();\n }\n return this.surfaceEl.getClientRects();\n }\n\n protected override render() {\n return this.renderSurface();\n }\n\n /**\n * Renders the positionable surface element and its contents.\n */\n private renderSurface() {\n return html`\n <div\n class=\"menu ${classMap(this.getSurfaceClasses())}\"\n style=${styleMap(this.menuPositionController.surfaceStyles)}\n popover=${this.positioning === 'popover' ? 'manual' : nothing}>\n ${this.renderElevation()}\n <div class=\"items\">\n <div class=\"item-padding\"> ${this.renderMenuItems()} </div>\n </div>\n </div>\n `;\n }\n\n /**\n * Renders the menu items' slot\n */\n private renderMenuItems() {\n return html`<slot\n @close-menu=${this.onCloseMenu}\n @deactivate-items=${this.onDeactivateItems}\n @request-activation=${this.onRequestActivation}\n @deactivate-typeahead=${this.handleDeactivateTypeahead}\n @activate-typeahead=${this.handleActivateTypeahead}\n @stay-open-on-focusout=${this.handleStayOpenOnFocusout}\n @close-on-focusout=${this.handleCloseOnFocusout}\n @slotchange=${this.listController.onSlotchange}></slot>`;\n }\n\n /**\n * Renders the elevation component.\n */\n private renderElevation() {\n return html`<md-elevation part=\"elevation\"></md-elevation>`;\n }\n\n private getSurfaceClasses(): ClassInfo {\n return {\n open: this.open,\n fixed: this.positioning === 'fixed',\n 'has-overflow': this.hasOverflow,\n };\n }\n\n private readonly handleFocusout = async (event: FocusEvent) => {\n const anchorEl = this.anchorElement!;\n // Do not close if we focused out by clicking on the anchor element. We\n // can't assume anchor buttons can be the related target because of iOS does\n // not focus buttons.\n if (\n this.stayOpenOnFocusout ||\n !this.open ||\n this.pointerPath.includes(anchorEl)\n ) {\n return;\n }\n\n if (event.relatedTarget) {\n // Don't close the menu if we are switching focus between menu,\n // md-menu-item, and md-list or if the anchor was click focused, but check\n // if length of pointerPath is 0 because that means something was at least\n // clicked (shift+tab case).\n if (\n isElementInSubtree(event.relatedTarget, this) ||\n (this.pointerPath.length !== 0 &&\n isElementInSubtree(event.relatedTarget, anchorEl))\n ) {\n return;\n }\n } else if (this.pointerPath.includes(this)) {\n // If menu tabindex == -1 and the user clicks on the menu or a divider, we\n // want to keep the menu open.\n return;\n }\n\n const oldRestoreFocus = this.skipRestoreFocus;\n // allow focus to continue to the next focused object rather than returning\n this.skipRestoreFocus = true;\n this.close();\n // await for close\n await this.updateComplete;\n // return to previous behavior\n this.skipRestoreFocus = oldRestoreFocus;\n };\n\n private captureKeydown(event: KeyboardEvent) {\n if (\n event.target === this &&\n !event.defaultPrevented &&\n isClosableKey(event.code)\n ) {\n event.preventDefault();\n this.close();\n }\n\n this.typeaheadController.onKeydown(event);\n }\n\n /**\n * Saves the last focused element focuses the new element based on\n * `defaultFocus`, and animates open.\n */\n private readonly onOpened = async () => {\n this.lastFocusedElement = getFocusedElement();\n\n const items = this.items;\n const activeItemRecord = getActiveItem(items);\n\n if (activeItemRecord && this.defaultFocus !== FocusState.NONE) {\n activeItemRecord.item.tabIndex = -1;\n }\n\n let animationAborted = !this.quick;\n\n if (this.quick) {\n this.dispatchEvent(new Event('opening'));\n } else {\n animationAborted = !!(await this.animateOpen());\n }\n\n // This must come after the opening animation or else it may focus one of\n // the items before the animation has begun and causes the list to slide\n // (block-padding-of-the-menu)px at the end of the animation\n switch (this.defaultFocus) {\n case FocusState.FIRST_ITEM:\n const first = getFirstActivatableItem(items);\n if (first) {\n first.tabIndex = 0;\n first.focus();\n await (first as LitElement & MenuItem).updateComplete;\n }\n break;\n case FocusState.LAST_ITEM:\n const last = getLastActivatableItem(items);\n if (last) {\n last.tabIndex = 0;\n last.focus();\n await (last as LitElement & MenuItem).updateComplete;\n }\n break;\n case FocusState.LIST_ROOT:\n this.focus();\n break;\n default:\n case FocusState.NONE:\n // Do nothing.\n break;\n }\n\n if (!animationAborted) {\n this.dispatchEvent(new Event('opened'));\n }\n };\n\n /**\n * Animates closed.\n */\n private readonly beforeClose = async () => {\n this.open = false;\n\n if (!this.skipRestoreFocus) {\n this.lastFocusedElement?.focus?.();\n }\n\n if (!this.quick) {\n await this.animateClose();\n }\n };\n\n /**\n * Focuses the last focused element.\n */\n private readonly onClosed = () => {\n if (this.quick) {\n this.dispatchEvent(new Event('closing'));\n this.dispatchEvent(new Event('closed'));\n }\n };\n\n /**\n * Performs the opening animation:\n *\n * https://direct.googleplex.com/#/spec/295000003+271060003\n *\n * @return A promise that resolve to `true` if the animation was aborted,\n * `false` if it was not aborted.\n */\n private async animateOpen() {\n const surfaceEl = this.surfaceEl;\n const slotEl = this.slotEl;\n\n if (!surfaceEl || !slotEl) return true;\n\n const openDirection = this.openDirection;\n this.dispatchEvent(new Event('opening'));\n // needs to be imperative because we don't want to mix animation and Lit\n // render timing\n surfaceEl.classList.toggle('animating', true);\n\n const signal = this.openCloseAnimationSignal.start();\n const height = surfaceEl.offsetHeight;\n const openingUpwards = openDirection === 'UP';\n const children = this.items;\n const FULL_DURATION = 500;\n const SURFACE_OPACITY_DURATION = 50;\n const ITEM_OPACITY_DURATION = 250;\n // We want to fit every child fade-in animation within the full duration of\n // the animation.\n const DELAY_BETWEEN_ITEMS =\n (FULL_DURATION - ITEM_OPACITY_DURATION) / children.length;\n\n const surfaceHeightAnimation = surfaceEl.animate(\n [{height: '0px'}, {height: `${height}px`}],\n {\n duration: FULL_DURATION,\n easing: EASING.EMPHASIZED,\n },\n );\n // When we are opening upwards, we want to make sure the last item is always\n // in view, so we need to translate it upwards the opposite direction of the\n // height animation\n const upPositionCorrectionAnimation = slotEl.animate(\n [\n {transform: openingUpwards ? `translateY(-${height}px)` : ''},\n {transform: ''},\n ],\n {duration: FULL_DURATION, easing: EASING.EMPHASIZED},\n );\n\n const surfaceOpacityAnimation = surfaceEl.animate(\n [{opacity: 0}, {opacity: 1}],\n SURFACE_OPACITY_DURATION,\n );\n\n const childrenAnimations: Array<[HTMLElement, Animation]> = [];\n\n for (let i = 0; i < children.length; i++) {\n // If we are animating upwards, then reverse the children list.\n const directionalIndex = openingUpwards ? children.length - 1 - i : i;\n const child = children[directionalIndex];\n const animation = child.animate([{opacity: 0}, {opacity: 1}], {\n duration: ITEM_OPACITY_DURATION,\n delay: DELAY_BETWEEN_ITEMS * i,\n });\n\n // Make them all initially hidden and then clean up at the end of each\n // animation.\n child.classList.toggle('md-menu-hidden', true);\n animation.addEventListener('finish', () => {\n child.classList.toggle('md-menu-hidden', false);\n });\n\n childrenAnimations.push([child, animation]);\n }\n\n let resolveAnimation = (value: boolean) => {};\n const animationFinished = new Promise<boolean>((resolve) => {\n resolveAnimation = resolve;\n });\n\n signal.addEventListener('abort', () => {\n surfaceHeightAnimation.cancel();\n upPositionCorrectionAnimation.cancel();\n surfaceOpacityAnimation.cancel();\n childrenAnimations.forEach(([child, animation]) => {\n child.classList.toggle('md-menu-hidden', false);\n animation.cancel();\n });\n\n resolveAnimation(true);\n });\n\n surfaceHeightAnimation.addEventListener('finish', () => {\n surfaceEl.classList.toggle('animating', false);\n this.openCloseAnimationSignal.finish();\n resolveAnimation(false);\n });\n\n return await animationFinished;\n }\n\n /**\n * Performs the closing animation:\n *\n * https://direct.googleplex.com/#/spec/295000003+271060003\n */\n private animateClose() {\n let resolve!: (value: unknown) => void;\n\n // This promise blocks the surface position controller from setting\n // display: none on the surface which will interfere with this animation.\n const animationEnded = new Promise((res) => {\n resolve = res;\n });\n\n const surfaceEl = this.surfaceEl;\n const slotEl = this.slotEl;\n\n if (!surfaceEl || !slotEl) {\n resolve(false);\n return animationEnded;\n }\n\n const openDirection = this.openDirection;\n const closingDownwards = openDirection === 'UP';\n this.dispatchEvent(new Event('closing'));\n // needs to be imperative because we don't want to mix animation and Lit\n // render timing\n surfaceEl.classList.toggle('animating', true);\n const signal = this.openCloseAnimationSignal.start();\n const height = surfaceEl.offsetHeight;\n const children = this.items;\n const FULL_DURATION = 150;\n const SURFACE_OPACITY_DURATION = 50;\n // The surface fades away at the very end\n const SURFACE_OPACITY_DELAY = FULL_DURATION - SURFACE_OPACITY_DURATION;\n const ITEM_OPACITY_DURATION = 50;\n const ITEM_OPACITY_INITIAL_DELAY = 50;\n const END_HEIGHT_PERCENTAGE = 0.35;\n\n // We want to fit every child fade-out animation within the full duration of\n // the animation.\n const DELAY_BETWEEN_ITEMS =\n (FULL_DURATION - ITEM_OPACITY_INITIAL_DELAY - ITEM_OPACITY_DURATION) /\n children.length;\n\n // The mock has the animation shrink to 35%\n const surfaceHeightAnimation = surfaceEl.animate(\n [\n {height: `${height}px`},\n {height: `${height * END_HEIGHT_PERCENTAGE}px`},\n ],\n {\n duration: FULL_DURATION,\n easing: EASING.EMPHASIZED_ACCELERATE,\n },\n );\n\n // When we are closing downwards, we want to make sure the last item is\n // always in view, so we need to translate it upwards the opposite direction\n // of the height animation\n const downPositionCorrectionAnimation = slotEl.animate(\n [\n {transform: ''},\n {\n transform: closingDownwards\n ? `translateY(-${height * (1 - END_HEIGHT_PERCENTAGE)}px)`\n : '',\n },\n ],\n {duration: FULL_DURATION, easing: EASING.EMPHASIZED_ACCELERATE},\n );\n\n const surfaceOpacityAnimation = surfaceEl.animate(\n [{opacity: 1}, {opacity: 0}],\n {duration: SURFACE_OPACITY_DURATION, delay: SURFACE_OPACITY_DELAY},\n );\n\n const childrenAnimations: Array<[HTMLElement, Animation]> = [];\n\n for (let i = 0; i < children.length; i++) {\n // If the animation is closing upwards, then reverse the list of\n // children so that we animate in the opposite direction.\n const directionalIndex = closingDownwards ? i : children.length - 1 - i;\n const child = children[directionalIndex];\n const animation = child.animate([{opacity: 1}, {opacity: 0}], {\n duration: ITEM_OPACITY_DURATION,\n delay: ITEM_OPACITY_INITIAL_DELAY + DELAY_BETWEEN_ITEMS * i,\n });\n\n // Make sure the items stay hidden at the end of each child animation.\n // We clean this up at the end of the overall animation.\n animation.addEventListener('finish', () => {\n child.classList.toggle('md-menu-hidden', true);\n });\n childrenAnimations.push([child, animation]);\n }\n\n signal.addEventListener('abort', () => {\n surfaceHeightAnimation.cancel();\n downPositionCorrectionAnimation.cancel();\n surfaceOpacityAnimation.cancel();\n childrenAnimations.forEach(([child, animation]) => {\n animation.cancel();\n child.classList.toggle('md-menu-hidden', false);\n });\n resolve(false);\n });\n\n surfaceHeightAnimation.addEventListener('finish', () => {\n surfaceEl.classList.toggle('animating', false);\n childrenAnimations.forEach(([child]) => {\n child.classList.toggle('md-menu-hidden', false);\n });\n this.openCloseAnimationSignal.finish();\n this.dispatchEvent(new Event('closed'));\n resolve(true);\n });\n\n return animationEnded;\n }\n\n private handleKeydown(event: KeyboardEvent) {\n // At any key event, the pointer interaction is done so we need to clear our\n // cached pointerpath. This handles the case where the user clicks on the\n // anchor, and then hits shift+tab\n this.pointerPath = [];\n this.listController.handleKeydown(event);\n }\n\n private setUpGlobalEventListeners() {\n document.addEventListener('click', this.onDocumentClick, {capture: true});\n window.addEventListener('pointerdown', this.onWindowPointerdown);\n document.addEventListener('resize', this.onWindowResize, {passive: true});\n window.addEventListener('resize', this.onWindowResize, {passive: true});\n }\n\n private cleanUpGlobalEventListeners() {\n document.removeEventListener('click', this.onDocumentClick, {\n capture: true,\n });\n window.removeEventListener('pointerdown', this.onWindowPointerdown);\n document.removeEventListener('resize', this.onWindowResize);\n window.removeEventListener('resize', this.onWindowResize);\n }\n\n private readonly onWindowPointerdown = (event: PointerEvent) => {\n this.pointerPath = event.composedPath();\n };\n\n /**\n * We cannot listen to window click because Safari on iOS will not bubble a\n * click event on window if the item clicked is not a \"clickable\" item such as\n * <body>\n */\n private readonly onDocumentClick = (event: Event) => {\n if (!this.open) {\n return;\n }\n\n const path = event.composedPath();\n\n if (\n !this.stayOpenOnOutsideClick &&\n !path.includes(this) &&\n !path.includes(this.anchorElement!)\n ) {\n this.open = false;\n }\n };\n\n private onCloseMenu() {\n this.close();\n }\n\n private onDeactivateItems(event: Event) {\n event.stopPropagation();\n this.listController.onDeactivateItems();\n }\n\n private onRequestActivation(event: Event) {\n event.stopPropagation();\n this.listController.onRequestActivation(event);\n }\n\n private handleDeactivateTypeahead(event: DeactivateTypeaheadEvent) {\n // stopPropagation so that this does not deactivate any typeaheads in menus\n // nested above it e.g. md-sub-menu\n event.stopPropagation();\n this.typeaheadActive = false;\n }\n\n private handleActivateTypeahead(event: ActivateTypeaheadEvent) {\n // stopPropagation so that this does not activate any typeaheads in menus\n // nested above it e.g. md-sub-menu\n event.stopPropagation();\n this.typeaheadActive = true;\n }\n\n private handleStayOpenOnFocusout(event: Event) {\n event.stopPropagation();\n this.stayOpenOnFocusout = true;\n }\n\n private handleCloseOnFocusout(event: Event) {\n event.stopPropagation();\n this.stayOpenOnFocusout = false;\n }\n\n close() {\n this.open = false;\n const maybeSubmenu = this.slotItems as Array<\n HTMLElement & {close?: () => void}\n >;\n maybeSubmenu.forEach((item) => {\n item.close?.();\n });\n }\n\n show() {\n this.open = true;\n }\n\n /**\n * Activates the next item in the menu. If at the end of the menu, the first\n * item will be activated.\n *\n * @return The activated menu item or `null` if there are no items.\n */\n activateNextItem() {\n return this.listController.activateNextItem() ?? null;\n }\n\n /**\n * Activates the previous item in the menu. If at the start of the menu, the\n * last item will be activated.\n *\n * @return The activated menu item or `null` if there are no items.\n */\n activatePreviousItem() {\n return this.listController.activatePreviousItem() ?? null;\n }\n\n /**\n * Repositions the menu if it is open.\n *\n * Useful for the case where document or window-positioned menus have their\n * anchors moved while open.\n */\n reposition() {\n if (this.open) {\n this.menuPositionController.position();\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,iCAAiC,CAAC;AACzC,OAAO,4BAA4B,CAAC;AACpC,OAAO,2BAA2B,CAAC;AAEnC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9D,OAAO,E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CAAC;gDAAsD;AAGvD;IADlB,qBAAqB,CAAC,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;oDACU;AAEjC;IADlB,qBAAqB,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAC,CAAC;0DACS;AAEvC;IADlB,kBAAkB,CAAC,EAAC,IAAI,EAAE,EAAE,EAAC,CAAC;mDACa;AAW5C;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,gBAAgB,EAAC,CAAC;+CAGvC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../focus/md-focus-ring.js';\nimport '../../../labs/item/item.js';\nimport '../../../ripple/ripple.js';\n\nimport {html, LitElement, nothing, TemplateResult} from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {literal, html as staticHtml, StaticValue} from 'lit/static-html.js';\n\nimport {ARIAMixinStrict} from '../../../internal/aria/aria.js';\nimport {mixinDelegatesAria} from '../../../internal/aria/delegate.js';\nimport {\n MenuItem,\n MenuItemController,\n type MenuItemType,\n} from '../controllers/menuItemController.js';\n\n// Separate variable needed for closure.\nconst menuItemBaseClass = mixinDelegatesAria(LitElement);\n\n/**\n * @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}\n * Closes the encapsulating menu on closable interaction. --bubbles --composed\n */\nexport class MenuItemEl extends menuItemBaseClass implements MenuItem {\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Sets the behavior and role of the menu item, defaults to \"menuitem\".\n */\n @property() type: MenuItemType = 'menuitem';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `href` resource attribute.\n */\n @property() href = '';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `target` attribute when `href` is\n * set.\n */\n @property() target: '_blank' | '_parent' | '_self' | '_top' | '' = '';\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n /**\n * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({type: Boolean}) selected = false;\n\n @query('.list-item') protected readonly listItemRoot!: HTMLElement | null;\n\n @queryAssignedElements({slot: 'headline'})\n protected readonly headlineElements!: HTMLElement[];\n @queryAssignedElements({slot: 'supporting-text'})\n protected readonly supportingTextElements!: HTMLElement[];\n @queryAssignedNodes({slot: ''})\n protected readonly defaultElements!: Node[];\n\n /**\n * The text that is selectable via typeahead. If not set, defaults to the\n * innerText of the item slotted into the `\"headline\"` slot.\n */\n get typeaheadText() {\n return this.menuItemController.typeaheadText;\n }\n\n @property({attribute: 'typeahead-text'})\n set typeaheadText(text: string) {\n this.menuItemController.setTypeaheadText(text);\n }\n\n private readonly menuItemController = new MenuItemController(this, {\n getHeadlineElements: () => {\n return this.headlineElements;\n },\n getSupportingTextElements: () => {\n return this.supportingTextElements;\n },\n getDefaultElements: () => {\n return this.defaultElements;\n },\n getInteractiveElement: () => this.listItemRoot,\n });\n\n protected override render() {\n return this.renderListItem(html`\n <md-item>\n <div slot=\"container\">\n ${this.renderRipple()} ${this.renderFocusRing()}\n </div>\n <slot name=\"start\" slot=\"start\"></slot>\n <slot name=\"end\" slot=\"end\"></slot>\n ${this.renderBody()}\n </md-item>\n `);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n const isAnchor = this.type === 'link';\n let tag: StaticValue;\n switch (this.menuItemController.tagName) {\n case 'a':\n tag = literal`a`;\n break;\n case 'button':\n tag = literal`button`;\n break;\n default:\n case 'li':\n tag = literal`li`;\n break;\n }\n\n // TODO(b/265339866): announce \"button\"/\"link\" inside of a list item. Until\n // then all are \"menuitem\" roles for correct announcement.\n const target = isAnchor && !!this.target ? this.target : nothing;\n return staticHtml`\n <${tag}\n id=\"item\"\n tabindex=${this.disabled && !isAnchor ? -1 : 0}\n role=${this.menuItemController.role}\n aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n aria-expanded=${(this as ARIAMixinStrict).ariaExpanded || nothing}\n aria-haspopup=${(this as ARIAMixinStrict).ariaHasPopup || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n href=${this.href || nothing}\n target=${target}\n @click=${this.menuItemController.onClick}\n @keydown=${this.menuItemController.onKeydown}\n >${content}</${tag}>\n `;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n protected renderRipple(): TemplateResult | typeof nothing {\n return html` <md-ripple\n part=\"ripple\"\n for=\"item\"\n ?disabled=${this.disabled}></md-ripple>`;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n protected renderFocusRing(): TemplateResult | typeof nothing {\n return html` <md-focus-ring\n part=\"focus-ring\"\n for=\"item\"\n inward></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses(): ClassInfo {\n return {\n 'disabled': this.disabled,\n 'selected': this.selected,\n };\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n protected renderBody() {\n return html`\n <slot></slot>\n <slot name=\"overline\" slot=\"overline\"></slot>\n <slot name=\"headline\" slot=\"headline\"></slot>\n <slot name=\"supporting-text\" slot=\"supporting-text\"></slot>\n <slot\n name=\"trailing-supporting-text\"\n slot=\"trailing-supporting-text\"></slot>\n `;\n }\n\n override focus() {\n // TODO(b/300334509): needed for some cases where delegatesFocus doesn't\n // work programmatically like in FF and select-option\n this.listItemRoot?.focus();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,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,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAC,CAAC;4CAAkB;AAKzC;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;4CAAkB;AAEJ;IAAvC,KAAK,CAAC,YAAY,CAAC;gDAAsD;AAGvD;IADlB,qBAAqB,CAAC,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;oDACU;AAEjC;IADlB,qBAAqB,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAC,CAAC;0DACS;AAEvC;IADlB,kBAAkB,CAAC,EAAC,IAAI,EAAE,EAAE,EAAC,CAAC;mDACa;AAW5C;IADC,QAAQ,CAAC,EAAC,SAAS,EAAE,gBAAgB,EAAC,CAAC;+CAGvC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../focus/md-focus-ring.js';\nimport '../../../labs/item/item.js';\nimport '../../../ripple/ripple.js';\n\nimport {html, LitElement, nothing, TemplateResult} from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n queryAssignedNodes,\n} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {literal, html as staticHtml, StaticValue} from 'lit/static-html.js';\n\nimport {ARIAMixinStrict} from '../../../internal/aria/aria.js';\nimport {mixinDelegatesAria} from '../../../internal/aria/delegate.js';\nimport {\n MenuItem,\n MenuItemController,\n type MenuItemType,\n} from '../controllers/menuItemController.js';\n\n// Separate variable needed for closure.\nconst menuItemBaseClass = mixinDelegatesAria(LitElement);\n\n/**\n * @fires close-menu {CustomEvent<{initiator: SelectOption, reason: Reason, itemPath: SelectOption[]}>}\n * Closes the encapsulating menu on closable interaction. --bubbles --composed\n */\nexport class MenuItemEl extends menuItemBaseClass implements MenuItem {\n /** @nocollapse */\n static override shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n /**\n * Sets the behavior and role of the menu item, defaults to \"menuitem\".\n */\n @property() type: MenuItemType = 'menuitem';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `href` resource attribute.\n */\n @property() href = '';\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `target` attribute when `href` is\n * set.\n */\n @property() target: '_blank' | '_parent' | '_self' | '_top' | '' = '';\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n /**\n * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({type: Boolean}) selected = false;\n\n @query('.list-item') protected readonly listItemRoot!: HTMLElement | null;\n\n @queryAssignedElements({slot: 'headline'})\n protected readonly headlineElements!: HTMLElement[];\n @queryAssignedElements({slot: 'supporting-text'})\n protected readonly supportingTextElements!: HTMLElement[];\n @queryAssignedNodes({slot: ''})\n protected readonly defaultElements!: Node[];\n\n /**\n * The text that is selectable via typeahead. If not set, defaults to the\n * innerText of the item slotted into the `\"headline\"` slot.\n */\n get typeaheadText() {\n return this.menuItemController.typeaheadText;\n }\n\n @property({attribute: 'typeahead-text'})\n set typeaheadText(text: string) {\n this.menuItemController.setTypeaheadText(text);\n }\n\n private readonly menuItemController = new MenuItemController(this, {\n getHeadlineElements: () => {\n return this.headlineElements;\n },\n getSupportingTextElements: () => {\n return this.supportingTextElements;\n },\n getDefaultElements: () => {\n return this.defaultElements;\n },\n getInteractiveElement: () => this.listItemRoot,\n });\n\n protected override render() {\n return this.renderListItem(html`\n <md-item>\n <div slot=\"container\">\n ${this.renderRipple()} ${this.renderFocusRing()}\n </div>\n <slot name=\"start\" slot=\"start\"></slot>\n <slot name=\"end\" slot=\"end\"></slot>\n ${this.renderBody()}\n </md-item>\n `);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n const isAnchor = this.type === 'link';\n let tag: StaticValue;\n switch (this.menuItemController.tagName) {\n case 'a':\n tag = literal`a`;\n break;\n case 'button':\n tag = literal`button`;\n break;\n default:\n case 'li':\n tag = literal`li`;\n break;\n }\n\n // TODO(b/265339866): announce \"button\"/\"link\" inside of a list item. Until\n // then all are \"menuitem\" roles for correct announcement.\n const target = isAnchor && !!this.target ? this.target : nothing;\n return staticHtml`\n <${tag}\n id=\"item\"\n tabindex=${this.disabled && !isAnchor ? -1 : 0}\n role=${this.menuItemController.role}\n aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n aria-expanded=${(this as ARIAMixinStrict).ariaExpanded || nothing}\n aria-haspopup=${(this as ARIAMixinStrict).ariaHasPopup || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n href=${this.href || nothing}\n target=${target}\n @click=${this.menuItemController.onClick}\n @keydown=${this.menuItemController.onKeydown}\n >${content}</${tag}>\n `;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n protected renderRipple(): TemplateResult | typeof nothing {\n return html` <md-ripple\n part=\"ripple\"\n for=\"item\"\n ?disabled=${this.disabled}></md-ripple>`;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n protected renderFocusRing(): TemplateResult | typeof nothing {\n return html` <md-focus-ring\n part=\"focus-ring\"\n for=\"item\"\n inward></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses(): ClassInfo {\n return {\n 'disabled': this.disabled,\n 'selected': this.selected,\n };\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n protected renderBody() {\n return html`\n <slot></slot>\n <slot name=\"overline\" slot=\"overline\"></slot>\n <slot name=\"headline\" slot=\"headline\"></slot>\n <slot name=\"supporting-text\" slot=\"supporting-text\"></slot>\n <slot\n name=\"trailing-supporting-text\"\n slot=\"trailing-supporting-text\"></slot>\n `;\n }\n\n override focus() {\n // TODO(b/300334509): needed for some cases where delegatesFocus doesn't\n // work programmatically like in FF and select-option\n this.listItemRoot?.focus();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-menu.js","sourceRoot":"","sources":["sub-menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAElE,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mDAAmD,CAAC;AAE3D,OAAO,EAEL,WAAW,EACX,4BAA4B,EAC5B,8BAA8B,EAC9B,eAAe,EAEf,YAAY,EACZ,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,OAAO,OAAQ,SAAQ,UAAU;IA0BrC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/B,CAAC;IAWD;QACE,KAAK,EAAE,CAAC;QA3CV;;WAEG;QAEH,iBAAY,GAAW,MAAM,CAAC,SAAS,CAAC;QACxC;;WAEG;QACmC,eAAU,GAAW,MAAM,CAAC,WAAW,CAAC;QAC9E;;WAEG;QACsD,mBAAc,GAAG,GAAG,CAAC;QAC9E;;WAEG;QAEH,oBAAe,GAAG,GAAG,CAAC;QAEtB;;WAEG;QAEH,cAAS,GAAG,IAAI,CAAC;QAgBT,wBAAmB,GAAG,CAAC,CAAC;QACxB,yBAAoB,GAAG,CAAC,CAAC;QA4JjC;;;;;;;;WAQG;QACO,iBAAY,GAAG,GAAG,EAAE;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AE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;sCACrB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {\n createDeactivateItemsEvent,\n createRequestActivationEvent,\n deactivateActiveItem,\n getFirstActivatableItem,\n} from '../../../list/internal/list-navigation-helpers.js';\nimport {MenuItem} from '../controllers/menuItemController.js';\nimport {\n CloseMenuEvent,\n CloseReason,\n createActivateTypeaheadEvent,\n createDeactivateTypeaheadEvent,\n KeydownCloseKey,\n Menu,\n NavigableKey,\n SelectionKey,\n} from '../controllers/shared.js';\nimport {Corner} from '../menu.js';\n\n/**\n * @fires deactivate-items {Event} Requests the parent menu to deselect other\n * items when a submenu opens. --bubbles --composed\n * @fires request-activation {Event} Requests the parent to make the slotted item\n * focusable and focus the item. --bubbles --composed\n * @fires deactivate-typeahead {Event} Requests the parent menu to deactivate\n * the typeahead functionality when a submenu opens. --bubbles --composed\n * @fires activate-typeahead {Event} Requests the parent menu to activate the\n * typeahead functionality when a submenu closes. --bubbles --composed\n */\nexport class SubMenu extends LitElement {\n /**\n * The anchorCorner to set on the submenu.\n */\n @property({attribute: 'anchor-corner'})\n anchorCorner: Corner = Corner.START_END;\n /**\n * The menuCorner to set on the submenu.\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = Corner.START_START;\n /**\n * The delay between mouseenter and submenu opening.\n */\n @property({type: Number, attribute: 'hover-open-delay'}) hoverOpenDelay = 400;\n /**\n * The delay between ponterleave and the submenu closing.\n */\n @property({type: Number, attribute: 'hover-close-delay'})\n hoverCloseDelay = 400;\n\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, reflect: true, attribute: 'md-sub-menu'})\n isSubMenu = true;\n\n get item() {\n return this.items[0] ?? null;\n }\n\n get menu() {\n return this.menus[0] ?? null;\n }\n\n @queryAssignedElements({slot: 'item', flatten: true})\n private readonly items!: MenuItem[];\n\n @queryAssignedElements({slot: 'menu', flatten: true})\n private readonly menus!: Menu[];\n\n private previousOpenTimeout = 0;\n private previousCloseTimeout = 0;\n\n constructor() {\n super();\n\n if (!isServer) {\n this.addEventListener('mouseenter', this.onMouseenter);\n this.addEventListener('mouseleave', this.onMouseleave);\n }\n }\n\n override render() {\n return html`\n <slot\n name=\"item\"\n @click=${this.onClick}\n @keydown=${this.onKeydown}\n @slotchange=${this.onSlotchange}>\n </slot>\n <slot\n name=\"menu\"\n @keydown=${this.onSubMenuKeydown}\n @close-menu=${this.onCloseSubmenu}\n @slotchange=${this.onSlotchange}>\n </slot>\n `;\n }\n\n protected override firstUpdated() {\n // slotchange is not fired if the contents have been SSRd\n this.onSlotchange();\n }\n\n /**\n * Shows the submenu.\n */\n async show() {\n const menu = this.menu;\n if (!menu || menu.open) return;\n\n // Ensures that we deselect items when the menu closes and reactivate\n // typeahead when the menu closes, so that we do not have dirty state of\n // `sub-menu > menu-item[selected]` when we reopen.\n //\n // This cannot happen in `close()` because the menu may close via other\n // means Additionally, this cannot happen in onCloseSubmenu because\n // `close-menu` may not be called via focusout of outside click and not\n // triggered by an item\n menu.addEventListener(\n 'closed',\n () => {\n this.item.ariaExpanded = 'false';\n this.dispatchEvent(createActivateTypeaheadEvent());\n this.dispatchEvent(createDeactivateItemsEvent());\n // aria-hidden required so ChromeVox doesn't announce the closed menu\n menu.ariaHidden = 'true';\n },\n {once: true},\n );\n\n // Parent menu is `position: absolute` – this creates a new CSS relative\n // positioning context (similar to doing `position: relative`), so the\n // submenu's `<md-menu slot=\"submenu\" positioning=\"document\">` would be\n // wrong even if we change `md-sub-menu` from `position: relative` to\n // `position: static` because the submenu it would still be positioning\n // itself relative to the parent menu.\n if (menu.positioning === 'document') {\n menu.positioning = 'absolute';\n }\n menu.quick = true;\n // Submenus are in overflow when not fixed. Can remove once we have native\n // popup support\n menu.hasOverflow = true;\n menu.anchorCorner = this.anchorCorner;\n menu.menuCorner = this.menuCorner;\n menu.anchorElement = this.item;\n menu.defaultFocus = 'first-item';\n // aria-hidden management required so ChromeVox doesn't announce the closed\n // menu. Remove it here since we are about to show and focus it.\n menu.removeAttribute('aria-hidden');\n // This is required in the case where we have a leaf menu open and and the\n // user hovers a parent menu's item which is not an md-sub-menu item.\n // If this were set to true, then the menu would close and focus would be\n // lost. That means the focusout event would have a `relatedTarget` of\n // `null` since nothing in the menu would be focused anymore due to the\n // leaf menu closing. restoring focus ensures that we keep focus in the\n // submenu tree.\n menu.skipRestoreFocus = false;\n\n // Menu could already be opened because of mouse interaction\n const menuAlreadyOpen = menu.open;\n menu.show();\n this.item.ariaExpanded = 'true';\n this.item.ariaHasPopup = 'menu';\n if (menu.id) {\n this.item.setAttribute('aria-controls', menu.id);\n }\n\n // Deactivate other items. This can be the case if the user has tabbed\n // around the menu and then mouses over an md-sub-menu.\n this.dispatchEvent(createDeactivateItemsEvent());\n this.dispatchEvent(createDeactivateTypeaheadEvent());\n this.item.selected = true;\n\n // This is the case of mouse hovering when already opened via keyboard or\n // vice versa\n if (!menuAlreadyOpen) {\n let open = (value: unknown) => {};\n const opened = new Promise((resolve) => {\n open = resolve;\n });\n menu.addEventListener('opened', open, {once: true});\n await opened;\n }\n }\n\n /**\n * Closes the submenu.\n */\n async close() {\n const menu = this.menu;\n if (!menu || !menu.open) return;\n\n this.dispatchEvent(createActivateTypeaheadEvent());\n menu.quick = true;\n menu.close();\n this.dispatchEvent(createDeactivateItemsEvent());\n let close = (value: unknown) => {};\n const closed = new Promise((resolve) => {\n close = resolve;\n });\n menu.addEventListener('closed', close, {once: true});\n await closed;\n }\n\n protected onSlotchange() {\n if (!this.item) {\n return;\n }\n\n // TODO(b/301296618): clean up old aria values on change\n this.item.ariaExpanded = 'false';\n this.item.ariaHasPopup = 'menu';\n if (this.menu?.id) {\n this.item.setAttribute('aria-controls', this.menu.id);\n }\n this.item.keepOpen = true;\n\n const menu = this.menu;\n if (!menu) return;\n\n menu.isSubmenu = true;\n // Required for ChromeVox to not linearly navigate to the menu while closed\n menu.ariaHidden = 'true';\n }\n\n /**\n * Starts the default 400ms countdown to open the submenu.\n *\n * NOTE: We explicitly use mouse events and not pointer events because\n * pointer events apply to touch events. And if a user were to tap a\n * sub-menu, it would fire the \"pointerenter\", \"pointerleave\", \"click\" events\n * which would open the menu on click, and then set the timeout to close the\n * menu due to pointerleave.\n */\n protected onMouseenter = () => {\n clearTimeout(this.previousOpenTimeout);\n clearTimeout(this.previousCloseTimeout);\n if (this.menu?.open) return;\n\n // Open synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverOpenDelay) {\n this.show();\n } else {\n this.previousOpenTimeout = setTimeout(() => {\n this.show();\n }, this.hoverOpenDelay);\n }\n };\n\n /**\n * Starts the default 400ms countdown to close the submenu.\n *\n * NOTE: We explicitly use mouse events and not pointer events because\n * pointer events apply to touch events. And if a user were to tap a\n * sub-menu, it would fire the \"pointerenter\", \"pointerleave\", \"click\" events\n * which would open the menu on click, and then set the timeout to close the\n * menu due to pointerleave.\n */\n protected onMouseleave = () => {\n clearTimeout(this.previousCloseTimeout);\n clearTimeout(this.previousOpenTimeout);\n\n // Close synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverCloseDelay) {\n this.close();\n } else {\n this.previousCloseTimeout = setTimeout(() => {\n this.close();\n }, this.hoverCloseDelay);\n }\n };\n\n protected onClick() {\n this.show();\n }\n\n /**\n * On item keydown handles opening the submenu.\n */\n protected async onKeydown(event: KeyboardEvent) {\n const shouldOpenSubmenu = this.isSubmenuOpenKey(event.code);\n\n if (event.defaultPrevented) return;\n\n const openedWithLR =\n shouldOpenSubmenu &&\n (NavigableKey.LEFT === event.code || NavigableKey.RIGHT === event.code);\n\n if (event.code === SelectionKey.SPACE || openedWithLR) {\n // prevent space from scrolling and Left + Right from selecting previous /\n // next items or opening / closing parent menus. Only open the submenu.\n event.preventDefault();\n\n if (openedWithLR) {\n event.stopPropagation();\n }\n }\n\n if (!shouldOpenSubmenu) {\n return;\n }\n\n const submenu = this.menu;\n if (!submenu) return;\n\n const submenuItems = submenu.items;\n const firstActivatableItem = getFirstActivatableItem(submenuItems);\n\n if (firstActivatableItem) {\n await this.show();\n\n firstActivatableItem.tabIndex = 0;\n firstActivatableItem.focus();\n\n return;\n }\n }\n\n private onCloseSubmenu(event: CloseMenuEvent) {\n const {itemPath, reason} = event.detail;\n itemPath.push(this.item);\n\n this.dispatchEvent(createActivateTypeaheadEvent());\n // Escape should only close one menu not all of the menus unlike space or\n // click selection which should close all menus.\n if (\n reason.kind === CloseReason.KEYDOWN &&\n reason.key === KeydownCloseKey.ESCAPE\n ) {\n event.stopPropagation();\n this.item.dispatchEvent(createRequestActivationEvent());\n return;\n }\n\n this.dispatchEvent(createDeactivateItemsEvent());\n }\n\n private async onSubMenuKeydown(event: KeyboardEvent) {\n if (event.defaultPrevented) return;\n const {close: shouldClose, keyCode} = this.isSubmenuCloseKey(event.code);\n if (!shouldClose) return;\n\n // Communicate that it's handled so that we don't accidentally close every\n // parent menu. Additionally, we want to isolate things like the typeahead\n // keydowns from bubbling up to the parent menu and confounding things.\n event.preventDefault();\n\n if (keyCode === NavigableKey.LEFT || keyCode === NavigableKey.RIGHT) {\n // Prevent this from bubbling to parents\n event.stopPropagation();\n }\n\n await this.close();\n\n deactivateActiveItem(this.menu.items);\n this.item?.focus();\n this.item.tabIndex = 0;\n this.item.focus();\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should open\n * the submenu. This is RTL-aware. By default, left, right, space, or enter.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should open the submenu.\n */\n private isSubmenuOpenKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NavigableKey.LEFT : NavigableKey.RIGHT;\n switch (code) {\n case arrowEnterKey:\n case SelectionKey.SPACE:\n case SelectionKey.ENTER:\n return true;\n default:\n return false;\n }\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should close\n * the submenu. This is RTL-aware. By default right, left, or escape.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should close the submenu.\n */\n private isSubmenuCloseKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NavigableKey.RIGHT : NavigableKey.LEFT;\n switch (code) {\n case arrowEnterKey:\n case KeydownCloseKey.ESCAPE:\n return {close: true, keyCode: code} as const;\n default:\n return {close: false} as const;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sub-menu.js","sourceRoot":"","sources":["sub-menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAElE,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,mDAAmD,CAAC;AAE3D,OAAO,EAEL,WAAW,EACX,4BAA4B,EAC5B,8BAA8B,EAC9B,eAAe,EAEf,YAAY,EACZ,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,OAAO,OAAQ,SAAQ,UAAU;IA0BrC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/B,CAAC;IAWD;QACE,KAAK,EAAE,CAAC;QA3CV;;WAEG;QAEH,iBAAY,GAAW,MAAM,CAAC,SAAS,CAAC;QACxC;;WAEG;QACmC,eAAU,GAAW,MAAM,CAAC,WAAW,CAAC;QAC9E;;WAE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,CAAC;2CAAyC;AAIrB;IAAxD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;+CAAsB;AAK9E;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;gDACnC;AAMtB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAC,CAAC;0CAClD;AAWA;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;sCACjB;AAGnB;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;sCACrB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, isServer, LitElement} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {\n createDeactivateItemsEvent,\n createRequestActivationEvent,\n deactivateActiveItem,\n getFirstActivatableItem,\n} from '../../../list/internal/list-navigation-helpers.js';\nimport {MenuItem} from '../controllers/menuItemController.js';\nimport {\n CloseMenuEvent,\n CloseReason,\n createActivateTypeaheadEvent,\n createDeactivateTypeaheadEvent,\n KeydownCloseKey,\n Menu,\n NavigableKey,\n SelectionKey,\n} from '../controllers/shared.js';\nimport {Corner} from '../menu.js';\n\n/**\n * @fires deactivate-items {Event} Requests the parent menu to deselect other\n * items when a submenu opens. --bubbles --composed\n * @fires request-activation {Event} Requests the parent to make the slotted item\n * focusable and focus the item. --bubbles --composed\n * @fires deactivate-typeahead {Event} Requests the parent menu to deactivate\n * the typeahead functionality when a submenu opens. --bubbles --composed\n * @fires activate-typeahead {Event} Requests the parent menu to activate the\n * typeahead functionality when a submenu closes. --bubbles --composed\n */\nexport class SubMenu extends LitElement {\n /**\n * The anchorCorner to set on the submenu.\n */\n @property({attribute: 'anchor-corner'})\n anchorCorner: Corner = Corner.START_END;\n /**\n * The menuCorner to set on the submenu.\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = Corner.START_START;\n /**\n * The delay between mouseenter and submenu opening.\n */\n @property({type: Number, attribute: 'hover-open-delay'}) hoverOpenDelay = 400;\n /**\n * The delay between ponterleave and the submenu closing.\n */\n @property({type: Number, attribute: 'hover-close-delay'})\n hoverCloseDelay = 400;\n\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, reflect: true, attribute: 'md-sub-menu'})\n isSubMenu = true;\n\n get item() {\n return this.items[0] ?? null;\n }\n\n get menu() {\n return this.menus[0] ?? null;\n }\n\n @queryAssignedElements({slot: 'item', flatten: true})\n private readonly items!: MenuItem[];\n\n @queryAssignedElements({slot: 'menu', flatten: true})\n private readonly menus!: Menu[];\n\n private previousOpenTimeout = 0;\n private previousCloseTimeout = 0;\n\n constructor() {\n super();\n\n if (!isServer) {\n this.addEventListener('mouseenter', this.onMouseenter);\n this.addEventListener('mouseleave', this.onMouseleave);\n }\n }\n\n override render() {\n return html`\n <slot\n name=\"item\"\n @click=${this.onClick}\n @keydown=${this.onKeydown}\n @slotchange=${this.onSlotchange}>\n </slot>\n <slot\n name=\"menu\"\n @keydown=${this.onSubMenuKeydown}\n @close-menu=${this.onCloseSubmenu}\n @slotchange=${this.onSlotchange}>\n </slot>\n `;\n }\n\n protected override firstUpdated() {\n // slotchange is not fired if the contents have been SSRd\n this.onSlotchange();\n }\n\n /**\n * Shows the submenu.\n */\n async show() {\n const menu = this.menu;\n if (!menu || menu.open) return;\n\n // Ensures that we deselect items when the menu closes and reactivate\n // typeahead when the menu closes, so that we do not have dirty state of\n // `sub-menu > menu-item[selected]` when we reopen.\n //\n // This cannot happen in `close()` because the menu may close via other\n // means Additionally, this cannot happen in onCloseSubmenu because\n // `close-menu` may not be called via focusout of outside click and not\n // triggered by an item\n menu.addEventListener(\n 'closed',\n () => {\n this.item.ariaExpanded = 'false';\n this.dispatchEvent(createActivateTypeaheadEvent());\n this.dispatchEvent(createDeactivateItemsEvent());\n // aria-hidden required so ChromeVox doesn't announce the closed menu\n menu.ariaHidden = 'true';\n },\n {once: true},\n );\n\n // Parent menu is `position: absolute` – this creates a new CSS relative\n // positioning context (similar to doing `position: relative`), so the\n // submenu's `<md-menu slot=\"submenu\" positioning=\"document\">` would be\n // wrong even if we change `md-sub-menu` from `position: relative` to\n // `position: static` because the submenu it would still be positioning\n // itself relative to the parent menu.\n if (menu.positioning === 'document') {\n menu.positioning = 'absolute';\n }\n menu.quick = true;\n // Submenus are in overflow when not fixed. Can remove once we have native\n // popup support\n menu.hasOverflow = true;\n menu.anchorCorner = this.anchorCorner;\n menu.menuCorner = this.menuCorner;\n menu.anchorElement = this.item;\n menu.defaultFocus = 'first-item';\n // aria-hidden management required so ChromeVox doesn't announce the closed\n // menu. Remove it here since we are about to show and focus it.\n menu.removeAttribute('aria-hidden');\n // This is required in the case where we have a leaf menu open and and the\n // user hovers a parent menu's item which is not an md-sub-menu item.\n // If this were set to true, then the menu would close and focus would be\n // lost. That means the focusout event would have a `relatedTarget` of\n // `null` since nothing in the menu would be focused anymore due to the\n // leaf menu closing. restoring focus ensures that we keep focus in the\n // submenu tree.\n menu.skipRestoreFocus = false;\n\n // Menu could already be opened because of mouse interaction\n const menuAlreadyOpen = menu.open;\n menu.show();\n this.item.ariaExpanded = 'true';\n this.item.ariaHasPopup = 'menu';\n if (menu.id) {\n this.item.setAttribute('aria-controls', menu.id);\n }\n\n // Deactivate other items. This can be the case if the user has tabbed\n // around the menu and then mouses over an md-sub-menu.\n this.dispatchEvent(createDeactivateItemsEvent());\n this.dispatchEvent(createDeactivateTypeaheadEvent());\n this.item.selected = true;\n\n // This is the case of mouse hovering when already opened via keyboard or\n // vice versa\n if (!menuAlreadyOpen) {\n let open = (value: unknown) => {};\n const opened = new Promise((resolve) => {\n open = resolve;\n });\n menu.addEventListener('opened', open, {once: true});\n await opened;\n }\n }\n\n /**\n * Closes the submenu.\n */\n async close() {\n const menu = this.menu;\n if (!menu || !menu.open) return;\n\n this.dispatchEvent(createActivateTypeaheadEvent());\n menu.quick = true;\n menu.close();\n this.dispatchEvent(createDeactivateItemsEvent());\n let close = (value: unknown) => {};\n const closed = new Promise((resolve) => {\n close = resolve;\n });\n menu.addEventListener('closed', close, {once: true});\n await closed;\n }\n\n protected onSlotchange() {\n if (!this.item) {\n return;\n }\n\n // TODO(b/301296618): clean up old aria values on change\n this.item.ariaExpanded = 'false';\n this.item.ariaHasPopup = 'menu';\n if (this.menu?.id) {\n this.item.setAttribute('aria-controls', this.menu.id);\n }\n this.item.keepOpen = true;\n\n const menu = this.menu;\n if (!menu) return;\n\n menu.isSubmenu = true;\n // Required for ChromeVox to not linearly navigate to the menu while closed\n menu.ariaHidden = 'true';\n }\n\n /**\n * Starts the default 400ms countdown to open the submenu.\n *\n * NOTE: We explicitly use mouse events and not pointer events because\n * pointer events apply to touch events. And if a user were to tap a\n * sub-menu, it would fire the \"pointerenter\", \"pointerleave\", \"click\" events\n * which would open the menu on click, and then set the timeout to close the\n * menu due to pointerleave.\n */\n protected onMouseenter = () => {\n clearTimeout(this.previousOpenTimeout);\n clearTimeout(this.previousCloseTimeout);\n if (this.menu?.open) return;\n\n // Open synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverOpenDelay) {\n this.show();\n } else {\n this.previousOpenTimeout = setTimeout(() => {\n this.show();\n }, this.hoverOpenDelay);\n }\n };\n\n /**\n * Starts the default 400ms countdown to close the submenu.\n *\n * NOTE: We explicitly use mouse events and not pointer events because\n * pointer events apply to touch events. And if a user were to tap a\n * sub-menu, it would fire the \"pointerenter\", \"pointerleave\", \"click\" events\n * which would open the menu on click, and then set the timeout to close the\n * menu due to pointerleave.\n */\n protected onMouseleave = () => {\n clearTimeout(this.previousCloseTimeout);\n clearTimeout(this.previousOpenTimeout);\n\n // Close synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverCloseDelay) {\n this.close();\n } else {\n this.previousCloseTimeout = setTimeout(() => {\n this.close();\n }, this.hoverCloseDelay);\n }\n };\n\n protected onClick() {\n this.show();\n }\n\n /**\n * On item keydown handles opening the submenu.\n */\n protected async onKeydown(event: KeyboardEvent) {\n const shouldOpenSubmenu = this.isSubmenuOpenKey(event.code);\n\n if (event.defaultPrevented) return;\n\n const openedWithLR =\n shouldOpenSubmenu &&\n (NavigableKey.LEFT === event.code || NavigableKey.RIGHT === event.code);\n\n if (event.code === SelectionKey.SPACE || openedWithLR) {\n // prevent space from scrolling and Left + Right from selecting previous /\n // next items or opening / closing parent menus. Only open the submenu.\n event.preventDefault();\n\n if (openedWithLR) {\n event.stopPropagation();\n }\n }\n\n if (!shouldOpenSubmenu) {\n return;\n }\n\n const submenu = this.menu;\n if (!submenu) return;\n\n const submenuItems = submenu.items;\n const firstActivatableItem = getFirstActivatableItem(submenuItems);\n\n if (firstActivatableItem) {\n await this.show();\n\n firstActivatableItem.tabIndex = 0;\n firstActivatableItem.focus();\n\n return;\n }\n }\n\n private onCloseSubmenu(event: CloseMenuEvent) {\n const {itemPath, reason} = event.detail;\n itemPath.push(this.item);\n\n this.dispatchEvent(createActivateTypeaheadEvent());\n // Escape should only close one menu not all of the menus unlike space or\n // click selection which should close all menus.\n if (\n reason.kind === CloseReason.KEYDOWN &&\n reason.key === KeydownCloseKey.ESCAPE\n ) {\n event.stopPropagation();\n this.item.dispatchEvent(createRequestActivationEvent());\n return;\n }\n\n this.dispatchEvent(createDeactivateItemsEvent());\n }\n\n private async onSubMenuKeydown(event: KeyboardEvent) {\n if (event.defaultPrevented) return;\n const {close: shouldClose, keyCode} = this.isSubmenuCloseKey(event.code);\n if (!shouldClose) return;\n\n // Communicate that it's handled so that we don't accidentally close every\n // parent menu. Additionally, we want to isolate things like the typeahead\n // keydowns from bubbling up to the parent menu and confounding things.\n event.preventDefault();\n\n if (keyCode === NavigableKey.LEFT || keyCode === NavigableKey.RIGHT) {\n // Prevent this from bubbling to parents\n event.stopPropagation();\n }\n\n await this.close();\n\n deactivateActiveItem(this.menu.items);\n this.item?.focus();\n this.item.tabIndex = 0;\n this.item.focus();\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should open\n * the submenu. This is RTL-aware. By default, left, right, space, or enter.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should open the submenu.\n */\n private isSubmenuOpenKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NavigableKey.LEFT : NavigableKey.RIGHT;\n switch (code) {\n case arrowEnterKey:\n case SelectionKey.SPACE:\n case SelectionKey.ENTER:\n return true;\n default:\n return false;\n }\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should close\n * the submenu. This is RTL-aware. By default right, left, or escape.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should close the submenu.\n */\n private isSubmenuCloseKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NavigableKey.RIGHT : NavigableKey.LEFT;\n switch (code) {\n case arrowEnterKey:\n case KeydownCloseKey.ESCAPE:\n return {close: true, keyCode: code} as const;\n default:\n return {close: false} as const;\n }\n }\n}\n"]}
|
package/menu/menu-item.js
CHANGED
|
@@ -22,10 +22,11 @@ import { styles } from './internal/menuitem/menu-item-styles.js';
|
|
|
22
22
|
* @final
|
|
23
23
|
* @suppress {visibility}
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
let MdMenuItem = class MdMenuItem extends MenuItemEl {
|
|
26
26
|
};
|
|
27
27
|
MdMenuItem.styles = [styles];
|
|
28
28
|
MdMenuItem = __decorate([
|
|
29
29
|
customElement('md-menu-item')
|
|
30
30
|
], MdMenuItem);
|
|
31
|
+
export { MdMenuItem };
|
|
31
32
|
//# sourceMappingURL=menu-item.js.map
|
package/menu/menu-item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAC,MAAM,EAAC,MAAM,yCAAyC,CAAC;AAW/D;;;;;;;;;;;;;;GAcG;AAEI,
|
|
1
|
+
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAC,MAAM,EAAC,MAAM,yCAAyC,CAAC;AAW/D;;;;;;;;;;;;;;GAcG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;;AACxB,iBAAM,GAAwB,CAAC,MAAM,CAAC,AAAhC,CAAiC;AAD5C,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAEtB","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {CSSResultOrNative} from 'lit';\nimport {customElement} from 'lit/decorators.js';\n\nimport {MenuItemEl} from './internal/menuitem/menu-item.js';\nimport {styles} from './internal/menuitem/menu-item-styles.js';\n\nexport {type MenuItem} from './internal/controllers/menuItemController.js';\nexport {type CloseMenuEvent} from './internal/controllers/shared.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-menu-item': MdMenuItem;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menu items are the selectable choices within the menu. Menu items must\n * implement the `MenuItem` interface and also have the `md-menu-item`\n * attribute. Additionally menu items are list items so they must also have the\n * `md-list-item` attribute.\n *\n * Menu items can control a menu by selectively firing the `close-menu` and\n * `deselect-items` events.\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-menu-item')\nexport class MdMenuItem extends MenuItemEl {\n static override styles: CSSResultOrNative[] = [styles];\n}\n"]}
|
package/menu/menu.js
CHANGED
|
@@ -58,10 +58,11 @@ export { Corner } from './internal/menu.js';
|
|
|
58
58
|
* @final
|
|
59
59
|
* @suppress {visibility}
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
let MdMenu = class MdMenu extends Menu {
|
|
62
62
|
};
|
|
63
63
|
MdMenu.styles = [styles];
|
|
64
64
|
MdMenu = __decorate([
|
|
65
65
|
customElement('md-menu')
|
|
66
66
|
], MdMenu);
|
|
67
|
+
export { MdMenu };
|
|
67
68
|
//# sourceMappingURL=menu.js.map
|
package/menu/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AAIjD,OAAO,EACL,UAAU,GAGX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEI,
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AAIjD,OAAO,EACL,UAAU,GAGX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,IAAI;;AACd,aAAM,GAAwB,CAAC,MAAM,CAAC,AAAhC,CAAiC;AAD5C,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAElB","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {CSSResultOrNative} from 'lit';\nimport {customElement} from 'lit/decorators.js';\n\nimport {Menu} from './internal/menu.js';\nimport {styles} from './internal/menu-styles.js';\n\nexport {type ListItem} from '../list/internal/list-navigation-helpers.js';\nexport {type MenuItem} from './internal/controllers/menuItemController.js';\nexport {\n FocusState,\n type CloseMenuEvent,\n type Menu,\n} from './internal/controllers/shared.js';\nexport {Corner} from './internal/menu.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-menu': MdMenu;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menus appear when users interact with a button, action, or other control.\n *\n * They can be opened from a variety of elements, most commonly icon buttons,\n * buttons, and text fields.\n *\n * md-menu listens for the `close-menu` and `deselect-items` events.\n *\n * - `close-menu` closes the menu when dispatched from a child element.\n * - `deselect-items` deselects all of its immediate menu-item children.\n *\n * @example\n * ```html\n * <div style=\"position:relative;\">\n * <button\n * id=\"anchor\"\n * @click=${() => this.menuRef.value.show()}>\n * Click to open menu\n * </button>\n * <!--\n * `has-overflow` is required when using a submenu which overflows the\n * menu's contents.\n *\n * Additionally, `anchor` ingests an idref which do not pass through shadow\n * roots. You can also set `.anchorElement` to an element reference if\n * necessary.\n * -->\n * <md-menu anchor=\"anchor\" has-overflow ${ref(menuRef)}>\n * <md-menu-item headline=\"This is a headline\"></md-menu-item>\n * <md-sub-menu>\n * <md-menu-item\n * slot=\"item\"\n * headline=\"this is a submenu item\">\n * </md-menu-item>\n * <md-menu slot=\"menu\">\n * <md-menu-item headline=\"This is an item inside a submenu\">\n * </md-menu-item>\n * </md-menu>\n * </md-sub-menu>\n * </md-menu>\n * </div>\n * ```\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-menu')\nexport class MdMenu extends Menu {\n static override styles: CSSResultOrNative[] = [styles];\n}\n"]}
|
package/menu/sub-menu.js
CHANGED
|
@@ -55,10 +55,11 @@ import { styles } from './internal/submenu/sub-menu-styles.js';
|
|
|
55
55
|
* @final
|
|
56
56
|
* @suppress {visibility}
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
let MdSubMenu = class MdSubMenu extends SubMenu {
|
|
59
59
|
};
|
|
60
60
|
MdSubMenu.styles = [styles];
|
|
61
61
|
MdSubMenu = __decorate([
|
|
62
62
|
customElement('md-sub-menu')
|
|
63
63
|
], MdSubMenu);
|
|
64
|
+
export { MdSubMenu };
|
|
64
65
|
//# sourceMappingURL=sub-menu.js.map
|