@material/web 1.0.1 → 1.0.2-nightly.6a1fb38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +2 -0
- package/all.js +2 -0
- package/all.js.map +1 -1
- package/button/elevated-button.js +5 -1
- package/button/elevated-button.js.map +1 -1
- package/button/internal/_elevation.scss +32 -32
- package/button/internal/_icon.scss +22 -23
- package/button/internal/_outlined-button.scss +21 -19
- package/button/internal/_shared.scss +84 -77
- package/button/internal/_touch-target.scss +4 -0
- package/button/internal/button.d.ts +7 -11
- package/button/internal/button.js +52 -38
- package/button/internal/button.js.map +1 -1
- package/button/internal/elevated-button.d.ts +1 -1
- package/button/internal/elevated-button.js +1 -1
- package/button/internal/elevated-button.js.map +1 -1
- package/button/internal/filled-button.d.ts +1 -1
- package/button/internal/filled-button.js +1 -1
- package/button/internal/filled-button.js.map +1 -1
- package/button/internal/filled-tonal-button.d.ts +1 -1
- package/button/internal/filled-tonal-button.js +1 -1
- package/button/internal/filled-tonal-button.js.map +1 -1
- package/button/internal/outlined-button.d.ts +1 -1
- package/button/internal/outlined-button.js +2 -2
- package/button/internal/outlined-button.js.map +1 -1
- package/button/internal/outlined-styles.css.js +1 -1
- package/button/internal/outlined-styles.css.js.map +1 -1
- package/button/internal/shared-elevation-styles.css.js +1 -1
- package/button/internal/shared-elevation-styles.css.js.map +1 -1
- package/button/internal/shared-styles.css.js +1 -1
- package/button/internal/shared-styles.css.js.map +1 -1
- package/checkbox/internal/checkbox.d.ts +16 -23
- package/checkbox/internal/checkbox.js +38 -52
- package/checkbox/internal/checkbox.js.map +1 -1
- package/chips/filter-chip.js +5 -1
- package/chips/filter-chip.js.map +1 -1
- package/chips/harness.js.map +1 -1
- package/chips/input-chip.js +6 -1
- package/chips/input-chip.js.map +1 -1
- package/chips/internal/assist-chip.js +8 -4
- package/chips/internal/assist-chip.js.map +1 -1
- package/chips/internal/chip-set.js +6 -4
- package/chips/internal/chip-set.js.map +1 -1
- package/chips/internal/chip.d.ts +3 -0
- package/chips/internal/chip.js +7 -5
- package/chips/internal/chip.js.map +1 -1
- package/chips/internal/filter-chip.d.ts +2 -0
- package/chips/internal/filter-chip.js +11 -5
- package/chips/internal/filter-chip.js.map +1 -1
- package/chips/internal/input-chip.d.ts +2 -0
- package/chips/internal/input-chip.js +10 -4
- package/chips/internal/input-chip.js.map +1 -1
- package/chips/internal/multi-action-chip.js.map +1 -1
- package/chips/internal/trailing-icons.d.ts +1 -1
- package/chips/internal/trailing-icons.js +6 -5
- package/chips/internal/trailing-icons.js.map +1 -1
- package/common.d.ts +2 -0
- package/common.js +2 -0
- package/common.js.map +1 -1
- package/dialog/harness.js +1 -2
- package/dialog/harness.js.map +1 -1
- package/dialog/internal/_dialog.scss +1 -1
- package/dialog/internal/animations.js +14 -12
- package/dialog/internal/animations.js.map +1 -1
- package/dialog/internal/dialog-styles.css.js +1 -1
- package/dialog/internal/dialog-styles.css.js.map +1 -1
- package/dialog/internal/dialog.d.ts +6 -6
- package/dialog/internal/dialog.js +24 -24
- package/dialog/internal/dialog.js.map +1 -1
- package/fab/harness.js.map +1 -1
- package/fab/internal/fab.js.map +1 -1
- package/fab/internal/shared.js +10 -11
- package/fab/internal/shared.js.map +1 -1
- package/field/harness.js.map +1 -1
- package/field/internal/_content.scss +185 -174
- package/field/internal/_filled-field.scss +147 -136
- package/field/internal/_label.scss +83 -72
- package/field/internal/_outlined-field.scss +276 -262
- package/field/internal/_supporting-text.scss +53 -42
- package/field/internal/field.js +26 -22
- package/field/internal/field.js.map +1 -1
- package/field/internal/filled-styles.css.js +1 -1
- package/field/internal/filled-styles.css.js.map +1 -1
- package/field/internal/outlined-styles.css.js +1 -1
- package/field/internal/outlined-styles.css.js.map +1 -1
- package/field/internal/shared-styles.css.js +1 -1
- package/field/internal/shared-styles.css.js.map +1 -1
- package/focus/internal/focus-ring.d.ts +2 -0
- package/focus/internal/focus-ring.js +3 -3
- package/focus/internal/focus-ring.js.map +1 -1
- package/icon/internal/_icon.scss +7 -4
- package/icon/internal/icon-styles.css.js +1 -1
- package/icon/internal/icon-styles.css.js.map +1 -1
- package/iconbutton/internal/icon-button.d.ts +9 -4
- package/iconbutton/internal/icon-button.js +35 -22
- package/iconbutton/internal/icon-button.js.map +1 -1
- package/internal/aria/aria.d.ts +4 -26
- package/internal/aria/aria.js +10 -28
- package/internal/aria/aria.js.map +1 -1
- package/internal/aria/delegate.js +2 -2
- package/internal/aria/delegate.js.map +1 -1
- package/internal/controller/attachable-controller.js +3 -5
- package/internal/controller/attachable-controller.js.map +1 -1
- package/internal/controller/form-submitter.d.ts +3 -5
- package/internal/controller/form-submitter.js +5 -7
- package/internal/controller/form-submitter.js.map +1 -1
- package/internal/controller/is-rtl.js +2 -2
- package/internal/controller/is-rtl.js.map +1 -1
- package/internal/controller/string-converter.js +1 -1
- package/internal/controller/string-converter.js.map +1 -1
- package/internal/motion/animation.js.map +1 -1
- package/labs/behaviors/element-internals.d.ts +45 -0
- package/labs/behaviors/element-internals.js +50 -0
- package/labs/behaviors/element-internals.js.map +1 -0
- package/labs/behaviors/focusable.d.ts +39 -0
- package/labs/behaviors/focusable.js +82 -0
- package/labs/behaviors/focusable.js.map +1 -0
- package/labs/behaviors/form-associated.d.ts +199 -0
- package/labs/behaviors/form-associated.js +155 -0
- package/labs/behaviors/form-associated.js.map +1 -0
- package/labs/behaviors/mixin.d.ts +54 -0
- package/labs/behaviors/mixin.js +7 -0
- package/labs/behaviors/mixin.js.map +1 -0
- package/labs/card/_elevated-card.scss +6 -0
- package/labs/card/_filled-card.scss +6 -0
- package/labs/card/_outlined-card.scss +6 -0
- package/labs/card/elevated-card.d.ts +18 -0
- package/labs/card/elevated-card.js +21 -0
- package/labs/card/elevated-card.js.map +1 -0
- package/labs/card/filled-card.d.ts +18 -0
- package/labs/card/filled-card.js +21 -0
- package/labs/card/filled-card.js.map +1 -0
- package/labs/card/internal/_elevated-card.scss +35 -0
- package/labs/card/internal/_filled-card.scss +35 -0
- package/labs/card/internal/_outlined-card.scss +39 -0
- package/labs/card/internal/_shared.scss +40 -0
- package/labs/card/internal/card.d.ts +13 -0
- package/labs/card/internal/card.js +20 -0
- package/labs/card/internal/card.js.map +1 -0
- package/labs/card/internal/elevated-styles.css.js +9 -0
- package/labs/card/internal/elevated-styles.css.js.map +1 -0
- package/labs/card/internal/elevated-styles.scss +10 -0
- package/labs/card/internal/filled-styles.css.js +9 -0
- package/labs/card/internal/filled-styles.css.js.map +1 -0
- package/labs/card/internal/filled-styles.scss +10 -0
- package/labs/card/internal/outlined-styles.css.js +9 -0
- package/labs/card/internal/outlined-styles.css.js.map +1 -0
- package/labs/card/internal/outlined-styles.scss +10 -0
- package/labs/card/internal/shared-styles.css.js +9 -0
- package/labs/card/internal/shared-styles.css.js.map +1 -0
- package/labs/card/internal/shared-styles.scss +10 -0
- package/labs/card/outlined-card.d.ts +18 -0
- package/labs/card/outlined-card.js +21 -0
- package/labs/card/outlined-card.js.map +1 -0
- package/labs/item/internal/item.js +8 -8
- package/labs/item/internal/item.js.map +1 -1
- package/labs/navigationbar/internal/constants.js.map +1 -1
- package/labs/navigationbar/internal/navigation-bar.d.ts +3 -0
- package/labs/navigationbar/internal/navigation-bar.js +18 -11
- package/labs/navigationbar/internal/navigation-bar.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer-modal.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js +10 -3
- package/labs/navigationdrawer/internal/navigation-drawer-modal.js.map +1 -1
- package/labs/navigationdrawer/internal/navigation-drawer.d.ts +3 -0
- package/labs/navigationdrawer/internal/navigation-drawer.js +8 -1
- package/labs/navigationdrawer/internal/navigation-drawer.js.map +1 -1
- package/labs/navigationtab/harness.js.map +1 -1
- package/labs/navigationtab/internal/navigation-tab.d.ts +6 -0
- package/labs/navigationtab/internal/navigation-tab.js +43 -27
- package/labs/navigationtab/internal/navigation-tab.js.map +1 -1
- package/labs/navigationtab/internal/state.js.map +1 -1
- package/labs/segmentedbutton/internal/segmented-button.d.ts +3 -0
- package/labs/segmentedbutton/internal/segmented-button.js +26 -12
- package/labs/segmentedbutton/internal/segmented-button.js.map +1 -1
- package/labs/segmentedbuttonset/internal/segmented-button-set.d.ts +5 -0
- package/labs/segmentedbuttonset/internal/segmented-button-set.js +14 -9
- package/labs/segmentedbuttonset/internal/segmented-button-set.js.map +1 -1
- package/list/harness.d.ts +1 -1
- package/list/harness.js.map +1 -1
- package/list/internal/list-controller.d.ts +1 -1
- package/list/internal/list-controller.js +7 -3
- package/list/internal/list-controller.js.map +1 -1
- package/list/internal/list-navigation-helpers.js.map +1 -1
- package/list/internal/list.d.ts +2 -2
- package/list/internal/list.js +8 -6
- package/list/internal/list.js.map +1 -1
- package/list/internal/listitem/harness.d.ts +1 -1
- package/list/internal/listitem/harness.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +3 -2
- package/list/internal/listitem/list-item.js +19 -20
- package/list/internal/listitem/list-item.js.map +1 -1
- package/list/list-item.d.ts +4 -12
- package/list/list-item.js +4 -12
- package/list/list-item.js.map +1 -1
- package/menu/harness.js.map +1 -1
- package/menu/internal/_menu.scss +12 -1
- package/menu/internal/controllers/menuItemController.js +9 -4
- package/menu/internal/controllers/menuItemController.js.map +1 -1
- package/menu/internal/controllers/shared.d.ts +9 -1
- package/menu/internal/controllers/shared.js +4 -4
- package/menu/internal/controllers/shared.js.map +1 -1
- package/menu/internal/controllers/surfacePositionController.d.ts +15 -2
- package/menu/internal/controllers/surfacePositionController.js +124 -54
- package/menu/internal/controllers/surfacePositionController.js.map +1 -1
- package/menu/internal/controllers/typeaheadController.js +19 -14
- package/menu/internal/controllers/typeaheadController.js.map +1 -1
- package/menu/internal/menu-styles.css.js +1 -1
- package/menu/internal/menu-styles.css.js.map +1 -1
- package/menu/internal/menu.d.ts +43 -12
- package/menu/internal/menu.js +124 -57
- package/menu/internal/menu.js.map +1 -1
- package/menu/internal/menuitem/harness.js.map +1 -1
- package/menu/internal/menuitem/menu-item.d.ts +3 -2
- package/menu/internal/menuitem/menu-item.js +18 -19
- package/menu/internal/menuitem/menu-item.js.map +1 -1
- package/menu/internal/submenu/sub-menu.d.ts +8 -8
- package/menu/internal/submenu/sub-menu.js +31 -22
- package/menu/internal/submenu/sub-menu.js.map +1 -1
- package/menu/internal/types.js.map +1 -1
- package/package.json +1 -1
- package/progress/internal/_circular-progress.scss +2 -2
- package/progress/internal/_linear-progress.scss +1 -1
- package/progress/internal/circular-progress-styles.css.js +1 -1
- package/progress/internal/circular-progress-styles.css.js.map +1 -1
- package/progress/internal/circular-progress.js +11 -10
- package/progress/internal/circular-progress.js.map +1 -1
- package/progress/internal/linear-progress-styles.css.js +1 -1
- package/progress/internal/linear-progress-styles.css.js.map +1 -1
- package/progress/internal/linear-progress.d.ts +1 -1
- package/progress/internal/linear-progress.js +3 -3
- package/progress/internal/linear-progress.js.map +1 -1
- package/progress/internal/progress.js +4 -2
- package/progress/internal/progress.js.map +1 -1
- package/radio/internal/radio.d.ts +11 -27
- package/radio/internal/radio.js +30 -54
- package/radio/internal/radio.js.map +1 -1
- package/radio/internal/single-selection-controller.js +1 -1
- package/radio/internal/single-selection-controller.js.map +1 -1
- package/ripple/internal/ripple.js +14 -9
- package/ripple/internal/ripple.js.map +1 -1
- package/select/filled-select.js +1 -2
- package/select/filled-select.js.map +1 -1
- package/select/harness.js +1 -1
- package/select/harness.js.map +1 -1
- package/select/internal/select.d.ts +25 -34
- package/select/internal/select.js +101 -91
- package/select/internal/select.js.map +1 -1
- package/select/internal/selectoption/select-option.d.ts +8 -6
- package/select/internal/selectoption/select-option.js +23 -22
- package/select/internal/selectoption/select-option.js.map +1 -1
- package/select/internal/selectoption/selectOptionController.js +1 -1
- package/select/internal/selectoption/selectOptionController.js.map +1 -1
- package/select/outlined-select.js +1 -2
- package/select/outlined-select.js.map +1 -1
- package/slider/harness.js +5 -5
- package/slider/harness.js.map +1 -1
- package/slider/internal/slider.d.ts +16 -25
- package/slider/internal/slider.js +110 -114
- package/slider/internal/slider.js.map +1 -1
- package/switch/internal/switch.d.ts +9 -25
- package/switch/internal/switch.js +31 -57
- package/switch/internal/switch.js.map +1 -1
- package/tabs/harness.js +3 -3
- package/tabs/harness.js.map +1 -1
- package/tabs/internal/_tab.scss +27 -35
- package/tabs/internal/primary-tab.d.ts +0 -2
- package/tabs/internal/tab-styles.css.js +1 -1
- package/tabs/internal/tab-styles.css.js.map +1 -1
- package/tabs/internal/tab.d.ts +4 -5
- package/tabs/internal/tab.js +34 -22
- package/tabs/internal/tab.js.map +1 -1
- package/tabs/internal/tabs.d.ts +6 -2
- package/tabs/internal/tabs.js +18 -11
- package/tabs/internal/tabs.js.map +1 -1
- package/textfield/filled-text-field.js +1 -2
- package/textfield/filled-text-field.js.map +1 -1
- package/textfield/harness.js +3 -2
- package/textfield/harness.js.map +1 -1
- package/textfield/internal/text-field.d.ts +26 -18
- package/textfield/internal/text-field.js +81 -58
- package/textfield/internal/text-field.js.map +1 -1
- package/textfield/outlined-text-field.js +1 -2
- package/textfield/outlined-text-field.js.map +1 -1
- package/tokens/_index.scss +3 -0
- package/tokens/_md-comp-elevated-card.scss +63 -0
- package/tokens/_md-comp-filled-card.scss +63 -0
- package/tokens/_md-comp-icon.scss +2 -0
- package/tokens/_md-comp-outlined-card.scss +69 -0
- package/tokens/_md-comp-test-table.scss +1 -0
- package/internal/controller/element-internals.d.ts +0 -35
- package/internal/controller/element-internals.js +0 -24
- package/internal/controller/element-internals.js.map +0 -1
- package/select/internal/filled-forced-colors-styles.css.js +0 -9
- package/select/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/select/internal/filled-forced-colors-styles.scss +0 -29
- package/select/internal/outlined-forced-colors-styles.css.js +0 -9
- package/select/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/select/internal/outlined-forced-colors-styles.scss +0 -29
- package/textfield/internal/filled-forced-colors-styles.css.js +0 -9
- package/textfield/internal/filled-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/filled-forced-colors-styles.scss +0 -29
- package/textfield/internal/outlined-forced-colors-styles.css.js +0 -9
- package/textfield/internal/outlined-forced-colors-styles.css.js.map +0 -1
- package/textfield/internal/outlined-forced-colors-styles.scss +0 -29
- /package/{select/internal/filled-forced-colors-styles.css.d.ts → labs/card/internal/elevated-styles.css.d.ts} +0 -0
- /package/{select/internal/outlined-forced-colors-styles.css.d.ts → labs/card/internal/filled-styles.css.d.ts} +0 -0
- /package/{textfield/internal/filled-forced-colors-styles.css.d.ts → labs/card/internal/outlined-styles.css.d.ts} +0 -0
- /package/{textfield/internal/outlined-forced-colors-styles.css.d.ts → labs/card/internal/shared-styles.css.d.ts} +0 -0
|
@@ -6,23 +6,25 @@
|
|
|
6
6
|
import '../../menu/menu.js';
|
|
7
7
|
import { LitElement, PropertyValues } from 'lit';
|
|
8
8
|
import { StaticValue } from 'lit/static-html.js';
|
|
9
|
+
import { getFormValue } from '../../labs/behaviors/form-associated.js';
|
|
9
10
|
import { SelectOption } from './selectoption/selectOptionController.js';
|
|
10
11
|
declare const VALUE: unique symbol;
|
|
12
|
+
declare const selectBaseClass: import("../../labs/behaviors/mixin.js").MixinReturn<(abstract new (...args: any[]) => import("../../labs/behaviors/element-internals.js").WithElementInternals) & typeof LitElement & import("../../labs/behaviors/form-associated.js").FormAssociatedConstructor, import("../../labs/behaviors/form-associated.js").FormAssociated>;
|
|
11
13
|
/**
|
|
12
|
-
* @fires
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @fires
|
|
20
|
-
*
|
|
21
|
-
*
|
|
14
|
+
* @fires change {Event} The native `change` event on
|
|
15
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)
|
|
16
|
+
* --bubbles
|
|
17
|
+
* @fires input {InputEvent} The native `input` event on
|
|
18
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)
|
|
19
|
+
* --bubbles --composed
|
|
20
|
+
* @fires opening {Event} Fired when the select's menu is about to open.
|
|
21
|
+
* @fires opened {Event} Fired when the select's menu has finished animations
|
|
22
|
+
* and opened.
|
|
23
|
+
* @fires closing {Event} Fired when the select's menu is about to close.
|
|
24
|
+
* @fires closed {Event} Fired when the select's menu has finished animations
|
|
25
|
+
* and closed.
|
|
22
26
|
*/
|
|
23
|
-
export declare abstract class Select extends
|
|
24
|
-
/** @nocollapse */
|
|
25
|
-
static readonly formAssociated = true;
|
|
27
|
+
export declare abstract class Select extends selectBaseClass {
|
|
26
28
|
/**
|
|
27
29
|
* Opens the menu synchronously with no animation.
|
|
28
30
|
*/
|
|
@@ -31,10 +33,6 @@ export declare abstract class Select extends LitElement {
|
|
|
31
33
|
* Whether or not the select is required.
|
|
32
34
|
*/
|
|
33
35
|
required: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Disables the select.
|
|
36
|
-
*/
|
|
37
|
-
disabled: boolean;
|
|
38
36
|
/**
|
|
39
37
|
* The error message that replaces supporting text when `error` is true. If
|
|
40
38
|
* `errorText` is an empty string, then the supporting text will continue to
|
|
@@ -67,7 +65,7 @@ export declare abstract class Select extends LitElement {
|
|
|
67
65
|
* position:fixed is useful for cases where select is inside of another
|
|
68
66
|
* element with stacking context and hidden overflows such as `md-dialog`.
|
|
69
67
|
*/
|
|
70
|
-
menuPositioning: 'absolute' | 'fixed';
|
|
68
|
+
menuPositioning: 'absolute' | 'fixed' | 'popover';
|
|
71
69
|
/**
|
|
72
70
|
* The max time between the keystrokes of the typeahead select / menu behavior
|
|
73
71
|
* before it clears the typeahead buffer.
|
|
@@ -106,19 +104,6 @@ export declare abstract class Select extends LitElement {
|
|
|
106
104
|
* NOTE: md-select only suppoprts single selection.
|
|
107
105
|
*/
|
|
108
106
|
get selectedOptions(): SelectOption[];
|
|
109
|
-
/**
|
|
110
|
-
* The HTML name to use in form submission.
|
|
111
|
-
*/
|
|
112
|
-
get name(): string;
|
|
113
|
-
set name(name: string);
|
|
114
|
-
/**
|
|
115
|
-
* The associated form element with which this element's value will submit.
|
|
116
|
-
*/
|
|
117
|
-
get form(): HTMLFormElement;
|
|
118
|
-
/**
|
|
119
|
-
* The labels this element is associated with.
|
|
120
|
-
*/
|
|
121
|
-
get labels(): NodeList;
|
|
122
107
|
/**
|
|
123
108
|
* Returns a ValidityState object that represents the validity states of the
|
|
124
109
|
* checkbox.
|
|
@@ -171,8 +156,9 @@ export declare abstract class Select extends LitElement {
|
|
|
171
156
|
private readonly menu;
|
|
172
157
|
private readonly labelEl;
|
|
173
158
|
private readonly leadingIcons;
|
|
159
|
+
private isCheckingValidity;
|
|
160
|
+
private isReportingValidity;
|
|
174
161
|
private customValidationMessage;
|
|
175
|
-
private readonly internals;
|
|
176
162
|
/**
|
|
177
163
|
* Selects an option given the value of the option, and updates MdSelect's
|
|
178
164
|
* value.
|
|
@@ -215,6 +201,7 @@ export declare abstract class Select extends LitElement {
|
|
|
215
201
|
* @return true if the select is valid, or false if not.
|
|
216
202
|
*/
|
|
217
203
|
reportValidity(): boolean;
|
|
204
|
+
private showErrorMessage;
|
|
218
205
|
/**
|
|
219
206
|
* Sets the select's native validation error message. This is used to
|
|
220
207
|
* customize `validationMessage`.
|
|
@@ -305,9 +292,13 @@ export declare abstract class Select extends LitElement {
|
|
|
305
292
|
private getErrorText;
|
|
306
293
|
private syncValidity;
|
|
307
294
|
private getRequiredValidationMessage;
|
|
308
|
-
|
|
295
|
+
private readonly onInvalid;
|
|
296
|
+
connectedCallback(): void;
|
|
297
|
+
disconnectedCallback(): void;
|
|
298
|
+
disabled: boolean;
|
|
299
|
+
name: string;
|
|
300
|
+
[getFormValue](): string;
|
|
309
301
|
formResetCallback(): void;
|
|
310
|
-
/** @private */
|
|
311
302
|
formStateRestoreCallback(state: string): void;
|
|
312
303
|
}
|
|
313
304
|
export {};
|
|
@@ -12,25 +12,31 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
12
12
|
import { html as staticHtml } from 'lit/static-html.js';
|
|
13
13
|
import { requestUpdateOnAriaChange } from '../../internal/aria/delegate.js';
|
|
14
14
|
import { redispatchEvent } from '../../internal/controller/events.js';
|
|
15
|
+
import { internals, mixinElementInternals, } from '../../labs/behaviors/element-internals.js';
|
|
16
|
+
import { getFormValue, mixinFormAssociated, } from '../../labs/behaviors/form-associated.js';
|
|
15
17
|
import { getActiveItem } from '../../list/internal/list-navigation-helpers.js';
|
|
16
|
-
import { isElementInSubtree, isSelectableKey } from '../../menu/internal/controllers/shared.js';
|
|
18
|
+
import { isElementInSubtree, isSelectableKey, } from '../../menu/internal/controllers/shared.js';
|
|
17
19
|
import { TYPEAHEAD_RECORD } from '../../menu/internal/controllers/typeaheadController.js';
|
|
18
20
|
import { DEFAULT_TYPEAHEAD_BUFFER_TIME } from '../../menu/internal/menu.js';
|
|
19
21
|
import { getSelectedItems } from './shared.js';
|
|
20
22
|
const VALUE = Symbol('value');
|
|
23
|
+
// Separate variable needed for closure.
|
|
24
|
+
const selectBaseClass = mixinFormAssociated(mixinElementInternals(LitElement));
|
|
21
25
|
/**
|
|
22
|
-
* @fires
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @fires
|
|
30
|
-
*
|
|
31
|
-
*
|
|
26
|
+
* @fires change {Event} The native `change` event on
|
|
27
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)
|
|
28
|
+
* --bubbles
|
|
29
|
+
* @fires input {InputEvent} The native `input` event on
|
|
30
|
+
* [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)
|
|
31
|
+
* --bubbles --composed
|
|
32
|
+
* @fires opening {Event} Fired when the select's menu is about to open.
|
|
33
|
+
* @fires opened {Event} Fired when the select's menu has finished animations
|
|
34
|
+
* and opened.
|
|
35
|
+
* @fires closing {Event} Fired when the select's menu is about to close.
|
|
36
|
+
* @fires closed {Event} Fired when the select's menu has finished animations
|
|
37
|
+
* and closed.
|
|
32
38
|
*/
|
|
33
|
-
export class Select extends
|
|
39
|
+
export class Select extends selectBaseClass {
|
|
34
40
|
constructor() {
|
|
35
41
|
super(...arguments);
|
|
36
42
|
/**
|
|
@@ -41,10 +47,6 @@ export class Select extends LitElement {
|
|
|
41
47
|
* Whether or not the select is required.
|
|
42
48
|
*/
|
|
43
49
|
this.required = false;
|
|
44
|
-
/**
|
|
45
|
-
* Disables the select.
|
|
46
|
-
*/
|
|
47
|
-
this.disabled = false;
|
|
48
50
|
/**
|
|
49
51
|
* The error message that replaces supporting text when `error` is true. If
|
|
50
52
|
* `errorText` is an empty string, then the supporting text will continue to
|
|
@@ -77,7 +79,7 @@ export class Select extends LitElement {
|
|
|
77
79
|
* position:fixed is useful for cases where select is inside of another
|
|
78
80
|
* element with stacking context and hidden overflows such as `md-dialog`.
|
|
79
81
|
*/
|
|
80
|
-
this.menuPositioning = '
|
|
82
|
+
this.menuPositioning = 'popover';
|
|
81
83
|
/**
|
|
82
84
|
* The max time between the keystrokes of the typeahead select / menu behavior
|
|
83
85
|
* before it clears the typeahead buffer.
|
|
@@ -118,8 +120,15 @@ export class Select extends LitElement {
|
|
|
118
120
|
this.nativeErrorText = '';
|
|
119
121
|
this.focused = false;
|
|
120
122
|
this.open = false;
|
|
123
|
+
this.isCheckingValidity = false;
|
|
124
|
+
this.isReportingValidity = false;
|
|
121
125
|
this.customValidationMessage = '';
|
|
122
|
-
this.
|
|
126
|
+
this.onInvalid = (invalidEvent) => {
|
|
127
|
+
if (this.isCheckingValidity || this.isReportingValidity) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.showErrorMessage(false, invalidEvent);
|
|
131
|
+
};
|
|
123
132
|
}
|
|
124
133
|
/**
|
|
125
134
|
* The value of the currently selected option.
|
|
@@ -164,27 +173,6 @@ export class Select extends LitElement {
|
|
|
164
173
|
get selectedOptions() {
|
|
165
174
|
return (this.getSelectedOptions() ?? []).map(([option]) => option);
|
|
166
175
|
}
|
|
167
|
-
/**
|
|
168
|
-
* The HTML name to use in form submission.
|
|
169
|
-
*/
|
|
170
|
-
get name() {
|
|
171
|
-
return this.getAttribute('name') ?? '';
|
|
172
|
-
}
|
|
173
|
-
set name(name) {
|
|
174
|
-
this.setAttribute('name', name);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* The associated form element with which this element's value will submit.
|
|
178
|
-
*/
|
|
179
|
-
get form() {
|
|
180
|
-
return this.internals.form;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* The labels this element is associated with.
|
|
184
|
-
*/
|
|
185
|
-
get labels() {
|
|
186
|
-
return this.internals.labels;
|
|
187
|
-
}
|
|
188
176
|
/**
|
|
189
177
|
* Returns a ValidityState object that represents the validity states of the
|
|
190
178
|
* checkbox.
|
|
@@ -194,7 +182,7 @@ export class Select extends LitElement {
|
|
|
194
182
|
*/
|
|
195
183
|
get validity() {
|
|
196
184
|
this.syncValidity();
|
|
197
|
-
return this
|
|
185
|
+
return this[internals].validity;
|
|
198
186
|
}
|
|
199
187
|
/**
|
|
200
188
|
* Returns the native validation error message.
|
|
@@ -203,7 +191,7 @@ export class Select extends LitElement {
|
|
|
203
191
|
*/
|
|
204
192
|
get validationMessage() {
|
|
205
193
|
this.syncValidity();
|
|
206
|
-
return this
|
|
194
|
+
return this[internals].validationMessage;
|
|
207
195
|
}
|
|
208
196
|
/**
|
|
209
197
|
* Returns whether an element will successfully validate based on forms
|
|
@@ -213,7 +201,7 @@ export class Select extends LitElement {
|
|
|
213
201
|
*/
|
|
214
202
|
get willValidate() {
|
|
215
203
|
this.syncValidity();
|
|
216
|
-
return this
|
|
204
|
+
return this[internals].willValidate;
|
|
217
205
|
}
|
|
218
206
|
get hasError() {
|
|
219
207
|
return this.error || this.nativeError;
|
|
@@ -223,7 +211,7 @@ export class Select extends LitElement {
|
|
|
223
211
|
* value.
|
|
224
212
|
*/
|
|
225
213
|
select(value) {
|
|
226
|
-
const optionToSelect = this.options.find(option => option.value === value);
|
|
214
|
+
const optionToSelect = this.options.find((option) => option.value === value);
|
|
227
215
|
if (optionToSelect) {
|
|
228
216
|
this.selectItem(optionToSelect);
|
|
229
217
|
}
|
|
@@ -260,8 +248,11 @@ export class Select extends LitElement {
|
|
|
260
248
|
* @return true if the select is valid, or false if not.
|
|
261
249
|
*/
|
|
262
250
|
checkValidity() {
|
|
251
|
+
this.isCheckingValidity = true;
|
|
263
252
|
this.syncValidity();
|
|
264
|
-
|
|
253
|
+
const isValid = this[internals].checkValidity();
|
|
254
|
+
this.isCheckingValidity = false;
|
|
255
|
+
return isValid;
|
|
265
256
|
}
|
|
266
257
|
/**
|
|
267
258
|
* Checks the select's native validation and returns whether or not the
|
|
@@ -280,11 +271,17 @@ export class Select extends LitElement {
|
|
|
280
271
|
* @return true if the select is valid, or false if not.
|
|
281
272
|
*/
|
|
282
273
|
reportValidity() {
|
|
274
|
+
this.isReportingValidity = true;
|
|
283
275
|
let invalidEvent;
|
|
284
|
-
this.addEventListener('invalid', event => {
|
|
276
|
+
this.addEventListener('invalid', (event) => {
|
|
285
277
|
invalidEvent = event;
|
|
286
278
|
}, { once: true });
|
|
287
279
|
const valid = this.checkValidity();
|
|
280
|
+
this.showErrorMessage(valid, invalidEvent);
|
|
281
|
+
this.isReportingValidity = false;
|
|
282
|
+
return valid;
|
|
283
|
+
}
|
|
284
|
+
showErrorMessage(valid, invalidEvent) {
|
|
288
285
|
if (invalidEvent?.defaultPrevented) {
|
|
289
286
|
return valid;
|
|
290
287
|
}
|
|
@@ -322,10 +319,9 @@ export class Select extends LitElement {
|
|
|
322
319
|
render() {
|
|
323
320
|
return html `
|
|
324
321
|
<span
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
${this.renderField()}
|
|
328
|
-
${this.renderMenu()}
|
|
322
|
+
class="select ${classMap(this.getRenderClasses())}"
|
|
323
|
+
@focusout=${this.handleFocusout}>
|
|
324
|
+
${this.renderField()} ${this.renderMenu()}
|
|
329
325
|
</span>
|
|
330
326
|
`;
|
|
331
327
|
}
|
|
@@ -342,7 +338,8 @@ export class Select extends LitElement {
|
|
|
342
338
|
}
|
|
343
339
|
// Case for when the DOM is streaming, there are no children, and a child
|
|
344
340
|
// has [selected] set on it, we need to wait for DOM to render something.
|
|
345
|
-
if (!this.lastSelectedOptionRecords.length &&
|
|
341
|
+
if (!this.lastSelectedOptionRecords.length &&
|
|
342
|
+
!isServer &&
|
|
346
343
|
!this.options.length) {
|
|
347
344
|
setTimeout(() => {
|
|
348
345
|
this.updateValueAndDisplayText();
|
|
@@ -399,21 +396,29 @@ export class Select extends LitElement {
|
|
|
399
396
|
renderLeadingIcon() {
|
|
400
397
|
return html `
|
|
401
398
|
<span class="icon leading" slot="start">
|
|
402
|
-
|
|
399
|
+
<slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
|
|
403
400
|
</span>
|
|
404
|
-
|
|
401
|
+
`;
|
|
405
402
|
}
|
|
406
403
|
renderTrailingIcon() {
|
|
407
404
|
return html `
|
|
408
405
|
<span class="icon trailing" slot="end">
|
|
409
406
|
<slot name="trailing-icon" @slotchange=${this.handleIconChange}>
|
|
410
407
|
<svg height="5" viewBox="7 10 10 5" focusable="false">
|
|
411
|
-
<polygon
|
|
412
|
-
|
|
408
|
+
<polygon
|
|
409
|
+
class="down"
|
|
410
|
+
stroke="none"
|
|
411
|
+
fill-rule="evenodd"
|
|
412
|
+
points="7 10 12 15 17 10"></polygon>
|
|
413
|
+
<polygon
|
|
414
|
+
class="up"
|
|
415
|
+
stroke="none"
|
|
416
|
+
fill-rule="evenodd"
|
|
417
|
+
points="7 15 12 10 17 15"></polygon>
|
|
413
418
|
</svg>
|
|
414
419
|
</slot>
|
|
415
420
|
</span>
|
|
416
|
-
|
|
421
|
+
`;
|
|
417
422
|
}
|
|
418
423
|
renderLabel() {
|
|
419
424
|
// need to render so that line-height can apply and give it a
|
|
@@ -422,30 +427,29 @@ export class Select extends LitElement {
|
|
|
422
427
|
}
|
|
423
428
|
renderMenu() {
|
|
424
429
|
const ariaLabel = this.label || this.ariaLabel;
|
|
425
|
-
return html `
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
</md-menu>`;
|
|
430
|
+
return html ` <md-menu
|
|
431
|
+
id="listbox"
|
|
432
|
+
default-focus="none"
|
|
433
|
+
role="listbox"
|
|
434
|
+
tabindex="-1"
|
|
435
|
+
aria-label=${ariaLabel || nothing}
|
|
436
|
+
stay-open-on-focusout
|
|
437
|
+
part="menu"
|
|
438
|
+
exportparts="focus-ring: menu-focus-ring"
|
|
439
|
+
anchor="field"
|
|
440
|
+
.open=${this.open}
|
|
441
|
+
.quick=${this.quick}
|
|
442
|
+
.positioning=${this.menuPositioning}
|
|
443
|
+
.typeaheadDelay=${this.typeaheadDelay}
|
|
444
|
+
@opening=${this.handleOpening}
|
|
445
|
+
@opened=${this.redispatchEvent}
|
|
446
|
+
@closing=${this.redispatchEvent}
|
|
447
|
+
@closed=${this.handleClosed}
|
|
448
|
+
@close-menu=${this.handleCloseMenu}
|
|
449
|
+
@request-selection=${this.handleRequestSelection}
|
|
450
|
+
@request-deselection=${this.handleRequestDeselection}>
|
|
451
|
+
${this.renderMenuContent()}
|
|
452
|
+
</md-menu>`;
|
|
449
453
|
}
|
|
450
454
|
renderMenuContent() {
|
|
451
455
|
return html `<slot></slot>`;
|
|
@@ -459,7 +463,8 @@ export class Select extends LitElement {
|
|
|
459
463
|
return;
|
|
460
464
|
}
|
|
461
465
|
const typeaheadController = this.menu.typeaheadController;
|
|
462
|
-
const isOpenKey = event.code === 'Space' ||
|
|
466
|
+
const isOpenKey = event.code === 'Space' ||
|
|
467
|
+
event.code === 'ArrowDown' ||
|
|
463
468
|
event.code === 'Enter';
|
|
464
469
|
// Do not open if currently typing ahead because the user may be typing the
|
|
465
470
|
// spacebar to match a word with a space
|
|
@@ -549,7 +554,6 @@ export class Select extends LitElement {
|
|
|
549
554
|
this[VALUE] = '';
|
|
550
555
|
this.displayText = '';
|
|
551
556
|
}
|
|
552
|
-
this.internals.setFormValue(this.value);
|
|
553
557
|
this.syncValidity();
|
|
554
558
|
return hasSelectedOptionChanged;
|
|
555
559
|
}
|
|
@@ -683,8 +687,9 @@ export class Select extends LitElement {
|
|
|
683
687
|
const valueMissing = this.required && !this.value;
|
|
684
688
|
const customError = !!this.customValidationMessage;
|
|
685
689
|
const validationMessage = this.customValidationMessage ||
|
|
686
|
-
valueMissing && this.getRequiredValidationMessage() ||
|
|
687
|
-
|
|
690
|
+
(valueMissing && this.getRequiredValidationMessage()) ||
|
|
691
|
+
'';
|
|
692
|
+
this[internals].setValidity({ valueMissing, customError }, validationMessage, this.field ?? undefined);
|
|
688
693
|
}
|
|
689
694
|
// Returns the platform `<select>` validation message for i18n.
|
|
690
695
|
getRequiredValidationMessage() {
|
|
@@ -692,30 +697,35 @@ export class Select extends LitElement {
|
|
|
692
697
|
select.required = true;
|
|
693
698
|
return select.validationMessage;
|
|
694
699
|
}
|
|
695
|
-
|
|
700
|
+
connectedCallback() {
|
|
701
|
+
super.connectedCallback();
|
|
702
|
+
// Handles the case where the user submits the form and native validation
|
|
703
|
+
// error pops up. We want the error styles to show.
|
|
704
|
+
this.addEventListener('invalid', this.onInvalid);
|
|
705
|
+
}
|
|
706
|
+
disconnectedCallback() {
|
|
707
|
+
super.disconnectedCallback();
|
|
708
|
+
this.removeEventListener('invalid', this.onInvalid);
|
|
709
|
+
}
|
|
710
|
+
[(_a = VALUE, getFormValue)]() {
|
|
711
|
+
return this.value;
|
|
712
|
+
}
|
|
696
713
|
formResetCallback() {
|
|
697
714
|
this.reset();
|
|
698
715
|
}
|
|
699
|
-
/** @private */
|
|
700
716
|
formStateRestoreCallback(state) {
|
|
701
717
|
this.value = state;
|
|
702
718
|
}
|
|
703
719
|
}
|
|
704
|
-
_a = VALUE;
|
|
705
720
|
(() => {
|
|
706
721
|
requestUpdateOnAriaChange(Select);
|
|
707
722
|
})();
|
|
708
|
-
/** @nocollapse */
|
|
709
|
-
Select.formAssociated = true;
|
|
710
723
|
__decorate([
|
|
711
724
|
property({ type: Boolean })
|
|
712
725
|
], Select.prototype, "quick", void 0);
|
|
713
726
|
__decorate([
|
|
714
727
|
property({ type: Boolean })
|
|
715
728
|
], Select.prototype, "required", void 0);
|
|
716
|
-
__decorate([
|
|
717
|
-
property({ type: Boolean, reflect: true })
|
|
718
|
-
], Select.prototype, "disabled", void 0);
|
|
719
729
|
__decorate([
|
|
720
730
|
property({ type: String, attribute: 'error-text' })
|
|
721
731
|
], Select.prototype, "errorText", void 0);
|