@material/web 1.0.0-pre.5 → 1.0.0-pre.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/aria/aria.d.ts +43 -0
- package/aria/aria.js +56 -0
- package/aria/aria.js.map +1 -0
- package/aria/delegate.d.ts +37 -0
- package/aria/delegate.js +53 -0
- package/aria/delegate.js.map +1 -0
- package/badge/badge.d.ts +0 -1
- package/badge/badge.js +0 -1
- package/badge/badge.js.map +1 -1
- package/badge/lib/badge-styles.css.js +1 -1
- package/badge/lib/badge-styles.css.js.map +1 -1
- package/badge/lib/badge.d.ts +8 -7
- package/badge/lib/badge.js +5 -6
- package/badge/lib/badge.js.map +1 -1
- package/button/lib/_elevation.scss +15 -11
- package/button/lib/_outlined-button.scss +1 -1
- package/button/lib/_shared.scss +5 -0
- package/button/lib/_text-button.scss +1 -1
- package/button/lib/_tonal-button.scss +1 -1
- package/button/lib/button.d.ts +13 -11
- package/button/lib/button.js +51 -60
- package/button/lib/button.js.map +1 -1
- package/button/lib/elevated-button.d.ts +3 -0
- package/button/lib/elevated-button.js +4 -2
- package/button/lib/elevated-button.js.map +1 -1
- package/button/lib/elevated-styles.css.js +1 -1
- package/button/lib/elevated-styles.css.js.map +1 -1
- package/button/lib/filled-button.d.ts +3 -1
- package/button/lib/filled-button.js +4 -3
- package/button/lib/filled-button.js.map +1 -1
- package/button/lib/filled-styles.css.js +1 -1
- package/button/lib/filled-styles.css.js.map +1 -1
- package/button/lib/outlined-button.d.ts +3 -0
- package/button/lib/outlined-button.js +3 -1
- package/button/lib/outlined-button.js.map +1 -1
- package/button/lib/outlined-styles.css.js +1 -1
- package/button/lib/outlined-styles.css.js.map +1 -1
- package/button/lib/shared-elevation-styles.css.js +1 -1
- package/button/lib/shared-elevation-styles.css.js.map +1 -1
- package/button/lib/shared-styles.css.js +1 -1
- package/button/lib/shared-styles.css.js.map +1 -1
- package/button/lib/text-button.d.ts +3 -0
- package/button/lib/text-button.js +3 -1
- package/button/lib/text-button.js.map +1 -1
- package/button/lib/text-styles.css.js +1 -1
- package/button/lib/text-styles.css.js.map +1 -1
- package/button/lib/tonal-button.d.ts +3 -1
- package/button/lib/tonal-button.js +4 -3
- package/button/lib/tonal-button.js.map +1 -1
- package/button/lib/tonal-styles.css.js +1 -1
- package/button/lib/tonal-styles.css.js.map +1 -1
- package/checkbox/lib/checkbox-styles.css.js +1 -1
- package/checkbox/lib/checkbox-styles.css.js.map +1 -1
- package/checkbox/lib/checkbox.d.ts +0 -1
- package/checkbox/lib/checkbox.js +33 -43
- package/checkbox/lib/checkbox.js.map +1 -1
- package/chips/_filter-chip.scss +6 -0
- package/chips/filter-chip.d.ts +20 -0
- package/chips/filter-chip.js +24 -0
- package/chips/filter-chip.js.map +1 -0
- package/chips/lib/_filter-chip.scss +141 -0
- package/chips/lib/_shared.scss +71 -37
- package/chips/lib/assist-styles.css.js +1 -1
- package/chips/lib/assist-styles.css.js.map +1 -1
- package/chips/lib/chip.d.ts +8 -3
- package/chips/lib/chip.js +30 -31
- package/chips/lib/chip.js.map +1 -1
- package/chips/lib/filter-chip.d.ts +21 -0
- package/chips/lib/filter-chip.js +47 -0
- package/chips/lib/filter-chip.js.map +1 -0
- package/chips/lib/filter-styles.css.js +9 -0
- package/chips/lib/filter-styles.css.js.map +1 -0
- package/{fab/lib/fab-extended-styles.scss → chips/lib/filter-styles.scss} +3 -3
- package/chips/lib/shared-styles.css.js +1 -1
- package/chips/lib/shared-styles.css.js.map +1 -1
- package/chips/lib/suggestion-styles.css.js +1 -1
- package/chips/lib/suggestion-styles.css.js.map +1 -1
- package/circularprogress/_circular-progress.scss +6 -0
- package/circularprogress/circular-progress.d.ts +24 -0
- package/circularprogress/circular-progress.js +27 -0
- package/circularprogress/circular-progress.js.map +1 -0
- package/circularprogress/harness.d.ts +13 -0
- package/circularprogress/harness.js +16 -0
- package/circularprogress/harness.js.map +1 -0
- package/circularprogress/lib/_circular-progress.scss +282 -0
- package/circularprogress/lib/circular-progress-styles.css.js +9 -0
- package/circularprogress/lib/circular-progress-styles.css.js.map +1 -0
- package/circularprogress/lib/circular-progress-styles.scss +8 -0
- package/circularprogress/lib/circular-progress.d.ts +28 -0
- package/circularprogress/lib/circular-progress.js +95 -0
- package/circularprogress/lib/circular-progress.js.map +1 -0
- package/dialog/lib/_dialog.scss +9 -14
- package/dialog/lib/dialog-styles.css.js +1 -1
- package/dialog/lib/dialog-styles.css.js.map +1 -1
- package/dialog/lib/dialog.js +26 -50
- package/dialog/lib/dialog.js.map +1 -1
- package/divider/lib/divider.js +4 -7
- package/divider/lib/divider.js.map +1 -1
- package/elevation/lib/_elevation.scss +14 -51
- package/elevation/lib/elevation-styles.css.js +1 -1
- package/elevation/lib/elevation-styles.css.js.map +1 -1
- package/elevation/lib/elevation.d.ts +0 -8
- package/elevation/lib/elevation.js +1 -25
- package/elevation/lib/elevation.js.map +1 -1
- package/fab/_fab.scss +1 -0
- package/fab/branded-fab.d.ts +53 -0
- package/fab/branded-fab.js +56 -0
- package/fab/branded-fab.js.map +1 -0
- package/fab/fab.d.ts +25 -5
- package/fab/fab.js +27 -10
- package/fab/fab.js.map +1 -1
- package/fab/harness.d.ts +1 -2
- package/fab/harness.js +1 -1
- package/fab/harness.js.map +1 -1
- package/fab/lib/_fab-branded.scss +27 -0
- package/fab/lib/_fab.scss +144 -16
- package/fab/lib/_shared.scss +153 -131
- package/fab/lib/fab-branded-styles.css.js +9 -0
- package/fab/lib/fab-branded-styles.css.js.map +1 -0
- package/fab/lib/fab-branded-styles.scss +10 -0
- package/fab/lib/fab-styles.css.js +1 -1
- package/fab/lib/fab-styles.css.js.map +1 -1
- package/fab/lib/fab.d.ts +14 -10
- package/fab/lib/fab.js +19 -12
- package/fab/lib/fab.js.map +1 -1
- package/fab/lib/forced-colors-styles.css.js +9 -0
- package/fab/lib/forced-colors-styles.css.js.map +1 -0
- package/fab/lib/forced-colors-styles.scss +26 -0
- package/fab/lib/shared-styles.css.d.ts +1 -0
- package/fab/lib/shared-styles.css.js +9 -0
- package/fab/lib/shared-styles.css.js.map +1 -0
- package/fab/lib/{fab-shared-styles.scss → shared-styles.scss} +1 -1
- package/fab/lib/{fab-shared.d.ts → shared.d.ts} +24 -16
- package/fab/lib/shared.js +137 -0
- package/fab/lib/shared.js.map +1 -0
- package/field/lib/field.js +14 -27
- package/field/lib/field.js.map +1 -1
- package/field/lib/filled-styles.css.js +1 -1
- package/field/lib/filled-styles.css.js.map +1 -1
- package/field/lib/outlined-styles.css.js +1 -1
- package/field/lib/outlined-styles.css.js.map +1 -1
- package/focus/focus-ring.d.ts +0 -1
- package/focus/focus-ring.js +0 -1
- package/focus/focus-ring.js.map +1 -1
- package/focus/lib/_focus-ring.scss +30 -20
- package/focus/lib/focus-ring-styles.css.js +1 -1
- package/focus/lib/focus-ring-styles.css.js.map +1 -1
- package/focus/lib/focus-ring.js +2 -3
- package/focus/lib/focus-ring.js.map +1 -1
- package/focus/strong-focus.d.ts +11 -0
- package/focus/strong-focus.js +16 -1
- package/focus/strong-focus.js.map +1 -1
- package/icon/icon.d.ts +0 -1
- package/icon/icon.js +0 -1
- package/icon/icon.js.map +1 -1
- package/icon/lib/_icon.scss +2 -0
- package/icon/lib/icon-styles.css.js +1 -1
- package/icon/lib/icon-styles.css.js.map +1 -1
- package/icon/lib/icon.d.ts +5 -4
- package/icon/lib/icon.js +3 -2
- package/icon/lib/icon.js.map +1 -1
- package/iconbutton/filled-icon-button.js +1 -0
- package/iconbutton/filled-icon-button.js.map +1 -1
- package/iconbutton/filled-tonal-icon-button.js +1 -0
- package/iconbutton/filled-tonal-icon-button.js.map +1 -1
- package/iconbutton/harness.d.ts +1 -2
- package/iconbutton/harness.js.map +1 -1
- package/iconbutton/lib/filled-styles.css.js +1 -1
- package/iconbutton/lib/filled-styles.css.js.map +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
- package/iconbutton/lib/icon-button.d.ts +31 -4
- package/iconbutton/lib/icon-button.js +105 -37
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/iconbutton/lib/outlined-styles.css.js +1 -1
- package/iconbutton/lib/outlined-styles.css.js.map +1 -1
- package/iconbutton/lib/standard-styles.css.js +1 -1
- package/iconbutton/lib/standard-styles.css.js.map +1 -1
- package/linearprogress/_linear-progress.scss +6 -0
- package/linearprogress/harness.d.ts +13 -0
- package/linearprogress/harness.js +18 -0
- package/linearprogress/harness.js.map +1 -0
- package/linearprogress/lib/_linear-progress.scss +380 -0
- package/linearprogress/lib/linear-progress-styles.css.d.ts +1 -0
- package/linearprogress/lib/linear-progress-styles.css.js +9 -0
- package/linearprogress/lib/linear-progress-styles.css.js.map +1 -0
- package/linearprogress/lib/linear-progress-styles.scss +8 -0
- package/linearprogress/lib/linear-progress.d.ts +35 -0
- package/linearprogress/lib/linear-progress.js +127 -0
- package/linearprogress/lib/linear-progress.js.map +1 -0
- package/linearprogress/linear-progress.d.ts +23 -0
- package/linearprogress/linear-progress.js +26 -0
- package/linearprogress/linear-progress.js.map +1 -0
- package/list/harness.d.ts +1 -0
- package/list/harness.js +1 -0
- package/list/harness.js.map +1 -1
- package/list/lib/_list.scss +6 -50
- package/list/lib/list-styles.css.js +1 -1
- package/list/lib/list-styles.css.js.map +1 -1
- package/list/lib/list.d.ts +1 -3
- package/list/lib/list.js +20 -34
- package/list/lib/list.js.map +1 -1
- package/list/lib/listitem/_list-item.scss +19 -82
- package/list/lib/listitem/forced-colors-styles.css.d.ts +1 -0
- package/list/lib/listitem/forced-colors-styles.css.js +9 -0
- package/list/lib/listitem/forced-colors-styles.css.js.map +1 -0
- package/list/lib/listitem/forced-colors-styles.scss +23 -0
- package/list/lib/listitem/list-item-styles.css.js +1 -1
- package/list/lib/listitem/list-item-styles.css.js.map +1 -1
- package/list/lib/listitem/list-item.d.ts +5 -7
- package/list/lib/listitem/list-item.js +27 -56
- package/list/lib/listitem/list-item.js.map +1 -1
- package/list/lib/listitemlink/list-item-link.js +4 -6
- package/list/lib/listitemlink/list-item-link.js.map +1 -1
- package/list/list-item-link.js +2 -1
- package/list/list-item-link.js.map +1 -1
- package/list/list-item.js +2 -1
- package/list/list-item.js.map +1 -1
- package/menu/harness.d.ts +1 -0
- package/menu/harness.js +1 -0
- package/menu/harness.js.map +1 -1
- package/menu/lib/_menu.scss +10 -37
- package/menu/lib/forced-colors-styles.css.d.ts +1 -0
- package/menu/lib/forced-colors-styles.css.js +9 -0
- package/menu/lib/forced-colors-styles.css.js.map +1 -0
- package/menu/lib/forced-colors-styles.scss +12 -0
- package/menu/lib/menu-styles.css.js +1 -1
- package/menu/lib/menu-styles.css.js.map +1 -1
- package/menu/lib/menu.d.ts +13 -3
- package/menu/lib/menu.js +78 -65
- package/menu/lib/menu.js.map +1 -1
- package/menu/lib/menuitem/_menu-item.scss +18 -43
- package/menu/lib/menuitem/forced-colors-styles.css.d.ts +1 -0
- package/menu/lib/menuitem/forced-colors-styles.css.js +9 -0
- package/menu/lib/menuitem/forced-colors-styles.css.js.map +1 -0
- package/menu/lib/menuitem/forced-colors-styles.scss +22 -0
- package/menu/lib/menuitem/menu-item-styles.css.js +1 -1
- package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/lib/menuitem/menu-item.d.ts +1 -1
- package/menu/lib/menuitem/menu-item.js +4 -6
- package/menu/lib/menuitem/menu-item.js.map +1 -1
- package/menu/lib/menuitemlink/menu-item-link.d.ts +0 -2
- package/menu/lib/menuitemlink/menu-item-link.js +3 -6
- package/menu/lib/menuitemlink/menu-item-link.js.map +1 -1
- package/menu/lib/shared.d.ts +16 -2
- package/menu/lib/shared.js +23 -0
- package/menu/lib/shared.js.map +1 -1
- package/menu/lib/submenuitem/sub-menu-item.d.ts +4 -2
- package/menu/lib/submenuitem/sub-menu-item.js +17 -13
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
- package/menu/lib/typeaheadController.d.ts +10 -2
- package/menu/lib/typeaheadController.js +20 -14
- package/menu/lib/typeaheadController.js.map +1 -1
- package/menu/menu-item-link.js +3 -1
- package/menu/menu-item-link.js.map +1 -1
- package/menu/menu-item.js +4 -2
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.js +2 -1
- package/menu/menu.js.map +1 -1
- package/menu/sub-menu-item.js +3 -1
- package/menu/sub-menu-item.js.map +1 -1
- package/navigationbar/lib/_navigation-bar.scss +9 -6
- package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
- package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
- package/navigationbar/lib/navigation-bar.d.ts +5 -5
- package/navigationbar/lib/navigation-bar.js +19 -20
- package/navigationbar/lib/navigation-bar.js.map +1 -1
- package/navigationbar/navigation-bar.d.ts +0 -1
- package/navigationbar/navigation-bar.js +0 -1
- package/navigationbar/navigation-bar.js.map +1 -1
- package/navigationdrawer/lib/_navigation-drawer-modal.scss +10 -11
- package/navigationdrawer/lib/_navigation-drawer.scss +9 -14
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal.d.ts +5 -10
- package/navigationdrawer/lib/navigation-drawer-modal.js +19 -41
- package/navigationdrawer/lib/navigation-drawer-modal.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer.d.ts +5 -9
- package/navigationdrawer/lib/navigation-drawer.js +18 -39
- package/navigationdrawer/lib/navigation-drawer.js.map +1 -1
- package/navigationdrawer/navigation-drawer-modal.d.ts +0 -1
- package/navigationdrawer/navigation-drawer-modal.js +0 -1
- package/navigationdrawer/navigation-drawer-modal.js.map +1 -1
- package/navigationdrawer/navigation-drawer.d.ts +0 -1
- package/navigationdrawer/navigation-drawer.js +0 -1
- package/navigationdrawer/navigation-drawer.js.map +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
- package/navigationtab/lib/navigation-tab.d.ts +19 -24
- package/navigationtab/lib/navigation-tab.js +48 -68
- package/navigationtab/lib/navigation-tab.js.map +1 -1
- package/navigationtab/navigation-tab.d.ts +0 -1
- package/navigationtab/navigation-tab.js +0 -1
- package/navigationtab/navigation-tab.js.map +1 -1
- package/package.json +2 -1
- package/radio/lib/radio-styles.css.js +1 -1
- package/radio/lib/radio-styles.css.js.map +1 -1
- package/radio/lib/radio.d.ts +0 -1
- package/radio/lib/radio.js +30 -37
- package/radio/lib/radio.js.map +1 -1
- package/ripple/lib/_md-comp-ripple.scss +3 -3
- package/ripple/lib/ripple-styles.css.js +1 -1
- package/ripple/lib/ripple-styles.css.js.map +1 -1
- package/ripple/lib/ripple.js +7 -13
- package/ripple/lib/ripple.js.map +1 -1
- package/segmentedbutton/lib/outlined-segmented-button.d.ts +16 -7
- package/segmentedbutton/lib/outlined-segmented-button.js +3 -3
- package/segmentedbutton/lib/outlined-segmented-button.js.map +1 -1
- package/segmentedbutton/lib/outlined-styles.css.js +1 -1
- package/segmentedbutton/lib/outlined-styles.css.js.map +1 -1
- package/segmentedbutton/lib/segmented-button.d.ts +27 -33
- package/segmentedbutton/lib/segmented-button.js +42 -75
- package/segmentedbutton/lib/segmented-button.js.map +1 -1
- package/segmentedbutton/outlined-segmented-button.d.ts +0 -1
- package/segmentedbutton/outlined-segmented-button.js +0 -1
- package/segmentedbutton/outlined-segmented-button.js.map +1 -1
- package/segmentedbuttonset/lib/outlined-segmented-button-set.d.ts +6 -4
- package/segmentedbuttonset/lib/outlined-segmented-button-set.js +3 -2
- package/segmentedbuttonset/lib/outlined-segmented-button-set.js.map +1 -1
- package/segmentedbuttonset/lib/outlined-styles.css.js +1 -1
- package/segmentedbuttonset/lib/outlined-styles.css.js.map +1 -1
- package/segmentedbuttonset/lib/segmented-button-set.d.ts +3 -9
- package/segmentedbuttonset/lib/segmented-button-set.js +14 -20
- package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
- package/segmentedbuttonset/outlined-segmented-button-set.d.ts +0 -1
- package/segmentedbuttonset/outlined-segmented-button-set.js +0 -1
- package/segmentedbuttonset/outlined-segmented-button-set.js.map +1 -1
- package/select/_filled-select.scss +6 -0
- package/select/_outlined-select.scss +6 -0
- package/select/filled-select.d.ts +41 -0
- package/select/filled-select.js +46 -0
- package/select/filled-select.js.map +1 -0
- package/select/harness.d.ts +24 -0
- package/select/harness.js +53 -0
- package/select/harness.js.map +1 -0
- package/select/lib/_filled-select.scss +163 -0
- package/select/lib/_outlined-select.scss +146 -0
- package/select/lib/_shared.scss +48 -0
- package/select/lib/filled-forced-colors-styles.css.d.ts +1 -0
- package/select/lib/filled-forced-colors-styles.css.js +9 -0
- package/select/lib/filled-forced-colors-styles.css.js.map +1 -0
- package/select/lib/filled-forced-colors-styles.scss +29 -0
- package/select/lib/filled-select-styles.css.d.ts +1 -0
- package/select/lib/filled-select-styles.css.js +9 -0
- package/select/lib/filled-select-styles.css.js.map +1 -0
- package/select/lib/filled-select-styles.scss +10 -0
- package/select/lib/filled-select.d.ts +10 -0
- package/select/lib/filled-select.js +16 -0
- package/select/lib/filled-select.js.map +1 -0
- package/select/lib/outlined-forced-colors-styles.css.d.ts +1 -0
- package/select/lib/outlined-forced-colors-styles.css.js +9 -0
- package/select/lib/outlined-forced-colors-styles.css.js.map +1 -0
- package/select/lib/outlined-forced-colors-styles.scss +29 -0
- package/select/lib/outlined-select-styles.css.d.ts +1 -0
- package/select/lib/outlined-select-styles.css.js +9 -0
- package/select/lib/outlined-select-styles.css.js.map +1 -0
- package/select/lib/outlined-select-styles.scss +10 -0
- package/select/lib/outlined-select.d.ts +10 -0
- package/select/lib/outlined-select.js +16 -0
- package/select/lib/outlined-select.js.map +1 -0
- package/select/lib/select.d.ts +218 -0
- package/select/lib/select.js +587 -0
- package/select/lib/select.js.map +1 -0
- package/select/lib/selectoption/harness.d.ts +11 -0
- package/select/lib/selectoption/harness.js +12 -0
- package/select/lib/selectoption/harness.js.map +1 -0
- package/select/lib/selectoption/select-option.d.ts +30 -0
- package/select/lib/selectoption/select-option.js +71 -0
- package/select/lib/selectoption/select-option.js.map +1 -0
- package/select/lib/shared-styles.css.d.ts +1 -0
- package/select/lib/shared-styles.css.js +9 -0
- package/select/lib/shared-styles.css.js.map +1 -0
- package/select/lib/shared-styles.scss +10 -0
- package/select/lib/shared.d.ts +52 -0
- package/select/lib/shared.js +41 -0
- package/select/lib/shared.js.map +1 -0
- package/select/outlined-select.d.ts +41 -0
- package/select/outlined-select.js +46 -0
- package/select/outlined-select.js.map +1 -0
- package/select/select-option.d.ts +44 -0
- package/select/select-option.js +51 -0
- package/select/select-option.js.map +1 -0
- package/slider/harness.d.ts +1 -0
- package/slider/harness.js +5 -0
- package/slider/harness.js.map +1 -1
- package/slider/lib/_slider.scss +147 -171
- package/slider/lib/forced-colors-styles.css.js +1 -1
- package/slider/lib/forced-colors-styles.css.js.map +1 -1
- package/slider/lib/forced-colors-styles.scss +2 -2
- package/slider/lib/slider-styles.css.js +1 -1
- package/slider/lib/slider-styles.css.js.map +1 -1
- package/slider/lib/slider.d.ts +2 -7
- package/slider/lib/slider.js +65 -119
- package/slider/lib/slider.js.map +1 -1
- package/switch/lib/switch-styles.css.js +1 -1
- package/switch/lib/switch-styles.css.js.map +1 -1
- package/switch/lib/switch.d.ts +0 -2
- package/switch/lib/switch.js +32 -54
- package/switch/lib/switch.js.map +1 -1
- package/textfield/lib/filled-styles.css.js +1 -1
- package/textfield/lib/filled-styles.css.js.map +1 -1
- package/textfield/lib/outlined-styles.css.js +1 -1
- package/textfield/lib/outlined-styles.css.js.map +1 -1
- package/textfield/lib/text-field.d.ts +0 -10
- package/textfield/lib/text-field.js +45 -115
- package/textfield/lib/text-field.js.map +1 -1
- package/tokens/_index.scss +6 -0
- package/tokens/_md-comp-assist-chip.scss +81 -21
- package/tokens/_md-comp-badge.scss +8 -1
- package/tokens/_md-comp-banner.scss +1 -1
- package/tokens/_md-comp-bottom-app-bar.scss +1 -1
- package/tokens/_md-comp-carousel-item.scss +1 -1
- package/tokens/_md-comp-checkbox.scss +1 -1
- package/tokens/_md-comp-circular-progress-indicator.scss +17 -2
- package/tokens/_md-comp-data-table.scss +1 -1
- package/tokens/_md-comp-date-input-modal.scss +1 -1
- package/tokens/_md-comp-date-picker-docked.scss +1 -1
- package/tokens/_md-comp-date-picker-modal.scss +1 -1
- package/tokens/_md-comp-dialog.scss +10 -1
- package/tokens/_md-comp-divider.scss +1 -1
- package/tokens/_md-comp-elevated-button.scss +80 -20
- package/tokens/_md-comp-elevated-card.scss +1 -1
- package/tokens/_md-comp-elevation.scss +24 -0
- package/tokens/_md-comp-extended-fab-branded.scss +8 -1
- package/tokens/_md-comp-extended-fab-primary.scss +8 -1
- package/tokens/_md-comp-extended-fab-secondary.scss +8 -1
- package/tokens/_md-comp-extended-fab-surface.scss +8 -1
- package/tokens/_md-comp-extended-fab-tertiary.scss +8 -1
- package/tokens/_md-comp-fab-branded-large.scss +1 -1
- package/tokens/_md-comp-fab-branded.scss +110 -2
- package/tokens/_md-comp-fab-primary-large.scss +1 -1
- package/tokens/_md-comp-fab-primary-small.scss +1 -1
- package/tokens/_md-comp-fab-primary.scss +1 -1
- package/tokens/_md-comp-fab-secondary-large.scss +1 -1
- package/tokens/_md-comp-fab-secondary-small.scss +1 -1
- package/tokens/_md-comp-fab-secondary.scss +1 -1
- package/tokens/_md-comp-fab-surface-large.scss +1 -1
- package/tokens/_md-comp-fab-surface-small.scss +1 -1
- package/tokens/_md-comp-fab-surface.scss +1 -1
- package/tokens/_md-comp-fab-tertiary-large.scss +1 -1
- package/tokens/_md-comp-fab-tertiary-small.scss +1 -1
- package/tokens/_md-comp-fab-tertiary.scss +1 -1
- package/tokens/_md-comp-fab.scss +290 -0
- package/tokens/_md-comp-filled-autocomplete.scss +1 -1
- package/tokens/_md-comp-filled-button.scss +80 -20
- package/tokens/_md-comp-filled-card.scss +1 -1
- package/tokens/_md-comp-filled-icon-button.scss +1 -1
- package/tokens/_md-comp-filled-menu-button.scss +1 -1
- package/tokens/_md-comp-filled-select.scss +151 -2
- package/tokens/_md-comp-filled-text-field.scss +10 -1
- package/tokens/_md-comp-filled-tonal-button.scss +80 -20
- package/tokens/_md-comp-filled-tonal-icon-button.scss +1 -1
- package/tokens/_md-comp-filter-chip.scss +211 -11
- package/tokens/_md-comp-focus-ring.scss +46 -0
- package/tokens/_md-comp-full-screen-dialog.scss +1 -1
- package/tokens/_md-comp-icon-button.scss +1 -1
- package/tokens/_md-comp-input-chip.scss +186 -11
- package/tokens/_md-comp-linear-progress-indicator.scss +15 -2
- package/tokens/_md-comp-list-item.scss +201 -0
- package/tokens/_md-comp-list.scss +110 -12
- package/tokens/_md-comp-menu-item.scss +76 -0
- package/tokens/_md-comp-menu.scss +53 -3
- package/tokens/_md-comp-navigation-bar.scss +1 -1
- package/tokens/_md-comp-navigation-drawer.scss +1 -1
- package/tokens/_md-comp-navigation-rail.scss +1 -1
- package/tokens/_md-comp-outlined-autocomplete.scss +1 -1
- package/tokens/_md-comp-outlined-button.scss +77 -19
- package/tokens/_md-comp-outlined-card.scss +1 -1
- package/tokens/_md-comp-outlined-icon-button.scss +1 -1
- package/tokens/_md-comp-outlined-menu-button.scss +1 -1
- package/tokens/_md-comp-outlined-segmented-button.scss +10 -1
- package/tokens/_md-comp-outlined-select.scss +151 -2
- package/tokens/_md-comp-outlined-text-field.scss +10 -1
- package/tokens/_md-comp-plain-tooltip.scss +1 -1
- package/tokens/_md-comp-primary-navigation-tab.scss +10 -1
- package/tokens/_md-comp-radio-button.scss +1 -1
- package/tokens/_md-comp-rich-tooltip.scss +1 -1
- package/tokens/_md-comp-scrim.scss +1 -1
- package/tokens/_md-comp-search-bar.scss +1 -1
- package/tokens/_md-comp-search-view.scss +1 -1
- package/tokens/_md-comp-secondary-navigation-tab.scss +9 -1
- package/tokens/_md-comp-sheet-bottom.scss +1 -1
- package/tokens/_md-comp-sheet-floating.scss +1 -1
- package/tokens/_md-comp-sheet-side.scss +1 -1
- package/tokens/_md-comp-slider.scss +23 -2
- package/tokens/_md-comp-snackbar.scss +1 -1
- package/tokens/_md-comp-standard-menu-button.scss +1 -1
- package/tokens/_md-comp-suggestion-chip.scss +83 -24
- package/tokens/_md-comp-switch.scss +1 -1
- package/tokens/_md-comp-test-table.scss +31 -0
- package/tokens/_md-comp-text-button.scss +70 -19
- package/tokens/_md-comp-time-input.scss +1 -1
- package/tokens/_md-comp-time-picker.scss +1 -1
- package/tokens/_md-comp-top-app-bar-large.scss +1 -1
- package/tokens/_md-comp-top-app-bar-medium.scss +1 -1
- package/tokens/_md-comp-top-app-bar-small-centered.scss +1 -1
- package/tokens/_md-comp-top-app-bar-small.scss +1 -1
- package/tokens/_md-ref-palette.scss +1 -1
- package/tokens/_md-ref-typeface.scss +24 -2
- package/tokens/_md-sys-color.scss +1 -1
- package/tokens/_md-sys-elevation.scss +1 -1
- package/tokens/_md-sys-motion.scss +1 -1
- package/tokens/_md-sys-shape.scss +1 -1
- package/tokens/_md-sys-state.scss +1 -1
- package/tokens/_md-sys-typescale.scss +36 -2
- package/tokens/_values.scss +114 -0
- package/tokens/{v0_161 → v0_172}/_md-comp-assist-chip.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-badge.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-banner.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-bottom-app-bar.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-carousel-item.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-checkbox.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-circular-progress-indicator.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-data-table.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-date-input-modal.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-docked.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-modal.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-dialog.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-divider.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-elevated-button.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-elevated-card.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-branded.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-primary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-secondary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-surface.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-tertiary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded-large.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-large.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-small.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-autocomplete.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-card.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-icon-button.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-select.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-text-field.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-icon-button.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filter-chip.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-full-screen-dialog.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-icon-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-input-chip.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-linear-progress-indicator.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-list.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-menu.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-bar.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-drawer.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-rail.scss +1 -16
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-autocomplete.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-card.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-icon-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-segmented-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-select.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-text-field.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-plain-tooltip.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-primary-navigation-tab.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-radio-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-rich-tooltip.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-scrim.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-search-bar.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-search-view.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-secondary-navigation-tab.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-bottom.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-floating.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-side.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-slider.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-snackbar.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-standard-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-suggestion-chip.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-switch.scss +13 -11
- package/tokens/{v0_161 → v0_172}/_md-comp-text-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-time-input.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-time-picker.scss +5 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-large.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-medium.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small-centered.scss +3 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-ref-palette.scss +23 -23
- package/tokens/{v0_161 → v0_172}/_md-ref-typeface.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-color.scss +9 -9
- package/tokens/{v0_161 → v0_172}/_md-sys-elevation.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-motion.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-shape.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-state.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-typescale.scss +1 -1
- package/tokens/v0_172/index.test.css.d.ts +1 -0
- package/tokens/v0_172/lib.test.css.d.ts +1 -0
- package/types/aria.d.ts +61 -1
- package/actionelement/action-element.d.ts +0 -79
- package/actionelement/action-element.js +0 -97
- package/actionelement/action-element.js.map +0 -1
- package/button/elevated-link-button.d.ts +0 -36
- package/button/elevated-link-button.js +0 -41
- package/button/elevated-link-button.js.map +0 -1
- package/button/filled-link-button.d.ts +0 -34
- package/button/filled-link-button.js +0 -39
- package/button/filled-link-button.js.map +0 -1
- package/button/lib/elevated-link-button.d.ts +0 -13
- package/button/lib/elevated-link-button.js +0 -21
- package/button/lib/elevated-link-button.js.map +0 -1
- package/button/lib/filled-link-button.d.ts +0 -14
- package/button/lib/filled-link-button.js +0 -22
- package/button/lib/filled-link-button.js.map +0 -1
- package/button/lib/link-button.d.ts +0 -24
- package/button/lib/link-button.js +0 -59
- package/button/lib/link-button.js.map +0 -1
- package/button/lib/outlined-link-button.d.ts +0 -12
- package/button/lib/outlined-link-button.js +0 -20
- package/button/lib/outlined-link-button.js.map +0 -1
- package/button/lib/state.d.ts +0 -10
- package/button/lib/state.js +0 -7
- package/button/lib/state.js.map +0 -1
- package/button/lib/text-link-button.d.ts +0 -10
- package/button/lib/text-link-button.js +0 -16
- package/button/lib/text-link-button.js.map +0 -1
- package/button/lib/tonal-link-button.d.ts +0 -14
- package/button/lib/tonal-link-button.js +0 -22
- package/button/lib/tonal-link-button.js.map +0 -1
- package/button/outlined-link-button.d.ts +0 -36
- package/button/outlined-link-button.js +0 -40
- package/button/outlined-link-button.js.map +0 -1
- package/button/text-link-button.d.ts +0 -34
- package/button/text-link-button.js +0 -38
- package/button/text-link-button.js.map +0 -1
- package/button/tonal-link-button.d.ts +0 -35
- package/button/tonal-link-button.js +0 -40
- package/button/tonal-link-button.js.map +0 -1
- package/controller/action-controller.d.ts +0 -147
- package/controller/action-controller.js +0 -286
- package/controller/action-controller.js.map +0 -1
- package/decorators/aria-property.d.ts +0 -32
- package/decorators/aria-property.js +0 -99
- package/decorators/aria-property.js.map +0 -1
- package/elevation/lib/_md-comp-elevation.scss +0 -27
- package/fab/_fab-extended.scss +0 -6
- package/fab/fab-extended.d.ts +0 -23
- package/fab/fab-extended.js +0 -29
- package/fab/fab-extended.js.map +0 -1
- package/fab/lib/_fab-extended.scss +0 -73
- package/fab/lib/fab-extended-styles.css.js +0 -9
- package/fab/lib/fab-extended-styles.css.js.map +0 -1
- package/fab/lib/fab-extended.d.ts +0 -19
- package/fab/lib/fab-extended.js +0 -28
- package/fab/lib/fab-extended.js.map +0 -1
- package/fab/lib/fab-shared-styles.css.js +0 -9
- package/fab/lib/fab-shared-styles.css.js.map +0 -1
- package/fab/lib/fab-shared.js +0 -121
- package/fab/lib/fab-shared.js.map +0 -1
- package/focus/lib/_md-comp-focus-ring.scss +0 -30
- package/iconbutton/filled-icon-button-toggle.d.ts +0 -31
- package/iconbutton/filled-icon-button-toggle.js +0 -40
- package/iconbutton/filled-icon-button-toggle.js.map +0 -1
- package/iconbutton/filled-link-icon-button.d.ts +0 -31
- package/iconbutton/filled-link-icon-button.js +0 -39
- package/iconbutton/filled-link-icon-button.js.map +0 -1
- package/iconbutton/filled-tonal-icon-button-toggle.d.ts +0 -31
- package/iconbutton/filled-tonal-icon-button-toggle.js +0 -40
- package/iconbutton/filled-tonal-icon-button-toggle.js.map +0 -1
- package/iconbutton/filled-tonal-link-icon-button.d.ts +0 -31
- package/iconbutton/filled-tonal-link-icon-button.js +0 -39
- package/iconbutton/filled-tonal-link-icon-button.js.map +0 -1
- package/iconbutton/lib/icon-button-toggle.d.ts +0 -34
- package/iconbutton/lib/icon-button-toggle.js +0 -87
- package/iconbutton/lib/icon-button-toggle.js.map +0 -1
- package/iconbutton/lib/link-icon-button.d.ts +0 -23
- package/iconbutton/lib/link-icon-button.js +0 -58
- package/iconbutton/lib/link-icon-button.js.map +0 -1
- package/iconbutton/outlined-icon-button-toggle.d.ts +0 -31
- package/iconbutton/outlined-icon-button-toggle.js +0 -39
- package/iconbutton/outlined-icon-button-toggle.js.map +0 -1
- package/iconbutton/outlined-link-icon-button.d.ts +0 -31
- package/iconbutton/outlined-link-icon-button.js +0 -39
- package/iconbutton/outlined-link-icon-button.js.map +0 -1
- package/iconbutton/standard-icon-button-toggle.d.ts +0 -31
- package/iconbutton/standard-icon-button-toggle.js +0 -39
- package/iconbutton/standard-icon-button-toggle.js.map +0 -1
- package/iconbutton/standard-link-icon-button.d.ts +0 -31
- package/iconbutton/standard-link-icon-button.js +0 -39
- package/iconbutton/standard-link-icon-button.js.map +0 -1
- package/slider/lib/_tokens.scss +0 -60
- /package/{fab/lib/fab-extended-styles.css.d.ts → chips/lib/filter-styles.css.d.ts} +0 -0
- /package/{fab/lib/fab-shared-styles.css.d.ts → circularprogress/lib/circular-progress-styles.css.d.ts} +0 -0
- /package/{tokens/v0_161/index.test.css.d.ts → fab/lib/fab-branded-styles.css.d.ts} +0 -0
- /package/{tokens/v0_161/lib.test.css.d.ts → fab/lib/forced-colors-styles.css.d.ts} +0 -0
- /package/tokens/{v0_161 → v0_172}/_index.scss +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.css.js +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.css.js.map +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.scss +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.css.js +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.css.js.map +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.scss +0 -0
package/ripple/lib/ripple.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2022 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { __decorate
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
7
|
import { html, LitElement } from 'lit';
|
|
8
8
|
import { property, query, state } from 'lit/decorators.js';
|
|
9
9
|
import { classMap } from 'lit/directives/class-map.js';
|
|
@@ -330,27 +330,21 @@ export class Ripple extends LitElement {
|
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
332
|
__decorate([
|
|
333
|
-
property({ type: Boolean, reflect: true })
|
|
334
|
-
__metadata("design:type", Object)
|
|
333
|
+
property({ type: Boolean, reflect: true })
|
|
335
334
|
], Ripple.prototype, "unbounded", void 0);
|
|
336
335
|
__decorate([
|
|
337
|
-
property({ type: Boolean, reflect: true })
|
|
338
|
-
__metadata("design:type", Object)
|
|
336
|
+
property({ type: Boolean, reflect: true })
|
|
339
337
|
], Ripple.prototype, "disabled", void 0);
|
|
340
338
|
__decorate([
|
|
341
|
-
state()
|
|
342
|
-
__metadata("design:type", Object)
|
|
339
|
+
state()
|
|
343
340
|
], Ripple.prototype, "hovered", void 0);
|
|
344
341
|
__decorate([
|
|
345
|
-
state()
|
|
346
|
-
__metadata("design:type", Object)
|
|
342
|
+
state()
|
|
347
343
|
], Ripple.prototype, "focused", void 0);
|
|
348
344
|
__decorate([
|
|
349
|
-
state()
|
|
350
|
-
__metadata("design:type", Object)
|
|
345
|
+
state()
|
|
351
346
|
], Ripple.prototype, "pressed", void 0);
|
|
352
347
|
__decorate([
|
|
353
|
-
query('.surface')
|
|
354
|
-
__metadata("design:type", HTMLElement)
|
|
348
|
+
query('.surface')
|
|
355
349
|
], Ripple.prototype, "mdRoot", void 0);
|
|
356
350
|
//# sourceMappingURL=ripple.js.map
|
package/ripple/lib/ripple.js.map
CHANGED
|
@@ -1 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CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE;YAClE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SAC7B;QAED,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACK,QAAQ,CAAC,EAAC,CAAC,EAAE,CAAC,EAAe;QACnC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAChE,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC;IAC5D,CAAC;IAEO,OAAO,CAAC,EAAC,WAAW,EAAe;QACzC,OAAO,WAAW,KAAK,OAAO,CAAC;IACjC,CAAC;CACF;AAtTC;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;yCAAmB;AAK5D;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;wCAAkB;AAE3D;IAAC,KAAK,EAAE;;uCAAyB;AACjC;IAAC,KAAK,EAAE;;uCAAyB;AACjC;IAAC,KAAK,EAAE;;uCAAyB;AAEjC;IAAC,KAAK,CAAC,UAAU,CAAC;8BAA2B,WAAW;sCAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, LitElement, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {EASING} from '../../motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/**\n * Interaction states for the ripple.\n *\n * On Touch:\n * - `INACTIVE -> TOUCH_DELAY -> WAITING_FOR_CLICK -> INACTIVE`\n * - `INACTIVE -> TOUCH_DELAY -> HOLDING -> WAITING_FOR_CLICK -> INACTIVE`\n *\n * On Mouse or Pen:\n * - `INACTIVE -> WAITING_FOR_CLICK -> INACTIVE`\n */\nenum State {\n /**\n * Initial state of the control, no touch in progress.\n *\n * Transitions:\n * - on touch down: transition to `TOUCH_DELAY`.\n * - on mouse down: transition to `WAITING_FOR_CLICK`.\n */\n INACTIVE,\n /**\n * Touch down has been received, waiting to determine if it's a swipe or\n * scroll.\n *\n * Transitions:\n * - on touch up: begin press; transition to `WAITING_FOR_CLICK`.\n * - on cancel: transition to `INACTIVE`.\n * - after `TOUCH_DELAY_MS`: begin press; transition to `HOLDING`.\n */\n TOUCH_DELAY,\n /**\n * A touch has been deemed to be a press\n *\n * Transitions:\n * - on up: transition to `WAITING_FOR_CLICK`.\n */\n HOLDING,\n /**\n * The user touch has finished, transition into rest state.\n *\n * Transitions:\n * - on click end press; transition to `INACTIVE`.\n */\n WAITING_FOR_CLICK\n}\n\n/**\n * Delay reacting to touch so that we do not show the ripple for a swipe or\n * scroll interaction.\n */\nconst TOUCH_DELAY_MS = 150;\n\n/**\n * A ripple component.\n */\nexport class Ripple extends LitElement {\n // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)\n // Remove Safari workaround that requires reflecting `unbounded` so\n // it can be styled against.\n /**\n * Sets the ripple to be an unbounded circle.\n */\n @property({type: Boolean, reflect: true}) unbounded = false;\n\n /**\n * Disables the ripple.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n @state() private hovered = false;\n @state() private focused = false;\n @state() private pressed = false;\n\n @query('.surface') private readonly mdRoot!: HTMLElement;\n private rippleSize = '';\n private rippleScale = '';\n private initialSize = 0;\n private growAnimation?: Animation;\n private state = State.INACTIVE;\n private rippleStartEvent?: PointerEvent;\n private checkBoundsAfterContextMenu = false;\n\n handlePointerenter(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = true;\n }\n\n handlePointerleave(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = false;\n\n // release a held mouse or pen press that moves outside the element\n if (this.state !== State.INACTIVE) {\n this.endPressAnimation();\n }\n }\n\n handleFocusin() {\n this.focused = true;\n }\n\n handleFocusout() {\n this.focused = false;\n }\n\n handlePointerup(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n if (this.state === State.HOLDING) {\n this.state = State.WAITING_FOR_CLICK;\n return;\n }\n\n if (this.state === State.TOUCH_DELAY) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(this.rippleStartEvent);\n return;\n }\n }\n\n async handlePointerdown(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.rippleStartEvent = event;\n if (!this.isTouch(event)) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(event);\n return;\n }\n\n // after a longpress contextmenu event, an extra `pointerdown` can be\n // dispatched to the pressed element. Check that the down is within\n // bounds of the element in this case.\n if (this.checkBoundsAfterContextMenu && !this.inBounds(event)) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = false;\n\n // Wait for a hold after touch delay\n this.state = State.TOUCH_DELAY;\n await new Promise(resolve => {\n setTimeout(resolve, TOUCH_DELAY_MS);\n });\n\n if (this.state !== State.TOUCH_DELAY) {\n return;\n }\n\n this.state = State.HOLDING;\n this.startPressAnimation(event);\n }\n\n handleClick() {\n // Click is a MouseEvent in Firefox and Safari, so we cannot use\n // `shouldReactToEvent`\n if (this.disabled) {\n return;\n }\n\n if (this.state === State.WAITING_FOR_CLICK) {\n this.endPressAnimation();\n return;\n }\n\n if (this.state === State.INACTIVE) {\n // keyboard synthesized click event\n this.startPressAnimation();\n this.endPressAnimation();\n }\n }\n\n handlePointercancel(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.endPressAnimation();\n }\n\n handleContextmenu() {\n if (this.disabled) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = true;\n this.endPressAnimation();\n }\n\n protected override render() {\n const classes = {\n 'hovered': this.hovered,\n 'focused': this.focused,\n 'pressed': this.pressed,\n 'unbounded': this.unbounded,\n };\n\n return html`<div class=\"surface ${classMap(classes)}\"></div>`;\n }\n\n protected override update(changedProps: PropertyValues<this>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.hovered = false;\n this.focused = false;\n this.pressed = false;\n }\n super.update(changedProps);\n }\n\n private getDimensions() {\n return (this.parentElement ?? this).getBoundingClientRect();\n }\n\n private determineRippleSize() {\n const {height, width} = this.getDimensions();\n const maxDim = Math.max(height, width);\n const softEdgeSize =\n Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE);\n\n\n let maxRadius = maxDim;\n let initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n maxRadius = hypotenuse + PADDING;\n\n // ensure `initialSize` is even for unbounded\n if (this.unbounded) {\n initialSize = initialSize - (initialSize % 2);\n }\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${this.initialSize}px`;\n }\n\n private getNormalizedPointerEventCoords(pointerEvent: PointerEvent):\n {x: number, y: number} {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getDimensions();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n private getTranslationCoordinates(positionEvent?: Event) {\n const {height, width} = this.getDimensions();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - (this.initialSize / 2),\n y: startPoint.y - (this.initialSize / 2),\n };\n\n return {startPoint, endPoint};\n }\n\n private startPressAnimation(positionEvent?: Event) {\n this.pressed = true;\n this.growAnimation?.cancel();\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n this.growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: EASING.STANDARD,\n fill: ANIMATION_FILL\n });\n }\n\n private async endPressAnimation() {\n const animation = this.growAnimation;\n const pressAnimationPlayState = animation?.currentTime ?? Infinity;\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n return;\n }\n\n await new Promise(resolve => {\n setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState);\n });\n\n if (this.growAnimation !== animation) {\n // A new press animation was started. The old animation was canceled and\n // should not finish the pressed state.\n return;\n }\n\n this.pressed = false;\n }\n\n /**\n * Returns `true` if\n * - the ripple element is enabled\n * - the pointer is primary for the input type\n * - the pointer is the pointer that started the interaction, or will start\n * the interaction\n * - the pointer is a touch, or the pointer state has the primary button\n * held, or the pointer is hovering\n */\n private shouldReactToEvent(event: PointerEvent) {\n if (this.disabled || !event.isPrimary) {\n return false;\n }\n\n if (this.rippleStartEvent &&\n this.rippleStartEvent.pointerId !== event.pointerId) {\n return false;\n }\n\n if (event.type === 'pointerenter' || event.type === 'pointerleave') {\n return !this.isTouch(event);\n }\n\n const isPrimaryButton = event.buttons === 1;\n return this.isTouch(event) || isPrimaryButton;\n }\n\n /**\n * Check if the event is within the bounds of the element.\n *\n * This is only needed for the \"stuck\" contextmenu longpress on Chrome.\n */\n private inBounds({x, y}: PointerEvent) {\n const {top, left, bottom, right} = this.getBoundingClientRect();\n return x >= left && x <= right && y >= top && y <= bottom;\n }\n\n private isTouch({pointerType}: PointerEvent) {\n return pointerType === 'touch';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ripple.js","sourceRoot":"","sources":["ripple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,MAAM,EAAC,MAAM,2BAA2B,CAAC;AAEjD,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,YAAY,GAAG,SAAS,CAAC;AAC/B,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC;;;;;;;;;GASG;AACH,IAAK,KAiCJ;AAjCD,WAAK,KAAK;IACR;;;;;;OAMG;IACH,yCAAQ,CAAA;IACR;;;;;;;;OAQG;IACH,+CAAW,CAAA;IACX;;;;;OAKG;IACH,uCAAO,CAAA;IACP;;;;;OA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IAAI,EAAC,CAAC;wCAAkB;AAElD;IAAR,KAAK,EAAE;uCAAyB;AACxB;IAAR,KAAK,EAAE;uCAAyB;AACxB;IAAR,KAAK,EAAE;uCAAyB;AAEd;IAAlB,KAAK,CAAC,UAAU,CAAC;sCAAuC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html, LitElement, PropertyValues} from 'lit';\nimport {property, query, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\n\nimport {EASING} from '../../motion/animation.js';\n\nconst PRESS_GROW_MS = 450;\nconst MINIMUM_PRESS_MS = 225;\nconst INITIAL_ORIGIN_SCALE = 0.2;\nconst PADDING = 10;\nconst SOFT_EDGE_MINIMUM_SIZE = 75;\nconst SOFT_EDGE_CONTAINER_RATIO = 0.35;\nconst PRESS_PSEUDO = '::after';\nconst ANIMATION_FILL = 'forwards';\n\n/**\n * Interaction states for the ripple.\n *\n * On Touch:\n * - `INACTIVE -> TOUCH_DELAY -> WAITING_FOR_CLICK -> INACTIVE`\n * - `INACTIVE -> TOUCH_DELAY -> HOLDING -> WAITING_FOR_CLICK -> INACTIVE`\n *\n * On Mouse or Pen:\n * - `INACTIVE -> WAITING_FOR_CLICK -> INACTIVE`\n */\nenum State {\n /**\n * Initial state of the control, no touch in progress.\n *\n * Transitions:\n * - on touch down: transition to `TOUCH_DELAY`.\n * - on mouse down: transition to `WAITING_FOR_CLICK`.\n */\n INACTIVE,\n /**\n * Touch down has been received, waiting to determine if it's a swipe or\n * scroll.\n *\n * Transitions:\n * - on touch up: begin press; transition to `WAITING_FOR_CLICK`.\n * - on cancel: transition to `INACTIVE`.\n * - after `TOUCH_DELAY_MS`: begin press; transition to `HOLDING`.\n */\n TOUCH_DELAY,\n /**\n * A touch has been deemed to be a press\n *\n * Transitions:\n * - on up: transition to `WAITING_FOR_CLICK`.\n */\n HOLDING,\n /**\n * The user touch has finished, transition into rest state.\n *\n * Transitions:\n * - on click end press; transition to `INACTIVE`.\n */\n WAITING_FOR_CLICK\n}\n\n/**\n * Delay reacting to touch so that we do not show the ripple for a swipe or\n * scroll interaction.\n */\nconst TOUCH_DELAY_MS = 150;\n\n/**\n * A ripple component.\n */\nexport class Ripple extends LitElement {\n // TODO(https://bugs.webkit.org/show_bug.cgi?id=247546)\n // Remove Safari workaround that requires reflecting `unbounded` so\n // it can be styled against.\n /**\n * Sets the ripple to be an unbounded circle.\n */\n @property({type: Boolean, reflect: true}) unbounded = false;\n\n /**\n * Disables the ripple.\n */\n @property({type: Boolean, reflect: true}) disabled = false;\n\n @state() private hovered = false;\n @state() private focused = false;\n @state() private pressed = false;\n\n @query('.surface') private readonly mdRoot!: HTMLElement;\n private rippleSize = '';\n private rippleScale = '';\n private initialSize = 0;\n private growAnimation?: Animation;\n private state = State.INACTIVE;\n private rippleStartEvent?: PointerEvent;\n private checkBoundsAfterContextMenu = false;\n\n handlePointerenter(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = true;\n }\n\n handlePointerleave(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.hovered = false;\n\n // release a held mouse or pen press that moves outside the element\n if (this.state !== State.INACTIVE) {\n this.endPressAnimation();\n }\n }\n\n handleFocusin() {\n this.focused = true;\n }\n\n handleFocusout() {\n this.focused = false;\n }\n\n handlePointerup(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n if (this.state === State.HOLDING) {\n this.state = State.WAITING_FOR_CLICK;\n return;\n }\n\n if (this.state === State.TOUCH_DELAY) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(this.rippleStartEvent);\n return;\n }\n }\n\n async handlePointerdown(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.rippleStartEvent = event;\n if (!this.isTouch(event)) {\n this.state = State.WAITING_FOR_CLICK;\n this.startPressAnimation(event);\n return;\n }\n\n // after a longpress contextmenu event, an extra `pointerdown` can be\n // dispatched to the pressed element. Check that the down is within\n // bounds of the element in this case.\n if (this.checkBoundsAfterContextMenu && !this.inBounds(event)) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = false;\n\n // Wait for a hold after touch delay\n this.state = State.TOUCH_DELAY;\n await new Promise(resolve => {\n setTimeout(resolve, TOUCH_DELAY_MS);\n });\n\n if (this.state !== State.TOUCH_DELAY) {\n return;\n }\n\n this.state = State.HOLDING;\n this.startPressAnimation(event);\n }\n\n handleClick() {\n // Click is a MouseEvent in Firefox and Safari, so we cannot use\n // `shouldReactToEvent`\n if (this.disabled) {\n return;\n }\n\n if (this.state === State.WAITING_FOR_CLICK) {\n this.endPressAnimation();\n return;\n }\n\n if (this.state === State.INACTIVE) {\n // keyboard synthesized click event\n this.startPressAnimation();\n this.endPressAnimation();\n }\n }\n\n handlePointercancel(event: PointerEvent) {\n if (!this.shouldReactToEvent(event)) {\n return;\n }\n\n this.endPressAnimation();\n }\n\n handleContextmenu() {\n if (this.disabled) {\n return;\n }\n\n this.checkBoundsAfterContextMenu = true;\n this.endPressAnimation();\n }\n\n protected override render() {\n const classes = {\n 'hovered': this.hovered,\n 'focused': this.focused,\n 'pressed': this.pressed,\n 'unbounded': this.unbounded,\n };\n\n return html`<div class=\"surface ${classMap(classes)}\"></div>`;\n }\n\n protected override update(changedProps: PropertyValues<this>) {\n if (changedProps.has('disabled') && this.disabled) {\n this.hovered = false;\n this.focused = false;\n this.pressed = false;\n }\n super.update(changedProps);\n }\n\n private getDimensions() {\n return (this.parentElement ?? this).getBoundingClientRect();\n }\n\n private determineRippleSize() {\n const {height, width} = this.getDimensions();\n const maxDim = Math.max(height, width);\n const softEdgeSize =\n Math.max(SOFT_EDGE_CONTAINER_RATIO * maxDim, SOFT_EDGE_MINIMUM_SIZE);\n\n\n let maxRadius = maxDim;\n let initialSize = Math.floor(maxDim * INITIAL_ORIGIN_SCALE);\n\n const hypotenuse = Math.sqrt(width ** 2 + height ** 2);\n maxRadius = hypotenuse + PADDING;\n\n // ensure `initialSize` is even for unbounded\n if (this.unbounded) {\n initialSize = initialSize - (initialSize % 2);\n }\n\n this.initialSize = initialSize;\n this.rippleScale = `${(maxRadius + softEdgeSize) / initialSize}`;\n this.rippleSize = `${this.initialSize}px`;\n }\n\n private getNormalizedPointerEventCoords(pointerEvent: PointerEvent):\n {x: number, y: number} {\n const {scrollX, scrollY} = window;\n const {left, top} = this.getDimensions();\n const documentX = scrollX + left;\n const documentY = scrollY + top;\n const {pageX, pageY} = pointerEvent;\n return {x: pageX - documentX, y: pageY - documentY};\n }\n\n private getTranslationCoordinates(positionEvent?: Event) {\n const {height, width} = this.getDimensions();\n // end in the center\n const endPoint = {\n x: (width - this.initialSize) / 2,\n y: (height - this.initialSize) / 2,\n };\n\n let startPoint;\n if (positionEvent instanceof PointerEvent) {\n startPoint = this.getNormalizedPointerEventCoords(positionEvent);\n } else {\n startPoint = {\n x: width / 2,\n y: height / 2,\n };\n }\n\n // center around start point\n startPoint = {\n x: startPoint.x - (this.initialSize / 2),\n y: startPoint.y - (this.initialSize / 2),\n };\n\n return {startPoint, endPoint};\n }\n\n private startPressAnimation(positionEvent?: Event) {\n this.pressed = true;\n this.growAnimation?.cancel();\n this.determineRippleSize();\n const {startPoint, endPoint} =\n this.getTranslationCoordinates(positionEvent);\n const translateStart = `${startPoint.x}px, ${startPoint.y}px`;\n const translateEnd = `${endPoint.x}px, ${endPoint.y}px`;\n\n this.growAnimation = this.mdRoot.animate(\n {\n top: [0, 0],\n left: [0, 0],\n height: [this.rippleSize, this.rippleSize],\n width: [this.rippleSize, this.rippleSize],\n transform: [\n `translate(${translateStart}) scale(1)`,\n `translate(${translateEnd}) scale(${this.rippleScale})`\n ],\n },\n {\n pseudoElement: PRESS_PSEUDO,\n duration: PRESS_GROW_MS,\n easing: EASING.STANDARD,\n fill: ANIMATION_FILL\n });\n }\n\n private async endPressAnimation() {\n const animation = this.growAnimation;\n const pressAnimationPlayState = animation?.currentTime ?? Infinity;\n if (pressAnimationPlayState >= MINIMUM_PRESS_MS) {\n this.pressed = false;\n return;\n }\n\n await new Promise(resolve => {\n setTimeout(resolve, MINIMUM_PRESS_MS - pressAnimationPlayState);\n });\n\n if (this.growAnimation !== animation) {\n // A new press animation was started. The old animation was canceled and\n // should not finish the pressed state.\n return;\n }\n\n this.pressed = false;\n }\n\n /**\n * Returns `true` if\n * - the ripple element is enabled\n * - the pointer is primary for the input type\n * - the pointer is the pointer that started the interaction, or will start\n * the interaction\n * - the pointer is a touch, or the pointer state has the primary button\n * held, or the pointer is hovering\n */\n private shouldReactToEvent(event: PointerEvent) {\n if (this.disabled || !event.isPrimary) {\n return false;\n }\n\n if (this.rippleStartEvent &&\n this.rippleStartEvent.pointerId !== event.pointerId) {\n return false;\n }\n\n if (event.type === 'pointerenter' || event.type === 'pointerleave') {\n return !this.isTouch(event);\n }\n\n const isPrimaryButton = event.buttons === 1;\n return this.isTouch(event) || isPrimaryButton;\n }\n\n /**\n * Check if the event is within the bounds of the element.\n *\n * This is only needed for the \"stuck\" contextmenu longpress on Chrome.\n */\n private inBounds({x, y}: PointerEvent) {\n const {top, left, bottom, right} = this.getBoundingClientRect();\n return x >= left && x <= right && y >= top && y <= bottom;\n }\n\n private isTouch({pointerType}: PointerEvent) {\n return pointerType === 'touch';\n }\n}\n"]}
|
|
@@ -3,13 +3,22 @@
|
|
|
3
3
|
* Copyright 2022 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { TemplateResult } from 'lit';
|
|
7
|
-
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
8
6
|
import { SegmentedButton } from './segmented-button.js';
|
|
9
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* TODO(b/265346443): add docs
|
|
9
|
+
*/
|
|
10
10
|
export declare class OutlinedSegmentedButton extends SegmentedButton {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
protected getRenderClasses(): {
|
|
12
|
+
'md3-segmented-button--outlined': boolean;
|
|
13
|
+
'md3-segmented-button--selected': boolean;
|
|
14
|
+
'md3-segmented-button--unselected': boolean;
|
|
15
|
+
'md3-segmented-button--with-label': boolean;
|
|
16
|
+
'md3-segmented-button--without-label': boolean;
|
|
17
|
+
'md3-segmented-button--with-icon': boolean;
|
|
18
|
+
'md3-segmented-button--with-checkmark': boolean;
|
|
19
|
+
'md3-segmented-button--without-checkmark': boolean;
|
|
20
|
+
'md3-segmented-button--selecting': boolean;
|
|
21
|
+
'md3-segmented-button--deselecting': boolean;
|
|
22
|
+
};
|
|
23
|
+
protected renderOutline(): import("lit-html").TemplateResult<1>;
|
|
15
24
|
}
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { html } from 'lit';
|
|
7
7
|
import { SegmentedButton } from './segmented-button.js';
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* TODO(b/265346443): add docs
|
|
10
|
+
*/
|
|
9
11
|
export class OutlinedSegmentedButton extends SegmentedButton {
|
|
10
|
-
/** @soyTemplate */
|
|
11
12
|
getRenderClasses() {
|
|
12
13
|
return {
|
|
13
14
|
...super.getRenderClasses(),
|
|
14
15
|
'md3-segmented-button--outlined': true,
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
/** @soyTemplate */
|
|
18
18
|
renderOutline() {
|
|
19
19
|
return html `<span class="md3-segmented-button__outline"></span>`;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlined-segmented-button.js","sourceRoot":"","sources":["outlined-segmented-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"outlined-segmented-button.js","sourceRoot":"","sources":["outlined-segmented-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAAe;IACvC,gBAAgB;QACjC,OAAO;YACL,GAAG,KAAK,CAAC,gBAAgB,EAAE;YAC3B,gCAAgC,EAAE,IAAI;SACvC,CAAC;IACJ,CAAC;IAEkB,aAAa;QAC9B,OAAO,IAAI,CAAA,qDAAqD,CAAC;IACnE,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html} from 'lit';\n\nimport {SegmentedButton} from './segmented-button.js';\n\n/**\n * TODO(b/265346443): add docs\n */\nexport class OutlinedSegmentedButton extends SegmentedButton {\n protected override getRenderClasses() {\n return {\n ...super.getRenderClasses(),\n 'md3-segmented-button--outlined': true,\n };\n }\n\n protected override renderOutline() {\n return html`<span class=\"md3-segmented-button__outline\"></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 `:host{--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb,
|
|
7
|
+
export const styles = css `:host{--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.38));--_disabled-label-text-color: var(--md-segmented-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.38));--_disabled-outline-color: var(--md-segmented-button-disabled-outline-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.12));--_focus-state-layer-opacity: var(--md-segmented-button-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-segmented-button-hover-state-layer-opacity, 0.08);--_label-text-type: var(--md-segmented-button-label-text-type, var(--md-sys-typescale-label-large, 500 0.875rem / 1.25rem var(--md-ref-typeface-plain, Roboto)));--_outline-color: var(--md-segmented-button-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-segmented-button-outline-width, 1px);--_pressed-state-layer-opacity: var(--md-segmented-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-segmented-button-selected-container-color, var(--md-sys-color-secondary-container, #e8def8));--_selected-focus-icon-color: var(--md-segmented-button-selected-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-label-text-color: var(--md-segmented-button-selected-focus-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-state-layer-color: var(--md-segmented-button-selected-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-icon-color: var(--md-segmented-button-selected-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-label-text-color: var(--md-segmented-button-selected-hover-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-state-layer-color: var(--md-segmented-button-selected-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-label-text-color: var(--md-segmented-button-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-icon-color: var(--md-segmented-button-selected-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-label-text-color: var(--md-segmented-button-selected-pressed-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-state-layer-color: var(--md-segmented-button-selected-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-with-icon-icon-color: var(--md-segmented-button-selected-with-icon-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_shape: var(--md-segmented-button-shape, 9999px);--_unselected-focus-icon-color: var(--md-segmented-button-unselected-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-focus-label-text-color: var(--md-segmented-button-unselected-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-focus-state-layer-color: var(--md-segmented-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-icon-color: var(--md-segmented-button-unselected-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-label-text-color: var(--md-segmented-button-unselected-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-state-layer-color: var(--md-segmented-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-label-text-color: var(--md-segmented-button-unselected-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-icon-color: var(--md-segmented-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-label-text-color: var(--md-segmented-button-unselected-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-state-layer-color: var(--md-segmented-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-with-icon-icon-color: var(--md-segmented-button-unselected-with-icon-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_with-icon-icon-size: var(--md-segmented-button-with-icon-icon-size, 18px);--_spacing-leading: var(--md-segmented-button-spacing-leading, 12px);--_spacing-trailing: var(--md-segmented-button-spacing-trailing, 12px)}.md3-segmented-button__outline{border-radius:inherit;border-style:solid;border-width:1px;inset:0px -0.5px;pointer-events:none;position:absolute}/*# sourceMappingURL=outlined-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=outlined-styles.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outlined-styles.css.js","sourceRoot":"","sources":["outlined-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb,
|
|
1
|
+
{"version":3,"file":"outlined-styles.css.js","sourceRoot":"","sources":["outlined-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_container-height: var(--md-segmented-button-container-height, 40px);--_disabled-icon-color: var(--md-segmented-button-disabled-icon-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.38));--_disabled-label-text-color: var(--md-segmented-button-disabled-label-text-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.38));--_disabled-outline-color: var(--md-segmented-button-disabled-outline-color, rgb(var(--md-sys-color-on-surface-rgb, 29, 27, 32), 0.12));--_focus-state-layer-opacity: var(--md-segmented-button-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-segmented-button-hover-state-layer-opacity, 0.08);--_label-text-type: var(--md-segmented-button-label-text-type, var(--md-sys-typescale-label-large, 500 0.875rem / 1.25rem var(--md-ref-typeface-plain, Roboto)));--_outline-color: var(--md-segmented-button-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-segmented-button-outline-width, 1px);--_pressed-state-layer-opacity: var(--md-segmented-button-pressed-state-layer-opacity, 0.12);--_selected-container-color: var(--md-segmented-button-selected-container-color, var(--md-sys-color-secondary-container, #e8def8));--_selected-focus-icon-color: var(--md-segmented-button-selected-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-label-text-color: var(--md-segmented-button-selected-focus-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-focus-state-layer-color: var(--md-segmented-button-selected-focus-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-icon-color: var(--md-segmented-button-selected-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-label-text-color: var(--md-segmented-button-selected-hover-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-hover-state-layer-color: var(--md-segmented-button-selected-hover-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-label-text-color: var(--md-segmented-button-selected-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-icon-color: var(--md-segmented-button-selected-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-label-text-color: var(--md-segmented-button-selected-pressed-label-text-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-pressed-state-layer-color: var(--md-segmented-button-selected-pressed-state-layer-color, var(--md-sys-color-on-secondary-container, #1d192b));--_selected-with-icon-icon-color: var(--md-segmented-button-selected-with-icon-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_shape: var(--md-segmented-button-shape, 9999px);--_unselected-focus-icon-color: var(--md-segmented-button-unselected-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-focus-label-text-color: var(--md-segmented-button-unselected-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-focus-state-layer-color: var(--md-segmented-button-unselected-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-icon-color: var(--md-segmented-button-unselected-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-label-text-color: var(--md-segmented-button-unselected-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-hover-state-layer-color: var(--md-segmented-button-unselected-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-label-text-color: var(--md-segmented-button-unselected-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-icon-color: var(--md-segmented-button-unselected-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-label-text-color: var(--md-segmented-button-unselected-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-pressed-state-layer-color: var(--md-segmented-button-unselected-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_unselected-with-icon-icon-color: var(--md-segmented-button-unselected-with-icon-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_with-icon-icon-size: var(--md-segmented-button-with-icon-icon-size, 18px);--_spacing-leading: var(--md-segmented-button-spacing-leading, 12px);--_spacing-trailing: var(--md-segmented-button-spacing-trailing, 12px)}.md3-segmented-button__outline{border-radius:inherit;border-style:solid;border-width:1px;inset:0px -0.5px;pointer-events:none;position:absolute}/*# sourceMappingURL=outlined-styles.css.map */\n`;\n "]}
|
|
@@ -4,57 +4,51 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import '../../focus/focus-ring.js';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { ActionElement, BeginPressConfig, EndPressConfig } from '../../actionelement/action-element.js';
|
|
7
|
+
import '../../ripple/ripple.js';
|
|
8
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
10
9
|
import { MdRipple } from '../../ripple/ripple.js';
|
|
11
10
|
/**
|
|
12
11
|
* SegmentedButton is a web component implementation of the Material Design
|
|
13
12
|
* segmented button component. It is intended **only** for use as a child of a
|
|
14
13
|
* `SementedButtonSet` component. It is **not** intended for use in any other
|
|
15
14
|
* context.
|
|
16
|
-
* @soyCompatible
|
|
17
15
|
*/
|
|
18
|
-
export declare class SegmentedButton extends
|
|
16
|
+
export declare class SegmentedButton extends LitElement {
|
|
19
17
|
disabled: boolean;
|
|
20
18
|
selected: boolean;
|
|
21
19
|
label: string;
|
|
22
20
|
noCheckmark: boolean;
|
|
23
21
|
hasIcon: boolean;
|
|
24
|
-
/** @soyPrefixAttribute */
|
|
25
|
-
ariaLabel: string;
|
|
26
22
|
protected animState: string;
|
|
27
23
|
protected showFocusRing: boolean;
|
|
24
|
+
protected showRipple: boolean;
|
|
28
25
|
protected iconElement: HTMLElement[];
|
|
29
|
-
ripple: MdRipple
|
|
26
|
+
protected ripple: Promise<MdRipple | null>;
|
|
30
27
|
protected update(props: PropertyValues<SegmentedButton>): void;
|
|
31
28
|
private nextAnimationState;
|
|
32
|
-
|
|
33
|
-
endPress(options: EndPressConfig): void;
|
|
29
|
+
handleClick(e: MouseEvent): void;
|
|
34
30
|
handlePointerDown(e: PointerEvent): void;
|
|
35
|
-
handlePointerUp(e: PointerEvent): void;
|
|
36
|
-
protected handlePointerEnter(e: PointerEvent): void;
|
|
37
|
-
handlePointerLeave(e: PointerEvent): void;
|
|
38
31
|
protected handleFocus(): void;
|
|
39
32
|
protected handleBlur(): void;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
protected
|
|
54
|
-
|
|
55
|
-
protected
|
|
56
|
-
|
|
57
|
-
protected
|
|
58
|
-
|
|
59
|
-
protected
|
|
33
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
34
|
+
protected getRenderClasses(): {
|
|
35
|
+
'md3-segmented-button--selected': boolean;
|
|
36
|
+
'md3-segmented-button--unselected': boolean;
|
|
37
|
+
'md3-segmented-button--with-label': boolean;
|
|
38
|
+
'md3-segmented-button--without-label': boolean;
|
|
39
|
+
'md3-segmented-button--with-icon': boolean;
|
|
40
|
+
'md3-segmented-button--with-checkmark': boolean;
|
|
41
|
+
'md3-segmented-button--without-checkmark': boolean;
|
|
42
|
+
'md3-segmented-button--selecting': boolean;
|
|
43
|
+
'md3-segmented-button--deselecting': boolean;
|
|
44
|
+
};
|
|
45
|
+
protected renderFocusRing(): import("lit-html").TemplateResult<1>;
|
|
46
|
+
protected readonly getRipple: () => Promise<MdRipple>;
|
|
47
|
+
protected renderRipple: () => import("lit-html").TemplateResult<1>;
|
|
48
|
+
protected renderOutline(): import("lit-html").TemplateResult<1>;
|
|
49
|
+
protected renderLeading(): import("lit-html").TemplateResult<1>;
|
|
50
|
+
protected renderLeadingWithoutLabel(): import("lit-html").TemplateResult<1>;
|
|
51
|
+
protected renderLeadingWithLabel(): import("lit-html").TemplateResult<1>;
|
|
52
|
+
protected renderLabel(): import("lit-html").TemplateResult<1>;
|
|
53
|
+
protected renderTouchTarget(): import("lit-html").TemplateResult<1>;
|
|
60
54
|
}
|
|
@@ -3,24 +3,24 @@
|
|
|
3
3
|
* Copyright 2021 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
var _a;
|
|
7
|
+
import { __decorate } from "tslib";
|
|
7
8
|
import '../../focus/focus-ring.js';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
9
|
+
import '../../ripple/ripple.js';
|
|
10
|
+
import { html, LitElement, nothing } from 'lit';
|
|
11
|
+
import { property, queryAssignedElements, queryAsync, state } from 'lit/decorators.js';
|
|
10
12
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { ariaProperty } from '../../decorators/aria-property.js';
|
|
13
|
+
import { when } from 'lit/directives/when.js';
|
|
14
|
+
import { requestUpdateOnAriaChange } from '../../aria/delegate.js';
|
|
14
15
|
import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
|
|
15
|
-
import {
|
|
16
|
+
import { ripple } from '../../ripple/directive.js';
|
|
16
17
|
/**
|
|
17
18
|
* SegmentedButton is a web component implementation of the Material Design
|
|
18
19
|
* segmented button component. It is intended **only** for use as a child of a
|
|
19
20
|
* `SementedButtonSet` component. It is **not** intended for use in any other
|
|
20
21
|
* context.
|
|
21
|
-
* @soyCompatible
|
|
22
22
|
*/
|
|
23
|
-
export class SegmentedButton extends
|
|
23
|
+
export class SegmentedButton extends LitElement {
|
|
24
24
|
constructor() {
|
|
25
25
|
super(...arguments);
|
|
26
26
|
this.disabled = false;
|
|
@@ -30,6 +30,14 @@ export class SegmentedButton extends ActionElement {
|
|
|
30
30
|
this.hasIcon = false;
|
|
31
31
|
this.animState = '';
|
|
32
32
|
this.showFocusRing = false;
|
|
33
|
+
this.showRipple = false;
|
|
34
|
+
this.getRipple = () => {
|
|
35
|
+
this.showRipple = true;
|
|
36
|
+
return this.ripple;
|
|
37
|
+
};
|
|
38
|
+
this.renderRipple = () => {
|
|
39
|
+
return html `<md-ripple ?disabled="${this.disabled}" class="md3-segmented-button__ripple"> </md-ripple>`;
|
|
40
|
+
};
|
|
33
41
|
}
|
|
34
42
|
update(props) {
|
|
35
43
|
this.animState = this.nextAnimationState(props);
|
|
@@ -53,58 +61,37 @@ export class SegmentedButton extends ActionElement {
|
|
|
53
61
|
}
|
|
54
62
|
return '';
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
endPress(options) {
|
|
60
|
-
// TODO(b/261201805): connect to ripple
|
|
61
|
-
super.endPress(options);
|
|
62
|
-
if (!options.cancelled) {
|
|
63
|
-
const event = new Event('segmented-button-interaction', { bubbles: true, composed: true });
|
|
64
|
-
this.dispatchEvent(event);
|
|
65
|
-
}
|
|
64
|
+
handleClick(e) {
|
|
65
|
+
const event = new Event('segmented-button-interaction', { bubbles: true, composed: true });
|
|
66
|
+
this.dispatchEvent(event);
|
|
66
67
|
}
|
|
67
68
|
handlePointerDown(e) {
|
|
68
|
-
super.handlePointerDown(e);
|
|
69
69
|
pointerPress();
|
|
70
70
|
this.showFocusRing = shouldShowStrongFocus();
|
|
71
71
|
}
|
|
72
|
-
handlePointerUp(e) {
|
|
73
|
-
super.handlePointerUp(e);
|
|
74
|
-
}
|
|
75
|
-
handlePointerEnter(e) {
|
|
76
|
-
this.ripple.handlePointerenter(e);
|
|
77
|
-
}
|
|
78
|
-
handlePointerLeave(e) {
|
|
79
|
-
super.handlePointerLeave(e);
|
|
80
|
-
this.ripple.handlePointerleave(e);
|
|
81
|
-
}
|
|
82
72
|
handleFocus() {
|
|
83
73
|
this.showFocusRing = shouldShowStrongFocus();
|
|
84
74
|
}
|
|
85
75
|
handleBlur() {
|
|
86
76
|
this.showFocusRing = false;
|
|
87
77
|
}
|
|
88
|
-
/** @soyTemplate */
|
|
89
78
|
render() {
|
|
79
|
+
// Needed for closure conformance
|
|
80
|
+
const { ariaLabel } = this;
|
|
90
81
|
return html `
|
|
91
82
|
<button
|
|
92
83
|
tabindex="${this.disabled ? '-1' : '0'}"
|
|
93
|
-
aria-label
|
|
84
|
+
aria-label=${ariaLabel || nothing}
|
|
94
85
|
aria-pressed=${this.selected}
|
|
95
86
|
?disabled=${this.disabled}
|
|
96
87
|
@focus="${this.handleFocus}"
|
|
97
88
|
@blur="${this.handleBlur}"
|
|
98
89
|
@pointerdown="${this.handlePointerDown}"
|
|
99
|
-
@pointerup="${this.handlePointerUp}"
|
|
100
|
-
@pointercancel="${this.handlePointerCancel}"
|
|
101
|
-
@pointerleave="${this.handlePointerLeave}"
|
|
102
|
-
@pointerenter="${this.handlePointerEnter}"
|
|
103
90
|
@click="${this.handleClick}"
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
class="md3-segmented-button ${classMap(this.getRenderClasses())}"
|
|
92
|
+
${ripple(this.getRipple)}>
|
|
106
93
|
${this.renderFocusRing()}
|
|
107
|
-
${this.renderRipple
|
|
94
|
+
${when(this.showRipple, this.renderRipple)}
|
|
108
95
|
${this.renderOutline()}
|
|
109
96
|
${this.renderLeading()}
|
|
110
97
|
${this.renderLabel()}
|
|
@@ -112,7 +99,6 @@ export class SegmentedButton extends ActionElement {
|
|
|
112
99
|
</button>
|
|
113
100
|
`;
|
|
114
101
|
}
|
|
115
|
-
/** @soyTemplate */
|
|
116
102
|
getRenderClasses() {
|
|
117
103
|
return {
|
|
118
104
|
'md3-segmented-button--selected': this.selected,
|
|
@@ -126,24 +112,16 @@ export class SegmentedButton extends ActionElement {
|
|
|
126
112
|
'md3-segmented-button--deselecting': this.animState === 'deselecting',
|
|
127
113
|
};
|
|
128
114
|
}
|
|
129
|
-
/** @soyTemplate */
|
|
130
115
|
renderFocusRing() {
|
|
131
116
|
return html `<md-focus-ring .visible="${this.showFocusRing}" class="md3-segmented-button__focus-ring"></md-focus-ring>`;
|
|
132
117
|
}
|
|
133
|
-
/** @soyTemplate */
|
|
134
|
-
renderRipple() {
|
|
135
|
-
return html `<md-ripple ?disabled="${this.disabled}" class="md3-segmented-button__ripple"> </md-ripple>`;
|
|
136
|
-
}
|
|
137
|
-
/** @soyTemplate */
|
|
138
118
|
renderOutline() {
|
|
139
119
|
return html ``;
|
|
140
120
|
}
|
|
141
|
-
/** @soyTemplate */
|
|
142
121
|
renderLeading() {
|
|
143
122
|
return this.label === '' ? this.renderLeadingWithoutLabel() :
|
|
144
123
|
this.renderLeadingWithLabel();
|
|
145
124
|
}
|
|
146
|
-
/** @soyTemplate */
|
|
147
125
|
renderLeadingWithoutLabel() {
|
|
148
126
|
return html `
|
|
149
127
|
<span class="md3-segmented-button__leading" aria-hidden="true">
|
|
@@ -158,7 +136,6 @@ export class SegmentedButton extends ActionElement {
|
|
|
158
136
|
</span>
|
|
159
137
|
`;
|
|
160
138
|
}
|
|
161
|
-
/** @soyTemplate */
|
|
162
139
|
renderLeadingWithLabel() {
|
|
163
140
|
return html `
|
|
164
141
|
<span class="md3-segmented-button__leading" aria-hidden="true">
|
|
@@ -173,57 +150,47 @@ export class SegmentedButton extends ActionElement {
|
|
|
173
150
|
</span>
|
|
174
151
|
`;
|
|
175
152
|
}
|
|
176
|
-
/** @soyTemplate */
|
|
177
153
|
renderLabel() {
|
|
178
154
|
return html `
|
|
179
155
|
<span class="md3-segmented-button__label-text">${this.label}</span>
|
|
180
156
|
`;
|
|
181
157
|
}
|
|
182
|
-
/** @soyTemplate */
|
|
183
158
|
renderTouchTarget() {
|
|
184
159
|
return html `<span class="md3-segmented-button__touch"></span>`;
|
|
185
160
|
}
|
|
186
161
|
}
|
|
162
|
+
_a = SegmentedButton;
|
|
163
|
+
(() => {
|
|
164
|
+
requestUpdateOnAriaChange(_a);
|
|
165
|
+
})();
|
|
187
166
|
__decorate([
|
|
188
|
-
property({ type: Boolean })
|
|
189
|
-
__metadata("design:type", Object)
|
|
167
|
+
property({ type: Boolean })
|
|
190
168
|
], SegmentedButton.prototype, "disabled", void 0);
|
|
191
169
|
__decorate([
|
|
192
|
-
property({ type: Boolean })
|
|
193
|
-
__metadata("design:type", Object)
|
|
170
|
+
property({ type: Boolean })
|
|
194
171
|
], SegmentedButton.prototype, "selected", void 0);
|
|
195
172
|
__decorate([
|
|
196
|
-
property(
|
|
197
|
-
__metadata("design:type", Object)
|
|
173
|
+
property()
|
|
198
174
|
], SegmentedButton.prototype, "label", void 0);
|
|
199
175
|
__decorate([
|
|
200
|
-
property({ type: Boolean })
|
|
201
|
-
__metadata("design:type", Object)
|
|
176
|
+
property({ type: Boolean })
|
|
202
177
|
], SegmentedButton.prototype, "noCheckmark", void 0);
|
|
203
178
|
__decorate([
|
|
204
|
-
property({ type: Boolean })
|
|
205
|
-
__metadata("design:type", Object)
|
|
179
|
+
property({ type: Boolean })
|
|
206
180
|
], SegmentedButton.prototype, "hasIcon", void 0);
|
|
207
181
|
__decorate([
|
|
208
|
-
|
|
209
|
-
,
|
|
210
|
-
property({ type: String, attribute: 'aria-label' }),
|
|
211
|
-
__metadata("design:type", String)
|
|
212
|
-
], SegmentedButton.prototype, "ariaLabel", void 0);
|
|
213
|
-
__decorate([
|
|
214
|
-
state(),
|
|
215
|
-
__metadata("design:type", String)
|
|
182
|
+
state()
|
|
216
183
|
], SegmentedButton.prototype, "animState", void 0);
|
|
217
184
|
__decorate([
|
|
218
|
-
state()
|
|
219
|
-
__metadata("design:type", Object)
|
|
185
|
+
state()
|
|
220
186
|
], SegmentedButton.prototype, "showFocusRing", void 0);
|
|
221
187
|
__decorate([
|
|
222
|
-
|
|
223
|
-
|
|
188
|
+
state()
|
|
189
|
+
], SegmentedButton.prototype, "showRipple", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
queryAssignedElements({ slot: 'icon', flatten: true })
|
|
224
192
|
], SegmentedButton.prototype, "iconElement", void 0);
|
|
225
193
|
__decorate([
|
|
226
|
-
|
|
227
|
-
__metadata("design:type", MdRipple)
|
|
194
|
+
queryAsync('md-ripple')
|
|
228
195
|
], SegmentedButton.prototype, "ripple", void 0);
|
|
229
196
|
//# sourceMappingURL=segmented-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-button.js","sourceRoot":"","sources":["segmented-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,2BAA2B,CAAC;AAEnC,OAAO,EAAC,IAAI,EAAiC,MAAM,KAAK,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAC,aAAa,EAAmC,MAAM,uCAAuC,CAAC;AACtG,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAAlD;;QAC6B,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QAClB,UAAK,GAAG,EAAE,CAAC;QACV,gBAAW,GAAG,KAAK,CAAC;QACpB,YAAO,GAAG,KAAK,CAAC;QAOxB,c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QACnB,OAAO,IAAI,CAAA;uDACwC,IAAI,CAAC,KAAK;KAC5D,CAAC;IACJ,CAAC;IAED,mBAAmB;IACT,iBAAiB;QACzB,OAAO,IAAI,CAAA,mDAAmD,CAAC;IACjE,CAAC;CACF;AAhMC;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;iDAAkB;AAC5C;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;iDAAkB;AAC5C;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;8CAAY;AACrC;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;oDAAqB;AAC/C;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;gDAAiB;AAG3C;IAAC,YAAY,CAAE,wCAAwC;;IACtD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAC,CAAC;;kDACtB;AAE5B;IAAC,KAAK,EAAE;;kDAAkC;AAC1C;IAAC,KAAK,EAAE;;sDAAiC;AACzC;IAAC,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;oDACf;AACtC;IAAC,KAAK,CAAC,WAAW,CAAC;8BAAU,QAAQ;+CAAC","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/focus-ring.js';\n\nimport {html, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, queryAssignedElements, state} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {ActionElement, BeginPressConfig, EndPressConfig} from '../../actionelement/action-element.js';\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';\nimport {MdRipple} from '../../ripple/ripple.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 * @soyCompatible\n */\nexport class SegmentedButton extends ActionElement {\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean}) selected = false;\n @property({type: String}) label = '';\n @property({type: Boolean}) noCheckmark = false;\n @property({type: Boolean}) hasIcon = false;\n\n /** @soyPrefixAttribute */\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property({type: String, attribute: 'aria-label'})\n override ariaLabel!: string;\n\n @state() protected animState: string = '';\n @state() protected showFocusRing = false;\n @queryAssignedElements({slot: 'icon', flatten: true})\n protected iconElement!: HTMLElement[];\n @query('md-ripple') ripple!: MdRipple;\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(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 override beginPress({positionEvent}: BeginPressConfig) {\n // TODO(b/261201805): connect to ripple\n }\n\n override endPress(options: EndPressConfig) {\n // TODO(b/261201805): connect to ripple\n super.endPress(options);\n if (!options.cancelled) {\n const event = new Event(\n 'segmented-button-interaction', {bubbles: true, composed: true});\n this.dispatchEvent(event);\n }\n }\n\n override handlePointerDown(e: PointerEvent) {\n super.handlePointerDown(e);\n pointerPress();\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n override handlePointerUp(e: PointerEvent) {\n super.handlePointerUp(e);\n }\n\n protected handlePointerEnter(e: PointerEvent) {\n this.ripple.handlePointerenter(e);\n }\n\n override handlePointerLeave(e: PointerEvent) {\n super.handlePointerLeave(e);\n this.ripple.handlePointerleave(e);\n }\n\n protected handleFocus() {\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected handleBlur() {\n this.showFocusRing = false;\n }\n\n /** @soyTemplate */\n override render(): TemplateResult {\n return html`\n <button\n tabindex=\"${this.disabled ? '-1' : '0'}\"\n aria-label=\"${ifDefined(this.ariaLabel)}\"\n aria-pressed=${this.selected}\n ?disabled=${this.disabled}\n @focus=\"${this.handleFocus}\"\n @blur=\"${this.handleBlur}\"\n @pointerdown=\"${this.handlePointerDown}\"\n @pointerup=\"${this.handlePointerUp}\"\n @pointercancel=\"${this.handlePointerCancel}\"\n @pointerleave=\"${this.handlePointerLeave}\"\n @pointerenter=\"${this.handlePointerEnter}\"\n @click=\"${this.handleClick}\"\n @contextmenu=\"${this.handleContextMenu}\"\n class=\"md3-segmented-button ${classMap(this.getRenderClasses())}\">\n ${this.renderFocusRing()}\n ${this.renderRipple()}\n ${this.renderOutline()}\n ${this.renderLeading()}\n ${this.renderLabel()}\n ${this.renderTouchTarget()}\n </button>\n `;\n }\n\n /** @soyTemplate */\n protected getRenderClasses(): ClassInfo {\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 /** @soyTemplate */\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring .visible=\"${\n this.showFocusRing}\" class=\"md3-segmented-button__focus-ring\"></md-focus-ring>`;\n }\n\n /** @soyTemplate */\n protected renderRipple(): TemplateResult|string {\n return html`<md-ripple ?disabled=\"${\n this.disabled}\" class=\"md3-segmented-button__ripple\"> </md-ripple>`;\n }\n\n /** @soyTemplate */\n protected renderOutline(): TemplateResult {\n return html``;\n }\n\n /** @soyTemplate */\n protected renderLeading(): TemplateResult {\n return this.label === '' ? this.renderLeadingWithoutLabel() :\n this.renderLeadingWithLabel();\n }\n\n /** @soyTemplate */\n protected renderLeadingWithoutLabel(): TemplateResult {\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 class=\"md3-segmented-button__checkmark-path\" fill=\"none\" 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 /** @soyTemplate */\n protected renderLeadingWithLabel(): TemplateResult {\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 class=\"md3-segmented-button__checkmark-path\" fill=\"none\" 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 /** @soyTemplate */\n protected renderLabel(): TemplateResult {\n return html`\n <span class=\"md3-segmented-button__label-text\">${this.label}</span>\n `;\n }\n\n /** @soyTemplate */\n protected renderTouchTarget(): TemplateResult {\n return html`<span class=\"md3-segmented-button__touch\"></span>`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"segmented-button.js","sourceRoot":"","sources":["segmented-button.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;AAEH,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB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ES,yBAAyB;QACjC,OAAO,IAAI,CAAA;;;;;;;;;;;KAWV,CAAC;IACJ,CAAC;IAES,sBAAsB;QAC9B,OAAO,IAAI,CAAA;;;;;;;;;;;KAWV,CAAC;IACJ,CAAC;IAES,WAAW;QACnB,OAAO,IAAI,CAAA;uDACwC,IAAI,CAAC,KAAK;KAC5D,CAAC;IACJ,CAAC;IAES,iBAAiB;QACzB,OAAO,IAAI,CAAA,mDAAmD,CAAC;IACjE,CAAC;CACF;;AAnKC;IACE,yBAAyB,CAAC,EAAI,CAAC,CAAC;AAClC,CAAC,GAAA,CAAA;AAE0B;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;iDAAkB;AACjB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;iDAAkB;AAChC;IAAX,QAAQ,EAAE;8CAAY;AACI;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;oDAAqB;AACpB;IAA1B,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;gDAAiB;AAElC;IAAR,KAAK,EAAE;kDAA0B;AACzB;IAAR,KAAK,EAAE;sDAAiC;AAChC;IAAR,KAAK,EAAE;mDAA8B;AAEtC;IADC,qBAAqB,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;oDACf;AACb;IAAxB,UAAU,CAAC,WAAW,CAAC;+CAA2C","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../focus/focus-ring.js';\nimport '../../ripple/ripple.js';\n\nimport {html, LitElement, nothing, PropertyValues} from 'lit';\nimport {property, queryAssignedElements, queryAsync, state} from 'lit/decorators.js';\nimport {classMap} from 'lit/directives/class-map.js';\nimport {when} from 'lit/directives/when.js';\n\nimport {requestUpdateOnAriaChange} from '../../aria/delegate.js';\nimport {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';\nimport {ripple} from '../../ripple/directive.js';\nimport {MdRipple} from '../../ripple/ripple.js';\nimport {ARIAMixinStrict} from '../../types/aria.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 */\nexport class SegmentedButton extends LitElement {\n static {\n requestUpdateOnAriaChange(this);\n }\n\n @property({type: Boolean}) disabled = false;\n @property({type: Boolean}) selected = false;\n @property() label = '';\n @property({type: Boolean}) noCheckmark = false;\n @property({type: Boolean}) hasIcon = false;\n\n @state() protected animState = '';\n @state() protected showFocusRing = false;\n @state() protected showRipple = false;\n @queryAssignedElements({slot: 'icon', flatten: true})\n protected iconElement!: HTMLElement[];\n @queryAsync('md-ripple') protected ripple!: Promise<MdRipple|null>;\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(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 handleClick(e: MouseEvent) {\n const event = new Event(\n 'segmented-button-interaction', {bubbles: true, composed: true});\n this.dispatchEvent(event);\n }\n\n handlePointerDown(e: PointerEvent) {\n pointerPress();\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected handleFocus() {\n this.showFocusRing = shouldShowStrongFocus();\n }\n\n protected handleBlur() {\n this.showFocusRing = false;\n }\n\n 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 @focus=\"${this.handleFocus}\"\n @blur=\"${this.handleBlur}\"\n @pointerdown=\"${this.handlePointerDown}\"\n @click=\"${this.handleClick}\"\n class=\"md3-segmented-button ${classMap(this.getRenderClasses())}\"\n ${ripple(this.getRipple)}>\n ${this.renderFocusRing()}\n ${when(this.showRipple, this.renderRipple)}\n ${this.renderOutline()}\n ${this.renderLeading()}\n ${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 renderFocusRing() {\n return html`<md-focus-ring .visible=\"${\n this.showFocusRing}\" class=\"md3-segmented-button__focus-ring\"></md-focus-ring>`;\n }\n\n protected readonly getRipple = () => {\n this.showRipple = true;\n return this.ripple;\n };\n\n protected renderRipple = () => {\n return html`<md-ripple ?disabled=\"${\n this.disabled}\" class=\"md3-segmented-button__ripple\"> </md-ripple>`;\n };\n\n protected renderOutline() {\n return html``;\n }\n\n protected renderLeading() {\n return this.label === '' ? this.renderLeadingWithoutLabel() :\n this.renderLeadingWithLabel();\n }\n\n protected 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 class=\"md3-segmented-button__checkmark-path\" fill=\"none\" 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 protected 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 class=\"md3-segmented-button__checkmark-path\" fill=\"none\" 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 protected renderLabel() {\n return html`\n <span class=\"md3-segmented-button__label-text\">${this.label}</span>\n `;\n }\n\n protected renderTouchTarget() {\n return html`<span class=\"md3-segmented-button__touch\"></span>`;\n }\n}\n"]}
|