seat-editor 1.4.19 → 1.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/layout.d.ts +1 -1
- package/dist/app/layout.js +22 -0
- package/dist/app/new-board/page.d.ts +1 -1
- package/dist/app/new-board/page.js +30 -0
- package/dist/app/old-board/page.d.ts +1 -2
- package/dist/app/old-board/page.js +377 -0
- package/dist/app/only-view/page.d.ts +1 -1
- package/dist/app/only-view/page.js +41 -0
- package/dist/app/page.d.ts +1 -1
- package/dist/app/page.js +8 -0
- package/dist/components/button-tools/index.d.ts +1 -1
- package/dist/components/button-tools/index.js +11 -0
- package/dist/components/form-tools/label.d.ts +1 -1
- package/dist/components/form-tools/label.js +7 -0
- package/dist/components/form-tools/shape.d.ts +1 -1
- package/dist/components/form-tools/shape.js +25 -0
- package/dist/components/input/number-indicator.d.ts +1 -1
- package/dist/components/input/number-indicator.js +27 -0
- package/dist/components/joystick/index.d.ts +1 -2
- package/dist/components/joystick/index.js +48 -0
- package/dist/components/layer/index.d.ts +1 -1
- package/dist/components/layer/index.js +276 -0
- package/dist/components/lib/index.d.ts +1 -1
- package/dist/components/lib/index.js +28 -0
- package/dist/components/modal-preview/index.d.ts +1 -1
- package/dist/components/modal-preview/index.js +10 -0
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/board/index.js +626 -0
- package/dist/features/navbar/index.d.ts +1 -1
- package/dist/features/navbar/index.js +6 -0
- package/dist/features/package/index.d.ts +1 -1
- package/dist/features/package/index.js +102 -0
- package/dist/features/package/index.jsx +6 -9
- package/dist/features/panel/index.d.ts +1 -1
- package/dist/features/panel/index.js +97 -0
- package/dist/features/panel/select-tool.d.ts +1 -1
- package/dist/features/panel/select-tool.js +44 -0
- package/dist/features/panel/square-circle-tool.d.ts +1 -1
- package/dist/features/panel/square-circle-tool.js +8 -0
- package/dist/features/panel/table-seat-circle.d.ts +1 -1
- package/dist/features/panel/table-seat-circle.js +9 -0
- package/dist/features/panel/text-tool.d.ts +1 -1
- package/dist/features/panel/text-tool.js +7 -0
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.js +155 -0
- package/dist/features/side-tool/index.d.ts +1 -1
- package/dist/features/side-tool/index.js +244 -0
- package/dist/features/view/index.d.ts +1 -1
- package/dist/features/view/index.js +213 -0
- package/dist/features/view/index.jsx +4 -6
- package/dist/provider/antd-provider.js +43 -0
- package/dist/provider/redux-provider.d.ts +1 -1
- package/dist/provider/redux-provider.js +7 -0
- package/dist/provider/store-provider.d.ts +1 -1
- package/dist/provider/store-provider.js +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Joystick.tsx
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
export const Joystick = ({ size = 120, onMove, onEnd, }) => {
|
|
5
|
+
const baseRef = useRef(null);
|
|
6
|
+
const [position, setPosition] = useState({ x: 0, y: 0 });
|
|
7
|
+
const handleMove = (e) => {
|
|
8
|
+
const base = baseRef.current;
|
|
9
|
+
if (!base)
|
|
10
|
+
return;
|
|
11
|
+
const rect = base.getBoundingClientRect();
|
|
12
|
+
const isTouch = "touches" in e;
|
|
13
|
+
const clientX = isTouch ? e.touches[0].clientX : e.clientX;
|
|
14
|
+
const clientY = isTouch ? e.touches[0].clientY : e.clientY;
|
|
15
|
+
const centerX = rect.left + rect.width / 2;
|
|
16
|
+
const centerY = rect.top + rect.height / 2;
|
|
17
|
+
const dx = clientX - centerX;
|
|
18
|
+
const dy = clientY - centerY;
|
|
19
|
+
const distance = Math.min(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)), size / 2 - 20);
|
|
20
|
+
const angle = Math.atan2(dy, dx);
|
|
21
|
+
const x = Math.cos(angle) * distance;
|
|
22
|
+
const y = Math.sin(angle) * distance;
|
|
23
|
+
setPosition({ x, y });
|
|
24
|
+
onMove === null || onMove === void 0 ? void 0 : onMove({ x, y });
|
|
25
|
+
};
|
|
26
|
+
const handleEnd = () => {
|
|
27
|
+
setPosition({ x: 0, y: 0 });
|
|
28
|
+
onEnd === null || onEnd === void 0 ? void 0 : onEnd();
|
|
29
|
+
};
|
|
30
|
+
return (_jsx("div", { ref: baseRef, onMouseMove: (e) => e.buttons === 1 && handleMove(e), onMouseUp: handleEnd, onMouseLeave: handleEnd, onTouchMove: handleMove, onTouchEnd: handleEnd, style: {
|
|
31
|
+
width: size,
|
|
32
|
+
height: size,
|
|
33
|
+
background: "#ddd",
|
|
34
|
+
borderRadius: "50%",
|
|
35
|
+
position: "relative",
|
|
36
|
+
touchAction: "none",
|
|
37
|
+
userSelect: "none",
|
|
38
|
+
}, children: _jsx("div", { onMouseDown: handleMove, onTouchStart: handleMove, style: {
|
|
39
|
+
width: 40,
|
|
40
|
+
height: 40,
|
|
41
|
+
background: "#3E97FF",
|
|
42
|
+
borderRadius: "50%",
|
|
43
|
+
position: "absolute",
|
|
44
|
+
left: `calc(50% + ${position.x}px - 20px)`,
|
|
45
|
+
top: `calc(50% + ${position.y}px - 20px)`,
|
|
46
|
+
touchAction: "none",
|
|
47
|
+
} }) }));
|
|
48
|
+
};
|
|
@@ -15,5 +15,5 @@ interface LayersProps {
|
|
|
15
15
|
onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
|
|
16
16
|
onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
|
|
17
17
|
}
|
|
18
|
-
declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchEnd, onTouchMove, onTouchStart }: LayersProps) => import("react").JSX.Element;
|
|
18
|
+
declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchEnd, onTouchMove, onTouchStart }: LayersProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
export default Layers;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { omit } from "lodash";
|
|
4
|
+
const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style, onTouchEnd, onTouchMove, onTouchStart }) => {
|
|
5
|
+
const renderShadowShape = (item) => {
|
|
6
|
+
const { id, x, y, width, height, fill, opacity, rotation, shape, fontColor, text, seatFill, labels, } = item;
|
|
7
|
+
const commonProps = { fill, opacity };
|
|
8
|
+
switch (shape) {
|
|
9
|
+
case "square":
|
|
10
|
+
return (_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height }, commonProps), id));
|
|
11
|
+
case "circle":
|
|
12
|
+
return (_jsx("circle", Object.assign({ cx: x + width / 2, cy: y + height / 2, r: width / 2 }, commonProps), id));
|
|
13
|
+
case "diamond":
|
|
14
|
+
return (_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, transform: `rotate(${rotation}, ${x}, ${y})` }, commonProps), id));
|
|
15
|
+
case "table-seat-circle": {
|
|
16
|
+
const seatCount = item.seatCount;
|
|
17
|
+
const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
|
|
18
|
+
const centerX = x + width / 2;
|
|
19
|
+
const centerY = y + height / 2;
|
|
20
|
+
const radius = width;
|
|
21
|
+
const seatRadius = width / 4;
|
|
22
|
+
const fullAngle = 2 * Math.PI;
|
|
23
|
+
const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
|
|
24
|
+
const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
|
|
25
|
+
const angleStep = availableAngle / seatCount;
|
|
26
|
+
const seatCircles = Array.from({ length: seatCount }, (_, i) => {
|
|
27
|
+
const angle = angleStart + i * angleStep;
|
|
28
|
+
const cx = centerX + radius * Math.cos(angle);
|
|
29
|
+
const cy = centerY + radius * Math.sin(angle);
|
|
30
|
+
return { cx, cy };
|
|
31
|
+
});
|
|
32
|
+
return (_jsxs("g", { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: width - 15 }, commonProps, { opacity: id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity })), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
return (_jsx("text", { 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})`, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
|
|
35
|
+
}), _jsx("g", { fill: "#e6b9c0", opacity: id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity, stroke: "#c49ba3", strokeWidth: "1", children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`)] }, id));
|
|
36
|
+
}
|
|
37
|
+
case "table-seat-square": {
|
|
38
|
+
const seatCount = item.seatCount || 6;
|
|
39
|
+
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
40
|
+
const seatRadius = width / 6;
|
|
41
|
+
// split seats evenly on top and bottom
|
|
42
|
+
const seatCountPerSide = Math.ceil(seatCount / 2);
|
|
43
|
+
const availableWidth = width * (1 - openSpace);
|
|
44
|
+
const startX = x + (width * openSpace) / 2;
|
|
45
|
+
const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
|
|
46
|
+
const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
|
|
47
|
+
cx: startX + i * spacing,
|
|
48
|
+
cy: y - seatRadius * 1.5,
|
|
49
|
+
}));
|
|
50
|
+
const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
|
|
51
|
+
(_, i) => ({
|
|
52
|
+
cx: startX + i * spacing,
|
|
53
|
+
cy: y + height + seatRadius * 1.5,
|
|
54
|
+
}));
|
|
55
|
+
return (_jsxs("g", { children: [_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height }, commonProps)), _jsx("g", { fill: "#e6b9c0", fillOpacity: "0.5", stroke: "#c49ba3", strokeWidth: "1", children: [...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius }, `${id}-seat-${i}`))) }, `${id}-seats`)] }, id));
|
|
56
|
+
}
|
|
57
|
+
case "text":
|
|
58
|
+
return (_jsxs("g", { onClick: () => onClick(item), children: [_jsx("rect", { x: x, y: y, width: width, height: height, fill: "transparent", opacity: opacity }), _jsx("text", { x: x + width / 2, y: y + height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fontColor, fontSize: height * 0.6, opacity: opacity, children: text })] }, id));
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const renderShape = (item) => {
|
|
64
|
+
const { id, x, y, width, height, fill, opacity, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, } = item;
|
|
65
|
+
const commonProps = {
|
|
66
|
+
fill,
|
|
67
|
+
opacity,
|
|
68
|
+
onClick: (e) => {
|
|
69
|
+
// e.stopPropagation();
|
|
70
|
+
onClick(item);
|
|
71
|
+
},
|
|
72
|
+
stroke,
|
|
73
|
+
strokeWidth,
|
|
74
|
+
onMouseDown: (e) => {
|
|
75
|
+
// e.stopPropagation();
|
|
76
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, item);
|
|
77
|
+
},
|
|
78
|
+
onMouseUp: (e) => {
|
|
79
|
+
// e.stopPropagation();
|
|
80
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
|
|
81
|
+
},
|
|
82
|
+
onBlur: (e) => {
|
|
83
|
+
// e.stopPropagation();
|
|
84
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
85
|
+
},
|
|
86
|
+
onTouchMove: (e) => {
|
|
87
|
+
e.stopPropagation();
|
|
88
|
+
onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(e);
|
|
89
|
+
},
|
|
90
|
+
onTouchStart: (e) => {
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e, item);
|
|
93
|
+
},
|
|
94
|
+
onTouchEnd: (e) => {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
|
|
97
|
+
},
|
|
98
|
+
onDoubleClick: (e) => {
|
|
99
|
+
e.stopPropagation();
|
|
100
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(item);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
switch (shape) {
|
|
104
|
+
case "square":
|
|
105
|
+
return (_jsxs("g", { children: [_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill, style: Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style), opacity: id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity }, omit(commonProps, "opacity"), { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})` }), id), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
106
|
+
var _a, _b, _c, _d;
|
|
107
|
+
return (_jsx("text", { 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) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
onClick(item);
|
|
110
|
+
}, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
|
|
111
|
+
})] }, id));
|
|
112
|
+
case "circle":
|
|
113
|
+
return (_jsxs("g", { children: [_jsx("circle", Object.assign({ cx: x + width / 2, cy: y + height / 2, r: width / 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")), id), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
114
|
+
var _a, _b, _c, _d;
|
|
115
|
+
return (_jsx("text", { 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) => {
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
onClick(item);
|
|
118
|
+
}, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
|
|
119
|
+
})] }, id));
|
|
120
|
+
case "diamond":
|
|
121
|
+
return (_jsxs("g", { children: [_jsx("rect", Object.assign({ 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 }), 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));
|
|
122
|
+
case "table-seat-circle": {
|
|
123
|
+
const seatCount = item.seatCount;
|
|
124
|
+
const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
|
|
125
|
+
const centerX = x + width / 2;
|
|
126
|
+
const centerY = y + height / 2;
|
|
127
|
+
const radius = width;
|
|
128
|
+
const seatRadius = width / 4;
|
|
129
|
+
const fullAngle = 2 * Math.PI;
|
|
130
|
+
const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
|
|
131
|
+
const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
|
|
132
|
+
const angleStep = availableAngle / seatCount;
|
|
133
|
+
const seatCircles = Array.from({ length: seatCount }, (_, i) => {
|
|
134
|
+
const angle = angleStart + i * angleStep;
|
|
135
|
+
const cx = centerX + radius * Math.cos(angle);
|
|
136
|
+
const cy = centerY + radius * Math.sin(angle);
|
|
137
|
+
return { cx, cy };
|
|
138
|
+
});
|
|
139
|
+
return (_jsxs("g", { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, children: [_jsx("circle", Object.assign({ cx: centerX, style: Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style), cy: centerY, r: width - 15, fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill }, commonProps, { opacity: id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity })), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
140
|
+
var _a, _b, _c, _d;
|
|
141
|
+
return (_jsx("text", { 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) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
onClick(item);
|
|
144
|
+
}, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
|
|
145
|
+
}), _jsx("g", { fill: "#e6b9c0", opacity: id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity, stroke: "#c49ba3", strokeWidth: "1", children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`)] }, id));
|
|
146
|
+
}
|
|
147
|
+
case "table-seat-square": {
|
|
148
|
+
const seatCount = item.seatCount || 6;
|
|
149
|
+
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
150
|
+
const seatRadius = width / 6;
|
|
151
|
+
// split seats evenly on top and bottom
|
|
152
|
+
const seatCountPerSide = Math.ceil(seatCount / 2);
|
|
153
|
+
const availableWidth = width * (1 - openSpace);
|
|
154
|
+
const startX = x + (width * openSpace) / 2;
|
|
155
|
+
const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
|
|
156
|
+
const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
|
|
157
|
+
cx: startX + i * spacing,
|
|
158
|
+
cy: y - seatRadius * 1.5,
|
|
159
|
+
}));
|
|
160
|
+
const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
|
|
161
|
+
(_, i) => ({
|
|
162
|
+
cx: startX + i * spacing,
|
|
163
|
+
cy: y + height + seatRadius * 1.5,
|
|
164
|
+
}));
|
|
165
|
+
return (_jsxs("g", { transform: `rotate(${rotation}, ${x}, ${y})`, children: [_jsx("rect", Object.assign({ 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 })), _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 }), _jsx("g", { fill: "#e6b9c0", fillOpacity: "0.5", stroke: "#c49ba3", strokeWidth: "1", children: [...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius }, `${id}-seat-${i}`))) }, `${id}-seats`)] }, id));
|
|
166
|
+
}
|
|
167
|
+
case "text":
|
|
168
|
+
return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: width, height: height, fill: "transparent", opacity: opacity, onClick: (e) => {
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
onClick(item);
|
|
171
|
+
} }), _jsx("text", Object.assign({ 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"]), { children: text }))] }, id));
|
|
172
|
+
case "image-table":
|
|
173
|
+
case "background":
|
|
174
|
+
return (_jsxs("g", { onClick: () => onClick(item), children: [_jsx("image", Object.assign({ href: src, x: x, y: y, width: width, height: height, transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})` }, commonProps)), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
175
|
+
var _a, _b, _c, _d;
|
|
176
|
+
return (_jsx("text", { 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})`, children: _ === null || _ === void 0 ? void 0 : _.label }, index));
|
|
177
|
+
})] }, id));
|
|
178
|
+
default:
|
|
179
|
+
return _jsx("g", {}, id);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
let date = new Date();
|
|
183
|
+
return (_jsxs("g", { children: [components === null || components === void 0 ? void 0 : components.map(renderShape), shadowShape === null || shadowShape === void 0 ? void 0 : shadowShape.map(renderShadowShape), selectedComponent && (_jsxs(_Fragment, { children: [[
|
|
184
|
+
"square",
|
|
185
|
+
"circle",
|
|
186
|
+
"diamond",
|
|
187
|
+
"text",
|
|
188
|
+
"background",
|
|
189
|
+
"image-table",
|
|
190
|
+
].includes(selectedComponent.shape) && (_jsxs("g", { children: [_jsx("rect", { x: selectedComponent.x - 25, y: selectedComponent.y - 25, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
onMouseDown(e, selectedComponent, "top-left");
|
|
193
|
+
}, onTouchStart: (e) => {
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
onTouchStart(e, selectedComponent, "top-left");
|
|
196
|
+
}, onTouchMove: (e) => {
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
onTouchMove(e);
|
|
199
|
+
} }), _jsx("rect", { x: selectedComponent.x + (selectedComponent.width - 15) / 2, y: selectedComponent.y - 25, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
200
|
+
e.stopPropagation();
|
|
201
|
+
onMouseDown(e, selectedComponent, "top-center");
|
|
202
|
+
}, onTouchStart: (e) => {
|
|
203
|
+
e.stopPropagation();
|
|
204
|
+
onTouchStart(e, selectedComponent, "top-center");
|
|
205
|
+
}, onTouchMove: (e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
onTouchMove(e);
|
|
208
|
+
} }), _jsx("rect", { x: selectedComponent.x - 25, y: selectedComponent.y + (selectedComponent.height - 15) / 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
209
|
+
e.stopPropagation();
|
|
210
|
+
onMouseDown(e, selectedComponent, "left-center");
|
|
211
|
+
}, onTouchStart: (e) => {
|
|
212
|
+
e.stopPropagation();
|
|
213
|
+
onTouchStart(e, selectedComponent, "left-center");
|
|
214
|
+
}, onTouchMove: (e) => {
|
|
215
|
+
e.stopPropagation();
|
|
216
|
+
onTouchMove(e);
|
|
217
|
+
} }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5, y: selectedComponent.y - 25, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
onMouseDown(e, selectedComponent, "top-right");
|
|
220
|
+
}, onTouchStart: (e) => {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
onTouchStart(e, selectedComponent, "top-right");
|
|
223
|
+
}, onTouchMove: (e) => {
|
|
224
|
+
e.stopPropagation();
|
|
225
|
+
onTouchMove(e);
|
|
226
|
+
} }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5, y: selectedComponent.y + selectedComponent.height + 5, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
227
|
+
e.stopPropagation();
|
|
228
|
+
onMouseDown(e, selectedComponent, "bottom-right");
|
|
229
|
+
}, onTouchStart: (e) => {
|
|
230
|
+
e.stopPropagation();
|
|
231
|
+
onTouchStart(e, selectedComponent, "bottom-right");
|
|
232
|
+
}, onTouchMove: (e) => {
|
|
233
|
+
e.stopPropagation();
|
|
234
|
+
onTouchMove(e);
|
|
235
|
+
} }), _jsx("rect", { x: selectedComponent.x + (selectedComponent.width - 15) / 2, y: selectedComponent.y + selectedComponent.height + 5, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
236
|
+
e.stopPropagation();
|
|
237
|
+
onMouseDown(e, selectedComponent, "bottom-center");
|
|
238
|
+
}, onTouchStart: (e) => {
|
|
239
|
+
e.stopPropagation();
|
|
240
|
+
onTouchStart(e, selectedComponent, "bottom-center");
|
|
241
|
+
}, onTouchMove: (e) => {
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
onTouchMove(e);
|
|
244
|
+
} }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5, y: selectedComponent.y + (selectedComponent.height - 15) / 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
245
|
+
e.stopPropagation();
|
|
246
|
+
onMouseDown(e, selectedComponent, "right-center");
|
|
247
|
+
}, onTouchStart: (e) => {
|
|
248
|
+
e.stopPropagation();
|
|
249
|
+
onTouchStart(e, selectedComponent, "right-center");
|
|
250
|
+
}, onTouchMove: (e) => {
|
|
251
|
+
e.stopPropagation();
|
|
252
|
+
onTouchMove(e);
|
|
253
|
+
} }), _jsx("rect", { x: selectedComponent.x - 25, y: selectedComponent.y + selectedComponent.height + 5, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
254
|
+
e.stopPropagation();
|
|
255
|
+
onMouseDown(e, selectedComponent, "bottom-left");
|
|
256
|
+
}, onTouchStart: (e) => {
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
onTouchStart(e, selectedComponent, "bottom-left");
|
|
259
|
+
}, onTouchMove: (e) => {
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
onTouchMove(e);
|
|
262
|
+
} })] }, `${selectedComponent.id}-selection`)), ["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape) && (_jsxs("g", { children: [_jsx("rect", { x: selectedComponent.x - selectedComponent.width, y: selectedComponent.y - selectedComponent.height, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
onMouseDown(e, selectedComponent, "top-left");
|
|
265
|
+
} }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width * 2 - 10, y: selectedComponent.y - selectedComponent.height, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
266
|
+
e.stopPropagation();
|
|
267
|
+
onMouseDown(e, selectedComponent, "top-right");
|
|
268
|
+
} }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width * 2 - 10, y: selectedComponent.y + selectedComponent.height * 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
269
|
+
e.stopPropagation();
|
|
270
|
+
onMouseDown(e, selectedComponent, "bottom-right");
|
|
271
|
+
} }), _jsx("rect", { x: selectedComponent.x - selectedComponent.width, y: selectedComponent.y + selectedComponent.height * 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", transform: `scale(${selectedComponent.scale})`, onMouseDown: (e) => {
|
|
272
|
+
e.stopPropagation();
|
|
273
|
+
onMouseDown(e, selectedComponent, "b-left");
|
|
274
|
+
} })] }, selectedComponent.id))] }))] }, `${date}`));
|
|
275
|
+
};
|
|
276
|
+
export default Layers;
|
|
@@ -3,6 +3,6 @@ export interface LayerViewProps {
|
|
|
3
3
|
componentProps: any[];
|
|
4
4
|
extraComponentProps: any[];
|
|
5
5
|
}
|
|
6
|
-
declare const TableEditor: ({ componentProps, extraComponentProps, }: LayerViewProps) => import("react").JSX.Element;
|
|
6
|
+
declare const TableEditor: ({ componentProps, extraComponentProps, }: LayerViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default TableEditor;
|
|
8
8
|
export { LayerView };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import Board from "../../features/board";
|
|
5
|
+
import SideTool from "../../features/side-tool";
|
|
6
|
+
import ControlPanels from "../../features/panel";
|
|
7
|
+
import LayerView from "../../features/view";
|
|
8
|
+
import { useAppDispatch } from "../../hooks/use-redux";
|
|
9
|
+
const TableEditor = ({ componentProps = [], extraComponentProps = [], }) => {
|
|
10
|
+
const dispatch = useAppDispatch();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (componentProps.length > 0) {
|
|
13
|
+
dispatch({
|
|
14
|
+
type: "board/setNewComponents",
|
|
15
|
+
payload: componentProps,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (extraComponentProps.length > 0) {
|
|
19
|
+
dispatch({
|
|
20
|
+
type: "board/setNewExtraComponent",
|
|
21
|
+
payload: extraComponentProps,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [componentProps, extraComponentProps]);
|
|
25
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "w-full h-screen flex relative", children: [_jsx(SideTool, {}), _jsx(Board, {}), _jsx(ControlPanels, {})] }) }));
|
|
26
|
+
};
|
|
27
|
+
export default TableEditor;
|
|
28
|
+
export { LayerView };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Modal } from "antd";
|
|
4
|
+
import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
|
|
5
|
+
const ModalPreview = ({ children }) => {
|
|
6
|
+
const { isPreview } = useAppSelector((state) => state.tool);
|
|
7
|
+
const dispatch = useAppDispatch();
|
|
8
|
+
return (_jsx(Modal, { open: isPreview, onCancel: () => dispatch({ type: "tool/setTooglePreview", payload: false }), width: 700, title: "Preview Board", centered: true, footer: null, children: _jsx("div", { className: "flex flex-col p-4 h-[500px]", children: children }) }));
|
|
9
|
+
};
|
|
10
|
+
export default ModalPreview;
|
|
@@ -2,5 +2,5 @@ interface BoardTemplateProps {
|
|
|
2
2
|
onSelectComponent?: (items: any) => void;
|
|
3
3
|
mappingKey?: string;
|
|
4
4
|
}
|
|
5
|
-
declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => import("react").JSX.Element;
|
|
5
|
+
declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default BoardTemplate;
|