@material/web 1.0.0-pre.5 → 1.0.0-pre.6
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 +1 -1
- package/badge/lib/badge-styles.css.js +1 -1
- package/badge/lib/badge-styles.css.js.map +1 -1
- package/button/lib/_elevation.scss +7 -13
- package/button/lib/_outlined-button.scss +1 -1
- package/button/lib/_shared.scss +5 -0
- package/button/lib/_text-button.scss +1 -1
- package/button/lib/_tonal-button.scss +1 -1
- package/button/lib/button.d.ts +14 -1
- package/button/lib/button.js +36 -14
- package/button/lib/button.js.map +1 -1
- package/button/lib/elevated-button.d.ts +3 -0
- package/button/lib/elevated-button.js +4 -2
- package/button/lib/elevated-button.js.map +1 -1
- package/button/lib/elevated-styles.css.js +1 -1
- package/button/lib/elevated-styles.css.js.map +1 -1
- package/button/lib/filled-button.d.ts +3 -1
- package/button/lib/filled-button.js +4 -3
- package/button/lib/filled-button.js.map +1 -1
- package/button/lib/filled-styles.css.js +1 -1
- package/button/lib/filled-styles.css.js.map +1 -1
- package/button/lib/outlined-button.d.ts +3 -0
- package/button/lib/outlined-button.js +3 -1
- package/button/lib/outlined-button.js.map +1 -1
- package/button/lib/outlined-styles.css.js +1 -1
- package/button/lib/outlined-styles.css.js.map +1 -1
- package/button/lib/shared-elevation-styles.css.js +1 -1
- package/button/lib/shared-elevation-styles.css.js.map +1 -1
- package/button/lib/shared-styles.css.js +1 -1
- package/button/lib/shared-styles.css.js.map +1 -1
- package/button/lib/text-button.d.ts +3 -0
- package/button/lib/text-button.js +3 -1
- package/button/lib/text-button.js.map +1 -1
- package/button/lib/text-styles.css.js +1 -1
- package/button/lib/text-styles.css.js.map +1 -1
- package/button/lib/tonal-button.d.ts +3 -1
- package/button/lib/tonal-button.js +4 -3
- package/button/lib/tonal-button.js.map +1 -1
- package/button/lib/tonal-styles.css.js +1 -1
- package/button/lib/tonal-styles.css.js.map +1 -1
- package/checkbox/lib/checkbox-styles.css.js +1 -1
- package/checkbox/lib/checkbox-styles.css.js.map +1 -1
- package/chips/lib/_shared.scss +63 -33
- package/chips/lib/assist-styles.css.js +1 -1
- package/chips/lib/assist-styles.css.js.map +1 -1
- package/chips/lib/chip.js +1 -1
- package/chips/lib/chip.js.map +1 -1
- package/chips/lib/shared-styles.css.js +1 -1
- package/chips/lib/shared-styles.css.js.map +1 -1
- package/chips/lib/suggestion-styles.css.js +1 -1
- package/chips/lib/suggestion-styles.css.js.map +1 -1
- package/circularprogress/_circular-progress.scss +6 -0
- package/circularprogress/circular-progress.d.ts +24 -0
- package/circularprogress/circular-progress.js +27 -0
- package/circularprogress/circular-progress.js.map +1 -0
- package/circularprogress/harness.d.ts +12 -0
- package/circularprogress/harness.js +12 -0
- package/circularprogress/harness.js.map +1 -0
- package/circularprogress/lib/_circular-progress.scss +282 -0
- package/circularprogress/lib/circular-progress-styles.css.js +9 -0
- package/circularprogress/lib/circular-progress-styles.css.js.map +1 -0
- package/circularprogress/lib/circular-progress-styles.scss +8 -0
- package/circularprogress/lib/circular-progress.d.ts +29 -0
- package/circularprogress/lib/circular-progress.js +98 -0
- package/circularprogress/lib/circular-progress.js.map +1 -0
- package/dialog/lib/_dialog.scss +1 -6
- package/dialog/lib/dialog-styles.css.js +1 -1
- package/dialog/lib/dialog-styles.css.js.map +1 -1
- package/dialog/lib/dialog.js +1 -1
- package/dialog/lib/dialog.js.map +1 -1
- package/elevation/lib/_elevation.scss +13 -48
- package/elevation/lib/elevation-styles.css.js +1 -1
- package/elevation/lib/elevation-styles.css.js.map +1 -1
- package/elevation/lib/elevation.d.ts +0 -8
- package/elevation/lib/elevation.js +1 -25
- package/elevation/lib/elevation.js.map +1 -1
- package/fab/lib/_shared.scss +18 -21
- package/fab/lib/fab-extended-styles.css.js +1 -1
- package/fab/lib/fab-extended-styles.css.js.map +1 -1
- package/fab/lib/fab-shared-styles.css.js +1 -1
- package/fab/lib/fab-shared-styles.css.js.map +1 -1
- package/fab/lib/fab-shared.js +1 -1
- package/fab/lib/fab-shared.js.map +1 -1
- package/fab/lib/fab-styles.css.js +1 -1
- package/fab/lib/fab-styles.css.js.map +1 -1
- package/field/lib/filled-styles.css.js +1 -1
- package/field/lib/filled-styles.css.js.map +1 -1
- package/field/lib/outlined-styles.css.js +1 -1
- package/field/lib/outlined-styles.css.js.map +1 -1
- package/focus/lib/_focus-ring.scss +30 -20
- package/focus/lib/focus-ring-styles.css.js +1 -1
- package/focus/lib/focus-ring-styles.css.js.map +1 -1
- package/focus/strong-focus.d.ts +11 -0
- package/focus/strong-focus.js +11 -1
- package/focus/strong-focus.js.map +1 -1
- package/iconbutton/filled-icon-button.js +1 -0
- package/iconbutton/filled-icon-button.js.map +1 -1
- package/iconbutton/filled-tonal-icon-button.js +1 -0
- package/iconbutton/filled-tonal-icon-button.js.map +1 -1
- package/iconbutton/harness.d.ts +1 -2
- package/iconbutton/harness.js.map +1 -1
- package/iconbutton/lib/filled-styles.css.js +1 -1
- package/iconbutton/lib/filled-styles.css.js.map +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js +1 -1
- package/iconbutton/lib/filled-tonal-styles.css.js.map +1 -1
- package/iconbutton/lib/icon-button.d.ts +33 -2
- package/iconbutton/lib/icon-button.js +104 -16
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/iconbutton/lib/outlined-styles.css.js +1 -1
- package/iconbutton/lib/outlined-styles.css.js.map +1 -1
- package/iconbutton/lib/standard-styles.css.js +1 -1
- package/iconbutton/lib/standard-styles.css.js.map +1 -1
- package/list/harness.d.ts +1 -0
- package/list/harness.js +1 -0
- package/list/harness.js.map +1 -1
- package/list/lib/_list.scss +0 -1
- package/list/lib/list-styles.css.js +1 -1
- package/list/lib/list-styles.css.js.map +1 -1
- package/list/lib/list.js +2 -0
- package/list/lib/list.js.map +1 -1
- package/list/lib/listitem/_list-item.scss +9 -13
- package/list/lib/listitem/forced-colors-styles.css.js +9 -0
- package/list/lib/listitem/forced-colors-styles.css.js.map +1 -0
- package/list/lib/listitem/forced-colors-styles.scss +23 -0
- package/list/lib/listitem/list-item-styles.css.js +1 -1
- package/list/lib/listitem/list-item-styles.css.js.map +1 -1
- package/list/lib/listitem/list-item.d.ts +3 -3
- package/list/lib/listitem/list-item.js +3 -3
- package/list/lib/listitem/list-item.js.map +1 -1
- package/list/list-item-link.js +2 -1
- package/list/list-item-link.js.map +1 -1
- package/list/list-item.js +2 -1
- package/list/list-item.js.map +1 -1
- package/menu/harness.d.ts +1 -0
- package/menu/harness.js +1 -0
- package/menu/harness.js.map +1 -1
- package/menu/lib/_menu.scss +5 -10
- package/menu/lib/forced-colors-styles.css.d.ts +1 -0
- package/menu/lib/forced-colors-styles.css.js +9 -0
- package/menu/lib/forced-colors-styles.css.js.map +1 -0
- package/menu/lib/forced-colors-styles.scss +12 -0
- package/menu/lib/menu-styles.css.js +1 -1
- package/menu/lib/menu-styles.css.js.map +1 -1
- package/menu/lib/menu.d.ts +12 -1
- package/menu/lib/menu.js +42 -4
- package/menu/lib/menu.js.map +1 -1
- package/menu/lib/menuitem/_menu-item.scss +5 -11
- package/menu/lib/menuitem/forced-colors-styles.css.d.ts +1 -0
- package/menu/lib/menuitem/forced-colors-styles.css.js +9 -0
- package/menu/lib/menuitem/forced-colors-styles.css.js.map +1 -0
- package/menu/lib/menuitem/forced-colors-styles.scss +22 -0
- package/menu/lib/menuitem/menu-item-styles.css.js +1 -1
- package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/lib/shared.d.ts +10 -0
- package/menu/lib/shared.js +23 -0
- package/menu/lib/shared.js.map +1 -1
- package/menu/lib/submenuitem/sub-menu-item.d.ts +4 -0
- package/menu/lib/submenuitem/sub-menu-item.js +12 -0
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
- package/menu/lib/typeaheadController.d.ts +10 -2
- package/menu/lib/typeaheadController.js +20 -14
- package/menu/lib/typeaheadController.js.map +1 -1
- package/menu/menu-item-link.js +3 -1
- package/menu/menu-item-link.js.map +1 -1
- package/menu/menu-item.js +4 -2
- package/menu/menu-item.js.map +1 -1
- package/menu/menu.js +2 -1
- package/menu/menu.js.map +1 -1
- package/menu/sub-menu-item.js +3 -1
- package/menu/sub-menu-item.js.map +1 -1
- package/navigationbar/lib/_navigation-bar.scss +3 -6
- package/navigationbar/lib/navigation-bar-styles.css.js +1 -1
- package/navigationbar/lib/navigation-bar-styles.css.js.map +1 -1
- package/navigationbar/lib/navigation-bar.js +2 -2
- package/navigationbar/lib/navigation-bar.js.map +1 -1
- package/navigationdrawer/lib/_navigation-drawer-modal.scss +10 -11
- package/navigationdrawer/lib/_navigation-drawer.scss +9 -14
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-modal-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js +1 -1
- package/navigationdrawer/lib/navigation-drawer-styles.css.js.map +1 -1
- package/navigationdrawer/lib/navigation-drawer.js +1 -1
- package/navigationdrawer/lib/navigation-drawer.js.map +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js +1 -1
- package/navigationtab/lib/navigation-tab-styles.css.js.map +1 -1
- package/package.json +2 -1
- package/radio/lib/radio-styles.css.js +1 -1
- package/radio/lib/radio-styles.css.js.map +1 -1
- package/ripple/lib/_md-comp-ripple.scss +3 -3
- package/ripple/lib/ripple-styles.css.js +1 -1
- package/ripple/lib/ripple-styles.css.js.map +1 -1
- package/segmentedbutton/lib/outlined-styles.css.js +1 -1
- package/segmentedbutton/lib/outlined-styles.css.js.map +1 -1
- package/segmentedbuttonset/lib/outlined-styles.css.js +1 -1
- package/segmentedbuttonset/lib/outlined-styles.css.js.map +1 -1
- package/slider/lib/_slider.scss +1 -7
- package/slider/lib/_tokens.scss +5 -0
- package/slider/lib/slider-styles.css.js +1 -1
- package/slider/lib/slider-styles.css.js.map +1 -1
- package/slider/lib/slider.js +1 -1
- package/slider/lib/slider.js.map +1 -1
- package/switch/lib/switch-styles.css.js +1 -1
- package/switch/lib/switch-styles.css.js.map +1 -1
- package/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/tokens/_index.scss +3 -0
- package/tokens/_md-comp-assist-chip.scss +69 -14
- package/tokens/_md-comp-badge.scss +8 -1
- package/tokens/_md-comp-banner.scss +1 -1
- package/tokens/_md-comp-bottom-app-bar.scss +1 -1
- package/tokens/_md-comp-carousel-item.scss +1 -1
- package/tokens/_md-comp-checkbox.scss +1 -1
- package/tokens/_md-comp-circular-progress-indicator.scss +17 -2
- package/tokens/_md-comp-data-table.scss +1 -1
- package/tokens/_md-comp-date-input-modal.scss +1 -1
- package/tokens/_md-comp-date-picker-docked.scss +1 -1
- package/tokens/_md-comp-date-picker-modal.scss +1 -1
- package/tokens/_md-comp-dialog.scss +10 -1
- package/tokens/_md-comp-divider.scss +1 -1
- package/tokens/_md-comp-elevated-button.scss +80 -20
- package/tokens/_md-comp-elevated-card.scss +1 -1
- package/tokens/_md-comp-elevation.scss +28 -0
- package/tokens/_md-comp-extended-fab-branded.scss +8 -1
- package/tokens/_md-comp-extended-fab-primary.scss +8 -1
- package/tokens/_md-comp-extended-fab-secondary.scss +8 -1
- package/tokens/_md-comp-extended-fab-surface.scss +8 -1
- package/tokens/_md-comp-extended-fab-tertiary.scss +8 -1
- package/tokens/_md-comp-fab-branded-large.scss +1 -1
- package/tokens/_md-comp-fab-branded.scss +1 -1
- package/tokens/_md-comp-fab-primary-large.scss +1 -1
- package/tokens/_md-comp-fab-primary-small.scss +1 -1
- package/tokens/_md-comp-fab-primary.scss +1 -1
- package/tokens/_md-comp-fab-secondary-large.scss +1 -1
- package/tokens/_md-comp-fab-secondary-small.scss +1 -1
- package/tokens/_md-comp-fab-secondary.scss +1 -1
- package/tokens/_md-comp-fab-surface-large.scss +1 -1
- package/tokens/_md-comp-fab-surface-small.scss +1 -1
- package/tokens/_md-comp-fab-surface.scss +1 -1
- package/tokens/_md-comp-fab-tertiary-large.scss +1 -1
- package/tokens/_md-comp-fab-tertiary-small.scss +1 -1
- package/tokens/_md-comp-fab-tertiary.scss +1 -1
- package/tokens/_md-comp-filled-autocomplete.scss +1 -1
- package/tokens/_md-comp-filled-button.scss +80 -20
- package/tokens/_md-comp-filled-card.scss +1 -1
- package/tokens/_md-comp-filled-icon-button.scss +1 -1
- package/tokens/_md-comp-filled-menu-button.scss +1 -1
- package/tokens/_md-comp-filled-select.scss +1 -1
- package/tokens/_md-comp-filled-text-field.scss +10 -1
- package/tokens/_md-comp-filled-tonal-button.scss +80 -20
- package/tokens/_md-comp-filled-tonal-icon-button.scss +1 -1
- package/tokens/_md-comp-filter-chip.scss +201 -11
- package/tokens/_md-comp-focus-ring.scss +46 -0
- package/tokens/_md-comp-full-screen-dialog.scss +1 -1
- package/tokens/_md-comp-icon-button.scss +1 -1
- package/tokens/_md-comp-input-chip.scss +194 -11
- package/tokens/_md-comp-linear-progress-indicator.scss +1 -1
- package/tokens/_md-comp-list.scss +18 -1
- package/tokens/_md-comp-menu.scss +1 -1
- package/tokens/_md-comp-navigation-bar.scss +1 -1
- package/tokens/_md-comp-navigation-drawer.scss +1 -1
- package/tokens/_md-comp-navigation-rail.scss +1 -1
- package/tokens/_md-comp-outlined-autocomplete.scss +1 -1
- package/tokens/_md-comp-outlined-button.scss +77 -19
- package/tokens/_md-comp-outlined-card.scss +1 -1
- package/tokens/_md-comp-outlined-icon-button.scss +1 -1
- package/tokens/_md-comp-outlined-menu-button.scss +1 -1
- package/tokens/_md-comp-outlined-segmented-button.scss +10 -1
- package/tokens/_md-comp-outlined-select.scss +1 -1
- package/tokens/_md-comp-outlined-text-field.scss +10 -1
- package/tokens/_md-comp-plain-tooltip.scss +1 -1
- package/tokens/_md-comp-primary-navigation-tab.scss +10 -1
- package/tokens/_md-comp-radio-button.scss +1 -1
- package/tokens/_md-comp-rich-tooltip.scss +1 -1
- package/tokens/_md-comp-scrim.scss +1 -1
- package/tokens/_md-comp-search-bar.scss +1 -1
- package/tokens/_md-comp-search-view.scss +1 -1
- package/tokens/_md-comp-secondary-navigation-tab.scss +9 -1
- package/tokens/_md-comp-sheet-bottom.scss +1 -1
- package/tokens/_md-comp-sheet-floating.scss +1 -1
- package/tokens/_md-comp-sheet-side.scss +1 -1
- package/tokens/_md-comp-slider.scss +10 -1
- package/tokens/_md-comp-snackbar.scss +1 -1
- package/tokens/_md-comp-standard-menu-button.scss +1 -1
- package/tokens/_md-comp-suggestion-chip.scss +65 -14
- package/tokens/_md-comp-switch.scss +1 -1
- package/tokens/_md-comp-test-table.scss +31 -0
- package/tokens/_md-comp-text-button.scss +70 -19
- package/tokens/_md-comp-time-input.scss +1 -1
- package/tokens/_md-comp-time-picker.scss +1 -1
- package/tokens/_md-comp-top-app-bar-large.scss +1 -1
- package/tokens/_md-comp-top-app-bar-medium.scss +1 -1
- package/tokens/_md-comp-top-app-bar-small-centered.scss +1 -1
- package/tokens/_md-comp-top-app-bar-small.scss +1 -1
- package/tokens/_md-ref-palette.scss +1 -1
- package/tokens/_md-ref-typeface.scss +24 -2
- package/tokens/_md-sys-color.scss +1 -1
- package/tokens/_md-sys-elevation.scss +1 -1
- package/tokens/_md-sys-motion.scss +1 -1
- package/tokens/_md-sys-shape.scss +1 -1
- package/tokens/_md-sys-state.scss +1 -1
- package/tokens/_md-sys-typescale.scss +36 -2
- package/tokens/_values.scss +111 -0
- package/tokens/{v0_161 → v0_172}/_md-comp-assist-chip.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-badge.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-banner.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-bottom-app-bar.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-carousel-item.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-checkbox.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-circular-progress-indicator.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-data-table.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-date-input-modal.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-docked.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-date-picker-modal.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-dialog.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-divider.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-elevated-button.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-elevated-card.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-branded.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-primary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-secondary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-surface.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-extended-fab-tertiary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded-large.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-branded.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-primary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-secondary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-large.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface-small.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-surface.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-large.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary-small.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-fab-tertiary.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-autocomplete.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-card.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-icon-button.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-select.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-text-field.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-filled-tonal-icon-button.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-filter-chip.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-full-screen-dialog.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-icon-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-input-chip.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-linear-progress-indicator.scss +2 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-list.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-menu.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-bar.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-drawer.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-navigation-rail.scss +1 -16
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-autocomplete.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-card.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-icon-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-segmented-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-select.scss +4 -6
- package/tokens/{v0_161 → v0_172}/_md-comp-outlined-text-field.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-plain-tooltip.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-primary-navigation-tab.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-radio-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-rich-tooltip.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-scrim.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-search-bar.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-search-view.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-secondary-navigation-tab.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-bottom.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-floating.scss +3 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-sheet-side.scss +4 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-slider.scss +3 -2
- package/tokens/{v0_161 → v0_172}/_md-comp-snackbar.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-standard-menu-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-suggestion-chip.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-switch.scss +13 -11
- package/tokens/{v0_161 → v0_172}/_md-comp-text-button.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-time-input.scss +3 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-time-picker.scss +5 -5
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-large.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-medium.scss +1 -3
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small-centered.scss +3 -1
- package/tokens/{v0_161 → v0_172}/_md-comp-top-app-bar-small.scss +3 -3
- package/tokens/{v0_161 → v0_172}/_md-ref-palette.scss +23 -23
- package/tokens/{v0_161 → v0_172}/_md-ref-typeface.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-color.scss +9 -9
- package/tokens/{v0_161 → v0_172}/_md-sys-elevation.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-motion.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-shape.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-state.scss +1 -1
- package/tokens/{v0_161 → v0_172}/_md-sys-typescale.scss +1 -1
- package/tokens/v0_172/index.test.css.d.ts +1 -0
- package/tokens/v0_172/lib.test.css.d.ts +1 -0
- package/button/elevated-link-button.d.ts +0 -36
- package/button/elevated-link-button.js +0 -41
- package/button/elevated-link-button.js.map +0 -1
- package/button/filled-link-button.d.ts +0 -34
- package/button/filled-link-button.js +0 -39
- package/button/filled-link-button.js.map +0 -1
- package/button/lib/elevated-link-button.d.ts +0 -13
- package/button/lib/elevated-link-button.js +0 -21
- package/button/lib/elevated-link-button.js.map +0 -1
- package/button/lib/filled-link-button.d.ts +0 -14
- package/button/lib/filled-link-button.js +0 -22
- package/button/lib/filled-link-button.js.map +0 -1
- package/button/lib/link-button.d.ts +0 -24
- package/button/lib/link-button.js +0 -59
- package/button/lib/link-button.js.map +0 -1
- package/button/lib/outlined-link-button.d.ts +0 -12
- package/button/lib/outlined-link-button.js +0 -20
- package/button/lib/outlined-link-button.js.map +0 -1
- package/button/lib/text-link-button.d.ts +0 -10
- package/button/lib/text-link-button.js +0 -16
- package/button/lib/text-link-button.js.map +0 -1
- package/button/lib/tonal-link-button.d.ts +0 -14
- package/button/lib/tonal-link-button.js +0 -22
- package/button/lib/tonal-link-button.js.map +0 -1
- package/button/outlined-link-button.d.ts +0 -36
- package/button/outlined-link-button.js +0 -40
- package/button/outlined-link-button.js.map +0 -1
- package/button/text-link-button.d.ts +0 -34
- package/button/text-link-button.js +0 -38
- package/button/text-link-button.js.map +0 -1
- package/button/tonal-link-button.d.ts +0 -35
- package/button/tonal-link-button.js +0 -40
- package/button/tonal-link-button.js.map +0 -1
- package/elevation/lib/_md-comp-elevation.scss +0 -27
- package/focus/lib/_md-comp-focus-ring.scss +0 -30
- package/iconbutton/filled-icon-button-toggle.d.ts +0 -31
- package/iconbutton/filled-icon-button-toggle.js +0 -40
- package/iconbutton/filled-icon-button-toggle.js.map +0 -1
- package/iconbutton/filled-link-icon-button.d.ts +0 -31
- package/iconbutton/filled-link-icon-button.js +0 -39
- package/iconbutton/filled-link-icon-button.js.map +0 -1
- package/iconbutton/filled-tonal-icon-button-toggle.d.ts +0 -31
- package/iconbutton/filled-tonal-icon-button-toggle.js +0 -40
- package/iconbutton/filled-tonal-icon-button-toggle.js.map +0 -1
- package/iconbutton/filled-tonal-link-icon-button.d.ts +0 -31
- package/iconbutton/filled-tonal-link-icon-button.js +0 -39
- package/iconbutton/filled-tonal-link-icon-button.js.map +0 -1
- package/iconbutton/lib/icon-button-toggle.d.ts +0 -34
- package/iconbutton/lib/icon-button-toggle.js +0 -87
- package/iconbutton/lib/icon-button-toggle.js.map +0 -1
- package/iconbutton/lib/link-icon-button.d.ts +0 -23
- package/iconbutton/lib/link-icon-button.js +0 -58
- package/iconbutton/lib/link-icon-button.js.map +0 -1
- package/iconbutton/outlined-icon-button-toggle.d.ts +0 -31
- package/iconbutton/outlined-icon-button-toggle.js +0 -39
- package/iconbutton/outlined-icon-button-toggle.js.map +0 -1
- package/iconbutton/outlined-link-icon-button.d.ts +0 -31
- package/iconbutton/outlined-link-icon-button.js +0 -39
- package/iconbutton/outlined-link-icon-button.js.map +0 -1
- package/iconbutton/standard-icon-button-toggle.d.ts +0 -31
- package/iconbutton/standard-icon-button-toggle.js +0 -39
- package/iconbutton/standard-icon-button-toggle.js.map +0 -1
- package/iconbutton/standard-link-icon-button.d.ts +0 -31
- package/iconbutton/standard-link-icon-button.js +0 -39
- package/iconbutton/standard-link-icon-button.js.map +0 -1
- /package/{tokens/v0_161/index.test.css.d.ts → circularprogress/lib/circular-progress-styles.css.d.ts} +0 -0
- /package/{tokens/v0_161/lib.test.css.d.ts → list/lib/listitem/forced-colors-styles.css.d.ts} +0 -0
- /package/tokens/{v0_161 → v0_172}/_index.scss +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.css.js +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.css.js.map +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.scss +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.css.js +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.css.js.map +0 -0
- /package/tokens/{v0_161 → v0_172}/lib.test.scss +0 -0
|
@@ -40,6 +40,10 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
40
40
|
* The delay between ponterleave and the submenu closing.
|
|
41
41
|
*/
|
|
42
42
|
this.hoverCloseDelay = 400;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the item in the selected visual state when a submenu is opened.
|
|
45
|
+
*/
|
|
46
|
+
this.selected = false;
|
|
43
47
|
this.keepOpenOnClick = true;
|
|
44
48
|
this.previousOpenTimeout = 0;
|
|
45
49
|
this.previousCloseTimeout = 0;
|
|
@@ -138,11 +142,13 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
138
142
|
e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {
|
|
139
143
|
e.stopPropagation();
|
|
140
144
|
this.active = true;
|
|
145
|
+
this.selected = false;
|
|
141
146
|
// It might already be active so manually focus
|
|
142
147
|
this.listItemRoot.focus();
|
|
143
148
|
return;
|
|
144
149
|
}
|
|
145
150
|
this.active = false;
|
|
151
|
+
this.selected = false;
|
|
146
152
|
}
|
|
147
153
|
async onSubMenuKeydown(e) {
|
|
148
154
|
// Stop propagation so that we don't accidentally close every parent menu.
|
|
@@ -187,6 +193,7 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
187
193
|
this.dispatchEvent(new DeactivateItemsEvent());
|
|
188
194
|
this.dispatchEvent(new DeactivateTypeaheadEvent());
|
|
189
195
|
this.active = true;
|
|
196
|
+
this.selected = true;
|
|
190
197
|
// This is the case of mouse hovering when already opened via keyboard or
|
|
191
198
|
// vice versa
|
|
192
199
|
if (menuAlreadyOpen) {
|
|
@@ -209,6 +216,7 @@ export class SubMenuItem extends MenuItemEl {
|
|
|
209
216
|
menu.quick = true;
|
|
210
217
|
menu.close();
|
|
211
218
|
this.active = false;
|
|
219
|
+
this.selected = false;
|
|
212
220
|
menu.addEventListener('closed', onClosed, { once: true });
|
|
213
221
|
}
|
|
214
222
|
/**
|
|
@@ -265,6 +273,10 @@ __decorate([
|
|
|
265
273
|
property({ type: Number, attribute: 'hover-close-delay' }),
|
|
266
274
|
__metadata("design:type", Object)
|
|
267
275
|
], SubMenuItem.prototype, "hoverCloseDelay", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
property({ type: Boolean, reflect: true }),
|
|
278
|
+
__metadata("design:type", Object)
|
|
279
|
+
], SubMenuItem.prototype, "selected", void 0);
|
|
268
280
|
__decorate([
|
|
269
281
|
queryAssignedElements({ slot: 'submenu', flatten: true }),
|
|
270
282
|
__metadata("design:type", Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAC,IAAI,EAAC,MAAM,2BAA2B,CAAC;AAG/C,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAE,YAAY,EAAkB,oBAAo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S,EAAE,kBAAkB,EAAC,CAAC;;mDAAsB;AAI9E;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;;oDACnC;AAEtB;IAAC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;0CAC/B","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {List} from '../../../list/lib/list.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {Corner, Menu} from '../menu.js';\nimport {MenuItemEl} from '../menuitem/menu-item.js';\nimport {ActivateTypeaheadEvent, CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, DeactivateTypeaheadEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY} from '../shared.js';\n\nfunction stopPropagation(e: Event) {\n e.stopPropagation();\n}\n\n/**\n * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to\n * deselect other items when a submenu opens\n * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu\n * to deactivate the typeahead functionality when a submenu opens\n * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to\n * activate the typeahead functionality when a submenu closes\n */\nexport class SubMenuItem extends MenuItemEl {\n override role: ARIARole = 'menuitem';\n /**\n * The anchorCorner to set on the submenu.\n */\n @property({attribute: 'anchor-corner'}) anchorCorner: Corner = 'START_END';\n /**\n * The menuCorner to set on the submenu.\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = 'START_START';\n /**\n * The delay between pointerenter and submenu opening.\n */\n @property({type: Number, attribute: 'hover-open-delay'}) hoverOpenDelay = 400;\n /**\n * The delay between ponterleave and the submenu closing.\n */\n @property({type: Number, attribute: 'hover-close-delay'})\n hoverCloseDelay = 400;\n\n @queryAssignedElements({slot: 'submenu', flatten: true})\n protected menus!: Menu[];\n\n protected override keepOpenOnClick = true;\n protected previousOpenTimeout = 0;\n protected previousCloseTimeout = 0;\n\n protected get submenuEl(): Menu|undefined {\n return this.menus[0];\n }\n\n /**\n * Starts the default 400ms countdown to open the submenu.\n */\n protected override onPointerenter = () => {\n clearTimeout(this.previousOpenTimeout);\n clearTimeout(this.previousCloseTimeout);\n if (this.submenuEl?.open) return;\n\n // Open synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverOpenDelay) {\n this.show();\n } else {\n this.previousOpenTimeout = setTimeout(() => {\n this.show();\n }, this.hoverOpenDelay);\n }\n };\n\n /**\n * Starts the default 400ms countdown to close the submenu.\n */\n protected override onPointerleave = () => {\n clearTimeout(this.previousCloseTimeout);\n clearTimeout(this.previousOpenTimeout);\n\n // Close synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverCloseDelay) {\n this.close();\n } else {\n this.previousCloseTimeout = setTimeout(() => {\n this.close();\n }, this.hoverCloseDelay);\n }\n };\n\n protected override onClick() {\n this.show();\n }\n\n /**\n * On item keydown handles opening the submenu.\n */\n protected override onKeydown(e: KeyboardEvent) {\n const shouldOpenSubmenu = this.isSubmenuOpenKey(e.code);\n\n if (e.code === SELECTION_KEY.SPACE) {\n // prevent space from scrolling. Only open the submenu.\n e.preventDefault();\n }\n\n if (!shouldOpenSubmenu) {\n super.onKeydown(e);\n return;\n }\n\n const submenu = this.submenuEl;\n if (!submenu) return;\n\n const submenuItems = submenu.items;\n const firstActivatableItem = List.getFirstActivatableItem(submenuItems);\n\n if (firstActivatableItem) {\n this.show(() => {\n firstActivatableItem.active = true;\n });\n\n return;\n }\n }\n\n /**\n * Render the submenu at the end\n */\n protected override renderEnd() {\n return html`${super.renderEnd()}${this.renderSubMenu()}`;\n }\n\n /**\n * Renders the slot for the submenu.\n */\n protected renderSubMenu() {\n return html`<span class=\"submenu\"><slot\n name=\"submenu\"\n @pointerdown=${stopPropagation}\n @click=${stopPropagation}\n @keydown=${this.onSubMenuKeydown}\n @close-menu=${this.onCloseSubmenu}\n ></slot></span>`;\n }\n\n protected onCloseSubmenu(e: CloseMenuEvent) {\n e.itemPath.push(this);\n this.dispatchEvent(new ActivateTypeaheadEvent());\n // Escape should only close one menu not all of the menus unlike space or\n // click selection which should close all menus.\n if (e.reason.kind === CLOSE_REASON.KEYDOWN &&\n e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {\n e.stopPropagation();\n this.active = true;\n // It might already be active so manually focus\n this.listItemRoot.focus();\n return;\n }\n\n this.active = false;\n }\n\n protected async onSubMenuKeydown(e: KeyboardEvent) {\n // Stop propagation so that we don't accidentally close every parent menu.\n // Additionally, we want to isolate things like the typeahead keydowns\n // from bubbling up to the parent menu and confounding things.\n e.stopPropagation();\n const shouldClose = this.isSubmenuCloseKey(e.code);\n\n if (!shouldClose) return;\n\n this.close(() => {\n List.deactivateActiveItem(this.submenuEl!.items);\n this.listItemRoot.focus();\n this.active = true;\n });\n }\n\n /**\n * Shows the submenu.\n *\n * @param onOpened A function to call after the menu is opened.\n */\n show(onOpened = () => {}) {\n const menu = this.submenuEl;\n if (!menu) return;\n\n menu.quick = true;\n // Submenus are in overflow when not fixed. Can remove once we have native\n // popup support\n menu.hasOverflow = true;\n menu.anchorCorner = this.anchorCorner;\n menu.menuCorner = this.menuCorner;\n menu.anchor = this;\n // We manually set focus with `active` on keyboard navigation. And we\n // want to focus the root on hover, so the user can pick up navigation with\n // keyboard after hover.\n menu.defaultFocus = 'LIST_ROOT';\n menu.skipRestoreFocus = true;\n\n // Menu could already be opened because of mouse interaction\n const menuAlreadyOpen = menu.open;\n menu.show();\n\n // Deactivate other items. This can be the case if the user has tabbed\n // around the menu and then mouses over an md-sub-menu.\n this.dispatchEvent(new DeactivateItemsEvent());\n this.dispatchEvent(new DeactivateTypeaheadEvent());\n this.active = true;\n\n // This is the case of mouse hovering when already opened via keyboard or\n // vice versa\n if (menuAlreadyOpen) {\n onOpened();\n } else {\n menu.addEventListener('opened', onOpened, {once: true});\n }\n }\n\n /**\n * Closes the submenu.\n *\n * @param onClosed A function to call after the menu is closed.\n */\n close(onClosed = () => {}) {\n const menu = this.submenuEl;\n if (!menu || !menu.open) return;\n\n this.dispatchEvent(new ActivateTypeaheadEvent());\n menu.quick = true;\n menu.close();\n this.active = false;\n menu.addEventListener('closed', onClosed, {once: true});\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should open\n * the submenu. This is RTL-aware. By default, left, right, space, or enter.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should open the submenu.\n */\n protected isSubmenuOpenKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.LEFT : NAVIGABLE_KEY.RIGHT;\n switch (code) {\n case arrowEnterKey:\n case SELECTION_KEY.SPACE:\n case SELECTION_KEY.ENTER:\n return true;\n default:\n return false;\n }\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should close\n * the submenu. This is RTL-aware. By default right, left, or escape.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should close the submenu.\n */\n protected isSubmenuCloseKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.RIGHT : NAVIGABLE_KEY.LEFT;\n switch (code) {\n case arrowEnterKey:\n case KEYDOWN_CLOSE_KEYS.ESCAPE:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAC,IAAI,EAAC,MAAM,2BAA2B,CAAC;AAG/C,OAAO,EAAC,UAAU,EAAC,MAAM,0B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BAC5B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF;AA9PC;IAAC,QAAQ,CAAC,EAAC,SAAS,EAAE,eAAe,EAAC,CAAC;;iDAAoC;AAI3E;IAAC,QAAQ,CAAC,EAAC,SAAS,EAAE,aAAa,EAAC,CAAC;;+CAAoC;AAIzE;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAC,CAAC;;mDAAsB;AAI9E;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAC,CAAC;;oDACnC;AAItB;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;6CAAkB;AAE3D;IAAC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;0CAC/B","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {html} from 'lit';\nimport {property, queryAssignedElements} from 'lit/decorators.js';\n\nimport {List} from '../../../list/lib/list.js';\nimport {ARIARole} from '../../../types/aria.js';\nimport {Corner, Menu} from '../menu.js';\nimport {MenuItemEl} from '../menuitem/menu-item.js';\nimport {ActivateTypeaheadEvent, CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, DeactivateTypeaheadEvent, KEYDOWN_CLOSE_KEYS, NAVIGABLE_KEY, SELECTION_KEY} from '../shared.js';\n\nfunction stopPropagation(e: Event) {\n e.stopPropagation();\n}\n\n/**\n * @fires deactivate-items {DeactivateItemsEvent} Requests the parent menu to\n * deselect other items when a submenu opens\n * @fires deactivate-typeahead {DeactivateItemsEvent} Requests the parent menu\n * to deactivate the typeahead functionality when a submenu opens\n * @fires activate-typeahead {DeactivateItemsEvent} Requests the parent menu to\n * activate the typeahead functionality when a submenu closes\n */\nexport class SubMenuItem extends MenuItemEl {\n override role: ARIARole = 'menuitem';\n /**\n * The anchorCorner to set on the submenu.\n */\n @property({attribute: 'anchor-corner'}) anchorCorner: Corner = 'START_END';\n /**\n * The menuCorner to set on the submenu.\n */\n @property({attribute: 'menu-corner'}) menuCorner: Corner = 'START_START';\n /**\n * The delay between pointerenter and submenu opening.\n */\n @property({type: Number, attribute: 'hover-open-delay'}) hoverOpenDelay = 400;\n /**\n * The delay between ponterleave and the submenu closing.\n */\n @property({type: Number, attribute: 'hover-close-delay'})\n hoverCloseDelay = 400;\n /**\n * Sets the item in the selected visual state when a submenu is opened.\n */\n @property({type: Boolean, reflect: true}) selected = false;\n\n @queryAssignedElements({slot: 'submenu', flatten: true})\n protected menus!: Menu[];\n\n protected override keepOpenOnClick = true;\n protected previousOpenTimeout = 0;\n protected previousCloseTimeout = 0;\n\n protected get submenuEl(): Menu|undefined {\n return this.menus[0];\n }\n\n /**\n * Starts the default 400ms countdown to open the submenu.\n */\n protected override onPointerenter = () => {\n clearTimeout(this.previousOpenTimeout);\n clearTimeout(this.previousCloseTimeout);\n if (this.submenuEl?.open) return;\n\n // Open synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverOpenDelay) {\n this.show();\n } else {\n this.previousOpenTimeout = setTimeout(() => {\n this.show();\n }, this.hoverOpenDelay);\n }\n };\n\n /**\n * Starts the default 400ms countdown to close the submenu.\n */\n protected override onPointerleave = () => {\n clearTimeout(this.previousCloseTimeout);\n clearTimeout(this.previousOpenTimeout);\n\n // Close synchronously if delay is 0. (screenshot tests infra\n // would never resolve otherwise)\n if (!this.hoverCloseDelay) {\n this.close();\n } else {\n this.previousCloseTimeout = setTimeout(() => {\n this.close();\n }, this.hoverCloseDelay);\n }\n };\n\n protected override onClick() {\n this.show();\n }\n\n /**\n * On item keydown handles opening the submenu.\n */\n protected override onKeydown(e: KeyboardEvent) {\n const shouldOpenSubmenu = this.isSubmenuOpenKey(e.code);\n\n if (e.code === SELECTION_KEY.SPACE) {\n // prevent space from scrolling. Only open the submenu.\n e.preventDefault();\n }\n\n if (!shouldOpenSubmenu) {\n super.onKeydown(e);\n return;\n }\n\n const submenu = this.submenuEl;\n if (!submenu) return;\n\n const submenuItems = submenu.items;\n const firstActivatableItem = List.getFirstActivatableItem(submenuItems);\n\n if (firstActivatableItem) {\n this.show(() => {\n firstActivatableItem.active = true;\n });\n\n return;\n }\n }\n\n /**\n * Render the submenu at the end\n */\n protected override renderEnd() {\n return html`${super.renderEnd()}${this.renderSubMenu()}`;\n }\n\n /**\n * Renders the slot for the submenu.\n */\n protected renderSubMenu() {\n return html`<span class=\"submenu\"><slot\n name=\"submenu\"\n @pointerdown=${stopPropagation}\n @click=${stopPropagation}\n @keydown=${this.onSubMenuKeydown}\n @close-menu=${this.onCloseSubmenu}\n ></slot></span>`;\n }\n\n protected onCloseSubmenu(e: CloseMenuEvent) {\n e.itemPath.push(this);\n this.dispatchEvent(new ActivateTypeaheadEvent());\n // Escape should only close one menu not all of the menus unlike space or\n // click selection which should close all menus.\n if (e.reason.kind === CLOSE_REASON.KEYDOWN &&\n e.reason.key === KEYDOWN_CLOSE_KEYS.ESCAPE) {\n e.stopPropagation();\n this.active = true;\n this.selected = false;\n // It might already be active so manually focus\n this.listItemRoot.focus();\n return;\n }\n\n this.active = false;\n this.selected = false;\n }\n\n protected async onSubMenuKeydown(e: KeyboardEvent) {\n // Stop propagation so that we don't accidentally close every parent menu.\n // Additionally, we want to isolate things like the typeahead keydowns\n // from bubbling up to the parent menu and confounding things.\n e.stopPropagation();\n const shouldClose = this.isSubmenuCloseKey(e.code);\n\n if (!shouldClose) return;\n\n this.close(() => {\n List.deactivateActiveItem(this.submenuEl!.items);\n this.listItemRoot.focus();\n this.active = true;\n });\n }\n\n /**\n * Shows the submenu.\n *\n * @param onOpened A function to call after the menu is opened.\n */\n show(onOpened = () => {}) {\n const menu = this.submenuEl;\n if (!menu) return;\n\n menu.quick = true;\n // Submenus are in overflow when not fixed. Can remove once we have native\n // popup support\n menu.hasOverflow = true;\n menu.anchorCorner = this.anchorCorner;\n menu.menuCorner = this.menuCorner;\n menu.anchor = this;\n // We manually set focus with `active` on keyboard navigation. And we\n // want to focus the root on hover, so the user can pick up navigation with\n // keyboard after hover.\n menu.defaultFocus = 'LIST_ROOT';\n menu.skipRestoreFocus = true;\n\n // Menu could already be opened because of mouse interaction\n const menuAlreadyOpen = menu.open;\n menu.show();\n\n // Deactivate other items. This can be the case if the user has tabbed\n // around the menu and then mouses over an md-sub-menu.\n this.dispatchEvent(new DeactivateItemsEvent());\n this.dispatchEvent(new DeactivateTypeaheadEvent());\n this.active = true;\n this.selected = true;\n\n // This is the case of mouse hovering when already opened via keyboard or\n // vice versa\n if (menuAlreadyOpen) {\n onOpened();\n } else {\n menu.addEventListener('opened', onOpened, {once: true});\n }\n }\n\n /**\n * Closes the submenu.\n *\n * @param onClosed A function to call after the menu is closed.\n */\n close(onClosed = () => {}) {\n const menu = this.submenuEl;\n if (!menu || !menu.open) return;\n\n this.dispatchEvent(new ActivateTypeaheadEvent());\n menu.quick = true;\n menu.close();\n this.active = false;\n this.selected = false;\n menu.addEventListener('closed', onClosed, {once: true});\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should open\n * the submenu. This is RTL-aware. By default, left, right, space, or enter.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should open the submenu.\n */\n protected isSubmenuOpenKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.LEFT : NAVIGABLE_KEY.RIGHT;\n switch (code) {\n case arrowEnterKey:\n case SELECTION_KEY.SPACE:\n case SELECTION_KEY.ENTER:\n return true;\n default:\n return false;\n }\n }\n\n /**\n * Determines whether the given KeyboardEvent code is one that should close\n * the submenu. This is RTL-aware. By default right, left, or escape.\n *\n * @param code The native KeyboardEvent code.\n * @return Whether or not the key code should close the submenu.\n */\n protected isSubmenuCloseKey(code: string) {\n const isRtl = getComputedStyle(this).direction === 'rtl';\n const arrowEnterKey = isRtl ? NAVIGABLE_KEY.RIGHT : NAVIGABLE_KEY.LEFT;\n switch (code) {\n case arrowEnterKey:\n case KEYDOWN_CLOSE_KEYS.ESCAPE:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
|
|
@@ -29,6 +29,14 @@ export interface TypeaheadControllerProperties {
|
|
|
29
29
|
* [index, item, normalized header text]
|
|
30
30
|
*/
|
|
31
31
|
type TypeaheadRecord = [number, MenuItem, string];
|
|
32
|
+
/**
|
|
33
|
+
* Indicies to access the TypeaheadRecord tuple type.
|
|
34
|
+
*/
|
|
35
|
+
export declare const TYPEAHEAD_RECORD: {
|
|
36
|
+
readonly INDEX: 0;
|
|
37
|
+
readonly ITEM: 1;
|
|
38
|
+
readonly TEXT: 2;
|
|
39
|
+
};
|
|
32
40
|
/**
|
|
33
41
|
* This controller listens to `keydown` events and searches the header text of
|
|
34
42
|
* an array of `MenuItem`s with the corresponding entered keys within the buffer
|
|
@@ -75,11 +83,11 @@ export declare class TypeaheadController {
|
|
|
75
83
|
/**
|
|
76
84
|
* If we are currently "typing"
|
|
77
85
|
*/
|
|
78
|
-
|
|
86
|
+
isTypingAhead: boolean;
|
|
79
87
|
/**
|
|
80
88
|
* The record of the last active item.
|
|
81
89
|
*/
|
|
82
|
-
|
|
90
|
+
lastActiveRecord: TypeaheadRecord | null;
|
|
83
91
|
/**
|
|
84
92
|
* @param getProperties A function that returns the options of the typeahead
|
|
85
93
|
* controller:
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
* Copyright 2023 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
6
|
+
/**
|
|
7
|
+
* Indicies to access the TypeaheadRecord tuple type.
|
|
8
|
+
*/
|
|
9
|
+
export const TYPEAHEAD_RECORD = {
|
|
10
|
+
INDEX: 0,
|
|
11
|
+
ITEM: 1,
|
|
12
|
+
TEXT: 2,
|
|
13
|
+
};
|
|
10
14
|
/**
|
|
11
15
|
* This controller listens to `keydown` events and searches the header text of
|
|
12
16
|
* an array of `MenuItem`s with the corresponding entered keys within the buffer
|
|
@@ -117,10 +121,10 @@ export class TypeaheadController {
|
|
|
117
121
|
// and a normalized header.
|
|
118
122
|
this.typeaheadRecords = this.items.map((el, index) => [index, el, el.headline.trim().toLowerCase()]);
|
|
119
123
|
this.lastActiveRecord =
|
|
120
|
-
this.typeaheadRecords.find(record => record[
|
|
124
|
+
this.typeaheadRecords.find(record => record[TYPEAHEAD_RECORD.ITEM].active) ??
|
|
121
125
|
null;
|
|
122
126
|
if (this.lastActiveRecord) {
|
|
123
|
-
this.lastActiveRecord[
|
|
127
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
124
128
|
}
|
|
125
129
|
this.typeahead(e);
|
|
126
130
|
}
|
|
@@ -168,7 +172,7 @@ export class TypeaheadController {
|
|
|
168
172
|
e.code === 'Escape') {
|
|
169
173
|
this.endTypeahead();
|
|
170
174
|
if (this.lastActiveRecord) {
|
|
171
|
-
this.lastActiveRecord[
|
|
175
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
172
176
|
}
|
|
173
177
|
return;
|
|
174
178
|
}
|
|
@@ -181,7 +185,9 @@ export class TypeaheadController {
|
|
|
181
185
|
this.cancelTypeaheadTimeout =
|
|
182
186
|
setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);
|
|
183
187
|
this.typaheadBuffer += e.key.toLowerCase();
|
|
184
|
-
const lastActiveIndex = this.lastActiveRecord ?
|
|
188
|
+
const lastActiveIndex = this.lastActiveRecord ?
|
|
189
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] :
|
|
190
|
+
-1;
|
|
185
191
|
const numRecords = this.typeaheadRecords.length;
|
|
186
192
|
/**
|
|
187
193
|
* Sorting function that will resort the items starting with the given index
|
|
@@ -206,13 +212,13 @@ export class TypeaheadController {
|
|
|
206
212
|
* 5: [2, <reference>, 'banana']
|
|
207
213
|
*/
|
|
208
214
|
const rebaseIndexOnActive = (record) => {
|
|
209
|
-
return (record[
|
|
215
|
+
return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %
|
|
210
216
|
numRecords;
|
|
211
217
|
};
|
|
212
218
|
// records filtered and sorted / rebased around the last active index
|
|
213
219
|
const matchingRecords = this.typeaheadRecords
|
|
214
|
-
.filter(record => !record[
|
|
215
|
-
record[
|
|
220
|
+
.filter(record => !record[TYPEAHEAD_RECORD.ITEM].disabled &&
|
|
221
|
+
record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer))
|
|
216
222
|
.sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));
|
|
217
223
|
// Just leave if there's nothing that matches. Native select will just
|
|
218
224
|
// choose the first thing that starts with the next letter in the alphabet
|
|
@@ -220,7 +226,7 @@ export class TypeaheadController {
|
|
|
220
226
|
if (matchingRecords.length === 0) {
|
|
221
227
|
clearTimeout(this.cancelTypeaheadTimeout);
|
|
222
228
|
if (this.lastActiveRecord) {
|
|
223
|
-
this.lastActiveRecord[
|
|
229
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
224
230
|
}
|
|
225
231
|
this.endTypeahead();
|
|
226
232
|
return;
|
|
@@ -236,10 +242,10 @@ export class TypeaheadController {
|
|
|
236
242
|
nextRecord = matchingRecords[0];
|
|
237
243
|
}
|
|
238
244
|
if (this.lastActiveRecord) {
|
|
239
|
-
this.lastActiveRecord[
|
|
245
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
240
246
|
}
|
|
241
247
|
this.lastActiveRecord = nextRecord;
|
|
242
|
-
nextRecord[
|
|
248
|
+
nextRecord[TYPEAHEAD_RECORD.ITEM].active = true;
|
|
243
249
|
return;
|
|
244
250
|
}
|
|
245
251
|
}
|
|
@@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C,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzE,sEAAsE;QACtE,0EAA0E;QAC1E,+CAA+C;QAC/C,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1C,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACzB,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;aACtD;YACD,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,OAAO;SACR;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC;QACpD,IAAI,UAA2B,CAAC;QAEhC,4EAA4E;QAC5E,0CAA0C;QAC1C,IAAI,IAAI,CAAC,gBAAgB,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;YAC9D,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;SACvD;aAAM;YACL,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;SACjC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;SACtD;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,UAAU,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QACzC,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './shared.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n// Indicies to access the TypeaheadRecord tuple\nconst TYPEAHEAD_INDEX = 0;\nconst TYPEAHEAD_ITEM = 1;\nconst TYPEAHEAD_TEXT = 2;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n protected typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n protected typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n protected cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n protected isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n protected lastActiveRecord: TypeaheadRecord|null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n protected getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n protected get items() {\n return this.getProperties().getItems();\n }\n\n protected get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param e The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (e: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(e);\n } else {\n this.beginTypeahead(e);\n }\n };\n\n /**\n * Sets up typingahead\n */\n protected beginTypeahead(e: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (e.code === 'Space' || e.code === 'Enter' ||\n e.code.startsWith('Arrow') || e.code === 'Escape') {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map(\n (el, index) => [index, el, el.headline.trim().toLowerCase()]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(record => record[TYPEAHEAD_ITEM].active) ??\n null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n this.typeahead(e);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n protected typeahead(e: KeyboardEvent) {\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (e.code === 'Enter' || e.code.startsWith('Arrow') ||\n e.code === 'Escape') {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (e.code === 'Space') {\n e.stopPropagation();\n e.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout =\n setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);\n\n this.typaheadBuffer += e.key.toLowerCase();\n\n const lastActiveIndex =\n this.lastActiveRecord ? this.lastActiveRecord[TYPEAHEAD_INDEX] : -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (record[TYPEAHEAD_INDEX] + numRecords - lastActiveIndex) %\n numRecords;\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords =\n this.typeaheadRecords\n .filter(\n record => !record[TYPEAHEAD_ITEM].disabled &&\n record[TYPEAHEAD_TEXT].startsWith(this.typaheadBuffer))\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_ITEM].active = true;\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n protected endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8BH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACC,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,mBAAmB;IAsB9B;;;;;;;;;OASG;IACH,YACc,aAAkD;QAAlD,kBAAa,GAAb,aAAa,CAAqC;QAhChE;;WAEG;QACO,qBAAgB,GAAsB,EAAE,CAAC;QACnD;;WAEG;QACO,mBAAc,GAAG,EAAE,CAAC;QAC9B;;WAEG;QACO,2BAAsB,GAAG,CAAC,CAAC;QACrC;;WAEG;QACH,kBAAa,GAAG,KAAK,CAAC;QACtB;;WAEG;QACH,qBAAgB,GAAyB,IAAI,CAAC;QAwB9C;;;;;WAKG;QACM,cAAS,GAAG,CAAC,CAAgB,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,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AAE;YAC9D,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC;SACvD;aAAM;YACL,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;SACjC;QAED,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;SAC7D;QAED,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;QACnC,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;QAChD,OAAO;IACT,CAAC;CAUF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {MenuItem} from './shared.js';\n\n/**\n * The options that are passed to the typeahead controller.\n */\nexport interface TypeaheadControllerProperties {\n /**\n * A function that returns an array of menu items to be searched.\n * @return An array of menu items to be searched by typing.\n */\n getItems: () => MenuItem[];\n /**\n * The maximum time between each keystroke to keep the current type buffer\n * alive.\n */\n typeaheadBufferTime: number;\n /**\n * Whether or not the typeahead should listen for keystrokes or not.\n */\n active: boolean;\n}\n\n/**\n * Data structure tuple that helps with indexing.\n *\n * [index, item, normalized header text]\n */\ntype TypeaheadRecord = [number, MenuItem, string];\n/**\n * Indicies to access the TypeaheadRecord tuple type.\n */\nexport const TYPEAHEAD_RECORD = {\n INDEX: 0,\n ITEM: 1,\n TEXT: 2,\n} as const;\n\n/**\n * This controller listens to `keydown` events and searches the header text of\n * an array of `MenuItem`s with the corresponding entered keys within the buffer\n * time and activates the item.\n *\n * @example\n * ```ts\n * const typeaheadController = new TypeaheadController(() => ({\n * typeaheadBufferTime: 50,\n * getItems: () => Array.from(document.querySelectorAll('md-menu-item'))\n * }));\n * html`\n * <div\n * @keydown=${typeaheadController.onKeydown}\n * tabindex=\"0\"\n * class=\"activeItemText\">\n * <!-- focusable element that will receive keydown events -->\n * Apple\n * </div>\n * <div>\n * <md-menu-item active header=\"Apple\"></md-menu-item>\n * <md-menu-item header=\"Apricot\"></md-menu-item>\n * <md-menu-item header=\"Banana\"></md-menu-item>\n * <md-menu-item header=\"Olive\"></md-menu-item>\n * <md-menu-item header=\"Orange\"></md-menu-item>\n * </div>\n * `;\n * ```\n */\nexport class TypeaheadController {\n /**\n * Array of tuples that helps with indexing.\n */\n protected typeaheadRecords: TypeaheadRecord[] = [];\n /**\n * Currently-typed text since last buffer timeout\n */\n protected typaheadBuffer = '';\n /**\n * The timeout id from the current buffer's setTimeout\n */\n protected cancelTypeaheadTimeout = 0;\n /**\n * If we are currently \"typing\"\n */\n isTypingAhead = false;\n /**\n * The record of the last active item.\n */\n lastActiveRecord: TypeaheadRecord|null = null;\n\n /**\n * @param getProperties A function that returns the options of the typeahead\n * controller:\n *\n * {\n * getItems: A function that returns an array of menu items to be searched.\n * typeaheadBufferTime: The maximum time between each keystroke to keep the\n * current type buffer alive.\n * }\n */\n constructor(\n protected getProperties: () => TypeaheadControllerProperties,\n ) {}\n\n protected get items() {\n return this.getProperties().getItems();\n }\n\n protected get active() {\n return this.getProperties().active;\n }\n\n /**\n * Apply this listener to the element that will receive `keydown` events that\n * should trigger this controller.\n *\n * @param e The native browser `KeyboardEvent` from the `keydown` event.\n */\n readonly onKeydown = (e: KeyboardEvent) => {\n if (this.isTypingAhead) {\n this.typeahead(e);\n } else {\n this.beginTypeahead(e);\n }\n };\n\n /**\n * Sets up typingahead\n */\n protected beginTypeahead(e: KeyboardEvent) {\n if (!this.active) {\n return;\n }\n\n // We don't want to typeahead if the _beginning_ of the typeahead is a menu\n // navigation, or a selection. We will handle \"Space\" only if it's in the\n // middle of a typeahead\n if (e.code === 'Space' || e.code === 'Enter' ||\n e.code.startsWith('Arrow') || e.code === 'Escape') {\n return;\n }\n\n this.isTypingAhead = true;\n // Generates the record array data structure which is the index, the element\n // and a normalized header.\n this.typeaheadRecords = this.items.map(\n (el, index) => [index, el, el.headline.trim().toLowerCase()]);\n this.lastActiveRecord =\n this.typeaheadRecords.find(\n record => record[TYPEAHEAD_RECORD.ITEM].active) ??\n null;\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n this.typeahead(e);\n }\n\n /**\n * Performs the typeahead. Based on the normalized items and the current text\n * buffer, finds the _next_ item with matching text and activates it.\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: 'o'\n * user types: l\n *\n * activates Olive\n *\n * @example\n *\n * items: Apple, Banana, Olive (active), Orange, Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Orange\n *\n * @example\n *\n * items: Apple, Banana, Olive, Orange (active), Cucumber\n * buffer: ''\n * user types: o\n *\n * activates Olive\n */\n protected typeahead(e: KeyboardEvent) {\n clearTimeout(this.cancelTypeaheadTimeout);\n // Stop typingahead if one of the navigation or selection keys (except for\n // Space) are pressed\n if (e.code === 'Enter' || e.code.startsWith('Arrow') ||\n e.code === 'Escape') {\n this.endTypeahead();\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n return;\n }\n\n // If Space is pressed, prevent it from selecting and closing the menu\n if (e.code === 'Space') {\n e.stopPropagation();\n e.preventDefault();\n }\n\n // Start up a new keystroke buffer timeout\n this.cancelTypeaheadTimeout =\n setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);\n\n this.typaheadBuffer += e.key.toLowerCase();\n\n const lastActiveIndex = this.lastActiveRecord ?\n this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] :\n -1;\n const numRecords = this.typeaheadRecords.length;\n\n /**\n * Sorting function that will resort the items starting with the given index\n *\n * @example\n *\n * this.typeaheadRecords =\n * 0: [0, <reference>, 'apple']\n * 1: [1, <reference>, 'apricot']\n * 2: [2, <reference>, 'banana']\n * 3: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 4: [4, <reference>, 'orange']\n * 5: [5, <reference>, 'strawberry']\n *\n * this.typeaheadRecords.sort((a,b) => rebaseIndexOnActive(a)\n * - rebaseIndexOnActive(b)) ===\n * 0: [3, <reference>, 'olive'] <-- lastActiveIndex\n * 1: [4, <reference>, 'orange']\n * 2: [5, <reference>, 'strawberry']\n * 3: [0, <reference>, 'apple']\n * 4: [1, <reference>, 'apricot']\n * 5: [2, <reference>, 'banana']\n */\n const rebaseIndexOnActive = (record: TypeaheadRecord) => {\n return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %\n numRecords;\n };\n\n // records filtered and sorted / rebased around the last active index\n const matchingRecords =\n this.typeaheadRecords\n .filter(\n record => !record[TYPEAHEAD_RECORD.ITEM].disabled &&\n record[TYPEAHEAD_RECORD.TEXT].startsWith(\n this.typaheadBuffer))\n .sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));\n\n // Just leave if there's nothing that matches. Native select will just\n // choose the first thing that starts with the next letter in the alphabet\n // but that's out of scope and hard to localize\n if (matchingRecords.length === 0) {\n clearTimeout(this.cancelTypeaheadTimeout);\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n this.endTypeahead();\n return;\n }\n\n const isNewQuery = this.typaheadBuffer.length === 1;\n let nextRecord: TypeaheadRecord;\n\n // This is likely the case that someone is trying to \"tab\" through different\n // entries that start with the same letter\n if (this.lastActiveRecord === matchingRecords[0] && isNewQuery) {\n nextRecord = matchingRecords[1] ?? matchingRecords[0];\n } else {\n nextRecord = matchingRecords[0];\n }\n\n if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;\n }\n\n this.lastActiveRecord = nextRecord;\n nextRecord[TYPEAHEAD_RECORD.ITEM].active = true;\n return;\n }\n\n /**\n * Ends the current typeahead and clears the buffer.\n */\n protected endTypeahead = () => {\n this.isTypingAhead = false;\n this.typaheadBuffer = '';\n this.typeaheadRecords = [];\n };\n}\n"]}
|
package/menu/menu-item-link.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as listItemForcedColorsStyles } from '../list/lib/listitem/forced-colors-styles.css.js';
|
|
8
9
|
import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js';
|
|
10
|
+
import { styles as forcedColorsStyles } from './lib/menuitem/forced-colors-styles.css.js';
|
|
9
11
|
import { styles } from './lib/menuitem/menu-item-styles.css.js';
|
|
10
12
|
import { MenuItemLink } from './lib/menuitemlink/menu-item-link.js';
|
|
11
13
|
export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
@@ -28,7 +30,7 @@ export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
|
28
30
|
*/
|
|
29
31
|
let MdMenuItemLink = class MdMenuItemLink extends MenuItemLink {
|
|
30
32
|
};
|
|
31
|
-
MdMenuItemLink.styles = [listItemStyles, styles];
|
|
33
|
+
MdMenuItemLink.styles = [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];
|
|
32
34
|
MdMenuItemLink = __decorate([
|
|
33
35
|
customElement('md-menu-item-link')
|
|
34
36
|
], MdMenuItemLink);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item-link.js","sourceRoot":"","sources":["menu-item-link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,EAAC,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAC;AAGlE,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAS/E;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,YAAY;;AAC9B,qBAAM,
|
|
1
|
+
{"version":3,"file":"menu-item-link.js","sourceRoot":"","sources":["menu-item-link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,0BAA0B,EAAC,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,IAAI,kBAAkB,EAAC,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAC,MAAM,EAAC,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAC;AAGlE,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAS/E;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,YAAY;;AAC9B,qBAAM,GAClB,CAAC,cAAc,EAAE,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAFlE,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CAG1B;SAHY,cAAc","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as listItemForcedColorsStyles} from '../list/lib/listitem/forced-colors-styles.css.js';\nimport {styles as listItemStyles} from '../list/lib/listitem/list-item-styles.css.js';\n\nimport {styles as forcedColorsStyles} from './lib/menuitem/forced-colors-styles.css.js';\nimport {styles} from './lib/menuitem/menu-item-styles.css.js';\nimport {MenuItemLink} from './lib/menuitemlink/menu-item-link.js';\n\nexport {ListItem} from '../list/lib/listitem/list-item.js';\nexport {CloseMenuEvent, DeactivateItemsEvent, MenuItem} from './lib/shared.js';\n\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-menu-item-link': MdMenuItemLink;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menu items are the selectable choices within the menu. Menu items must\n * implement the `MenuItem` interface and also have the `md-menu-item`\n * attribute. Additionally menu items are list items so they must also have the\n * `md-list-item` attribute.\n *\n * Menu items can control a menu by selectively firing the `close-menu` and\n * `deselect-items` events.\n *\n * This is a linkable variant.\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-menu-item-link')\nexport class MdMenuItemLink extends MenuItemLink {\n static override styles =\n [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];\n}\n"]}
|
package/menu/menu-item.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as listItemForcedColorsStyles } from '../list/lib/listitem/forced-colors-styles.css.js';
|
|
8
9
|
import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js';
|
|
9
|
-
import { styles } from './lib/menuitem/
|
|
10
|
+
import { styles as forcedColorsStyles } from './lib/menuitem/forced-colors-styles.css.js';
|
|
10
11
|
import { MenuItemEl } from './lib/menuitem/menu-item.js';
|
|
12
|
+
import { styles } from './lib/menuitem/menu-item-styles.css.js';
|
|
11
13
|
export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
12
14
|
/**
|
|
13
15
|
* @summary Menus display a list of choices on a temporary surface.
|
|
@@ -26,7 +28,7 @@ export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
|
26
28
|
*/
|
|
27
29
|
let MdMenuItem = class MdMenuItem extends MenuItemEl {
|
|
28
30
|
};
|
|
29
|
-
MdMenuItem.styles = [listItemStyles, styles];
|
|
31
|
+
MdMenuItem.styles = [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];
|
|
30
32
|
MdMenuItem = __decorate([
|
|
31
33
|
customElement('md-menu-item')
|
|
32
34
|
], MdMenuItem);
|
package/menu/menu-item.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,0BAA0B,EAAC,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,IAAI,kBAAkB,EAAC,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAC,MAAM,EAAC,MAAM,wCAAwC,CAAC;AAG9D,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAQ/E;;;;;;;;;;;;;;GAcG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;;AACxB,iBAAM,GAClB,CAAC,cAAc,EAAE,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAFlE,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAGtB;SAHY,UAAU","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as listItemForcedColorsStyles} from '../list/lib/listitem/forced-colors-styles.css.js';\nimport {styles as listItemStyles} from '../list/lib/listitem/list-item-styles.css.js';\n\nimport {styles as forcedColorsStyles} from './lib/menuitem/forced-colors-styles.css.js';\nimport {MenuItemEl} from './lib/menuitem/menu-item.js';\nimport {styles} from './lib/menuitem/menu-item-styles.css.js';\n\nexport {ListItem} from '../list/lib/listitem/list-item.js';\nexport {CloseMenuEvent, DeactivateItemsEvent, MenuItem} from './lib/shared.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-menu-item': MdMenuItem;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menu items are the selectable choices within the menu. Menu items must\n * implement the `MenuItem` interface and also have the `md-menu-item`\n * attribute. Additionally menu items are list items so they must also have the\n * `md-list-item` attribute.\n *\n * Menu items can control a menu by selectively firing the `close-menu` and\n * `deselect-items` events.\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-menu-item')\nexport class MdMenuItem extends MenuItemEl {\n static override styles =\n [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];\n}\n"]}
|
package/menu/menu.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as forcedColors } from './lib/forced-colors-styles.css.js';
|
|
8
9
|
import { Menu } from './lib/menu.js';
|
|
9
10
|
import { styles } from './lib/menu-styles.css.js';
|
|
10
11
|
export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
@@ -52,7 +53,7 @@ export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
|
52
53
|
*/
|
|
53
54
|
let MdMenu = class MdMenu extends Menu {
|
|
54
55
|
};
|
|
55
|
-
MdMenu.styles = [styles];
|
|
56
|
+
MdMenu.styles = [styles, forcedColors];
|
|
56
57
|
MdMenu = __decorate([
|
|
57
58
|
customElement('md-menu')
|
|
58
59
|
], MdMenu);
|
package/menu/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIhD,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,IAAI;;AACd,aAAM,GAAG,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,YAAY,EAAC,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIhD,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,IAAI;;AACd,aAAM,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AADrC,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAElB;SAFY,MAAM","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as forcedColors} from './lib/forced-colors-styles.css.js';\nimport {Menu} from './lib/menu.js';\nimport {styles} from './lib/menu-styles.css.js';\n\nexport {ListItem} from '../list/lib/listitem/list-item.js';\nexport {Corner, DefaultFocusState} from './lib/menu.js';\nexport {CloseMenuEvent, DeactivateItemsEvent, MenuItem} from './lib/shared.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-menu': MdMenu;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menus appear when users interact with a button, action, or other control.\n *\n * They can be opened from a variety of elements, most commonly icon buttons,\n * buttons, and text fields.\n *\n * md-menu listens for the `close-menu` and `deselect-items` events.\n *\n * - `close-menu` closes the menu when dispatched from a child element.\n * - `deselect-items` deselects all of its immediate menu-item children.\n *\n * @example\n * ```html\n * <div style=\"position:relative;\">\n * <button\n * class=\"anchor\"\n * ${ref(anchorRef)}\n * @click=${() => this.menuRef.value.show()}>\n * Click to open menu\n * </button>\n * <!--\n * `has-overflow` is required when using a submenu which overflows the\n * menu's contents\n * -->\n * <md-menu has-overflow ${ref(menuRef)} ${(el) => el.anchor =\n * anchorRef.value}> <md-menu-item header=\"This is a header\"></md-menu-item>\n * <md-sub-menu-item header=\"this is a submenu item\">\n * <md-menu slot=\"submenu\">\n * <md-menu-item\n * header=\"This is an item inside a submenu\"></md-menu-item>\n * </md-menu>\n * </md-sub-menu>\n * </md-menu>\n * </div>\n * ```\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-menu')\nexport class MdMenu extends Menu {\n static override styles = [styles, forcedColors];\n}\n"]}
|
package/menu/sub-menu-item.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { __decorate } from "tslib";
|
|
7
7
|
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { styles as listItemForcedColorsStyles } from '../list/lib/listitem/forced-colors-styles.css.js';
|
|
8
9
|
import { styles as listItemStyles } from '../list/lib/listitem/list-item-styles.css.js';
|
|
10
|
+
import { styles as forcedColorsStyles } from './lib/menuitem/forced-colors-styles.css.js';
|
|
9
11
|
import { styles } from './lib/menuitem/menu-item-styles.css.js';
|
|
10
12
|
import { SubMenuItem } from './lib/submenuitem/sub-menu-item.js';
|
|
11
13
|
export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
@@ -55,7 +57,7 @@ export { CloseMenuEvent, DeactivateItemsEvent } from './lib/shared.js';
|
|
|
55
57
|
*/
|
|
56
58
|
let MdSubMenuItem = class MdSubMenuItem extends SubMenuItem {
|
|
57
59
|
};
|
|
58
|
-
MdSubMenuItem.styles = [listItemStyles, styles];
|
|
60
|
+
MdSubMenuItem.styles = [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];
|
|
59
61
|
MdSubMenuItem = __decorate([
|
|
60
62
|
customElement('md-sub-menu-item')
|
|
61
63
|
], MdSubMenuItem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,EAAC,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,WAAW;;AAC5B,oBAAM,
|
|
1
|
+
{"version":3,"file":"sub-menu-item.js","sourceRoot":"","sources":["sub-menu-item.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,MAAM,IAAI,0BAA0B,EAAC,MAAM,kDAAkD,CAAC;AACtG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAEtF,OAAO,EAAC,MAAM,IAAI,kBAAkB,EAAC,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAC,MAAM,EAAC,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAW,MAAM,iBAAiB,CAAC;AAQ/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,WAAW;;AAC5B,oBAAM,GAClB,CAAC,cAAc,EAAE,MAAM,EAAE,0BAA0B,EAAE,kBAAkB,CAAC,CAAC;AAFlE,aAAa;IADzB,aAAa,CAAC,kBAAkB,CAAC;GACrB,aAAa,CAGzB;SAHY,aAAa","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {customElement} from 'lit/decorators.js';\n\nimport {styles as listItemForcedColorsStyles} from '../list/lib/listitem/forced-colors-styles.css.js';\nimport {styles as listItemStyles} from '../list/lib/listitem/list-item-styles.css.js';\n\nimport {styles as forcedColorsStyles} from './lib/menuitem/forced-colors-styles.css.js';\nimport {styles} from './lib/menuitem/menu-item-styles.css.js';\nimport {SubMenuItem} from './lib/submenuitem/sub-menu-item.js';\n\nexport {ListItem} from '../list/lib/listitem/list-item.js';\nexport {CloseMenuEvent, DeactivateItemsEvent, MenuItem} from './lib/shared.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'md-sub-menu-item': MdSubMenuItem;\n }\n}\n\n/**\n * @summary Menus display a list of choices on a temporary surface.\n *\n * @description\n * Menu items are the selectable choices within the menu. Menu items must\n * implement the `MenuItem` interface and also have the `md-menu-item`\n * attribute. Additionally menu items are list items so they must also have the\n * `md-list-item` attribute.\n *\n * Menu items can control a menu by selectively firing the `close-menu` and\n * `deselect-items` events.\n *\n * This menu item will open a sub-menu that is slotted in the `submenu` slot.\n * Additionally, the containing menu must either have `has-overflow` or `fixed`\n * set to `true` in order to display the containing menu properly.\n *\n * @example\n * ```html\n * <div style=\"position:relative;\">\n * <button\n * class=\"anchor\"\n * ${ref(anchorRef)}\n * @click=${() => this.menuRef.value.show()}>\n * Click to open menu\n * </button>\n * <!--\n * `has-overflow` is required when using a submenu which overflows the\n * menu's contents\n * -->\n * <md-menu has-overflow ${ref(menuRef)} ${(el) => el.anchor =\n * anchorRef.value}> <md-menu-item header=\"This is a header\"></md-menu-item>\n * <md-sub-menu-item header=\"this is a submenu item\">\n * <md-menu slot=\"submenu\">\n * <md-menu-item\n * header=\"This is an item inside a submenu\"></md-menu-item>\n * </md-menu>\n * </md-sub-menu>\n * </md-menu>\n * </div>\n * ```\n *\n * @final\n * @suppress {visibility}\n */\n@customElement('md-sub-menu-item')\nexport class MdSubMenuItem extends SubMenuItem {\n static override styles =\n [listItemStyles, styles, listItemForcedColorsStyles, forcedColorsStyles];\n}\n"]}
|
|
@@ -33,10 +33,9 @@
|
|
|
33
33
|
|
|
34
34
|
@include elevation.theme(
|
|
35
35
|
(
|
|
36
|
-
duration: 280ms,
|
|
37
|
-
level: var(--_container-elevation),
|
|
38
|
-
shadow-color: var(--_container-shadow-color),
|
|
39
|
-
surface-tint: var(--_container-surface-tint-layer-color),
|
|
36
|
+
'duration': 280ms,
|
|
37
|
+
'level': var(--_container-elevation),
|
|
38
|
+
'shadow-color': var(--_container-shadow-color),
|
|
40
39
|
)
|
|
41
40
|
);
|
|
42
41
|
|
|
@@ -58,8 +57,6 @@
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
md-elevation {
|
|
61
|
-
inset: 0;
|
|
62
|
-
position: absolute;
|
|
63
60
|
z-index: 0;
|
|
64
61
|
}
|
|
65
62
|
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { css } from 'lit';
|
|
7
|
-
export const styles = css `:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #
|
|
7
|
+
export const styles = css `:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-focus-state-layer-color: var(--md-navigation-bar-active-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-icon-color: var(--md-navigation-bar-active-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-hover-label-text-color: var(--md-navigation-bar-active-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-state-layer-color: var(--md-navigation-bar-active-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-icon-color: var(--md-navigation-bar-active-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-label-text-color: var(--md-navigation-bar-active-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-label-text-weight: var(--md-navigation-bar-active-label-text-weight, 700);--_active-pressed-icon-color: var(--md-navigation-bar-active-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-pressed-label-text-color: var(--md-navigation-bar-active-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-pressed-state-layer-color: var(--md-navigation-bar-active-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_container-color: var(--md-navigation-bar-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-navigation-bar-container-elevation, 2);--_container-height: var(--md-navigation-bar-container-height, 80px);--_container-shape: var(--md-navigation-bar-container-shape, 0px);--_focus-state-layer-opacity: var(--md-navigation-bar-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-navigation-bar-hover-state-layer-opacity, 0.08);--_icon-size: var(--md-navigation-bar-icon-size, 24px);--_inactive-focus-icon-color: var(--md-navigation-bar-inactive-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-focus-label-text-color: var(--md-navigation-bar-inactive-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-focus-state-layer-color: var(--md-navigation-bar-inactive-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-icon-color: var(--md-navigation-bar-inactive-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-label-text-color: var(--md-navigation-bar-inactive-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-state-layer-color: var(--md-navigation-bar-inactive-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-icon-color: var(--md-navigation-bar-inactive-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-label-text-color: var(--md-navigation-bar-inactive-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-pressed-icon-color: var(--md-navigation-bar-inactive-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-pressed-label-text-color: var(--md-navigation-bar-inactive-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-pressed-state-layer-color: var(--md-navigation-bar-inactive-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-navigation-bar-label-text-font, var(--md-ref-typeface-plain, Roboto));--_label-text-line-height: var(--md-navigation-bar-label-text-line-height, 1rem);--_label-text-size: var(--md-navigation-bar-label-text-size, 0.75rem);--_label-text-tracking: var(--md-navigation-bar-label-text-tracking, 0.031rem);--_label-text-type: var(--md-navigation-bar-label-text-type, 500 0.75rem / 1rem var(--md-ref-typeface-plain, Roboto));--_label-text-weight: var(--md-navigation-bar-label-text-weight, 500);--_pressed-state-layer-opacity: var(--md-navigation-bar-pressed-state-layer-opacity, 0.12);--md-elevation-duration:280ms;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);width:100%}.md3-navigation-bar{display:flex;position:relative;width:100%;background-color:var(--_container-color);border-radius:var(--_container-shape);height:var(--_container-height)}.md3-navigation-bar .md3-navigation-bar__tabs-slot-container{display:inherit;width:inherit}md-elevation{z-index:0}/*# sourceMappingURL=navigation-bar-styles.css.map */
|
|
8
8
|
`;
|
|
9
9
|
//# sourceMappingURL=navigation-bar-styles.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-bar-styles.css.js","sourceRoot":"","sources":["navigation-bar-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #
|
|
1
|
+
{"version":3,"file":"navigation-bar-styles.css.js","sourceRoot":"","sources":["navigation-bar-styles.css.ts"],"names":[],"mappings":"AAAA;;;;IAII;AACH,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;CACzB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n import {css} from 'lit';\n export const styles = css`:host{--_active-indicator-color: var(--md-navigation-bar-active-indicator-color, var(--md-sys-color-secondary-container, #e8def8));--_active-indicator-height: var(--md-navigation-bar-active-indicator-height, 32px);--_active-indicator-shape: var(--md-navigation-bar-active-indicator-shape, 9999px);--_active-indicator-width: var(--md-navigation-bar-active-indicator-width, 64px);--_active-focus-icon-color: var(--md-navigation-bar-active-focus-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-focus-label-text-color: var(--md-navigation-bar-active-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-focus-state-layer-color: var(--md-navigation-bar-active-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-icon-color: var(--md-navigation-bar-active-hover-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-hover-label-text-color: var(--md-navigation-bar-active-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-hover-state-layer-color: var(--md-navigation-bar-active-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_active-icon-color: var(--md-navigation-bar-active-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-label-text-color: var(--md-navigation-bar-active-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-label-text-weight: var(--md-navigation-bar-active-label-text-weight, 700);--_active-pressed-icon-color: var(--md-navigation-bar-active-pressed-icon-color, var(--md-sys-color-on-secondary-container, #1d192b));--_active-pressed-label-text-color: var(--md-navigation-bar-active-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_active-pressed-state-layer-color: var(--md-navigation-bar-active-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_container-color: var(--md-navigation-bar-container-color, var(--md-sys-color-surface-container, #f3edf7));--_container-elevation: var(--md-navigation-bar-container-elevation, 2);--_container-height: var(--md-navigation-bar-container-height, 80px);--_container-shape: var(--md-navigation-bar-container-shape, 0px);--_focus-state-layer-opacity: var(--md-navigation-bar-focus-state-layer-opacity, 0.12);--_hover-state-layer-opacity: var(--md-navigation-bar-hover-state-layer-opacity, 0.08);--_icon-size: var(--md-navigation-bar-icon-size, 24px);--_inactive-focus-icon-color: var(--md-navigation-bar-inactive-focus-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-focus-label-text-color: var(--md-navigation-bar-inactive-focus-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-focus-state-layer-color: var(--md-navigation-bar-inactive-focus-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-icon-color: var(--md-navigation-bar-inactive-hover-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-label-text-color: var(--md-navigation-bar-inactive-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-hover-state-layer-color: var(--md-navigation-bar-inactive-hover-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-icon-color: var(--md-navigation-bar-inactive-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-label-text-color: var(--md-navigation-bar-inactive-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_inactive-pressed-icon-color: var(--md-navigation-bar-inactive-pressed-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-pressed-label-text-color: var(--md-navigation-bar-inactive-pressed-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_inactive-pressed-state-layer-color: var(--md-navigation-bar-inactive-pressed-state-layer-color, var(--md-sys-color-on-surface, #1d1b20));--_label-text-font: var(--md-navigation-bar-label-text-font, var(--md-ref-typeface-plain, Roboto));--_label-text-line-height: var(--md-navigation-bar-label-text-line-height, 1rem);--_label-text-size: var(--md-navigation-bar-label-text-size, 0.75rem);--_label-text-tracking: var(--md-navigation-bar-label-text-tracking, 0.031rem);--_label-text-type: var(--md-navigation-bar-label-text-type, 500 0.75rem / 1rem var(--md-ref-typeface-plain, Roboto));--_label-text-weight: var(--md-navigation-bar-label-text-weight, 500);--_pressed-state-layer-opacity: var(--md-navigation-bar-pressed-state-layer-opacity, 0.12);--md-elevation-duration:280ms;--md-elevation-level:var(--_container-elevation);--md-elevation-shadow-color:var(--_container-shadow-color);width:100%}.md3-navigation-bar{display:flex;position:relative;width:100%;background-color:var(--_container-color);border-radius:var(--_container-shape);height:var(--_container-height)}.md3-navigation-bar .md3-navigation-bar__tabs-slot-container{display:inherit;width:inherit}md-elevation{z-index:0}/*# sourceMappingURL=navigation-bar-styles.css.map */\n`;\n "]}
|
|
@@ -26,8 +26,8 @@ export class NavigationBar extends LitElement {
|
|
|
26
26
|
@keydown="${this.handleKeydown}"
|
|
27
27
|
@navigation-tab-interaction="${this.handleNavigationTabInteraction}"
|
|
28
28
|
@navigation-tab-rendered=${this.handleNavigationTabConnected}
|
|
29
|
-
><md-elevation
|
|
30
|
-
|
|
29
|
+
><md-elevation></md-elevation
|
|
30
|
+
><div class="md3-navigation-bar__tabs-slot-container"
|
|
31
31
|
><slot></slot></div></div>`;
|
|
32
32
|
}
|
|
33
33
|
updated(changedProperties) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-bar.js","sourceRoot":"","sources":["navigation-bar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;SACR;IACH,CAAC;IAEO,mBAAmB,CAAC,KAAa;QACvC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACjE;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK,CAAC;SACnC;IACH,CAAC;IAEO,0BAA0B,CAAC,KAAc;QAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE;YAC3B,GAAG,CAAC,iBAAiB,GAAG,KAAK,CAAC;SAC/B;IACH,CAAC;CACF;AArIC;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;;kDAAiB;AAE1C;IAAC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;yDAA4B;AAItD;IAAC,qBAAqB,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;;kDACC;AAGxC;IAAC,YAAY;IACZ,QAAQ,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;gDAC/B","sourcesContent":["/**\n * @license\n * Copyright 2022 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, queryAssignedElements} from 'lit/decorators.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {isRtl} from '../../controller/is-rtl.js';\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {NavigationTab} from '../../navigationtab/lib/navigation-tab.js';\n\nimport {NavigationTabInteractionEvent} from './constants.js';\nimport {NavigationBarState} from './state.js';\n\n/** @soyCompatible */\nexport class NavigationBar extends LitElement implements NavigationBarState {\n @property({type: Number}) activeIndex = 0;\n\n @property({type: Boolean}) hideInactiveLabels = false;\n\n tabs: NavigationTab[] = [];\n\n @queryAssignedElements({flatten: true})\n protected tabsElement!: NavigationTab[];\n\n // tslint:disable-next-line:no-new-decorators\n @ariaProperty\n @property({attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n /** @soyTemplate */\n override render(): TemplateResult {\n return html`<div class=\"md3-navigation-bar\"\n role=\"tablist\"\n aria-label=\"${ifDefined(this.ariaLabel || undefined)}\"\n @keydown=\"${this.handleKeydown}\"\n @navigation-tab-interaction=\"${this.handleNavigationTabInteraction}\"\n @navigation-tab-rendered=${this.handleNavigationTabConnected}\n ><md-elevation
|
|
1
|
+
{"version":3,"file":"navigation-bar.js","sourceRoot":"","sources":["navigation-bar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAEH,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAC,IAAI,EAAE,UAAU,EAAiC,MAAM,KAAK,CAAC;AACrE,OAAO,EAAC,QAAQ,EAAE,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAC,KAAK,EAAC,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAM/D,qBAAqB;AACrB,MAAM,OAAO,aAAc,SAAQ,UAAU;IAA7C;;QAC4B,gBAAW,GAAG,CAAC,CAAC;QAEf,uBAAkB,GAAG,KAAK,CAAC;QAEtD,SAAI,GAAoB,EAAE,CAAC;IAiI7B,CAAC;IAvHC,mBAAmB;IACV,MAAM;QACb,OAAO,IAAI,CAAA;;0BAEW,SAAS,CAAC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC;wBACxC,IAAI,CAAC,aAAa;2CACC,IAAI,CAAC,8BAA8B;uCACvC,IAAI,CAAC,4BAA4B;;;mCAGrC,CAAC;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AAC;;kDACC;AAGxC;IAAC,YAAY;IACZ,QAAQ,CAAC,EAAC,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC;;gDAC/B","sourcesContent":["/**\n * @license\n * Copyright 2022 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, queryAssignedElements} from 'lit/decorators.js';\nimport {ifDefined} from 'lit/directives/if-defined.js';\n\nimport {isRtl} from '../../controller/is-rtl.js';\nimport {ariaProperty} from '../../decorators/aria-property.js';\nimport {NavigationTab} from '../../navigationtab/lib/navigation-tab.js';\n\nimport {NavigationTabInteractionEvent} from './constants.js';\nimport {NavigationBarState} from './state.js';\n\n/** @soyCompatible */\nexport class NavigationBar extends LitElement implements NavigationBarState {\n @property({type: Number}) activeIndex = 0;\n\n @property({type: Boolean}) hideInactiveLabels = false;\n\n tabs: NavigationTab[] = [];\n\n @queryAssignedElements({flatten: true})\n protected tabsElement!: NavigationTab[];\n\n // tslint:disable-next-line:no-new-decorators\n @ariaProperty\n @property({attribute: 'data-aria-label', noAccessor: true})\n override ariaLabel!: string;\n\n /** @soyTemplate */\n override render(): TemplateResult {\n return html`<div class=\"md3-navigation-bar\"\n role=\"tablist\"\n aria-label=\"${ifDefined(this.ariaLabel || undefined)}\"\n @keydown=\"${this.handleKeydown}\"\n @navigation-tab-interaction=\"${this.handleNavigationTabInteraction}\"\n @navigation-tab-rendered=${this.handleNavigationTabConnected}\n ><md-elevation></md-elevation\n ><div class=\"md3-navigation-bar__tabs-slot-container\"\n ><slot></slot></div></div>`;\n }\n\n protected override updated(changedProperties: PropertyValues<NavigationBar>) {\n if (changedProperties.has('activeIndex')) {\n this.onActiveIndexChange(this.activeIndex);\n this.dispatchEvent(new CustomEvent('navigation-bar-activated', {\n detail:\n {tab: this.tabs[this.activeIndex], activeIndex: this.activeIndex},\n bubbles: true,\n composed: true\n }));\n }\n\n if (changedProperties.has('hideInactiveLabels')) {\n this.onHideInactiveLabelsChange(this.hideInactiveLabels);\n }\n\n if (changedProperties.has('tabs')) {\n this.onHideInactiveLabelsChange(this.hideInactiveLabels);\n this.onActiveIndexChange(this.activeIndex);\n }\n }\n\n override firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n this.layout();\n }\n\n layout() {\n if (!this.tabsElement) return;\n const navTabs: NavigationTab[] = [];\n for (const node of this.tabsElement) {\n navTabs.push(node);\n }\n this.tabs = navTabs;\n }\n\n private handleNavigationTabConnected(event: CustomEvent) {\n const target = event.target as NavigationTab;\n if (this.tabs.indexOf(target) === -1) {\n this.layout();\n }\n }\n\n private handleNavigationTabInteraction(event: NavigationTabInteractionEvent) {\n this.activeIndex = this.tabs.indexOf(event.detail.state as NavigationTab);\n }\n\n private handleKeydown(event: KeyboardEvent) {\n const key = event.key;\n const focusedTabIndex = this.tabs.findIndex((tab) => {\n return tab.matches(':focus-within');\n });\n const isRTL = isRtl(this);\n const maxIndex = this.tabs.length - 1;\n\n if (key === 'Enter' || key === ' ') {\n this.activeIndex = focusedTabIndex;\n return;\n }\n\n if (key === 'Home') {\n this.tabs[0].focus();\n return;\n }\n\n if (key === 'End') {\n this.tabs[maxIndex].focus();\n return;\n }\n\n const toNextTab =\n (key === 'ArrowRight' && !isRTL) || (key === 'ArrowLeft' && isRTL);\n if (toNextTab && focusedTabIndex === maxIndex) {\n this.tabs[0].focus();\n return;\n }\n if (toNextTab) {\n this.tabs[focusedTabIndex + 1].focus();\n return;\n }\n\n const toPreviousTab =\n (key === 'ArrowLeft' && !isRTL) || (key === 'ArrowRight' && isRTL);\n if (toPreviousTab && focusedTabIndex === 0) {\n this.tabs[maxIndex].focus();\n return;\n }\n if (toPreviousTab) {\n this.tabs[focusedTabIndex - 1].focus();\n return;\n }\n }\n\n private onActiveIndexChange(value: number) {\n if (!this.tabs[value]) {\n throw new Error('NavigationBar: activeIndex is out of bounds.');\n }\n for (let i = 0; i < this.tabs.length; i++) {\n this.tabs[i].active = i === value;\n }\n }\n\n private onHideInactiveLabelsChange(value: boolean) {\n for (const tab of this.tabs) {\n tab.hideInactiveLabel = value;\n }\n }\n}\n"]}
|