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