seat-editor 1.4.19 → 1.4.21

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.
Files changed (56) hide show
  1. package/dist/app/layout.d.ts +1 -1
  2. package/dist/app/layout.js +22 -0
  3. package/dist/app/new-board/page.d.ts +1 -1
  4. package/dist/app/new-board/page.js +30 -0
  5. package/dist/app/old-board/page.d.ts +1 -2
  6. package/dist/app/old-board/page.js +377 -0
  7. package/dist/app/only-view/page.d.ts +1 -1
  8. package/dist/app/only-view/page.js +41 -0
  9. package/dist/app/page.d.ts +1 -1
  10. package/dist/app/page.js +8 -0
  11. package/dist/components/button-tools/index.d.ts +1 -1
  12. package/dist/components/button-tools/index.js +11 -0
  13. package/dist/components/form-tools/label.d.ts +1 -1
  14. package/dist/components/form-tools/label.js +7 -0
  15. package/dist/components/form-tools/shape.d.ts +1 -1
  16. package/dist/components/form-tools/shape.js +25 -0
  17. package/dist/components/input/number-indicator.d.ts +1 -1
  18. package/dist/components/input/number-indicator.js +27 -0
  19. package/dist/components/joystick/index.d.ts +1 -2
  20. package/dist/components/joystick/index.js +48 -0
  21. package/dist/components/layer/index.d.ts +1 -1
  22. package/dist/components/layer/index.js +276 -0
  23. package/dist/components/lib/index.d.ts +1 -1
  24. package/dist/components/lib/index.js +28 -0
  25. package/dist/components/modal-preview/index.d.ts +1 -1
  26. package/dist/components/modal-preview/index.js +10 -0
  27. package/dist/features/board/index.d.ts +1 -1
  28. package/dist/features/board/index.js +626 -0
  29. package/dist/features/navbar/index.d.ts +1 -1
  30. package/dist/features/navbar/index.js +6 -0
  31. package/dist/features/package/index.d.ts +1 -1
  32. package/dist/features/package/index.js +102 -0
  33. package/dist/features/package/index.jsx +6 -9
  34. package/dist/features/panel/index.d.ts +1 -1
  35. package/dist/features/panel/index.js +97 -0
  36. package/dist/features/panel/select-tool.d.ts +1 -1
  37. package/dist/features/panel/select-tool.js +44 -0
  38. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  39. package/dist/features/panel/square-circle-tool.js +8 -0
  40. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  41. package/dist/features/panel/table-seat-circle.js +9 -0
  42. package/dist/features/panel/text-tool.d.ts +1 -1
  43. package/dist/features/panel/text-tool.js +7 -0
  44. package/dist/features/panel/upload-tool.d.ts +1 -1
  45. package/dist/features/panel/upload-tool.js +155 -0
  46. package/dist/features/side-tool/index.d.ts +1 -1
  47. package/dist/features/side-tool/index.js +244 -0
  48. package/dist/features/view/index.d.ts +1 -1
  49. package/dist/features/view/index.js +213 -0
  50. package/dist/features/view/index.jsx +4 -6
  51. package/dist/provider/antd-provider.js +43 -0
  52. package/dist/provider/redux-provider.d.ts +1 -1
  53. package/dist/provider/redux-provider.js +7 -0
  54. package/dist/provider/store-provider.d.ts +1 -1
  55. package/dist/provider/store-provider.js +9 -0
  56. package/package.json +1 -1
@@ -0,0 +1,626 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { TransformWrapper, TransformComponent, MiniMap, } from "react-zoom-pan-pinch";
5
+ import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
6
+ import Layers from "../../components/layer";
7
+ import { throttle } from "lodash";
8
+ import ModalPreview from "../../components/modal-preview";
9
+ import LayerView from "../view";
10
+ import { isEqual, debounce } from "lodash";
11
+ import { ZoomIn, ZoomOut } from "lucide-react";
12
+ import { Button } from "antd";
13
+ const BoardTemplate = ({ onSelectComponent }) => {
14
+ const dispatch = useAppDispatch();
15
+ const theme = useAppSelector((state) => state.theme);
16
+ const transformRef = useRef(null);
17
+ const containerRef = useRef(null);
18
+ const [widthBoard, setWidthBoard] = useState(0);
19
+ const [heightBoard, setHeightBoard] = useState(0);
20
+ const svgRef = useRef(null);
21
+ const [shadowShape, setShadowShape] = useState([]);
22
+ const [startPoint, setStartPoint] = useState(null);
23
+ const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 });
24
+ const [moveComponent, setMoveComponent] = useState(false);
25
+ const [scale, setScale] = useState(1);
26
+ const activeTool = useAppSelector((state) => state.tool.active);
27
+ const { components: componentsProps, extraComponents: extraComponentsProps, flagChange, } = useAppSelector((state) => state.board);
28
+ const isTouching = useRef(false);
29
+ const [isDragging, setIsDragging] = useState(false);
30
+ const [resizeDirection, setResizeDirection] = useState(null);
31
+ const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
32
+ const selectedComponentProps = useAppSelector((state) => state.panel.selectedComponent);
33
+ const screenCTMRef = useRef(null);
34
+ const dragIndex = useRef(null);
35
+ const [componentsState, setComponentsState] = useState([]);
36
+ const [extraComponentsState, setExtraComponentsState] = useState([]);
37
+ const [selectedComponent, setSelectedComponent] = useState(null);
38
+ const isSyncingFromRedux = useRef(false);
39
+ const debouncedSyncToReduxSelected = useRef(debounce((data) => {
40
+ throttledDispatch(data);
41
+ }, 300)).current;
42
+ const debouncedSyncComponents = useRef(debounce((data) => {
43
+ dispatch({
44
+ type: "board/setNewComponents",
45
+ payload: data,
46
+ });
47
+ }, 300));
48
+ const debouncedSyncExtraComponents = useRef(debounce((data) => {
49
+ dispatch({
50
+ type: "board/setNewExtraComponents",
51
+ payload: data,
52
+ });
53
+ }, 300));
54
+ // Redux → Local
55
+ useEffect(() => {
56
+ if (flagChange) {
57
+ if (!isEqual(componentsProps, componentsState)) {
58
+ isSyncingFromRedux.current = true;
59
+ setComponentsState(componentsProps);
60
+ }
61
+ if (!isEqual(extraComponentsProps, extraComponentsState)) {
62
+ isSyncingFromRedux.current = true;
63
+ setExtraComponentsState(extraComponentsProps);
64
+ }
65
+ if (!isEqual(selectedComponentProps, selectedComponent)) {
66
+ isSyncingFromRedux.current = true;
67
+ setSelectedComponent(selectedComponentProps);
68
+ }
69
+ dispatch({ type: "board/setFlagChange", payload: false });
70
+ }
71
+ }, [
72
+ componentsProps,
73
+ extraComponentsProps,
74
+ selectedComponentProps,
75
+ flagChange,
76
+ ]);
77
+ // Local → Redux
78
+ useEffect(() => {
79
+ if (isSyncingFromRedux.current) {
80
+ isSyncingFromRedux.current = false;
81
+ return;
82
+ }
83
+ if (!isEqual(componentsState, componentsProps)) {
84
+ debouncedSyncComponents.current(componentsState);
85
+ }
86
+ if (!isEqual(extraComponentsState, extraComponentsProps)) {
87
+ debouncedSyncExtraComponents.current(extraComponentsState);
88
+ }
89
+ }, [componentsState, extraComponentsState]);
90
+ const handleAddComponent = (shape) => {
91
+ dispatch({
92
+ type: activeTool === "text"
93
+ ? "board/setExtraComponent"
94
+ : "board/addComponent",
95
+ payload: Object.assign(Object.assign({}, shape), { fill: theme === null || theme === void 0 ? void 0 : theme.primaryColor }),
96
+ });
97
+ const payload = Object.assign(Object.assign({}, shape), { fill: theme === null || theme === void 0 ? void 0 : theme.primaryColor });
98
+ if (activeTool === "text") {
99
+ setExtraComponentsState((prev) => [...prev, payload]);
100
+ }
101
+ else {
102
+ setComponentsState((prev) => [...prev, payload]);
103
+ }
104
+ };
105
+ const getSvgCoords = (e) => {
106
+ var _a;
107
+ const svg = svgRef.current;
108
+ const point = svg.createSVGPoint();
109
+ point.x = e.clientX;
110
+ point.y = e.clientY;
111
+ const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
112
+ return { x: transformed.x, y: transformed.y };
113
+ };
114
+ const createShape = (x, y, fill) => ({
115
+ x,
116
+ y,
117
+ width: 50,
118
+ height: 50,
119
+ shape: activeTool,
120
+ id: Date.now(),
121
+ fill,
122
+ rotation: activeTool === "diamond" ? 45 : 0,
123
+ seatCount: activeTool === "table-seat-circle" ? 6 : 0,
124
+ openSpace: activeTool === "table-seat-circle" ? 0 : undefined,
125
+ seatFill: activeTool === "table-seat-circle" ? "#DADADA" : undefined,
126
+ text: activeTool === "text" ? "Text" : "",
127
+ fontColor: activeTool === "text" ? "#DADADA" : undefined,
128
+ });
129
+ const handleMouseDown = (e, item, direction) => {
130
+ if (activeTool === "select" && direction) {
131
+ setResizeDirection(direction);
132
+ setIsDragging(true);
133
+ }
134
+ if (activeTool === "select" && !direction && !moveComponent) {
135
+ if (e) {
136
+ dispatch({ type: "panel/setShow", payload: false });
137
+ setMoveComponent(true);
138
+ setIsDragging(true);
139
+ // dispatch({ type: "panel/setSelectedComponent", payload: null });
140
+ // setSelectedComponent(null)
141
+ const rectBox = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
142
+ setDragOffset({
143
+ x: e.clientX - rectBox.left,
144
+ y: e.clientY - rectBox.top,
145
+ });
146
+ }
147
+ }
148
+ };
149
+ const handleMouseUp = () => {
150
+ if (activeTool === "select" && selectedComponent && (moveComponent || isDragging)) {
151
+ setMoveComponent(false);
152
+ dispatch({ type: "panel/setShow", payload: false });
153
+ dispatch({ type: "panel/setSelectedComponent", payload: null });
154
+ setSelectedComponent(null);
155
+ setIsDragging(false);
156
+ setResizeDirection(null);
157
+ }
158
+ };
159
+ const handleMouseEnter = () => {
160
+ if (![
161
+ "square",
162
+ "circle",
163
+ "diamond",
164
+ "table-seat-circle",
165
+ "table-seat-square",
166
+ "text",
167
+ ].includes(activeTool))
168
+ return;
169
+ };
170
+ const handleMouseLeave = () => {
171
+ if (![
172
+ "square",
173
+ "circle",
174
+ "diamond",
175
+ "table-seat-circle",
176
+ "table-seat-square",
177
+ "text",
178
+ ].includes(activeTool))
179
+ return;
180
+ setShadowShape([]);
181
+ };
182
+ const handleMouseClick = (e) => {
183
+ if (![
184
+ "square",
185
+ "circle",
186
+ "diamond",
187
+ "table-seat-circle",
188
+ "table-seat-square",
189
+ "text",
190
+ ].includes(activeTool)) {
191
+ return;
192
+ }
193
+ const { x, y } = getSvgCoords(e);
194
+ setStartPoint({ x, y });
195
+ handleAddComponent(createShape(x, y, theme === null || theme === void 0 ? void 0 : theme.primaryColor));
196
+ };
197
+ const throttledDispatch = useCallback(throttle((component) => {
198
+ // dispatch({
199
+ // type: "board/updateComponent",
200
+ // payload: component,
201
+ // });
202
+ dispatch({
203
+ type: "panel/updateSelectedComponent",
204
+ payload: component,
205
+ });
206
+ }, 16), // 16ms ≈ 60fps
207
+ [dispatch]);
208
+ const handleMouseMove = (e) => {
209
+ if ([
210
+ "square",
211
+ "circle",
212
+ "diamond",
213
+ "table-seat-circle",
214
+ "table-seat-square",
215
+ "text",
216
+ ].includes(activeTool)) {
217
+ const { x, y } = getSvgCoords(e);
218
+ setShadowShape([createShape(x, y, theme === null || theme === void 0 ? void 0 : theme.primaryColor)]);
219
+ return;
220
+ }
221
+ if (activeTool === "select" &&
222
+ selectedComponent &&
223
+ moveComponent &&
224
+ dragOffset &&
225
+ // !isTouching.current &&
226
+ !resizeDirection) {
227
+ const workspaceRect = e.currentTarget.getBoundingClientRect();
228
+ const newX = e.clientX - workspaceRect.left - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x);
229
+ const newY = e.clientY - workspaceRect.top - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y);
230
+ let newPosition = {
231
+ x: newX,
232
+ y: newY,
233
+ };
234
+ requestAnimationFrame(() => {
235
+ setComponentsState((prev) => {
236
+ return prev.map((component) => {
237
+ if (component.id === selectedComponent.id) {
238
+ return Object.assign(Object.assign({}, component), { x: newPosition.x, y: newPosition.y });
239
+ }
240
+ return component;
241
+ });
242
+ });
243
+ setExtraComponentsState((prev) => {
244
+ return prev.map((component) => {
245
+ if (component.id === selectedComponent.id) {
246
+ return Object.assign(Object.assign({}, component), { x: newPosition.x, y: newPosition.y });
247
+ }
248
+ return component;
249
+ });
250
+ });
251
+ setSelectedComponent((prev) => {
252
+ return Object.assign(Object.assign({}, prev), { x: newPosition.x, y: newPosition.y });
253
+ });
254
+ });
255
+ debouncedSyncToReduxSelected(Object.assign(Object.assign({}, selectedComponent), newPosition));
256
+ return;
257
+ }
258
+ if (activeTool === "select" && resizeDirection) {
259
+ const workspaceRect = e.currentTarget.getBoundingClientRect();
260
+ const currentX = e.clientX - workspaceRect.left;
261
+ const currentY = e.clientY - workspaceRect.top;
262
+ const { x, y, width, height } = selectedComponent;
263
+ let newShape = Object.assign({}, selectedComponent);
264
+ if (!["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape)) {
265
+ switch (resizeDirection) {
266
+ case "top-left":
267
+ newShape.width = width + (x - currentX);
268
+ newShape.height = height + (y - currentY);
269
+ newShape.x = currentX;
270
+ newShape.y = currentY;
271
+ break;
272
+ case "top-right":
273
+ newShape.width = currentX - newShape.x;
274
+ newShape.height = newShape.height + (newShape.y - currentY);
275
+ newShape.y = currentY;
276
+ break;
277
+ case "bottom-left":
278
+ newShape.width += newShape.x - currentX;
279
+ newShape.height = currentY - newShape.y;
280
+ newShape.x = currentX;
281
+ break;
282
+ case "bottom-right":
283
+ newShape.width = currentX - newShape.x;
284
+ newShape.height = currentY - newShape.y;
285
+ break;
286
+ case "left-center":
287
+ newShape.width += newShape.x - currentX;
288
+ newShape.x = currentX;
289
+ break;
290
+ case "right-center":
291
+ newShape.width = currentX - newShape.x;
292
+ break;
293
+ case "top-center":
294
+ newShape.height += newShape.y - currentY;
295
+ newShape.y = currentY;
296
+ break;
297
+ case "bottom-center":
298
+ newShape.height = currentY - newShape.y;
299
+ break;
300
+ default:
301
+ break;
302
+ }
303
+ }
304
+ else if (["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape)) {
305
+ switch (resizeDirection) {
306
+ case "top-left":
307
+ newShape.width = width + (x - currentX);
308
+ newShape.height = height + (y - currentY);
309
+ newShape.x = currentX;
310
+ newShape.y = currentY;
311
+ break;
312
+ case "top-right":
313
+ newShape.width = currentX - newShape.x;
314
+ newShape.height = newShape.height + (newShape.y - currentY);
315
+ newShape.y = currentY;
316
+ break;
317
+ case "bottom-left":
318
+ newShape.width += newShape.x - currentX;
319
+ newShape.height = currentY - newShape.y;
320
+ newShape.x = currentX;
321
+ break;
322
+ case "bottom-right":
323
+ newShape.width = currentX - newShape.x;
324
+ newShape.height = currentY - newShape.y;
325
+ break;
326
+ default:
327
+ break;
328
+ }
329
+ }
330
+ // updateComponentRef({
331
+ // ...(typeof selectedComponent === "object" && selectedComponent !== null
332
+ // ? selectedComponent
333
+ // : {}),
334
+ // ...newShape,
335
+ // });
336
+ requestAnimationFrame(() => {
337
+ setComponentsState((prev) => {
338
+ return prev.map((component) => {
339
+ if (component.id === selectedComponent.id) {
340
+ return Object.assign(Object.assign({}, component), newShape);
341
+ }
342
+ return component;
343
+ });
344
+ });
345
+ setExtraComponentsState((prev) => {
346
+ return prev.map((component) => {
347
+ if (component.id === selectedComponent.id) {
348
+ return Object.assign(Object.assign({}, component), newShape);
349
+ }
350
+ return component;
351
+ });
352
+ });
353
+ setSelectedComponent(newShape);
354
+ });
355
+ debouncedSyncToReduxSelected(newShape);
356
+ }
357
+ };
358
+ const handleSelectComponent = (items) => {
359
+ if (activeTool === "select") {
360
+ setIsDragging(true);
361
+ setMoveComponent(false);
362
+ onSelectComponent && onSelectComponent(items);
363
+ setSelectedComponent(items);
364
+ dispatch({ type: "panel/setSelectedComponent", payload: items });
365
+ // selectedComponentRef.current = items;
366
+ dispatch({ type: "panel/setShow", payload: true });
367
+ }
368
+ };
369
+ useEffect(() => {
370
+ if (containerRef.current) {
371
+ setWidthBoard(containerRef.current.offsetWidth);
372
+ setHeightBoard(containerRef.current.offsetHeight);
373
+ }
374
+ });
375
+ const handleUnSelectComponent = () => {
376
+ dispatch({ type: "panel/setSelectedComponent", payload: null });
377
+ setSelectedComponent(null);
378
+ // selectedComponentRef.current = null;
379
+ };
380
+ const handleTouchStart = (e, items, direction) => {
381
+ var _a, _b, _c, _d;
382
+ if (activeTool === "select" && !direction) {
383
+ // dispatch({ type: "panel/setShow", payload: false });
384
+ setMoveComponent(true);
385
+ isTouching.current = true;
386
+ // dispatch({ type: "panel/setSelectedComponent", payload: item });
387
+ onSelectComponent && onSelectComponent(items);
388
+ dispatch({ type: "panel/setSelectedComponent", payload: items });
389
+ setSelectedComponent(items);
390
+ // selectedComponentRef.current = items;
391
+ const touch = e.touches[0];
392
+ const svg = e.currentTarget.ownerSVGElement;
393
+ const pt = svg.createSVGPoint();
394
+ if (!svg)
395
+ return;
396
+ pt.x = touch.clientX;
397
+ pt.y = touch.clientY;
398
+ const cursorpt = pt.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
399
+ screenCTMRef.current = ((_b = svg.getScreenCTM()) === null || _b === void 0 ? void 0 : _b.inverse()) || null;
400
+ setDragOffset({
401
+ x: cursorpt.x - items.x,
402
+ y: cursorpt.y - items.y,
403
+ });
404
+ // dragOffset.current = {
405
+ // x: cursorpt.x - items.x,
406
+ // y: cursorpt.y - items.y
407
+ // }
408
+ }
409
+ else if (activeTool === "select" && direction) {
410
+ setResizeDirection(direction);
411
+ setIsDragging(true);
412
+ setMoveComponent(true);
413
+ isTouching.current = true;
414
+ const touch = e.touches[0];
415
+ const svg = e.currentTarget.ownerSVGElement;
416
+ const pt = svg.createSVGPoint();
417
+ if (!svg)
418
+ return;
419
+ pt.x = touch.clientX;
420
+ pt.y = touch.clientY;
421
+ const cursorpt = pt.matrixTransform((_c = svg.getScreenCTM()) === null || _c === void 0 ? void 0 : _c.inverse());
422
+ screenCTMRef.current = ((_d = svg.getScreenCTM()) === null || _d === void 0 ? void 0 : _d.inverse()) || null;
423
+ setDragOffset({
424
+ x: cursorpt.x - items.x,
425
+ y: cursorpt.y - items.y,
426
+ });
427
+ // dragOffset.current = {
428
+ // x: cursorpt.x - items.x,
429
+ // y: cursorpt.y - items.y
430
+ // }
431
+ }
432
+ };
433
+ const [isMove, setIsMove] = useState(false);
434
+ const handleTouchMove = (e) => {
435
+ if (activeTool === "select" &&
436
+ moveComponent &&
437
+ isTouching.current &&
438
+ !resizeDirection) {
439
+ setIsDragging(true);
440
+ setIsMove(true);
441
+ const touch = e.touches[0];
442
+ const svg = e.currentTarget.ownerSVGElement;
443
+ if (!svg)
444
+ return;
445
+ const pt = svg.createSVGPoint();
446
+ pt.x = touch.clientX;
447
+ pt.y = touch.clientY;
448
+ const cursorpt = pt.matrixTransform(screenCTMRef.current);
449
+ requestAnimationFrame(() => {
450
+ if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) != "background") {
451
+ setComponentsState((prev) => {
452
+ return prev.map((component) => {
453
+ if (component.id === selectedComponent.id) {
454
+ return Object.assign(Object.assign({}, component), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) });
455
+ }
456
+ return component;
457
+ });
458
+ });
459
+ }
460
+ if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) == "background") {
461
+ setExtraComponentsState((prev) => {
462
+ return prev.map((component) => {
463
+ if (component.id === selectedComponent.id) {
464
+ return Object.assign(Object.assign({}, component), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) });
465
+ }
466
+ return component;
467
+ });
468
+ });
469
+ }
470
+ setSelectedComponent(Object.assign(Object.assign({}, selectedComponent), { x: cursorpt.x - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.x), y: cursorpt.y - (dragOffset === null || dragOffset === void 0 ? void 0 : dragOffset.y) }));
471
+ });
472
+ // updateComponentRef({
473
+ // ...(typeof selectedComponent === "object" && selectedComponent !== null
474
+ // ? selectedComponent
475
+ // : {}),
476
+ // x: cursorpt.x - dragOffset?.current.x,
477
+ // y: cursorpt.y - dragOffset?.current.y,
478
+ // });
479
+ }
480
+ else if (activeTool === "select" &&
481
+ moveComponent &&
482
+ isTouching.current &&
483
+ resizeDirection) {
484
+ setIsDragging(true);
485
+ const touch = e.touches[0];
486
+ const svg = e.currentTarget.ownerSVGElement;
487
+ if (!svg)
488
+ return;
489
+ const pt = svg.createSVGPoint();
490
+ pt.x = touch.clientX;
491
+ pt.y = touch.clientY;
492
+ const cursorpt = pt.matrixTransform(screenCTMRef.current);
493
+ let newShape = Object.assign({}, selectedComponent);
494
+ switch (resizeDirection) {
495
+ case "top-left":
496
+ newShape.width = newShape.width + (newShape.x - cursorpt.x);
497
+ newShape.height = newShape.height + (newShape.y - cursorpt.y);
498
+ newShape.x = cursorpt.x;
499
+ newShape.y = cursorpt.y;
500
+ break;
501
+ case "top-right":
502
+ newShape.width = cursorpt.x - newShape.x;
503
+ newShape.height = newShape.height + (newShape.y - cursorpt.y);
504
+ newShape.y = cursorpt.y;
505
+ break;
506
+ case "bottom-left":
507
+ newShape.width = newShape.width + (newShape.x - cursorpt.x);
508
+ newShape.height = cursorpt.y - newShape.y;
509
+ newShape.x = cursorpt.x;
510
+ break;
511
+ case "bottom-right":
512
+ newShape.width = cursorpt.x - newShape.x;
513
+ newShape.height = cursorpt.y - newShape.y;
514
+ break;
515
+ case "top-center":
516
+ newShape.height = newShape.height + (newShape.y - cursorpt.y);
517
+ newShape.y = cursorpt.y;
518
+ break;
519
+ case "bottom-center":
520
+ newShape.height = cursorpt.y - newShape.y;
521
+ break;
522
+ case "right-center":
523
+ newShape.width = cursorpt.x - newShape.x;
524
+ break;
525
+ case "left-center":
526
+ newShape.width = newShape.width + (newShape.x - cursorpt.x);
527
+ newShape.x = cursorpt.x;
528
+ break;
529
+ default:
530
+ break;
531
+ }
532
+ // updateComponentRef({
533
+ // ...(typeof selectedComponent === "object" && selectedComponent !== null
534
+ // ? selectedComponent
535
+ // : {}),
536
+ // ...newShape,
537
+ // });
538
+ requestAnimationFrame(() => {
539
+ setComponentsState((prev) => {
540
+ return prev.map((component) => {
541
+ if (component.id === selectedComponent.id) {
542
+ return Object.assign(Object.assign({}, component), newShape);
543
+ }
544
+ return component;
545
+ });
546
+ });
547
+ setExtraComponentsState((prev) => {
548
+ return prev.map((component) => {
549
+ if (component.id === selectedComponent.id) {
550
+ return Object.assign(Object.assign({}, component), newShape);
551
+ }
552
+ return component;
553
+ });
554
+ });
555
+ setSelectedComponent(Object.assign(Object.assign({}, selectedComponent), newShape));
556
+ });
557
+ debouncedSyncToReduxSelected(newShape);
558
+ }
559
+ };
560
+ const handleTouchEnd = () => {
561
+ setMoveComponent(false);
562
+ setIsDragging(false);
563
+ isTouching.current = false;
564
+ setResizeDirection(null);
565
+ };
566
+ const getCursorStyle = () => {
567
+ if (activeTool === "select" && moveComponent) {
568
+ return "grabbing";
569
+ }
570
+ else if (activeTool === "select" && resizeDirection) {
571
+ return "grab";
572
+ }
573
+ else if (activeTool === "grab") {
574
+ return "grab";
575
+ }
576
+ };
577
+ const renderMiniMap = () => {
578
+ return (_jsx(MiniMap, { width: 250, height: 250, children: _jsx("div", { className: "w-full h-full", children: _jsx("svg", { id: "workspace", width: "100%", height: "100%", viewBox: `0 0 ${widthBoard} ${heightBoard}`, className: "h-screen w-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
579
+ background: "#f5f5f5",
580
+ display: "block",
581
+ }, children: _jsx(Layers, { shadowShape: shadowShape, components: [...extraComponentsState, ...componentsState], activeTool: activeTool, onClick: handleSelectComponent, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp,
582
+ // onBlur={handleUnSelectComponent}
583
+ selectedComponent: selectedComponent, onTouchStart: (e, item, direction) => handleTouchStart(e, item, direction), onTouchMove: (e) => handleTouchMove(e), onTouchEnd: handleTouchEnd }) }) }) }));
584
+ };
585
+ const handelZoomIn = () => {
586
+ var _a;
587
+ if (activeTool !== "grab") {
588
+ dispatch({
589
+ type: "tool/setActiveTool",
590
+ payload: "grab",
591
+ });
592
+ }
593
+ (_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.zoomIn();
594
+ };
595
+ const handleZoomOut = () => {
596
+ var _a;
597
+ if (activeTool !== "grab") {
598
+ dispatch({
599
+ type: "tool/setActiveTool",
600
+ payload: "grab",
601
+ });
602
+ }
603
+ (_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.zoomOut();
604
+ };
605
+ // activeTool === "select" &&
606
+ // moveComponent &&
607
+ // isTouching.current &&
608
+ // !resizeDirection
609
+ return (_jsxs(_Fragment, { children: [_jsx(ModalPreview, { children: _jsx(LayerView, { statusKey: "status" }) }), _jsxs("div", { className: "relative w-full h-screen flex-1 overflow-hidden", style: {
610
+ cursor: getCursorStyle(),
611
+ }, ref: containerRef, children: [_jsx("div", { className: "absolute bottom-5 left-1/2 transform -translate-x-1/2 z-10", children: _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { icon: _jsx(ZoomIn, {}), onClick: handelZoomIn }), _jsx(Button, { icon: _jsx(ZoomOut, {}), onClick: handleZoomOut })] }) }), _jsxs(TransformWrapper, { ref: transformRef, panning: { disabled: activeTool === "select" }, centerZoomedOut: true, onTransformed: ({ state: { scale } }) => setScale(scale), minScale: 1, maxScale: 1000, initialScale: 1, pinch: { step: 1 }, smooth: true, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, children: [scale > 1 && (_jsx("div", { className: "absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10", children: renderMiniMap() })), _jsx(TransformComponent, { wrapperStyle: {
612
+ width: "100%",
613
+ height: "100%",
614
+ overflow: "hidden",
615
+ }, contentStyle: {
616
+ width: "100%",
617
+ height: "100%",
618
+ }, children: _jsx("svg", { id: "workspace", ref: svgRef, width: "100%", height: "100%", viewBox: `0 0 ${widthBoard} ${heightBoard}`, className: "h-screen", onMouseUp: handleMouseUp, onMouseMove: handleMouseMove, onMouseEnter: handleMouseEnter, onClick: (e) => {
619
+ e.stopPropagation();
620
+ handleMouseClick(e);
621
+ }, onMouseLeave: handleMouseLeave, xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
622
+ background: backgroundColor,
623
+ display: "block",
624
+ }, children: _jsx(Layers, { shadowShape: shadowShape, components: [...extraComponentsState, ...componentsState], onClick: handleSelectComponent, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onBlur: handleUnSelectComponent, selectedComponent: selectedComponent, activeTool: activeTool, onTouchStart: (e, item, direction) => handleTouchStart(e, item, direction), onTouchMove: (e) => handleTouchMove(e), onTouchEnd: handleTouchEnd }) }) })] })] })] }));
625
+ };
626
+ export default BoardTemplate;
@@ -1,2 +1,2 @@
1
- declare const Navbar: () => import("react").JSX.Element;
1
+ declare const Navbar: () => import("react/jsx-runtime").JSX.Element;
2
2
  export default Navbar;
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ const Navbar = () => {
4
+ return _jsx("div", { children: "Navbar" });
5
+ };
6
+ export default Navbar;
@@ -22,5 +22,5 @@ export interface TableEditorProps {
22
22
  };
23
23
  dragOnly?: boolean;
24
24
  }
25
- declare const TableEditor: (props: TableEditorProps) => import("react").JSX.Element;
25
+ declare const TableEditor: (props: TableEditorProps) => import("react/jsx-runtime").JSX.Element;
26
26
  export default TableEditor;