seat-editor 1.5.6 → 1.6.0
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/layout.d.ts +1 -1
- package/dist/app/new-board/page.d.ts +1 -1
- package/dist/app/new-board/page.jsx +21 -17
- package/dist/app/old-board/page.d.ts +2 -1
- package/dist/app/only-view/page.d.ts +1 -1
- package/dist/app/page.d.ts +1 -1
- package/dist/components/button-tools/index.d.ts +1 -1
- package/dist/components/form-tools/label.d.ts +1 -1
- package/dist/components/form-tools/shape.d.ts +1 -1
- package/dist/components/input/number-indicator.d.ts +1 -1
- package/dist/components/joystick/index.d.ts +2 -1
- package/dist/components/layer/index.d.ts +1 -1
- package/dist/components/layer/index.jsx +29 -9
- package/dist/components/lib/index.d.ts +1 -1
- package/dist/components/modal-preview/index.d.ts +1 -1
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/board/index.jsx +44 -8
- package/dist/features/navbar/index.d.ts +1 -1
- package/dist/features/package/index.d.ts +1 -1
- package/dist/features/package/index.jsx +11 -2
- package/dist/features/panel/index.d.ts +1 -1
- package/dist/features/panel/index.jsx +7 -2
- package/dist/features/panel/select-tool.d.ts +1 -1
- package/dist/features/panel/square-circle-tool.d.ts +1 -1
- package/dist/features/panel/table-seat-circle.d.ts +1 -1
- package/dist/features/panel/text-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.jsx +10 -11
- package/dist/features/side-tool/index.d.ts +1 -1
- package/dist/features/side-tool/index.jsx +7 -2
- package/dist/features/view/index.d.ts +1 -1
- package/dist/features/view-only/index.d.ts +1 -1
- package/dist/provider/redux-provider.d.ts +1 -1
- package/dist/provider/store-provider.d.ts +1 -1
- package/dist/seat-editor.css +1 -1
- package/package.json +1 -1
- package/dist/app/layout.js +0 -22
- package/dist/app/new-board/page.js +0 -31
- package/dist/app/old-board/page.js +0 -377
- package/dist/app/only-view/page.js +0 -41
- package/dist/app/page.js +0 -8
- package/dist/components/button-tools/index.js +0 -11
- package/dist/components/form-tools/label.js +0 -7
- package/dist/components/form-tools/shape.js +0 -25
- package/dist/components/input/number-indicator.js +0 -27
- package/dist/components/joystick/index.js +0 -48
- package/dist/components/layer/index.js +0 -278
- package/dist/components/lib/index.js +0 -28
- package/dist/components/modal-preview/index.js +0 -10
- package/dist/features/board/index.js +0 -650
- package/dist/features/navbar/index.js +0 -6
- package/dist/features/package/index.js +0 -95
- package/dist/features/panel/index.js +0 -97
- package/dist/features/panel/select-tool.js +0 -48
- package/dist/features/panel/square-circle-tool.js +0 -8
- package/dist/features/panel/table-seat-circle.js +0 -9
- package/dist/features/panel/text-tool.js +0 -7
- package/dist/features/panel/upload-tool.js +0 -147
- package/dist/features/side-tool/index.js +0 -244
- package/dist/features/view/index.js +0 -219
- package/dist/features/view-only/index.js +0 -197
- package/dist/provider/antd-provider.js +0 -43
- package/dist/provider/redux-provider.js +0 -7
- package/dist/provider/store-provider.js +0 -9
package/dist/app/layout.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function NewBoard(): import("react
|
|
1
|
+
export default function NewBoard(): import("react").JSX.Element;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
import { useEffect, useState } from "react";
|
|
12
3
|
import SeatEditor from "../../features/package";
|
|
13
4
|
import { constantData } from "../constant";
|
|
14
5
|
export default function NewBoard() {
|
|
15
6
|
const [initialValue, setInitialValue] = useState([]);
|
|
7
|
+
const [extraComponents, setExtraComponents] = useState([]);
|
|
16
8
|
const [viewOnly, setViewOnly] = useState(true);
|
|
17
|
-
console.log("constantData", constantData);
|
|
9
|
+
console.log("constantData", constantData, initialValue);
|
|
18
10
|
useEffect(() => {
|
|
19
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
|
+
}]);
|
|
20
21
|
}, []);
|
|
21
22
|
return (<>
|
|
22
23
|
<div className="w-full h-screen flex flex-col relative justify-center">
|
|
@@ -35,15 +36,18 @@ export default function NewBoard() {
|
|
|
35
36
|
{viewOnly ? "Edit Mode" : "View Mode"}
|
|
36
37
|
</button>
|
|
37
38
|
<div className="flex-1 h-full">
|
|
38
|
-
<SeatEditor componentProps={initialValue} viewOnly={viewOnly} mappingKey="properties" onCurrentStateChange={(setState) => {
|
|
39
|
-
var _a;
|
|
39
|
+
<SeatEditor componentProps={initialValue} viewOnly={viewOnly} dragOnly mappingKey="properties" onCurrentStateChange={(setState) => {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
40
41
|
console.log("setState", setState);
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
if (((_a = setState === null || setState === void 0 ? void 0 : setState.components) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
43
|
+
setInitialValue((_b = setState === null || setState === void 0 ? void 0 : setState.components) !== null && _b !== void 0 ? _b : []);
|
|
44
|
+
}
|
|
45
|
+
if (((_c = setState === null || setState === void 0 ? void 0 : setState.extraComponents) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
46
|
+
setExtraComponents((_d = setState === null || setState === void 0 ? void 0 : setState.extraComponents) !== null && _d !== void 0 ? _d : []);
|
|
47
|
+
}
|
|
48
|
+
}} extraComponentProps={extraComponents} defaultBackground="#ffffff"
|
|
43
49
|
// dragOnly={true}
|
|
44
|
-
statusKey="status"
|
|
45
|
-
console.log("action", action);
|
|
46
|
-
})}/>
|
|
50
|
+
statusKey="status"/>
|
|
47
51
|
</div>
|
|
48
52
|
|
|
49
53
|
</div>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const TouchScrollDetect: () => import("react
|
|
1
|
+
declare const TouchScrollDetect: () => import("react").JSX.Element;
|
|
2
2
|
export default TouchScrollDetect;
|
package/dist/app/page.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const TableEditor: () => import("react
|
|
1
|
+
declare const TableEditor: () => import("react").JSX.Element;
|
|
2
2
|
export default TableEditor;
|
|
@@ -7,5 +7,5 @@ interface ButtonToolsProps {
|
|
|
7
7
|
}>;
|
|
8
8
|
popoverProps?: PopoverProps;
|
|
9
9
|
}
|
|
10
|
-
declare const ButtonTools: (props: ButtonToolsProps) => import("react
|
|
10
|
+
declare const ButtonTools: (props: ButtonToolsProps) => import("react").JSX.Element;
|
|
11
11
|
export default ButtonTools;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const SectionLabel: () => import("react
|
|
1
|
+
declare const SectionLabel: () => import("react").JSX.Element;
|
|
2
2
|
export default SectionLabel;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const SectionShape: () => import("react
|
|
1
|
+
declare const SectionShape: () => import("react").JSX.Element;
|
|
2
2
|
export default SectionShape;
|
|
@@ -3,5 +3,5 @@ interface NumberIndicatorProps {
|
|
|
3
3
|
defaultValue?: number;
|
|
4
4
|
onChange: (value: number) => void;
|
|
5
5
|
}
|
|
6
|
-
declare const NumberIndicator: ({ name, defaultValue, onChange }: NumberIndicatorProps) => import("react
|
|
6
|
+
declare const NumberIndicator: ({ name, defaultValue, onChange }: NumberIndicatorProps) => import("react").JSX.Element;
|
|
7
7
|
export default NumberIndicator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
type JoystickPosition = {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
@@ -7,5 +8,5 @@ type JoystickProps = {
|
|
|
7
8
|
onMove?: (pos: JoystickPosition) => void;
|
|
8
9
|
onEnd?: () => void;
|
|
9
10
|
};
|
|
10
|
-
export declare const Joystick: ({ size, onMove, onEnd, }: JoystickProps) =>
|
|
11
|
+
export declare const Joystick: ({ size, onMove, onEnd, }: JoystickProps) => React.JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -15,5 +15,5 @@ interface LayersProps {
|
|
|
15
15
|
onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
|
|
16
16
|
onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
|
|
17
17
|
}
|
|
18
|
-
declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchEnd, onTouchMove, onTouchStart }: LayersProps) => import("react
|
|
18
|
+
declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchEnd, onTouchMove, onTouchStart }: LayersProps) => import("react").JSX.Element;
|
|
19
19
|
export default Layers;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useRef } from "react";
|
|
2
3
|
import { omit } from "lodash";
|
|
3
4
|
const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style, onTouchEnd, onTouchMove, onTouchStart }) => {
|
|
5
|
+
const refItemTemp = useRef(null);
|
|
6
|
+
const handleOnHover = (item) => {
|
|
7
|
+
if (mode === "edit") {
|
|
8
|
+
refItemTemp.current = item;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
4
11
|
const renderShadowShape = (item) => {
|
|
5
12
|
const { id, x, y, width, height, fill, opacity, rotation, shape, fontColor, text, seatFill, labels, } = item;
|
|
6
13
|
const commonProps = { fill, opacity };
|
|
@@ -70,26 +77,37 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
70
77
|
</g>);
|
|
71
78
|
}
|
|
72
79
|
case "text":
|
|
73
|
-
return (<g key={id} onClick={() =>
|
|
80
|
+
return (<g key={id} onClick={() => {
|
|
81
|
+
onClick && onClick(item);
|
|
82
|
+
}}>
|
|
74
83
|
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity}/>
|
|
75
84
|
<text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={height * 0.6} opacity={opacity}>
|
|
76
85
|
{text}
|
|
77
86
|
</text>
|
|
87
|
+
</g>);
|
|
88
|
+
case "ruler":
|
|
89
|
+
return (<g key={id}>
|
|
90
|
+
<rect x={x - (window.innerWidth * 3) / 2} y={y} width={window.innerWidth * 3} height={1} fill="black"/>
|
|
91
|
+
<rect x={x} y={y - (window.innerHeight * 3) / 2} width={1} height={window.innerHeight * 3} fill="black"/>
|
|
92
|
+
|
|
78
93
|
</g>);
|
|
79
94
|
default:
|
|
80
95
|
return null;
|
|
81
96
|
}
|
|
82
97
|
};
|
|
83
98
|
const renderShape = (item) => {
|
|
84
|
-
const { id, x, y, width, height, fill, opacity, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, } = item;
|
|
99
|
+
const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, } = item;
|
|
85
100
|
const commonProps = {
|
|
86
101
|
fill,
|
|
87
102
|
opacity,
|
|
88
103
|
stroke,
|
|
89
104
|
strokeWidth,
|
|
90
105
|
onMouseDown: (e) => {
|
|
106
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, item || refItemTemp.current);
|
|
107
|
+
},
|
|
108
|
+
onMouseEnter: (e) => {
|
|
91
109
|
// e.stopPropagation();
|
|
92
|
-
|
|
110
|
+
handleOnHover === null || handleOnHover === void 0 ? void 0 : handleOnHover(item);
|
|
93
111
|
},
|
|
94
112
|
onClick: (e) => {
|
|
95
113
|
// e.stopPropagation();
|
|
@@ -126,9 +144,9 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
126
144
|
<rect key={id} x={x} y={y} width={width} height={height} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} {...omit(commonProps, "opacity")} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}/>
|
|
127
145
|
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
128
146
|
var _a, _b, _c, _d;
|
|
129
|
-
return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
|
|
147
|
+
return (<text {...omit(commonProps, ["opacity", "stroke", "strokeWidth"])} key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
|
|
130
148
|
e.stopPropagation();
|
|
131
|
-
onClick(item);
|
|
149
|
+
onClick && onClick(item);
|
|
132
150
|
}}>
|
|
133
151
|
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
134
152
|
</text>);
|
|
@@ -141,7 +159,7 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
141
159
|
var _a, _b, _c, _d;
|
|
142
160
|
return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
|
|
143
161
|
e.stopPropagation();
|
|
144
|
-
onClick(item);
|
|
162
|
+
onClick && onClick(item);
|
|
145
163
|
}}>
|
|
146
164
|
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
147
165
|
</text>);
|
|
@@ -177,7 +195,7 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
177
195
|
var _a, _b, _c, _d;
|
|
178
196
|
return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
|
|
179
197
|
e.stopPropagation();
|
|
180
|
-
onClick(item);
|
|
198
|
+
onClick && onClick(item);
|
|
181
199
|
}}>
|
|
182
200
|
{_ === null || _ === void 0 ? void 0 : _.label}
|
|
183
201
|
</text>);
|
|
@@ -221,7 +239,7 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
221
239
|
return (<g key={id}>
|
|
222
240
|
<rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity} onClick={(e) => {
|
|
223
241
|
e.stopPropagation();
|
|
224
|
-
onClick(item);
|
|
242
|
+
onClick && onClick(item);
|
|
225
243
|
}}/>
|
|
226
244
|
<text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
|
|
227
245
|
{text}
|
|
@@ -229,7 +247,9 @@ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedT
|
|
|
229
247
|
</g>);
|
|
230
248
|
case "image-table":
|
|
231
249
|
case "background":
|
|
232
|
-
return (<g key={id} onClick={() =>
|
|
250
|
+
return (<g key={id} onClick={() => {
|
|
251
|
+
onClick && onClick(item);
|
|
252
|
+
}}>
|
|
233
253
|
<image href={src} x={x} y={y} width={width} height={height} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} {...commonProps}/>
|
|
234
254
|
{labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
|
|
235
255
|
var _a, _b, _c, _d;
|
|
@@ -3,6 +3,6 @@ export interface LayerViewProps {
|
|
|
3
3
|
componentProps: any[];
|
|
4
4
|
extraComponentProps: any[];
|
|
5
5
|
}
|
|
6
|
-
declare const TableEditor: ({ componentProps, extraComponentProps, }: LayerViewProps) => import("react
|
|
6
|
+
declare const TableEditor: ({ componentProps, extraComponentProps, }: LayerViewProps) => import("react").JSX.Element;
|
|
7
7
|
export default TableEditor;
|
|
8
8
|
export { LayerView };
|
|
@@ -2,5 +2,5 @@ interface BoardTemplateProps {
|
|
|
2
2
|
onSelectComponent?: (items: any) => void;
|
|
3
3
|
mappingKey?: string;
|
|
4
4
|
}
|
|
5
|
-
declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => import("react
|
|
5
|
+
declare const BoardTemplate: ({ onSelectComponent }: BoardTemplateProps) => import("react").JSX.Element;
|
|
6
6
|
export default BoardTemplate;
|
|
@@ -25,6 +25,12 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
25
25
|
const activeTool = useAppSelector((state) => state.tool.active);
|
|
26
26
|
const { components: componentsProps, extraComponents: extraComponentsProps, flagChange, } = useAppSelector((state) => state.board);
|
|
27
27
|
const isTouching = useRef(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (activeTool !== ((_a = shadowShape[0]) === null || _a === void 0 ? void 0 : _a.shape)) {
|
|
31
|
+
setShadowShape([]);
|
|
32
|
+
}
|
|
33
|
+
}, [activeTool]);
|
|
28
34
|
// const [isDragging, setIsDragging] = useState(false);
|
|
29
35
|
const [resizeDirection, setResizeDirection] = useState(null);
|
|
30
36
|
const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
|
|
@@ -82,7 +88,8 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
82
88
|
isSyncingFromRedux.current = false;
|
|
83
89
|
return;
|
|
84
90
|
}
|
|
85
|
-
if (!isEqual(componentsState, componentsProps) &&
|
|
91
|
+
if (!isEqual(componentsState, componentsProps) &&
|
|
92
|
+
!isEqual(componentsState, [])) {
|
|
86
93
|
debouncedSyncComponents.current(componentsState);
|
|
87
94
|
}
|
|
88
95
|
if (!isEqual(extraComponentsState, extraComponentsProps)) {
|
|
@@ -140,7 +147,7 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
140
147
|
const dx = Math.abs(event.clientX - startPos.current.x);
|
|
141
148
|
const dy = Math.abs(event.clientY - startPos.current.y);
|
|
142
149
|
if (dx > 1 || dy > 1) {
|
|
143
|
-
if (!moveComponent.current) {
|
|
150
|
+
if (!moveComponent.current && item) {
|
|
144
151
|
dispatch({ type: "panel/setSelectedComponent", payload: item });
|
|
145
152
|
setSelectedComponent(item);
|
|
146
153
|
}
|
|
@@ -157,9 +164,11 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
157
164
|
isDragging.current = true;
|
|
158
165
|
moveComponent.current = false;
|
|
159
166
|
setResizeDirection(direction);
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
if (item) {
|
|
168
|
+
dispatch({ type: "panel/setSelectedComponent", payload: item });
|
|
169
|
+
dispatch({ type: "panel/setShow", payload: true });
|
|
170
|
+
setSelectedComponent(item);
|
|
171
|
+
}
|
|
163
172
|
}
|
|
164
173
|
};
|
|
165
174
|
// Pasang ke `document` agar global
|
|
@@ -231,6 +240,7 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
231
240
|
"table-seat-circle",
|
|
232
241
|
"table-seat-square",
|
|
233
242
|
"text",
|
|
243
|
+
"ruler",
|
|
234
244
|
].includes(activeTool)) {
|
|
235
245
|
const { x, y } = getSvgCoords(e);
|
|
236
246
|
setShadowShape([createShape(x, y, theme === null || theme === void 0 ? void 0 : theme.primaryColor)]);
|
|
@@ -390,7 +400,7 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
390
400
|
};
|
|
391
401
|
const handleTouchStart = (e, items, direction) => {
|
|
392
402
|
var _a, _b, _c, _d;
|
|
393
|
-
if (activeTool === "select" && !direction) {
|
|
403
|
+
if (activeTool === "select" && !direction && items) {
|
|
394
404
|
// dispatch({ type: "panel/setShow", payload: false });
|
|
395
405
|
// setMoveComponent(true);
|
|
396
406
|
moveComponent.current = true;
|
|
@@ -589,6 +599,9 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
589
599
|
else if (activeTool === "grab") {
|
|
590
600
|
return "grab";
|
|
591
601
|
}
|
|
602
|
+
else if (activeTool === "ruler") {
|
|
603
|
+
return "crosshair";
|
|
604
|
+
}
|
|
592
605
|
};
|
|
593
606
|
const renderMiniMap = () => {
|
|
594
607
|
return (<MiniMap width={250} height={250}>
|
|
@@ -642,8 +655,6 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
642
655
|
<Button icon={<ZoomOut />} onClick={handleZoomOut}/>
|
|
643
656
|
</div>
|
|
644
657
|
</div>
|
|
645
|
-
{moveComponent.current && (<h1>Move Component</h1>)}
|
|
646
|
-
|
|
647
658
|
<TransformWrapper ref={transformRef} panning={{ disabled: activeTool === "select" }} centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} // sangat kecil = bisa zoom out jauh
|
|
648
659
|
maxScale={1000} initialScale={1} pinch={{ step: 1 }} smooth={true} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding>
|
|
649
660
|
{scale > 1 && (<div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10">
|
|
@@ -663,6 +674,7 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
663
674
|
}} onMouseLeave={handleMouseLeave} xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
|
|
664
675
|
background: backgroundColor,
|
|
665
676
|
display: "block",
|
|
677
|
+
cursor: activeTool === "ruler" ? "crosshair" : "auto",
|
|
666
678
|
}}>
|
|
667
679
|
<Layers shadowShape={shadowShape} components={[...extraComponentsState, ...componentsState]} style={{
|
|
668
680
|
cursor: getCursorStyle(),
|
|
@@ -671,6 +683,30 @@ const BoardTemplate = ({ onSelectComponent }) => {
|
|
|
671
683
|
onMouseDown={handleMouseDown}
|
|
672
684
|
// onMouseUp={handleMouseUp}
|
|
673
685
|
onBlur={handleUnSelectComponent} selectedComponent={selectedComponent} activeTool={activeTool} onTouchStart={(e, item, direction) => handleTouchStart(e, item, direction)} onTouchMove={(e) => handleTouchMove(e)} onTouchEnd={handleTouchEnd}/>
|
|
686
|
+
{activeTool === "ruler" && (<>
|
|
687
|
+
<g id="horizontal-ruler">
|
|
688
|
+
<rect x="0" y="0" width={window.innerWidth} height="30" fill="#e0e0e0"/>
|
|
689
|
+
<g stroke="#888" font-size="10" text-anchor="middle">
|
|
690
|
+
{Array.from({ length: window.innerWidth / 50 }, (_, i) => (<g key={i}>
|
|
691
|
+
<line x1={i * 50} y1="0" x2={i * 50} y2="10"/>
|
|
692
|
+
<text x={i * 50} y="15">
|
|
693
|
+
{i * 50}
|
|
694
|
+
</text>
|
|
695
|
+
</g>))}
|
|
696
|
+
</g>
|
|
697
|
+
</g>
|
|
698
|
+
<g id="vertical-ruler">
|
|
699
|
+
<rect x="0" y="0" width="30" height={window.innerHeight} fill="#e0e0e0"/>
|
|
700
|
+
<g stroke="#888" font-size="10" text-anchor="middle">
|
|
701
|
+
{Array.from({ length: window.innerHeight / 10 }, (_, i) => (<g key={i}>
|
|
702
|
+
<line x1="0" y1={i * 50} x2="10" y2={i * 50}/>
|
|
703
|
+
<text x="15" y={i * 50}>
|
|
704
|
+
{i * 50}
|
|
705
|
+
</text>
|
|
706
|
+
</g>))}
|
|
707
|
+
</g>
|
|
708
|
+
</g>
|
|
709
|
+
</>)}
|
|
674
710
|
</svg>
|
|
675
711
|
</TransformComponent>
|
|
676
712
|
</TransformWrapper>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const Navbar: () => import("react
|
|
1
|
+
declare const Navbar: () => import("react").JSX.Element;
|
|
2
2
|
export default Navbar;
|
|
@@ -23,5 +23,5 @@ export interface TableEditorProps {
|
|
|
23
23
|
dragOnly?: boolean;
|
|
24
24
|
viewOnly?: boolean;
|
|
25
25
|
}
|
|
26
|
-
declare const TableEditor: (props: TableEditorProps) => import("react
|
|
26
|
+
declare const TableEditor: (props: TableEditorProps) => import("react").JSX.Element;
|
|
27
27
|
export default TableEditor;
|
|
@@ -9,8 +9,16 @@ import LayerView from "../view";
|
|
|
9
9
|
const TableEditor = (props) => {
|
|
10
10
|
const [initialValue, setInitialValue] = useState(null);
|
|
11
11
|
const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, } = props;
|
|
12
|
-
const { components, extraComponents } = useAppSelector((state) => state.board);
|
|
12
|
+
const { components, extraComponents, backgroundColor } = useAppSelector((state) => state.board);
|
|
13
13
|
const dispatch = useAppDispatch();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!viewOnly) {
|
|
16
|
+
dispatch({
|
|
17
|
+
type: "panel/setSelectedComponent",
|
|
18
|
+
payload: null,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}, [viewOnly]);
|
|
14
22
|
const onUpdateCurrentState = () => {
|
|
15
23
|
let matchInitialValueWithComponents = initialValue === null || initialValue === void 0 ? void 0 : initialValue.map((item) => {
|
|
16
24
|
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
@@ -35,6 +43,7 @@ const TableEditor = (props) => {
|
|
|
35
43
|
onCurrentStateChange({
|
|
36
44
|
components: matchInitialValueWithComponents,
|
|
37
45
|
extraComponents,
|
|
46
|
+
background: backgroundColor,
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
};
|
|
@@ -43,7 +52,7 @@ const TableEditor = (props) => {
|
|
|
43
52
|
!isEqual(extraComponents, extraComponentProps)) {
|
|
44
53
|
onCurrentStateChange && onUpdateCurrentState();
|
|
45
54
|
}
|
|
46
|
-
}, [components, extraComponents]);
|
|
55
|
+
}, [components, extraComponents, backgroundColor]);
|
|
47
56
|
const convertComponentProps = () => {
|
|
48
57
|
let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
|
|
49
58
|
if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
|
|
@@ -7,5 +7,5 @@ interface ControlPanelsProps {
|
|
|
7
7
|
src: string;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
declare const ControlPanels: (props: ControlPanelsProps) => import("react
|
|
10
|
+
declare const ControlPanels: (props: ControlPanelsProps) => import("react").JSX.Element;
|
|
11
11
|
export default ControlPanels;
|
|
@@ -28,6 +28,7 @@ const ControlPanels = (props) => {
|
|
|
28
28
|
const [form] = Form.useForm();
|
|
29
29
|
let values = Form.useWatch([], form);
|
|
30
30
|
useEffect(() => {
|
|
31
|
+
form.resetFields();
|
|
31
32
|
if (selectedComponent) {
|
|
32
33
|
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);
|
|
33
34
|
const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
|
|
@@ -91,8 +92,12 @@ const ControlPanels = (props) => {
|
|
|
91
92
|
});
|
|
92
93
|
};
|
|
93
94
|
// if(!show) return null
|
|
94
|
-
return (<Drawer open={show} onClose={handleClose} title="Panel"
|
|
95
|
-
|
|
95
|
+
return (<Drawer open={show} onClose={handleClose} title="Panel" styles={{
|
|
96
|
+
body: {
|
|
97
|
+
paddingBottom: 0
|
|
98
|
+
}
|
|
99
|
+
}}>
|
|
100
|
+
<div className="bg-white h-full max-h-screen w-full p-2">
|
|
96
101
|
<Form layout="vertical" form={form} name="table" onFinish={(values) => { }} onValuesChange={handleChangeComponent} initialValues={{ labels: [{}] }}>
|
|
97
102
|
<Form.Item name="id" hidden>
|
|
98
103
|
<Input />
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const SquareToolForm: () => import("react
|
|
1
|
+
declare const SquareToolForm: () => import("react").JSX.Element;
|
|
2
2
|
export default SquareToolForm;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const SeatCircle: () => import("react
|
|
1
|
+
declare const SeatCircle: () => import("react").JSX.Element;
|
|
2
2
|
export default SeatCircle;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const TextTool: () => import("react
|
|
1
|
+
declare const TextTool: () => import("react").JSX.Element;
|
|
2
2
|
export default TextTool;
|
|
@@ -10,5 +10,5 @@ interface UploadToolProps {
|
|
|
10
10
|
};
|
|
11
11
|
defaultValue?: any;
|
|
12
12
|
}
|
|
13
|
-
declare const UploadTool: ({ name, type, action, responseMapping, defaultValue, }: UploadToolProps) => import("react
|
|
13
|
+
declare const UploadTool: ({ name, type, action, responseMapping, defaultValue, }: UploadToolProps) => import("react").JSX.Element;
|
|
14
14
|
export default UploadTool;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
import { useState, useEffect } from "react";
|
|
12
|
-
import { Upload,
|
|
12
|
+
import { Upload, Image, Button } from "antd";
|
|
13
13
|
import { InboxOutlined } from "@ant-design/icons";
|
|
14
14
|
import { useAppDispatch } from "../../hooks/use-redux";
|
|
15
15
|
import SectionLabel from "../../components/form-tools/label";
|
|
@@ -40,13 +40,13 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
40
40
|
id: id || new Date().getTime(),
|
|
41
41
|
x: 0,
|
|
42
42
|
y: 0,
|
|
43
|
-
width,
|
|
44
|
-
height,
|
|
43
|
+
width: width < 1 ? 100 : width,
|
|
44
|
+
height: height < 1 ? 100 : height,
|
|
45
45
|
rotation: 0,
|
|
46
46
|
shape: name,
|
|
47
47
|
src,
|
|
48
48
|
});
|
|
49
|
-
const
|
|
49
|
+
const propsUpload = {
|
|
50
50
|
name: "file",
|
|
51
51
|
multiple: true,
|
|
52
52
|
maxCount: 1,
|
|
@@ -61,7 +61,7 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
61
61
|
// ⬇️ IF ada custom action (upload ke server)
|
|
62
62
|
if (action) {
|
|
63
63
|
const res = yield action(file);
|
|
64
|
-
srcFromResponse =
|
|
64
|
+
srcFromResponse = URL.createObjectURL(file);
|
|
65
65
|
img.onload = () => {
|
|
66
66
|
const scaleX = widthWorkspace / img.width;
|
|
67
67
|
const scaleY = heightWorkspace / img.height;
|
|
@@ -90,10 +90,10 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
93
|
-
message.success(`${info.file.name} uploaded successfully.`);
|
|
93
|
+
// message.success(`${info.file.name} uploaded successfully.`);
|
|
94
94
|
};
|
|
95
95
|
// Set img src AFTER onload
|
|
96
|
-
img.src =
|
|
96
|
+
img.src = URL.createObjectURL(file);
|
|
97
97
|
}
|
|
98
98
|
// ⬇️ IF local upload
|
|
99
99
|
else {
|
|
@@ -125,15 +125,14 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
128
|
-
message.success(`${info.file.name} uploaded successfully.`);
|
|
128
|
+
// message.success(`${info.file.name} uploaded successfully.`);
|
|
129
129
|
};
|
|
130
130
|
// Set img src AFTER onload
|
|
131
131
|
img.src = URL.createObjectURL(file);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
catch (e) {
|
|
135
|
-
|
|
136
|
-
message.error("Upload failed, please try again.");
|
|
135
|
+
// message.error("Upload failed, please try again.");
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
}),
|
|
@@ -149,7 +148,7 @@ const UploadTool = ({ name, type, action, responseMapping, defaultValue, }) => {
|
|
|
149
148
|
<Button type="primary" onClick={handleDelete}>
|
|
150
149
|
Edit
|
|
151
150
|
</Button>
|
|
152
|
-
</>) : (<Dragger {...
|
|
151
|
+
</>) : (<Dragger {...propsUpload} action={""}>
|
|
153
152
|
<p className="ant-upload-drag-icon">
|
|
154
153
|
<InboxOutlined />
|
|
155
154
|
</p>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers } from "lucide-react";
|
|
2
|
+
import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Ruler } from "lucide-react";
|
|
3
3
|
import ButtonTools from "../../components/button-tools";
|
|
4
4
|
import { Divider, ColorPicker, Button, } from "antd";
|
|
5
5
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
@@ -21,6 +21,11 @@ const SideTool = ({ dragOnly }) => {
|
|
|
21
21
|
id: "grab",
|
|
22
22
|
name: "Grab Tool",
|
|
23
23
|
icon: <Hand />,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "ruler",
|
|
27
|
+
name: "Ruler",
|
|
28
|
+
icon: <Ruler />,
|
|
24
29
|
}
|
|
25
30
|
];
|
|
26
31
|
const actionsTools = [
|
|
@@ -78,7 +83,7 @@ const SideTool = ({ dragOnly }) => {
|
|
|
78
83
|
// }
|
|
79
84
|
];
|
|
80
85
|
const hanldeSelectTool = (id) => {
|
|
81
|
-
if (id === "background" || id === "
|
|
86
|
+
if (id === "background" || id === "image-table") {
|
|
82
87
|
dispatch({
|
|
83
88
|
type: "panel/setShow",
|
|
84
89
|
payload: true,
|
|
@@ -15,5 +15,5 @@ export interface LayerViewProps {
|
|
|
15
15
|
containerProps?: any;
|
|
16
16
|
svgProps?: any;
|
|
17
17
|
}
|
|
18
|
-
declare const LayerView: (props: LayerViewProps) => import("react
|
|
18
|
+
declare const LayerView: (props: LayerViewProps) => import("react").JSX.Element;
|
|
19
19
|
export default LayerView;
|
|
@@ -15,5 +15,5 @@ export interface LayerViewProps {
|
|
|
15
15
|
containerProps?: any;
|
|
16
16
|
svgProps?: any;
|
|
17
17
|
}
|
|
18
|
-
declare const LayerView: (props: LayerViewProps) => import("react
|
|
18
|
+
declare const LayerView: (props: LayerViewProps) => import("react").JSX.Element;
|
|
19
19
|
export default LayerView;
|