seat-editor 1.6.11 → 1.6.13

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 (42) hide show
  1. package/dist/app/test/page.d.ts +1 -0
  2. package/dist/app/test/page.js +43 -0
  3. package/dist/app/v2/page.d.ts +2 -0
  4. package/dist/app/v2/page.js +8 -0
  5. package/dist/components/layer-v2/index.d.ts +19 -0
  6. package/dist/components/layer-v2/index.js +295 -0
  7. package/dist/features/board/index.js +2 -2
  8. package/dist/features/board-v2/board-slice.d.ts +14 -0
  9. package/dist/features/board-v2/board-slice.js +52 -0
  10. package/dist/features/board-v2/index.d.ts +6 -0
  11. package/dist/features/{board/index.jsx → board-v2/index.js} +40 -100
  12. package/dist/features/package/index.js +1 -1
  13. package/dist/features/panel/index.js +0 -2
  14. package/dist/features/side-tool/index.js +13 -1
  15. package/package.json +1 -1
  16. package/dist/app/layout.jsx +0 -27
  17. package/dist/app/new-board/page.jsx +0 -53
  18. package/dist/app/old-board/page.jsx +0 -510
  19. package/dist/app/only-view/page.jsx +0 -40
  20. package/dist/app/page.jsx +0 -13
  21. package/dist/components/button-tools/index.jsx +0 -17
  22. package/dist/components/form-tools/label.jsx +0 -44
  23. package/dist/components/form-tools/shape.jsx +0 -66
  24. package/dist/components/input/number-indicator.jsx +0 -36
  25. package/dist/components/joystick/index.jsx +0 -49
  26. package/dist/components/layer/index.jsx +0 -383
  27. package/dist/components/lib/index.jsx +0 -33
  28. package/dist/components/modal-preview/index.jsx +0 -11
  29. package/dist/features/navbar/index.jsx +0 -5
  30. package/dist/features/package/index.jsx +0 -114
  31. package/dist/features/panel/index.jsx +0 -115
  32. package/dist/features/panel/select-tool.jsx +0 -60
  33. package/dist/features/panel/square-circle-tool.jsx +0 -10
  34. package/dist/features/panel/table-seat-circle.jsx +0 -31
  35. package/dist/features/panel/text-tool.jsx +0 -26
  36. package/dist/features/panel/upload-tool.jsx +0 -152
  37. package/dist/features/side-tool/index.jsx +0 -298
  38. package/dist/features/view/index.jsx +0 -226
  39. package/dist/features/view-only/index.jsx +0 -204
  40. package/dist/provider/antd-provider.jsx +0 -46
  41. package/dist/provider/redux-provider.jsx +0 -6
  42. package/dist/provider/store-provider.jsx +0 -10
@@ -1,204 +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;
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
- 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
- minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
107
- minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
108
- maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
109
- maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
110
- }
111
- if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) < 1) {
112
- minX = minX - minX * 0.5;
113
- minY = minY - minY * 0.5;
114
- }
115
- return {
116
- minX,
117
- minY,
118
- width: maxX,
119
- height: maxY,
120
- };
121
- }, [componentsEditor, extraComponentsEditor]);
122
- const renderElements = (elementEditor, mappingKey, colorMatchKey) => {
123
- return elementEditor.map((editorItem, i) => {
124
- var _a, _b, _c, _d;
125
- const isUsingMapping = mappingKey &&
126
- typeof editorItem[mappingKey] === "object" &&
127
- editorItem[mappingKey] !== null;
128
- const finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
129
- if (colorMatchKey) {
130
- if (isUsingMapping) {
131
- 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 });
132
- }
133
- else {
134
- 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 });
135
- }
136
- }
137
- return finalProps;
138
- });
139
- };
140
- const [fingerCount, setFingerCount] = useState(0);
141
- useEffect(() => {
142
- const container = document.getElementById("workspace");
143
- const handleTouchStart = (e) => {
144
- const count = e.touches.length;
145
- setFingerCount(count);
146
- };
147
- const handleTouchEnd = () => {
148
- setFingerCount(0);
149
- };
150
- if (container) {
151
- container.addEventListener("touchstart", handleTouchStart);
152
- container.addEventListener("touchend", handleTouchEnd);
153
- }
154
- return () => {
155
- if (container) {
156
- container.removeEventListener("touchstart", handleTouchStart);
157
- container.removeEventListener("touchend", handleTouchEnd);
158
- }
159
- };
160
- }, []);
161
- return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
162
- height: "100vh",
163
- overflow: "auto",
164
- WebkitOverflowScrolling: "touch",
165
- touchAction: "pan-y",
166
- }} {...props.containerProps}>
167
- <TransformWrapper ref={transformRef} {...props.transformProps} disabled={fingerCount === 1 && scale === 1} disablePadding={true}
168
- // panning={{
169
- // disabled: false,
170
- // velocityDisabled: true,
171
- // }}
172
- // limitToBounds={false}
173
- // doubleClick={{ disabled: true }}
174
- // pinch={{ disabled: false }}
175
- // wheel={{ disabled: true }}
176
- // disabled={true}
177
- // disablePadding={true}
178
- centerZoomedOut={true} onTransformed={({ state: { scale } }) => setScale(scale)} minScale={1} maxScale={1000} initialScale={1}
179
- // pinch={{ step: 1 }}
180
- smooth={true}>
181
- <TransformComponent wrapperStyle={{
182
- width: "100%",
183
- height: "100%",
184
- overflow: "visible",
185
- }} contentStyle={{
186
- width: "100%",
187
- height: "100%",
188
- }}>
189
- <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={{
190
- background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
191
- display: "block",
192
- pointerEvents: "auto",
193
- // touchAction: "pan-y",
194
- }}>
195
- <Layers mode="view" components={[
196
- ...extraComponentsEditor,
197
- ...renderElements(componentsEditor, mappingKey, colorMatchKey),
198
- ]} onClick={handleSelectComponent} selectedTable={selectedTable} selectedTableColor={selectedTableColor}/>
199
- </svg>
200
- </TransformComponent>
201
- </TransformWrapper>
202
- </div>);
203
- };
204
- export default LayerView;
@@ -1,46 +0,0 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import { ConfigProvider } from "antd";
4
- import { AntdRegistry } from "@ant-design/nextjs-registry";
5
- import { useAppSelector, useAppDispatch } from "../hooks/use-redux";
6
- export const AntdProvider = ({ children, themeColor }) => {
7
- const dispatch = useAppDispatch();
8
- const theme = useAppSelector((state) => state.theme);
9
- useEffect(() => {
10
- if (themeColor !== theme.primaryColor) {
11
- dispatch({
12
- type: "theme/setPrimaryColor",
13
- payload: themeColor
14
- });
15
- }
16
- }, [themeColor]);
17
- return (<AntdRegistry>
18
- <ConfigProvider theme={{
19
- token: {
20
- colorPrimary: themeColor,
21
- },
22
- // token: {
23
- // colorPrimary: theme.theme["--primary-color"],
24
- // colorPrimaryBorderHover: theme.theme["--primary-color"],
25
- // fontFamily: "var(--font-inter), sans-serif",
26
- // colorError: theme.theme["--danger"],
27
- // controlOutlineWidth: 4,
28
- // controlOutline: theme.theme["--surface-color"],
29
- // colorBgContainerDisabled: "var(--netral-03)",
30
- // colorTextPlaceholder: "var(--netral-06)",
31
- // },
32
- components: {
33
- Form: {
34
- labelFontSize: 14,
35
- fontWeightStrong: 500,
36
- itemMarginBottom: 12,
37
- },
38
- Button: {
39
- colorPrimary: themeColor
40
- }
41
- },
42
- }}>
43
- {children}
44
- </ConfigProvider>
45
- </AntdRegistry>);
46
- };
@@ -1,6 +0,0 @@
1
- "use client";
2
- import { store } from "../libs/store";
3
- import { Provider } from "react-redux";
4
- export const ReduxProvider = ({ children }) => {
5
- return <Provider store={store}>{children}</Provider>;
6
- };
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { ReduxProvider } from "./redux-provider";
3
- import { AntdProvider } from "./antd-provider";
4
- import { injectSeatEditorCSS } from "../utils/injectCss";
5
- export const StoreProvider = ({ children, themeColor = "red", }) => {
6
- injectSeatEditorCSS();
7
- return (<ReduxProvider>
8
- <AntdProvider themeColor={themeColor}>{children}</AntdProvider>
9
- </ReduxProvider>);
10
- };