seat-editor 3.3.2 → 3.3.3
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/components/form-tools/shape.d.ts +4 -0
- package/dist/components/form-tools/shape.jsx +42 -42
- package/dist/features/board-v3/board-slice.js +1 -1
- package/dist/features/panel/index.jsx +8 -6
- package/dist/features/panel/selected-group.jsx +67 -36
- package/dist/features/panel/table-seat-circle.jsx +8 -3
- package/dist/features/panel/table-seat-square.jsx +8 -3
- package/dist/features/panel/utils.js +3 -1
- package/dist/features/view-only-3/index.jsx +2 -3
- package/package.json +1 -1
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
|
|
3
|
+
export const optionsShape = [
|
|
4
|
+
{
|
|
5
|
+
value: "circle",
|
|
6
|
+
label: "Circle",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: "square",
|
|
10
|
+
label: "Square",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
value: "table-seat-circle",
|
|
14
|
+
label: "Type 1",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
value: "table-seat-square",
|
|
18
|
+
label: "Type 2",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: "table-seat-half-square",
|
|
22
|
+
label: "Type 3",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "table-seat-rect-square",
|
|
26
|
+
label: "Type 4",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "table-seat-rect-circle",
|
|
30
|
+
label: "Type 5",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Image Table",
|
|
34
|
+
value: "image-table",
|
|
35
|
+
},
|
|
36
|
+
];
|
|
3
37
|
const SectionShape = ({ allowChangeShape = true, }) => {
|
|
4
|
-
const
|
|
5
|
-
{
|
|
6
|
-
value: "circle",
|
|
7
|
-
label: "Circle",
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
value: "square",
|
|
11
|
-
label: "Square",
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
value: "table-seat-circle",
|
|
15
|
-
label: "Type 1",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
value: "table-seat-square",
|
|
19
|
-
label: "Type 2",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
value: "table-seat-half-square",
|
|
23
|
-
label: "Type 3",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: "table-seat-rect-square",
|
|
27
|
-
label: "Type 4",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
value: "table-seat-rect-circle",
|
|
31
|
-
label: "Type 5",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: "Image Table",
|
|
35
|
-
value: "image-table",
|
|
36
|
-
},
|
|
37
|
-
];
|
|
38
|
+
const shape = Form.useWatch("shape");
|
|
38
39
|
return (<div className="py-2">
|
|
39
40
|
<h1 className="heading-s">Shape</h1>
|
|
40
41
|
{allowChangeShape && (<Flex gap={2} className="w-full">
|
|
@@ -57,7 +58,6 @@ const SectionShape = ({ allowChangeShape = true, }) => {
|
|
|
57
58
|
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
58
59
|
}}/>
|
|
59
60
|
</Form.Item>
|
|
60
|
-
|
|
61
61
|
</Flex>
|
|
62
62
|
<Flex gap={2}>
|
|
63
63
|
<Form.Item label="Position X" name="x" className="w-full">
|
|
@@ -89,13 +89,13 @@ const SectionShape = ({ allowChangeShape = true, }) => {
|
|
|
89
89
|
<Form.Item label="Stroke" name={"strokeWidth"} className="w-full">
|
|
90
90
|
<InputNumber />
|
|
91
91
|
</Form.Item>
|
|
92
|
-
<Form.Item label="Radius" name="radius" className="w-full">
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
{!(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && (<Form.Item label="Radius" name="radius" className="w-full">
|
|
93
|
+
<InputNumber suffix="px" parser={(value) => {
|
|
94
|
+
var _a;
|
|
95
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
96
|
+
return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
|
|
97
|
+
}}/>
|
|
98
|
+
</Form.Item>)}
|
|
99
99
|
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
100
100
|
<InputNumber step={0.1} max={1} min={0} parser={(value) => {
|
|
101
101
|
if (value === undefined || value === null || value === "")
|
|
@@ -237,7 +237,7 @@ const boardSlice = createSlice({
|
|
|
237
237
|
setInitialValue: (state, action) => {
|
|
238
238
|
const { components, extraComponents, backgroundColor, boundingBox } = action.payload;
|
|
239
239
|
state.components = components;
|
|
240
|
-
state.extraComponents = extraComponents;
|
|
240
|
+
state.extraComponents = extraComponents === null || extraComponents === void 0 ? void 0 : extraComponents.filter((item) => item.shape);
|
|
241
241
|
state.pointer = 0;
|
|
242
242
|
state.backgroundColor = backgroundColor;
|
|
243
243
|
state.boundingBox = boundingBox;
|
|
@@ -79,6 +79,8 @@ const ControlPanels = (props) => {
|
|
|
79
79
|
rotation: getValueIfSame(selectedGroup, "rotation"),
|
|
80
80
|
strokeWidth: getValueIfSame(selectedGroup, "strokeWidth"),
|
|
81
81
|
radius: getValueIfSame(selectedGroup, "radius"),
|
|
82
|
+
shape: getValueIfSame(selectedGroup, "shape"),
|
|
83
|
+
labels: getValueIfSame(selectedGroup, "labels"),
|
|
82
84
|
});
|
|
83
85
|
const values = form.getFieldsValue();
|
|
84
86
|
}
|
|
@@ -92,11 +94,11 @@ const ControlPanels = (props) => {
|
|
|
92
94
|
}
|
|
93
95
|
}, [tool, show]);
|
|
94
96
|
const createShape = (shape, props = {}) => {
|
|
95
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
96
98
|
const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
|
|
97
|
-
return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape, height: (
|
|
98
|
-
? (
|
|
99
|
-
: undefined, text: shape === "text" ? (
|
|
99
|
+
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)
|
|
100
|
+
? (_f = props.seatFill) !== null && _f !== void 0 ? _f : "transparent"
|
|
101
|
+
: 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 });
|
|
100
102
|
};
|
|
101
103
|
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
102
104
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -172,8 +174,8 @@ const ControlPanels = (props) => {
|
|
|
172
174
|
debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
173
175
|
}
|
|
174
176
|
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
175
|
-
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, } = newValues;
|
|
176
|
-
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({}, 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 } : {}))));
|
|
177
|
+
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels } = 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(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 } : {}))));
|
|
177
179
|
let minX = Infinity;
|
|
178
180
|
let minY = Infinity;
|
|
179
181
|
let maxX = -Infinity;
|
|
@@ -1,49 +1,80 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
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";
|
|
3
6
|
const SelectedGroup = () => {
|
|
7
|
+
const shape = Form.useWatch("shape");
|
|
8
|
+
const sameShape = [
|
|
9
|
+
"table-seat-circle",
|
|
10
|
+
"table-seat-rect-circle",
|
|
11
|
+
"table-seat-square",
|
|
12
|
+
"table-seat-square",
|
|
13
|
+
"table-seat-rect-square",
|
|
14
|
+
].includes(shape);
|
|
4
15
|
return (<>
|
|
5
16
|
<div className="py-2">
|
|
6
17
|
<h1 className="heading-s"> Group Selection</h1>
|
|
7
18
|
<div className="py-2">
|
|
8
19
|
<Flex gap={2} className="w-full">
|
|
9
|
-
<Form.Item label="
|
|
10
|
-
<
|
|
11
|
-
</Form.Item>
|
|
12
|
-
<Form.Item label="Height" name="height" className="w-full">
|
|
13
|
-
<InputNumber suffix="px"/>
|
|
14
|
-
</Form.Item>
|
|
15
|
-
<Form.Item label="Radius" name={"radius"} className="w-full">
|
|
16
|
-
<InputNumber step={1} max={1} min={0}/>
|
|
17
|
-
</Form.Item>
|
|
18
|
-
</Flex>
|
|
19
|
-
<Flex gap={2}>
|
|
20
|
-
<Form.Item label="Position X" name="x" className="w-full">
|
|
21
|
-
<InputNumber />
|
|
22
|
-
</Form.Item>
|
|
23
|
-
<Form.Item label="Position Y" name="y" className="w-full">
|
|
24
|
-
<InputNumber />
|
|
25
|
-
</Form.Item>
|
|
26
|
-
<Form.Item label="Rotation" name="rotation" className="w-full">
|
|
27
|
-
<InputNumber max={360} min={0}/>
|
|
20
|
+
<Form.Item label="Name" name="shape" className="w-full">
|
|
21
|
+
<Select options={optionsShape} className="w-full"/>
|
|
28
22
|
</Form.Item>
|
|
29
23
|
</Flex>
|
|
30
|
-
<Flex gap={2}>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</Flex>
|
|
38
|
-
<Flex>
|
|
39
|
-
<Form.Item label="Stroke Width" name={"strokeWidth"} className="w-full">
|
|
40
|
-
<InputNumber />
|
|
41
|
-
</Form.Item>
|
|
42
|
-
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
43
|
-
<InputNumber step={0.1} max={1} min={0}/>
|
|
44
|
-
</Form.Item>
|
|
45
|
-
|
|
24
|
+
<Flex gap={2} className="w-full">
|
|
25
|
+
{["table-seat-circle", "table-seat-rect-circle"].includes(shape) && <SeatCircle />}
|
|
26
|
+
{[
|
|
27
|
+
"table-seat-square",
|
|
28
|
+
"table-seat-square",
|
|
29
|
+
"table-seat-rect-square",
|
|
30
|
+
].includes(shape) && <SeatSquare />}
|
|
46
31
|
</Flex>
|
|
32
|
+
{!sameShape && (<>
|
|
33
|
+
<Flex gap={2} className="w-full">
|
|
34
|
+
<Form.Item label="Width" name="width" className="w-full">
|
|
35
|
+
<InputNumber suffix="px"/>
|
|
36
|
+
</Form.Item>
|
|
37
|
+
<Form.Item label="Height" name="height" className="w-full">
|
|
38
|
+
<InputNumber suffix="px"/>
|
|
39
|
+
</Form.Item>
|
|
40
|
+
{!(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && (<Form.Item label="Radius" name={"radius"} className="w-full">
|
|
41
|
+
<InputNumber suffix="px" parser={(value) => {
|
|
42
|
+
var _a;
|
|
43
|
+
const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
|
|
44
|
+
return onlyNumber === ""
|
|
45
|
+
? 1
|
|
46
|
+
: Math.max(1, Number(onlyNumber));
|
|
47
|
+
}}/>
|
|
48
|
+
</Form.Item>)}
|
|
49
|
+
</Flex>
|
|
50
|
+
<Flex gap={2}>
|
|
51
|
+
<Form.Item label="Position X" name="x" className="w-full">
|
|
52
|
+
<InputNumber />
|
|
53
|
+
</Form.Item>
|
|
54
|
+
<Form.Item label="Position Y" name="y" className="w-full">
|
|
55
|
+
<InputNumber />
|
|
56
|
+
</Form.Item>
|
|
57
|
+
<Form.Item label="Rotation" name="rotation" className="w-full">
|
|
58
|
+
<InputNumber max={360} min={0}/>
|
|
59
|
+
</Form.Item>
|
|
60
|
+
</Flex>
|
|
61
|
+
<Flex gap={2}>
|
|
62
|
+
<Form.Item label="Fill" name={"fill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
63
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
64
|
+
</Form.Item>
|
|
65
|
+
<Form.Item label="Stroke" name={"stroke"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
66
|
+
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
67
|
+
</Form.Item>
|
|
68
|
+
</Flex>
|
|
69
|
+
<Flex>
|
|
70
|
+
<Form.Item label="Stroke Width" name={"strokeWidth"} className="w-full">
|
|
71
|
+
<InputNumber />
|
|
72
|
+
</Form.Item>
|
|
73
|
+
<Form.Item label="opacity" name={"opacity"} className="w-full">
|
|
74
|
+
<InputNumber step={0.1} max={1} min={0}/>
|
|
75
|
+
</Form.Item>
|
|
76
|
+
</Flex>
|
|
77
|
+
</>)}
|
|
47
78
|
</div>
|
|
48
79
|
</div>
|
|
49
80
|
</>);
|
|
@@ -19,9 +19,14 @@ const SeatCircle = () => {
|
|
|
19
19
|
<Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
20
20
|
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
21
21
|
</Form.Item>
|
|
22
|
-
<Form.Item
|
|
23
|
-
|
|
24
|
-
|
|
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> */}
|
|
25
30
|
</Flex>
|
|
26
31
|
<SectionShape />
|
|
27
32
|
<SectionLabel />
|
|
@@ -34,9 +34,14 @@ const SeatSquare = () => {
|
|
|
34
34
|
<Form.Item label="Seat Fill" name={"seatFill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
35
35
|
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
36
36
|
</Form.Item>
|
|
37
|
-
<Form.Item
|
|
38
|
-
|
|
39
|
-
|
|
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> */}
|
|
40
45
|
</Flex>
|
|
41
46
|
<SectionShape />
|
|
42
47
|
<SectionLabel />
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SEAT_SHAPES } from "../../utils/constant";
|
|
2
|
+
import { MIN_HEIGHT, MIN_WIDTH } from "../board-v3/constant";
|
|
2
3
|
export const isSeatShape = (shape) => SEAT_SHAPES.includes(shape);
|
|
3
4
|
export const getSeatCount = (shape, props) => {
|
|
4
5
|
// if (shape === "table-seat-circle") {
|
|
@@ -39,7 +40,8 @@ export const getSeatPosition = (shape, props) => {
|
|
|
39
40
|
export const adjustHeightWidthForSeatShape = (shape, props) => {
|
|
40
41
|
if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
|
|
41
42
|
const sizeDefault = Math.min(props.width, props.height);
|
|
42
|
-
|
|
43
|
+
const sizeFinal = sizeDefault < MIN_WIDTH ? MIN_WIDTH : sizeDefault;
|
|
44
|
+
return Object.assign(Object.assign({}, props), { height: isNaN(sizeFinal) ? MIN_WIDTH : sizeFinal, width: isNaN(sizeFinal) ? MIN_HEIGHT : sizeFinal });
|
|
43
45
|
}
|
|
44
46
|
return props;
|
|
45
47
|
};
|
|
@@ -23,7 +23,7 @@ const LayerView = (props) => {
|
|
|
23
23
|
const [panningGroup, setPanningGroup] = useState(false);
|
|
24
24
|
const [scale, setScale] = useState(1);
|
|
25
25
|
const [selectedTable, setSelectedTable] = useState(null);
|
|
26
|
-
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps } = useAppSelector((state) => state.board);
|
|
26
|
+
const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps, } = useAppSelector((state) => state.board);
|
|
27
27
|
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
28
28
|
const { loading } = useAppSelector((state) => state.panel);
|
|
29
29
|
useImperativeHandle(refs, () => ({
|
|
@@ -38,7 +38,7 @@ const LayerView = (props) => {
|
|
|
38
38
|
}));
|
|
39
39
|
const dispatch = useAppDispatch();
|
|
40
40
|
useEffect(() => {
|
|
41
|
-
if (
|
|
41
|
+
if (!loading && (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state)) {
|
|
42
42
|
dispatch({ type: "panel/setLoading", payload: true });
|
|
43
43
|
}
|
|
44
44
|
if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
|
|
@@ -563,7 +563,6 @@ const LayerView = (props) => {
|
|
|
563
563
|
touchAction: "none",
|
|
564
564
|
userSelect: "none",
|
|
565
565
|
}} {...props.svgProps}>
|
|
566
|
-
|
|
567
566
|
{hasBoundingBox && (<defs>
|
|
568
567
|
<clipPath id="contentCrop">
|
|
569
568
|
<rect x={boundingBox.minX} y={boundingBox.minY} width={boundingBox.width} height={boundingBox.height}/>
|