seat-editor 1.6.16 → 1.6.18
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/new-board/page.jsx +14 -1
- package/dist/features/board-v2/index.d.ts +2 -1
- package/dist/features/board-v2/index.jsx +3 -2
- package/dist/features/package/index.jsx +2 -2
- package/dist/features/panel/index.jsx +34 -10
- package/dist/features/side-tool/index.jsx +5 -4
- package/package.json +1 -1
- package/dist/app/new-board/page.js +0 -36
- package/dist/features/board-v2/index.js +0 -774
- package/dist/features/package/index.js +0 -104
- package/dist/features/panel/index.js +0 -106
- package/dist/features/side-tool/index.js +0 -304
|
@@ -5,6 +5,7 @@ import { constantData } from "../constant";
|
|
|
5
5
|
export default function NewBoard() {
|
|
6
6
|
const [initialValue, setInitialValue] = useState([]);
|
|
7
7
|
const [extraComponents, setExtraComponents] = useState([]);
|
|
8
|
+
const [backgroundColor, setBackgroundColor] = useState("#ffffff");
|
|
8
9
|
const [viewOnly, setViewOnly] = useState(true);
|
|
9
10
|
useEffect(() => {
|
|
10
11
|
setInitialValue(constantData);
|
|
@@ -16,6 +17,15 @@ export default function NewBoard() {
|
|
|
16
17
|
shape: "background",
|
|
17
18
|
width: 100,
|
|
18
19
|
height: 100,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
src: "https://d3l3j4e3k9p181.cloudfront.net/dev/5bf923de-2366-4a11-9b8b-e92de0afbf05/3a65cb36-7d85-4c38-9403-a15f94641920/68d45207-d66b-4bb5-92a2-4e5a87715e98/rsvp/1751350513582817819_download (10).jpg",
|
|
23
|
+
id: 1747388267451,
|
|
24
|
+
x: 100,
|
|
25
|
+
y: 100,
|
|
26
|
+
shape: "background",
|
|
27
|
+
width: 100,
|
|
28
|
+
height: 100,
|
|
19
29
|
}]);
|
|
20
30
|
}, []);
|
|
21
31
|
return (<>
|
|
@@ -43,10 +53,13 @@ export default function NewBoard() {
|
|
|
43
53
|
if (((_a = setState === null || setState === void 0 ? void 0 : setState.components) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
44
54
|
setInitialValue((_b = setState === null || setState === void 0 ? void 0 : setState.components) !== null && _b !== void 0 ? _b : []);
|
|
45
55
|
}
|
|
56
|
+
if (setState === null || setState === void 0 ? void 0 : setState.background) {
|
|
57
|
+
setBackgroundColor(setState === null || setState === void 0 ? void 0 : setState.backgroundColor);
|
|
58
|
+
}
|
|
46
59
|
if (((_c = setState === null || setState === void 0 ? void 0 : setState.extraComponents) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
47
60
|
setExtraComponents((_d = setState === null || setState === void 0 ? void 0 : setState.extraComponents) !== null && _d !== void 0 ? _d : []);
|
|
48
61
|
}
|
|
49
|
-
}} extraComponentProps={extraComponents} defaultBackground=
|
|
62
|
+
}} extraComponentProps={extraComponents} defaultBackground={backgroundColor}
|
|
50
63
|
// dragOnly={true}
|
|
51
64
|
statusKey="status"/>
|
|
52
65
|
</div>
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
interface BoardTemplateProps {
|
|
3
3
|
onSelectComponent?: (items: any) => void;
|
|
4
4
|
mappingKey?: string;
|
|
5
|
+
viewOnly?: boolean;
|
|
5
6
|
}
|
|
6
|
-
declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => React.JSX.Element;
|
|
7
|
+
declare const BoardTemplate: ({ onSelectComponent, viewOnly }: BoardTemplateProps) => React.JSX.Element;
|
|
7
8
|
export default BoardTemplate;
|
|
@@ -9,7 +9,8 @@ import LayerView from "../view";
|
|
|
9
9
|
import { isEqual, debounce } from "lodash";
|
|
10
10
|
import { ZoomIn, ZoomOut } from "lucide-react";
|
|
11
11
|
import { Button } from "antd";
|
|
12
|
-
const BoardTemplate = ({ onSelectComponent }) => {
|
|
12
|
+
const BoardTemplate = ({ onSelectComponent, viewOnly }) => {
|
|
13
|
+
var _a, _b;
|
|
13
14
|
const dispatch = useAppDispatch();
|
|
14
15
|
const theme = useAppSelector((state) => state.theme);
|
|
15
16
|
const transformRef = useRef(null);
|
|
@@ -451,7 +452,7 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
451
452
|
setWidthBoard(containerRef.current.offsetWidth);
|
|
452
453
|
setHeightBoard(containerRef.current.offsetHeight);
|
|
453
454
|
}
|
|
454
|
-
});
|
|
455
|
+
}, [(_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth, (_b = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight, viewOnly]);
|
|
455
456
|
const handleUnSelectComponent = () => {
|
|
456
457
|
dispatch({ type: "panel/setSelectedComponent", payload: null });
|
|
457
458
|
setSelectedComponent(null);
|
|
@@ -49,7 +49,7 @@ const TableEditor = (props) => {
|
|
|
49
49
|
};
|
|
50
50
|
useEffect(() => {
|
|
51
51
|
if (!isEqual(components, convertComponentProps()) ||
|
|
52
|
-
!isEqual(extraComponents, extraComponentProps)) {
|
|
52
|
+
!isEqual(extraComponents, extraComponentProps) || !isEqual(backgroundColor, props === null || props === void 0 ? void 0 : props.defaultBackground)) {
|
|
53
53
|
onCurrentStateChange && onUpdateCurrentState();
|
|
54
54
|
}
|
|
55
55
|
}, [components, extraComponents, backgroundColor]);
|
|
@@ -105,7 +105,7 @@ const TableEditor = (props) => {
|
|
|
105
105
|
display: viewOnly ? "none" : "flex",
|
|
106
106
|
}}>
|
|
107
107
|
<SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
|
|
108
|
-
<Board onSelectComponent={props.onSelectComponent}/>
|
|
108
|
+
<Board onSelectComponent={props.onSelectComponent} viewOnly={viewOnly}/>
|
|
109
109
|
<ControlPanels action={props.action} responseMapping={props.responseMapping}/>
|
|
110
110
|
</div>
|
|
111
111
|
</div>
|
|
@@ -10,13 +10,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
-
import { useEffect, useState } from "react";
|
|
13
|
+
import { useEffect, useRef, useState } from "react";
|
|
14
14
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
15
15
|
import { Form, Drawer, Input } from "antd";
|
|
16
16
|
import SelectToolForm from "./select-tool";
|
|
17
17
|
import SquareToolForm from "./square-circle-tool";
|
|
18
18
|
import SeatCircle from "./table-seat-circle";
|
|
19
19
|
import UploadTool from "./upload-tool";
|
|
20
|
+
import { debounce } from "lodash";
|
|
20
21
|
const ControlPanels = (props) => {
|
|
21
22
|
const { action, responseMapping } = props;
|
|
22
23
|
const dispatch = useAppDispatch();
|
|
@@ -56,20 +57,43 @@ const ControlPanels = (props) => {
|
|
|
56
57
|
? (_h = (_g = props === null || props === void 0 ? void 0 : props[0]) === null || _g === void 0 ? void 0 : _g.seatFill) !== null && _h !== void 0 ? _h : "#DADADA"
|
|
57
58
|
: undefined, text: shape === "text" ? (_k = (_j = props === null || props === void 0 ? void 0 : props[0]) === null || _j === void 0 ? void 0 : _j.text) !== null && _k !== void 0 ? _k : "Text" : undefined, fontColor: shape === "text" ? (_m = (_l = props === null || props === void 0 ? void 0 : props[0]) === null || _l === void 0 ? void 0 : _l.fontColor) !== null && _m !== void 0 ? _m : "#DADADA" : undefined }));
|
|
58
59
|
};
|
|
59
|
-
const
|
|
60
|
-
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
61
|
-
const newValues = createShape(shape, restProps);
|
|
60
|
+
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
62
61
|
dispatch({
|
|
63
62
|
type: "board/updateComponent",
|
|
64
|
-
payload:
|
|
63
|
+
payload: data,
|
|
64
|
+
});
|
|
65
|
+
}, 300));
|
|
66
|
+
const debouncedSyncSelectedComponents = useRef(debounce((data) => {
|
|
67
|
+
dispatch({
|
|
68
|
+
type: "panel/updateSelectedComponent",
|
|
69
|
+
payload: data,
|
|
65
70
|
});
|
|
71
|
+
}, 300));
|
|
72
|
+
const debouncedSyncForm = useRef(debounce(() => {
|
|
73
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
74
|
+
}, 300));
|
|
75
|
+
const handleChangeComponent = (values, allValues) => {
|
|
76
|
+
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
77
|
+
const newValues = createShape(shape, restProps);
|
|
78
|
+
debouncedSyncComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
79
|
+
// dispatch({
|
|
80
|
+
// type: "board/updateComponent",
|
|
81
|
+
// payload: {
|
|
82
|
+
// ...(selectedComponent || {}),
|
|
83
|
+
// ...newValues,
|
|
84
|
+
// },
|
|
85
|
+
// });
|
|
66
86
|
if (shape !== (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
debouncedSyncSelectedComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
88
|
+
// dispatch({
|
|
89
|
+
// type: "panel/updateSelectedComponent",
|
|
90
|
+
// payload: {
|
|
91
|
+
// ...(selectedComponent || {}),
|
|
92
|
+
// ...newValues,
|
|
93
|
+
// },
|
|
94
|
+
// });
|
|
71
95
|
}
|
|
72
|
-
|
|
96
|
+
debouncedSyncForm.current();
|
|
73
97
|
};
|
|
74
98
|
const renderFormPanel = () => {
|
|
75
99
|
switch (tool.active) {
|
|
@@ -146,21 +146,22 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
|
|
|
146
146
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
147
147
|
};
|
|
148
148
|
const handleRemoveComponent = () => {
|
|
149
|
-
|
|
149
|
+
const exludedShapes = ["background", "text"];
|
|
150
|
+
if (!exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) && !(deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component)) {
|
|
150
151
|
message.error("You are not authorized to delete this table.");
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
|
-
if ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)
|
|
154
|
+
if (exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) && !(deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent)) {
|
|
154
155
|
message.error("You are not authorized to delete this background.");
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
|
-
if (deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component) {
|
|
158
|
+
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.component) && !exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
158
159
|
dispatch({
|
|
159
160
|
type: "board/removeComponent",
|
|
160
161
|
payload: selectedComponent,
|
|
161
162
|
});
|
|
162
163
|
}
|
|
163
|
-
if (deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent) {
|
|
164
|
+
if ((deleteAutorized === null || deleteAutorized === void 0 ? void 0 : deleteAutorized.extraComponent) && exludedShapes.includes(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
164
165
|
dispatch({
|
|
165
166
|
type: "board/removeExtraComponent",
|
|
166
167
|
payload: selectedComponent,
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import SeatEditor from "../../features/package";
|
|
5
|
-
import { constantData } from "../constant";
|
|
6
|
-
export default function NewBoard() {
|
|
7
|
-
const [initialValue, setInitialValue] = useState([]);
|
|
8
|
-
const [extraComponents, setExtraComponents] = useState([]);
|
|
9
|
-
const [viewOnly, setViewOnly] = useState(true);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
setInitialValue(constantData);
|
|
12
|
-
setExtraComponents([{
|
|
13
|
-
src: "https://d3l3j4e3k9p181.cloudfront.net/dev/5bf923de-2366-4a11-9b8b-e92de0afbf05/3a65cb36-7d85-4c38-9403-a15f94641920/68d45207-d66b-4bb5-92a2-4e5a87715e98/rsvp/1751350513582817819_download (10).jpg",
|
|
14
|
-
id: 1747388267450,
|
|
15
|
-
x: 0,
|
|
16
|
-
y: 0,
|
|
17
|
-
shape: "background",
|
|
18
|
-
width: 100,
|
|
19
|
-
height: 100,
|
|
20
|
-
}]);
|
|
21
|
-
}, []);
|
|
22
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { className: "w-full h-screen flex flex-col relative justify-center", children: [_jsx("button", { className: "bg-blue-500 text-white px-4 py-2 rounded", onClick: () => setViewOnly(!viewOnly), children: viewOnly ? "Edit Mode" : "View Mode" }), _jsx("div", { className: "flex-1 h-full", children: _jsx(SeatEditor, { componentProps: initialValue, viewOnly: viewOnly, dragOnly: true, deleteAutorized: {
|
|
23
|
-
component: true,
|
|
24
|
-
extraComponent: true,
|
|
25
|
-
}, mappingKey: "properties", onCurrentStateChange: (setState) => {
|
|
26
|
-
var _a, _b, _c, _d;
|
|
27
|
-
if (((_a = setState === null || setState === void 0 ? void 0 : setState.components) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
28
|
-
setInitialValue((_b = setState === null || setState === void 0 ? void 0 : setState.components) !== null && _b !== void 0 ? _b : []);
|
|
29
|
-
}
|
|
30
|
-
if (((_c = setState === null || setState === void 0 ? void 0 : setState.extraComponents) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
31
|
-
setExtraComponents((_d = setState === null || setState === void 0 ? void 0 : setState.extraComponents) !== null && _d !== void 0 ? _d : []);
|
|
32
|
-
}
|
|
33
|
-
}, extraComponentProps: extraComponents, defaultBackground: "#ffffff",
|
|
34
|
-
// dragOnly={true}
|
|
35
|
-
statusKey: "status" }) })] }) }));
|
|
36
|
-
}
|