@angular/cdk-experimental 13.0.0-next.7 → 13.0.0-rc.2

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 (329) hide show
  1. package/column-resize/column-resize-directives/column-resize-flex.d.ts +3 -0
  2. package/column-resize/column-resize-directives/column-resize.d.ts +3 -0
  3. package/column-resize/column-resize-directives/default-enabled-column-resize-flex.d.ts +3 -0
  4. package/column-resize/column-resize-directives/default-enabled-column-resize.d.ts +3 -0
  5. package/column-resize/column-resize-module.d.ts +11 -7
  6. package/column-resize/column-resize-notifier.d.ts +5 -7
  7. package/column-resize/column-resize.d.ts +3 -0
  8. package/column-resize/column-resize_public_index.d.ts +4 -0
  9. package/column-resize/column-size-store.d.ts +3 -7
  10. package/column-resize/event-dispatcher.d.ts +3 -0
  11. package/column-resize/index.d.ts +5 -2
  12. package/column-resize/overlay-handle.d.ts +3 -0
  13. package/column-resize/package.json +6 -6
  14. package/column-resize/resizable.d.ts +3 -0
  15. package/column-resize/resize-strategy.d.ts +7 -0
  16. package/combobox/combobox-module.d.ts +8 -7
  17. package/combobox/combobox-panel.d.ts +5 -2
  18. package/combobox/combobox-popup.d.ts +3 -0
  19. package/combobox/combobox.d.ts +8 -5
  20. package/combobox/combobox_public_index.d.ts +4 -0
  21. package/combobox/index.d.ts +5 -1
  22. package/combobox/package.json +6 -6
  23. package/dialog/dialog-container.d.ts +4 -1
  24. package/dialog/dialog-module.d.ts +8 -7
  25. package/dialog/dialog.d.ts +3 -0
  26. package/dialog/dialog_public_index.d.ts +4 -0
  27. package/dialog/index.d.ts +5 -1
  28. package/dialog/package.json +6 -6
  29. package/esm2020/column-resize/column-resize-directives/column-resize-flex.mjs +42 -0
  30. package/esm2020/column-resize/column-resize-directives/column-resize.mjs +42 -0
  31. package/{esm2015/column-resize/column-resize-directives/constants.js → esm2020/column-resize/column-resize-directives/constants.mjs} +0 -0
  32. package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize-flex.mjs +48 -0
  33. package/esm2020/column-resize/column-resize-directives/default-enabled-column-resize.mjs +48 -0
  34. package/esm2020/column-resize/column-resize-module.mjs +46 -0
  35. package/esm2020/column-resize/column-resize-notifier.mjs +52 -0
  36. package/esm2020/column-resize/column-resize.mjs +82 -0
  37. package/esm2020/column-resize/column-resize_public_index.mjs +5 -0
  38. package/esm2020/column-resize/column-size-store.mjs +20 -0
  39. package/esm2020/column-resize/event-dispatcher.mjs +70 -0
  40. package/esm2020/column-resize/index.mjs +9 -0
  41. package/esm2020/column-resize/overlay-handle.mjs +146 -0
  42. package/{esm2015/column-resize/public-api.js → esm2020/column-resize/public-api.mjs} +0 -0
  43. package/esm2020/column-resize/resizable.mjs +195 -0
  44. package/{esm2015/column-resize/resize-ref.js → esm2020/column-resize/resize-ref.mjs} +1 -1
  45. package/esm2020/column-resize/resize-strategy.mjs +230 -0
  46. package/{esm2015/column-resize/selectors.js → esm2020/column-resize/selectors.mjs} +0 -0
  47. package/esm2020/combobox/combobox-module.mjs +28 -0
  48. package/esm2020/combobox/combobox-panel.mjs +48 -0
  49. package/esm2020/combobox/combobox-popup.mjs +83 -0
  50. package/esm2020/combobox/combobox.mjs +261 -0
  51. package/esm2020/combobox/combobox_public_index.mjs +5 -0
  52. package/esm2020/combobox/index.mjs +9 -0
  53. package/{esm2015/combobox/public-api.js → esm2020/combobox/public-api.mjs} +0 -0
  54. package/{esm2015/dialog/dialog-config.js → esm2020/dialog/dialog-config.mjs} +0 -0
  55. package/esm2020/dialog/dialog-container.mjs +310 -0
  56. package/esm2020/dialog/dialog-injectors.mjs +30 -0
  57. package/esm2020/dialog/dialog-module.mjs +57 -0
  58. package/esm2020/dialog/dialog-ref.mjs +116 -0
  59. package/esm2020/dialog/dialog.mjs +252 -0
  60. package/esm2020/dialog/dialog_public_index.mjs +5 -0
  61. package/esm2020/dialog/index.mjs +9 -0
  62. package/{esm2015/dialog/public-api.js → esm2020/dialog/public-api.mjs} +0 -0
  63. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  64. package/esm2020/listbox/index.mjs +9 -0
  65. package/esm2020/listbox/listbox-module.mjs +24 -0
  66. package/esm2020/listbox/listbox.mjs +499 -0
  67. package/esm2020/listbox/listbox_public_index.mjs +5 -0
  68. package/{esm2015/listbox/public-api.js → esm2020/listbox/public-api.mjs} +0 -0
  69. package/esm2020/menu/context-menu.mjs +287 -0
  70. package/esm2020/menu/index.mjs +9 -0
  71. package/esm2020/menu/menu-aim.mjs +199 -0
  72. package/esm2020/menu/menu-bar.mjs +272 -0
  73. package/{esm2015/menu/menu-errors.js → esm2020/menu/menu-errors.mjs} +1 -1
  74. package/esm2020/menu/menu-group.mjs +68 -0
  75. package/{esm2015/menu/menu-interface.js → esm2020/menu/menu-interface.mjs} +0 -0
  76. package/esm2020/menu/menu-item-checkbox.mjs +48 -0
  77. package/esm2020/menu/menu-item-radio.mjs +90 -0
  78. package/esm2020/menu/menu-item-selectable.mjs +57 -0
  79. package/esm2020/menu/menu-item-trigger.mjs +361 -0
  80. package/esm2020/menu/menu-item.mjs +291 -0
  81. package/esm2020/menu/menu-module.mjs +64 -0
  82. package/esm2020/menu/menu-panel.mjs +37 -0
  83. package/{esm2015/menu/menu-stack.js → esm2020/menu/menu-stack.mjs} +0 -0
  84. package/esm2020/menu/menu.mjs +316 -0
  85. package/esm2020/menu/menu_public_index.mjs +5 -0
  86. package/{esm2015/menu/pointer-focus-tracker.js → esm2020/menu/pointer-focus-tracker.mjs} +1 -1
  87. package/{esm2015/menu/public-api.js → esm2020/menu/public-api.mjs} +0 -0
  88. package/{esm2015/popover-edit/constants.js → esm2020/popover-edit/constants.mjs} +0 -0
  89. package/esm2020/popover-edit/edit-event-dispatcher.mjs +215 -0
  90. package/esm2020/popover-edit/edit-ref.mjs +84 -0
  91. package/esm2020/popover-edit/edit-services.mjs +48 -0
  92. package/esm2020/popover-edit/focus-dispatcher.mjs +82 -0
  93. package/esm2020/popover-edit/focus-escape-notifier.mjs +63 -0
  94. package/{esm2015/popover-edit/form-value-container.js → esm2020/popover-edit/form-value-container.mjs} +0 -0
  95. package/esm2020/popover-edit/index.mjs +9 -0
  96. package/esm2020/popover-edit/lens-directives.mjs +210 -0
  97. package/esm2020/popover-edit/polyfill.mjs +37 -0
  98. package/esm2020/popover-edit/popover-edit-module.mjs +62 -0
  99. package/esm2020/popover-edit/popover-edit-position-strategy-factory.mjs +76 -0
  100. package/esm2020/popover-edit/popover-edit_public_index.mjs +5 -0
  101. package/{esm2015/popover-edit/public-api.js → esm2020/popover-edit/public-api.mjs} +0 -0
  102. package/esm2020/popover-edit/table-directives.mjs +400 -0
  103. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  104. package/esm2020/scrolling/auto-size-virtual-scroll.mjs +421 -0
  105. package/esm2020/scrolling/index.mjs +9 -0
  106. package/{esm2015/scrolling/public-api.js → esm2020/scrolling/public-api.mjs} +0 -0
  107. package/esm2020/scrolling/scrolling-module.mjs +23 -0
  108. package/esm2020/scrolling/scrolling_public_index.mjs +5 -0
  109. package/esm2020/selection/index.mjs +9 -0
  110. package/{esm2015/selection/public-api.js → esm2020/selection/public-api.mjs} +0 -0
  111. package/esm2020/selection/row-selection.mjs +49 -0
  112. package/esm2020/selection/select-all.mjs +109 -0
  113. package/esm2020/selection/selection-column.mjs +134 -0
  114. package/esm2020/selection/selection-module.mjs +40 -0
  115. package/{esm2015/selection/selection-set.js → esm2020/selection/selection-set.mjs} +1 -1
  116. package/esm2020/selection/selection-toggle.mjs +101 -0
  117. package/esm2020/selection/selection.mjs +186 -0
  118. package/esm2020/selection/selection_public_index.mjs +5 -0
  119. package/esm2020/table-scroll-container/index.mjs +9 -0
  120. package/{esm2015/table-scroll-container/public-api.js → esm2020/table-scroll-container/public-api.mjs} +0 -0
  121. package/esm2020/table-scroll-container/table-scroll-container-module.mjs +23 -0
  122. package/esm2020/table-scroll-container/table-scroll-container.mjs +131 -0
  123. package/esm2020/table-scroll-container/table-scroll-container_public_index.mjs +5 -0
  124. package/{esm2015/version.js → esm2020/version.mjs} +1 -1
  125. package/fesm2015/{cdk-experimental.js → cdk-experimental.mjs} +2 -2
  126. package/fesm2015/cdk-experimental.mjs.map +1 -0
  127. package/fesm2015/{column-resize.js → column-resize.mjs} +213 -175
  128. package/fesm2015/column-resize.mjs.map +1 -0
  129. package/fesm2015/{combobox.js → combobox.mjs} +134 -102
  130. package/fesm2015/combobox.mjs.map +1 -0
  131. package/fesm2015/dialog.mjs +813 -0
  132. package/fesm2015/dialog.mjs.map +1 -0
  133. package/fesm2015/{listbox.js → listbox.mjs} +128 -91
  134. package/fesm2015/listbox.mjs.map +1 -0
  135. package/fesm2015/{menu.js → menu.mjs} +576 -397
  136. package/fesm2015/menu.mjs.map +1 -0
  137. package/fesm2015/{popover-edit.js → popover-edit.mjs} +257 -230
  138. package/fesm2015/popover-edit.mjs.map +1 -0
  139. package/fesm2015/{scrolling.js → scrolling.mjs} +66 -36
  140. package/fesm2015/scrolling.mjs.map +1 -0
  141. package/fesm2015/selection.mjs +693 -0
  142. package/fesm2015/selection.mjs.map +1 -0
  143. package/fesm2015/{table-scroll-container.js → table-scroll-container.mjs} +43 -30
  144. package/fesm2015/table-scroll-container.mjs.map +1 -0
  145. package/fesm2020/cdk-experimental.mjs +30 -0
  146. package/fesm2020/cdk-experimental.mjs.map +1 -0
  147. package/fesm2020/column-resize.mjs +1016 -0
  148. package/fesm2020/column-resize.mjs.map +1 -0
  149. package/fesm2020/combobox.mjs +430 -0
  150. package/fesm2020/combobox.mjs.map +1 -0
  151. package/{fesm2015/dialog.js → fesm2020/dialog.mjs} +156 -104
  152. package/fesm2020/dialog.mjs.map +1 -0
  153. package/fesm2020/listbox.mjs +541 -0
  154. package/fesm2020/listbox.mjs.map +1 -0
  155. package/fesm2020/menu.mjs +2202 -0
  156. package/fesm2020/menu.mjs.map +1 -0
  157. package/fesm2020/popover-edit.mjs +1289 -0
  158. package/fesm2020/popover-edit.mjs.map +1 -0
  159. package/fesm2020/scrolling.mjs +464 -0
  160. package/fesm2020/scrolling.mjs.map +1 -0
  161. package/{fesm2015/selection.js → fesm2020/selection.mjs} +195 -107
  162. package/fesm2020/selection.mjs.map +1 -0
  163. package/fesm2020/table-scroll-container.mjs +173 -0
  164. package/fesm2020/table-scroll-container.mjs.map +1 -0
  165. package/listbox/index.d.ts +5 -1
  166. package/listbox/listbox-module.d.ts +5 -7
  167. package/listbox/listbox.d.ts +5 -0
  168. package/listbox/listbox_public_index.d.ts +4 -0
  169. package/listbox/package.json +6 -6
  170. package/menu/context-menu.d.ts +5 -0
  171. package/menu/index.d.ts +5 -3
  172. package/menu/menu-aim.d.ts +5 -0
  173. package/menu/menu-bar.d.ts +3 -0
  174. package/menu/menu-group.d.ts +3 -0
  175. package/menu/menu-item-checkbox.d.ts +3 -7
  176. package/menu/menu-item-radio.d.ts +3 -0
  177. package/menu/menu-item-selectable.d.ts +3 -0
  178. package/menu/menu-item-trigger.d.ts +3 -0
  179. package/menu/menu-item.d.ts +3 -0
  180. package/menu/menu-module.d.ts +15 -7
  181. package/menu/menu-panel.d.ts +3 -0
  182. package/menu/menu.d.ts +3 -0
  183. package/menu/menu_public_index.d.ts +4 -0
  184. package/menu/package.json +6 -6
  185. package/package.json +94 -8
  186. package/popover-edit/edit-event-dispatcher.d.ts +3 -0
  187. package/popover-edit/edit-ref.d.ts +3 -0
  188. package/popover-edit/edit-services.d.ts +3 -0
  189. package/popover-edit/focus-dispatcher.d.ts +3 -0
  190. package/popover-edit/focus-escape-notifier.d.ts +3 -0
  191. package/popover-edit/index.d.ts +5 -3
  192. package/popover-edit/lens-directives.d.ts +7 -0
  193. package/popover-edit/package.json +6 -6
  194. package/popover-edit/popover-edit-module.d.ts +7 -7
  195. package/popover-edit/popover-edit-position-strategy-factory.d.ts +5 -0
  196. package/popover-edit/popover-edit_public_index.d.ts +4 -0
  197. package/popover-edit/table-directives.d.ts +11 -0
  198. package/scrolling/auto-size-virtual-scroll.d.ts +3 -0
  199. package/scrolling/index.d.ts +5 -1
  200. package/scrolling/package.json +6 -6
  201. package/scrolling/scrolling-module.d.ts +5 -7
  202. package/scrolling/scrolling_public_index.d.ts +4 -0
  203. package/selection/index.d.ts +5 -1
  204. package/selection/package.json +6 -6
  205. package/selection/row-selection.d.ts +3 -0
  206. package/selection/select-all.d.ts +3 -0
  207. package/selection/selection-column.d.ts +3 -0
  208. package/selection/selection-module.d.ts +11 -7
  209. package/selection/selection-toggle.d.ts +3 -0
  210. package/selection/selection.d.ts +3 -0
  211. package/selection/selection_public_index.d.ts +4 -0
  212. package/table-scroll-container/index.d.ts +5 -1
  213. package/table-scroll-container/package.json +6 -6
  214. package/table-scroll-container/table-scroll-container-module.d.ts +5 -7
  215. package/table-scroll-container/table-scroll-container.d.ts +3 -0
  216. package/table-scroll-container/table-scroll-container_public_index.d.ts +4 -0
  217. package/bundles/cdk-experimental-column-resize.umd.js +0 -1324
  218. package/bundles/cdk-experimental-column-resize.umd.js.map +0 -1
  219. package/bundles/cdk-experimental-combobox.umd.js +0 -443
  220. package/bundles/cdk-experimental-combobox.umd.js.map +0 -1
  221. package/bundles/cdk-experimental-dialog.umd.js +0 -1113
  222. package/bundles/cdk-experimental-dialog.umd.js.map +0 -1
  223. package/bundles/cdk-experimental-listbox.umd.js +0 -935
  224. package/bundles/cdk-experimental-listbox.umd.js.map +0 -1
  225. package/bundles/cdk-experimental-menu.umd.js +0 -2461
  226. package/bundles/cdk-experimental-menu.umd.js.map +0 -1
  227. package/bundles/cdk-experimental-popover-edit.umd.js +0 -1679
  228. package/bundles/cdk-experimental-popover-edit.umd.js.map +0 -1
  229. package/bundles/cdk-experimental-scrolling.umd.js +0 -459
  230. package/bundles/cdk-experimental-scrolling.umd.js.map +0 -1
  231. package/bundles/cdk-experimental-selection.umd.js +0 -961
  232. package/bundles/cdk-experimental-selection.umd.js.map +0 -1
  233. package/bundles/cdk-experimental-table-scroll-container.umd.js +0 -499
  234. package/bundles/cdk-experimental-table-scroll-container.umd.js.map +0 -1
  235. package/bundles/cdk-experimental.umd.js +0 -38
  236. package/bundles/cdk-experimental.umd.js.map +0 -1
  237. package/column-resize/index.metadata.json +0 -1
  238. package/combobox/index.metadata.json +0 -1
  239. package/dialog/index.metadata.json +0 -1
  240. package/esm2015/cdk-experimental.externs.js +0 -0
  241. package/esm2015/column-resize/column-resize-directives/column-resize-flex.js +0 -46
  242. package/esm2015/column-resize/column-resize-directives/column-resize.js +0 -46
  243. package/esm2015/column-resize/column-resize-directives/default-enabled-column-resize-flex.js +0 -46
  244. package/esm2015/column-resize/column-resize-directives/default-enabled-column-resize.js +0 -46
  245. package/esm2015/column-resize/column-resize-module.js +0 -37
  246. package/esm2015/column-resize/column-resize-notifier.js +0 -45
  247. package/esm2015/column-resize/column-resize.externs.js +0 -6
  248. package/esm2015/column-resize/column-resize.js +0 -71
  249. package/esm2015/column-resize/column-size-store.js +0 -17
  250. package/esm2015/column-resize/event-dispatcher.js +0 -70
  251. package/esm2015/column-resize/index.js +0 -6
  252. package/esm2015/column-resize/overlay-handle.js +0 -139
  253. package/esm2015/column-resize/resizable.js +0 -185
  254. package/esm2015/column-resize/resize-strategy.js +0 -227
  255. package/esm2015/combobox/combobox-module.js +0 -23
  256. package/esm2015/combobox/combobox-panel.js +0 -55
  257. package/esm2015/combobox/combobox-popup.js +0 -74
  258. package/esm2015/combobox/combobox.externs.js +0 -6
  259. package/esm2015/combobox/combobox.js +0 -248
  260. package/esm2015/combobox/index.js +0 -5
  261. package/esm2015/dialog/dialog-container.js +0 -289
  262. package/esm2015/dialog/dialog-injectors.js +0 -30
  263. package/esm2015/dialog/dialog-module.js +0 -47
  264. package/esm2015/dialog/dialog-ref.js +0 -115
  265. package/esm2015/dialog/dialog.externs.js +0 -6
  266. package/esm2015/dialog/dialog.js +0 -238
  267. package/esm2015/dialog/index.js +0 -5
  268. package/esm2015/listbox/index.js +0 -5
  269. package/esm2015/listbox/listbox-module.js +0 -19
  270. package/esm2015/listbox/listbox.externs.js +0 -6
  271. package/esm2015/listbox/listbox.js +0 -481
  272. package/esm2015/menu/context-menu.js +0 -280
  273. package/esm2015/menu/index.js +0 -6
  274. package/esm2015/menu/menu-aim.js +0 -195
  275. package/esm2015/menu/menu-bar.js +0 -252
  276. package/esm2015/menu/menu-group.js +0 -63
  277. package/esm2015/menu/menu-item-checkbox.js +0 -41
  278. package/esm2015/menu/menu-item-radio.js +0 -73
  279. package/esm2015/menu/menu-item-selectable.js +0 -51
  280. package/esm2015/menu/menu-item-trigger.js +0 -354
  281. package/esm2015/menu/menu-item.js +0 -253
  282. package/esm2015/menu/menu-module.js +0 -41
  283. package/esm2015/menu/menu-panel.js +0 -37
  284. package/esm2015/menu/menu.externs.js +0 -6
  285. package/esm2015/menu/menu.js +0 -293
  286. package/esm2015/popover-edit/edit-event-dispatcher.js +0 -215
  287. package/esm2015/popover-edit/edit-ref.js +0 -82
  288. package/esm2015/popover-edit/edit-services.js +0 -49
  289. package/esm2015/popover-edit/focus-dispatcher.js +0 -83
  290. package/esm2015/popover-edit/focus-escape-notifier.js +0 -64
  291. package/esm2015/popover-edit/index.js +0 -7
  292. package/esm2015/popover-edit/lens-directives.js +0 -199
  293. package/esm2015/popover-edit/polyfill.js +0 -35
  294. package/esm2015/popover-edit/popover-edit-module.js +0 -38
  295. package/esm2015/popover-edit/popover-edit-position-strategy-factory.js +0 -70
  296. package/esm2015/popover-edit/popover-edit.externs.js +0 -6
  297. package/esm2015/popover-edit/table-directives.js +0 -390
  298. package/esm2015/scrolling/auto-size-virtual-scroll.js +0 -403
  299. package/esm2015/scrolling/index.js +0 -5
  300. package/esm2015/scrolling/scrolling-module.js +0 -18
  301. package/esm2015/scrolling/scrolling.externs.js +0 -6
  302. package/esm2015/selection/index.js +0 -5
  303. package/esm2015/selection/row-selection.js +0 -41
  304. package/esm2015/selection/select-all.js +0 -96
  305. package/esm2015/selection/selection-column.js +0 -93
  306. package/esm2015/selection/selection-module.js +0 -40
  307. package/esm2015/selection/selection-toggle.js +0 -82
  308. package/esm2015/selection/selection.externs.js +0 -6
  309. package/esm2015/selection/selection.js +0 -176
  310. package/esm2015/table-scroll-container/index.js +0 -5
  311. package/esm2015/table-scroll-container/table-scroll-container-module.js +0 -18
  312. package/esm2015/table-scroll-container/table-scroll-container.externs.js +0 -6
  313. package/esm2015/table-scroll-container/table-scroll-container.js +0 -133
  314. package/fesm2015/cdk-experimental.js.map +0 -1
  315. package/fesm2015/column-resize.js.map +0 -1
  316. package/fesm2015/combobox.js.map +0 -1
  317. package/fesm2015/dialog.js.map +0 -1
  318. package/fesm2015/listbox.js.map +0 -1
  319. package/fesm2015/menu.js.map +0 -1
  320. package/fesm2015/popover-edit.js.map +0 -1
  321. package/fesm2015/scrolling.js.map +0 -1
  322. package/fesm2015/selection.js.map +0 -1
  323. package/fesm2015/table-scroll-container.js.map +0 -1
  324. package/listbox/index.metadata.json +0 -1
  325. package/menu/index.metadata.json +0 -1
  326. package/popover-edit/index.metadata.json +0 -1
  327. package/scrolling/index.metadata.json +0 -1
  328. package/selection/index.metadata.json +0 -1
  329. package/table-scroll-container/index.metadata.json +0 -1
@@ -1,2461 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/overlay'), require('@angular/cdk/a11y'), require('@angular/cdk/keycodes'), require('@angular/cdk/bidi'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/collections'), require('@angular/cdk/coercion'), require('@angular/cdk/portal')) :
3
- typeof define === 'function' && define.amd ? define('@angular/cdk-experimental/menu', ['exports', '@angular/core', '@angular/cdk/overlay', '@angular/cdk/a11y', '@angular/cdk/keycodes', '@angular/cdk/bidi', 'rxjs', 'rxjs/operators', '@angular/cdk/collections', '@angular/cdk/coercion', '@angular/cdk/portal'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.cdkExperimental = global.ng.cdkExperimental || {}, global.ng.cdkExperimental.menu = {}), global.ng.core, global.ng.cdk.overlay, global.ng.cdk.a11y, global.ng.cdk.keycodes, global.ng.cdk.bidi, global.rxjs, global.rxjs.operators, global.ng.cdk.collections, global.ng.cdk.coercion, global.ng.cdk.portal));
5
- }(this, (function (exports, i0, overlay, a11y, keycodes, bidi, rxjs, operators, collections, coercion, portal) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
-
29
- /*! *****************************************************************************
30
- Copyright (c) Microsoft Corporation.
31
-
32
- Permission to use, copy, modify, and/or distribute this software for any
33
- purpose with or without fee is hereby granted.
34
-
35
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
- PERFORMANCE OF THIS SOFTWARE.
42
- ***************************************************************************** */
43
- /* global Reflect, Promise */
44
- var extendStatics = function (d, b) {
45
- extendStatics = Object.setPrototypeOf ||
46
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
- function (d, b) { for (var p in b)
48
- if (Object.prototype.hasOwnProperty.call(b, p))
49
- d[p] = b[p]; };
50
- return extendStatics(d, b);
51
- };
52
- function __extends(d, b) {
53
- if (typeof b !== "function" && b !== null)
54
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
- extendStatics(d, b);
56
- function __() { this.constructor = d; }
57
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
- }
59
- var __assign = function () {
60
- __assign = Object.assign || function __assign(t) {
61
- for (var s, i = 1, n = arguments.length; i < n; i++) {
62
- s = arguments[i];
63
- for (var p in s)
64
- if (Object.prototype.hasOwnProperty.call(s, p))
65
- t[p] = s[p];
66
- }
67
- return t;
68
- };
69
- return __assign.apply(this, arguments);
70
- };
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s)
74
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- }
83
- function __decorate(decorators, target, key, desc) {
84
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
- r = Reflect.decorate(decorators, target, key, desc);
87
- else
88
- for (var i = decorators.length - 1; i >= 0; i--)
89
- if (d = decorators[i])
90
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
- return c > 3 && r && Object.defineProperty(target, key, r), r;
92
- }
93
- function __param(paramIndex, decorator) {
94
- return function (target, key) { decorator(target, key, paramIndex); };
95
- }
96
- function __metadata(metadataKey, metadataValue) {
97
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
- return Reflect.metadata(metadataKey, metadataValue);
99
- }
100
- function __awaiter(thisArg, _arguments, P, generator) {
101
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
- return new (P || (P = Promise))(function (resolve, reject) {
103
- function fulfilled(value) { try {
104
- step(generator.next(value));
105
- }
106
- catch (e) {
107
- reject(e);
108
- } }
109
- function rejected(value) { try {
110
- step(generator["throw"](value));
111
- }
112
- catch (e) {
113
- reject(e);
114
- } }
115
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
- step((generator = generator.apply(thisArg, _arguments || [])).next());
117
- });
118
- }
119
- function __generator(thisArg, body) {
120
- var _ = { label: 0, sent: function () { if (t[0] & 1)
121
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
- function verb(n) { return function (v) { return step([n, v]); }; }
124
- function step(op) {
125
- if (f)
126
- throw new TypeError("Generator is already executing.");
127
- while (_)
128
- try {
129
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
- return t;
131
- if (y = 0, t)
132
- op = [op[0] & 2, t.value];
133
- switch (op[0]) {
134
- case 0:
135
- case 1:
136
- t = op;
137
- break;
138
- case 4:
139
- _.label++;
140
- return { value: op[1], done: false };
141
- case 5:
142
- _.label++;
143
- y = op[1];
144
- op = [0];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2])
170
- _.ops.pop();
171
- _.trys.pop();
172
- continue;
173
- }
174
- op = body.call(thisArg, _);
175
- }
176
- catch (e) {
177
- op = [6, e];
178
- y = 0;
179
- }
180
- finally {
181
- f = t = 0;
182
- }
183
- if (op[0] & 5)
184
- throw op[1];
185
- return { value: op[0] ? op[1] : void 0, done: true };
186
- }
187
- }
188
- var __createBinding = Object.create ? (function (o, m, k, k2) {
189
- if (k2 === undefined)
190
- k2 = k;
191
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
- }) : (function (o, m, k, k2) {
193
- if (k2 === undefined)
194
- k2 = k;
195
- o[k2] = m[k];
196
- });
197
- function __exportStar(m, o) {
198
- for (var p in m)
199
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
- __createBinding(o, m, p);
201
- }
202
- function __values(o) {
203
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
- if (m)
205
- return m.call(o);
206
- if (o && typeof o.length === "number")
207
- return {
208
- next: function () {
209
- if (o && i >= o.length)
210
- o = void 0;
211
- return { value: o && o[i++], done: !o };
212
- }
213
- };
214
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
- }
216
- function __read(o, n) {
217
- var m = typeof Symbol === "function" && o[Symbol.iterator];
218
- if (!m)
219
- return o;
220
- var i = m.call(o), r, ar = [], e;
221
- try {
222
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
- ar.push(r.value);
224
- }
225
- catch (error) {
226
- e = { error: error };
227
- }
228
- finally {
229
- try {
230
- if (r && !r.done && (m = i["return"]))
231
- m.call(i);
232
- }
233
- finally {
234
- if (e)
235
- throw e.error;
236
- }
237
- }
238
- return ar;
239
- }
240
- /** @deprecated */
241
- function __spread() {
242
- for (var ar = [], i = 0; i < arguments.length; i++)
243
- ar = ar.concat(__read(arguments[i]));
244
- return ar;
245
- }
246
- /** @deprecated */
247
- function __spreadArrays() {
248
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
- s += arguments[i].length;
250
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
- r[k] = a[j];
253
- return r;
254
- }
255
- function __spreadArray(to, from, pack) {
256
- if (pack || arguments.length === 2)
257
- for (var i = 0, l = from.length, ar; i < l; i++) {
258
- if (ar || !(i in from)) {
259
- if (!ar)
260
- ar = Array.prototype.slice.call(from, 0, i);
261
- ar[i] = from[i];
262
- }
263
- }
264
- return to.concat(ar || Array.prototype.slice.call(from));
265
- }
266
- function __await(v) {
267
- return this instanceof __await ? (this.v = v, this) : new __await(v);
268
- }
269
- function __asyncGenerator(thisArg, _arguments, generator) {
270
- if (!Symbol.asyncIterator)
271
- throw new TypeError("Symbol.asyncIterator is not defined.");
272
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
- function verb(n) { if (g[n])
275
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
- function resume(n, v) { try {
277
- step(g[n](v));
278
- }
279
- catch (e) {
280
- settle(q[0][3], e);
281
- } }
282
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
- function fulfill(value) { resume("next", value); }
284
- function reject(value) { resume("throw", value); }
285
- function settle(f, v) { if (f(v), q.shift(), q.length)
286
- resume(q[0][0], q[0][1]); }
287
- }
288
- function __asyncDelegator(o) {
289
- var i, p;
290
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
- }
293
- function __asyncValues(o) {
294
- if (!Symbol.asyncIterator)
295
- throw new TypeError("Symbol.asyncIterator is not defined.");
296
- var m = o[Symbol.asyncIterator], i;
297
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
- }
301
- function __makeTemplateObject(cooked, raw) {
302
- if (Object.defineProperty) {
303
- Object.defineProperty(cooked, "raw", { value: raw });
304
- }
305
- else {
306
- cooked.raw = raw;
307
- }
308
- return cooked;
309
- }
310
- ;
311
- var __setModuleDefault = Object.create ? (function (o, v) {
312
- Object.defineProperty(o, "default", { enumerable: true, value: v });
313
- }) : function (o, v) {
314
- o["default"] = v;
315
- };
316
- function __importStar(mod) {
317
- if (mod && mod.__esModule)
318
- return mod;
319
- var result = {};
320
- if (mod != null)
321
- for (var k in mod)
322
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
- __createBinding(result, mod, k);
324
- __setModuleDefault(result, mod);
325
- return result;
326
- }
327
- function __importDefault(mod) {
328
- return (mod && mod.__esModule) ? mod : { default: mod };
329
- }
330
- function __classPrivateFieldGet(receiver, state, kind, f) {
331
- if (kind === "a" && !f)
332
- throw new TypeError("Private accessor was defined without a getter");
333
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
- }
337
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
- if (kind === "m")
339
- throw new TypeError("Private method is not writable");
340
- if (kind === "a" && !f)
341
- throw new TypeError("Private accessor was defined without a setter");
342
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
- }
346
-
347
- /**
348
- * @license
349
- * Copyright Google LLC All Rights Reserved.
350
- *
351
- * Use of this source code is governed by an MIT-style license that can be
352
- * found in the LICENSE file at https://angular.io/license
353
- */
354
- /** Injection token used to return classes implementing the Menu interface */
355
- var CDK_MENU = new i0.InjectionToken('cdk-menu');
356
-
357
- /**
358
- * MenuStack allows subscribers to listen for close events (when a MenuStackItem is popped off
359
- * of the stack) in order to perform closing actions. Upon the MenuStack being empty it emits
360
- * from the `empty` observable specifying the next focus action which the listener should perform
361
- * as requested by the closer.
362
- */
363
- var MenuStack = /** @class */ (function () {
364
- function MenuStack() {
365
- /** All MenuStackItems tracked by this MenuStack. */
366
- this._elements = [];
367
- /** Emits the element which was popped off of the stack when requested by a closer. */
368
- this._close = new rxjs.Subject();
369
- /** Emits once the MenuStack has become empty after popping off elements. */
370
- this._empty = new rxjs.Subject();
371
- /** Observable which emits the MenuStackItem which has been requested to close. */
372
- this.closed = this._close;
373
- /**
374
- * Observable which emits when the MenuStack is empty after popping off the last element. It
375
- * emits a FocusNext event which specifies the action the closer has requested the listener
376
- * perform.
377
- */
378
- this.emptied = this._empty;
379
- }
380
- /** @param menu the MenuStackItem to put on the stack. */
381
- MenuStack.prototype.push = function (menu) {
382
- this._elements.push(menu);
383
- };
384
- /**
385
- * Pop items off of the stack up to and including `lastItem` and emit each on the close
386
- * observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
387
- * @param lastItem the last item to pop off the stack.
388
- * @param focusNext the event to emit on the `empty` observable if the method call resulted in an
389
- * empty stack. Does not emit if the stack was initially empty or if `lastItem` was not on the
390
- * stack.
391
- */
392
- MenuStack.prototype.close = function (lastItem, focusNext) {
393
- if (this._elements.indexOf(lastItem) >= 0) {
394
- var poppedElement = void 0;
395
- do {
396
- poppedElement = this._elements.pop();
397
- this._close.next(poppedElement);
398
- } while (poppedElement !== lastItem);
399
- if (this.isEmpty()) {
400
- this._empty.next(focusNext);
401
- }
402
- }
403
- };
404
- /**
405
- * Pop items off of the stack up to but excluding `lastItem` and emit each on the close
406
- * observable. If the stack is empty or `lastItem` is not on the stack it does nothing.
407
- * @param lastItem the element which should be left on the stack
408
- * @return whether or not an item was removed from the stack
409
- */
410
- MenuStack.prototype.closeSubMenuOf = function (lastItem) {
411
- var removed = false;
412
- if (this._elements.indexOf(lastItem) >= 0) {
413
- removed = this.peek() !== lastItem;
414
- while (this.peek() !== lastItem) {
415
- this._close.next(this._elements.pop());
416
- }
417
- }
418
- return removed;
419
- };
420
- /**
421
- * Pop off all MenuStackItems and emit each one on the `close` observable one by one.
422
- * @param focusNext the event to emit on the `empty` observable once the stack is emptied. Does
423
- * not emit if the stack was initially empty.
424
- */
425
- MenuStack.prototype.closeAll = function (focusNext) {
426
- if (!this.isEmpty()) {
427
- while (!this.isEmpty()) {
428
- var menuStackItem = this._elements.pop();
429
- if (menuStackItem) {
430
- this._close.next(menuStackItem);
431
- }
432
- }
433
- this._empty.next(focusNext);
434
- }
435
- };
436
- /** Return true if this stack is empty. */
437
- MenuStack.prototype.isEmpty = function () {
438
- return !this._elements.length;
439
- };
440
- /** Return the length of the stack. */
441
- MenuStack.prototype.length = function () {
442
- return this._elements.length;
443
- };
444
- /** Get the top most element on the stack. */
445
- MenuStack.prototype.peek = function () {
446
- return this._elements[this._elements.length - 1];
447
- };
448
- return MenuStack;
449
- }());
450
- /** NoopMenuStack is a placeholder MenuStack used for inline menus. */
451
- var NoopMenuStack = /** @class */ (function (_super) {
452
- __extends(NoopMenuStack, _super);
453
- function NoopMenuStack() {
454
- return _super !== null && _super.apply(this, arguments) || this;
455
- }
456
- /** Noop push - does not add elements to the MenuStack. */
457
- NoopMenuStack.prototype.push = function (_) { };
458
- return NoopMenuStack;
459
- }(MenuStack));
460
-
461
- /**
462
- * @license
463
- * Copyright Google LLC All Rights Reserved.
464
- *
465
- * Use of this source code is governed by an MIT-style license that can be
466
- * found in the LICENSE file at https://angular.io/license
467
- */
468
- /**
469
- * Throws an exception when a menu panel already has a menu stack.
470
- * @docs-private
471
- */
472
- function throwExistingMenuStackError() {
473
- throw Error('CdkMenuPanel is already referenced by different CdkMenuTrigger. Ensure that a menu is' +
474
- ' opened by a single trigger only.');
475
- }
476
- /**
477
- * Throws an exception when an instance of the PointerFocusTracker is not provided.
478
- * @docs-private
479
- */
480
- function throwMissingPointerFocusTracker() {
481
- throw Error('expected an instance of PointerFocusTracker to be provided');
482
- }
483
- /**
484
- * Throws an exception when a reference to the parent menu is not provided.
485
- * @docs-private
486
- */
487
- function throwMissingMenuReference() {
488
- throw Error('expected a reference to the parent menu');
489
- }
490
-
491
- /**
492
- * @license
493
- * Copyright Google LLC All Rights Reserved.
494
- *
495
- * Use of this source code is governed by an MIT-style license that can be
496
- * found in the LICENSE file at https://angular.io/license
497
- */
498
- /** Injection token used for an implementation of MenuAim. */
499
- var MENU_AIM = new i0.InjectionToken('cdk-menu-aim');
500
- /** Capture every nth mouse move event. */
501
- var MOUSE_MOVE_SAMPLE_FREQUENCY = 3;
502
- /** The number of mouse move events to track. */
503
- var NUM_POINTS = 5;
504
- /**
505
- * How long to wait before closing a sibling menu if a user stops short of the submenu they were
506
- * predicted to go into.
507
- */
508
- var CLOSE_DELAY = 300;
509
- /** Calculate the slope between point a and b. */
510
- function getSlope(a, b) {
511
- return (b.y - a.y) / (b.x - a.x);
512
- }
513
- /** Calculate the y intercept for the given point and slope. */
514
- function getYIntercept(point, slope) {
515
- return point.y - slope * point.x;
516
- }
517
- /**
518
- * Whether the given mouse trajectory line defined by the slope and y intercept falls within the
519
- * submenu as defined by `submenuPoints`
520
- * @param submenuPoints the submenu DOMRect points.
521
- * @param m the slope of the trajectory line.
522
- * @param b the y intercept of the trajectory line.
523
- *
524
- * @return true if any point on the line falls within the submenu.
525
- */
526
- function isWithinSubmenu(submenuPoints, m, b) {
527
- var left = submenuPoints.left, right = submenuPoints.right, top = submenuPoints.top, bottom = submenuPoints.bottom;
528
- // Check for intersection with each edge of the submenu (left, right, top, bottom)
529
- // by fixing one coordinate to that edge's coordinate (either x or y) and checking if the
530
- // other coordinate is within bounds.
531
- return ((m * left + b >= top && m * left + b <= bottom) ||
532
- (m * right + b >= top && m * right + b <= bottom) ||
533
- ((top - b) / m >= left && (top - b) / m <= right) ||
534
- ((bottom - b) / m >= left && (bottom - b) / m <= right));
535
- }
536
- /**
537
- * TargetMenuAim predicts if a user is moving into a submenu. It calculates the
538
- * trajectory of the user's mouse movement in the current menu to determine if the
539
- * mouse is moving towards an open submenu.
540
- *
541
- * The determination is made by calculating the slope of the users last NUM_POINTS moves where each
542
- * pair of points determines if the trajectory line points into the submenu. It uses consensus
543
- * approach by checking if at least NUM_POINTS / 2 pairs determine that the user is moving towards
544
- * to submenu.
545
- */
546
- var TargetMenuAim = /** @class */ (function () {
547
- function TargetMenuAim(_ngZone) {
548
- this._ngZone = _ngZone;
549
- /** The last NUM_POINTS mouse move events. */
550
- this._points = [];
551
- /** Emits when this service is destroyed. */
552
- this._destroyed = new rxjs.Subject();
553
- }
554
- /** Set the Menu and its PointerFocusTracker. */
555
- TargetMenuAim.prototype.initialize = function (menu, pointerTracker) {
556
- this._menu = menu;
557
- this._pointerTracker = pointerTracker;
558
- this._subscribeToMouseMoves();
559
- };
560
- /**
561
- * Calls the `doToggle` callback when it is deemed that the user is not moving towards
562
- * the submenu.
563
- * @param doToggle the function called when the user is not moving towards the submenu.
564
- */
565
- TargetMenuAim.prototype.toggle = function (doToggle) {
566
- // If the menu is horizontal the sub-menus open below and there is no risk of premature
567
- // closing of any sub-menus therefore we automatically resolve the callback.
568
- if (this._menu.orientation === 'horizontal') {
569
- doToggle();
570
- }
571
- this._checkConfigured();
572
- var siblingItemIsWaiting = !!this._timeoutId;
573
- var hasPoints = this._points.length > 1;
574
- if (hasPoints && !siblingItemIsWaiting) {
575
- if (this._isMovingToSubmenu()) {
576
- this._startTimeout(doToggle);
577
- }
578
- else {
579
- doToggle();
580
- }
581
- }
582
- else if (!siblingItemIsWaiting) {
583
- doToggle();
584
- }
585
- };
586
- /**
587
- * Start the delayed toggle handler if one isn't running already.
588
- *
589
- * The delayed toggle handler executes the `doToggle` callback after some period of time iff the
590
- * users mouse is on an item in the current menu.
591
- */
592
- TargetMenuAim.prototype._startTimeout = function (doToggle) {
593
- var _this = this;
594
- // If the users mouse is moving towards a submenu we don't want to immediately resolve.
595
- // Wait for some period of time before determining if the previous menu should close in
596
- // cases where the user may have moved towards the submenu but stopped on a sibling menu
597
- // item intentionally.
598
- var timeoutId = setTimeout(function () {
599
- // Resolve if the user is currently moused over some element in the root menu
600
- if (_this._pointerTracker.activeElement && timeoutId === _this._timeoutId) {
601
- doToggle();
602
- }
603
- _this._timeoutId = null;
604
- }, CLOSE_DELAY);
605
- this._timeoutId = timeoutId;
606
- };
607
- /** Whether the user is heading towards the open submenu. */
608
- TargetMenuAim.prototype._isMovingToSubmenu = function () {
609
- var submenuPoints = this._getSubmenuBounds();
610
- if (!submenuPoints) {
611
- return false;
612
- }
613
- var numMoving = 0;
614
- var currPoint = this._points[this._points.length - 1];
615
- // start from the second last point and calculate the slope between each point and the last
616
- // point.
617
- for (var i = this._points.length - 2; i >= 0; i--) {
618
- var previous = this._points[i];
619
- var slope = getSlope(currPoint, previous);
620
- if (isWithinSubmenu(submenuPoints, slope, getYIntercept(currPoint, slope))) {
621
- numMoving++;
622
- }
623
- }
624
- return numMoving >= Math.floor(NUM_POINTS / 2);
625
- };
626
- /** Get the bounding DOMRect for the open submenu. */
627
- TargetMenuAim.prototype._getSubmenuBounds = function () {
628
- var _a, _b, _c;
629
- return (_c = (_b = (_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.previousElement) === null || _b === void 0 ? void 0 : _b.getMenu()) === null || _c === void 0 ? void 0 : _c._elementRef.nativeElement.getBoundingClientRect();
630
- };
631
- /**
632
- * Check if a reference to the PointerFocusTracker and menu element is provided.
633
- * @throws an error if neither reference is provided.
634
- */
635
- TargetMenuAim.prototype._checkConfigured = function () {
636
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
637
- if (!this._pointerTracker) {
638
- throwMissingPointerFocusTracker();
639
- }
640
- if (!this._menu) {
641
- throwMissingMenuReference();
642
- }
643
- }
644
- };
645
- /** Subscribe to the root menus mouse move events and update the tracked mouse points. */
646
- TargetMenuAim.prototype._subscribeToMouseMoves = function () {
647
- var _this = this;
648
- this._ngZone.runOutsideAngular(function () {
649
- rxjs.fromEvent(_this._menu._elementRef.nativeElement, 'mousemove')
650
- .pipe(operators.filter(function (_, index) { return index % MOUSE_MOVE_SAMPLE_FREQUENCY === 0; }), operators.takeUntil(_this._destroyed))
651
- .subscribe(function (event) {
652
- _this._points.push({ x: event.clientX, y: event.clientY });
653
- if (_this._points.length > NUM_POINTS) {
654
- _this._points.shift();
655
- }
656
- });
657
- });
658
- };
659
- TargetMenuAim.prototype.ngOnDestroy = function () {
660
- this._destroyed.next();
661
- this._destroyed.complete();
662
- };
663
- return TargetMenuAim;
664
- }());
665
- TargetMenuAim.decorators = [
666
- { type: i0.Injectable }
667
- ];
668
- TargetMenuAim.ctorParameters = function () { return [
669
- { type: i0.NgZone }
670
- ]; };
671
- /**
672
- * CdkTargetMenuAim is a provider for the TargetMenuAim service. It should be added to an
673
- * element with either the `cdkMenu` or `cdkMenuBar` directive and child menu items.
674
- */
675
- var CdkTargetMenuAim = /** @class */ (function () {
676
- function CdkTargetMenuAim() {
677
- }
678
- return CdkTargetMenuAim;
679
- }());
680
- CdkTargetMenuAim.decorators = [
681
- { type: i0.Directive, args: [{
682
- selector: '[cdkTargetMenuAim]',
683
- exportAs: 'cdkTargetMenuAim',
684
- providers: [{ provide: MENU_AIM, useClass: TargetMenuAim }],
685
- },] }
686
- ];
687
-
688
- /**
689
- * @license
690
- * Copyright Google LLC All Rights Reserved.
691
- *
692
- * Use of this source code is governed by an MIT-style license that can be
693
- * found in the LICENSE file at https://angular.io/license
694
- */
695
- /**
696
- * Whether the target element is a menu item to be ignored by the overlay background click handler.
697
- */
698
- function isClickInsideMenuOverlay(target) {
699
- while (target === null || target === void 0 ? void 0 : target.parentElement) {
700
- var isOpenTrigger = target.getAttribute('aria-expanded') === 'true' &&
701
- target.classList.contains('cdk-menu-trigger');
702
- var isOverlayMenu = target.classList.contains('cdk-menu') && !target.classList.contains('cdk-menu-inline');
703
- if (isOpenTrigger || isOverlayMenu) {
704
- return true;
705
- }
706
- target = target.parentElement;
707
- }
708
- return false;
709
- }
710
- /**
711
- * A directive to be combined with CdkMenuItem which opens the Menu it is bound to. If the
712
- * element is in a top level MenuBar it will open the menu on click, or if a sibling is already
713
- * opened it will open on hover. If it is inside of a Menu it will open the attached Submenu on
714
- * hover regardless of its sibling state.
715
- *
716
- * The directive must be placed along with the `cdkMenuItem` directive in order to enable full
717
- * functionality.
718
- */
719
- var CdkMenuItemTrigger = /** @class */ (function () {
720
- function CdkMenuItemTrigger(_elementRef, _viewContainerRef, _overlay, _ngZone, _parentMenu, _menuAim, _directionality) {
721
- this._elementRef = _elementRef;
722
- this._viewContainerRef = _viewContainerRef;
723
- this._overlay = _overlay;
724
- this._ngZone = _ngZone;
725
- this._parentMenu = _parentMenu;
726
- this._menuAim = _menuAim;
727
- this._directionality = _directionality;
728
- /** Emits when the attached menu is requested to open */
729
- this.opened = new i0.EventEmitter();
730
- /** Emits when the attached menu is requested to close */
731
- this.closed = new i0.EventEmitter();
732
- /** The menu stack for this trigger and its sub-menus. */
733
- this._menuStack = new MenuStack();
734
- /** A reference to the overlay which manages the triggered menu */
735
- this._overlayRef = null;
736
- /** Emits when this trigger is destroyed. */
737
- this._destroyed = new rxjs.Subject();
738
- /** Emits when the outside pointer events listener on the overlay should be stopped. */
739
- this._stopOutsideClicksListener = rxjs.merge(this.closed, this._destroyed);
740
- this._registerCloseHandler();
741
- this._subscribeToMouseEnter();
742
- }
743
- Object.defineProperty(CdkMenuItemTrigger.prototype, "menuPanel", {
744
- /** Template reference variable to the menu this trigger opens */
745
- get: function () {
746
- return this._menuPanel;
747
- },
748
- set: function (panel) {
749
- // If the provided panel already has a stack, that means it already has a trigger configured.
750
- // Note however that there are some edge cases where two triggers **may** share the same menu,
751
- // e.g. two triggers in two separate menus.
752
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && (panel === null || panel === void 0 ? void 0 : panel._menuStack)) {
753
- throwExistingMenuStackError();
754
- }
755
- this._menuPanel = panel;
756
- if (this._menuPanel) {
757
- this._menuPanel._menuStack = this._getMenuStack();
758
- }
759
- },
760
- enumerable: false,
761
- configurable: true
762
- });
763
- /** Open/close the attached menu if the trigger has been configured with one */
764
- CdkMenuItemTrigger.prototype.toggle = function () {
765
- if (this.hasMenu()) {
766
- this.isMenuOpen() ? this.closeMenu() : this.openMenu();
767
- }
768
- };
769
- /** Open the attached menu. */
770
- CdkMenuItemTrigger.prototype.openMenu = function () {
771
- if (!this.isMenuOpen()) {
772
- this.opened.next();
773
- this._overlayRef = this._overlayRef || this._overlay.create(this._getOverlayConfig());
774
- this._overlayRef.attach(this._getPortal());
775
- this._subscribeToOutsideClicks();
776
- }
777
- };
778
- /** Close the opened menu. */
779
- CdkMenuItemTrigger.prototype.closeMenu = function () {
780
- if (this.isMenuOpen()) {
781
- this.closed.next();
782
- this._overlayRef.detach();
783
- }
784
- this._closeSiblingTriggers();
785
- };
786
- /** Return true if the trigger has an attached menu */
787
- CdkMenuItemTrigger.prototype.hasMenu = function () {
788
- return !!this.menuPanel;
789
- };
790
- /** Whether the menu this button is a trigger for is open */
791
- CdkMenuItemTrigger.prototype.isMenuOpen = function () {
792
- return this._overlayRef ? this._overlayRef.hasAttached() : false;
793
- };
794
- /**
795
- * Get a reference to the rendered Menu if the Menu is open and it is visible in the DOM.
796
- * @return the menu if it is open, otherwise undefined.
797
- */
798
- CdkMenuItemTrigger.prototype.getMenu = function () {
799
- var _a;
800
- return (_a = this.menuPanel) === null || _a === void 0 ? void 0 : _a._menu;
801
- };
802
- /**
803
- * Subscribe to the mouseenter events and close any sibling menu items if this element is moused
804
- * into.
805
- */
806
- CdkMenuItemTrigger.prototype._subscribeToMouseEnter = function () {
807
- var _this = this;
808
- // Closes any sibling menu items and opens the menu associated with this trigger.
809
- var toggleMenus = function () { return _this._ngZone.run(function () {
810
- _this._closeSiblingTriggers();
811
- _this.openMenu();
812
- }); };
813
- this._ngZone.runOutsideAngular(function () {
814
- rxjs.fromEvent(_this._elementRef.nativeElement, 'mouseenter')
815
- .pipe(operators.filter(function () { var _a; return !((_a = _this._getMenuStack()) === null || _a === void 0 ? void 0 : _a.isEmpty()) && !_this.isMenuOpen(); }), operators.takeUntil(_this._destroyed))
816
- .subscribe(function () {
817
- if (_this._menuAim) {
818
- _this._menuAim.toggle(toggleMenus);
819
- }
820
- else {
821
- toggleMenus();
822
- }
823
- });
824
- });
825
- };
826
- /**
827
- * Handles keyboard events for the menu item, specifically opening/closing the attached menu and
828
- * focusing the appropriate submenu item.
829
- * @param event the keyboard event to handle
830
- */
831
- CdkMenuItemTrigger.prototype._toggleOnKeydown = function (event) {
832
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
833
- var keyCode = event.keyCode;
834
- switch (keyCode) {
835
- case keycodes.SPACE:
836
- case keycodes.ENTER:
837
- event.preventDefault();
838
- this.toggle();
839
- (_b = (_a = this.menuPanel) === null || _a === void 0 ? void 0 : _a._menu) === null || _b === void 0 ? void 0 : _b.focusFirstItem('keyboard');
840
- break;
841
- case keycodes.RIGHT_ARROW:
842
- if (this._parentMenu && this._isParentVertical()) {
843
- event.preventDefault();
844
- if (((_c = this._directionality) === null || _c === void 0 ? void 0 : _c.value) === 'rtl') {
845
- this._getMenuStack().close(this._parentMenu, 2 /* currentItem */);
846
- }
847
- else {
848
- this.openMenu();
849
- (_e = (_d = this.menuPanel) === null || _d === void 0 ? void 0 : _d._menu) === null || _e === void 0 ? void 0 : _e.focusFirstItem('keyboard');
850
- }
851
- }
852
- break;
853
- case keycodes.LEFT_ARROW:
854
- if (this._parentMenu && this._isParentVertical()) {
855
- event.preventDefault();
856
- if (((_f = this._directionality) === null || _f === void 0 ? void 0 : _f.value) === 'rtl') {
857
- this.openMenu();
858
- (_h = (_g = this.menuPanel) === null || _g === void 0 ? void 0 : _g._menu) === null || _h === void 0 ? void 0 : _h.focusFirstItem('keyboard');
859
- }
860
- else {
861
- this._getMenuStack().close(this._parentMenu, 2 /* currentItem */);
862
- }
863
- }
864
- break;
865
- case keycodes.DOWN_ARROW:
866
- case keycodes.UP_ARROW:
867
- if (!this._isParentVertical()) {
868
- event.preventDefault();
869
- this.openMenu();
870
- keyCode === keycodes.DOWN_ARROW
871
- ? (_k = (_j = this.menuPanel) === null || _j === void 0 ? void 0 : _j._menu) === null || _k === void 0 ? void 0 : _k.focusFirstItem('keyboard')
872
- : (_m = (_l = this.menuPanel) === null || _l === void 0 ? void 0 : _l._menu) === null || _m === void 0 ? void 0 : _m.focusLastItem('keyboard');
873
- }
874
- break;
875
- }
876
- };
877
- /** Close out any sibling menu trigger menus. */
878
- CdkMenuItemTrigger.prototype._closeSiblingTriggers = function () {
879
- if (this._parentMenu) {
880
- var menuStack = this._getMenuStack();
881
- // If nothing was removed from the stack and the last element is not the parent item
882
- // that means that the parent menu is a menu bar since we don't put the menu bar on the
883
- // stack
884
- var isParentMenuBar = !menuStack.closeSubMenuOf(this._parentMenu) && menuStack.peek() !== this._parentMenu;
885
- if (isParentMenuBar) {
886
- menuStack.closeAll();
887
- }
888
- }
889
- else {
890
- this._getMenuStack().closeAll();
891
- }
892
- };
893
- /** Get the configuration object used to create the overlay */
894
- CdkMenuItemTrigger.prototype._getOverlayConfig = function () {
895
- return new overlay.OverlayConfig({
896
- positionStrategy: this._getOverlayPositionStrategy(),
897
- scrollStrategy: this._overlay.scrollStrategies.block(),
898
- direction: this._directionality,
899
- });
900
- };
901
- /** Build the position strategy for the overlay which specifies where to place the menu */
902
- CdkMenuItemTrigger.prototype._getOverlayPositionStrategy = function () {
903
- return this._overlay
904
- .position()
905
- .flexibleConnectedTo(this._elementRef)
906
- .withPositions(this._getOverlayPositions());
907
- };
908
- /** Determine and return where to position the opened menu relative to the menu item */
909
- CdkMenuItemTrigger.prototype._getOverlayPositions = function () {
910
- // TODO: use a common positioning config from (possibly) cdk/overlay
911
- return !this._parentMenu || this._parentMenu.orientation === 'horizontal'
912
- ? [
913
- { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
914
- { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
915
- { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },
916
- { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },
917
- ]
918
- : [
919
- { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },
920
- { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },
921
- { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
922
- { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },
923
- ];
924
- };
925
- /**
926
- * Get the portal to be attached to the overlay which contains the menu. Allows for the menu
927
- * content to change dynamically and be reflected in the application.
928
- */
929
- CdkMenuItemTrigger.prototype._getPortal = function () {
930
- var _a, _b;
931
- var hasMenuContentChanged = ((_a = this.menuPanel) === null || _a === void 0 ? void 0 : _a._templateRef) !== ((_b = this._panelContent) === null || _b === void 0 ? void 0 : _b.templateRef);
932
- if (this.menuPanel && (!this._panelContent || hasMenuContentChanged)) {
933
- this._panelContent = new portal.TemplatePortal(this.menuPanel._templateRef, this._viewContainerRef);
934
- }
935
- return this._panelContent;
936
- };
937
- /**
938
- * @return true if if the enclosing parent menu is configured in a vertical orientation.
939
- */
940
- CdkMenuItemTrigger.prototype._isParentVertical = function () {
941
- var _a;
942
- return ((_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a.orientation) === 'vertical';
943
- };
944
- /**
945
- * Subscribe to the MenuStack close events if this is a standalone trigger and close out the menu
946
- * this triggers when requested.
947
- */
948
- CdkMenuItemTrigger.prototype._registerCloseHandler = function () {
949
- var _this = this;
950
- if (!this._parentMenu) {
951
- this._menuStack.closed.pipe(operators.takeUntil(this._destroyed)).subscribe(function (item) {
952
- var _a;
953
- if (item === ((_a = _this._menuPanel) === null || _a === void 0 ? void 0 : _a._menu)) {
954
- _this.closeMenu();
955
- }
956
- });
957
- }
958
- };
959
- /** Get the menu stack for this trigger - either from the parent or this trigger. */
960
- CdkMenuItemTrigger.prototype._getMenuStack = function () {
961
- var _a;
962
- // We use a function since at the construction of the MenuItemTrigger the parent Menu won't have
963
- // its menu stack set. Therefore we need to reference the menu stack from the parent each time
964
- // we want to use it.
965
- return ((_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a._menuStack) || this._menuStack;
966
- };
967
- CdkMenuItemTrigger.prototype.ngOnDestroy = function () {
968
- this._destroyOverlay();
969
- this._resetPanelMenuStack();
970
- this._destroyed.next();
971
- this._destroyed.complete();
972
- };
973
- /** Set the menu panels menu stack back to null. */
974
- CdkMenuItemTrigger.prototype._resetPanelMenuStack = function () {
975
- // If a CdkMenuTrigger is placed in a submenu, each time the trigger is rendered (its parent
976
- // menu is opened) the panel setter for CdkMenuPanel is called. From the first render onward,
977
- // the attached CdkMenuPanel has the MenuStack set. Since we throw an error if a panel already
978
- // has a stack set, we want to reset the attached stack here to prevent the error from being
979
- // thrown if the trigger re-configures its attached panel (in the case where there is a 1:1
980
- // relationship between the panel and trigger).
981
- if (this._menuPanel) {
982
- this._menuPanel._menuStack = null;
983
- }
984
- };
985
- /**
986
- * Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
987
- * click occurs outside the menus.
988
- */
989
- CdkMenuItemTrigger.prototype._subscribeToOutsideClicks = function () {
990
- var _this = this;
991
- if (this._overlayRef) {
992
- this._overlayRef
993
- .outsidePointerEvents()
994
- .pipe(operators.takeUntil(this._stopOutsideClicksListener))
995
- .subscribe(function (event) {
996
- if (!isClickInsideMenuOverlay(event.target)) {
997
- _this._getMenuStack().closeAll();
998
- }
999
- });
1000
- }
1001
- };
1002
- /** Destroy and unset the overlay reference it if exists */
1003
- CdkMenuItemTrigger.prototype._destroyOverlay = function () {
1004
- if (this._overlayRef) {
1005
- this._overlayRef.dispose();
1006
- this._overlayRef = null;
1007
- }
1008
- };
1009
- return CdkMenuItemTrigger;
1010
- }());
1011
- CdkMenuItemTrigger.decorators = [
1012
- { type: i0.Directive, args: [{
1013
- selector: '[cdkMenuTriggerFor]',
1014
- exportAs: 'cdkMenuTriggerFor',
1015
- host: {
1016
- '(keydown)': '_toggleOnKeydown($event)',
1017
- '(click)': 'toggle()',
1018
- 'class': 'cdk-menu-trigger',
1019
- 'aria-haspopup': 'menu',
1020
- '[attr.aria-expanded]': 'isMenuOpen()',
1021
- },
1022
- },] }
1023
- ];
1024
- CdkMenuItemTrigger.ctorParameters = function () { return [
1025
- { type: i0.ElementRef },
1026
- { type: i0.ViewContainerRef },
1027
- { type: overlay.Overlay },
1028
- { type: i0.NgZone },
1029
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_MENU,] }] },
1030
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [MENU_AIM,] }] },
1031
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] }
1032
- ]; };
1033
- CdkMenuItemTrigger.propDecorators = {
1034
- menuPanel: [{ type: i0.Input, args: ['cdkMenuTriggerFor',] }],
1035
- opened: [{ type: i0.Output, args: ['cdkMenuOpened',] }],
1036
- closed: [{ type: i0.Output, args: ['cdkMenuClosed',] }]
1037
- };
1038
-
1039
- // TODO refactor this to be configurable allowing for custom elements to be removed
1040
- /** Removes all icons from within the given element. */
1041
- function removeIcons(element) {
1042
- var e_1, _g;
1043
- var _a;
1044
- try {
1045
- for (var _h = __values(Array.from(element.querySelectorAll('mat-icon, .material-icons'))), _j = _h.next(); !_j.done; _j = _h.next()) {
1046
- var icon = _j.value;
1047
- (_a = icon.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(icon);
1048
- }
1049
- }
1050
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1051
- finally {
1052
- try {
1053
- if (_j && !_j.done && (_g = _h.return)) _g.call(_h);
1054
- }
1055
- finally { if (e_1) throw e_1.error; }
1056
- }
1057
- }
1058
- /**
1059
- * Directive which provides the ability for an element to be focused and navigated to using the
1060
- * keyboard when residing in a CdkMenu, CdkMenuBar, or CdkMenuGroup. It performs user defined
1061
- * behavior when clicked.
1062
- */
1063
- var CdkMenuItem = /** @class */ (function () {
1064
- function CdkMenuItem(_elementRef, _ngZone, _parentMenu, _menuAim, _dir,
1065
- /** Reference to the CdkMenuItemTrigger directive if one is added to the same element */
1066
- // `CdkMenuItem` is commonly used in combination with a `CdkMenuItemTrigger`.
1067
- // tslint:disable-next-line: lightweight-tokens
1068
- _menuTrigger) {
1069
- this._elementRef = _elementRef;
1070
- this._ngZone = _ngZone;
1071
- this._parentMenu = _parentMenu;
1072
- this._menuAim = _menuAim;
1073
- this._dir = _dir;
1074
- this._menuTrigger = _menuTrigger;
1075
- this._disabled = false;
1076
- /**
1077
- * If this MenuItem is a regular MenuItem, outputs when it is triggered by a keyboard or mouse
1078
- * event.
1079
- */
1080
- this.triggered = new i0.EventEmitter();
1081
- /**
1082
- * The tabindex for this menu item managed internally and used for implementing roving a
1083
- * tab index.
1084
- */
1085
- this._tabindex = -1;
1086
- /** Emits when the menu item is destroyed. */
1087
- this._destroyed = new rxjs.Subject();
1088
- this._setupMouseEnter();
1089
- if (this._isStandaloneItem()) {
1090
- this._tabindex = 0;
1091
- }
1092
- }
1093
- Object.defineProperty(CdkMenuItem.prototype, "disabled", {
1094
- /** Whether the CdkMenuItem is disabled - defaults to false */
1095
- get: function () {
1096
- return this._disabled;
1097
- },
1098
- set: function (value) {
1099
- this._disabled = coercion.coerceBooleanProperty(value);
1100
- },
1101
- enumerable: false,
1102
- configurable: true
1103
- });
1104
- /** Place focus on the element. */
1105
- CdkMenuItem.prototype.focus = function () {
1106
- this._elementRef.nativeElement.focus();
1107
- };
1108
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1109
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1110
- // can move this back into `host`.
1111
- // tslint:disable:no-host-decorator-in-concrete
1112
- /** Reset the _tabindex to -1. */
1113
- CdkMenuItem.prototype._resetTabIndex = function () {
1114
- if (!this._isStandaloneItem()) {
1115
- this._tabindex = -1;
1116
- }
1117
- };
1118
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1119
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1120
- // can move this back into `host`.
1121
- // tslint:disable:no-host-decorator-in-concrete
1122
- /**
1123
- * Set the tab index to 0 if not disabled and it's a focus event, or a mouse enter if this element
1124
- * is not in a menu bar.
1125
- */
1126
- CdkMenuItem.prototype._setTabIndex = function (event) {
1127
- var _a;
1128
- if (this.disabled) {
1129
- return;
1130
- }
1131
- // don't set the tabindex if there are no open sibling or parent menus
1132
- if (!event || !((_a = this._getMenuStack()) === null || _a === void 0 ? void 0 : _a.isEmpty())) {
1133
- this._tabindex = 0;
1134
- }
1135
- };
1136
- /** Whether this menu item is standalone or within a menu or menu bar. */
1137
- CdkMenuItem.prototype._isStandaloneItem = function () {
1138
- return !this._parentMenu;
1139
- };
1140
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1141
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1142
- // can move this back into `host`.
1143
- // tslint:disable:no-host-decorator-in-concrete
1144
- /**
1145
- * If the menu item is not disabled and the element does not have a menu trigger attached, emit
1146
- * on the cdkMenuItemTriggered emitter and close all open menus.
1147
- */
1148
- CdkMenuItem.prototype.trigger = function () {
1149
- var _a;
1150
- if (!this.disabled && !this.hasMenu()) {
1151
- this.triggered.next();
1152
- (_a = this._getMenuStack()) === null || _a === void 0 ? void 0 : _a.closeAll();
1153
- }
1154
- };
1155
- /** Whether the menu item opens a menu. */
1156
- CdkMenuItem.prototype.hasMenu = function () {
1157
- var _a;
1158
- return !!((_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.hasMenu());
1159
- };
1160
- /** Return true if this MenuItem has an attached menu and it is open. */
1161
- CdkMenuItem.prototype.isMenuOpen = function () {
1162
- var _a;
1163
- return !!((_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.isMenuOpen());
1164
- };
1165
- /**
1166
- * Get a reference to the rendered Menu if the Menu is open and it is visible in the DOM.
1167
- * @return the menu if it is open, otherwise undefined.
1168
- */
1169
- CdkMenuItem.prototype.getMenu = function () {
1170
- var _a;
1171
- return (_a = this._menuTrigger) === null || _a === void 0 ? void 0 : _a.getMenu();
1172
- };
1173
- /** Get the MenuItemTrigger associated with this element. */
1174
- CdkMenuItem.prototype.getMenuTrigger = function () {
1175
- return this._menuTrigger;
1176
- };
1177
- /** Get the label for this element which is required by the FocusableOption interface. */
1178
- CdkMenuItem.prototype.getLabel = function () {
1179
- var _a;
1180
- // TODO cloning the tree may be expensive; implement a better method
1181
- // we know that the current node is an element type
1182
- var clone = this._elementRef.nativeElement.cloneNode(true);
1183
- removeIcons(clone);
1184
- return ((_a = clone.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
1185
- };
1186
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1187
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1188
- // can move this back into `host`.
1189
- // tslint:disable:no-host-decorator-in-concrete
1190
- /**
1191
- * Handles keyboard events for the menu item, specifically either triggering the user defined
1192
- * callback or opening/closing the current menu based on whether the left or right arrow key was
1193
- * pressed.
1194
- * @param event the keyboard event to handle
1195
- */
1196
- CdkMenuItem.prototype._onKeydown = function (event) {
1197
- var _a, _b, _c, _d, _e, _f;
1198
- switch (event.keyCode) {
1199
- case keycodes.SPACE:
1200
- case keycodes.ENTER:
1201
- event.preventDefault();
1202
- this.trigger();
1203
- break;
1204
- case keycodes.RIGHT_ARROW:
1205
- if (this._parentMenu && this._isParentVertical() && !this.hasMenu()) {
1206
- event.preventDefault();
1207
- ((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) === 'rtl'
1208
- ? (_b = this._getMenuStack()) === null || _b === void 0 ? void 0 : _b.close(this._parentMenu, 1 /* previousItem */)
1209
- : (_c = this._getMenuStack()) === null || _c === void 0 ? void 0 : _c.closeAll(0 /* nextItem */);
1210
- }
1211
- break;
1212
- case keycodes.LEFT_ARROW:
1213
- if (this._parentMenu && this._isParentVertical() && !this.hasMenu()) {
1214
- event.preventDefault();
1215
- ((_d = this._dir) === null || _d === void 0 ? void 0 : _d.value) === 'rtl'
1216
- ? (_e = this._getMenuStack()) === null || _e === void 0 ? void 0 : _e.closeAll(0 /* nextItem */)
1217
- : (_f = this._getMenuStack()) === null || _f === void 0 ? void 0 : _f.close(this._parentMenu, 1 /* previousItem */);
1218
- }
1219
- break;
1220
- }
1221
- };
1222
- /**
1223
- * Subscribe to the mouseenter events and close any sibling menu items if this element is moused
1224
- * into.
1225
- */
1226
- CdkMenuItem.prototype._setupMouseEnter = function () {
1227
- var _this = this;
1228
- if (!this._isStandaloneItem()) {
1229
- var closeOpenSiblings_1 = function () { return _this._ngZone.run(function () { var _a; return (_a = _this._getMenuStack()) === null || _a === void 0 ? void 0 : _a.closeSubMenuOf(_this._parentMenu); }); };
1230
- this._ngZone.runOutsideAngular(function () { return rxjs.fromEvent(_this._elementRef.nativeElement, 'mouseenter')
1231
- .pipe(operators.filter(function () { var _a; return !((_a = _this._getMenuStack()) === null || _a === void 0 ? void 0 : _a.isEmpty()) && !_this.hasMenu(); }), operators.takeUntil(_this._destroyed))
1232
- .subscribe(function () {
1233
- if (_this._menuAim) {
1234
- _this._menuAim.toggle(closeOpenSiblings_1);
1235
- }
1236
- else {
1237
- closeOpenSiblings_1();
1238
- }
1239
- }); });
1240
- }
1241
- };
1242
- /**
1243
- * Return true if the enclosing parent menu is configured in a horizontal orientation, false
1244
- * otherwise or if no parent.
1245
- */
1246
- CdkMenuItem.prototype._isParentVertical = function () {
1247
- var _a;
1248
- return ((_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a.orientation) === 'vertical';
1249
- };
1250
- /** Get the MenuStack from the parent menu. */
1251
- CdkMenuItem.prototype._getMenuStack = function () {
1252
- var _a;
1253
- // We use a function since at the construction of the MenuItemTrigger the parent Menu won't have
1254
- // its menu stack set. Therefore we need to reference the menu stack from the parent each time
1255
- // we want to use it.
1256
- return (_a = this._parentMenu) === null || _a === void 0 ? void 0 : _a._menuStack;
1257
- };
1258
- CdkMenuItem.prototype.ngOnDestroy = function () {
1259
- this._destroyed.next();
1260
- };
1261
- return CdkMenuItem;
1262
- }());
1263
- CdkMenuItem.decorators = [
1264
- { type: i0.Directive, args: [{
1265
- selector: '[cdkMenuItem]',
1266
- exportAs: 'cdkMenuItem',
1267
- host: {
1268
- '[tabindex]': '_tabindex',
1269
- 'type': 'button',
1270
- 'role': 'menuitem',
1271
- 'class': 'cdk-menu-item',
1272
- '[attr.aria-disabled]': 'disabled || null',
1273
- },
1274
- },] }
1275
- ];
1276
- CdkMenuItem.ctorParameters = function () { return [
1277
- { type: i0.ElementRef },
1278
- { type: i0.NgZone },
1279
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_MENU,] }] },
1280
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [MENU_AIM,] }] },
1281
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
1282
- { type: CdkMenuItemTrigger, decorators: [{ type: i0.Self }, { type: i0.Optional }] }
1283
- ]; };
1284
- CdkMenuItem.propDecorators = {
1285
- disabled: [{ type: i0.Input }],
1286
- triggered: [{ type: i0.Output, args: ['cdkMenuItemTriggered',] }],
1287
- _resetTabIndex: [{ type: i0.HostListener, args: ['blur',] }, { type: i0.HostListener, args: ['mouseout',] }],
1288
- _setTabIndex: [{ type: i0.HostListener, args: ['focus',] }, { type: i0.HostListener, args: ['mouseenter', ['$event'],] }],
1289
- trigger: [{ type: i0.HostListener, args: ['click',] }],
1290
- _onKeydown: [{ type: i0.HostListener, args: ['keydown', ['$event'],] }]
1291
- };
1292
-
1293
- /** Counter used to set a unique id and name for a selectable item */
1294
- var nextId = 0;
1295
- /**
1296
- * Base class providing checked state for MenuItems along with outputting a clicked event when the
1297
- * element is triggered. It provides functionality for selectable elements.
1298
- */
1299
- var CdkMenuItemSelectable = /** @class */ (function (_super) {
1300
- __extends(CdkMenuItemSelectable, _super);
1301
- function CdkMenuItemSelectable() {
1302
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1303
- /** Event emitted when the selectable item is clicked */
1304
- _this.toggled = new i0.EventEmitter();
1305
- _this._checked = false;
1306
- /** The name of the selectable element with a default value */
1307
- _this.name = "cdk-selectable-item-" + nextId++;
1308
- /** The id of the selectable element with a default value */
1309
- _this.id = "cdk-selectable-item-" + nextId++;
1310
- return _this;
1311
- }
1312
- Object.defineProperty(CdkMenuItemSelectable.prototype, "checked", {
1313
- /** Whether the element is checked */
1314
- get: function () {
1315
- return this._checked;
1316
- },
1317
- set: function (value) {
1318
- this._checked = coercion.coerceBooleanProperty(value);
1319
- },
1320
- enumerable: false,
1321
- configurable: true
1322
- });
1323
- /** If the element is not disabled emit the click event */
1324
- CdkMenuItemSelectable.prototype.trigger = function () {
1325
- if (!this.disabled) {
1326
- this.toggled.next(this);
1327
- }
1328
- };
1329
- return CdkMenuItemSelectable;
1330
- }(CdkMenuItem));
1331
- CdkMenuItemSelectable.decorators = [
1332
- { type: i0.Directive }
1333
- ];
1334
- CdkMenuItemSelectable.propDecorators = {
1335
- toggled: [{ type: i0.Output, args: ['cdkMenuItemToggled',] }],
1336
- checked: [{ type: i0.Input }],
1337
- name: [{ type: i0.Input }],
1338
- id: [{ type: i0.Input }]
1339
- };
1340
-
1341
- /**
1342
- * @license
1343
- * Copyright Google LLC All Rights Reserved.
1344
- *
1345
- * Use of this source code is governed by an MIT-style license that can be
1346
- * found in the LICENSE file at https://angular.io/license
1347
- */
1348
- /**
1349
- * Directive which acts as a grouping container for `CdkMenuItem` instances with
1350
- * `role="menuitemradio"`, similar to a `role="radiogroup"` element.
1351
- */
1352
- var CdkMenuGroup = /** @class */ (function () {
1353
- function CdkMenuGroup() {
1354
- /** Emits the element when checkbox or radiobutton state changed */
1355
- this.change = new i0.EventEmitter();
1356
- /** Emits when the _selectableItems QueryList triggers a change */
1357
- this._selectableChanges = new i0.EventEmitter();
1358
- }
1359
- CdkMenuGroup.prototype.ngAfterContentInit = function () {
1360
- this._registerMenuSelectionListeners();
1361
- };
1362
- /**
1363
- * Register the child selectable elements with the change emitter and ensure any new child
1364
- * elements do so as well.
1365
- */
1366
- CdkMenuGroup.prototype._registerMenuSelectionListeners = function () {
1367
- var _this = this;
1368
- this._selectableItems.forEach(function (selectable) { return _this._registerClickListener(selectable); });
1369
- this._selectableItems.changes.subscribe(function (selectableItems) {
1370
- _this._selectableChanges.next();
1371
- selectableItems.forEach(function (selectable) { return _this._registerClickListener(selectable); });
1372
- });
1373
- };
1374
- /** Register each selectable to emit on the change Emitter when clicked */
1375
- CdkMenuGroup.prototype._registerClickListener = function (selectable) {
1376
- var _this = this;
1377
- selectable.toggled
1378
- .pipe(operators.takeUntil(this._selectableChanges))
1379
- .subscribe(function () { return _this.change.next(selectable); });
1380
- };
1381
- CdkMenuGroup.prototype.ngOnDestroy = function () {
1382
- this._selectableChanges.next();
1383
- this._selectableChanges.complete();
1384
- };
1385
- return CdkMenuGroup;
1386
- }());
1387
- CdkMenuGroup.decorators = [
1388
- { type: i0.Directive, args: [{
1389
- selector: '[cdkMenuGroup]',
1390
- exportAs: 'cdkMenuGroup',
1391
- host: {
1392
- 'role': 'group',
1393
- 'class': 'cdk-menu-group',
1394
- },
1395
- providers: [{ provide: collections.UniqueSelectionDispatcher, useClass: collections.UniqueSelectionDispatcher }],
1396
- },] }
1397
- ];
1398
- CdkMenuGroup.propDecorators = {
1399
- change: [{ type: i0.Output }],
1400
- _selectableItems: [{ type: i0.ContentChildren, args: [CdkMenuItemSelectable, { descendants: true },] }]
1401
- };
1402
-
1403
- /**
1404
- * @license
1405
- * Copyright Google LLC All Rights Reserved.
1406
- *
1407
- * Use of this source code is governed by an MIT-style license that can be
1408
- * found in the LICENSE file at https://angular.io/license
1409
- */
1410
- /**
1411
- * Directive applied to an ng-template which wraps a CdkMenu and provides a reference to the
1412
- * child element it wraps which allows for opening of the CdkMenu in an overlay.
1413
- */
1414
- var CdkMenuPanel = /** @class */ (function () {
1415
- function CdkMenuPanel(_templateRef) {
1416
- this._templateRef = _templateRef;
1417
- }
1418
- /**
1419
- * Set the Menu component on the menu panel. Since we cannot use ContentChild to fetch the
1420
- * child Menu component, the child Menu must register its self with the parent MenuPanel.
1421
- */
1422
- CdkMenuPanel.prototype._registerMenu = function (child) {
1423
- var _a;
1424
- this._menu = child;
1425
- // The ideal solution would be to affect the CdkMenuPanel injector from the CdkMenuTrigger and
1426
- // inject the menu stack reference into the child menu and menu items, however this isn't
1427
- // possible at this time.
1428
- this._menu._menuStack = this._menuStack;
1429
- (_a = this._menuStack) === null || _a === void 0 ? void 0 : _a.push(child);
1430
- };
1431
- return CdkMenuPanel;
1432
- }());
1433
- CdkMenuPanel.decorators = [
1434
- { type: i0.Directive, args: [{ selector: 'ng-template[cdkMenuPanel]', exportAs: 'cdkMenuPanel' },] }
1435
- ];
1436
- CdkMenuPanel.ctorParameters = function () { return [
1437
- { type: i0.TemplateRef }
1438
- ]; };
1439
-
1440
- /**
1441
- * @license
1442
- * Copyright Google LLC All Rights Reserved.
1443
- *
1444
- * Use of this source code is governed by an MIT-style license that can be
1445
- * found in the LICENSE file at https://angular.io/license
1446
- */
1447
- /**
1448
- * PointerFocusTracker keeps track of the currently active item under mouse focus. It also has
1449
- * observables which emit when the users mouse enters and leaves a tracked element.
1450
- */
1451
- var PointerFocusTracker = /** @class */ (function () {
1452
- function PointerFocusTracker(_items) {
1453
- var _this = this;
1454
- this._items = _items;
1455
- /** Emits when an element is moused into. */
1456
- this.entered = this._getItemPointerEntries();
1457
- /** Emits when an element is moused out. */
1458
- this.exited = this._getItemPointerExits();
1459
- /** Emits when this is destroyed. */
1460
- this._destroyed = new rxjs.Subject();
1461
- this.entered.subscribe(function (element) { return (_this.activeElement = element); });
1462
- this.exited.subscribe(function () {
1463
- _this.previousElement = _this.activeElement;
1464
- _this.activeElement = undefined;
1465
- });
1466
- }
1467
- /**
1468
- * Gets a stream of pointer (mouse) entries into the given items.
1469
- * This should typically run outside the Angular zone.
1470
- */
1471
- PointerFocusTracker.prototype._getItemPointerEntries = function () {
1472
- var _this = this;
1473
- return rxjs.defer(function () { return _this._items.changes.pipe(operators.startWith(_this._items), operators.mergeMap(function (list) { return list.map(function (element) { return rxjs.fromEvent(element._elementRef.nativeElement, 'mouseenter').pipe(operators.mapTo(element), operators.takeUntil(_this._items.changes)); }); }), operators.mergeAll()); });
1474
- };
1475
- /**
1476
- * Gets a stream of pointer (mouse) exits out of the given items.
1477
- * This should typically run outside the Angular zone.
1478
- */
1479
- PointerFocusTracker.prototype._getItemPointerExits = function () {
1480
- var _this = this;
1481
- return rxjs.defer(function () { return _this._items.changes.pipe(operators.startWith(_this._items), operators.mergeMap(function (list) { return list.map(function (element) { return rxjs.fromEvent(element._elementRef.nativeElement, 'mouseout').pipe(operators.mapTo(element), operators.takeUntil(_this._items.changes)); }); }), operators.mergeAll()); });
1482
- };
1483
- /** Stop the managers listeners. */
1484
- PointerFocusTracker.prototype.destroy = function () {
1485
- this._destroyed.next();
1486
- this._destroyed.complete();
1487
- };
1488
- return PointerFocusTracker;
1489
- }());
1490
-
1491
- /**
1492
- * Directive which configures the element as a Menu which should contain child elements marked as
1493
- * CdkMenuItem or CdkMenuGroup. Sets the appropriate role and aria-attributes for a menu and
1494
- * contains accessible keyboard and mouse handling logic.
1495
- *
1496
- * It also acts as a RadioGroup for elements marked with role `menuitemradio`.
1497
- */
1498
- var CdkMenu = /** @class */ (function (_super) {
1499
- __extends(CdkMenu, _super);
1500
- function CdkMenu(_ngZone, _elementRef, _menuAim, _dir,
1501
- // `CdkMenuPanel` is always used in combination with a `CdkMenu`.
1502
- // tslint:disable-next-line: lightweight-tokens
1503
- _menuPanel) {
1504
- var _this = _super.call(this) || this;
1505
- _this._ngZone = _ngZone;
1506
- _this._elementRef = _elementRef;
1507
- _this._menuAim = _menuAim;
1508
- _this._dir = _dir;
1509
- _this._menuPanel = _menuPanel;
1510
- /**
1511
- * Sets the aria-orientation attribute and determines where menus will be opened.
1512
- * Does not affect styling/layout.
1513
- */
1514
- _this.orientation = 'vertical';
1515
- /** Event emitted when the menu is closed. */
1516
- _this.closed = new i0.EventEmitter();
1517
- // We provide a default MenuStack implementation in case the menu is an inline menu.
1518
- // For Menus part of a MenuBar nested within a MenuPanel this will be overwritten
1519
- // to the correct parent MenuStack.
1520
- /** Track the Menus making up the open menu stack. */
1521
- _this._menuStack = new NoopMenuStack();
1522
- return _this;
1523
- }
1524
- CdkMenu.prototype.ngOnInit = function () {
1525
- this._registerWithParentPanel();
1526
- };
1527
- CdkMenu.prototype.ngAfterContentInit = function () {
1528
- var _a;
1529
- _super.prototype.ngAfterContentInit.call(this);
1530
- this._completeChangeEmitter();
1531
- this._setKeyManager();
1532
- this._subscribeToMenuOpen();
1533
- this._subscribeToMenuStack();
1534
- this._subscribeToMouseManager();
1535
- (_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this._pointerTracker);
1536
- };
1537
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1538
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1539
- // can move this back into `host`.
1540
- // tslint:disable:no-host-decorator-in-concrete
1541
- /** Place focus on the first MenuItem in the menu and set the focus origin. */
1542
- CdkMenu.prototype.focusFirstItem = function (focusOrigin) {
1543
- if (focusOrigin === void 0) { focusOrigin = 'program'; }
1544
- this._keyManager.setFocusOrigin(focusOrigin);
1545
- this._keyManager.setFirstItemActive();
1546
- };
1547
- /** Place focus on the last MenuItem in the menu and set the focus origin. */
1548
- CdkMenu.prototype.focusLastItem = function (focusOrigin) {
1549
- if (focusOrigin === void 0) { focusOrigin = 'program'; }
1550
- this._keyManager.setFocusOrigin(focusOrigin);
1551
- this._keyManager.setLastItemActive();
1552
- };
1553
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1554
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1555
- // can move this back into `host`.
1556
- // tslint:disable:no-host-decorator-in-concrete
1557
- /** Handle keyboard events for the Menu. */
1558
- CdkMenu.prototype._handleKeyEvent = function (event) {
1559
- var keyManager = this._keyManager;
1560
- switch (event.keyCode) {
1561
- case keycodes.LEFT_ARROW:
1562
- case keycodes.RIGHT_ARROW:
1563
- if (this._isHorizontal()) {
1564
- event.preventDefault();
1565
- keyManager.setFocusOrigin('keyboard');
1566
- keyManager.onKeydown(event);
1567
- }
1568
- break;
1569
- case keycodes.UP_ARROW:
1570
- case keycodes.DOWN_ARROW:
1571
- if (!this._isHorizontal()) {
1572
- event.preventDefault();
1573
- keyManager.setFocusOrigin('keyboard');
1574
- keyManager.onKeydown(event);
1575
- }
1576
- break;
1577
- case keycodes.ESCAPE:
1578
- if (!keycodes.hasModifierKey(event)) {
1579
- event.preventDefault();
1580
- this._menuStack.close(this, 2 /* currentItem */);
1581
- }
1582
- break;
1583
- case keycodes.TAB:
1584
- this._menuStack.closeAll();
1585
- break;
1586
- default:
1587
- keyManager.onKeydown(event);
1588
- }
1589
- };
1590
- /** Register this menu with its enclosing parent menu panel */
1591
- CdkMenu.prototype._registerWithParentPanel = function () {
1592
- var _a;
1593
- (_a = this._getMenuPanel()) === null || _a === void 0 ? void 0 : _a._registerMenu(this);
1594
- };
1595
- /**
1596
- * Get the enclosing CdkMenuPanel defaulting to the injected reference over the developer
1597
- * provided reference.
1598
- */
1599
- CdkMenu.prototype._getMenuPanel = function () {
1600
- return this._menuPanel || this._explicitPanel;
1601
- };
1602
- /**
1603
- * Complete the change emitter if there are any nested MenuGroups or register to complete the
1604
- * change emitter if a MenuGroup is rendered at some point
1605
- */
1606
- CdkMenu.prototype._completeChangeEmitter = function () {
1607
- var _this = this;
1608
- if (this._hasNestedGroups()) {
1609
- this.change.complete();
1610
- }
1611
- else {
1612
- this._nestedGroups.changes.pipe(operators.take(1)).subscribe(function () { return _this.change.complete(); });
1613
- }
1614
- };
1615
- /** Return true if there are nested CdkMenuGroup elements within the Menu */
1616
- CdkMenu.prototype._hasNestedGroups = function () {
1617
- // view engine has a bug where @ContentChildren will return the current element
1618
- // along with children if the selectors match - not just the children.
1619
- // Here, if there is at least one element, we check to see if the first element is a CdkMenu in
1620
- // order to ensure that we return true iff there are child CdkMenuGroup elements.
1621
- return this._nestedGroups.length > 0 && !(this._nestedGroups.first instanceof CdkMenu);
1622
- };
1623
- /** Setup the FocusKeyManager with the correct orientation for the menu. */
1624
- CdkMenu.prototype._setKeyManager = function () {
1625
- var _a;
1626
- this._keyManager = new a11y.FocusKeyManager(this._allItems)
1627
- .withWrap()
1628
- .withTypeAhead()
1629
- .withHomeAndEnd();
1630
- if (this._isHorizontal()) {
1631
- this._keyManager.withHorizontalOrientation(((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) || 'ltr');
1632
- }
1633
- else {
1634
- this._keyManager.withVerticalOrientation();
1635
- }
1636
- };
1637
- /**
1638
- * Set the PointerFocusTracker and ensure that when mouse focus changes the key manager is updated
1639
- * with the latest menu item under mouse focus.
1640
- */
1641
- CdkMenu.prototype._subscribeToMouseManager = function () {
1642
- var _this = this;
1643
- this._ngZone.runOutsideAngular(function () {
1644
- _this._pointerTracker = new PointerFocusTracker(_this._allItems);
1645
- _this._pointerTracker.entered
1646
- .pipe(operators.takeUntil(_this.closed))
1647
- .subscribe(function (item) { return _this._keyManager.setActiveItem(item); });
1648
- });
1649
- };
1650
- /** Subscribe to the MenuStack close and empty observables. */
1651
- CdkMenu.prototype._subscribeToMenuStack = function () {
1652
- var _this = this;
1653
- this._menuStack.closed
1654
- .pipe(operators.takeUntil(this.closed))
1655
- .subscribe(function (item) { return _this._closeOpenMenu(item); });
1656
- this._menuStack.emptied
1657
- .pipe(operators.takeUntil(this.closed))
1658
- .subscribe(function (event) { return _this._toggleMenuFocus(event); });
1659
- };
1660
- /**
1661
- * Close the open menu if the current active item opened the requested MenuStackItem.
1662
- * @param item the MenuStackItem requested to be closed.
1663
- */
1664
- CdkMenu.prototype._closeOpenMenu = function (menu) {
1665
- var _a, _b, _c;
1666
- var keyManager = this._keyManager;
1667
- var trigger = this._openItem;
1668
- if (menu === ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _a === void 0 ? void 0 : _a.getMenu())) {
1669
- (_b = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.closeMenu();
1670
- // If the user has moused over a sibling item we want to focus the element under mouse focus
1671
- // not the trigger which previously opened the now closed menu.
1672
- if (trigger) {
1673
- keyManager.setActiveItem(((_c = this._pointerTracker) === null || _c === void 0 ? void 0 : _c.activeElement) || trigger);
1674
- }
1675
- }
1676
- };
1677
- /** Set focus the either the current, previous or next item based on the FocusNext event. */
1678
- CdkMenu.prototype._toggleMenuFocus = function (event) {
1679
- var keyManager = this._keyManager;
1680
- switch (event) {
1681
- case 0 /* nextItem */:
1682
- keyManager.setFocusOrigin('keyboard');
1683
- keyManager.setNextItemActive();
1684
- break;
1685
- case 1 /* previousItem */:
1686
- keyManager.setFocusOrigin('keyboard');
1687
- keyManager.setPreviousItemActive();
1688
- break;
1689
- case 2 /* currentItem */:
1690
- if (keyManager.activeItem) {
1691
- keyManager.setFocusOrigin('keyboard');
1692
- keyManager.setActiveItem(keyManager.activeItem);
1693
- }
1694
- break;
1695
- }
1696
- };
1697
- // TODO(andy9775): remove duplicate logic between menu an menu bar
1698
- /**
1699
- * Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
1700
- * and stop tracking it when the menu is closed.
1701
- */
1702
- CdkMenu.prototype._subscribeToMenuOpen = function () {
1703
- var _this = this;
1704
- var exitCondition = rxjs.merge(this._allItems.changes, this.closed);
1705
- this._allItems.changes
1706
- .pipe(operators.startWith(this._allItems), operators.mergeMap(function (list) { return list
1707
- .filter(function (item) { return item.hasMenu(); })
1708
- .map(function (item) { return item.getMenuTrigger().opened.pipe(operators.mapTo(item), operators.takeUntil(exitCondition)); }); }), operators.mergeAll(), operators.switchMap(function (item) {
1709
- _this._openItem = item;
1710
- return item.getMenuTrigger().closed;
1711
- }), operators.takeUntil(this.closed))
1712
- .subscribe(function () { return (_this._openItem = undefined); });
1713
- };
1714
- /** Return true if this menu has been configured in a horizontal orientation. */
1715
- CdkMenu.prototype._isHorizontal = function () {
1716
- return this.orientation === 'horizontal';
1717
- };
1718
- /**
1719
- * Return true if this menu is an inline menu. That is, it does not exist in a pop-up and is
1720
- * always visible in the dom.
1721
- */
1722
- CdkMenu.prototype._isInline = function () {
1723
- // NoopMenuStack is the default. If this menu is not inline than the NoopMenuStack is replaced
1724
- // automatically.
1725
- return this._menuStack instanceof NoopMenuStack;
1726
- };
1727
- CdkMenu.prototype.ngOnDestroy = function () {
1728
- var _a;
1729
- this._emitClosedEvent();
1730
- (_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
1731
- };
1732
- /** Emit and complete the closed event emitter */
1733
- CdkMenu.prototype._emitClosedEvent = function () {
1734
- this.closed.next();
1735
- this.closed.complete();
1736
- };
1737
- return CdkMenu;
1738
- }(CdkMenuGroup));
1739
- CdkMenu.decorators = [
1740
- { type: i0.Directive, args: [{
1741
- selector: '[cdkMenu]',
1742
- exportAs: 'cdkMenu',
1743
- host: {
1744
- '[tabindex]': '_isInline() ? 0 : null',
1745
- 'role': 'menu',
1746
- 'class': 'cdk-menu',
1747
- '[class.cdk-menu-inline]': '_isInline()',
1748
- '[attr.aria-orientation]': 'orientation',
1749
- },
1750
- providers: [
1751
- { provide: CdkMenuGroup, useExisting: CdkMenu },
1752
- { provide: CDK_MENU, useExisting: CdkMenu },
1753
- ],
1754
- },] }
1755
- ];
1756
- CdkMenu.ctorParameters = function () { return [
1757
- { type: i0.NgZone },
1758
- { type: i0.ElementRef },
1759
- { type: undefined, decorators: [{ type: i0.Self }, { type: i0.Optional }, { type: i0.Inject, args: [MENU_AIM,] }] },
1760
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
1761
- { type: CdkMenuPanel, decorators: [{ type: i0.Optional }] }
1762
- ]; };
1763
- CdkMenu.propDecorators = {
1764
- orientation: [{ type: i0.Input, args: ['cdkMenuOrientation',] }],
1765
- closed: [{ type: i0.Output }],
1766
- _nestedGroups: [{ type: i0.ContentChildren, args: [CdkMenuGroup, { descendants: true },] }],
1767
- _allItems: [{ type: i0.ContentChildren, args: [CdkMenuItem, { descendants: true },] }],
1768
- _explicitPanel: [{ type: i0.Input, args: ['cdkMenuPanel',] }],
1769
- focusFirstItem: [{ type: i0.HostListener, args: ['focus',] }],
1770
- _handleKeyEvent: [{ type: i0.HostListener, args: ['keydown', ['$event'],] }]
1771
- };
1772
-
1773
- /**
1774
- * Directive applied to an element which configures it as a MenuBar by setting the appropriate
1775
- * role, aria attributes, and accessible keyboard and mouse handling logic. The component that
1776
- * this directive is applied to should contain components marked with CdkMenuItem.
1777
- *
1778
- */
1779
- var CdkMenuBar = /** @class */ (function (_super) {
1780
- __extends(CdkMenuBar, _super);
1781
- function CdkMenuBar(_menuStack, _ngZone, _elementRef, _menuAim, _dir) {
1782
- var _this = _super.call(this) || this;
1783
- _this._menuStack = _menuStack;
1784
- _this._ngZone = _ngZone;
1785
- _this._elementRef = _elementRef;
1786
- _this._menuAim = _menuAim;
1787
- _this._dir = _dir;
1788
- /**
1789
- * Sets the aria-orientation attribute and determines where menus will be opened.
1790
- * Does not affect styling/layout.
1791
- */
1792
- _this.orientation = 'horizontal';
1793
- /** Emits when the MenuBar is destroyed. */
1794
- _this._destroyed = new rxjs.Subject();
1795
- return _this;
1796
- }
1797
- CdkMenuBar.prototype.ngAfterContentInit = function () {
1798
- var _a;
1799
- _super.prototype.ngAfterContentInit.call(this);
1800
- this._setKeyManager();
1801
- this._subscribeToMenuOpen();
1802
- this._subscribeToMenuStack();
1803
- this._subscribeToMouseManager();
1804
- (_a = this._menuAim) === null || _a === void 0 ? void 0 : _a.initialize(this, this._pointerTracker);
1805
- };
1806
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1807
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1808
- // can move this back into `host`.
1809
- // tslint:disable:no-host-decorator-in-concrete
1810
- /** Place focus on the first MenuItem in the menu and set the focus origin. */
1811
- CdkMenuBar.prototype.focusFirstItem = function (focusOrigin) {
1812
- if (focusOrigin === void 0) { focusOrigin = 'program'; }
1813
- this._keyManager.setFocusOrigin(focusOrigin);
1814
- this._keyManager.setFirstItemActive();
1815
- };
1816
- /** Place focus on the last MenuItem in the menu and set the focus origin. */
1817
- CdkMenuBar.prototype.focusLastItem = function (focusOrigin) {
1818
- if (focusOrigin === void 0) { focusOrigin = 'program'; }
1819
- this._keyManager.setFocusOrigin(focusOrigin);
1820
- this._keyManager.setLastItemActive();
1821
- };
1822
- // In Ivy the `host` metadata will be merged, whereas in ViewEngine it is overridden. In order
1823
- // to avoid double event listeners, we need to use `HostListener`. Once Ivy is the default, we
1824
- // can move this back into `host`.
1825
- // tslint:disable:no-host-decorator-in-concrete
1826
- /**
1827
- * Handle keyboard events, specifically changing the focused element and/or toggling the active
1828
- * items menu.
1829
- * @param event the KeyboardEvent to handle.
1830
- */
1831
- CdkMenuBar.prototype._handleKeyEvent = function (event) {
1832
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1833
- var keyManager = this._keyManager;
1834
- switch (event.keyCode) {
1835
- case keycodes.UP_ARROW:
1836
- case keycodes.DOWN_ARROW:
1837
- case keycodes.LEFT_ARROW:
1838
- case keycodes.RIGHT_ARROW:
1839
- var horizontalArrows = event.keyCode === keycodes.LEFT_ARROW || event.keyCode === keycodes.RIGHT_ARROW;
1840
- // For a horizontal menu if the left/right keys were clicked, or a vertical menu if the
1841
- // up/down keys were clicked: if the current menu is open, close it then focus and open the
1842
- // next menu.
1843
- if ((this._isHorizontal() && horizontalArrows) ||
1844
- (!this._isHorizontal() && !horizontalArrows)) {
1845
- event.preventDefault();
1846
- var prevIsOpen = (_a = keyManager.activeItem) === null || _a === void 0 ? void 0 : _a.isMenuOpen();
1847
- (_c = (_b = keyManager.activeItem) === null || _b === void 0 ? void 0 : _b.getMenuTrigger()) === null || _c === void 0 ? void 0 : _c.closeMenu();
1848
- keyManager.setFocusOrigin('keyboard');
1849
- keyManager.onKeydown(event);
1850
- if (prevIsOpen) {
1851
- (_e = (_d = keyManager.activeItem) === null || _d === void 0 ? void 0 : _d.getMenuTrigger()) === null || _e === void 0 ? void 0 : _e.openMenu();
1852
- }
1853
- }
1854
- break;
1855
- case keycodes.ESCAPE:
1856
- event.preventDefault();
1857
- (_g = (_f = keyManager.activeItem) === null || _f === void 0 ? void 0 : _f.getMenuTrigger()) === null || _g === void 0 ? void 0 : _g.closeMenu();
1858
- break;
1859
- case keycodes.TAB:
1860
- (_j = (_h = keyManager.activeItem) === null || _h === void 0 ? void 0 : _h.getMenuTrigger()) === null || _j === void 0 ? void 0 : _j.closeMenu();
1861
- break;
1862
- default:
1863
- keyManager.onKeydown(event);
1864
- }
1865
- };
1866
- /** Setup the FocusKeyManager with the correct orientation for the menu bar. */
1867
- CdkMenuBar.prototype._setKeyManager = function () {
1868
- var _a;
1869
- this._keyManager = new a11y.FocusKeyManager(this._allItems)
1870
- .withWrap()
1871
- .withTypeAhead()
1872
- .withHomeAndEnd();
1873
- if (this._isHorizontal()) {
1874
- this._keyManager.withHorizontalOrientation(((_a = this._dir) === null || _a === void 0 ? void 0 : _a.value) || 'ltr');
1875
- }
1876
- else {
1877
- this._keyManager.withVerticalOrientation();
1878
- }
1879
- };
1880
- /**
1881
- * Set the PointerFocusTracker and ensure that when mouse focus changes the key manager is updated
1882
- * with the latest menu item under mouse focus.
1883
- */
1884
- CdkMenuBar.prototype._subscribeToMouseManager = function () {
1885
- var _this = this;
1886
- this._ngZone.runOutsideAngular(function () {
1887
- _this._pointerTracker = new PointerFocusTracker(_this._allItems);
1888
- _this._pointerTracker.entered.pipe(operators.takeUntil(_this._destroyed)).subscribe(function (item) {
1889
- if (_this._hasOpenSubmenu()) {
1890
- _this._keyManager.setActiveItem(item);
1891
- }
1892
- });
1893
- });
1894
- };
1895
- /** Subscribe to the MenuStack close and empty observables. */
1896
- CdkMenuBar.prototype._subscribeToMenuStack = function () {
1897
- var _this = this;
1898
- this._menuStack.closed
1899
- .pipe(operators.takeUntil(this._destroyed))
1900
- .subscribe(function (item) { return _this._closeOpenMenu(item); });
1901
- this._menuStack.emptied
1902
- .pipe(operators.takeUntil(this._destroyed))
1903
- .subscribe(function (event) { return _this._toggleOpenMenu(event); });
1904
- };
1905
- /**
1906
- * Close the open menu if the current active item opened the requested MenuStackItem.
1907
- * @param item the MenuStackItem requested to be closed.
1908
- */
1909
- CdkMenuBar.prototype._closeOpenMenu = function (menu) {
1910
- var _a, _b, _c;
1911
- var trigger = this._openItem;
1912
- var keyManager = this._keyManager;
1913
- if (menu === ((_a = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _a === void 0 ? void 0 : _a.getMenu())) {
1914
- (_b = trigger === null || trigger === void 0 ? void 0 : trigger.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.closeMenu();
1915
- // If the user has moused over a sibling item we want to focus the element under mouse focus
1916
- // not the trigger which previously opened the now closed menu.
1917
- if (trigger) {
1918
- keyManager.setActiveItem(((_c = this._pointerTracker) === null || _c === void 0 ? void 0 : _c.activeElement) || trigger);
1919
- }
1920
- }
1921
- };
1922
- /**
1923
- * Set focus to either the current, previous or next item based on the FocusNext event, then
1924
- * open the previous or next item.
1925
- */
1926
- CdkMenuBar.prototype._toggleOpenMenu = function (event) {
1927
- var _a, _b, _c, _d;
1928
- var keyManager = this._keyManager;
1929
- switch (event) {
1930
- case 0 /* nextItem */:
1931
- keyManager.setFocusOrigin('keyboard');
1932
- keyManager.setNextItemActive();
1933
- (_b = (_a = keyManager.activeItem) === null || _a === void 0 ? void 0 : _a.getMenuTrigger()) === null || _b === void 0 ? void 0 : _b.openMenu();
1934
- break;
1935
- case 1 /* previousItem */:
1936
- keyManager.setFocusOrigin('keyboard');
1937
- keyManager.setPreviousItemActive();
1938
- (_d = (_c = keyManager.activeItem) === null || _c === void 0 ? void 0 : _c.getMenuTrigger()) === null || _d === void 0 ? void 0 : _d.openMenu();
1939
- break;
1940
- case 2 /* currentItem */:
1941
- if (keyManager.activeItem) {
1942
- keyManager.setFocusOrigin('keyboard');
1943
- keyManager.setActiveItem(keyManager.activeItem);
1944
- }
1945
- break;
1946
- }
1947
- };
1948
- /**
1949
- * @return true if the menu bar is configured to be horizontal.
1950
- */
1951
- CdkMenuBar.prototype._isHorizontal = function () {
1952
- return this.orientation === 'horizontal';
1953
- };
1954
- /**
1955
- * Subscribe to the menu trigger's open events in order to track the trigger which opened the menu
1956
- * and stop tracking it when the menu is closed.
1957
- */
1958
- CdkMenuBar.prototype._subscribeToMenuOpen = function () {
1959
- var _this = this;
1960
- var exitCondition = rxjs.merge(this._allItems.changes, this._destroyed);
1961
- this._allItems.changes
1962
- .pipe(operators.startWith(this._allItems), operators.mergeMap(function (list) { return list
1963
- .filter(function (item) { return item.hasMenu(); })
1964
- .map(function (item) { return item.getMenuTrigger().opened.pipe(operators.mapTo(item), operators.takeUntil(exitCondition)); }); }), operators.mergeAll(), operators.switchMap(function (item) {
1965
- _this._openItem = item;
1966
- return item.getMenuTrigger().closed;
1967
- }), operators.takeUntil(this._destroyed))
1968
- .subscribe(function () { return (_this._openItem = undefined); });
1969
- };
1970
- /** Return true if the MenuBar has an open submenu. */
1971
- CdkMenuBar.prototype._hasOpenSubmenu = function () {
1972
- return !!this._openItem;
1973
- };
1974
- CdkMenuBar.prototype.ngOnDestroy = function () {
1975
- var _a;
1976
- _super.prototype.ngOnDestroy.call(this);
1977
- this._destroyed.next();
1978
- this._destroyed.complete();
1979
- (_a = this._pointerTracker) === null || _a === void 0 ? void 0 : _a.destroy();
1980
- };
1981
- return CdkMenuBar;
1982
- }(CdkMenuGroup));
1983
- CdkMenuBar.decorators = [
1984
- { type: i0.Directive, args: [{
1985
- selector: '[cdkMenuBar]',
1986
- exportAs: 'cdkMenuBar',
1987
- host: {
1988
- 'role': 'menubar',
1989
- 'class': 'cdk-menu-bar',
1990
- 'tabindex': '0',
1991
- '[attr.aria-orientation]': 'orientation',
1992
- },
1993
- providers: [
1994
- { provide: CdkMenuGroup, useExisting: CdkMenuBar },
1995
- { provide: CDK_MENU, useExisting: CdkMenuBar },
1996
- { provide: MenuStack, useClass: MenuStack },
1997
- ],
1998
- },] }
1999
- ];
2000
- CdkMenuBar.ctorParameters = function () { return [
2001
- { type: MenuStack },
2002
- { type: i0.NgZone },
2003
- { type: i0.ElementRef },
2004
- { type: undefined, decorators: [{ type: i0.Self }, { type: i0.Optional }, { type: i0.Inject, args: [MENU_AIM,] }] },
2005
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] }
2006
- ]; };
2007
- CdkMenuBar.propDecorators = {
2008
- orientation: [{ type: i0.Input, args: ['cdkMenuBarOrientation',] }],
2009
- _allItems: [{ type: i0.ContentChildren, args: [CdkMenuItem, { descendants: true },] }],
2010
- focusFirstItem: [{ type: i0.HostListener, args: ['focus',] }],
2011
- _handleKeyEvent: [{ type: i0.HostListener, args: ['keydown', ['$event'],] }]
2012
- };
2013
-
2014
- /**
2015
- * A directive providing behavior for the "menuitemradio" ARIA role, which behaves similarly to
2016
- * a conventional radio-button. Any sibling `CdkMenuItemRadio` instances within the same `CdkMenu`
2017
- * or `CdkMenuGroup` comprise a radio group with unique selection enforced.
2018
- */
2019
- var CdkMenuItemRadio = /** @class */ (function (_super) {
2020
- __extends(CdkMenuItemRadio, _super);
2021
- function CdkMenuItemRadio(_selectionDispatcher, element, ngZone, parentMenu, menuAim, dir,
2022
- /** Reference to the CdkMenuItemTrigger directive if one is added to the same element */
2023
- // `CdkMenuItemRadio` is commonly used in combination with a `CdkMenuItemTrigger`.
2024
- // tslint:disable-next-line: lightweight-tokens
2025
- menuTrigger) {
2026
- var _this = _super.call(this, element, ngZone, parentMenu, menuAim, dir, menuTrigger) || this;
2027
- _this._selectionDispatcher = _selectionDispatcher;
2028
- _this._registerDispatcherListener();
2029
- return _this;
2030
- }
2031
- /** Configure the unique selection dispatcher listener in order to toggle the checked state */
2032
- CdkMenuItemRadio.prototype._registerDispatcherListener = function () {
2033
- var _this = this;
2034
- this._removeDispatcherListener = this._selectionDispatcher.listen(function (id, name) { return (_this.checked = _this.id === id && _this.name === name); });
2035
- };
2036
- /** Toggles the checked state of the radio-button. */
2037
- CdkMenuItemRadio.prototype.trigger = function () {
2038
- _super.prototype.trigger.call(this);
2039
- if (!this.disabled) {
2040
- this._selectionDispatcher.notify(this.id, this.name);
2041
- }
2042
- };
2043
- CdkMenuItemRadio.prototype.ngOnDestroy = function () {
2044
- _super.prototype.ngOnDestroy.call(this);
2045
- this._removeDispatcherListener();
2046
- };
2047
- return CdkMenuItemRadio;
2048
- }(CdkMenuItemSelectable));
2049
- CdkMenuItemRadio.decorators = [
2050
- { type: i0.Directive, args: [{
2051
- selector: '[cdkMenuItemRadio]',
2052
- exportAs: 'cdkMenuItemRadio',
2053
- host: {
2054
- '[tabindex]': '_tabindex',
2055
- 'type': 'button',
2056
- 'role': 'menuitemradio',
2057
- '[attr.aria-checked]': 'checked || null',
2058
- '[attr.aria-disabled]': 'disabled || null',
2059
- },
2060
- providers: [
2061
- { provide: CdkMenuItemSelectable, useExisting: CdkMenuItemRadio },
2062
- { provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
2063
- ],
2064
- },] }
2065
- ];
2066
- CdkMenuItemRadio.ctorParameters = function () { return [
2067
- { type: collections.UniqueSelectionDispatcher },
2068
- { type: i0.ElementRef },
2069
- { type: i0.NgZone },
2070
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [CDK_MENU,] }] },
2071
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [MENU_AIM,] }] },
2072
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] },
2073
- { type: CdkMenuItemTrigger, decorators: [{ type: i0.Self }, { type: i0.Optional }] }
2074
- ]; };
2075
-
2076
- /**
2077
- * A directive providing behavior for the "menuitemcheckbox" ARIA role, which behaves similarly to a
2078
- * conventional checkbox.
2079
- */
2080
- var CdkMenuItemCheckbox = /** @class */ (function (_super) {
2081
- __extends(CdkMenuItemCheckbox, _super);
2082
- function CdkMenuItemCheckbox() {
2083
- return _super !== null && _super.apply(this, arguments) || this;
2084
- }
2085
- /** Toggle the checked state of the checkbox. */
2086
- CdkMenuItemCheckbox.prototype.trigger = function () {
2087
- _super.prototype.trigger.call(this);
2088
- if (!this.disabled) {
2089
- this.checked = !this.checked;
2090
- }
2091
- };
2092
- return CdkMenuItemCheckbox;
2093
- }(CdkMenuItemSelectable));
2094
- CdkMenuItemCheckbox.decorators = [
2095
- { type: i0.Directive, args: [{
2096
- selector: '[cdkMenuItemCheckbox]',
2097
- exportAs: 'cdkMenuItemCheckbox',
2098
- host: {
2099
- '[tabindex]': '_tabindex',
2100
- 'type': 'button',
2101
- 'role': 'menuitemcheckbox',
2102
- '[attr.aria-checked]': 'checked || null',
2103
- '[attr.aria-disabled]': 'disabled || null',
2104
- },
2105
- providers: [
2106
- { provide: CdkMenuItemSelectable, useExisting: CdkMenuItemCheckbox },
2107
- { provide: CdkMenuItem, useExisting: CdkMenuItemSelectable },
2108
- ],
2109
- },] }
2110
- ];
2111
-
2112
- /**
2113
- * @license
2114
- * Copyright Google LLC All Rights Reserved.
2115
- *
2116
- * Use of this source code is governed by an MIT-style license that can be
2117
- * found in the LICENSE file at https://angular.io/license
2118
- */
2119
- /** Tracks the last open context menu trigger across the entire application. */
2120
- var ContextMenuTracker = /** @class */ (function () {
2121
- function ContextMenuTracker() {
2122
- }
2123
- /**
2124
- * Close the previous open context menu and set the given one as being open.
2125
- * @param trigger the trigger for the currently open Context Menu.
2126
- */
2127
- ContextMenuTracker.prototype.update = function (trigger) {
2128
- var _a;
2129
- if (ContextMenuTracker._openContextMenuTrigger !== trigger) {
2130
- (_a = ContextMenuTracker._openContextMenuTrigger) === null || _a === void 0 ? void 0 : _a.close();
2131
- ContextMenuTracker._openContextMenuTrigger = trigger;
2132
- }
2133
- };
2134
- return ContextMenuTracker;
2135
- }());
2136
- ContextMenuTracker.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ContextMenuTracker_Factory() { return new ContextMenuTracker(); }, token: ContextMenuTracker, providedIn: "root" });
2137
- ContextMenuTracker.decorators = [
2138
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
2139
- ];
2140
- /** Injection token for the ContextMenu options object. */
2141
- var CDK_CONTEXT_MENU_DEFAULT_OPTIONS = new i0.InjectionToken('cdk-context-menu-default-options');
2142
- var ɵ0 = { offsetX: 2, offsetY: 2 };
2143
- /**
2144
- * A directive which when placed on some element opens a the Menu it is bound to when a user
2145
- * right-clicks within that element. It is aware of nested Context Menus and the lowest level
2146
- * non-disabled context menu will trigger.
2147
- */
2148
- var CdkContextMenuTrigger = /** @class */ (function () {
2149
- function CdkContextMenuTrigger(_viewContainerRef, _overlay, _contextMenuTracker, _options, _directionality) {
2150
- this._viewContainerRef = _viewContainerRef;
2151
- this._overlay = _overlay;
2152
- this._contextMenuTracker = _contextMenuTracker;
2153
- this._options = _options;
2154
- this._directionality = _directionality;
2155
- /** Emits when the attached menu is requested to open. */
2156
- this.opened = new i0.EventEmitter();
2157
- /** Emits when the attached menu is requested to close. */
2158
- this.closed = new i0.EventEmitter();
2159
- this._disabled = false;
2160
- /** A reference to the overlay which manages the triggered menu. */
2161
- this._overlayRef = null;
2162
- /** Emits when the element is destroyed. */
2163
- this._destroyed = new rxjs.Subject();
2164
- /** The menu stack for this trigger and its associated menus. */
2165
- this._menuStack = new MenuStack();
2166
- /** Emits when the outside pointer events listener on the overlay should be stopped. */
2167
- this._stopOutsideClicksListener = rxjs.merge(this.closed, this._destroyed);
2168
- this._setMenuStackListener();
2169
- }
2170
- Object.defineProperty(CdkContextMenuTrigger.prototype, "menuPanel", {
2171
- /** Template reference variable to the menu to open on right click. */
2172
- get: function () {
2173
- return this._menuPanel;
2174
- },
2175
- set: function (panel) {
2176
- if ((typeof ngDevMode === 'undefined' || ngDevMode) && panel._menuStack) {
2177
- throwExistingMenuStackError();
2178
- }
2179
- this._menuPanel = panel;
2180
- if (this._menuPanel) {
2181
- this._menuPanel._menuStack = this._menuStack;
2182
- }
2183
- },
2184
- enumerable: false,
2185
- configurable: true
2186
- });
2187
- Object.defineProperty(CdkContextMenuTrigger.prototype, "disabled", {
2188
- /** Whether the context menu should be disabled. */
2189
- get: function () {
2190
- return this._disabled;
2191
- },
2192
- set: function (value) {
2193
- this._disabled = coercion.coerceBooleanProperty(value);
2194
- },
2195
- enumerable: false,
2196
- configurable: true
2197
- });
2198
- /**
2199
- * Open the attached menu at the specified location.
2200
- * @param coordinates where to open the context menu
2201
- */
2202
- CdkContextMenuTrigger.prototype.open = function (coordinates) {
2203
- if (this.disabled) {
2204
- return;
2205
- }
2206
- else if (this.isOpen()) {
2207
- // since we're moving this menu we need to close any submenus first otherwise they end up
2208
- // disconnected from this one.
2209
- this._menuStack.closeSubMenuOf(this._menuPanel._menu);
2210
- this._overlayRef.getConfig()
2211
- .positionStrategy.setOrigin(coordinates);
2212
- this._overlayRef.updatePosition();
2213
- }
2214
- else {
2215
- this.opened.next();
2216
- if (this._overlayRef) {
2217
- this._overlayRef.getConfig()
2218
- .positionStrategy.setOrigin(coordinates);
2219
- this._overlayRef.updatePosition();
2220
- }
2221
- else {
2222
- this._overlayRef = this._overlay.create(this._getOverlayConfig(coordinates));
2223
- }
2224
- this._overlayRef.attach(this._getMenuContent());
2225
- this._subscribeToOutsideClicks();
2226
- }
2227
- };
2228
- /** Close the opened menu. */
2229
- CdkContextMenuTrigger.prototype.close = function () {
2230
- this._menuStack.closeAll();
2231
- };
2232
- /**
2233
- * Open the context menu and close any previously open menus.
2234
- * @param event the mouse event which opens the context menu.
2235
- */
2236
- CdkContextMenuTrigger.prototype._openOnContextMenu = function (event) {
2237
- var _a, _b, _c;
2238
- if (!this.disabled) {
2239
- // Prevent the native context menu from opening because we're opening a custom one.
2240
- event.preventDefault();
2241
- // Stop event propagation to ensure that only the closest enabled context menu opens.
2242
- // Otherwise, any context menus attached to containing elements would *also* open,
2243
- // resulting in multiple stacked context menus being displayed.
2244
- event.stopPropagation();
2245
- this._contextMenuTracker.update(this);
2246
- this.open({ x: event.clientX, y: event.clientY });
2247
- // A context menu can be triggered via a mouse right click or a keyboard shortcut.
2248
- if (event.button === 2) {
2249
- (_a = this._menuPanel._menu) === null || _a === void 0 ? void 0 : _a.focusFirstItem('mouse');
2250
- }
2251
- else if (event.button === 0) {
2252
- (_b = this._menuPanel._menu) === null || _b === void 0 ? void 0 : _b.focusFirstItem('keyboard');
2253
- }
2254
- else {
2255
- (_c = this._menuPanel._menu) === null || _c === void 0 ? void 0 : _c.focusFirstItem('program');
2256
- }
2257
- }
2258
- };
2259
- /** Whether the attached menu is open. */
2260
- CdkContextMenuTrigger.prototype.isOpen = function () {
2261
- var _a;
2262
- return !!((_a = this._overlayRef) === null || _a === void 0 ? void 0 : _a.hasAttached());
2263
- };
2264
- /**
2265
- * Get the configuration object used to create the overlay.
2266
- * @param coordinates the location to place the opened menu
2267
- */
2268
- CdkContextMenuTrigger.prototype._getOverlayConfig = function (coordinates) {
2269
- return new overlay.OverlayConfig({
2270
- positionStrategy: this._getOverlayPositionStrategy(coordinates),
2271
- scrollStrategy: this._overlay.scrollStrategies.block(),
2272
- direction: this._directionality,
2273
- });
2274
- };
2275
- /**
2276
- * Build the position strategy for the overlay which specifies where to place the menu.
2277
- * @param coordinates the location to place the opened menu
2278
- */
2279
- CdkContextMenuTrigger.prototype._getOverlayPositionStrategy = function (coordinates) {
2280
- return this._overlay
2281
- .position()
2282
- .flexibleConnectedTo(coordinates)
2283
- .withDefaultOffsetX(this._options.offsetX)
2284
- .withDefaultOffsetY(this._options.offsetY)
2285
- .withPositions(this._getOverlayPositions());
2286
- };
2287
- /**
2288
- * Determine and return where to position the opened menu relative to the mouse location.
2289
- */
2290
- CdkContextMenuTrigger.prototype._getOverlayPositions = function () {
2291
- // TODO: this should be configurable through the injected context menu options
2292
- return [
2293
- { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },
2294
- { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
2295
- { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },
2296
- { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },
2297
- ];
2298
- };
2299
- /**
2300
- * Get the portal to be attached to the overlay which contains the menu. Allows for the menu
2301
- * content to change dynamically and be reflected in the application.
2302
- */
2303
- CdkContextMenuTrigger.prototype._getMenuContent = function () {
2304
- var _a;
2305
- var hasMenuContentChanged = this.menuPanel._templateRef !== ((_a = this._panelContent) === null || _a === void 0 ? void 0 : _a.templateRef);
2306
- if (this.menuPanel && (!this._panelContent || hasMenuContentChanged)) {
2307
- this._panelContent = new portal.TemplatePortal(this.menuPanel._templateRef, this._viewContainerRef);
2308
- }
2309
- return this._panelContent;
2310
- };
2311
- /** Subscribe to the menu stack close events and close this menu when requested. */
2312
- CdkContextMenuTrigger.prototype._setMenuStackListener = function () {
2313
- var _this = this;
2314
- this._menuStack.closed.pipe(operators.takeUntil(this._destroyed)).subscribe(function (item) {
2315
- if (item === _this._menuPanel._menu && _this.isOpen()) {
2316
- _this.closed.next();
2317
- _this._overlayRef.detach();
2318
- }
2319
- });
2320
- };
2321
- /**
2322
- * Subscribe to the overlays outside pointer events stream and handle closing out the stack if a
2323
- * click occurs outside the menus.
2324
- */
2325
- CdkContextMenuTrigger.prototype._subscribeToOutsideClicks = function () {
2326
- var _this = this;
2327
- if (this._overlayRef) {
2328
- this._overlayRef
2329
- .outsidePointerEvents()
2330
- .pipe(operators.takeUntil(this._stopOutsideClicksListener))
2331
- .subscribe(function (event) {
2332
- if (!isClickInsideMenuOverlay(event.target)) {
2333
- _this._menuStack.closeAll();
2334
- }
2335
- });
2336
- }
2337
- };
2338
- CdkContextMenuTrigger.prototype.ngOnDestroy = function () {
2339
- this._destroyOverlay();
2340
- this._resetPanelMenuStack();
2341
- this._destroyed.next();
2342
- this._destroyed.complete();
2343
- };
2344
- /** Destroy and unset the overlay reference it if exists. */
2345
- CdkContextMenuTrigger.prototype._destroyOverlay = function () {
2346
- if (this._overlayRef) {
2347
- this._overlayRef.dispose();
2348
- this._overlayRef = null;
2349
- }
2350
- };
2351
- /** Set the menu panels menu stack back to null. */
2352
- CdkContextMenuTrigger.prototype._resetPanelMenuStack = function () {
2353
- // If a ContextMenuTrigger is placed in a conditionally rendered view, each time the trigger is
2354
- // rendered the panel setter for ContextMenuTrigger is called. From the first render onward,
2355
- // the attached CdkMenuPanel has the MenuStack set. Since we throw an error if a panel already
2356
- // has a stack set, we want to reset the attached stack here to prevent the error from being
2357
- // thrown if the trigger re-configures its attached panel (in the case where there is a 1:1
2358
- // relationship between the panel and trigger).
2359
- if (this._menuPanel) {
2360
- this._menuPanel._menuStack = null;
2361
- }
2362
- };
2363
- return CdkContextMenuTrigger;
2364
- }());
2365
- CdkContextMenuTrigger.decorators = [
2366
- { type: i0.Directive, args: [{
2367
- selector: '[cdkContextMenuTriggerFor]',
2368
- exportAs: 'cdkContextMenuTriggerFor',
2369
- host: {
2370
- '(contextmenu)': '_openOnContextMenu($event)',
2371
- },
2372
- providers: [
2373
- // In cases where the first menu item in the context menu is a trigger the submenu opens on a
2374
- // hover event. Offsetting the opened context menu by 2px prevents this from occurring.
2375
- { provide: CDK_CONTEXT_MENU_DEFAULT_OPTIONS, useValue: ɵ0 },
2376
- ],
2377
- },] }
2378
- ];
2379
- CdkContextMenuTrigger.ctorParameters = function () { return [
2380
- { type: i0.ViewContainerRef },
2381
- { type: overlay.Overlay },
2382
- { type: ContextMenuTracker },
2383
- { type: undefined, decorators: [{ type: i0.Inject, args: [CDK_CONTEXT_MENU_DEFAULT_OPTIONS,] }] },
2384
- { type: bidi.Directionality, decorators: [{ type: i0.Optional }] }
2385
- ]; };
2386
- CdkContextMenuTrigger.propDecorators = {
2387
- menuPanel: [{ type: i0.Input, args: ['cdkContextMenuTriggerFor',] }],
2388
- opened: [{ type: i0.Output, args: ['cdkContextMenuOpened',] }],
2389
- closed: [{ type: i0.Output, args: ['cdkContextMenuClosed',] }],
2390
- disabled: [{ type: i0.Input, args: ['cdkContextMenuDisabled',] }]
2391
- };
2392
-
2393
- /**
2394
- * @license
2395
- * Copyright Google LLC All Rights Reserved.
2396
- *
2397
- * Use of this source code is governed by an MIT-style license that can be
2398
- * found in the LICENSE file at https://angular.io/license
2399
- */
2400
- var EXPORTED_DECLARATIONS = [
2401
- CdkMenuBar,
2402
- CdkMenu,
2403
- CdkMenuPanel,
2404
- CdkMenuItem,
2405
- CdkMenuItemRadio,
2406
- CdkMenuItemCheckbox,
2407
- CdkMenuItemTrigger,
2408
- CdkMenuGroup,
2409
- CdkContextMenuTrigger,
2410
- CdkTargetMenuAim,
2411
- ];
2412
- var CdkMenuModule = /** @class */ (function () {
2413
- function CdkMenuModule() {
2414
- }
2415
- return CdkMenuModule;
2416
- }());
2417
- CdkMenuModule.decorators = [
2418
- { type: i0.NgModule, args: [{
2419
- imports: [overlay.OverlayModule],
2420
- exports: EXPORTED_DECLARATIONS,
2421
- declarations: EXPORTED_DECLARATIONS,
2422
- },] }
2423
- ];
2424
-
2425
- /**
2426
- * @license
2427
- * Copyright Google LLC All Rights Reserved.
2428
- *
2429
- * Use of this source code is governed by an MIT-style license that can be
2430
- * found in the LICENSE file at https://angular.io/license
2431
- */
2432
-
2433
- /**
2434
- * Generated bundle index. Do not edit.
2435
- */
2436
-
2437
- exports.CDK_CONTEXT_MENU_DEFAULT_OPTIONS = CDK_CONTEXT_MENU_DEFAULT_OPTIONS;
2438
- exports.CDK_MENU = CDK_MENU;
2439
- exports.CdkContextMenuTrigger = CdkContextMenuTrigger;
2440
- exports.CdkMenu = CdkMenu;
2441
- exports.CdkMenuBar = CdkMenuBar;
2442
- exports.CdkMenuGroup = CdkMenuGroup;
2443
- exports.CdkMenuItem = CdkMenuItem;
2444
- exports.CdkMenuItemCheckbox = CdkMenuItemCheckbox;
2445
- exports.CdkMenuItemRadio = CdkMenuItemRadio;
2446
- exports.CdkMenuItemTrigger = CdkMenuItemTrigger;
2447
- exports.CdkMenuModule = CdkMenuModule;
2448
- exports.CdkMenuPanel = CdkMenuPanel;
2449
- exports.CdkTargetMenuAim = CdkTargetMenuAim;
2450
- exports.ContextMenuTracker = ContextMenuTracker;
2451
- exports.MENU_AIM = MENU_AIM;
2452
- exports.MenuStack = MenuStack;
2453
- exports.TargetMenuAim = TargetMenuAim;
2454
- exports.isClickInsideMenuOverlay = isClickInsideMenuOverlay;
2455
- exports.ɵ0 = ɵ0;
2456
- exports.ɵangular_material_src_cdk_experimental_menu_menu_b = CdkMenuItemSelectable;
2457
-
2458
- Object.defineProperty(exports, '__esModule', { value: true });
2459
-
2460
- })));
2461
- //# sourceMappingURL=cdk-experimental-menu.umd.js.map