seat-editor 2.1.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/constant.d.ts +232 -0
- package/dist/app/constant.js +3683 -3045
- package/dist/app/new-board/page.js +5 -6
- package/dist/app/only-view/chair.d.ts +1 -0
- package/dist/app/only-view/chair.js +4 -0
- package/dist/app/only-view/constant.d.ts +22 -2
- package/dist/app/only-view/constant.js +4 -4
- package/dist/app/only-view/page.js +74 -37
- package/dist/app/only-view/user.d.ts +1 -0
- package/dist/app/only-view/user.js +4 -0
- package/dist/components/layer-v3/index.d.ts +23 -4
- package/dist/components/layer-v3/index.js +329 -146
- package/dist/components/layer-v4/index.d.ts +20 -0
- package/dist/components/layer-v4/index.js +445 -0
- package/dist/components/lib/index.d.ts +1 -1
- package/dist/components/lib/index.js +1 -1
- package/dist/features/board/index.js +1 -1
- package/dist/features/board-v2/index.js +1 -1
- package/dist/features/board-v3/board-slice.d.ts +1 -0
- package/dist/features/board-v3/board-slice.js +26 -3
- package/dist/features/board-v3/constant.d.ts +5 -0
- package/dist/features/board-v3/constant.js +5 -0
- package/dist/features/board-v3/index copy.d.ts +47 -0
- package/dist/features/board-v3/index copy.js +2073 -0
- package/dist/features/board-v3/index.js +1409 -647
- package/dist/features/board-v3/polygon.d.ts +28 -0
- package/dist/features/board-v3/polygon.js +109 -0
- package/dist/features/board-v3/rect.d.ts +9 -0
- package/dist/features/board-v3/rect.js +152 -0
- package/dist/features/board-v3/resize-element.d.ts +12 -0
- package/dist/features/board-v3/resize-element.js +40 -0
- package/dist/features/board-v3/utils.d.ts +162 -0
- package/dist/features/board-v3/utils.js +787 -0
- package/dist/features/package/index.js +1 -1
- package/dist/features/panel/index.js +130 -20
- package/dist/features/panel/panel-slice.d.ts +5 -0
- package/dist/features/panel/panel-slice.js +15 -0
- package/dist/features/panel/select-tool.js +11 -1
- package/dist/features/panel/selected-group.d.ts +2 -0
- package/dist/features/panel/selected-group.js +7 -0
- package/dist/features/panel/table-seat-square.d.ts +2 -0
- package/dist/features/panel/table-seat-square.js +9 -0
- package/dist/features/side-tool/index.js +13 -6
- package/dist/features/view-only/index.js +0 -1
- package/dist/features/view-only-2/index.js +0 -1
- package/dist/features/view-only-3/index.d.ts +68 -0
- package/dist/features/view-only-3/index.js +510 -0
- package/dist/features/view-only-3/utils.d.ts +1 -0
- package/dist/features/view-only-3/utils.js +3 -0
- package/dist/seat-editor.css +1 -1
- package/dist/utils/constant.d.ts +1 -0
- package/dist/utils/constant.js +11 -0
- package/dist/utils/format.d.ts +2 -0
- package/dist/utils/format.js +29 -0
- package/package.json +3 -1
- package/dist/features/view/index.d.ts +0 -19
- package/dist/features/view/index.js +0 -221
|
@@ -6,7 +6,7 @@ import SideTool from "../side-tool";
|
|
|
6
6
|
import ControlPanels from "../panel";
|
|
7
7
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
8
8
|
import { isEqual } from "lodash";
|
|
9
|
-
import LayerView from "../view";
|
|
9
|
+
import LayerView from "../view-only";
|
|
10
10
|
const TableEditor = (props) => {
|
|
11
11
|
const [initialValue, setInitialValue] = useState(null);
|
|
12
12
|
const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized } = props;
|
|
@@ -13,18 +13,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { useEffect, useRef, useState } from "react";
|
|
15
15
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
16
|
-
import { Form,
|
|
16
|
+
import { Form, Input } from "antd";
|
|
17
17
|
import SelectToolForm from "./select-tool";
|
|
18
18
|
import SquareToolForm from "./square-circle-tool";
|
|
19
19
|
import SeatCircle from "./table-seat-circle";
|
|
20
20
|
import UploadTool from "./upload-tool";
|
|
21
21
|
import { debounce } from "lodash";
|
|
22
|
+
import clsx from "clsx";
|
|
23
|
+
import { getAttributeElement } from "../board-v3/resize-element";
|
|
24
|
+
import { applyResizeToSvgElement, updateSelectionBox } from "../board-v3/utils";
|
|
22
25
|
const ControlPanels = (props) => {
|
|
23
26
|
const { action, responseMapping } = props;
|
|
24
27
|
const dispatch = useAppDispatch();
|
|
25
28
|
const theme = useAppSelector((state) => state.theme);
|
|
26
29
|
const tool = useAppSelector((state) => state.tool);
|
|
27
30
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
31
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
32
|
+
const components = useAppSelector((state) => state.board.components);
|
|
33
|
+
const extraComponents = useAppSelector((state) => state.board.extraComponents);
|
|
34
|
+
const svgRef = useRef(null);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
svgRef.current = document.querySelectorAll("#workspace");
|
|
37
|
+
}, []);
|
|
28
38
|
const { show } = useAppSelector((state) => state.panel);
|
|
29
39
|
const [open, setOpen] = useState(false);
|
|
30
40
|
const [form] = Form.useForm();
|
|
@@ -43,20 +53,48 @@ const ControlPanels = (props) => {
|
|
|
43
53
|
}
|
|
44
54
|
form.setFieldsValue(selectedComponent);
|
|
45
55
|
}
|
|
56
|
+
else if (selectedGroup) {
|
|
57
|
+
if (show)
|
|
58
|
+
setOpen(true);
|
|
59
|
+
if (!show)
|
|
60
|
+
setOpen(false);
|
|
61
|
+
function isSameAllByKey(arr, key) {
|
|
62
|
+
if (!arr || arr.length === 0)
|
|
63
|
+
return false;
|
|
64
|
+
const firstValue = arr[0][key];
|
|
65
|
+
return arr.every((item) => item[key] === firstValue);
|
|
66
|
+
}
|
|
67
|
+
const isSameAllWidth = isSameAllByKey(selectedGroup, "width");
|
|
68
|
+
const isSameAllHeight = isSameAllByKey(selectedGroup, "height");
|
|
69
|
+
const isSameX = isSameAllByKey(selectedGroup, "x");
|
|
70
|
+
const isSameY = isSameAllByKey(selectedGroup, "y");
|
|
71
|
+
const isSameFill = isSameAllByKey(selectedGroup, "fill");
|
|
72
|
+
const isSameStroke = isSameAllByKey(selectedGroup, "stroke");
|
|
73
|
+
const isSameOpacity = isSameAllByKey(selectedGroup, "opacity");
|
|
74
|
+
const isSampeRotation = isSameAllByKey(selectedGroup, "rotation");
|
|
75
|
+
const isSameStrokeWidth = isSameAllByKey(selectedGroup, "strokeWidth");
|
|
76
|
+
form.setFieldsValue(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (isSameAllWidth ? { width: selectedGroup[0].width } : {})), (isSameAllHeight ? { height: selectedGroup[0].height } : {})), (isSameX ? { x: selectedGroup[0].x } : {})), (isSameY ? { y: selectedGroup[0].y } : {})), (isSameFill ? { fill: selectedGroup[0].fill } : {})), (isSameStroke ? { stroke: selectedGroup[0].stroke } : {})), (isSameOpacity ? { opacity: selectedGroup[0].opacity } : {})), (isSampeRotation ? { rotation: selectedGroup[0].rotation } : {})), (isSameStrokeWidth
|
|
77
|
+
? { strokeWidth: selectedGroup[0].strokeWidth }
|
|
78
|
+
: {})));
|
|
79
|
+
}
|
|
46
80
|
else {
|
|
47
81
|
setOpen(false);
|
|
48
82
|
}
|
|
49
|
-
}, [selectedComponent]);
|
|
83
|
+
}, [selectedComponent, selectedGroup, show]);
|
|
50
84
|
useEffect(() => {
|
|
51
85
|
if (tool.active === "background" || tool.active === "image-table") {
|
|
52
86
|
setOpen(true);
|
|
53
87
|
}
|
|
54
88
|
}, [tool]);
|
|
55
89
|
const createShape = (shape, ...props) => {
|
|
56
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
57
|
-
return (Object.assign(Object.assign({}, props === null || props === void 0 ? void 0 : props[0]), { shape, fill: (
|
|
58
|
-
? (
|
|
59
|
-
: undefined,
|
|
90
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
91
|
+
return (Object.assign(Object.assign({}, props === null || props === void 0 ? void 0 : props[0]), { shape, fill: (_a = props === null || props === void 0 ? void 0 : props[0]) === null || _a === void 0 ? void 0 : _a.fill, seatCount: shape === "table-seat-circle" ? (_c = (_b = props === null || props === void 0 ? void 0 : props[0]) === null || _b === void 0 ? void 0 : _b.seatCount) !== null && _c !== void 0 ? _c : 6 : 0, openSpace: ["table-seat-circle", "table-seat-square"].includes(shape)
|
|
92
|
+
? (_e = (_d = props === null || props === void 0 ? void 0 : props[0]) === null || _d === void 0 ? void 0 : _d.openSpace) !== null && _e !== void 0 ? _e : 0
|
|
93
|
+
: undefined,
|
|
94
|
+
// seatFill: ["table-seat-circle", "table-seat-square"].includes(shape)
|
|
95
|
+
// ? props?.[0]?.seatFill ?? "#DADADA"
|
|
96
|
+
// : undefined,
|
|
97
|
+
text: shape === "text" ? (_g = (_f = props === null || props === void 0 ? void 0 : props[0]) === null || _f === void 0 ? void 0 : _f.text) !== null && _g !== void 0 ? _g : "Text" : undefined, fontColor: shape === "text" ? (_j = (_h = props === null || props === void 0 ? void 0 : props[0]) === null || _h === void 0 ? void 0 : _h.fontColor) !== null && _j !== void 0 ? _j : "#DADADA" : undefined }));
|
|
60
98
|
};
|
|
61
99
|
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
62
100
|
dispatch({
|
|
@@ -70,21 +108,61 @@ const ControlPanels = (props) => {
|
|
|
70
108
|
payload: data,
|
|
71
109
|
});
|
|
72
110
|
}, 300));
|
|
111
|
+
const debouncedSyncSelectedSelectionLines = useRef(debounce((data) => {
|
|
112
|
+
dispatch({
|
|
113
|
+
type: "panel/setSelectionLines",
|
|
114
|
+
payload: data,
|
|
115
|
+
});
|
|
116
|
+
}));
|
|
117
|
+
const debounceSyncSelectedGroup = useRef(debounce((data) => {
|
|
118
|
+
dispatch({
|
|
119
|
+
type: "panel/updateSelectedGroup",
|
|
120
|
+
payload: data,
|
|
121
|
+
});
|
|
122
|
+
}, 300));
|
|
123
|
+
const debounceSyncDataSelectedGroup = useRef(debounce((data) => {
|
|
124
|
+
dispatch({
|
|
125
|
+
type: "board/updateAllComponents",
|
|
126
|
+
payload: data,
|
|
127
|
+
});
|
|
128
|
+
}, 300));
|
|
73
129
|
const debouncedSyncForm = useRef(debounce(() => {
|
|
74
130
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
131
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
75
132
|
}, 300));
|
|
133
|
+
const updateElement = (id, values) => {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
console.log({ id, values });
|
|
136
|
+
let findElement = [...components, ...extraComponents].find((item) => item.id === id);
|
|
137
|
+
if (!findElement)
|
|
138
|
+
return;
|
|
139
|
+
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: (_c = values.width) !== null && _c !== void 0 ? _c : findElement.width, height: (_d = values.height) !== null && _d !== void 0 ? _d : findElement.height });
|
|
140
|
+
const newSelection = {
|
|
141
|
+
width: newElement.width,
|
|
142
|
+
height: newElement.height,
|
|
143
|
+
x: newElement.x,
|
|
144
|
+
y: newElement.y,
|
|
145
|
+
};
|
|
146
|
+
const { g, element, inner, seats, seatGroup } = getAttributeElement((_e = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _e === void 0 ? void 0 : _e[1], id);
|
|
147
|
+
updateSelectionBox((_f = svgRef === null || svgRef === void 0 ? void 0 : svgRef.current) === null || _f === void 0 ? void 0 : _f[1], newSelection);
|
|
148
|
+
applyResizeToSvgElement(element, g, newElement);
|
|
149
|
+
};
|
|
76
150
|
const handleChangeComponent = (values, allValues) => {
|
|
77
151
|
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
78
152
|
const newValues = createShape(shape, restProps);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
153
|
+
// console.log("debouncedSyncSelectedComponents","haduhh",allValues, values);
|
|
154
|
+
if (selectedComponent) {
|
|
155
|
+
updateElement(allValues.id, values);
|
|
156
|
+
debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
157
|
+
// dispatch({
|
|
158
|
+
// type: "board/updateComponent",
|
|
159
|
+
// payload: {
|
|
160
|
+
// ...(selectedComponent || {}),
|
|
161
|
+
// ...newValues,
|
|
162
|
+
// },
|
|
163
|
+
// });
|
|
164
|
+
// if (shape !== selectedComponent?.shape) {
|
|
165
|
+
// console.log("debouncedSyncSelectedComponents","haduhh")
|
|
88
166
|
debouncedSyncSelectedComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
89
167
|
// dispatch({
|
|
90
168
|
// type: "panel/updateSelectedComponent",
|
|
@@ -93,6 +171,41 @@ const ControlPanels = (props) => {
|
|
|
93
171
|
// ...newValues,
|
|
94
172
|
// },
|
|
95
173
|
// });
|
|
174
|
+
// }
|
|
175
|
+
}
|
|
176
|
+
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
177
|
+
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, } = newValues;
|
|
178
|
+
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({}, 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 } : {}))));
|
|
179
|
+
let minX = Infinity;
|
|
180
|
+
let minY = Infinity;
|
|
181
|
+
let maxX = -Infinity;
|
|
182
|
+
let maxY = -Infinity;
|
|
183
|
+
updatedGroup.forEach((comp) => {
|
|
184
|
+
minX = Math.min(minX, comp.x);
|
|
185
|
+
minY = Math.min(minY, comp.y);
|
|
186
|
+
maxX = Math.max(maxX, comp.x + comp.width);
|
|
187
|
+
maxY = Math.max(maxY, comp.y + comp.height);
|
|
188
|
+
});
|
|
189
|
+
const newSelectionGroup = {
|
|
190
|
+
x: minX,
|
|
191
|
+
y: minY,
|
|
192
|
+
width: maxX - minX,
|
|
193
|
+
height: maxY - minY,
|
|
194
|
+
shape: "selection-box",
|
|
195
|
+
id: `${Date.now()}`,
|
|
196
|
+
fill: "transparent",
|
|
197
|
+
rotation: 0,
|
|
198
|
+
stroke: "red",
|
|
199
|
+
};
|
|
200
|
+
dispatch({
|
|
201
|
+
type: "panel/setSelectionLines",
|
|
202
|
+
payload: newSelectionGroup,
|
|
203
|
+
});
|
|
204
|
+
// dispatch({
|
|
205
|
+
// type: "panel/updateSelectedGroup",
|
|
206
|
+
// payload: updatedGroup,
|
|
207
|
+
// });
|
|
208
|
+
debounceSyncDataSelectedGroup.current(updatedGroup);
|
|
96
209
|
}
|
|
97
210
|
debouncedSyncForm.current();
|
|
98
211
|
};
|
|
@@ -115,16 +228,13 @@ const ControlPanels = (props) => {
|
|
|
115
228
|
};
|
|
116
229
|
const handleClose = () => {
|
|
117
230
|
setOpen(false);
|
|
231
|
+
// HIDE SEMENTARA
|
|
118
232
|
dispatch({
|
|
119
233
|
type: "panel/setShow",
|
|
120
234
|
payload: false,
|
|
121
235
|
});
|
|
122
236
|
};
|
|
123
237
|
// if(!show) return null
|
|
124
|
-
return (_jsx(
|
|
125
|
-
body: {
|
|
126
|
-
paddingBottom: 0,
|
|
127
|
-
},
|
|
128
|
-
}, children: _jsx("div", { className: "bg-white h-full max-h-screen w-full p-2", children: _jsxs(Form, { layout: "vertical", form: form, name: "table", onValuesChange: handleChangeComponent, initialValues: { labels: [{}] }, children: [_jsx(Form.Item, { name: "id", hidden: true, children: _jsx(Input, {}) }), renderFormPanel()] }) }) }));
|
|
238
|
+
return (_jsx("div", { className: clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll ", open ? "right-0" : "right-[-300px]"), children: _jsx("div", { className: "bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300", children: _jsxs(Form, { layout: "vertical", form: form, name: "table", onValuesChange: handleChangeComponent, initialValues: { labels: [{}] }, children: [_jsx(Form.Item, { name: "id", hidden: true, children: _jsx(Input, {}) }), renderFormPanel()] }) }) }));
|
|
129
239
|
};
|
|
130
240
|
export default ControlPanels;
|
|
@@ -4,12 +4,17 @@ export interface PanelState {
|
|
|
4
4
|
history: any[];
|
|
5
5
|
active: string;
|
|
6
6
|
show: boolean;
|
|
7
|
+
selectedGroup: any;
|
|
8
|
+
selectionLines?: any;
|
|
7
9
|
}
|
|
8
10
|
export declare const panelSlice: import("@reduxjs/toolkit").Slice<PanelState, {
|
|
9
11
|
setSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
|
|
10
12
|
setUnSelectedComponent: (state: import("immer").WritableDraft<PanelState>) => void;
|
|
11
13
|
updateSelectedComponent: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
|
|
12
14
|
setShow: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<boolean>) => void;
|
|
15
|
+
setSelectedGroup: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
|
|
16
|
+
updateSelectedGroup: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
|
|
17
|
+
setSelectionLines: (state: import("immer").WritableDraft<PanelState>, action: PayloadAction<any>) => void;
|
|
13
18
|
}, "panel", "panel", import("@reduxjs/toolkit").SliceSelectors<PanelState>>;
|
|
14
19
|
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
20
|
declare const _default: import("redux").Reducer<PanelState>;
|
|
@@ -4,6 +4,8 @@ const initialState = {
|
|
|
4
4
|
history: [],
|
|
5
5
|
active: "",
|
|
6
6
|
show: false,
|
|
7
|
+
selectedGroup: null,
|
|
8
|
+
selectionLines: null,
|
|
7
9
|
};
|
|
8
10
|
export const panelSlice = createSlice({
|
|
9
11
|
name: "panel",
|
|
@@ -24,6 +26,19 @@ export const panelSlice = createSlice({
|
|
|
24
26
|
},
|
|
25
27
|
setShow: (state, action) => {
|
|
26
28
|
state.show = action.payload;
|
|
29
|
+
},
|
|
30
|
+
setSelectedGroup: (state, action) => {
|
|
31
|
+
state.selectedGroup = action.payload;
|
|
32
|
+
},
|
|
33
|
+
updateSelectedGroup: (state, action) => {
|
|
34
|
+
state.selectedGroup = Object.assign({}, action.payload);
|
|
35
|
+
state.history.push(state.selectedGroup);
|
|
36
|
+
if (state.history.length > 20) {
|
|
37
|
+
state.history.shift();
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
setSelectionLines: (state, action) => {
|
|
41
|
+
state.selectionLines = action.payload;
|
|
27
42
|
}
|
|
28
43
|
},
|
|
29
44
|
});
|
|
@@ -3,12 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
4
4
|
import SquareToolForm from "./square-circle-tool";
|
|
5
5
|
import SeatCircle from "./table-seat-circle";
|
|
6
|
+
import SeatSquare from "./table-seat-square";
|
|
6
7
|
import UploadTool from "./upload-tool";
|
|
7
8
|
import TextTool from "./text-tool";
|
|
9
|
+
import SelectedGroup from "./selected-group";
|
|
8
10
|
const SelectToolForm = ({ title = "Title", action, responseMapping }) => {
|
|
9
11
|
const components = useAppSelector((state) => state.board.components);
|
|
10
12
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
11
13
|
const extraComponents = useAppSelector((state) => state.board.extraComponents);
|
|
14
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
12
15
|
const SummaryComponents = () => {
|
|
13
16
|
const countByShape = components === null || components === void 0 ? void 0 : components.reduce((acc, item) => {
|
|
14
17
|
acc[item.shape] = (acc[item.shape] || 0) + 1;
|
|
@@ -32,6 +35,8 @@ const SelectToolForm = ({ title = "Title", action, responseMapping }) => {
|
|
|
32
35
|
return _jsx(SquareToolForm, {});
|
|
33
36
|
case "table-seat-circle":
|
|
34
37
|
return _jsx(SeatCircle, {});
|
|
38
|
+
case "table-seat-square":
|
|
39
|
+
return _jsx(SeatSquare, {});
|
|
35
40
|
case "image-table":
|
|
36
41
|
case "background":
|
|
37
42
|
return (_jsx(UploadTool, { action: action, responseMapping: responseMapping, name: selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape, defaultValue: selectedComponent, type: (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "background"
|
|
@@ -43,6 +48,11 @@ const SelectToolForm = ({ title = "Title", action, responseMapping }) => {
|
|
|
43
48
|
return null;
|
|
44
49
|
}
|
|
45
50
|
};
|
|
46
|
-
|
|
51
|
+
const renderSelectionComponent = () => {
|
|
52
|
+
if (selectedGroup) {
|
|
53
|
+
return (_jsx(SelectedGroup, {}));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(SummaryComponents, {}), renderComponent(), renderSelectionComponent()] }));
|
|
47
57
|
};
|
|
48
58
|
export default SelectToolForm;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { ColorPicker, Flex, Form, InputNumber } from "antd";
|
|
4
|
+
const SelectedGroup = () => {
|
|
5
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: " Group Selection" }), _jsxs("div", { className: "py-2", children: [_jsxs(Flex, { gap: 2, className: "w-full", children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", children: _jsx(InputNumber, { suffix: "px" }) }), _jsx(Form.Item, { label: "Height", name: "height", className: "w-full", children: _jsx(InputNumber, { suffix: "px" }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Position X", name: "x", className: "w-full", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { label: "Position Y", name: "y", className: "w-full", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { label: "Rotation", name: "rotation", className: "w-full", children: _jsx(InputNumber, { max: 360, min: 0 }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] }), _jsxs(Flex, { children: [_jsx(Form.Item, { label: "Stroke Width", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 0.1, max: 1, min: 0 }) })] })] })] }) }));
|
|
6
|
+
};
|
|
7
|
+
export default SelectedGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Col, ColorPicker, Flex, Form, InputNumber, Row, } from "antd";
|
|
4
|
+
import SectionLabel from "../../components/form-tools/label";
|
|
5
|
+
import SectionShape from "../../components/form-tools/shape";
|
|
6
|
+
const SeatSquare = () => {
|
|
7
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: " Square table" }), _jsx(Flex, { className: "w-full", children: _jsx(Form.Item, { name: "openSpace", label: "Open Space", className: "w-full", children: _jsx(InputNumber, { max: 1, min: 0, step: 0.1 }) }) }), _jsxs(Row, { gutter: [16, 16], children: [_jsxs(Col, { span: 12, children: [_jsx(Form.Item, { name: ["seatPositions", "top"], label: "Top", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 1 }) }), _jsx(Form.Item, { name: ["seatPositions", "left"], label: "Left", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 1 }) })] }), _jsxs(Col, { span: 12, children: [_jsx(Form.Item, { name: ["seatPositions", "right"], label: "Right", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 1 }) }), _jsx(Form.Item, { name: ["seatPositions", "bottom"], label: "Bottom", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 1 }) })] })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Seat Fill", name: "seatFill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Table Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] }), _jsx(SectionShape, {}), _jsx(SectionLabel, {})] }) }));
|
|
8
|
+
};
|
|
9
|
+
export default SeatSquare;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Ruler, Grid,
|
|
3
|
+
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Ruler, Grid, Lock, LockOpen, Undo2, Redo2, PenTool } from "lucide-react";
|
|
4
4
|
import ButtonTools from "../../components/button-tools";
|
|
5
5
|
import { Divider, ColorPicker, Button, message, } from "antd";
|
|
6
6
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
@@ -28,11 +28,11 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
28
28
|
name: "Ruler",
|
|
29
29
|
icon: _jsx(Ruler, {}),
|
|
30
30
|
},
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
31
|
+
// {
|
|
32
|
+
// id: "node",
|
|
33
|
+
// name: "Node Tool",
|
|
34
|
+
// icon: <MousePointer2 />,
|
|
35
|
+
// },
|
|
36
36
|
];
|
|
37
37
|
const actionsTools = [
|
|
38
38
|
// {
|
|
@@ -82,6 +82,11 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
82
82
|
name: "Text",
|
|
83
83
|
icon: _jsx(Type, {}),
|
|
84
84
|
},
|
|
85
|
+
{
|
|
86
|
+
id: "polygon",
|
|
87
|
+
name: "Polygon Tool",
|
|
88
|
+
icon: _jsx(PenTool, {}),
|
|
89
|
+
}
|
|
85
90
|
// {
|
|
86
91
|
// id: "background-color",
|
|
87
92
|
// name: "Background Color",
|
|
@@ -246,10 +251,12 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
246
251
|
const handleUndo = () => {
|
|
247
252
|
dispatch({ type: "board/undoHistory" });
|
|
248
253
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
254
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
249
255
|
};
|
|
250
256
|
const handleRedo = () => {
|
|
251
257
|
dispatch({ type: "board/redoHistory" });
|
|
252
258
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
259
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
253
260
|
};
|
|
254
261
|
return (_jsxs("div", { className: "h-full left-0 flex flex-col items-center border-r-2 border-gray-300 bg-white px-2 pt-4", children: [tools === null || tools === void 0 ? void 0 : tools.map((tool) => (_jsx(ButtonTools, { buttonProps: {
|
|
255
262
|
icon: tool.icon,
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { CSSProperties, SVGAttributes } from "react";
|
|
2
|
+
import { ReactZoomPanPinchRef, ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from "react-zoom-pan-pinch";
|
|
3
|
+
import { PropertiesProps } from "@/dto/table";
|
|
4
|
+
import { EventHandleType } from "@/dto/event-handler";
|
|
5
|
+
export type TableGhost = {
|
|
6
|
+
table: PropertiesProps;
|
|
7
|
+
event: EventHandleType;
|
|
8
|
+
};
|
|
9
|
+
export type TableMatchKey = {
|
|
10
|
+
key: string | number;
|
|
11
|
+
properties: PropertiesProps;
|
|
12
|
+
};
|
|
13
|
+
export type TableMatchEvent = {
|
|
14
|
+
event: EventHandleType;
|
|
15
|
+
properties: PropertiesProps;
|
|
16
|
+
};
|
|
17
|
+
export type ComponentProps = PropertiesProps | {
|
|
18
|
+
[key: string]: PropertiesProps | string | number | boolean | null | undefined;
|
|
19
|
+
};
|
|
20
|
+
export type OnCurrentStateChange = ({ components, extraComponents, }: {
|
|
21
|
+
components: ComponentProps[];
|
|
22
|
+
extraComponents: ComponentProps[];
|
|
23
|
+
}) => void;
|
|
24
|
+
export type TransformProps = React.ForwardRefExoticComponent<Omit<ReactZoomPanPinchProps, "ref"> & React.RefAttributes<ReactZoomPanPinchContentRef>>;
|
|
25
|
+
export type RefLayerView = {
|
|
26
|
+
svgRef: SVGSVGElement;
|
|
27
|
+
transformRef: ReactZoomPanPinchRef;
|
|
28
|
+
containerRef: HTMLDivElement;
|
|
29
|
+
tableGhost: SVGGElement;
|
|
30
|
+
hoverUnderghost: ComponentProps;
|
|
31
|
+
};
|
|
32
|
+
export interface LayerViewProps {
|
|
33
|
+
componentProps?: ComponentProps[];
|
|
34
|
+
extraComponentProps?: ComponentProps[];
|
|
35
|
+
onCurrentStateChange?: OnCurrentStateChange;
|
|
36
|
+
onSelectComponent?: (component: ComponentProps) => void;
|
|
37
|
+
mappingKey?: string;
|
|
38
|
+
tableMatchKey?: TableMatchKey[];
|
|
39
|
+
eventMatchTable?: TableMatchEvent[];
|
|
40
|
+
statusKey: string;
|
|
41
|
+
defaultBackground?: string;
|
|
42
|
+
transformProps?: TransformProps;
|
|
43
|
+
containerProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
44
|
+
svgProps?: SVGAttributes<SVGSVGElement>;
|
|
45
|
+
ghostAttributes?: SVGAttributes<SVGGElement>;
|
|
46
|
+
iconTags?: {
|
|
47
|
+
icon: React.JSX.Element;
|
|
48
|
+
key: string;
|
|
49
|
+
}[];
|
|
50
|
+
tooltipProps?: {
|
|
51
|
+
className: string;
|
|
52
|
+
style: CSSProperties;
|
|
53
|
+
minWidth: number;
|
|
54
|
+
};
|
|
55
|
+
dragTableBlockKey: [
|
|
56
|
+
{
|
|
57
|
+
key: string;
|
|
58
|
+
value: string | number;
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
onRightClick?: (e: MouseEvent, component: ComponentProps) => void;
|
|
62
|
+
allowTooltip?: boolean;
|
|
63
|
+
onDrop?: (e: React.MouseEvent<SVGSVGElement>, component: ComponentProps) => void;
|
|
64
|
+
onSwitch?: (e: MouseEvent, component: ComponentProps) => void;
|
|
65
|
+
refs?: React.ForwardedRef<RefLayerView>;
|
|
66
|
+
}
|
|
67
|
+
declare const LayerView: (props: LayerViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
export default LayerView;
|