@angular/cdk 13.0.0-next.6 → 13.0.0-rc.1

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 (796) hide show
  1. package/a11y/a11y-module.d.ts +9 -7
  2. package/a11y/aria-describer/aria-describer.d.ts +3 -7
  3. package/a11y/focus-monitor/focus-monitor.d.ts +5 -0
  4. package/a11y/focus-trap/configurable-focus-trap-factory.d.ts +3 -7
  5. package/a11y/focus-trap/focus-trap-manager.d.ts +3 -7
  6. package/a11y/focus-trap/focus-trap.d.ts +5 -0
  7. package/a11y/high-contrast-mode/high-contrast-mode-detector.d.ts +3 -0
  8. package/a11y/index.d.ts +0 -1
  9. package/a11y/input-modality/input-modality-detector.d.ts +3 -7
  10. package/a11y/interactivity-checker/interactivity-checker.d.ts +3 -0
  11. package/a11y/live-announcer/live-announcer.d.ts +6 -1
  12. package/a11y/package.json +5 -5
  13. package/accordion/accordion-item.d.ts +3 -0
  14. package/accordion/accordion-module.d.ts +6 -7
  15. package/accordion/accordion.d.ts +3 -0
  16. package/accordion/index.d.ts +0 -1
  17. package/accordion/package.json +5 -5
  18. package/bidi/bidi-module.d.ts +5 -7
  19. package/bidi/dir.d.ts +3 -0
  20. package/bidi/directionality.d.ts +3 -0
  21. package/bidi/index.d.ts +0 -1
  22. package/bidi/package.json +5 -5
  23. package/clipboard/clipboard-module.d.ts +5 -7
  24. package/clipboard/clipboard.d.ts +3 -7
  25. package/clipboard/copy-to-clipboard.d.ts +3 -0
  26. package/clipboard/package.json +5 -5
  27. package/coercion/package.json +5 -5
  28. package/collections/package.json +5 -5
  29. package/collections/unique-selection-dispatcher.d.ts +3 -0
  30. package/drag-drop/client-rect.d.ts +8 -1
  31. package/drag-drop/directives/drag-handle.d.ts +3 -0
  32. package/drag-drop/directives/drag-placeholder.d.ts +3 -0
  33. package/drag-drop/directives/drag-preview.d.ts +3 -0
  34. package/drag-drop/directives/drag.d.ts +3 -0
  35. package/drag-drop/directives/drop-list-group.d.ts +3 -0
  36. package/drag-drop/directives/drop-list.d.ts +3 -0
  37. package/drag-drop/drag-drop-module.d.ts +11 -7
  38. package/drag-drop/drag-drop-registry.d.ts +3 -0
  39. package/drag-drop/drag-drop.d.ts +3 -0
  40. package/drag-drop/index.d.ts +0 -1
  41. package/drag-drop/package.json +5 -5
  42. package/esm2020/a11y/a11y-module.mjs +33 -0
  43. package/esm2020/a11y/aria-describer/aria-describer.mjs +208 -0
  44. package/{esm2015/a11y/aria-describer/aria-reference.js → esm2020/a11y/aria-describer/aria-reference.mjs} +1 -1
  45. package/esm2020/a11y/fake-event-detection.mjs +29 -0
  46. package/esm2020/a11y/focus-monitor/focus-monitor.mjs +400 -0
  47. package/{esm2015/a11y/focus-trap/configurable-focus-trap-config.js → esm2020/a11y/focus-trap/configurable-focus-trap-config.mjs} +0 -0
  48. package/esm2020/a11y/focus-trap/configurable-focus-trap-factory.mjs +53 -0
  49. package/esm2020/a11y/focus-trap/configurable-focus-trap.mjs +51 -0
  50. package/esm2020/a11y/focus-trap/event-listener-inert-strategy.mjs +61 -0
  51. package/esm2020/a11y/focus-trap/focus-trap-inert-strategy.mjs +11 -0
  52. package/esm2020/a11y/focus-trap/focus-trap-manager.mjs +53 -0
  53. package/esm2020/a11y/focus-trap/focus-trap.mjs +399 -0
  54. package/esm2020/a11y/high-contrast-mode/high-contrast-mode-detector.mjs +95 -0
  55. package/esm2020/a11y/index.mjs +5 -0
  56. package/esm2020/a11y/input-modality/input-modality-detector.mjs +176 -0
  57. package/esm2020/a11y/interactivity-checker/interactivity-checker.mjs +238 -0
  58. package/{esm2015/a11y/key-manager/activedescendant-key-manager.js → esm2020/a11y/key-manager/activedescendant-key-manager.mjs} +1 -1
  59. package/{esm2015/a11y/key-manager/focus-key-manager.js → esm2020/a11y/key-manager/focus-key-manager.mjs} +0 -0
  60. package/esm2020/a11y/key-manager/list-key-manager.mjs +321 -0
  61. package/esm2020/a11y/live-announcer/live-announcer-tokens.mjs +19 -0
  62. package/esm2020/a11y/live-announcer/live-announcer.mjs +170 -0
  63. package/{esm2015/a11y/public-api.js → esm2020/a11y/public-api.mjs} +0 -0
  64. package/esm2020/accordion/accordion-item.mjs +167 -0
  65. package/esm2020/accordion/accordion-module.mjs +24 -0
  66. package/esm2020/accordion/accordion.mjs +70 -0
  67. package/esm2020/accordion/index.mjs +5 -0
  68. package/{esm2015/accordion/public-api.js → esm2020/accordion/public-api.mjs} +0 -0
  69. package/esm2020/bidi/bidi-module.mjs +23 -0
  70. package/{esm2015/bidi/dir-document-token.js → esm2020/bidi/dir-document-token.mjs} +1 -1
  71. package/esm2020/bidi/dir.mjs +67 -0
  72. package/esm2020/bidi/directionality.mjs +47 -0
  73. package/esm2020/bidi/index.mjs +5 -0
  74. package/{esm2015/bidi/public-api.js → esm2020/bidi/public-api.mjs} +1 -1
  75. package/esm2020/clipboard/clipboard-module.mjs +23 -0
  76. package/esm2020/clipboard/clipboard.mjs +53 -0
  77. package/esm2020/clipboard/copy-to-clipboard.mjs +99 -0
  78. package/{esm2015/clipboard/index.js → esm2020/clipboard/index.mjs} +0 -0
  79. package/esm2020/clipboard/pending-copy.mjs +67 -0
  80. package/{esm2015/clipboard/public-api.js → esm2020/clipboard/public-api.mjs} +0 -0
  81. package/{esm2015/coercion/array.js → esm2020/coercion/array.mjs} +0 -0
  82. package/{esm2015/coercion/boolean-property.js → esm2020/coercion/boolean-property.mjs} +0 -0
  83. package/{esm2015/coercion/css-pixel-value.js → esm2020/coercion/css-pixel-value.mjs} +0 -0
  84. package/{esm2015/coercion/element.js → esm2020/coercion/element.mjs} +0 -0
  85. package/{esm2015/coercion/index.js → esm2020/coercion/index.mjs} +0 -0
  86. package/{esm2015/coercion/number-property.js → esm2020/coercion/number-property.mjs} +0 -0
  87. package/{esm2015/coercion/public-api.js → esm2020/coercion/public-api.mjs} +0 -0
  88. package/{esm2015/coercion/string-array.js → esm2020/coercion/string-array.mjs} +0 -0
  89. package/{esm2015/collections/array-data-source.js → esm2020/collections/array-data-source.mjs} +1 -1
  90. package/esm2020/collections/collection-viewer.mjs +9 -0
  91. package/{esm2015/collections/data-source.js → esm2020/collections/data-source.mjs} +0 -0
  92. package/esm2020/collections/dispose-view-repeater-strategy.mjs +47 -0
  93. package/{esm2015/collections/index.js → esm2020/collections/index.mjs} +0 -0
  94. package/{esm2015/collections/public-api.js → esm2020/collections/public-api.mjs} +0 -0
  95. package/esm2020/collections/recycle-view-repeater-strategy.mjs +128 -0
  96. package/{esm2015/collections/selection-model.js → esm2020/collections/selection-model.mjs} +2 -2
  97. package/esm2020/collections/tree-adapter.mjs +9 -0
  98. package/esm2020/collections/unique-selection-dispatcher.mjs +55 -0
  99. package/esm2020/collections/view-repeater.mjs +14 -0
  100. package/esm2020/drag-drop/client-rect.mjs +64 -0
  101. package/esm2020/drag-drop/clone-node.mjs +65 -0
  102. package/esm2020/drag-drop/directives/assertions.mjs +18 -0
  103. package/{esm2015/drag-drop/directives/config.js → esm2020/drag-drop/directives/config.mjs} +1 -1
  104. package/esm2020/drag-drop/directives/drag-handle.mjs +66 -0
  105. package/esm2020/drag-drop/directives/drag-placeholder.mjs +36 -0
  106. package/esm2020/drag-drop/directives/drag-preview.mjs +47 -0
  107. package/esm2020/drag-drop/directives/drag.mjs +483 -0
  108. package/esm2020/drag-drop/directives/drop-list-group.mjs +53 -0
  109. package/esm2020/drag-drop/directives/drop-list.mjs +344 -0
  110. package/esm2020/drag-drop/drag-drop-module.mjs +57 -0
  111. package/esm2020/drag-drop/drag-drop-registry.mjs +231 -0
  112. package/esm2020/drag-drop/drag-drop.mjs +57 -0
  113. package/esm2020/drag-drop/drag-events.mjs +9 -0
  114. package/{esm2015/drag-drop/drag-parent.js → esm2020/drag-drop/drag-parent.mjs} +0 -0
  115. package/esm2020/drag-drop/drag-ref.mjs +1108 -0
  116. package/esm2020/drag-drop/drag-styling.mjs +69 -0
  117. package/esm2020/drag-drop/drag-utils.mjs +60 -0
  118. package/esm2020/drag-drop/drop-list-ref.mjs +830 -0
  119. package/{esm2015/drag-drop/index.js → esm2020/drag-drop/index.mjs} +1 -1
  120. package/{esm2015/drag-drop/parent-position-tracker.js → esm2020/drag-drop/parent-position-tracker.mjs} +2 -2
  121. package/{esm2015/drag-drop/public-api.js → esm2020/drag-drop/public-api.mjs} +0 -0
  122. package/esm2020/drag-drop/transition-duration.mjs +36 -0
  123. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  124. package/{esm2015/keycodes/index.js → esm2020/keycodes/index.mjs} +0 -0
  125. package/{esm2015/keycodes/keycodes.js → esm2020/keycodes/keycodes.mjs} +1 -1
  126. package/{esm2015/keycodes/modifiers.js → esm2020/keycodes/modifiers.mjs} +0 -0
  127. package/{esm2015/keycodes/public-api.js → esm2020/keycodes/public-api.mjs} +0 -0
  128. package/esm2020/layout/breakpoints-observer.mjs +105 -0
  129. package/{esm2015/layout/breakpoints.js → esm2020/layout/breakpoints.mjs} +1 -1
  130. package/{esm2015/layout/index.js → esm2020/layout/index.mjs} +0 -0
  131. package/esm2020/layout/layout-module.mjs +19 -0
  132. package/esm2020/layout/media-matcher.mjs +85 -0
  133. package/{esm2015/layout/public-api.js → esm2020/layout/public-api.mjs} +0 -0
  134. package/{esm2015/observers/index.js → esm2020/observers/index.mjs} +0 -0
  135. package/esm2020/observers/observe-content.mjs +187 -0
  136. package/{esm2015/observers/public-api.js → esm2020/observers/public-api.mjs} +0 -0
  137. package/esm2020/overlay/dispatchers/base-overlay-dispatcher.mjs +52 -0
  138. package/{esm2015/overlay/dispatchers/index.js → esm2020/overlay/dispatchers/index.mjs} +0 -0
  139. package/esm2020/overlay/dispatchers/overlay-keyboard-dispatcher.mjs +63 -0
  140. package/esm2020/overlay/dispatchers/overlay-outside-click-dispatcher.mjs +116 -0
  141. package/esm2020/overlay/fullscreen-overlay-container.mjs +94 -0
  142. package/esm2020/overlay/index.mjs +5 -0
  143. package/esm2020/overlay/overlay-config.mjs +45 -0
  144. package/esm2020/overlay/overlay-container.mjs +81 -0
  145. package/esm2020/overlay/overlay-directives.mjs +427 -0
  146. package/esm2020/overlay/overlay-module.mjs +29 -0
  147. package/esm2020/overlay/overlay-ref.mjs +402 -0
  148. package/{esm2015/overlay/overlay-reference.js → esm2020/overlay/overlay-reference.mjs} +0 -0
  149. package/esm2020/overlay/overlay.mjs +119 -0
  150. package/esm2020/overlay/position/connected-position.mjs +97 -0
  151. package/esm2020/overlay/position/flexible-connected-position-strategy.mjs +959 -0
  152. package/esm2020/overlay/position/global-position-strategy.mjs +203 -0
  153. package/esm2020/overlay/position/overlay-position-builder.mjs +50 -0
  154. package/{esm2015/overlay/position/position-strategy.js → esm2020/overlay/position/position-strategy.mjs} +0 -0
  155. package/esm2020/overlay/position/scroll-clip.mjs +40 -0
  156. package/{esm2015/overlay/public-api.js → esm2020/overlay/public-api.mjs} +0 -0
  157. package/{esm2015/overlay/scroll/block-scroll-strategy.js → esm2020/overlay/scroll/block-scroll-strategy.mjs} +1 -1
  158. package/esm2020/overlay/scroll/close-scroll-strategy.mjs +61 -0
  159. package/{esm2015/overlay/scroll/index.js → esm2020/overlay/scroll/index.mjs} +2 -2
  160. package/{esm2015/overlay/scroll/noop-scroll-strategy.js → esm2020/overlay/scroll/noop-scroll-strategy.mjs} +1 -1
  161. package/{esm2015/overlay/scroll/reposition-scroll-strategy.js → esm2020/overlay/scroll/reposition-scroll-strategy.mjs} +1 -1
  162. package/esm2020/overlay/scroll/scroll-strategy-options.mjs +55 -0
  163. package/{esm2015/overlay/scroll/scroll-strategy.js → esm2020/overlay/scroll/scroll-strategy.mjs} +0 -0
  164. package/{esm2015/platform/features/input-types.js → esm2020/platform/features/input-types.mjs} +1 -1
  165. package/esm2020/platform/features/passive-listeners.mjs +36 -0
  166. package/esm2020/platform/features/scrolling.mjs +85 -0
  167. package/{esm2015/platform/features/shadow-dom.js → esm2020/platform/features/shadow-dom.mjs} +4 -3
  168. package/esm2020/platform/features/test-environment.mjs +27 -0
  169. package/{esm2015/platform/index.js → esm2020/platform/index.mjs} +0 -0
  170. package/esm2020/platform/platform-module.mjs +19 -0
  171. package/esm2020/platform/platform.mjs +85 -0
  172. package/{esm2015/platform/public-api.js → esm2020/platform/public-api.mjs} +0 -0
  173. package/esm2020/portal/dom-portal-outlet.mjs +134 -0
  174. package/{esm2015/portal/index.js → esm2020/portal/index.mjs} +0 -0
  175. package/esm2020/portal/portal-directives.mjs +244 -0
  176. package/{esm2015/portal/portal-errors.js → esm2020/portal/portal-errors.mjs} +1 -1
  177. package/esm2020/portal/portal-injector.mjs +28 -0
  178. package/esm2020/portal/portal.mjs +179 -0
  179. package/{esm2015/portal/public-api.js → esm2020/portal/public-api.mjs} +0 -0
  180. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  181. package/esm2020/scrolling/fixed-size-virtual-scroll.mjs +217 -0
  182. package/{esm2015/scrolling/index.js → esm2020/scrolling/index.mjs} +0 -0
  183. package/{esm2015/scrolling/public-api.js → esm2020/scrolling/public-api.mjs} +0 -0
  184. package/esm2020/scrolling/scroll-dispatcher.mjs +163 -0
  185. package/esm2020/scrolling/scrollable.mjs +176 -0
  186. package/esm2020/scrolling/scrolling-module.mjs +52 -0
  187. package/esm2020/scrolling/viewport-ruler.mjs +146 -0
  188. package/esm2020/scrolling/virtual-for-of.mjs +296 -0
  189. package/{esm2015/scrolling/virtual-scroll-repeater.js → esm2020/scrolling/virtual-scroll-repeater.mjs} +0 -0
  190. package/esm2020/scrolling/virtual-scroll-strategy.mjs +11 -0
  191. package/esm2020/scrolling/virtual-scroll-viewport.mjs +378 -0
  192. package/{esm2015/stepper/index.js → esm2020/stepper/index.mjs} +0 -0
  193. package/{esm2015/stepper/public-api.js → esm2020/stepper/public-api.mjs} +0 -0
  194. package/esm2020/stepper/step-header.mjs +30 -0
  195. package/esm2020/stepper/step-label.mjs +23 -0
  196. package/esm2020/stepper/stepper-button.mjs +76 -0
  197. package/esm2020/stepper/stepper-module.mjs +40 -0
  198. package/esm2020/stepper/stepper.mjs +471 -0
  199. package/esm2020/table/can-stick.mjs +44 -0
  200. package/esm2020/table/cell.mjs +222 -0
  201. package/esm2020/table/coalesced-style-scheduler.mjs +91 -0
  202. package/{esm2015/table/index.js → esm2020/table/index.mjs} +0 -0
  203. package/{esm2015/table/public-api.js → esm2020/table/public-api.mjs} +0 -0
  204. package/esm2020/table/row.mjs +254 -0
  205. package/esm2020/table/sticky-position-listener.mjs +11 -0
  206. package/esm2020/table/sticky-styler.mjs +345 -0
  207. package/{esm2015/table/table-errors.js → esm2020/table/table-errors.mjs} +1 -1
  208. package/esm2020/table/table-module.mjs +94 -0
  209. package/esm2020/table/table.mjs +1023 -0
  210. package/esm2020/table/text-column.mjs +153 -0
  211. package/{esm2015/table/tokens.js → esm2020/table/tokens.mjs} +1 -1
  212. package/esm2020/testing/change-detection.mjs +102 -0
  213. package/esm2020/testing/component-harness.mjs +322 -0
  214. package/{esm2015/testing/element-dimensions.js → esm2020/testing/element-dimensions.mjs} +1 -1
  215. package/esm2020/testing/harness-environment.mjs +202 -0
  216. package/{esm2015/testing/index.js → esm2020/testing/index.mjs} +0 -0
  217. package/{esm2015/testing/protractor/index.js → esm2020/testing/protractor/index.mjs} +0 -0
  218. package/esm2020/testing/protractor/protractor-element.mjs +234 -0
  219. package/esm2020/testing/protractor/protractor-harness-environment.mjs +72 -0
  220. package/{esm2015/testing/protractor/public-api.js → esm2020/testing/protractor/public-api.mjs} +0 -0
  221. package/{esm2015/testing/public-api.js → esm2020/testing/public-api.mjs} +0 -0
  222. package/{esm2015/testing/selenium-webdriver/index.js → esm2020/testing/selenium-webdriver/index.mjs} +0 -0
  223. package/{esm2015/testing/selenium-webdriver/public-api.js → esm2020/testing/selenium-webdriver/public-api.mjs} +0 -0
  224. package/esm2020/testing/selenium-webdriver/selenium-web-driver-element.mjs +199 -0
  225. package/esm2020/testing/selenium-webdriver/selenium-web-driver-harness-environment.mjs +87 -0
  226. package/{esm2015/testing/selenium-webdriver/selenium-webdriver-keys.js → esm2020/testing/selenium-webdriver/selenium-webdriver-keys.mjs} +2 -2
  227. package/esm2020/testing/test-element.mjs +48 -0
  228. package/esm2020/testing/testbed/fake-events/dispatch-events.mjs +53 -0
  229. package/esm2020/testing/testbed/fake-events/element-focus.mjs +39 -0
  230. package/esm2020/testing/testbed/fake-events/event-objects.mjs +113 -0
  231. package/{esm2015/testing/testbed/fake-events/index.js → esm2020/testing/testbed/fake-events/index.mjs} +0 -0
  232. package/esm2020/testing/testbed/fake-events/type-in-element.mjs +88 -0
  233. package/{esm2015/testing/testbed/index.js → esm2020/testing/testbed/index.mjs} +0 -0
  234. package/{esm2015/testing/testbed/public-api.js → esm2020/testing/testbed/public-api.mjs} +0 -0
  235. package/esm2020/testing/testbed/task-state-zone-interceptor.mjs +82 -0
  236. package/esm2020/testing/testbed/testbed-harness-environment.mjs +162 -0
  237. package/esm2020/testing/testbed/unit-test-element.mjs +224 -0
  238. package/esm2020/testing/text-filtering.mjs +21 -0
  239. package/esm2020/text-field/autofill.mjs +113 -0
  240. package/esm2020/text-field/autosize.mjs +310 -0
  241. package/{esm2015/text-field/index.js → esm2020/text-field/index.mjs} +0 -0
  242. package/{esm2015/text-field/public-api.js → esm2020/text-field/public-api.mjs} +0 -0
  243. package/esm2020/text-field/text-field-module.mjs +26 -0
  244. package/{esm2015/tree/control/base-tree-control.js → esm2020/tree/control/base-tree-control.mjs} +4 -4
  245. package/{esm2015/tree/control/flat-tree-control.js → esm2020/tree/control/flat-tree-control.mjs} +1 -1
  246. package/esm2020/tree/control/nested-tree-control.mjs +58 -0
  247. package/{esm2015/tree/control/tree-control.js → esm2020/tree/control/tree-control.mjs} +0 -0
  248. package/{esm2015/tree/index.js → esm2020/tree/index.mjs} +0 -0
  249. package/esm2020/tree/nested-node.mjs +117 -0
  250. package/esm2020/tree/node.mjs +35 -0
  251. package/esm2020/tree/outlet.mjs +39 -0
  252. package/esm2020/tree/padding.mjs +131 -0
  253. package/{esm2015/tree/public-api.js → esm2020/tree/public-api.mjs} +0 -0
  254. package/esm2020/tree/toggle.mjs +53 -0
  255. package/{esm2015/tree/tree-errors.js → esm2020/tree/tree-errors.mjs} +0 -0
  256. package/esm2020/tree/tree-module.mjs +49 -0
  257. package/esm2020/tree/tree.mjs +361 -0
  258. package/{esm2015/version.js → esm2020/version.mjs} +1 -1
  259. package/fesm2015/a11y.mjs +2356 -0
  260. package/fesm2015/a11y.mjs.map +1 -0
  261. package/fesm2015/accordion.mjs +267 -0
  262. package/fesm2015/accordion.mjs.map +1 -0
  263. package/fesm2015/bidi.mjs +179 -0
  264. package/fesm2015/bidi.mjs.map +1 -0
  265. package/fesm2015/{cdk.js → cdk.mjs} +2 -2
  266. package/fesm2015/cdk.mjs.map +1 -0
  267. package/fesm2015/clipboard.mjs +253 -0
  268. package/fesm2015/clipboard.mjs.map +1 -0
  269. package/fesm2015/{coercion.js → coercion.mjs} +1 -1
  270. package/fesm2015/coercion.mjs.map +1 -0
  271. package/fesm2015/{collections.js → collections.mjs} +15 -27
  272. package/fesm2015/collections.mjs.map +1 -0
  273. package/fesm2015/drag-drop.mjs +3667 -0
  274. package/fesm2015/drag-drop.mjs.map +1 -0
  275. package/fesm2015/{keycodes.js → keycodes.mjs} +1 -1
  276. package/fesm2015/keycodes.mjs.map +1 -0
  277. package/fesm2015/{layout.js → layout.mjs} +30 -28
  278. package/fesm2015/layout.mjs.map +1 -0
  279. package/fesm2015/{observers.js → observers.mjs} +50 -41
  280. package/fesm2015/observers.mjs.map +1 -0
  281. package/fesm2015/overlay.mjs +3004 -0
  282. package/fesm2015/overlay.mjs.map +1 -0
  283. package/fesm2015/platform.mjs +380 -0
  284. package/fesm2015/platform.mjs.map +1 -0
  285. package/fesm2015/portal.mjs +649 -0
  286. package/fesm2015/portal.mjs.map +1 -0
  287. package/fesm2015/scrolling.mjs +1394 -0
  288. package/fesm2015/scrolling.mjs.map +1 -0
  289. package/fesm2015/{stepper.js → stepper.mjs} +186 -133
  290. package/fesm2015/stepper.mjs.map +1 -0
  291. package/fesm2015/{table.js → table.mjs} +500 -359
  292. package/fesm2015/table.mjs.map +1 -0
  293. package/fesm2015/testing/{protractor.js → protractor.mjs} +12 -25
  294. package/fesm2015/testing/protractor.mjs.map +1 -0
  295. package/fesm2015/testing/{selenium-webdriver.js → selenium-webdriver.mjs} +14 -28
  296. package/fesm2015/testing/selenium-webdriver.mjs.map +1 -0
  297. package/fesm2015/testing/{testbed.js → testbed.mjs} +23 -29
  298. package/fesm2015/testing/testbed.mjs.map +1 -0
  299. package/fesm2015/{testing.js → testing.mjs} +19 -45
  300. package/fesm2015/testing.mjs.map +1 -0
  301. package/fesm2015/text-field.mjs +455 -0
  302. package/fesm2015/text-field.mjs.map +1 -0
  303. package/fesm2015/{tree.js → tree.mjs} +198 -152
  304. package/fesm2015/tree.mjs.map +1 -0
  305. package/{fesm2015/a11y.js → fesm2020/a11y.mjs} +272 -233
  306. package/fesm2020/a11y.mjs.map +1 -0
  307. package/{fesm2015/accordion.js → fesm2020/accordion.mjs} +87 -57
  308. package/fesm2020/accordion.mjs.map +1 -0
  309. package/{fesm2015/bidi.js → fesm2020/bidi.mjs} +47 -31
  310. package/fesm2020/bidi.mjs.map +1 -0
  311. package/fesm2020/cdk.mjs +30 -0
  312. package/fesm2020/cdk.mjs.map +1 -0
  313. package/{fesm2015/clipboard.js → fesm2020/clipboard.mjs} +51 -40
  314. package/fesm2020/clipboard.mjs.map +1 -0
  315. package/fesm2020/coercion.mjs +132 -0
  316. package/fesm2020/coercion.mjs.map +1 -0
  317. package/fesm2020/collections.mjs +472 -0
  318. package/fesm2020/collections.mjs.map +1 -0
  319. package/{fesm2015/drag-drop.js → fesm2020/drag-drop.mjs} +523 -366
  320. package/fesm2020/drag-drop.mjs.map +1 -0
  321. package/fesm2020/keycodes.mjs +159 -0
  322. package/fesm2020/keycodes.mjs.map +1 -0
  323. package/fesm2020/layout.mjs +246 -0
  324. package/fesm2020/layout.mjs.map +1 -0
  325. package/fesm2020/observers.mjs +202 -0
  326. package/fesm2020/observers.mjs.map +1 -0
  327. package/{fesm2015/overlay.js → fesm2020/overlay.mjs} +312 -228
  328. package/fesm2020/overlay.mjs.map +1 -0
  329. package/{fesm2015/platform.js → fesm2020/platform.mjs} +52 -28
  330. package/fesm2020/platform.mjs.map +1 -0
  331. package/{fesm2015/portal.js → fesm2020/portal.mjs} +85 -64
  332. package/fesm2020/portal.mjs.map +1 -0
  333. package/{fesm2015/scrolling.js → fesm2020/scrolling.mjs} +213 -170
  334. package/fesm2020/scrolling.mjs.map +1 -0
  335. package/fesm2020/stepper.mjs +638 -0
  336. package/fesm2020/stepper.mjs.map +1 -0
  337. package/fesm2020/table.mjs +2295 -0
  338. package/fesm2020/table.mjs.map +1 -0
  339. package/fesm2020/testing/protractor.mjs +322 -0
  340. package/fesm2020/testing/protractor.mjs.map +1 -0
  341. package/fesm2020/testing/selenium-webdriver.mjs +362 -0
  342. package/fesm2020/testing/selenium-webdriver.mjs.map +1 -0
  343. package/fesm2020/testing/testbed.mjs +780 -0
  344. package/fesm2020/testing/testbed.mjs.map +1 -0
  345. package/fesm2020/testing.mjs +719 -0
  346. package/fesm2020/testing.mjs.map +1 -0
  347. package/{fesm2015/text-field.js → fesm2020/text-field.mjs} +83 -68
  348. package/fesm2020/text-field.mjs.map +1 -0
  349. package/fesm2020/tree.mjs +967 -0
  350. package/fesm2020/tree.mjs.map +1 -0
  351. package/keycodes/package.json +5 -5
  352. package/layout/breakpoints-observer.d.ts +3 -7
  353. package/layout/layout-module.d.ts +4 -0
  354. package/layout/media-matcher.d.ts +3 -0
  355. package/layout/package.json +5 -5
  356. package/observers/observe-content.d.ts +10 -0
  357. package/observers/package.json +5 -5
  358. package/overlay/dispatchers/base-overlay-dispatcher.d.ts +3 -7
  359. package/overlay/dispatchers/overlay-keyboard-dispatcher.d.ts +3 -7
  360. package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +6 -7
  361. package/overlay/fullscreen-overlay-container.d.ts +3 -0
  362. package/overlay/index.d.ts +0 -2
  363. package/overlay/overlay-container.d.ts +3 -7
  364. package/overlay/overlay-directives.d.ts +5 -0
  365. package/overlay/overlay-module.d.ts +8 -7
  366. package/overlay/overlay.d.ts +3 -0
  367. package/overlay/package.json +5 -5
  368. package/overlay/position/flexible-connected-position-strategy.d.ts +2 -2
  369. package/overlay/position/overlay-position-builder.d.ts +3 -0
  370. package/overlay/position/scroll-clip.d.ts +5 -2
  371. package/overlay/scroll/index.d.ts +1 -1
  372. package/overlay/scroll/scroll-strategy-options.d.ts +3 -0
  373. package/package.json +219 -7
  374. package/platform/package.json +5 -5
  375. package/platform/platform-module.d.ts +4 -7
  376. package/platform/platform.d.ts +3 -7
  377. package/portal/package.json +5 -5
  378. package/portal/portal-directives.d.ts +12 -0
  379. package/schematics/ng-add/index.js +3 -3
  380. package/schematics/ng-add/index.mjs +3 -3
  381. package/schematics/ng-add/package-config.js +4 -2
  382. package/schematics/ng-add/package-config.mjs +4 -2
  383. package/schematics/ng-add/schema.js +1 -1
  384. package/schematics/ng-add/schema.mjs +1 -1
  385. package/schematics/ng-generate/drag-drop/index.js +6 -6
  386. package/schematics/ng-generate/drag-drop/index.mjs +6 -6
  387. package/schematics/ng-update/data/attribute-selectors.js +7 -5
  388. package/schematics/ng-update/data/attribute-selectors.mjs +7 -5
  389. package/schematics/ng-update/data/class-names.js +13 -11
  390. package/schematics/ng-update/data/class-names.mjs +13 -11
  391. package/schematics/ng-update/data/constructor-checks.js +28 -20
  392. package/schematics/ng-update/data/constructor-checks.mjs +28 -20
  393. package/schematics/ng-update/data/css-selectors.js +2 -2
  394. package/schematics/ng-update/data/css-selectors.mjs +2 -2
  395. package/schematics/ng-update/data/element-selectors.js +2 -2
  396. package/schematics/ng-update/data/element-selectors.mjs +2 -2
  397. package/schematics/ng-update/data/input-names.js +40 -16
  398. package/schematics/ng-update/data/input-names.mjs +40 -16
  399. package/schematics/ng-update/data/method-call-checks.js +32 -18
  400. package/schematics/ng-update/data/method-call-checks.mjs +32 -18
  401. package/schematics/ng-update/data/output-names.js +8 -6
  402. package/schematics/ng-update/data/output-names.mjs +8 -6
  403. package/schematics/ng-update/data/property-names.js +40 -32
  404. package/schematics/ng-update/data/property-names.mjs +40 -32
  405. package/schematics/ng-update/devkit-file-system.js +2 -2
  406. package/schematics/ng-update/devkit-file-system.mjs +2 -2
  407. package/schematics/ng-update/devkit-migration-rule.js +8 -7
  408. package/schematics/ng-update/devkit-migration-rule.mjs +8 -7
  409. package/schematics/ng-update/devkit-migration.d.ts +1 -1
  410. package/schematics/ng-update/devkit-migration.js +1 -1
  411. package/schematics/ng-update/devkit-migration.mjs +1 -1
  412. package/schematics/ng-update/find-stylesheets.js +3 -3
  413. package/schematics/ng-update/find-stylesheets.mjs +3 -3
  414. package/schematics/ng-update/html-parsing/angular.js +7 -7
  415. package/schematics/ng-update/html-parsing/angular.mjs +7 -7
  416. package/schematics/ng-update/html-parsing/elements.js +2 -2
  417. package/schematics/ng-update/html-parsing/elements.mjs +2 -2
  418. package/schematics/ng-update/index.js +11 -9
  419. package/schematics/ng-update/index.mjs +11 -9
  420. package/schematics/ng-update/migrations/attribute-selectors.js +11 -7
  421. package/schematics/ng-update/migrations/attribute-selectors.mjs +11 -7
  422. package/schematics/ng-update/migrations/class-inheritance.js +3 -3
  423. package/schematics/ng-update/migrations/class-inheritance.mjs +3 -3
  424. package/schematics/ng-update/migrations/class-names.js +7 -6
  425. package/schematics/ng-update/migrations/class-names.mjs +7 -6
  426. package/schematics/ng-update/migrations/constructor-signature.js +16 -13
  427. package/schematics/ng-update/migrations/constructor-signature.mjs +16 -13
  428. package/schematics/ng-update/migrations/css-selectors.js +7 -6
  429. package/schematics/ng-update/migrations/css-selectors.mjs +7 -6
  430. package/schematics/ng-update/migrations/element-selectors.js +7 -6
  431. package/schematics/ng-update/migrations/element-selectors.mjs +7 -6
  432. package/schematics/ng-update/migrations/input-names.js +8 -9
  433. package/schematics/ng-update/migrations/input-names.mjs +8 -9
  434. package/schematics/ng-update/migrations/method-call-arguments.js +4 -3
  435. package/schematics/ng-update/migrations/method-call-arguments.mjs +4 -3
  436. package/schematics/ng-update/migrations/misc-template.js +3 -3
  437. package/schematics/ng-update/migrations/misc-template.mjs +3 -3
  438. package/schematics/ng-update/migrations/output-names.js +7 -8
  439. package/schematics/ng-update/migrations/output-names.mjs +7 -8
  440. package/schematics/ng-update/migrations/property-names.js +4 -3
  441. package/schematics/ng-update/migrations/property-names.mjs +4 -3
  442. package/schematics/ng-update/migrations/symbol-removal.js +2 -2
  443. package/schematics/ng-update/migrations/symbol-removal.mjs +2 -2
  444. package/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.d.ts +14 -0
  445. package/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.js +38 -0
  446. package/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.mjs +38 -0
  447. package/schematics/ng-update/typescript/base-types.js +1 -1
  448. package/schematics/ng-update/typescript/base-types.mjs +1 -1
  449. package/schematics/ng-update/typescript/literal.d.ts +1 -1
  450. package/schematics/ng-update/typescript/literal.js +1 -1
  451. package/schematics/ng-update/typescript/literal.mjs +1 -1
  452. package/schematics/ng-update/typescript/module-specifiers.js +5 -5
  453. package/schematics/ng-update/typescript/module-specifiers.mjs +5 -5
  454. package/schematics/ng-update/upgrade-data.js +2 -2
  455. package/schematics/ng-update/upgrade-data.mjs +2 -2
  456. package/schematics/package.json +3 -0
  457. package/schematics/paths.js +3 -3
  458. package/schematics/paths.mjs +3 -3
  459. package/schematics/update-tool/component-resource-collector.js +10 -10
  460. package/schematics/update-tool/component-resource-collector.mjs +10 -10
  461. package/schematics/update-tool/file-system.js +1 -1
  462. package/schematics/update-tool/file-system.mjs +1 -1
  463. package/schematics/update-tool/index.d.ts +4 -1
  464. package/schematics/update-tool/index.js +9 -5
  465. package/schematics/update-tool/index.mjs +9 -5
  466. package/schematics/update-tool/migration.d.ts +1 -1
  467. package/schematics/update-tool/migration.js +1 -1
  468. package/schematics/update-tool/migration.mjs +1 -1
  469. package/schematics/update-tool/target-version.js +1 -1
  470. package/schematics/update-tool/target-version.mjs +1 -1
  471. package/schematics/update-tool/utils/decorators.js +8 -4
  472. package/schematics/update-tool/utils/decorators.mjs +8 -4
  473. package/schematics/update-tool/utils/functions.js +1 -1
  474. package/schematics/update-tool/utils/functions.mjs +1 -1
  475. package/schematics/update-tool/utils/imports.js +2 -2
  476. package/schematics/update-tool/utils/imports.mjs +2 -2
  477. package/schematics/update-tool/utils/line-mappings.js +1 -1
  478. package/schematics/update-tool/utils/line-mappings.mjs +1 -1
  479. package/schematics/update-tool/utils/parse-tsconfig.js +2 -2
  480. package/schematics/update-tool/utils/parse-tsconfig.mjs +2 -2
  481. package/schematics/update-tool/utils/property-name.js +1 -1
  482. package/schematics/update-tool/utils/property-name.mjs +1 -1
  483. package/schematics/update-tool/utils/virtual-host.d.ts +1 -1
  484. package/schematics/update-tool/utils/virtual-host.js +3 -3
  485. package/schematics/update-tool/utils/virtual-host.mjs +3 -3
  486. package/schematics/update-tool/version-changes.js +1 -1
  487. package/schematics/update-tool/version-changes.mjs +1 -1
  488. package/schematics/utils/ast/ng-module-imports.js +5 -3
  489. package/schematics/utils/ast/ng-module-imports.mjs +5 -3
  490. package/schematics/utils/ast.js +5 -5
  491. package/schematics/utils/ast.mjs +5 -5
  492. package/schematics/utils/build-component.js +32 -38
  493. package/schematics/utils/build-component.mjs +32 -38
  494. package/schematics/utils/get-project.js +1 -1
  495. package/schematics/utils/get-project.mjs +1 -1
  496. package/schematics/utils/html-manipulation.js +8 -7
  497. package/schematics/utils/html-manipulation.mjs +8 -7
  498. package/schematics/utils/parse5-element.js +9 -10
  499. package/schematics/utils/parse5-element.mjs +9 -10
  500. package/schematics/utils/project-index-file.js +2 -2
  501. package/schematics/utils/project-index-file.mjs +2 -2
  502. package/schematics/utils/project-main-file.js +2 -2
  503. package/schematics/utils/project-main-file.mjs +2 -2
  504. package/schematics/utils/project-style-file.js +7 -9
  505. package/schematics/utils/project-style-file.mjs +7 -9
  506. package/schematics/utils/project-targets.js +1 -1
  507. package/schematics/utils/project-targets.mjs +1 -1
  508. package/schematics/utils/project-tsconfig-paths.js +4 -4
  509. package/schematics/utils/project-tsconfig-paths.mjs +4 -4
  510. package/schematics/utils/schematic-options.js +7 -5
  511. package/schematics/utils/schematic-options.mjs +7 -5
  512. package/schematics/utils/vendored-ast-utils/index.js +17 -18
  513. package/schematics/utils/vendored-ast-utils/index.mjs +17 -18
  514. package/scrolling/fixed-size-virtual-scroll.d.ts +3 -0
  515. package/scrolling/package.json +5 -5
  516. package/scrolling/scroll-dispatcher.d.ts +3 -7
  517. package/scrolling/scrollable.d.ts +3 -0
  518. package/scrolling/scrolling-module.d.ts +13 -7
  519. package/scrolling/viewport-ruler.d.ts +11 -1
  520. package/scrolling/virtual-for-of.d.ts +3 -0
  521. package/scrolling/virtual-scroll-viewport.d.ts +3 -0
  522. package/stepper/package.json +5 -5
  523. package/stepper/step-header.d.ts +3 -0
  524. package/stepper/step-label.d.ts +3 -0
  525. package/stepper/stepper-button.d.ts +5 -7
  526. package/stepper/stepper-module.d.ts +9 -7
  527. package/stepper/stepper.d.ts +5 -7
  528. package/table/cell.d.ts +15 -0
  529. package/table/coalesced-style-scheduler.d.ts +3 -0
  530. package/table/package.json +5 -5
  531. package/table/row.d.ts +19 -0
  532. package/table/table-module.d.ts +9 -7
  533. package/table/table.d.ts +13 -0
  534. package/table/text-column.d.ts +3 -0
  535. package/testing/package.json +5 -5
  536. package/testing/protractor/package.json +5 -5
  537. package/testing/selenium-webdriver/package.json +5 -5
  538. package/testing/testbed/package.json +5 -5
  539. package/testing/testbed/proxy-zone-types.d.ts +1 -1
  540. package/testing/testbed/zone-types.d.ts +1 -1
  541. package/text-field/autofill.d.ts +5 -0
  542. package/text-field/autosize.d.ts +3 -0
  543. package/text-field/package.json +5 -5
  544. package/text-field/text-field-module.d.ts +7 -7
  545. package/tree/control/base-tree-control.d.ts +1 -1
  546. package/tree/control/nested-tree-control.d.ts +2 -2
  547. package/tree/nested-node.d.ts +3 -0
  548. package/tree/node.d.ts +3 -0
  549. package/tree/outlet.d.ts +3 -0
  550. package/tree/package.json +5 -5
  551. package/tree/padding.d.ts +3 -0
  552. package/tree/toggle.d.ts +3 -0
  553. package/tree/tree-module.d.ts +10 -7
  554. package/tree/tree.d.ts +5 -0
  555. package/a11y/index.metadata.json +0 -1
  556. package/accordion/index.metadata.json +0 -1
  557. package/bidi/index.metadata.json +0 -1
  558. package/bundles/cdk-a11y.umd.js +0 -2752
  559. package/bundles/cdk-a11y.umd.js.map +0 -1
  560. package/bundles/cdk-accordion.umd.js +0 -262
  561. package/bundles/cdk-accordion.umd.js.map +0 -1
  562. package/bundles/cdk-bidi.umd.js +0 -206
  563. package/bundles/cdk-bidi.umd.js.map +0 -1
  564. package/bundles/cdk-clipboard.umd.js +0 -278
  565. package/bundles/cdk-clipboard.umd.js.map +0 -1
  566. package/bundles/cdk-coercion.umd.js +0 -477
  567. package/bundles/cdk-coercion.umd.js.map +0 -1
  568. package/bundles/cdk-collections.umd.js +0 -846
  569. package/bundles/cdk-collections.umd.js.map +0 -1
  570. package/bundles/cdk-drag-drop.umd.js +0 -3915
  571. package/bundles/cdk-drag-drop.umd.js.map +0 -1
  572. package/bundles/cdk-keycodes.umd.js +0 -292
  573. package/bundles/cdk-keycodes.umd.js.map +0 -1
  574. package/bundles/cdk-layout.umd.js +0 -284
  575. package/bundles/cdk-layout.umd.js.map +0 -1
  576. package/bundles/cdk-observers.umd.js +0 -242
  577. package/bundles/cdk-observers.umd.js.map +0 -1
  578. package/bundles/cdk-overlay.umd.js +0 -3417
  579. package/bundles/cdk-overlay.umd.js.map +0 -1
  580. package/bundles/cdk-platform.umd.js +0 -397
  581. package/bundles/cdk-platform.umd.js.map +0 -1
  582. package/bundles/cdk-portal.umd.js +0 -1008
  583. package/bundles/cdk-portal.umd.js.map +0 -1
  584. package/bundles/cdk-scrolling.umd.js +0 -1787
  585. package/bundles/cdk-scrolling.umd.js.map +0 -1
  586. package/bundles/cdk-stepper.umd.js +0 -648
  587. package/bundles/cdk-stepper.umd.js.map +0 -1
  588. package/bundles/cdk-table.umd.js +0 -2730
  589. package/bundles/cdk-table.umd.js.map +0 -1
  590. package/bundles/cdk-testing-protractor.umd.js +0 -833
  591. package/bundles/cdk-testing-protractor.umd.js.map +0 -1
  592. package/bundles/cdk-testing-selenium-webdriver.umd.js +0 -1002
  593. package/bundles/cdk-testing-selenium-webdriver.umd.js.map +0 -1
  594. package/bundles/cdk-testing-testbed.umd.js +0 -1396
  595. package/bundles/cdk-testing-testbed.umd.js.map +0 -1
  596. package/bundles/cdk-testing.umd.js +0 -1285
  597. package/bundles/cdk-testing.umd.js.map +0 -1
  598. package/bundles/cdk-text-field.umd.js +0 -494
  599. package/bundles/cdk-text-field.umd.js.map +0 -1
  600. package/bundles/cdk-tree.umd.js +0 -1308
  601. package/bundles/cdk-tree.umd.js.map +0 -1
  602. package/bundles/cdk.umd.js +0 -38
  603. package/bundles/cdk.umd.js.map +0 -1
  604. package/clipboard/index.metadata.json +0 -1
  605. package/collections/index.metadata.json +0 -1
  606. package/drag-drop/index.metadata.json +0 -1
  607. package/esm2015/a11y/a11y-module.js +0 -30
  608. package/esm2015/a11y/a11y.externs.js +0 -6
  609. package/esm2015/a11y/aria-describer/aria-describer.js +0 -213
  610. package/esm2015/a11y/fake-event-detection.js +0 -28
  611. package/esm2015/a11y/focus-monitor/focus-monitor.js +0 -394
  612. package/esm2015/a11y/focus-trap/configurable-focus-trap-factory.js +0 -52
  613. package/esm2015/a11y/focus-trap/configurable-focus-trap.js +0 -49
  614. package/esm2015/a11y/focus-trap/event-listener-inert-strategy.js +0 -62
  615. package/esm2015/a11y/focus-trap/focus-trap-inert-strategy.js +0 -11
  616. package/esm2015/a11y/focus-trap/focus-trap-manager.js +0 -51
  617. package/esm2015/a11y/focus-trap/focus-trap.js +0 -391
  618. package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +0 -92
  619. package/esm2015/a11y/index.js +0 -6
  620. package/esm2015/a11y/input-modality/input-modality-detector.js +0 -171
  621. package/esm2015/a11y/interactivity-checker/interactivity-checker.js +0 -237
  622. package/esm2015/a11y/key-manager/list-key-manager.js +0 -317
  623. package/esm2015/a11y/live-announcer/live-announcer-tokens.js +0 -19
  624. package/esm2015/a11y/live-announcer/live-announcer.js +0 -167
  625. package/esm2015/accordion/accordion-item.js +0 -146
  626. package/esm2015/accordion/accordion-module.js +0 -19
  627. package/esm2015/accordion/accordion.externs.js +0 -6
  628. package/esm2015/accordion/accordion.js +0 -63
  629. package/esm2015/accordion/index.js +0 -6
  630. package/esm2015/bidi/bidi-module.js +0 -18
  631. package/esm2015/bidi/bidi.externs.js +0 -6
  632. package/esm2015/bidi/dir.js +0 -58
  633. package/esm2015/bidi/directionality.js +0 -44
  634. package/esm2015/bidi/index.js +0 -6
  635. package/esm2015/cdk.externs.js +0 -0
  636. package/esm2015/clipboard/clipboard-module.js +0 -18
  637. package/esm2015/clipboard/clipboard.externs.js +0 -6
  638. package/esm2015/clipboard/clipboard.js +0 -52
  639. package/esm2015/clipboard/copy-to-clipboard.js +0 -90
  640. package/esm2015/clipboard/pending-copy.js +0 -68
  641. package/esm2015/coercion/coercion.externs.js +0 -0
  642. package/esm2015/collections/collection-viewer.js +0 -9
  643. package/esm2015/collections/collections.externs.js +0 -6
  644. package/esm2015/collections/dispose-view-repeater-strategy.js +0 -48
  645. package/esm2015/collections/recycle-view-repeater-strategy.js +0 -125
  646. package/esm2015/collections/tree-adapter.js +0 -9
  647. package/esm2015/collections/unique-selection-dispatcher.js +0 -53
  648. package/esm2015/collections/view-repeater.js +0 -14
  649. package/esm2015/drag-drop/client-rect.js +0 -60
  650. package/esm2015/drag-drop/clone-node.js +0 -65
  651. package/esm2015/drag-drop/directives/assertions.js +0 -19
  652. package/esm2015/drag-drop/directives/drag-handle.js +0 -57
  653. package/esm2015/drag-drop/directives/drag-placeholder.js +0 -36
  654. package/esm2015/drag-drop/directives/drag-preview.js +0 -42
  655. package/esm2015/drag-drop/directives/drag.js +0 -407
  656. package/esm2015/drag-drop/directives/drop-list-group.js +0 -47
  657. package/esm2015/drag-drop/directives/drop-list.js +0 -301
  658. package/esm2015/drag-drop/drag-drop-module.js +0 -43
  659. package/esm2015/drag-drop/drag-drop-registry.js +0 -231
  660. package/esm2015/drag-drop/drag-drop.externs.js +0 -6
  661. package/esm2015/drag-drop/drag-drop.js +0 -59
  662. package/esm2015/drag-drop/drag-events.js +0 -9
  663. package/esm2015/drag-drop/drag-ref.js +0 -1110
  664. package/esm2015/drag-drop/drag-styling.js +0 -69
  665. package/esm2015/drag-drop/drag-utils.js +0 -60
  666. package/esm2015/drag-drop/drop-list-ref.js +0 -813
  667. package/esm2015/drag-drop/transition-duration.js +0 -36
  668. package/esm2015/keycodes/keycodes.externs.js +0 -6
  669. package/esm2015/layout/breakpoints-observer.js +0 -106
  670. package/esm2015/layout/layout-module.js +0 -14
  671. package/esm2015/layout/layout.externs.js +0 -6
  672. package/esm2015/layout/media-matcher.js +0 -85
  673. package/esm2015/observers/observe-content.js +0 -179
  674. package/esm2015/observers/observers.externs.js +0 -6
  675. package/esm2015/overlay/dispatchers/base-overlay-dispatcher.js +0 -51
  676. package/esm2015/overlay/dispatchers/overlay-keyboard-dispatcher.js +0 -62
  677. package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +0 -97
  678. package/esm2015/overlay/fullscreen-overlay-container.js +0 -94
  679. package/esm2015/overlay/index.js +0 -7
  680. package/esm2015/overlay/overlay-config.js +0 -45
  681. package/esm2015/overlay/overlay-container.js +0 -85
  682. package/esm2015/overlay/overlay-directives.js +0 -352
  683. package/esm2015/overlay/overlay-module.js +0 -27
  684. package/esm2015/overlay/overlay-ref.js +0 -409
  685. package/esm2015/overlay/overlay.externs.js +0 -6
  686. package/esm2015/overlay/overlay.js +0 -119
  687. package/esm2015/overlay/position/connected-position.js +0 -94
  688. package/esm2015/overlay/position/flexible-connected-position-strategy.js +0 -960
  689. package/esm2015/overlay/position/global-position-strategy.js +0 -197
  690. package/esm2015/overlay/position/overlay-position-builder.js +0 -52
  691. package/esm2015/overlay/position/scroll-clip.js +0 -42
  692. package/esm2015/overlay/scroll/close-scroll-strategy.js +0 -61
  693. package/esm2015/overlay/scroll/scroll-strategy-options.js +0 -57
  694. package/esm2015/platform/features/passive-listeners.js +0 -36
  695. package/esm2015/platform/features/scrolling.js +0 -85
  696. package/esm2015/platform/features/test-environment.js +0 -16
  697. package/esm2015/platform/platform-module.js +0 -14
  698. package/esm2015/platform/platform.externs.js +0 -6
  699. package/esm2015/platform/platform.js +0 -77
  700. package/esm2015/portal/dom-portal-outlet.js +0 -136
  701. package/esm2015/portal/portal-directives.js +0 -221
  702. package/esm2015/portal/portal-injector.js +0 -28
  703. package/esm2015/portal/portal.externs.js +0 -6
  704. package/esm2015/portal/portal.js +0 -179
  705. package/esm2015/scrolling/fixed-size-virtual-scroll.js +0 -188
  706. package/esm2015/scrolling/scroll-dispatcher.js +0 -163
  707. package/esm2015/scrolling/scrollable.js +0 -173
  708. package/esm2015/scrolling/scrolling-module.js +0 -49
  709. package/esm2015/scrolling/scrolling.externs.js +0 -6
  710. package/esm2015/scrolling/viewport-ruler.js +0 -139
  711. package/esm2015/scrolling/virtual-for-of.js +0 -293
  712. package/esm2015/scrolling/virtual-scroll-strategy.js +0 -11
  713. package/esm2015/scrolling/virtual-scroll-viewport.js +0 -371
  714. package/esm2015/stepper/step-header.js +0 -29
  715. package/esm2015/stepper/step-label.js +0 -22
  716. package/esm2015/stepper/stepper-button.js +0 -72
  717. package/esm2015/stepper/stepper-module.js +0 -37
  718. package/esm2015/stepper/stepper.externs.js +0 -6
  719. package/esm2015/stepper/stepper.js +0 -428
  720. package/esm2015/table/can-stick.js +0 -42
  721. package/esm2015/table/cell.js +0 -211
  722. package/esm2015/table/coalesced-style-scheduler.js +0 -89
  723. package/esm2015/table/row.js +0 -244
  724. package/esm2015/table/sticky-position-listener.js +0 -11
  725. package/esm2015/table/sticky-styler.js +0 -336
  726. package/esm2015/table/table-module.js +0 -47
  727. package/esm2015/table/table.externs.js +0 -6
  728. package/esm2015/table/table.js +0 -987
  729. package/esm2015/table/text-column.js +0 -127
  730. package/esm2015/testing/change-detection.js +0 -110
  731. package/esm2015/testing/component-harness.js +0 -344
  732. package/esm2015/testing/harness-environment.js +0 -219
  733. package/esm2015/testing/protractor/protractor-element.js +0 -274
  734. package/esm2015/testing/protractor/protractor-harness-environment.js +0 -79
  735. package/esm2015/testing/protractor/protractor.externs.js +0 -0
  736. package/esm2015/testing/selenium-webdriver/selenium-web-driver-element.js +0 -241
  737. package/esm2015/testing/selenium-webdriver/selenium-web-driver-harness-environment.js +0 -97
  738. package/esm2015/testing/selenium-webdriver/selenium-webdriver.externs.js +0 -0
  739. package/esm2015/testing/test-element.js +0 -48
  740. package/esm2015/testing/testbed/fake-events/dispatch-events.js +0 -53
  741. package/esm2015/testing/testbed/fake-events/element-focus.js +0 -39
  742. package/esm2015/testing/testbed/fake-events/event-objects.js +0 -107
  743. package/esm2015/testing/testbed/fake-events/type-in-element.js +0 -79
  744. package/esm2015/testing/testbed/task-state-zone-interceptor.js +0 -82
  745. package/esm2015/testing/testbed/testbed-harness-environment.js +0 -173
  746. package/esm2015/testing/testbed/testbed.externs.js +0 -0
  747. package/esm2015/testing/testbed/unit-test-element.js +0 -266
  748. package/esm2015/testing/testing.externs.js +0 -0
  749. package/esm2015/testing/text-filtering.js +0 -23
  750. package/esm2015/text-field/autofill.js +0 -117
  751. package/esm2015/text-field/autosize.js +0 -293
  752. package/esm2015/text-field/text-field-module.js +0 -21
  753. package/esm2015/text-field/text-field.externs.js +0 -6
  754. package/esm2015/tree/control/nested-tree-control.js +0 -59
  755. package/esm2015/tree/nested-node.js +0 -112
  756. package/esm2015/tree/node.js +0 -36
  757. package/esm2015/tree/outlet.js +0 -34
  758. package/esm2015/tree/padding.js +0 -119
  759. package/esm2015/tree/toggle.js +0 -46
  760. package/esm2015/tree/tree-module.js +0 -32
  761. package/esm2015/tree/tree.externs.js +0 -6
  762. package/esm2015/tree/tree.js +0 -345
  763. package/fesm2015/a11y.js.map +0 -1
  764. package/fesm2015/accordion.js.map +0 -1
  765. package/fesm2015/bidi.js.map +0 -1
  766. package/fesm2015/cdk.js.map +0 -1
  767. package/fesm2015/clipboard.js.map +0 -1
  768. package/fesm2015/coercion.js.map +0 -1
  769. package/fesm2015/collections.js.map +0 -1
  770. package/fesm2015/drag-drop.js.map +0 -1
  771. package/fesm2015/keycodes.js.map +0 -1
  772. package/fesm2015/layout.js.map +0 -1
  773. package/fesm2015/observers.js.map +0 -1
  774. package/fesm2015/overlay.js.map +0 -1
  775. package/fesm2015/platform.js.map +0 -1
  776. package/fesm2015/portal.js.map +0 -1
  777. package/fesm2015/scrolling.js.map +0 -1
  778. package/fesm2015/stepper.js.map +0 -1
  779. package/fesm2015/table.js.map +0 -1
  780. package/fesm2015/testing/protractor.js.map +0 -1
  781. package/fesm2015/testing/selenium-webdriver.js.map +0 -1
  782. package/fesm2015/testing/testbed.js.map +0 -1
  783. package/fesm2015/testing.js.map +0 -1
  784. package/fesm2015/text-field.js.map +0 -1
  785. package/fesm2015/tree.js.map +0 -1
  786. package/keycodes/index.metadata.json +0 -1
  787. package/layout/index.metadata.json +0 -1
  788. package/observers/index.metadata.json +0 -1
  789. package/overlay/index.metadata.json +0 -1
  790. package/platform/index.metadata.json +0 -1
  791. package/portal/index.metadata.json +0 -1
  792. package/scrolling/index.metadata.json +0 -1
  793. package/stepper/index.metadata.json +0 -1
  794. package/table/index.metadata.json +0 -1
  795. package/text-field/index.metadata.json +0 -1
  796. package/tree/index.metadata.json +0 -1
@@ -0,0 +1,3667 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Inject, InjectionToken, Directive, Input, EventEmitter, Optional, SkipSelf, Output, Self, ContentChildren, ContentChild, NgModule } from '@angular/core';
3
+ import { DOCUMENT } from '@angular/common';
4
+ import { _getEventTarget, normalizePassiveListenerOptions, _getShadowRoot } from '@angular/cdk/platform';
5
+ import { coerceBooleanProperty, coerceElement, coerceArray, coerceNumberProperty } from '@angular/cdk/coercion';
6
+ import { isFakeTouchstartFromScreenReader, isFakeMousedownFromScreenReader } from '@angular/cdk/a11y';
7
+ import { Subject, Subscription, interval, animationFrameScheduler, Observable, merge } from 'rxjs';
8
+ import { takeUntil, startWith, map, take, tap, switchMap } from 'rxjs/operators';
9
+ import * as i1 from '@angular/cdk/scrolling';
10
+ import { CdkScrollableModule } from '@angular/cdk/scrolling';
11
+ import * as i3 from '@angular/cdk/bidi';
12
+
13
+ /**
14
+ * @license
15
+ * Copyright Google LLC All Rights Reserved.
16
+ *
17
+ * Use of this source code is governed by an MIT-style license that can be
18
+ * found in the LICENSE file at https://angular.io/license
19
+ */
20
+ /**
21
+ * Shallow-extends a stylesheet object with another stylesheet-like object.
22
+ * Note that the keys in `source` have to be dash-cased.
23
+ * @docs-private
24
+ */
25
+ function extendStyles(dest, source, importantProperties) {
26
+ for (let key in source) {
27
+ if (source.hasOwnProperty(key)) {
28
+ const value = source[key];
29
+ if (value) {
30
+ dest.setProperty(key, value, (importantProperties === null || importantProperties === void 0 ? void 0 : importantProperties.has(key)) ? 'important' : '');
31
+ }
32
+ else {
33
+ dest.removeProperty(key);
34
+ }
35
+ }
36
+ }
37
+ return dest;
38
+ }
39
+ /**
40
+ * Toggles whether the native drag interactions should be enabled for an element.
41
+ * @param element Element on which to toggle the drag interactions.
42
+ * @param enable Whether the drag interactions should be enabled.
43
+ * @docs-private
44
+ */
45
+ function toggleNativeDragInteractions(element, enable) {
46
+ const userSelect = enable ? '' : 'none';
47
+ extendStyles(element.style, {
48
+ 'touch-action': enable ? '' : 'none',
49
+ '-webkit-user-drag': enable ? '' : 'none',
50
+ '-webkit-tap-highlight-color': enable ? '' : 'transparent',
51
+ 'user-select': userSelect,
52
+ '-ms-user-select': userSelect,
53
+ '-webkit-user-select': userSelect,
54
+ '-moz-user-select': userSelect,
55
+ });
56
+ }
57
+ /**
58
+ * Toggles whether an element is visible while preserving its dimensions.
59
+ * @param element Element whose visibility to toggle
60
+ * @param enable Whether the element should be visible.
61
+ * @param importantProperties Properties to be set as `!important`.
62
+ * @docs-private
63
+ */
64
+ function toggleVisibility(element, enable, importantProperties) {
65
+ extendStyles(element.style, {
66
+ position: enable ? '' : 'fixed',
67
+ top: enable ? '' : '0',
68
+ opacity: enable ? '' : '0',
69
+ left: enable ? '' : '-999em',
70
+ }, importantProperties);
71
+ }
72
+ /**
73
+ * Combines a transform string with an optional other transform
74
+ * that exited before the base transform was applied.
75
+ */
76
+ function combineTransforms(transform, initialTransform) {
77
+ return initialTransform && initialTransform != 'none'
78
+ ? transform + ' ' + initialTransform
79
+ : transform;
80
+ }
81
+
82
+ /**
83
+ * @license
84
+ * Copyright Google LLC All Rights Reserved.
85
+ *
86
+ * Use of this source code is governed by an MIT-style license that can be
87
+ * found in the LICENSE file at https://angular.io/license
88
+ */
89
+ /** Parses a CSS time value to milliseconds. */
90
+ function parseCssTimeUnitsToMs(value) {
91
+ // Some browsers will return it in seconds, whereas others will return milliseconds.
92
+ const multiplier = value.toLowerCase().indexOf('ms') > -1 ? 1 : 1000;
93
+ return parseFloat(value) * multiplier;
94
+ }
95
+ /** Gets the transform transition duration, including the delay, of an element in milliseconds. */
96
+ function getTransformTransitionDurationInMs(element) {
97
+ const computedStyle = getComputedStyle(element);
98
+ const transitionedProperties = parseCssPropertyValue(computedStyle, 'transition-property');
99
+ const property = transitionedProperties.find(prop => prop === 'transform' || prop === 'all');
100
+ // If there's no transition for `all` or `transform`, we shouldn't do anything.
101
+ if (!property) {
102
+ return 0;
103
+ }
104
+ // Get the index of the property that we're interested in and match
105
+ // it up to the same index in `transition-delay` and `transition-duration`.
106
+ const propertyIndex = transitionedProperties.indexOf(property);
107
+ const rawDurations = parseCssPropertyValue(computedStyle, 'transition-duration');
108
+ const rawDelays = parseCssPropertyValue(computedStyle, 'transition-delay');
109
+ return (parseCssTimeUnitsToMs(rawDurations[propertyIndex]) +
110
+ parseCssTimeUnitsToMs(rawDelays[propertyIndex]));
111
+ }
112
+ /** Parses out multiple values from a computed style into an array. */
113
+ function parseCssPropertyValue(computedStyle, name) {
114
+ const value = computedStyle.getPropertyValue(name);
115
+ return value.split(',').map(part => part.trim());
116
+ }
117
+
118
+ /**
119
+ * @license
120
+ * Copyright Google LLC All Rights Reserved.
121
+ *
122
+ * Use of this source code is governed by an MIT-style license that can be
123
+ * found in the LICENSE file at https://angular.io/license
124
+ */
125
+ /** Gets a mutable version of an element's bounding `ClientRect`. */
126
+ function getMutableClientRect(element) {
127
+ const clientRect = element.getBoundingClientRect();
128
+ // We need to clone the `clientRect` here, because all the values on it are readonly
129
+ // and we need to be able to update them. Also we can't use a spread here, because
130
+ // the values on a `ClientRect` aren't own properties. See:
131
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#Notes
132
+ return {
133
+ top: clientRect.top,
134
+ right: clientRect.right,
135
+ bottom: clientRect.bottom,
136
+ left: clientRect.left,
137
+ width: clientRect.width,
138
+ height: clientRect.height,
139
+ x: clientRect.x,
140
+ y: clientRect.y,
141
+ };
142
+ }
143
+ /**
144
+ * Checks whether some coordinates are within a `ClientRect`.
145
+ * @param clientRect ClientRect that is being checked.
146
+ * @param x Coordinates along the X axis.
147
+ * @param y Coordinates along the Y axis.
148
+ */
149
+ function isInsideClientRect(clientRect, x, y) {
150
+ const { top, bottom, left, right } = clientRect;
151
+ return y >= top && y <= bottom && x >= left && x <= right;
152
+ }
153
+ /**
154
+ * Updates the top/left positions of a `ClientRect`, as well as their bottom/right counterparts.
155
+ * @param clientRect `ClientRect` that should be updated.
156
+ * @param top Amount to add to the `top` position.
157
+ * @param left Amount to add to the `left` position.
158
+ */
159
+ function adjustClientRect(clientRect, top, left) {
160
+ clientRect.top += top;
161
+ clientRect.bottom = clientRect.top + clientRect.height;
162
+ clientRect.left += left;
163
+ clientRect.right = clientRect.left + clientRect.width;
164
+ }
165
+ /**
166
+ * Checks whether the pointer coordinates are close to a ClientRect.
167
+ * @param rect ClientRect to check against.
168
+ * @param threshold Threshold around the ClientRect.
169
+ * @param pointerX Coordinates along the X axis.
170
+ * @param pointerY Coordinates along the Y axis.
171
+ */
172
+ function isPointerNearClientRect(rect, threshold, pointerX, pointerY) {
173
+ const { top, right, bottom, left, width, height } = rect;
174
+ const xThreshold = width * threshold;
175
+ const yThreshold = height * threshold;
176
+ return (pointerY > top - yThreshold &&
177
+ pointerY < bottom + yThreshold &&
178
+ pointerX > left - xThreshold &&
179
+ pointerX < right + xThreshold);
180
+ }
181
+
182
+ /**
183
+ * @license
184
+ * Copyright Google LLC All Rights Reserved.
185
+ *
186
+ * Use of this source code is governed by an MIT-style license that can be
187
+ * found in the LICENSE file at https://angular.io/license
188
+ */
189
+ /** Keeps track of the scroll position and dimensions of the parents of an element. */
190
+ class ParentPositionTracker {
191
+ constructor(_document, _viewportRuler) {
192
+ this._document = _document;
193
+ this._viewportRuler = _viewportRuler;
194
+ /** Cached positions of the scrollable parent elements. */
195
+ this.positions = new Map();
196
+ }
197
+ /** Clears the cached positions. */
198
+ clear() {
199
+ this.positions.clear();
200
+ }
201
+ /** Caches the positions. Should be called at the beginning of a drag sequence. */
202
+ cache(elements) {
203
+ this.clear();
204
+ this.positions.set(this._document, {
205
+ scrollPosition: this._viewportRuler.getViewportScrollPosition(),
206
+ });
207
+ elements.forEach(element => {
208
+ this.positions.set(element, {
209
+ scrollPosition: { top: element.scrollTop, left: element.scrollLeft },
210
+ clientRect: getMutableClientRect(element),
211
+ });
212
+ });
213
+ }
214
+ /** Handles scrolling while a drag is taking place. */
215
+ handleScroll(event) {
216
+ const target = _getEventTarget(event);
217
+ const cachedPosition = this.positions.get(target);
218
+ if (!cachedPosition) {
219
+ return null;
220
+ }
221
+ const scrollPosition = cachedPosition.scrollPosition;
222
+ let newTop;
223
+ let newLeft;
224
+ if (target === this._document) {
225
+ const viewportScrollPosition = this._viewportRuler.getViewportScrollPosition();
226
+ newTop = viewportScrollPosition.top;
227
+ newLeft = viewportScrollPosition.left;
228
+ }
229
+ else {
230
+ newTop = target.scrollTop;
231
+ newLeft = target.scrollLeft;
232
+ }
233
+ const topDifference = scrollPosition.top - newTop;
234
+ const leftDifference = scrollPosition.left - newLeft;
235
+ // Go through and update the cached positions of the scroll
236
+ // parents that are inside the element that was scrolled.
237
+ this.positions.forEach((position, node) => {
238
+ if (position.clientRect && target !== node && target.contains(node)) {
239
+ adjustClientRect(position.clientRect, topDifference, leftDifference);
240
+ }
241
+ });
242
+ scrollPosition.top = newTop;
243
+ scrollPosition.left = newLeft;
244
+ return { top: topDifference, left: leftDifference };
245
+ }
246
+ }
247
+
248
+ /**
249
+ * @license
250
+ * Copyright Google LLC All Rights Reserved.
251
+ *
252
+ * Use of this source code is governed by an MIT-style license that can be
253
+ * found in the LICENSE file at https://angular.io/license
254
+ */
255
+ /** Creates a deep clone of an element. */
256
+ function deepCloneNode(node) {
257
+ const clone = node.cloneNode(true);
258
+ const descendantsWithId = clone.querySelectorAll('[id]');
259
+ const nodeName = node.nodeName.toLowerCase();
260
+ // Remove the `id` to avoid having multiple elements with the same id on the page.
261
+ clone.removeAttribute('id');
262
+ for (let i = 0; i < descendantsWithId.length; i++) {
263
+ descendantsWithId[i].removeAttribute('id');
264
+ }
265
+ if (nodeName === 'canvas') {
266
+ transferCanvasData(node, clone);
267
+ }
268
+ else if (nodeName === 'input' || nodeName === 'select' || nodeName === 'textarea') {
269
+ transferInputData(node, clone);
270
+ }
271
+ transferData('canvas', node, clone, transferCanvasData);
272
+ transferData('input, textarea, select', node, clone, transferInputData);
273
+ return clone;
274
+ }
275
+ /** Matches elements between an element and its clone and allows for their data to be cloned. */
276
+ function transferData(selector, node, clone, callback) {
277
+ const descendantElements = node.querySelectorAll(selector);
278
+ if (descendantElements.length) {
279
+ const cloneElements = clone.querySelectorAll(selector);
280
+ for (let i = 0; i < descendantElements.length; i++) {
281
+ callback(descendantElements[i], cloneElements[i]);
282
+ }
283
+ }
284
+ }
285
+ // Counter for unique cloned radio button names.
286
+ let cloneUniqueId = 0;
287
+ /** Transfers the data of one input element to another. */
288
+ function transferInputData(source, clone) {
289
+ // Browsers throw an error when assigning the value of a file input programmatically.
290
+ if (clone.type !== 'file') {
291
+ clone.value = source.value;
292
+ }
293
+ // Radio button `name` attributes must be unique for radio button groups
294
+ // otherwise original radio buttons can lose their checked state
295
+ // once the clone is inserted in the DOM.
296
+ if (clone.type === 'radio' && clone.name) {
297
+ clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`;
298
+ }
299
+ }
300
+ /** Transfers the data of one canvas element to another. */
301
+ function transferCanvasData(source, clone) {
302
+ const context = clone.getContext('2d');
303
+ if (context) {
304
+ // In some cases `drawImage` can throw (e.g. if the canvas size is 0x0).
305
+ // We can't do much about it so just ignore the error.
306
+ try {
307
+ context.drawImage(source, 0, 0);
308
+ }
309
+ catch (_a) { }
310
+ }
311
+ }
312
+
313
+ /**
314
+ * @license
315
+ * Copyright Google LLC All Rights Reserved.
316
+ *
317
+ * Use of this source code is governed by an MIT-style license that can be
318
+ * found in the LICENSE file at https://angular.io/license
319
+ */
320
+ /** Options that can be used to bind a passive event listener. */
321
+ const passiveEventListenerOptions = normalizePassiveListenerOptions({ passive: true });
322
+ /** Options that can be used to bind an active event listener. */
323
+ const activeEventListenerOptions = normalizePassiveListenerOptions({ passive: false });
324
+ /**
325
+ * Time in milliseconds for which to ignore mouse events, after
326
+ * receiving a touch event. Used to avoid doing double work for
327
+ * touch devices where the browser fires fake mouse events, in
328
+ * addition to touch events.
329
+ */
330
+ const MOUSE_EVENT_IGNORE_TIME = 800;
331
+ /** Inline styles to be set as `!important` while dragging. */
332
+ const dragImportantProperties = new Set([
333
+ // Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.
334
+ 'position',
335
+ ]);
336
+ /**
337
+ * Reference to a draggable item. Used to manipulate or dispose of the item.
338
+ */
339
+ class DragRef {
340
+ constructor(element, _config, _document, _ngZone, _viewportRuler, _dragDropRegistry) {
341
+ this._config = _config;
342
+ this._document = _document;
343
+ this._ngZone = _ngZone;
344
+ this._viewportRuler = _viewportRuler;
345
+ this._dragDropRegistry = _dragDropRegistry;
346
+ /**
347
+ * CSS `transform` applied to the element when it isn't being dragged. We need a
348
+ * passive transform in order for the dragged element to retain its new position
349
+ * after the user has stopped dragging and because we need to know the relative
350
+ * position in case they start dragging again. This corresponds to `element.style.transform`.
351
+ */
352
+ this._passiveTransform = { x: 0, y: 0 };
353
+ /** CSS `transform` that is applied to the element while it's being dragged. */
354
+ this._activeTransform = { x: 0, y: 0 };
355
+ /**
356
+ * Whether the dragging sequence has been started. Doesn't
357
+ * necessarily mean that the element has been moved.
358
+ */
359
+ this._hasStartedDragging = false;
360
+ /** Emits when the item is being moved. */
361
+ this._moveEvents = new Subject();
362
+ /** Subscription to pointer movement events. */
363
+ this._pointerMoveSubscription = Subscription.EMPTY;
364
+ /** Subscription to the event that is dispatched when the user lifts their pointer. */
365
+ this._pointerUpSubscription = Subscription.EMPTY;
366
+ /** Subscription to the viewport being scrolled. */
367
+ this._scrollSubscription = Subscription.EMPTY;
368
+ /** Subscription to the viewport being resized. */
369
+ this._resizeSubscription = Subscription.EMPTY;
370
+ /** Cached reference to the boundary element. */
371
+ this._boundaryElement = null;
372
+ /** Whether the native dragging interactions have been enabled on the root element. */
373
+ this._nativeInteractionsEnabled = true;
374
+ /** Elements that can be used to drag the draggable item. */
375
+ this._handles = [];
376
+ /** Registered handles that are currently disabled. */
377
+ this._disabledHandles = new Set();
378
+ /** Layout direction of the item. */
379
+ this._direction = 'ltr';
380
+ /**
381
+ * Amount of milliseconds to wait after the user has put their
382
+ * pointer down before starting to drag the element.
383
+ */
384
+ this.dragStartDelay = 0;
385
+ this._disabled = false;
386
+ /** Emits as the drag sequence is being prepared. */
387
+ this.beforeStarted = new Subject();
388
+ /** Emits when the user starts dragging the item. */
389
+ this.started = new Subject();
390
+ /** Emits when the user has released a drag item, before any animations have started. */
391
+ this.released = new Subject();
392
+ /** Emits when the user stops dragging an item in the container. */
393
+ this.ended = new Subject();
394
+ /** Emits when the user has moved the item into a new container. */
395
+ this.entered = new Subject();
396
+ /** Emits when the user removes the item its container by dragging it into another container. */
397
+ this.exited = new Subject();
398
+ /** Emits when the user drops the item inside a container. */
399
+ this.dropped = new Subject();
400
+ /**
401
+ * Emits as the user is dragging the item. Use with caution,
402
+ * because this event will fire for every pixel that the user has dragged.
403
+ */
404
+ this.moved = this._moveEvents;
405
+ /** Handler for the `mousedown`/`touchstart` events. */
406
+ this._pointerDown = (event) => {
407
+ this.beforeStarted.next();
408
+ // Delegate the event based on whether it started from a handle or the element itself.
409
+ if (this._handles.length) {
410
+ const targetHandle = this._handles.find(handle => {
411
+ const target = _getEventTarget(event);
412
+ return !!target && (target === handle || handle.contains(target));
413
+ });
414
+ if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {
415
+ this._initializeDragSequence(targetHandle, event);
416
+ }
417
+ }
418
+ else if (!this.disabled) {
419
+ this._initializeDragSequence(this._rootElement, event);
420
+ }
421
+ };
422
+ /** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
423
+ this._pointerMove = (event) => {
424
+ const pointerPosition = this._getPointerPositionOnPage(event);
425
+ if (!this._hasStartedDragging) {
426
+ const distanceX = Math.abs(pointerPosition.x - this._pickupPositionOnPage.x);
427
+ const distanceY = Math.abs(pointerPosition.y - this._pickupPositionOnPage.y);
428
+ const isOverThreshold = distanceX + distanceY >= this._config.dragStartThreshold;
429
+ // Only start dragging after the user has moved more than the minimum distance in either
430
+ // direction. Note that this is preferrable over doing something like `skip(minimumDistance)`
431
+ // in the `pointerMove` subscription, because we're not guaranteed to have one move event
432
+ // per pixel of movement (e.g. if the user moves their pointer quickly).
433
+ if (isOverThreshold) {
434
+ const isDelayElapsed = Date.now() >= this._dragStartTime + this._getDragStartDelay(event);
435
+ const container = this._dropContainer;
436
+ if (!isDelayElapsed) {
437
+ this._endDragSequence(event);
438
+ return;
439
+ }
440
+ // Prevent other drag sequences from starting while something in the container is still
441
+ // being dragged. This can happen while we're waiting for the drop animation to finish
442
+ // and can cause errors, because some elements might still be moving around.
443
+ if (!container || (!container.isDragging() && !container.isReceiving())) {
444
+ // Prevent the default action as soon as the dragging sequence is considered as
445
+ // "started" since waiting for the next event can allow the device to begin scrolling.
446
+ event.preventDefault();
447
+ this._hasStartedDragging = true;
448
+ this._ngZone.run(() => this._startDragSequence(event));
449
+ }
450
+ }
451
+ return;
452
+ }
453
+ // We only need the preview dimensions if we have a boundary element.
454
+ if (this._boundaryElement) {
455
+ // Cache the preview element rect if we haven't cached it already or if
456
+ // we cached it too early before the element dimensions were computed.
457
+ if (!this._previewRect || (!this._previewRect.width && !this._previewRect.height)) {
458
+ this._previewRect = (this._preview || this._rootElement).getBoundingClientRect();
459
+ }
460
+ }
461
+ // We prevent the default action down here so that we know that dragging has started. This is
462
+ // important for touch devices where doing this too early can unnecessarily block scrolling,
463
+ // if there's a dragging delay.
464
+ event.preventDefault();
465
+ const constrainedPointerPosition = this._getConstrainedPointerPosition(pointerPosition);
466
+ this._hasMoved = true;
467
+ this._lastKnownPointerPosition = pointerPosition;
468
+ this._updatePointerDirectionDelta(constrainedPointerPosition);
469
+ if (this._dropContainer) {
470
+ this._updateActiveDropContainer(constrainedPointerPosition, pointerPosition);
471
+ }
472
+ else {
473
+ const activeTransform = this._activeTransform;
474
+ activeTransform.x =
475
+ constrainedPointerPosition.x - this._pickupPositionOnPage.x + this._passiveTransform.x;
476
+ activeTransform.y =
477
+ constrainedPointerPosition.y - this._pickupPositionOnPage.y + this._passiveTransform.y;
478
+ this._applyRootElementTransform(activeTransform.x, activeTransform.y);
479
+ }
480
+ // Since this event gets fired for every pixel while dragging, we only
481
+ // want to fire it if the consumer opted into it. Also we have to
482
+ // re-enter the zone because we run all of the events on the outside.
483
+ if (this._moveEvents.observers.length) {
484
+ this._ngZone.run(() => {
485
+ this._moveEvents.next({
486
+ source: this,
487
+ pointerPosition: constrainedPointerPosition,
488
+ event,
489
+ distance: this._getDragDistance(constrainedPointerPosition),
490
+ delta: this._pointerDirectionDelta,
491
+ });
492
+ });
493
+ }
494
+ };
495
+ /** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
496
+ this._pointerUp = (event) => {
497
+ this._endDragSequence(event);
498
+ };
499
+ this.withRootElement(element).withParent(_config.parentDragRef || null);
500
+ this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
501
+ _dragDropRegistry.registerDragItem(this);
502
+ }
503
+ /** Whether starting to drag this element is disabled. */
504
+ get disabled() {
505
+ return this._disabled || !!(this._dropContainer && this._dropContainer.disabled);
506
+ }
507
+ set disabled(value) {
508
+ const newValue = coerceBooleanProperty(value);
509
+ if (newValue !== this._disabled) {
510
+ this._disabled = newValue;
511
+ this._toggleNativeDragInteractions();
512
+ this._handles.forEach(handle => toggleNativeDragInteractions(handle, newValue));
513
+ }
514
+ }
515
+ /**
516
+ * Returns the element that is being used as a placeholder
517
+ * while the current element is being dragged.
518
+ */
519
+ getPlaceholderElement() {
520
+ return this._placeholder;
521
+ }
522
+ /** Returns the root draggable element. */
523
+ getRootElement() {
524
+ return this._rootElement;
525
+ }
526
+ /**
527
+ * Gets the currently-visible element that represents the drag item.
528
+ * While dragging this is the placeholder, otherwise it's the root element.
529
+ */
530
+ getVisibleElement() {
531
+ return this.isDragging() ? this.getPlaceholderElement() : this.getRootElement();
532
+ }
533
+ /** Registers the handles that can be used to drag the element. */
534
+ withHandles(handles) {
535
+ this._handles = handles.map(handle => coerceElement(handle));
536
+ this._handles.forEach(handle => toggleNativeDragInteractions(handle, this.disabled));
537
+ this._toggleNativeDragInteractions();
538
+ // Delete any lingering disabled handles that may have been destroyed. Note that we re-create
539
+ // the set, rather than iterate over it and filter out the destroyed handles, because while
540
+ // the ES spec allows for sets to be modified while they're being iterated over, some polyfills
541
+ // use an array internally which may throw an error.
542
+ const disabledHandles = new Set();
543
+ this._disabledHandles.forEach(handle => {
544
+ if (this._handles.indexOf(handle) > -1) {
545
+ disabledHandles.add(handle);
546
+ }
547
+ });
548
+ this._disabledHandles = disabledHandles;
549
+ return this;
550
+ }
551
+ /**
552
+ * Registers the template that should be used for the drag preview.
553
+ * @param template Template that from which to stamp out the preview.
554
+ */
555
+ withPreviewTemplate(template) {
556
+ this._previewTemplate = template;
557
+ return this;
558
+ }
559
+ /**
560
+ * Registers the template that should be used for the drag placeholder.
561
+ * @param template Template that from which to stamp out the placeholder.
562
+ */
563
+ withPlaceholderTemplate(template) {
564
+ this._placeholderTemplate = template;
565
+ return this;
566
+ }
567
+ /**
568
+ * Sets an alternate drag root element. The root element is the element that will be moved as
569
+ * the user is dragging. Passing an alternate root element is useful when trying to enable
570
+ * dragging on an element that you might not have access to.
571
+ */
572
+ withRootElement(rootElement) {
573
+ const element = coerceElement(rootElement);
574
+ if (element !== this._rootElement) {
575
+ if (this._rootElement) {
576
+ this._removeRootElementListeners(this._rootElement);
577
+ }
578
+ this._ngZone.runOutsideAngular(() => {
579
+ element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
580
+ element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
581
+ });
582
+ this._initialTransform = undefined;
583
+ this._rootElement = element;
584
+ }
585
+ if (typeof SVGElement !== 'undefined' && this._rootElement instanceof SVGElement) {
586
+ this._ownerSVGElement = this._rootElement.ownerSVGElement;
587
+ }
588
+ return this;
589
+ }
590
+ /**
591
+ * Element to which the draggable's position will be constrained.
592
+ */
593
+ withBoundaryElement(boundaryElement) {
594
+ this._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;
595
+ this._resizeSubscription.unsubscribe();
596
+ if (boundaryElement) {
597
+ this._resizeSubscription = this._viewportRuler
598
+ .change(10)
599
+ .subscribe(() => this._containInsideBoundaryOnResize());
600
+ }
601
+ return this;
602
+ }
603
+ /** Sets the parent ref that the ref is nested in. */
604
+ withParent(parent) {
605
+ this._parentDragRef = parent;
606
+ return this;
607
+ }
608
+ /** Removes the dragging functionality from the DOM element. */
609
+ dispose() {
610
+ var _a, _b;
611
+ this._removeRootElementListeners(this._rootElement);
612
+ // Do this check before removing from the registry since it'll
613
+ // stop being considered as dragged once it is removed.
614
+ if (this.isDragging()) {
615
+ // Since we move out the element to the end of the body while it's being
616
+ // dragged, we have to make sure that it's removed if it gets destroyed.
617
+ (_a = this._rootElement) === null || _a === void 0 ? void 0 : _a.remove();
618
+ }
619
+ (_b = this._anchor) === null || _b === void 0 ? void 0 : _b.remove();
620
+ this._destroyPreview();
621
+ this._destroyPlaceholder();
622
+ this._dragDropRegistry.removeDragItem(this);
623
+ this._removeSubscriptions();
624
+ this.beforeStarted.complete();
625
+ this.started.complete();
626
+ this.released.complete();
627
+ this.ended.complete();
628
+ this.entered.complete();
629
+ this.exited.complete();
630
+ this.dropped.complete();
631
+ this._moveEvents.complete();
632
+ this._handles = [];
633
+ this._disabledHandles.clear();
634
+ this._dropContainer = undefined;
635
+ this._resizeSubscription.unsubscribe();
636
+ this._parentPositions.clear();
637
+ this._boundaryElement =
638
+ this._rootElement =
639
+ this._ownerSVGElement =
640
+ this._placeholderTemplate =
641
+ this._previewTemplate =
642
+ this._anchor =
643
+ this._parentDragRef =
644
+ null;
645
+ }
646
+ /** Checks whether the element is currently being dragged. */
647
+ isDragging() {
648
+ return this._hasStartedDragging && this._dragDropRegistry.isDragging(this);
649
+ }
650
+ /** Resets a standalone drag item to its initial position. */
651
+ reset() {
652
+ this._rootElement.style.transform = this._initialTransform || '';
653
+ this._activeTransform = { x: 0, y: 0 };
654
+ this._passiveTransform = { x: 0, y: 0 };
655
+ }
656
+ /**
657
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
658
+ * @param handle Handle element that should be disabled.
659
+ */
660
+ disableHandle(handle) {
661
+ if (!this._disabledHandles.has(handle) && this._handles.indexOf(handle) > -1) {
662
+ this._disabledHandles.add(handle);
663
+ toggleNativeDragInteractions(handle, true);
664
+ }
665
+ }
666
+ /**
667
+ * Enables a handle, if it has been disabled.
668
+ * @param handle Handle element to be enabled.
669
+ */
670
+ enableHandle(handle) {
671
+ if (this._disabledHandles.has(handle)) {
672
+ this._disabledHandles.delete(handle);
673
+ toggleNativeDragInteractions(handle, this.disabled);
674
+ }
675
+ }
676
+ /** Sets the layout direction of the draggable item. */
677
+ withDirection(direction) {
678
+ this._direction = direction;
679
+ return this;
680
+ }
681
+ /** Sets the container that the item is part of. */
682
+ _withDropContainer(container) {
683
+ this._dropContainer = container;
684
+ }
685
+ /**
686
+ * Gets the current position in pixels the draggable outside of a drop container.
687
+ */
688
+ getFreeDragPosition() {
689
+ const position = this.isDragging() ? this._activeTransform : this._passiveTransform;
690
+ return { x: position.x, y: position.y };
691
+ }
692
+ /**
693
+ * Sets the current position in pixels the draggable outside of a drop container.
694
+ * @param value New position to be set.
695
+ */
696
+ setFreeDragPosition(value) {
697
+ this._activeTransform = { x: 0, y: 0 };
698
+ this._passiveTransform.x = value.x;
699
+ this._passiveTransform.y = value.y;
700
+ if (!this._dropContainer) {
701
+ this._applyRootElementTransform(value.x, value.y);
702
+ }
703
+ return this;
704
+ }
705
+ /**
706
+ * Sets the container into which to insert the preview element.
707
+ * @param value Container into which to insert the preview.
708
+ */
709
+ withPreviewContainer(value) {
710
+ this._previewContainer = value;
711
+ return this;
712
+ }
713
+ /** Updates the item's sort order based on the last-known pointer position. */
714
+ _sortFromLastPointerPosition() {
715
+ const position = this._lastKnownPointerPosition;
716
+ if (position && this._dropContainer) {
717
+ this._updateActiveDropContainer(this._getConstrainedPointerPosition(position), position);
718
+ }
719
+ }
720
+ /** Unsubscribes from the global subscriptions. */
721
+ _removeSubscriptions() {
722
+ this._pointerMoveSubscription.unsubscribe();
723
+ this._pointerUpSubscription.unsubscribe();
724
+ this._scrollSubscription.unsubscribe();
725
+ }
726
+ /** Destroys the preview element and its ViewRef. */
727
+ _destroyPreview() {
728
+ var _a, _b;
729
+ (_a = this._preview) === null || _a === void 0 ? void 0 : _a.remove();
730
+ (_b = this._previewRef) === null || _b === void 0 ? void 0 : _b.destroy();
731
+ this._preview = this._previewRef = null;
732
+ }
733
+ /** Destroys the placeholder element and its ViewRef. */
734
+ _destroyPlaceholder() {
735
+ var _a, _b;
736
+ (_a = this._placeholder) === null || _a === void 0 ? void 0 : _a.remove();
737
+ (_b = this._placeholderRef) === null || _b === void 0 ? void 0 : _b.destroy();
738
+ this._placeholder = this._placeholderRef = null;
739
+ }
740
+ /**
741
+ * Clears subscriptions and stops the dragging sequence.
742
+ * @param event Browser event object that ended the sequence.
743
+ */
744
+ _endDragSequence(event) {
745
+ // Note that here we use `isDragging` from the service, rather than from `this`.
746
+ // The difference is that the one from the service reflects whether a dragging sequence
747
+ // has been initiated, whereas the one on `this` includes whether the user has passed
748
+ // the minimum dragging threshold.
749
+ if (!this._dragDropRegistry.isDragging(this)) {
750
+ return;
751
+ }
752
+ this._removeSubscriptions();
753
+ this._dragDropRegistry.stopDragging(this);
754
+ this._toggleNativeDragInteractions();
755
+ if (this._handles) {
756
+ this._rootElement.style.webkitTapHighlightColor = this._rootElementTapHighlight;
757
+ }
758
+ if (!this._hasStartedDragging) {
759
+ return;
760
+ }
761
+ this.released.next({ source: this });
762
+ if (this._dropContainer) {
763
+ // Stop scrolling immediately, instead of waiting for the animation to finish.
764
+ this._dropContainer._stopScrolling();
765
+ this._animatePreviewToPlaceholder().then(() => {
766
+ this._cleanupDragArtifacts(event);
767
+ this._cleanupCachedDimensions();
768
+ this._dragDropRegistry.stopDragging(this);
769
+ });
770
+ }
771
+ else {
772
+ // Convert the active transform into a passive one. This means that next time
773
+ // the user starts dragging the item, its position will be calculated relatively
774
+ // to the new passive transform.
775
+ this._passiveTransform.x = this._activeTransform.x;
776
+ const pointerPosition = this._getPointerPositionOnPage(event);
777
+ this._passiveTransform.y = this._activeTransform.y;
778
+ this._ngZone.run(() => {
779
+ this.ended.next({
780
+ source: this,
781
+ distance: this._getDragDistance(pointerPosition),
782
+ dropPoint: pointerPosition,
783
+ });
784
+ });
785
+ this._cleanupCachedDimensions();
786
+ this._dragDropRegistry.stopDragging(this);
787
+ }
788
+ }
789
+ /** Starts the dragging sequence. */
790
+ _startDragSequence(event) {
791
+ if (isTouchEvent(event)) {
792
+ this._lastTouchEventTime = Date.now();
793
+ }
794
+ this._toggleNativeDragInteractions();
795
+ const dropContainer = this._dropContainer;
796
+ if (dropContainer) {
797
+ const element = this._rootElement;
798
+ const parent = element.parentNode;
799
+ const placeholder = (this._placeholder = this._createPlaceholderElement());
800
+ const anchor = (this._anchor = this._anchor || this._document.createComment(''));
801
+ // Needs to happen before the root element is moved.
802
+ const shadowRoot = this._getShadowRoot();
803
+ // Insert an anchor node so that we can restore the element's position in the DOM.
804
+ parent.insertBefore(anchor, element);
805
+ // There's no risk of transforms stacking when inside a drop container so
806
+ // we can keep the initial transform up to date any time dragging starts.
807
+ this._initialTransform = element.style.transform || '';
808
+ // Create the preview after the initial transform has
809
+ // been cached, because it can be affected by the transform.
810
+ this._preview = this._createPreviewElement();
811
+ // We move the element out at the end of the body and we make it hidden, because keeping it in
812
+ // place will throw off the consumer's `:last-child` selectors. We can't remove the element
813
+ // from the DOM completely, because iOS will stop firing all subsequent events in the chain.
814
+ toggleVisibility(element, false, dragImportantProperties);
815
+ this._document.body.appendChild(parent.replaceChild(placeholder, element));
816
+ this._getPreviewInsertionPoint(parent, shadowRoot).appendChild(this._preview);
817
+ this.started.next({ source: this }); // Emit before notifying the container.
818
+ dropContainer.start();
819
+ this._initialContainer = dropContainer;
820
+ this._initialIndex = dropContainer.getItemIndex(this);
821
+ }
822
+ else {
823
+ this.started.next({ source: this });
824
+ this._initialContainer = this._initialIndex = undefined;
825
+ }
826
+ // Important to run after we've called `start` on the parent container
827
+ // so that it has had time to resolve its scrollable parents.
828
+ this._parentPositions.cache(dropContainer ? dropContainer.getScrollableParents() : []);
829
+ }
830
+ /**
831
+ * Sets up the different variables and subscriptions
832
+ * that will be necessary for the dragging sequence.
833
+ * @param referenceElement Element that started the drag sequence.
834
+ * @param event Browser event object that started the sequence.
835
+ */
836
+ _initializeDragSequence(referenceElement, event) {
837
+ // Stop propagation if the item is inside another
838
+ // draggable so we don't start multiple drag sequences.
839
+ if (this._parentDragRef) {
840
+ event.stopPropagation();
841
+ }
842
+ const isDragging = this.isDragging();
843
+ const isTouchSequence = isTouchEvent(event);
844
+ const isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
845
+ const rootElement = this._rootElement;
846
+ const target = _getEventTarget(event);
847
+ const isSyntheticEvent = !isTouchSequence &&
848
+ this._lastTouchEventTime &&
849
+ this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
850
+ const isFakeEvent = isTouchSequence
851
+ ? isFakeTouchstartFromScreenReader(event)
852
+ : isFakeMousedownFromScreenReader(event);
853
+ // If the event started from an element with the native HTML drag&drop, it'll interfere
854
+ // with our own dragging (e.g. `img` tags do it by default). Prevent the default action
855
+ // to stop it from happening. Note that preventing on `dragstart` also seems to work, but
856
+ // it's flaky and it fails if the user drags it away quickly. Also note that we only want
857
+ // to do this for `mousedown` since doing the same for `touchstart` will stop any `click`
858
+ // events from firing on touch devices.
859
+ if (target && target.draggable && event.type === 'mousedown') {
860
+ event.preventDefault();
861
+ }
862
+ // Abort if the user is already dragging or is using a mouse button other than the primary one.
863
+ if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent || isFakeEvent) {
864
+ return;
865
+ }
866
+ // If we've got handles, we need to disable the tap highlight on the entire root element,
867
+ // otherwise iOS will still add it, even though all the drag interactions on the handle
868
+ // are disabled.
869
+ if (this._handles.length) {
870
+ const rootStyles = rootElement.style;
871
+ this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || '';
872
+ rootStyles.webkitTapHighlightColor = 'transparent';
873
+ }
874
+ this._hasStartedDragging = this._hasMoved = false;
875
+ // Avoid multiple subscriptions and memory leaks when multi touch
876
+ // (isDragging check above isn't enough because of possible temporal and/or dimensional delays)
877
+ this._removeSubscriptions();
878
+ this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
879
+ this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
880
+ this._scrollSubscription = this._dragDropRegistry
881
+ .scrolled(this._getShadowRoot())
882
+ .subscribe(scrollEvent => this._updateOnScroll(scrollEvent));
883
+ if (this._boundaryElement) {
884
+ this._boundaryRect = getMutableClientRect(this._boundaryElement);
885
+ }
886
+ // If we have a custom preview we can't know ahead of time how large it'll be so we position
887
+ // it next to the cursor. The exception is when the consumer has opted into making the preview
888
+ // the same size as the root element, in which case we do know the size.
889
+ const previewTemplate = this._previewTemplate;
890
+ this._pickupPositionInElement =
891
+ previewTemplate && previewTemplate.template && !previewTemplate.matchSize
892
+ ? { x: 0, y: 0 }
893
+ : this._getPointerPositionInElement(referenceElement, event);
894
+ const pointerPosition = (this._pickupPositionOnPage =
895
+ this._lastKnownPointerPosition =
896
+ this._getPointerPositionOnPage(event));
897
+ this._pointerDirectionDelta = { x: 0, y: 0 };
898
+ this._pointerPositionAtLastDirectionChange = { x: pointerPosition.x, y: pointerPosition.y };
899
+ this._dragStartTime = Date.now();
900
+ this._dragDropRegistry.startDragging(this, event);
901
+ }
902
+ /** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
903
+ _cleanupDragArtifacts(event) {
904
+ // Restore the element's visibility and insert it at its old position in the DOM.
905
+ // It's important that we maintain the position, because moving the element around in the DOM
906
+ // can throw off `NgFor` which does smart diffing and re-creates elements only when necessary,
907
+ // while moving the existing elements in all other cases.
908
+ toggleVisibility(this._rootElement, true, dragImportantProperties);
909
+ this._anchor.parentNode.replaceChild(this._rootElement, this._anchor);
910
+ this._destroyPreview();
911
+ this._destroyPlaceholder();
912
+ this._boundaryRect = this._previewRect = this._initialTransform = undefined;
913
+ // Re-enter the NgZone since we bound `document` events on the outside.
914
+ this._ngZone.run(() => {
915
+ const container = this._dropContainer;
916
+ const currentIndex = container.getItemIndex(this);
917
+ const pointerPosition = this._getPointerPositionOnPage(event);
918
+ const distance = this._getDragDistance(pointerPosition);
919
+ const isPointerOverContainer = container._isOverContainer(pointerPosition.x, pointerPosition.y);
920
+ this.ended.next({ source: this, distance, dropPoint: pointerPosition });
921
+ this.dropped.next({
922
+ item: this,
923
+ currentIndex,
924
+ previousIndex: this._initialIndex,
925
+ container: container,
926
+ previousContainer: this._initialContainer,
927
+ isPointerOverContainer,
928
+ distance,
929
+ dropPoint: pointerPosition,
930
+ });
931
+ container.drop(this, currentIndex, this._initialIndex, this._initialContainer, isPointerOverContainer, distance, pointerPosition);
932
+ this._dropContainer = this._initialContainer;
933
+ });
934
+ }
935
+ /**
936
+ * Updates the item's position in its drop container, or moves it
937
+ * into a new one, depending on its current drag position.
938
+ */
939
+ _updateActiveDropContainer({ x, y }, { x: rawX, y: rawY }) {
940
+ // Drop container that draggable has been moved into.
941
+ let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
942
+ // If we couldn't find a new container to move the item into, and the item has left its
943
+ // initial container, check whether the it's over the initial container. This handles the
944
+ // case where two containers are connected one way and the user tries to undo dragging an
945
+ // item into a new container.
946
+ if (!newContainer &&
947
+ this._dropContainer !== this._initialContainer &&
948
+ this._initialContainer._isOverContainer(x, y)) {
949
+ newContainer = this._initialContainer;
950
+ }
951
+ if (newContainer && newContainer !== this._dropContainer) {
952
+ this._ngZone.run(() => {
953
+ // Notify the old container that the item has left.
954
+ this.exited.next({ item: this, container: this._dropContainer });
955
+ this._dropContainer.exit(this);
956
+ // Notify the new container that the item has entered.
957
+ this._dropContainer = newContainer;
958
+ this._dropContainer.enter(this, x, y, newContainer === this._initialContainer &&
959
+ // If we're re-entering the initial container and sorting is disabled,
960
+ // put item the into its starting index to begin with.
961
+ newContainer.sortingDisabled
962
+ ? this._initialIndex
963
+ : undefined);
964
+ this.entered.next({
965
+ item: this,
966
+ container: newContainer,
967
+ currentIndex: newContainer.getItemIndex(this),
968
+ });
969
+ });
970
+ }
971
+ // Dragging may have been interrupted as a result of the events above.
972
+ if (this.isDragging()) {
973
+ this._dropContainer._startScrollingIfNecessary(rawX, rawY);
974
+ this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
975
+ this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
976
+ }
977
+ }
978
+ /**
979
+ * Creates the element that will be rendered next to the user's pointer
980
+ * and will be used as a preview of the element that is being dragged.
981
+ */
982
+ _createPreviewElement() {
983
+ const previewConfig = this._previewTemplate;
984
+ const previewClass = this.previewClass;
985
+ const previewTemplate = previewConfig ? previewConfig.template : null;
986
+ let preview;
987
+ if (previewTemplate && previewConfig) {
988
+ // Measure the element before we've inserted the preview
989
+ // since the insertion could throw off the measurement.
990
+ const rootRect = previewConfig.matchSize ? this._rootElement.getBoundingClientRect() : null;
991
+ const viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
992
+ viewRef.detectChanges();
993
+ preview = getRootNode(viewRef, this._document);
994
+ this._previewRef = viewRef;
995
+ if (previewConfig.matchSize) {
996
+ matchElementSize(preview, rootRect);
997
+ }
998
+ else {
999
+ preview.style.transform = getTransform(this._pickupPositionOnPage.x, this._pickupPositionOnPage.y);
1000
+ }
1001
+ }
1002
+ else {
1003
+ const element = this._rootElement;
1004
+ preview = deepCloneNode(element);
1005
+ matchElementSize(preview, element.getBoundingClientRect());
1006
+ if (this._initialTransform) {
1007
+ preview.style.transform = this._initialTransform;
1008
+ }
1009
+ }
1010
+ extendStyles(preview.style, {
1011
+ // It's important that we disable the pointer events on the preview, because
1012
+ // it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
1013
+ 'pointer-events': 'none',
1014
+ // We have to reset the margin, because it can throw off positioning relative to the viewport.
1015
+ 'margin': '0',
1016
+ 'position': 'fixed',
1017
+ 'top': '0',
1018
+ 'left': '0',
1019
+ 'z-index': `${this._config.zIndex || 1000}`,
1020
+ }, dragImportantProperties);
1021
+ toggleNativeDragInteractions(preview, false);
1022
+ preview.classList.add('cdk-drag-preview');
1023
+ preview.setAttribute('dir', this._direction);
1024
+ if (previewClass) {
1025
+ if (Array.isArray(previewClass)) {
1026
+ previewClass.forEach(className => preview.classList.add(className));
1027
+ }
1028
+ else {
1029
+ preview.classList.add(previewClass);
1030
+ }
1031
+ }
1032
+ return preview;
1033
+ }
1034
+ /**
1035
+ * Animates the preview element from its current position to the location of the drop placeholder.
1036
+ * @returns Promise that resolves when the animation completes.
1037
+ */
1038
+ _animatePreviewToPlaceholder() {
1039
+ // If the user hasn't moved yet, the transitionend event won't fire.
1040
+ if (!this._hasMoved) {
1041
+ return Promise.resolve();
1042
+ }
1043
+ const placeholderRect = this._placeholder.getBoundingClientRect();
1044
+ // Apply the class that adds a transition to the preview.
1045
+ this._preview.classList.add('cdk-drag-animating');
1046
+ // Move the preview to the placeholder position.
1047
+ this._applyPreviewTransform(placeholderRect.left, placeholderRect.top);
1048
+ // If the element doesn't have a `transition`, the `transitionend` event won't fire. Since
1049
+ // we need to trigger a style recalculation in order for the `cdk-drag-animating` class to
1050
+ // apply its style, we take advantage of the available info to figure out whether we need to
1051
+ // bind the event in the first place.
1052
+ const duration = getTransformTransitionDurationInMs(this._preview);
1053
+ if (duration === 0) {
1054
+ return Promise.resolve();
1055
+ }
1056
+ return this._ngZone.runOutsideAngular(() => {
1057
+ return new Promise(resolve => {
1058
+ const handler = ((event) => {
1059
+ var _a;
1060
+ if (!event ||
1061
+ (_getEventTarget(event) === this._preview && event.propertyName === 'transform')) {
1062
+ (_a = this._preview) === null || _a === void 0 ? void 0 : _a.removeEventListener('transitionend', handler);
1063
+ resolve();
1064
+ clearTimeout(timeout);
1065
+ }
1066
+ });
1067
+ // If a transition is short enough, the browser might not fire the `transitionend` event.
1068
+ // Since we know how long it's supposed to take, add a timeout with a 50% buffer that'll
1069
+ // fire if the transition hasn't completed when it was supposed to.
1070
+ const timeout = setTimeout(handler, duration * 1.5);
1071
+ this._preview.addEventListener('transitionend', handler);
1072
+ });
1073
+ });
1074
+ }
1075
+ /** Creates an element that will be shown instead of the current element while dragging. */
1076
+ _createPlaceholderElement() {
1077
+ const placeholderConfig = this._placeholderTemplate;
1078
+ const placeholderTemplate = placeholderConfig ? placeholderConfig.template : null;
1079
+ let placeholder;
1080
+ if (placeholderTemplate) {
1081
+ this._placeholderRef = placeholderConfig.viewContainer.createEmbeddedView(placeholderTemplate, placeholderConfig.context);
1082
+ this._placeholderRef.detectChanges();
1083
+ placeholder = getRootNode(this._placeholderRef, this._document);
1084
+ }
1085
+ else {
1086
+ placeholder = deepCloneNode(this._rootElement);
1087
+ }
1088
+ placeholder.classList.add('cdk-drag-placeholder');
1089
+ return placeholder;
1090
+ }
1091
+ /**
1092
+ * Figures out the coordinates at which an element was picked up.
1093
+ * @param referenceElement Element that initiated the dragging.
1094
+ * @param event Event that initiated the dragging.
1095
+ */
1096
+ _getPointerPositionInElement(referenceElement, event) {
1097
+ const elementRect = this._rootElement.getBoundingClientRect();
1098
+ const handleElement = referenceElement === this._rootElement ? null : referenceElement;
1099
+ const referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
1100
+ const point = isTouchEvent(event) ? event.targetTouches[0] : event;
1101
+ const scrollPosition = this._getViewportScrollPosition();
1102
+ const x = point.pageX - referenceRect.left - scrollPosition.left;
1103
+ const y = point.pageY - referenceRect.top - scrollPosition.top;
1104
+ return {
1105
+ x: referenceRect.left - elementRect.left + x,
1106
+ y: referenceRect.top - elementRect.top + y,
1107
+ };
1108
+ }
1109
+ /** Determines the point of the page that was touched by the user. */
1110
+ _getPointerPositionOnPage(event) {
1111
+ const scrollPosition = this._getViewportScrollPosition();
1112
+ const point = isTouchEvent(event)
1113
+ ? // `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
1114
+ // Also note that on real devices we're guaranteed for either `touches` or `changedTouches`
1115
+ // to have a value, but Firefox in device emulation mode has a bug where both can be empty
1116
+ // for `touchstart` and `touchend` so we fall back to a dummy object in order to avoid
1117
+ // throwing an error. The value returned here will be incorrect, but since this only
1118
+ // breaks inside a developer tool and the value is only used for secondary information,
1119
+ // we can get away with it. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615824.
1120
+ event.touches[0] || event.changedTouches[0] || { pageX: 0, pageY: 0 }
1121
+ : event;
1122
+ const x = point.pageX - scrollPosition.left;
1123
+ const y = point.pageY - scrollPosition.top;
1124
+ // if dragging SVG element, try to convert from the screen coordinate system to the SVG
1125
+ // coordinate system
1126
+ if (this._ownerSVGElement) {
1127
+ const svgMatrix = this._ownerSVGElement.getScreenCTM();
1128
+ if (svgMatrix) {
1129
+ const svgPoint = this._ownerSVGElement.createSVGPoint();
1130
+ svgPoint.x = x;
1131
+ svgPoint.y = y;
1132
+ return svgPoint.matrixTransform(svgMatrix.inverse());
1133
+ }
1134
+ }
1135
+ return { x, y };
1136
+ }
1137
+ /** Gets the pointer position on the page, accounting for any position constraints. */
1138
+ _getConstrainedPointerPosition(point) {
1139
+ const dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
1140
+ let { x, y } = this.constrainPosition ? this.constrainPosition(point, this) : point;
1141
+ if (this.lockAxis === 'x' || dropContainerLock === 'x') {
1142
+ y = this._pickupPositionOnPage.y;
1143
+ }
1144
+ else if (this.lockAxis === 'y' || dropContainerLock === 'y') {
1145
+ x = this._pickupPositionOnPage.x;
1146
+ }
1147
+ if (this._boundaryRect) {
1148
+ const { x: pickupX, y: pickupY } = this._pickupPositionInElement;
1149
+ const boundaryRect = this._boundaryRect;
1150
+ const previewRect = this._previewRect;
1151
+ const minY = boundaryRect.top + pickupY;
1152
+ const maxY = boundaryRect.bottom - (previewRect.height - pickupY);
1153
+ const minX = boundaryRect.left + pickupX;
1154
+ const maxX = boundaryRect.right - (previewRect.width - pickupX);
1155
+ x = clamp$1(x, minX, maxX);
1156
+ y = clamp$1(y, minY, maxY);
1157
+ }
1158
+ return { x, y };
1159
+ }
1160
+ /** Updates the current drag delta, based on the user's current pointer position on the page. */
1161
+ _updatePointerDirectionDelta(pointerPositionOnPage) {
1162
+ const { x, y } = pointerPositionOnPage;
1163
+ const delta = this._pointerDirectionDelta;
1164
+ const positionSinceLastChange = this._pointerPositionAtLastDirectionChange;
1165
+ // Amount of pixels the user has dragged since the last time the direction changed.
1166
+ const changeX = Math.abs(x - positionSinceLastChange.x);
1167
+ const changeY = Math.abs(y - positionSinceLastChange.y);
1168
+ // Because we handle pointer events on a per-pixel basis, we don't want the delta
1169
+ // to change for every pixel, otherwise anything that depends on it can look erratic.
1170
+ // To make the delta more consistent, we track how much the user has moved since the last
1171
+ // delta change and we only update it after it has reached a certain threshold.
1172
+ if (changeX > this._config.pointerDirectionChangeThreshold) {
1173
+ delta.x = x > positionSinceLastChange.x ? 1 : -1;
1174
+ positionSinceLastChange.x = x;
1175
+ }
1176
+ if (changeY > this._config.pointerDirectionChangeThreshold) {
1177
+ delta.y = y > positionSinceLastChange.y ? 1 : -1;
1178
+ positionSinceLastChange.y = y;
1179
+ }
1180
+ return delta;
1181
+ }
1182
+ /** Toggles the native drag interactions, based on how many handles are registered. */
1183
+ _toggleNativeDragInteractions() {
1184
+ if (!this._rootElement || !this._handles) {
1185
+ return;
1186
+ }
1187
+ const shouldEnable = this._handles.length > 0 || !this.isDragging();
1188
+ if (shouldEnable !== this._nativeInteractionsEnabled) {
1189
+ this._nativeInteractionsEnabled = shouldEnable;
1190
+ toggleNativeDragInteractions(this._rootElement, shouldEnable);
1191
+ }
1192
+ }
1193
+ /** Removes the manually-added event listeners from the root element. */
1194
+ _removeRootElementListeners(element) {
1195
+ element.removeEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
1196
+ element.removeEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
1197
+ }
1198
+ /**
1199
+ * Applies a `transform` to the root element, taking into account any existing transforms on it.
1200
+ * @param x New transform value along the X axis.
1201
+ * @param y New transform value along the Y axis.
1202
+ */
1203
+ _applyRootElementTransform(x, y) {
1204
+ const transform = getTransform(x, y);
1205
+ const styles = this._rootElement.style;
1206
+ // Cache the previous transform amount only after the first drag sequence, because
1207
+ // we don't want our own transforms to stack on top of each other.
1208
+ // Should be excluded none because none + translate3d(x, y, x) is invalid css
1209
+ if (this._initialTransform == null) {
1210
+ this._initialTransform =
1211
+ styles.transform && styles.transform != 'none' ? styles.transform : '';
1212
+ }
1213
+ // Preserve the previous `transform` value, if there was one. Note that we apply our own
1214
+ // transform before the user's, because things like rotation can affect which direction
1215
+ // the element will be translated towards.
1216
+ styles.transform = combineTransforms(transform, this._initialTransform);
1217
+ }
1218
+ /**
1219
+ * Applies a `transform` to the preview, taking into account any existing transforms on it.
1220
+ * @param x New transform value along the X axis.
1221
+ * @param y New transform value along the Y axis.
1222
+ */
1223
+ _applyPreviewTransform(x, y) {
1224
+ var _a;
1225
+ // Only apply the initial transform if the preview is a clone of the original element, otherwise
1226
+ // it could be completely different and the transform might not make sense anymore.
1227
+ const initialTransform = ((_a = this._previewTemplate) === null || _a === void 0 ? void 0 : _a.template) ? undefined : this._initialTransform;
1228
+ const transform = getTransform(x, y);
1229
+ this._preview.style.transform = combineTransforms(transform, initialTransform);
1230
+ }
1231
+ /**
1232
+ * Gets the distance that the user has dragged during the current drag sequence.
1233
+ * @param currentPosition Current position of the user's pointer.
1234
+ */
1235
+ _getDragDistance(currentPosition) {
1236
+ const pickupPosition = this._pickupPositionOnPage;
1237
+ if (pickupPosition) {
1238
+ return { x: currentPosition.x - pickupPosition.x, y: currentPosition.y - pickupPosition.y };
1239
+ }
1240
+ return { x: 0, y: 0 };
1241
+ }
1242
+ /** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
1243
+ _cleanupCachedDimensions() {
1244
+ this._boundaryRect = this._previewRect = undefined;
1245
+ this._parentPositions.clear();
1246
+ }
1247
+ /**
1248
+ * Checks whether the element is still inside its boundary after the viewport has been resized.
1249
+ * If not, the position is adjusted so that the element fits again.
1250
+ */
1251
+ _containInsideBoundaryOnResize() {
1252
+ let { x, y } = this._passiveTransform;
1253
+ if ((x === 0 && y === 0) || this.isDragging() || !this._boundaryElement) {
1254
+ return;
1255
+ }
1256
+ const boundaryRect = this._boundaryElement.getBoundingClientRect();
1257
+ const elementRect = this._rootElement.getBoundingClientRect();
1258
+ // It's possible that the element got hidden away after dragging (e.g. by switching to a
1259
+ // different tab). Don't do anything in this case so we don't clear the user's position.
1260
+ if ((boundaryRect.width === 0 && boundaryRect.height === 0) ||
1261
+ (elementRect.width === 0 && elementRect.height === 0)) {
1262
+ return;
1263
+ }
1264
+ const leftOverflow = boundaryRect.left - elementRect.left;
1265
+ const rightOverflow = elementRect.right - boundaryRect.right;
1266
+ const topOverflow = boundaryRect.top - elementRect.top;
1267
+ const bottomOverflow = elementRect.bottom - boundaryRect.bottom;
1268
+ // If the element has become wider than the boundary, we can't
1269
+ // do much to make it fit so we just anchor it to the left.
1270
+ if (boundaryRect.width > elementRect.width) {
1271
+ if (leftOverflow > 0) {
1272
+ x += leftOverflow;
1273
+ }
1274
+ if (rightOverflow > 0) {
1275
+ x -= rightOverflow;
1276
+ }
1277
+ }
1278
+ else {
1279
+ x = 0;
1280
+ }
1281
+ // If the element has become taller than the boundary, we can't
1282
+ // do much to make it fit so we just anchor it to the top.
1283
+ if (boundaryRect.height > elementRect.height) {
1284
+ if (topOverflow > 0) {
1285
+ y += topOverflow;
1286
+ }
1287
+ if (bottomOverflow > 0) {
1288
+ y -= bottomOverflow;
1289
+ }
1290
+ }
1291
+ else {
1292
+ y = 0;
1293
+ }
1294
+ if (x !== this._passiveTransform.x || y !== this._passiveTransform.y) {
1295
+ this.setFreeDragPosition({ y, x });
1296
+ }
1297
+ }
1298
+ /** Gets the drag start delay, based on the event type. */
1299
+ _getDragStartDelay(event) {
1300
+ const value = this.dragStartDelay;
1301
+ if (typeof value === 'number') {
1302
+ return value;
1303
+ }
1304
+ else if (isTouchEvent(event)) {
1305
+ return value.touch;
1306
+ }
1307
+ return value ? value.mouse : 0;
1308
+ }
1309
+ /** Updates the internal state of the draggable element when scrolling has occurred. */
1310
+ _updateOnScroll(event) {
1311
+ const scrollDifference = this._parentPositions.handleScroll(event);
1312
+ if (scrollDifference) {
1313
+ const target = _getEventTarget(event);
1314
+ // ClientRect dimensions are based on the scroll position of the page and its parent
1315
+ // node so we have to update the cached boundary ClientRect if the user has scrolled.
1316
+ if (this._boundaryRect &&
1317
+ target !== this._boundaryElement &&
1318
+ target.contains(this._boundaryElement)) {
1319
+ adjustClientRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
1320
+ }
1321
+ this._pickupPositionOnPage.x += scrollDifference.left;
1322
+ this._pickupPositionOnPage.y += scrollDifference.top;
1323
+ // If we're in free drag mode, we have to update the active transform, because
1324
+ // it isn't relative to the viewport like the preview inside a drop list.
1325
+ if (!this._dropContainer) {
1326
+ this._activeTransform.x -= scrollDifference.left;
1327
+ this._activeTransform.y -= scrollDifference.top;
1328
+ this._applyRootElementTransform(this._activeTransform.x, this._activeTransform.y);
1329
+ }
1330
+ }
1331
+ }
1332
+ /** Gets the scroll position of the viewport. */
1333
+ _getViewportScrollPosition() {
1334
+ const cachedPosition = this._parentPositions.positions.get(this._document);
1335
+ return cachedPosition
1336
+ ? cachedPosition.scrollPosition
1337
+ : this._viewportRuler.getViewportScrollPosition();
1338
+ }
1339
+ /**
1340
+ * Lazily resolves and returns the shadow root of the element. We do this in a function, rather
1341
+ * than saving it in property directly on init, because we want to resolve it as late as possible
1342
+ * in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
1343
+ * constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
1344
+ */
1345
+ _getShadowRoot() {
1346
+ if (this._cachedShadowRoot === undefined) {
1347
+ this._cachedShadowRoot = _getShadowRoot(this._rootElement);
1348
+ }
1349
+ return this._cachedShadowRoot;
1350
+ }
1351
+ /** Gets the element into which the drag preview should be inserted. */
1352
+ _getPreviewInsertionPoint(initialParent, shadowRoot) {
1353
+ const previewContainer = this._previewContainer || 'global';
1354
+ if (previewContainer === 'parent') {
1355
+ return initialParent;
1356
+ }
1357
+ if (previewContainer === 'global') {
1358
+ const documentRef = this._document;
1359
+ // We can't use the body if the user is in fullscreen mode,
1360
+ // because the preview will render under the fullscreen element.
1361
+ // TODO(crisbeto): dedupe this with the `FullscreenOverlayContainer` eventually.
1362
+ return (shadowRoot ||
1363
+ documentRef.fullscreenElement ||
1364
+ documentRef.webkitFullscreenElement ||
1365
+ documentRef.mozFullScreenElement ||
1366
+ documentRef.msFullscreenElement ||
1367
+ documentRef.body);
1368
+ }
1369
+ return coerceElement(previewContainer);
1370
+ }
1371
+ }
1372
+ /**
1373
+ * Gets a 3d `transform` that can be applied to an element.
1374
+ * @param x Desired position of the element along the X axis.
1375
+ * @param y Desired position of the element along the Y axis.
1376
+ */
1377
+ function getTransform(x, y) {
1378
+ // Round the transforms since some browsers will
1379
+ // blur the elements for sub-pixel transforms.
1380
+ return `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;
1381
+ }
1382
+ /** Clamps a value between a minimum and a maximum. */
1383
+ function clamp$1(value, min, max) {
1384
+ return Math.max(min, Math.min(max, value));
1385
+ }
1386
+ /** Determines whether an event is a touch event. */
1387
+ function isTouchEvent(event) {
1388
+ // This function is called for every pixel that the user has dragged so we need it to be
1389
+ // as fast as possible. Since we only bind mouse events and touch events, we can assume
1390
+ // that if the event's name starts with `t`, it's a touch event.
1391
+ return event.type[0] === 't';
1392
+ }
1393
+ /**
1394
+ * Gets the root HTML element of an embedded view.
1395
+ * If the root is not an HTML element it gets wrapped in one.
1396
+ */
1397
+ function getRootNode(viewRef, _document) {
1398
+ const rootNodes = viewRef.rootNodes;
1399
+ if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
1400
+ return rootNodes[0];
1401
+ }
1402
+ const wrapper = _document.createElement('div');
1403
+ rootNodes.forEach(node => wrapper.appendChild(node));
1404
+ return wrapper;
1405
+ }
1406
+ /**
1407
+ * Matches the target element's size to the source's size.
1408
+ * @param target Element that needs to be resized.
1409
+ * @param sourceRect Dimensions of the source element.
1410
+ */
1411
+ function matchElementSize(target, sourceRect) {
1412
+ target.style.width = `${sourceRect.width}px`;
1413
+ target.style.height = `${sourceRect.height}px`;
1414
+ target.style.transform = getTransform(sourceRect.left, sourceRect.top);
1415
+ }
1416
+
1417
+ /**
1418
+ * @license
1419
+ * Copyright Google LLC All Rights Reserved.
1420
+ *
1421
+ * Use of this source code is governed by an MIT-style license that can be
1422
+ * found in the LICENSE file at https://angular.io/license
1423
+ */
1424
+ /**
1425
+ * Moves an item one index in an array to another.
1426
+ * @param array Array in which to move the item.
1427
+ * @param fromIndex Starting index of the item.
1428
+ * @param toIndex Index to which the item should be moved.
1429
+ */
1430
+ function moveItemInArray(array, fromIndex, toIndex) {
1431
+ const from = clamp(fromIndex, array.length - 1);
1432
+ const to = clamp(toIndex, array.length - 1);
1433
+ if (from === to) {
1434
+ return;
1435
+ }
1436
+ const target = array[from];
1437
+ const delta = to < from ? -1 : 1;
1438
+ for (let i = from; i !== to; i += delta) {
1439
+ array[i] = array[i + delta];
1440
+ }
1441
+ array[to] = target;
1442
+ }
1443
+ /**
1444
+ * Moves an item from one array to another.
1445
+ * @param currentArray Array from which to transfer the item.
1446
+ * @param targetArray Array into which to put the item.
1447
+ * @param currentIndex Index of the item in its current array.
1448
+ * @param targetIndex Index at which to insert the item.
1449
+ */
1450
+ function transferArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
1451
+ const from = clamp(currentIndex, currentArray.length - 1);
1452
+ const to = clamp(targetIndex, targetArray.length);
1453
+ if (currentArray.length) {
1454
+ targetArray.splice(to, 0, currentArray.splice(from, 1)[0]);
1455
+ }
1456
+ }
1457
+ /**
1458
+ * Copies an item from one array to another, leaving it in its
1459
+ * original position in current array.
1460
+ * @param currentArray Array from which to copy the item.
1461
+ * @param targetArray Array into which is copy the item.
1462
+ * @param currentIndex Index of the item in its current array.
1463
+ * @param targetIndex Index at which to insert the item.
1464
+ *
1465
+ */
1466
+ function copyArrayItem(currentArray, targetArray, currentIndex, targetIndex) {
1467
+ const to = clamp(targetIndex, targetArray.length);
1468
+ if (currentArray.length) {
1469
+ targetArray.splice(to, 0, currentArray[currentIndex]);
1470
+ }
1471
+ }
1472
+ /** Clamps a number between zero and a maximum. */
1473
+ function clamp(value, max) {
1474
+ return Math.max(0, Math.min(max, value));
1475
+ }
1476
+
1477
+ /**
1478
+ * @license
1479
+ * Copyright Google LLC All Rights Reserved.
1480
+ *
1481
+ * Use of this source code is governed by an MIT-style license that can be
1482
+ * found in the LICENSE file at https://angular.io/license
1483
+ */
1484
+ /**
1485
+ * Proximity, as a ratio to width/height, at which a
1486
+ * dragged item will affect the drop container.
1487
+ */
1488
+ const DROP_PROXIMITY_THRESHOLD = 0.05;
1489
+ /**
1490
+ * Proximity, as a ratio to width/height at which to start auto-scrolling the drop list or the
1491
+ * viewport. The value comes from trying it out manually until it feels right.
1492
+ */
1493
+ const SCROLL_PROXIMITY_THRESHOLD = 0.05;
1494
+ /**
1495
+ * Reference to a drop list. Used to manipulate or dispose of the container.
1496
+ */
1497
+ class DropListRef {
1498
+ constructor(element, _dragDropRegistry, _document, _ngZone, _viewportRuler) {
1499
+ this._dragDropRegistry = _dragDropRegistry;
1500
+ this._ngZone = _ngZone;
1501
+ this._viewportRuler = _viewportRuler;
1502
+ /** Whether starting a dragging sequence from this container is disabled. */
1503
+ this.disabled = false;
1504
+ /** Whether sorting items within the list is disabled. */
1505
+ this.sortingDisabled = false;
1506
+ /**
1507
+ * Whether auto-scrolling the view when the user
1508
+ * moves their pointer close to the edges is disabled.
1509
+ */
1510
+ this.autoScrollDisabled = false;
1511
+ /** Number of pixels to scroll for each frame when auto-scrolling an element. */
1512
+ this.autoScrollStep = 2;
1513
+ /**
1514
+ * Function that is used to determine whether an item
1515
+ * is allowed to be moved into a drop container.
1516
+ */
1517
+ this.enterPredicate = () => true;
1518
+ /** Functions that is used to determine whether an item can be sorted into a particular index. */
1519
+ this.sortPredicate = () => true;
1520
+ /** Emits right before dragging has started. */
1521
+ this.beforeStarted = new Subject();
1522
+ /**
1523
+ * Emits when the user has moved a new drag item into this container.
1524
+ */
1525
+ this.entered = new Subject();
1526
+ /**
1527
+ * Emits when the user removes an item from the container
1528
+ * by dragging it into another container.
1529
+ */
1530
+ this.exited = new Subject();
1531
+ /** Emits when the user drops an item inside the container. */
1532
+ this.dropped = new Subject();
1533
+ /** Emits as the user is swapping items while actively dragging. */
1534
+ this.sorted = new Subject();
1535
+ /** Whether an item in the list is being dragged. */
1536
+ this._isDragging = false;
1537
+ /** Cache of the dimensions of all the items inside the container. */
1538
+ this._itemPositions = [];
1539
+ /**
1540
+ * Keeps track of the item that was last swapped with the dragged item, as well as what direction
1541
+ * the pointer was moving in when the swap occured and whether the user's pointer continued to
1542
+ * overlap with the swapped item after the swapping occurred.
1543
+ */
1544
+ this._previousSwap = { drag: null, delta: 0, overlaps: false };
1545
+ /** Draggable items in the container. */
1546
+ this._draggables = [];
1547
+ /** Drop lists that are connected to the current one. */
1548
+ this._siblings = [];
1549
+ /** Direction in which the list is oriented. */
1550
+ this._orientation = 'vertical';
1551
+ /** Connected siblings that currently have a dragged item. */
1552
+ this._activeSiblings = new Set();
1553
+ /** Layout direction of the drop list. */
1554
+ this._direction = 'ltr';
1555
+ /** Subscription to the window being scrolled. */
1556
+ this._viewportScrollSubscription = Subscription.EMPTY;
1557
+ /** Vertical direction in which the list is currently scrolling. */
1558
+ this._verticalScrollDirection = 0 /* NONE */;
1559
+ /** Horizontal direction in which the list is currently scrolling. */
1560
+ this._horizontalScrollDirection = 0 /* NONE */;
1561
+ /** Used to signal to the current auto-scroll sequence when to stop. */
1562
+ this._stopScrollTimers = new Subject();
1563
+ /** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
1564
+ this._cachedShadowRoot = null;
1565
+ /** Starts the interval that'll auto-scroll the element. */
1566
+ this._startScrollInterval = () => {
1567
+ this._stopScrolling();
1568
+ interval(0, animationFrameScheduler)
1569
+ .pipe(takeUntil(this._stopScrollTimers))
1570
+ .subscribe(() => {
1571
+ const node = this._scrollNode;
1572
+ const scrollStep = this.autoScrollStep;
1573
+ if (this._verticalScrollDirection === 1 /* UP */) {
1574
+ node.scrollBy(0, -scrollStep);
1575
+ }
1576
+ else if (this._verticalScrollDirection === 2 /* DOWN */) {
1577
+ node.scrollBy(0, scrollStep);
1578
+ }
1579
+ if (this._horizontalScrollDirection === 1 /* LEFT */) {
1580
+ node.scrollBy(-scrollStep, 0);
1581
+ }
1582
+ else if (this._horizontalScrollDirection === 2 /* RIGHT */) {
1583
+ node.scrollBy(scrollStep, 0);
1584
+ }
1585
+ });
1586
+ };
1587
+ this.element = coerceElement(element);
1588
+ this._document = _document;
1589
+ this.withScrollableParents([this.element]);
1590
+ _dragDropRegistry.registerDropContainer(this);
1591
+ this._parentPositions = new ParentPositionTracker(_document, _viewportRuler);
1592
+ }
1593
+ /** Removes the drop list functionality from the DOM element. */
1594
+ dispose() {
1595
+ this._stopScrolling();
1596
+ this._stopScrollTimers.complete();
1597
+ this._viewportScrollSubscription.unsubscribe();
1598
+ this.beforeStarted.complete();
1599
+ this.entered.complete();
1600
+ this.exited.complete();
1601
+ this.dropped.complete();
1602
+ this.sorted.complete();
1603
+ this._activeSiblings.clear();
1604
+ this._scrollNode = null;
1605
+ this._parentPositions.clear();
1606
+ this._dragDropRegistry.removeDropContainer(this);
1607
+ }
1608
+ /** Whether an item from this list is currently being dragged. */
1609
+ isDragging() {
1610
+ return this._isDragging;
1611
+ }
1612
+ /** Starts dragging an item. */
1613
+ start() {
1614
+ this._draggingStarted();
1615
+ this._notifyReceivingSiblings();
1616
+ }
1617
+ /**
1618
+ * Emits an event to indicate that the user moved an item into the container.
1619
+ * @param item Item that was moved into the container.
1620
+ * @param pointerX Position of the item along the X axis.
1621
+ * @param pointerY Position of the item along the Y axis.
1622
+ * @param index Index at which the item entered. If omitted, the container will try to figure it
1623
+ * out automatically.
1624
+ */
1625
+ enter(item, pointerX, pointerY, index) {
1626
+ this._draggingStarted();
1627
+ // If sorting is disabled, we want the item to return to its starting
1628
+ // position if the user is returning it to its initial container.
1629
+ let newIndex;
1630
+ if (index == null) {
1631
+ newIndex = this.sortingDisabled ? this._draggables.indexOf(item) : -1;
1632
+ if (newIndex === -1) {
1633
+ // We use the coordinates of where the item entered the drop
1634
+ // zone to figure out at which index it should be inserted.
1635
+ newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
1636
+ }
1637
+ }
1638
+ else {
1639
+ newIndex = index;
1640
+ }
1641
+ const activeDraggables = this._activeDraggables;
1642
+ const currentIndex = activeDraggables.indexOf(item);
1643
+ const placeholder = item.getPlaceholderElement();
1644
+ let newPositionReference = activeDraggables[newIndex];
1645
+ // If the item at the new position is the same as the item that is being dragged,
1646
+ // it means that we're trying to restore the item to its initial position. In this
1647
+ // case we should use the next item from the list as the reference.
1648
+ if (newPositionReference === item) {
1649
+ newPositionReference = activeDraggables[newIndex + 1];
1650
+ }
1651
+ // Since the item may be in the `activeDraggables` already (e.g. if the user dragged it
1652
+ // into another container and back again), we have to ensure that it isn't duplicated.
1653
+ if (currentIndex > -1) {
1654
+ activeDraggables.splice(currentIndex, 1);
1655
+ }
1656
+ // Don't use items that are being dragged as a reference, because
1657
+ // their element has been moved down to the bottom of the body.
1658
+ if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
1659
+ const element = newPositionReference.getRootElement();
1660
+ element.parentElement.insertBefore(placeholder, element);
1661
+ activeDraggables.splice(newIndex, 0, item);
1662
+ }
1663
+ else if (this._shouldEnterAsFirstChild(pointerX, pointerY)) {
1664
+ const reference = activeDraggables[0].getRootElement();
1665
+ reference.parentNode.insertBefore(placeholder, reference);
1666
+ activeDraggables.unshift(item);
1667
+ }
1668
+ else {
1669
+ coerceElement(this.element).appendChild(placeholder);
1670
+ activeDraggables.push(item);
1671
+ }
1672
+ // The transform needs to be cleared so it doesn't throw off the measurements.
1673
+ placeholder.style.transform = '';
1674
+ // Note that the positions were already cached when we called `start` above,
1675
+ // but we need to refresh them since the amount of items has changed and also parent rects.
1676
+ this._cacheItemPositions();
1677
+ this._cacheParentPositions();
1678
+ // Notify siblings at the end so that the item has been inserted into the `activeDraggables`.
1679
+ this._notifyReceivingSiblings();
1680
+ this.entered.next({ item, container: this, currentIndex: this.getItemIndex(item) });
1681
+ }
1682
+ /**
1683
+ * Removes an item from the container after it was dragged into another container by the user.
1684
+ * @param item Item that was dragged out.
1685
+ */
1686
+ exit(item) {
1687
+ this._reset();
1688
+ this.exited.next({ item, container: this });
1689
+ }
1690
+ /**
1691
+ * Drops an item into this container.
1692
+ * @param item Item being dropped into the container.
1693
+ * @param currentIndex Index at which the item should be inserted.
1694
+ * @param previousIndex Index of the item when dragging started.
1695
+ * @param previousContainer Container from which the item got dragged in.
1696
+ * @param isPointerOverContainer Whether the user's pointer was over the
1697
+ * container when the item was dropped.
1698
+ * @param distance Distance the user has dragged since the start of the dragging sequence.
1699
+ */
1700
+ drop(item, currentIndex, previousIndex, previousContainer, isPointerOverContainer, distance, dropPoint) {
1701
+ this._reset();
1702
+ this.dropped.next({
1703
+ item,
1704
+ currentIndex,
1705
+ previousIndex,
1706
+ container: this,
1707
+ previousContainer,
1708
+ isPointerOverContainer,
1709
+ distance,
1710
+ dropPoint,
1711
+ });
1712
+ }
1713
+ /**
1714
+ * Sets the draggable items that are a part of this list.
1715
+ * @param items Items that are a part of this list.
1716
+ */
1717
+ withItems(items) {
1718
+ const previousItems = this._draggables;
1719
+ this._draggables = items;
1720
+ items.forEach(item => item._withDropContainer(this));
1721
+ if (this.isDragging()) {
1722
+ const draggedItems = previousItems.filter(item => item.isDragging());
1723
+ // If all of the items being dragged were removed
1724
+ // from the list, abort the current drag sequence.
1725
+ if (draggedItems.every(item => items.indexOf(item) === -1)) {
1726
+ this._reset();
1727
+ }
1728
+ else {
1729
+ this._cacheItems();
1730
+ }
1731
+ }
1732
+ return this;
1733
+ }
1734
+ /** Sets the layout direction of the drop list. */
1735
+ withDirection(direction) {
1736
+ this._direction = direction;
1737
+ return this;
1738
+ }
1739
+ /**
1740
+ * Sets the containers that are connected to this one. When two or more containers are
1741
+ * connected, the user will be allowed to transfer items between them.
1742
+ * @param connectedTo Other containers that the current containers should be connected to.
1743
+ */
1744
+ connectedTo(connectedTo) {
1745
+ this._siblings = connectedTo.slice();
1746
+ return this;
1747
+ }
1748
+ /**
1749
+ * Sets the orientation of the container.
1750
+ * @param orientation New orientation for the container.
1751
+ */
1752
+ withOrientation(orientation) {
1753
+ this._orientation = orientation;
1754
+ return this;
1755
+ }
1756
+ /**
1757
+ * Sets which parent elements are can be scrolled while the user is dragging.
1758
+ * @param elements Elements that can be scrolled.
1759
+ */
1760
+ withScrollableParents(elements) {
1761
+ const element = coerceElement(this.element);
1762
+ // We always allow the current element to be scrollable
1763
+ // so we need to ensure that it's in the array.
1764
+ this._scrollableElements =
1765
+ elements.indexOf(element) === -1 ? [element, ...elements] : elements.slice();
1766
+ return this;
1767
+ }
1768
+ /** Gets the scrollable parents that are registered with this drop container. */
1769
+ getScrollableParents() {
1770
+ return this._scrollableElements;
1771
+ }
1772
+ /**
1773
+ * Figures out the index of an item in the container.
1774
+ * @param item Item whose index should be determined.
1775
+ */
1776
+ getItemIndex(item) {
1777
+ if (!this._isDragging) {
1778
+ return this._draggables.indexOf(item);
1779
+ }
1780
+ // Items are sorted always by top/left in the cache, however they flow differently in RTL.
1781
+ // The rest of the logic still stands no matter what orientation we're in, however
1782
+ // we need to invert the array when determining the index.
1783
+ const items = this._orientation === 'horizontal' && this._direction === 'rtl'
1784
+ ? this._itemPositions.slice().reverse()
1785
+ : this._itemPositions;
1786
+ return items.findIndex(currentItem => currentItem.drag === item);
1787
+ }
1788
+ /**
1789
+ * Whether the list is able to receive the item that
1790
+ * is currently being dragged inside a connected drop list.
1791
+ */
1792
+ isReceiving() {
1793
+ return this._activeSiblings.size > 0;
1794
+ }
1795
+ /**
1796
+ * Sorts an item inside the container based on its position.
1797
+ * @param item Item to be sorted.
1798
+ * @param pointerX Position of the item along the X axis.
1799
+ * @param pointerY Position of the item along the Y axis.
1800
+ * @param pointerDelta Direction in which the pointer is moving along each axis.
1801
+ */
1802
+ _sortItem(item, pointerX, pointerY, pointerDelta) {
1803
+ // Don't sort the item if sorting is disabled or it's out of range.
1804
+ if (this.sortingDisabled ||
1805
+ !this._clientRect ||
1806
+ !isPointerNearClientRect(this._clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
1807
+ return;
1808
+ }
1809
+ const siblings = this._itemPositions;
1810
+ const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
1811
+ if (newIndex === -1 && siblings.length > 0) {
1812
+ return;
1813
+ }
1814
+ const isHorizontal = this._orientation === 'horizontal';
1815
+ const currentIndex = siblings.findIndex(currentItem => currentItem.drag === item);
1816
+ const siblingAtNewPosition = siblings[newIndex];
1817
+ const currentPosition = siblings[currentIndex].clientRect;
1818
+ const newPosition = siblingAtNewPosition.clientRect;
1819
+ const delta = currentIndex > newIndex ? 1 : -1;
1820
+ // How many pixels the item's placeholder should be offset.
1821
+ const itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
1822
+ // How many pixels all the other items should be offset.
1823
+ const siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
1824
+ // Save the previous order of the items before moving the item to its new index.
1825
+ // We use this to check whether an item has been moved as a result of the sorting.
1826
+ const oldOrder = siblings.slice();
1827
+ // Shuffle the array in place.
1828
+ moveItemInArray(siblings, currentIndex, newIndex);
1829
+ this.sorted.next({
1830
+ previousIndex: currentIndex,
1831
+ currentIndex: newIndex,
1832
+ container: this,
1833
+ item,
1834
+ });
1835
+ siblings.forEach((sibling, index) => {
1836
+ // Don't do anything if the position hasn't changed.
1837
+ if (oldOrder[index] === sibling) {
1838
+ return;
1839
+ }
1840
+ const isDraggedItem = sibling.drag === item;
1841
+ const offset = isDraggedItem ? itemOffset : siblingOffset;
1842
+ const elementToOffset = isDraggedItem
1843
+ ? item.getPlaceholderElement()
1844
+ : sibling.drag.getRootElement();
1845
+ // Update the offset to reflect the new position.
1846
+ sibling.offset += offset;
1847
+ // Since we're moving the items with a `transform`, we need to adjust their cached
1848
+ // client rects to reflect their new position, as well as swap their positions in the cache.
1849
+ // Note that we shouldn't use `getBoundingClientRect` here to update the cache, because the
1850
+ // elements may be mid-animation which will give us a wrong result.
1851
+ if (isHorizontal) {
1852
+ // Round the transforms since some browsers will
1853
+ // blur the elements, for sub-pixel transforms.
1854
+ elementToOffset.style.transform = combineTransforms(`translate3d(${Math.round(sibling.offset)}px, 0, 0)`, sibling.initialTransform);
1855
+ adjustClientRect(sibling.clientRect, 0, offset);
1856
+ }
1857
+ else {
1858
+ elementToOffset.style.transform = combineTransforms(`translate3d(0, ${Math.round(sibling.offset)}px, 0)`, sibling.initialTransform);
1859
+ adjustClientRect(sibling.clientRect, offset, 0);
1860
+ }
1861
+ });
1862
+ // Note that it's important that we do this after the client rects have been adjusted.
1863
+ this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);
1864
+ this._previousSwap.drag = siblingAtNewPosition.drag;
1865
+ this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
1866
+ }
1867
+ /**
1868
+ * Checks whether the user's pointer is close to the edges of either the
1869
+ * viewport or the drop list and starts the auto-scroll sequence.
1870
+ * @param pointerX User's pointer position along the x axis.
1871
+ * @param pointerY User's pointer position along the y axis.
1872
+ */
1873
+ _startScrollingIfNecessary(pointerX, pointerY) {
1874
+ if (this.autoScrollDisabled) {
1875
+ return;
1876
+ }
1877
+ let scrollNode;
1878
+ let verticalScrollDirection = 0 /* NONE */;
1879
+ let horizontalScrollDirection = 0 /* NONE */;
1880
+ // Check whether we should start scrolling any of the parent containers.
1881
+ this._parentPositions.positions.forEach((position, element) => {
1882
+ // We have special handling for the `document` below. Also this would be
1883
+ // nicer with a for...of loop, but it requires changing a compiler flag.
1884
+ if (element === this._document || !position.clientRect || scrollNode) {
1885
+ return;
1886
+ }
1887
+ if (isPointerNearClientRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
1888
+ [verticalScrollDirection, horizontalScrollDirection] = getElementScrollDirections(element, position.clientRect, pointerX, pointerY);
1889
+ if (verticalScrollDirection || horizontalScrollDirection) {
1890
+ scrollNode = element;
1891
+ }
1892
+ }
1893
+ });
1894
+ // Otherwise check if we can start scrolling the viewport.
1895
+ if (!verticalScrollDirection && !horizontalScrollDirection) {
1896
+ const { width, height } = this._viewportRuler.getViewportSize();
1897
+ const clientRect = {
1898
+ width,
1899
+ height,
1900
+ top: 0,
1901
+ right: width,
1902
+ bottom: height,
1903
+ left: 0,
1904
+ };
1905
+ verticalScrollDirection = getVerticalScrollDirection(clientRect, pointerY);
1906
+ horizontalScrollDirection = getHorizontalScrollDirection(clientRect, pointerX);
1907
+ scrollNode = window;
1908
+ }
1909
+ if (scrollNode &&
1910
+ (verticalScrollDirection !== this._verticalScrollDirection ||
1911
+ horizontalScrollDirection !== this._horizontalScrollDirection ||
1912
+ scrollNode !== this._scrollNode)) {
1913
+ this._verticalScrollDirection = verticalScrollDirection;
1914
+ this._horizontalScrollDirection = horizontalScrollDirection;
1915
+ this._scrollNode = scrollNode;
1916
+ if ((verticalScrollDirection || horizontalScrollDirection) && scrollNode) {
1917
+ this._ngZone.runOutsideAngular(this._startScrollInterval);
1918
+ }
1919
+ else {
1920
+ this._stopScrolling();
1921
+ }
1922
+ }
1923
+ }
1924
+ /** Stops any currently-running auto-scroll sequences. */
1925
+ _stopScrolling() {
1926
+ this._stopScrollTimers.next();
1927
+ }
1928
+ /** Starts the dragging sequence within the list. */
1929
+ _draggingStarted() {
1930
+ const styles = coerceElement(this.element).style;
1931
+ this.beforeStarted.next();
1932
+ this._isDragging = true;
1933
+ // We need to disable scroll snapping while the user is dragging, because it breaks automatic
1934
+ // scrolling. The browser seems to round the value based on the snapping points which means
1935
+ // that we can't increment/decrement the scroll position.
1936
+ this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
1937
+ styles.scrollSnapType = styles.msScrollSnapType = 'none';
1938
+ this._cacheItems();
1939
+ this._viewportScrollSubscription.unsubscribe();
1940
+ this._listenToScrollEvents();
1941
+ }
1942
+ /** Caches the positions of the configured scrollable parents. */
1943
+ _cacheParentPositions() {
1944
+ const element = coerceElement(this.element);
1945
+ this._parentPositions.cache(this._scrollableElements);
1946
+ // The list element is always in the `scrollableElements`
1947
+ // so we can take advantage of the cached `ClientRect`.
1948
+ this._clientRect = this._parentPositions.positions.get(element).clientRect;
1949
+ }
1950
+ /** Refreshes the position cache of the items and sibling containers. */
1951
+ _cacheItemPositions() {
1952
+ const isHorizontal = this._orientation === 'horizontal';
1953
+ this._itemPositions = this._activeDraggables
1954
+ .map(drag => {
1955
+ const elementToMeasure = drag.getVisibleElement();
1956
+ return {
1957
+ drag,
1958
+ offset: 0,
1959
+ initialTransform: elementToMeasure.style.transform || '',
1960
+ clientRect: getMutableClientRect(elementToMeasure),
1961
+ };
1962
+ })
1963
+ .sort((a, b) => {
1964
+ return isHorizontal
1965
+ ? a.clientRect.left - b.clientRect.left
1966
+ : a.clientRect.top - b.clientRect.top;
1967
+ });
1968
+ }
1969
+ /** Resets the container to its initial state. */
1970
+ _reset() {
1971
+ this._isDragging = false;
1972
+ const styles = coerceElement(this.element).style;
1973
+ styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
1974
+ // TODO(crisbeto): may have to wait for the animations to finish.
1975
+ this._activeDraggables.forEach(item => {
1976
+ var _a;
1977
+ const rootElement = item.getRootElement();
1978
+ if (rootElement) {
1979
+ const initialTransform = (_a = this._itemPositions.find(current => current.drag === item)) === null || _a === void 0 ? void 0 : _a.initialTransform;
1980
+ rootElement.style.transform = initialTransform || '';
1981
+ }
1982
+ });
1983
+ this._siblings.forEach(sibling => sibling._stopReceiving(this));
1984
+ this._activeDraggables = [];
1985
+ this._itemPositions = [];
1986
+ this._previousSwap.drag = null;
1987
+ this._previousSwap.delta = 0;
1988
+ this._previousSwap.overlaps = false;
1989
+ this._stopScrolling();
1990
+ this._viewportScrollSubscription.unsubscribe();
1991
+ this._parentPositions.clear();
1992
+ }
1993
+ /**
1994
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
1995
+ * @param currentIndex Index of the item currently being dragged.
1996
+ * @param siblings All of the items in the list.
1997
+ * @param delta Direction in which the user is moving.
1998
+ */
1999
+ _getSiblingOffsetPx(currentIndex, siblings, delta) {
2000
+ const isHorizontal = this._orientation === 'horizontal';
2001
+ const currentPosition = siblings[currentIndex].clientRect;
2002
+ const immediateSibling = siblings[currentIndex + delta * -1];
2003
+ let siblingOffset = currentPosition[isHorizontal ? 'width' : 'height'] * delta;
2004
+ if (immediateSibling) {
2005
+ const start = isHorizontal ? 'left' : 'top';
2006
+ const end = isHorizontal ? 'right' : 'bottom';
2007
+ // Get the spacing between the start of the current item and the end of the one immediately
2008
+ // after it in the direction in which the user is dragging, or vice versa. We add it to the
2009
+ // offset in order to push the element to where it will be when it's inline and is influenced
2010
+ // by the `margin` of its siblings.
2011
+ if (delta === -1) {
2012
+ siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
2013
+ }
2014
+ else {
2015
+ siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
2016
+ }
2017
+ }
2018
+ return siblingOffset;
2019
+ }
2020
+ /**
2021
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
2022
+ * @param currentPosition Current position of the item.
2023
+ * @param newPosition Position of the item where the current item should be moved.
2024
+ * @param delta Direction in which the user is moving.
2025
+ */
2026
+ _getItemOffsetPx(currentPosition, newPosition, delta) {
2027
+ const isHorizontal = this._orientation === 'horizontal';
2028
+ let itemOffset = isHorizontal
2029
+ ? newPosition.left - currentPosition.left
2030
+ : newPosition.top - currentPosition.top;
2031
+ // Account for differences in the item width/height.
2032
+ if (delta === -1) {
2033
+ itemOffset += isHorizontal
2034
+ ? newPosition.width - currentPosition.width
2035
+ : newPosition.height - currentPosition.height;
2036
+ }
2037
+ return itemOffset;
2038
+ }
2039
+ /**
2040
+ * Checks if pointer is entering in the first position
2041
+ * @param pointerX Position of the user's pointer along the X axis.
2042
+ * @param pointerY Position of the user's pointer along the Y axis.
2043
+ */
2044
+ _shouldEnterAsFirstChild(pointerX, pointerY) {
2045
+ if (!this._activeDraggables.length) {
2046
+ return false;
2047
+ }
2048
+ const itemPositions = this._itemPositions;
2049
+ const isHorizontal = this._orientation === 'horizontal';
2050
+ // `itemPositions` are sorted by position while `activeDraggables` are sorted by child index
2051
+ // check if container is using some sort of "reverse" ordering (eg: flex-direction: row-reverse)
2052
+ const reversed = itemPositions[0].drag !== this._activeDraggables[0];
2053
+ if (reversed) {
2054
+ const lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
2055
+ return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
2056
+ }
2057
+ else {
2058
+ const firstItemRect = itemPositions[0].clientRect;
2059
+ return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
2060
+ }
2061
+ }
2062
+ /**
2063
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
2064
+ * @param item Item that is being sorted.
2065
+ * @param pointerX Position of the user's pointer along the X axis.
2066
+ * @param pointerY Position of the user's pointer along the Y axis.
2067
+ * @param delta Direction in which the user is moving their pointer.
2068
+ */
2069
+ _getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {
2070
+ const isHorizontal = this._orientation === 'horizontal';
2071
+ const index = this._itemPositions.findIndex(({ drag, clientRect }) => {
2072
+ // Skip the item itself.
2073
+ if (drag === item) {
2074
+ return false;
2075
+ }
2076
+ if (delta) {
2077
+ const direction = isHorizontal ? delta.x : delta.y;
2078
+ // If the user is still hovering over the same item as last time, their cursor hasn't left
2079
+ // the item after we made the swap, and they didn't change the direction in which they're
2080
+ // dragging, we don't consider it a direction swap.
2081
+ if (drag === this._previousSwap.drag &&
2082
+ this._previousSwap.overlaps &&
2083
+ direction === this._previousSwap.delta) {
2084
+ return false;
2085
+ }
2086
+ }
2087
+ return isHorizontal
2088
+ ? // Round these down since most browsers report client rects with
2089
+ // sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
2090
+ pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right)
2091
+ : pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
2092
+ });
2093
+ return index === -1 || !this.sortPredicate(index, item, this) ? -1 : index;
2094
+ }
2095
+ /** Caches the current items in the list and their positions. */
2096
+ _cacheItems() {
2097
+ this._activeDraggables = this._draggables.slice();
2098
+ this._cacheItemPositions();
2099
+ this._cacheParentPositions();
2100
+ }
2101
+ /**
2102
+ * Checks whether the user's pointer is positioned over the container.
2103
+ * @param x Pointer position along the X axis.
2104
+ * @param y Pointer position along the Y axis.
2105
+ */
2106
+ _isOverContainer(x, y) {
2107
+ return this._clientRect != null && isInsideClientRect(this._clientRect, x, y);
2108
+ }
2109
+ /**
2110
+ * Figures out whether an item should be moved into a sibling
2111
+ * drop container, based on its current position.
2112
+ * @param item Drag item that is being moved.
2113
+ * @param x Position of the item along the X axis.
2114
+ * @param y Position of the item along the Y axis.
2115
+ */
2116
+ _getSiblingContainerFromPosition(item, x, y) {
2117
+ return this._siblings.find(sibling => sibling._canReceive(item, x, y));
2118
+ }
2119
+ /**
2120
+ * Checks whether the drop list can receive the passed-in item.
2121
+ * @param item Item that is being dragged into the list.
2122
+ * @param x Position of the item along the X axis.
2123
+ * @param y Position of the item along the Y axis.
2124
+ */
2125
+ _canReceive(item, x, y) {
2126
+ if (!this._clientRect ||
2127
+ !isInsideClientRect(this._clientRect, x, y) ||
2128
+ !this.enterPredicate(item, this)) {
2129
+ return false;
2130
+ }
2131
+ const elementFromPoint = this._getShadowRoot().elementFromPoint(x, y);
2132
+ // If there's no element at the pointer position, then
2133
+ // the client rect is probably scrolled out of the view.
2134
+ if (!elementFromPoint) {
2135
+ return false;
2136
+ }
2137
+ const nativeElement = coerceElement(this.element);
2138
+ // The `ClientRect`, that we're using to find the container over which the user is
2139
+ // hovering, doesn't give us any information on whether the element has been scrolled
2140
+ // out of the view or whether it's overlapping with other containers. This means that
2141
+ // we could end up transferring the item into a container that's invisible or is positioned
2142
+ // below another one. We use the result from `elementFromPoint` to get the top-most element
2143
+ // at the pointer position and to find whether it's one of the intersecting drop containers.
2144
+ return elementFromPoint === nativeElement || nativeElement.contains(elementFromPoint);
2145
+ }
2146
+ /**
2147
+ * Called by one of the connected drop lists when a dragging sequence has started.
2148
+ * @param sibling Sibling in which dragging has started.
2149
+ */
2150
+ _startReceiving(sibling, items) {
2151
+ const activeSiblings = this._activeSiblings;
2152
+ if (!activeSiblings.has(sibling) &&
2153
+ items.every(item => {
2154
+ // Note that we have to add an exception to the `enterPredicate` for items that started off
2155
+ // in this drop list. The drag ref has logic that allows an item to return to its initial
2156
+ // container, if it has left the initial container and none of the connected containers
2157
+ // allow it to enter. See `DragRef._updateActiveDropContainer` for more context.
2158
+ return this.enterPredicate(item, this) || this._draggables.indexOf(item) > -1;
2159
+ })) {
2160
+ activeSiblings.add(sibling);
2161
+ this._cacheParentPositions();
2162
+ this._listenToScrollEvents();
2163
+ }
2164
+ }
2165
+ /**
2166
+ * Called by a connected drop list when dragging has stopped.
2167
+ * @param sibling Sibling whose dragging has stopped.
2168
+ */
2169
+ _stopReceiving(sibling) {
2170
+ this._activeSiblings.delete(sibling);
2171
+ this._viewportScrollSubscription.unsubscribe();
2172
+ }
2173
+ /**
2174
+ * Starts listening to scroll events on the viewport.
2175
+ * Used for updating the internal state of the list.
2176
+ */
2177
+ _listenToScrollEvents() {
2178
+ this._viewportScrollSubscription = this._dragDropRegistry
2179
+ .scrolled(this._getShadowRoot())
2180
+ .subscribe(event => {
2181
+ if (this.isDragging()) {
2182
+ const scrollDifference = this._parentPositions.handleScroll(event);
2183
+ if (scrollDifference) {
2184
+ // Since we know the amount that the user has scrolled we can shift all of the
2185
+ // client rectangles ourselves. This is cheaper than re-measuring everything and
2186
+ // we can avoid inconsistent behavior where we might be measuring the element before
2187
+ // its position has changed.
2188
+ this._itemPositions.forEach(({ clientRect }) => {
2189
+ adjustClientRect(clientRect, scrollDifference.top, scrollDifference.left);
2190
+ });
2191
+ // We need two loops for this, because we want all of the cached
2192
+ // positions to be up-to-date before we re-sort the item.
2193
+ this._itemPositions.forEach(({ drag }) => {
2194
+ if (this._dragDropRegistry.isDragging(drag)) {
2195
+ // We need to re-sort the item manually, because the pointer move
2196
+ // events won't be dispatched while the user is scrolling.
2197
+ drag._sortFromLastPointerPosition();
2198
+ }
2199
+ });
2200
+ }
2201
+ }
2202
+ else if (this.isReceiving()) {
2203
+ this._cacheParentPositions();
2204
+ }
2205
+ });
2206
+ }
2207
+ /**
2208
+ * Lazily resolves and returns the shadow root of the element. We do this in a function, rather
2209
+ * than saving it in property directly on init, because we want to resolve it as late as possible
2210
+ * in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
2211
+ * constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
2212
+ */
2213
+ _getShadowRoot() {
2214
+ if (!this._cachedShadowRoot) {
2215
+ const shadowRoot = _getShadowRoot(coerceElement(this.element));
2216
+ this._cachedShadowRoot = (shadowRoot || this._document);
2217
+ }
2218
+ return this._cachedShadowRoot;
2219
+ }
2220
+ /** Notifies any siblings that may potentially receive the item. */
2221
+ _notifyReceivingSiblings() {
2222
+ const draggedItems = this._activeDraggables.filter(item => item.isDragging());
2223
+ this._siblings.forEach(sibling => sibling._startReceiving(this, draggedItems));
2224
+ }
2225
+ }
2226
+ /**
2227
+ * Gets whether the vertical auto-scroll direction of a node.
2228
+ * @param clientRect Dimensions of the node.
2229
+ * @param pointerY Position of the user's pointer along the y axis.
2230
+ */
2231
+ function getVerticalScrollDirection(clientRect, pointerY) {
2232
+ const { top, bottom, height } = clientRect;
2233
+ const yThreshold = height * SCROLL_PROXIMITY_THRESHOLD;
2234
+ if (pointerY >= top - yThreshold && pointerY <= top + yThreshold) {
2235
+ return 1 /* UP */;
2236
+ }
2237
+ else if (pointerY >= bottom - yThreshold && pointerY <= bottom + yThreshold) {
2238
+ return 2 /* DOWN */;
2239
+ }
2240
+ return 0 /* NONE */;
2241
+ }
2242
+ /**
2243
+ * Gets whether the horizontal auto-scroll direction of a node.
2244
+ * @param clientRect Dimensions of the node.
2245
+ * @param pointerX Position of the user's pointer along the x axis.
2246
+ */
2247
+ function getHorizontalScrollDirection(clientRect, pointerX) {
2248
+ const { left, right, width } = clientRect;
2249
+ const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
2250
+ if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
2251
+ return 1 /* LEFT */;
2252
+ }
2253
+ else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
2254
+ return 2 /* RIGHT */;
2255
+ }
2256
+ return 0 /* NONE */;
2257
+ }
2258
+ /**
2259
+ * Gets the directions in which an element node should be scrolled,
2260
+ * assuming that the user's pointer is already within it scrollable region.
2261
+ * @param element Element for which we should calculate the scroll direction.
2262
+ * @param clientRect Bounding client rectangle of the element.
2263
+ * @param pointerX Position of the user's pointer along the x axis.
2264
+ * @param pointerY Position of the user's pointer along the y axis.
2265
+ */
2266
+ function getElementScrollDirections(element, clientRect, pointerX, pointerY) {
2267
+ const computedVertical = getVerticalScrollDirection(clientRect, pointerY);
2268
+ const computedHorizontal = getHorizontalScrollDirection(clientRect, pointerX);
2269
+ let verticalScrollDirection = 0 /* NONE */;
2270
+ let horizontalScrollDirection = 0 /* NONE */;
2271
+ // Note that we here we do some extra checks for whether the element is actually scrollable in
2272
+ // a certain direction and we only assign the scroll direction if it is. We do this so that we
2273
+ // can allow other elements to be scrolled, if the current element can't be scrolled anymore.
2274
+ // This allows us to handle cases where the scroll regions of two scrollable elements overlap.
2275
+ if (computedVertical) {
2276
+ const scrollTop = element.scrollTop;
2277
+ if (computedVertical === 1 /* UP */) {
2278
+ if (scrollTop > 0) {
2279
+ verticalScrollDirection = 1 /* UP */;
2280
+ }
2281
+ }
2282
+ else if (element.scrollHeight - scrollTop > element.clientHeight) {
2283
+ verticalScrollDirection = 2 /* DOWN */;
2284
+ }
2285
+ }
2286
+ if (computedHorizontal) {
2287
+ const scrollLeft = element.scrollLeft;
2288
+ if (computedHorizontal === 1 /* LEFT */) {
2289
+ if (scrollLeft > 0) {
2290
+ horizontalScrollDirection = 1 /* LEFT */;
2291
+ }
2292
+ }
2293
+ else if (element.scrollWidth - scrollLeft > element.clientWidth) {
2294
+ horizontalScrollDirection = 2 /* RIGHT */;
2295
+ }
2296
+ }
2297
+ return [verticalScrollDirection, horizontalScrollDirection];
2298
+ }
2299
+
2300
+ /**
2301
+ * @license
2302
+ * Copyright Google LLC All Rights Reserved.
2303
+ *
2304
+ * Use of this source code is governed by an MIT-style license that can be
2305
+ * found in the LICENSE file at https://angular.io/license
2306
+ */
2307
+ /** Event options that can be used to bind an active, capturing event. */
2308
+ const activeCapturingEventOptions = normalizePassiveListenerOptions({
2309
+ passive: false,
2310
+ capture: true,
2311
+ });
2312
+ /**
2313
+ * Service that keeps track of all the drag item and drop container
2314
+ * instances, and manages global event listeners on the `document`.
2315
+ * @docs-private
2316
+ */
2317
+ // Note: this class is generic, rather than referencing CdkDrag and CdkDropList directly, in order
2318
+ // to avoid circular imports. If we were to reference them here, importing the registry into the
2319
+ // classes that are registering themselves will introduce a circular import.
2320
+ class DragDropRegistry {
2321
+ constructor(_ngZone, _document) {
2322
+ this._ngZone = _ngZone;
2323
+ /** Registered drop container instances. */
2324
+ this._dropInstances = new Set();
2325
+ /** Registered drag item instances. */
2326
+ this._dragInstances = new Set();
2327
+ /** Drag item instances that are currently being dragged. */
2328
+ this._activeDragInstances = [];
2329
+ /** Keeps track of the event listeners that we've bound to the `document`. */
2330
+ this._globalListeners = new Map();
2331
+ /**
2332
+ * Predicate function to check if an item is being dragged. Moved out into a property,
2333
+ * because it'll be called a lot and we don't want to create a new function every time.
2334
+ */
2335
+ this._draggingPredicate = (item) => item.isDragging();
2336
+ /**
2337
+ * Emits the `touchmove` or `mousemove` events that are dispatched
2338
+ * while the user is dragging a drag item instance.
2339
+ */
2340
+ this.pointerMove = new Subject();
2341
+ /**
2342
+ * Emits the `touchend` or `mouseup` events that are dispatched
2343
+ * while the user is dragging a drag item instance.
2344
+ */
2345
+ this.pointerUp = new Subject();
2346
+ /**
2347
+ * Emits when the viewport has been scrolled while the user is dragging an item.
2348
+ * @deprecated To be turned into a private member. Use the `scrolled` method instead.
2349
+ * @breaking-change 13.0.0
2350
+ */
2351
+ this.scroll = new Subject();
2352
+ /**
2353
+ * Event listener that will prevent the default browser action while the user is dragging.
2354
+ * @param event Event whose default action should be prevented.
2355
+ */
2356
+ this._preventDefaultWhileDragging = (event) => {
2357
+ if (this._activeDragInstances.length > 0) {
2358
+ event.preventDefault();
2359
+ }
2360
+ };
2361
+ /** Event listener for `touchmove` that is bound even if no dragging is happening. */
2362
+ this._persistentTouchmoveListener = (event) => {
2363
+ if (this._activeDragInstances.length > 0) {
2364
+ // Note that we only want to prevent the default action after dragging has actually started.
2365
+ // Usually this is the same time at which the item is added to the `_activeDragInstances`,
2366
+ // but it could be pushed back if the user has set up a drag delay or threshold.
2367
+ if (this._activeDragInstances.some(this._draggingPredicate)) {
2368
+ event.preventDefault();
2369
+ }
2370
+ this.pointerMove.next(event);
2371
+ }
2372
+ };
2373
+ this._document = _document;
2374
+ }
2375
+ /** Adds a drop container to the registry. */
2376
+ registerDropContainer(drop) {
2377
+ if (!this._dropInstances.has(drop)) {
2378
+ this._dropInstances.add(drop);
2379
+ }
2380
+ }
2381
+ /** Adds a drag item instance to the registry. */
2382
+ registerDragItem(drag) {
2383
+ this._dragInstances.add(drag);
2384
+ // The `touchmove` event gets bound once, ahead of time, because WebKit
2385
+ // won't preventDefault on a dynamically-added `touchmove` listener.
2386
+ // See https://bugs.webkit.org/show_bug.cgi?id=184250.
2387
+ if (this._dragInstances.size === 1) {
2388
+ this._ngZone.runOutsideAngular(() => {
2389
+ // The event handler has to be explicitly active,
2390
+ // because newer browsers make it passive by default.
2391
+ this._document.addEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);
2392
+ });
2393
+ }
2394
+ }
2395
+ /** Removes a drop container from the registry. */
2396
+ removeDropContainer(drop) {
2397
+ this._dropInstances.delete(drop);
2398
+ }
2399
+ /** Removes a drag item instance from the registry. */
2400
+ removeDragItem(drag) {
2401
+ this._dragInstances.delete(drag);
2402
+ this.stopDragging(drag);
2403
+ if (this._dragInstances.size === 0) {
2404
+ this._document.removeEventListener('touchmove', this._persistentTouchmoveListener, activeCapturingEventOptions);
2405
+ }
2406
+ }
2407
+ /**
2408
+ * Starts the dragging sequence for a drag instance.
2409
+ * @param drag Drag instance which is being dragged.
2410
+ * @param event Event that initiated the dragging.
2411
+ */
2412
+ startDragging(drag, event) {
2413
+ // Do not process the same drag twice to avoid memory leaks and redundant listeners
2414
+ if (this._activeDragInstances.indexOf(drag) > -1) {
2415
+ return;
2416
+ }
2417
+ this._activeDragInstances.push(drag);
2418
+ if (this._activeDragInstances.length === 1) {
2419
+ const isTouchEvent = event.type.startsWith('touch');
2420
+ // We explicitly bind __active__ listeners here, because newer browsers will default to
2421
+ // passive ones for `mousemove` and `touchmove`. The events need to be active, because we
2422
+ // use `preventDefault` to prevent the page from scrolling while the user is dragging.
2423
+ this._globalListeners
2424
+ .set(isTouchEvent ? 'touchend' : 'mouseup', {
2425
+ handler: (e) => this.pointerUp.next(e),
2426
+ options: true,
2427
+ })
2428
+ .set('scroll', {
2429
+ handler: (e) => this.scroll.next(e),
2430
+ // Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
2431
+ // the document. See https://github.com/angular/components/issues/17144.
2432
+ options: true,
2433
+ })
2434
+ // Preventing the default action on `mousemove` isn't enough to disable text selection
2435
+ // on Safari so we need to prevent the selection event as well. Alternatively this can
2436
+ // be done by setting `user-select: none` on the `body`, however it has causes a style
2437
+ // recalculation which can be expensive on pages with a lot of elements.
2438
+ .set('selectstart', {
2439
+ handler: this._preventDefaultWhileDragging,
2440
+ options: activeCapturingEventOptions,
2441
+ });
2442
+ // We don't have to bind a move event for touch drag sequences, because
2443
+ // we already have a persistent global one bound from `registerDragItem`.
2444
+ if (!isTouchEvent) {
2445
+ this._globalListeners.set('mousemove', {
2446
+ handler: (e) => this.pointerMove.next(e),
2447
+ options: activeCapturingEventOptions,
2448
+ });
2449
+ }
2450
+ this._ngZone.runOutsideAngular(() => {
2451
+ this._globalListeners.forEach((config, name) => {
2452
+ this._document.addEventListener(name, config.handler, config.options);
2453
+ });
2454
+ });
2455
+ }
2456
+ }
2457
+ /** Stops dragging a drag item instance. */
2458
+ stopDragging(drag) {
2459
+ const index = this._activeDragInstances.indexOf(drag);
2460
+ if (index > -1) {
2461
+ this._activeDragInstances.splice(index, 1);
2462
+ if (this._activeDragInstances.length === 0) {
2463
+ this._clearGlobalListeners();
2464
+ }
2465
+ }
2466
+ }
2467
+ /** Gets whether a drag item instance is currently being dragged. */
2468
+ isDragging(drag) {
2469
+ return this._activeDragInstances.indexOf(drag) > -1;
2470
+ }
2471
+ /**
2472
+ * Gets a stream that will emit when any element on the page is scrolled while an item is being
2473
+ * dragged.
2474
+ * @param shadowRoot Optional shadow root that the current dragging sequence started from.
2475
+ * Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
2476
+ * be used to include an additional top-level listener at the shadow root level.
2477
+ */
2478
+ scrolled(shadowRoot) {
2479
+ const streams = [this.scroll];
2480
+ if (shadowRoot && shadowRoot !== this._document) {
2481
+ // Note that this is basically the same as `fromEvent` from rjxs, but we do it ourselves,
2482
+ // because we want to guarantee that the event is bound outside of the `NgZone`. With
2483
+ // `fromEvent` it'll only happen if the subscription is outside the `NgZone`.
2484
+ streams.push(new Observable((observer) => {
2485
+ return this._ngZone.runOutsideAngular(() => {
2486
+ const eventOptions = true;
2487
+ const callback = (event) => {
2488
+ if (this._activeDragInstances.length) {
2489
+ observer.next(event);
2490
+ }
2491
+ };
2492
+ shadowRoot.addEventListener('scroll', callback, eventOptions);
2493
+ return () => {
2494
+ shadowRoot.removeEventListener('scroll', callback, eventOptions);
2495
+ };
2496
+ });
2497
+ }));
2498
+ }
2499
+ return merge(...streams);
2500
+ }
2501
+ ngOnDestroy() {
2502
+ this._dragInstances.forEach(instance => this.removeDragItem(instance));
2503
+ this._dropInstances.forEach(instance => this.removeDropContainer(instance));
2504
+ this._clearGlobalListeners();
2505
+ this.pointerMove.complete();
2506
+ this.pointerUp.complete();
2507
+ }
2508
+ /** Clears out the global event listeners from the `document`. */
2509
+ _clearGlobalListeners() {
2510
+ this._globalListeners.forEach((config, name) => {
2511
+ this._document.removeEventListener(name, config.handler, config.options);
2512
+ });
2513
+ this._globalListeners.clear();
2514
+ }
2515
+ }
2516
+ DragDropRegistry.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropRegistry, deps: [{ token: i0.NgZone }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
2517
+ DragDropRegistry.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropRegistry, providedIn: 'root' });
2518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropRegistry, decorators: [{
2519
+ type: Injectable,
2520
+ args: [{ providedIn: 'root' }]
2521
+ }], ctorParameters: function () {
2522
+ return [{ type: i0.NgZone }, { type: undefined, decorators: [{
2523
+ type: Inject,
2524
+ args: [DOCUMENT]
2525
+ }] }];
2526
+ } });
2527
+
2528
+ /**
2529
+ * @license
2530
+ * Copyright Google LLC All Rights Reserved.
2531
+ *
2532
+ * Use of this source code is governed by an MIT-style license that can be
2533
+ * found in the LICENSE file at https://angular.io/license
2534
+ */
2535
+ /** Default configuration to be used when creating a `DragRef`. */
2536
+ const DEFAULT_CONFIG = {
2537
+ dragStartThreshold: 5,
2538
+ pointerDirectionChangeThreshold: 5,
2539
+ };
2540
+ /**
2541
+ * Service that allows for drag-and-drop functionality to be attached to DOM elements.
2542
+ */
2543
+ class DragDrop {
2544
+ constructor(_document, _ngZone, _viewportRuler, _dragDropRegistry) {
2545
+ this._document = _document;
2546
+ this._ngZone = _ngZone;
2547
+ this._viewportRuler = _viewportRuler;
2548
+ this._dragDropRegistry = _dragDropRegistry;
2549
+ }
2550
+ /**
2551
+ * Turns an element into a draggable item.
2552
+ * @param element Element to which to attach the dragging functionality.
2553
+ * @param config Object used to configure the dragging behavior.
2554
+ */
2555
+ createDrag(element, config = DEFAULT_CONFIG) {
2556
+ return new DragRef(element, config, this._document, this._ngZone, this._viewportRuler, this._dragDropRegistry);
2557
+ }
2558
+ /**
2559
+ * Turns an element into a drop list.
2560
+ * @param element Element to which to attach the drop list functionality.
2561
+ */
2562
+ createDropList(element) {
2563
+ return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler);
2564
+ }
2565
+ }
2566
+ DragDrop.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDrop, deps: [{ token: DOCUMENT }, { token: i0.NgZone }, { token: i1.ViewportRuler }, { token: DragDropRegistry }], target: i0.ɵɵFactoryTarget.Injectable });
2567
+ DragDrop.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDrop, providedIn: 'root' });
2568
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDrop, decorators: [{
2569
+ type: Injectable,
2570
+ args: [{ providedIn: 'root' }]
2571
+ }], ctorParameters: function () {
2572
+ return [{ type: undefined, decorators: [{
2573
+ type: Inject,
2574
+ args: [DOCUMENT]
2575
+ }] }, { type: i0.NgZone }, { type: i1.ViewportRuler }, { type: DragDropRegistry }];
2576
+ } });
2577
+
2578
+ /**
2579
+ * @license
2580
+ * Copyright Google LLC All Rights Reserved.
2581
+ *
2582
+ * Use of this source code is governed by an MIT-style license that can be
2583
+ * found in the LICENSE file at https://angular.io/license
2584
+ */
2585
+ /**
2586
+ * Injection token that can be used for a `CdkDrag` to provide itself as a parent to the
2587
+ * drag-specific child directive (`CdkDragHandle`, `CdkDragPreview` etc.). Used primarily
2588
+ * to avoid circular imports.
2589
+ * @docs-private
2590
+ */
2591
+ const CDK_DRAG_PARENT = new InjectionToken('CDK_DRAG_PARENT');
2592
+
2593
+ /**
2594
+ * @license
2595
+ * Copyright Google LLC All Rights Reserved.
2596
+ *
2597
+ * Use of this source code is governed by an MIT-style license that can be
2598
+ * found in the LICENSE file at https://angular.io/license
2599
+ */
2600
+ /**
2601
+ * Injection token that can be used to reference instances of `CdkDropListGroup`. It serves as
2602
+ * alternative token to the actual `CdkDropListGroup` class which could cause unnecessary
2603
+ * retention of the class and its directive metadata.
2604
+ */
2605
+ const CDK_DROP_LIST_GROUP = new InjectionToken('CdkDropListGroup');
2606
+ /**
2607
+ * Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
2608
+ * elements that are placed inside a `cdkDropListGroup` will be connected to each other
2609
+ * automatically. Can be used as an alternative to the `cdkDropListConnectedTo` input
2610
+ * from `cdkDropList`.
2611
+ */
2612
+ class CdkDropListGroup {
2613
+ constructor() {
2614
+ /** Drop lists registered inside the group. */
2615
+ this._items = new Set();
2616
+ this._disabled = false;
2617
+ }
2618
+ /** Whether starting a dragging sequence from inside this group is disabled. */
2619
+ get disabled() {
2620
+ return this._disabled;
2621
+ }
2622
+ set disabled(value) {
2623
+ this._disabled = coerceBooleanProperty(value);
2624
+ }
2625
+ ngOnDestroy() {
2626
+ this._items.clear();
2627
+ }
2628
+ }
2629
+ CdkDropListGroup.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDropListGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2630
+ CdkDropListGroup.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDropListGroup, selector: "[cdkDropListGroup]", inputs: { disabled: ["cdkDropListGroupDisabled", "disabled"] }, providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }], exportAs: ["cdkDropListGroup"], ngImport: i0 });
2631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDropListGroup, decorators: [{
2632
+ type: Directive,
2633
+ args: [{
2634
+ selector: '[cdkDropListGroup]',
2635
+ exportAs: 'cdkDropListGroup',
2636
+ providers: [{ provide: CDK_DROP_LIST_GROUP, useExisting: CdkDropListGroup }],
2637
+ }]
2638
+ }], propDecorators: { disabled: [{
2639
+ type: Input,
2640
+ args: ['cdkDropListGroupDisabled']
2641
+ }] } });
2642
+
2643
+ /**
2644
+ * @license
2645
+ * Copyright Google LLC All Rights Reserved.
2646
+ *
2647
+ * Use of this source code is governed by an MIT-style license that can be
2648
+ * found in the LICENSE file at https://angular.io/license
2649
+ */
2650
+ /**
2651
+ * Injection token that can be used to configure the
2652
+ * behavior of the drag&drop-related components.
2653
+ */
2654
+ const CDK_DRAG_CONFIG = new InjectionToken('CDK_DRAG_CONFIG');
2655
+
2656
+ /**
2657
+ * @license
2658
+ * Copyright Google LLC All Rights Reserved.
2659
+ *
2660
+ * Use of this source code is governed by an MIT-style license that can be
2661
+ * found in the LICENSE file at https://angular.io/license
2662
+ */
2663
+ /**
2664
+ * Asserts that a particular node is an element.
2665
+ * @param node Node to be checked.
2666
+ * @param name Name to attach to the error message.
2667
+ */
2668
+ function assertElementNode(node, name) {
2669
+ if (node.nodeType !== 1) {
2670
+ throw Error(`${name} must be attached to an element node. ` + `Currently attached to "${node.nodeName}".`);
2671
+ }
2672
+ }
2673
+
2674
+ /**
2675
+ * @license
2676
+ * Copyright Google LLC All Rights Reserved.
2677
+ *
2678
+ * Use of this source code is governed by an MIT-style license that can be
2679
+ * found in the LICENSE file at https://angular.io/license
2680
+ */
2681
+ /** Counter used to generate unique ids for drop zones. */
2682
+ let _uniqueIdCounter = 0;
2683
+ /**
2684
+ * Injection token that can be used to reference instances of `CdkDropList`. It serves as
2685
+ * alternative token to the actual `CdkDropList` class which could cause unnecessary
2686
+ * retention of the class and its directive metadata.
2687
+ */
2688
+ const CDK_DROP_LIST = new InjectionToken('CdkDropList');
2689
+ /** Container that wraps a set of draggable items. */
2690
+ class CdkDropList {
2691
+ constructor(
2692
+ /** Element that the drop list is attached to. */
2693
+ element, dragDrop, _changeDetectorRef, _scrollDispatcher, _dir, _group, config) {
2694
+ this.element = element;
2695
+ this._changeDetectorRef = _changeDetectorRef;
2696
+ this._scrollDispatcher = _scrollDispatcher;
2697
+ this._dir = _dir;
2698
+ this._group = _group;
2699
+ /** Emits when the list has been destroyed. */
2700
+ this._destroyed = new Subject();
2701
+ /**
2702
+ * Other draggable containers that this container is connected to and into which the
2703
+ * container's items can be transferred. Can either be references to other drop containers,
2704
+ * or their unique IDs.
2705
+ */
2706
+ this.connectedTo = [];
2707
+ /**
2708
+ * Unique ID for the drop zone. Can be used as a reference
2709
+ * in the `connectedTo` of another `CdkDropList`.
2710
+ */
2711
+ this.id = `cdk-drop-list-${_uniqueIdCounter++}`;
2712
+ /**
2713
+ * Function that is used to determine whether an item
2714
+ * is allowed to be moved into a drop container.
2715
+ */
2716
+ this.enterPredicate = () => true;
2717
+ /** Functions that is used to determine whether an item can be sorted into a particular index. */
2718
+ this.sortPredicate = () => true;
2719
+ /** Emits when the user drops an item inside the container. */
2720
+ this.dropped = new EventEmitter();
2721
+ /**
2722
+ * Emits when the user has moved a new drag item into this container.
2723
+ */
2724
+ this.entered = new EventEmitter();
2725
+ /**
2726
+ * Emits when the user removes an item from the container
2727
+ * by dragging it into another container.
2728
+ */
2729
+ this.exited = new EventEmitter();
2730
+ /** Emits as the user is swapping items while actively dragging. */
2731
+ this.sorted = new EventEmitter();
2732
+ /**
2733
+ * Keeps track of the items that are registered with this container. Historically we used to
2734
+ * do this with a `ContentChildren` query, however queries don't handle transplanted views very
2735
+ * well which means that we can't handle cases like dragging the headers of a `mat-table`
2736
+ * correctly. What we do instead is to have the items register themselves with the container
2737
+ * and then we sort them based on their position in the DOM.
2738
+ */
2739
+ this._unsortedItems = new Set();
2740
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2741
+ assertElementNode(element.nativeElement, 'cdkDropList');
2742
+ }
2743
+ this._dropListRef = dragDrop.createDropList(element);
2744
+ this._dropListRef.data = this;
2745
+ if (config) {
2746
+ this._assignDefaults(config);
2747
+ }
2748
+ this._dropListRef.enterPredicate = (drag, drop) => {
2749
+ return this.enterPredicate(drag.data, drop.data);
2750
+ };
2751
+ this._dropListRef.sortPredicate = (index, drag, drop) => {
2752
+ return this.sortPredicate(index, drag.data, drop.data);
2753
+ };
2754
+ this._setupInputSyncSubscription(this._dropListRef);
2755
+ this._handleEvents(this._dropListRef);
2756
+ CdkDropList._dropLists.push(this);
2757
+ if (_group) {
2758
+ _group._items.add(this);
2759
+ }
2760
+ }
2761
+ /** Whether starting a dragging sequence from this container is disabled. */
2762
+ get disabled() {
2763
+ return this._disabled || (!!this._group && this._group.disabled);
2764
+ }
2765
+ set disabled(value) {
2766
+ // Usually we sync the directive and ref state right before dragging starts, in order to have
2767
+ // a single point of failure and to avoid having to use setters for everything. `disabled` is
2768
+ // a special case, because it can prevent the `beforeStarted` event from firing, which can lock
2769
+ // the user in a disabled state, so we also need to sync it as it's being set.
2770
+ this._dropListRef.disabled = this._disabled = coerceBooleanProperty(value);
2771
+ }
2772
+ /** Registers an items with the drop list. */
2773
+ addItem(item) {
2774
+ this._unsortedItems.add(item);
2775
+ if (this._dropListRef.isDragging()) {
2776
+ this._syncItemsWithRef();
2777
+ }
2778
+ }
2779
+ /** Removes an item from the drop list. */
2780
+ removeItem(item) {
2781
+ this._unsortedItems.delete(item);
2782
+ if (this._dropListRef.isDragging()) {
2783
+ this._syncItemsWithRef();
2784
+ }
2785
+ }
2786
+ /** Gets the registered items in the list, sorted by their position in the DOM. */
2787
+ getSortedItems() {
2788
+ return Array.from(this._unsortedItems).sort((a, b) => {
2789
+ const documentPosition = a._dragRef
2790
+ .getVisibleElement()
2791
+ .compareDocumentPosition(b._dragRef.getVisibleElement());
2792
+ // `compareDocumentPosition` returns a bitmask so we have to use a bitwise operator.
2793
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
2794
+ // tslint:disable-next-line:no-bitwise
2795
+ return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
2796
+ });
2797
+ }
2798
+ ngOnDestroy() {
2799
+ const index = CdkDropList._dropLists.indexOf(this);
2800
+ if (index > -1) {
2801
+ CdkDropList._dropLists.splice(index, 1);
2802
+ }
2803
+ if (this._group) {
2804
+ this._group._items.delete(this);
2805
+ }
2806
+ this._unsortedItems.clear();
2807
+ this._dropListRef.dispose();
2808
+ this._destroyed.next();
2809
+ this._destroyed.complete();
2810
+ }
2811
+ /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
2812
+ _setupInputSyncSubscription(ref) {
2813
+ if (this._dir) {
2814
+ this._dir.change
2815
+ .pipe(startWith(this._dir.value), takeUntil(this._destroyed))
2816
+ .subscribe(value => ref.withDirection(value));
2817
+ }
2818
+ ref.beforeStarted.subscribe(() => {
2819
+ const siblings = coerceArray(this.connectedTo).map(drop => {
2820
+ if (typeof drop === 'string') {
2821
+ const correspondingDropList = CdkDropList._dropLists.find(list => list.id === drop);
2822
+ if (!correspondingDropList && (typeof ngDevMode === 'undefined' || ngDevMode)) {
2823
+ console.warn(`CdkDropList could not find connected drop list with id "${drop}"`);
2824
+ }
2825
+ return correspondingDropList;
2826
+ }
2827
+ return drop;
2828
+ });
2829
+ if (this._group) {
2830
+ this._group._items.forEach(drop => {
2831
+ if (siblings.indexOf(drop) === -1) {
2832
+ siblings.push(drop);
2833
+ }
2834
+ });
2835
+ }
2836
+ // Note that we resolve the scrollable parents here so that we delay the resolution
2837
+ // as long as possible, ensuring that the element is in its final place in the DOM.
2838
+ if (!this._scrollableParentsResolved) {
2839
+ const scrollableParents = this._scrollDispatcher
2840
+ .getAncestorScrollContainers(this.element)
2841
+ .map(scrollable => scrollable.getElementRef().nativeElement);
2842
+ this._dropListRef.withScrollableParents(scrollableParents);
2843
+ // Only do this once since it involves traversing the DOM and the parents
2844
+ // shouldn't be able to change without the drop list being destroyed.
2845
+ this._scrollableParentsResolved = true;
2846
+ }
2847
+ ref.disabled = this.disabled;
2848
+ ref.lockAxis = this.lockAxis;
2849
+ ref.sortingDisabled = coerceBooleanProperty(this.sortingDisabled);
2850
+ ref.autoScrollDisabled = coerceBooleanProperty(this.autoScrollDisabled);
2851
+ ref.autoScrollStep = coerceNumberProperty(this.autoScrollStep, 2);
2852
+ ref
2853
+ .connectedTo(siblings.filter(drop => drop && drop !== this).map(list => list._dropListRef))
2854
+ .withOrientation(this.orientation);
2855
+ });
2856
+ }
2857
+ /** Handles events from the underlying DropListRef. */
2858
+ _handleEvents(ref) {
2859
+ ref.beforeStarted.subscribe(() => {
2860
+ this._syncItemsWithRef();
2861
+ this._changeDetectorRef.markForCheck();
2862
+ });
2863
+ ref.entered.subscribe(event => {
2864
+ this.entered.emit({
2865
+ container: this,
2866
+ item: event.item.data,
2867
+ currentIndex: event.currentIndex,
2868
+ });
2869
+ });
2870
+ ref.exited.subscribe(event => {
2871
+ this.exited.emit({
2872
+ container: this,
2873
+ item: event.item.data,
2874
+ });
2875
+ this._changeDetectorRef.markForCheck();
2876
+ });
2877
+ ref.sorted.subscribe(event => {
2878
+ this.sorted.emit({
2879
+ previousIndex: event.previousIndex,
2880
+ currentIndex: event.currentIndex,
2881
+ container: this,
2882
+ item: event.item.data,
2883
+ });
2884
+ });
2885
+ ref.dropped.subscribe(event => {
2886
+ this.dropped.emit({
2887
+ previousIndex: event.previousIndex,
2888
+ currentIndex: event.currentIndex,
2889
+ previousContainer: event.previousContainer.data,
2890
+ container: event.container.data,
2891
+ item: event.item.data,
2892
+ isPointerOverContainer: event.isPointerOverContainer,
2893
+ distance: event.distance,
2894
+ dropPoint: event.dropPoint,
2895
+ });
2896
+ // Mark for check since all of these events run outside of change
2897
+ // detection and we're not guaranteed for something else to have triggered it.
2898
+ this._changeDetectorRef.markForCheck();
2899
+ });
2900
+ }
2901
+ /** Assigns the default input values based on a provided config object. */
2902
+ _assignDefaults(config) {
2903
+ const { lockAxis, draggingDisabled, sortingDisabled, listAutoScrollDisabled, listOrientation } = config;
2904
+ this.disabled = draggingDisabled == null ? false : draggingDisabled;
2905
+ this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
2906
+ this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
2907
+ this.orientation = listOrientation || 'vertical';
2908
+ if (lockAxis) {
2909
+ this.lockAxis = lockAxis;
2910
+ }
2911
+ }
2912
+ /** Syncs up the registered drag items with underlying drop list ref. */
2913
+ _syncItemsWithRef() {
2914
+ this._dropListRef.withItems(this.getSortedItems().map(item => item._dragRef));
2915
+ }
2916
+ }
2917
+ /** Keeps track of the drop lists that are currently on the page. */
2918
+ CdkDropList._dropLists = [];
2919
+ CdkDropList.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDropList, deps: [{ token: i0.ElementRef }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: i1.ScrollDispatcher }, { token: i3.Directionality, optional: true }, { token: CDK_DROP_LIST_GROUP, optional: true, skipSelf: true }, { token: CDK_DRAG_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
2920
+ CdkDropList.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: { connectedTo: ["cdkDropListConnectedTo", "connectedTo"], data: ["cdkDropListData", "data"], orientation: ["cdkDropListOrientation", "orientation"], id: "id", lockAxis: ["cdkDropListLockAxis", "lockAxis"], disabled: ["cdkDropListDisabled", "disabled"], sortingDisabled: ["cdkDropListSortingDisabled", "sortingDisabled"], enterPredicate: ["cdkDropListEnterPredicate", "enterPredicate"], sortPredicate: ["cdkDropListSortPredicate", "sortPredicate"], autoScrollDisabled: ["cdkDropListAutoScrollDisabled", "autoScrollDisabled"], autoScrollStep: ["cdkDropListAutoScrollStep", "autoScrollStep"] }, outputs: { dropped: "cdkDropListDropped", entered: "cdkDropListEntered", exited: "cdkDropListExited", sorted: "cdkDropListSorted" }, host: { properties: { "attr.id": "id", "class.cdk-drop-list-disabled": "disabled", "class.cdk-drop-list-dragging": "_dropListRef.isDragging()", "class.cdk-drop-list-receiving": "_dropListRef.isReceiving()" }, classAttribute: "cdk-drop-list" }, providers: [
2921
+ // Prevent child drop lists from picking up the same group as their parent.
2922
+ { provide: CDK_DROP_LIST_GROUP, useValue: undefined },
2923
+ { provide: CDK_DROP_LIST, useExisting: CdkDropList },
2924
+ ], exportAs: ["cdkDropList"], ngImport: i0 });
2925
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDropList, decorators: [{
2926
+ type: Directive,
2927
+ args: [{
2928
+ selector: '[cdkDropList], cdk-drop-list',
2929
+ exportAs: 'cdkDropList',
2930
+ providers: [
2931
+ // Prevent child drop lists from picking up the same group as their parent.
2932
+ { provide: CDK_DROP_LIST_GROUP, useValue: undefined },
2933
+ { provide: CDK_DROP_LIST, useExisting: CdkDropList },
2934
+ ],
2935
+ host: {
2936
+ 'class': 'cdk-drop-list',
2937
+ '[attr.id]': 'id',
2938
+ '[class.cdk-drop-list-disabled]': 'disabled',
2939
+ '[class.cdk-drop-list-dragging]': '_dropListRef.isDragging()',
2940
+ '[class.cdk-drop-list-receiving]': '_dropListRef.isReceiving()',
2941
+ },
2942
+ }]
2943
+ }], ctorParameters: function () {
2944
+ return [{ type: i0.ElementRef }, { type: DragDrop }, { type: i0.ChangeDetectorRef }, { type: i1.ScrollDispatcher }, { type: i3.Directionality, decorators: [{
2945
+ type: Optional
2946
+ }] }, { type: CdkDropListGroup, decorators: [{
2947
+ type: Optional
2948
+ }, {
2949
+ type: Inject,
2950
+ args: [CDK_DROP_LIST_GROUP]
2951
+ }, {
2952
+ type: SkipSelf
2953
+ }] }, { type: undefined, decorators: [{
2954
+ type: Optional
2955
+ }, {
2956
+ type: Inject,
2957
+ args: [CDK_DRAG_CONFIG]
2958
+ }] }];
2959
+ }, propDecorators: { connectedTo: [{
2960
+ type: Input,
2961
+ args: ['cdkDropListConnectedTo']
2962
+ }], data: [{
2963
+ type: Input,
2964
+ args: ['cdkDropListData']
2965
+ }], orientation: [{
2966
+ type: Input,
2967
+ args: ['cdkDropListOrientation']
2968
+ }], id: [{
2969
+ type: Input
2970
+ }], lockAxis: [{
2971
+ type: Input,
2972
+ args: ['cdkDropListLockAxis']
2973
+ }], disabled: [{
2974
+ type: Input,
2975
+ args: ['cdkDropListDisabled']
2976
+ }], sortingDisabled: [{
2977
+ type: Input,
2978
+ args: ['cdkDropListSortingDisabled']
2979
+ }], enterPredicate: [{
2980
+ type: Input,
2981
+ args: ['cdkDropListEnterPredicate']
2982
+ }], sortPredicate: [{
2983
+ type: Input,
2984
+ args: ['cdkDropListSortPredicate']
2985
+ }], autoScrollDisabled: [{
2986
+ type: Input,
2987
+ args: ['cdkDropListAutoScrollDisabled']
2988
+ }], autoScrollStep: [{
2989
+ type: Input,
2990
+ args: ['cdkDropListAutoScrollStep']
2991
+ }], dropped: [{
2992
+ type: Output,
2993
+ args: ['cdkDropListDropped']
2994
+ }], entered: [{
2995
+ type: Output,
2996
+ args: ['cdkDropListEntered']
2997
+ }], exited: [{
2998
+ type: Output,
2999
+ args: ['cdkDropListExited']
3000
+ }], sorted: [{
3001
+ type: Output,
3002
+ args: ['cdkDropListSorted']
3003
+ }] } });
3004
+
3005
+ /**
3006
+ * @license
3007
+ * Copyright Google LLC All Rights Reserved.
3008
+ *
3009
+ * Use of this source code is governed by an MIT-style license that can be
3010
+ * found in the LICENSE file at https://angular.io/license
3011
+ */
3012
+ /**
3013
+ * Injection token that can be used to reference instances of `CdkDragHandle`. It serves as
3014
+ * alternative token to the actual `CdkDragHandle` class which could cause unnecessary
3015
+ * retention of the class and its directive metadata.
3016
+ */
3017
+ const CDK_DRAG_HANDLE = new InjectionToken('CdkDragHandle');
3018
+ /** Handle that can be used to drag a CdkDrag instance. */
3019
+ class CdkDragHandle {
3020
+ constructor(element, parentDrag) {
3021
+ this.element = element;
3022
+ /** Emits when the state of the handle has changed. */
3023
+ this._stateChanges = new Subject();
3024
+ this._disabled = false;
3025
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
3026
+ assertElementNode(element.nativeElement, 'cdkDragHandle');
3027
+ }
3028
+ this._parentDrag = parentDrag;
3029
+ }
3030
+ /** Whether starting to drag through this handle is disabled. */
3031
+ get disabled() {
3032
+ return this._disabled;
3033
+ }
3034
+ set disabled(value) {
3035
+ this._disabled = coerceBooleanProperty(value);
3036
+ this._stateChanges.next(this);
3037
+ }
3038
+ ngOnDestroy() {
3039
+ this._stateChanges.complete();
3040
+ }
3041
+ }
3042
+ CdkDragHandle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragHandle, deps: [{ token: i0.ElementRef }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3043
+ CdkDragHandle.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDragHandle, selector: "[cdkDragHandle]", inputs: { disabled: ["cdkDragHandleDisabled", "disabled"] }, host: { classAttribute: "cdk-drag-handle" }, providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }], ngImport: i0 });
3044
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragHandle, decorators: [{
3045
+ type: Directive,
3046
+ args: [{
3047
+ selector: '[cdkDragHandle]',
3048
+ host: {
3049
+ 'class': 'cdk-drag-handle',
3050
+ },
3051
+ providers: [{ provide: CDK_DRAG_HANDLE, useExisting: CdkDragHandle }],
3052
+ }]
3053
+ }], ctorParameters: function () {
3054
+ return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
3055
+ type: Inject,
3056
+ args: [CDK_DRAG_PARENT]
3057
+ }, {
3058
+ type: Optional
3059
+ }, {
3060
+ type: SkipSelf
3061
+ }] }];
3062
+ }, propDecorators: { disabled: [{
3063
+ type: Input,
3064
+ args: ['cdkDragHandleDisabled']
3065
+ }] } });
3066
+
3067
+ /**
3068
+ * @license
3069
+ * Copyright Google LLC All Rights Reserved.
3070
+ *
3071
+ * Use of this source code is governed by an MIT-style license that can be
3072
+ * found in the LICENSE file at https://angular.io/license
3073
+ */
3074
+ /**
3075
+ * Injection token that can be used to reference instances of `CdkDragPlaceholder`. It serves as
3076
+ * alternative token to the actual `CdkDragPlaceholder` class which could cause unnecessary
3077
+ * retention of the class and its directive metadata.
3078
+ */
3079
+ const CDK_DRAG_PLACEHOLDER = new InjectionToken('CdkDragPlaceholder');
3080
+ /**
3081
+ * Element that will be used as a template for the placeholder of a CdkDrag when
3082
+ * it is being dragged. The placeholder is displayed in place of the element being dragged.
3083
+ */
3084
+ class CdkDragPlaceholder {
3085
+ constructor(templateRef) {
3086
+ this.templateRef = templateRef;
3087
+ }
3088
+ }
3089
+ CdkDragPlaceholder.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragPlaceholder, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3090
+ CdkDragPlaceholder.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: { data: "data" }, providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }], ngImport: i0 });
3091
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragPlaceholder, decorators: [{
3092
+ type: Directive,
3093
+ args: [{
3094
+ selector: 'ng-template[cdkDragPlaceholder]',
3095
+ providers: [{ provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder }],
3096
+ }]
3097
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { data: [{
3098
+ type: Input
3099
+ }] } });
3100
+
3101
+ /**
3102
+ * @license
3103
+ * Copyright Google LLC All Rights Reserved.
3104
+ *
3105
+ * Use of this source code is governed by an MIT-style license that can be
3106
+ * found in the LICENSE file at https://angular.io/license
3107
+ */
3108
+ /**
3109
+ * Injection token that can be used to reference instances of `CdkDragPreview`. It serves as
3110
+ * alternative token to the actual `CdkDragPreview` class which could cause unnecessary
3111
+ * retention of the class and its directive metadata.
3112
+ */
3113
+ const CDK_DRAG_PREVIEW = new InjectionToken('CdkDragPreview');
3114
+ /**
3115
+ * Element that will be used as a template for the preview
3116
+ * of a CdkDrag when it is being dragged.
3117
+ */
3118
+ class CdkDragPreview {
3119
+ constructor(templateRef) {
3120
+ this.templateRef = templateRef;
3121
+ this._matchSize = false;
3122
+ }
3123
+ /** Whether the preview should preserve the same size as the item that is being dragged. */
3124
+ get matchSize() {
3125
+ return this._matchSize;
3126
+ }
3127
+ set matchSize(value) {
3128
+ this._matchSize = coerceBooleanProperty(value);
3129
+ }
3130
+ }
3131
+ CdkDragPreview.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragPreview, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
3132
+ CdkDragPreview.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDragPreview, selector: "ng-template[cdkDragPreview]", inputs: { data: "data", matchSize: "matchSize" }, providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }], ngImport: i0 });
3133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDragPreview, decorators: [{
3134
+ type: Directive,
3135
+ args: [{
3136
+ selector: 'ng-template[cdkDragPreview]',
3137
+ providers: [{ provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview }],
3138
+ }]
3139
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; }, propDecorators: { data: [{
3140
+ type: Input
3141
+ }], matchSize: [{
3142
+ type: Input
3143
+ }] } });
3144
+
3145
+ const DRAG_HOST_CLASS = 'cdk-drag';
3146
+ /** Element that can be moved inside a CdkDropList container. */
3147
+ class CdkDrag {
3148
+ constructor(
3149
+ /** Element that the draggable is attached to. */
3150
+ element,
3151
+ /** Droppable container that the draggable is a part of. */
3152
+ dropContainer,
3153
+ /**
3154
+ * @deprecated `_document` parameter no longer being used and will be removed.
3155
+ * @breaking-change 12.0.0
3156
+ */
3157
+ _document, _ngZone, _viewContainerRef, config, _dir, dragDrop, _changeDetectorRef, _selfHandle, _parentDrag) {
3158
+ this.element = element;
3159
+ this.dropContainer = dropContainer;
3160
+ this._ngZone = _ngZone;
3161
+ this._viewContainerRef = _viewContainerRef;
3162
+ this._dir = _dir;
3163
+ this._changeDetectorRef = _changeDetectorRef;
3164
+ this._selfHandle = _selfHandle;
3165
+ this._parentDrag = _parentDrag;
3166
+ this._destroyed = new Subject();
3167
+ /** Emits when the user starts dragging the item. */
3168
+ this.started = new EventEmitter();
3169
+ /** Emits when the user has released a drag item, before any animations have started. */
3170
+ this.released = new EventEmitter();
3171
+ /** Emits when the user stops dragging an item in the container. */
3172
+ this.ended = new EventEmitter();
3173
+ /** Emits when the user has moved the item into a new container. */
3174
+ this.entered = new EventEmitter();
3175
+ /** Emits when the user removes the item its container by dragging it into another container. */
3176
+ this.exited = new EventEmitter();
3177
+ /** Emits when the user drops the item inside a container. */
3178
+ this.dropped = new EventEmitter();
3179
+ /**
3180
+ * Emits as the user is dragging the item. Use with caution,
3181
+ * because this event will fire for every pixel that the user has dragged.
3182
+ */
3183
+ this.moved = new Observable((observer) => {
3184
+ const subscription = this._dragRef.moved
3185
+ .pipe(map(movedEvent => ({
3186
+ source: this,
3187
+ pointerPosition: movedEvent.pointerPosition,
3188
+ event: movedEvent.event,
3189
+ delta: movedEvent.delta,
3190
+ distance: movedEvent.distance,
3191
+ })))
3192
+ .subscribe(observer);
3193
+ return () => {
3194
+ subscription.unsubscribe();
3195
+ };
3196
+ });
3197
+ this._dragRef = dragDrop.createDrag(element, {
3198
+ dragStartThreshold: config && config.dragStartThreshold != null ? config.dragStartThreshold : 5,
3199
+ pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null
3200
+ ? config.pointerDirectionChangeThreshold
3201
+ : 5,
3202
+ zIndex: config === null || config === void 0 ? void 0 : config.zIndex,
3203
+ });
3204
+ this._dragRef.data = this;
3205
+ // We have to keep track of the drag instances in order to be able to match an element to
3206
+ // a drag instance. We can't go through the global registry of `DragRef`, because the root
3207
+ // element could be different.
3208
+ CdkDrag._dragInstances.push(this);
3209
+ if (config) {
3210
+ this._assignDefaults(config);
3211
+ }
3212
+ // Note that usually the container is assigned when the drop list is picks up the item, but in
3213
+ // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation
3214
+ // where there are no items on the first change detection pass, but the items get picked up as
3215
+ // soon as the user triggers another pass by dragging. This is a problem, because the item would
3216
+ // have to switch from standalone mode to drag mode in the middle of the dragging sequence which
3217
+ // is too late since the two modes save different kinds of information. We work around it by
3218
+ // assigning the drop container both from here and the list.
3219
+ if (dropContainer) {
3220
+ this._dragRef._withDropContainer(dropContainer._dropListRef);
3221
+ dropContainer.addItem(this);
3222
+ }
3223
+ this._syncInputs(this._dragRef);
3224
+ this._handleEvents(this._dragRef);
3225
+ }
3226
+ /** Whether starting to drag this element is disabled. */
3227
+ get disabled() {
3228
+ return this._disabled || (this.dropContainer && this.dropContainer.disabled);
3229
+ }
3230
+ set disabled(value) {
3231
+ this._disabled = coerceBooleanProperty(value);
3232
+ this._dragRef.disabled = this._disabled;
3233
+ }
3234
+ /**
3235
+ * Returns the element that is being used as a placeholder
3236
+ * while the current element is being dragged.
3237
+ */
3238
+ getPlaceholderElement() {
3239
+ return this._dragRef.getPlaceholderElement();
3240
+ }
3241
+ /** Returns the root draggable element. */
3242
+ getRootElement() {
3243
+ return this._dragRef.getRootElement();
3244
+ }
3245
+ /** Resets a standalone drag item to its initial position. */
3246
+ reset() {
3247
+ this._dragRef.reset();
3248
+ }
3249
+ /**
3250
+ * Gets the pixel coordinates of the draggable outside of a drop container.
3251
+ */
3252
+ getFreeDragPosition() {
3253
+ return this._dragRef.getFreeDragPosition();
3254
+ }
3255
+ ngAfterViewInit() {
3256
+ // Normally this isn't in the zone, but it can cause major performance regressions for apps
3257
+ // using `zone-patch-rxjs` because it'll trigger a change detection when it unsubscribes.
3258
+ this._ngZone.runOutsideAngular(() => {
3259
+ // We need to wait for the zone to stabilize, in order for the reference
3260
+ // element to be in the proper place in the DOM. This is mostly relevant
3261
+ // for draggable elements inside portals since they get stamped out in
3262
+ // their original DOM position and then they get transferred to the portal.
3263
+ this._ngZone.onStable.pipe(take(1), takeUntil(this._destroyed)).subscribe(() => {
3264
+ this._updateRootElement();
3265
+ this._setupHandlesListener();
3266
+ if (this.freeDragPosition) {
3267
+ this._dragRef.setFreeDragPosition(this.freeDragPosition);
3268
+ }
3269
+ });
3270
+ });
3271
+ }
3272
+ ngOnChanges(changes) {
3273
+ const rootSelectorChange = changes['rootElementSelector'];
3274
+ const positionChange = changes['freeDragPosition'];
3275
+ // We don't have to react to the first change since it's being
3276
+ // handled in `ngAfterViewInit` where it needs to be deferred.
3277
+ if (rootSelectorChange && !rootSelectorChange.firstChange) {
3278
+ this._updateRootElement();
3279
+ }
3280
+ // Skip the first change since it's being handled in `ngAfterViewInit`.
3281
+ if (positionChange && !positionChange.firstChange && this.freeDragPosition) {
3282
+ this._dragRef.setFreeDragPosition(this.freeDragPosition);
3283
+ }
3284
+ }
3285
+ ngOnDestroy() {
3286
+ if (this.dropContainer) {
3287
+ this.dropContainer.removeItem(this);
3288
+ }
3289
+ const index = CdkDrag._dragInstances.indexOf(this);
3290
+ if (index > -1) {
3291
+ CdkDrag._dragInstances.splice(index, 1);
3292
+ }
3293
+ // Unnecessary in most cases, but used to avoid extra change detections with `zone-paths-rxjs`.
3294
+ this._ngZone.runOutsideAngular(() => {
3295
+ this._destroyed.next();
3296
+ this._destroyed.complete();
3297
+ this._dragRef.dispose();
3298
+ });
3299
+ }
3300
+ /** Syncs the root element with the `DragRef`. */
3301
+ _updateRootElement() {
3302
+ var _a;
3303
+ const element = this.element.nativeElement;
3304
+ let rootElement = element;
3305
+ if (this.rootElementSelector) {
3306
+ rootElement =
3307
+ element.closest !== undefined
3308
+ ? element.closest(this.rootElementSelector)
3309
+ : // Comment tag doesn't have closest method, so use parent's one.
3310
+ (_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.closest(this.rootElementSelector);
3311
+ }
3312
+ if (rootElement && (typeof ngDevMode === 'undefined' || ngDevMode)) {
3313
+ assertElementNode(rootElement, 'cdkDrag');
3314
+ }
3315
+ this._dragRef.withRootElement(rootElement || element);
3316
+ }
3317
+ /** Gets the boundary element, based on the `boundaryElement` value. */
3318
+ _getBoundaryElement() {
3319
+ const boundary = this.boundaryElement;
3320
+ if (!boundary) {
3321
+ return null;
3322
+ }
3323
+ if (typeof boundary === 'string') {
3324
+ return this.element.nativeElement.closest(boundary);
3325
+ }
3326
+ const element = coerceElement(boundary);
3327
+ if ((typeof ngDevMode === 'undefined' || ngDevMode) &&
3328
+ !element.contains(this.element.nativeElement)) {
3329
+ throw Error('Draggable element is not inside of the node passed into cdkDragBoundary.');
3330
+ }
3331
+ return element;
3332
+ }
3333
+ /** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
3334
+ _syncInputs(ref) {
3335
+ ref.beforeStarted.subscribe(() => {
3336
+ if (!ref.isDragging()) {
3337
+ const dir = this._dir;
3338
+ const dragStartDelay = this.dragStartDelay;
3339
+ const placeholder = this._placeholderTemplate
3340
+ ? {
3341
+ template: this._placeholderTemplate.templateRef,
3342
+ context: this._placeholderTemplate.data,
3343
+ viewContainer: this._viewContainerRef,
3344
+ }
3345
+ : null;
3346
+ const preview = this._previewTemplate
3347
+ ? {
3348
+ template: this._previewTemplate.templateRef,
3349
+ context: this._previewTemplate.data,
3350
+ matchSize: this._previewTemplate.matchSize,
3351
+ viewContainer: this._viewContainerRef,
3352
+ }
3353
+ : null;
3354
+ ref.disabled = this.disabled;
3355
+ ref.lockAxis = this.lockAxis;
3356
+ ref.dragStartDelay =
3357
+ typeof dragStartDelay === 'object' && dragStartDelay
3358
+ ? dragStartDelay
3359
+ : coerceNumberProperty(dragStartDelay);
3360
+ ref.constrainPosition = this.constrainPosition;
3361
+ ref.previewClass = this.previewClass;
3362
+ ref
3363
+ .withBoundaryElement(this._getBoundaryElement())
3364
+ .withPlaceholderTemplate(placeholder)
3365
+ .withPreviewTemplate(preview)
3366
+ .withPreviewContainer(this.previewContainer || 'global');
3367
+ if (dir) {
3368
+ ref.withDirection(dir.value);
3369
+ }
3370
+ }
3371
+ });
3372
+ // This only needs to be resolved once.
3373
+ ref.beforeStarted.pipe(take(1)).subscribe(() => {
3374
+ var _a;
3375
+ // If we managed to resolve a parent through DI, use it.
3376
+ if (this._parentDrag) {
3377
+ ref.withParent(this._parentDrag._dragRef);
3378
+ return;
3379
+ }
3380
+ // Otherwise fall back to resolving the parent by looking up the DOM. This can happen if
3381
+ // the item was projected into another item by something like `ngTemplateOutlet`.
3382
+ let parent = this.element.nativeElement.parentElement;
3383
+ while (parent) {
3384
+ if (parent.classList.contains(DRAG_HOST_CLASS)) {
3385
+ ref.withParent(((_a = CdkDrag._dragInstances.find(drag => {
3386
+ return drag.element.nativeElement === parent;
3387
+ })) === null || _a === void 0 ? void 0 : _a._dragRef) || null);
3388
+ break;
3389
+ }
3390
+ parent = parent.parentElement;
3391
+ }
3392
+ });
3393
+ }
3394
+ /** Handles the events from the underlying `DragRef`. */
3395
+ _handleEvents(ref) {
3396
+ ref.started.subscribe(() => {
3397
+ this.started.emit({ source: this });
3398
+ // Since all of these events run outside of change detection,
3399
+ // we need to ensure that everything is marked correctly.
3400
+ this._changeDetectorRef.markForCheck();
3401
+ });
3402
+ ref.released.subscribe(() => {
3403
+ this.released.emit({ source: this });
3404
+ });
3405
+ ref.ended.subscribe(event => {
3406
+ this.ended.emit({
3407
+ source: this,
3408
+ distance: event.distance,
3409
+ dropPoint: event.dropPoint,
3410
+ });
3411
+ // Since all of these events run outside of change detection,
3412
+ // we need to ensure that everything is marked correctly.
3413
+ this._changeDetectorRef.markForCheck();
3414
+ });
3415
+ ref.entered.subscribe(event => {
3416
+ this.entered.emit({
3417
+ container: event.container.data,
3418
+ item: this,
3419
+ currentIndex: event.currentIndex,
3420
+ });
3421
+ });
3422
+ ref.exited.subscribe(event => {
3423
+ this.exited.emit({
3424
+ container: event.container.data,
3425
+ item: this,
3426
+ });
3427
+ });
3428
+ ref.dropped.subscribe(event => {
3429
+ this.dropped.emit({
3430
+ previousIndex: event.previousIndex,
3431
+ currentIndex: event.currentIndex,
3432
+ previousContainer: event.previousContainer.data,
3433
+ container: event.container.data,
3434
+ isPointerOverContainer: event.isPointerOverContainer,
3435
+ item: this,
3436
+ distance: event.distance,
3437
+ dropPoint: event.dropPoint,
3438
+ });
3439
+ });
3440
+ }
3441
+ /** Assigns the default input values based on a provided config object. */
3442
+ _assignDefaults(config) {
3443
+ const { lockAxis, dragStartDelay, constrainPosition, previewClass, boundaryElement, draggingDisabled, rootElementSelector, previewContainer, } = config;
3444
+ this.disabled = draggingDisabled == null ? false : draggingDisabled;
3445
+ this.dragStartDelay = dragStartDelay || 0;
3446
+ if (lockAxis) {
3447
+ this.lockAxis = lockAxis;
3448
+ }
3449
+ if (constrainPosition) {
3450
+ this.constrainPosition = constrainPosition;
3451
+ }
3452
+ if (previewClass) {
3453
+ this.previewClass = previewClass;
3454
+ }
3455
+ if (boundaryElement) {
3456
+ this.boundaryElement = boundaryElement;
3457
+ }
3458
+ if (rootElementSelector) {
3459
+ this.rootElementSelector = rootElementSelector;
3460
+ }
3461
+ if (previewContainer) {
3462
+ this.previewContainer = previewContainer;
3463
+ }
3464
+ }
3465
+ /** Sets up the listener that syncs the handles with the drag ref. */
3466
+ _setupHandlesListener() {
3467
+ // Listen for any newly-added handles.
3468
+ this._handles.changes
3469
+ .pipe(startWith(this._handles),
3470
+ // Sync the new handles with the DragRef.
3471
+ tap((handles) => {
3472
+ const childHandleElements = handles
3473
+ .filter(handle => handle._parentDrag === this)
3474
+ .map(handle => handle.element);
3475
+ // Usually handles are only allowed to be a descendant of the drag element, but if
3476
+ // the consumer defined a different drag root, we should allow the drag element
3477
+ // itself to be a handle too.
3478
+ if (this._selfHandle && this.rootElementSelector) {
3479
+ childHandleElements.push(this.element);
3480
+ }
3481
+ this._dragRef.withHandles(childHandleElements);
3482
+ }),
3483
+ // Listen if the state of any of the handles changes.
3484
+ switchMap((handles) => {
3485
+ return merge(...handles.map(item => {
3486
+ return item._stateChanges.pipe(startWith(item));
3487
+ }));
3488
+ }), takeUntil(this._destroyed))
3489
+ .subscribe(handleInstance => {
3490
+ // Enabled/disable the handle that changed in the DragRef.
3491
+ const dragRef = this._dragRef;
3492
+ const handle = handleInstance.element.nativeElement;
3493
+ handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
3494
+ });
3495
+ }
3496
+ }
3497
+ CdkDrag._dragInstances = [];
3498
+ CdkDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDrag, deps: [{ token: i0.ElementRef }, { token: CDK_DROP_LIST, optional: true, skipSelf: true }, { token: DOCUMENT }, { token: i0.NgZone }, { token: i0.ViewContainerRef }, { token: CDK_DRAG_CONFIG, optional: true }, { token: i3.Directionality, optional: true }, { token: DragDrop }, { token: i0.ChangeDetectorRef }, { token: CDK_DRAG_HANDLE, optional: true, self: true }, { token: CDK_DRAG_PARENT, optional: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
3499
+ CdkDrag.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.0-next.15", type: CdkDrag, selector: "[cdkDrag]", inputs: { data: ["cdkDragData", "data"], lockAxis: ["cdkDragLockAxis", "lockAxis"], rootElementSelector: ["cdkDragRootElement", "rootElementSelector"], boundaryElement: ["cdkDragBoundary", "boundaryElement"], dragStartDelay: ["cdkDragStartDelay", "dragStartDelay"], freeDragPosition: ["cdkDragFreeDragPosition", "freeDragPosition"], disabled: ["cdkDragDisabled", "disabled"], constrainPosition: ["cdkDragConstrainPosition", "constrainPosition"], previewClass: ["cdkDragPreviewClass", "previewClass"], previewContainer: ["cdkDragPreviewContainer", "previewContainer"] }, outputs: { started: "cdkDragStarted", released: "cdkDragReleased", ended: "cdkDragEnded", entered: "cdkDragEntered", exited: "cdkDragExited", dropped: "cdkDragDropped", moved: "cdkDragMoved" }, host: { properties: { "class.cdk-drag-disabled": "disabled", "class.cdk-drag-dragging": "_dragRef.isDragging()" }, classAttribute: "cdk-drag" }, providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }], queries: [{ propertyName: "_previewTemplate", first: true, predicate: CDK_DRAG_PREVIEW, descendants: true }, { propertyName: "_placeholderTemplate", first: true, predicate: CDK_DRAG_PLACEHOLDER, descendants: true }, { propertyName: "_handles", predicate: CDK_DRAG_HANDLE, descendants: true }], exportAs: ["cdkDrag"], usesOnChanges: true, ngImport: i0 });
3500
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: CdkDrag, decorators: [{
3501
+ type: Directive,
3502
+ args: [{
3503
+ selector: '[cdkDrag]',
3504
+ exportAs: 'cdkDrag',
3505
+ host: {
3506
+ 'class': DRAG_HOST_CLASS,
3507
+ '[class.cdk-drag-disabled]': 'disabled',
3508
+ '[class.cdk-drag-dragging]': '_dragRef.isDragging()',
3509
+ },
3510
+ providers: [{ provide: CDK_DRAG_PARENT, useExisting: CdkDrag }],
3511
+ }]
3512
+ }], ctorParameters: function () {
3513
+ return [{ type: i0.ElementRef }, { type: undefined, decorators: [{
3514
+ type: Inject,
3515
+ args: [CDK_DROP_LIST]
3516
+ }, {
3517
+ type: Optional
3518
+ }, {
3519
+ type: SkipSelf
3520
+ }] }, { type: undefined, decorators: [{
3521
+ type: Inject,
3522
+ args: [DOCUMENT]
3523
+ }] }, { type: i0.NgZone }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
3524
+ type: Optional
3525
+ }, {
3526
+ type: Inject,
3527
+ args: [CDK_DRAG_CONFIG]
3528
+ }] }, { type: i3.Directionality, decorators: [{
3529
+ type: Optional
3530
+ }] }, { type: DragDrop }, { type: i0.ChangeDetectorRef }, { type: CdkDragHandle, decorators: [{
3531
+ type: Optional
3532
+ }, {
3533
+ type: Self
3534
+ }, {
3535
+ type: Inject,
3536
+ args: [CDK_DRAG_HANDLE]
3537
+ }] }, { type: CdkDrag, decorators: [{
3538
+ type: Optional
3539
+ }, {
3540
+ type: SkipSelf
3541
+ }, {
3542
+ type: Inject,
3543
+ args: [CDK_DRAG_PARENT]
3544
+ }] }];
3545
+ }, propDecorators: { _handles: [{
3546
+ type: ContentChildren,
3547
+ args: [CDK_DRAG_HANDLE, { descendants: true }]
3548
+ }], _previewTemplate: [{
3549
+ type: ContentChild,
3550
+ args: [CDK_DRAG_PREVIEW]
3551
+ }], _placeholderTemplate: [{
3552
+ type: ContentChild,
3553
+ args: [CDK_DRAG_PLACEHOLDER]
3554
+ }], data: [{
3555
+ type: Input,
3556
+ args: ['cdkDragData']
3557
+ }], lockAxis: [{
3558
+ type: Input,
3559
+ args: ['cdkDragLockAxis']
3560
+ }], rootElementSelector: [{
3561
+ type: Input,
3562
+ args: ['cdkDragRootElement']
3563
+ }], boundaryElement: [{
3564
+ type: Input,
3565
+ args: ['cdkDragBoundary']
3566
+ }], dragStartDelay: [{
3567
+ type: Input,
3568
+ args: ['cdkDragStartDelay']
3569
+ }], freeDragPosition: [{
3570
+ type: Input,
3571
+ args: ['cdkDragFreeDragPosition']
3572
+ }], disabled: [{
3573
+ type: Input,
3574
+ args: ['cdkDragDisabled']
3575
+ }], constrainPosition: [{
3576
+ type: Input,
3577
+ args: ['cdkDragConstrainPosition']
3578
+ }], previewClass: [{
3579
+ type: Input,
3580
+ args: ['cdkDragPreviewClass']
3581
+ }], previewContainer: [{
3582
+ type: Input,
3583
+ args: ['cdkDragPreviewContainer']
3584
+ }], started: [{
3585
+ type: Output,
3586
+ args: ['cdkDragStarted']
3587
+ }], released: [{
3588
+ type: Output,
3589
+ args: ['cdkDragReleased']
3590
+ }], ended: [{
3591
+ type: Output,
3592
+ args: ['cdkDragEnded']
3593
+ }], entered: [{
3594
+ type: Output,
3595
+ args: ['cdkDragEntered']
3596
+ }], exited: [{
3597
+ type: Output,
3598
+ args: ['cdkDragExited']
3599
+ }], dropped: [{
3600
+ type: Output,
3601
+ args: ['cdkDragDropped']
3602
+ }], moved: [{
3603
+ type: Output,
3604
+ args: ['cdkDragMoved']
3605
+ }] } });
3606
+
3607
+ /**
3608
+ * @license
3609
+ * Copyright Google LLC All Rights Reserved.
3610
+ *
3611
+ * Use of this source code is governed by an MIT-style license that can be
3612
+ * found in the LICENSE file at https://angular.io/license
3613
+ */
3614
+ class DragDropModule {
3615
+ }
3616
+ DragDropModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3617
+ DragDropModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropModule, declarations: [CdkDropList,
3618
+ CdkDropListGroup,
3619
+ CdkDrag,
3620
+ CdkDragHandle,
3621
+ CdkDragPreview,
3622
+ CdkDragPlaceholder], exports: [CdkScrollableModule,
3623
+ CdkDropList,
3624
+ CdkDropListGroup,
3625
+ CdkDrag,
3626
+ CdkDragHandle,
3627
+ CdkDragPreview,
3628
+ CdkDragPlaceholder] });
3629
+ DragDropModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropModule, providers: [DragDrop], imports: [CdkScrollableModule] });
3630
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0-next.15", ngImport: i0, type: DragDropModule, decorators: [{
3631
+ type: NgModule,
3632
+ args: [{
3633
+ declarations: [
3634
+ CdkDropList,
3635
+ CdkDropListGroup,
3636
+ CdkDrag,
3637
+ CdkDragHandle,
3638
+ CdkDragPreview,
3639
+ CdkDragPlaceholder,
3640
+ ],
3641
+ exports: [
3642
+ CdkScrollableModule,
3643
+ CdkDropList,
3644
+ CdkDropListGroup,
3645
+ CdkDrag,
3646
+ CdkDragHandle,
3647
+ CdkDragPreview,
3648
+ CdkDragPlaceholder,
3649
+ ],
3650
+ providers: [DragDrop],
3651
+ }]
3652
+ }] });
3653
+
3654
+ /**
3655
+ * @license
3656
+ * Copyright Google LLC All Rights Reserved.
3657
+ *
3658
+ * Use of this source code is governed by an MIT-style license that can be
3659
+ * found in the LICENSE file at https://angular.io/license
3660
+ */
3661
+
3662
+ /**
3663
+ * Generated bundle index. Do not edit.
3664
+ */
3665
+
3666
+ export { CDK_DRAG_CONFIG, CDK_DRAG_HANDLE, CDK_DRAG_PARENT, CDK_DRAG_PLACEHOLDER, CDK_DRAG_PREVIEW, CDK_DROP_LIST, CDK_DROP_LIST_GROUP, CdkDrag, CdkDragHandle, CdkDragPlaceholder, CdkDragPreview, CdkDropList, CdkDropListGroup, DragDrop, DragDropModule, DragDropRegistry, DragRef, DropListRef, copyArrayItem, moveItemInArray, transferArrayItem };
3667
+ //# sourceMappingURL=drag-drop.mjs.map