seat-editor 3.3.35 → 3.3.37

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