seat-editor 1.6.12 → 1.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/app/layout.d.ts +1 -1
  2. package/dist/app/{layout.jsx → layout.js} +2 -7
  3. package/dist/app/new-board/page.d.ts +1 -1
  4. package/dist/app/new-board/page.js +33 -0
  5. package/dist/app/old-board/page.d.ts +1 -2
  6. package/dist/app/old-board/{page.jsx → page.js} +82 -215
  7. package/dist/app/only-view/page.d.ts +1 -1
  8. package/dist/app/only-view/{page.jsx → page.js} +2 -1
  9. package/dist/app/page.d.ts +1 -1
  10. package/dist/app/page.js +8 -0
  11. package/dist/app/test/page.d.ts +1 -0
  12. package/dist/app/test/page.js +43 -0
  13. package/dist/app/v2/page.d.ts +2 -0
  14. package/dist/app/v2/page.js +8 -0
  15. package/dist/components/button-tools/index.d.ts +1 -1
  16. package/dist/components/button-tools/index.js +11 -0
  17. package/dist/components/form-tools/label.d.ts +1 -1
  18. package/dist/components/form-tools/label.js +7 -0
  19. package/dist/components/form-tools/shape.d.ts +1 -1
  20. package/dist/components/form-tools/shape.js +25 -0
  21. package/dist/components/input/number-indicator.d.ts +1 -1
  22. package/dist/components/input/{number-indicator.jsx → number-indicator.js} +2 -11
  23. package/dist/components/joystick/index.d.ts +1 -2
  24. package/dist/components/joystick/{index.jsx → index.js} +13 -14
  25. package/dist/components/layer/index.d.ts +1 -1
  26. package/dist/components/layer/index.js +295 -0
  27. package/dist/components/layer-v2/index.d.ts +19 -0
  28. package/dist/components/layer-v2/index.js +295 -0
  29. package/dist/components/lib/index.d.ts +1 -1
  30. package/dist/components/lib/{index.jsx → index.js} +2 -7
  31. package/dist/components/modal-preview/index.d.ts +1 -1
  32. package/dist/components/modal-preview/index.js +10 -0
  33. package/dist/features/board/index.d.ts +1 -1
  34. package/dist/features/board/{index.jsx → index.js} +31 -90
  35. package/dist/features/board-v2/board-slice.d.ts +14 -0
  36. package/dist/features/board-v2/board-slice.js +52 -0
  37. package/dist/features/board-v2/index.d.ts +6 -0
  38. package/dist/features/board-v2/index.js +666 -0
  39. package/dist/features/navbar/index.d.ts +1 -1
  40. package/dist/features/navbar/index.js +6 -0
  41. package/dist/features/package/index.d.ts +1 -1
  42. package/dist/features/package/{index.jsx → index.js} +7 -17
  43. package/dist/features/panel/index.d.ts +1 -1
  44. package/dist/features/panel/{index.jsx → index.js} +8 -18
  45. package/dist/features/panel/select-tool.d.ts +1 -1
  46. package/dist/features/panel/{select-tool.jsx → select-tool.js} +8 -20
  47. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  48. package/dist/features/panel/{square-circle-tool.jsx → square-circle-tool.js} +2 -4
  49. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  50. package/dist/features/panel/table-seat-circle.js +9 -0
  51. package/dist/features/panel/text-tool.d.ts +1 -1
  52. package/dist/features/panel/text-tool.js +7 -0
  53. package/dist/features/panel/upload-tool.d.ts +1 -1
  54. package/dist/features/panel/{upload-tool.jsx → upload-tool.js} +2 -24
  55. package/dist/features/side-tool/index.d.ts +1 -1
  56. package/dist/features/side-tool/{index.jsx → index.js} +83 -89
  57. package/dist/features/view/index.d.ts +1 -1
  58. package/dist/features/view/{index.jsx → index.js} +31 -38
  59. package/dist/features/view-only/index.d.ts +1 -1
  60. package/dist/features/view-only/{index.jsx → index.js} +31 -38
  61. package/dist/provider/antd-provider.js +43 -0
  62. package/dist/provider/redux-provider.d.ts +1 -1
  63. package/dist/provider/{redux-provider.jsx → redux-provider.js} +2 -1
  64. package/dist/provider/store-provider.d.ts +1 -1
  65. package/dist/provider/{store-provider.jsx → store-provider.js} +2 -3
  66. package/package.json +1 -1
  67. package/dist/app/new-board/page.jsx +0 -53
  68. package/dist/app/page.jsx +0 -13
  69. package/dist/components/button-tools/index.jsx +0 -17
  70. package/dist/components/form-tools/label.jsx +0 -44
  71. package/dist/components/form-tools/shape.jsx +0 -66
  72. package/dist/components/layer/index.jsx +0 -383
  73. package/dist/components/modal-preview/index.jsx +0 -11
  74. package/dist/features/navbar/index.jsx +0 -5
  75. package/dist/features/panel/table-seat-circle.jsx +0 -31
  76. package/dist/features/panel/text-tool.jsx +0 -26
  77. package/dist/provider/antd-provider.jsx +0 -46
@@ -0,0 +1,295 @@
1
+ "use client";
2
+ import { createElement as _createElement } from "react";
3
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
4
+ import { useRef } from "react";
5
+ import { omit } from "lodash";
6
+ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style, onTouchEnd, onTouchMove, onTouchStart }) => {
7
+ const refItemTemp = useRef(null);
8
+ const handleOnHover = (item) => {
9
+ if (mode === "edit") {
10
+ refItemTemp.current = item;
11
+ }
12
+ };
13
+ const renderShadowShape = (item) => {
14
+ const { id, x, y, width, height, fill, opacity, rotation, shape, fontColor, text, seatFill, labels, } = item;
15
+ const commonProps = { fill, opacity };
16
+ switch (shape) {
17
+ case "square":
18
+ return (_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height }, commonProps), id));
19
+ case "circle":
20
+ return (_jsx("circle", Object.assign({ cx: x + width / 2, cy: y + height / 2, r: width / 2 }, commonProps), id));
21
+ case "diamond":
22
+ return (_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, transform: `rotate(${rotation}, ${x}, ${y})` }, commonProps), id));
23
+ case "table-seat-circle": {
24
+ const seatCount = item.seatCount;
25
+ const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
26
+ const centerX = x + width / 2;
27
+ const centerY = y + height / 2;
28
+ const radius = width;
29
+ const seatRadius = width / 4;
30
+ const fullAngle = 2 * Math.PI;
31
+ const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
32
+ const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
33
+ const angleStep = availableAngle / seatCount;
34
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
35
+ const angle = angleStart + i * angleStep;
36
+ const cx = centerX + radius * Math.cos(angle);
37
+ const cy = centerY + radius * Math.sin(angle);
38
+ return { cx, cy };
39
+ });
40
+ 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) => {
41
+ var _a, _b, _c, _d;
42
+ 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}`));
43
+ }), _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));
44
+ }
45
+ case "table-seat-square": {
46
+ const seatCount = item.seatCount || 6;
47
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
48
+ const seatRadius = width / 6;
49
+ // split seats evenly on top and bottom
50
+ const seatCountPerSide = Math.ceil(seatCount / 2);
51
+ const availableWidth = width * (1 - openSpace);
52
+ const startX = x + (width * openSpace) / 2;
53
+ const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
54
+ const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
55
+ cx: startX + i * spacing,
56
+ cy: y - seatRadius * 1.5,
57
+ }));
58
+ const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
59
+ (_, i) => ({
60
+ cx: startX + i * spacing,
61
+ cy: y + height + seatRadius * 1.5,
62
+ }));
63
+ 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));
64
+ }
65
+ case "text":
66
+ return (_jsxs("g", { onClick: () => {
67
+ onClick && onClick(item);
68
+ }, 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));
69
+ case "ruler":
70
+ return (_jsxs("g", { children: [_jsx("rect", { x: x - (window.innerWidth * 3) / 2, y: y, width: window.innerWidth * 3, height: 1, fill: "black" }), _jsx("rect", { x: x, y: y - (window.innerHeight * 3) / 2, width: 1, height: window.innerHeight * 3, fill: "black" })] }, id));
71
+ default:
72
+ return null;
73
+ }
74
+ };
75
+ const renderShape = (item) => {
76
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, } = item;
77
+ const commonProps = {
78
+ fill,
79
+ opacity,
80
+ stroke,
81
+ strokeWidth,
82
+ onMouseDown: (e) => {
83
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, item || refItemTemp.current);
84
+ },
85
+ onMouseEnter: (e) => {
86
+ // e.stopPropagation();
87
+ handleOnHover === null || handleOnHover === void 0 ? void 0 : handleOnHover(item);
88
+ },
89
+ onClick: (e) => {
90
+ // e.stopPropagation();
91
+ onClick === null || onClick === void 0 ? void 0 : onClick(item);
92
+ },
93
+ onMouseUp: (e) => {
94
+ // e.stopPropagation();
95
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
96
+ },
97
+ onBlur: (e) => {
98
+ // e.stopPropagation();
99
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur();
100
+ },
101
+ onTouchMove: (e) => {
102
+ // e.stopPropagation();
103
+ onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(e);
104
+ },
105
+ onTouchStart: (e) => {
106
+ // e.stopPropagation();
107
+ onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e, item);
108
+ },
109
+ onTouchEnd: (e) => {
110
+ // e.stopPropagation();
111
+ onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
112
+ },
113
+ onDoubleClick: (e) => {
114
+ // e.stopPropagation();
115
+ onClick === null || onClick === void 0 ? void 0 : onClick(item);
116
+ },
117
+ };
118
+ switch (shape) {
119
+ case "square":
120
+ 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) => {
121
+ var _a, _b, _c, _d;
122
+ return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { key: `${id}-label-${index}`, x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, onClick: (e) => {
123
+ e.stopPropagation();
124
+ onClick && onClick(item);
125
+ } }), _ === null || _ === void 0 ? void 0 : _.label));
126
+ })] }, id));
127
+ case "circle":
128
+ 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) => {
129
+ var _a, _b, _c, _d;
130
+ 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) => {
131
+ e.stopPropagation();
132
+ onClick && onClick(item);
133
+ }, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
134
+ })] }, id));
135
+ case "diamond":
136
+ 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));
137
+ case "table-seat-circle": {
138
+ const seatCount = item.seatCount;
139
+ const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
140
+ const centerX = x + width / 2;
141
+ const centerY = y + height / 2;
142
+ const radius = width;
143
+ const seatRadius = width / 4;
144
+ const fullAngle = 2 * Math.PI;
145
+ const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
146
+ const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
147
+ const angleStep = availableAngle / seatCount;
148
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
149
+ const angle = angleStart + i * angleStep;
150
+ const cx = centerX + radius * Math.cos(angle);
151
+ const cy = centerY + radius * Math.sin(angle);
152
+ return { cx, cy };
153
+ });
154
+ 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) => {
155
+ var _a, _b, _c, _d;
156
+ 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) => {
157
+ e.stopPropagation();
158
+ onClick && onClick(item);
159
+ }, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
160
+ }), _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));
161
+ }
162
+ case "table-seat-square": {
163
+ const seatCount = item.seatCount || 6;
164
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
165
+ const seatRadius = width / 6;
166
+ // split seats evenly on top and bottom
167
+ const seatCountPerSide = Math.ceil(seatCount / 2);
168
+ const availableWidth = width * (1 - openSpace);
169
+ const startX = x + (width * openSpace) / 2;
170
+ const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
171
+ const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
172
+ cx: startX + i * spacing,
173
+ cy: y - seatRadius * 1.5,
174
+ }));
175
+ const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
176
+ (_, i) => ({
177
+ cx: startX + i * spacing,
178
+ cy: y + height + seatRadius * 1.5,
179
+ }));
180
+ 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));
181
+ }
182
+ case "text":
183
+ return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y, width: width, height: height, fill: "transparent", opacity: opacity, onClick: (e) => {
184
+ e.stopPropagation();
185
+ onClick && onClick(item);
186
+ } }), _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));
187
+ case "image-table":
188
+ case "background":
189
+ return (_jsxs("g", { onClick: () => {
190
+ onClick && onClick(item);
191
+ }, 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) => {
192
+ var _a, _b, _c, _d;
193
+ 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));
194
+ })] }, id));
195
+ default:
196
+ return _jsx("g", {}, id);
197
+ }
198
+ };
199
+ let date = new Date();
200
+ 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 && activeTool === "select" && (_jsxs(_Fragment, { children: [[
201
+ "square",
202
+ "circle",
203
+ "diamond",
204
+ "text",
205
+ "background",
206
+ "image-table",
207
+ ].includes(selectedComponent.shape) && (_jsxs("g", { children: [_jsx("rect", { x: selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2",
208
+ // transform={`scale(${selectedComponent.scale})`}
209
+ onMouseDown: (e) => {
210
+ e.stopPropagation();
211
+ onMouseDown(e, selectedComponent, "top-left");
212
+ }, onTouchStart: (e) => {
213
+ e.stopPropagation();
214
+ onTouchStart(e, selectedComponent, "top-left");
215
+ }, onTouchMove: (e) => {
216
+ e.stopPropagation();
217
+ onTouchMove(e);
218
+ } }), _jsx("rect", { x: selectedComponent.x + (selectedComponent.width - 15) / 2, y: selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
219
+ e.stopPropagation();
220
+ onMouseDown(e, selectedComponent, "top-center");
221
+ }, onTouchStart: (e) => {
222
+ e.stopPropagation();
223
+ onTouchStart(e, selectedComponent, "top-center");
224
+ }, onTouchMove: (e) => {
225
+ e.stopPropagation();
226
+ onTouchMove(e);
227
+ } }), _jsx("rect", { x: selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y + (selectedComponent.height - 15) / 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
228
+ e.stopPropagation();
229
+ onMouseDown(e, selectedComponent, "left-center");
230
+ }, onTouchStart: (e) => {
231
+ e.stopPropagation();
232
+ onTouchStart(e, selectedComponent, "left-center");
233
+ }, onTouchMove: (e) => {
234
+ e.stopPropagation();
235
+ onTouchMove(e);
236
+ } }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
237
+ e.stopPropagation();
238
+ onMouseDown(e, selectedComponent, "top-right");
239
+ }, onTouchStart: (e) => {
240
+ e.stopPropagation();
241
+ onTouchStart(e, selectedComponent, "top-right");
242
+ }, onTouchMove: (e) => {
243
+ e.stopPropagation();
244
+ onTouchMove(e);
245
+ } }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
246
+ e.stopPropagation();
247
+ onMouseDown(e, selectedComponent, "bottom-right");
248
+ }, onTouchStart: (e) => {
249
+ e.stopPropagation();
250
+ onTouchStart(e, selectedComponent, "bottom-right");
251
+ }, onTouchMove: (e) => {
252
+ e.stopPropagation();
253
+ onTouchMove(e);
254
+ } }), _jsx("rect", { x: selectedComponent.x + (selectedComponent.width - 15) / 2, y: selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
255
+ e.stopPropagation();
256
+ onMouseDown(e, selectedComponent, "bottom-center");
257
+ }, onTouchStart: (e) => {
258
+ e.stopPropagation();
259
+ onTouchStart(e, selectedComponent, "bottom-center");
260
+ }, onTouchMove: (e) => {
261
+ e.stopPropagation();
262
+ onTouchMove(e);
263
+ } }), _jsx("rect", { x: selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y + (selectedComponent.height - 15) / 2, width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
264
+ e.stopPropagation();
265
+ onMouseDown(e, selectedComponent, "right-center");
266
+ }, onTouchStart: (e) => {
267
+ e.stopPropagation();
268
+ onTouchStart(e, selectedComponent, "right-center");
269
+ }, onTouchMove: (e) => {
270
+ e.stopPropagation();
271
+ onTouchMove(e);
272
+ } }), _jsx("rect", { x: selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), y: selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0), width: 20, height: 20, fill: "black", stroke: "white", strokeWidth: "2", onMouseDown: (e) => {
273
+ e.stopPropagation();
274
+ onMouseDown(e, selectedComponent, "bottom-left");
275
+ }, onTouchStart: (e) => {
276
+ e.stopPropagation();
277
+ onTouchStart(e, selectedComponent, "bottom-left");
278
+ }, onTouchMove: (e) => {
279
+ e.stopPropagation();
280
+ onTouchMove(e);
281
+ } })] }, `${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) => {
282
+ e.stopPropagation();
283
+ onMouseDown(e, selectedComponent, "top-left");
284
+ } }), _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) => {
285
+ e.stopPropagation();
286
+ onMouseDown(e, selectedComponent, "top-right");
287
+ } }), _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) => {
288
+ e.stopPropagation();
289
+ onMouseDown(e, selectedComponent, "bottom-right");
290
+ } }), _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) => {
291
+ e.stopPropagation();
292
+ onMouseDown(e, selectedComponent, "b-left");
293
+ } })] }, selectedComponent.id))] }))] }, `${date}`));
294
+ };
295
+ 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 };
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  import { useEffect } from "react";
3
4
  import Board from "../../features/board";
4
5
  import SideTool from "../../features/side-tool";
@@ -21,13 +22,7 @@ const TableEditor = ({ componentProps = [], extraComponentProps = [], }) => {
21
22
  });
22
23
  }
23
24
  }, [componentProps, extraComponentProps]);
24
- return (<>
25
- <div className="w-full h-screen flex relative">
26
- <SideTool />
27
- <Board />
28
- <ControlPanels />
29
- </div>
30
- </>);
25
+ return (_jsx(_Fragment, { children: _jsxs("div", { className: "w-full h-screen flex relative", children: [_jsx(SideTool, {}), _jsx(Board, {}), _jsx(ControlPanels, {})] }) }));
31
26
  };
32
27
  export default TableEditor;
33
28
  export { LayerView };
@@ -1,4 +1,4 @@
1
1
  declare const ModalPreview: ({ children }: {
2
2
  children: React.ReactNode;
3
- }) => import("react").JSX.Element;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
4
  export default ModalPreview;
@@ -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;
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
3
  import { useCallback, useEffect, useRef, useState } from "react";
3
4
  import { TransformWrapper, TransformComponent, MiniMap, } from "react-zoom-pan-pinch";
4
5
  import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
@@ -607,21 +608,15 @@ const BoardTemplate = ({ onSelectComponent }) => {
607
608
  }
608
609
  };
609
610
  const renderMiniMap = () => {
610
- return (<MiniMap width={250} height={250}>
611
- <div className="w-full h-full">
612
- <svg id="workspace" width="100%" height="100%" viewBox={`0 0 ${widthBoard} ${heightBoard}`} className="h-screen w-full" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
613
- background: "#f5f5f5",
614
- display: "block",
615
- }}>
616
- <Layers shadowShape={shadowShape} components={[...extraComponentsState, ...componentsState]} activeTool={activeTool}
617
- // onClick={handleSelectComponent}
618
- // onMouseDown={handleMouseDown}
619
- // onMouseUp={handleMouseUp}
620
- // onBlur={handleUnSelectComponent}
621
- selectedComponent={selectedComponent}/>
622
- </svg>
623
- </div>
624
- </MiniMap>);
611
+ return (_jsx(MiniMap, { width: 250, height: 250, children: _jsx("div", { className: "w-full h-full", children: _jsx("svg", { id: "workspace", width: "100%", height: "100%", viewBox: `0 0 ${widthBoard} ${heightBoard}`, className: "h-screen w-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
612
+ background: "#f5f5f5",
613
+ display: "block",
614
+ }, children: _jsx(Layers, { shadowShape: shadowShape, components: [...extraComponentsState, ...componentsState], activeTool: activeTool,
615
+ // onClick={handleSelectComponent}
616
+ // onMouseDown={handleMouseDown}
617
+ // onMouseUp={handleMouseUp}
618
+ // onBlur={handleUnSelectComponent}
619
+ selectedComponent: selectedComponent }) }) }) }));
625
620
  };
626
621
  const handelZoomIn = () => {
627
622
  var _a;
@@ -647,80 +642,26 @@ const BoardTemplate = ({ onSelectComponent }) => {
647
642
  // moveComponent &&
648
643
  // isTouching.current &&
649
644
  // !resizeDirection
650
- return (<>
651
- <ModalPreview>
652
- <LayerView statusKey="status"/>
653
- </ModalPreview>
654
- <div className="relative w-full h-screen flex-1 overflow-hidden" ref={containerRef}>
655
- <div className="absolute bottom-5 left-1/2 transform -translate-x-1/2 z-10">
656
- <div className="flex gap-2">
657
- <Button icon={<ZoomIn />} onClick={handelZoomIn}/>
658
- <Button icon={<ZoomOut />} onClick={handleZoomOut}/>
659
- </div>
660
- </div>
661
- <TransformWrapper ref={transformRef} panning={{ disabled: activeTool === "select" }} centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} // sangat kecil = bisa zoom out jauh
662
- maxScale={1000} initialScale={1} pinch={{ step: 1 }} smooth={true} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding>
663
- {scale > 1 && (<div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10">
664
- {renderMiniMap()}
665
- </div>)}
666
- <TransformComponent wrapperStyle={{
667
- width: "100%",
668
- height: "100%",
669
- overflow: "hidden",
670
- }} contentStyle={{
671
- width: "100%",
672
- height: "100%",
673
- }}>
674
- <svg id="workspace" ref={svgRef} width="100%" height="100%" viewBox={`0 0 ${widthBoard} ${heightBoard}`} className="h-screen" onMouseUp={handleMouseUp} onMouseMove={handleMouseMove} onMouseEnter={handleMouseEnter} onClick={(e) => {
675
- e.stopPropagation();
676
- handleMouseClick(e);
677
- }} onMouseLeave={handleMouseLeave} xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
678
- background: backgroundColor,
679
- display: "block",
680
- cursor: activeTool === "ruler" ? "crosshair" : "auto",
681
- }}>
682
- <Layers shadowShape={shadowShape} components={[...extraComponentsState, ...componentsState]} style={{
683
- cursor: getCursorStyle(),
684
- }}
685
- // onClick={handleSelectComponent}
686
- onMouseDown={handleMouseDown}
687
- // onMouseUp={handleMouseUp}
688
- onBlur={handleUnSelectComponent} selectedComponent={selectedComponent} activeTool={activeTool} onTouchStart={(e, item, direction) => handleTouchStart(e, item, direction)} onTouchMove={(e) => handleTouchMove(e)} onTouchEnd={handleTouchEnd}/>
689
- {activeTool === "ruler" && (<>
690
- <g id="horizontal-ruler">
691
- <rect x="0" y="0" width={window.innerWidth} height="30" fill="#e0e0e0"/>
692
- <g stroke="#888" font-size="10" text-anchor="middle">
693
- {Array.from({ length: window.innerWidth / 50 }, (_, i) => (<g key={i}>
694
- <line x1={i * 50} y1="0" x2={i * 50} y2="10"/>
695
- <text x={i * 50} y="15">
696
- {i * 50}
697
- </text>
698
- </g>))}
699
- </g>
700
- </g>
701
- <g id="vertical-ruler">
702
- <rect x="0" y="0" width="30" height={window.innerHeight} fill="#e0e0e0"/>
703
- <g stroke="#888" font-size="10" text-anchor="middle">
704
- {Array.from({ length: window.innerHeight / 10 }, (_, i) => (<g key={i}>
705
- <line x1="0" y1={i * 50} x2="10" y2={i * 50}/>
706
- <text x="15" y={i * 50}>
707
- {i * 50}
708
- </text>
709
- </g>))}
710
- </g>
711
- </g>
712
- </>)}
713
- {grid && (<g stroke="#ddd" strokeWidth={0.5}>
714
- {/* Vertical lines */}
715
- {Array.from({ length: widthBoard / 10 }, (_, i) => (<line key={`v-${i}`} x1={i * 10} y1={0} x2={i * 10} y2={heightBoard}/>))}
716
-
717
- {/* Horizontal lines */}
718
- {Array.from({ length: heightBoard / 10 }, (_, i) => (<line key={`h-${i}`} x1={0} y1={i * 10} x2={widthBoard} y2={i * 10}/>))}
719
- </g>)}
720
- </svg>
721
- </TransformComponent>
722
- </TransformWrapper>
723
- </div>
724
- </>);
645
+ return (_jsxs(_Fragment, { children: [_jsx(ModalPreview, { children: _jsx(LayerView, { statusKey: "status" }) }), _jsxs("div", { className: "relative w-full h-screen flex-1 overflow-hidden", ref: containerRef, children: [_jsx("div", { className: "absolute bottom-5 left-1/2 transform -translate-x-1/2 z-10", children: _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { icon: _jsx(ZoomIn, {}), onClick: handelZoomIn }), _jsx(Button, { icon: _jsx(ZoomOut, {}), onClick: handleZoomOut })] }) }), _jsxs(TransformWrapper, { ref: transformRef, panning: { disabled: activeTool === "select" }, centerZoomedOut: true, onTransformed: ({ state: { scale } }) => setScale(scale), minScale: 1, maxScale: 1000, initialScale: 1, pinch: { step: 1 }, smooth: true, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, children: [scale > 1 && (_jsx("div", { className: "absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10", children: renderMiniMap() })), _jsx(TransformComponent, { wrapperStyle: {
646
+ width: "100%",
647
+ height: "100%",
648
+ overflow: "hidden",
649
+ }, contentStyle: {
650
+ width: "100%",
651
+ height: "100%",
652
+ }, children: _jsxs("svg", { id: "workspace", ref: svgRef, width: "100%", height: "100%", viewBox: `0 0 ${widthBoard} ${heightBoard}`, className: "h-screen", onMouseUp: handleMouseUp, onMouseMove: handleMouseMove, onMouseEnter: handleMouseEnter, onClick: (e) => {
653
+ e.stopPropagation();
654
+ handleMouseClick(e);
655
+ }, onMouseLeave: handleMouseLeave, xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
656
+ background: backgroundColor,
657
+ display: "block",
658
+ cursor: activeTool === "ruler" ? "crosshair" : "auto",
659
+ }, children: [_jsx(Layers, { shadowShape: shadowShape, components: [...extraComponentsState, ...componentsState], style: {
660
+ cursor: getCursorStyle(),
661
+ },
662
+ // onClick={handleSelectComponent}
663
+ onMouseDown: handleMouseDown,
664
+ // onMouseUp={handleMouseUp}
665
+ onBlur: handleUnSelectComponent, selectedComponent: selectedComponent, activeTool: activeTool, onTouchStart: (e, item, direction) => handleTouchStart(e, item, direction), onTouchMove: (e) => handleTouchMove(e), onTouchEnd: handleTouchEnd }), activeTool === "ruler" && (_jsxs(_Fragment, { children: [_jsxs("g", { id: "horizontal-ruler", children: [_jsx("rect", { x: "0", y: "0", width: window.innerWidth, height: "30", fill: "#e0e0e0" }), _jsx("g", { stroke: "#888", "font-size": "10", "text-anchor": "middle", children: Array.from({ length: window.innerWidth / 50 }, (_, i) => (_jsxs("g", { children: [_jsx("line", { x1: i * 50, y1: "0", x2: i * 50, y2: "10" }), _jsx("text", { x: i * 50, y: "15", children: i * 50 })] }, i))) })] }), _jsxs("g", { id: "vertical-ruler", children: [_jsx("rect", { x: "0", y: "0", width: "30", height: window.innerHeight, fill: "#e0e0e0" }), _jsx("g", { stroke: "#888", "font-size": "10", "text-anchor": "middle", children: Array.from({ length: window.innerHeight / 10 }, (_, i) => (_jsxs("g", { children: [_jsx("line", { x1: "0", y1: i * 50, x2: "10", y2: i * 50 }), _jsx("text", { x: "15", y: i * 50, children: i * 50 })] }, i))) })] })] })), grid && (_jsxs("g", { stroke: "#ddd", strokeWidth: 0.5, children: [Array.from({ length: widthBoard / 10 }, (_, i) => (_jsx("line", { x1: i * 10, y1: 0, x2: i * 10, y2: heightBoard }, `v-${i}`))), Array.from({ length: heightBoard / 10 }, (_, i) => (_jsx("line", { x1: 0, y1: i * 10, x2: widthBoard, y2: i * 10 }, `h-${i}`)))] }))] }) })] })] })] }));
725
666
  };
726
667
  export default BoardTemplate;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,52 @@
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;
@@ -0,0 +1,6 @@
1
+ interface BoardTemplateProps {
2
+ onSelectComponent?: (items: any) => void;
3
+ mappingKey?: string;
4
+ }
5
+ declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default BoardTemplate;