seat-editor 2.0.0 → 2.1.1

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 (101) hide show
  1. package/package.json +1 -1
  2. package/dist/app/constant.d.ts +0 -101
  3. package/dist/app/constant.js +0 -3064
  4. package/dist/app/layout.d.ts +0 -6
  5. package/dist/app/layout.jsx +0 -27
  6. package/dist/app/new-board/page.d.ts +0 -1
  7. package/dist/app/new-board/page.jsx +0 -56
  8. package/dist/app/old-board/page.d.ts +0 -3
  9. package/dist/app/old-board/page.jsx +0 -510
  10. package/dist/app/only-view/constant.d.ts +0 -40
  11. package/dist/app/only-view/constant.js +0 -1336
  12. package/dist/app/only-view/page.d.ts +0 -2
  13. package/dist/app/only-view/page.jsx +0 -40
  14. package/dist/app/page.d.ts +0 -2
  15. package/dist/app/page.jsx +0 -13
  16. package/dist/app/test/page.d.ts +0 -2
  17. package/dist/app/test/page.jsx +0 -45
  18. package/dist/app/v2/page.d.ts +0 -2
  19. package/dist/app/v2/page.jsx +0 -13
  20. package/dist/components/button-tools/index.d.ts +0 -11
  21. package/dist/components/button-tools/index.jsx +0 -17
  22. package/dist/components/form-tools/label.d.ts +0 -2
  23. package/dist/components/form-tools/label.jsx +0 -44
  24. package/dist/components/form-tools/shape.d.ts +0 -4
  25. package/dist/components/form-tools/shape.jsx +0 -66
  26. package/dist/components/input/number-indicator.d.ts +0 -7
  27. package/dist/components/input/number-indicator.jsx +0 -36
  28. package/dist/components/joystick/index.d.ts +0 -12
  29. package/dist/components/joystick/index.jsx +0 -49
  30. package/dist/components/layer/index.d.ts +0 -19
  31. package/dist/components/layer/index.jsx +0 -383
  32. package/dist/components/layer-v2/index.d.ts +0 -19
  33. package/dist/components/layer-v2/index.jsx +0 -370
  34. package/dist/components/layer-v3/index.d.ts +0 -19
  35. package/dist/components/layer-v3/index.jsx +0 -418
  36. package/dist/components/lib/index.d.ts +0 -8
  37. package/dist/components/lib/index.jsx +0 -33
  38. package/dist/components/modal-preview/index.d.ts +0 -4
  39. package/dist/components/modal-preview/index.jsx +0 -11
  40. package/dist/features/board/board-slice.d.ts +0 -14
  41. package/dist/features/board/board-slice.js +0 -52
  42. package/dist/features/board/index.d.ts +0 -6
  43. package/dist/features/board/index.jsx +0 -725
  44. package/dist/features/board-v2/board-slice.d.ts +0 -14
  45. package/dist/features/board-v2/board-slice.js +0 -52
  46. package/dist/features/board-v2/index.d.ts +0 -8
  47. package/dist/features/board-v2/index.jsx +0 -869
  48. package/dist/features/board-v3/board-slice.d.ts +0 -16
  49. package/dist/features/board-v3/board-slice.js +0 -83
  50. package/dist/features/board-v3/history-slice.d.ts +0 -27
  51. package/dist/features/board-v3/history-slice.js +0 -27
  52. package/dist/features/board-v3/index.d.ts +0 -8
  53. package/dist/features/board-v3/index.jsx +0 -863
  54. package/dist/features/navbar/index.d.ts +0 -2
  55. package/dist/features/navbar/index.jsx +0 -5
  56. package/dist/features/package/index.d.ts +0 -31
  57. package/dist/features/package/index.jsx +0 -114
  58. package/dist/features/panel/index.d.ts +0 -11
  59. package/dist/features/panel/index.jsx +0 -138
  60. package/dist/features/panel/panel-slice.d.ts +0 -16
  61. package/dist/features/panel/panel-slice.js +0 -31
  62. package/dist/features/panel/select-tool.d.ts +0 -6
  63. package/dist/features/panel/select-tool.jsx +0 -60
  64. package/dist/features/panel/square-circle-tool.d.ts +0 -2
  65. package/dist/features/panel/square-circle-tool.jsx +0 -10
  66. package/dist/features/panel/table-seat-circle.d.ts +0 -2
  67. package/dist/features/panel/table-seat-circle.jsx +0 -31
  68. package/dist/features/panel/text-tool.d.ts +0 -2
  69. package/dist/features/panel/text-tool.jsx +0 -26
  70. package/dist/features/panel/upload-tool.d.ts +0 -14
  71. package/dist/features/panel/upload-tool.jsx +0 -152
  72. package/dist/features/side-tool/index.d.ts +0 -8
  73. package/dist/features/side-tool/index.jsx +0 -371
  74. package/dist/features/side-tool/side-tool-slice.d.ts +0 -16
  75. package/dist/features/side-tool/side-tool-slice.js +0 -28
  76. package/dist/features/theme/theme-slice.d.ts +0 -12
  77. package/dist/features/theme/theme-slice.js +0 -15
  78. package/dist/features/view/index.d.ts +0 -19
  79. package/dist/features/view/index.jsx +0 -228
  80. package/dist/features/view-only/index.d.ts +0 -19
  81. package/dist/features/view-only/index.jsx +0 -206
  82. package/dist/features/view-only-2/index.d.ts +0 -19
  83. package/dist/features/view-only-2/index.jsx +0 -181
  84. package/dist/hooks/use-redux.d.ts +0 -4
  85. package/dist/hooks/use-redux.js +0 -3
  86. package/dist/index.d.ts +0 -8
  87. package/dist/index.js +0 -8
  88. package/dist/libs/middleware.d.ts +0 -2
  89. package/dist/libs/middleware.js +0 -5
  90. package/dist/libs/rootReducer.d.ts +0 -12
  91. package/dist/libs/rootReducer.js +0 -14
  92. package/dist/libs/store.d.ts +0 -18
  93. package/dist/libs/store.js +0 -19
  94. package/dist/provider/antd-provider.d.ts +0 -4
  95. package/dist/provider/antd-provider.jsx +0 -46
  96. package/dist/provider/redux-provider.d.ts +0 -3
  97. package/dist/provider/redux-provider.jsx +0 -6
  98. package/dist/provider/store-provider.d.ts +0 -4
  99. package/dist/provider/store-provider.jsx +0 -10
  100. package/dist/utils/injectCss.d.ts +0 -1
  101. package/dist/utils/injectCss.js +0 -13
@@ -1,228 +0,0 @@
1
- "use client";
2
- "use client";
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
- import { isEqual } from "lodash";
8
- const LayerView = (props) => {
9
- const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
10
- const transformRef = useRef(null);
11
- const containerRef = useRef(null);
12
- const svgRef = useRef(null);
13
- const [scale, setScale] = useState(1);
14
- const [selectedTable, setSelectedTable] = useState(null);
15
- const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
16
- const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
17
- const dispatch = useAppDispatch();
18
- const convertComponentProps = () => {
19
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
20
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
21
- return Object.assign({}, item === null || item === void 0 ? void 0 : item[mappingKey]);
22
- }
23
- return item;
24
- });
25
- return mappingData;
26
- };
27
- useEffect(() => {
28
- if (componentProps) {
29
- if (!isEqual(componentsEditor, convertComponentProps())) {
30
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
31
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
32
- return Object.assign({}, item[props.mappingKey]);
33
- }
34
- return item;
35
- });
36
- dispatch({
37
- type: "board/setNewComponents",
38
- payload: mappingData,
39
- });
40
- }
41
- }
42
- if (extraComponentsEditor) {
43
- if (!isEqual(extraComponentsEditor, extraComponentProps)) {
44
- dispatch({
45
- type: "board/setNewExtraComponents",
46
- payload: extraComponentProps,
47
- });
48
- }
49
- }
50
- if (defaultBackground) {
51
- dispatch({
52
- type: "board/setBackgroundColor",
53
- payload: defaultBackground,
54
- });
55
- }
56
- }, [componentProps, extraComponentProps, defaultBackground]);
57
- useEffect(() => {
58
- onCurrentStateChange &&
59
- onCurrentStateChange({
60
- components: componentsEditor,
61
- extraComponents: extraComponentsEditor,
62
- });
63
- }, [componentsEditor, extraComponentsEditor]);
64
- const handleSelectComponent = (items) => {
65
- const find = componentsEditor.find((item) => {
66
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
67
- return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
68
- }
69
- return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
70
- });
71
- onSelectComponent && onSelectComponent(find);
72
- setSelectedTable(find);
73
- };
74
- const boundingBox = useMemo(() => {
75
- var _a, _b, _c, _d, _e, _f, _g;
76
- if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
77
- return { minX: 0, minY: 0, width: 500, height: 500 };
78
- }
79
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
80
- componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
81
- var _a, _b, _c, _d;
82
- const hasMappingKey = mappingKey && _[mappingKey];
83
- let values = hasMappingKey ? _[mappingKey] : _;
84
- if (!values)
85
- return;
86
- if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
87
- minX = Math.min(minX, values.x);
88
- minY = Math.min(minY, values.y);
89
- maxX = Math.max(maxX, values.x + values.width);
90
- maxY = Math.max(maxY, values.y + values.height);
91
- }
92
- if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
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 ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
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
- if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
105
- minX = Math.min(minX, values.x);
106
- minY = Math.min(minY, values.y);
107
- maxX = Math.max(maxX, values.x + values.width);
108
- maxY = Math.max(maxY, values.y + values.height);
109
- }
110
- });
111
- extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
112
- var _a, _b;
113
- if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
114
- minX = Math.min(minX, values.x);
115
- minY = Math.min(minY, values.y);
116
- maxX = Math.max(maxX, values.x + values.width);
117
- maxY = Math.max(maxY, values.y + values.height);
118
- }
119
- if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
120
- minX = Math.min(minX, values.x);
121
- minY = Math.min(minY, values.y);
122
- maxX = Math.max(maxX, values.x + values.width);
123
- maxY = Math.max(maxY, values.y + values.height);
124
- }
125
- });
126
- let backgroundHasOne = false;
127
- if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
128
- ((_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"))) {
129
- backgroundHasOne = true;
130
- minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
131
- minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
132
- maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
133
- maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
134
- }
135
- 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)) {
136
- minX = minX - minX * 0.5;
137
- minY = minY - minY * 0.5;
138
- }
139
- return {
140
- minX: backgroundHasOne ? minX : minX - minX * 0.5,
141
- minY: backgroundHasOne ? minY : minY - minY * 0.5,
142
- width: maxX,
143
- height: maxY,
144
- };
145
- }, [componentsEditor, extraComponentsEditor]);
146
- const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
147
- return elementEditor === null || elementEditor === void 0 ? void 0 : elementEditor.map((editorItem, i) => {
148
- var _a, _b, _c, _d;
149
- const isUsingMapping = mappingKey &&
150
- typeof editorItem[mappingKey] === "object" &&
151
- editorItem[mappingKey] !== null;
152
- const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
153
- if (colorMatchKey) {
154
- if (isUsingMapping) {
155
- 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 });
156
- }
157
- else {
158
- 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 });
159
- }
160
- }
161
- return finalProps;
162
- });
163
- };
164
- const [fingerCount, setFingerCount] = useState(0);
165
- useEffect(() => {
166
- const container = document.getElementById("workspace");
167
- const handleTouchStart = (e) => {
168
- const count = e.touches.length;
169
- setFingerCount(count);
170
- };
171
- const handleTouchEnd = () => {
172
- setFingerCount(0);
173
- };
174
- if (container) {
175
- container.addEventListener("touchstart", handleTouchStart);
176
- container.addEventListener("touchend", handleTouchEnd);
177
- }
178
- return () => {
179
- if (container) {
180
- container.removeEventListener("touchstart", handleTouchStart);
181
- container.removeEventListener("touchend", handleTouchEnd);
182
- }
183
- };
184
- }, []);
185
- return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
186
- height: "100vh",
187
- overflow: "auto",
188
- WebkitOverflowScrolling: "touch",
189
- touchAction: "pan-y",
190
- }} {...props.containerProps}>
191
- <TransformWrapper ref={transformRef} {...props.transformProps} disabled={fingerCount === 1 && scale === 1} disablePadding={true}
192
- // panning={{
193
- // disabled: false,
194
- // velocityDisabled: true,
195
- // }}
196
- // limitToBounds={false}
197
- // doubleClick={{ disabled: true }}
198
- // pinch={{ disabled: false }}
199
- // wheel={{ disabled: true }}
200
- // disabled={true}
201
- // disablePadding={true}
202
- centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1}
203
- // pinch={{ step: 1 }}
204
- smooth={true}>
205
- <TransformComponent wrapperStyle={{
206
- width: "100%",
207
- height: "100%",
208
- overflow: "visible",
209
- }} contentStyle={{
210
- width: "100%",
211
- height: "100%",
212
- }}>
213
- <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={{
214
- background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
215
- display: "block",
216
- pointerEvents: "auto",
217
- // touchAction: "pan-y",
218
- }}>
219
- <Layers mode="view" components={[
220
- ...((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) > 0 ? extraComponentsEditor : []),
221
- ...renderElements(componentsEditor, mappingKey, colorMatchKey),
222
- ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
223
- </svg>
224
- </TransformComponent>
225
- </TransformWrapper>
226
- </div>);
227
- };
228
- export default LayerView;
@@ -1,19 +0,0 @@
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;
@@ -1,206 +0,0 @@
1
- "use client";
2
- "use client";
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 (<div 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}>
169
- <TransformWrapper ref={transformRef} {...props.transformProps} disabled={fingerCount === 1 && scale === 1} disablePadding={true}
170
- // panning={{
171
- // disabled: false,
172
- // velocityDisabled: true,
173
- // }}
174
- // limitToBounds={false}
175
- // doubleClick={{ disabled: true }}
176
- // pinch={{ disabled: false }}
177
- // wheel={{ disabled: true }}
178
- // disabled={true}
179
- // disablePadding={true}
180
- centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1}
181
- // pinch={{ step: 1 }}
182
- smooth={true}>
183
- <TransformComponent wrapperStyle={{
184
- width: "100%",
185
- height: "100%",
186
- overflow: "visible",
187
- }} contentStyle={{
188
- width: "100%",
189
- height: "100%",
190
- }}>
191
- <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={{
192
- background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
193
- display: "block",
194
- pointerEvents: "auto",
195
- // touchAction: "pan-y",
196
- }}>
197
- <Layers mode="view" components={[
198
- ...extraComponentsEditor,
199
- ...renderElements(componentsEditor, mappingKey, colorMatchKey),
200
- ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
201
- </svg>
202
- </TransformComponent>
203
- </TransformWrapper>
204
- </div>);
205
- };
206
- export default LayerView;
@@ -1,19 +0,0 @@
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;
@@ -1,181 +0,0 @@
1
- "use client";
2
- "use client";
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
- return {
119
- minX: backgroundHasOne ? minX : minX - minX * 0.5,
120
- minY: backgroundHasOne ? minY : minY - minY * 0.5,
121
- width: maxX,
122
- height: maxY,
123
- };
124
- }, [componentsEditor, extraComponentsEditor]);
125
- const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
126
- return elementEditor.map((editorItem, i) => {
127
- var _a, _b, _c, _d;
128
- const isUsingMapping = mappingKey &&
129
- typeof editorItem[mappingKey] === "object" &&
130
- editorItem[mappingKey] !== null;
131
- const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
132
- if (colorMatchKey) {
133
- if (isUsingMapping) {
134
- 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 });
135
- }
136
- else {
137
- 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 });
138
- }
139
- }
140
- return finalProps;
141
- });
142
- };
143
- const [fingerCount, setFingerCount] = useState(0);
144
- useEffect(() => {
145
- const container = document.getElementById("workspace");
146
- const handleTouchStart = (e) => {
147
- const count = e.touches.length;
148
- setFingerCount(count);
149
- };
150
- const handleTouchEnd = () => {
151
- setFingerCount(0);
152
- };
153
- if (container) {
154
- container.addEventListener("touchstart", handleTouchStart);
155
- container.addEventListener("touchend", handleTouchEnd);
156
- }
157
- return () => {
158
- if (container) {
159
- container.removeEventListener("touchstart", handleTouchStart);
160
- container.removeEventListener("touchend", handleTouchEnd);
161
- }
162
- };
163
- }, []);
164
- return (<div className="relative w-full h-full flex-1" ref={containerRef} {...props.containerProps}>
165
- <svg {...props.svgProps}
166
- // id="workspace"
167
- 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={{
168
- background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
169
- display: "block",
170
- pointerEvents: "auto",
171
- touchAction: "auto",
172
- // touchAction: "pan-y",
173
- }}>
174
- <Layers mode="view" components={[
175
- ...extraComponentsEditor,
176
- ...renderElements(componentsEditor, mappingKey, colorMatchKey),
177
- ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
178
- </svg>
179
- </div>);
180
- };
181
- export default LayerView;
@@ -1,4 +0,0 @@
1
- import { TypedUseSelectorHook } from "react-redux";
2
- import type { RootState, AppDispatch } from "../libs/store";
3
- export declare const useAppDispatch: () => AppDispatch;
4
- export declare const useAppSelector: TypedUseSelectorHook<RootState>;
@@ -1,3 +0,0 @@
1
- import { useDispatch, useSelector } from "react-redux";
2
- export const useAppDispatch = useDispatch;
3
- export const useAppSelector = useSelector;