seat-editor 3.2.5 → 3.2.7
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/features/package/index.d.ts +1 -2
- package/dist/features/package/index.jsx +3 -2
- package/dist/features/panel/index.d.ts +2 -3
- package/dist/features/panel/index.jsx +4 -4
- package/dist/features/panel/select-tool.d.ts +2 -1
- package/dist/features/panel/select-tool.jsx +2 -2
- package/dist/features/panel/upload-tool.d.ts +3 -3
- package/dist/features/panel/upload-tool.jsx +18 -7
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RefsType } from "../board-v3";
|
|
2
2
|
import { PropertiesProps } from "@/dto/table";
|
|
3
|
-
import { UploadFile } from "antd";
|
|
4
3
|
export interface TableEditorProps {
|
|
5
4
|
componentProps: PropertiesProps[];
|
|
6
5
|
extraComponentProps: PropertiesProps[];
|
|
@@ -20,7 +19,7 @@ export interface TableEditorProps {
|
|
|
20
19
|
];
|
|
21
20
|
statusKey: string;
|
|
22
21
|
defaultBackground?: string;
|
|
23
|
-
action?: (file:
|
|
22
|
+
action?: (file: File) => Promise<string>;
|
|
24
23
|
responseMapping?: {
|
|
25
24
|
status: string;
|
|
26
25
|
message: string;
|
|
@@ -7,6 +7,7 @@ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
|
7
7
|
import { isEqual } from "lodash";
|
|
8
8
|
import LayerView from "../view-only";
|
|
9
9
|
const TableEditor = (props) => {
|
|
10
|
+
var _a;
|
|
10
11
|
const [initialValue, setInitialValue] = useState(null);
|
|
11
12
|
const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized, refs, } = props;
|
|
12
13
|
const { components, extraComponents, backgroundColor } = useAppSelector((state) => state.board);
|
|
@@ -29,7 +30,7 @@ const TableEditor = (props) => {
|
|
|
29
30
|
}
|
|
30
31
|
dispatch({
|
|
31
32
|
type: "tool/setActiveTool",
|
|
32
|
-
payload: ""
|
|
33
|
+
payload: "",
|
|
33
34
|
});
|
|
34
35
|
if (viewOnly) {
|
|
35
36
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -128,7 +129,7 @@ const TableEditor = (props) => {
|
|
|
128
129
|
</div>) : (<div key={`${viewOnly}`} className="w-full h-full flex relative">
|
|
129
130
|
<SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
|
|
130
131
|
<Board key={`${viewOnly}`} refs={refsBoard}/>
|
|
131
|
-
<ControlPanels action={props.action}/>
|
|
132
|
+
<ControlPanels action={props.action} transform={(_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef}/>
|
|
132
133
|
</div>)}
|
|
133
134
|
</div>
|
|
134
135
|
</>);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UploadFile } from "antd";
|
|
2
|
-
import { PropertiesProps } from "../../dto/table";
|
|
3
1
|
interface ControlPanelsProps {
|
|
4
|
-
action?: (file:
|
|
2
|
+
action?: (file: File) => Promise<string>;
|
|
3
|
+
transform?: any;
|
|
5
4
|
}
|
|
6
5
|
declare const ControlPanels: (props: ControlPanelsProps) => import("react").JSX.Element;
|
|
7
6
|
export default ControlPanels;
|
|
@@ -25,7 +25,7 @@ import { SEAT_SHAPES } from "../../utils/constant";
|
|
|
25
25
|
import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
|
|
26
26
|
import SeatSquare from "./table-seat-square";
|
|
27
27
|
const ControlPanels = (props) => {
|
|
28
|
-
const { action } = props;
|
|
28
|
+
const { action, transform } = props;
|
|
29
29
|
const dispatch = useAppDispatch();
|
|
30
30
|
const theme = useAppSelector((state) => state.theme);
|
|
31
31
|
const tool = useAppSelector((state) => state.tool);
|
|
@@ -216,7 +216,7 @@ const ControlPanels = (props) => {
|
|
|
216
216
|
const renderFormPanel = () => {
|
|
217
217
|
switch (tool.active) {
|
|
218
218
|
case "select":
|
|
219
|
-
return (<SelectToolForm action={action}/>);
|
|
219
|
+
return (<SelectToolForm action={action} tranform={transform}/>);
|
|
220
220
|
case "square":
|
|
221
221
|
case "circle":
|
|
222
222
|
return <SquareToolForm />;
|
|
@@ -225,9 +225,9 @@ const ControlPanels = (props) => {
|
|
|
225
225
|
case "table-seat-square":
|
|
226
226
|
return <SeatSquare />;
|
|
227
227
|
case "image-table":
|
|
228
|
-
return (<UploadTool name={tool.active} type="component" action={action}/>);
|
|
228
|
+
return (<UploadTool name={tool.active} type="component" action={action} transform={transform}/>);
|
|
229
229
|
case "background":
|
|
230
|
-
return (<UploadTool name={tool.active} type="background" action={action}/>);
|
|
230
|
+
return (<UploadTool name={tool.active} type="background" action={action} transform={transform}/>);
|
|
231
231
|
default:
|
|
232
232
|
return null;
|
|
233
233
|
}
|
|
@@ -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, tranform }) => {
|
|
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);
|
|
@@ -49,7 +49,7 @@ const SelectToolForm = ({ title = "Title", action }) => {
|
|
|
49
49
|
case "background":
|
|
50
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
|
-
: "component"}/>);
|
|
52
|
+
: "component"} transform={tranform}/>);
|
|
53
53
|
case "text":
|
|
54
54
|
return <TextTool />;
|
|
55
55
|
default:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { UploadFile } from "antd";
|
|
2
1
|
import { PropertiesProps } from "@/dto/table";
|
|
3
2
|
interface UploadToolProps {
|
|
4
3
|
name: string;
|
|
5
4
|
type?: "component" | "background" | "assets";
|
|
6
|
-
action?: (file:
|
|
5
|
+
action?: (file: File) => Promise<string>;
|
|
7
6
|
defaultValue?: PropertiesProps;
|
|
7
|
+
transform?: any;
|
|
8
8
|
}
|
|
9
|
-
declare const UploadTool: ({ name, type, action, defaultValue }: UploadToolProps) => import("react").JSX.Element;
|
|
9
|
+
declare const UploadTool: ({ name, type, action, defaultValue, transform }: UploadToolProps) => import("react").JSX.Element;
|
|
10
10
|
export default UploadTool;
|
|
@@ -15,8 +15,9 @@ 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, defaultValue }) => {
|
|
19
|
-
var _a, _b;
|
|
18
|
+
const UploadTool = ({ name, type, action, defaultValue, transform }) => {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
const transformState = (_a = transform === null || transform === void 0 ? void 0 : transform.instance) === null || _a === void 0 ? void 0 : _a.transformState;
|
|
20
21
|
const [defaultSrc, setDefaultSrc] = useState(null);
|
|
21
22
|
const [isEdit, setIsEdit] = useState(false);
|
|
22
23
|
const [loading, setLoading] = useState(false);
|
|
@@ -28,12 +29,12 @@ const UploadTool = ({ name, type, action, defaultValue }) => {
|
|
|
28
29
|
}
|
|
29
30
|
}, [defaultValue]);
|
|
30
31
|
const dispatch = useAppDispatch();
|
|
31
|
-
const widthWorkspace = ((
|
|
32
|
-
const heightWorkspace = ((
|
|
32
|
+
const widthWorkspace = ((_b = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _b === void 0 ? void 0 : _b.clientWidth) || 0;
|
|
33
|
+
const heightWorkspace = ((_c = document === null || document === void 0 ? void 0 : document.getElementById("workspace")) === null || _c === void 0 ? void 0 : _c.clientHeight) || 0;
|
|
33
34
|
const defaultFormatValue = (width, height, src, id) => ({
|
|
34
35
|
id: id || new Date().getTime(),
|
|
35
|
-
x: 0,
|
|
36
|
-
y: 0,
|
|
36
|
+
x: Math.abs(transformState === null || transformState === void 0 ? void 0 : transformState.positionX),
|
|
37
|
+
y: Math.abs(transformState === null || transformState === void 0 ? void 0 : transformState.positionY),
|
|
37
38
|
width: width < 1 ? 100 : width,
|
|
38
39
|
height: height < 1 ? 100 : height,
|
|
39
40
|
rotation: 0,
|
|
@@ -54,7 +55,7 @@ const UploadTool = ({ name, type, action, defaultValue }) => {
|
|
|
54
55
|
try {
|
|
55
56
|
// ⬇️ IF ada custom action (upload ke server)
|
|
56
57
|
if (action) {
|
|
57
|
-
const src = yield action(file
|
|
58
|
+
const src = yield action(file);
|
|
58
59
|
if (isEdit) {
|
|
59
60
|
dispatch({
|
|
60
61
|
type: "board/updateComponent",
|
|
@@ -68,6 +69,16 @@ const UploadTool = ({ name, type, action, defaultValue }) => {
|
|
|
68
69
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
69
70
|
dispatch({ type: "board/setUpdateBy", payload: "global" });
|
|
70
71
|
}
|
|
72
|
+
else {
|
|
73
|
+
dispatch({
|
|
74
|
+
type: "board/addComponent",
|
|
75
|
+
payload: Object.assign({}, defaultFormatValue(widthWorkspace, heightWorkspace, src)),
|
|
76
|
+
});
|
|
77
|
+
dispatch({
|
|
78
|
+
type: "panel/setSelectedComponent",
|
|
79
|
+
payload: Object.assign({}, defaultFormatValue(widthWorkspace, heightWorkspace, src)),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
71
82
|
}
|
|
72
83
|
// ⬇️ IF local upload
|
|
73
84
|
else {
|