seat-editor 3.4.8 → 3.5.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/constant.d.ts +1 -1
- package/dist/app/graph-view/page.d.ts +1 -0
- package/dist/app/graph-view/page.js +343 -0
- package/dist/app/graph-view/page.jsx +445 -0
- package/dist/app/graph-view-new/constant.d.ts +581 -0
- package/dist/app/graph-view-new/constant.js +6973 -0
- package/dist/app/graph-view-new/page.d.ts +1 -0
- package/dist/app/graph-view-new/page.js +71 -0
- package/dist/app/graph-view-new/page.jsx +98 -0
- package/dist/app/layout.d.ts +1 -1
- package/dist/app/new-board/page.d.ts +1 -1
- package/dist/app/new-board/page.js +43 -7
- package/dist/app/new-board/page.jsx +45 -12
- package/dist/app/old-board/page.d.ts +1 -2
- package/dist/app/only-view/chair.d.ts +1 -1
- package/dist/app/only-view/chair.js +2 -10
- package/dist/app/only-view/page.d.ts +1 -1
- package/dist/app/only-view/user.d.ts +1 -1
- package/dist/app/only-view/user.js +2 -10
- package/dist/app/page.d.ts +1 -1
- package/dist/app/test/page.d.ts +1 -2
- package/dist/app/v2/page.d.ts +1 -1
- package/dist/components/button-tools/index.d.ts +1 -1
- package/dist/components/button-tools/index.js +7 -5
- package/dist/components/button-tools/index.jsx +21 -9
- package/dist/components/form-tools/label.d.ts +1 -1
- package/dist/components/form-tools/label.js +9 -20
- package/dist/components/form-tools/label.jsx +38 -28
- package/dist/components/form-tools/shape.d.ts +1 -1
- package/dist/components/form-tools/shape.js +5 -5
- package/dist/components/form-tools/shape.jsx +8 -8
- package/dist/components/input/number-indicator.d.ts +1 -1
- package/dist/components/joystick/index.d.ts +1 -2
- package/dist/components/layer/index.d.ts +1 -1
- package/dist/components/layer-v2/index.d.ts +1 -1
- package/dist/components/layer-v3/index.d.ts +1 -1
- package/dist/components/layer-v3/index.js +44 -3
- package/dist/components/layer-v3/index.jsx +120 -3
- package/dist/components/layer-v4/index.d.ts +1 -1
- package/dist/components/layer-v5/constant.d.ts +60 -0
- package/dist/components/layer-v5/constant.js +93 -0
- package/dist/components/layer-v5/index.d.ts +24 -0
- package/dist/components/layer-v5/index.js +927 -0
- package/dist/components/layer-v5/index.jsx +1049 -0
- 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-v2/index.d.ts +1 -2
- package/dist/features/board-v3/index.d.ts +1 -1
- package/dist/features/board-v3/index.js +350 -72
- package/dist/features/board-v3/index.jsx +369 -75
- package/dist/features/board-v3/resize-element.js +5 -0
- package/dist/features/board-v3/utils.d.ts +8 -0
- package/dist/features/board-v3/utils.js +23 -7
- package/dist/features/navbar/index.d.ts +1 -1
- package/dist/features/package/index.d.ts +3 -1
- package/dist/features/package/index.js +1 -1
- package/dist/features/package/index.jsx +6 -1
- package/dist/features/panel/index.d.ts +9 -1
- package/dist/features/panel/index.js +160 -38
- package/dist/features/panel/index.jsx +173 -46
- package/dist/features/panel/polygon.d.ts +2 -0
- package/dist/features/panel/polygon.js +44 -0
- package/dist/features/panel/polygon.jsx +70 -0
- package/dist/features/panel/select-tool.d.ts +1 -1
- package/dist/features/panel/select-tool.js +3 -0
- package/dist/features/panel/select-tool.jsx +3 -0
- package/dist/features/panel/selected-group.d.ts +1 -1
- package/dist/features/panel/selected-group.js +24 -26
- package/dist/features/panel/selected-group.jsx +56 -51
- 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/table-seat-square.d.ts +1 -1
- package/dist/features/panel/text-tool.d.ts +1 -1
- package/dist/features/panel/text-tool.js +17 -2
- package/dist/features/panel/text-tool.jsx +19 -2
- package/dist/features/panel/upload-tool.d.ts +1 -1
- package/dist/features/panel/upload-tool.js +17 -3
- package/dist/features/panel/upload-tool.jsx +23 -4
- package/dist/features/side-tool/index.d.ts +1 -1
- package/dist/features/side-tool/index.js +43 -6
- package/dist/features/side-tool/index.jsx +47 -10
- package/dist/features/view-only/index.d.ts +1 -1
- package/dist/features/view-only-2/index.d.ts +1 -1
- package/dist/features/view-only-3/index.d.ts +1 -1
- package/dist/features/view-only-4/connect-handle.d.ts +13 -0
- package/dist/features/view-only-4/connect-handle.js +23 -0
- package/dist/features/view-only-4/connect-handle.jsx +30 -0
- package/dist/features/view-only-4/connection-layer.d.ts +21 -0
- package/dist/features/view-only-4/connection-layer.js +219 -0
- package/dist/features/view-only-4/connection-layer.jsx +291 -0
- package/dist/features/view-only-4/index.d.ts +99 -0
- package/dist/features/view-only-4/index.js +684 -0
- package/dist/features/view-only-4/index.jsx +722 -0
- package/dist/features/view-only-4/integration-guide.d.ts +0 -0
- package/dist/features/view-only-4/integration-guide.js +0 -0
- package/dist/features/view-only-4/use-connection-graph.d.ts +41 -0
- package/dist/features/view-only-4/use-connection-graph.js +182 -0
- package/dist/features/view-only-4/utils.d.ts +74 -0
- package/dist/features/view-only-4/utils.js +106 -0
- package/dist/features/view-only-5/connect-handle.d.ts +30 -0
- package/dist/features/view-only-5/connect-handle.js +88 -0
- package/dist/features/view-only-5/connect-handle.jsx +96 -0
- package/dist/features/view-only-5/connection-layer.d.ts +34 -0
- package/dist/features/view-only-5/connection-layer.js +182 -0
- package/dist/features/view-only-5/connection-layer.jsx +265 -0
- package/dist/features/view-only-5/index.d.ts +102 -0
- package/dist/features/view-only-5/index.js +585 -0
- package/dist/features/view-only-5/index.jsx +614 -0
- package/dist/features/view-only-5/use-connection-graph.d.ts +57 -0
- package/dist/features/view-only-5/use-connection-graph.js +196 -0
- package/dist/features/view-only-5/utils.d.ts +52 -0
- package/dist/features/view-only-5/utils.js +80 -0
- package/dist/features/view-only-6/connect-handle.d.ts +13 -0
- package/dist/features/view-only-6/connect-handle.js +20 -0
- package/dist/features/view-only-6/connect-handle.jsx +21 -0
- package/dist/features/view-only-6/connection-layer.d.ts +22 -0
- package/dist/features/view-only-6/connection-layer.js +191 -0
- package/dist/features/view-only-6/connection-layer.jsx +244 -0
- package/dist/features/view-only-6/index.d.ts +99 -0
- package/dist/features/view-only-6/index.js +687 -0
- package/dist/features/view-only-6/index.jsx +724 -0
- package/dist/features/view-only-6/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-6/use-connection-graph.js +103 -0
- package/dist/features/view-only-6/utils.d.ts +66 -0
- package/dist/features/view-only-6/utils.js +96 -0
- package/dist/features/view-only-7/connect-handle.d.ts +13 -0
- package/dist/features/view-only-7/connect-handle.js +23 -0
- package/dist/features/view-only-7/connect-handle.jsx +30 -0
- package/dist/features/view-only-7/connection-layer.d.ts +22 -0
- package/dist/features/view-only-7/connection-layer.js +165 -0
- package/dist/features/view-only-7/connection-layer.jsx +217 -0
- package/dist/features/view-only-7/index.d.ts +99 -0
- package/dist/features/view-only-7/index.js +687 -0
- package/dist/features/view-only-7/index.jsx +724 -0
- package/dist/features/view-only-7/use-connection-graph.d.ts +26 -0
- package/dist/features/view-only-7/use-connection-graph.js +104 -0
- package/dist/features/view-only-7/utils.d.ts +69 -0
- package/dist/features/view-only-7/utils.js +144 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -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
|
@@ -4,6 +4,11 @@ export function getAttributeElement(root, id) {
|
|
|
4
4
|
const g = root.querySelector(`g[data-id="${id}"]`);
|
|
5
5
|
const seats = root.querySelectorAll(`g[data-seat="${id}-seats"]`);
|
|
6
6
|
const seatGroup = root.querySelector(`g[data-seat="${id}-seats"]`);
|
|
7
|
+
const boundingBox = root.querySelector(`g[data-bounding-box="${id}"]`);
|
|
8
|
+
if (boundingBox) {
|
|
9
|
+
const element = boundingBox.querySelector("rect");
|
|
10
|
+
return { g: boundingBox, inner: null, element, seats, seatGroup };
|
|
11
|
+
}
|
|
7
12
|
if (!g)
|
|
8
13
|
return { g, inner: null, element: null };
|
|
9
14
|
const inner = g.querySelector("g");
|
|
@@ -37,6 +37,7 @@ export declare function getAnchorByHandle(handle: ResizeHandle, box: {
|
|
|
37
37
|
ax: number;
|
|
38
38
|
ay: number;
|
|
39
39
|
};
|
|
40
|
+
import { TableProps } from "@/dto/table";
|
|
40
41
|
interface ResizeSeatSquare {
|
|
41
42
|
seatsPositions: {
|
|
42
43
|
top: number;
|
|
@@ -98,6 +99,12 @@ export declare function getGlobalBBox(svg: SVGSVGElement, el: SVGGraphicsElement
|
|
|
98
99
|
width: number;
|
|
99
100
|
height: number;
|
|
100
101
|
};
|
|
102
|
+
export declare function functionGetGlobalBBoxById(svg: SVGSVGElement, id: string): {
|
|
103
|
+
x: number;
|
|
104
|
+
y: number;
|
|
105
|
+
width: number;
|
|
106
|
+
height: number;
|
|
107
|
+
};
|
|
101
108
|
export declare function getTranslate(el: any): {
|
|
102
109
|
x: number;
|
|
103
110
|
y: number;
|
|
@@ -178,4 +185,5 @@ type GuideLineIds = {
|
|
|
178
185
|
hBottom: string;
|
|
179
186
|
};
|
|
180
187
|
export declare const updateSelectionGuides: (svg: SVGSVGElement | null, rect: Rect, ids: GuideLineIds, range?: number) => void;
|
|
188
|
+
export declare const getAllSelectionBox: (elements: TableProps[]) => TableProps;
|
|
181
189
|
export {};
|
|
@@ -226,7 +226,7 @@ export const resizeSeatSquare = ({ seatsPositions, r = 10, openSpace, newElement
|
|
|
226
226
|
id: "left",
|
|
227
227
|
}));
|
|
228
228
|
const bottomXs = distributeWithSpacing({
|
|
229
|
-
start:
|
|
229
|
+
start: 0,
|
|
230
230
|
length: newElement.width,
|
|
231
231
|
count: bottomCount,
|
|
232
232
|
radius: r,
|
|
@@ -854,6 +854,12 @@ export function getGlobalBBox(svg, el) {
|
|
|
854
854
|
// rotation
|
|
855
855
|
};
|
|
856
856
|
}
|
|
857
|
+
export function functionGetGlobalBBoxById(svg, id) {
|
|
858
|
+
const el = svg.getElementById(id);
|
|
859
|
+
if (!el)
|
|
860
|
+
return null;
|
|
861
|
+
return getGlobalBBox(svg, el);
|
|
862
|
+
}
|
|
857
863
|
function localToWorld(dx, dy, angle) {
|
|
858
864
|
const cosR = Math.cos(angle);
|
|
859
865
|
const sinR = Math.sin(angle);
|
|
@@ -1017,18 +1023,18 @@ export function applyResizeToSvgElement(element, group, resize, component) {
|
|
|
1017
1023
|
case "rect":
|
|
1018
1024
|
case "image": {
|
|
1019
1025
|
updateSvgAttrs(element, {
|
|
1020
|
-
width: resize.width < 60 ? 60 : resize.width,
|
|
1021
|
-
height: resize.height < MIN_HEIGHT ? MIN_HEIGHT : resize.height,
|
|
1026
|
+
width: resize.width < 60 ? 60 : Math.round(resize.width),
|
|
1027
|
+
height: resize.height < MIN_HEIGHT ? MIN_HEIGHT : Math.round(resize.height),
|
|
1022
1028
|
// fill: component.fill,
|
|
1023
1029
|
});
|
|
1024
1030
|
updateSvgAttrs(group, {
|
|
1025
|
-
transform: `translate(${resize.x}, ${resize.y})`,
|
|
1031
|
+
transform: `translate(${Math.round(resize.x)}, ${Math.round(resize.y)})`,
|
|
1026
1032
|
});
|
|
1027
1033
|
break;
|
|
1028
1034
|
}
|
|
1029
1035
|
case "circle": {
|
|
1030
|
-
const width = resize.width < MIN_WIDTH ? MIN_WIDTH : resize.width;
|
|
1031
|
-
const height = resize.height < MIN_HEIGHT ? MIN_HEIGHT : resize.height;
|
|
1036
|
+
const width = resize.width < MIN_WIDTH ? MIN_WIDTH : Math.round(resize.width);
|
|
1037
|
+
const height = resize.height < MIN_HEIGHT ? MIN_HEIGHT : Math.round(resize.height);
|
|
1032
1038
|
const r = Math.min(width, height) / 2;
|
|
1033
1039
|
updateSvgAttrs(element, {
|
|
1034
1040
|
r,
|
|
@@ -1036,7 +1042,7 @@ export function applyResizeToSvgElement(element, group, resize, component) {
|
|
|
1036
1042
|
cy: height / 2,
|
|
1037
1043
|
// fill: component.fill,
|
|
1038
1044
|
});
|
|
1039
|
-
group.setAttribute("transform", `translate(${resize.x}, ${resize.y})`);
|
|
1045
|
+
group.setAttribute("transform", `translate(${Math.round(resize.x)}, ${Math.round(resize.y)})`);
|
|
1040
1046
|
// inner
|
|
1041
1047
|
break;
|
|
1042
1048
|
}
|
|
@@ -1259,3 +1265,13 @@ export const updateSelectionGuides = (svg, rect, ids, range = 10000) => {
|
|
|
1259
1265
|
h(ids.hCenter, cy);
|
|
1260
1266
|
h(ids.hBottom, y + height);
|
|
1261
1267
|
};
|
|
1268
|
+
export const getAllSelectionBox = (elements) => {
|
|
1269
|
+
return {
|
|
1270
|
+
x: Math.min(...elements.map((el) => el.x)),
|
|
1271
|
+
y: Math.min(...elements.map((el) => el.y)),
|
|
1272
|
+
width: Math.max(...elements.map((el) => el.x + el.width)) -
|
|
1273
|
+
Math.min(...elements.map((el) => el.x)),
|
|
1274
|
+
height: Math.max(...elements.map((el) => el.y + el.height)) -
|
|
1275
|
+
Math.min(...elements.map((el) => el.y)),
|
|
1276
|
+
};
|
|
1277
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const Navbar: () => import("react").JSX.Element;
|
|
1
|
+
declare const Navbar: () => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default Navbar;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { RefsType } from "../board-v3";
|
|
2
3
|
import { OnCurrentStateChange } from "../view-only-3";
|
|
3
4
|
import { PropertiesProps } from "../../dto/table";
|
|
@@ -44,6 +45,7 @@ export interface TableEditorProps<TMeta = undefined> {
|
|
|
44
45
|
};
|
|
45
46
|
disabledView?: boolean;
|
|
46
47
|
defaultSeatCountKey?: string;
|
|
48
|
+
header?: React.ReactNode;
|
|
47
49
|
}
|
|
48
|
-
declare const TableEditor: <TMeta>(props: TableEditorProps<TMeta>) => import("react").JSX.Element;
|
|
50
|
+
declare const TableEditor: <TMeta>(props: TableEditorProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
|
|
49
51
|
export default TableEditor;
|
|
@@ -172,6 +172,6 @@ const TableEditor = (props) => {
|
|
|
172
172
|
switch: false,
|
|
173
173
|
drop: false,
|
|
174
174
|
rightClick: false,
|
|
175
|
-
} }, `${viewOnly}`) })) : (_jsxs("div", { className: "w-full h-full flex relative", children: [loading && !isPreview && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx(SideTool, { dragOnly: dragOnly, deleteAutorized: deleteAutorized }), _jsx(Board, { refs: refsBoard, loadingRender: props === null || props === void 0 ? void 0 : props.loadingRender, disabled: props === null || props === void 0 ? void 0 : props.disabledView }, `${viewOnly}`), _jsx(ControlPanels, { action: props.action, transform: (_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef })] }, `${viewOnly}`)) }) }));
|
|
175
|
+
} }, `${viewOnly}`) })) : (_jsxs("div", { className: "w-full h-full flex relative", children: [loading && !isPreview && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx("div", { className: "absolute top-0 left-0 w-full bg-white pointer-events-none p-[20px] z-[51] border-b border-gray-200", children: props.header ? (props.header) : (_jsx("div", { className: "text-xl font-bold h-[38px] leading-[38px] flex ", children: "Navbar" })) }), _jsx(SideTool, { dragOnly: dragOnly, deleteAutorized: deleteAutorized }), _jsx(Board, { refs: refsBoard, loadingRender: props === null || props === void 0 ? void 0 : props.loadingRender, disabled: props === null || props === void 0 ? void 0 : props.disabledView }, `${viewOnly}`), _jsx(ControlPanels, { action: props.action, transform: (_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef })] }, `${viewOnly}`)) }) }));
|
|
176
176
|
};
|
|
177
177
|
export default TableEditor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
2
|
+
import React, { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
3
|
import Board from "../board-v3";
|
|
4
4
|
import SideTool from "../side-tool";
|
|
5
5
|
import ControlPanels from "../panel";
|
|
@@ -179,6 +179,11 @@ const TableEditor = (props) => {
|
|
|
179
179
|
{loading && !isPreview && (<div className="absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center">
|
|
180
180
|
{(loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || <Spin />}
|
|
181
181
|
</div>)}
|
|
182
|
+
<div className="absolute top-0 left-0 w-full bg-white pointer-events-none p-[20px] z-[51] border-b border-gray-200">
|
|
183
|
+
{props.header ? (props.header) : (<div className="text-xl font-bold h-[38px] leading-[38px] flex ">
|
|
184
|
+
Navbar
|
|
185
|
+
</div>)}
|
|
186
|
+
</div>
|
|
182
187
|
<SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
|
|
183
188
|
<Board key={`${viewOnly}`} refs={refsBoard} loadingRender={props === null || props === void 0 ? void 0 : props.loadingRender} disabled={props === null || props === void 0 ? void 0 : props.disabledView}/>
|
|
184
189
|
<ControlPanels action={props.action} transform={(_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.transformRef}/>
|
|
@@ -2,5 +2,13 @@ interface ControlPanelsProps {
|
|
|
2
2
|
action?: (file: File) => Promise<string>;
|
|
3
3
|
transform?: any;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
interface FormPlaceholderContextType {
|
|
6
|
+
placeholders: Record<string, string>;
|
|
7
|
+
setPlaceholder: (name: string, placeholder: string) => void;
|
|
8
|
+
unsetPlaceholder: (name: string) => void;
|
|
9
|
+
setPlaceholderBulk: (bulk: Record<string, string>) => void;
|
|
10
|
+
resetPlaceholders: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare const ControlPanels: (props: ControlPanelsProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
13
|
export default ControlPanels;
|
|
14
|
+
export declare const useFormPlaceholder: () => FormPlaceholderContextType;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { useEffect, useRef, useState } from "react";
|
|
14
|
+
import { useEffect, createContext, useRef, useState, useContext } from "react";
|
|
15
15
|
import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
|
|
16
16
|
import { Form, Input } from "antd";
|
|
17
17
|
import SelectToolForm from "./select-tool";
|
|
@@ -26,6 +26,7 @@ import { SEAT_SHAPES } from "../../utils/constant";
|
|
|
26
26
|
import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
|
|
27
27
|
import SeatSquare from "./table-seat-square";
|
|
28
28
|
import _ from "lodash";
|
|
29
|
+
const FormPlaceholderContext = createContext(null);
|
|
29
30
|
const ControlPanels = (props) => {
|
|
30
31
|
const { action, transform } = props;
|
|
31
32
|
const dispatch = useAppDispatch();
|
|
@@ -37,29 +38,67 @@ const ControlPanels = (props) => {
|
|
|
37
38
|
const components = useAppSelector((state) => state.board.components);
|
|
38
39
|
const extraComponents = useAppSelector((state) => state.board.extraComponents);
|
|
39
40
|
const svgRef = useRef(null);
|
|
41
|
+
const [bufferValueForm, setBufferValueForm] = useState(null);
|
|
40
42
|
useEffect(() => {
|
|
41
43
|
svgRef.current = document.querySelectorAll("#workspace");
|
|
42
44
|
}, []);
|
|
43
45
|
const { show } = useAppSelector((state) => state.panel);
|
|
44
46
|
const [open, setOpen] = useState(false);
|
|
45
47
|
const [form] = Form.useForm();
|
|
48
|
+
const [placeholders, setPlaceholders] = useState({});
|
|
49
|
+
const [groupBufferSelected, setGroupBufferSelected] = useState([]);
|
|
46
50
|
let values = Form.useWatch([], form);
|
|
51
|
+
const setPlaceholder = (name, placeholder) => {
|
|
52
|
+
setPlaceholders((prev) => (Object.assign(Object.assign({}, prev), { [name]: placeholder })));
|
|
53
|
+
};
|
|
54
|
+
const unsetPlaceholder = (name) => {
|
|
55
|
+
setPlaceholders((prev) => {
|
|
56
|
+
const next = Object.assign({}, prev);
|
|
57
|
+
delete next[name];
|
|
58
|
+
return next;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const setPlaceholderBulk = (bulk) => {
|
|
62
|
+
setPlaceholders((prev) => (Object.assign(Object.assign({}, prev), bulk)));
|
|
63
|
+
};
|
|
64
|
+
const resetPlaceholders = () => setPlaceholders({});
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (tool.active === "background" || tool.active === "image-table") {
|
|
67
|
+
setOpen(true);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
setOpen(false);
|
|
71
|
+
}
|
|
72
|
+
}, [tool, show]);
|
|
47
73
|
useEffect(() => {
|
|
48
74
|
if (selectedComponent) {
|
|
49
|
-
|
|
75
|
+
const id = values === null || values === void 0 ? void 0 : values.id;
|
|
76
|
+
if (id !== selectedComponent.id) {
|
|
77
|
+
form.resetFields();
|
|
78
|
+
}
|
|
50
79
|
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);
|
|
51
80
|
const isSameIdAndSameDimensions = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) === (values === null || values === void 0 ? void 0 : values.id) &&
|
|
52
81
|
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.height) === (values === null || values === void 0 ? void 0 : values.height) &&
|
|
53
82
|
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.width) === (values === null || values === void 0 ? void 0 : values.width) &&
|
|
54
83
|
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.x) === (values === null || values === void 0 ? void 0 : values.x) &&
|
|
55
84
|
(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.y) === (values === null || values === void 0 ? void 0 : values.y);
|
|
56
|
-
|
|
85
|
+
const isPolygon = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "polygon";
|
|
86
|
+
if (show && (isDifferentId || isSameIdAndSameDimensions || isPolygon)) {
|
|
57
87
|
setOpen(true);
|
|
58
88
|
}
|
|
59
89
|
form.setFieldsValue(Object.assign(Object.assign({}, selectedComponent), { opacity: (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.opacity) * 100, openSpace: (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.openSpace) * 100 }));
|
|
60
90
|
}
|
|
61
91
|
else if (selectedGroup) {
|
|
62
|
-
form.resetFields();
|
|
92
|
+
// form.resetFields();
|
|
93
|
+
if (selectedGroup.length === 0) {
|
|
94
|
+
form.resetFields();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const notSameGroup = (selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) !== (groupBufferSelected === null || groupBufferSelected === void 0 ? void 0 : groupBufferSelected.length);
|
|
98
|
+
if (notSameGroup) {
|
|
99
|
+
form.resetFields();
|
|
100
|
+
setBufferValueForm(null);
|
|
101
|
+
}
|
|
63
102
|
if (show)
|
|
64
103
|
setOpen(true);
|
|
65
104
|
if (!show)
|
|
@@ -68,53 +107,100 @@ const ControlPanels = (props) => {
|
|
|
68
107
|
if (!arr || arr.length === 0)
|
|
69
108
|
return false;
|
|
70
109
|
const firstValue = arr[0][key];
|
|
71
|
-
return arr.every((item) => item[key] === firstValue);
|
|
110
|
+
return arr.every((item) => (item === null || item === void 0 ? void 0 : item[key]) === firstValue);
|
|
72
111
|
}
|
|
73
112
|
function getValueIfSame(arr, key) {
|
|
113
|
+
var _a;
|
|
74
114
|
if (key === "opacity") {
|
|
75
115
|
return isSameAllByKey(arr, key)
|
|
76
116
|
? Number(arr[0][key]) * 100
|
|
77
117
|
: undefined;
|
|
78
118
|
}
|
|
79
119
|
if (key === "labels") {
|
|
80
|
-
const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key]));
|
|
81
|
-
return (arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key])))
|
|
82
|
-
? arr[0][key]
|
|
120
|
+
const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); });
|
|
121
|
+
return (arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); }))
|
|
122
|
+
? (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]
|
|
83
123
|
: [];
|
|
84
124
|
}
|
|
85
125
|
return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
|
|
86
126
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
function getAllValuesKey(arr, key) {
|
|
128
|
+
return arr
|
|
129
|
+
.map((item) => item === null || item === void 0 ? void 0 : item[key])
|
|
130
|
+
.filter((value) => value !== undefined)
|
|
131
|
+
.sort((a, b) => {
|
|
132
|
+
if (typeof a === "number" && typeof b === "number")
|
|
133
|
+
return a - b;
|
|
134
|
+
return String(a).localeCompare(String(b));
|
|
135
|
+
})
|
|
136
|
+
.filter((value, index, self) => self.indexOf(value) === index);
|
|
137
|
+
}
|
|
138
|
+
function showAllValueNotSame(arr, key) {
|
|
139
|
+
if (key === "opacity") {
|
|
140
|
+
return !isSameAllByKey(arr, key)
|
|
141
|
+
? `${getAllValuesKey(arr, key)
|
|
142
|
+
.map((value) => Number(value) * 100)
|
|
143
|
+
.join(", ")}`
|
|
144
|
+
: `${Number(arr[0][key]) * 100}`;
|
|
145
|
+
}
|
|
146
|
+
return !isSameAllByKey(arr, key)
|
|
147
|
+
? `${getAllValuesKey(arr, key)}`
|
|
148
|
+
: `${arr[0][key]}`;
|
|
149
|
+
}
|
|
150
|
+
const fields = [
|
|
151
|
+
"width",
|
|
152
|
+
"height",
|
|
153
|
+
"x",
|
|
154
|
+
"y",
|
|
155
|
+
"opacity",
|
|
156
|
+
"rotation",
|
|
157
|
+
"radius",
|
|
158
|
+
"fill",
|
|
159
|
+
"stroke",
|
|
160
|
+
"strokeWidth",
|
|
161
|
+
"shape",
|
|
162
|
+
"labels",
|
|
163
|
+
"seatCount",
|
|
164
|
+
"seatPositions",
|
|
165
|
+
"seatFill",
|
|
166
|
+
"openSpace",
|
|
167
|
+
];
|
|
168
|
+
// placeholder (khusus field tertentu saja)
|
|
169
|
+
const placeholderFields = [
|
|
170
|
+
"width",
|
|
171
|
+
"height",
|
|
172
|
+
"x",
|
|
173
|
+
"y",
|
|
174
|
+
"opacity",
|
|
175
|
+
"rotation",
|
|
176
|
+
"radius",
|
|
177
|
+
"strokeWidth",
|
|
178
|
+
];
|
|
179
|
+
// build placeholder
|
|
180
|
+
const placeholder = Object.fromEntries(placeholderFields.map((key) => [
|
|
181
|
+
key,
|
|
182
|
+
showAllValueNotSame(selectedGroup, key),
|
|
183
|
+
]));
|
|
184
|
+
// build values
|
|
185
|
+
const values = Object.fromEntries(fields.map((key) => [
|
|
186
|
+
key,
|
|
187
|
+
(bufferValueForm === null || bufferValueForm === void 0 ? void 0 : bufferValueForm.key) === key
|
|
188
|
+
? bufferValueForm.value
|
|
189
|
+
: getValueIfSame(selectedGroup, key),
|
|
190
|
+
]));
|
|
191
|
+
// apply
|
|
192
|
+
setPlaceholderBulk(placeholder);
|
|
193
|
+
form.setFieldsValue(values);
|
|
194
|
+
setGroupBufferSelected(selectedGroup);
|
|
195
|
+
if (notSameGroup) {
|
|
196
|
+
form.setFieldValue(`${bufferValueForm === null || bufferValueForm === void 0 ? void 0 : bufferValueForm.key}`, getValueIfSame(selectedGroup, bufferValueForm === null || bufferValueForm === void 0 ? void 0 : bufferValueForm.key));
|
|
197
|
+
}
|
|
113
198
|
}
|
|
114
199
|
else {
|
|
115
|
-
|
|
200
|
+
if (tool.active !== "background")
|
|
201
|
+
setOpen(false);
|
|
116
202
|
}
|
|
117
|
-
}, [
|
|
203
|
+
}, [selectedComponent, selectedGroup, show, groupBufferSelected, tool]);
|
|
118
204
|
const createShape = (shape, props = {}, selectedComponent) => {
|
|
119
205
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
120
206
|
const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -250,6 +336,7 @@ const ControlPanels = (props) => {
|
|
|
250
336
|
switch (tool.active) {
|
|
251
337
|
case "select":
|
|
252
338
|
case "text":
|
|
339
|
+
case "polygon":
|
|
253
340
|
return _jsx(SelectToolForm, { action: action, tranform: transform });
|
|
254
341
|
case "square":
|
|
255
342
|
case "circle":
|
|
@@ -274,7 +361,42 @@ const ControlPanels = (props) => {
|
|
|
274
361
|
payload: false,
|
|
275
362
|
});
|
|
276
363
|
};
|
|
277
|
-
|
|
278
|
-
|
|
364
|
+
return (_jsx(FormPlaceholderContext.Provider, { value: {
|
|
365
|
+
placeholders,
|
|
366
|
+
setPlaceholder,
|
|
367
|
+
unsetPlaceholder,
|
|
368
|
+
setPlaceholderBulk,
|
|
369
|
+
resetPlaceholders,
|
|
370
|
+
}, children: _jsx("div", { className: clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll mt-[78px]", open ? "right-0" : "right-[-1000px]"), children: _jsx("div", { className: "bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300", children: _jsxs(Form, { layout: "vertical", form: form, name: "table", colon: false, onValuesChange: handleChangeComponent, onFocus: (e) => {
|
|
371
|
+
var _a, _b, _c;
|
|
372
|
+
e.stopPropagation();
|
|
373
|
+
const name = e.target.name;
|
|
374
|
+
const placeholder = (_c = (_b = (_a = placeholders === null || placeholders === void 0 ? void 0 : placeholders[name]) === null || _a === void 0 ? void 0 : _a.split(",")) === null || _b === void 0 ? void 0 : _b.map(Number)) === null || _c === void 0 ? void 0 : _c.filter((item) => !_.isNaN(item));
|
|
375
|
+
const averageValuePlaceHolder = (placeholder === null || placeholder === void 0 ? void 0 : placeholder.reduce((a, b) => a + b, 0)) / (placeholder === null || placeholder === void 0 ? void 0 : placeholder.length);
|
|
376
|
+
const value = Math.round(averageValuePlaceHolder);
|
|
377
|
+
if (placeholder && placeholder.length > 0) {
|
|
378
|
+
setBufferValueForm({
|
|
379
|
+
key: name,
|
|
380
|
+
value: value,
|
|
381
|
+
});
|
|
382
|
+
form.setFieldsValue({
|
|
383
|
+
[name]: value,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}, onBlur: (e) => {
|
|
387
|
+
e.stopPropagation();
|
|
388
|
+
setBufferValueForm(null);
|
|
389
|
+
const name = e.target.name;
|
|
390
|
+
const value = e.target.value;
|
|
391
|
+
if (value) {
|
|
392
|
+
handleChangeComponent({ [name]: value }, form.getFieldsValue());
|
|
393
|
+
}
|
|
394
|
+
}, initialValues: { labels: [{}] }, children: [_jsx(Form.Item, { name: "id", hidden: true, children: _jsx(Input, {}) }), _jsx(Form.Item, { name: "shape", hidden: true, children: _jsx(Input, {}) }), renderFormPanel()] }) }) }) }));
|
|
279
395
|
};
|
|
280
396
|
export default ControlPanels;
|
|
397
|
+
export const useFormPlaceholder = () => {
|
|
398
|
+
const ctx = useContext(FormPlaceholderContext);
|
|
399
|
+
if (!ctx)
|
|
400
|
+
throw new Error("useFormPlaceholder must be used within FormPlaceholderProvider");
|
|
401
|
+
return ctx;
|
|
402
|
+
};
|