@material/web 1.0.0-pre.14 → 1.0.0-pre.15
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/README.md +5 -5
- package/all.d.ts +4 -8
- package/all.js +4 -8
- package/all.js.map +1 -1
- package/button/{_tonal-button.scss → _filled-tonal-button.scss} +1 -1
- package/button/{tonal-button.d.ts → filled-tonal-button.d.ts} +3 -3
- package/button/{tonal-button.js → filled-tonal-button.js} +9 -9
- package/button/filled-tonal-button.js.map +1 -0
- package/button/internal/{_tonal-button.scss → _filled-tonal-button.scss} +7 -7
- package/button/internal/_shared.scss +12 -7
- package/button/internal/_touch-target.scss +5 -1
- package/button/internal/button.d.ts +6 -10
- package/button/internal/button.js +10 -43
- package/button/internal/button.js.map +1 -1
- package/button/internal/elevated-styles.css.js +1 -1
- package/button/internal/elevated-styles.css.js.map +1 -1
- package/button/internal/filled-styles.css.js +1 -1
- package/button/internal/filled-styles.css.js.map +1 -1
- package/button/internal/{tonal-button.d.ts → filled-tonal-button.d.ts} +2 -2
- package/button/internal/{tonal-button.js → filled-tonal-button.js} +3 -3
- package/button/internal/filled-tonal-button.js.map +1 -0
- package/button/internal/filled-tonal-styles.css.js +9 -0
- package/button/internal/filled-tonal-styles.css.js.map +1 -0
- package/button/internal/{tonal-styles.scss → filled-tonal-styles.scss} +2 -2
- package/button/internal/outlined-styles.css.js +1 -1
- package/button/internal/outlined-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/button/internal/text-styles.css.js +1 -1
- package/button/internal/text-styles.css.js.map +1 -1
- package/checkbox/internal/_checkbox.scss +22 -78
- 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 +77 -6
- package/checkbox/internal/checkbox.js +123 -14
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/internal/_shared.scss +8 -0
- package/chips/internal/chip-set.js +1 -3
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.js +1 -3
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.d.ts +1 -0
- package/chips/internal/filter-chip.js +12 -6
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/shared-styles.css.js +1 -1
- package/chips/internal/shared-styles.css.js.map +1 -1
- package/common.d.ts +2 -6
- package/common.js +2 -6
- package/common.js.map +1 -1
- package/dialog/harness.d.ts +1 -6
- package/dialog/harness.js +2 -43
- package/dialog/harness.js.map +1 -1
- package/dialog/internal/_dialog.scss +165 -281
- package/dialog/internal/animations.d.ts +47 -0
- package/dialog/internal/animations.js +117 -0
- package/dialog/internal/animations.js.map +1 -0
- 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 +76 -169
- package/dialog/internal/dialog.js +251 -475
- package/dialog/internal/dialog.js.map +1 -1
- package/fab/internal/_fab.scss +4 -0
- package/fab/internal/_shared.scss +12 -0
- package/fab/internal/fab-styles.css.js +1 -1
- package/fab/internal/fab-styles.css.js.map +1 -1
- package/fab/internal/shared-styles.css.js +1 -1
- package/fab/internal/shared-styles.css.js.map +1 -1
- package/fab/internal/shared.d.ts +0 -4
- package/fab/internal/shared.js +3 -13
- package/fab/internal/shared.js.map +1 -1
- package/focus/internal/_focus-ring.scss +52 -48
- package/focus/internal/focus-ring-styles.css.js +1 -1
- package/focus/internal/focus-ring-styles.css.js.map +1 -1
- package/focus/internal/focus-ring.d.ts +2 -1
- package/focus/internal/focus-ring.js +10 -0
- package/focus/internal/focus-ring.js.map +1 -1
- package/icon/internal/_icon.scss +18 -17
- package/icon/internal/icon-styles.css.js +1 -1
- package/icon/internal/icon-styles.css.js.map +1 -1
- package/icon/internal/icon.d.ts +1 -0
- package/icon/internal/icon.js +9 -0
- package/icon/internal/icon.js.map +1 -1
- package/iconbutton/{_standard-icon-button.scss → _icon-button.scss} +1 -1
- package/iconbutton/{standard-icon-button.d.ts → icon-button.d.ts} +2 -2
- package/iconbutton/{standard-icon-button.js → icon-button.js} +7 -7
- package/iconbutton/icon-button.js.map +1 -0
- package/iconbutton/internal/_filled-icon-button.scss +8 -6
- package/iconbutton/internal/_filled-tonal-icon-button.scss +8 -6
- package/iconbutton/internal/{_standard-icon-button.scss → _icon-button.scss} +8 -8
- package/iconbutton/internal/_outlined-icon-button.scss +14 -14
- package/iconbutton/internal/_shared.scss +6 -9
- package/iconbutton/internal/filled-styles.css.js +1 -1
- package/iconbutton/internal/filled-styles.css.js.map +1 -1
- package/iconbutton/internal/filled-tonal-styles.css.js +1 -1
- package/iconbutton/internal/filled-tonal-styles.css.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +10 -1
- package/iconbutton/internal/icon-button.js +17 -2
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/iconbutton/internal/outlined-styles.css.js +1 -1
- package/iconbutton/internal/outlined-styles.css.js.map +1 -1
- package/iconbutton/internal/shared-styles.css.js +1 -1
- package/iconbutton/internal/shared-styles.css.js.map +1 -1
- package/iconbutton/internal/standard-styles.css.js +1 -1
- package/iconbutton/internal/standard-styles.css.js.map +1 -1
- package/iconbutton/internal/standard-styles.scss +2 -2
- package/internal/aria/delegate.d.ts +1 -1
- package/internal/aria/delegate.js +1 -1
- package/internal/aria/delegate.js.map +1 -1
- package/internal/controller/element-internals.d.ts +35 -0
- package/internal/controller/element-internals.js +24 -0
- package/internal/controller/element-internals.js.map +1 -0
- package/internal/controller/form-submitter.d.ts +60 -0
- package/internal/controller/form-submitter.js +69 -0
- package/internal/controller/form-submitter.js.map +1 -0
- package/labs/navigationbar/internal/navigation-bar.js +1 -3
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js +1 -3
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js +1 -3
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.js +1 -3
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/segmentedbutton/internal/outlined-styles.css.js +1 -1
- package/labs/segmentedbutton/internal/outlined-styles.css.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.js +1 -3
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/outlined-styles.css.js +1 -1
- package/labs/segmentedbuttonset/internal/outlined-styles.css.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.js +1 -3
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/list/internal/list.d.ts +2 -2
- package/list/internal/list.js +1 -3
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/_list-item.scss +20 -54
- 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 +15 -3
- package/list/internal/listitem/list-item.js +43 -10
- package/list/internal/listitem/list-item.js.map +1 -1
- package/menu/internal/menu.js +3 -4
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/_menu-item.scss +1 -1
- package/menu/internal/menuitem/forced-colors-styles.css.js +1 -1
- package/menu/internal/menuitem/forced-colors-styles.css.js.map +1 -1
- package/menu/internal/menuitem/forced-colors-styles.scss +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 +9 -0
- package/menu/internal/menuitem/menu-item.js +18 -4
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/menu/internal/shared.d.ts +45 -38
- package/menu/internal/shared.js +29 -40
- package/menu/internal/shared.js.map +1 -1
- package/menu/internal/submenuitem/sub-menu-item.d.ts +22 -12
- package/menu/internal/submenuitem/sub-menu-item.js +39 -24
- package/menu/internal/submenuitem/sub-menu-item.js.map +1 -1
- package/menu/menu-item.d.ts +1 -1
- package/menu/menu-item.js +0 -1
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.d.ts +1 -1
- package/menu/menu.js +0 -1
- package/menu/menu.js.map +1 -1
- package/menu/sub-menu-item.d.ts +1 -1
- package/menu/sub-menu-item.js +0 -1
- package/menu/sub-menu-item.js.map +1 -1
- package/package.json +1 -3
- package/progress/internal/progress.js +1 -3
- package/progress/internal/progress.js.map +1 -1
- package/radio/internal/_radio.scss +38 -24
- package/radio/internal/forced-colors-styles.css.js +1 -1
- package/radio/internal/forced-colors-styles.css.js.map +1 -1
- package/radio/internal/forced-colors-styles.scss +4 -4
- package/radio/internal/radio-styles.css.js +1 -1
- package/radio/internal/radio-styles.css.js.map +1 -1
- package/radio/internal/radio.js +7 -6
- package/radio/internal/radio.js.map +1 -1
- package/select/internal/_filled-select.scss +2 -2
- package/select/internal/_outlined-select.scss +2 -2
- package/select/internal/_shared.scss +30 -0
- package/select/internal/filled-select-styles.css.js +1 -1
- package/select/internal/filled-select-styles.css.js.map +1 -1
- package/select/internal/outlined-select-styles.css.js +1 -1
- package/select/internal/outlined-select-styles.css.js.map +1 -1
- package/select/internal/select.d.ts +0 -5
- package/select/internal/select.js +11 -16
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +5 -6
- package/select/internal/selectoption/select-option.js +8 -9
- package/select/internal/selectoption/select-option.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/internal/shared.d.ts +5 -9
- package/select/internal/shared.js +13 -11
- package/select/internal/shared.js.map +1 -1
- package/slider/internal/slider.js +1 -3
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/_handle.scss +12 -12
- package/switch/internal/_icon.scss +8 -8
- package/switch/internal/_track.scss +10 -10
- package/switch/internal/forced-colors-styles.css.js +1 -1
- package/switch/internal/forced-colors-styles.css.js.map +1 -1
- package/switch/internal/forced-colors-styles.scss +12 -12
- package/switch/internal/switch-styles.css.js +1 -1
- package/switch/internal/switch-styles.css.js.map +1 -1
- package/switch/internal/switch.js +1 -3
- package/switch/internal/switch.js.map +1 -1
- package/tabs/internal/_tab.scss +1 -1
- package/tabs/internal/_tabs.scss +1 -0
- package/tabs/internal/tab.d.ts +3 -9
- package/tabs/internal/tab.js +4 -7
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.d.ts +1 -4
- package/tabs/internal/tabs.js +5 -10
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/harness.js +4 -0
- package/textfield/harness.js.map +1 -1
- package/textfield/internal/text-field.js +1 -4
- package/textfield/internal/text-field.js.map +1 -1
- package/tokens/_index.scss +1 -0
- package/tokens/_md-comp-checkbox.scss +16 -16
- package/tokens/_md-comp-dialog.scss +2 -1
- package/tokens/_md-comp-elevated-button.scss +14 -12
- package/tokens/_md-comp-filled-button.scss +14 -12
- package/tokens/_md-comp-filled-icon-button.scss +23 -8
- package/tokens/_md-comp-filled-select.scss +19 -1
- package/tokens/_md-comp-filled-tonal-button.scss +14 -12
- package/tokens/_md-comp-filled-tonal-icon-button.scss +23 -8
- package/tokens/_md-comp-icon-button.scss +24 -11
- package/tokens/_md-comp-icon.scss +32 -0
- package/tokens/_md-comp-outlined-button.scss +14 -12
- package/tokens/_md-comp-outlined-icon-button.scss +26 -12
- package/tokens/_md-comp-outlined-segmented-button.scss +2 -2
- package/tokens/_md-comp-radio-button.scss +20 -9
- package/tokens/_md-comp-switch.scss +66 -32
- package/tokens/_md-comp-text-button.scss +14 -12
- package/button/internal/tonal-button.js.map +0 -1
- package/button/internal/tonal-styles.css.js +0 -9
- package/button/internal/tonal-styles.css.js.map +0 -1
- package/button/tonal-button.js.map +0 -1
- package/dialog/internal/_tokens.scss +0 -66
- package/icon/internal/_md-comp-icon.scss +0 -18
- package/iconbutton/standard-icon-button.js.map +0 -1
- package/list/internal/listitemlink/list-item-link-only.d.ts +0 -23
- package/list/internal/listitemlink/list-item-link-only.js +0 -36
- package/list/internal/listitemlink/list-item-link-only.js.map +0 -1
- package/list/internal/listitemlink/list-item-link.d.ts +0 -18
- package/list/internal/listitemlink/list-item-link.js +0 -42
- package/list/internal/listitemlink/list-item-link.js.map +0 -1
- package/list/list-item-link.d.ts +0 -53
- package/list/list-item-link.js +0 -57
- package/list/list-item-link.js.map +0 -1
- package/menu/internal/menuitemlink/menu-item-link.d.ts +0 -23
- package/menu/internal/menuitemlink/menu-item-link.js +0 -49
- package/menu/internal/menuitemlink/menu-item-link.js.map +0 -1
- package/menu/menu-item-link.d.ts +0 -33
- package/menu/menu-item-link.js +0 -38
- package/menu/menu-item-link.js.map +0 -1
- /package/button/internal/{tonal-styles.css.d.ts → filled-tonal-styles.css.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forced-colors-styles.css.js","sourceRoot":"","sources":["forced-colors-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`@media(forced-colors: active){.list-item{position:relative}:host([selected]) .list-item:not(
|
|
1
|
+
{"version":3,"file":"forced-colors-styles.css.js","sourceRoot":"","sources":["forced-colors-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`@media(forced-colors: active){.list-item{position:relative}:host([selected]) .list-item:not(.has-focus-ring)::before{content:\"\";position:absolute;inset:0;box-sizing:border-box;border-radius:inherit;pointer-events:none;border:3px double CanvasText}}/*# sourceMappingURL=forced-colors-styles.css.map */\n`;\n "]}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
// Show double border only when selected, and the current list item does not
|
|
12
12
|
// have a focus ring on it.
|
|
13
|
-
:host([selected]) .list-item:not(
|
|
13
|
+
:host([selected]) .list-item:not(.has-focus-ring)::before {
|
|
14
14
|
content: '';
|
|
15
15
|
position: absolute;
|
|
16
16
|
inset: 0;
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { css } from 'lit';
|
|
7
|
-
export const styles = css `:host{--_list-item-selected-container-color: var(--md-menu-item-list-item-selected-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_list-item-container-color: var(--md-menu-item-list-item-container-color, var(--md-sys-color-surface-container, #f3edf7));--md-list-item-list-item-container-color: var(--_list-item-container-color)}:host([selected]) .list-item{background-color:var(--_list-item-selected-container-color)}.
|
|
7
|
+
export const styles = css `:host{--_list-item-selected-container-color: var(--md-menu-item-list-item-selected-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_list-item-container-color: var(--md-menu-item-list-item-container-color, var(--md-sys-color-surface-container, #f3edf7));--md-list-item-list-item-container-color: var(--_list-item-container-color)}:host([selected]) .list-item{background-color:var(--_list-item-selected-container-color)}.submenu-hover{--md-ripple-hover-opacity: 0}/*# sourceMappingURL=menu-item-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=menu-item-styles.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item-styles.css.js","sourceRoot":"","sources":["menu-item-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_list-item-selected-container-color: var(--md-menu-item-list-item-selected-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_list-item-container-color: var(--md-menu-item-list-item-container-color, var(--md-sys-color-surface-container, #f3edf7));--md-list-item-list-item-container-color: var(--_list-item-container-color)}:host([selected]) .list-item{background-color:var(--_list-item-selected-container-color)}.
|
|
1
|
+
{"version":3,"file":"menu-item-styles.css.js","sourceRoot":"","sources":["menu-item-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_list-item-selected-container-color: var(--md-menu-item-list-item-selected-container-color, var(--md-sys-color-surface-container-highest, #e6e0e9));--_list-item-container-color: var(--md-menu-item-list-item-container-color, var(--md-sys-color-surface-container, #f3edf7));--md-list-item-list-item-container-color: var(--_list-item-container-color)}:host([selected]) .list-item{background-color:var(--_list-item-selected-container-color)}.submenu-hover{--md-ripple-hover-opacity: 0}/*# sourceMappingURL=menu-item-styles.css.map */\n`;\n "]}
|
|
@@ -18,11 +18,20 @@ export declare class MenuItemEl extends ListItemEl implements MenuItem {
|
|
|
18
18
|
* Keeps the menu open if clicked or keyboard selected.
|
|
19
19
|
*/
|
|
20
20
|
keepOpen: boolean;
|
|
21
|
+
protected hasFocusRing: boolean;
|
|
21
22
|
/**
|
|
22
23
|
* Used for overriding e.g. sub-menu-item.
|
|
23
24
|
*/
|
|
24
25
|
protected keepOpenOnClick: boolean;
|
|
25
26
|
readonly type: ListItemRole;
|
|
26
27
|
protected onClick(): void;
|
|
28
|
+
protected getRenderClasses(): {
|
|
29
|
+
'has-focus-ring': boolean;
|
|
30
|
+
'with-one-line': boolean;
|
|
31
|
+
'with-two-line': boolean;
|
|
32
|
+
'with-three-line': boolean;
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
};
|
|
35
|
+
protected onFocusRingVisibilityChanged(e: Event): void;
|
|
27
36
|
protected onKeydown(event: KeyboardEvent): void;
|
|
28
37
|
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
|
-
import { property } from 'lit/decorators.js';
|
|
7
|
+
import { property, state } from 'lit/decorators.js';
|
|
8
8
|
import { ListItemEl } from '../../../list/internal/listitem/list-item.js';
|
|
9
|
-
import { CLOSE_REASON,
|
|
9
|
+
import { CLOSE_REASON, createDefaultCloseMenuEvent, isClosableKey } from '../shared.js';
|
|
10
10
|
/**
|
|
11
11
|
* @fires close-menu {CloseMenuEvent}
|
|
12
12
|
*/
|
|
@@ -21,6 +21,7 @@ export class MenuItemEl extends ListItemEl {
|
|
|
21
21
|
* Keeps the menu open if clicked or keyboard selected.
|
|
22
22
|
*/
|
|
23
23
|
this.keepOpen = false;
|
|
24
|
+
this.hasFocusRing = false;
|
|
24
25
|
/**
|
|
25
26
|
* Used for overriding e.g. sub-menu-item.
|
|
26
27
|
*/
|
|
@@ -30,7 +31,17 @@ export class MenuItemEl extends ListItemEl {
|
|
|
30
31
|
onClick() {
|
|
31
32
|
if (this.keepOpen || this.keepOpenOnClick)
|
|
32
33
|
return;
|
|
33
|
-
this.dispatchEvent(
|
|
34
|
+
this.dispatchEvent(createDefaultCloseMenuEvent(this, { kind: CLOSE_REASON.CLICK_SELECTION }));
|
|
35
|
+
}
|
|
36
|
+
getRenderClasses() {
|
|
37
|
+
return {
|
|
38
|
+
...super.getRenderClasses(),
|
|
39
|
+
'has-focus-ring': this.hasFocusRing,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
onFocusRingVisibilityChanged(e) {
|
|
43
|
+
const focusRing = e.target;
|
|
44
|
+
this.hasFocusRing = focusRing.visible;
|
|
34
45
|
}
|
|
35
46
|
onKeydown(event) {
|
|
36
47
|
if (this.keepOpen)
|
|
@@ -38,7 +49,7 @@ export class MenuItemEl extends ListItemEl {
|
|
|
38
49
|
const keyCode = event.code;
|
|
39
50
|
if (!event.defaultPrevented && isClosableKey(keyCode)) {
|
|
40
51
|
event.preventDefault();
|
|
41
|
-
this.dispatchEvent(
|
|
52
|
+
this.dispatchEvent(createDefaultCloseMenuEvent(this, { kind: CLOSE_REASON.KEYDOWN, key: keyCode }));
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
55
|
}
|
|
@@ -48,4 +59,7 @@ __decorate([
|
|
|
48
59
|
__decorate([
|
|
49
60
|
property({ type: Boolean, attribute: 'keep-open' })
|
|
50
61
|
], MenuItemEl.prototype, "keepOpen", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
state()
|
|
64
|
+
], MenuItemEl.prototype, "hasFocusRing", void 0);
|
|
51
65
|
//# sourceMappingURL=menu-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,UAAU,EAAe,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAC,YAAY,EAAE,2BAA2B,EAAE,aAAa,EAAW,MAAM,cAAc,CAAC;AAIhG;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QACE;;WAEG;QAEH,eAAU,GAAG,IAAI,CA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,EAAE,WAAW,EAAC,CAAC;4CAAkB;AAE3D;IAAR,KAAK,EAAE;gDAAgC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {property, state} from 'lit/decorators.js';\n\nimport type {MdFocusRing} from '../../../focus/md-focus-ring.js';\nimport {ListItemEl, ListItemRole} from '../../../list/internal/listitem/list-item.js';\nimport {CLOSE_REASON, createDefaultCloseMenuEvent, isClosableKey, MenuItem} from '../shared.js';\n\nexport {ListItemRole} from '../../../list/internal/listitem/list-item.js';\n\n/**\n * @fires close-menu {CloseMenuEvent}\n */\nexport class MenuItemEl extends ListItemEl implements MenuItem {\n /**\n * READONLY: self-identifies as a menu item and sets its identifying attribute\n */\n @property({type: Boolean, attribute: 'md-menu-item', reflect: true})\n isMenuItem = true;\n\n /**\n * Keeps the menu open if clicked or keyboard selected.\n */\n @property({type: Boolean, attribute: 'keep-open'}) keepOpen = false;\n\n @state() protected hasFocusRing = false;\n\n /**\n * Used for overriding e.g. sub-menu-item.\n */\n protected keepOpenOnClick = false;\n\n override readonly type: ListItemRole = 'menuitem';\n\n protected override onClick() {\n if (this.keepOpen || this.keepOpenOnClick) return;\n\n this.dispatchEvent(createDefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.CLICK_SELECTION}));\n }\n\n protected override getRenderClasses() {\n return {\n ...super.getRenderClasses(),\n 'has-focus-ring': this.hasFocusRing,\n };\n }\n\n protected override onFocusRingVisibilityChanged(e: Event) {\n const focusRing = e.target as MdFocusRing;\n this.hasFocusRing = focusRing.visible;\n }\n\n protected override onKeydown(event: KeyboardEvent) {\n if (this.keepOpen) return;\n const keyCode = event.code;\n\n if (!event.defaultPrevented && isClosableKey(keyCode)) {\n event.preventDefault();\n this.dispatchEvent(createDefaultCloseMenuEvent(\n this, {kind: CLOSE_REASON.KEYDOWN, key: keyCode}));\n }\n }\n}\n"]}
|
|
@@ -63,58 +63,65 @@ export interface KeydownReason extends Reason {
|
|
|
63
63
|
*/
|
|
64
64
|
export type DefaultReasons = ClickReason | KeydownReason;
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
* dispatch this event rather than creating your own `close-menu` event.
|
|
66
|
+
* Creates an event that closes any parent menus.
|
|
68
67
|
*/
|
|
69
|
-
export declare
|
|
68
|
+
export declare function createCloseMenuEvent<T extends Reason = DefaultReasons>(initiator: MenuItem, reason: T): CustomEvent<{
|
|
70
69
|
initiator: MenuItem;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
70
|
+
itemPath: MenuItem[];
|
|
71
|
+
reason: T;
|
|
72
|
+
}>;
|
|
75
73
|
/**
|
|
76
|
-
*
|
|
77
|
-
* event.
|
|
74
|
+
* Creates an event that signals to the menu that it should stay open on the
|
|
75
|
+
* focusout event.
|
|
78
76
|
*/
|
|
79
|
-
export declare
|
|
80
|
-
constructor();
|
|
81
|
-
}
|
|
77
|
+
export declare function createStayOpenOnFocusoutEvent(): Event;
|
|
82
78
|
/**
|
|
83
|
-
*
|
|
84
|
-
* event.
|
|
79
|
+
* Creates an event that signals to the menu that it should close open on the
|
|
80
|
+
* focusout event.
|
|
85
81
|
*/
|
|
86
|
-
export declare
|
|
87
|
-
constructor();
|
|
88
|
-
}
|
|
82
|
+
export declare function createCloseOnFocusoutEvent(): Event;
|
|
89
83
|
/**
|
|
90
|
-
*
|
|
91
|
-
* event, you should subclass the `CloseMenuEvent` instead.
|
|
84
|
+
* Creates a default close menu event used by md-menu.
|
|
92
85
|
*/
|
|
93
|
-
export declare const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
readonly NONE: number;
|
|
99
|
-
};
|
|
86
|
+
export declare const createDefaultCloseMenuEvent: (initiator: MenuItem, reason: DefaultReasons) => CustomEvent<{
|
|
87
|
+
initiator: MenuItem;
|
|
88
|
+
itemPath: MenuItem[];
|
|
89
|
+
reason: DefaultReasons;
|
|
90
|
+
}>;
|
|
100
91
|
/**
|
|
101
|
-
* The
|
|
92
|
+
* The type of the default close menu event used by md-menu.
|
|
102
93
|
*/
|
|
103
|
-
export
|
|
104
|
-
constructor();
|
|
105
|
-
}
|
|
94
|
+
export type CloseMenuEvent<T extends Reason = DefaultReasons> = ReturnType<typeof createCloseMenuEvent<T>>;
|
|
106
95
|
/**
|
|
107
|
-
*
|
|
96
|
+
* Creates an event that requests the parent md-menu to deactivate all other
|
|
97
|
+
* items.
|
|
108
98
|
*/
|
|
109
|
-
export declare
|
|
110
|
-
constructor();
|
|
111
|
-
}
|
|
99
|
+
export declare function createDeactivateItemsEvent(): Event;
|
|
112
100
|
/**
|
|
113
|
-
*
|
|
101
|
+
* The type of the event that requests the parent md-menu to deactivate all
|
|
102
|
+
* other items.
|
|
114
103
|
*/
|
|
115
|
-
export
|
|
116
|
-
|
|
117
|
-
|
|
104
|
+
export type DeactivateItemsEvent = ReturnType<typeof createDeactivateItemsEvent>;
|
|
105
|
+
/**
|
|
106
|
+
* Creates an event that requests the typeahead functionality of containing menu
|
|
107
|
+
* be deactivated.
|
|
108
|
+
*/
|
|
109
|
+
export declare function createDeactivateTypeaheadEvent(): Event;
|
|
110
|
+
/**
|
|
111
|
+
* The type of the event that requests the typeahead functionality of containing
|
|
112
|
+
* menu be deactivated.
|
|
113
|
+
*/
|
|
114
|
+
export type DeactivateTypeaheadEvent = ReturnType<typeof createDeactivateTypeaheadEvent>;
|
|
115
|
+
/**
|
|
116
|
+
* Creates an event that requests the typeahead functionality of containing menu
|
|
117
|
+
* be activated.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createActivateTypeaheadEvent(): Event;
|
|
120
|
+
/**
|
|
121
|
+
* The type of the event that requests the typeahead functionality of containing
|
|
122
|
+
* menu be activated.
|
|
123
|
+
*/
|
|
124
|
+
export type ActivateTypeaheadEvent = ReturnType<typeof createActivateTypeaheadEvent>;
|
|
118
125
|
/**
|
|
119
126
|
* Keys that are used to navigate menus.
|
|
120
127
|
*/
|
package/menu/internal/shared.js
CHANGED
|
@@ -4,64 +4,53 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* dispatch this event rather than creating your own `close-menu` event.
|
|
7
|
+
* Creates an event that closes any parent menus.
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
9
|
+
export function createCloseMenuEvent(initiator, reason) {
|
|
10
|
+
return new CustomEvent('close-menu', {
|
|
11
|
+
bubbles: true,
|
|
12
|
+
composed: true,
|
|
13
|
+
detail: { initiator, reason, itemPath: [initiator] }
|
|
14
|
+
});
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
20
|
-
* event.
|
|
17
|
+
* Creates an event that signals to the menu that it should stay open on the
|
|
18
|
+
* focusout event.
|
|
21
19
|
*/
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
super('stay-open-on-focusout', { bubbles: true, composed: true });
|
|
25
|
-
}
|
|
20
|
+
export function createStayOpenOnFocusoutEvent() {
|
|
21
|
+
return new Event('stay-open-on-focusout', { bubbles: true, composed: true });
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
28
|
-
*
|
|
29
|
-
* event.
|
|
24
|
+
* Creates an event that signals to the menu that it should close open on the
|
|
25
|
+
* focusout event.
|
|
30
26
|
*/
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
super('close-on-focusout', { bubbles: true, composed: true });
|
|
34
|
-
}
|
|
27
|
+
export function createCloseOnFocusoutEvent() {
|
|
28
|
+
return new Event('close-on-focusout', { bubbles: true, composed: true });
|
|
35
29
|
}
|
|
36
30
|
/**
|
|
37
|
-
*
|
|
38
|
-
* event, you should subclass the `CloseMenuEvent` instead.
|
|
31
|
+
* Creates a default close menu event used by md-menu.
|
|
39
32
|
*/
|
|
40
|
-
|
|
41
|
-
export const DefaultCloseMenuEvent = (CloseMenuEvent);
|
|
33
|
+
export const createDefaultCloseMenuEvent = (createCloseMenuEvent);
|
|
42
34
|
/**
|
|
43
|
-
*
|
|
35
|
+
* Creates an event that requests the parent md-menu to deactivate all other
|
|
36
|
+
* items.
|
|
44
37
|
*/
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
super('deactivate-items', { bubbles: true, composed: true });
|
|
48
|
-
}
|
|
38
|
+
export function createDeactivateItemsEvent() {
|
|
39
|
+
return new Event('deactivate-items', { bubbles: true, composed: true });
|
|
49
40
|
}
|
|
50
41
|
/**
|
|
51
|
-
*
|
|
42
|
+
* Creates an event that requests the typeahead functionality of containing menu
|
|
43
|
+
* be deactivated.
|
|
52
44
|
*/
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
super('deactivate-typeahead', { bubbles: true, composed: true });
|
|
56
|
-
}
|
|
45
|
+
export function createDeactivateTypeaheadEvent() {
|
|
46
|
+
return new Event('deactivate-typeahead', { bubbles: true, composed: true });
|
|
57
47
|
}
|
|
58
48
|
/**
|
|
59
|
-
*
|
|
49
|
+
* Creates an event that requests the typeahead functionality of containing menu
|
|
50
|
+
* be activated.
|
|
60
51
|
*/
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
super('activate-typeahead', { bubbles: true, composed: true });
|
|
64
|
-
}
|
|
52
|
+
export function createActivateTypeaheadEvent() {
|
|
53
|
+
return new Event('activate-typeahead', { bubbles: true, composed: true });
|
|
65
54
|
}
|
|
66
55
|
/**
|
|
67
56
|
* Keys that are used to navigate menus.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoEH
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoEH;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAChC,SAAmB,EAAE,MAAS;IAChC,OAA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AAC;IACpD,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,CAAC,mBAAmB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ListItem} from '../../list/internal/listitem/list-item.js';\n\n/**\n * Interface specific to menu item and not list item.\n */\ninterface MenuItemSelf {\n /**\n * The visible headline text of the item.\n */\n headline: string;\n /**\n * Whether or not the item is the currently active item of interest (focuses\n * upon activation).\n */\n active: boolean;\n /**\n * Whether or not the item is in the selected visual state.\n */\n selected?: boolean;\n /**\n * If it is a sub-menu-item, a method that can close the submenu.\n */\n close?: () => void;\n /**\n * Focuses the item.\n */\n focus: () => void;\n}\n\n/**\n * The interface of every menu item interactive with a menu. All menu items\n * should implement this interface to be compatible with md-menu. Additionally\n * they should have both the `md-menu-item` and `md-list-item` attributes set.\n */\nexport type MenuItem = MenuItemSelf&ListItem;\n\n/**\n * The reason the `close-menu` event was dispatched.\n */\nexport interface Reason {\n kind: string;\n}\n\n/**\n * The click selection reason for the `close-menu` event. The menu was closed\n * because an item was selected via user click.\n */\nexport interface ClickReason extends Reason {\n kind: typeof CLOSE_REASON.CLICK_SELECTION;\n}\n\n/**\n * The keydown reason for the `close-menu` event. The menu was closed\n * because a specific key was pressed. The default closing keys for\n * `md-menu-item` are, Space, Enter or Escape.\n */\nexport interface KeydownReason extends Reason {\n kind: typeof CLOSE_REASON.KEYDOWN;\n key: string;\n}\n\n/**\n * The default menu closing reasons for the material md-menu package.\n */\nexport type DefaultReasons = ClickReason|KeydownReason;\n\n/**\n * Creates an event that closes any parent menus.\n */\nexport function createCloseMenuEvent<T extends Reason = DefaultReasons>(\n initiator: MenuItem, reason: T) {\n return new CustomEvent<\n {initiator: MenuItem, itemPath: MenuItem[], reason: T}>('close-menu', {\n bubbles: true,\n composed: true,\n detail: {initiator, reason, itemPath: [initiator]}\n });\n}\n\n/**\n * Creates an event that signals to the menu that it should stay open on the\n * focusout event.\n */\nexport function createStayOpenOnFocusoutEvent() {\n return new Event('stay-open-on-focusout', {bubbles: true, composed: true});\n}\n\n/**\n * Creates an event that signals to the menu that it should close open on the\n * focusout event.\n */\nexport function createCloseOnFocusoutEvent() {\n return new Event('close-on-focusout', {bubbles: true, composed: true});\n}\n\n/**\n * Creates a default close menu event used by md-menu.\n */\nexport const createDefaultCloseMenuEvent = createCloseMenuEvent<DefaultReasons>;\n\n/**\n * The type of the default close menu event used by md-menu.\n */\n// tslint:disable-next-line\nexport type CloseMenuEvent<T extends Reason = DefaultReasons> =\n ReturnType<typeof createCloseMenuEvent<T>>;\n\n/**\n * Creates an event that requests the parent md-menu to deactivate all other\n * items.\n */\nexport function createDeactivateItemsEvent() {\n return new Event('deactivate-items', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the parent md-menu to deactivate all\n * other items.\n */\nexport type DeactivateItemsEvent =\n ReturnType<typeof createDeactivateItemsEvent>;\n\n\n/**\n * Creates an event that requests the typeahead functionality of containing menu\n * be deactivated.\n */\nexport function createDeactivateTypeaheadEvent() {\n return new Event('deactivate-typeahead', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the typeahead functionality of containing\n * menu be deactivated.\n */\nexport type DeactivateTypeaheadEvent =\n ReturnType<typeof createDeactivateTypeaheadEvent>;\n\n/**\n * Creates an event that requests the typeahead functionality of containing menu\n * be activated.\n */\nexport function createActivateTypeaheadEvent() {\n return new Event('activate-typeahead', {bubbles: true, composed: true});\n}\n\n/**\n * The type of the event that requests the typeahead functionality of containing\n * menu be activated.\n */\nexport type ActivateTypeaheadEvent =\n ReturnType<typeof createActivateTypeaheadEvent>;\n\n/**\n * Keys that are used to navigate menus.\n */\nexport const NAVIGABLE_KEY = {\n UP: 'ArrowUp',\n DOWN: 'ArrowDown',\n RIGHT: 'ArrowRight',\n LEFT: 'ArrowLeft',\n} as const;\n\n/**\n * Keys that are used for selection in menus.\n */\nexport const SELECTION_KEY = {\n SPACE: 'Space',\n ENTER: 'Enter',\n} as const;\n\n/**\n * Default close `Reason` kind values.\n */\nexport const CLOSE_REASON = {\n CLICK_SELECTION: 'CLICK_SELECTION',\n KEYDOWN: 'KEYDOWN',\n} as const;\n\n/**\n * Keys that can close menus.\n */\nexport const KEYDOWN_CLOSE_KEYS = {\n ESCAPE: 'Escape',\n SPACE: SELECTION_KEY.SPACE,\n ENTER: SELECTION_KEY.ENTER,\n} as const;\n\ntype Values<T> = T[keyof T];\n\n/**\n * Determines whether the given key code is a key code that should close the\n * menu.\n *\n * @param code The KeyboardEvent code to check.\n * @return Whether or not the key code is in the predetermined list to close the\n * menu.\n */\nexport function isClosableKey(code: string):\n code is Values<typeof KEYDOWN_CLOSE_KEYS> {\n return Object.values(KEYDOWN_CLOSE_KEYS).some(value => (value === code));\n}\n\n/**\n * Determines whether the given key code is a key code that should select a menu\n * item.\n *\n * @param code They KeyboardEvent code to check.\n * @return Whether or not the key code is in the predetermined list to select a\n * menu item.\n */\nexport function isSelectableKey(code: string):\n code is Values<typeof SELECTION_KEY> {\n return Object.values(SELECTION_KEY).some(value => (value === code));\n}\n\n/**\n * Determines whether a target element is contained inside another element's\n * composed tree.\n *\n * @param target The potential contained element.\n * @param container The potential containing element of the target.\n * @returns Whether the target element is contained inside the container's\n * composed subtree\n */\nexport function isElementInSubtree(\n target: EventTarget, container: EventTarget) {\n // Dispatch a composed, bubbling event to check its path to see if the\n // newly-focused element is contained in container's subtree\n const focusEv = new Event('md-contains', {bubbles: true, composed: true});\n let composedPath: EventTarget[] = [];\n const listener = (ev: Event) => {\n composedPath = ev.composedPath();\n };\n\n container.addEventListener('md-contains', listener);\n target.dispatchEvent(focusEv);\n container.removeEventListener('md-contains', listener);\n\n const isContained = composedPath.length > 0;\n return isContained;\n}\n"]}
|
|
@@ -6,18 +6,17 @@
|
|
|
6
6
|
import { Corner } from '../menu.js';
|
|
7
7
|
import { MenuItemEl } from '../menuitem/menu-item.js';
|
|
8
8
|
/**
|
|
9
|
-
* @fires deactivate-items
|
|
10
|
-
*
|
|
11
|
-
* @fires deactivate-typeahead
|
|
12
|
-
*
|
|
13
|
-
* @fires activate-typeahead
|
|
14
|
-
*
|
|
15
|
-
* @fires stay-open-on-focusout
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @fires close-on-focusout
|
|
19
|
-
*
|
|
20
|
-
* `relatedTarget` When submenu is closed.
|
|
9
|
+
* @fires deactivate-items Requests the parent menu to deselect other items when
|
|
10
|
+
* a submenu opens
|
|
11
|
+
* @fires deactivate-typeahead Requests the parent menu to deactivate the
|
|
12
|
+
* typeahead functionality when a submenu opens
|
|
13
|
+
* @fires activate-typeahead Requests the parent menu to activate the typeahead
|
|
14
|
+
* functionality when a submenu closes
|
|
15
|
+
* @fires stay-open-on-focusout Requests the parent menu to stay open when
|
|
16
|
+
* focusout event is fired or has a `null` `relatedTarget` when submenu is
|
|
17
|
+
* opened.
|
|
18
|
+
* @fires close-on-focusout Requests the parent menu to close when focusout
|
|
19
|
+
* event is fired or has a `null` `relatedTarget` When submenu is closed.
|
|
21
20
|
*/
|
|
22
21
|
export declare class SubMenuItem extends MenuItemEl {
|
|
23
22
|
/**
|
|
@@ -40,6 +39,7 @@ export declare class SubMenuItem extends MenuItemEl {
|
|
|
40
39
|
* Sets the item in the selected visual state when a submenu is opened.
|
|
41
40
|
*/
|
|
42
41
|
selected: boolean;
|
|
42
|
+
protected submenuHover: boolean;
|
|
43
43
|
private readonly menus;
|
|
44
44
|
protected keepOpenOnClick: boolean;
|
|
45
45
|
private previousOpenTimeout;
|
|
@@ -54,6 +54,14 @@ export declare class SubMenuItem extends MenuItemEl {
|
|
|
54
54
|
*/
|
|
55
55
|
protected onPointerleave: () => void;
|
|
56
56
|
protected onClick(): void;
|
|
57
|
+
protected getRenderClasses(): {
|
|
58
|
+
'submenu-hover': boolean;
|
|
59
|
+
'has-focus-ring': boolean;
|
|
60
|
+
'with-one-line': boolean;
|
|
61
|
+
'with-two-line': boolean;
|
|
62
|
+
'with-three-line': boolean;
|
|
63
|
+
disabled: boolean;
|
|
64
|
+
};
|
|
57
65
|
/**
|
|
58
66
|
* On item keydown handles opening the submenu.
|
|
59
67
|
*/
|
|
@@ -96,4 +104,6 @@ export declare class SubMenuItem extends MenuItemEl {
|
|
|
96
104
|
* @return Whether or not the key code should close the submenu.
|
|
97
105
|
*/
|
|
98
106
|
private isSubmenuCloseKey;
|
|
107
|
+
private onSubmenuPointerEnter;
|
|
108
|
+
private onSubmenuPointerLeave;
|
|
99
109
|
}
|
|
@@ -5,26 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { html } from 'lit';
|
|
8
|
-
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
8
|
+
import { property, queryAssignedElements, state } from 'lit/decorators.js';
|
|
9
9
|
import { List } from '../../../list/internal/list.js';
|
|
10
10
|
import { MenuItemEl } from '../menuitem/menu-item.js';
|
|
11
|
-
import {
|
|
11
|
+
import { CLOSE_REASON, createActivateTypeaheadEvent, createCloseOnFocusoutEvent, createDeactivateItemsEvent, createDeactivateTypeaheadEvent, createStayOpenOnFocusoutEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY } from '../shared.js';
|
|
12
12
|
function stopPropagation(event) {
|
|
13
13
|
event.stopPropagation();
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @fires deactivate-items
|
|
17
|
-
*
|
|
18
|
-
* @fires deactivate-typeahead
|
|
19
|
-
*
|
|
20
|
-
* @fires activate-typeahead
|
|
21
|
-
*
|
|
22
|
-
* @fires stay-open-on-focusout
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @fires close-on-focusout
|
|
26
|
-
*
|
|
27
|
-
* `relatedTarget` When submenu is closed.
|
|
16
|
+
* @fires deactivate-items Requests the parent menu to deselect other items when
|
|
17
|
+
* a submenu opens
|
|
18
|
+
* @fires deactivate-typeahead Requests the parent menu to deactivate the
|
|
19
|
+
* typeahead functionality when a submenu opens
|
|
20
|
+
* @fires activate-typeahead Requests the parent menu to activate the typeahead
|
|
21
|
+
* functionality when a submenu closes
|
|
22
|
+
* @fires stay-open-on-focusout Requests the parent menu to stay open when
|
|
23
|
+
* focusout event is fired or has a `null` `relatedTarget` when submenu is
|
|
24
|
+
* opened.
|
|
25
|
+
* @fires close-on-focusout Requests the parent menu to close when focusout
|
|
26
|
+
* event is fired or has a `null` `relatedTarget` When submenu is closed.
|
|
28
27
|
*/
|
|
29
28
|
export class SubMenuItem extends MenuItemEl {
|
|
30
29
|
constructor() {
|
|
@@ -49,6 +48,7 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
49
48
|
* Sets the item in the selected visual state when a submenu is opened.
|
|
50
49
|
*/
|
|
51
50
|
this.selected = false;
|
|
51
|
+
this.submenuHover = false;
|
|
52
52
|
this.keepOpenOnClick = true;
|
|
53
53
|
this.previousOpenTimeout = 0;
|
|
54
54
|
this.previousCloseTimeout = 0;
|
|
@@ -95,6 +95,9 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
95
95
|
onClick() {
|
|
96
96
|
this.show();
|
|
97
97
|
}
|
|
98
|
+
getRenderClasses() {
|
|
99
|
+
return { ...super.getRenderClasses(), 'submenu-hover': this.submenuHover };
|
|
100
|
+
}
|
|
98
101
|
/**
|
|
99
102
|
* On item keydown handles opening the submenu.
|
|
100
103
|
*/
|
|
@@ -132,6 +135,8 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
132
135
|
renderSubMenu() {
|
|
133
136
|
return html `<span class="submenu"><slot
|
|
134
137
|
name="submenu"
|
|
138
|
+
@pointerenter=${this.onSubmenuPointerEnter}
|
|
139
|
+
@pointerleave=${this.onSubmenuPointerLeave}
|
|
135
140
|
@pointerdown=${stopPropagation}
|
|
136
141
|
@click=${stopPropagation}
|
|
137
142
|
@keydown=${this.onSubMenuKeydown}
|
|
@@ -139,14 +144,15 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
139
144
|
></slot></span>`;
|
|
140
145
|
}
|
|
141
146
|
onCloseSubmenu(event) {
|
|
142
|
-
event.
|
|
147
|
+
const { itemPath, reason } = event.detail;
|
|
148
|
+
itemPath.push(this);
|
|
143
149
|
// Restore focusout behavior
|
|
144
|
-
this.dispatchEvent(
|
|
145
|
-
this.dispatchEvent(
|
|
150
|
+
this.dispatchEvent(createCloseOnFocusoutEvent());
|
|
151
|
+
this.dispatchEvent(createActivateTypeaheadEvent());
|
|
146
152
|
// Escape should only close one menu not all of the menus unlike space or
|
|
147
153
|
// click selection which should close all menus.
|
|
148
|
-
if (
|
|
149
|
-
|
|
154
|
+
if (reason.kind === CLOSE_REASON.KEYDOWN &&
|
|
155
|
+
reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
|
|
150
156
|
event.stopPropagation();
|
|
151
157
|
this.active = true;
|
|
152
158
|
this.selected = false;
|
|
@@ -200,12 +206,12 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
200
206
|
// has a submenuitem hovered which opens a third submenut. Then if you hover
|
|
201
207
|
// on yet another middle menu-item (not submenuitem) then focusout Event's
|
|
202
208
|
// relatedTarget will be `null` thus, causing all the menus to close
|
|
203
|
-
this.dispatchEvent(
|
|
209
|
+
this.dispatchEvent(createStayOpenOnFocusoutEvent());
|
|
204
210
|
menu.show();
|
|
205
211
|
// Deactivate other items. This can be the case if the user has tabbed
|
|
206
212
|
// around the menu and then mouses over an md-sub-menu.
|
|
207
|
-
this.dispatchEvent(
|
|
208
|
-
this.dispatchEvent(
|
|
213
|
+
this.dispatchEvent(createDeactivateItemsEvent());
|
|
214
|
+
this.dispatchEvent(createDeactivateTypeaheadEvent());
|
|
209
215
|
this.selected = true;
|
|
210
216
|
// This is the case of mouse hovering when already opened via keyboard or
|
|
211
217
|
// vice versa
|
|
@@ -225,11 +231,11 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
225
231
|
const menu = this.submenuEl;
|
|
226
232
|
if (!menu || !menu.open)
|
|
227
233
|
return;
|
|
228
|
-
this.dispatchEvent(
|
|
234
|
+
this.dispatchEvent(createActivateTypeaheadEvent());
|
|
229
235
|
menu.quick = true;
|
|
230
236
|
menu.close();
|
|
231
237
|
// Restore focusout behavior.
|
|
232
|
-
this.dispatchEvent(
|
|
238
|
+
this.dispatchEvent(createCloseOnFocusoutEvent());
|
|
233
239
|
this.active = false;
|
|
234
240
|
this.selected = false;
|
|
235
241
|
menu.addEventListener('closed', onClosed, { once: true });
|
|
@@ -271,6 +277,12 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
271
277
|
return false;
|
|
272
278
|
}
|
|
273
279
|
}
|
|
280
|
+
onSubmenuPointerEnter() {
|
|
281
|
+
this.submenuHover = true;
|
|
282
|
+
}
|
|
283
|
+
onSubmenuPointerLeave() {
|
|
284
|
+
this.submenuHover = false;
|
|
285
|
+
}
|
|
274
286
|
}
|
|
275
287
|
__decorate([
|
|
276
288
|
property({ attribute: 'anchor-corner' })
|
|
@@ -287,6 +299,9 @@ __decorate([
|
|
|
287
299
|
__decorate([
|
|
288
300
|
property({ type: Boolean, reflect: true })
|
|
289
301
|
], SubMenuItem.prototype, "selected", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
state()
|
|
304
|
+
], SubMenuItem.prototype, "submenuHover", void 0);
|
|
290
305
|
__decorate([
|
|
291
306
|
queryAssignedElements({ slot: 'submenu', flatten: true })
|
|
292
307
|
], SubMenuItem.prototype, "menus", void 0);
|