seat-editor 3.3.13 → 3.3.14
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/constant.d.ts +1 -0
- package/dist/app/constant.js +1 -0
- package/dist/app/layout.d.ts +6 -0
- package/dist/app/layout.jsx +27 -0
- package/dist/app/new-board/page.jsx +55 -0
- package/dist/app/old-board/page.d.ts +3 -0
- package/dist/app/old-board/page.jsx +510 -0
- package/dist/app/only-view/chair.d.ts +1 -0
- package/dist/app/only-view/chair.js +12 -0
- package/dist/app/only-view/constant.d.ts +60 -0
- package/dist/app/only-view/constant.js +1336 -0
- package/dist/app/only-view/page.jsx +248 -0
- package/dist/app/only-view/user.d.ts +1 -0
- package/dist/app/only-view/user.js +12 -0
- package/dist/app/page.d.ts +2 -0
- package/dist/app/page.jsx +13 -0
- package/dist/app/test/page.d.ts +2 -0
- package/dist/app/test/page.jsx +45 -0
- package/dist/app/v2/page.d.ts +2 -0
- package/dist/app/v2/page.jsx +13 -0
- package/dist/components/button-tools/index.d.ts +11 -0
- package/dist/components/button-tools/index.jsx +17 -0
- package/dist/components/form-tools/label.d.ts +2 -0
- package/dist/components/form-tools/label.jsx +63 -0
- package/dist/components/form-tools/shape.d.ts +8 -0
- package/dist/components/form-tools/shape.jsx +113 -0
- package/dist/components/input/number-indicator.d.ts +7 -0
- package/dist/components/input/number-indicator.jsx +36 -0
- package/dist/components/joystick/index.d.ts +12 -0
- package/dist/components/joystick/index.jsx +49 -0
- package/dist/components/layer/index.d.ts +19 -0
- package/dist/components/layer/index.jsx +383 -0
- package/dist/components/layer-v2/index.d.ts +19 -0
- package/dist/components/layer-v2/index.jsx +370 -0
- package/dist/components/layer-v3/index.d.ts +13 -0
- package/dist/components/layer-v3/index.jsx +631 -0
- package/dist/components/layer-v3/utils.d.ts +19 -0
- package/dist/components/layer-v3/utils.js +72 -0
- package/dist/components/layer-v4/constant.d.ts +60 -0
- package/dist/components/layer-v4/constant.js +93 -0
- package/dist/components/layer-v4/index.d.ts +24 -0
- package/dist/components/layer-v4/index.jsx +1046 -0
- package/dist/components/lib/index.d.ts +8 -0
- package/dist/components/lib/index.jsx +33 -0
- package/dist/components/modal-preview/index.d.ts +4 -0
- package/dist/components/modal-preview/index.jsx +11 -0
- package/dist/dto/event-handler.d.ts +1 -0
- package/dist/dto/event-handler.js +1 -0
- package/dist/dto/table.d.ts +79 -0
- package/dist/dto/table.js +1 -0
- package/dist/features/board/board-slice.d.ts +14 -0
- package/dist/features/board/board-slice.js +52 -0
- package/dist/features/board/index.d.ts +6 -0
- package/dist/features/board/index.jsx +725 -0
- package/dist/features/board-v2/board-slice.d.ts +14 -0
- package/dist/features/board-v2/board-slice.js +52 -0
- package/dist/features/board-v2/index.d.ts +8 -0
- package/dist/features/board-v2/index.jsx +869 -0
- package/dist/features/board-v3/board-slice.d.ts +19 -0
- package/dist/features/board-v3/board-slice.js +274 -0
- package/dist/features/board-v3/constant.d.ts +5 -0
- package/dist/features/board-v3/constant.js +5 -0
- package/dist/features/board-v3/history-slice.d.ts +27 -0
- package/dist/features/board-v3/history-slice.js +27 -0
- package/dist/features/board-v3/icons.d.ts +4 -0
- package/dist/features/board-v3/icons.jsx +100 -0
- package/dist/features/board-v3/index.d.ts +16 -0
- package/dist/features/board-v3/index.jsx +1678 -0
- package/dist/features/board-v3/polygon.d.ts +28 -0
- package/dist/features/board-v3/polygon.js +109 -0
- package/dist/features/board-v3/rect.d.ts +9 -0
- package/dist/features/board-v3/rect.js +152 -0
- package/dist/features/board-v3/resize-element.d.ts +12 -0
- package/dist/features/board-v3/resize-element.js +43 -0
- package/dist/features/board-v3/utils.d.ts +180 -0
- package/dist/features/board-v3/utils.js +1235 -0
- package/dist/features/navbar/index.d.ts +2 -0
- package/dist/features/navbar/index.jsx +5 -0
- package/dist/features/panel/index.d.ts +6 -0
- package/dist/features/panel/index.jsx +251 -0
- package/dist/features/panel/panel-slice.d.ts +23 -0
- package/dist/features/panel/panel-slice.js +46 -0
- package/dist/features/panel/select-tool.d.ts +6 -0
- package/dist/features/panel/select-tool.jsx +70 -0
- package/dist/features/panel/selected-group.d.ts +2 -0
- package/dist/features/panel/selected-group.jsx +93 -0
- package/dist/features/panel/square-circle-tool.d.ts +2 -0
- package/dist/features/panel/square-circle-tool.jsx +10 -0
- package/dist/features/panel/table-seat-circle.d.ts +2 -0
- package/dist/features/panel/table-seat-circle.jsx +36 -0
- package/dist/features/panel/table-seat-square.d.ts +2 -0
- package/dist/features/panel/table-seat-square.jsx +51 -0
- package/dist/features/panel/text-tool.d.ts +2 -0
- package/dist/features/panel/text-tool.jsx +57 -0
- package/dist/features/panel/upload-tool.d.ts +10 -0
- package/dist/features/panel/upload-tool.jsx +176 -0
- package/dist/features/panel/utils.d.ts +5 -0
- package/dist/features/panel/utils.js +47 -0
- package/dist/features/side-tool/index.d.ts +8 -0
- package/dist/features/side-tool/index.jsx +390 -0
- package/dist/features/side-tool/side-tool-slice.d.ts +16 -0
- package/dist/features/side-tool/side-tool-slice.js +28 -0
- package/dist/features/theme/theme-slice.d.ts +12 -0
- package/dist/features/theme/theme-slice.js +15 -0
- package/dist/features/view-only/index.d.ts +19 -0
- package/dist/features/view-only/index.jsx +205 -0
- package/dist/features/view-only-2/index.d.ts +19 -0
- package/dist/features/view-only-2/index.jsx +190 -0
- package/dist/features/view-only-3/index.d.ts +89 -0
- package/dist/features/view-only-3/index.jsx +590 -0
- package/dist/features/view-only-3/utils.d.ts +1 -0
- package/dist/features/view-only-3/utils.js +3 -0
- package/dist/hooks/use-redux.d.ts +4 -0
- package/dist/hooks/use-redux.js +3 -0
- package/dist/index.js +10 -0
- package/dist/libs/middleware.d.ts +2 -0
- package/dist/libs/middleware.js +5 -0
- package/dist/libs/rootReducer.d.ts +12 -0
- package/dist/libs/rootReducer.js +14 -0
- package/dist/libs/store.d.ts +18 -0
- package/dist/libs/store.js +19 -0
- package/dist/provider/antd-provider.d.ts +4 -0
- package/dist/provider/antd-provider.jsx +46 -0
- package/dist/provider/redux-provider.d.ts +3 -0
- package/dist/provider/redux-provider.jsx +6 -0
- package/dist/provider/store-provider.d.ts +4 -0
- package/dist/provider/store-provider.jsx +10 -0
- package/dist/utils/constant.d.ts +3 -0
- package/dist/utils/constant.js +13 -0
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +29 -0
- package/dist/utils/injectCss.d.ts +1 -0
- package/dist/utils/injectCss.js +13 -0
- package/dist/utils/regex.d.ts +3 -0
- package/dist/utils/regex.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isEmpty, omit } from "lodash";
|
|
3
|
+
import { arcByDirection, distributeWithSpacing, rectToPolygonNodes, rectToPolygonPoints, } from "./utils";
|
|
4
|
+
import { useAppSelector } from "../../hooks/use-redux";
|
|
5
|
+
const Layers = ({ components, selectedComponent, activeTool, selectionLines, }) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const hasPoints = selectionLines && !isEmpty(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.points);
|
|
8
|
+
const lockBackground = useAppSelector((state) => state.tool.lockBackground);
|
|
9
|
+
const renderShape = (item) => {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11
|
+
const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, } = item;
|
|
12
|
+
const commonProps = {
|
|
13
|
+
fill,
|
|
14
|
+
opacity,
|
|
15
|
+
stroke,
|
|
16
|
+
strokeWidth,
|
|
17
|
+
};
|
|
18
|
+
switch (shape) {
|
|
19
|
+
case "square":
|
|
20
|
+
return (<g key={id} data-id={id} id={id} transform={`translate(${x}, ${y})`}>
|
|
21
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
22
|
+
<rect {...commonProps} key={id} width={width} height={height} rx={radius}/>
|
|
23
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
24
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
26
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
27
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
28
|
+
return (<text {...omit(commonProps, [
|
|
29
|
+
"opacity",
|
|
30
|
+
"stroke",
|
|
31
|
+
"strokeWidth",
|
|
32
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
33
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
34
|
+
</text>);
|
|
35
|
+
})}
|
|
36
|
+
</g>
|
|
37
|
+
</g>
|
|
38
|
+
</g>);
|
|
39
|
+
case "polygon":
|
|
40
|
+
function isPolygonClosed(points) {
|
|
41
|
+
if (points.length < 3)
|
|
42
|
+
return false;
|
|
43
|
+
const first = points[0];
|
|
44
|
+
const last = points[points.length - 1];
|
|
45
|
+
return first.x === last.x && first.y === last.y;
|
|
46
|
+
}
|
|
47
|
+
const finalPoint = points.map((p) => `${p.x},${p.y}`).join(" ");
|
|
48
|
+
const isClosed = isPolygonClosed(points);
|
|
49
|
+
const showPoints = (selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.id) == id;
|
|
50
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
51
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
52
|
+
<polygon {...commonProps} key={id} points={finalPoint} x="0" y="0"/>
|
|
53
|
+
{(showPoints || !isClosed) &&
|
|
54
|
+
points.map((_, index) => {
|
|
55
|
+
return (<>
|
|
56
|
+
<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"}/>
|
|
57
|
+
<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"}/>
|
|
58
|
+
</>);
|
|
59
|
+
})}
|
|
60
|
+
</g>
|
|
61
|
+
</g>);
|
|
62
|
+
case "selection-box":
|
|
63
|
+
const pointsFormat = rectToPolygonPoints(x, y, width, height);
|
|
64
|
+
return (<g key={id} data-table={JSON.stringify(item)} data-id={id}>
|
|
65
|
+
<g transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
|
|
66
|
+
<polygon {...commonProps} key={id} points={pointsFormat}/>
|
|
67
|
+
{/* circle every points */}
|
|
68
|
+
{points.map((_, index) => {
|
|
69
|
+
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"/>);
|
|
70
|
+
})}
|
|
71
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
72
|
+
var _a, _b, _c, _d;
|
|
73
|
+
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})`}>
|
|
74
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
75
|
+
</text>);
|
|
76
|
+
})}
|
|
77
|
+
</g>
|
|
78
|
+
</g>);
|
|
79
|
+
case "circle":
|
|
80
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
81
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
82
|
+
<circle key={id} cx={width / 2} cy={height / 2} r={Math.min(height, width) / 2} fill={fill} {...commonProps}/>
|
|
83
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
84
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
86
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
87
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
88
|
+
return (<text {...omit(commonProps, [
|
|
89
|
+
"opacity",
|
|
90
|
+
"stroke",
|
|
91
|
+
"strokeWidth",
|
|
92
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
93
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
94
|
+
</text>);
|
|
95
|
+
})}
|
|
96
|
+
</g>
|
|
97
|
+
</g>
|
|
98
|
+
</g>);
|
|
99
|
+
case "diamond":
|
|
100
|
+
return (<g key={id} data-table={JSON.stringify(item)}>
|
|
101
|
+
<rect key={id} x={x} y={y} width={width} height={height} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps} fill={fill}/>
|
|
102
|
+
<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">
|
|
103
|
+
{label}
|
|
104
|
+
</text>
|
|
105
|
+
</g>);
|
|
106
|
+
case "table-seat-circle": {
|
|
107
|
+
const seatCount = item.seatCount;
|
|
108
|
+
const openSpace = (_a = item.openSpace) !== null && _a !== void 0 ? _a : 0;
|
|
109
|
+
// LOCAL SPACE (tanpa x,y)
|
|
110
|
+
const centerX = width / 2;
|
|
111
|
+
const centerY = height / 2;
|
|
112
|
+
// meja
|
|
113
|
+
const tableRadius = Math.min(width, height) / 2;
|
|
114
|
+
// seat statis
|
|
115
|
+
const seatRadius = 10;
|
|
116
|
+
const fullAngle = Math.PI * 2;
|
|
117
|
+
const availableAngle = fullAngle * (1 - openSpace);
|
|
118
|
+
const angleStart = (fullAngle - availableAngle) / 2;
|
|
119
|
+
const angleStep = availableAngle / seatCount;
|
|
120
|
+
const seatCircles = Array.from({ length: seatCount }, (_, i) => {
|
|
121
|
+
const angle = angleStart + i * angleStep;
|
|
122
|
+
const cx = centerX + (tableRadius + seatRadius) * Math.cos(angle);
|
|
123
|
+
const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
|
|
124
|
+
return { cx, cy };
|
|
125
|
+
});
|
|
126
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
127
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
128
|
+
{/* Meja */}
|
|
129
|
+
<circle cx={centerX} cy={centerY} r={tableRadius} fill={fill} {...commonProps}/>
|
|
130
|
+
{/* Seat */}
|
|
131
|
+
<g data-seat={`${id}-seats`}>
|
|
132
|
+
{seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
|
|
133
|
+
</g>
|
|
134
|
+
|
|
135
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
136
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
138
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
139
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
140
|
+
return (<text {...omit(commonProps, [
|
|
141
|
+
"opacity",
|
|
142
|
+
"stroke",
|
|
143
|
+
"strokeWidth",
|
|
144
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
145
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
146
|
+
</text>);
|
|
147
|
+
})}
|
|
148
|
+
</g>
|
|
149
|
+
</g>
|
|
150
|
+
</g>);
|
|
151
|
+
}
|
|
152
|
+
case "table-seat-rect-circle": {
|
|
153
|
+
const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
|
|
154
|
+
const base = clamp(Math.min(width, height) * 0.08, 12, 28);
|
|
155
|
+
const tableRadius = Math.min(width, height) / 2;
|
|
156
|
+
const seatSizeTB = {
|
|
157
|
+
w: base * 1.8, // lebih panjang
|
|
158
|
+
h: base * 0.9, // lebih tipis
|
|
159
|
+
};
|
|
160
|
+
const seatSizeLR = {
|
|
161
|
+
w: base * 0.9, // lebih tipis
|
|
162
|
+
h: base * 1.8, // lebih panjang
|
|
163
|
+
};
|
|
164
|
+
const openSpace = item.openSpace || 0;
|
|
165
|
+
const seatRadius = Math.min(width, height) * 0.2;
|
|
166
|
+
const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
|
|
167
|
+
const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
|
|
168
|
+
const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
|
|
169
|
+
const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
|
|
170
|
+
// split seats evenly on top and bottom
|
|
171
|
+
const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
|
|
172
|
+
const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
|
|
173
|
+
const availableWidth = width * (1 - openSpace);
|
|
174
|
+
const availableHeight = height * (1 - openSpace);
|
|
175
|
+
const spacingWidth = availableWidth / seatCountTopBottom;
|
|
176
|
+
const spacingHeight = availableHeight / seatCountLeftRight;
|
|
177
|
+
const topSeats = distributeWithSpacing({
|
|
178
|
+
start: 0,
|
|
179
|
+
length: width,
|
|
180
|
+
count: top,
|
|
181
|
+
radius: seatRadius,
|
|
182
|
+
spacing: spacingWidth,
|
|
183
|
+
}).map((cx) => ({
|
|
184
|
+
x: cx - seatSizeTB.w / 2,
|
|
185
|
+
y: -seatSizeTB.h,
|
|
186
|
+
width: seatSizeTB.w,
|
|
187
|
+
height: seatSizeTB.h,
|
|
188
|
+
id: "top",
|
|
189
|
+
}));
|
|
190
|
+
const bottomSeats = distributeWithSpacing({
|
|
191
|
+
start: 0,
|
|
192
|
+
length: width,
|
|
193
|
+
count: bottom,
|
|
194
|
+
radius: seatRadius,
|
|
195
|
+
spacing: spacingWidth,
|
|
196
|
+
}).map((cx) => ({
|
|
197
|
+
x: cx - seatSizeTB.w / 2,
|
|
198
|
+
y: height,
|
|
199
|
+
width: seatSizeTB.w,
|
|
200
|
+
height: seatSizeTB.h,
|
|
201
|
+
id: "bottom",
|
|
202
|
+
}));
|
|
203
|
+
const leftSeats = distributeWithSpacing({
|
|
204
|
+
start: 0,
|
|
205
|
+
length: height,
|
|
206
|
+
count: left,
|
|
207
|
+
radius: seatRadius,
|
|
208
|
+
spacing: spacingHeight,
|
|
209
|
+
}).map((cy) => ({
|
|
210
|
+
x: -seatSizeLR.w,
|
|
211
|
+
y: cy - seatSizeLR.h / 2,
|
|
212
|
+
width: seatSizeLR.w,
|
|
213
|
+
height: seatSizeLR.h,
|
|
214
|
+
id: "left",
|
|
215
|
+
}));
|
|
216
|
+
const rightSeats = distributeWithSpacing({
|
|
217
|
+
start: 0,
|
|
218
|
+
length: height,
|
|
219
|
+
count: right,
|
|
220
|
+
radius: seatRadius,
|
|
221
|
+
spacing: spacingHeight,
|
|
222
|
+
}).map((cy) => ({
|
|
223
|
+
x: width,
|
|
224
|
+
y: cy - seatSizeLR.h / 2,
|
|
225
|
+
width: seatSizeLR.w,
|
|
226
|
+
height: seatSizeLR.h,
|
|
227
|
+
id: "right",
|
|
228
|
+
}));
|
|
229
|
+
const seats = [
|
|
230
|
+
...topSeats,
|
|
231
|
+
...bottomSeats,
|
|
232
|
+
...leftSeats,
|
|
233
|
+
...rightSeats,
|
|
234
|
+
];
|
|
235
|
+
return (<g key={id} transform={`translate(${x}, ${y})`} data-id={id}>
|
|
236
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
237
|
+
{/* Seats */}
|
|
238
|
+
<circle cx={width / 2} cy={height / 2} r={tableRadius} {...commonProps} fill={fill}/>
|
|
239
|
+
<g key={`${id}-seats`} data-seat={`${id}-seats`}>
|
|
240
|
+
{seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (<rect x={x} y={y} key={`${id}-seat-${i}`} id={`seat-${id}`} height={height} width={width} rx={radius / 4} fill={seatFill}/>))}
|
|
241
|
+
</g>
|
|
242
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
243
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
244
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
245
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
246
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
247
|
+
return (<text {...omit(commonProps, [
|
|
248
|
+
"opacity",
|
|
249
|
+
"stroke",
|
|
250
|
+
"strokeWidth",
|
|
251
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
252
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
253
|
+
</text>);
|
|
254
|
+
})}
|
|
255
|
+
</g>
|
|
256
|
+
</g>
|
|
257
|
+
</g>);
|
|
258
|
+
}
|
|
259
|
+
case "table-seat-square": {
|
|
260
|
+
const openSpace = item.openSpace || 0; // from 0 to 0.9
|
|
261
|
+
const r = 10;
|
|
262
|
+
const seatPositions = item.seatPositions;
|
|
263
|
+
const topCount = (_b = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) !== null && _b !== void 0 ? _b : 0;
|
|
264
|
+
const bottomCount = (_c = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) !== null && _c !== void 0 ? _c : 0;
|
|
265
|
+
const leftCount = (_d = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) !== null && _d !== void 0 ? _d : 0;
|
|
266
|
+
const rightCount = (_e = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) !== null && _e !== void 0 ? _e : 0;
|
|
267
|
+
// split seats evenly on top and bottom
|
|
268
|
+
const seatCountTopBottom = Math.ceil(Math.max(topCount, bottomCount) / 2);
|
|
269
|
+
const seatCountLeftRight = Math.ceil(Math.max(leftCount, rightCount) / 2);
|
|
270
|
+
const availableWidth = width * (1 - openSpace);
|
|
271
|
+
const availableHeight = height * (1 - openSpace);
|
|
272
|
+
const spacingWidth = availableWidth / seatCountTopBottom;
|
|
273
|
+
const spacingHeight = availableHeight / seatCountLeftRight;
|
|
274
|
+
const topXs = distributeWithSpacing({
|
|
275
|
+
start: x,
|
|
276
|
+
length: width,
|
|
277
|
+
count: topCount,
|
|
278
|
+
radius: r,
|
|
279
|
+
spacing: spacingWidth,
|
|
280
|
+
});
|
|
281
|
+
const topSeats = topXs.map((cx) => ({ cx, cy: y - r, id: "top" }));
|
|
282
|
+
// TOP
|
|
283
|
+
const bottomSeats = distributeWithSpacing({
|
|
284
|
+
start: x,
|
|
285
|
+
length: width,
|
|
286
|
+
count: bottomCount,
|
|
287
|
+
radius: r,
|
|
288
|
+
spacing: spacingWidth,
|
|
289
|
+
}).map((cx) => ({
|
|
290
|
+
cx: cx,
|
|
291
|
+
cy: y + height + r,
|
|
292
|
+
id: "bottom",
|
|
293
|
+
}));
|
|
294
|
+
const leftYs = distributeWithSpacing({
|
|
295
|
+
start: y,
|
|
296
|
+
length: height,
|
|
297
|
+
count: leftCount,
|
|
298
|
+
radius: r,
|
|
299
|
+
spacing: spacingHeight,
|
|
300
|
+
});
|
|
301
|
+
const leftSeats = leftYs.map((cy) => ({ cx: x - r, cy, id: "left" }));
|
|
302
|
+
const rightSeats = distributeWithSpacing({
|
|
303
|
+
start: y,
|
|
304
|
+
length: height,
|
|
305
|
+
count: rightCount,
|
|
306
|
+
radius: r,
|
|
307
|
+
spacing: spacingHeight,
|
|
308
|
+
}).map((cy) => ({
|
|
309
|
+
cx: x + width + r,
|
|
310
|
+
cy,
|
|
311
|
+
id: "right",
|
|
312
|
+
}));
|
|
313
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
314
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
315
|
+
{/* Square Table */}
|
|
316
|
+
<rect width={width} height={height} {...commonProps} rx={radius} fill={fill}/>
|
|
317
|
+
{/* Seats */}
|
|
318
|
+
<g key={`${id}-seats`} data-seat={`${id}-seats`} transform={`translate(${-x}, ${-y})`}>
|
|
319
|
+
{[...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}/>))}
|
|
320
|
+
</g>
|
|
321
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
322
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
323
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
324
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
325
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
326
|
+
return (<text {...omit(commonProps, [
|
|
327
|
+
"opacity",
|
|
328
|
+
"stroke",
|
|
329
|
+
"strokeWidth",
|
|
330
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
331
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
332
|
+
</text>);
|
|
333
|
+
})}
|
|
334
|
+
</g>
|
|
335
|
+
</g>
|
|
336
|
+
</g>);
|
|
337
|
+
}
|
|
338
|
+
case "table-seat-half-square": {
|
|
339
|
+
const openSpace = item.openSpace || 0;
|
|
340
|
+
const seatRadius = Math.min(width, height) * 0.15;
|
|
341
|
+
const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
|
|
342
|
+
const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
|
|
343
|
+
const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
|
|
344
|
+
const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
|
|
345
|
+
// split seats evenly on top and bottom
|
|
346
|
+
const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
|
|
347
|
+
const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
|
|
348
|
+
const availableWidth = width * (1 - openSpace);
|
|
349
|
+
const availableHeight = height * (1 - openSpace);
|
|
350
|
+
const spacingWidth = availableWidth / seatCountTopBottom;
|
|
351
|
+
const spacingHeight = availableHeight / seatCountLeftRight;
|
|
352
|
+
const topSeats = distributeWithSpacing({
|
|
353
|
+
start: 0,
|
|
354
|
+
length: width,
|
|
355
|
+
count: top,
|
|
356
|
+
radius: seatRadius,
|
|
357
|
+
spacing: spacingWidth,
|
|
358
|
+
}).map((cx) => ({ cx, cy: seatRadius * 0.1, id: "top" }));
|
|
359
|
+
const bottomSeats = distributeWithSpacing({
|
|
360
|
+
start: 0,
|
|
361
|
+
length: width,
|
|
362
|
+
count: bottom,
|
|
363
|
+
radius: seatRadius,
|
|
364
|
+
spacing: spacingWidth,
|
|
365
|
+
}).map((cx) => ({
|
|
366
|
+
cx,
|
|
367
|
+
cy: height - seatRadius * 0.1,
|
|
368
|
+
id: "bottom",
|
|
369
|
+
}));
|
|
370
|
+
const leftSeats = distributeWithSpacing({
|
|
371
|
+
start: 0,
|
|
372
|
+
length: height,
|
|
373
|
+
count: left,
|
|
374
|
+
radius: seatRadius,
|
|
375
|
+
spacing: spacingHeight,
|
|
376
|
+
}).map((cy) => ({ cx: seatRadius * 0.1, cy, id: "left" }));
|
|
377
|
+
const rightSeats = distributeWithSpacing({
|
|
378
|
+
start: 0,
|
|
379
|
+
length: height,
|
|
380
|
+
count: right,
|
|
381
|
+
radius: seatRadius,
|
|
382
|
+
spacing: spacingHeight,
|
|
383
|
+
}).map((cy) => ({ cx: width - seatRadius * 0.1, cy, id: "right" }));
|
|
384
|
+
const seats = (_f = [
|
|
385
|
+
...topSeats,
|
|
386
|
+
...bottomSeats,
|
|
387
|
+
...leftSeats,
|
|
388
|
+
...rightSeats,
|
|
389
|
+
]) === null || _f === void 0 ? void 0 : _f.map((seat) => (Object.assign(Object.assign({}, seat), { d: arcByDirection({
|
|
390
|
+
cx: seat.cx,
|
|
391
|
+
cy: seat.cy,
|
|
392
|
+
r: seatRadius,
|
|
393
|
+
direction: seat.id,
|
|
394
|
+
fraction: 0.4,
|
|
395
|
+
}) })));
|
|
396
|
+
return (<g key={id} transform={`translate(${x}, ${y})`} data-id={id}>
|
|
397
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
398
|
+
{/* Seats */}
|
|
399
|
+
<rect width={width} height={height} rx={radius} {...commonProps} fill={fill}/>
|
|
400
|
+
<g key={`${id}-seats`} data-seat={`${id}-seats`}>
|
|
401
|
+
{seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (<path key={`${id}-seat-${i}`} id={`seat-${id}`} d={d} fill="white"/>))}
|
|
402
|
+
</g>
|
|
403
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
404
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
405
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
406
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
407
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
408
|
+
return (<text {...omit(commonProps, [
|
|
409
|
+
"opacity",
|
|
410
|
+
"stroke",
|
|
411
|
+
"strokeWidth",
|
|
412
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
413
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
414
|
+
</text>);
|
|
415
|
+
})}
|
|
416
|
+
</g>
|
|
417
|
+
</g>
|
|
418
|
+
</g>);
|
|
419
|
+
}
|
|
420
|
+
case "table-seat-rect-square": {
|
|
421
|
+
const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
|
|
422
|
+
const base = clamp(Math.min(width, height) * 0.08, 12, 28);
|
|
423
|
+
const seatSizeTB = {
|
|
424
|
+
w: base * 1.8, // lebih panjang
|
|
425
|
+
h: base * 0.9, // lebih tipis
|
|
426
|
+
};
|
|
427
|
+
const seatSizeLR = {
|
|
428
|
+
w: base * 0.9, // lebih tipis
|
|
429
|
+
h: base * 1.8, // lebih panjang
|
|
430
|
+
};
|
|
431
|
+
const openSpace = item.openSpace || 0;
|
|
432
|
+
const seatRadius = Math.min(width, height) * 0.2;
|
|
433
|
+
const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
|
|
434
|
+
const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
|
|
435
|
+
const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
|
|
436
|
+
const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
|
|
437
|
+
// split seats evenly on top and bottom
|
|
438
|
+
const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
|
|
439
|
+
const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
|
|
440
|
+
const availableWidth = width * (1 - openSpace);
|
|
441
|
+
const availableHeight = height * (1 - openSpace);
|
|
442
|
+
const spacingWidth = availableWidth / seatCountTopBottom;
|
|
443
|
+
const spacingHeight = availableHeight / seatCountLeftRight;
|
|
444
|
+
const topSeats = distributeWithSpacing({
|
|
445
|
+
start: x,
|
|
446
|
+
length: width,
|
|
447
|
+
count: top,
|
|
448
|
+
radius: seatRadius,
|
|
449
|
+
spacing: spacingWidth,
|
|
450
|
+
}).map((cx) => ({
|
|
451
|
+
x: cx - seatSizeTB.w / 2,
|
|
452
|
+
y: y - seatSizeTB.h,
|
|
453
|
+
width: seatSizeTB.w,
|
|
454
|
+
height: seatSizeTB.h,
|
|
455
|
+
id: "top",
|
|
456
|
+
}));
|
|
457
|
+
const bottomSeats = distributeWithSpacing({
|
|
458
|
+
start: x,
|
|
459
|
+
length: width,
|
|
460
|
+
count: bottom,
|
|
461
|
+
radius: seatRadius,
|
|
462
|
+
spacing: spacingWidth,
|
|
463
|
+
}).map((cx) => ({
|
|
464
|
+
x: cx - seatSizeTB.w / 2,
|
|
465
|
+
y: y + height,
|
|
466
|
+
width: seatSizeTB.w,
|
|
467
|
+
height: seatSizeTB.h,
|
|
468
|
+
id: "bottom",
|
|
469
|
+
}));
|
|
470
|
+
const leftSeats = distributeWithSpacing({
|
|
471
|
+
start: 0,
|
|
472
|
+
length: height,
|
|
473
|
+
count: left,
|
|
474
|
+
radius: seatRadius,
|
|
475
|
+
spacing: spacingHeight,
|
|
476
|
+
}).map((cy) => ({
|
|
477
|
+
x: x - seatSizeLR.w,
|
|
478
|
+
y: y + cy - seatSizeLR.h / 2,
|
|
479
|
+
width: seatSizeLR.w,
|
|
480
|
+
height: seatSizeLR.h,
|
|
481
|
+
id: "left",
|
|
482
|
+
}));
|
|
483
|
+
const rightSeats = distributeWithSpacing({
|
|
484
|
+
start: 0,
|
|
485
|
+
length: height,
|
|
486
|
+
count: right,
|
|
487
|
+
radius: seatRadius,
|
|
488
|
+
spacing: spacingHeight,
|
|
489
|
+
}).map((cy) => ({
|
|
490
|
+
x: x + width,
|
|
491
|
+
y: y + cy - seatSizeLR.h / 2,
|
|
492
|
+
width: seatSizeLR.w,
|
|
493
|
+
height: seatSizeLR.h,
|
|
494
|
+
id: "right",
|
|
495
|
+
}));
|
|
496
|
+
const seats = [
|
|
497
|
+
...topSeats,
|
|
498
|
+
...bottomSeats,
|
|
499
|
+
...leftSeats,
|
|
500
|
+
...rightSeats,
|
|
501
|
+
];
|
|
502
|
+
return (<g key={id} transform={`translate(${x}, ${y})`} data-id={id}>
|
|
503
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
504
|
+
{/* Seats */}
|
|
505
|
+
<rect width={width} height={height} rx={radius} {...commonProps} fill={fill}/>
|
|
506
|
+
<g key={`${id}-seats`} data-seat={`${id}-seats`} transform={`translate(${-x}, ${-y})`}>
|
|
507
|
+
{seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (<rect x={x} y={y} key={`${id}-seat-${i}`} id={`seat-${id}`} height={height} width={width} rx={radius / 4} fill={seatFill}/>))}
|
|
508
|
+
</g>
|
|
509
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
510
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
511
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
512
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
513
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
514
|
+
return (<text {...omit(commonProps, [
|
|
515
|
+
"opacity",
|
|
516
|
+
"stroke",
|
|
517
|
+
"strokeWidth",
|
|
518
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
519
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
520
|
+
</text>);
|
|
521
|
+
})}
|
|
522
|
+
</g>
|
|
523
|
+
</g>
|
|
524
|
+
</g>);
|
|
525
|
+
}
|
|
526
|
+
case "text":
|
|
527
|
+
return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
|
|
528
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
529
|
+
<rect width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
530
|
+
<text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
531
|
+
{text}
|
|
532
|
+
</text>
|
|
533
|
+
</g>
|
|
534
|
+
</g>);
|
|
535
|
+
case "image-table":
|
|
536
|
+
case "background":
|
|
537
|
+
return (<g key={id} id={id} data-id={id} transform={`translate(${x}, ${y})`} style={{
|
|
538
|
+
pointerEvents: lockBackground ? "none" : "auto",
|
|
539
|
+
}}>
|
|
540
|
+
<g transform={`rotate(${rotation}, 0, 0)`}>
|
|
541
|
+
<image href={src} width={width} height={height} {...commonProps}/>
|
|
542
|
+
<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
|
|
543
|
+
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
544
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
545
|
+
const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
|
|
546
|
+
const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
|
|
547
|
+
return (<text {...omit(commonProps, [
|
|
548
|
+
"opacity",
|
|
549
|
+
"stroke",
|
|
550
|
+
"strokeWidth",
|
|
551
|
+
])} transform={`rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`} key={`${id}-label-${index}`} x={width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0)} y={height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0)} fill={(_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black"} fontSize={`${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
|
|
552
|
+
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
553
|
+
</text>);
|
|
554
|
+
})}
|
|
555
|
+
</g>
|
|
556
|
+
</g>
|
|
557
|
+
</g>);
|
|
558
|
+
case "bounding-box": {
|
|
559
|
+
return (<g key={id} transform={`translate(${x}, ${y})`} data-bounding-box={id}>
|
|
560
|
+
<rect width={width} height={height} fill="none" stroke="#3b82f6" strokeWidth={1} strokeDasharray="6 4" pointerEvents="none"/>
|
|
561
|
+
</g>);
|
|
562
|
+
}
|
|
563
|
+
default:
|
|
564
|
+
return <g key={id}/>;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
let date = new Date();
|
|
568
|
+
const nodesRaw = rectToPolygonNodes(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.width, selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.height);
|
|
569
|
+
return (<g key={`${date}`} id="selection-layer">
|
|
570
|
+
{components === null || components === void 0 ? void 0 : components.map(renderShape)}
|
|
571
|
+
{!isEmpty(selectionLines) && activeTool === "select" && (<>
|
|
572
|
+
{nodesRaw.map((p1, index) => {
|
|
573
|
+
const p2 = nodesRaw[(index + 2) % nodesRaw.length];
|
|
574
|
+
const side = index === 0
|
|
575
|
+
? "top"
|
|
576
|
+
: index === 1
|
|
577
|
+
? "right"
|
|
578
|
+
: index === 2
|
|
579
|
+
? "bottom"
|
|
580
|
+
: "left";
|
|
581
|
+
const mx = (p1.x + p2.x) / 2;
|
|
582
|
+
const my = (p1.y + p2.y) / 2;
|
|
583
|
+
if (side === "top")
|
|
584
|
+
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})`}>
|
|
585
|
+
<g transform={`rotate(${0}, 0,0)`}>
|
|
586
|
+
{side === "top" && (<g id="help-group-1">
|
|
587
|
+
<line x1={mx} y1={my + selectionLines.height / 2} x2={mx} y2={my - selectionLines.height / 3 - 10} // panjang line
|
|
588
|
+
stroke="#4a90e2" strokeWidth={2} id="line-help"/>
|
|
589
|
+
|
|
590
|
+
<circle id="circle-help" data-role="rotate" cx={mx} cy={my - selectionLines.height / 3 - 10} r={8} fill="#4a90e2"/>
|
|
591
|
+
</g>)}
|
|
592
|
+
</g>
|
|
593
|
+
</g>);
|
|
594
|
+
})}
|
|
595
|
+
<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})`}>
|
|
596
|
+
<g transform={`rotate(${0}, 0,0)`}>
|
|
597
|
+
{!hasPoints && (<rect width={selectionLines.width} height={selectionLines.height} fill="none" stroke="#4a90e2" strokeWidth={1} id="rect-box-selection"/>)}
|
|
598
|
+
|
|
599
|
+
{!hasPoints &&
|
|
600
|
+
(nodesRaw === null || nodesRaw === void 0 ? void 0 : nodesRaw.map((node, index) => {
|
|
601
|
+
const corner = (index) => {
|
|
602
|
+
switch (index) {
|
|
603
|
+
case 0:
|
|
604
|
+
return "top-left";
|
|
605
|
+
case 1:
|
|
606
|
+
return "top";
|
|
607
|
+
case 2:
|
|
608
|
+
return "top-right";
|
|
609
|
+
case 3:
|
|
610
|
+
return "right";
|
|
611
|
+
case 4:
|
|
612
|
+
return "bottom-right";
|
|
613
|
+
case 5:
|
|
614
|
+
return "bottom";
|
|
615
|
+
case 6:
|
|
616
|
+
return "bottom-left";
|
|
617
|
+
case 7:
|
|
618
|
+
return "left";
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
return (<>
|
|
622
|
+
<circle data-position={corner(index)} key={index} r={5} cx={node.x} cy={node.y} fill="transparent" style={{ cursor: "pointer" }}/>
|
|
623
|
+
<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" }}/>
|
|
624
|
+
</>);
|
|
625
|
+
}))}
|
|
626
|
+
</g>
|
|
627
|
+
</g>
|
|
628
|
+
</>)}
|
|
629
|
+
</g>);
|
|
630
|
+
};
|
|
631
|
+
export default Layers;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function rectToPolygonPoints(x: number, y: number, width: number, height: number): string;
|
|
2
|
+
export declare function rectToPolygonNodes(width: number, height: number): {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}[];
|
|
6
|
+
export declare function distributeWithSpacing({ start, length, count, radius, spacing, }: {
|
|
7
|
+
start: number;
|
|
8
|
+
length: number;
|
|
9
|
+
count: number;
|
|
10
|
+
radius: number;
|
|
11
|
+
spacing?: number;
|
|
12
|
+
}): number[];
|
|
13
|
+
export declare const arcByDirection: ({ cx, cy, r, direction, fraction, }: {
|
|
14
|
+
cx: number;
|
|
15
|
+
cy: number;
|
|
16
|
+
r: number;
|
|
17
|
+
direction?: string;
|
|
18
|
+
fraction?: number;
|
|
19
|
+
}) => string;
|