@angular/cdk 16.0.0-next.4 → 16.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (454) hide show
  1. package/a11y/index.d.ts +2 -2
  2. package/accordion/index.d.ts +2 -2
  3. package/bidi/index.d.ts +1 -1
  4. package/clipboard/index.d.ts +1 -1
  5. package/drag-drop/index.d.ts +6 -6
  6. package/{esm2020 → esm2022}/a11y/a11y-module.mjs +5 -5
  7. package/{esm2020 → esm2022}/a11y/aria-describer/aria-describer.mjs +4 -4
  8. package/{esm2020 → esm2022}/a11y/focus-monitor/focus-monitor.mjs +7 -7
  9. package/{esm2020 → esm2022}/a11y/focus-trap/configurable-focus-trap-factory.mjs +4 -4
  10. package/{esm2020 → esm2022}/a11y/focus-trap/focus-trap-manager.mjs +4 -4
  11. package/{esm2020 → esm2022}/a11y/focus-trap/focus-trap.mjs +7 -7
  12. package/{esm2020 → esm2022}/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +4 -4
  13. package/{esm2020 → esm2022}/a11y/input-modality/input-modality-detector.mjs +4 -4
  14. package/{esm2020 → esm2022}/a11y/interactivity-checker/interactivity-checker.mjs +4 -4
  15. package/{esm2020 → esm2022}/a11y/live-announcer/live-announcer.mjs +7 -7
  16. package/{esm2020 → esm2022}/accordion/accordion-item.mjs +8 -8
  17. package/{esm2020 → esm2022}/accordion/accordion-module.mjs +5 -5
  18. package/{esm2020 → esm2022}/accordion/accordion.mjs +4 -4
  19. package/{esm2020 → esm2022}/bidi/bidi-module.mjs +5 -5
  20. package/{esm2020 → esm2022}/bidi/dir.mjs +4 -4
  21. package/{esm2020 → esm2022}/bidi/directionality.mjs +4 -4
  22. package/{esm2020 → esm2022}/clipboard/clipboard-module.mjs +5 -5
  23. package/{esm2020 → esm2022}/clipboard/clipboard.mjs +4 -4
  24. package/{esm2020 → esm2022}/clipboard/copy-to-clipboard.mjs +4 -4
  25. package/{esm2020 → esm2022}/collections/unique-selection-dispatcher.mjs +4 -4
  26. package/{esm2020 → esm2022}/dialog/dialog-container.mjs +4 -4
  27. package/{esm2020 → esm2022}/dialog/dialog-module.mjs +12 -12
  28. package/{esm2020 → esm2022}/dialog/dialog.mjs +4 -4
  29. package/{esm2020 → esm2022}/drag-drop/directives/drag-handle.mjs +4 -4
  30. package/{esm2020 → esm2022}/drag-drop/directives/drag-placeholder.mjs +4 -4
  31. package/{esm2020 → esm2022}/drag-drop/directives/drag-preview.mjs +4 -4
  32. package/esm2022/drag-drop/directives/drag.mjs +489 -0
  33. package/{esm2020 → esm2022}/drag-drop/directives/drop-list-group.mjs +4 -4
  34. package/esm2022/drag-drop/directives/drop-list.mjs +348 -0
  35. package/{esm2020 → esm2022}/drag-drop/drag-drop-module.mjs +15 -15
  36. package/{esm2020 → esm2022}/drag-drop/drag-drop-registry.mjs +4 -4
  37. package/{esm2020 → esm2022}/drag-drop/drag-drop.mjs +4 -4
  38. package/{esm2020 → esm2022}/layout/breakpoints-observer.mjs +4 -4
  39. package/{esm2020 → esm2022}/layout/layout-module.mjs +5 -5
  40. package/{esm2020 → esm2022}/layout/media-matcher.mjs +4 -4
  41. package/{esm2020 → esm2022}/listbox/listbox-module.mjs +5 -5
  42. package/{esm2020 → esm2022}/listbox/listbox.mjs +13 -13
  43. package/{esm2020 → esm2022}/menu/context-menu-trigger.mjs +10 -10
  44. package/{esm2020 → esm2022}/menu/menu-aim.mjs +7 -7
  45. package/{esm2020 → esm2022}/menu/menu-bar.mjs +8 -8
  46. package/{esm2020 → esm2022}/menu/menu-base.mjs +4 -4
  47. package/{esm2020 → esm2022}/menu/menu-group.mjs +4 -4
  48. package/{esm2020 → esm2022}/menu/menu-item-checkbox.mjs +7 -7
  49. package/{esm2020 → esm2022}/menu/menu-item-radio.mjs +7 -7
  50. package/{esm2020 → esm2022}/menu/menu-item-selectable.mjs +4 -4
  51. package/{esm2020 → esm2022}/menu/menu-item.mjs +4 -4
  52. package/{esm2020 → esm2022}/menu/menu-module.mjs +21 -21
  53. package/{esm2020 → esm2022}/menu/menu-stack.mjs +4 -4
  54. package/{esm2020 → esm2022}/menu/menu-trigger-base.mjs +4 -4
  55. package/esm2022/menu/menu-trigger.mjs +307 -0
  56. package/{esm2020 → esm2022}/menu/menu.mjs +8 -8
  57. package/{esm2020 → esm2022}/observers/observe-content.mjs +14 -14
  58. package/{esm2020 → esm2022}/overlay/dispatchers/base-overlay-dispatcher.mjs +4 -4
  59. package/{esm2020 → esm2022}/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +4 -4
  60. package/{esm2020 → esm2022}/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +4 -4
  61. package/{esm2020 → esm2022}/overlay/fullscreen-overlay-container.mjs +4 -4
  62. package/{esm2020 → esm2022}/overlay/overlay-container.mjs +4 -4
  63. package/{esm2020 → esm2022}/overlay/overlay-directives.mjs +7 -7
  64. package/{esm2020 → esm2022}/overlay/overlay-module.mjs +5 -5
  65. package/{esm2020 → esm2022}/overlay/overlay.mjs +4 -4
  66. package/{esm2020 → esm2022}/overlay/position/overlay-position-builder.mjs +4 -4
  67. package/{esm2020 → esm2022}/overlay/scroll/scroll-strategy-options.mjs +4 -4
  68. package/{esm2020 → esm2022}/platform/platform-module.mjs +5 -5
  69. package/{esm2020 → esm2022}/platform/platform.mjs +4 -4
  70. package/esm2022/portal/portal-directives.mjs +250 -0
  71. package/{esm2020 → esm2022}/scrolling/fixed-size-virtual-scroll.mjs +10 -10
  72. package/{esm2020 → esm2022}/scrolling/scroll-dispatcher.mjs +4 -4
  73. package/{esm2020 → esm2022}/scrolling/scrollable.mjs +4 -4
  74. package/{esm2020 → esm2022}/scrolling/scrolling-module.mjs +19 -19
  75. package/{esm2020 → esm2022}/scrolling/viewport-ruler.mjs +4 -4
  76. package/{esm2020 → esm2022}/scrolling/virtual-for-of.mjs +4 -4
  77. package/{esm2020 → esm2022}/scrolling/virtual-scroll-viewport.mjs +10 -10
  78. package/{esm2020 → esm2022}/scrolling/virtual-scrollable-element.mjs +4 -4
  79. package/{esm2020 → esm2022}/scrolling/virtual-scrollable-window.mjs +4 -4
  80. package/{esm2020 → esm2022}/scrolling/virtual-scrollable.mjs +4 -4
  81. package/{esm2020 → esm2022}/stepper/step-header.mjs +4 -4
  82. package/{esm2020 → esm2022}/stepper/step-label.mjs +4 -4
  83. package/{esm2020 → esm2022}/stepper/stepper-button.mjs +7 -7
  84. package/{esm2020 → esm2022}/stepper/stepper-module.mjs +10 -10
  85. package/{esm2020 → esm2022}/stepper/stepper.mjs +7 -7
  86. package/{esm2020 → esm2022}/table/cell.mjs +22 -22
  87. package/{esm2020 → esm2022}/table/coalesced-style-scheduler.mjs +4 -4
  88. package/esm2022/table/row.mjs +271 -0
  89. package/{esm2020 → esm2022}/table/table-module.mjs +47 -47
  90. package/{esm2020 → esm2022}/table/table.mjs +25 -25
  91. package/{esm2020 → esm2022}/table/text-column.mjs +6 -6
  92. package/{esm2020 → esm2022}/text-field/autofill.mjs +7 -7
  93. package/{esm2020 → esm2022}/text-field/autosize.mjs +4 -4
  94. package/{esm2020 → esm2022}/text-field/text-field-module.mjs +5 -5
  95. package/{esm2020 → esm2022}/tree/nested-node.mjs +7 -7
  96. package/{esm2020 → esm2022}/tree/node.mjs +4 -4
  97. package/{esm2020 → esm2022}/tree/outlet.mjs +4 -4
  98. package/{esm2020 → esm2022}/tree/padding.mjs +4 -4
  99. package/{esm2020 → esm2022}/tree/toggle.mjs +4 -4
  100. package/{esm2020 → esm2022}/tree/tree-module.mjs +17 -17
  101. package/esm2022/tree/tree.mjs +349 -0
  102. package/{esm2020 → esm2022}/version.mjs +1 -1
  103. package/{fesm2020 → fesm2022}/a11y.mjs +40 -197
  104. package/fesm2022/a11y.mjs.map +1 -0
  105. package/{fesm2020 → fesm2022}/accordion.mjs +14 -51
  106. package/fesm2022/accordion.mjs.map +1 -0
  107. package/{fesm2020 → fesm2022}/bidi.mjs +10 -54
  108. package/fesm2022/bidi.mjs.map +1 -0
  109. package/fesm2022/cdk.mjs +7 -0
  110. package/fesm2022/cdk.mjs.map +1 -0
  111. package/{fesm2020 → fesm2022}/clipboard.mjs +10 -54
  112. package/fesm2022/clipboard.mjs.map +1 -0
  113. package/{fesm2015 → fesm2022}/coercion.mjs +0 -58
  114. package/fesm2022/coercion.mjs.map +1 -0
  115. package/{fesm2015 → fesm2022}/collections.mjs +5 -70
  116. package/fesm2022/collections.mjs.map +1 -0
  117. package/{fesm2020 → fesm2022}/dialog.mjs +17 -75
  118. package/fesm2022/dialog.mjs.map +1 -0
  119. package/{fesm2020 → fesm2022}/drag-drop.mjs +45 -216
  120. package/fesm2022/drag-drop.mjs.map +1 -0
  121. package/{fesm2020 → fesm2022}/keycodes.mjs +0 -30
  122. package/fesm2022/keycodes.mjs.map +1 -0
  123. package/{fesm2015 → fesm2022}/layout.mjs +10 -54
  124. package/fesm2022/layout.mjs.map +1 -0
  125. package/{fesm2020 → fesm2022}/listbox.mjs +16 -46
  126. package/fesm2022/listbox.mjs.map +1 -0
  127. package/{fesm2020 → fesm2022}/menu.mjs +86 -220
  128. package/fesm2022/menu.mjs.map +1 -0
  129. package/{fesm2020 → fesm2022}/observers.mjs +13 -36
  130. package/fesm2022/observers.mjs.map +1 -0
  131. package/{fesm2020 → fesm2022}/overlay.mjs +34 -206
  132. package/fesm2022/overlay.mjs.map +1 -0
  133. package/{fesm2020 → fesm2022}/platform.mjs +7 -72
  134. package/fesm2022/platform.mjs.map +1 -0
  135. package/{fesm2020 → fesm2022}/portal.mjs +26 -77
  136. package/fesm2022/portal.mjs.map +1 -0
  137. package/{fesm2020 → fesm2022}/scrolling.mjs +57 -158
  138. package/fesm2022/scrolling.mjs.map +1 -0
  139. package/{fesm2020 → fesm2022}/stepper.mjs +27 -78
  140. package/fesm2022/stepper.mjs.map +1 -0
  141. package/{fesm2020 → fesm2022}/table.mjs +134 -227
  142. package/fesm2022/table.mjs.map +1 -0
  143. package/{fesm2020 → fesm2022}/testing/selenium-webdriver.mjs +0 -37
  144. package/fesm2022/testing/selenium-webdriver.mjs.map +1 -0
  145. package/{fesm2020 → fesm2022}/testing/testbed.mjs +1 -72
  146. package/fesm2022/testing/testbed.mjs.map +1 -0
  147. package/{fesm2020 → fesm2022}/testing.mjs +0 -66
  148. package/fesm2022/testing.mjs.map +1 -0
  149. package/{fesm2020 → fesm2022}/text-field.mjs +13 -50
  150. package/fesm2022/text-field.mjs.map +1 -0
  151. package/{fesm2020 → fesm2022}/tree.mjs +45 -131
  152. package/fesm2022/tree.mjs.map +1 -0
  153. package/listbox/index.d.ts +2 -2
  154. package/menu/index.d.ts +5 -5
  155. package/observers/index.d.ts +1 -1
  156. package/overlay/index.d.ts +1 -1
  157. package/package.json +77 -131
  158. package/portal/index.d.ts +2 -2
  159. package/schematics/ng-add/index.js +1 -1
  160. package/schematics/ng-add/index.mjs +1 -1
  161. package/schematics/ng-update/devkit-file-system.js +3 -2
  162. package/schematics/ng-update/devkit-file-system.mjs +3 -2
  163. package/schematics/ng-update/migrations/attribute-selectors.js +5 -8
  164. package/schematics/ng-update/migrations/attribute-selectors.mjs +5 -8
  165. package/schematics/ng-update/migrations/class-inheritance.js +8 -11
  166. package/schematics/ng-update/migrations/class-inheritance.mjs +8 -11
  167. package/schematics/ng-update/migrations/class-names.js +12 -15
  168. package/schematics/ng-update/migrations/class-names.mjs +12 -15
  169. package/schematics/ng-update/migrations/constructor-signature.js +7 -10
  170. package/schematics/ng-update/migrations/constructor-signature.mjs +7 -10
  171. package/schematics/ng-update/migrations/css-selectors.js +5 -8
  172. package/schematics/ng-update/migrations/css-selectors.mjs +5 -8
  173. package/schematics/ng-update/migrations/element-selectors.js +5 -8
  174. package/schematics/ng-update/migrations/element-selectors.mjs +5 -8
  175. package/schematics/ng-update/migrations/input-names.js +5 -8
  176. package/schematics/ng-update/migrations/input-names.mjs +5 -8
  177. package/schematics/ng-update/migrations/method-call-arguments.js +5 -8
  178. package/schematics/ng-update/migrations/method-call-arguments.mjs +5 -8
  179. package/schematics/ng-update/migrations/misc-template.js +3 -6
  180. package/schematics/ng-update/migrations/misc-template.mjs +3 -6
  181. package/schematics/ng-update/migrations/output-names.js +5 -8
  182. package/schematics/ng-update/migrations/output-names.mjs +5 -8
  183. package/schematics/ng-update/migrations/property-names.js +5 -8
  184. package/schematics/ng-update/migrations/property-names.mjs +5 -8
  185. package/schematics/ng-update/migrations/symbol-removal.js +5 -8
  186. package/schematics/ng-update/migrations/symbol-removal.mjs +5 -8
  187. package/schematics/update-tool/component-resource-collector.js +5 -3
  188. package/schematics/update-tool/component-resource-collector.mjs +5 -3
  189. package/schematics/update-tool/index.js +8 -2
  190. package/schematics/update-tool/index.mjs +8 -2
  191. package/schematics/update-tool/migration.js +10 -3
  192. package/schematics/update-tool/migration.mjs +10 -3
  193. package/schematics/update-tool/utils/virtual-host.js +3 -2
  194. package/schematics/update-tool/utils/virtual-host.mjs +3 -2
  195. package/scrolling/index.d.ts +3 -3
  196. package/stepper/index.d.ts +4 -4
  197. package/table/index.d.ts +6 -6
  198. package/text-field/index.d.ts +1 -1
  199. package/tree/index.d.ts +6 -6
  200. package/esm2020/drag-drop/directives/drag.mjs +0 -489
  201. package/esm2020/drag-drop/directives/drop-list.mjs +0 -348
  202. package/esm2020/menu/menu-trigger.mjs +0 -306
  203. package/esm2020/portal/portal-directives.mjs +0 -250
  204. package/esm2020/table/row.mjs +0 -271
  205. package/esm2020/tree/tree.mjs +0 -349
  206. package/fesm2015/a11y.mjs +0 -2544
  207. package/fesm2015/a11y.mjs.map +0 -1
  208. package/fesm2015/accordion.mjs +0 -275
  209. package/fesm2015/accordion.mjs.map +0 -1
  210. package/fesm2015/bidi.mjs +0 -194
  211. package/fesm2015/bidi.mjs.map +0 -1
  212. package/fesm2015/cdk.mjs +0 -30
  213. package/fesm2015/cdk.mjs.map +0 -1
  214. package/fesm2015/clipboard.mjs +0 -263
  215. package/fesm2015/clipboard.mjs.map +0 -1
  216. package/fesm2015/coercion.mjs.map +0 -1
  217. package/fesm2015/collections.mjs.map +0 -1
  218. package/fesm2015/dialog.mjs +0 -800
  219. package/fesm2015/dialog.mjs.map +0 -1
  220. package/fesm2015/drag-drop.mjs +0 -3823
  221. package/fesm2015/drag-drop.mjs.map +0 -1
  222. package/fesm2015/keycodes.mjs +0 -167
  223. package/fesm2015/keycodes.mjs.map +0 -1
  224. package/fesm2015/layout.mjs.map +0 -1
  225. package/fesm2015/listbox.mjs +0 -918
  226. package/fesm2015/listbox.mjs.map +0 -1
  227. package/fesm2015/menu.mjs +0 -2009
  228. package/fesm2015/menu.mjs.map +0 -1
  229. package/fesm2015/observers.mjs +0 -211
  230. package/fesm2015/observers.mjs.map +0 -1
  231. package/fesm2015/overlay.mjs +0 -3142
  232. package/fesm2015/overlay.mjs.map +0 -1
  233. package/fesm2015/platform.mjs +0 -385
  234. package/fesm2015/platform.mjs.map +0 -1
  235. package/fesm2015/portal.mjs +0 -691
  236. package/fesm2015/portal.mjs.map +0 -1
  237. package/fesm2015/scrolling.mjs +0 -1566
  238. package/fesm2015/scrolling.mjs.map +0 -1
  239. package/fesm2015/stepper.mjs +0 -621
  240. package/fesm2015/stepper.mjs.map +0 -1
  241. package/fesm2015/table.mjs +0 -2357
  242. package/fesm2015/table.mjs.map +0 -1
  243. package/fesm2015/testing/selenium-webdriver.mjs +0 -419
  244. package/fesm2015/testing/selenium-webdriver.mjs.map +0 -1
  245. package/fesm2015/testing/testbed.mjs +0 -868
  246. package/fesm2015/testing/testbed.mjs.map +0 -1
  247. package/fesm2015/testing.mjs +0 -785
  248. package/fesm2015/testing.mjs.map +0 -1
  249. package/fesm2015/text-field.mjs +0 -461
  250. package/fesm2015/text-field.mjs.map +0 -1
  251. package/fesm2015/tree.mjs +0 -950
  252. package/fesm2015/tree.mjs.map +0 -1
  253. package/fesm2020/a11y.mjs.map +0 -1
  254. package/fesm2020/accordion.mjs.map +0 -1
  255. package/fesm2020/bidi.mjs.map +0 -1
  256. package/fesm2020/cdk.mjs +0 -30
  257. package/fesm2020/cdk.mjs.map +0 -1
  258. package/fesm2020/clipboard.mjs.map +0 -1
  259. package/fesm2020/coercion.mjs +0 -132
  260. package/fesm2020/coercion.mjs.map +0 -1
  261. package/fesm2020/collections.mjs +0 -543
  262. package/fesm2020/collections.mjs.map +0 -1
  263. package/fesm2020/dialog.mjs.map +0 -1
  264. package/fesm2020/drag-drop.mjs.map +0 -1
  265. package/fesm2020/keycodes.mjs.map +0 -1
  266. package/fesm2020/layout.mjs +0 -254
  267. package/fesm2020/layout.mjs.map +0 -1
  268. package/fesm2020/listbox.mjs.map +0 -1
  269. package/fesm2020/menu.mjs.map +0 -1
  270. package/fesm2020/observers.mjs.map +0 -1
  271. package/fesm2020/overlay.mjs.map +0 -1
  272. package/fesm2020/platform.mjs.map +0 -1
  273. package/fesm2020/portal.mjs.map +0 -1
  274. package/fesm2020/scrolling.mjs.map +0 -1
  275. package/fesm2020/stepper.mjs.map +0 -1
  276. package/fesm2020/table.mjs.map +0 -1
  277. package/fesm2020/testing/selenium-webdriver.mjs.map +0 -1
  278. package/fesm2020/testing/testbed.mjs.map +0 -1
  279. package/fesm2020/testing.mjs.map +0 -1
  280. package/fesm2020/text-field.mjs.map +0 -1
  281. package/fesm2020/tree.mjs.map +0 -1
  282. /package/{esm2020 → esm2022}/a11y/a11y_public_index.mjs +0 -0
  283. /package/{esm2020 → esm2022}/a11y/aria-describer/aria-reference.mjs +0 -0
  284. /package/{esm2020 → esm2022}/a11y/fake-event-detection.mjs +0 -0
  285. /package/{esm2020 → esm2022}/a11y/focus-trap/configurable-focus-trap-config.mjs +0 -0
  286. /package/{esm2020 → esm2022}/a11y/focus-trap/configurable-focus-trap.mjs +0 -0
  287. /package/{esm2020 → esm2022}/a11y/focus-trap/event-listener-inert-strategy.mjs +0 -0
  288. /package/{esm2020 → esm2022}/a11y/focus-trap/focus-trap-inert-strategy.mjs +0 -0
  289. /package/{esm2020 → esm2022}/a11y/index.mjs +0 -0
  290. /package/{esm2020 → esm2022}/a11y/key-manager/activedescendant-key-manager.mjs +0 -0
  291. /package/{esm2020 → esm2022}/a11y/key-manager/focus-key-manager.mjs +0 -0
  292. /package/{esm2020 → esm2022}/a11y/key-manager/list-key-manager.mjs +0 -0
  293. /package/{esm2020 → esm2022}/a11y/live-announcer/live-announcer-tokens.mjs +0 -0
  294. /package/{esm2020 → esm2022}/a11y/public-api.mjs +0 -0
  295. /package/{esm2020 → esm2022}/accordion/accordion_public_index.mjs +0 -0
  296. /package/{esm2020 → esm2022}/accordion/index.mjs +0 -0
  297. /package/{esm2020 → esm2022}/accordion/public-api.mjs +0 -0
  298. /package/{esm2020 → esm2022}/bidi/bidi_public_index.mjs +0 -0
  299. /package/{esm2020 → esm2022}/bidi/dir-document-token.mjs +0 -0
  300. /package/{esm2020 → esm2022}/bidi/index.mjs +0 -0
  301. /package/{esm2020 → esm2022}/bidi/public-api.mjs +0 -0
  302. /package/{esm2020 → esm2022}/clipboard/clipboard_public_index.mjs +0 -0
  303. /package/{esm2020 → esm2022}/clipboard/index.mjs +0 -0
  304. /package/{esm2020 → esm2022}/clipboard/pending-copy.mjs +0 -0
  305. /package/{esm2020 → esm2022}/clipboard/public-api.mjs +0 -0
  306. /package/{esm2020 → esm2022}/coercion/array.mjs +0 -0
  307. /package/{esm2020 → esm2022}/coercion/boolean-property.mjs +0 -0
  308. /package/{esm2020 → esm2022}/coercion/css-pixel-value.mjs +0 -0
  309. /package/{esm2020 → esm2022}/coercion/element.mjs +0 -0
  310. /package/{esm2020 → esm2022}/coercion/index.mjs +0 -0
  311. /package/{esm2020 → esm2022}/coercion/number-property.mjs +0 -0
  312. /package/{esm2020 → esm2022}/coercion/public-api.mjs +0 -0
  313. /package/{esm2020 → esm2022}/coercion/string-array.mjs +0 -0
  314. /package/{esm2020 → esm2022}/collections/array-data-source.mjs +0 -0
  315. /package/{esm2020 → esm2022}/collections/collection-viewer.mjs +0 -0
  316. /package/{esm2020 → esm2022}/collections/collections_public_index.mjs +0 -0
  317. /package/{esm2020 → esm2022}/collections/data-source.mjs +0 -0
  318. /package/{esm2020 → esm2022}/collections/dispose-view-repeater-strategy.mjs +0 -0
  319. /package/{esm2020 → esm2022}/collections/index.mjs +0 -0
  320. /package/{esm2020 → esm2022}/collections/public-api.mjs +0 -0
  321. /package/{esm2020 → esm2022}/collections/recycle-view-repeater-strategy.mjs +0 -0
  322. /package/{esm2020 → esm2022}/collections/selection-model.mjs +0 -0
  323. /package/{esm2020 → esm2022}/collections/tree-adapter.mjs +0 -0
  324. /package/{esm2020 → esm2022}/collections/view-repeater.mjs +0 -0
  325. /package/{esm2020 → esm2022}/dialog/dialog-config.mjs +0 -0
  326. /package/{esm2020 → esm2022}/dialog/dialog-injectors.mjs +0 -0
  327. /package/{esm2020 → esm2022}/dialog/dialog-ref.mjs +0 -0
  328. /package/{esm2020 → esm2022}/dialog/dialog_public_index.mjs +0 -0
  329. /package/{esm2020 → esm2022}/dialog/index.mjs +0 -0
  330. /package/{esm2020 → esm2022}/dialog/public-api.mjs +0 -0
  331. /package/{esm2020 → esm2022}/drag-drop/directives/assertions.mjs +0 -0
  332. /package/{esm2020 → esm2022}/drag-drop/directives/config.mjs +0 -0
  333. /package/{esm2020 → esm2022}/drag-drop/dom/client-rect.mjs +0 -0
  334. /package/{esm2020 → esm2022}/drag-drop/dom/clone-node.mjs +0 -0
  335. /package/{esm2020 → esm2022}/drag-drop/dom/parent-position-tracker.mjs +0 -0
  336. /package/{esm2020 → esm2022}/drag-drop/dom/styling.mjs +0 -0
  337. /package/{esm2020 → esm2022}/drag-drop/dom/transition-duration.mjs +0 -0
  338. /package/{esm2020 → esm2022}/drag-drop/drag-drop_public_index.mjs +0 -0
  339. /package/{esm2020 → esm2022}/drag-drop/drag-events.mjs +0 -0
  340. /package/{esm2020 → esm2022}/drag-drop/drag-parent.mjs +0 -0
  341. /package/{esm2020 → esm2022}/drag-drop/drag-ref.mjs +0 -0
  342. /package/{esm2020 → esm2022}/drag-drop/drag-utils.mjs +0 -0
  343. /package/{esm2020 → esm2022}/drag-drop/drop-list-ref.mjs +0 -0
  344. /package/{esm2020 → esm2022}/drag-drop/index.mjs +0 -0
  345. /package/{esm2020 → esm2022}/drag-drop/public-api.mjs +0 -0
  346. /package/{esm2020 → esm2022}/drag-drop/sorting/drop-list-sort-strategy.mjs +0 -0
  347. /package/{esm2020 → esm2022}/drag-drop/sorting/single-axis-sort-strategy.mjs +0 -0
  348. /package/{esm2020 → esm2022}/index.mjs +0 -0
  349. /package/{esm2020 → esm2022}/keycodes/index.mjs +0 -0
  350. /package/{esm2020 → esm2022}/keycodes/keycodes.mjs +0 -0
  351. /package/{esm2020 → esm2022}/keycodes/keycodes_public_index.mjs +0 -0
  352. /package/{esm2020 → esm2022}/keycodes/modifiers.mjs +0 -0
  353. /package/{esm2020 → esm2022}/keycodes/public-api.mjs +0 -0
  354. /package/{esm2020 → esm2022}/layout/breakpoints.mjs +0 -0
  355. /package/{esm2020 → esm2022}/layout/index.mjs +0 -0
  356. /package/{esm2020 → esm2022}/layout/layout_public_index.mjs +0 -0
  357. /package/{esm2020 → esm2022}/layout/public-api.mjs +0 -0
  358. /package/{esm2020 → esm2022}/listbox/index.mjs +0 -0
  359. /package/{esm2020 → esm2022}/listbox/listbox_public_index.mjs +0 -0
  360. /package/{esm2020 → esm2022}/listbox/public-api.mjs +0 -0
  361. /package/{esm2020 → esm2022}/menu/index.mjs +0 -0
  362. /package/{esm2020 → esm2022}/menu/menu-errors.mjs +0 -0
  363. /package/{esm2020 → esm2022}/menu/menu-interface.mjs +0 -0
  364. /package/{esm2020 → esm2022}/menu/menu_public_index.mjs +0 -0
  365. /package/{esm2020 → esm2022}/menu/pointer-focus-tracker.mjs +0 -0
  366. /package/{esm2020 → esm2022}/menu/public-api.mjs +0 -0
  367. /package/{esm2020 → esm2022}/observers/index.mjs +0 -0
  368. /package/{esm2020 → esm2022}/observers/observers_public_index.mjs +0 -0
  369. /package/{esm2020 → esm2022}/observers/public-api.mjs +0 -0
  370. /package/{esm2020 → esm2022}/overlay/dispatchers/index.mjs +0 -0
  371. /package/{esm2020 → esm2022}/overlay/index.mjs +0 -0
  372. /package/{esm2020 → esm2022}/overlay/overlay-config.mjs +0 -0
  373. /package/{esm2020 → esm2022}/overlay/overlay-ref.mjs +0 -0
  374. /package/{esm2020 → esm2022}/overlay/overlay-reference.mjs +0 -0
  375. /package/{esm2020 → esm2022}/overlay/overlay_public_index.mjs +0 -0
  376. /package/{esm2020 → esm2022}/overlay/position/connected-position.mjs +0 -0
  377. /package/{esm2020 → esm2022}/overlay/position/flexible-connected-position-strategy.mjs +0 -0
  378. /package/{esm2020 → esm2022}/overlay/position/global-position-strategy.mjs +0 -0
  379. /package/{esm2020 → esm2022}/overlay/position/position-strategy.mjs +0 -0
  380. /package/{esm2020 → esm2022}/overlay/position/scroll-clip.mjs +0 -0
  381. /package/{esm2020 → esm2022}/overlay/public-api.mjs +0 -0
  382. /package/{esm2020 → esm2022}/overlay/scroll/block-scroll-strategy.mjs +0 -0
  383. /package/{esm2020 → esm2022}/overlay/scroll/close-scroll-strategy.mjs +0 -0
  384. /package/{esm2020 → esm2022}/overlay/scroll/index.mjs +0 -0
  385. /package/{esm2020 → esm2022}/overlay/scroll/noop-scroll-strategy.mjs +0 -0
  386. /package/{esm2020 → esm2022}/overlay/scroll/reposition-scroll-strategy.mjs +0 -0
  387. /package/{esm2020 → esm2022}/overlay/scroll/scroll-strategy.mjs +0 -0
  388. /package/{esm2020 → esm2022}/platform/features/input-types.mjs +0 -0
  389. /package/{esm2020 → esm2022}/platform/features/passive-listeners.mjs +0 -0
  390. /package/{esm2020 → esm2022}/platform/features/scrolling.mjs +0 -0
  391. /package/{esm2020 → esm2022}/platform/features/shadow-dom.mjs +0 -0
  392. /package/{esm2020 → esm2022}/platform/features/test-environment.mjs +0 -0
  393. /package/{esm2020 → esm2022}/platform/index.mjs +0 -0
  394. /package/{esm2020 → esm2022}/platform/platform_public_index.mjs +0 -0
  395. /package/{esm2020 → esm2022}/platform/public-api.mjs +0 -0
  396. /package/{esm2020 → esm2022}/portal/dom-portal-outlet.mjs +0 -0
  397. /package/{esm2020 → esm2022}/portal/index.mjs +0 -0
  398. /package/{esm2020 → esm2022}/portal/portal-errors.mjs +0 -0
  399. /package/{esm2020 → esm2022}/portal/portal-injector.mjs +0 -0
  400. /package/{esm2020 → esm2022}/portal/portal.mjs +0 -0
  401. /package/{esm2020 → esm2022}/portal/portal_public_index.mjs +0 -0
  402. /package/{esm2020 → esm2022}/portal/public-api.mjs +0 -0
  403. /package/{esm2020 → esm2022}/public-api.mjs +0 -0
  404. /package/{esm2020 → esm2022}/scrolling/index.mjs +0 -0
  405. /package/{esm2020 → esm2022}/scrolling/public-api.mjs +0 -0
  406. /package/{esm2020 → esm2022}/scrolling/scrolling_public_index.mjs +0 -0
  407. /package/{esm2020 → esm2022}/scrolling/virtual-scroll-repeater.mjs +0 -0
  408. /package/{esm2020 → esm2022}/scrolling/virtual-scroll-strategy.mjs +0 -0
  409. /package/{esm2020 → esm2022}/stepper/index.mjs +0 -0
  410. /package/{esm2020 → esm2022}/stepper/public-api.mjs +0 -0
  411. /package/{esm2020 → esm2022}/stepper/stepper_public_index.mjs +0 -0
  412. /package/{esm2020 → esm2022}/table/can-stick.mjs +0 -0
  413. /package/{esm2020 → esm2022}/table/index.mjs +0 -0
  414. /package/{esm2020 → esm2022}/table/public-api.mjs +0 -0
  415. /package/{esm2020 → esm2022}/table/sticky-position-listener.mjs +0 -0
  416. /package/{esm2020 → esm2022}/table/sticky-styler.mjs +0 -0
  417. /package/{esm2020 → esm2022}/table/table-errors.mjs +0 -0
  418. /package/{esm2020 → esm2022}/table/table_public_index.mjs +0 -0
  419. /package/{esm2020 → esm2022}/table/tokens.mjs +0 -0
  420. /package/{esm2020 → esm2022}/testing/change-detection.mjs +0 -0
  421. /package/{esm2020 → esm2022}/testing/component-harness.mjs +0 -0
  422. /package/{esm2020 → esm2022}/testing/element-dimensions.mjs +0 -0
  423. /package/{esm2020 → esm2022}/testing/harness-environment.mjs +0 -0
  424. /package/{esm2020 → esm2022}/testing/index.mjs +0 -0
  425. /package/{esm2020 → esm2022}/testing/public-api.mjs +0 -0
  426. /package/{esm2020 → esm2022}/testing/selenium-webdriver/index.mjs +0 -0
  427. /package/{esm2020 → esm2022}/testing/selenium-webdriver/public-api.mjs +0 -0
  428. /package/{esm2020 → esm2022}/testing/selenium-webdriver/selenium-web-driver-element.mjs +0 -0
  429. /package/{esm2020 → esm2022}/testing/selenium-webdriver/selenium-web-driver-harness-environment.mjs +0 -0
  430. /package/{esm2020 → esm2022}/testing/selenium-webdriver/selenium-webdriver-keys.mjs +0 -0
  431. /package/{esm2020 → esm2022}/testing/test-element-errors.mjs +0 -0
  432. /package/{esm2020 → esm2022}/testing/test-element.mjs +0 -0
  433. /package/{esm2020 → esm2022}/testing/testbed/fake-events/dispatch-events.mjs +0 -0
  434. /package/{esm2020 → esm2022}/testing/testbed/fake-events/element-focus.mjs +0 -0
  435. /package/{esm2020 → esm2022}/testing/testbed/fake-events/event-objects.mjs +0 -0
  436. /package/{esm2020 → esm2022}/testing/testbed/fake-events/index.mjs +0 -0
  437. /package/{esm2020 → esm2022}/testing/testbed/fake-events/type-in-element.mjs +0 -0
  438. /package/{esm2020 → esm2022}/testing/testbed/index.mjs +0 -0
  439. /package/{esm2020 → esm2022}/testing/testbed/public-api.mjs +0 -0
  440. /package/{esm2020 → esm2022}/testing/testbed/task-state-zone-interceptor.mjs +0 -0
  441. /package/{esm2020 → esm2022}/testing/testbed/testbed-harness-environment.mjs +0 -0
  442. /package/{esm2020 → esm2022}/testing/testbed/unit-test-element.mjs +0 -0
  443. /package/{esm2020 → esm2022}/testing/text-filtering.mjs +0 -0
  444. /package/{esm2020 → esm2022}/text-field/index.mjs +0 -0
  445. /package/{esm2020 → esm2022}/text-field/public-api.mjs +0 -0
  446. /package/{esm2020 → esm2022}/text-field/text-field_public_index.mjs +0 -0
  447. /package/{esm2020 → esm2022}/tree/control/base-tree-control.mjs +0 -0
  448. /package/{esm2020 → esm2022}/tree/control/flat-tree-control.mjs +0 -0
  449. /package/{esm2020 → esm2022}/tree/control/nested-tree-control.mjs +0 -0
  450. /package/{esm2020 → esm2022}/tree/control/tree-control.mjs +0 -0
  451. /package/{esm2020 → esm2022}/tree/index.mjs +0 -0
  452. /package/{esm2020 → esm2022}/tree/public-api.mjs +0 -0
  453. /package/{esm2020 → esm2022}/tree/tree-errors.mjs +0 -0
  454. /package/{esm2020 → esm2022}/tree/tree_public_index.mjs +0 -0
@@ -1,3142 +0,0 @@
1
- import * as i1 from '@angular/cdk/scrolling';
2
- import { ScrollingModule } from '@angular/cdk/scrolling';
3
- export { CdkScrollable, ScrollDispatcher, ViewportRuler } from '@angular/cdk/scrolling';
4
- import * as i6 from '@angular/common';
5
- import { DOCUMENT } from '@angular/common';
6
- import * as i0 from '@angular/core';
7
- import { Injectable, Inject, ElementRef, Optional, ApplicationRef, ANIMATION_MODULE_TYPE, InjectionToken, Directive, EventEmitter, Input, Output, NgModule } from '@angular/core';
8
- import { coerceCssPixelValue, coerceArray, coerceBooleanProperty } from '@angular/cdk/coercion';
9
- import * as i1$1 from '@angular/cdk/platform';
10
- import { supportsScrollBehavior, _isTestEnvironment, _getEventTarget } from '@angular/cdk/platform';
11
- import { filter, take, takeUntil, takeWhile } from 'rxjs/operators';
12
- import * as i5 from '@angular/cdk/bidi';
13
- import { BidiModule } from '@angular/cdk/bidi';
14
- import { DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';
15
- import { Subject, Subscription, merge } from 'rxjs';
16
- import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
17
-
18
- /**
19
- * @license
20
- * Copyright Google LLC All Rights Reserved.
21
- *
22
- * Use of this source code is governed by an MIT-style license that can be
23
- * found in the LICENSE file at https://angular.io/license
24
- */
25
- const scrollBehaviorSupported = supportsScrollBehavior();
26
- /**
27
- * Strategy that will prevent the user from scrolling while the overlay is visible.
28
- */
29
- class BlockScrollStrategy {
30
- constructor(_viewportRuler, document) {
31
- this._viewportRuler = _viewportRuler;
32
- this._previousHTMLStyles = { top: '', left: '' };
33
- this._isEnabled = false;
34
- this._document = document;
35
- }
36
- /** Attaches this scroll strategy to an overlay. */
37
- attach() { }
38
- /** Blocks page-level scroll while the attached overlay is open. */
39
- enable() {
40
- if (this._canBeEnabled()) {
41
- const root = this._document.documentElement;
42
- this._previousScrollPosition = this._viewportRuler.getViewportScrollPosition();
43
- // Cache the previous inline styles in case the user had set them.
44
- this._previousHTMLStyles.left = root.style.left || '';
45
- this._previousHTMLStyles.top = root.style.top || '';
46
- // Note: we're using the `html` node, instead of the `body`, because the `body` may
47
- // have the user agent margin, whereas the `html` is guaranteed not to have one.
48
- root.style.left = coerceCssPixelValue(-this._previousScrollPosition.left);
49
- root.style.top = coerceCssPixelValue(-this._previousScrollPosition.top);
50
- root.classList.add('cdk-global-scrollblock');
51
- this._isEnabled = true;
52
- }
53
- }
54
- /** Unblocks page-level scroll while the attached overlay is open. */
55
- disable() {
56
- if (this._isEnabled) {
57
- const html = this._document.documentElement;
58
- const body = this._document.body;
59
- const htmlStyle = html.style;
60
- const bodyStyle = body.style;
61
- const previousHtmlScrollBehavior = htmlStyle.scrollBehavior || '';
62
- const previousBodyScrollBehavior = bodyStyle.scrollBehavior || '';
63
- this._isEnabled = false;
64
- htmlStyle.left = this._previousHTMLStyles.left;
65
- htmlStyle.top = this._previousHTMLStyles.top;
66
- html.classList.remove('cdk-global-scrollblock');
67
- // Disable user-defined smooth scrolling temporarily while we restore the scroll position.
68
- // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior
69
- // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,
70
- // because it can throw off feature detections in `supportsScrollBehavior` which
71
- // checks for `'scrollBehavior' in documentElement.style`.
72
- if (scrollBehaviorSupported) {
73
- htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';
74
- }
75
- window.scroll(this._previousScrollPosition.left, this._previousScrollPosition.top);
76
- if (scrollBehaviorSupported) {
77
- htmlStyle.scrollBehavior = previousHtmlScrollBehavior;
78
- bodyStyle.scrollBehavior = previousBodyScrollBehavior;
79
- }
80
- }
81
- }
82
- _canBeEnabled() {
83
- // Since the scroll strategies can't be singletons, we have to use a global CSS class
84
- // (`cdk-global-scrollblock`) to make sure that we don't try to disable global
85
- // scrolling multiple times.
86
- const html = this._document.documentElement;
87
- if (html.classList.contains('cdk-global-scrollblock') || this._isEnabled) {
88
- return false;
89
- }
90
- const body = this._document.body;
91
- const viewport = this._viewportRuler.getViewportSize();
92
- return body.scrollHeight > viewport.height || body.scrollWidth > viewport.width;
93
- }
94
- }
95
-
96
- /**
97
- * @license
98
- * Copyright Google LLC All Rights Reserved.
99
- *
100
- * Use of this source code is governed by an MIT-style license that can be
101
- * found in the LICENSE file at https://angular.io/license
102
- */
103
- /**
104
- * Returns an error to be thrown when attempting to attach an already-attached scroll strategy.
105
- */
106
- function getMatScrollStrategyAlreadyAttachedError() {
107
- return Error(`Scroll strategy has already been attached.`);
108
- }
109
-
110
- /**
111
- * Strategy that will close the overlay as soon as the user starts scrolling.
112
- */
113
- class CloseScrollStrategy {
114
- constructor(_scrollDispatcher, _ngZone, _viewportRuler, _config) {
115
- this._scrollDispatcher = _scrollDispatcher;
116
- this._ngZone = _ngZone;
117
- this._viewportRuler = _viewportRuler;
118
- this._config = _config;
119
- this._scrollSubscription = null;
120
- /** Detaches the overlay ref and disables the scroll strategy. */
121
- this._detach = () => {
122
- this.disable();
123
- if (this._overlayRef.hasAttached()) {
124
- this._ngZone.run(() => this._overlayRef.detach());
125
- }
126
- };
127
- }
128
- /** Attaches this scroll strategy to an overlay. */
129
- attach(overlayRef) {
130
- if (this._overlayRef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
131
- throw getMatScrollStrategyAlreadyAttachedError();
132
- }
133
- this._overlayRef = overlayRef;
134
- }
135
- /** Enables the closing of the attached overlay on scroll. */
136
- enable() {
137
- if (this._scrollSubscription) {
138
- return;
139
- }
140
- const stream = this._scrollDispatcher.scrolled(0).pipe(filter(scrollable => {
141
- return (!scrollable ||
142
- !this._overlayRef.overlayElement.contains(scrollable.getElementRef().nativeElement));
143
- }));
144
- if (this._config && this._config.threshold && this._config.threshold > 1) {
145
- this._initialScrollPosition = this._viewportRuler.getViewportScrollPosition().top;
146
- this._scrollSubscription = stream.subscribe(() => {
147
- const scrollPosition = this._viewportRuler.getViewportScrollPosition().top;
148
- if (Math.abs(scrollPosition - this._initialScrollPosition) > this._config.threshold) {
149
- this._detach();
150
- }
151
- else {
152
- this._overlayRef.updatePosition();
153
- }
154
- });
155
- }
156
- else {
157
- this._scrollSubscription = stream.subscribe(this._detach);
158
- }
159
- }
160
- /** Disables the closing the attached overlay on scroll. */
161
- disable() {
162
- if (this._scrollSubscription) {
163
- this._scrollSubscription.unsubscribe();
164
- this._scrollSubscription = null;
165
- }
166
- }
167
- detach() {
168
- this.disable();
169
- this._overlayRef = null;
170
- }
171
- }
172
-
173
- /**
174
- * @license
175
- * Copyright Google LLC All Rights Reserved.
176
- *
177
- * Use of this source code is governed by an MIT-style license that can be
178
- * found in the LICENSE file at https://angular.io/license
179
- */
180
- /** Scroll strategy that doesn't do anything. */
181
- class NoopScrollStrategy {
182
- /** Does nothing, as this scroll strategy is a no-op. */
183
- enable() { }
184
- /** Does nothing, as this scroll strategy is a no-op. */
185
- disable() { }
186
- /** Does nothing, as this scroll strategy is a no-op. */
187
- attach() { }
188
- }
189
-
190
- /**
191
- * @license
192
- * Copyright Google LLC All Rights Reserved.
193
- *
194
- * Use of this source code is governed by an MIT-style license that can be
195
- * found in the LICENSE file at https://angular.io/license
196
- */
197
- /**
198
- * Gets whether an element is scrolled outside of view by any of its parent scrolling containers.
199
- * @param element Dimensions of the element (from getBoundingClientRect)
200
- * @param scrollContainers Dimensions of element's scrolling containers (from getBoundingClientRect)
201
- * @returns Whether the element is scrolled out of view
202
- * @docs-private
203
- */
204
- function isElementScrolledOutsideView(element, scrollContainers) {
205
- return scrollContainers.some(containerBounds => {
206
- const outsideAbove = element.bottom < containerBounds.top;
207
- const outsideBelow = element.top > containerBounds.bottom;
208
- const outsideLeft = element.right < containerBounds.left;
209
- const outsideRight = element.left > containerBounds.right;
210
- return outsideAbove || outsideBelow || outsideLeft || outsideRight;
211
- });
212
- }
213
- /**
214
- * Gets whether an element is clipped by any of its scrolling containers.
215
- * @param element Dimensions of the element (from getBoundingClientRect)
216
- * @param scrollContainers Dimensions of element's scrolling containers (from getBoundingClientRect)
217
- * @returns Whether the element is clipped
218
- * @docs-private
219
- */
220
- function isElementClippedByScrolling(element, scrollContainers) {
221
- return scrollContainers.some(scrollContainerRect => {
222
- const clippedAbove = element.top < scrollContainerRect.top;
223
- const clippedBelow = element.bottom > scrollContainerRect.bottom;
224
- const clippedLeft = element.left < scrollContainerRect.left;
225
- const clippedRight = element.right > scrollContainerRect.right;
226
- return clippedAbove || clippedBelow || clippedLeft || clippedRight;
227
- });
228
- }
229
-
230
- /**
231
- * @license
232
- * Copyright Google LLC All Rights Reserved.
233
- *
234
- * Use of this source code is governed by an MIT-style license that can be
235
- * found in the LICENSE file at https://angular.io/license
236
- */
237
- /**
238
- * Strategy that will update the element position as the user is scrolling.
239
- */
240
- class RepositionScrollStrategy {
241
- constructor(_scrollDispatcher, _viewportRuler, _ngZone, _config) {
242
- this._scrollDispatcher = _scrollDispatcher;
243
- this._viewportRuler = _viewportRuler;
244
- this._ngZone = _ngZone;
245
- this._config = _config;
246
- this._scrollSubscription = null;
247
- }
248
- /** Attaches this scroll strategy to an overlay. */
249
- attach(overlayRef) {
250
- if (this._overlayRef && (typeof ngDevMode === 'undefined' || ngDevMode)) {
251
- throw getMatScrollStrategyAlreadyAttachedError();
252
- }
253
- this._overlayRef = overlayRef;
254
- }
255
- /** Enables repositioning of the attached overlay on scroll. */
256
- enable() {
257
- if (!this._scrollSubscription) {
258
- const throttle = this._config ? this._config.scrollThrottle : 0;
259
- this._scrollSubscription = this._scrollDispatcher.scrolled(throttle).subscribe(() => {
260
- this._overlayRef.updatePosition();
261
- // TODO(crisbeto): make `close` on by default once all components can handle it.
262
- if (this._config && this._config.autoClose) {
263
- const overlayRect = this._overlayRef.overlayElement.getBoundingClientRect();
264
- const { width, height } = this._viewportRuler.getViewportSize();
265
- // TODO(crisbeto): include all ancestor scroll containers here once
266
- // we have a way of exposing the trigger element to the scroll strategy.
267
- const parentRects = [{ width, height, bottom: height, right: width, top: 0, left: 0 }];
268
- if (isElementScrolledOutsideView(overlayRect, parentRects)) {
269
- this.disable();
270
- this._ngZone.run(() => this._overlayRef.detach());
271
- }
272
- }
273
- });
274
- }
275
- }
276
- /** Disables repositioning of the attached overlay on scroll. */
277
- disable() {
278
- if (this._scrollSubscription) {
279
- this._scrollSubscription.unsubscribe();
280
- this._scrollSubscription = null;
281
- }
282
- }
283
- detach() {
284
- this.disable();
285
- this._overlayRef = null;
286
- }
287
- }
288
-
289
- /**
290
- * Options for how an overlay will handle scrolling.
291
- *
292
- * Users can provide a custom value for `ScrollStrategyOptions` to replace the default
293
- * behaviors. This class primarily acts as a factory for ScrollStrategy instances.
294
- */
295
- class ScrollStrategyOptions {
296
- constructor(_scrollDispatcher, _viewportRuler, _ngZone, document) {
297
- this._scrollDispatcher = _scrollDispatcher;
298
- this._viewportRuler = _viewportRuler;
299
- this._ngZone = _ngZone;
300
- /** Do nothing on scroll. */
301
- this.noop = () => new NoopScrollStrategy();
302
- /**
303
- * Close the overlay as soon as the user scrolls.
304
- * @param config Configuration to be used inside the scroll strategy.
305
- */
306
- this.close = (config) => new CloseScrollStrategy(this._scrollDispatcher, this._ngZone, this._viewportRuler, config);
307
- /** Block scrolling. */
308
- this.block = () => new BlockScrollStrategy(this._viewportRuler, this._document);
309
- /**
310
- * Update the overlay's position on scroll.
311
- * @param config Configuration to be used inside the scroll strategy.
312
- * Allows debouncing the reposition calls.
313
- */
314
- this.reposition = (config) => new RepositionScrollStrategy(this._scrollDispatcher, this._viewportRuler, this._ngZone, config);
315
- this._document = document;
316
- }
317
- }
318
- ScrollStrategyOptions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: ScrollStrategyOptions, deps: [{ token: i1.ScrollDispatcher }, { token: i1.ViewportRuler }, { token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
319
- ScrollStrategyOptions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: ScrollStrategyOptions, providedIn: 'root' });
320
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: ScrollStrategyOptions, decorators: [{
321
- type: Injectable,
322
- args: [{ providedIn: 'root' }]
323
- }], ctorParameters: function () {
324
- return [{ type: i1.ScrollDispatcher }, { type: i1.ViewportRuler }, { type: i0.NgZone }, { type: undefined, decorators: [{
325
- type: Inject,
326
- args: [DOCUMENT]
327
- }] }];
328
- } });
329
-
330
- /**
331
- * @license
332
- * Copyright Google LLC All Rights Reserved.
333
- *
334
- * Use of this source code is governed by an MIT-style license that can be
335
- * found in the LICENSE file at https://angular.io/license
336
- */
337
-
338
- /**
339
- * @license
340
- * Copyright Google LLC All Rights Reserved.
341
- *
342
- * Use of this source code is governed by an MIT-style license that can be
343
- * found in the LICENSE file at https://angular.io/license
344
- */
345
- /** Initial configuration used when creating an overlay. */
346
- class OverlayConfig {
347
- constructor(config) {
348
- /** Strategy to be used when handling scroll events while the overlay is open. */
349
- this.scrollStrategy = new NoopScrollStrategy();
350
- /** Custom class to add to the overlay pane. */
351
- this.panelClass = '';
352
- /** Whether the overlay has a backdrop. */
353
- this.hasBackdrop = false;
354
- /** Custom class to add to the backdrop */
355
- this.backdropClass = 'cdk-overlay-dark-backdrop';
356
- /**
357
- * Whether the overlay should be disposed of when the user goes backwards/forwards in history.
358
- * Note that this usually doesn't include clicking on links (unless the user is using
359
- * the `HashLocationStrategy`).
360
- */
361
- this.disposeOnNavigation = false;
362
- if (config) {
363
- // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
364
- // loses the array generic type in the `for of`. But we *also* have to use `Array` because
365
- // typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
366
- const configKeys = Object.keys(config);
367
- for (const key of configKeys) {
368
- if (config[key] !== undefined) {
369
- // TypeScript, as of version 3.5, sees the left-hand-side of this expression
370
- // as "I don't know *which* key this is, so the only valid value is the intersection
371
- // of all the possible values." In this case, that happens to be `undefined`. TypeScript
372
- // is not smart enough to see that the right-hand-side is actually an access of the same
373
- // exact type with the same exact key, meaning that the value type must be identical.
374
- // So we use `any` to work around this.
375
- this[key] = config[key];
376
- }
377
- }
378
- }
379
- }
380
- }
381
-
382
- /**
383
- * @license
384
- * Copyright Google LLC All Rights Reserved.
385
- *
386
- * Use of this source code is governed by an MIT-style license that can be
387
- * found in the LICENSE file at https://angular.io/license
388
- */
389
- /** The points of the origin element and the overlay element to connect. */
390
- class ConnectionPositionPair {
391
- constructor(origin, overlay,
392
- /** Offset along the X axis. */
393
- offsetX,
394
- /** Offset along the Y axis. */
395
- offsetY,
396
- /** Class(es) to be applied to the panel while this position is active. */
397
- panelClass) {
398
- this.offsetX = offsetX;
399
- this.offsetY = offsetY;
400
- this.panelClass = panelClass;
401
- this.originX = origin.originX;
402
- this.originY = origin.originY;
403
- this.overlayX = overlay.overlayX;
404
- this.overlayY = overlay.overlayY;
405
- }
406
- }
407
- /**
408
- * Set of properties regarding the position of the origin and overlay relative to the viewport
409
- * with respect to the containing Scrollable elements.
410
- *
411
- * The overlay and origin are clipped if any part of their bounding client rectangle exceeds the
412
- * bounds of any one of the strategy's Scrollable's bounding client rectangle.
413
- *
414
- * The overlay and origin are outside view if there is no overlap between their bounding client
415
- * rectangle and any one of the strategy's Scrollable's bounding client rectangle.
416
- *
417
- * ----------- -----------
418
- * | outside | | clipped |
419
- * | view | --------------------------
420
- * | | | | | |
421
- * ---------- | ----------- |
422
- * -------------------------- | |
423
- * | | | Scrollable |
424
- * | | | |
425
- * | | --------------------------
426
- * | Scrollable |
427
- * | |
428
- * --------------------------
429
- *
430
- * @docs-private
431
- */
432
- class ScrollingVisibility {
433
- }
434
- /** The change event emitted by the strategy when a fallback position is used. */
435
- class ConnectedOverlayPositionChange {
436
- constructor(
437
- /** The position used as a result of this change. */
438
- connectionPair,
439
- /** @docs-private */
440
- scrollableViewProperties) {
441
- this.connectionPair = connectionPair;
442
- this.scrollableViewProperties = scrollableViewProperties;
443
- }
444
- }
445
- /**
446
- * Validates whether a vertical position property matches the expected values.
447
- * @param property Name of the property being validated.
448
- * @param value Value of the property being validated.
449
- * @docs-private
450
- */
451
- function validateVerticalPosition(property, value) {
452
- if (value !== 'top' && value !== 'bottom' && value !== 'center') {
453
- throw Error(`ConnectedPosition: Invalid ${property} "${value}". ` +
454
- `Expected "top", "bottom" or "center".`);
455
- }
456
- }
457
- /**
458
- * Validates whether a horizontal position property matches the expected values.
459
- * @param property Name of the property being validated.
460
- * @param value Value of the property being validated.
461
- * @docs-private
462
- */
463
- function validateHorizontalPosition(property, value) {
464
- if (value !== 'start' && value !== 'end' && value !== 'center') {
465
- throw Error(`ConnectedPosition: Invalid ${property} "${value}". ` +
466
- `Expected "start", "end" or "center".`);
467
- }
468
- }
469
-
470
- /**
471
- * @license
472
- * Copyright Google LLC All Rights Reserved.
473
- *
474
- * Use of this source code is governed by an MIT-style license that can be
475
- * found in the LICENSE file at https://angular.io/license
476
- */
477
- /**
478
- * Reference to an overlay that has been created with the Overlay service.
479
- * Used to manipulate or dispose of said overlay.
480
- */
481
- class OverlayRef {
482
- constructor(_portalOutlet, _host, _pane, _config, _ngZone, _keyboardDispatcher, _document, _location, _outsideClickDispatcher, _animationsDisabled = false) {
483
- this._portalOutlet = _portalOutlet;
484
- this._host = _host;
485
- this._pane = _pane;
486
- this._config = _config;
487
- this._ngZone = _ngZone;
488
- this._keyboardDispatcher = _keyboardDispatcher;
489
- this._document = _document;
490
- this._location = _location;
491
- this._outsideClickDispatcher = _outsideClickDispatcher;
492
- this._animationsDisabled = _animationsDisabled;
493
- this._backdropElement = null;
494
- this._backdropClick = new Subject();
495
- this._attachments = new Subject();
496
- this._detachments = new Subject();
497
- this._locationChanges = Subscription.EMPTY;
498
- this._backdropClickHandler = (event) => this._backdropClick.next(event);
499
- this._backdropTransitionendHandler = (event) => {
500
- this._disposeBackdrop(event.target);
501
- };
502
- /** Stream of keydown events dispatched to this overlay. */
503
- this._keydownEvents = new Subject();
504
- /** Stream of mouse outside events dispatched to this overlay. */
505
- this._outsidePointerEvents = new Subject();
506
- if (_config.scrollStrategy) {
507
- this._scrollStrategy = _config.scrollStrategy;
508
- this._scrollStrategy.attach(this);
509
- }
510
- this._positionStrategy = _config.positionStrategy;
511
- }
512
- /** The overlay's HTML element */
513
- get overlayElement() {
514
- return this._pane;
515
- }
516
- /** The overlay's backdrop HTML element. */
517
- get backdropElement() {
518
- return this._backdropElement;
519
- }
520
- /**
521
- * Wrapper around the panel element. Can be used for advanced
522
- * positioning where a wrapper with specific styling is
523
- * required around the overlay pane.
524
- */
525
- get hostElement() {
526
- return this._host;
527
- }
528
- /**
529
- * Attaches content, given via a Portal, to the overlay.
530
- * If the overlay is configured to have a backdrop, it will be created.
531
- *
532
- * @param portal Portal instance to which to attach the overlay.
533
- * @returns The portal attachment result.
534
- */
535
- attach(portal) {
536
- // Insert the host into the DOM before attaching the portal, otherwise
537
- // the animations module will skip animations on repeat attachments.
538
- if (!this._host.parentElement && this._previousHostParent) {
539
- this._previousHostParent.appendChild(this._host);
540
- }
541
- const attachResult = this._portalOutlet.attach(portal);
542
- if (this._positionStrategy) {
543
- this._positionStrategy.attach(this);
544
- }
545
- this._updateStackingOrder();
546
- this._updateElementSize();
547
- this._updateElementDirection();
548
- if (this._scrollStrategy) {
549
- this._scrollStrategy.enable();
550
- }
551
- // Update the position once the zone is stable so that the overlay will be fully rendered
552
- // before attempting to position it, as the position may depend on the size of the rendered
553
- // content.
554
- this._ngZone.onStable.pipe(take(1)).subscribe(() => {
555
- // The overlay could've been detached before the zone has stabilized.
556
- if (this.hasAttached()) {
557
- this.updatePosition();
558
- }
559
- });
560
- // Enable pointer events for the overlay pane element.
561
- this._togglePointerEvents(true);
562
- if (this._config.hasBackdrop) {
563
- this._attachBackdrop();
564
- }
565
- if (this._config.panelClass) {
566
- this._toggleClasses(this._pane, this._config.panelClass, true);
567
- }
568
- // Only emit the `attachments` event once all other setup is done.
569
- this._attachments.next();
570
- // Track this overlay by the keyboard dispatcher
571
- this._keyboardDispatcher.add(this);
572
- if (this._config.disposeOnNavigation) {
573
- this._locationChanges = this._location.subscribe(() => this.dispose());
574
- }
575
- this._outsideClickDispatcher.add(this);
576
- // TODO(crisbeto): the null check is here, because the portal outlet returns `any`.
577
- // We should be guaranteed for the result to be `ComponentRef | EmbeddedViewRef`, but
578
- // `instanceof EmbeddedViewRef` doesn't appear to work at the moment.
579
- if (typeof (attachResult === null || attachResult === void 0 ? void 0 : attachResult.onDestroy) === 'function') {
580
- // In most cases we control the portal and we know when it is being detached so that
581
- // we can finish the disposal process. The exception is if the user passes in a custom
582
- // `ViewContainerRef` that isn't destroyed through the overlay API. Note that we use
583
- // `detach` here instead of `dispose`, because we don't know if the user intends to
584
- // reattach the overlay at a later point. It also has the advantage of waiting for animations.
585
- attachResult.onDestroy(() => {
586
- if (this.hasAttached()) {
587
- // We have to delay the `detach` call, because detaching immediately prevents
588
- // other destroy hooks from running. This is likely a framework bug similar to
589
- // https://github.com/angular/angular/issues/46119
590
- this._ngZone.runOutsideAngular(() => Promise.resolve().then(() => this.detach()));
591
- }
592
- });
593
- }
594
- return attachResult;
595
- }
596
- /**
597
- * Detaches an overlay from a portal.
598
- * @returns The portal detachment result.
599
- */
600
- detach() {
601
- if (!this.hasAttached()) {
602
- return;
603
- }
604
- this.detachBackdrop();
605
- // When the overlay is detached, the pane element should disable pointer events.
606
- // This is necessary because otherwise the pane element will cover the page and disable
607
- // pointer events therefore. Depends on the position strategy and the applied pane boundaries.
608
- this._togglePointerEvents(false);
609
- if (this._positionStrategy && this._positionStrategy.detach) {
610
- this._positionStrategy.detach();
611
- }
612
- if (this._scrollStrategy) {
613
- this._scrollStrategy.disable();
614
- }
615
- const detachmentResult = this._portalOutlet.detach();
616
- // Only emit after everything is detached.
617
- this._detachments.next();
618
- // Remove this overlay from keyboard dispatcher tracking.
619
- this._keyboardDispatcher.remove(this);
620
- // Keeping the host element in the DOM can cause scroll jank, because it still gets
621
- // rendered, even though it's transparent and unclickable which is why we remove it.
622
- this._detachContentWhenStable();
623
- this._locationChanges.unsubscribe();
624
- this._outsideClickDispatcher.remove(this);
625
- return detachmentResult;
626
- }
627
- /** Cleans up the overlay from the DOM. */
628
- dispose() {
629
- var _a;
630
- const isAttached = this.hasAttached();
631
- if (this._positionStrategy) {
632
- this._positionStrategy.dispose();
633
- }
634
- this._disposeScrollStrategy();
635
- this._disposeBackdrop(this._backdropElement);
636
- this._locationChanges.unsubscribe();
637
- this._keyboardDispatcher.remove(this);
638
- this._portalOutlet.dispose();
639
- this._attachments.complete();
640
- this._backdropClick.complete();
641
- this._keydownEvents.complete();
642
- this._outsidePointerEvents.complete();
643
- this._outsideClickDispatcher.remove(this);
644
- (_a = this._host) === null || _a === void 0 ? void 0 : _a.remove();
645
- this._previousHostParent = this._pane = this._host = null;
646
- if (isAttached) {
647
- this._detachments.next();
648
- }
649
- this._detachments.complete();
650
- }
651
- /** Whether the overlay has attached content. */
652
- hasAttached() {
653
- return this._portalOutlet.hasAttached();
654
- }
655
- /** Gets an observable that emits when the backdrop has been clicked. */
656
- backdropClick() {
657
- return this._backdropClick;
658
- }
659
- /** Gets an observable that emits when the overlay has been attached. */
660
- attachments() {
661
- return this._attachments;
662
- }
663
- /** Gets an observable that emits when the overlay has been detached. */
664
- detachments() {
665
- return this._detachments;
666
- }
667
- /** Gets an observable of keydown events targeted to this overlay. */
668
- keydownEvents() {
669
- return this._keydownEvents;
670
- }
671
- /** Gets an observable of pointer events targeted outside this overlay. */
672
- outsidePointerEvents() {
673
- return this._outsidePointerEvents;
674
- }
675
- /** Gets the current overlay configuration, which is immutable. */
676
- getConfig() {
677
- return this._config;
678
- }
679
- /** Updates the position of the overlay based on the position strategy. */
680
- updatePosition() {
681
- if (this._positionStrategy) {
682
- this._positionStrategy.apply();
683
- }
684
- }
685
- /** Switches to a new position strategy and updates the overlay position. */
686
- updatePositionStrategy(strategy) {
687
- if (strategy === this._positionStrategy) {
688
- return;
689
- }
690
- if (this._positionStrategy) {
691
- this._positionStrategy.dispose();
692
- }
693
- this._positionStrategy = strategy;
694
- if (this.hasAttached()) {
695
- strategy.attach(this);
696
- this.updatePosition();
697
- }
698
- }
699
- /** Update the size properties of the overlay. */
700
- updateSize(sizeConfig) {
701
- this._config = Object.assign(Object.assign({}, this._config), sizeConfig);
702
- this._updateElementSize();
703
- }
704
- /** Sets the LTR/RTL direction for the overlay. */
705
- setDirection(dir) {
706
- this._config = Object.assign(Object.assign({}, this._config), { direction: dir });
707
- this._updateElementDirection();
708
- }
709
- /** Add a CSS class or an array of classes to the overlay pane. */
710
- addPanelClass(classes) {
711
- if (this._pane) {
712
- this._toggleClasses(this._pane, classes, true);
713
- }
714
- }
715
- /** Remove a CSS class or an array of classes from the overlay pane. */
716
- removePanelClass(classes) {
717
- if (this._pane) {
718
- this._toggleClasses(this._pane, classes, false);
719
- }
720
- }
721
- /**
722
- * Returns the layout direction of the overlay panel.
723
- */
724
- getDirection() {
725
- const direction = this._config.direction;
726
- if (!direction) {
727
- return 'ltr';
728
- }
729
- return typeof direction === 'string' ? direction : direction.value;
730
- }
731
- /** Switches to a new scroll strategy. */
732
- updateScrollStrategy(strategy) {
733
- if (strategy === this._scrollStrategy) {
734
- return;
735
- }
736
- this._disposeScrollStrategy();
737
- this._scrollStrategy = strategy;
738
- if (this.hasAttached()) {
739
- strategy.attach(this);
740
- strategy.enable();
741
- }
742
- }
743
- /** Updates the text direction of the overlay panel. */
744
- _updateElementDirection() {
745
- this._host.setAttribute('dir', this.getDirection());
746
- }
747
- /** Updates the size of the overlay element based on the overlay config. */
748
- _updateElementSize() {
749
- if (!this._pane) {
750
- return;
751
- }
752
- const style = this._pane.style;
753
- style.width = coerceCssPixelValue(this._config.width);
754
- style.height = coerceCssPixelValue(this._config.height);
755
- style.minWidth = coerceCssPixelValue(this._config.minWidth);
756
- style.minHeight = coerceCssPixelValue(this._config.minHeight);
757
- style.maxWidth = coerceCssPixelValue(this._config.maxWidth);
758
- style.maxHeight = coerceCssPixelValue(this._config.maxHeight);
759
- }
760
- /** Toggles the pointer events for the overlay pane element. */
761
- _togglePointerEvents(enablePointer) {
762
- this._pane.style.pointerEvents = enablePointer ? '' : 'none';
763
- }
764
- /** Attaches a backdrop for this overlay. */
765
- _attachBackdrop() {
766
- const showingClass = 'cdk-overlay-backdrop-showing';
767
- this._backdropElement = this._document.createElement('div');
768
- this._backdropElement.classList.add('cdk-overlay-backdrop');
769
- if (this._animationsDisabled) {
770
- this._backdropElement.classList.add('cdk-overlay-backdrop-noop-animation');
771
- }
772
- if (this._config.backdropClass) {
773
- this._toggleClasses(this._backdropElement, this._config.backdropClass, true);
774
- }
775
- // Insert the backdrop before the pane in the DOM order,
776
- // in order to handle stacked overlays properly.
777
- this._host.parentElement.insertBefore(this._backdropElement, this._host);
778
- // Forward backdrop clicks such that the consumer of the overlay can perform whatever
779
- // action desired when such a click occurs (usually closing the overlay).
780
- this._backdropElement.addEventListener('click', this._backdropClickHandler);
781
- // Add class to fade-in the backdrop after one frame.
782
- if (!this._animationsDisabled && typeof requestAnimationFrame !== 'undefined') {
783
- this._ngZone.runOutsideAngular(() => {
784
- requestAnimationFrame(() => {
785
- if (this._backdropElement) {
786
- this._backdropElement.classList.add(showingClass);
787
- }
788
- });
789
- });
790
- }
791
- else {
792
- this._backdropElement.classList.add(showingClass);
793
- }
794
- }
795
- /**
796
- * Updates the stacking order of the element, moving it to the top if necessary.
797
- * This is required in cases where one overlay was detached, while another one,
798
- * that should be behind it, was destroyed. The next time both of them are opened,
799
- * the stacking will be wrong, because the detached element's pane will still be
800
- * in its original DOM position.
801
- */
802
- _updateStackingOrder() {
803
- if (this._host.nextSibling) {
804
- this._host.parentNode.appendChild(this._host);
805
- }
806
- }
807
- /** Detaches the backdrop (if any) associated with the overlay. */
808
- detachBackdrop() {
809
- const backdropToDetach = this._backdropElement;
810
- if (!backdropToDetach) {
811
- return;
812
- }
813
- if (this._animationsDisabled) {
814
- this._disposeBackdrop(backdropToDetach);
815
- return;
816
- }
817
- backdropToDetach.classList.remove('cdk-overlay-backdrop-showing');
818
- this._ngZone.runOutsideAngular(() => {
819
- backdropToDetach.addEventListener('transitionend', this._backdropTransitionendHandler);
820
- });
821
- // If the backdrop doesn't have a transition, the `transitionend` event won't fire.
822
- // In this case we make it unclickable and we try to remove it after a delay.
823
- backdropToDetach.style.pointerEvents = 'none';
824
- // Run this outside the Angular zone because there's nothing that Angular cares about.
825
- // If it were to run inside the Angular zone, every test that used Overlay would have to be
826
- // either async or fakeAsync.
827
- this._backdropTimeout = this._ngZone.runOutsideAngular(() => setTimeout(() => {
828
- this._disposeBackdrop(backdropToDetach);
829
- }, 500));
830
- }
831
- /** Toggles a single CSS class or an array of classes on an element. */
832
- _toggleClasses(element, cssClasses, isAdd) {
833
- const classes = coerceArray(cssClasses || []).filter(c => !!c);
834
- if (classes.length) {
835
- isAdd ? element.classList.add(...classes) : element.classList.remove(...classes);
836
- }
837
- }
838
- /** Detaches the overlay content next time the zone stabilizes. */
839
- _detachContentWhenStable() {
840
- // Normally we wouldn't have to explicitly run this outside the `NgZone`, however
841
- // if the consumer is using `zone-patch-rxjs`, the `Subscription.unsubscribe` call will
842
- // be patched to run inside the zone, which will throw us into an infinite loop.
843
- this._ngZone.runOutsideAngular(() => {
844
- // We can't remove the host here immediately, because the overlay pane's content
845
- // might still be animating. This stream helps us avoid interrupting the animation
846
- // by waiting for the pane to become empty.
847
- const subscription = this._ngZone.onStable
848
- .pipe(takeUntil(merge(this._attachments, this._detachments)))
849
- .subscribe(() => {
850
- // Needs a couple of checks for the pane and host, because
851
- // they may have been removed by the time the zone stabilizes.
852
- if (!this._pane || !this._host || this._pane.children.length === 0) {
853
- if (this._pane && this._config.panelClass) {
854
- this._toggleClasses(this._pane, this._config.panelClass, false);
855
- }
856
- if (this._host && this._host.parentElement) {
857
- this._previousHostParent = this._host.parentElement;
858
- this._host.remove();
859
- }
860
- subscription.unsubscribe();
861
- }
862
- });
863
- });
864
- }
865
- /** Disposes of a scroll strategy. */
866
- _disposeScrollStrategy() {
867
- const scrollStrategy = this._scrollStrategy;
868
- if (scrollStrategy) {
869
- scrollStrategy.disable();
870
- if (scrollStrategy.detach) {
871
- scrollStrategy.detach();
872
- }
873
- }
874
- }
875
- /** Removes a backdrop element from the DOM. */
876
- _disposeBackdrop(backdrop) {
877
- if (backdrop) {
878
- backdrop.removeEventListener('click', this._backdropClickHandler);
879
- backdrop.removeEventListener('transitionend', this._backdropTransitionendHandler);
880
- backdrop.remove();
881
- // It is possible that a new portal has been attached to this overlay since we started
882
- // removing the backdrop. If that is the case, only clear the backdrop reference if it
883
- // is still the same instance that we started to remove.
884
- if (this._backdropElement === backdrop) {
885
- this._backdropElement = null;
886
- }
887
- }
888
- if (this._backdropTimeout) {
889
- clearTimeout(this._backdropTimeout);
890
- this._backdropTimeout = undefined;
891
- }
892
- }
893
- }
894
-
895
- /**
896
- * @license
897
- * Copyright Google LLC All Rights Reserved.
898
- *
899
- * Use of this source code is governed by an MIT-style license that can be
900
- * found in the LICENSE file at https://angular.io/license
901
- */
902
- /** Container inside which all overlays will render. */
903
- class OverlayContainer {
904
- constructor(document, _platform) {
905
- this._platform = _platform;
906
- this._document = document;
907
- }
908
- ngOnDestroy() {
909
- var _a;
910
- (_a = this._containerElement) === null || _a === void 0 ? void 0 : _a.remove();
911
- }
912
- /**
913
- * This method returns the overlay container element. It will lazily
914
- * create the element the first time it is called to facilitate using
915
- * the container in non-browser environments.
916
- * @returns the container element
917
- */
918
- getContainerElement() {
919
- if (!this._containerElement) {
920
- this._createContainer();
921
- }
922
- return this._containerElement;
923
- }
924
- /**
925
- * Create the overlay container element, which is simply a div
926
- * with the 'cdk-overlay-container' class on the document body.
927
- */
928
- _createContainer() {
929
- const containerClass = 'cdk-overlay-container';
930
- // TODO(crisbeto): remove the testing check once we have an overlay testing
931
- // module or Angular starts tearing down the testing `NgModule`. See:
932
- // https://github.com/angular/angular/issues/18831
933
- if (this._platform.isBrowser || _isTestEnvironment()) {
934
- const oppositePlatformContainers = this._document.querySelectorAll(`.${containerClass}[platform="server"], ` + `.${containerClass}[platform="test"]`);
935
- // Remove any old containers from the opposite platform.
936
- // This can happen when transitioning from the server to the client.
937
- for (let i = 0; i < oppositePlatformContainers.length; i++) {
938
- oppositePlatformContainers[i].remove();
939
- }
940
- }
941
- const container = this._document.createElement('div');
942
- container.classList.add(containerClass);
943
- // A long time ago we kept adding new overlay containers whenever a new app was instantiated,
944
- // but at some point we added logic which clears the duplicate ones in order to avoid leaks.
945
- // The new logic was a little too aggressive since it was breaking some legitimate use cases.
946
- // To mitigate the problem we made it so that only containers from a different platform are
947
- // cleared, but the side-effect was that people started depending on the overly-aggressive
948
- // logic to clean up their tests for them. Until we can introduce an overlay-specific testing
949
- // module which does the cleanup, we try to detect that we're in a test environment and we
950
- // always clear the container. See #17006.
951
- // TODO(crisbeto): remove the test environment check once we have an overlay testing module.
952
- if (_isTestEnvironment()) {
953
- container.setAttribute('platform', 'test');
954
- }
955
- else if (!this._platform.isBrowser) {
956
- container.setAttribute('platform', 'server');
957
- }
958
- this._document.body.appendChild(container);
959
- this._containerElement = container;
960
- }
961
- }
962
- OverlayContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayContainer, deps: [{ token: DOCUMENT }, { token: i1$1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
963
- OverlayContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayContainer, providedIn: 'root' });
964
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayContainer, decorators: [{
965
- type: Injectable,
966
- args: [{ providedIn: 'root' }]
967
- }], ctorParameters: function () {
968
- return [{ type: undefined, decorators: [{
969
- type: Inject,
970
- args: [DOCUMENT]
971
- }] }, { type: i1$1.Platform }];
972
- } });
973
-
974
- /**
975
- * @license
976
- * Copyright Google LLC All Rights Reserved.
977
- *
978
- * Use of this source code is governed by an MIT-style license that can be
979
- * found in the LICENSE file at https://angular.io/license
980
- */
981
- // TODO: refactor clipping detection into a separate thing (part of scrolling module)
982
- // TODO: doesn't handle both flexible width and height when it has to scroll along both axis.
983
- /** Class to be added to the overlay bounding box. */
984
- const boundingBoxClass = 'cdk-overlay-connected-position-bounding-box';
985
- /** Regex used to split a string on its CSS units. */
986
- const cssUnitPattern = /([A-Za-z%]+)$/;
987
- /**
988
- * A strategy for positioning overlays. Using this strategy, an overlay is given an
989
- * implicit position relative some origin element. The relative position is defined in terms of
990
- * a point on the origin element that is connected to a point on the overlay element. For example,
991
- * a basic dropdown is connecting the bottom-left corner of the origin to the top-left corner
992
- * of the overlay.
993
- */
994
- class FlexibleConnectedPositionStrategy {
995
- /** Ordered list of preferred positions, from most to least desirable. */
996
- get positions() {
997
- return this._preferredPositions;
998
- }
999
- constructor(connectedTo, _viewportRuler, _document, _platform, _overlayContainer) {
1000
- this._viewportRuler = _viewportRuler;
1001
- this._document = _document;
1002
- this._platform = _platform;
1003
- this._overlayContainer = _overlayContainer;
1004
- /** Last size used for the bounding box. Used to avoid resizing the overlay after open. */
1005
- this._lastBoundingBoxSize = { width: 0, height: 0 };
1006
- /** Whether the overlay was pushed in a previous positioning. */
1007
- this._isPushed = false;
1008
- /** Whether the overlay can be pushed on-screen on the initial open. */
1009
- this._canPush = true;
1010
- /** Whether the overlay can grow via flexible width/height after the initial open. */
1011
- this._growAfterOpen = false;
1012
- /** Whether the overlay's width and height can be constrained to fit within the viewport. */
1013
- this._hasFlexibleDimensions = true;
1014
- /** Whether the overlay position is locked. */
1015
- this._positionLocked = false;
1016
- /** Amount of space that must be maintained between the overlay and the edge of the viewport. */
1017
- this._viewportMargin = 0;
1018
- /** The Scrollable containers used to check scrollable view properties on position change. */
1019
- this._scrollables = [];
1020
- /** Ordered list of preferred positions, from most to least desirable. */
1021
- this._preferredPositions = [];
1022
- /** Subject that emits whenever the position changes. */
1023
- this._positionChanges = new Subject();
1024
- /** Subscription to viewport size changes. */
1025
- this._resizeSubscription = Subscription.EMPTY;
1026
- /** Default offset for the overlay along the x axis. */
1027
- this._offsetX = 0;
1028
- /** Default offset for the overlay along the y axis. */
1029
- this._offsetY = 0;
1030
- /** Keeps track of the CSS classes that the position strategy has applied on the overlay panel. */
1031
- this._appliedPanelClasses = [];
1032
- /** Observable sequence of position changes. */
1033
- this.positionChanges = this._positionChanges;
1034
- this.setOrigin(connectedTo);
1035
- }
1036
- /** Attaches this position strategy to an overlay. */
1037
- attach(overlayRef) {
1038
- if (this._overlayRef &&
1039
- overlayRef !== this._overlayRef &&
1040
- (typeof ngDevMode === 'undefined' || ngDevMode)) {
1041
- throw Error('This position strategy is already attached to an overlay');
1042
- }
1043
- this._validatePositions();
1044
- overlayRef.hostElement.classList.add(boundingBoxClass);
1045
- this._overlayRef = overlayRef;
1046
- this._boundingBox = overlayRef.hostElement;
1047
- this._pane = overlayRef.overlayElement;
1048
- this._isDisposed = false;
1049
- this._isInitialRender = true;
1050
- this._lastPosition = null;
1051
- this._resizeSubscription.unsubscribe();
1052
- this._resizeSubscription = this._viewportRuler.change().subscribe(() => {
1053
- // When the window is resized, we want to trigger the next reposition as if it
1054
- // was an initial render, in order for the strategy to pick a new optimal position,
1055
- // otherwise position locking will cause it to stay at the old one.
1056
- this._isInitialRender = true;
1057
- this.apply();
1058
- });
1059
- }
1060
- /**
1061
- * Updates the position of the overlay element, using whichever preferred position relative
1062
- * to the origin best fits on-screen.
1063
- *
1064
- * The selection of a position goes as follows:
1065
- * - If any positions fit completely within the viewport as-is,
1066
- * choose the first position that does so.
1067
- * - If flexible dimensions are enabled and at least one satisfies the given minimum width/height,
1068
- * choose the position with the greatest available size modified by the positions' weight.
1069
- * - If pushing is enabled, take the position that went off-screen the least and push it
1070
- * on-screen.
1071
- * - If none of the previous criteria were met, use the position that goes off-screen the least.
1072
- * @docs-private
1073
- */
1074
- apply() {
1075
- // We shouldn't do anything if the strategy was disposed or we're on the server.
1076
- if (this._isDisposed || !this._platform.isBrowser) {
1077
- return;
1078
- }
1079
- // If the position has been applied already (e.g. when the overlay was opened) and the
1080
- // consumer opted into locking in the position, re-use the old position, in order to
1081
- // prevent the overlay from jumping around.
1082
- if (!this._isInitialRender && this._positionLocked && this._lastPosition) {
1083
- this.reapplyLastPosition();
1084
- return;
1085
- }
1086
- this._clearPanelClasses();
1087
- this._resetOverlayElementStyles();
1088
- this._resetBoundingBoxStyles();
1089
- // We need the bounding rects for the origin, the overlay and the container to determine how to position
1090
- // the overlay relative to the origin.
1091
- // We use the viewport rect to determine whether a position would go off-screen.
1092
- this._viewportRect = this._getNarrowedViewportRect();
1093
- this._originRect = this._getOriginRect();
1094
- this._overlayRect = this._pane.getBoundingClientRect();
1095
- this._containerRect = this._overlayContainer.getContainerElement().getBoundingClientRect();
1096
- const originRect = this._originRect;
1097
- const overlayRect = this._overlayRect;
1098
- const viewportRect = this._viewportRect;
1099
- const containerRect = this._containerRect;
1100
- // Positions where the overlay will fit with flexible dimensions.
1101
- const flexibleFits = [];
1102
- // Fallback if none of the preferred positions fit within the viewport.
1103
- let fallback;
1104
- // Go through each of the preferred positions looking for a good fit.
1105
- // If a good fit is found, it will be applied immediately.
1106
- for (let pos of this._preferredPositions) {
1107
- // Get the exact (x, y) coordinate for the point-of-origin on the origin element.
1108
- let originPoint = this._getOriginPoint(originRect, containerRect, pos);
1109
- // From that point-of-origin, get the exact (x, y) coordinate for the top-left corner of the
1110
- // overlay in this position. We use the top-left corner for calculations and later translate
1111
- // this into an appropriate (top, left, bottom, right) style.
1112
- let overlayPoint = this._getOverlayPoint(originPoint, overlayRect, pos);
1113
- // Calculate how well the overlay would fit into the viewport with this point.
1114
- let overlayFit = this._getOverlayFit(overlayPoint, overlayRect, viewportRect, pos);
1115
- // If the overlay, without any further work, fits into the viewport, use this position.
1116
- if (overlayFit.isCompletelyWithinViewport) {
1117
- this._isPushed = false;
1118
- this._applyPosition(pos, originPoint);
1119
- return;
1120
- }
1121
- // If the overlay has flexible dimensions, we can use this position
1122
- // so long as there's enough space for the minimum dimensions.
1123
- if (this._canFitWithFlexibleDimensions(overlayFit, overlayPoint, viewportRect)) {
1124
- // Save positions where the overlay will fit with flexible dimensions. We will use these
1125
- // if none of the positions fit *without* flexible dimensions.
1126
- flexibleFits.push({
1127
- position: pos,
1128
- origin: originPoint,
1129
- overlayRect,
1130
- boundingBoxRect: this._calculateBoundingBoxRect(originPoint, pos),
1131
- });
1132
- continue;
1133
- }
1134
- // If the current preferred position does not fit on the screen, remember the position
1135
- // if it has more visible area on-screen than we've seen and move onto the next preferred
1136
- // position.
1137
- if (!fallback || fallback.overlayFit.visibleArea < overlayFit.visibleArea) {
1138
- fallback = { overlayFit, overlayPoint, originPoint, position: pos, overlayRect };
1139
- }
1140
- }
1141
- // If there are any positions where the overlay would fit with flexible dimensions, choose the
1142
- // one that has the greatest area available modified by the position's weight
1143
- if (flexibleFits.length) {
1144
- let bestFit = null;
1145
- let bestScore = -1;
1146
- for (const fit of flexibleFits) {
1147
- const score = fit.boundingBoxRect.width * fit.boundingBoxRect.height * (fit.position.weight || 1);
1148
- if (score > bestScore) {
1149
- bestScore = score;
1150
- bestFit = fit;
1151
- }
1152
- }
1153
- this._isPushed = false;
1154
- this._applyPosition(bestFit.position, bestFit.origin);
1155
- return;
1156
- }
1157
- // When none of the preferred positions fit within the viewport, take the position
1158
- // that went off-screen the least and attempt to push it on-screen.
1159
- if (this._canPush) {
1160
- // TODO(jelbourn): after pushing, the opening "direction" of the overlay might not make sense.
1161
- this._isPushed = true;
1162
- this._applyPosition(fallback.position, fallback.originPoint);
1163
- return;
1164
- }
1165
- // All options for getting the overlay within the viewport have been exhausted, so go with the
1166
- // position that went off-screen the least.
1167
- this._applyPosition(fallback.position, fallback.originPoint);
1168
- }
1169
- detach() {
1170
- this._clearPanelClasses();
1171
- this._lastPosition = null;
1172
- this._previousPushAmount = null;
1173
- this._resizeSubscription.unsubscribe();
1174
- }
1175
- /** Cleanup after the element gets destroyed. */
1176
- dispose() {
1177
- if (this._isDisposed) {
1178
- return;
1179
- }
1180
- // We can't use `_resetBoundingBoxStyles` here, because it resets
1181
- // some properties to zero, rather than removing them.
1182
- if (this._boundingBox) {
1183
- extendStyles(this._boundingBox.style, {
1184
- top: '',
1185
- left: '',
1186
- right: '',
1187
- bottom: '',
1188
- height: '',
1189
- width: '',
1190
- alignItems: '',
1191
- justifyContent: '',
1192
- });
1193
- }
1194
- if (this._pane) {
1195
- this._resetOverlayElementStyles();
1196
- }
1197
- if (this._overlayRef) {
1198
- this._overlayRef.hostElement.classList.remove(boundingBoxClass);
1199
- }
1200
- this.detach();
1201
- this._positionChanges.complete();
1202
- this._overlayRef = this._boundingBox = null;
1203
- this._isDisposed = true;
1204
- }
1205
- /**
1206
- * This re-aligns the overlay element with the trigger in its last calculated position,
1207
- * even if a position higher in the "preferred positions" list would now fit. This
1208
- * allows one to re-align the panel without changing the orientation of the panel.
1209
- */
1210
- reapplyLastPosition() {
1211
- if (this._isDisposed || !this._platform.isBrowser) {
1212
- return;
1213
- }
1214
- const lastPosition = this._lastPosition;
1215
- if (lastPosition) {
1216
- this._originRect = this._getOriginRect();
1217
- this._overlayRect = this._pane.getBoundingClientRect();
1218
- this._viewportRect = this._getNarrowedViewportRect();
1219
- this._containerRect = this._overlayContainer.getContainerElement().getBoundingClientRect();
1220
- const originPoint = this._getOriginPoint(this._originRect, this._containerRect, lastPosition);
1221
- this._applyPosition(lastPosition, originPoint);
1222
- }
1223
- else {
1224
- this.apply();
1225
- }
1226
- }
1227
- /**
1228
- * Sets the list of Scrollable containers that host the origin element so that
1229
- * on reposition we can evaluate if it or the overlay has been clipped or outside view. Every
1230
- * Scrollable must be an ancestor element of the strategy's origin element.
1231
- */
1232
- withScrollableContainers(scrollables) {
1233
- this._scrollables = scrollables;
1234
- return this;
1235
- }
1236
- /**
1237
- * Adds new preferred positions.
1238
- * @param positions List of positions options for this overlay.
1239
- */
1240
- withPositions(positions) {
1241
- this._preferredPositions = positions;
1242
- // If the last calculated position object isn't part of the positions anymore, clear
1243
- // it in order to avoid it being picked up if the consumer tries to re-apply.
1244
- if (positions.indexOf(this._lastPosition) === -1) {
1245
- this._lastPosition = null;
1246
- }
1247
- this._validatePositions();
1248
- return this;
1249
- }
1250
- /**
1251
- * Sets a minimum distance the overlay may be positioned to the edge of the viewport.
1252
- * @param margin Required margin between the overlay and the viewport edge in pixels.
1253
- */
1254
- withViewportMargin(margin) {
1255
- this._viewportMargin = margin;
1256
- return this;
1257
- }
1258
- /** Sets whether the overlay's width and height can be constrained to fit within the viewport. */
1259
- withFlexibleDimensions(flexibleDimensions = true) {
1260
- this._hasFlexibleDimensions = flexibleDimensions;
1261
- return this;
1262
- }
1263
- /** Sets whether the overlay can grow after the initial open via flexible width/height. */
1264
- withGrowAfterOpen(growAfterOpen = true) {
1265
- this._growAfterOpen = growAfterOpen;
1266
- return this;
1267
- }
1268
- /** Sets whether the overlay can be pushed on-screen if none of the provided positions fit. */
1269
- withPush(canPush = true) {
1270
- this._canPush = canPush;
1271
- return this;
1272
- }
1273
- /**
1274
- * Sets whether the overlay's position should be locked in after it is positioned
1275
- * initially. When an overlay is locked in, it won't attempt to reposition itself
1276
- * when the position is re-applied (e.g. when the user scrolls away).
1277
- * @param isLocked Whether the overlay should locked in.
1278
- */
1279
- withLockedPosition(isLocked = true) {
1280
- this._positionLocked = isLocked;
1281
- return this;
1282
- }
1283
- /**
1284
- * Sets the origin, relative to which to position the overlay.
1285
- * Using an element origin is useful for building components that need to be positioned
1286
- * relatively to a trigger (e.g. dropdown menus or tooltips), whereas using a point can be
1287
- * used for cases like contextual menus which open relative to the user's pointer.
1288
- * @param origin Reference to the new origin.
1289
- */
1290
- setOrigin(origin) {
1291
- this._origin = origin;
1292
- return this;
1293
- }
1294
- /**
1295
- * Sets the default offset for the overlay's connection point on the x-axis.
1296
- * @param offset New offset in the X axis.
1297
- */
1298
- withDefaultOffsetX(offset) {
1299
- this._offsetX = offset;
1300
- return this;
1301
- }
1302
- /**
1303
- * Sets the default offset for the overlay's connection point on the y-axis.
1304
- * @param offset New offset in the Y axis.
1305
- */
1306
- withDefaultOffsetY(offset) {
1307
- this._offsetY = offset;
1308
- return this;
1309
- }
1310
- /**
1311
- * Configures that the position strategy should set a `transform-origin` on some elements
1312
- * inside the overlay, depending on the current position that is being applied. This is
1313
- * useful for the cases where the origin of an animation can change depending on the
1314
- * alignment of the overlay.
1315
- * @param selector CSS selector that will be used to find the target
1316
- * elements onto which to set the transform origin.
1317
- */
1318
- withTransformOriginOn(selector) {
1319
- this._transformOriginSelector = selector;
1320
- return this;
1321
- }
1322
- /**
1323
- * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
1324
- */
1325
- _getOriginPoint(originRect, containerRect, pos) {
1326
- let x;
1327
- if (pos.originX == 'center') {
1328
- // Note: when centering we should always use the `left`
1329
- // offset, otherwise the position will be wrong in RTL.
1330
- x = originRect.left + originRect.width / 2;
1331
- }
1332
- else {
1333
- const startX = this._isRtl() ? originRect.right : originRect.left;
1334
- const endX = this._isRtl() ? originRect.left : originRect.right;
1335
- x = pos.originX == 'start' ? startX : endX;
1336
- }
1337
- // When zooming in Safari the container rectangle contains negative values for the position
1338
- // and we need to re-add them to the calculated coordinates.
1339
- if (containerRect.left < 0) {
1340
- x -= containerRect.left;
1341
- }
1342
- let y;
1343
- if (pos.originY == 'center') {
1344
- y = originRect.top + originRect.height / 2;
1345
- }
1346
- else {
1347
- y = pos.originY == 'top' ? originRect.top : originRect.bottom;
1348
- }
1349
- // Normally the containerRect's top value would be zero, however when the overlay is attached to an input
1350
- // (e.g. in an autocomplete), mobile browsers will shift everything in order to put the input in the middle
1351
- // of the screen and to make space for the virtual keyboard. We need to account for this offset,
1352
- // otherwise our positioning will be thrown off.
1353
- // Additionally, when zooming in Safari this fixes the vertical position.
1354
- if (containerRect.top < 0) {
1355
- y -= containerRect.top;
1356
- }
1357
- return { x, y };
1358
- }
1359
- /**
1360
- * Gets the (x, y) coordinate of the top-left corner of the overlay given a given position and
1361
- * origin point to which the overlay should be connected.
1362
- */
1363
- _getOverlayPoint(originPoint, overlayRect, pos) {
1364
- // Calculate the (overlayStartX, overlayStartY), the start of the
1365
- // potential overlay position relative to the origin point.
1366
- let overlayStartX;
1367
- if (pos.overlayX == 'center') {
1368
- overlayStartX = -overlayRect.width / 2;
1369
- }
1370
- else if (pos.overlayX === 'start') {
1371
- overlayStartX = this._isRtl() ? -overlayRect.width : 0;
1372
- }
1373
- else {
1374
- overlayStartX = this._isRtl() ? 0 : -overlayRect.width;
1375
- }
1376
- let overlayStartY;
1377
- if (pos.overlayY == 'center') {
1378
- overlayStartY = -overlayRect.height / 2;
1379
- }
1380
- else {
1381
- overlayStartY = pos.overlayY == 'top' ? 0 : -overlayRect.height;
1382
- }
1383
- // The (x, y) coordinates of the overlay.
1384
- return {
1385
- x: originPoint.x + overlayStartX,
1386
- y: originPoint.y + overlayStartY,
1387
- };
1388
- }
1389
- /** Gets how well an overlay at the given point will fit within the viewport. */
1390
- _getOverlayFit(point, rawOverlayRect, viewport, position) {
1391
- // Round the overlay rect when comparing against the
1392
- // viewport, because the viewport is always rounded.
1393
- const overlay = getRoundedBoundingClientRect(rawOverlayRect);
1394
- let { x, y } = point;
1395
- let offsetX = this._getOffset(position, 'x');
1396
- let offsetY = this._getOffset(position, 'y');
1397
- // Account for the offsets since they could push the overlay out of the viewport.
1398
- if (offsetX) {
1399
- x += offsetX;
1400
- }
1401
- if (offsetY) {
1402
- y += offsetY;
1403
- }
1404
- // How much the overlay would overflow at this position, on each side.
1405
- let leftOverflow = 0 - x;
1406
- let rightOverflow = x + overlay.width - viewport.width;
1407
- let topOverflow = 0 - y;
1408
- let bottomOverflow = y + overlay.height - viewport.height;
1409
- // Visible parts of the element on each axis.
1410
- let visibleWidth = this._subtractOverflows(overlay.width, leftOverflow, rightOverflow);
1411
- let visibleHeight = this._subtractOverflows(overlay.height, topOverflow, bottomOverflow);
1412
- let visibleArea = visibleWidth * visibleHeight;
1413
- return {
1414
- visibleArea,
1415
- isCompletelyWithinViewport: overlay.width * overlay.height === visibleArea,
1416
- fitsInViewportVertically: visibleHeight === overlay.height,
1417
- fitsInViewportHorizontally: visibleWidth == overlay.width,
1418
- };
1419
- }
1420
- /**
1421
- * Whether the overlay can fit within the viewport when it may resize either its width or height.
1422
- * @param fit How well the overlay fits in the viewport at some position.
1423
- * @param point The (x, y) coordinates of the overlay at some position.
1424
- * @param viewport The geometry of the viewport.
1425
- */
1426
- _canFitWithFlexibleDimensions(fit, point, viewport) {
1427
- if (this._hasFlexibleDimensions) {
1428
- const availableHeight = viewport.bottom - point.y;
1429
- const availableWidth = viewport.right - point.x;
1430
- const minHeight = getPixelValue(this._overlayRef.getConfig().minHeight);
1431
- const minWidth = getPixelValue(this._overlayRef.getConfig().minWidth);
1432
- const verticalFit = fit.fitsInViewportVertically || (minHeight != null && minHeight <= availableHeight);
1433
- const horizontalFit = fit.fitsInViewportHorizontally || (minWidth != null && minWidth <= availableWidth);
1434
- return verticalFit && horizontalFit;
1435
- }
1436
- return false;
1437
- }
1438
- /**
1439
- * Gets the point at which the overlay can be "pushed" on-screen. If the overlay is larger than
1440
- * the viewport, the top-left corner will be pushed on-screen (with overflow occurring on the
1441
- * right and bottom).
1442
- *
1443
- * @param start Starting point from which the overlay is pushed.
1444
- * @param rawOverlayRect Dimensions of the overlay.
1445
- * @param scrollPosition Current viewport scroll position.
1446
- * @returns The point at which to position the overlay after pushing. This is effectively a new
1447
- * originPoint.
1448
- */
1449
- _pushOverlayOnScreen(start, rawOverlayRect, scrollPosition) {
1450
- // If the position is locked and we've pushed the overlay already, reuse the previous push
1451
- // amount, rather than pushing it again. If we were to continue pushing, the element would
1452
- // remain in the viewport, which goes against the expectations when position locking is enabled.
1453
- if (this._previousPushAmount && this._positionLocked) {
1454
- return {
1455
- x: start.x + this._previousPushAmount.x,
1456
- y: start.y + this._previousPushAmount.y,
1457
- };
1458
- }
1459
- // Round the overlay rect when comparing against the
1460
- // viewport, because the viewport is always rounded.
1461
- const overlay = getRoundedBoundingClientRect(rawOverlayRect);
1462
- const viewport = this._viewportRect;
1463
- // Determine how much the overlay goes outside the viewport on each
1464
- // side, which we'll use to decide which direction to push it.
1465
- const overflowRight = Math.max(start.x + overlay.width - viewport.width, 0);
1466
- const overflowBottom = Math.max(start.y + overlay.height - viewport.height, 0);
1467
- const overflowTop = Math.max(viewport.top - scrollPosition.top - start.y, 0);
1468
- const overflowLeft = Math.max(viewport.left - scrollPosition.left - start.x, 0);
1469
- // Amount by which to push the overlay in each axis such that it remains on-screen.
1470
- let pushX = 0;
1471
- let pushY = 0;
1472
- // If the overlay fits completely within the bounds of the viewport, push it from whichever
1473
- // direction is goes off-screen. Otherwise, push the top-left corner such that its in the
1474
- // viewport and allow for the trailing end of the overlay to go out of bounds.
1475
- if (overlay.width <= viewport.width) {
1476
- pushX = overflowLeft || -overflowRight;
1477
- }
1478
- else {
1479
- pushX = start.x < this._viewportMargin ? viewport.left - scrollPosition.left - start.x : 0;
1480
- }
1481
- if (overlay.height <= viewport.height) {
1482
- pushY = overflowTop || -overflowBottom;
1483
- }
1484
- else {
1485
- pushY = start.y < this._viewportMargin ? viewport.top - scrollPosition.top - start.y : 0;
1486
- }
1487
- this._previousPushAmount = { x: pushX, y: pushY };
1488
- return {
1489
- x: start.x + pushX,
1490
- y: start.y + pushY,
1491
- };
1492
- }
1493
- /**
1494
- * Applies a computed position to the overlay and emits a position change.
1495
- * @param position The position preference
1496
- * @param originPoint The point on the origin element where the overlay is connected.
1497
- */
1498
- _applyPosition(position, originPoint) {
1499
- this._setTransformOrigin(position);
1500
- this._setOverlayElementStyles(originPoint, position);
1501
- this._setBoundingBoxStyles(originPoint, position);
1502
- if (position.panelClass) {
1503
- this._addPanelClasses(position.panelClass);
1504
- }
1505
- // Save the last connected position in case the position needs to be re-calculated.
1506
- this._lastPosition = position;
1507
- // Notify that the position has been changed along with its change properties.
1508
- // We only emit if we've got any subscriptions, because the scroll visibility
1509
- // calculations can be somewhat expensive.
1510
- if (this._positionChanges.observers.length) {
1511
- const scrollableViewProperties = this._getScrollVisibility();
1512
- const changeEvent = new ConnectedOverlayPositionChange(position, scrollableViewProperties);
1513
- this._positionChanges.next(changeEvent);
1514
- }
1515
- this._isInitialRender = false;
1516
- }
1517
- /** Sets the transform origin based on the configured selector and the passed-in position. */
1518
- _setTransformOrigin(position) {
1519
- if (!this._transformOriginSelector) {
1520
- return;
1521
- }
1522
- const elements = this._boundingBox.querySelectorAll(this._transformOriginSelector);
1523
- let xOrigin;
1524
- let yOrigin = position.overlayY;
1525
- if (position.overlayX === 'center') {
1526
- xOrigin = 'center';
1527
- }
1528
- else if (this._isRtl()) {
1529
- xOrigin = position.overlayX === 'start' ? 'right' : 'left';
1530
- }
1531
- else {
1532
- xOrigin = position.overlayX === 'start' ? 'left' : 'right';
1533
- }
1534
- for (let i = 0; i < elements.length; i++) {
1535
- elements[i].style.transformOrigin = `${xOrigin} ${yOrigin}`;
1536
- }
1537
- }
1538
- /**
1539
- * Gets the position and size of the overlay's sizing container.
1540
- *
1541
- * This method does no measuring and applies no styles so that we can cheaply compute the
1542
- * bounds for all positions and choose the best fit based on these results.
1543
- */
1544
- _calculateBoundingBoxRect(origin, position) {
1545
- const viewport = this._viewportRect;
1546
- const isRtl = this._isRtl();
1547
- let height, top, bottom;
1548
- if (position.overlayY === 'top') {
1549
- // Overlay is opening "downward" and thus is bound by the bottom viewport edge.
1550
- top = origin.y;
1551
- height = viewport.height - top + this._viewportMargin;
1552
- }
1553
- else if (position.overlayY === 'bottom') {
1554
- // Overlay is opening "upward" and thus is bound by the top viewport edge. We need to add
1555
- // the viewport margin back in, because the viewport rect is narrowed down to remove the
1556
- // margin, whereas the `origin` position is calculated based on its `ClientRect`.
1557
- bottom = viewport.height - origin.y + this._viewportMargin * 2;
1558
- height = viewport.height - bottom + this._viewportMargin;
1559
- }
1560
- else {
1561
- // If neither top nor bottom, it means that the overlay is vertically centered on the
1562
- // origin point. Note that we want the position relative to the viewport, rather than
1563
- // the page, which is why we don't use something like `viewport.bottom - origin.y` and
1564
- // `origin.y - viewport.top`.
1565
- const smallestDistanceToViewportEdge = Math.min(viewport.bottom - origin.y + viewport.top, origin.y);
1566
- const previousHeight = this._lastBoundingBoxSize.height;
1567
- height = smallestDistanceToViewportEdge * 2;
1568
- top = origin.y - smallestDistanceToViewportEdge;
1569
- if (height > previousHeight && !this._isInitialRender && !this._growAfterOpen) {
1570
- top = origin.y - previousHeight / 2;
1571
- }
1572
- }
1573
- // The overlay is opening 'right-ward' (the content flows to the right).
1574
- const isBoundedByRightViewportEdge = (position.overlayX === 'start' && !isRtl) || (position.overlayX === 'end' && isRtl);
1575
- // The overlay is opening 'left-ward' (the content flows to the left).
1576
- const isBoundedByLeftViewportEdge = (position.overlayX === 'end' && !isRtl) || (position.overlayX === 'start' && isRtl);
1577
- let width, left, right;
1578
- if (isBoundedByLeftViewportEdge) {
1579
- right = viewport.width - origin.x + this._viewportMargin;
1580
- width = origin.x - this._viewportMargin;
1581
- }
1582
- else if (isBoundedByRightViewportEdge) {
1583
- left = origin.x;
1584
- width = viewport.right - origin.x;
1585
- }
1586
- else {
1587
- // If neither start nor end, it means that the overlay is horizontally centered on the
1588
- // origin point. Note that we want the position relative to the viewport, rather than
1589
- // the page, which is why we don't use something like `viewport.right - origin.x` and
1590
- // `origin.x - viewport.left`.
1591
- const smallestDistanceToViewportEdge = Math.min(viewport.right - origin.x + viewport.left, origin.x);
1592
- const previousWidth = this._lastBoundingBoxSize.width;
1593
- width = smallestDistanceToViewportEdge * 2;
1594
- left = origin.x - smallestDistanceToViewportEdge;
1595
- if (width > previousWidth && !this._isInitialRender && !this._growAfterOpen) {
1596
- left = origin.x - previousWidth / 2;
1597
- }
1598
- }
1599
- return { top: top, left: left, bottom: bottom, right: right, width, height };
1600
- }
1601
- /**
1602
- * Sets the position and size of the overlay's sizing wrapper. The wrapper is positioned on the
1603
- * origin's connection point and stretches to the bounds of the viewport.
1604
- *
1605
- * @param origin The point on the origin element where the overlay is connected.
1606
- * @param position The position preference
1607
- */
1608
- _setBoundingBoxStyles(origin, position) {
1609
- const boundingBoxRect = this._calculateBoundingBoxRect(origin, position);
1610
- // It's weird if the overlay *grows* while scrolling, so we take the last size into account
1611
- // when applying a new size.
1612
- if (!this._isInitialRender && !this._growAfterOpen) {
1613
- boundingBoxRect.height = Math.min(boundingBoxRect.height, this._lastBoundingBoxSize.height);
1614
- boundingBoxRect.width = Math.min(boundingBoxRect.width, this._lastBoundingBoxSize.width);
1615
- }
1616
- const styles = {};
1617
- if (this._hasExactPosition()) {
1618
- styles.top = styles.left = '0';
1619
- styles.bottom = styles.right = styles.maxHeight = styles.maxWidth = '';
1620
- styles.width = styles.height = '100%';
1621
- }
1622
- else {
1623
- const maxHeight = this._overlayRef.getConfig().maxHeight;
1624
- const maxWidth = this._overlayRef.getConfig().maxWidth;
1625
- styles.height = coerceCssPixelValue(boundingBoxRect.height);
1626
- styles.top = coerceCssPixelValue(boundingBoxRect.top);
1627
- styles.bottom = coerceCssPixelValue(boundingBoxRect.bottom);
1628
- styles.width = coerceCssPixelValue(boundingBoxRect.width);
1629
- styles.left = coerceCssPixelValue(boundingBoxRect.left);
1630
- styles.right = coerceCssPixelValue(boundingBoxRect.right);
1631
- // Push the pane content towards the proper direction.
1632
- if (position.overlayX === 'center') {
1633
- styles.alignItems = 'center';
1634
- }
1635
- else {
1636
- styles.alignItems = position.overlayX === 'end' ? 'flex-end' : 'flex-start';
1637
- }
1638
- if (position.overlayY === 'center') {
1639
- styles.justifyContent = 'center';
1640
- }
1641
- else {
1642
- styles.justifyContent = position.overlayY === 'bottom' ? 'flex-end' : 'flex-start';
1643
- }
1644
- if (maxHeight) {
1645
- styles.maxHeight = coerceCssPixelValue(maxHeight);
1646
- }
1647
- if (maxWidth) {
1648
- styles.maxWidth = coerceCssPixelValue(maxWidth);
1649
- }
1650
- }
1651
- this._lastBoundingBoxSize = boundingBoxRect;
1652
- extendStyles(this._boundingBox.style, styles);
1653
- }
1654
- /** Resets the styles for the bounding box so that a new positioning can be computed. */
1655
- _resetBoundingBoxStyles() {
1656
- extendStyles(this._boundingBox.style, {
1657
- top: '0',
1658
- left: '0',
1659
- right: '0',
1660
- bottom: '0',
1661
- height: '',
1662
- width: '',
1663
- alignItems: '',
1664
- justifyContent: '',
1665
- });
1666
- }
1667
- /** Resets the styles for the overlay pane so that a new positioning can be computed. */
1668
- _resetOverlayElementStyles() {
1669
- extendStyles(this._pane.style, {
1670
- top: '',
1671
- left: '',
1672
- bottom: '',
1673
- right: '',
1674
- position: '',
1675
- transform: '',
1676
- });
1677
- }
1678
- /** Sets positioning styles to the overlay element. */
1679
- _setOverlayElementStyles(originPoint, position) {
1680
- const styles = {};
1681
- const hasExactPosition = this._hasExactPosition();
1682
- const hasFlexibleDimensions = this._hasFlexibleDimensions;
1683
- const config = this._overlayRef.getConfig();
1684
- if (hasExactPosition) {
1685
- const scrollPosition = this._viewportRuler.getViewportScrollPosition();
1686
- extendStyles(styles, this._getExactOverlayY(position, originPoint, scrollPosition));
1687
- extendStyles(styles, this._getExactOverlayX(position, originPoint, scrollPosition));
1688
- }
1689
- else {
1690
- styles.position = 'static';
1691
- }
1692
- // Use a transform to apply the offsets. We do this because the `center` positions rely on
1693
- // being in the normal flex flow and setting a `top` / `left` at all will completely throw
1694
- // off the position. We also can't use margins, because they won't have an effect in some
1695
- // cases where the element doesn't have anything to "push off of". Finally, this works
1696
- // better both with flexible and non-flexible positioning.
1697
- let transformString = '';
1698
- let offsetX = this._getOffset(position, 'x');
1699
- let offsetY = this._getOffset(position, 'y');
1700
- if (offsetX) {
1701
- transformString += `translateX(${offsetX}px) `;
1702
- }
1703
- if (offsetY) {
1704
- transformString += `translateY(${offsetY}px)`;
1705
- }
1706
- styles.transform = transformString.trim();
1707
- // If a maxWidth or maxHeight is specified on the overlay, we remove them. We do this because
1708
- // we need these values to both be set to "100%" for the automatic flexible sizing to work.
1709
- // The maxHeight and maxWidth are set on the boundingBox in order to enforce the constraint.
1710
- // Note that this doesn't apply when we have an exact position, in which case we do want to
1711
- // apply them because they'll be cleared from the bounding box.
1712
- if (config.maxHeight) {
1713
- if (hasExactPosition) {
1714
- styles.maxHeight = coerceCssPixelValue(config.maxHeight);
1715
- }
1716
- else if (hasFlexibleDimensions) {
1717
- styles.maxHeight = '';
1718
- }
1719
- }
1720
- if (config.maxWidth) {
1721
- if (hasExactPosition) {
1722
- styles.maxWidth = coerceCssPixelValue(config.maxWidth);
1723
- }
1724
- else if (hasFlexibleDimensions) {
1725
- styles.maxWidth = '';
1726
- }
1727
- }
1728
- extendStyles(this._pane.style, styles);
1729
- }
1730
- /** Gets the exact top/bottom for the overlay when not using flexible sizing or when pushing. */
1731
- _getExactOverlayY(position, originPoint, scrollPosition) {
1732
- // Reset any existing styles. This is necessary in case the
1733
- // preferred position has changed since the last `apply`.
1734
- let styles = { top: '', bottom: '' };
1735
- let overlayPoint = this._getOverlayPoint(originPoint, this._overlayRect, position);
1736
- if (this._isPushed) {
1737
- overlayPoint = this._pushOverlayOnScreen(overlayPoint, this._overlayRect, scrollPosition);
1738
- }
1739
- // We want to set either `top` or `bottom` based on whether the overlay wants to appear
1740
- // above or below the origin and the direction in which the element will expand.
1741
- if (position.overlayY === 'bottom') {
1742
- // When using `bottom`, we adjust the y position such that it is the distance
1743
- // from the bottom of the viewport rather than the top.
1744
- const documentHeight = this._document.documentElement.clientHeight;
1745
- styles.bottom = `${documentHeight - (overlayPoint.y + this._overlayRect.height)}px`;
1746
- }
1747
- else {
1748
- styles.top = coerceCssPixelValue(overlayPoint.y);
1749
- }
1750
- return styles;
1751
- }
1752
- /** Gets the exact left/right for the overlay when not using flexible sizing or when pushing. */
1753
- _getExactOverlayX(position, originPoint, scrollPosition) {
1754
- // Reset any existing styles. This is necessary in case the preferred position has
1755
- // changed since the last `apply`.
1756
- let styles = { left: '', right: '' };
1757
- let overlayPoint = this._getOverlayPoint(originPoint, this._overlayRect, position);
1758
- if (this._isPushed) {
1759
- overlayPoint = this._pushOverlayOnScreen(overlayPoint, this._overlayRect, scrollPosition);
1760
- }
1761
- // We want to set either `left` or `right` based on whether the overlay wants to appear "before"
1762
- // or "after" the origin, which determines the direction in which the element will expand.
1763
- // For the horizontal axis, the meaning of "before" and "after" change based on whether the
1764
- // page is in RTL or LTR.
1765
- let horizontalStyleProperty;
1766
- if (this._isRtl()) {
1767
- horizontalStyleProperty = position.overlayX === 'end' ? 'left' : 'right';
1768
- }
1769
- else {
1770
- horizontalStyleProperty = position.overlayX === 'end' ? 'right' : 'left';
1771
- }
1772
- // When we're setting `right`, we adjust the x position such that it is the distance
1773
- // from the right edge of the viewport rather than the left edge.
1774
- if (horizontalStyleProperty === 'right') {
1775
- const documentWidth = this._document.documentElement.clientWidth;
1776
- styles.right = `${documentWidth - (overlayPoint.x + this._overlayRect.width)}px`;
1777
- }
1778
- else {
1779
- styles.left = coerceCssPixelValue(overlayPoint.x);
1780
- }
1781
- return styles;
1782
- }
1783
- /**
1784
- * Gets the view properties of the trigger and overlay, including whether they are clipped
1785
- * or completely outside the view of any of the strategy's scrollables.
1786
- */
1787
- _getScrollVisibility() {
1788
- // Note: needs fresh rects since the position could've changed.
1789
- const originBounds = this._getOriginRect();
1790
- const overlayBounds = this._pane.getBoundingClientRect();
1791
- // TODO(jelbourn): instead of needing all of the client rects for these scrolling containers
1792
- // every time, we should be able to use the scrollTop of the containers if the size of those
1793
- // containers hasn't changed.
1794
- const scrollContainerBounds = this._scrollables.map(scrollable => {
1795
- return scrollable.getElementRef().nativeElement.getBoundingClientRect();
1796
- });
1797
- return {
1798
- isOriginClipped: isElementClippedByScrolling(originBounds, scrollContainerBounds),
1799
- isOriginOutsideView: isElementScrolledOutsideView(originBounds, scrollContainerBounds),
1800
- isOverlayClipped: isElementClippedByScrolling(overlayBounds, scrollContainerBounds),
1801
- isOverlayOutsideView: isElementScrolledOutsideView(overlayBounds, scrollContainerBounds),
1802
- };
1803
- }
1804
- /** Subtracts the amount that an element is overflowing on an axis from its length. */
1805
- _subtractOverflows(length, ...overflows) {
1806
- return overflows.reduce((currentValue, currentOverflow) => {
1807
- return currentValue - Math.max(currentOverflow, 0);
1808
- }, length);
1809
- }
1810
- /** Narrows the given viewport rect by the current _viewportMargin. */
1811
- _getNarrowedViewportRect() {
1812
- // We recalculate the viewport rect here ourselves, rather than using the ViewportRuler,
1813
- // because we want to use the `clientWidth` and `clientHeight` as the base. The difference
1814
- // being that the client properties don't include the scrollbar, as opposed to `innerWidth`
1815
- // and `innerHeight` that do. This is necessary, because the overlay container uses
1816
- // 100% `width` and `height` which don't include the scrollbar either.
1817
- const width = this._document.documentElement.clientWidth;
1818
- const height = this._document.documentElement.clientHeight;
1819
- const scrollPosition = this._viewportRuler.getViewportScrollPosition();
1820
- return {
1821
- top: scrollPosition.top + this._viewportMargin,
1822
- left: scrollPosition.left + this._viewportMargin,
1823
- right: scrollPosition.left + width - this._viewportMargin,
1824
- bottom: scrollPosition.top + height - this._viewportMargin,
1825
- width: width - 2 * this._viewportMargin,
1826
- height: height - 2 * this._viewportMargin,
1827
- };
1828
- }
1829
- /** Whether the we're dealing with an RTL context */
1830
- _isRtl() {
1831
- return this._overlayRef.getDirection() === 'rtl';
1832
- }
1833
- /** Determines whether the overlay uses exact or flexible positioning. */
1834
- _hasExactPosition() {
1835
- return !this._hasFlexibleDimensions || this._isPushed;
1836
- }
1837
- /** Retrieves the offset of a position along the x or y axis. */
1838
- _getOffset(position, axis) {
1839
- if (axis === 'x') {
1840
- // We don't do something like `position['offset' + axis]` in
1841
- // order to avoid breaking minifiers that rename properties.
1842
- return position.offsetX == null ? this._offsetX : position.offsetX;
1843
- }
1844
- return position.offsetY == null ? this._offsetY : position.offsetY;
1845
- }
1846
- /** Validates that the current position match the expected values. */
1847
- _validatePositions() {
1848
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
1849
- if (!this._preferredPositions.length) {
1850
- throw Error('FlexibleConnectedPositionStrategy: At least one position is required.');
1851
- }
1852
- // TODO(crisbeto): remove these once Angular's template type
1853
- // checking is advanced enough to catch these cases.
1854
- this._preferredPositions.forEach(pair => {
1855
- validateHorizontalPosition('originX', pair.originX);
1856
- validateVerticalPosition('originY', pair.originY);
1857
- validateHorizontalPosition('overlayX', pair.overlayX);
1858
- validateVerticalPosition('overlayY', pair.overlayY);
1859
- });
1860
- }
1861
- }
1862
- /** Adds a single CSS class or an array of classes on the overlay panel. */
1863
- _addPanelClasses(cssClasses) {
1864
- if (this._pane) {
1865
- coerceArray(cssClasses).forEach(cssClass => {
1866
- if (cssClass !== '' && this._appliedPanelClasses.indexOf(cssClass) === -1) {
1867
- this._appliedPanelClasses.push(cssClass);
1868
- this._pane.classList.add(cssClass);
1869
- }
1870
- });
1871
- }
1872
- }
1873
- /** Clears the classes that the position strategy has applied from the overlay panel. */
1874
- _clearPanelClasses() {
1875
- if (this._pane) {
1876
- this._appliedPanelClasses.forEach(cssClass => {
1877
- this._pane.classList.remove(cssClass);
1878
- });
1879
- this._appliedPanelClasses = [];
1880
- }
1881
- }
1882
- /** Returns the ClientRect of the current origin. */
1883
- _getOriginRect() {
1884
- const origin = this._origin;
1885
- if (origin instanceof ElementRef) {
1886
- return origin.nativeElement.getBoundingClientRect();
1887
- }
1888
- // Check for Element so SVG elements are also supported.
1889
- if (origin instanceof Element) {
1890
- return origin.getBoundingClientRect();
1891
- }
1892
- const width = origin.width || 0;
1893
- const height = origin.height || 0;
1894
- // If the origin is a point, return a client rect as if it was a 0x0 element at the point.
1895
- return {
1896
- top: origin.y,
1897
- bottom: origin.y + height,
1898
- left: origin.x,
1899
- right: origin.x + width,
1900
- height,
1901
- width,
1902
- };
1903
- }
1904
- }
1905
- /** Shallow-extends a stylesheet object with another stylesheet object. */
1906
- function extendStyles(destination, source) {
1907
- for (let key in source) {
1908
- if (source.hasOwnProperty(key)) {
1909
- destination[key] = source[key];
1910
- }
1911
- }
1912
- return destination;
1913
- }
1914
- /**
1915
- * Extracts the pixel value as a number from a value, if it's a number
1916
- * or a CSS pixel string (e.g. `1337px`). Otherwise returns null.
1917
- */
1918
- function getPixelValue(input) {
1919
- if (typeof input !== 'number' && input != null) {
1920
- const [value, units] = input.split(cssUnitPattern);
1921
- return !units || units === 'px' ? parseFloat(value) : null;
1922
- }
1923
- return input || null;
1924
- }
1925
- /**
1926
- * Gets a version of an element's bounding `ClientRect` where all the values are rounded down to
1927
- * the nearest pixel. This allows us to account for the cases where there may be sub-pixel
1928
- * deviations in the `ClientRect` returned by the browser (e.g. when zoomed in with a percentage
1929
- * size, see #21350).
1930
- */
1931
- function getRoundedBoundingClientRect(clientRect) {
1932
- return {
1933
- top: Math.floor(clientRect.top),
1934
- right: Math.floor(clientRect.right),
1935
- bottom: Math.floor(clientRect.bottom),
1936
- left: Math.floor(clientRect.left),
1937
- width: Math.floor(clientRect.width),
1938
- height: Math.floor(clientRect.height),
1939
- };
1940
- }
1941
- const STANDARD_DROPDOWN_BELOW_POSITIONS = [
1942
- { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top' },
1943
- { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom' },
1944
- { originX: 'end', originY: 'bottom', overlayX: 'end', overlayY: 'top' },
1945
- { originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom' },
1946
- ];
1947
- const STANDARD_DROPDOWN_ADJACENT_POSITIONS = [
1948
- { originX: 'end', originY: 'top', overlayX: 'start', overlayY: 'top' },
1949
- { originX: 'end', originY: 'bottom', overlayX: 'start', overlayY: 'bottom' },
1950
- { originX: 'start', originY: 'top', overlayX: 'end', overlayY: 'top' },
1951
- { originX: 'start', originY: 'bottom', overlayX: 'end', overlayY: 'bottom' },
1952
- ];
1953
-
1954
- /**
1955
- * @license
1956
- * Copyright Google LLC All Rights Reserved.
1957
- *
1958
- * Use of this source code is governed by an MIT-style license that can be
1959
- * found in the LICENSE file at https://angular.io/license
1960
- */
1961
- /** Class to be added to the overlay pane wrapper. */
1962
- const wrapperClass = 'cdk-global-overlay-wrapper';
1963
- /**
1964
- * A strategy for positioning overlays. Using this strategy, an overlay is given an
1965
- * explicit position relative to the browser's viewport. We use flexbox, instead of
1966
- * transforms, in order to avoid issues with subpixel rendering which can cause the
1967
- * element to become blurry.
1968
- */
1969
- class GlobalPositionStrategy {
1970
- constructor() {
1971
- this._cssPosition = 'static';
1972
- this._topOffset = '';
1973
- this._bottomOffset = '';
1974
- this._alignItems = '';
1975
- this._xPosition = '';
1976
- this._xOffset = '';
1977
- this._width = '';
1978
- this._height = '';
1979
- this._isDisposed = false;
1980
- }
1981
- attach(overlayRef) {
1982
- const config = overlayRef.getConfig();
1983
- this._overlayRef = overlayRef;
1984
- if (this._width && !config.width) {
1985
- overlayRef.updateSize({ width: this._width });
1986
- }
1987
- if (this._height && !config.height) {
1988
- overlayRef.updateSize({ height: this._height });
1989
- }
1990
- overlayRef.hostElement.classList.add(wrapperClass);
1991
- this._isDisposed = false;
1992
- }
1993
- /**
1994
- * Sets the top position of the overlay. Clears any previously set vertical position.
1995
- * @param value New top offset.
1996
- */
1997
- top(value = '') {
1998
- this._bottomOffset = '';
1999
- this._topOffset = value;
2000
- this._alignItems = 'flex-start';
2001
- return this;
2002
- }
2003
- /**
2004
- * Sets the left position of the overlay. Clears any previously set horizontal position.
2005
- * @param value New left offset.
2006
- */
2007
- left(value = '') {
2008
- this._xOffset = value;
2009
- this._xPosition = 'left';
2010
- return this;
2011
- }
2012
- /**
2013
- * Sets the bottom position of the overlay. Clears any previously set vertical position.
2014
- * @param value New bottom offset.
2015
- */
2016
- bottom(value = '') {
2017
- this._topOffset = '';
2018
- this._bottomOffset = value;
2019
- this._alignItems = 'flex-end';
2020
- return this;
2021
- }
2022
- /**
2023
- * Sets the right position of the overlay. Clears any previously set horizontal position.
2024
- * @param value New right offset.
2025
- */
2026
- right(value = '') {
2027
- this._xOffset = value;
2028
- this._xPosition = 'right';
2029
- return this;
2030
- }
2031
- /**
2032
- * Sets the overlay to the start of the viewport, depending on the overlay direction.
2033
- * This will be to the left in LTR layouts and to the right in RTL.
2034
- * @param offset Offset from the edge of the screen.
2035
- */
2036
- start(value = '') {
2037
- this._xOffset = value;
2038
- this._xPosition = 'start';
2039
- return this;
2040
- }
2041
- /**
2042
- * Sets the overlay to the end of the viewport, depending on the overlay direction.
2043
- * This will be to the right in LTR layouts and to the left in RTL.
2044
- * @param offset Offset from the edge of the screen.
2045
- */
2046
- end(value = '') {
2047
- this._xOffset = value;
2048
- this._xPosition = 'end';
2049
- return this;
2050
- }
2051
- /**
2052
- * Sets the overlay width and clears any previously set width.
2053
- * @param value New width for the overlay
2054
- * @deprecated Pass the `width` through the `OverlayConfig`.
2055
- * @breaking-change 8.0.0
2056
- */
2057
- width(value = '') {
2058
- if (this._overlayRef) {
2059
- this._overlayRef.updateSize({ width: value });
2060
- }
2061
- else {
2062
- this._width = value;
2063
- }
2064
- return this;
2065
- }
2066
- /**
2067
- * Sets the overlay height and clears any previously set height.
2068
- * @param value New height for the overlay
2069
- * @deprecated Pass the `height` through the `OverlayConfig`.
2070
- * @breaking-change 8.0.0
2071
- */
2072
- height(value = '') {
2073
- if (this._overlayRef) {
2074
- this._overlayRef.updateSize({ height: value });
2075
- }
2076
- else {
2077
- this._height = value;
2078
- }
2079
- return this;
2080
- }
2081
- /**
2082
- * Centers the overlay horizontally with an optional offset.
2083
- * Clears any previously set horizontal position.
2084
- *
2085
- * @param offset Overlay offset from the horizontal center.
2086
- */
2087
- centerHorizontally(offset = '') {
2088
- this.left(offset);
2089
- this._xPosition = 'center';
2090
- return this;
2091
- }
2092
- /**
2093
- * Centers the overlay vertically with an optional offset.
2094
- * Clears any previously set vertical position.
2095
- *
2096
- * @param offset Overlay offset from the vertical center.
2097
- */
2098
- centerVertically(offset = '') {
2099
- this.top(offset);
2100
- this._alignItems = 'center';
2101
- return this;
2102
- }
2103
- /**
2104
- * Apply the position to the element.
2105
- * @docs-private
2106
- */
2107
- apply() {
2108
- // Since the overlay ref applies the strategy asynchronously, it could
2109
- // have been disposed before it ends up being applied. If that is the
2110
- // case, we shouldn't do anything.
2111
- if (!this._overlayRef || !this._overlayRef.hasAttached()) {
2112
- return;
2113
- }
2114
- const styles = this._overlayRef.overlayElement.style;
2115
- const parentStyles = this._overlayRef.hostElement.style;
2116
- const config = this._overlayRef.getConfig();
2117
- const { width, height, maxWidth, maxHeight } = config;
2118
- const shouldBeFlushHorizontally = (width === '100%' || width === '100vw') &&
2119
- (!maxWidth || maxWidth === '100%' || maxWidth === '100vw');
2120
- const shouldBeFlushVertically = (height === '100%' || height === '100vh') &&
2121
- (!maxHeight || maxHeight === '100%' || maxHeight === '100vh');
2122
- const xPosition = this._xPosition;
2123
- const xOffset = this._xOffset;
2124
- const isRtl = this._overlayRef.getConfig().direction === 'rtl';
2125
- let marginLeft = '';
2126
- let marginRight = '';
2127
- let justifyContent = '';
2128
- if (shouldBeFlushHorizontally) {
2129
- justifyContent = 'flex-start';
2130
- }
2131
- else if (xPosition === 'center') {
2132
- justifyContent = 'center';
2133
- if (isRtl) {
2134
- marginRight = xOffset;
2135
- }
2136
- else {
2137
- marginLeft = xOffset;
2138
- }
2139
- }
2140
- else if (isRtl) {
2141
- if (xPosition === 'left' || xPosition === 'end') {
2142
- justifyContent = 'flex-end';
2143
- marginLeft = xOffset;
2144
- }
2145
- else if (xPosition === 'right' || xPosition === 'start') {
2146
- justifyContent = 'flex-start';
2147
- marginRight = xOffset;
2148
- }
2149
- }
2150
- else if (xPosition === 'left' || xPosition === 'start') {
2151
- justifyContent = 'flex-start';
2152
- marginLeft = xOffset;
2153
- }
2154
- else if (xPosition === 'right' || xPosition === 'end') {
2155
- justifyContent = 'flex-end';
2156
- marginRight = xOffset;
2157
- }
2158
- styles.position = this._cssPosition;
2159
- styles.marginLeft = shouldBeFlushHorizontally ? '0' : marginLeft;
2160
- styles.marginTop = shouldBeFlushVertically ? '0' : this._topOffset;
2161
- styles.marginBottom = this._bottomOffset;
2162
- styles.marginRight = shouldBeFlushHorizontally ? '0' : marginRight;
2163
- parentStyles.justifyContent = justifyContent;
2164
- parentStyles.alignItems = shouldBeFlushVertically ? 'flex-start' : this._alignItems;
2165
- }
2166
- /**
2167
- * Cleans up the DOM changes from the position strategy.
2168
- * @docs-private
2169
- */
2170
- dispose() {
2171
- if (this._isDisposed || !this._overlayRef) {
2172
- return;
2173
- }
2174
- const styles = this._overlayRef.overlayElement.style;
2175
- const parent = this._overlayRef.hostElement;
2176
- const parentStyles = parent.style;
2177
- parent.classList.remove(wrapperClass);
2178
- parentStyles.justifyContent =
2179
- parentStyles.alignItems =
2180
- styles.marginTop =
2181
- styles.marginBottom =
2182
- styles.marginLeft =
2183
- styles.marginRight =
2184
- styles.position =
2185
- '';
2186
- this._overlayRef = null;
2187
- this._isDisposed = true;
2188
- }
2189
- }
2190
-
2191
- /** Builder for overlay position strategy. */
2192
- class OverlayPositionBuilder {
2193
- constructor(_viewportRuler, _document, _platform, _overlayContainer) {
2194
- this._viewportRuler = _viewportRuler;
2195
- this._document = _document;
2196
- this._platform = _platform;
2197
- this._overlayContainer = _overlayContainer;
2198
- }
2199
- /**
2200
- * Creates a global position strategy.
2201
- */
2202
- global() {
2203
- return new GlobalPositionStrategy();
2204
- }
2205
- /**
2206
- * Creates a flexible position strategy.
2207
- * @param origin Origin relative to which to position the overlay.
2208
- */
2209
- flexibleConnectedTo(origin) {
2210
- return new FlexibleConnectedPositionStrategy(origin, this._viewportRuler, this._document, this._platform, this._overlayContainer);
2211
- }
2212
- }
2213
- OverlayPositionBuilder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayPositionBuilder, deps: [{ token: i1.ViewportRuler }, { token: DOCUMENT }, { token: i1$1.Platform }, { token: OverlayContainer }], target: i0.ɵɵFactoryTarget.Injectable });
2214
- OverlayPositionBuilder.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayPositionBuilder, providedIn: 'root' });
2215
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayPositionBuilder, decorators: [{
2216
- type: Injectable,
2217
- args: [{ providedIn: 'root' }]
2218
- }], ctorParameters: function () {
2219
- return [{ type: i1.ViewportRuler }, { type: undefined, decorators: [{
2220
- type: Inject,
2221
- args: [DOCUMENT]
2222
- }] }, { type: i1$1.Platform }, { type: OverlayContainer }];
2223
- } });
2224
-
2225
- /**
2226
- * @license
2227
- * Copyright Google LLC All Rights Reserved.
2228
- *
2229
- * Use of this source code is governed by an MIT-style license that can be
2230
- * found in the LICENSE file at https://angular.io/license
2231
- */
2232
- /**
2233
- * Service for dispatching events that land on the body to appropriate overlay ref,
2234
- * if any. It maintains a list of attached overlays to determine best suited overlay based
2235
- * on event target and order of overlay opens.
2236
- */
2237
- class BaseOverlayDispatcher {
2238
- constructor(document) {
2239
- /** Currently attached overlays in the order they were attached. */
2240
- this._attachedOverlays = [];
2241
- this._document = document;
2242
- }
2243
- ngOnDestroy() {
2244
- this.detach();
2245
- }
2246
- /** Add a new overlay to the list of attached overlay refs. */
2247
- add(overlayRef) {
2248
- // Ensure that we don't get the same overlay multiple times.
2249
- this.remove(overlayRef);
2250
- this._attachedOverlays.push(overlayRef);
2251
- }
2252
- /** Remove an overlay from the list of attached overlay refs. */
2253
- remove(overlayRef) {
2254
- const index = this._attachedOverlays.indexOf(overlayRef);
2255
- if (index > -1) {
2256
- this._attachedOverlays.splice(index, 1);
2257
- }
2258
- // Remove the global listener once there are no more overlays.
2259
- if (this._attachedOverlays.length === 0) {
2260
- this.detach();
2261
- }
2262
- }
2263
- }
2264
- BaseOverlayDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: BaseOverlayDispatcher, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
2265
- BaseOverlayDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: BaseOverlayDispatcher, providedIn: 'root' });
2266
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: BaseOverlayDispatcher, decorators: [{
2267
- type: Injectable,
2268
- args: [{ providedIn: 'root' }]
2269
- }], ctorParameters: function () {
2270
- return [{ type: undefined, decorators: [{
2271
- type: Inject,
2272
- args: [DOCUMENT]
2273
- }] }];
2274
- } });
2275
-
2276
- /**
2277
- * @license
2278
- * Copyright Google LLC All Rights Reserved.
2279
- *
2280
- * Use of this source code is governed by an MIT-style license that can be
2281
- * found in the LICENSE file at https://angular.io/license
2282
- */
2283
- /**
2284
- * Service for dispatching keyboard events that land on the body to appropriate overlay ref,
2285
- * if any. It maintains a list of attached overlays to determine best suited overlay based
2286
- * on event target and order of overlay opens.
2287
- */
2288
- class OverlayKeyboardDispatcher extends BaseOverlayDispatcher {
2289
- constructor(document,
2290
- /** @breaking-change 14.0.0 _ngZone will be required. */
2291
- _ngZone) {
2292
- super(document);
2293
- this._ngZone = _ngZone;
2294
- /** Keyboard event listener that will be attached to the body. */
2295
- this._keydownListener = (event) => {
2296
- const overlays = this._attachedOverlays;
2297
- for (let i = overlays.length - 1; i > -1; i--) {
2298
- // Dispatch the keydown event to the top overlay which has subscribers to its keydown events.
2299
- // We want to target the most recent overlay, rather than trying to match where the event came
2300
- // from, because some components might open an overlay, but keep focus on a trigger element
2301
- // (e.g. for select and autocomplete). We skip overlays without keydown event subscriptions,
2302
- // because we don't want overlays that don't handle keyboard events to block the ones below
2303
- // them that do.
2304
- if (overlays[i]._keydownEvents.observers.length > 0) {
2305
- const keydownEvents = overlays[i]._keydownEvents;
2306
- /** @breaking-change 14.0.0 _ngZone will be required. */
2307
- if (this._ngZone) {
2308
- this._ngZone.run(() => keydownEvents.next(event));
2309
- }
2310
- else {
2311
- keydownEvents.next(event);
2312
- }
2313
- break;
2314
- }
2315
- }
2316
- };
2317
- }
2318
- /** Add a new overlay to the list of attached overlay refs. */
2319
- add(overlayRef) {
2320
- super.add(overlayRef);
2321
- // Lazily start dispatcher once first overlay is added
2322
- if (!this._isAttached) {
2323
- /** @breaking-change 14.0.0 _ngZone will be required. */
2324
- if (this._ngZone) {
2325
- this._ngZone.runOutsideAngular(() => this._document.body.addEventListener('keydown', this._keydownListener));
2326
- }
2327
- else {
2328
- this._document.body.addEventListener('keydown', this._keydownListener);
2329
- }
2330
- this._isAttached = true;
2331
- }
2332
- }
2333
- /** Detaches the global keyboard event listener. */
2334
- detach() {
2335
- if (this._isAttached) {
2336
- this._document.body.removeEventListener('keydown', this._keydownListener);
2337
- this._isAttached = false;
2338
- }
2339
- }
2340
- }
2341
- OverlayKeyboardDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayKeyboardDispatcher, deps: [{ token: DOCUMENT }, { token: i0.NgZone, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2342
- OverlayKeyboardDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayKeyboardDispatcher, providedIn: 'root' });
2343
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayKeyboardDispatcher, decorators: [{
2344
- type: Injectable,
2345
- args: [{ providedIn: 'root' }]
2346
- }], ctorParameters: function () {
2347
- return [{ type: undefined, decorators: [{
2348
- type: Inject,
2349
- args: [DOCUMENT]
2350
- }] }, { type: i0.NgZone, decorators: [{
2351
- type: Optional
2352
- }] }];
2353
- } });
2354
-
2355
- /**
2356
- * @license
2357
- * Copyright Google LLC All Rights Reserved.
2358
- *
2359
- * Use of this source code is governed by an MIT-style license that can be
2360
- * found in the LICENSE file at https://angular.io/license
2361
- */
2362
- /**
2363
- * Service for dispatching mouse click events that land on the body to appropriate overlay ref,
2364
- * if any. It maintains a list of attached overlays to determine best suited overlay based
2365
- * on event target and order of overlay opens.
2366
- */
2367
- class OverlayOutsideClickDispatcher extends BaseOverlayDispatcher {
2368
- constructor(document, _platform,
2369
- /** @breaking-change 14.0.0 _ngZone will be required. */
2370
- _ngZone) {
2371
- super(document);
2372
- this._platform = _platform;
2373
- this._ngZone = _ngZone;
2374
- this._cursorStyleIsSet = false;
2375
- /** Store pointerdown event target to track origin of click. */
2376
- this._pointerDownListener = (event) => {
2377
- this._pointerDownEventTarget = _getEventTarget(event);
2378
- };
2379
- /** Click event listener that will be attached to the body propagate phase. */
2380
- this._clickListener = (event) => {
2381
- const target = _getEventTarget(event);
2382
- // In case of a click event, we want to check the origin of the click
2383
- // (e.g. in case where a user starts a click inside the overlay and
2384
- // releases the click outside of it).
2385
- // This is done by using the event target of the preceding pointerdown event.
2386
- // Every click event caused by a pointer device has a preceding pointerdown
2387
- // event, unless the click was programmatically triggered (e.g. in a unit test).
2388
- const origin = event.type === 'click' && this._pointerDownEventTarget
2389
- ? this._pointerDownEventTarget
2390
- : target;
2391
- // Reset the stored pointerdown event target, to avoid having it interfere
2392
- // in subsequent events.
2393
- this._pointerDownEventTarget = null;
2394
- // We copy the array because the original may be modified asynchronously if the
2395
- // outsidePointerEvents listener decides to detach overlays resulting in index errors inside
2396
- // the for loop.
2397
- const overlays = this._attachedOverlays.slice();
2398
- // Dispatch the mouse event to the top overlay which has subscribers to its mouse events.
2399
- // We want to target all overlays for which the click could be considered as outside click.
2400
- // As soon as we reach an overlay for which the click is not outside click we break off
2401
- // the loop.
2402
- for (let i = overlays.length - 1; i > -1; i--) {
2403
- const overlayRef = overlays[i];
2404
- if (overlayRef._outsidePointerEvents.observers.length < 1 || !overlayRef.hasAttached()) {
2405
- continue;
2406
- }
2407
- // If it's a click inside the overlay, just break - we should do nothing
2408
- // If it's an outside click (both origin and target of the click) dispatch the mouse event,
2409
- // and proceed with the next overlay
2410
- if (overlayRef.overlayElement.contains(target) ||
2411
- overlayRef.overlayElement.contains(origin)) {
2412
- break;
2413
- }
2414
- const outsidePointerEvents = overlayRef._outsidePointerEvents;
2415
- /** @breaking-change 14.0.0 _ngZone will be required. */
2416
- if (this._ngZone) {
2417
- this._ngZone.run(() => outsidePointerEvents.next(event));
2418
- }
2419
- else {
2420
- outsidePointerEvents.next(event);
2421
- }
2422
- }
2423
- };
2424
- }
2425
- /** Add a new overlay to the list of attached overlay refs. */
2426
- add(overlayRef) {
2427
- super.add(overlayRef);
2428
- // Safari on iOS does not generate click events for non-interactive
2429
- // elements. However, we want to receive a click for any element outside
2430
- // the overlay. We can force a "clickable" state by setting
2431
- // `cursor: pointer` on the document body. See:
2432
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event#Safari_Mobile
2433
- // https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
2434
- if (!this._isAttached) {
2435
- const body = this._document.body;
2436
- /** @breaking-change 14.0.0 _ngZone will be required. */
2437
- if (this._ngZone) {
2438
- this._ngZone.runOutsideAngular(() => this._addEventListeners(body));
2439
- }
2440
- else {
2441
- this._addEventListeners(body);
2442
- }
2443
- // click event is not fired on iOS. To make element "clickable" we are
2444
- // setting the cursor to pointer
2445
- if (this._platform.IOS && !this._cursorStyleIsSet) {
2446
- this._cursorOriginalValue = body.style.cursor;
2447
- body.style.cursor = 'pointer';
2448
- this._cursorStyleIsSet = true;
2449
- }
2450
- this._isAttached = true;
2451
- }
2452
- }
2453
- /** Detaches the global keyboard event listener. */
2454
- detach() {
2455
- if (this._isAttached) {
2456
- const body = this._document.body;
2457
- body.removeEventListener('pointerdown', this._pointerDownListener, true);
2458
- body.removeEventListener('click', this._clickListener, true);
2459
- body.removeEventListener('auxclick', this._clickListener, true);
2460
- body.removeEventListener('contextmenu', this._clickListener, true);
2461
- if (this._platform.IOS && this._cursorStyleIsSet) {
2462
- body.style.cursor = this._cursorOriginalValue;
2463
- this._cursorStyleIsSet = false;
2464
- }
2465
- this._isAttached = false;
2466
- }
2467
- }
2468
- _addEventListeners(body) {
2469
- body.addEventListener('pointerdown', this._pointerDownListener, true);
2470
- body.addEventListener('click', this._clickListener, true);
2471
- body.addEventListener('auxclick', this._clickListener, true);
2472
- body.addEventListener('contextmenu', this._clickListener, true);
2473
- }
2474
- }
2475
- OverlayOutsideClickDispatcher.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayOutsideClickDispatcher, deps: [{ token: DOCUMENT }, { token: i1$1.Platform }, { token: i0.NgZone, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2476
- OverlayOutsideClickDispatcher.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayOutsideClickDispatcher, providedIn: 'root' });
2477
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayOutsideClickDispatcher, decorators: [{
2478
- type: Injectable,
2479
- args: [{ providedIn: 'root' }]
2480
- }], ctorParameters: function () {
2481
- return [{ type: undefined, decorators: [{
2482
- type: Inject,
2483
- args: [DOCUMENT]
2484
- }] }, { type: i1$1.Platform }, { type: i0.NgZone, decorators: [{
2485
- type: Optional
2486
- }] }];
2487
- } });
2488
-
2489
- /** Next overlay unique ID. */
2490
- let nextUniqueId = 0;
2491
- // Note that Overlay is *not* scoped to the app root because of the ComponentFactoryResolver
2492
- // which needs to be different depending on where OverlayModule is imported.
2493
- /**
2494
- * Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be
2495
- * used as a low-level building block for other components. Dialogs, tooltips, menus,
2496
- * selects, etc. can all be built using overlays. The service should primarily be used by authors
2497
- * of re-usable components rather than developers building end-user applications.
2498
- *
2499
- * An overlay *is* a PortalOutlet, so any kind of Portal can be loaded into one.
2500
- */
2501
- class Overlay {
2502
- constructor(
2503
- /** Scrolling strategies that can be used when creating an overlay. */
2504
- scrollStrategies, _overlayContainer, _componentFactoryResolver, _positionBuilder, _keyboardDispatcher, _injector, _ngZone, _document, _directionality, _location, _outsideClickDispatcher, _animationsModuleType) {
2505
- this.scrollStrategies = scrollStrategies;
2506
- this._overlayContainer = _overlayContainer;
2507
- this._componentFactoryResolver = _componentFactoryResolver;
2508
- this._positionBuilder = _positionBuilder;
2509
- this._keyboardDispatcher = _keyboardDispatcher;
2510
- this._injector = _injector;
2511
- this._ngZone = _ngZone;
2512
- this._document = _document;
2513
- this._directionality = _directionality;
2514
- this._location = _location;
2515
- this._outsideClickDispatcher = _outsideClickDispatcher;
2516
- this._animationsModuleType = _animationsModuleType;
2517
- }
2518
- /**
2519
- * Creates an overlay.
2520
- * @param config Configuration applied to the overlay.
2521
- * @returns Reference to the created overlay.
2522
- */
2523
- create(config) {
2524
- const host = this._createHostElement();
2525
- const pane = this._createPaneElement(host);
2526
- const portalOutlet = this._createPortalOutlet(pane);
2527
- const overlayConfig = new OverlayConfig(config);
2528
- overlayConfig.direction = overlayConfig.direction || this._directionality.value;
2529
- return new OverlayRef(portalOutlet, host, pane, overlayConfig, this._ngZone, this._keyboardDispatcher, this._document, this._location, this._outsideClickDispatcher, this._animationsModuleType === 'NoopAnimations');
2530
- }
2531
- /**
2532
- * Gets a position builder that can be used, via fluent API,
2533
- * to construct and configure a position strategy.
2534
- * @returns An overlay position builder.
2535
- */
2536
- position() {
2537
- return this._positionBuilder;
2538
- }
2539
- /**
2540
- * Creates the DOM element for an overlay and appends it to the overlay container.
2541
- * @returns Newly-created pane element
2542
- */
2543
- _createPaneElement(host) {
2544
- const pane = this._document.createElement('div');
2545
- pane.id = `cdk-overlay-${nextUniqueId++}`;
2546
- pane.classList.add('cdk-overlay-pane');
2547
- host.appendChild(pane);
2548
- return pane;
2549
- }
2550
- /**
2551
- * Creates the host element that wraps around an overlay
2552
- * and can be used for advanced positioning.
2553
- * @returns Newly-create host element.
2554
- */
2555
- _createHostElement() {
2556
- const host = this._document.createElement('div');
2557
- this._overlayContainer.getContainerElement().appendChild(host);
2558
- return host;
2559
- }
2560
- /**
2561
- * Create a DomPortalOutlet into which the overlay content can be loaded.
2562
- * @param pane The DOM element to turn into a portal outlet.
2563
- * @returns A portal outlet for the given DOM element.
2564
- */
2565
- _createPortalOutlet(pane) {
2566
- // We have to resolve the ApplicationRef later in order to allow people
2567
- // to use overlay-based providers during app initialization.
2568
- if (!this._appRef) {
2569
- this._appRef = this._injector.get(ApplicationRef);
2570
- }
2571
- return new DomPortalOutlet(pane, this._componentFactoryResolver, this._appRef, this._injector, this._document);
2572
- }
2573
- }
2574
- Overlay.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: Overlay, deps: [{ token: ScrollStrategyOptions }, { token: OverlayContainer }, { token: i0.ComponentFactoryResolver }, { token: OverlayPositionBuilder }, { token: OverlayKeyboardDispatcher }, { token: i0.Injector }, { token: i0.NgZone }, { token: DOCUMENT }, { token: i5.Directionality }, { token: i6.Location }, { token: OverlayOutsideClickDispatcher }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
2575
- Overlay.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: Overlay, providedIn: 'root' });
2576
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: Overlay, decorators: [{
2577
- type: Injectable,
2578
- args: [{ providedIn: 'root' }]
2579
- }], ctorParameters: function () {
2580
- return [{ type: ScrollStrategyOptions }, { type: OverlayContainer }, { type: i0.ComponentFactoryResolver }, { type: OverlayPositionBuilder }, { type: OverlayKeyboardDispatcher }, { type: i0.Injector }, { type: i0.NgZone }, { type: undefined, decorators: [{
2581
- type: Inject,
2582
- args: [DOCUMENT]
2583
- }] }, { type: i5.Directionality }, { type: i6.Location }, { type: OverlayOutsideClickDispatcher }, { type: undefined, decorators: [{
2584
- type: Inject,
2585
- args: [ANIMATION_MODULE_TYPE]
2586
- }, {
2587
- type: Optional
2588
- }] }];
2589
- } });
2590
-
2591
- /** Default set of positions for the overlay. Follows the behavior of a dropdown. */
2592
- const defaultPositionList = [
2593
- {
2594
- originX: 'start',
2595
- originY: 'bottom',
2596
- overlayX: 'start',
2597
- overlayY: 'top',
2598
- },
2599
- {
2600
- originX: 'start',
2601
- originY: 'top',
2602
- overlayX: 'start',
2603
- overlayY: 'bottom',
2604
- },
2605
- {
2606
- originX: 'end',
2607
- originY: 'top',
2608
- overlayX: 'end',
2609
- overlayY: 'bottom',
2610
- },
2611
- {
2612
- originX: 'end',
2613
- originY: 'bottom',
2614
- overlayX: 'end',
2615
- overlayY: 'top',
2616
- },
2617
- ];
2618
- /** Injection token that determines the scroll handling while the connected overlay is open. */
2619
- const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY = new InjectionToken('cdk-connected-overlay-scroll-strategy');
2620
- /**
2621
- * Directive applied to an element to make it usable as an origin for an Overlay using a
2622
- * ConnectedPositionStrategy.
2623
- */
2624
- class CdkOverlayOrigin {
2625
- constructor(
2626
- /** Reference to the element on which the directive is applied. */
2627
- elementRef) {
2628
- this.elementRef = elementRef;
2629
- }
2630
- }
2631
- CdkOverlayOrigin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkOverlayOrigin, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
2632
- CdkOverlayOrigin.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkOverlayOrigin, isStandalone: true, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"], ngImport: i0 });
2633
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkOverlayOrigin, decorators: [{
2634
- type: Directive,
2635
- args: [{
2636
- selector: '[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]',
2637
- exportAs: 'cdkOverlayOrigin',
2638
- standalone: true,
2639
- }]
2640
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; } });
2641
- /**
2642
- * Directive to facilitate declarative creation of an
2643
- * Overlay using a FlexibleConnectedPositionStrategy.
2644
- */
2645
- class CdkConnectedOverlay {
2646
- /** The offset in pixels for the overlay connection point on the x-axis */
2647
- get offsetX() {
2648
- return this._offsetX;
2649
- }
2650
- set offsetX(offsetX) {
2651
- this._offsetX = offsetX;
2652
- if (this._position) {
2653
- this._updatePositionStrategy(this._position);
2654
- }
2655
- }
2656
- /** The offset in pixels for the overlay connection point on the y-axis */
2657
- get offsetY() {
2658
- return this._offsetY;
2659
- }
2660
- set offsetY(offsetY) {
2661
- this._offsetY = offsetY;
2662
- if (this._position) {
2663
- this._updatePositionStrategy(this._position);
2664
- }
2665
- }
2666
- /** Whether or not the overlay should attach a backdrop. */
2667
- get hasBackdrop() {
2668
- return this._hasBackdrop;
2669
- }
2670
- set hasBackdrop(value) {
2671
- this._hasBackdrop = coerceBooleanProperty(value);
2672
- }
2673
- /** Whether or not the overlay should be locked when scrolling. */
2674
- get lockPosition() {
2675
- return this._lockPosition;
2676
- }
2677
- set lockPosition(value) {
2678
- this._lockPosition = coerceBooleanProperty(value);
2679
- }
2680
- /** Whether the overlay's width and height can be constrained to fit within the viewport. */
2681
- get flexibleDimensions() {
2682
- return this._flexibleDimensions;
2683
- }
2684
- set flexibleDimensions(value) {
2685
- this._flexibleDimensions = coerceBooleanProperty(value);
2686
- }
2687
- /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */
2688
- get growAfterOpen() {
2689
- return this._growAfterOpen;
2690
- }
2691
- set growAfterOpen(value) {
2692
- this._growAfterOpen = coerceBooleanProperty(value);
2693
- }
2694
- /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */
2695
- get push() {
2696
- return this._push;
2697
- }
2698
- set push(value) {
2699
- this._push = coerceBooleanProperty(value);
2700
- }
2701
- // TODO(jelbourn): inputs for size, scroll behavior, animation, etc.
2702
- constructor(_overlay, templateRef, viewContainerRef, scrollStrategyFactory, _dir) {
2703
- this._overlay = _overlay;
2704
- this._dir = _dir;
2705
- this._hasBackdrop = false;
2706
- this._lockPosition = false;
2707
- this._growAfterOpen = false;
2708
- this._flexibleDimensions = false;
2709
- this._push = false;
2710
- this._backdropSubscription = Subscription.EMPTY;
2711
- this._attachSubscription = Subscription.EMPTY;
2712
- this._detachSubscription = Subscription.EMPTY;
2713
- this._positionSubscription = Subscription.EMPTY;
2714
- /** Margin between the overlay and the viewport edges. */
2715
- this.viewportMargin = 0;
2716
- /** Whether the overlay is open. */
2717
- this.open = false;
2718
- /** Whether the overlay can be closed by user interaction. */
2719
- this.disableClose = false;
2720
- /** Event emitted when the backdrop is clicked. */
2721
- this.backdropClick = new EventEmitter();
2722
- /** Event emitted when the position has changed. */
2723
- this.positionChange = new EventEmitter();
2724
- /** Event emitted when the overlay has been attached. */
2725
- this.attach = new EventEmitter();
2726
- /** Event emitted when the overlay has been detached. */
2727
- this.detach = new EventEmitter();
2728
- /** Emits when there are keyboard events that are targeted at the overlay. */
2729
- this.overlayKeydown = new EventEmitter();
2730
- /** Emits when there are mouse outside click events that are targeted at the overlay. */
2731
- this.overlayOutsideClick = new EventEmitter();
2732
- this._templatePortal = new TemplatePortal(templateRef, viewContainerRef);
2733
- this._scrollStrategyFactory = scrollStrategyFactory;
2734
- this.scrollStrategy = this._scrollStrategyFactory();
2735
- }
2736
- /** The associated overlay reference. */
2737
- get overlayRef() {
2738
- return this._overlayRef;
2739
- }
2740
- /** The element's layout direction. */
2741
- get dir() {
2742
- return this._dir ? this._dir.value : 'ltr';
2743
- }
2744
- ngOnDestroy() {
2745
- this._attachSubscription.unsubscribe();
2746
- this._detachSubscription.unsubscribe();
2747
- this._backdropSubscription.unsubscribe();
2748
- this._positionSubscription.unsubscribe();
2749
- if (this._overlayRef) {
2750
- this._overlayRef.dispose();
2751
- }
2752
- }
2753
- ngOnChanges(changes) {
2754
- if (this._position) {
2755
- this._updatePositionStrategy(this._position);
2756
- this._overlayRef.updateSize({
2757
- width: this.width,
2758
- minWidth: this.minWidth,
2759
- height: this.height,
2760
- minHeight: this.minHeight,
2761
- });
2762
- if (changes['origin'] && this.open) {
2763
- this._position.apply();
2764
- }
2765
- }
2766
- if (changes['open']) {
2767
- this.open ? this._attachOverlay() : this._detachOverlay();
2768
- }
2769
- }
2770
- /** Creates an overlay */
2771
- _createOverlay() {
2772
- if (!this.positions || !this.positions.length) {
2773
- this.positions = defaultPositionList;
2774
- }
2775
- const overlayRef = (this._overlayRef = this._overlay.create(this._buildConfig()));
2776
- this._attachSubscription = overlayRef.attachments().subscribe(() => this.attach.emit());
2777
- this._detachSubscription = overlayRef.detachments().subscribe(() => this.detach.emit());
2778
- overlayRef.keydownEvents().subscribe((event) => {
2779
- this.overlayKeydown.next(event);
2780
- if (event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event)) {
2781
- event.preventDefault();
2782
- this._detachOverlay();
2783
- }
2784
- });
2785
- this._overlayRef.outsidePointerEvents().subscribe((event) => {
2786
- this.overlayOutsideClick.next(event);
2787
- });
2788
- }
2789
- /** Builds the overlay config based on the directive's inputs */
2790
- _buildConfig() {
2791
- const positionStrategy = (this._position =
2792
- this.positionStrategy || this._createPositionStrategy());
2793
- const overlayConfig = new OverlayConfig({
2794
- direction: this._dir,
2795
- positionStrategy,
2796
- scrollStrategy: this.scrollStrategy,
2797
- hasBackdrop: this.hasBackdrop,
2798
- });
2799
- if (this.width || this.width === 0) {
2800
- overlayConfig.width = this.width;
2801
- }
2802
- if (this.height || this.height === 0) {
2803
- overlayConfig.height = this.height;
2804
- }
2805
- if (this.minWidth || this.minWidth === 0) {
2806
- overlayConfig.minWidth = this.minWidth;
2807
- }
2808
- if (this.minHeight || this.minHeight === 0) {
2809
- overlayConfig.minHeight = this.minHeight;
2810
- }
2811
- if (this.backdropClass) {
2812
- overlayConfig.backdropClass = this.backdropClass;
2813
- }
2814
- if (this.panelClass) {
2815
- overlayConfig.panelClass = this.panelClass;
2816
- }
2817
- return overlayConfig;
2818
- }
2819
- /** Updates the state of a position strategy, based on the values of the directive inputs. */
2820
- _updatePositionStrategy(positionStrategy) {
2821
- const positions = this.positions.map(currentPosition => ({
2822
- originX: currentPosition.originX,
2823
- originY: currentPosition.originY,
2824
- overlayX: currentPosition.overlayX,
2825
- overlayY: currentPosition.overlayY,
2826
- offsetX: currentPosition.offsetX || this.offsetX,
2827
- offsetY: currentPosition.offsetY || this.offsetY,
2828
- panelClass: currentPosition.panelClass || undefined,
2829
- }));
2830
- return positionStrategy
2831
- .setOrigin(this._getFlexibleConnectedPositionStrategyOrigin())
2832
- .withPositions(positions)
2833
- .withFlexibleDimensions(this.flexibleDimensions)
2834
- .withPush(this.push)
2835
- .withGrowAfterOpen(this.growAfterOpen)
2836
- .withViewportMargin(this.viewportMargin)
2837
- .withLockedPosition(this.lockPosition)
2838
- .withTransformOriginOn(this.transformOriginSelector);
2839
- }
2840
- /** Returns the position strategy of the overlay to be set on the overlay config */
2841
- _createPositionStrategy() {
2842
- const strategy = this._overlay
2843
- .position()
2844
- .flexibleConnectedTo(this._getFlexibleConnectedPositionStrategyOrigin());
2845
- this._updatePositionStrategy(strategy);
2846
- return strategy;
2847
- }
2848
- _getFlexibleConnectedPositionStrategyOrigin() {
2849
- if (this.origin instanceof CdkOverlayOrigin) {
2850
- return this.origin.elementRef;
2851
- }
2852
- else {
2853
- return this.origin;
2854
- }
2855
- }
2856
- /** Attaches the overlay and subscribes to backdrop clicks if backdrop exists */
2857
- _attachOverlay() {
2858
- if (!this._overlayRef) {
2859
- this._createOverlay();
2860
- }
2861
- else {
2862
- // Update the overlay size, in case the directive's inputs have changed
2863
- this._overlayRef.getConfig().hasBackdrop = this.hasBackdrop;
2864
- }
2865
- if (!this._overlayRef.hasAttached()) {
2866
- this._overlayRef.attach(this._templatePortal);
2867
- }
2868
- if (this.hasBackdrop) {
2869
- this._backdropSubscription = this._overlayRef.backdropClick().subscribe(event => {
2870
- this.backdropClick.emit(event);
2871
- });
2872
- }
2873
- else {
2874
- this._backdropSubscription.unsubscribe();
2875
- }
2876
- this._positionSubscription.unsubscribe();
2877
- // Only subscribe to `positionChanges` if requested, because putting
2878
- // together all the information for it can be expensive.
2879
- if (this.positionChange.observers.length > 0) {
2880
- this._positionSubscription = this._position.positionChanges
2881
- .pipe(takeWhile(() => this.positionChange.observers.length > 0))
2882
- .subscribe(position => {
2883
- this.positionChange.emit(position);
2884
- if (this.positionChange.observers.length === 0) {
2885
- this._positionSubscription.unsubscribe();
2886
- }
2887
- });
2888
- }
2889
- }
2890
- /** Detaches the overlay and unsubscribes to backdrop clicks if backdrop exists */
2891
- _detachOverlay() {
2892
- if (this._overlayRef) {
2893
- this._overlayRef.detach();
2894
- }
2895
- this._backdropSubscription.unsubscribe();
2896
- this._positionSubscription.unsubscribe();
2897
- }
2898
- }
2899
- CdkConnectedOverlay.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkConnectedOverlay, deps: [{ token: Overlay }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }, { token: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY }, { token: i5.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2900
- CdkConnectedOverlay.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0-next.2", type: CdkConnectedOverlay, isStandalone: true, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: { origin: ["cdkConnectedOverlayOrigin", "origin"], positions: ["cdkConnectedOverlayPositions", "positions"], positionStrategy: ["cdkConnectedOverlayPositionStrategy", "positionStrategy"], offsetX: ["cdkConnectedOverlayOffsetX", "offsetX"], offsetY: ["cdkConnectedOverlayOffsetY", "offsetY"], width: ["cdkConnectedOverlayWidth", "width"], height: ["cdkConnectedOverlayHeight", "height"], minWidth: ["cdkConnectedOverlayMinWidth", "minWidth"], minHeight: ["cdkConnectedOverlayMinHeight", "minHeight"], backdropClass: ["cdkConnectedOverlayBackdropClass", "backdropClass"], panelClass: ["cdkConnectedOverlayPanelClass", "panelClass"], viewportMargin: ["cdkConnectedOverlayViewportMargin", "viewportMargin"], scrollStrategy: ["cdkConnectedOverlayScrollStrategy", "scrollStrategy"], open: ["cdkConnectedOverlayOpen", "open"], disableClose: ["cdkConnectedOverlayDisableClose", "disableClose"], transformOriginSelector: ["cdkConnectedOverlayTransformOriginOn", "transformOriginSelector"], hasBackdrop: ["cdkConnectedOverlayHasBackdrop", "hasBackdrop"], lockPosition: ["cdkConnectedOverlayLockPosition", "lockPosition"], flexibleDimensions: ["cdkConnectedOverlayFlexibleDimensions", "flexibleDimensions"], growAfterOpen: ["cdkConnectedOverlayGrowAfterOpen", "growAfterOpen"], push: ["cdkConnectedOverlayPush", "push"] }, outputs: { backdropClick: "backdropClick", positionChange: "positionChange", attach: "attach", detach: "detach", overlayKeydown: "overlayKeydown", overlayOutsideClick: "overlayOutsideClick" }, exportAs: ["cdkConnectedOverlay"], usesOnChanges: true, ngImport: i0 });
2901
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: CdkConnectedOverlay, decorators: [{
2902
- type: Directive,
2903
- args: [{
2904
- selector: '[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]',
2905
- exportAs: 'cdkConnectedOverlay',
2906
- standalone: true,
2907
- }]
2908
- }], ctorParameters: function () {
2909
- return [{ type: Overlay }, { type: i0.TemplateRef }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
2910
- type: Inject,
2911
- args: [CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY]
2912
- }] }, { type: i5.Directionality, decorators: [{
2913
- type: Optional
2914
- }] }];
2915
- }, propDecorators: { origin: [{
2916
- type: Input,
2917
- args: ['cdkConnectedOverlayOrigin']
2918
- }], positions: [{
2919
- type: Input,
2920
- args: ['cdkConnectedOverlayPositions']
2921
- }], positionStrategy: [{
2922
- type: Input,
2923
- args: ['cdkConnectedOverlayPositionStrategy']
2924
- }], offsetX: [{
2925
- type: Input,
2926
- args: ['cdkConnectedOverlayOffsetX']
2927
- }], offsetY: [{
2928
- type: Input,
2929
- args: ['cdkConnectedOverlayOffsetY']
2930
- }], width: [{
2931
- type: Input,
2932
- args: ['cdkConnectedOverlayWidth']
2933
- }], height: [{
2934
- type: Input,
2935
- args: ['cdkConnectedOverlayHeight']
2936
- }], minWidth: [{
2937
- type: Input,
2938
- args: ['cdkConnectedOverlayMinWidth']
2939
- }], minHeight: [{
2940
- type: Input,
2941
- args: ['cdkConnectedOverlayMinHeight']
2942
- }], backdropClass: [{
2943
- type: Input,
2944
- args: ['cdkConnectedOverlayBackdropClass']
2945
- }], panelClass: [{
2946
- type: Input,
2947
- args: ['cdkConnectedOverlayPanelClass']
2948
- }], viewportMargin: [{
2949
- type: Input,
2950
- args: ['cdkConnectedOverlayViewportMargin']
2951
- }], scrollStrategy: [{
2952
- type: Input,
2953
- args: ['cdkConnectedOverlayScrollStrategy']
2954
- }], open: [{
2955
- type: Input,
2956
- args: ['cdkConnectedOverlayOpen']
2957
- }], disableClose: [{
2958
- type: Input,
2959
- args: ['cdkConnectedOverlayDisableClose']
2960
- }], transformOriginSelector: [{
2961
- type: Input,
2962
- args: ['cdkConnectedOverlayTransformOriginOn']
2963
- }], hasBackdrop: [{
2964
- type: Input,
2965
- args: ['cdkConnectedOverlayHasBackdrop']
2966
- }], lockPosition: [{
2967
- type: Input,
2968
- args: ['cdkConnectedOverlayLockPosition']
2969
- }], flexibleDimensions: [{
2970
- type: Input,
2971
- args: ['cdkConnectedOverlayFlexibleDimensions']
2972
- }], growAfterOpen: [{
2973
- type: Input,
2974
- args: ['cdkConnectedOverlayGrowAfterOpen']
2975
- }], push: [{
2976
- type: Input,
2977
- args: ['cdkConnectedOverlayPush']
2978
- }], backdropClick: [{
2979
- type: Output
2980
- }], positionChange: [{
2981
- type: Output
2982
- }], attach: [{
2983
- type: Output
2984
- }], detach: [{
2985
- type: Output
2986
- }], overlayKeydown: [{
2987
- type: Output
2988
- }], overlayOutsideClick: [{
2989
- type: Output
2990
- }] } });
2991
- /** @docs-private */
2992
- function CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY(overlay) {
2993
- return () => overlay.scrollStrategies.reposition();
2994
- }
2995
- /** @docs-private */
2996
- const CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {
2997
- provide: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY,
2998
- deps: [Overlay],
2999
- useFactory: CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY,
3000
- };
3001
-
3002
- /**
3003
- * @license
3004
- * Copyright Google LLC All Rights Reserved.
3005
- *
3006
- * Use of this source code is governed by an MIT-style license that can be
3007
- * found in the LICENSE file at https://angular.io/license
3008
- */
3009
- class OverlayModule {
3010
- }
3011
- OverlayModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3012
- OverlayModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayModule, imports: [BidiModule, PortalModule, ScrollingModule, CdkConnectedOverlay, CdkOverlayOrigin], exports: [CdkConnectedOverlay, CdkOverlayOrigin, ScrollingModule] });
3013
- OverlayModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayModule, providers: [Overlay, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER], imports: [BidiModule, PortalModule, ScrollingModule, ScrollingModule] });
3014
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: OverlayModule, decorators: [{
3015
- type: NgModule,
3016
- args: [{
3017
- imports: [BidiModule, PortalModule, ScrollingModule, CdkConnectedOverlay, CdkOverlayOrigin],
3018
- exports: [CdkConnectedOverlay, CdkOverlayOrigin, ScrollingModule],
3019
- providers: [Overlay, CDK_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER],
3020
- }]
3021
- }] });
3022
-
3023
- /**
3024
- * @license
3025
- * Copyright Google LLC All Rights Reserved.
3026
- *
3027
- * Use of this source code is governed by an MIT-style license that can be
3028
- * found in the LICENSE file at https://angular.io/license
3029
- */
3030
-
3031
- /**
3032
- * @license
3033
- * Copyright Google LLC All Rights Reserved.
3034
- *
3035
- * Use of this source code is governed by an MIT-style license that can be
3036
- * found in the LICENSE file at https://angular.io/license
3037
- */
3038
- /**
3039
- * Alternative to OverlayContainer that supports correct displaying of overlay elements in
3040
- * Fullscreen mode
3041
- * https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen
3042
- *
3043
- * Should be provided in the root component.
3044
- */
3045
- class FullscreenOverlayContainer extends OverlayContainer {
3046
- constructor(_document, platform) {
3047
- super(_document, platform);
3048
- }
3049
- ngOnDestroy() {
3050
- super.ngOnDestroy();
3051
- if (this._fullScreenEventName && this._fullScreenListener) {
3052
- this._document.removeEventListener(this._fullScreenEventName, this._fullScreenListener);
3053
- }
3054
- }
3055
- _createContainer() {
3056
- super._createContainer();
3057
- this._adjustParentForFullscreenChange();
3058
- this._addFullscreenChangeListener(() => this._adjustParentForFullscreenChange());
3059
- }
3060
- _adjustParentForFullscreenChange() {
3061
- if (!this._containerElement) {
3062
- return;
3063
- }
3064
- const fullscreenElement = this.getFullscreenElement();
3065
- const parent = fullscreenElement || this._document.body;
3066
- parent.appendChild(this._containerElement);
3067
- }
3068
- _addFullscreenChangeListener(fn) {
3069
- const eventName = this._getEventName();
3070
- if (eventName) {
3071
- if (this._fullScreenListener) {
3072
- this._document.removeEventListener(eventName, this._fullScreenListener);
3073
- }
3074
- this._document.addEventListener(eventName, fn);
3075
- this._fullScreenListener = fn;
3076
- }
3077
- }
3078
- _getEventName() {
3079
- if (!this._fullScreenEventName) {
3080
- const _document = this._document;
3081
- if (_document.fullscreenEnabled) {
3082
- this._fullScreenEventName = 'fullscreenchange';
3083
- }
3084
- else if (_document.webkitFullscreenEnabled) {
3085
- this._fullScreenEventName = 'webkitfullscreenchange';
3086
- }
3087
- else if (_document.mozFullScreenEnabled) {
3088
- this._fullScreenEventName = 'mozfullscreenchange';
3089
- }
3090
- else if (_document.msFullscreenEnabled) {
3091
- this._fullScreenEventName = 'MSFullscreenChange';
3092
- }
3093
- }
3094
- return this._fullScreenEventName;
3095
- }
3096
- /**
3097
- * When the page is put into fullscreen mode, a specific element is specified.
3098
- * Only that element and its children are visible when in fullscreen mode.
3099
- */
3100
- getFullscreenElement() {
3101
- const _document = this._document;
3102
- return (_document.fullscreenElement ||
3103
- _document.webkitFullscreenElement ||
3104
- _document.mozFullScreenElement ||
3105
- _document.msFullscreenElement ||
3106
- null);
3107
- }
3108
- }
3109
- FullscreenOverlayContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FullscreenOverlayContainer, deps: [{ token: DOCUMENT }, { token: i1$1.Platform }], target: i0.ɵɵFactoryTarget.Injectable });
3110
- FullscreenOverlayContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FullscreenOverlayContainer, providedIn: 'root' });
3111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.2", ngImport: i0, type: FullscreenOverlayContainer, decorators: [{
3112
- type: Injectable,
3113
- args: [{ providedIn: 'root' }]
3114
- }], ctorParameters: function () {
3115
- return [{ type: undefined, decorators: [{
3116
- type: Inject,
3117
- args: [DOCUMENT]
3118
- }] }, { type: i1$1.Platform }];
3119
- } });
3120
-
3121
- /**
3122
- * @license
3123
- * Copyright Google LLC All Rights Reserved.
3124
- *
3125
- * Use of this source code is governed by an MIT-style license that can be
3126
- * found in the LICENSE file at https://angular.io/license
3127
- */
3128
-
3129
- /**
3130
- * @license
3131
- * Copyright Google LLC All Rights Reserved.
3132
- *
3133
- * Use of this source code is governed by an MIT-style license that can be
3134
- * found in the LICENSE file at https://angular.io/license
3135
- */
3136
-
3137
- /**
3138
- * Generated bundle index. Do not edit.
3139
- */
3140
-
3141
- export { BlockScrollStrategy, CdkConnectedOverlay, CdkOverlayOrigin, CloseScrollStrategy, ConnectedOverlayPositionChange, ConnectionPositionPair, FlexibleConnectedPositionStrategy, FullscreenOverlayContainer, GlobalPositionStrategy, NoopScrollStrategy, Overlay, OverlayConfig, OverlayContainer, OverlayKeyboardDispatcher, OverlayModule, OverlayOutsideClickDispatcher, OverlayPositionBuilder, OverlayRef, RepositionScrollStrategy, STANDARD_DROPDOWN_ADJACENT_POSITIONS, STANDARD_DROPDOWN_BELOW_POSITIONS, ScrollStrategyOptions, ScrollingVisibility, validateHorizontalPosition, validateVerticalPosition };
3142
- //# sourceMappingURL=overlay.mjs.map