@caspeco/casper-ui-library 8.2.2 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/modal/modal.spec.d.ts +0 -1
- package/dist/components/modal/modal.spec.d.ts.map +1 -1
- package/dist/components/paginator/paginator.composition.d.ts +1 -0
- package/dist/components/paginator/paginator.composition.d.ts.map +1 -1
- package/dist/components/paginator/paginator.d.ts +3 -1
- package/dist/components/paginator/paginator.d.ts.map +1 -1
- package/dist/components/paginator/paginator.js +12 -11
- package/dist/components/table/helper.d.ts +2 -0
- package/dist/components/table/helper.d.ts.map +1 -0
- package/dist/components/table/helper.js +7 -0
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +93 -80
- package/dist/components/table/table-context-provider.d.ts +10 -2
- package/dist/components/table/table-context-provider.d.ts.map +1 -1
- package/dist/components/table/table-context-provider.js +149 -110
- package/dist/components/table/table-header-row.d.ts.map +1 -1
- package/dist/components/table/table-header-row.js +170 -121
- package/dist/components/table/table-row.js +11 -11
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +16 -8
- package/dist/components/table/table.spec.d.ts +0 -1
- package/dist/components/table/table.spec.d.ts.map +1 -1
- package/dist/components/table/types.d.ts +21 -0
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.spec.d.ts +0 -1
- package/dist/components/toggle-button/toggle-button.spec.d.ts.map +1 -1
- package/dist/node_modules/@dnd-kit/abstract/index.js +1142 -0
- package/dist/node_modules/@dnd-kit/collision/dist/index.js +91 -0
- package/dist/node_modules/@dnd-kit/dom/index.js +1554 -0
- package/dist/node_modules/@dnd-kit/dom/sortable.js +631 -0
- package/dist/node_modules/@dnd-kit/dom/utilities.js +943 -0
- package/dist/node_modules/@dnd-kit/geometry/dist/index.js +200 -0
- package/dist/node_modules/@dnd-kit/react/hooks.js +69 -0
- package/dist/node_modules/@dnd-kit/react/index.js +235 -0
- package/dist/node_modules/@dnd-kit/react/sortable.js +129 -0
- package/dist/node_modules/@dnd-kit/react/utilities.js +11 -0
- package/dist/node_modules/@dnd-kit/state/dist/index.js +181 -0
- package/dist/node_modules/@preact/signals-core/dist/signals-core.module.js +265 -0
- package/dist/test-utils/hooks/setup-mock-resize-observer.d.ts +1 -1
- package/dist/test-utils/hooks/setup-mock-resize-observer.d.ts.map +1 -1
- package/dist/theme/theme-config/components/paginator-theme.d.ts +5 -19
- package/dist/theme/theme-config/components/paginator-theme.d.ts.map +1 -1
- package/dist/theme/theme-config/components/paginator-theme.js +34 -18
- package/package.json +3 -1
|
@@ -0,0 +1,1142 @@
|
|
|
1
|
+
import { effects as rt, ValueHistory as Ie, snapshot as nt, reactive as _, derived as b } from "../state/dist/index.js";
|
|
2
|
+
import { Position as Pe } from "../geometry/dist/index.js";
|
|
3
|
+
import { untracked as k, effect as Lt, batch as Rt, signal as jt } from "../../@preact/signals-core/dist/signals-core.module.js";
|
|
4
|
+
var Se = Object.create, dt = Object.defineProperty, xe = Object.defineProperties, ze = Object.getOwnPropertyDescriptor, Ce = Object.getOwnPropertyDescriptors, st = Object.getOwnPropertySymbols, Ht = Object.prototype.hasOwnProperty, Vt = Object.prototype.propertyIsEnumerable, qt = (t, e) => (e = Symbol[t]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + t), q = (t) => {
|
|
5
|
+
throw TypeError(t);
|
|
6
|
+
}, ct = (t, e, s) => e in t ? dt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, Nt = (t, e) => {
|
|
7
|
+
for (var s in e || (e = {}))
|
|
8
|
+
Ht.call(e, s) && ct(t, s, e[s]);
|
|
9
|
+
if (st)
|
|
10
|
+
for (var s of st(e))
|
|
11
|
+
Vt.call(e, s) && ct(t, s, e[s]);
|
|
12
|
+
return t;
|
|
13
|
+
}, Ut = (t, e) => xe(t, Ce(e)), zt = (t, e) => dt(t, "name", { value: e, configurable: !0 }), Tt = (t, e) => {
|
|
14
|
+
var s = {};
|
|
15
|
+
for (var r in t)
|
|
16
|
+
Ht.call(t, r) && e.indexOf(r) < 0 && (s[r] = t[r]);
|
|
17
|
+
if (t != null && st)
|
|
18
|
+
for (var r of st(t))
|
|
19
|
+
e.indexOf(r) < 0 && Vt.call(t, r) && (s[r] = t[r]);
|
|
20
|
+
return s;
|
|
21
|
+
}, N = (t) => {
|
|
22
|
+
var e;
|
|
23
|
+
return [, , , Se((e = t?.[qt("metadata")]) != null ? e : null)];
|
|
24
|
+
}, $t = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], $ = (t) => t !== void 0 && typeof t != "function" ? q("Function expected") : t, Ae = (t, e, s, r, i) => ({ kind: $t[t], name: e, metadata: r, addInitializer: (n) => s._ ? q("Already initialized") : i.push($(n || null)) }), F = (t, e) => ct(e, qt("metadata"), t[3]), a = (t, e, s, r) => {
|
|
25
|
+
for (var i = 0, n = t[e >> 1], u = n && n.length; i < u; i++) e & 1 ? n[i].call(s) : r = n[i].call(s, r);
|
|
26
|
+
return r;
|
|
27
|
+
}, l = (t, e, s, r, i, n) => {
|
|
28
|
+
var u, o, p, h, g, c = e & 7, P = !!(e & 8), D = !!(e & 16), L = c > 3 ? t.length + 1 : c ? P ? 1 : 2 : 0, K = $t[c + 5], U = c > 3 && (t[L - 1] = []), R = t[L] || (t[L] = []), M = c && (!D && !P && (i = i.prototype), c < 5 && (c > 3 || !D) && ze(c < 4 ? i : { get [s]() {
|
|
29
|
+
return m(this, n);
|
|
30
|
+
}, set [s](O) {
|
|
31
|
+
return E(this, n, O);
|
|
32
|
+
} }, s));
|
|
33
|
+
c ? D && c < 4 && zt(n, (c > 2 ? "set " : c > 1 ? "get " : "") + s) : zt(i, s);
|
|
34
|
+
for (var T = r.length - 1; T >= 0; T--)
|
|
35
|
+
h = Ae(c, s, p = {}, t[3], R), c && (h.static = P, h.private = D, g = h.access = { has: D ? (O) => Fe(i, O) : (O) => s in O }, c ^ 3 && (g.get = D ? (O) => (c ^ 1 ? m : Le)(O, i, c ^ 4 ? n : M.get) : (O) => O[s]), c > 2 && (g.set = D ? (O, it) => E(O, i, it, c ^ 4 ? n : M.set) : (O, it) => O[s] = it)), o = (0, r[T])(c ? c < 4 ? D ? n : M[K] : c > 4 ? void 0 : { get: M.get, set: M.set } : i, h), p._ = 1, c ^ 4 || o === void 0 ? $(o) && (c > 4 ? U.unshift(o) : c ? D ? n = o : M[K] = o : i = o) : typeof o != "object" || o === null ? q("Object expected") : ($(u = o.get) && (M.get = u), $(u = o.set) && (M.set = u), $(u = o.init) && U.unshift(u));
|
|
36
|
+
return c || F(t, i), M && dt(i, s, M), D ? c ^ 4 ? n : M : i;
|
|
37
|
+
}, ht = (t, e, s) => e.has(t) || q("Cannot " + s), Fe = (t, e) => Object(e) !== e ? q('Cannot use the "in" operator on this value') : t.has(e), m = (t, e, s) => (ht(t, e, "read from private field"), s ? s.call(t) : e.get(t)), d = (t, e, s) => e.has(t) ? q("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), E = (t, e, s, r) => (ht(t, e, "write to private field"), r ? r.call(t, s) : e.set(t, s), s), Le = (t, e, s) => (ht(t, e, "access private method"), s);
|
|
38
|
+
function Gt(t, e) {
|
|
39
|
+
return {
|
|
40
|
+
plugin: t,
|
|
41
|
+
options: e
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function Qe(t) {
|
|
45
|
+
return (e) => Gt(t, e);
|
|
46
|
+
}
|
|
47
|
+
function Bt(t) {
|
|
48
|
+
return typeof t == "function" ? {
|
|
49
|
+
plugin: t,
|
|
50
|
+
options: void 0
|
|
51
|
+
} : t;
|
|
52
|
+
}
|
|
53
|
+
var Jt, J, pt, X;
|
|
54
|
+
Jt = [_];
|
|
55
|
+
var C = class {
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new plugin instance.
|
|
58
|
+
*
|
|
59
|
+
* @param manager - The drag and drop manager that owns this plugin
|
|
60
|
+
* @param options - Optional configuration for the plugin
|
|
61
|
+
*/
|
|
62
|
+
constructor(t, e) {
|
|
63
|
+
this.manager = t, this.options = e, d(this, pt, a(J, 8, this, !1)), a(J, 11, this), d(this, X, /* @__PURE__ */ new Set());
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Enables a disabled plugin instance.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* This method triggers effects when called.
|
|
70
|
+
*/
|
|
71
|
+
enable() {
|
|
72
|
+
this.disabled = !1;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Disables an enabled plugin instance.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* This method triggers effects when called.
|
|
79
|
+
*/
|
|
80
|
+
disable() {
|
|
81
|
+
this.disabled = !0;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks if the plugin instance is disabled.
|
|
85
|
+
*
|
|
86
|
+
* @returns true if the plugin is disabled
|
|
87
|
+
* @remarks
|
|
88
|
+
* This method does not trigger effects when accessed.
|
|
89
|
+
*/
|
|
90
|
+
isDisabled() {
|
|
91
|
+
return k(() => this.disabled);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Configures a plugin instance with new options.
|
|
95
|
+
*
|
|
96
|
+
* @param options - The new options to apply
|
|
97
|
+
*/
|
|
98
|
+
configure(t) {
|
|
99
|
+
this.options = t;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Registers an effect that will be cleaned up when the plugin is destroyed.
|
|
103
|
+
*
|
|
104
|
+
* @param callback - The effect callback to register
|
|
105
|
+
* @returns A function to dispose of the effect
|
|
106
|
+
*/
|
|
107
|
+
registerEffect(t) {
|
|
108
|
+
const e = Lt(t.bind(this));
|
|
109
|
+
return m(this, X).add(e), e;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Destroys a plugin instance and cleans up its resources.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* This method:
|
|
116
|
+
* - Calls all registered cleanup functions
|
|
117
|
+
* - Should be overridden by subclasses to clean up additional resources
|
|
118
|
+
*/
|
|
119
|
+
destroy() {
|
|
120
|
+
m(this, X).forEach((t) => t());
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Configures a plugin constructor with options.
|
|
124
|
+
*
|
|
125
|
+
* @param options - The options to configure the constructor with
|
|
126
|
+
* @returns The configured plugin constructor
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This method is used to configure the options that the
|
|
130
|
+
* plugin constructor will use to create plugin instances.
|
|
131
|
+
*/
|
|
132
|
+
static configure(t) {
|
|
133
|
+
return Gt(this, t);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
J = N(null);
|
|
137
|
+
pt = /* @__PURE__ */ new WeakMap();
|
|
138
|
+
X = /* @__PURE__ */ new WeakMap();
|
|
139
|
+
l(J, 4, "disabled", Jt, C, pt);
|
|
140
|
+
F(J, C);
|
|
141
|
+
var Kt = class extends C {
|
|
142
|
+
}, Y, at = class {
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new plugin registry.
|
|
145
|
+
*
|
|
146
|
+
* @param manager - The drag and drop manager that owns this registry
|
|
147
|
+
*/
|
|
148
|
+
constructor(t) {
|
|
149
|
+
this.manager = t, this.instances = /* @__PURE__ */ new Map(), d(this, Y, []);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Gets all registered plugin instances.
|
|
153
|
+
*
|
|
154
|
+
* @returns An array of all active plugin instances
|
|
155
|
+
*/
|
|
156
|
+
get values() {
|
|
157
|
+
return Array.from(this.instances.values());
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Sets the list of plugins to be used by the registry.
|
|
161
|
+
*
|
|
162
|
+
* @param entries - Array of plugin constructors or descriptors
|
|
163
|
+
* @remarks
|
|
164
|
+
* This method:
|
|
165
|
+
* - Filters out duplicate plugins
|
|
166
|
+
* - Unregisters plugins that are no longer in use
|
|
167
|
+
* - Registers new plugins with their options
|
|
168
|
+
*/
|
|
169
|
+
set values(t) {
|
|
170
|
+
const e = t.map(Bt).reduceRight((r, i) => r.some(({ plugin: n }) => n === i.plugin) ? r : [i, ...r], []), s = e.map(({ plugin: r }) => r);
|
|
171
|
+
for (const r of m(this, Y))
|
|
172
|
+
if (!s.includes(r)) {
|
|
173
|
+
if (r.prototype instanceof Kt)
|
|
174
|
+
continue;
|
|
175
|
+
this.unregister(r);
|
|
176
|
+
}
|
|
177
|
+
for (const { plugin: r, options: i } of e)
|
|
178
|
+
this.register(r, i);
|
|
179
|
+
E(this, Y, s);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Gets a plugin instance by its constructor.
|
|
183
|
+
*
|
|
184
|
+
* @param plugin - The plugin constructor to look up
|
|
185
|
+
* @returns The plugin instance or undefined if not found
|
|
186
|
+
*/
|
|
187
|
+
get(t) {
|
|
188
|
+
return this.instances.get(t);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Registers a new plugin instance.
|
|
192
|
+
*
|
|
193
|
+
* @param plugin - The plugin constructor to register
|
|
194
|
+
* @param options - Optional configuration for the plugin
|
|
195
|
+
* @returns The registered plugin instance
|
|
196
|
+
* @remarks
|
|
197
|
+
* If the plugin is already registered, its options will be updated
|
|
198
|
+
* and the existing instance will be returned.
|
|
199
|
+
*/
|
|
200
|
+
register(t, e) {
|
|
201
|
+
const s = this.instances.get(t);
|
|
202
|
+
if (s)
|
|
203
|
+
return s.options !== e && (s.options = e), s;
|
|
204
|
+
const r = new t(this.manager, e);
|
|
205
|
+
return this.instances.set(t, r), r;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Unregisters a plugin instance.
|
|
209
|
+
*
|
|
210
|
+
* @param plugin - The plugin constructor to unregister
|
|
211
|
+
* @remarks
|
|
212
|
+
* This method:
|
|
213
|
+
* - Destroys the plugin instance
|
|
214
|
+
* - Removes it from the registry
|
|
215
|
+
*/
|
|
216
|
+
unregister(t) {
|
|
217
|
+
const e = this.instances.get(t);
|
|
218
|
+
e && (e.destroy(), this.instances.delete(t));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Destroys all registered plugin instances.
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* This method:
|
|
225
|
+
* - Calls destroy() on all plugin instances
|
|
226
|
+
* - Clears the registry
|
|
227
|
+
*/
|
|
228
|
+
destroy() {
|
|
229
|
+
for (const t of this.instances.values())
|
|
230
|
+
t.destroy();
|
|
231
|
+
this.instances.clear();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
Y = /* @__PURE__ */ new WeakMap();
|
|
235
|
+
function Re(t, e) {
|
|
236
|
+
return t.priority === e.priority ? t.type === e.type ? e.value - t.value : e.type - t.type : e.priority - t.priority;
|
|
237
|
+
}
|
|
238
|
+
var Q = [], j, H, je = class extends C {
|
|
239
|
+
/**
|
|
240
|
+
* Creates a new CollisionObserver instance.
|
|
241
|
+
*
|
|
242
|
+
* @param manager - The drag drop manager instance
|
|
243
|
+
*/
|
|
244
|
+
constructor(t) {
|
|
245
|
+
super(t), d(this, j), d(this, H), this.computeCollisions = this.computeCollisions.bind(this), E(this, H, jt(Q)), this.destroy = rt(
|
|
246
|
+
() => {
|
|
247
|
+
const e = this.computeCollisions(), s = k(
|
|
248
|
+
() => this.manager.dragOperation.position.current
|
|
249
|
+
);
|
|
250
|
+
if (e !== Q) {
|
|
251
|
+
const r = m(this, j);
|
|
252
|
+
if (E(this, j, s), r && s.x == r.x && s.y == r.y)
|
|
253
|
+
return;
|
|
254
|
+
} else
|
|
255
|
+
E(this, j, void 0);
|
|
256
|
+
m(this, H).value = e;
|
|
257
|
+
},
|
|
258
|
+
() => {
|
|
259
|
+
const { dragOperation: e } = this.manager;
|
|
260
|
+
e.status.initialized && this.forceUpdate();
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Forces an immediate update of collision detection.
|
|
266
|
+
*
|
|
267
|
+
* @param immediate - If true, updates collisions immediately. If false, resets previous coordinates.
|
|
268
|
+
*/
|
|
269
|
+
forceUpdate(t = !0) {
|
|
270
|
+
k(() => {
|
|
271
|
+
t ? m(this, H).value = this.computeCollisions() : E(this, j, void 0);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Computes collisions between draggable and droppable elements.
|
|
276
|
+
*
|
|
277
|
+
* @param entries - Optional array of droppable elements to check. If not provided, uses all registered droppables.
|
|
278
|
+
* @param collisionDetector - Optional custom collision detector function
|
|
279
|
+
* @returns Array of detected collisions, sorted by priority
|
|
280
|
+
*/
|
|
281
|
+
computeCollisions(t, e) {
|
|
282
|
+
const { registry: s, dragOperation: r } = this.manager, { source: i, shape: n, status: u } = r;
|
|
283
|
+
if (!u.initialized || !n)
|
|
284
|
+
return Q;
|
|
285
|
+
const o = [], p = [];
|
|
286
|
+
for (const h of t ?? s.droppables) {
|
|
287
|
+
if (h.disabled || i && !h.accepts(i))
|
|
288
|
+
continue;
|
|
289
|
+
const g = e ?? h.collisionDetector;
|
|
290
|
+
if (!g)
|
|
291
|
+
continue;
|
|
292
|
+
p.push(h), h.shape;
|
|
293
|
+
const c = k(
|
|
294
|
+
() => g({
|
|
295
|
+
droppable: h,
|
|
296
|
+
dragOperation: r
|
|
297
|
+
})
|
|
298
|
+
);
|
|
299
|
+
c && (h.collisionPriority != null && (c.priority = h.collisionPriority), o.push(c));
|
|
300
|
+
}
|
|
301
|
+
return p.length === 0 ? Q : (o.sort(Re), o);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Gets the current collisions signal value.
|
|
305
|
+
*/
|
|
306
|
+
get collisions() {
|
|
307
|
+
return m(this, H).value;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
j = /* @__PURE__ */ new WeakMap();
|
|
311
|
+
H = /* @__PURE__ */ new WeakMap();
|
|
312
|
+
var He = class {
|
|
313
|
+
constructor() {
|
|
314
|
+
this.registry = /* @__PURE__ */ new Map();
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Adds an event listener for the specified event type.
|
|
318
|
+
*
|
|
319
|
+
* @param name - The name of the event to listen for
|
|
320
|
+
* @param handler - The function to call when the event occurs
|
|
321
|
+
* @returns A function to remove the event listener
|
|
322
|
+
*/
|
|
323
|
+
addEventListener(t, e) {
|
|
324
|
+
const { registry: s } = this, r = new Set(s.get(t));
|
|
325
|
+
return r.add(e), s.set(t, r), () => this.removeEventListener(t, e);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Removes an event listener for the specified event type.
|
|
329
|
+
*
|
|
330
|
+
* @param name - The name of the event
|
|
331
|
+
* @param handler - The function to remove
|
|
332
|
+
*/
|
|
333
|
+
removeEventListener(t, e) {
|
|
334
|
+
const { registry: s } = this, r = new Set(s.get(t));
|
|
335
|
+
r.delete(e), s.set(t, r);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Dispatches an event to all registered listeners.
|
|
339
|
+
*
|
|
340
|
+
* @param name - The name of the event to dispatch
|
|
341
|
+
* @param args - Arguments to pass to the event handlers
|
|
342
|
+
*/
|
|
343
|
+
dispatch(t, ...e) {
|
|
344
|
+
const { registry: s } = this, r = s.get(t);
|
|
345
|
+
if (r)
|
|
346
|
+
for (const i of r)
|
|
347
|
+
i(...e);
|
|
348
|
+
}
|
|
349
|
+
}, Ve = class extends He {
|
|
350
|
+
/**
|
|
351
|
+
* Creates a new drag and drop monitor.
|
|
352
|
+
*
|
|
353
|
+
* @param manager - The drag and drop manager to monitor
|
|
354
|
+
*/
|
|
355
|
+
constructor(t) {
|
|
356
|
+
super(), this.manager = t;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Dispatches a drag and drop event.
|
|
360
|
+
*
|
|
361
|
+
* @param type - The type of event to dispatch
|
|
362
|
+
* @param event - The event data to dispatch
|
|
363
|
+
*/
|
|
364
|
+
dispatch(t, e) {
|
|
365
|
+
const s = [e, this.manager];
|
|
366
|
+
super.dispatch(t, ...s);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
function Z(t, e = !0) {
|
|
370
|
+
let s = !1;
|
|
371
|
+
return Ut(Nt({}, t), {
|
|
372
|
+
cancelable: e,
|
|
373
|
+
get defaultPrevented() {
|
|
374
|
+
return s;
|
|
375
|
+
},
|
|
376
|
+
preventDefault() {
|
|
377
|
+
e && (s = !0);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
var qe = class extends Kt {
|
|
382
|
+
constructor(t) {
|
|
383
|
+
super(t);
|
|
384
|
+
const e = (r, i) => r.map(({ id: n }) => n).join("") === i.map(({ id: n }) => n).join("");
|
|
385
|
+
let s = [];
|
|
386
|
+
this.destroy = rt(
|
|
387
|
+
() => {
|
|
388
|
+
const { dragOperation: r, collisionObserver: i } = t;
|
|
389
|
+
r.status.initializing && (s = [], i.enable());
|
|
390
|
+
},
|
|
391
|
+
() => {
|
|
392
|
+
const { collisionObserver: r, monitor: i } = t, { collisions: n } = r;
|
|
393
|
+
if (r.isDisabled())
|
|
394
|
+
return;
|
|
395
|
+
const u = Z({
|
|
396
|
+
collisions: n
|
|
397
|
+
});
|
|
398
|
+
if (i.dispatch("collision", u), u.defaultPrevented || e(n, s))
|
|
399
|
+
return;
|
|
400
|
+
s = n;
|
|
401
|
+
const [o] = n;
|
|
402
|
+
k(() => {
|
|
403
|
+
var p;
|
|
404
|
+
o?.id !== ((p = t.dragOperation.target) == null ? void 0 : p.id) && (r.disable(), t.actions.setDropTarget(o?.id).then(() => {
|
|
405
|
+
r.enable();
|
|
406
|
+
}));
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
}, Ne = /* @__PURE__ */ ((t) => (t[t.Lowest = 0] = "Lowest", t[t.Low = 1] = "Low", t[t.Normal = 2] = "Normal", t[t.High = 3] = "High", t[t.Highest = 4] = "Highest", t))(Ne || {}), Ue = /* @__PURE__ */ ((t) => (t[t.Collision = 0] = "Collision", t[t.ShapeIntersection = 1] = "ShapeIntersection", t[t.PointerIntersection = 2] = "PointerIntersection", t))(Ue || {}), Qt, Xt, Yt, Zt, te, ee, se, W, gt;
|
|
412
|
+
se = [_], ee = [b], te = [b], Zt = [b], Yt = [b], Xt = [b], Qt = [b];
|
|
413
|
+
var z = class {
|
|
414
|
+
constructor() {
|
|
415
|
+
a(W, 5, this), d(this, gt, a(
|
|
416
|
+
W,
|
|
417
|
+
8,
|
|
418
|
+
this,
|
|
419
|
+
"idle"
|
|
420
|
+
/* Idle */
|
|
421
|
+
)), a(W, 11, this);
|
|
422
|
+
}
|
|
423
|
+
get current() {
|
|
424
|
+
return this.value;
|
|
425
|
+
}
|
|
426
|
+
get idle() {
|
|
427
|
+
return this.value === "idle";
|
|
428
|
+
}
|
|
429
|
+
get initializing() {
|
|
430
|
+
return this.value === "initializing";
|
|
431
|
+
}
|
|
432
|
+
get initialized() {
|
|
433
|
+
const { value: t } = this;
|
|
434
|
+
return t !== "idle" && t !== "initialization-pending";
|
|
435
|
+
}
|
|
436
|
+
get dragging() {
|
|
437
|
+
return this.value === "dragging";
|
|
438
|
+
}
|
|
439
|
+
get dropped() {
|
|
440
|
+
return this.value === "dropped";
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Sets the current status value.
|
|
444
|
+
*
|
|
445
|
+
* @param value - The new status value
|
|
446
|
+
*/
|
|
447
|
+
set(t) {
|
|
448
|
+
this.value = t;
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
W = N(null);
|
|
452
|
+
gt = /* @__PURE__ */ new WeakMap();
|
|
453
|
+
l(W, 4, "value", se, z, gt);
|
|
454
|
+
l(W, 2, "current", ee, z);
|
|
455
|
+
l(W, 2, "idle", te, z);
|
|
456
|
+
l(W, 2, "initializing", Zt, z);
|
|
457
|
+
l(W, 2, "initialized", Yt, z);
|
|
458
|
+
l(W, 2, "dragging", Xt, z);
|
|
459
|
+
l(W, 2, "dropped", Qt, z);
|
|
460
|
+
F(W, z);
|
|
461
|
+
var Te = class {
|
|
462
|
+
/**
|
|
463
|
+
* Creates a new instance of drag actions.
|
|
464
|
+
*
|
|
465
|
+
* @param manager - The drag and drop manager instance
|
|
466
|
+
*/
|
|
467
|
+
constructor(t) {
|
|
468
|
+
this.manager = t;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Sets the source of the drag operation.
|
|
472
|
+
*
|
|
473
|
+
* @param source - The draggable entity or its unique identifier
|
|
474
|
+
*/
|
|
475
|
+
setDragSource(t) {
|
|
476
|
+
const { dragOperation: e } = this.manager;
|
|
477
|
+
e.sourceIdentifier = typeof t == "string" || typeof t == "number" ? t : t.id;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Sets the target of the drop operation.
|
|
481
|
+
*
|
|
482
|
+
* @param identifier - The unique identifier of the droppable entity or null/undefined
|
|
483
|
+
* @returns A promise that resolves to true if the drop was prevented
|
|
484
|
+
*/
|
|
485
|
+
setDropTarget(t) {
|
|
486
|
+
return k(() => {
|
|
487
|
+
const { dragOperation: e } = this.manager, s = t ?? null;
|
|
488
|
+
if (e.targetIdentifier === s)
|
|
489
|
+
return Promise.resolve(!1);
|
|
490
|
+
e.targetIdentifier = s;
|
|
491
|
+
const r = Z({
|
|
492
|
+
operation: e.snapshot()
|
|
493
|
+
});
|
|
494
|
+
return e.status.dragging && this.manager.monitor.dispatch("dragover", r), this.manager.renderer.rendering.then(() => r.defaultPrevented);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Starts a new drag operation.
|
|
499
|
+
*
|
|
500
|
+
* @param args - Configuration for the drag operation
|
|
501
|
+
* @param args.event - The event that initiated the drag
|
|
502
|
+
* @param args.source - The source draggable entity or its identifier
|
|
503
|
+
* @param args.coordinates - The initial coordinates of the drag
|
|
504
|
+
* @returns true if the drag operation started successfully
|
|
505
|
+
* @throws {Error} If there is no drag source or another operation is active
|
|
506
|
+
*/
|
|
507
|
+
start(t) {
|
|
508
|
+
return k(() => {
|
|
509
|
+
const { dragOperation: e } = this.manager;
|
|
510
|
+
if (t.source != null && this.setDragSource(t.source), !e.source)
|
|
511
|
+
throw new Error("Cannot start a drag operation without a drag source");
|
|
512
|
+
if (!e.status.idle)
|
|
513
|
+
throw new Error(
|
|
514
|
+
"Cannot start a drag operation while another is active"
|
|
515
|
+
);
|
|
516
|
+
const r = new AbortController(), { event: i, coordinates: n } = t;
|
|
517
|
+
Rt(() => {
|
|
518
|
+
e.status.set(
|
|
519
|
+
"initialization-pending"
|
|
520
|
+
/* InitializationPending */
|
|
521
|
+
), e.shape = null, e.canceled = !1, e.activatorEvent = i ?? null, e.position.reset(n);
|
|
522
|
+
});
|
|
523
|
+
const u = Z({
|
|
524
|
+
operation: e.snapshot()
|
|
525
|
+
});
|
|
526
|
+
return this.manager.monitor.dispatch("beforedragstart", u), u.defaultPrevented ? (e.reset(), r.abort(), r) : (e.status.set(
|
|
527
|
+
"initializing"
|
|
528
|
+
/* Initializing */
|
|
529
|
+
), e.controller = r, this.manager.renderer.rendering.then(() => {
|
|
530
|
+
if (r.signal.aborted) return;
|
|
531
|
+
const { status: o } = e;
|
|
532
|
+
o.current === "initializing" && (e.status.set(
|
|
533
|
+
"dragging"
|
|
534
|
+
/* Dragging */
|
|
535
|
+
), this.manager.monitor.dispatch("dragstart", {
|
|
536
|
+
nativeEvent: i,
|
|
537
|
+
operation: e.snapshot(),
|
|
538
|
+
cancelable: !1
|
|
539
|
+
}));
|
|
540
|
+
}), r);
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Moves the dragged entity to a new position.
|
|
545
|
+
*
|
|
546
|
+
* @param args - Configuration for the move operation
|
|
547
|
+
* @param args.by - Relative coordinates to move by
|
|
548
|
+
* @param args.to - Absolute coordinates to move to
|
|
549
|
+
* @param args.event - The event that triggered the move
|
|
550
|
+
* @param args.cancelable - Whether the move can be canceled
|
|
551
|
+
* @param args.propagate - Whether to dispatch dragmove events
|
|
552
|
+
*/
|
|
553
|
+
move(t) {
|
|
554
|
+
return k(() => {
|
|
555
|
+
var e, s;
|
|
556
|
+
const { dragOperation: r } = this.manager, { status: i, controller: n } = r;
|
|
557
|
+
if (!i.dragging || !n || n.signal.aborted)
|
|
558
|
+
return;
|
|
559
|
+
const u = Z(
|
|
560
|
+
{
|
|
561
|
+
nativeEvent: t.event,
|
|
562
|
+
operation: r.snapshot(),
|
|
563
|
+
by: t.by,
|
|
564
|
+
to: t.to
|
|
565
|
+
},
|
|
566
|
+
(e = t.cancelable) != null ? e : !0
|
|
567
|
+
);
|
|
568
|
+
((s = t.propagate) == null || s) && this.manager.monitor.dispatch("dragmove", u), queueMicrotask(() => {
|
|
569
|
+
var o, p, h, g, c;
|
|
570
|
+
if (u.defaultPrevented)
|
|
571
|
+
return;
|
|
572
|
+
const P = (c = t.to) != null ? c : {
|
|
573
|
+
x: r.position.current.x + ((p = (o = t.by) == null ? void 0 : o.x) != null ? p : 0),
|
|
574
|
+
y: r.position.current.y + ((g = (h = t.by) == null ? void 0 : h.y) != null ? g : 0)
|
|
575
|
+
};
|
|
576
|
+
r.position.current = P;
|
|
577
|
+
});
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Stops the current drag operation.
|
|
582
|
+
*
|
|
583
|
+
* @param args - Configuration for stopping the operation
|
|
584
|
+
* @param args.event - The event that triggered the stop
|
|
585
|
+
* @param args.canceled - Whether the operation was canceled
|
|
586
|
+
* @remarks
|
|
587
|
+
* This method:
|
|
588
|
+
* - Dispatches a dragend event
|
|
589
|
+
* - Allows suspension of the operation
|
|
590
|
+
* - Handles cleanup of the operation state
|
|
591
|
+
*/
|
|
592
|
+
stop(t = {}) {
|
|
593
|
+
return k(() => {
|
|
594
|
+
var e, s;
|
|
595
|
+
const { dragOperation: r } = this.manager, { controller: i } = r;
|
|
596
|
+
if (!i || i.signal.aborted) return;
|
|
597
|
+
let n;
|
|
598
|
+
const u = () => {
|
|
599
|
+
const p = {
|
|
600
|
+
resume: () => {
|
|
601
|
+
},
|
|
602
|
+
abort: () => {
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
return n = new Promise((h, g) => {
|
|
606
|
+
p.resume = h, p.abort = g;
|
|
607
|
+
}), p;
|
|
608
|
+
};
|
|
609
|
+
i.abort();
|
|
610
|
+
const o = () => {
|
|
611
|
+
this.manager.renderer.rendering.then(() => {
|
|
612
|
+
r.status.set(
|
|
613
|
+
"dropped"
|
|
614
|
+
/* Dropped */
|
|
615
|
+
);
|
|
616
|
+
const p = k(
|
|
617
|
+
() => {
|
|
618
|
+
var g;
|
|
619
|
+
return ((g = r.source) == null ? void 0 : g.status) === "dropping";
|
|
620
|
+
}
|
|
621
|
+
), h = () => {
|
|
622
|
+
r.controller === i && (r.controller = void 0), r.reset();
|
|
623
|
+
};
|
|
624
|
+
if (p) {
|
|
625
|
+
const { source: g } = r, c = Lt(() => {
|
|
626
|
+
g?.status === "idle" && (c(), h());
|
|
627
|
+
});
|
|
628
|
+
} else
|
|
629
|
+
this.manager.renderer.rendering.then(h);
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
r.canceled = (e = t.canceled) != null ? e : !1, this.manager.monitor.dispatch("dragend", {
|
|
633
|
+
nativeEvent: t.event,
|
|
634
|
+
operation: r.snapshot(),
|
|
635
|
+
canceled: (s = t.canceled) != null ? s : !1,
|
|
636
|
+
suspend: u
|
|
637
|
+
}), n ? n.then(o).catch(() => r.reset()) : o();
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}, re, ie, ne, ae, w, ft, vt, _t, mt;
|
|
641
|
+
ae = [_], ne = [_], ie = [_], re = [_];
|
|
642
|
+
var A = class {
|
|
643
|
+
/**
|
|
644
|
+
* Creates a new instance of the `Entity` class.
|
|
645
|
+
*
|
|
646
|
+
* @param input - An object containing the initial properties of the entity.
|
|
647
|
+
* @param manager - The manager that controls the drag and drop operations.
|
|
648
|
+
*/
|
|
649
|
+
constructor(t, e) {
|
|
650
|
+
d(this, ft, a(w, 8, this)), a(w, 11, this), d(this, vt, a(w, 12, this)), a(w, 15, this), d(this, _t, a(w, 16, this)), a(w, 19, this), d(this, mt, a(w, 20, this)), a(w, 23, this);
|
|
651
|
+
const { effects: s, id: r, data: i = {}, disabled: n = !1, register: u = !0 } = t;
|
|
652
|
+
let o = r;
|
|
653
|
+
this.manager = e, this.id = r, this.data = i, this.disabled = n, this.effects = () => {
|
|
654
|
+
var p;
|
|
655
|
+
return [
|
|
656
|
+
() => {
|
|
657
|
+
const { id: h, manager: g } = this;
|
|
658
|
+
if (h !== o)
|
|
659
|
+
return g?.registry.register(this), () => g?.registry.unregister(this);
|
|
660
|
+
},
|
|
661
|
+
...(p = s?.()) != null ? p : []
|
|
662
|
+
];
|
|
663
|
+
}, this.register = this.register.bind(this), this.unregister = this.unregister.bind(this), this.destroy = this.destroy.bind(this), e && u && queueMicrotask(this.register);
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* A method that registers the entity with the manager.
|
|
667
|
+
* @returns CleanupFunction | void
|
|
668
|
+
*/
|
|
669
|
+
register() {
|
|
670
|
+
var t;
|
|
671
|
+
return (t = this.manager) == null ? void 0 : t.registry.register(this);
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* A method that unregisters the entity from the manager.
|
|
675
|
+
* @returns void
|
|
676
|
+
*/
|
|
677
|
+
unregister() {
|
|
678
|
+
var t;
|
|
679
|
+
(t = this.manager) == null || t.registry.unregister(this);
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* A method that cleans up the entity when it is no longer needed.
|
|
683
|
+
* @returns void
|
|
684
|
+
*/
|
|
685
|
+
destroy() {
|
|
686
|
+
var t;
|
|
687
|
+
(t = this.manager) == null || t.registry.unregister(this);
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
w = N(null);
|
|
691
|
+
ft = /* @__PURE__ */ new WeakMap();
|
|
692
|
+
vt = /* @__PURE__ */ new WeakMap();
|
|
693
|
+
_t = /* @__PURE__ */ new WeakMap();
|
|
694
|
+
mt = /* @__PURE__ */ new WeakMap();
|
|
695
|
+
l(w, 4, "manager", ae, A, ft);
|
|
696
|
+
l(w, 4, "id", ne, A, vt);
|
|
697
|
+
l(w, 4, "data", ie, A, _t);
|
|
698
|
+
l(w, 4, "disabled", re, A, mt);
|
|
699
|
+
F(w, A);
|
|
700
|
+
var Ct = class {
|
|
701
|
+
constructor() {
|
|
702
|
+
this.map = jt(/* @__PURE__ */ new Map()), this.cleanupFunctions = /* @__PURE__ */ new WeakMap(), this.register = (t, e) => {
|
|
703
|
+
const s = this.map.peek(), r = s.get(t), i = () => this.unregister(t, e);
|
|
704
|
+
if (r === e) return i;
|
|
705
|
+
if (r) {
|
|
706
|
+
const o = this.cleanupFunctions.get(r);
|
|
707
|
+
o?.(), this.cleanupFunctions.delete(r);
|
|
708
|
+
}
|
|
709
|
+
const n = new Map(s);
|
|
710
|
+
n.set(t, e), this.map.value = n;
|
|
711
|
+
const u = rt(...e.effects());
|
|
712
|
+
return this.cleanupFunctions.set(e, u), i;
|
|
713
|
+
}, this.unregister = (t, e) => {
|
|
714
|
+
const s = this.map.peek();
|
|
715
|
+
if (s.get(t) !== e)
|
|
716
|
+
return;
|
|
717
|
+
const r = this.cleanupFunctions.get(e);
|
|
718
|
+
r?.(), this.cleanupFunctions.delete(e);
|
|
719
|
+
const i = new Map(s);
|
|
720
|
+
i.delete(t), this.map.value = i;
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Iterator for the EntityRegistry class.
|
|
725
|
+
* @returns An iterator for the values in the map.
|
|
726
|
+
*/
|
|
727
|
+
[Symbol.iterator]() {
|
|
728
|
+
return this.map.peek().values();
|
|
729
|
+
}
|
|
730
|
+
get value() {
|
|
731
|
+
return this.map.value.values();
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Checks if a entity with the given identifier exists in the registry.
|
|
735
|
+
* @param identifier - The unique identifier of the entity.
|
|
736
|
+
* @returns True if the entity exists, false otherwise.
|
|
737
|
+
*/
|
|
738
|
+
has(t) {
|
|
739
|
+
return this.map.value.has(t);
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Retrieves a entity from the registry using its identifier.
|
|
743
|
+
* @param identifier - The unique identifier of the entity.
|
|
744
|
+
* @returns The entity if it exists, undefined otherwise.
|
|
745
|
+
*/
|
|
746
|
+
get(t) {
|
|
747
|
+
return this.map.value.get(t);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Destroys all entries in the registry and clears the registry.
|
|
751
|
+
*/
|
|
752
|
+
destroy() {
|
|
753
|
+
for (const t of this) {
|
|
754
|
+
const e = this.cleanupFunctions.get(t);
|
|
755
|
+
e?.(), t.destroy();
|
|
756
|
+
}
|
|
757
|
+
this.map.value = /* @__PURE__ */ new Map();
|
|
758
|
+
}
|
|
759
|
+
}, oe, ce, le, ue, de, he, lt, y, yt, wt, bt, S = class extends (lt = A, he = [_], de = [_], ue = [_], le = [b], ce = [b], oe = [b], lt) {
|
|
760
|
+
constructor(e, s) {
|
|
761
|
+
var r = e, { modifiers: i, type: n, sensors: u } = r, o = Tt(r, ["modifiers", "type", "sensors"]);
|
|
762
|
+
super(o, s), a(y, 5, this), d(this, yt, a(y, 8, this)), a(y, 11, this), d(this, wt, a(y, 12, this)), a(y, 15, this), d(this, bt, a(y, 16, this, this.isDragSource ? "dragging" : "idle")), a(y, 19, this), this.type = n, this.sensors = u, this.modifiers = i, this.alignment = o.alignment;
|
|
763
|
+
}
|
|
764
|
+
get isDropping() {
|
|
765
|
+
return this.status === "dropping" && this.isDragSource;
|
|
766
|
+
}
|
|
767
|
+
get isDragging() {
|
|
768
|
+
return this.status === "dragging" && this.isDragSource;
|
|
769
|
+
}
|
|
770
|
+
get isDragSource() {
|
|
771
|
+
var e, s;
|
|
772
|
+
return ((s = (e = this.manager) == null ? void 0 : e.dragOperation.source) == null ? void 0 : s.id) === this.id;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
y = N(lt);
|
|
776
|
+
yt = /* @__PURE__ */ new WeakMap();
|
|
777
|
+
wt = /* @__PURE__ */ new WeakMap();
|
|
778
|
+
bt = /* @__PURE__ */ new WeakMap();
|
|
779
|
+
l(y, 4, "type", he, S, yt);
|
|
780
|
+
l(y, 4, "modifiers", de, S, wt);
|
|
781
|
+
l(y, 4, "status", ue, S, bt);
|
|
782
|
+
l(y, 2, "isDropping", le, S);
|
|
783
|
+
l(y, 2, "isDragging", ce, S);
|
|
784
|
+
l(y, 2, "isDragSource", oe, S);
|
|
785
|
+
F(y, S);
|
|
786
|
+
var pe, ge, fe, ve, _e, me, ut, v, Dt, Mt, Ot, kt, Et, x = class extends (ut = A, me = [_], _e = [_], ve = [_], fe = [_], ge = [_], pe = [b], ut) {
|
|
787
|
+
constructor(e, s) {
|
|
788
|
+
var r = e, { accept: i, collisionDetector: n, collisionPriority: u, type: o } = r, p = Tt(r, ["accept", "collisionDetector", "collisionPriority", "type"]);
|
|
789
|
+
super(p, s), a(v, 5, this), d(this, Dt, a(v, 8, this)), a(v, 11, this), d(this, Mt, a(v, 12, this)), a(v, 15, this), d(this, Ot, a(v, 16, this)), a(v, 19, this), d(this, kt, a(v, 20, this)), a(v, 23, this), d(this, Et, a(v, 24, this)), a(v, 27, this), this.accept = i, this.collisionDetector = n, this.collisionPriority = u, this.type = o;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* Checks whether or not the droppable accepts a given draggable.
|
|
793
|
+
*
|
|
794
|
+
* @param draggable - The draggable to check
|
|
795
|
+
* @returns true if the draggable can be dropped here
|
|
796
|
+
*/
|
|
797
|
+
accepts(e) {
|
|
798
|
+
const { accept: s } = this;
|
|
799
|
+
return s ? typeof s == "function" ? s(e) : e.type ? Array.isArray(s) ? s.includes(e.type) : e.type === s : !1 : !0;
|
|
800
|
+
}
|
|
801
|
+
get isDropTarget() {
|
|
802
|
+
var e, s;
|
|
803
|
+
return ((s = (e = this.manager) == null ? void 0 : e.dragOperation.target) == null ? void 0 : s.id) === this.id;
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
v = N(ut);
|
|
807
|
+
Dt = /* @__PURE__ */ new WeakMap();
|
|
808
|
+
Mt = /* @__PURE__ */ new WeakMap();
|
|
809
|
+
Ot = /* @__PURE__ */ new WeakMap();
|
|
810
|
+
kt = /* @__PURE__ */ new WeakMap();
|
|
811
|
+
Et = /* @__PURE__ */ new WeakMap();
|
|
812
|
+
l(v, 4, "accept", me, x, Dt);
|
|
813
|
+
l(v, 4, "type", _e, x, Mt);
|
|
814
|
+
l(v, 4, "collisionDetector", ve, x, Ot);
|
|
815
|
+
l(v, 4, "collisionPriority", fe, x, kt);
|
|
816
|
+
l(v, 4, "shape", ge, x, Et);
|
|
817
|
+
l(v, 2, "isDropTarget", pe, x);
|
|
818
|
+
F(v, x);
|
|
819
|
+
var At = class extends C {
|
|
820
|
+
/**
|
|
821
|
+
* Creates a new sensor instance.
|
|
822
|
+
*
|
|
823
|
+
* @param manager - The drag drop manager instance
|
|
824
|
+
* @param options - Optional sensor configuration
|
|
825
|
+
*/
|
|
826
|
+
constructor(t, e) {
|
|
827
|
+
super(t, e), this.manager = t, this.options = e;
|
|
828
|
+
}
|
|
829
|
+
}, Ze = class extends AbortController {
|
|
830
|
+
constructor(t, e) {
|
|
831
|
+
super(), this.constraints = t, this.onActivate = e, this.activated = !1;
|
|
832
|
+
for (const s of t ?? [])
|
|
833
|
+
s.controller = this;
|
|
834
|
+
}
|
|
835
|
+
onEvent(t) {
|
|
836
|
+
var e;
|
|
837
|
+
if (!this.activated)
|
|
838
|
+
if ((e = this.constraints) != null && e.length)
|
|
839
|
+
for (const s of this.constraints)
|
|
840
|
+
s.onEvent(t);
|
|
841
|
+
else
|
|
842
|
+
this.activate(t);
|
|
843
|
+
}
|
|
844
|
+
activate(t) {
|
|
845
|
+
this.activated || (this.activated = !0, this.onActivate(t));
|
|
846
|
+
}
|
|
847
|
+
abort(t) {
|
|
848
|
+
this.activated = !1, super.abort(t);
|
|
849
|
+
}
|
|
850
|
+
}, tt, ts = class {
|
|
851
|
+
constructor(t) {
|
|
852
|
+
this.options = t, d(this, tt);
|
|
853
|
+
}
|
|
854
|
+
set controller(t) {
|
|
855
|
+
E(this, tt, t), t.signal.addEventListener("abort", () => this.abort());
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Called when the activation is triggered.
|
|
859
|
+
*/
|
|
860
|
+
activate(t) {
|
|
861
|
+
var e;
|
|
862
|
+
(e = m(this, tt)) == null || e.activate(t);
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
tt = /* @__PURE__ */ new WeakMap();
|
|
866
|
+
var Ft = class extends C {
|
|
867
|
+
/**
|
|
868
|
+
* Creates a new modifier instance.
|
|
869
|
+
*
|
|
870
|
+
* @param manager - The drag and drop manager that owns this modifier
|
|
871
|
+
* @param options - Optional configuration for the modifier
|
|
872
|
+
*/
|
|
873
|
+
constructor(t, e) {
|
|
874
|
+
super(t, e), this.manager = t, this.options = e;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Applies the modifier to the current drag operation.
|
|
878
|
+
*
|
|
879
|
+
* @param operation - The current state of the drag operation
|
|
880
|
+
* @returns The transformed coordinates
|
|
881
|
+
*
|
|
882
|
+
* @remarks
|
|
883
|
+
* Override this method to implement custom transformation logic.
|
|
884
|
+
* The default implementation returns the original transform unchanged.
|
|
885
|
+
*/
|
|
886
|
+
apply(t) {
|
|
887
|
+
return t.transform;
|
|
888
|
+
}
|
|
889
|
+
}, $e = class {
|
|
890
|
+
/**
|
|
891
|
+
* Creates a new registry instance.
|
|
892
|
+
*
|
|
893
|
+
* @param manager - The drag and drop manager that owns this registry
|
|
894
|
+
*/
|
|
895
|
+
constructor(t) {
|
|
896
|
+
this.draggables = new Ct(), this.droppables = new Ct(), this.plugins = new at(t), this.sensors = new at(t), this.modifiers = new at(t);
|
|
897
|
+
}
|
|
898
|
+
register(t, e) {
|
|
899
|
+
if (t instanceof S)
|
|
900
|
+
return this.draggables.register(t.id, t);
|
|
901
|
+
if (t instanceof x)
|
|
902
|
+
return this.droppables.register(t.id, t);
|
|
903
|
+
if (t.prototype instanceof Ft)
|
|
904
|
+
return this.modifiers.register(t, e);
|
|
905
|
+
if (t.prototype instanceof At)
|
|
906
|
+
return this.sensors.register(t, e);
|
|
907
|
+
if (t.prototype instanceof C)
|
|
908
|
+
return this.plugins.register(t, e);
|
|
909
|
+
throw new Error("Invalid instance type");
|
|
910
|
+
}
|
|
911
|
+
unregister(t) {
|
|
912
|
+
if (t instanceof A)
|
|
913
|
+
return t instanceof S ? this.draggables.unregister(t.id, t) : t instanceof x ? this.droppables.unregister(t.id, t) : () => {
|
|
914
|
+
};
|
|
915
|
+
if (t.prototype instanceof Ft)
|
|
916
|
+
return this.modifiers.unregister(t);
|
|
917
|
+
if (t.prototype instanceof At)
|
|
918
|
+
return this.sensors.unregister(t);
|
|
919
|
+
if (t.prototype instanceof C)
|
|
920
|
+
return this.plugins.unregister(t);
|
|
921
|
+
throw new Error("Invalid instance type");
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Destroys all registered entities and cleans up resources.
|
|
925
|
+
*
|
|
926
|
+
* @remarks
|
|
927
|
+
* This method:
|
|
928
|
+
* - Destroys all draggable and droppable entities
|
|
929
|
+
* - Destroys all plugins, sensors, and modifiers
|
|
930
|
+
* - Cleans up any associated resources
|
|
931
|
+
*/
|
|
932
|
+
destroy() {
|
|
933
|
+
this.draggables.destroy(), this.droppables.destroy(), this.plugins.destroy(), this.sensors.destroy(), this.modifiers.destroy();
|
|
934
|
+
}
|
|
935
|
+
}, ye, we, be, De, Me, Oe, ke, Ee, We, G, et, V, f, Wt, It, Pt, St, xt, B;
|
|
936
|
+
We = [b], Ee = [_], ke = [_], Oe = [_], Me = [_], De = [_], be = [b], we = [b], ye = [b];
|
|
937
|
+
var I = class {
|
|
938
|
+
/**
|
|
939
|
+
* Creates a new drag operation instance.
|
|
940
|
+
*
|
|
941
|
+
* @param manager - The drag and drop manager that owns this operation
|
|
942
|
+
*/
|
|
943
|
+
constructor(t) {
|
|
944
|
+
a(f, 5, this), d(this, G), d(this, et), d(this, V, new Ie(
|
|
945
|
+
void 0,
|
|
946
|
+
(e, s) => e && s ? e.equals(s) : e === s
|
|
947
|
+
)), this.status = new z(), d(this, Wt, a(f, 8, this, !1)), a(f, 11, this), d(this, It, a(f, 12, this, null)), a(f, 15, this), d(this, Pt, a(f, 16, this, null)), a(f, 19, this), d(this, St, a(f, 20, this, null)), a(f, 23, this), d(this, xt, a(f, 24, this, [])), a(f, 27, this), this.position = new Pe({ x: 0, y: 0 }), d(this, B, { x: 0, y: 0 }), E(this, G, t);
|
|
948
|
+
}
|
|
949
|
+
get shape() {
|
|
950
|
+
const { current: t, initial: e, previous: s } = m(this, V);
|
|
951
|
+
return !t || !e ? null : { current: t, initial: e, previous: s };
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Sets the shape of the dragged entity.
|
|
955
|
+
*
|
|
956
|
+
* @param value - The new shape or null to reset
|
|
957
|
+
*/
|
|
958
|
+
set shape(t) {
|
|
959
|
+
t ? m(this, V).current = t : m(this, V).reset();
|
|
960
|
+
}
|
|
961
|
+
get source() {
|
|
962
|
+
var t;
|
|
963
|
+
const e = this.sourceIdentifier;
|
|
964
|
+
if (e == null) return null;
|
|
965
|
+
const s = m(this, G).registry.draggables.get(e);
|
|
966
|
+
return s && E(this, et, s), (t = s ?? m(this, et)) != null ? t : null;
|
|
967
|
+
}
|
|
968
|
+
get target() {
|
|
969
|
+
var t;
|
|
970
|
+
const e = this.targetIdentifier;
|
|
971
|
+
return e != null && (t = m(this, G).registry.droppables.get(e)) != null ? t : null;
|
|
972
|
+
}
|
|
973
|
+
get transform() {
|
|
974
|
+
const { x: t, y: e } = this.position.delta;
|
|
975
|
+
let s = { x: t, y: e };
|
|
976
|
+
for (const r of this.modifiers)
|
|
977
|
+
s = r.apply(Ut(Nt({}, this.snapshot()), {
|
|
978
|
+
transform: s
|
|
979
|
+
}));
|
|
980
|
+
return E(this, B, s), s;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Creates a snapshot of the current drag operation state.
|
|
984
|
+
*
|
|
985
|
+
* @returns An immutable snapshot of the current operation state
|
|
986
|
+
*/
|
|
987
|
+
snapshot() {
|
|
988
|
+
return k(() => ({
|
|
989
|
+
source: this.source,
|
|
990
|
+
target: this.target,
|
|
991
|
+
activatorEvent: this.activatorEvent,
|
|
992
|
+
transform: m(this, B),
|
|
993
|
+
shape: this.shape ? nt(this.shape) : null,
|
|
994
|
+
position: nt(this.position),
|
|
995
|
+
status: nt(this.status),
|
|
996
|
+
canceled: this.canceled
|
|
997
|
+
}));
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Resets the drag operation to its initial state.
|
|
1001
|
+
*
|
|
1002
|
+
* @remarks
|
|
1003
|
+
* This method:
|
|
1004
|
+
* - Sets status to idle
|
|
1005
|
+
* - Clears source and target identifiers
|
|
1006
|
+
* - Resets shape history
|
|
1007
|
+
* - Resets position and transform
|
|
1008
|
+
* - Clears modifiers
|
|
1009
|
+
*/
|
|
1010
|
+
reset() {
|
|
1011
|
+
Rt(() => {
|
|
1012
|
+
this.status.set(
|
|
1013
|
+
"idle"
|
|
1014
|
+
/* Idle */
|
|
1015
|
+
), this.sourceIdentifier = null, this.targetIdentifier = null, m(this, V).reset(), this.position.reset({ x: 0, y: 0 }), E(this, B, { x: 0, y: 0 }), this.modifiers = [];
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
f = N(null);
|
|
1020
|
+
G = /* @__PURE__ */ new WeakMap();
|
|
1021
|
+
et = /* @__PURE__ */ new WeakMap();
|
|
1022
|
+
V = /* @__PURE__ */ new WeakMap();
|
|
1023
|
+
Wt = /* @__PURE__ */ new WeakMap();
|
|
1024
|
+
It = /* @__PURE__ */ new WeakMap();
|
|
1025
|
+
Pt = /* @__PURE__ */ new WeakMap();
|
|
1026
|
+
St = /* @__PURE__ */ new WeakMap();
|
|
1027
|
+
xt = /* @__PURE__ */ new WeakMap();
|
|
1028
|
+
B = /* @__PURE__ */ new WeakMap();
|
|
1029
|
+
l(f, 2, "shape", We, I);
|
|
1030
|
+
l(f, 4, "canceled", Ee, I, Wt);
|
|
1031
|
+
l(f, 4, "activatorEvent", ke, I, It);
|
|
1032
|
+
l(f, 4, "sourceIdentifier", Oe, I, Pt);
|
|
1033
|
+
l(f, 4, "targetIdentifier", Me, I, St);
|
|
1034
|
+
l(f, 4, "modifiers", De, I, xt);
|
|
1035
|
+
l(f, 2, "source", be, I);
|
|
1036
|
+
l(f, 2, "target", we, I);
|
|
1037
|
+
l(f, 2, "transform", ye, I);
|
|
1038
|
+
F(f, I);
|
|
1039
|
+
var Ge = {
|
|
1040
|
+
get rendering() {
|
|
1041
|
+
return Promise.resolve();
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
function ot(t, e) {
|
|
1045
|
+
return typeof t == "function" ? t(e) : t ?? e;
|
|
1046
|
+
}
|
|
1047
|
+
var es = class {
|
|
1048
|
+
/**
|
|
1049
|
+
* Creates a new drag and drop manager instance.
|
|
1050
|
+
*
|
|
1051
|
+
* @param config - Optional configuration for plugins, sensors, modifiers, and renderer
|
|
1052
|
+
*/
|
|
1053
|
+
constructor(e) {
|
|
1054
|
+
this.destroy = () => {
|
|
1055
|
+
this.dragOperation.status.idle || this.actions.stop({ canceled: !0 }), this.dragOperation.modifiers.forEach((P) => P.destroy()), this.registry.destroy(), this.collisionObserver.destroy();
|
|
1056
|
+
};
|
|
1057
|
+
var s;
|
|
1058
|
+
const r = e ?? {}, i = ot(r.plugins, []), n = ot(r.sensors, []), u = ot(r.modifiers, []), o = (s = r.renderer) != null ? s : Ge, p = new Ve(this), h = new $e(this);
|
|
1059
|
+
this.registry = h, this.monitor = p, this.renderer = o, this.actions = new Te(this), this.dragOperation = new I(this), this.collisionObserver = new je(this), this.plugins = [qe, ...i], this.modifiers = u, this.sensors = n;
|
|
1060
|
+
const { destroy: g } = this, c = rt(() => {
|
|
1061
|
+
var P, D, L;
|
|
1062
|
+
const K = k(() => this.dragOperation.modifiers), U = this.modifiers;
|
|
1063
|
+
for (const R of K)
|
|
1064
|
+
U.includes(R) || R.destroy();
|
|
1065
|
+
this.dragOperation.modifiers = (L = (D = (P = this.dragOperation.source) == null ? void 0 : P.modifiers) == null ? void 0 : D.map((R) => {
|
|
1066
|
+
const { plugin: M, options: T } = Bt(R);
|
|
1067
|
+
return new M(this, T);
|
|
1068
|
+
})) != null ? L : U;
|
|
1069
|
+
});
|
|
1070
|
+
this.destroy = () => {
|
|
1071
|
+
c(), g();
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Gets the list of active plugins.
|
|
1076
|
+
*
|
|
1077
|
+
* @returns Array of active plugin instances
|
|
1078
|
+
*/
|
|
1079
|
+
get plugins() {
|
|
1080
|
+
return this.registry.plugins.values;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Sets the list of plugins to be used by the manager.
|
|
1084
|
+
*
|
|
1085
|
+
* @param plugins - Array of plugin constructors or instances
|
|
1086
|
+
*/
|
|
1087
|
+
set plugins(e) {
|
|
1088
|
+
this.registry.plugins.values = e;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Gets the list of active modifiers.
|
|
1092
|
+
*
|
|
1093
|
+
* @returns Array of active modifier instances
|
|
1094
|
+
*/
|
|
1095
|
+
get modifiers() {
|
|
1096
|
+
return this.registry.modifiers.values;
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Sets the list of modifiers to be used by the manager.
|
|
1100
|
+
*
|
|
1101
|
+
* @param modifiers - Array of modifier constructors or instances
|
|
1102
|
+
*/
|
|
1103
|
+
set modifiers(e) {
|
|
1104
|
+
this.registry.modifiers.values = e;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Gets the list of active sensors.
|
|
1108
|
+
*
|
|
1109
|
+
* @returns Array of active sensor instances
|
|
1110
|
+
*/
|
|
1111
|
+
get sensors() {
|
|
1112
|
+
return this.registry.sensors.values;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Sets the list of sensors to be used by the manager.
|
|
1116
|
+
*
|
|
1117
|
+
* @param sensors - Array of sensor constructors or instances
|
|
1118
|
+
*/
|
|
1119
|
+
set sensors(e) {
|
|
1120
|
+
this.registry.sensors.values = e;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
export {
|
|
1124
|
+
ts as ActivationConstraint,
|
|
1125
|
+
Ze as ActivationController,
|
|
1126
|
+
Ne as CollisionPriority,
|
|
1127
|
+
Ue as CollisionType,
|
|
1128
|
+
Kt as CorePlugin,
|
|
1129
|
+
es as DragDropManager,
|
|
1130
|
+
z as DragOperationStatus,
|
|
1131
|
+
S as Draggable,
|
|
1132
|
+
x as Droppable,
|
|
1133
|
+
Ft as Modifier,
|
|
1134
|
+
C as Plugin,
|
|
1135
|
+
at as PluginRegistry,
|
|
1136
|
+
At as Sensor,
|
|
1137
|
+
Qe as configurator,
|
|
1138
|
+
Gt as configure,
|
|
1139
|
+
Bt as descriptor,
|
|
1140
|
+
ot as resolveCustomizable,
|
|
1141
|
+
Re as sortCollisions
|
|
1142
|
+
};
|