@ptahjs/dnd 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dnd.es.js +3114 -0
- package/package.json +8 -4
- package/dist/dnd.css +0 -2
- package/dist/dnd.js +0 -1753
package/dist/dnd.js
DELETED
|
@@ -1,1753 +0,0 @@
|
|
|
1
|
-
//#region src/core/EventDispatcher.js
|
|
2
|
-
var e = class {
|
|
3
|
-
#e = /* @__PURE__ */ new Map();
|
|
4
|
-
emit(e, t) {
|
|
5
|
-
let n = this.#e.get(e);
|
|
6
|
-
if (!n || n.length === 0) return t;
|
|
7
|
-
let r = n.slice();
|
|
8
|
-
for (let n of r) try {
|
|
9
|
-
n(t);
|
|
10
|
-
} catch (t) {
|
|
11
|
-
console.error(`[EventDispatcher] handler error for "${e}":`, t);
|
|
12
|
-
}
|
|
13
|
-
return t;
|
|
14
|
-
}
|
|
15
|
-
pipe(e, t) {
|
|
16
|
-
let n = this.#e.get(e);
|
|
17
|
-
if (!n || n.length === 0) return t;
|
|
18
|
-
let r = t;
|
|
19
|
-
for (let t of n.slice()) try {
|
|
20
|
-
let e = t(r);
|
|
21
|
-
e !== void 0 && (r = e);
|
|
22
|
-
} catch (t) {
|
|
23
|
-
console.error(`[EventDispatcher] pipe handler error for "${e}":`, t);
|
|
24
|
-
}
|
|
25
|
-
return r;
|
|
26
|
-
}
|
|
27
|
-
on(e, t) {
|
|
28
|
-
let n = this.#e.get(e);
|
|
29
|
-
return n ? n.includes(t) || n.push(t) : this.#e.set(e, [t]), this;
|
|
30
|
-
}
|
|
31
|
-
off(e, t) {
|
|
32
|
-
let n = this.#e.get(e);
|
|
33
|
-
if (n) if (t) {
|
|
34
|
-
let e = n.indexOf(t);
|
|
35
|
-
e !== -1 && n.splice(e, 1);
|
|
36
|
-
} else this.#e.delete(e);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
offAll() {
|
|
40
|
-
this.#e.clear();
|
|
41
|
-
}
|
|
42
|
-
}, t = {
|
|
43
|
-
dataAttr: "data",
|
|
44
|
-
copyAttr: "copy",
|
|
45
|
-
dragAttr: "drag",
|
|
46
|
-
dragScopeAttr: "drag-scope",
|
|
47
|
-
dragdropAttr: "dragdrop",
|
|
48
|
-
dropAttr: "drop",
|
|
49
|
-
handleAttr: "drag-handle",
|
|
50
|
-
handleResizeAttr: "drag-handle-resize",
|
|
51
|
-
handleRotateAttr: "drag-handle-rotate",
|
|
52
|
-
namespaceAttr: "namespace",
|
|
53
|
-
dropIndicatorAttr: "drop-indicator",
|
|
54
|
-
ignoreClickAttr: "ignore-click",
|
|
55
|
-
ignoreMirrorAttr: "ignore-mirror",
|
|
56
|
-
resizableAttr: "resizable",
|
|
57
|
-
rotatableAttr: "rotatable",
|
|
58
|
-
scaleRatioAttr: "scale-ratio"
|
|
59
|
-
}, n = {
|
|
60
|
-
canDrop: "dnd-canDrop",
|
|
61
|
-
noDrop: "dnd-noDrop",
|
|
62
|
-
dragging: "dnd-dragging",
|
|
63
|
-
mirror: "dnd-mirror",
|
|
64
|
-
active: "dnd-active",
|
|
65
|
-
dropIndicator: "dnd-indicator",
|
|
66
|
-
dropIndicatorActive: "dnd-indicator-active",
|
|
67
|
-
indicatorTop: "dnd-indicator--top",
|
|
68
|
-
indicatorRight: "dnd-indicator--right",
|
|
69
|
-
indicatorBottom: "dnd-indicator--bottom",
|
|
70
|
-
indicatorLeft: "dnd-indicator--left",
|
|
71
|
-
marquee: "dnd-marquee"
|
|
72
|
-
}, r = .5, i = 1 / 3, a = {
|
|
73
|
-
MARQUEE_MOVE: 5,
|
|
74
|
-
DRAG_START: 3
|
|
75
|
-
}, o = {
|
|
76
|
-
EDGE: 48,
|
|
77
|
-
MIN_SPEED: 180,
|
|
78
|
-
MAX_SPEED: 600
|
|
79
|
-
};
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/utils/computeDropRegion.js
|
|
82
|
-
function s(e, t) {
|
|
83
|
-
let n = `dropRegionFns_${(t instanceof Set ? Array.from(t).sort().join(",") : t) || "all"}`;
|
|
84
|
-
if (e?.cache?.[n]) return e.cache[n];
|
|
85
|
-
let a = () => {
|
|
86
|
-
if (e.currentDrop) return e.currentDropRect || void 0;
|
|
87
|
-
}, o = !t || t === "all" || t instanceof Set && (t.has("top") || t.has("bottom")), s = !t || t === "all" || t instanceof Set && (t.has("left") || t.has("right")), c = {
|
|
88
|
-
isOverTop: o ? () => {
|
|
89
|
-
let t = a();
|
|
90
|
-
return t ? e.y < t.y + t.height * r : !1;
|
|
91
|
-
} : () => !1,
|
|
92
|
-
isOverBottom: o ? () => {
|
|
93
|
-
let t = a();
|
|
94
|
-
return t ? e.y > t.y + t.height * (1 - r) : !1;
|
|
95
|
-
} : () => !1,
|
|
96
|
-
isOverLeft: s ? () => {
|
|
97
|
-
let t = a();
|
|
98
|
-
return t ? e.x < t.x + t.width * i : !1;
|
|
99
|
-
} : () => !1,
|
|
100
|
-
isOverRight: s ? () => {
|
|
101
|
-
let t = a();
|
|
102
|
-
return t ? e.x > t.x + t.width * (1 - i) : !1;
|
|
103
|
-
} : () => !1
|
|
104
|
-
};
|
|
105
|
-
return e?.cache && (e.cache[n] = c), c;
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/utils/parseData.js
|
|
109
|
-
function c(e) {
|
|
110
|
-
if (e === void 0) return;
|
|
111
|
-
let t = String(e).trim();
|
|
112
|
-
if (!t) return "";
|
|
113
|
-
try {
|
|
114
|
-
return JSON.parse(t);
|
|
115
|
-
} catch {
|
|
116
|
-
return t;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/utils/createPayload.js
|
|
121
|
-
function l(e, n) {
|
|
122
|
-
let r = () => {
|
|
123
|
-
let e = n.currentDrop;
|
|
124
|
-
if (!e) return;
|
|
125
|
-
let r = n.currentDropRect || e.getBoundingClientRect(), i = n.adapter.getAttr(e, t.scaleRatioAttr) ?? e.getAttribute?.("data-scale-ratio"), a = Number(i), o = Number.isFinite(a) && a > 0 ? a : 1, s = r.left + (e.clientLeft || 0), c = r.top + (e.clientTop || 0), l = n.x - s, u = n.y - c, d = l + (e.scrollLeft || 0), f = u + (e.scrollTop || 0);
|
|
126
|
-
return {
|
|
127
|
-
x: d / o,
|
|
128
|
-
y: f / o,
|
|
129
|
-
scale: o,
|
|
130
|
-
px: d,
|
|
131
|
-
py: f
|
|
132
|
-
};
|
|
133
|
-
}, i = () => {
|
|
134
|
-
let e = n.currentDrop, r = n.cache;
|
|
135
|
-
if (!e) {
|
|
136
|
-
r.dropDataEl = void 0, r.dropDataRaw = void 0, r.dropDataParsed = void 0;
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
let i = n.adapter.getAttr(e, t.dataAttr);
|
|
140
|
-
return r.dropDataEl === e && i === r.dropDataRaw ? r.dropDataParsed : (r.dropDataEl = e, r.dropDataRaw = i, r.dropDataParsed = c(i), r.dropDataParsed);
|
|
141
|
-
};
|
|
142
|
-
if (!n.cache.hitDropFn) {
|
|
143
|
-
let e = -1, t = 0, r = 0, i, a;
|
|
144
|
-
n.cache.hitDropFn = (o, s, c) => {
|
|
145
|
-
let l = n?.adapter?.frameId ?? n?.cache?.frameId ?? 0;
|
|
146
|
-
if (l === e && o === t && s === r && c === i) return a;
|
|
147
|
-
e = l, t = o, r = s, i = c;
|
|
148
|
-
let u = n.adapter;
|
|
149
|
-
if (!u?.hitDrop) throw Error("createPayload requires monitor.adapter.hitDrop");
|
|
150
|
-
return a = u.hitDrop(o, s, n.namespace, c), a;
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
return {
|
|
154
|
-
type: e,
|
|
155
|
-
namespace: n.namespace,
|
|
156
|
-
data: n.data,
|
|
157
|
-
dropData: i(),
|
|
158
|
-
dropPoint: r(),
|
|
159
|
-
indicatorRegion: n.lastIndicatorRegion,
|
|
160
|
-
isDragScope: n.isDragScope,
|
|
161
|
-
isCopy: n.isCopy,
|
|
162
|
-
sourceEl: n.sourceEl,
|
|
163
|
-
handleEl: n.handleEl,
|
|
164
|
-
originDrop: n.originDrop,
|
|
165
|
-
currentDrop: n.currentDrop,
|
|
166
|
-
x: n.x,
|
|
167
|
-
y: n.y,
|
|
168
|
-
dx: n.dx,
|
|
169
|
-
dy: n.dy,
|
|
170
|
-
started: n.started,
|
|
171
|
-
hitDrop: n.cache.hitDropFn,
|
|
172
|
-
...s(n)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/utils/createSession.js
|
|
177
|
-
function u(e) {
|
|
178
|
-
return {
|
|
179
|
-
adapter: void 0,
|
|
180
|
-
currentDropRect: void 0,
|
|
181
|
-
dragAbort: void 0,
|
|
182
|
-
isDragScope: !1,
|
|
183
|
-
isCopy: !1,
|
|
184
|
-
active: !1,
|
|
185
|
-
pointerId: void 0,
|
|
186
|
-
startX: 0,
|
|
187
|
-
startY: 0,
|
|
188
|
-
x: 0,
|
|
189
|
-
y: 0,
|
|
190
|
-
dx: 0,
|
|
191
|
-
dy: 0,
|
|
192
|
-
started: !1,
|
|
193
|
-
threshold: a.DRAG_START,
|
|
194
|
-
lastMoveTs: 0,
|
|
195
|
-
sourceEl: void 0,
|
|
196
|
-
handleEl: void 0,
|
|
197
|
-
originDrop: void 0,
|
|
198
|
-
currentDrop: void 0,
|
|
199
|
-
namespace: void 0,
|
|
200
|
-
data: void 0,
|
|
201
|
-
mirrorEl: void 0,
|
|
202
|
-
mirrorOffsetX: 0,
|
|
203
|
-
mirrorOffsetY: 0,
|
|
204
|
-
currentAllowed: !1,
|
|
205
|
-
dirty: !1,
|
|
206
|
-
prevX: 0,
|
|
207
|
-
prevY: 0,
|
|
208
|
-
cache: {
|
|
209
|
-
frameId: 0,
|
|
210
|
-
dropDataEl: void 0,
|
|
211
|
-
dropDataRaw: void 0,
|
|
212
|
-
dropDataParsed: void 0,
|
|
213
|
-
dropRegionFns: void 0,
|
|
214
|
-
hitDropFn: void 0,
|
|
215
|
-
canDropCtx: void 0,
|
|
216
|
-
dropRectDirty: !1,
|
|
217
|
-
autoScrollPlan: void 0,
|
|
218
|
-
autoScrollLastTs: 0
|
|
219
|
-
},
|
|
220
|
-
indicatorEl: void 0,
|
|
221
|
-
indicatorRegion: void 0,
|
|
222
|
-
lastIndicatorRegion: void 0,
|
|
223
|
-
selectedByNs: e?.selectedByNs,
|
|
224
|
-
lastDragTs: 0,
|
|
225
|
-
suppressNextClick: !1
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region src/utils/createContext.js
|
|
230
|
-
function d({ dnd: e, session: t, store: n, frame: r, adapter: i }) {
|
|
231
|
-
let a = /* @__PURE__ */ new Map();
|
|
232
|
-
return {
|
|
233
|
-
dnd: e,
|
|
234
|
-
session: t,
|
|
235
|
-
store: n,
|
|
236
|
-
frame: r,
|
|
237
|
-
adapter: i,
|
|
238
|
-
payload: (e = "drag") => {
|
|
239
|
-
if (a.has(e)) return a.get(e);
|
|
240
|
-
let n = l(e, t);
|
|
241
|
-
return a.set(e, n), n;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
//#endregion
|
|
246
|
-
//#region src/utils/isToggleEnabled.js
|
|
247
|
-
function f(e, t, n = !0) {
|
|
248
|
-
if (!e?.getAttribute) return n;
|
|
249
|
-
let r = `data-${t}`, i = e.getAttribute(t) ?? e.getAttribute(r);
|
|
250
|
-
return i === null ? n : String(i).toLowerCase() !== "false";
|
|
251
|
-
}
|
|
252
|
-
//#endregion
|
|
253
|
-
//#region src/utils/matchHandle.js
|
|
254
|
-
function p(e, n) {
|
|
255
|
-
let r = n?.closestDraggable?.(e) || e?.closest?.(`[${t.dragAttr}], [${t.dragdropAttr}]`);
|
|
256
|
-
if (!r) return;
|
|
257
|
-
let i = f(r, t.rotatableAttr, !0), a = f(r, t.resizableAttr, !0);
|
|
258
|
-
if (i && (r.hasAttribute(t.handleRotateAttr) || r.querySelector?.(`[${t.handleRotateAttr}]`)) || a && (r.hasAttribute(t.handleResizeAttr) || r.querySelector?.(`[${t.handleResizeAttr}]`))) {
|
|
259
|
-
let n = (i ? e.closest?.(`[${t.handleRotateAttr}]`) : null) || (a ? e.closest?.(`[${t.handleResizeAttr}]`) : null);
|
|
260
|
-
return n && r.contains(n) ? n : r;
|
|
261
|
-
}
|
|
262
|
-
if (r.hasAttribute(t.handleAttr) || r.querySelector?.(`[${t.handleAttr}]`)) {
|
|
263
|
-
let n = e.closest?.(`[${t.handleAttr}]`);
|
|
264
|
-
return n && r.contains(n) ? n : void 0;
|
|
265
|
-
}
|
|
266
|
-
return r;
|
|
267
|
-
}
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/utils/isHTMLElement.js
|
|
270
|
-
function m(e) {
|
|
271
|
-
return e && typeof e == "object" && e.nodeType === 1;
|
|
272
|
-
}
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/utils/isIgnoreClick.js
|
|
275
|
-
function h(e) {
|
|
276
|
-
if (!m(e)) return !1;
|
|
277
|
-
let n = t.ignoreClickAttr, r = `data-${n}`;
|
|
278
|
-
return !!(e.closest?.(`[${n}], [${r}]`) || e.hasAttribute?.(n) || e.hasAttribute?.(r));
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/utils/scopeHelpers.js
|
|
282
|
-
var g = t.dragScopeAttr, _ = `[${g}], [data-${g}]`, v = class {
|
|
283
|
-
#e = 0;
|
|
284
|
-
#t = /* @__PURE__ */ new WeakMap();
|
|
285
|
-
#n = /* @__PURE__ */ new WeakMap();
|
|
286
|
-
get frameId() {
|
|
287
|
-
return this.#e;
|
|
288
|
-
}
|
|
289
|
-
beginFrame() {
|
|
290
|
-
this.#e++;
|
|
291
|
-
}
|
|
292
|
-
endFrame() {}
|
|
293
|
-
resolveRoot(e) {
|
|
294
|
-
if (e) {
|
|
295
|
-
if (typeof e == "string") {
|
|
296
|
-
let t = document.querySelector(e);
|
|
297
|
-
return t instanceof HTMLElement ? t : void 0;
|
|
298
|
-
}
|
|
299
|
-
return e instanceof HTMLElement ? e : void 0;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
getAttr(e, t) {
|
|
303
|
-
return e?.getAttribute?.(t) ?? void 0;
|
|
304
|
-
}
|
|
305
|
-
getNamespace(e) {
|
|
306
|
-
if (!e) return "_default";
|
|
307
|
-
let n = this.#n.get(e);
|
|
308
|
-
if (n && n.frameId === this.#e) return n.ns;
|
|
309
|
-
let r = this.getAttr(e, t.namespaceAttr) || "_default";
|
|
310
|
-
return this.#n.set(e, {
|
|
311
|
-
frameId: this.#e,
|
|
312
|
-
ns: r
|
|
313
|
-
}), r;
|
|
314
|
-
}
|
|
315
|
-
isDrop(e) {
|
|
316
|
-
return e ? e.hasAttribute?.(t.dropAttr) || e.hasAttribute?.(t.dragdropAttr) : !1;
|
|
317
|
-
}
|
|
318
|
-
closestDraggable(e) {
|
|
319
|
-
let { dragAttr: n, dragdropAttr: r } = t;
|
|
320
|
-
if (e) return e.hasAttribute(n) || e.hasAttribute(r) ? e : e.closest?.(`[${n}], [${r}]`) || void 0;
|
|
321
|
-
}
|
|
322
|
-
closestDrop(e) {
|
|
323
|
-
if (e) {
|
|
324
|
-
let { dropAttr: n, dragdropAttr: r } = t;
|
|
325
|
-
return e.closest?.(`[${n}], [${r}]`) || void 0;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
closestDragScope(e) {
|
|
329
|
-
let { dragScopeAttr: n } = t;
|
|
330
|
-
if (e) return e.hasAttribute(n) ? e : e.closest?.(`[${n}]`) || void 0;
|
|
331
|
-
}
|
|
332
|
-
measureRect(e) {
|
|
333
|
-
if (!e) return;
|
|
334
|
-
let t = this.#t.get(e);
|
|
335
|
-
if (t && t.frameId === this.#e) return t.rect;
|
|
336
|
-
let n = e.getBoundingClientRect();
|
|
337
|
-
return this.#t.set(e, {
|
|
338
|
-
frameId: this.#e,
|
|
339
|
-
rect: n
|
|
340
|
-
}), n;
|
|
341
|
-
}
|
|
342
|
-
hitDrop(e, t, n, r) {
|
|
343
|
-
let i = document.elementFromPoint(e, t);
|
|
344
|
-
if (!i) return;
|
|
345
|
-
let a = n || "_default", o = i;
|
|
346
|
-
if (!(r && r.contains(o) && (o = r.parentElement ?? null, !o))) for (; o;) {
|
|
347
|
-
if (this.isDrop(o) && this.getNamespace(o) === a) return o;
|
|
348
|
-
o = o.parentElement;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}, y = class {
|
|
352
|
-
#e = !1;
|
|
353
|
-
#t = !1;
|
|
354
|
-
#n = 0;
|
|
355
|
-
#r;
|
|
356
|
-
constructor(e) {
|
|
357
|
-
this.#r = typeof e == "function" ? e : () => !1;
|
|
358
|
-
}
|
|
359
|
-
request() {
|
|
360
|
-
this.#t = !0, !this.#e && (this.#e = !0, this.#n = requestAnimationFrame(this.#i));
|
|
361
|
-
}
|
|
362
|
-
cancel() {
|
|
363
|
-
this.#e && (this.#e = !1, this.#t = !1, this.#n &&= (cancelAnimationFrame(this.#n), 0));
|
|
364
|
-
}
|
|
365
|
-
#i = () => {
|
|
366
|
-
if (!this.#e) return;
|
|
367
|
-
this.#t = !1;
|
|
368
|
-
let e = !1;
|
|
369
|
-
try {
|
|
370
|
-
e = !!this.#r(performance.now());
|
|
371
|
-
} catch (t) {
|
|
372
|
-
e = !1, console.error("[RafScheduler] frame callback error:", t);
|
|
373
|
-
}
|
|
374
|
-
if (this.#e) {
|
|
375
|
-
if (e || this.#t) {
|
|
376
|
-
this.#n = requestAnimationFrame(this.#i);
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
this.#e = !1, this.#n = 0;
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
}, b = class {
|
|
383
|
-
#e;
|
|
384
|
-
#t = new AbortController();
|
|
385
|
-
#n = !1;
|
|
386
|
-
#r;
|
|
387
|
-
#i = 0;
|
|
388
|
-
#a = 0;
|
|
389
|
-
#o;
|
|
390
|
-
#s;
|
|
391
|
-
#c;
|
|
392
|
-
constructor({ onDown: e, onMove: t, onUp: n } = {}) {
|
|
393
|
-
this.#o = typeof e == "function" ? e : void 0, this.#s = typeof t == "function" ? t : void 0, this.#c = typeof n == "function" ? n : void 0;
|
|
394
|
-
}
|
|
395
|
-
setRoot(e) {
|
|
396
|
-
e !== this.#e && (this.#t.abort(), this.#t = new AbortController(), this.#e = e, this.#e && this.#e.addEventListener("pointerdown", this.#l, {
|
|
397
|
-
passive: !1,
|
|
398
|
-
signal: this.#t.signal
|
|
399
|
-
}));
|
|
400
|
-
}
|
|
401
|
-
destroy() {
|
|
402
|
-
this.#t.abort(), this.#d(), this.#e = void 0;
|
|
403
|
-
}
|
|
404
|
-
#l = (e) => {
|
|
405
|
-
if (!this.#o || !this.#e) return;
|
|
406
|
-
let t = this.#o(e);
|
|
407
|
-
!t?.accepted || !t?.signal || !Number.isFinite(t.pointerId) || (this.#n = !0, this.#r = t.pointerId, this.#i = e.clientX, this.#a = e.clientY, this.#u(t.signal));
|
|
408
|
-
};
|
|
409
|
-
#u(e) {
|
|
410
|
-
globalThis.addEventListener("pointermove", this.#f, {
|
|
411
|
-
passive: !1,
|
|
412
|
-
signal: e
|
|
413
|
-
}), globalThis.addEventListener("pointerup", this.#p, {
|
|
414
|
-
passive: !1,
|
|
415
|
-
signal: e
|
|
416
|
-
}), globalThis.addEventListener("pointercancel", this.#p, {
|
|
417
|
-
passive: !1,
|
|
418
|
-
signal: e
|
|
419
|
-
}), globalThis.addEventListener("blur", this.#p, {
|
|
420
|
-
passive: !1,
|
|
421
|
-
signal: e
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
#d() {
|
|
425
|
-
this.#n = !1, this.#r = void 0;
|
|
426
|
-
}
|
|
427
|
-
#f = (e) => {
|
|
428
|
-
if (!this.#n || !this.#s || e.pointerId !== this.#r) return;
|
|
429
|
-
let t = e.getCoalescedEvents?.(), n = t?.length ? t[t.length - 1] : e, r = performance.now(), i = n.clientX, a = n.clientY;
|
|
430
|
-
if (i === this.#i && a === this.#a) {
|
|
431
|
-
e.preventDefault();
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
this.#i = i, this.#a = a, this.#s({
|
|
435
|
-
pointerId: e.pointerId,
|
|
436
|
-
x: i,
|
|
437
|
-
y: a,
|
|
438
|
-
event: e,
|
|
439
|
-
now: r
|
|
440
|
-
}), e.preventDefault();
|
|
441
|
-
};
|
|
442
|
-
#p = (e) => {
|
|
443
|
-
if (!this.#n || !this.#c || "pointerId" in e && e.pointerId !== this.#r) return;
|
|
444
|
-
let t = this.#r, n = e.type;
|
|
445
|
-
this.#d(), this.#c({
|
|
446
|
-
event: e,
|
|
447
|
-
pointerId: t,
|
|
448
|
-
reason: n
|
|
449
|
-
}), e.preventDefault?.();
|
|
450
|
-
};
|
|
451
|
-
}, ee = class {
|
|
452
|
-
scrolled = !1;
|
|
453
|
-
now = 0;
|
|
454
|
-
classOps = /* @__PURE__ */ new Map();
|
|
455
|
-
styleOps = /* @__PURE__ */ new Map();
|
|
456
|
-
appendOps = /* @__PURE__ */ new Map();
|
|
457
|
-
removeOps = /* @__PURE__ */ new Set();
|
|
458
|
-
fnOps = [];
|
|
459
|
-
reset(e) {
|
|
460
|
-
this.now = e, this.scrolled = !1, this.classOps.clear(), this.styleOps.clear(), this.appendOps.clear(), this.removeOps.clear(), this.fnOps.length = 0;
|
|
461
|
-
}
|
|
462
|
-
toggleClass(e, t, n) {
|
|
463
|
-
if (!e || !t || this.removeOps.has(e)) return;
|
|
464
|
-
let r = this.classOps.get(e);
|
|
465
|
-
r || (r = /* @__PURE__ */ new Map(), this.classOps.set(e, r)), r.set(t, !!n);
|
|
466
|
-
}
|
|
467
|
-
setStyle(e, t, n) {
|
|
468
|
-
if (!e || !t || this.removeOps.has(e)) return;
|
|
469
|
-
let r = this.styleOps.get(e);
|
|
470
|
-
r || (r = /* @__PURE__ */ new Map(), this.styleOps.set(e, r)), r.set(t, n);
|
|
471
|
-
}
|
|
472
|
-
append(e, t) {
|
|
473
|
-
!e || !t || this.removeOps.has(t) || this.appendOps.set(t, e);
|
|
474
|
-
}
|
|
475
|
-
remove(e) {
|
|
476
|
-
e && (this.removeOps.add(e), this.classOps.delete(e), this.styleOps.delete(e), this.appendOps.delete(e));
|
|
477
|
-
}
|
|
478
|
-
run(e) {
|
|
479
|
-
typeof e == "function" && this.fnOps.push(e);
|
|
480
|
-
}
|
|
481
|
-
commit() {
|
|
482
|
-
for (let e of this.removeOps) e?.parentNode?.removeChild?.(e);
|
|
483
|
-
let e = this.removeOps.size > 0;
|
|
484
|
-
for (let [t, n] of this.appendOps) (!e || !this.removeOps.has(t) && !this.removeOps.has(n)) && n?.appendChild?.(t);
|
|
485
|
-
for (let [t, n] of this.classOps) if (!e || !this.removeOps.has(t)) for (let [e, r] of n) r ? t?.classList?.add?.(e) : t?.classList?.remove?.(e);
|
|
486
|
-
for (let [t, n] of this.styleOps) if (!e || !this.removeOps.has(t)) for (let [e, r] of n) r == null ? e.includes("-") ? t?.style?.removeProperty?.(e) : t?.style && (t.style[e] = "") : e.includes("-") ? t?.style?.setProperty?.(e, String(r)) : t?.style && (t.style[e] = r);
|
|
487
|
-
for (let e of this.fnOps) e?.();
|
|
488
|
-
}
|
|
489
|
-
}, te = class {
|
|
490
|
-
#e = [];
|
|
491
|
-
use(e, t) {
|
|
492
|
-
e && (this.#e.push(e), this.#e.sort((e, t) => (e.order ?? 0) - (t.order ?? 0)), e.onAttach?.(t));
|
|
493
|
-
}
|
|
494
|
-
onRootChange(e, t, n) {
|
|
495
|
-
for (let r of this.#e) r.onRootChange?.(e, t, n);
|
|
496
|
-
}
|
|
497
|
-
onDown(e, t) {
|
|
498
|
-
for (let n of this.#e) n.onDown?.(e, t);
|
|
499
|
-
}
|
|
500
|
-
onStart(e) {
|
|
501
|
-
for (let t of this.#e) t.onStart?.(e);
|
|
502
|
-
}
|
|
503
|
-
onMeasure(e) {
|
|
504
|
-
for (let t of this.#e) t.onMeasure?.(e);
|
|
505
|
-
}
|
|
506
|
-
onCompute(e) {
|
|
507
|
-
for (let t of this.#e) t.onCompute?.(e);
|
|
508
|
-
}
|
|
509
|
-
onCommit(e) {
|
|
510
|
-
for (let t of this.#e) t.onCommit?.(e);
|
|
511
|
-
}
|
|
512
|
-
onAfterDrag(e) {
|
|
513
|
-
let t = !1;
|
|
514
|
-
for (let n of this.#e) {
|
|
515
|
-
let r = n.onAfterDrag?.(e);
|
|
516
|
-
(r === !0 || r?.scrolled) && (t = !0);
|
|
517
|
-
}
|
|
518
|
-
return t;
|
|
519
|
-
}
|
|
520
|
-
onEnd(e, t) {
|
|
521
|
-
for (let n of this.#e) n.onEnd?.(e, t);
|
|
522
|
-
}
|
|
523
|
-
onDestroy(e, t) {
|
|
524
|
-
for (let n of this.#e) n.onDestroy?.(e, t);
|
|
525
|
-
}
|
|
526
|
-
dispose() {
|
|
527
|
-
this.#e.length = 0;
|
|
528
|
-
}
|
|
529
|
-
}, ne = class {
|
|
530
|
-
#e;
|
|
531
|
-
#t;
|
|
532
|
-
constructor({ store: e, session: t } = {}) {
|
|
533
|
-
this.#e = e, this.#t = t;
|
|
534
|
-
}
|
|
535
|
-
get session() {
|
|
536
|
-
return this.#t;
|
|
537
|
-
}
|
|
538
|
-
get store() {
|
|
539
|
-
return this.#e;
|
|
540
|
-
}
|
|
541
|
-
dispatch(e) {
|
|
542
|
-
if (!e || !this.#t) return { handled: !1 };
|
|
543
|
-
switch (e.type) {
|
|
544
|
-
case "DOWN": {
|
|
545
|
-
if (this.#t.active) return { handled: !1 };
|
|
546
|
-
Object.assign(this.#t, {
|
|
547
|
-
active: !0,
|
|
548
|
-
started: !1,
|
|
549
|
-
dirty: !1,
|
|
550
|
-
pointerId: e.pointerId,
|
|
551
|
-
startX: e.x,
|
|
552
|
-
startY: e.y,
|
|
553
|
-
x: e.x,
|
|
554
|
-
y: e.y,
|
|
555
|
-
prevX: e.x,
|
|
556
|
-
prevY: e.y,
|
|
557
|
-
dx: 0,
|
|
558
|
-
dy: 0,
|
|
559
|
-
namespace: e.namespace,
|
|
560
|
-
data: e.data,
|
|
561
|
-
sourceEl: e.sourceEl,
|
|
562
|
-
handleEl: e.handleEl,
|
|
563
|
-
originDrop: e.originDrop,
|
|
564
|
-
currentDrop: void 0,
|
|
565
|
-
currentDropRect: void 0,
|
|
566
|
-
isDragScope: !!e.isDragScope,
|
|
567
|
-
isCopy: !!e.isCopy,
|
|
568
|
-
mirrorOffsetX: e.mirrorOffsetX ?? 0,
|
|
569
|
-
mirrorOffsetY: e.mirrorOffsetY ?? 0,
|
|
570
|
-
lastMoveTs: 0
|
|
571
|
-
}), this.#t.dragAbort = new AbortController();
|
|
572
|
-
let { cache: t } = this.#t;
|
|
573
|
-
return t && (t.dropDataEl = void 0, t.dropDataRaw = void 0, t.dropDataParsed = void 0, t.dropRegionFns = void 0, t.hitDropFn = void 0, t.dropRectDirty = !0), {
|
|
574
|
-
handled: !0,
|
|
575
|
-
accepted: !0,
|
|
576
|
-
dragAbort: this.#t.dragAbort
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
case "MOVE": {
|
|
580
|
-
if (!this.#t.active || e.pointerId !== this.#t.pointerId) return { handled: !1 };
|
|
581
|
-
let t = e.x, n = e.y;
|
|
582
|
-
if (t === this.#t.x && n === this.#t.y) return {
|
|
583
|
-
handled: !0,
|
|
584
|
-
moved: !1
|
|
585
|
-
};
|
|
586
|
-
this.#t.prevX = this.#t.x, this.#t.prevY = this.#t.y, this.#t.x = t, this.#t.y = n, this.#t.dx = t - this.#t.startX, this.#t.dy = n - this.#t.startY, this.#t.dirty = !0;
|
|
587
|
-
let r = !1;
|
|
588
|
-
return this.#t.started || Math.hypot(this.#t.dx, this.#t.dy) >= this.#t.threshold && (this.#t.started = !0, r = !0), {
|
|
589
|
-
handled: !0,
|
|
590
|
-
moved: !0,
|
|
591
|
-
startedNow: r,
|
|
592
|
-
started: this.#t.started
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
case "END": {
|
|
596
|
-
if (!this.#t.active || e.pointerId !== void 0 && e.pointerId !== this.#t.pointerId) return { handled: !1 };
|
|
597
|
-
let t = !!this.#t.started;
|
|
598
|
-
return this.#t.active = !1, {
|
|
599
|
-
handled: !0,
|
|
600
|
-
ended: t,
|
|
601
|
-
reason: e.reason
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
default: return { handled: !1 };
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
resetSession({ ended: e } = { ended: !1 }) {
|
|
608
|
-
let t = this.#e, n = this.#t, r = u(t);
|
|
609
|
-
return r.adapter = n?.adapter, e && (r.suppressNextClick = !0, r.lastDragTs = performance.now()), this.#t = r, r;
|
|
610
|
-
}
|
|
611
|
-
}, re = class extends e {
|
|
612
|
-
#e = new AbortController();
|
|
613
|
-
#t;
|
|
614
|
-
#n;
|
|
615
|
-
#r = new v();
|
|
616
|
-
#i = new ee();
|
|
617
|
-
#a = { selectedByNs: /* @__PURE__ */ new Map() };
|
|
618
|
-
#o;
|
|
619
|
-
#s = new te();
|
|
620
|
-
#c;
|
|
621
|
-
#l;
|
|
622
|
-
#u = !1;
|
|
623
|
-
canDrop = () => !0;
|
|
624
|
-
renderMirror = void 0;
|
|
625
|
-
get root() {
|
|
626
|
-
return this.#t;
|
|
627
|
-
}
|
|
628
|
-
get monitor() {
|
|
629
|
-
if (!this.#u) return this.#o?.session;
|
|
630
|
-
}
|
|
631
|
-
get destroyed() {
|
|
632
|
-
return this.#u;
|
|
633
|
-
}
|
|
634
|
-
constructor(e = {}) {
|
|
635
|
-
super(), this.#n = { threshold: e.threshold ?? a.DRAG_START };
|
|
636
|
-
let t = u(this.#a);
|
|
637
|
-
t.threshold = this.#n.threshold, t.adapter = this.#r, this.#o = new ne({
|
|
638
|
-
store: this.#a,
|
|
639
|
-
session: t
|
|
640
|
-
}), this.#c = new y(this.#h), this.#l = new b({
|
|
641
|
-
onDown: this.#f,
|
|
642
|
-
onMove: this.#p,
|
|
643
|
-
onUp: this.#m
|
|
644
|
-
}), this.setRoot(e.root);
|
|
645
|
-
}
|
|
646
|
-
use(e) {
|
|
647
|
-
return e ? (this.#s.use(e, this), this.#t && e.onRootChange?.(this.#t, void 0, this.#e.signal), this) : this;
|
|
648
|
-
}
|
|
649
|
-
setRoot(e) {
|
|
650
|
-
let t = this.#r.resolveRoot(e);
|
|
651
|
-
if (t === this.#t) return;
|
|
652
|
-
let n = this.#t;
|
|
653
|
-
this.#e.abort(), this.#e = new AbortController(), this.#t = t, this.#l.setRoot(this.#t), this.#t && (this.#s.onRootChange(this.#t, n, this.#e.signal), this.#t.addEventListener("click", this.#d, {
|
|
654
|
-
capture: !0,
|
|
655
|
-
passive: !1,
|
|
656
|
-
signal: this.#e.signal
|
|
657
|
-
}));
|
|
658
|
-
}
|
|
659
|
-
destroy() {
|
|
660
|
-
if (this.#u) return;
|
|
661
|
-
this.#e.abort(), this.#l.destroy(), this.#c.cancel();
|
|
662
|
-
let e = this.#o.session;
|
|
663
|
-
e?.active && (this.#s.onEnd(d({
|
|
664
|
-
dnd: this,
|
|
665
|
-
session: e,
|
|
666
|
-
store: this.#a,
|
|
667
|
-
frame: this.#i,
|
|
668
|
-
adapter: this.#r
|
|
669
|
-
}), {
|
|
670
|
-
ended: !1,
|
|
671
|
-
reason: "destroy"
|
|
672
|
-
}), e.dragAbort?.abort()), this.#s.onDestroy(this, e), this.#s.dispose?.(), this.offAll(), this.#u = !0;
|
|
673
|
-
}
|
|
674
|
-
#d = (e) => {
|
|
675
|
-
let t = this.#o?.session;
|
|
676
|
-
if (!t?.suppressNextClick) return;
|
|
677
|
-
let n = performance.now(), r = !t.lastDragTs || n - t.lastDragTs < 800;
|
|
678
|
-
t.suppressNextClick = !1, r && (e.preventDefault?.(), e.stopPropagation?.(), e.stopImmediatePropagation?.());
|
|
679
|
-
};
|
|
680
|
-
#f = (e) => {
|
|
681
|
-
if (!this.#t || e.button !== 0) return { accepted: !1 };
|
|
682
|
-
let n = p(e.target, this.#r);
|
|
683
|
-
if (!n) return { accepted: !1 };
|
|
684
|
-
let r = this.#r.closestDraggable(n);
|
|
685
|
-
if (!r || e.target?.closest?.("input, textarea, select, button, a[href], [contenteditable]")) return { accepted: !1 };
|
|
686
|
-
e.preventDefault(), e.target?.setPointerCapture?.(e.pointerId);
|
|
687
|
-
let i = this.#r.getNamespace(r), a = this.#r.closestDrop(r), o = r.getBoundingClientRect(), s = c(this.#r.getAttr(r, t.dataAttr));
|
|
688
|
-
if (!this.#o.dispatch({
|
|
689
|
-
type: "DOWN",
|
|
690
|
-
pointerId: e.pointerId,
|
|
691
|
-
x: e.clientX,
|
|
692
|
-
y: e.clientY,
|
|
693
|
-
namespace: i,
|
|
694
|
-
data: s,
|
|
695
|
-
sourceEl: r,
|
|
696
|
-
handleEl: n,
|
|
697
|
-
originDrop: a,
|
|
698
|
-
isDragScope: !!this.#r.closestDragScope(r),
|
|
699
|
-
isCopy: !!this.#r.getAttr(r, t.copyAttr),
|
|
700
|
-
mirrorOffsetX: e.clientX - o.left,
|
|
701
|
-
mirrorOffsetY: e.clientY - o.top
|
|
702
|
-
})?.accepted) return { accepted: !1 };
|
|
703
|
-
let l = this.#o.session;
|
|
704
|
-
l.threshold = this.#n.threshold, l.adapter = this.#r, this.#i.reset(performance.now()), this.#r.beginFrame(), l.cache.frameId = this.#r.frameId;
|
|
705
|
-
let u = d({
|
|
706
|
-
dnd: this,
|
|
707
|
-
session: l,
|
|
708
|
-
store: this.#a,
|
|
709
|
-
frame: this.#i,
|
|
710
|
-
adapter: this.#r
|
|
711
|
-
});
|
|
712
|
-
return this.#s.onDown(u, e), this.#i.commit(), this.#r.endFrame(), {
|
|
713
|
-
accepted: !0,
|
|
714
|
-
pointerId: e.pointerId,
|
|
715
|
-
signal: l.dragAbort.signal
|
|
716
|
-
};
|
|
717
|
-
};
|
|
718
|
-
#p = ({ pointerId: e, x: t, y: n }) => {
|
|
719
|
-
let r = this.#o.dispatch({
|
|
720
|
-
type: "MOVE",
|
|
721
|
-
pointerId: e,
|
|
722
|
-
x: t,
|
|
723
|
-
y: n
|
|
724
|
-
});
|
|
725
|
-
if (!r?.handled) return;
|
|
726
|
-
let i = this.#o.session;
|
|
727
|
-
if (r.startedNow) {
|
|
728
|
-
let e = d({
|
|
729
|
-
dnd: this,
|
|
730
|
-
session: i,
|
|
731
|
-
store: this.#a,
|
|
732
|
-
frame: this.#i,
|
|
733
|
-
adapter: this.#r
|
|
734
|
-
});
|
|
735
|
-
this.#s.onStart(e), this.emit("dragstart", l("dragstart", i));
|
|
736
|
-
}
|
|
737
|
-
r.started && this.#c.request();
|
|
738
|
-
};
|
|
739
|
-
#m = ({ event: e, pointerId: t, reason: n }) => {
|
|
740
|
-
let r = this.#o.dispatch({
|
|
741
|
-
type: "END",
|
|
742
|
-
pointerId: t,
|
|
743
|
-
reason: n
|
|
744
|
-
});
|
|
745
|
-
if (!r?.handled) return;
|
|
746
|
-
let i = this.#o.session;
|
|
747
|
-
"pointerId" in e && e.target?.releasePointerCapture?.(e.pointerId);
|
|
748
|
-
let a = !!r.ended;
|
|
749
|
-
this.#r.beginFrame(), i.cache.frameId = this.#r.frameId, i.currentDrop = this.#r.hitDrop(i.x, i.y, i.namespace, i.sourceEl), i.currentDropRect = i.currentDrop ? this.#r.measureRect(i.currentDrop) : void 0, this.#r.endFrame();
|
|
750
|
-
let o = d({
|
|
751
|
-
dnd: this,
|
|
752
|
-
session: i,
|
|
753
|
-
store: this.#a,
|
|
754
|
-
frame: this.#i,
|
|
755
|
-
adapter: this.#r
|
|
756
|
-
});
|
|
757
|
-
this.#s.onEnd(o, {
|
|
758
|
-
ended: a,
|
|
759
|
-
reason: n || "pointerup"
|
|
760
|
-
});
|
|
761
|
-
let s = l(a ? "drop" : "cancel", i);
|
|
762
|
-
i.dragAbort?.abort(), i.dragAbort = void 0, this.#c.cancel();
|
|
763
|
-
let c = this.#o.resetSession({ ended: a });
|
|
764
|
-
c.adapter = this.#r, a ? this.emit("drop", s) : this.emit("cancel", s), e.preventDefault?.();
|
|
765
|
-
};
|
|
766
|
-
#h = (e) => {
|
|
767
|
-
let t = this.#o.session;
|
|
768
|
-
if (!t.active || !t.started) return !1;
|
|
769
|
-
this.#i.reset(e), this.#r.beginFrame(), t.cache.frameId = this.#r.frameId;
|
|
770
|
-
let n = d({
|
|
771
|
-
dnd: this,
|
|
772
|
-
session: t,
|
|
773
|
-
store: this.#a,
|
|
774
|
-
frame: this.#i,
|
|
775
|
-
adapter: this.#r
|
|
776
|
-
}), r = !1;
|
|
777
|
-
return t.dirty &&= (this.#s.onMeasure(n), this.#s.onCompute(n), this.emit("drag", n.payload("drag")), this.#s.onCommit(n), this.#i.commit(), this.#i.scrolled && (r = !0), !1), this.#s.onAfterDrag(n) && (r = !0), r && (t.dirty = !0), this.#r.endFrame(), t.dirty || r;
|
|
778
|
-
};
|
|
779
|
-
}, x = class {
|
|
780
|
-
order = 10;
|
|
781
|
-
onMeasure(e) {
|
|
782
|
-
let t = e.session;
|
|
783
|
-
if (!t.active || !t.started) return;
|
|
784
|
-
let n = e.adapter.hitDrop(t.x, t.y, t.namespace, t.sourceEl);
|
|
785
|
-
if (n && t.sourceEl && e.adapter.isDrop(t.sourceEl)) {
|
|
786
|
-
let r = e.adapter.measureRect(t.sourceEl);
|
|
787
|
-
r && t.x >= r.left && t.x <= r.right && t.y >= r.top && t.y <= r.bottom && (n = void 0);
|
|
788
|
-
}
|
|
789
|
-
if (n !== t.currentDrop && (t.currentDrop = n, t.cache && (t.cache.dropRectDirty = !0)), !n) {
|
|
790
|
-
t.currentDropRect = void 0, t.cache && (t.cache.dropRectDirty = !1);
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
(t.cache?.dropRectDirty || !t.currentDropRect) && (t.currentDropRect = e.adapter.measureRect(n), t.cache.dropRectDirty = !1);
|
|
794
|
-
}
|
|
795
|
-
onCompute(e) {
|
|
796
|
-
let t = e.session;
|
|
797
|
-
if (!t.active || !t.started) return;
|
|
798
|
-
if (!t.currentDrop) {
|
|
799
|
-
t.currentAllowed = !1;
|
|
800
|
-
return;
|
|
801
|
-
}
|
|
802
|
-
let n = e.dnd?.canDrop;
|
|
803
|
-
if (typeof n != "function") {
|
|
804
|
-
t.currentAllowed = !0;
|
|
805
|
-
return;
|
|
806
|
-
}
|
|
807
|
-
try {
|
|
808
|
-
t.currentAllowed = !!n(e.payload("drag"));
|
|
809
|
-
} catch {
|
|
810
|
-
t.currentAllowed = !1;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
onCommit(e) {
|
|
814
|
-
let t = e.session;
|
|
815
|
-
if (!t?.active || !t?.started) return;
|
|
816
|
-
let r = t.cache ||= {}, i = r._dropClassEl, a = t.currentDrop;
|
|
817
|
-
m(i) && i !== a && (e.frame.toggleClass(i, n.canDrop, !1), e.frame.toggleClass(i, n.noDrop, !1)), m(a) && (e.frame.toggleClass(a, n.canDrop, !!t.currentAllowed), e.frame.toggleClass(a, n.noDrop, !t.currentAllowed)), r._dropClassEl = a;
|
|
818
|
-
}
|
|
819
|
-
onEnd(e) {
|
|
820
|
-
let t = e?.session;
|
|
821
|
-
if (!t) return;
|
|
822
|
-
let r = t.cache?._dropClassEl;
|
|
823
|
-
m(r) && r.classList.remove(n.canDrop, n.noDrop), t.cache && (t.cache._dropClassEl = void 0);
|
|
824
|
-
}
|
|
825
|
-
onDestroy(e, t) {
|
|
826
|
-
this.onEnd({ session: t });
|
|
827
|
-
}
|
|
828
|
-
}, S = class {
|
|
829
|
-
order = 0;
|
|
830
|
-
onStart = (e) => {
|
|
831
|
-
let r = e?.session;
|
|
832
|
-
if (!r?.sourceEl || r.mirrorEl || (r.sourceEl.classList.add(n.dragging), r.sourceEl.hasAttribute?.(t.ignoreMirrorAttr))) return;
|
|
833
|
-
let i = e.adapter.measureRect(r.sourceEl), a = typeof e?.dnd?.renderMirror == "function" ? e.dnd.renderMirror(e) : r.sourceEl.cloneNode(!0);
|
|
834
|
-
a instanceof HTMLElement && (a.setAttribute(t.ignoreMirrorAttr, ""), a.classList.add(n.mirror), Object.assign(a.style, {
|
|
835
|
-
width: `${i.width}px`,
|
|
836
|
-
height: `${i.height}px`,
|
|
837
|
-
position: "fixed"
|
|
838
|
-
}), (e.dnd?.root || document.body).appendChild(a), r.mirrorEl = a);
|
|
839
|
-
};
|
|
840
|
-
onCommit = (e) => {
|
|
841
|
-
let t = e?.session;
|
|
842
|
-
if (!(!t?.active || !t.started) && t.mirrorEl) {
|
|
843
|
-
let n = t.x - (t.mirrorOffsetX || 0), r = t.y - (t.mirrorOffsetY || 0);
|
|
844
|
-
e.frame.setStyle(t.mirrorEl, "transform", `translate3d(${n}px, ${r}px, 0)`);
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
onEnd = (e) => {
|
|
848
|
-
let t = e?.session;
|
|
849
|
-
t && (t.mirrorEl &&= (t.mirrorEl.remove(), void 0), t.sourceEl?.classList.remove(n.dragging));
|
|
850
|
-
};
|
|
851
|
-
onDestroy = (e, t) => {
|
|
852
|
-
this.onEnd({ session: t });
|
|
853
|
-
};
|
|
854
|
-
}, C = /(auto|scroll|overlay)/i;
|
|
855
|
-
function w(e) {
|
|
856
|
-
if (!(e instanceof HTMLElement)) return !1;
|
|
857
|
-
let t = getComputedStyle(e), n = C.test(t.overflowY) && e.scrollHeight > e.clientHeight + 1;
|
|
858
|
-
return C.test(t.overflowX) && e.scrollWidth > e.clientWidth + 1 || n;
|
|
859
|
-
}
|
|
860
|
-
function T(e) {
|
|
861
|
-
let t = e;
|
|
862
|
-
for (; t;) {
|
|
863
|
-
if (w(t)) return t;
|
|
864
|
-
t = t.parentElement;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
function E(e, t, n, r) {
|
|
868
|
-
return e < t + r ? {
|
|
869
|
-
dir: -1,
|
|
870
|
-
k: (t + r - e) / r
|
|
871
|
-
} : e > n - r ? {
|
|
872
|
-
dir: 1,
|
|
873
|
-
k: (e - (n - r)) / r
|
|
874
|
-
} : {
|
|
875
|
-
dir: 0,
|
|
876
|
-
k: 0
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
var D = class {
|
|
880
|
-
order = 1e4;
|
|
881
|
-
constructor(e = {}) {
|
|
882
|
-
this.edge = e.edge ?? o.EDGE, this.minSpeed = e.minSpeed ?? o.MIN_SPEED, this.maxSpeed = e.maxSpeed ?? o.MAX_SPEED, this.allowWindowScroll = e.allowWindowScroll ?? !0;
|
|
883
|
-
}
|
|
884
|
-
onAfterDrag = (e) => {
|
|
885
|
-
let t = e.session;
|
|
886
|
-
if (!t.active || !t.started) return !1;
|
|
887
|
-
let n = t.currentDrop ? T(t.currentDrop) : void 0, r = !1;
|
|
888
|
-
if (!n && this.allowWindowScroll && (n = document.scrollingElement || document.documentElement, r = !!n), !n) return !1;
|
|
889
|
-
let i = e.frame.now, a = t.cache.autoScrollLastTs || 0, o = a ? Math.max(8, Math.min(64, i - a)) : 16.67;
|
|
890
|
-
t.cache && (t.cache.autoScrollLastTs = i);
|
|
891
|
-
let s = r ? {
|
|
892
|
-
left: 0,
|
|
893
|
-
top: 0,
|
|
894
|
-
right: innerWidth,
|
|
895
|
-
bottom: innerHeight
|
|
896
|
-
} : e.adapter.measureRect(n), c = t.x, l = t.y, u = E(c, s.left, s.right, this.edge), d = E(l, s.top, s.bottom, this.edge), f = (e) => this.minSpeed + (this.maxSpeed - this.minSpeed) * e, p = u.dir ? u.dir * f(u.k) * o / 1e3 : 0, m = d.dir ? d.dir * f(d.k) * o / 1e3 : 0;
|
|
897
|
-
if (!p && !m) return !1;
|
|
898
|
-
let h = n.scrollTop, g = n.scrollLeft;
|
|
899
|
-
r ? window.scrollBy(p, m) : n.scrollBy({
|
|
900
|
-
left: p,
|
|
901
|
-
top: m,
|
|
902
|
-
behavior: "auto"
|
|
903
|
-
});
|
|
904
|
-
let _ = h !== n.scrollTop || g !== n.scrollLeft;
|
|
905
|
-
return _ && e.frame && (e.frame.scrolled = !0), _;
|
|
906
|
-
};
|
|
907
|
-
onEnd = (e) => {
|
|
908
|
-
let t = e?.session;
|
|
909
|
-
t?.cache && (t.cache.autoScrollLastTs = 0);
|
|
910
|
-
};
|
|
911
|
-
}, O = {
|
|
912
|
-
top: n.indicatorTop,
|
|
913
|
-
right: n.indicatorRight,
|
|
914
|
-
bottom: n.indicatorBottom,
|
|
915
|
-
left: n.indicatorLeft
|
|
916
|
-
}, k = Object.values(O), ie = new Set([
|
|
917
|
-
"top",
|
|
918
|
-
"right",
|
|
919
|
-
"bottom",
|
|
920
|
-
"left"
|
|
921
|
-
]);
|
|
922
|
-
function A(e, t, n, r) {
|
|
923
|
-
m(t) && (e.frame.toggleClass ? e.frame.toggleClass(t, n, !!r) : t.classList.toggle(n, !!r));
|
|
924
|
-
}
|
|
925
|
-
function ae(e) {
|
|
926
|
-
if (!m(e)) return;
|
|
927
|
-
let n = t.dropIndicatorAttr || "drop-indicator", r = `data-${n}`, i;
|
|
928
|
-
if (e.hasAttribute?.(n)) i = e.getAttribute?.(n);
|
|
929
|
-
else if (e.hasAttribute?.(r)) i = e.getAttribute?.(r);
|
|
930
|
-
else return;
|
|
931
|
-
let a = (i ?? "").trim();
|
|
932
|
-
if (!a) return "all";
|
|
933
|
-
console.log("raw", i);
|
|
934
|
-
let o = /* @__PURE__ */ new Set();
|
|
935
|
-
for (let e of a.split(/[,\s]+/)) {
|
|
936
|
-
let t = (e || "").trim().toLowerCase();
|
|
937
|
-
ie.has(t) && o.add(t);
|
|
938
|
-
}
|
|
939
|
-
return o.size ? o : void 0;
|
|
940
|
-
}
|
|
941
|
-
function oe(e) {
|
|
942
|
-
let t = e.session, r = e.dnd?.root?.ownerDocument || document, i = t.indicatorEl;
|
|
943
|
-
m(i) || (i = r.createElement("div"), i.classList.add(n.dropIndicator), t.indicatorEl = i);
|
|
944
|
-
let a = t.currentDrop || e.dnd?.root || r.body;
|
|
945
|
-
return m(a) && i.parentNode !== a && a.appendChild(i), i;
|
|
946
|
-
}
|
|
947
|
-
function se(e, t) {
|
|
948
|
-
if (!e.currentDrop || !e.currentDropRect) return;
|
|
949
|
-
let n = s(e, t);
|
|
950
|
-
if (n.isOverLeft()) return "left";
|
|
951
|
-
if (n.isOverRight()) return "right";
|
|
952
|
-
if (n.isOverTop()) return "top";
|
|
953
|
-
if (n.isOverBottom()) return "bottom";
|
|
954
|
-
}
|
|
955
|
-
function ce(e) {
|
|
956
|
-
let t = e.session;
|
|
957
|
-
return t.currentDrop ? typeof t.currentAllowed == "boolean" ? t.currentAllowed : !0 : !1;
|
|
958
|
-
}
|
|
959
|
-
var le = class {
|
|
960
|
-
order = 40;
|
|
961
|
-
onCommit(e) {
|
|
962
|
-
let t = e.session;
|
|
963
|
-
if (!t?.active || !t?.started) return;
|
|
964
|
-
let r = t.currentDrop, i = ae(r);
|
|
965
|
-
if (!i) {
|
|
966
|
-
let r = t.indicatorEl;
|
|
967
|
-
if (m(r)) {
|
|
968
|
-
A(e, r, n.dropIndicatorActive, !1);
|
|
969
|
-
for (let t of k) A(e, r, t, !1);
|
|
970
|
-
}
|
|
971
|
-
t.indicatorRegion = void 0;
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
let a = oe(e), o = ce(e), s = se(t, i), c = i === "all" || s && i.has(s) ? s : void 0, l = !!(r && t.currentDropRect && o && c);
|
|
975
|
-
if (A(e, a, n.dropIndicatorActive, l), t.indicatorRegion = l ? c : void 0, l) for (let [t, n] of Object.entries(O)) A(e, a, n, t === c);
|
|
976
|
-
else for (let t of k) A(e, a, t, !1);
|
|
977
|
-
}
|
|
978
|
-
onEnd(e) {
|
|
979
|
-
let t = e.session;
|
|
980
|
-
t && (t.lastIndicatorRegion = t.indicatorRegion ?? "inside", m(t.indicatorEl) && t.indicatorEl.remove(), t.indicatorEl = void 0, t.indicatorRegion = void 0);
|
|
981
|
-
}
|
|
982
|
-
onDestroy(e, t) {
|
|
983
|
-
this.onEnd({ session: t });
|
|
984
|
-
}
|
|
985
|
-
}, j = "draggable-dot-wrap", M = "draggable-dot", N = "draggable-rotate";
|
|
986
|
-
function P(e, n = {}) {
|
|
987
|
-
let { resizable: r = !0, rotatable: i = !0 } = n, a = e.createElement("div");
|
|
988
|
-
if (a.classList.add(j), a.dataset.resizable = String(r), a.dataset.rotatable = String(i), r) for (let [n, r] of [
|
|
989
|
-
["nw", "tl"],
|
|
990
|
-
["n", "tm"],
|
|
991
|
-
["ne", "tr"],
|
|
992
|
-
["e", "rm"],
|
|
993
|
-
["se", "br"],
|
|
994
|
-
["s", "bm"],
|
|
995
|
-
["sw", "bl"],
|
|
996
|
-
["w", "lm"]
|
|
997
|
-
]) {
|
|
998
|
-
let i = e.createElement("div");
|
|
999
|
-
i.classList.add(M), i.setAttribute(t.handleResizeAttr, ""), i.dataset.dir = n, i.dataset.pos = r, a.appendChild(i);
|
|
1000
|
-
}
|
|
1001
|
-
if (i) {
|
|
1002
|
-
let n = e.createElement("div");
|
|
1003
|
-
n.classList.add(N), n.setAttribute(t.handleRotateAttr, ""), n.dataset.dir = "rotate", a.appendChild(n);
|
|
1004
|
-
}
|
|
1005
|
-
return a;
|
|
1006
|
-
}
|
|
1007
|
-
function F(e) {
|
|
1008
|
-
m(e) && e.querySelector?.(`.${j}`)?.remove();
|
|
1009
|
-
}
|
|
1010
|
-
function I(e) {
|
|
1011
|
-
if (!m(e)) return;
|
|
1012
|
-
let n = !!e.closest?.(_), r = e.querySelector?.(".draggable-dot-wrap") || null, i = !!r, a = f(e, t.resizableAttr, !0), o = f(e, t.rotatableAttr, !0), s = a || o;
|
|
1013
|
-
if (!n) {
|
|
1014
|
-
i && F(e);
|
|
1015
|
-
return;
|
|
1016
|
-
}
|
|
1017
|
-
if (!s) {
|
|
1018
|
-
i && F(e);
|
|
1019
|
-
return;
|
|
1020
|
-
}
|
|
1021
|
-
if (r && (String(r.dataset?.resizable) !== String(a) || String(r.dataset?.rotatable) !== String(o)) && (r.remove(), r = null, i = !1), !i) {
|
|
1022
|
-
let t = getComputedStyle(e).position;
|
|
1023
|
-
(t === "static" || !t) && (e.style.position = "relative"), e.appendChild(P(e.ownerDocument || document, {
|
|
1024
|
-
resizable: a,
|
|
1025
|
-
rotatable: o
|
|
1026
|
-
}));
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
function L(e, t, r, i) {
|
|
1030
|
-
let a = t.get(i);
|
|
1031
|
-
if (a && a !== r) if (Array.isArray(a)) for (let e of a) e?.classList?.remove?.(n.active), F(e);
|
|
1032
|
-
else a.classList.remove(n.active), F(a);
|
|
1033
|
-
r.classList.add(n.active), I(r), t.set(i, r);
|
|
1034
|
-
}
|
|
1035
|
-
function R(e, t, r) {
|
|
1036
|
-
let i = e.get(r);
|
|
1037
|
-
if (i) if (Array.isArray(i)) for (let e of i) e?.classList?.remove?.(n.active), F(e);
|
|
1038
|
-
else i.classList.remove(n.active), F(i);
|
|
1039
|
-
for (let e of t) e.classList.add(n.active), I(e);
|
|
1040
|
-
e.set(r, t);
|
|
1041
|
-
}
|
|
1042
|
-
function z(e, t) {
|
|
1043
|
-
if (t !== void 0) {
|
|
1044
|
-
let r = e.get(t);
|
|
1045
|
-
if (r) {
|
|
1046
|
-
if (Array.isArray(r)) for (let e of r) e?.classList?.remove?.(n.active), F(e);
|
|
1047
|
-
else r?.classList?.remove?.(n.active), F(r);
|
|
1048
|
-
e.delete(t);
|
|
1049
|
-
}
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
|
-
for (let t of e.values()) if (Array.isArray(t)) for (let e of t) e?.classList?.remove?.(n.active), F(e);
|
|
1053
|
-
else t?.classList?.remove?.(n.active), F(t);
|
|
1054
|
-
e.clear();
|
|
1055
|
-
}
|
|
1056
|
-
var B = class {
|
|
1057
|
-
order = -50;
|
|
1058
|
-
#e;
|
|
1059
|
-
onAttach(e) {
|
|
1060
|
-
this.#e = e;
|
|
1061
|
-
}
|
|
1062
|
-
onRootChange(e, t, n) {
|
|
1063
|
-
if (!m(e)) return;
|
|
1064
|
-
let r = this.#e.monitor;
|
|
1065
|
-
e.addEventListener("pointerdown", (e) => {
|
|
1066
|
-
if (e.button !== 0 || h(e.target)) return;
|
|
1067
|
-
let t = r.selectedByNs;
|
|
1068
|
-
if (!t) return;
|
|
1069
|
-
let n = r.adapter.closestDraggable(e.target);
|
|
1070
|
-
if (!n) {
|
|
1071
|
-
z(t);
|
|
1072
|
-
return;
|
|
1073
|
-
}
|
|
1074
|
-
let i = r.adapter.getNamespace(n), a = t.get(i);
|
|
1075
|
-
Array.isArray(a) && a.length > 1 && a.includes(n) || L(null, t, n, i);
|
|
1076
|
-
}, {
|
|
1077
|
-
capture: !0,
|
|
1078
|
-
signal: n
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
onDown(e, t) {
|
|
1082
|
-
let r = e?.session;
|
|
1083
|
-
if (!r?.sourceEl || t?.button !== 0 || h(t.target)) return;
|
|
1084
|
-
let i = e.store?.selectedByNs || r.selectedByNs;
|
|
1085
|
-
if (!i) return;
|
|
1086
|
-
let a = r.namespace || e.adapter.getNamespace(r.sourceEl), o = i.get(a);
|
|
1087
|
-
Array.isArray(o) && o.length > 1 && o.includes(r.sourceEl) || (o && o !== r.sourceEl && (Array.isArray(o) ? o.forEach((t) => {
|
|
1088
|
-
e.frame.toggleClass(t, n.active, !1), F(t);
|
|
1089
|
-
}) : (e.frame.toggleClass(o, n.active, !1), F(o))), e.frame.toggleClass(r.sourceEl, n.active, !0), I(r.sourceEl), i.set(a, r.sourceEl));
|
|
1090
|
-
}
|
|
1091
|
-
onDestroy(e, t) {
|
|
1092
|
-
let n = t?.selectedByNs;
|
|
1093
|
-
n && z(n);
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
//#endregion
|
|
1097
|
-
//#region src/services/MarqueeSelectionService.js
|
|
1098
|
-
function V(e, t, n, r) {
|
|
1099
|
-
return {
|
|
1100
|
-
left: Math.min(e, n),
|
|
1101
|
-
right: Math.max(e, n),
|
|
1102
|
-
top: Math.min(t, r),
|
|
1103
|
-
bottom: Math.max(t, r),
|
|
1104
|
-
width: Math.abs(n - e),
|
|
1105
|
-
height: Math.abs(r - t)
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
function H(e, t) {
|
|
1109
|
-
let n = Math.max(e.left, t.left), r = Math.min(e.right, t.right), i = Math.max(e.top, t.top), a = Math.min(e.bottom, t.bottom), o = r - n, s = a - i;
|
|
1110
|
-
return o <= 0 || s <= 0 ? !1 : o * s > (t.right - t.left) * (t.bottom - t.top) * .5;
|
|
1111
|
-
}
|
|
1112
|
-
var U = class {
|
|
1113
|
-
order = -40;
|
|
1114
|
-
#e;
|
|
1115
|
-
#t;
|
|
1116
|
-
onAttach(e) {
|
|
1117
|
-
this.#e = e;
|
|
1118
|
-
}
|
|
1119
|
-
onRootChange(e, t, n) {
|
|
1120
|
-
this.#t = n, m(e) && e.addEventListener("pointerdown", (e) => {
|
|
1121
|
-
if (e.button !== 0 || h(e.target)) return;
|
|
1122
|
-
let t = e.target.closest(_);
|
|
1123
|
-
t && (this.#e.monitor.adapter.closestDraggable(e.target) || this.#n(t, e));
|
|
1124
|
-
}, {
|
|
1125
|
-
capture: !0,
|
|
1126
|
-
signal: n
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
#n(e, r) {
|
|
1130
|
-
let i = r.clientX, o = r.clientY, s = this.#e.monitor.adapter.getNamespace(e), c = parseFloat(e.getAttribute(t.scaleRatioAttr) || "1"), l = document.createElement("div");
|
|
1131
|
-
l.classList.add(n.marquee), e.appendChild(l);
|
|
1132
|
-
let u = !1, d = (t) => {
|
|
1133
|
-
let n = t.clientX - i, r = t.clientY - o;
|
|
1134
|
-
if (!u && Math.abs(n) < a.MARQUEE_MOVE && Math.abs(r) < a.MARQUEE_MOVE) return;
|
|
1135
|
-
u = !0;
|
|
1136
|
-
let d = V(i, o, t.clientX, t.clientY);
|
|
1137
|
-
this.#r(l, d, e, c);
|
|
1138
|
-
let f = this.#i(e, s, d), p = this.#e.monitor.selectedByNs;
|
|
1139
|
-
p && (z(p, s), f.length > 0 && R(p, f, s));
|
|
1140
|
-
}, f = new AbortController(), p = [f.signal, this.#t].filter(Boolean), m = () => {
|
|
1141
|
-
if (!f.signal.aborted) {
|
|
1142
|
-
try {
|
|
1143
|
-
l.remove();
|
|
1144
|
-
} catch {}
|
|
1145
|
-
f.abort();
|
|
1146
|
-
}
|
|
1147
|
-
}, h = () => {
|
|
1148
|
-
if (!u) {
|
|
1149
|
-
let e = this.#e.monitor?.selectedByNs;
|
|
1150
|
-
e && z(e, s);
|
|
1151
|
-
}
|
|
1152
|
-
m();
|
|
1153
|
-
};
|
|
1154
|
-
for (let e of p) {
|
|
1155
|
-
if (e.aborted) {
|
|
1156
|
-
m();
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
e.addEventListener("abort", m, { once: !0 });
|
|
1160
|
-
}
|
|
1161
|
-
let g = { signal: f.signal };
|
|
1162
|
-
document.addEventListener("pointermove", d, g), document.addEventListener("pointerup", h, g), document.addEventListener("pointercancel", m, g), window.addEventListener("blur", m, g);
|
|
1163
|
-
}
|
|
1164
|
-
#r(e, t, n, r) {
|
|
1165
|
-
let i = n.getBoundingClientRect(), a = (t.left - i.left) / r, o = (t.top - i.top) / r, s = t.width / r, c = t.height / r;
|
|
1166
|
-
e.style.left = `${a}px`, e.style.top = `${o}px`, e.style.width = `${s}px`, e.style.height = `${c}px`;
|
|
1167
|
-
}
|
|
1168
|
-
#i(e, n, r) {
|
|
1169
|
-
let i = this.#e.monitor.adapter, a = e.querySelectorAll(`[${t.dragAttr}], [${t.dragdropAttr}]`), o = [];
|
|
1170
|
-
for (let e of a) {
|
|
1171
|
-
if (i.getNamespace(e) !== n) continue;
|
|
1172
|
-
let t = i.measureRect(e);
|
|
1173
|
-
t && H(r, t) && o.push(e);
|
|
1174
|
-
}
|
|
1175
|
-
return o;
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
//#endregion
|
|
1179
|
-
//#region src/services/transform/utils/geometry.js
|
|
1180
|
-
function W(e = 0) {
|
|
1181
|
-
return `${Number.parseInt(String(e), 10) || 0}px`;
|
|
1182
|
-
}
|
|
1183
|
-
function G(e) {
|
|
1184
|
-
return e * Math.PI / 180;
|
|
1185
|
-
}
|
|
1186
|
-
function ue(e, t) {
|
|
1187
|
-
return Math.sqrt(e * e + t * t);
|
|
1188
|
-
}
|
|
1189
|
-
function K(e, t) {
|
|
1190
|
-
let n = Math.max(1, Number(t) || 1), r = Math.abs(e) % n, i = e > 0 ? n : -n;
|
|
1191
|
-
return r > n / 2 ? i * Math.ceil(Math.abs(e) / n) : i * Math.floor(Math.abs(e) / n);
|
|
1192
|
-
}
|
|
1193
|
-
function q(e, t = 1, n) {
|
|
1194
|
-
let r = n.measureRect(e), i = Number(t) || 1;
|
|
1195
|
-
return {
|
|
1196
|
-
bottom: r.bottom / i,
|
|
1197
|
-
height: r.height / i,
|
|
1198
|
-
left: r.left / i,
|
|
1199
|
-
right: r.right / i,
|
|
1200
|
-
top: r.top / i,
|
|
1201
|
-
width: r.width / i
|
|
1202
|
-
};
|
|
1203
|
-
}
|
|
1204
|
-
function J(e, t, n, r) {
|
|
1205
|
-
let i = n - e, a = r - t, o = Math.atan2(a, i) * 180 / Math.PI + 90;
|
|
1206
|
-
return o = (o % 360 + 360) % 360, o;
|
|
1207
|
-
}
|
|
1208
|
-
function de(e, t, n) {
|
|
1209
|
-
let { width: r, height: i } = e;
|
|
1210
|
-
return {
|
|
1211
|
-
height: Math.abs(i),
|
|
1212
|
-
width: Math.abs(r),
|
|
1213
|
-
x: t - Math.abs(r) / 2,
|
|
1214
|
-
y: n - Math.abs(i) / 2
|
|
1215
|
-
};
|
|
1216
|
-
}
|
|
1217
|
-
function fe({ centerX: e, centerY: t, width: n, height: r, angle: i }) {
|
|
1218
|
-
return {
|
|
1219
|
-
angle: i,
|
|
1220
|
-
height: r,
|
|
1221
|
-
width: n,
|
|
1222
|
-
x: e - n / 2,
|
|
1223
|
-
y: t - r / 2
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
function Y(e) {
|
|
1227
|
-
let t = getComputedStyle(e), n = {};
|
|
1228
|
-
try {
|
|
1229
|
-
n = new DOMMatrixReadOnly(t.transform);
|
|
1230
|
-
} catch {
|
|
1231
|
-
n = new DOMMatrixReadOnly();
|
|
1232
|
-
}
|
|
1233
|
-
let r = n.m41, i = n.m42, a = Number.parseFloat(t.width), o = Number.parseFloat(t.height);
|
|
1234
|
-
if (!Number.isFinite(a) || !Number.isFinite(o)) {
|
|
1235
|
-
let t = e.getBoundingClientRect();
|
|
1236
|
-
a = t.width, o = t.height;
|
|
1237
|
-
}
|
|
1238
|
-
return {
|
|
1239
|
-
angle: -Math.atan2(n.m21, n.m11) * (180 / Math.PI),
|
|
1240
|
-
height: o,
|
|
1241
|
-
width: a,
|
|
1242
|
-
x: r,
|
|
1243
|
-
y: i
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
//#endregion
|
|
1247
|
-
//#region src/services/transform/utils/cursor.js
|
|
1248
|
-
var pe = {
|
|
1249
|
-
e: "right",
|
|
1250
|
-
n: "top",
|
|
1251
|
-
ne: "top-right",
|
|
1252
|
-
nw: "top-left",
|
|
1253
|
-
s: "bottom",
|
|
1254
|
-
se: "bottom-right",
|
|
1255
|
-
sw: "bottom-left",
|
|
1256
|
-
w: "left"
|
|
1257
|
-
}, me = [
|
|
1258
|
-
"n",
|
|
1259
|
-
"ne",
|
|
1260
|
-
"e",
|
|
1261
|
-
"se",
|
|
1262
|
-
"s",
|
|
1263
|
-
"sw",
|
|
1264
|
-
"w",
|
|
1265
|
-
"nw"
|
|
1266
|
-
], he = {
|
|
1267
|
-
0: 0,
|
|
1268
|
-
1: 1,
|
|
1269
|
-
2: 1,
|
|
1270
|
-
3: 2,
|
|
1271
|
-
4: 3,
|
|
1272
|
-
5: 3,
|
|
1273
|
-
6: 4,
|
|
1274
|
-
7: 5,
|
|
1275
|
-
8: 5,
|
|
1276
|
-
9: 6,
|
|
1277
|
-
10: 7,
|
|
1278
|
-
11: 7
|
|
1279
|
-
}, ge = {
|
|
1280
|
-
e: 2,
|
|
1281
|
-
n: 0,
|
|
1282
|
-
ne: 1,
|
|
1283
|
-
nw: 7,
|
|
1284
|
-
s: 4,
|
|
1285
|
-
se: 3,
|
|
1286
|
-
sw: 5,
|
|
1287
|
-
w: 6
|
|
1288
|
-
};
|
|
1289
|
-
function _e(e, t) {
|
|
1290
|
-
let n = he[Math.floor((e % 360 + 360) % 360 / 30)];
|
|
1291
|
-
return me[(ge[t] + n) % 8];
|
|
1292
|
-
}
|
|
1293
|
-
//#endregion
|
|
1294
|
-
//#region src/services/transform/utils/markline.js
|
|
1295
|
-
function ve(e, t) {
|
|
1296
|
-
let n = {
|
|
1297
|
-
x: [],
|
|
1298
|
-
y: []
|
|
1299
|
-
}, { width: r = 0, height: i = 0 } = t;
|
|
1300
|
-
return e.forEach((e) => {
|
|
1301
|
-
let { top: t, left: a, width: o, height: s } = e;
|
|
1302
|
-
n.y.push({
|
|
1303
|
-
showTop: t,
|
|
1304
|
-
top: t
|
|
1305
|
-
}), n.y.push({
|
|
1306
|
-
showTop: t,
|
|
1307
|
-
top: t - i
|
|
1308
|
-
}), n.y.push({
|
|
1309
|
-
showTop: t + s / 2,
|
|
1310
|
-
top: t + s / 2 - i / 2
|
|
1311
|
-
}), n.y.push({
|
|
1312
|
-
showTop: t + s,
|
|
1313
|
-
top: t + s
|
|
1314
|
-
}), n.y.push({
|
|
1315
|
-
showTop: t + s,
|
|
1316
|
-
top: t + s - i
|
|
1317
|
-
}), n.x.push({
|
|
1318
|
-
left: a,
|
|
1319
|
-
showLeft: a
|
|
1320
|
-
}), n.x.push({
|
|
1321
|
-
left: a + o,
|
|
1322
|
-
showLeft: a + o
|
|
1323
|
-
}), n.x.push({
|
|
1324
|
-
left: a + o / 2 - r / 2,
|
|
1325
|
-
showLeft: a + o / 2
|
|
1326
|
-
}), n.x.push({
|
|
1327
|
-
left: a + o - r,
|
|
1328
|
-
showLeft: a + o
|
|
1329
|
-
}), n.x.push({
|
|
1330
|
-
left: a - r,
|
|
1331
|
-
showLeft: a
|
|
1332
|
-
});
|
|
1333
|
-
}), n;
|
|
1334
|
-
}
|
|
1335
|
-
function ye(e) {
|
|
1336
|
-
let t = e.querySelector(".draggable-markline-x"), n = e.querySelector(".draggable-markline-y");
|
|
1337
|
-
return t || (t = document.createElement("div"), t.className = "draggable-markline-x", e.appendChild(t)), n || (n = document.createElement("div"), n.className = "draggable-markline-y", e.appendChild(n)), {
|
|
1338
|
-
x: t,
|
|
1339
|
-
y: n
|
|
1340
|
-
};
|
|
1341
|
-
}
|
|
1342
|
-
function X(e) {
|
|
1343
|
-
e && (e.style.display = "none");
|
|
1344
|
-
}
|
|
1345
|
-
//#endregion
|
|
1346
|
-
//#region src/services/transform/utils/resize.js
|
|
1347
|
-
function Z(e, t, n) {
|
|
1348
|
-
let r = e + t;
|
|
1349
|
-
return r > n ? e = r : (t = n - e, e = n), {
|
|
1350
|
-
deltaW: t,
|
|
1351
|
-
width: e
|
|
1352
|
-
};
|
|
1353
|
-
}
|
|
1354
|
-
function Q(e, t, n) {
|
|
1355
|
-
let r = e + t;
|
|
1356
|
-
return r > n ? e = r : (t = n - e, e = n), {
|
|
1357
|
-
deltaH: t,
|
|
1358
|
-
height: e
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
function be(e, t, n, r, i, a, o) {
|
|
1362
|
-
let { width: s, height: c, centerX: l, centerY: u, rotateAngle: d } = t, f = s < 0 ? -1 : 1, p = c < 0 ? -1 : 1;
|
|
1363
|
-
switch (s = Math.abs(s), c = Math.abs(c), [
|
|
1364
|
-
"top-left",
|
|
1365
|
-
"top-right",
|
|
1366
|
-
"bottom-left",
|
|
1367
|
-
"bottom-right"
|
|
1368
|
-
].includes(e) && (e === "top-right" ? r = -r : e === "bottom-left" ? n = -n : e === "top-left" && (n = -n, r = -r), {width: s, deltaW: n} = Z(s, n, a), {height: c, deltaH: r} = Q(c, r, o), i && (r = n / i, c = s / i)), e) {
|
|
1369
|
-
case "right":
|
|
1370
|
-
({width: s, deltaW: n} = Z(s, n, a)), i ? (r = n / i, c = s / i, l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d))) : (l += n / 2 * Math.cos(G(d)), u += n / 2 * Math.sin(G(d)));
|
|
1371
|
-
break;
|
|
1372
|
-
case "top-right":
|
|
1373
|
-
l += n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d));
|
|
1374
|
-
break;
|
|
1375
|
-
case "bottom-right":
|
|
1376
|
-
l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d));
|
|
1377
|
-
break;
|
|
1378
|
-
case "bottom":
|
|
1379
|
-
({height: c, deltaH: r} = Q(c, r, o)), i ? (n = r * i, s = c * i, l += n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d))) : (l -= r / 2 * Math.sin(G(d)), u += r / 2 * Math.cos(G(d)));
|
|
1380
|
-
break;
|
|
1381
|
-
case "bottom-left":
|
|
1382
|
-
l -= n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d));
|
|
1383
|
-
break;
|
|
1384
|
-
case "left":
|
|
1385
|
-
n = -n, {width: s, deltaW: n} = Z(s, n, a), i ? (c = s / i, r = n / i, l -= n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d))) : (l -= n / 2 * Math.cos(G(d)), u -= n / 2 * Math.sin(G(d)));
|
|
1386
|
-
break;
|
|
1387
|
-
case "top-left":
|
|
1388
|
-
l -= n / 2 * Math.cos(G(d)) - r / 2 * Math.sin(G(d)), u -= n / 2 * Math.sin(G(d)) + r / 2 * Math.cos(G(d));
|
|
1389
|
-
break;
|
|
1390
|
-
case "top":
|
|
1391
|
-
r = -r, {height: c, deltaH: r} = Q(c, r, o), i ? (s = c * i, n = r * i, l += n / 2 * Math.cos(G(d)) + r / 2 * Math.sin(G(d)), u += n / 2 * Math.sin(G(d)) - r / 2 * Math.cos(G(d))) : (l += r / 2 * Math.sin(G(d)), u -= r / 2 * Math.cos(G(d)));
|
|
1392
|
-
break;
|
|
1393
|
-
default: break;
|
|
1394
|
-
}
|
|
1395
|
-
return {
|
|
1396
|
-
position: {
|
|
1397
|
-
centerX: l,
|
|
1398
|
-
centerY: u
|
|
1399
|
-
},
|
|
1400
|
-
size: {
|
|
1401
|
-
height: c * p,
|
|
1402
|
-
width: s * f
|
|
1403
|
-
}
|
|
1404
|
-
};
|
|
1405
|
-
}
|
|
1406
|
-
//#endregion
|
|
1407
|
-
//#region src/services/transform/utils/handles.js
|
|
1408
|
-
function xe(e) {
|
|
1409
|
-
let t = e?.querySelector?.(":scope > .draggable-dot-wrap");
|
|
1410
|
-
return t ? [...t.querySelectorAll?.(".draggable-dot") || []] : [];
|
|
1411
|
-
}
|
|
1412
|
-
function Se(e) {
|
|
1413
|
-
let t = e?.dataset?.dir;
|
|
1414
|
-
return t && pe[t] || "right";
|
|
1415
|
-
}
|
|
1416
|
-
function Ce(e) {
|
|
1417
|
-
return !!e?.hasAttribute?.(t.handleRotateAttr);
|
|
1418
|
-
}
|
|
1419
|
-
function $(e) {
|
|
1420
|
-
return !!e?.hasAttribute?.(t.handleResizeAttr);
|
|
1421
|
-
}
|
|
1422
|
-
//#endregion
|
|
1423
|
-
//#region src/services/TransformControllerService.js
|
|
1424
|
-
var we = class {
|
|
1425
|
-
order = 25;
|
|
1426
|
-
#e;
|
|
1427
|
-
constructor(e = {}) {
|
|
1428
|
-
this.#e = {
|
|
1429
|
-
resizable: !0,
|
|
1430
|
-
rotatable: !0,
|
|
1431
|
-
boundary: !0,
|
|
1432
|
-
scaleRatio: 1,
|
|
1433
|
-
snapToGrid: !1,
|
|
1434
|
-
gridX: 10,
|
|
1435
|
-
gridY: 10,
|
|
1436
|
-
aspectRatio: void 0,
|
|
1437
|
-
minWidth: 10,
|
|
1438
|
-
minHeight: 10,
|
|
1439
|
-
maxWidth: 0,
|
|
1440
|
-
maxHeight: 0,
|
|
1441
|
-
rotateSnap: !1,
|
|
1442
|
-
rotateStep: 15,
|
|
1443
|
-
snap: !0,
|
|
1444
|
-
snapThreshold: 10,
|
|
1445
|
-
markline: !0,
|
|
1446
|
-
disableMirrorInScope: !0,
|
|
1447
|
-
disableDropIndicatorInScope: !0,
|
|
1448
|
-
canTransform: () => !0,
|
|
1449
|
-
...e
|
|
1450
|
-
};
|
|
1451
|
-
}
|
|
1452
|
-
#t(e, n) {
|
|
1453
|
-
let r = t.scaleRatioAttr || "scale-ratio", i = n?.getAttr?.(e, r) ?? n?.getAttr?.(e, `data-${r}`) ?? e?.getAttribute?.(r) ?? e?.getAttribute?.(`data-${r}`), a = Number.parseFloat(String(i ?? ""));
|
|
1454
|
-
if (Number.isFinite(a) && a > 0) return a;
|
|
1455
|
-
let o = Number(this.#e.scaleRatio);
|
|
1456
|
-
return Number.isFinite(o) && o > 0 ? o : 1;
|
|
1457
|
-
}
|
|
1458
|
-
#n(e) {
|
|
1459
|
-
let t = Number(e?.scaleRatio);
|
|
1460
|
-
if (Number.isFinite(t) && t > 0) return t;
|
|
1461
|
-
let n = Number(this.#e.scaleRatio);
|
|
1462
|
-
return Number.isFinite(n) && n > 0 ? n : 1;
|
|
1463
|
-
}
|
|
1464
|
-
onDown(e) {
|
|
1465
|
-
let t = e?.session;
|
|
1466
|
-
if (!t?.isDragScope || !m(t.sourceEl) || !this.#e.resizable) return;
|
|
1467
|
-
let { angle: n } = Y(t.sourceEl);
|
|
1468
|
-
n && this.#l(t.sourceEl, n);
|
|
1469
|
-
}
|
|
1470
|
-
onStart(e) {
|
|
1471
|
-
let n = e.session;
|
|
1472
|
-
if (!n?.active || !n?.started || !n.isDragScope || !m(n.sourceEl) || typeof this.#e.canTransform == "function" && !this.#e.canTransform(n.sourceEl)) return;
|
|
1473
|
-
let r = n.selectedByNs?.get(n.namespace), i = Array.isArray(r) && r.length > 1, a = "move", o = "", s = this.#e.rotatable && f(n.sourceEl, t.rotatableAttr, !0), c = this.#e.resizable && f(n.sourceEl, t.resizableAttr, !0);
|
|
1474
|
-
if (Ce(n.handleEl) && s) {
|
|
1475
|
-
if (i) return;
|
|
1476
|
-
a = "rotate";
|
|
1477
|
-
} else if ($(n.handleEl) && c) {
|
|
1478
|
-
if (i) return;
|
|
1479
|
-
a = "resize", o = Se(n.handleEl);
|
|
1480
|
-
}
|
|
1481
|
-
this.#e.disableMirrorInScope && this.#m(n), this.#e.disableDropIndicatorInScope && this.#h(n), n.cache.__transform = {
|
|
1482
|
-
phase: 0,
|
|
1483
|
-
type: a,
|
|
1484
|
-
side: o,
|
|
1485
|
-
scaleRatio: void 0,
|
|
1486
|
-
container: void 0,
|
|
1487
|
-
containerRect: void 0,
|
|
1488
|
-
containerRectScaled: void 0,
|
|
1489
|
-
boundary: void 0,
|
|
1490
|
-
start: void 0,
|
|
1491
|
-
data: void 0,
|
|
1492
|
-
center: void 0,
|
|
1493
|
-
rotateOffset: 0,
|
|
1494
|
-
startRect: void 0,
|
|
1495
|
-
viewportCenterOffset: void 0,
|
|
1496
|
-
lines: void 0,
|
|
1497
|
-
guideX: void 0,
|
|
1498
|
-
guideY: void 0,
|
|
1499
|
-
mark: {
|
|
1500
|
-
diffX: 0,
|
|
1501
|
-
diffY: 0,
|
|
1502
|
-
left: void 0,
|
|
1503
|
-
top: void 0
|
|
1504
|
-
},
|
|
1505
|
-
didCompute: !1,
|
|
1506
|
-
lastValidData: void 0,
|
|
1507
|
-
lastAppliedX: void 0,
|
|
1508
|
-
lastAppliedY: void 0,
|
|
1509
|
-
lastAppliedW: void 0,
|
|
1510
|
-
lastAppliedH: void 0,
|
|
1511
|
-
lastAppliedAngle: void 0,
|
|
1512
|
-
multiSelection: {
|
|
1513
|
-
enabled: i,
|
|
1514
|
-
elements: [],
|
|
1515
|
-
initialTransforms: []
|
|
1516
|
-
}
|
|
1517
|
-
};
|
|
1518
|
-
}
|
|
1519
|
-
onMeasure(e) {
|
|
1520
|
-
let n = e.session, r = n?.cache?.__transform;
|
|
1521
|
-
if (!n?.active || !n?.started || !n.isDragScope || !r || r.phase !== 0) return;
|
|
1522
|
-
if (!m(n.sourceEl)) {
|
|
1523
|
-
n.cache.__transform = void 0;
|
|
1524
|
-
return;
|
|
1525
|
-
}
|
|
1526
|
-
let i = e.adapter.closestDragScope(n.sourceEl);
|
|
1527
|
-
if (!m(i)) {
|
|
1528
|
-
n.cache.__transform = void 0;
|
|
1529
|
-
return;
|
|
1530
|
-
}
|
|
1531
|
-
let a = this.#t(i, e.adapter), o = Y(n.sourceEl), s = e.adapter.measureRect(i), c = {
|
|
1532
|
-
height: s.height / a,
|
|
1533
|
-
left: s.left / a,
|
|
1534
|
-
top: s.top / a,
|
|
1535
|
-
width: s.width / a
|
|
1536
|
-
};
|
|
1537
|
-
if (r.container = i, r.scaleRatio = a, r.containerRect = s, r.containerRectScaled = c, r.start = { ...o }, r.data = { ...o }, r.center = {
|
|
1538
|
-
x: o.x + o.width / 2,
|
|
1539
|
-
y: o.y + o.height / 2
|
|
1540
|
-
}, this.#e.boundary && (r.boundary = {
|
|
1541
|
-
w: Math.max(0, i.clientWidth),
|
|
1542
|
-
h: Math.max(0, i.clientHeight)
|
|
1543
|
-
}), r.type === "rotate") {
|
|
1544
|
-
let e = (n.x - s.left) / a, t = (n.y - s.top) / a;
|
|
1545
|
-
r.rotateOffset = J(r.center.x, r.center.y, e, t) - r.data.angle;
|
|
1546
|
-
}
|
|
1547
|
-
if (this.#e.snap || this.#e.markline) {
|
|
1548
|
-
let o = q(n.sourceEl, a, e.adapter);
|
|
1549
|
-
r.startRect = o, r.viewportCenterOffset = {
|
|
1550
|
-
x: o.left + o.width / 2 - r.center.x,
|
|
1551
|
-
y: o.top + o.height / 2 - r.center.y
|
|
1552
|
-
};
|
|
1553
|
-
let s = [...i.querySelectorAll?.(`[${t.dragAttr}]`) || []], c = [];
|
|
1554
|
-
for (let t of s) t !== n.sourceEl && m(t) && c.push(q(t, a, e.adapter));
|
|
1555
|
-
if (r.lines = ve(c, o), this.#e.markline) {
|
|
1556
|
-
let e = ye(i);
|
|
1557
|
-
r.guideX = e.x, r.guideY = e.y;
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
if (r.multiSelection.enabled) {
|
|
1561
|
-
let e = n.selectedByNs?.get(n.namespace);
|
|
1562
|
-
if (Array.isArray(e)) for (let t of e) t !== n.sourceEl && m(t) && (r.multiSelection.elements.push(t), r.multiSelection.initialTransforms.push(Y(t)));
|
|
1563
|
-
}
|
|
1564
|
-
r.phase = 1;
|
|
1565
|
-
}
|
|
1566
|
-
onCompute(e) {
|
|
1567
|
-
let t = e.session, n = t?.cache?.__transform;
|
|
1568
|
-
!t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || m(t.sourceEl) && (n.didCompute = !0, n.type === "move" ? this.#r(t, n) : n.type === "rotate" ? this.#i(t, n) : n.type === "resize" && this.#a(t, n));
|
|
1569
|
-
}
|
|
1570
|
-
onCommit(e) {
|
|
1571
|
-
let t = e.session, n = t?.cache?.__transform;
|
|
1572
|
-
if (!t?.active || !t?.started || !t.isDragScope || !n || n.phase !== 1 || !n.didCompute || !m(t.sourceEl)) return;
|
|
1573
|
-
if (this.#d(e, t.sourceEl, n), n.multiSelection.enabled && n.type === "move") {
|
|
1574
|
-
let t = n.data.x - n.start.x, r = n.data.y - n.start.y;
|
|
1575
|
-
for (let i = 0; i < n.multiSelection.elements.length; i++) {
|
|
1576
|
-
let a = n.multiSelection.elements[i], o = n.multiSelection.initialTransforms[i], s = {
|
|
1577
|
-
x: o.x + t,
|
|
1578
|
-
y: o.y + r,
|
|
1579
|
-
width: o.width,
|
|
1580
|
-
height: o.height,
|
|
1581
|
-
angle: o.angle
|
|
1582
|
-
};
|
|
1583
|
-
this.#u(e, a, s);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
n.type === "rotate" && this.#e.resizable && n.lastCursorAngle !== n.data?.angle && (n.lastCursorAngle = n.data?.angle, e.frame?.run?.(() => {
|
|
1587
|
-
this.#l(t.sourceEl, n.lastCursorAngle || 0);
|
|
1588
|
-
})), this.#e.markline && this.#c(e, n);
|
|
1589
|
-
let r = e.dnd;
|
|
1590
|
-
if (r?.emit && n?.data) {
|
|
1591
|
-
let i = {
|
|
1592
|
-
type: n.type,
|
|
1593
|
-
el: t.sourceEl,
|
|
1594
|
-
...n.data
|
|
1595
|
-
}, a = n.type === "move" ? "draggable:drag" : n.type === "rotate" ? "draggable:rotate" : "draggable:resize";
|
|
1596
|
-
e.frame?.run?.(() => {
|
|
1597
|
-
r.emit(a, i);
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
n.didCompute = !1;
|
|
1601
|
-
}
|
|
1602
|
-
onEnd(e, t) {
|
|
1603
|
-
let n = e.session, r = n?.cache?.__transform;
|
|
1604
|
-
r && (X(r.guideX), X(r.guideY), t?.ended && m(n?.sourceEl) && r?.data && e.dnd?.emit?.("draggable:drop", {
|
|
1605
|
-
type: r.type,
|
|
1606
|
-
el: n.sourceEl,
|
|
1607
|
-
data: n.data,
|
|
1608
|
-
...r.data
|
|
1609
|
-
}), t?.ended && r.type === "rotate" && this.#e.resizable && m(n?.sourceEl) && this.#l(n.sourceEl, r.data?.angle || 0), n.cache.__transform = void 0);
|
|
1610
|
-
}
|
|
1611
|
-
onDestroy(e, t) {
|
|
1612
|
-
let n = t?.cache?.__transform;
|
|
1613
|
-
n && (X(n.guideX), X(n.guideY), t.cache.__transform = void 0);
|
|
1614
|
-
}
|
|
1615
|
-
#r(e, t) {
|
|
1616
|
-
let n = this.#n(t), r = t.start.x + e.dx / n, i = t.start.y + e.dy / n;
|
|
1617
|
-
this.#e.snapToGrid && (r = t.start.x + K(r - t.start.x, this.#e.gridX), i = t.start.y + K(i - t.start.y, this.#e.gridY)), t.data = {
|
|
1618
|
-
...t.data,
|
|
1619
|
-
x: r,
|
|
1620
|
-
y: i
|
|
1621
|
-
}, this.#s(t), this.#f(t.data, t.boundary);
|
|
1622
|
-
}
|
|
1623
|
-
#i(e, t) {
|
|
1624
|
-
let n = this.#n(t), r = t.containerRect;
|
|
1625
|
-
if (!r) return;
|
|
1626
|
-
let i = (e.x - r.left) / n, a = (e.y - r.top) / n, o = J(t.center.x, t.center.y, i, a) - (t.rotateOffset ?? 0);
|
|
1627
|
-
if (o = (o % 360 + 360) % 360, this.#e.rotateSnap) {
|
|
1628
|
-
let e = Number(this.#e.rotateStep) || 15;
|
|
1629
|
-
o = Math.round(o / e) * e;
|
|
1630
|
-
}
|
|
1631
|
-
t.data = {
|
|
1632
|
-
...t.data,
|
|
1633
|
-
angle: o
|
|
1634
|
-
};
|
|
1635
|
-
}
|
|
1636
|
-
#a(e, t) {
|
|
1637
|
-
let n = this.#n(t), r = this.#e.aspectRatio, i = e.dx / n, a = e.dy / n, o = Math.atan2(a, i), s = ue(i, a), c = o - G(t.start.angle), l = s * Math.cos(c), u = s * Math.sin(c), d = {
|
|
1638
|
-
centerX: t.start.x + t.start.width / 2,
|
|
1639
|
-
centerY: t.start.y + t.start.height / 2,
|
|
1640
|
-
height: t.start.height,
|
|
1641
|
-
rotateAngle: t.start.angle,
|
|
1642
|
-
width: t.start.width
|
|
1643
|
-
}, { position: { centerX: f, centerY: p }, size: { width: m, height: h } } = be(t.side, d, l, u, r, this.#e.minWidth, this.#e.minHeight), g = fe({
|
|
1644
|
-
angle: t.data.angle,
|
|
1645
|
-
centerX: f,
|
|
1646
|
-
centerY: p,
|
|
1647
|
-
height: h,
|
|
1648
|
-
width: m
|
|
1649
|
-
}), _ = {
|
|
1650
|
-
...t.data,
|
|
1651
|
-
...de(g, f, p)
|
|
1652
|
-
};
|
|
1653
|
-
if (this.#e.maxWidth > 0 && (_.width = Math.min(_.width, this.#e.maxWidth)), this.#e.maxHeight > 0 && (_.height = Math.min(_.height, this.#e.maxHeight)), this.#e.snapToGrid) {
|
|
1654
|
-
let e = _.x + _.width / 2, n = _.y + _.height / 2, i = this.#e.gridX, a = this.#e.gridY, o = t.start.width + K(_.width - t.start.width, i), s;
|
|
1655
|
-
s = r ? o / r : t.start.height + K(_.height - t.start.height, a), _.width = Math.abs(o), _.height = Math.abs(s), _.x = e - _.width / 2, _.y = n - _.height / 2;
|
|
1656
|
-
}
|
|
1657
|
-
let v = _;
|
|
1658
|
-
this.#p(v, t.boundary) ? (t.data = v, t.lastValidData = { ...v }) : t.data = t.lastValidData ? { ...t.lastValidData } : { ...t.start }, this.#s(t);
|
|
1659
|
-
}
|
|
1660
|
-
#o(e) {
|
|
1661
|
-
let t = e?.data, n = e?.viewportCenterOffset;
|
|
1662
|
-
if (!t || !n) return e.startRect;
|
|
1663
|
-
let r = G(t.angle || 0), i = Math.cos(r), a = Math.sin(r), o = Math.abs(t.width * i) + Math.abs(t.height * a), s = Math.abs(t.width * a) + Math.abs(t.height * i), c = t.x + t.width / 2 + n.x, l = t.y + t.height / 2 + n.y, u = c - o / 2, d = l - s / 2;
|
|
1664
|
-
return {
|
|
1665
|
-
bottom: d + s,
|
|
1666
|
-
height: s,
|
|
1667
|
-
left: u,
|
|
1668
|
-
right: u + o,
|
|
1669
|
-
top: d,
|
|
1670
|
-
width: o
|
|
1671
|
-
};
|
|
1672
|
-
}
|
|
1673
|
-
#s(e) {
|
|
1674
|
-
if (!this.#e.snap && !this.#e.markline || !e?.lines || !e.containerRectScaled) return;
|
|
1675
|
-
let t = this.#o(e), n = e.lines || {
|
|
1676
|
-
x: [],
|
|
1677
|
-
y: []
|
|
1678
|
-
}, r = {
|
|
1679
|
-
diffX: 0,
|
|
1680
|
-
diffY: 0,
|
|
1681
|
-
left: void 0,
|
|
1682
|
-
top: void 0
|
|
1683
|
-
};
|
|
1684
|
-
for (let i = 0; i < (n.y.length || 0); i++) {
|
|
1685
|
-
let { top: a, showTop: o } = n.y[i], s = a - t.top;
|
|
1686
|
-
if (Math.abs(s) < this.#e.snapThreshold) {
|
|
1687
|
-
r.diffY = s, r.top = o - e.containerRectScaled.top;
|
|
1688
|
-
break;
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
for (let i = 0; i < (n.x.length || 0); i++) {
|
|
1692
|
-
let { left: a, showLeft: o } = n.x[i], s = a - t.left;
|
|
1693
|
-
if (Math.abs(s) < this.#e.snapThreshold) {
|
|
1694
|
-
r.diffX = s, r.left = o - e.containerRectScaled.left;
|
|
1695
|
-
break;
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
this.#e.snap && (r.diffX && (e.data.x += r.diffX), r.diffY && (e.data.y += r.diffY)), e.mark = r;
|
|
1699
|
-
}
|
|
1700
|
-
#c(e, t) {
|
|
1701
|
-
let { guideX: n, guideY: r } = t, i = t.mark || {};
|
|
1702
|
-
n && (i.left === void 0 ? e.frame?.setStyle?.(n, "display", "none") : (e.frame?.setStyle?.(n, "display", "block"), e.frame?.setStyle?.(n, "transform", `translate(${W(i.left)}, 0)`))), r && (i.top === void 0 ? e.frame?.setStyle?.(r, "display", "none") : (e.frame?.setStyle?.(r, "display", "block"), e.frame?.setStyle?.(r, "transform", `translate(0, ${W(i.top)})`)));
|
|
1703
|
-
}
|
|
1704
|
-
#l(e, t) {
|
|
1705
|
-
let n = xe(e);
|
|
1706
|
-
for (let e of n) {
|
|
1707
|
-
let n = e?.dataset?.dir;
|
|
1708
|
-
n && (e.style.cursor = `${_e(t, n)}-resize`);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
#u(e, t, n) {
|
|
1712
|
-
e.frame?.setStyle?.(t, "transform", `translate(${W(n.x)}, ${W(n.y)}) rotate(${n.angle}deg)`);
|
|
1713
|
-
}
|
|
1714
|
-
#d(e, t, n) {
|
|
1715
|
-
let r = n.data;
|
|
1716
|
-
n.lastAppliedW !== r.width && (e.frame?.setStyle?.(t, "width", W(r.width)), n.lastAppliedW = r.width), n.lastAppliedH !== r.height && (e.frame?.setStyle?.(t, "height", W(r.height)), n.lastAppliedH = r.height), (n.lastAppliedX !== r.x || n.lastAppliedY !== r.y || n.lastAppliedAngle !== r.angle) && (this.#u(e, t, r), n.lastAppliedX = r.x, n.lastAppliedY = r.y, n.lastAppliedAngle = r.angle);
|
|
1717
|
-
}
|
|
1718
|
-
#f(e, t) {
|
|
1719
|
-
if (!t) return;
|
|
1720
|
-
let n = G(e.angle || 0), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.width * r + e.height * i, o = e.width * i + e.height * r, s = (a - e.width) / 2, c = t.w - a / 2 - e.width / 2, l = (o - e.height) / 2, u = t.h - o / 2 - e.height / 2;
|
|
1721
|
-
e.x = Math.max(Math.min(s, c), Math.min(e.x, Math.max(s, c))), e.y = Math.max(Math.min(l, u), Math.min(e.y, Math.max(l, u)));
|
|
1722
|
-
}
|
|
1723
|
-
#p(e, t) {
|
|
1724
|
-
if (!t) return !0;
|
|
1725
|
-
let n = G(e.angle || 0), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = e.width * r + e.height * i, o = e.width * i + e.height * r, s = e.x + e.width / 2, c = e.y + e.height / 2, l = s - a / 2, u = s + a / 2, d = c - o / 2, f = c + o / 2;
|
|
1726
|
-
return !(l < -.5 || d < -.5 || u > t.w + .5 || f > t.h + .5);
|
|
1727
|
-
}
|
|
1728
|
-
#m(e) {
|
|
1729
|
-
if (e?.mirrorEl) {
|
|
1730
|
-
try {
|
|
1731
|
-
e.mirrorEl.parentNode?.removeChild?.(e.mirrorEl);
|
|
1732
|
-
} catch {}
|
|
1733
|
-
e.mirrorEl = void 0;
|
|
1734
|
-
}
|
|
1735
|
-
if (m(e?.sourceEl)) try {
|
|
1736
|
-
e.sourceEl.style.visibility = "";
|
|
1737
|
-
} catch {}
|
|
1738
|
-
}
|
|
1739
|
-
#h(e) {
|
|
1740
|
-
if (e?.indicatorEl) {
|
|
1741
|
-
try {
|
|
1742
|
-
e.indicatorEl.parentNode?.removeChild?.(e.indicatorEl);
|
|
1743
|
-
} catch {}
|
|
1744
|
-
e.indicatorEl = void 0, e.indicatorRegion = void 0;
|
|
1745
|
-
}
|
|
1746
|
-
e.currentDrop = void 0, e.currentDropRect = void 0, e.currentAllowed = !1;
|
|
1747
|
-
}
|
|
1748
|
-
}, Te = {
|
|
1749
|
-
name: "@ptahjs/dnd",
|
|
1750
|
-
version: "0.1.1"
|
|
1751
|
-
};
|
|
1752
|
-
//#endregion
|
|
1753
|
-
export { j as ACTIVE_WRAP_CLASS, B as ActiveSelectionService, D as AutoScrollService, M as DOT_CLASS, re as Dnd, Te as DndVersion, le as DropIndicatorService, x as DropService, U as MarqueeSelectionService, S as MirrorService, N as ROTATE_CLASS, we as TransformControllerService, z as clearAll, R as setMultipleActive };
|