@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.
Files changed (627) hide show
  1. package/_theming.scss +17 -17
  2. package/autocomplete/index.metadata.json +1 -1
  3. package/autocomplete/testing/autocomplete-harness.d.ts +2 -0
  4. package/bundles/material-autocomplete-testing.umd.js +11 -0
  5. package/bundles/material-autocomplete-testing.umd.js.map +1 -1
  6. package/bundles/material-autocomplete-testing.umd.min.js +2 -2
  7. package/bundles/material-autocomplete-testing.umd.min.js.map +1 -1
  8. package/bundles/material-autocomplete.umd.js +3 -1
  9. package/bundles/material-autocomplete.umd.js.map +1 -1
  10. package/bundles/material-autocomplete.umd.min.js +5 -5
  11. package/bundles/material-autocomplete.umd.min.js.map +1 -1
  12. package/bundles/material-badge-testing.umd.min.js +1 -1
  13. package/bundles/material-badge-testing.umd.min.js.map +1 -1
  14. package/bundles/material-bottom-sheet-testing.umd.min.js +1 -1
  15. package/bundles/material-bottom-sheet-testing.umd.min.js.map +1 -1
  16. package/bundles/material-button-testing.umd.js +11 -0
  17. package/bundles/material-button-testing.umd.js.map +1 -1
  18. package/bundles/material-button-testing.umd.min.js +2 -2
  19. package/bundles/material-button-testing.umd.min.js.map +1 -1
  20. package/bundles/material-button-toggle-testing.umd.js +11 -0
  21. package/bundles/material-button-toggle-testing.umd.js.map +1 -1
  22. package/bundles/material-button-toggle-testing.umd.min.js +3 -3
  23. package/bundles/material-button-toggle-testing.umd.min.js.map +1 -1
  24. package/bundles/material-button-toggle.umd.js +12 -3
  25. package/bundles/material-button-toggle.umd.js.map +1 -1
  26. package/bundles/material-button-toggle.umd.min.js +2 -2
  27. package/bundles/material-button-toggle.umd.min.js.map +1 -1
  28. package/bundles/material-button.umd.js +7 -2
  29. package/bundles/material-button.umd.js.map +1 -1
  30. package/bundles/material-button.umd.min.js +4 -4
  31. package/bundles/material-button.umd.min.js.map +1 -1
  32. package/bundles/material-card-testing.umd.js +335 -0
  33. package/bundles/material-card-testing.umd.js.map +1 -0
  34. package/bundles/material-card-testing.umd.min.js +44 -0
  35. package/bundles/material-card-testing.umd.min.js.map +1 -0
  36. package/bundles/material-checkbox-testing.umd.js +11 -0
  37. package/bundles/material-checkbox-testing.umd.js.map +1 -1
  38. package/bundles/material-checkbox-testing.umd.min.js +3 -3
  39. package/bundles/material-checkbox-testing.umd.min.js.map +1 -1
  40. package/bundles/material-checkbox.umd.js.map +1 -1
  41. package/bundles/material-chips.umd.js +36 -12
  42. package/bundles/material-chips.umd.js.map +1 -1
  43. package/bundles/material-chips.umd.min.js +4 -4
  44. package/bundles/material-chips.umd.min.js.map +1 -1
  45. package/bundles/material-core-testing.umd.min.js +1 -1
  46. package/bundles/material-core-testing.umd.min.js.map +1 -1
  47. package/bundles/material-core.umd.js +11 -3
  48. package/bundles/material-core.umd.js.map +1 -1
  49. package/bundles/material-core.umd.min.js +11 -11
  50. package/bundles/material-core.umd.min.js.map +1 -1
  51. package/bundles/material-datepicker.umd.js +20 -11
  52. package/bundles/material-datepicker.umd.js.map +1 -1
  53. package/bundles/material-datepicker.umd.min.js +5 -5
  54. package/bundles/material-datepicker.umd.min.js.map +1 -1
  55. package/bundles/material-dialog-testing.umd.min.js +1 -1
  56. package/bundles/material-dialog-testing.umd.min.js.map +1 -1
  57. package/bundles/material-dialog.umd.js +45 -8
  58. package/bundles/material-dialog.umd.js.map +1 -1
  59. package/bundles/material-dialog.umd.min.js +14 -7
  60. package/bundles/material-dialog.umd.min.js.map +1 -1
  61. package/bundles/material-divider-testing.umd.min.js +1 -1
  62. package/bundles/material-divider-testing.umd.min.js.map +1 -1
  63. package/bundles/material-expansion-testing.umd.js +11 -0
  64. package/bundles/material-expansion-testing.umd.js.map +1 -1
  65. package/bundles/material-expansion-testing.umd.min.js +3 -3
  66. package/bundles/material-expansion-testing.umd.min.js.map +1 -1
  67. package/bundles/material-form-field-testing.umd.js +32 -0
  68. package/bundles/material-form-field-testing.umd.js.map +1 -1
  69. package/bundles/material-form-field-testing.umd.min.js +4 -4
  70. package/bundles/material-form-field-testing.umd.min.js.map +1 -1
  71. package/bundles/material-form-field.umd.js +47 -21
  72. package/bundles/material-form-field.umd.js.map +1 -1
  73. package/bundles/material-form-field.umd.min.js +5 -5
  74. package/bundles/material-form-field.umd.min.js.map +1 -1
  75. package/bundles/material-grid-list-testing.umd.min.js +1 -1
  76. package/bundles/material-grid-list-testing.umd.min.js.map +1 -1
  77. package/bundles/material-grid-list.umd.js +2 -2
  78. package/bundles/material-grid-list.umd.js.map +1 -1
  79. package/bundles/material-grid-list.umd.min.js +2 -2
  80. package/bundles/material-grid-list.umd.min.js.map +1 -1
  81. package/bundles/material-input-testing.umd.js +23 -6
  82. package/bundles/material-input-testing.umd.js.map +1 -1
  83. package/bundles/material-input-testing.umd.min.js +3 -3
  84. package/bundles/material-input-testing.umd.min.js.map +1 -1
  85. package/bundles/material-input.umd.js +28 -3
  86. package/bundles/material-input.umd.js.map +1 -1
  87. package/bundles/material-input.umd.min.js +3 -3
  88. package/bundles/material-input.umd.min.js.map +1 -1
  89. package/bundles/material-list-testing.umd.js +33 -0
  90. package/bundles/material-list-testing.umd.js.map +1 -1
  91. package/bundles/material-list-testing.umd.min.js +2 -2
  92. package/bundles/material-list-testing.umd.min.js.map +1 -1
  93. package/bundles/material-list.umd.js +3 -3
  94. package/bundles/material-list.umd.min.js +1 -1
  95. package/bundles/material-list.umd.min.js.map +1 -1
  96. package/bundles/material-menu-testing.umd.js +22 -0
  97. package/bundles/material-menu-testing.umd.js.map +1 -1
  98. package/bundles/material-menu-testing.umd.min.js +2 -2
  99. package/bundles/material-menu-testing.umd.min.js.map +1 -1
  100. package/bundles/material-menu.umd.js +13 -2
  101. package/bundles/material-menu.umd.js.map +1 -1
  102. package/bundles/material-menu.umd.min.js +4 -4
  103. package/bundles/material-menu.umd.min.js.map +1 -1
  104. package/bundles/material-paginator-testing.umd.min.js +1 -1
  105. package/bundles/material-paginator-testing.umd.min.js.map +1 -1
  106. package/bundles/material-progress-bar-testing.umd.min.js +1 -1
  107. package/bundles/material-progress-bar-testing.umd.min.js.map +1 -1
  108. package/bundles/material-progress-spinner-testing.umd.js +1 -1
  109. package/bundles/material-progress-spinner-testing.umd.js.map +1 -1
  110. package/bundles/material-progress-spinner-testing.umd.min.js +2 -2
  111. package/bundles/material-progress-spinner-testing.umd.min.js.map +1 -1
  112. package/bundles/material-progress-spinner.umd.js +2 -2
  113. package/bundles/material-progress-spinner.umd.min.js +3 -3
  114. package/bundles/material-progress-spinner.umd.min.js.map +1 -1
  115. package/bundles/material-radio-testing.umd.js +11 -0
  116. package/bundles/material-radio-testing.umd.js.map +1 -1
  117. package/bundles/material-radio-testing.umd.min.js +3 -3
  118. package/bundles/material-radio-testing.umd.min.js.map +1 -1
  119. package/bundles/material-radio.umd.js +15 -5
  120. package/bundles/material-radio.umd.js.map +1 -1
  121. package/bundles/material-radio.umd.min.js +2 -2
  122. package/bundles/material-radio.umd.min.js.map +1 -1
  123. package/bundles/material-select-testing.umd.js +11 -0
  124. package/bundles/material-select-testing.umd.js.map +1 -1
  125. package/bundles/material-select-testing.umd.min.js +2 -2
  126. package/bundles/material-select-testing.umd.min.js.map +1 -1
  127. package/bundles/material-select.umd.js +11 -3
  128. package/bundles/material-select.umd.js.map +1 -1
  129. package/bundles/material-select.umd.min.js +4 -4
  130. package/bundles/material-select.umd.min.js.map +1 -1
  131. package/bundles/material-sidenav-testing.umd.min.js +1 -1
  132. package/bundles/material-sidenav-testing.umd.min.js.map +1 -1
  133. package/bundles/material-sidenav.umd.js +41 -17
  134. package/bundles/material-sidenav.umd.js.map +1 -1
  135. package/bundles/material-sidenav.umd.min.js +2 -2
  136. package/bundles/material-sidenav.umd.min.js.map +1 -1
  137. package/bundles/material-slide-toggle-testing.umd.js +11 -0
  138. package/bundles/material-slide-toggle-testing.umd.js.map +1 -1
  139. package/bundles/material-slide-toggle-testing.umd.min.js +2 -2
  140. package/bundles/material-slide-toggle-testing.umd.min.js.map +1 -1
  141. package/bundles/material-slide-toggle.umd.js.map +1 -1
  142. package/bundles/material-slider-testing.umd.js +11 -0
  143. package/bundles/material-slider-testing.umd.js.map +1 -1
  144. package/bundles/material-slider-testing.umd.min.js +2 -2
  145. package/bundles/material-slider-testing.umd.min.js.map +1 -1
  146. package/bundles/material-snack-bar-testing.umd.min.js +1 -1
  147. package/bundles/material-snack-bar-testing.umd.min.js.map +1 -1
  148. package/bundles/material-snack-bar.umd.js +47 -39
  149. package/bundles/material-snack-bar.umd.js.map +1 -1
  150. package/bundles/material-snack-bar.umd.min.js +2 -2
  151. package/bundles/material-snack-bar.umd.min.js.map +1 -1
  152. package/bundles/material-sort-testing.umd.js +10 -10
  153. package/bundles/material-sort-testing.umd.js.map +1 -1
  154. package/bundles/material-sort-testing.umd.min.js +3 -3
  155. package/bundles/material-sort-testing.umd.min.js.map +1 -1
  156. package/bundles/material-sort.umd.js +25 -12
  157. package/bundles/material-sort.umd.js.map +1 -1
  158. package/bundles/material-sort.umd.min.js +5 -5
  159. package/bundles/material-sort.umd.min.js.map +1 -1
  160. package/bundles/material-table-testing.umd.min.js +1 -1
  161. package/bundles/material-table-testing.umd.min.js.map +1 -1
  162. package/bundles/material-table.umd.min.js +2 -2
  163. package/bundles/material-table.umd.min.js.map +1 -1
  164. package/bundles/material-tabs-testing.umd.min.js +1 -1
  165. package/bundles/material-tabs-testing.umd.min.js.map +1 -1
  166. package/bundles/material-tabs.umd.js +23 -4
  167. package/bundles/material-tabs.umd.js.map +1 -1
  168. package/bundles/material-tabs.umd.min.js +5 -12
  169. package/bundles/material-tabs.umd.min.js.map +1 -1
  170. package/bundles/material-toolbar-testing.umd.js +330 -0
  171. package/bundles/material-toolbar-testing.umd.js.map +1 -0
  172. package/bundles/material-toolbar-testing.umd.min.js +44 -0
  173. package/bundles/material-toolbar-testing.umd.min.js.map +1 -0
  174. package/bundles/material-tooltip-testing.umd.min.js +1 -1
  175. package/bundles/material-tooltip-testing.umd.min.js.map +1 -1
  176. package/bundles/material-tooltip.umd.js +14 -1
  177. package/bundles/material-tooltip.umd.js.map +1 -1
  178. package/bundles/material-tooltip.umd.min.js +3 -3
  179. package/bundles/material-tooltip.umd.min.js.map +1 -1
  180. package/bundles/material-tree.umd.js.map +1 -1
  181. package/button/_button-base.scss +1 -1
  182. package/button/_button-theme.scss +8 -8
  183. package/button/index.metadata.json +1 -1
  184. package/button/testing/button-harness.d.ts +2 -0
  185. package/button-toggle/button-toggle.d.ts +10 -3
  186. package/button-toggle/index.metadata.json +1 -1
  187. package/button-toggle/testing/button-toggle-harness.d.ts +2 -0
  188. package/card/testing/card-harness-filters.d.ts +17 -0
  189. package/card/testing/card-harness.d.ts +36 -0
  190. package/card/testing/index.d.ts +8 -0
  191. package/card/testing/package.json +9 -0
  192. package/card/testing/public-api.d.ts +9 -0
  193. package/checkbox/index.metadata.json +1 -1
  194. package/checkbox/testing/checkbox-harness.d.ts +2 -0
  195. package/chips/chip.d.ts +19 -1
  196. package/chips/index.metadata.json +1 -1
  197. package/core/focus-indicators/_focus-indicators.scss +6 -6
  198. package/core/index.metadata.json +1 -1
  199. package/core/option/optgroup.d.ts +7 -0
  200. package/core/ripple/ripple-ref.d.ts +21 -2
  201. package/core/ripple/ripple-renderer.d.ts +1 -19
  202. package/core/ripple/ripple.d.ts +2 -2
  203. package/core/style/_list-common.scss +1 -1
  204. package/datepicker/date-range-input-parts.d.ts +2 -4
  205. package/datepicker/date-range-input.d.ts +4 -4
  206. package/datepicker/date-range-picker.d.ts +10 -3
  207. package/datepicker/datepicker.d.ts +2 -3
  208. package/datepicker/index.metadata.json +1 -1
  209. package/datepicker/public-api.d.ts +1 -1
  210. package/dialog/dialog-container.d.ts +9 -2
  211. package/dialog/dialog-content-directives.d.ts +1 -0
  212. package/dialog/dialog-ref.d.ts +7 -0
  213. package/dialog/index.metadata.json +1 -1
  214. package/esm2015/autocomplete/autocomplete-module.js +18 -22
  215. package/esm2015/autocomplete/autocomplete-origin.js +16 -20
  216. package/esm2015/autocomplete/autocomplete-trigger.js +519 -521
  217. package/esm2015/autocomplete/autocomplete.js +126 -130
  218. package/esm2015/autocomplete/testing/autocomplete-harness.js +99 -97
  219. package/esm2015/badge/badge-module.js +13 -17
  220. package/esm2015/badge/badge.js +184 -188
  221. package/esm2015/badge/testing/badge-harness.js +74 -78
  222. package/esm2015/bottom-sheet/bottom-sheet-container.js +161 -165
  223. package/esm2015/bottom-sheet/bottom-sheet-module.js +15 -19
  224. package/esm2015/bottom-sheet/bottom-sheet.js +124 -128
  225. package/esm2015/bottom-sheet/testing/bottom-sheet-harness.js +29 -33
  226. package/esm2015/button/button-module.js +20 -24
  227. package/esm2015/button/button.js +111 -114
  228. package/esm2015/button/testing/button-harness.js +60 -58
  229. package/esm2015/button-toggle/button-toggle-module.js +10 -14
  230. package/esm2015/button-toggle/button-toggle.js +368 -368
  231. package/esm2015/button-toggle/testing/button-toggle-group-harness.js +42 -46
  232. package/esm2015/button-toggle/testing/button-toggle-harness.js +113 -111
  233. package/esm2015/card/card-module.js +30 -34
  234. package/esm2015/card/card.js +147 -203
  235. package/esm2015/card/testing/card-harness-filters.js +8 -0
  236. package/esm2015/card/testing/card-harness.js +52 -0
  237. package/esm2015/card/testing/index.js +9 -0
  238. package/esm2015/card/testing/public-api.js +10 -0
  239. package/esm2015/card/testing/testing.externs.js +0 -0
  240. package/esm2015/checkbox/checkbox-module.js +21 -29
  241. package/esm2015/checkbox/checkbox-required-validator.js +9 -13
  242. package/esm2015/checkbox/checkbox.js +315 -319
  243. package/esm2015/checkbox/testing/checkbox-harness.js +150 -148
  244. package/esm2015/chips/chip-input.js +119 -123
  245. package/esm2015/chips/chip-list.js +572 -576
  246. package/esm2015/chips/chip.js +333 -328
  247. package/esm2015/chips/chips-module.js +16 -20
  248. package/esm2015/core/animation/animation.js +12 -20
  249. package/esm2015/core/common-behaviors/common-module.js +91 -95
  250. package/esm2015/core/datetime/index.js +19 -27
  251. package/esm2015/core/datetime/native-date-adapter.js +202 -206
  252. package/esm2015/core/error/error-options.js +16 -24
  253. package/esm2015/core/line/line.js +18 -26
  254. package/esm2015/core/option/index.js +10 -14
  255. package/esm2015/core/option/optgroup.js +36 -33
  256. package/esm2015/core/option/option.js +181 -185
  257. package/esm2015/core/ripple/index.js +10 -14
  258. package/esm2015/core/ripple/ripple-ref.js +1 -1
  259. package/esm2015/core/ripple/ripple-renderer.js +1 -1
  260. package/esm2015/core/ripple/ripple.js +102 -106
  261. package/esm2015/core/selection/index.js +9 -13
  262. package/esm2015/core/selection/pseudo-checkbox/pseudo-checkbox.js +32 -36
  263. package/esm2015/core/testing/optgroup-harness.js +39 -43
  264. package/esm2015/core/testing/option-harness.js +51 -55
  265. package/esm2015/core/version.js +1 -1
  266. package/esm2015/datepicker/calendar-body.js +214 -218
  267. package/esm2015/datepicker/calendar.js +295 -303
  268. package/esm2015/datepicker/date-range-input-parts.js +214 -229
  269. package/esm2015/datepicker/date-range-input.js +244 -242
  270. package/esm2015/datepicker/date-range-picker.js +19 -23
  271. package/esm2015/datepicker/date-range-selection-strategy.js +31 -35
  272. package/esm2015/datepicker/date-selection-model.js +110 -122
  273. package/esm2015/datepicker/datepicker-base.js +418 -426
  274. package/esm2015/datepicker/datepicker-input-base.js +227 -224
  275. package/esm2015/datepicker/datepicker-input.js +111 -115
  276. package/esm2015/datepicker/datepicker-intl.js +37 -41
  277. package/esm2015/datepicker/datepicker-module.js +62 -66
  278. package/esm2015/datepicker/datepicker-toggle.js +81 -89
  279. package/esm2015/datepicker/datepicker.js +13 -17
  280. package/esm2015/datepicker/month-view.js +283 -287
  281. package/esm2015/datepicker/multi-year-view.js +198 -202
  282. package/esm2015/datepicker/public-api.js +2 -2
  283. package/esm2015/datepicker/year-view.js +220 -224
  284. package/esm2015/dialog/dialog-container.js +175 -164
  285. package/esm2015/dialog/dialog-content-directives.js +105 -114
  286. package/esm2015/dialog/dialog-module.js +32 -36
  287. package/esm2015/dialog/dialog-ref.js +17 -3
  288. package/esm2015/dialog/dialog.js +236 -240
  289. package/esm2015/dialog/testing/dialog-harness.js +58 -62
  290. package/esm2015/divider/divider-module.js +10 -14
  291. package/esm2015/divider/divider.js +33 -37
  292. package/esm2015/divider/testing/divider-harness.js +16 -20
  293. package/esm2015/expansion/accordion.js +73 -77
  294. package/esm2015/expansion/expansion-module.js +26 -30
  295. package/esm2015/expansion/expansion-panel-content.js +13 -17
  296. package/esm2015/expansion/expansion-panel-header.js +168 -180
  297. package/esm2015/expansion/expansion-panel.js +144 -152
  298. package/esm2015/expansion/testing/accordion-harness.js +24 -28
  299. package/esm2015/expansion/testing/expansion-harness.js +136 -134
  300. package/esm2015/form-field/error.js +26 -23
  301. package/esm2015/form-field/form-field-control.js +6 -10
  302. package/esm2015/form-field/form-field-module.js +31 -35
  303. package/esm2015/form-field/form-field.js +407 -409
  304. package/esm2015/form-field/hint.js +35 -29
  305. package/esm2015/form-field/label.js +8 -12
  306. package/esm2015/form-field/placeholder.js +8 -12
  307. package/esm2015/form-field/prefix.js +16 -13
  308. package/esm2015/form-field/suffix.js +16 -13
  309. package/esm2015/form-field/testing/form-field-harness.js +220 -206
  310. package/esm2015/grid-list/grid-list-module.js +26 -30
  311. package/esm2015/grid-list/grid-list.js +108 -112
  312. package/esm2015/grid-list/grid-tile.js +91 -111
  313. package/esm2015/grid-list/testing/grid-list-harness.js +62 -66
  314. package/esm2015/grid-list/testing/grid-tile-harness.js +69 -73
  315. package/esm2015/grid-list/tile-styler.js +1 -1
  316. package/esm2015/icon/icon-module.js +10 -14
  317. package/esm2015/icon/icon-registry.js +406 -410
  318. package/esm2015/icon/icon.js +228 -232
  319. package/esm2015/icon/testing/fake-icon-registry.js +66 -74
  320. package/esm2015/input/autosize.js +30 -34
  321. package/esm2015/input/input-module.js +21 -25
  322. package/esm2015/input/input.js +305 -284
  323. package/esm2015/input/testing/input-harness.js +129 -123
  324. package/esm2015/list/list-module.js +32 -36
  325. package/esm2015/list/list.js +165 -189
  326. package/esm2015/list/selection-list.js +503 -511
  327. package/esm2015/list/testing/action-list-harness.js +55 -57
  328. package/esm2015/list/testing/list-harness.js +31 -39
  329. package/esm2015/list/testing/list-item-harness-base.js +13 -17
  330. package/esm2015/list/testing/nav-list-harness.js +62 -64
  331. package/esm2015/list/testing/selection-list-harness.js +136 -138
  332. package/esm2015/menu/menu-content.js +74 -71
  333. package/esm2015/menu/menu-item.js +119 -123
  334. package/esm2015/menu/menu-module.js +29 -37
  335. package/esm2015/menu/menu-panel.js +1 -1
  336. package/esm2015/menu/menu-trigger.js +402 -405
  337. package/esm2015/menu/menu.js +329 -339
  338. package/esm2015/menu/testing/menu-harness.js +193 -189
  339. package/esm2015/paginator/paginator-intl.js +36 -40
  340. package/esm2015/paginator/paginator-module.js +16 -20
  341. package/esm2015/paginator/paginator.js +205 -209
  342. package/esm2015/paginator/testing/paginator-harness.js +91 -95
  343. package/esm2015/progress-bar/progress-bar-module.js +10 -14
  344. package/esm2015/progress-bar/progress-bar.js +114 -118
  345. package/esm2015/progress-bar/testing/progress-bar-harness.js +27 -31
  346. package/esm2015/progress-spinner/progress-spinner-module.js +17 -21
  347. package/esm2015/progress-spinner/progress-spinner.js +181 -189
  348. package/esm2015/progress-spinner/testing/progress-spinner-harness.js +28 -32
  349. package/esm2015/radio/radio-module.js +10 -14
  350. package/esm2015/radio/radio.js +437 -444
  351. package/esm2015/radio/testing/radio-harness.js +241 -243
  352. package/esm2015/select/select-module.js +23 -27
  353. package/esm2015/select/select.js +917 -918
  354. package/esm2015/select/testing/select-harness.js +138 -136
  355. package/esm2015/sidenav/drawer.js +632 -620
  356. package/esm2015/sidenav/sidenav-module.js +31 -35
  357. package/esm2015/sidenav/sidenav.js +104 -116
  358. package/esm2015/sidenav/testing/drawer-harness.js +40 -44
  359. package/esm2015/sidenav/testing/sidenav-harness.js +20 -24
  360. package/esm2015/slide-toggle/slide-toggle-module.js +27 -35
  361. package/esm2015/slide-toggle/slide-toggle-required-validator.js +9 -13
  362. package/esm2015/slide-toggle/slide-toggle.js +184 -188
  363. package/esm2015/slide-toggle/testing/slide-toggle-harness.js +123 -121
  364. package/esm2015/slider/slider-module.js +10 -14
  365. package/esm2015/slider/slider.js +640 -644
  366. package/esm2015/slider/testing/slider-harness.js +129 -127
  367. package/esm2015/snack-bar/simple-snack-bar.js +32 -36
  368. package/esm2015/snack-bar/snack-bar-container.js +144 -148
  369. package/esm2015/snack-bar/snack-bar-module.js +17 -21
  370. package/esm2015/snack-bar/snack-bar-ref.js +1 -1
  371. package/esm2015/snack-bar/snack-bar.js +208 -205
  372. package/esm2015/snack-bar/testing/snack-bar-harness.js +112 -116
  373. package/esm2015/sort/sort-header-intl.js +21 -21
  374. package/esm2015/sort/sort-header.js +200 -194
  375. package/esm2015/sort/sort-module.js +11 -15
  376. package/esm2015/sort/sort.js +92 -96
  377. package/esm2015/sort/testing/sort-harness.js +28 -32
  378. package/esm2015/sort/testing/sort-header-harness.js +66 -67
  379. package/esm2015/stepper/step-header.js +78 -82
  380. package/esm2015/stepper/step-label.js +8 -12
  381. package/esm2015/stepper/stepper-button.js +23 -31
  382. package/esm2015/stepper/stepper-icon.js +16 -20
  383. package/esm2015/stepper/stepper-intl.js +15 -19
  384. package/esm2015/stepper/stepper-module.js +40 -44
  385. package/esm2015/stepper/stepper.js +139 -155
  386. package/esm2015/table/cell.js +94 -122
  387. package/esm2015/table/row.js +90 -118
  388. package/esm2015/table/table-module.js +13 -17
  389. package/esm2015/table/table.js +26 -30
  390. package/esm2015/table/testing/cell-harness.js +56 -68
  391. package/esm2015/table/testing/row-harness.js +90 -102
  392. package/esm2015/table/testing/table-harness.js +65 -69
  393. package/esm2015/table/text-column.js +17 -21
  394. package/esm2015/tabs/index.js +4 -2
  395. package/esm2015/tabs/ink-bar.js +55 -59
  396. package/esm2015/tabs/paginated-tab-header.js +415 -419
  397. package/esm2015/tabs/tab-body.js +179 -191
  398. package/esm2015/tabs/tab-content.js +21 -16
  399. package/esm2015/tabs/tab-group.js +263 -271
  400. package/esm2015/tabs/tab-header.js +69 -77
  401. package/esm2015/tabs/tab-label-wrapper.js +29 -33
  402. package/esm2015/tabs/tab-label.js +16 -13
  403. package/esm2015/tabs/tab-nav-bar/tab-nav-bar.js +199 -215
  404. package/esm2015/tabs/tab.js +80 -83
  405. package/esm2015/tabs/tabs-module.js +38 -42
  406. package/esm2015/tabs/testing/tab-group-harness.js +52 -56
  407. package/esm2015/tabs/testing/tab-harness.js +78 -82
  408. package/esm2015/toolbar/testing/index.js +9 -0
  409. package/esm2015/toolbar/testing/public-api.js +10 -0
  410. package/esm2015/toolbar/testing/testing.externs.js +0 -0
  411. package/esm2015/toolbar/testing/toolbar-harness-filters.js +8 -0
  412. package/esm2015/toolbar/testing/toolbar-harness.js +47 -0
  413. package/esm2015/toolbar/toolbar-module.js +10 -14
  414. package/esm2015/toolbar/toolbar.js +61 -69
  415. package/esm2015/tooltip/testing/tooltip-harness.js +43 -47
  416. package/esm2015/tooltip/tooltip-module.js +17 -21
  417. package/esm2015/tooltip/tooltip.js +502 -497
  418. package/esm2015/tree/data-source/flat-data-source.js +1 -1
  419. package/esm2015/tree/node.js +99 -111
  420. package/esm2015/tree/outlet.js +19 -23
  421. package/esm2015/tree/padding.js +13 -17
  422. package/esm2015/tree/toggle.js +15 -19
  423. package/esm2015/tree/tree-module.js +10 -14
  424. package/esm2015/tree/tree.js +23 -27
  425. package/expansion/testing/expansion-harness.d.ts +2 -0
  426. package/fesm2015/autocomplete/testing.js +98 -95
  427. package/fesm2015/autocomplete/testing.js.map +1 -1
  428. package/fesm2015/autocomplete.js +677 -687
  429. package/fesm2015/autocomplete.js.map +1 -1
  430. package/fesm2015/badge/testing.js +73 -76
  431. package/fesm2015/badge/testing.js.map +1 -1
  432. package/fesm2015/badge.js +195 -201
  433. package/fesm2015/badge.js.map +1 -1
  434. package/fesm2015/bottom-sheet/testing.js +28 -31
  435. package/fesm2015/bottom-sheet/testing.js.map +1 -1
  436. package/fesm2015/bottom-sheet.js +297 -306
  437. package/fesm2015/bottom-sheet.js.map +1 -1
  438. package/fesm2015/button/testing.js +59 -56
  439. package/fesm2015/button/testing.js.map +1 -1
  440. package/fesm2015/button-toggle/testing.js +155 -155
  441. package/fesm2015/button-toggle/testing.js.map +1 -1
  442. package/fesm2015/button-toggle.js +377 -378
  443. package/fesm2015/button-toggle.js.map +1 -1
  444. package/fesm2015/button.js +129 -133
  445. package/fesm2015/button.js.map +1 -1
  446. package/fesm2015/card/testing.js +79 -0
  447. package/fesm2015/card/testing.js.map +1 -0
  448. package/fesm2015/card.js +175 -220
  449. package/fesm2015/card.js.map +1 -1
  450. package/fesm2015/checkbox/testing.js +149 -146
  451. package/fesm2015/checkbox/testing.js.map +1 -1
  452. package/fesm2015/checkbox.js +342 -354
  453. package/fesm2015/checkbox.js.map +1 -1
  454. package/fesm2015/chips.js +1039 -1039
  455. package/fesm2015/chips.js.map +1 -1
  456. package/fesm2015/core/testing.js +88 -94
  457. package/fesm2015/core/testing.js.map +1 -1
  458. package/fesm2015/core.js +729 -773
  459. package/fesm2015/core.js.map +1 -1
  460. package/fesm2015/datepicker.js +2821 -2884
  461. package/fesm2015/datepicker.js.map +1 -1
  462. package/fesm2015/dialog/testing.js +57 -60
  463. package/fesm2015/dialog/testing.js.map +1 -1
  464. package/fesm2015/dialog.js +564 -549
  465. package/fesm2015/dialog.js.map +1 -1
  466. package/fesm2015/divider/testing.js +15 -18
  467. package/fesm2015/divider/testing.js.map +1 -1
  468. package/fesm2015/divider.js +41 -47
  469. package/fesm2015/divider.js.map +1 -1
  470. package/fesm2015/expansion/testing.js +159 -159
  471. package/fesm2015/expansion/testing.js.map +1 -1
  472. package/fesm2015/expansion.js +422 -446
  473. package/fesm2015/expansion.js.map +1 -1
  474. package/fesm2015/form-field/testing.js +219 -204
  475. package/fesm2015/form-field/testing.js.map +1 -1
  476. package/fesm2015/form-field.js +538 -532
  477. package/fesm2015/form-field.js.map +1 -1
  478. package/fesm2015/grid-list/testing.js +129 -135
  479. package/fesm2015/grid-list/testing.js.map +1 -1
  480. package/fesm2015/grid-list.js +221 -242
  481. package/fesm2015/grid-list.js.map +1 -1
  482. package/fesm2015/icon/testing.js +65 -71
  483. package/fesm2015/icon/testing.js.map +1 -1
  484. package/fesm2015/icon.js +660 -669
  485. package/fesm2015/icon.js.map +1 -1
  486. package/fesm2015/input/testing.js +128 -121
  487. package/fesm2015/input/testing.js.map +1 -1
  488. package/fesm2015/input.js +353 -337
  489. package/fesm2015/input.js.map +1 -1
  490. package/fesm2015/list/testing.js +298 -307
  491. package/fesm2015/list/testing.js.map +1 -1
  492. package/fesm2015/list.js +698 -725
  493. package/fesm2015/list.js.map +1 -1
  494. package/fesm2015/menu/testing.js +192 -186
  495. package/fesm2015/menu/testing.js.map +1 -1
  496. package/fesm2015/menu.js +948 -962
  497. package/fesm2015/menu.js.map +1 -1
  498. package/fesm2015/paginator/testing.js +90 -93
  499. package/fesm2015/paginator/testing.js.map +1 -1
  500. package/fesm2015/paginator.js +247 -256
  501. package/fesm2015/paginator.js.map +1 -1
  502. package/fesm2015/progress-bar/testing.js +26 -29
  503. package/fesm2015/progress-bar/testing.js.map +1 -1
  504. package/fesm2015/progress-bar.js +122 -128
  505. package/fesm2015/progress-bar.js.map +1 -1
  506. package/fesm2015/progress-spinner/testing.js +27 -30
  507. package/fesm2015/progress-spinner/testing.js.map +1 -1
  508. package/fesm2015/progress-spinner.js +196 -205
  509. package/fesm2015/progress-spinner.js.map +1 -1
  510. package/fesm2015/radio/testing.js +240 -240
  511. package/fesm2015/radio/testing.js.map +1 -1
  512. package/fesm2015/radio.js +447 -453
  513. package/fesm2015/radio.js.map +1 -1
  514. package/fesm2015/select/testing.js +137 -134
  515. package/fesm2015/select/testing.js.map +1 -1
  516. package/fesm2015/select.js +939 -941
  517. package/fesm2015/select.js.map +1 -1
  518. package/fesm2015/sidenav/testing.js +58 -64
  519. package/fesm2015/sidenav/testing.js.map +1 -1
  520. package/fesm2015/sidenav.js +765 -762
  521. package/fesm2015/sidenav.js.map +1 -1
  522. package/fesm2015/slide-toggle/testing.js +122 -119
  523. package/fesm2015/slide-toggle/testing.js.map +1 -1
  524. package/fesm2015/slide-toggle.js +217 -229
  525. package/fesm2015/slide-toggle.js.map +1 -1
  526. package/fesm2015/slider/testing.js +128 -125
  527. package/fesm2015/slider/testing.js.map +1 -1
  528. package/fesm2015/slider.js +648 -654
  529. package/fesm2015/slider.js.map +1 -1
  530. package/fesm2015/snack-bar/testing.js +111 -114
  531. package/fesm2015/snack-bar/testing.js.map +1 -1
  532. package/fesm2015/snack-bar.js +426 -431
  533. package/fesm2015/snack-bar.js.map +1 -1
  534. package/fesm2015/sort/testing.js +92 -95
  535. package/fesm2015/sort/testing.js.map +1 -1
  536. package/fesm2015/sort.js +320 -318
  537. package/fesm2015/sort.js.map +1 -1
  538. package/fesm2015/stepper.js +312 -345
  539. package/fesm2015/stepper.js.map +1 -1
  540. package/fesm2015/table/testing.js +208 -229
  541. package/fesm2015/table/testing.js.map +1 -1
  542. package/fesm2015/table.js +235 -286
  543. package/fesm2015/table.js.map +1 -1
  544. package/fesm2015/tabs/testing.js +128 -134
  545. package/fesm2015/tabs/testing.js.map +1 -1
  546. package/fesm2015/tabs.js +1362 -1399
  547. package/fesm2015/tabs.js.map +1 -1
  548. package/fesm2015/toolbar/testing.js +74 -0
  549. package/fesm2015/toolbar/testing.js.map +1 -0
  550. package/fesm2015/toolbar.js +69 -78
  551. package/fesm2015/toolbar.js.map +1 -1
  552. package/fesm2015/tooltip/testing.js +42 -45
  553. package/fesm2015/tooltip/testing.js.map +1 -1
  554. package/fesm2015/tooltip.js +517 -513
  555. package/fesm2015/tooltip.js.map +1 -1
  556. package/fesm2015/tree.js +173 -197
  557. package/fesm2015/tree.js.map +1 -1
  558. package/form-field/error.d.ts +7 -0
  559. package/form-field/hint.d.ts +10 -0
  560. package/form-field/index.metadata.json +1 -1
  561. package/form-field/prefix.d.ts +7 -0
  562. package/form-field/suffix.d.ts +7 -0
  563. package/form-field/testing/form-field-harness.d.ts +8 -0
  564. package/grid-list/grid-list.d.ts +2 -1
  565. package/grid-list/index.metadata.json +1 -1
  566. package/grid-list/tile-styler.d.ts +10 -5
  567. package/input/_input-theme.scss +2 -2
  568. package/input/index.metadata.json +1 -1
  569. package/input/input.d.ts +6 -2
  570. package/input/testing/input-harness.d.ts +2 -0
  571. package/list/index.metadata.json +1 -1
  572. package/list/testing/action-list-harness.d.ts +2 -0
  573. package/list/testing/nav-list-harness.d.ts +2 -0
  574. package/list/testing/selection-list-harness.d.ts +2 -0
  575. package/menu/index.metadata.json +1 -1
  576. package/menu/menu-content.d.ts +7 -1
  577. package/menu/menu-panel.d.ts +1 -0
  578. package/menu/menu.d.ts +4 -0
  579. package/menu/testing/menu-harness.d.ts +4 -0
  580. package/package.json +6 -6
  581. package/prebuilt-themes/deeppurple-amber.css +1 -1
  582. package/prebuilt-themes/indigo-pink.css +1 -1
  583. package/prebuilt-themes/pink-bluegrey.css +1 -1
  584. package/prebuilt-themes/purple-green.css +1 -1
  585. package/progress-spinner/index.metadata.json +1 -1
  586. package/radio/index.metadata.json +1 -1
  587. package/radio/radio.d.ts +6 -0
  588. package/radio/testing/radio-harness.d.ts +2 -0
  589. package/schematics/migration.json +5 -0
  590. package/schematics/ng-add/index.js +2 -2
  591. package/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +3 -3
  592. package/schematics/ng-generate/navigation/schema.json +5 -0
  593. package/schematics/ng-update/data/index.js +1 -1
  594. package/schematics/ng-update/index.d.ts +2 -0
  595. package/schematics/ng-update/index.js +7 -2
  596. package/schematics/ng-update/migrations/hammer-gestures-v9/hammer-gestures-migration.js +639 -639
  597. package/schematics/ng-update/migrations/misc-ripples-v7/ripple-speed-factor-migration.js +1 -1
  598. package/select/index.metadata.json +1 -1
  599. package/select/select.d.ts +6 -0
  600. package/select/testing/select-harness.d.ts +2 -0
  601. package/sidenav/drawer.d.ts +15 -3
  602. package/sidenav/index.metadata.json +1 -1
  603. package/slide-toggle/index.metadata.json +1 -1
  604. package/slide-toggle/testing/slide-toggle-harness.d.ts +2 -0
  605. package/slider/testing/slider-harness.d.ts +2 -0
  606. package/snack-bar/index.metadata.json +1 -1
  607. package/snack-bar/simple-snack-bar.d.ts +13 -1
  608. package/snack-bar/snack-bar-container.d.ts +16 -3
  609. package/snack-bar/snack-bar-ref.d.ts +3 -3
  610. package/snack-bar/snack-bar.d.ts +10 -3
  611. package/sort/index.metadata.json +1 -1
  612. package/sort/sort-header-intl.d.ts +5 -1
  613. package/sort/sort-header.d.ts +3 -1
  614. package/sort/testing/sort-header-harness.d.ts +6 -2
  615. package/tabs/index.d.ts +3 -1
  616. package/tabs/index.metadata.json +1 -1
  617. package/tabs/tab-content.d.ts +7 -1
  618. package/tabs/tab-label.d.ts +7 -0
  619. package/toolbar/testing/index.d.ts +8 -0
  620. package/toolbar/testing/package.json +9 -0
  621. package/toolbar/testing/public-api.d.ts +9 -0
  622. package/toolbar/testing/toolbar-harness-filters.d.ts +13 -0
  623. package/toolbar/testing/toolbar-harness.d.ts +31 -0
  624. package/tooltip/index.metadata.json +1 -1
  625. package/tooltip/tooltip.d.ts +1 -0
  626. package/tree/data-source/flat-data-source.d.ts +4 -4
  627. package/tree/index.metadata.json +1 -1
@@ -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, MatOptgroup, MatOptionSelectionChange, _countGroupLabelsBeforeOption, _getOptionScrollPosition, MatOptionModule, MatCommonModule } from '@angular/material/core';
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
- let MatAutocomplete = /** @class */ (() => {
55
- class MatAutocomplete extends _MatAutocompleteMixinBase {
56
- constructor(_changeDetectorRef, _elementRef, defaults) {
57
- super();
58
- this._changeDetectorRef = _changeDetectorRef;
59
- this._elementRef = _elementRef;
60
- this._activeOptionChanges = Subscription.EMPTY;
61
- /** Whether the autocomplete panel should be visible, depending on option length. */
62
- this.showPanel = false;
63
- this._isOpen = false;
64
- /** Function that maps an option's control value to its display value in the trigger. */
65
- this.displayWith = null;
66
- /** Event that is emitted whenever an option from the list is selected. */
67
- this.optionSelected = new EventEmitter();
68
- /** Event that is emitted when the autocomplete panel is opened. */
69
- this.opened = new EventEmitter();
70
- /** Event that is emitted when the autocomplete panel is closed. */
71
- this.closed = new EventEmitter();
72
- /** Emits whenever an option is activated using the keyboard. */
73
- this.optionActivated = new EventEmitter();
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
- ngOnDestroy() {
115
- this._activeOptionChanges.unsubscribe();
116
- }
117
- /**
118
- * Sets the panel scrollTop. This allows us to manually scroll to display options
119
- * above or below the fold, as they are not actually being focused when active.
120
- */
121
- _setScrollTop(scrollTop) {
122
- if (this.panel) {
123
- this.panel.nativeElement.scrollTop = scrollTop;
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
- /** Returns the panel's scrollTop. */
127
- _getScrollTop() {
128
- return this.panel ? this.panel.nativeElement.scrollTop : 0;
129
- }
130
- /** Panel should hide itself when the option list is empty. */
131
- _setVisibility() {
132
- this.showPanel = !!this.options.length;
133
- this._setVisibilityClasses(this._classList);
134
- this._changeDetectorRef.markForCheck();
135
- }
136
- /** Emits the `select` event. */
137
- _emitSelectEvent(option) {
138
- const event = new MatAutocompleteSelectedEvent(this, option);
139
- this.optionSelected.emit(event);
140
- }
141
- /** Sets the autocomplete visibility classes on a classlist based on the panel is visible. */
142
- _setVisibilityClasses(classList) {
143
- classList['mat-autocomplete-visible'] = this.showPanel;
144
- classList['mat-autocomplete-hidden'] = !this.showPanel;
145
- }
146
- }
147
- MatAutocomplete.decorators = [
148
- { type: Component, args: [{
149
- selector: 'mat-autocomplete',
150
- 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",
151
- encapsulation: ViewEncapsulation.None,
152
- changeDetection: ChangeDetectionStrategy.OnPush,
153
- exportAs: 'matAutocomplete',
154
- inputs: ['disableRipple'],
155
- host: {
156
- 'class': 'mat-autocomplete'
157
- },
158
- providers: [
159
- { provide: MAT_OPTION_PARENT_COMPONENT, useExisting: MatAutocomplete }
160
- ],
161
- 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"]
162
- },] }
163
- ];
164
- MatAutocomplete.ctorParameters = () => [
165
- { type: ChangeDetectorRef },
166
- { type: ElementRef },
167
- { type: undefined, decorators: [{ type: Inject, args: [MAT_AUTOCOMPLETE_DEFAULT_OPTIONS,] }] }
168
- ];
169
- MatAutocomplete.propDecorators = {
170
- template: [{ type: ViewChild, args: [TemplateRef, { static: true },] }],
171
- panel: [{ type: ViewChild, args: ['panel',] }],
172
- options: [{ type: ContentChildren, args: [MatOption, { descendants: true },] }],
173
- optionGroups: [{ type: ContentChildren, args: [MatOptgroup, { descendants: true },] }],
174
- displayWith: [{ type: Input }],
175
- autoActiveFirstOption: [{ type: Input }],
176
- panelWidth: [{ type: Input }],
177
- optionSelected: [{ type: Output }],
178
- opened: [{ type: Output }],
179
- closed: [{ type: Output }],
180
- optionActivated: [{ type: Output }],
181
- classList: [{ type: Input, args: ['class',] }]
182
- };
183
- return MatAutocomplete;
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
- let MatAutocompleteOrigin = /** @class */ (() => {
198
- class MatAutocompleteOrigin {
199
- constructor(
200
- /** Reference to the element on which the directive is applied. */
201
- elementRef) {
202
- this.elementRef = elementRef;
203
- }
204
- }
205
- MatAutocompleteOrigin.decorators = [
206
- { type: Directive, args: [{
207
- selector: '[matAutocompleteOrigin]',
208
- exportAs: 'matAutocompleteOrigin',
209
- },] }
210
- ];
211
- MatAutocompleteOrigin.ctorParameters = () => [
212
- { type: ElementRef }
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
- let MatAutocompleteTrigger = /** @class */ (() => {
264
- class MatAutocompleteTrigger {
265
- constructor(_element, _overlay, _viewContainerRef, _zone, _changeDetectorRef, scrollStrategy, _dir, _formField, _document, _viewportRuler) {
266
- this._element = _element;
267
- this._overlay = _overlay;
268
- this._viewContainerRef = _viewContainerRef;
269
- this._zone = _zone;
270
- this._changeDetectorRef = _changeDetectorRef;
271
- this._dir = _dir;
272
- this._formField = _formField;
273
- this._document = _document;
274
- this._viewportRuler = _viewportRuler;
275
- this._componentDestroyed = false;
276
- this._autocompleteDisabled = false;
277
- /** Whether or not the label state is being overridden. */
278
- this._manuallyFloatingLabel = false;
279
- /** Subscription to viewport size changes. */
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 disabled. When disabled, the element will
333
- * act as a regular input and the user won't be able to open the panel.
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
- get autocompleteDisabled() { return this._autocompleteDisabled; }
336
- set autocompleteDisabled(value) {
337
- this._autocompleteDisabled = coerceBooleanProperty(value);
338
- }
339
- ngAfterViewInit() {
340
- const window = this._getWindow();
341
- if (typeof window !== 'undefined') {
342
- this._zone.runOutsideAngular(() => window.addEventListener('blur', this._windowBlurHandler));
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
- ngOnChanges(changes) {
346
- if (changes['position'] && this._positionStrategy) {
347
- this._setStrategyPositions(this._positionStrategy);
348
- if (this.panelOpen) {
349
- this._overlayRef.updatePosition();
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
- ngOnDestroy() {
354
- const window = this._getWindow();
355
- if (typeof window !== 'undefined') {
356
- window.removeEventListener('blur', this._windowBlurHandler);
357
- }
358
- this._viewportSubscription.unsubscribe();
359
- this._componentDestroyed = true;
360
- this._destroyPanel();
361
- this._closeKeyEventStream.complete();
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
- /** Whether or not the autocomplete panel is open. */
364
- get panelOpen() {
365
- return this._overlayAttached && this.autocomplete.showPanel;
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
- /** Opens the autocomplete suggestion panel. */
368
- openPanel() {
369
- this._attachOverlay();
370
- this._floatLabel();
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
- /** Closes the autocomplete suggestion panel. */
373
- closePanel() {
374
- this._resetLabel();
375
- if (!this._overlayAttached) {
376
- return;
377
- }
378
- if (this.panelOpen) {
379
- // Only emit if the panel was visible.
380
- this.autocomplete.closed.emit();
381
- }
382
- this.autocomplete._isOpen = this._overlayAttached = false;
383
- if (this._overlayRef && this._overlayRef.hasAttached()) {
384
- this._overlayRef.detach();
385
- this._closingActionsSubscription.unsubscribe();
386
- }
387
- // Note that in some cases this can end up being called after the component is destroyed.
388
- // Add a check to ensure that we don't try to run change detection on a destroyed view.
389
- if (!this._componentDestroyed) {
390
- // We need to trigger change detection manually, because
391
- // `fromEvent` doesn't seem to do it at the proper time.
392
- // This ensures that the label is reset when the
393
- // user clicks outside.
394
- this._changeDetectorRef.detectChanges();
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
- * Updates the position of the autocomplete suggestion panel to ensure that it fits all options
399
- * within the viewport.
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
- * A stream of actions that should close the autocomplete panel, including
408
- * when an option is selected, on blur, and when TAB is pressed.
409
- */
410
- get panelClosingActions() {
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
- return null;
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.activeOption && keyCode === ENTER && this.panelOpen) {
464
- this.activeOption._selectViaInteraction();
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
- _handleFocus() {
503
- if (!this._canOpenOnNextFocus) {
504
- this._canOpenOnNextFocus = true;
505
- }
506
- else if (this._canOpen()) {
507
- this._previousValue = this._element.nativeElement.value;
508
- this._attachOverlay();
509
- this._floatLabel(true);
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
- * In "auto" mode, the label will animate down as soon as focus is lost.
514
- * This causes the value to jump when selecting an option with the mouse.
515
- * This method manually floats the label until the panel can be closed.
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
- /** If the label has been manually elevated, return it to its normal state. */
530
- _resetLabel() {
531
- if (this._manuallyFloatingLabel) {
532
- this._formField.floatLabel = 'auto';
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
- * Given that we are not actually focusing active options, we must manually adjust scroll
538
- * to reveal options below the fold. First, we find the offset of the option from the top
539
- * of the panel. If that offset is below the fold, the new scrollTop will be the offset -
540
- * the panel height + the option height, so the active option will be just visible at the
541
- * bottom of the panel. If that offset is above the top of the visible panel, the new scrollTop
542
- * will become the offset. If that offset is visible within the panel already, the scrollTop is
543
- * not adjusted.
544
- */
545
- _scrollToOption() {
546
- const index = this.autocomplete._keyManager.activeItemIndex || 0;
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
- const newScrollPosition = _getOptionScrollPosition(index + labelCount, AUTOCOMPLETE_OPTION_HEIGHT, this.autocomplete._getScrollTop(), AUTOCOMPLETE_PANEL_HEIGHT);
556
- this.autocomplete._setScrollTop(newScrollPosition);
519
+ this._formField.floatLabel = 'always';
557
520
  }
521
+ this._manuallyFloatingLabel = true;
558
522
  }
559
- /**
560
- * This method listens to a stream of panel closing actions and resets the
561
- * stream every time the option list changes.
562
- */
563
- _subscribeToClosingActions() {
564
- const firstStable = this._zone.onStable.asObservable().pipe(take(1));
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
- _setTriggerValue(value) {
604
- const toDisplay = this.autocomplete && this.autocomplete.displayWith ?
605
- this.autocomplete.displayWith(value) :
606
- value;
607
- // Simply falling back to an empty string if the display value is falsy does not work properly.
608
- // The display value can also be the number zero and shouldn't fall back to an empty string.
609
- const inputValue = toDisplay != null ? toDisplay : '';
610
- // If it's used within a `MatFormField`, we should set it through the property so it can go
611
- // through change detection.
612
- if (this._formField) {
613
- this._formField._control.value = inputValue;
614
- }
615
- else {
616
- this._element.nativeElement.value = inputValue;
617
- }
618
- this._previousValue = inputValue;
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
- * This method closes the panel, and if a value is specified, also sets the associated
622
- * control to that value. It will also mark the control as dirty if this interaction
623
- * stemmed from the user.
624
- */
625
- _setValueAndClose(event) {
626
- if (event && event.source) {
627
- this._clearPreviousSelectedOption(event.source);
628
- this._setTriggerValue(event.source.value);
629
- this._onChange(event.source.value);
630
- this._element.nativeElement.focus();
631
- this.autocomplete._emitSelectEvent(event.source);
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
- * Clear any previous selected option and emit a selection change event for this option
637
- */
638
- _clearPreviousSelectedOption(skip) {
639
- this.autocomplete.options.forEach(option => {
640
- if (option != skip && option.selected) {
641
- option.deselect();
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
- _attachOverlay() {
646
- if (!this.autocomplete) {
647
- throw getMatAutocompleteMissingPanelError();
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
- _getOverlayPosition() {
706
- const strategy = this._overlay.position()
707
- .flexibleConnectedTo(this._getConnectedElement())
708
- .withFlexibleDimensions(false)
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
- _getConnectedElement() {
743
- if (this.connectedTo) {
744
- return this.connectedTo.elementRef;
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
- _getPanelWidth() {
749
- return this.autocomplete.panelWidth || this._getHostWidth();
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
- /** Returns the width of the input element, so the panel width can match it. */
752
- _getHostWidth() {
753
- return this._getConnectedElement().nativeElement.getBoundingClientRect().width;
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
- * Resets the active item to -1 so arrow events will activate the
757
- * correct options, or to 0 if the consumer opted into it.
758
- */
759
- _resetActiveItem() {
760
- this.autocomplete._keyManager.setActiveItem(this.autocomplete.autoActiveFirstOption ? 0 : -1);
761
- }
762
- /** Determines whether the panel can be opened. */
763
- _canOpen() {
764
- const element = this._element.nativeElement;
765
- return !element.readOnly && !element.disabled && !this._autocompleteDisabled;
766
- }
767
- /** Use defaultView of injected document if available or fallback to global window reference */
768
- _getWindow() {
769
- var _a;
770
- return ((_a = this._document) === null || _a === void 0 ? void 0 : _a.defaultView) || window;
771
- }
772
- }
773
- MatAutocompleteTrigger.decorators = [
774
- { type: Directive, args: [{
775
- selector: `input[matAutocomplete], textarea[matAutocomplete]`,
776
- host: {
777
- 'class': 'mat-autocomplete-trigger',
778
- '[attr.autocomplete]': 'autocompleteAttribute',
779
- '[attr.role]': 'autocompleteDisabled ? null : "combobox"',
780
- '[attr.aria-autocomplete]': 'autocompleteDisabled ? null : "list"',
781
- '[attr.aria-activedescendant]': '(panelOpen && activeOption) ? activeOption.id : null',
782
- '[attr.aria-expanded]': 'autocompleteDisabled ? null : panelOpen.toString()',
783
- '[attr.aria-owns]': '(autocompleteDisabled || !panelOpen) ? null : autocomplete?.id',
784
- '[attr.aria-haspopup]': '!autocompleteDisabled',
785
- // Note: we use `focusin`, as opposed to `focus`, in order to open the panel
786
- // a little earlier. This avoids issues where IE delays the focusing of the input.
787
- '(focusin)': '_handleFocus()',
788
- '(blur)': '_onTouched()',
789
- '(input)': '_handleInput($event)',
790
- '(keydown)': '_handleKeydown($event)',
791
- },
792
- exportAs: 'matAutocompleteTrigger',
793
- providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR]
794
- },] }
795
- ];
796
- MatAutocompleteTrigger.ctorParameters = () => [
797
- { type: ElementRef },
798
- { type: Overlay },
799
- { type: ViewContainerRef },
800
- { type: NgZone },
801
- { type: ChangeDetectorRef },
802
- { type: undefined, decorators: [{ type: Inject, args: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY,] }] },
803
- { type: Directionality, decorators: [{ type: Optional }] },
804
- { type: MatFormField, decorators: [{ type: Optional }, { type: Inject, args: [MAT_FORM_FIELD,] }, { type: Host }] },
805
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
806
- { type: ViewportRuler }
807
- ];
808
- MatAutocompleteTrigger.propDecorators = {
809
- autocomplete: [{ type: Input, args: ['matAutocomplete',] }],
810
- position: [{ type: Input, args: ['matAutocompletePosition',] }],
811
- connectedTo: [{ type: Input, args: ['matAutocompleteConnectedTo',] }],
812
- autocompleteAttribute: [{ type: Input, args: ['autocomplete',] }],
813
- autocompleteDisabled: [{ type: Input, args: ['matAutocompleteDisabled',] }]
814
- };
815
- return MatAutocompleteTrigger;
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
- let MatAutocompleteModule = /** @class */ (() => {
826
- class MatAutocompleteModule {
827
- }
828
- MatAutocompleteModule.decorators = [
829
- { type: NgModule, args: [{
830
- imports: [MatOptionModule, OverlayModule, MatCommonModule, CommonModule],
831
- exports: [
832
- CdkScrollableModule,
833
- MatAutocomplete,
834
- MatOptionModule,
835
- MatAutocompleteTrigger,
836
- MatAutocompleteOrigin,
837
- MatCommonModule
838
- ],
839
- declarations: [MatAutocomplete, MatAutocompleteTrigger, MatAutocompleteOrigin],
840
- providers: [MAT_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY_PROVIDER],
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