@material/web 1.0.0 → 1.0.2-nightly.6a1fb38.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/all.d.ts +2 -0
- package/all.js +2 -0
- package/all.js.map +1 -1
- package/button/elevated-button.js +5 -1
- package/button/elevated-button.js.map +1 -1
- package/button/internal/_elevation.scss +32 -32
- package/button/internal/_icon.scss +22 -23
- package/button/internal/_outlined-button.scss +21 -19
- package/button/internal/_shared.scss +84 -77
- package/button/internal/_touch-target.scss +4 -0
- package/button/internal/button.d.ts +7 -11
- package/button/internal/button.js +52 -38
- package/button/internal/button.js.map +1 -1
- package/button/internal/elevated-button.d.ts +1 -1
- package/button/internal/elevated-button.js +1 -1
- package/button/internal/elevated-button.js.map +1 -1
- package/button/internal/filled-button.d.ts +1 -1
- package/button/internal/filled-button.js +1 -1
- package/button/internal/filled-button.js.map +1 -1
- package/button/internal/filled-tonal-button.d.ts +1 -1
- package/button/internal/filled-tonal-button.js +1 -1
- package/button/internal/filled-tonal-button.js.map +1 -1
- package/button/internal/outlined-button.d.ts +1 -1
- package/button/internal/outlined-button.js +2 -2
- package/button/internal/outlined-button.js.map +1 -1
- package/button/internal/outlined-styles.css.js +1 -1
- package/button/internal/outlined-styles.css.js.map +1 -1
- package/button/internal/shared-elevation-styles.css.js +1 -1
- package/button/internal/shared-elevation-styles.css.js.map +1 -1
- package/button/internal/shared-styles.css.js +1 -1
- package/button/internal/shared-styles.css.js.map +1 -1
- package/checkbox/internal/_checkbox.scss +6 -0
- package/checkbox/internal/checkbox-styles.css.js +1 -1
- package/checkbox/internal/checkbox-styles.css.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +16 -23
- package/checkbox/internal/checkbox.js +38 -52
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/filter-chip.js +5 -1
- package/chips/filter-chip.js.map +1 -1
- package/chips/harness.js.map +1 -1
- package/chips/input-chip.js +6 -1
- package/chips/input-chip.js.map +1 -1
- package/chips/internal/assist-chip.js +8 -4
- package/chips/internal/assist-chip.js.map +1 -1
- package/chips/internal/chip-set.js +6 -4
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.d.ts +3 -0
- package/chips/internal/chip.js +7 -5
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.d.ts +2 -0
- package/chips/internal/filter-chip.js +11 -5
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/input-chip.d.ts +2 -0
- package/chips/internal/input-chip.js +10 -4
- package/chips/internal/input-chip.js.map +1 -1
- package/chips/internal/multi-action-chip.js.map +1 -1
- package/chips/internal/trailing-icons.d.ts +1 -1
- package/chips/internal/trailing-icons.js +6 -5
- package/chips/internal/trailing-icons.js.map +1 -1
- package/common.d.ts +2 -0
- package/common.js +2 -0
- package/common.js.map +1 -1
- package/dialog/harness.js +1 -2
- package/dialog/harness.js.map +1 -1
- package/dialog/internal/_dialog.scss +1 -1
- package/dialog/internal/animations.js +14 -12
- package/dialog/internal/animations.js.map +1 -1
- package/dialog/internal/dialog-styles.css.js +1 -1
- package/dialog/internal/dialog-styles.css.js.map +1 -1
- package/dialog/internal/dialog.d.ts +6 -6
- package/dialog/internal/dialog.js +24 -24
- package/dialog/internal/dialog.js.map +1 -1
- package/fab/harness.js.map +1 -1
- package/fab/internal/_fab.scss +4 -0
- package/fab/internal/fab-styles.css.js +1 -1
- package/fab/internal/fab-styles.css.js.map +1 -1
- package/fab/internal/fab.js.map +1 -1
- package/fab/internal/shared.js +10 -11
- package/fab/internal/shared.js.map +1 -1
- package/field/harness.js.map +1 -1
- package/field/internal/_content.scss +185 -174
- package/field/internal/_filled-field.scss +147 -135
- package/field/internal/_label.scss +83 -72
- package/field/internal/_outlined-field.scss +276 -261
- package/field/internal/_supporting-text.scss +53 -42
- package/field/internal/field.js +26 -22
- package/field/internal/field.js.map +1 -1
- package/field/internal/filled-styles.css.js +1 -1
- package/field/internal/filled-styles.css.js.map +1 -1
- package/field/internal/outlined-styles.css.js +1 -1
- package/field/internal/outlined-styles.css.js.map +1 -1
- package/field/internal/shared-styles.css.js +1 -1
- package/field/internal/shared-styles.css.js.map +1 -1
- package/focus/internal/focus-ring.d.ts +2 -0
- package/focus/internal/focus-ring.js +3 -3
- package/focus/internal/focus-ring.js.map +1 -1
- package/icon/internal/_icon.scss +7 -4
- package/icon/internal/icon-styles.css.js +1 -1
- package/icon/internal/icon-styles.css.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +9 -4
- package/iconbutton/internal/icon-button.js +35 -22
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +4 -26
- package/internal/aria/aria.js +10 -28
- package/internal/aria/aria.js.map +1 -1
- package/internal/aria/delegate.js +2 -2
- package/internal/aria/delegate.js.map +1 -1
- package/internal/controller/attachable-controller.js +3 -5
- package/internal/controller/attachable-controller.js.map +1 -1
- package/internal/controller/form-submitter.d.ts +3 -5
- package/internal/controller/form-submitter.js +5 -7
- package/internal/controller/form-submitter.js.map +1 -1
- package/internal/controller/is-rtl.js +2 -2
- package/internal/controller/is-rtl.js.map +1 -1
- package/internal/controller/string-converter.js +1 -1
- package/internal/controller/string-converter.js.map +1 -1
- package/internal/motion/animation.js.map +1 -1
- package/labs/behaviors/element-internals.d.ts +45 -0
- package/labs/behaviors/element-internals.js +50 -0
- package/labs/behaviors/element-internals.js.map +1 -0
- package/labs/behaviors/focusable.d.ts +39 -0
- package/labs/behaviors/focusable.js +82 -0
- package/labs/behaviors/focusable.js.map +1 -0
- package/labs/behaviors/form-associated.d.ts +199 -0
- package/labs/behaviors/form-associated.js +155 -0
- package/labs/behaviors/form-associated.js.map +1 -0
- package/labs/behaviors/mixin.d.ts +54 -0
- package/labs/behaviors/mixin.js +7 -0
- package/labs/behaviors/mixin.js.map +1 -0
- package/labs/card/_elevated-card.scss +6 -0
- package/labs/card/_filled-card.scss +6 -0
- package/labs/card/_outlined-card.scss +6 -0
- package/labs/card/elevated-card.d.ts +18 -0
- package/labs/card/elevated-card.js +21 -0
- package/labs/card/elevated-card.js.map +1 -0
- package/labs/card/filled-card.d.ts +18 -0
- package/labs/card/filled-card.js +21 -0
- package/labs/card/filled-card.js.map +1 -0
- package/labs/card/internal/_elevated-card.scss +35 -0
- package/labs/card/internal/_filled-card.scss +35 -0
- package/labs/card/internal/_outlined-card.scss +39 -0
- package/labs/card/internal/_shared.scss +40 -0
- package/labs/card/internal/card.d.ts +13 -0
- package/labs/card/internal/card.js +20 -0
- package/labs/card/internal/card.js.map +1 -0
- package/labs/card/internal/elevated-styles.css.js +9 -0
- package/labs/card/internal/elevated-styles.css.js.map +1 -0
- package/labs/card/internal/elevated-styles.scss +10 -0
- package/labs/card/internal/filled-styles.css.js +9 -0
- package/labs/card/internal/filled-styles.css.js.map +1 -0
- package/labs/card/internal/filled-styles.scss +10 -0
- package/labs/card/internal/outlined-styles.css.js +9 -0
- package/labs/card/internal/outlined-styles.css.js.map +1 -0
- package/labs/card/internal/outlined-styles.scss +10 -0
- package/labs/card/internal/shared-styles.css.js +9 -0
- package/labs/card/internal/shared-styles.css.js.map +1 -0
- package/labs/card/internal/shared-styles.scss +10 -0
- package/labs/card/outlined-card.d.ts +18 -0
- package/labs/card/outlined-card.js +21 -0
- package/labs/card/outlined-card.js.map +1 -0
- package/labs/item/internal/_item.scss +1 -1
- package/labs/item/internal/item-styles.css.js +1 -1
- package/labs/item/internal/item-styles.css.js.map +1 -1
- package/labs/item/internal/item.js +8 -8
- package/labs/item/internal/item.js.map +1 -1
- package/labs/navigationbar/internal/constants.js.map +1 -1
- package/labs/navigationbar/internal/navigation-bar.d.ts +3 -0
- package/labs/navigationbar/internal/navigation-bar.js +18 -11
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js +10 -3
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer.js +8 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/harness.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.d.ts +6 -0
- package/labs/navigationtab/internal/navigation-tab.js +43 -27
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/navigationtab/internal/state.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.d.ts +3 -0
- package/labs/segmentedbutton/internal/segmented-button.js +26 -12
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.d.ts +5 -0
- package/labs/segmentedbuttonset/internal/segmented-button-set.js +14 -9
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/list/harness.d.ts +3 -2
- package/list/harness.js.map +1 -1
- package/list/internal/list-controller.d.ts +1 -1
- package/list/internal/list-controller.js +7 -3
- package/list/internal/list-controller.js.map +1 -1
- package/list/internal/list-navigation-helpers.js.map +1 -1
- package/list/internal/list.d.ts +2 -2
- package/list/internal/list.js +8 -6
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/_list-item.scss +18 -0
- package/list/internal/listitem/harness.d.ts +3 -3
- package/list/internal/listitem/harness.js.map +1 -1
- package/list/internal/listitem/list-item-styles.css.js +1 -1
- package/list/internal/listitem/list-item-styles.css.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +3 -2
- package/list/internal/listitem/list-item.js +20 -21
- package/list/internal/listitem/list-item.js.map +1 -1
- package/list/list-item.d.ts +4 -12
- package/list/list-item.js +5 -14
- package/list/list-item.js.map +1 -1
- package/menu/harness.js.map +1 -1
- package/menu/internal/_menu.scss +20 -1
- package/menu/internal/controllers/menuItemController.d.ts +7 -0
- package/menu/internal/controllers/menuItemController.js +17 -4
- package/menu/internal/controllers/menuItemController.js.map +1 -1
- package/menu/internal/controllers/shared.d.ts +9 -1
- package/menu/internal/controllers/shared.js +4 -4
- package/menu/internal/controllers/shared.js.map +1 -1
- package/menu/internal/controllers/surfacePositionController.d.ts +15 -2
- package/menu/internal/controllers/surfacePositionController.js +134 -56
- package/menu/internal/controllers/surfacePositionController.js.map +1 -1
- package/menu/internal/controllers/typeaheadController.js +19 -14
- package/menu/internal/controllers/typeaheadController.js.map +1 -1
- package/menu/internal/menu-styles.css.js +1 -1
- package/menu/internal/menu-styles.css.js.map +1 -1
- package/menu/internal/menu.d.ts +55 -17
- package/menu/internal/menu.js +175 -88
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/_menu-item.scss +24 -0
- package/menu/internal/menuitem/harness.d.ts +3 -1
- package/menu/internal/menuitem/harness.js.map +1 -1
- package/menu/internal/menuitem/menu-item-styles.css.js +1 -1
- package/menu/internal/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +3 -2
- package/menu/internal/menuitem/menu-item.js +20 -20
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/menu/internal/submenu/sub-menu.d.ts +9 -8
- package/menu/internal/submenu/sub-menu.js +35 -22
- package/menu/internal/submenu/sub-menu.js.map +1 -1
- package/menu/internal/types.js.map +1 -1
- package/menu/menu-item.js +1 -2
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.js +1 -2
- package/menu/menu.js.map +1 -1
- package/package.json +1 -1
- package/progress/internal/_circular-progress.scss +2 -2
- package/progress/internal/_linear-progress.scss +1 -1
- package/progress/internal/circular-progress-styles.css.js +1 -1
- package/progress/internal/circular-progress-styles.css.js.map +1 -1
- package/progress/internal/circular-progress.js +11 -10
- package/progress/internal/circular-progress.js.map +1 -1
- package/progress/internal/linear-progress-styles.css.js +1 -1
- package/progress/internal/linear-progress-styles.css.js.map +1 -1
- package/progress/internal/linear-progress.d.ts +1 -1
- package/progress/internal/linear-progress.js +3 -3
- package/progress/internal/linear-progress.js.map +1 -1
- package/progress/internal/progress.js +4 -2
- package/progress/internal/progress.js.map +1 -1
- package/radio/internal/_radio.scss +144 -123
- package/radio/internal/radio-styles.css.js +1 -1
- package/radio/internal/radio-styles.css.js.map +1 -1
- package/radio/internal/radio.d.ts +12 -23
- package/radio/internal/radio.js +31 -50
- package/radio/internal/radio.js.map +1 -1
- package/radio/internal/single-selection-controller.js +1 -1
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/radio/radio.js +1 -2
- package/radio/radio.js.map +1 -1
- package/ripple/internal/ripple.js +21 -18
- package/ripple/internal/ripple.js.map +1 -1
- package/select/filled-select.js +1 -2
- package/select/filled-select.js.map +1 -1
- package/select/harness.js +1 -1
- package/select/harness.js.map +1 -1
- package/select/internal/_shared.scss +4 -0
- package/select/internal/select.d.ts +25 -34
- package/select/internal/select.js +101 -91
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +8 -6
- package/select/internal/selectoption/select-option.js +25 -23
- package/select/internal/selectoption/select-option.js.map +1 -1
- package/select/internal/selectoption/selectOptionController.js +1 -1
- package/select/internal/selectoption/selectOptionController.js.map +1 -1
- package/select/internal/shared-styles.css.js +1 -1
- package/select/internal/shared-styles.css.js.map +1 -1
- package/select/outlined-select.js +1 -2
- package/select/outlined-select.js.map +1 -1
- package/select/select-option.js +1 -2
- package/select/select-option.js.map +1 -1
- package/slider/harness.js +5 -5
- package/slider/harness.js.map +1 -1
- package/slider/internal/_slider.scss +68 -30
- package/slider/internal/slider-styles.css.js +1 -1
- package/slider/internal/slider-styles.css.js.map +1 -1
- package/slider/internal/slider.d.ts +16 -25
- package/slider/internal/slider.js +111 -115
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/_handle.scss +159 -141
- package/switch/internal/_icon.scss +95 -72
- package/switch/internal/_switch.scss +90 -95
- package/switch/internal/_track.scss +110 -77
- package/switch/internal/switch-styles.css.js +1 -1
- package/switch/internal/switch-styles.css.js.map +1 -1
- package/switch/internal/switch.d.ts +9 -25
- package/switch/internal/switch.js +31 -57
- package/switch/internal/switch.js.map +1 -1
- package/switch/switch.js +1 -2
- package/switch/switch.js.map +1 -1
- package/tabs/harness.js +3 -3
- package/tabs/harness.js.map +1 -1
- package/tabs/internal/_tab.scss +27 -35
- package/tabs/internal/primary-tab.d.ts +0 -2
- package/tabs/internal/tab-styles.css.js +1 -1
- package/tabs/internal/tab-styles.css.js.map +1 -1
- package/tabs/internal/tab.d.ts +10 -5
- package/tabs/internal/tab.js +43 -22
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.d.ts +7 -4
- package/tabs/internal/tabs.js +23 -22
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/filled-text-field.js +1 -2
- package/textfield/filled-text-field.js.map +1 -1
- package/textfield/harness.js +3 -2
- package/textfield/harness.js.map +1 -1
- package/textfield/internal/text-field.d.ts +33 -18
- package/textfield/internal/text-field.js +96 -58
- package/textfield/internal/text-field.js.map +1 -1
- package/textfield/outlined-text-field.js +1 -2
- package/textfield/outlined-text-field.js.map +1 -1
- package/tokens/_index.scss +3 -0
- package/tokens/_md-comp-elevated-card.scss +63 -0
- package/tokens/_md-comp-filled-card.scss +63 -0
- package/tokens/_md-comp-icon.scss +2 -0
- package/tokens/_md-comp-outlined-card.scss +69 -0
- package/tokens/_md-comp-test-table.scss +1 -0
- package/internal/controller/element-internals.d.ts +0 -35
- package/internal/controller/element-internals.js +0 -24
- package/internal/controller/element-internals.js.map +0 -1
- package/list/internal/listitem/forced-colors-styles.css.js +0 -9
- package/list/internal/listitem/forced-colors-styles.css.js.map +0 -1
- package/list/internal/listitem/forced-colors-styles.scss +0 -19
- package/menu/internal/forced-colors-styles.css.js +0 -9
- package/menu/internal/forced-colors-styles.css.js.map +0 -1
- package/menu/internal/forced-colors-styles.scss +0 -12
- package/menu/internal/menuitem/forced-colors-styles.css.js +0 -9
- package/menu/internal/menuitem/forced-colors-styles.css.js.map +0 -1
- package/menu/internal/menuitem/forced-colors-styles.scss +0 -26
- package/radio/internal/forced-colors-styles.css.js +0 -9
- package/radio/internal/forced-colors-styles.css.js.map +0 -1
- package/radio/internal/forced-colors-styles.scss +0 -29
- package/select/internal/filled-forced-colors-styles.css.d.ts +0 -1
- package/select/internal/filled-forced-colors-styles.css.js +0 -9
- package/select/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/select/internal/filled-forced-colors-styles.scss +0 -29
- package/select/internal/outlined-forced-colors-styles.css.d.ts +0 -1
- package/select/internal/outlined-forced-colors-styles.css.js +0 -9
- package/select/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/select/internal/outlined-forced-colors-styles.scss +0 -29
- package/switch/internal/forced-colors-styles.css.d.ts +0 -1
- package/switch/internal/forced-colors-styles.css.js +0 -9
- package/switch/internal/forced-colors-styles.css.js.map +0 -1
- package/switch/internal/forced-colors-styles.scss +0 -42
- package/textfield/internal/filled-forced-colors-styles.css.d.ts +0 -1
- package/textfield/internal/filled-forced-colors-styles.css.js +0 -9
- package/textfield/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/filled-forced-colors-styles.scss +0 -29
- package/textfield/internal/outlined-forced-colors-styles.css.d.ts +0 -1
- package/textfield/internal/outlined-forced-colors-styles.css.js +0 -9
- package/textfield/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/outlined-forced-colors-styles.scss +0 -29
- /package/{list/internal/listitem/forced-colors-styles.css.d.ts → labs/card/internal/elevated-styles.css.d.ts} +0 -0
- /package/{menu/internal/forced-colors-styles.css.d.ts → labs/card/internal/filled-styles.css.d.ts} +0 -0
- /package/{menu/internal/menuitem/forced-colors-styles.css.d.ts → labs/card/internal/outlined-styles.css.d.ts} +0 -0
- /package/{radio/internal/forced-colors-styles.css.d.ts → labs/card/internal/shared-styles.css.d.ts} +0 -0
package/menu/internal/menu.js
CHANGED
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
|
-
import '../../focus/md-focus-ring.js';
|
|
8
7
|
import '../../elevation/elevation.js';
|
|
9
|
-
import
|
|
8
|
+
import '../../focus/md-focus-ring.js';
|
|
9
|
+
import { LitElement, html, isServer, nothing } from 'lit';
|
|
10
10
|
import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
|
|
11
11
|
import { classMap } from 'lit/directives/class-map.js';
|
|
12
12
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
13
|
-
import { polyfillElementInternalsAria,
|
|
14
|
-
import {
|
|
15
|
-
import { ListController, NavigableKeys } from '../../list/internal/list-controller.js';
|
|
16
|
-
import { getActiveItem, getFirstActivatableItem, getLastActivatableItem } from '../../list/internal/list-navigation-helpers.js';
|
|
17
|
-
import { FocusState, isClosableKey, isElementInSubtree } from './controllers/shared.js';
|
|
18
|
-
import { Corner, SurfacePositionController } from './controllers/surfacePositionController.js';
|
|
13
|
+
import { polyfillARIAMixin, polyfillElementInternalsAria, } from '../../internal/aria/aria.js';
|
|
14
|
+
import { EASING, createAnimationSignal } from '../../internal/motion/animation.js';
|
|
15
|
+
import { ListController, NavigableKeys, } from '../../list/internal/list-controller.js';
|
|
16
|
+
import { getActiveItem, getFirstActivatableItem, getLastActivatableItem, } from '../../list/internal/list-navigation-helpers.js';
|
|
17
|
+
import { FocusState, isClosableKey, isElementInSubtree, } from './controllers/shared.js';
|
|
18
|
+
import { Corner, SurfacePositionController, } from './controllers/surfacePositionController.js';
|
|
19
19
|
import { TypeaheadController } from './controllers/typeaheadController.js';
|
|
20
20
|
export { Corner } from './controllers/surfacePositionController.js';
|
|
21
21
|
/**
|
|
@@ -50,10 +50,10 @@ function getFocusedElement(activeDoc = document) {
|
|
|
50
50
|
return activeEl;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* @fires opening Fired before the opening animation begins
|
|
54
|
-
* @fires opened Fired once the menu is open, after any animations
|
|
55
|
-
* @fires closing Fired before the closing animation begins
|
|
56
|
-
* @fires closed Fired once the menu is closed, after any animations
|
|
53
|
+
* @fires opening {Event} Fired before the opening animation begins
|
|
54
|
+
* @fires opened {Event} Fired once the menu is open, after any animations
|
|
55
|
+
* @fires closing {Event} Fired before the closing animation begins
|
|
56
|
+
* @fires closed {Event} Fired once the menu is closed, after any animations
|
|
57
57
|
*/
|
|
58
58
|
export class Menu extends LitElement {
|
|
59
59
|
/**
|
|
@@ -61,8 +61,8 @@ export class Menu extends LitElement {
|
|
|
61
61
|
* helpful for calculating some animation calculations.
|
|
62
62
|
*/
|
|
63
63
|
get openDirection() {
|
|
64
|
-
const menuCornerBlock = this.menuCorner.split('
|
|
65
|
-
return menuCornerBlock === '
|
|
64
|
+
const menuCornerBlock = this.menuCorner.split('-')[0];
|
|
65
|
+
return menuCornerBlock === 'start' ? 'DOWN' : 'UP';
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* The element which the menu should align to. If `anchor` is set to a
|
|
@@ -71,8 +71,7 @@ export class Menu extends LitElement {
|
|
|
71
71
|
*/
|
|
72
72
|
get anchorElement() {
|
|
73
73
|
if (this.anchor) {
|
|
74
|
-
return this.getRootNode()
|
|
75
|
-
.querySelector(`#${this.anchor}`);
|
|
74
|
+
return this.getRootNode().querySelector(`#${this.anchor}`);
|
|
76
75
|
}
|
|
77
76
|
return this.currentAnchorElement;
|
|
78
77
|
}
|
|
@@ -92,9 +91,12 @@ export class Menu extends LitElement {
|
|
|
92
91
|
this.anchor = '';
|
|
93
92
|
/**
|
|
94
93
|
* Whether the positioning algorithim should calculate relative to the parent
|
|
95
|
-
* of the anchor element (absolute)
|
|
94
|
+
* of the anchor element (`absolute`), relative to the window (`fixed`), or
|
|
95
|
+
* relative to the document (`document`). `popover` will use the popover API
|
|
96
|
+
* to render the menu in the top-layer. If your browser does not support the
|
|
97
|
+
* popover API, it will fall back to `fixed`.
|
|
96
98
|
*
|
|
97
|
-
*
|
|
99
|
+
* __Examples for `position = 'fixed'`:__
|
|
98
100
|
*
|
|
99
101
|
* - If there is no `position:relative` in the given parent tree and the
|
|
100
102
|
* surface is `position:absolute`
|
|
@@ -103,12 +105,27 @@ export class Menu extends LitElement {
|
|
|
103
105
|
* - The anchor and the surface do not share a common `position:relative`
|
|
104
106
|
* ancestor
|
|
105
107
|
*
|
|
106
|
-
* When using positioning
|
|
108
|
+
* When using `positioning=fixed`, in most cases, the menu should position
|
|
107
109
|
* itself above most other `position:absolute` or `position:fixed` elements
|
|
108
110
|
* when placed inside of them. e.g. using a menu inside of an `md-dialog`.
|
|
109
111
|
*
|
|
110
112
|
* __NOTE__: Fixed menus will not scroll with the page and will be fixed to
|
|
111
113
|
* the window instead.
|
|
114
|
+
*
|
|
115
|
+
* __Examples for `position = 'document'`:__
|
|
116
|
+
*
|
|
117
|
+
* - There is no parent that creates a relative positioning context e.g.
|
|
118
|
+
* `position: relative`, `position: absolute`, `transform: translate(x, y)`,
|
|
119
|
+
* etc.
|
|
120
|
+
* - You put the effort into hoisting the menu to the top of the DOM like the
|
|
121
|
+
* end of the `<body>` to render over everything or in a top-layer.
|
|
122
|
+
* - You are reusing a single `md-menu` element that dynamically renders
|
|
123
|
+
* content.
|
|
124
|
+
*
|
|
125
|
+
* __Examples for `position = 'popover'`:__
|
|
126
|
+
*
|
|
127
|
+
* - Your browser supports `popover`.
|
|
128
|
+
* - Most cases. Once popover is in browsers, this will become the default.
|
|
112
129
|
*/
|
|
113
130
|
this.positioning = 'absolute';
|
|
114
131
|
/**
|
|
@@ -116,7 +133,8 @@ export class Menu extends LitElement {
|
|
|
116
133
|
*/
|
|
117
134
|
this.quick = false;
|
|
118
135
|
/**
|
|
119
|
-
* Displays overflow content like a submenu.
|
|
136
|
+
* Displays overflow content like a submenu. Not required in most cases when
|
|
137
|
+
* using `positioning="popover"`.
|
|
120
138
|
*
|
|
121
139
|
* __NOTE__: This may cause adverse effects if you set
|
|
122
140
|
* `md-menu {max-height:...}`
|
|
@@ -204,14 +222,17 @@ export class Menu extends LitElement {
|
|
|
204
222
|
* The event path of the last window pointerdown event.
|
|
205
223
|
*/
|
|
206
224
|
this.pointerPath = [];
|
|
207
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Whether or not the menu is repositoining due to window / document resize
|
|
227
|
+
*/
|
|
228
|
+
this.isRepositioning = false;
|
|
208
229
|
this.openCloseAnimationSignal = createAnimationSignal();
|
|
209
230
|
this.listController = new ListController({
|
|
210
231
|
isItem: (maybeItem) => {
|
|
211
232
|
return maybeItem.hasAttribute('md-menu-item');
|
|
212
233
|
},
|
|
213
234
|
getPossibleItems: () => this.slotItems,
|
|
214
|
-
isRtl: () =>
|
|
235
|
+
isRtl: () => getComputedStyle(this).direction === 'rtl',
|
|
215
236
|
deactivateItem: (item) => {
|
|
216
237
|
item.selected = false;
|
|
217
238
|
item.tabIndex = -1;
|
|
@@ -229,7 +250,9 @@ export class Menu extends LitElement {
|
|
|
229
250
|
// key so it can close the menu instead of navigate the list.
|
|
230
251
|
// Therefore we need to include all keys but left/right arrow close
|
|
231
252
|
// key
|
|
232
|
-
const arrowOpen = isRtl
|
|
253
|
+
const arrowOpen = isRtl
|
|
254
|
+
? NavigableKeys.ArrowLeft
|
|
255
|
+
: NavigableKeys.ArrowRight;
|
|
233
256
|
if (key === arrowOpen) {
|
|
234
257
|
return true;
|
|
235
258
|
}
|
|
@@ -247,11 +270,13 @@ export class Menu extends LitElement {
|
|
|
247
270
|
return {
|
|
248
271
|
getItems: () => this.items,
|
|
249
272
|
typeaheadBufferTime: this.typeaheadDelay,
|
|
250
|
-
active: this.typeaheadActive
|
|
273
|
+
active: this.typeaheadActive,
|
|
251
274
|
};
|
|
252
275
|
});
|
|
253
276
|
this.currentAnchorElement = null;
|
|
254
|
-
this.internals = polyfillElementInternalsAria(this,
|
|
277
|
+
this.internals = polyfillElementInternalsAria(this,
|
|
278
|
+
// Cast needed for closure
|
|
279
|
+
this.attachInternals());
|
|
255
280
|
/**
|
|
256
281
|
* Handles positioning the surface and aligning it to the anchor as well as
|
|
257
282
|
* keeping it in the viewport.
|
|
@@ -262,7 +287,7 @@ export class Menu extends LitElement {
|
|
|
262
287
|
surfaceCorner: this.menuCorner,
|
|
263
288
|
surfaceEl: this.surfaceEl,
|
|
264
289
|
anchorEl: this.anchorElement,
|
|
265
|
-
positioning: this.positioning,
|
|
290
|
+
positioning: this.positioning === 'popover' ? 'document' : this.positioning,
|
|
266
291
|
isOpen: this.open,
|
|
267
292
|
xOffset: this.xOffset,
|
|
268
293
|
yOffset: this.yOffset,
|
|
@@ -271,28 +296,44 @@ export class Menu extends LitElement {
|
|
|
271
296
|
onClose: this.onClosed,
|
|
272
297
|
// We can't resize components that have overflow like menus with
|
|
273
298
|
// submenus because the overflow-y will show menu items / content
|
|
274
|
-
// outside the bounds of the menu.
|
|
275
|
-
|
|
299
|
+
// outside the bounds of the menu. Popover API fixes this because each
|
|
300
|
+
// submenu is hoisted to the top-layer and are not considered overflow
|
|
301
|
+
// content.
|
|
302
|
+
repositionStrategy: this.hasOverflow && this.positioning !== 'popover'
|
|
303
|
+
? 'move'
|
|
304
|
+
: 'resize',
|
|
276
305
|
};
|
|
277
306
|
});
|
|
307
|
+
this.onWindowResize = () => {
|
|
308
|
+
if (this.isRepositioning ||
|
|
309
|
+
(this.positioning !== 'document' &&
|
|
310
|
+
this.positioning !== 'fixed' &&
|
|
311
|
+
this.positioning !== 'popover')) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
this.isRepositioning = true;
|
|
315
|
+
this.reposition();
|
|
316
|
+
this.isRepositioning = false;
|
|
317
|
+
};
|
|
278
318
|
this.handleFocusout = async (event) => {
|
|
279
|
-
|
|
319
|
+
const anchorEl = this.anchorElement;
|
|
320
|
+
// Do not close if we focused out by clicking on the anchor element. We
|
|
321
|
+
// can't assume anchor buttons can be the related target because of iOS does
|
|
322
|
+
// not focus buttons.
|
|
323
|
+
if (this.stayOpenOnFocusout ||
|
|
324
|
+
!this.open ||
|
|
325
|
+
this.pointerPath.includes(anchorEl)) {
|
|
280
326
|
return;
|
|
281
327
|
}
|
|
282
328
|
if (event.relatedTarget) {
|
|
283
329
|
// Don't close the menu if we are switching focus between menu,
|
|
284
|
-
// md-menu-item, and md-list
|
|
285
|
-
if (isElementInSubtree(event.relatedTarget, this)
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
const anchorEl = this.anchorElement;
|
|
289
|
-
const wasAnchorClickFocused = isElementInSubtree(event.relatedTarget, anchorEl) &&
|
|
290
|
-
this.isPointerDown;
|
|
291
|
-
if (wasAnchorClickFocused) {
|
|
330
|
+
// md-menu-item, and md-list or if the anchor was click focused.
|
|
331
|
+
if (isElementInSubtree(event.relatedTarget, this) ||
|
|
332
|
+
isElementInSubtree(event.relatedTarget, anchorEl)) {
|
|
292
333
|
return;
|
|
293
334
|
}
|
|
294
335
|
}
|
|
295
|
-
else if (this.
|
|
336
|
+
else if (this.pointerPath.includes(this)) {
|
|
296
337
|
// If menu tabindex == -1 and the user clicks on the menu or a divider, we
|
|
297
338
|
// want to keep the menu open.
|
|
298
339
|
return;
|
|
@@ -322,7 +363,7 @@ export class Menu extends LitElement {
|
|
|
322
363
|
this.dispatchEvent(new Event('opening'));
|
|
323
364
|
}
|
|
324
365
|
else {
|
|
325
|
-
animationAborted = !!await this.animateOpen();
|
|
366
|
+
animationAborted = !!(await this.animateOpen());
|
|
326
367
|
}
|
|
327
368
|
// This must come after the opening animation or else it may focus one of
|
|
328
369
|
// the items before the animation has begun and causes the list to slide
|
|
@@ -378,25 +419,27 @@ export class Menu extends LitElement {
|
|
|
378
419
|
}
|
|
379
420
|
};
|
|
380
421
|
this.onWindowPointerdown = (event) => {
|
|
381
|
-
this.isPointerDown = true;
|
|
382
422
|
this.pointerPath = event.composedPath();
|
|
383
423
|
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
424
|
+
/**
|
|
425
|
+
* We cannot listen to window click because Safari on iOS will not bubble a
|
|
426
|
+
* click event on window if the item clicked is not a "clickable" item such as
|
|
427
|
+
* <body>
|
|
428
|
+
*/
|
|
429
|
+
this.onDocumentClick = (event) => {
|
|
388
430
|
if (!this.open) {
|
|
389
431
|
return;
|
|
390
432
|
}
|
|
391
433
|
const path = event.composedPath();
|
|
392
|
-
if (!this.stayOpenOnOutsideClick &&
|
|
434
|
+
if (!this.stayOpenOnOutsideClick &&
|
|
435
|
+
!path.includes(this) &&
|
|
393
436
|
!path.includes(this.anchorElement)) {
|
|
394
437
|
this.open = false;
|
|
395
438
|
}
|
|
396
439
|
};
|
|
397
440
|
if (!isServer) {
|
|
398
441
|
this.internals.role = 'menu';
|
|
399
|
-
this.addEventListener('keydown', this.
|
|
442
|
+
this.addEventListener('keydown', this.handleKeydown);
|
|
400
443
|
// Capture so that we can grab the event before it reaches the menu item
|
|
401
444
|
// istelf. Specifically useful for the case where typeahead encounters a
|
|
402
445
|
// space and we don't want the menu item to close the menu.
|
|
@@ -421,6 +464,34 @@ export class Menu extends LitElement {
|
|
|
421
464
|
}
|
|
422
465
|
this.setAttribute('aria-hidden', 'true');
|
|
423
466
|
}
|
|
467
|
+
update(changed) {
|
|
468
|
+
if (changed.has('open')) {
|
|
469
|
+
if (this.open) {
|
|
470
|
+
this.setUpGlobalEventListeners();
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
this.cleanUpGlobalEventListeners();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
// Firefox does not support popover. Fall-back to using fixed.
|
|
477
|
+
if (changed.has('positioning') &&
|
|
478
|
+
this.positioning === 'popover' &&
|
|
479
|
+
// type required for Google JS conformance
|
|
480
|
+
!this.showPopover) {
|
|
481
|
+
this.positioning = 'fixed';
|
|
482
|
+
}
|
|
483
|
+
super.update(changed);
|
|
484
|
+
}
|
|
485
|
+
connectedCallback() {
|
|
486
|
+
super.connectedCallback();
|
|
487
|
+
if (this.open) {
|
|
488
|
+
this.setUpGlobalEventListeners();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
disconnectedCallback() {
|
|
492
|
+
super.disconnectedCallback();
|
|
493
|
+
this.cleanUpGlobalEventListeners();
|
|
494
|
+
}
|
|
424
495
|
render() {
|
|
425
496
|
return this.renderSurface();
|
|
426
497
|
}
|
|
@@ -429,31 +500,30 @@ export class Menu extends LitElement {
|
|
|
429
500
|
*/
|
|
430
501
|
renderSurface() {
|
|
431
502
|
return html `
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
503
|
+
<div
|
|
504
|
+
class="menu ${classMap(this.getSurfaceClasses())}"
|
|
505
|
+
style=${styleMap(this.menuPositionController.surfaceStyles)}
|
|
506
|
+
popover=${this.positioning === 'popover' ? 'manual' : nothing}>
|
|
435
507
|
${this.renderElevation()}
|
|
436
508
|
<div class="items">
|
|
437
|
-
<div class="item-padding">
|
|
438
|
-
${this.renderMenuItems()}
|
|
439
|
-
</div>
|
|
509
|
+
<div class="item-padding"> ${this.renderMenuItems()} </div>
|
|
440
510
|
</div>
|
|
441
|
-
|
|
442
|
-
|
|
511
|
+
</div>
|
|
512
|
+
`;
|
|
443
513
|
}
|
|
444
514
|
/**
|
|
445
515
|
* Renders the menu items' slot
|
|
446
516
|
*/
|
|
447
517
|
renderMenuItems() {
|
|
448
518
|
return html `<slot
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
519
|
+
@close-menu=${this.onCloseMenu}
|
|
520
|
+
@deactivate-items=${this.onDeactivateItems}
|
|
521
|
+
@request-activation=${this.onRequestActivation}
|
|
522
|
+
@deactivate-typeahead=${this.handleDeactivateTypeahead}
|
|
523
|
+
@activate-typeahead=${this.handleActivateTypeahead}
|
|
524
|
+
@stay-open-on-focusout=${this.handleStayOpenOnFocusout}
|
|
525
|
+
@close-on-focusout=${this.handleCloseOnFocusout}
|
|
526
|
+
@slotchange=${this.listController.onSlotchange}></slot>`;
|
|
457
527
|
}
|
|
458
528
|
/**
|
|
459
529
|
* Renders the elevation component.
|
|
@@ -469,7 +539,8 @@ export class Menu extends LitElement {
|
|
|
469
539
|
};
|
|
470
540
|
}
|
|
471
541
|
captureKeydown(event) {
|
|
472
|
-
if (event.target === this &&
|
|
542
|
+
if (event.target === this &&
|
|
543
|
+
!event.defaultPrevented &&
|
|
473
544
|
isClosableKey(event.code)) {
|
|
474
545
|
event.preventDefault();
|
|
475
546
|
this.close();
|
|
@@ -513,7 +584,7 @@ export class Menu extends LitElement {
|
|
|
513
584
|
// height animation
|
|
514
585
|
const upPositionCorrectionAnimation = slotEl.animate([
|
|
515
586
|
{ transform: openingUpwards ? `translateY(-${height}px)` : '' },
|
|
516
|
-
{ transform: '' }
|
|
587
|
+
{ transform: '' },
|
|
517
588
|
], { duration: FULL_DURATION, easing: EASING.EMPHASIZED });
|
|
518
589
|
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 0 }, { opacity: 1 }], SURFACE_OPACITY_DURATION);
|
|
519
590
|
const childrenAnimations = [];
|
|
@@ -589,7 +660,7 @@ export class Menu extends LitElement {
|
|
|
589
660
|
const SURFACE_OPACITY_DELAY = FULL_DURATION - SURFACE_OPACITY_DURATION;
|
|
590
661
|
const ITEM_OPACITY_DURATION = 50;
|
|
591
662
|
const ITEM_OPACITY_INITIAL_DELAY = 50;
|
|
592
|
-
const END_HEIGHT_PERCENTAGE = .35;
|
|
663
|
+
const END_HEIGHT_PERCENTAGE = 0.35;
|
|
593
664
|
// We want to fit every child fade-out animation within the full duration of
|
|
594
665
|
// the animation.
|
|
595
666
|
const DELAY_BETWEEN_ITEMS = (FULL_DURATION - ITEM_OPACITY_INITIAL_DELAY - ITEM_OPACITY_DURATION) /
|
|
@@ -597,7 +668,7 @@ export class Menu extends LitElement {
|
|
|
597
668
|
// The mock has the animation shrink to 35%
|
|
598
669
|
const surfaceHeightAnimation = surfaceEl.animate([
|
|
599
670
|
{ height: `${height}px` },
|
|
600
|
-
{ height: `${height * END_HEIGHT_PERCENTAGE}px` }
|
|
671
|
+
{ height: `${height * END_HEIGHT_PERCENTAGE}px` },
|
|
601
672
|
], {
|
|
602
673
|
duration: FULL_DURATION,
|
|
603
674
|
easing: EASING.EMPHASIZED_ACCELERATE,
|
|
@@ -606,11 +677,12 @@ export class Menu extends LitElement {
|
|
|
606
677
|
// always in view, so we need to translate it upwards the opposite direction
|
|
607
678
|
// of the height animation
|
|
608
679
|
const downPositionCorrectionAnimation = slotEl.animate([
|
|
609
|
-
{ transform: '' },
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
680
|
+
{ transform: '' },
|
|
681
|
+
{
|
|
682
|
+
transform: closingDownwards
|
|
683
|
+
? `translateY(-${height * (1 - END_HEIGHT_PERCENTAGE)}px)`
|
|
684
|
+
: '',
|
|
685
|
+
},
|
|
614
686
|
], { duration: FULL_DURATION, easing: EASING.EMPHASIZED_ACCELERATE });
|
|
615
687
|
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 1 }, { opacity: 0 }], { duration: SURFACE_OPACITY_DURATION, delay: SURFACE_OPACITY_DELAY });
|
|
616
688
|
const childrenAnimations = [];
|
|
@@ -651,21 +723,26 @@ export class Menu extends LitElement {
|
|
|
651
723
|
});
|
|
652
724
|
return animationEnded;
|
|
653
725
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
726
|
+
handleKeydown(event) {
|
|
727
|
+
// At any key event, the pointer interaction is done so we need to clear our
|
|
728
|
+
// cached pointerpath. This handles the case where the user clicks on the
|
|
729
|
+
// anchor, and then hits shift+tab
|
|
730
|
+
this.pointerPath = [];
|
|
731
|
+
this.listController.handleKeydown(event);
|
|
661
732
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
733
|
+
setUpGlobalEventListeners() {
|
|
734
|
+
document.addEventListener('click', this.onDocumentClick, { capture: true });
|
|
735
|
+
window.addEventListener('pointerdown', this.onWindowPointerdown);
|
|
736
|
+
document.addEventListener('resize', this.onWindowResize, { passive: true });
|
|
737
|
+
window.addEventListener('resize', this.onWindowResize, { passive: true });
|
|
738
|
+
}
|
|
739
|
+
cleanUpGlobalEventListeners() {
|
|
740
|
+
document.removeEventListener('click', this.onDocumentClick, {
|
|
741
|
+
capture: true,
|
|
742
|
+
});
|
|
743
|
+
window.removeEventListener('pointerdown', this.onWindowPointerdown);
|
|
744
|
+
document.removeEventListener('resize', this.onWindowResize);
|
|
745
|
+
window.removeEventListener('resize', this.onWindowResize);
|
|
669
746
|
}
|
|
670
747
|
onCloseMenu() {
|
|
671
748
|
this.close();
|
|
@@ -701,7 +778,7 @@ export class Menu extends LitElement {
|
|
|
701
778
|
close() {
|
|
702
779
|
this.open = false;
|
|
703
780
|
const maybeSubmenu = this.slotItems;
|
|
704
|
-
maybeSubmenu.forEach(item => {
|
|
781
|
+
maybeSubmenu.forEach((item) => {
|
|
705
782
|
item.close?.();
|
|
706
783
|
});
|
|
707
784
|
}
|
|
@@ -726,10 +803,20 @@ export class Menu extends LitElement {
|
|
|
726
803
|
activatePreviousItem() {
|
|
727
804
|
return this.listController.activatePreviousItem() ?? null;
|
|
728
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* Repositions the menu if it is open.
|
|
808
|
+
*
|
|
809
|
+
* Useful for the case where document or window-positioned menus have their
|
|
810
|
+
* anchors moved while open.
|
|
811
|
+
*/
|
|
812
|
+
reposition() {
|
|
813
|
+
if (this.open) {
|
|
814
|
+
this.menuPositionController.position();
|
|
815
|
+
}
|
|
816
|
+
}
|
|
729
817
|
}
|
|
730
818
|
(() => {
|
|
731
|
-
|
|
732
|
-
setupHostAria(Menu, { focusable: false });
|
|
819
|
+
polyfillARIAMixin(Menu);
|
|
733
820
|
})();
|
|
734
821
|
__decorate([
|
|
735
822
|
query('.menu')
|