seat-editor 3.2.3 → 3.2.5
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 +30 -0
- package/dist/app/constant.js +1388 -4
- package/dist/app/new-board/page.jsx +8 -7
- package/dist/components/layer-v3/index.jsx +5 -5
- package/dist/features/board-v3/board-slice.js +106 -9
- package/dist/features/board-v3/index.jsx +73 -25
- package/dist/features/package/index.d.ts +1 -1
- package/dist/features/package/index.jsx +28 -18
- package/dist/features/panel/index.d.ts +1 -7
- package/dist/features/panel/index.jsx +25 -12
- package/dist/features/panel/select-tool.d.ts +1 -2
- package/dist/features/panel/select-tool.jsx +2 -2
- package/dist/features/panel/upload-tool.d.ts +2 -8
- package/dist/features/panel/upload-tool.jsx +39 -18
- package/dist/features/panel/utils.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import SeatSquare from "./table-seat-square";
|
|
|
6
6
|
import UploadTool from "./upload-tool";
|
|
7
7
|
import TextTool from "./text-tool";
|
|
8
8
|
import SelectedGroup from "./selected-group";
|
|
9
|
-
const SelectToolForm = ({ title = "Title", action
|
|
9
|
+
const SelectToolForm = ({ title = "Title", action }) => {
|
|
10
10
|
const components = useAppSelector((state) => state.board.components);
|
|
11
11
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
12
12
|
const extraComponents = useAppSelector((state) => state.board.extraComponents);
|
|
@@ -47,7 +47,7 @@ const SelectToolForm = ({ title = "Title", action, responseMapping }) => {
|
|
|
47
47
|
return <SeatSquare />;
|
|
48
48
|
case "image-table":
|
|
49
49
|
case "background":
|
|
50
|
-
return (<UploadTool action={action}
|
|
50
|
+
return (<UploadTool action={action} name={selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape} defaultValue={selectedComponent} type={(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "background"
|
|
51
51
|
? "background"
|
|
52
52
|
: "component"}/>);
|
|
53
53
|
case "text":
|
|
@@ -3,14 +3,8 @@ import { PropertiesProps } from "@/dto/table";
|
|
|
3
3
|
interface UploadToolProps {
|
|
4
4
|
name: string;
|
|
5
5
|
type?: "component" | "background" | "assets";
|
|
6
|
-
action?: (file: UploadFile<File>, type: string, defaultValue: PropertiesProps) => Promise<
|
|
7
|
-
responseMapping?: {
|
|
8
|
-
status: string;
|
|
9
|
-
message: string;
|
|
10
|
-
data: string;
|
|
11
|
-
src: string;
|
|
12
|
-
};
|
|
6
|
+
action?: (file: UploadFile<File>, type: string, defaultValue: PropertiesProps) => Promise<string>;
|
|
13
7
|
defaultValue?: PropertiesProps;
|
|
14
8
|
}
|
|
15
|
-
declare const UploadTool: ({ name, type, action,
|
|
9
|
+
declare const UploadTool: ({ name, type, action, defaultValue }: UploadToolProps) => import("react").JSX.Element;
|
|
16
10
|
export default UploadTool;
|
|
@@ -10,19 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { useState, useEffect } from "react";
|
|
12
12
|
import { Upload, Image, Button } from "antd";
|
|
13
|
-
import { InboxOutlined } from "@ant-design/icons";
|
|
13
|
+
import { InboxOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
14
14
|
import { useAppDispatch } from "../../hooks/use-redux";
|
|
15
15
|
import SectionLabel from "../../components/form-tools/label";
|
|
16
16
|
import SectionShape from "../../components/form-tools/shape";
|
|
17
17
|
const { Dragger } = Upload;
|
|
18
|
-
const UploadTool = ({ name, type, action,
|
|
18
|
+
const UploadTool = ({ name, type, action, defaultValue }) => {
|
|
19
19
|
var _a, _b;
|
|
20
20
|
const [defaultSrc, setDefaultSrc] = useState(null);
|
|
21
21
|
const [isEdit, setIsEdit] = useState(false);
|
|
22
|
+
const [loading, setLoading] = useState(false);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
if (defaultValue) {
|
|
24
25
|
setDefaultSrc(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.src);
|
|
25
26
|
setIsEdit(true);
|
|
27
|
+
setLoading(false);
|
|
26
28
|
}
|
|
27
29
|
}, [defaultValue]);
|
|
28
30
|
const dispatch = useAppDispatch();
|
|
@@ -44,7 +46,7 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
44
46
|
maxCount: 1,
|
|
45
47
|
showUploadList: false,
|
|
46
48
|
onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
|
|
49
|
+
setLoading(true);
|
|
48
50
|
if (info.file) {
|
|
49
51
|
const file = info.file;
|
|
50
52
|
const img = new window.Image();
|
|
@@ -52,7 +54,20 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
52
54
|
try {
|
|
53
55
|
// ⬇️ IF ada custom action (upload ke server)
|
|
54
56
|
if (action) {
|
|
55
|
-
yield action(file, type, defaultValue);
|
|
57
|
+
const src = yield action(file, type, defaultValue);
|
|
58
|
+
if (isEdit) {
|
|
59
|
+
dispatch({
|
|
60
|
+
type: "board/updateComponent",
|
|
61
|
+
payload: Object.assign({}, defaultFormatValue(widthWorkspace, heightWorkspace, src, Number(defaultValue.id))),
|
|
62
|
+
});
|
|
63
|
+
dispatch({
|
|
64
|
+
type: "panel/setSelectedComponent",
|
|
65
|
+
payload: Object.assign({}, defaultFormatValue(widthWorkspace, heightWorkspace, src, Number(defaultValue.id))),
|
|
66
|
+
});
|
|
67
|
+
setDefaultSrc(src);
|
|
68
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
69
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
70
|
+
}
|
|
56
71
|
}
|
|
57
72
|
// ⬇️ IF local upload
|
|
58
73
|
else {
|
|
@@ -64,16 +79,16 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
64
79
|
const height = img.height * scale;
|
|
65
80
|
if (isEdit) {
|
|
66
81
|
dispatch({
|
|
67
|
-
type:
|
|
68
|
-
? "board/updateComponent"
|
|
69
|
-
: "board/updateExtraComponent",
|
|
82
|
+
type: "board/updateComponent",
|
|
70
83
|
payload: Object.assign({}, defaultFormatValue(width, height, img.src, Number(defaultValue.id))),
|
|
71
84
|
});
|
|
72
85
|
dispatch({
|
|
73
86
|
type: "panel/setSelectedComponent",
|
|
74
|
-
payload: Object.assign({}, defaultFormatValue(width, height, srcFromResponse, Number(defaultValue.id))),
|
|
87
|
+
payload: Object.assign({}, defaultFormatValue(width, height, srcFromResponse || img.src, Number(defaultValue.id))),
|
|
75
88
|
});
|
|
76
89
|
setDefaultSrc(img.src);
|
|
90
|
+
dispatch({ type: "board/setFlagChange", payload: true });
|
|
91
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
77
92
|
}
|
|
78
93
|
else {
|
|
79
94
|
dispatch({
|
|
@@ -83,7 +98,9 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
83
98
|
payload: Object.assign({}, defaultFormatValue(width, height, img.src)),
|
|
84
99
|
});
|
|
85
100
|
}
|
|
101
|
+
setDefaultSrc(img.src);
|
|
86
102
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
103
|
+
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
87
104
|
// message.success(`${info.file.name} uploaded successfully.`);
|
|
88
105
|
};
|
|
89
106
|
// Set img src AFTER onload
|
|
@@ -108,16 +125,20 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
108
125
|
Edit
|
|
109
126
|
</Button>
|
|
110
127
|
</>) : (<Dragger beforeUpload={() => false} {...propsUpload}>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
128
|
+
{loading ? (<div className="w-full flex flex-col items-center gap-2 max-h-[200px]">
|
|
129
|
+
<LoadingOutlined />
|
|
130
|
+
</div>) : (<>
|
|
131
|
+
<p className="ant-upload-drag-icon">
|
|
132
|
+
<InboxOutlined />
|
|
133
|
+
</p>
|
|
134
|
+
<p className="ant-upload-text">
|
|
135
|
+
Click or drag file to this area to upload
|
|
136
|
+
</p>
|
|
137
|
+
<p className="ant-upload-hint">
|
|
138
|
+
Support for a single or bulk upload. Strictly prohibited from
|
|
139
|
+
uploading company data or other banned files.
|
|
140
|
+
</p>
|
|
141
|
+
</>)}
|
|
121
142
|
</Dragger>)}
|
|
122
143
|
|
|
123
144
|
<SectionShape allowChangeShape={type === "component"}/>
|
|
@@ -37,7 +37,7 @@ export const getSeatPosition = (shape, props) => {
|
|
|
37
37
|
return (props === null || props === void 0 ? void 0 : props.seatPositions) || { top: 0, bottom: 0, left: 0, right: 0 };
|
|
38
38
|
};
|
|
39
39
|
export const adjustHeightWidthForSeatShape = (shape, props) => {
|
|
40
|
-
if (shape.includes("circle")) {
|
|
40
|
+
if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
|
|
41
41
|
const sizeDefault = Math.min(props.width, props.height);
|
|
42
42
|
return Object.assign(Object.assign({}, props), { height: sizeDefault, width: sizeDefault });
|
|
43
43
|
}
|