@dnd-kit/abstract 0.0.3 → 0.0.4-beta-20240621030124
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/index.cjs +247 -168
- package/index.cjs.map +1 -1
- package/index.d.cts +445 -0
- package/index.d.ts +18 -17
- package/index.js +248 -169
- package/index.js.map +1 -1
- package/modifiers.cjs +27 -17
- package/modifiers.cjs.map +1 -1
- package/modifiers.d.cts +36 -0
- package/modifiers.js +27 -17
- package/modifiers.js.map +1 -1
- package/package.json +5 -5
package/index.d.cts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import * as _preact_signals_core from '@preact/signals-core';
|
|
2
|
+
import { Effect, CleanupFunction } from '@dnd-kit/state';
|
|
3
|
+
import { Coordinates, Shape, Position } from '@dnd-kit/geometry';
|
|
4
|
+
|
|
5
|
+
type Data = Record<string, any>;
|
|
6
|
+
type UniqueIdentifier = string | number;
|
|
7
|
+
type Type = Symbol | string | number;
|
|
8
|
+
|
|
9
|
+
interface Options {
|
|
10
|
+
/**
|
|
11
|
+
* A boolean indicating whether the entity should automatically be registered with the manager.
|
|
12
|
+
* @defaultValue true
|
|
13
|
+
*/
|
|
14
|
+
register?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface Input$2<T extends Data = Data> {
|
|
17
|
+
id: UniqueIdentifier;
|
|
18
|
+
data?: T | null;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
options?: Options;
|
|
21
|
+
effects?(): Effect[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.
|
|
25
|
+
* It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.
|
|
26
|
+
*
|
|
27
|
+
* @template T - The type of data associated with the entity.
|
|
28
|
+
*/
|
|
29
|
+
declare class Entity<T extends Data = Data> {
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of the `Entity` class.
|
|
32
|
+
*
|
|
33
|
+
* @param input - An object containing the initial properties of the entity.
|
|
34
|
+
* @param manager - The manager that controls the drag and drop operations.
|
|
35
|
+
*/
|
|
36
|
+
constructor(input: Input$2<T>, manager: DragDropManager | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* The manager that controls the drag and drop operations.
|
|
39
|
+
*/
|
|
40
|
+
accessor manager: DragDropManager | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The unique identifier of the entity.
|
|
43
|
+
*/
|
|
44
|
+
accessor id: UniqueIdentifier;
|
|
45
|
+
/**
|
|
46
|
+
* The data associated with the entity.
|
|
47
|
+
*/
|
|
48
|
+
accessor data: Data | null;
|
|
49
|
+
/**
|
|
50
|
+
* A boolean indicating whether the entity is disabled.
|
|
51
|
+
*/
|
|
52
|
+
accessor disabled: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* An array of effects that are applied to the entity.
|
|
55
|
+
*/
|
|
56
|
+
effects: () => Effect[];
|
|
57
|
+
/**
|
|
58
|
+
* A method that cleans up the entity when it is no longer needed.
|
|
59
|
+
* @returns void
|
|
60
|
+
*/
|
|
61
|
+
destroy(): void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Reactive class representing a registry for entities.
|
|
66
|
+
* @template T - The type of entries that the registry manages,
|
|
67
|
+
* for example, `Draggable` or `Droppable` entities.
|
|
68
|
+
*/
|
|
69
|
+
declare class EntityRegistry<T extends Entity> {
|
|
70
|
+
private map;
|
|
71
|
+
private cleanupFunctions;
|
|
72
|
+
/**
|
|
73
|
+
* Iterator for the EntityRegistry class.
|
|
74
|
+
* @returns An iterator for the values in the map.
|
|
75
|
+
*/
|
|
76
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
77
|
+
get value(): IterableIterator<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Checks if a entity with the given identifier exists in the registry.
|
|
80
|
+
* @param identifier - The unique identifier of the entity.
|
|
81
|
+
* @returns True if the entity exists, false otherwise.
|
|
82
|
+
*/
|
|
83
|
+
has(identifier: UniqueIdentifier): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves a entity from the registry using its identifier.
|
|
86
|
+
* @param identifier - The unique identifier of the entity.
|
|
87
|
+
* @returns The entity if it exists, undefined otherwise.
|
|
88
|
+
*/
|
|
89
|
+
get(identifier: UniqueIdentifier): T | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Registers a entity in the registry.
|
|
92
|
+
* @param key - The unique identifier of the entity.
|
|
93
|
+
* @param value - The entity to register.
|
|
94
|
+
* @returns A function that unregisters the entity.
|
|
95
|
+
*/
|
|
96
|
+
register: (key: UniqueIdentifier, value: T) => (() => void) | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Unregisters an entity from the registry.
|
|
99
|
+
* @param key - The unique identifier of the entity.
|
|
100
|
+
* @param value - The entity instance to unregister.
|
|
101
|
+
*/
|
|
102
|
+
unregister: (key: UniqueIdentifier, value: T) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Destroys all entries in the registry and clears the registry.
|
|
105
|
+
*/
|
|
106
|
+
destroy(): void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type PluginOptions = Record<string, any>;
|
|
110
|
+
interface PluginConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends Plugin<T> = Plugin<T>, V extends PluginOptions = InferPluginOptions<U>> {
|
|
111
|
+
new (manager: T, options?: V): U;
|
|
112
|
+
}
|
|
113
|
+
type PluginDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends Plugin<T> = Plugin<T>, V extends PluginConstructor<T, U> = PluginConstructor<T, U>> = {
|
|
114
|
+
plugin: V;
|
|
115
|
+
options?: InferPluginOptions<U>;
|
|
116
|
+
};
|
|
117
|
+
type Plugins<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (PluginConstructor<T> | PluginDescriptor<T>)[];
|
|
118
|
+
type InferPluginOptions<P> = P extends PluginConstructor<any, any, infer T> ? T : P extends Plugin<any, infer T> ? T : never;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* An abstract plugin class that can be extended to implement custom
|
|
122
|
+
* functionality that augments the `DragDropManager`'s core capabilities.
|
|
123
|
+
*/
|
|
124
|
+
declare abstract class Plugin<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends PluginOptions = PluginOptions> {
|
|
125
|
+
manager: T;
|
|
126
|
+
options?: U | undefined;
|
|
127
|
+
constructor(manager: T, options?: U | undefined);
|
|
128
|
+
/**
|
|
129
|
+
* Whether the plugin instance is disabled.
|
|
130
|
+
* Triggers effects when accessed.
|
|
131
|
+
*/
|
|
132
|
+
accessor disabled: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Enable a disabled plugin instance.
|
|
135
|
+
* Triggers effects.
|
|
136
|
+
*/
|
|
137
|
+
enable(): void;
|
|
138
|
+
/**
|
|
139
|
+
* Disable an enabled plugin instance.
|
|
140
|
+
* Triggers effects.
|
|
141
|
+
*/
|
|
142
|
+
disable(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the plugin instance is disabled.
|
|
145
|
+
* Does not trigger effects when accessed.
|
|
146
|
+
*/
|
|
147
|
+
isDisabled(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Configure a plugin instance with new options.
|
|
150
|
+
*/
|
|
151
|
+
configure(options?: U): void;
|
|
152
|
+
/**
|
|
153
|
+
* Destroy a plugin instance.
|
|
154
|
+
*/
|
|
155
|
+
destroy(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Configure a plugin constructor with options.
|
|
158
|
+
* This method is used to configure the options that the
|
|
159
|
+
* plugin constructor will use to create plugin instances.
|
|
160
|
+
*/
|
|
161
|
+
static configure(options: PluginOptions): PluginDescriptor<any, any, any>;
|
|
162
|
+
}
|
|
163
|
+
declare class CorePlugin<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends PluginOptions = PluginOptions> extends Plugin<T, U> {
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare class PluginRegistry<T extends DragDropManager<any, any>, W extends PluginConstructor<T> = PluginConstructor<T>, U extends Plugin<T> = InstanceType<W>> {
|
|
167
|
+
#private;
|
|
168
|
+
private manager;
|
|
169
|
+
private instances;
|
|
170
|
+
constructor(manager: T);
|
|
171
|
+
get values(): U[];
|
|
172
|
+
set values(entries: Plugins<T>);
|
|
173
|
+
get<X extends W>(plugin: X): InstanceType<X> | undefined;
|
|
174
|
+
register<X extends W>(plugin: X, options?: InferPluginOptions<X>): InstanceType<X>;
|
|
175
|
+
unregister<X extends W>(plugin: X): void;
|
|
176
|
+
destroy(): void;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare function configure<T extends PluginConstructor<any, any, any>, V extends PluginOptions = InferPluginOptions<T>>(plugin: T, options: V): PluginDescriptor<any, any, T>;
|
|
180
|
+
declare function configurator<T extends PluginConstructor<any, any, any>>(plugin: T): (options: InferPluginOptions<T>) => PluginDescriptor<any, any, T>;
|
|
181
|
+
declare function descriptor<T extends PluginConstructor<any, any, any>>(plugin: T | PluginDescriptor<any, any, T>): PluginDescriptor<any, any, T>;
|
|
182
|
+
|
|
183
|
+
type ModifierOptions = PluginOptions;
|
|
184
|
+
declare class Modifier<T extends DragDropManager<any, any> = DragDropManager, U extends ModifierOptions = ModifierOptions> extends Plugin<T, U> {
|
|
185
|
+
manager: T;
|
|
186
|
+
options?: U | undefined;
|
|
187
|
+
constructor(manager: T, options?: U | undefined);
|
|
188
|
+
apply(operation: T['dragOperation']): Coordinates;
|
|
189
|
+
}
|
|
190
|
+
type ModifierConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Modifier<T, any>>;
|
|
191
|
+
type ModifierDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;
|
|
192
|
+
type Modifiers<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];
|
|
193
|
+
|
|
194
|
+
type SensorOptions = PluginOptions;
|
|
195
|
+
declare abstract class Sensor<T extends DragDropManager<any, any> = DragDropManager, U extends SensorOptions = SensorOptions> extends Plugin<T, U> {
|
|
196
|
+
manager: T;
|
|
197
|
+
options?: U | undefined;
|
|
198
|
+
constructor(manager: T, options?: U | undefined);
|
|
199
|
+
/**
|
|
200
|
+
* Bind the sensor to a draggable source, and optionally pass
|
|
201
|
+
* in sensor options to override the default sensor options
|
|
202
|
+
* for this draggable source only.
|
|
203
|
+
*/
|
|
204
|
+
abstract bind(source: Draggable, options?: U): CleanupFunction;
|
|
205
|
+
}
|
|
206
|
+
type SensorConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Sensor<T>>;
|
|
207
|
+
type SensorDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;
|
|
208
|
+
type Sensors<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (SensorConstructor<T> | SensorDescriptor<T>)[];
|
|
209
|
+
|
|
210
|
+
interface Input$1<T extends Data = Data> extends Input$2<T> {
|
|
211
|
+
type?: Type;
|
|
212
|
+
modifiers?: Modifiers;
|
|
213
|
+
sensors?: Sensors;
|
|
214
|
+
}
|
|
215
|
+
declare class Draggable<T extends Data = Data> extends Entity<T> {
|
|
216
|
+
#private;
|
|
217
|
+
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: DragDropManager | undefined);
|
|
218
|
+
sensors: Sensors | undefined;
|
|
219
|
+
set modifiers(modifiers: Modifiers | undefined);
|
|
220
|
+
get modifiers(): Modifier[] | undefined;
|
|
221
|
+
accessor type: Type | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* A boolean indicating whether the draggable item is the source of a drag operation.
|
|
224
|
+
*/
|
|
225
|
+
get isDragSource(): boolean;
|
|
226
|
+
destroy(): void;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
declare enum CollisionPriority {
|
|
230
|
+
Lowest = 0,
|
|
231
|
+
Low = 1,
|
|
232
|
+
Normal = 2,
|
|
233
|
+
High = 3,
|
|
234
|
+
Highest = 4
|
|
235
|
+
}
|
|
236
|
+
interface Collision {
|
|
237
|
+
id: UniqueIdentifier;
|
|
238
|
+
priority: CollisionPriority | number;
|
|
239
|
+
value: number;
|
|
240
|
+
}
|
|
241
|
+
type Collisions = Collision[];
|
|
242
|
+
interface CollisionDetectorInput<T extends Draggable = Draggable, U extends Droppable = Droppable> {
|
|
243
|
+
droppable: U;
|
|
244
|
+
dragOperation: DragOperation<T, U>;
|
|
245
|
+
}
|
|
246
|
+
type CollisionDetector = <T extends Draggable = Draggable, U extends Droppable = Droppable>(input: CollisionDetectorInput<T, U>) => Collision | null;
|
|
247
|
+
|
|
248
|
+
declare class CollisionObserver<T extends Draggable = Draggable, U extends Droppable = Droppable, V extends DragDropManager<T, U> = DragDropManager<T, U>> extends Plugin<V> {
|
|
249
|
+
#private;
|
|
250
|
+
constructor(manager: V);
|
|
251
|
+
forceUpdateCount: _preact_signals_core.Signal<number>;
|
|
252
|
+
forceUpdate(refresh?: boolean): void;
|
|
253
|
+
computeCollisions(entries?: Droppable[], collisionDetector?: CollisionDetector): Collisions;
|
|
254
|
+
get collisions(): Collisions;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Sort collisions from greatest to smallest priority
|
|
259
|
+
* Collisions of equal priority are sorted from greatest to smallest value
|
|
260
|
+
*/
|
|
261
|
+
declare function sortCollisions(a: Collision, b: Collision): number;
|
|
262
|
+
|
|
263
|
+
interface Input<T extends Data = Data> extends Input$2<T> {
|
|
264
|
+
accept?: Type | Type[] | ((source: Draggable) => boolean);
|
|
265
|
+
collisionPriority?: CollisionPriority | number;
|
|
266
|
+
collisionDetector: CollisionDetector;
|
|
267
|
+
type?: Type;
|
|
268
|
+
}
|
|
269
|
+
declare class Droppable<T extends Data = Data> extends Entity<T> {
|
|
270
|
+
constructor({ accept, collisionDetector, collisionPriority, type, ...input }: Input<T>, manager: DragDropManager | undefined);
|
|
271
|
+
/**
|
|
272
|
+
* An array of types that are compatible with the droppable.
|
|
273
|
+
*/
|
|
274
|
+
accessor accept: Type | Type[] | ((draggable: Draggable) => boolean) | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* The type of the droppable.
|
|
277
|
+
*/
|
|
278
|
+
accessor type: Type | undefined;
|
|
279
|
+
/**
|
|
280
|
+
* Checks whether or not the droppable accepts a given draggable.
|
|
281
|
+
*
|
|
282
|
+
* @param {Draggable} draggable
|
|
283
|
+
* @returns {boolean}
|
|
284
|
+
*/
|
|
285
|
+
accepts(draggable: Draggable): boolean;
|
|
286
|
+
accessor collisionDetector: CollisionDetector;
|
|
287
|
+
accessor collisionPriority: number;
|
|
288
|
+
accessor shape: Shape | undefined;
|
|
289
|
+
get isDropTarget(): boolean;
|
|
290
|
+
refreshShape(): void;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare class DragDropRegistry<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> {
|
|
294
|
+
constructor(manager: V);
|
|
295
|
+
draggables: EntityRegistry<T>;
|
|
296
|
+
droppables: EntityRegistry<U>;
|
|
297
|
+
plugins: PluginRegistry<V, PluginConstructor<V>>;
|
|
298
|
+
sensors: PluginRegistry<V, SensorConstructor<V>>;
|
|
299
|
+
modifiers: PluginRegistry<V, ModifierConstructor<V>>;
|
|
300
|
+
register(input: Entity): () => void;
|
|
301
|
+
register(input: Draggable): () => void;
|
|
302
|
+
register(input: Droppable): () => void;
|
|
303
|
+
register(input: SensorConstructor, options?: SensorOptions): Sensor;
|
|
304
|
+
register(input: ModifierConstructor): Modifier;
|
|
305
|
+
register(input: PluginConstructor, options?: PluginOptions): Plugin;
|
|
306
|
+
unregister(input: Entity): CleanupFunction;
|
|
307
|
+
unregister(input: Draggable): CleanupFunction;
|
|
308
|
+
unregister(input: Droppable): CleanupFunction;
|
|
309
|
+
unregister(input: SensorConstructor): CleanupFunction;
|
|
310
|
+
unregister(input: ModifierConstructor): CleanupFunction;
|
|
311
|
+
unregister(input: PluginConstructor): CleanupFunction;
|
|
312
|
+
destroy(): void;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare enum Status {
|
|
316
|
+
Idle = "idle",
|
|
317
|
+
Initializing = "initializing",
|
|
318
|
+
Dragging = "dragging",
|
|
319
|
+
Dropped = "dropped"
|
|
320
|
+
}
|
|
321
|
+
type Serializable = {
|
|
322
|
+
[key: string]: string | number | null | Serializable | Serializable[];
|
|
323
|
+
};
|
|
324
|
+
interface DragOperation<T extends Draggable = Draggable, U extends Droppable = Droppable> {
|
|
325
|
+
activatorEvent: Event | null;
|
|
326
|
+
canceled: boolean;
|
|
327
|
+
position: Position;
|
|
328
|
+
transform: Coordinates;
|
|
329
|
+
status: {
|
|
330
|
+
current: Status;
|
|
331
|
+
initialized: boolean;
|
|
332
|
+
initializing: boolean;
|
|
333
|
+
dragging: boolean;
|
|
334
|
+
dragended: boolean;
|
|
335
|
+
dropped: boolean;
|
|
336
|
+
idle: boolean;
|
|
337
|
+
};
|
|
338
|
+
get shape(): {
|
|
339
|
+
initial: Shape;
|
|
340
|
+
current: Shape;
|
|
341
|
+
} | null;
|
|
342
|
+
set shape(value: Shape | null);
|
|
343
|
+
source: T | null;
|
|
344
|
+
target: U | null;
|
|
345
|
+
data?: Serializable;
|
|
346
|
+
}
|
|
347
|
+
type DragActions<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> = ReturnType<typeof DragOperationManager<T, U, V>>['actions'];
|
|
348
|
+
declare function DragOperationManager<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>>(manager: V): {
|
|
349
|
+
operation: DragOperation<T, U>;
|
|
350
|
+
actions: {
|
|
351
|
+
setDragSource(identifier: UniqueIdentifier): void;
|
|
352
|
+
setDropTarget(identifier: UniqueIdentifier | null | undefined): Promise<void>;
|
|
353
|
+
start({ event, coordinates }: {
|
|
354
|
+
event: Event;
|
|
355
|
+
coordinates: Coordinates;
|
|
356
|
+
}): void;
|
|
357
|
+
move({ by, to, cancelable, }: {
|
|
358
|
+
by: Coordinates;
|
|
359
|
+
to?: undefined;
|
|
360
|
+
cancelable?: boolean;
|
|
361
|
+
} | {
|
|
362
|
+
by?: undefined;
|
|
363
|
+
to: Coordinates;
|
|
364
|
+
cancelable?: boolean;
|
|
365
|
+
}): void;
|
|
366
|
+
stop({ canceled: eventCanceled }?: {
|
|
367
|
+
canceled?: boolean;
|
|
368
|
+
}): void;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
type Events = Record<string, (...args: any[]) => void>;
|
|
373
|
+
type Preventable<T> = T & {
|
|
374
|
+
cancelable: boolean;
|
|
375
|
+
defaultPrevented: boolean;
|
|
376
|
+
preventDefault(): void;
|
|
377
|
+
};
|
|
378
|
+
declare class Monitor<T extends Events> {
|
|
379
|
+
private registry;
|
|
380
|
+
addEventListener<U extends keyof T>(name: U, handler: T[U]): () => void;
|
|
381
|
+
removeEventListener(name: keyof T, handler: T[keyof T]): void;
|
|
382
|
+
protected dispatch<U extends keyof T>(name: U, ...args: any[]): void;
|
|
383
|
+
}
|
|
384
|
+
type DragDropEvents<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> = {
|
|
385
|
+
collision(event: Preventable<{
|
|
386
|
+
collisions: Collisions;
|
|
387
|
+
}>, manager: V): void;
|
|
388
|
+
beforedragstart(event: Preventable<{
|
|
389
|
+
operation: DragOperation<T, U>;
|
|
390
|
+
}>, manager: V): void;
|
|
391
|
+
dragstart(event: {
|
|
392
|
+
cancelable: false;
|
|
393
|
+
operation: DragOperation<T, U>;
|
|
394
|
+
}, manager: V): void;
|
|
395
|
+
dragmove(event: Preventable<{
|
|
396
|
+
operation: DragOperation<T, U>;
|
|
397
|
+
to?: Coordinates;
|
|
398
|
+
by?: Coordinates;
|
|
399
|
+
}>, manager: V): void;
|
|
400
|
+
dragover(event: Preventable<{
|
|
401
|
+
operation: DragOperation<T, U>;
|
|
402
|
+
}>, manager: V): void;
|
|
403
|
+
dragend(event: {
|
|
404
|
+
operation: DragOperation<T, U>;
|
|
405
|
+
canceled: boolean;
|
|
406
|
+
suspend(): {
|
|
407
|
+
resume(): void;
|
|
408
|
+
abort(): void;
|
|
409
|
+
};
|
|
410
|
+
}, manager: V): void;
|
|
411
|
+
};
|
|
412
|
+
declare class DragDropMonitor<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> extends Monitor<DragDropEvents<T, U, V>> {
|
|
413
|
+
private manager;
|
|
414
|
+
constructor(manager: V);
|
|
415
|
+
dispatch<Key extends keyof DragDropEvents<T, U, V>>(type: Key, event: Parameters<DragDropEvents<T, U, V>[Key]>[0]): void;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
interface Renderer {
|
|
419
|
+
get rendering(): Promise<void>;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
type DragDropManagerInput<T extends DragDropManager<any, any>> = {
|
|
423
|
+
plugins?: Plugins<T>;
|
|
424
|
+
sensors?: Sensors<T>;
|
|
425
|
+
modifiers?: Modifiers<T>;
|
|
426
|
+
renderer?: Renderer;
|
|
427
|
+
};
|
|
428
|
+
declare class DragDropManager<T extends Draggable = Draggable, U extends Droppable = Droppable> {
|
|
429
|
+
actions: DragActions<T, U, DragDropManager<T, U>>;
|
|
430
|
+
collisionObserver: CollisionObserver<T, U>;
|
|
431
|
+
dragOperation: DragOperation<T, U>;
|
|
432
|
+
monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;
|
|
433
|
+
registry: DragDropRegistry<T, U, DragDropManager<T, U>>;
|
|
434
|
+
renderer: Renderer;
|
|
435
|
+
constructor(config?: DragDropManagerInput<any>);
|
|
436
|
+
get plugins(): Plugin<any>[];
|
|
437
|
+
set plugins(plugins: Plugins<any>);
|
|
438
|
+
get modifiers(): Modifier<any>[];
|
|
439
|
+
set modifiers(modifiers: Modifiers<any>);
|
|
440
|
+
get sensors(): Sensor<any>[];
|
|
441
|
+
set sensors(sensors: Sensors<any>);
|
|
442
|
+
destroy(): void;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export { type Collision, type CollisionDetector, CollisionPriority, CorePlugin, type Data, type DragDropEvents, DragDropManager, type DragDropManagerInput, type DragOperation, DragOperationManager, Status as DragOperationStatus, Draggable, type Input$1 as DraggableInput, Droppable, type Input as DroppableInput, Entity, Modifier, type ModifierConstructor, type Modifiers, Plugin, type PluginConstructor, type PluginDescriptor, type PluginOptions, PluginRegistry, type Plugins, type Renderer, Sensor, type SensorConstructor, type SensorDescriptor, type SensorOptions, type Sensors, type Type, type UniqueIdentifier, configurator, configure, descriptor, sortCollisions };
|
package/index.d.ts
CHANGED
|
@@ -33,20 +33,23 @@ declare class Entity<T extends Data = Data> {
|
|
|
33
33
|
* @param input - An object containing the initial properties of the entity.
|
|
34
34
|
* @param manager - The manager that controls the drag and drop operations.
|
|
35
35
|
*/
|
|
36
|
-
constructor(input: Input$2<T>, manager: DragDropManager);
|
|
37
|
-
|
|
36
|
+
constructor(input: Input$2<T>, manager: DragDropManager | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* The manager that controls the drag and drop operations.
|
|
39
|
+
*/
|
|
40
|
+
accessor manager: DragDropManager | undefined;
|
|
38
41
|
/**
|
|
39
42
|
* The unique identifier of the entity.
|
|
40
43
|
*/
|
|
41
|
-
id: UniqueIdentifier;
|
|
44
|
+
accessor id: UniqueIdentifier;
|
|
42
45
|
/**
|
|
43
46
|
* The data associated with the entity.
|
|
44
47
|
*/
|
|
45
|
-
data: Data | null;
|
|
48
|
+
accessor data: Data | null;
|
|
46
49
|
/**
|
|
47
50
|
* A boolean indicating whether the entity is disabled.
|
|
48
51
|
*/
|
|
49
|
-
disabled: boolean;
|
|
52
|
+
accessor disabled: boolean;
|
|
50
53
|
/**
|
|
51
54
|
* An array of effects that are applied to the entity.
|
|
52
55
|
*/
|
|
@@ -126,7 +129,7 @@ declare abstract class Plugin<T extends DragDropManager<any, any> = DragDropMana
|
|
|
126
129
|
* Whether the plugin instance is disabled.
|
|
127
130
|
* Triggers effects when accessed.
|
|
128
131
|
*/
|
|
129
|
-
disabled: boolean;
|
|
132
|
+
accessor disabled: boolean;
|
|
130
133
|
/**
|
|
131
134
|
* Enable a disabled plugin instance.
|
|
132
135
|
* Triggers effects.
|
|
@@ -211,12 +214,11 @@ interface Input$1<T extends Data = Data> extends Input$2<T> {
|
|
|
211
214
|
}
|
|
212
215
|
declare class Draggable<T extends Data = Data> extends Entity<T> {
|
|
213
216
|
#private;
|
|
214
|
-
manager: DragDropManager;
|
|
215
|
-
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: DragDropManager);
|
|
217
|
+
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: DragDropManager | undefined);
|
|
216
218
|
sensors: Sensors | undefined;
|
|
217
219
|
set modifiers(modifiers: Modifiers | undefined);
|
|
218
220
|
get modifiers(): Modifier[] | undefined;
|
|
219
|
-
type: Type | undefined;
|
|
221
|
+
accessor type: Type | undefined;
|
|
220
222
|
/**
|
|
221
223
|
* A boolean indicating whether the draggable item is the source of a drag operation.
|
|
222
224
|
*/
|
|
@@ -265,16 +267,15 @@ interface Input<T extends Data = Data> extends Input$2<T> {
|
|
|
265
267
|
type?: Type;
|
|
266
268
|
}
|
|
267
269
|
declare class Droppable<T extends Data = Data> extends Entity<T> {
|
|
268
|
-
manager: DragDropManager;
|
|
269
|
-
constructor({ accept, collisionDetector, collisionPriority, type, ...input }: Input<T>, manager: DragDropManager);
|
|
270
|
+
constructor({ accept, collisionDetector, collisionPriority, type, ...input }: Input<T>, manager: DragDropManager | undefined);
|
|
270
271
|
/**
|
|
271
272
|
* An array of types that are compatible with the droppable.
|
|
272
273
|
*/
|
|
273
|
-
accept: Type | Type[] | ((draggable: Draggable) => boolean) | undefined;
|
|
274
|
+
accessor accept: Type | Type[] | ((draggable: Draggable) => boolean) | undefined;
|
|
274
275
|
/**
|
|
275
276
|
* The type of the droppable.
|
|
276
277
|
*/
|
|
277
|
-
type: Type | undefined;
|
|
278
|
+
accessor type: Type | undefined;
|
|
278
279
|
/**
|
|
279
280
|
* Checks whether or not the droppable accepts a given draggable.
|
|
280
281
|
*
|
|
@@ -282,9 +283,9 @@ declare class Droppable<T extends Data = Data> extends Entity<T> {
|
|
|
282
283
|
* @returns {boolean}
|
|
283
284
|
*/
|
|
284
285
|
accepts(draggable: Draggable): boolean;
|
|
285
|
-
collisionDetector: CollisionDetector;
|
|
286
|
-
collisionPriority: number;
|
|
287
|
-
shape: Shape | undefined;
|
|
286
|
+
accessor collisionDetector: CollisionDetector;
|
|
287
|
+
accessor collisionPriority: number;
|
|
288
|
+
accessor shape: Shape | undefined;
|
|
288
289
|
get isDropTarget(): boolean;
|
|
289
290
|
refreshShape(): void;
|
|
290
291
|
}
|
|
@@ -441,4 +442,4 @@ declare class DragDropManager<T extends Draggable = Draggable, U extends Droppab
|
|
|
441
442
|
destroy(): void;
|
|
442
443
|
}
|
|
443
444
|
|
|
444
|
-
export { Collision, CollisionDetector, CollisionPriority, CorePlugin, Data, DragDropEvents, DragDropManager, DragDropManagerInput, DragOperation, DragOperationManager, Status as DragOperationStatus, Draggable, Input$1 as DraggableInput, Droppable, Input as DroppableInput, Entity, Modifier, ModifierConstructor, Modifiers, Plugin, PluginConstructor, PluginDescriptor, PluginOptions, PluginRegistry, Plugins, Renderer, Sensor, SensorConstructor, SensorDescriptor, SensorOptions, Sensors, Type, UniqueIdentifier, configurator, configure, descriptor, sortCollisions };
|
|
445
|
+
export { type Collision, type CollisionDetector, CollisionPriority, CorePlugin, type Data, type DragDropEvents, DragDropManager, type DragDropManagerInput, type DragOperation, DragOperationManager, Status as DragOperationStatus, Draggable, type Input$1 as DraggableInput, Droppable, type Input as DroppableInput, Entity, Modifier, type ModifierConstructor, type Modifiers, Plugin, type PluginConstructor, type PluginDescriptor, type PluginOptions, PluginRegistry, type Plugins, type Renderer, Sensor, type SensorConstructor, type SensorDescriptor, type SensorOptions, type Sensors, type Type, type UniqueIdentifier, configurator, configure, descriptor, sortCollisions };
|