@material/web 1.0.0-pre.1 → 1.0.0-pre.2
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 +66 -19
- package/autocomplete/lib/_filled-autocomplete.scss +1 -34
- package/autocomplete/lib/_outlined-autocomplete.scss +1 -34
- package/autocomplete/lib/autocomplete.d.ts +0 -4
- package/autocomplete/lib/autocomplete.js +5 -12
- package/autocomplete/lib/autocomplete.js.map +1 -1
- package/autocomplete/lib/autocompleteitem/autocomplete-item.d.ts +2 -2
- package/autocomplete/lib/autocompleteitem/autocomplete-item.js +2 -2
- package/autocomplete/lib/autocompleteitem/autocomplete-item.js.map +1 -1
- package/autocomplete/lib/autocompletelist/autocomplete-list.d.ts +1 -1
- package/autocomplete/lib/autocompletelist/autocomplete-list.js +2 -2
- package/autocomplete/lib/autocompletelist/autocomplete-list.js.map +1 -1
- package/autocomplete/lib/filled-styles.css.js +1 -1
- package/autocomplete/lib/filled-styles.css.js.map +1 -1
- package/autocomplete/lib/outlined-styles.css.js +1 -1
- package/autocomplete/lib/outlined-styles.css.js.map +1 -1
- package/button/lib/_elevation.scss +1 -1
- package/button/lib/_icon.scss +14 -24
- package/button/lib/_shared.scss +1 -0
- package/button/lib/button.d.ts +0 -3
- package/button/lib/button.js +1 -12
- package/button/lib/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/link-button.d.ts +0 -1
- package/button/lib/link-button.js +0 -5
- package/button/lib/link-button.js.map +1 -1
- package/button/lib/shared-elevation-styles.css.js +1 -1
- package/button/lib/shared-elevation-styles.css.js.map +1 -1
- package/button/lib/shared-styles.css.js +1 -1
- package/button/lib/shared-styles.css.js.map +1 -1
- package/checkbox/checkbox.d.ts +11 -2
- package/checkbox/checkbox.js +11 -2
- package/checkbox/checkbox.js.map +1 -1
- package/checkbox/lib/checkbox.d.ts +28 -0
- package/checkbox/lib/checkbox.js +30 -1
- package/checkbox/lib/checkbox.js.map +1 -1
- package/chips/chip/lib/_chip-theme.scss +1 -1
- package/dialog/_dialog.scss +6 -0
- package/dialog/dialog.d.ts +38 -0
- package/dialog/dialog.js +41 -0
- package/dialog/dialog.js.map +1 -0
- package/dialog/harness.d.ts +18 -0
- package/dialog/harness.js +55 -0
- package/dialog/harness.js.map +1 -0
- package/dialog/lib/_dialog.scss +386 -0
- package/dialog/lib/_tokens.scss +86 -0
- package/{list/lib/divider/list-divider-styles.css.d.ts → dialog/lib/dialog-styles.css.d.ts} +0 -0
- package/dialog/lib/dialog-styles.css.js +9 -0
- package/dialog/lib/dialog-styles.css.js.map +1 -0
- package/dialog/lib/dialog-styles.scss +8 -0
- package/dialog/lib/dialog.d.ts +190 -0
- package/dialog/lib/dialog.js +566 -0
- package/dialog/lib/dialog.js.map +1 -0
- package/divider/_divider.scss +6 -0
- package/divider/divider.d.ts +24 -0
- package/divider/divider.js +27 -0
- package/divider/divider.js.map +1 -0
- package/divider/lib/_divider.scss +54 -0
- package/{menu/lib/menu-button-styles.css.d.ts → divider/lib/divider-styles.css.d.ts} +0 -0
- package/divider/lib/divider-styles.css.js +9 -0
- package/divider/lib/divider-styles.css.js.map +1 -0
- package/divider/lib/divider-styles.scss +8 -0
- package/divider/lib/divider.d.ts +23 -0
- package/divider/lib/divider.js +41 -0
- package/divider/lib/divider.js.map +1 -0
- package/elevation/lib/_elevation.scss +1 -1
- package/elevation/lib/_md-comp-elevation.scss +1 -1
- package/elevation/lib/elevation-styles.css.js +1 -1
- package/elevation/lib/elevation-styles.css.js.map +1 -1
- package/fab/lib/_shared.scss +1 -1
- package/fab/lib/fab-shared-styles.css.js +1 -1
- package/fab/lib/fab-shared-styles.css.js.map +1 -1
- package/field/lib/_filled-field.scss +5 -2
- package/field/lib/_md-comp-filled-field.scss +3 -1
- package/field/lib/_md-comp-outlined-field.scss +1 -1
- package/field/lib/_shared.scss +2 -0
- package/field/lib/field.d.ts +0 -2
- package/field/lib/field.js +2 -4
- 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/field/lib/shared-styles.css.js +1 -1
- package/field/lib/shared-styles.css.js.map +1 -1
- package/focus/lib/_focus-ring.scss +3 -10
- package/focus/lib/focus-ring-styles.css.js +1 -1
- package/focus/lib/focus-ring-styles.css.js.map +1 -1
- package/focus/lib/focus-ring.d.ts +1 -4
- package/focus/lib/focus-ring.js +2 -11
- package/focus/lib/focus-ring.js.map +1 -1
- package/iconbutton/lib/_filled-icon-button.scss +1 -1
- package/iconbutton/lib/_filled-tonal-icon-button.scss +1 -1
- package/iconbutton/lib/_outlined-icon-button.scss +7 -5
- package/iconbutton/lib/_shared.scss +5 -25
- package/iconbutton/lib/_standard-icon-button.scss +4 -6
- 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-toggle.d.ts +13 -42
- package/iconbutton/lib/icon-button-toggle.js +33 -103
- package/iconbutton/lib/icon-button-toggle.js.map +1 -1
- package/iconbutton/lib/icon-button.d.ts +2 -4
- package/iconbutton/lib/icon-button.js +3 -9
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/iconbutton/lib/outlined-styles.css.js +1 -1
- package/iconbutton/lib/outlined-styles.css.js.map +1 -1
- package/iconbutton/lib/shared-styles.css.js +1 -1
- package/iconbutton/lib/shared-styles.css.js.map +1 -1
- package/iconbutton/lib/standard-styles.css.js +1 -1
- package/iconbutton/lib/standard-styles.css.js.map +1 -1
- package/list/lib/_list.scss +32 -40
- package/list/lib/avatar/_list-item-avatar.scss +1 -1
- package/list/lib/avatar/list-item-avatar-styles.css.js +1 -1
- package/list/lib/avatar/list-item-avatar-styles.css.js.map +1 -1
- package/list/lib/avatar/list-item-avatar.d.ts +9 -4
- package/list/lib/avatar/list-item-avatar.js +24 -11
- package/list/lib/avatar/list-item-avatar.js.map +1 -1
- package/list/lib/icon/_list-item-icon.scss +3 -1
- package/list/lib/icon/list-item-icon-styles.css.js +1 -1
- package/list/lib/icon/list-item-icon-styles.css.js.map +1 -1
- package/list/lib/icon/list-item-icon.d.ts +0 -3
- package/list/lib/icon/list-item-icon.js +1 -12
- package/list/lib/icon/list-item-icon.js.map +1 -1
- package/list/lib/image/_list-item-image.scss +1 -1
- package/list/lib/image/list-item-image-styles.css.js +1 -1
- package/list/lib/image/list-item-image-styles.css.js.map +1 -1
- package/list/lib/image/list-item-image.d.ts +11 -4
- package/list/lib/image/list-item-image.js +24 -13
- package/list/lib/image/list-item-image.js.map +1 -1
- 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 +99 -28
- package/list/lib/list.js +210 -111
- package/list/lib/list.js.map +1 -1
- package/list/lib/listitem/_list-item.scss +104 -39
- package/list/lib/listitem/harness.js +2 -1
- package/list/lib/listitem/harness.js.map +1 -1
- package/{tokens/v0_150/index.test.css.d.ts → list/lib/listitem/list-item-private-styles.css.d.ts} +0 -0
- package/list/lib/listitem/list-item-private-styles.css.js +9 -0
- package/list/lib/listitem/list-item-private-styles.css.js.map +1 -0
- package/list/lib/listitem/list-item-private-styles.scss +8 -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 +99 -43
- package/list/lib/listitem/list-item.js +201 -172
- package/list/lib/listitem/list-item.js.map +1 -1
- package/list/lib/listitemlink/list-item-link.d.ts +17 -0
- package/list/lib/listitemlink/list-item-link.js +42 -0
- package/list/lib/listitemlink/list-item-link.js.map +1 -0
- package/list/lib/video/_list-item-video.scss +10 -4
- package/list/lib/video/list-item-video-styles.css.js +1 -1
- package/list/lib/video/list-item-video-styles.css.js.map +1 -1
- package/list/lib/video/list-item-video.d.ts +43 -4
- package/list/lib/video/list-item-video.js +90 -12
- package/list/lib/video/list-item-video.js.map +1 -1
- package/list/list-item-avatar.d.ts +2 -1
- package/list/list-item-avatar.js +2 -1
- package/list/list-item-avatar.js.map +1 -1
- package/list/list-item-icon.d.ts +2 -1
- package/list/list-item-icon.js +2 -1
- package/list/list-item-icon.js.map +1 -1
- package/list/list-item-image.d.ts +2 -1
- package/list/list-item-image.js +2 -1
- package/list/list-item-image.js.map +1 -1
- package/list/list-item-link.d.ts +35 -0
- package/list/list-item-link.js +39 -0
- package/list/list-item-link.js.map +1 -0
- package/list/list-item-video.d.ts +2 -1
- package/list/list-item-video.js +2 -1
- package/list/list-item-video.js.map +1 -1
- package/list/list-item.d.ts +18 -2
- package/list/list-item.js +20 -3
- package/list/list-item.js.map +1 -1
- package/list/list.d.ts +15 -1
- package/list/list.js +15 -1
- package/list/list.js.map +1 -1
- package/menu/_menu-item.scss +6 -0
- package/menu/_menu.scss +6 -0
- package/menu/harness.d.ts +5 -0
- package/menu/harness.js +22 -0
- package/menu/harness.js.map +1 -1
- package/menu/lib/_menu.scss +61 -62
- 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 +176 -42
- package/menu/lib/menu.js +506 -246
- package/menu/lib/menu.js.map +1 -1
- package/menu/lib/menuitem/_menu-item.scss +115 -0
- package/{tokens/v0_150/lib.test.css.d.ts → menu/lib/menuitem/menu-item-private-styles.css.d.ts} +0 -0
- package/menu/lib/menuitem/menu-item-private-styles.css.js +9 -0
- package/menu/lib/menuitem/menu-item-private-styles.css.js.map +1 -0
- package/menu/lib/menuitem/menu-item-private-styles.scss +8 -0
- package/menu/lib/menuitem/menu-item-styles.css.d.ts +1 -0
- package/menu/lib/menuitem/menu-item-styles.css.js +9 -0
- package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -0
- package/menu/lib/menuitem/menu-item-styles.scss +8 -0
- package/menu/lib/menuitem/menu-item.d.ts +20 -3
- package/menu/lib/menuitem/menu-item.js +42 -3
- package/menu/lib/menuitem/menu-item.js.map +1 -1
- package/menu/lib/menuitemlink/menu-item-link.d.ts +25 -0
- package/menu/lib/menuitemlink/menu-item-link.js +51 -0
- package/menu/lib/menuitemlink/menu-item-link.js.map +1 -0
- package/menu/lib/shared.d.ts +134 -0
- package/menu/lib/shared.js +85 -0
- package/menu/lib/shared.js.map +1 -0
- package/menu/lib/submenuitem/harness.d.ts +11 -0
- package/menu/lib/submenuitem/harness.js +12 -0
- package/menu/lib/submenuitem/harness.js.map +1 -0
- package/menu/lib/submenuitem/sub-menu-item.d.ts +89 -0
- package/menu/lib/submenuitem/sub-menu-item.js +266 -0
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -0
- package/menu/lib/surfacePositionController.d.ts +117 -0
- package/menu/lib/surfacePositionController.js +196 -0
- package/menu/lib/surfacePositionController.js.map +1 -0
- package/menu/lib/typeaheadController.d.ts +144 -0
- package/menu/lib/typeaheadController.js +242 -0
- package/menu/lib/typeaheadController.js.map +1 -0
- package/menu/menu-item-link.d.ts +33 -0
- package/menu/menu-item-link.js +37 -0
- package/menu/menu-item-link.js.map +1 -0
- package/menu/menu-item.d.ts +19 -2
- package/menu/menu-item.js +22 -4
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.d.ts +45 -0
- package/menu/menu.js +43 -0
- package/menu/menu.js.map +1 -1
- package/menu/sub-menu-item.d.ts +60 -0
- package/menu/sub-menu-item.js +64 -0
- package/menu/sub-menu-item.js.map +1 -0
- package/menusurface/lib/_menu-surface.scss +1 -1
- package/menusurface/lib/menu-surface-styles.css.js +1 -1
- package/menusurface/lib/menu-surface-styles.css.js.map +1 -1
- package/motion/animation.d.ts +20 -3
- package/motion/animation.js +39 -4
- package/motion/animation.js.map +1 -1
- package/navigationbar/lib/_navigation-bar.scss +9 -9
- package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
- package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
- package/navigationdrawer/lib/_navigation-drawer.scss +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
- package/navigationtab/lib/_navigation-tab.scss +8 -19
- package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
- package/package.json +1 -8
- package/radio/lib/_radio.scss +0 -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 +10 -1
- package/radio/lib/radio.js +10 -1
- package/radio/lib/radio.js.map +1 -1
- package/radio/radio.d.ts +16 -1
- package/radio/radio.js +16 -1
- package/radio/radio.js.map +1 -1
- package/ripple/lib/_ripple.scss +5 -21
- package/ripple/lib/ripple-styles.css.js +1 -1
- package/ripple/lib/ripple-styles.css.js.map +1 -1
- package/ripple/lib/ripple.js +2 -2
- package/ripple/lib/ripple.js.map +1 -1
- package/sass/_map-ext.scss +24 -0
- package/sass/_string-ext.scss +23 -0
- package/segmentedbuttonset/lib/segmented-button-set.d.ts +0 -2
- package/segmentedbuttonset/lib/segmented-button-set.js +0 -2
- package/segmentedbuttonset/lib/segmented-button-set.js.map +1 -1
- package/switch/lib/_handle.scss +56 -9
- package/switch/lib/_icon.scss +36 -0
- package/switch/lib/_switch.scss +1 -115
- package/switch/lib/_track.scss +39 -0
- 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 +3 -0
- package/switch/lib/switch.js +3 -0
- package/switch/lib/switch.js.map +1 -1
- package/textfield/lib/_filled-text-field.scss +4 -2
- package/textfield/lib/_outlined-text-field.scss +3 -2
- 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 -2
- package/textfield/lib/text-field.js +0 -2
- package/textfield/lib/text-field.js.map +1 -1
- package/tokens/_index.scss +1 -1
- package/tokens/{v0_150 → v0_152}/_index.scss +1 -1
- package/tokens/{v0_150 → v0_152}/_md-comp-assist-chip.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-badge.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-banner.scss +2 -43
- package/tokens/{v0_150 → v0_152}/_md-comp-bottom-app-bar.scss +3 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-carousel-item.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-checkbox.scss +2 -12
- package/tokens/{v0_150 → v0_152}/_md-comp-circular-progress-indicator.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-data-table.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-date-input-modal.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-docked.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-date-picker-modal.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-dialog.scss +2 -25
- package/tokens/{v0_150 → v0_152}/_md-comp-divider.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-elevated-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-elevated-card.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-branded.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-primary.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-secondary.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-surface.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-extended-fab-tertiary.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded-large.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-branded.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-large.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary-small.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-primary.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-large.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary-small.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-secondary.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-large.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface-small.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-surface.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-large.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary-small.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-fab-tertiary.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-autocomplete.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-button.scss +2 -8
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-card.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-icon-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-menu-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-select.scss +2 -6
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-text-field.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-filled-tonal-icon-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-filter-chip.scss +2 -30
- package/tokens/{v0_150 → v0_152}/_md-comp-full-screen-dialog.scss +3 -53
- package/tokens/{v0_150 → v0_152}/_md-comp-icon-button.scss +3 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-input-chip.scss +2 -52
- package/tokens/{v0_150 → v0_152}/_md-comp-linear-progress-indicator.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-list.scss +3 -12
- package/tokens/{v0_150 → v0_152}/_md-comp-menu.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-navigation-bar.scss +2 -9
- package/tokens/{v0_150 → v0_152}/_md-comp-navigation-drawer.scss +2 -8
- package/tokens/{v0_150 → v0_152}/_md-comp-navigation-rail.scss +2 -39
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-autocomplete.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-button.scss +2 -6
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-card.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-icon-button.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-menu-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-segmented-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-select.scss +2 -6
- package/tokens/{v0_150 → v0_152}/_md-comp-outlined-text-field.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-plain-tooltip.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-primary-navigation-tab.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-radio-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-rich-tooltip.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-scrim.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-search-bar.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-search-view.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-secondary-navigation-tab.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-sheet-bottom.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-sheet-floating.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-sheet-side.scss +4 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-slider.scss +2 -4
- package/tokens/{v0_150 → v0_152}/_md-comp-snackbar.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-standard-menu-button.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-suggestion-chip.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-switch.scss +2 -11
- package/tokens/{v0_150 → v0_152}/_md-comp-text-button.scss +2 -6
- package/tokens/{v0_150 → v0_152}/_md-comp-time-input.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-time-picker.scss +2 -5
- package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-large.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-medium.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small-centered.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-comp-top-app-bar-small.scss +2 -3
- package/tokens/{v0_150 → v0_152}/_md-ref-palette.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-ref-typeface.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-sys-color.scss +2 -20
- package/tokens/{v0_150 → v0_152}/_md-sys-elevation.scss +4 -13
- package/tokens/{v0_150 → v0_152}/_md-sys-motion.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-sys-shape.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-sys-state.scss +2 -2
- package/tokens/{v0_150 → v0_152}/_md-sys-typescale.scss +2 -3
- package/tokens/v0_152/index.test.css.d.ts +1 -0
- package/tokens/{v0_150 → v0_152}/index.test.css.js +0 -0
- package/tokens/{v0_150 → v0_152}/index.test.css.js.map +0 -0
- package/tokens/{v0_150 → v0_152}/index.test.scss +1 -1
- package/tokens/v0_152/lib.test.css.d.ts +1 -0
- package/tokens/{v0_150 → v0_152}/lib.test.css.js +0 -0
- package/tokens/{v0_150 → v0_152}/lib.test.css.js.map +0 -0
- package/tokens/{v0_150 → v0_152}/lib.test.scss +1 -1
- package/list/lib/_tokens.scss +0 -80
- package/list/lib/divider/_list-divider.scss +0 -46
- package/list/lib/divider/list-divider-styles.css.js +0 -9
- package/list/lib/divider/list-divider-styles.css.js.map +0 -1
- package/list/lib/divider/list-divider-styles.scss +0 -8
- package/list/lib/divider/list-divider.d.ts +0 -13
- package/list/lib/divider/list-divider.js +0 -32
- package/list/lib/divider/list-divider.js.map +0 -1
- package/list/list-divider.d.ts +0 -19
- package/list/list-divider.js +0 -22
- package/list/list-divider.js.map +0 -1
- package/menu/lib/_menu-button.scss +0 -14
- package/menu/lib/adapter.d.ts +0 -66
- package/menu/lib/adapter.js +0 -7
- package/menu/lib/adapter.js.map +0 -1
- package/menu/lib/constants.d.ts +0 -22
- package/menu/lib/constants.js +0 -23
- package/menu/lib/constants.js.map +0 -1
- package/menu/lib/foundation.d.ts +0 -49
- package/menu/lib/foundation.js +0 -123
- package/menu/lib/foundation.js.map +0 -1
- package/menu/lib/menu-button-styles.css.js +0 -9
- package/menu/lib/menu-button-styles.css.js.map +0 -1
- package/menu/lib/menu-button-styles.scss +0 -8
- package/menu/lib/menu-button.d.ts +0 -27
- package/menu/lib/menu-button.js +0 -93
- package/menu/lib/menu-button.js.map +0 -1
- package/menu/menu-button.d.ts +0 -14
- package/menu/menu-button.js +0 -17
- package/menu/menu-button.js.map +0 -1
package/menu/lib/menu.js
CHANGED
|
@@ -4,331 +4,591 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate, __metadata } from "tslib";
|
|
7
|
+
// Required for @ariaProperty
|
|
8
|
+
// tslint:disable:no-new-decorators
|
|
7
9
|
import '../../list/list.js';
|
|
8
|
-
import '../../
|
|
10
|
+
import '../../focus/focus-ring.js';
|
|
11
|
+
import '../../elevation/elevation.js';
|
|
9
12
|
import { html, LitElement } from 'lit';
|
|
10
13
|
import { property, query } from 'lit/decorators.js';
|
|
11
|
-
import {
|
|
14
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
15
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
12
16
|
import { ariaProperty } from '../../decorators/aria-property.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
17
|
+
import { MdFocusRing } from '../../focus/focus-ring.js';
|
|
18
|
+
import { pointerPress, shouldShowStrongFocus } from '../../focus/strong-focus.js';
|
|
19
|
+
import { List } from '../../list/lib/list.js';
|
|
20
|
+
import { createAnimationSignal, EASING } from '../../motion/animation.js';
|
|
21
|
+
import { SurfacePositionController } from './surfacePositionController.js';
|
|
22
|
+
import { TypeaheadController } from './typeaheadController.js';
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
24
|
+
* Gets the currently focused element on the page.
|
|
25
|
+
*
|
|
26
|
+
* @param activeDoc The document or shadowroot from which to start the search.
|
|
27
|
+
* Defaults to `window.document`
|
|
28
|
+
* @return Returns the currently deeply focused element or `null` if none.
|
|
29
|
+
*/
|
|
30
|
+
function getFocusedElement(activeDoc = document) {
|
|
31
|
+
const activeEl = activeDoc.activeElement;
|
|
32
|
+
if (!activeEl) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (activeEl.shadowRoot) {
|
|
36
|
+
return getFocusedElement(activeEl.shadowRoot) ?? activeEl;
|
|
37
|
+
}
|
|
38
|
+
return activeEl;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @fires opening Fired before the opening animation begins (not fired on quick)
|
|
42
|
+
* @fires opened Fired once the menu is open, after any animations
|
|
43
|
+
* @fires closing Fired before the closing animation begins (not fired on quick)
|
|
44
|
+
* @fires closed Fired once the menu is closed, after any animations
|
|
21
45
|
*/
|
|
22
46
|
export class Menu extends LitElement {
|
|
23
47
|
constructor() {
|
|
24
48
|
super(...arguments);
|
|
25
|
-
|
|
49
|
+
/**
|
|
50
|
+
* The element in which the menu should align to.
|
|
51
|
+
*/
|
|
26
52
|
this.anchor = null;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Makes the element use `position:fixed` instead of `position:absolute`. In
|
|
55
|
+
* most cases, the menu should position itself above most other
|
|
56
|
+
* `position:absolute` or `position:fixed` elements when placed inside of
|
|
57
|
+
* them. e.g. using a menu inside of an `md-dialog`.
|
|
58
|
+
*
|
|
59
|
+
* __NOTE__: Fixed menus will not scroll with the page and will be fixed to
|
|
60
|
+
* the window instead.
|
|
61
|
+
*/
|
|
34
62
|
this.fixed = false;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
63
|
+
/**
|
|
64
|
+
* Skips the opening and closing animations.
|
|
65
|
+
*/
|
|
66
|
+
this.quick = false;
|
|
67
|
+
/**
|
|
68
|
+
* Displays overflow content like a submenu.
|
|
69
|
+
*
|
|
70
|
+
* __NOTE__: This may cause adverse effects if you set
|
|
71
|
+
* `md-menu {max-height:...}`
|
|
72
|
+
* and have items overflowing items in the "y" direction.
|
|
73
|
+
*/
|
|
74
|
+
this.hasOverflow = false;
|
|
75
|
+
/**
|
|
76
|
+
* Opens the menu and makes it visible. Alternative to the `.show()` and
|
|
77
|
+
* `.close()` methods
|
|
78
|
+
*/
|
|
79
|
+
this.open = false;
|
|
80
|
+
/**
|
|
81
|
+
* Offsets the menu's inline alignment from the anchor by the given number in
|
|
82
|
+
* pixels. This value is direction aware and will follow the LTR / RTL
|
|
83
|
+
* direction.
|
|
84
|
+
*
|
|
85
|
+
* e.g. LTR: positive -> right, negative -> left
|
|
86
|
+
* RTL: positive -> left, negative -> right
|
|
87
|
+
*/
|
|
88
|
+
this.xOffset = 0;
|
|
89
|
+
/**
|
|
90
|
+
* Offsets the menu's block alignment from the anchor by the given number in
|
|
91
|
+
* pixels.
|
|
92
|
+
*
|
|
93
|
+
* e.g. positive -> down, negative -> up
|
|
94
|
+
*/
|
|
95
|
+
this.yOffset = 0;
|
|
96
|
+
/**
|
|
97
|
+
* The tabindex of the underlying list element.
|
|
98
|
+
*/
|
|
99
|
+
this.listTabIndex = 0;
|
|
100
|
+
/**
|
|
101
|
+
* The max time between the keystrokes of the typeahead menu behavior before
|
|
102
|
+
* it clears the typeahead buffer.
|
|
103
|
+
*/
|
|
104
|
+
this.typeaheadBufferTime = 200;
|
|
105
|
+
/**
|
|
106
|
+
* The corner of the anchor which to align the menu in the standard logical
|
|
107
|
+
* property style of <block>_<inline>.
|
|
108
|
+
*/
|
|
109
|
+
this.anchorCorner = 'END_START';
|
|
110
|
+
/**
|
|
111
|
+
* The corner of the menu which to align the anchor in the standard logical
|
|
112
|
+
* property style of <block>_<inline>.
|
|
113
|
+
*/
|
|
114
|
+
this.menuCorner = 'START_START';
|
|
115
|
+
/**
|
|
116
|
+
* Keeps the user clicks outside the menu
|
|
117
|
+
*/
|
|
118
|
+
this.stayOpenOnOutsideClick = false;
|
|
119
|
+
/**
|
|
120
|
+
* After closing, does not restore focus to the last focused element before
|
|
121
|
+
* the menu was opened.
|
|
122
|
+
*/
|
|
39
123
|
this.skipRestoreFocus = false;
|
|
124
|
+
/**
|
|
125
|
+
* The element that should be focused by default once opened.
|
|
126
|
+
*/
|
|
40
127
|
this.defaultFocus = 'LIST_ROOT';
|
|
41
|
-
this.
|
|
128
|
+
this.openCloseAnimationSignal = createAnimationSignal();
|
|
129
|
+
/**
|
|
130
|
+
* The element that was focused before the menu opened.
|
|
131
|
+
*/
|
|
132
|
+
this.lastFocusedElement = null;
|
|
133
|
+
/**
|
|
134
|
+
* Handles typeahead navigation through the menu.
|
|
135
|
+
*/
|
|
136
|
+
this.typeaheadController = new TypeaheadController(() => {
|
|
137
|
+
return {
|
|
138
|
+
getItems: () => this.items,
|
|
139
|
+
typeaheadBufferTime: this.typeaheadBufferTime,
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Handles positioning the surface and aligning it to the anchor.
|
|
144
|
+
*/
|
|
145
|
+
this.menuPositionController = new SurfacePositionController(this, () => {
|
|
146
|
+
return {
|
|
147
|
+
anchorCorner: this.anchorCorner,
|
|
148
|
+
surfaceCorner: this.menuCorner,
|
|
149
|
+
surfaceEl: this.surfaceEl,
|
|
150
|
+
anchorEl: this.anchor,
|
|
151
|
+
isTopLayer: this.fixed,
|
|
152
|
+
isOpen: this.open,
|
|
153
|
+
xOffset: this.xOffset,
|
|
154
|
+
yOffset: this.yOffset,
|
|
155
|
+
onOpen: this.onOpened,
|
|
156
|
+
beforeClose: this.beforeClose,
|
|
157
|
+
onClose: this.onClosed,
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
/**
|
|
161
|
+
* Saves the last focused element focuses the new element based on
|
|
162
|
+
* `defaultFocus`, and animates open.
|
|
163
|
+
*/
|
|
164
|
+
this.onOpened = () => {
|
|
165
|
+
this.lastFocusedElement = getFocusedElement();
|
|
166
|
+
if (!this.listElement)
|
|
167
|
+
return;
|
|
168
|
+
const items = this.listElement.items;
|
|
169
|
+
const activeItemRecord = List.getActiveItem(items);
|
|
170
|
+
if (activeItemRecord && this.defaultFocus !== 'NONE') {
|
|
171
|
+
activeItemRecord.item.active = false;
|
|
172
|
+
}
|
|
173
|
+
switch (this.defaultFocus) {
|
|
174
|
+
case 'FIRST_ITEM':
|
|
175
|
+
const first = List.getFirstActivatableItem(items);
|
|
176
|
+
if (first) {
|
|
177
|
+
first.active = true;
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
case 'LAST_ITEM':
|
|
181
|
+
const last = List.getLastActivatableItem(items);
|
|
182
|
+
if (last) {
|
|
183
|
+
last.active = true;
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
case 'LIST_ROOT':
|
|
187
|
+
this.listElement?.focus();
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
case 'NONE':
|
|
191
|
+
// Do nothing.
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (this.quick) {
|
|
195
|
+
this.dispatchEvent(new Event('opened'));
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this.animateOpen();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Animates closed.
|
|
203
|
+
*/
|
|
204
|
+
this.beforeClose = async () => {
|
|
205
|
+
this.open = false;
|
|
206
|
+
if (!this.quick) {
|
|
207
|
+
await this.animateClose();
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Focuses the last focused element.
|
|
212
|
+
*/
|
|
213
|
+
this.onClosed = () => {
|
|
214
|
+
if (this.quick) {
|
|
215
|
+
this.dispatchEvent(new Event('closed'));
|
|
216
|
+
}
|
|
217
|
+
if (!this.skipRestoreFocus) {
|
|
218
|
+
this.lastFocusedElement?.focus?.();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
this.onWindowClick = (e) => {
|
|
222
|
+
if (!this.stayOpenOnOutsideClick && !e.composedPath().includes(this)) {
|
|
223
|
+
this.open = false;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
42
226
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Whether the menu is animating upwards or downwards when opening. This is
|
|
229
|
+
* helpful for calculating some animation calculations.
|
|
230
|
+
*/
|
|
231
|
+
get openDirection() {
|
|
232
|
+
const menuCornerBlock = this.menuCorner.split('_')[0];
|
|
233
|
+
return menuCornerBlock === 'START' ? 'DOWN' : 'UP';
|
|
49
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* The menu items associated with this menu. The items must be `MenuItem`s and
|
|
237
|
+
* have both the `md-menu-item` and `md-list-item` attributes.
|
|
238
|
+
*/
|
|
50
239
|
get items() {
|
|
51
240
|
const listElement = this.listElement;
|
|
52
241
|
if (listElement) {
|
|
53
|
-
return listElement.items;
|
|
242
|
+
return listElement.items.filter(el => el.hasAttribute('md-menu-item'));
|
|
54
243
|
}
|
|
55
244
|
return [];
|
|
56
245
|
}
|
|
57
246
|
render() {
|
|
247
|
+
return this.renderSurface();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Renders the positionable surface element and its contents.
|
|
251
|
+
*/
|
|
252
|
+
renderSurface() {
|
|
253
|
+
return html `
|
|
254
|
+
<div
|
|
255
|
+
class="menu ${classMap(this.getSurfaceClasses())}"
|
|
256
|
+
style=${styleMap(this.menuPositionController.surfaceStyles)}>
|
|
257
|
+
${this.renderList()}
|
|
258
|
+
${this.renderElevation()}
|
|
259
|
+
${this.renderFocusRing()}
|
|
260
|
+
</div>
|
|
261
|
+
`;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Renders the List element and its items
|
|
265
|
+
*/
|
|
266
|
+
renderList() {
|
|
58
267
|
return html `
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<md-list
|
|
78
|
-
aria-label="${ifDefined(this.ariaLabel)}"
|
|
79
|
-
role=${'menu'}
|
|
80
|
-
.listTabIndex=${-1}
|
|
81
|
-
.listItemTagName=${this.getMenuItemTagName()}
|
|
82
|
-
@action=${this.onAction}>
|
|
83
|
-
<slot></slot>
|
|
84
|
-
</md-list>
|
|
85
|
-
</md-menu-surface>`;
|
|
268
|
+
<md-list
|
|
269
|
+
.ariaLabel=${this.ariaLabel}
|
|
270
|
+
role="menu"
|
|
271
|
+
listTabIndex=${this.listTabIndex}
|
|
272
|
+
@focus=${this.onListFocus}
|
|
273
|
+
@blur=${this.onListBlur}
|
|
274
|
+
@click=${this.onListClick}
|
|
275
|
+
@keydown=${this.typeaheadController.onKeydown}>
|
|
276
|
+
${this.renderMenuItems()}
|
|
277
|
+
</md-list>`;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Renders the menu items' slot
|
|
281
|
+
*/
|
|
282
|
+
renderMenuItems() {
|
|
283
|
+
return html `<slot
|
|
284
|
+
@close-menu=${this.onCloseMenu}
|
|
285
|
+
@deactivate-items=${this.onDeactivateItems}></slot>`;
|
|
86
286
|
}
|
|
87
|
-
|
|
88
|
-
|
|
287
|
+
/**
|
|
288
|
+
* Renders the elevation component.
|
|
289
|
+
*/
|
|
290
|
+
renderElevation() {
|
|
291
|
+
return html `<md-elevation shadow surface></md-elevation>`;
|
|
89
292
|
}
|
|
90
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Renders the focus ring component.
|
|
295
|
+
*/
|
|
296
|
+
renderFocusRing() {
|
|
297
|
+
return html `<md-focus-ring></md-focus-ring>`;
|
|
298
|
+
}
|
|
299
|
+
getSurfaceClasses() {
|
|
91
300
|
return {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const element = listElement.items[index];
|
|
98
|
-
if (!element) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
element.classList.add(className);
|
|
102
|
-
},
|
|
103
|
-
removeClassFromElementAtIndex: (index, className) => {
|
|
104
|
-
const listElement = this.listElement;
|
|
105
|
-
if (!listElement) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const element = listElement.items[index];
|
|
109
|
-
if (!element) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
element.classList.remove(className);
|
|
113
|
-
},
|
|
114
|
-
addAttributeToElementAtIndex: (index, attr, value) => {
|
|
115
|
-
// TODO(b/240174946): This method is only used for setting
|
|
116
|
-
// `aria-checked` and `aria-disabled` on the menu items when selected
|
|
117
|
-
// and disabled states change. Remove this in favor of adding to the
|
|
118
|
-
// template declaratively.
|
|
119
|
-
},
|
|
120
|
-
removeAttributeFromElementAtIndex: (index, attr) => {
|
|
121
|
-
const listElement = this.listElement;
|
|
122
|
-
if (!listElement) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const element = listElement.items[index];
|
|
126
|
-
if (!element) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
element.removeAttribute(attr);
|
|
130
|
-
},
|
|
131
|
-
getAttributeFromElementAtIndex: (index, attr) => {
|
|
132
|
-
const listElement = this.listElement;
|
|
133
|
-
if (!listElement) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
const element = listElement.items[index];
|
|
137
|
-
if (!element) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
return element.getAttribute(attr);
|
|
141
|
-
},
|
|
142
|
-
elementContainsClass: (element, className) => element.classList.contains(className),
|
|
143
|
-
closeSurface: (skipRestoreFocus) => {
|
|
144
|
-
this.skipRestoreFocus = Boolean(skipRestoreFocus);
|
|
145
|
-
this.open = false;
|
|
146
|
-
},
|
|
147
|
-
getElementIndex: (element) => {
|
|
148
|
-
const listElement = this.listElement;
|
|
149
|
-
if (listElement) {
|
|
150
|
-
return listElement.items.indexOf(element);
|
|
151
|
-
}
|
|
152
|
-
return -1;
|
|
153
|
-
},
|
|
154
|
-
notifySelected: () => { },
|
|
155
|
-
getMenuItemCount: () => {
|
|
156
|
-
const listElement = this.listElement;
|
|
157
|
-
if (!listElement) {
|
|
158
|
-
return 0;
|
|
159
|
-
}
|
|
160
|
-
return listElement.items.length;
|
|
161
|
-
},
|
|
162
|
-
getSelectedSiblingOfItemAtIndex: (index) => {
|
|
163
|
-
const listElement = this.listElement;
|
|
164
|
-
if (!listElement) {
|
|
165
|
-
return -1;
|
|
166
|
-
}
|
|
167
|
-
// TODO(b/240177152): Remove/refactor this when implementing keyboard
|
|
168
|
-
// navigation support.
|
|
169
|
-
// const elementAtIndex = listElement.items[index];
|
|
170
|
-
// if (!elementAtIndex || !elementAtIndex.group) {
|
|
171
|
-
// return -1;
|
|
172
|
-
// }
|
|
173
|
-
// for (let i = 0; i < listElement.items.length; i++) {
|
|
174
|
-
// if (i === index) {
|
|
175
|
-
// continue;
|
|
176
|
-
// }
|
|
177
|
-
// const current = listElement.items[i];
|
|
178
|
-
// if (current.selected && current.group === elementAtIndex.group) {
|
|
179
|
-
// return i;
|
|
180
|
-
// }
|
|
181
|
-
// }
|
|
182
|
-
return -1;
|
|
183
|
-
},
|
|
184
|
-
isSelectableItemAtIndex: (index) => {
|
|
185
|
-
const listElement = this.listElement;
|
|
186
|
-
if (!listElement) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
const elementAtIndex = listElement.items[index];
|
|
190
|
-
if (!elementAtIndex) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
return elementAtIndex.hasAttribute('group');
|
|
194
|
-
},
|
|
301
|
+
open: this.open,
|
|
302
|
+
fixed: this.fixed,
|
|
303
|
+
'has-overflow': this.hasOverflow,
|
|
195
304
|
};
|
|
196
305
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
306
|
+
onListFocus() {
|
|
307
|
+
this.focusRing.visible = shouldShowStrongFocus();
|
|
308
|
+
}
|
|
309
|
+
onListClick() {
|
|
310
|
+
pointerPress();
|
|
311
|
+
this.focusRing.visible = shouldShowStrongFocus();
|
|
312
|
+
}
|
|
313
|
+
onListBlur() {
|
|
314
|
+
this.focusRing.visible = false;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Performs the opening animation:
|
|
318
|
+
*
|
|
319
|
+
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
320
|
+
*/
|
|
321
|
+
animateOpen() {
|
|
322
|
+
const surfaceEl = this.surfaceEl;
|
|
323
|
+
const slotEl = this.slotEl;
|
|
324
|
+
if (!surfaceEl || !slotEl)
|
|
325
|
+
return;
|
|
326
|
+
const openDirection = this.openDirection;
|
|
327
|
+
this.dispatchEvent(new Event('opening'));
|
|
328
|
+
// needs to be imperative because we don't want to mix animation and Lit
|
|
329
|
+
// render timing
|
|
330
|
+
surfaceEl.classList.toggle('animating', true);
|
|
331
|
+
const signal = this.openCloseAnimationSignal.start();
|
|
332
|
+
const height = surfaceEl.offsetHeight;
|
|
333
|
+
const openingUpwards = openDirection === 'UP';
|
|
334
|
+
const children = this.items;
|
|
335
|
+
const FULL_DURATION = 500;
|
|
336
|
+
const SURFACE_OPACITY_DURATION = 50;
|
|
337
|
+
const ITEM_OPACITY_DURATION = 250;
|
|
338
|
+
// We want to fit every child fade-in animation within the full duration of
|
|
339
|
+
// the animation.
|
|
340
|
+
const DELAY_BETWEEN_ITEMS = (FULL_DURATION - ITEM_OPACITY_DURATION) / children.length;
|
|
341
|
+
const surfaceHeightAnimation = surfaceEl.animate([{ height: '0px' }, { height: `${height}px` }], {
|
|
342
|
+
duration: FULL_DURATION,
|
|
343
|
+
easing: EASING.EMPHASIZED,
|
|
344
|
+
});
|
|
345
|
+
// When we are opening upwards, we want to make sure the last item is always
|
|
346
|
+
// in view, so we need to translate it upwards the opposite direction of the
|
|
347
|
+
// height animation
|
|
348
|
+
const upPositionCorrectionAnimation = slotEl.animate([
|
|
349
|
+
{ transform: openingUpwards ? `translateY(-${height}px)` : '' },
|
|
350
|
+
{ transform: '' }
|
|
351
|
+
], { duration: FULL_DURATION, easing: EASING.EMPHASIZED });
|
|
352
|
+
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 0 }, { opacity: 1 }], SURFACE_OPACITY_DURATION);
|
|
353
|
+
const childrenAnimations = [];
|
|
354
|
+
for (let i = 0; i < children.length; i++) {
|
|
355
|
+
// If we are animating upwards, then reverse the children list.
|
|
356
|
+
const directionalIndex = openingUpwards ? children.length - 1 - i : i;
|
|
357
|
+
const child = children[directionalIndex];
|
|
358
|
+
const animation = child.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
359
|
+
duration: ITEM_OPACITY_DURATION,
|
|
360
|
+
delay: DELAY_BETWEEN_ITEMS * i,
|
|
361
|
+
});
|
|
362
|
+
// Make them all initially hidden and then clean up at the end of each
|
|
363
|
+
// animation.
|
|
364
|
+
child.classList.toggle('hidden', true);
|
|
365
|
+
animation.addEventListener('finish', () => {
|
|
366
|
+
child.classList.toggle('hidden', false);
|
|
367
|
+
});
|
|
368
|
+
childrenAnimations.push([child, animation]);
|
|
200
369
|
}
|
|
370
|
+
signal.addEventListener('abort', () => {
|
|
371
|
+
surfaceHeightAnimation.cancel();
|
|
372
|
+
upPositionCorrectionAnimation.cancel();
|
|
373
|
+
surfaceOpacityAnimation.cancel();
|
|
374
|
+
childrenAnimations.forEach(([child, animation]) => {
|
|
375
|
+
child.classList.toggle('hidden', false);
|
|
376
|
+
animation.cancel();
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
surfaceHeightAnimation.addEventListener('finish', () => {
|
|
380
|
+
surfaceEl.classList.toggle('animating', false);
|
|
381
|
+
this.openCloseAnimationSignal.finish();
|
|
382
|
+
this.dispatchEvent(new Event('opened'));
|
|
383
|
+
});
|
|
201
384
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
385
|
+
/**
|
|
386
|
+
* Performs the closing animation:
|
|
387
|
+
*
|
|
388
|
+
* https://direct.googleplex.com/#/spec/295000003+271060003
|
|
389
|
+
*/
|
|
390
|
+
animateClose() {
|
|
391
|
+
let resolve;
|
|
392
|
+
let reject;
|
|
393
|
+
// This promise blocks the surface position controller from setting
|
|
394
|
+
// display: none on the surface which will interfere with this animation.
|
|
395
|
+
const animationEnded = new Promise((res, rej) => {
|
|
396
|
+
resolve = res;
|
|
397
|
+
reject = rej;
|
|
398
|
+
});
|
|
399
|
+
const surfaceEl = this.surfaceEl;
|
|
400
|
+
const slotEl = this.slotEl;
|
|
401
|
+
if (!surfaceEl || !slotEl) {
|
|
402
|
+
reject();
|
|
403
|
+
return animationEnded;
|
|
404
|
+
}
|
|
405
|
+
const openDirection = this.openDirection;
|
|
406
|
+
const closingDownwards = openDirection === 'UP';
|
|
407
|
+
this.dispatchEvent(new Event('closing'));
|
|
408
|
+
// needs to be imperative because we don't want to mix animation and Lit
|
|
409
|
+
// render timing
|
|
410
|
+
surfaceEl.classList.toggle('animating', true);
|
|
411
|
+
const signal = this.openCloseAnimationSignal.start();
|
|
412
|
+
const height = surfaceEl.offsetHeight;
|
|
413
|
+
const children = this.items;
|
|
414
|
+
const FULL_DURATION = 150;
|
|
415
|
+
const SURFACE_OPACITY_DURATION = 50;
|
|
416
|
+
// The surface fades away at the very end
|
|
417
|
+
const SURFACE_OPACITY_DELAY = FULL_DURATION - SURFACE_OPACITY_DURATION;
|
|
418
|
+
const ITEM_OPACITY_DURATION = 50;
|
|
419
|
+
const ITEM_OPACITY_INITIAL_DELAY = 50;
|
|
420
|
+
const END_HEIGHT_PRECENTAGE = .35;
|
|
421
|
+
// We want to fit every child fade-out animation within the full duration of
|
|
422
|
+
// the animation.
|
|
423
|
+
const DELAY_BETWEEN_ITEMS = (FULL_DURATION - ITEM_OPACITY_INITIAL_DELAY - ITEM_OPACITY_DURATION) /
|
|
424
|
+
children.length;
|
|
425
|
+
// The mock has the animation shrink to 35%
|
|
426
|
+
const surfaceHeightAnimation = surfaceEl.animate([
|
|
427
|
+
{ height: `${height}px` },
|
|
428
|
+
{ height: `${height * END_HEIGHT_PRECENTAGE}px` }
|
|
429
|
+
], {
|
|
430
|
+
duration: FULL_DURATION,
|
|
431
|
+
easing: EASING.EMPHASIZED_ACCELERATE,
|
|
432
|
+
});
|
|
433
|
+
// When we are closing downwards, we want to make sure the last item is
|
|
434
|
+
// always in view, so we need to translate it upwards the opposite direction
|
|
435
|
+
// of the height animation
|
|
436
|
+
const downPositionCorrectionAnimation = slotEl.animate([
|
|
437
|
+
{ transform: '' }, {
|
|
438
|
+
transform: closingDownwards ?
|
|
439
|
+
`translateY(-${height * (1 - END_HEIGHT_PRECENTAGE)}px)` :
|
|
440
|
+
''
|
|
208
441
|
}
|
|
442
|
+
], { duration: FULL_DURATION, easing: EASING.EMPHASIZED_ACCELERATE });
|
|
443
|
+
const surfaceOpacityAnimation = surfaceEl.animate([{ opacity: 1 }, { opacity: 0 }], { duration: SURFACE_OPACITY_DURATION, delay: SURFACE_OPACITY_DELAY });
|
|
444
|
+
const childrenAnimations = [];
|
|
445
|
+
for (let i = 0; i < children.length; i++) {
|
|
446
|
+
// If the animation is closing upwards, then reverse the list of
|
|
447
|
+
// children so that we animate in the opposite direction.
|
|
448
|
+
const directionalIndex = closingDownwards ? i : children.length - 1 - i;
|
|
449
|
+
const child = children[directionalIndex];
|
|
450
|
+
const animation = child.animate([{ opacity: 1 }, { opacity: 0 }], {
|
|
451
|
+
duration: ITEM_OPACITY_DURATION,
|
|
452
|
+
delay: ITEM_OPACITY_INITIAL_DELAY + DELAY_BETWEEN_ITEMS * i,
|
|
453
|
+
});
|
|
454
|
+
// Make sure the items stay hidden at the end of each child animation.
|
|
455
|
+
// We clean this up at the end of the overall animation.
|
|
456
|
+
animation.addEventListener('finish', () => {
|
|
457
|
+
child.classList.toggle('hidden', true);
|
|
458
|
+
});
|
|
459
|
+
childrenAnimations.push([child, animation]);
|
|
209
460
|
}
|
|
461
|
+
signal.addEventListener('abort', () => {
|
|
462
|
+
surfaceHeightAnimation.cancel();
|
|
463
|
+
downPositionCorrectionAnimation.cancel();
|
|
464
|
+
surfaceOpacityAnimation.cancel();
|
|
465
|
+
childrenAnimations.forEach(([child, animation]) => {
|
|
466
|
+
animation.cancel();
|
|
467
|
+
child.classList.toggle('hidden', false);
|
|
468
|
+
});
|
|
469
|
+
reject();
|
|
470
|
+
});
|
|
471
|
+
surfaceHeightAnimation.addEventListener('finish', () => {
|
|
472
|
+
surfaceEl.classList.toggle('animating', false);
|
|
473
|
+
childrenAnimations.forEach(([child]) => {
|
|
474
|
+
child.classList.toggle('hidden', false);
|
|
475
|
+
});
|
|
476
|
+
this.openCloseAnimationSignal.finish();
|
|
477
|
+
this.dispatchEvent(new Event('closed'));
|
|
478
|
+
resolve(true);
|
|
479
|
+
});
|
|
480
|
+
return animationEnded;
|
|
210
481
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
switch (this.defaultFocus) {
|
|
216
|
-
case 'FIRST_ITEM':
|
|
217
|
-
this.listElement?.activateFirstItem();
|
|
218
|
-
break;
|
|
219
|
-
case 'LAST_ITEM':
|
|
220
|
-
this.listElement?.activateLastItem();
|
|
221
|
-
break;
|
|
222
|
-
case 'NONE':
|
|
223
|
-
// Do nothing.
|
|
224
|
-
break;
|
|
225
|
-
case 'LIST_ROOT':
|
|
226
|
-
default:
|
|
227
|
-
this.listElement?.focus();
|
|
228
|
-
break;
|
|
482
|
+
connectedCallback() {
|
|
483
|
+
super.connectedCallback();
|
|
484
|
+
if (window && window.addEventListener) {
|
|
485
|
+
window.addEventListener('click', this.onWindowClick, { capture: true });
|
|
229
486
|
}
|
|
230
487
|
}
|
|
231
|
-
|
|
232
|
-
|
|
488
|
+
disconnectedCallback() {
|
|
489
|
+
super.disconnectedCallback();
|
|
490
|
+
if (window && window.removeEventListener) {
|
|
491
|
+
window.removeEventListener('click', this.onWindowClick);
|
|
492
|
+
}
|
|
233
493
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
await this.listUpdateComplete;
|
|
237
|
-
// @ts-ignore
|
|
238
|
-
const result = await super.getUpdateComplete();
|
|
239
|
-
return result;
|
|
494
|
+
onCloseMenu(e) {
|
|
495
|
+
this.close();
|
|
240
496
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
this.mdcFoundation = new MDCMenuFoundation(this.createAdapter());
|
|
247
|
-
const listElement = this.listElement;
|
|
248
|
-
if (listElement) {
|
|
249
|
-
this.listUpdateComplete = listElement.updateComplete;
|
|
250
|
-
await this.listUpdateComplete;
|
|
497
|
+
onDeactivateItems(e) {
|
|
498
|
+
e.stopPropagation();
|
|
499
|
+
const items = this.items;
|
|
500
|
+
for (const item of items) {
|
|
501
|
+
item.active = false;
|
|
251
502
|
}
|
|
252
503
|
}
|
|
504
|
+
focus() {
|
|
505
|
+
this.listElement?.focus();
|
|
506
|
+
}
|
|
253
507
|
close() {
|
|
254
508
|
this.open = false;
|
|
509
|
+
this.items.forEach(item => {
|
|
510
|
+
item.close?.();
|
|
511
|
+
});
|
|
255
512
|
}
|
|
256
513
|
show() {
|
|
257
514
|
this.open = true;
|
|
258
515
|
}
|
|
259
516
|
}
|
|
260
517
|
__decorate([
|
|
261
|
-
query('
|
|
262
|
-
__metadata("design:type",
|
|
263
|
-
], Menu.prototype, "
|
|
518
|
+
query('md-list'),
|
|
519
|
+
__metadata("design:type", List)
|
|
520
|
+
], Menu.prototype, "listElement", void 0);
|
|
521
|
+
__decorate([
|
|
522
|
+
query('.menu'),
|
|
523
|
+
__metadata("design:type", HTMLElement)
|
|
524
|
+
], Menu.prototype, "surfaceEl", void 0);
|
|
264
525
|
__decorate([
|
|
265
526
|
query('slot'),
|
|
266
527
|
__metadata("design:type", HTMLSlotElement)
|
|
267
|
-
], Menu.prototype, "
|
|
528
|
+
], Menu.prototype, "slotEl", void 0);
|
|
268
529
|
__decorate([
|
|
269
|
-
|
|
270
|
-
__metadata("design:type",
|
|
271
|
-
], Menu.prototype, "
|
|
530
|
+
query('md-focus-ring'),
|
|
531
|
+
__metadata("design:type", MdFocusRing)
|
|
532
|
+
], Menu.prototype, "focusRing", void 0);
|
|
272
533
|
__decorate([
|
|
273
|
-
ariaProperty
|
|
274
|
-
,
|
|
534
|
+
ariaProperty,
|
|
275
535
|
property({ type: String, attribute: 'data-aria-label', noAccessor: true }),
|
|
276
536
|
__metadata("design:type", String)
|
|
277
537
|
], Menu.prototype, "ariaLabel", void 0);
|
|
278
538
|
__decorate([
|
|
279
|
-
property({
|
|
539
|
+
property({ attribute: false }),
|
|
540
|
+
__metadata("design:type", HTMLElement)
|
|
541
|
+
], Menu.prototype, "anchor", void 0);
|
|
542
|
+
__decorate([
|
|
543
|
+
property({ type: Boolean }),
|
|
280
544
|
__metadata("design:type", Object)
|
|
281
|
-
], Menu.prototype, "
|
|
545
|
+
], Menu.prototype, "fixed", void 0);
|
|
282
546
|
__decorate([
|
|
283
547
|
property({ type: Boolean }),
|
|
284
548
|
__metadata("design:type", Object)
|
|
285
549
|
], Menu.prototype, "quick", void 0);
|
|
286
550
|
__decorate([
|
|
287
|
-
property({ type:
|
|
288
|
-
__metadata("design:type", String)
|
|
289
|
-
], Menu.prototype, "corner", void 0);
|
|
290
|
-
__decorate([
|
|
291
|
-
property({ type: Number }),
|
|
292
|
-
__metadata("design:type", Number)
|
|
293
|
-
], Menu.prototype, "x", void 0);
|
|
294
|
-
__decorate([
|
|
295
|
-
property({ type: Number }),
|
|
296
|
-
__metadata("design:type", Number)
|
|
297
|
-
], Menu.prototype, "y", void 0);
|
|
298
|
-
__decorate([
|
|
299
|
-
property({ type: Boolean }),
|
|
551
|
+
property({ type: Boolean, attribute: 'has-overflow' }),
|
|
300
552
|
__metadata("design:type", Object)
|
|
301
|
-
], Menu.prototype, "
|
|
553
|
+
], Menu.prototype, "hasOverflow", void 0);
|
|
302
554
|
__decorate([
|
|
303
|
-
property({ type: Boolean }),
|
|
555
|
+
property({ type: Boolean, reflect: true }),
|
|
304
556
|
__metadata("design:type", Object)
|
|
305
|
-
], Menu.prototype, "
|
|
557
|
+
], Menu.prototype, "open", void 0);
|
|
306
558
|
__decorate([
|
|
307
|
-
property({ type:
|
|
559
|
+
property({ type: Number, attribute: 'x-offset' }),
|
|
308
560
|
__metadata("design:type", Object)
|
|
309
|
-
], Menu.prototype, "
|
|
561
|
+
], Menu.prototype, "xOffset", void 0);
|
|
310
562
|
__decorate([
|
|
311
|
-
property({ type:
|
|
563
|
+
property({ type: Number, attribute: 'y-offset' }),
|
|
312
564
|
__metadata("design:type", Object)
|
|
313
|
-
], Menu.prototype, "
|
|
565
|
+
], Menu.prototype, "yOffset", void 0);
|
|
314
566
|
__decorate([
|
|
315
|
-
property({ type:
|
|
567
|
+
property({ type: Number, attribute: 'list-tab-index' }),
|
|
316
568
|
__metadata("design:type", Object)
|
|
317
|
-
], Menu.prototype, "
|
|
569
|
+
], Menu.prototype, "listTabIndex", void 0);
|
|
318
570
|
__decorate([
|
|
319
|
-
property({ type:
|
|
571
|
+
property({ type: Number, attribute: 'typeahead-delay' }),
|
|
320
572
|
__metadata("design:type", Object)
|
|
321
|
-
], Menu.prototype, "
|
|
573
|
+
], Menu.prototype, "typeaheadBufferTime", void 0);
|
|
322
574
|
__decorate([
|
|
323
|
-
property({ type:
|
|
575
|
+
property({ type: String, attribute: 'anchor-corner' }),
|
|
576
|
+
__metadata("design:type", String)
|
|
577
|
+
], Menu.prototype, "anchorCorner", void 0);
|
|
578
|
+
__decorate([
|
|
579
|
+
property({ type: String, attribute: 'menu-corner' }),
|
|
580
|
+
__metadata("design:type", String)
|
|
581
|
+
], Menu.prototype, "menuCorner", void 0);
|
|
582
|
+
__decorate([
|
|
583
|
+
property({ type: Boolean, attribute: 'stay-open-on-outside-click' }),
|
|
324
584
|
__metadata("design:type", Object)
|
|
325
|
-
], Menu.prototype, "
|
|
585
|
+
], Menu.prototype, "stayOpenOnOutsideClick", void 0);
|
|
326
586
|
__decorate([
|
|
327
|
-
property({ type: Boolean }),
|
|
587
|
+
property({ type: Boolean, attribute: 'skip-restore-focus' }),
|
|
328
588
|
__metadata("design:type", Object)
|
|
329
589
|
], Menu.prototype, "skipRestoreFocus", void 0);
|
|
330
590
|
__decorate([
|
|
331
|
-
property({ type: String }),
|
|
591
|
+
property({ type: String, attribute: 'default-focus' }),
|
|
332
592
|
__metadata("design:type", String)
|
|
333
593
|
], Menu.prototype, "defaultFocus", void 0);
|
|
334
594
|
//# sourceMappingURL=menu.js.map
|