seat-editor 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/layout.d.ts +1 -1
- package/dist/app/{layout.js → layout.jsx} +7 -2
- package/dist/app/new-board/page.d.ts +1 -1
- package/dist/app/new-board/page.jsx +55 -0
- package/dist/app/old-board/page.d.ts +2 -1
- package/dist/app/old-board/{page.js → page.jsx} +215 -82
- package/dist/app/only-view/chair.d.ts +1 -1
- package/dist/app/only-view/chair.js +10 -2
- package/dist/app/only-view/page.d.ts +1 -1
- package/dist/app/only-view/page.jsx +101 -0
- package/dist/app/only-view/user.d.ts +1 -1
- package/dist/app/only-view/user.js +10 -2
- package/dist/app/page.d.ts +1 -1
- package/dist/app/page.jsx +13 -0
- package/dist/app/test/page.d.ts +2 -1
- package/dist/app/test/{page.js → page.jsx} +5 -3
- package/dist/app/v2/page.d.ts +1 -1
- package/dist/app/v2/page.jsx +13 -0
- package/dist/components/button-tools/index.d.ts +1 -1
- package/dist/components/button-tools/index.jsx +17 -0
- package/dist/components/form-tools/label.d.ts +1 -1
- package/dist/components/form-tools/label.jsx +44 -0
- package/dist/components/form-tools/shape.d.ts +1 -1
- package/dist/components/form-tools/shape.jsx +66 -0
- package/dist/components/input/number-indicator.d.ts +1 -1
- package/dist/components/input/{number-indicator.js → number-indicator.jsx} +11 -2
- package/dist/components/joystick/index.d.ts +2 -1
- package/dist/components/joystick/{index.js → index.jsx} +14 -13
- package/dist/components/layer/index.d.ts +1 -1
- package/dist/components/layer/index.jsx +383 -0
- package/dist/components/layer-v2/index.d.ts +1 -1
- package/dist/components/layer-v2/index.jsx +370 -0
- package/dist/components/layer-v3/index.d.ts +1 -1
- package/dist/components/layer-v3/{index.js → index.jsx} +242 -102
- package/dist/components/layer-v4/index.d.ts +1 -1
- package/dist/components/layer-v4/{index.js → index.jsx} +157 -80
- package/dist/components/lib/index.d.ts +1 -1
- package/dist/components/lib/{index.js → index.jsx} +7 -2
- package/dist/components/modal-preview/index.d.ts +1 -1
- package/dist/components/modal-preview/index.jsx +11 -0
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/board/{index.js → index.jsx} +90 -31
- package/dist/features/board-v2/index.d.ts +2 -1
- package/dist/features/board-v2/{index.js → index.jsx} +101 -39
- package/dist/features/board-v3/index copy.d.ts +2 -1
- package/dist/features/board-v3/{index copy.js → index copy.jsx } +128 -50
- package/dist/features/board-v3/index.d.ts +2 -1
- package/dist/features/board-v3/{index.js → index.jsx} +110 -32
- package/dist/features/navbar/index.d.ts +1 -1
- package/dist/features/navbar/index.jsx +5 -0
- package/dist/features/package/index.d.ts +1 -1
- package/dist/features/package/{index.js → index.jsx} +16 -6
- package/dist/features/panel/index.d.ts +1 -1
- package/dist/features/panel/{index.js → index.jsx} +25 -7
- package/dist/features/panel/select-tool.d.ts +1 -1
- package/dist/features/panel/{select-tool.js → select-tool.jsx} +23 -10
- package/dist/features/panel/selected-group.d.ts +1 -1
- package/dist/features/panel/selected-group.jsx +47 -0
- package/dist/features/panel/square-circle-tool.d.ts +1 -1
- package/dist/features/panel/{square-circle-tool.js → square-circle-tool.jsx} +4 -2
- package/dist/features/panel/table-seat-circle.d.ts +1 -1
- package/dist/features/panel/table-seat-circle.jsx +31 -0
- package/dist/features/panel/table-seat-square.d.ts +1 -1
- package/dist/features/panel/table-seat-square.jsx +46 -0
- package/dist/features/panel/text-tool.d.ts +1 -1
- package/dist/features/panel/text-tool.jsx +26 -0
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/{upload-tool.js → upload-tool.jsx} +24 -2
- package/dist/features/side-tool/index.d.ts +1 -1
- package/dist/features/side-tool/{index.js → index.jsx} +120 -98
- package/dist/features/view-only/index.d.ts +1 -1
- package/dist/features/view-only/{index.js → index.jsx} +38 -31
- package/dist/features/view-only-2/index.d.ts +1 -1
- package/dist/features/view-only-2/{index.js → index.jsx} +16 -13
- package/dist/features/view-only-3/index.d.ts +1 -1
- package/dist/features/view-only-3/{index.js → index.jsx} +46 -27
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/provider/antd-provider.jsx +46 -0
- package/dist/provider/redux-provider.d.ts +1 -1
- package/dist/provider/{redux-provider.js → redux-provider.jsx} +1 -2
- package/dist/provider/store-provider.d.ts +1 -1
- package/dist/provider/{store-provider.js → store-provider.jsx} +3 -2
- package/package.json +1 -1
- package/dist/app/new-board/page.js +0 -33
- package/dist/app/only-view/page.js +0 -78
- package/dist/app/page.js +0 -8
- package/dist/app/v2/page.js +0 -8
- package/dist/components/button-tools/index.js +0 -11
- package/dist/components/form-tools/label.js +0 -7
- package/dist/components/form-tools/shape.js +0 -25
- package/dist/components/layer/index.js +0 -295
- package/dist/components/layer-v2/index.js +0 -282
- package/dist/components/modal-preview/index.js +0 -10
- package/dist/features/navbar/index.js +0 -6
- package/dist/features/panel/selected-group.js +0 -7
- package/dist/features/panel/table-seat-circle.js +0 -9
- package/dist/features/panel/table-seat-square.js +0 -9
- package/dist/features/panel/text-tool.js +0 -7
- package/dist/provider/antd-provider.js +0 -43
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createElement as _createElement } from "react";
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
2
|
import { useRef } from "react";
|
|
5
3
|
import { isArray, isEmpty, omit } from "lodash";
|
|
6
4
|
const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style, selectionLines, }) => {
|
|
@@ -33,11 +31,11 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
33
31
|
const pointsFormat = !isEmpty(points)
|
|
34
32
|
? points
|
|
35
33
|
: rectToPolygonPoints(x, y, width, height);
|
|
36
|
-
return
|
|
34
|
+
return <polygon key={id} points={pointsFormat} {...commonProps}/>;
|
|
37
35
|
case "circle":
|
|
38
|
-
return (
|
|
36
|
+
return (<circle key={id} cx={x + width / 2} cy={y + height / 2} r={Math.min(height, width) / 2} {...commonProps}/>);
|
|
39
37
|
case "diamond":
|
|
40
|
-
return (
|
|
38
|
+
return (<rect key={id} x={x} y={y} width={width} height={height} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps}/>);
|
|
41
39
|
case "table-seat-circle": {
|
|
42
40
|
const seatCount = item.seatCount;
|
|
43
41
|
const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0.2;
|
|
@@ -58,13 +56,26 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
58
56
|
const cy = centerY + (radius - inset) * Math.sin(angle);
|
|
59
57
|
return { cx, cy };
|
|
60
58
|
});
|
|
61
|
-
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
return (<g key={id} transform={`rotate(${rotation} ${centerX} ${centerY})`}>
|
|
60
|
+
{/* Meja */}
|
|
61
|
+
<circle cx={centerX} cy={centerY} r={radius - 15} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...commonProps}/>
|
|
62
|
+
|
|
63
|
+
{/* Label */}
|
|
64
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
65
|
+
var _a, _b, _c, _d;
|
|
66
|
+
return (<text key={`${id}-label-${index}`} x={centerX + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={centerY + ((_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} ${centerX} ${centerY})`} onClick={(e) => {
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
onClick && onClick(item);
|
|
69
|
+
}}>
|
|
70
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
71
|
+
</text>);
|
|
72
|
+
})}
|
|
73
|
+
|
|
74
|
+
{/* Kursi */}
|
|
75
|
+
<g fill="#e6b9c0" stroke="#c49ba3" strokeWidth="1">
|
|
76
|
+
{seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
|
|
77
|
+
</g>
|
|
78
|
+
</g>);
|
|
68
79
|
}
|
|
69
80
|
case "table-seat-square": {
|
|
70
81
|
const seatCount = item.seatCount || 6;
|
|
@@ -84,14 +95,29 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
84
95
|
cx: startX + i * spacing,
|
|
85
96
|
cy: y + height + seatRadius * 1.5,
|
|
86
97
|
}));
|
|
87
|
-
return (
|
|
98
|
+
return (<g key={id}>
|
|
99
|
+
{/* Seats */}
|
|
100
|
+
<g fill="#e6b9c0" fillOpacity="0.5" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
|
|
101
|
+
{[...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius}/>))}
|
|
102
|
+
</g>
|
|
103
|
+
{/* Square Table */}
|
|
104
|
+
<rect x={x} y={y} width={width} height={height} {...commonProps}/>
|
|
105
|
+
</g>);
|
|
88
106
|
}
|
|
89
107
|
case "text":
|
|
90
|
-
return (
|
|
108
|
+
return (<g key={id} onClick={() => {
|
|
91
109
|
onClick && onClick(item);
|
|
92
|
-
}
|
|
110
|
+
}}>
|
|
111
|
+
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
112
|
+
<text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={height * 0.6} opacity={opacity}>
|
|
113
|
+
{text}
|
|
114
|
+
</text>
|
|
115
|
+
</g>);
|
|
93
116
|
case "ruler":
|
|
94
|
-
return (
|
|
117
|
+
return (<g key={id}>
|
|
118
|
+
<rect x={x - (window.innerWidth * 3) / 2} y={y} width={window.innerWidth * 3} height={1} fill="black"/>
|
|
119
|
+
<rect x={x} y={y - (window.innerHeight * 3) / 2} width={1} height={window.innerHeight * 3} fill="black"/>
|
|
120
|
+
</g>);
|
|
95
121
|
default:
|
|
96
122
|
return null;
|
|
97
123
|
}
|
|
@@ -150,15 +176,22 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
150
176
|
};
|
|
151
177
|
switch (shape) {
|
|
152
178
|
case "square":
|
|
153
|
-
return (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
return (<g key={id} data-id={id}
|
|
180
|
+
// data-table={JSON.stringify(item)}
|
|
181
|
+
transform={`translate(${x}, ${y})`} stroke="red">
|
|
182
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
183
|
+
<rect {...commonProps} key={id} width={width} height={height}/>
|
|
184
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
185
|
+
var _a, _b, _c, _d;
|
|
186
|
+
return (<text {...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})`} onClick={(e) => {
|
|
187
|
+
e.stopPropagation();
|
|
188
|
+
onClick && onClick(item);
|
|
189
|
+
}}>
|
|
190
|
+
{_ === null || _ === void 0 ? void 0 : _.text}
|
|
191
|
+
</text>);
|
|
192
|
+
})}
|
|
193
|
+
</g>
|
|
194
|
+
</g>);
|
|
162
195
|
case "polygon":
|
|
163
196
|
function isPolygonClosed(points) {
|
|
164
197
|
if (points.length < 3)
|
|
@@ -171,31 +204,55 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
171
204
|
const isClosed = isPolygonClosed(points);
|
|
172
205
|
console.log({ isClosed });
|
|
173
206
|
const showPoints = (selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.id) == id;
|
|
174
|
-
return (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
207
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
208
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
209
|
+
<polygon {...commonProps} key={id} points={finalPoint} x="0" y="0"/>
|
|
210
|
+
{(showPoints || !isClosed) &&
|
|
211
|
+
points.map((_, index) => {
|
|
212
|
+
return (<>
|
|
213
|
+
<rect data-point={JSON.stringify(_)} id={`${index}`} key={`${id}-point-${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"}/>
|
|
214
|
+
<circle data-point={JSON.stringify(_)} id={`${index}`} key={`${id}-point-${index}`} cx={_ === null || _ === void 0 ? void 0 : _.x} cy={_ === null || _ === void 0 ? void 0 : _.y} r={15} fill="transparent" cursor={"pointer"}/>
|
|
215
|
+
</>);
|
|
216
|
+
})}
|
|
217
|
+
</g>
|
|
218
|
+
</g>);
|
|
178
219
|
case "selection-box":
|
|
179
220
|
const pointsFormat = !isEmpty(points)
|
|
180
221
|
? points
|
|
181
222
|
: rectToPolygonPoints(x, y, width, height);
|
|
182
|
-
return (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
223
|
+
return (<g key={id} data-table={JSON.stringify(item)} data-id={id}>
|
|
224
|
+
<g transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
|
|
225
|
+
<polygon {...commonProps} key={id} points={pointsFormat}/>
|
|
226
|
+
{/* circle every points */}
|
|
227
|
+
{points.map((_, index) => {
|
|
228
|
+
return (<rect key={`${id}-point-${index}`} x={(_ === null || _ === void 0 ? void 0 : _.x) - 5} y={(_ === null || _ === void 0 ? void 0 : _.y) - 5} width={10} height={10} fill="blue"/>);
|
|
229
|
+
})}
|
|
230
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
231
|
+
var _a, _b, _c, _d;
|
|
232
|
+
return (<text {...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})`} onClick={(e) => {
|
|
233
|
+
e.stopPropagation();
|
|
234
|
+
onClick && onClick(item);
|
|
235
|
+
}}>
|
|
236
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
237
|
+
</text>);
|
|
238
|
+
})}
|
|
239
|
+
</g>
|
|
240
|
+
</g>);
|
|
191
241
|
case "circle":
|
|
192
|
-
return (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
242
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
243
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
244
|
+
<circle key={id} cx={width / 2} cy={height / 2} r={Math.min(height, width) / 2} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...omit(commonProps, "opacity")}/>
|
|
245
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
246
|
+
var _a, _b, _c, _d;
|
|
247
|
+
return (<text key={`${id}-label-${index}`} x={width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={width / 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})`} onClick={(e) => {
|
|
248
|
+
e.stopPropagation();
|
|
249
|
+
onClick && onClick(item);
|
|
250
|
+
}}>
|
|
251
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
252
|
+
</text>);
|
|
253
|
+
})}
|
|
254
|
+
</g>
|
|
255
|
+
</g>);
|
|
199
256
|
// case "elipse":
|
|
200
257
|
// return (
|
|
201
258
|
// <g
|
|
@@ -245,7 +302,12 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
245
302
|
// </g>
|
|
246
303
|
// );
|
|
247
304
|
case "diamond":
|
|
248
|
-
return (
|
|
305
|
+
return (<g key={id} data-table={JSON.stringify(item)}>
|
|
306
|
+
<rect key={id} x={x} y={y} width={width} height={height} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
|
|
307
|
+
<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">
|
|
308
|
+
{label}
|
|
309
|
+
</text>
|
|
310
|
+
</g>);
|
|
249
311
|
case "table-seat-circle": {
|
|
250
312
|
const seatCount = item.seatCount;
|
|
251
313
|
const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
|
|
@@ -266,13 +328,27 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
266
328
|
const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
|
|
267
329
|
return { cx, cy };
|
|
268
330
|
});
|
|
269
|
-
return (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
331
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
332
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
333
|
+
{/* Meja */}
|
|
334
|
+
<circle cx={centerX} cy={centerY} r={tableRadius} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...commonProps}/>
|
|
335
|
+
{/* Seat */}
|
|
336
|
+
<g data-seat={`${id}-seats`}>
|
|
337
|
+
{seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
|
|
338
|
+
</g>
|
|
339
|
+
|
|
340
|
+
{/* Label */}
|
|
341
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
342
|
+
var _a, _b, _c, _d;
|
|
343
|
+
return (<text key={`${id}-label-${index}`} x={centerX + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={centerY + ((_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} ${centerX} ${centerY})`} onClick={(e) => {
|
|
344
|
+
e.stopPropagation();
|
|
345
|
+
onClick && onClick(item);
|
|
346
|
+
}}>
|
|
347
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
348
|
+
</text>);
|
|
349
|
+
})}
|
|
350
|
+
</g>
|
|
351
|
+
</g>);
|
|
276
352
|
}
|
|
277
353
|
case "table-seat-square": {
|
|
278
354
|
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
@@ -328,7 +404,20 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
328
404
|
cy,
|
|
329
405
|
id: "right",
|
|
330
406
|
}));
|
|
331
|
-
return (
|
|
407
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
408
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
409
|
+
{/* Square Table */}
|
|
410
|
+
<rect width={width} height={height} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
|
|
411
|
+
{/* Seats */}
|
|
412
|
+
<g fill="#e6b9c0" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`} data-seat={`${id}-seats`} transform={`translate(${-x}, ${-y})`}>
|
|
413
|
+
{[...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}/>))}
|
|
414
|
+
</g>
|
|
415
|
+
|
|
416
|
+
<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">
|
|
417
|
+
{label}
|
|
418
|
+
</text>
|
|
419
|
+
</g>
|
|
420
|
+
</g>);
|
|
332
421
|
}
|
|
333
422
|
case "table-seat-square-side": {
|
|
334
423
|
const seatRadius = Math.min(width, height) * 0.15;
|
|
@@ -390,23 +479,49 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
390
479
|
// cy: y + height / 2,
|
|
391
480
|
// },
|
|
392
481
|
// ];
|
|
393
|
-
return (
|
|
482
|
+
return (<g key={id} transform={`translate(${x}, ${y}) )`} data-id={id}>
|
|
483
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
484
|
+
{/* Seats */}
|
|
485
|
+
{/* Square Table */}
|
|
486
|
+
<rect x={x} y={y} width={width} height={height} rx={10} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
|
|
487
|
+
<g>
|
|
488
|
+
{seats === null || seats === void 0 ? void 0 : seats.map(({ d }, i) => (<path key={`${id}-seat-${i}`} id={`seat-${id}`} d={d} fill="white"/>))}
|
|
489
|
+
</g>
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
{/* Label */}
|
|
494
|
+
<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">
|
|
495
|
+
{label}
|
|
496
|
+
</text>
|
|
497
|
+
</g>
|
|
498
|
+
</g>);
|
|
394
499
|
}
|
|
395
500
|
case "text":
|
|
396
|
-
return (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
501
|
+
return (<g key={id} data-table={JSON.stringify(item)}>
|
|
502
|
+
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity} onClick={(e) => {
|
|
503
|
+
e.stopPropagation();
|
|
504
|
+
onClick && onClick(item);
|
|
505
|
+
}}/>
|
|
506
|
+
<text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
507
|
+
{text}
|
|
508
|
+
</text>
|
|
509
|
+
</g>);
|
|
400
510
|
case "image-table":
|
|
401
511
|
case "background":
|
|
402
|
-
return (
|
|
512
|
+
return (<g key={id} onClick={() => {
|
|
403
513
|
onClick && onClick(item);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
514
|
+
}} data-table={JSON.stringify(item)}>
|
|
515
|
+
<image href={src} x={x} y={y} width={width} height={height} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} {...commonProps}/>
|
|
516
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
517
|
+
var _a, _b, _c, _d;
|
|
518
|
+
return (<text key={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})`}>
|
|
519
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
520
|
+
</text>);
|
|
521
|
+
})}
|
|
522
|
+
</g>);
|
|
408
523
|
default:
|
|
409
|
-
return
|
|
524
|
+
return <g key={id}/>;
|
|
410
525
|
}
|
|
411
526
|
};
|
|
412
527
|
let date = new Date();
|
|
@@ -417,43 +532,68 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
417
532
|
const polylinePoints = [...nodesRaw, nodesRaw[0]]
|
|
418
533
|
.map((n) => `${n.x},${n.y}`)
|
|
419
534
|
.join(" ");
|
|
420
|
-
return (
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
535
|
+
return (<g key={`${date}`} id="selection-layer">
|
|
536
|
+
{components === null || components === void 0 ? void 0 : components.map(renderShape)}
|
|
537
|
+
{shadowShape === null || shadowShape === void 0 ? void 0 : shadowShape.map(renderShadowShape)}
|
|
538
|
+
{!isEmpty(selectionLines) && activeTool === "select" && (<>
|
|
539
|
+
{nodesRaw.map((p1, index) => {
|
|
540
|
+
const p2 = nodesRaw[(index + 2) % nodesRaw.length];
|
|
541
|
+
const side = index === 0
|
|
542
|
+
? "top"
|
|
543
|
+
: index === 1
|
|
544
|
+
? "right"
|
|
545
|
+
: index === 2
|
|
546
|
+
? "bottom"
|
|
547
|
+
: "left";
|
|
548
|
+
const mx = (p1.x + p2.x) / 2;
|
|
549
|
+
const my = (p1.y + p2.y) / 2;
|
|
550
|
+
if (side === "top")
|
|
551
|
+
return (<g key={`selection-${date}`} id="help-group-0" data-selection={`selection-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`} transform={`translate(${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.x},${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.y})`}>
|
|
552
|
+
<g transform={`rotate(${(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.rotation) || 0}, 0,0)`}>
|
|
553
|
+
{side === "top" && (<g id="help-group-1">
|
|
554
|
+
<line x1={mx} y1={my + selectionLines.height / 2} x2={mx} y2={my - selectionLines.height / 3 - 10} // panjang line
|
|
555
|
+
stroke="#4a90e2" strokeWidth={2} id="line-help"/>
|
|
556
|
+
|
|
557
|
+
<circle id="circle-help" data-role="rotate" cx={mx} cy={my - selectionLines.height / 3 - 10} r={8} fill="#4a90e2"/>
|
|
558
|
+
</g>)}
|
|
559
|
+
</g>
|
|
560
|
+
</g>);
|
|
561
|
+
})}
|
|
562
|
+
<g key={`selection-${date}`} id="selection-lines" data-selection={`selection-${(_a = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) !== null && _a !== void 0 ? _a : selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.id}`} transform={`translate(${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.x},${selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.y})`}>
|
|
563
|
+
<g transform={`rotate(${(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.rotation) || 0}, 0,0)`}>
|
|
564
|
+
{!hasPoints && (<rect width={selectionLines.width} height={selectionLines.height} fill="none" stroke="#4a90e2" strokeWidth={1} id="rect-box-selection"/>)}
|
|
565
|
+
|
|
566
|
+
{!hasPoints &&
|
|
567
|
+
(nodesRaw === null || nodesRaw === void 0 ? void 0 : nodesRaw.map((node, index) => {
|
|
568
|
+
const corner = (index) => {
|
|
569
|
+
switch (index) {
|
|
570
|
+
case 0:
|
|
571
|
+
return "top-left";
|
|
572
|
+
case 1:
|
|
573
|
+
return "top";
|
|
574
|
+
case 2:
|
|
575
|
+
return "top-right";
|
|
576
|
+
case 3:
|
|
577
|
+
return "right";
|
|
578
|
+
case 4:
|
|
579
|
+
return "bottom-right";
|
|
580
|
+
case 5:
|
|
581
|
+
return "bottom";
|
|
582
|
+
case 6:
|
|
583
|
+
return "bottom-left";
|
|
584
|
+
case 7:
|
|
585
|
+
return "left";
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
return (<>
|
|
589
|
+
<circle data-position={corner(index)} key={index} r={5} cx={node.x} cy={node.y} fill="transparent" style={{ cursor: "pointer" }}/>
|
|
590
|
+
<circle data-position={corner(index)} key={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" }}/>
|
|
591
|
+
</>);
|
|
592
|
+
}))}
|
|
593
|
+
</g>
|
|
594
|
+
</g>
|
|
595
|
+
</>)}
|
|
596
|
+
</g>);
|
|
457
597
|
};
|
|
458
598
|
export default Layers;
|
|
459
599
|
export function rectToPolygonNodes(x, y, width, height) {
|
|
@@ -16,5 +16,5 @@ interface LayersProps {
|
|
|
16
16
|
onForceRestoreGroup?: (group: SVGGElement, eventType: EventHandleType) => void;
|
|
17
17
|
selectedTableColor?: string;
|
|
18
18
|
}
|
|
19
|
-
declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, }: LayersProps) => import("react
|
|
19
|
+
declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, }: LayersProps) => import("react").JSX.Element;
|
|
20
20
|
export default Layers;
|