@vue-dnd-kit/core 2.4.7 → 3.0.0-beta.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.
- package/LICENSE +21 -0
- package/dist/devtools.cjs +2 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +610 -0
- package/dist/devtools.d.ts +610 -0
- package/dist/devtools.js +569 -0
- package/dist/devtools.js.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2425 -0
- package/dist/index.d.ts +2425 -2
- package/dist/index.js +5865 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -29
- package/dist/external/components/DnDProvider.vue.d.ts +0 -25
- package/dist/external/components/DragPreview.vue.d.ts +0 -89
- package/dist/external/composables/makeAutoScroll.d.ts +0 -14
- package/dist/external/composables/makeConstraintArea.d.ts +0 -7
- package/dist/external/composables/makeDraggable.d.ts +0 -24
- package/dist/external/composables/makeDroppable.d.ts +0 -21
- package/dist/external/composables/makeSelectionArea.d.ts +0 -15
- package/dist/external/composables/useDnDProvider.d.ts +0 -2
- package/dist/external/env.d.ts +0 -7
- package/dist/external/index.d.ts +0 -11
- package/dist/external/types/entities.d.ts +0 -208
- package/dist/external/types/index.d.ts +0 -5
- package/dist/external/types/operations.d.ts +0 -187
- package/dist/external/types/placement.d.ts +0 -34
- package/dist/external/types/pointer.d.ts +0 -10
- package/dist/external/types/provider.d.ts +0 -89
- package/dist/internal/composables/useDnDProviderEvents.d.ts +0 -2
- package/dist/internal/composables/useDnDProviderInternal.d.ts +0 -2
- package/dist/internal/composables/useDnDProviderState.d.ts +0 -4
- package/dist/internal/composables/useViewportAutoScroll.d.ts +0 -9
- package/dist/internal/logic/hover.d.ts +0 -6
- package/dist/internal/logic/keyboard.d.ts +0 -6
- package/dist/internal/logic/operations.d.ts +0 -35
- package/dist/internal/logic/payload.d.ts +0 -5
- package/dist/internal/logic/pointer.d.ts +0 -11
- package/dist/internal/logic/scroll.d.ts +0 -2
- package/dist/internal/sensors/default-collision.d.ts +0 -18
- package/dist/internal/sensors/index.d.ts +0 -2
- package/dist/internal/sensors/sensor.d.ts +0 -68
- package/dist/internal/sensors/steps.d.ts +0 -58
- package/dist/internal/types/auto-scroll.d.ts +0 -20
- package/dist/internal/types/observer.d.ts +0 -11
- package/dist/internal/types/provider.d.ts +0 -31
- package/dist/internal/utils/auto-scroll.d.ts +0 -13
- package/dist/internal/utils/constraints.d.ts +0 -43
- package/dist/internal/utils/disabled.d.ts +0 -9
- package/dist/internal/utils/dom.d.ts +0 -44
- package/dist/internal/utils/drag-activation.d.ts +0 -29
- package/dist/internal/utils/events.d.ts +0 -22
- package/dist/internal/utils/geometry.d.ts +0 -23
- package/dist/internal/utils/groups.d.ts +0 -23
- package/dist/internal/utils/hover.d.ts +0 -15
- package/dist/internal/utils/keyboard.d.ts +0 -5
- package/dist/internal/utils/namespaces.d.ts +0 -18
- package/dist/internal/utils/observer.d.ts +0 -15
- package/dist/internal/utils/placement.d.ts +0 -22
- package/dist/internal/utils/pointer.d.ts +0 -33
- package/dist/internal/utils/provider.d.ts +0 -12
- package/dist/internal/utils/selection.d.ts +0 -36
- package/dist/internal/utils/session.d.ts +0 -5
- package/dist/vite.svg +0 -1
- package/dist/vue-dnd-kit-core.cjs.js +0 -2
- package/dist/vue-dnd-kit-core.es.js +0 -1524
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2425 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
4
|
+
import { ComponentProvideOptions } from 'vue';
|
|
5
|
+
import { ComponentPublicInstance } from 'vue';
|
|
6
|
+
import { ComputedRef } from 'vue';
|
|
7
|
+
import { DefineComponent } from 'vue';
|
|
8
|
+
import { ExtractPropTypes } from 'vue';
|
|
9
|
+
import { PropType } from 'vue';
|
|
10
|
+
import { PublicProps } from 'vue';
|
|
11
|
+
import { Ref } from 'vue';
|
|
12
|
+
import { RendererElement } from 'vue';
|
|
13
|
+
import { RendererNode } from 'vue';
|
|
14
|
+
import { SlotsType } from 'vue';
|
|
15
|
+
import { TransitionProps } from 'vue';
|
|
16
|
+
import { VNode } from 'vue';
|
|
17
|
+
import { WritableComputedRef } from 'vue';
|
|
18
|
+
|
|
19
|
+
/** What a function `accept` rule is asked with. */
|
|
20
|
+
export declare interface AcceptContext {
|
|
21
|
+
/** The drag. */
|
|
22
|
+
active: Active;
|
|
23
|
+
/** Every dragged item. */
|
|
24
|
+
items: DragItem[];
|
|
25
|
+
/** The types of every dragged item, together. */
|
|
26
|
+
types: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** `'all'`: every dragged item must match; `'some'`: at least one (the rest can be rejected in `onBeforeDrop`). */
|
|
30
|
+
export declare type AcceptMode = 'all' | 'some';
|
|
31
|
+
|
|
32
|
+
/** `'*'` or omitted accepts everything. Untyped items fit any string rule (v2 `groups: []` parity). */
|
|
33
|
+
export declare type AcceptRule = '*' | string | string[] | ((context: AcceptContext) => boolean);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* What a press must do before it becomes a drag: travel `distance`, or be held for `delay`,
|
|
37
|
+
* whichever comes first. Nothing set: the drag starts at once.
|
|
38
|
+
*/
|
|
39
|
+
export declare interface ActivationConstraint {
|
|
40
|
+
/** Pixels the pointer must travel before the drag starts. */
|
|
41
|
+
distance?: number;
|
|
42
|
+
/** Milliseconds the pointer must be held before the drag starts. */
|
|
43
|
+
delay?: number;
|
|
44
|
+
/** With `delay`: movement in px that aborts activation, so the page can scroll. */
|
|
45
|
+
tolerance?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Per pointer kind. Defaults: mouse `{ distance: 4 }` (immediate on a handle), pen `{ distance: 4 }`, touch `{ delay: 200, tolerance: 5 }`. */
|
|
49
|
+
export declare type ActivationOptions = Partial<Record<PointerKind, ActivationConstraint>>;
|
|
50
|
+
|
|
51
|
+
/** The running drag: the item it started from, and every item it carries. */
|
|
52
|
+
export declare interface Active<T = unknown> {
|
|
53
|
+
/** Id of the item the drag started from. */
|
|
54
|
+
id: Key;
|
|
55
|
+
/** Every dragged id, the primary one first (multi-drag). */
|
|
56
|
+
ids: Key[];
|
|
57
|
+
/** Every dragged item, the primary one first. */
|
|
58
|
+
items: DragItem<T>[];
|
|
59
|
+
/** The `data` of the item the drag started from. */
|
|
60
|
+
data: unknown;
|
|
61
|
+
/** The `label` of the item the drag started from, what people call it. */
|
|
62
|
+
label?: string;
|
|
63
|
+
/** The normalized `type` of the item the drag started from; empty means it fits any drop target. */
|
|
64
|
+
type: string[];
|
|
65
|
+
/** Element the drag started from. It may get detached (virtual lists, cross-list moves). */
|
|
66
|
+
element: HTMLElement;
|
|
67
|
+
/** Layout rect of `element` at drag start. */
|
|
68
|
+
rect: Rect;
|
|
69
|
+
/** How the drag moves: `'pointer'` follows points, `'keyboard'` moves by items (`SensorActivation.type`). */
|
|
70
|
+
sensor: SensorType;
|
|
71
|
+
/**
|
|
72
|
+
* A drag from outside the page (files, a link, text, or items from another window of the
|
|
73
|
+
* app): what it carries. Its `items` are made for it (`element` is a stand-in).
|
|
74
|
+
*/
|
|
75
|
+
external?: ExternalData;
|
|
76
|
+
/** The browser's own drag (`native`, or one from outside): the browser draws the dragged image, and there is no overlay. */
|
|
77
|
+
native?: boolean;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The timing of an animation. What is left out keeps the default of that animation. */
|
|
81
|
+
export declare interface AnimationOptions {
|
|
82
|
+
/** In ms. Default 200 for layout moves, 250 for the drop; `0` turns the animation off. */
|
|
83
|
+
duration?: number;
|
|
84
|
+
/** A CSS easing (`'ease-out'`, `cubic-bezier(…)`). */
|
|
85
|
+
easing?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A place in a sortable list or tree (its visible rows): `index` counts from 0, out of `length`. */
|
|
89
|
+
export declare interface AnnouncedPosition {
|
|
90
|
+
/** Id of the list or tree. */
|
|
91
|
+
list: Key;
|
|
92
|
+
/** The list's `label`, what people call it. */
|
|
93
|
+
label?: string;
|
|
94
|
+
/** The place, from 0: the built-in texts say `index + 1`. */
|
|
95
|
+
index: number;
|
|
96
|
+
/** How many places the list has. */
|
|
97
|
+
length: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* What an announcement is about, beyond the event: for texts of your own (another
|
|
102
|
+
* language, other words) that say what the built-in ones say.
|
|
103
|
+
*/
|
|
104
|
+
export declare interface AnnouncementContext {
|
|
105
|
+
/**
|
|
106
|
+
* In a sortable list or tree: where the dragged items are. At the start, where they
|
|
107
|
+
* were picked up; while moving, where they would land (none outside the lists); at the
|
|
108
|
+
* end, where they landed, or where they went back to.
|
|
109
|
+
*/
|
|
110
|
+
position?: AnnouncedPosition;
|
|
111
|
+
/** A swap: the item exchanged with the dragged one, and where it is now. */
|
|
112
|
+
partner?: {
|
|
113
|
+
key: Key;
|
|
114
|
+
label?: string;
|
|
115
|
+
position: AnnouncedPosition;
|
|
116
|
+
};
|
|
117
|
+
/** How many items the drag carries. */
|
|
118
|
+
count: number;
|
|
119
|
+
/** The drag copies (`group.pull: 'clone'`, the copy modifier). */
|
|
120
|
+
copy: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Texts for screen readers, per event. Return `undefined` for the built-in text, `''` for
|
|
125
|
+
* none. `context` has the positions the built-in texts of sortable lists speak.
|
|
126
|
+
*
|
|
127
|
+
* A text is spoken by the provider's live region (moves once the drag rests for 500 ms);
|
|
128
|
+
* `undefined` leaves the event to the next source (the texts of integrations such as
|
|
129
|
+
* sortable positions, then the defaults). A move isn't announced for the target found at
|
|
130
|
+
* pickup: nothing moved yet.
|
|
131
|
+
*/
|
|
132
|
+
export declare interface Announcements {
|
|
133
|
+
/** A drag started. */
|
|
134
|
+
onDragStart(event: DnDEvent, context: AnnouncementContext): string | undefined;
|
|
135
|
+
/** The drag moved over another target, or to another place in a list (once it rests for 500 ms). */
|
|
136
|
+
onDragOver(event: DnDEvent, context: AnnouncementContext): string | undefined;
|
|
137
|
+
/** The drop went through, or the drag ended outside every target. */
|
|
138
|
+
onDragEnd(event: DnDEndEvent, context: AnnouncementContext): string | undefined;
|
|
139
|
+
/** The drag was cancelled, or its drop refused. */
|
|
140
|
+
onDragCancel(event: DnDEvent, context: AnnouncementContext): string | undefined;
|
|
141
|
+
/** `onBeforeDrop` answered `'continue'`: the drag goes on. */
|
|
142
|
+
onDragResume(event: DnDEvent, context: AnnouncementContext): string | undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Animates changes of a list's (or tree's) items that no drag made: items added, removed,
|
|
147
|
+
* moved (a sort, a shuffle, a move between lists of one group) or filtered. Off by default
|
|
148
|
+
* (`false`); `true` animates moves, entering and leaving items with the default timing.
|
|
149
|
+
* Drags keep their own animations (`animation`, `dropAnimation`). With
|
|
150
|
+
* `prefers-reduced-motion: reduce` the default animations don't run; functions of yours
|
|
151
|
+
* still do (with `reducedMotion: true`). Only items near the visible area animate
|
|
152
|
+
* (unmounted rows of a virtual list are skipped).
|
|
153
|
+
*/
|
|
154
|
+
export declare type AutoAnimation = boolean | AutoAnimationOptions;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* `animateChanges` with its parts: `duration` and `easing` for all of them, and per kind of
|
|
158
|
+
* change `true`, options (over the shared ones), `false`, or a function of your own.
|
|
159
|
+
*/
|
|
160
|
+
export declare interface AutoAnimationOptions extends AnimationOptions {
|
|
161
|
+
/** Items that changed places (the default FLIP, as `animation`'s; a function replaces it). */
|
|
162
|
+
move?: LayoutAnimation;
|
|
163
|
+
/** Items that appeared. Default: they fade in where they are. */
|
|
164
|
+
enter?: EnterAnimation;
|
|
165
|
+
/** Items that left. Default: a copy of the item fades out where it was, shrinking a little. */
|
|
166
|
+
leave?: LeaveAnimation;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** How containers scroll when a drag nears their edges (the provider's `autoScroll`). */
|
|
170
|
+
export declare interface AutoScrollOptions {
|
|
171
|
+
/** Edge zone as a fraction of the container size. Default 0.2 (clamped to 24–96px). */
|
|
172
|
+
threshold?: number;
|
|
173
|
+
/** Maximum speed in px per 16ms frame. */
|
|
174
|
+
maxSpeed?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Speed in px per frame with the pointer at the container's edge: slower inside the edge
|
|
177
|
+
* zone, faster past the edge, up to `maxSpeed`. Default 10.
|
|
178
|
+
*/
|
|
179
|
+
acceleration?: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* What `onBeforeDrop` decides:
|
|
184
|
+
* - `'accept'` (or `true`, or nothing): the drop goes through;
|
|
185
|
+
* - `'reject'` (or `false`): no drop, the items fly back;
|
|
186
|
+
* - a list of ids: only those items are accepted, the others fly back;
|
|
187
|
+
* - `'continue'`: no drop, and the drag goes on. With a pointer the item follows it again
|
|
188
|
+
* (no button held) and the next release drops it, a click does; a touch takes it again;
|
|
189
|
+
* the keyboard moves it as before. Escape cancels it. The drop asks `onBeforeDrop` again.
|
|
190
|
+
*/
|
|
191
|
+
export declare type BeforeDropResult = boolean | void | Key[] | 'accept' | 'reject' | 'continue';
|
|
192
|
+
|
|
193
|
+
/** Every target, by distance between centers. */
|
|
194
|
+
export declare const closestCenter: CollisionDetection;
|
|
195
|
+
|
|
196
|
+
/** Every target, by summed distance between corners (good for stacked targets such as kanban columns). */
|
|
197
|
+
export declare const closestCorners: CollisionDetection;
|
|
198
|
+
|
|
199
|
+
/** What a collision detection gets, on every move of the drag. */
|
|
200
|
+
export declare interface CollisionArgs {
|
|
201
|
+
/** Pointer in viewport coordinates, after modifiers. */
|
|
202
|
+
pointer: Coordinates;
|
|
203
|
+
/** Rect of the dragged box (the overlay, or the element itself with `overlay: false`) where the drag has moved it. */
|
|
204
|
+
overlayRect: Rect | null;
|
|
205
|
+
/** Every drop target the drag could go to, whether its `accept` rule takes the drag or not. */
|
|
206
|
+
candidates: CollisionCandidate[];
|
|
207
|
+
/** Drop targets under the pointer from hit-testing (respects z-order and shadow roots), best first. */
|
|
208
|
+
hits: Key[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** A drop target a collision detection can pick: enabled, on the page and not fully clipped. */
|
|
212
|
+
export declare interface CollisionCandidate {
|
|
213
|
+
/** Id of the drop target. */
|
|
214
|
+
id: Key;
|
|
215
|
+
/** Visible part of the target: clipped by its scroll containers and the viewport. */
|
|
216
|
+
rect: Rect;
|
|
217
|
+
/** The target's `priority` (default 0): higher wins when targets overlap without nesting. Sortable items beat containers. */
|
|
218
|
+
priority: number;
|
|
219
|
+
/** Nesting level among drop targets: 0 at the top, deeper targets have higher values. */
|
|
220
|
+
depth?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Returns candidate ids, best first. */
|
|
224
|
+
export declare type CollisionDetection = (args: CollisionArgs) => Key[];
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A component instance as a template ref gives it. Only `$el` is read: Vue's full
|
|
228
|
+
* `ComponentPublicInstance` would reject every component that declares typed emits
|
|
229
|
+
* (its `$emit` takes any event name), which is most UI kit components.
|
|
230
|
+
*/
|
|
231
|
+
declare type ComponentRef = Pick<ComponentPublicInstance, '$el'>;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* A point or an offset, in px: a position from the viewport's top-left corner, or an offset
|
|
235
|
+
* from where the drag started (`delta`, `transform`).
|
|
236
|
+
*/
|
|
237
|
+
export declare interface Coordinates {
|
|
238
|
+
/** Horizontal, growing to the right. */
|
|
239
|
+
x: number;
|
|
240
|
+
/** Vertical, growing downward. */
|
|
241
|
+
y: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Defines a sensor (see `Sensor`): it only helps with the types and returns its argument. */
|
|
245
|
+
export declare const defineSensor: (sensor: Sensor) => Sensor;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* A provider as `useDnDContext()` returns it, to hand to `provideDnDContext()`: another
|
|
249
|
+
* Vue app (e.g. one mounted in a shadow root) then works with the same provider. Opaque:
|
|
250
|
+
* it has no public members, so it never changes with the library's internals.
|
|
251
|
+
*/
|
|
252
|
+
export declare interface DnDContext {
|
|
253
|
+
readonly [dndContext]: true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
declare const dndContext: unique symbol;
|
|
257
|
+
|
|
258
|
+
/** What `onDragEnd` (and the target's `onDrop`) gets: the event of the drop, and how it went. */
|
|
259
|
+
export declare interface DnDEndEvent<T = unknown> extends DnDEvent<T> {
|
|
260
|
+
/** False when the drag ended outside every drop target. */
|
|
261
|
+
dropped: boolean;
|
|
262
|
+
/** Ids accepted by `onBeforeDrop` (all dragged ids unless a subset was returned). */
|
|
263
|
+
accepted: Key[];
|
|
264
|
+
/** The other dragged ids: `onBeforeDrop` left them out, and they fly back. Empty when it took them all. */
|
|
265
|
+
rejected: Key[];
|
|
266
|
+
/**
|
|
267
|
+
* A drag out of the page (`native`) dropped somewhere else: what that place did with it.
|
|
268
|
+
* `'move'` takes the items out of their sortable list here; `'copy'` and `'link'` leave them.
|
|
269
|
+
*/
|
|
270
|
+
droppedOutside?: 'move' | 'copy' | 'link';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** What drag events carry: monitors, the provider's events and the hooks of drop targets get it. */
|
|
274
|
+
export declare interface DnDEvent<T = unknown> {
|
|
275
|
+
/** The drag. */
|
|
276
|
+
active: Active<T>;
|
|
277
|
+
/** The drop target under the drag; `null` over nothing. */
|
|
278
|
+
over: Over | null;
|
|
279
|
+
/** Pointer in viewport coordinates, after modifiers. */
|
|
280
|
+
pointer: Coordinates;
|
|
281
|
+
/** Offset from the drag start, after modifiers. */
|
|
282
|
+
delta: Coordinates;
|
|
283
|
+
/**
|
|
284
|
+
* Where the dragged box's top-left corner is in `over`, from its padding edge and with
|
|
285
|
+
* its scroll: the `left`/`top` that put an absolutely positioned item where it was
|
|
286
|
+
* dropped (a note on a board). `null` over nothing. Of the overlay box, or of the
|
|
287
|
+
* element itself with `overlay: false`.
|
|
288
|
+
*/
|
|
289
|
+
readonly position: Coordinates | null;
|
|
290
|
+
/**
|
|
291
|
+
* What a drop would do: `'move'`, `'copy'` (a list's `pull: 'clone'`, or the copy
|
|
292
|
+
* modifier held over items whose list can `clone`), `'swap'` or `'insert'`. A plain drop
|
|
293
|
+
* target reads it to copy instead of moving.
|
|
294
|
+
*/
|
|
295
|
+
mode: DragMode;
|
|
296
|
+
/** Present when the dragged items come from a sortable list. */
|
|
297
|
+
source?: DragSource;
|
|
298
|
+
/** A drag from outside the page: what it carries (`active.external`). Its data comes at the drop. */
|
|
299
|
+
external?: ExternalData;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Hooks for every drag under the provider (`useDnDMonitor`). */
|
|
303
|
+
export declare interface DnDMonitor {
|
|
304
|
+
/** A drag started, after its activation. */
|
|
305
|
+
onDragStart?(event: DnDEvent): void;
|
|
306
|
+
/** The drag moved (once per frame at most). */
|
|
307
|
+
onDragMove?(event: DnDEvent): void;
|
|
308
|
+
/** The target under the drag changed. */
|
|
309
|
+
onDragOver?(event: DnDEvent): void;
|
|
310
|
+
/** Runs before the drop is committed (see `BeforeDropResult`): `'reject'` refuses it, ids accept a subset. */
|
|
311
|
+
onBeforeDrop?(event: DnDEvent): MaybePromise<BeforeDropResult>;
|
|
312
|
+
/** A notification once the drop is done: sortable lists have run their `onDrop` and written it. */
|
|
313
|
+
onDragEnd?(event: DnDEndEvent): void;
|
|
314
|
+
/** The drag was cancelled, or its drop refused: the items fly back. */
|
|
315
|
+
onDragCancel?(event: DnDEvent): void;
|
|
316
|
+
/** `onBeforeDrop` answered `'continue'`: there was no drop, and the drag goes on. */
|
|
317
|
+
onDragResume?(event: DnDEvent): void;
|
|
318
|
+
/**
|
|
319
|
+
* The overlay of an ended drag has landed: after its drop animation (or the flight back
|
|
320
|
+
* of a cancel), with the event `onDragEnd` (a `DnDEndEvent`) or `onDragCancel` got.
|
|
321
|
+
* The next drag may have started meanwhile: drags don't wait for landings.
|
|
322
|
+
*/
|
|
323
|
+
onDragSettle?(event: DnDEvent | DnDEndEvent): void;
|
|
324
|
+
/** Keyboard drags: next pointer position for an arrow key (e.g. the next sortable slot). */
|
|
325
|
+
getKeyboardCoordinates?(event: KeyboardEvent, context: KeyboardMoveContext): MaybePromise<Coordinates | undefined>;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Owns the drags of everything rendered inside it: input, the overlay, the selection,
|
|
330
|
+
* auto-scroll and the screen reader announcements (see `DnDProviderProps`).
|
|
331
|
+
*/
|
|
332
|
+
export declare const DnDProvider: DefineComponent<ExtractPropTypes< {
|
|
333
|
+
collision: PropType<CollisionDetection>;
|
|
334
|
+
modifiers: PropType<Modifier[]>;
|
|
335
|
+
animation: {
|
|
336
|
+
type: PropType<LayoutAnimation>;
|
|
337
|
+
default: undefined;
|
|
338
|
+
};
|
|
339
|
+
dropAnimation: {
|
|
340
|
+
type: PropType<DropAnimation>;
|
|
341
|
+
default: undefined;
|
|
342
|
+
};
|
|
343
|
+
animateChanges: {
|
|
344
|
+
type: PropType<AutoAnimation>;
|
|
345
|
+
default: undefined;
|
|
346
|
+
};
|
|
347
|
+
autoScroll: {
|
|
348
|
+
type: PropType<boolean | AutoScrollOptions>;
|
|
349
|
+
default: boolean;
|
|
350
|
+
};
|
|
351
|
+
activation: PropType<ActivationOptions>;
|
|
352
|
+
keyboard: {
|
|
353
|
+
type: PropType<KeyboardOptions | false>;
|
|
354
|
+
default: undefined;
|
|
355
|
+
};
|
|
356
|
+
sensors: PropType<Sensor[]>;
|
|
357
|
+
haptics: {
|
|
358
|
+
type: PropType<boolean | HapticsOptions>;
|
|
359
|
+
default: undefined;
|
|
360
|
+
};
|
|
361
|
+
copyModifier: {
|
|
362
|
+
type: PropType<string | null>;
|
|
363
|
+
default: string;
|
|
364
|
+
};
|
|
365
|
+
overlayTo: {
|
|
366
|
+
type: PropType<string | HTMLElement>;
|
|
367
|
+
default: string;
|
|
368
|
+
};
|
|
369
|
+
overlayFit: {
|
|
370
|
+
type: PropType<"slot" | "source">;
|
|
371
|
+
default: string;
|
|
372
|
+
};
|
|
373
|
+
overlayPreviews: {
|
|
374
|
+
type: PropType<number | "all">;
|
|
375
|
+
default: number;
|
|
376
|
+
};
|
|
377
|
+
overlayTransition: {
|
|
378
|
+
type: PropType<boolean | TransitionProps>;
|
|
379
|
+
default: boolean;
|
|
380
|
+
};
|
|
381
|
+
overlayClass: {
|
|
382
|
+
type: PropType<DnDProviderProps["overlayClass"]>;
|
|
383
|
+
default: undefined;
|
|
384
|
+
};
|
|
385
|
+
announcements: {
|
|
386
|
+
type: PropType<Partial<Announcements> | false>;
|
|
387
|
+
default: undefined;
|
|
388
|
+
};
|
|
389
|
+
screenReaderInstructions: StringConstructor;
|
|
390
|
+
defaultStyles: {
|
|
391
|
+
type: BooleanConstructor;
|
|
392
|
+
default: boolean;
|
|
393
|
+
};
|
|
394
|
+
}>, () => (VNode<RendererNode, RendererElement, {
|
|
395
|
+
[key: string]: any;
|
|
396
|
+
}> | VNode<RendererNode, RendererElement, {
|
|
397
|
+
[key: string]: any;
|
|
398
|
+
}>[] | null | undefined)[], {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
399
|
+
dragStart: (_event: DnDEvent) => true;
|
|
400
|
+
dragMove: (_event: DnDEvent) => true;
|
|
401
|
+
dragOver: (_event: DnDEvent) => true;
|
|
402
|
+
dragEnd: (_event: DnDEndEvent) => true;
|
|
403
|
+
dragCancel: (_event: DnDEvent) => true;
|
|
404
|
+
dragResume: (_event: DnDEvent) => true;
|
|
405
|
+
dragSettle: (_event: DnDEvent | DnDEndEvent) => true;
|
|
406
|
+
}, string, PublicProps, Readonly<ExtractPropTypes< {
|
|
407
|
+
collision: PropType<CollisionDetection>;
|
|
408
|
+
modifiers: PropType<Modifier[]>;
|
|
409
|
+
animation: {
|
|
410
|
+
type: PropType<LayoutAnimation>;
|
|
411
|
+
default: undefined;
|
|
412
|
+
};
|
|
413
|
+
dropAnimation: {
|
|
414
|
+
type: PropType<DropAnimation>;
|
|
415
|
+
default: undefined;
|
|
416
|
+
};
|
|
417
|
+
animateChanges: {
|
|
418
|
+
type: PropType<AutoAnimation>;
|
|
419
|
+
default: undefined;
|
|
420
|
+
};
|
|
421
|
+
autoScroll: {
|
|
422
|
+
type: PropType<boolean | AutoScrollOptions>;
|
|
423
|
+
default: boolean;
|
|
424
|
+
};
|
|
425
|
+
activation: PropType<ActivationOptions>;
|
|
426
|
+
keyboard: {
|
|
427
|
+
type: PropType<KeyboardOptions | false>;
|
|
428
|
+
default: undefined;
|
|
429
|
+
};
|
|
430
|
+
sensors: PropType<Sensor[]>;
|
|
431
|
+
haptics: {
|
|
432
|
+
type: PropType<boolean | HapticsOptions>;
|
|
433
|
+
default: undefined;
|
|
434
|
+
};
|
|
435
|
+
copyModifier: {
|
|
436
|
+
type: PropType<string | null>;
|
|
437
|
+
default: string;
|
|
438
|
+
};
|
|
439
|
+
overlayTo: {
|
|
440
|
+
type: PropType<string | HTMLElement>;
|
|
441
|
+
default: string;
|
|
442
|
+
};
|
|
443
|
+
overlayFit: {
|
|
444
|
+
type: PropType<"slot" | "source">;
|
|
445
|
+
default: string;
|
|
446
|
+
};
|
|
447
|
+
overlayPreviews: {
|
|
448
|
+
type: PropType<number | "all">;
|
|
449
|
+
default: number;
|
|
450
|
+
};
|
|
451
|
+
overlayTransition: {
|
|
452
|
+
type: PropType<boolean | TransitionProps>;
|
|
453
|
+
default: boolean;
|
|
454
|
+
};
|
|
455
|
+
overlayClass: {
|
|
456
|
+
type: PropType<DnDProviderProps["overlayClass"]>;
|
|
457
|
+
default: undefined;
|
|
458
|
+
};
|
|
459
|
+
announcements: {
|
|
460
|
+
type: PropType<Partial<Announcements> | false>;
|
|
461
|
+
default: undefined;
|
|
462
|
+
};
|
|
463
|
+
screenReaderInstructions: StringConstructor;
|
|
464
|
+
defaultStyles: {
|
|
465
|
+
type: BooleanConstructor;
|
|
466
|
+
default: boolean;
|
|
467
|
+
};
|
|
468
|
+
}>> & Readonly<{
|
|
469
|
+
onDragStart?: ((_event: DnDEvent<unknown>) => any) | undefined;
|
|
470
|
+
onDragMove?: ((_event: DnDEvent<unknown>) => any) | undefined;
|
|
471
|
+
onDragOver?: ((_event: DnDEvent<unknown>) => any) | undefined;
|
|
472
|
+
onDragEnd?: ((_event: DnDEndEvent<unknown>) => any) | undefined;
|
|
473
|
+
onDragCancel?: ((_event: DnDEvent<unknown>) => any) | undefined;
|
|
474
|
+
onDragResume?: ((_event: DnDEvent<unknown>) => any) | undefined;
|
|
475
|
+
onDragSettle?: ((_event: DnDEvent<unknown> | DnDEndEvent<unknown>) => any) | undefined;
|
|
476
|
+
}>, {
|
|
477
|
+
keyboard: false | KeyboardOptions;
|
|
478
|
+
animation: LayoutAnimation;
|
|
479
|
+
dropAnimation: DropAnimation;
|
|
480
|
+
animateChanges: AutoAnimation;
|
|
481
|
+
autoScroll: boolean | AutoScrollOptions;
|
|
482
|
+
haptics: boolean | HapticsOptions;
|
|
483
|
+
copyModifier: string | null;
|
|
484
|
+
overlayTo: string | HTMLElement;
|
|
485
|
+
overlayFit: "slot" | "source";
|
|
486
|
+
overlayPreviews: number | "all";
|
|
487
|
+
overlayTransition: boolean | TransitionProps;
|
|
488
|
+
overlayClass: string | Record<string, boolean> | (string | Record<string, boolean>)[] | undefined;
|
|
489
|
+
announcements: false | Partial<Announcements>;
|
|
490
|
+
defaultStyles: boolean;
|
|
491
|
+
}, SlotsType<{
|
|
492
|
+
default?: () => VNode[];
|
|
493
|
+
/**
|
|
494
|
+
* Overlay for drags without an `overlay` component of their own (item, list or
|
|
495
|
+
* tree option). Rendering nothing (`v-if`) falls back to the clone.
|
|
496
|
+
*/
|
|
497
|
+
overlay?: (props: OverlaySlotProps) => VNode[];
|
|
498
|
+
}>, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Props of `DnDProvider`. Most are read when the provider needs them: change one, and the
|
|
502
|
+
* next drag uses it.
|
|
503
|
+
*/
|
|
504
|
+
export declare interface DnDProviderProps {
|
|
505
|
+
/** How the target under the drag is chosen. Default `pointerFirst`; another built-in (`closestCorners`) or your own. */
|
|
506
|
+
collision?: CollisionDetection;
|
|
507
|
+
/** Modifiers for every drag, applied first: those of drag areas, draggables and lists come after. */
|
|
508
|
+
modifiers?: Modifier[];
|
|
509
|
+
/** Default FLIP animation for sortable lists. */
|
|
510
|
+
animation?: LayoutAnimation;
|
|
511
|
+
/**
|
|
512
|
+
* How the overlay lands on drop and flies back on cancel, when nothing closer sets one:
|
|
513
|
+
* the drop target's `overDropAnimation` comes first, then the dragged item's own (or its
|
|
514
|
+
* list's), then this one.
|
|
515
|
+
*/
|
|
516
|
+
dropAnimation?: DropAnimation;
|
|
517
|
+
/** Default `animateChanges` of sortable lists and trees: changes of their items that no drag made. Off by default. */
|
|
518
|
+
animateChanges?: AutoAnimation;
|
|
519
|
+
/**
|
|
520
|
+
* Scrolls containers and the page when a drag nears their edges. Default `true`; options
|
|
521
|
+
* tune it, `false` turns it off. Lists, trees and drag areas can override it.
|
|
522
|
+
*/
|
|
523
|
+
autoScroll?: boolean | AutoScrollOptions;
|
|
524
|
+
/**
|
|
525
|
+
* What a press must do before it becomes a drag, per pointer kind (see
|
|
526
|
+
* `ActivationOptions` for the defaults). Drag areas, lists, trees, items and draggables
|
|
527
|
+
* can override it.
|
|
528
|
+
*/
|
|
529
|
+
activation?: ActivationOptions;
|
|
530
|
+
/** Keyboard drags: their keys and step. `false` turns them off; Escape still cancels any drag. */
|
|
531
|
+
keyboard?: KeyboardOptions | false;
|
|
532
|
+
/**
|
|
533
|
+
* What turns input into drags. Default `[pointerSensor, keyboardSensor]`: leave one out,
|
|
534
|
+
* wrap or replace it, or add your own (`defineSensor`). The keyboard sensor also cancels
|
|
535
|
+
* any drag with Escape; `keyboard: false` turns its drags off but keeps that. The list
|
|
536
|
+
* may change at any time: sensors that leave it stop, cancelling their drag.
|
|
537
|
+
*/
|
|
538
|
+
sensors?: Sensor[];
|
|
539
|
+
/**
|
|
540
|
+
* Vibration for touch drags. Default: a short one when a drag starts after the long
|
|
541
|
+
* press; an object adds others (`enter`, `drop`, `refuse`); `false` turns them all off.
|
|
542
|
+
*/
|
|
543
|
+
haptics?: boolean | HapticsOptions;
|
|
544
|
+
/** Key (KeyboardEvent.key) that turns a move into a copy. Default `'Alt'`; `null` disables. */
|
|
545
|
+
copyModifier?: string | null;
|
|
546
|
+
/**
|
|
547
|
+
* Where the overlay renders: a selector or an element. Default `'body'`. A modal
|
|
548
|
+
* `<dialog>` sits above the rest of the page: drags inside one need it there.
|
|
549
|
+
*/
|
|
550
|
+
overlayTo?: string | HTMLElement;
|
|
551
|
+
/**
|
|
552
|
+
* Overlay size while dragging. `'slot'` (default): it follows the slot the item will
|
|
553
|
+
* land in, so over another list it takes the size of that list's items, and the drop
|
|
554
|
+
* needs no resize. It resizes around the pointer, which stays at the same fraction of
|
|
555
|
+
* the box. `'source'`: it keeps the dragged element's size. The default overlay
|
|
556
|
+
* content re-lays out at the new size; it is never scaled.
|
|
557
|
+
*/
|
|
558
|
+
overlayFit?: 'slot' | 'source';
|
|
559
|
+
/**
|
|
560
|
+
* Multi-drag: how many dragged items get a clone at pickup, the grabbed one and the
|
|
561
|
+
* others next to it in drop order. Default 5; `'all'` clones every one that is rendered.
|
|
562
|
+
* The default overlay shows the clones and counts the rest (`+N`); in a layout of your
|
|
563
|
+
* own, `DragPreview` renders its slot for an item without one. Every clone flies: back to
|
|
564
|
+
* its item on a cancel, to its slot on a drop, into the zone a drop goes into, one after
|
|
565
|
+
* another. The clones are taken together, one layout per snapshot pass for all, but each
|
|
566
|
+
* costs reading its styles: mind long items on slow phones.
|
|
567
|
+
*/
|
|
568
|
+
overlayPreviews?: number | 'all';
|
|
569
|
+
/**
|
|
570
|
+
* How the overlay changes from one component to another during a drag (a drop target's
|
|
571
|
+
* `overOverlay` takes over, an `overlay` ref is switched): `true` (default) crossfades them
|
|
572
|
+
* in 150 ms, `false` swaps them at once, and an object is the props of a Vue
|
|
573
|
+
* `<Transition>` around the content's root (`name`, `mode`, JS hooks for GSAP or
|
|
574
|
+
* motion). Without `mode: 'out-in'` both show at once: give the leaving one
|
|
575
|
+
* `position: absolute` (`.<name>-leave-active`) so they stack in the box.
|
|
576
|
+
*/
|
|
577
|
+
overlayTransition?: boolean | TransitionProps;
|
|
578
|
+
/**
|
|
579
|
+
* Classes for the overlay's content (`[data-dnd-overlay-content]`), the element that
|
|
580
|
+
* fills the overlay box: the one to animate as a whole while the library moves and
|
|
581
|
+
* sizes the box. A transition on it runs from `@starting-style` as the drag picks up,
|
|
582
|
+
* and back as it lands (`[data-dnd-overlay='dropping']`): the drop waits for it. Plain
|
|
583
|
+
* CSS reaches it outside `<style scoped>` (or with `:global(...)`), Tailwind with
|
|
584
|
+
* `starting:` and `in-data-[dnd-overlay=dragging]:`.
|
|
585
|
+
*/
|
|
586
|
+
overlayClass?: string | Record<string, boolean> | Array<string | Record<string, boolean>>;
|
|
587
|
+
/** Own texts for some events (see `Announcements`); `false` keeps the live region silent. */
|
|
588
|
+
announcements?: Partial<Announcements> | false;
|
|
589
|
+
/**
|
|
590
|
+
* How to drag with the keyboard, read out by screen readers for every draggable (its
|
|
591
|
+
* `aria-describedby`). Default: English instructions for Space, Enter, the arrows and Escape.
|
|
592
|
+
*/
|
|
593
|
+
screenReaderInstructions?: string;
|
|
594
|
+
/**
|
|
595
|
+
* Inject the default looks: zero-specificity, layered CSS that dims placeholders and the
|
|
596
|
+
* items a multi-drag leaves in place (`opacity: 0.4`). Default `true`; `false` leaves
|
|
597
|
+
* the looks to you. What drags need is injected either way: no text selection and no
|
|
598
|
+
* scroll anchoring while dragging (virtual lists rely on it), the drag cursor
|
|
599
|
+
* (`--dnd-cursor`), and no link callout on a long press on iOS.
|
|
600
|
+
*/
|
|
601
|
+
defaultStyles?: boolean;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* The selected draggables, by id: a drag of one of them carries them all (multi-drag). Kept
|
|
606
|
+
* by id, a selection survives unmounts (virtual lists).
|
|
607
|
+
*/
|
|
608
|
+
export declare interface DnDSelection {
|
|
609
|
+
/** The selected ids, reactive. */
|
|
610
|
+
readonly ids: ReadonlySet<Key>;
|
|
611
|
+
/** Whether `id` is selected. */
|
|
612
|
+
has(id: Key): boolean;
|
|
613
|
+
/** Selects these ids. */
|
|
614
|
+
add(...ids: Key[]): void;
|
|
615
|
+
/** Deselects these ids. */
|
|
616
|
+
delete(...ids: Key[]): void;
|
|
617
|
+
/** Selects `id` or deselects it; `force: true` selects it, `false` deselects it. */
|
|
618
|
+
toggle(id: Key, force?: boolean): void;
|
|
619
|
+
/** Selects these ids and no others. */
|
|
620
|
+
set(ids: Iterable<Key>): void;
|
|
621
|
+
/** Deselects every id. */
|
|
622
|
+
clear(): void;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* The drag state ends when the drop is decided: `active`, `over` and `pointer` read
|
|
627
|
+
* `null` (and droppables stop accepting) while the overlay still animates into place.
|
|
628
|
+
* Derived UI never mixes the old drag with the new data. While an async `onBeforeDrop`
|
|
629
|
+
* decides, the state is kept as it was at release, but the page is out of drag mode: its
|
|
630
|
+
* own cursor and text selection are back (a confirmation dialog works normally), and the
|
|
631
|
+
* overlay waits where it was dropped.
|
|
632
|
+
*
|
|
633
|
+
* `status` is `'dragging'` while a drag runs, else `'dropping'` while a drop is decided or
|
|
634
|
+
* an overlay still lands, else `'idle'` (`'activating'` and `'selecting'` aside). A new drag
|
|
635
|
+
* doesn't wait for the landings: it starts at once, and they finish around it.
|
|
636
|
+
*/
|
|
637
|
+
export declare interface DnDState {
|
|
638
|
+
/** What the provider is doing (see `DnDStatus`). */
|
|
639
|
+
status: Readonly<Ref<DnDStatus>>;
|
|
640
|
+
/** The running drag; `null` without one, and as soon as its drop is decided. */
|
|
641
|
+
active: Readonly<Ref<Active | null>>;
|
|
642
|
+
/** The drop target under the drag; `null` over nothing. */
|
|
643
|
+
over: Readonly<Ref<Over | null>>;
|
|
644
|
+
/** Pointer in viewport coordinates, after modifiers; `null` without a drag. */
|
|
645
|
+
pointer: Readonly<Ref<Coordinates | null>>;
|
|
646
|
+
/**
|
|
647
|
+
* Where the dragged box's top-left corner is in `over`, live: `DnDEvent.position` on every
|
|
648
|
+
* move. `null` over nothing. An overlay component reads it to show where it would land
|
|
649
|
+
* (a time on a calendar).
|
|
650
|
+
*/
|
|
651
|
+
position: Readonly<Ref<Coordinates | null>>;
|
|
652
|
+
/**
|
|
653
|
+
* `progress`: how far a press has come toward its activation constraint, from 0 to 1,
|
|
654
|
+
* while `status` is `'activating'`: e.g. a ring that fills during a long press.
|
|
655
|
+
*/
|
|
656
|
+
activation: {
|
|
657
|
+
progress: Readonly<Ref<number>>;
|
|
658
|
+
};
|
|
659
|
+
/** Auto-scroll is moving a container. */
|
|
660
|
+
isAutoScrolling: Readonly<Ref<boolean>>;
|
|
661
|
+
/** The selected draggables (see `DnDSelection`). */
|
|
662
|
+
selection: DnDSelection;
|
|
663
|
+
/** Cancels the drag (it flies back), or the pending activation. */
|
|
664
|
+
cancel(): void;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* What the provider is doing:
|
|
669
|
+
* - `'idle'`: nothing;
|
|
670
|
+
* - `'activating'`: a press waits for its activation constraint (a distance, a long press);
|
|
671
|
+
* - `'dragging'`: a drag runs;
|
|
672
|
+
* - `'dropping'`: a drop is decided (an async `onBeforeDrop`), or an overlay still lands;
|
|
673
|
+
* - `'selecting'`: a selection area draws its band.
|
|
674
|
+
*/
|
|
675
|
+
export declare type DnDStatus = 'idle' | 'activating' | 'dragging' | 'dropping' | 'selecting';
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Options of `makeDragArea`: rules for the drags that start inside the area's element
|
|
679
|
+
* (draggables and sortable items alike), so one provider can serve the whole app while
|
|
680
|
+
* parts of the page drag their own way. The closest area wins when areas are nested.
|
|
681
|
+
*
|
|
682
|
+
* Every option takes a value, a ref or a getter and is read when it is needed: when a
|
|
683
|
+
* press starts (`activation`, `disabled`) or when the drag starts.
|
|
684
|
+
*/
|
|
685
|
+
export declare interface DragAreaOptions {
|
|
686
|
+
/**
|
|
687
|
+
* Locks the drags to one axis, after the modifiers. A draggable's own `axis` (or its
|
|
688
|
+
* list's) wins.
|
|
689
|
+
*/
|
|
690
|
+
axis?: MaybeReadonlyRefOrGetter<'x' | 'y' | undefined>;
|
|
691
|
+
/**
|
|
692
|
+
* Modifiers for the drags, after the provider's and before the draggable's own (or its
|
|
693
|
+
* list's): e.g. `[snapToGrid(20)]` for a board.
|
|
694
|
+
*/
|
|
695
|
+
modifiers?: MaybeReadonlyRefOrGetter<Modifier[] | undefined>;
|
|
696
|
+
/** `true`: the drags stay inside the area's element (after the modifiers, before the axis lock). */
|
|
697
|
+
restrictToArea?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
698
|
+
/**
|
|
699
|
+
* Overrides the provider's `autoScroll` for the area's scroll container: the element
|
|
700
|
+
* itself, or its closest scrollable ancestor. `false` turns it off there. Unlike the other
|
|
701
|
+
* options it applies to every drag that scrolls the container, wherever it started.
|
|
702
|
+
*/
|
|
703
|
+
autoScroll?: MaybeReadonlyRefOrGetter<boolean | AutoScrollOptions | undefined>;
|
|
704
|
+
/**
|
|
705
|
+
* Activation of the drags per pointer kind, between the draggable's own (which wins)
|
|
706
|
+
* and the provider's: e.g. a longer touch press in a scrolling feed.
|
|
707
|
+
*/
|
|
708
|
+
activation?: MaybeReadonlyRefOrGetter<ActivationOptions | undefined>;
|
|
709
|
+
/**
|
|
710
|
+
* `true`: no drag starts in the area, nor in the areas inside it (unlike the other
|
|
711
|
+
* options, which come from the closest area). Its draggables report `aria-disabled`.
|
|
712
|
+
*/
|
|
713
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/** What `makeDragArea` returns. */
|
|
717
|
+
export declare interface DragAreaReturn {
|
|
718
|
+
/** A drag that started in this area is running (until its drop is decided). */
|
|
719
|
+
isDragging: ComputedRef<boolean>;
|
|
720
|
+
/** Auto-scroll is moving the area's scroll container (the element, or its closest scrollable ancestor). */
|
|
721
|
+
isAutoScrolling: ComputedRef<boolean>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Options of `makeDraggable`. Every option but `canDrag` takes a value, a ref or a
|
|
726
|
+
* getter (`overlay`, `dropAnimation`: a value or a ref) and is read when it is needed,
|
|
727
|
+
* so a change applies to the next drag at the latest.
|
|
728
|
+
*/
|
|
729
|
+
export declare interface DraggableOptions<TData = unknown> {
|
|
730
|
+
/**
|
|
731
|
+
* Stable id. Pass a getter in virtual lists, where elements are recycled. Default:
|
|
732
|
+
* `useId()`, stable between server and client render but new for every component
|
|
733
|
+
* instance.
|
|
734
|
+
*/
|
|
735
|
+
id?: MaybeReadonlyRefOrGetter<Key>;
|
|
736
|
+
/** Anything the drag should carry: events and drop targets read it as `active.data`. */
|
|
737
|
+
data?: MaybeReadonlyRefOrGetter<TData>;
|
|
738
|
+
/**
|
|
739
|
+
* What people call it: screen reader texts say it instead of the id (`Picked up Tomato`).
|
|
740
|
+
* Events carry it as `active.label` and in `items`.
|
|
741
|
+
*/
|
|
742
|
+
label?: MaybeReadonlyRefOrGetter<string | undefined>;
|
|
743
|
+
/** Its type or types, matched by the `accept` rules of drop targets. Without one it fits any target. */
|
|
744
|
+
type?: MaybeReadonlyRefOrGetter<string | string[] | undefined>;
|
|
745
|
+
/** `true`: it can't be dragged (it reports `aria-disabled`). */
|
|
746
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
747
|
+
/** Element or selector inside the draggable that starts the drag (and gets the attributes). */
|
|
748
|
+
handle?: MaybeReadonlyRefOrGetter<MaybeElement | string>;
|
|
749
|
+
/** Overrides the provider's `activation`. Read when a press starts. */
|
|
750
|
+
activation?: MaybeReadonlyRefOrGetter<ActivationOptions | undefined>;
|
|
751
|
+
/** Extra gate, e.g. drag only while a key is held. */
|
|
752
|
+
canDrag?: (event: PointerEvent | KeyboardEvent) => boolean;
|
|
753
|
+
/**
|
|
754
|
+
* `true` (default): an overlay follows the pointer, rendered by the provider's
|
|
755
|
+
* `#overlay` slot or as a clone of the element. A component: the overlay renders it
|
|
756
|
+
* with `OverlayProps`, before the slot. `false`: no overlay, the element itself moves
|
|
757
|
+
* via the returned `transform`. A value or a ref (a function is a functional
|
|
758
|
+
* component, so `(props) => <Card {...props} />` works). Whether there is an overlay
|
|
759
|
+
* is decided when the drag starts; a ref switched mid-drag swaps the component at once
|
|
760
|
+
* (see the provider's `overlayTransition`). A drop target's `overOverlay` wins while
|
|
761
|
+
* the drag is over it. The clone leaves out the press effects of UI kits (ripples) and
|
|
762
|
+
* any element inside marked `data-dnd-no-clone`.
|
|
763
|
+
*/
|
|
764
|
+
overlay?: MaybeReadonlyRef<boolean | Component | undefined>;
|
|
765
|
+
/**
|
|
766
|
+
* How the overlay lands when a drag of this element ends, instead of the provider's
|
|
767
|
+
* `dropAnimation`; a drop target's `overDropAnimation` wins. A value or a ref (a function
|
|
768
|
+
* is the animation), read at the drop.
|
|
769
|
+
*/
|
|
770
|
+
dropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
771
|
+
/**
|
|
772
|
+
* Modifiers for drags that start here, applied after the provider's `modifiers`: e.g.
|
|
773
|
+
* `[restrictToVerticalAxis]` for one element on a page where other drags move freely.
|
|
774
|
+
* Read when the drag starts.
|
|
775
|
+
*/
|
|
776
|
+
modifiers?: MaybeReadonlyRefOrGetter<Modifier[] | undefined>;
|
|
777
|
+
/**
|
|
778
|
+
* Locks drags that start here to one axis: `'x'` moves only horizontally, `'y'` only
|
|
779
|
+
* vertically. The lock comes after `modifiers` (`restrictToHorizontalAxis` /
|
|
780
|
+
* `restrictToVerticalAxis` last), so it holds whatever they do. Read when the drag starts.
|
|
781
|
+
*/
|
|
782
|
+
axis?: MaybeReadonlyRefOrGetter<'x' | 'y' | undefined>;
|
|
783
|
+
/**
|
|
784
|
+
* Arrow keys in free drags: move by pixels (default) or jump between accepting drop
|
|
785
|
+
* targets. Read on every arrow press.
|
|
786
|
+
*/
|
|
787
|
+
keyboardMode?: MaybeReadonlyRefOrGetter<'pixels' | 'droppables' | undefined>;
|
|
788
|
+
/**
|
|
789
|
+
* Set role/tabindex/aria-* attributes (default `true`), never overriding the user's
|
|
790
|
+
* own. The provider's instructions id joins an existing `aria-describedby` as one more
|
|
791
|
+
* token (a UI kit tooltip on the same element keeps its own), and only that token is
|
|
792
|
+
* ever removed. Live: turning it off removes what the library set.
|
|
793
|
+
*/
|
|
794
|
+
attributes?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
795
|
+
/**
|
|
796
|
+
* A mouse drag of it is the browser's own drag, which can leave the page: onto the
|
|
797
|
+
* desktop, into another app or tab, into another window of the app. On the page it works
|
|
798
|
+
* as usual (targets, lists that make room), but the browser draws the dragged image
|
|
799
|
+
* instead of the overlay. Touch and keyboard drags stay the library's. `true` carries
|
|
800
|
+
* the `label` as text. Read when a press starts. `canDrag` is asked at the press; the
|
|
801
|
+
* browser decides how far a mouse moves before its drag starts (`activation` doesn't
|
|
802
|
+
* apply to it).
|
|
803
|
+
*/
|
|
804
|
+
native?: MaybeReadonlyRefOrGetter<boolean | NativeDragOptions | undefined>;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/** What `makeDraggable` returns. */
|
|
808
|
+
export declare interface DraggableReturn {
|
|
809
|
+
/** The draggable's id: the `id` option, or the one made for it. */
|
|
810
|
+
id: ComputedRef<Key>;
|
|
811
|
+
/** It is being dragged (also as another item of a multi-drag), or its overlay is still landing. */
|
|
812
|
+
isDragging: ComputedRef<boolean>;
|
|
813
|
+
/**
|
|
814
|
+
* Offset to apply when `overlay: false`: the drag's, less how far the content the
|
|
815
|
+
* element is in has moved since the start (the page or a container scrolled), so the
|
|
816
|
+
* element stays under the pointer.
|
|
817
|
+
*/
|
|
818
|
+
transform: ComputedRef<Coordinates | null>;
|
|
819
|
+
/** It is in the provider's selection: a drag of one selected item carries them all. Set it to select or deselect. */
|
|
820
|
+
selected: WritableComputedRef<boolean>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** One dragged item: the one the drag started from, or another one of a multi-drag. */
|
|
824
|
+
export declare interface DragItem<T = unknown> {
|
|
825
|
+
/** Id of its draggable (the key of a sortable item). */
|
|
826
|
+
id: Key;
|
|
827
|
+
/** Item object when the drag comes from a sortable list. */
|
|
828
|
+
item?: T;
|
|
829
|
+
/** Its `data` option. */
|
|
830
|
+
data: unknown;
|
|
831
|
+
/** Its `label`, what people call it. */
|
|
832
|
+
label?: string;
|
|
833
|
+
/** Normalized `type` of the draggable; empty means it fits any drop target. */
|
|
834
|
+
type: string[];
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* What a drop does: `'move'`, `'copy'` (the items stay, copies of them go in), `'swap'`
|
|
839
|
+
* (`behavior: 'swap'`: two items exchange places) or `'insert'` (a plain draggable goes into
|
|
840
|
+
* a list as the item its `createItem` made).
|
|
841
|
+
*/
|
|
842
|
+
export declare type DragMode = 'move' | 'copy' | 'swap' | 'insert';
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* The default clone of one dragged item (see `DragPreviewProps`). Custom overlays use
|
|
846
|
+
* it to lay out several items themselves; the default overlay shows a multi-drag with it.
|
|
847
|
+
*/
|
|
848
|
+
export declare const DragPreview: DefineComponent<ExtractPropTypes< {
|
|
849
|
+
id: {
|
|
850
|
+
type: PropType<DragPreviewProps["id"]>;
|
|
851
|
+
required: true;
|
|
852
|
+
};
|
|
853
|
+
}>, () => VNode<RendererNode, RendererElement, {
|
|
854
|
+
[key: string]: any;
|
|
855
|
+
}> | null, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
|
|
856
|
+
id: {
|
|
857
|
+
type: PropType<DragPreviewProps["id"]>;
|
|
858
|
+
required: true;
|
|
859
|
+
};
|
|
860
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Props of `DragPreview`: the default clone of one dragged item, for custom overlays (an
|
|
864
|
+
* `overlay` component or the provider's `#overlay` slot) that lay out several items
|
|
865
|
+
* themselves, e.g. `<DragPreview v-for="item in items" :key="item.id" :id="item.id" />`.
|
|
866
|
+
*
|
|
867
|
+
* Clones are taken at pickup, of the grabbed item and of the others next to it in drop
|
|
868
|
+
* order, as many as the provider's `overlayPreviews` (5 by default; those that are rendered
|
|
869
|
+
* then). For any other item `DragPreview` renders its
|
|
870
|
+
* default slot in an element that takes `class` and `style` as a clone's does, or nothing
|
|
871
|
+
* without one. The clone fills the element, which has the item's size at
|
|
872
|
+
* pickup, set inline: change it with `style` (`:style="{ width: '100%', height: '100%' }"`),
|
|
873
|
+
* which falls through; a class can't override it.
|
|
874
|
+
*
|
|
875
|
+
* In a sortable multi-drag (`multiple: 'group'` or `'gaps'`), the preview of an item other
|
|
876
|
+
* than the grabbed one lands on that item's slot with the drop (back on its place when
|
|
877
|
+
* cancelled), from wherever the layout put it: wrappers turned or scaled with `transform`
|
|
878
|
+
* are undone on the way, its size animates as width and height. Style the preview itself
|
|
879
|
+
* (corners, shadow): its wrappers stay in the box. Items without a clone fade in instead.
|
|
880
|
+
* Dropped into a zone (not a list), the previews go into it one after another, the box
|
|
881
|
+
* last.
|
|
882
|
+
*/
|
|
883
|
+
export declare interface DragPreviewProps {
|
|
884
|
+
/** Id of a dragged item: one of `items` in `OverlayProps`. */
|
|
885
|
+
id: Key;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/** Where the dragged items come from, when that is a sortable list. */
|
|
889
|
+
export declare interface DragSource {
|
|
890
|
+
/** Sortable list the dragged items come from. */
|
|
891
|
+
list: Key;
|
|
892
|
+
/** Removes the dragged items from their list (trash zones). */
|
|
893
|
+
remove(): void;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* How the overlay lands on a drop and flies back on a cancel: `true` (default timing),
|
|
898
|
+
* options, `false` (no flight: it ends where it was let go), or a function that animates
|
|
899
|
+
* `overlay` from `from` to `to` and returns its `Animation`, a promise that settles when it
|
|
900
|
+
* ends, or nothing.
|
|
901
|
+
*/
|
|
902
|
+
export declare type DropAnimation = boolean | AnimationOptions | ((context: DropAnimationContext) => Animation | Promise<unknown> | void);
|
|
903
|
+
|
|
904
|
+
/** What a drop animation function gets: the overlay, where it is and where it lands. */
|
|
905
|
+
export declare interface DropAnimationContext {
|
|
906
|
+
/**
|
|
907
|
+
* The overlay box; it lands on the active item's slot. In a multi-drag the clones of the
|
|
908
|
+
* other items riding inside it (the default overlay's, the `DragPreview`s of a custom
|
|
909
|
+
* one) land on their own slots by themselves (with the default timing when this is a
|
|
910
|
+
* custom function).
|
|
911
|
+
*/
|
|
912
|
+
overlay: HTMLElement;
|
|
913
|
+
/** Where the overlay is when the drag ends. */
|
|
914
|
+
from: Rect;
|
|
915
|
+
/** Final rect of the dropped item; `null` when it isn't rendered or visible (the overlay fades out). */
|
|
916
|
+
to: Rect | null;
|
|
917
|
+
/**
|
|
918
|
+
* The item isn't shown after a drop on a zone (not a sortable list), e.g. it was dropped
|
|
919
|
+
* into another item (a folder) or a trash zone: the zone's visible rect. The default
|
|
920
|
+
* animation shrinks the overlay into it as it fades out, instead of fading in place.
|
|
921
|
+
*/
|
|
922
|
+
into: Rect | null;
|
|
923
|
+
/** `'drop'`: the overlay lands where the drop put the item. `'cancel'`: it flies back to where the item was. */
|
|
924
|
+
reason: 'drop' | 'cancel';
|
|
925
|
+
/** The drag that ended. */
|
|
926
|
+
active: Active;
|
|
927
|
+
/** The target the drop lands on (a list, a zone); `null` on a cancel. */
|
|
928
|
+
over: Over | null;
|
|
929
|
+
/** The timing the options give, defaults filled in. */
|
|
930
|
+
options: Required<AnimationOptions>;
|
|
931
|
+
/**
|
|
932
|
+
* `prefers-reduced-motion: reduce` is set. The library's own animations don't run then;
|
|
933
|
+
* functions of yours always do, and decide with this (skip, or keep a fade).
|
|
934
|
+
*/
|
|
935
|
+
reducedMotion: boolean;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Where a drop would put the dragged items: a place in a sortable list or tree, as the
|
|
940
|
+
* drop event's `to` will say (the overlay's `to` prop, live).
|
|
941
|
+
*/
|
|
942
|
+
export declare interface DropDestination {
|
|
943
|
+
/** Id of the list or tree. */
|
|
944
|
+
list: Key;
|
|
945
|
+
/** Index the dragged items take: in the list, or among the siblings under `parentKey` in a tree. */
|
|
946
|
+
index: number;
|
|
947
|
+
/** Trees: the node they go under; `null` at the root. */
|
|
948
|
+
parentKey?: Key | null;
|
|
949
|
+
/** Trees: the depth they go at (roots are 0). */
|
|
950
|
+
depth?: number;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* What a drop outside every target does: `'placeholder'` keeps the items where their slot
|
|
955
|
+
* is, `'cancel'` sends them back, `'remove'` takes them out of their list.
|
|
956
|
+
*/
|
|
957
|
+
export declare type DropOutside = 'placeholder' | 'cancel' | 'remove';
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Options of `makeDroppable`.
|
|
961
|
+
*
|
|
962
|
+
* **Drop into an item.** A drop target on a sortable item's element (or inside it) works
|
|
963
|
+
* as everywhere else, with one rule while that item's list would sort the drag: it counts
|
|
964
|
+
* only while the pointer is in the middle of the item (25–75% along the list's axis; x in
|
|
965
|
+
* grids), where the drop goes into the target and the list doesn't move for it. Near the
|
|
966
|
+
* item's edges the list sorts as usual. A target whose `accept` refuses the drag is left
|
|
967
|
+
* out, so the list sorts over the item like over any other (no need to disable it). The
|
|
968
|
+
* keyboard stops on such a target before moving past its item. A drag never targets what
|
|
969
|
+
* it carries: no target in (or on) a dragged item, nor in the slot one lands in. To move the
|
|
970
|
+
* items out of their list in `onDrop`, call `e.source.remove()`.
|
|
971
|
+
*
|
|
972
|
+
* Every option but the callbacks takes a value, a ref or a getter (`accept`, `overOverlay`,
|
|
973
|
+
* `overDropAnimation`: a value or a ref) and is read live, while a drag looks for its target.
|
|
974
|
+
*/
|
|
975
|
+
export declare interface DroppableOptions<TData = unknown> {
|
|
976
|
+
/** Default: `useId()`, stable between server and client render. */
|
|
977
|
+
id?: MaybeReadonlyRefOrGetter<Key>;
|
|
978
|
+
/** Anything to tell about the target: events carry it as `over.data`. */
|
|
979
|
+
data?: MaybeReadonlyRefOrGetter<TData>;
|
|
980
|
+
/** What people call it: screen reader texts say it instead of the id (`over Trash`); events carry it as `over.label`. */
|
|
981
|
+
label?: MaybeReadonlyRefOrGetter<string | undefined>;
|
|
982
|
+
/**
|
|
983
|
+
* What this target takes. Inside a sortable item, one that refuses the drag lets the
|
|
984
|
+
* list sort over it. A value or a ref: a function is a rule.
|
|
985
|
+
*/
|
|
986
|
+
accept?: MaybeReadonlyRef<AcceptRule | undefined>;
|
|
987
|
+
/** Default `'all'`. */
|
|
988
|
+
acceptMode?: MaybeReadonlyRefOrGetter<AcceptMode | undefined>;
|
|
989
|
+
/** `true`: drags pass over it as if it weren't there. */
|
|
990
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
991
|
+
/** Higher wins when targets overlap without nesting (default 0). Sortable items beat containers. */
|
|
992
|
+
priority?: MaybeReadonlyRefOrGetter<number | undefined>;
|
|
993
|
+
/**
|
|
994
|
+
* What the overlay shows while a drag this target accepts is over it: a component that
|
|
995
|
+
* gets `OverlayProps`, rendered instead of the drag's own overlay (the dragged item's
|
|
996
|
+
* component, the provider's slot or the clone), which it gets as its default slot to
|
|
997
|
+
* wrap or leave out (`<slot />`). It stays while the drop lands here. Drags without an
|
|
998
|
+
* overlay (`overlay: false`) keep none. A value or a ref, read live; the change of
|
|
999
|
+
* component animates with the provider's `overlayTransition`. (On draggables, items and
|
|
1000
|
+
* lists, `overlay` is the drag's own overlay; sortable lists and trees take this one as
|
|
1001
|
+
* `overOverlay` too.)
|
|
1002
|
+
*/
|
|
1003
|
+
overOverlay?: MaybeReadonlyRef<Component | undefined>;
|
|
1004
|
+
/**
|
|
1005
|
+
* How the overlay lands when it is dropped here, instead of the dragged item's and the
|
|
1006
|
+
* provider's `dropAnimation`: `false` leaves it where it was dropped (an overlay
|
|
1007
|
+
* component's own animation, a splash, plays there), a function animates it. A value or
|
|
1008
|
+
* a ref, read at the drop.
|
|
1009
|
+
*/
|
|
1010
|
+
overDropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
1011
|
+
/** A drag came over this target, whether it accepts the drag or not (`event.over.accepted`). */
|
|
1012
|
+
onDragEnter?(event: DnDEvent): void;
|
|
1013
|
+
/** The drag left this target. */
|
|
1014
|
+
onDragLeave?(event: DnDEvent): void;
|
|
1015
|
+
/**
|
|
1016
|
+
* Asked before a drop on this target goes through, after the monitors' `onBeforeDrop`,
|
|
1017
|
+
* if it accepts the drag (see `BeforeDropResult`). May be async: the overlay waits where
|
|
1018
|
+
* it was dropped. An error rejects the drop.
|
|
1019
|
+
*/
|
|
1020
|
+
onBeforeDrop?(event: DnDEvent): MaybePromise<BeforeDropResult>;
|
|
1021
|
+
/**
|
|
1022
|
+
* A drop on this target went through: do what it means (move the item, upload the file).
|
|
1023
|
+
* When an `onBeforeDrop` took only some of the dragged items, `event.accepted` has their
|
|
1024
|
+
* ids and `event.rejected` the others, which fly back; `active` is still the whole drag.
|
|
1025
|
+
*/
|
|
1026
|
+
onDrop?(event: DnDEndEvent): void;
|
|
1027
|
+
/**
|
|
1028
|
+
* Takes drags from outside the page: files from the desktop, a link or text from another
|
|
1029
|
+
* app or tab (the browser's drag and drop). They work as the library's drags do (`isOver`,
|
|
1030
|
+
* `isAccepting`, the events), and `e.external` has their data at the drop. Targets
|
|
1031
|
+
* without `external` ignore them. A value, a ref or a getter, read live.
|
|
1032
|
+
*/
|
|
1033
|
+
external?: MaybeReadonlyRefOrGetter<ExternalAccept | undefined>;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/** What `makeDroppable` returns. */
|
|
1037
|
+
export declare interface DroppableReturn {
|
|
1038
|
+
/** The target's id: the `id` option, or the one made for it. */
|
|
1039
|
+
id: ComputedRef<Key>;
|
|
1040
|
+
/** A drag is over it (one from outside the page too, with `external`). */
|
|
1041
|
+
isOver: ComputedRef<boolean>;
|
|
1042
|
+
/** Something is being dragged and this target accepts it. */
|
|
1043
|
+
isAccepting: ComputedRef<boolean>;
|
|
1044
|
+
/** Pointer position relative to the target's halves while it is hovered. */
|
|
1045
|
+
placement: ComputedRef<Placement | null>;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/** `true`, options, `false` (the item just appears), or a function that animates it in. */
|
|
1049
|
+
export declare type EnterAnimation = boolean | AnimationOptions | ((context: EnterAnimationContext) => Animation | Promise<unknown> | void);
|
|
1050
|
+
|
|
1051
|
+
/** An item that appeared in a list with `animateChanges` on: added, or shown again (a filter, an expanded tree node). */
|
|
1052
|
+
export declare interface EnterAnimationContext {
|
|
1053
|
+
/** Key of the item. */
|
|
1054
|
+
key: Key;
|
|
1055
|
+
/** The item's element, already in its place. */
|
|
1056
|
+
element: HTMLElement;
|
|
1057
|
+
/** Where it appeared (layout rect). */
|
|
1058
|
+
to: Rect;
|
|
1059
|
+
/** The timing the options give, defaults filled in. */
|
|
1060
|
+
options: Required<AnimationOptions>;
|
|
1061
|
+
/**
|
|
1062
|
+
* `prefers-reduced-motion: reduce` is set. The library's own animations don't run then;
|
|
1063
|
+
* functions of yours always do, and decide with this (skip, or keep a fade).
|
|
1064
|
+
*/
|
|
1065
|
+
reducedMotion: boolean;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* What a drop target, list or tree takes from drags that come from outside the page: files
|
|
1070
|
+
* from the desktop, a link or text from another app or tab (`external`).
|
|
1071
|
+
*/
|
|
1072
|
+
export declare interface ExternalAccept {
|
|
1073
|
+
/**
|
|
1074
|
+
* Files: `true` takes any. Or as `<input accept>` has it: MIME types (`image/*`,
|
|
1075
|
+
* `application/pdf`) and extensions (`.md`), a string with commas or a list; extensions
|
|
1076
|
+
* are checked at the drop. Or a function asked about each file (`false` refuses it).
|
|
1077
|
+
* Folders are never taken.
|
|
1078
|
+
*/
|
|
1079
|
+
files?: boolean | string | readonly string[] | ((file: ExternalFile) => boolean);
|
|
1080
|
+
/** Several files at once (default `true`); `false` refuses a drag of more than one. */
|
|
1081
|
+
multiple?: boolean;
|
|
1082
|
+
/** Links (`text/uri-list`): an address dragged from another tab, a link from a page. */
|
|
1083
|
+
links?: boolean;
|
|
1084
|
+
/** Plain text (`text/plain`): a selection dragged from another app. */
|
|
1085
|
+
text?: boolean;
|
|
1086
|
+
/** Other MIME types it takes, exactly as other apps offer them. */
|
|
1087
|
+
types?: readonly string[];
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* A drag from outside the page (`Active.external`, `DnDEvent.external`). While it is held
|
|
1092
|
+
* the browser tells what it carries, not the data: the files, links and text come at the
|
|
1093
|
+
* drop (`ready`).
|
|
1094
|
+
*/
|
|
1095
|
+
export declare interface ExternalData {
|
|
1096
|
+
/** The MIME types it offers (`Files`, `text/uri-list`, `text/plain`, an app's own). */
|
|
1097
|
+
types: readonly string[];
|
|
1098
|
+
/** The MIME types of its files, one per file (`''` when the browser can't tell). */
|
|
1099
|
+
fileTypes: readonly string[];
|
|
1100
|
+
/** At the drop: the files the target takes (folders and refused files left out). */
|
|
1101
|
+
files: readonly File[];
|
|
1102
|
+
/** At the drop: its links (`text/uri-list`). */
|
|
1103
|
+
urls: readonly string[];
|
|
1104
|
+
/** At the drop: its plain text. */
|
|
1105
|
+
text: string;
|
|
1106
|
+
/** At the drop: its HTML. */
|
|
1107
|
+
html: string;
|
|
1108
|
+
/** At the drop: the data of any type it offers (`''` before, and for a type it doesn't offer). */
|
|
1109
|
+
getData(type: string): string;
|
|
1110
|
+
/** It was dropped: the data above is there. */
|
|
1111
|
+
ready: boolean;
|
|
1112
|
+
/**
|
|
1113
|
+
* Items of the library dragged in from another window of the app (`native`): the name of
|
|
1114
|
+
* their sortable group. The lists of that group take them as if they came from one of
|
|
1115
|
+
* their own lists; `active.items` has them.
|
|
1116
|
+
*/
|
|
1117
|
+
group?: string;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* A file of a drag from outside, as `ExternalAccept.files` is asked about it. While the
|
|
1122
|
+
* files are held over the page the browser tells their types only: `name` and `size`
|
|
1123
|
+
* come at the drop.
|
|
1124
|
+
*/
|
|
1125
|
+
export declare interface ExternalFile {
|
|
1126
|
+
/** Its MIME type (`image/png`); `''` when the browser can't tell. */
|
|
1127
|
+
type: string;
|
|
1128
|
+
/** Its name with the extension (`notes.md`), at the drop. */
|
|
1129
|
+
name?: string;
|
|
1130
|
+
/** Its size in bytes, at the drop. */
|
|
1131
|
+
size?: number;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** A visible node of a tree, as the tree's `items` list it: render them in order, indented by `depth`. */
|
|
1135
|
+
export declare interface FlatNode<T> {
|
|
1136
|
+
/** The node's key (`getKey`). */
|
|
1137
|
+
key: Key;
|
|
1138
|
+
/** Your node. */
|
|
1139
|
+
item: T;
|
|
1140
|
+
/** Its depth: roots are 0. The dragged node has its projected depth. */
|
|
1141
|
+
depth: number;
|
|
1142
|
+
/** Key of its parent; `null` for a root. */
|
|
1143
|
+
parentKey: Key | null;
|
|
1144
|
+
/** Index among siblings. */
|
|
1145
|
+
index: number;
|
|
1146
|
+
/** It has children, shown or not. */
|
|
1147
|
+
hasChildren: boolean;
|
|
1148
|
+
/** Its children are hidden (its key is in `collapsed`). */
|
|
1149
|
+
collapsed: boolean;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* A vibration (`navigator.vibrate`): its length in ms or an on/off pattern. `true` is the
|
|
1154
|
+
* default one (10ms; `[20, 40, 20]` for `refuse`), `false` or `0` none.
|
|
1155
|
+
*/
|
|
1156
|
+
export declare type HapticPattern = boolean | number | number[];
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* When touch drags vibrate. Only drags started by touch do; where the browser can't
|
|
1160
|
+
* vibrate (iOS Safari) or blocks it (no tap on the page yet), nothing happens.
|
|
1161
|
+
*/
|
|
1162
|
+
export declare interface HapticsOptions {
|
|
1163
|
+
/** The drag starts, after the long press. Default `true`. */
|
|
1164
|
+
start?: HapticPattern;
|
|
1165
|
+
/** The drag enters a drop target (a list, a zone) that accepts it. Default `false`. */
|
|
1166
|
+
enter?: HapticPattern;
|
|
1167
|
+
/** The drop goes through. Default `false`. */
|
|
1168
|
+
drop?: HapticPattern;
|
|
1169
|
+
/** The drop is refused (by a target or `onBeforeDrop`) and the items fly back. Default `false`. */
|
|
1170
|
+
refuse?: HapticPattern;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/** An id or a key: of a draggable, a drop target, a list, an item of a list. */
|
|
1174
|
+
export declare type Key = string | number;
|
|
1175
|
+
|
|
1176
|
+
/** What `getKeyboardCoordinates` is asked with, for an arrow key. */
|
|
1177
|
+
export declare interface KeyboardMoveContext {
|
|
1178
|
+
/** The drag. */
|
|
1179
|
+
active: Active;
|
|
1180
|
+
/** Where the drag is now, in viewport coordinates. */
|
|
1181
|
+
pointer: Coordinates;
|
|
1182
|
+
/** Unit vector of the pressed arrow key. */
|
|
1183
|
+
direction: Coordinates;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/** Keyboard drags (the provider's `keyboard`): their keys, and the step of free drags. */
|
|
1187
|
+
export declare interface KeyboardOptions {
|
|
1188
|
+
/**
|
|
1189
|
+
* The keys that pick up (`start`), drop and cancel, as `KeyboardEvent.code` (`'Space'`,
|
|
1190
|
+
* `'KeyW'`) or `.key` (`'Enter'`, `'w'`). Default: Space and Enter pick up and drop,
|
|
1191
|
+
* Escape cancels. The arrows always move.
|
|
1192
|
+
*/
|
|
1193
|
+
keys?: {
|
|
1194
|
+
start?: string[];
|
|
1195
|
+
drop?: string[];
|
|
1196
|
+
cancel?: string[];
|
|
1197
|
+
};
|
|
1198
|
+
/** Pixels per arrow press for free (non-sortable) drags. Default 25. */
|
|
1199
|
+
step?: number;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Space/Enter, arrows and Escape (rebound with the provider's `keyboard` option). In
|
|
1204
|
+
* `sensors` by default; it also cancels pointer and custom drags with Escape, even with
|
|
1205
|
+
* `keyboard: false`.
|
|
1206
|
+
*/
|
|
1207
|
+
export declare const keyboardSensor: Sensor;
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* How items move to their new places: `true` (default timing), options, `false` (they
|
|
1211
|
+
* jump), or a function that animates one item from `from` to `to` and returns its
|
|
1212
|
+
* `Animation`, a promise that settles when it ends, or nothing.
|
|
1213
|
+
*/
|
|
1214
|
+
export declare type LayoutAnimation = boolean | AnimationOptions | ((context: LayoutAnimationContext) => Animation | Promise<unknown> | void);
|
|
1215
|
+
|
|
1216
|
+
/** What a layout animation function gets, for one item that moves to its new place. */
|
|
1217
|
+
export declare interface LayoutAnimationContext {
|
|
1218
|
+
/** Key of the item. */
|
|
1219
|
+
key: Key;
|
|
1220
|
+
/** The item's element, already in its new place. */
|
|
1221
|
+
element: HTMLElement;
|
|
1222
|
+
/** Visual rect before the change (where a running animation showed the item). */
|
|
1223
|
+
from: Rect;
|
|
1224
|
+
/** Layout rect after the change. */
|
|
1225
|
+
to: Rect;
|
|
1226
|
+
/** The timing the options give, defaults filled in. */
|
|
1227
|
+
options: Required<AnimationOptions>;
|
|
1228
|
+
/**
|
|
1229
|
+
* What moved the item: a drag (`'drag'`: sorting, the drop, a cancel), or a change of
|
|
1230
|
+
* your data that no drag made (`'change'`, with the list's `animateChanges` on).
|
|
1231
|
+
*/
|
|
1232
|
+
reason: 'drag' | 'change';
|
|
1233
|
+
/**
|
|
1234
|
+
* Aborted when the library interrupts the animation: the item moves again before it
|
|
1235
|
+
* ends (the next animation starts where it is shown), or animations are turned off. A
|
|
1236
|
+
* returned `Animation` is cancelled for you. Stop anything else here and undo the styles
|
|
1237
|
+
* it set, at once: the layout is measured right after.
|
|
1238
|
+
*/
|
|
1239
|
+
signal: AbortSignal;
|
|
1240
|
+
/**
|
|
1241
|
+
* `prefers-reduced-motion: reduce` is set. The library's own animations don't run then;
|
|
1242
|
+
* functions of yours always do, and decide with this (skip, or keep a fade).
|
|
1243
|
+
*/
|
|
1244
|
+
reducedMotion: boolean;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* `true`, options, `false` (the item just disappears), or a function that animates out the
|
|
1249
|
+
* copy left in its place: return its `Animation` or a promise, and the copy is removed
|
|
1250
|
+
* when it ends (at once when the function returns nothing).
|
|
1251
|
+
*/
|
|
1252
|
+
export declare type LeaveAnimation = boolean | AnimationOptions | ((context: LeaveAnimationContext) => Animation | Promise<unknown> | void);
|
|
1253
|
+
|
|
1254
|
+
/** An item that left a list with `animateChanges` on: removed, or hidden (a filter, a collapsed tree node). */
|
|
1255
|
+
export declare interface LeaveAnimationContext {
|
|
1256
|
+
/** Key of the item. */
|
|
1257
|
+
key: Key;
|
|
1258
|
+
/**
|
|
1259
|
+
* A copy of the item's element, shown where the item was (the item itself is gone):
|
|
1260
|
+
* positioned absolutely in its old parent, ignoring the pointer, marked
|
|
1261
|
+
* `data-dnd-leaving`. The library removes it when your animation ends.
|
|
1262
|
+
*/
|
|
1263
|
+
element: HTMLElement;
|
|
1264
|
+
/** Where the item was. */
|
|
1265
|
+
from: Rect;
|
|
1266
|
+
/** The timing the options give, defaults filled in. */
|
|
1267
|
+
options: Required<AnimationOptions>;
|
|
1268
|
+
/**
|
|
1269
|
+
* `prefers-reduced-motion: reduce` is set. The library's own animations don't run then;
|
|
1270
|
+
* functions of yours always do, and decide with this (skip, or keep a fade).
|
|
1271
|
+
*/
|
|
1272
|
+
reducedMotion: boolean;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Makes an element a drag area: the drags that start inside it (draggables and sortable
|
|
1277
|
+
* items) follow its rules, see `DragAreaOptions`. One provider can then serve the whole
|
|
1278
|
+
* app, with boards, canvases and feeds that drag their own way. The closest area wins
|
|
1279
|
+
* when areas are nested.
|
|
1280
|
+
*/
|
|
1281
|
+
export declare function makeDragArea(target: MaybeElementRef, options?: DragAreaOptions): DragAreaReturn;
|
|
1282
|
+
|
|
1283
|
+
/** Makes an element draggable. Free drag by default; sortable lists build on top of it. */
|
|
1284
|
+
export declare function makeDraggable<TData = unknown>(target: MaybeElementRef, options?: DraggableOptions<TData>): DraggableReturn;
|
|
1285
|
+
|
|
1286
|
+
/** Makes an element a drop target. */
|
|
1287
|
+
export declare function makeDroppable<TData = unknown>(target: MaybeElementRef, options?: DroppableOptions<TData>): DroppableReturn;
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Makes an element a rubber-band selection area for the draggables inside it.
|
|
1291
|
+
* Render the rectangle yourself: `<div v-if="isSelecting" class="band" :style="style" />`.
|
|
1292
|
+
*/
|
|
1293
|
+
export declare function makeSelectionArea(target: MaybeElementRef, options?: SelectionAreaOptions): SelectionAreaReturn;
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* Makes an element a row of a sortable list or tree: it drags, makes room and lands in
|
|
1297
|
+
* its slot. Call it in a component rendered inside the one that called `makeSortableList`
|
|
1298
|
+
* (or `makeSortableTree`); of several lists made there, the row joins the innermost one
|
|
1299
|
+
* whose element holds it. Identify the row with `item` (keyed by the list's `getKey`,
|
|
1300
|
+
* `item.id` by default) or `id`.
|
|
1301
|
+
*/
|
|
1302
|
+
export declare function makeSortableItem<TData = unknown>(target: MaybeElementRef, options: SortableItemOptions<TData>): SortableItemReturn;
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* Makes a container a sortable list. Render the returned `items` (the draft order), not
|
|
1306
|
+
* your array: the drop is written back to `options.items`, after `onDrop`, unless
|
|
1307
|
+
* `event.preventDefault()` leaves `event.result` to you.
|
|
1308
|
+
*/
|
|
1309
|
+
export declare function makeSortableList<T>(target: MaybeElementRef, options: SortableListOptions<T>): SortableListReturn<T>;
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Makes a container a sortable tree. Render the returned `items` (visible nodes in
|
|
1313
|
+
* draft order, indented by `depth`) with a row component that calls `makeSortableItem`.
|
|
1314
|
+
* On drop, after `onDrop`, the moved nodes (with their subtrees) are written into
|
|
1315
|
+
* `options.items`, unless `event.preventDefault()` leaves `event.result` to you.
|
|
1316
|
+
*/
|
|
1317
|
+
export declare function makeSortableTree<T>(target: MaybeElementRef, options: SortableTreeOptions<T>): SortableTreeReturn<T>;
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* An element: an HTML or SVG element, or a component instance (its root element, `$el`),
|
|
1321
|
+
* as a template ref gives them. `null` or `undefined` while there is none (not mounted yet).
|
|
1322
|
+
*/
|
|
1323
|
+
export declare type MaybeElement = HTMLElement | SVGElement | ComponentRef | null | undefined;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* The element a composable works on (`makeDraggable(target)`): the element, a template ref
|
|
1327
|
+
* (`useTemplateRef`) or a getter. It may change (a `v-if`): the library follows it.
|
|
1328
|
+
*/
|
|
1329
|
+
export declare type MaybeElementRef = MaybeReadonlyRefOrGetter<MaybeElement>;
|
|
1330
|
+
|
|
1331
|
+
/** A value, or a promise of it: what a hook that may be async returns (`onBeforeDrop`). */
|
|
1332
|
+
export declare type MaybePromise<T> = T | Promise<T>;
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* A value or any ref, for options where a function is a value of its own (an overlay
|
|
1336
|
+
* component, an accept rule, a custom animation), so a getter can't be told apart.
|
|
1337
|
+
* Hold components in a `shallowRef` (or a computed): Vue must not make them reactive.
|
|
1338
|
+
*/
|
|
1339
|
+
export declare type MaybeReadonlyRef<T> = T | Readonly<Ref<T>>;
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* A value, a getter or any ref (writable, shallow, computed, readonly — e.g. from
|
|
1343
|
+
* `useTemplateRef`) that the library only reads. Unlike Vue's `MaybeRefOrGetter`
|
|
1344
|
+
* it accepts `Ref<string>` where `string | number` is expected.
|
|
1345
|
+
*/
|
|
1346
|
+
export declare type MaybeReadonlyRefOrGetter<T> = T | Readonly<Ref<T>> | (() => T);
|
|
1347
|
+
|
|
1348
|
+
/** Changes where the dragged item goes: takes the drag's offset (`transform`) and returns a new one. */
|
|
1349
|
+
export declare type Modifier = (args: ModifierArgs) => Coordinates;
|
|
1350
|
+
|
|
1351
|
+
/** What a modifier gets, on every move of the drag. */
|
|
1352
|
+
export declare interface ModifierArgs {
|
|
1353
|
+
/** Offset from the drag start, as modified by the previous modifiers. */
|
|
1354
|
+
transform: Coordinates;
|
|
1355
|
+
/** The drag. */
|
|
1356
|
+
active: Active;
|
|
1357
|
+
/** Rect of the dragged element at drag start. */
|
|
1358
|
+
activeRect: Rect;
|
|
1359
|
+
/**
|
|
1360
|
+
* Rect of the overlay box if it were moved by `transform`, at the size it has now. With
|
|
1361
|
+
* `overlayFit: 'slot'` the box resizes around the pointer, so it isn't always
|
|
1362
|
+
* `activeRect` moved by `transform`.
|
|
1363
|
+
*/
|
|
1364
|
+
overlayRect: Rect;
|
|
1365
|
+
/** Pointer position at drag start. */
|
|
1366
|
+
origin: Coordinates;
|
|
1367
|
+
/** Sortable list container (or parent element) of the dragged item, where it is now (it follows scrolling). */
|
|
1368
|
+
containerRect: Rect | null;
|
|
1369
|
+
/**
|
|
1370
|
+
* How far the content the drag started in has moved on screen since the start: the
|
|
1371
|
+
* container moved (the page or a container around it scrolled, the layout shifted), and
|
|
1372
|
+
* its content scrolled inside it. Axis locks hold the other axis there, so the drag
|
|
1373
|
+
* stays on its row or column of that content.
|
|
1374
|
+
*/
|
|
1375
|
+
containerShift: Coordinates;
|
|
1376
|
+
/** Rect of the window (the viewport). */
|
|
1377
|
+
windowRect: Rect;
|
|
1378
|
+
/** The drop target under the drag, as last found; `null` over nothing. */
|
|
1379
|
+
over: Over | null;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* What the other selected items do in a multi-drag:
|
|
1384
|
+
* - `'group'`: they leave their places and travel with the active item as contiguous
|
|
1385
|
+
* placeholders, so while hovering the list already shows the result of the drop;
|
|
1386
|
+
* - `'gaps'`: they stay in place until the drop;
|
|
1387
|
+
* - `'stack'`: they collapse into the overlay.
|
|
1388
|
+
*
|
|
1389
|
+
* The default overlay shows the dragged items in a column along the list (`'group'`,
|
|
1390
|
+
* `'gaps'`; a row in horizontal lists, a pile behind the active one in grids), or the active
|
|
1391
|
+
* one with a count (`'stack'`).
|
|
1392
|
+
*/
|
|
1393
|
+
export declare type MultipleMode = 'group' | 'gaps' | 'stack';
|
|
1394
|
+
|
|
1395
|
+
/**
|
|
1396
|
+
* A draggable or sortable item that a mouse can drag out of the page (`native`): onto the
|
|
1397
|
+
* desktop, into another app, another tab, another window of the app.
|
|
1398
|
+
*/
|
|
1399
|
+
export declare interface NativeDragOptions {
|
|
1400
|
+
/**
|
|
1401
|
+
* What other apps and pages get: text by MIME type, as
|
|
1402
|
+
* `{ 'text/plain': title, 'text/uri-list': url }`. Read when the drag starts. Sortable
|
|
1403
|
+
* items also carry themselves, for the lists of their group in another window of the app.
|
|
1404
|
+
*/
|
|
1405
|
+
data?: (active: Active) => Record<string, string>;
|
|
1406
|
+
/**
|
|
1407
|
+
* What the drag lets the place it is dropped on do (`effectAllowed`). Default
|
|
1408
|
+
* `'copyMove'`: a move takes the items out of their list here, a copy leaves them.
|
|
1409
|
+
*/
|
|
1410
|
+
effect?: 'copy' | 'move' | 'link' | 'copyMove' | 'copyLink' | 'linkMove' | 'all';
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/** The drop target under the drag. */
|
|
1414
|
+
export declare interface Over {
|
|
1415
|
+
/** Id of the drop target. */
|
|
1416
|
+
id: Key;
|
|
1417
|
+
/** The target's `data` option. */
|
|
1418
|
+
data: unknown;
|
|
1419
|
+
/** The target's `label`, what people call it. */
|
|
1420
|
+
label?: string;
|
|
1421
|
+
/** The target's element. */
|
|
1422
|
+
element: HTMLElement;
|
|
1423
|
+
/** The rect of `element`, measured during the drag. */
|
|
1424
|
+
rect: Rect;
|
|
1425
|
+
/** Whether the target's `accept` rule accepts the dragged items. */
|
|
1426
|
+
accepted: boolean;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Props of an overlay component, for `defineProps<OverlayProps>()`.
|
|
1431
|
+
*
|
|
1432
|
+
* The component renders inside the overlay box, which follows the slot size
|
|
1433
|
+
* (`overlayFit: 'slot'`) and animates it on drop. Give the root `width: 100%` (and
|
|
1434
|
+
* `height: 100%`) to follow that size; a fixed size keeps the component's own.
|
|
1435
|
+
*/
|
|
1436
|
+
export declare type OverlayProps = OverlaySlotProps;
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* What the overlay shows: the props of the provider's `#overlay` slot and of overlay
|
|
1440
|
+
* components (`overlay` option of draggables, sortable items, lists and trees).
|
|
1441
|
+
*/
|
|
1442
|
+
export declare interface OverlaySlotProps {
|
|
1443
|
+
/** The drag. */
|
|
1444
|
+
active: Active;
|
|
1445
|
+
/** Every dragged item, the primary one first: one overlay for the whole multi-drag. */
|
|
1446
|
+
items: DragItem[];
|
|
1447
|
+
/**
|
|
1448
|
+
* The drop target under the drag. While a decided drop animates, the target it lands
|
|
1449
|
+
* on (as it was at the drop); `null` while a cancelled drag flies back.
|
|
1450
|
+
*/
|
|
1451
|
+
over: Over | null;
|
|
1452
|
+
/** Whether `over` accepts the dragged items; `false` when over nothing. */
|
|
1453
|
+
accepted: boolean;
|
|
1454
|
+
/** `'dragging'`, then `'dropping'` while the overlay lands (or flies back). */
|
|
1455
|
+
status: DnDStatus;
|
|
1456
|
+
/** What a drop would do now (see `DnDEvent.mode`): e.g. show a plus while it copies. */
|
|
1457
|
+
mode: DragMode;
|
|
1458
|
+
/**
|
|
1459
|
+
* Where a drop would put the dragged items now, in a sortable list or tree: e.g. tint
|
|
1460
|
+
* the overlay by the folder a tree drag would go into. Outside every target it is the
|
|
1461
|
+
* slot's place, where `dropOutside: 'placeholder'` (the default) keeps them. `null` when
|
|
1462
|
+
* the drop would put them in no list: over a plain drop target, over a list that refuses
|
|
1463
|
+
* them, outside with `dropOutside: 'cancel'` or `'remove'`. While a decided drop
|
|
1464
|
+
* animates, the place it lands on.
|
|
1465
|
+
*/
|
|
1466
|
+
to: DropDestination | null;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
/** Which halves of a hovered drop target the pointer is in (`DroppableReturn.placement`). */
|
|
1470
|
+
export declare interface Placement {
|
|
1471
|
+
/** In its top half. */
|
|
1472
|
+
top: boolean;
|
|
1473
|
+
/** In its right half. */
|
|
1474
|
+
right: boolean;
|
|
1475
|
+
/** In its bottom half. */
|
|
1476
|
+
bottom: boolean;
|
|
1477
|
+
/** In its left half. */
|
|
1478
|
+
left: boolean;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
/** Default: what is under the pointer, else what the overlay overlaps. */
|
|
1482
|
+
export declare const pointerFirst: CollisionDetection;
|
|
1483
|
+
|
|
1484
|
+
/** The kind of pointer that pressed (`PointerEvent.pointerType`): activation is set per kind. */
|
|
1485
|
+
export declare type PointerKind = 'mouse' | 'touch' | 'pen';
|
|
1486
|
+
|
|
1487
|
+
/** Mouse, touch and pen via Pointer Events. In `sensors` by default. */
|
|
1488
|
+
export declare const pointerSensor: Sensor;
|
|
1489
|
+
|
|
1490
|
+
/** Targets under the pointer, from hit-testing: respects z-order, overlays and shadow roots. */
|
|
1491
|
+
export declare const pointerWithin: CollisionDetection;
|
|
1492
|
+
|
|
1493
|
+
/** Shares a provider (from `useDnDContext()`) with another Vue app, e.g. one mounted inside a shadow root. */
|
|
1494
|
+
export declare const provideDnDContext: (app: App, context: DnDContext) => void;
|
|
1495
|
+
|
|
1496
|
+
/** A box in px, in viewport coordinates, as `getBoundingClientRect()` gives it. */
|
|
1497
|
+
export declare interface Rect {
|
|
1498
|
+
/** Its top edge, from the top of the viewport. */
|
|
1499
|
+
top: number;
|
|
1500
|
+
/** Its left edge, from the left of the viewport. */
|
|
1501
|
+
left: number;
|
|
1502
|
+
/** Its width. */
|
|
1503
|
+
width: number;
|
|
1504
|
+
/** Its height. */
|
|
1505
|
+
height: number;
|
|
1506
|
+
/** Its right edge, from the left of the viewport: `left + width`. */
|
|
1507
|
+
right: number;
|
|
1508
|
+
/** Its bottom edge, from the top of the viewport: `top + height`. */
|
|
1509
|
+
bottom: number;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/** Targets overlapping the overlay: higher priority, then deeper nesting, then intersection over union. */
|
|
1513
|
+
export declare const rectIntersection: CollisionDetection;
|
|
1514
|
+
|
|
1515
|
+
/** Keeps the overlay inside an element: the element, a ref or a getter. */
|
|
1516
|
+
export declare const restrictToElement: (target: MaybeElementRef) => Modifier;
|
|
1517
|
+
|
|
1518
|
+
/** Keeps the overlay inside the first scrollable ancestor of the dragged element. */
|
|
1519
|
+
export declare const restrictToFirstScrollableAncestor: Modifier;
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Moves only horizontally: vertically it stays with the content it started in
|
|
1523
|
+
* (`containerShift`), however the page scrolls. The `axis: 'x'` option does the same, last.
|
|
1524
|
+
*/
|
|
1525
|
+
export declare const restrictToHorizontalAxis: Modifier;
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Keeps the overlay inside the container the drag started in: the sortable list
|
|
1529
|
+
* (not its DOM parent) or, for plain draggables, the parent element.
|
|
1530
|
+
*/
|
|
1531
|
+
export declare const restrictToParent: Modifier;
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Moves only vertically: horizontally it stays with the content it started in
|
|
1535
|
+
* (`containerShift`), however the page scrolls. The `axis: 'y'` option does the same, last.
|
|
1536
|
+
*/
|
|
1537
|
+
export declare const restrictToVerticalAxis: Modifier;
|
|
1538
|
+
|
|
1539
|
+
/** Keeps the overlay inside the window. */
|
|
1540
|
+
export declare const restrictToWindowEdges: Modifier;
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Options of `makeSelectionArea`. The band selects into the provider's selection, the one
|
|
1544
|
+
* multi-drag and `selected` read (`useDnD().selection`). `modifier`, `strategy`, `accept`
|
|
1545
|
+
* and `disabled` take a value, a ref or a getter (`accept`: a value or a ref, a function
|
|
1546
|
+
* is a rule) and are read when a press starts a band; turning `disabled` on also cancels
|
|
1547
|
+
* a running one.
|
|
1548
|
+
*/
|
|
1549
|
+
export declare interface SelectionAreaOptions {
|
|
1550
|
+
/** Keys that must be held for a press to draw a band. Default: none, any press on the empty space draws. */
|
|
1551
|
+
modifier?: MaybeReadonlyRefOrGetter<SelectionModifier | undefined>;
|
|
1552
|
+
/** Default `'toggle'`. */
|
|
1553
|
+
strategy?: MaybeReadonlyRefOrGetter<SelectionStrategy | undefined>;
|
|
1554
|
+
/** Which draggables the band selects; the matcher of drop targets. */
|
|
1555
|
+
accept?: MaybeReadonlyRef<AcceptRule | undefined>;
|
|
1556
|
+
/** `true`: presses draw no band. */
|
|
1557
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
1558
|
+
/** The band ended: gets every id selected now. */
|
|
1559
|
+
onSelected?: (ids: Key[]) => void;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/** What `makeSelectionArea` returns. */
|
|
1563
|
+
export declare interface SelectionAreaReturn {
|
|
1564
|
+
/** A band is being drawn: render it then. */
|
|
1565
|
+
isSelecting: ComputedRef<boolean>;
|
|
1566
|
+
/** Style for the selection rectangle element (absolute, container-relative). */
|
|
1567
|
+
style: ComputedRef<Record<string, string>>;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Keys (`KeyboardEvent.key` or `.code`) that must be held for a press to draw a band:
|
|
1572
|
+
* every one of them, or `'some'` of them.
|
|
1573
|
+
*/
|
|
1574
|
+
export declare interface SelectionModifier {
|
|
1575
|
+
/** The keys, as `KeyboardEvent.key` (`'Shift'`) or `.code` (`'KeyA'`). None: any press draws. */
|
|
1576
|
+
keys: string[];
|
|
1577
|
+
/** `'every'`: all of `keys` must be held; `'some'`: one of them is enough. */
|
|
1578
|
+
method: 'every' | 'some';
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* - `'toggle'`: items the band crosses flip their state from before the band;
|
|
1583
|
+
* - `'select'`: only the items inside the band are selected.
|
|
1584
|
+
*/
|
|
1585
|
+
export declare type SelectionStrategy = 'toggle' | 'select';
|
|
1586
|
+
|
|
1587
|
+
/**
|
|
1588
|
+
* Input that starts drags: pointer, keyboard, or your own (a gamepad, an on-screen
|
|
1589
|
+
* joystick, voice, scripted drags). `setup` runs once per provider, in the browser only,
|
|
1590
|
+
* inside an effect scope that ends with the provider (or when the sensor leaves
|
|
1591
|
+
* `sensors`, or the component that called `useSensor` unmounts). Register listeners
|
|
1592
|
+
* with `useEventListener` or return a cleanup; a drag still running then is cancelled.
|
|
1593
|
+
*
|
|
1594
|
+
* To wrap a sensor, run its `setup` with a context of your own. `Object.create(context, {
|
|
1595
|
+
* activate: { value: … } })` keeps the live getters (`status`, `drag`, `props`): a spread
|
|
1596
|
+
* would freeze them.
|
|
1597
|
+
*/
|
|
1598
|
+
export declare interface Sensor {
|
|
1599
|
+
/** For debugging. */
|
|
1600
|
+
name?: string;
|
|
1601
|
+
/**
|
|
1602
|
+
* Starts listening to the input, once per provider: call `context.activate()` when it
|
|
1603
|
+
* wants to drag. May return a cleanup, run when the sensor stops.
|
|
1604
|
+
*/
|
|
1605
|
+
setup(context: SensorContext): void | (() => void);
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/** What a sensor asks for when its input wants to drag (`SensorContext.activate()`). */
|
|
1609
|
+
export declare interface SensorActivation {
|
|
1610
|
+
/**
|
|
1611
|
+
* Where the input landed: an element inside a draggable, or the id of a draggable.
|
|
1612
|
+
* An element must belong to this provider; for `'pointer'` drags it must be on the
|
|
1613
|
+
* handle when there is one and not on an interactive child (a button, an input), for
|
|
1614
|
+
* `'keyboard'` drags it must be the draggable's focus target (the handle, else the
|
|
1615
|
+
* draggable itself) and not an editable field. An id skips these checks: the drag
|
|
1616
|
+
* starts from the item wherever the input was.
|
|
1617
|
+
*/
|
|
1618
|
+
target: Element | Key;
|
|
1619
|
+
/**
|
|
1620
|
+
* How the drag moves. `'pointer'` (default): it follows the points given to `move()`,
|
|
1621
|
+
* targets are hit-tested there, containers auto-scroll at their edges and the page
|
|
1622
|
+
* shows the grabbing cursor. `'keyboard'`: it moves by items with `step()` and
|
|
1623
|
+
* `place()` as arrow keys do, targets are revealed instead of auto-scrolled, and the
|
|
1624
|
+
* focus goes back to the item when it ends. `Active.sensor` tells which.
|
|
1625
|
+
*/
|
|
1626
|
+
type?: SensorType;
|
|
1627
|
+
/** Where the drag starts, in viewport coordinates. Default: the center of the draggable. */
|
|
1628
|
+
point?: Coordinates;
|
|
1629
|
+
/**
|
|
1630
|
+
* The input event. It is handed to the draggable's `canDrag`: without one (a gamepad,
|
|
1631
|
+
* a programmatic drag), `canDrag` isn't asked. A `pointerType` of `'touch'` makes the
|
|
1632
|
+
* drag a touch drag (`haptics`).
|
|
1633
|
+
*/
|
|
1634
|
+
event?: PointerEvent | KeyboardEvent;
|
|
1635
|
+
/**
|
|
1636
|
+
* What the drag waits for before it starts (`useDnD().status` is `'activating'` until
|
|
1637
|
+
* then, with its progress). A pointer kind reads the draggable's `activation` option
|
|
1638
|
+
* for it, then the provider's, then the defaults (mouse 4px, at once on a handle; pen
|
|
1639
|
+
* 4px; touch a 200ms long press with 5px tolerance). A constraint is used as it
|
|
1640
|
+
* is. Default: none, the drag starts at once.
|
|
1641
|
+
*/
|
|
1642
|
+
activation?: PointerKind | ActivationConstraint;
|
|
1643
|
+
/** The drag started, after its activation: e.g. capture the pointer. */
|
|
1644
|
+
onStart?(drag: SensorDrag): void;
|
|
1645
|
+
/** The drag is over: its activation was aborted, or it dropped or was cancelled (by anyone). */
|
|
1646
|
+
onEnd?(drag: SensorDrag): void;
|
|
1647
|
+
/**
|
|
1648
|
+
* The drop the sensor asked for didn't happen and the drag goes on (`onBeforeDrop`
|
|
1649
|
+
* answered `'continue'`): `move`, `drop` and `cancel` apply again. A pointer sensor
|
|
1650
|
+
* lets the item follow the pointer until the next release.
|
|
1651
|
+
*/
|
|
1652
|
+
onResume?(drag: SensorDrag): void;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
/** What a sensor gets from the provider it runs in. */
|
|
1656
|
+
export declare interface SensorContext {
|
|
1657
|
+
/** The provider's props (e.g. `activation`, `keyboard`). Read them when needed: they may change. */
|
|
1658
|
+
readonly props: Readonly<DnDProviderProps>;
|
|
1659
|
+
/** The provider's drag status, whichever sensor runs the drag. */
|
|
1660
|
+
readonly status: DnDStatus;
|
|
1661
|
+
/**
|
|
1662
|
+
* The provider's drag, pending or dragging, whichever sensor started it; `null` when
|
|
1663
|
+
* there is none. Sensors may drive each other's drags: the keyboard sensor moves and
|
|
1664
|
+
* drops every keyboard drag, e.g. one a "Move" button picked up (`@vue-dnd-kit/actions`).
|
|
1665
|
+
*/
|
|
1666
|
+
readonly drag: SensorDrag | null;
|
|
1667
|
+
/**
|
|
1668
|
+
* Asks to drag an item. The provider checks that it is idle (one drag at a time, none
|
|
1669
|
+
* while a drop lands), that the target is a draggable of its own that isn't disabled,
|
|
1670
|
+
* where the input landed (see `target`) and the draggable's `canDrag`, then waits for
|
|
1671
|
+
* the activation constraint and starts the drag. Returns the drag (pending, or already
|
|
1672
|
+
* dragging when there is nothing to wait for), or `null` when no drag may start.
|
|
1673
|
+
*/
|
|
1674
|
+
activate(activation: SensorActivation): SensorDrag | null;
|
|
1675
|
+
/** Cancels the provider's drag or pending activation, whichever sensor runs it (Escape, a hidden tab). */
|
|
1676
|
+
cancel(): void;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/** Arrow of a keyboard step. */
|
|
1680
|
+
export declare type SensorDirection = 'up' | 'down' | 'left' | 'right';
|
|
1681
|
+
|
|
1682
|
+
/**
|
|
1683
|
+
* One drag of a sensor, from `activate()` until it ends. Every call is ignored once it
|
|
1684
|
+
* no longer applies: moves before the start or after the end, a second `drop()`.
|
|
1685
|
+
*/
|
|
1686
|
+
export declare interface SensorDrag {
|
|
1687
|
+
/** Id of the dragged item. */
|
|
1688
|
+
readonly id: Key;
|
|
1689
|
+
/** How the drag moves, as `activate()` asked (`SensorActivation.type`). */
|
|
1690
|
+
readonly type: SensorType;
|
|
1691
|
+
/** Where the drag is: waiting for its activation, dragging, or ended. */
|
|
1692
|
+
readonly state: SensorDragState;
|
|
1693
|
+
/** The drag started, even if it has ended since (the pointer sensor swallows the click that follows it). */
|
|
1694
|
+
readonly started: boolean;
|
|
1695
|
+
/**
|
|
1696
|
+
* The input moved. While pending, the activation constraint is checked (moving past its
|
|
1697
|
+
* tolerance aborts it); while dragging, the drag goes there. Pointer drags take one
|
|
1698
|
+
* position per frame; keyboard drags move at once, after the steps before them.
|
|
1699
|
+
*/
|
|
1700
|
+
move(point: Coordinates): void;
|
|
1701
|
+
/**
|
|
1702
|
+
* Keyboard drags: one arrow step, as the keyboard sensor's arrow keys do (the next item
|
|
1703
|
+
* of a list, the next accepting target in `'droppables'` mode, or `keyboard.step`
|
|
1704
|
+
* pixels). Steps queue: each runs once the one before has rendered, and a repeated key
|
|
1705
|
+
* (`event.repeat`) is skipped while one still resolves. Pointer drags ignore it.
|
|
1706
|
+
*/
|
|
1707
|
+
step(direction: SensorDirection, options?: SensorStepOptions): Promise<void>;
|
|
1708
|
+
/**
|
|
1709
|
+
* Puts the item at a position of a sortable list, as keyboard moves do (other lists
|
|
1710
|
+
* take it only if they accept it), and moves the drag to its new place. Resolves
|
|
1711
|
+
* `false` when no list takes it there. Queued like `step()` in keyboard drags.
|
|
1712
|
+
*/
|
|
1713
|
+
place(position: SortablePosition): Promise<boolean>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Drops: a pending activation is aborted instead. Resolves once the drag has ended and
|
|
1716
|
+
* landed: `true` when the drop went through, `false` when it was refused (a target,
|
|
1717
|
+
* `onBeforeDrop`) or there was nothing to drop.
|
|
1718
|
+
*/
|
|
1719
|
+
drop(): Promise<boolean>;
|
|
1720
|
+
/** Cancels the drag (it flies back), or aborts a pending activation. */
|
|
1721
|
+
cancel(): void;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* - `'pending'`: waiting for the activation constraint;
|
|
1726
|
+
* - `'dragging'`: from the start until the drop is decided or the drag is cancelled;
|
|
1727
|
+
* - `'ended'`: the activation was aborted, or the drag dropped or was cancelled, by the
|
|
1728
|
+
* sensor or by anything else (Escape, a hidden tab, `useDnD().cancel()`, the provider
|
|
1729
|
+
* unmounting).
|
|
1730
|
+
*/
|
|
1731
|
+
export declare type SensorDragState = 'pending' | 'dragging' | 'ended';
|
|
1732
|
+
|
|
1733
|
+
/** Options of `SensorDrag.step()`. */
|
|
1734
|
+
export declare interface SensorStepOptions {
|
|
1735
|
+
/** The key press, handed to monitors' `getKeyboardCoordinates`. Default: a keydown of the arrow key. */
|
|
1736
|
+
event?: KeyboardEvent;
|
|
1737
|
+
/** A bigger step in free drags (as Shift). Default: `event.shiftKey`. */
|
|
1738
|
+
fast?: boolean;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* How a drag moves, whichever sensor drives it (`SensorActivation.type`): `'pointer'`
|
|
1743
|
+
* follows points, `'keyboard'` moves by items.
|
|
1744
|
+
*/
|
|
1745
|
+
export declare type SensorType = 'pointer' | 'keyboard';
|
|
1746
|
+
|
|
1747
|
+
/** A width and a height, in px. */
|
|
1748
|
+
export declare interface Size {
|
|
1749
|
+
/** Width in px. */
|
|
1750
|
+
width: number;
|
|
1751
|
+
/** Height in px. */
|
|
1752
|
+
height: number;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
/** Centers the overlay under the pointer instead of keeping the grab offset. */
|
|
1756
|
+
export declare const snapCenterToCursor: Modifier;
|
|
1757
|
+
|
|
1758
|
+
/**
|
|
1759
|
+
* Snaps the overlay to a grid, to the nearest cell: a number is the size of square cells;
|
|
1760
|
+
* options set each axis, where the grid starts and a glide between cells (`SnapToGridOptions`).
|
|
1761
|
+
*/
|
|
1762
|
+
export declare const snapToGrid: (size: number | SnapToGridOptions) => Modifier;
|
|
1763
|
+
|
|
1764
|
+
/** Options of `snapToGrid`. */
|
|
1765
|
+
export declare interface SnapToGridOptions {
|
|
1766
|
+
/** The cell's width in px. Without one (or 0), the drag moves freely along x. */
|
|
1767
|
+
x?: number;
|
|
1768
|
+
/** The cell's height in px. Without one (or 0), the drag moves freely along y: `{ y: 15 }` snaps the time of a calendar event only. */
|
|
1769
|
+
y?: number;
|
|
1770
|
+
/**
|
|
1771
|
+
* `'container'` (default): the overlay's top-left lands on grid lines drawn from the
|
|
1772
|
+
* container's top-left (`containerRect`: the sortable list or the parent element).
|
|
1773
|
+
* `'delta'`: the drag offset is rounded, keeping where the item started off-grid.
|
|
1774
|
+
*/
|
|
1775
|
+
origin?: 'container' | 'delta';
|
|
1776
|
+
/**
|
|
1777
|
+
* Glide the overlay between snapped positions (default 80ms). Collision still
|
|
1778
|
+
* uses the snapped position at once.
|
|
1779
|
+
*/
|
|
1780
|
+
smooth?: boolean | AnimationOptions;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/** What hovering an item does: `'sort'` makes room (the items between shift), `'swap'` exchanges the two items. */
|
|
1784
|
+
export declare type SortableBehavior = 'sort' | 'swap';
|
|
1785
|
+
|
|
1786
|
+
/**
|
|
1787
|
+
* A drop on a sortable list or tree. Its hooks run in order: `onBeforeDrop` decides,
|
|
1788
|
+
* `onDrop` is told, then the default action writes `result` into the `items` of every
|
|
1789
|
+
* list it names, and the overlay lands. `preventDefault()` in either hook skips that
|
|
1790
|
+
* write, so you can apply `result` yourself.
|
|
1791
|
+
*/
|
|
1792
|
+
export declare interface SortableDropEvent<T = unknown> {
|
|
1793
|
+
/** Keys of the dragged items. */
|
|
1794
|
+
keys: Key[];
|
|
1795
|
+
/** The items that land: the dragged ones, their copies (`mode: 'copy'`), or the item `createItem` made (`'insert'`). */
|
|
1796
|
+
items: T[];
|
|
1797
|
+
/** Keys that go through: all of them, unless the list or `onBeforeDrop` takes only some. */
|
|
1798
|
+
accepted: Key[];
|
|
1799
|
+
/** Keys that fly back to where they were. */
|
|
1800
|
+
rejected: Key[];
|
|
1801
|
+
/** Where the drag started: the list and index of the active item. `list` is `null` for a plain draggable from outside. */
|
|
1802
|
+
from: {
|
|
1803
|
+
list: Key | null;
|
|
1804
|
+
index: number;
|
|
1805
|
+
};
|
|
1806
|
+
/** `index` is -1 when nothing landed: the items left their lists (`e.source.remove()`, `dropOutside: 'remove'`). */
|
|
1807
|
+
to: {
|
|
1808
|
+
list: Key;
|
|
1809
|
+
index: number;
|
|
1810
|
+
};
|
|
1811
|
+
/** The drop stays in the list the drag started from. */
|
|
1812
|
+
sameList: boolean;
|
|
1813
|
+
/** What the drop does (see `DragMode`). */
|
|
1814
|
+
mode: DragMode;
|
|
1815
|
+
/**
|
|
1816
|
+
* `mode: 'swap'`: the item the dragged one was exchanged with. It moved the other way,
|
|
1817
|
+
* `from` the place the dragged item took (`to` above) `to` the one the dragged item
|
|
1818
|
+
* started at (`from` above); between lists, into the dragged item's list.
|
|
1819
|
+
*/
|
|
1820
|
+
partner?: {
|
|
1821
|
+
key: Key;
|
|
1822
|
+
item: T;
|
|
1823
|
+
from: {
|
|
1824
|
+
list: Key;
|
|
1825
|
+
index: number;
|
|
1826
|
+
};
|
|
1827
|
+
to: {
|
|
1828
|
+
list: Key;
|
|
1829
|
+
index: number;
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1832
|
+
/**
|
|
1833
|
+
* The new items of every list the drop changes, by list id: exactly what the default
|
|
1834
|
+
* write puts in their `items`, as new arrays. Moves, copies, created items, a partial
|
|
1835
|
+
* accept, both sides of a swap and items removed (`e.source.remove()` in a target
|
|
1836
|
+
* inside an item, a trash zone, `dropOutside: 'remove'`) are all in it; a list the drop
|
|
1837
|
+
* leaves as it is isn't. A tree's entry is a new root array: the nodes on the changed
|
|
1838
|
+
* paths are copies (`withChildren`), untouched subtrees are shared, your nodes are never
|
|
1839
|
+
* mutated. In `onBeforeDrop` it is the drop as it stands before the hook answers
|
|
1840
|
+
* (returning some keys changes it); `onDrop` gets the final one.
|
|
1841
|
+
*/
|
|
1842
|
+
result: ReadonlyMap<Key, T[]>;
|
|
1843
|
+
/**
|
|
1844
|
+
* Skips the default write, into every list in `result` (writing only some would lose
|
|
1845
|
+
* or duplicate items). Apply `result` yourself in `onDrop`, or before an async
|
|
1846
|
+
* `onBeforeDrop` resolves, and the overlay lands in the new order. Applied nowhere,
|
|
1847
|
+
* the lists stay as they were and the overlay flies back (copies and created items,
|
|
1848
|
+
* which have no place yet, fade out).
|
|
1849
|
+
*/
|
|
1850
|
+
preventDefault(): void;
|
|
1851
|
+
/** `preventDefault()` was called, in `onBeforeDrop` or `onDrop`. */
|
|
1852
|
+
readonly defaultPrevented: boolean;
|
|
1853
|
+
/** A drag from outside the page (`external`): what it carried, with its data (it was dropped). */
|
|
1854
|
+
external?: ExternalData;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/** A list's group: the lists that exchange items, and whether items may leave and enter this one. */
|
|
1858
|
+
export declare interface SortableGroupOptions<T = unknown> {
|
|
1859
|
+
/** Lists and trees with the same name exchange items. */
|
|
1860
|
+
name: string;
|
|
1861
|
+
/** Can items leave this list: move, copy (`'clone'`, a palette) or not at all. */
|
|
1862
|
+
pull?: boolean | 'clone';
|
|
1863
|
+
/**
|
|
1864
|
+
* Can items enter this list: `true` (default), `false`, a type or types the items must
|
|
1865
|
+
* have (as a drop target's `accept`: with `acceptMode`, all of them or some), or a
|
|
1866
|
+
* function of the drag.
|
|
1867
|
+
*/
|
|
1868
|
+
put?: boolean | string | string[] | ((context: SortablePutContext<T>) => boolean);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
/** Where the drop goes with `placeholder: 'indicator'`: the list doesn't move, you draw the line. */
|
|
1872
|
+
export declare interface SortableIndicator {
|
|
1873
|
+
/** Id of the list (or tree) the drop goes into. */
|
|
1874
|
+
list: Key;
|
|
1875
|
+
/** Insertion position in the list as rendered. */
|
|
1876
|
+
index: number;
|
|
1877
|
+
/** Item the indicator is attached to; `null` in an empty list. */
|
|
1878
|
+
key: Key | null;
|
|
1879
|
+
/**
|
|
1880
|
+
* Side of `key` the line goes on. `'inside'` (trees): the middle of a row that takes
|
|
1881
|
+
* the dragged nodes is hovered, the drop goes into it as its first child. `'swap'`
|
|
1882
|
+
* (`behavior: 'swap'`): `key` is the item the drop exchanges with; mark the item itself.
|
|
1883
|
+
*/
|
|
1884
|
+
side: 'before' | 'after' | 'inside' | 'swap';
|
|
1885
|
+
/** Trees: depth the dropped nodes get (roots are 0), e.g. to indent the line. */
|
|
1886
|
+
depth?: number;
|
|
1887
|
+
/** Trees: parent the dropped nodes get, `null` at the root level. */
|
|
1888
|
+
parentKey?: Key | null;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* Pass `id` or `item` (`id` wins when both are given). Sortable keys must come from the
|
|
1893
|
+
* data: an automatic id would change whenever the component is recreated (moved to
|
|
1894
|
+
* another list, recycled by a virtual list), and the drag would lose the item.
|
|
1895
|
+
*
|
|
1896
|
+
* Options but `canDrag` take a value, a ref or a getter (`overlay`, `dropAnimation`: a
|
|
1897
|
+
* value or a ref) and mean what they mean on `makeDraggable`. There is no `keyboardMode`:
|
|
1898
|
+
* the keyboard moves a sortable item by slots.
|
|
1899
|
+
*/
|
|
1900
|
+
export declare interface SortableItemOptions<TData = unknown> {
|
|
1901
|
+
/** Key of the item in its list. A getter keeps it current in virtual lists. */
|
|
1902
|
+
id?: MaybeReadonlyRefOrGetter<Key>;
|
|
1903
|
+
/**
|
|
1904
|
+
* The item this element renders, e.g. `() => props.task`. Its key comes from the
|
|
1905
|
+
* owning list's (or tree's) `getKey`, by default `item.id`.
|
|
1906
|
+
*/
|
|
1907
|
+
item?: MaybeReadonlyRefOrGetter<unknown>;
|
|
1908
|
+
/** Overlay component for this item; wins over the list's `overlay`. A ref switched mid-drag swaps it at once. */
|
|
1909
|
+
overlay?: MaybeReadonlyRef<Component | undefined>;
|
|
1910
|
+
/** How the overlay lands when a drag of this item ends; wins over the list's `dropAnimation`. Read at the drop. */
|
|
1911
|
+
dropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
1912
|
+
/** Modifiers for drags of this item, after the provider's; win over the list's `modifiers`. */
|
|
1913
|
+
modifiers?: MaybeReadonlyRefOrGetter<Modifier[] | undefined>;
|
|
1914
|
+
/** Locks drags of this item to one axis (`'x'`, `'y'`); wins over the list's `axis`. */
|
|
1915
|
+
axis?: MaybeReadonlyRefOrGetter<'x' | 'y' | undefined>;
|
|
1916
|
+
/** Element or selector inside the item that starts the drag (and gets the attributes). */
|
|
1917
|
+
handle?: MaybeReadonlyRefOrGetter<MaybeElement | string>;
|
|
1918
|
+
/** `true`: the item can't be dragged (as every item of a disabled list). */
|
|
1919
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
1920
|
+
/** Its type or types, for `group.put` rules and drop targets' `accept`. Default: the name of its list's group. */
|
|
1921
|
+
type?: MaybeReadonlyRefOrGetter<string | string[] | undefined>;
|
|
1922
|
+
/** Anything the drag should carry: events and drop targets read it as `active.data`. */
|
|
1923
|
+
data?: MaybeReadonlyRefOrGetter<TData>;
|
|
1924
|
+
/**
|
|
1925
|
+
* What people call the item: screen reader texts say it instead of its key (`Picked up
|
|
1926
|
+
* Tomato at position 2 of 5 in Garden`). Events carry it as `active.label` and in `items`.
|
|
1927
|
+
*/
|
|
1928
|
+
label?: MaybeReadonlyRefOrGetter<string | undefined>;
|
|
1929
|
+
/** Overrides its list's (or tree's) `activation` and the provider's. Read when a press starts. */
|
|
1930
|
+
activation?: MaybeReadonlyRefOrGetter<ActivationOptions | undefined>;
|
|
1931
|
+
/** Extra gate, e.g. drag only while a key is held. */
|
|
1932
|
+
canDrag?: (event: PointerEvent | KeyboardEvent) => boolean;
|
|
1933
|
+
/**
|
|
1934
|
+
* Set role/tabindex/aria-* attributes (default `true`), never overriding the user's
|
|
1935
|
+
* own. Live: turning it off removes what the library set.
|
|
1936
|
+
*/
|
|
1937
|
+
attributes?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
1938
|
+
/**
|
|
1939
|
+
* A mouse drag of it is the browser's own drag, which can leave the page (see
|
|
1940
|
+
* `DraggableOptions.native`). It carries the item too: the lists of its group in another
|
|
1941
|
+
* window of the app take it, and when one does, it leaves this list (`'move'`).
|
|
1942
|
+
*/
|
|
1943
|
+
native?: MaybeReadonlyRefOrGetter<boolean | NativeDragOptions | undefined>;
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/** What `makeSortableItem` returns. */
|
|
1947
|
+
export declare interface SortableItemReturn {
|
|
1948
|
+
/** This item is being dragged (also true for the other items of a multi-drag), or its overlay is still landing. */
|
|
1949
|
+
isDragging: ComputedRef<boolean>;
|
|
1950
|
+
/**
|
|
1951
|
+
* This element is a slot a dragged item will land in: the active item's, and in
|
|
1952
|
+
* multi-drag `'group'` mode the slots of the items travelling with it.
|
|
1953
|
+
*/
|
|
1954
|
+
isPlaceholder: ComputedRef<boolean>;
|
|
1955
|
+
/** It is in the provider's selection: a drag of one selected item carries them all. Set it to select or deselect. */
|
|
1956
|
+
selected: WritableComputedRef<boolean>;
|
|
1957
|
+
/**
|
|
1958
|
+
* Indicator mode: the list's `indicator` while it is attached to this item, `null`
|
|
1959
|
+
* otherwise. `side` says where the line goes; in trees `depth` and `parentKey` say
|
|
1960
|
+
* where the drop lands (`side: 'inside'`: into this item).
|
|
1961
|
+
*/
|
|
1962
|
+
indicator: ComputedRef<SortableIndicator | null>;
|
|
1963
|
+
/** Index in the rendered draft, -1 when unknown. */
|
|
1964
|
+
index: ComputedRef<number>;
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* A source of sortable items. A writable ref: the library writes each drop into it. A
|
|
1969
|
+
* read-only one (a getter, a readonly ref, a computed: an immutable store, server state,
|
|
1970
|
+
* a store changed only through actions): you apply each drop from `event.result`, after
|
|
1971
|
+
* `event.preventDefault()` (see `SortableDropEvent`).
|
|
1972
|
+
*/
|
|
1973
|
+
export declare type SortableItems<T> = Ref<T[]> | Readonly<Ref<readonly T[]>> | (() => readonly T[]);
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Options of `makeSortableList`. A component may make several lists (and trees): each
|
|
1977
|
+
* item rendered in it joins the innermost one whose element holds it.
|
|
1978
|
+
*
|
|
1979
|
+
* Options take a value, a ref or a getter (`overlay`, `overOverlay`, `dropAnimation`,
|
|
1980
|
+
* `overDropAnimation`, `animation`: a value or a ref) and are read when the list needs
|
|
1981
|
+
* them, so a change applies to the next drag at the latest.
|
|
1982
|
+
* Exceptions: `id` and `group` are read once, when the list is created; `items` is the
|
|
1983
|
+
* model itself; functions (`getKey`, `filter`, `clone`, `createItem`, the callbacks) are
|
|
1984
|
+
* passed as they are.
|
|
1985
|
+
*/
|
|
1986
|
+
export declare interface SortableListOptions<T> {
|
|
1987
|
+
/**
|
|
1988
|
+
* Source of truth. A writable ref takes the new array on drop, right after `onDrop`.
|
|
1989
|
+
* A read-only source (a getter, a readonly ref, a computed) can't: call
|
|
1990
|
+
* `event.preventDefault()` and apply `event.result` yourself. Development builds warn
|
|
1991
|
+
* about a drop left to the library there, which then changes nothing.
|
|
1992
|
+
*/
|
|
1993
|
+
items: SortableItems<T>;
|
|
1994
|
+
/** Default: `item.id`, or the item itself for primitives. Also keys `makeSortableItem({ item })`. */
|
|
1995
|
+
getKey?: (item: T) => Key;
|
|
1996
|
+
/**
|
|
1997
|
+
* Shows only the items it returns `true` for (a search, a tag): `items` (the returned
|
|
1998
|
+
* one) has them, and a drag sorts among them. The others keep their places in the source:
|
|
1999
|
+
* a drop writes the whole array, each hidden item still after the shown one it followed
|
|
2000
|
+
* (after the nearest that stayed, when that one moved). Reactive: what it reads (a query
|
|
2001
|
+
* ref) applies at once. `e.to.index` and `activeIndex` count the shown items.
|
|
2002
|
+
*/
|
|
2003
|
+
filter?: (item: T) => boolean;
|
|
2004
|
+
/** Default: `useId()`, stable between server and client render. Read once. */
|
|
2005
|
+
id?: Key;
|
|
2006
|
+
/** What people call the list: screen reader texts say it instead of its id (`position 2 of 5 in Garden`). */
|
|
2007
|
+
label?: MaybeReadonlyRefOrGetter<string | undefined>;
|
|
2008
|
+
/** Anything to tell about the list as a drop target: events carry it as `over.data` while a drag is over it. */
|
|
2009
|
+
data?: MaybeReadonlyRefOrGetter<unknown>;
|
|
2010
|
+
/**
|
|
2011
|
+
* How a press on this list's items starts a drag, instead of the provider's `activation`
|
|
2012
|
+
* (an item's own wins). Read when a press starts.
|
|
2013
|
+
*/
|
|
2014
|
+
activation?: MaybeReadonlyRefOrGetter<ActivationOptions | undefined>;
|
|
2015
|
+
/**
|
|
2016
|
+
* Overlay component for this list's items (an item's own `overlay` wins). It receives
|
|
2017
|
+
* `OverlayProps` and stays for the whole drag, also over other lists, unless the target
|
|
2018
|
+
* under the drag has an overlay of its own (`overOverlay`). A ref switched mid-drag
|
|
2019
|
+
* swaps it at once.
|
|
2020
|
+
*/
|
|
2021
|
+
overlay?: MaybeReadonlyRef<Component | undefined>;
|
|
2022
|
+
/**
|
|
2023
|
+
* What the overlay shows while a drag this list accepts is over it, whatever list it
|
|
2024
|
+
* comes from: a component that gets `OverlayProps` and the drag's own overlay as its
|
|
2025
|
+
* default slot (see `DroppableOptions.overOverlay`). Read live.
|
|
2026
|
+
*/
|
|
2027
|
+
overOverlay?: MaybeReadonlyRef<Component | undefined>;
|
|
2028
|
+
/**
|
|
2029
|
+
* How the overlay lands when a drag of this list's items ends, instead of the
|
|
2030
|
+
* provider's `dropAnimation` (an item's own wins; a drop target's wins over both).
|
|
2031
|
+
* Read at the drop.
|
|
2032
|
+
*/
|
|
2033
|
+
dropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
2034
|
+
/**
|
|
2035
|
+
* How the overlay lands when it is dropped into this list, whatever list it comes from:
|
|
2036
|
+
* wins over the dragged item's and the provider's `dropAnimation`. Read at the drop.
|
|
2037
|
+
*/
|
|
2038
|
+
overDropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
2039
|
+
/**
|
|
2040
|
+
* Modifiers for drags of this list's items, applied after the provider's `modifiers`
|
|
2041
|
+
* (an item's own `modifiers` win): e.g. `[restrictToVerticalAxis]` to keep a vertical
|
|
2042
|
+
* list's items on their axis. Read when the drag starts.
|
|
2043
|
+
*/
|
|
2044
|
+
modifiers?: MaybeReadonlyRefOrGetter<Modifier[] | undefined>;
|
|
2045
|
+
/**
|
|
2046
|
+
* Locks drags of this list's items to one axis: `'y'` for a vertical list, `'x'` for a
|
|
2047
|
+
* horizontal one (an item's own `axis` wins). The lock comes after the modifiers, so it
|
|
2048
|
+
* holds whatever they do. Read when the drag starts.
|
|
2049
|
+
*/
|
|
2050
|
+
axis?: MaybeReadonlyRefOrGetter<'x' | 'y' | undefined>;
|
|
2051
|
+
/** Lists with the same group name exchange items. Default: a group of its own. Read once. */
|
|
2052
|
+
group?: string | SortableGroupOptions<T>;
|
|
2053
|
+
/** Multi-drag of items of several types: `'all'` (default) or `'some'` must be accepted (`group.put`). */
|
|
2054
|
+
acceptMode?: MaybeReadonlyRefOrGetter<AcceptMode | undefined>;
|
|
2055
|
+
/** Default `'vertical'`. */
|
|
2056
|
+
strategy?: MaybeReadonlyRefOrGetter<SortableStrategy | undefined>;
|
|
2057
|
+
/**
|
|
2058
|
+
* `'swap'`: the dragged item exchanges places with the hovered one, live; moving back
|
|
2059
|
+
* onto it or off the lists reverts. Lists of one group that both swap exchange items
|
|
2060
|
+
* between them: the hovered item moves into the dragged one's place, so it must be
|
|
2061
|
+
* able to leave its list (`group.pull: true`) and enter the dragged item's
|
|
2062
|
+
* (`group.put`). Multi-drag sorts instead. Default `'sort'`.
|
|
2063
|
+
*/
|
|
2064
|
+
behavior?: MaybeReadonlyRefOrGetter<SortableBehavior | undefined>;
|
|
2065
|
+
/** `'indicator'`: the list doesn't move, `indicator` says where the drop goes. Default `'item'`. */
|
|
2066
|
+
placeholder?: MaybeReadonlyRefOrGetter<SortablePlaceholder | undefined>;
|
|
2067
|
+
/** Multi-drag mode of drags that start in this list. Default `'group'`. Read when the drag starts. */
|
|
2068
|
+
multiple?: MaybeReadonlyRefOrGetter<MultipleMode | undefined>;
|
|
2069
|
+
/** `false`: items can't be reordered inside this list (palettes). */
|
|
2070
|
+
sort?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
2071
|
+
/** Creates copies (`pull: 'clone'`, copy modifier key). Required for copying. */
|
|
2072
|
+
clone?: (item: T) => T;
|
|
2073
|
+
/**
|
|
2074
|
+
* Accepts plain draggables from outside: creates the item to insert. With the keyboard,
|
|
2075
|
+
* an arrow toward the list takes the draggable in (level with it, as moves between
|
|
2076
|
+
* lists go), and the created item then moves by slots like any other.
|
|
2077
|
+
*
|
|
2078
|
+
* A drag from outside the page (`external`) is asked twice: while it is held, for the
|
|
2079
|
+
* item that shows where it goes (only `active.external.fileTypes` and `types` are known
|
|
2080
|
+
* then), and at the drop, with its data (`active.external.ready`), for what is
|
|
2081
|
+
* inserted. A list of items inserts them all where the slot was: a file each.
|
|
2082
|
+
*/
|
|
2083
|
+
createItem?: (active: Active) => T | T[] | undefined;
|
|
2084
|
+
/**
|
|
2085
|
+
* Takes drags from outside the page: files, links, text (see `ExternalAccept`). The list
|
|
2086
|
+
* makes room for them as for a plain draggable, with `createItem`, which it needs. Items
|
|
2087
|
+
* of its group dragged in from another window of the app (`native`) need neither option:
|
|
2088
|
+
* they come in as themselves. A value, a ref or a getter, read live.
|
|
2089
|
+
*/
|
|
2090
|
+
external?: MaybeReadonlyRefOrGetter<ExternalAccept | undefined>;
|
|
2091
|
+
/**
|
|
2092
|
+
* A drop outside every target: keep the items where the placeholder is, cancel, or
|
|
2093
|
+
* remove them. Default `'placeholder'` (`'cancel'` with `placeholder: 'indicator'`).
|
|
2094
|
+
* Read at the drop.
|
|
2095
|
+
*/
|
|
2096
|
+
dropOutside?: MaybeReadonlyRefOrGetter<DropOutside | undefined>;
|
|
2097
|
+
/** FLIP animation of this list; default: the provider's `animation`. A value or a ref (a function is a custom animation). */
|
|
2098
|
+
animation?: MaybeReadonlyRef<LayoutAnimation | undefined>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Animates changes of `items` that no drag made: added, removed, moved and filtered
|
|
2101
|
+
* items (see `AutoAnimation`). Default: the provider's `animateChanges`, off unless set
|
|
2102
|
+
* there. Read when `items` changes.
|
|
2103
|
+
*/
|
|
2104
|
+
animateChanges?: MaybeReadonlyRefOrGetter<AutoAnimation | undefined>;
|
|
2105
|
+
/**
|
|
2106
|
+
* The list's own size follows its items: when a drag brings an item in or takes one out
|
|
2107
|
+
* (and at the drop, and for the changes `animateChanges` shows), it grows or shrinks to its new
|
|
2108
|
+
* size with `animation`'s duration and easing instead of jumping, and what is around it
|
|
2109
|
+
* moves along. Default `true`; `false` lets it jump. Read on every change.
|
|
2110
|
+
*/
|
|
2111
|
+
animateSize?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
2112
|
+
/** Overrides the provider's `autoScroll` for this list's scroll container. Read when the drag starts. */
|
|
2113
|
+
autoScroll?: MaybeReadonlyRefOrGetter<boolean | AutoScrollOptions | undefined>;
|
|
2114
|
+
/**
|
|
2115
|
+
* The element that takes drops for the list, default the list element itself: e.g. the
|
|
2116
|
+
* whole column around a short list of cards, so a card let go below the last one still
|
|
2117
|
+
* lands in the list (at its end). The items stay in the list element.
|
|
2118
|
+
*/
|
|
2119
|
+
dropzone?: MaybeElementRef;
|
|
2120
|
+
/** `true`: its items can't be dragged, and it takes no items. */
|
|
2121
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
2122
|
+
/**
|
|
2123
|
+
* Asked before a drop into this list, and before `dropOutside: 'remove'` takes its items
|
|
2124
|
+
* out: `false` rejects it (the items fly back), some keys accept only those. May be
|
|
2125
|
+
* async: the overlay waits where it was dropped. An error rejects the drop too. See
|
|
2126
|
+
* `SortableDropEvent` for `result` and `preventDefault`.
|
|
2127
|
+
*/
|
|
2128
|
+
onBeforeDrop?: (event: SortableDropEvent<T>) => MaybePromise<BeforeDropResult>;
|
|
2129
|
+
/**
|
|
2130
|
+
* Called once a drop into this list is accepted, before it is written: `items` still
|
|
2131
|
+
* holds the old order, `event.result` the new one. Synchronous: the write follows as it
|
|
2132
|
+
* returns, unless it called `event.preventDefault()`. Also called on the list the items
|
|
2133
|
+
* came from when they are removed (`to.index` is -1).
|
|
2134
|
+
*/
|
|
2135
|
+
onDrop?: (event: SortableDropEvent<T>) => void;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/** What `makeSortableList` returns. */
|
|
2139
|
+
export declare interface SortableListReturn<T> {
|
|
2140
|
+
/** The list's id: the `id` option, or the one made for it. */
|
|
2141
|
+
id: Key;
|
|
2142
|
+
/** Draft order: render this, not the source array. */
|
|
2143
|
+
items: ComputedRef<T[]>;
|
|
2144
|
+
/** A drag is over the list. */
|
|
2145
|
+
isOver: ComputedRef<boolean>;
|
|
2146
|
+
/** Something is being dragged and this list takes it. */
|
|
2147
|
+
isAccepting: ComputedRef<boolean>;
|
|
2148
|
+
/** Indicator mode: where the drop goes in this list; `null` when not here. */
|
|
2149
|
+
indicator: ComputedRef<SortableIndicator | null>;
|
|
2150
|
+
/**
|
|
2151
|
+
* The row a virtualizer must keep mounted: the slot while it is in this list (a copy, a
|
|
2152
|
+
* created item), otherwise the dragged item; `null` without a drag.
|
|
2153
|
+
*/
|
|
2154
|
+
activeKey: ComputedRef<Key | null>;
|
|
2155
|
+
/** Index of the active item in this list's draft, -1 when it isn't here. */
|
|
2156
|
+
activeIndex: ComputedRef<number>;
|
|
2157
|
+
/** Size of the dragged item at drag start: e.g. for the size of a virtual row it holds. */
|
|
2158
|
+
activeSize: ComputedRef<Size | null>;
|
|
2159
|
+
/** Animates layout changes the library didn't cause (e.g. a virtualizer re-measure). */
|
|
2160
|
+
captureLayout(): void;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
/**
|
|
2164
|
+
* How a drag shows where it goes: `'item'`, the dragged item's slot moves through the list;
|
|
2165
|
+
* `'indicator'`, the list stays as it is and `indicator` says where the drop goes (you draw the line).
|
|
2166
|
+
*/
|
|
2167
|
+
export declare type SortablePlaceholder = 'item' | 'indicator';
|
|
2168
|
+
|
|
2169
|
+
/**
|
|
2170
|
+
* A position in a sortable list, for `SensorDrag.place()` (and `moveItem` of
|
|
2171
|
+
* `@vue-dnd-kit/actions`). Lists only: trees place items by their own keys.
|
|
2172
|
+
*/
|
|
2173
|
+
export declare interface SortablePosition {
|
|
2174
|
+
/** Id of the list (`SortableListOptions.id`). Default: the list the item is in. */
|
|
2175
|
+
list?: Key;
|
|
2176
|
+
/**
|
|
2177
|
+
* Index the item ends up at, counted without the item itself (a multi-drag block
|
|
2178
|
+
* counts once). Clamped to the list; default: the end.
|
|
2179
|
+
*/
|
|
2180
|
+
index?: number;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/** What a function `group.put` is asked with: the items that would enter the list. */
|
|
2184
|
+
export declare interface SortablePutContext<T = unknown> {
|
|
2185
|
+
/** Keys of the items. */
|
|
2186
|
+
keys: Key[];
|
|
2187
|
+
/** The items (for a plain draggable, the item `createItem` made). */
|
|
2188
|
+
items: T[];
|
|
2189
|
+
/** The types of the items, together. */
|
|
2190
|
+
types: string[];
|
|
2191
|
+
/** Source list, `null` for external draggables. */
|
|
2192
|
+
from: Key | null;
|
|
2193
|
+
/** Id of the list asked. */
|
|
2194
|
+
to: Key;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
/** How a list lays out its items: a column (`'vertical'`), a row (`'horizontal'`) or a grid that wraps (`'grid'`). */
|
|
2198
|
+
export declare type SortableStrategy = 'vertical' | 'horizontal' | 'grid';
|
|
2199
|
+
|
|
2200
|
+
/**
|
|
2201
|
+
* Drop event of a tree. `index` is the position among the siblings under `parentKey`
|
|
2202
|
+
* (`from`: before the move; `to`: after it, with the node already removed from its
|
|
2203
|
+
* old place). `from.parentKey` is `null` for root nodes and for items from another list.
|
|
2204
|
+
* A multi-drag moves `keys` (each with its subtree) side by side: `from` is where the
|
|
2205
|
+
* node leading the drag was (the grabbed one, or the selected node it rides in), `to`
|
|
2206
|
+
* where the first of them lands. A copy (`mode: 'copy'`) leaves the nodes where they are
|
|
2207
|
+
* and inserts `items`, their copies; a plain draggable (`mode: 'insert'`) the node
|
|
2208
|
+
* `createItem` made.
|
|
2209
|
+
*/
|
|
2210
|
+
export declare interface SortableTreeDropEvent<T = unknown> extends SortableDropEvent<T> {
|
|
2211
|
+
/** Where the node leading the drag was: its tree, its index among its siblings, its parent. */
|
|
2212
|
+
from: {
|
|
2213
|
+
list: Key | null;
|
|
2214
|
+
index: number;
|
|
2215
|
+
parentKey: Key | null;
|
|
2216
|
+
};
|
|
2217
|
+
/** Where the first dropped node lands: its tree, its index among its new siblings, its new parent. */
|
|
2218
|
+
to: {
|
|
2219
|
+
list: Key;
|
|
2220
|
+
index: number;
|
|
2221
|
+
parentKey: Key | null;
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
/**
|
|
2226
|
+
* Options of `makeSortableTree`. A multi-drag moves the selected nodes as one block, each
|
|
2227
|
+
* with its subtree, to one place and depth (in document order); a selected node inside
|
|
2228
|
+
* another selected one rides along in its subtree. That goes for the grabbed node too
|
|
2229
|
+
* (as in VS Code): it stays inside the selected node it is in, which moves with its
|
|
2230
|
+
* subtree, while the overlay stays on the grabbed row. `canNest` and `maxDepth` apply to
|
|
2231
|
+
* the whole block.
|
|
2232
|
+
*
|
|
2233
|
+
* The other options mean what they mean on `makeSortableList`. They take a value, a ref
|
|
2234
|
+
* or a getter (`overlay`, `overOverlay`, `animation`, `dropAnimation`,
|
|
2235
|
+
* `overDropAnimation`: a value or a ref) and are read when the tree needs
|
|
2236
|
+
* them, so a change applies to the next drag at the latest. Exceptions: `id` and `group`
|
|
2237
|
+
* are read once, when the tree is created; `items` is the model itself; functions
|
|
2238
|
+
* (`getKey`, `getChildren`, `setChildren`, `canNest`, `clone`, `createItem`, the
|
|
2239
|
+
* callbacks) are passed as they are.
|
|
2240
|
+
*/
|
|
2241
|
+
export declare interface SortableTreeOptions<T> {
|
|
2242
|
+
/**
|
|
2243
|
+
* The root nodes. A writable ref: on drop the library gives the changed nodes their new
|
|
2244
|
+
* children (`setChildren`) and writes a new root array. A read-only source (a getter, a
|
|
2245
|
+
* readonly ref, a computed): call `event.preventDefault()` and apply `event.result`
|
|
2246
|
+
* yourself (as in `SortableListOptions.items`).
|
|
2247
|
+
*/
|
|
2248
|
+
items: SortableItems<T>;
|
|
2249
|
+
/** Default: `node.id`. Also keys `makeSortableItem({ item })`, copies and created nodes. */
|
|
2250
|
+
getKey?: (node: T) => Key;
|
|
2251
|
+
/** The children of a node. Default: `node.children`. */
|
|
2252
|
+
getChildren?: (node: T) => T[] | undefined;
|
|
2253
|
+
/** How the default write gives a node its new children. Default: `node.children = children`. */
|
|
2254
|
+
setChildren?: (node: T, children: T[]) => void;
|
|
2255
|
+
/**
|
|
2256
|
+
* A copy of `node` with `children`, for `event.result`: a new tree that leaves your
|
|
2257
|
+
* nodes as they are (the default write still goes through `setChildren`). Default:
|
|
2258
|
+
* `{ ...node }` given the children through `setChildren` (`{ ...node, children }`
|
|
2259
|
+
* without a `setChildren`). Pass it for class instances and nodes that need more
|
|
2260
|
+
* than a shallow copy.
|
|
2261
|
+
*/
|
|
2262
|
+
withChildren?: (node: T, children: T[]) => T;
|
|
2263
|
+
/** Default: `useId()`, stable between server and client render. Read once. */
|
|
2264
|
+
id?: Key;
|
|
2265
|
+
/** What people call the tree: screen reader texts say it instead of its id. */
|
|
2266
|
+
label?: MaybeReadonlyRefOrGetter<string | undefined>;
|
|
2267
|
+
/** Anything to tell about the tree as a drop target: events carry it as `over.data` while a drag is over it. */
|
|
2268
|
+
data?: MaybeReadonlyRefOrGetter<unknown>;
|
|
2269
|
+
/** How a press on this tree's rows starts a drag, instead of the provider's `activation` (a row's own wins). */
|
|
2270
|
+
activation?: MaybeReadonlyRefOrGetter<ActivationOptions | undefined>;
|
|
2271
|
+
/** Overlay component for this tree's rows (a row's own `overlay` wins). A ref switched mid-drag swaps it at once. */
|
|
2272
|
+
overlay?: MaybeReadonlyRef<Component | undefined>;
|
|
2273
|
+
/**
|
|
2274
|
+
* What the overlay shows while a drag this tree accepts is over it (see
|
|
2275
|
+
* `SortableListOptions.overOverlay`). Its `to` prop says where the drop would nest.
|
|
2276
|
+
*/
|
|
2277
|
+
overOverlay?: MaybeReadonlyRef<Component | undefined>;
|
|
2278
|
+
/** How the overlay lands when a drag of this tree's rows ends (see `SortableListOptions.dropAnimation`). */
|
|
2279
|
+
dropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
2280
|
+
/** How the overlay lands when it is dropped into this tree (see `SortableListOptions.overDropAnimation`). */
|
|
2281
|
+
overDropAnimation?: MaybeReadonlyRef<DropAnimation | undefined>;
|
|
2282
|
+
/**
|
|
2283
|
+
* Modifiers for drags of this tree's rows, applied after the provider's `modifiers` (a
|
|
2284
|
+
* row's own `modifiers` win): e.g. `[restrictToVerticalAxis]`. Read when the drag starts.
|
|
2285
|
+
* A locked axis still nests: the depth then comes from hovering the middle of a row.
|
|
2286
|
+
*/
|
|
2287
|
+
modifiers?: MaybeReadonlyRefOrGetter<Modifier[] | undefined>;
|
|
2288
|
+
/**
|
|
2289
|
+
* Locks drags of this tree's rows to one axis (a row's own `axis` wins), after the
|
|
2290
|
+
* modifiers. With `'y'` rows still nest: the depth then comes from hovering the middle of
|
|
2291
|
+
* a row. Read when the drag starts.
|
|
2292
|
+
*/
|
|
2293
|
+
axis?: MaybeReadonlyRefOrGetter<'x' | 'y' | undefined>;
|
|
2294
|
+
/** Lists and trees with the same group name exchange items. Default: a group of its own. Read once. */
|
|
2295
|
+
group?: string | SortableGroupOptions<T>;
|
|
2296
|
+
/** Multi-drag of items of several types: `'all'` (default) or `'some'` must be accepted (`group.put`). */
|
|
2297
|
+
acceptMode?: MaybeReadonlyRefOrGetter<AcceptMode | undefined>;
|
|
2298
|
+
/** Pixels of horizontal offset per depth level. Default 24. */
|
|
2299
|
+
indentation?: MaybeReadonlyRefOrGetter<number | undefined>;
|
|
2300
|
+
/** How the depth is chosen: horizontal offset, hovering the middle of a row, or both (default). */
|
|
2301
|
+
nesting?: MaybeReadonlyRefOrGetter<TreeNesting | undefined>;
|
|
2302
|
+
/**
|
|
2303
|
+
* `'item'` (default): the dragged node moves through the rows at its projected depth.
|
|
2304
|
+
* `'indicator'`: the tree doesn't move; `indicator` (on the tree and on each row's
|
|
2305
|
+
* `makeSortableItem`) says where the drop goes, with its `depth` and `parentKey`, and
|
|
2306
|
+
* you draw the line. Dropping outside then cancels.
|
|
2307
|
+
*/
|
|
2308
|
+
placeholder?: MaybeReadonlyRefOrGetter<SortablePlaceholder | undefined>;
|
|
2309
|
+
/** Deepest allowed depth (roots are 0). The dragged nodes' own descendants count. */
|
|
2310
|
+
maxDepth?: MaybeReadonlyRefOrGetter<number | undefined>;
|
|
2311
|
+
/** Whether `node` may go under `parent`; a multi-drag asks for every dragged node. */
|
|
2312
|
+
canNest?: (node: T, parent: T) => boolean;
|
|
2313
|
+
/** Keys of the nodes whose children are hidden. */
|
|
2314
|
+
collapsed?: MaybeReadonlyRefOrGetter<ReadonlySet<Key> | undefined>;
|
|
2315
|
+
/**
|
|
2316
|
+
* Creates copies (`group.pull: 'clone'`, the copy modifier key). Required for copying.
|
|
2317
|
+
* Return the copy with its whole subtree: a copied folder keeps its children. The copy
|
|
2318
|
+
* and each of its descendants need keys of their own (read with `getKey`), as every
|
|
2319
|
+
* node of a tree does.
|
|
2320
|
+
*/
|
|
2321
|
+
clone?: (node: T) => T;
|
|
2322
|
+
/**
|
|
2323
|
+
* Accepts plain draggables from outside: creates the node to insert, at the projected
|
|
2324
|
+
* position and depth (`canNest` and `maxDepth` apply to it). With the keyboard, an arrow
|
|
2325
|
+
* toward the tree takes the draggable in, level with the row it goes before, and the
|
|
2326
|
+
* arrow keys then move the node like any other. A drag from outside the page (`external`)
|
|
2327
|
+
* is asked twice, while it is held and at the drop (see the list's `createItem`); a
|
|
2328
|
+
* folder node with a child per file holds several files.
|
|
2329
|
+
*/
|
|
2330
|
+
createItem?: (active: Active) => T | undefined;
|
|
2331
|
+
/**
|
|
2332
|
+
* Takes drags from outside the page: files, links, text (see `ExternalAccept`), with
|
|
2333
|
+
* `createItem`. Nodes of its group dragged in from another window of the app come in as
|
|
2334
|
+
* themselves. A value, a ref or a getter, read live.
|
|
2335
|
+
*/
|
|
2336
|
+
external?: MaybeReadonlyRefOrGetter<ExternalAccept | undefined>;
|
|
2337
|
+
/**
|
|
2338
|
+
* A drop outside every target: keep the nodes where the placeholder is, cancel, or
|
|
2339
|
+
* remove them. Default `'placeholder'` (`'cancel'` with `placeholder: 'indicator'`).
|
|
2340
|
+
* Read at the drop.
|
|
2341
|
+
*/
|
|
2342
|
+
dropOutside?: MaybeReadonlyRefOrGetter<DropOutside | undefined>;
|
|
2343
|
+
/** FLIP animation of this tree; default: the provider's `animation`. A value or a ref (a function is a custom animation). */
|
|
2344
|
+
animation?: MaybeReadonlyRef<LayoutAnimation | undefined>;
|
|
2345
|
+
/**
|
|
2346
|
+
* As in `SortableListOptions`, for the visible rows: nodes added, removed or moved, and
|
|
2347
|
+
* the rows a node shows or hides as it expands or collapses (`collapsed`).
|
|
2348
|
+
*/
|
|
2349
|
+
animateChanges?: MaybeReadonlyRefOrGetter<AutoAnimation | undefined>;
|
|
2350
|
+
/** The tree's own size follows its rows, as a list's does (`animateSize`). Default `true`. */
|
|
2351
|
+
animateSize?: MaybeReadonlyRefOrGetter<boolean | undefined>;
|
|
2352
|
+
/** Overrides the provider's `autoScroll` for this tree's scroll container. Read when the drag starts. */
|
|
2353
|
+
autoScroll?: MaybeReadonlyRefOrGetter<boolean | AutoScrollOptions | undefined>;
|
|
2354
|
+
/** As in `SortableListOptions`: the element that takes drops for the tree, default the tree's own. */
|
|
2355
|
+
dropzone?: MaybeElementRef;
|
|
2356
|
+
/** `true`: its rows can't be dragged, and it takes no items. */
|
|
2357
|
+
disabled?: MaybeReadonlyRefOrGetter<boolean>;
|
|
2358
|
+
/** As in `SortableListOptions`. */
|
|
2359
|
+
onBeforeDrop?: (event: SortableTreeDropEvent<T>) => MaybePromise<BeforeDropResult>;
|
|
2360
|
+
/** As in `SortableListOptions`: before the write, which `event.preventDefault()` skips. */
|
|
2361
|
+
onDrop?: (event: SortableTreeDropEvent<T>) => void;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
/** What `makeSortableTree` returns. */
|
|
2365
|
+
export declare interface SortableTreeReturn<T> {
|
|
2366
|
+
/** The tree's id: the `id` option, or the one made for it. */
|
|
2367
|
+
id: Key;
|
|
2368
|
+
/** Visible nodes in draft order; the active node carries its projected depth. */
|
|
2369
|
+
items: ComputedRef<FlatNode<T>[]>;
|
|
2370
|
+
/** Where the active node would land, `null` when it isn't in this tree. */
|
|
2371
|
+
projected: ComputedRef<TreeProjection | null>;
|
|
2372
|
+
/** Indicator mode: where the drop goes, with its `depth` and `parentKey`; `null` when not here. */
|
|
2373
|
+
indicator: ComputedRef<SortableIndicator | null>;
|
|
2374
|
+
/** A drag is over the tree. */
|
|
2375
|
+
isOver: ComputedRef<boolean>;
|
|
2376
|
+
/** Something is being dragged and this tree takes it. */
|
|
2377
|
+
isAccepting: ComputedRef<boolean>;
|
|
2378
|
+
/**
|
|
2379
|
+
* The row a virtualizer must keep mounted: the slot while it is in this tree (the
|
|
2380
|
+
* dragged node, the selected node the grabbed one rides in, a copy, a created node),
|
|
2381
|
+
* otherwise the dragged node.
|
|
2382
|
+
*/
|
|
2383
|
+
activeKey: ComputedRef<Key | null>;
|
|
2384
|
+
/** Index of `activeKey` in `items`, -1 when it isn't here. */
|
|
2385
|
+
activeIndex: ComputedRef<number>;
|
|
2386
|
+
/** Size of the dragged row at drag start. */
|
|
2387
|
+
activeSize: ComputedRef<Size | null>;
|
|
2388
|
+
/** Animates layout changes the library didn't cause (e.g. a virtualizer re-measure). */
|
|
2389
|
+
captureLayout(): void;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* How a tree drag chooses its depth: `'offset'`, by how far it moves sideways
|
|
2394
|
+
* (`indentation` per level); `'hover'`, by hovering the middle of a row, which takes it as a
|
|
2395
|
+
* child; `'both'`.
|
|
2396
|
+
*/
|
|
2397
|
+
export declare type TreeNesting = 'offset' | 'hover' | 'both';
|
|
2398
|
+
|
|
2399
|
+
/** Where the dragged node would land in a tree. */
|
|
2400
|
+
export declare interface TreeProjection {
|
|
2401
|
+
/** The depth it would get (roots are 0). */
|
|
2402
|
+
depth: number;
|
|
2403
|
+
/** The node it would go under; `null` at the root. */
|
|
2404
|
+
parentKey: Key | null;
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
/** Read-only drag state for custom UI (valid-target highlighting, spinners, progress). */
|
|
2408
|
+
export declare const useDnD: () => DnDState;
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* The provider above this component, as an opaque handle for `provideDnDContext`: it
|
|
2412
|
+
* bridges the provider into shadow roots and separate Vue apps.
|
|
2413
|
+
*/
|
|
2414
|
+
export declare const useDnDContext: () => DnDContext;
|
|
2415
|
+
|
|
2416
|
+
/** Subscribes to the events of every drag under the provider, for as long as the calling component (or effect scope) lives. */
|
|
2417
|
+
export declare const useDnDMonitor: (monitor: DnDMonitor) => void;
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* Runs a sensor in the provider above for as long as the calling component (or effect
|
|
2421
|
+
* scope) lives, next to the provider's `sensors`. Its drag is cancelled when it unmounts.
|
|
2422
|
+
*/
|
|
2423
|
+
export declare function useSensor(sensor: Sensor): void;
|
|
2424
|
+
|
|
2425
|
+
export { }
|