seat-editor 2.0.0 → 2.1.1
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/package.json +1 -1
- package/dist/app/constant.d.ts +0 -101
- package/dist/app/constant.js +0 -3064
- package/dist/app/layout.d.ts +0 -6
- package/dist/app/layout.jsx +0 -27
- package/dist/app/new-board/page.d.ts +0 -1
- package/dist/app/new-board/page.jsx +0 -56
- package/dist/app/old-board/page.d.ts +0 -3
- package/dist/app/old-board/page.jsx +0 -510
- package/dist/app/only-view/constant.d.ts +0 -40
- package/dist/app/only-view/constant.js +0 -1336
- package/dist/app/only-view/page.d.ts +0 -2
- package/dist/app/only-view/page.jsx +0 -40
- package/dist/app/page.d.ts +0 -2
- package/dist/app/page.jsx +0 -13
- package/dist/app/test/page.d.ts +0 -2
- package/dist/app/test/page.jsx +0 -45
- package/dist/app/v2/page.d.ts +0 -2
- package/dist/app/v2/page.jsx +0 -13
- package/dist/components/button-tools/index.d.ts +0 -11
- package/dist/components/button-tools/index.jsx +0 -17
- package/dist/components/form-tools/label.d.ts +0 -2
- package/dist/components/form-tools/label.jsx +0 -44
- package/dist/components/form-tools/shape.d.ts +0 -4
- package/dist/components/form-tools/shape.jsx +0 -66
- package/dist/components/input/number-indicator.d.ts +0 -7
- package/dist/components/input/number-indicator.jsx +0 -36
- package/dist/components/joystick/index.d.ts +0 -12
- package/dist/components/joystick/index.jsx +0 -49
- package/dist/components/layer/index.d.ts +0 -19
- package/dist/components/layer/index.jsx +0 -383
- package/dist/components/layer-v2/index.d.ts +0 -19
- package/dist/components/layer-v2/index.jsx +0 -370
- package/dist/components/layer-v3/index.d.ts +0 -19
- package/dist/components/layer-v3/index.jsx +0 -418
- package/dist/components/lib/index.d.ts +0 -8
- package/dist/components/lib/index.jsx +0 -33
- package/dist/components/modal-preview/index.d.ts +0 -4
- package/dist/components/modal-preview/index.jsx +0 -11
- package/dist/features/board/board-slice.d.ts +0 -14
- package/dist/features/board/board-slice.js +0 -52
- package/dist/features/board/index.d.ts +0 -6
- package/dist/features/board/index.jsx +0 -725
- package/dist/features/board-v2/board-slice.d.ts +0 -14
- package/dist/features/board-v2/board-slice.js +0 -52
- package/dist/features/board-v2/index.d.ts +0 -8
- package/dist/features/board-v2/index.jsx +0 -869
- package/dist/features/board-v3/board-slice.d.ts +0 -16
- package/dist/features/board-v3/board-slice.js +0 -83
- package/dist/features/board-v3/history-slice.d.ts +0 -27
- package/dist/features/board-v3/history-slice.js +0 -27
- package/dist/features/board-v3/index.d.ts +0 -8
- package/dist/features/board-v3/index.jsx +0 -863
- package/dist/features/navbar/index.d.ts +0 -2
- package/dist/features/navbar/index.jsx +0 -5
- package/dist/features/package/index.d.ts +0 -31
- package/dist/features/package/index.jsx +0 -114
- package/dist/features/panel/index.d.ts +0 -11
- package/dist/features/panel/index.jsx +0 -138
- package/dist/features/panel/panel-slice.d.ts +0 -16
- package/dist/features/panel/panel-slice.js +0 -31
- package/dist/features/panel/select-tool.d.ts +0 -6
- package/dist/features/panel/select-tool.jsx +0 -60
- package/dist/features/panel/square-circle-tool.d.ts +0 -2
- package/dist/features/panel/square-circle-tool.jsx +0 -10
- package/dist/features/panel/table-seat-circle.d.ts +0 -2
- package/dist/features/panel/table-seat-circle.jsx +0 -31
- package/dist/features/panel/text-tool.d.ts +0 -2
- package/dist/features/panel/text-tool.jsx +0 -26
- package/dist/features/panel/upload-tool.d.ts +0 -14
- package/dist/features/panel/upload-tool.jsx +0 -152
- package/dist/features/side-tool/index.d.ts +0 -8
- package/dist/features/side-tool/index.jsx +0 -371
- package/dist/features/side-tool/side-tool-slice.d.ts +0 -16
- package/dist/features/side-tool/side-tool-slice.js +0 -28
- package/dist/features/theme/theme-slice.d.ts +0 -12
- package/dist/features/theme/theme-slice.js +0 -15
- package/dist/features/view/index.d.ts +0 -19
- package/dist/features/view/index.jsx +0 -228
- package/dist/features/view-only/index.d.ts +0 -19
- package/dist/features/view-only/index.jsx +0 -206
- package/dist/features/view-only-2/index.d.ts +0 -19
- package/dist/features/view-only-2/index.jsx +0 -181
- package/dist/hooks/use-redux.d.ts +0 -4
- package/dist/hooks/use-redux.js +0 -3
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/libs/middleware.d.ts +0 -2
- package/dist/libs/middleware.js +0 -5
- package/dist/libs/rootReducer.d.ts +0 -12
- package/dist/libs/rootReducer.js +0 -14
- package/dist/libs/store.d.ts +0 -18
- package/dist/libs/store.js +0 -19
- package/dist/provider/antd-provider.d.ts +0 -4
- package/dist/provider/antd-provider.jsx +0 -46
- package/dist/provider/redux-provider.d.ts +0 -3
- package/dist/provider/redux-provider.jsx +0 -6
- package/dist/provider/store-provider.d.ts +0 -4
- package/dist/provider/store-provider.jsx +0 -10
- package/dist/utils/injectCss.d.ts +0 -1
- package/dist/utils/injectCss.js +0 -13
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import { isArray, isEmpty, omit } from "lodash";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style,
|
|
6
|
-
// onTouchEnd,
|
|
7
|
-
// onTouchMove,
|
|
8
|
-
onTouchStart, }) => {
|
|
9
|
-
const refItemTemp = useRef(null);
|
|
10
|
-
const handleOnHover = (item) => {
|
|
11
|
-
if (mode === "edit") {
|
|
12
|
-
refItemTemp.current = item;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function rectToPolygonPoints(x, y, width, height) {
|
|
16
|
-
const topLeft = [x, y];
|
|
17
|
-
const topRight = [x + width, y];
|
|
18
|
-
const bottomRight = [x + width, y + height];
|
|
19
|
-
const bottomLeft = [x, y + height];
|
|
20
|
-
const points = [topLeft, topRight, bottomRight, bottomLeft]
|
|
21
|
-
.map((point) => point.join(","))
|
|
22
|
-
.join(" ");
|
|
23
|
-
return points;
|
|
24
|
-
}
|
|
25
|
-
function rectToPolygonNodes(x, y, width, height) {
|
|
26
|
-
const points = [
|
|
27
|
-
{ x: x, y: y },
|
|
28
|
-
{ x: x + width, y: y },
|
|
29
|
-
{ x: x + width, y: y + height },
|
|
30
|
-
{ x: x, y: y + height },
|
|
31
|
-
];
|
|
32
|
-
return points;
|
|
33
|
-
}
|
|
34
|
-
const renderShadowShape = (item) => {
|
|
35
|
-
var _a;
|
|
36
|
-
const { id, x, y, width, height, fill, opacity, rotation, shape, fontColor, text, seatFill, labels, points, } = item;
|
|
37
|
-
const commonProps = { fill, opacity };
|
|
38
|
-
switch (shape) {
|
|
39
|
-
case "square":
|
|
40
|
-
case "polygon":
|
|
41
|
-
const pointsFormat = !isEmpty(points)
|
|
42
|
-
? points
|
|
43
|
-
: rectToPolygonPoints(x, y, width, height);
|
|
44
|
-
return <polygon key={id} points={pointsFormat} {...commonProps}/>;
|
|
45
|
-
case "circle":
|
|
46
|
-
return (<circle key={id} cx={x + width / 2} cy={y + height / 2} r={width / 2} {...commonProps}/>);
|
|
47
|
-
case "diamond":
|
|
48
|
-
return (<rect key={id} x={x} y={y} width={width} height={height} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps}/>);
|
|
49
|
-
case "table-seat-circle": {
|
|
50
|
-
const seatCount = item.seatCount;
|
|
51
|
-
const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
|
|
52
|
-
const centerX = x + width / 2;
|
|
53
|
-
const centerY = y + height / 2;
|
|
54
|
-
const baseSize = Math.min(width, height);
|
|
55
|
-
const radius = baseSize / 2; // jarak kursi dari pusat
|
|
56
|
-
const seatRadius = baseSize / 6; // ukuran kursi
|
|
57
|
-
const fullAngle = 2 * Math.PI;
|
|
58
|
-
const availableAngle = fullAngle * (1 - openSpace);
|
|
59
|
-
const angleStart = (fullAngle - availableAngle) / 2;
|
|
60
|
-
const angleStep = availableAngle / seatCount;
|
|
61
|
-
const seatInsetFactor = 0.3;
|
|
62
|
-
const seatCircles = Array.from({ length: seatCount }, (_, i) => {
|
|
63
|
-
const angle = angleStart + i * angleStep;
|
|
64
|
-
const inset = seatRadius * seatInsetFactor; // default 0.3
|
|
65
|
-
const cx = centerX + (radius - inset) * Math.cos(angle);
|
|
66
|
-
const cy = centerY + (radius - inset) * Math.sin(angle);
|
|
67
|
-
return { cx, cy };
|
|
68
|
-
});
|
|
69
|
-
return (<g key={id} transform={`rotate(${rotation} ${centerX} ${centerY})`}>
|
|
70
|
-
{/* Meja */}
|
|
71
|
-
<circle cx={centerX} cy={centerY} r={radius - 15} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...commonProps} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity}/>
|
|
72
|
-
|
|
73
|
-
{/* Label */}
|
|
74
|
-
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
75
|
-
var _a, _b, _c, _d;
|
|
76
|
-
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) => {
|
|
77
|
-
e.stopPropagation();
|
|
78
|
-
onClick && onClick(item);
|
|
79
|
-
}}>
|
|
80
|
-
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
81
|
-
</text>);
|
|
82
|
-
})}
|
|
83
|
-
|
|
84
|
-
{/* Kursi */}
|
|
85
|
-
<g fill="#e6b9c0" opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} stroke="#c49ba3" strokeWidth="1">
|
|
86
|
-
{seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
|
|
87
|
-
</g>
|
|
88
|
-
</g>);
|
|
89
|
-
}
|
|
90
|
-
case "table-seat-square": {
|
|
91
|
-
const seatCount = item.seatCount || 6;
|
|
92
|
-
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
93
|
-
const seatRadius = width / 6;
|
|
94
|
-
// split seats evenly on top and bottom
|
|
95
|
-
const seatCountPerSide = Math.ceil(seatCount / 2);
|
|
96
|
-
const availableWidth = width * (1 - openSpace);
|
|
97
|
-
const startX = x + (width * openSpace) / 2;
|
|
98
|
-
const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
|
|
99
|
-
const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
|
|
100
|
-
cx: startX + i * spacing,
|
|
101
|
-
cy: y - seatRadius * 1.5,
|
|
102
|
-
}));
|
|
103
|
-
const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
|
|
104
|
-
(_, i) => ({
|
|
105
|
-
cx: startX + i * spacing,
|
|
106
|
-
cy: y + height + seatRadius * 1.5,
|
|
107
|
-
}));
|
|
108
|
-
return (<g key={id}>
|
|
109
|
-
{/* Square Table */}
|
|
110
|
-
<rect x={x} y={y} width={width} height={height} {...commonProps}/>
|
|
111
|
-
|
|
112
|
-
{/* Seats */}
|
|
113
|
-
<g fill="#e6b9c0" fillOpacity="0.5" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
|
|
114
|
-
{[...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius}/>))}
|
|
115
|
-
</g>
|
|
116
|
-
</g>);
|
|
117
|
-
}
|
|
118
|
-
case "text":
|
|
119
|
-
return (<g key={id} onClick={() => {
|
|
120
|
-
onClick && onClick(item);
|
|
121
|
-
}}>
|
|
122
|
-
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
123
|
-
<text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={height * 0.6} opacity={opacity}>
|
|
124
|
-
{text}
|
|
125
|
-
</text>
|
|
126
|
-
</g>);
|
|
127
|
-
case "ruler":
|
|
128
|
-
return (<g key={id}>
|
|
129
|
-
<rect x={x - (window.innerWidth * 3) / 2} y={y} width={window.innerWidth * 3} height={1} fill="black"/>
|
|
130
|
-
<rect x={x} y={y - (window.innerHeight * 3) / 2} width={1} height={window.innerHeight * 3} fill="black"/>
|
|
131
|
-
</g>);
|
|
132
|
-
default:
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const renderShape = (item) => {
|
|
137
|
-
var _a;
|
|
138
|
-
const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, } = item;
|
|
139
|
-
const commonProps = {
|
|
140
|
-
fill,
|
|
141
|
-
opacity,
|
|
142
|
-
stroke,
|
|
143
|
-
strokeWidth,
|
|
144
|
-
onMouseDown: (e) => {
|
|
145
|
-
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, item || refItemTemp.current);
|
|
146
|
-
},
|
|
147
|
-
onMouseEnter: (e) => {
|
|
148
|
-
// e.stopPropagation();
|
|
149
|
-
handleOnHover === null || handleOnHover === void 0 ? void 0 : handleOnHover(item);
|
|
150
|
-
},
|
|
151
|
-
onClick: (e) => {
|
|
152
|
-
// e.stopPropagation();
|
|
153
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(item);
|
|
154
|
-
},
|
|
155
|
-
onMouseUp: (e) => {
|
|
156
|
-
// e.stopPropagation();
|
|
157
|
-
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
|
|
158
|
-
},
|
|
159
|
-
onBlur: (e) => {
|
|
160
|
-
// e.stopPropagation();
|
|
161
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
162
|
-
},
|
|
163
|
-
// onTouchMove: (
|
|
164
|
-
// e: React.TouchEvent<
|
|
165
|
-
// SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement
|
|
166
|
-
// >
|
|
167
|
-
// ) => {
|
|
168
|
-
// // e.stopPropagation();
|
|
169
|
-
// onTouchMove?.(e);
|
|
170
|
-
// },
|
|
171
|
-
onTouchStart: (e) => {
|
|
172
|
-
// e.stopPropagation();
|
|
173
|
-
onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e, item);
|
|
174
|
-
},
|
|
175
|
-
// onTouchEnd: (
|
|
176
|
-
// e: React.TouchEvent<
|
|
177
|
-
// SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement
|
|
178
|
-
// >
|
|
179
|
-
// ) => {
|
|
180
|
-
// // e.stopPropagation();
|
|
181
|
-
// onTouchEnd?.(e);
|
|
182
|
-
// },
|
|
183
|
-
onDoubleClick: (e) => {
|
|
184
|
-
// e.stopPropagation();
|
|
185
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(item);
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
switch (shape) {
|
|
189
|
-
case "square":
|
|
190
|
-
case "polygon":
|
|
191
|
-
const pointsFormat = !isEmpty(points)
|
|
192
|
-
? points
|
|
193
|
-
: rectToPolygonPoints(x, y, width, height);
|
|
194
|
-
return (<g key={id}>
|
|
195
|
-
<polygon {...commonProps} key={id} points={pointsFormat}/>
|
|
196
|
-
</g>);
|
|
197
|
-
// return (
|
|
198
|
-
// <g key={id}>
|
|
199
|
-
// <rect
|
|
200
|
-
// key={id}
|
|
201
|
-
// x={x}
|
|
202
|
-
// y={y}
|
|
203
|
-
// width={width}
|
|
204
|
-
// height={height}
|
|
205
|
-
// fill={selectedTableColor ?? fill}
|
|
206
|
-
// style={{
|
|
207
|
-
// cursor: mode === "view" ? "pointer" : "default",
|
|
208
|
-
// ...style,
|
|
209
|
-
// }}
|
|
210
|
-
// opacity={id === selectedComponent?.id ? 0.5 : opacity}
|
|
211
|
-
// {...omit(commonProps, "opacity")}
|
|
212
|
-
// transform={`rotate(${rotation} ${x + width / 2} ${
|
|
213
|
-
// y + height / 2
|
|
214
|
-
// })`}
|
|
215
|
-
// />
|
|
216
|
-
// {labels?.map((_: any, index: number) => {
|
|
217
|
-
// return (
|
|
218
|
-
// <text
|
|
219
|
-
// {...omit(commonProps, ["opacity", "stroke", "strokeWidth"])}
|
|
220
|
-
// key={`${id}-label-${index}`}
|
|
221
|
-
// x={x + width / 2 + (_?.x ?? 0)}
|
|
222
|
-
// y={y + height / 2 + (_?.y ?? 0)}
|
|
223
|
-
// fill={_?.fontColor ?? "black"}
|
|
224
|
-
// fontSize={`${_?.fontSize ?? 10}px`}
|
|
225
|
-
// fontWeight="bold"
|
|
226
|
-
// textAnchor="middle"
|
|
227
|
-
// dominantBaseline="middle"
|
|
228
|
-
// transform={`rotate(${rotation} ${x + width / 2} ${
|
|
229
|
-
// y + height / 2
|
|
230
|
-
// })`}
|
|
231
|
-
// onClick={(e) => {
|
|
232
|
-
// e.stopPropagation();
|
|
233
|
-
// onClick&& onClick(item);
|
|
234
|
-
// }}
|
|
235
|
-
// >
|
|
236
|
-
// {_?.label}
|
|
237
|
-
// </text>
|
|
238
|
-
// );
|
|
239
|
-
// })}
|
|
240
|
-
// </g>
|
|
241
|
-
// );
|
|
242
|
-
case "circle":
|
|
243
|
-
return (<g key={id}>
|
|
244
|
-
<circle key={id} cx={x + width / 2} cy={y + height / 2} r={Math.min(width, height) / 2} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} {...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={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) => {
|
|
248
|
-
e.stopPropagation();
|
|
249
|
-
onClick && onClick(item);
|
|
250
|
-
}}>
|
|
251
|
-
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
252
|
-
</text>);
|
|
253
|
-
})}
|
|
254
|
-
</g>);
|
|
255
|
-
case "diamond":
|
|
256
|
-
return (<g key={id}>
|
|
257
|
-
<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}/>
|
|
258
|
-
<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">
|
|
259
|
-
{label}
|
|
260
|
-
</text>
|
|
261
|
-
</g>);
|
|
262
|
-
case "table-seat-circle": {
|
|
263
|
-
const seatCount = item.seatCount;
|
|
264
|
-
const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
|
|
265
|
-
const centerX = x + width / 2;
|
|
266
|
-
const centerY = y + height / 2;
|
|
267
|
-
const baseSize = Math.min(width, height);
|
|
268
|
-
const radius = baseSize / 2; // jarak kursi dari pusat
|
|
269
|
-
const seatRadius = baseSize / 6; // ukuran kursi
|
|
270
|
-
const fullAngle = 2 * Math.PI;
|
|
271
|
-
const availableAngle = fullAngle * (1 - openSpace);
|
|
272
|
-
const angleStart = (fullAngle - availableAngle) / 2;
|
|
273
|
-
const angleStep = availableAngle / seatCount;
|
|
274
|
-
const seatInsetFactor = 0.3;
|
|
275
|
-
const seatCircles = Array.from({ length: seatCount }, (_, i) => {
|
|
276
|
-
const angle = angleStart + i * angleStep;
|
|
277
|
-
const inset = seatRadius * seatInsetFactor; // default 0.3
|
|
278
|
-
const cx = centerX + (radius - inset) * Math.cos(angle);
|
|
279
|
-
const cy = centerY + (radius - inset) * Math.sin(angle);
|
|
280
|
-
return { cx, cy };
|
|
281
|
-
});
|
|
282
|
-
return (<g key={id} transform={`rotate(${rotation} ${centerX} ${centerY})`}>
|
|
283
|
-
{/* Meja */}
|
|
284
|
-
<circle cx={centerX} cy={centerY} r={radius - 15} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...commonProps} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity}/>
|
|
285
|
-
|
|
286
|
-
{/* Label */}
|
|
287
|
-
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
288
|
-
var _a, _b, _c, _d;
|
|
289
|
-
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) => {
|
|
290
|
-
e.stopPropagation();
|
|
291
|
-
onClick && onClick(item);
|
|
292
|
-
}}>
|
|
293
|
-
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
294
|
-
</text>);
|
|
295
|
-
})}
|
|
296
|
-
|
|
297
|
-
{/* Kursi */}
|
|
298
|
-
<g fill="#e6b9c0" opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} stroke="#c49ba3" strokeWidth="1">
|
|
299
|
-
{seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
|
|
300
|
-
</g>
|
|
301
|
-
</g>);
|
|
302
|
-
}
|
|
303
|
-
case "table-seat-square": {
|
|
304
|
-
const seatCount = item.seatCount || 6;
|
|
305
|
-
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
306
|
-
const seatRadius = width / 6;
|
|
307
|
-
// split seats evenly on top and bottom
|
|
308
|
-
const seatCountPerSide = Math.ceil(seatCount / 2);
|
|
309
|
-
const availableWidth = width * (1 - openSpace);
|
|
310
|
-
const startX = x + (width * openSpace) / 2;
|
|
311
|
-
const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
|
|
312
|
-
const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
|
|
313
|
-
cx: startX + i * spacing,
|
|
314
|
-
cy: y - seatRadius * 1.5,
|
|
315
|
-
}));
|
|
316
|
-
const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
|
|
317
|
-
(_, i) => ({
|
|
318
|
-
cx: startX + i * spacing,
|
|
319
|
-
cy: y + height + seatRadius * 1.5,
|
|
320
|
-
}));
|
|
321
|
-
return (<g key={id} transform={`rotate(${rotation}, ${x}, ${y})`}>
|
|
322
|
-
{/* Square Table */}
|
|
323
|
-
<rect x={x} y={y} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} width={width} height={height} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
|
|
324
|
-
<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">
|
|
325
|
-
{label}
|
|
326
|
-
</text>
|
|
327
|
-
{/* Seats */}
|
|
328
|
-
<g fill="#e6b9c0" fillOpacity="0.5" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
|
|
329
|
-
{[...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius}/>))}
|
|
330
|
-
</g>
|
|
331
|
-
</g>);
|
|
332
|
-
}
|
|
333
|
-
case "text":
|
|
334
|
-
return (<g key={id}>
|
|
335
|
-
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity} onClick={(e) => {
|
|
336
|
-
e.stopPropagation();
|
|
337
|
-
onClick && onClick(item);
|
|
338
|
-
}}/>
|
|
339
|
-
<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"])}>
|
|
340
|
-
{text}
|
|
341
|
-
</text>
|
|
342
|
-
</g>);
|
|
343
|
-
case "image-table":
|
|
344
|
-
case "background":
|
|
345
|
-
return (<g key={id} onClick={() => {
|
|
346
|
-
onClick && onClick(item);
|
|
347
|
-
}}>
|
|
348
|
-
<image href={src} x={x} y={y} width={width} height={height} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} {...commonProps}/>
|
|
349
|
-
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
350
|
-
var _a, _b, _c, _d;
|
|
351
|
-
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})`}>
|
|
352
|
-
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
353
|
-
</text>);
|
|
354
|
-
})}
|
|
355
|
-
</g>);
|
|
356
|
-
default:
|
|
357
|
-
return <g key={id}/>;
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
let date = new Date();
|
|
361
|
-
const nodesRaw = !isEmpty(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.nodes) && isArray(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.nodes)
|
|
362
|
-
? selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.nodes
|
|
363
|
-
: rectToPolygonNodes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.width, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height);
|
|
364
|
-
const polylinePoints = [...nodesRaw, nodesRaw[0]]
|
|
365
|
-
.map((n) => `${n.x},${n.y}`)
|
|
366
|
-
.join(" ");
|
|
367
|
-
return (<g key={`${date}`}>
|
|
368
|
-
{components === null || components === void 0 ? void 0 : components.map(renderShape)}
|
|
369
|
-
{shadowShape === null || shadowShape === void 0 ? void 0 : shadowShape.map(renderShadowShape)}
|
|
370
|
-
{selectedComponent && activeTool === "select" && (<>
|
|
371
|
-
{nodesRaw.map((p1, index) => {
|
|
372
|
-
const p2 = nodesRaw[(index + 1) % nodesRaw.length]; // sisi berikutnya (wrap ke awal)
|
|
373
|
-
const side = index === 0
|
|
374
|
-
? "top"
|
|
375
|
-
: index === 1
|
|
376
|
-
? "right"
|
|
377
|
-
: index === 2
|
|
378
|
-
? "bottom"
|
|
379
|
-
: "left";
|
|
380
|
-
return (<polyline key={index} points={`${p1.x},${p1.y} ${p2.x},${p2.y}`} fill="none" stroke="transparent" strokeWidth={5} className={clsx([
|
|
381
|
-
{
|
|
382
|
-
"cursor-ns-resize": side === "top" || side === "bottom",
|
|
383
|
-
"cursor-ew-resize": side === "left" || side === "right",
|
|
384
|
-
},
|
|
385
|
-
])} onMouseDown={(e) => {
|
|
386
|
-
e.stopPropagation();
|
|
387
|
-
if (side === "top" || side === "bottom") {
|
|
388
|
-
onMouseDown(e, selectedComponent, side); // misal "top" / "bottom"
|
|
389
|
-
}
|
|
390
|
-
else if (side === "left" || side === "right") {
|
|
391
|
-
onMouseDown(e, selectedComponent, side);
|
|
392
|
-
}
|
|
393
|
-
}}/>);
|
|
394
|
-
})}
|
|
395
|
-
{nodesRaw === null || nodesRaw === void 0 ? void 0 : nodesRaw.map((node, index) => {
|
|
396
|
-
const corner = index === 0
|
|
397
|
-
? "top-left"
|
|
398
|
-
: index === 1
|
|
399
|
-
? "top-right"
|
|
400
|
-
: index === 2
|
|
401
|
-
? "bottom-right"
|
|
402
|
-
: "bottom-left";
|
|
403
|
-
return (<rect key={index} x={node.x - 10} y={node.y - 10} width={20} height={20} fill="transparent" className={clsx([
|
|
404
|
-
{
|
|
405
|
-
"cursor-nwse-resize": corner === "top-left" || corner === "bottom-right",
|
|
406
|
-
"cursor-nesw-resize": corner === "top-right" || corner === "bottom-left",
|
|
407
|
-
},
|
|
408
|
-
])} onMouseDown={(e) => {
|
|
409
|
-
e.stopPropagation();
|
|
410
|
-
onMouseDown(e, selectedComponent, corner);
|
|
411
|
-
}}/>);
|
|
412
|
-
})}
|
|
413
|
-
<polyline points={polylinePoints} fill="none" stroke="blue" strokeWidth={1}/>
|
|
414
|
-
</>)}
|
|
415
|
-
|
|
416
|
-
</g>);
|
|
417
|
-
};
|
|
418
|
-
export default Layers;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import LayerView from "../../features/view";
|
|
2
|
-
export interface LayerViewProps {
|
|
3
|
-
componentProps: any[];
|
|
4
|
-
extraComponentProps: any[];
|
|
5
|
-
}
|
|
6
|
-
declare const TableEditor: ({ componentProps, extraComponentProps, }: LayerViewProps) => import("react").JSX.Element;
|
|
7
|
-
export default TableEditor;
|
|
8
|
-
export { LayerView };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import Board from "../../features/board";
|
|
4
|
-
import SideTool from "../../features/side-tool";
|
|
5
|
-
import ControlPanels from "../../features/panel";
|
|
6
|
-
import LayerView from "../../features/view";
|
|
7
|
-
import { useAppDispatch } from "../../hooks/use-redux";
|
|
8
|
-
const TableEditor = ({ componentProps = [], extraComponentProps = [], }) => {
|
|
9
|
-
const dispatch = useAppDispatch();
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (componentProps.length > 0) {
|
|
12
|
-
dispatch({
|
|
13
|
-
type: "board/setNewComponents",
|
|
14
|
-
payload: componentProps,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
if (extraComponentProps.length > 0) {
|
|
18
|
-
dispatch({
|
|
19
|
-
type: "board/setNewExtraComponent",
|
|
20
|
-
payload: extraComponentProps,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}, [componentProps, extraComponentProps]);
|
|
24
|
-
return (<>
|
|
25
|
-
<div className="w-full h-screen flex relative">
|
|
26
|
-
<SideTool />
|
|
27
|
-
<Board />
|
|
28
|
-
<ControlPanels />
|
|
29
|
-
</div>
|
|
30
|
-
</>);
|
|
31
|
-
};
|
|
32
|
-
export default TableEditor;
|
|
33
|
-
export { LayerView };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Modal } from "antd";
|
|
3
|
-
import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
|
|
4
|
-
const ModalPreview = ({ children }) => {
|
|
5
|
-
const { isPreview } = useAppSelector((state) => state.tool);
|
|
6
|
-
const dispatch = useAppDispatch();
|
|
7
|
-
return (<Modal open={isPreview} onCancel={() => dispatch({ type: "tool/setTooglePreview", payload: false })} width={700} title="Preview Board" centered footer={null}>
|
|
8
|
-
<div className="flex flex-col p-4 h-[500px]">{children}</div>
|
|
9
|
-
</Modal>);
|
|
10
|
-
};
|
|
11
|
-
export default ModalPreview;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface Component {
|
|
2
|
-
id: string;
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
5
|
-
export interface InitialState {
|
|
6
|
-
components: Component[];
|
|
7
|
-
backgroundColor: string;
|
|
8
|
-
themeColor: string;
|
|
9
|
-
extraComponents: Component[];
|
|
10
|
-
flagChange: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare const addComponent: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "board/addComponent">, removeComponent: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "board/removeComponent">, updateComponent: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "board/updateComponent">, setBackgroundColor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "board/setBackgroundColor">, removeExtraComponent: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "board/removeExtraComponent">;
|
|
13
|
-
declare const _default: import("redux").Reducer<InitialState>;
|
|
14
|
-
export default _default;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
-
const initialState = {
|
|
3
|
-
components: [],
|
|
4
|
-
backgroundColor: "#FFFFFF",
|
|
5
|
-
themeColor: "#4A90E2",
|
|
6
|
-
extraComponents: [],
|
|
7
|
-
flagChange: false
|
|
8
|
-
};
|
|
9
|
-
const boardSlice = createSlice({
|
|
10
|
-
name: "board",
|
|
11
|
-
initialState,
|
|
12
|
-
reducers: {
|
|
13
|
-
addComponent: (state, action) => {
|
|
14
|
-
state.components.push(action.payload);
|
|
15
|
-
},
|
|
16
|
-
removeComponent: (state, action) => {
|
|
17
|
-
state.components = state.components.filter((component) => component.id !== action.payload.id);
|
|
18
|
-
},
|
|
19
|
-
removeExtraComponent: (state, action) => {
|
|
20
|
-
state.extraComponents = state.extraComponents.filter((component) => component.id !== action.payload.id);
|
|
21
|
-
},
|
|
22
|
-
updateComponent: (state, action) => {
|
|
23
|
-
const index = state.components.findIndex((component) => component.id === action.payload.id);
|
|
24
|
-
const indexExtra = state.extraComponents.findIndex((extraComponent) => extraComponent.id === action.payload.id);
|
|
25
|
-
if (index !== -1) {
|
|
26
|
-
// Update component biasa
|
|
27
|
-
state.components[index] = Object.assign(Object.assign({}, state.components[index]), action.payload);
|
|
28
|
-
}
|
|
29
|
-
else if (indexExtra !== -1) {
|
|
30
|
-
// Update extraComponent
|
|
31
|
-
state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), action.payload);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
setBackgroundColor: (state, action) => {
|
|
35
|
-
state.backgroundColor = action.payload;
|
|
36
|
-
},
|
|
37
|
-
setNewComponents: (state, action) => {
|
|
38
|
-
state.components = action.payload;
|
|
39
|
-
},
|
|
40
|
-
setNewExtraComponents: (state, action) => {
|
|
41
|
-
state.extraComponents = action.payload;
|
|
42
|
-
},
|
|
43
|
-
setExtraComponent: (state, action) => {
|
|
44
|
-
state.extraComponents.push(action.payload);
|
|
45
|
-
},
|
|
46
|
-
setFlagChange: (state, action) => {
|
|
47
|
-
state.flagChange = action.payload;
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
export const { addComponent, removeComponent, updateComponent, setBackgroundColor, removeExtraComponent } = boardSlice.actions;
|
|
52
|
-
export default boardSlice.reducer;
|