@angular/material 10.0.0-rc.3 → 10.1.0
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/_theming.scss +17 -17
- package/autocomplete/index.metadata.json +1 -1
- package/autocomplete/testing/autocomplete-harness.d.ts +2 -0
- package/bundles/material-autocomplete-testing.umd.js +11 -0
- package/bundles/material-autocomplete-testing.umd.js.map +1 -1
- package/bundles/material-autocomplete-testing.umd.min.js +2 -2
- package/bundles/material-autocomplete-testing.umd.min.js.map +1 -1
- package/bundles/material-autocomplete.umd.js +3 -1
- package/bundles/material-autocomplete.umd.js.map +1 -1
- package/bundles/material-autocomplete.umd.min.js +5 -5
- package/bundles/material-autocomplete.umd.min.js.map +1 -1
- package/bundles/material-badge-testing.umd.min.js +1 -1
- package/bundles/material-badge-testing.umd.min.js.map +1 -1
- package/bundles/material-bottom-sheet-testing.umd.min.js +1 -1
- package/bundles/material-bottom-sheet-testing.umd.min.js.map +1 -1
- package/bundles/material-button-testing.umd.js +11 -0
- package/bundles/material-button-testing.umd.js.map +1 -1
- package/bundles/material-button-testing.umd.min.js +2 -2
- package/bundles/material-button-testing.umd.min.js.map +1 -1
- package/bundles/material-button-toggle-testing.umd.js +11 -0
- package/bundles/material-button-toggle-testing.umd.js.map +1 -1
- package/bundles/material-button-toggle-testing.umd.min.js +3 -3
- package/bundles/material-button-toggle-testing.umd.min.js.map +1 -1
- package/bundles/material-button-toggle.umd.js +12 -3
- package/bundles/material-button-toggle.umd.js.map +1 -1
- package/bundles/material-button-toggle.umd.min.js +2 -2
- package/bundles/material-button-toggle.umd.min.js.map +1 -1
- package/bundles/material-button.umd.js +7 -2
- package/bundles/material-button.umd.js.map +1 -1
- package/bundles/material-button.umd.min.js +4 -4
- package/bundles/material-button.umd.min.js.map +1 -1
- package/bundles/material-card-testing.umd.js +335 -0
- package/bundles/material-card-testing.umd.js.map +1 -0
- package/bundles/material-card-testing.umd.min.js +44 -0
- package/bundles/material-card-testing.umd.min.js.map +1 -0
- package/bundles/material-checkbox-testing.umd.js +11 -0
- package/bundles/material-checkbox-testing.umd.js.map +1 -1
- package/bundles/material-checkbox-testing.umd.min.js +3 -3
- package/bundles/material-checkbox-testing.umd.min.js.map +1 -1
- package/bundles/material-checkbox.umd.js.map +1 -1
- package/bundles/material-chips.umd.js +36 -12
- package/bundles/material-chips.umd.js.map +1 -1
- package/bundles/material-chips.umd.min.js +4 -4
- package/bundles/material-chips.umd.min.js.map +1 -1
- package/bundles/material-core-testing.umd.min.js +1 -1
- package/bundles/material-core-testing.umd.min.js.map +1 -1
- package/bundles/material-core.umd.js +11 -3
- package/bundles/material-core.umd.js.map +1 -1
- package/bundles/material-core.umd.min.js +11 -11
- package/bundles/material-core.umd.min.js.map +1 -1
- package/bundles/material-datepicker.umd.js +20 -11
- package/bundles/material-datepicker.umd.js.map +1 -1
- package/bundles/material-datepicker.umd.min.js +5 -5
- package/bundles/material-datepicker.umd.min.js.map +1 -1
- package/bundles/material-dialog-testing.umd.min.js +1 -1
- package/bundles/material-dialog-testing.umd.min.js.map +1 -1
- package/bundles/material-dialog.umd.js +45 -8
- package/bundles/material-dialog.umd.js.map +1 -1
- package/bundles/material-dialog.umd.min.js +14 -7
- package/bundles/material-dialog.umd.min.js.map +1 -1
- package/bundles/material-divider-testing.umd.min.js +1 -1
- package/bundles/material-divider-testing.umd.min.js.map +1 -1
- package/bundles/material-expansion-testing.umd.js +11 -0
- package/bundles/material-expansion-testing.umd.js.map +1 -1
- package/bundles/material-expansion-testing.umd.min.js +3 -3
- package/bundles/material-expansion-testing.umd.min.js.map +1 -1
- package/bundles/material-form-field-testing.umd.js +32 -0
- package/bundles/material-form-field-testing.umd.js.map +1 -1
- package/bundles/material-form-field-testing.umd.min.js +4 -4
- package/bundles/material-form-field-testing.umd.min.js.map +1 -1
- package/bundles/material-form-field.umd.js +47 -21
- package/bundles/material-form-field.umd.js.map +1 -1
- package/bundles/material-form-field.umd.min.js +5 -5
- package/bundles/material-form-field.umd.min.js.map +1 -1
- package/bundles/material-grid-list-testing.umd.min.js +1 -1
- package/bundles/material-grid-list-testing.umd.min.js.map +1 -1
- package/bundles/material-grid-list.umd.js +2 -2
- package/bundles/material-grid-list.umd.js.map +1 -1
- package/bundles/material-grid-list.umd.min.js +2 -2
- package/bundles/material-grid-list.umd.min.js.map +1 -1
- package/bundles/material-input-testing.umd.js +23 -6
- package/bundles/material-input-testing.umd.js.map +1 -1
- package/bundles/material-input-testing.umd.min.js +3 -3
- package/bundles/material-input-testing.umd.min.js.map +1 -1
- package/bundles/material-input.umd.js +28 -3
- package/bundles/material-input.umd.js.map +1 -1
- package/bundles/material-input.umd.min.js +3 -3
- package/bundles/material-input.umd.min.js.map +1 -1
- package/bundles/material-list-testing.umd.js +33 -0
- package/bundles/material-list-testing.umd.js.map +1 -1
- package/bundles/material-list-testing.umd.min.js +2 -2
- package/bundles/material-list-testing.umd.min.js.map +1 -1
- package/bundles/material-list.umd.js +3 -3
- package/bundles/material-list.umd.min.js +1 -1
- package/bundles/material-list.umd.min.js.map +1 -1
- package/bundles/material-menu-testing.umd.js +22 -0
- package/bundles/material-menu-testing.umd.js.map +1 -1
- package/bundles/material-menu-testing.umd.min.js +2 -2
- package/bundles/material-menu-testing.umd.min.js.map +1 -1
- package/bundles/material-menu.umd.js +13 -2
- package/bundles/material-menu.umd.js.map +1 -1
- package/bundles/material-menu.umd.min.js +4 -4
- package/bundles/material-menu.umd.min.js.map +1 -1
- package/bundles/material-paginator-testing.umd.min.js +1 -1
- package/bundles/material-paginator-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-bar-testing.umd.min.js +1 -1
- package/bundles/material-progress-bar-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-spinner-testing.umd.js +1 -1
- package/bundles/material-progress-spinner-testing.umd.js.map +1 -1
- package/bundles/material-progress-spinner-testing.umd.min.js +2 -2
- package/bundles/material-progress-spinner-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-spinner.umd.js +2 -2
- package/bundles/material-progress-spinner.umd.min.js +3 -3
- package/bundles/material-progress-spinner.umd.min.js.map +1 -1
- package/bundles/material-radio-testing.umd.js +11 -0
- package/bundles/material-radio-testing.umd.js.map +1 -1
- package/bundles/material-radio-testing.umd.min.js +3 -3
- package/bundles/material-radio-testing.umd.min.js.map +1 -1
- package/bundles/material-radio.umd.js +15 -5
- package/bundles/material-radio.umd.js.map +1 -1
- package/bundles/material-radio.umd.min.js +2 -2
- package/bundles/material-radio.umd.min.js.map +1 -1
- package/bundles/material-select-testing.umd.js +11 -0
- package/bundles/material-select-testing.umd.js.map +1 -1
- package/bundles/material-select-testing.umd.min.js +2 -2
- package/bundles/material-select-testing.umd.min.js.map +1 -1
- package/bundles/material-select.umd.js +11 -3
- package/bundles/material-select.umd.js.map +1 -1
- package/bundles/material-select.umd.min.js +4 -4
- package/bundles/material-select.umd.min.js.map +1 -1
- package/bundles/material-sidenav-testing.umd.min.js +1 -1
- package/bundles/material-sidenav-testing.umd.min.js.map +1 -1
- package/bundles/material-sidenav.umd.js +41 -17
- package/bundles/material-sidenav.umd.js.map +1 -1
- package/bundles/material-sidenav.umd.min.js +2 -2
- package/bundles/material-sidenav.umd.min.js.map +1 -1
- package/bundles/material-slide-toggle-testing.umd.js +11 -0
- package/bundles/material-slide-toggle-testing.umd.js.map +1 -1
- package/bundles/material-slide-toggle-testing.umd.min.js +2 -2
- package/bundles/material-slide-toggle-testing.umd.min.js.map +1 -1
- package/bundles/material-slide-toggle.umd.js.map +1 -1
- package/bundles/material-slider-testing.umd.js +11 -0
- package/bundles/material-slider-testing.umd.js.map +1 -1
- package/bundles/material-slider-testing.umd.min.js +2 -2
- package/bundles/material-slider-testing.umd.min.js.map +1 -1
- package/bundles/material-snack-bar-testing.umd.min.js +1 -1
- package/bundles/material-snack-bar-testing.umd.min.js.map +1 -1
- package/bundles/material-snack-bar.umd.js +47 -39
- package/bundles/material-snack-bar.umd.js.map +1 -1
- package/bundles/material-snack-bar.umd.min.js +2 -2
- package/bundles/material-snack-bar.umd.min.js.map +1 -1
- package/bundles/material-sort-testing.umd.js +10 -10
- package/bundles/material-sort-testing.umd.js.map +1 -1
- package/bundles/material-sort-testing.umd.min.js +3 -3
- package/bundles/material-sort-testing.umd.min.js.map +1 -1
- package/bundles/material-sort.umd.js +25 -12
- package/bundles/material-sort.umd.js.map +1 -1
- package/bundles/material-sort.umd.min.js +5 -5
- package/bundles/material-sort.umd.min.js.map +1 -1
- package/bundles/material-table-testing.umd.min.js +1 -1
- package/bundles/material-table-testing.umd.min.js.map +1 -1
- package/bundles/material-table.umd.min.js +2 -2
- package/bundles/material-table.umd.min.js.map +1 -1
- package/bundles/material-tabs-testing.umd.min.js +1 -1
- package/bundles/material-tabs-testing.umd.min.js.map +1 -1
- package/bundles/material-tabs.umd.js +23 -4
- package/bundles/material-tabs.umd.js.map +1 -1
- package/bundles/material-tabs.umd.min.js +5 -12
- package/bundles/material-tabs.umd.min.js.map +1 -1
- package/bundles/material-toolbar-testing.umd.js +330 -0
- package/bundles/material-toolbar-testing.umd.js.map +1 -0
- package/bundles/material-toolbar-testing.umd.min.js +44 -0
- package/bundles/material-toolbar-testing.umd.min.js.map +1 -0
- package/bundles/material-tooltip-testing.umd.min.js +1 -1
- package/bundles/material-tooltip-testing.umd.min.js.map +1 -1
- package/bundles/material-tooltip.umd.js +14 -1
- package/bundles/material-tooltip.umd.js.map +1 -1
- package/bundles/material-tooltip.umd.min.js +3 -3
- package/bundles/material-tooltip.umd.min.js.map +1 -1
- package/bundles/material-tree.umd.js.map +1 -1
- package/button/_button-base.scss +1 -1
- package/button/_button-theme.scss +8 -8
- package/button/index.metadata.json +1 -1
- package/button/testing/button-harness.d.ts +2 -0
- package/button-toggle/button-toggle.d.ts +10 -3
- package/button-toggle/index.metadata.json +1 -1
- package/button-toggle/testing/button-toggle-harness.d.ts +2 -0
- package/card/testing/card-harness-filters.d.ts +17 -0
- package/card/testing/card-harness.d.ts +36 -0
- package/card/testing/index.d.ts +8 -0
- package/card/testing/package.json +9 -0
- package/card/testing/public-api.d.ts +9 -0
- package/checkbox/index.metadata.json +1 -1
- package/checkbox/testing/checkbox-harness.d.ts +2 -0
- package/chips/chip.d.ts +19 -1
- package/chips/index.metadata.json +1 -1
- package/core/focus-indicators/_focus-indicators.scss +6 -6
- package/core/index.metadata.json +1 -1
- package/core/option/optgroup.d.ts +7 -0
- package/core/ripple/ripple-ref.d.ts +21 -2
- package/core/ripple/ripple-renderer.d.ts +1 -19
- package/core/ripple/ripple.d.ts +2 -2
- package/core/style/_list-common.scss +1 -1
- package/datepicker/date-range-input-parts.d.ts +2 -4
- package/datepicker/date-range-input.d.ts +4 -4
- package/datepicker/date-range-picker.d.ts +10 -3
- package/datepicker/datepicker.d.ts +2 -3
- package/datepicker/index.metadata.json +1 -1
- package/datepicker/public-api.d.ts +1 -1
- package/dialog/dialog-container.d.ts +9 -2
- package/dialog/dialog-content-directives.d.ts +1 -0
- package/dialog/dialog-ref.d.ts +7 -0
- package/dialog/index.metadata.json +1 -1
- package/esm2015/autocomplete/autocomplete-module.js +18 -22
- package/esm2015/autocomplete/autocomplete-origin.js +16 -20
- package/esm2015/autocomplete/autocomplete-trigger.js +519 -521
- package/esm2015/autocomplete/autocomplete.js +126 -130
- package/esm2015/autocomplete/testing/autocomplete-harness.js +99 -97
- package/esm2015/badge/badge-module.js +13 -17
- package/esm2015/badge/badge.js +184 -188
- package/esm2015/badge/testing/badge-harness.js +74 -78
- package/esm2015/bottom-sheet/bottom-sheet-container.js +161 -165
- package/esm2015/bottom-sheet/bottom-sheet-module.js +15 -19
- package/esm2015/bottom-sheet/bottom-sheet.js +124 -128
- package/esm2015/bottom-sheet/testing/bottom-sheet-harness.js +29 -33
- package/esm2015/button/button-module.js +20 -24
- package/esm2015/button/button.js +111 -114
- package/esm2015/button/testing/button-harness.js +60 -58
- package/esm2015/button-toggle/button-toggle-module.js +10 -14
- package/esm2015/button-toggle/button-toggle.js +368 -368
- package/esm2015/button-toggle/testing/button-toggle-group-harness.js +42 -46
- package/esm2015/button-toggle/testing/button-toggle-harness.js +113 -111
- package/esm2015/card/card-module.js +30 -34
- package/esm2015/card/card.js +147 -203
- package/esm2015/card/testing/card-harness-filters.js +8 -0
- package/esm2015/card/testing/card-harness.js +52 -0
- package/esm2015/card/testing/index.js +9 -0
- package/esm2015/card/testing/public-api.js +10 -0
- package/esm2015/card/testing/testing.externs.js +0 -0
- package/esm2015/checkbox/checkbox-module.js +21 -29
- package/esm2015/checkbox/checkbox-required-validator.js +9 -13
- package/esm2015/checkbox/checkbox.js +315 -319
- package/esm2015/checkbox/testing/checkbox-harness.js +150 -148
- package/esm2015/chips/chip-input.js +119 -123
- package/esm2015/chips/chip-list.js +572 -576
- package/esm2015/chips/chip.js +333 -328
- package/esm2015/chips/chips-module.js +16 -20
- package/esm2015/core/animation/animation.js +12 -20
- package/esm2015/core/common-behaviors/common-module.js +91 -95
- package/esm2015/core/datetime/index.js +19 -27
- package/esm2015/core/datetime/native-date-adapter.js +202 -206
- package/esm2015/core/error/error-options.js +16 -24
- package/esm2015/core/line/line.js +18 -26
- package/esm2015/core/option/index.js +10 -14
- package/esm2015/core/option/optgroup.js +36 -33
- package/esm2015/core/option/option.js +181 -185
- package/esm2015/core/ripple/index.js +10 -14
- package/esm2015/core/ripple/ripple-ref.js +1 -1
- package/esm2015/core/ripple/ripple-renderer.js +1 -1
- package/esm2015/core/ripple/ripple.js +102 -106
- package/esm2015/core/selection/index.js +9 -13
- package/esm2015/core/selection/pseudo-checkbox/pseudo-checkbox.js +32 -36
- package/esm2015/core/testing/optgroup-harness.js +39 -43
- package/esm2015/core/testing/option-harness.js +51 -55
- package/esm2015/core/version.js +1 -1
- package/esm2015/datepicker/calendar-body.js +214 -218
- package/esm2015/datepicker/calendar.js +295 -303
- package/esm2015/datepicker/date-range-input-parts.js +214 -229
- package/esm2015/datepicker/date-range-input.js +244 -242
- package/esm2015/datepicker/date-range-picker.js +19 -23
- package/esm2015/datepicker/date-range-selection-strategy.js +31 -35
- package/esm2015/datepicker/date-selection-model.js +110 -122
- package/esm2015/datepicker/datepicker-base.js +418 -426
- package/esm2015/datepicker/datepicker-input-base.js +227 -224
- package/esm2015/datepicker/datepicker-input.js +111 -115
- package/esm2015/datepicker/datepicker-intl.js +37 -41
- package/esm2015/datepicker/datepicker-module.js +62 -66
- package/esm2015/datepicker/datepicker-toggle.js +81 -89
- package/esm2015/datepicker/datepicker.js +13 -17
- package/esm2015/datepicker/month-view.js +283 -287
- package/esm2015/datepicker/multi-year-view.js +198 -202
- package/esm2015/datepicker/public-api.js +2 -2
- package/esm2015/datepicker/year-view.js +220 -224
- package/esm2015/dialog/dialog-container.js +175 -164
- package/esm2015/dialog/dialog-content-directives.js +105 -114
- package/esm2015/dialog/dialog-module.js +32 -36
- package/esm2015/dialog/dialog-ref.js +17 -3
- package/esm2015/dialog/dialog.js +236 -240
- package/esm2015/dialog/testing/dialog-harness.js +58 -62
- package/esm2015/divider/divider-module.js +10 -14
- package/esm2015/divider/divider.js +33 -37
- package/esm2015/divider/testing/divider-harness.js +16 -20
- package/esm2015/expansion/accordion.js +73 -77
- package/esm2015/expansion/expansion-module.js +26 -30
- package/esm2015/expansion/expansion-panel-content.js +13 -17
- package/esm2015/expansion/expansion-panel-header.js +168 -180
- package/esm2015/expansion/expansion-panel.js +144 -152
- package/esm2015/expansion/testing/accordion-harness.js +24 -28
- package/esm2015/expansion/testing/expansion-harness.js +136 -134
- package/esm2015/form-field/error.js +26 -23
- package/esm2015/form-field/form-field-control.js +6 -10
- package/esm2015/form-field/form-field-module.js +31 -35
- package/esm2015/form-field/form-field.js +407 -409
- package/esm2015/form-field/hint.js +35 -29
- package/esm2015/form-field/label.js +8 -12
- package/esm2015/form-field/placeholder.js +8 -12
- package/esm2015/form-field/prefix.js +16 -13
- package/esm2015/form-field/suffix.js +16 -13
- package/esm2015/form-field/testing/form-field-harness.js +220 -206
- package/esm2015/grid-list/grid-list-module.js +26 -30
- package/esm2015/grid-list/grid-list.js +108 -112
- package/esm2015/grid-list/grid-tile.js +91 -111
- package/esm2015/grid-list/testing/grid-list-harness.js +62 -66
- package/esm2015/grid-list/testing/grid-tile-harness.js +69 -73
- package/esm2015/grid-list/tile-styler.js +1 -1
- package/esm2015/icon/icon-module.js +10 -14
- package/esm2015/icon/icon-registry.js +406 -410
- package/esm2015/icon/icon.js +228 -232
- package/esm2015/icon/testing/fake-icon-registry.js +66 -74
- package/esm2015/input/autosize.js +30 -34
- package/esm2015/input/input-module.js +21 -25
- package/esm2015/input/input.js +305 -284
- package/esm2015/input/testing/input-harness.js +129 -123
- package/esm2015/list/list-module.js +32 -36
- package/esm2015/list/list.js +165 -189
- package/esm2015/list/selection-list.js +503 -511
- package/esm2015/list/testing/action-list-harness.js +55 -57
- package/esm2015/list/testing/list-harness.js +31 -39
- package/esm2015/list/testing/list-item-harness-base.js +13 -17
- package/esm2015/list/testing/nav-list-harness.js +62 -64
- package/esm2015/list/testing/selection-list-harness.js +136 -138
- package/esm2015/menu/menu-content.js +74 -71
- package/esm2015/menu/menu-item.js +119 -123
- package/esm2015/menu/menu-module.js +29 -37
- package/esm2015/menu/menu-panel.js +1 -1
- package/esm2015/menu/menu-trigger.js +402 -405
- package/esm2015/menu/menu.js +329 -339
- package/esm2015/menu/testing/menu-harness.js +193 -189
- package/esm2015/paginator/paginator-intl.js +36 -40
- package/esm2015/paginator/paginator-module.js +16 -20
- package/esm2015/paginator/paginator.js +205 -209
- package/esm2015/paginator/testing/paginator-harness.js +91 -95
- package/esm2015/progress-bar/progress-bar-module.js +10 -14
- package/esm2015/progress-bar/progress-bar.js +114 -118
- package/esm2015/progress-bar/testing/progress-bar-harness.js +27 -31
- package/esm2015/progress-spinner/progress-spinner-module.js +17 -21
- package/esm2015/progress-spinner/progress-spinner.js +181 -189
- package/esm2015/progress-spinner/testing/progress-spinner-harness.js +28 -32
- package/esm2015/radio/radio-module.js +10 -14
- package/esm2015/radio/radio.js +437 -444
- package/esm2015/radio/testing/radio-harness.js +241 -243
- package/esm2015/select/select-module.js +23 -27
- package/esm2015/select/select.js +917 -918
- package/esm2015/select/testing/select-harness.js +138 -136
- package/esm2015/sidenav/drawer.js +632 -620
- package/esm2015/sidenav/sidenav-module.js +31 -35
- package/esm2015/sidenav/sidenav.js +104 -116
- package/esm2015/sidenav/testing/drawer-harness.js +40 -44
- package/esm2015/sidenav/testing/sidenav-harness.js +20 -24
- package/esm2015/slide-toggle/slide-toggle-module.js +27 -35
- package/esm2015/slide-toggle/slide-toggle-required-validator.js +9 -13
- package/esm2015/slide-toggle/slide-toggle.js +184 -188
- package/esm2015/slide-toggle/testing/slide-toggle-harness.js +123 -121
- package/esm2015/slider/slider-module.js +10 -14
- package/esm2015/slider/slider.js +640 -644
- package/esm2015/slider/testing/slider-harness.js +129 -127
- package/esm2015/snack-bar/simple-snack-bar.js +32 -36
- package/esm2015/snack-bar/snack-bar-container.js +144 -148
- package/esm2015/snack-bar/snack-bar-module.js +17 -21
- package/esm2015/snack-bar/snack-bar-ref.js +1 -1
- package/esm2015/snack-bar/snack-bar.js +208 -205
- package/esm2015/snack-bar/testing/snack-bar-harness.js +112 -116
- package/esm2015/sort/sort-header-intl.js +21 -21
- package/esm2015/sort/sort-header.js +200 -194
- package/esm2015/sort/sort-module.js +11 -15
- package/esm2015/sort/sort.js +92 -96
- package/esm2015/sort/testing/sort-harness.js +28 -32
- package/esm2015/sort/testing/sort-header-harness.js +66 -67
- package/esm2015/stepper/step-header.js +78 -82
- package/esm2015/stepper/step-label.js +8 -12
- package/esm2015/stepper/stepper-button.js +23 -31
- package/esm2015/stepper/stepper-icon.js +16 -20
- package/esm2015/stepper/stepper-intl.js +15 -19
- package/esm2015/stepper/stepper-module.js +40 -44
- package/esm2015/stepper/stepper.js +139 -155
- package/esm2015/table/cell.js +94 -122
- package/esm2015/table/row.js +90 -118
- package/esm2015/table/table-module.js +13 -17
- package/esm2015/table/table.js +26 -30
- package/esm2015/table/testing/cell-harness.js +56 -68
- package/esm2015/table/testing/row-harness.js +90 -102
- package/esm2015/table/testing/table-harness.js +65 -69
- package/esm2015/table/text-column.js +17 -21
- package/esm2015/tabs/index.js +4 -2
- package/esm2015/tabs/ink-bar.js +55 -59
- package/esm2015/tabs/paginated-tab-header.js +415 -419
- package/esm2015/tabs/tab-body.js +179 -191
- package/esm2015/tabs/tab-content.js +21 -16
- package/esm2015/tabs/tab-group.js +263 -271
- package/esm2015/tabs/tab-header.js +69 -77
- package/esm2015/tabs/tab-label-wrapper.js +29 -33
- package/esm2015/tabs/tab-label.js +16 -13
- package/esm2015/tabs/tab-nav-bar/tab-nav-bar.js +199 -215
- package/esm2015/tabs/tab.js +80 -83
- package/esm2015/tabs/tabs-module.js +38 -42
- package/esm2015/tabs/testing/tab-group-harness.js +52 -56
- package/esm2015/tabs/testing/tab-harness.js +78 -82
- package/esm2015/toolbar/testing/index.js +9 -0
- package/esm2015/toolbar/testing/public-api.js +10 -0
- package/esm2015/toolbar/testing/testing.externs.js +0 -0
- package/esm2015/toolbar/testing/toolbar-harness-filters.js +8 -0
- package/esm2015/toolbar/testing/toolbar-harness.js +47 -0
- package/esm2015/toolbar/toolbar-module.js +10 -14
- package/esm2015/toolbar/toolbar.js +61 -69
- package/esm2015/tooltip/testing/tooltip-harness.js +43 -47
- package/esm2015/tooltip/tooltip-module.js +17 -21
- package/esm2015/tooltip/tooltip.js +502 -497
- package/esm2015/tree/data-source/flat-data-source.js +1 -1
- package/esm2015/tree/node.js +99 -111
- package/esm2015/tree/outlet.js +19 -23
- package/esm2015/tree/padding.js +13 -17
- package/esm2015/tree/toggle.js +15 -19
- package/esm2015/tree/tree-module.js +10 -14
- package/esm2015/tree/tree.js +23 -27
- package/expansion/testing/expansion-harness.d.ts +2 -0
- package/fesm2015/autocomplete/testing.js +98 -95
- package/fesm2015/autocomplete/testing.js.map +1 -1
- package/fesm2015/autocomplete.js +677 -687
- package/fesm2015/autocomplete.js.map +1 -1
- package/fesm2015/badge/testing.js +73 -76
- package/fesm2015/badge/testing.js.map +1 -1
- package/fesm2015/badge.js +195 -201
- package/fesm2015/badge.js.map +1 -1
- package/fesm2015/bottom-sheet/testing.js +28 -31
- package/fesm2015/bottom-sheet/testing.js.map +1 -1
- package/fesm2015/bottom-sheet.js +297 -306
- package/fesm2015/bottom-sheet.js.map +1 -1
- package/fesm2015/button/testing.js +59 -56
- package/fesm2015/button/testing.js.map +1 -1
- package/fesm2015/button-toggle/testing.js +155 -155
- package/fesm2015/button-toggle/testing.js.map +1 -1
- package/fesm2015/button-toggle.js +377 -378
- package/fesm2015/button-toggle.js.map +1 -1
- package/fesm2015/button.js +129 -133
- package/fesm2015/button.js.map +1 -1
- package/fesm2015/card/testing.js +79 -0
- package/fesm2015/card/testing.js.map +1 -0
- package/fesm2015/card.js +175 -220
- package/fesm2015/card.js.map +1 -1
- package/fesm2015/checkbox/testing.js +149 -146
- package/fesm2015/checkbox/testing.js.map +1 -1
- package/fesm2015/checkbox.js +342 -354
- package/fesm2015/checkbox.js.map +1 -1
- package/fesm2015/chips.js +1039 -1039
- package/fesm2015/chips.js.map +1 -1
- package/fesm2015/core/testing.js +88 -94
- package/fesm2015/core/testing.js.map +1 -1
- package/fesm2015/core.js +729 -773
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/datepicker.js +2821 -2884
- package/fesm2015/datepicker.js.map +1 -1
- package/fesm2015/dialog/testing.js +57 -60
- package/fesm2015/dialog/testing.js.map +1 -1
- package/fesm2015/dialog.js +564 -549
- package/fesm2015/dialog.js.map +1 -1
- package/fesm2015/divider/testing.js +15 -18
- package/fesm2015/divider/testing.js.map +1 -1
- package/fesm2015/divider.js +41 -47
- package/fesm2015/divider.js.map +1 -1
- package/fesm2015/expansion/testing.js +159 -159
- package/fesm2015/expansion/testing.js.map +1 -1
- package/fesm2015/expansion.js +422 -446
- package/fesm2015/expansion.js.map +1 -1
- package/fesm2015/form-field/testing.js +219 -204
- package/fesm2015/form-field/testing.js.map +1 -1
- package/fesm2015/form-field.js +538 -532
- package/fesm2015/form-field.js.map +1 -1
- package/fesm2015/grid-list/testing.js +129 -135
- package/fesm2015/grid-list/testing.js.map +1 -1
- package/fesm2015/grid-list.js +221 -242
- package/fesm2015/grid-list.js.map +1 -1
- package/fesm2015/icon/testing.js +65 -71
- package/fesm2015/icon/testing.js.map +1 -1
- package/fesm2015/icon.js +660 -669
- package/fesm2015/icon.js.map +1 -1
- package/fesm2015/input/testing.js +128 -121
- package/fesm2015/input/testing.js.map +1 -1
- package/fesm2015/input.js +353 -337
- package/fesm2015/input.js.map +1 -1
- package/fesm2015/list/testing.js +298 -307
- package/fesm2015/list/testing.js.map +1 -1
- package/fesm2015/list.js +698 -725
- package/fesm2015/list.js.map +1 -1
- package/fesm2015/menu/testing.js +192 -186
- package/fesm2015/menu/testing.js.map +1 -1
- package/fesm2015/menu.js +948 -962
- package/fesm2015/menu.js.map +1 -1
- package/fesm2015/paginator/testing.js +90 -93
- package/fesm2015/paginator/testing.js.map +1 -1
- package/fesm2015/paginator.js +247 -256
- package/fesm2015/paginator.js.map +1 -1
- package/fesm2015/progress-bar/testing.js +26 -29
- package/fesm2015/progress-bar/testing.js.map +1 -1
- package/fesm2015/progress-bar.js +122 -128
- package/fesm2015/progress-bar.js.map +1 -1
- package/fesm2015/progress-spinner/testing.js +27 -30
- package/fesm2015/progress-spinner/testing.js.map +1 -1
- package/fesm2015/progress-spinner.js +196 -205
- package/fesm2015/progress-spinner.js.map +1 -1
- package/fesm2015/radio/testing.js +240 -240
- package/fesm2015/radio/testing.js.map +1 -1
- package/fesm2015/radio.js +447 -453
- package/fesm2015/radio.js.map +1 -1
- package/fesm2015/select/testing.js +137 -134
- package/fesm2015/select/testing.js.map +1 -1
- package/fesm2015/select.js +939 -941
- package/fesm2015/select.js.map +1 -1
- package/fesm2015/sidenav/testing.js +58 -64
- package/fesm2015/sidenav/testing.js.map +1 -1
- package/fesm2015/sidenav.js +765 -762
- package/fesm2015/sidenav.js.map +1 -1
- package/fesm2015/slide-toggle/testing.js +122 -119
- package/fesm2015/slide-toggle/testing.js.map +1 -1
- package/fesm2015/slide-toggle.js +217 -229
- package/fesm2015/slide-toggle.js.map +1 -1
- package/fesm2015/slider/testing.js +128 -125
- package/fesm2015/slider/testing.js.map +1 -1
- package/fesm2015/slider.js +648 -654
- package/fesm2015/slider.js.map +1 -1
- package/fesm2015/snack-bar/testing.js +111 -114
- package/fesm2015/snack-bar/testing.js.map +1 -1
- package/fesm2015/snack-bar.js +426 -431
- package/fesm2015/snack-bar.js.map +1 -1
- package/fesm2015/sort/testing.js +92 -95
- package/fesm2015/sort/testing.js.map +1 -1
- package/fesm2015/sort.js +320 -318
- package/fesm2015/sort.js.map +1 -1
- package/fesm2015/stepper.js +312 -345
- package/fesm2015/stepper.js.map +1 -1
- package/fesm2015/table/testing.js +208 -229
- package/fesm2015/table/testing.js.map +1 -1
- package/fesm2015/table.js +235 -286
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/tabs/testing.js +128 -134
- package/fesm2015/tabs/testing.js.map +1 -1
- package/fesm2015/tabs.js +1362 -1399
- package/fesm2015/tabs.js.map +1 -1
- package/fesm2015/toolbar/testing.js +74 -0
- package/fesm2015/toolbar/testing.js.map +1 -0
- package/fesm2015/toolbar.js +69 -78
- package/fesm2015/toolbar.js.map +1 -1
- package/fesm2015/tooltip/testing.js +42 -45
- package/fesm2015/tooltip/testing.js.map +1 -1
- package/fesm2015/tooltip.js +517 -513
- package/fesm2015/tooltip.js.map +1 -1
- package/fesm2015/tree.js +173 -197
- package/fesm2015/tree.js.map +1 -1
- package/form-field/error.d.ts +7 -0
- package/form-field/hint.d.ts +10 -0
- package/form-field/index.metadata.json +1 -1
- package/form-field/prefix.d.ts +7 -0
- package/form-field/suffix.d.ts +7 -0
- package/form-field/testing/form-field-harness.d.ts +8 -0
- package/grid-list/grid-list.d.ts +2 -1
- package/grid-list/index.metadata.json +1 -1
- package/grid-list/tile-styler.d.ts +10 -5
- package/input/_input-theme.scss +2 -2
- package/input/index.metadata.json +1 -1
- package/input/input.d.ts +6 -2
- package/input/testing/input-harness.d.ts +2 -0
- package/list/index.metadata.json +1 -1
- package/list/testing/action-list-harness.d.ts +2 -0
- package/list/testing/nav-list-harness.d.ts +2 -0
- package/list/testing/selection-list-harness.d.ts +2 -0
- package/menu/index.metadata.json +1 -1
- package/menu/menu-content.d.ts +7 -1
- package/menu/menu-panel.d.ts +1 -0
- package/menu/menu.d.ts +4 -0
- package/menu/testing/menu-harness.d.ts +4 -0
- package/package.json +6 -6
- package/prebuilt-themes/deeppurple-amber.css +1 -1
- package/prebuilt-themes/indigo-pink.css +1 -1
- package/prebuilt-themes/pink-bluegrey.css +1 -1
- package/prebuilt-themes/purple-green.css +1 -1
- package/progress-spinner/index.metadata.json +1 -1
- package/radio/index.metadata.json +1 -1
- package/radio/radio.d.ts +6 -0
- package/radio/testing/radio-harness.d.ts +2 -0
- package/schematics/migration.json +5 -0
- package/schematics/ng-add/index.js +2 -2
- package/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +3 -3
- package/schematics/ng-generate/navigation/schema.json +5 -0
- package/schematics/ng-update/data/index.js +1 -1
- package/schematics/ng-update/index.d.ts +2 -0
- package/schematics/ng-update/index.js +7 -2
- package/schematics/ng-update/migrations/hammer-gestures-v9/hammer-gestures-migration.js +639 -639
- package/schematics/ng-update/migrations/misc-ripples-v7/ripple-speed-factor-migration.js +1 -1
- package/select/index.metadata.json +1 -1
- package/select/select.d.ts +6 -0
- package/select/testing/select-harness.d.ts +2 -0
- package/sidenav/drawer.d.ts +15 -3
- package/sidenav/index.metadata.json +1 -1
- package/slide-toggle/index.metadata.json +1 -1
- package/slide-toggle/testing/slide-toggle-harness.d.ts +2 -0
- package/slider/testing/slider-harness.d.ts +2 -0
- package/snack-bar/index.metadata.json +1 -1
- package/snack-bar/simple-snack-bar.d.ts +13 -1
- package/snack-bar/snack-bar-container.d.ts +16 -3
- package/snack-bar/snack-bar-ref.d.ts +3 -3
- package/snack-bar/snack-bar.d.ts +10 -3
- package/sort/index.metadata.json +1 -1
- package/sort/sort-header-intl.d.ts +5 -1
- package/sort/sort-header.d.ts +3 -1
- package/sort/testing/sort-header-harness.d.ts +6 -2
- package/tabs/index.d.ts +3 -1
- package/tabs/index.metadata.json +1 -1
- package/tabs/tab-content.d.ts +7 -1
- package/tabs/tab-label.d.ts +7 -0
- package/toolbar/testing/index.d.ts +8 -0
- package/toolbar/testing/package.json +9 -0
- package/toolbar/testing/public-api.d.ts +9 -0
- package/toolbar/testing/toolbar-harness-filters.d.ts +13 -0
- package/toolbar/testing/toolbar-harness.d.ts +31 -0
- package/tooltip/index.metadata.json +1 -1
- package/tooltip/tooltip.d.ts +1 -0
- package/tree/data-source/flat-data-source.d.ts +4 -4
- package/tree/index.metadata.json +1 -1
package/fesm2015/menu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FocusMonitor, FocusKeyManager, isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
|
|
2
2
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
3
3
|
import { UP_ARROW, DOWN_ARROW, END, hasModifierKey, HOME, RIGHT_ARROW, LEFT_ARROW, ESCAPE } from '@angular/cdk/keycodes';
|
|
4
|
-
import { Directive, TemplateRef, ComponentFactoryResolver, ApplicationRef, Injector, ViewContainerRef, Inject, ChangeDetectorRef,
|
|
4
|
+
import { InjectionToken, Directive, TemplateRef, ComponentFactoryResolver, ApplicationRef, Injector, ViewContainerRef, Inject, ChangeDetectorRef, Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, Optional, Input, HostListener, QueryList, EventEmitter, NgZone, ContentChildren, ViewChild, ContentChild, Output, Self, NgModule } from '@angular/core';
|
|
5
5
|
import { Subject, Subscription, merge, of, asapScheduler } from 'rxjs';
|
|
6
6
|
import { startWith, switchMap, take, filter, takeUntil, delay } from 'rxjs/operators';
|
|
7
7
|
import { trigger, state, style, transition, group, query, animate } from '@angular/animations';
|
|
@@ -82,82 +82,86 @@ const transformMenu = matMenuAnimations.transformMenu;
|
|
|
82
82
|
* Use of this source code is governed by an MIT-style license that can be
|
|
83
83
|
* found in the LICENSE file at https://angular.io/license
|
|
84
84
|
*/
|
|
85
|
+
/**
|
|
86
|
+
* Injection token that can be used to reference instances of `MatMenuContent`. It serves
|
|
87
|
+
* as alternative token to the actual `MatMenuContent` class which could cause unnecessary
|
|
88
|
+
* retention of the class and its directive metadata.
|
|
89
|
+
*/
|
|
90
|
+
const MAT_MENU_CONTENT = new InjectionToken('MatMenuContent');
|
|
85
91
|
/**
|
|
86
92
|
* Menu content that will be rendered lazily once the menu is opened.
|
|
87
93
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
class MatMenuContent {
|
|
95
|
+
constructor(_template, _componentFactoryResolver, _appRef, _injector, _viewContainerRef, _document, _changeDetectorRef) {
|
|
96
|
+
this._template = _template;
|
|
97
|
+
this._componentFactoryResolver = _componentFactoryResolver;
|
|
98
|
+
this._appRef = _appRef;
|
|
99
|
+
this._injector = _injector;
|
|
100
|
+
this._viewContainerRef = _viewContainerRef;
|
|
101
|
+
this._document = _document;
|
|
102
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
103
|
+
/** Emits when the menu content has been attached. */
|
|
104
|
+
this._attached = new Subject();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Attaches the content with a particular context.
|
|
108
|
+
* @docs-private
|
|
109
|
+
*/
|
|
110
|
+
attach(context = {}) {
|
|
111
|
+
if (!this._portal) {
|
|
112
|
+
this._portal = new TemplatePortal(this._template, this._viewContainerRef);
|
|
100
113
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
attach(context = {}) {
|
|
106
|
-
if (!this._portal) {
|
|
107
|
-
this._portal = new TemplatePortal(this._template, this._viewContainerRef);
|
|
108
|
-
}
|
|
109
|
-
this.detach();
|
|
110
|
-
if (!this._outlet) {
|
|
111
|
-
this._outlet = new DomPortalOutlet(this._document.createElement('div'), this._componentFactoryResolver, this._appRef, this._injector);
|
|
112
|
-
}
|
|
113
|
-
const element = this._template.elementRef.nativeElement;
|
|
114
|
-
// Because we support opening the same menu from different triggers (which in turn have their
|
|
115
|
-
// own `OverlayRef` panel), we have to re-insert the host element every time, otherwise we
|
|
116
|
-
// risk it staying attached to a pane that's no longer in the DOM.
|
|
117
|
-
element.parentNode.insertBefore(this._outlet.outletElement, element);
|
|
118
|
-
// When `MatMenuContent` is used in an `OnPush` component, the insertion of the menu
|
|
119
|
-
// content via `createEmbeddedView` does not cause the content to be seen as "dirty"
|
|
120
|
-
// by Angular. This causes the `@ContentChildren` for menu items within the menu to
|
|
121
|
-
// not be updated by Angular. By explicitly marking for check here, we tell Angular that
|
|
122
|
-
// it needs to check for new menu items and update the `@ContentChild` in `MatMenu`.
|
|
123
|
-
// @breaking-change 9.0.0 Make change detector ref required
|
|
124
|
-
if (this._changeDetectorRef) {
|
|
125
|
-
this._changeDetectorRef.markForCheck();
|
|
126
|
-
}
|
|
127
|
-
this._portal.attach(this._outlet, context);
|
|
128
|
-
this._attached.next();
|
|
114
|
+
this.detach();
|
|
115
|
+
if (!this._outlet) {
|
|
116
|
+
this._outlet = new DomPortalOutlet(this._document.createElement('div'), this._componentFactoryResolver, this._appRef, this._injector);
|
|
129
117
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
118
|
+
const element = this._template.elementRef.nativeElement;
|
|
119
|
+
// Because we support opening the same menu from different triggers (which in turn have their
|
|
120
|
+
// own `OverlayRef` panel), we have to re-insert the host element every time, otherwise we
|
|
121
|
+
// risk it staying attached to a pane that's no longer in the DOM.
|
|
122
|
+
element.parentNode.insertBefore(this._outlet.outletElement, element);
|
|
123
|
+
// When `MatMenuContent` is used in an `OnPush` component, the insertion of the menu
|
|
124
|
+
// content via `createEmbeddedView` does not cause the content to be seen as "dirty"
|
|
125
|
+
// by Angular. This causes the `@ContentChildren` for menu items within the menu to
|
|
126
|
+
// not be updated by Angular. By explicitly marking for check here, we tell Angular that
|
|
127
|
+
// it needs to check for new menu items and update the `@ContentChild` in `MatMenu`.
|
|
128
|
+
// @breaking-change 9.0.0 Make change detector ref required
|
|
129
|
+
if (this._changeDetectorRef) {
|
|
130
|
+
this._changeDetectorRef.markForCheck();
|
|
138
131
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
this._portal.attach(this._outlet, context);
|
|
133
|
+
this._attached.next();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Detaches the content.
|
|
137
|
+
* @docs-private
|
|
138
|
+
*/
|
|
139
|
+
detach() {
|
|
140
|
+
if (this._portal.isAttached) {
|
|
141
|
+
this._portal.detach();
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
144
|
+
ngOnDestroy() {
|
|
145
|
+
if (this._outlet) {
|
|
146
|
+
this._outlet.dispose();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
MatMenuContent.decorators = [
|
|
151
|
+
{ type: Directive, args: [{
|
|
152
|
+
selector: 'ng-template[matMenuContent]',
|
|
153
|
+
providers: [{ provide: MAT_MENU_CONTENT, useExisting: MatMenuContent }],
|
|
154
|
+
},] }
|
|
155
|
+
];
|
|
156
|
+
MatMenuContent.ctorParameters = () => [
|
|
157
|
+
{ type: TemplateRef },
|
|
158
|
+
{ type: ComponentFactoryResolver },
|
|
159
|
+
{ type: ApplicationRef },
|
|
160
|
+
{ type: Injector },
|
|
161
|
+
{ type: ViewContainerRef },
|
|
162
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
163
|
+
{ type: ChangeDetectorRef }
|
|
164
|
+
];
|
|
161
165
|
|
|
162
166
|
/**
|
|
163
167
|
* @license
|
|
@@ -224,138 +228,135 @@ const _MatMenuItemMixinBase = mixinDisableRipple(mixinDisabled(MatMenuItemBase))
|
|
|
224
228
|
/**
|
|
225
229
|
* Single item inside of a `mat-menu`. Provides the menu item styling and accessibility treatment.
|
|
226
230
|
*/
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
_parentMenu.addItem(this);
|
|
247
|
-
}
|
|
248
|
-
this._document = document;
|
|
231
|
+
class MatMenuItem extends _MatMenuItemMixinBase {
|
|
232
|
+
constructor(_elementRef, document, _focusMonitor, _parentMenu) {
|
|
233
|
+
// @breaking-change 8.0.0 make `_focusMonitor` and `document` required params.
|
|
234
|
+
super();
|
|
235
|
+
this._elementRef = _elementRef;
|
|
236
|
+
this._focusMonitor = _focusMonitor;
|
|
237
|
+
this._parentMenu = _parentMenu;
|
|
238
|
+
/** ARIA role for the menu item. */
|
|
239
|
+
this.role = 'menuitem';
|
|
240
|
+
/** Stream that emits when the menu item is hovered. */
|
|
241
|
+
this._hovered = new Subject();
|
|
242
|
+
/** Stream that emits when the menu item is focused. */
|
|
243
|
+
this._focused = new Subject();
|
|
244
|
+
/** Whether the menu item is highlighted. */
|
|
245
|
+
this._highlighted = false;
|
|
246
|
+
/** Whether the menu item acts as a trigger for a sub-menu. */
|
|
247
|
+
this._triggersSubmenu = false;
|
|
248
|
+
if (_parentMenu && _parentMenu.addItem) {
|
|
249
|
+
_parentMenu.addItem(this);
|
|
249
250
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
this._getHostElement().focus(options);
|
|
257
|
-
}
|
|
258
|
-
this._focused.next(this);
|
|
251
|
+
this._document = document;
|
|
252
|
+
}
|
|
253
|
+
/** Focuses the menu item. */
|
|
254
|
+
focus(origin = 'program', options) {
|
|
255
|
+
if (this._focusMonitor) {
|
|
256
|
+
this._focusMonitor.focusVia(this._getHostElement(), origin, options);
|
|
259
257
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// Start monitoring the element so it gets the appropriate focused classes. We want
|
|
263
|
-
// to show the focus style for menu items only when the focus was not caused by a
|
|
264
|
-
// mouse or touch interaction.
|
|
265
|
-
this._focusMonitor.monitor(this._elementRef, false);
|
|
266
|
-
}
|
|
258
|
+
else {
|
|
259
|
+
this._getHostElement().focus(options);
|
|
267
260
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
this.
|
|
276
|
-
this._focused.complete();
|
|
277
|
-
}
|
|
278
|
-
/** Used to set the `tabindex`. */
|
|
279
|
-
_getTabIndex() {
|
|
280
|
-
return this.disabled ? '-1' : '0';
|
|
261
|
+
this._focused.next(this);
|
|
262
|
+
}
|
|
263
|
+
ngAfterViewInit() {
|
|
264
|
+
if (this._focusMonitor) {
|
|
265
|
+
// Start monitoring the element so it gets the appropriate focused classes. We want
|
|
266
|
+
// to show the focus style for menu items only when the focus was not caused by a
|
|
267
|
+
// mouse or touch interaction.
|
|
268
|
+
this._focusMonitor.monitor(this._elementRef, false);
|
|
281
269
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
}
|
|
271
|
+
ngOnDestroy() {
|
|
272
|
+
if (this._focusMonitor) {
|
|
273
|
+
this._focusMonitor.stopMonitoring(this._elementRef);
|
|
285
274
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
// In Ivy the `host` bindings will be merged when this class is extended, whereas in
|
|
289
|
-
// ViewEngine they're overwritten.
|
|
290
|
-
// TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
|
|
291
|
-
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
292
|
-
_checkDisabled(event) {
|
|
293
|
-
if (this.disabled) {
|
|
294
|
-
event.preventDefault();
|
|
295
|
-
event.stopPropagation();
|
|
296
|
-
}
|
|
275
|
+
if (this._parentMenu && this._parentMenu.removeItem) {
|
|
276
|
+
this._parentMenu.removeItem(this);
|
|
297
277
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
278
|
+
this._hovered.complete();
|
|
279
|
+
this._focused.complete();
|
|
280
|
+
}
|
|
281
|
+
/** Used to set the `tabindex`. */
|
|
282
|
+
_getTabIndex() {
|
|
283
|
+
return this.disabled ? '-1' : '0';
|
|
284
|
+
}
|
|
285
|
+
/** Returns the host DOM element. */
|
|
286
|
+
_getHostElement() {
|
|
287
|
+
return this._elementRef.nativeElement;
|
|
288
|
+
}
|
|
289
|
+
/** Prevents the default element actions if it is disabled. */
|
|
290
|
+
// We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
|
|
291
|
+
// In Ivy the `host` bindings will be merged when this class is extended, whereas in
|
|
292
|
+
// ViewEngine they're overwritten.
|
|
293
|
+
// TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
|
|
294
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
295
|
+
_checkDisabled(event) {
|
|
296
|
+
if (this.disabled) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
event.stopPropagation();
|
|
306
299
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
300
|
+
}
|
|
301
|
+
/** Emits to the hover stream. */
|
|
302
|
+
// We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
|
|
303
|
+
// In Ivy the `host` bindings will be merged when this class is extended, whereas in
|
|
304
|
+
// ViewEngine they're overwritten.
|
|
305
|
+
// TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
|
|
306
|
+
// tslint:disable-next-line:no-host-decorator-in-concrete
|
|
307
|
+
_handleMouseEnter() {
|
|
308
|
+
this._hovered.next(this);
|
|
309
|
+
}
|
|
310
|
+
/** Gets the label to be used when determining whether the option should be focused. */
|
|
311
|
+
getLabel() {
|
|
312
|
+
const element = this._elementRef.nativeElement;
|
|
313
|
+
const textNodeType = this._document ? this._document.TEXT_NODE : 3;
|
|
314
|
+
let output = '';
|
|
315
|
+
if (element.childNodes) {
|
|
316
|
+
const length = element.childNodes.length;
|
|
317
|
+
// Go through all the top-level text nodes and extract their text.
|
|
318
|
+
// We skip anything that's not a text node to prevent the text from
|
|
319
|
+
// being thrown off by something like an icon.
|
|
320
|
+
for (let i = 0; i < length; i++) {
|
|
321
|
+
if (element.childNodes[i].nodeType === textNodeType) {
|
|
322
|
+
output += element.childNodes[i].textContent;
|
|
321
323
|
}
|
|
322
324
|
}
|
|
323
|
-
return output.trim();
|
|
324
325
|
}
|
|
326
|
+
return output.trim();
|
|
325
327
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
]
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
})();
|
|
328
|
+
}
|
|
329
|
+
MatMenuItem.decorators = [
|
|
330
|
+
{ type: Component, args: [{
|
|
331
|
+
selector: '[mat-menu-item]',
|
|
332
|
+
exportAs: 'matMenuItem',
|
|
333
|
+
inputs: ['disabled', 'disableRipple'],
|
|
334
|
+
host: {
|
|
335
|
+
'[attr.role]': 'role',
|
|
336
|
+
'[class.mat-menu-item]': 'true',
|
|
337
|
+
'[class.mat-menu-item-highlighted]': '_highlighted',
|
|
338
|
+
'[class.mat-menu-item-submenu-trigger]': '_triggersSubmenu',
|
|
339
|
+
'[attr.tabindex]': '_getTabIndex()',
|
|
340
|
+
'[attr.aria-disabled]': 'disabled.toString()',
|
|
341
|
+
'[attr.disabled]': 'disabled || null',
|
|
342
|
+
'class': 'mat-focus-indicator',
|
|
343
|
+
},
|
|
344
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
345
|
+
encapsulation: ViewEncapsulation.None,
|
|
346
|
+
template: "<ng-content></ng-content>\n<div class=\"mat-menu-ripple\" matRipple\n [matRippleDisabled]=\"disableRipple || disabled\"\n [matRippleTrigger]=\"_getHostElement()\">\n</div>\n"
|
|
347
|
+
},] }
|
|
348
|
+
];
|
|
349
|
+
MatMenuItem.ctorParameters = () => [
|
|
350
|
+
{ type: ElementRef },
|
|
351
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
352
|
+
{ type: FocusMonitor },
|
|
353
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_MENU_PANEL,] }, { type: Optional }] }
|
|
354
|
+
];
|
|
355
|
+
MatMenuItem.propDecorators = {
|
|
356
|
+
role: [{ type: Input }],
|
|
357
|
+
_checkDisabled: [{ type: HostListener, args: ['click', ['$event'],] }],
|
|
358
|
+
_handleMouseEnter: [{ type: HostListener, args: ['mouseenter',] }]
|
|
359
|
+
};
|
|
359
360
|
|
|
360
361
|
/**
|
|
361
362
|
* @license
|
|
@@ -385,328 +386,324 @@ function MAT_MENU_DEFAULT_OPTIONS_FACTORY() {
|
|
|
385
386
|
const MAT_MENU_BASE_ELEVATION = 4;
|
|
386
387
|
let menuPanelUid = 0;
|
|
387
388
|
/** Base class with all of the `MatMenu` functionality. */
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
* Event emitted when the menu is closed.
|
|
414
|
-
* @deprecated Switch to `closed` instead
|
|
415
|
-
* @breaking-change 8.0.0
|
|
416
|
-
*/
|
|
417
|
-
this.close = this.closed;
|
|
418
|
-
this.panelId = `mat-menu-panel-${menuPanelUid++}`;
|
|
419
|
-
}
|
|
420
|
-
/** Position of the menu in the X axis. */
|
|
421
|
-
get xPosition() { return this._xPosition; }
|
|
422
|
-
set xPosition(value) {
|
|
423
|
-
if (value !== 'before' && value !== 'after') {
|
|
424
|
-
throwMatMenuInvalidPositionX();
|
|
425
|
-
}
|
|
426
|
-
this._xPosition = value;
|
|
427
|
-
this.setPositionClasses();
|
|
428
|
-
}
|
|
429
|
-
/** Position of the menu in the Y axis. */
|
|
430
|
-
get yPosition() { return this._yPosition; }
|
|
431
|
-
set yPosition(value) {
|
|
432
|
-
if (value !== 'above' && value !== 'below') {
|
|
433
|
-
throwMatMenuInvalidPositionY();
|
|
434
|
-
}
|
|
435
|
-
this._yPosition = value;
|
|
436
|
-
this.setPositionClasses();
|
|
437
|
-
}
|
|
438
|
-
/** Whether the menu should overlap its trigger. */
|
|
439
|
-
get overlapTrigger() { return this._overlapTrigger; }
|
|
440
|
-
set overlapTrigger(value) {
|
|
441
|
-
this._overlapTrigger = coerceBooleanProperty(value);
|
|
442
|
-
}
|
|
443
|
-
/** Whether the menu has a backdrop. */
|
|
444
|
-
get hasBackdrop() { return this._hasBackdrop; }
|
|
445
|
-
set hasBackdrop(value) {
|
|
446
|
-
this._hasBackdrop = coerceBooleanProperty(value);
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* This method takes classes set on the host mat-menu element and applies them on the
|
|
450
|
-
* menu template that displays in the overlay container. Otherwise, it's difficult
|
|
451
|
-
* to style the containing menu from outside the component.
|
|
452
|
-
* @param classes list of class names
|
|
453
|
-
*/
|
|
454
|
-
set panelClass(classes) {
|
|
455
|
-
const previousPanelClass = this._previousPanelClass;
|
|
456
|
-
if (previousPanelClass && previousPanelClass.length) {
|
|
457
|
-
previousPanelClass.split(' ').forEach((className) => {
|
|
458
|
-
this._classList[className] = false;
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
this._previousPanelClass = classes;
|
|
462
|
-
if (classes && classes.length) {
|
|
463
|
-
classes.split(' ').forEach((className) => {
|
|
464
|
-
this._classList[className] = true;
|
|
465
|
-
});
|
|
466
|
-
this._elementRef.nativeElement.className = '';
|
|
467
|
-
}
|
|
468
|
-
}
|
|
389
|
+
class _MatMenuBase {
|
|
390
|
+
constructor(_elementRef, _ngZone, _defaultOptions) {
|
|
391
|
+
this._elementRef = _elementRef;
|
|
392
|
+
this._ngZone = _ngZone;
|
|
393
|
+
this._defaultOptions = _defaultOptions;
|
|
394
|
+
this._xPosition = this._defaultOptions.xPosition;
|
|
395
|
+
this._yPosition = this._defaultOptions.yPosition;
|
|
396
|
+
/** Only the direct descendant menu items. */
|
|
397
|
+
this._directDescendantItems = new QueryList();
|
|
398
|
+
/** Subscription to tab events on the menu panel */
|
|
399
|
+
this._tabSubscription = Subscription.EMPTY;
|
|
400
|
+
/** Config object to be passed into the menu's ngClass */
|
|
401
|
+
this._classList = {};
|
|
402
|
+
/** Current state of the panel animation. */
|
|
403
|
+
this._panelAnimationState = 'void';
|
|
404
|
+
/** Emits whenever an animation on the menu completes. */
|
|
405
|
+
this._animationDone = new Subject();
|
|
406
|
+
/** Class or list of classes to be added to the overlay panel. */
|
|
407
|
+
this.overlayPanelClass = this._defaultOptions.overlayPanelClass || '';
|
|
408
|
+
/** Class to be added to the backdrop element. */
|
|
409
|
+
this.backdropClass = this._defaultOptions.backdropClass;
|
|
410
|
+
this._overlapTrigger = this._defaultOptions.overlapTrigger;
|
|
411
|
+
this._hasBackdrop = this._defaultOptions.hasBackdrop;
|
|
412
|
+
/** Event emitted when the menu is closed. */
|
|
413
|
+
this.closed = new EventEmitter();
|
|
469
414
|
/**
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* to style the containing menu from outside the component.
|
|
473
|
-
* @deprecated Use `panelClass` instead.
|
|
415
|
+
* Event emitted when the menu is closed.
|
|
416
|
+
* @deprecated Switch to `closed` instead
|
|
474
417
|
* @breaking-change 8.0.0
|
|
475
418
|
*/
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
this._tabSubscription = this._keyManager.tabOut.subscribe(() => this.closed.emit('tab'));
|
|
485
|
-
// If a user manually (programatically) focuses a menu item, we need to reflect that focus
|
|
486
|
-
// change back to the key manager. Note that we don't need to unsubscribe here because _focused
|
|
487
|
-
// is internal and we know that it gets completed on destroy.
|
|
488
|
-
this._directDescendantItems.changes.pipe(startWith(this._directDescendantItems), switchMap(items => merge(...items.map((item) => item._focused)))).subscribe(focusedItem => this._keyManager.updateActiveItem(focusedItem));
|
|
489
|
-
}
|
|
490
|
-
ngOnDestroy() {
|
|
491
|
-
this._directDescendantItems.destroy();
|
|
492
|
-
this._tabSubscription.unsubscribe();
|
|
493
|
-
this.closed.complete();
|
|
419
|
+
this.close = this.closed;
|
|
420
|
+
this.panelId = `mat-menu-panel-${menuPanelUid++}`;
|
|
421
|
+
}
|
|
422
|
+
/** Position of the menu in the X axis. */
|
|
423
|
+
get xPosition() { return this._xPosition; }
|
|
424
|
+
set xPosition(value) {
|
|
425
|
+
if (value !== 'before' && value !== 'after') {
|
|
426
|
+
throwMatMenuInvalidPositionX();
|
|
494
427
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
428
|
+
this._xPosition = value;
|
|
429
|
+
this.setPositionClasses();
|
|
430
|
+
}
|
|
431
|
+
/** Position of the menu in the Y axis. */
|
|
432
|
+
get yPosition() { return this._yPosition; }
|
|
433
|
+
set yPosition(value) {
|
|
434
|
+
if (value !== 'above' && value !== 'below') {
|
|
435
|
+
throwMatMenuInvalidPositionY();
|
|
500
436
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
case LEFT_ARROW:
|
|
527
|
-
if (this.parentMenu && this.direction === 'ltr') {
|
|
528
|
-
this.closed.emit('keydown');
|
|
529
|
-
}
|
|
530
|
-
break;
|
|
531
|
-
case RIGHT_ARROW:
|
|
532
|
-
if (this.parentMenu && this.direction === 'rtl') {
|
|
533
|
-
this.closed.emit('keydown');
|
|
534
|
-
}
|
|
535
|
-
break;
|
|
536
|
-
case HOME:
|
|
537
|
-
case END:
|
|
538
|
-
if (!hasModifierKey(event)) {
|
|
539
|
-
keyCode === HOME ? manager.setFirstItemActive() : manager.setLastItemActive();
|
|
540
|
-
event.preventDefault();
|
|
541
|
-
}
|
|
542
|
-
break;
|
|
543
|
-
default:
|
|
544
|
-
if (keyCode === UP_ARROW || keyCode === DOWN_ARROW) {
|
|
545
|
-
manager.setFocusOrigin('keyboard');
|
|
546
|
-
}
|
|
547
|
-
manager.onKeydown(event);
|
|
548
|
-
}
|
|
437
|
+
this._yPosition = value;
|
|
438
|
+
this.setPositionClasses();
|
|
439
|
+
}
|
|
440
|
+
/** Whether the menu should overlap its trigger. */
|
|
441
|
+
get overlapTrigger() { return this._overlapTrigger; }
|
|
442
|
+
set overlapTrigger(value) {
|
|
443
|
+
this._overlapTrigger = coerceBooleanProperty(value);
|
|
444
|
+
}
|
|
445
|
+
/** Whether the menu has a backdrop. */
|
|
446
|
+
get hasBackdrop() { return this._hasBackdrop; }
|
|
447
|
+
set hasBackdrop(value) {
|
|
448
|
+
this._hasBackdrop = coerceBooleanProperty(value);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* This method takes classes set on the host mat-menu element and applies them on the
|
|
452
|
+
* menu template that displays in the overlay container. Otherwise, it's difficult
|
|
453
|
+
* to style the containing menu from outside the component.
|
|
454
|
+
* @param classes list of class names
|
|
455
|
+
*/
|
|
456
|
+
set panelClass(classes) {
|
|
457
|
+
const previousPanelClass = this._previousPanelClass;
|
|
458
|
+
if (previousPanelClass && previousPanelClass.length) {
|
|
459
|
+
previousPanelClass.split(' ').forEach((className) => {
|
|
460
|
+
this._classList[className] = false;
|
|
461
|
+
});
|
|
549
462
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
if (this.lazyContent) {
|
|
557
|
-
this._ngZone.onStable.asObservable()
|
|
558
|
-
.pipe(take(1))
|
|
559
|
-
.subscribe(() => this._focusFirstItem(origin));
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
this._focusFirstItem(origin);
|
|
563
|
-
}
|
|
463
|
+
this._previousPanelClass = classes;
|
|
464
|
+
if (classes && classes.length) {
|
|
465
|
+
classes.split(' ').forEach((className) => {
|
|
466
|
+
this._classList[className] = true;
|
|
467
|
+
});
|
|
468
|
+
this._elementRef.nativeElement.className = '';
|
|
564
469
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* This method takes classes set on the host mat-menu element and applies them on the
|
|
473
|
+
* menu template that displays in the overlay container. Otherwise, it's difficult
|
|
474
|
+
* to style the containing menu from outside the component.
|
|
475
|
+
* @deprecated Use `panelClass` instead.
|
|
476
|
+
* @breaking-change 8.0.0
|
|
477
|
+
*/
|
|
478
|
+
get classList() { return this.panelClass; }
|
|
479
|
+
set classList(classes) { this.panelClass = classes; }
|
|
480
|
+
ngOnInit() {
|
|
481
|
+
this.setPositionClasses();
|
|
482
|
+
}
|
|
483
|
+
ngAfterContentInit() {
|
|
484
|
+
this._updateDirectDescendants();
|
|
485
|
+
this._keyManager = new FocusKeyManager(this._directDescendantItems).withWrap().withTypeAhead();
|
|
486
|
+
this._tabSubscription = this._keyManager.tabOut.subscribe(() => this.closed.emit('tab'));
|
|
487
|
+
// If a user manually (programatically) focuses a menu item, we need to reflect that focus
|
|
488
|
+
// change back to the key manager. Note that we don't need to unsubscribe here because _focused
|
|
489
|
+
// is internal and we know that it gets completed on destroy.
|
|
490
|
+
this._directDescendantItems.changes.pipe(startWith(this._directDescendantItems), switchMap(items => merge(...items.map((item) => item._focused)))).subscribe(focusedItem => this._keyManager.updateActiveItem(focusedItem));
|
|
491
|
+
}
|
|
492
|
+
ngOnDestroy() {
|
|
493
|
+
this._directDescendantItems.destroy();
|
|
494
|
+
this._tabSubscription.unsubscribe();
|
|
495
|
+
this.closed.complete();
|
|
496
|
+
}
|
|
497
|
+
/** Stream that emits whenever the hovered menu item changes. */
|
|
498
|
+
_hovered() {
|
|
499
|
+
// Coerce the `changes` property because Angular types it as `Observable<any>`
|
|
500
|
+
const itemChanges = this._directDescendantItems.changes;
|
|
501
|
+
return itemChanges.pipe(startWith(this._directDescendantItems), switchMap(items => merge(...items.map((item) => item._hovered))));
|
|
502
|
+
}
|
|
503
|
+
/*
|
|
504
|
+
* Registers a menu item with the menu.
|
|
505
|
+
* @docs-private
|
|
506
|
+
* @deprecated No longer being used. To be removed.
|
|
507
|
+
* @breaking-change 9.0.0
|
|
508
|
+
*/
|
|
509
|
+
addItem(_item) { }
|
|
510
|
+
/**
|
|
511
|
+
* Removes an item from the menu.
|
|
512
|
+
* @docs-private
|
|
513
|
+
* @deprecated No longer being used. To be removed.
|
|
514
|
+
* @breaking-change 9.0.0
|
|
515
|
+
*/
|
|
516
|
+
removeItem(_item) { }
|
|
517
|
+
/** Handle a keyboard event from the menu, delegating to the appropriate action. */
|
|
518
|
+
_handleKeydown(event) {
|
|
519
|
+
const keyCode = event.keyCode;
|
|
520
|
+
const manager = this._keyManager;
|
|
521
|
+
switch (keyCode) {
|
|
522
|
+
case ESCAPE:
|
|
523
|
+
if (!hasModifierKey(event)) {
|
|
524
|
+
event.preventDefault();
|
|
525
|
+
this.closed.emit('keydown');
|
|
589
526
|
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
* the user to start from the first option when pressing the down arrow.
|
|
595
|
-
*/
|
|
596
|
-
resetActiveItem() {
|
|
597
|
-
this._keyManager.setActiveItem(-1);
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Sets the menu panel elevation.
|
|
601
|
-
* @param depth Number of parent menus that come before the menu.
|
|
602
|
-
*/
|
|
603
|
-
setElevation(depth) {
|
|
604
|
-
// The elevation starts at the base and increases by one for each level.
|
|
605
|
-
// Capped at 24 because that's the maximum elevation defined in the Material design spec.
|
|
606
|
-
const elevation = Math.min(MAT_MENU_BASE_ELEVATION + depth, 24);
|
|
607
|
-
const newElevation = `mat-elevation-z${elevation}`;
|
|
608
|
-
const customElevation = Object.keys(this._classList).find(c => c.startsWith('mat-elevation-z'));
|
|
609
|
-
if (!customElevation || customElevation === this._previousElevation) {
|
|
610
|
-
if (this._previousElevation) {
|
|
611
|
-
this._classList[this._previousElevation] = false;
|
|
527
|
+
break;
|
|
528
|
+
case LEFT_ARROW:
|
|
529
|
+
if (this.parentMenu && this.direction === 'ltr') {
|
|
530
|
+
this.closed.emit('keydown');
|
|
612
531
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
532
|
+
break;
|
|
533
|
+
case RIGHT_ARROW:
|
|
534
|
+
if (this.parentMenu && this.direction === 'rtl') {
|
|
535
|
+
this.closed.emit('keydown');
|
|
536
|
+
}
|
|
537
|
+
break;
|
|
538
|
+
case HOME:
|
|
539
|
+
case END:
|
|
540
|
+
if (!hasModifierKey(event)) {
|
|
541
|
+
keyCode === HOME ? manager.setFirstItemActive() : manager.setLastItemActive();
|
|
542
|
+
event.preventDefault();
|
|
543
|
+
}
|
|
544
|
+
break;
|
|
545
|
+
default:
|
|
546
|
+
if (keyCode === UP_ARROW || keyCode === DOWN_ARROW) {
|
|
547
|
+
manager.setFocusOrigin('keyboard');
|
|
548
|
+
}
|
|
549
|
+
manager.onKeydown(event);
|
|
630
550
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Focus the first item in the menu.
|
|
554
|
+
* @param origin Action from which the focus originated. Used to set the correct styling.
|
|
555
|
+
*/
|
|
556
|
+
focusFirstItem(origin = 'program') {
|
|
557
|
+
// When the content is rendered lazily, it takes a bit before the items are inside the DOM.
|
|
558
|
+
if (this.lazyContent) {
|
|
559
|
+
this._ngZone.onStable.asObservable()
|
|
560
|
+
.pipe(take(1))
|
|
561
|
+
.subscribe(() => this._focusFirstItem(origin));
|
|
635
562
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
// @breaking-change 8.0.0 Combine with _startAnimation.
|
|
639
|
-
this._panelAnimationState = 'void';
|
|
563
|
+
else {
|
|
564
|
+
this._focusFirstItem(origin);
|
|
640
565
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Actual implementation that focuses the first item. Needs to be separated
|
|
569
|
+
* out so we don't repeat the same logic in the public `focusFirstItem` method.
|
|
570
|
+
*/
|
|
571
|
+
_focusFirstItem(origin) {
|
|
572
|
+
const manager = this._keyManager;
|
|
573
|
+
manager.setFocusOrigin(origin).setFirstItemActive();
|
|
574
|
+
// If there's no active item at this point, it means that all the items are disabled.
|
|
575
|
+
// Move focus to the menu panel so keyboard events like Escape still work. Also this will
|
|
576
|
+
// give _some_ feedback to screen readers.
|
|
577
|
+
if (!manager.activeItem && this._directDescendantItems.length) {
|
|
578
|
+
let element = this._directDescendantItems.first._getHostElement().parentElement;
|
|
579
|
+
// Because the `mat-menu` is at the DOM insertion point, not inside the overlay, we don't
|
|
580
|
+
// have a nice way of getting a hold of the menu panel. We can't use a `ViewChild` either
|
|
581
|
+
// because the panel is inside an `ng-template`. We work around it by starting from one of
|
|
582
|
+
// the items and walking up the DOM.
|
|
583
|
+
while (element) {
|
|
584
|
+
if (element.getAttribute('role') === 'menu') {
|
|
585
|
+
element.focus();
|
|
586
|
+
break;
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
element = element.parentElement;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
645
592
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Resets the active item in the menu. This is used when the menu is opened, allowing
|
|
596
|
+
* the user to start from the first option when pressing the down arrow.
|
|
597
|
+
*/
|
|
598
|
+
resetActiveItem() {
|
|
599
|
+
this._keyManager.setActiveItem(-1);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Sets the menu panel elevation.
|
|
603
|
+
* @param depth Number of parent menus that come before the menu.
|
|
604
|
+
*/
|
|
605
|
+
setElevation(depth) {
|
|
606
|
+
// The elevation starts at the base and increases by one for each level.
|
|
607
|
+
// Capped at 24 because that's the maximum elevation defined in the Material design spec.
|
|
608
|
+
const elevation = Math.min(MAT_MENU_BASE_ELEVATION + depth, 24);
|
|
609
|
+
const newElevation = `mat-elevation-z${elevation}`;
|
|
610
|
+
const customElevation = Object.keys(this._classList).find(c => c.startsWith('mat-elevation-z'));
|
|
611
|
+
if (!customElevation || customElevation === this._previousElevation) {
|
|
612
|
+
if (this._previousElevation) {
|
|
613
|
+
this._classList[this._previousElevation] = false;
|
|
656
614
|
}
|
|
615
|
+
this._classList[newElevation] = true;
|
|
616
|
+
this._previousElevation = newElevation;
|
|
657
617
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Adds classes to the menu panel based on its position. Can be used by
|
|
621
|
+
* consumers to add specific styling based on the position.
|
|
622
|
+
* @param posX Position of the menu along the x axis.
|
|
623
|
+
* @param posY Position of the menu along the y axis.
|
|
624
|
+
* @docs-private
|
|
625
|
+
*/
|
|
626
|
+
setPositionClasses(posX = this.xPosition, posY = this.yPosition) {
|
|
627
|
+
const classes = this._classList;
|
|
628
|
+
classes['mat-menu-before'] = posX === 'before';
|
|
629
|
+
classes['mat-menu-after'] = posX === 'after';
|
|
630
|
+
classes['mat-menu-above'] = posY === 'above';
|
|
631
|
+
classes['mat-menu-below'] = posY === 'below';
|
|
632
|
+
}
|
|
633
|
+
/** Starts the enter animation. */
|
|
634
|
+
_startAnimation() {
|
|
635
|
+
// @breaking-change 8.0.0 Combine with _resetAnimation.
|
|
636
|
+
this._panelAnimationState = 'enter';
|
|
637
|
+
}
|
|
638
|
+
/** Resets the panel animation to its initial state. */
|
|
639
|
+
_resetAnimation() {
|
|
640
|
+
// @breaking-change 8.0.0 Combine with _startAnimation.
|
|
641
|
+
this._panelAnimationState = 'void';
|
|
642
|
+
}
|
|
643
|
+
/** Callback that is invoked when the panel animation completes. */
|
|
644
|
+
_onAnimationDone(event) {
|
|
645
|
+
this._animationDone.next(event);
|
|
646
|
+
this._isAnimating = false;
|
|
647
|
+
}
|
|
648
|
+
_onAnimationStart(event) {
|
|
649
|
+
this._isAnimating = true;
|
|
650
|
+
// Scroll the content element to the top as soon as the animation starts. This is necessary,
|
|
651
|
+
// because we move focus to the first item while it's still being animated, which can throw
|
|
652
|
+
// the browser off when it determines the scroll position. Alternatively we can move focus
|
|
653
|
+
// when the animation is done, however moving focus asynchronously will interrupt screen
|
|
654
|
+
// readers which are in the process of reading out the menu already. We take the `element`
|
|
655
|
+
// from the `event` since we can't use a `ViewChild` to access the pane.
|
|
656
|
+
if (event.toState === 'enter' && this._keyManager.activeItemIndex === 0) {
|
|
657
|
+
event.element.scrollTop = 0;
|
|
671
658
|
}
|
|
672
659
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
ariaDescribedby: [{ type: Input, args: ['aria-describedby',] }],
|
|
687
|
-
xPosition: [{ type: Input }],
|
|
688
|
-
yPosition: [{ type: Input }],
|
|
689
|
-
templateRef: [{ type: ViewChild, args: [TemplateRef,] }],
|
|
690
|
-
items: [{ type: ContentChildren, args: [MatMenuItem, { descendants: false },] }],
|
|
691
|
-
lazyContent: [{ type: ContentChild, args: [MatMenuContent,] }],
|
|
692
|
-
overlapTrigger: [{ type: Input }],
|
|
693
|
-
hasBackdrop: [{ type: Input }],
|
|
694
|
-
panelClass: [{ type: Input, args: ['class',] }],
|
|
695
|
-
classList: [{ type: Input }],
|
|
696
|
-
closed: [{ type: Output }],
|
|
697
|
-
close: [{ type: Output }]
|
|
698
|
-
};
|
|
699
|
-
return _MatMenuBase;
|
|
700
|
-
})();
|
|
701
|
-
/** @docs-private We show the "_MatMenu" class as "MatMenu" in the docs. */
|
|
702
|
-
let MatMenu = /** @class */ (() => {
|
|
703
|
-
class MatMenu extends _MatMenuBase {
|
|
660
|
+
/**
|
|
661
|
+
* Sets up a stream that will keep track of any newly-added menu items and will update the list
|
|
662
|
+
* of direct descendants. We collect the descendants this way, because `_allItems` can include
|
|
663
|
+
* items that are part of child menus, and using a custom way of registering items is unreliable
|
|
664
|
+
* when it comes to maintaining the item order.
|
|
665
|
+
*/
|
|
666
|
+
_updateDirectDescendants() {
|
|
667
|
+
this._allItems.changes
|
|
668
|
+
.pipe(startWith(this._allItems))
|
|
669
|
+
.subscribe((items) => {
|
|
670
|
+
this._directDescendantItems.reset(items.filter(item => item._parentMenu === this));
|
|
671
|
+
this._directDescendantItems.notifyOnChanges();
|
|
672
|
+
});
|
|
704
673
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
674
|
+
}
|
|
675
|
+
_MatMenuBase.decorators = [
|
|
676
|
+
{ type: Directive }
|
|
677
|
+
];
|
|
678
|
+
_MatMenuBase.ctorParameters = () => [
|
|
679
|
+
{ type: ElementRef },
|
|
680
|
+
{ type: NgZone },
|
|
681
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_MENU_DEFAULT_OPTIONS,] }] }
|
|
682
|
+
];
|
|
683
|
+
_MatMenuBase.propDecorators = {
|
|
684
|
+
_allItems: [{ type: ContentChildren, args: [MatMenuItem, { descendants: true },] }],
|
|
685
|
+
backdropClass: [{ type: Input }],
|
|
686
|
+
ariaLabel: [{ type: Input, args: ['aria-label',] }],
|
|
687
|
+
ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
|
|
688
|
+
ariaDescribedby: [{ type: Input, args: ['aria-describedby',] }],
|
|
689
|
+
xPosition: [{ type: Input }],
|
|
690
|
+
yPosition: [{ type: Input }],
|
|
691
|
+
templateRef: [{ type: ViewChild, args: [TemplateRef,] }],
|
|
692
|
+
items: [{ type: ContentChildren, args: [MatMenuItem, { descendants: false },] }],
|
|
693
|
+
lazyContent: [{ type: ContentChild, args: [MAT_MENU_CONTENT,] }],
|
|
694
|
+
overlapTrigger: [{ type: Input }],
|
|
695
|
+
hasBackdrop: [{ type: Input }],
|
|
696
|
+
panelClass: [{ type: Input, args: ['class',] }],
|
|
697
|
+
classList: [{ type: Input }],
|
|
698
|
+
closed: [{ type: Output }],
|
|
699
|
+
close: [{ type: Output }]
|
|
700
|
+
};
|
|
701
|
+
/** @docs-private We show the "_MatMenu" class as "MatMenu" in the docs. */
|
|
702
|
+
class MatMenu extends _MatMenuBase {
|
|
703
|
+
}
|
|
704
|
+
MatMenu.decorators = [
|
|
705
|
+
{ type: Directive }
|
|
706
|
+
];
|
|
710
707
|
// Note on the weird inheritance setup: we need three classes, because the MDC-based menu has to
|
|
711
708
|
// extend `MatMenu`, however keeping a reference to it will cause the inlined template and styles
|
|
712
709
|
// to be retained as well. The MDC menu also has to provide itself as a `MatMenu` in order for
|
|
@@ -718,37 +715,34 @@ let MatMenu = /** @class */ (() => {
|
|
|
718
715
|
// * _MatMenu - the actual menu component implementation with the Angular metadata that should
|
|
719
716
|
// be tree shaken away for MDC.
|
|
720
717
|
/** @docs-public MatMenu */
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
super(elementRef, ngZone, defaultOptions);
|
|
725
|
-
}
|
|
718
|
+
class _MatMenu extends MatMenu {
|
|
719
|
+
constructor(elementRef, ngZone, defaultOptions) {
|
|
720
|
+
super(elementRef, ngZone, defaultOptions);
|
|
726
721
|
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
]
|
|
750
|
-
|
|
751
|
-
})();
|
|
722
|
+
}
|
|
723
|
+
_MatMenu.decorators = [
|
|
724
|
+
{ type: Component, args: [{
|
|
725
|
+
selector: 'mat-menu',
|
|
726
|
+
template: "<ng-template>\n <div\n class=\"mat-menu-panel\"\n [id]=\"panelId\"\n [ngClass]=\"_classList\"\n (keydown)=\"_handleKeydown($event)\"\n (click)=\"closed.emit('click')\"\n [@transformMenu]=\"_panelAnimationState\"\n (@transformMenu.start)=\"_onAnimationStart($event)\"\n (@transformMenu.done)=\"_onAnimationDone($event)\"\n tabindex=\"-1\"\n role=\"menu\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\n [attr.aria-describedby]=\"ariaDescribedby || null\">\n <div class=\"mat-menu-content\">\n <ng-content></ng-content>\n </div>\n </div>\n</ng-template>\n",
|
|
727
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
728
|
+
encapsulation: ViewEncapsulation.None,
|
|
729
|
+
exportAs: 'matMenu',
|
|
730
|
+
animations: [
|
|
731
|
+
matMenuAnimations.transformMenu,
|
|
732
|
+
matMenuAnimations.fadeInItems
|
|
733
|
+
],
|
|
734
|
+
providers: [
|
|
735
|
+
{ provide: MAT_MENU_PANEL, useExisting: MatMenu },
|
|
736
|
+
{ provide: MatMenu, useExisting: _MatMenu }
|
|
737
|
+
],
|
|
738
|
+
styles: [".mat-menu-panel{min-width:112px;max-width:280px;overflow:auto;-webkit-overflow-scrolling:touch;max-height:calc(100vh - 48px);border-radius:4px;outline:0;min-height:64px}.mat-menu-panel.ng-animating{pointer-events:none}.cdk-high-contrast-active .mat-menu-panel{outline:solid 1px}.mat-menu-content:not(:empty){padding-top:8px;padding-bottom:8px}.mat-menu-item{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;outline:none;border:none;-webkit-tap-highlight-color:transparent;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;line-height:48px;height:48px;padding:0 16px;text-align:left;text-decoration:none;max-width:100%;position:relative}.mat-menu-item::-moz-focus-inner{border:0}.mat-menu-item[disabled]{cursor:default}[dir=rtl] .mat-menu-item{text-align:right}.mat-menu-item .mat-icon{margin-right:16px;vertical-align:middle}.mat-menu-item .mat-icon svg{vertical-align:top}[dir=rtl] .mat-menu-item .mat-icon{margin-left:16px;margin-right:0}.mat-menu-item[disabled]{pointer-events:none}.cdk-high-contrast-active .mat-menu-item.cdk-program-focused,.cdk-high-contrast-active .mat-menu-item.cdk-keyboard-focused,.cdk-high-contrast-active .mat-menu-item-highlighted{outline:dotted 1px}.mat-menu-item-submenu-trigger{padding-right:32px}.mat-menu-item-submenu-trigger::after{width:0;height:0;border-style:solid;border-width:5px 0 5px 5px;border-color:transparent transparent transparent currentColor;content:\"\";display:inline-block;position:absolute;top:50%;right:16px;transform:translateY(-50%)}[dir=rtl] .mat-menu-item-submenu-trigger{padding-right:16px;padding-left:32px}[dir=rtl] .mat-menu-item-submenu-trigger::after{right:auto;left:16px;transform:rotateY(180deg) translateY(-50%)}button.mat-menu-item{width:100%}.mat-menu-item .mat-menu-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none}\n"]
|
|
739
|
+
},] }
|
|
740
|
+
];
|
|
741
|
+
_MatMenu.ctorParameters = () => [
|
|
742
|
+
{ type: ElementRef },
|
|
743
|
+
{ type: NgZone },
|
|
744
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_MENU_DEFAULT_OPTIONS,] }] }
|
|
745
|
+
];
|
|
752
746
|
|
|
753
747
|
/**
|
|
754
748
|
* @license
|
|
@@ -775,449 +769,447 @@ const MENU_PANEL_TOP_PADDING = 8;
|
|
|
775
769
|
const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
|
|
776
770
|
// TODO(andrewseguin): Remove the kebab versions in favor of camelCased attribute selectors
|
|
777
771
|
/** Directive applied to an element that should trigger a `mat-menu`. */
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
this._menuCloseSubscription = Subscription.EMPTY;
|
|
796
|
-
/**
|
|
797
|
-
* Handles touch start events on the trigger.
|
|
798
|
-
* Needs to be an arrow function so we can easily use addEventListener and removeEventListener.
|
|
799
|
-
*/
|
|
800
|
-
this._handleTouchStart = () => this._openedBy = 'touch';
|
|
801
|
-
// Tracking input type is necessary so it's possible to only auto-focus
|
|
802
|
-
// the first item of the list when the menu is opened via the keyboard
|
|
803
|
-
this._openedBy = null;
|
|
804
|
-
/**
|
|
805
|
-
* Whether focus should be restored when the menu is closed.
|
|
806
|
-
* Note that disabling this option can have accessibility implications
|
|
807
|
-
* and it's up to you to manage focus, if you decide to turn it off.
|
|
808
|
-
*/
|
|
809
|
-
this.restoreFocus = true;
|
|
810
|
-
/** Event emitted when the associated menu is opened. */
|
|
811
|
-
this.menuOpened = new EventEmitter();
|
|
812
|
-
/**
|
|
813
|
-
* Event emitted when the associated menu is opened.
|
|
814
|
-
* @deprecated Switch to `menuOpened` instead
|
|
815
|
-
* @breaking-change 8.0.0
|
|
816
|
-
*/
|
|
817
|
-
// tslint:disable-next-line:no-output-on-prefix
|
|
818
|
-
this.onMenuOpen = this.menuOpened;
|
|
819
|
-
/** Event emitted when the associated menu is closed. */
|
|
820
|
-
this.menuClosed = new EventEmitter();
|
|
821
|
-
/**
|
|
822
|
-
* Event emitted when the associated menu is closed.
|
|
823
|
-
* @deprecated Switch to `menuClosed` instead
|
|
824
|
-
* @breaking-change 8.0.0
|
|
825
|
-
*/
|
|
826
|
-
// tslint:disable-next-line:no-output-on-prefix
|
|
827
|
-
this.onMenuClose = this.menuClosed;
|
|
828
|
-
_element.nativeElement.addEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
|
|
829
|
-
if (_menuItemInstance) {
|
|
830
|
-
_menuItemInstance._triggersSubmenu = this.triggersSubmenu();
|
|
831
|
-
}
|
|
832
|
-
this._scrollStrategy = scrollStrategy;
|
|
833
|
-
}
|
|
772
|
+
class MatMenuTrigger {
|
|
773
|
+
constructor(_overlay, _element, _viewContainerRef, scrollStrategy, _parentMenu, _menuItemInstance, _dir,
|
|
774
|
+
// TODO(crisbeto): make the _focusMonitor required when doing breaking changes.
|
|
775
|
+
// @breaking-change 8.0.0
|
|
776
|
+
_focusMonitor) {
|
|
777
|
+
this._overlay = _overlay;
|
|
778
|
+
this._element = _element;
|
|
779
|
+
this._viewContainerRef = _viewContainerRef;
|
|
780
|
+
this._parentMenu = _parentMenu;
|
|
781
|
+
this._menuItemInstance = _menuItemInstance;
|
|
782
|
+
this._dir = _dir;
|
|
783
|
+
this._focusMonitor = _focusMonitor;
|
|
784
|
+
this._overlayRef = null;
|
|
785
|
+
this._menuOpen = false;
|
|
786
|
+
this._closingActionsSubscription = Subscription.EMPTY;
|
|
787
|
+
this._hoverSubscription = Subscription.EMPTY;
|
|
788
|
+
this._menuCloseSubscription = Subscription.EMPTY;
|
|
834
789
|
/**
|
|
835
|
-
*
|
|
790
|
+
* Handles touch start events on the trigger.
|
|
791
|
+
* Needs to be an arrow function so we can easily use addEventListener and removeEventListener.
|
|
792
|
+
*/
|
|
793
|
+
this._handleTouchStart = () => this._openedBy = 'touch';
|
|
794
|
+
// Tracking input type is necessary so it's possible to only auto-focus
|
|
795
|
+
// the first item of the list when the menu is opened via the keyboard
|
|
796
|
+
this._openedBy = null;
|
|
797
|
+
/**
|
|
798
|
+
* Whether focus should be restored when the menu is closed.
|
|
799
|
+
* Note that disabling this option can have accessibility implications
|
|
800
|
+
* and it's up to you to manage focus, if you decide to turn it off.
|
|
801
|
+
*/
|
|
802
|
+
this.restoreFocus = true;
|
|
803
|
+
/** Event emitted when the associated menu is opened. */
|
|
804
|
+
this.menuOpened = new EventEmitter();
|
|
805
|
+
/**
|
|
806
|
+
* Event emitted when the associated menu is opened.
|
|
807
|
+
* @deprecated Switch to `menuOpened` instead
|
|
836
808
|
* @breaking-change 8.0.0
|
|
837
809
|
*/
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
this._destroyMenu();
|
|
853
|
-
// If a click closed the menu, we should close the entire chain of nested menus.
|
|
854
|
-
if ((reason === 'click' || reason === 'tab') && this._parentMenu) {
|
|
855
|
-
this._parentMenu.closed.emit(reason);
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
}
|
|
810
|
+
// tslint:disable-next-line:no-output-on-prefix
|
|
811
|
+
this.onMenuOpen = this.menuOpened;
|
|
812
|
+
/** Event emitted when the associated menu is closed. */
|
|
813
|
+
this.menuClosed = new EventEmitter();
|
|
814
|
+
/**
|
|
815
|
+
* Event emitted when the associated menu is closed.
|
|
816
|
+
* @deprecated Switch to `menuClosed` instead
|
|
817
|
+
* @breaking-change 8.0.0
|
|
818
|
+
*/
|
|
819
|
+
// tslint:disable-next-line:no-output-on-prefix
|
|
820
|
+
this.onMenuClose = this.menuClosed;
|
|
821
|
+
_element.nativeElement.addEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
|
|
822
|
+
if (_menuItemInstance) {
|
|
823
|
+
_menuItemInstance._triggersSubmenu = this.triggersSubmenu();
|
|
859
824
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
825
|
+
this._scrollStrategy = scrollStrategy;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* @deprecated
|
|
829
|
+
* @breaking-change 8.0.0
|
|
830
|
+
*/
|
|
831
|
+
get _deprecatedMatMenuTriggerFor() { return this.menu; }
|
|
832
|
+
set _deprecatedMatMenuTriggerFor(v) {
|
|
833
|
+
this.menu = v;
|
|
834
|
+
}
|
|
835
|
+
/** References the menu instance that the trigger is associated with. */
|
|
836
|
+
get menu() { return this._menu; }
|
|
837
|
+
set menu(menu) {
|
|
838
|
+
if (menu === this._menu) {
|
|
839
|
+
return;
|
|
863
840
|
}
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
841
|
+
this._menu = menu;
|
|
842
|
+
this._menuCloseSubscription.unsubscribe();
|
|
843
|
+
if (menu) {
|
|
844
|
+
this._menuCloseSubscription = menu.close.asObservable().subscribe(reason => {
|
|
845
|
+
this._destroyMenu();
|
|
846
|
+
// If a click closed the menu, we should close the entire chain of nested menus.
|
|
847
|
+
if ((reason === 'click' || reason === 'tab') && this._parentMenu) {
|
|
848
|
+
this._parentMenu.closed.emit(reason);
|
|
849
|
+
}
|
|
850
|
+
});
|
|
873
851
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
852
|
+
}
|
|
853
|
+
ngAfterContentInit() {
|
|
854
|
+
this._checkMenu();
|
|
855
|
+
this._handleHover();
|
|
856
|
+
}
|
|
857
|
+
ngOnDestroy() {
|
|
858
|
+
if (this._overlayRef) {
|
|
859
|
+
this._overlayRef.dispose();
|
|
860
|
+
this._overlayRef = null;
|
|
877
861
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
862
|
+
this._element.nativeElement.removeEventListener('touchstart', this._handleTouchStart, passiveEventListenerOptions);
|
|
863
|
+
this._menuCloseSubscription.unsubscribe();
|
|
864
|
+
this._closingActionsSubscription.unsubscribe();
|
|
865
|
+
this._hoverSubscription.unsubscribe();
|
|
866
|
+
}
|
|
867
|
+
/** Whether the menu is open. */
|
|
868
|
+
get menuOpen() {
|
|
869
|
+
return this._menuOpen;
|
|
870
|
+
}
|
|
871
|
+
/** The text direction of the containing app. */
|
|
872
|
+
get dir() {
|
|
873
|
+
return this._dir && this._dir.value === 'rtl' ? 'rtl' : 'ltr';
|
|
874
|
+
}
|
|
875
|
+
/** Whether the menu triggers a sub-menu or a top-level one. */
|
|
876
|
+
triggersSubmenu() {
|
|
877
|
+
return !!(this._menuItemInstance && this._parentMenu);
|
|
878
|
+
}
|
|
879
|
+
/** Toggles the menu between the open and closed states. */
|
|
880
|
+
toggleMenu() {
|
|
881
|
+
return this._menuOpen ? this.closeMenu() : this.openMenu();
|
|
882
|
+
}
|
|
883
|
+
/** Opens the menu. */
|
|
884
|
+
openMenu() {
|
|
885
|
+
if (this._menuOpen) {
|
|
886
|
+
return;
|
|
881
887
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
888
|
+
this._checkMenu();
|
|
889
|
+
const overlayRef = this._createOverlay();
|
|
890
|
+
const overlayConfig = overlayRef.getConfig();
|
|
891
|
+
this._setPosition(overlayConfig.positionStrategy);
|
|
892
|
+
overlayConfig.hasBackdrop = this.menu.hasBackdrop == null ? !this.triggersSubmenu() :
|
|
893
|
+
this.menu.hasBackdrop;
|
|
894
|
+
overlayRef.attach(this._getPortal());
|
|
895
|
+
if (this.menu.lazyContent) {
|
|
896
|
+
this.menu.lazyContent.attach(this.menuData);
|
|
885
897
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
898
|
+
this._closingActionsSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
|
|
899
|
+
this._initMenu();
|
|
900
|
+
if (this.menu instanceof MatMenu) {
|
|
901
|
+
this.menu._startAnimation();
|
|
889
902
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
if (this.menu.lazyContent) {
|
|
903
|
-
this.menu.lazyContent.attach(this.menuData);
|
|
904
|
-
}
|
|
905
|
-
this._closingActionsSubscription = this._menuClosingActions().subscribe(() => this.closeMenu());
|
|
906
|
-
this._initMenu();
|
|
907
|
-
if (this.menu instanceof MatMenu) {
|
|
908
|
-
this.menu._startAnimation();
|
|
909
|
-
}
|
|
903
|
+
}
|
|
904
|
+
/** Closes the menu. */
|
|
905
|
+
closeMenu() {
|
|
906
|
+
this.menu.close.emit();
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Focuses the menu trigger.
|
|
910
|
+
* @param origin Source of the menu trigger's focus.
|
|
911
|
+
*/
|
|
912
|
+
focus(origin = 'program', options) {
|
|
913
|
+
if (this._focusMonitor) {
|
|
914
|
+
this._focusMonitor.focusVia(this._element, origin, options);
|
|
910
915
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
this.menu.close.emit();
|
|
916
|
+
else {
|
|
917
|
+
this._element.nativeElement.focus(options);
|
|
914
918
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
if (this._focusMonitor) {
|
|
921
|
-
this._focusMonitor.focusVia(this._element, origin, options);
|
|
922
|
-
}
|
|
923
|
-
else {
|
|
924
|
-
this._element.nativeElement.focus(options);
|
|
925
|
-
}
|
|
919
|
+
}
|
|
920
|
+
/** Closes the menu and does the necessary cleanup. */
|
|
921
|
+
_destroyMenu() {
|
|
922
|
+
if (!this._overlayRef || !this.menuOpen) {
|
|
923
|
+
return;
|
|
926
924
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
menu.
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
.subscribe({
|
|
945
|
-
next: () => menu.lazyContent.detach(),
|
|
946
|
-
// No matter whether the content got re-attached, reset the menu.
|
|
947
|
-
complete: () => this._setIsMenuOpen(false)
|
|
948
|
-
});
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
this._setIsMenuOpen(false);
|
|
952
|
-
}
|
|
925
|
+
const menu = this.menu;
|
|
926
|
+
this._closingActionsSubscription.unsubscribe();
|
|
927
|
+
this._overlayRef.detach();
|
|
928
|
+
this._restoreFocus();
|
|
929
|
+
if (menu instanceof MatMenu) {
|
|
930
|
+
menu._resetAnimation();
|
|
931
|
+
if (menu.lazyContent) {
|
|
932
|
+
// Wait for the exit animation to finish before detaching the content.
|
|
933
|
+
menu._animationDone
|
|
934
|
+
.pipe(filter(event => event.toState === 'void'), take(1),
|
|
935
|
+
// Interrupt if the content got re-attached.
|
|
936
|
+
takeUntil(menu.lazyContent._attached))
|
|
937
|
+
.subscribe({
|
|
938
|
+
next: () => menu.lazyContent.detach(),
|
|
939
|
+
// No matter whether the content got re-attached, reset the menu.
|
|
940
|
+
complete: () => this._setIsMenuOpen(false)
|
|
941
|
+
});
|
|
953
942
|
}
|
|
954
943
|
else {
|
|
955
944
|
this._setIsMenuOpen(false);
|
|
956
|
-
if (menu.lazyContent) {
|
|
957
|
-
menu.lazyContent.detach();
|
|
958
|
-
}
|
|
959
945
|
}
|
|
960
946
|
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
_initMenu() {
|
|
966
|
-
this.menu.parentMenu = this.triggersSubmenu() ? this._parentMenu : undefined;
|
|
967
|
-
this.menu.direction = this.dir;
|
|
968
|
-
this._setMenuElevation();
|
|
969
|
-
this._setIsMenuOpen(true);
|
|
970
|
-
this.menu.focusFirstItem(this._openedBy || 'program');
|
|
971
|
-
}
|
|
972
|
-
/** Updates the menu elevation based on the amount of parent menus that it has. */
|
|
973
|
-
_setMenuElevation() {
|
|
974
|
-
if (this.menu.setElevation) {
|
|
975
|
-
let depth = 0;
|
|
976
|
-
let parentMenu = this.menu.parentMenu;
|
|
977
|
-
while (parentMenu) {
|
|
978
|
-
depth++;
|
|
979
|
-
parentMenu = parentMenu.parentMenu;
|
|
980
|
-
}
|
|
981
|
-
this.menu.setElevation(depth);
|
|
947
|
+
else {
|
|
948
|
+
this._setIsMenuOpen(false);
|
|
949
|
+
if (menu.lazyContent) {
|
|
950
|
+
menu.lazyContent.detach();
|
|
982
951
|
}
|
|
983
952
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* This method sets the menu state to open and focuses the first item if
|
|
956
|
+
* the menu was opened via the keyboard.
|
|
957
|
+
*/
|
|
958
|
+
_initMenu() {
|
|
959
|
+
this.menu.parentMenu = this.triggersSubmenu() ? this._parentMenu : undefined;
|
|
960
|
+
this.menu.direction = this.dir;
|
|
961
|
+
this._setMenuElevation();
|
|
962
|
+
this._setIsMenuOpen(true);
|
|
963
|
+
this.menu.focusFirstItem(this._openedBy || 'program');
|
|
964
|
+
}
|
|
965
|
+
/** Updates the menu elevation based on the amount of parent menus that it has. */
|
|
966
|
+
_setMenuElevation() {
|
|
967
|
+
if (this.menu.setElevation) {
|
|
968
|
+
let depth = 0;
|
|
969
|
+
let parentMenu = this.menu.parentMenu;
|
|
970
|
+
while (parentMenu) {
|
|
971
|
+
depth++;
|
|
972
|
+
parentMenu = parentMenu.parentMenu;
|
|
998
973
|
}
|
|
999
|
-
this.
|
|
974
|
+
this.menu.setElevation(depth);
|
|
1000
975
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
976
|
+
}
|
|
977
|
+
/** Restores focus to the element that was focused before the menu was open. */
|
|
978
|
+
_restoreFocus() {
|
|
979
|
+
// We should reset focus if the user is navigating using a keyboard or
|
|
980
|
+
// if we have a top-level trigger which might cause focus to be lost
|
|
981
|
+
// when clicking on the backdrop.
|
|
982
|
+
if (this.restoreFocus) {
|
|
983
|
+
if (!this._openedBy) {
|
|
984
|
+
// Note that the focus style will show up both for `program` and
|
|
985
|
+
// `keyboard` so we don't have to specify which one it is.
|
|
986
|
+
this.focus();
|
|
1007
987
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
* This method checks that a valid instance of MatMenu has been passed into
|
|
1011
|
-
* matMenuTriggerFor. If not, an exception is thrown.
|
|
1012
|
-
*/
|
|
1013
|
-
_checkMenu() {
|
|
1014
|
-
if (!this.menu) {
|
|
1015
|
-
throwMatMenuMissingError();
|
|
988
|
+
else if (!this.triggersSubmenu()) {
|
|
989
|
+
this.focus(this._openedBy);
|
|
1016
990
|
}
|
|
1017
991
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
this._overlayRef = this._overlay.create(config);
|
|
1027
|
-
// Consume the `keydownEvents` in order to prevent them from going to another overlay.
|
|
1028
|
-
// Ideally we'd also have our keyboard event logic in here, however doing so will
|
|
1029
|
-
// break anybody that may have implemented the `MatMenuPanel` themselves.
|
|
1030
|
-
this._overlayRef.keydownEvents().subscribe();
|
|
1031
|
-
}
|
|
1032
|
-
return this._overlayRef;
|
|
992
|
+
this._openedBy = null;
|
|
993
|
+
}
|
|
994
|
+
// set state rather than toggle to support triggers sharing a menu
|
|
995
|
+
_setIsMenuOpen(isOpen) {
|
|
996
|
+
this._menuOpen = isOpen;
|
|
997
|
+
this._menuOpen ? this.menuOpened.emit() : this.menuClosed.emit();
|
|
998
|
+
if (this.triggersSubmenu()) {
|
|
999
|
+
this._menuItemInstance._highlighted = isOpen;
|
|
1033
1000
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* This method checks that a valid instance of MatMenu has been passed into
|
|
1004
|
+
* matMenuTriggerFor. If not, an exception is thrown.
|
|
1005
|
+
*/
|
|
1006
|
+
_checkMenu() {
|
|
1007
|
+
if (!this.menu) {
|
|
1008
|
+
throwMatMenuMissingError();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* This method creates the overlay from the provided menu's template and saves its
|
|
1013
|
+
* OverlayRef so that it can be attached to the DOM when openMenu is called.
|
|
1014
|
+
*/
|
|
1015
|
+
_createOverlay() {
|
|
1016
|
+
if (!this._overlayRef) {
|
|
1017
|
+
const config = this._getOverlayConfig();
|
|
1018
|
+
this._subscribeToPositions(config.positionStrategy);
|
|
1019
|
+
this._overlayRef = this._overlay.create(config);
|
|
1020
|
+
// Consume the `keydownEvents` in order to prevent them from going to another overlay.
|
|
1021
|
+
// Ideally we'd also have our keyboard event logic in here, however doing so will
|
|
1022
|
+
// break anybody that may have implemented the `MatMenuPanel` themselves.
|
|
1023
|
+
this._overlayRef.keydownEvents().subscribe();
|
|
1024
|
+
}
|
|
1025
|
+
return this._overlayRef;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* This method builds the configuration object needed to create the overlay, the OverlayState.
|
|
1029
|
+
* @returns OverlayConfig
|
|
1030
|
+
*/
|
|
1031
|
+
_getOverlayConfig() {
|
|
1032
|
+
return new OverlayConfig({
|
|
1033
|
+
positionStrategy: this._overlay.position()
|
|
1034
|
+
.flexibleConnectedTo(this._element)
|
|
1035
|
+
.withLockedPosition()
|
|
1036
|
+
.withTransformOriginOn('.mat-menu-panel, .mat-mdc-menu-panel'),
|
|
1037
|
+
backdropClass: this.menu.backdropClass || 'cdk-overlay-transparent-backdrop',
|
|
1038
|
+
panelClass: this.menu.overlayPanelClass,
|
|
1039
|
+
scrollStrategy: this._scrollStrategy(),
|
|
1040
|
+
direction: this._dir
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Listens to changes in the position of the overlay and sets the correct classes
|
|
1045
|
+
* on the menu based on the new position. This ensures the animation origin is always
|
|
1046
|
+
* correct, even if a fallback position is used for the overlay.
|
|
1047
|
+
*/
|
|
1048
|
+
_subscribeToPositions(position) {
|
|
1049
|
+
if (this.menu.setPositionClasses) {
|
|
1050
|
+
position.positionChanges.subscribe(change => {
|
|
1051
|
+
const posX = change.connectionPair.overlayX === 'start' ? 'after' : 'before';
|
|
1052
|
+
const posY = change.connectionPair.overlayY === 'top' ? 'below' : 'above';
|
|
1053
|
+
this.menu.setPositionClasses(posX, posY);
|
|
1047
1054
|
});
|
|
1048
1055
|
}
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Sets the appropriate positions on a position strategy
|
|
1059
|
+
* so the overlay connects with the trigger correctly.
|
|
1060
|
+
* @param positionStrategy Strategy whose position to update.
|
|
1061
|
+
*/
|
|
1062
|
+
_setPosition(positionStrategy) {
|
|
1063
|
+
let [originX, originFallbackX] = this.menu.xPosition === 'before' ? ['end', 'start'] : ['start', 'end'];
|
|
1064
|
+
let [overlayY, overlayFallbackY] = this.menu.yPosition === 'above' ? ['bottom', 'top'] : ['top', 'bottom'];
|
|
1065
|
+
let [originY, originFallbackY] = [overlayY, overlayFallbackY];
|
|
1066
|
+
let [overlayX, overlayFallbackX] = [originX, originFallbackX];
|
|
1067
|
+
let offsetY = 0;
|
|
1068
|
+
if (this.triggersSubmenu()) {
|
|
1069
|
+
// When the menu is a sub-menu, it should always align itself
|
|
1070
|
+
// to the edges of the trigger, instead of overlapping it.
|
|
1071
|
+
overlayFallbackX = originX = this.menu.xPosition === 'before' ? 'start' : 'end';
|
|
1072
|
+
originFallbackX = overlayX = originX === 'end' ? 'start' : 'end';
|
|
1073
|
+
offsetY = overlayY === 'bottom' ? MENU_PANEL_TOP_PADDING : -MENU_PANEL_TOP_PADDING;
|
|
1062
1074
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1075
|
+
else if (!this.menu.overlapTrigger) {
|
|
1076
|
+
originY = overlayY === 'top' ? 'bottom' : 'top';
|
|
1077
|
+
originFallbackY = overlayFallbackY === 'top' ? 'bottom' : 'top';
|
|
1078
|
+
}
|
|
1079
|
+
positionStrategy.withPositions([
|
|
1080
|
+
{ originX, originY, overlayX, overlayY, offsetY },
|
|
1081
|
+
{ originX: originFallbackX, originY, overlayX: overlayFallbackX, overlayY, offsetY },
|
|
1082
|
+
{
|
|
1083
|
+
originX,
|
|
1084
|
+
originY: originFallbackY,
|
|
1085
|
+
overlayX,
|
|
1086
|
+
overlayY: overlayFallbackY,
|
|
1087
|
+
offsetY: -offsetY
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
originX: originFallbackX,
|
|
1091
|
+
originY: originFallbackY,
|
|
1092
|
+
overlayX: overlayFallbackX,
|
|
1093
|
+
overlayY: overlayFallbackY,
|
|
1094
|
+
offsetY: -offsetY
|
|
1080
1095
|
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1096
|
+
]);
|
|
1097
|
+
}
|
|
1098
|
+
/** Returns a stream that emits whenever an action that should close the menu occurs. */
|
|
1099
|
+
_menuClosingActions() {
|
|
1100
|
+
const backdrop = this._overlayRef.backdropClick();
|
|
1101
|
+
const detachments = this._overlayRef.detachments();
|
|
1102
|
+
const parentClose = this._parentMenu ? this._parentMenu.closed : of();
|
|
1103
|
+
const hover = this._parentMenu ? this._parentMenu._hovered().pipe(filter(active => active !== this._menuItemInstance), filter(() => this._menuOpen)) : of();
|
|
1104
|
+
return merge(backdrop, parentClose, hover, detachments);
|
|
1105
|
+
}
|
|
1106
|
+
/** Handles mouse presses on the trigger. */
|
|
1107
|
+
_handleMousedown(event) {
|
|
1108
|
+
if (!isFakeMousedownFromScreenReader(event)) {
|
|
1109
|
+
// Since right or middle button clicks won't trigger the `click` event,
|
|
1110
|
+
// we shouldn't consider the menu as opened by mouse in those cases.
|
|
1111
|
+
this._openedBy = event.button === 0 ? 'mouse' : null;
|
|
1112
|
+
// Since clicking on the trigger won't close the menu if it opens a sub-menu,
|
|
1113
|
+
// we should prevent focus from moving onto it via click to avoid the
|
|
1114
|
+
// highlight from lingering on the menu item.
|
|
1115
|
+
if (this.triggersSubmenu()) {
|
|
1116
|
+
event.preventDefault();
|
|
1084
1117
|
}
|
|
1085
|
-
positionStrategy.withPositions([
|
|
1086
|
-
{ originX, originY, overlayX, overlayY, offsetY },
|
|
1087
|
-
{ originX: originFallbackX, originY, overlayX: overlayFallbackX, overlayY, offsetY },
|
|
1088
|
-
{
|
|
1089
|
-
originX,
|
|
1090
|
-
originY: originFallbackY,
|
|
1091
|
-
overlayX,
|
|
1092
|
-
overlayY: overlayFallbackY,
|
|
1093
|
-
offsetY: -offsetY
|
|
1094
|
-
},
|
|
1095
|
-
{
|
|
1096
|
-
originX: originFallbackX,
|
|
1097
|
-
originY: originFallbackY,
|
|
1098
|
-
overlayX: overlayFallbackX,
|
|
1099
|
-
overlayY: overlayFallbackY,
|
|
1100
|
-
offsetY: -offsetY
|
|
1101
|
-
}
|
|
1102
|
-
]);
|
|
1103
1118
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1119
|
+
}
|
|
1120
|
+
/** Handles key presses on the trigger. */
|
|
1121
|
+
_handleKeydown(event) {
|
|
1122
|
+
const keyCode = event.keyCode;
|
|
1123
|
+
if (this.triggersSubmenu() && ((keyCode === RIGHT_ARROW && this.dir === 'ltr') ||
|
|
1124
|
+
(keyCode === LEFT_ARROW && this.dir === 'rtl'))) {
|
|
1125
|
+
this.openMenu();
|
|
1111
1126
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
// we should prevent focus from moving onto it via click to avoid the
|
|
1120
|
-
// highlight from lingering on the menu item.
|
|
1121
|
-
if (this.triggersSubmenu()) {
|
|
1122
|
-
event.preventDefault();
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1127
|
+
}
|
|
1128
|
+
/** Handles click events on the trigger. */
|
|
1129
|
+
_handleClick(event) {
|
|
1130
|
+
if (this.triggersSubmenu()) {
|
|
1131
|
+
// Stop event propagation to avoid closing the parent menu.
|
|
1132
|
+
event.stopPropagation();
|
|
1133
|
+
this.openMenu();
|
|
1125
1134
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
const keyCode = event.keyCode;
|
|
1129
|
-
if (this.triggersSubmenu() && ((keyCode === RIGHT_ARROW && this.dir === 'ltr') ||
|
|
1130
|
-
(keyCode === LEFT_ARROW && this.dir === 'rtl'))) {
|
|
1131
|
-
this.openMenu();
|
|
1132
|
-
}
|
|
1135
|
+
else {
|
|
1136
|
+
this.toggleMenu();
|
|
1133
1137
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
}
|
|
1141
|
-
else {
|
|
1142
|
-
this.toggleMenu();
|
|
1143
|
-
}
|
|
1138
|
+
}
|
|
1139
|
+
/** Handles the cases where the user hovers over the trigger. */
|
|
1140
|
+
_handleHover() {
|
|
1141
|
+
// Subscribe to changes in the hovered item in order to toggle the panel.
|
|
1142
|
+
if (!this.triggersSubmenu()) {
|
|
1143
|
+
return;
|
|
1144
1144
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
//
|
|
1148
|
-
|
|
1149
|
-
|
|
1145
|
+
this._hoverSubscription = this._parentMenu._hovered()
|
|
1146
|
+
// Since we might have multiple competing triggers for the same menu (e.g. a sub-menu
|
|
1147
|
+
// with different data and triggers), we have to delay it by a tick to ensure that
|
|
1148
|
+
// it won't be closed immediately after it is opened.
|
|
1149
|
+
.pipe(filter(active => active === this._menuItemInstance && !active.disabled), delay(0, asapScheduler))
|
|
1150
|
+
.subscribe(() => {
|
|
1151
|
+
this._openedBy = 'mouse';
|
|
1152
|
+
// If the same menu is used between multiple triggers, it might still be animating
|
|
1153
|
+
// while the new trigger tries to re-open it. Wait for the animation to finish
|
|
1154
|
+
// before doing so. Also interrupt if the user moves to another item.
|
|
1155
|
+
if (this.menu instanceof MatMenu && this.menu._isAnimating) {
|
|
1156
|
+
// We need the `delay(0)` here in order to avoid
|
|
1157
|
+
// 'changed after checked' errors in some cases. See #12194.
|
|
1158
|
+
this.menu._animationDone
|
|
1159
|
+
.pipe(take(1), delay(0, asapScheduler), takeUntil(this._parentMenu._hovered()))
|
|
1160
|
+
.subscribe(() => this.openMenu());
|
|
1150
1161
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
// with different data and triggers), we have to delay it by a tick to ensure that
|
|
1154
|
-
// it won't be closed immediately after it is opened.
|
|
1155
|
-
.pipe(filter(active => active === this._menuItemInstance && !active.disabled), delay(0, asapScheduler))
|
|
1156
|
-
.subscribe(() => {
|
|
1157
|
-
this._openedBy = 'mouse';
|
|
1158
|
-
// If the same menu is used between multiple triggers, it might still be animating
|
|
1159
|
-
// while the new trigger tries to re-open it. Wait for the animation to finish
|
|
1160
|
-
// before doing so. Also interrupt if the user moves to another item.
|
|
1161
|
-
if (this.menu instanceof MatMenu && this.menu._isAnimating) {
|
|
1162
|
-
// We need the `delay(0)` here in order to avoid
|
|
1163
|
-
// 'changed after checked' errors in some cases. See #12194.
|
|
1164
|
-
this.menu._animationDone
|
|
1165
|
-
.pipe(take(1), delay(0, asapScheduler), takeUntil(this._parentMenu._hovered()))
|
|
1166
|
-
.subscribe(() => this.openMenu());
|
|
1167
|
-
}
|
|
1168
|
-
else {
|
|
1169
|
-
this.openMenu();
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
/** Gets the portal that should be attached to the overlay. */
|
|
1174
|
-
_getPortal() {
|
|
1175
|
-
// Note that we can avoid this check by keeping the portal on the menu panel.
|
|
1176
|
-
// While it would be cleaner, we'd have to introduce another required method on
|
|
1177
|
-
// `MatMenuPanel`, making it harder to consume.
|
|
1178
|
-
if (!this._portal || this._portal.templateRef !== this.menu.templateRef) {
|
|
1179
|
-
this._portal = new TemplatePortal(this.menu.templateRef, this._viewContainerRef);
|
|
1162
|
+
else {
|
|
1163
|
+
this.openMenu();
|
|
1180
1164
|
}
|
|
1181
|
-
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
/** Gets the portal that should be attached to the overlay. */
|
|
1168
|
+
_getPortal() {
|
|
1169
|
+
// Note that we can avoid this check by keeping the portal on the menu panel.
|
|
1170
|
+
// While it would be cleaner, we'd have to introduce another required method on
|
|
1171
|
+
// `MatMenuPanel`, making it harder to consume.
|
|
1172
|
+
if (!this._portal || this._portal.templateRef !== this.menu.templateRef) {
|
|
1173
|
+
this._portal = new TemplatePortal(this.menu.templateRef, this._viewContainerRef);
|
|
1182
1174
|
}
|
|
1175
|
+
return this._portal;
|
|
1183
1176
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
})();
|
|
1177
|
+
}
|
|
1178
|
+
MatMenuTrigger.decorators = [
|
|
1179
|
+
{ type: Directive, args: [{
|
|
1180
|
+
selector: `[mat-menu-trigger-for], [matMenuTriggerFor]`,
|
|
1181
|
+
host: {
|
|
1182
|
+
'class': 'mat-menu-trigger',
|
|
1183
|
+
'aria-haspopup': 'true',
|
|
1184
|
+
'[attr.aria-expanded]': 'menuOpen || null',
|
|
1185
|
+
'[attr.aria-controls]': 'menuOpen ? menu.panelId : null',
|
|
1186
|
+
'(mousedown)': '_handleMousedown($event)',
|
|
1187
|
+
'(keydown)': '_handleKeydown($event)',
|
|
1188
|
+
'(click)': '_handleClick($event)',
|
|
1189
|
+
},
|
|
1190
|
+
exportAs: 'matMenuTrigger'
|
|
1191
|
+
},] }
|
|
1192
|
+
];
|
|
1193
|
+
MatMenuTrigger.ctorParameters = () => [
|
|
1194
|
+
{ type: Overlay },
|
|
1195
|
+
{ type: ElementRef },
|
|
1196
|
+
{ type: ViewContainerRef },
|
|
1197
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_MENU_SCROLL_STRATEGY,] }] },
|
|
1198
|
+
{ type: MatMenu, decorators: [{ type: Optional }] },
|
|
1199
|
+
{ type: MatMenuItem, decorators: [{ type: Optional }, { type: Self }] },
|
|
1200
|
+
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
1201
|
+
{ type: FocusMonitor }
|
|
1202
|
+
];
|
|
1203
|
+
MatMenuTrigger.propDecorators = {
|
|
1204
|
+
_deprecatedMatMenuTriggerFor: [{ type: Input, args: ['mat-menu-trigger-for',] }],
|
|
1205
|
+
menu: [{ type: Input, args: ['matMenuTriggerFor',] }],
|
|
1206
|
+
menuData: [{ type: Input, args: ['matMenuTriggerData',] }],
|
|
1207
|
+
restoreFocus: [{ type: Input, args: ['matMenuTriggerRestoreFocus',] }],
|
|
1208
|
+
menuOpened: [{ type: Output }],
|
|
1209
|
+
onMenuOpen: [{ type: Output }],
|
|
1210
|
+
menuClosed: [{ type: Output }],
|
|
1211
|
+
onMenuClose: [{ type: Output }]
|
|
1212
|
+
};
|
|
1221
1213
|
|
|
1222
1214
|
/**
|
|
1223
1215
|
* @license
|
|
@@ -1230,40 +1222,34 @@ let MatMenuTrigger = /** @class */ (() => {
|
|
|
1230
1222
|
* Used by both the current `MatMenuModule` and the MDC `MatMenuModule`
|
|
1231
1223
|
* to declare the menu-related directives.
|
|
1232
1224
|
*/
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
declarations: [_MatMenu, MatMenuItem],
|
|
1262
|
-
providers: [MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER]
|
|
1263
|
-
},] }
|
|
1264
|
-
];
|
|
1265
|
-
return MatMenuModule;
|
|
1266
|
-
})();
|
|
1225
|
+
class _MatMenuDirectivesModule {
|
|
1226
|
+
}
|
|
1227
|
+
_MatMenuDirectivesModule.decorators = [
|
|
1228
|
+
{ type: NgModule, args: [{
|
|
1229
|
+
exports: [MatMenuTrigger, MatMenuContent, MatCommonModule],
|
|
1230
|
+
declarations: [
|
|
1231
|
+
MatMenuTrigger,
|
|
1232
|
+
MatMenuContent,
|
|
1233
|
+
],
|
|
1234
|
+
providers: [MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER]
|
|
1235
|
+
},] }
|
|
1236
|
+
];
|
|
1237
|
+
class MatMenuModule {
|
|
1238
|
+
}
|
|
1239
|
+
MatMenuModule.decorators = [
|
|
1240
|
+
{ type: NgModule, args: [{
|
|
1241
|
+
imports: [
|
|
1242
|
+
CommonModule,
|
|
1243
|
+
MatCommonModule,
|
|
1244
|
+
MatRippleModule,
|
|
1245
|
+
OverlayModule,
|
|
1246
|
+
_MatMenuDirectivesModule,
|
|
1247
|
+
],
|
|
1248
|
+
exports: [CdkScrollableModule, MatCommonModule, _MatMenu, MatMenuItem, _MatMenuDirectivesModule],
|
|
1249
|
+
declarations: [_MatMenu, MatMenuItem],
|
|
1250
|
+
providers: [MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER]
|
|
1251
|
+
},] }
|
|
1252
|
+
];
|
|
1267
1253
|
|
|
1268
1254
|
/**
|
|
1269
1255
|
* @license
|
|
@@ -1285,5 +1271,5 @@ let MatMenuModule = /** @class */ (() => {
|
|
|
1285
1271
|
* Generated bundle index. Do not edit.
|
|
1286
1272
|
*/
|
|
1287
1273
|
|
|
1288
|
-
export { MAT_MENU_DEFAULT_OPTIONS, MAT_MENU_PANEL, MAT_MENU_SCROLL_STRATEGY, MatMenu, MatMenuContent, MatMenuItem, MatMenuModule, MatMenuTrigger, _MatMenu, _MatMenuBase, _MatMenuDirectivesModule, fadeInItems, matMenuAnimations, transformMenu, MAT_MENU_DEFAULT_OPTIONS_FACTORY as ɵangular_material_src_material_menu_menu_a, MAT_MENU_SCROLL_STRATEGY_FACTORY as ɵangular_material_src_material_menu_menu_b, MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER as ɵangular_material_src_material_menu_menu_c };
|
|
1274
|
+
export { MAT_MENU_CONTENT, MAT_MENU_DEFAULT_OPTIONS, MAT_MENU_PANEL, MAT_MENU_SCROLL_STRATEGY, MatMenu, MatMenuContent, MatMenuItem, MatMenuModule, MatMenuTrigger, _MatMenu, _MatMenuBase, _MatMenuDirectivesModule, fadeInItems, matMenuAnimations, transformMenu, MAT_MENU_DEFAULT_OPTIONS_FACTORY as ɵangular_material_src_material_menu_menu_a, MAT_MENU_SCROLL_STRATEGY_FACTORY as ɵangular_material_src_material_menu_menu_b, MAT_MENU_SCROLL_STRATEGY_FACTORY_PROVIDER as ɵangular_material_src_material_menu_menu_c };
|
|
1289
1275
|
//# sourceMappingURL=menu.js.map
|