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