@material/web 1.0.0-pre.6 → 1.0.0-pre.7
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 +7 -7
- package/aria/aria.d.ts +43 -0
- package/aria/aria.js +56 -0
- package/aria/aria.js.map +1 -0
- package/aria/delegate.d.ts +37 -0
- package/aria/delegate.js +53 -0
- package/aria/delegate.js.map +1 -0
- package/badge/badge.d.ts +0 -1
- package/badge/badge.js +0 -1
- package/badge/badge.js.map +1 -1
- package/badge/lib/badge.d.ts +8 -7
- package/badge/lib/badge.js +5 -6
- package/badge/lib/badge.js.map +1 -1
- package/button/lib/_elevation.scss +13 -3
- package/button/lib/button.d.ts +1 -12
- package/button/lib/button.js +29 -60
- package/button/lib/button.js.map +1 -1
- package/button/lib/shared-elevation-styles.css.js +1 -1
- package/button/lib/shared-elevation-styles.css.js.map +1 -1
- package/checkbox/lib/checkbox.d.ts +0 -1
- package/checkbox/lib/checkbox.js +33 -43
- package/checkbox/lib/checkbox.js.map +1 -1
- package/chips/_filter-chip.scss +6 -0
- package/chips/filter-chip.d.ts +20 -0
- package/chips/filter-chip.js +24 -0
- package/chips/filter-chip.js.map +1 -0
- package/chips/lib/_filter-chip.scss +141 -0
- package/chips/lib/_shared.scss +18 -14
- 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 +8 -3
- package/chips/lib/chip.js +29 -30
- package/chips/lib/chip.js.map +1 -1
- package/chips/lib/filter-chip.d.ts +21 -0
- package/chips/lib/filter-chip.js +47 -0
- package/chips/lib/filter-chip.js.map +1 -0
- package/chips/lib/filter-styles.css.js +9 -0
- package/chips/lib/filter-styles.css.js.map +1 -0
- package/{fab/lib/fab-extended-styles.scss → chips/lib/filter-styles.scss} +3 -3
- package/chips/lib/shared-styles.css.js +1 -1
- package/chips/lib/shared-styles.css.js.map +1 -1
- package/chips/lib/suggestion-styles.css.js +1 -1
- package/chips/lib/suggestion-styles.css.js.map +1 -1
- package/circularprogress/harness.d.ts +1 -0
- package/circularprogress/harness.js +4 -0
- package/circularprogress/harness.js.map +1 -1
- package/circularprogress/lib/circular-progress.d.ts +0 -1
- package/circularprogress/lib/circular-progress.js +16 -19
- package/circularprogress/lib/circular-progress.js.map +1 -1
- package/dialog/lib/_dialog.scss +8 -8
- package/dialog/lib/dialog-styles.css.js +1 -1
- package/dialog/lib/dialog-styles.css.js.map +1 -1
- package/dialog/lib/dialog.js +25 -49
- package/dialog/lib/dialog.js.map +1 -1
- package/divider/lib/divider.js +4 -7
- package/divider/lib/divider.js.map +1 -1
- package/elevation/lib/_elevation.scss +5 -7
- package/elevation/lib/elevation-styles.css.js +1 -1
- package/elevation/lib/elevation-styles.css.js.map +1 -1
- package/fab/_fab.scss +1 -0
- package/fab/branded-fab.d.ts +53 -0
- package/fab/branded-fab.js +56 -0
- package/fab/branded-fab.js.map +1 -0
- package/fab/fab.d.ts +25 -5
- package/fab/fab.js +27 -10
- package/fab/fab.js.map +1 -1
- package/fab/harness.d.ts +1 -2
- package/fab/harness.js +1 -1
- package/fab/harness.js.map +1 -1
- package/fab/lib/_fab-branded.scss +27 -0
- package/fab/lib/_fab.scss +144 -16
- package/fab/lib/_shared.scss +155 -130
- package/fab/lib/fab-branded-styles.css.js +9 -0
- package/fab/lib/fab-branded-styles.css.js.map +1 -0
- package/fab/lib/fab-branded-styles.scss +10 -0
- 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 +14 -10
- package/fab/lib/fab.js +19 -12
- package/fab/lib/fab.js.map +1 -1
- package/fab/lib/forced-colors-styles.css.d.ts +1 -0
- package/fab/lib/forced-colors-styles.css.js +9 -0
- package/fab/lib/forced-colors-styles.css.js.map +1 -0
- package/fab/lib/forced-colors-styles.scss +26 -0
- package/fab/lib/shared-styles.css.d.ts +1 -0
- package/fab/lib/shared-styles.css.js +9 -0
- package/fab/lib/shared-styles.css.js.map +1 -0
- package/fab/lib/{fab-shared-styles.scss → shared-styles.scss} +1 -1
- package/fab/lib/{fab-shared.d.ts → shared.d.ts} +24 -16
- package/fab/lib/shared.js +137 -0
- package/fab/lib/shared.js.map +1 -0
- package/field/lib/field.js +14 -27
- package/field/lib/field.js.map +1 -1
- package/focus/focus-ring.d.ts +0 -1
- package/focus/focus-ring.js +0 -1
- package/focus/focus-ring.js.map +1 -1
- package/focus/lib/focus-ring.js +2 -3
- package/focus/lib/focus-ring.js.map +1 -1
- package/focus/strong-focus.js +5 -0
- package/focus/strong-focus.js.map +1 -1
- package/icon/icon.d.ts +0 -1
- package/icon/icon.js +0 -1
- package/icon/icon.js.map +1 -1
- package/icon/lib/_icon.scss +2 -0
- package/icon/lib/icon-styles.css.js +1 -1
- package/icon/lib/icon-styles.css.js.map +1 -1
- package/icon/lib/icon.d.ts +5 -4
- package/icon/lib/icon.js +3 -2
- package/icon/lib/icon.js.map +1 -1
- package/iconbutton/lib/icon-button.d.ts +0 -4
- package/iconbutton/lib/icon-button.js +28 -48
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/linearprogress/_linear-progress.scss +6 -0
- package/linearprogress/harness.d.ts +13 -0
- package/linearprogress/harness.js +18 -0
- package/linearprogress/harness.js.map +1 -0
- package/linearprogress/lib/_linear-progress.scss +380 -0
- package/linearprogress/lib/linear-progress-styles.css.d.ts +1 -0
- package/linearprogress/lib/linear-progress-styles.css.js +9 -0
- package/linearprogress/lib/linear-progress-styles.css.js.map +1 -0
- package/linearprogress/lib/linear-progress-styles.scss +8 -0
- package/linearprogress/lib/linear-progress.d.ts +35 -0
- package/linearprogress/lib/linear-progress.js +127 -0
- package/linearprogress/lib/linear-progress.js.map +1 -0
- package/linearprogress/linear-progress.d.ts +23 -0
- package/linearprogress/linear-progress.js +26 -0
- package/linearprogress/linear-progress.js.map +1 -0
- package/list/lib/_list.scss +6 -49
- package/list/lib/list-styles.css.js +1 -1
- package/list/lib/list-styles.css.js.map +1 -1
- package/list/lib/list.d.ts +1 -3
- package/list/lib/list.js +18 -34
- package/list/lib/list.js.map +1 -1
- package/list/lib/listitem/_list-item.scss +10 -69
- package/list/lib/listitem/forced-colors-styles.css.js +1 -1
- package/list/lib/listitem/forced-colors-styles.css.js.map +1 -1
- 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 +2 -4
- package/list/lib/listitem/list-item.js +24 -53
- package/list/lib/listitem/list-item.js.map +1 -1
- package/list/lib/listitemlink/list-item-link.js +4 -6
- package/list/lib/listitemlink/list-item-link.js.map +1 -1
- package/menu/lib/_menu.scss +6 -28
- 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 +1 -2
- package/menu/lib/menu.js +38 -63
- package/menu/lib/menu.js.map +1 -1
- package/menu/lib/menuitem/_menu-item.scss +13 -32
- package/menu/lib/menuitem/menu-item-styles.css.js +1 -1
- package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/lib/menuitem/menu-item.d.ts +1 -1
- package/menu/lib/menuitem/menu-item.js +4 -6
- package/menu/lib/menuitem/menu-item.js.map +1 -1
- package/menu/lib/menuitemlink/menu-item-link.d.ts +0 -2
- package/menu/lib/menuitemlink/menu-item-link.js +3 -6
- package/menu/lib/menuitemlink/menu-item-link.js.map +1 -1
- package/menu/lib/shared.d.ts +6 -2
- package/menu/lib/shared.js.map +1 -1
- package/menu/lib/submenuitem/sub-menu-item.d.ts +0 -2
- package/menu/lib/submenuitem/sub-menu-item.js +7 -15
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
- package/navigationbar/lib/_navigation-bar.scss +7 -1
- package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
- package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
- package/navigationbar/lib/navigation-bar.d.ts +5 -5
- package/navigationbar/lib/navigation-bar.js +17 -18
- package/navigationbar/lib/navigation-bar.js.map +1 -1
- package/navigationbar/navigation-bar.d.ts +0 -1
- package/navigationbar/navigation-bar.js +0 -1
- package/navigationbar/navigation-bar.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal.d.ts +5 -10
- package/navigationdrawer/lib/navigation-drawer-modal.js +19 -41
- package/navigationdrawer/lib/navigation-drawer-modal.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer.d.ts +5 -9
- package/navigationdrawer/lib/navigation-drawer.js +17 -38
- package/navigationdrawer/lib/navigation-drawer.js.map +1 -1
- package/navigationdrawer/navigation-drawer-modal.d.ts +0 -1
- package/navigationdrawer/navigation-drawer-modal.js +0 -1
- package/navigationdrawer/navigation-drawer-modal.js.map +1 -1
- package/navigationdrawer/navigation-drawer.d.ts +0 -1
- package/navigationdrawer/navigation-drawer.js +0 -1
- package/navigationdrawer/navigation-drawer.js.map +1 -1
- package/navigationtab/lib/navigation-tab.d.ts +19 -24
- package/navigationtab/lib/navigation-tab.js +48 -68
- package/navigationtab/lib/navigation-tab.js.map +1 -1
- package/navigationtab/navigation-tab.d.ts +0 -1
- package/navigationtab/navigation-tab.js +0 -1
- package/navigationtab/navigation-tab.js.map +1 -1
- package/package.json +1 -1
- package/radio/lib/radio.d.ts +0 -1
- package/radio/lib/radio.js +30 -37
- package/radio/lib/radio.js.map +1 -1
- package/ripple/lib/ripple.js +7 -13
- package/ripple/lib/ripple.js.map +1 -1
- package/segmentedbutton/lib/outlined-segmented-button.d.ts +16 -7
- package/segmentedbutton/lib/outlined-segmented-button.js +3 -3
- package/segmentedbutton/lib/outlined-segmented-button.js.map +1 -1
- package/segmentedbutton/lib/segmented-button.d.ts +27 -33
- package/segmentedbutton/lib/segmented-button.js +42 -75
- package/segmentedbutton/lib/segmented-button.js.map +1 -1
- package/segmentedbutton/outlined-segmented-button.d.ts +0 -1
- package/segmentedbutton/outlined-segmented-button.js +0 -1
- package/segmentedbutton/outlined-segmented-button.js.map +1 -1
- package/segmentedbuttonset/lib/outlined-segmented-button-set.d.ts +6 -4
- package/segmentedbuttonset/lib/outlined-segmented-button-set.js +3 -2
- package/segmentedbuttonset/lib/outlined-segmented-button-set.js.map +1 -1
- package/segmentedbuttonset/lib/segmented-button-set.d.ts +3 -9
- package/segmentedbuttonset/lib/segmented-button-set.js +14 -20
- package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
- package/segmentedbuttonset/outlined-segmented-button-set.d.ts +0 -1
- package/segmentedbuttonset/outlined-segmented-button-set.js +0 -1
- package/segmentedbuttonset/outlined-segmented-button-set.js.map +1 -1
- package/select/_filled-select.scss +6 -0
- package/select/_outlined-select.scss +6 -0
- package/select/filled-select.d.ts +41 -0
- package/select/filled-select.js +46 -0
- package/select/filled-select.js.map +1 -0
- package/select/harness.d.ts +24 -0
- package/select/harness.js +53 -0
- package/select/harness.js.map +1 -0
- package/select/lib/_filled-select.scss +163 -0
- package/select/lib/_outlined-select.scss +146 -0
- package/select/lib/_shared.scss +48 -0
- package/select/lib/filled-forced-colors-styles.css.d.ts +1 -0
- package/select/lib/filled-forced-colors-styles.css.js +9 -0
- package/select/lib/filled-forced-colors-styles.css.js.map +1 -0
- package/select/lib/filled-forced-colors-styles.scss +29 -0
- package/select/lib/filled-select-styles.css.d.ts +1 -0
- package/select/lib/filled-select-styles.css.js +9 -0
- package/select/lib/filled-select-styles.css.js.map +1 -0
- package/select/lib/filled-select-styles.scss +10 -0
- package/select/lib/filled-select.d.ts +10 -0
- package/select/lib/filled-select.js +16 -0
- package/select/lib/filled-select.js.map +1 -0
- package/select/lib/outlined-forced-colors-styles.css.d.ts +1 -0
- package/select/lib/outlined-forced-colors-styles.css.js +9 -0
- package/select/lib/outlined-forced-colors-styles.css.js.map +1 -0
- package/select/lib/outlined-forced-colors-styles.scss +29 -0
- package/select/lib/outlined-select-styles.css.d.ts +1 -0
- package/select/lib/outlined-select-styles.css.js +9 -0
- package/select/lib/outlined-select-styles.css.js.map +1 -0
- package/select/lib/outlined-select-styles.scss +10 -0
- package/select/lib/outlined-select.d.ts +10 -0
- package/select/lib/outlined-select.js +16 -0
- package/select/lib/outlined-select.js.map +1 -0
- package/select/lib/select.d.ts +218 -0
- package/select/lib/select.js +587 -0
- package/select/lib/select.js.map +1 -0
- package/select/lib/selectoption/harness.d.ts +11 -0
- package/select/lib/selectoption/harness.js +12 -0
- package/select/lib/selectoption/harness.js.map +1 -0
- package/select/lib/selectoption/select-option.d.ts +30 -0
- package/select/lib/selectoption/select-option.js +71 -0
- package/select/lib/selectoption/select-option.js.map +1 -0
- package/select/lib/shared-styles.css.d.ts +1 -0
- package/select/lib/shared-styles.css.js +9 -0
- package/select/lib/shared-styles.css.js.map +1 -0
- package/select/lib/shared-styles.scss +10 -0
- package/select/lib/shared.d.ts +52 -0
- package/select/lib/shared.js +41 -0
- package/select/lib/shared.js.map +1 -0
- package/select/outlined-select.d.ts +41 -0
- package/select/outlined-select.js +46 -0
- package/select/outlined-select.js.map +1 -0
- package/select/select-option.d.ts +44 -0
- package/select/select-option.js +51 -0
- package/select/select-option.js.map +1 -0
- package/slider/harness.d.ts +1 -0
- package/slider/harness.js +5 -0
- package/slider/harness.js.map +1 -1
- package/slider/lib/_slider.scss +146 -164
- package/slider/lib/forced-colors-styles.css.js +1 -1
- package/slider/lib/forced-colors-styles.css.js.map +1 -1
- package/slider/lib/forced-colors-styles.scss +2 -2
- 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 +2 -7
- package/slider/lib/slider.js +64 -118
- package/slider/lib/slider.js.map +1 -1
- package/switch/lib/switch.d.ts +0 -2
- package/switch/lib/switch.js +32 -54
- package/switch/lib/switch.js.map +1 -1
- package/textfield/lib/text-field.d.ts +0 -10
- package/textfield/lib/text-field.js +45 -115
- package/textfield/lib/text-field.js.map +1 -1
- package/tokens/_index.scss +3 -0
- package/tokens/_md-comp-assist-chip.scss +25 -20
- package/tokens/_md-comp-elevation.scss +0 -4
- package/tokens/_md-comp-fab-branded.scss +109 -1
- package/tokens/_md-comp-fab.scss +290 -0
- package/tokens/_md-comp-filled-select.scss +150 -1
- package/tokens/_md-comp-filter-chip.scss +103 -93
- package/tokens/_md-comp-input-chip.scss +77 -85
- package/tokens/_md-comp-linear-progress-indicator.scss +14 -1
- package/tokens/_md-comp-list-item.scss +201 -0
- package/tokens/_md-comp-list.scss +107 -26
- package/tokens/_md-comp-menu-item.scss +76 -0
- package/tokens/_md-comp-menu.scss +52 -2
- package/tokens/_md-comp-outlined-select.scss +150 -1
- package/tokens/_md-comp-slider.scss +13 -1
- package/tokens/_md-comp-suggestion-chip.scss +29 -21
- package/tokens/_values.scss +5 -2
- package/types/aria.d.ts +61 -1
- package/actionelement/action-element.d.ts +0 -79
- package/actionelement/action-element.js +0 -97
- package/actionelement/action-element.js.map +0 -1
- package/button/lib/state.d.ts +0 -10
- package/button/lib/state.js +0 -7
- package/button/lib/state.js.map +0 -1
- package/controller/action-controller.d.ts +0 -147
- package/controller/action-controller.js +0 -286
- package/controller/action-controller.js.map +0 -1
- package/decorators/aria-property.d.ts +0 -32
- package/decorators/aria-property.js +0 -99
- package/decorators/aria-property.js.map +0 -1
- package/fab/_fab-extended.scss +0 -6
- package/fab/fab-extended.d.ts +0 -23
- package/fab/fab-extended.js +0 -29
- package/fab/fab-extended.js.map +0 -1
- package/fab/lib/_fab-extended.scss +0 -73
- package/fab/lib/fab-extended-styles.css.js +0 -9
- package/fab/lib/fab-extended-styles.css.js.map +0 -1
- package/fab/lib/fab-extended.d.ts +0 -19
- package/fab/lib/fab-extended.js +0 -28
- package/fab/lib/fab-extended.js.map +0 -1
- package/fab/lib/fab-shared-styles.css.js +0 -9
- package/fab/lib/fab-shared-styles.css.js.map +0 -1
- package/fab/lib/fab-shared.js +0 -121
- package/fab/lib/fab-shared.js.map +0 -1
- package/slider/lib/_tokens.scss +0 -65
- /package/{fab/lib/fab-extended-styles.css.d.ts → chips/lib/filter-styles.css.d.ts} +0 -0
- /package/fab/lib/{fab-shared-styles.css.d.ts → fab-branded-styles.css.d.ts} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { PropertyValues } from 'lit';
|
|
7
|
+
import { MenuItemEl } from '../../../menu/lib/menuitem/menu-item.js';
|
|
8
|
+
import { ARIARole } from '../../../types/aria.js';
|
|
9
|
+
import { SelectOption } from '../shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* @fires close-menu {CloseMenuEvent} Closes the encapsulating menu on
|
|
12
|
+
* @fires request-selection {RequestSelectionEvent} Requests the parent
|
|
13
|
+
* md-select to select this element (and deselect others if single-selection)
|
|
14
|
+
* when `selected` changed to `true`.
|
|
15
|
+
* @fires request-deselection {RequestDeselectionEvent} Requests the parent
|
|
16
|
+
* md-select to deselect this element when `selected` changed to `false`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SelectOptionEl extends MenuItemEl implements SelectOption {
|
|
19
|
+
/**
|
|
20
|
+
* Form value of the option.
|
|
21
|
+
*/
|
|
22
|
+
value: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether or not this option is selected.
|
|
25
|
+
*/
|
|
26
|
+
selected: boolean;
|
|
27
|
+
protected readonly listItemRole: ARIARole;
|
|
28
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
29
|
+
updated(changed: PropertyValues<this>): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { property } from 'lit/decorators.js';
|
|
8
|
+
import { MenuItemEl } from '../../../menu/lib/menuitem/menu-item.js';
|
|
9
|
+
import { RequestDeselectionEvent, RequestSelectionEvent } from '../shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* @fires close-menu {CloseMenuEvent} Closes the encapsulating menu on
|
|
12
|
+
* @fires request-selection {RequestSelectionEvent} Requests the parent
|
|
13
|
+
* md-select to select this element (and deselect others if single-selection)
|
|
14
|
+
* when `selected` changed to `true`.
|
|
15
|
+
* @fires request-deselection {RequestDeselectionEvent} Requests the parent
|
|
16
|
+
* md-select to deselect this element when `selected` changed to `false`.
|
|
17
|
+
*/
|
|
18
|
+
export class SelectOptionEl extends MenuItemEl {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
/**
|
|
22
|
+
* Form value of the option.
|
|
23
|
+
*/
|
|
24
|
+
this.value = '';
|
|
25
|
+
/**
|
|
26
|
+
* Whether or not this option is selected.
|
|
27
|
+
*/
|
|
28
|
+
this.selected = false;
|
|
29
|
+
this.listItemRole = 'option';
|
|
30
|
+
}
|
|
31
|
+
willUpdate(changed) {
|
|
32
|
+
if (changed.has('selected')) {
|
|
33
|
+
// Synchronize selected -> active but not the other way around because
|
|
34
|
+
// active is used for keyboard navigation and doesn't mean the option
|
|
35
|
+
// should be selected if active.
|
|
36
|
+
this.active = this.selected;
|
|
37
|
+
this.ariaSelected = this.selected ? 'true' : 'false';
|
|
38
|
+
// By default active = true focuses the element. We want to prevent that
|
|
39
|
+
// in this case because we set active = this.selected and that may mess
|
|
40
|
+
// around with menu's restore focus function once the menu closes.
|
|
41
|
+
this.focusOnActivation = false;
|
|
42
|
+
}
|
|
43
|
+
super.willUpdate(changed);
|
|
44
|
+
}
|
|
45
|
+
updated(changed) {
|
|
46
|
+
super.updated(changed);
|
|
47
|
+
// Restore the active = true focusing behavior which happens in
|
|
48
|
+
// super.updated() if it was turned off.
|
|
49
|
+
this.focusOnActivation = true;
|
|
50
|
+
// Do not dispatch event on first update / boot-up.
|
|
51
|
+
if (changed.has('selected') && changed.get('selected') !== undefined) {
|
|
52
|
+
// This section is really useful for when the user sets selected on the
|
|
53
|
+
// option programmatically. Most other cases (click and keyboard) are
|
|
54
|
+
// handled by md-select because it needs to coordinate the
|
|
55
|
+
// single-selection behavior.
|
|
56
|
+
if (this.selected) {
|
|
57
|
+
this.dispatchEvent(new RequestSelectionEvent());
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.dispatchEvent(new RequestDeselectionEvent());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
__decorate([
|
|
66
|
+
property()
|
|
67
|
+
], SelectOptionEl.prototype, "value", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
property({ type: Boolean, reflect: true })
|
|
70
|
+
], SelectOptionEl.prototype, "selected", void 0);
|
|
71
|
+
//# sourceMappingURL=select-option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-option.js","sourceRoot":"","sources":["select-option.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAGH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAC,uBAAuB,EAAE,qBAAqB,EAAe,MAAM,cAAc,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAA9C;;QACE;;WAEG;QACS,UAAK,GAAG,EAAE,CAAC;QAEvB;;WAEG;QACuC,aAAQ,GAAG,KAAK,CAAC;QAE/B,iBAAY,GAAa,QAAQ,CAAC;IAqChE,CAAC;IAnCU,UAAU,CAAC,OAA6B;QAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC3B,sEAAsE;YACtE,qEAAqE;YACrE,gCAAgC;YAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;YACrD,wEAAwE;YACxE,uEAAuE;YACvE,kEAAkE;YAClE,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;SAChC;QAED,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAEQ,OAAO,CAAC,OAA6B;QAC5C,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,+DAA+D;QAC/D,wCAAwC;QACxC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAE9B,mDAAmD;QACnD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACpE,uEAAuE;YACvE,qEAAqE;YACrE,0DAA0D;YAC1D,6BAA6B;YAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjB,IAAI,CAAC,aAAa,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;aACjD;iBAAM;gBACL,IAAI,CAAC,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC,CAAC;aACnD;SACF;IACH,CAAC;CACF;AA5Ca;IAAX,QAAQ,EAAE;6CAAY;AAKmB;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;gDAAkB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {PropertyValues} from 'lit';\nimport {property} from 'lit/decorators.js';\n\nimport {MenuItemEl} from '../../../menu/lib/menuitem/menu-item.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {RequestDeselectionEvent, RequestSelectionEvent, SelectOption} from '../shared.js';\n\n/**\n * @fires close-menu {CloseMenuEvent} Closes the encapsulating menu on\n * @fires request-selection {RequestSelectionEvent} Requests the parent\n * md-select to select this element (and deselect others if single-selection)\n * when `selected` changed to `true`.\n * @fires request-deselection {RequestDeselectionEvent} Requests the parent\n * md-select to deselect this element when `selected` changed to `false`.\n */\nexport class SelectOptionEl extends MenuItemEl implements SelectOption {\n /**\n * Form value of the option.\n */\n @property() value = '';\n\n /**\n * Whether or not this option is selected.\n */\n @property({type: Boolean, reflect: true}) selected = false;\n\n protected override readonly listItemRole: ARIARole = 'option';\n\n override willUpdate(changed: PropertyValues<this>) {\n if (changed.has('selected')) {\n // Synchronize selected -> active but not the other way around because\n // active is used for keyboard navigation and doesn't mean the option\n // should be selected if active.\n this.active = this.selected;\n this.ariaSelected = this.selected ? 'true' : 'false';\n // By default active = true focuses the element. We want to prevent that\n // in this case because we set active = this.selected and that may mess\n // around with menu's restore focus function once the menu closes.\n this.focusOnActivation = false;\n }\n\n super.willUpdate(changed);\n }\n\n override updated(changed: PropertyValues<this>) {\n super.updated(changed);\n // Restore the active = true focusing behavior which happens in\n // super.updated() if it was turned off.\n this.focusOnActivation = true;\n\n // Do not dispatch event on first update / boot-up.\n if (changed.has('selected') && changed.get('selected') !== undefined) {\n // This section is really useful for when the user sets selected on the\n // option programmatically. Most other cases (click and keyboard) are\n // handled by md-select because it needs to coordinate the\n // single-selection behavior.\n if (this.selected) {\n this.dispatchEvent(new RequestSelectionEvent());\n } else {\n this.dispatchEvent(new RequestDeselectionEvent());\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
export const styles = css `:host{color:unset;min-width:210px}.field{cursor:default;outline:none}.select{position:relative}.field,.select{min-width:inherit}:host{display:inline-flex}.label{width:100%}:host([disabled]){pointer-events:none}/*# sourceMappingURL=shared-styles.css.map */
|
|
8
|
+
`;
|
|
9
|
+
//# sourceMappingURL=shared-styles.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-styles.css.js","sourceRoot":"","sources":["shared-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{color:unset;min-width:210px}.field{cursor:default;outline:none}.select{position:relative}.field,.select{min-width:inherit}:host{display:inline-flex}.label{width:100%}:host([disabled]){pointer-events:none}/*# sourceMappingURL=shared-styles.css.map */\n`;\n "]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { MenuItem } from '../../menu/lib/shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* The interface specific to a Select Option
|
|
9
|
+
*/
|
|
10
|
+
interface SelectOptionSelf {
|
|
11
|
+
/**
|
|
12
|
+
* The form value associated with the Select Option. (Note: the visual portion
|
|
13
|
+
* of the SelectOption is the headline defined in ListItem)
|
|
14
|
+
*/
|
|
15
|
+
value: string;
|
|
16
|
+
/**
|
|
17
|
+
* Whether or not the SelectOption is selected.
|
|
18
|
+
*/
|
|
19
|
+
selected: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The interface to implement for a select option. Additionally, the element
|
|
23
|
+
* must have `md-list-item` and `md-menu-item` attributes on the host.
|
|
24
|
+
*/
|
|
25
|
+
export type SelectOption = SelectOptionSelf & MenuItem;
|
|
26
|
+
/**
|
|
27
|
+
* A type that describes a SelectOption and its index.
|
|
28
|
+
*/
|
|
29
|
+
export type SelectOptionRecord = [SelectOption, number];
|
|
30
|
+
/**
|
|
31
|
+
* Given a list of select options, this function will return an array of
|
|
32
|
+
* SelectOptionRecords that are selected.
|
|
33
|
+
*
|
|
34
|
+
* @return An array of SelectOptionRecords describing the options that are
|
|
35
|
+
* selected.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getSelectedItems(items: SelectOption[]): SelectOptionRecord[];
|
|
38
|
+
/**
|
|
39
|
+
* An event fired by a SelectOption to request selection from md-select.
|
|
40
|
+
* Typically fired after `selected` changes from `false` to `true`.
|
|
41
|
+
*/
|
|
42
|
+
export declare class RequestSelectionEvent extends Event {
|
|
43
|
+
constructor();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An event fired by a SelectOption to request deselection from md-select.
|
|
47
|
+
* Typically fired after `selected` changes from `true` to `false`.
|
|
48
|
+
*/
|
|
49
|
+
export declare class RequestDeselectionEvent extends Event {
|
|
50
|
+
constructor();
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Given a list of select options, this function will return an array of
|
|
8
|
+
* SelectOptionRecords that are selected.
|
|
9
|
+
*
|
|
10
|
+
* @return An array of SelectOptionRecords describing the options that are
|
|
11
|
+
* selected.
|
|
12
|
+
*/
|
|
13
|
+
export function getSelectedItems(items) {
|
|
14
|
+
const selectedItemRecords = [];
|
|
15
|
+
for (let i = 0; i < items.length; i++) {
|
|
16
|
+
const item = items[i];
|
|
17
|
+
if (item.selected) {
|
|
18
|
+
selectedItemRecords.push([item, i]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return selectedItemRecords;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An event fired by a SelectOption to request selection from md-select.
|
|
25
|
+
* Typically fired after `selected` changes from `false` to `true`.
|
|
26
|
+
*/
|
|
27
|
+
export class RequestSelectionEvent extends Event {
|
|
28
|
+
constructor() {
|
|
29
|
+
super('request-selection', { bubbles: true, composed: true });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* An event fired by a SelectOption to request deselection from md-select.
|
|
34
|
+
* Typically fired after `selected` changes from `true` to `false`.
|
|
35
|
+
*/
|
|
36
|
+
export class RequestDeselectionEvent extends Event {
|
|
37
|
+
constructor() {
|
|
38
|
+
super('request-deselection', { bubbles: true, composed: true });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,MAAM,mBAAmB,GAAyB,EAAE,CAAC;IAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;SACrC;KACF;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C;QACE,KAAK,CAAC,mBAAmB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD;QACE,KAAK,CAAC,qBAAqB,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from '../../menu/lib/shared.js';\n\n/**\n * The interface specific to a Select Option\n */\ninterface SelectOptionSelf {\n /**\n * The form value associated with the Select Option. (Note: the visual portion\n * of the SelectOption is the headline defined in ListItem)\n */\n value: string;\n /**\n * Whether or not the SelectOption is selected.\n */\n selected: boolean;\n}\n\n/**\n * The interface to implement for a select option. Additionally, the element\n * must have `md-list-item` and `md-menu-item` attributes on the host.\n */\nexport type SelectOption = SelectOptionSelf&MenuItem;\n\n/**\n * A type that describes a SelectOption and its index.\n */\nexport type SelectOptionRecord = [SelectOption, number];\n\n/**\n * Given a list of select options, this function will return an array of\n * SelectOptionRecords that are selected.\n * \n * @return An array of SelectOptionRecords describing the options that are\n * selected.\n */\nexport function getSelectedItems(items: SelectOption[]) {\n const selectedItemRecords: SelectOptionRecord[] = [];\n\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item.selected) {\n selectedItemRecords.push([item, i]);\n }\n }\n\n return selectedItemRecords;\n}\n\n/**\n * An event fired by a SelectOption to request selection from md-select.\n * Typically fired after `selected` changes from `false` to `true`.\n */\nexport class RequestSelectionEvent extends Event {\n constructor() {\n super('request-selection', {bubbles: true, composed: true});\n }\n}\n\n/**\n * An event fired by a SelectOption to request deselection from md-select.\n * Typically fired after `selected` changes from `true` to `false`.\n */\nexport class RequestDeselectionEvent extends Event {\n constructor() {\n super('request-deselection', {bubbles: true, composed: true});\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OutlinedSelect } from './lib/outlined-select.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'md-outlined-select': MdOutlinedSelect;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @summary
|
|
14
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
15
|
+
* currently selected menu item above the menu.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* The select component allows users to choose a value from a fixed list of
|
|
19
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
20
|
+
* analogous to the native HTML `<select>` element. This is the "outlined"
|
|
21
|
+
* variant.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```html
|
|
25
|
+
* <md-outlined-select label="fruits">
|
|
26
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
27
|
+
* <md-select-option selected></md-select-option>
|
|
28
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
29
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
30
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
31
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
32
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
33
|
+
* </md-outlined-select>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @final
|
|
37
|
+
* @suppress {visibility}
|
|
38
|
+
*/
|
|
39
|
+
export declare class MdOutlinedSelect extends OutlinedSelect {
|
|
40
|
+
static styles: import("lit").CSSResult[];
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as outlinedForcedColorsStyles } from './lib/outlined-forced-colors-styles.css.js';
|
|
9
|
+
import { OutlinedSelect } from './lib/outlined-select.js';
|
|
10
|
+
import { styles } from './lib/outlined-select-styles.css.js';
|
|
11
|
+
import { styles as sharedStyles } from './lib/shared-styles.css.js';
|
|
12
|
+
/**
|
|
13
|
+
* @summary
|
|
14
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
15
|
+
* currently selected menu item above the menu.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* The select component allows users to choose a value from a fixed list of
|
|
19
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
20
|
+
* analogous to the native HTML `<select>` element. This is the "outlined"
|
|
21
|
+
* variant.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```html
|
|
25
|
+
* <md-outlined-select label="fruits">
|
|
26
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
27
|
+
* <md-select-option selected></md-select-option>
|
|
28
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
29
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
30
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
31
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
32
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
33
|
+
* </md-outlined-select>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @final
|
|
37
|
+
* @suppress {visibility}
|
|
38
|
+
*/
|
|
39
|
+
let MdOutlinedSelect = class MdOutlinedSelect extends OutlinedSelect {
|
|
40
|
+
};
|
|
41
|
+
MdOutlinedSelect.styles = [sharedStyles, styles, outlinedForcedColorsStyles];
|
|
42
|
+
MdOutlinedSelect = __decorate([
|
|
43
|
+
customElement('md-outlined-select')
|
|
44
|
+
], MdOutlinedSelect);
|
|
45
|
+
export { MdOutlinedSelect };
|
|
46
|
+
//# sourceMappingURL=outlined-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outlined-select.js","sourceRoot":"","sources":["outlined-select.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,0BAA0B,EAAC,MAAM,4CAA4C,CAAC;AAChG,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,qCAAqC,CAAC;AAC3D,OAAO,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAQlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,cAAc;;AAClC,uBAAM,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,0BAA0B,CAAC,CAAC;AADjE,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAE5B;SAFY,gBAAgB","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as outlinedForcedColorsStyles} from './lib/outlined-forced-colors-styles.css.js';\nimport {OutlinedSelect} from './lib/outlined-select.js';\nimport {styles} from './lib/outlined-select-styles.css.js';\nimport {styles as sharedStyles} from './lib/shared-styles.css.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-outlined-select': MdOutlinedSelect;\n }\n}\n\n/**\n * @summary\n * Select menus display a list of choices on temporary surfaces and display the\n * currently selected menu item above the menu.\n *\n * @description\n * The select component allows users to choose a value from a fixed list of\n * available options. Composed of an interactive anchor button and a menu, it is\n * analogous to the native HTML `<select>` element. This is the \"outlined\"\n * variant.\n *\n * @example\n * ```html\n * <md-outlined-select label=\"fruits\">\n * <!-- An empty selected option will give select an \"un-filled\" state -->\n * <md-select-option selected></md-select-option>\n * <md-select-option value=\"apple\" headline=\"Apple\"></md-select-option>\n * <md-select-option value=\"banana\" headline=\"Banana\"></md-select-option>\n * <md-select-option value=\"kiwi\" headline=\"Kiwi\"></md-select-option>\n * <md-select-option value=\"orange\" headline=\"Orange\"></md-select-option>\n * <md-select-option value=\"tomato\" headline=\"Tomato\"></md-select-option>\n * </md-outlined-select>\n * ```\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-outlined-select')\nexport class MdOutlinedSelect extends OutlinedSelect {\n static override styles = [sharedStyles, styles, outlinedForcedColorsStyles];\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { SelectOptionEl } from './lib/selectoption/select-option.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'md-select-option': MdSelectOption;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @summary
|
|
14
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
15
|
+
* currently selected menu item above the menu.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* The select component allows users to choose a value from a fixed list of
|
|
19
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
20
|
+
* analogous to the native HTML `<select>` element. This is the option that
|
|
21
|
+
* can be placed inside of an md-select.
|
|
22
|
+
*
|
|
23
|
+
* This component is a subclass of `md-menu-item` and can accept the same slots,
|
|
24
|
+
* properties, and events as `md-menu-item`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```html
|
|
28
|
+
* <md-outlined-select label="fruits">
|
|
29
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
30
|
+
* <md-select-option selected></md-select-option>
|
|
31
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
32
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
33
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
34
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
35
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
36
|
+
* </md-outlined-select>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @final
|
|
40
|
+
* @suppress {visibility}
|
|
41
|
+
*/
|
|
42
|
+
export declare class MdSelectOption extends SelectOptionEl {
|
|
43
|
+
static styles: import("lit").CSSResult[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as listItemForcedColorsStyles } from '../list/lib/listitem/forced-colors-styles.css.js';
|
|
9
|
+
import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js';
|
|
10
|
+
import { styles as forcedColorsStyles } from '../menu/lib/menuitem/forced-colors-styles.css.js';
|
|
11
|
+
import { styles } from '../menu/lib/menuitem/menu-item-styles.css.js';
|
|
12
|
+
// TODO(b/236285090): update with HCM best practices
|
|
13
|
+
import { SelectOptionEl } from './lib/selectoption/select-option.js';
|
|
14
|
+
/**
|
|
15
|
+
* @summary
|
|
16
|
+
* Select menus display a list of choices on temporary surfaces and display the
|
|
17
|
+
* currently selected menu item above the menu.
|
|
18
|
+
*
|
|
19
|
+
* @description
|
|
20
|
+
* The select component allows users to choose a value from a fixed list of
|
|
21
|
+
* available options. Composed of an interactive anchor button and a menu, it is
|
|
22
|
+
* analogous to the native HTML `<select>` element. This is the option that
|
|
23
|
+
* can be placed inside of an md-select.
|
|
24
|
+
*
|
|
25
|
+
* This component is a subclass of `md-menu-item` and can accept the same slots,
|
|
26
|
+
* properties, and events as `md-menu-item`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <md-outlined-select label="fruits">
|
|
31
|
+
* <!-- An empty selected option will give select an "un-filled" state -->
|
|
32
|
+
* <md-select-option selected></md-select-option>
|
|
33
|
+
* <md-select-option value="apple" headline="Apple"></md-select-option>
|
|
34
|
+
* <md-select-option value="banana" headline="Banana"></md-select-option>
|
|
35
|
+
* <md-select-option value="kiwi" headline="Kiwi"></md-select-option>
|
|
36
|
+
* <md-select-option value="orange" headline="Orange"></md-select-option>
|
|
37
|
+
* <md-select-option value="tomato" headline="Tomato"></md-select-option>
|
|
38
|
+
* </md-outlined-select>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @final
|
|
42
|
+
* @suppress {visibility}
|
|
43
|
+
*/
|
|
44
|
+
let MdSelectOption = class MdSelectOption extends SelectOptionEl {
|
|
45
|
+
};
|
|
46
|
+
MdSelectOption.styles = [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];
|
|
47
|
+
MdSelectOption = __decorate([
|
|
48
|
+
customElement('md-select-option')
|
|
49
|
+
], MdSelectOption);
|
|
50
|
+
export { MdSelectOption };
|
|
51
|
+
//# sourceMappingURL=select-option.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-option.js","sourceRoot":"","sources":["select-option.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,0BAA0B,EAAC,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAC,MAAM,IAAI,kBAAkB,EAAC,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAC,MAAM,EAAC,MAAM,8CAA8C,CAAC;AAEpE,oDAAoD;AACpD,OAAO,EAAC,cAAc,EAAC,MAAM,qCAAqC,CAAC;AAQnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,cAAc;;AAChC,qBAAM,GAClB,CAAC,cAAc,EAAE,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAFlE,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAG1B;SAHY,cAAc","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as listItemForcedColorsStyles} from '../list/lib/listitem/forced-colors-styles.css.js';\nimport {styles as listItemStyles} from '../list/lib/listitem/list-item-styles.css.js';\nimport {styles as forcedColorsStyles} from '../menu/lib/menuitem/forced-colors-styles.css.js';\nimport {styles} from '../menu/lib/menuitem/menu-item-styles.css.js';\n\n// TODO(b/236285090): update with HCM best practices\nimport {SelectOptionEl} from './lib/selectoption/select-option.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-select-option': MdSelectOption;\n }\n}\n\n/**\n * @summary\n * Select menus display a list of choices on temporary surfaces and display the\n * currently selected menu item above the menu.\n *\n * @description\n * The select component allows users to choose a value from a fixed list of\n * available options. Composed of an interactive anchor button and a menu, it is\n * analogous to the native HTML `<select>` element. This is the option that\n * can be placed inside of an md-select.\n *\n * This component is a subclass of `md-menu-item` and can accept the same slots,\n * properties, and events as `md-menu-item`.\n *\n * @example\n * ```html\n * <md-outlined-select label=\"fruits\">\n * <!-- An empty selected option will give select an \"un-filled\" state -->\n * <md-select-option selected></md-select-option>\n * <md-select-option value=\"apple\" headline=\"Apple\"></md-select-option>\n * <md-select-option value=\"banana\" headline=\"Banana\"></md-select-option>\n * <md-select-option value=\"kiwi\" headline=\"Kiwi\"></md-select-option>\n * <md-select-option value=\"orange\" headline=\"Orange\"></md-select-option>\n * <md-select-option value=\"tomato\" headline=\"Tomato\"></md-select-option>\n * </md-outlined-select>\n * ```\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-select-option')\nexport class MdSelectOption extends SelectOptionEl {\n static override styles =\n [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];\n}\n"]}
|
package/slider/harness.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ export declare class SliderHarness extends Harness<Slider> {
|
|
|
17
17
|
simulateValueInteraction(value: number, el?: HTMLInputElement): Promise<void>;
|
|
18
18
|
private positionEventAtHandle;
|
|
19
19
|
protected simulateStartHover(element: HTMLElement, init?: PointerEventInit): void;
|
|
20
|
+
protected simulateMousePress(element: HTMLElement, init?: PointerEventInit): void;
|
|
20
21
|
}
|
package/slider/harness.js
CHANGED
|
@@ -59,5 +59,10 @@ export class SliderHarness extends Harness {
|
|
|
59
59
|
}
|
|
60
60
|
super.simulateStartHover(element, init);
|
|
61
61
|
}
|
|
62
|
+
simulateMousePress(element, init = {}) {
|
|
63
|
+
super.simulateMousePress(element, init);
|
|
64
|
+
// advance beyond RAF, which is used by the element's pointerDown handler.
|
|
65
|
+
jasmine.clock().tick(1);
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
//# sourceMappingURL=harness.js.map
|
package/slider/harness.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.js","sourceRoot":"","sources":["harness.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {Harness} from '../testing/harness.js';\n\nimport {Slider} from './lib/slider.js';\n\n/**\n * Test harness for slider.\n */\nexport class SliderHarness extends Harness<Slider> {\n override async getInteractiveElement() {\n await this.element.updateComplete;\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return this.element['inputB'];\n }\n\n getInputs() {\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return [this.element['inputB'], this.element['inputA']];\n }\n getHandles() {\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return [this.element['handleB'], this.element['handleA']];\n }\n\n getLabels() {\n return Array.from(this.element.renderRoot.querySelectorAll('.label'));\n }\n\n isLabelShowing() {\n const labels = this.getLabels();\n return labels.some(l => {\n // remove transition to avoid the need to wait for it.\n (l as HTMLElement).style.setProperty('transition', 'none');\n const {width} = l.getBoundingClientRect();\n (l as HTMLElement).style.removeProperty('transition');\n return width > 0;\n });\n }\n\n async simulateValueInteraction(value: number, el?: HTMLInputElement) {\n if (!el) {\n el = (this.getInputs())[0];\n }\n el.focus();\n el.value = String(value);\n el.dispatchEvent(new Event('input', {bubbles: true, composed: true}));\n el.dispatchEvent(new Event('change', {bubbles: true}));\n await this.element.updateComplete;\n }\n\n private positionEventAtHandle(init: PointerEventInit, startHandle = false) {\n const handle = this.getHandles()[startHandle ? 1 : 0];\n const {x, y} = handle.getBoundingClientRect();\n return {...init, clientX: x, clientY: y, screenX: x, screenY: y};\n }\n\n protected override simulateStartHover(\n element: HTMLElement, init: PointerEventInit = {}) {\n const i = this.getInputs().indexOf(element as HTMLInputElement);\n if ((i >= 0) || (element === this.element)) {\n init = this.positionEventAtHandle(init, i === 1);\n }\n super.simulateStartHover(element, init);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["harness.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {Harness} from '../testing/harness.js';\n\nimport {Slider} from './lib/slider.js';\n\n/**\n * Test harness for slider.\n */\nexport class SliderHarness extends Harness<Slider> {\n override async getInteractiveElement() {\n await this.element.updateComplete;\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return this.element['inputB'];\n }\n\n getInputs() {\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return [this.element['inputB'], this.element['inputA']];\n }\n getHandles() {\n // Test access to protected property\n // tslint:disable-next-line:no-dict-access-on-struct-type\n return [this.element['handleB'], this.element['handleA']];\n }\n\n getLabels() {\n return Array.from(this.element.renderRoot.querySelectorAll('.label'));\n }\n\n isLabelShowing() {\n const labels = this.getLabels();\n return labels.some(l => {\n // remove transition to avoid the need to wait for it.\n (l as HTMLElement).style.setProperty('transition', 'none');\n const {width} = l.getBoundingClientRect();\n (l as HTMLElement).style.removeProperty('transition');\n return width > 0;\n });\n }\n\n async simulateValueInteraction(value: number, el?: HTMLInputElement) {\n if (!el) {\n el = (this.getInputs())[0];\n }\n el.focus();\n el.value = String(value);\n el.dispatchEvent(new Event('input', {bubbles: true, composed: true}));\n el.dispatchEvent(new Event('change', {bubbles: true}));\n await this.element.updateComplete;\n }\n\n private positionEventAtHandle(init: PointerEventInit, startHandle = false) {\n const handle = this.getHandles()[startHandle ? 1 : 0];\n const {x, y} = handle.getBoundingClientRect();\n return {...init, clientX: x, clientY: y, screenX: x, screenY: y};\n }\n\n protected override simulateStartHover(\n element: HTMLElement, init: PointerEventInit = {}) {\n const i = this.getInputs().indexOf(element as HTMLInputElement);\n if ((i >= 0) || (element === this.element)) {\n init = this.positionEventAtHandle(init, i === 1);\n }\n super.simulateStartHover(element, init);\n }\n\n protected override simulateMousePress(\n element: HTMLElement, init: PointerEventInit = {}) {\n super.simulateMousePress(element, init);\n // advance beyond RAF, which is used by the element's pointerDown handler.\n jasmine.clock().tick(1);\n }\n}\n"]}
|