react-sync-board 1.4.1 → 1.4.3
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/react-sync-board.js
CHANGED
|
@@ -124,25 +124,27 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
124
124
|
return e.useEffect(() => (h.current = !0, () => {
|
|
125
125
|
h.current = !1;
|
|
126
126
|
}), []), e.useEffect(() => {
|
|
127
|
-
if (!t) return
|
|
127
|
+
if (!t) return;
|
|
128
128
|
let e = () => {
|
|
129
129
|
console.log(`Disconnected from ${i}…`), h.current && (l(!1), d(!1));
|
|
130
130
|
};
|
|
131
131
|
return t.on("disconnect", e), () => {
|
|
132
132
|
t.off("disconnect", e);
|
|
133
133
|
};
|
|
134
|
-
}, [i, t]), e.useEffect(() =>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
134
|
+
}, [i, t]), e.useEffect(() => {
|
|
135
|
+
if (t) return t.connected || t.connect(), console.log(`Try to connect to wire ${n} on channel ${i}`), _.current || (_.current = !0, te({
|
|
136
|
+
socket: t,
|
|
137
|
+
room: n,
|
|
138
|
+
onMaster: () => {
|
|
139
|
+
console.log(`Is now master on channel ${i}…`), h.current && d(!0);
|
|
140
|
+
},
|
|
141
|
+
onJoined: (e) => {
|
|
142
|
+
console.log(`Connected on channel ${i}…`), m.current = e, h.current && (p(e), l(!0));
|
|
143
|
+
}
|
|
144
|
+
})), () => {
|
|
145
|
+
m.current?.leave();
|
|
146
|
+
};
|
|
147
|
+
}, [
|
|
146
148
|
i,
|
|
147
149
|
n,
|
|
148
150
|
t
|
|
@@ -167,25 +169,25 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
167
169
|
}, oe = ([e, t], { scale: n, rotate: r, translateX: i, translateY: a }) => ae((e - i) / n, (t - a) / n, -r), M = ([e, t], { scale: n, rotate: r, translateX: i, translateY: a }) => {
|
|
168
170
|
let [o, s] = ae(e, t, r);
|
|
169
171
|
return [o * n + i, s * n + a];
|
|
170
|
-
},
|
|
172
|
+
}, se = (e, t) => e.x > t.left && e.x < t.left + t.width && e.y > t.top && e.y < t.top + t.height, ce = (e, t) => Array.from(e.querySelectorAll(".corner")).every((e) => {
|
|
171
173
|
let { top: n, left: r } = e.getBoundingClientRect();
|
|
172
|
-
return
|
|
174
|
+
return se({
|
|
173
175
|
x: r,
|
|
174
176
|
y: n
|
|
175
177
|
}, t);
|
|
176
|
-
}),
|
|
178
|
+
}), le = (e, t) => ce(e, t.getBoundingClientRect()), N = (e, t) => {
|
|
177
179
|
try {
|
|
178
180
|
return document.getElementById(`${e}__${t}`);
|
|
179
181
|
} catch {
|
|
180
182
|
console.error(`Error while getting item with id ${t} inside wrapper`, e);
|
|
181
183
|
return;
|
|
182
184
|
}
|
|
183
|
-
},
|
|
185
|
+
}, P = (e) => {
|
|
184
186
|
let t = e?.dataset?.id;
|
|
185
187
|
return t || console.error("getIdFromElem call fails", e, JSON.stringify(e?.dataset), e?.dataset?.id), t;
|
|
186
|
-
},
|
|
188
|
+
}, ue = (e, t) => {
|
|
187
189
|
let n = e.reduce((e, n) => {
|
|
188
|
-
let r =
|
|
190
|
+
let r = N(t, n);
|
|
189
191
|
if (!r) return e || null;
|
|
190
192
|
let { left: i, right: a, top: o, bottom: s } = r.getBoundingClientRect(), c;
|
|
191
193
|
return c = e || {
|
|
@@ -196,10 +198,10 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
196
198
|
}, c.left = Math.min(i, c.left), c.top = Math.min(o, c.top), c.right = Math.max(a, c.right), c.bottom = Math.max(s, c.bottom), c;
|
|
197
199
|
}, null);
|
|
198
200
|
return n && (n.width = n.right - n.left, n.height = n.bottom - n.top, n);
|
|
199
|
-
},
|
|
200
|
-
let r = new Set(
|
|
201
|
+
}, de = (e, t, n = null) => (n === null && (n = /* @__PURE__ */ new Set()), !Array.isArray(t) || t.length === 0 ? [] : t.map((t) => n.has(t) ? [] : (n.add(t), e[t] ? [t, ...de(e, e[t].linkedItems, n)] : [])).flat()), fe = (e, t, n) => {
|
|
202
|
+
let r = new Set(de(e, n));
|
|
201
203
|
return t.filter((e) => r.has(e));
|
|
202
|
-
},
|
|
204
|
+
}, pe = ({ x: e, y: t, width: n, height: r }, { type: i = "grid", size: a = 1, offset: o = {
|
|
203
205
|
x: 0,
|
|
204
206
|
y: 0
|
|
205
207
|
} }) => {
|
|
@@ -220,7 +222,11 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
220
222
|
x: l + o.x - n / 2,
|
|
221
223
|
y: u + o.y - r / 2
|
|
222
224
|
};
|
|
223
|
-
},
|
|
225
|
+
}, me = /* @__PURE__ */ new Set([
|
|
226
|
+
"grid",
|
|
227
|
+
"hexH",
|
|
228
|
+
"hexV"
|
|
229
|
+
]), he = (e, t) => t && me.has(t.type) ? t : e && me.has(e.type) ? e : null, ge = /* @__PURE__ */ "#037758.#99092a.#067070.#c6650f.#008726.#3d7004.#348402.#057f58.#b58612.#c44c01.#0a7704.#0e910e.#027377.#c99e02.#054160.#157a01.#b10de2.#0d6289.#bc5d03.#ba0cd1.#d39f10.#0c4c7a.#460782.#a51f10.#cecb10.#9b0943.#607f0c.#007a4b.#bf0daa.#af0ad8".split("."), _e = () => ge[Math.floor(Math.random() * ge.length)], F = ({ wire: e, storeName: t, noSync: n = [], defaultValue: r }, i) => (a, o, s) => {
|
|
224
230
|
a({ ready: !1 });
|
|
225
231
|
let c = [];
|
|
226
232
|
(async () => {
|
|
@@ -244,7 +250,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
244
250
|
return d.unsub = () => {
|
|
245
251
|
c.forEach((e) => e());
|
|
246
252
|
}, d;
|
|
247
|
-
},
|
|
253
|
+
}, ve = e.createContext(), ye = (e, t) => ({
|
|
248
254
|
items: {},
|
|
249
255
|
getItems: () => t().items,
|
|
250
256
|
setItems: (t) => e({ items: t }),
|
|
@@ -267,7 +273,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
267
273
|
});
|
|
268
274
|
}), { items: r };
|
|
269
275
|
})
|
|
270
|
-
}),
|
|
276
|
+
}), be = (e, t) => ({
|
|
271
277
|
itemIds: [],
|
|
272
278
|
setItemIds: (t) => e({ itemIds: t }),
|
|
273
279
|
getItemIds: () => t().itemIds,
|
|
@@ -284,7 +290,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
284
290
|
return r[t] = n, { itemIds: r };
|
|
285
291
|
}),
|
|
286
292
|
updateManyItemIds: (t) => e((e) => ({ itemIds: e.itemIds.map((e, n) => t[n] === void 0 ? e : t[n]) }))
|
|
287
|
-
}),
|
|
293
|
+
}), xe = (e, t) => ({
|
|
288
294
|
removeItemsById: (t) => e((e) => ({
|
|
289
295
|
itemIds: e.itemIds.filter((e) => !t.includes(e)),
|
|
290
296
|
items: Object.fromEntries(Object.entries(e.items).filter(([e]) => !t.includes(e)))
|
|
@@ -311,7 +317,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
311
317
|
itemIds: r
|
|
312
318
|
};
|
|
313
319
|
})
|
|
314
|
-
}),
|
|
320
|
+
}), Se = (e, t) => ({
|
|
315
321
|
boardConfig: {},
|
|
316
322
|
getBoardConfig: () => t().boardConfig,
|
|
317
323
|
setBoardConfig: (t) => e({ boardConfig: t }),
|
|
@@ -319,7 +325,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
319
325
|
...e.boardConfig,
|
|
320
326
|
...t
|
|
321
327
|
} }))
|
|
322
|
-
}),
|
|
328
|
+
}), Ce = (e, t) => ({
|
|
323
329
|
session: {},
|
|
324
330
|
getSessionInfo: () => t().session,
|
|
325
331
|
setSessionInfo: (t) => e({ session: t }),
|
|
@@ -327,34 +333,34 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
327
333
|
...e.session,
|
|
328
334
|
...t
|
|
329
335
|
} }))
|
|
330
|
-
}),
|
|
331
|
-
let { wire: i } = k("room"), [o, c] = e.useState(!1), [l] = e.useState(() => s(
|
|
336
|
+
}), we = ({ storeName: t, children: n, defaultValue: r }) => {
|
|
337
|
+
let { wire: i } = k("room"), [o, c] = e.useState(!1), [l] = e.useState(() => s(F({
|
|
332
338
|
wire: i,
|
|
333
339
|
storeName: t,
|
|
334
340
|
defaultValue: r
|
|
335
341
|
}, (...e) => ({
|
|
336
|
-
...ge(...e),
|
|
337
|
-
..._e(...e),
|
|
338
|
-
...ve(...e),
|
|
339
342
|
...ye(...e),
|
|
340
|
-
...be(...e)
|
|
343
|
+
...be(...e),
|
|
344
|
+
...xe(...e),
|
|
345
|
+
...Se(...e),
|
|
346
|
+
...Ce(...e)
|
|
341
347
|
}))));
|
|
342
348
|
return e.useEffect(() => {
|
|
343
349
|
let e = l.subscribe((t) => {
|
|
344
350
|
t.ready && (e(), c(!0));
|
|
345
351
|
});
|
|
346
|
-
}, [l]), o ? /* @__PURE__ */ a(
|
|
352
|
+
}, [l]), o ? /* @__PURE__ */ a(ve.Provider, {
|
|
347
353
|
value: l,
|
|
348
354
|
children: n
|
|
349
355
|
}) : null;
|
|
350
|
-
},
|
|
351
|
-
let t = r(
|
|
356
|
+
}, I = (e) => {
|
|
357
|
+
let t = r(ve);
|
|
352
358
|
return c(t, e, l);
|
|
353
|
-
},
|
|
354
|
-
let [t, n] =
|
|
359
|
+
}, Te = () => {
|
|
360
|
+
let [t, n] = I((e) => [e.itemIds, e.items]);
|
|
355
361
|
return e.useMemo(() => t.map((e) => n[e]), [t, n]);
|
|
356
|
-
},
|
|
357
|
-
let [t, n, r] =
|
|
362
|
+
}, Ee = () => {
|
|
363
|
+
let [t, n, r] = I((e) => [
|
|
358
364
|
e.items,
|
|
359
365
|
e.itemIds,
|
|
360
366
|
e.getItemList
|
|
@@ -369,7 +375,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
369
375
|
n,
|
|
370
376
|
r
|
|
371
377
|
]), i;
|
|
372
|
-
},
|
|
378
|
+
}, De = 5e4, Oe = e.createContext(), ke = (e, t) => ({
|
|
373
379
|
config: {
|
|
374
380
|
itemTemplates: {},
|
|
375
381
|
actions: {},
|
|
@@ -380,14 +386,14 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
380
386
|
radius: 0
|
|
381
387
|
},
|
|
382
388
|
boardWrapperRect: {},
|
|
383
|
-
boardSize:
|
|
389
|
+
boardSize: De
|
|
384
390
|
},
|
|
385
391
|
updateConfiguration: (t) => e((e) => ({ config: {
|
|
386
392
|
...e.config,
|
|
387
393
|
...t
|
|
388
394
|
} })),
|
|
389
395
|
getConfiguration: () => t().config
|
|
390
|
-
}),
|
|
396
|
+
}), Ae = (e, t) => ({
|
|
391
397
|
boardState: {
|
|
392
398
|
movingItems: !1,
|
|
393
399
|
selecting: !1,
|
|
@@ -403,7 +409,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
403
409
|
...t
|
|
404
410
|
} })),
|
|
405
411
|
getBoardState: () => t().boardState
|
|
406
|
-
}),
|
|
412
|
+
}), je = (e, t) => ({
|
|
407
413
|
interactions: {},
|
|
408
414
|
getInteractions: () => t().interactions,
|
|
409
415
|
register: (t, n) => e((e) => {
|
|
@@ -425,7 +431,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
425
431
|
setTimeout(() => e(n), 0);
|
|
426
432
|
});
|
|
427
433
|
}
|
|
428
|
-
}),
|
|
434
|
+
}), Me = (e, t) => ({
|
|
429
435
|
selection: [],
|
|
430
436
|
setSelection: (t) => e((e) => JSON.stringify(e.selection) === JSON.stringify(t) ? {} : { selection: t }),
|
|
431
437
|
getSelection: () => t().selection,
|
|
@@ -441,34 +447,34 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
441
447
|
let n = e.selectionBox;
|
|
442
448
|
return !n || !t || n.top !== t.top || n.left !== t.left || n.width !== t.width || n.height !== t.height ? { selectionBox: t } : {};
|
|
443
449
|
})
|
|
444
|
-
}),
|
|
450
|
+
}), Ne = ({ children: t }) => {
|
|
445
451
|
let [n] = e.useState(() => s((...e) => ({
|
|
446
|
-
...
|
|
447
|
-
...
|
|
448
|
-
...
|
|
449
|
-
...
|
|
452
|
+
...ke(...e),
|
|
453
|
+
...Ae(...e),
|
|
454
|
+
...je(...e),
|
|
455
|
+
...Me(...e)
|
|
450
456
|
})));
|
|
451
|
-
return /* @__PURE__ */ a(
|
|
457
|
+
return /* @__PURE__ */ a(Oe.Provider, {
|
|
452
458
|
value: n,
|
|
453
459
|
children: t
|
|
454
460
|
});
|
|
455
|
-
},
|
|
456
|
-
let t = r(
|
|
461
|
+
}, L = (e) => {
|
|
462
|
+
let t = r(Oe);
|
|
457
463
|
return c(t, e, l);
|
|
458
|
-
},
|
|
459
|
-
let [e] =
|
|
464
|
+
}, Pe = () => {
|
|
465
|
+
let [e] = L((e) => [e.selection]);
|
|
460
466
|
return e;
|
|
461
|
-
},
|
|
462
|
-
let [e] =
|
|
467
|
+
}, Fe = () => {
|
|
468
|
+
let [e] = L((e) => [e.getSelection]);
|
|
463
469
|
return e;
|
|
464
|
-
},
|
|
465
|
-
let [t, n, r, i, a] =
|
|
470
|
+
}, Ie = 1e3, Le = .8, R = !1, z = () => {
|
|
471
|
+
let [t, n, r, i, a] = L((e) => [
|
|
466
472
|
e.getBoardState,
|
|
467
473
|
e.updateBoardState,
|
|
468
474
|
e.config.itemExtent,
|
|
469
475
|
e.getConfiguration,
|
|
470
476
|
e.updateConfiguration
|
|
471
|
-
]), o = e.useRef([.15, 5]), [s] =
|
|
477
|
+
]), o = e.useRef([.15, 5]), [s] = I((e) => [e.getItemList]), c = e.useCallback(() => {
|
|
472
478
|
let { translateX: e, translateY: n, scale: r, rotate: i } = t();
|
|
473
479
|
return {
|
|
474
480
|
translateX: e,
|
|
@@ -489,9 +495,9 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
489
495
|
...r,
|
|
490
496
|
...e(r)
|
|
491
497
|
};
|
|
492
|
-
|
|
498
|
+
R && console.log("New expected values: ", i, a, o, s);
|
|
493
499
|
let c = p(o), l = i, u = a;
|
|
494
|
-
|
|
500
|
+
R && console.log("New fixed values: ", l, u, c, s), n({
|
|
495
501
|
translateX: Number.isFinite(l) ? l : r.translateX,
|
|
496
502
|
translateY: Number.isFinite(u) ? u : r.translateY,
|
|
497
503
|
scale: Number.isFinite(c) ? c : p(1),
|
|
@@ -536,7 +542,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
536
542
|
e || 0,
|
|
537
543
|
n || 0,
|
|
538
544
|
r || 2e3
|
|
539
|
-
], u = o.width / (l * 2), d = o.height / (l * 2), f = p(Math.min(u, d) *
|
|
545
|
+
], u = o.width / (l * 2), d = o.height / (l * 2), f = p(Math.min(u, d) * Le), [h, g] = M([-s, -c], {
|
|
540
546
|
translateX: o.width / 2,
|
|
541
547
|
translateY: o.height / 2,
|
|
542
548
|
scale: f,
|
|
@@ -561,7 +567,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
561
567
|
};
|
|
562
568
|
}, [l, i]), y = e.useCallback(() => {
|
|
563
569
|
let e = s(), { uid: t } = i(), n = e.reduce((e, n) => {
|
|
564
|
-
let r =
|
|
570
|
+
let r = N(t, n.id);
|
|
565
571
|
return r && (e.left = Math.min(n.x, e.left), e.top = Math.min(n.y, e.top), e.right = Math.max(n.x + r.offsetWidth, e.right), e.bottom = Math.max(n.y + r.offsetHeight, e.bottom)), e;
|
|
566
572
|
}, {
|
|
567
573
|
left: Infinity,
|
|
@@ -573,7 +579,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
573
579
|
a({ itemExtent: {
|
|
574
580
|
x: 0,
|
|
575
581
|
y: 0,
|
|
576
|
-
radius:
|
|
582
|
+
radius: Ie
|
|
577
583
|
} });
|
|
578
584
|
return;
|
|
579
585
|
}
|
|
@@ -581,7 +587,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
581
587
|
x: (n.right + n.left) / 2,
|
|
582
588
|
y: (n.bottom + n.top) / 2
|
|
583
589
|
};
|
|
584
|
-
r.radius = Math.max(ie([r.x, r.y], [n.left, n.top]),
|
|
590
|
+
r.radius = Math.max(ie([r.x, r.y], [n.left, n.top]), Ie), a({ itemExtent: r });
|
|
585
591
|
}, [
|
|
586
592
|
i,
|
|
587
593
|
s,
|
|
@@ -600,7 +606,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
600
606
|
]), x = u(() => y(), [y], 200);
|
|
601
607
|
return e.useEffect(() => {
|
|
602
608
|
window.debugUpdateExtent = () => y(), window.debugDisplayExtent = () => console.log(i().itemExtent), window.debugSetDebug = () => {
|
|
603
|
-
|
|
609
|
+
R = !0;
|
|
604
610
|
};
|
|
605
611
|
}, [i, y]), {
|
|
606
612
|
setDim: m,
|
|
@@ -616,8 +622,8 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
616
622
|
fromWrapperToBoard: l,
|
|
617
623
|
fromBoardToWrapper: d
|
|
618
624
|
};
|
|
619
|
-
},
|
|
620
|
-
let [n, r, i] =
|
|
625
|
+
}, B = (t) => {
|
|
626
|
+
let [n, r, i] = L(({ register: e, unregister: t, callInteractions: n }) => [
|
|
621
627
|
e,
|
|
622
628
|
t,
|
|
623
629
|
n
|
|
@@ -634,13 +640,13 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
634
640
|
i(t, e);
|
|
635
641
|
}, [i, t])
|
|
636
642
|
};
|
|
637
|
-
},
|
|
638
|
-
let { call: t } =
|
|
643
|
+
}, V = () => {
|
|
644
|
+
let { call: t } = B("place"), { call: n } = B("delete"), { getCenter: r, updateItemExtent: i } = z(), [a, o, s, c] = L((e) => [
|
|
639
645
|
e.clear,
|
|
640
646
|
e.reverse,
|
|
641
647
|
e.unselect,
|
|
642
648
|
e.getConfiguration
|
|
643
|
-
]), { getItems: l, getItemIds: u, setItemIds: d, updateItems: f, moveItems: p, removeItemsById: m, getItemList: h, insertItems: g, setItemList: _ } =
|
|
649
|
+
]), { getItems: l, getItemIds: u, setItemIds: d, updateItems: f, moveItems: p, removeItemsById: m, getItemList: h, insertItems: g, setItemList: _ } = I(({ getItems: e, getItemIds: t, setItemIds: n, updateItems: r, moveItems: i, removeItemsById: a, getItemList: o, insertItems: s, setItemList: c }) => ({
|
|
644
650
|
getItems: e,
|
|
645
651
|
getItemIds: t,
|
|
646
652
|
setItemIds: n,
|
|
@@ -674,7 +680,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
674
680
|
]), b = e.useCallback((e, t, n = !1) => {
|
|
675
681
|
v([e], t, n);
|
|
676
682
|
}, [v]), x = e.useCallback((e, t) => {
|
|
677
|
-
p(
|
|
683
|
+
p(fe(l(), u(), e), t);
|
|
678
684
|
}, [
|
|
679
685
|
u,
|
|
680
686
|
l,
|
|
@@ -682,29 +688,21 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
682
688
|
]), S = e.useCallback((e) => {
|
|
683
689
|
let t = u(), n = t.filter((t) => !e.includes(t)), r = t.filter((t) => e.includes(t));
|
|
684
690
|
d([...n, ...r]);
|
|
685
|
-
}, [u, d]), C = e.useCallback((e,
|
|
686
|
-
let { uid:
|
|
691
|
+
}, [u, d]), C = e.useCallback((e, t) => {
|
|
692
|
+
let { uid: n } = c();
|
|
687
693
|
v(e, (e) => {
|
|
688
|
-
let
|
|
689
|
-
if (!
|
|
690
|
-
let
|
|
691
|
-
|
|
692
|
-
size: n || 1,
|
|
693
|
-
offset: {
|
|
694
|
-
x: 0,
|
|
695
|
-
y: 0
|
|
696
|
-
},
|
|
697
|
-
...e.grid
|
|
698
|
-
};
|
|
699
|
-
return fe({
|
|
694
|
+
let r = N(n, e.id);
|
|
695
|
+
if (!r) return;
|
|
696
|
+
let i = he(t, e.grid);
|
|
697
|
+
if (i) return pe({
|
|
700
698
|
x: e.x,
|
|
701
699
|
y: e.y,
|
|
702
|
-
width:
|
|
703
|
-
height:
|
|
704
|
-
},
|
|
700
|
+
width: r.clientWidth,
|
|
701
|
+
height: r.clientHeight
|
|
702
|
+
}, i);
|
|
705
703
|
}, !0);
|
|
706
704
|
}, [c, v]), w = e.useCallback((e, n) => {
|
|
707
|
-
let r =
|
|
705
|
+
let r = fe(l(), u(), e);
|
|
708
706
|
S(r), v(r, { moving: !1 }, !0), C(r, n), t(e), i();
|
|
709
707
|
}, [
|
|
710
708
|
v,
|
|
@@ -786,8 +784,8 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
786
784
|
if (!i && A(a, "locked") && !A(e, "passthrough")) return r ? a : null;
|
|
787
785
|
if (A(e, "passthrough")) {
|
|
788
786
|
let e = u(), { uid: r } = c(), o = e.reduce((e, i) => {
|
|
789
|
-
let a =
|
|
790
|
-
return
|
|
787
|
+
let a = N(r, i), o = a.getBoundingClientRect();
|
|
788
|
+
return se({
|
|
791
789
|
x: t,
|
|
792
790
|
y: n
|
|
793
791
|
}, o) && e.unshift(a), e;
|
|
@@ -803,7 +801,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
803
801
|
}, [c, u]),
|
|
804
802
|
getItems: ne
|
|
805
803
|
};
|
|
806
|
-
},
|
|
804
|
+
}, Re = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
807
805
|
t.exports = function e(t, n) {
|
|
808
806
|
if (t === n) return !0;
|
|
809
807
|
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
@@ -843,17 +841,17 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
843
841
|
}
|
|
844
842
|
return t !== t && n !== n;
|
|
845
843
|
};
|
|
846
|
-
})))(), 1),
|
|
844
|
+
})))(), 1), ze = (e, t) => {
|
|
847
845
|
if (e.type in t) {
|
|
848
846
|
let n = t[e.type].defaultActions;
|
|
849
847
|
return typeof n == "function" ? n(e) : n;
|
|
850
848
|
}
|
|
851
849
|
return [];
|
|
852
|
-
},
|
|
853
|
-
let { actions: n =
|
|
850
|
+
}, Be = (e, t) => {
|
|
851
|
+
let { actions: n = ze(e, t) } = e;
|
|
854
852
|
return n.map((e) => typeof e == "string" ? { name: e } : e);
|
|
855
|
-
},
|
|
856
|
-
let [t, r] =
|
|
853
|
+
}, Ve = () => {
|
|
854
|
+
let [t, r] = I((e) => [e.items, e.getItems]), [i, a, o] = L((e) => [
|
|
857
855
|
e.config.itemTemplates,
|
|
858
856
|
e.selection,
|
|
859
857
|
e.getSelection
|
|
@@ -871,9 +869,9 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
871
869
|
if (e.length > 0) {
|
|
872
870
|
if (!l.current) return;
|
|
873
871
|
let e = t.reduce((e, t) => {
|
|
874
|
-
let n =
|
|
875
|
-
return e.filter((e) => n.some((t) => (0,
|
|
876
|
-
},
|
|
872
|
+
let n = Be(t, i);
|
|
873
|
+
return e.filter((e) => n.some((t) => (0, Re.default)(e, t)));
|
|
874
|
+
}, Be(t[0], i));
|
|
877
875
|
u(() => {
|
|
878
876
|
c(e);
|
|
879
877
|
});
|
|
@@ -886,28 +884,28 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
886
884
|
a,
|
|
887
885
|
p
|
|
888
886
|
], 100), { availableActions: s };
|
|
889
|
-
},
|
|
890
|
-
let [e] =
|
|
887
|
+
}, He = () => {
|
|
888
|
+
let [e] = L((e) => [e.selectionBox]);
|
|
891
889
|
return e;
|
|
892
|
-
},
|
|
890
|
+
}, Ue = e.createContext(), H = (e) => {
|
|
893
891
|
localStorage.setItem("user", JSON.stringify(e));
|
|
894
|
-
},
|
|
892
|
+
}, We = () => {
|
|
895
893
|
if (localStorage.user) {
|
|
896
894
|
let e = {
|
|
897
895
|
name: "Player",
|
|
898
|
-
color:
|
|
896
|
+
color: _e(),
|
|
899
897
|
uid: w(),
|
|
900
898
|
...JSON.parse(localStorage.user)
|
|
901
899
|
};
|
|
902
|
-
return
|
|
900
|
+
return H(e), e;
|
|
903
901
|
}
|
|
904
902
|
let e = {
|
|
905
903
|
name: "Player",
|
|
906
|
-
color:
|
|
904
|
+
color: _e(),
|
|
907
905
|
uid: w()
|
|
908
906
|
};
|
|
909
|
-
return
|
|
910
|
-
},
|
|
907
|
+
return H(e), e;
|
|
908
|
+
}, Ge = (e) => (t, n) => ({
|
|
911
909
|
isSpaceMaster: !1,
|
|
912
910
|
users: {},
|
|
913
911
|
getUser: () => n().users[e],
|
|
@@ -930,7 +928,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
930
928
|
id: r,
|
|
931
929
|
uid: t.users[r].uid
|
|
932
930
|
};
|
|
933
|
-
return a.id === e &&
|
|
931
|
+
return a.id === e && H(a), setTimeout(() => n().electSpaceMaster(), 100), { users: {
|
|
934
932
|
...t.users,
|
|
935
933
|
[r]: a
|
|
936
934
|
} };
|
|
@@ -953,7 +951,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
953
951
|
e < i.timestamp && (i.id = t, i.timestamp = e);
|
|
954
952
|
}), t({ isSpaceMaster: i.id === e });
|
|
955
953
|
}
|
|
956
|
-
}),
|
|
954
|
+
}), Ke = (e) => ({
|
|
957
955
|
cursors: {},
|
|
958
956
|
moveCursor: (t, n) => e((e) => ({ cursors: {
|
|
959
957
|
...e.cursors,
|
|
@@ -963,12 +961,12 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
963
961
|
let n = { ...e.cursors };
|
|
964
962
|
return delete n[t], { cursors: n };
|
|
965
963
|
})
|
|
966
|
-
}),
|
|
964
|
+
}), qe = ({ storeName: t, children: n }) => {
|
|
967
965
|
let { wire: r, isMaster: i } = k("room"), [o, c] = e.useState(null), [l, u] = e.useState(!1), d = e.useRef(!1);
|
|
968
966
|
return e.useEffect(() => {
|
|
969
967
|
let e = !0, n = [];
|
|
970
968
|
if (!o && !d.current) return d.current = !0, (() => {
|
|
971
|
-
let n = s(
|
|
969
|
+
let n = s(F({
|
|
972
970
|
wire: r,
|
|
973
971
|
storeName: t,
|
|
974
972
|
noSync: [
|
|
@@ -978,8 +976,8 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
978
976
|
"electSpaceMaster"
|
|
979
977
|
]
|
|
980
978
|
}, (...e) => ({
|
|
981
|
-
...
|
|
982
|
-
...
|
|
979
|
+
...Ge(r.userId)(...e),
|
|
980
|
+
...Ke(...e)
|
|
983
981
|
}), r, t)), i = n.subscribe((t) => {
|
|
984
982
|
t.ready && (i(), e && c(n));
|
|
985
983
|
});
|
|
@@ -993,7 +991,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
993
991
|
r.userId
|
|
994
992
|
]), e.useEffect(() => {
|
|
995
993
|
if (o) return o.getState().addUser({
|
|
996
|
-
...
|
|
994
|
+
...We(),
|
|
997
995
|
id: r.userId
|
|
998
996
|
}), u(!0), () => {
|
|
999
997
|
o.getState().removeUser(r.userId);
|
|
@@ -1021,14 +1019,14 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1021
1019
|
i,
|
|
1022
1020
|
o,
|
|
1023
1021
|
r
|
|
1024
|
-
]), l ? /* @__PURE__ */ a(
|
|
1022
|
+
]), l ? /* @__PURE__ */ a(Ue.Provider, {
|
|
1025
1023
|
value: o,
|
|
1026
1024
|
children: n
|
|
1027
1025
|
}) : null;
|
|
1028
1026
|
}, U = (e) => {
|
|
1029
|
-
let t = r(
|
|
1027
|
+
let t = r(Ue);
|
|
1030
1028
|
return c(t, e, l);
|
|
1031
|
-
},
|
|
1029
|
+
}, Je = () => {
|
|
1032
1030
|
let [t, n, r, i, a] = U((e) => [
|
|
1033
1031
|
e.isSpaceMaster,
|
|
1034
1032
|
e.getUser(),
|
|
@@ -1047,8 +1045,8 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1047
1045
|
}, [n, o]),
|
|
1048
1046
|
joinSpace: a
|
|
1049
1047
|
};
|
|
1050
|
-
},
|
|
1051
|
-
let [t, n, r] =
|
|
1048
|
+
}, Ye = () => {
|
|
1049
|
+
let [t, n, r] = I((e) => [
|
|
1052
1050
|
e.boardConfig,
|
|
1053
1051
|
e.getBoardConfig,
|
|
1054
1052
|
e.setBoardConfig
|
|
@@ -1059,11 +1057,11 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1059
1057
|
let i = n(), a = t(i);
|
|
1060
1058
|
r(a);
|
|
1061
1059
|
}, [n, r])];
|
|
1062
|
-
},
|
|
1063
|
-
let [e] =
|
|
1060
|
+
}, Xe = () => {
|
|
1061
|
+
let [e] = L((e) => [e.boardState]);
|
|
1064
1062
|
return e;
|
|
1065
|
-
},
|
|
1066
|
-
let [e, t, n, r] =
|
|
1063
|
+
}, Ze = () => {
|
|
1064
|
+
let [e, t, n, r] = I((e) => [
|
|
1067
1065
|
e.getSessionInfo,
|
|
1068
1066
|
e.setSessionInfo,
|
|
1069
1067
|
e.updateSessionInfo,
|
|
@@ -1075,7 +1073,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1075
1073
|
sessionInfo: r,
|
|
1076
1074
|
updateSessionInfo: n
|
|
1077
1075
|
};
|
|
1078
|
-
},
|
|
1076
|
+
}, Qe = e.createContext(), $e = ({ user: { name: e, uid: t, color: n }, content: r }) => ({
|
|
1079
1077
|
type: "message",
|
|
1080
1078
|
user: {
|
|
1081
1079
|
name: e,
|
|
@@ -1085,7 +1083,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1085
1083
|
content: r,
|
|
1086
1084
|
uid: w(),
|
|
1087
1085
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1088
|
-
}),
|
|
1086
|
+
}), et = (e, t) => ({
|
|
1089
1087
|
messages: [],
|
|
1090
1088
|
setMessages: (t) => e({ messages: t.map((e) => ({
|
|
1091
1089
|
...e,
|
|
@@ -1096,28 +1094,28 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1096
1094
|
timestamp: Date.parse(t.timestamp)
|
|
1097
1095
|
}] })),
|
|
1098
1096
|
sendMessage: (e, n) => {
|
|
1099
|
-
let r =
|
|
1097
|
+
let r = $e({
|
|
1100
1098
|
user: e,
|
|
1101
1099
|
content: n
|
|
1102
1100
|
});
|
|
1103
1101
|
r && t().addMessage(r);
|
|
1104
1102
|
}
|
|
1105
|
-
}),
|
|
1106
|
-
let { wire: i } = k("room"), [o] = e.useState(() => s(
|
|
1103
|
+
}), tt = ({ storeName: t, children: n, defaultValue: r = [] }) => {
|
|
1104
|
+
let { wire: i } = k("room"), [o] = e.useState(() => s(F({
|
|
1107
1105
|
wire: i,
|
|
1108
1106
|
storeName: t,
|
|
1109
1107
|
defaultValue: r,
|
|
1110
1108
|
noSync: ["sendMessage"]
|
|
1111
|
-
}, (...e) => ({ ...
|
|
1112
|
-
return /* @__PURE__ */ a(
|
|
1109
|
+
}, (...e) => ({ ...et(...e) }))));
|
|
1110
|
+
return /* @__PURE__ */ a(Qe.Provider, {
|
|
1113
1111
|
value: o,
|
|
1114
1112
|
children: n
|
|
1115
1113
|
});
|
|
1116
|
-
},
|
|
1117
|
-
let t = r(
|
|
1114
|
+
}, nt = (e) => {
|
|
1115
|
+
let t = r(Qe);
|
|
1118
1116
|
return c(t, e, l);
|
|
1119
|
-
},
|
|
1120
|
-
let n = U((e) => e.getUser()), [r, i, a] =
|
|
1117
|
+
}, rt = () => {}, it = (t = rt) => {
|
|
1118
|
+
let n = U((e) => e.getUser()), [r, i, a] = nt((e) => [
|
|
1121
1119
|
e.messages,
|
|
1122
1120
|
e.setMessages,
|
|
1123
1121
|
e.sendMessage
|
|
@@ -1131,23 +1129,23 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1131
1129
|
a(n, e);
|
|
1132
1130
|
}, [n, a])
|
|
1133
1131
|
};
|
|
1134
|
-
},
|
|
1132
|
+
}, at = ({ children: t, session: n }) => {
|
|
1135
1133
|
let r = U((e) => e.joinSpace);
|
|
1136
1134
|
return e.useEffect(() => (r(n), () => {
|
|
1137
1135
|
r(null);
|
|
1138
1136
|
}), [r, n]), t;
|
|
1139
|
-
},
|
|
1137
|
+
}, ot = ({ socket: t, room: n, session: r, items: i = [], messages: o = [], LoadingComponent: s, ...c }) => {
|
|
1140
1138
|
let [l] = e.useState(n || w()), [u] = e.useState(r || w()), [d] = e.useState(() => ({
|
|
1141
1139
|
itemIds: i.map(({ id: e }) => e),
|
|
1142
1140
|
items: Object.fromEntries(i.map((e) => [e.id, e]))
|
|
1143
1141
|
}));
|
|
1144
|
-
return k("room") ? /* @__PURE__ */ a(
|
|
1142
|
+
return k("room") ? /* @__PURE__ */ a(tt, {
|
|
1145
1143
|
storeName: `${u}_messages`,
|
|
1146
1144
|
defaultValue: o,
|
|
1147
|
-
children: /* @__PURE__ */ a(
|
|
1145
|
+
children: /* @__PURE__ */ a(Ne, { children: /* @__PURE__ */ a(we, {
|
|
1148
1146
|
storeName: `${u}_item`,
|
|
1149
1147
|
defaultValue: d,
|
|
1150
|
-
children: /* @__PURE__ */ a(
|
|
1148
|
+
children: /* @__PURE__ */ a(at, {
|
|
1151
1149
|
...c,
|
|
1152
1150
|
session: u
|
|
1153
1151
|
})
|
|
@@ -1157,15 +1155,15 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1157
1155
|
channel: "room",
|
|
1158
1156
|
socket: t,
|
|
1159
1157
|
LoadingComponent: s,
|
|
1160
|
-
children: /* @__PURE__ */ a(
|
|
1158
|
+
children: /* @__PURE__ */ a(qe, {
|
|
1161
1159
|
storeName: `${l}_users`,
|
|
1162
|
-
children: /* @__PURE__ */ a(
|
|
1160
|
+
children: /* @__PURE__ */ a(tt, {
|
|
1163
1161
|
storeName: `${u}_messages`,
|
|
1164
1162
|
defaultValue: o,
|
|
1165
|
-
children: /* @__PURE__ */ a(
|
|
1163
|
+
children: /* @__PURE__ */ a(Ne, { children: /* @__PURE__ */ a(we, {
|
|
1166
1164
|
storeName: `${u}_item`,
|
|
1167
1165
|
defaultValue: d,
|
|
1168
|
-
children: /* @__PURE__ */ a(
|
|
1166
|
+
children: /* @__PURE__ */ a(at, {
|
|
1169
1167
|
...c,
|
|
1170
1168
|
session: u
|
|
1171
1169
|
})
|
|
@@ -1173,19 +1171,19 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1173
1171
|
})
|
|
1174
1172
|
})
|
|
1175
1173
|
});
|
|
1176
|
-
},
|
|
1174
|
+
}, st = ({ socket: t, room: n, children: r, LoadingComponent: i }) => {
|
|
1177
1175
|
let [o] = e.useState(n || w());
|
|
1178
1176
|
return /* @__PURE__ */ a(re, {
|
|
1179
1177
|
room: o,
|
|
1180
1178
|
channel: "room",
|
|
1181
1179
|
socket: t,
|
|
1182
1180
|
LoadingComponent: i,
|
|
1183
|
-
children: /* @__PURE__ */ a(
|
|
1181
|
+
children: /* @__PURE__ */ a(qe, {
|
|
1184
1182
|
storeName: `${o}_users`,
|
|
1185
1183
|
children: r
|
|
1186
1184
|
})
|
|
1187
1185
|
});
|
|
1188
|
-
},
|
|
1186
|
+
}, ct = { data: "" }, lt = (e) => {
|
|
1189
1187
|
if (typeof window == "object") {
|
|
1190
1188
|
let t = (e ? e.querySelector("#_goober") : window._goober) || Object.assign(document.createElement("style"), {
|
|
1191
1189
|
innerHTML: " ",
|
|
@@ -1193,23 +1191,23 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1193
1191
|
});
|
|
1194
1192
|
return t.nonce = window.__nonce__, t.parentNode || (e || document.head).appendChild(t), t.firstChild;
|
|
1195
1193
|
}
|
|
1196
|
-
return e ||
|
|
1197
|
-
},
|
|
1194
|
+
return e || ct;
|
|
1195
|
+
}, ut = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, dt = /\/\*[^]*?\*\/| +/g, ft = /\n+/g, W = (e, t) => {
|
|
1198
1196
|
let n = "", r = "", i = "";
|
|
1199
1197
|
for (let a in e) {
|
|
1200
1198
|
let o = e[a];
|
|
1201
1199
|
a[0] == "@" ? a[1] == "i" ? n = a + " " + o + ";" : r += a[1] == "f" ? W(o, a) : a + "{" + W(o, a[1] == "k" ? "" : t) + "}" : typeof o == "object" ? r += W(o, t ? t.replace(/([^,])+/g, (e) => a.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g, (t) => /&/.test(t) ? t.replace(/&/g, e) : e ? e + " " + t : t)) : a) : o != null && (a = a[1] == "-" ? a : a.replace(/[A-Z]/g, "-$&").toLowerCase(), i += W.p ? W.p(a, o) : a + ":" + o + ";");
|
|
1202
1200
|
}
|
|
1203
1201
|
return n + (t && i ? t + "{" + i + "}" : i) + r;
|
|
1204
|
-
}, G = {},
|
|
1202
|
+
}, G = {}, pt = (e) => {
|
|
1205
1203
|
if (typeof e == "object") {
|
|
1206
1204
|
let t = "";
|
|
1207
|
-
for (let n in e) t += n +
|
|
1205
|
+
for (let n in e) t += n + pt(e[n]);
|
|
1208
1206
|
return t;
|
|
1209
1207
|
}
|
|
1210
1208
|
return e;
|
|
1211
|
-
},
|
|
1212
|
-
let a =
|
|
1209
|
+
}, mt = (e, t, n, r, i) => {
|
|
1210
|
+
let a = pt(e), o = G[a] || (G[a] = ((e) => {
|
|
1213
1211
|
let t = 0, n = 11;
|
|
1214
1212
|
for (; t < e.length;) n = 101 * n + e.charCodeAt(t++) >>> 0;
|
|
1215
1213
|
return "go" + n;
|
|
@@ -1217,7 +1215,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1217
1215
|
if (!G[o]) {
|
|
1218
1216
|
let t = a === e ? ((e) => {
|
|
1219
1217
|
let t, n, r = [{}];
|
|
1220
|
-
for (; t =
|
|
1218
|
+
for (; t = ut.exec(e.replace(dt, ""));) t[4] ? r.shift() : t[3] ? (n = t[3].replace(ft, " ").trim(), r.unshift(r[0][n] = r[0][n] || {})) : r[0][t[1]] = t[2].replace(ft, " ").trim();
|
|
1221
1219
|
return r[0];
|
|
1222
1220
|
})(e) : e;
|
|
1223
1221
|
G[o] = W(i ? { ["@keyframes " + o]: t } : t, n ? "" : "." + o);
|
|
@@ -1226,7 +1224,7 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1226
1224
|
return n && (G.g = G[o]), ((e, t, n, r) => {
|
|
1227
1225
|
r ? t.data = t.data.replace(r, e) : t.data.indexOf(e) === -1 && (t.data = n ? e + t.data : t.data + e);
|
|
1228
1226
|
})(G[o], t, r, s), o;
|
|
1229
|
-
},
|
|
1227
|
+
}, ht = (e, t, n) => e.reduce((e, r, i) => {
|
|
1230
1228
|
let a = t[i];
|
|
1231
1229
|
if (a && a.call) {
|
|
1232
1230
|
let e = a(n), t = e && e.props && e.props.className || /^go/.test(e) && e;
|
|
@@ -1236,15 +1234,15 @@ var m = Object.create, h = Object.defineProperty, g = Object.getOwnPropertyDescr
|
|
|
1236
1234
|
}, "");
|
|
1237
1235
|
function K(e) {
|
|
1238
1236
|
let t = this || {}, n = e.call ? e(t.p) : e;
|
|
1239
|
-
return
|
|
1237
|
+
return mt(n.unshift ? n.raw ? ht(n, [].slice.call(arguments, 1), t.p) : n.reduce((e, n) => Object.assign(e, n && n.call ? n(t.p) : n), {}) : n, lt(t.target), t.g, t.o, t.k);
|
|
1240
1238
|
}
|
|
1241
1239
|
K.bind({ g: 1 }), K.bind({ k: 1 });
|
|
1242
|
-
function
|
|
1240
|
+
function gt(e, t, n, r) {
|
|
1243
1241
|
W.p = t;
|
|
1244
1242
|
}
|
|
1245
1243
|
//#endregion
|
|
1246
1244
|
//#region src/lib/board/Gesture.jsx
|
|
1247
|
-
var
|
|
1245
|
+
var _t = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
1248
1246
|
t.exports = function e(t, n) {
|
|
1249
1247
|
if (t === n) return !0;
|
|
1250
1248
|
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
@@ -1268,23 +1266,23 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1268
1266
|
}
|
|
1269
1267
|
return t !== t && n !== n;
|
|
1270
1268
|
};
|
|
1271
|
-
})))(), 1),
|
|
1269
|
+
})))(), 1), vt = () => {
|
|
1272
1270
|
let e = navigator.userAgent.toLowerCase();
|
|
1273
1271
|
return /mac os ?x 10/.test(e);
|
|
1274
|
-
},
|
|
1272
|
+
}, yt = (() => {
|
|
1275
1273
|
let e = document.createElement("iframe");
|
|
1276
1274
|
e.src = "#", document.body.appendChild(e);
|
|
1277
1275
|
let t = e.contentWindow.document;
|
|
1278
1276
|
t.open(), t.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>"), t.close();
|
|
1279
1277
|
let n = t.body.firstElementChild.offsetHeight;
|
|
1280
1278
|
return document.body.removeChild(e), n;
|
|
1281
|
-
})(),
|
|
1279
|
+
})(), bt = 800, xt = (e, t) => e[Object.keys(e).map((e) => Number(e)).find((e) => e !== t)], St = ([e, t], [n, r]) => {
|
|
1282
1280
|
let i = Math.abs(e - n), a = Math.abs(t - r);
|
|
1283
1281
|
return Math.hypot(i, a);
|
|
1284
|
-
}, q = () => {},
|
|
1282
|
+
}, q = () => {}, Ct = (e) => (t) => {
|
|
1285
1283
|
let { event: n } = t;
|
|
1286
1284
|
return n.isPropagationStopped() ? null : e(t);
|
|
1287
|
-
},
|
|
1285
|
+
}, wt = (e) => async (...t) => {
|
|
1288
1286
|
try {
|
|
1289
1287
|
await e(...t);
|
|
1290
1288
|
} catch (e) {
|
|
@@ -1294,7 +1292,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1294
1292
|
lastPromise = Promise.resolve(!0);
|
|
1295
1293
|
add(e, ...t) {
|
|
1296
1294
|
return new Promise((n, r) => {
|
|
1297
|
-
this.lastPromise = this.lastPromise.then(() =>
|
|
1295
|
+
this.lastPromise = this.lastPromise.then(() => Ct(wt(e))(...t)).then(n).catch(r);
|
|
1298
1296
|
});
|
|
1299
1297
|
}
|
|
1300
1298
|
}(), Y = ({ children: t, onDrag: n = q, onDragStart: r = q, onDragEnd: i = q, onPan: o = q, onTap: s = q, onLongTap: c = q, onDoubleTap: l = q, onZoom: u, mainAction: d = "drag", fill: f = !1 }) => {
|
|
@@ -1304,8 +1302,8 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1304
1302
|
mainPointer: void 0
|
|
1305
1303
|
}), h = (e) => {
|
|
1306
1304
|
let { deltaX: t, deltaY: n, clientX: r, clientY: i, deltaMode: a, ctrlKey: s, altKey: c, metaKey: l, target: d } = e;
|
|
1307
|
-
if (!(c || s && !
|
|
1308
|
-
if (
|
|
1305
|
+
if (!(c || s && !vt())) {
|
|
1306
|
+
if (vt() && !s) J.add(o, {
|
|
1309
1307
|
deltaX: -2 * t,
|
|
1310
1308
|
deltaY: -2 * n,
|
|
1311
1309
|
button: 1,
|
|
@@ -1319,11 +1317,11 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1319
1317
|
let t = n;
|
|
1320
1318
|
switch (a) {
|
|
1321
1319
|
case 1:
|
|
1322
|
-
t *=
|
|
1320
|
+
t *= yt;
|
|
1323
1321
|
break;
|
|
1324
|
-
case 2: t *=
|
|
1322
|
+
case 2: t *= bt;
|
|
1325
1323
|
}
|
|
1326
|
-
|
|
1324
|
+
vt() && (t *= 2), J.add(u, {
|
|
1327
1325
|
scale: t,
|
|
1328
1326
|
clientX: r,
|
|
1329
1327
|
clientY: i,
|
|
@@ -1338,7 +1336,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1338
1336
|
clientY: i
|
|
1339
1337
|
}, u && (m.current.mainPointer = void 0), m.current.mainPointer !== void 0) {
|
|
1340
1338
|
if (m.current.mainPointer !== a) try {
|
|
1341
|
-
let { clientX: e, clientY: t } =
|
|
1339
|
+
let { clientX: e, clientY: t } = xt(m.current.pointers, a), n = (e + r) / 2, o = (t + i) / 2, s = St([e, t], [r, i]);
|
|
1342
1340
|
Object.assign(m.current, {
|
|
1343
1341
|
pressed: !0,
|
|
1344
1342
|
moving: !1,
|
|
@@ -1395,8 +1393,8 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1395
1393
|
}, m.current.moving = !0;
|
|
1396
1394
|
let g = Object.keys(m.current.pointers).length === 2, _, v, y = 0;
|
|
1397
1395
|
if (g) {
|
|
1398
|
-
let { clientX: e, clientY: n } =
|
|
1399
|
-
_ = (e + i) / 2, v = (n + a) / 2, y =
|
|
1396
|
+
let { clientX: e, clientY: n } = xt(m.current.pointers, t);
|
|
1397
|
+
_ = (e + i) / 2, v = (n + a) / 2, y = St([e, n], [i, a]);
|
|
1400
1398
|
} else _ = i, v = a;
|
|
1401
1399
|
let b = c || s || l || f || h !== 1;
|
|
1402
1400
|
d !== "drag" && (b = !b);
|
|
@@ -1552,8 +1550,8 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1552
1550
|
ref: p,
|
|
1553
1551
|
children: t
|
|
1554
1552
|
});
|
|
1555
|
-
},
|
|
1556
|
-
let [n] =
|
|
1553
|
+
}, Tt = ({ onResize: e, ...t }) => {
|
|
1554
|
+
let [n] = L((e) => [e.getBoardState]);
|
|
1557
1555
|
return /* @__PURE__ */ a(Y, {
|
|
1558
1556
|
onDrag: ({ deltaX: t, deltaY: r, event: i }) => {
|
|
1559
1557
|
i.stopPropagation();
|
|
@@ -1565,13 +1563,13 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1565
1563
|
},
|
|
1566
1564
|
children: /* @__PURE__ */ a("div", { ...t })
|
|
1567
1565
|
});
|
|
1568
|
-
},
|
|
1566
|
+
}, Et = K`
|
|
1569
1567
|
display: inline-block;
|
|
1570
1568
|
transition: transform 150ms;
|
|
1571
1569
|
user-select: none;
|
|
1572
1570
|
padding: 2px;
|
|
1573
1571
|
box-sizing: border-box;
|
|
1574
|
-
`,
|
|
1572
|
+
`, Dt = K`
|
|
1575
1573
|
border: 2px dashed #db5034;
|
|
1576
1574
|
padding: 0px;
|
|
1577
1575
|
cursor: pointer;
|
|
@@ -1579,22 +1577,22 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1579
1577
|
position: absolute;
|
|
1580
1578
|
width: 0px;
|
|
1581
1579
|
height: 0px;
|
|
1582
|
-
`,
|
|
1580
|
+
`, Ot = K`
|
|
1583
1581
|
top: 0;
|
|
1584
1582
|
left: 0;
|
|
1585
|
-
`,
|
|
1583
|
+
`, kt = K`
|
|
1586
1584
|
top: 0;
|
|
1587
1585
|
right: 0;
|
|
1588
|
-
`,
|
|
1586
|
+
`, At = K`
|
|
1589
1587
|
bottom: 0;
|
|
1590
1588
|
left: 0;
|
|
1591
|
-
`,
|
|
1589
|
+
`, jt = K`
|
|
1592
1590
|
bottom: 0;
|
|
1593
1591
|
right: 0;
|
|
1594
|
-
`,
|
|
1592
|
+
`, Mt = K`
|
|
1595
1593
|
top: 50%;
|
|
1596
1594
|
left: 50%;
|
|
1597
|
-
`,
|
|
1595
|
+
`, Nt = K`
|
|
1598
1596
|
position: absolute;
|
|
1599
1597
|
|
|
1600
1598
|
width: 10px;
|
|
@@ -1602,19 +1600,19 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1602
1600
|
border: 2px solid #db5034;
|
|
1603
1601
|
background-color: #db5034;
|
|
1604
1602
|
cursor: move;
|
|
1605
|
-
`,
|
|
1603
|
+
`, Pt = K`
|
|
1606
1604
|
cursor: ew-resize;
|
|
1607
1605
|
right: -6px;
|
|
1608
1606
|
top: calc(50% - 5px);
|
|
1609
|
-
`,
|
|
1607
|
+
`, Ft = K`
|
|
1610
1608
|
cursor: ns-resize;
|
|
1611
1609
|
bottom: -6px;
|
|
1612
1610
|
left: calc(50% - 5px);
|
|
1613
|
-
`,
|
|
1611
|
+
`, It = K`
|
|
1614
1612
|
cursor: nwse-resize;
|
|
1615
1613
|
bottom: -6px;
|
|
1616
1614
|
right: -6px;
|
|
1617
|
-
`,
|
|
1615
|
+
`, Lt = ({ onReload: e }) => /* @__PURE__ */ o("div", {
|
|
1618
1616
|
className: `syncboard-error-item ${K({
|
|
1619
1617
|
width: "100px",
|
|
1620
1618
|
display: "flex",
|
|
@@ -1627,7 +1625,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1627
1625
|
onClick: e,
|
|
1628
1626
|
children: "Reload it"
|
|
1629
1627
|
})]
|
|
1630
|
-
}),
|
|
1628
|
+
}), Rt = class extends e.Component {
|
|
1631
1629
|
constructor(e) {
|
|
1632
1630
|
super(e), this.state = {
|
|
1633
1631
|
hasError: !1,
|
|
@@ -1647,9 +1645,9 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1647
1645
|
let { ErrorComponent: e } = this.props;
|
|
1648
1646
|
return this.state.hasError ? /* @__PURE__ */ a(e, { onReload: this.onReload }) : this.props.children;
|
|
1649
1647
|
}
|
|
1650
|
-
},
|
|
1648
|
+
}, zt = (e) => {
|
|
1651
1649
|
e.target.className = "";
|
|
1652
|
-
},
|
|
1650
|
+
}, Bt = ({ width: e, height: t, actualWidth: n, actualHeight: r, prevState: i, keepRatio: a }) => {
|
|
1653
1651
|
let { width: o, height: s } = i;
|
|
1654
1652
|
if ([o, s] = [parseFloat(o), parseFloat(s)], (!o || Number.isNaN(Number(o))) && (o = n), (!s || Number.isNaN(Number(s))) && (s = r), a) {
|
|
1655
1653
|
let n = o / s;
|
|
@@ -1664,21 +1662,21 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1664
1662
|
width: (o + e).toFixed(1),
|
|
1665
1663
|
height: (s + t).toFixed(1)
|
|
1666
1664
|
};
|
|
1667
|
-
},
|
|
1665
|
+
}, Vt = {
|
|
1668
1666
|
w: !0,
|
|
1669
1667
|
h: !0,
|
|
1670
1668
|
b: !0
|
|
1671
|
-
},
|
|
1672
|
-
let h = e.useRef(null), [g] =
|
|
1669
|
+
}, Ht = t(({ setState: t, state: { type: n, rotation: r = 0, id: s, locked: c, extraClasses: l, ...u } = {}, animate: d = "hvr-pop", isSelected: f, itemMap: p, showResizeHandle: m = !0 }) => {
|
|
1670
|
+
let h = e.useRef(null), [g] = L((e) => [e.config.uid]), { component: _ = () => null, resizeDirections: v = Vt, resize: y = Bt } = p[n], b = e.useCallback((e, n = !1) => t(s, e, n), [t, s]);
|
|
1673
1671
|
e.useEffect(() => {
|
|
1674
1672
|
h.current.className = d;
|
|
1675
1673
|
}, [d]);
|
|
1676
1674
|
let x = [
|
|
1677
1675
|
"item",
|
|
1678
1676
|
s,
|
|
1679
|
-
|
|
1677
|
+
Et
|
|
1680
1678
|
];
|
|
1681
|
-
c && x.push("locked"), f && (x.push("selected"), x.push(
|
|
1679
|
+
c && x.push("locked"), f && (x.push("selected"), x.push(Dt)), Array.isArray(l) && x.concat(l);
|
|
1682
1680
|
let S = x.join(" "), C = ({ width: e = 0, height: t = 0, keepRatio: n }) => {
|
|
1683
1681
|
b((r) => {
|
|
1684
1682
|
let { offsetWidth: i, offsetHeight: a } = h.current;
|
|
@@ -1710,59 +1708,59 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1710
1708
|
children: /* @__PURE__ */ o("div", {
|
|
1711
1709
|
style: { display: "flex" },
|
|
1712
1710
|
ref: h,
|
|
1713
|
-
onAnimationEnd:
|
|
1711
|
+
onAnimationEnd: zt,
|
|
1714
1712
|
onKeyDown: (e) => e.stopPropagation(),
|
|
1715
1713
|
onKeyUp: (e) => e.stopPropagation(),
|
|
1716
1714
|
children: [
|
|
1717
|
-
/* @__PURE__ */ a(
|
|
1715
|
+
/* @__PURE__ */ a(Rt, {
|
|
1718
1716
|
itemId: s,
|
|
1719
1717
|
state: u,
|
|
1720
|
-
ErrorComponent: p?.error?.component ||
|
|
1718
|
+
ErrorComponent: p?.error?.component || Lt,
|
|
1721
1719
|
children: /* @__PURE__ */ a(_, {
|
|
1722
1720
|
...u,
|
|
1723
1721
|
id: s,
|
|
1724
1722
|
setState: b
|
|
1725
1723
|
})
|
|
1726
1724
|
}),
|
|
1727
|
-
/* @__PURE__ */ a("div", { className: `corner ${X} ${Et}` }),
|
|
1728
|
-
/* @__PURE__ */ a("div", { className: `corner ${X} ${Dt}` }),
|
|
1729
|
-
/* @__PURE__ */ a("div", { className: `corner ${X} ${kt}` }),
|
|
1730
1725
|
/* @__PURE__ */ a("div", { className: `corner ${X} ${Ot}` }),
|
|
1731
|
-
/* @__PURE__ */ a("div", { className: `
|
|
1726
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${kt}` }),
|
|
1727
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${jt}` }),
|
|
1728
|
+
/* @__PURE__ */ a("div", { className: `corner ${X} ${At}` }),
|
|
1729
|
+
/* @__PURE__ */ a("div", { className: `center ${X} ${Mt}` }),
|
|
1732
1730
|
m && /* @__PURE__ */ o(i, { children: [
|
|
1733
|
-
v.b && /* @__PURE__ */ a(
|
|
1734
|
-
className: `${
|
|
1731
|
+
v.b && /* @__PURE__ */ a(Tt, {
|
|
1732
|
+
className: `${Nt} ${It}`,
|
|
1735
1733
|
onResize: T
|
|
1736
1734
|
}),
|
|
1737
|
-
v.h && /* @__PURE__ */ a(
|
|
1738
|
-
className: `${
|
|
1735
|
+
v.h && /* @__PURE__ */ a(Tt, {
|
|
1736
|
+
className: `${Nt} ${Ft}`,
|
|
1739
1737
|
onResize: ee
|
|
1740
1738
|
}),
|
|
1741
|
-
v.w && /* @__PURE__ */ a(
|
|
1742
|
-
className: `${
|
|
1739
|
+
v.w && /* @__PURE__ */ a(Tt, {
|
|
1740
|
+
className: `${Nt} ${Pt}`,
|
|
1743
1741
|
onResize: w
|
|
1744
1742
|
})
|
|
1745
1743
|
] })
|
|
1746
1744
|
]
|
|
1747
1745
|
})
|
|
1748
1746
|
});
|
|
1749
|
-
}, ({ state: e, setState: t, isSelected: n, showResizeHandle: r }, { state: i, setState: a, isSelected: o, showResizeHandle: s }) => n === o && r === s && t === a && (0,
|
|
1747
|
+
}, ({ state: e, setState: t, isSelected: n, showResizeHandle: r }, { state: i, setState: a, isSelected: o, showResizeHandle: s }) => n === o && r === s && t === a && (0, _t.default)(e, i)), Ut = (e) => e, Wt = t(({ state: e = {}, getCurrentUser: t, className: n, ...r }) => {
|
|
1750
1748
|
if (!r.itemMap[e.type]) return null;
|
|
1751
|
-
let { stateHook: i =
|
|
1749
|
+
let { stateHook: i = Ut } = r.itemMap[e.type], { x: o = 0, y: s = 0, layer: c = 0, moving: l, ...u } = i(e, { currentUser: t?.() }), d = (c + 4) * 10 + 100 + (l ? 5 : 0);
|
|
1752
1750
|
return /* @__PURE__ */ a("div", {
|
|
1753
1751
|
className: n,
|
|
1754
1752
|
style: {
|
|
1755
1753
|
transform: `translate(${o}px, ${s}px)`,
|
|
1756
1754
|
zIndex: d
|
|
1757
1755
|
},
|
|
1758
|
-
children: /* @__PURE__ */ a(
|
|
1756
|
+
children: /* @__PURE__ */ a(Ht, {
|
|
1759
1757
|
...r,
|
|
1760
1758
|
showResizeHandle: r.isSelected && r.showResizeHandle,
|
|
1761
1759
|
state: u
|
|
1762
1760
|
})
|
|
1763
1761
|
});
|
|
1764
|
-
}),
|
|
1765
|
-
let { updateItem: e } =
|
|
1762
|
+
}), Gt = () => {
|
|
1763
|
+
let { updateItem: e } = V(), [t, n] = I((e) => [e.itemIds, e.items]), [r, i, o] = L((e) => [
|
|
1766
1764
|
e.config.showResizeHandle,
|
|
1767
1765
|
e.config.itemTemplates,
|
|
1768
1766
|
e.selection
|
|
@@ -1774,7 +1772,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1774
1772
|
display: "inline-block",
|
|
1775
1773
|
lineHeight: 0
|
|
1776
1774
|
});
|
|
1777
|
-
return t.map((t) => /* @__PURE__ */ a(
|
|
1775
|
+
return t.map((t) => /* @__PURE__ */ a(Wt, {
|
|
1778
1776
|
state: n[t],
|
|
1779
1777
|
setState: e,
|
|
1780
1778
|
isSelected: o.includes(t),
|
|
@@ -1783,28 +1781,28 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1783
1781
|
showResizeHandle: r,
|
|
1784
1782
|
className: c
|
|
1785
1783
|
}, t));
|
|
1786
|
-
},
|
|
1784
|
+
}, Kt = K({
|
|
1787
1785
|
zIndex: 210,
|
|
1788
1786
|
position: "absolute",
|
|
1789
1787
|
backgroundColor: "hsla(0, 40%, 50%, 10%)",
|
|
1790
1788
|
border: "2px solid hsl(0, 55%, 40%)"
|
|
1791
|
-
}),
|
|
1789
|
+
}), qt = (e, t, n = !1) => {
|
|
1792
1790
|
let r = t.getElementsByClassName("selector");
|
|
1793
1791
|
if (!r.length) return [];
|
|
1794
1792
|
let i = r[0];
|
|
1795
1793
|
return Array.from(t.getElementsByClassName("item")).filter((t) => {
|
|
1796
|
-
let r = e[
|
|
1797
|
-
return !r || !n && r.locked ? !1 :
|
|
1798
|
-
}).map((e) =>
|
|
1799
|
-
},
|
|
1800
|
-
let [r, i, s, c, l, u] =
|
|
1794
|
+
let r = e[P(t)];
|
|
1795
|
+
return !r || !n && r.locked ? !1 : le(t, i);
|
|
1796
|
+
}).map((e) => P(e));
|
|
1797
|
+
}, Jt = ({ children: t, moveFirst: n }) => {
|
|
1798
|
+
let [r, i, s, c, l, u] = L((e) => [
|
|
1801
1799
|
e.getSelection,
|
|
1802
1800
|
e.clear,
|
|
1803
1801
|
e.setSelection,
|
|
1804
1802
|
e.select,
|
|
1805
1803
|
e.getConfiguration,
|
|
1806
1804
|
e.updateBoardState
|
|
1807
|
-
]), { findElementUnderPointer: d } =
|
|
1805
|
+
]), { findElementUnderPointer: d } = V(), [p] = I((e) => [e.getItems]), [m, h] = e.useState({}), [, g] = e.useTransition(), [_, v] = e.useState(!1), y = e.useRef(null), b = e.useRef({ moving: !1 });
|
|
1808
1806
|
return f(document, "keydown", (e) => {
|
|
1809
1807
|
e.key === "l" && v(!0);
|
|
1810
1808
|
}), f(document, "keyup", (e) => {
|
|
@@ -1813,7 +1811,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1813
1811
|
i();
|
|
1814
1812
|
}), [i]), e.useEffect(() => {
|
|
1815
1813
|
if (b.current.moving) {
|
|
1816
|
-
let e = p(), { boardWrapper: t } = l(), n =
|
|
1814
|
+
let e = p(), { boardWrapper: t } = l(), n = qt(e, t, _);
|
|
1817
1815
|
g(() => {
|
|
1818
1816
|
s(n);
|
|
1819
1817
|
});
|
|
@@ -1849,7 +1847,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1849
1847
|
let { ctrlKey: t, metaKey: n } = e, a = d(e);
|
|
1850
1848
|
if (!a) i();
|
|
1851
1849
|
else {
|
|
1852
|
-
let e =
|
|
1850
|
+
let e = P(a);
|
|
1853
1851
|
if (!e) {
|
|
1854
1852
|
i();
|
|
1855
1853
|
return;
|
|
@@ -1861,7 +1859,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1861
1859
|
onLongTap: ({ target: e }) => {
|
|
1862
1860
|
let t = j(e, "item");
|
|
1863
1861
|
if (t) {
|
|
1864
|
-
let e =
|
|
1862
|
+
let e = P(t);
|
|
1865
1863
|
s([e]);
|
|
1866
1864
|
}
|
|
1867
1865
|
},
|
|
@@ -1878,45 +1876,55 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1878
1876
|
height: `${m.height}px`,
|
|
1879
1877
|
width: `${m.width}px`
|
|
1880
1878
|
},
|
|
1881
|
-
className: `selector ${
|
|
1879
|
+
className: `selector ${Kt}`
|
|
1882
1880
|
}), t]
|
|
1883
1881
|
})
|
|
1884
1882
|
});
|
|
1885
|
-
},
|
|
1886
|
-
let { moveItems: n, placeItems: r, findElementUnderPointer: i } =
|
|
1883
|
+
}, Yt = ({ children: t }) => {
|
|
1884
|
+
let { moveItems: n, placeItems: r, findElementUnderPointer: i } = V(), { vectorFromWrapperToBoard: o } = z(), [s, c, l, u, d] = L((e) => [
|
|
1887
1885
|
e.select,
|
|
1888
1886
|
e.setSelection,
|
|
1889
1887
|
e.getSelection,
|
|
1890
1888
|
e.getBoardState,
|
|
1891
1889
|
e.updateBoardState
|
|
1892
|
-
]), [p] =
|
|
1890
|
+
]), [p] = I((e) => [e.getBoardConfig]), m = () => {
|
|
1891
|
+
let { grid: e, gridType: t, gridSize: n = 1 } = p(), r = e || {
|
|
1892
|
+
type: t === void 0 ? n ? "grid" : "none" : t,
|
|
1893
|
+
size: n
|
|
1894
|
+
};
|
|
1895
|
+
return {
|
|
1896
|
+
type: r.type || "none",
|
|
1897
|
+
size: Number(r.size) || 1,
|
|
1898
|
+
offset: {
|
|
1899
|
+
x: Number(r.offset?.x) || 0,
|
|
1900
|
+
y: Number(r.offset?.y) || 0
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
}, h = e.useRef({}), g = e.useRef({ items: [] });
|
|
1893
1904
|
return f(document, "keydown", (e) => {
|
|
1894
1905
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return;
|
|
1895
1906
|
let t = l();
|
|
1896
1907
|
if (t.length) {
|
|
1897
|
-
let
|
|
1908
|
+
let i = 0, a = 0;
|
|
1898
1909
|
switch (e.key) {
|
|
1899
1910
|
case "ArrowLeft":
|
|
1900
|
-
|
|
1911
|
+
i = -10;
|
|
1901
1912
|
break;
|
|
1902
1913
|
case "ArrowRight":
|
|
1903
|
-
|
|
1914
|
+
i = 10;
|
|
1904
1915
|
break;
|
|
1905
1916
|
case "ArrowUp":
|
|
1906
|
-
|
|
1917
|
+
a = -10;
|
|
1907
1918
|
break;
|
|
1908
|
-
case "ArrowDown":
|
|
1919
|
+
case "ArrowDown": a = 10;
|
|
1909
1920
|
}
|
|
1910
|
-
if (
|
|
1911
|
-
e.shiftKey && (
|
|
1912
|
-
let [
|
|
1921
|
+
if (i || a) {
|
|
1922
|
+
e.shiftKey && (i *= 5, a *= 5), (e.ctrlKey || e.altKey || e.metaKey) && (i /= 10, a /= 10);
|
|
1923
|
+
let [s, c] = o(i, a);
|
|
1913
1924
|
n(t, {
|
|
1914
|
-
x:
|
|
1915
|
-
y:
|
|
1916
|
-
}, !0), r(t,
|
|
1917
|
-
type: "grid",
|
|
1918
|
-
size: i || 1
|
|
1919
|
-
}), e.preventDefault();
|
|
1925
|
+
x: s,
|
|
1926
|
+
y: c
|
|
1927
|
+
}, !0), r(t, m()), e.preventDefault();
|
|
1920
1928
|
}
|
|
1921
1929
|
}
|
|
1922
1930
|
}), /* @__PURE__ */ a(Y, {
|
|
@@ -1926,33 +1934,27 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1926
1934
|
if (a) {
|
|
1927
1935
|
r.stopPropagation();
|
|
1928
1936
|
let e = l();
|
|
1929
|
-
|
|
1930
|
-
let i =
|
|
1931
|
-
e.includes(i) || (t || n ? (
|
|
1937
|
+
g.current.items = e;
|
|
1938
|
+
let i = P(a);
|
|
1939
|
+
e.includes(i) || (t || n ? (g.current.items = [...e, i], s([i])) : (g.current.items = [i], c([i]))), Object.assign(h.current, { moving: !0 });
|
|
1932
1940
|
}
|
|
1933
1941
|
},
|
|
1934
1942
|
onDrag: ({ deltaX: e, deltaY: t, event: r }) => {
|
|
1935
|
-
if (
|
|
1943
|
+
if (h.current.moving) {
|
|
1936
1944
|
r.stopPropagation();
|
|
1937
1945
|
let { movingItems: i } = u(), [a, s] = o(e, t);
|
|
1938
|
-
n(
|
|
1946
|
+
n(g.current.items, {
|
|
1939
1947
|
x: a,
|
|
1940
1948
|
y: s
|
|
1941
1949
|
}, !0), i || d({ movingItems: !0 });
|
|
1942
1950
|
}
|
|
1943
1951
|
},
|
|
1944
1952
|
onDragEnd: () => {
|
|
1945
|
-
|
|
1946
|
-
let { gridSize: e = 1 } = p(), t = e || 1;
|
|
1947
|
-
m.current = { moving: !1 }, r(h.current.items, {
|
|
1948
|
-
type: "grid",
|
|
1949
|
-
size: t
|
|
1950
|
-
}), d({ movingItems: !1 });
|
|
1951
|
-
}
|
|
1953
|
+
h.current.moving && (h.current = { moving: !1 }, r(g.current.items, m()), d({ movingItems: !1 }));
|
|
1952
1954
|
},
|
|
1953
1955
|
children: t
|
|
1954
1956
|
});
|
|
1955
|
-
},
|
|
1957
|
+
}, Xt = (t) => {
|
|
1956
1958
|
let n = e.useRef({
|
|
1957
1959
|
hover: !1,
|
|
1958
1960
|
x: 0,
|
|
@@ -1966,16 +1968,16 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1966
1968
|
}), f(t, "mouseleave", () => {
|
|
1967
1969
|
n.current.hover = !1;
|
|
1968
1970
|
}), e.useCallback(() => n.current, []);
|
|
1969
|
-
},
|
|
1971
|
+
}, Zt = [...[
|
|
1970
1972
|
,
|
|
1971
1973
|
,
|
|
1972
1974
|
,
|
|
1973
1975
|
,
|
|
1974
1976
|
,
|
|
1975
|
-
].keys()].map((e) => `Digit${e + 1}`),
|
|
1976
|
-
let [t, n] = e.useState({}), [r, i] =
|
|
1977
|
+
].keys()].map((e) => `Digit${e + 1}`), Qt = () => {
|
|
1978
|
+
let [t, n] = e.useState({}), [r, i] = L((e) => [e.getBoardState, e.updateBoardState]);
|
|
1977
1979
|
return f(document, "keydown", (e) => {
|
|
1978
|
-
if (!["INPUT", "TEXTAREA"].includes(e.target.tagName) &&
|
|
1980
|
+
if (!["INPUT", "TEXTAREA"].includes(e.target.tagName) && Zt.includes(e.code)) {
|
|
1979
1981
|
let a = e.code, { translateX: o, translateY: s, scale: c } = r();
|
|
1980
1982
|
e.altKey || e.metaKey || e.ctrlKey || e.shiftKey ? n((e) => ({
|
|
1981
1983
|
...e,
|
|
@@ -1987,14 +1989,14 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
1987
1989
|
})) : t[a] && i(t[a]), e.preventDefault();
|
|
1988
1990
|
}
|
|
1989
1991
|
}), null;
|
|
1990
|
-
},
|
|
1991
|
-
let r = e.useRef(null), [i, o, s, c] =
|
|
1992
|
+
}, $t = ({ children: t, moveFirst: n = !1 }) => {
|
|
1993
|
+
let r = e.useRef(null), [i, o, s, c] = L((e) => [
|
|
1992
1994
|
e.config.itemExtent,
|
|
1993
1995
|
e.getConfiguration,
|
|
1994
1996
|
e.updateBoardState,
|
|
1995
1997
|
e.getSelection
|
|
1996
|
-
]), { zoomToCenter: l, zoomToExtent: u, moveBoard: d } =
|
|
1997
|
-
|
|
1998
|
+
]), { zoomToCenter: l, zoomToExtent: u, moveBoard: d } = z(), [p, m] = e.useState(!1), h = e.useRef({}), g = Xt(r);
|
|
1999
|
+
Qt();
|
|
1998
2000
|
let _ = e.useCallback(() => {
|
|
1999
2001
|
let { itemExtent: e } = o();
|
|
2000
2002
|
u(e);
|
|
@@ -2080,7 +2082,7 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
2080
2082
|
children: t
|
|
2081
2083
|
})
|
|
2082
2084
|
});
|
|
2083
|
-
},
|
|
2085
|
+
}, en = K({
|
|
2084
2086
|
position: "absolute",
|
|
2085
2087
|
top: 0,
|
|
2086
2088
|
left: 0,
|
|
@@ -2088,8 +2090,8 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
2088
2090
|
backgroundColor: "hsla(0, 40%, 50%, 0%)",
|
|
2089
2091
|
border: "2px dashed hsl(20, 55%, 40%)",
|
|
2090
2092
|
pointerEvents: "none"
|
|
2091
|
-
}),
|
|
2092
|
-
let [t, n, r, i, o, { translateX: s, translateY: c, scale: l }] =
|
|
2093
|
+
}), tn = () => {
|
|
2094
|
+
let [t, n, r, i, o, { translateX: s, translateY: c, scale: l }] = L((e) => [
|
|
2093
2095
|
e.selection,
|
|
2094
2096
|
e.getSelection,
|
|
2095
2097
|
e.selectionBox,
|
|
@@ -2100,13 +2102,13 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
2100
2102
|
translateY: e.boardState.translateY,
|
|
2101
2103
|
scale: e.boardState.scale
|
|
2102
2104
|
}
|
|
2103
|
-
]), [d] =
|
|
2105
|
+
]), [d] = I((e) => [e.items]), f = e.useCallback(() => {
|
|
2104
2106
|
let e = n(), { boardWrapperRect: t, uid: r } = o();
|
|
2105
2107
|
if (e.length === 0) {
|
|
2106
2108
|
i(null);
|
|
2107
2109
|
return;
|
|
2108
2110
|
}
|
|
2109
|
-
let a =
|
|
2111
|
+
let a = ue(e, r);
|
|
2110
2112
|
if (!a) {
|
|
2111
2113
|
i(null);
|
|
2112
2114
|
return;
|
|
@@ -2139,15 +2141,15 @@ var ht = /* @__PURE__ */ S((/* @__PURE__ */ b(((e, t) => {
|
|
|
2139
2141
|
height: `${r.height}px`,
|
|
2140
2142
|
width: `${r.width}px`
|
|
2141
2143
|
},
|
|
2142
|
-
className: `selection ${
|
|
2144
|
+
className: `selection ${en}`
|
|
2143
2145
|
});
|
|
2144
|
-
},
|
|
2145
|
-
let [e] =
|
|
2146
|
-
return e ? null : /* @__PURE__ */ a(
|
|
2146
|
+
}, nn = () => {
|
|
2147
|
+
let [e] = L((e) => [e.boardState.movingItems]);
|
|
2148
|
+
return e ? null : /* @__PURE__ */ a(tn, {});
|
|
2147
2149
|
};
|
|
2148
2150
|
//#endregion
|
|
2149
2151
|
//#region node_modules/color2k/dist/index.exports.import.es.mjs
|
|
2150
|
-
function
|
|
2152
|
+
function rn(e, t, n) {
|
|
2151
2153
|
return Math.min(Math.max(e, n), t);
|
|
2152
2154
|
}
|
|
2153
2155
|
var Z = class extends Error {
|
|
@@ -2155,7 +2157,7 @@ var Z = class extends Error {
|
|
|
2155
2157
|
super(`Failed to parse color: "${e}"`);
|
|
2156
2158
|
}
|
|
2157
2159
|
};
|
|
2158
|
-
function
|
|
2160
|
+
function an(e) {
|
|
2159
2161
|
if (typeof e != "string") throw new Z(e);
|
|
2160
2162
|
if (e.trim().toLowerCase() === "transparent") return [
|
|
2161
2163
|
0,
|
|
@@ -2164,52 +2166,52 @@ function nn(e) {
|
|
|
2164
2166
|
0
|
|
2165
2167
|
];
|
|
2166
2168
|
let t = e.trim();
|
|
2167
|
-
t =
|
|
2168
|
-
let n =
|
|
2169
|
+
t = mn.test(e) ? ln(e) : e;
|
|
2170
|
+
let n = un.exec(t);
|
|
2169
2171
|
if (n) {
|
|
2170
2172
|
let e = Array.from(n).slice(1);
|
|
2171
2173
|
return [...e.slice(0, 3).map((e) => parseInt(Q(e, 2), 16)), parseInt(Q(e[3] || "f", 2), 16) / 255];
|
|
2172
2174
|
}
|
|
2173
|
-
let r =
|
|
2175
|
+
let r = dn.exec(t);
|
|
2174
2176
|
if (r) {
|
|
2175
2177
|
let e = Array.from(r).slice(1);
|
|
2176
2178
|
return [...e.slice(0, 3).map((e) => parseInt(e, 16)), parseInt(e[3] || "ff", 16) / 255];
|
|
2177
2179
|
}
|
|
2178
|
-
let i =
|
|
2180
|
+
let i = fn.exec(t);
|
|
2179
2181
|
if (i) {
|
|
2180
2182
|
let e = Array.from(i).slice(1);
|
|
2181
2183
|
return [...e.slice(0, 3).map((e) => parseInt(e, 10)), parseFloat(e[3] || "1")];
|
|
2182
2184
|
}
|
|
2183
|
-
let a =
|
|
2185
|
+
let a = pn.exec(t);
|
|
2184
2186
|
if (a) {
|
|
2185
2187
|
let [t, n, r, i] = Array.from(a).slice(1).map(parseFloat);
|
|
2186
|
-
if (
|
|
2187
|
-
return [...
|
|
2188
|
+
if (rn(0, 100, n) !== n || rn(0, 100, r) !== r) throw new Z(e);
|
|
2189
|
+
return [...gn(t, n, r), Number.isNaN(i) ? 1 : i];
|
|
2188
2190
|
}
|
|
2189
2191
|
throw new Z(e);
|
|
2190
2192
|
}
|
|
2191
|
-
function
|
|
2193
|
+
function on(e) {
|
|
2192
2194
|
let t = 5381, n = e.length;
|
|
2193
2195
|
for (; n;) t = t * 33 ^ e.charCodeAt(--n);
|
|
2194
2196
|
return (t >>> 0) % 2341;
|
|
2195
2197
|
}
|
|
2196
|
-
var
|
|
2197
|
-
let n =
|
|
2198
|
+
var sn = (e) => parseInt(e.replace(/_/g, ""), 36), cn = "1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((e, t) => {
|
|
2199
|
+
let n = sn(t.substring(0, 3)), r = sn(t.substring(3)).toString(16), i = "";
|
|
2198
2200
|
for (let e = 0; e < 6 - r.length; e++) i += "0";
|
|
2199
2201
|
return e[n] = `${i}${r}`, e;
|
|
2200
2202
|
}, {});
|
|
2201
|
-
function
|
|
2202
|
-
let t = on
|
|
2203
|
+
function ln(e) {
|
|
2204
|
+
let t = cn[on(e.toLowerCase().trim())];
|
|
2203
2205
|
if (!t) throw new Z(e);
|
|
2204
2206
|
return `#${t}`;
|
|
2205
2207
|
}
|
|
2206
|
-
var Q = (e, t) => Array.from(Array(t)).map(() => e).join(""),
|
|
2208
|
+
var Q = (e, t) => Array.from(Array(t)).map(() => e).join(""), un = RegExp(`^#${Q("([a-f0-9])", 3)}([a-f0-9])?$`, "i"), dn = RegExp(`^#${Q("([a-f0-9]{2})", 3)}([a-f0-9]{2})?$`, "i"), fn = RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Q(",\\s*(\\d+)\\s*", 2)}(?:,\\s*([\\d.]+))?\\s*\\)$`, "i"), pn = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i, mn = /^[a-z]+$/i, hn = (e) => Math.round(e * 255), gn = (e, t, n) => {
|
|
2207
2209
|
let r = n / 100;
|
|
2208
2210
|
if (t === 0) return [
|
|
2209
2211
|
r,
|
|
2210
2212
|
r,
|
|
2211
2213
|
r
|
|
2212
|
-
].map(
|
|
2214
|
+
].map(hn);
|
|
2213
2215
|
let i = (e % 360 + 360) % 360 / 60, a = (1 - Math.abs(2 * r - 1)) * (t / 100), o = a * (1 - Math.abs(i % 2 - 1)), s = 0, c = 0, l = 0;
|
|
2214
2216
|
i >= 0 && i < 1 ? (s = a, c = o) : i >= 1 && i < 2 ? (s = o, c = a) : i >= 2 && i < 3 ? (c = a, l = o) : i >= 3 && i < 4 ? (c = o, l = a) : i >= 4 && i < 5 ? (s = o, l = a) : i >= 5 && i < 6 && (s = a, l = o);
|
|
2215
2217
|
let u = r - a / 2;
|
|
@@ -2217,29 +2219,29 @@ var Q = (e, t) => Array.from(Array(t)).map(() => e).join(""), cn = RegExp(`^#${Q
|
|
|
2217
2219
|
s + u,
|
|
2218
2220
|
c + u,
|
|
2219
2221
|
l + u
|
|
2220
|
-
].map(
|
|
2222
|
+
].map(hn);
|
|
2221
2223
|
};
|
|
2222
|
-
function
|
|
2224
|
+
function _n(e) {
|
|
2223
2225
|
if (e === "transparent") return 0;
|
|
2224
2226
|
function t(e) {
|
|
2225
2227
|
let t = e / 255;
|
|
2226
2228
|
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
2227
2229
|
}
|
|
2228
|
-
let [n, r, i] =
|
|
2230
|
+
let [n, r, i] = an(e);
|
|
2229
2231
|
return .2126 * t(n) + .7152 * t(r) + .0722 * t(i);
|
|
2230
2232
|
}
|
|
2231
|
-
function
|
|
2232
|
-
return
|
|
2233
|
+
function vn(e) {
|
|
2234
|
+
return _n(e) > .179;
|
|
2233
2235
|
}
|
|
2234
2236
|
//#endregion
|
|
2235
2237
|
//#region src/lib/board/Cursors/Cursor.jsx
|
|
2236
|
-
var
|
|
2238
|
+
var yn = K({
|
|
2237
2239
|
display: "flex",
|
|
2238
2240
|
flexDirection: "row",
|
|
2239
2241
|
alignItems: "center",
|
|
2240
2242
|
zIndex: 210,
|
|
2241
2243
|
pointerEvents: "none"
|
|
2242
|
-
}),
|
|
2244
|
+
}), bn = K({
|
|
2243
2245
|
fontWeight: "bold",
|
|
2244
2246
|
padding: "0 0.5em",
|
|
2245
2247
|
borderRadius: "2px",
|
|
@@ -2250,10 +2252,10 @@ var _n = K({
|
|
|
2250
2252
|
marginTop: "1.7em",
|
|
2251
2253
|
whitespace: "nowrap",
|
|
2252
2254
|
pointerEvents: "none"
|
|
2253
|
-
}),
|
|
2254
|
-
let r =
|
|
2255
|
+
}), xn = e.memo(({ color: e = "#666", size: t = 40, text: n }) => {
|
|
2256
|
+
let r = vn(e) ? "#222" : "#EEE";
|
|
2255
2257
|
return /* @__PURE__ */ o("div", {
|
|
2256
|
-
className:
|
|
2258
|
+
className: yn,
|
|
2257
2259
|
children: [/* @__PURE__ */ o("svg", {
|
|
2258
2260
|
version: "1.1",
|
|
2259
2261
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2276,22 +2278,22 @@ var _n = K({
|
|
|
2276
2278
|
color: r,
|
|
2277
2279
|
backgroundColor: e
|
|
2278
2280
|
},
|
|
2279
|
-
className:
|
|
2281
|
+
className: bn,
|
|
2280
2282
|
children: n
|
|
2281
2283
|
})]
|
|
2282
2284
|
});
|
|
2283
|
-
}),
|
|
2285
|
+
}), Sn = K({
|
|
2284
2286
|
top: 0,
|
|
2285
2287
|
left: 0,
|
|
2286
2288
|
zIndex: 210,
|
|
2287
2289
|
position: "fixed",
|
|
2288
2290
|
pointerEvents: "none"
|
|
2289
|
-
}),
|
|
2290
|
-
className:
|
|
2291
|
+
}), Cn = ({ pos: e, ...t }) => /* @__PURE__ */ a("div", {
|
|
2292
|
+
className: Sn,
|
|
2291
2293
|
style: { transform: `translate(${e.x - 6}px, ${e.y - 15}px)` },
|
|
2292
|
-
children: /* @__PURE__ */ a(
|
|
2293
|
-
}),
|
|
2294
|
-
let [t] =
|
|
2294
|
+
children: /* @__PURE__ */ a(xn, { ...t })
|
|
2295
|
+
}), wn = ({ children: e }) => {
|
|
2296
|
+
let [t] = L((e) => [e.getConfiguration, e.boardState.scale]), { fromWrapperToBoard: n, fromBoardToWrapper: r } = z(), [i, s, c, l] = U((e) => [
|
|
2295
2297
|
e.getUser(),
|
|
2296
2298
|
e.getLocalUsers(),
|
|
2297
2299
|
e.cursors,
|
|
@@ -2313,15 +2315,15 @@ var _n = K({
|
|
|
2313
2315
|
x: n + f.left,
|
|
2314
2316
|
y: i + f.top
|
|
2315
2317
|
};
|
|
2316
|
-
return
|
|
2318
|
+
return se(o, f) ? /* @__PURE__ */ a(Cn, {
|
|
2317
2319
|
pos: o,
|
|
2318
2320
|
text: l[e].name,
|
|
2319
2321
|
color: l[e].color
|
|
2320
2322
|
}, e) : null;
|
|
2321
2323
|
})]
|
|
2322
2324
|
});
|
|
2323
|
-
},
|
|
2324
|
-
function
|
|
2325
|
+
}, Tn = /[+-]?(?:\d*\.)?\d+(?:e[+-]?\d+)?(?:px|%)/gi;
|
|
2326
|
+
function En(e, t = ",") {
|
|
2325
2327
|
let n = 0, r = "", i = 0, a = [];
|
|
2326
2328
|
for (let [o, s] of e.split("").entries()) if (r) s === r && e[o - 1] !== "\\" && (r = "");
|
|
2327
2329
|
else if (s === "\"" || s === "'") r = s;
|
|
@@ -2335,10 +2337,10 @@ function wn(e, t = ",") {
|
|
|
2335
2337
|
return o && a.push(o), a;
|
|
2336
2338
|
}
|
|
2337
2339
|
function $(e, t) {
|
|
2338
|
-
return [...e.replace(/\s/g, "").matchAll(
|
|
2340
|
+
return [...e.replace(/\s/g, "").matchAll(Tn)].reduce((e, [n]) => e + Number.parseFloat(n) * (n.endsWith("%") ? t / 100 : 1), 0);
|
|
2339
2341
|
}
|
|
2340
|
-
function
|
|
2341
|
-
let [i, a = "auto"] =
|
|
2342
|
+
function Dn(e, t, n, r) {
|
|
2343
|
+
let [i, a = "auto"] = En(e, " "), o = r?.width, s = r?.height;
|
|
2342
2344
|
if (i === "cover" || i === "contain") {
|
|
2343
2345
|
if (!o || !s) return [t, n];
|
|
2344
2346
|
let e = Math[i === "cover" ? "max" : "min"](t / o, n / s);
|
|
@@ -2347,7 +2349,7 @@ function Tn(e, t, n, r) {
|
|
|
2347
2349
|
let c = i === "auto" ? null : $(i, t), l = a === "auto" ? null : $(a, n);
|
|
2348
2350
|
return c === null && l === null ? [o || t, s || n] : (c === null && (c = o && s ? l * o / s : t), l === null && (l = o && s ? c * s / o : n), [c, l]);
|
|
2349
2351
|
}
|
|
2350
|
-
function
|
|
2352
|
+
function On(e, t, n) {
|
|
2351
2353
|
let r = [
|
|
2352
2354
|
[0, 0],
|
|
2353
2355
|
[e, 0],
|
|
@@ -2363,9 +2365,9 @@ function En(e, t, n) {
|
|
|
2363
2365
|
y: d
|
|
2364
2366
|
};
|
|
2365
2367
|
}
|
|
2366
|
-
var
|
|
2367
|
-
function
|
|
2368
|
-
let i =
|
|
2368
|
+
var kn = (e, t, n) => ((e - t) % n + n) % n;
|
|
2369
|
+
function An(e, t, n, r) {
|
|
2370
|
+
let i = On(e, t, n), a = Number.isFinite(r) && r > 0 ? r : 512 * 2 ** Math.max(0, Math.ceil(Math.log2(1 / n.scale))), o = Math.floor(i.left / a) - 1, s = Math.floor((i.left + i.width) / a) + 1, c = Math.floor(i.top / a) - 1, l = Math.floor((i.top + i.height) / a) + 1, u = o * a, d = c * a, [f, p] = M([u, d], n);
|
|
2369
2371
|
return {
|
|
2370
2372
|
tiles: Array.from({ length: l - c + 1 }, (e, t) => {
|
|
2371
2373
|
let n = c + t;
|
|
@@ -2387,18 +2389,18 @@ function On(e, t, n, r) {
|
|
|
2387
2389
|
}
|
|
2388
2390
|
//#endregion
|
|
2389
2391
|
//#region src/lib/board/WorldBackground.jsx
|
|
2390
|
-
var
|
|
2392
|
+
var jn = {
|
|
2391
2393
|
position: "absolute",
|
|
2392
2394
|
inset: 0,
|
|
2393
2395
|
pointerEvents: "none"
|
|
2394
2396
|
};
|
|
2395
|
-
function
|
|
2396
|
-
let [r, i] =
|
|
2397
|
+
function Mn({ style: t, tileSizeOverride: n }) {
|
|
2398
|
+
let [r, i] = L((e) => [e.boardState, e.config.boardWrapperRect]), s = i.width || 1, c = i.height || 1, l = e.useRef(null), [u, d] = e.useState({
|
|
2397
2399
|
color: "#333",
|
|
2398
2400
|
layers: []
|
|
2399
2401
|
}), [f, p] = e.useState({});
|
|
2400
2402
|
e.useLayoutEffect(() => {
|
|
2401
|
-
let e = getComputedStyle(l.current), t = (t) =>
|
|
2403
|
+
let e = getComputedStyle(l.current), t = (t) => En(e[t]), n = t("backgroundSize"), r = t("backgroundPositionX"), i = t("backgroundPositionY"), a = t("backgroundRepeat"), o = t("backgroundBlendMode");
|
|
2402
2404
|
d({
|
|
2403
2405
|
color: e.backgroundColor,
|
|
2404
2406
|
layers: t("backgroundImage").map((e, t) => ({
|
|
@@ -2432,19 +2434,19 @@ function An({ style: t, tileSizeOverride: n }) {
|
|
|
2432
2434
|
e = !1;
|
|
2433
2435
|
};
|
|
2434
2436
|
}, [u.layers]);
|
|
2435
|
-
let m =
|
|
2436
|
-
let [t, n] =
|
|
2437
|
+
let m = An(s, c, r, n), h = u.layers.map((e) => {
|
|
2438
|
+
let [t, n] = Dn(e.size, s, c, f[e.image]), r = ["repeat", "repeat-x"].includes(e.repeat) || e.repeat.startsWith("repeat "), i = ["repeat", "repeat-y"].includes(e.repeat) || e.repeat.endsWith(" repeat"), a = $(e.x, s - t), o = $(e.y, c - n);
|
|
2437
2439
|
return {
|
|
2438
2440
|
...e,
|
|
2439
2441
|
size: `${t}px ${n}px`,
|
|
2440
|
-
position: (e, s) => `${r && t ?
|
|
2442
|
+
position: (e, s) => `${r && t ? kn(a, e, t) : a - e}px ${i && n ? kn(o, s, n) : o - s}px`
|
|
2441
2443
|
};
|
|
2442
2444
|
});
|
|
2443
2445
|
return /* @__PURE__ */ o("div", {
|
|
2444
2446
|
className: "world-background",
|
|
2445
2447
|
"aria-hidden": "true",
|
|
2446
2448
|
style: {
|
|
2447
|
-
...
|
|
2449
|
+
...jn,
|
|
2448
2450
|
overflow: "hidden",
|
|
2449
2451
|
backgroundColor: u.color
|
|
2450
2452
|
},
|
|
@@ -2487,17 +2489,17 @@ function An({ style: t, tileSizeOverride: n }) {
|
|
|
2487
2489
|
}
|
|
2488
2490
|
//#endregion
|
|
2489
2491
|
//#region src/lib/board/Board.jsx
|
|
2490
|
-
var
|
|
2492
|
+
var Nn = ({ children: e }) => e, Pn = {}, Fn = {
|
|
2491
2493
|
overflow: "hidden",
|
|
2492
2494
|
position: "absolute",
|
|
2493
2495
|
inset: 0
|
|
2494
|
-
},
|
|
2495
|
-
let f = e.useRef(null), [m, h] =
|
|
2496
|
+
}, In = ({ moveFirst: t = !0, style: n, wrapperStyle: r, itemTemplates: i = Pn, boardSize: s = De, backgroundTileSize: c, children: l, showResizeHandle: u = !1, Wrapper: d = Nn }) => {
|
|
2497
|
+
let f = e.useRef(null), [m, h] = L((e) => [e.config.uid, e.updateConfiguration]), [g, _, v, y] = L((e) => [
|
|
2496
2498
|
e.boardState.translateX,
|
|
2497
2499
|
e.boardState.translateY,
|
|
2498
2500
|
e.boardState.scale,
|
|
2499
2501
|
e.boardState.rotate
|
|
2500
|
-
]), { updateItemExtent: b } =
|
|
2502
|
+
]), { updateItemExtent: b } = z(), x = {
|
|
2501
2503
|
userSelect: "none",
|
|
2502
2504
|
position: "absolute",
|
|
2503
2505
|
inset: 0,
|
|
@@ -2535,7 +2537,7 @@ var jn = ({ children: e }) => e, Mn = {}, Nn = {
|
|
|
2535
2537
|
f.current && h({ boardWrapperRect: f.current.getBoundingClientRect() });
|
|
2536
2538
|
});
|
|
2537
2539
|
let S = K({
|
|
2538
|
-
...
|
|
2540
|
+
...Fn,
|
|
2539
2541
|
...r
|
|
2540
2542
|
});
|
|
2541
2543
|
return /* @__PURE__ */ o("div", {
|
|
@@ -2543,15 +2545,15 @@ var jn = ({ children: e }) => e, Mn = {}, Nn = {
|
|
|
2543
2545
|
id: m,
|
|
2544
2546
|
className: `sync-board ${S}`,
|
|
2545
2547
|
children: [
|
|
2546
|
-
/* @__PURE__ */ a(
|
|
2548
|
+
/* @__PURE__ */ a(Mn, {
|
|
2547
2549
|
style: n,
|
|
2548
2550
|
tileSizeOverride: c
|
|
2549
2551
|
}),
|
|
2550
|
-
/* @__PURE__ */ a(
|
|
2552
|
+
/* @__PURE__ */ a(wn, { children: /* @__PURE__ */ a(Jt, {
|
|
2551
2553
|
moveFirst: t,
|
|
2552
|
-
children: /* @__PURE__ */ a(
|
|
2554
|
+
children: /* @__PURE__ */ a($t, {
|
|
2553
2555
|
moveFirst: t,
|
|
2554
|
-
children: /* @__PURE__ */ a(
|
|
2556
|
+
children: /* @__PURE__ */ a(Yt, {
|
|
2555
2557
|
moveFirst: t,
|
|
2556
2558
|
children: /* @__PURE__ */ a(d, { children: /* @__PURE__ */ o("div", {
|
|
2557
2559
|
onContextMenu: (e) => {
|
|
@@ -2559,7 +2561,7 @@ var jn = ({ children: e }) => e, Mn = {}, Nn = {
|
|
|
2559
2561
|
},
|
|
2560
2562
|
style: x,
|
|
2561
2563
|
className: `board-pane${v < .5 ? " board-pane__far" : ""}`,
|
|
2562
|
-
children: [/* @__PURE__ */ a(
|
|
2564
|
+
children: [/* @__PURE__ */ a(Gt, {}), /* @__PURE__ */ a("div", {
|
|
2563
2565
|
style: { pointerEvents: "auto" },
|
|
2564
2566
|
children: l
|
|
2565
2567
|
})]
|
|
@@ -2567,14 +2569,14 @@ var jn = ({ children: e }) => e, Mn = {}, Nn = {
|
|
|
2567
2569
|
})
|
|
2568
2570
|
})
|
|
2569
2571
|
}) }),
|
|
2570
|
-
/* @__PURE__ */ a(
|
|
2572
|
+
/* @__PURE__ */ a(nn, {})
|
|
2571
2573
|
]
|
|
2572
2574
|
});
|
|
2573
2575
|
};
|
|
2574
2576
|
//#endregion
|
|
2575
2577
|
//#region src/lib/index.js
|
|
2576
|
-
|
|
2578
|
+
gt(e.createElement);
|
|
2577
2579
|
//#endregion
|
|
2578
|
-
export {
|
|
2580
|
+
export { In as Board, ot as BoardWrapper, st as RoomWrapper, Ve as useAvailableActions, Ye as useBoardConfig, z as useBoardPosition, Xe as useBoardState, Ee as useDebouncedItems, Fe as useGetSelectedItems, V as useItemActions, B as useItemInteraction, Te as useItems, it as useMessage, Pe as useSelectedItems, He as useSelectionBox, Ze as useSessionInfo, Je as useUsers, k as useWire };
|
|
2579
2581
|
|
|
2580
2582
|
//# sourceMappingURL=react-sync-board.js.map
|