@material/web 1.0.1 → 1.0.2-nightly.33c1afe.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 +20 -87
- package/checkbox/internal/checkbox.js +35 -153
- 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/_shared.scss +1 -0
- 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/shared-styles.css.js +1 -1
- package/chips/internal/shared-styles.css.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/_shared.scss +1 -0
- package/fab/internal/fab.js.map +1 -1
- package/fab/internal/shared-styles.css.js +1 -1
- package/fab/internal/shared-styles.css.js.map +1 -1
- package/fab/internal/shared.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/constraint-validation.d.ts +133 -0
- package/labs/behaviors/constraint-validation.js +114 -0
- package/labs/behaviors/constraint-validation.js.map +1 -0
- 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/behaviors/on-report-validity.d.ts +70 -0
- package/labs/behaviors/on-report-validity.js +150 -0
- package/labs/behaviors/on-report-validity.js.map +1 -0
- package/labs/behaviors/validators/checkbox-validator.d.ts +31 -0
- package/labs/behaviors/validators/checkbox-validator.js +29 -0
- package/labs/behaviors/validators/checkbox-validator.js.map +1 -0
- package/labs/behaviors/validators/select-validator.d.ts +31 -0
- package/labs/behaviors/validators/select-validator.js +30 -0
- package/labs/behaviors/validators/select-validator.js.map +1 -0
- package/labs/behaviors/validators/validator.d.ts +92 -0
- package/labs/behaviors/validators/validator.js +83 -0
- package/labs/behaviors/validators/validator.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/_shared.scss +1 -0
- 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/segmentedbutton/internal/shared-styles.css.js +1 -1
- package/labs/segmentedbutton/internal/shared-styles.css.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/_list-item.scss +1 -0
- package/list/internal/listitem/harness.d.ts +1 -1
- package/list/internal/listitem/harness.js.map +1 -1
- package/list/internal/listitem/list-item-styles.css.js +1 -1
- package/list/internal/listitem/list-item-styles.css.js.map +1 -1
- package/list/internal/listitem/list-item.d.ts +3 -2
- package/list/internal/listitem/list-item.js +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 +16 -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 +26 -99
- package/select/internal/select.js +78 -187
- 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 +13 -89
- package/switch/internal/switch.js +32 -159
- 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
|
@@ -10,6 +10,12 @@ import { LitElement, PropertyValues } from 'lit';
|
|
|
10
10
|
import { NavigationTabState } from './state.js';
|
|
11
11
|
/**
|
|
12
12
|
* TODO(b/265346501): add docs
|
|
13
|
+
*
|
|
14
|
+
* @fires navigation-tab-rendered {Event} Dispatched when the navigation tab's
|
|
15
|
+
* DOM has rendered and custom element definition has loaded. --bubbles
|
|
16
|
+
* --composed
|
|
17
|
+
* @fires navigation-tab-interaction {CustomEvent<{state: MdNavigationTab}>}
|
|
18
|
+
* Dispatched when the navigation tab has been clicked. --bubbles --composed
|
|
13
19
|
*/
|
|
14
20
|
export declare class NavigationTab extends LitElement implements NavigationTabState {
|
|
15
21
|
disabled: boolean;
|
|
@@ -13,6 +13,12 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
13
13
|
import { requestUpdateOnAriaChange } from '../../../internal/aria/delegate.js';
|
|
14
14
|
/**
|
|
15
15
|
* TODO(b/265346501): add docs
|
|
16
|
+
*
|
|
17
|
+
* @fires navigation-tab-rendered {Event} Dispatched when the navigation tab's
|
|
18
|
+
* DOM has rendered and custom element definition has loaded. --bubbles
|
|
19
|
+
* --composed
|
|
20
|
+
* @fires navigation-tab-interaction {CustomEvent<{state: MdNavigationTab}>}
|
|
21
|
+
* Dispatched when the navigation tab has been clicked. --bubbles --composed
|
|
16
22
|
*/
|
|
17
23
|
export class NavigationTab extends LitElement {
|
|
18
24
|
constructor() {
|
|
@@ -26,27 +32,27 @@ export class NavigationTab extends LitElement {
|
|
|
26
32
|
render() {
|
|
27
33
|
// Needed for closure conformance
|
|
28
34
|
const { ariaLabel } = this;
|
|
29
|
-
return html `
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
return html ` <button
|
|
36
|
+
class="md3-navigation-tab ${classMap(this.getRenderClasses())}"
|
|
37
|
+
role="tab"
|
|
38
|
+
aria-selected="${this.active}"
|
|
39
|
+
aria-label=${ariaLabel || nothing}
|
|
40
|
+
tabindex="${this.active ? 0 : -1}"
|
|
41
|
+
@click="${this.handleClick}">
|
|
42
|
+
<md-focus-ring part="focus-ring" inward></md-focus-ring>
|
|
43
|
+
<md-ripple
|
|
44
|
+
?disabled="${this.disabled}"
|
|
45
|
+
class="md3-navigation-tab__ripple"></md-ripple>
|
|
46
|
+
<span aria-hidden="true" class="md3-navigation-tab__icon-content"
|
|
47
|
+
><span class="md3-navigation-tab__active-indicator"></span
|
|
48
|
+
><span class="md3-navigation-tab__icon"
|
|
43
49
|
><slot name="inactive-icon"></slot
|
|
44
50
|
></span>
|
|
45
51
|
<span class="md3-navigation-tab__icon md3-navigation-tab__icon--active"
|
|
46
|
-
><slot name="active-icon"></slot
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
><slot name="active-icon"></slot></span
|
|
53
|
+
>${this.renderBadge()}</span
|
|
54
|
+
>${this.renderLabel()}
|
|
55
|
+
</button>`;
|
|
50
56
|
}
|
|
51
57
|
getRenderClasses() {
|
|
52
58
|
return {
|
|
@@ -55,22 +61,28 @@ export class NavigationTab extends LitElement {
|
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
63
|
renderBadge() {
|
|
58
|
-
return this.showBadge
|
|
59
|
-
html `<md-badge .value="${this.badgeValue}"></md-badge>`
|
|
60
|
-
nothing;
|
|
64
|
+
return this.showBadge
|
|
65
|
+
? html `<md-badge .value="${this.badgeValue}"></md-badge>`
|
|
66
|
+
: nothing;
|
|
61
67
|
}
|
|
62
68
|
renderLabel() {
|
|
63
69
|
// Needed for closure conformance
|
|
64
70
|
const { ariaLabel } = this;
|
|
65
71
|
const ariaHidden = ariaLabel ? 'true' : 'false';
|
|
66
|
-
return !this.label
|
|
67
|
-
nothing
|
|
68
|
-
html `
|
|
69
|
-
|
|
72
|
+
return !this.label
|
|
73
|
+
? nothing
|
|
74
|
+
: html ` <span
|
|
75
|
+
aria-hidden="${ariaHidden}"
|
|
76
|
+
class="md3-navigation-tab__label-text"
|
|
77
|
+
>${this.label}</span
|
|
78
|
+
>`;
|
|
70
79
|
}
|
|
71
80
|
firstUpdated(changedProperties) {
|
|
72
81
|
super.firstUpdated(changedProperties);
|
|
73
|
-
const event = new Event('navigation-tab-rendered', {
|
|
82
|
+
const event = new Event('navigation-tab-rendered', {
|
|
83
|
+
bubbles: true,
|
|
84
|
+
composed: true,
|
|
85
|
+
});
|
|
74
86
|
this.dispatchEvent(event);
|
|
75
87
|
}
|
|
76
88
|
focus() {
|
|
@@ -87,7 +99,11 @@ export class NavigationTab extends LitElement {
|
|
|
87
99
|
}
|
|
88
100
|
handleClick() {
|
|
89
101
|
// TODO(b/269772145): connect to ripple
|
|
90
|
-
this.dispatchEvent(new CustomEvent('navigation-tab-interaction', {
|
|
102
|
+
this.dispatchEvent(new CustomEvent('navigation-tab-interaction', {
|
|
103
|
+
detail: { state: this },
|
|
104
|
+
bubbles: true,
|
|
105
|
+
composed: true,
|
|
106
|
+
}));
|
|
91
107
|
}
|
|
92
108
|
}
|
|
93
109
|
(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-tab.js","sourceRoot":"","sources":["navigation-tab.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,iCAAiC,CAAC;AACzC,OAAO,2BAA2B,CAAC;AACnC,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAiB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAGrD,OAAO,EAAC,yBAAyB,EAAC,MAAM,oCAAoC,CAAC;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AAa,CAAC,CAAC;AAC3C,CAAC,GAAA,CAAA;AAE0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CAAkB;AACF;IAAzC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;6CAAgB;AAEzD;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAC,CAAC;wDAClC;AACd;IAAX,QAAQ,EAAE;4CAAgB;AACW;IAArC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;iDAAiB;AACF;IAAnD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAC,CAAC;gDAAmB;AAErD;IAAhB,KAAK,CAAC,QAAQ,CAAC;oDAAoC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../focus/md-focus-ring.js';\nimport '../../../ripple/ripple.js';\nimport '../../badge/badge.js';\n\nimport {html, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, query} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ARIAMixinStrict} from '../../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../../internal/aria/delegate.js';\n\nimport {NavigationTabState} from './state.js';\n\n/**\n * TODO(b/265346501): add docs\n *\n * @fires navigation-tab-rendered {Event} Dispatched when the navigation tab's\n * DOM has rendered and custom element definition has loaded. --bubbles\n * --composed\n * @fires navigation-tab-interaction {CustomEvent<{state: MdNavigationTab}>}\n * Dispatched when the navigation tab has been clicked. --bubbles --composed\n */\nexport class NavigationTab extends LitElement implements NavigationTabState {\n static {\n requestUpdateOnAriaChange(NavigationTab);\n }\n\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean, reflect: true}) active = false;\n @property({type: Boolean, attribute: 'hide-inactive-label'})\n hideInactiveLabel = false;\n @property() label?: string;\n @property({attribute: 'badge-value'}) badgeValue = '';\n @property({type: Boolean, attribute: 'show-badge'}) showBadge = false;\n\n @query('button') buttonElement!: HTMLElement | null;\n\n protected override render() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html` <button\n class=\"md3-navigation-tab ${classMap(this.getRenderClasses())}\"\n role=\"tab\"\n aria-selected=\"${this.active}\"\n aria-label=${ariaLabel || nothing}\n tabindex=\"${this.active ? 0 : -1}\"\n @click=\"${this.handleClick}\">\n <md-focus-ring part=\"focus-ring\" inward></md-focus-ring>\n <md-ripple\n ?disabled=\"${this.disabled}\"\n class=\"md3-navigation-tab__ripple\"></md-ripple>\n <span aria-hidden=\"true\" class=\"md3-navigation-tab__icon-content\"\n ><span class=\"md3-navigation-tab__active-indicator\"></span\n ><span class=\"md3-navigation-tab__icon\"\n ><slot name=\"inactive-icon\"></slot\n ></span>\n <span class=\"md3-navigation-tab__icon md3-navigation-tab__icon--active\"\n ><slot name=\"active-icon\"></slot></span\n >${this.renderBadge()}</span\n >${this.renderLabel()}\n </button>`;\n }\n\n private getRenderClasses() {\n return {\n 'md3-navigation-tab--hide-inactive-label': this.hideInactiveLabel,\n 'md3-navigation-tab--active': this.active,\n };\n }\n\n private renderBadge() {\n return this.showBadge\n ? html`<md-badge .value=\"${this.badgeValue}\"></md-badge>`\n : nothing;\n }\n\n private renderLabel() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n const ariaHidden = ariaLabel ? 'true' : 'false';\n return !this.label\n ? nothing\n : html` <span\n aria-hidden=\"${ariaHidden}\"\n class=\"md3-navigation-tab__label-text\"\n >${this.label}</span\n >`;\n }\n\n override firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n const event = new Event('navigation-tab-rendered', {\n bubbles: true,\n composed: true,\n });\n this.dispatchEvent(event);\n }\n\n override focus() {\n const buttonElement = this.buttonElement;\n if (buttonElement) {\n buttonElement.focus();\n }\n }\n\n override blur() {\n const buttonElement = this.buttonElement;\n if (buttonElement) {\n buttonElement.blur();\n }\n }\n\n handleClick() {\n // TODO(b/269772145): connect to ripple\n this.dispatchEvent(\n new CustomEvent('navigation-tab-interaction', {\n detail: {state: this},\n bubbles: true,\n composed: true,\n }),\n );\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * The state of a navigation tab.\n */\nexport interface NavigationTabState {\n /**\n * Active state of the navigation tab.\n */\n active: boolean;\n /**\n * If true, when inactive label will be hidden.\n */\n hideInactiveLabel: boolean;\n\n /**\n * Inner button for the tab\n * TODO(b/229015424): Remove this when the jscompiler rename issue is\n * understood.\n */\n buttonElement: HTMLElement|null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["state.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * The state of a navigation tab.\n */\nexport interface NavigationTabState {\n /**\n * Active state of the navigation tab.\n */\n active: boolean;\n /**\n * If true, when inactive label will be hidden.\n */\n hideInactiveLabel: boolean;\n\n /**\n * Inner button for the tab\n * TODO(b/229015424): Remove this when the jscompiler rename issue is\n * understood.\n */\n buttonElement: HTMLElement | null;\n}\n"]}
|
|
@@ -11,6 +11,9 @@ import { LitElement, nothing, PropertyValues, TemplateResult } from 'lit';
|
|
|
11
11
|
* segmented button component. It is intended **only** for use as a child of a
|
|
12
12
|
* `SementedButtonSet` component. It is **not** intended for use in any other
|
|
13
13
|
* context.
|
|
14
|
+
*
|
|
15
|
+
* @fires segmented-button-interaction {Event} Dispatched whenever a button is
|
|
16
|
+
* clicked. --bubbles --composed
|
|
14
17
|
*/
|
|
15
18
|
export declare class SegmentedButton extends LitElement {
|
|
16
19
|
disabled: boolean;
|
|
@@ -15,6 +15,9 @@ import { requestUpdateOnAriaChange } from '../../../internal/aria/delegate.js';
|
|
|
15
15
|
* segmented button component. It is intended **only** for use as a child of a
|
|
16
16
|
* `SementedButtonSet` component. It is **not** intended for use in any other
|
|
17
17
|
* context.
|
|
18
|
+
*
|
|
19
|
+
* @fires segmented-button-interaction {Event} Dispatched whenever a button is
|
|
20
|
+
* clicked. --bubbles --composed
|
|
18
21
|
*/
|
|
19
22
|
export class SegmentedButton extends LitElement {
|
|
20
23
|
constructor() {
|
|
@@ -49,7 +52,10 @@ export class SegmentedButton extends LitElement {
|
|
|
49
52
|
return '';
|
|
50
53
|
}
|
|
51
54
|
handleClick() {
|
|
52
|
-
const event = new Event('segmented-button-interaction', {
|
|
55
|
+
const event = new Event('segmented-button-interaction', {
|
|
56
|
+
bubbles: true,
|
|
57
|
+
composed: true,
|
|
58
|
+
});
|
|
53
59
|
this.dispatchEvent(event);
|
|
54
60
|
}
|
|
55
61
|
render() {
|
|
@@ -62,13 +68,14 @@ export class SegmentedButton extends LitElement {
|
|
|
62
68
|
aria-pressed=${this.selected}
|
|
63
69
|
?disabled=${this.disabled}
|
|
64
70
|
@click="${this.handleClick}"
|
|
65
|
-
class="md3-segmented-button ${classMap(this.getRenderClasses())}"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
class="md3-segmented-button ${classMap(this.getRenderClasses())}">
|
|
72
|
+
<md-focus-ring
|
|
73
|
+
class="md3-segmented-button__focus-ring"
|
|
74
|
+
part="focus-ring"></md-focus-ring>
|
|
75
|
+
<md-ripple
|
|
76
|
+
?disabled="${this.disabled}"
|
|
77
|
+
class="md3-segmented-button__ripple"></md-ripple>
|
|
78
|
+
${this.renderOutline()} ${this.renderLeading()} ${this.renderLabel()}
|
|
72
79
|
${this.renderTouchTarget()}
|
|
73
80
|
</button>
|
|
74
81
|
`;
|
|
@@ -90,15 +97,19 @@ export class SegmentedButton extends LitElement {
|
|
|
90
97
|
return nothing;
|
|
91
98
|
}
|
|
92
99
|
renderLeading() {
|
|
93
|
-
return this.label === ''
|
|
94
|
-
this.
|
|
100
|
+
return this.label === ''
|
|
101
|
+
? this.renderLeadingWithoutLabel()
|
|
102
|
+
: this.renderLeadingWithLabel();
|
|
95
103
|
}
|
|
96
104
|
renderLeadingWithoutLabel() {
|
|
97
105
|
return html `
|
|
98
106
|
<span class="md3-segmented-button__leading" aria-hidden="true">
|
|
99
107
|
<span class="md3-segmented-button__graphic">
|
|
100
108
|
<svg class="md3-segmented-button__checkmark" viewBox="0 0 24 24">
|
|
101
|
-
<path
|
|
109
|
+
<path
|
|
110
|
+
class="md3-segmented-button__checkmark-path"
|
|
111
|
+
fill="none"
|
|
112
|
+
d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
|
|
102
113
|
</svg>
|
|
103
114
|
</span>
|
|
104
115
|
<span class="md3-segmented-button__icon" aria-hidden="true">
|
|
@@ -112,7 +123,10 @@ export class SegmentedButton extends LitElement {
|
|
|
112
123
|
<span class="md3-segmented-button__leading" aria-hidden="true">
|
|
113
124
|
<span class="md3-segmented-button__graphic">
|
|
114
125
|
<svg class="md3-segmented-button__checkmark" viewBox="0 0 24 24">
|
|
115
|
-
<path
|
|
126
|
+
<path
|
|
127
|
+
class="md3-segmented-button__checkmark-path"
|
|
128
|
+
fill="none"
|
|
129
|
+
d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
|
|
116
130
|
</svg>
|
|
117
131
|
<span class="md3-segmented-button__icon" aria-hidden="true">
|
|
118
132
|
<slot name="icon"></slot>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-button.js","sourceRoot":"","sources":["segmented-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,iCAAiC,CAAC;AACzC,OAAO,2BAA2B,CAAC;AAEnC,OA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c,EAAC,CAAC;oDAAqB;AACxB;IAAjD,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAC,CAAC;gDAAiB;AAEjD;IAAhB,KAAK,EAAE;kDAAwB;AAEf;IADhB,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;oDACR","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../../focus/md-focus-ring.js';\nimport '../../../ripple/ripple.js';\n\nimport {html, LitElement, nothing, PropertyValues, TemplateResult} from 'lit';\nimport {property, queryAssignedElements, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {ARIAMixinStrict} from '../../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../../internal/aria/delegate.js';\n\n/**\n * SegmentedButton is a web component implementation of the Material Design\n * segmented button component. It is intended **only** for use as a child of a\n * `SementedButtonSet` component. It is **not** intended for use in any other\n * context.\n *\n * @fires segmented-button-interaction {Event} Dispatched whenever a button is\n * clicked. --bubbles --composed\n */\nexport class SegmentedButton extends LitElement {\n static {\n requestUpdateOnAriaChange(SegmentedButton);\n }\n\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean}) selected = false;\n @property() label = '';\n @property({type: Boolean, attribute: 'no-checkmark'}) noCheckmark = false;\n @property({type: Boolean, attribute: 'has-icon'}) hasIcon = false;\n\n @state() private animState = '';\n @queryAssignedElements({slot: 'icon', flatten: true})\n private readonly iconElement!: HTMLElement[];\n\n protected override update(props: PropertyValues<SegmentedButton>) {\n this.animState = this.nextAnimationState(props);\n super.update(props);\n // NOTE: This needs to be set *after* calling super.update() to ensure the\n // appropriate CSS classes are applied.\n this.hasIcon = this.iconElement.length > 0;\n }\n\n private nextAnimationState(\n changedProps: PropertyValues<SegmentedButton>,\n ): string {\n const prevSelected = changedProps.get('selected');\n // Early exit for first update.\n if (prevSelected === undefined) return '';\n\n const nextSelected = this.selected;\n const nextHasCheckmark = !this.noCheckmark;\n if (!prevSelected && nextSelected && nextHasCheckmark) {\n return 'selecting';\n }\n if (prevSelected && !nextSelected && nextHasCheckmark) {\n return 'deselecting';\n }\n return '';\n }\n\n private handleClick() {\n const event = new Event('segmented-button-interaction', {\n bubbles: true,\n composed: true,\n });\n this.dispatchEvent(event);\n }\n\n protected override render() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html`\n <button\n tabindex=\"${this.disabled ? '-1' : '0'}\"\n aria-label=${ariaLabel || nothing}\n aria-pressed=${this.selected}\n ?disabled=${this.disabled}\n @click=\"${this.handleClick}\"\n class=\"md3-segmented-button ${classMap(this.getRenderClasses())}\">\n <md-focus-ring\n class=\"md3-segmented-button__focus-ring\"\n part=\"focus-ring\"></md-focus-ring>\n <md-ripple\n ?disabled=\"${this.disabled}\"\n class=\"md3-segmented-button__ripple\"></md-ripple>\n ${this.renderOutline()} ${this.renderLeading()} ${this.renderLabel()}\n ${this.renderTouchTarget()}\n </button>\n `;\n }\n\n protected getRenderClasses() {\n return {\n 'md3-segmented-button--selected': this.selected,\n 'md3-segmented-button--unselected': !this.selected,\n 'md3-segmented-button--with-label': this.label !== '',\n 'md3-segmented-button--without-label': this.label === '',\n 'md3-segmented-button--with-icon': this.hasIcon,\n 'md3-segmented-button--with-checkmark': !this.noCheckmark,\n 'md3-segmented-button--without-checkmark': this.noCheckmark,\n 'md3-segmented-button--selecting': this.animState === 'selecting',\n 'md3-segmented-button--deselecting': this.animState === 'deselecting',\n };\n }\n\n protected renderOutline(): TemplateResult | typeof nothing {\n return nothing;\n }\n\n private renderLeading() {\n return this.label === ''\n ? this.renderLeadingWithoutLabel()\n : this.renderLeadingWithLabel();\n }\n\n private renderLeadingWithoutLabel() {\n return html`\n <span class=\"md3-segmented-button__leading\" aria-hidden=\"true\">\n <span class=\"md3-segmented-button__graphic\">\n <svg class=\"md3-segmented-button__checkmark\" viewBox=\"0 0 24 24\">\n <path\n class=\"md3-segmented-button__checkmark-path\"\n fill=\"none\"\n d=\"M1.73,12.91 8.1,19.28 22.79,4.59\"></path>\n </svg>\n </span>\n <span class=\"md3-segmented-button__icon\" aria-hidden=\"true\">\n <slot name=\"icon\"></slot>\n </span>\n </span>\n `;\n }\n\n private renderLeadingWithLabel() {\n return html`\n <span class=\"md3-segmented-button__leading\" aria-hidden=\"true\">\n <span class=\"md3-segmented-button__graphic\">\n <svg class=\"md3-segmented-button__checkmark\" viewBox=\"0 0 24 24\">\n <path\n class=\"md3-segmented-button__checkmark-path\"\n fill=\"none\"\n d=\"M1.73,12.91 8.1,19.28 22.79,4.59\"></path>\n </svg>\n <span class=\"md3-segmented-button__icon\" aria-hidden=\"true\">\n <slot name=\"icon\"></slot>\n </span>\n </span>\n </span>\n `;\n }\n\n private renderLabel() {\n return html`\n <span class=\"md3-segmented-button__label-text\">${this.label}</span>\n `;\n }\n\n private renderTouchTarget() {\n return html`<span class=\"md3-segmented-button__touch\"></span>`;\n }\n}\n"]}
|
|
@@ -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 `@keyframes md3-segmented-button-checkmark-selection-draw-in{from{stroke-dashoffset:29.7833385}to{stroke-dashoffset:0}}@keyframes md3-segmented-button-simple-fade-out{from{opacity:1}to{opacity:0}}@keyframes md3-segmented-button-simple-fade-in{from{opacity:0}to{opacity:1}}:host{display:inline-flex;outline:none}.md3-segmented-button{align-items:center;background:rgba(0,0,0,0);border:none;border-radius:inherit;display:flex;flex:1;justify-content:center;outline:none;position:relative;vertical-align:middle;padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing)}.md3-segmented-button .md3-segmented-button__outline{border-color:var(--_outline-color)}.md3-segmented-button:disabled .md3-segmented-button__outline{border-color:var(--_disabled-outline-color)}.md3-segmented-button .md3-segmented-button__graphic,.md3-segmented-button .md3-segmented-button__checkmark,.md3-segmented-button .md3-segmented-button__icon,.md3-segmented-button .md3-segmented-button__icon ::slotted([slot=icon]){height:var(--_icon-size);width:var(--_icon-size);font-size:var(--_icon-size)}.md3-segmented-button.md3-segmented-button--with-icon.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--with-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--without-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic{width:calc(var(--_icon-size) + 8px)}.md3-segmented-button .md3-segmented-button__label-text{font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight)}.md3-segmented-button.md3-segmented-button--selected:enabled .md3-segmented-button__label-text{color:var(--_selected-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:hover .md3-segmented-button__label-text{color:var(--_selected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:focus .md3-segmented-button__label-text{color:var(--_selected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:active .md3-segmented-button__label-text{color:var(--_selected-pressed-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled .md3-segmented-button__label-text{color:var(--_unselected-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:hover .md3-segmented-button__label-text{color:var(--_unselected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:focus .md3-segmented-button__label-text{color:var(--_unselected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:active .md3-segmented-button__label-text{color:var(--_unselected-pressed-label-text-color)}.md3-segmented-button:disabled .md3-segmented-button__label-text{color:var(--_disabled-label-text-color)}.md3-segmented-button--unselected{--md-ripple-hover-color: var(--_unselected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--unselected .md3-segmented-button__icon{color:var(--_unselected-icon-color)}.md3-segmented-button--unselected:hover .md3-segmented-button__icon{color:var(--_unselected-hover-icon-color)}.md3-segmented-button--unselected:focus .md3-segmented-button__icon{color:var(--_unselected-focus-icon-color)}.md3-segmented-button--unselected:active .md3-segmented-button__icon{color:var(--_unselected-pressed-icon-color)}.md3-segmented-button--unselected:disabled .md3-segmented-button__icon{color:var(--_disabled-icon-color)}.md3-segmented-button--selected{background-color:var(--_selected-container-color);--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--selected .md3-segmented-button__icon{color:var(--_selected-icon-color)}.md3-segmented-button--selected .md3-segmented-button__checkmark-path{stroke:var(--_selected-icon-color)}.md3-segmented-button--selected:hover .md3-segmented-button__checkmark-path{stroke:var(--_selected-hover-icon-color)}.md3-segmented-button--selected:focus .md3-segmented-button__checkmark-path{stroke:var(--_selected-focus-icon-color)}.md3-segmented-button--selected:active .md3-segmented-button__checkmark-path{stroke:var(--_selected-pressed-icon-color)}.md3-segmented-button--selected:disabled .md3-segmented-button__checkmark-path{stroke:var(--_disabled-icon-color)}.md3-segmented-button:enabled{cursor:pointer}.md3-segmented-button__focus-ring{z-index:1}.md3-segmented-button__ripple{border-radius:inherit;z-index:0}.md3-segmented-button__touch{position:absolute;top:50%;height:48px;left:50%;width:100%;transform:translate(-50%, -50%)}.md3-segmented-button__leading,.md3-segmented-button__graphic{display:inline-flex;justify-content:flex-start;align-items:center}.md3-segmented-button__graphic{position:relative;overflow:hidden}.md3-segmented-button__graphic{transition:width 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--unselected.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button--unselected.md3-segmented-button--without-label .md3-segmented-button__graphic,.md3-segmented-button--selected.md3-segmented-button--without-checkmark .md3-segmented-button__graphic{width:0}.md3-segmented-button--unselected .md3-segmented-button__checkmark{opacity:0}.md3-segmented-button--selected.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0}.md3-segmented-button--with-label .md3-segmented-button__checkmark{display:inline-flex;position:absolute}.md3-segmented-button__checkmark-path{stroke-width:2px;stroke-dasharray:29.7833385}.md3-segmented-button--selecting .md3-segmented-button__checkmark-path{stroke-dashoffset:29.7833385;animation:md3-segmented-button-checkmark-selection-draw-in;animation-duration:150ms;animation-delay:50ms;animation-fill-mode:forwards;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--selecting.md3-segmented-button--with-label .md3-segmented-button__icon{animation:md3-segmented-button-simple-fade-out;animation-duration:75ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting .md3-segmented-button__checkmark{animation:md3-segmented-button-simple-fade-out;animation-duration:50ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0;animation:md3-segmented-button-simple-fade-in;animation-delay:50ms;animation-duration:150ms;animation-timing-function:linear;animation-fill-mode:forwards}/*# sourceMappingURL=shared-styles.css.map */
|
|
7
|
+
export const styles = css `@keyframes md3-segmented-button-checkmark-selection-draw-in{from{stroke-dashoffset:29.7833385}to{stroke-dashoffset:0}}@keyframes md3-segmented-button-simple-fade-out{from{opacity:1}to{opacity:0}}@keyframes md3-segmented-button-simple-fade-in{from{opacity:0}to{opacity:1}}:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-segmented-button{align-items:center;background:rgba(0,0,0,0);border:none;border-radius:inherit;display:flex;flex:1;justify-content:center;outline:none;position:relative;vertical-align:middle;padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing)}.md3-segmented-button .md3-segmented-button__outline{border-color:var(--_outline-color)}.md3-segmented-button:disabled .md3-segmented-button__outline{border-color:var(--_disabled-outline-color)}.md3-segmented-button .md3-segmented-button__graphic,.md3-segmented-button .md3-segmented-button__checkmark,.md3-segmented-button .md3-segmented-button__icon,.md3-segmented-button .md3-segmented-button__icon ::slotted([slot=icon]){height:var(--_icon-size);width:var(--_icon-size);font-size:var(--_icon-size)}.md3-segmented-button.md3-segmented-button--with-icon.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--with-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--without-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic{width:calc(var(--_icon-size) + 8px)}.md3-segmented-button .md3-segmented-button__label-text{font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight)}.md3-segmented-button.md3-segmented-button--selected:enabled .md3-segmented-button__label-text{color:var(--_selected-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:hover .md3-segmented-button__label-text{color:var(--_selected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:focus .md3-segmented-button__label-text{color:var(--_selected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:active .md3-segmented-button__label-text{color:var(--_selected-pressed-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled .md3-segmented-button__label-text{color:var(--_unselected-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:hover .md3-segmented-button__label-text{color:var(--_unselected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:focus .md3-segmented-button__label-text{color:var(--_unselected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:active .md3-segmented-button__label-text{color:var(--_unselected-pressed-label-text-color)}.md3-segmented-button:disabled .md3-segmented-button__label-text{color:var(--_disabled-label-text-color)}.md3-segmented-button--unselected{--md-ripple-hover-color: var(--_unselected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--unselected .md3-segmented-button__icon{color:var(--_unselected-icon-color)}.md3-segmented-button--unselected:hover .md3-segmented-button__icon{color:var(--_unselected-hover-icon-color)}.md3-segmented-button--unselected:focus .md3-segmented-button__icon{color:var(--_unselected-focus-icon-color)}.md3-segmented-button--unselected:active .md3-segmented-button__icon{color:var(--_unselected-pressed-icon-color)}.md3-segmented-button--unselected:disabled .md3-segmented-button__icon{color:var(--_disabled-icon-color)}.md3-segmented-button--selected{background-color:var(--_selected-container-color);--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--selected .md3-segmented-button__icon{color:var(--_selected-icon-color)}.md3-segmented-button--selected .md3-segmented-button__checkmark-path{stroke:var(--_selected-icon-color)}.md3-segmented-button--selected:hover .md3-segmented-button__checkmark-path{stroke:var(--_selected-hover-icon-color)}.md3-segmented-button--selected:focus .md3-segmented-button__checkmark-path{stroke:var(--_selected-focus-icon-color)}.md3-segmented-button--selected:active .md3-segmented-button__checkmark-path{stroke:var(--_selected-pressed-icon-color)}.md3-segmented-button--selected:disabled .md3-segmented-button__checkmark-path{stroke:var(--_disabled-icon-color)}.md3-segmented-button:enabled{cursor:pointer}.md3-segmented-button__focus-ring{z-index:1}.md3-segmented-button__ripple{border-radius:inherit;z-index:0}.md3-segmented-button__touch{position:absolute;top:50%;height:48px;left:50%;width:100%;transform:translate(-50%, -50%)}.md3-segmented-button__leading,.md3-segmented-button__graphic{display:inline-flex;justify-content:flex-start;align-items:center}.md3-segmented-button__graphic{position:relative;overflow:hidden}.md3-segmented-button__graphic{transition:width 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--unselected.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button--unselected.md3-segmented-button--without-label .md3-segmented-button__graphic,.md3-segmented-button--selected.md3-segmented-button--without-checkmark .md3-segmented-button__graphic{width:0}.md3-segmented-button--unselected .md3-segmented-button__checkmark{opacity:0}.md3-segmented-button--selected.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0}.md3-segmented-button--with-label .md3-segmented-button__checkmark{display:inline-flex;position:absolute}.md3-segmented-button__checkmark-path{stroke-width:2px;stroke-dasharray:29.7833385}.md3-segmented-button--selecting .md3-segmented-button__checkmark-path{stroke-dashoffset:29.7833385;animation:md3-segmented-button-checkmark-selection-draw-in;animation-duration:150ms;animation-delay:50ms;animation-fill-mode:forwards;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--selecting.md3-segmented-button--with-label .md3-segmented-button__icon{animation:md3-segmented-button-simple-fade-out;animation-duration:75ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting .md3-segmented-button__checkmark{animation:md3-segmented-button-simple-fade-out;animation-duration:50ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0;animation:md3-segmented-button-simple-fade-in;animation-delay:50ms;animation-duration:150ms;animation-timing-function:linear;animation-fill-mode:forwards}/*# sourceMappingURL=shared-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=shared-styles.css.js.map
|
|
@@ -1 +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`@keyframes md3-segmented-button-checkmark-selection-draw-in{from{stroke-dashoffset:29.7833385}to{stroke-dashoffset:0}}@keyframes md3-segmented-button-simple-fade-out{from{opacity:1}to{opacity:0}}@keyframes md3-segmented-button-simple-fade-in{from{opacity:0}to{opacity:1}}:host{display:inline-flex;outline:none}.md3-segmented-button{align-items:center;background:rgba(0,0,0,0);border:none;border-radius:inherit;display:flex;flex:1;justify-content:center;outline:none;position:relative;vertical-align:middle;padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing)}.md3-segmented-button .md3-segmented-button__outline{border-color:var(--_outline-color)}.md3-segmented-button:disabled .md3-segmented-button__outline{border-color:var(--_disabled-outline-color)}.md3-segmented-button .md3-segmented-button__graphic,.md3-segmented-button .md3-segmented-button__checkmark,.md3-segmented-button .md3-segmented-button__icon,.md3-segmented-button .md3-segmented-button__icon ::slotted([slot=icon]){height:var(--_icon-size);width:var(--_icon-size);font-size:var(--_icon-size)}.md3-segmented-button.md3-segmented-button--with-icon.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--with-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--without-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic{width:calc(var(--_icon-size) + 8px)}.md3-segmented-button .md3-segmented-button__label-text{font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight)}.md3-segmented-button.md3-segmented-button--selected:enabled .md3-segmented-button__label-text{color:var(--_selected-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:hover .md3-segmented-button__label-text{color:var(--_selected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:focus .md3-segmented-button__label-text{color:var(--_selected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:active .md3-segmented-button__label-text{color:var(--_selected-pressed-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled .md3-segmented-button__label-text{color:var(--_unselected-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:hover .md3-segmented-button__label-text{color:var(--_unselected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:focus .md3-segmented-button__label-text{color:var(--_unselected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:active .md3-segmented-button__label-text{color:var(--_unselected-pressed-label-text-color)}.md3-segmented-button:disabled .md3-segmented-button__label-text{color:var(--_disabled-label-text-color)}.md3-segmented-button--unselected{--md-ripple-hover-color: var(--_unselected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--unselected .md3-segmented-button__icon{color:var(--_unselected-icon-color)}.md3-segmented-button--unselected:hover .md3-segmented-button__icon{color:var(--_unselected-hover-icon-color)}.md3-segmented-button--unselected:focus .md3-segmented-button__icon{color:var(--_unselected-focus-icon-color)}.md3-segmented-button--unselected:active .md3-segmented-button__icon{color:var(--_unselected-pressed-icon-color)}.md3-segmented-button--unselected:disabled .md3-segmented-button__icon{color:var(--_disabled-icon-color)}.md3-segmented-button--selected{background-color:var(--_selected-container-color);--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--selected .md3-segmented-button__icon{color:var(--_selected-icon-color)}.md3-segmented-button--selected .md3-segmented-button__checkmark-path{stroke:var(--_selected-icon-color)}.md3-segmented-button--selected:hover .md3-segmented-button__checkmark-path{stroke:var(--_selected-hover-icon-color)}.md3-segmented-button--selected:focus .md3-segmented-button__checkmark-path{stroke:var(--_selected-focus-icon-color)}.md3-segmented-button--selected:active .md3-segmented-button__checkmark-path{stroke:var(--_selected-pressed-icon-color)}.md3-segmented-button--selected:disabled .md3-segmented-button__checkmark-path{stroke:var(--_disabled-icon-color)}.md3-segmented-button:enabled{cursor:pointer}.md3-segmented-button__focus-ring{z-index:1}.md3-segmented-button__ripple{border-radius:inherit;z-index:0}.md3-segmented-button__touch{position:absolute;top:50%;height:48px;left:50%;width:100%;transform:translate(-50%, -50%)}.md3-segmented-button__leading,.md3-segmented-button__graphic{display:inline-flex;justify-content:flex-start;align-items:center}.md3-segmented-button__graphic{position:relative;overflow:hidden}.md3-segmented-button__graphic{transition:width 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--unselected.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button--unselected.md3-segmented-button--without-label .md3-segmented-button__graphic,.md3-segmented-button--selected.md3-segmented-button--without-checkmark .md3-segmented-button__graphic{width:0}.md3-segmented-button--unselected .md3-segmented-button__checkmark{opacity:0}.md3-segmented-button--selected.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0}.md3-segmented-button--with-label .md3-segmented-button__checkmark{display:inline-flex;position:absolute}.md3-segmented-button__checkmark-path{stroke-width:2px;stroke-dasharray:29.7833385}.md3-segmented-button--selecting .md3-segmented-button__checkmark-path{stroke-dashoffset:29.7833385;animation:md3-segmented-button-checkmark-selection-draw-in;animation-duration:150ms;animation-delay:50ms;animation-fill-mode:forwards;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--selecting.md3-segmented-button--with-label .md3-segmented-button__icon{animation:md3-segmented-button-simple-fade-out;animation-duration:75ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting .md3-segmented-button__checkmark{animation:md3-segmented-button-simple-fade-out;animation-duration:50ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0;animation:md3-segmented-button-simple-fade-in;animation-delay:50ms;animation-duration:150ms;animation-timing-function:linear;animation-fill-mode:forwards}/*# sourceMappingURL=shared-styles.css.map */\n`;\n "]}
|
|
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`@keyframes md3-segmented-button-checkmark-selection-draw-in{from{stroke-dashoffset:29.7833385}to{stroke-dashoffset:0}}@keyframes md3-segmented-button-simple-fade-out{from{opacity:1}to{opacity:0}}@keyframes md3-segmented-button-simple-fade-in{from{opacity:0}to{opacity:1}}:host{display:inline-flex;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.md3-segmented-button{align-items:center;background:rgba(0,0,0,0);border:none;border-radius:inherit;display:flex;flex:1;justify-content:center;outline:none;position:relative;vertical-align:middle;padding-inline-start:var(--_spacing-leading);padding-inline-end:var(--_spacing-trailing)}.md3-segmented-button .md3-segmented-button__outline{border-color:var(--_outline-color)}.md3-segmented-button:disabled .md3-segmented-button__outline{border-color:var(--_disabled-outline-color)}.md3-segmented-button .md3-segmented-button__graphic,.md3-segmented-button .md3-segmented-button__checkmark,.md3-segmented-button .md3-segmented-button__icon,.md3-segmented-button .md3-segmented-button__icon ::slotted([slot=icon]){height:var(--_icon-size);width:var(--_icon-size);font-size:var(--_icon-size)}.md3-segmented-button.md3-segmented-button--with-icon.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--with-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic,.md3-segmented-button.md3-segmented-button--selected.md3-segmented-button--without-label.md3-segmented-button--with-checkmark .md3-segmented-button__graphic{width:calc(var(--_icon-size) + 8px)}.md3-segmented-button .md3-segmented-button__label-text{font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight)}.md3-segmented-button.md3-segmented-button--selected:enabled .md3-segmented-button__label-text{color:var(--_selected-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:hover .md3-segmented-button__label-text{color:var(--_selected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:focus .md3-segmented-button__label-text{color:var(--_selected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--selected:enabled:active .md3-segmented-button__label-text{color:var(--_selected-pressed-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled .md3-segmented-button__label-text{color:var(--_unselected-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:hover .md3-segmented-button__label-text{color:var(--_unselected-hover-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:focus .md3-segmented-button__label-text{color:var(--_unselected-focus-label-text-color)}.md3-segmented-button.md3-segmented-button--unselected:enabled:active .md3-segmented-button__label-text{color:var(--_unselected-pressed-label-text-color)}.md3-segmented-button:disabled .md3-segmented-button__label-text{color:var(--_disabled-label-text-color)}.md3-segmented-button--unselected{--md-ripple-hover-color: var(--_unselected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_unselected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--unselected .md3-segmented-button__icon{color:var(--_unselected-icon-color)}.md3-segmented-button--unselected:hover .md3-segmented-button__icon{color:var(--_unselected-hover-icon-color)}.md3-segmented-button--unselected:focus .md3-segmented-button__icon{color:var(--_unselected-focus-icon-color)}.md3-segmented-button--unselected:active .md3-segmented-button__icon{color:var(--_unselected-pressed-icon-color)}.md3-segmented-button--unselected:disabled .md3-segmented-button__icon{color:var(--_disabled-icon-color)}.md3-segmented-button--selected{background-color:var(--_selected-container-color);--md-ripple-hover-color: var(--_selected-hover-state-layer-color);--md-ripple-hover-opacity: var(--_hover-state-layer-opacity);--md-ripple-pressed-color: var(--_selected-pressed-state-layer-color);--md-ripple-pressed-opacity: var(--_pressed-state-layer-opacity)}.md3-segmented-button--selected .md3-segmented-button__icon{color:var(--_selected-icon-color)}.md3-segmented-button--selected .md3-segmented-button__checkmark-path{stroke:var(--_selected-icon-color)}.md3-segmented-button--selected:hover .md3-segmented-button__checkmark-path{stroke:var(--_selected-hover-icon-color)}.md3-segmented-button--selected:focus .md3-segmented-button__checkmark-path{stroke:var(--_selected-focus-icon-color)}.md3-segmented-button--selected:active .md3-segmented-button__checkmark-path{stroke:var(--_selected-pressed-icon-color)}.md3-segmented-button--selected:disabled .md3-segmented-button__checkmark-path{stroke:var(--_disabled-icon-color)}.md3-segmented-button:enabled{cursor:pointer}.md3-segmented-button__focus-ring{z-index:1}.md3-segmented-button__ripple{border-radius:inherit;z-index:0}.md3-segmented-button__touch{position:absolute;top:50%;height:48px;left:50%;width:100%;transform:translate(-50%, -50%)}.md3-segmented-button__leading,.md3-segmented-button__graphic{display:inline-flex;justify-content:flex-start;align-items:center}.md3-segmented-button__graphic{position:relative;overflow:hidden}.md3-segmented-button__graphic{transition:width 150ms cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--unselected.md3-segmented-button--with-label .md3-segmented-button__graphic,.md3-segmented-button--unselected.md3-segmented-button--without-label .md3-segmented-button__graphic,.md3-segmented-button--selected.md3-segmented-button--without-checkmark .md3-segmented-button__graphic{width:0}.md3-segmented-button--unselected .md3-segmented-button__checkmark{opacity:0}.md3-segmented-button--selected.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0}.md3-segmented-button--with-label .md3-segmented-button__checkmark{display:inline-flex;position:absolute}.md3-segmented-button__checkmark-path{stroke-width:2px;stroke-dasharray:29.7833385}.md3-segmented-button--selecting .md3-segmented-button__checkmark-path{stroke-dashoffset:29.7833385;animation:md3-segmented-button-checkmark-selection-draw-in;animation-duration:150ms;animation-delay:50ms;animation-fill-mode:forwards;animation-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.md3-segmented-button--selecting.md3-segmented-button--with-label .md3-segmented-button__icon{animation:md3-segmented-button-simple-fade-out;animation-duration:75ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting .md3-segmented-button__checkmark{animation:md3-segmented-button-simple-fade-out;animation-duration:50ms;animation-timing-function:linear;animation-fill-mode:forwards}.md3-segmented-button--deselecting.md3-segmented-button--with-label .md3-segmented-button__icon{opacity:0;animation:md3-segmented-button-simple-fade-in;animation-delay:50ms;animation-duration:150ms;animation-timing-function:linear;animation-fill-mode:forwards}/*# sourceMappingURL=shared-styles.css.map */\n`;\n "]}
|
|
@@ -9,6 +9,11 @@ import { SegmentedButton } from '../../segmentedbutton/internal/segmented-button
|
|
|
9
9
|
* SegmentedButtonSet is the parent component for two or more
|
|
10
10
|
* `SegmentedButton` components. **Only** `SegmentedButton` components may be
|
|
11
11
|
* used as children.
|
|
12
|
+
*
|
|
13
|
+
* @fires segmented-button-set-selection {CustomEvent<{button: SegmentedButton, selected: boolean, index: number}>}
|
|
14
|
+
* Dispatched when a button is selected programattically with the
|
|
15
|
+
* `setButtonSelected` or the `toggleSelection` methods as well as on user
|
|
16
|
+
* interaction. --bubbles --composed
|
|
12
17
|
*/
|
|
13
18
|
export declare class SegmentedButtonSet extends LitElement {
|
|
14
19
|
multiselect: boolean;
|
|
@@ -11,6 +11,11 @@ import { requestUpdateOnAriaChange } from '../../../internal/aria/delegate.js';
|
|
|
11
11
|
* SegmentedButtonSet is the parent component for two or more
|
|
12
12
|
* `SegmentedButton` components. **Only** `SegmentedButton` components may be
|
|
13
13
|
* used as children.
|
|
14
|
+
*
|
|
15
|
+
* @fires segmented-button-set-selection {CustomEvent<{button: SegmentedButton, selected: boolean, index: number}>}
|
|
16
|
+
* Dispatched when a button is selected programattically with the
|
|
17
|
+
* `setButtonSelected` or the `toggleSelection` methods as well as on user
|
|
18
|
+
* interaction. --bubbles --composed
|
|
14
19
|
*/
|
|
15
20
|
export class SegmentedButtonSet extends LitElement {
|
|
16
21
|
constructor() {
|
|
@@ -76,21 +81,21 @@ export class SegmentedButtonSet extends LitElement {
|
|
|
76
81
|
index,
|
|
77
82
|
},
|
|
78
83
|
bubbles: true,
|
|
79
|
-
composed: true
|
|
84
|
+
composed: true,
|
|
80
85
|
}));
|
|
81
86
|
}
|
|
82
87
|
render() {
|
|
83
88
|
// Needed for closure conformance
|
|
84
89
|
const { ariaLabel } = this;
|
|
85
90
|
return html `
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
<span
|
|
92
|
+
role="group"
|
|
93
|
+
@segmented-button-interaction="${this.handleSegmentedButtonInteraction}"
|
|
94
|
+
aria-label=${ariaLabel || nothing}
|
|
95
|
+
class="md3-segmented-button-set">
|
|
96
|
+
<slot></slot>
|
|
97
|
+
</span>
|
|
98
|
+
`;
|
|
94
99
|
}
|
|
95
100
|
getRenderClasses() {
|
|
96
101
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-button-set.js","sourceRoot":"","sources":["segmented-button-set.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAC,yBAAyB,EAAC,MAAM,oCAAoC,CAAC;AAG7E
|
|
1
|
+
{"version":3,"file":"segmented-button-set.js","sourceRoot":"","sources":["segmented-button-set.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAC,MAAM,KAAK,CAAC;AAC9C,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,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IAAuB,CAAC;QAC5C,OAAO,IAAI,CAAA;;;yCAG0B,IAAI,CAAC,gCAAgC;qBACzD,SAAS,IAAI,OAAO;;;;KAIpC,CAAC;IACJ,CAAC;IAES,gBAAgB;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA5FC;IACE,yBAAyB,CAAC,kBAAkB,CAAC,CAAC;AAChD,CAAC,GAAA,CAAA;AAE0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;uDAAqB;AAEP;IAAvC,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;mDAA6B","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, LitElement, nothing} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {ARIAMixinStrict} from '../../../internal/aria/aria.js';\nimport {requestUpdateOnAriaChange} from '../../../internal/aria/delegate.js';\nimport {SegmentedButton} from '../../segmentedbutton/internal/segmented-button.js';\n\n/**\n * SegmentedButtonSet is the parent component for two or more\n * `SegmentedButton` components. **Only** `SegmentedButton` components may be\n * used as children.\n *\n * @fires segmented-button-set-selection {CustomEvent<{button: SegmentedButton, selected: boolean, index: number}>}\n * Dispatched when a button is selected programattically with the\n * `setButtonSelected` or the `toggleSelection` methods as well as on user\n * interaction. --bubbles --composed\n */\nexport class SegmentedButtonSet extends LitElement {\n static {\n requestUpdateOnAriaChange(SegmentedButtonSet);\n }\n\n @property({type: Boolean}) multiselect = false;\n\n @queryAssignedElements({flatten: true}) buttons!: SegmentedButton[];\n\n getButtonDisabled(index: number): boolean {\n if (this.indexOutOfBounds(index)) return false;\n return this.buttons[index].disabled;\n }\n\n setButtonDisabled(index: number, disabled: boolean) {\n if (this.indexOutOfBounds(index)) return;\n this.buttons[index].disabled = disabled;\n }\n\n getButtonSelected(index: number): boolean {\n if (this.indexOutOfBounds(index)) return false;\n return this.buttons[index].selected;\n }\n\n setButtonSelected(index: number, selected: boolean) {\n // Ignore out-of-index values.\n if (this.indexOutOfBounds(index)) return;\n // Ignore disabled buttons.\n if (this.getButtonDisabled(index)) return;\n\n if (this.multiselect) {\n this.buttons[index].selected = selected;\n this.emitSelectionEvent(index);\n return;\n }\n\n // Single-select segmented buttons are not unselectable.\n if (!selected) return;\n\n this.buttons[index].selected = true;\n this.emitSelectionEvent(index);\n // Deselect all other buttons for single-select.\n for (let i = 0; i < this.buttons.length; i++) {\n if (i === index) continue;\n this.buttons[i].selected = false;\n }\n }\n\n private handleSegmentedButtonInteraction(event: CustomEvent) {\n const index = this.buttons.indexOf(event.target as SegmentedButton);\n this.toggleSelection(index);\n }\n\n private toggleSelection(index: number) {\n if (this.indexOutOfBounds(index)) return;\n this.setButtonSelected(index, !this.buttons[index].selected);\n }\n\n private indexOutOfBounds(index: number): boolean {\n return index < 0 || index >= this.buttons.length;\n }\n\n private emitSelectionEvent(index: number) {\n this.dispatchEvent(\n new CustomEvent('segmented-button-set-selection', {\n detail: {\n button: this.buttons[index],\n selected: this.buttons[index].selected,\n index,\n },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n protected override render() {\n // Needed for closure conformance\n const {ariaLabel} = this as ARIAMixinStrict;\n return html`\n <span\n role=\"group\"\n @segmented-button-interaction=\"${this.handleSegmentedButtonInteraction}\"\n aria-label=${ariaLabel || nothing}\n class=\"md3-segmented-button-set\">\n <slot></slot>\n </span>\n `;\n }\n\n protected getRenderClasses() {\n return {};\n }\n}\n"]}
|
package/list/harness.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare const NAVIGABLE_KEYS: {
|
|
|
18
18
|
* Keys that are handled by MdList. Keys not included in this are not handled by
|
|
19
19
|
* MdList and should be dispatched by yourself.
|
|
20
20
|
*/
|
|
21
|
-
export type HandledListKeys = typeof NAVIGABLE_KEYS[keyof typeof NAVIGABLE_KEYS];
|
|
21
|
+
export type HandledListKeys = (typeof NAVIGABLE_KEYS)[keyof typeof NAVIGABLE_KEYS];
|
|
22
22
|
/**
|
|
23
23
|
* Test harness for list.
|
|
24
24
|
*/
|
package/list/harness.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness.js","sourceRoot":"","sources":["harness.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAG9C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D,MAAM,cAAc,GAAG;IACrB,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;CACJ,CAAC;AASX;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAa;IAC5C;;OAEG;IACgB,KAAK,CAAC,qBAAqB;QAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAClC,OAAO,IAAI,CAAC,OAAe,CAAC;IAC9B,CAAC;IAED,mCAAmC;IACnC,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["harness.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAG9C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D,MAAM,cAAc,GAAG;IACrB,WAAW,EAAE,WAAW;IACxB,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,KAAK;CACJ,CAAC;AASX;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,OAAa;IAC5C;;OAEG;IACgB,KAAK,CAAC,qBAAqB;QAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAClC,OAAO,IAAI,CAAC,OAAe,CAAC;IAC9B,CAAC;IAED,mCAAmC;IACnC,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAC3B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,IAAkB,CAAC,CAClD,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAqC,GAAM;QAC9D,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAAO,EAAuB;QACjE,IAAI,GAAG,EAAC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAC,CAAC;QAC5B,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {Harness} from '../testing/harness.js';\n\nimport {List} from './internal/list.js';\nimport {ListItemHarness} from './internal/listitem/harness.js';\nimport {ListItemEl} from './internal/listitem/list-item.js';\n\nexport {ListItemHarness} from './internal/listitem/harness.js';\n\nconst NAVIGABLE_KEYS = {\n 'ArrowDown': 'ArrowDown',\n 'ArrowUp': 'ArrowUp',\n 'Home': 'Home',\n 'End': 'End',\n} as const;\n\n/**\n * Keys that are handled by MdList. Keys not included in this are not handled by\n * MdList and should be dispatched by yourself.\n */\nexport type HandledListKeys =\n (typeof NAVIGABLE_KEYS)[keyof typeof NAVIGABLE_KEYS];\n\n/**\n * Test harness for list.\n */\nexport class ListHarness extends Harness<List> {\n /**\n * Returns the first list item element.\n */\n protected override async getInteractiveElement() {\n await this.element.updateComplete;\n return this.element as List;\n }\n\n /** @return List item harnesses. */\n getItems() {\n return this.element.items.map(\n (item) => new ListItemHarness(item as ListItemEl),\n );\n }\n\n /**\n * Constructs keyboard events that are handled by List and makes sure that\n * they are constructed in a manner that List understands.\n *\n * @param key The key to dispatch on the list.\n */\n async pressHandledKey<T extends string = HandledListKeys>(key: T) {\n await this.keypress(key, {code: key});\n }\n\n /**\n * Dispatches a keypress on the list. It may or may not be a supported event.\n *\n * @param key The key to dispatch on the list.\n */\n override async keypress(key: string, init = {} as KeyboardEventInit) {\n init = {code: key, ...init};\n await super.keypress(key, init);\n }\n}\n"]}
|
|
@@ -18,7 +18,7 @@ export declare const NavigableKeys: {
|
|
|
18
18
|
/**
|
|
19
19
|
* Default set of navigable keys.
|
|
20
20
|
*/
|
|
21
|
-
export type NavigableKeys = typeof NavigableKeys[keyof typeof NavigableKeys];
|
|
21
|
+
export type NavigableKeys = (typeof NavigableKeys)[keyof typeof NavigableKeys];
|
|
22
22
|
/**
|
|
23
23
|
* The configuration object to customize the behavior of the List Controller
|
|
24
24
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { activateFirstItem, activateLastItem, activateNextItem, activatePreviousItem, getActiveItem, getFirstActivatableItem } from './list-navigation-helpers.js';
|
|
6
|
+
import { activateFirstItem, activateLastItem, activateNextItem, activatePreviousItem, getActiveItem, getFirstActivatableItem, } from './list-navigation-helpers.js';
|
|
7
7
|
// TODO: move this file to List and make List use this
|
|
8
8
|
/**
|
|
9
9
|
* Default keys that trigger navigation.
|
|
@@ -43,8 +43,12 @@ export class ListController {
|
|
|
43
43
|
}
|
|
44
44
|
event.preventDefault();
|
|
45
45
|
const isRtl = this.isRtl();
|
|
46
|
-
const inlinePrevious = isRtl
|
|
47
|
-
|
|
46
|
+
const inlinePrevious = isRtl
|
|
47
|
+
? NavigableKeys.ArrowRight
|
|
48
|
+
: NavigableKeys.ArrowLeft;
|
|
49
|
+
const inlineNext = isRtl
|
|
50
|
+
? NavigableKeys.ArrowLeft
|
|
51
|
+
: NavigableKeys.ArrowRight;
|
|
48
52
|
switch (key) {
|
|
49
53
|
// Activate the next item
|
|
50
54
|
case NavigableKeys.ArrowDown:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-controller.js","sourceRoot":"","sources":["list-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,aAAa,EAAE,uBAAuB,EAAW,MAAM,8BAA8B,CAAC;AAE3K,sDAAsD;AAEtD;;GAEG;AACH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC;AA8CX;;GAEG;AACH,MAAM,OAAO,cAAc;IASzB,YAAY,MAAkC;QA6C9C;;;WAGG;QACH,kBAAa,GAAG,CAAC,KAAoB,EAAE,EAAE;YACvC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YACtB,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBACvD,OAAO;aACR;YACD,sEAAsE;YACtE,iCAAiC;YACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAEzB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;gBACjB,OAAO;aACR;YAED,MAAM,gBAAgB,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAElE,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;aACrC;YAED,KAAK,CAAC,cAAc,EA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G,CAAC,CAAC,CAAC;SACrC;QACD,OAAO,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;CA0DF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {activateFirstItem, activateLastItem, activateNextItem, activatePreviousItem, getActiveItem, getFirstActivatableItem, ListItem} from './list-navigation-helpers.js';\n\n// TODO: move this file to List and make List use this\n\n/**\n * Default keys that trigger navigation.\n */\n// tslint:disable:enforce-name-casing Following Enum style\nexport const NavigableKeys = {\n ArrowDown: 'ArrowDown',\n ArrowLeft: 'ArrowLeft',\n ArrowUp: 'ArrowUp',\n ArrowRight: 'ArrowRight',\n Home: 'Home',\n End: 'End',\n} as const;\n// tslint:enable:enforce-name-casing\n\n/**\n * Default set of navigable keys.\n */\nexport type NavigableKeys = typeof NavigableKeys[keyof typeof NavigableKeys];\n\n/**\n * The configuration object to customize the behavior of the List Controller\n */\nexport interface ListControllerConfig<Item extends ListItem> {\n /**\n * A function that determines whether or not the given element is an Item\n */\n isItem: (item: HTMLElement) => item is Item;\n /**\n * A function that returns an array of elements to consider as items. For\n * example, all the slotted elements.\n */\n getPossibleItems: () => HTMLElement[];\n /**\n * A function that returns whether or not the list is in an RTL context.\n */\n isRtl: () => boolean;\n /**\n * Deactivates an item such as setting the tabindex to -1 and or sets selected\n * to false.\n */\n deactivateItem: (item: Item) => void;\n /**\n * Activates an item such as setting the tabindex to 1 and or sets selected to\n * true (but does not focus).\n */\n activateItem: (item: Item) => void;\n /**\n * Whether or not the key should be handled by the list for navigation.\n */\n isNavigableKey: (key: string) => boolean;\n /**\n * Whether or not the item can be activated. Defaults to items that are not\n * disabled.\n */\n isActivatable?: (item: Item) => boolean;\n}\n\n/**\n * A controller that handles list keyboard navigation and item management.\n */\nexport class ListController<Item extends ListItem> {\n isItem: (item: HTMLElement) => item is Item;\n private readonly getPossibleItems: () => HTMLElement[];\n private readonly isRtl: () => boolean;\n private readonly deactivateItem: (item: Item) => void;\n private readonly activateItem: (item: Item) => void;\n private readonly isNavigableKey: (key: string) => boolean;\n private readonly isActivatable?: (item: Item) => boolean;\n\n constructor(config: ListControllerConfig<Item>) {\n const {\n isItem,\n getPossibleItems,\n isRtl,\n deactivateItem,\n activateItem,\n isNavigableKey,\n isActivatable,\n } = config;\n this.isItem = isItem;\n this.getPossibleItems = getPossibleItems;\n this.isRtl = isRtl;\n this.deactivateItem = deactivateItem;\n this.activateItem = activateItem;\n this.isNavigableKey = isNavigableKey;\n this.isActivatable = isActivatable;\n }\n\n /**\n * The items being managed by the list. Additionally, attempts to see if the\n * object has a sub-item in the `.item` property.\n */\n get items(): Item[] {\n const maybeItems = this.getPossibleItems();\n const items: Item[] = [];\n\n for (const itemOrParent of maybeItems) {\n const isItem = this.isItem(itemOrParent);\n // if the item is a list item, add it to the list of items\n if (isItem) {\n items.push(itemOrParent);\n continue;\n }\n\n // If the item exposes an `item` property check if it is a list item.\n const subItem = (itemOrParent as HTMLElement & {item?: Item}).item;\n if (subItem && this.isItem(subItem)) {\n items.push(subItem);\n }\n }\n\n return items;\n }\n\n /**\n * Handles keyboard navigation. Should be bound to the node that will act as\n * the List.\n */\n handleKeydown = (event: KeyboardEvent) => {\n const key = event.key;\n if (event.defaultPrevented || !this.isNavigableKey(key)) {\n return;\n }\n // do not use this.items directly in upcoming calculations so we don't\n // re-query the DOM unnecessarily\n const items = this.items;\n\n if (!items.length) {\n return;\n }\n\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n\n event.preventDefault();\n\n const isRtl = this.isRtl();\n const inlinePrevious =\n isRtl ? NavigableKeys.ArrowRight : NavigableKeys.ArrowLeft;\n const inlineNext =\n isRtl ? NavigableKeys.ArrowLeft : NavigableKeys.ArrowRight;\n\n switch (key) {\n // Activate the next item\n case NavigableKeys.ArrowDown:\n case inlineNext:\n activateNextItem(items, activeItemRecord, this.isActivatable);\n break;\n\n // Activate the previous item\n case NavigableKeys.ArrowUp:\n case inlinePrevious:\n activatePreviousItem(items, activeItemRecord, this.isActivatable);\n break;\n\n // Activate the first item\n case NavigableKeys.Home:\n activateFirstItem(items, this.isActivatable);\n break;\n\n // Activate the last item\n case NavigableKeys.End:\n activateLastItem(items, this.isActivatable);\n break;\n\n default:\n break;\n }\n };\n\n /**\n * Activates the next item in the list. If at the end of the list, the first\n * item will be activated.\n *\n * @return The activated list item or `null` if there are no items.\n */\n activateNextItem(): Item|null {\n const items = this.items;\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n return activateNextItem(items, activeItemRecord, this.isActivatable);\n }\n\n /**\n * Activates the previous item in the list. If at the start of the list, the\n * last item will be activated.\n *\n * @return The activated list item or `null` if there are no items.\n */\n activatePreviousItem(): Item|null {\n const items = this.items;\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n return activatePreviousItem(items, activeItemRecord, this.isActivatable);\n }\n\n /**\n * Listener to be bound to the `deactivate-items` item event.\n */\n onDeactivateItems = () => {\n const items = this.items;\n\n for (const item of items) {\n this.deactivateItem(item);\n }\n };\n\n /**\n * Listener to be bound to the `request-activation` item event..\n */\n onRequestActivation = (event: Event) => {\n this.onDeactivateItems();\n const target = event.target as Item;\n this.activateItem(target);\n target.focus();\n };\n\n /**\n * Listener to be bound to the `slotchange` event for the slot that renders\n * the items.\n */\n onSlotchange = () => {\n const items = this.items;\n // Whether we have encountered an item that has been activated\n let encounteredActivated = false;\n\n for (const item of items) {\n const isActivated = !item.disabled && item.tabIndex > -1;\n\n if (isActivated && !encounteredActivated) {\n encounteredActivated = true;\n item.tabIndex = 0;\n continue;\n }\n\n // Deactivate the rest including disabled\n item.tabIndex = -1;\n }\n\n if (encounteredActivated) {\n return;\n }\n\n const firstActivatableItem =\n getFirstActivatableItem(items, this.isActivatable);\n\n if (!firstActivatableItem) {\n return;\n }\n\n firstActivatableItem.tabIndex = 0;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list-controller.js","sourceRoot":"","sources":["list-controller.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,GAExB,MAAM,8BAA8B,CAAC;AAEtC,sDAAsD;AAEtD;;GAEG;AACH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC;AA8CX;;GAEG;AACH,MAAM,OAAO,cAAc;IASzB,YAAY,MAAkC;QA6C9C;;;WAGG;QACH,kBAAa,GAAG,CAAC,KAAoB,EAAE,EAAE;YACvC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;YACtB,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBACvD,OAAO;aACR;YACD,sEAAsE;YACtE,iCAAiC;YACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAEzB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;gBACjB,OAAO;aACR;YAED,MAAM,gBAAgB,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAElE,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;aACrC;YAED,KAAK,CAAC,cAAc,EAAE,CAAC;YAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,cAAc,G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AI,CAAC,aAAa,CAAC,CAAC;IAC3E,CAAC;CA4DF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n activateFirstItem,\n activateLastItem,\n activateNextItem,\n activatePreviousItem,\n getActiveItem,\n getFirstActivatableItem,\n ListItem,\n} from './list-navigation-helpers.js';\n\n// TODO: move this file to List and make List use this\n\n/**\n * Default keys that trigger navigation.\n */\n// tslint:disable:enforce-name-casing Following Enum style\nexport const NavigableKeys = {\n ArrowDown: 'ArrowDown',\n ArrowLeft: 'ArrowLeft',\n ArrowUp: 'ArrowUp',\n ArrowRight: 'ArrowRight',\n Home: 'Home',\n End: 'End',\n} as const;\n// tslint:enable:enforce-name-casing\n\n/**\n * Default set of navigable keys.\n */\nexport type NavigableKeys = (typeof NavigableKeys)[keyof typeof NavigableKeys];\n\n/**\n * The configuration object to customize the behavior of the List Controller\n */\nexport interface ListControllerConfig<Item extends ListItem> {\n /**\n * A function that determines whether or not the given element is an Item\n */\n isItem: (item: HTMLElement) => item is Item;\n /**\n * A function that returns an array of elements to consider as items. For\n * example, all the slotted elements.\n */\n getPossibleItems: () => HTMLElement[];\n /**\n * A function that returns whether or not the list is in an RTL context.\n */\n isRtl: () => boolean;\n /**\n * Deactivates an item such as setting the tabindex to -1 and or sets selected\n * to false.\n */\n deactivateItem: (item: Item) => void;\n /**\n * Activates an item such as setting the tabindex to 1 and or sets selected to\n * true (but does not focus).\n */\n activateItem: (item: Item) => void;\n /**\n * Whether or not the key should be handled by the list for navigation.\n */\n isNavigableKey: (key: string) => boolean;\n /**\n * Whether or not the item can be activated. Defaults to items that are not\n * disabled.\n */\n isActivatable?: (item: Item) => boolean;\n}\n\n/**\n * A controller that handles list keyboard navigation and item management.\n */\nexport class ListController<Item extends ListItem> {\n isItem: (item: HTMLElement) => item is Item;\n private readonly getPossibleItems: () => HTMLElement[];\n private readonly isRtl: () => boolean;\n private readonly deactivateItem: (item: Item) => void;\n private readonly activateItem: (item: Item) => void;\n private readonly isNavigableKey: (key: string) => boolean;\n private readonly isActivatable?: (item: Item) => boolean;\n\n constructor(config: ListControllerConfig<Item>) {\n const {\n isItem,\n getPossibleItems,\n isRtl,\n deactivateItem,\n activateItem,\n isNavigableKey,\n isActivatable,\n } = config;\n this.isItem = isItem;\n this.getPossibleItems = getPossibleItems;\n this.isRtl = isRtl;\n this.deactivateItem = deactivateItem;\n this.activateItem = activateItem;\n this.isNavigableKey = isNavigableKey;\n this.isActivatable = isActivatable;\n }\n\n /**\n * The items being managed by the list. Additionally, attempts to see if the\n * object has a sub-item in the `.item` property.\n */\n get items(): Item[] {\n const maybeItems = this.getPossibleItems();\n const items: Item[] = [];\n\n for (const itemOrParent of maybeItems) {\n const isItem = this.isItem(itemOrParent);\n // if the item is a list item, add it to the list of items\n if (isItem) {\n items.push(itemOrParent);\n continue;\n }\n\n // If the item exposes an `item` property check if it is a list item.\n const subItem = (itemOrParent as HTMLElement & {item?: Item}).item;\n if (subItem && this.isItem(subItem)) {\n items.push(subItem);\n }\n }\n\n return items;\n }\n\n /**\n * Handles keyboard navigation. Should be bound to the node that will act as\n * the List.\n */\n handleKeydown = (event: KeyboardEvent) => {\n const key = event.key;\n if (event.defaultPrevented || !this.isNavigableKey(key)) {\n return;\n }\n // do not use this.items directly in upcoming calculations so we don't\n // re-query the DOM unnecessarily\n const items = this.items;\n\n if (!items.length) {\n return;\n }\n\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n\n event.preventDefault();\n\n const isRtl = this.isRtl();\n const inlinePrevious = isRtl\n ? NavigableKeys.ArrowRight\n : NavigableKeys.ArrowLeft;\n const inlineNext = isRtl\n ? NavigableKeys.ArrowLeft\n : NavigableKeys.ArrowRight;\n\n switch (key) {\n // Activate the next item\n case NavigableKeys.ArrowDown:\n case inlineNext:\n activateNextItem(items, activeItemRecord, this.isActivatable);\n break;\n\n // Activate the previous item\n case NavigableKeys.ArrowUp:\n case inlinePrevious:\n activatePreviousItem(items, activeItemRecord, this.isActivatable);\n break;\n\n // Activate the first item\n case NavigableKeys.Home:\n activateFirstItem(items, this.isActivatable);\n break;\n\n // Activate the last item\n case NavigableKeys.End:\n activateLastItem(items, this.isActivatable);\n break;\n\n default:\n break;\n }\n };\n\n /**\n * Activates the next item in the list. If at the end of the list, the first\n * item will be activated.\n *\n * @return The activated list item or `null` if there are no items.\n */\n activateNextItem(): Item | null {\n const items = this.items;\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n return activateNextItem(items, activeItemRecord, this.isActivatable);\n }\n\n /**\n * Activates the previous item in the list. If at the start of the list, the\n * last item will be activated.\n *\n * @return The activated list item or `null` if there are no items.\n */\n activatePreviousItem(): Item | null {\n const items = this.items;\n const activeItemRecord = getActiveItem(items, this.isActivatable);\n if (activeItemRecord) {\n activeItemRecord.item.tabIndex = -1;\n }\n return activatePreviousItem(items, activeItemRecord, this.isActivatable);\n }\n\n /**\n * Listener to be bound to the `deactivate-items` item event.\n */\n onDeactivateItems = () => {\n const items = this.items;\n\n for (const item of items) {\n this.deactivateItem(item);\n }\n };\n\n /**\n * Listener to be bound to the `request-activation` item event..\n */\n onRequestActivation = (event: Event) => {\n this.onDeactivateItems();\n const target = event.target as Item;\n this.activateItem(target);\n target.focus();\n };\n\n /**\n * Listener to be bound to the `slotchange` event for the slot that renders\n * the items.\n */\n onSlotchange = () => {\n const items = this.items;\n // Whether we have encountered an item that has been activated\n let encounteredActivated = false;\n\n for (const item of items) {\n const isActivated = !item.disabled && item.tabIndex > -1;\n\n if (isActivated && !encounteredActivated) {\n encounteredActivated = true;\n item.tabIndex = 0;\n continue;\n }\n\n // Deactivate the rest including disabled\n item.tabIndex = -1;\n }\n\n if (encounteredActivated) {\n return;\n }\n\n const firstActivatableItem = getFirstActivatableItem(\n items,\n this.isActivatable,\n );\n\n if (!firstActivatableItem) {\n return;\n }\n\n firstActivatableItem.tabIndex = 0;\n };\n}\n"]}
|