@angular/cdk 7.1.0 → 7.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/LICENSE +1 -1
  2. package/_a11y.scss +1 -1
  3. package/a11y/typings/focus-monitor/focus-monitor.d.ts +20 -5
  4. package/a11y/typings/focus-trap/focus-trap.d.ts +2 -0
  5. package/a11y/typings/index.metadata.json +1 -1
  6. package/bundles/cdk-a11y.umd.js +428 -197
  7. package/bundles/cdk-a11y.umd.js.map +1 -1
  8. package/bundles/cdk-a11y.umd.min.js +1 -1
  9. package/bundles/cdk-a11y.umd.min.js.map +1 -1
  10. package/bundles/cdk-accordion.umd.js +16 -9
  11. package/bundles/cdk-accordion.umd.js.map +1 -1
  12. package/bundles/cdk-accordion.umd.min.js.map +1 -1
  13. package/bundles/cdk-bidi.umd.js +11 -6
  14. package/bundles/cdk-bidi.umd.js.map +1 -1
  15. package/bundles/cdk-bidi.umd.min.js.map +1 -1
  16. package/bundles/cdk-coercion.umd.js +25 -9
  17. package/bundles/cdk-coercion.umd.js.map +1 -1
  18. package/bundles/cdk-coercion.umd.min.js +1 -1
  19. package/bundles/cdk-coercion.umd.min.js.map +1 -1
  20. package/bundles/cdk-collections.umd.js +28 -5
  21. package/bundles/cdk-collections.umd.js.map +1 -1
  22. package/bundles/cdk-collections.umd.min.js.map +1 -1
  23. package/bundles/cdk-drag-drop.umd.js +2297 -973
  24. package/bundles/cdk-drag-drop.umd.js.map +1 -1
  25. package/bundles/cdk-drag-drop.umd.min.js +2 -1
  26. package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
  27. package/bundles/cdk-keycodes.umd.js +12 -2
  28. package/bundles/cdk-keycodes.umd.js.map +1 -1
  29. package/bundles/cdk-layout.umd.js +29 -22
  30. package/bundles/cdk-layout.umd.js.map +1 -1
  31. package/bundles/cdk-layout.umd.min.js +1 -1
  32. package/bundles/cdk-layout.umd.min.js.map +1 -1
  33. package/bundles/cdk-observers.umd.js +27 -8
  34. package/bundles/cdk-observers.umd.js.map +1 -1
  35. package/bundles/cdk-observers.umd.min.js +1 -1
  36. package/bundles/cdk-observers.umd.min.js.map +1 -1
  37. package/bundles/cdk-overlay.umd.js +586 -240
  38. package/bundles/cdk-overlay.umd.js.map +1 -1
  39. package/bundles/cdk-overlay.umd.min.js +2 -2
  40. package/bundles/cdk-overlay.umd.min.js.map +1 -1
  41. package/bundles/cdk-platform.umd.js +50 -28
  42. package/bundles/cdk-platform.umd.js.map +1 -1
  43. package/bundles/cdk-platform.umd.min.js.map +1 -1
  44. package/bundles/cdk-portal.umd.js +17 -10
  45. package/bundles/cdk-portal.umd.js.map +1 -1
  46. package/bundles/cdk-portal.umd.min.js.map +1 -1
  47. package/bundles/cdk-scrolling.umd.js +148 -50
  48. package/bundles/cdk-scrolling.umd.js.map +1 -1
  49. package/bundles/cdk-scrolling.umd.min.js +1 -1
  50. package/bundles/cdk-scrolling.umd.min.js.map +1 -1
  51. package/bundles/cdk-stepper.umd.js +69 -27
  52. package/bundles/cdk-stepper.umd.js.map +1 -1
  53. package/bundles/cdk-stepper.umd.min.js +1 -1
  54. package/bundles/cdk-stepper.umd.min.js.map +1 -1
  55. package/bundles/cdk-table.umd.js +189 -51
  56. package/bundles/cdk-table.umd.js.map +1 -1
  57. package/bundles/cdk-table.umd.min.js +1 -1
  58. package/bundles/cdk-table.umd.min.js.map +1 -1
  59. package/bundles/cdk-text-field.umd.js +76 -38
  60. package/bundles/cdk-text-field.umd.js.map +1 -1
  61. package/bundles/cdk-text-field.umd.min.js +1 -1
  62. package/bundles/cdk-text-field.umd.min.js.map +1 -1
  63. package/bundles/cdk-tree.umd.js +71 -34
  64. package/bundles/cdk-tree.umd.js.map +1 -1
  65. package/bundles/cdk-tree.umd.min.js +1 -1
  66. package/bundles/cdk-tree.umd.min.js.map +1 -1
  67. package/bundles/cdk.umd.js +5 -4
  68. package/bundles/cdk.umd.js.map +1 -1
  69. package/bundles/cdk.umd.min.js +1 -1
  70. package/bundles/cdk.umd.min.js.map +1 -1
  71. package/coercion/typings/element.d.ts +13 -0
  72. package/coercion/typings/index.metadata.json +1 -1
  73. package/coercion/typings/public-api.d.ts +1 -0
  74. package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  75. package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  76. package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  77. package/drag-drop/typings/directives/drag.d.ts +110 -0
  78. package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
  79. package/drag-drop/typings/{drop-list.d.ts → directives/drop-list.d.ts} +32 -72
  80. package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
  81. package/drag-drop/typings/drag-events.d.ts +14 -7
  82. package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +152 -83
  83. package/drag-drop/typings/drop-list-container.d.ts +19 -3
  84. package/drag-drop/typings/drop-list-ref.d.ts +234 -0
  85. package/drag-drop/typings/index.d.ts +1 -0
  86. package/drag-drop/typings/index.metadata.json +1 -1
  87. package/drag-drop/typings/public-api.d.ts +13 -6
  88. package/esm2015/a11y.js +306 -182
  89. package/esm2015/a11y.js.map +1 -1
  90. package/esm2015/accordion.js +16 -11
  91. package/esm2015/accordion.js.map +1 -1
  92. package/esm2015/bidi.js +13 -8
  93. package/esm2015/bidi.js.map +1 -1
  94. package/esm2015/cdk.js +7 -6
  95. package/esm2015/cdk.js.map +1 -1
  96. package/esm2015/coercion.js +25 -8
  97. package/esm2015/coercion.js.map +1 -1
  98. package/esm2015/collections.js +22 -7
  99. package/esm2015/collections.js.map +1 -1
  100. package/esm2015/drag-drop.js +1774 -864
  101. package/esm2015/drag-drop.js.map +1 -1
  102. package/esm2015/keycodes.js +14 -4
  103. package/esm2015/keycodes.js.map +1 -1
  104. package/esm2015/layout.js +29 -19
  105. package/esm2015/layout.js.map +1 -1
  106. package/esm2015/observers.js +16 -11
  107. package/esm2015/observers.js.map +1 -1
  108. package/esm2015/overlay.js +373 -213
  109. package/esm2015/overlay.js.map +1 -1
  110. package/esm2015/platform.js +53 -31
  111. package/esm2015/platform.js.map +1 -1
  112. package/esm2015/portal.js +14 -10
  113. package/esm2015/portal.js.map +1 -1
  114. package/esm2015/scrolling.js +111 -51
  115. package/esm2015/scrolling.js.map +1 -1
  116. package/esm2015/stepper.js +56 -30
  117. package/esm2015/stepper.js.map +1 -1
  118. package/esm2015/table.js +96 -48
  119. package/esm2015/table.js.map +1 -1
  120. package/esm2015/text-field.js +54 -37
  121. package/esm2015/text-field.js.map +1 -1
  122. package/esm2015/tree.js +55 -36
  123. package/esm2015/tree.js.map +1 -1
  124. package/esm5/a11y.es5.js +432 -201
  125. package/esm5/a11y.es5.js.map +1 -1
  126. package/esm5/accordion.es5.js +18 -11
  127. package/esm5/accordion.es5.js.map +1 -1
  128. package/esm5/bidi.es5.js +13 -8
  129. package/esm5/bidi.es5.js.map +1 -1
  130. package/esm5/cdk.es5.js +7 -6
  131. package/esm5/cdk.es5.js.map +1 -1
  132. package/esm5/coercion.es5.js +25 -8
  133. package/esm5/coercion.es5.js.map +1 -1
  134. package/esm5/collections.es5.js +35 -7
  135. package/esm5/collections.es5.js.map +1 -1
  136. package/esm5/drag-drop.es5.js +2358 -1035
  137. package/esm5/drag-drop.es5.js.map +1 -1
  138. package/esm5/keycodes.es5.js +14 -4
  139. package/esm5/keycodes.es5.js.map +1 -1
  140. package/esm5/layout.es5.js +31 -24
  141. package/esm5/layout.es5.js.map +1 -1
  142. package/esm5/observers.es5.js +30 -11
  143. package/esm5/observers.es5.js.map +1 -1
  144. package/esm5/overlay.es5.js +590 -244
  145. package/esm5/overlay.es5.js.map +1 -1
  146. package/esm5/platform.es5.js +52 -30
  147. package/esm5/platform.es5.js.map +1 -1
  148. package/esm5/portal.es5.js +19 -12
  149. package/esm5/portal.es5.js.map +1 -1
  150. package/esm5/scrolling.es5.js +150 -52
  151. package/esm5/scrolling.es5.js.map +1 -1
  152. package/esm5/stepper.es5.js +71 -30
  153. package/esm5/stepper.es5.js.map +1 -1
  154. package/esm5/table.es5.js +191 -53
  155. package/esm5/table.es5.js.map +1 -1
  156. package/esm5/text-field.es5.js +75 -37
  157. package/esm5/text-field.es5.js.map +1 -1
  158. package/esm5/tree.es5.js +74 -37
  159. package/esm5/tree.es5.js.map +1 -1
  160. package/overlay/typings/index.metadata.json +1 -1
  161. package/overlay/typings/overlay-directives.d.ts +0 -2
  162. package/overlay/typings/overlay-ref.d.ts +1 -1
  163. package/package.json +4 -4
  164. package/portal/typings/portal.d.ts +1 -1
  165. package/schematics/migration.json +5 -0
  166. package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
  167. package/schematics/ng-update/index.d.ts +2 -0
  168. package/schematics/ng-update/index.js +5 -0
  169. package/schematics/ng-update/index.js.map +1 -1
  170. package/schematics/ng-update/target-version.d.ts +7 -1
  171. package/schematics/ng-update/target-version.js +10 -0
  172. package/schematics/ng-update/target-version.js.map +1 -1
  173. package/schematics/ng-update/upgrade-data.js +2 -1
  174. package/schematics/ng-update/upgrade-data.js.map +1 -1
  175. package/schematics/ng-update/upgrade-rules/index.js +3 -2
  176. package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
  177. package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  178. package/schematics/utils/ast/ng-module-imports.js +25 -13
  179. package/schematics/utils/ast/ng-module-imports.js.map +1 -1
  180. package/schematics/utils/get-project.js +2 -1
  181. package/schematics/utils/get-project.js.map +1 -1
  182. package/schematics/utils/parse5-element.js +3 -2
  183. package/schematics/utils/parse5-element.js.map +1 -1
  184. package/schematics/utils/project-targets.js +2 -1
  185. package/schematics/utils/project-targets.js.map +1 -1
  186. package/schematics/utils/version-agnostic-typescript.js +3 -2
  187. package/schematics/utils/version-agnostic-typescript.js.map +1 -1
  188. package/scrolling/typings/index.metadata.json +1 -1
  189. package/stepper/typings/index.metadata.json +1 -1
  190. package/stepper/typings/stepper.d.ts +13 -1
  191. package/text-field/typings/autosize.d.ts +6 -0
  192. package/text-field/typings/index.metadata.json +1 -1
  193. package/tree/typings/control/base-tree-control.d.ts +1 -1
  194. package/tree/typings/control/nested-tree-control.d.ts +2 -2
  195. package/tree/typings/control/tree-control.d.ts +1 -1
  196. package/tree/typings/nested-node.d.ts +5 -5
  197. package/typings/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  198. package/typings/a11y/focus-trap/focus-trap.d.ts +2 -0
  199. package/typings/a11y/index.metadata.json +1 -1
  200. package/typings/coercion/element.d.ts +13 -0
  201. package/typings/coercion/index.metadata.json +1 -1
  202. package/typings/coercion/public-api.d.ts +1 -0
  203. package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  204. package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  205. package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  206. package/typings/drag-drop/directives/drag.d.ts +110 -0
  207. package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
  208. package/typings/{esm5/drag-drop → drag-drop/directives}/drop-list.d.ts +32 -72
  209. package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
  210. package/typings/drag-drop/drag-events.d.ts +14 -7
  211. package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +152 -83
  212. package/typings/drag-drop/drop-list-container.d.ts +19 -3
  213. package/typings/drag-drop/drop-list-ref.d.ts +234 -0
  214. package/typings/drag-drop/index.d.ts +1 -0
  215. package/typings/drag-drop/index.metadata.json +1 -1
  216. package/typings/drag-drop/public-api.d.ts +13 -6
  217. package/typings/esm5/a11y/focus-monitor/focus-monitor.d.ts +20 -5
  218. package/typings/esm5/a11y/focus-trap/focus-trap.d.ts +2 -0
  219. package/typings/esm5/a11y/index.metadata.json +1 -1
  220. package/typings/esm5/coercion/element.d.ts +13 -0
  221. package/typings/esm5/coercion/index.metadata.json +1 -1
  222. package/typings/esm5/coercion/public-api.d.ts +1 -0
  223. package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +6 -2
  224. package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
  225. package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
  226. package/typings/esm5/drag-drop/directives/drag.d.ts +110 -0
  227. package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
  228. package/typings/{drag-drop → esm5/drag-drop/directives}/drop-list.d.ts +32 -72
  229. package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
  230. package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
  231. package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +152 -83
  232. package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
  233. package/typings/esm5/drag-drop/drop-list-ref.d.ts +234 -0
  234. package/typings/esm5/drag-drop/index.d.ts +1 -0
  235. package/typings/esm5/drag-drop/index.metadata.json +1 -1
  236. package/typings/esm5/drag-drop/public-api.d.ts +13 -6
  237. package/typings/esm5/index.metadata.json +1 -1
  238. package/typings/esm5/overlay/index.metadata.json +1 -1
  239. package/typings/esm5/overlay/overlay-directives.d.ts +0 -2
  240. package/typings/esm5/overlay/overlay-ref.d.ts +1 -1
  241. package/typings/esm5/portal/portal.d.ts +1 -1
  242. package/typings/esm5/scrolling/index.metadata.json +1 -1
  243. package/typings/esm5/stepper/index.metadata.json +1 -1
  244. package/typings/esm5/stepper/stepper.d.ts +13 -1
  245. package/typings/esm5/text-field/autosize.d.ts +6 -0
  246. package/typings/esm5/text-field/index.metadata.json +1 -1
  247. package/typings/esm5/tree/control/base-tree-control.d.ts +1 -1
  248. package/typings/esm5/tree/control/nested-tree-control.d.ts +2 -2
  249. package/typings/esm5/tree/control/tree-control.d.ts +1 -1
  250. package/typings/esm5/tree/nested-node.d.ts +5 -5
  251. package/typings/index.metadata.json +1 -1
  252. package/typings/overlay/index.metadata.json +1 -1
  253. package/typings/overlay/overlay-directives.d.ts +0 -2
  254. package/typings/overlay/overlay-ref.d.ts +1 -1
  255. package/typings/portal/portal.d.ts +1 -1
  256. package/typings/schematics/ng-update/index.d.ts +2 -0
  257. package/typings/schematics/ng-update/target-version.d.ts +7 -1
  258. package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
  259. package/typings/scrolling/index.metadata.json +1 -1
  260. package/typings/stepper/index.metadata.json +1 -1
  261. package/typings/stepper/stepper.d.ts +13 -1
  262. package/typings/text-field/autosize.d.ts +6 -0
  263. package/typings/text-field/index.metadata.json +1 -1
  264. package/typings/tree/control/base-tree-control.d.ts +1 -1
  265. package/typings/tree/control/nested-tree-control.d.ts +2 -2
  266. package/typings/tree/control/tree-control.d.ts +1 -1
  267. package/typings/tree/nested-node.d.ts +5 -5
@@ -5,18 +5,14 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { Directionality } from '@angular/cdk/bidi';
8
+ import { ElementRef, NgZone, ViewContainerRef, TemplateRef } from '@angular/core';
9
9
  import { ViewportRuler } from '@angular/cdk/scrolling';
10
- import { AfterViewInit, ElementRef, EventEmitter, InjectionToken, NgZone, OnDestroy, QueryList, ViewContainerRef } from '@angular/core';
11
- import { Observable } from 'rxjs';
10
+ import { Directionality } from '@angular/cdk/bidi';
11
+ import { Subject, Observable } from 'rxjs';
12
+ import { DropListRefInternal as DropListRef } from './drop-list-ref';
12
13
  import { DragDropRegistry } from './drag-drop-registry';
13
- import { CdkDragDrop, CdkDragEnd, CdkDragEnter, CdkDragExit, CdkDragMove, CdkDragStart } from './drag-events';
14
- import { CdkDragHandle } from './drag-handle';
15
- import { CdkDragPlaceholder } from './drag-placeholder';
16
- import { CdkDragPreview } from './drag-preview';
17
- import { CdkDropListContainer } from './drop-list-container';
18
- /** Object that can be used to configure the behavior of CdkDrag. */
19
- export interface CdkDragConfig {
14
+ /** Object that can be used to configure the behavior of DragRef. */
15
+ export interface DragRefConfig {
20
16
  /**
21
17
  * Minimum amount of pixels that the user should
22
18
  * drag, before the CDK initiates a drag sequence.
@@ -28,23 +24,27 @@ export interface CdkDragConfig {
28
24
  */
29
25
  pointerDirectionChangeThreshold: number;
30
26
  }
31
- /** Injection token that can be used to configure the behavior of `CdkDrag`. */
32
- export declare const CDK_DRAG_CONFIG: InjectionToken<CdkDragConfig>;
33
- /** @docs-private */
34
- export declare function CDK_DRAG_CONFIG_FACTORY(): CdkDragConfig;
35
- /** Element that can be moved inside a CdkDropList container. */
36
- export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
37
- /** Element that the draggable is attached to. */
38
- element: ElementRef<HTMLElement>;
39
- /** Droppable container that the draggable is a part of. */
40
- dropContainer: CdkDropListContainer;
27
+ /**
28
+ * Internal compile-time-only representation of a `DragRef`.
29
+ * Used to avoid circular import issues between the `DragRef` and the `DropListRef`.
30
+ * @docs-private
31
+ */
32
+ export interface DragRefInternal extends DragRef {
33
+ }
34
+ /**
35
+ * Reference to a draggable item. Used to manipulate or dispose of the item.
36
+ * @docs-private
37
+ */
38
+ export declare class DragRef<T = any> {
39
+ private _document;
41
40
  private _ngZone;
42
41
  private _viewContainerRef;
43
42
  private _viewportRuler;
44
43
  private _dragDropRegistry;
45
44
  private _config;
46
- private _dir;
47
- private _document;
45
+ /** Droppable container that the draggable is a part of. */
46
+ dropContainer?: DropListRef | undefined;
47
+ private _dir?;
48
48
  /** Element displayed next to the user's pointer while the element is dragged. */
49
49
  private _preview;
50
50
  /** Reference to the view of the preview element. */
@@ -77,10 +77,10 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
77
77
  * Whether the dragging sequence has been started. Doesn't
78
78
  * necessarily mean that the element has been moved.
79
79
  */
80
- _hasStartedDragging: boolean;
80
+ private _hasStartedDragging;
81
81
  /** Whether the element has moved since the user started dragging it. */
82
82
  private _hasMoved;
83
- /** Drop container in which the CdkDrag resided when dragging began. */
83
+ /** Drop container in which the DragRef resided when dragging began. */
84
84
  private _initialContainer;
85
85
  /** Cached scroll position on the page when the element was picked up. */
86
86
  private _scrollPosition;
@@ -95,8 +95,16 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
95
95
  private _pointerDirectionDelta;
96
96
  /** Pointer position at which the last change in the delta occurred. */
97
97
  private _pointerPositionAtLastDirectionChange;
98
- /** Root element that will be dragged by the user. */
98
+ /**
99
+ * Root DOM node of the drag instance. This is the element that will
100
+ * be moved around as the user is dragging.
101
+ */
99
102
  private _rootElement;
103
+ /**
104
+ * Inline style value of `-webkit-tap-highlight-color` at the time the
105
+ * dragging was started. Used to restore the value once we're done dragging.
106
+ */
107
+ private _rootElementTapHighlight;
100
108
  /** Subscription to pointer movement events. */
101
109
  private _pointerMoveSubscription;
102
110
  /** Subscription to the event that is dispatched when the user lifts their pointer. */
@@ -107,47 +115,81 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
107
115
  * mouse event for each touch event, after a certain time.
108
116
  */
109
117
  private _lastTouchEventTime;
110
- /** Subscription to the stream that initializes the root element. */
111
- private _rootElementInitSubscription;
112
- /** Elements that can be used to drag the draggable item. */
113
- _handles: QueryList<CdkDragHandle>;
118
+ /** Cached reference to the boundary element. */
119
+ private _boundaryElement;
120
+ /** Whether the native dragging interactions have been enabled on the root element. */
121
+ private _nativeInteractionsEnabled;
122
+ /** Cached dimensions of the preview element. */
123
+ private _previewRect?;
124
+ /** Cached dimensions of the boundary element. */
125
+ private _boundaryRect?;
114
126
  /** Element that will be used as a template to create the draggable item's preview. */
115
- _previewTemplate: CdkDragPreview;
127
+ private _previewTemplate?;
116
128
  /** Template for placeholder element rendered to show where a draggable would be dropped. */
117
- _placeholderTemplate: CdkDragPlaceholder;
118
- /** Arbitrary data to attach to this drag instance. */
119
- data: T;
120
- /** Locks the position of the dragged element along the specified axis. */
129
+ private _placeholderTemplate?;
130
+ /** Elements that can be used to drag the draggable item. */
131
+ private _handles;
132
+ /** Registered handles that are currently disabled. */
133
+ private _disabledHandles;
134
+ /** Axis along which dragging is locked. */
121
135
  lockAxis: 'x' | 'y';
122
- /**
123
- * Selector that will be used to determine the root draggable element, starting from
124
- * the `cdkDrag` element and going up the DOM. Passing an alternate root element is useful
125
- * when trying to enable dragging on an element that you might not have access to.
126
- */
127
- rootElementSelector: string;
128
136
  /** Whether starting to drag this element is disabled. */
129
137
  disabled: boolean;
130
138
  private _disabled;
139
+ /** Emits as the drag sequence is being prepared. */
140
+ beforeStarted: Subject<void>;
131
141
  /** Emits when the user starts dragging the item. */
132
- started: EventEmitter<CdkDragStart>;
142
+ started: Subject<{
143
+ source: DragRef<any>;
144
+ }>;
145
+ /** Emits when the user has released a drag item, before any animations have started. */
146
+ released: Subject<{
147
+ source: DragRef<any>;
148
+ }>;
133
149
  /** Emits when the user stops dragging an item in the container. */
134
- ended: EventEmitter<CdkDragEnd>;
150
+ ended: Subject<{
151
+ source: DragRef<any>;
152
+ }>;
135
153
  /** Emits when the user has moved the item into a new container. */
136
- entered: EventEmitter<CdkDragEnter<any>>;
154
+ entered: Subject<{
155
+ container: DropListRef;
156
+ item: DragRef<any>;
157
+ }>;
137
158
  /** Emits when the user removes the item its container by dragging it into another container. */
138
- exited: EventEmitter<CdkDragExit<any>>;
159
+ exited: Subject<{
160
+ container: DropListRef;
161
+ item: DragRef<any>;
162
+ }>;
139
163
  /** Emits when the user drops the item inside a container. */
140
- dropped: EventEmitter<CdkDragDrop<any>>;
164
+ dropped: Subject<{
165
+ previousIndex: number;
166
+ currentIndex: number;
167
+ item: DragRef<any>;
168
+ container: DropListRef;
169
+ previousContainer: DropListRef;
170
+ isPointerOverContainer: boolean;
171
+ }>;
141
172
  /**
142
173
  * Emits as the user is dragging the item. Use with caution,
143
174
  * because this event will fire for every pixel that the user has dragged.
144
175
  */
145
- moved: Observable<CdkDragMove<T>>;
146
- constructor(
147
- /** Element that the draggable is attached to. */
148
- element: ElementRef<HTMLElement>,
176
+ moved: Observable<{
177
+ source: DragRef;
178
+ pointerPosition: {
179
+ x: number;
180
+ y: number;
181
+ };
182
+ event: MouseEvent | TouchEvent;
183
+ delta: {
184
+ x: -1 | 0 | 1;
185
+ y: -1 | 0 | 1;
186
+ };
187
+ }>;
188
+ /** Arbitrary data that can be attached to the drag item. */
189
+ data: T;
190
+ constructor(element: ElementRef<HTMLElement> | HTMLElement, _document: Document, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry<DragRef, DropListRef>, _config: DragRefConfig,
149
191
  /** Droppable container that the draggable is a part of. */
150
- dropContainer: CdkDropListContainer, document: any, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry<CdkDrag<T>, CdkDropListContainer>, _config: CdkDragConfig, _dir: Directionality);
192
+ dropContainer?: DropListRef | undefined, _dir?: Directionality | undefined);
151
193
  /**
152
194
  * Returns the element that is being used as a placeholder
153
195
  * while the current element is being dragged.
@@ -155,16 +197,60 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
155
197
  getPlaceholderElement(): HTMLElement;
156
198
  /** Returns the root draggable element. */
157
199
  getRootElement(): HTMLElement;
200
+ /** Registers the handles that can be used to drag the element. */
201
+ withHandles(handles: (HTMLElement | ElementRef<HTMLElement>)[]): this;
202
+ /**
203
+ * Registers the template that should be used for the drag preview.
204
+ * @param template Template that from which to stamp out the preview.
205
+ * @param context Variables to add to the template's context.
206
+ */
207
+ withPreviewTemplate(template: TemplateRef<any> | null, context?: any): this;
208
+ /**
209
+ * Registers the template that should be used for the drag placeholder.
210
+ * @param template Template that from which to stamp out the placeholder.
211
+ * @param context Variables to add to the template's context.
212
+ */
213
+ withPlaceholderTemplate(template: TemplateRef<any> | null, context?: any): this;
214
+ /**
215
+ * Sets an alternate drag root element. The root element is the element that will be moved as
216
+ * the user is dragging. Passing an alternate root element is useful when trying to enable
217
+ * dragging on an element that you might not have access to.
218
+ */
219
+ withRootElement(rootElement: ElementRef<HTMLElement> | HTMLElement): this;
220
+ /**
221
+ * Element to which the draggable's position will be constrained.
222
+ */
223
+ withBoundaryElement(boundaryElement: ElementRef<HTMLElement> | HTMLElement | null): this;
224
+ /** Removes the dragging functionality from the DOM element. */
225
+ dispose(): void;
226
+ /** Checks whether the element is currently being dragged. */
227
+ isDragging(): boolean;
158
228
  /** Resets a standalone drag item to its initial position. */
159
229
  reset(): void;
160
- ngAfterViewInit(): void;
161
- ngOnDestroy(): void;
162
- /** Checks whether the element is currently being dragged. */
163
- _isDragging(): boolean;
164
- /** Gets only handles that are not inside descendant `CdkDrag` instances. */
165
- private getChildHandles;
230
+ /**
231
+ * Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
232
+ * @param handle Handle element that should be disabled.
233
+ */
234
+ disableHandle(handle: HTMLElement): void;
235
+ /**
236
+ * Enables a handle, if it has been disabled.
237
+ * @param handle Handle element to be enabled.
238
+ */
239
+ enableHandle(handle: HTMLElement): void;
240
+ /** Unsubscribes from the global subscriptions. */
241
+ private _removeSubscriptions;
242
+ /** Destroys the preview element and its ViewRef. */
243
+ private _destroyPreview;
244
+ /** Destroys the placeholder element and its ViewRef. */
245
+ private _destroyPlaceholder;
166
246
  /** Handler for the `mousedown`/`touchstart` events. */
167
- _pointerDown: (event: TouchEvent | MouseEvent) => void;
247
+ private _pointerDown;
248
+ /** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
249
+ private _pointerMove;
250
+ /** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
251
+ private _pointerUp;
252
+ /** Starts the dragging sequence. */
253
+ private _startDragSequence;
168
254
  /**
169
255
  * Sets up the different variables and subscriptions
170
256
  * that will be necessary for the dragging sequence.
@@ -172,12 +258,6 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
172
258
  * @param event Browser event object that started the sequence.
173
259
  */
174
260
  private _initializeDragSequence;
175
- /** Starts the dragging sequence. */
176
- private _startDragSequence;
177
- /** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
178
- private _pointerMove;
179
- /** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
180
- private _pointerUp;
181
261
  /** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
182
262
  private _cleanupDragArtifacts;
183
263
  /**
@@ -190,6 +270,11 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
190
270
  * and will be used as a preview of the element that is being dragged.
191
271
  */
192
272
  private _createPreviewElement;
273
+ /**
274
+ * Animates the preview element from its current position to the location of the drop placeholder.
275
+ * @returns Promise that resolves when the animation completes.
276
+ */
277
+ private _animatePreviewToPlaceholder;
193
278
  /** Creates an element that will be shown instead of the current element while dragging. */
194
279
  private _createPlaceholderElement;
195
280
  /**
@@ -198,30 +283,14 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
198
283
  * @param event Event that initiated the dragging.
199
284
  */
200
285
  private _getPointerPositionInElement;
201
- /**
202
- * Animates the preview element from its current position to the location of the drop placeholder.
203
- * @returns Promise that resolves when the animation completes.
204
- */
205
- private _animatePreviewToPlaceholder;
206
- /**
207
- * Helper to remove an element from the DOM and to do all the necessary null checks.
208
- * @param element Element to be removed.
209
- */
210
- private _removeElement;
211
286
  /** Determines the point of the page that was touched by the user. */
212
287
  private _getPointerPositionOnPage;
213
288
  /** Gets the pointer position on the page, accounting for any position constraints. */
214
289
  private _getConstrainedPointerPosition;
215
- /** Determines whether an event is a touch event. */
216
- private _isTouchEvent;
217
- /** Destroys the preview element and its ViewRef. */
218
- private _destroyPreview;
219
- /** Destroys the placeholder element and its ViewRef. */
220
- private _destroyPlaceholder;
221
290
  /** Updates the current drag delta, based on the user's current pointer position on the page. */
222
291
  private _updatePointerDirectionDelta;
223
- /** Gets the root draggable element, based on the `rootElementSelector`. */
224
- private _getRootElement;
225
- /** Unsubscribes from the global subscriptions. */
226
- private _removeSubscriptions;
292
+ /** Toggles the native drag interactions, based on how many handles are registered. */
293
+ private _toggleNativeDragInteractions;
294
+ /** Removes the manually-added event listeners from the root element. */
295
+ private _removeRootElementListeners;
227
296
  }
@@ -6,7 +6,14 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { InjectionToken, QueryList, ElementRef } from '@angular/core';
9
- import { CdkDrag } from './drag';
9
+ import { CdkDrag } from './directives/drag';
10
+ /**
11
+ * @deprecated To be removed. No longer being used. Previously the interface was used to avoid
12
+ * circular imports between `CdkDrag` and `CdkDropList`, however now we're using the
13
+ * `CdkDropListInternal` interface to achieve the same result, without having to maintain
14
+ * this large of an interface.
15
+ * @breaking-change 8.0.0
16
+ */
10
17
  export interface CdkDropListContainer<T = any> {
11
18
  /** DOM node that corresponds to the drop container. */
12
19
  element: ElementRef<HTMLElement>;
@@ -27,8 +34,10 @@ export interface CdkDropListContainer<T = any> {
27
34
  * @param item Item being dropped into the container.
28
35
  * @param currentIndex Index at which the item should be inserted.
29
36
  * @param previousContainer Container from which the item got dragged in.
37
+ * @param isPointerOverContainer Whether the user's pointer was over the
38
+ * container when the item was dropped.
30
39
  */
31
- drop(item: CdkDrag, currentIndex: number, previousContainer?: CdkDropListContainer): void;
40
+ drop(item: CdkDrag, currentIndex: number, previousContainer: Partial<CdkDropListContainer>, isPointerOverContainer: boolean): void;
32
41
  /**
33
42
  * Emits an event to indicate that the user moved an item into the container.
34
43
  * @param item Item that was moved into the container.
@@ -52,10 +61,17 @@ export interface CdkDropListContainer<T = any> {
52
61
  }): void;
53
62
  _draggables: QueryList<CdkDrag>;
54
63
  _getSiblingContainerFromPosition(item: CdkDrag, x: number, y: number): CdkDropListContainer | null;
55
- _canReturnItem(x: number, y: number): boolean;
64
+ _isOverContainer(x: number, y: number): boolean;
56
65
  }
57
66
  /**
58
67
  * Injection token that is used to provide a CdkDropList instance to CdkDrag.
59
68
  * Used for avoiding circular imports.
60
69
  */
70
+ export declare const CDK_DROP_LIST: InjectionToken<CdkDropListContainer<any>>;
71
+ /**
72
+ * Injection token that is used to provide a CdkDropList instance to CdkDrag.
73
+ * Used for avoiding circular imports.
74
+ * @deprecated Use `CDK_DROP_LIST` instead.
75
+ * @breaking-change 8.0.0
76
+ */
61
77
  export declare const CDK_DROP_LIST_CONTAINER: InjectionToken<CdkDropListContainer<any>>;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { ElementRef } from '@angular/core';
9
+ import { DragDropRegistry } from './drag-drop-registry';
10
+ import { Directionality } from '@angular/cdk/bidi';
11
+ import { Subject } from 'rxjs';
12
+ import { DragRefInternal as DragRef } from './drag-ref';
13
+ /**
14
+ * Internal compile-time-only representation of a `DropListRef`.
15
+ * Used to avoid circular import issues between the `DropListRef` and the `DragRef`.
16
+ * @docs-private
17
+ */
18
+ export interface DropListRefInternal extends DropListRef {
19
+ }
20
+ /**
21
+ * Reference to a drop list. Used to manipulate or dispose of the container.
22
+ * @docs-private
23
+ */
24
+ export declare class DropListRef<T = any> {
25
+ element: ElementRef<HTMLElement>;
26
+ private _dragDropRegistry;
27
+ private _dir?;
28
+ private _document;
29
+ /**
30
+ * Unique ID for the drop list.
31
+ * @deprecated No longer being used. To be removed.
32
+ * @breaking-change 8.0.0
33
+ */
34
+ id: string;
35
+ /** Whether starting a dragging sequence from this container is disabled. */
36
+ disabled: boolean;
37
+ /** Locks the position of the draggable elements inside the container along the specified axis. */
38
+ lockAxis: 'x' | 'y';
39
+ /**
40
+ * Function that is used to determine whether an item
41
+ * is allowed to be moved into a drop container.
42
+ */
43
+ enterPredicate: (drag: DragRef, drop: DropListRef) => boolean;
44
+ /** Emits right before dragging has started. */
45
+ beforeStarted: Subject<void>;
46
+ /**
47
+ * Emits when the user has moved a new drag item into this container.
48
+ */
49
+ entered: Subject<{
50
+ item: DragRef;
51
+ container: DropListRef<any>;
52
+ }>;
53
+ /**
54
+ * Emits when the user removes an item from the container
55
+ * by dragging it into another container.
56
+ */
57
+ exited: Subject<{
58
+ item: DragRef;
59
+ container: DropListRef<any>;
60
+ }>;
61
+ /** Emits when the user drops an item inside the container. */
62
+ dropped: Subject<{
63
+ item: DragRef;
64
+ currentIndex: number;
65
+ previousIndex: number;
66
+ container: DropListRef<any>;
67
+ previousContainer: DropListRef<any>;
68
+ isPointerOverContainer: boolean;
69
+ }>;
70
+ /** Emits as the user is swapping items while actively dragging. */
71
+ sorted: Subject<{
72
+ previousIndex: number;
73
+ currentIndex: number;
74
+ container: DropListRef<any>;
75
+ item: DragRef;
76
+ }>;
77
+ /** Arbitrary data that can be attached to the drop list. */
78
+ data: T;
79
+ /** Whether an item in the list is being dragged. */
80
+ private _isDragging;
81
+ /** Cache of the dimensions of all the items inside the container. */
82
+ private _itemPositions;
83
+ /** Cached `ClientRect` of the drop list. */
84
+ private _clientRect;
85
+ /**
86
+ * Draggable items that are currently active inside the container. Includes the items
87
+ * from `_draggables`, as well as any items that have been dragged in, but haven't
88
+ * been dropped yet.
89
+ */
90
+ private _activeDraggables;
91
+ /**
92
+ * Keeps track of the item that was last swapped with the dragged item, as
93
+ * well as what direction the pointer was moving in when the swap occured.
94
+ */
95
+ private _previousSwap;
96
+ /** Draggable items in the container. */
97
+ private _draggables;
98
+ /** Drop lists that are connected to the current one. */
99
+ private _siblings;
100
+ /** Direction in which the list is oriented. */
101
+ private _orientation;
102
+ /** Connected siblings that currently have a dragged item. */
103
+ private _activeSiblings;
104
+ constructor(element: ElementRef<HTMLElement>, _dragDropRegistry: DragDropRegistry<DragRef, DropListRef>, _document: any, _dir?: Directionality | undefined);
105
+ /** Removes the drop list functionality from the DOM element. */
106
+ dispose(): void;
107
+ /** Whether an item from this list is currently being dragged. */
108
+ isDragging(): boolean;
109
+ /** Starts dragging an item. */
110
+ start(): void;
111
+ /**
112
+ * Emits an event to indicate that the user moved an item into the container.
113
+ * @param item Item that was moved into the container.
114
+ * @param pointerX Position of the item along the X axis.
115
+ * @param pointerY Position of the item along the Y axis.
116
+ */
117
+ enter(item: DragRef, pointerX: number, pointerY: number): void;
118
+ /**
119
+ * Removes an item from the container after it was dragged into another container by the user.
120
+ * @param item Item that was dragged out.
121
+ */
122
+ exit(item: DragRef): void;
123
+ /**
124
+ * Drops an item into this container.
125
+ * @param item Item being dropped into the container.
126
+ * @param currentIndex Index at which the item should be inserted.
127
+ * @param previousContainer Container from which the item got dragged in.
128
+ * @param isPointerOverContainer Whether the user's pointer was over the
129
+ * container when the item was dropped.
130
+ */
131
+ drop(item: DragRef, currentIndex: number, previousContainer: DropListRef, isPointerOverContainer: boolean): void;
132
+ /**
133
+ * Sets the draggable items that are a part of this list.
134
+ * @param items Items that are a part of this list.
135
+ */
136
+ withItems(items: DragRef[]): this;
137
+ /**
138
+ * Sets the containers that are connected to this one. When two or more containers are
139
+ * connected, the user will be allowed to transfer items between them.
140
+ * @param connectedTo Other containers that the current containers should be connected to.
141
+ */
142
+ connectedTo(connectedTo: DropListRef[]): this;
143
+ /**
144
+ * Sets the orientation of the container.
145
+ * @param orientation New orientation for the container.
146
+ */
147
+ withOrientation(orientation: 'vertical' | 'horizontal'): this;
148
+ /**
149
+ * Figures out the index of an item in the container.
150
+ * @param item Item whose index should be determined.
151
+ */
152
+ getItemIndex(item: DragRef): number;
153
+ /**
154
+ * Whether the list is able to receive the item that
155
+ * is currently being dragged inside a connected drop list.
156
+ */
157
+ isReceiving(): boolean;
158
+ /**
159
+ * Sorts an item inside the container based on its position.
160
+ * @param item Item to be sorted.
161
+ * @param pointerX Position of the item along the X axis.
162
+ * @param pointerY Position of the item along the Y axis.
163
+ * @param pointerDelta Direction in which the pointer is moving along each axis.
164
+ */
165
+ _sortItem(item: DragRef, pointerX: number, pointerY: number, pointerDelta: {
166
+ x: number;
167
+ y: number;
168
+ }): void;
169
+ /** Caches the position of the drop list. */
170
+ private _cacheOwnPosition;
171
+ /** Refreshes the position cache of the items and sibling containers. */
172
+ private _cacheItemPositions;
173
+ /** Resets the container to its initial state. */
174
+ private _reset;
175
+ /**
176
+ * Gets the offset in pixels by which the items that aren't being dragged should be moved.
177
+ * @param currentIndex Index of the item currently being dragged.
178
+ * @param siblings All of the items in the list.
179
+ * @param delta Direction in which the user is moving.
180
+ */
181
+ private _getSiblingOffsetPx;
182
+ /**
183
+ * Checks whether the pointer coordinates are close to the drop container.
184
+ * @param pointerX Coordinates along the X axis.
185
+ * @param pointerY Coordinates along the Y axis.
186
+ */
187
+ private _isPointerNearDropContainer;
188
+ /**
189
+ * Gets the offset in pixels by which the item that is being dragged should be moved.
190
+ * @param currentPosition Current position of the item.
191
+ * @param newPosition Position of the item where the current item should be moved.
192
+ * @param delta Direction in which the user is moving.
193
+ */
194
+ private _getItemOffsetPx;
195
+ /**
196
+ * Gets the index of an item in the drop container, based on the position of the user's pointer.
197
+ * @param item Item that is being sorted.
198
+ * @param pointerX Position of the user's pointer along the X axis.
199
+ * @param pointerY Position of the user's pointer along the Y axis.
200
+ * @param delta Direction in which the user is moving their pointer.
201
+ */
202
+ private _getItemIndexFromPointerPosition;
203
+ /**
204
+ * Checks whether the user's pointer is positioned over the container.
205
+ * @param x Pointer position along the X axis.
206
+ * @param y Pointer position along the Y axis.
207
+ */
208
+ _isOverContainer(x: number, y: number): boolean;
209
+ /**
210
+ * Figures out whether an item should be moved into a sibling
211
+ * drop container, based on its current position.
212
+ * @param item Drag item that is being moved.
213
+ * @param x Position of the item along the X axis.
214
+ * @param y Position of the item along the Y axis.
215
+ */
216
+ _getSiblingContainerFromPosition(item: DragRef, x: number, y: number): DropListRef | undefined;
217
+ /**
218
+ * Checks whether the drop list can receive the passed-in item.
219
+ * @param item Item that is being dragged into the list.
220
+ * @param x Position of the item along the X axis.
221
+ * @param y Position of the item along the Y axis.
222
+ */
223
+ _canReceive(item: DragRef, x: number, y: number): boolean;
224
+ /**
225
+ * Called by one of the connected drop lists when a dragging sequence has started.
226
+ * @param sibling Sibling in which dragging has started.
227
+ */
228
+ _startReceiving(sibling: DropListRef): void;
229
+ /**
230
+ * Called by a connected drop list when dragging has stopped.
231
+ * @param sibling Sibling whose dragging has stopped.
232
+ */
233
+ _stopReceiving(sibling: DropListRef): void;
234
+ }
@@ -3,3 +3,4 @@
3
3
  */
4
4
  export * from './public-api';
5
5
  export { CDK_DRAG_PARENT as ɵa } from './drag-parent';
6
+ export { DragRefConfig as ɵb } from './drag-ref';