seat-editor 3.3.35 → 3.3.36

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.
Files changed (81) hide show
  1. package/dist/app/layout.d.ts +1 -1
  2. package/dist/app/layout.js +22 -0
  3. package/dist/app/new-board/page.d.ts +1 -1
  4. package/dist/app/new-board/page.js +58 -0
  5. package/dist/app/old-board/page.d.ts +1 -2
  6. package/dist/app/old-board/page.js +377 -0
  7. package/dist/app/only-view/chair.d.ts +1 -1
  8. package/dist/app/only-view/chair.js +2 -10
  9. package/dist/app/only-view/page.d.ts +1 -1
  10. package/dist/app/only-view/page.js +226 -0
  11. package/dist/app/only-view/user.d.ts +1 -1
  12. package/dist/app/only-view/user.js +2 -10
  13. package/dist/app/page.d.ts +1 -1
  14. package/dist/app/page.js +8 -0
  15. package/dist/app/test/page.d.ts +1 -2
  16. package/dist/app/test/page.js +43 -0
  17. package/dist/app/v2/page.d.ts +1 -1
  18. package/dist/app/v2/page.js +8 -0
  19. package/dist/components/button-tools/index.d.ts +1 -1
  20. package/dist/components/button-tools/index.js +11 -0
  21. package/dist/components/form-tools/label.d.ts +1 -1
  22. package/dist/components/form-tools/label.js +21 -0
  23. package/dist/components/form-tools/shape.d.ts +1 -1
  24. package/dist/components/form-tools/shape.js +69 -0
  25. package/dist/components/input/number-indicator.d.ts +1 -1
  26. package/dist/components/input/number-indicator.js +27 -0
  27. package/dist/components/joystick/index.d.ts +1 -2
  28. package/dist/components/joystick/index.js +48 -0
  29. package/dist/components/layer/index.d.ts +1 -1
  30. package/dist/components/layer/index.js +295 -0
  31. package/dist/components/layer-v2/index.d.ts +1 -1
  32. package/dist/components/layer-v2/index.js +282 -0
  33. package/dist/components/layer-v3/index.d.ts +1 -1
  34. package/dist/components/layer-v3/index.js +483 -0
  35. package/dist/components/layer-v4/index.d.ts +1 -1
  36. package/dist/components/layer-v4/index.js +924 -0
  37. package/dist/components/lib/index.d.ts +1 -1
  38. package/dist/components/lib/index.js +28 -0
  39. package/dist/components/modal-preview/index.d.ts +1 -1
  40. package/dist/components/modal-preview/index.js +10 -0
  41. package/dist/features/board/index.d.ts +1 -1
  42. package/dist/features/board/index.js +666 -0
  43. package/dist/features/board-v2/index.d.ts +1 -2
  44. package/dist/features/board-v2/index.js +807 -0
  45. package/dist/features/board-v3/icons.js +16 -0
  46. package/dist/features/board-v3/index.d.ts +1 -1
  47. package/dist/features/board-v3/index.js +1587 -0
  48. package/dist/features/navbar/index.d.ts +1 -1
  49. package/dist/features/navbar/index.js +6 -0
  50. package/dist/features/package/index.d.ts +1 -1
  51. package/dist/features/package/index.js +166 -0
  52. package/dist/features/panel/index.d.ts +1 -1
  53. package/dist/features/panel/index.js +243 -0
  54. package/dist/features/panel/select-tool.d.ts +1 -1
  55. package/dist/features/panel/select-tool.js +57 -0
  56. package/dist/features/panel/selected-group.d.ts +1 -1
  57. package/dist/features/panel/selected-group.js +35 -0
  58. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  59. package/dist/features/panel/square-circle-tool.js +8 -0
  60. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  61. package/dist/features/panel/table-seat-circle.js +9 -0
  62. package/dist/features/panel/table-seat-square.d.ts +1 -1
  63. package/dist/features/panel/table-seat-square.js +9 -0
  64. package/dist/features/panel/text-tool.d.ts +1 -1
  65. package/dist/features/panel/text-tool.js +22 -0
  66. package/dist/features/panel/upload-tool.d.ts +1 -1
  67. package/dist/features/panel/upload-tool.js +150 -0
  68. package/dist/features/side-tool/index.d.ts +1 -1
  69. package/dist/features/side-tool/index.js +365 -0
  70. package/dist/features/view-only/index.d.ts +1 -1
  71. package/dist/features/view-only/index.js +198 -0
  72. package/dist/features/view-only-2/index.d.ts +1 -1
  73. package/dist/features/view-only-2/index.js +187 -0
  74. package/dist/features/view-only-3/index.d.ts +1 -1
  75. package/dist/features/view-only-3/index.js +577 -0
  76. package/dist/provider/antd-provider.js +43 -0
  77. package/dist/provider/redux-provider.d.ts +1 -1
  78. package/dist/provider/redux-provider.js +7 -0
  79. package/dist/provider/store-provider.d.ts +1 -1
  80. package/dist/provider/store-provider.js +9 -0
  81. package/package.json +1 -1
@@ -0,0 +1,198 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from "react";
4
+ import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
5
+ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
6
+ import Layers from "../../components/layer";
7
+ const LayerView = (props) => {
8
+ const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
9
+ const transformRef = useRef(null);
10
+ const containerRef = useRef(null);
11
+ const svgRef = useRef(null);
12
+ const [scale, setScale] = useState(1);
13
+ const [selectedTable, setSelectedTable] = useState(null);
14
+ const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
15
+ const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
16
+ const dispatch = useAppDispatch();
17
+ useEffect(() => {
18
+ if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
19
+ dispatch({
20
+ type: "board/setNewComponents",
21
+ payload: componentProps,
22
+ });
23
+ }
24
+ if ((extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) > 0) {
25
+ dispatch({
26
+ type: "board/setNewExtraComponents",
27
+ payload: extraComponentProps,
28
+ });
29
+ }
30
+ if (defaultBackground) {
31
+ dispatch({
32
+ type: "board/setBackgroundColor",
33
+ payload: defaultBackground,
34
+ });
35
+ }
36
+ }, [componentProps, extraComponentProps, defaultBackground]);
37
+ useEffect(() => {
38
+ onCurrentStateChange &&
39
+ onCurrentStateChange({
40
+ components: componentsEditor,
41
+ extraComponents: extraComponentsEditor,
42
+ });
43
+ }, [componentsEditor, extraComponentsEditor]);
44
+ const handleSelectComponent = (items) => {
45
+ const find = componentsEditor.find((item) => {
46
+ if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
47
+ return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
48
+ }
49
+ return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
50
+ });
51
+ onSelectComponent && onSelectComponent(find);
52
+ setSelectedTable(find);
53
+ };
54
+ const boundingBox = useMemo(() => {
55
+ var _a, _b, _c, _d, _e, _f, _g;
56
+ if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
57
+ return { minX: 0, minY: 0, width: 500, height: 500 };
58
+ }
59
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
60
+ componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
61
+ var _a, _b, _c, _d;
62
+ let values = mappingKey ? _[mappingKey] : _;
63
+ if (!values)
64
+ return;
65
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
66
+ minX = Math.min(minX, values.x);
67
+ minY = Math.min(minY, values.y);
68
+ maxX = Math.max(maxX, values.x + values.width);
69
+ maxY = Math.max(maxY, values.y + values.height);
70
+ }
71
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
72
+ minX = Math.min(minX, values.x);
73
+ minY = Math.min(minY, values.y);
74
+ maxX = Math.max(maxX, values.x + values.width);
75
+ maxY = Math.max(maxY, values.y + values.height);
76
+ }
77
+ if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
78
+ minX = Math.min(minX, values.x);
79
+ minY = Math.min(minY, values.y);
80
+ maxX = Math.max(maxX, values.x + values.width);
81
+ maxY = Math.max(maxY, values.y + values.height);
82
+ }
83
+ if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
84
+ minX = Math.min(minX, values.x);
85
+ minY = Math.min(minY, values.y);
86
+ maxX = Math.max(maxX, values.x + values.width);
87
+ maxY = Math.max(maxY, values.y + values.height);
88
+ }
89
+ });
90
+ extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
91
+ var _a, _b;
92
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
93
+ minX = Math.min(minX, values.x);
94
+ minY = Math.min(minY, values.y);
95
+ maxX = Math.max(maxX, values.x + values.width);
96
+ maxY = Math.max(maxY, values.y + values.height);
97
+ }
98
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
99
+ minX = Math.min(minX, values.x);
100
+ minY = Math.min(minY, values.y);
101
+ maxX = Math.max(maxX, values.x + values.width);
102
+ maxY = Math.max(maxY, values.y + values.height);
103
+ }
104
+ });
105
+ let backgroundHasOne = false;
106
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 && ((_b = (_a = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _a === void 0 ? void 0 : _a.shape) === null || _b === void 0 ? void 0 : _b.includes("background"))) {
107
+ backgroundHasOne = true;
108
+ minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
109
+ minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
110
+ maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
111
+ maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
112
+ }
113
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1 && ["background", "text"].includes((_g = componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor[0]) === null || _g === void 0 ? void 0 : _g.shape)) {
114
+ minX = minX - minX * 0.5;
115
+ minY = minY - minY * 0.5;
116
+ }
117
+ return {
118
+ minX: backgroundHasOne ? minX : minX - minX * 0.5,
119
+ minY: backgroundHasOne ? minY : minY - minY * 0.5,
120
+ width: maxX,
121
+ height: maxY,
122
+ };
123
+ }, [componentsEditor, extraComponentsEditor]);
124
+ const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
125
+ return elementEditor.map((editorItem, i) => {
126
+ var _a, _b, _c, _d;
127
+ const isUsingMapping = mappingKey &&
128
+ typeof editorItem[mappingKey] === "object" &&
129
+ editorItem[mappingKey] !== null;
130
+ const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
131
+ if (colorMatchKey) {
132
+ if (isUsingMapping) {
133
+ return Object.assign(Object.assign({}, finalProps), { fill: (_b = (_a = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : finalProps.fill });
134
+ }
135
+ else {
136
+ return Object.assign(Object.assign({}, finalProps), { fill: (_d = (_c = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : finalProps.fill });
137
+ }
138
+ }
139
+ return finalProps;
140
+ });
141
+ };
142
+ const [fingerCount, setFingerCount] = useState(0);
143
+ useEffect(() => {
144
+ const container = document.getElementById("workspace");
145
+ const handleTouchStart = (e) => {
146
+ const count = e.touches.length;
147
+ setFingerCount(count);
148
+ };
149
+ const handleTouchEnd = () => {
150
+ setFingerCount(0);
151
+ };
152
+ if (container) {
153
+ container.addEventListener("touchstart", handleTouchStart);
154
+ container.addEventListener("touchend", handleTouchEnd);
155
+ }
156
+ return () => {
157
+ if (container) {
158
+ container.removeEventListener("touchstart", handleTouchStart);
159
+ container.removeEventListener("touchend", handleTouchEnd);
160
+ }
161
+ };
162
+ }, []);
163
+ return (_jsx("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: {
164
+ height: "100vh",
165
+ overflow: "auto",
166
+ WebkitOverflowScrolling: "touch",
167
+ touchAction: "pan-y",
168
+ } }, props.containerProps, { children: _jsx(TransformWrapper, Object.assign({ ref: transformRef }, props.transformProps, { disabled: fingerCount === 1 && scale === 1, disablePadding: true,
169
+ // panning={{
170
+ // disabled: false,
171
+ // velocityDisabled: true,
172
+ // }}
173
+ // limitToBounds={false}
174
+ // doubleClick={{ disabled: true }}
175
+ // pinch={{ disabled: false }}
176
+ // wheel={{ disabled: true }}
177
+ // disabled={true}
178
+ // disablePadding={true}
179
+ centerZoomedOut: true, onTransformed: ({ state: { scale } }) => setScale(scale), minScale: 1, maxScale: 1000, initialScale: 1,
180
+ // pinch={{ step: 1 }}
181
+ smooth: true, children: _jsx(TransformComponent, { wrapperStyle: {
182
+ width: "100%",
183
+ height: "100%",
184
+ overflow: "visible",
185
+ }, contentStyle: {
186
+ width: "100%",
187
+ height: "100%",
188
+ }, children: _jsx("svg", Object.assign({}, props.svgProps, { id: "workspace", ref: svgRef, width: "100%", height: "100%", viewBox: `${boundingBox.minX} ${boundingBox.minY} ${boundingBox.width} ${boundingBox.height}`, className: "h-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
189
+ background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
190
+ display: "block",
191
+ pointerEvents: "auto",
192
+ // touchAction: "pan-y",
193
+ }, children: _jsx(Layers, { mode: "view", components: [
194
+ ...extraComponentsEditor,
195
+ ...renderElements(componentsEditor, mappingKey, colorMatchKey),
196
+ ], onClick: handleSelectComponent, selectedTable: selectedTable, selectedTableColor: selectedTableColor }) })) }) })) })));
197
+ };
198
+ 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").JSX.Element;
18
+ declare const LayerView: (props: LayerViewProps) => import("react/jsx-runtime").JSX.Element;
19
19
  export default LayerView;
@@ -0,0 +1,187 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from "react";
4
+ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
5
+ import Layers from "../../components/layer";
6
+ const LayerView = (props) => {
7
+ const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
8
+ const transformRef = useRef(null);
9
+ const containerRef = useRef(null);
10
+ const svgRef = useRef(null);
11
+ const [scale, setScale] = useState(1);
12
+ const [selectedTable, setSelectedTable] = useState(null);
13
+ const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
14
+ const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
15
+ const dispatch = useAppDispatch();
16
+ useEffect(() => {
17
+ if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
18
+ dispatch({
19
+ type: "board/setNewComponents",
20
+ payload: componentProps,
21
+ });
22
+ }
23
+ if ((extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) > 0) {
24
+ dispatch({
25
+ type: "board/setNewExtraComponents",
26
+ payload: extraComponentProps,
27
+ });
28
+ }
29
+ if (defaultBackground) {
30
+ dispatch({
31
+ type: "board/setBackgroundColor",
32
+ payload: defaultBackground,
33
+ });
34
+ }
35
+ }, [componentProps, extraComponentProps, defaultBackground]);
36
+ useEffect(() => {
37
+ onCurrentStateChange &&
38
+ onCurrentStateChange({
39
+ components: componentsEditor,
40
+ extraComponents: extraComponentsEditor,
41
+ });
42
+ }, [componentsEditor, extraComponentsEditor]);
43
+ const handleSelectComponent = (items) => {
44
+ const find = componentsEditor.find((item) => {
45
+ if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
46
+ return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
47
+ }
48
+ return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
49
+ });
50
+ onSelectComponent && onSelectComponent(find);
51
+ setSelectedTable(find);
52
+ };
53
+ const boundingBox = useMemo(() => {
54
+ var _a, _b, _c, _d, _e, _f, _g;
55
+ if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
56
+ return { minX: 0, minY: 0, width: 500, height: 500 };
57
+ }
58
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
59
+ componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
60
+ var _a, _b, _c, _d;
61
+ let values = mappingKey ? _[mappingKey] : _;
62
+ if (!values)
63
+ return;
64
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
65
+ minX = Math.min(minX, values.x);
66
+ minY = Math.min(minY, values.y);
67
+ maxX = Math.max(maxX, values.x + values.width);
68
+ maxY = Math.max(maxY, values.y + values.height);
69
+ }
70
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
71
+ minX = Math.min(minX, values.x);
72
+ minY = Math.min(minY, values.y);
73
+ maxX = Math.max(maxX, values.x + values.width);
74
+ maxY = Math.max(maxY, values.y + values.height);
75
+ }
76
+ if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
77
+ minX = Math.min(minX, values.x);
78
+ minY = Math.min(minY, values.y);
79
+ maxX = Math.max(maxX, values.x + values.width);
80
+ maxY = Math.max(maxY, values.y + values.height);
81
+ }
82
+ if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
83
+ minX = Math.min(minX, values.x);
84
+ minY = Math.min(minY, values.y);
85
+ maxX = Math.max(maxX, values.x + values.width);
86
+ maxY = Math.max(maxY, values.y + values.height);
87
+ }
88
+ });
89
+ extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
90
+ var _a, _b;
91
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
92
+ minX = Math.min(minX, values.x);
93
+ minY = Math.min(minY, values.y);
94
+ maxX = Math.max(maxX, values.x + values.width);
95
+ maxY = Math.max(maxY, values.y + values.height);
96
+ }
97
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
98
+ minX = Math.min(minX, values.x);
99
+ minY = Math.min(minY, values.y);
100
+ maxX = Math.max(maxX, values.x + values.width);
101
+ maxY = Math.max(maxY, values.y + values.height);
102
+ }
103
+ });
104
+ let backgroundHasOne = false;
105
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
106
+ ((_b = (_a = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _a === void 0 ? void 0 : _a.shape) === null || _b === void 0 ? void 0 : _b.includes("background"))) {
107
+ backgroundHasOne = true;
108
+ minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
109
+ minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
110
+ maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
111
+ maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
112
+ }
113
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1 &&
114
+ ["background", "text"].includes((_g = componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor[0]) === null || _g === void 0 ? void 0 : _g.shape)) {
115
+ minX = minX - minX * 0.5;
116
+ minY = minY - minY * 0.5;
117
+ }
118
+ const hasBoundingBox = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.some((item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.shape) === null || _a === void 0 ? void 0 : _a.includes("bounding-box"); });
119
+ if (hasBoundingBox) {
120
+ const findBoundingBox = extraComponentsEditor.find((item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.shape) === null || _a === void 0 ? void 0 : _a.includes("bounding-box"); });
121
+ return {
122
+ minX: findBoundingBox.x,
123
+ minY: findBoundingBox.y,
124
+ width: findBoundingBox.width,
125
+ height: findBoundingBox.height,
126
+ };
127
+ }
128
+ return {
129
+ minX: backgroundHasOne ? minX : minX - minX * 0.5,
130
+ minY: backgroundHasOne ? minY : minY - minY * 0.5,
131
+ width: maxX,
132
+ height: maxY,
133
+ };
134
+ }, [componentsEditor, extraComponentsEditor]);
135
+ const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
136
+ return elementEditor.map((editorItem, i) => {
137
+ var _a, _b, _c, _d;
138
+ const isUsingMapping = mappingKey &&
139
+ typeof editorItem[mappingKey] === "object" &&
140
+ editorItem[mappingKey] !== null;
141
+ const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
142
+ if (colorMatchKey) {
143
+ if (isUsingMapping) {
144
+ return Object.assign(Object.assign({}, finalProps), { fill: (_b = (_a = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : finalProps.fill });
145
+ }
146
+ else {
147
+ return Object.assign(Object.assign({}, finalProps), { fill: (_d = (_c = colorMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]))) === null || _c === void 0 ? void 0 : _c.color) !== null && _d !== void 0 ? _d : finalProps.fill });
148
+ }
149
+ }
150
+ return finalProps;
151
+ });
152
+ };
153
+ const [fingerCount, setFingerCount] = useState(0);
154
+ useEffect(() => {
155
+ const container = document.getElementById("workspace");
156
+ const handleTouchStart = (e) => {
157
+ const count = e.touches.length;
158
+ setFingerCount(count);
159
+ };
160
+ const handleTouchEnd = () => {
161
+ setFingerCount(0);
162
+ };
163
+ if (container) {
164
+ container.addEventListener("touchstart", handleTouchStart);
165
+ container.addEventListener("touchend", handleTouchEnd);
166
+ }
167
+ return () => {
168
+ if (container) {
169
+ container.removeEventListener("touchstart", handleTouchStart);
170
+ container.removeEventListener("touchend", handleTouchEnd);
171
+ }
172
+ };
173
+ }, []);
174
+ return (_jsx("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef }, props.containerProps, { children: _jsx("svg", Object.assign({}, props.svgProps, {
175
+ // id="workspace"
176
+ ref: svgRef, width: "100%", height: "100%", viewBox: `${boundingBox.minX} ${boundingBox.minY} ${boundingBox.width} ${boundingBox.height}`, className: "h-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
177
+ background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
178
+ display: "block",
179
+ pointerEvents: "auto",
180
+ touchAction: "auto",
181
+ // touchAction: "pan-y",
182
+ }, children: _jsx(Layers, { mode: "view", components: [
183
+ ...extraComponentsEditor,
184
+ ...renderElements(componentsEditor, mappingKey, colorMatchKey),
185
+ ], onClick: handleSelectComponent, selectedTable: selectedTable, selectedTableColor: selectedTableColor }) })) })));
186
+ };
187
+ export default LayerView;
@@ -85,5 +85,5 @@ export interface LayerViewProps<TMeta = undefined> {
85
85
  defaultBoundingBox?: PropertiesProps;
86
86
  viewOnly?: boolean;
87
87
  }
88
- declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => React.JSX.Element;
88
+ declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
89
89
  export default LayerView;