seat-editor 3.3.13 → 3.3.15

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 (136) hide show
  1. package/dist/app/constant.d.ts +1 -0
  2. package/dist/app/constant.js +1 -0
  3. package/dist/app/layout.d.ts +6 -0
  4. package/dist/app/layout.jsx +27 -0
  5. package/dist/app/new-board/page.jsx +55 -0
  6. package/dist/app/old-board/page.d.ts +3 -0
  7. package/dist/app/old-board/page.jsx +510 -0
  8. package/dist/app/only-view/chair.d.ts +1 -0
  9. package/dist/app/only-view/chair.js +12 -0
  10. package/dist/app/only-view/constant.d.ts +60 -0
  11. package/dist/app/only-view/constant.js +1336 -0
  12. package/dist/app/only-view/page.jsx +248 -0
  13. package/dist/app/only-view/user.d.ts +1 -0
  14. package/dist/app/only-view/user.js +12 -0
  15. package/dist/app/page.d.ts +2 -0
  16. package/dist/app/page.jsx +13 -0
  17. package/dist/app/test/page.d.ts +2 -0
  18. package/dist/app/test/page.jsx +45 -0
  19. package/dist/app/v2/page.d.ts +2 -0
  20. package/dist/app/v2/page.jsx +13 -0
  21. package/dist/components/button-tools/index.d.ts +11 -0
  22. package/dist/components/button-tools/index.jsx +17 -0
  23. package/dist/components/form-tools/label.d.ts +2 -0
  24. package/dist/components/form-tools/label.jsx +63 -0
  25. package/dist/components/form-tools/shape.d.ts +8 -0
  26. package/dist/components/form-tools/shape.jsx +113 -0
  27. package/dist/components/input/number-indicator.d.ts +7 -0
  28. package/dist/components/input/number-indicator.jsx +36 -0
  29. package/dist/components/joystick/index.d.ts +12 -0
  30. package/dist/components/joystick/index.jsx +49 -0
  31. package/dist/components/layer/index.d.ts +19 -0
  32. package/dist/components/layer/index.jsx +383 -0
  33. package/dist/components/layer-v2/index.d.ts +19 -0
  34. package/dist/components/layer-v2/index.jsx +370 -0
  35. package/dist/components/layer-v3/index.d.ts +13 -0
  36. package/dist/components/layer-v3/index.jsx +631 -0
  37. package/dist/components/layer-v3/utils.d.ts +19 -0
  38. package/dist/components/layer-v3/utils.js +72 -0
  39. package/dist/components/layer-v4/constant.d.ts +60 -0
  40. package/dist/components/layer-v4/constant.js +93 -0
  41. package/dist/components/layer-v4/index.d.ts +24 -0
  42. package/dist/components/layer-v4/index.jsx +1046 -0
  43. package/dist/components/lib/index.d.ts +8 -0
  44. package/dist/components/lib/index.jsx +33 -0
  45. package/dist/components/modal-preview/index.d.ts +4 -0
  46. package/dist/components/modal-preview/index.jsx +11 -0
  47. package/dist/dto/event-handler.d.ts +1 -0
  48. package/dist/dto/event-handler.js +1 -0
  49. package/dist/dto/table.d.ts +80 -0
  50. package/dist/dto/table.js +1 -0
  51. package/dist/features/board/board-slice.d.ts +14 -0
  52. package/dist/features/board/board-slice.js +52 -0
  53. package/dist/features/board/index.d.ts +6 -0
  54. package/dist/features/board/index.jsx +725 -0
  55. package/dist/features/board-v2/board-slice.d.ts +14 -0
  56. package/dist/features/board-v2/board-slice.js +52 -0
  57. package/dist/features/board-v2/index.d.ts +8 -0
  58. package/dist/features/board-v2/index.jsx +869 -0
  59. package/dist/features/board-v3/board-slice.d.ts +19 -0
  60. package/dist/features/board-v3/board-slice.js +274 -0
  61. package/dist/features/board-v3/constant.d.ts +5 -0
  62. package/dist/features/board-v3/constant.js +5 -0
  63. package/dist/features/board-v3/history-slice.d.ts +27 -0
  64. package/dist/features/board-v3/history-slice.js +27 -0
  65. package/dist/features/board-v3/icons.d.ts +4 -0
  66. package/dist/features/board-v3/icons.jsx +100 -0
  67. package/dist/features/board-v3/index.d.ts +16 -0
  68. package/dist/features/board-v3/index.jsx +1678 -0
  69. package/dist/features/board-v3/polygon.d.ts +28 -0
  70. package/dist/features/board-v3/polygon.js +109 -0
  71. package/dist/features/board-v3/rect.d.ts +9 -0
  72. package/dist/features/board-v3/rect.js +152 -0
  73. package/dist/features/board-v3/resize-element.d.ts +12 -0
  74. package/dist/features/board-v3/resize-element.js +43 -0
  75. package/dist/features/board-v3/utils.d.ts +180 -0
  76. package/dist/features/board-v3/utils.js +1235 -0
  77. package/dist/features/navbar/index.d.ts +2 -0
  78. package/dist/features/navbar/index.jsx +5 -0
  79. package/dist/features/panel/index.d.ts +6 -0
  80. package/dist/features/panel/index.jsx +251 -0
  81. package/dist/features/panel/panel-slice.d.ts +23 -0
  82. package/dist/features/panel/panel-slice.js +46 -0
  83. package/dist/features/panel/select-tool.d.ts +6 -0
  84. package/dist/features/panel/select-tool.jsx +70 -0
  85. package/dist/features/panel/selected-group.d.ts +2 -0
  86. package/dist/features/panel/selected-group.jsx +93 -0
  87. package/dist/features/panel/square-circle-tool.d.ts +2 -0
  88. package/dist/features/panel/square-circle-tool.jsx +10 -0
  89. package/dist/features/panel/table-seat-circle.d.ts +2 -0
  90. package/dist/features/panel/table-seat-circle.jsx +36 -0
  91. package/dist/features/panel/table-seat-square.d.ts +2 -0
  92. package/dist/features/panel/table-seat-square.jsx +51 -0
  93. package/dist/features/panel/text-tool.d.ts +2 -0
  94. package/dist/features/panel/text-tool.jsx +57 -0
  95. package/dist/features/panel/upload-tool.d.ts +10 -0
  96. package/dist/features/panel/upload-tool.jsx +176 -0
  97. package/dist/features/panel/utils.d.ts +5 -0
  98. package/dist/features/panel/utils.js +47 -0
  99. package/dist/features/side-tool/index.d.ts +8 -0
  100. package/dist/features/side-tool/index.jsx +390 -0
  101. package/dist/features/side-tool/side-tool-slice.d.ts +16 -0
  102. package/dist/features/side-tool/side-tool-slice.js +28 -0
  103. package/dist/features/theme/theme-slice.d.ts +12 -0
  104. package/dist/features/theme/theme-slice.js +15 -0
  105. package/dist/features/view-only/index.d.ts +19 -0
  106. package/dist/features/view-only/index.jsx +205 -0
  107. package/dist/features/view-only-2/index.d.ts +19 -0
  108. package/dist/features/view-only-2/index.jsx +190 -0
  109. package/dist/features/view-only-3/index.d.ts +89 -0
  110. package/dist/features/view-only-3/index.jsx +590 -0
  111. package/dist/features/view-only-3/utils.d.ts +1 -0
  112. package/dist/features/view-only-3/utils.js +3 -0
  113. package/dist/hooks/use-redux.d.ts +4 -0
  114. package/dist/hooks/use-redux.js +3 -0
  115. package/dist/index.js +10 -0
  116. package/dist/libs/middleware.d.ts +2 -0
  117. package/dist/libs/middleware.js +5 -0
  118. package/dist/libs/rootReducer.d.ts +12 -0
  119. package/dist/libs/rootReducer.js +14 -0
  120. package/dist/libs/store.d.ts +18 -0
  121. package/dist/libs/store.js +19 -0
  122. package/dist/provider/antd-provider.d.ts +4 -0
  123. package/dist/provider/antd-provider.jsx +46 -0
  124. package/dist/provider/redux-provider.d.ts +3 -0
  125. package/dist/provider/redux-provider.jsx +6 -0
  126. package/dist/provider/store-provider.d.ts +4 -0
  127. package/dist/provider/store-provider.jsx +10 -0
  128. package/dist/utils/constant.d.ts +3 -0
  129. package/dist/utils/constant.js +13 -0
  130. package/dist/utils/format.d.ts +2 -0
  131. package/dist/utils/format.js +29 -0
  132. package/dist/utils/injectCss.d.ts +1 -0
  133. package/dist/utils/injectCss.js +13 -0
  134. package/dist/utils/regex.d.ts +3 -0
  135. package/dist/utils/regex.js +3 -0
  136. package/package.json +1 -1
@@ -0,0 +1,205 @@
1
+ "use client";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
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 && ((_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"))) {
106
+ backgroundHasOne = true;
107
+ minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
108
+ minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
109
+ maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
110
+ maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
111
+ }
112
+ 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)) {
113
+ minX = minX - minX * 0.5;
114
+ minY = minY - minY * 0.5;
115
+ }
116
+ return {
117
+ minX: backgroundHasOne ? minX : minX - minX * 0.5,
118
+ minY: backgroundHasOne ? minY : minY - minY * 0.5,
119
+ width: maxX,
120
+ height: maxY,
121
+ };
122
+ }, [componentsEditor, extraComponentsEditor]);
123
+ const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
124
+ return elementEditor.map((editorItem, i) => {
125
+ var _a, _b, _c, _d;
126
+ const isUsingMapping = mappingKey &&
127
+ typeof editorItem[mappingKey] === "object" &&
128
+ editorItem[mappingKey] !== null;
129
+ const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
130
+ if (colorMatchKey) {
131
+ if (isUsingMapping) {
132
+ 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 });
133
+ }
134
+ else {
135
+ 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 });
136
+ }
137
+ }
138
+ return finalProps;
139
+ });
140
+ };
141
+ const [fingerCount, setFingerCount] = useState(0);
142
+ useEffect(() => {
143
+ const container = document.getElementById("workspace");
144
+ const handleTouchStart = (e) => {
145
+ const count = e.touches.length;
146
+ setFingerCount(count);
147
+ };
148
+ const handleTouchEnd = () => {
149
+ setFingerCount(0);
150
+ };
151
+ if (container) {
152
+ container.addEventListener("touchstart", handleTouchStart);
153
+ container.addEventListener("touchend", handleTouchEnd);
154
+ }
155
+ return () => {
156
+ if (container) {
157
+ container.removeEventListener("touchstart", handleTouchStart);
158
+ container.removeEventListener("touchend", handleTouchEnd);
159
+ }
160
+ };
161
+ }, []);
162
+ return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
163
+ height: "100vh",
164
+ overflow: "auto",
165
+ WebkitOverflowScrolling: "touch",
166
+ touchAction: "pan-y",
167
+ }} {...props.containerProps}>
168
+ <TransformWrapper 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}>
182
+ <TransformComponent wrapperStyle={{
183
+ width: "100%",
184
+ height: "100%",
185
+ overflow: "visible",
186
+ }} contentStyle={{
187
+ width: "100%",
188
+ height: "100%",
189
+ }}>
190
+ <svg {...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={{
191
+ background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
192
+ display: "block",
193
+ pointerEvents: "auto",
194
+ // touchAction: "pan-y",
195
+ }}>
196
+ <Layers mode="view" components={[
197
+ ...extraComponentsEditor,
198
+ ...renderElements(componentsEditor, mappingKey, colorMatchKey),
199
+ ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
200
+ </svg>
201
+ </TransformComponent>
202
+ </TransformWrapper>
203
+ </div>);
204
+ };
205
+ export default LayerView;
@@ -0,0 +1,19 @@
1
+ export interface LayerViewProps {
2
+ componentProps?: any[];
3
+ extraComponentProps?: any[];
4
+ onCurrentStateChange?: (state: any) => void;
5
+ onSelectComponent?: (component: any) => void;
6
+ mappingKey?: string;
7
+ selectedTableColor?: string;
8
+ colorMatchKey?: {
9
+ color: string;
10
+ key: string;
11
+ }[];
12
+ statusKey: string;
13
+ defaultBackground?: string;
14
+ transformProps?: any;
15
+ containerProps?: any;
16
+ svgProps?: any;
17
+ }
18
+ declare const LayerView: (props: LayerViewProps) => import("react").JSX.Element;
19
+ export default LayerView;
@@ -0,0 +1,190 @@
1
+ "use client";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
4
+ import Layers from "../../components/layer";
5
+ const LayerView = (props) => {
6
+ const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
7
+ const transformRef = useRef(null);
8
+ const containerRef = useRef(null);
9
+ const svgRef = useRef(null);
10
+ const [scale, setScale] = useState(1);
11
+ const [selectedTable, setSelectedTable] = useState(null);
12
+ const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
13
+ const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
14
+ const dispatch = useAppDispatch();
15
+ useEffect(() => {
16
+ if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
17
+ dispatch({
18
+ type: "board/setNewComponents",
19
+ payload: componentProps,
20
+ });
21
+ }
22
+ if ((extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) > 0) {
23
+ dispatch({
24
+ type: "board/setNewExtraComponents",
25
+ payload: extraComponentProps,
26
+ });
27
+ }
28
+ if (defaultBackground) {
29
+ dispatch({
30
+ type: "board/setBackgroundColor",
31
+ payload: defaultBackground,
32
+ });
33
+ }
34
+ }, [componentProps, extraComponentProps, defaultBackground]);
35
+ useEffect(() => {
36
+ onCurrentStateChange &&
37
+ onCurrentStateChange({
38
+ components: componentsEditor,
39
+ extraComponents: extraComponentsEditor,
40
+ });
41
+ }, [componentsEditor, extraComponentsEditor]);
42
+ const handleSelectComponent = (items) => {
43
+ const find = componentsEditor.find((item) => {
44
+ if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
45
+ return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
46
+ }
47
+ return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
48
+ });
49
+ onSelectComponent && onSelectComponent(find);
50
+ setSelectedTable(find);
51
+ };
52
+ const boundingBox = useMemo(() => {
53
+ var _a, _b, _c, _d, _e, _f, _g;
54
+ if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
55
+ return { minX: 0, minY: 0, width: 500, height: 500 };
56
+ }
57
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
58
+ componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
59
+ var _a, _b, _c, _d;
60
+ let values = mappingKey ? _[mappingKey] : _;
61
+ if (!values)
62
+ return;
63
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
64
+ minX = Math.min(minX, values.x);
65
+ minY = Math.min(minY, values.y);
66
+ maxX = Math.max(maxX, values.x + values.width);
67
+ maxY = Math.max(maxY, values.y + values.height);
68
+ }
69
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
70
+ minX = Math.min(minX, values.x);
71
+ minY = Math.min(minY, values.y);
72
+ maxX = Math.max(maxX, values.x + values.width);
73
+ maxY = Math.max(maxY, values.y + values.height);
74
+ }
75
+ if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
76
+ minX = Math.min(minX, values.x);
77
+ minY = Math.min(minY, values.y);
78
+ maxX = Math.max(maxX, values.x + values.width);
79
+ maxY = Math.max(maxY, values.y + values.height);
80
+ }
81
+ if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
82
+ minX = Math.min(minX, values.x);
83
+ minY = Math.min(minY, values.y);
84
+ maxX = Math.max(maxX, values.x + values.width);
85
+ maxY = Math.max(maxY, values.y + values.height);
86
+ }
87
+ });
88
+ extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
89
+ var _a, _b;
90
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
91
+ minX = Math.min(minX, values.x);
92
+ minY = Math.min(minY, values.y);
93
+ maxX = Math.max(maxX, values.x + values.width);
94
+ maxY = Math.max(maxY, values.y + values.height);
95
+ }
96
+ if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
97
+ minX = Math.min(minX, values.x);
98
+ minY = Math.min(minY, values.y);
99
+ maxX = Math.max(maxX, values.x + values.width);
100
+ maxY = Math.max(maxY, values.y + values.height);
101
+ }
102
+ });
103
+ let backgroundHasOne = false;
104
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
105
+ ((_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"))) {
106
+ backgroundHasOne = true;
107
+ minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
108
+ minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
109
+ maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
110
+ maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
111
+ }
112
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1 &&
113
+ ["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
+ 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"); });
118
+ if (hasBoundingBox) {
119
+ 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"); });
120
+ return {
121
+ minX: findBoundingBox.x,
122
+ minY: findBoundingBox.y,
123
+ width: findBoundingBox.width,
124
+ height: findBoundingBox.height,
125
+ };
126
+ }
127
+ return {
128
+ minX: backgroundHasOne ? minX : minX - minX * 0.5,
129
+ minY: backgroundHasOne ? minY : minY - minY * 0.5,
130
+ width: maxX,
131
+ height: maxY,
132
+ };
133
+ }, [componentsEditor, extraComponentsEditor]);
134
+ const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
135
+ return elementEditor.map((editorItem, i) => {
136
+ var _a, _b, _c, _d;
137
+ const isUsingMapping = mappingKey &&
138
+ typeof editorItem[mappingKey] === "object" &&
139
+ editorItem[mappingKey] !== null;
140
+ const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
141
+ if (colorMatchKey) {
142
+ if (isUsingMapping) {
143
+ 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 });
144
+ }
145
+ else {
146
+ 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 });
147
+ }
148
+ }
149
+ return finalProps;
150
+ });
151
+ };
152
+ const [fingerCount, setFingerCount] = useState(0);
153
+ useEffect(() => {
154
+ const container = document.getElementById("workspace");
155
+ const handleTouchStart = (e) => {
156
+ const count = e.touches.length;
157
+ setFingerCount(count);
158
+ };
159
+ const handleTouchEnd = () => {
160
+ setFingerCount(0);
161
+ };
162
+ if (container) {
163
+ container.addEventListener("touchstart", handleTouchStart);
164
+ container.addEventListener("touchend", handleTouchEnd);
165
+ }
166
+ return () => {
167
+ if (container) {
168
+ container.removeEventListener("touchstart", handleTouchStart);
169
+ container.removeEventListener("touchend", handleTouchEnd);
170
+ }
171
+ };
172
+ }, []);
173
+ return (<div className="relative w-full h-full flex-1" ref={containerRef} {...props.containerProps}>
174
+ <svg {...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
+ }}>
183
+ <Layers mode="view" components={[
184
+ ...extraComponentsEditor,
185
+ ...renderElements(componentsEditor, mappingKey, colorMatchKey),
186
+ ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
187
+ </svg>
188
+ </div>);
189
+ };
190
+ export default LayerView;
@@ -0,0 +1,89 @@
1
+ import React, { CSSProperties, SVGAttributes } from "react";
2
+ import { ReactZoomPanPinchRef, ReactZoomPanPinchProps, ReactZoomPanPinchContentRef } from "react-zoom-pan-pinch";
3
+ import { PropertiesProps } from "../../dto/table";
4
+ import { EventHandleType } from "../../dto/event-handler";
5
+ export type TableGhost = {
6
+ table: PropertiesProps;
7
+ event: EventHandleType;
8
+ };
9
+ export type TableMatchKey = {
10
+ key: string | number;
11
+ properties?: PropertiesProps;
12
+ className?: string;
13
+ };
14
+ export type TableMatchEvent = {
15
+ event: EventHandleType;
16
+ properties: PropertiesProps;
17
+ };
18
+ export type ComponentProps<T = undefined> = PropertiesProps & T & {
19
+ [key: string]: PropertiesProps;
20
+ };
21
+ export type OnCurrentStateChange<TMeta = undefined> = ({ components, extraComponents, background, boundingBox, }: {
22
+ components: ComponentProps<TMeta>[];
23
+ extraComponents: ComponentProps[];
24
+ background: string;
25
+ boundingBox: PropertiesProps | null;
26
+ }) => void;
27
+ export type TransformProps = React.ForwardRefExoticComponent<Omit<ReactZoomPanPinchProps, "ref"> & React.RefAttributes<ReactZoomPanPinchContentRef>>;
28
+ export type RefLayerView = {
29
+ svgRef: SVGSVGElement;
30
+ transformRef: ReactZoomPanPinchRef;
31
+ containerRef: HTMLDivElement;
32
+ tableGhost: SVGGElement;
33
+ hoverUnderghost: ComponentProps;
34
+ };
35
+ export type TypeActionProps<TMeta = undefined> = {
36
+ targetTable: ComponentProps<TMeta>;
37
+ sourceTable: ComponentProps<TMeta>;
38
+ };
39
+ export interface LayerViewProps<TMeta = undefined> {
40
+ componentProps?: ComponentProps<TMeta>[];
41
+ extraComponentProps?: ComponentProps[];
42
+ onCurrentStateChange?: OnCurrentStateChange;
43
+ onSelectComponent?: (component: ComponentProps<TMeta>) => void;
44
+ mappingKey?: string;
45
+ tableMatchKey?: TableMatchKey[];
46
+ eventMatchTable?: TableMatchEvent[];
47
+ statusKey: string;
48
+ defaultBackground?: string;
49
+ transformProps?: ReactZoomPanPinchProps;
50
+ containerProps?: React.HTMLAttributes<HTMLDivElement>;
51
+ svgProps?: SVGAttributes<SVGSVGElement>;
52
+ ghostAttributes?: SVGAttributes<SVGGElement>;
53
+ iconTags?: {
54
+ icon: React.JSX.Element;
55
+ key: string;
56
+ }[];
57
+ privilegedTags?: {
58
+ key: string;
59
+ items: string[];
60
+ }[];
61
+ tooltipProps?: {
62
+ className?: string;
63
+ style?: CSSProperties;
64
+ minWidth?: number;
65
+ children: React.ReactNode;
66
+ };
67
+ dragTableBlockKey?: {
68
+ key: string;
69
+ value: string | number | null;
70
+ }[];
71
+ onRightClick?: (e: MouseEvent, component: ComponentProps<TMeta>) => void;
72
+ allowTooltip?: boolean;
73
+ onDrop?: (e: React.MouseEvent<SVGSVGElement>, component: TypeActionProps<TMeta>) => void;
74
+ onSwitch?: (e: MouseEvent, component: TypeActionProps<TMeta>) => void;
75
+ refs?: React.ForwardedRef<RefLayerView>;
76
+ viewStyles?: {
77
+ paddingTop?: number;
78
+ paddingLeft?: number;
79
+ paddingRight?: number;
80
+ paddingBottom?: number;
81
+ };
82
+ disabled?: boolean;
83
+ loadingRender?: {
84
+ state: boolean;
85
+ element: React.JSX.Element;
86
+ };
87
+ }
88
+ declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => React.JSX.Element;
89
+ export default LayerView;