seat-editor 1.2.2 → 1.2.4

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 (64) hide show
  1. package/dist/app/only-view/constant.js +26 -26
  2. package/dist/app/only-view/page.jsx +10 -1
  3. package/dist/components/layer/index.jsx +1 -0
  4. package/dist/features/view/index.d.ts +4 -6
  5. package/dist/features/view/index.jsx +16 -11
  6. package/package.json +1 -1
  7. package/dist/app/constant.d.ts +0 -23
  8. package/dist/app/constant.js +0 -34
  9. package/dist/app/layout.d.ts +0 -6
  10. package/dist/app/layout.jsx +0 -27
  11. package/dist/app/new-board/page.jsx +0 -12
  12. package/dist/app/old-board/page.d.ts +0 -3
  13. package/dist/app/old-board/page.jsx +0 -515
  14. package/dist/app/page.jsx +0 -13
  15. package/dist/components/button-tools/index.d.ts +0 -11
  16. package/dist/components/button-tools/index.jsx +0 -17
  17. package/dist/components/form-tools/label.d.ts +0 -2
  18. package/dist/components/form-tools/label.jsx +0 -44
  19. package/dist/components/form-tools/shape.d.ts +0 -2
  20. package/dist/components/form-tools/shape.jsx +0 -43
  21. package/dist/components/input/number-indicator.d.ts +0 -7
  22. package/dist/components/input/number-indicator.jsx +0 -36
  23. package/dist/components/lib/index.jsx +0 -33
  24. package/dist/components/modal-preview/index.d.ts +0 -4
  25. package/dist/components/modal-preview/index.jsx +0 -11
  26. package/dist/features/board/board-slice.d.ts +0 -12
  27. package/dist/features/board/board-slice.js +0 -44
  28. package/dist/features/board/index.jsx +0 -290
  29. package/dist/features/navbar/index.d.ts +0 -2
  30. package/dist/features/navbar/index.jsx +0 -5
  31. package/dist/features/package/index.jsx +0 -39
  32. package/dist/features/panel/index.d.ts +0 -2
  33. package/dist/features/panel/index.jsx +0 -91
  34. package/dist/features/panel/panel-slice.d.ts +0 -16
  35. package/dist/features/panel/panel-slice.js +0 -31
  36. package/dist/features/panel/select-tool.d.ts +0 -4
  37. package/dist/features/panel/select-tool.jsx +0 -45
  38. package/dist/features/panel/square-circle-tool.d.ts +0 -2
  39. package/dist/features/panel/square-circle-tool.jsx +0 -10
  40. package/dist/features/panel/table-seat-circle.d.ts +0 -2
  41. package/dist/features/panel/table-seat-circle.jsx +0 -31
  42. package/dist/features/panel/text-tool.d.ts +0 -2
  43. package/dist/features/panel/text-tool.jsx +0 -22
  44. package/dist/features/panel/upload-tool.d.ts +0 -6
  45. package/dist/features/panel/upload-tool.jsx +0 -80
  46. package/dist/features/side-tool/index.d.ts +0 -2
  47. package/dist/features/side-tool/index.jsx +0 -211
  48. package/dist/features/side-tool/side-tool-slice.d.ts +0 -12
  49. package/dist/features/side-tool/side-tool-slice.js +0 -20
  50. package/dist/hooks/use-redux.d.ts +0 -4
  51. package/dist/hooks/use-redux.js +0 -3
  52. package/dist/index.js +0 -7
  53. package/dist/libs/middleware.d.ts +0 -2
  54. package/dist/libs/middleware.js +0 -5
  55. package/dist/libs/rootReducer.d.ts +0 -10
  56. package/dist/libs/rootReducer.js +0 -12
  57. package/dist/libs/store.d.ts +0 -16
  58. package/dist/libs/store.js +0 -20
  59. package/dist/provider/antd-provider.d.ts +0 -3
  60. package/dist/provider/antd-provider.jsx +0 -30
  61. package/dist/provider/redux-provider.d.ts +0 -3
  62. package/dist/provider/redux-provider.jsx +0 -6
  63. package/dist/provider/store-provider.d.ts +0 -3
  64. package/dist/provider/store-provider.jsx +0 -8
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
- import { Input, Button, Flex, Form } from "antd";
4
- import { ArrowRight, ArrowLeft } from "lucide-react";
5
- const NumberIndicator = ({ name, defaultValue, onChange }) => {
6
- const [value, setValue] = useState(0);
7
- const form = Form.useFormInstance();
8
- useEffect(() => {
9
- if (defaultValue) {
10
- setValue(defaultValue);
11
- form.setFieldsValue({ [name]: defaultValue });
12
- }
13
- }, [defaultValue]);
14
- const handlePrev = () => {
15
- setValue(value - 1);
16
- form.setFieldsValue({ [name]: value - 1 });
17
- onChange(value - 1);
18
- };
19
- const handleNext = () => {
20
- setValue(value + 1);
21
- form.setFieldsValue({ [name]: value + 1 });
22
- onChange(value + 1);
23
- };
24
- return (<Flex gap={2}>
25
- <Button onClick={handlePrev}>
26
- <ArrowLeft />
27
- </Button>
28
- <Form.Item name={name} noStyle>
29
- <Input className="flex text-center" type="number" value={value} name={name} onChange={(e) => setValue(parseInt(e.target.value))}/>
30
- </Form.Item>
31
- <Button onClick={handleNext}>
32
- <ArrowRight />
33
- </Button>
34
- </Flex>);
35
- };
36
- export default NumberIndicator;
@@ -1,33 +0,0 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import Board from "../../features/board";
4
- import SideTool from "../../features/side-tool";
5
- import ControlPanels from "../../features/panel";
6
- import LayerView from "../../features/view";
7
- import { useAppDispatch } from "../../hooks/use-redux";
8
- const TableEditor = ({ componentProps = [], extraComponentProps = [], }) => {
9
- const dispatch = useAppDispatch();
10
- useEffect(() => {
11
- if (componentProps.length > 0) {
12
- dispatch({
13
- type: "board/setNewComponents",
14
- payload: componentProps,
15
- });
16
- }
17
- if (extraComponentProps.length > 0) {
18
- dispatch({
19
- type: "board/setNewExtraComponent",
20
- payload: extraComponentProps,
21
- });
22
- }
23
- }, [componentProps, extraComponentProps]);
24
- return (<>
25
- <div className="w-full h-screen flex relative">
26
- <SideTool />
27
- <Board />
28
- <ControlPanels />
29
- </div>
30
- </>);
31
- };
32
- export default TableEditor;
33
- export { LayerView };
@@ -1,4 +0,0 @@
1
- declare const ModalPreview: ({ children }: {
2
- children: React.ReactNode;
3
- }) => import("react").JSX.Element;
4
- export default ModalPreview;
@@ -1,11 +0,0 @@
1
- "use client";
2
- import { Modal } from "antd";
3
- import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
4
- const ModalPreview = ({ children }) => {
5
- const { isPreview } = useAppSelector((state) => state.tool);
6
- const dispatch = useAppDispatch();
7
- return (<Modal open={isPreview} onCancel={() => dispatch({ type: "tool/setTooglePreview", payload: false })} width={700} title="Preview Board" centered footer={null}>
8
- <div className="flex flex-col p-4 h-[500px]">{children}</div>
9
- </Modal>);
10
- };
11
- export default ModalPreview;
@@ -1,12 +0,0 @@
1
- export interface Component {
2
- id: string;
3
- [key: string]: any;
4
- }
5
- export interface InitialState {
6
- components: Component[];
7
- backgroundColor: string;
8
- extraComponents: Component[];
9
- }
10
- 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">;
11
- declare const _default: import("redux").Reducer<InitialState>;
12
- export default _default;
@@ -1,44 +0,0 @@
1
- import { createSlice } from "@reduxjs/toolkit";
2
- const initialState = {
3
- components: [],
4
- backgroundColor: "#000000",
5
- extraComponents: []
6
- };
7
- const boardSlice = createSlice({
8
- name: "board",
9
- initialState,
10
- reducers: {
11
- addComponent: (state, action) => {
12
- state.components.push(action.payload);
13
- },
14
- removeComponent: (state, action) => {
15
- state.components = state.components.filter((component) => component.id !== action.payload.id);
16
- },
17
- updateComponent: (state, action) => {
18
- const index = state.components.findIndex((component) => component.id === action.payload.id);
19
- const indexExtra = state.extraComponents.findIndex((extraComponent) => extraComponent.id === action.payload.id);
20
- if (index !== -1) {
21
- // Update component biasa
22
- state.components[index] = Object.assign(Object.assign({}, state.components[index]), action.payload);
23
- }
24
- else if (indexExtra !== -1) {
25
- // Update extraComponent
26
- state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), action.payload);
27
- }
28
- },
29
- setBackgroundColor: (state, action) => {
30
- state.backgroundColor = action.payload;
31
- },
32
- setNewComponents: (state, action) => {
33
- state.components = action.payload;
34
- },
35
- setNewExtraComponents: (state, action) => {
36
- state.extraComponents = action.payload;
37
- },
38
- setExtraComponent: (state, action) => {
39
- state.extraComponents.push(action.payload);
40
- },
41
- },
42
- });
43
- export const { addComponent, removeComponent, updateComponent, setBackgroundColor } = boardSlice.actions;
44
- export default boardSlice.reducer;
@@ -1,290 +0,0 @@
1
- "use client";
2
- import { useCallback, useEffect, useRef, useState } from "react";
3
- import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
4
- import { useAppSelector, useAppDispatch } from "../../hooks/use-redux";
5
- import Layers from "../../components/layer";
6
- import { throttle } from "lodash";
7
- import ModalPreview from "../../components/modal-preview";
8
- import LayerView from "../view";
9
- const BoardTemplate = ({ onSelectComponent }) => {
10
- const dispatch = useAppDispatch();
11
- const transformRef = useRef(null);
12
- const containerRef = useRef(null);
13
- const [widthBoard, setWidthBoard] = useState(0);
14
- const [heightBoard, setHeightBoard] = useState(0);
15
- const svgRef = useRef(null);
16
- const [shadowShape, setShadowShape] = useState([]);
17
- const [startPoint, setStartPoint] = useState(null);
18
- const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 });
19
- const [moveComponent, setMoveComponent] = useState(false);
20
- const [scale, setScale] = useState(1);
21
- const activeTool = useAppSelector((state) => state.tool.active);
22
- const { components, extraComponents } = useAppSelector((state) => state.board);
23
- const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
24
- const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
25
- // useEffect(() => {
26
- // const handleKeyDown = (event: KeyboardEvent) => {
27
- // if (event.key === 'Backspace' && selectedComponent) {
28
- // dispatch({
29
- // type:"board/removeComponent",
30
- // payload:selectedComponent
31
- // })
32
- // dispatch({
33
- // type:"panel/setUnSelectedComponent",
34
- // })
35
- // }
36
- // };
37
- // window.addEventListener('keydown', handleKeyDown);
38
- // return () => {
39
- // window.removeEventListener('keydown', handleKeyDown);
40
- // };
41
- // }, [selectedComponent]);
42
- const handleAddComponent = (shape) => {
43
- dispatch({
44
- type: activeTool === "text"
45
- ? "board/setExtraComponent"
46
- : "board/addComponent",
47
- payload: Object.assign(Object.assign({}, shape), { fill: "#4A90E2" }),
48
- });
49
- };
50
- const handleUpdateComponent = () => {
51
- if (!selectedComponent)
52
- return;
53
- dispatch({
54
- type: "board/updateComponent",
55
- payload: Object.assign({}, (typeof selectedComponent === "object" && selectedComponent !== null
56
- ? selectedComponent
57
- : {})),
58
- });
59
- };
60
- const getSvgCoords = (e) => {
61
- var _a;
62
- const svg = svgRef.current;
63
- const point = svg.createSVGPoint();
64
- point.x = e.clientX;
65
- point.y = e.clientY;
66
- const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
67
- return { x: transformed.x, y: transformed.y };
68
- };
69
- const createShape = (x, y, fill) => ({
70
- x,
71
- y,
72
- width: 50,
73
- height: 50,
74
- shape: activeTool,
75
- id: Date.now(),
76
- fill,
77
- rotation: activeTool === "diamond" ? 45 : 0,
78
- seatCount: activeTool === "table-seat-circle" ? 6 : 0,
79
- openSpace: activeTool === "table-seat-circle" ? 0 : undefined,
80
- seatFill: activeTool === "table-seat-circle" ? "#DADADA" : undefined,
81
- text: activeTool === "text" ? "Text" : "",
82
- fontColor: activeTool === "text" ? "#DADADA" : undefined,
83
- });
84
- // console.log({ moveComponent})
85
- const handleMouseDown = (e, item) => {
86
- // console.log(" mouse down", item);
87
- // if (!isEmpty(item)) {
88
- // handleSelectComponent(item);
89
- // }
90
- if (activeTool === "select") {
91
- if (e) {
92
- dispatch({ type: "panel/setShow", payload: false });
93
- setMoveComponent(true);
94
- dispatch({ type: "panel/setSelectedComponent", payload: item });
95
- const rectBox = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
96
- setDragOffset({
97
- x: e.clientX - rectBox.left,
98
- y: e.clientY - rectBox.top,
99
- });
100
- // dispatch({ type: "panel/setShow" , payload: false });
101
- }
102
- }
103
- };
104
- const handleMouseUp = () => {
105
- if (activeTool === "select") {
106
- setMoveComponent(false);
107
- dispatch({ type: "panel/setShow", payload: false });
108
- }
109
- };
110
- const handleMouseEnter = () => {
111
- if (![
112
- "square",
113
- "circle",
114
- "diamond",
115
- "table-seat-circle",
116
- "table-seat-square",
117
- "text",
118
- ].includes(activeTool))
119
- return;
120
- };
121
- const handleMouseLeave = () => {
122
- if (![
123
- "square",
124
- "circle",
125
- "diamond",
126
- "table-seat-circle",
127
- "table-seat-square",
128
- "text",
129
- ].includes(activeTool))
130
- return;
131
- setShadowShape([]);
132
- };
133
- const handleMouseClick = (e) => {
134
- if (![
135
- "square",
136
- "circle",
137
- "diamond",
138
- "table-seat-circle",
139
- "table-seat-square",
140
- "text",
141
- ].includes(activeTool))
142
- return;
143
- const { x, y } = getSvgCoords(event);
144
- setStartPoint({ x, y });
145
- handleAddComponent(createShape(x, y, "#4A90E2"));
146
- };
147
- const throttledDispatch = useCallback(throttle((component) => {
148
- dispatch({
149
- type: "board/updateComponent",
150
- payload: component,
151
- });
152
- }, 16), // 16ms ≈ 60fps
153
- [dispatch]);
154
- const handleMouseMove = (e) => {
155
- if ([
156
- "square",
157
- "circle",
158
- "diamond",
159
- "table-seat-circle",
160
- "table-seat-square",
161
- "text",
162
- ].includes(activeTool)) {
163
- const { x, y } = getSvgCoords(event);
164
- setShadowShape([createShape(x, y, "white")]);
165
- return;
166
- }
167
- if (activeTool === "select" &&
168
- selectedComponent &&
169
- moveComponent &&
170
- dragOffset) {
171
- const workspaceRect = e.currentTarget.getBoundingClientRect();
172
- const newX = e.clientX - workspaceRect.left - dragOffset.x;
173
- const newY = e.clientY - workspaceRect.top - dragOffset.y;
174
- let newPosition = {
175
- x: newX,
176
- y: newY,
177
- };
178
- throttledDispatch(Object.assign(Object.assign({}, (typeof selectedComponent === "object" && selectedComponent !== null
179
- ? selectedComponent
180
- : {})), { x: newPosition.x, y: newPosition.y }));
181
- // dispatch({
182
- // type: "board/updateComponent",
183
- // payload: {
184
- // ...(typeof selectedComponent === "object" &&
185
- // selectedComponent !== null
186
- // ? selectedComponent
187
- // : {}),
188
- // x: newPosition.x,
189
- // y: newPosition.y,
190
- // },
191
- // });
192
- return;
193
- }
194
- };
195
- // if (activeTool === "table-seat-circle") {
196
- // shape = {
197
- // x: Math.min(x, startPoint.x),
198
- // y: Math.min(y, startPoint.y),
199
- // width: Math.abs(x - startPoint.x),
200
- // height: Math.abs(y - startPoint.y),
201
- // shape: activeTool,
202
- // id: Date.now(),
203
- // fill: "#4A90E2",
204
- // seats: 6,
205
- // };
206
- // }
207
- // if (activeTool === "text") {
208
- // shape = {
209
- // x: Math.min(x, startPoint.x),
210
- // y: Math.min(y, startPoint.y),
211
- // width: Math.abs(x - startPoint.x),
212
- // height: Math.abs(y - startPoint.y),
213
- // shape: activeTool,
214
- // id: Date.now(),
215
- // fill: "#4A90E2",
216
- // text: "Text",
217
- // };
218
- // }
219
- // if (activeTool === "select" && selectedComponent) {
220
- // shape = {
221
- // ...selectedComponent,
222
- // x: Math.min(x, startPoint.x),
223
- // y: Math.min(y, startPoint.y),
224
- // width: Math.abs(x - startPoint.x),
225
- // height: Math.abs(y - startPoint.y),
226
- // };
227
- // setSelectedComponent(shape);
228
- // return;
229
- // }
230
- // }
231
- const handleSelectComponent = (items) => {
232
- if (activeTool === "select") {
233
- // if (isEmpty(items)) {
234
- // dispatch({ type: "panel/setSelectedComponent", payload: null });
235
- // setMoveComponent(false);
236
- // } else {
237
- onSelectComponent && onSelectComponent(items);
238
- dispatch({ type: "panel/setSelectedComponent", payload: items });
239
- dispatch({ type: "panel/setShow", payload: true });
240
- // }
241
- }
242
- };
243
- useEffect(() => {
244
- if (containerRef.current) {
245
- setWidthBoard(containerRef.current.offsetWidth);
246
- setHeightBoard(containerRef.current.offsetHeight);
247
- }
248
- });
249
- const handleUnSelectComponent = () => {
250
- dispatch({ type: "panel/setSelectedComponent", payload: null });
251
- };
252
- return (<>
253
- <ModalPreview>
254
- <LayerView statusKey="status"/>
255
- </ModalPreview>
256
- <div className="relative w-full h-screen flex-1" ref={containerRef}>
257
- <TransformWrapper ref={transformRef} panning={{ disabled: false }} centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} // sangat kecil = bisa zoom out jauh
258
- maxScale={1000} initialScale={1} pinch={{ step: 1 }} smooth={true}
259
- // doubleClick={{ step: 2, mode: "zoomIn" }}
260
- disablePadding>
261
- <TransformComponent wrapperStyle={{
262
- width: "100%",
263
- height: "100%",
264
- overflow: "hidden",
265
- }} contentStyle={{
266
- width: "100%",
267
- height: "100%",
268
- }}>
269
- <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) => {
270
- e.stopPropagation();
271
- handleMouseClick(e);
272
- }} onMouseLeave={handleMouseLeave}
273
- // onMouseDown={(e) => {
274
- // e.stopPropagation();
275
- // }}
276
- // onFocus={(e) => {
277
- // console.log(e.target);
278
- // }}
279
- xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
280
- background: backgroundColor,
281
- display: "block",
282
- }}>
283
- <Layers shadowShape={shadowShape} components={[...extraComponents, ...components]} onClick={handleSelectComponent} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp} onBlur={handleUnSelectComponent} selectedComponent={selectedComponent} activeTool={activeTool}/>
284
- </svg>
285
- </TransformComponent>
286
- </TransformWrapper>
287
- </div>
288
- </>);
289
- };
290
- export default BoardTemplate;
@@ -1,2 +0,0 @@
1
- declare const Navbar: () => import("react").JSX.Element;
2
- export default Navbar;
@@ -1,5 +0,0 @@
1
- "use client";
2
- const Navbar = () => {
3
- return <div>Navbar</div>;
4
- };
5
- export default Navbar;
@@ -1,39 +0,0 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import Board from "../board";
4
- import SideTool from "../side-tool";
5
- import ControlPanels from "../panel";
6
- import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
7
- const TableEditor = (props) => {
8
- const { componentProps, extraComponentProps, onCurrentStateChange } = props;
9
- const { components, extraComponents } = useAppSelector((state) => state.board);
10
- const dispatch = useAppDispatch();
11
- useEffect(() => {
12
- onCurrentStateChange && onCurrentStateChange({
13
- components,
14
- extraComponents,
15
- });
16
- }, [components, extraComponents]);
17
- useEffect(() => {
18
- if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
19
- dispatch({
20
- type: "board/setNewComponents",
21
- payload: componentProps,
22
- });
23
- }
24
- if ((extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) > 0) {
25
- dispatch({
26
- type: "board/setNewExtraComponent",
27
- payload: extraComponentProps,
28
- });
29
- }
30
- }, [componentProps, extraComponentProps]);
31
- return (<>
32
- <div className="w-full h-screen flex relative">
33
- <SideTool />
34
- <Board onSelectComponent={props.onSelectComponent}/>
35
- <ControlPanels />
36
- </div>
37
- </>);
38
- };
39
- export default TableEditor;
@@ -1,2 +0,0 @@
1
- declare const ControlPanels: () => import("react").JSX.Element;
2
- export default ControlPanels;
@@ -1,91 +0,0 @@
1
- "use client";
2
- import { useEffect, useState } from "react";
3
- import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
4
- import { Form, Drawer, Input } from "antd";
5
- import SelectToolForm from "./select-tool";
6
- import SquareToolForm from "./square-circle-tool";
7
- import SeatCircle from "./table-seat-circle";
8
- import UploadTool from "./upload-tool";
9
- const ControlPanels = () => {
10
- const dispatch = useAppDispatch();
11
- const tool = useAppSelector((state) => state.tool);
12
- const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
13
- const { show } = useAppSelector((state) => state.panel);
14
- const [open, setOpen] = useState(false);
15
- const [form] = Form.useForm();
16
- let values = Form.useWatch([], form);
17
- useEffect(() => {
18
- console.log("masuuuuk");
19
- if (selectedComponent) {
20
- 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);
21
- const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
22
- (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height) === (values === null || values === void 0 ? void 0 : values.height) &&
23
- (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.width) === (values === null || values === void 0 ? void 0 : values.width) &&
24
- (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x) === (values === null || values === void 0 ? void 0 : values.x) &&
25
- (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y) === (values === null || values === void 0 ? void 0 : values.y);
26
- console.log({ isDifferentId, isSameIdAndSameDimensions, show });
27
- if (show && (isDifferentId || isSameIdAndSameDimensions)) {
28
- setOpen(true);
29
- }
30
- console.log("turee");
31
- form.setFieldsValue(selectedComponent);
32
- }
33
- else {
34
- console.log("false");
35
- setOpen(false);
36
- }
37
- }, [selectedComponent]);
38
- useEffect(() => {
39
- if (tool.active === "background" || tool.active === "image-table") {
40
- setOpen(true);
41
- }
42
- }, [tool]);
43
- const handleChangeComponent = (values, allValues) => {
44
- dispatch({
45
- type: "board/updateComponent",
46
- payload: Object.assign(Object.assign({}, (selectedComponent || {})), allValues),
47
- });
48
- dispatch({
49
- type: "panel/updateSelectedComponent",
50
- payload: Object.assign(Object.assign({}, (selectedComponent || {})), allValues),
51
- });
52
- };
53
- const renderFormPanel = () => {
54
- switch (tool.active) {
55
- case "select":
56
- return <SelectToolForm />;
57
- case "square":
58
- case "circle":
59
- return <SquareToolForm />;
60
- case "table-seat-circle":
61
- return <SeatCircle />;
62
- case "image-table":
63
- return <UploadTool name={tool.active} type="component"/>;
64
- case "background":
65
- return <UploadTool name={tool.active} type="background"/>;
66
- default:
67
- return null;
68
- }
69
- };
70
- const handleClose = () => {
71
- setOpen(false);
72
- dispatch({
73
- type: "panel/setShow",
74
- payload: false,
75
- });
76
- };
77
- // if(!show) return null
78
- return (<Drawer open={show} onClose={handleClose} title="Panel">
79
- <div className="bg-white h-full max-h-screen overflow-y-auto w-[300px]">
80
- <Form layout="vertical" form={form} name="table" onFinish={(values) => {
81
- console.log(values);
82
- }} onValuesChange={handleChangeComponent} initialValues={{ labels: [{}] }}>
83
- <Form.Item name="id" hidden>
84
- <Input />
85
- </Form.Item>
86
- {renderFormPanel()}
87
- </Form>
88
- </div>
89
- </Drawer>);
90
- };
91
- export default ControlPanels;
@@ -1,16 +0,0 @@
1
- import { PayloadAction } from "@reduxjs/toolkit";
2
- export interface PanelState {
3
- selectedComponent: any;
4
- pasSelectedComponent: any[];
5
- active: string;
6
- show: boolean;
7
- }
8
- export declare const panelSlice: import("@reduxjs/toolkit").Slice<PanelState, {
9
- setSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
10
- setUnSelectedComponent: (state: import("immer").WritableDraft<PanelState>) => void;
11
- updateSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
12
- setShow: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<boolean>) => void;
13
- }, "panel", "panel", import("@reduxjs/toolkit").SliceSelectors<PanelState>>;
14
- 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">;
15
- declare const _default: import("redux").Reducer<PanelState>;
16
- export default _default;
@@ -1,31 +0,0 @@
1
- import { createSlice } from "@reduxjs/toolkit";
2
- const initialState = {
3
- selectedComponent: null,
4
- pasSelectedComponent: [],
5
- active: "",
6
- show: false,
7
- };
8
- export const panelSlice = createSlice({
9
- name: "panel",
10
- initialState,
11
- reducers: {
12
- setSelectedComponent: (state, action) => {
13
- state.pasSelectedComponent = [
14
- ...state.pasSelectedComponent,
15
- action.payload,
16
- ];
17
- state.selectedComponent = action.payload;
18
- },
19
- setUnSelectedComponent: (state) => {
20
- state.selectedComponent = null;
21
- },
22
- updateSelectedComponent: (state, action) => {
23
- state.selectedComponent = Object.assign({}, action.payload);
24
- },
25
- setShow: (state, action) => {
26
- state.show = action.payload;
27
- }
28
- },
29
- });
30
- export const { setSelectedComponent, setUnSelectedComponent, setShow } = panelSlice.actions;
31
- export default panelSlice.reducer;
@@ -1,4 +0,0 @@
1
- declare const SelectToolForm: ({ title }: {
2
- title?: string;
3
- }) => import("react").JSX.Element;
4
- export default SelectToolForm;