seat-editor 3.5.65 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/app/graph-view/page.d.ts +1 -1
  2. package/dist/app/graph-view-new/page.d.ts +1 -1
  3. package/dist/app/layout.d.ts +1 -1
  4. package/dist/app/new-board/page.d.ts +1 -1
  5. package/dist/app/new-board/page.js +18 -1
  6. package/dist/app/new-board/page.jsx +18 -1
  7. package/dist/app/old-board/page.d.ts +1 -2
  8. package/dist/app/only-view/chair.d.ts +1 -1
  9. package/dist/app/only-view/chair.js +2 -10
  10. package/dist/app/only-view/page.d.ts +1 -1
  11. package/dist/app/only-view/user.d.ts +1 -1
  12. package/dist/app/only-view/user.js +2 -10
  13. package/dist/app/page.d.ts +1 -1
  14. package/dist/app/test/page.d.ts +1 -2
  15. package/dist/app/v2/page.d.ts +1 -1
  16. package/dist/components/button-radio/index.d.ts +11 -0
  17. package/dist/components/button-radio/index.js +19 -0
  18. package/dist/components/button-radio/index.jsx +22 -0
  19. package/dist/components/button-tools/index.d.ts +1 -1
  20. package/dist/components/form-tools/label.d.ts +1 -1
  21. package/dist/components/form-tools/label.js +20 -2
  22. package/dist/components/form-tools/label.jsx +30 -2
  23. package/dist/components/form-tools/shape.d.ts +2 -2
  24. package/dist/components/icons/camera.d.ts +1 -2
  25. package/dist/components/icons/circle.d.ts +1 -2
  26. package/dist/components/icons/square.d.ts +1 -2
  27. package/dist/components/icons/type-1.d.ts +1 -2
  28. package/dist/components/icons/type-2.d.ts +1 -2
  29. package/dist/components/icons/type-3.d.ts +1 -2
  30. package/dist/components/icons/type-4.d.ts +1 -2
  31. package/dist/components/icons/type-5.d.ts +1 -2
  32. package/dist/components/input/number-indicator.d.ts +1 -1
  33. package/dist/components/joystick/index.d.ts +1 -2
  34. package/dist/components/layer/index.d.ts +1 -1
  35. package/dist/components/layer-v2/index.d.ts +1 -1
  36. package/dist/components/layer-v3/index.d.ts +10 -3
  37. package/dist/components/layer-v3/index.js +65 -95
  38. package/dist/components/layer-v3/index.jsx +79 -115
  39. package/dist/components/layer-v4/constant.d.ts +16 -2
  40. package/dist/components/layer-v4/constant.js +57 -12
  41. package/dist/components/layer-v4/index.d.ts +1 -1
  42. package/dist/components/layer-v4/index.js +111 -188
  43. package/dist/components/layer-v4/index.jsx +124 -215
  44. package/dist/components/layer-v5/index.d.ts +1 -1
  45. package/dist/components/lib/index.d.ts +1 -1
  46. package/dist/components/modal-preview/index.d.ts +4 -2
  47. package/dist/components/modal-preview/index.js +12 -2
  48. package/dist/components/modal-preview/index.jsx +13 -3
  49. package/dist/dto/table.d.ts +5 -0
  50. package/dist/features/board/index.d.ts +1 -1
  51. package/dist/features/board-v2/index.d.ts +1 -2
  52. package/dist/features/board-v3/board-slice.d.ts +2 -1
  53. package/dist/features/board-v3/board-slice.js +4 -1
  54. package/dist/features/board-v3/constant.d.ts +5 -1
  55. package/dist/features/board-v3/constant.js +23 -1
  56. package/dist/features/board-v3/index.d.ts +6 -1
  57. package/dist/features/board-v3/index.js +59 -49
  58. package/dist/features/board-v3/index.jsx +105 -68
  59. package/dist/features/board-v3/utils.js +48 -28
  60. package/dist/features/navbar/index.d.ts +1 -1
  61. package/dist/features/package/index.d.ts +6 -1
  62. package/dist/features/package/index.js +1 -1
  63. package/dist/features/package/index.jsx +2 -2
  64. package/dist/features/panel/index.d.ts +1 -1
  65. package/dist/features/panel/index.js +2 -2
  66. package/dist/features/panel/index.jsx +2 -2
  67. package/dist/features/panel/polygon.d.ts +1 -1
  68. package/dist/features/panel/select-tool.d.ts +1 -1
  69. package/dist/features/panel/selected-group.d.ts +1 -1
  70. package/dist/features/panel/selected-group.js +2 -2
  71. package/dist/features/panel/selected-group.jsx +4 -2
  72. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  73. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  74. package/dist/features/panel/table-seat-square.d.ts +1 -1
  75. package/dist/features/panel/text-tool.d.ts +1 -1
  76. package/dist/features/panel/upload-group-tool.d.ts +1 -1
  77. package/dist/features/panel/upload-tool.d.ts +1 -1
  78. package/dist/features/side-tool/icons.d.ts +1 -0
  79. package/dist/features/side-tool/icons.js +2 -0
  80. package/dist/features/side-tool/icons.jsx +6 -0
  81. package/dist/features/side-tool/index.d.ts +7 -2
  82. package/dist/features/side-tool/index.js +31 -3
  83. package/dist/features/side-tool/index.jsx +32 -16
  84. package/dist/features/side-tool/side-tool-slice.d.ts +2 -0
  85. package/dist/features/side-tool/side-tool-slice.js +8 -1
  86. package/dist/features/view-only/index.d.ts +1 -1
  87. package/dist/features/view-only-2/index.d.ts +1 -1
  88. package/dist/features/view-only-3/index.d.ts +1 -1
  89. package/dist/features/view-only-3/index.js +1 -22
  90. package/dist/features/view-only-3/index.jsx +1 -22
  91. package/dist/features/view-only-4/index.d.ts +1 -1
  92. package/dist/features/view-only-5/index.d.ts +1 -1
  93. package/dist/features/view-only-6/index.d.ts +1 -1
  94. package/dist/features/view-only-7/index.d.ts +1 -1
  95. package/dist/provider/antd-provider.js +5 -2
  96. package/dist/provider/antd-provider.jsx +5 -2
  97. package/dist/provider/redux-provider.d.ts +1 -1
  98. package/dist/provider/store-provider.d.ts +1 -1
  99. package/package.json +1 -1
@@ -19,13 +19,23 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
19
19
  }, [selectedGroup, selectedComponent]);
20
20
  const renderShape = (item) => {
21
21
  var _a, _b, _c, _d, _e, _f;
22
- const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, } = item;
22
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, horizontalAlign, verticalAlign, } = item;
23
23
  const commonProps = {
24
24
  fill,
25
25
  opacity,
26
26
  stroke,
27
27
  strokeWidth,
28
28
  };
29
+ const labelProps = {
30
+ labels,
31
+ id,
32
+ width,
33
+ height,
34
+ commonProps,
35
+ horizontalAlign,
36
+ verticalAlign,
37
+ rotation,
38
+ };
29
39
  if (allSelectionId === null || allSelectionId === void 0 ? void 0 : allSelectionId.includes(id)) {
30
40
  commonProps.stroke = "#ffa39e";
31
41
  commonProps.strokeWidth = 4;
@@ -36,16 +46,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
36
46
  }
37
47
  switch (shape) {
38
48
  case "square":
39
- return (_jsx("g", { "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("rect", Object.assign({}, commonProps, { key: id, width: width, height: height, rx: radius })), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
40
- var _a, _b, _c, _d, _e, _f, _g;
41
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
42
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
43
- return (_createElement("text", Object.assign({}, omit(commonProps, [
44
- "opacity",
45
- "stroke",
46
- "strokeWidth",
47
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
48
- }) })] }) }, id));
49
+ return (_jsx("g", { "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("rect", Object.assign({}, commonProps, { key: id, width: width, height: height, rx: radius })), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
49
50
  case "polygon":
50
51
  if (!points)
51
52
  return null;
@@ -65,16 +66,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
65
66
  return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: finalPoint, x: "0", y: "0" })), (showPoints || !isClosed) &&
66
67
  points.map((_, index) => {
67
68
  return (_jsxs(_Fragment, { children: [_jsx("rect", { "data-point": JSON.stringify(_), id: `${index}`, x: (_ === null || _ === void 0 ? void 0 : _.x) - 5, y: (_ === null || _ === void 0 ? void 0 : _.y) - 5, width: 10, height: 10, fill: "#4a90e2", cursor: "pointer" }, `${id}-point-${index}`), _jsx("circle", { "data-point": JSON.stringify(_), id: `${index}`, cx: _ === null || _ === void 0 ? void 0 : _.x, cy: _ === null || _ === void 0 ? void 0 : _.y, r: 15, fill: "transparent", cursor: "pointer" }, `${id}-point-${index - 100}`)] }));
68
- }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${centerX}, ${centerY}) translate(${box === null || box === void 0 ? void 0 : box.x}, ${box === null || box === void 0 ? void 0 : box.y})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
69
- var _a, _b, _c, _d, _e, _f, _g;
70
- const cx = (box === null || box === void 0 ? void 0 : box.width) / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
71
- const cy = (box === null || box === void 0 ? void 0 : box.height) / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
72
- return (_createElement("text", Object.assign({}, omit(commonProps, [
73
- "opacity",
74
- "stroke",
75
- "strokeWidth",
76
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: (box === null || box === void 0 ? void 0 : box.width) / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: (box === null || box === void 0 ? void 0 : box.height) / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
77
- }) })] }) }, id));
69
+ }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${centerX}, ${centerY}) translate(${box === null || box === void 0 ? void 0 : box.x}, ${box === null || box === void 0 ? void 0 : box.y})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
78
70
  case "selection-box":
79
71
  const pointsFormat = rectToPolygonPoints(x, y, width, height);
80
72
  return (_jsx("g", { "data-table": JSON.stringify(item), "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: pointsFormat })), points.map((_, index) => {
@@ -84,16 +76,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
84
76
  return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { key: `${id}-label-${index}`, x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})` }), _ === null || _ === void 0 ? void 0 : _.label));
85
77
  })] }) }, id));
86
78
  case "circle":
87
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps), id), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
88
- var _a, _b, _c, _d, _e, _f, _g;
89
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
90
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
91
- return (_createElement("text", Object.assign({}, omit(commonProps, [
92
- "opacity",
93
- "stroke",
94
- "strokeWidth",
95
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
96
- }) })] }) }, id));
79
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps), id), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
97
80
  case "diamond":
98
81
  return (_jsxs("g", { "data-table": JSON.stringify(item), children: [_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, transform: `rotate(${rotation}, ${x}, ${y})` }, commonProps, { fill: fill }), id), _jsx("text", { x: x + width / 2, y: y + height / 2, fill: fontColor !== null && fontColor !== void 0 ? fontColor : "black", fontSize: `${fontSize !== null && fontSize !== void 0 ? fontSize : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", children: label })] }, id));
99
82
  case "table-seat-circle": {
@@ -116,16 +99,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
116
99
  const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
117
100
  return { cx, cy };
118
101
  });
119
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: fill }, commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", Object.assign({ cx: cx, cy: cy, r: seatRadius, fill: seatFill }, omit(commonProps, ["fill"])), `${id}-seat-${i}`))) }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
120
- var _a, _b, _c, _d, _e, _f, _g;
121
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
122
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
123
- return (_createElement("text", Object.assign({}, omit(commonProps, [
124
- "opacity",
125
- "stroke",
126
- "strokeWidth",
127
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
128
- }) })] }) }, id));
102
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: fill }, commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", Object.assign({ cx: cx, cy: cy, r: seatRadius, fill: seatFill }, omit(commonProps, ["fill"])), `${id}-seat-${i}`))) }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
129
103
  }
130
104
  case "table-seat-rect-circle": {
131
105
  const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
@@ -210,16 +184,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
210
184
  ...leftSeats,
211
185
  ...rightSeats,
212
186
  ];
213
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
214
- var _a, _b, _c, _d, _e, _f, _g;
215
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
216
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
217
- return (_createElement("text", Object.assign({}, omit(commonProps, [
218
- "opacity",
219
- "stroke",
220
- "strokeWidth",
221
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
222
- }) })] }) }, id));
187
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
223
188
  }
224
189
  case "table-seat-square": {
225
190
  const openSpace = item.openSpace || 0; // from 0 to 0.9
@@ -275,16 +240,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
275
240
  cy,
276
241
  id: "right",
277
242
  }));
278
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height }, commonProps, { rx: radius, fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
279
- var _a, _b, _c, _d, _e, _f, _g;
280
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
281
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
282
- return (_createElement("text", Object.assign({}, omit(commonProps, [
283
- "opacity",
284
- "stroke",
285
- "strokeWidth",
286
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
287
- }) })] }) }, id));
243
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height }, commonProps, { rx: radius, fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
288
244
  }
289
245
  case "table-seat-half-square": {
290
246
  const openSpace = item.openSpace || 0;
@@ -344,16 +300,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
344
300
  direction: seat.id,
345
301
  fraction: 0.4,
346
302
  }) })));
347
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
348
- var _a, _b, _c, _d, _e, _f, _g;
349
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
350
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
351
- return (_createElement("text", Object.assign({}, omit(commonProps, [
352
- "opacity",
353
- "stroke",
354
- "strokeWidth",
355
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
356
- }) })] }) }, id));
303
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${0}, ${0})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
357
304
  }
358
305
  case "table-seat-rect-square": {
359
306
  const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
@@ -437,16 +384,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
437
384
  ...leftSeats,
438
385
  ...rightSeats,
439
386
  ];
440
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
441
- var _a, _b, _c, _d, _e, _f, _g;
442
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
443
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
444
- return (_createElement("text", Object.assign({}, omit(commonProps, [
445
- "opacity",
446
- "stroke",
447
- "strokeWidth",
448
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
449
- }) })] }) }, id));
387
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
450
388
  }
451
389
  case "text":
452
390
  return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"]))), _jsx("text", Object.assign({ "data-text-raw": `${id}-text`, x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, [
@@ -456,19 +394,11 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
456
394
  "strokeWidth",
457
395
  ]), { children: text }))] }) }, id));
458
396
  case "image-table":
397
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
459
398
  case "background":
460
399
  return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: {
461
400
  pointerEvents: lockBackground ? "none" : "auto",
462
- }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
463
- var _a, _b, _c, _d, _e, _f, _g;
464
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
465
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
466
- return (_createElement("text", Object.assign({}, omit(commonProps, [
467
- "opacity",
468
- "stroke",
469
- "strokeWidth",
470
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
471
- }) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
401
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
472
402
  case "bounding-box": {
473
403
  const topLine = `${0},${0} ${width},${0}`;
474
404
  const rightLine = `${width},${0} ${width},${height}`;
@@ -494,10 +424,6 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
494
424
  };
495
425
  // let date = new Date();
496
426
  const nodesRaw = rectToPolygonNodes(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.width, selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.height);
497
- // const nodesRawNew = rectToPolygonNodes(
498
- // selectionLinesPoints?.width,
499
- // selectionLinesPoints?.height
500
- // );
501
427
  return (_jsxs("g", { id: "selection-layer", children: [components === null || components === void 0 ? void 0 : components.map(renderShape), !isEmpty(selectionLines) && activeTool === "select" && (_jsxs(_Fragment, { children: [nodesRaw.map((p1, index) => {
502
428
  const p2 = nodesRaw[(index + 2) % nodesRaw.length];
503
429
  const side = index === 0
@@ -536,4 +462,48 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
536
462
  return (_jsxs(React.Fragment, { children: [_jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "transparent", style: { cursor: "pointer" } }, `circle-${index}`), _jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "#4a90e2", id: `circle-corner-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`, style: { cursor: "pointer" } }, `circle-${index}`)] }, `corner-${index}`));
537
463
  }))] }) }, `selection-${Date.now()}`)] }))] }, `${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`));
538
464
  };
465
+ export const LabelItem = ({ id, width, height, labels, commonProps, rotation = 0, }) => {
466
+ // const getEffectiveDimensions = (width: number, height: number, rotation: number) => {
467
+ // const rad = (rotation * Math.PI) / 180;
468
+ // const cos = Math.abs(Math.cos(rad));
469
+ // const sin = Math.abs(Math.sin(rad));
470
+ // return {
471
+ // effectiveWidth: width * cos + height * sin,
472
+ // effectiveHeight: width * sin + height * cos,
473
+ // };
474
+ // };
475
+ const PADDING = 0;
476
+ const getX = (labelX = 0, horizontalAlign = "middle") => {
477
+ // const { effectiveWidth } = getEffectiveDimensions(width, height, rotation);
478
+ if (horizontalAlign === "start")
479
+ return PADDING + labelX;
480
+ if (horizontalAlign === "end")
481
+ return width - PADDING + labelX;
482
+ return width / 2 + labelX;
483
+ };
484
+ const getY = (labelY = 0, verticalAlign = "middle") => {
485
+ // const { effectiveHeight } = getEffectiveDimensions(width, height, rotation);
486
+ if (verticalAlign === "hanging")
487
+ return PADDING + labelY;
488
+ if (verticalAlign === "auto")
489
+ return height - PADDING + labelY;
490
+ return height / 2 + labelY;
491
+ };
492
+ const textAnchorMap = {
493
+ start: "start",
494
+ middle: "middle",
495
+ end: "end",
496
+ };
497
+ const dominantBaselineMap = {
498
+ hanging: "hanging",
499
+ middle: "middle",
500
+ bottom: "auto",
501
+ };
502
+ return (_jsx(_Fragment, { children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
503
+ var _a, _b, _c, _d, _e;
504
+ const x = getX(_ === null || _ === void 0 ? void 0 : _.x, _ === null || _ === void 0 ? void 0 : _.horizontalAlign);
505
+ const y = getY(_ === null || _ === void 0 ? void 0 : _.y, _ === null || _ === void 0 ? void 0 : _.verticalAlign);
506
+ return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { transform: `rotate(${(_a = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _a !== void 0 ? _a : 0}, ${x}, ${y})`, key: `${id}-label-${index}`, x: x, y: y, fill: (_b = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _b !== void 0 ? _b : "black", fontSize: `${(_c = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _c !== void 0 ? _c : 10}px`, fontWeight: "bold", textAnchor: textAnchorMap[(_d = _ === null || _ === void 0 ? void 0 : _.horizontalAlign) !== null && _d !== void 0 ? _d : "middle"], dominantBaseline: dominantBaselineMap[(_e = _ === null || _ === void 0 ? void 0 : _.verticalAlign) !== null && _e !== void 0 ? _e : "middle"] }), _ === null || _ === void 0 ? void 0 : _.label));
507
+ }) }));
508
+ };
539
509
  export default Layers;
@@ -17,13 +17,23 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
17
17
  }, [selectedGroup, selectedComponent]);
18
18
  const renderShape = (item) => {
19
19
  var _a, _b, _c, _d, _e, _f;
20
- const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, } = item;
20
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, horizontalAlign, verticalAlign, } = item;
21
21
  const commonProps = {
22
22
  fill,
23
23
  opacity,
24
24
  stroke,
25
25
  strokeWidth,
26
26
  };
27
+ const labelProps = {
28
+ labels,
29
+ id,
30
+ width,
31
+ height,
32
+ commonProps,
33
+ horizontalAlign,
34
+ verticalAlign,
35
+ rotation,
36
+ };
27
37
  if (allSelectionId === null || allSelectionId === void 0 ? void 0 : allSelectionId.includes(id)) {
28
38
  commonProps.stroke = "#ffa39e";
29
39
  commonProps.strokeWidth = 4;
@@ -38,18 +48,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
38
48
  <g transform={`rotate(${rotation}, 0, 0)`}>
39
49
  <rect {...commonProps} key={id} width={width} height={height} rx={radius}/>
40
50
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
41
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
42
- var _a, _b, _c, _d, _e, _f, _g;
43
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
44
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
45
- return (<text {...omit(commonProps, [
46
- "opacity",
47
- "stroke",
48
- "strokeWidth",
49
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
50
- {_ === null || _ === void 0 ? void 0 : _.label}
51
- </text>);
52
- })}
51
+ <LabelItem {...labelProps}/>
53
52
  </g>
54
53
  </g>
55
54
  </g>);
@@ -80,18 +79,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
80
79
  </>);
81
80
  })}
82
81
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${centerX}, ${centerY}) translate(${box === null || box === void 0 ? void 0 : box.x}, ${box === null || box === void 0 ? void 0 : box.y})`}>
83
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
84
- var _a, _b, _c, _d, _e, _f, _g;
85
- const cx = (box === null || box === void 0 ? void 0 : box.width) / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
86
- const cy = (box === null || box === void 0 ? void 0 : box.height) / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
87
- return (<text {...omit(commonProps, [
88
- "opacity",
89
- "stroke",
90
- "strokeWidth",
91
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={(box === null || box === void 0 ? void 0 : box.width) / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={(box === null || box === void 0 ? void 0 : box.height) / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
92
- {_ === null || _ === void 0 ? void 0 : _.label}
93
- </text>);
94
- })}
82
+ <LabelItem {...labelProps}/>
95
83
  </g>
96
84
  </g>
97
85
  </g>);
@@ -117,18 +105,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
117
105
  <g transform={`rotate(${rotation}, 0, 0)`}>
118
106
  <circle key={id} cx={width / 2} cy={height / 2} r={Math.min(height, width) / 2} fill={fill} {...commonProps}/>
119
107
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
120
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
121
- var _a, _b, _c, _d, _e, _f, _g;
122
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
123
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
124
- return (<text {...omit(commonProps, [
125
- "opacity",
126
- "stroke",
127
- "strokeWidth",
128
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
129
- {_ === null || _ === void 0 ? void 0 : _.label}
130
- </text>);
131
- })}
108
+ <LabelItem {...labelProps}/>
132
109
  </g>
133
110
  </g>
134
111
  </g>);
@@ -169,18 +146,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
169
146
  </g>
170
147
 
171
148
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
172
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
173
- var _a, _b, _c, _d, _e, _f, _g;
174
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
175
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
176
- return (<text {...omit(commonProps, [
177
- "opacity",
178
- "stroke",
179
- "strokeWidth",
180
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
181
- {_ === null || _ === void 0 ? void 0 : _.label}
182
- </text>);
183
- })}
149
+ <LabelItem {...labelProps}/>
184
150
  </g>
185
151
  </g>
186
152
  </g>);
@@ -276,18 +242,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
276
242
  {seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (<rect x={x} y={y} key={`${id}-seat-${i}`} id={`seat-${id}`} height={height} width={width} rx={radius / 4} fill={seatFill}/>))}
277
243
  </g>
278
244
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
279
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
280
- var _a, _b, _c, _d, _e, _f, _g;
281
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
282
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
283
- return (<text {...omit(commonProps, [
284
- "opacity",
285
- "stroke",
286
- "strokeWidth",
287
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
288
- {_ === null || _ === void 0 ? void 0 : _.label}
289
- </text>);
290
- })}
245
+ <LabelItem {...labelProps}/>
291
246
  </g>
292
247
  </g>
293
248
  </g>);
@@ -355,18 +310,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
355
310
  {[...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (<circle key={`${id}-seat-${i}`} id={`seat-${id}`} cx={cx} cy={cy} r={r} fill={seatFill}/>))}
356
311
  </g>
357
312
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
358
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
359
- var _a, _b, _c, _d, _e, _f, _g;
360
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
361
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
362
- return (<text {...omit(commonProps, [
363
- "opacity",
364
- "stroke",
365
- "strokeWidth",
366
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
367
- {_ === null || _ === void 0 ? void 0 : _.label}
368
- </text>);
369
- })}
313
+ <LabelItem {...labelProps}/>
370
314
  </g>
371
315
  </g>
372
316
  </g>);
@@ -433,22 +377,11 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
433
377
  <g transform={`rotate(${rotation}, 0, 0)`}>
434
378
  {/* Seats */}
435
379
  <rect width={width} height={height} rx={radius} {...commonProps} fill={fill}/>
436
- <g key={`${id}-seats`} data-seat={`${id}-seats`}>
380
+ <g key={`${id}-seats`} data-seat={`${id}-seats`} transform={`translate(${0}, ${0})`}>
437
381
  {seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (<path key={`${id}-seat-${i}`} id={`seat-${id}`} d={d} fill={seatFill}/>))}
438
382
  </g>
439
383
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
440
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
441
- var _a, _b, _c, _d, _e, _f, _g;
442
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
443
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
444
- return (<text {...omit(commonProps, [
445
- "opacity",
446
- "stroke",
447
- "strokeWidth",
448
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
449
- {_ === null || _ === void 0 ? void 0 : _.label}
450
- </text>);
451
- })}
384
+ <LabelItem {...labelProps}/>
452
385
  </g>
453
386
  </g>
454
387
  </g>);
@@ -543,18 +476,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
543
476
  {seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (<rect x={x} y={y} key={`${id}-seat-${i}`} id={`seat-${id}`} height={height} width={width} rx={radius / 4} fill={seatFill}/>))}
544
477
  </g>
545
478
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
546
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
547
- var _a, _b, _c, _d, _e, _f, _g;
548
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
549
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
550
- return (<text {...omit(commonProps, [
551
- "opacity",
552
- "stroke",
553
- "strokeWidth",
554
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
555
- {_ === null || _ === void 0 ? void 0 : _.label}
556
- </text>);
557
- })}
479
+ <LabelItem {...labelProps}/>
558
480
  </g>
559
481
  </g>
560
482
  </g>);
@@ -574,6 +496,15 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
574
496
  </g>
575
497
  </g>);
576
498
  case "image-table":
499
+ return (<g key={id} id={`${id}`} data-id={id} transform={`translate(${x}, ${y})`}>
500
+ <g transform={`rotate(${rotation}, 0, 0)`}>
501
+ <image href={src} width={width} height={height}/>
502
+ <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
503
+ <LabelItem {...labelProps}/>
504
+ </g>
505
+ <rect width={width} height={height} fill="transparent" opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}/>
506
+ </g>
507
+ </g>);
577
508
  case "background":
578
509
  return (<g key={id} id={`${id}`} data-id={id} transform={`translate(${x}, ${y})`} style={{
579
510
  pointerEvents: lockBackground ? "none" : "auto",
@@ -581,18 +512,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
581
512
  <g transform={`rotate(${rotation}, 0, 0)`}>
582
513
  <image href={src} width={width} height={height}/>
583
514
  <g data-text={`${id}-text`} transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
584
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
585
- var _a, _b, _c, _d, _e, _f, _g;
586
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
587
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
588
- return (<text {...omit(commonProps, [
589
- "opacity",
590
- "stroke",
591
- "strokeWidth",
592
- ])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
593
- {_ === null || _ === void 0 ? void 0 : _.label}
594
- </text>);
595
- })}
515
+ <LabelItem {...labelProps}/>
596
516
  </g>
597
517
  <rect width={width} height={height} fill="transparent" opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}/>
598
518
  </g>
@@ -632,10 +552,6 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
632
552
  };
633
553
  // let date = new Date();
634
554
  const nodesRaw = rectToPolygonNodes(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.width, selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.height);
635
- // const nodesRawNew = rectToPolygonNodes(
636
- // selectionLinesPoints?.width,
637
- // selectionLinesPoints?.height
638
- // );
639
555
  return (<g key={`${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`} id="selection-layer">
640
556
  {components === null || components === void 0 ? void 0 : components.map(renderShape)}
641
557
  {!isEmpty(selectionLines) && activeTool === "select" && (<>
@@ -691,11 +607,59 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
691
607
  return (<React.Fragment key={`corner-${index}`}>
692
608
  <circle data-position={corner(index)} key={`circle-${index}`} r={5} cx={node.x} cy={node.y} fill="transparent" style={{ cursor: "pointer" }}/>
693
609
  <circle data-position={corner(index)} key={`circle-${index}`} r={5} cx={node.x} cy={node.y} fill="#4a90e2" id={`circle-corner-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`} style={{ cursor: "pointer" }}/>
694
- </React.Fragment>);
610
+ </React.Fragment>);
695
611
  }))}
696
612
  </g>
697
613
  </g>
698
614
  </>)}
699
615
  </g>);
700
616
  };
617
+ export const LabelItem = ({ id, width, height, labels, commonProps, rotation = 0, }) => {
618
+ // const getEffectiveDimensions = (width: number, height: number, rotation: number) => {
619
+ // const rad = (rotation * Math.PI) / 180;
620
+ // const cos = Math.abs(Math.cos(rad));
621
+ // const sin = Math.abs(Math.sin(rad));
622
+ // return {
623
+ // effectiveWidth: width * cos + height * sin,
624
+ // effectiveHeight: width * sin + height * cos,
625
+ // };
626
+ // };
627
+ const PADDING = 0;
628
+ const getX = (labelX = 0, horizontalAlign = "middle") => {
629
+ // const { effectiveWidth } = getEffectiveDimensions(width, height, rotation);
630
+ if (horizontalAlign === "start")
631
+ return PADDING + labelX;
632
+ if (horizontalAlign === "end")
633
+ return width - PADDING + labelX;
634
+ return width / 2 + labelX;
635
+ };
636
+ const getY = (labelY = 0, verticalAlign = "middle") => {
637
+ // const { effectiveHeight } = getEffectiveDimensions(width, height, rotation);
638
+ if (verticalAlign === "hanging")
639
+ return PADDING + labelY;
640
+ if (verticalAlign === "auto")
641
+ return height - PADDING + labelY;
642
+ return height / 2 + labelY;
643
+ };
644
+ const textAnchorMap = {
645
+ start: "start",
646
+ middle: "middle",
647
+ end: "end",
648
+ };
649
+ const dominantBaselineMap = {
650
+ hanging: "hanging",
651
+ middle: "middle",
652
+ bottom: "auto",
653
+ };
654
+ return (<>
655
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
656
+ var _a, _b, _c, _d, _e;
657
+ const x = getX(_ === null || _ === void 0 ? void 0 : _.x, _ === null || _ === void 0 ? void 0 : _.horizontalAlign);
658
+ const y = getY(_ === null || _ === void 0 ? void 0 : _.y, _ === null || _ === void 0 ? void 0 : _.verticalAlign);
659
+ return (<text {...omit(commonProps, ["opacity", "stroke", "strokeWidth"])} transform={`rotate(${(_a = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _a !== void 0 ? _a : 0}, ${x}, ${y})`} key={`${id}-label-${index}`} x={x} y={y} fill={(_b = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _b !== void 0 ? _b : "black"} fontSize={`${(_c = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _c !== void 0 ? _c : 10}px`} fontWeight="bold" textAnchor={textAnchorMap[(_d = _ === null || _ === void 0 ? void 0 : _.horizontalAlign) !== null && _d !== void 0 ? _d : "middle"]} dominantBaseline={dominantBaselineMap[(_e = _ === null || _ === void 0 ? void 0 : _.verticalAlign) !== null && _e !== void 0 ? _e : "middle"]}>
660
+ {_ === null || _ === void 0 ? void 0 : _.label}
661
+ </text>);
662
+ })}
663
+ </>);
664
+ };
701
665
  export default Layers;