@material/web 1.0.0-pre.4 → 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 +5 -5
- package/badge/lib/_badge.scss +2 -10
- package/badge/lib/badge-styles.css.js +1 -1
- package/badge/lib/badge-styles.css.js.map +1 -1
- package/button/lib/_elevated-button.scss +5 -30
- package/button/lib/_elevation.scss +8 -29
- package/button/lib/_filled-button.scss +4 -31
- package/button/lib/_icon.scss +1 -0
- package/button/lib/_outlined-button.scss +6 -23
- package/button/lib/_shared.scss +23 -52
- package/button/lib/_text-button.scss +8 -34
- package/button/lib/_tonal-button.scss +5 -28
- package/button/lib/button.d.ts +16 -1
- package/button/lib/button.js +41 -15
- 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.scss +1 -2
- package/checkbox/lib/checkbox-styles.css.js +1 -1
- package/checkbox/lib/checkbox-styles.css.js.map +1 -1
- package/chips/_assist-chip.scss +6 -0
- package/chips/_suggestion-chip.scss +6 -0
- package/chips/assist-chip.d.ts +20 -0
- package/chips/assist-chip.js +24 -0
- package/chips/assist-chip.js.map +1 -0
- package/chips/lib/_assist-chip.scss +27 -0
- package/chips/lib/_shared.scss +213 -0
- package/chips/lib/_suggestion-chip.scss +30 -0
- package/chips/lib/assist-chip.d.ts +11 -0
- package/chips/lib/assist-chip.js +12 -0
- package/chips/lib/assist-chip.js.map +1 -0
- package/chips/lib/assist-styles.css.js +9 -0
- package/chips/lib/assist-styles.css.js.map +1 -0
- package/{menusurface/lib/menu-surface-styles.scss → chips/lib/assist-styles.scss} +3 -3
- package/chips/lib/chip.d.ts +29 -0
- package/chips/lib/chip.js +110 -0
- package/chips/lib/chip.js.map +1 -0
- package/chips/lib/shared-styles.css.js +9 -0
- package/chips/lib/shared-styles.css.js.map +1 -0
- package/{autocomplete → chips}/lib/shared-styles.scss +1 -1
- package/chips/lib/suggestion-chip.d.ts +11 -0
- package/chips/lib/suggestion-chip.js +12 -0
- package/chips/lib/suggestion-chip.js.map +1 -0
- package/chips/lib/suggestion-styles.css.js +9 -0
- package/chips/lib/suggestion-styles.css.js.map +1 -0
- package/{autocomplete/lib/autocompletelist/autocomplete-list-styles.scss → chips/lib/suggestion-styles.scss} +3 -3
- package/chips/suggestion-chip.d.ts +20 -0
- package/chips/suggestion-chip.js +24 -0
- package/chips/suggestion-chip.js.map +1 -0
- 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 +5 -8
- package/dialog/lib/_tokens.scss +1 -2
- 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 +14 -69
- 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/_fab-extended.scss +3 -10
- package/fab/lib/_fab.scss +0 -3
- package/fab/lib/_shared.scss +19 -44
- 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.d.ts +0 -1
- package/fab/lib/fab-shared.js +2 -8
- 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/field.d.ts +4 -1
- package/field/lib/field.js +7 -0
- package/field/lib/field.js.map +1 -1
- package/field/lib/filled-styles.css.js +1 -1
- package/field/lib/filled-styles.css.js.map +1 -1
- package/field/lib/outlined-styles.css.js +1 -1
- package/field/lib/outlined-styles.css.js.map +1 -1
- package/focus/lib/_focus-ring.scss +30 -14
- 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-icon-button.scss +1 -12
- package/iconbutton/lib/_filled-tonal-icon-button.scss +1 -12
- package/iconbutton/lib/_outlined-icon-button.scss +1 -13
- package/iconbutton/lib/_shared.scss +10 -6
- package/iconbutton/lib/_standard-icon-button.scss +5 -12
- 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 -18
- package/iconbutton/lib/icon-button.js.map +1 -1
- package/iconbutton/lib/outlined-styles.css.js +1 -1
- package/iconbutton/lib/outlined-styles.css.js.map +1 -1
- package/iconbutton/lib/shared-styles.css.js +1 -1
- package/iconbutton/lib/shared-styles.css.js.map +1 -1
- package/iconbutton/lib/standard-styles.css.js +1 -1
- package/iconbutton/lib/standard-styles.css.js.map +1 -1
- package/list/harness.d.ts +1 -0
- package/list/harness.js +1 -0
- package/list/harness.js.map +1 -1
- package/list/lib/_list.scss +15 -9
- 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 +50 -57
- 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 +4 -3
- package/list/lib/listitem/list-item.js +7 -4
- 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 +11 -19
- 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 +34 -10
- package/menu/lib/menu.js +116 -30
- 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.js +9 -0
- package/menu/lib/menuitem/forced-colors-styles.css.js.map +1 -0
- package/menu/lib/menuitem/forced-colors-styles.scss +22 -0
- package/menu/lib/menuitem/menu-item-styles.css.js +1 -1
- package/menu/lib/menuitem/menu-item-styles.css.js.map +1 -1
- package/menu/lib/menuitem/menu-item.js +1 -1
- package/menu/lib/menuitem/menu-item.js.map +1 -1
- package/menu/lib/menuitemlink/menu-item-link.js +2 -1
- package/menu/lib/menuitemlink/menu-item-link.js.map +1 -1
- package/menu/lib/shared.d.ts +26 -0
- package/menu/lib/shared.js +39 -0
- package/menu/lib/shared.js.map +1 -1
- package/menu/lib/submenuitem/sub-menu-item.d.ts +8 -0
- package/menu/lib/submenuitem/sub-menu-item.js +21 -2
- package/menu/lib/submenuitem/sub-menu-item.js.map +1 -1
- package/menu/lib/surfacePositionController.d.ts +10 -2
- package/menu/lib/surfacePositionController.js +6 -2
- package/menu/lib/surfacePositionController.js.map +1 -1
- package/menu/lib/typeaheadController.d.ts +15 -2
- package/menu/lib/typeaheadController.js +27 -17
- 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 +4 -10
- 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 -14
- package/navigationdrawer/lib/_navigation-drawer.scss +9 -17
- package/navigationdrawer/lib/_shared.scss +0 -9
- 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.scss +4 -10
- 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.scss +1 -2
- 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/_shared.scss +0 -2
- 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 +2 -11
- package/slider/lib/_tokens.scss +7 -8
- 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-text-field.scss +1 -7
- package/textfield/lib/_outlined-text-field.scss +1 -7
- 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 +104 -2
- package/tokens/_md-comp-assist-chip.scss +123 -0
- package/tokens/_md-comp-badge.scss +41 -0
- package/tokens/_md-comp-banner.scss +23 -0
- package/tokens/_md-comp-bottom-app-bar.scss +21 -0
- package/tokens/_md-comp-carousel-item.scss +23 -0
- package/tokens/_md-comp-checkbox.scss +21 -0
- package/tokens/_md-comp-circular-progress-indicator.scss +37 -0
- package/tokens/_md-comp-data-table.scss +23 -0
- package/tokens/_md-comp-date-input-modal.scss +23 -0
- package/tokens/_md-comp-date-picker-docked.scss +25 -0
- package/tokens/_md-comp-date-picker-modal.scss +25 -0
- package/tokens/_md-comp-dialog.scss +52 -0
- package/tokens/_md-comp-divider.scss +17 -0
- package/tokens/_md-comp-elevated-button.scss +118 -0
- package/tokens/_md-comp-elevated-card.scss +23 -0
- package/tokens/_md-comp-elevation.scss +28 -0
- package/tokens/_md-comp-extended-fab-branded.scss +45 -0
- package/tokens/_md-comp-extended-fab-primary.scss +45 -0
- package/tokens/_md-comp-extended-fab-secondary.scss +48 -0
- package/tokens/_md-comp-extended-fab-surface.scss +45 -0
- package/tokens/_md-comp-extended-fab-tertiary.scss +48 -0
- package/tokens/_md-comp-fab-branded-large.scss +23 -0
- package/tokens/_md-comp-fab-branded.scss +23 -0
- package/tokens/_md-comp-fab-primary-large.scss +23 -0
- package/tokens/_md-comp-fab-primary-small.scss +23 -0
- package/tokens/_md-comp-fab-primary.scss +23 -0
- package/tokens/_md-comp-fab-secondary-large.scss +23 -0
- package/tokens/_md-comp-fab-secondary-small.scss +23 -0
- package/tokens/_md-comp-fab-secondary.scss +23 -0
- package/tokens/_md-comp-fab-surface-large.scss +23 -0
- package/tokens/_md-comp-fab-surface-small.scss +23 -0
- package/tokens/_md-comp-fab-surface.scss +23 -0
- package/tokens/_md-comp-fab-tertiary-large.scss +23 -0
- package/tokens/_md-comp-fab-tertiary-small.scss +23 -0
- package/tokens/_md-comp-fab-tertiary.scss +23 -0
- package/tokens/_md-comp-filled-autocomplete.scss +25 -0
- package/tokens/_md-comp-filled-button.scss +118 -0
- package/tokens/_md-comp-filled-card.scss +23 -0
- package/tokens/_md-comp-filled-icon-button.scss +21 -0
- package/tokens/_md-comp-filled-menu-button.scss +25 -0
- package/tokens/_md-comp-filled-select.scss +25 -0
- package/tokens/_md-comp-filled-text-field.scss +55 -0
- package/tokens/_md-comp-filled-tonal-button.scss +119 -0
- package/tokens/_md-comp-filled-tonal-icon-button.scss +24 -0
- package/tokens/_md-comp-filter-chip.scss +228 -0
- package/tokens/_md-comp-focus-ring.scss +46 -0
- package/tokens/_md-comp-full-screen-dialog.scss +25 -0
- package/tokens/_md-comp-icon-button.scss +21 -0
- package/tokens/_md-comp-input-chip.scss +221 -0
- package/tokens/_md-comp-linear-progress-indicator.scss +22 -0
- package/tokens/_md-comp-list.scss +75 -0
- package/tokens/_md-comp-menu.scss +21 -0
- package/tokens/_md-comp-navigation-bar.scss +25 -0
- package/tokens/_md-comp-navigation-drawer.scss +25 -0
- package/tokens/_md-comp-navigation-rail.scss +25 -0
- package/tokens/_md-comp-outlined-autocomplete.scss +28 -0
- package/tokens/_md-comp-outlined-button.scss +114 -0
- package/tokens/_md-comp-outlined-card.scss +23 -0
- package/tokens/_md-comp-outlined-icon-button.scss +21 -0
- package/tokens/_md-comp-outlined-menu-button.scss +23 -0
- package/tokens/_md-comp-outlined-segmented-button.scss +47 -0
- package/tokens/_md-comp-outlined-select.scss +25 -0
- package/tokens/_md-comp-outlined-text-field.scss +53 -0
- package/tokens/_md-comp-plain-tooltip.scss +21 -0
- package/tokens/_md-comp-primary-navigation-tab.scss +50 -0
- package/tokens/_md-comp-radio-button.scss +19 -0
- package/tokens/_md-comp-rich-tooltip.scss +25 -0
- package/tokens/_md-comp-scrim.scss +17 -0
- package/tokens/_md-comp-search-bar.scss +25 -0
- package/tokens/_md-comp-search-view.scss +23 -0
- package/tokens/_md-comp-secondary-navigation-tab.scss +49 -0
- package/tokens/_md-comp-sheet-bottom.scss +21 -0
- package/tokens/_md-comp-sheet-floating.scss +21 -0
- package/tokens/_md-comp-sheet-side.scss +25 -0
- package/tokens/_md-comp-slider.scss +47 -0
- package/tokens/_md-comp-snackbar.scss +25 -0
- package/tokens/_md-comp-standard-menu-button.scss +23 -0
- package/tokens/_md-comp-suggestion-chip.scss +123 -0
- package/tokens/_md-comp-switch.scss +21 -0
- package/tokens/_md-comp-test-table.scss +31 -0
- package/tokens/_md-comp-text-button.scss +107 -0
- package/tokens/_md-comp-time-input.scss +25 -0
- package/tokens/_md-comp-time-picker.scss +25 -0
- package/tokens/_md-comp-top-app-bar-large.scss +23 -0
- package/tokens/_md-comp-top-app-bar-medium.scss +23 -0
- package/tokens/_md-comp-top-app-bar-small-centered.scss +26 -0
- package/tokens/_md-comp-top-app-bar-small.scss +23 -0
- package/tokens/_md-ref-palette.scss +12 -0
- package/tokens/_md-ref-typeface.scss +34 -0
- package/tokens/_md-sys-color.scss +25 -0
- package/tokens/_md-sys-elevation.scss +30 -0
- package/tokens/_md-sys-motion.scss +12 -0
- package/tokens/_md-sys-shape.scss +12 -0
- package/tokens/_md-sys-state.scss +12 -0
- package/tokens/_md-sys-typescale.scss +51 -0
- package/tokens/_values.scss +111 -0
- package/tokens/{v0_161 → v0_172}/_md-comp-assist-chip.scss +3 -4
- package/tokens/{v0_160 → v0_172}/_md-comp-badge.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-banner.scss +2 -4
- package/tokens/{v0_160 → v0_172}/_md-comp-bottom-app-bar.scss +3 -5
- package/tokens/{v0_160 → 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_160 → 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_160 → v0_172}/_md-comp-dialog.scss +2 -4
- package/tokens/{v0_161 → v0_172}/_md-comp-divider.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-elevated-button.scss +2 -4
- package/tokens/{v0_160 → 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_160 → 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_160 → 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_160 → 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_160 → v0_172}/_md-comp-fab-secondary.scss +1 -1
- package/tokens/{v0_160 → 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_160 → v0_172}/_md-comp-fab-tertiary-large.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-fab-tertiary-small.scss +1 -1
- package/tokens/{v0_160 → 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_160 → v0_172}/_md-comp-filled-tonal-icon-button.scss +2 -2
- package/tokens/{v0_160 → v0_172}/_md-comp-filter-chip.scss +2 -4
- package/tokens/{v0_160 → v0_172}/_md-comp-full-screen-dialog.scss +3 -3
- package/tokens/{v0_160 → v0_172}/_md-comp-icon-button.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-input-chip.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-linear-progress-indicator.scss +2 -2
- package/tokens/{v0_160 → 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_160/_md-comp-navigation-bar.scss → v0_172/_md-comp-navigation-rail.scss} +9 -7
- package/tokens/{v0_160 → 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_160 → v0_172}/_md-comp-outlined-menu-button.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-outlined-segmented-button.scss +1 -1
- package/tokens/{v0_160 → 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_160 → v0_172}/_md-comp-primary-navigation-tab.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-radio-button.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-comp-rich-tooltip.scss +3 -5
- package/tokens/{v0_160 → 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_160 → v0_172}/_md-comp-secondary-navigation-tab.scss +3 -3
- package/tokens/{v0_160 → 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_160 → 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_160 → v0_172}/_md-comp-time-input.scss +3 -4
- package/tokens/{v0_160 → 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_160 → 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_160 → v0_172}/_md-sys-elevation.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-sys-motion.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-sys-shape.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-sys-state.scss +1 -1
- package/tokens/{v0_160 → v0_172}/_md-sys-typescale.scss +1 -1
- package/autocomplete/_filled-autocomplete.scss +0 -6
- package/autocomplete/_outlined-autocomplete.scss +0 -6
- package/autocomplete/autocomplete-item.d.ts +0 -19
- package/autocomplete/autocomplete-item.js +0 -22
- package/autocomplete/autocomplete-item.js.map +0 -1
- package/autocomplete/autocomplete-list.d.ts +0 -19
- package/autocomplete/autocomplete-list.js +0 -23
- package/autocomplete/autocomplete-list.js.map +0 -1
- package/autocomplete/autocomplete-surface.d.ts +0 -19
- package/autocomplete/autocomplete-surface.js +0 -23
- package/autocomplete/autocomplete-surface.js.map +0 -1
- package/autocomplete/filled-autocomplete.d.ts +0 -28
- package/autocomplete/filled-autocomplete.js +0 -46
- package/autocomplete/filled-autocomplete.js.map +0 -1
- package/autocomplete/lib/_filled-autocomplete.scss +0 -189
- package/autocomplete/lib/_outlined-autocomplete.scss +0 -178
- package/autocomplete/lib/_shared.scss +0 -25
- package/autocomplete/lib/autocomplete.d.ts +0 -54
- package/autocomplete/lib/autocomplete.js +0 -265
- package/autocomplete/lib/autocomplete.js.map +0 -1
- package/autocomplete/lib/autocompleteitem/autocomplete-item.d.ts +0 -11
- package/autocomplete/lib/autocompleteitem/autocomplete-item.js +0 -14
- package/autocomplete/lib/autocompleteitem/autocomplete-item.js.map +0 -1
- package/autocomplete/lib/autocompleteitem/harness.d.ts +0 -11
- package/autocomplete/lib/autocompleteitem/harness.js +0 -12
- package/autocomplete/lib/autocompleteitem/harness.js.map +0 -1
- package/autocomplete/lib/autocompletelist/_autocomplete-list.scss +0 -13
- package/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js +0 -9
- package/autocomplete/lib/autocompletelist/autocomplete-list-styles.css.js.map +0 -1
- package/autocomplete/lib/autocompletelist/autocomplete-list.d.ts +0 -14
- package/autocomplete/lib/autocompletelist/autocomplete-list.js +0 -21
- package/autocomplete/lib/autocompletelist/autocomplete-list.js.map +0 -1
- package/autocomplete/lib/autocompletelist/harness.d.ts +0 -11
- package/autocomplete/lib/autocompletelist/harness.js +0 -12
- package/autocomplete/lib/autocompletelist/harness.js.map +0 -1
- package/autocomplete/lib/autocompletesurface/_autocomplete-surface.scss +0 -13
- package/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js +0 -9
- package/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.js.map +0 -1
- package/autocomplete/lib/autocompletesurface/autocomplete-surface-styles.scss +0 -10
- package/autocomplete/lib/autocompletesurface/autocomplete-surface.d.ts +0 -13
- package/autocomplete/lib/autocompletesurface/autocomplete-surface.js +0 -21
- package/autocomplete/lib/autocompletesurface/autocomplete-surface.js.map +0 -1
- package/autocomplete/lib/filled-styles.css.js +0 -9
- package/autocomplete/lib/filled-styles.css.js.map +0 -1
- package/autocomplete/lib/filled-styles.scss +0 -10
- package/autocomplete/lib/outlined-styles.css.js +0 -9
- package/autocomplete/lib/outlined-styles.css.js.map +0 -1
- package/autocomplete/lib/outlined-styles.scss +0 -10
- package/autocomplete/lib/shared-styles.css.js +0 -9
- package/autocomplete/lib/shared-styles.css.js.map +0 -1
- package/autocomplete/outlined-autocomplete.d.ts +0 -28
- package/autocomplete/outlined-autocomplete.js +0 -46
- package/autocomplete/outlined-autocomplete.js.map +0 -1
- package/button/elevated-link-button.d.ts +0 -36
- package/button/elevated-link-button.js +0 -41
- package/button/elevated-link-button.js.map +0 -1
- package/button/filled-link-button.d.ts +0 -34
- package/button/filled-link-button.js +0 -39
- package/button/filled-link-button.js.map +0 -1
- package/button/lib/elevated-link-button.d.ts +0 -13
- package/button/lib/elevated-link-button.js +0 -21
- package/button/lib/elevated-link-button.js.map +0 -1
- package/button/lib/filled-link-button.d.ts +0 -14
- package/button/lib/filled-link-button.js +0 -22
- package/button/lib/filled-link-button.js.map +0 -1
- package/button/lib/link-button.d.ts +0 -24
- package/button/lib/link-button.js +0 -59
- package/button/lib/link-button.js.map +0 -1
- package/button/lib/outlined-link-button.d.ts +0 -12
- package/button/lib/outlined-link-button.js +0 -20
- package/button/lib/outlined-link-button.js.map +0 -1
- package/button/lib/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/chips/action/delete-action.d.ts +0 -18
- package/chips/action/delete-action.js +0 -20
- package/chips/action/delete-action.js.map +0 -1
- package/chips/action/lib/action.d.ts +0 -47
- package/chips/action/lib/action.js +0 -162
- package/chips/action/lib/action.js.map +0 -1
- package/chips/action/lib/constants.d.ts +0 -62
- package/chips/action/lib/constants.js +0 -69
- package/chips/action/lib/constants.js.map +0 -1
- package/chips/action/lib/delete-action.d.ts +0 -20
- package/chips/action/lib/delete-action.js +0 -65
- package/chips/action/lib/delete-action.js.map +0 -1
- package/chips/action/lib/events.d.ts +0 -14
- package/chips/action/lib/events.js +0 -16
- package/chips/action/lib/events.js.map +0 -1
- package/chips/action/lib/link-action.d.ts +0 -19
- package/chips/action/lib/link-action.js +0 -55
- package/chips/action/lib/link-action.js.map +0 -1
- package/chips/action/lib/presentational-action.d.ts +0 -15
- package/chips/action/lib/presentational-action.js +0 -30
- package/chips/action/lib/presentational-action.js.map +0 -1
- package/chips/action/lib/primary-action.d.ts +0 -28
- package/chips/action/lib/primary-action.js +0 -88
- package/chips/action/lib/primary-action.js.map +0 -1
- package/chips/action/lib/selectable-action.d.ts +0 -17
- package/chips/action/lib/selectable-action.js +0 -67
- package/chips/action/lib/selectable-action.js.map +0 -1
- package/chips/action/lib/types.d.ts +0 -23
- package/chips/action/lib/types.js +0 -7
- package/chips/action/lib/types.js.map +0 -1
- package/chips/action/link-action.d.ts +0 -18
- package/chips/action/link-action.js +0 -20
- package/chips/action/link-action.js.map +0 -1
- package/chips/action/presentational-action.d.ts +0 -18
- package/chips/action/presentational-action.js +0 -20
- package/chips/action/presentational-action.js.map +0 -1
- package/chips/action/primary-action.d.ts +0 -18
- package/chips/action/primary-action.js +0 -20
- package/chips/action/primary-action.js.map +0 -1
- package/chips/action/selectable-action.d.ts +0 -18
- package/chips/action/selectable-action.js +0 -20
- package/chips/action/selectable-action.js.map +0 -1
- package/chips/chip/lib/_assist-chip-theme.scss +0 -99
- package/chips/chip/lib/_chip-theme.scss +0 -1285
- package/chips/chip/lib/_chip.scss +0 -444
- package/chips/chip/lib/_filter-chip-theme.scss +0 -130
- package/chips/chip/lib/_input-chip-theme.scss +0 -91
- package/chips/chip/lib/_suggestion-chip-theme.scss +0 -92
- package/chips/chip/lib/action-chip.d.ts +0 -18
- package/chips/chip/lib/action-chip.js +0 -39
- package/chips/chip/lib/action-chip.js.map +0 -1
- package/chips/chip/lib/adapter.d.ts +0 -50
- package/chips/chip/lib/adapter.js +0 -7
- package/chips/chip/lib/adapter.js.map +0 -1
- package/chips/chip/lib/animationframe.d.ts +0 -31
- package/chips/chip/lib/animationframe.js +0 -66
- package/chips/chip/lib/animationframe.js.map +0 -1
- package/chips/chip/lib/chip.d.ts +0 -43
- package/chips/chip/lib/chip.js +0 -134
- package/chips/chip/lib/chip.js.map +0 -1
- package/chips/chip/lib/constants.d.ts +0 -43
- package/chips/chip/lib/constants.js +0 -48
- package/chips/chip/lib/constants.js.map +0 -1
- package/chips/chip/lib/foundation.d.ts +0 -41
- package/chips/chip/lib/foundation.js +0 -255
- package/chips/chip/lib/foundation.js.map +0 -1
- package/chips/chip/lib/link-chip.d.ts +0 -21
- package/chips/chip/lib/link-chip.js +0 -53
- package/chips/chip/lib/link-chip.js.map +0 -1
- package/chips/chip/lib/presentational-chip.d.ts +0 -18
- package/chips/chip/lib/presentational-chip.js +0 -39
- package/chips/chip/lib/presentational-chip.js.map +0 -1
- package/chips/chip/lib/selectable-chip.d.ts +0 -22
- package/chips/chip/lib/selectable-chip.js +0 -57
- package/chips/chip/lib/selectable-chip.js.map +0 -1
- package/chips/chip/lib/types.d.ts +0 -42
- package/chips/chip/lib/types.js +0 -7
- package/chips/chip/lib/types.js.map +0 -1
- package/chips/chipset/lib/_chip-set-theme.scss +0 -50
- package/chips/chipset/lib/_chip-set.scss +0 -48
- package/chips/chipset/lib/adapter.d.ts +0 -45
- package/chips/chipset/lib/adapter.js +0 -7
- package/chips/chipset/lib/adapter.js.map +0 -1
- package/chips/chipset/lib/constants.d.ts +0 -26
- package/chips/chipset/lib/constants.js +0 -30
- package/chips/chipset/lib/constants.js.map +0 -1
- package/chips/chipset/lib/foundation.d.ts +0 -68
- package/chips/chipset/lib/foundation.js +0 -314
- package/chips/chipset/lib/foundation.js.map +0 -1
- package/chips/chipset/lib/types.d.ts +0 -41
- package/chips/chipset/lib/types.js +0 -7
- package/chips/chipset/lib/types.js.map +0 -1
- package/elevation/lib/_md-comp-elevation.scss +0 -27
- package/focus/lib/_md-comp-focus-ring.scss +0 -31
- 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/menusurface/_menu-surface.scss +0 -6
- package/menusurface/lib/_md-comp-menu-surface.scss +0 -31
- package/menusurface/lib/_menu-surface.scss +0 -122
- package/menusurface/lib/adapter.d.ts +0 -46
- package/menusurface/lib/adapter.js +0 -7
- package/menusurface/lib/adapter.js.map +0 -1
- package/menusurface/lib/constants.d.ts +0 -71
- package/menusurface/lib/constants.js +0 -83
- package/menusurface/lib/constants.js.map +0 -1
- package/menusurface/lib/foundation.d.ts +0 -176
- package/menusurface/lib/foundation.js +0 -544
- package/menusurface/lib/foundation.js.map +0 -1
- package/menusurface/lib/menu-surface-styles.css.js +0 -9
- package/menusurface/lib/menu-surface-styles.css.js.map +0 -1
- package/menusurface/lib/menu-surface.d.ts +0 -62
- package/menusurface/lib/menu-surface.js +0 -347
- package/menusurface/lib/menu-surface.js.map +0 -1
- package/menusurface/lib/types.d.ts +0 -19
- package/menusurface/lib/types.js +0 -7
- package/menusurface/lib/types.js.map +0 -1
- package/menusurface/menu-surface.d.ts +0 -14
- package/menusurface/menu-surface.js +0 -17
- package/menusurface/menu-surface.js.map +0 -1
- package/sass/_elevation.scss +0 -159
- package/sass/_resolvers.scss +0 -16
- package/sass/_typography.scss +0 -39
- package/tokens/v0_160/_md-comp-assist-chip.scss +0 -109
- package/tokens/v0_160/_md-comp-checkbox.scss +0 -126
- package/tokens/v0_160/_md-comp-circular-progress-indicator.scss +0 -39
- package/tokens/v0_160/_md-comp-date-input-modal.scss +0 -89
- package/tokens/v0_160/_md-comp-date-picker-docked.scss +0 -246
- package/tokens/v0_160/_md-comp-date-picker-modal.scss +0 -305
- package/tokens/v0_160/_md-comp-divider.scss +0 -25
- package/tokens/v0_160/_md-comp-extended-fab-branded.scss +0 -86
- package/tokens/v0_160/_md-comp-extended-fab-primary.scss +0 -94
- package/tokens/v0_160/_md-comp-extended-fab-surface.scss +0 -90
- package/tokens/v0_160/_md-comp-extended-fab-tertiary.scss +0 -95
- package/tokens/v0_160/_md-comp-fab-branded-large.scss +0 -60
- package/tokens/v0_160/_md-comp-fab-primary-large.scss +0 -65
- package/tokens/v0_160/_md-comp-fab-primary-small.scss +0 -65
- package/tokens/v0_160/_md-comp-fab-secondary-large.scss +0 -66
- package/tokens/v0_160/_md-comp-fab-secondary-small.scss +0 -66
- package/tokens/v0_160/_md-comp-fab-surface-small.scss +0 -64
- package/tokens/v0_160/_md-comp-fab-surface.scss +0 -64
- package/tokens/v0_160/_md-comp-filled-autocomplete.scss +0 -267
- package/tokens/v0_160/_md-comp-filled-button.scss +0 -89
- package/tokens/v0_160/_md-comp-filled-card.scss +0 -58
- package/tokens/v0_160/_md-comp-filled-icon-button.scss +0 -79
- package/tokens/v0_160/_md-comp-filled-menu-button.scss +0 -98
- package/tokens/v0_160/_md-comp-filled-select.scss +0 -272
- package/tokens/v0_160/_md-comp-filled-text-field.scss +0 -189
- package/tokens/v0_160/_md-comp-filled-tonal-button.scss +0 -99
- package/tokens/v0_160/_md-comp-menu.scss +0 -121
- package/tokens/v0_160/_md-comp-navigation-drawer.scss +0 -162
- package/tokens/v0_160/_md-comp-navigation-rail.scss +0 -131
- package/tokens/v0_160/_md-comp-outlined-button.scss +0 -84
- package/tokens/v0_160/_md-comp-outlined-card.scss +0 -65
- package/tokens/v0_160/_md-comp-outlined-icon-button.scss +0 -79
- package/tokens/v0_160/_md-comp-outlined-text-field.scss +0 -171
- package/tokens/v0_160/_md-comp-plain-tooltip.scss +0 -55
- package/tokens/v0_160/_md-comp-search-bar.scss +0 -99
- package/tokens/v0_160/_md-comp-search-view.scss +0 -93
- package/tokens/v0_160/_md-comp-sheet-floating.scss +0 -34
- package/tokens/v0_160/_md-comp-sheet-side.scss +0 -91
- package/tokens/v0_160/_md-comp-snackbar.scss +0 -127
- package/tokens/v0_160/_md-comp-standard-menu-button.scss +0 -98
- package/tokens/v0_160/_md-comp-suggestion-chip.scss +0 -125
- package/tokens/v0_160/_md-comp-switch.scss +0 -136
- package/tokens/v0_160/_md-comp-text-button.scss +0 -77
- package/tokens/v0_160/_md-comp-top-app-bar-large.scss +0 -63
- package/tokens/v0_160/_md-comp-top-app-bar-medium.scss +0 -63
- package/tokens/v0_160/_md-comp-top-app-bar-small-centered.scss +0 -66
- package/tokens/v0_160/_md-ref-palette.scss +0 -107
- package/tokens/v0_160/_md-ref-typeface.scss +0 -21
- package/tokens/v0_160/_md-sys-color.scss +0 -904
- package/tokens/v0_161/_index.scss +0 -107
- package/tokens/v0_161/_md-comp-badge.scss +0 -58
- package/tokens/v0_161/_md-comp-banner.scss +0 -75
- package/tokens/v0_161/_md-comp-bottom-app-bar.scss +0 -35
- package/tokens/v0_161/_md-comp-carousel-item.scss +0 -65
- package/tokens/v0_161/_md-comp-data-table.scss +0 -96
- package/tokens/v0_161/_md-comp-dialog.scss +0 -123
- package/tokens/v0_161/_md-comp-elevated-button.scss +0 -91
- package/tokens/v0_161/_md-comp-elevated-card.scss +0 -59
- package/tokens/v0_161/_md-comp-extended-fab-secondary.scss +0 -95
- package/tokens/v0_161/_md-comp-fab-branded.scss +0 -60
- package/tokens/v0_161/_md-comp-fab-primary.scss +0 -65
- package/tokens/v0_161/_md-comp-fab-secondary.scss +0 -66
- package/tokens/v0_161/_md-comp-fab-surface-large.scss +0 -64
- package/tokens/v0_161/_md-comp-fab-tertiary-large.scss +0 -66
- package/tokens/v0_161/_md-comp-fab-tertiary-small.scss +0 -66
- package/tokens/v0_161/_md-comp-fab-tertiary.scss +0 -66
- package/tokens/v0_161/_md-comp-filled-tonal-icon-button.scss +0 -86
- package/tokens/v0_161/_md-comp-filter-chip.scss +0 -209
- package/tokens/v0_161/_md-comp-full-screen-dialog.scss +0 -111
- package/tokens/v0_161/_md-comp-icon-button.scss +0 -70
- package/tokens/v0_161/_md-comp-input-chip.scss +0 -184
- package/tokens/v0_161/_md-comp-linear-progress-indicator.scss +0 -41
- package/tokens/v0_161/_md-comp-list.scss +0 -248
- package/tokens/v0_161/_md-comp-navigation-rail.scss +0 -131
- package/tokens/v0_161/_md-comp-outlined-autocomplete.scss +0 -257
- package/tokens/v0_161/_md-comp-outlined-menu-button.scss +0 -94
- package/tokens/v0_161/_md-comp-outlined-segmented-button.scss +0 -112
- package/tokens/v0_161/_md-comp-outlined-select.scss +0 -262
- package/tokens/v0_161/_md-comp-primary-navigation-tab.scss +0 -121
- package/tokens/v0_161/_md-comp-radio-button.scss +0 -68
- package/tokens/v0_161/_md-comp-rich-tooltip.scss +0 -121
- package/tokens/v0_161/_md-comp-scrim.scss +0 -25
- package/tokens/v0_161/_md-comp-secondary-navigation-tab.scss +0 -84
- package/tokens/v0_161/_md-comp-sheet-bottom.scss +0 -45
- package/tokens/v0_161/_md-comp-slider.scss +0 -114
- package/tokens/v0_161/_md-comp-time-input.scss +0 -218
- package/tokens/v0_161/_md-comp-time-picker.scss +0 -264
- package/tokens/v0_161/_md-comp-top-app-bar-small.scss +0 -64
- package/tokens/v0_161/_md-sys-elevation.scss +0 -21
- package/tokens/v0_161/_md-sys-motion.scss +0 -53
- package/tokens/v0_161/_md-sys-shape.scss +0 -30
- package/tokens/v0_161/_md-sys-state.scss +0 -19
- package/tokens/v0_161/_md-sys-typescale.scss +0 -284
- package/tokens/v0_161/index.test.css.js +0 -9
- package/tokens/v0_161/index.test.css.js.map +0 -1
- package/tokens/v0_161/index.test.scss +0 -584
- package/tokens/v0_161/lib.test.css.d.ts +0 -1
- package/tokens/v0_161/lib.test.css.js +0 -9
- package/tokens/v0_161/lib.test.css.js.map +0 -1
- package/tokens/v0_161/lib.test.scss +0 -663
- /package/{autocomplete/lib/autocompletelist/autocomplete-list-styles.css.d.ts → chips/lib/assist-styles.css.d.ts} +0 -0
- /package/{autocomplete → chips}/lib/shared-styles.css.d.ts +0 -0
- /package/{autocomplete/lib/autocompletesurface/autocomplete-surface-styles.css.d.ts → chips/lib/suggestion-styles.css.d.ts} +0 -0
- /package/{autocomplete/lib/filled-styles.css.d.ts → circularprogress/lib/circular-progress-styles.css.d.ts} +0 -0
- /package/{autocomplete/lib/outlined-styles.css.d.ts → list/lib/listitem/forced-colors-styles.css.d.ts} +0 -0
- /package/{menusurface/lib/menu-surface-styles.css.d.ts → menu/lib/forced-colors-styles.css.d.ts} +0 -0
- /package/{tokens/v0_160/index.test.css.d.ts → menu/lib/menuitem/forced-colors-styles.css.d.ts} +0 -0
- /package/tokens/{v0_160 → v0_172}/_index.scss +0 -0
- /package/tokens/{v0_161 → v0_172}/index.test.css.d.ts +0 -0
- /package/tokens/{v0_160 → v0_172}/index.test.css.js +0 -0
- /package/tokens/{v0_160 → v0_172}/index.test.css.js.map +0 -0
- /package/tokens/{v0_160 → v0_172}/index.test.scss +0 -0
- /package/tokens/{v0_160 → v0_172}/lib.test.css.d.ts +0 -0
- /package/tokens/{v0_160 → v0_172}/lib.test.css.js +0 -0
- /package/tokens/{v0_160 → v0_172}/lib.test.css.js.map +0 -0
- /package/tokens/{v0_160 → v0_172}/lib.test.scss +0 -0
|
@@ -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,YAAY,EAAkB,oBAAoB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAElI,SAAS,eAAe,CAAC,CAAQ;IAC/B,CAAC,CAAC,eAAe,EAAE,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAA3C;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AAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;QACvE,QAAQ,IAAI,EAAE;YACZ,KAAK,aAAa,CAAC;YACnB,KAAK,aAAa,CAAC,KAAK,CAAC;YACzB,KAAK,aAAa,CAAC,KAAK;gBACtB,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;IAED;;;;;;OAMG;IACO,iBAAiB,CAAC,IAAY;QACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;QACzD,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;QACvE,QAAQ,IAAI,EAAE;YACZ,KAAK,aAAa,CAAC;YACnB,KAAK,kBAAkB,CAAC,MAAM;gBAC5B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF;AAjPC;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;AAEtB;IAAC,qBAAqB,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;;0CAA0B","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 {CLOSE_REASON, CloseMenuEvent, DeactivateItemsEvent, 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 */\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'}) 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 // 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 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.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 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,0BAA0B,CAAC;AACpD,OAAO,EAAC,sBAAsB,EAAE,YAAY,EAAkB,oBAAoB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAEpL,SAAS,eAAe,CAAC,CAAQ;IAC/B,CAAC,CAAC,eAAe,EAAE,CAAC;AACtB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,WAAY,SAAQ,UAAU;IAA3C;;QACW,SAAI,GAAa,UAAU,CAAC;QACrC;;WAEG;QACqC,iBAAY,GAAW,WAAW,CAAC;QAC3E;;WAEG;QACmC,eAAU,GAAW,aAAa,CAAC;QACzE;;WAEG;QACsD,mBAAc,GAAG,GAAG,CAAC;QAC9E;;WAEG;QAEH,oBAAe,GAAG,GAAG,CAAC;QACtB;;WAEG;QACuC,aAAQ,GAAG,KAAK,CAAC;QAKxC,oBAAe,GAAG,IAAI,CAAC;QAChC,wBAAmB,GAAG,CAAC,CAAC;QACxB,yBAAoB,GAAG,CAAC,CAAC;QAMnC;;WAEG;QACgB,mBAAc,GAAG,GAAG,EAAE;YACvC,YAAY,CAAC,IAAI,CAAC,m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AAC,KAAK,CAAC;QACvE,QAAQ,IAAI,EAAE;YACZ,KAAK,aAAa,CAAC;YACnB,KAAK,aAAa,CAAC,KAAK,CAAC;YACzB,KAAK,aAAa,CAAC,KAAK;gBACtB,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;IAED;;;;;;OAMG;IACO,iBAAiB,CAAC,IAAY;QACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC;QACzD,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC;QACvE,QAAQ,IAAI,EAAE;YACZ,KAAK,aAAa,CAAC;YACnB,KAAK,kBAAkB,CAAC,MAAM;gBAC5B,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"]}
|
|
@@ -9,6 +9,14 @@ import { StyleInfo } from 'lit/directives/style-map.js';
|
|
|
9
9
|
* A corner of a box in the standard logical property style of <block>_<inline>
|
|
10
10
|
*/
|
|
11
11
|
export type Corner = 'END_START' | 'END_END' | 'START_START' | 'START_END';
|
|
12
|
+
/**
|
|
13
|
+
* An interface that provides a method to customize the rect from which to
|
|
14
|
+
* calculate the anchor positioning. Useful for when you want a surface to
|
|
15
|
+
* anchor to an element in your shadow DOM rather than the host element.
|
|
16
|
+
*/
|
|
17
|
+
export interface SurfacePositionTarget extends HTMLElement {
|
|
18
|
+
getSurfacePositionClientRect?: () => DOMRect;
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
21
|
* The configurable options for the surface position controller.
|
|
14
22
|
*/
|
|
@@ -24,11 +32,11 @@ export interface SurfacePositionControllerProperties {
|
|
|
24
32
|
/**
|
|
25
33
|
* The HTMLElement reference of the surface to be positioned.
|
|
26
34
|
*/
|
|
27
|
-
surfaceEl:
|
|
35
|
+
surfaceEl: SurfacePositionTarget | null;
|
|
28
36
|
/**
|
|
29
37
|
* The HTMLElement reference of the anchor to align to.
|
|
30
38
|
*/
|
|
31
|
-
anchorEl:
|
|
39
|
+
anchorEl: SurfacePositionTarget | null;
|
|
32
40
|
/**
|
|
33
41
|
* Whether or not the calculation should be relative to the top layer rather
|
|
34
42
|
* than relative to the parent of the anchor.
|
|
@@ -55,8 +55,12 @@ export class SurfacePositionController {
|
|
|
55
55
|
// Wait for it to be visible.
|
|
56
56
|
this.host.requestUpdate();
|
|
57
57
|
await this.host.updateComplete;
|
|
58
|
-
const surfaceRect = surfaceEl.
|
|
59
|
-
|
|
58
|
+
const surfaceRect = surfaceEl.getSurfacePositionClientRect ?
|
|
59
|
+
surfaceEl.getSurfacePositionClientRect() :
|
|
60
|
+
surfaceEl.getBoundingClientRect();
|
|
61
|
+
const anchorRect = anchorEl.getSurfacePositionClientRect ?
|
|
62
|
+
anchorEl.getSurfacePositionClientRect() :
|
|
63
|
+
anchorEl.getBoundingClientRect();
|
|
60
64
|
const [surfaceBlock, surfaceInline] = surfaceCorner.split('_');
|
|
61
65
|
const [anchorBlock, anchorInline] = anchorCorner.split('_');
|
|
62
66
|
// We use number booleans to multiply values rather than `if` / ternary
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfacePositionController.js","sourceRoot":"","sources":["surfacePositionController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4EH;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAUpC;;;;OAIG;IACH,YACqB,IAA4B,EAC5B,aAAwD;QADxD,SAAI,GAAJ,IAAI,CAAwB;QAC5B,kBAAa,GAAb,aAAa,CAA2C;QAhB7E,8CAA8C;QACtC,0BAAqB,GAAc;YACzC,SAAS,EAAE,MAAM;SAClB,CAAC;QACF,wEAAwE;QACxE,+CAA+C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AAC,MAAM,EAAE,CAAC;aAChB;iBAAM,IAAI,WAAW,EAAE;gBACtB,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;gBAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,KAAK,CAAC,OAAO,EAAE,CAAC;aACjB;SACF;IACH,CAAC;IAED;;OAEG;IACK,KAAK;QACX,IAAI,CAAC,qBAAqB,GAAG;YAC3B,SAAS,EAAE,MAAM;SAClB,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ReactiveController, ReactiveControllerHost} from 'lit';\nimport {StyleInfo} from 'lit/directives/style-map.js';\n\n/**\n * A corner of a box in the standard logical property style of <block>_<inline>\n */\nexport type Corner = 'END_START'|'END_END'|'START_START'|'START_END';\n\n/**\n * The configurable options for the surface position controller.\n */\nexport interface SurfacePositionControllerProperties {\n /**\n * The corner of the anchor to align the surface's position.\n */\n anchorCorner: Corner;\n /**\n * The corner of the surface to align to the given anchor corner.\n */\n surfaceCorner: Corner;\n /**\n * The HTMLElement reference of the surface to be positioned.\n */\n surfaceEl: HTMLElement|null;\n /**\n * The HTMLElement reference of the anchor to align to.\n */\n anchorEl: HTMLElement|null;\n /**\n * Whether or not the calculation should be relative to the top layer rather\n * than relative to the parent of the anchor.\n *\n * Examples for `isTopLayer:true`:\n *\n * - If there is no `position:relative` in the given parent tree and the\n * surface is `position:absolute`\n * - If the surface is `position:fixed`\n * - If the surface is in the \"top layer\"\n * - The anchor and the surface do not share a common `position:relative`\n * ancestor\n */\n isTopLayer: boolean;\n /**\n * Whether or not the surface should be \"open\" and visible\n */\n isOpen: boolean;\n /**\n * The number of pixels in which to offset from the inline axis relative to\n * logical property.\n *\n * Positive is right in LTR and left in RTL.\n */\n xOffset: number;\n /**\n * The number of pixes in which to offset the block axis.\n *\n * Positive is down and negative is up.\n */\n yOffset: number;\n /**\n * A function to call after the surface has been positioned.\n */\n onOpen: () => void;\n /**\n * A function to call before the surface should be closed. (A good time to\n * perform animations while the surface is still visible)\n */\n beforeClose: () => Promise<void>;\n /**\n * A function to call after the surface has been closed.\n */\n onClose: () => void;\n}\n\n/**\n * Given a surface, an anchor, corners, and some options, this surface will\n * calculate the position of a surface to align the two given corners and keep\n * the surface inside the window viewport. It also provides a StyleInfo map that\n * can be applied to the surface to handle visiblility and position.\n */\nexport class SurfacePositionController implements ReactiveController {\n // The current styles to apply to the surface.\n private surfaceStylesInternal: StyleInfo = {\n 'display': 'none',\n };\n // Previous values stored for change detection. Open change detection is\n // calculated separately so initialize it here.\n private lastValues: SurfacePositionControllerProperties = {isOpen: false} as\n SurfacePositionControllerProperties;\n\n /**\n * @param host The host to connect the controller to.\n * @param getProperties A function that returns the properties for the\n * controller.\n */\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly getProperties: () => SurfacePositionControllerProperties,\n ) {\n this.host.addController(this);\n }\n\n /**\n * The StyleInfo map to apply to the surface via Lit's stylemap\n */\n get surfaceStyles() {\n return this.surfaceStylesInternal;\n }\n\n /**\n * Calculates the surface's new position required so that the surface's\n * `surfaceCorner` aligns to the anchor's `anchorCorner` while keeping the\n * surface inside the window viewport. This positioning also respects RTL by\n * checking `getComputedStyle()` on the surface element.\n */\n async position() {\n const {\n surfaceEl,\n anchorEl,\n anchorCorner: anchorCornerRaw,\n surfaceCorner: surfaceCornerRaw,\n isTopLayer: topLayerRaw,\n xOffset,\n yOffset,\n } = this.getProperties();\n const anchorCorner = anchorCornerRaw.toUpperCase().trim();\n const surfaceCorner = surfaceCornerRaw.toUpperCase().trim();\n\n if (!surfaceEl || !anchorEl) {\n return;\n }\n\n // Paint the surface transparently so that we can get the position and the\n // rect info of the surface.\n this.surfaceStylesInternal = {\n 'display': 'block',\n 'opacity': '0',\n };\n\n // Wait for it to be visible.\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n const surfaceRect = surfaceEl.getBoundingClientRect();\n const anchorRect = anchorEl.getBoundingClientRect();\n const [surfaceBlock, surfaceInline] =\n surfaceCorner.split('_') as Array<'START'|'END'>;\n const [anchorBlock, anchorInline] =\n anchorCorner.split('_') as Array<'START'|'END'>;\n\n\n // We use number booleans to multiply values rather than `if` / ternary\n // statements because it _heavily_ cuts down on nesting and readability\n const isTopLayer = topLayerRaw ? 1 : 0;\n // LTR depends on the direction of the SURFACE not the anchor.\n const isLTR = getComputedStyle(surfaceEl).direction === 'ltr' ? 1 : 0;\n const isRTL = isLTR ? 0 : 1;\n const isSurfaceInlineStart = surfaceInline === 'START' ? 1 : 0;\n const isSurfaceInlineEnd = surfaceInline === 'END' ? 1 : 0;\n const isSurfaceBlockStart = surfaceBlock === 'START' ? 1 : 0;\n const isSurfaceBlockEnd = surfaceBlock === 'END' ? 1 : 0;\n const isOneInlineEnd = anchorInline !== surfaceInline ? 1 : 0;\n const isOneBlockEnd = anchorBlock !== surfaceBlock ? 1 : 0;\n\n /*\n * A diagram that helps describe some of the variables used in the following\n * calculations.\n *\n * ┌───── inline/blockTopLayerOffset\n * │ │\n * │ ┌─▼───┐ Window\n * │ ┌┼─────┴────────────────────────┐\n * │ ││ │\n * └──► ││ ┌──inline/blockAnchorOffset │\n * ││ │ │ │\n * └┤ │ ┌──▼───┐ │\n * │ │ ┌┼──────┤ │\n * │ └─►│Anchor│ │\n * │ └┴──────┘ │\n * │ │\n * │ ┌────────────────────────┼────┐\n * │ │ Surface │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * └─────┼────────────────────────┘ ├┐\n * │ inline/blockOOBCorrection ││\n * │ │ ││\n * │ ├──►││\n * │ │ ││\n * └────────────────────────┐▼───┼┘\n * └────┘\n */\n\n // Whether or not to apply the width of the anchor\n const inlineAnchorOffset = isOneInlineEnd * anchorRect.width + xOffset;\n // The inline position of the anchor relative to window in LTR\n const inlineTopLayerOffsetLTR = isSurfaceInlineStart * anchorRect.left +\n isSurfaceInlineEnd * (window.innerWidth - anchorRect.right);\n // The inline position of the anchor relative to window in RTL\n const inlineTopLayerOffsetRTL =\n isSurfaceInlineStart * (window.innerWidth - anchorRect.right) +\n isSurfaceInlineEnd * anchorRect.left;\n // The inline position of the anchor relative to window\n const inlineTopLayerOffset =\n isLTR * inlineTopLayerOffsetLTR + isRTL * inlineTopLayerOffsetRTL;\n // If the surface's inline would be out of bounds of the window, move it\n // back in\n const inlineOutOfBoundsCorrection = Math.min(\n 0,\n window.innerWidth - inlineTopLayerOffset - inlineAnchorOffset -\n surfaceRect.width);\n\n // The inline logical value of the surface\n const inline = isTopLayer * inlineTopLayerOffset + inlineAnchorOffset +\n inlineOutOfBoundsCorrection;\n\n // Whether or not to apply the height of the anchor\n const blockAnchorOffset = isOneBlockEnd * anchorRect.height + yOffset;\n // The absolute block position of the anchor relative to window\n const blockTopLayerOffset = isSurfaceBlockStart * anchorRect.top +\n isSurfaceBlockEnd * (window.innerHeight - anchorRect.bottom);\n // If the surface's block would be out of bounds of the window, move it back\n // in\n const blockOutOfBoundsCorrection = Math.min(\n 0,\n window.innerHeight - blockTopLayerOffset - blockAnchorOffset -\n surfaceRect.height);\n\n // The block logical value of the surface\n const block = isTopLayer * blockTopLayerOffset + blockAnchorOffset +\n blockOutOfBoundsCorrection;\n\n const surfaceBlockProperty =\n surfaceBlock === 'START' ? 'inset-block-start' : 'inset-block-end';\n const surfaceInlineProperty =\n surfaceInline === 'START' ? 'inset-inline-start' : 'inset-inline-end';\n\n this.surfaceStylesInternal = {\n 'display': 'block',\n 'opacity': '1',\n [surfaceBlockProperty]: `${block}px`,\n [surfaceInlineProperty]: `${inline}px`,\n };\n\n this.host.requestUpdate();\n }\n\n hostUpdate() {\n this.onUpdate();\n }\n\n hostUpdated() {\n this.onUpdate();\n }\n\n /**\n * Checks whether the properties passed into the controller have changed since\n * the last positioning. If so, it will reposition if the surface is open or\n * close it if the surface should close.\n */\n private async onUpdate() {\n const props = this.getProperties();\n let hasChanged = false;\n for (const [key, value] of Object.entries(props)) {\n // tslint:disable-next-line\n hasChanged = hasChanged || (value !== (this.lastValues as any)[key]);\n if (hasChanged) break;\n }\n\n const openChanged = this.lastValues.isOpen !== props.isOpen;\n const hasAnchor = !!props.anchorEl;\n const hasSurface = !!props.surfaceEl;\n\n if (hasChanged && hasAnchor && hasSurface) {\n // Only update isOpen, because if it's closed, we do not want to waste\n // time on a useless reposition calculation. So save the other \"dirty\"\n // values until next time it opens.\n this.lastValues.isOpen = props.isOpen;\n\n if (props.isOpen) {\n // We are going to do a reposition, so save the prop values for future\n // dirty checking.\n this.lastValues = props;\n\n await this.position();\n props.onOpen();\n } else if (openChanged) {\n await props.beforeClose();\n this.close();\n props.onClose();\n }\n }\n }\n\n /**\n * Hides the surface.\n */\n private close() {\n this.surfaceStylesInternal = {\n 'display': 'none',\n };\n this.host.requestUpdate();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"surfacePositionController.js","sourceRoot":"","sources":["surfacePositionController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqFH;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IAUpC;;;;OAIG;IACH,YACqB,IAA4B,EAC5B,aAAwD;QADxD,SAAI,GAAJ,IAAI,CAAwB;QAC5B,kBAAa,GAAb,aAAa,CAA2C;QAhB7E,8CAA8C;QACtC,0BAAqB,GAAc;YACzC,SAAS,EAAE,MAAM;SAClB,CAAC;QACF,wEAAwE;QACxE,+CAA+C;QACvC,eAAU,GAAwC,EAAC,MAAM,EAAE,KAAK,EACjC,CAAC;QAWtC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,EACJ,SAAS,EACT,QAAQ,EACR,YAAY,EAAE,eAAe,EAC7B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KAAK,CAAC,OAAO,EAAE,CAAC;aACjB;SACF;IACH,CAAC;IAED;;OAEG;IACK,KAAK;QACX,IAAI,CAAC,qBAAqB,GAAG;YAC3B,SAAS,EAAE,MAAM;SAClB,CAAC;QACF,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {ReactiveController, ReactiveControllerHost} from 'lit';\nimport {StyleInfo} from 'lit/directives/style-map.js';\n\n/**\n * A corner of a box in the standard logical property style of <block>_<inline>\n */\nexport type Corner = 'END_START'|'END_END'|'START_START'|'START_END';\n\n/**\n * An interface that provides a method to customize the rect from which to\n * calculate the anchor positioning. Useful for when you want a surface to\n * anchor to an element in your shadow DOM rather than the host element.\n */\nexport interface SurfacePositionTarget extends HTMLElement {\n getSurfacePositionClientRect?: () => DOMRect;\n}\n\n/**\n * The configurable options for the surface position controller.\n */\nexport interface SurfacePositionControllerProperties {\n /**\n * The corner of the anchor to align the surface's position.\n */\n anchorCorner: Corner;\n /**\n * The corner of the surface to align to the given anchor corner.\n */\n surfaceCorner: Corner;\n /**\n * The HTMLElement reference of the surface to be positioned.\n */\n surfaceEl: SurfacePositionTarget|null;\n /**\n * The HTMLElement reference of the anchor to align to.\n */\n anchorEl: SurfacePositionTarget|null;\n /**\n * Whether or not the calculation should be relative to the top layer rather\n * than relative to the parent of the anchor.\n *\n * Examples for `isTopLayer:true`:\n *\n * - If there is no `position:relative` in the given parent tree and the\n * surface is `position:absolute`\n * - If the surface is `position:fixed`\n * - If the surface is in the \"top layer\"\n * - The anchor and the surface do not share a common `position:relative`\n * ancestor\n */\n isTopLayer: boolean;\n /**\n * Whether or not the surface should be \"open\" and visible\n */\n isOpen: boolean;\n /**\n * The number of pixels in which to offset from the inline axis relative to\n * logical property.\n *\n * Positive is right in LTR and left in RTL.\n */\n xOffset: number;\n /**\n * The number of pixes in which to offset the block axis.\n *\n * Positive is down and negative is up.\n */\n yOffset: number;\n /**\n * A function to call after the surface has been positioned.\n */\n onOpen: () => void;\n /**\n * A function to call before the surface should be closed. (A good time to\n * perform animations while the surface is still visible)\n */\n beforeClose: () => Promise<void>;\n /**\n * A function to call after the surface has been closed.\n */\n onClose: () => void;\n}\n\n/**\n * Given a surface, an anchor, corners, and some options, this surface will\n * calculate the position of a surface to align the two given corners and keep\n * the surface inside the window viewport. It also provides a StyleInfo map that\n * can be applied to the surface to handle visiblility and position.\n */\nexport class SurfacePositionController implements ReactiveController {\n // The current styles to apply to the surface.\n private surfaceStylesInternal: StyleInfo = {\n 'display': 'none',\n };\n // Previous values stored for change detection. Open change detection is\n // calculated separately so initialize it here.\n private lastValues: SurfacePositionControllerProperties = {isOpen: false} as\n SurfacePositionControllerProperties;\n\n /**\n * @param host The host to connect the controller to.\n * @param getProperties A function that returns the properties for the\n * controller.\n */\n constructor(\n private readonly host: ReactiveControllerHost,\n private readonly getProperties: () => SurfacePositionControllerProperties,\n ) {\n this.host.addController(this);\n }\n\n /**\n * The StyleInfo map to apply to the surface via Lit's stylemap\n */\n get surfaceStyles() {\n return this.surfaceStylesInternal;\n }\n\n /**\n * Calculates the surface's new position required so that the surface's\n * `surfaceCorner` aligns to the anchor's `anchorCorner` while keeping the\n * surface inside the window viewport. This positioning also respects RTL by\n * checking `getComputedStyle()` on the surface element.\n */\n async position() {\n const {\n surfaceEl,\n anchorEl,\n anchorCorner: anchorCornerRaw,\n surfaceCorner: surfaceCornerRaw,\n isTopLayer: topLayerRaw,\n xOffset,\n yOffset,\n } = this.getProperties();\n const anchorCorner = anchorCornerRaw.toUpperCase().trim();\n const surfaceCorner = surfaceCornerRaw.toUpperCase().trim();\n\n if (!surfaceEl || !anchorEl) {\n return;\n }\n\n // Paint the surface transparently so that we can get the position and the\n // rect info of the surface.\n this.surfaceStylesInternal = {\n 'display': 'block',\n 'opacity': '0',\n };\n\n // Wait for it to be visible.\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n const surfaceRect = surfaceEl.getSurfacePositionClientRect ?\n surfaceEl.getSurfacePositionClientRect() :\n surfaceEl.getBoundingClientRect();\n const anchorRect = anchorEl.getSurfacePositionClientRect ?\n anchorEl.getSurfacePositionClientRect() :\n anchorEl.getBoundingClientRect();\n const [surfaceBlock, surfaceInline] =\n surfaceCorner.split('_') as Array<'START'|'END'>;\n const [anchorBlock, anchorInline] =\n anchorCorner.split('_') as Array<'START'|'END'>;\n\n\n // We use number booleans to multiply values rather than `if` / ternary\n // statements because it _heavily_ cuts down on nesting and readability\n const isTopLayer = topLayerRaw ? 1 : 0;\n // LTR depends on the direction of the SURFACE not the anchor.\n const isLTR =\n getComputedStyle(surfaceEl as HTMLElement).direction === 'ltr' ? 1 : 0;\n const isRTL = isLTR ? 0 : 1;\n const isSurfaceInlineStart = surfaceInline === 'START' ? 1 : 0;\n const isSurfaceInlineEnd = surfaceInline === 'END' ? 1 : 0;\n const isSurfaceBlockStart = surfaceBlock === 'START' ? 1 : 0;\n const isSurfaceBlockEnd = surfaceBlock === 'END' ? 1 : 0;\n const isOneInlineEnd = anchorInline !== surfaceInline ? 1 : 0;\n const isOneBlockEnd = anchorBlock !== surfaceBlock ? 1 : 0;\n\n /*\n * A diagram that helps describe some of the variables used in the following\n * calculations.\n *\n * ┌───── inline/blockTopLayerOffset\n * │ │\n * │ ┌─▼───┐ Window\n * │ ┌┼─────┴────────────────────────┐\n * │ ││ │\n * └──► ││ ┌──inline/blockAnchorOffset │\n * ││ │ │ │\n * └┤ │ ┌──▼───┐ │\n * │ │ ┌┼──────┤ │\n * │ └─►│Anchor│ │\n * │ └┴──────┘ │\n * │ │\n * │ ┌────────────────────────┼────┐\n * │ │ Surface │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * │ │ │ │\n * └─────┼────────────────────────┘ ├┐\n * │ inline/blockOOBCorrection ││\n * │ │ ││\n * │ ├──►││\n * │ │ ││\n * └────────────────────────┐▼───┼┘\n * └────┘\n */\n\n // Whether or not to apply the width of the anchor\n const inlineAnchorOffset = isOneInlineEnd * anchorRect.width + xOffset;\n // The inline position of the anchor relative to window in LTR\n const inlineTopLayerOffsetLTR = isSurfaceInlineStart * anchorRect.left +\n isSurfaceInlineEnd * (window.innerWidth - anchorRect.right);\n // The inline position of the anchor relative to window in RTL\n const inlineTopLayerOffsetRTL =\n isSurfaceInlineStart * (window.innerWidth - anchorRect.right) +\n isSurfaceInlineEnd * anchorRect.left;\n // The inline position of the anchor relative to window\n const inlineTopLayerOffset =\n isLTR * inlineTopLayerOffsetLTR + isRTL * inlineTopLayerOffsetRTL;\n // If the surface's inline would be out of bounds of the window, move it\n // back in\n const inlineOutOfBoundsCorrection = Math.min(\n 0,\n window.innerWidth - inlineTopLayerOffset - inlineAnchorOffset -\n surfaceRect.width);\n\n // The inline logical value of the surface\n const inline = isTopLayer * inlineTopLayerOffset + inlineAnchorOffset +\n inlineOutOfBoundsCorrection;\n\n // Whether or not to apply the height of the anchor\n const blockAnchorOffset = isOneBlockEnd * anchorRect.height + yOffset;\n // The absolute block position of the anchor relative to window\n const blockTopLayerOffset = isSurfaceBlockStart * anchorRect.top +\n isSurfaceBlockEnd * (window.innerHeight - anchorRect.bottom);\n // If the surface's block would be out of bounds of the window, move it back\n // in\n const blockOutOfBoundsCorrection = Math.min(\n 0,\n window.innerHeight - blockTopLayerOffset - blockAnchorOffset -\n surfaceRect.height);\n\n // The block logical value of the surface\n const block = isTopLayer * blockTopLayerOffset + blockAnchorOffset +\n blockOutOfBoundsCorrection;\n\n const surfaceBlockProperty =\n surfaceBlock === 'START' ? 'inset-block-start' : 'inset-block-end';\n const surfaceInlineProperty =\n surfaceInline === 'START' ? 'inset-inline-start' : 'inset-inline-end';\n\n this.surfaceStylesInternal = {\n 'display': 'block',\n 'opacity': '1',\n [surfaceBlockProperty]: `${block}px`,\n [surfaceInlineProperty]: `${inline}px`,\n };\n\n this.host.requestUpdate();\n }\n\n hostUpdate() {\n this.onUpdate();\n }\n\n hostUpdated() {\n this.onUpdate();\n }\n\n /**\n * Checks whether the properties passed into the controller have changed since\n * the last positioning. If so, it will reposition if the surface is open or\n * close it if the surface should close.\n */\n private async onUpdate() {\n const props = this.getProperties();\n let hasChanged = false;\n for (const [key, value] of Object.entries(props)) {\n // tslint:disable-next-line\n hasChanged = hasChanged || (value !== (this.lastValues as any)[key]);\n if (hasChanged) break;\n }\n\n const openChanged = this.lastValues.isOpen !== props.isOpen;\n const hasAnchor = !!props.anchorEl;\n const hasSurface = !!props.surfaceEl;\n\n if (hasChanged && hasAnchor && hasSurface) {\n // Only update isOpen, because if it's closed, we do not want to waste\n // time on a useless reposition calculation. So save the other \"dirty\"\n // values until next time it opens.\n this.lastValues.isOpen = props.isOpen;\n\n if (props.isOpen) {\n // We are going to do a reposition, so save the prop values for future\n // dirty checking.\n this.lastValues = props;\n\n await this.position();\n props.onOpen();\n } else if (openChanged) {\n await props.beforeClose();\n this.close();\n props.onClose();\n }\n }\n }\n\n /**\n * Hides the surface.\n */\n private close() {\n this.surfaceStylesInternal = {\n 'display': 'none',\n };\n this.host.requestUpdate();\n }\n}\n"]}
|
|
@@ -18,6 +18,10 @@ export interface TypeaheadControllerProperties {
|
|
|
18
18
|
* alive.
|
|
19
19
|
*/
|
|
20
20
|
typeaheadBufferTime: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether or not the typeahead should listen for keystrokes or not.
|
|
23
|
+
*/
|
|
24
|
+
active: boolean;
|
|
21
25
|
}
|
|
22
26
|
/**
|
|
23
27
|
* Data structure tuple that helps with indexing.
|
|
@@ -25,6 +29,14 @@ export interface TypeaheadControllerProperties {
|
|
|
25
29
|
* [index, item, normalized header text]
|
|
26
30
|
*/
|
|
27
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
|
+
};
|
|
28
40
|
/**
|
|
29
41
|
* This controller listens to `keydown` events and searches the header text of
|
|
30
42
|
* an array of `MenuItem`s with the corresponding entered keys within the buffer
|
|
@@ -71,11 +83,11 @@ export declare class TypeaheadController {
|
|
|
71
83
|
/**
|
|
72
84
|
* If we are currently "typing"
|
|
73
85
|
*/
|
|
74
|
-
|
|
86
|
+
isTypingAhead: boolean;
|
|
75
87
|
/**
|
|
76
88
|
* The record of the last active item.
|
|
77
89
|
*/
|
|
78
|
-
|
|
90
|
+
lastActiveRecord: TypeaheadRecord | null;
|
|
79
91
|
/**
|
|
80
92
|
* @param getProperties A function that returns the options of the typeahead
|
|
81
93
|
* controller:
|
|
@@ -88,6 +100,7 @@ export declare class TypeaheadController {
|
|
|
88
100
|
*/
|
|
89
101
|
constructor(getProperties: () => TypeaheadControllerProperties);
|
|
90
102
|
protected get items(): MenuItem[];
|
|
103
|
+
protected get active(): boolean;
|
|
91
104
|
/**
|
|
92
105
|
* Apply this listener to the element that will receive `keydown` events that
|
|
93
106
|
* should trigger this 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
|
|
@@ -95,18 +99,21 @@ export class TypeaheadController {
|
|
|
95
99
|
get items() {
|
|
96
100
|
return this.getProperties().getItems();
|
|
97
101
|
}
|
|
102
|
+
get active() {
|
|
103
|
+
return this.getProperties().active;
|
|
104
|
+
}
|
|
98
105
|
/**
|
|
99
106
|
* Sets up typingahead
|
|
100
107
|
*/
|
|
101
108
|
beginTypeahead(e) {
|
|
109
|
+
if (!this.active) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
102
112
|
// We don't want to typeahead if the _beginning_ of the typeahead is a menu
|
|
103
113
|
// navigation, or a selection. We will handle "Space" only if it's in the
|
|
104
114
|
// middle of a typeahead
|
|
105
115
|
if (e.code === 'Space' || e.code === 'Enter' ||
|
|
106
116
|
e.code.startsWith('Arrow') || e.code === 'Escape') {
|
|
107
|
-
if (this.lastActiveRecord) {
|
|
108
|
-
this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;
|
|
109
|
-
}
|
|
110
117
|
return;
|
|
111
118
|
}
|
|
112
119
|
this.isTypingAhead = true;
|
|
@@ -114,10 +121,10 @@ export class TypeaheadController {
|
|
|
114
121
|
// and a normalized header.
|
|
115
122
|
this.typeaheadRecords = this.items.map((el, index) => [index, el, el.headline.trim().toLowerCase()]);
|
|
116
123
|
this.lastActiveRecord =
|
|
117
|
-
this.typeaheadRecords.find(record => record[
|
|
124
|
+
this.typeaheadRecords.find(record => record[TYPEAHEAD_RECORD.ITEM].active) ??
|
|
118
125
|
null;
|
|
119
126
|
if (this.lastActiveRecord) {
|
|
120
|
-
this.lastActiveRecord[
|
|
127
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
121
128
|
}
|
|
122
129
|
this.typeahead(e);
|
|
123
130
|
}
|
|
@@ -165,19 +172,22 @@ export class TypeaheadController {
|
|
|
165
172
|
e.code === 'Escape') {
|
|
166
173
|
this.endTypeahead();
|
|
167
174
|
if (this.lastActiveRecord) {
|
|
168
|
-
this.lastActiveRecord[
|
|
175
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
169
176
|
}
|
|
170
177
|
return;
|
|
171
178
|
}
|
|
172
179
|
// If Space is pressed, prevent it from selecting and closing the menu
|
|
173
180
|
if (e.code === 'Space') {
|
|
174
181
|
e.stopPropagation();
|
|
182
|
+
e.preventDefault();
|
|
175
183
|
}
|
|
176
184
|
// Start up a new keystroke buffer timeout
|
|
177
185
|
this.cancelTypeaheadTimeout =
|
|
178
186
|
setTimeout(this.endTypeahead, this.getProperties().typeaheadBufferTime);
|
|
179
187
|
this.typaheadBuffer += e.key.toLowerCase();
|
|
180
|
-
const lastActiveIndex = this.lastActiveRecord ?
|
|
188
|
+
const lastActiveIndex = this.lastActiveRecord ?
|
|
189
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.INDEX] :
|
|
190
|
+
-1;
|
|
181
191
|
const numRecords = this.typeaheadRecords.length;
|
|
182
192
|
/**
|
|
183
193
|
* Sorting function that will resort the items starting with the given index
|
|
@@ -202,13 +212,13 @@ export class TypeaheadController {
|
|
|
202
212
|
* 5: [2, <reference>, 'banana']
|
|
203
213
|
*/
|
|
204
214
|
const rebaseIndexOnActive = (record) => {
|
|
205
|
-
return (record[
|
|
215
|
+
return (record[TYPEAHEAD_RECORD.INDEX] + numRecords - lastActiveIndex) %
|
|
206
216
|
numRecords;
|
|
207
217
|
};
|
|
208
218
|
// records filtered and sorted / rebased around the last active index
|
|
209
219
|
const matchingRecords = this.typeaheadRecords
|
|
210
|
-
.filter(record => !record[
|
|
211
|
-
record[
|
|
220
|
+
.filter(record => !record[TYPEAHEAD_RECORD.ITEM].disabled &&
|
|
221
|
+
record[TYPEAHEAD_RECORD.TEXT].startsWith(this.typaheadBuffer))
|
|
212
222
|
.sort((a, b) => rebaseIndexOnActive(a) - rebaseIndexOnActive(b));
|
|
213
223
|
// Just leave if there's nothing that matches. Native select will just
|
|
214
224
|
// choose the first thing that starts with the next letter in the alphabet
|
|
@@ -216,7 +226,7 @@ export class TypeaheadController {
|
|
|
216
226
|
if (matchingRecords.length === 0) {
|
|
217
227
|
clearTimeout(this.cancelTypeaheadTimeout);
|
|
218
228
|
if (this.lastActiveRecord) {
|
|
219
|
-
this.lastActiveRecord[
|
|
229
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
220
230
|
}
|
|
221
231
|
this.endTypeahead();
|
|
222
232
|
return;
|
|
@@ -232,10 +242,10 @@ export class TypeaheadController {
|
|
|
232
242
|
nextRecord = matchingRecords[0];
|
|
233
243
|
}
|
|
234
244
|
if (this.lastActiveRecord) {
|
|
235
|
-
this.lastActiveRecord[
|
|
245
|
+
this.lastActiveRecord[TYPEAHEAD_RECORD.ITEM].active = false;
|
|
236
246
|
}
|
|
237
247
|
this.lastActiveRecord = nextRecord;
|
|
238
|
-
nextRecord[
|
|
248
|
+
nextRecord[TYPEAHEAD_RECORD.ITEM].active = true;
|
|
239
249
|
return;
|
|
240
250
|
}
|
|
241
251
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeaheadController.js","sourceRoot":"","sources":["typeaheadController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0BH,+CAA+C;AAC/C,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;QACO,kBAAa,GAAG,KAAK,CAAC;QAChC;;WAEG;QACO,qBAAgB,GAAyB,IAAI,CAAC;QAoBxD;;;;;WAKG;QACM,cAAS,GAAG,CAAC,CAAgB,EAAE,EAAE;YACxC,IAAI,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,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\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 /**\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 // 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 if (this.lastActiveRecord) {\n this.lastActiveRecord[TYPEAHEAD_ITEM].active = false;\n }\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 }\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(\n (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;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AAE;YAChC,YAAY,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC1C,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACzB,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC;aAC7D;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,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"]}
|