@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/autocomplete.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActiveDescendantKeyManager } from '@angular/cdk/a11y';
|
|
2
2
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
3
3
|
import { InjectionToken, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, Inject, ViewChild, TemplateRef, ContentChildren, Input, Output, Directive, forwardRef, ViewContainerRef, NgZone, Optional, Host, NgModule } from '@angular/core';
|
|
4
|
-
import { mixinDisableRipple, MAT_OPTION_PARENT_COMPONENT, MatOption,
|
|
4
|
+
import { mixinDisableRipple, MAT_OPTION_PARENT_COMPONENT, MatOption, MAT_OPTGROUP, MatOptionSelectionChange, _countGroupLabelsBeforeOption, _getOptionScrollPosition, MatOptionModule, MatCommonModule } from '@angular/material/core';
|
|
5
5
|
import { Subscription, Subject, defer, merge, of, fromEvent } from 'rxjs';
|
|
6
6
|
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
7
7
|
import { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
|
|
@@ -51,137 +51,134 @@ const MAT_AUTOCOMPLETE_DEFAULT_OPTIONS = new InjectionToken('mat-autocomplete-de
|
|
|
51
51
|
function MAT_AUTOCOMPLETE_DEFAULT_OPTIONS_FACTORY() {
|
|
52
52
|
return { autoActiveFirstOption: false };
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
class MatAutocomplete extends _MatAutocompleteMixinBase {
|
|
55
|
+
constructor(_changeDetectorRef, _elementRef, defaults) {
|
|
56
|
+
super();
|
|
57
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
58
|
+
this._elementRef = _elementRef;
|
|
59
|
+
this._activeOptionChanges = Subscription.EMPTY;
|
|
60
|
+
/** Whether the autocomplete panel should be visible, depending on option length. */
|
|
61
|
+
this.showPanel = false;
|
|
62
|
+
this._isOpen = false;
|
|
63
|
+
/** Function that maps an option's control value to its display value in the trigger. */
|
|
64
|
+
this.displayWith = null;
|
|
65
|
+
/** Event that is emitted whenever an option from the list is selected. */
|
|
66
|
+
this.optionSelected = new EventEmitter();
|
|
67
|
+
/** Event that is emitted when the autocomplete panel is opened. */
|
|
68
|
+
this.opened = new EventEmitter();
|
|
69
|
+
/** Event that is emitted when the autocomplete panel is closed. */
|
|
70
|
+
this.closed = new EventEmitter();
|
|
71
|
+
/** Emits whenever an option is activated using the keyboard. */
|
|
72
|
+
this.optionActivated = new EventEmitter();
|
|
73
|
+
this._classList = {};
|
|
74
|
+
/** Unique ID to be used by autocomplete trigger's "aria-owns" property. */
|
|
75
|
+
this.id = `mat-autocomplete-${_uniqueAutocompleteIdCounter++}`;
|
|
76
|
+
this._autoActiveFirstOption = !!defaults.autoActiveFirstOption;
|
|
77
|
+
}
|
|
78
|
+
/** Whether the autocomplete panel is open. */
|
|
79
|
+
get isOpen() { return this._isOpen && this.showPanel; }
|
|
80
|
+
/**
|
|
81
|
+
* Whether the first option should be highlighted when the autocomplete panel is opened.
|
|
82
|
+
* Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.
|
|
83
|
+
*/
|
|
84
|
+
get autoActiveFirstOption() { return this._autoActiveFirstOption; }
|
|
85
|
+
set autoActiveFirstOption(value) {
|
|
86
|
+
this._autoActiveFirstOption = coerceBooleanProperty(value);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Takes classes set on the host mat-autocomplete element and applies them to the panel
|
|
90
|
+
* inside the overlay container to allow for easy styling.
|
|
91
|
+
*/
|
|
92
|
+
set classList(value) {
|
|
93
|
+
if (value && value.length) {
|
|
94
|
+
this._classList = value.split(' ').reduce((classList, className) => {
|
|
95
|
+
classList[className.trim()] = true;
|
|
96
|
+
return classList;
|
|
97
|
+
}, {});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
74
100
|
this._classList = {};
|
|
75
|
-
/** Unique ID to be used by autocomplete trigger's "aria-owns" property. */
|
|
76
|
-
this.id = `mat-autocomplete-${_uniqueAutocompleteIdCounter++}`;
|
|
77
|
-
this._autoActiveFirstOption = !!defaults.autoActiveFirstOption;
|
|
78
|
-
}
|
|
79
|
-
/** Whether the autocomplete panel is open. */
|
|
80
|
-
get isOpen() { return this._isOpen && this.showPanel; }
|
|
81
|
-
/**
|
|
82
|
-
* Whether the first option should be highlighted when the autocomplete panel is opened.
|
|
83
|
-
* Can be configured globally through the `MAT_AUTOCOMPLETE_DEFAULT_OPTIONS` token.
|
|
84
|
-
*/
|
|
85
|
-
get autoActiveFirstOption() { return this._autoActiveFirstOption; }
|
|
86
|
-
set autoActiveFirstOption(value) {
|
|
87
|
-
this._autoActiveFirstOption = coerceBooleanProperty(value);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Takes classes set on the host mat-autocomplete element and applies them to the panel
|
|
91
|
-
* inside the overlay container to allow for easy styling.
|
|
92
|
-
*/
|
|
93
|
-
set classList(value) {
|
|
94
|
-
if (value && value.length) {
|
|
95
|
-
this._classList = value.split(' ').reduce((classList, className) => {
|
|
96
|
-
classList[className.trim()] = true;
|
|
97
|
-
return classList;
|
|
98
|
-
}, {});
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
this._classList = {};
|
|
102
|
-
}
|
|
103
|
-
this._setVisibilityClasses(this._classList);
|
|
104
|
-
this._elementRef.nativeElement.className = '';
|
|
105
|
-
}
|
|
106
|
-
ngAfterContentInit() {
|
|
107
|
-
this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap();
|
|
108
|
-
this._activeOptionChanges = this._keyManager.change.subscribe(index => {
|
|
109
|
-
this.optionActivated.emit({ source: this, option: this.options.toArray()[index] || null });
|
|
110
|
-
});
|
|
111
|
-
// Set the initial visibility state.
|
|
112
|
-
this._setVisibility();
|
|
113
101
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
this._setVisibilityClasses(this._classList);
|
|
103
|
+
this._elementRef.nativeElement.className = '';
|
|
104
|
+
}
|
|
105
|
+
ngAfterContentInit() {
|
|
106
|
+
this._keyManager = new ActiveDescendantKeyManager(this.options).withWrap();
|
|
107
|
+
this._activeOptionChanges = this._keyManager.change.subscribe(index => {
|
|
108
|
+
this.optionActivated.emit({ source: this, option: this.options.toArray()[index] || null });
|
|
109
|
+
});
|
|
110
|
+
// Set the initial visibility state.
|
|
111
|
+
this._setVisibility();
|
|
112
|
+
}
|
|
113
|
+
ngOnDestroy() {
|
|
114
|
+
this._activeOptionChanges.unsubscribe();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Sets the panel scrollTop. This allows us to manually scroll to display options
|
|
118
|
+
* above or below the fold, as they are not actually being focused when active.
|
|
119
|
+
*/
|
|
120
|
+
_setScrollTop(scrollTop) {
|
|
121
|
+
if (this.panel) {
|
|
122
|
+
this.panel.nativeElement.scrollTop = scrollTop;
|
|
125
123
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
]
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
})();
|
|
124
|
+
}
|
|
125
|
+
/** Returns the panel's scrollTop. */
|
|
126
|
+
_getScrollTop() {
|
|
127
|
+
return this.panel ? this.panel.nativeElement.scrollTop : 0;
|
|
128
|
+
}
|
|
129
|
+
/** Panel should hide itself when the option list is empty. */
|
|
130
|
+
_setVisibility() {
|
|
131
|
+
this.showPanel = !!this.options.length;
|
|
132
|
+
this._setVisibilityClasses(this._classList);
|
|
133
|
+
this._changeDetectorRef.markForCheck();
|
|
134
|
+
}
|
|
135
|
+
/** Emits the `select` event. */
|
|
136
|
+
_emitSelectEvent(option) {
|
|
137
|
+
const event = new MatAutocompleteSelectedEvent(this, option);
|
|
138
|
+
this.optionSelected.emit(event);
|
|
139
|
+
}
|
|
140
|
+
/** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
|
|
141
|
+
_setVisibilityClasses(classList) {
|
|
142
|
+
classList['mat-autocomplete-visible'] = this.showPanel;
|
|
143
|
+
classList['mat-autocomplete-hidden'] = !this.showPanel;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
MatAutocomplete.decorators = [
|
|
147
|
+
{ type: Component, args: [{
|
|
148
|
+
selector: 'mat-autocomplete',
|
|
149
|
+
template: "<ng-template>\n <div class=\"mat-autocomplete-panel\" role=\"listbox\" [id]=\"id\" [ngClass]=\"_classList\" #panel>\n <ng-content></ng-content>\n </div>\n</ng-template>\n",
|
|
150
|
+
encapsulation: ViewEncapsulation.None,
|
|
151
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
152
|
+
exportAs: 'matAutocomplete',
|
|
153
|
+
inputs: ['disableRipple'],
|
|
154
|
+
host: {
|
|
155
|
+
'class': 'mat-autocomplete'
|
|
156
|
+
},
|
|
157
|
+
providers: [
|
|
158
|
+
{ provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }
|
|
159
|
+
],
|
|
160
|
+
styles: [".mat-autocomplete-panel{min-width:112px;max-width:280px;overflow:auto;-webkit-overflow-scrolling:touch;visibility:hidden;max-width:none;max-height:256px;position:relative;width:100%;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.mat-autocomplete-panel.mat-autocomplete-visible{visibility:visible}.mat-autocomplete-panel.mat-autocomplete-hidden{visibility:hidden}.mat-autocomplete-panel-above .mat-autocomplete-panel{border-radius:0;border-top-left-radius:4px;border-top-right-radius:4px}.mat-autocomplete-panel .mat-divider-horizontal{margin-top:-1px}.cdk-high-contrast-active .mat-autocomplete-panel{outline:solid 1px}\n"]
|
|
161
|
+
},] }
|
|
162
|
+
];
|
|
163
|
+
MatAutocomplete.ctorParameters = () => [
|
|
164
|
+
{ type: ChangeDetectorRef },
|
|
165
|
+
{ type: ElementRef },
|
|
166
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_AUTOCOMPLETE_DEFAULT_OPTIONS,] }] }
|
|
167
|
+
];
|
|
168
|
+
MatAutocomplete.propDecorators = {
|
|
169
|
+
template: [{ type: ViewChild, args: [TemplateRef, { static: true },] }],
|
|
170
|
+
panel: [{ type: ViewChild, args: ['panel',] }],
|
|
171
|
+
options: [{ type: ContentChildren, args: [MatOption, { descendants: true },] }],
|
|
172
|
+
optionGroups: [{ type: ContentChildren, args: [MAT_OPTGROUP, { descendants: true },] }],
|
|
173
|
+
displayWith: [{ type: Input }],
|
|
174
|
+
autoActiveFirstOption: [{ type: Input }],
|
|
175
|
+
panelWidth: [{ type: Input }],
|
|
176
|
+
optionSelected: [{ type: Output }],
|
|
177
|
+
opened: [{ type: Output }],
|
|
178
|
+
closed: [{ type: Output }],
|
|
179
|
+
optionActivated: [{ type: Output }],
|
|
180
|
+
classList: [{ type: Input, args: ['class',] }]
|
|
181
|
+
};
|
|
185
182
|
|
|
186
183
|
/**
|
|
187
184
|
* @license
|
|
@@ -194,25 +191,22 @@ let MatAutocomplete = /** @class */ (() => {
|
|
|
194
191
|
* Directive applied to an element to make it usable
|
|
195
192
|
* as a connection point for an autocomplete panel.
|
|
196
193
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
elementRef
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
];
|
|
214
|
-
return MatAutocompleteOrigin;
|
|
215
|
-
})();
|
|
194
|
+
class MatAutocompleteOrigin {
|
|
195
|
+
constructor(
|
|
196
|
+
/** Reference to the element on which the directive is applied. */
|
|
197
|
+
elementRef) {
|
|
198
|
+
this.elementRef = elementRef;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
MatAutocompleteOrigin.decorators = [
|
|
202
|
+
{ type: Directive, args: [{
|
|
203
|
+
selector: '[matAutocompleteOrigin]',
|
|
204
|
+
exportAs: 'matAutocompleteOrigin',
|
|
205
|
+
},] }
|
|
206
|
+
];
|
|
207
|
+
MatAutocompleteOrigin.ctorParameters = () => [
|
|
208
|
+
{ type: ElementRef }
|
|
209
|
+
];
|
|
216
210
|
|
|
217
211
|
/**
|
|
218
212
|
* @license
|
|
@@ -260,560 +254,559 @@ function getMatAutocompleteMissingPanelError() {
|
|
|
260
254
|
'Make sure that the id passed to the `matAutocomplete` is correct and that ' +
|
|
261
255
|
'you\'re attempting to open it after the ngAfterContentInit hook.');
|
|
262
256
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
this._viewportSubscription = Subscription.EMPTY;
|
|
281
|
-
/**
|
|
282
|
-
* Whether the autocomplete can open the next time it is focused. Used to prevent a focused,
|
|
283
|
-
* closed autocomplete from being reopened if the user switches to another browser tab and then
|
|
284
|
-
* comes back.
|
|
285
|
-
*/
|
|
286
|
-
this._canOpenOnNextFocus = true;
|
|
287
|
-
/** Stream of keyboard events that can close the panel. */
|
|
288
|
-
this._closeKeyEventStream = new Subject();
|
|
289
|
-
/**
|
|
290
|
-
* Event handler for when the window is blurred. Needs to be an
|
|
291
|
-
* arrow function in order to preserve the context.
|
|
292
|
-
*/
|
|
293
|
-
this._windowBlurHandler = () => {
|
|
294
|
-
// If the user blurred the window while the autocomplete is focused, it means that it'll be
|
|
295
|
-
// refocused when they come back. In this case we want to skip the first focus event, if the
|
|
296
|
-
// pane was closed, in order to avoid reopening it unintentionally.
|
|
297
|
-
this._canOpenOnNextFocus =
|
|
298
|
-
this._document.activeElement !== this._element.nativeElement || this.panelOpen;
|
|
299
|
-
};
|
|
300
|
-
/** `View -> model callback called when value changes` */
|
|
301
|
-
this._onChange = () => { };
|
|
302
|
-
/** `View -> model callback called when autocomplete has been touched` */
|
|
303
|
-
this._onTouched = () => { };
|
|
304
|
-
/**
|
|
305
|
-
* Position of the autocomplete panel relative to the trigger element. A position of `auto`
|
|
306
|
-
* will render the panel underneath the trigger if there is enough space for it to fit in
|
|
307
|
-
* the viewport, otherwise the panel will be shown above it. If the position is set to
|
|
308
|
-
* `above` or `below`, the panel will always be shown above or below the trigger. no matter
|
|
309
|
-
* whether it fits completely in the viewport.
|
|
310
|
-
*/
|
|
311
|
-
this.position = 'auto';
|
|
312
|
-
/**
|
|
313
|
-
* `autocomplete` attribute to be set on the input element.
|
|
314
|
-
* @docs-private
|
|
315
|
-
*/
|
|
316
|
-
this.autocompleteAttribute = 'off';
|
|
317
|
-
this._overlayAttached = false;
|
|
318
|
-
/** Stream of autocomplete option selections. */
|
|
319
|
-
this.optionSelections = defer(() => {
|
|
320
|
-
if (this.autocomplete && this.autocomplete.options) {
|
|
321
|
-
return merge(...this.autocomplete.options.map(option => option.onSelectionChange));
|
|
322
|
-
}
|
|
323
|
-
// If there are any subscribers before `ngAfterViewInit`, the `autocomplete` will be undefined.
|
|
324
|
-
// Return a stream that we'll replace with the real one once everything is in place.
|
|
325
|
-
return this._zone.onStable
|
|
326
|
-
.asObservable()
|
|
327
|
-
.pipe(take(1), switchMap(() => this.optionSelections));
|
|
328
|
-
});
|
|
329
|
-
this._scrollStrategy = scrollStrategy;
|
|
330
|
-
}
|
|
257
|
+
class MatAutocompleteTrigger {
|
|
258
|
+
constructor(_element, _overlay, _viewContainerRef, _zone, _changeDetectorRef, scrollStrategy, _dir, _formField, _document, _viewportRuler) {
|
|
259
|
+
this._element = _element;
|
|
260
|
+
this._overlay = _overlay;
|
|
261
|
+
this._viewContainerRef = _viewContainerRef;
|
|
262
|
+
this._zone = _zone;
|
|
263
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
264
|
+
this._dir = _dir;
|
|
265
|
+
this._formField = _formField;
|
|
266
|
+
this._document = _document;
|
|
267
|
+
this._viewportRuler = _viewportRuler;
|
|
268
|
+
this._componentDestroyed = false;
|
|
269
|
+
this._autocompleteDisabled = false;
|
|
270
|
+
/** Whether or not the label state is being overridden. */
|
|
271
|
+
this._manuallyFloatingLabel = false;
|
|
272
|
+
/** Subscription to viewport size changes. */
|
|
273
|
+
this._viewportSubscription = Subscription.EMPTY;
|
|
331
274
|
/**
|
|
332
|
-
* Whether the autocomplete is
|
|
333
|
-
*
|
|
275
|
+
* Whether the autocomplete can open the next time it is focused. Used to prevent a focused,
|
|
276
|
+
* closed autocomplete from being reopened if the user switches to another browser tab and then
|
|
277
|
+
* comes back.
|
|
334
278
|
*/
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
279
|
+
this._canOpenOnNextFocus = true;
|
|
280
|
+
/** Stream of keyboard events that can close the panel. */
|
|
281
|
+
this._closeKeyEventStream = new Subject();
|
|
282
|
+
/**
|
|
283
|
+
* Event handler for when the window is blurred. Needs to be an
|
|
284
|
+
* arrow function in order to preserve the context.
|
|
285
|
+
*/
|
|
286
|
+
this._windowBlurHandler = () => {
|
|
287
|
+
// If the user blurred the window while the autocomplete is focused, it means that it'll be
|
|
288
|
+
// refocused when they come back. In this case we want to skip the first focus event, if the
|
|
289
|
+
// pane was closed, in order to avoid reopening it unintentionally.
|
|
290
|
+
this._canOpenOnNextFocus =
|
|
291
|
+
this._document.activeElement !== this._element.nativeElement || this.panelOpen;
|
|
292
|
+
};
|
|
293
|
+
/** `View -> model callback called when value changes` */
|
|
294
|
+
this._onChange = () => { };
|
|
295
|
+
/** `View -> model callback called when autocomplete has been touched` */
|
|
296
|
+
this._onTouched = () => { };
|
|
297
|
+
/**
|
|
298
|
+
* Position of the autocomplete panel relative to the trigger element. A position of `auto`
|
|
299
|
+
* will render the panel underneath the trigger if there is enough space for it to fit in
|
|
300
|
+
* the viewport, otherwise the panel will be shown above it. If the position is set to
|
|
301
|
+
* `above` or `below`, the panel will always be shown above or below the trigger. no matter
|
|
302
|
+
* whether it fits completely in the viewport.
|
|
303
|
+
*/
|
|
304
|
+
this.position = 'auto';
|
|
305
|
+
/**
|
|
306
|
+
* `autocomplete` attribute to be set on the input element.
|
|
307
|
+
* @docs-private
|
|
308
|
+
*/
|
|
309
|
+
this.autocompleteAttribute = 'off';
|
|
310
|
+
this._overlayAttached = false;
|
|
311
|
+
/** Stream of autocomplete option selections. */
|
|
312
|
+
this.optionSelections = defer(() => {
|
|
313
|
+
if (this.autocomplete && this.autocomplete.options) {
|
|
314
|
+
return merge(...this.autocomplete.options.map(option => option.onSelectionChange));
|
|
315
|
+
}
|
|
316
|
+
// If there are any subscribers before `ngAfterViewInit`, the `autocomplete` will be undefined.
|
|
317
|
+
// Return a stream that we'll replace with the real one once everything is in place.
|
|
318
|
+
return this._zone.onStable
|
|
319
|
+
.asObservable()
|
|
320
|
+
.pipe(take(1), switchMap(() => this.optionSelections));
|
|
321
|
+
});
|
|
322
|
+
this._scrollStrategy = scrollStrategy;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Whether the autocomplete is disabled. When disabled, the element will
|
|
326
|
+
* act as a regular input and the user won't be able to open the panel.
|
|
327
|
+
*/
|
|
328
|
+
get autocompleteDisabled() { return this._autocompleteDisabled; }
|
|
329
|
+
set autocompleteDisabled(value) {
|
|
330
|
+
this._autocompleteDisabled = coerceBooleanProperty(value);
|
|
331
|
+
}
|
|
332
|
+
ngAfterViewInit() {
|
|
333
|
+
const window = this._getWindow();
|
|
334
|
+
if (typeof window !== 'undefined') {
|
|
335
|
+
this._zone.runOutsideAngular(() => window.addEventListener('blur', this._windowBlurHandler));
|
|
344
336
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
337
|
+
}
|
|
338
|
+
ngOnChanges(changes) {
|
|
339
|
+
if (changes['position'] && this._positionStrategy) {
|
|
340
|
+
this._setStrategyPositions(this._positionStrategy);
|
|
341
|
+
if (this.panelOpen) {
|
|
342
|
+
this._overlayRef.updatePosition();
|
|
351
343
|
}
|
|
352
344
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
345
|
+
}
|
|
346
|
+
ngOnDestroy() {
|
|
347
|
+
const window = this._getWindow();
|
|
348
|
+
if (typeof window !== 'undefined') {
|
|
349
|
+
window.removeEventListener('blur', this._windowBlurHandler);
|
|
350
|
+
}
|
|
351
|
+
this._viewportSubscription.unsubscribe();
|
|
352
|
+
this._componentDestroyed = true;
|
|
353
|
+
this._destroyPanel();
|
|
354
|
+
this._closeKeyEventStream.complete();
|
|
355
|
+
}
|
|
356
|
+
/** Whether or not the autocomplete panel is open. */
|
|
357
|
+
get panelOpen() {
|
|
358
|
+
return this._overlayAttached && this.autocomplete.showPanel;
|
|
359
|
+
}
|
|
360
|
+
/** Opens the autocomplete suggestion panel. */
|
|
361
|
+
openPanel() {
|
|
362
|
+
this._attachOverlay();
|
|
363
|
+
this._floatLabel();
|
|
364
|
+
}
|
|
365
|
+
/** Closes the autocomplete suggestion panel. */
|
|
366
|
+
closePanel() {
|
|
367
|
+
this._resetLabel();
|
|
368
|
+
if (!this._overlayAttached) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
if (this.panelOpen) {
|
|
372
|
+
// Only emit if the panel was visible.
|
|
373
|
+
this.autocomplete.closed.emit();
|
|
374
|
+
}
|
|
375
|
+
this.autocomplete._isOpen = this._overlayAttached = false;
|
|
376
|
+
if (this._overlayRef && this._overlayRef.hasAttached()) {
|
|
377
|
+
this._overlayRef.detach();
|
|
378
|
+
this._closingActionsSubscription.unsubscribe();
|
|
379
|
+
}
|
|
380
|
+
// Note that in some cases this can end up being called after the component is destroyed.
|
|
381
|
+
// Add a check to ensure that we don't try to run change detection on a destroyed view.
|
|
382
|
+
if (!this._componentDestroyed) {
|
|
383
|
+
// We need to trigger change detection manually, because
|
|
384
|
+
// `fromEvent` doesn't seem to do it at the proper time.
|
|
385
|
+
// This ensures that the label is reset when the
|
|
386
|
+
// user clicks outside.
|
|
387
|
+
this._changeDetectorRef.detectChanges();
|
|
362
388
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Updates the position of the autocomplete suggestion panel to ensure that it fits all options
|
|
392
|
+
* within the viewport.
|
|
393
|
+
*/
|
|
394
|
+
updatePosition() {
|
|
395
|
+
if (this._overlayAttached) {
|
|
396
|
+
this._overlayRef.updatePosition();
|
|
366
397
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* A stream of actions that should close the autocomplete panel, including
|
|
401
|
+
* when an option is selected, on blur, and when TAB is pressed.
|
|
402
|
+
*/
|
|
403
|
+
get panelClosingActions() {
|
|
404
|
+
return merge(this.optionSelections, this.autocomplete._keyManager.tabOut.pipe(filter(() => this._overlayAttached)), this._closeKeyEventStream, this._getOutsideClickStream(), this._overlayRef ?
|
|
405
|
+
this._overlayRef.detachments().pipe(filter(() => this._overlayAttached)) :
|
|
406
|
+
of()).pipe(
|
|
407
|
+
// Normalize the output so we return a consistent type.
|
|
408
|
+
map(event => event instanceof MatOptionSelectionChange ? event : null));
|
|
409
|
+
}
|
|
410
|
+
/** The currently active option, coerced to MatOption type. */
|
|
411
|
+
get activeOption() {
|
|
412
|
+
if (this.autocomplete && this.autocomplete._keyManager) {
|
|
413
|
+
return this.autocomplete._keyManager.activeItem;
|
|
371
414
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
this.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
/** Stream of clicks outside of the autocomplete panel. */
|
|
418
|
+
_getOutsideClickStream() {
|
|
419
|
+
return merge(fromEvent(this._document, 'click'), fromEvent(this._document, 'touchend'))
|
|
420
|
+
.pipe(filter(event => {
|
|
421
|
+
// If we're in the Shadow DOM, the event target will be the shadow root, so we have to
|
|
422
|
+
// fall back to check the first element in the path of the click event.
|
|
423
|
+
const clickTarget = (this._isInsideShadowRoot && event.composedPath ? event.composedPath()[0] :
|
|
424
|
+
event.target);
|
|
425
|
+
const formField = this._formField ? this._formField._elementRef.nativeElement : null;
|
|
426
|
+
const customOrigin = this.connectedTo ? this.connectedTo.elementRef.nativeElement : null;
|
|
427
|
+
return this._overlayAttached && clickTarget !== this._element.nativeElement &&
|
|
428
|
+
(!formField || !formField.contains(clickTarget)) &&
|
|
429
|
+
(!customOrigin || !customOrigin.contains(clickTarget)) &&
|
|
430
|
+
(!!this._overlayRef && !this._overlayRef.overlayElement.contains(clickTarget));
|
|
431
|
+
}));
|
|
432
|
+
}
|
|
433
|
+
// Implemented as part of ControlValueAccessor.
|
|
434
|
+
writeValue(value) {
|
|
435
|
+
Promise.resolve(null).then(() => this._setTriggerValue(value));
|
|
436
|
+
}
|
|
437
|
+
// Implemented as part of ControlValueAccessor.
|
|
438
|
+
registerOnChange(fn) {
|
|
439
|
+
this._onChange = fn;
|
|
440
|
+
}
|
|
441
|
+
// Implemented as part of ControlValueAccessor.
|
|
442
|
+
registerOnTouched(fn) {
|
|
443
|
+
this._onTouched = fn;
|
|
444
|
+
}
|
|
445
|
+
// Implemented as part of ControlValueAccessor.
|
|
446
|
+
setDisabledState(isDisabled) {
|
|
447
|
+
this._element.nativeElement.disabled = isDisabled;
|
|
448
|
+
}
|
|
449
|
+
_handleKeydown(event) {
|
|
450
|
+
const keyCode = event.keyCode;
|
|
451
|
+
// Prevent the default action on all escape key presses. This is here primarily to bring IE
|
|
452
|
+
// in line with other browsers. By default, pressing escape on IE will cause it to revert
|
|
453
|
+
// the input value to the one that it had on focus, however it won't dispatch any events
|
|
454
|
+
// which means that the model value will be out of sync with the view.
|
|
455
|
+
if (keyCode === ESCAPE) {
|
|
456
|
+
event.preventDefault();
|
|
396
457
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
updatePosition() {
|
|
402
|
-
if (this._overlayAttached) {
|
|
403
|
-
this._overlayRef.updatePosition();
|
|
404
|
-
}
|
|
458
|
+
if (this.activeOption && keyCode === ENTER && this.panelOpen) {
|
|
459
|
+
this.activeOption._selectViaInteraction();
|
|
460
|
+
this._resetActiveItem();
|
|
461
|
+
event.preventDefault();
|
|
405
462
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
return merge(this.optionSelections, this.autocomplete._keyManager.tabOut.pipe(filter(() => this._overlayAttached)), this._closeKeyEventStream, this._getOutsideClickStream(), this._overlayRef ?
|
|
412
|
-
this._overlayRef.detachments().pipe(filter(() => this._overlayAttached)) :
|
|
413
|
-
of()).pipe(
|
|
414
|
-
// Normalize the output so we return a consistent type.
|
|
415
|
-
map(event => event instanceof MatOptionSelectionChange ? event : null));
|
|
416
|
-
}
|
|
417
|
-
/** The currently active option, coerced to MatOption type. */
|
|
418
|
-
get activeOption() {
|
|
419
|
-
if (this.autocomplete && this.autocomplete._keyManager) {
|
|
420
|
-
return this.autocomplete._keyManager.activeItem;
|
|
463
|
+
else if (this.autocomplete) {
|
|
464
|
+
const prevActiveItem = this.autocomplete._keyManager.activeItem;
|
|
465
|
+
const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW;
|
|
466
|
+
if (this.panelOpen || keyCode === TAB) {
|
|
467
|
+
this.autocomplete._keyManager.onKeydown(event);
|
|
421
468
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
/** Stream of clicks outside of the autocomplete panel. */
|
|
425
|
-
_getOutsideClickStream() {
|
|
426
|
-
return merge(fromEvent(this._document, 'click'), fromEvent(this._document, 'touchend'))
|
|
427
|
-
.pipe(filter(event => {
|
|
428
|
-
// If we're in the Shadow DOM, the event target will be the shadow root, so we have to
|
|
429
|
-
// fall back to check the first element in the path of the click event.
|
|
430
|
-
const clickTarget = (this._isInsideShadowRoot && event.composedPath ? event.composedPath()[0] :
|
|
431
|
-
event.target);
|
|
432
|
-
const formField = this._formField ? this._formField._elementRef.nativeElement : null;
|
|
433
|
-
return this._overlayAttached && clickTarget !== this._element.nativeElement &&
|
|
434
|
-
(!formField || !formField.contains(clickTarget)) &&
|
|
435
|
-
(!!this._overlayRef && !this._overlayRef.overlayElement.contains(clickTarget));
|
|
436
|
-
}));
|
|
437
|
-
}
|
|
438
|
-
// Implemented as part of ControlValueAccessor.
|
|
439
|
-
writeValue(value) {
|
|
440
|
-
Promise.resolve(null).then(() => this._setTriggerValue(value));
|
|
441
|
-
}
|
|
442
|
-
// Implemented as part of ControlValueAccessor.
|
|
443
|
-
registerOnChange(fn) {
|
|
444
|
-
this._onChange = fn;
|
|
445
|
-
}
|
|
446
|
-
// Implemented as part of ControlValueAccessor.
|
|
447
|
-
registerOnTouched(fn) {
|
|
448
|
-
this._onTouched = fn;
|
|
449
|
-
}
|
|
450
|
-
// Implemented as part of ControlValueAccessor.
|
|
451
|
-
setDisabledState(isDisabled) {
|
|
452
|
-
this._element.nativeElement.disabled = isDisabled;
|
|
453
|
-
}
|
|
454
|
-
_handleKeydown(event) {
|
|
455
|
-
const keyCode = event.keyCode;
|
|
456
|
-
// Prevent the default action on all escape key presses. This is here primarily to bring IE
|
|
457
|
-
// in line with other browsers. By default, pressing escape on IE will cause it to revert
|
|
458
|
-
// the input value to the one that it had on focus, however it won't dispatch any events
|
|
459
|
-
// which means that the model value will be out of sync with the view.
|
|
460
|
-
if (keyCode === ESCAPE) {
|
|
461
|
-
event.preventDefault();
|
|
469
|
+
else if (isArrowKey && this._canOpen()) {
|
|
470
|
+
this.openPanel();
|
|
462
471
|
}
|
|
463
|
-
if (this.
|
|
464
|
-
this.
|
|
465
|
-
this._resetActiveItem();
|
|
466
|
-
event.preventDefault();
|
|
467
|
-
}
|
|
468
|
-
else if (this.autocomplete) {
|
|
469
|
-
const prevActiveItem = this.autocomplete._keyManager.activeItem;
|
|
470
|
-
const isArrowKey = keyCode === UP_ARROW || keyCode === DOWN_ARROW;
|
|
471
|
-
if (this.panelOpen || keyCode === TAB) {
|
|
472
|
-
this.autocomplete._keyManager.onKeydown(event);
|
|
473
|
-
}
|
|
474
|
-
else if (isArrowKey && this._canOpen()) {
|
|
475
|
-
this.openPanel();
|
|
476
|
-
}
|
|
477
|
-
if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {
|
|
478
|
-
this._scrollToOption();
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
_handleInput(event) {
|
|
483
|
-
let target = event.target;
|
|
484
|
-
let value = target.value;
|
|
485
|
-
// Based on `NumberValueAccessor` from forms.
|
|
486
|
-
if (target.type === 'number') {
|
|
487
|
-
value = value == '' ? null : parseFloat(value);
|
|
488
|
-
}
|
|
489
|
-
// If the input has a placeholder, IE will fire the `input` event on page load,
|
|
490
|
-
// focus and blur, in addition to when the user actually changed the value. To
|
|
491
|
-
// filter out all of the extra events, we save the value on focus and between
|
|
492
|
-
// `input` events, and we check whether it changed.
|
|
493
|
-
// See: https://connect.microsoft.com/IE/feedback/details/885747/
|
|
494
|
-
if (this._previousValue !== value) {
|
|
495
|
-
this._previousValue = value;
|
|
496
|
-
this._onChange(value);
|
|
497
|
-
if (this._canOpen() && this._document.activeElement === event.target) {
|
|
498
|
-
this.openPanel();
|
|
499
|
-
}
|
|
472
|
+
if (isArrowKey || this.autocomplete._keyManager.activeItem !== prevActiveItem) {
|
|
473
|
+
this._scrollToOption();
|
|
500
474
|
}
|
|
501
475
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
476
|
+
}
|
|
477
|
+
_handleInput(event) {
|
|
478
|
+
let target = event.target;
|
|
479
|
+
let value = target.value;
|
|
480
|
+
// Based on `NumberValueAccessor` from forms.
|
|
481
|
+
if (target.type === 'number') {
|
|
482
|
+
value = value == '' ? null : parseFloat(value);
|
|
483
|
+
}
|
|
484
|
+
// If the input has a placeholder, IE will fire the `input` event on page load,
|
|
485
|
+
// focus and blur, in addition to when the user actually changed the value. To
|
|
486
|
+
// filter out all of the extra events, we save the value on focus and between
|
|
487
|
+
// `input` events, and we check whether it changed.
|
|
488
|
+
// See: https://connect.microsoft.com/IE/feedback/details/885747/
|
|
489
|
+
if (this._previousValue !== value) {
|
|
490
|
+
this._previousValue = value;
|
|
491
|
+
this._onChange(value);
|
|
492
|
+
if (this._canOpen() && this._document.activeElement === event.target) {
|
|
493
|
+
this.openPanel();
|
|
510
494
|
}
|
|
511
495
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
* @param shouldAnimate Whether the label should be animated when it is floated.
|
|
517
|
-
*/
|
|
518
|
-
_floatLabel(shouldAnimate = false) {
|
|
519
|
-
if (this._formField && this._formField.floatLabel === 'auto') {
|
|
520
|
-
if (shouldAnimate) {
|
|
521
|
-
this._formField._animateAndLockLabel();
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
this._formField.floatLabel = 'always';
|
|
525
|
-
}
|
|
526
|
-
this._manuallyFloatingLabel = true;
|
|
527
|
-
}
|
|
496
|
+
}
|
|
497
|
+
_handleFocus() {
|
|
498
|
+
if (!this._canOpenOnNextFocus) {
|
|
499
|
+
this._canOpenOnNextFocus = true;
|
|
528
500
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
this._manuallyFloatingLabel = false;
|
|
534
|
-
}
|
|
501
|
+
else if (this._canOpen()) {
|
|
502
|
+
this._previousValue = this._element.nativeElement.value;
|
|
503
|
+
this._attachOverlay();
|
|
504
|
+
this._floatLabel(true);
|
|
535
505
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const labelCount = _countGroupLabelsBeforeOption(index, this.autocomplete.options, this.autocomplete.optionGroups);
|
|
548
|
-
if (index === 0 && labelCount === 1) {
|
|
549
|
-
// If we've got one group label before the option and we're at the top option,
|
|
550
|
-
// scroll the list to the top. This is better UX than scrolling the list to the
|
|
551
|
-
// top of the option, because it allows the user to read the top group's label.
|
|
552
|
-
this.autocomplete._setScrollTop(0);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* In "auto" mode, the label will animate down as soon as focus is lost.
|
|
509
|
+
* This causes the value to jump when selecting an option with the mouse.
|
|
510
|
+
* This method manually floats the label until the panel can be closed.
|
|
511
|
+
* @param shouldAnimate Whether the label should be animated when it is floated.
|
|
512
|
+
*/
|
|
513
|
+
_floatLabel(shouldAnimate = false) {
|
|
514
|
+
if (this._formField && this._formField.floatLabel === 'auto') {
|
|
515
|
+
if (shouldAnimate) {
|
|
516
|
+
this._formField._animateAndLockLabel();
|
|
553
517
|
}
|
|
554
518
|
else {
|
|
555
|
-
|
|
556
|
-
this.autocomplete._setScrollTop(newScrollPosition);
|
|
519
|
+
this._formField.floatLabel = 'always';
|
|
557
520
|
}
|
|
521
|
+
this._manuallyFloatingLabel = true;
|
|
558
522
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
const optionChanges = this.autocomplete.options.changes.pipe(tap(() => this._positionStrategy.reapplyLastPosition()),
|
|
566
|
-
// Defer emitting to the stream until the next tick, because changing
|
|
567
|
-
// bindings in here will cause "changed after checked" errors.
|
|
568
|
-
delay(0));
|
|
569
|
-
// When the zone is stable initially, and when the option list changes...
|
|
570
|
-
return merge(firstStable, optionChanges)
|
|
571
|
-
.pipe(
|
|
572
|
-
// create a new stream of panelClosingActions, replacing any previous streams
|
|
573
|
-
// that were created, and flatten it so our stream only emits closing events...
|
|
574
|
-
switchMap(() => {
|
|
575
|
-
const wasOpen = this.panelOpen;
|
|
576
|
-
this._resetActiveItem();
|
|
577
|
-
this.autocomplete._setVisibility();
|
|
578
|
-
if (this.panelOpen) {
|
|
579
|
-
this._overlayRef.updatePosition();
|
|
580
|
-
// If the `panelOpen` state changed, we need to make sure to emit the `opened`
|
|
581
|
-
// event, because we may not have emitted it when the panel was attached. This
|
|
582
|
-
// can happen if the users opens the panel and there are no options, but the
|
|
583
|
-
// options come in slightly later or as a result of the value changing.
|
|
584
|
-
if (wasOpen !== this.panelOpen) {
|
|
585
|
-
this.autocomplete.opened.emit();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return this.panelClosingActions;
|
|
589
|
-
}),
|
|
590
|
-
// when the first closing event occurs...
|
|
591
|
-
take(1))
|
|
592
|
-
// set the value, close the panel, and complete.
|
|
593
|
-
.subscribe(event => this._setValueAndClose(event));
|
|
594
|
-
}
|
|
595
|
-
/** Destroys the autocomplete suggestion panel. */
|
|
596
|
-
_destroyPanel() {
|
|
597
|
-
if (this._overlayRef) {
|
|
598
|
-
this.closePanel();
|
|
599
|
-
this._overlayRef.dispose();
|
|
600
|
-
this._overlayRef = null;
|
|
601
|
-
}
|
|
523
|
+
}
|
|
524
|
+
/** If the label has been manually elevated, return it to its normal state. */
|
|
525
|
+
_resetLabel() {
|
|
526
|
+
if (this._manuallyFloatingLabel) {
|
|
527
|
+
this._formField.floatLabel = 'auto';
|
|
528
|
+
this._manuallyFloatingLabel = false;
|
|
602
529
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Given that we are not actually focusing active options, we must manually adjust scroll
|
|
533
|
+
* to reveal options below the fold. First, we find the offset of the option from the top
|
|
534
|
+
* of the panel. If that offset is below the fold, the new scrollTop will be the offset -
|
|
535
|
+
* the panel height + the option height, so the active option will be just visible at the
|
|
536
|
+
* bottom of the panel. If that offset is above the top of the visible panel, the new scrollTop
|
|
537
|
+
* will become the offset. If that offset is visible within the panel already, the scrollTop is
|
|
538
|
+
* not adjusted.
|
|
539
|
+
*/
|
|
540
|
+
_scrollToOption() {
|
|
541
|
+
const index = this.autocomplete._keyManager.activeItemIndex || 0;
|
|
542
|
+
const labelCount = _countGroupLabelsBeforeOption(index, this.autocomplete.options, this.autocomplete.optionGroups);
|
|
543
|
+
if (index === 0 && labelCount === 1) {
|
|
544
|
+
// If we've got one group label before the option and we're at the top option,
|
|
545
|
+
// scroll the list to the top. This is better UX than scrolling the list to the
|
|
546
|
+
// top of the option, because it allows the user to read the top group's label.
|
|
547
|
+
this.autocomplete._setScrollTop(0);
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
const newScrollPosition = _getOptionScrollPosition(index + labelCount, AUTOCOMPLETE_OPTION_HEIGHT, this.autocomplete._getScrollTop(), AUTOCOMPLETE_PANEL_HEIGHT);
|
|
551
|
+
this.autocomplete._setScrollTop(newScrollPosition);
|
|
619
552
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* This method listens to a stream of panel closing actions and resets the
|
|
556
|
+
* stream every time the option list changes.
|
|
557
|
+
*/
|
|
558
|
+
_subscribeToClosingActions() {
|
|
559
|
+
const firstStable = this._zone.onStable.asObservable().pipe(take(1));
|
|
560
|
+
const optionChanges = this.autocomplete.options.changes.pipe(tap(() => this._positionStrategy.reapplyLastPosition()),
|
|
561
|
+
// Defer emitting to the stream until the next tick, because changing
|
|
562
|
+
// bindings in here will cause "changed after checked" errors.
|
|
563
|
+
delay(0));
|
|
564
|
+
// When the zone is stable initially, and when the option list changes...
|
|
565
|
+
return merge(firstStable, optionChanges)
|
|
566
|
+
.pipe(
|
|
567
|
+
// create a new stream of panelClosingActions, replacing any previous streams
|
|
568
|
+
// that were created, and flatten it so our stream only emits closing events...
|
|
569
|
+
switchMap(() => {
|
|
570
|
+
const wasOpen = this.panelOpen;
|
|
571
|
+
this._resetActiveItem();
|
|
572
|
+
this.autocomplete._setVisibility();
|
|
573
|
+
if (this.panelOpen) {
|
|
574
|
+
this._overlayRef.updatePosition();
|
|
575
|
+
// If the `panelOpen` state changed, we need to make sure to emit the `opened`
|
|
576
|
+
// event, because we may not have emitted it when the panel was attached. This
|
|
577
|
+
// can happen if the users opens the panel and there are no options, but the
|
|
578
|
+
// options come in slightly later or as a result of the value changing.
|
|
579
|
+
if (wasOpen !== this.panelOpen) {
|
|
580
|
+
this.autocomplete.opened.emit();
|
|
581
|
+
}
|
|
632
582
|
}
|
|
583
|
+
return this.panelClosingActions;
|
|
584
|
+
}),
|
|
585
|
+
// when the first closing event occurs...
|
|
586
|
+
take(1))
|
|
587
|
+
// set the value, close the panel, and complete.
|
|
588
|
+
.subscribe(event => this._setValueAndClose(event));
|
|
589
|
+
}
|
|
590
|
+
/** Destroys the autocomplete suggestion panel. */
|
|
591
|
+
_destroyPanel() {
|
|
592
|
+
if (this._overlayRef) {
|
|
633
593
|
this.closePanel();
|
|
594
|
+
this._overlayRef.dispose();
|
|
595
|
+
this._overlayRef = null;
|
|
634
596
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
597
|
+
}
|
|
598
|
+
_setTriggerValue(value) {
|
|
599
|
+
const toDisplay = this.autocomplete && this.autocomplete.displayWith ?
|
|
600
|
+
this.autocomplete.displayWith(value) :
|
|
601
|
+
value;
|
|
602
|
+
// Simply falling back to an empty string if the display value is falsy does not work properly.
|
|
603
|
+
// The display value can also be the number zero and shouldn't fall back to an empty string.
|
|
604
|
+
const inputValue = toDisplay != null ? toDisplay : '';
|
|
605
|
+
// If it's used within a `MatFormField`, we should set it through the property so it can go
|
|
606
|
+
// through change detection.
|
|
607
|
+
if (this._formField) {
|
|
608
|
+
this._formField._control.value = inputValue;
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
this._element.nativeElement.value = inputValue;
|
|
612
|
+
}
|
|
613
|
+
this._previousValue = inputValue;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* This method closes the panel, and if a value is specified, also sets the associated
|
|
617
|
+
* control to that value. It will also mark the control as dirty if this interaction
|
|
618
|
+
* stemmed from the user.
|
|
619
|
+
*/
|
|
620
|
+
_setValueAndClose(event) {
|
|
621
|
+
if (event && event.source) {
|
|
622
|
+
this._clearPreviousSelectedOption(event.source);
|
|
623
|
+
this._setTriggerValue(event.source.value);
|
|
624
|
+
this._onChange(event.source.value);
|
|
625
|
+
this._element.nativeElement.focus();
|
|
626
|
+
this.autocomplete._emitSelectEvent(event.source);
|
|
627
|
+
}
|
|
628
|
+
this.closePanel();
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Clear any previous selected option and emit a selection change event for this option
|
|
632
|
+
*/
|
|
633
|
+
_clearPreviousSelectedOption(skip) {
|
|
634
|
+
this.autocomplete.options.forEach(option => {
|
|
635
|
+
if (option != skip && option.selected) {
|
|
636
|
+
option.deselect();
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
_attachOverlay() {
|
|
641
|
+
if (!this.autocomplete) {
|
|
642
|
+
throw getMatAutocompleteMissingPanelError();
|
|
643
|
+
}
|
|
644
|
+
// We want to resolve this once, as late as possible so that we can be
|
|
645
|
+
// sure that the element has been moved into its final place in the DOM.
|
|
646
|
+
if (this._isInsideShadowRoot == null) {
|
|
647
|
+
this._isInsideShadowRoot = !!_getShadowRoot(this._element.nativeElement);
|
|
648
|
+
}
|
|
649
|
+
let overlayRef = this._overlayRef;
|
|
650
|
+
if (!overlayRef) {
|
|
651
|
+
this._portal = new TemplatePortal(this.autocomplete.template, this._viewContainerRef);
|
|
652
|
+
overlayRef = this._overlay.create(this._getOverlayConfig());
|
|
653
|
+
this._overlayRef = overlayRef;
|
|
654
|
+
// Use the `keydownEvents` in order to take advantage of
|
|
655
|
+
// the overlay event targeting provided by the CDK overlay.
|
|
656
|
+
overlayRef.keydownEvents().subscribe(event => {
|
|
657
|
+
// Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.
|
|
658
|
+
// See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction
|
|
659
|
+
if (event.keyCode === ESCAPE || (event.keyCode === UP_ARROW && event.altKey)) {
|
|
660
|
+
this._resetActiveItem();
|
|
661
|
+
this._closeKeyEventStream.next();
|
|
662
|
+
// We need to stop propagation, otherwise the event will eventually
|
|
663
|
+
// reach the input itself and cause the overlay to be reopened.
|
|
664
|
+
event.stopPropagation();
|
|
665
|
+
event.preventDefault();
|
|
642
666
|
}
|
|
643
667
|
});
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
// We want to resolve this once, as late as possible so that we can be
|
|
650
|
-
// sure that the element has been moved into its final place in the DOM.
|
|
651
|
-
if (this._isInsideShadowRoot == null) {
|
|
652
|
-
this._isInsideShadowRoot = !!_getShadowRoot(this._element.nativeElement);
|
|
653
|
-
}
|
|
654
|
-
let overlayRef = this._overlayRef;
|
|
655
|
-
if (!overlayRef) {
|
|
656
|
-
this._portal = new TemplatePortal(this.autocomplete.template, this._viewContainerRef);
|
|
657
|
-
overlayRef = this._overlay.create(this._getOverlayConfig());
|
|
658
|
-
this._overlayRef = overlayRef;
|
|
659
|
-
// Use the `keydownEvents` in order to take advantage of
|
|
660
|
-
// the overlay event targeting provided by the CDK overlay.
|
|
661
|
-
overlayRef.keydownEvents().subscribe(event => {
|
|
662
|
-
// Close when pressing ESCAPE or ALT + UP_ARROW, based on the a11y guidelines.
|
|
663
|
-
// See: https://www.w3.org/TR/wai-aria-practices-1.1/#textbox-keyboard-interaction
|
|
664
|
-
if (event.keyCode === ESCAPE || (event.keyCode === UP_ARROW && event.altKey)) {
|
|
665
|
-
this._resetActiveItem();
|
|
666
|
-
this._closeKeyEventStream.next();
|
|
667
|
-
// We need to stop propagation, otherwise the event will eventually
|
|
668
|
-
// reach the input itself and cause the overlay to be reopened.
|
|
669
|
-
event.stopPropagation();
|
|
670
|
-
event.preventDefault();
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
this._viewportSubscription = this._viewportRuler.change().subscribe(() => {
|
|
674
|
-
if (this.panelOpen && overlayRef) {
|
|
675
|
-
overlayRef.updateSize({ width: this._getPanelWidth() });
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
// Update the trigger, panel width and direction, in case anything has changed.
|
|
681
|
-
this._positionStrategy.setOrigin(this._getConnectedElement());
|
|
682
|
-
overlayRef.updateSize({ width: this._getPanelWidth() });
|
|
683
|
-
}
|
|
684
|
-
if (overlayRef && !overlayRef.hasAttached()) {
|
|
685
|
-
overlayRef.attach(this._portal);
|
|
686
|
-
this._closingActionsSubscription = this._subscribeToClosingActions();
|
|
687
|
-
}
|
|
688
|
-
const wasOpen = this.panelOpen;
|
|
689
|
-
this.autocomplete._setVisibility();
|
|
690
|
-
this.autocomplete._isOpen = this._overlayAttached = true;
|
|
691
|
-
// We need to do an extra `panelOpen` check in here, because the
|
|
692
|
-
// autocomplete won't be shown if there are no options.
|
|
693
|
-
if (this.panelOpen && wasOpen !== this.panelOpen) {
|
|
694
|
-
this.autocomplete.opened.emit();
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
_getOverlayConfig() {
|
|
698
|
-
return new OverlayConfig({
|
|
699
|
-
positionStrategy: this._getOverlayPosition(),
|
|
700
|
-
scrollStrategy: this._scrollStrategy(),
|
|
701
|
-
width: this._getPanelWidth(),
|
|
702
|
-
direction: this._dir
|
|
668
|
+
this._viewportSubscription = this._viewportRuler.change().subscribe(() => {
|
|
669
|
+
if (this.panelOpen && overlayRef) {
|
|
670
|
+
overlayRef.updateSize({ width: this._getPanelWidth() });
|
|
671
|
+
}
|
|
703
672
|
});
|
|
704
673
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
.withPush(false);
|
|
710
|
-
this._setStrategyPositions(strategy);
|
|
711
|
-
this._positionStrategy = strategy;
|
|
712
|
-
return strategy;
|
|
713
|
-
}
|
|
714
|
-
/** Sets the positions on a position strategy based on the directive's input state. */
|
|
715
|
-
_setStrategyPositions(positionStrategy) {
|
|
716
|
-
// Note that we provide horizontal fallback positions, even though by default the dropdown
|
|
717
|
-
// width matches the input, because consumers can override the width. See #18854.
|
|
718
|
-
const belowPositions = [
|
|
719
|
-
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
|
|
720
|
-
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' }
|
|
721
|
-
];
|
|
722
|
-
// The overlay edge connected to the trigger should have squared corners, while
|
|
723
|
-
// the opposite end has rounded corners. We apply a CSS class to swap the
|
|
724
|
-
// border-radius based on the overlay position.
|
|
725
|
-
const panelClass = 'mat-autocomplete-panel-above';
|
|
726
|
-
const abovePositions = [
|
|
727
|
-
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', panelClass },
|
|
728
|
-
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', panelClass }
|
|
729
|
-
];
|
|
730
|
-
let positions;
|
|
731
|
-
if (this.position === 'above') {
|
|
732
|
-
positions = abovePositions;
|
|
733
|
-
}
|
|
734
|
-
else if (this.position === 'below') {
|
|
735
|
-
positions = belowPositions;
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
positions = [...belowPositions, ...abovePositions];
|
|
739
|
-
}
|
|
740
|
-
positionStrategy.withPositions(positions);
|
|
674
|
+
else {
|
|
675
|
+
// Update the trigger, panel width and direction, in case anything has changed.
|
|
676
|
+
this._positionStrategy.setOrigin(this._getConnectedElement());
|
|
677
|
+
overlayRef.updateSize({ width: this._getPanelWidth() });
|
|
741
678
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
return this._formField ? this._formField.getConnectedOverlayOrigin() : this._element;
|
|
679
|
+
if (overlayRef && !overlayRef.hasAttached()) {
|
|
680
|
+
overlayRef.attach(this._portal);
|
|
681
|
+
this._closingActionsSubscription = this._subscribeToClosingActions();
|
|
747
682
|
}
|
|
748
|
-
|
|
749
|
-
|
|
683
|
+
const wasOpen = this.panelOpen;
|
|
684
|
+
this.autocomplete._setVisibility();
|
|
685
|
+
this.autocomplete._isOpen = this._overlayAttached = true;
|
|
686
|
+
// We need to do an extra `panelOpen` check in here, because the
|
|
687
|
+
// autocomplete won't be shown if there are no options.
|
|
688
|
+
if (this.panelOpen && wasOpen !== this.panelOpen) {
|
|
689
|
+
this.autocomplete.opened.emit();
|
|
750
690
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
691
|
+
}
|
|
692
|
+
_getOverlayConfig() {
|
|
693
|
+
return new OverlayConfig({
|
|
694
|
+
positionStrategy: this._getOverlayPosition(),
|
|
695
|
+
scrollStrategy: this._scrollStrategy(),
|
|
696
|
+
width: this._getPanelWidth(),
|
|
697
|
+
direction: this._dir
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
_getOverlayPosition() {
|
|
701
|
+
const strategy = this._overlay.position()
|
|
702
|
+
.flexibleConnectedTo(this._getConnectedElement())
|
|
703
|
+
.withFlexibleDimensions(false)
|
|
704
|
+
.withPush(false);
|
|
705
|
+
this._setStrategyPositions(strategy);
|
|
706
|
+
this._positionStrategy = strategy;
|
|
707
|
+
return strategy;
|
|
708
|
+
}
|
|
709
|
+
/** Sets the positions on a position strategy based on the directive's input state. */
|
|
710
|
+
_setStrategyPositions(positionStrategy) {
|
|
711
|
+
// Note that we provide horizontal fallback positions, even though by default the dropdown
|
|
712
|
+
// width matches the input, because consumers can override the width. See #18854.
|
|
713
|
+
const belowPositions = [
|
|
714
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
|
|
715
|
+
{ originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' }
|
|
716
|
+
];
|
|
717
|
+
// The overlay edge connected to the trigger should have squared corners, while
|
|
718
|
+
// the opposite end has rounded corners. We apply a CSS class to swap the
|
|
719
|
+
// border-radius based on the overlay position.
|
|
720
|
+
const panelClass = 'mat-autocomplete-panel-above';
|
|
721
|
+
const abovePositions = [
|
|
722
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', panelClass },
|
|
723
|
+
{ originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom', panelClass }
|
|
724
|
+
];
|
|
725
|
+
let positions;
|
|
726
|
+
if (this.position === 'above') {
|
|
727
|
+
positions = abovePositions;
|
|
728
|
+
}
|
|
729
|
+
else if (this.position === 'below') {
|
|
730
|
+
positions = belowPositions;
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
positions = [...belowPositions, ...abovePositions];
|
|
734
|
+
}
|
|
735
|
+
positionStrategy.withPositions(positions);
|
|
736
|
+
}
|
|
737
|
+
_getConnectedElement() {
|
|
738
|
+
if (this.connectedTo) {
|
|
739
|
+
return this.connectedTo.elementRef;
|
|
754
740
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
|
|
741
|
+
return this._formField ? this._formField.getConnectedOverlayOrigin() : this._element;
|
|
742
|
+
}
|
|
743
|
+
_getPanelWidth() {
|
|
744
|
+
return this.autocomplete.panelWidth || this._getHostWidth();
|
|
745
|
+
}
|
|
746
|
+
/** Returns the width of the input element, so the panel width can match it. */
|
|
747
|
+
_getHostWidth() {
|
|
748
|
+
return this._getConnectedElement().nativeElement.getBoundingClientRect().width;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Resets the active item to -1 so arrow events will activate the
|
|
752
|
+
* correct options, or to 0 if the consumer opted into it.
|
|
753
|
+
*/
|
|
754
|
+
_resetActiveItem() {
|
|
755
|
+
this.autocomplete._keyManager.setActiveItem(this.autocomplete.autoActiveFirstOption ? 0 : -1);
|
|
756
|
+
}
|
|
757
|
+
/** Determines whether the panel can be opened. */
|
|
758
|
+
_canOpen() {
|
|
759
|
+
const element = this._element.nativeElement;
|
|
760
|
+
return !element.readOnly && !element.disabled && !this._autocompleteDisabled;
|
|
761
|
+
}
|
|
762
|
+
/** Use defaultView of injected document if available or fallback to global window reference */
|
|
763
|
+
_getWindow() {
|
|
764
|
+
var _a;
|
|
765
|
+
return ((_a = this._document) === null || _a === void 0 ? void 0 : _a.defaultView) || window;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
MatAutocompleteTrigger.decorators = [
|
|
769
|
+
{ type: Directive, args: [{
|
|
770
|
+
selector: `input[matAutocomplete], textarea[matAutocomplete]`,
|
|
771
|
+
host: {
|
|
772
|
+
'class': 'mat-autocomplete-trigger',
|
|
773
|
+
'[attr.autocomplete]': 'autocompleteAttribute',
|
|
774
|
+
'[attr.role]': 'autocompleteDisabled ? null : "combobox"',
|
|
775
|
+
'[attr.aria-autocomplete]': 'autocompleteDisabled ? null : "list"',
|
|
776
|
+
'[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',
|
|
777
|
+
'[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
|
|
778
|
+
'[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
|
|
779
|
+
'[attr.aria-haspopup]': '!autocompleteDisabled',
|
|
780
|
+
// Note: we use `focusin`, as opposed to `focus`, in order to open the panel
|
|
781
|
+
// a little earlier. This avoids issues where IE delays the focusing of the input.
|
|
782
|
+
'(focusin)': '_handleFocus()',
|
|
783
|
+
'(blur)': '_onTouched()',
|
|
784
|
+
'(input)': '_handleInput($event)',
|
|
785
|
+
'(keydown)': '_handleKeydown($event)',
|
|
786
|
+
},
|
|
787
|
+
exportAs: 'matAutocompleteTrigger',
|
|
788
|
+
providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR]
|
|
789
|
+
},] }
|
|
790
|
+
];
|
|
791
|
+
MatAutocompleteTrigger.ctorParameters = () => [
|
|
792
|
+
{ type: ElementRef },
|
|
793
|
+
{ type: Overlay },
|
|
794
|
+
{ type: ViewContainerRef },
|
|
795
|
+
{ type: NgZone },
|
|
796
|
+
{ type: ChangeDetectorRef },
|
|
797
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY,] }] },
|
|
798
|
+
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
799
|
+
{ type: MatFormField, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD,] }, { type: Host }] },
|
|
800
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
801
|
+
{ type: ViewportRuler }
|
|
802
|
+
];
|
|
803
|
+
MatAutocompleteTrigger.propDecorators = {
|
|
804
|
+
autocomplete: [{ type: Input, args: ['matAutocomplete',] }],
|
|
805
|
+
position: [{ type: Input, args: ['matAutocompletePosition',] }],
|
|
806
|
+
connectedTo: [{ type: Input, args: ['matAutocompleteConnectedTo',] }],
|
|
807
|
+
autocompleteAttribute: [{ type: Input, args: ['autocomplete',] }],
|
|
808
|
+
autocompleteDisabled: [{ type: Input, args: ['matAutocompleteDisabled',] }]
|
|
809
|
+
};
|
|
817
810
|
|
|
818
811
|
/**
|
|
819
812
|
* @license
|
|
@@ -822,26 +815,23 @@ let MatAutocompleteTrigger = /** @class */ (() => {
|
|
|
822
815
|
* Use of this source code is governed by an MIT-style license that can be
|
|
823
816
|
* found in the LICENSE file at https://angular.io/license
|
|
824
817
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
];
|
|
843
|
-
return MatAutocompleteModule;
|
|
844
|
-
})();
|
|
818
|
+
class MatAutocompleteModule {
|
|
819
|
+
}
|
|
820
|
+
MatAutocompleteModule.decorators = [
|
|
821
|
+
{ type: NgModule, args: [{
|
|
822
|
+
imports: [MatOptionModule, OverlayModule, MatCommonModule, CommonModule],
|
|
823
|
+
exports: [
|
|
824
|
+
CdkScrollableModule,
|
|
825
|
+
MatAutocomplete,
|
|
826
|
+
MatOptionModule,
|
|
827
|
+
MatAutocompleteTrigger,
|
|
828
|
+
MatAutocompleteOrigin,
|
|
829
|
+
MatCommonModule
|
|
830
|
+
],
|
|
831
|
+
declarations: [MatAutocomplete, MatAutocompleteTrigger, MatAutocompleteOrigin],
|
|
832
|
+
providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER],
|
|
833
|
+
},] }
|
|
834
|
+
];
|
|
845
835
|
|
|
846
836
|
/**
|
|
847
837
|
* @license
|