@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/list/lib/list.js
CHANGED
|
@@ -4,165 +4,268 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate, __metadata } from "tslib";
|
|
7
|
-
|
|
7
|
+
// Required for @ariaProperty
|
|
8
|
+
// tslint:disable:no-new-decorators
|
|
8
9
|
import { html, LitElement } from 'lit';
|
|
9
10
|
import { property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
10
11
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
12
13
|
import { ariaProperty } from '../../decorators/aria-property.js';
|
|
13
|
-
const
|
|
14
|
+
const NAVIGABLE_KEYS = {
|
|
14
15
|
ArrowDown: 'ArrowDown',
|
|
15
16
|
ArrowUp: 'ArrowUp',
|
|
16
17
|
Home: 'Home',
|
|
17
18
|
End: 'End',
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
+
const navigableKeySet = new Set(Object.values(NAVIGABLE_KEYS));
|
|
21
|
+
function isNavigableKey(key) {
|
|
22
|
+
return navigableKeySet.has(key);
|
|
23
|
+
}
|
|
24
|
+
// tslint:disable-next-line:enforce-comments-on-exported-symbols
|
|
20
25
|
export class List extends LitElement {
|
|
21
26
|
constructor() {
|
|
22
27
|
super(...arguments);
|
|
23
28
|
// @ts-ignore(b/264292293): Use `override` with TS 4.9+
|
|
24
29
|
this.role = 'list';
|
|
25
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The tabindex of the underlying list.
|
|
32
|
+
*/
|
|
26
33
|
this.listTabIndex = 0;
|
|
27
|
-
this.items = [];
|
|
28
|
-
this.activeListItem = null;
|
|
29
|
-
this.listItemTagName = 'md-list-item';
|
|
30
|
-
}
|
|
31
|
-
firstUpdated(changedProperties) {
|
|
32
|
-
super.firstUpdated(changedProperties);
|
|
33
|
-
this.updateItems();
|
|
34
34
|
}
|
|
35
|
-
/** @soyTemplate */
|
|
36
35
|
render() {
|
|
36
|
+
return this.renderList();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Renders the main list element.
|
|
40
|
+
*/
|
|
41
|
+
renderList() {
|
|
37
42
|
return html `
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<md-elevation surface></md-elevation>
|
|
48
|
-
</ul>
|
|
49
|
-
`;
|
|
43
|
+
<ul class="md3-list ${classMap(this.getListClasses())}"
|
|
44
|
+
aria-label="${ifDefined(this.ariaLabel)}"
|
|
45
|
+
tabindex=${this.listTabIndex}
|
|
46
|
+
role=${this.role}
|
|
47
|
+
@keydown=${this.handleKeydown}
|
|
48
|
+
>
|
|
49
|
+
${this.renderContent()}
|
|
50
|
+
</ul>
|
|
51
|
+
`;
|
|
50
52
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The classes to be applied to the underlying list.
|
|
55
|
+
*/
|
|
56
|
+
getListClasses() {
|
|
53
57
|
return {};
|
|
54
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* The content to be slotted into the list.
|
|
61
|
+
*/
|
|
62
|
+
renderContent() {
|
|
63
|
+
return html `<span><slot @click=${(e) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
}}></slot></span>`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handles keyboard navigation in the list.
|
|
69
|
+
*
|
|
70
|
+
* @param event {KeyboardEvent} The keyboard event that triggers this handler.
|
|
71
|
+
*/
|
|
55
72
|
handleKeydown(event) {
|
|
56
|
-
|
|
73
|
+
const key = event.key;
|
|
74
|
+
if (!isNavigableKey(key)) {
|
|
57
75
|
return;
|
|
58
|
-
for (const item of this.items) {
|
|
59
|
-
if (this.isListItemActive(item)) {
|
|
60
|
-
this.activeListItem = item;
|
|
61
|
-
}
|
|
62
|
-
this.deactivateListItem(item);
|
|
63
76
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.activeListItem = this.getFirstItem();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (event.key === NAVIGATABLE_KEYS.ArrowUp) {
|
|
74
|
-
event.preventDefault();
|
|
75
|
-
if (this.activeListItem) {
|
|
76
|
-
this.activeListItem = this.getPrevItem(this.activeListItem);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
this.activeListItem = this.getLastItem();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (event.key === NAVIGATABLE_KEYS.Home) {
|
|
83
|
-
event.preventDefault();
|
|
84
|
-
this.activeListItem = this.getFirstItem();
|
|
77
|
+
// do not use this.items directly so we don't re-query the DOM unnecessarily
|
|
78
|
+
const items = this.items;
|
|
79
|
+
if (!items.length) {
|
|
80
|
+
return;
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
const activeItemRecord = List.getActiveItem(items);
|
|
83
|
+
if (activeItemRecord) {
|
|
84
|
+
activeItemRecord.item.active = false;
|
|
89
85
|
}
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
switch (key) {
|
|
88
|
+
// Activate the next item
|
|
89
|
+
case NAVIGABLE_KEYS.ArrowDown:
|
|
90
|
+
if (activeItemRecord) {
|
|
91
|
+
const next = List.getNextItem(items, activeItemRecord.index);
|
|
92
|
+
if (next)
|
|
93
|
+
next.active = true;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
List.activateFirstItem(items);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
// Activate the previous item
|
|
100
|
+
case NAVIGABLE_KEYS.ArrowUp:
|
|
101
|
+
if (activeItemRecord) {
|
|
102
|
+
const prev = List.getPrevItem(items, activeItemRecord.index);
|
|
103
|
+
if (prev)
|
|
104
|
+
prev.active = true;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
items[items.length - 1].active = true;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
// Activate the first item
|
|
111
|
+
case NAVIGABLE_KEYS.Home:
|
|
112
|
+
List.activateFirstItem(items);
|
|
113
|
+
break;
|
|
114
|
+
// Activate the last item
|
|
115
|
+
case NAVIGABLE_KEYS.End:
|
|
116
|
+
List.activateLastItem(items);
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
break;
|
|
92
120
|
}
|
|
93
121
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Activates the first non-disabled item of a given array of items.
|
|
124
|
+
*
|
|
125
|
+
* @param items {Array<ListItem>} The items from which to activate the
|
|
126
|
+
* first item.
|
|
127
|
+
*/
|
|
128
|
+
static activateFirstItem(items) {
|
|
129
|
+
// NOTE: These selector functions are static and not on the instance such
|
|
130
|
+
// that multiple operations can be chained and we do not have to re-query
|
|
131
|
+
// the DOM
|
|
132
|
+
const firstItem = List.getFirstActivatableItem(items);
|
|
133
|
+
if (firstItem) {
|
|
134
|
+
firstItem.active = true;
|
|
135
|
+
}
|
|
107
136
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Activates the last non-disabled item of a given array of items.
|
|
139
|
+
*
|
|
140
|
+
* @param items {Array<ListItem>} The items from which to activate the
|
|
141
|
+
* last item.
|
|
142
|
+
*/
|
|
143
|
+
static activateLastItem(items) {
|
|
144
|
+
const lastItem = List.getLastActivatableItem(items);
|
|
145
|
+
if (lastItem) {
|
|
146
|
+
lastItem.active = true;
|
|
147
|
+
}
|
|
111
148
|
}
|
|
112
|
-
|
|
113
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Deactivates the currently active item of a given array of items.
|
|
151
|
+
*
|
|
152
|
+
* @param items {Array<ListItem>} The items from which to deactivate the
|
|
153
|
+
* active item.
|
|
154
|
+
* @returns A record of the deleselcted activated item including the item and
|
|
155
|
+
* the index of the item or `null` if none are deactivated.
|
|
156
|
+
*/
|
|
157
|
+
static deactivateActiveItem(items) {
|
|
158
|
+
const activeItem = List.getActiveItem(items);
|
|
159
|
+
if (activeItem) {
|
|
160
|
+
activeItem.item.active = false;
|
|
161
|
+
}
|
|
162
|
+
return activeItem;
|
|
114
163
|
}
|
|
115
|
-
|
|
164
|
+
focus() {
|
|
116
165
|
this.listRoot.focus();
|
|
117
166
|
}
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the the first activated item of a given array of items.
|
|
169
|
+
*
|
|
170
|
+
* @param items {Array<ListItem>} The items to search.
|
|
171
|
+
* @returns A record of the first activated item including the item and the
|
|
172
|
+
* index of the item or `null` if none are activated.
|
|
173
|
+
*/
|
|
174
|
+
static getActiveItem(items) {
|
|
175
|
+
for (let i = 0; i < items.length; i++) {
|
|
176
|
+
const item = items[i];
|
|
177
|
+
if (item.active) {
|
|
178
|
+
return {
|
|
179
|
+
item,
|
|
180
|
+
index: i,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
126
185
|
}
|
|
127
|
-
|
|
128
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Retrieves the the first non-disabled item of a given array of items. This
|
|
188
|
+
* the first item that is not disabled.
|
|
189
|
+
*
|
|
190
|
+
* @param items {Array<ListItem>} The items to search.
|
|
191
|
+
* @returns The first activatable item or `null` if none are activatable.
|
|
192
|
+
*/
|
|
193
|
+
static getFirstActivatableItem(items) {
|
|
194
|
+
for (const item of items) {
|
|
195
|
+
if (!item.disabled) {
|
|
196
|
+
return item;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
129
200
|
}
|
|
130
|
-
|
|
131
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Retrieves the the last non-disabled item of a given array of items.
|
|
203
|
+
*
|
|
204
|
+
* @param items {Array<ListItem>} The items to search.
|
|
205
|
+
* @returns The last activatable item or `null` if none are activatable.
|
|
206
|
+
*/
|
|
207
|
+
static getLastActivatableItem(items) {
|
|
208
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
209
|
+
const item = items[i];
|
|
210
|
+
if (!item.disabled) {
|
|
211
|
+
return item;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
132
215
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Retrieves the the next non-disabled item of a given array of items.
|
|
218
|
+
*
|
|
219
|
+
* @param items {Array<ListItem>} The items to search.
|
|
220
|
+
* @param index {{index: number}} The index to search from.
|
|
221
|
+
* @returns The next activatable item or `null` if none are activatable.
|
|
222
|
+
*/
|
|
223
|
+
static getNextItem(items, index) {
|
|
224
|
+
for (let i = 1; i < items.length; i++) {
|
|
225
|
+
const nextIndex = (i + index) % items.length;
|
|
226
|
+
const item = items[nextIndex];
|
|
227
|
+
if (!item.disabled) {
|
|
228
|
+
return item;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return null;
|
|
136
232
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Retrieves the the previous non-disabled item of a given array of items.
|
|
235
|
+
*
|
|
236
|
+
* @param items {Array<ListItem>} The items to search.
|
|
237
|
+
* @param index {{index: number}} The index to search from.
|
|
238
|
+
* @returns The previous activatable item or `null` if none are activatable.
|
|
239
|
+
*/
|
|
240
|
+
static getPrevItem(items, index) {
|
|
241
|
+
for (let i = 1; i < items.length; i++) {
|
|
242
|
+
const prevIndex = (index - i + items.length) % items.length;
|
|
243
|
+
const item = items[prevIndex];
|
|
244
|
+
if (!item.disabled) {
|
|
245
|
+
return item;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
140
249
|
}
|
|
141
250
|
}
|
|
142
251
|
List.shadowRootOptions = { mode: 'open', delegatesFocus: true };
|
|
143
252
|
__decorate([
|
|
144
|
-
ariaProperty
|
|
145
|
-
,
|
|
253
|
+
ariaProperty,
|
|
146
254
|
property({ type: String, attribute: 'data-aria-label', noAccessor: true }),
|
|
147
255
|
__metadata("design:type", String)
|
|
148
256
|
], List.prototype, "ariaLabel", void 0);
|
|
149
257
|
__decorate([
|
|
150
|
-
ariaProperty
|
|
151
|
-
,
|
|
258
|
+
ariaProperty,
|
|
152
259
|
property({ type: String, attribute: 'data-aria-activedescendant', noAccessor: true }),
|
|
153
260
|
__metadata("design:type", String)
|
|
154
261
|
], List.prototype, "ariaActivedescendant", void 0);
|
|
155
262
|
__decorate([
|
|
156
|
-
ariaProperty
|
|
157
|
-
// tslint:disable-next-line
|
|
263
|
+
ariaProperty
|
|
264
|
+
// tslint:disable-next-line
|
|
158
265
|
,
|
|
159
266
|
property({ type: String, attribute: 'data-role', noAccessor: true }),
|
|
160
267
|
__metadata("design:type", String)
|
|
161
268
|
], List.prototype, "role", void 0);
|
|
162
|
-
__decorate([
|
|
163
|
-
property({ type: String }),
|
|
164
|
-
__metadata("design:type", Object)
|
|
165
|
-
], List.prototype, "listId", void 0);
|
|
166
269
|
__decorate([
|
|
167
270
|
property({ type: Number }),
|
|
168
271
|
__metadata("design:type", Number)
|
|
@@ -172,11 +275,7 @@ __decorate([
|
|
|
172
275
|
__metadata("design:type", HTMLElement)
|
|
173
276
|
], List.prototype, "listRoot", void 0);
|
|
174
277
|
__decorate([
|
|
175
|
-
|
|
176
|
-
__metadata("design:type", Object)
|
|
177
|
-
], List.prototype, "listItemTagName", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
queryAssignedElements({ flatten: true }),
|
|
278
|
+
queryAssignedElements({ flatten: true, selector: '[md-list-item]' }),
|
|
180
279
|
__metadata("design:type", Array)
|
|
181
|
-
], List.prototype, "
|
|
280
|
+
], List.prototype, "items", void 0);
|
|
182
281
|
//# sourceMappingURL=list.js.map
|
package/list/lib/list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,IAAI,EAAE,UAAU,EAA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AAC;;oCAAa;AAEZ;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;0CAA0B;AAK/B;IAAnB,KAAK,CAAC,WAAW,CAAC;8BAAY,WAAW;sCAAC;AAEjB;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;6CAAkC;AAG3D;IADC,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;;8CACS","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport '../../elevation/elevation.js';\n\nimport {html, LitElement, PropertyValues, TemplateResult} from 'lit';\nimport {property, query, queryAssignedElements} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {ARIARole} from '../../types/aria.js';\n\nimport {ListItem} from './listitem/list-item.js';\n\nconst NAVIGATABLE_KEYS = {\n ArrowDown: 'ArrowDown',\n ArrowUp: 'ArrowUp',\n Home: 'Home',\n End: 'End',\n};\n\n/** @soyCompatible */\nexport class List extends LitElement {\n static override shadowRootOptions:\n ShadowRootInit = {mode: 'open', delegatesFocus: true};\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property({type: String, attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n @property(\n {type: String, attribute: 'data-aria-activedescendant', noAccessor: true})\n ariaActivedescendant!: string;\n\n @ariaProperty // tslint:disable-line:no-new-decorators\n // tslint:disable-next-line:decorator-placement\n @property({type: String, attribute: 'data-role', noAccessor: true})\n // @ts-ignore(b/264292293): Use `override` with TS 4.9+\n role: ARIARole = 'list';\n\n @property({type: String}) listId = '';\n\n @property({type: Number}) listTabIndex: number = 0;\n\n items: ListItem[] = [];\n activeListItem: ListItem|null = null;\n\n @query('.md3-list') listRoot!: HTMLElement;\n\n @property({type: String}) listItemTagName = 'md-list-item';\n\n @queryAssignedElements({flatten: true})\n protected assignedElements!: HTMLElement[]|null;\n\n override firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n\n this.updateItems();\n }\n\n /** @soyTemplate */\n override render(): TemplateResult {\n return html`\n <ul class=\"md3-list ${classMap(this.getRenderClasses())}\"\n aria-label=\"${ifDefined(this.ariaLabel)}\"\n id=${ifDefined(this.listId || undefined)}\n tabindex=${this.listTabIndex}\n role=${this.role}\n @action=${this.handleAction}\n @keydown=${this.handleKeydown}\n >\n <span><slot></slot></span>\n <md-elevation surface></md-elevation>\n </ul>\n `;\n }\n\n /** @soyTemplate */\n protected getRenderClasses(): ClassInfo {\n return {};\n }\n\n handleKeydown(event: KeyboardEvent) {\n if (Object.values(NAVIGATABLE_KEYS).indexOf(event.key) === -1) return;\n\n for (const item of this.items) {\n if (this.isListItemActive(item)) {\n this.activeListItem = item;\n }\n\n this.deactivateListItem(item);\n }\n\n if (event.key === NAVIGATABLE_KEYS.ArrowDown) {\n event.preventDefault();\n if (this.activeListItem) {\n this.activeListItem = this.getNextItem(this.activeListItem);\n } else {\n this.activeListItem = this.getFirstItem();\n }\n }\n\n if (event.key === NAVIGATABLE_KEYS.ArrowUp) {\n event.preventDefault();\n if (this.activeListItem) {\n this.activeListItem = this.getPrevItem(this.activeListItem);\n } else {\n this.activeListItem = this.getLastItem();\n }\n }\n\n if (event.key === NAVIGATABLE_KEYS.Home) {\n event.preventDefault();\n this.activeListItem = this.getFirstItem();\n }\n\n if (event.key === NAVIGATABLE_KEYS.End) {\n event.preventDefault();\n this.activeListItem = this.getLastItem();\n }\n\n if (this.activeListItem) {\n this.activateListItem(this.activeListItem);\n }\n }\n\n protected activateListItem(item: ListItem) {\n item.activate();\n }\n\n protected deactivateListItem(item: ListItem) {\n item.deactivate();\n }\n\n protected isListItemActive(item: ListItem): boolean {\n return item.isActive();\n }\n\n protected handleAction(event: CustomEvent) {}\n\n activateFirstItem() {\n this.activeListItem = this.getFirstItem();\n this.activeListItem.activate();\n }\n\n activateLastItem() {\n this.activeListItem = this.getLastItem();\n this.activeListItem.activate();\n }\n\n resetActiveListItem() {\n this.activeListItem = null;\n }\n\n focusListRoot() {\n this.listRoot.focus();\n }\n\n /** Updates `this.items` based on slot elements in the DOM. */\n protected updateItems() {\n const elements = this.assignedElements || [];\n this.items = elements.filter(this.isListItem, this);\n }\n\n /** @return Whether the given element is a list item element. */\n private isListItem(element: Element): element is ListItem {\n return element.tagName.toLowerCase() === this.listItemTagName;\n }\n\n private getFirstItem(): ListItem {\n return this.items[0];\n }\n\n private getLastItem(): ListItem {\n return this.items[this.items.length - 1];\n }\n\n private getPrevItem(item: ListItem): ListItem {\n const curIndex = this.items.indexOf(item);\n return this.items[curIndex === 0 ? this.items.length - 1 : curIndex - 1];\n }\n\n private getNextItem(item: ListItem): ListItem {\n const curIndex = this.items.indexOf(item);\n return this.items[(curIndex + 1) % this.items.length];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,6BAA6B;AAC7B,mCAAmC;AAEnC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAY,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAK/D,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC;AAIX,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,cAA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iB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;uCAC7C;AAK5B;IAHC,YAAY;IACZ,QAAQ,CACL,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;kDAChD;AAM9B;IAJC,YAAY;IACb,2BAA2B;;IAC1B,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;kCAE3C;AAKE;IAAzB,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;0CAA0B;AAE/B;IAAnB,KAAK,CAAC,WAAW,CAAC;8BAAY,WAAW;sCAAC;AAW3C;IADC,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAC,CAAC;;mCAChD","sourcesContent":["/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Required for @ariaProperty\n// tslint:disable:no-new-decorators\n\nimport {html, LitElement, TemplateResult} from 'lit';\nimport {property, query, queryAssignedElements} from 'lit/decorators.js';\nimport {ClassInfo, classMap} from 'lit/directives/class-map.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {ARIARole} from '../../types/aria.js';\n\nimport {ListItem} from './listitem/list-item.js';\n\nconst NAVIGABLE_KEYS = {\n ArrowDown: 'ArrowDown',\n ArrowUp: 'ArrowUp',\n Home: 'Home',\n End: 'End',\n} as const;\n\ntype NavigatableValues = typeof NAVIGABLE_KEYS[keyof typeof NAVIGABLE_KEYS];\n\nconst navigableKeySet = new Set(Object.values(NAVIGABLE_KEYS));\n\nfunction isNavigableKey(key: string): key is NavigatableValues {\n return navigableKeySet.has(key as NavigatableValues);\n}\n\n// tslint:disable-next-line:enforce-comments-on-exported-symbols\nexport class List extends LitElement {\n static override shadowRootOptions:\n ShadowRootInit = {mode: 'open', delegatesFocus: true};\n\n @ariaProperty\n @property({type: String, attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n @ariaProperty\n @property(\n {type: String, attribute: 'data-aria-activedescendant', noAccessor: true})\n ariaActivedescendant!: string;\n\n @ariaProperty\n // tslint:disable-next-line\n @property({type: String, attribute: 'data-role', noAccessor: true})\n // @ts-ignore(b/264292293): Use `override` with TS 4.9+\n role: ARIARole = 'list';\n\n /**\n * The tabindex of the underlying list.\n */\n @property({type: Number}) listTabIndex: number = 0;\n\n @query('.md3-list') listRoot!: HTMLElement;\n\n /**\n * An array of activatable and disableable list items. Queries every assigned\n * element that has the `md-list-item` attribute.\n *\n * _NOTE:_ This is a shallow, flattened query via\n * `HTMLSlotElement.queryAssignedElements` and thus will _only_ include direct\n * children / directly slotted elements.\n */\n @queryAssignedElements({flatten: true, selector: '[md-list-item]'})\n items!: ListItem[];\n\n override render(): TemplateResult {\n return this.renderList();\n }\n\n /**\n * Renders the main list element.\n */\n protected renderList() {\n return html`\n <ul class=\"md3-list ${classMap(this.getListClasses())}\"\n aria-label=\"${ifDefined(this.ariaLabel)}\"\n tabindex=${this.listTabIndex}\n role=${this.role}\n @keydown=${this.handleKeydown}\n >\n ${this.renderContent()}\n </ul>\n `;\n }\n\n /**\n * The classes to be applied to the underlying list.\n */\n protected getListClasses(): ClassInfo {\n return {};\n }\n\n /**\n * The content to be slotted into the list.\n */\n protected renderContent() {\n return html`<span><slot @click=${(e: Event) => {\n e.stopPropagation();\n }}></slot></span>`;\n }\n\n /**\n * Handles keyboard navigation in the list.\n *\n * @param event {KeyboardEvent} The keyboard event that triggers this handler.\n */\n handleKeydown(event: KeyboardEvent) {\n const key = event.key;\n if (!isNavigableKey(key)) {\n return;\n }\n // do not use this.items directly so we don't re-query the DOM unnecessarily\n const items = this.items;\n\n if (!items.length) {\n return;\n }\n\n const activeItemRecord = List.getActiveItem(items);\n\n if (activeItemRecord) {\n activeItemRecord.item.active = false;\n }\n\n event.preventDefault();\n\n switch (key) {\n // Activate the next item\n case NAVIGABLE_KEYS.ArrowDown:\n if (activeItemRecord) {\n const next = List.getNextItem(items, activeItemRecord.index);\n\n if (next) next.active = true;\n } else {\n List.activateFirstItem(items);\n }\n break;\n\n // Activate the previous item\n case NAVIGABLE_KEYS.ArrowUp:\n if (activeItemRecord) {\n const prev = List.getPrevItem(items, activeItemRecord.index);\n if (prev) prev.active = true;\n } else {\n items[items.length - 1].active = true;\n }\n break;\n\n // Activate the first item\n case NAVIGABLE_KEYS.Home:\n List.activateFirstItem(items);\n break;\n\n // Activate the last item\n case NAVIGABLE_KEYS.End:\n List.activateLastItem(items);\n break;\n\n default:\n break;\n }\n }\n\n /**\n * Activates the first non-disabled item of a given array of items.\n *\n * @param items {Array<ListItem>} The items from which to activate the\n * first item.\n */\n static activateFirstItem<T extends ListItem>(items: T[]) {\n // NOTE: These selector functions are static and not on the instance such\n // that multiple operations can be chained and we do not have to re-query\n // the DOM\n const firstItem = List.getFirstActivatableItem(items);\n if (firstItem) {\n firstItem.active = true;\n }\n }\n\n /**\n * Activates the last non-disabled item of a given array of items.\n *\n * @param items {Array<ListItem>} The items from which to activate the\n * last item.\n */\n static activateLastItem<T extends ListItem>(items: T[]) {\n const lastItem = List.getLastActivatableItem(items);\n if (lastItem) {\n lastItem.active = true;\n }\n }\n\n /**\n * Deactivates the currently active item of a given array of items.\n *\n * @param items {Array<ListItem>} The items from which to deactivate the\n * active item.\n * @returns A record of the deleselcted activated item including the item and\n * the index of the item or `null` if none are deactivated.\n */\n static deactivateActiveItem<T extends ListItem>(items: T[]) {\n const activeItem = List.getActiveItem(items);\n if (activeItem) {\n activeItem.item.active = false;\n }\n return activeItem;\n }\n\n override focus() {\n this.listRoot.focus();\n }\n\n /**\n * Retrieves the the first activated item of a given array of items.\n *\n * @param items {Array<ListItem>} The items to search.\n * @returns A record of the first activated item including the item and the\n * index of the item or `null` if none are activated.\n */\n static getActiveItem<T extends ListItem>(items: T[]) {\n for (let i = 0; i < items.length; i++) {\n const item = items[i];\n if (item.active) {\n return {\n item,\n index: i,\n };\n }\n }\n return null;\n }\n\n /**\n * Retrieves the the first non-disabled item of a given array of items. This\n * the first item that is not disabled.\n *\n * @param items {Array<ListItem>} The items to search.\n * @returns The first activatable item or `null` if none are activatable.\n */\n static getFirstActivatableItem<T extends ListItem>(items: T[]) {\n for (const item of items) {\n if (!item.disabled) {\n return item;\n }\n }\n\n return null;\n }\n\n /**\n * Retrieves the the last non-disabled item of a given array of items.\n *\n * @param items {Array<ListItem>} The items to search.\n * @returns The last activatable item or `null` if none are activatable.\n */\n static getLastActivatableItem<T extends ListItem>(items: T[]) {\n for (let i = items.length - 1; i >= 0; i--) {\n const item = items[i];\n if (!item.disabled) {\n return item;\n }\n }\n\n return null;\n }\n\n /**\n * Retrieves the the next non-disabled item of a given array of items.\n *\n * @param items {Array<ListItem>} The items to search.\n * @param index {{index: number}} The index to search from.\n * @returns The next activatable item or `null` if none are activatable.\n */\n protected static getNextItem<T extends ListItem>(items: T[], index: number) {\n for (let i = 1; i < items.length; i++) {\n const nextIndex = (i + index) % items.length;\n const item = items[nextIndex];\n if (!item.disabled) {\n return item;\n }\n }\n return null;\n }\n\n /**\n * Retrieves the the previous non-disabled item of a given array of items.\n *\n * @param items {Array<ListItem>} The items to search.\n * @param index {{index: number}} The index to search from.\n * @returns The previous activatable item or `null` if none are activatable.\n */\n protected static getPrevItem<T extends ListItem>(items: T[], index: number) {\n for (let i = 1; i < items.length; i++) {\n const prevIndex = (index - i + items.length) % items.length;\n const item = items[prevIndex];\n\n if (!item.disabled) {\n return item;\n }\n }\n return null;\n }\n}\n"]}
|