[6a3a178] | 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 { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
---|
| 9 | import { ElementRef, EventEmitter, OnDestroy, ChangeDetectorRef, InjectionToken } from '@angular/core';
|
---|
| 10 | import { Directionality } from '@angular/cdk/bidi';
|
---|
| 11 | import { ScrollDispatcher } from '@angular/cdk/scrolling';
|
---|
| 12 | import { CdkDrag } from './drag';
|
---|
| 13 | import { CdkDragDrop, CdkDragEnter, CdkDragExit, CdkDragSortEvent } from '../drag-events';
|
---|
| 14 | import { CdkDropListGroup } from './drop-list-group';
|
---|
| 15 | import { DropListRef } from '../drop-list-ref';
|
---|
| 16 | import { DragDrop } from '../drag-drop';
|
---|
| 17 | import { DropListOrientation, DragAxis, DragDropConfig } from './config';
|
---|
| 18 | /**
|
---|
| 19 | * Internal compile-time-only representation of a `CdkDropList`.
|
---|
| 20 | * Used to avoid circular import issues between the `CdkDropList` and the `CdkDrag`.
|
---|
| 21 | * @docs-private
|
---|
| 22 | */
|
---|
| 23 | export interface CdkDropListInternal extends CdkDropList {
|
---|
| 24 | }
|
---|
| 25 | /**
|
---|
| 26 | * Injection token that can be used to reference instances of `CdkDropList`. It serves as
|
---|
| 27 | * alternative token to the actual `CdkDropList` class which could cause unnecessary
|
---|
| 28 | * retention of the class and its directive metadata.
|
---|
| 29 | */
|
---|
| 30 | export declare const CDK_DROP_LIST: InjectionToken<CdkDropList<any>>;
|
---|
| 31 | /** Container that wraps a set of draggable items. */
|
---|
| 32 | export declare class CdkDropList<T = any> implements OnDestroy {
|
---|
| 33 | /** Element that the drop list is attached to. */
|
---|
| 34 | element: ElementRef<HTMLElement>;
|
---|
| 35 | private _changeDetectorRef;
|
---|
| 36 | private _scrollDispatcher;
|
---|
| 37 | private _dir?;
|
---|
| 38 | private _group?;
|
---|
| 39 | /** Emits when the list has been destroyed. */
|
---|
| 40 | private readonly _destroyed;
|
---|
| 41 | /** Whether the element's scrollable parents have been resolved. */
|
---|
| 42 | private _scrollableParentsResolved;
|
---|
| 43 | /** Keeps track of the drop lists that are currently on the page. */
|
---|
| 44 | private static _dropLists;
|
---|
| 45 | /** Reference to the underlying drop list instance. */
|
---|
| 46 | _dropListRef: DropListRef<CdkDropList<T>>;
|
---|
| 47 | /**
|
---|
| 48 | * Other draggable containers that this container is connected to and into which the
|
---|
| 49 | * container's items can be transferred. Can either be references to other drop containers,
|
---|
| 50 | * or their unique IDs.
|
---|
| 51 | */
|
---|
| 52 | connectedTo: (CdkDropList | string)[] | CdkDropList | string;
|
---|
| 53 | /** Arbitrary data to attach to this container. */
|
---|
| 54 | data: T;
|
---|
| 55 | /** Direction in which the list is oriented. */
|
---|
| 56 | orientation: DropListOrientation;
|
---|
| 57 | /**
|
---|
| 58 | * Unique ID for the drop zone. Can be used as a reference
|
---|
| 59 | * in the `connectedTo` of another `CdkDropList`.
|
---|
| 60 | */
|
---|
| 61 | id: string;
|
---|
| 62 | /** Locks the position of the draggable elements inside the container along the specified axis. */
|
---|
| 63 | lockAxis: DragAxis;
|
---|
| 64 | /** Whether starting a dragging sequence from this container is disabled. */
|
---|
| 65 | get disabled(): boolean;
|
---|
| 66 | set disabled(value: boolean);
|
---|
| 67 | private _disabled;
|
---|
| 68 | /** Whether sorting within this drop list is disabled. */
|
---|
| 69 | sortingDisabled: boolean;
|
---|
| 70 | /**
|
---|
| 71 | * Function that is used to determine whether an item
|
---|
| 72 | * is allowed to be moved into a drop container.
|
---|
| 73 | */
|
---|
| 74 | enterPredicate: (drag: CdkDrag, drop: CdkDropList) => boolean;
|
---|
| 75 | /** Functions that is used to determine whether an item can be sorted into a particular index. */
|
---|
| 76 | sortPredicate: (index: number, drag: CdkDrag, drop: CdkDropList) => boolean;
|
---|
| 77 | /** Whether to auto-scroll the view when the user moves their pointer close to the edges. */
|
---|
| 78 | autoScrollDisabled: boolean;
|
---|
| 79 | /** Number of pixels to scroll for each frame when auto-scrolling an element. */
|
---|
| 80 | autoScrollStep: number;
|
---|
| 81 | /** Emits when the user drops an item inside the container. */
|
---|
| 82 | readonly dropped: EventEmitter<CdkDragDrop<T, any>>;
|
---|
| 83 | /**
|
---|
| 84 | * Emits when the user has moved a new drag item into this container.
|
---|
| 85 | */
|
---|
| 86 | readonly entered: EventEmitter<CdkDragEnter<T>>;
|
---|
| 87 | /**
|
---|
| 88 | * Emits when the user removes an item from the container
|
---|
| 89 | * by dragging it into another container.
|
---|
| 90 | */
|
---|
| 91 | readonly exited: EventEmitter<CdkDragExit<T>>;
|
---|
| 92 | /** Emits as the user is swapping items while actively dragging. */
|
---|
| 93 | readonly sorted: EventEmitter<CdkDragSortEvent<T>>;
|
---|
| 94 | /**
|
---|
| 95 | * Keeps track of the items that are registered with this container. Historically we used to
|
---|
| 96 | * do this with a `ContentChildren` query, however queries don't handle transplanted views very
|
---|
| 97 | * well which means that we can't handle cases like dragging the headers of a `mat-table`
|
---|
| 98 | * correctly. What we do instead is to have the items register themselves with the container
|
---|
| 99 | * and then we sort them based on their position in the DOM.
|
---|
| 100 | */
|
---|
| 101 | private _unsortedItems;
|
---|
| 102 | constructor(
|
---|
| 103 | /** Element that the drop list is attached to. */
|
---|
| 104 | element: ElementRef<HTMLElement>, dragDrop: DragDrop, _changeDetectorRef: ChangeDetectorRef, _scrollDispatcher: ScrollDispatcher, _dir?: Directionality | undefined, _group?: CdkDropListGroup<CdkDropList<any>> | undefined, config?: DragDropConfig);
|
---|
| 105 | /** Registers an items with the drop list. */
|
---|
| 106 | addItem(item: CdkDrag): void;
|
---|
| 107 | /** Removes an item from the drop list. */
|
---|
| 108 | removeItem(item: CdkDrag): void;
|
---|
| 109 | /** Gets the registered items in the list, sorted by their position in the DOM. */
|
---|
| 110 | getSortedItems(): CdkDrag[];
|
---|
| 111 | ngOnDestroy(): void;
|
---|
| 112 | /** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
|
---|
| 113 | private _setupInputSyncSubscription;
|
---|
| 114 | /** Handles events from the underlying DropListRef. */
|
---|
| 115 | private _handleEvents;
|
---|
| 116 | /** Assigns the default input values based on a provided config object. */
|
---|
| 117 | private _assignDefaults;
|
---|
| 118 | /** Syncs up the registered drag items with underlying drop list ref. */
|
---|
| 119 | private _syncItemsWithRef;
|
---|
| 120 | static ngAcceptInputType_disabled: BooleanInput;
|
---|
| 121 | static ngAcceptInputType_sortingDisabled: BooleanInput;
|
---|
| 122 | static ngAcceptInputType_autoScrollDisabled: BooleanInput;
|
---|
| 123 | static ngAcceptInputType_autoScrollStep: NumberInput;
|
---|
| 124 | }
|
---|