@angular/cdk 14.0.0-next.1 → 14.0.0-next.12

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 (357) hide show
  1. package/a11y/_index.scss +11 -0
  2. package/a11y/a11y-module.d.ts +2 -3
  3. package/a11y/focus-monitor/focus-monitor.d.ts +1 -1
  4. package/a11y/focus-trap/focus-trap.d.ts +1 -1
  5. package/a11y/live-announcer/live-announcer.d.ts +5 -1
  6. package/a11y-prebuilt.css +1 -1
  7. package/accordion/accordion-item.d.ts +1 -1
  8. package/accordion/accordion.d.ts +1 -1
  9. package/bidi/dir.d.ts +1 -1
  10. package/clipboard/copy-to-clipboard.d.ts +1 -1
  11. package/dialog/dialog-config.d.ts +115 -0
  12. package/dialog/dialog-container.d.ts +95 -0
  13. package/dialog/dialog-injectors.d.ts +24 -0
  14. package/dialog/dialog-module.d.ts +10 -0
  15. package/dialog/dialog-ref.d.ts +64 -0
  16. package/dialog/dialog.d.ts +103 -0
  17. package/dialog/dialog_public_index.d.ts +4 -0
  18. package/dialog/index.d.ts +8 -0
  19. package/dialog/package.json +9 -0
  20. package/dialog/public-api.d.ts +13 -0
  21. package/drag-drop/directives/drag-handle.d.ts +1 -1
  22. package/drag-drop/directives/drag-placeholder.d.ts +1 -1
  23. package/drag-drop/directives/drag-preview.d.ts +1 -1
  24. package/drag-drop/directives/drag.d.ts +8 -9
  25. package/drag-drop/directives/drop-list-group.d.ts +1 -1
  26. package/drag-drop/directives/drop-list.d.ts +1 -1
  27. package/drag-drop/drag-events.d.ts +8 -0
  28. package/drag-drop/drag-ref.d.ts +11 -1
  29. package/drag-drop/drop-list-ref.d.ts +5 -1
  30. package/drag-drop/parent-position-tracker.d.ts +11 -3
  31. package/esm2020/a11y/a11y-module.mjs +6 -7
  32. package/esm2020/a11y/aria-describer/aria-describer.mjs +4 -4
  33. package/esm2020/a11y/focus-monitor/focus-monitor.mjs +13 -11
  34. package/esm2020/a11y/focus-trap/configurable-focus-trap-factory.mjs +4 -4
  35. package/esm2020/a11y/focus-trap/focus-trap-manager.mjs +4 -4
  36. package/esm2020/a11y/focus-trap/focus-trap.mjs +7 -7
  37. package/esm2020/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +7 -12
  38. package/esm2020/a11y/input-modality/input-modality-detector.mjs +4 -4
  39. package/esm2020/a11y/interactivity-checker/interactivity-checker.mjs +4 -4
  40. package/esm2020/a11y/live-announcer/live-announcer.mjs +26 -18
  41. package/esm2020/accordion/accordion-item.mjs +4 -4
  42. package/esm2020/accordion/accordion-module.mjs +5 -5
  43. package/esm2020/accordion/accordion.mjs +4 -4
  44. package/esm2020/bidi/bidi-module.mjs +5 -5
  45. package/esm2020/bidi/dir.mjs +4 -4
  46. package/esm2020/bidi/directionality.mjs +4 -4
  47. package/esm2020/clipboard/clipboard-module.mjs +5 -5
  48. package/esm2020/clipboard/clipboard.mjs +4 -4
  49. package/esm2020/clipboard/copy-to-clipboard.mjs +4 -4
  50. package/esm2020/collections/unique-selection-dispatcher.mjs +4 -4
  51. package/esm2020/dialog/dialog-config.mjs +58 -0
  52. package/esm2020/dialog/dialog-container.mjs +265 -0
  53. package/esm2020/dialog/dialog-injectors.mjs +26 -0
  54. package/esm2020/dialog/dialog-module.mjs +42 -0
  55. package/esm2020/dialog/dialog-ref.mjs +76 -0
  56. package/esm2020/dialog/dialog.mjs +285 -0
  57. package/esm2020/dialog/dialog_public_index.mjs +5 -0
  58. package/esm2020/dialog/index.mjs +9 -0
  59. package/esm2020/dialog/public-api.mjs +14 -0
  60. package/esm2020/drag-drop/directives/drag-handle.mjs +4 -4
  61. package/esm2020/drag-drop/directives/drag-placeholder.mjs +4 -4
  62. package/esm2020/drag-drop/directives/drag-preview.mjs +4 -4
  63. package/esm2020/drag-drop/directives/drag.mjs +33 -24
  64. package/esm2020/drag-drop/directives/drop-list-group.mjs +4 -4
  65. package/esm2020/drag-drop/directives/drop-list.mjs +14 -13
  66. package/esm2020/drag-drop/drag-drop-module.mjs +5 -5
  67. package/esm2020/drag-drop/drag-drop-registry.mjs +4 -4
  68. package/esm2020/drag-drop/drag-drop.mjs +4 -4
  69. package/esm2020/drag-drop/drag-events.mjs +1 -1
  70. package/esm2020/drag-drop/drag-ref.mjs +48 -24
  71. package/esm2020/drag-drop/drop-list-ref.mjs +7 -3
  72. package/esm2020/drag-drop/parent-position-tracker.mjs +13 -5
  73. package/esm2020/layout/breakpoints-observer.mjs +4 -4
  74. package/esm2020/layout/layout-module.mjs +5 -5
  75. package/esm2020/layout/media-matcher.mjs +4 -4
  76. package/esm2020/menu/context-menu-trigger.mjs +227 -0
  77. package/esm2020/menu/index.mjs +9 -0
  78. package/esm2020/menu/menu-aim.mjs +204 -0
  79. package/esm2020/menu/menu-bar.mjs +159 -0
  80. package/esm2020/menu/menu-base.mjs +203 -0
  81. package/esm2020/menu/menu-errors.mjs +22 -0
  82. package/esm2020/menu/menu-group.mjs +30 -0
  83. package/esm2020/menu/menu-interface.mjs +11 -0
  84. package/esm2020/menu/menu-item-checkbox.mjs +48 -0
  85. package/esm2020/menu/menu-item-radio.mjs +114 -0
  86. package/esm2020/menu/menu-item-selectable.mjs +42 -0
  87. package/esm2020/menu/menu-item.mjs +289 -0
  88. package/esm2020/menu/menu-module.mjs +62 -0
  89. package/esm2020/menu/menu-stack.mjs +156 -0
  90. package/esm2020/menu/menu-trigger-base.mjs +114 -0
  91. package/esm2020/menu/menu-trigger.mjs +302 -0
  92. package/esm2020/menu/menu.mjs +168 -0
  93. package/esm2020/menu/menu_public_index.mjs +5 -0
  94. package/esm2020/menu/pointer-focus-tracker.mjs +51 -0
  95. package/esm2020/menu/public-api.mjs +24 -0
  96. package/esm2020/observers/observe-content.mjs +14 -14
  97. package/esm2020/overlay/dispatchers/base-overlay-dispatcher.mjs +4 -4
  98. package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +26 -8
  99. package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +33 -12
  100. package/esm2020/overlay/fullscreen-overlay-container.mjs +4 -4
  101. package/esm2020/overlay/overlay-container.mjs +4 -4
  102. package/esm2020/overlay/overlay-directives.mjs +7 -7
  103. package/esm2020/overlay/overlay-module.mjs +5 -5
  104. package/esm2020/overlay/overlay-ref.mjs +27 -20
  105. package/esm2020/overlay/overlay.mjs +14 -8
  106. package/esm2020/overlay/position/flexible-connected-position-strategy.mjs +13 -1
  107. package/esm2020/overlay/position/global-position-strategy.mjs +64 -30
  108. package/esm2020/overlay/position/overlay-position-builder.mjs +4 -4
  109. package/esm2020/overlay/public-api.mjs +2 -2
  110. package/esm2020/overlay/scroll/scroll-strategy-options.mjs +4 -4
  111. package/esm2020/platform/platform-module.mjs +5 -5
  112. package/esm2020/platform/platform.mjs +4 -4
  113. package/esm2020/portal/dom-portal-outlet.mjs +29 -5
  114. package/esm2020/portal/portal-directives.mjs +20 -18
  115. package/esm2020/portal/portal.mjs +12 -3
  116. package/esm2020/scrolling/fixed-size-virtual-scroll.mjs +4 -4
  117. package/esm2020/scrolling/scroll-dispatcher.mjs +4 -4
  118. package/esm2020/scrolling/scrollable.mjs +4 -4
  119. package/esm2020/scrolling/scrolling-module.mjs +10 -11
  120. package/esm2020/scrolling/viewport-ruler.mjs +4 -4
  121. package/esm2020/scrolling/virtual-for-of.mjs +7 -5
  122. package/esm2020/scrolling/virtual-scroll-viewport.mjs +8 -6
  123. package/esm2020/stepper/step-header.mjs +4 -4
  124. package/esm2020/stepper/step-label.mjs +4 -4
  125. package/esm2020/stepper/stepper-button.mjs +7 -7
  126. package/esm2020/stepper/stepper-module.mjs +5 -5
  127. package/esm2020/stepper/stepper.mjs +9 -22
  128. package/esm2020/table/cell.mjs +22 -22
  129. package/esm2020/table/coalesced-style-scheduler.mjs +4 -4
  130. package/esm2020/table/row.mjs +28 -28
  131. package/esm2020/table/table-module.mjs +5 -5
  132. package/esm2020/table/table.mjs +21 -21
  133. package/esm2020/table/text-column.mjs +5 -5
  134. package/esm2020/testing/component-harness.mjs +7 -1
  135. package/esm2020/testing/harness-environment.mjs +12 -1
  136. package/esm2020/testing/public-api.mjs +2 -1
  137. package/esm2020/testing/selenium-webdriver/selenium-web-driver-element.mjs +8 -3
  138. package/esm2020/testing/test-element-errors.mjs +15 -0
  139. package/esm2020/testing/test-element.mjs +1 -1
  140. package/esm2020/testing/testbed/fake-events/type-in-element.mjs +13 -4
  141. package/esm2020/testing/testbed/unit-test-element.mjs +21 -5
  142. package/esm2020/text-field/autofill.mjs +7 -7
  143. package/esm2020/text-field/autosize.mjs +4 -4
  144. package/esm2020/text-field/text-field-module.mjs +5 -7
  145. package/esm2020/tree/nested-node.mjs +4 -4
  146. package/esm2020/tree/node.mjs +4 -4
  147. package/esm2020/tree/outlet.mjs +4 -4
  148. package/esm2020/tree/padding.mjs +4 -4
  149. package/esm2020/tree/toggle.mjs +4 -4
  150. package/esm2020/tree/tree-module.mjs +5 -5
  151. package/esm2020/tree/tree.mjs +7 -7
  152. package/esm2020/version.mjs +1 -1
  153. package/fesm2015/a11y.mjs +71 -66
  154. package/fesm2015/a11y.mjs.map +1 -1
  155. package/fesm2015/accordion.mjs +10 -10
  156. package/fesm2015/accordion.mjs.map +1 -1
  157. package/fesm2015/bidi.mjs +10 -10
  158. package/fesm2015/bidi.mjs.map +1 -1
  159. package/fesm2015/cdk.mjs +1 -1
  160. package/fesm2015/cdk.mjs.map +1 -1
  161. package/fesm2015/clipboard.mjs +10 -10
  162. package/fesm2015/clipboard.mjs.map +1 -1
  163. package/fesm2015/coercion.mjs.map +1 -1
  164. package/fesm2015/collections.mjs +3 -3
  165. package/fesm2015/collections.mjs.map +1 -1
  166. package/fesm2015/dialog.mjs +749 -0
  167. package/fesm2015/dialog.mjs.map +1 -0
  168. package/fesm2015/drag-drop.mjs +133 -86
  169. package/fesm2015/drag-drop.mjs.map +1 -1
  170. package/fesm2015/keycodes.mjs.map +1 -1
  171. package/fesm2015/layout.mjs +10 -10
  172. package/fesm2015/layout.mjs.map +1 -1
  173. package/fesm2015/menu.mjs +2131 -0
  174. package/fesm2015/menu.mjs.map +1 -0
  175. package/fesm2015/observers.mjs +13 -13
  176. package/fesm2015/observers.mjs.map +1 -1
  177. package/fesm2015/overlay.mjs +197 -99
  178. package/fesm2015/overlay.mjs.map +1 -1
  179. package/fesm2015/platform.mjs +7 -7
  180. package/fesm2015/platform.mjs.map +1 -1
  181. package/fesm2015/portal.mjs +58 -24
  182. package/fesm2015/portal.mjs.map +1 -1
  183. package/fesm2015/scrolling.mjs +35 -31
  184. package/fesm2015/scrolling.mjs.map +1 -1
  185. package/fesm2015/stepper.mjs +24 -37
  186. package/fesm2015/stepper.mjs.map +1 -1
  187. package/fesm2015/table.mjs +79 -79
  188. package/fesm2015/table.mjs.map +1 -1
  189. package/fesm2015/testing/selenium-webdriver.mjs +7 -2
  190. package/fesm2015/testing/selenium-webdriver.mjs.map +1 -1
  191. package/fesm2015/testing/testbed.mjs +32 -8
  192. package/fesm2015/testing/testbed.mjs.map +1 -1
  193. package/fesm2015/testing.mjs +39 -1
  194. package/fesm2015/testing.mjs.map +1 -1
  195. package/fesm2015/text-field.mjs +14 -15
  196. package/fesm2015/text-field.mjs.map +1 -1
  197. package/fesm2015/tree.mjs +25 -25
  198. package/fesm2015/tree.mjs.map +1 -1
  199. package/fesm2020/a11y.mjs +70 -65
  200. package/fesm2020/a11y.mjs.map +1 -1
  201. package/fesm2020/accordion.mjs +10 -10
  202. package/fesm2020/accordion.mjs.map +1 -1
  203. package/fesm2020/bidi.mjs +10 -10
  204. package/fesm2020/bidi.mjs.map +1 -1
  205. package/fesm2020/cdk.mjs +1 -1
  206. package/fesm2020/cdk.mjs.map +1 -1
  207. package/fesm2020/clipboard.mjs +10 -10
  208. package/fesm2020/clipboard.mjs.map +1 -1
  209. package/fesm2020/coercion.mjs.map +1 -1
  210. package/fesm2020/collections.mjs +3 -3
  211. package/fesm2020/collections.mjs.map +1 -1
  212. package/fesm2020/dialog.mjs +753 -0
  213. package/fesm2020/dialog.mjs.map +1 -0
  214. package/fesm2020/drag-drop.mjs +132 -86
  215. package/fesm2020/drag-drop.mjs.map +1 -1
  216. package/fesm2020/keycodes.mjs.map +1 -1
  217. package/fesm2020/layout.mjs +10 -10
  218. package/fesm2020/layout.mjs.map +1 -1
  219. package/fesm2020/menu.mjs +2104 -0
  220. package/fesm2020/menu.mjs.map +1 -0
  221. package/fesm2020/observers.mjs +13 -13
  222. package/fesm2020/observers.mjs.map +1 -1
  223. package/fesm2020/overlay.mjs +197 -99
  224. package/fesm2020/overlay.mjs.map +1 -1
  225. package/fesm2020/platform.mjs +7 -7
  226. package/fesm2020/platform.mjs.map +1 -1
  227. package/fesm2020/portal.mjs +58 -24
  228. package/fesm2020/portal.mjs.map +1 -1
  229. package/fesm2020/scrolling.mjs +35 -31
  230. package/fesm2020/scrolling.mjs.map +1 -1
  231. package/fesm2020/stepper.mjs +24 -37
  232. package/fesm2020/stepper.mjs.map +1 -1
  233. package/fesm2020/table.mjs +79 -79
  234. package/fesm2020/table.mjs.map +1 -1
  235. package/fesm2020/testing/selenium-webdriver.mjs +7 -2
  236. package/fesm2020/testing/selenium-webdriver.mjs.map +1 -1
  237. package/fesm2020/testing/testbed.mjs +32 -8
  238. package/fesm2020/testing/testbed.mjs.map +1 -1
  239. package/fesm2020/testing.mjs +33 -1
  240. package/fesm2020/testing.mjs.map +1 -1
  241. package/fesm2020/text-field.mjs +14 -15
  242. package/fesm2020/text-field.mjs.map +1 -1
  243. package/fesm2020/tree.mjs +25 -25
  244. package/fesm2020/tree.mjs.map +1 -1
  245. package/menu/context-menu-trigger.d.ts +98 -0
  246. package/menu/index.d.ts +8 -0
  247. package/menu/menu-aim.d.ts +107 -0
  248. package/menu/menu-bar.d.ts +52 -0
  249. package/menu/menu-base.d.ts +104 -0
  250. package/menu/menu-errors.d.ts +17 -0
  251. package/menu/menu-group.d.ts +8 -0
  252. package/menu/menu-interface.d.ts +25 -0
  253. package/menu/menu-item-checkbox.d.ts +18 -0
  254. package/menu/menu-item-radio.d.ts +59 -0
  255. package/menu/menu-item-selectable.d.ts +21 -0
  256. package/menu/menu-item.d.ts +140 -0
  257. package/menu/menu-module.d.ts +17 -0
  258. package/menu/menu-stack.d.ts +122 -0
  259. package/menu/menu-trigger-base.d.ts +77 -0
  260. package/menu/menu-trigger.d.ts +104 -0
  261. package/menu/menu.d.ts +60 -0
  262. package/menu/menu_public_index.d.ts +4 -0
  263. package/menu/package.json +9 -0
  264. package/menu/pointer-focus-tracker.d.ts +47 -0
  265. package/menu/public-api.d.ts +23 -0
  266. package/observers/observe-content.d.ts +1 -1
  267. package/overlay/_index.scss +11 -1
  268. package/overlay/dispatchers/overlay-keyboard-dispatcher.d.ts +7 -2
  269. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +8 -2
  270. package/overlay/overlay-directives.d.ts +2 -2
  271. package/overlay/overlay-ref.d.ts +4 -1
  272. package/overlay/overlay.d.ts +3 -2
  273. package/overlay/position/flexible-connected-position-strategy.d.ts +2 -0
  274. package/overlay/position/global-position-strategy.d.ts +14 -3
  275. package/overlay/public-api.d.ts +1 -1
  276. package/overlay-prebuilt.css +1 -1
  277. package/package.json +19 -3
  278. package/portal/dom-portal-outlet.d.ts +17 -6
  279. package/portal/portal-directives.d.ts +4 -4
  280. package/portal/portal.d.ts +12 -2
  281. package/schematics/collection.json +2 -1
  282. package/schematics/index.js +6 -2
  283. package/schematics/index.mjs +6 -2
  284. package/schematics/migration.json +5 -0
  285. package/schematics/ng-add/index.js +1 -1
  286. package/schematics/ng-add/index.mjs +1 -1
  287. package/schematics/ng-generate/drag-drop/index.js +5 -14
  288. package/schematics/ng-generate/drag-drop/index.mjs +5 -14
  289. package/schematics/ng-generate/drag-drop/schema.json +1 -1
  290. package/schematics/ng-update/data/constructor-checks.js +7 -1
  291. package/schematics/ng-update/data/constructor-checks.mjs +7 -1
  292. package/schematics/ng-update/data/index.js +6 -2
  293. package/schematics/ng-update/data/index.mjs +6 -2
  294. package/schematics/ng-update/devkit-migration-rule.js +5 -14
  295. package/schematics/ng-update/devkit-migration-rule.mjs +5 -14
  296. package/schematics/ng-update/devkit-migration.js +1 -1
  297. package/schematics/ng-update/devkit-migration.mjs +1 -1
  298. package/schematics/ng-update/html-parsing/elements.js +2 -3
  299. package/schematics/ng-update/html-parsing/elements.mjs +2 -3
  300. package/schematics/ng-update/index.d.ts +2 -0
  301. package/schematics/ng-update/index.js +7 -2
  302. package/schematics/ng-update/index.mjs +7 -2
  303. package/schematics/ng-update/migrations/symbol-removal.js +2 -3
  304. package/schematics/ng-update/migrations/symbol-removal.mjs +2 -3
  305. package/schematics/ng-update/public-api.js +6 -2
  306. package/schematics/ng-update/public-api.mjs +6 -2
  307. package/schematics/tsconfig.json +2 -10
  308. package/schematics/update-tool/public-api.js +6 -2
  309. package/schematics/update-tool/public-api.mjs +6 -2
  310. package/schematics/update-tool/target-version.d.ts +2 -1
  311. package/schematics/update-tool/target-version.js +2 -1
  312. package/schematics/update-tool/target-version.mjs +2 -1
  313. package/schematics/utils/ast.js +11 -22
  314. package/schematics/utils/ast.mjs +11 -22
  315. package/schematics/utils/build-component.js +10 -15
  316. package/schematics/utils/build-component.mjs +10 -15
  317. package/schematics/utils/get-project.d.ts +1 -1
  318. package/schematics/utils/get-project.js +7 -2
  319. package/schematics/utils/get-project.mjs +7 -2
  320. package/schematics/utils/index.js +6 -2
  321. package/schematics/utils/index.mjs +6 -2
  322. package/schematics/utils/project-index-file.js +2 -2
  323. package/schematics/utils/project-index-file.mjs +2 -2
  324. package/schematics/utils/project-targets.js +3 -4
  325. package/schematics/utils/project-targets.mjs +3 -4
  326. package/schematics/utils/project-tsconfig-paths.js +16 -28
  327. package/schematics/utils/project-tsconfig-paths.mjs +16 -28
  328. package/scrolling/fixed-size-virtual-scroll.d.ts +1 -1
  329. package/scrolling/scrollable.d.ts +1 -1
  330. package/scrolling/scrolling-module.d.ts +1 -2
  331. package/scrolling/virtual-for-of.d.ts +1 -1
  332. package/scrolling/virtual-scroll-viewport.d.ts +1 -1
  333. package/stepper/step-header.d.ts +1 -1
  334. package/stepper/step-label.d.ts +1 -1
  335. package/stepper/stepper-button.d.ts +2 -2
  336. package/stepper/stepper.d.ts +5 -14
  337. package/table/cell.d.ts +7 -7
  338. package/table/row.d.ts +9 -9
  339. package/table/table.d.ts +8 -12
  340. package/table/text-column.d.ts +2 -2
  341. package/testing/component-harness.d.ts +18 -0
  342. package/testing/harness-environment.d.ts +2 -0
  343. package/testing/public-api.d.ts +1 -0
  344. package/testing/test-element-errors.d.ts +12 -0
  345. package/testing/test-element.d.ts +4 -2
  346. package/testing/testbed/fake-events/type-in-element.d.ts +2 -2
  347. package/testing/testbed/unit-test-element.d.ts +4 -1
  348. package/text-field/autofill.d.ts +1 -1
  349. package/text-field/autosize.d.ts +1 -1
  350. package/text-field/text-field-module.d.ts +1 -2
  351. package/text-field-prebuilt.css +1 -1
  352. package/tree/nested-node.d.ts +1 -1
  353. package/tree/node.d.ts +1 -1
  354. package/tree/outlet.d.ts +1 -1
  355. package/tree/padding.d.ts +1 -1
  356. package/tree/toggle.d.ts +1 -1
  357. package/tree/tree.d.ts +2 -2
@@ -0,0 +1,749 @@
1
+ import { _getFocusedElementPierceShadowDom } from '@angular/cdk/platform';
2
+ import * as i3 from '@angular/cdk/portal';
3
+ import { BasePortalOutlet, CdkPortalOutlet, ComponentPortal, TemplatePortal, PortalModule } from '@angular/cdk/portal';
4
+ import { DOCUMENT } from '@angular/common';
5
+ import * as i0 from '@angular/core';
6
+ import { Component, ViewEncapsulation, ChangeDetectionStrategy, Optional, Inject, ViewChild, InjectionToken, Injector, TemplateRef, InjectFlags, Injectable, SkipSelf, NgModule } from '@angular/core';
7
+ import * as i1 from '@angular/cdk/a11y';
8
+ import { A11yModule } from '@angular/cdk/a11y';
9
+ import * as i1$1 from '@angular/cdk/overlay';
10
+ import { Overlay, OverlayConfig, OverlayRef, OverlayModule } from '@angular/cdk/overlay';
11
+ import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
12
+ import { Subject, defer, of } from 'rxjs';
13
+ import { Directionality } from '@angular/cdk/bidi';
14
+ import { startWith } from 'rxjs/operators';
15
+
16
+ /**
17
+ * @license
18
+ * Copyright Google LLC All Rights Reserved.
19
+ *
20
+ * Use of this source code is governed by an MIT-style license that can be
21
+ * found in the LICENSE file at https://angular.io/license
22
+ */
23
+ /** Configuration for opening a modal dialog. */
24
+ class DialogConfig {
25
+ constructor() {
26
+ /** The ARIA role of the dialog element. */
27
+ this.role = 'dialog';
28
+ /** Optional CSS class or classes applied to the overlay panel. */
29
+ this.panelClass = '';
30
+ /** Whether the dialog has a backdrop. */
31
+ this.hasBackdrop = true;
32
+ /** Optional CSS class or classes applied to the overlay backdrop. */
33
+ this.backdropClass = '';
34
+ /** Whether the dialog closes with the escape key or pointer events outside the panel element. */
35
+ this.disableClose = false;
36
+ /** Width of the dialog. */
37
+ this.width = '';
38
+ /** Height of the dialog. */
39
+ this.height = '';
40
+ /** Data being injected into the child component. */
41
+ this.data = null;
42
+ /** ID of the element that describes the dialog. */
43
+ this.ariaDescribedBy = null;
44
+ /** ID of the element that labels the dialog. */
45
+ this.ariaLabelledBy = null;
46
+ /** Dialog label applied via `aria-label` */
47
+ this.ariaLabel = null;
48
+ /** Whether this a modal dialog. Used to set the `aria-modal` attribute. */
49
+ this.ariaModal = true;
50
+ /**
51
+ * Where the dialog should focus on open.
52
+ * @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or
53
+ * AutoFocusTarget instead.
54
+ */
55
+ this.autoFocus = 'first-tabbable';
56
+ /**
57
+ * Whether the dialog should restore focus to the previously-focused element upon closing.
58
+ * Has the following behavior based on the type that is passed in:
59
+ * - `boolean` - when true, will return focus to the element that was focused before the dialog
60
+ * was opened, otherwise won't restore focus at all.
61
+ * - `string` - focus will be restored to the first element that matches the CSS selector.
62
+ * - `HTMLElement` - focus will be restored to the specific element.
63
+ */
64
+ this.restoreFocus = true;
65
+ /**
66
+ * Whether the dialog should close when the user navigates backwards or forwards through browser
67
+ * history. This does not apply to navigation via anchor element unless using URL-hash based
68
+ * routing (`HashLocationStrategy` in the Angular router).
69
+ */
70
+ this.closeOnNavigation = true;
71
+ }
72
+ }
73
+
74
+ function throwDialogContentAlreadyAttachedError() {
75
+ throw Error('Attempting to attach dialog content after content is already attached');
76
+ }
77
+ /**
78
+ * Internal component that wraps user-provided dialog content.
79
+ * @docs-private
80
+ */
81
+ class CdkDialogContainer extends BasePortalOutlet {
82
+ constructor(_elementRef, _focusTrapFactory, _document, _config, _interactivityChecker, _ngZone, _overlayRef, _focusMonitor) {
83
+ super();
84
+ this._elementRef = _elementRef;
85
+ this._focusTrapFactory = _focusTrapFactory;
86
+ this._config = _config;
87
+ this._interactivityChecker = _interactivityChecker;
88
+ this._ngZone = _ngZone;
89
+ this._overlayRef = _overlayRef;
90
+ this._focusMonitor = _focusMonitor;
91
+ /** Element that was focused before the dialog was opened. Save this to restore upon close. */
92
+ this._elementFocusedBeforeDialogWasOpened = null;
93
+ /**
94
+ * Type of interaction that led to the dialog being closed. This is used to determine
95
+ * whether the focus style will be applied when returning focus to its original location
96
+ * after the dialog is closed.
97
+ */
98
+ this._closeInteractionType = null;
99
+ /**
100
+ * Attaches a DOM portal to the dialog container.
101
+ * @param portal Portal to be attached.
102
+ * @deprecated To be turned into a method.
103
+ * @breaking-change 10.0.0
104
+ */
105
+ this.attachDomPortal = (portal) => {
106
+ if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
107
+ throwDialogContentAlreadyAttachedError();
108
+ }
109
+ return this._portalOutlet.attachDomPortal(portal);
110
+ };
111
+ this._ariaLabelledBy = this._config.ariaLabelledBy || null;
112
+ this._document = _document;
113
+ }
114
+ ngAfterViewInit() {
115
+ this._initializeFocusTrap();
116
+ this._handleBackdropClicks();
117
+ this._captureInitialFocus();
118
+ }
119
+ /**
120
+ * Can be used by child classes to customize the initial focus
121
+ * capturing behavior (e.g. if it's tied to an animation).
122
+ */
123
+ _captureInitialFocus() {
124
+ this._trapFocus();
125
+ }
126
+ ngOnDestroy() {
127
+ this._restoreFocus();
128
+ }
129
+ /**
130
+ * Attach a ComponentPortal as content to this dialog container.
131
+ * @param portal Portal to be attached as the dialog content.
132
+ */
133
+ attachComponentPortal(portal) {
134
+ if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
135
+ throwDialogContentAlreadyAttachedError();
136
+ }
137
+ return this._portalOutlet.attachComponentPortal(portal);
138
+ }
139
+ /**
140
+ * Attach a TemplatePortal as content to this dialog container.
141
+ * @param portal Portal to be attached as the dialog content.
142
+ */
143
+ attachTemplatePortal(portal) {
144
+ if (this._portalOutlet.hasAttached() && (typeof ngDevMode === 'undefined' || ngDevMode)) {
145
+ throwDialogContentAlreadyAttachedError();
146
+ }
147
+ return this._portalOutlet.attachTemplatePortal(portal);
148
+ }
149
+ /**
150
+ * Focuses the provided element. If the element is not focusable, it will add a tabIndex
151
+ * attribute to forcefully focus it. The attribute is removed after focus is moved.
152
+ * @param element The element to focus.
153
+ */
154
+ _forceFocus(element, options) {
155
+ if (!this._interactivityChecker.isFocusable(element)) {
156
+ element.tabIndex = -1;
157
+ // The tabindex attribute should be removed to avoid navigating to that element again
158
+ this._ngZone.runOutsideAngular(() => {
159
+ const callback = () => {
160
+ element.removeEventListener('blur', callback);
161
+ element.removeEventListener('mousedown', callback);
162
+ element.removeAttribute('tabindex');
163
+ };
164
+ element.addEventListener('blur', callback);
165
+ element.addEventListener('mousedown', callback);
166
+ });
167
+ }
168
+ element.focus(options);
169
+ }
170
+ /**
171
+ * Focuses the first element that matches the given selector within the focus trap.
172
+ * @param selector The CSS selector for the element to set focus to.
173
+ */
174
+ _focusByCssSelector(selector, options) {
175
+ let elementToFocus = this._elementRef.nativeElement.querySelector(selector);
176
+ if (elementToFocus) {
177
+ this._forceFocus(elementToFocus, options);
178
+ }
179
+ }
180
+ /**
181
+ * Moves the focus inside the focus trap. When autoFocus is not set to 'dialog', if focus
182
+ * cannot be moved then focus will go to the dialog container.
183
+ */
184
+ _trapFocus() {
185
+ const element = this._elementRef.nativeElement;
186
+ // If were to attempt to focus immediately, then the content of the dialog would not yet be
187
+ // ready in instances where change detection has to run first. To deal with this, we simply
188
+ // wait for the microtask queue to be empty when setting focus when autoFocus isn't set to
189
+ // dialog. If the element inside the dialog can't be focused, then the container is focused
190
+ // so the user can't tab into other elements behind it.
191
+ switch (this._config.autoFocus) {
192
+ case false:
193
+ case 'dialog':
194
+ // Ensure that focus is on the dialog container. It's possible that a different
195
+ // component tried to move focus while the open animation was running. See:
196
+ // https://github.com/angular/components/issues/16215. Note that we only want to do this
197
+ // if the focus isn't inside the dialog already, because it's possible that the consumer
198
+ // turned off `autoFocus` in order to move focus themselves.
199
+ if (!this._containsFocus()) {
200
+ element.focus();
201
+ }
202
+ break;
203
+ case true:
204
+ case 'first-tabbable':
205
+ this._focusTrap.focusInitialElementWhenReady().then(focusedSuccessfully => {
206
+ // If we weren't able to find a focusable element in the dialog, then focus the dialog
207
+ // container instead.
208
+ if (!focusedSuccessfully) {
209
+ this._focusDialogContainer();
210
+ }
211
+ });
212
+ break;
213
+ case 'first-heading':
214
+ this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
215
+ break;
216
+ default:
217
+ this._focusByCssSelector(this._config.autoFocus);
218
+ break;
219
+ }
220
+ }
221
+ /** Restores focus to the element that was focused before the dialog opened. */
222
+ _restoreFocus() {
223
+ const focusConfig = this._config.restoreFocus;
224
+ let focusTargetElement = null;
225
+ if (typeof focusConfig === 'string') {
226
+ focusTargetElement = this._document.querySelector(focusConfig);
227
+ }
228
+ else if (typeof focusConfig === 'boolean') {
229
+ focusTargetElement = focusConfig ? this._elementFocusedBeforeDialogWasOpened : null;
230
+ }
231
+ else if (focusConfig) {
232
+ focusTargetElement = focusConfig;
233
+ }
234
+ // We need the extra check, because IE can set the `activeElement` to null in some cases.
235
+ if (this._config.restoreFocus &&
236
+ focusTargetElement &&
237
+ typeof focusTargetElement.focus === 'function') {
238
+ const activeElement = _getFocusedElementPierceShadowDom();
239
+ const element = this._elementRef.nativeElement;
240
+ // Make sure that focus is still inside the dialog or is on the body (usually because a
241
+ // non-focusable element like the backdrop was clicked) before moving it. It's possible that
242
+ // the consumer moved it themselves before the animation was done, in which case we shouldn't
243
+ // do anything.
244
+ if (!activeElement ||
245
+ activeElement === this._document.body ||
246
+ activeElement === element ||
247
+ element.contains(activeElement)) {
248
+ if (this._focusMonitor) {
249
+ this._focusMonitor.focusVia(focusTargetElement, this._closeInteractionType);
250
+ this._closeInteractionType = null;
251
+ }
252
+ else {
253
+ focusTargetElement.focus();
254
+ }
255
+ }
256
+ }
257
+ if (this._focusTrap) {
258
+ this._focusTrap.destroy();
259
+ }
260
+ }
261
+ /** Focuses the dialog container. */
262
+ _focusDialogContainer() {
263
+ // Note that there is no focus method when rendering on the server.
264
+ if (this._elementRef.nativeElement.focus) {
265
+ this._elementRef.nativeElement.focus();
266
+ }
267
+ }
268
+ /** Returns whether focus is inside the dialog. */
269
+ _containsFocus() {
270
+ const element = this._elementRef.nativeElement;
271
+ const activeElement = _getFocusedElementPierceShadowDom();
272
+ return element === activeElement || element.contains(activeElement);
273
+ }
274
+ /** Sets up the focus trap. */
275
+ _initializeFocusTrap() {
276
+ this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
277
+ // Save the previously focused element. This element will be re-focused
278
+ // when the dialog closes.
279
+ if (this._document) {
280
+ this._elementFocusedBeforeDialogWasOpened = _getFocusedElementPierceShadowDom();
281
+ }
282
+ }
283
+ /** Sets up the listener that handles clicks on the dialog backdrop. */
284
+ _handleBackdropClicks() {
285
+ // Clicking on the backdrop will move focus out of dialog.
286
+ // Recapture it if closing via the backdrop is disabled.
287
+ this._overlayRef.backdropClick().subscribe(() => {
288
+ if (this._config.disableClose && !this._containsFocus()) {
289
+ this._trapFocus();
290
+ }
291
+ });
292
+ }
293
+ }
294
+ CdkDialogContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: CdkDialogContainer, deps: [{ token: i0.ElementRef }, { token: i1.FocusTrapFactory }, { token: DOCUMENT, optional: true }, { token: DialogConfig }, { token: i1.InteractivityChecker }, { token: i0.NgZone }, { token: i1$1.OverlayRef }, { token: i1.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component });
295
+ CdkDialogContainer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "14.0.0-next.14", type: CdkDialogContainer, selector: "cdk-dialog-container", host: { attributes: { "tabindex": "-1" }, properties: { "attr.id": "_config.id || null", "attr.role": "_config.role", "attr.aria-modal": "_config.ariaModal", "attr.aria-labelledby": "_config.ariaLabel ? null : _ariaLabelledBy", "attr.aria-label": "_config.ariaLabel", "attr.aria-describedby": "_config.ariaDescribedBy || null" }, classAttribute: "cdk-dialog-container" }, viewQueries: [{ propertyName: "_portalOutlet", first: true, predicate: CdkPortalOutlet, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: "<ng-template cdkPortalOutlet></ng-template>\n", dependencies: [{ kind: "directive", type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.Default, encapsulation: i0.ViewEncapsulation.None });
296
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: CdkDialogContainer, decorators: [{
297
+ type: Component,
298
+ args: [{ selector: 'cdk-dialog-container', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.Default, host: {
299
+ 'class': 'cdk-dialog-container',
300
+ 'tabindex': '-1',
301
+ '[attr.id]': '_config.id || null',
302
+ '[attr.role]': '_config.role',
303
+ '[attr.aria-modal]': '_config.ariaModal',
304
+ '[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledBy',
305
+ '[attr.aria-label]': '_config.ariaLabel',
306
+ '[attr.aria-describedby]': '_config.ariaDescribedBy || null',
307
+ }, template: "<ng-template cdkPortalOutlet></ng-template>\n" }]
308
+ }], ctorParameters: function () {
309
+ return [{ type: i0.ElementRef }, { type: i1.FocusTrapFactory }, { type: undefined, decorators: [{
310
+ type: Optional
311
+ }, {
312
+ type: Inject,
313
+ args: [DOCUMENT]
314
+ }] }, { type: undefined, decorators: [{
315
+ type: Inject,
316
+ args: [DialogConfig]
317
+ }] }, { type: i1.InteractivityChecker }, { type: i0.NgZone }, { type: i1$1.OverlayRef }, { type: i1.FocusMonitor }];
318
+ }, propDecorators: { _portalOutlet: [{
319
+ type: ViewChild,
320
+ args: [CdkPortalOutlet, { static: true }]
321
+ }] } });
322
+
323
+ /**
324
+ * @license
325
+ * Copyright Google LLC All Rights Reserved.
326
+ *
327
+ * Use of this source code is governed by an MIT-style license that can be
328
+ * found in the LICENSE file at https://angular.io/license
329
+ */
330
+ /**
331
+ * Reference to a dialog opened via the Dialog service.
332
+ */
333
+ class DialogRef {
334
+ constructor(overlayRef, config) {
335
+ this.overlayRef = overlayRef;
336
+ this.config = config;
337
+ /** Emits when the dialog has been closed. */
338
+ this.closed = new Subject();
339
+ this.disableClose = config.disableClose;
340
+ this.backdropClick = overlayRef.backdropClick();
341
+ this.keydownEvents = overlayRef.keydownEvents();
342
+ this.outsidePointerEvents = overlayRef.outsidePointerEvents();
343
+ this.id = config.id; // By the time the dialog is created we are guaranteed to have an ID.
344
+ this.keydownEvents.subscribe(event => {
345
+ if (event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)) {
346
+ event.preventDefault();
347
+ this.close(undefined, { focusOrigin: 'keyboard' });
348
+ }
349
+ });
350
+ this.backdropClick.subscribe(() => {
351
+ if (!this.disableClose) {
352
+ this.close(undefined, { focusOrigin: 'mouse' });
353
+ }
354
+ });
355
+ }
356
+ /**
357
+ * Close the dialog.
358
+ * @param result Optional result to return to the dialog opener.
359
+ * @param options Additional options to customize the closing behavior.
360
+ */
361
+ close(result, options) {
362
+ if (this.containerInstance) {
363
+ const closedSubject = this.closed;
364
+ this.containerInstance._closeInteractionType = (options === null || options === void 0 ? void 0 : options.focusOrigin) || 'program';
365
+ this.overlayRef.dispose();
366
+ closedSubject.next(result);
367
+ closedSubject.complete();
368
+ this.componentInstance = this.containerInstance = null;
369
+ }
370
+ }
371
+ /** Updates the position of the dialog based on the current position strategy. */
372
+ updatePosition() {
373
+ this.overlayRef.updatePosition();
374
+ return this;
375
+ }
376
+ /**
377
+ * Updates the dialog's width and height.
378
+ * @param width New width of the dialog.
379
+ * @param height New height of the dialog.
380
+ */
381
+ updateSize(width = '', height = '') {
382
+ this.overlayRef.updateSize({ width, height });
383
+ return this;
384
+ }
385
+ /** Add a CSS class or an array of classes to the overlay pane. */
386
+ addPanelClass(classes) {
387
+ this.overlayRef.addPanelClass(classes);
388
+ return this;
389
+ }
390
+ /** Remove a CSS class or an array of classes from the overlay pane. */
391
+ removePanelClass(classes) {
392
+ this.overlayRef.removePanelClass(classes);
393
+ return this;
394
+ }
395
+ }
396
+
397
+ /**
398
+ * @license
399
+ * Copyright Google LLC All Rights Reserved.
400
+ *
401
+ * Use of this source code is governed by an MIT-style license that can be
402
+ * found in the LICENSE file at https://angular.io/license
403
+ */
404
+ /** Injection token for the Dialog's ScrollStrategy. */
405
+ const DIALOG_SCROLL_STRATEGY = new InjectionToken('DialogScrollStrategy');
406
+ /** Injection token for the Dialog's Data. */
407
+ const DIALOG_DATA = new InjectionToken('DialogData');
408
+ /** Injection token that can be used to provide default options for the dialog module. */
409
+ const DEFAULT_DIALOG_CONFIG = new InjectionToken('DefaultDialogConfig');
410
+ /** @docs-private */
411
+ function DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
412
+ return () => overlay.scrollStrategies.block();
413
+ }
414
+ /** @docs-private */
415
+ const DIALOG_SCROLL_STRATEGY_PROVIDER = {
416
+ provide: DIALOG_SCROLL_STRATEGY,
417
+ deps: [Overlay],
418
+ useFactory: DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY,
419
+ };
420
+
421
+ /**
422
+ * @license
423
+ * Copyright Google LLC All Rights Reserved.
424
+ *
425
+ * Use of this source code is governed by an MIT-style license that can be
426
+ * found in the LICENSE file at https://angular.io/license
427
+ */
428
+ /** Unique id for the created dialog. */
429
+ let uniqueId = 0;
430
+ class Dialog {
431
+ constructor(_overlay, _injector, _defaultOptions, _parentDialog, _overlayContainer, scrollStrategy) {
432
+ this._overlay = _overlay;
433
+ this._injector = _injector;
434
+ this._defaultOptions = _defaultOptions;
435
+ this._parentDialog = _parentDialog;
436
+ this._overlayContainer = _overlayContainer;
437
+ this._openDialogsAtThisLevel = [];
438
+ this._afterAllClosedAtThisLevel = new Subject();
439
+ this._afterOpenedAtThisLevel = new Subject();
440
+ this._ariaHiddenElements = new Map();
441
+ /**
442
+ * Stream that emits when all open dialog have finished closing.
443
+ * Will emit on subscribe if there are no open dialogs to begin with.
444
+ */
445
+ this.afterAllClosed = defer(() => this.openDialogs.length
446
+ ? this._getAfterAllClosed()
447
+ : this._getAfterAllClosed().pipe(startWith(undefined)));
448
+ this._scrollStrategy = scrollStrategy;
449
+ }
450
+ /** Keeps track of the currently-open dialogs. */
451
+ get openDialogs() {
452
+ return this._parentDialog ? this._parentDialog.openDialogs : this._openDialogsAtThisLevel;
453
+ }
454
+ /** Stream that emits when a dialog has been opened. */
455
+ get afterOpened() {
456
+ return this._parentDialog ? this._parentDialog.afterOpened : this._afterOpenedAtThisLevel;
457
+ }
458
+ open(componentOrTemplateRef, config) {
459
+ const defaults = (this._defaultOptions || new DialogConfig());
460
+ config = Object.assign(Object.assign({}, defaults), config);
461
+ config.id = config.id || `cdk-dialog-${uniqueId++}`;
462
+ if (config.id &&
463
+ this.getDialogById(config.id) &&
464
+ (typeof ngDevMode === 'undefined' || ngDevMode)) {
465
+ throw Error(`Dialog with id "${config.id}" exists already. The dialog id must be unique.`);
466
+ }
467
+ const overlayConfig = this._getOverlayConfig(config);
468
+ const overlayRef = this._overlay.create(overlayConfig);
469
+ const dialogRef = new DialogRef(overlayRef, config);
470
+ const dialogContainer = this._attachContainer(overlayRef, dialogRef, config);
471
+ dialogRef.containerInstance = dialogContainer;
472
+ this._attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config);
473
+ // If this is the first dialog that we're opening, hide all the non-overlay content.
474
+ if (!this.openDialogs.length) {
475
+ this._hideNonDialogContentFromAssistiveTechnology();
476
+ }
477
+ this.openDialogs.push(dialogRef);
478
+ dialogRef.closed.subscribe(() => this._removeOpenDialog(dialogRef));
479
+ this.afterOpened.next(dialogRef);
480
+ return dialogRef;
481
+ }
482
+ /**
483
+ * Closes all of the currently-open dialogs.
484
+ */
485
+ closeAll() {
486
+ this._closeDialogs(this.openDialogs);
487
+ }
488
+ /**
489
+ * Finds an open dialog by its id.
490
+ * @param id ID to use when looking up the dialog.
491
+ */
492
+ getDialogById(id) {
493
+ return this.openDialogs.find(dialog => dialog.id === id);
494
+ }
495
+ ngOnDestroy() {
496
+ // Only close the dialogs at this level on destroy
497
+ // since the parent service may still be active.
498
+ this._closeDialogs(this._openDialogsAtThisLevel);
499
+ this._afterAllClosedAtThisLevel.complete();
500
+ this._afterOpenedAtThisLevel.complete();
501
+ }
502
+ /**
503
+ * Creates an overlay config from a dialog config.
504
+ * @param config The dialog configuration.
505
+ * @returns The overlay configuration.
506
+ */
507
+ _getOverlayConfig(config) {
508
+ const state = new OverlayConfig({
509
+ positionStrategy: config.positionStrategy ||
510
+ this._overlay.position().global().centerHorizontally().centerVertically(),
511
+ scrollStrategy: config.scrollStrategy || this._scrollStrategy(),
512
+ panelClass: config.panelClass,
513
+ hasBackdrop: config.hasBackdrop,
514
+ direction: config.direction,
515
+ minWidth: config.minWidth,
516
+ minHeight: config.minHeight,
517
+ maxWidth: config.maxWidth,
518
+ maxHeight: config.maxHeight,
519
+ width: config.width,
520
+ height: config.height,
521
+ disposeOnNavigation: config.closeOnNavigation,
522
+ });
523
+ if (config.backdropClass) {
524
+ state.backdropClass = config.backdropClass;
525
+ }
526
+ return state;
527
+ }
528
+ /**
529
+ * Attaches a dialog container to a dialog's already-created overlay.
530
+ * @param overlay Reference to the dialog's underlying overlay.
531
+ * @param config The dialog configuration.
532
+ * @returns A promise resolving to a ComponentRef for the attached container.
533
+ */
534
+ _attachContainer(overlay, dialogRef, config) {
535
+ var _a, _b;
536
+ const userInjector = (_a = config.injector) !== null && _a !== void 0 ? _a : (_b = config.viewContainerRef) === null || _b === void 0 ? void 0 : _b.injector;
537
+ const providers = [
538
+ { provide: DialogConfig, useValue: config },
539
+ { provide: DialogRef, useValue: dialogRef },
540
+ { provide: OverlayRef, useValue: overlay },
541
+ ];
542
+ let containerType;
543
+ if (config.container) {
544
+ if (typeof config.container === 'function') {
545
+ containerType = config.container;
546
+ }
547
+ else {
548
+ containerType = config.container.type;
549
+ providers.push(...config.container.providers(config));
550
+ }
551
+ }
552
+ else {
553
+ containerType = CdkDialogContainer;
554
+ }
555
+ const containerPortal = new ComponentPortal(containerType, config.viewContainerRef, Injector.create({ parent: userInjector || this._injector, providers }), config.componentFactoryResolver);
556
+ const containerRef = overlay.attach(containerPortal);
557
+ return containerRef.instance;
558
+ }
559
+ /**
560
+ * Attaches the user-provided component to the already-created dialog container.
561
+ * @param componentOrTemplateRef The type of component being loaded into the dialog,
562
+ * or a TemplateRef to instantiate as the content.
563
+ * @param dialogRef Reference to the dialog being opened.
564
+ * @param dialogContainer Component that is going to wrap the dialog content.
565
+ * @param config Configuration used to open the dialog.
566
+ */
567
+ _attachDialogContent(componentOrTemplateRef, dialogRef, dialogContainer, config) {
568
+ const injector = this._createInjector(config, dialogRef, dialogContainer);
569
+ if (componentOrTemplateRef instanceof TemplateRef) {
570
+ let context = { $implicit: config.data, dialogRef };
571
+ if (config.templateContext) {
572
+ context = Object.assign(Object.assign({}, context), (typeof config.templateContext === 'function'
573
+ ? config.templateContext()
574
+ : config.templateContext));
575
+ }
576
+ dialogContainer.attachTemplatePortal(new TemplatePortal(componentOrTemplateRef, null, context, injector));
577
+ }
578
+ else {
579
+ const contentRef = dialogContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.viewContainerRef, injector, config.componentFactoryResolver));
580
+ dialogRef.componentInstance = contentRef.instance;
581
+ }
582
+ }
583
+ /**
584
+ * Creates a custom injector to be used inside the dialog. This allows a component loaded inside
585
+ * of a dialog to close itself and, optionally, to return a value.
586
+ * @param config Config object that is used to construct the dialog.
587
+ * @param dialogRef Reference to the dialog being opened.
588
+ * @param dialogContainer Component that is going to wrap the dialog content.
589
+ * @returns The custom injector that can be used inside the dialog.
590
+ */
591
+ _createInjector(config, dialogRef, dialogContainer) {
592
+ const userInjector = config && config.viewContainerRef && config.viewContainerRef.injector;
593
+ const providers = [
594
+ { provide: DIALOG_DATA, useValue: config.data },
595
+ { provide: DialogRef, useValue: dialogRef },
596
+ ];
597
+ if (config.providers) {
598
+ if (typeof config.providers === 'function') {
599
+ providers.push(...config.providers(dialogRef, config, dialogContainer));
600
+ }
601
+ else {
602
+ providers.push(...config.providers);
603
+ }
604
+ }
605
+ if (config.direction &&
606
+ (!userInjector ||
607
+ !userInjector.get(Directionality, null, InjectFlags.Optional))) {
608
+ providers.push({
609
+ provide: Directionality,
610
+ useValue: { value: config.direction, change: of() },
611
+ });
612
+ }
613
+ return Injector.create({ parent: userInjector || this._injector, providers });
614
+ }
615
+ /**
616
+ * Removes a dialog from the array of open dialogs.
617
+ * @param dialogRef Dialog to be removed.
618
+ */
619
+ _removeOpenDialog(dialogRef) {
620
+ const index = this.openDialogs.indexOf(dialogRef);
621
+ if (index > -1) {
622
+ this.openDialogs.splice(index, 1);
623
+ // If all the dialogs were closed, remove/restore the `aria-hidden`
624
+ // to a the siblings and emit to the `afterAllClosed` stream.
625
+ if (!this.openDialogs.length) {
626
+ this._ariaHiddenElements.forEach((previousValue, element) => {
627
+ if (previousValue) {
628
+ element.setAttribute('aria-hidden', previousValue);
629
+ }
630
+ else {
631
+ element.removeAttribute('aria-hidden');
632
+ }
633
+ });
634
+ this._ariaHiddenElements.clear();
635
+ this._getAfterAllClosed().next();
636
+ }
637
+ }
638
+ }
639
+ /** Hides all of the content that isn't an overlay from assistive technology. */
640
+ _hideNonDialogContentFromAssistiveTechnology() {
641
+ const overlayContainer = this._overlayContainer.getContainerElement();
642
+ // Ensure that the overlay container is attached to the DOM.
643
+ if (overlayContainer.parentElement) {
644
+ const siblings = overlayContainer.parentElement.children;
645
+ for (let i = siblings.length - 1; i > -1; i--) {
646
+ const sibling = siblings[i];
647
+ if (sibling !== overlayContainer &&
648
+ sibling.nodeName !== 'SCRIPT' &&
649
+ sibling.nodeName !== 'STYLE' &&
650
+ !sibling.hasAttribute('aria-live')) {
651
+ this._ariaHiddenElements.set(sibling, sibling.getAttribute('aria-hidden'));
652
+ sibling.setAttribute('aria-hidden', 'true');
653
+ }
654
+ }
655
+ }
656
+ }
657
+ /** Closes all of the dialogs in an array. */
658
+ _closeDialogs(dialogs) {
659
+ let i = dialogs.length;
660
+ while (i--) {
661
+ // The `_openDialogs` property isn't updated after close until the rxjs subscription
662
+ // runs on the next microtask, in addition to modifying the array as we're going
663
+ // through it. We loop through all of them and call close without assuming that
664
+ // they'll be removed from the list instantaneously.
665
+ dialogs[i].close();
666
+ }
667
+ }
668
+ _getAfterAllClosed() {
669
+ const parent = this._parentDialog;
670
+ return parent ? parent._getAfterAllClosed() : this._afterAllClosedAtThisLevel;
671
+ }
672
+ }
673
+ Dialog.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: Dialog, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }, { token: DEFAULT_DIALOG_CONFIG, optional: true }, { token: Dialog, optional: true, skipSelf: true }, { token: i1$1.OverlayContainer }, { token: DIALOG_SCROLL_STRATEGY }], target: i0.ɵɵFactoryTarget.Injectable });
674
+ Dialog.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: Dialog });
675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: Dialog, decorators: [{
676
+ type: Injectable
677
+ }], ctorParameters: function () {
678
+ return [{ type: i1$1.Overlay }, { type: i0.Injector }, { type: DialogConfig, decorators: [{
679
+ type: Optional
680
+ }, {
681
+ type: Inject,
682
+ args: [DEFAULT_DIALOG_CONFIG]
683
+ }] }, { type: Dialog, decorators: [{
684
+ type: Optional
685
+ }, {
686
+ type: SkipSelf
687
+ }] }, { type: i1$1.OverlayContainer }, { type: undefined, decorators: [{
688
+ type: Inject,
689
+ args: [DIALOG_SCROLL_STRATEGY]
690
+ }] }];
691
+ } });
692
+
693
+ /**
694
+ * @license
695
+ * Copyright Google LLC All Rights Reserved.
696
+ *
697
+ * Use of this source code is governed by an MIT-style license that can be
698
+ * found in the LICENSE file at https://angular.io/license
699
+ */
700
+ class DialogModule {
701
+ }
702
+ DialogModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: DialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
703
+ DialogModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: DialogModule, declarations: [CdkDialogContainer], imports: [OverlayModule, PortalModule, A11yModule], exports: [
704
+ // Re-export the PortalModule so that people extending the `CdkDialogContainer`
705
+ // don't have to remember to import it or be faced with an unhelpful error.
706
+ PortalModule,
707
+ CdkDialogContainer
708
+ ] });
709
+ DialogModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: DialogModule, providers: [Dialog, DIALOG_SCROLL_STRATEGY_PROVIDER], imports: [[OverlayModule, PortalModule, A11yModule],
710
+ // Re-export the PortalModule so that people extending the `CdkDialogContainer`
711
+ // don't have to remember to import it or be faced with an unhelpful error.
712
+ PortalModule] });
713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.0-next.14", ngImport: i0, type: DialogModule, decorators: [{
714
+ type: NgModule,
715
+ args: [{
716
+ imports: [OverlayModule, PortalModule, A11yModule],
717
+ exports: [
718
+ // Re-export the PortalModule so that people extending the `CdkDialogContainer`
719
+ // don't have to remember to import it or be faced with an unhelpful error.
720
+ PortalModule,
721
+ CdkDialogContainer,
722
+ ],
723
+ declarations: [CdkDialogContainer],
724
+ providers: [Dialog, DIALOG_SCROLL_STRATEGY_PROVIDER],
725
+ }]
726
+ }] });
727
+
728
+ /**
729
+ * @license
730
+ * Copyright Google LLC All Rights Reserved.
731
+ *
732
+ * Use of this source code is governed by an MIT-style license that can be
733
+ * found in the LICENSE file at https://angular.io/license
734
+ */
735
+
736
+ /**
737
+ * @license
738
+ * Copyright Google LLC All Rights Reserved.
739
+ *
740
+ * Use of this source code is governed by an MIT-style license that can be
741
+ * found in the LICENSE file at https://angular.io/license
742
+ */
743
+
744
+ /**
745
+ * Generated bundle index. Do not edit.
746
+ */
747
+
748
+ export { CdkDialogContainer, DEFAULT_DIALOG_CONFIG, DIALOG_DATA, DIALOG_SCROLL_STRATEGY, DIALOG_SCROLL_STRATEGY_PROVIDER, DIALOG_SCROLL_STRATEGY_PROVIDER_FACTORY, Dialog, DialogConfig, DialogModule, DialogRef, throwDialogContentAlreadyAttachedError };
749
+ //# sourceMappingURL=dialog.mjs.map