seat-editor 2.0.0 → 2.1.1
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/package.json +1 -1
- package/dist/app/constant.d.ts +0 -101
- package/dist/app/constant.js +0 -3064
- package/dist/app/layout.d.ts +0 -6
- package/dist/app/layout.jsx +0 -27
- package/dist/app/new-board/page.d.ts +0 -1
- package/dist/app/new-board/page.jsx +0 -56
- package/dist/app/old-board/page.d.ts +0 -3
- package/dist/app/old-board/page.jsx +0 -510
- package/dist/app/only-view/constant.d.ts +0 -40
- package/dist/app/only-view/constant.js +0 -1336
- package/dist/app/only-view/page.d.ts +0 -2
- package/dist/app/only-view/page.jsx +0 -40
- package/dist/app/page.d.ts +0 -2
- package/dist/app/page.jsx +0 -13
- package/dist/app/test/page.d.ts +0 -2
- package/dist/app/test/page.jsx +0 -45
- package/dist/app/v2/page.d.ts +0 -2
- package/dist/app/v2/page.jsx +0 -13
- package/dist/components/button-tools/index.d.ts +0 -11
- package/dist/components/button-tools/index.jsx +0 -17
- package/dist/components/form-tools/label.d.ts +0 -2
- package/dist/components/form-tools/label.jsx +0 -44
- package/dist/components/form-tools/shape.d.ts +0 -4
- package/dist/components/form-tools/shape.jsx +0 -66
- package/dist/components/input/number-indicator.d.ts +0 -7
- package/dist/components/input/number-indicator.jsx +0 -36
- package/dist/components/joystick/index.d.ts +0 -12
- package/dist/components/joystick/index.jsx +0 -49
- package/dist/components/layer/index.d.ts +0 -19
- package/dist/components/layer/index.jsx +0 -383
- package/dist/components/layer-v2/index.d.ts +0 -19
- package/dist/components/layer-v2/index.jsx +0 -370
- package/dist/components/layer-v3/index.d.ts +0 -19
- package/dist/components/layer-v3/index.jsx +0 -418
- package/dist/components/lib/index.d.ts +0 -8
- package/dist/components/lib/index.jsx +0 -33
- package/dist/components/modal-preview/index.d.ts +0 -4
- package/dist/components/modal-preview/index.jsx +0 -11
- package/dist/features/board/board-slice.d.ts +0 -14
- package/dist/features/board/board-slice.js +0 -52
- package/dist/features/board/index.d.ts +0 -6
- package/dist/features/board/index.jsx +0 -725
- package/dist/features/board-v2/board-slice.d.ts +0 -14
- package/dist/features/board-v2/board-slice.js +0 -52
- package/dist/features/board-v2/index.d.ts +0 -8
- package/dist/features/board-v2/index.jsx +0 -869
- package/dist/features/board-v3/board-slice.d.ts +0 -16
- package/dist/features/board-v3/board-slice.js +0 -83
- package/dist/features/board-v3/history-slice.d.ts +0 -27
- package/dist/features/board-v3/history-slice.js +0 -27
- package/dist/features/board-v3/index.d.ts +0 -8
- package/dist/features/board-v3/index.jsx +0 -863
- package/dist/features/navbar/index.d.ts +0 -2
- package/dist/features/navbar/index.jsx +0 -5
- package/dist/features/package/index.d.ts +0 -31
- package/dist/features/package/index.jsx +0 -114
- package/dist/features/panel/index.d.ts +0 -11
- package/dist/features/panel/index.jsx +0 -138
- package/dist/features/panel/panel-slice.d.ts +0 -16
- package/dist/features/panel/panel-slice.js +0 -31
- package/dist/features/panel/select-tool.d.ts +0 -6
- package/dist/features/panel/select-tool.jsx +0 -60
- package/dist/features/panel/square-circle-tool.d.ts +0 -2
- package/dist/features/panel/square-circle-tool.jsx +0 -10
- package/dist/features/panel/table-seat-circle.d.ts +0 -2
- package/dist/features/panel/table-seat-circle.jsx +0 -31
- package/dist/features/panel/text-tool.d.ts +0 -2
- package/dist/features/panel/text-tool.jsx +0 -26
- package/dist/features/panel/upload-tool.d.ts +0 -14
- package/dist/features/panel/upload-tool.jsx +0 -152
- package/dist/features/side-tool/index.d.ts +0 -8
- package/dist/features/side-tool/index.jsx +0 -371
- package/dist/features/side-tool/side-tool-slice.d.ts +0 -16
- package/dist/features/side-tool/side-tool-slice.js +0 -28
- package/dist/features/theme/theme-slice.d.ts +0 -12
- package/dist/features/theme/theme-slice.js +0 -15
- package/dist/features/view/index.d.ts +0 -19
- package/dist/features/view/index.jsx +0 -228
- package/dist/features/view-only/index.d.ts +0 -19
- package/dist/features/view-only/index.jsx +0 -206
- package/dist/features/view-only-2/index.d.ts +0 -19
- package/dist/features/view-only-2/index.jsx +0 -181
- package/dist/hooks/use-redux.d.ts +0 -4
- package/dist/hooks/use-redux.js +0 -3
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/libs/middleware.d.ts +0 -2
- package/dist/libs/middleware.js +0 -5
- package/dist/libs/rootReducer.d.ts +0 -12
- package/dist/libs/rootReducer.js +0 -14
- package/dist/libs/store.d.ts +0 -18
- package/dist/libs/store.js +0 -19
- package/dist/provider/antd-provider.d.ts +0 -4
- package/dist/provider/antd-provider.jsx +0 -46
- package/dist/provider/redux-provider.d.ts +0 -3
- package/dist/provider/redux-provider.jsx +0 -6
- package/dist/provider/store-provider.d.ts +0 -4
- package/dist/provider/store-provider.jsx +0 -10
- package/dist/utils/injectCss.d.ts +0 -1
- package/dist/utils/injectCss.js +0 -13
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface TableEditorProps {
|
|
2
|
-
componentProps: any[];
|
|
3
|
-
extraComponentProps: any[];
|
|
4
|
-
onCurrentStateChange: (state: any) => void;
|
|
5
|
-
onSelectComponent?: (component: any) => void;
|
|
6
|
-
mappingKey?: string;
|
|
7
|
-
selectedTableColor?: string;
|
|
8
|
-
colorMatchKey?: [
|
|
9
|
-
{
|
|
10
|
-
color: string;
|
|
11
|
-
key: string;
|
|
12
|
-
}
|
|
13
|
-
];
|
|
14
|
-
statusKey: string;
|
|
15
|
-
defaultBackground?: string;
|
|
16
|
-
action?: (file: File, type: string, defaultValue: any) => Promise<any>;
|
|
17
|
-
responseMapping?: {
|
|
18
|
-
status: string;
|
|
19
|
-
message: string;
|
|
20
|
-
data: string;
|
|
21
|
-
src: string;
|
|
22
|
-
};
|
|
23
|
-
dragOnly?: boolean;
|
|
24
|
-
viewOnly?: boolean;
|
|
25
|
-
deleteAutorized?: {
|
|
26
|
-
component: boolean;
|
|
27
|
-
extraComponent: boolean;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
declare const TableEditor: (props: TableEditorProps) => import("react").JSX.Element;
|
|
31
|
-
export default TableEditor;
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import Board from "../board-v3";
|
|
4
|
-
import SideTool from "../side-tool";
|
|
5
|
-
import ControlPanels from "../panel";
|
|
6
|
-
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
7
|
-
import { isEqual } from "lodash";
|
|
8
|
-
import LayerView from "../view";
|
|
9
|
-
const TableEditor = (props) => {
|
|
10
|
-
const [initialValue, setInitialValue] = useState(null);
|
|
11
|
-
const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized } = props;
|
|
12
|
-
const { components, extraComponents, backgroundColor } = useAppSelector((state) => state.board);
|
|
13
|
-
const dispatch = useAppDispatch();
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!viewOnly) {
|
|
16
|
-
dispatch({
|
|
17
|
-
type: "panel/setSelectedComponent",
|
|
18
|
-
payload: null,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}, [viewOnly]);
|
|
22
|
-
const onUpdateCurrentState = () => {
|
|
23
|
-
let matchInitialValueWithComponents = initialValue === null || initialValue === void 0 ? void 0 : initialValue.map((item) => {
|
|
24
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
25
|
-
let findComponent = components === null || components === void 0 ? void 0 : components.find((c) => { var _a; return c.id === ((_a = item === null || item === void 0 ? void 0 : item[mappingKey]) === null || _a === void 0 ? void 0 : _a.id); });
|
|
26
|
-
if (!findComponent)
|
|
27
|
-
return undefined;
|
|
28
|
-
if (findComponent) {
|
|
29
|
-
return Object.assign(Object.assign({}, item), { [mappingKey]: Object.assign({}, findComponent) });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
let findComponent = components === null || components === void 0 ? void 0 : components.find((c) => c.id === (item === null || item === void 0 ? void 0 : item.id));
|
|
34
|
-
if (!findComponent)
|
|
35
|
-
return undefined;
|
|
36
|
-
if (findComponent) {
|
|
37
|
-
return Object.assign(Object.assign({}, item), findComponent);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
const hasUndefined = matchInitialValueWithComponents === null || matchInitialValueWithComponents === void 0 ? void 0 : matchInitialValueWithComponents.some((item) => item === undefined);
|
|
42
|
-
if (!hasUndefined && !viewOnly) {
|
|
43
|
-
onCurrentStateChange({
|
|
44
|
-
components: matchInitialValueWithComponents,
|
|
45
|
-
extraComponents,
|
|
46
|
-
background: backgroundColor,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (!isEqual(components, convertComponentProps()) ||
|
|
52
|
-
!isEqual(extraComponents, extraComponentProps) || !isEqual(backgroundColor, props === null || props === void 0 ? void 0 : props.defaultBackground)) {
|
|
53
|
-
onCurrentStateChange && onUpdateCurrentState();
|
|
54
|
-
}
|
|
55
|
-
}, [components, extraComponents, backgroundColor]);
|
|
56
|
-
const convertComponentProps = () => {
|
|
57
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
58
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
59
|
-
return Object.assign({}, item === null || item === void 0 ? void 0 : item[mappingKey]);
|
|
60
|
-
}
|
|
61
|
-
return item;
|
|
62
|
-
});
|
|
63
|
-
return mappingData;
|
|
64
|
-
};
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (!isEqual(components, convertComponentProps()) && componentProps) {
|
|
67
|
-
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
68
|
-
if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
|
|
69
|
-
return Object.assign({}, item[props.mappingKey]);
|
|
70
|
-
}
|
|
71
|
-
return item;
|
|
72
|
-
});
|
|
73
|
-
if (mappingKey) {
|
|
74
|
-
setInitialValue(componentProps);
|
|
75
|
-
}
|
|
76
|
-
dispatch({
|
|
77
|
-
type: "board/setNewComponents",
|
|
78
|
-
payload: mappingData,
|
|
79
|
-
});
|
|
80
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
81
|
-
}
|
|
82
|
-
if (!isEqual(extraComponents, extraComponentProps) && extraComponentProps) {
|
|
83
|
-
dispatch({
|
|
84
|
-
type: "board/setNewExtraComponents",
|
|
85
|
-
payload: extraComponentProps,
|
|
86
|
-
});
|
|
87
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
88
|
-
}
|
|
89
|
-
if (props === null || props === void 0 ? void 0 : props.defaultBackground) {
|
|
90
|
-
dispatch({
|
|
91
|
-
type: "board/setBackgroundColor",
|
|
92
|
-
payload: props === null || props === void 0 ? void 0 : props.defaultBackground,
|
|
93
|
-
});
|
|
94
|
-
dispatch({ type: "board/setFlagChange", payload: true });
|
|
95
|
-
}
|
|
96
|
-
}, [componentProps, extraComponentProps, props === null || props === void 0 ? void 0 : props.defaultBackground]);
|
|
97
|
-
return (<>
|
|
98
|
-
<div className="w-full h-screen flex relative">
|
|
99
|
-
<div className="w-full h-full flex relative" style={{
|
|
100
|
-
display: !viewOnly ? "none" : "flex",
|
|
101
|
-
}}>
|
|
102
|
-
<LayerView statusKey="status"/>
|
|
103
|
-
</div>
|
|
104
|
-
<div className="w-full h-full flex relative" style={{
|
|
105
|
-
display: viewOnly ? "none" : "flex",
|
|
106
|
-
}}>
|
|
107
|
-
<SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
|
|
108
|
-
<Board onSelectComponent={props.onSelectComponent} viewOnly={viewOnly}/>
|
|
109
|
-
<ControlPanels action={props.action} responseMapping={props.responseMapping}/>
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</>);
|
|
113
|
-
};
|
|
114
|
-
export default TableEditor;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface ControlPanelsProps {
|
|
2
|
-
action?: (file: File, type: string, defaultValue: any) => Promise<any>;
|
|
3
|
-
responseMapping?: {
|
|
4
|
-
status: string;
|
|
5
|
-
message: string;
|
|
6
|
-
data: string;
|
|
7
|
-
src: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
declare const ControlPanels: (props: ControlPanelsProps) => import("react").JSX.Element;
|
|
11
|
-
export default ControlPanels;
|
|
@@ -1,138 +0,0 @@
|
|
|
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, Drawer, 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
|
-
const ControlPanels = (props) => {
|
|
22
|
-
const { action, responseMapping } = props;
|
|
23
|
-
const dispatch = useAppDispatch();
|
|
24
|
-
const theme = useAppSelector((state) => state.theme);
|
|
25
|
-
const tool = useAppSelector((state) => state.tool);
|
|
26
|
-
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
27
|
-
const { show } = useAppSelector((state) => state.panel);
|
|
28
|
-
const [open, setOpen] = useState(false);
|
|
29
|
-
const [form] = Form.useForm();
|
|
30
|
-
let values = Form.useWatch([], form);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
form.resetFields();
|
|
33
|
-
if (selectedComponent) {
|
|
34
|
-
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);
|
|
35
|
-
const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
|
|
36
|
-
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height) === (values === null || values === void 0 ? void 0 : values.height) &&
|
|
37
|
-
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.width) === (values === null || values === void 0 ? void 0 : values.width) &&
|
|
38
|
-
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x) === (values === null || values === void 0 ? void 0 : values.x) &&
|
|
39
|
-
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y) === (values === null || values === void 0 ? void 0 : values.y);
|
|
40
|
-
if (show && (isDifferentId || isSameIdAndSameDimensions)) {
|
|
41
|
-
setOpen(true);
|
|
42
|
-
}
|
|
43
|
-
form.setFieldsValue(selectedComponent);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
setOpen(false);
|
|
47
|
-
}
|
|
48
|
-
}, [selectedComponent]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (tool.active === "background" || tool.active === "image-table") {
|
|
51
|
-
setOpen(true);
|
|
52
|
-
}
|
|
53
|
-
}, [tool]);
|
|
54
|
-
const createShape = (shape, ...props) => {
|
|
55
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
56
|
-
return (Object.assign(Object.assign({}, props === null || props === void 0 ? void 0 : props[0]), { shape, fill: (_b = (_a = props === null || props === void 0 ? void 0 : props[0]) === null || _a === void 0 ? void 0 : _a.fill) !== null && _b !== void 0 ? _b : theme === null || theme === void 0 ? void 0 : theme.primaryColor, seatCount: shape === "table-seat-circle" ? (_d = (_c = props === null || props === void 0 ? void 0 : props[0]) === null || _c === void 0 ? void 0 : _c.seatCount) !== null && _d !== void 0 ? _d : 6 : 0, openSpace: shape === "table-seat-circle" ? (_f = (_e = props === null || props === void 0 ? void 0 : props[0]) === null || _e === void 0 ? void 0 : _e.openSpace) !== null && _f !== void 0 ? _f : 0 : undefined, seatFill: shape === "table-seat-circle"
|
|
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"
|
|
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 }));
|
|
59
|
-
};
|
|
60
|
-
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
61
|
-
dispatch({
|
|
62
|
-
type: "board/updateComponent",
|
|
63
|
-
payload: data,
|
|
64
|
-
});
|
|
65
|
-
}, 300));
|
|
66
|
-
const debouncedSyncSelectedComponents = useRef(debounce((data) => {
|
|
67
|
-
dispatch({
|
|
68
|
-
type: "panel/updateSelectedComponent",
|
|
69
|
-
payload: data,
|
|
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
|
-
// });
|
|
86
|
-
if (shape !== (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape)) {
|
|
87
|
-
debouncedSyncSelectedComponents.current(Object.assign(Object.assign({}, (selectedComponent || {})), newValues));
|
|
88
|
-
// dispatch({
|
|
89
|
-
// type: "panel/updateSelectedComponent",
|
|
90
|
-
// payload: {
|
|
91
|
-
// ...(selectedComponent || {}),
|
|
92
|
-
// ...newValues,
|
|
93
|
-
// },
|
|
94
|
-
// });
|
|
95
|
-
}
|
|
96
|
-
debouncedSyncForm.current();
|
|
97
|
-
};
|
|
98
|
-
const renderFormPanel = () => {
|
|
99
|
-
switch (tool.active) {
|
|
100
|
-
case "select":
|
|
101
|
-
return (<SelectToolForm action={action} responseMapping={responseMapping}/>);
|
|
102
|
-
case "square":
|
|
103
|
-
case "circle":
|
|
104
|
-
return <SquareToolForm />;
|
|
105
|
-
case "table-seat-circle":
|
|
106
|
-
return <SeatCircle />;
|
|
107
|
-
case "image-table":
|
|
108
|
-
return (<UploadTool name={tool.active} type="component" action={action} responseMapping={responseMapping}/>);
|
|
109
|
-
case "background":
|
|
110
|
-
return (<UploadTool name={tool.active} type="background" action={action} responseMapping={responseMapping}/>);
|
|
111
|
-
default:
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const handleClose = () => {
|
|
116
|
-
setOpen(false);
|
|
117
|
-
dispatch({
|
|
118
|
-
type: "panel/setShow",
|
|
119
|
-
payload: false,
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
// if(!show) return null
|
|
123
|
-
return (<Drawer open={show} onClose={handleClose} title="Panel" styles={{
|
|
124
|
-
body: {
|
|
125
|
-
paddingBottom: 0,
|
|
126
|
-
},
|
|
127
|
-
}}>
|
|
128
|
-
<div className="bg-white h-full max-h-screen w-full p-2">
|
|
129
|
-
<Form layout="vertical" form={form} name="table" onValuesChange={handleChangeComponent} initialValues={{ labels: [{}] }}>
|
|
130
|
-
<Form.Item name="id" hidden>
|
|
131
|
-
<Input />
|
|
132
|
-
</Form.Item>
|
|
133
|
-
{renderFormPanel()}
|
|
134
|
-
</Form>
|
|
135
|
-
</div>
|
|
136
|
-
</Drawer>);
|
|
137
|
-
};
|
|
138
|
-
export default ControlPanels;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
-
export interface PanelState {
|
|
3
|
-
selectedComponent: any;
|
|
4
|
-
history: 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
|
-
history: [],
|
|
5
|
-
active: "",
|
|
6
|
-
show: false,
|
|
7
|
-
};
|
|
8
|
-
export const panelSlice = createSlice({
|
|
9
|
-
name: "panel",
|
|
10
|
-
initialState,
|
|
11
|
-
reducers: {
|
|
12
|
-
setSelectedComponent: (state, action) => {
|
|
13
|
-
state.selectedComponent = action.payload;
|
|
14
|
-
},
|
|
15
|
-
setUnSelectedComponent: (state) => {
|
|
16
|
-
state.selectedComponent = null;
|
|
17
|
-
},
|
|
18
|
-
updateSelectedComponent: (state, action) => {
|
|
19
|
-
state.selectedComponent = Object.assign({}, action.payload);
|
|
20
|
-
state.history.push(state.selectedComponent);
|
|
21
|
-
if (state.history.length > 20) {
|
|
22
|
-
state.history.shift();
|
|
23
|
-
}
|
|
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,60 +0,0 @@
|
|
|
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 UploadTool from "./upload-tool";
|
|
6
|
-
import TextTool from "./text-tool";
|
|
7
|
-
const SelectToolForm = ({ title = "Title", action, responseMapping }) => {
|
|
8
|
-
const components = useAppSelector((state) => state.board.components);
|
|
9
|
-
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
10
|
-
const extraComponents = useAppSelector((state) => state.board.extraComponents);
|
|
11
|
-
const SummaryComponents = () => {
|
|
12
|
-
const countByShape = components === null || components === void 0 ? void 0 : components.reduce((acc, item) => {
|
|
13
|
-
acc[item.shape] = (acc[item.shape] || 0) + 1;
|
|
14
|
-
return acc;
|
|
15
|
-
}, {});
|
|
16
|
-
const extraCountByShape = extraComponents === null || extraComponents === void 0 ? void 0 : extraComponents.reduce((acc, item) => {
|
|
17
|
-
acc[item.shape] = (acc[item.shape] || 0) + 1;
|
|
18
|
-
return acc;
|
|
19
|
-
}, {});
|
|
20
|
-
const variableFormatToString = (variable) => {
|
|
21
|
-
return variable
|
|
22
|
-
.replace(/-/g, " ")
|
|
23
|
-
.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
24
|
-
};
|
|
25
|
-
return (<div className="flex flex-col">
|
|
26
|
-
<h1 className="heading-s">{title}</h1>
|
|
27
|
-
<div className="flex flex-col gap-2 mt-5">
|
|
28
|
-
{Object.entries(countByShape).map(([shape, count]) => (<div key={shape}>
|
|
29
|
-
<span className="font-bold">
|
|
30
|
-
{variableFormatToString(shape)}:
|
|
31
|
-
</span>{" "}
|
|
32
|
-
{count}
|
|
33
|
-
</div>))}
|
|
34
|
-
</div>
|
|
35
|
-
</div>);
|
|
36
|
-
};
|
|
37
|
-
const renderComponent = () => {
|
|
38
|
-
switch (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) {
|
|
39
|
-
case "square":
|
|
40
|
-
case "circle":
|
|
41
|
-
return <SquareToolForm />;
|
|
42
|
-
case "table-seat-circle":
|
|
43
|
-
return <SeatCircle />;
|
|
44
|
-
case "image-table":
|
|
45
|
-
case "background":
|
|
46
|
-
return (<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"
|
|
47
|
-
? "background"
|
|
48
|
-
: "component"}/>);
|
|
49
|
-
case "text":
|
|
50
|
-
return <TextTool />;
|
|
51
|
-
default:
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return (<div className="flex flex-col gap-2">
|
|
56
|
-
<SummaryComponents />
|
|
57
|
-
{renderComponent()}
|
|
58
|
-
</div>);
|
|
59
|
-
};
|
|
60
|
-
export default SelectToolForm;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
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 label="Table Fill" name={"fill"} getValueFromEvent={(color) => color.toHexString()} className="w-full ">
|
|
23
|
-
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
24
|
-
</Form.Item>
|
|
25
|
-
</Flex>
|
|
26
|
-
<SectionShape />
|
|
27
|
-
<SectionLabel />
|
|
28
|
-
</div>
|
|
29
|
-
</>);
|
|
30
|
-
};
|
|
31
|
-
export default SeatCircle;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { ColorPicker, Form, Input, InputNumber } from "antd";
|
|
3
|
-
const TextTool = () => {
|
|
4
|
-
return (<div className="py-2">
|
|
5
|
-
<Form.Item label="Name" name="shape" className="w-full hidden">
|
|
6
|
-
<Input defaultValue={"text"}/>
|
|
7
|
-
</Form.Item>
|
|
8
|
-
|
|
9
|
-
<Form.Item name="text" label="Text">
|
|
10
|
-
<Input />
|
|
11
|
-
</Form.Item>
|
|
12
|
-
<Form.Item name={"fontColor"} label="Color" getValueFromEvent={(color) => color.toHexString()}>
|
|
13
|
-
<ColorPicker allowClear format="hex" defaultFormat="hex"/>
|
|
14
|
-
</Form.Item>
|
|
15
|
-
<Form.Item name={"x"} label="X">
|
|
16
|
-
<InputNumber />
|
|
17
|
-
</Form.Item>
|
|
18
|
-
<Form.Item name={"y"} label="Y">
|
|
19
|
-
<InputNumber />
|
|
20
|
-
</Form.Item>
|
|
21
|
-
<Form.Item name={"fontSize"} label="Size">
|
|
22
|
-
<InputNumber suffix="px"/>
|
|
23
|
-
</Form.Item>
|
|
24
|
-
</div>);
|
|
25
|
-
};
|
|
26
|
-
export default TextTool;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
interface UploadToolProps {
|
|
2
|
-
name: string;
|
|
3
|
-
type?: "component" | "background";
|
|
4
|
-
action?: (file: File, type: string, defaultValue: any) => Promise<any>;
|
|
5
|
-
responseMapping?: {
|
|
6
|
-
status: string;
|
|
7
|
-
message: string;
|
|
8
|
-
data: string;
|
|
9
|
-
src: string;
|
|
10
|
-
};
|
|
11
|
-
defaultValue?: any;
|
|
12
|
-
}
|
|
13
|
-
declare const UploadTool: ({ name, type, action, responseMapping, defaultValue, }: UploadToolProps) => import("react").JSX.Element;
|
|
14
|
-
export default UploadTool;
|