seat-editor 2.1.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/app/constant.d.ts +232 -0
  2. package/dist/app/constant.js +3683 -3045
  3. package/dist/app/new-board/page.js +5 -6
  4. package/dist/app/only-view/chair.d.ts +1 -0
  5. package/dist/app/only-view/chair.js +4 -0
  6. package/dist/app/only-view/constant.d.ts +22 -2
  7. package/dist/app/only-view/constant.js +4 -4
  8. package/dist/app/only-view/page.js +74 -37
  9. package/dist/app/only-view/user.d.ts +1 -0
  10. package/dist/app/only-view/user.js +4 -0
  11. package/dist/components/layer-v3/index.d.ts +23 -4
  12. package/dist/components/layer-v3/index.js +329 -146
  13. package/dist/components/layer-v4/index.d.ts +20 -0
  14. package/dist/components/layer-v4/index.js +445 -0
  15. package/dist/components/lib/index.d.ts +1 -1
  16. package/dist/components/lib/index.js +1 -1
  17. package/dist/features/board/index.js +1 -1
  18. package/dist/features/board-v2/index.js +1 -1
  19. package/dist/features/board-v3/board-slice.d.ts +1 -0
  20. package/dist/features/board-v3/board-slice.js +26 -3
  21. package/dist/features/board-v3/constant.d.ts +5 -0
  22. package/dist/features/board-v3/constant.js +5 -0
  23. package/dist/features/board-v3/index copy.d.ts +47 -0
  24. package/dist/features/board-v3/index copy.js +2073 -0
  25. package/dist/features/board-v3/index.js +1409 -647
  26. package/dist/features/board-v3/polygon.d.ts +28 -0
  27. package/dist/features/board-v3/polygon.js +109 -0
  28. package/dist/features/board-v3/rect.d.ts +9 -0
  29. package/dist/features/board-v3/rect.js +152 -0
  30. package/dist/features/board-v3/resize-element.d.ts +12 -0
  31. package/dist/features/board-v3/resize-element.js +40 -0
  32. package/dist/features/board-v3/utils.d.ts +162 -0
  33. package/dist/features/board-v3/utils.js +787 -0
  34. package/dist/features/package/index.js +1 -1
  35. package/dist/features/panel/index.js +130 -20
  36. package/dist/features/panel/panel-slice.d.ts +5 -0
  37. package/dist/features/panel/panel-slice.js +15 -0
  38. package/dist/features/panel/select-tool.js +11 -1
  39. package/dist/features/panel/selected-group.d.ts +2 -0
  40. package/dist/features/panel/selected-group.js +7 -0
  41. package/dist/features/panel/table-seat-square.d.ts +2 -0
  42. package/dist/features/panel/table-seat-square.js +9 -0
  43. package/dist/features/side-tool/index.js +13 -6
  44. package/dist/features/view-only/index.js +0 -1
  45. package/dist/features/view-only-2/index.js +0 -1
  46. package/dist/features/view-only-3/index.d.ts +68 -0
  47. package/dist/features/view-only-3/index.js +510 -0
  48. package/dist/features/view-only-3/utils.d.ts +1 -0
  49. package/dist/features/view-only-3/utils.js +3 -0
  50. package/dist/seat-editor.css +1 -1
  51. package/dist/utils/constant.d.ts +1 -0
  52. package/dist/utils/constant.js +11 -0
  53. package/dist/utils/format.d.ts +2 -0
  54. package/dist/utils/format.js +29 -0
  55. package/package.json +3 -1
  56. package/dist/features/view/index.d.ts +0 -19
  57. package/dist/features/view/index.js +0 -221
@@ -1,221 +0,0 @@
1
- "use client";
2
- "use client";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { useEffect, useMemo, useRef, useState } from "react";
5
- import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
6
- import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
7
- import Layers from "../../components/layer";
8
- import { isEqual } from "lodash";
9
- const LayerView = (props) => {
10
- const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, selectedTableColor, colorMatchKey, statusKey, defaultBackground, } = props;
11
- const transformRef = useRef(null);
12
- const containerRef = useRef(null);
13
- const svgRef = useRef(null);
14
- const [scale, setScale] = useState(1);
15
- const [selectedTable, setSelectedTable] = useState(null);
16
- const { components: componentsEditor, extraComponents: extraComponentsEditor, } = useAppSelector((state) => state.board);
17
- const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
18
- const dispatch = useAppDispatch();
19
- const convertComponentProps = () => {
20
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
21
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
22
- return Object.assign({}, item === null || item === void 0 ? void 0 : item[mappingKey]);
23
- }
24
- return item;
25
- });
26
- return mappingData;
27
- };
28
- useEffect(() => {
29
- if (componentProps) {
30
- if (!isEqual(componentsEditor, convertComponentProps())) {
31
- let mappingData = componentProps === null || componentProps === void 0 ? void 0 : componentProps.map((item) => {
32
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[props.mappingKey])) {
33
- return Object.assign({}, item[props.mappingKey]);
34
- }
35
- return item;
36
- });
37
- dispatch({
38
- type: "board/setNewComponents",
39
- payload: mappingData,
40
- });
41
- }
42
- }
43
- if (extraComponentsEditor) {
44
- if (!isEqual(extraComponentsEditor, extraComponentProps)) {
45
- dispatch({
46
- type: "board/setNewExtraComponents",
47
- payload: extraComponentProps,
48
- });
49
- }
50
- }
51
- if (defaultBackground) {
52
- dispatch({
53
- type: "board/setBackgroundColor",
54
- payload: defaultBackground,
55
- });
56
- }
57
- }, [componentProps, extraComponentProps, defaultBackground]);
58
- useEffect(() => {
59
- onCurrentStateChange &&
60
- onCurrentStateChange({
61
- components: componentsEditor,
62
- extraComponents: extraComponentsEditor,
63
- });
64
- }, [componentsEditor, extraComponentsEditor]);
65
- const handleSelectComponent = (items) => {
66
- const find = componentsEditor.find((item) => {
67
- if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
68
- return item[mappingKey].id === (items === null || items === void 0 ? void 0 : items.id);
69
- }
70
- return (item === null || item === void 0 ? void 0 : item.id) === (items === null || items === void 0 ? void 0 : items.id);
71
- });
72
- onSelectComponent && onSelectComponent(find);
73
- setSelectedTable(find);
74
- };
75
- const boundingBox = useMemo(() => {
76
- var _a, _b, _c, _d, _e, _f, _g;
77
- if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
78
- return { minX: 0, minY: 0, width: 500, height: 500 };
79
- }
80
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
81
- componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_) => {
82
- var _a, _b, _c, _d;
83
- const hasMappingKey = mappingKey && _[mappingKey];
84
- let values = hasMappingKey ? _[mappingKey] : _;
85
- if (!values)
86
- return;
87
- if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("square")) {
88
- minX = Math.min(minX, values.x);
89
- minY = Math.min(minY, values.y);
90
- maxX = Math.max(maxX, values.x + values.width);
91
- maxY = Math.max(maxY, values.y + values.height);
92
- }
93
- if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("circle")) {
94
- minX = Math.min(minX, values.x);
95
- minY = Math.min(minY, values.y);
96
- maxX = Math.max(maxX, values.x + values.width);
97
- maxY = Math.max(maxY, values.y + values.height);
98
- }
99
- if ((_c = values === null || values === void 0 ? void 0 : values.shape) === null || _c === void 0 ? void 0 : _c.includes("table-seat-circle")) {
100
- minX = Math.min(minX, values.x);
101
- minY = Math.min(minY, values.y);
102
- maxX = Math.max(maxX, values.x + values.width);
103
- maxY = Math.max(maxY, values.y + values.height);
104
- }
105
- if ((_d = values === null || values === void 0 ? void 0 : values.shape) === null || _d === void 0 ? void 0 : _d.includes("image-table")) {
106
- minX = Math.min(minX, values.x);
107
- minY = Math.min(minY, values.y);
108
- maxX = Math.max(maxX, values.x + values.width);
109
- maxY = Math.max(maxY, values.y + values.height);
110
- }
111
- });
112
- extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
113
- var _a, _b;
114
- if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("background")) {
115
- minX = Math.min(minX, values.x);
116
- minY = Math.min(minY, values.y);
117
- maxX = Math.max(maxX, values.x + values.width);
118
- maxY = Math.max(maxY, values.y + values.height);
119
- }
120
- if ((_b = values === null || values === void 0 ? void 0 : values.shape) === null || _b === void 0 ? void 0 : _b.includes("text")) {
121
- minX = Math.min(minX, values.x);
122
- minY = Math.min(minY, values.y);
123
- maxX = Math.max(maxX, values.x + values.width);
124
- maxY = Math.max(maxY, values.y + values.height);
125
- }
126
- });
127
- let backgroundHasOne = false;
128
- if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
129
- ((_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"))) {
130
- backgroundHasOne = true;
131
- minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
132
- minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
133
- maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
134
- maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
135
- }
136
- 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)) {
137
- minX = minX - minX * 0.5;
138
- minY = minY - minY * 0.5;
139
- }
140
- return {
141
- minX: backgroundHasOne ? minX : minX - minX * 0.5,
142
- minY: backgroundHasOne ? minY : minY - minY * 0.5,
143
- width: maxX,
144
- height: maxY,
145
- };
146
- }, [componentsEditor, extraComponentsEditor]);
147
- const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
148
- return elementEditor === null || elementEditor === void 0 ? void 0 : elementEditor.map((editorItem, i) => {
149
- var _a, _b, _c, _d;
150
- const isUsingMapping = mappingKey &&
151
- typeof editorItem[mappingKey] === "object" &&
152
- editorItem[mappingKey] !== null;
153
- const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
154
- if (colorMatchKey) {
155
- if (isUsingMapping) {
156
- 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 });
157
- }
158
- else {
159
- 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 });
160
- }
161
- }
162
- return finalProps;
163
- });
164
- };
165
- const [fingerCount, setFingerCount] = useState(0);
166
- useEffect(() => {
167
- const container = document.getElementById("workspace");
168
- const handleTouchStart = (e) => {
169
- const count = e.touches.length;
170
- setFingerCount(count);
171
- };
172
- const handleTouchEnd = () => {
173
- setFingerCount(0);
174
- };
175
- if (container) {
176
- container.addEventListener("touchstart", handleTouchStart);
177
- container.addEventListener("touchend", handleTouchEnd);
178
- }
179
- return () => {
180
- if (container) {
181
- container.removeEventListener("touchstart", handleTouchStart);
182
- container.removeEventListener("touchend", handleTouchEnd);
183
- }
184
- };
185
- }, []);
186
- return (_jsx("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: {
187
- height: "100vh",
188
- overflow: "auto",
189
- WebkitOverflowScrolling: "touch",
190
- touchAction: "pan-y",
191
- } }, props.containerProps, { children: _jsx(TransformWrapper, Object.assign({ 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, children: _jsx(TransformComponent, { wrapperStyle: {
205
- width: "100%",
206
- height: "100%",
207
- overflow: "visible",
208
- }, contentStyle: {
209
- width: "100%",
210
- height: "100%",
211
- }, 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: {
212
- background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
213
- display: "block",
214
- pointerEvents: "auto",
215
- // touchAction: "pan-y",
216
- }, children: _jsx(Layers, { mode: "view", components: [
217
- ...((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) > 0 ? extraComponentsEditor : []),
218
- ...renderElements(componentsEditor, mappingKey, colorMatchKey),
219
- ], onClick: handleSelectComponent, selectedTable: selectedTable, selectedTableColor: selectedTableColor }) })) }) })) })));
220
- };
221
- export default LayerView;