@material/web 1.0.0-pre.7 → 1.0.0-pre.8
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 +3 -3
- package/aria/aria.js +37 -13
- package/aria/aria.js.map +1 -1
- package/aria/delegate.d.ts +1 -1
- package/aria/delegate.js +1 -1
- package/aria/delegate.js.map +1 -1
- package/badge/lib/badge.d.ts +0 -3
- package/badge/lib/badge.js +4 -6
- package/badge/lib/badge.js.map +1 -1
- package/button/lib/_elevated-button.scss +35 -6
- package/button/lib/_filled-button.scss +35 -3
- package/button/lib/_outlined-button.scss +35 -6
- package/button/lib/_shared.scss +4 -2
- package/button/lib/_text-button.scss +35 -6
- package/button/lib/_tonal-button.scss +34 -7
- package/button/lib/button.d.ts +23 -26
- package/button/lib/button.js +12 -30
- package/button/lib/button.js.map +1 -1
- package/button/lib/elevated-button.d.ts +6 -4
- package/button/lib/elevated-button.js.map +1 -1
- package/button/lib/elevated-styles.css.js +1 -1
- package/button/lib/elevated-styles.css.js.map +1 -1
- package/button/lib/filled-button.d.ts +6 -4
- package/button/lib/filled-button.js.map +1 -1
- package/button/lib/filled-styles.css.js +1 -1
- package/button/lib/filled-styles.css.js.map +1 -1
- package/button/lib/outlined-button.d.ts +6 -4
- package/button/lib/outlined-button.js.map +1 -1
- package/button/lib/outlined-styles.css.js +1 -1
- package/button/lib/outlined-styles.css.js.map +1 -1
- package/button/lib/shared-styles.css.js +1 -1
- package/button/lib/shared-styles.css.js.map +1 -1
- package/button/lib/text-button.d.ts +5 -2
- package/button/lib/text-button.js.map +1 -1
- package/button/lib/text-styles.css.js +1 -1
- package/button/lib/text-styles.css.js.map +1 -1
- package/button/lib/tonal-button.d.ts +6 -4
- package/button/lib/tonal-button.js.map +1 -1
- package/button/lib/tonal-styles.css.js +1 -1
- package/button/lib/tonal-styles.css.js.map +1 -1
- package/checkbox/lib/_checkbox.scss +48 -47
- package/checkbox/lib/checkbox-styles.css.js +1 -1
- package/checkbox/lib/checkbox-styles.css.js.map +1 -1
- package/checkbox/lib/checkbox.d.ts +2 -6
- package/checkbox/lib/checkbox.js +3 -20
- package/checkbox/lib/checkbox.js.map +1 -1
- package/checkbox/lib/forced-colors-styles.css.js +1 -1
- package/checkbox/lib/forced-colors-styles.css.js.map +1 -1
- package/chips/assist-chip.js +2 -1
- package/chips/assist-chip.js.map +1 -1
- package/chips/filter-chip.js +2 -1
- package/chips/filter-chip.js.map +1 -1
- package/chips/lib/_assist-chip.scss +37 -3
- package/chips/lib/_elevated.scss +60 -0
- package/chips/lib/_filter-chip.scss +43 -9
- package/chips/lib/_shared.scss +36 -76
- package/chips/lib/_suggestion-chip.scss +36 -5
- package/chips/lib/assist-chip.d.ts +12 -0
- package/chips/lib/assist-chip.js +64 -0
- package/chips/lib/assist-chip.js.map +1 -1
- package/chips/lib/assist-styles.css.js +1 -1
- package/chips/lib/assist-styles.css.js.map +1 -1
- package/chips/lib/chip.d.ts +19 -16
- package/chips/lib/chip.js +43 -63
- package/chips/lib/chip.js.map +1 -1
- package/chips/lib/elevated-styles.css.d.ts +1 -0
- package/chips/lib/elevated-styles.css.js +9 -0
- package/chips/lib/elevated-styles.css.js.map +1 -0
- package/chips/lib/elevated-styles.scss +10 -0
- package/chips/lib/filter-chip.d.ts +6 -1
- package/chips/lib/filter-chip.js +38 -5
- package/chips/lib/filter-chip.js.map +1 -1
- package/chips/lib/filter-styles.css.js +1 -1
- package/chips/lib/filter-styles.css.js.map +1 -1
- package/chips/lib/shared-styles.css.js +1 -1
- package/chips/lib/shared-styles.css.js.map +1 -1
- package/chips/lib/suggestion-chip.d.ts +2 -2
- package/chips/lib/suggestion-chip.js +4 -2
- package/chips/lib/suggestion-chip.js.map +1 -1
- package/chips/lib/suggestion-styles.css.js +1 -1
- package/chips/lib/suggestion-styles.css.js.map +1 -1
- package/chips/suggestion-chip.js +2 -1
- package/chips/suggestion-chip.js.map +1 -1
- package/circularprogress/lib/_circular-progress.scss +13 -7
- package/circularprogress/lib/circular-progress-styles.css.js +1 -1
- package/circularprogress/lib/circular-progress-styles.css.js.map +1 -1
- package/circularprogress/lib/circular-progress.d.ts +5 -6
- package/circularprogress/lib/circular-progress.js +1 -2
- package/circularprogress/lib/circular-progress.js.map +1 -1
- package/dialog/lib/_dialog.scss +0 -1
- package/dialog/lib/_tokens.scss +0 -1
- package/dialog/lib/dialog.d.ts +10 -10
- package/dialog/lib/dialog.js +8 -7
- package/dialog/lib/dialog.js.map +1 -1
- package/elevation/lib/elevation.d.ts +1 -1
- package/elevation/lib/elevation.js.map +1 -1
- package/fab/branded-fab.d.ts +3 -0
- package/fab/lib/_fab-branded.scss +58 -4
- package/fab/lib/_fab.scss +80 -6
- package/fab/lib/_shared.scss +8 -3
- package/fab/lib/fab-branded-styles.css.js +1 -1
- package/fab/lib/fab-branded-styles.css.js.map +1 -1
- package/fab/lib/fab-styles.css.js +1 -1
- package/fab/lib/fab-styles.css.js.map +1 -1
- package/fab/lib/fab.d.ts +4 -0
- package/fab/lib/forced-colors-styles.css.js +1 -1
- package/fab/lib/forced-colors-styles.css.js.map +1 -1
- package/fab/lib/shared-styles.css.js +1 -1
- package/fab/lib/shared-styles.css.js.map +1 -1
- package/fab/lib/shared.d.ts +12 -15
- package/fab/lib/shared.js +2 -26
- package/fab/lib/shared.js.map +1 -1
- package/field/lib/_filled-field.scss +47 -12
- package/field/lib/_outlined-field.scss +39 -12
- package/field/lib/filled-styles.css.js +1 -1
- package/field/lib/filled-styles.css.js.map +1 -1
- package/field/lib/outlined-styles.css.js +1 -1
- package/field/lib/outlined-styles.css.js.map +1 -1
- package/focus/focus-ring.d.ts +2 -0
- package/focus/focus-ring.js +2 -0
- package/focus/focus-ring.js.map +1 -1
- package/focus/lib/_focus-ring.scss +49 -34
- package/focus/lib/focus-ring-styles.css.js +1 -1
- package/focus/lib/focus-ring-styles.css.js.map +1 -1
- package/focus/lib/focus-ring.d.ts +59 -12
- package/focus/lib/focus-ring.js +116 -11
- package/focus/lib/focus-ring.js.map +1 -1
- package/iconbutton/filled-icon-button.d.ts +6 -2
- package/iconbutton/filled-icon-button.js.map +1 -1
- package/iconbutton/filled-tonal-icon-button.d.ts +6 -2
- package/iconbutton/filled-tonal-icon-button.js.map +1 -1
- package/iconbutton/harness.d.ts +1 -1
- package/iconbutton/harness.js +4 -1
- package/iconbutton/harness.js.map +1 -1
- package/iconbutton/lib/_filled-icon-button.scss +38 -13
- package/iconbutton/lib/_filled-tonal-icon-button.scss +38 -11
- package/iconbutton/lib/_outlined-icon-button.scss +38 -13
- package/iconbutton/lib/_shared.scss +4 -6
- package/iconbutton/lib/_standard-icon-button.scss +14 -14
- package/iconbutton/lib/filled-styles.css.js +1 -1
- package/iconbutton/lib/filled-styles.css.js.map +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
- package/iconbutton/lib/icon-button.d.ts +17 -21
- package/iconbutton/lib/icon-button.js +12 -28
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/iconbutton/lib/outlined-styles.css.js +1 -1
- package/iconbutton/lib/outlined-styles.css.js.map +1 -1
- package/iconbutton/lib/shared-styles.css.js +1 -1
- package/iconbutton/lib/shared-styles.css.js.map +1 -1
- package/iconbutton/lib/standard-styles.css.js +1 -1
- package/iconbutton/lib/standard-styles.css.js.map +1 -1
- package/iconbutton/outlined-icon-button.d.ts +5 -2
- package/iconbutton/outlined-icon-button.js.map +1 -1
- package/iconbutton/standard-icon-button.d.ts +5 -2
- package/iconbutton/standard-icon-button.js.map +1 -1
- package/linearprogress/lib/_linear-progress.scss +78 -72
- package/linearprogress/lib/linear-progress.d.ts +5 -5
- package/linearprogress/lib/linear-progress.js +1 -1
- package/linearprogress/lib/linear-progress.js.map +1 -1
- package/list/lib/_list.scss +4 -2
- package/list/lib/list.d.ts +7 -12
- package/list/lib/list.js +2 -11
- package/list/lib/list.js.map +1 -1
- package/list/lib/listitem/_list-item.scss +8 -4
- package/list/lib/listitem/list-item-styles.css.js +1 -1
- package/list/lib/listitem/list-item-styles.css.js.map +1 -1
- package/list/lib/listitem/list-item.d.ts +27 -27
- package/list/lib/listitem/list-item.js +4 -29
- package/list/lib/listitem/list-item.js.map +1 -1
- package/list/lib/listitemlink/list-item-link.js +1 -3
- package/list/lib/listitemlink/list-item-link.js.map +1 -1
- package/menu/lib/_menu.scss +4 -2
- package/menu/lib/menu-styles.css.js +1 -1
- package/menu/lib/menu-styles.css.js.map +1 -1
- package/menu/lib/menu.d.ts +31 -39
- package/menu/lib/menu.js +14 -20
- package/menu/lib/menu.js.map +1 -1
- package/menu/lib/menuitem/_menu-item.scss +4 -2
- package/menu/lib/shared.d.ts +14 -0
- package/menu/lib/shared.js +18 -0
- package/menu/lib/shared.js.map +1 -1
- package/menu/lib/submenuitem/sub-menu-item.d.ts +16 -11
- package/menu/lib/submenuitem/sub-menu-item.js +20 -3
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
- package/menu/lib/typeaheadController.d.ts +9 -9
- package/menu/lib/typeaheadController.js.map +1 -1
- package/navigationbar/lib/navigation-bar.d.ts +2 -2
- package/navigationbar/lib/navigation-bar.js.map +1 -1
- package/navigationdrawer/lib/_navigation-drawer-modal.scss +0 -3
- package/navigationdrawer/lib/_navigation-drawer.scss +0 -3
- package/navigationdrawer/lib/_shared.scss +1 -4
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal.d.ts +3 -3
- package/navigationdrawer/lib/navigation-drawer-modal.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer.d.ts +2 -2
- package/navigationdrawer/lib/navigation-drawer.js.map +1 -1
- package/navigationdrawer/lib/shared-styles.css.js +1 -1
- package/navigationdrawer/lib/shared-styles.css.js.map +1 -1
- package/navigationtab/lib/_navigation-tab.scss +2 -2
- package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
- package/navigationtab/lib/navigation-tab.d.ts +9 -17
- package/navigationtab/lib/navigation-tab.js +3 -22
- package/navigationtab/lib/navigation-tab.js.map +1 -1
- package/navigationtab/lib/state.d.ts +1 -1
- package/navigationtab/lib/state.js.map +1 -1
- package/package.json +1 -1
- package/radio/lib/_radio.scss +1 -1
- package/radio/lib/radio-styles.css.js +1 -1
- package/radio/lib/radio-styles.css.js.map +1 -1
- package/radio/lib/radio.d.ts +2 -7
- package/radio/lib/radio.js +2 -22
- package/radio/lib/radio.js.map +1 -1
- package/ripple/lib/ripple.js +4 -0
- package/ripple/lib/ripple.js.map +1 -1
- package/segmentedbutton/lib/segmented-button.d.ts +15 -21
- package/segmentedbutton/lib/segmented-button.js +3 -24
- package/segmentedbutton/lib/segmented-button.js.map +1 -1
- package/segmentedbuttonset/lib/_outlined-segmented-button-set.scss +32 -13
- package/segmentedbuttonset/lib/outlined-styles.css.js +1 -1
- package/segmentedbuttonset/lib/outlined-styles.css.js.map +1 -1
- package/segmentedbuttonset/lib/segmented-button-set.d.ts +1 -1
- package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
- package/select/lib/_filled-select.scss +66 -7
- package/select/lib/_outlined-select.scss +41 -7
- package/select/lib/filled-select-styles.css.js +1 -1
- package/select/lib/filled-select-styles.css.js.map +1 -1
- package/select/lib/outlined-select-styles.css.js +1 -1
- package/select/lib/outlined-select-styles.css.js.map +1 -1
- package/select/lib/select.d.ts +46 -48
- package/select/lib/select.js +21 -19
- package/select/lib/select.js.map +1 -1
- package/slider/harness.d.ts +1 -1
- package/slider/harness.js +9 -9
- package/slider/harness.js.map +1 -1
- package/slider/lib/_slider.scss +6 -6
- package/slider/lib/slider-styles.css.js +1 -1
- package/slider/lib/slider-styles.css.js.map +1 -1
- package/slider/lib/slider.d.ts +22 -51
- package/slider/lib/slider.js +18 -54
- package/slider/lib/slider.js.map +1 -1
- package/switch/lib/_switch.scss +63 -18
- package/switch/lib/switch-styles.css.js +1 -1
- package/switch/lib/switch-styles.css.js.map +1 -1
- package/switch/lib/switch.d.ts +0 -5
- package/switch/lib/switch.js +2 -27
- package/switch/lib/switch.js.map +1 -1
- package/textfield/harness.d.ts +1 -1
- package/textfield/harness.js.map +1 -1
- package/textfield/lib/_filled-text-field.scss +70 -14
- package/textfield/lib/_outlined-text-field.scss +60 -35
- package/textfield/lib/filled-forced-colors-styles.css.js +1 -1
- package/textfield/lib/filled-forced-colors-styles.css.js.map +1 -1
- package/textfield/lib/filled-styles.css.js +1 -1
- package/textfield/lib/filled-styles.css.js.map +1 -1
- package/textfield/lib/outlined-forced-colors-styles.css.js +1 -1
- package/textfield/lib/outlined-forced-colors-styles.css.js.map +1 -1
- package/textfield/lib/outlined-styles.css.js +1 -1
- package/textfield/lib/outlined-styles.css.js.map +1 -1
- package/textfield/lib/text-field.d.ts +1 -1
- package/textfield/lib/text-field.js.map +1 -1
- package/tokens/_index.scss +2 -18
- package/tokens/_md-comp-assist-chip.scss +0 -9
- package/tokens/_md-comp-checkbox.scss +78 -1
- package/tokens/_md-comp-circular-progress-indicator.scss +39 -13
- package/tokens/_md-comp-elevated-button.scss +0 -10
- package/tokens/_md-comp-fab-branded.scss +6 -31
- package/tokens/_md-comp-fab.scss +9 -50
- package/tokens/_md-comp-filled-button.scss +0 -10
- package/{field/lib → tokens}/_md-comp-filled-field.scss +91 -9
- package/tokens/_md-comp-filled-icon-button.scss +46 -1
- package/tokens/_md-comp-filled-select.scss +4 -30
- package/tokens/_md-comp-filled-text-field.scss +93 -9
- package/tokens/_md-comp-filled-tonal-button.scss +0 -11
- package/tokens/_md-comp-filled-tonal-icon-button.scss +45 -3
- package/tokens/_md-comp-filter-chip.scss +0 -10
- package/tokens/_md-comp-focus-ring.scss +23 -24
- package/tokens/_md-comp-icon-button.scss +37 -1
- package/tokens/_md-comp-input-chip.scss +0 -10
- package/tokens/_md-comp-linear-progress-indicator.scss +23 -8
- package/tokens/_md-comp-list-item.scss +0 -27
- package/tokens/_md-comp-list.scss +3 -29
- package/tokens/_md-comp-menu-item.scss +3 -29
- package/tokens/_md-comp-menu.scss +0 -23
- package/tokens/_md-comp-outlined-button.scss +0 -10
- package/{field/lib → tokens}/_md-comp-outlined-field.scss +85 -9
- package/tokens/_md-comp-outlined-icon-button.scss +41 -1
- package/tokens/_md-comp-outlined-segmented-button.scss +57 -11
- package/tokens/_md-comp-outlined-select.scss +1 -28
- package/tokens/_md-comp-outlined-text-field.scss +85 -8
- package/tokens/_md-comp-suggestion-chip.scss +0 -9
- package/tokens/_md-comp-switch.scss +81 -1
- package/tokens/_md-comp-text-button.scss +0 -10
- package/tokens/_values.scss +2 -7
- package/types/aria.d.ts +0 -2
- package/focus/strong-focus.d.ts +0 -56
- package/focus/strong-focus.js +0 -101
- package/focus/strong-focus.js.map +0 -1
- package/sass/_shape.scss +0 -154
- package/tokens/_md-comp-extended-fab-branded.scss +0 -45
- package/tokens/_md-comp-extended-fab-primary.scss +0 -45
- package/tokens/_md-comp-extended-fab-secondary.scss +0 -48
- package/tokens/_md-comp-extended-fab-surface.scss +0 -45
- package/tokens/_md-comp-extended-fab-tertiary.scss +0 -48
- package/tokens/_md-comp-fab-branded-large.scss +0 -23
- package/tokens/_md-comp-fab-primary-large.scss +0 -23
- package/tokens/_md-comp-fab-primary-small.scss +0 -23
- package/tokens/_md-comp-fab-primary.scss +0 -23
- package/tokens/_md-comp-fab-secondary-large.scss +0 -23
- package/tokens/_md-comp-fab-secondary-small.scss +0 -23
- package/tokens/_md-comp-fab-secondary.scss +0 -23
- package/tokens/_md-comp-fab-surface-large.scss +0 -23
- package/tokens/_md-comp-fab-surface-small.scss +0 -23
- package/tokens/_md-comp-fab-surface.scss +0 -23
- package/tokens/_md-comp-fab-tertiary-large.scss +0 -23
- package/tokens/_md-comp-fab-tertiary-small.scss +0 -23
- package/tokens/_md-comp-fab-tertiary.scss +0 -23
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import '../../../ripple/ripple.js';
|
|
7
7
|
import '../../../focus/focus-ring.js';
|
|
8
|
-
import { LitElement,
|
|
9
|
-
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
8
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
10
9
|
import { MdRipple } from '../../../ripple/ripple.js';
|
|
11
10
|
import { ARIARole } from '../../../types/aria.js';
|
|
12
11
|
interface ListItemSelf {
|
|
@@ -59,71 +58,72 @@ export declare class ListItemEl extends LitElement implements ListItem {
|
|
|
59
58
|
* READONLY. Sets the `md-list-item` attribute on the element.
|
|
60
59
|
*/
|
|
61
60
|
isListItem: boolean;
|
|
62
|
-
|
|
63
|
-
protected listItemRoot: HTMLElement;
|
|
61
|
+
private readonly ripple;
|
|
62
|
+
protected readonly listItemRoot: HTMLElement | null;
|
|
64
63
|
protected readonly listItemRole: ARIARole;
|
|
65
|
-
|
|
66
|
-
protected showRipple: boolean;
|
|
64
|
+
private showRipple;
|
|
67
65
|
/**
|
|
68
66
|
* Only meant to be overriden by subclassing and not by the user. This is
|
|
69
67
|
* so that we have control over focus on specific variants such as disabling
|
|
70
68
|
* focus on <md-autocomplete-item> but enabling it for <md-menu-item>.
|
|
71
69
|
*/
|
|
72
70
|
protected focusOnActivation: boolean;
|
|
73
|
-
protected getRipple: () => Promise<MdRipple>;
|
|
71
|
+
protected readonly getRipple: () => Promise<MdRipple>;
|
|
74
72
|
private isFirstUpdate;
|
|
75
|
-
willUpdate(changed: PropertyValues<this>): void;
|
|
76
|
-
render(): TemplateResult
|
|
73
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
74
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
77
75
|
/**
|
|
78
76
|
* Renders the root list item.
|
|
79
77
|
*
|
|
80
78
|
* @param content {unkown} the child content of the list item.
|
|
81
79
|
*/
|
|
82
|
-
protected renderListItem(content: unknown): TemplateResult<1>;
|
|
80
|
+
protected renderListItem(content: unknown): import("lit-html").TemplateResult<1>;
|
|
83
81
|
/**
|
|
84
82
|
* Handles rendering of the ripple element.
|
|
85
83
|
*/
|
|
86
|
-
|
|
84
|
+
private renderRipple;
|
|
87
85
|
/**
|
|
88
86
|
* Handles rendering of the focus ring.
|
|
89
87
|
*/
|
|
90
|
-
|
|
88
|
+
private renderFocusRing;
|
|
91
89
|
/**
|
|
92
90
|
* Classes applied to the list item root.
|
|
93
91
|
*/
|
|
94
|
-
protected getRenderClasses():
|
|
92
|
+
protected getRenderClasses(): {
|
|
93
|
+
'with-one-line': boolean;
|
|
94
|
+
'with-two-line': boolean;
|
|
95
|
+
'with-three-line': boolean;
|
|
96
|
+
disabled: boolean;
|
|
97
|
+
};
|
|
95
98
|
/**
|
|
96
99
|
* The content rendered at the start of the list item.
|
|
97
100
|
*/
|
|
98
|
-
|
|
101
|
+
private renderStart;
|
|
99
102
|
/**
|
|
100
103
|
* Handles rendering the headline and supporting text.
|
|
101
104
|
*/
|
|
102
|
-
|
|
105
|
+
private renderBody;
|
|
103
106
|
/**
|
|
104
107
|
* Renders the one-line supporting text.
|
|
105
108
|
*/
|
|
106
|
-
|
|
109
|
+
private renderSupportingText;
|
|
107
110
|
/**
|
|
108
111
|
* Gets the classes for the supporting text node
|
|
109
112
|
*/
|
|
110
|
-
|
|
113
|
+
private getSupportingTextClasses;
|
|
111
114
|
/**
|
|
112
115
|
* The content rendered at the end of the list item.
|
|
113
116
|
*/
|
|
114
|
-
protected renderEnd(): TemplateResult
|
|
117
|
+
protected renderEnd(): import("lit-html").TemplateResult<1>;
|
|
115
118
|
/**
|
|
116
119
|
* Renders the supporting text at the end of the list item.
|
|
117
120
|
*/
|
|
118
|
-
|
|
119
|
-
protected
|
|
120
|
-
protected
|
|
121
|
-
protected
|
|
122
|
-
protected
|
|
123
|
-
protected
|
|
124
|
-
protected onPointerenter(e: Event): void;
|
|
125
|
-
protected onPointerleave(e: Event): void;
|
|
126
|
-
updated(changed: PropertyValues<this>): void;
|
|
121
|
+
private renderTrailingSupportingText;
|
|
122
|
+
protected onClick?(event: Event): void;
|
|
123
|
+
protected onKeydown?(event: KeyboardEvent): void;
|
|
124
|
+
protected onPointerenter?(event: Event): void;
|
|
125
|
+
protected onPointerleave?(event: Event): void;
|
|
126
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
127
127
|
focus(): void;
|
|
128
128
|
}
|
|
129
129
|
export {};
|
|
@@ -11,7 +11,6 @@ import { html, LitElement, nothing } from 'lit';
|
|
|
11
11
|
import { property, query, queryAsync, state } from 'lit/decorators.js';
|
|
12
12
|
import { classMap } from 'lit/directives/class-map.js';
|
|
13
13
|
import { requestUpdateOnAriaChange } from '../../../aria/delegate.js';
|
|
14
|
-
import { pointerPress, shouldShowStrongFocus } from '../../../focus/strong-focus.js';
|
|
15
14
|
import { ripple } from '../../../ripple/directive.js';
|
|
16
15
|
// tslint:disable-next-line:enforce-comments-on-exported-symbols
|
|
17
16
|
export class ListItemEl extends LitElement {
|
|
@@ -58,7 +57,6 @@ export class ListItemEl extends LitElement {
|
|
|
58
57
|
*/
|
|
59
58
|
this.isListItem = true;
|
|
60
59
|
this.listItemRole = 'listitem';
|
|
61
|
-
this.showFocusRing = false;
|
|
62
60
|
this.showRipple = false;
|
|
63
61
|
/**
|
|
64
62
|
* Only meant to be overriden by subclassing and not by the user. This is
|
|
@@ -76,13 +74,10 @@ export class ListItemEl extends LitElement {
|
|
|
76
74
|
if (changed.has('active') && !this.disabled) {
|
|
77
75
|
if (this.active) {
|
|
78
76
|
this.itemTabIndex = 0;
|
|
79
|
-
if (this.focusOnActivation) {
|
|
80
|
-
this.showFocusRing = shouldShowStrongFocus();
|
|
81
|
-
}
|
|
82
|
-
// Do not reset anything if it's the first render because user could
|
|
83
|
-
// have set `itemTabIndex` manually.
|
|
84
77
|
}
|
|
85
78
|
else if (!this.isFirstUpdate) {
|
|
79
|
+
// Do not reset anything if it's the first render because user could
|
|
80
|
+
// have set `itemTabIndex` manually.
|
|
86
81
|
this.itemTabIndex = -1;
|
|
87
82
|
}
|
|
88
83
|
}
|
|
@@ -105,14 +100,12 @@ export class ListItemEl extends LitElement {
|
|
|
105
100
|
renderListItem(content) {
|
|
106
101
|
return html `
|
|
107
102
|
<li
|
|
103
|
+
id="item"
|
|
108
104
|
tabindex=${this.disabled ? -1 : this.itemTabIndex}
|
|
109
105
|
role=${this.listItemRole}
|
|
110
106
|
aria-selected=${this.ariaSelected || nothing}
|
|
111
107
|
aria-checked=${this.ariaChecked || nothing}
|
|
112
108
|
class="list-item ${classMap(this.getRenderClasses())}"
|
|
113
|
-
@pointerdown=${this.onPointerdown}
|
|
114
|
-
@focus=${this.onFocus}
|
|
115
|
-
@blur=${this.onBlur}
|
|
116
109
|
@click=${this.onClick}
|
|
117
110
|
@pointerenter=${this.onPointerenter}
|
|
118
111
|
@pointerleave=${this.onPointerleave}
|
|
@@ -131,7 +124,7 @@ export class ListItemEl extends LitElement {
|
|
|
131
124
|
* Handles rendering of the focus ring.
|
|
132
125
|
*/
|
|
133
126
|
renderFocusRing() {
|
|
134
|
-
return html `<md-focus-ring class="focus-ring"
|
|
127
|
+
return html `<md-focus-ring class="focus-ring" for="item"></md-focus-ring>`;
|
|
135
128
|
}
|
|
136
129
|
/**
|
|
137
130
|
* Classes applied to the list item root.
|
|
@@ -189,21 +182,6 @@ export class ListItemEl extends LitElement {
|
|
|
189
182
|
return html `<span class="trailing-supporting-text"
|
|
190
183
|
>${this.trailingSupportingText}</span>`;
|
|
191
184
|
}
|
|
192
|
-
onPointerdown() {
|
|
193
|
-
pointerPress();
|
|
194
|
-
this.showFocusRing = shouldShowStrongFocus();
|
|
195
|
-
}
|
|
196
|
-
onFocus() {
|
|
197
|
-
this.showFocusRing = shouldShowStrongFocus();
|
|
198
|
-
}
|
|
199
|
-
onBlur() {
|
|
200
|
-
this.showFocusRing = false;
|
|
201
|
-
}
|
|
202
|
-
// For easier overriding in menu-item
|
|
203
|
-
onClick(e) { }
|
|
204
|
-
onKeydown(e) { }
|
|
205
|
-
onPointerenter(e) { }
|
|
206
|
-
onPointerleave(e) { }
|
|
207
185
|
updated(changed) {
|
|
208
186
|
super.updated(changed);
|
|
209
187
|
// will focus the list item root if it is selected but not on the first
|
|
@@ -252,9 +230,6 @@ __decorate([
|
|
|
252
230
|
__decorate([
|
|
253
231
|
query('.list-item')
|
|
254
232
|
], ListItemEl.prototype, "listItemRoot", void 0);
|
|
255
|
-
__decorate([
|
|
256
|
-
state()
|
|
257
|
-
], ListItemEl.prototype, "showFocusRing", void 0);
|
|
258
233
|
__decorate([
|
|
259
234
|
state()
|
|
260
235
|
], ListItemEl.prototype, "showRipple", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-item.js","sourceRoot":"","sources":["list-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAiC,MAAM,KAAK,CAAC;AAC9E,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAepD,gEAAgE;AAChE,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QAKE;;WAEG;QACS,aAAQ,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACS,mBAAc,GAAG,EAAE,CAAC;QAEhC;;WAEG;QACwB,4BAAuB,GAAG,KAAK,CAAC;QAE3D;;;WAGG;QACS,2BAAsB,GAA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;QAEvB,uEAAuE;QACvE,8DAA8D;QAC9D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,iBAAiB,EAAE;YAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;SACd;QAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC7B,CAAC;IAEQ,KAAK;QACZ,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC;IAC/B,CAAC;CACF;;AApPC;IACE,yBAAyB,CAAC,EAAI,CAAC,CAAC;AAClC,CAAC,GAAA,CAAA;AAKW;IAAX,QAAQ,EAAE;4CAAe;AAOd;IAAX,QAAQ,EAAE;kDAAqB;AAKL;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;2DAAiC;AAM/C;IAAX,QAAQ,EAAE;0DAA6B;AAKb;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;4CAAkB;AAQlB;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;gDAAmB;AAOF;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;0CAAgB;AAMzD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;8CAClD;AAEO;IAAxB,UAAU,CAAC,WAAW,CAAC;0CAA2C;AAC9C;IAApB,KAAK,CAAC,YAAY,CAAC;gDAAsC;AAGjD;IAAR,KAAK,EAAE;iDAAiC;AAChC;IAAR,KAAK,EAAE;8CAA8B","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../ripple/ripple.js';\nimport '../../../focus/focus-ring.js';\n\nimport {html, LitElement, nothing, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, queryAsync, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\n\nimport {requestUpdateOnAriaChange} from '../../../aria/delegate.js';\nimport {pointerPress, shouldShowStrongFocus} from '../../../focus/strong-focus.js';\nimport {ripple} from '../../../ripple/directive.js';\nimport {MdRipple} from '../../../ripple/ripple.js';\nimport {ARIAMixinStrict, ARIARole} from '../../../types/aria.js';\n\ninterface ListItemSelf {\n active: boolean;\n disabled: boolean;\n}\n\n/**\n * The interface of an item that is compatible with md-list. An item that is\n * selectable and disablable.\n */\nexport type ListItem = ListItemSelf&HTMLElement;\n\n// tslint:disable-next-line:enforce-comments-on-exported-symbols\nexport class ListItemEl extends LitElement implements ListItem {\n static {\n requestUpdateOnAriaChange(this);\n }\n\n /**\n * The primary, headline text of the list item.\n */\n @property() headline = '';\n\n /**\n * The one-line supporting text below the headline. Set\n * `multiLineSupportingText` to `true` to support multiple lines in the\n * supporting text.\n */\n @property() supportingText = '';\n\n /**\n * Modifies `supportingText` to support multiple lines.\n */\n @property({type: Boolean}) multiLineSupportingText = false;\n\n /**\n * The supporting text placed at the end of the item. Overriden by elements\n * slotted into the `end` slot.\n */\n @property() trailingSupportingText = '';\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({type: Boolean}) disabled = false;\n\n /**\n * The tabindex of the underlying item.\n *\n * __NOTE:__ this is overriden by the keyboard behavior of `md-list` and by\n * setting `selected`.\n */\n @property({type: Number}) itemTabIndex = -1;\n\n /**\n * Whether or not the element is actively being interacted with by md-list.\n * When active, tabindex is set to 0, and in some list item variants (like\n * md-list-item), focuses the underlying item.\n */\n @property({type: Boolean, reflect: true}) active = false;\n\n /**\n * READONLY. Sets the `md-list-item` attribute on the element.\n */\n @property({type: Boolean, attribute: 'md-list-item', reflect: true})\n isListItem = true;\n\n @queryAsync('md-ripple') protected ripple!: Promise<MdRipple|null>;\n @query('.list-item') protected listItemRoot!: HTMLElement;\n\n protected readonly listItemRole: ARIARole = 'listitem';\n @state() protected showFocusRing = false;\n @state() protected showRipple = false;\n\n /**\n * Only meant to be overriden by subclassing and not by the user. This is\n * so that we have control over focus on specific variants such as disabling\n * focus on <md-autocomplete-item> but enabling it for <md-menu-item>.\n */\n protected focusOnActivation = true;\n\n protected getRipple = () => {\n this.showRipple = true;\n return this.ripple;\n };\n\n private isFirstUpdate = true;\n\n override willUpdate(changed: PropertyValues<this>) {\n if (changed.has('active') && !this.disabled) {\n if (this.active) {\n this.itemTabIndex = 0;\n\n if (this.focusOnActivation) {\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n // Do not reset anything if it's the first render because user could\n // have set `itemTabIndex` manually.\n } else if (!this.isFirstUpdate) {\n this.itemTabIndex = -1;\n }\n }\n }\n\n override render(): TemplateResult {\n return this.renderListItem(html`\n <div class=\"content-wrapper\">\n ${this.renderStart()}\n ${this.renderBody()}\n ${this.renderEnd()}\n ${this.renderRipple()}\n ${this.renderFocusRing()}\n </div>`);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content {unkown} the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n return html`\n <li\n tabindex=${this.disabled ? -1 : this.itemTabIndex}\n role=${this.listItemRole}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n @pointerdown=${this.onPointerdown}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n @click=${this.onClick}\n @pointerenter=${this.onPointerenter}\n @pointerleave=${this.onPointerleave}\n @keydown=${this.onKeydown}\n ${ripple(this.getRipple)}>${content}</li>`;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n protected renderRipple(): TemplateResult|typeof nothing {\n return this.showRipple ?\n html`<md-ripple ?disabled=\"${this.disabled}\"></md-ripple>` :\n nothing;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring class=\"focus-ring\" .visible=\"${\n this.showFocusRing}\"></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses(): ClassInfo {\n return {\n 'with-one-line': this.supportingText === '',\n 'with-two-line':\n this.supportingText !== '' && !this.multiLineSupportingText,\n 'with-three-line':\n this.supportingText !== '' && this.multiLineSupportingText,\n 'disabled': this.disabled\n };\n }\n\n /**\n * The content rendered at the start of the list item.\n */\n protected renderStart(): TemplateResult {\n return html`<div class=\"start\"><slot name=\"start\"></slot></div>`;\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n protected renderBody(): TemplateResult {\n const supportingText =\n this.supportingText !== '' ? this.renderSupportingText() : '';\n\n return html`<div class=\"body\"\n ><span class=\"label-text\">${this.headline}</span>${supportingText}</div>`;\n }\n\n /**\n * Renders the one-line supporting text.\n */\n protected renderSupportingText(): TemplateResult {\n return html`<span\n class=\"supporting-text ${classMap(this.getSupportingTextClasses())}\"\n >${this.supportingText}</span>`;\n }\n\n /**\n * Gets the classes for the supporting text node\n */\n protected getSupportingTextClasses(): ClassInfo {\n return {'supporting-text--multi-line': this.multiLineSupportingText};\n }\n\n /**\n * The content rendered at the end of the list item.\n */\n protected renderEnd(): TemplateResult {\n const supportingText = this.trailingSupportingText !== '' ?\n this.renderTrailingSupportingText() :\n '';\n return html`<div class=\"end\"\n ><slot name=\"end\">${supportingText}</slot></div>`;\n }\n\n /**\n * Renders the supporting text at the end of the list item.\n */\n protected renderTrailingSupportingText(): TemplateResult {\n return html`<span class=\"trailing-supporting-text\"\n >${this.trailingSupportingText}</span>`;\n }\n\n protected onPointerdown() {\n pointerPress();\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected onFocus() {\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected onBlur() {\n this.showFocusRing = false;\n }\n\n // For easier overriding in menu-item\n protected onClick(e: Event) {}\n protected onKeydown(e: KeyboardEvent) {}\n protected onPointerenter(e: Event) {}\n protected onPointerleave(e: Event) {}\n\n override updated(changed: PropertyValues<this>) {\n super.updated(changed);\n\n // will focus the list item root if it is selected but not on the first\n // update or else it may cause the page to jump on first load.\n if (changed.has('active') && !this.isFirstUpdate && this.active &&\n this.focusOnActivation) {\n this.focus();\n }\n\n this.isFirstUpdate = false;\n }\n\n override focus() {\n this.listItemRoot?.focus?.();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list-item.js","sourceRoot":"","sources":["list-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAepD,gEAAgE;AAChE,MAAM,OAAO,UAAW,SAAQ,UAAU;IAA1C;;QAKE;;WAEG;QACS,aAAQ,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACS,mBAAc,GAAG,EAAE,CAAC;QAEhC;;WAEG;QACwB,4BAAuB,GAAG,KAAK,CAAC;QAE3D;;;WAGG;QACS,2BAAsB,GAAG,EAAE,CAAC;QAExC;;WAEG;QACwB,aAAQ,GAAG,KAAK,CAAC;QAE5C;;;;;WAKG;QACuB,iBAAY,GAAG,CAAC,CAAC,CAAC;QAE5C;;;;WAIG;QACuC,WAAM,GAAG,KAAK,CAAC;QAEzD;;WAEG;QAEH,eAAU,GAAG,IAAI,CAAC;QAIC,iBAAY,GAAa,UAAU,CAAC;QAEtC,eAAU,GAAG,KAAK,CAAC;QAEpC;;;;WAIG;QACO,sBAAiB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AAI,EAAC,CAAC;8CAClD;AAEO;IAAxB,UAAU,CAAC,WAAW,CAAC;0CAAkD;AACrD;IAApB,KAAK,CAAC,YAAY,CAAC;gDAAoD;AAG/D;IAAR,KAAK,EAAE;8CAA4B","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../ripple/ripple.js';\nimport '../../../focus/focus-ring.js';\n\nimport {html, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query, queryAsync, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {requestUpdateOnAriaChange} from '../../../aria/delegate.js';\nimport {ripple} from '../../../ripple/directive.js';\nimport {MdRipple} from '../../../ripple/ripple.js';\nimport {ARIAMixinStrict, ARIARole} from '../../../types/aria.js';\n\ninterface ListItemSelf {\n active: boolean;\n disabled: boolean;\n}\n\n/**\n * The interface of an item that is compatible with md-list. An item that is\n * selectable and disablable.\n */\nexport type ListItem = ListItemSelf&HTMLElement;\n\n// tslint:disable-next-line:enforce-comments-on-exported-symbols\nexport class ListItemEl extends LitElement implements ListItem {\n static {\n requestUpdateOnAriaChange(this);\n }\n\n /**\n * The primary, headline text of the list item.\n */\n @property() headline = '';\n\n /**\n * The one-line supporting text below the headline. Set\n * `multiLineSupportingText` to `true` to support multiple lines in the\n * supporting text.\n */\n @property() supportingText = '';\n\n /**\n * Modifies `supportingText` to support multiple lines.\n */\n @property({type: Boolean}) multiLineSupportingText = false;\n\n /**\n * The supporting text placed at the end of the item. Overriden by elements\n * slotted into the `end` slot.\n */\n @property() trailingSupportingText = '';\n\n /**\n * Disables the item and makes it non-selectable and non-interactive.\n */\n @property({type: Boolean}) disabled = false;\n\n /**\n * The tabindex of the underlying item.\n *\n * __NOTE:__ this is overriden by the keyboard behavior of `md-list` and by\n * setting `selected`.\n */\n @property({type: Number}) itemTabIndex = -1;\n\n /**\n * Whether or not the element is actively being interacted with by md-list.\n * When active, tabindex is set to 0, and in some list item variants (like\n * md-list-item), focuses the underlying item.\n */\n @property({type: Boolean, reflect: true}) active = false;\n\n /**\n * READONLY. Sets the `md-list-item` attribute on the element.\n */\n @property({type: Boolean, attribute: 'md-list-item', reflect: true})\n isListItem = true;\n\n @queryAsync('md-ripple') private readonly ripple!: Promise<MdRipple|null>;\n @query('.list-item') protected readonly listItemRoot!: HTMLElement|null;\n protected readonly listItemRole: ARIARole = 'listitem';\n\n @state() private showRipple = false;\n\n /**\n * Only meant to be overriden by subclassing and not by the user. This is\n * so that we have control over focus on specific variants such as disabling\n * focus on <md-autocomplete-item> but enabling it for <md-menu-item>.\n */\n protected focusOnActivation = true;\n\n protected readonly getRipple = () => {\n this.showRipple = true;\n return this.ripple;\n };\n\n private isFirstUpdate = true;\n\n protected override willUpdate(changed: PropertyValues<this>) {\n if (changed.has('active') && !this.disabled) {\n if (this.active) {\n this.itemTabIndex = 0;\n } else if (!this.isFirstUpdate) {\n // Do not reset anything if it's the first render because user could\n // have set `itemTabIndex` manually.\n this.itemTabIndex = -1;\n }\n }\n }\n\n protected override render() {\n return this.renderListItem(html`\n <div class=\"content-wrapper\">\n ${this.renderStart()}\n ${this.renderBody()}\n ${this.renderEnd()}\n ${this.renderRipple()}\n ${this.renderFocusRing()}\n </div>`);\n }\n\n /**\n * Renders the root list item.\n *\n * @param content {unkown} the child content of the list item.\n */\n protected renderListItem(content: unknown) {\n return html`\n <li\n id=\"item\"\n tabindex=${this.disabled ? -1 : this.itemTabIndex}\n role=${this.listItemRole}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n @click=${this.onClick}\n @pointerenter=${this.onPointerenter}\n @pointerleave=${this.onPointerleave}\n @keydown=${this.onKeydown}\n ${ripple(this.getRipple)}>${content}</li>`;\n }\n\n /**\n * Handles rendering of the ripple element.\n */\n private renderRipple() {\n return this.showRipple ?\n html`<md-ripple ?disabled=\"${this.disabled}\"></md-ripple>` :\n nothing;\n }\n\n /**\n * Handles rendering of the focus ring.\n */\n private renderFocusRing() {\n return html`<md-focus-ring class=\"focus-ring\" for=\"item\"></md-focus-ring>`;\n }\n\n /**\n * Classes applied to the list item root.\n */\n protected getRenderClasses() {\n return {\n 'with-one-line': this.supportingText === '',\n 'with-two-line':\n this.supportingText !== '' && !this.multiLineSupportingText,\n 'with-three-line':\n this.supportingText !== '' && this.multiLineSupportingText,\n 'disabled': this.disabled\n };\n }\n\n /**\n * The content rendered at the start of the list item.\n */\n private renderStart() {\n return html`<div class=\"start\"><slot name=\"start\"></slot></div>`;\n }\n\n /**\n * Handles rendering the headline and supporting text.\n */\n private renderBody() {\n const supportingText =\n this.supportingText !== '' ? this.renderSupportingText() : '';\n\n return html`<div class=\"body\"\n ><span class=\"label-text\">${this.headline}</span>${supportingText}</div>`;\n }\n\n /**\n * Renders the one-line supporting text.\n */\n private renderSupportingText() {\n return html`<span\n class=\"supporting-text ${classMap(this.getSupportingTextClasses())}\"\n >${this.supportingText}</span>`;\n }\n\n /**\n * Gets the classes for the supporting text node\n */\n private getSupportingTextClasses() {\n return {'supporting-text--multi-line': this.multiLineSupportingText};\n }\n\n /**\n * The content rendered at the end of the list item.\n */\n protected renderEnd() {\n const supportingText = this.trailingSupportingText !== '' ?\n this.renderTrailingSupportingText() :\n '';\n return html`<div class=\"end\"\n ><slot name=\"end\">${supportingText}</slot></div>`;\n }\n\n /**\n * Renders the supporting text at the end of the list item.\n */\n private renderTrailingSupportingText() {\n return html`<span class=\"trailing-supporting-text\"\n >${this.trailingSupportingText}</span>`;\n }\n\n // For easier overriding in menu-item\n protected onClick?(event: Event): void;\n protected onKeydown?(event: KeyboardEvent): void;\n protected onPointerenter?(event: Event): void;\n protected onPointerleave?(event: Event): void;\n\n protected override updated(changed: PropertyValues<this>) {\n super.updated(changed);\n\n // will focus the list item root if it is selected but not on the first\n // update or else it may cause the page to jump on first load.\n if (changed.has('active') && !this.isFirstUpdate && this.active &&\n this.focusOnActivation) {\n this.focus();\n }\n\n this.isFirstUpdate = false;\n }\n\n override focus() {\n this.listItemRoot?.focus?.();\n }\n}\n"]}
|
|
@@ -14,6 +14,7 @@ export class ListItemLink extends ListItemEl {
|
|
|
14
14
|
renderListItem(content) {
|
|
15
15
|
return html `
|
|
16
16
|
<a
|
|
17
|
+
id="item"
|
|
17
18
|
tabindex=${this.disabled ? -1 : this.itemTabIndex}
|
|
18
19
|
role=${this.listItemRole}
|
|
19
20
|
aria-selected=${this.ariaSelected || nothing}
|
|
@@ -21,9 +22,6 @@ export class ListItemLink extends ListItemEl {
|
|
|
21
22
|
class="list-item ${classMap(this.getRenderClasses())}"
|
|
22
23
|
href=${this.href}
|
|
23
24
|
target=${this.target || nothing}
|
|
24
|
-
@pointerdown=${this.onPointerdown}
|
|
25
|
-
@focus=${this.onFocus}
|
|
26
|
-
@blur=${this.onBlur}
|
|
27
25
|
@click=${this.onClick}
|
|
28
26
|
@pointerenter=${this.onPointerenter}
|
|
29
27
|
@pointerleave=${this.onPointerleave}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-item-link.js","sourceRoot":"","sources":["list-item-link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAIpD,gEAAgE;AAChE,MAAM,OAAO,YAAa,SAAQ,UAAU;IAUvB,cAAc,CAAC,OAAgB;QAChD,OAAO,IAAI,CAAA
|
|
1
|
+
{"version":3,"file":"list-item-link.js","sourceRoot":"","sources":["list-item-link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAIpD,gEAAgE;AAChE,MAAM,OAAO,YAAa,SAAQ,UAAU;IAUvB,cAAc,CAAC,OAAgB;QAChD,OAAO,IAAI,CAAA;;;qBAGM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY;iBAC1C,IAAI,CAAC,YAAY;0BACP,IAAwB,CAAC,YAAY,IAAI,OAAO;yBACjD,IAAwB,CAAC,WAAW,IAAI,OAAO;6BAC5C,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;iBAC7C,IAAI,CAAC,IAAI;mBACP,IAAI,CAAC,MAAoB,IAAI,OAAO;mBACpC,IAAI,CAAC,OAAO;0BACL,IAAI,CAAC,cAAc;0BACnB,IAAI,CAAC,cAAc;qBACxB,IAAI,CAAC,SAAS;YACvB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,OAAO,MAAM,CAAC;IAClD,CAAC;CACF;AAvBa;IAAX,QAAQ,EAAE;0CAAe;AAKd;IAAX,QAAQ,EAAE;4CAAiB","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, nothing} from 'lit';\nimport {property} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ripple} from '../../../ripple/directive.js';\nimport {ARIAMixinStrict} from '../../../types/aria.js';\nimport {ListItemEl} from '../listitem/list-item.js';\n\ntype LinkTarget = '_blank'|'_parent'|'_self'|'_top';\n\n// tslint:disable-next-line:enforce-comments-on-exported-symbols\nexport class ListItemLink extends ListItemEl {\n /**\n * Sets the underlying `HTMLAnchorElement`'s `href` resource attribute.\n */\n @property() href!: string;\n\n /**\n * Sets the underlying `HTMLAnchorElement`'s `target` attribute.\n */\n @property() target!: string;\n protected override renderListItem(content: unknown) {\n return html`\n <a\n id=\"item\"\n tabindex=${this.disabled ? -1 : this.itemTabIndex}\n role=${this.listItemRole}\n aria-selected=${(this as ARIAMixinStrict).ariaSelected || nothing}\n aria-checked=${(this as ARIAMixinStrict).ariaChecked || nothing}\n class=\"list-item ${classMap(this.getRenderClasses())}\"\n href=${this.href}\n target=${this.target as LinkTarget || nothing}\n @click=${this.onClick}\n @pointerenter=${this.onPointerenter}\n @pointerleave=${this.onPointerleave}\n @keydown=${this.onKeydown}\n ${ripple(this.getRipple)}>${content}</a>`;\n }\n}\n"]}
|
package/menu/lib/_menu.scss
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
$tokens: theme.validate-theme(tokens.md-comp-menu-values(), $tokens);
|
|
22
22
|
|
|
23
23
|
@each $token, $value in $tokens {
|
|
24
|
-
|
|
24
|
+
@if $value {
|
|
25
|
+
--md-menu-#{$token}: #{$value};
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
|
|
31
33
|
:host {
|
|
32
34
|
@each $token, $value in $tokens {
|
|
33
|
-
--_#{$token}: #{$value};
|
|
35
|
+
--_#{$token}: var(--md-menu-#{$token}, #{$value});
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
@include md-list.theme(
|
|
@@ -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{--_container-color: var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-menu-container-elevation, 2);--_container-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-container-shape, 4px);--md-list-container-color: var(--_container-color);--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-focus-ring-shape
|
|
7
|
+
export const styles = css `:host{--_container-color: var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-menu-container-elevation, 2);--_container-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-container-shape, 4px);--md-list-container-color: var(--_container-color);--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-focus-ring-shape: var(--_container-shape);min-width:300px}.menu{border-radius:var(--_container-shape);display:none;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit;min-width:inherit}.menu.fixed{position:fixed}.menu md-list{height:inherit;max-height:inherit;display:block;overflow:auto;min-width:inherit;border-radius:inherit}.menu.has-overflow md-list{overflow:visible}.menu.animating md-list{pointer-events:none;overflow:hidden}.menu.animating ::slotted(.hidden){opacity:0}.menu slot{display:block;height:inherit;max-height:inherit}/*# sourceMappingURL=menu-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=menu-styles.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-styles.css.js","sourceRoot":"","sources":["menu-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{--_container-color: var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-menu-container-elevation, 2);--_container-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-container-shape, 4px);--md-list-container-color: var(--_container-color);--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-focus-ring-shape
|
|
1
|
+
{"version":3,"file":"menu-styles.css.js","sourceRoot":"","sources":["menu-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{--_container-color: var(--md-menu-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-menu-container-elevation, 2);--_container-shadow-color: var(--md-menu-container-shadow-color, var(--md-sys-color-shadow, #000));--_container-shape: var(--md-menu-container-shape, 4px);--md-list-container-color: var(--_container-color);--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);--md-focus-ring-shape: var(--_container-shape);min-width:300px}.menu{border-radius:var(--_container-shape);display:none;opacity:0;z-index:20;position:absolute;user-select:none;max-height:inherit;height:inherit;min-width:inherit}.menu.fixed{position:fixed}.menu md-list{height:inherit;max-height:inherit;display:block;overflow:auto;min-width:inherit;border-radius:inherit}.menu.has-overflow md-list{overflow:visible}.menu.animating md-list{pointer-events:none;overflow:hidden}.menu.animating ::slotted(.hidden){opacity:0}.menu slot{display:block;height:inherit;max-height:inherit}/*# sourceMappingURL=menu-styles.css.map */\n`;\n "]}
|
package/menu/lib/menu.d.ts
CHANGED
|
@@ -7,11 +7,9 @@ import '../../list/list.js';
|
|
|
7
7
|
import '../../focus/focus-ring.js';
|
|
8
8
|
import '../../elevation/elevation.js';
|
|
9
9
|
import { LitElement } from 'lit';
|
|
10
|
-
import { MdFocusRing } from '../../focus/focus-ring.js';
|
|
11
|
-
import { List } from '../../list/lib/list.js';
|
|
12
10
|
import { ARIARole } from '../../types/aria.js';
|
|
13
|
-
import {
|
|
14
|
-
import { Corner,
|
|
11
|
+
import { MenuItem } from './shared.js';
|
|
12
|
+
import { Corner, SurfacePositionTarget } from './surfacePositionController.js';
|
|
15
13
|
import { TypeaheadController } from './typeaheadController.js';
|
|
16
14
|
export { Corner } from './surfacePositionController.js';
|
|
17
15
|
/**
|
|
@@ -29,10 +27,9 @@ export type DefaultFocusState = 'NONE' | 'LIST_ROOT' | 'FIRST_ITEM' | 'LAST_ITEM
|
|
|
29
27
|
* @fires closed Fired once the menu is closed, after any animations
|
|
30
28
|
*/
|
|
31
29
|
export declare abstract class Menu extends LitElement {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
protected readonly focusRing: MdFocusRing;
|
|
30
|
+
private readonly listElement;
|
|
31
|
+
private readonly surfaceEl;
|
|
32
|
+
private readonly slotEl;
|
|
36
33
|
/**
|
|
37
34
|
* The element in which the menu should align to.
|
|
38
35
|
*/
|
|
@@ -126,17 +123,17 @@ export declare abstract class Menu extends LitElement {
|
|
|
126
123
|
* The element that should be focused by default once opened.
|
|
127
124
|
*/
|
|
128
125
|
defaultFocus: DefaultFocusState;
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
private typeaheadActive;
|
|
127
|
+
private readonly openCloseAnimationSignal;
|
|
131
128
|
/**
|
|
132
129
|
* Whether the menu is animating upwards or downwards when opening. This is
|
|
133
130
|
* helpful for calculating some animation calculations.
|
|
134
131
|
*/
|
|
135
|
-
|
|
132
|
+
private get openDirection();
|
|
136
133
|
/**
|
|
137
134
|
* The element that was focused before the menu opened.
|
|
138
135
|
*/
|
|
139
|
-
|
|
136
|
+
private lastFocusedElement;
|
|
140
137
|
/**
|
|
141
138
|
* Handles typeahead navigation through the menu.
|
|
142
139
|
*/
|
|
@@ -144,75 +141,70 @@ export declare abstract class Menu extends LitElement {
|
|
|
144
141
|
/**
|
|
145
142
|
* Handles positioning the surface and aligning it to the anchor.
|
|
146
143
|
*/
|
|
147
|
-
|
|
144
|
+
private readonly menuPositionController;
|
|
148
145
|
/**
|
|
149
146
|
* The menu items associated with this menu. The items must be `MenuItem`s and
|
|
150
147
|
* have both the `md-menu-item` and `md-list-item` attributes.
|
|
151
148
|
*/
|
|
152
149
|
get items(): MenuItem[];
|
|
153
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
150
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
154
151
|
/**
|
|
155
152
|
* Renders the positionable surface element and its contents.
|
|
156
153
|
*/
|
|
157
|
-
|
|
154
|
+
private renderSurface;
|
|
158
155
|
/**
|
|
159
156
|
* Renders the List element and its items
|
|
160
157
|
*/
|
|
161
|
-
|
|
158
|
+
private renderList;
|
|
162
159
|
/**
|
|
163
160
|
* Renders the menu items' slot
|
|
164
161
|
*/
|
|
165
|
-
|
|
162
|
+
private renderMenuItems;
|
|
166
163
|
/**
|
|
167
164
|
* Renders the elevation component.
|
|
168
165
|
*/
|
|
169
|
-
|
|
166
|
+
private renderElevation;
|
|
170
167
|
/**
|
|
171
168
|
* Renders the focus ring component.
|
|
172
169
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
'has-overflow': boolean;
|
|
178
|
-
};
|
|
179
|
-
protected handleFocusout(e: FocusEvent): Promise<void>;
|
|
180
|
-
protected handleListFocus(): void;
|
|
181
|
-
protected handleListClick(): void;
|
|
182
|
-
protected handleListKeydown(e: KeyboardEvent): void;
|
|
183
|
-
protected handleListBlur(): void;
|
|
170
|
+
private renderFocusRing;
|
|
171
|
+
private getSurfaceClasses;
|
|
172
|
+
private handleFocusout;
|
|
173
|
+
private handleListKeydown;
|
|
184
174
|
/**
|
|
185
175
|
* Saves the last focused element focuses the new element based on
|
|
186
176
|
* `defaultFocus`, and animates open.
|
|
187
177
|
*/
|
|
188
|
-
|
|
178
|
+
private readonly onOpened;
|
|
189
179
|
/**
|
|
190
180
|
* Animates closed.
|
|
191
181
|
*/
|
|
192
|
-
|
|
182
|
+
private readonly beforeClose;
|
|
193
183
|
/**
|
|
194
184
|
* Focuses the last focused element.
|
|
195
185
|
*/
|
|
196
|
-
|
|
186
|
+
private readonly onClosed;
|
|
197
187
|
/**
|
|
198
188
|
* Performs the opening animation:
|
|
199
189
|
*
|
|
200
190
|
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
201
191
|
*/
|
|
202
|
-
|
|
192
|
+
private animateOpen;
|
|
203
193
|
/**
|
|
204
194
|
* Performs the closing animation:
|
|
205
195
|
*
|
|
206
196
|
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
207
197
|
*/
|
|
208
|
-
|
|
198
|
+
private animateClose;
|
|
209
199
|
connectedCallback(): void;
|
|
210
200
|
disconnectedCallback(): void;
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
201
|
+
private readonly onWindowClick;
|
|
202
|
+
private onCloseMenu;
|
|
203
|
+
private onDeactivateItems;
|
|
204
|
+
private handleDeactivateTypeahead;
|
|
205
|
+
private handleActivateTypeahead;
|
|
206
|
+
private handleStayOpenOnFocusout;
|
|
207
|
+
private handleCloseOnFocusout;
|
|
216
208
|
focus(): void;
|
|
217
209
|
close(): void;
|
|
218
210
|
show(): void;
|
package/menu/lib/menu.js
CHANGED
|
@@ -13,7 +13,6 @@ import { eventOptions, property, query, state } from 'lit/decorators.js';
|
|
|
13
13
|
import { classMap } from 'lit/directives/class-map.js';
|
|
14
14
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
15
15
|
import { requestUpdateOnAriaChange } from '../../aria/delegate.js';
|
|
16
|
-
import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
|
|
17
16
|
import { List } from '../../list/lib/list.js';
|
|
18
17
|
import { createAnimationSignal, EASING } from '../../motion/animation.js';
|
|
19
18
|
import { isElementInSubtree } from './shared.js';
|
|
@@ -292,12 +291,10 @@ export class Menu extends LitElement {
|
|
|
292
291
|
const { ariaLabel } = this;
|
|
293
292
|
return html `
|
|
294
293
|
<md-list
|
|
294
|
+
id="list"
|
|
295
295
|
aria-label=${ariaLabel || nothing}
|
|
296
296
|
type=${this.type}
|
|
297
297
|
listTabIndex=${this.listTabIndex}
|
|
298
|
-
@focus=${this.handleListFocus}
|
|
299
|
-
@blur=${this.handleListBlur}
|
|
300
|
-
@click=${this.handleListClick}
|
|
301
298
|
@keydown=${this.handleListKeydown}>
|
|
302
299
|
${this.renderMenuItems()}
|
|
303
300
|
</md-list>`;
|
|
@@ -310,7 +307,9 @@ export class Menu extends LitElement {
|
|
|
310
307
|
@close-menu=${this.onCloseMenu}
|
|
311
308
|
@deactivate-items=${this.onDeactivateItems}
|
|
312
309
|
@deactivate-typeahead=${this.handleDeactivateTypeahead}
|
|
313
|
-
@activate-typeahead=${this.handleActivateTypeahead}
|
|
310
|
+
@activate-typeahead=${this.handleActivateTypeahead}
|
|
311
|
+
@stay-open-on-focusout=${this.handleStayOpenOnFocusout}
|
|
312
|
+
@close-on-focusout=${this.handleCloseOnFocusout}></slot>`;
|
|
314
313
|
}
|
|
315
314
|
/**
|
|
316
315
|
* Renders the elevation component.
|
|
@@ -322,7 +321,7 @@ export class Menu extends LitElement {
|
|
|
322
321
|
* Renders the focus ring component.
|
|
323
322
|
*/
|
|
324
323
|
renderFocusRing() {
|
|
325
|
-
return html `<md-focus-ring></md-focus-ring>`;
|
|
324
|
+
return html `<md-focus-ring for="list"></md-focus-ring>`;
|
|
326
325
|
}
|
|
327
326
|
getSurfaceClasses() {
|
|
328
327
|
return {
|
|
@@ -353,22 +352,12 @@ export class Menu extends LitElement {
|
|
|
353
352
|
// return to previous behavior
|
|
354
353
|
this.skipRestoreFocus = oldRestoreFocus;
|
|
355
354
|
}
|
|
356
|
-
handleListFocus() {
|
|
357
|
-
this.focusRing.visible = shouldShowStrongFocus();
|
|
358
|
-
}
|
|
359
|
-
handleListClick() {
|
|
360
|
-
pointerPress();
|
|
361
|
-
this.focusRing.visible = shouldShowStrongFocus();
|
|
362
|
-
}
|
|
363
355
|
// Capture so that we can grab the event before it reaches the list item
|
|
364
356
|
// istelf. Specifically useful for the case where typeahead encounters a space
|
|
365
357
|
// and we don't want the menu item to close the menu.
|
|
366
358
|
handleListKeydown(e) {
|
|
367
359
|
this.typeaheadController.onKeydown(e);
|
|
368
360
|
}
|
|
369
|
-
handleListBlur() {
|
|
370
|
-
this.focusRing.visible = false;
|
|
371
|
-
}
|
|
372
361
|
/**
|
|
373
362
|
* Performs the opening animation:
|
|
374
363
|
*
|
|
@@ -547,7 +536,7 @@ export class Menu extends LitElement {
|
|
|
547
536
|
window.removeEventListener('click', this.onWindowClick, { capture: true });
|
|
548
537
|
}
|
|
549
538
|
}
|
|
550
|
-
onCloseMenu(
|
|
539
|
+
onCloseMenu() {
|
|
551
540
|
this.close();
|
|
552
541
|
}
|
|
553
542
|
onDeactivateItems(e) {
|
|
@@ -570,6 +559,14 @@ export class Menu extends LitElement {
|
|
|
570
559
|
e.stopPropagation();
|
|
571
560
|
this.typeaheadActive = true;
|
|
572
561
|
}
|
|
562
|
+
handleStayOpenOnFocusout(e) {
|
|
563
|
+
e.stopPropagation();
|
|
564
|
+
this.stayOpenOnFocusout = true;
|
|
565
|
+
}
|
|
566
|
+
handleCloseOnFocusout(e) {
|
|
567
|
+
e.stopPropagation();
|
|
568
|
+
this.stayOpenOnFocusout = false;
|
|
569
|
+
}
|
|
573
570
|
focus() {
|
|
574
571
|
this.listElement?.focus();
|
|
575
572
|
}
|
|
@@ -596,9 +593,6 @@ __decorate([
|
|
|
596
593
|
__decorate([
|
|
597
594
|
query('slot')
|
|
598
595
|
], Menu.prototype, "slotEl", void 0);
|
|
599
|
-
__decorate([
|
|
600
|
-
query('md-focus-ring')
|
|
601
|
-
], Menu.prototype, "focusRing", void 0);
|
|
602
596
|
__decorate([
|
|
603
597
|
property({ attribute: false })
|
|
604
598
|
], Menu.prototype, "anchor", void 0);
|