seat-editor 3.3.13 → 3.3.15

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 (136) hide show
  1. package/dist/app/constant.d.ts +1 -0
  2. package/dist/app/constant.js +1 -0
  3. package/dist/app/layout.d.ts +6 -0
  4. package/dist/app/layout.jsx +27 -0
  5. package/dist/app/new-board/page.jsx +55 -0
  6. package/dist/app/old-board/page.d.ts +3 -0
  7. package/dist/app/old-board/page.jsx +510 -0
  8. package/dist/app/only-view/chair.d.ts +1 -0
  9. package/dist/app/only-view/chair.js +12 -0
  10. package/dist/app/only-view/constant.d.ts +60 -0
  11. package/dist/app/only-view/constant.js +1336 -0
  12. package/dist/app/only-view/page.jsx +248 -0
  13. package/dist/app/only-view/user.d.ts +1 -0
  14. package/dist/app/only-view/user.js +12 -0
  15. package/dist/app/page.d.ts +2 -0
  16. package/dist/app/page.jsx +13 -0
  17. package/dist/app/test/page.d.ts +2 -0
  18. package/dist/app/test/page.jsx +45 -0
  19. package/dist/app/v2/page.d.ts +2 -0
  20. package/dist/app/v2/page.jsx +13 -0
  21. package/dist/components/button-tools/index.d.ts +11 -0
  22. package/dist/components/button-tools/index.jsx +17 -0
  23. package/dist/components/form-tools/label.d.ts +2 -0
  24. package/dist/components/form-tools/label.jsx +63 -0
  25. package/dist/components/form-tools/shape.d.ts +8 -0
  26. package/dist/components/form-tools/shape.jsx +113 -0
  27. package/dist/components/input/number-indicator.d.ts +7 -0
  28. package/dist/components/input/number-indicator.jsx +36 -0
  29. package/dist/components/joystick/index.d.ts +12 -0
  30. package/dist/components/joystick/index.jsx +49 -0
  31. package/dist/components/layer/index.d.ts +19 -0
  32. package/dist/components/layer/index.jsx +383 -0
  33. package/dist/components/layer-v2/index.d.ts +19 -0
  34. package/dist/components/layer-v2/index.jsx +370 -0
  35. package/dist/components/layer-v3/index.d.ts +13 -0
  36. package/dist/components/layer-v3/index.jsx +631 -0
  37. package/dist/components/layer-v3/utils.d.ts +19 -0
  38. package/dist/components/layer-v3/utils.js +72 -0
  39. package/dist/components/layer-v4/constant.d.ts +60 -0
  40. package/dist/components/layer-v4/constant.js +93 -0
  41. package/dist/components/layer-v4/index.d.ts +24 -0
  42. package/dist/components/layer-v4/index.jsx +1046 -0
  43. package/dist/components/lib/index.d.ts +8 -0
  44. package/dist/components/lib/index.jsx +33 -0
  45. package/dist/components/modal-preview/index.d.ts +4 -0
  46. package/dist/components/modal-preview/index.jsx +11 -0
  47. package/dist/dto/event-handler.d.ts +1 -0
  48. package/dist/dto/event-handler.js +1 -0
  49. package/dist/dto/table.d.ts +80 -0
  50. package/dist/dto/table.js +1 -0
  51. package/dist/features/board/board-slice.d.ts +14 -0
  52. package/dist/features/board/board-slice.js +52 -0
  53. package/dist/features/board/index.d.ts +6 -0
  54. package/dist/features/board/index.jsx +725 -0
  55. package/dist/features/board-v2/board-slice.d.ts +14 -0
  56. package/dist/features/board-v2/board-slice.js +52 -0
  57. package/dist/features/board-v2/index.d.ts +8 -0
  58. package/dist/features/board-v2/index.jsx +869 -0
  59. package/dist/features/board-v3/board-slice.d.ts +19 -0
  60. package/dist/features/board-v3/board-slice.js +274 -0
  61. package/dist/features/board-v3/constant.d.ts +5 -0
  62. package/dist/features/board-v3/constant.js +5 -0
  63. package/dist/features/board-v3/history-slice.d.ts +27 -0
  64. package/dist/features/board-v3/history-slice.js +27 -0
  65. package/dist/features/board-v3/icons.d.ts +4 -0
  66. package/dist/features/board-v3/icons.jsx +100 -0
  67. package/dist/features/board-v3/index.d.ts +16 -0
  68. package/dist/features/board-v3/index.jsx +1678 -0
  69. package/dist/features/board-v3/polygon.d.ts +28 -0
  70. package/dist/features/board-v3/polygon.js +109 -0
  71. package/dist/features/board-v3/rect.d.ts +9 -0
  72. package/dist/features/board-v3/rect.js +152 -0
  73. package/dist/features/board-v3/resize-element.d.ts +12 -0
  74. package/dist/features/board-v3/resize-element.js +43 -0
  75. package/dist/features/board-v3/utils.d.ts +180 -0
  76. package/dist/features/board-v3/utils.js +1235 -0
  77. package/dist/features/navbar/index.d.ts +2 -0
  78. package/dist/features/navbar/index.jsx +5 -0
  79. package/dist/features/panel/index.d.ts +6 -0
  80. package/dist/features/panel/index.jsx +251 -0
  81. package/dist/features/panel/panel-slice.d.ts +23 -0
  82. package/dist/features/panel/panel-slice.js +46 -0
  83. package/dist/features/panel/select-tool.d.ts +6 -0
  84. package/dist/features/panel/select-tool.jsx +70 -0
  85. package/dist/features/panel/selected-group.d.ts +2 -0
  86. package/dist/features/panel/selected-group.jsx +93 -0
  87. package/dist/features/panel/square-circle-tool.d.ts +2 -0
  88. package/dist/features/panel/square-circle-tool.jsx +10 -0
  89. package/dist/features/panel/table-seat-circle.d.ts +2 -0
  90. package/dist/features/panel/table-seat-circle.jsx +36 -0
  91. package/dist/features/panel/table-seat-square.d.ts +2 -0
  92. package/dist/features/panel/table-seat-square.jsx +51 -0
  93. package/dist/features/panel/text-tool.d.ts +2 -0
  94. package/dist/features/panel/text-tool.jsx +57 -0
  95. package/dist/features/panel/upload-tool.d.ts +10 -0
  96. package/dist/features/panel/upload-tool.jsx +176 -0
  97. package/dist/features/panel/utils.d.ts +5 -0
  98. package/dist/features/panel/utils.js +47 -0
  99. package/dist/features/side-tool/index.d.ts +8 -0
  100. package/dist/features/side-tool/index.jsx +390 -0
  101. package/dist/features/side-tool/side-tool-slice.d.ts +16 -0
  102. package/dist/features/side-tool/side-tool-slice.js +28 -0
  103. package/dist/features/theme/theme-slice.d.ts +12 -0
  104. package/dist/features/theme/theme-slice.js +15 -0
  105. package/dist/features/view-only/index.d.ts +19 -0
  106. package/dist/features/view-only/index.jsx +205 -0
  107. package/dist/features/view-only-2/index.d.ts +19 -0
  108. package/dist/features/view-only-2/index.jsx +190 -0
  109. package/dist/features/view-only-3/index.d.ts +89 -0
  110. package/dist/features/view-only-3/index.jsx +590 -0
  111. package/dist/features/view-only-3/utils.d.ts +1 -0
  112. package/dist/features/view-only-3/utils.js +3 -0
  113. package/dist/hooks/use-redux.d.ts +4 -0
  114. package/dist/hooks/use-redux.js +3 -0
  115. package/dist/index.js +10 -0
  116. package/dist/libs/middleware.d.ts +2 -0
  117. package/dist/libs/middleware.js +5 -0
  118. package/dist/libs/rootReducer.d.ts +12 -0
  119. package/dist/libs/rootReducer.js +14 -0
  120. package/dist/libs/store.d.ts +18 -0
  121. package/dist/libs/store.js +19 -0
  122. package/dist/provider/antd-provider.d.ts +4 -0
  123. package/dist/provider/antd-provider.jsx +46 -0
  124. package/dist/provider/redux-provider.d.ts +3 -0
  125. package/dist/provider/redux-provider.jsx +6 -0
  126. package/dist/provider/store-provider.d.ts +4 -0
  127. package/dist/provider/store-provider.jsx +10 -0
  128. package/dist/utils/constant.d.ts +3 -0
  129. package/dist/utils/constant.js +13 -0
  130. package/dist/utils/format.d.ts +2 -0
  131. package/dist/utils/format.js +29 -0
  132. package/dist/utils/injectCss.d.ts +1 -0
  133. package/dist/utils/injectCss.js +13 -0
  134. package/dist/utils/regex.d.ts +3 -0
  135. package/dist/utils/regex.js +3 -0
  136. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ declare const Navbar: () => import("react").JSX.Element;
2
+ export default Navbar;
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ const Navbar = () => {
3
+ return <div>Navbar</div>;
4
+ };
5
+ export default Navbar;
@@ -0,0 +1,6 @@
1
+ interface ControlPanelsProps {
2
+ action?: (file: File) => Promise<string>;
3
+ transform?: any;
4
+ }
5
+ declare const ControlPanels: (props: ControlPanelsProps) => import("react").JSX.Element;
6
+ export default ControlPanels;
@@ -0,0 +1,251 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { useEffect, useRef, useState } from "react";
14
+ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
15
+ import { Form, Input } from "antd";
16
+ import SelectToolForm from "./select-tool";
17
+ import SquareToolForm from "./square-circle-tool";
18
+ import SeatCircle from "./table-seat-circle";
19
+ import UploadTool from "./upload-tool";
20
+ import { debounce } from "lodash";
21
+ import clsx from "clsx";
22
+ import { getAttributeElement } from "../board-v3/resize-element";
23
+ import { applyResizeToSvgElement, getGlobalBBox, updateSelectionBox, } from "../board-v3/utils";
24
+ import { SEAT_SHAPES } from "../../utils/constant";
25
+ import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
26
+ import SeatSquare from "./table-seat-square";
27
+ const ControlPanels = (props) => {
28
+ const { action, transform } = props;
29
+ const dispatch = useAppDispatch();
30
+ const theme = useAppSelector((state) => state.theme);
31
+ const tool = useAppSelector((state) => state.tool);
32
+ const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
33
+ const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
34
+ const components = useAppSelector((state) => state.board.components);
35
+ const extraComponents = useAppSelector((state) => state.board.extraComponents);
36
+ const svgRef = useRef(null);
37
+ useEffect(() => {
38
+ svgRef.current = document.querySelectorAll("#workspace");
39
+ }, []);
40
+ const { show } = useAppSelector((state) => state.panel);
41
+ const [open, setOpen] = useState(false);
42
+ const [form] = Form.useForm();
43
+ let values = Form.useWatch([], form);
44
+ useEffect(() => {
45
+ if (selectedComponent) {
46
+ const isDifferentId = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) !== (values === null || values === void 0 ? void 0 : values.id) || !(values === null || values === void 0 ? void 0 : values.id);
47
+ const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
48
+ (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height) === (values === null || values === void 0 ? void 0 : values.height) &&
49
+ (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.width) === (values === null || values === void 0 ? void 0 : values.width) &&
50
+ (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x) === (values === null || values === void 0 ? void 0 : values.x) &&
51
+ (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y) === (values === null || values === void 0 ? void 0 : values.y);
52
+ if (show && (isDifferentId || isSameIdAndSameDimensions)) {
53
+ setOpen(true);
54
+ }
55
+ form.setFieldsValue(selectedComponent);
56
+ }
57
+ else if (selectedGroup) {
58
+ if (show)
59
+ setOpen(true);
60
+ if (!show)
61
+ setOpen(false);
62
+ function isSameAllByKey(arr, key) {
63
+ if (!arr || arr.length === 0)
64
+ return false;
65
+ const firstValue = arr[0][key];
66
+ return arr.every((item) => item[key] === firstValue);
67
+ }
68
+ function getValueIfSame(arr, key) {
69
+ return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
70
+ }
71
+ form.setFieldsValue({
72
+ width: getValueIfSame(selectedGroup, "width"),
73
+ height: getValueIfSame(selectedGroup, "height"),
74
+ x: getValueIfSame(selectedGroup, "x"),
75
+ y: getValueIfSame(selectedGroup, "y"),
76
+ fill: getValueIfSame(selectedGroup, "fill"),
77
+ stroke: getValueIfSame(selectedGroup, "stroke"),
78
+ opacity: getValueIfSame(selectedGroup, "opacity"),
79
+ rotation: getValueIfSame(selectedGroup, "rotation"),
80
+ strokeWidth: getValueIfSame(selectedGroup, "strokeWidth"),
81
+ radius: getValueIfSame(selectedGroup, "radius"),
82
+ shape: getValueIfSame(selectedGroup, "shape"),
83
+ labels: getValueIfSame(selectedGroup, "labels"),
84
+ });
85
+ }
86
+ else {
87
+ setOpen(false);
88
+ }
89
+ }, [selectedComponent, selectedGroup, show]);
90
+ useEffect(() => {
91
+ if (tool.active === "background" || tool.active === "image-table") {
92
+ setOpen(true);
93
+ }
94
+ }, [tool, show]);
95
+ const createShape = (shape, props = {}) => {
96
+ var _a, _b, _c, _d, _e, _f, _g, _h;
97
+ const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
98
+ return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape: (_b = props.shape) !== null && _b !== void 0 ? _b : shape, height: (_c = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _c === void 0 ? void 0 : _c.height, width: (_d = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _d === void 0 ? void 0 : _d.width, fill: props.fill, seatCount: getSeatCount(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props), seatPositions: getSeatPosition(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props), openSpace: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape) ? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0 : undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
99
+ ? (_f = props.seatFill) !== null && _f !== void 0 ? _f : "transparent"
100
+ : undefined, text: shape === "text" ? (_g = props.text) !== null && _g !== void 0 ? _g : defaults.text : undefined, fontColor: shape === "text" ? (_h = props.fontColor) !== null && _h !== void 0 ? _h : defaults.fontColor : undefined, radius: props.radius });
101
+ };
102
+ const debouncedSyncComponents = useRef(debounce((data) => {
103
+ dispatch({ type: "board/setFlagChange", payload: true });
104
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
105
+ dispatch({
106
+ type: "board/updateComponent",
107
+ payload: data,
108
+ });
109
+ dispatch({
110
+ type: "panel/updateSelectedComponent",
111
+ payload: data,
112
+ });
113
+ }, 300));
114
+ const debouncedSyncSelectedComponents = useRef(debounce((data) => {
115
+ dispatch({
116
+ type: "panel/updateSelectedComponent",
117
+ payload: data,
118
+ });
119
+ }, 300));
120
+ const debouncedSyncSelectedSelectionLines = useRef(debounce((data) => {
121
+ dispatch({
122
+ type: "panel/setSelectionLines",
123
+ payload: data,
124
+ });
125
+ }));
126
+ const debounceSyncSelectedGroup = useRef(debounce((data) => {
127
+ dispatch({
128
+ type: "panel/updateSelectedGroup",
129
+ payload: data,
130
+ });
131
+ }, 300));
132
+ const debounceSyncDataSelectedGroup = useRef(debounce((data) => {
133
+ dispatch({
134
+ type: "panel/updateSelectedGroup",
135
+ payload: data,
136
+ });
137
+ dispatch({
138
+ type: "board/updateComponentsBulk",
139
+ payload: data,
140
+ });
141
+ dispatch({ type: "board/setFlagChange", payload: true });
142
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
143
+ }, 300));
144
+ const debouncedSyncForm = useRef(debounce(() => {
145
+ dispatch({ type: "board/setFlagChange", payload: true });
146
+ dispatch({ type: "board/setUpdateBy", payload: "global" });
147
+ }, 300));
148
+ const updateElement = (id, values) => {
149
+ var _a, _b, _c, _d, _e, _f, _g;
150
+ let findElement = [...components, ...extraComponents].find((item) => item.id === id);
151
+ const isAdjustSize = ["circle"].includes((findElement === null || findElement === void 0 ? void 0 : findElement.shape) || "");
152
+ let forceSize = {
153
+ width: Math.min(findElement.width, findElement.height),
154
+ height: Math.min(findElement.width, findElement.height),
155
+ };
156
+ if (!findElement)
157
+ return;
158
+ const newElement = Object.assign(Object.assign(Object.assign({}, findElement), values), { x: (_a = values.x) !== null && _a !== void 0 ? _a : findElement.x, y: (_b = values.y) !== null && _b !== void 0 ? _b : findElement.y, width: isAdjustSize ? forceSize.width : (_c = values.width) !== null && _c !== void 0 ? _c : findElement.width, height: isAdjustSize
159
+ ? forceSize.height
160
+ : (_d = values.height) !== null && _d !== void 0 ? _d : findElement.height });
161
+ const svg = (_f = (_e = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : (_g = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _g === void 0 ? void 0 : _g[0];
162
+ const { g, element } = getAttributeElement(svg, id);
163
+ applyResizeToSvgElement(element, g, newElement);
164
+ const getBBox = getGlobalBBox(svg, g);
165
+ debouncedSyncSelectedSelectionLines.current(Object.assign({}, getBBox));
166
+ updateSelectionBox(svg, getBBox);
167
+ };
168
+ const handleChangeComponent = (values, allValues) => {
169
+ const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
170
+ const newValues = createShape(shape, restProps);
171
+ if (selectedComponent) {
172
+ updateElement(allValues.id, values);
173
+ debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
174
+ }
175
+ if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
176
+ const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels } = newValues;
177
+ const updatedGroup = selectedGroup.map((comp) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, comp), (width !== undefined ? { width } : {})), (height !== undefined ? { height } : {})), (x !== undefined ? { x } : {})), (y !== undefined ? { y } : {})), (fill !== undefined ? { fill } : {})), (stroke !== undefined ? { stroke } : {})), (opacity !== undefined ? { opacity } : {})), (rotation !== undefined ? { rotation } : {})), (strokeWidth !== undefined ? { strokeWidth } : {})), (radius !== undefined ? { radius } : {})), (shape !== undefined ? { shape } : {})), (seatCount !== undefined ? { seatCount } : {})), (seatFill !== undefined ? { seatFill } : {})), (seatPositions !== undefined ? { seatPositions } : {})), (labels !== undefined ? { labels } : {}))));
178
+ let minX = Infinity;
179
+ let minY = Infinity;
180
+ let maxX = -Infinity;
181
+ let maxY = -Infinity;
182
+ updatedGroup.forEach((comp) => {
183
+ minX = Math.min(minX, comp.x);
184
+ minY = Math.min(minY, comp.y);
185
+ maxX = Math.max(maxX, comp.x + comp.width);
186
+ maxY = Math.max(maxY, comp.y + comp.height);
187
+ });
188
+ const newSelectionGroup = {
189
+ x: minX,
190
+ y: minY,
191
+ width: maxX - minX,
192
+ height: maxY - minY,
193
+ shape: "selection-box",
194
+ id: `${Date.now()}`,
195
+ fill: "transparent",
196
+ rotation: 0,
197
+ stroke: "red",
198
+ };
199
+ dispatch({
200
+ type: "panel/setSelectionLines",
201
+ payload: newSelectionGroup,
202
+ });
203
+ // dispatch({
204
+ // type: "panel/updateSelectedGroup",
205
+ // payload: updatedGroup,
206
+ // });
207
+ debounceSyncDataSelectedGroup.current(updatedGroup);
208
+ }
209
+ // debouncedSyncForm.current();
210
+ };
211
+ const renderFormPanel = () => {
212
+ switch (tool.active) {
213
+ case "select":
214
+ case "text":
215
+ return <SelectToolForm action={action} tranform={transform}/>;
216
+ case "square":
217
+ case "circle":
218
+ return <SquareToolForm />;
219
+ case "table-seat-circle":
220
+ return <SeatCircle />;
221
+ case "table-seat-square":
222
+ return <SeatSquare />;
223
+ case "image-table":
224
+ return (<UploadTool name={tool.active} type="component" action={action} transform={transform}/>);
225
+ case "background":
226
+ return (<UploadTool name={tool.active} type="background" action={action} transform={transform}/>);
227
+ default:
228
+ return null;
229
+ }
230
+ };
231
+ const handleClose = () => {
232
+ setOpen(false);
233
+ // HIDE SEMENTARA
234
+ dispatch({
235
+ type: "panel/setShow",
236
+ payload: false,
237
+ });
238
+ };
239
+ // if(!show) return null
240
+ return (<div className={clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll ", open ? "right-0" : "right-[-300px]")}>
241
+ <div className="bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300">
242
+ <Form layout="vertical" form={form} name="table" onValuesChange={handleChangeComponent} initialValues={{ labels: [{}] }}>
243
+ <Form.Item name="id" hidden>
244
+ <Input />
245
+ </Form.Item>
246
+ {renderFormPanel()}
247
+ </Form>
248
+ </div>
249
+ </div>);
250
+ };
251
+ export default ControlPanels;
@@ -0,0 +1,23 @@
1
+ import { PayloadAction } from "@reduxjs/toolkit";
2
+ export interface PanelState {
3
+ selectedComponent: any;
4
+ history: any[];
5
+ active: string;
6
+ show: boolean;
7
+ selectedGroup: any;
8
+ selectionLines?: any;
9
+ loading?: boolean;
10
+ }
11
+ export declare const panelSlice: import("@reduxjs/toolkit").Slice<PanelState, {
12
+ setLoading: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<boolean>) => void;
13
+ setSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
14
+ setUnSelectedComponent: (state: import("immer").WritableDraft<PanelState>) => void;
15
+ updateSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
16
+ setShow: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<boolean>) => void;
17
+ setSelectedGroup: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
18
+ updateSelectedGroup: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
19
+ setSelectionLines: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
20
+ }, "panel", "panel", import("@reduxjs/toolkit").SliceSelectors<PanelState>>;
21
+ export declare const setSelectedComponent: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "panel/setSelectedComponent">, setUnSelectedComponent: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"panel/setUnSelectedComponent">, setShow: import("@reduxjs/toolkit").ActionCreatorWithOptionalPayload<boolean, "panel/setShow">;
22
+ declare const _default: import("redux").Reducer<PanelState>;
23
+ export default _default;
@@ -0,0 +1,46 @@
1
+ import { createSlice } from "@reduxjs/toolkit";
2
+ const initialState = {
3
+ selectedComponent: null,
4
+ history: [],
5
+ active: "",
6
+ show: false,
7
+ selectedGroup: null,
8
+ selectionLines: null,
9
+ loading: false,
10
+ };
11
+ export const panelSlice = createSlice({
12
+ name: "panel",
13
+ initialState,
14
+ reducers: {
15
+ setLoading: (state, action) => {
16
+ state.loading = action.payload;
17
+ },
18
+ setSelectedComponent: (state, action) => {
19
+ state.selectedComponent = action.payload;
20
+ },
21
+ setUnSelectedComponent: (state) => {
22
+ state.selectedComponent = null;
23
+ },
24
+ updateSelectedComponent: (state, action) => {
25
+ state.selectedComponent = Object.assign({}, action.payload);
26
+ state.history.push(state.selectedComponent);
27
+ if (state.history.length > 20) {
28
+ state.history.shift();
29
+ }
30
+ },
31
+ setShow: (state, action) => {
32
+ state.show = action.payload;
33
+ },
34
+ setSelectedGroup: (state, action) => {
35
+ state.selectedGroup = action.payload;
36
+ },
37
+ updateSelectedGroup: (state, action) => {
38
+ state.selectedGroup = action.payload;
39
+ },
40
+ setSelectionLines: (state, action) => {
41
+ state.selectionLines = action.payload;
42
+ }
43
+ },
44
+ });
45
+ export const { setSelectedComponent, setUnSelectedComponent, setShow } = panelSlice.actions;
46
+ export default panelSlice.reducer;
@@ -0,0 +1,6 @@
1
+ declare const SelectToolForm: ({ title, action, tranform }: {
2
+ title?: string;
3
+ action: any;
4
+ tranform: any;
5
+ }) => import("react").JSX.Element;
6
+ export default SelectToolForm;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { useAppSelector } from "../../hooks/use-redux";
3
+ import SquareToolForm from "./square-circle-tool";
4
+ import SeatCircle from "./table-seat-circle";
5
+ import SeatSquare from "./table-seat-square";
6
+ import UploadTool from "./upload-tool";
7
+ import TextTool from "./text-tool";
8
+ import SelectedGroup from "./selected-group";
9
+ const SelectToolForm = ({ title = "Title", action, tranform }) => {
10
+ const components = useAppSelector((state) => state.board.components);
11
+ const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
12
+ const extraComponents = useAppSelector((state) => state.board.extraComponents);
13
+ const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
14
+ const SummaryComponents = () => {
15
+ const countByShape = components === null || components === void 0 ? void 0 : components.reduce((acc, item) => {
16
+ acc[item.shape] = (acc[item.shape] || 0) + 1;
17
+ return acc;
18
+ }, {});
19
+ const variableFormatToString = (variable) => {
20
+ return variable
21
+ .replace(/-/g, " ")
22
+ .replace(/\b\w/g, (char) => char.toUpperCase());
23
+ };
24
+ return (<div className="flex flex-col">
25
+ <h1 className="heading-s">{title}</h1>
26
+ <div className="flex flex-col gap-2 mt-5">
27
+ {Object.entries(countByShape).map(([shape, count]) => (<div key={shape}>
28
+ <span className="font-bold">
29
+ {variableFormatToString(shape)}:
30
+ </span>{" "}
31
+ {count}
32
+ </div>))}
33
+ </div>
34
+ </div>);
35
+ };
36
+ const renderComponent = () => {
37
+ switch (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) {
38
+ case "square":
39
+ case "circle":
40
+ return <SquareToolForm />;
41
+ case "table-seat-circle":
42
+ case "table-seat-rect-circle":
43
+ return <SeatCircle />;
44
+ case "table-seat-square":
45
+ case "table-seat-half-square":
46
+ case "table-seat-rect-square":
47
+ return <SeatSquare />;
48
+ case "image-table":
49
+ case "background":
50
+ return (<UploadTool action={action} name={selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape} defaultValue={selectedComponent} type={(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "background"
51
+ ? "background"
52
+ : "component"} transform={tranform}/>);
53
+ case "text":
54
+ return <TextTool />;
55
+ default:
56
+ return null;
57
+ }
58
+ };
59
+ const renderSelectionComponent = () => {
60
+ if (selectedGroup) {
61
+ return <SelectedGroup />;
62
+ }
63
+ };
64
+ return (<div className="flex flex-col gap-2">
65
+ <SummaryComponents />
66
+ {renderComponent()}
67
+ {renderSelectionComponent()}
68
+ </div>);
69
+ };
70
+ export default SelectToolForm;
@@ -0,0 +1,2 @@
1
+ declare const SelectedGroup: () => import("react").JSX.Element;
2
+ export default SelectedGroup;
@@ -0,0 +1,93 @@
1
+ "use client";
2
+ import { optionsShape } from "../../components/form-tools/shape";
3
+ import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
4
+ import SeatCircle from "./table-seat-circle";
5
+ import SeatSquare from "./table-seat-square";
6
+ import { useAppSelector } from "../../hooks/use-redux";
7
+ const SelectedGroup = () => {
8
+ const shape = Form.useWatch("shape");
9
+ const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
10
+ const sameShape = [
11
+ "table-seat-circle",
12
+ "table-seat-rect-circle",
13
+ "table-seat-square",
14
+ "table-seat-square",
15
+ "table-seat-rect-square",
16
+ "table-seat-half-square"
17
+ ].includes(shape);
18
+ const allShapeSelected = selectedGroup.map((item) => item.shape);
19
+ const shapeIncludeImage = ["background", "image-table", "polygon"].some((shape) => allShapeSelected.includes(shape));
20
+ const shapeAllIncludePolygon = allShapeSelected.includes("polygon");
21
+ return (<>
22
+ <div className="py-2">
23
+ <h1 className="heading-s"> Group Selection</h1>
24
+ <div className="py-2">
25
+ {!shapeIncludeImage && (<Flex gap={2} className="w-full">
26
+ <Form.Item label="Name" name="shape" className="w-full">
27
+ <Select options={optionsShape} className="w-full"/>
28
+ </Form.Item>
29
+ </Flex>)}
30
+ <Flex gap={2} className="w-full">
31
+ {["table-seat-circle", "table-seat-rect-circle"].includes(shape) && <SeatCircle />}
32
+ {[
33
+ "table-seat-square",
34
+ "table-seat-square",
35
+ "table-seat-rect-square",
36
+ "table-seat-half-square"
37
+ ].includes(shape) && <SeatSquare />}
38
+ </Flex>
39
+ {!sameShape && (<>
40
+ <Flex gap={2} className="w-full">
41
+ {!shapeAllIncludePolygon && (<>
42
+ <Form.Item label="Width" name="width" className="w-full">
43
+ <InputNumber suffix="px"/>
44
+ </Form.Item>
45
+ <Form.Item label="Height" name="height" className="w-full">
46
+ <InputNumber suffix="px"/>
47
+ </Form.Item>
48
+ </>)}
49
+ {(!(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && !shapeAllIncludePolygon) && (<Form.Item label="Radius" name={"radius"} className="w-full">
50
+ <InputNumber suffix="px" parser={(value) => {
51
+ var _a;
52
+ const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
53
+ return onlyNumber === ""
54
+ ? 1
55
+ : Math.max(1, Number(onlyNumber));
56
+ }}/>
57
+ </Form.Item>)}
58
+ </Flex>
59
+ {!shapeAllIncludePolygon && (<>
60
+ <Flex gap={2}>
61
+ <Form.Item label="Position X" name="x" className="w-full">
62
+ <InputNumber />
63
+ </Form.Item>
64
+ <Form.Item label="Position Y" name="y" className="w-full">
65
+ <InputNumber />
66
+ </Form.Item>
67
+ <Form.Item label="Rotation" name="rotation" className="w-full">
68
+ <InputNumber max={360} min={0}/>
69
+ </Form.Item>
70
+ </Flex>
71
+ </>)}
72
+ <Flex gap={2}>
73
+ <Form.Item label="Fill" name={"fill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
74
+ <ColorPicker allowClear format="hex" defaultFormat="hex"/>
75
+ </Form.Item>
76
+ <Form.Item label="Stroke" name={"stroke"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
77
+ <ColorPicker allowClear format="hex" defaultFormat="hex"/>
78
+ </Form.Item>
79
+ </Flex>
80
+ <Flex>
81
+ <Form.Item label="Stroke Width" name={"strokeWidth"} className="w-full">
82
+ <InputNumber />
83
+ </Form.Item>
84
+ <Form.Item label="opacity" name={"opacity"} className="w-full">
85
+ <InputNumber step={0.1} max={1} min={0}/>
86
+ </Form.Item>
87
+ </Flex>
88
+ </>)}
89
+ </div>
90
+ </div>
91
+ </>);
92
+ };
93
+ export default SelectedGroup;
@@ -0,0 +1,2 @@
1
+ declare const SquareToolForm: () => import("react").JSX.Element;
2
+ export default SquareToolForm;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import SectionLabel from "../../components/form-tools/label";
3
+ import SectionShape from "../../components/form-tools/shape";
4
+ const SquareToolForm = () => {
5
+ return (<>
6
+ <SectionShape />
7
+ <SectionLabel />
8
+ </>);
9
+ };
10
+ export default SquareToolForm;
@@ -0,0 +1,2 @@
1
+ declare const SeatCircle: () => import("react").JSX.Element;
2
+ export default SeatCircle;
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { ColorPicker, Flex, Form, InputNumber } from "antd";
3
+ import SectionLabel from "../../components/form-tools/label";
4
+ import SectionShape from "../../components/form-tools/shape";
5
+ const SeatCircle = () => {
6
+ return (<>
7
+ <div className="py-2">
8
+ <h1 className="heading-s"> Round table</h1>
9
+ <Flex>
10
+ <Form.Item name="seatCount" label="Seat Count" className="w-full">
11
+ <InputNumber />
12
+ </Form.Item>
13
+ <Form.Item name="openSpace" label="Open Space" className="w-full">
14
+ <InputNumber max={1} min={0} step={0.1}/>
15
+ </Form.Item>
16
+
17
+ </Flex>
18
+ <Flex gap={2}>
19
+ <Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
20
+ <ColorPicker allowClear format="hex" defaultFormat="hex"/>
21
+ </Form.Item>
22
+ {/* <Form.Item
23
+ label="Table Fill"
24
+ name={"fill"}
25
+ getValueFromEvent={(color) => color.toHexString()}
26
+ className="w-full "
27
+ >
28
+ <ColorPicker allowClear format="hex" defaultFormat="hex" />
29
+ </Form.Item> */}
30
+ </Flex>
31
+ <SectionShape />
32
+ <SectionLabel />
33
+ </div>
34
+ </>);
35
+ };
36
+ export default SeatCircle;
@@ -0,0 +1,2 @@
1
+ declare const SeatSquare: () => import("react").JSX.Element;
2
+ export default SeatSquare;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { Col, ColorPicker, Flex, Form, InputNumber, Row, } from "antd";
3
+ import SectionLabel from "../../components/form-tools/label";
4
+ import SectionShape from "../../components/form-tools/shape";
5
+ const SeatSquare = () => {
6
+ return (<>
7
+ <div className="py-2">
8
+ <h1 className="heading-s"> Square table</h1>
9
+ <Flex className="w-full">
10
+ <Form.Item name="openSpace" label="Open Space" className="w-full">
11
+ <InputNumber max={1} min={0} step={0.1}/>
12
+ </Form.Item>
13
+ </Flex>
14
+ <Row gutter={[16, 16]}>
15
+ <Col span={12}>
16
+ <Form.Item name={["seatPositions", "top"]} label="Top" className="w-full">
17
+ <InputNumber max={100} min={0} step={1}/>
18
+ </Form.Item>
19
+ <Form.Item name={["seatPositions", "left"]} label="Left" className="w-full">
20
+ <InputNumber max={100} min={0} step={1}/>
21
+ </Form.Item>
22
+ </Col>
23
+ <Col span={12}>
24
+ <Form.Item name={["seatPositions", "right"]} label="Right" className="w-full">
25
+ <InputNumber max={100} min={0} step={1}/>
26
+ </Form.Item>
27
+ <Form.Item name={["seatPositions", "bottom"]} label="Bottom" className="w-full">
28
+ <InputNumber max={100} min={0} step={1}/>
29
+ </Form.Item>
30
+ </Col>
31
+ </Row>
32
+
33
+ <Flex gap={2}>
34
+ <Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
35
+ <ColorPicker allowClear format="hex" defaultFormat="hex"/>
36
+ </Form.Item>
37
+ {/* <Form.Item
38
+ label="Table Fill"
39
+ name={"fill"}
40
+ getValueFromEvent={(color) => color.toHexString()}
41
+ className="w-full "
42
+ >
43
+ <ColorPicker allowClear format="hex" defaultFormat="hex" />
44
+ </Form.Item> */}
45
+ </Flex>
46
+ <SectionShape />
47
+ <SectionLabel />
48
+ </div>
49
+ </>);
50
+ };
51
+ export default SeatSquare;
@@ -0,0 +1,2 @@
1
+ declare const TextTool: () => import("react").JSX.Element;
2
+ export default TextTool;