@angular/cdk 7.1.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/cdk-a11y.umd.js +5 -1
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +1 -1
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +2030 -1049
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +2 -1
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-stepper.umd.js +11 -3
- package/bundles/cdk-stepper.umd.js.map +1 -1
- package/bundles/cdk-stepper.umd.min.js +1 -1
- package/bundles/cdk-stepper.umd.min.js.map +1 -1
- package/bundles/cdk-text-field.umd.js +41 -16
- package/bundles/cdk-text-field.umd.js.map +1 -1
- package/bundles/cdk-text-field.umd.min.js +1 -1
- package/bundles/cdk-text-field.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +1 -1
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/drag-drop/typings/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/drag-drop/typings/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/drag-drop/typings/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/drag-drop/typings/directives/drag.d.ts +108 -0
- package/{typings/esm5/drag-drop → drag-drop/typings/directives}/drop-list-group.d.ts +3 -0
- package/drag-drop/typings/directives/drop-list.d.ts +135 -0
- package/drag-drop/typings/drag-drop-registry.d.ts +8 -3
- package/drag-drop/typings/drag-events.d.ts +14 -7
- package/{typings/esm5/drag-drop/drag.d.ts → drag-drop/typings/drag-ref.d.ts} +143 -82
- package/drag-drop/typings/drop-list-container.d.ts +19 -3
- package/drag-drop/typings/{drop-list.d.ts → drop-list-ref.d.ts} +132 -84
- package/drag-drop/typings/index.d.ts +1 -0
- package/drag-drop/typings/index.metadata.json +1 -1
- package/drag-drop/typings/public-api.d.ts +13 -6
- package/esm2015/a11y.js +5 -1
- package/esm2015/a11y.js.map +1 -1
- package/esm2015/cdk.js +1 -1
- package/esm2015/cdk.js.map +1 -1
- package/esm2015/drag-drop.js +1546 -811
- package/esm2015/drag-drop.js.map +1 -1
- package/esm2015/stepper.js +11 -4
- package/esm2015/stepper.js.map +1 -1
- package/esm2015/text-field.js +28 -16
- package/esm2015/text-field.js.map +1 -1
- package/esm2015/tree.js +2 -2
- package/esm2015/tree.js.map +1 -1
- package/esm5/a11y.es5.js +5 -1
- package/esm5/a11y.es5.js.map +1 -1
- package/esm5/cdk.es5.js +1 -1
- package/esm5/cdk.es5.js.map +1 -1
- package/esm5/drag-drop.es5.js +2025 -1045
- package/esm5/drag-drop.es5.js.map +1 -1
- package/esm5/stepper.es5.js +11 -4
- package/esm5/stepper.es5.js.map +1 -1
- package/esm5/text-field.es5.js +41 -16
- package/esm5/text-field.es5.js.map +1 -1
- package/esm5/tree.es5.js +2 -2
- package/esm5/tree.es5.js.map +1 -1
- package/package.json +4 -4
- package/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts +2 -2
- package/schematics/ng-update/upgrade-data.js +2 -1
- package/schematics/ng-update/upgrade-data.js.map +1 -1
- package/schematics/ng-update/upgrade-rules/index.js +3 -2
- package/schematics/ng-update/upgrade-rules/index.js.map +1 -1
- package/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/schematics/utils/ast/ng-module-imports.js +25 -13
- package/schematics/utils/ast/ng-module-imports.js.map +1 -1
- package/schematics/utils/get-project.js +2 -1
- package/schematics/utils/get-project.js.map +1 -1
- package/schematics/utils/parse5-element.js +3 -2
- package/schematics/utils/parse5-element.js.map +1 -1
- package/schematics/utils/project-targets.js +2 -1
- package/schematics/utils/project-targets.js.map +1 -1
- package/schematics/utils/version-agnostic-typescript.js +3 -2
- package/schematics/utils/version-agnostic-typescript.js.map +1 -1
- package/stepper/typings/index.metadata.json +1 -1
- package/stepper/typings/stepper.d.ts +6 -0
- package/text-field/typings/autosize.d.ts +6 -0
- package/text-field/typings/index.metadata.json +1 -1
- package/typings/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/typings/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/drag-drop/directives/drag.d.ts +108 -0
- package/typings/drag-drop/{drop-list-group.d.ts → directives/drop-list-group.d.ts} +3 -0
- package/typings/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/drag-drop/drag-events.d.ts +14 -7
- package/typings/drag-drop/{drag.d.ts → drag-ref.d.ts} +143 -82
- package/typings/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/{esm5/drag-drop/drop-list.d.ts → drag-drop/drop-list-ref.d.ts} +132 -84
- package/typings/drag-drop/index.d.ts +1 -0
- package/typings/drag-drop/index.metadata.json +1 -1
- package/typings/drag-drop/public-api.d.ts +13 -6
- package/typings/esm5/drag-drop/{drag-handle.d.ts → directives/drag-handle.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-placeholder.d.ts → directives/drag-placeholder.d.ts} +0 -0
- package/typings/esm5/drag-drop/{drag-preview.d.ts → directives/drag-preview.d.ts} +0 -0
- package/typings/esm5/drag-drop/directives/drag.d.ts +108 -0
- package/{drag-drop/typings → typings/esm5/drag-drop/directives}/drop-list-group.d.ts +3 -0
- package/typings/esm5/drag-drop/directives/drop-list.d.ts +135 -0
- package/typings/esm5/drag-drop/drag-drop-registry.d.ts +8 -3
- package/typings/esm5/drag-drop/drag-events.d.ts +14 -7
- package/{drag-drop/typings/drag.d.ts → typings/esm5/drag-drop/drag-ref.d.ts} +143 -82
- package/typings/esm5/drag-drop/drop-list-container.d.ts +19 -3
- package/typings/{drag-drop/drop-list.d.ts → esm5/drag-drop/drop-list-ref.d.ts} +132 -84
- package/typings/esm5/drag-drop/index.d.ts +1 -0
- package/typings/esm5/drag-drop/index.metadata.json +1 -1
- package/typings/esm5/drag-drop/public-api.d.ts +13 -6
- package/typings/esm5/index.metadata.json +1 -1
- package/typings/esm5/stepper/index.metadata.json +1 -1
- package/typings/esm5/stepper/stepper.d.ts +6 -0
- package/typings/esm5/text-field/autosize.d.ts +6 -0
- package/typings/esm5/text-field/index.metadata.json +1 -1
- package/typings/index.metadata.json +1 -1
- package/typings/schematics/utils/ast/ng-module-imports.d.ts +1 -1
- package/typings/stepper/index.metadata.json +1 -1
- package/typings/stepper/stepper.d.ts +6 -0
- package/typings/text-field/autosize.d.ts +6 -0
- package/typings/text-field/index.metadata.json +1 -1
|
@@ -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 {
|
|
8
|
+
import { ElementRef, NgZone, ViewContainerRef, TemplateRef } from '@angular/core';
|
|
9
9
|
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
10
|
-
import {
|
|
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
|
-
|
|
14
|
-
|
|
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,38 @@ export interface CdkDragConfig {
|
|
|
28
24
|
*/
|
|
29
25
|
pointerDirectionChangeThreshold: number;
|
|
30
26
|
}
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Template that can be used to create a drag helper element (e.g. a preview or a placeholder).
|
|
29
|
+
*/
|
|
30
|
+
interface DragHelperTemplate<T = any> {
|
|
31
|
+
templateRef: TemplateRef<T>;
|
|
32
|
+
data: T;
|
|
33
|
+
}
|
|
34
|
+
interface DragHandle {
|
|
38
35
|
element: ElementRef<HTMLElement>;
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Internal compile-time-only representation of a `DragRef`.
|
|
40
|
+
* Used to avoid circular import issues between the `DragRef` and the `DropListRef`.
|
|
41
|
+
* @docs-private
|
|
42
|
+
*/
|
|
43
|
+
export interface DragRefInternal extends DragRef {
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Reference to a draggable item. Used to manipulate or dispose of the item.
|
|
47
|
+
* @docs-private
|
|
48
|
+
*/
|
|
49
|
+
export declare class DragRef<T = any> {
|
|
50
|
+
private _document;
|
|
41
51
|
private _ngZone;
|
|
42
52
|
private _viewContainerRef;
|
|
43
53
|
private _viewportRuler;
|
|
44
54
|
private _dragDropRegistry;
|
|
45
55
|
private _config;
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
/** Droppable container that the draggable is a part of. */
|
|
57
|
+
dropContainer?: DropListRef | undefined;
|
|
58
|
+
private _dir?;
|
|
48
59
|
/** Element displayed next to the user's pointer while the element is dragged. */
|
|
49
60
|
private _preview;
|
|
50
61
|
/** Reference to the view of the preview element. */
|
|
@@ -77,10 +88,10 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
77
88
|
* Whether the dragging sequence has been started. Doesn't
|
|
78
89
|
* necessarily mean that the element has been moved.
|
|
79
90
|
*/
|
|
80
|
-
_hasStartedDragging
|
|
91
|
+
private _hasStartedDragging;
|
|
81
92
|
/** Whether the element has moved since the user started dragging it. */
|
|
82
93
|
private _hasMoved;
|
|
83
|
-
/** Drop container in which the
|
|
94
|
+
/** Drop container in which the DragRef resided when dragging began. */
|
|
84
95
|
private _initialContainer;
|
|
85
96
|
/** Cached scroll position on the page when the element was picked up. */
|
|
86
97
|
private _scrollPosition;
|
|
@@ -95,8 +106,16 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
95
106
|
private _pointerDirectionDelta;
|
|
96
107
|
/** Pointer position at which the last change in the delta occurred. */
|
|
97
108
|
private _pointerPositionAtLastDirectionChange;
|
|
98
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Root DOM node of the drag instance. This is the element that will
|
|
111
|
+
* be moved around as the user is dragging.
|
|
112
|
+
*/
|
|
99
113
|
private _rootElement;
|
|
114
|
+
/**
|
|
115
|
+
* Inline style value of `-webkit-tap-highlight-color` at the time the
|
|
116
|
+
* dragging was started. Used to restore the value once we're done dragging.
|
|
117
|
+
*/
|
|
118
|
+
private _rootElementTapHighlight;
|
|
100
119
|
/** Subscription to pointer movement events. */
|
|
101
120
|
private _pointerMoveSubscription;
|
|
102
121
|
/** Subscription to the event that is dispatched when the user lifts their pointer. */
|
|
@@ -107,47 +126,79 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
107
126
|
* mouse event for each touch event, after a certain time.
|
|
108
127
|
*/
|
|
109
128
|
private _lastTouchEventTime;
|
|
110
|
-
/**
|
|
111
|
-
private
|
|
112
|
-
/**
|
|
113
|
-
|
|
129
|
+
/** Cached reference to the boundary element. */
|
|
130
|
+
private _boundaryElement;
|
|
131
|
+
/** Cached dimensions of the preview element. */
|
|
132
|
+
private _previewRect?;
|
|
133
|
+
/** Cached dimensions of the boundary element. */
|
|
134
|
+
private _boundaryRect?;
|
|
114
135
|
/** Element that will be used as a template to create the draggable item's preview. */
|
|
115
|
-
_previewTemplate
|
|
136
|
+
private _previewTemplate;
|
|
116
137
|
/** Template for placeholder element rendered to show where a draggable would be dropped. */
|
|
117
|
-
_placeholderTemplate
|
|
118
|
-
/**
|
|
119
|
-
|
|
120
|
-
/**
|
|
138
|
+
private _placeholderTemplate;
|
|
139
|
+
/** Elements that can be used to drag the draggable item. */
|
|
140
|
+
private _handles;
|
|
141
|
+
/** Whether the native interactions on the element are enabled. */
|
|
142
|
+
private _nativeInteractionsEnabled;
|
|
143
|
+
/** Axis along which dragging is locked. */
|
|
121
144
|
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
145
|
/** Whether starting to drag this element is disabled. */
|
|
129
146
|
disabled: boolean;
|
|
130
147
|
private _disabled;
|
|
148
|
+
/** Emits as the drag sequence is being prepared. */
|
|
149
|
+
beforeStarted: Subject<void>;
|
|
131
150
|
/** Emits when the user starts dragging the item. */
|
|
132
|
-
started:
|
|
151
|
+
started: Subject<{
|
|
152
|
+
source: DragRef<any>;
|
|
153
|
+
}>;
|
|
154
|
+
/** Emits when the user has released a drag item, before any animations have started. */
|
|
155
|
+
released: Subject<{
|
|
156
|
+
source: DragRef<any>;
|
|
157
|
+
}>;
|
|
133
158
|
/** Emits when the user stops dragging an item in the container. */
|
|
134
|
-
ended:
|
|
159
|
+
ended: Subject<{
|
|
160
|
+
source: DragRef<any>;
|
|
161
|
+
}>;
|
|
135
162
|
/** Emits when the user has moved the item into a new container. */
|
|
136
|
-
entered:
|
|
163
|
+
entered: Subject<{
|
|
164
|
+
container: DropListRef;
|
|
165
|
+
item: DragRef<any>;
|
|
166
|
+
}>;
|
|
137
167
|
/** Emits when the user removes the item its container by dragging it into another container. */
|
|
138
|
-
exited:
|
|
168
|
+
exited: Subject<{
|
|
169
|
+
container: DropListRef;
|
|
170
|
+
item: DragRef<any>;
|
|
171
|
+
}>;
|
|
139
172
|
/** Emits when the user drops the item inside a container. */
|
|
140
|
-
dropped:
|
|
173
|
+
dropped: Subject<{
|
|
174
|
+
previousIndex: number;
|
|
175
|
+
currentIndex: number;
|
|
176
|
+
item: DragRef<any>;
|
|
177
|
+
container: DropListRef;
|
|
178
|
+
previousContainer: DropListRef;
|
|
179
|
+
isPointerOverContainer: boolean;
|
|
180
|
+
}>;
|
|
141
181
|
/**
|
|
142
182
|
* Emits as the user is dragging the item. Use with caution,
|
|
143
183
|
* because this event will fire for every pixel that the user has dragged.
|
|
144
184
|
*/
|
|
145
|
-
moved: Observable<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
185
|
+
moved: Observable<{
|
|
186
|
+
source: DragRef;
|
|
187
|
+
pointerPosition: {
|
|
188
|
+
x: number;
|
|
189
|
+
y: number;
|
|
190
|
+
};
|
|
191
|
+
event: MouseEvent | TouchEvent;
|
|
192
|
+
delta: {
|
|
193
|
+
x: -1 | 0 | 1;
|
|
194
|
+
y: -1 | 0 | 1;
|
|
195
|
+
};
|
|
196
|
+
}>;
|
|
197
|
+
/** Arbitrary data that can be attached to the drag item. */
|
|
198
|
+
data: T;
|
|
199
|
+
constructor(element: ElementRef<HTMLElement> | HTMLElement, _document: Document, _ngZone: NgZone, _viewContainerRef: ViewContainerRef, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry<DragRef, DropListRef>, _config: DragRefConfig,
|
|
149
200
|
/** Droppable container that the draggable is a part of. */
|
|
150
|
-
dropContainer
|
|
201
|
+
dropContainer?: DropListRef | undefined, _dir?: Directionality | undefined);
|
|
151
202
|
/**
|
|
152
203
|
* Returns the element that is being used as a placeholder
|
|
153
204
|
* while the current element is being dragged.
|
|
@@ -155,16 +206,42 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
155
206
|
getPlaceholderElement(): HTMLElement;
|
|
156
207
|
/** Returns the root draggable element. */
|
|
157
208
|
getRootElement(): HTMLElement;
|
|
209
|
+
/** Registers the handles that can be used to drag the element. */
|
|
210
|
+
withHandles(handles: DragHandle[]): this;
|
|
211
|
+
/** Registers the template that should be used for the drag preview. */
|
|
212
|
+
withPreviewTemplate(template: DragHelperTemplate | null): this;
|
|
213
|
+
/** Registers the template that should be used for the drag placeholder. */
|
|
214
|
+
withPlaceholderTemplate(template: DragHelperTemplate | null): this;
|
|
215
|
+
/**
|
|
216
|
+
* Sets an alternate drag root element. The root element is the element that will be moved as
|
|
217
|
+
* the user is dragging. Passing an alternate root element is useful when trying to enable
|
|
218
|
+
* dragging on an element that you might not have access to.
|
|
219
|
+
*/
|
|
220
|
+
withRootElement(rootElement: ElementRef<HTMLElement> | HTMLElement): this;
|
|
221
|
+
/**
|
|
222
|
+
* Element to which the draggable's position will be constrained.
|
|
223
|
+
*/
|
|
224
|
+
withBoundaryElement(boundaryElement: ElementRef<HTMLElement> | HTMLElement | null): this;
|
|
225
|
+
/** Removes the dragging functionality from the DOM element. */
|
|
226
|
+
dispose(): void;
|
|
227
|
+
/** Checks whether the element is currently being dragged. */
|
|
228
|
+
isDragging(): boolean;
|
|
158
229
|
/** Resets a standalone drag item to its initial position. */
|
|
159
230
|
reset(): void;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
private
|
|
231
|
+
/** Unsubscribes from the global subscriptions. */
|
|
232
|
+
private _removeSubscriptions;
|
|
233
|
+
/** Destroys the preview element and its ViewRef. */
|
|
234
|
+
private _destroyPreview;
|
|
235
|
+
/** Destroys the placeholder element and its ViewRef. */
|
|
236
|
+
private _destroyPlaceholder;
|
|
166
237
|
/** Handler for the `mousedown`/`touchstart` events. */
|
|
167
|
-
_pointerDown
|
|
238
|
+
private _pointerDown;
|
|
239
|
+
/** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
|
|
240
|
+
private _pointerMove;
|
|
241
|
+
/** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
|
|
242
|
+
private _pointerUp;
|
|
243
|
+
/** Starts the dragging sequence. */
|
|
244
|
+
private _startDragSequence;
|
|
168
245
|
/**
|
|
169
246
|
* Sets up the different variables and subscriptions
|
|
170
247
|
* that will be necessary for the dragging sequence.
|
|
@@ -172,12 +249,6 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
172
249
|
* @param event Browser event object that started the sequence.
|
|
173
250
|
*/
|
|
174
251
|
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
252
|
/** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
|
|
182
253
|
private _cleanupDragArtifacts;
|
|
183
254
|
/**
|
|
@@ -190,6 +261,11 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
190
261
|
* and will be used as a preview of the element that is being dragged.
|
|
191
262
|
*/
|
|
192
263
|
private _createPreviewElement;
|
|
264
|
+
/**
|
|
265
|
+
* Animates the preview element from its current position to the location of the drop placeholder.
|
|
266
|
+
* @returns Promise that resolves when the animation completes.
|
|
267
|
+
*/
|
|
268
|
+
private _animatePreviewToPlaceholder;
|
|
193
269
|
/** Creates an element that will be shown instead of the current element while dragging. */
|
|
194
270
|
private _createPlaceholderElement;
|
|
195
271
|
/**
|
|
@@ -198,30 +274,15 @@ export declare class CdkDrag<T = any> implements AfterViewInit, OnDestroy {
|
|
|
198
274
|
* @param event Event that initiated the dragging.
|
|
199
275
|
*/
|
|
200
276
|
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
277
|
/** Determines the point of the page that was touched by the user. */
|
|
212
278
|
private _getPointerPositionOnPage;
|
|
213
279
|
/** Gets the pointer position on the page, accounting for any position constraints. */
|
|
214
280
|
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
281
|
/** Updates the current drag delta, based on the user's current pointer position on the page. */
|
|
222
282
|
private _updatePointerDirectionDelta;
|
|
223
|
-
/**
|
|
224
|
-
private
|
|
225
|
-
/**
|
|
226
|
-
private
|
|
283
|
+
/** Toggles the native drag interactions, based on how many handles are registered. */
|
|
284
|
+
private _toggleNativeDragInteractions;
|
|
285
|
+
/** Removes the manually-added event listeners from the root element. */
|
|
286
|
+
private _removeRootElementListeners;
|
|
227
287
|
}
|
|
288
|
+
export {};
|
|
@@ -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
|
|
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
|
-
|
|
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>>;
|
|
@@ -5,64 +5,79 @@
|
|
|
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 { ElementRef
|
|
9
|
-
import { Directionality } from '@angular/cdk/bidi';
|
|
10
|
-
import { CdkDrag } from './drag';
|
|
8
|
+
import { ElementRef } from '@angular/core';
|
|
11
9
|
import { DragDropRegistry } from './drag-drop-registry';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
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> {
|
|
16
25
|
element: ElementRef<HTMLElement>;
|
|
17
26
|
private _dragDropRegistry;
|
|
18
|
-
private _changeDetectorRef;
|
|
19
27
|
private _dir?;
|
|
20
|
-
private
|
|
21
|
-
/** Draggable items in the container. */
|
|
22
|
-
_draggables: QueryList<CdkDrag>;
|
|
23
|
-
/**
|
|
24
|
-
* Other draggable containers that this container is connected to and into which the
|
|
25
|
-
* container's items can be transferred. Can either be references to other drop containers,
|
|
26
|
-
* or their unique IDs.
|
|
27
|
-
*/
|
|
28
|
-
connectedTo: (CdkDropList | string)[] | CdkDropList | string;
|
|
29
|
-
/** Arbitrary data to attach to this container. */
|
|
30
|
-
data: T;
|
|
31
|
-
/** Direction in which the list is oriented. */
|
|
32
|
-
orientation: 'horizontal' | 'vertical';
|
|
28
|
+
private _document;
|
|
33
29
|
/**
|
|
34
|
-
* Unique ID for the drop
|
|
35
|
-
*
|
|
30
|
+
* Unique ID for the drop list.
|
|
31
|
+
* @deprecated No longer being used. To be removed.
|
|
32
|
+
* @breaking-change 8.0.0
|
|
36
33
|
*/
|
|
37
34
|
id: string;
|
|
38
|
-
/** Locks the position of the draggable elements inside the container along the specified axis. */
|
|
39
|
-
lockAxis: 'x' | 'y';
|
|
40
35
|
/** Whether starting a dragging sequence from this container is disabled. */
|
|
41
36
|
disabled: boolean;
|
|
42
|
-
|
|
37
|
+
/** Locks the position of the draggable elements inside the container along the specified axis. */
|
|
38
|
+
lockAxis: 'x' | 'y';
|
|
43
39
|
/**
|
|
44
40
|
* Function that is used to determine whether an item
|
|
45
41
|
* is allowed to be moved into a drop container.
|
|
46
42
|
*/
|
|
47
|
-
enterPredicate: (drag:
|
|
48
|
-
/** Emits
|
|
49
|
-
|
|
43
|
+
enterPredicate: (drag: DragRef, drop: DropListRef) => boolean;
|
|
44
|
+
/** Emits right before dragging has started. */
|
|
45
|
+
beforeStarted: Subject<void>;
|
|
50
46
|
/**
|
|
51
47
|
* Emits when the user has moved a new drag item into this container.
|
|
52
48
|
*/
|
|
53
|
-
entered:
|
|
49
|
+
entered: Subject<{
|
|
50
|
+
item: DragRef;
|
|
51
|
+
container: DropListRef<any>;
|
|
52
|
+
}>;
|
|
54
53
|
/**
|
|
55
54
|
* Emits when the user removes an item from the container
|
|
56
55
|
* by dragging it into another container.
|
|
57
56
|
*/
|
|
58
|
-
exited:
|
|
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
|
+
}>;
|
|
59
70
|
/** Emits as the user is swapping items while actively dragging. */
|
|
60
|
-
sorted:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
66
81
|
/** Cache of the dimensions of all the items and the sibling containers. */
|
|
67
82
|
private _positionCache;
|
|
68
83
|
/**
|
|
@@ -76,77 +91,97 @@ export declare class CdkDropList<T = any> implements OnInit, OnDestroy {
|
|
|
76
91
|
* well as what direction the pointer was moving in when the swap occured.
|
|
77
92
|
*/
|
|
78
93
|
private _previousSwap;
|
|
79
|
-
/** Starts dragging an item. */
|
|
80
|
-
start(): void;
|
|
81
94
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @param currentIndex Index at which the item should be inserted.
|
|
85
|
-
* @param previousContainer Container from which the item got dragged in.
|
|
95
|
+
* Draggable items in the container.
|
|
96
|
+
* TODO(crisbeto): support arrays.
|
|
86
97
|
*/
|
|
87
|
-
|
|
98
|
+
private _draggables;
|
|
99
|
+
private _siblings;
|
|
100
|
+
/** Direction in which the list is oriented. */
|
|
101
|
+
private _orientation;
|
|
102
|
+
/** Amount of 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;
|
|
88
111
|
/**
|
|
89
112
|
* Emits an event to indicate that the user moved an item into the container.
|
|
90
113
|
* @param item Item that was moved into the container.
|
|
91
114
|
* @param pointerX Position of the item along the X axis.
|
|
92
115
|
* @param pointerY Position of the item along the Y axis.
|
|
93
116
|
*/
|
|
94
|
-
enter(item:
|
|
117
|
+
enter(item: DragRef, pointerX: number, pointerY: number): void;
|
|
95
118
|
/**
|
|
96
119
|
* Removes an item from the container after it was dragged into another container by the user.
|
|
97
120
|
* @param item Item that was dragged out.
|
|
98
121
|
*/
|
|
99
|
-
exit(item:
|
|
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;
|
|
100
148
|
/**
|
|
101
149
|
* Figures out the index of an item in the container.
|
|
102
150
|
* @param item Item whose index should be determined.
|
|
103
151
|
*/
|
|
104
|
-
getItemIndex(item:
|
|
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;
|
|
105
158
|
/**
|
|
106
159
|
* Sorts an item inside the container based on its position.
|
|
107
160
|
* @param item Item to be sorted.
|
|
108
161
|
* @param pointerX Position of the item along the X axis.
|
|
109
162
|
* @param pointerY Position of the item along the Y axis.
|
|
110
|
-
* @param
|
|
163
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
111
164
|
*/
|
|
112
|
-
_sortItem(item:
|
|
165
|
+
_sortItem(item: DragRef, pointerX: number, pointerY: number, pointerDelta: {
|
|
113
166
|
x: number;
|
|
114
167
|
y: number;
|
|
115
168
|
}): void;
|
|
116
|
-
/**
|
|
117
|
-
* Figures out whether an item should be moved into a sibling
|
|
118
|
-
* drop container, based on its current position.
|
|
119
|
-
* @param item Drag item that is being moved.
|
|
120
|
-
* @param x Position of the item along the X axis.
|
|
121
|
-
* @param y Position of the item along the Y axis.
|
|
122
|
-
*/
|
|
123
|
-
_getSiblingContainerFromPosition(item: CdkDrag, x: number, y: number): CdkDropList | null;
|
|
124
|
-
/**
|
|
125
|
-
* Checks whether an item that started in this container can be returned to it,
|
|
126
|
-
* after it was moved out into another container.
|
|
127
|
-
* @param x Position of the item along the X axis.
|
|
128
|
-
* @param y Position of the item along the Y axis.
|
|
129
|
-
*/
|
|
130
|
-
_canReturnItem(x: number, y: number): boolean;
|
|
131
169
|
/** Refreshes the position cache of the items and sibling containers. */
|
|
132
170
|
private _cachePositions;
|
|
133
|
-
/** Resets the container to its initial state. */
|
|
134
|
-
private _reset;
|
|
135
171
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @param top Amount to add to the `top` position.
|
|
139
|
-
* @param left Amount to add to the `left` position.
|
|
172
|
+
* Toggles whether the list can receive the item that is currently being dragged.
|
|
173
|
+
* Usually called by a sibling that initiated the dragging.
|
|
140
174
|
*/
|
|
141
|
-
|
|
175
|
+
_toggleIsReceiving(isDragging: boolean): void;
|
|
176
|
+
/** Resets the container to its initial state. */
|
|
177
|
+
private _reset;
|
|
142
178
|
/**
|
|
143
|
-
* Gets the
|
|
144
|
-
* @param
|
|
145
|
-
* @param
|
|
146
|
-
* @param
|
|
147
|
-
* @param delta Direction in which the user is moving their pointer.
|
|
179
|
+
* Gets the offset in pixels by which the items that aren't being dragged should be moved.
|
|
180
|
+
* @param currentIndex Index of the item currently being dragged.
|
|
181
|
+
* @param siblings All of the items in the list.
|
|
182
|
+
* @param delta Direction in which the user is moving.
|
|
148
183
|
*/
|
|
149
|
-
private
|
|
184
|
+
private _getSiblingOffsetPx;
|
|
150
185
|
/**
|
|
151
186
|
* Checks whether the pointer coordinates are close to the drop container.
|
|
152
187
|
* @param pointerX Coordinates along the X axis.
|
|
@@ -161,12 +196,25 @@ export declare class CdkDropList<T = any> implements OnInit, OnDestroy {
|
|
|
161
196
|
*/
|
|
162
197
|
private _getItemOffsetPx;
|
|
163
198
|
/**
|
|
164
|
-
* Gets the
|
|
165
|
-
* @param
|
|
166
|
-
* @param
|
|
167
|
-
* @param
|
|
199
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
200
|
+
* @param item Item that is being sorted.
|
|
201
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
202
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
203
|
+
* @param delta Direction in which the user is moving their pointer.
|
|
168
204
|
*/
|
|
169
|
-
private
|
|
170
|
-
/**
|
|
171
|
-
|
|
205
|
+
private _getItemIndexFromPointerPosition;
|
|
206
|
+
/**
|
|
207
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
208
|
+
* @param x Pointer position along the X axis.
|
|
209
|
+
* @param y Pointer position along the Y axis.
|
|
210
|
+
*/
|
|
211
|
+
_isOverContainer(x: number, y: number): boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Figures out whether an item should be moved into a sibling
|
|
214
|
+
* drop container, based on its current position.
|
|
215
|
+
* @param item Drag item that is being moved.
|
|
216
|
+
* @param x Position of the item along the X axis.
|
|
217
|
+
* @param y Position of the item along the Y axis.
|
|
218
|
+
*/
|
|
219
|
+
_getSiblingContainerFromPosition(item: DragRef, x: number, y: number): DropListRef | null;
|
|
172
220
|
}
|