@vuu-ui/vuu-utils 3.1.0-beta.2 → 3.1.0-beta.4
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/package.json +10 -8
- package/src/index.js +4 -4
- package/src/vendor/@dnd-kit/abstract/index.d.ts +1279 -0
- package/src/vendor/@dnd-kit/abstract/index.js +1472 -0
- package/src/vendor/@dnd-kit/abstract/index.js.map +1 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.d.ts +134 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.js +100 -0
- package/src/vendor/@dnd-kit/abstract/modifiers.js.map +1 -0
- package/src/vendor/@dnd-kit/abstract/package.json +60 -0
- package/src/vendor/@dnd-kit/collision/dist/index.d.ts +46 -0
- package/src/vendor/@dnd-kit/collision/dist/index.js +175 -0
- package/src/vendor/@dnd-kit/collision/package.json +42 -0
- package/src/vendor/@dnd-kit/dom/index.d.ts +298 -0
- package/src/vendor/@dnd-kit/dom/index.js +1977 -0
- package/src/vendor/@dnd-kit/dom/index.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/modifiers.d.ts +26 -0
- package/src/vendor/@dnd-kit/dom/modifiers.js +117 -0
- package/src/vendor/@dnd-kit/dom/modifiers.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/package.json +92 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.d.ts +8 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.js +125 -0
- package/src/vendor/@dnd-kit/dom/plugins/debug.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/sortable.d.ts +125 -0
- package/src/vendor/@dnd-kit/dom/sortable.js +822 -0
- package/src/vendor/@dnd-kit/dom/sortable.js.map +1 -0
- package/src/vendor/@dnd-kit/dom/utilities.d.ts +215 -0
- package/src/vendor/@dnd-kit/dom/utilities.js +1361 -0
- package/src/vendor/@dnd-kit/dom/utilities.js.map +1 -0
- package/src/vendor/@dnd-kit/geometry/dist/index.d.ts +178 -0
- package/src/vendor/@dnd-kit/geometry/dist/index.js +347 -0
- package/src/vendor/@dnd-kit/geometry/package.json +31 -0
- package/src/vendor/@dnd-kit/react/hooks.d.ts +30 -0
- package/src/vendor/@dnd-kit/react/hooks.js +133 -0
- package/src/vendor/@dnd-kit/react/index.d.ts +84 -0
- package/src/vendor/@dnd-kit/react/index.js +617 -0
- package/src/vendor/@dnd-kit/react/package.json +80 -0
- package/src/vendor/@dnd-kit/react/sortable.d.ts +26 -0
- package/src/vendor/@dnd-kit/react/sortable.js +175 -0
- package/src/vendor/@dnd-kit/react/utilities.d.ts +7 -0
- package/src/vendor/@dnd-kit/react/utilities.js +18 -0
- package/src/vendor/@dnd-kit/state/dist/index.d.ts +54 -0
- package/src/vendor/@dnd-kit/state/dist/index.js +328 -0
- package/src/vendor/@dnd-kit/state/package.json +33 -0
- package/src/vendor/@preact/signals-core/dist/signals-core.js +1 -0
- package/src/vendor/@preact/signals-core/dist/signals-core.js.map +1 -0
- package/src/vendor/@preact/signals-core/package.json +4 -0
- package/src/vendor/tslib/CopyrightNotice.txt +15 -0
- package/src/vendor/tslib/LICENSE.txt +12 -0
- package/src/vendor/tslib/README.md +164 -0
- package/src/vendor/tslib/SECURITY.md +41 -0
- package/src/vendor/tslib/modules/index.d.ts +38 -0
- package/src/vendor/tslib/modules/index.js +70 -0
- package/src/vendor/tslib/modules/package.json +3 -0
- package/src/vendor/tslib/package.json +47 -0
- package/src/vendor/tslib/tslib.d.ts +460 -0
- package/src/vendor/tslib/tslib.es6.html +1 -0
- package/src/vendor/tslib/tslib.es6.js +402 -0
- package/src/vendor/tslib/tslib.es6.mjs +401 -0
- package/src/vendor/tslib/tslib.html +1 -0
- package/src/vendor/tslib/tslib.js +484 -0
|
@@ -0,0 +1,1279 @@
|
|
|
1
|
+
import { Position, Coordinates, Shape, Alignment } from '@dnd-kit/geometry';
|
|
2
|
+
import { Effect, CleanupFunction, WithHistory } from '@dnd-kit/state';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type representing arbitrary data associated with an entity.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This type is used to store additional information about entities
|
|
9
|
+
* that can be accessed during drag and drop operations.
|
|
10
|
+
*/
|
|
11
|
+
type Data = Record<string, any>;
|
|
12
|
+
/**
|
|
13
|
+
* Type representing a unique identifier for an entity.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This type is used to uniquely identify draggable and droppable entities
|
|
17
|
+
* within the drag and drop system.
|
|
18
|
+
*/
|
|
19
|
+
type UniqueIdentifier = string | number;
|
|
20
|
+
/**
|
|
21
|
+
* Type representing the type of an entity.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* This type is used to categorize entities and can be used to
|
|
25
|
+
* implement type-based filtering or matching.
|
|
26
|
+
*/
|
|
27
|
+
type Type = Symbol | string | number;
|
|
28
|
+
|
|
29
|
+
interface Input$2<T extends Data = Data> {
|
|
30
|
+
/**
|
|
31
|
+
* The unique identifier of the entity.
|
|
32
|
+
*/
|
|
33
|
+
id: UniqueIdentifier;
|
|
34
|
+
/**
|
|
35
|
+
* Optional data associated with the entity.
|
|
36
|
+
*/
|
|
37
|
+
data?: T;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the entity should initially be disabled.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the entity should be automatically registered with the manager when it is created.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
register?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* An array of effects that are set up when the entity is registered and cleaned up when it is unregistered.
|
|
50
|
+
*/
|
|
51
|
+
effects?(): Effect[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The `Entity` class is an abstract representation of a distinct unit in the drag and drop system.
|
|
55
|
+
* It is a base class that other concrete classes like `Draggable` and `Droppable` can extend.
|
|
56
|
+
*
|
|
57
|
+
* @template T - The type of data associated with the entity.
|
|
58
|
+
*/
|
|
59
|
+
declare class Entity<T extends Data = Data, U extends DragDropManager<any, any> = DragDropManager<any, any>> {
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new instance of the `Entity` class.
|
|
62
|
+
*
|
|
63
|
+
* @param input - An object containing the initial properties of the entity.
|
|
64
|
+
* @param manager - The manager that controls the drag and drop operations.
|
|
65
|
+
*/
|
|
66
|
+
constructor(input: Input$2<T>, manager: U | undefined);
|
|
67
|
+
/**
|
|
68
|
+
* The manager that controls the drag and drop operations.
|
|
69
|
+
*/
|
|
70
|
+
accessor manager: U | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The unique identifier of the entity.
|
|
73
|
+
*/
|
|
74
|
+
accessor id: UniqueIdentifier;
|
|
75
|
+
/**
|
|
76
|
+
* The data associated with the entity.
|
|
77
|
+
*/
|
|
78
|
+
accessor data: Data;
|
|
79
|
+
/**
|
|
80
|
+
* A boolean indicating whether the entity is disabled.
|
|
81
|
+
*/
|
|
82
|
+
accessor disabled: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* An array of effects that are applied to the entity.
|
|
85
|
+
*/
|
|
86
|
+
effects: () => Effect[];
|
|
87
|
+
/**
|
|
88
|
+
* A method that registers the entity with the manager.
|
|
89
|
+
* @returns CleanupFunction | void
|
|
90
|
+
*/
|
|
91
|
+
register(): CleanupFunction | void;
|
|
92
|
+
/**
|
|
93
|
+
* A method that unregisters the entity from the manager.
|
|
94
|
+
* @returns void
|
|
95
|
+
*/
|
|
96
|
+
unregister(): void;
|
|
97
|
+
/**
|
|
98
|
+
* A method that cleans up the entity when it is no longer needed.
|
|
99
|
+
* @returns void
|
|
100
|
+
*/
|
|
101
|
+
destroy(): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Reactive class representing a registry for entities.
|
|
106
|
+
* @template T - The type of entries that the registry manages,
|
|
107
|
+
* for example, `Draggable` or `Droppable` entities.
|
|
108
|
+
*/
|
|
109
|
+
declare class EntityRegistry<T extends Entity> {
|
|
110
|
+
private map;
|
|
111
|
+
private cleanupFunctions;
|
|
112
|
+
/**
|
|
113
|
+
* Iterator for the EntityRegistry class.
|
|
114
|
+
* @returns An iterator for the values in the map.
|
|
115
|
+
*/
|
|
116
|
+
[Symbol.iterator](): MapIterator<T>;
|
|
117
|
+
get value(): MapIterator<T>;
|
|
118
|
+
/**
|
|
119
|
+
* Checks if a entity with the given identifier exists in the registry.
|
|
120
|
+
* @param identifier - The unique identifier of the entity.
|
|
121
|
+
* @returns True if the entity exists, false otherwise.
|
|
122
|
+
*/
|
|
123
|
+
has(identifier: UniqueIdentifier): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Retrieves a entity from the registry using its identifier.
|
|
126
|
+
* @param identifier - The unique identifier of the entity.
|
|
127
|
+
* @returns The entity if it exists, undefined otherwise.
|
|
128
|
+
*/
|
|
129
|
+
get(identifier: UniqueIdentifier): T | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Registers a entity in the registry.
|
|
132
|
+
* @param key - The unique identifier of the entity.
|
|
133
|
+
* @param value - The entity to register.
|
|
134
|
+
* @returns A function that unregisters the entity.
|
|
135
|
+
*/
|
|
136
|
+
register: (key: UniqueIdentifier, value: T) => () => void;
|
|
137
|
+
/**
|
|
138
|
+
* Unregisters an entity from the registry.
|
|
139
|
+
* @param key - The unique identifier of the entity.
|
|
140
|
+
* @param value - The entity instance to unregister.
|
|
141
|
+
*/
|
|
142
|
+
unregister: (key: UniqueIdentifier, value: T) => void;
|
|
143
|
+
/**
|
|
144
|
+
* Destroys all entries in the registry and clears the registry.
|
|
145
|
+
*/
|
|
146
|
+
destroy(): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Base type for plugin options */
|
|
150
|
+
type PluginOptions = Record<string, any>;
|
|
151
|
+
/**
|
|
152
|
+
* Constructor type for plugins.
|
|
153
|
+
*
|
|
154
|
+
* @template T - The type of drag and drop manager
|
|
155
|
+
* @template U - The type of plugin instance
|
|
156
|
+
* @template V - The type of plugin options
|
|
157
|
+
*/
|
|
158
|
+
interface PluginConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends Plugin<T> = Plugin<T>, V extends PluginOptions = InferPluginOptions<U>> {
|
|
159
|
+
/** Creates a new plugin instance */
|
|
160
|
+
new (manager: T, options?: V): U;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Descriptor type for plugins.
|
|
164
|
+
*
|
|
165
|
+
* @template T - The type of drag and drop manager
|
|
166
|
+
* @template U - The type of plugin instance
|
|
167
|
+
* @template V - The type of plugin constructor
|
|
168
|
+
*/
|
|
169
|
+
type PluginDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends Plugin<T> = Plugin<T>, V extends PluginConstructor<T, U> = PluginConstructor<T, U>> = {
|
|
170
|
+
/** The plugin constructor */
|
|
171
|
+
plugin: V;
|
|
172
|
+
/** Optional configuration for the plugin */
|
|
173
|
+
options?: InferPluginOptions<U>;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Array type for plugin constructors or descriptors.
|
|
177
|
+
*
|
|
178
|
+
* @template T - The type of drag and drop manager
|
|
179
|
+
*/
|
|
180
|
+
type Plugins<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (PluginConstructor<T> | PluginDescriptor<T>)[];
|
|
181
|
+
/**
|
|
182
|
+
* Infers the options type from a plugin constructor or instance.
|
|
183
|
+
*
|
|
184
|
+
* @template P - The plugin constructor or instance type
|
|
185
|
+
*/
|
|
186
|
+
type InferPluginOptions<P> = P extends PluginConstructor<any, any, infer T> ? T : P extends Plugin<any, infer T> ? T : never;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Base class for plugins that extend drag and drop functionality.
|
|
190
|
+
*
|
|
191
|
+
* @template T - The type of drag and drop manager
|
|
192
|
+
* @template U - The type of plugin options
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* Plugins can add new features and behaviors to the drag and drop system
|
|
196
|
+
* by extending this class and implementing custom functionality.
|
|
197
|
+
*/
|
|
198
|
+
declare abstract class Plugin<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends PluginOptions = PluginOptions> {
|
|
199
|
+
#private;
|
|
200
|
+
manager: T;
|
|
201
|
+
options?: U | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Creates a new plugin instance.
|
|
204
|
+
*
|
|
205
|
+
* @param manager - The drag and drop manager that owns this plugin
|
|
206
|
+
* @param options - Optional configuration for the plugin
|
|
207
|
+
*/
|
|
208
|
+
constructor(manager: T, options?: U | undefined);
|
|
209
|
+
/**
|
|
210
|
+
* Whether the plugin instance is disabled.
|
|
211
|
+
*
|
|
212
|
+
* @remarks
|
|
213
|
+
* This property is reactive and triggers effects when accessed.
|
|
214
|
+
*/
|
|
215
|
+
accessor disabled: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Enables a disabled plugin instance.
|
|
218
|
+
*
|
|
219
|
+
* @remarks
|
|
220
|
+
* This method triggers effects when called.
|
|
221
|
+
*/
|
|
222
|
+
enable(): void;
|
|
223
|
+
/**
|
|
224
|
+
* Disables an enabled plugin instance.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* This method triggers effects when called.
|
|
228
|
+
*/
|
|
229
|
+
disable(): void;
|
|
230
|
+
/**
|
|
231
|
+
* Checks if the plugin instance is disabled.
|
|
232
|
+
*
|
|
233
|
+
* @returns true if the plugin is disabled
|
|
234
|
+
* @remarks
|
|
235
|
+
* This method does not trigger effects when accessed.
|
|
236
|
+
*/
|
|
237
|
+
isDisabled(): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Configures a plugin instance with new options.
|
|
240
|
+
*
|
|
241
|
+
* @param options - The new options to apply
|
|
242
|
+
*/
|
|
243
|
+
configure(options?: U): void;
|
|
244
|
+
/**
|
|
245
|
+
* Registers an effect that will be cleaned up when the plugin is destroyed.
|
|
246
|
+
*
|
|
247
|
+
* @param callback - The effect callback to register
|
|
248
|
+
* @returns A function to dispose of the effect
|
|
249
|
+
*/
|
|
250
|
+
protected registerEffect(callback: () => void): {
|
|
251
|
+
(): void;
|
|
252
|
+
[Symbol.dispose](): void;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Destroys a plugin instance and cleans up its resources.
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* This method:
|
|
259
|
+
* - Calls all registered cleanup functions
|
|
260
|
+
* - Should be overridden by subclasses to clean up additional resources
|
|
261
|
+
*/
|
|
262
|
+
destroy(): void;
|
|
263
|
+
/**
|
|
264
|
+
* Configures a plugin constructor with options.
|
|
265
|
+
*
|
|
266
|
+
* @param options - The options to configure the constructor with
|
|
267
|
+
* @returns The configured plugin constructor
|
|
268
|
+
*
|
|
269
|
+
* @remarks
|
|
270
|
+
* This method is used to configure the options that the
|
|
271
|
+
* plugin constructor will use to create plugin instances.
|
|
272
|
+
*/
|
|
273
|
+
static configure(options: PluginOptions): PluginDescriptor<any, any, any>;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Base class for core plugins that ship with the library.
|
|
277
|
+
*
|
|
278
|
+
* @template T - The type of drag and drop manager
|
|
279
|
+
* @template U - The type of plugin options
|
|
280
|
+
*/
|
|
281
|
+
declare class CorePlugin<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends PluginOptions = PluginOptions> extends Plugin<T, U> {
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Manages the registration and lifecycle of plugin instances.
|
|
286
|
+
*
|
|
287
|
+
* @template T - The type of drag and drop manager
|
|
288
|
+
* @template W - The type of plugin constructor
|
|
289
|
+
* @template U - The type of plugin instance
|
|
290
|
+
*/
|
|
291
|
+
declare class PluginRegistry<T extends DragDropManager<any, any>, W extends PluginConstructor<T> = PluginConstructor<T>, U extends Plugin<T> = InstanceType<W>> {
|
|
292
|
+
#private;
|
|
293
|
+
private manager;
|
|
294
|
+
private instances;
|
|
295
|
+
/**
|
|
296
|
+
* Creates a new plugin registry.
|
|
297
|
+
*
|
|
298
|
+
* @param manager - The drag and drop manager that owns this registry
|
|
299
|
+
*/
|
|
300
|
+
constructor(manager: T);
|
|
301
|
+
/**
|
|
302
|
+
* Gets all registered plugin instances.
|
|
303
|
+
*
|
|
304
|
+
* @returns An array of all active plugin instances
|
|
305
|
+
*/
|
|
306
|
+
get values(): U[];
|
|
307
|
+
/**
|
|
308
|
+
* Sets the list of plugins to be used by the registry.
|
|
309
|
+
*
|
|
310
|
+
* @param entries - Array of plugin constructors or descriptors
|
|
311
|
+
* @remarks
|
|
312
|
+
* This method:
|
|
313
|
+
* - Filters out duplicate plugins
|
|
314
|
+
* - Unregisters plugins that are no longer in use
|
|
315
|
+
* - Registers new plugins with their options
|
|
316
|
+
*/
|
|
317
|
+
set values(entries: Plugins<T>);
|
|
318
|
+
/**
|
|
319
|
+
* Gets a plugin instance by its constructor.
|
|
320
|
+
*
|
|
321
|
+
* @param plugin - The plugin constructor to look up
|
|
322
|
+
* @returns The plugin instance or undefined if not found
|
|
323
|
+
*/
|
|
324
|
+
get<X extends W>(plugin: X): InstanceType<X> | undefined;
|
|
325
|
+
/**
|
|
326
|
+
* Registers a new plugin instance.
|
|
327
|
+
*
|
|
328
|
+
* @param plugin - The plugin constructor to register
|
|
329
|
+
* @param options - Optional configuration for the plugin
|
|
330
|
+
* @returns The registered plugin instance
|
|
331
|
+
* @remarks
|
|
332
|
+
* If the plugin is already registered, its options will be updated
|
|
333
|
+
* and the existing instance will be returned.
|
|
334
|
+
*/
|
|
335
|
+
register<X extends W>(plugin: X, options?: InferPluginOptions<X>): InstanceType<X>;
|
|
336
|
+
/**
|
|
337
|
+
* Unregisters a plugin instance.
|
|
338
|
+
*
|
|
339
|
+
* @param plugin - The plugin constructor to unregister
|
|
340
|
+
* @remarks
|
|
341
|
+
* This method:
|
|
342
|
+
* - Destroys the plugin instance
|
|
343
|
+
* - Removes it from the registry
|
|
344
|
+
*/
|
|
345
|
+
unregister<X extends W>(plugin: X): void;
|
|
346
|
+
/**
|
|
347
|
+
* Destroys all registered plugin instances.
|
|
348
|
+
*
|
|
349
|
+
* @remarks
|
|
350
|
+
* This method:
|
|
351
|
+
* - Calls destroy() on all plugin instances
|
|
352
|
+
* - Clears the registry
|
|
353
|
+
*/
|
|
354
|
+
destroy(): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Creates a plugin descriptor with the given plugin constructor and options.
|
|
359
|
+
*
|
|
360
|
+
* @template T - The plugin constructor type
|
|
361
|
+
* @template V - The plugin options type
|
|
362
|
+
* @param plugin - The plugin constructor
|
|
363
|
+
* @param options - The plugin configuration options
|
|
364
|
+
* @returns A plugin descriptor containing the constructor and options
|
|
365
|
+
*/
|
|
366
|
+
declare function configure<T extends PluginConstructor<any, any, any>, V extends PluginOptions = InferPluginOptions<T>>(plugin: T, options: V): PluginDescriptor<any, any, T>;
|
|
367
|
+
/**
|
|
368
|
+
* Creates a configurator function for a specific plugin constructor.
|
|
369
|
+
*
|
|
370
|
+
* @template T - The plugin constructor type
|
|
371
|
+
* @param plugin - The plugin constructor to configure
|
|
372
|
+
* @returns A function that takes options and returns a plugin descriptor
|
|
373
|
+
*/
|
|
374
|
+
declare function configurator<T extends PluginConstructor<any, any, any>>(plugin: T): (options: InferPluginOptions<T>) => PluginDescriptor<any, any, T>;
|
|
375
|
+
/**
|
|
376
|
+
* Normalizes a plugin constructor or descriptor into a descriptor.
|
|
377
|
+
*
|
|
378
|
+
* @template T - The plugin constructor type
|
|
379
|
+
* @param plugin - Either a plugin constructor or a plugin descriptor
|
|
380
|
+
* @returns A plugin descriptor
|
|
381
|
+
*/
|
|
382
|
+
declare function descriptor<T extends PluginConstructor<any, any, any>>(plugin: T | PluginDescriptor<any, any, T>): PluginDescriptor<any, any, T>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Enum representing the possible states of a drag operation.
|
|
386
|
+
*/
|
|
387
|
+
declare enum StatusValue {
|
|
388
|
+
/** No drag operation is in progress */
|
|
389
|
+
Idle = "idle",
|
|
390
|
+
/** A drag operation is about to start */
|
|
391
|
+
InitializationPending = "initialization-pending",
|
|
392
|
+
/** A drag operation is being initialized */
|
|
393
|
+
Initializing = "initializing",
|
|
394
|
+
/** A drag operation is in progress */
|
|
395
|
+
Dragging = "dragging",
|
|
396
|
+
/** A drag operation has completed */
|
|
397
|
+
Dropped = "dropped"
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Manages the status of a drag operation.
|
|
401
|
+
*
|
|
402
|
+
* @remarks
|
|
403
|
+
* This class provides reactive accessors for checking the current state
|
|
404
|
+
* of a drag operation and methods for updating it.
|
|
405
|
+
*/
|
|
406
|
+
declare class Status {
|
|
407
|
+
/** The current status value */
|
|
408
|
+
private accessor value;
|
|
409
|
+
/**
|
|
410
|
+
* Gets the current status value.
|
|
411
|
+
*
|
|
412
|
+
* @returns The current status value
|
|
413
|
+
*/
|
|
414
|
+
get current(): StatusValue;
|
|
415
|
+
/**
|
|
416
|
+
* Checks if the status is idle.
|
|
417
|
+
*
|
|
418
|
+
* @returns true if no drag operation is in progress
|
|
419
|
+
*/
|
|
420
|
+
get idle(): boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Checks if the status is initializing.
|
|
423
|
+
*
|
|
424
|
+
* @returns true if a drag operation is being initialized
|
|
425
|
+
*/
|
|
426
|
+
get initializing(): boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Checks if the status is initialized.
|
|
429
|
+
*
|
|
430
|
+
* @returns true if a drag operation has started initialization
|
|
431
|
+
*/
|
|
432
|
+
get initialized(): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Checks if the status is dragging.
|
|
435
|
+
*
|
|
436
|
+
* @returns true if a drag operation is in progress
|
|
437
|
+
*/
|
|
438
|
+
get dragging(): boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Checks if the status is dropped.
|
|
441
|
+
*
|
|
442
|
+
* @returns true if a drag operation has completed
|
|
443
|
+
*/
|
|
444
|
+
get dropped(): boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Sets the current status value.
|
|
447
|
+
*
|
|
448
|
+
* @param value - The new status value
|
|
449
|
+
*/
|
|
450
|
+
set(value: StatusValue): void;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
interface DragOperationSnapshot<T extends Draggable = Draggable, U extends Droppable = Droppable> {
|
|
454
|
+
readonly activatorEvent: Event | null;
|
|
455
|
+
readonly canceled: boolean;
|
|
456
|
+
readonly position: Position;
|
|
457
|
+
readonly transform: Coordinates;
|
|
458
|
+
readonly status: Status;
|
|
459
|
+
get shape(): WithHistory<Shape> | null;
|
|
460
|
+
set shape(value: Shape | null);
|
|
461
|
+
readonly source: T | null;
|
|
462
|
+
readonly target: U | null;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Represents the current state of a drag operation.
|
|
466
|
+
*
|
|
467
|
+
* @template T - The type of draggable entities
|
|
468
|
+
* @template U - The type of droppable entities
|
|
469
|
+
*/
|
|
470
|
+
declare class DragOperation<T extends Draggable, U extends Droppable> implements DragOperationSnapshot<T, U> {
|
|
471
|
+
#private;
|
|
472
|
+
/**
|
|
473
|
+
* Creates a new drag operation instance.
|
|
474
|
+
*
|
|
475
|
+
* @param manager - The drag and drop manager that owns this operation
|
|
476
|
+
*/
|
|
477
|
+
constructor(manager: DragDropManager<T, U>);
|
|
478
|
+
/** Current status of the drag operation */
|
|
479
|
+
readonly status: Status;
|
|
480
|
+
/** The controller for the currentdrag operation */
|
|
481
|
+
controller: AbortController | undefined;
|
|
482
|
+
/**
|
|
483
|
+
* Gets the current shape of the dragged entity with history.
|
|
484
|
+
*
|
|
485
|
+
* @returns The shape history or null if no shape is set
|
|
486
|
+
*/
|
|
487
|
+
get shape(): WithHistory<Shape> | null;
|
|
488
|
+
/**
|
|
489
|
+
* Sets the shape of the dragged entity.
|
|
490
|
+
*
|
|
491
|
+
* @param value - The new shape or null to reset
|
|
492
|
+
*/
|
|
493
|
+
set shape(value: Shape | null);
|
|
494
|
+
/** Whether the drag operation was canceled */
|
|
495
|
+
accessor canceled: boolean;
|
|
496
|
+
/** The event that initiated the drag operation */
|
|
497
|
+
accessor activatorEvent: Event | null;
|
|
498
|
+
/** Unique identifier of the source draggable entity */
|
|
499
|
+
accessor sourceIdentifier: UniqueIdentifier | null;
|
|
500
|
+
/** Unique identifier of the target droppable entity */
|
|
501
|
+
accessor targetIdentifier: UniqueIdentifier | null;
|
|
502
|
+
/** List of modifiers applied to the drag operation */
|
|
503
|
+
accessor modifiers: Modifier[];
|
|
504
|
+
/** Current position of the dragged entity */
|
|
505
|
+
position: Position;
|
|
506
|
+
/**
|
|
507
|
+
* Gets the source draggable entity.
|
|
508
|
+
*
|
|
509
|
+
* @returns The current draggable entity or the previous one if the current is not found
|
|
510
|
+
*/
|
|
511
|
+
get source(): T | null;
|
|
512
|
+
/**
|
|
513
|
+
* Gets the target droppable entity.
|
|
514
|
+
*
|
|
515
|
+
* @returns The current droppable entity or null if not found
|
|
516
|
+
*/
|
|
517
|
+
get target(): U | null;
|
|
518
|
+
/**
|
|
519
|
+
* Gets the current transform after applying all modifiers.
|
|
520
|
+
*
|
|
521
|
+
* @returns The transformed coordinates
|
|
522
|
+
*/
|
|
523
|
+
get transform(): {
|
|
524
|
+
x: number;
|
|
525
|
+
y: number;
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Creates a snapshot of the current drag operation state.
|
|
529
|
+
*
|
|
530
|
+
* @returns An immutable snapshot of the current operation state
|
|
531
|
+
*/
|
|
532
|
+
snapshot(): DragOperationSnapshot<T, U>;
|
|
533
|
+
/**
|
|
534
|
+
* Resets the drag operation to its initial state.
|
|
535
|
+
*
|
|
536
|
+
* @remarks
|
|
537
|
+
* This method:
|
|
538
|
+
* - Sets status to idle
|
|
539
|
+
* - Clears source and target identifiers
|
|
540
|
+
* - Resets shape history
|
|
541
|
+
* - Resets position and transform
|
|
542
|
+
* - Clears modifiers
|
|
543
|
+
*/
|
|
544
|
+
reset(): void;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
/** Options that can be passed to a modifier */
|
|
548
|
+
type ModifierOptions = PluginOptions;
|
|
549
|
+
/**
|
|
550
|
+
* Base class for drag operation modifiers.
|
|
551
|
+
*
|
|
552
|
+
* @template T - The type of drag and drop manager
|
|
553
|
+
* @template U - The type of modifier options
|
|
554
|
+
*
|
|
555
|
+
* @remarks
|
|
556
|
+
* Modifiers can transform the coordinates of a drag operation,
|
|
557
|
+
* enabling features like snapping, constraints, and custom behaviors.
|
|
558
|
+
*/
|
|
559
|
+
declare class Modifier<T extends DragDropManager<any, any> = DragDropManager<any, any>, U extends ModifierOptions = ModifierOptions> extends Plugin<T, U> {
|
|
560
|
+
manager: T;
|
|
561
|
+
options?: U | undefined;
|
|
562
|
+
/**
|
|
563
|
+
* Creates a new modifier instance.
|
|
564
|
+
*
|
|
565
|
+
* @param manager - The drag and drop manager that owns this modifier
|
|
566
|
+
* @param options - Optional configuration for the modifier
|
|
567
|
+
*/
|
|
568
|
+
constructor(manager: T, options?: U | undefined);
|
|
569
|
+
/**
|
|
570
|
+
* Applies the modifier to the current drag operation.
|
|
571
|
+
*
|
|
572
|
+
* @param operation - The current state of the drag operation
|
|
573
|
+
* @returns The transformed coordinates
|
|
574
|
+
*
|
|
575
|
+
* @remarks
|
|
576
|
+
* Override this method to implement custom transformation logic.
|
|
577
|
+
* The default implementation returns the original transform unchanged.
|
|
578
|
+
*/
|
|
579
|
+
apply(operation: DragOperationSnapshot<any, any>): Coordinates;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Constructor type for modifiers.
|
|
583
|
+
*
|
|
584
|
+
* @template T - The type of drag and drop manager
|
|
585
|
+
*/
|
|
586
|
+
type ModifierConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Modifier<T, any>>;
|
|
587
|
+
/**
|
|
588
|
+
* Descriptor type for modifiers.
|
|
589
|
+
*
|
|
590
|
+
* @template T - The type of drag and drop manager
|
|
591
|
+
*/
|
|
592
|
+
type ModifierDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Modifier<T, any>, ModifierConstructor<T>>;
|
|
593
|
+
/**
|
|
594
|
+
* Array type for modifier constructors or descriptors.
|
|
595
|
+
*
|
|
596
|
+
* @template T - The type of drag and drop manager
|
|
597
|
+
*/
|
|
598
|
+
type Modifiers<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (ModifierConstructor<T> | ModifierDescriptor<T>)[];
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Options that can be passed to a sensor.
|
|
602
|
+
* Extends the base PluginOptions type.
|
|
603
|
+
*/
|
|
604
|
+
type SensorOptions = PluginOptions;
|
|
605
|
+
/**
|
|
606
|
+
* Abstract base class for all sensor implementations.
|
|
607
|
+
*
|
|
608
|
+
* @template T - The type of drag drop manager
|
|
609
|
+
* @template U - The type of sensor options
|
|
610
|
+
*
|
|
611
|
+
* @remarks
|
|
612
|
+
* Sensors are responsible for detecting and initiating drag operations.
|
|
613
|
+
* They handle the actual user interaction (mouse, touch, keyboard, etc.)
|
|
614
|
+
* and translate those interactions into drag operations.
|
|
615
|
+
*/
|
|
616
|
+
declare abstract class Sensor<T extends DragDropManager<any, any> = DragDropManager<Draggable, Droppable>, U extends SensorOptions = SensorOptions> extends Plugin<T, U> {
|
|
617
|
+
manager: T;
|
|
618
|
+
options?: U | undefined;
|
|
619
|
+
/**
|
|
620
|
+
* Creates a new sensor instance.
|
|
621
|
+
*
|
|
622
|
+
* @param manager - The drag drop manager instance
|
|
623
|
+
* @param options - Optional sensor configuration
|
|
624
|
+
*/
|
|
625
|
+
constructor(manager: T, options?: U | undefined);
|
|
626
|
+
/**
|
|
627
|
+
* Binds the sensor to a draggable source.
|
|
628
|
+
*
|
|
629
|
+
* @param source - The draggable element to bind to
|
|
630
|
+
* @param options - Optional sensor options specific to this draggable
|
|
631
|
+
* @returns A cleanup function to unbind the sensor
|
|
632
|
+
*/
|
|
633
|
+
abstract bind(source: Draggable, options?: U): CleanupFunction;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Constructor type for creating sensor instances.
|
|
637
|
+
*
|
|
638
|
+
* @template T - The type of drag drop manager
|
|
639
|
+
*/
|
|
640
|
+
type SensorConstructor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginConstructor<T, Sensor<T>>;
|
|
641
|
+
/**
|
|
642
|
+
* Descriptor type for configuring sensors.
|
|
643
|
+
*
|
|
644
|
+
* @template T - The type of drag drop manager
|
|
645
|
+
*/
|
|
646
|
+
type SensorDescriptor<T extends DragDropManager<any, any> = DragDropManager<any, any>> = PluginDescriptor<T, Sensor<T>, SensorConstructor<T>>;
|
|
647
|
+
/**
|
|
648
|
+
* Array type for multiple sensor configurations.
|
|
649
|
+
*
|
|
650
|
+
* @template T - The type of drag drop manager
|
|
651
|
+
*/
|
|
652
|
+
type Sensors<T extends DragDropManager<any, any> = DragDropManager<any, any>> = (SensorConstructor<T> | SensorDescriptor<T>)[];
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Input configuration for creating a draggable entity.
|
|
656
|
+
*
|
|
657
|
+
* @template T - The type of data associated with the draggable
|
|
658
|
+
*
|
|
659
|
+
* @remarks
|
|
660
|
+
* Extends the base entity input with draggable-specific configuration:
|
|
661
|
+
* - Type for categorization
|
|
662
|
+
* - Sensors for handling drag interactions
|
|
663
|
+
* - Modifiers for transforming drag behavior
|
|
664
|
+
* - Alignment for positioning
|
|
665
|
+
*/
|
|
666
|
+
interface Input$1<T extends Data = Data> extends Input$2<T> {
|
|
667
|
+
type?: Type;
|
|
668
|
+
sensors?: Sensors;
|
|
669
|
+
modifiers?: Modifiers;
|
|
670
|
+
alignment?: Alignment;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Possible status values for a draggable entity.
|
|
674
|
+
*
|
|
675
|
+
* @remarks
|
|
676
|
+
* - idle: Not being dragged
|
|
677
|
+
* - dragging: Currently being dragged
|
|
678
|
+
* - dropping: Currently being dropped
|
|
679
|
+
*/
|
|
680
|
+
type DraggableStatus = 'idle' | 'dragging' | 'dropping';
|
|
681
|
+
/**
|
|
682
|
+
* Represents an entity that can be dragged in a drag and drop operation.
|
|
683
|
+
*
|
|
684
|
+
* @template T - The type of data associated with the draggable
|
|
685
|
+
* @template U - The type of drag and drop manager
|
|
686
|
+
*
|
|
687
|
+
* @remarks
|
|
688
|
+
* This class extends the base Entity class with draggable-specific functionality:
|
|
689
|
+
* - Type-based categorization
|
|
690
|
+
* - Sensor-based interaction handling
|
|
691
|
+
* - Modifier-based behavior transformation
|
|
692
|
+
* - Status tracking during drag operations
|
|
693
|
+
*/
|
|
694
|
+
declare class Draggable<T extends Data = Data, U extends DragDropManager<any, any> = DragDropManager<any, any>> extends Entity<T, U> {
|
|
695
|
+
constructor({ modifiers, type, sensors, ...input }: Input$1<T>, manager: U | undefined);
|
|
696
|
+
/** The type of the draggable entity */
|
|
697
|
+
accessor type: Type | undefined;
|
|
698
|
+
/** The sensors associated with the draggable entity */
|
|
699
|
+
sensors: Sensors | undefined;
|
|
700
|
+
/** The modifiers associated with the draggable entity */
|
|
701
|
+
accessor modifiers: Modifiers | undefined;
|
|
702
|
+
/** The alignment of the draggable entity */
|
|
703
|
+
alignment: Alignment | undefined;
|
|
704
|
+
/** The current status of the draggable entity */
|
|
705
|
+
accessor status: DraggableStatus;
|
|
706
|
+
/**
|
|
707
|
+
* Checks if the draggable entity is currently being dropped.
|
|
708
|
+
*
|
|
709
|
+
* @returns true if the entity is being dropped and is the drag source
|
|
710
|
+
*/
|
|
711
|
+
get isDropping(): boolean;
|
|
712
|
+
/**
|
|
713
|
+
* Checks if the draggable entity is currently being dragged.
|
|
714
|
+
*
|
|
715
|
+
* @returns true if the entity is being dragged and is the drag source
|
|
716
|
+
*/
|
|
717
|
+
get isDragging(): boolean;
|
|
718
|
+
/**
|
|
719
|
+
* Checks if the draggable entity is the source of the current drag operation.
|
|
720
|
+
*
|
|
721
|
+
* @returns true if the entity's ID matches the current drag operation's source ID
|
|
722
|
+
*/
|
|
723
|
+
get isDragSource(): boolean;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Priority levels for collision detection.
|
|
728
|
+
*
|
|
729
|
+
* @remarks
|
|
730
|
+
* Higher priority collisions take precedence over lower priority ones.
|
|
731
|
+
* Custom numeric priorities can also be used for fine-grained control.
|
|
732
|
+
*/
|
|
733
|
+
declare enum CollisionPriority {
|
|
734
|
+
/** Lowest priority level */
|
|
735
|
+
Lowest = 0,
|
|
736
|
+
/** Low priority level */
|
|
737
|
+
Low = 1,
|
|
738
|
+
/** Normal priority level */
|
|
739
|
+
Normal = 2,
|
|
740
|
+
/** High priority level */
|
|
741
|
+
High = 3,
|
|
742
|
+
/** Highest priority level */
|
|
743
|
+
Highest = 4
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Types of collision detection.
|
|
747
|
+
*
|
|
748
|
+
* @remarks
|
|
749
|
+
* Different collision types can be used to implement various
|
|
750
|
+
* drag and drop behaviors and visual feedback.
|
|
751
|
+
*/
|
|
752
|
+
declare enum CollisionType {
|
|
753
|
+
/** Basic collision detection */
|
|
754
|
+
Collision = 0,
|
|
755
|
+
/** Shape-based intersection detection */
|
|
756
|
+
ShapeIntersection = 1,
|
|
757
|
+
/** Pointer-based intersection detection */
|
|
758
|
+
PointerIntersection = 2
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Represents a detected collision between a draggable and droppable.
|
|
762
|
+
*
|
|
763
|
+
* @remarks
|
|
764
|
+
* Contains information about the collision type, priority, and
|
|
765
|
+
* additional data that can be used for custom behaviors.
|
|
766
|
+
*/
|
|
767
|
+
interface Collision {
|
|
768
|
+
/** Unique identifier of the droppable involved in the collision */
|
|
769
|
+
id: UniqueIdentifier;
|
|
770
|
+
/** Priority of the collision */
|
|
771
|
+
priority: CollisionPriority | number;
|
|
772
|
+
/** Type of collision detected */
|
|
773
|
+
type: CollisionType;
|
|
774
|
+
/** Numeric value representing the collision strength or overlap */
|
|
775
|
+
value: number;
|
|
776
|
+
/** Additional data associated with the collision */
|
|
777
|
+
data?: Record<string, any>;
|
|
778
|
+
}
|
|
779
|
+
/** Array of detected collisions */
|
|
780
|
+
type Collisions = Collision[];
|
|
781
|
+
/**
|
|
782
|
+
* Input for collision detection functions.
|
|
783
|
+
*
|
|
784
|
+
* @template T - The type of draggable entities
|
|
785
|
+
* @template U - The type of droppable entities
|
|
786
|
+
*/
|
|
787
|
+
interface CollisionDetectorInput<T extends Draggable = Draggable, U extends Droppable = Droppable> {
|
|
788
|
+
/** The droppable to check for collisions */
|
|
789
|
+
droppable: U;
|
|
790
|
+
/** The current drag operation state */
|
|
791
|
+
dragOperation: DragOperationSnapshot<T, U>;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Function type for detecting collisions between draggables and droppables.
|
|
795
|
+
*
|
|
796
|
+
* @template T - The type of draggable entities
|
|
797
|
+
* @template U - The type of droppable entities
|
|
798
|
+
* @param input - The collision detection input
|
|
799
|
+
* @returns A collision object if detected, null otherwise
|
|
800
|
+
*/
|
|
801
|
+
type CollisionDetector = <T extends Draggable = Draggable, U extends Droppable = Droppable>(input: CollisionDetectorInput<T, U>) => Collision | null;
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Observes and manages collision detection between draggable and droppable elements.
|
|
805
|
+
*
|
|
806
|
+
* @template T - The type of draggable entities
|
|
807
|
+
* @template U - The type of droppable entities
|
|
808
|
+
* @template V - The type of drag drop manager
|
|
809
|
+
*
|
|
810
|
+
* @remarks
|
|
811
|
+
* The CollisionObserver is responsible for:
|
|
812
|
+
* - Computing collisions between draggable and droppable elements
|
|
813
|
+
* - Maintaining a signal of current collisions
|
|
814
|
+
* - Updating collision state based on drag operation changes
|
|
815
|
+
*/
|
|
816
|
+
declare class CollisionObserver<T extends Draggable = Draggable, U extends Droppable = Droppable, V extends DragDropManager<T, U> = DragDropManager<T, U>> extends Plugin<V> {
|
|
817
|
+
#private;
|
|
818
|
+
/**
|
|
819
|
+
* Creates a new CollisionObserver instance.
|
|
820
|
+
*
|
|
821
|
+
* @param manager - The drag drop manager instance
|
|
822
|
+
*/
|
|
823
|
+
constructor(manager: V);
|
|
824
|
+
/**
|
|
825
|
+
* Forces an immediate update of collision detection.
|
|
826
|
+
*
|
|
827
|
+
* @param immediate - If true, updates collisions immediately. If false, resets previous coordinates.
|
|
828
|
+
*/
|
|
829
|
+
forceUpdate(immediate?: boolean): void;
|
|
830
|
+
/**
|
|
831
|
+
* Computes collisions between draggable and droppable elements.
|
|
832
|
+
*
|
|
833
|
+
* @param entries - Optional array of droppable elements to check. If not provided, uses all registered droppables.
|
|
834
|
+
* @param collisionDetector - Optional custom collision detector function
|
|
835
|
+
* @returns Array of detected collisions, sorted by priority
|
|
836
|
+
*/
|
|
837
|
+
computeCollisions(entries?: Droppable[], collisionDetector?: CollisionDetector): Collisions;
|
|
838
|
+
/**
|
|
839
|
+
* Gets the current collisions signal value.
|
|
840
|
+
*/
|
|
841
|
+
get collisions(): Collisions;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Sort collisions from greatest to smallest priority
|
|
846
|
+
* Collisions of equal priority are sorted from greatest to smallest value
|
|
847
|
+
*/
|
|
848
|
+
declare function sortCollisions(a: Collision, b: Collision): number;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Input configuration for creating a droppable entity.
|
|
852
|
+
*
|
|
853
|
+
* @template T - The type of data associated with the droppable
|
|
854
|
+
*
|
|
855
|
+
* @remarks
|
|
856
|
+
* Extends the base entity input with droppable-specific configuration:
|
|
857
|
+
* - Accept rules for determining compatible draggables
|
|
858
|
+
* - Collision detection configuration
|
|
859
|
+
* - Type for categorization
|
|
860
|
+
*/
|
|
861
|
+
interface Input<T extends Data = Data> extends Input$2<T> {
|
|
862
|
+
/** Types of draggables that can be dropped here, or a function to determine compatibility */
|
|
863
|
+
accept?: Type | Type[] | ((source: Draggable) => boolean);
|
|
864
|
+
/** Priority for collision detection */
|
|
865
|
+
collisionPriority?: CollisionPriority | number;
|
|
866
|
+
/** Detector for determining collisions with draggables */
|
|
867
|
+
collisionDetector: CollisionDetector;
|
|
868
|
+
/** Type for categorization */
|
|
869
|
+
type?: Type;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Represents an entity that can receive draggable items in a drag and drop operation.
|
|
873
|
+
*
|
|
874
|
+
* @template T - The type of data associated with the droppable
|
|
875
|
+
* @template U - The type of drag and drop manager
|
|
876
|
+
*
|
|
877
|
+
* @remarks
|
|
878
|
+
* This class extends the base Entity class with droppable-specific functionality:
|
|
879
|
+
* - Type-based acceptance rules
|
|
880
|
+
* - Collision detection
|
|
881
|
+
* - Shape tracking
|
|
882
|
+
* - Target status tracking
|
|
883
|
+
*/
|
|
884
|
+
declare class Droppable<T extends Data = Data, U extends DragDropManager<any, any> = DragDropManager<any, any>> extends Entity<T, U> {
|
|
885
|
+
constructor({ accept, collisionDetector, collisionPriority, type, ...input }: Input<T>, manager: U | undefined);
|
|
886
|
+
/**
|
|
887
|
+
* Types of draggables that can be dropped here, or a function to determine compatibility.
|
|
888
|
+
*
|
|
889
|
+
* @remarks
|
|
890
|
+
* If undefined, all draggables are accepted.
|
|
891
|
+
* If a function, it determines compatibility based on the draggable.
|
|
892
|
+
* If a type or array of types, only draggables of matching types are accepted.
|
|
893
|
+
*/
|
|
894
|
+
accessor accept: Type | Type[] | ((draggable: Draggable) => boolean) | undefined;
|
|
895
|
+
/** The type of the droppable entity */
|
|
896
|
+
accessor type: Type | undefined;
|
|
897
|
+
/**
|
|
898
|
+
* Checks whether or not the droppable accepts a given draggable.
|
|
899
|
+
*
|
|
900
|
+
* @param draggable - The draggable to check
|
|
901
|
+
* @returns true if the draggable can be dropped here
|
|
902
|
+
*/
|
|
903
|
+
accepts(draggable: Draggable): boolean;
|
|
904
|
+
/** The collision detector for this droppable */
|
|
905
|
+
accessor collisionDetector: CollisionDetector;
|
|
906
|
+
/** The collision priority for this droppable */
|
|
907
|
+
accessor collisionPriority: CollisionPriority | number | undefined;
|
|
908
|
+
/** The current shape of this droppable */
|
|
909
|
+
accessor shape: Shape | undefined;
|
|
910
|
+
/**
|
|
911
|
+
* Checks if this droppable is the current drop target.
|
|
912
|
+
*
|
|
913
|
+
* @returns true if this droppable's ID matches the current drag operation's target ID
|
|
914
|
+
*/
|
|
915
|
+
get isDropTarget(): boolean;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Provides actions for controlling drag and drop operations.
|
|
920
|
+
*
|
|
921
|
+
* @template T - The type of draggable entities
|
|
922
|
+
* @template U - The type of droppable entities
|
|
923
|
+
* @template V - The type of drag and drop manager
|
|
924
|
+
*/
|
|
925
|
+
declare class DragActions<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> {
|
|
926
|
+
private readonly manager;
|
|
927
|
+
/**
|
|
928
|
+
* Creates a new instance of drag actions.
|
|
929
|
+
*
|
|
930
|
+
* @param manager - The drag and drop manager instance
|
|
931
|
+
*/
|
|
932
|
+
constructor(manager: V);
|
|
933
|
+
/**
|
|
934
|
+
* Sets the source of the drag operation.
|
|
935
|
+
*
|
|
936
|
+
* @param source - The draggable entity or its unique identifier
|
|
937
|
+
*/
|
|
938
|
+
setDragSource(source: T | UniqueIdentifier): void;
|
|
939
|
+
/**
|
|
940
|
+
* Sets the target of the drop operation.
|
|
941
|
+
*
|
|
942
|
+
* @param identifier - The unique identifier of the droppable entity or null/undefined
|
|
943
|
+
* @returns A promise that resolves to true if the drop was prevented
|
|
944
|
+
*/
|
|
945
|
+
setDropTarget(identifier: UniqueIdentifier | null | undefined): Promise<boolean>;
|
|
946
|
+
/**
|
|
947
|
+
* Starts a new drag operation.
|
|
948
|
+
*
|
|
949
|
+
* @param args - Configuration for the drag operation
|
|
950
|
+
* @param args.event - The event that initiated the drag
|
|
951
|
+
* @param args.source - The source draggable entity or its identifier
|
|
952
|
+
* @param args.coordinates - The initial coordinates of the drag
|
|
953
|
+
* @returns true if the drag operation started successfully
|
|
954
|
+
* @throws {Error} If there is no drag source or another operation is active
|
|
955
|
+
*/
|
|
956
|
+
start(args: {
|
|
957
|
+
/** The event that initiated the drag. */
|
|
958
|
+
event?: Event;
|
|
959
|
+
/** The source draggable entity or its identifier. */
|
|
960
|
+
source?: T | UniqueIdentifier;
|
|
961
|
+
/** The initial coordinates of the drag. */
|
|
962
|
+
coordinates: Coordinates;
|
|
963
|
+
}): AbortController;
|
|
964
|
+
/**
|
|
965
|
+
* Moves the dragged entity to a new position.
|
|
966
|
+
*
|
|
967
|
+
* @param args - Configuration for the move operation
|
|
968
|
+
* @param args.by - Relative coordinates to move by
|
|
969
|
+
* @param args.to - Absolute coordinates to move to
|
|
970
|
+
* @param args.event - The event that triggered the move
|
|
971
|
+
* @param args.cancelable - Whether the move can be canceled
|
|
972
|
+
* @param args.propagate - Whether to dispatch dragmove events
|
|
973
|
+
*/
|
|
974
|
+
move(args: {
|
|
975
|
+
/** The relative coordinates to move by. */
|
|
976
|
+
by?: Coordinates;
|
|
977
|
+
/** The absolute coordinates to move to. */
|
|
978
|
+
to?: Coordinates;
|
|
979
|
+
/** The event that triggered the move. */
|
|
980
|
+
event?: Event;
|
|
981
|
+
/** Whether the move can be canceled. */
|
|
982
|
+
cancelable?: boolean;
|
|
983
|
+
/** Whether to propagate the dragmove event to the manager. */
|
|
984
|
+
propagate?: boolean;
|
|
985
|
+
}): void;
|
|
986
|
+
/**
|
|
987
|
+
* Stops the current drag operation.
|
|
988
|
+
*
|
|
989
|
+
* @param args - Configuration for stopping the operation
|
|
990
|
+
* @param args.event - The event that triggered the stop
|
|
991
|
+
* @param args.canceled - Whether the operation was canceled
|
|
992
|
+
* @remarks
|
|
993
|
+
* This method:
|
|
994
|
+
* - Dispatches a dragend event
|
|
995
|
+
* - Allows suspension of the operation
|
|
996
|
+
* - Handles cleanup of the operation state
|
|
997
|
+
*/
|
|
998
|
+
stop(args?: {
|
|
999
|
+
/**
|
|
1000
|
+
* The event that triggered the stop.
|
|
1001
|
+
*/
|
|
1002
|
+
event?: Event;
|
|
1003
|
+
/**
|
|
1004
|
+
* Whether the operation was canceled.
|
|
1005
|
+
*
|
|
1006
|
+
* @default false
|
|
1007
|
+
*/
|
|
1008
|
+
canceled?: boolean;
|
|
1009
|
+
}): void;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Manages the registration and lifecycle of draggable and droppable entities,
|
|
1014
|
+
* as well as plugins, sensors, and modifiers.
|
|
1015
|
+
*
|
|
1016
|
+
* @template T - The type of draggable entities
|
|
1017
|
+
* @template U - The type of droppable entities
|
|
1018
|
+
* @template V - The type of drag and drop manager
|
|
1019
|
+
*/
|
|
1020
|
+
declare class DragDropRegistry<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> {
|
|
1021
|
+
/**
|
|
1022
|
+
* Creates a new registry instance.
|
|
1023
|
+
*
|
|
1024
|
+
* @param manager - The drag and drop manager that owns this registry
|
|
1025
|
+
*/
|
|
1026
|
+
constructor(manager: V);
|
|
1027
|
+
/** Registry for draggable entities */
|
|
1028
|
+
draggables: EntityRegistry<T>;
|
|
1029
|
+
/** Registry for droppable entities */
|
|
1030
|
+
droppables: EntityRegistry<U>;
|
|
1031
|
+
/** Registry for plugins */
|
|
1032
|
+
plugins: PluginRegistry<V, PluginConstructor<V>>;
|
|
1033
|
+
/** Registry for sensors */
|
|
1034
|
+
sensors: PluginRegistry<V, SensorConstructor<V>>;
|
|
1035
|
+
/** Registry for modifiers */
|
|
1036
|
+
modifiers: PluginRegistry<V, ModifierConstructor<V>>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Registers a new entity, plugin, sensor, or modifier.
|
|
1039
|
+
*
|
|
1040
|
+
* @param input - The entity, plugin constructor, sensor constructor, or modifier constructor to register
|
|
1041
|
+
* @param options - Optional configuration for plugins and sensors
|
|
1042
|
+
* @returns A cleanup function or the registered instance
|
|
1043
|
+
* @throws {Error} If the input type is invalid
|
|
1044
|
+
*/
|
|
1045
|
+
register(input: Entity): () => void;
|
|
1046
|
+
register(input: Draggable): () => void;
|
|
1047
|
+
register(input: Droppable): () => void;
|
|
1048
|
+
register(input: SensorConstructor, options?: SensorOptions): Sensor;
|
|
1049
|
+
register(input: ModifierConstructor): Modifier;
|
|
1050
|
+
register(input: PluginConstructor, options?: PluginOptions): Plugin;
|
|
1051
|
+
/**
|
|
1052
|
+
* Unregisters an entity, plugin, sensor, or modifier.
|
|
1053
|
+
*
|
|
1054
|
+
* @param input - The entity, plugin constructor, sensor constructor, or modifier constructor to unregister
|
|
1055
|
+
* @returns A cleanup function
|
|
1056
|
+
* @throws {Error} If the input type is invalid
|
|
1057
|
+
*/
|
|
1058
|
+
unregister(input: Entity): CleanupFunction;
|
|
1059
|
+
unregister(input: Draggable): CleanupFunction;
|
|
1060
|
+
unregister(input: Droppable): CleanupFunction;
|
|
1061
|
+
unregister(input: SensorConstructor): CleanupFunction;
|
|
1062
|
+
unregister(input: ModifierConstructor): CleanupFunction;
|
|
1063
|
+
unregister(input: PluginConstructor): CleanupFunction;
|
|
1064
|
+
/**
|
|
1065
|
+
* Destroys all registered entities and cleans up resources.
|
|
1066
|
+
*
|
|
1067
|
+
* @remarks
|
|
1068
|
+
* This method:
|
|
1069
|
+
* - Destroys all draggable and droppable entities
|
|
1070
|
+
* - Destroys all plugins, sensors, and modifiers
|
|
1071
|
+
* - Cleans up any associated resources
|
|
1072
|
+
*/
|
|
1073
|
+
destroy(): void;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/** Base type for event handler functions */
|
|
1077
|
+
type Events = Record<string, (...args: any[]) => void>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Extends an event type with preventable functionality.
|
|
1080
|
+
*
|
|
1081
|
+
* @template T - The base event type
|
|
1082
|
+
*/
|
|
1083
|
+
type Preventable<T> = T & {
|
|
1084
|
+
/** Whether the event can be canceled */
|
|
1085
|
+
cancelable: boolean;
|
|
1086
|
+
/** Whether the default action was prevented */
|
|
1087
|
+
defaultPrevented: boolean;
|
|
1088
|
+
/** Prevents the default action of the event */
|
|
1089
|
+
preventDefault(): void;
|
|
1090
|
+
};
|
|
1091
|
+
/**
|
|
1092
|
+
* Base class for event monitoring and dispatching.
|
|
1093
|
+
*
|
|
1094
|
+
* @template T - The type of events to monitor
|
|
1095
|
+
*/
|
|
1096
|
+
declare class Monitor<T extends Events> {
|
|
1097
|
+
private registry;
|
|
1098
|
+
/**
|
|
1099
|
+
* Adds an event listener for the specified event type.
|
|
1100
|
+
*
|
|
1101
|
+
* @param name - The name of the event to listen for
|
|
1102
|
+
* @param handler - The function to call when the event occurs
|
|
1103
|
+
* @returns A function to remove the event listener
|
|
1104
|
+
*/
|
|
1105
|
+
addEventListener<U extends keyof T>(name: U, handler: T[U]): () => void;
|
|
1106
|
+
/**
|
|
1107
|
+
* Removes an event listener for the specified event type.
|
|
1108
|
+
*
|
|
1109
|
+
* @param name - The name of the event
|
|
1110
|
+
* @param handler - The function to remove
|
|
1111
|
+
*/
|
|
1112
|
+
removeEventListener(name: keyof T, handler: T[keyof T]): void;
|
|
1113
|
+
/**
|
|
1114
|
+
* Dispatches an event to all registered listeners.
|
|
1115
|
+
*
|
|
1116
|
+
* @param name - The name of the event to dispatch
|
|
1117
|
+
* @param args - Arguments to pass to the event handlers
|
|
1118
|
+
*/
|
|
1119
|
+
protected dispatch<U extends keyof T>(name: U, ...args: any[]): void;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Type definition for drag and drop events.
|
|
1123
|
+
*
|
|
1124
|
+
* @template T - The type of draggable entities
|
|
1125
|
+
* @template U - The type of droppable entities
|
|
1126
|
+
* @template V - The type of drag and drop manager
|
|
1127
|
+
*/
|
|
1128
|
+
type DragDropEvents<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> = {
|
|
1129
|
+
/** Event fired when collisions are detected */
|
|
1130
|
+
collision(event: Preventable<{
|
|
1131
|
+
collisions: Collisions;
|
|
1132
|
+
}>, manager: V): void;
|
|
1133
|
+
/** Event fired before a drag operation starts */
|
|
1134
|
+
beforedragstart(event: Preventable<{
|
|
1135
|
+
operation: DragOperationSnapshot<T, U>;
|
|
1136
|
+
nativeEvent?: Event;
|
|
1137
|
+
}>, manager: V): void;
|
|
1138
|
+
/** Event fired when a drag operation starts */
|
|
1139
|
+
dragstart(event: {
|
|
1140
|
+
cancelable: false;
|
|
1141
|
+
operation: DragOperationSnapshot<T, U>;
|
|
1142
|
+
nativeEvent?: Event;
|
|
1143
|
+
}, manager: V): void;
|
|
1144
|
+
/** Event fired when a drag operation moves */
|
|
1145
|
+
dragmove(event: Preventable<{
|
|
1146
|
+
operation: DragOperationSnapshot<T, U>;
|
|
1147
|
+
to?: Coordinates;
|
|
1148
|
+
by?: Coordinates;
|
|
1149
|
+
nativeEvent?: Event;
|
|
1150
|
+
}>, manager: V): void;
|
|
1151
|
+
/** Event fired when a drag operation hovers over a droppable */
|
|
1152
|
+
dragover(event: Preventable<{
|
|
1153
|
+
operation: DragOperationSnapshot<T, U>;
|
|
1154
|
+
}>, manager: V): void;
|
|
1155
|
+
/** Event fired when a drag operation ends */
|
|
1156
|
+
dragend(event: {
|
|
1157
|
+
operation: DragOperationSnapshot<T, U>;
|
|
1158
|
+
nativeEvent?: Event;
|
|
1159
|
+
canceled: boolean;
|
|
1160
|
+
suspend(): {
|
|
1161
|
+
resume(): void;
|
|
1162
|
+
abort(): void;
|
|
1163
|
+
};
|
|
1164
|
+
}, manager: V): void;
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* Monitors and dispatches drag and drop events.
|
|
1168
|
+
*
|
|
1169
|
+
* @template T - The type of draggable entities
|
|
1170
|
+
* @template U - The type of droppable entities
|
|
1171
|
+
* @template V - The type of drag and drop manager
|
|
1172
|
+
*/
|
|
1173
|
+
declare class DragDropMonitor<T extends Draggable, U extends Droppable, V extends DragDropManager<T, U>> extends Monitor<DragDropEvents<T, U, V>> {
|
|
1174
|
+
private manager;
|
|
1175
|
+
/**
|
|
1176
|
+
* Creates a new drag and drop monitor.
|
|
1177
|
+
*
|
|
1178
|
+
* @param manager - The drag and drop manager to monitor
|
|
1179
|
+
*/
|
|
1180
|
+
constructor(manager: V);
|
|
1181
|
+
/**
|
|
1182
|
+
* Dispatches a drag and drop event.
|
|
1183
|
+
*
|
|
1184
|
+
* @param type - The type of event to dispatch
|
|
1185
|
+
* @param event - The event data to dispatch
|
|
1186
|
+
*/
|
|
1187
|
+
dispatch<Key extends keyof DragDropEvents<T, U, V>>(type: Key, event: Parameters<DragDropEvents<T, U, V>[Key]>[0]): void;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/**
|
|
1191
|
+
* Interface for handling visual feedback during drag operations.
|
|
1192
|
+
*
|
|
1193
|
+
* @remarks
|
|
1194
|
+
* Implementations of this interface are responsible for managing
|
|
1195
|
+
* the visual state of dragged elements and ensuring smooth animations.
|
|
1196
|
+
*/
|
|
1197
|
+
interface Renderer {
|
|
1198
|
+
/**
|
|
1199
|
+
* Gets a promise that resolves when the current rendering operation is complete.
|
|
1200
|
+
*
|
|
1201
|
+
* @returns A promise that resolves when rendering is finished
|
|
1202
|
+
*/
|
|
1203
|
+
get rendering(): Promise<void>;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
type DragDropManagerInput<T extends DragDropManager<any, any>> = {
|
|
1207
|
+
plugins?: Plugins<T>;
|
|
1208
|
+
sensors?: Sensors<T>;
|
|
1209
|
+
modifiers?: Modifiers<T>;
|
|
1210
|
+
renderer?: Renderer;
|
|
1211
|
+
};
|
|
1212
|
+
/**
|
|
1213
|
+
* Central manager class that orchestrates drag and drop operations.
|
|
1214
|
+
*
|
|
1215
|
+
* @template T - The type of draggable entities
|
|
1216
|
+
* @template U - The type of droppable entities
|
|
1217
|
+
*/
|
|
1218
|
+
declare class DragDropManager<T extends Draggable, U extends Droppable> {
|
|
1219
|
+
/** Actions that can be performed during drag operations */
|
|
1220
|
+
actions: DragActions<T, U, DragDropManager<T, U>>;
|
|
1221
|
+
/** Observes and manages collision detection between draggable and droppable entities */
|
|
1222
|
+
collisionObserver: CollisionObserver<T, U>;
|
|
1223
|
+
/** Tracks the current drag operation state and metadata */
|
|
1224
|
+
dragOperation: DragOperation<T, U>;
|
|
1225
|
+
/** Monitors and emits drag and drop events */
|
|
1226
|
+
monitor: DragDropMonitor<T, U, DragDropManager<T, U>>;
|
|
1227
|
+
/** Registry that manages draggable and droppable entities */
|
|
1228
|
+
registry: DragDropRegistry<T, U, DragDropManager<T, U>>;
|
|
1229
|
+
/** Handles rendering of drag and drop visual feedback */
|
|
1230
|
+
renderer: Renderer;
|
|
1231
|
+
/**
|
|
1232
|
+
* Creates a new drag and drop manager instance.
|
|
1233
|
+
*
|
|
1234
|
+
* @param config - Optional configuration for plugins, sensors, modifiers, and renderer
|
|
1235
|
+
*/
|
|
1236
|
+
constructor(config?: DragDropManagerInput<any>);
|
|
1237
|
+
/**
|
|
1238
|
+
* Gets the list of active plugins.
|
|
1239
|
+
*
|
|
1240
|
+
* @returns Array of active plugin instances
|
|
1241
|
+
*/
|
|
1242
|
+
get plugins(): Plugin<any>[];
|
|
1243
|
+
/**
|
|
1244
|
+
* Sets the list of plugins to be used by the manager.
|
|
1245
|
+
*
|
|
1246
|
+
* @param plugins - Array of plugin constructors or instances
|
|
1247
|
+
*/
|
|
1248
|
+
set plugins(plugins: Plugins<any>);
|
|
1249
|
+
/**
|
|
1250
|
+
* Gets the list of active modifiers.
|
|
1251
|
+
*
|
|
1252
|
+
* @returns Array of active modifier instances
|
|
1253
|
+
*/
|
|
1254
|
+
get modifiers(): Modifier<any>[];
|
|
1255
|
+
/**
|
|
1256
|
+
* Sets the list of modifiers to be used by the manager.
|
|
1257
|
+
*
|
|
1258
|
+
* @param modifiers - Array of modifier constructors or instances
|
|
1259
|
+
*/
|
|
1260
|
+
set modifiers(modifiers: Modifiers<any>);
|
|
1261
|
+
/**
|
|
1262
|
+
* Gets the list of active sensors.
|
|
1263
|
+
*
|
|
1264
|
+
* @returns Array of active sensor instances
|
|
1265
|
+
*/
|
|
1266
|
+
get sensors(): Sensor<any>[];
|
|
1267
|
+
/**
|
|
1268
|
+
* Sets the list of sensors to be used by the manager.
|
|
1269
|
+
*
|
|
1270
|
+
* @param sensors - Array of sensor constructors or instances
|
|
1271
|
+
*/
|
|
1272
|
+
set sensors(sensors: Sensors<any>);
|
|
1273
|
+
/**
|
|
1274
|
+
* Cleans up resources and stops any active drag operations.
|
|
1275
|
+
*/
|
|
1276
|
+
destroy: () => void;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
export { type Collision, type CollisionDetector, CollisionPriority, CollisionType, CorePlugin, type Data, DragActions, type DragDropEvents, DragDropManager, type DragDropManagerInput, type DragOperationSnapshot as DragOperation, 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 };
|