seat-editor 3.5.16 → 3.5.18

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 (32) hide show
  1. package/dist/app/new-board/page.js +2 -1
  2. package/dist/app/new-board/page.jsx +2 -1
  3. package/dist/components/button-tools/index.jsx +1 -11
  4. package/dist/components/form-tools/label.js +1 -1
  5. package/dist/components/form-tools/label.jsx +1 -1
  6. package/dist/components/form-tools/shape.js +1 -1
  7. package/dist/components/form-tools/shape.jsx +1 -1
  8. package/dist/components/layer-v3/index.js +1 -1
  9. package/dist/components/layer-v3/index.jsx +2 -2
  10. package/dist/features/board-v3/board-slice.d.ts +7 -1
  11. package/dist/features/board-v3/board-slice.js +70 -191
  12. package/dist/features/board-v3/index.js +25 -17
  13. package/dist/features/board-v3/index.jsx +25 -17
  14. package/dist/features/board-v3/resize-element.d.ts +1 -0
  15. package/dist/features/board-v3/resize-element.js +3 -1
  16. package/dist/features/board-v3/utils.d.ts +1 -1
  17. package/dist/features/board-v3/utils.js +18 -4
  18. package/dist/features/panel/index.js +5 -1
  19. package/dist/features/panel/index.jsx +5 -1
  20. package/dist/features/panel/polygon.js +1 -1
  21. package/dist/features/panel/polygon.jsx +1 -1
  22. package/dist/features/panel/selected-group.js +1 -1
  23. package/dist/features/panel/selected-group.jsx +1 -1
  24. package/dist/features/panel/text-tool.js +9 -2
  25. package/dist/features/panel/text-tool.jsx +9 -2
  26. package/dist/features/panel/upload-group-tool.js +2 -0
  27. package/dist/features/panel/upload-group-tool.jsx +2 -0
  28. package/dist/features/panel/upload-tool.js +6 -3
  29. package/dist/features/panel/upload-tool.jsx +23 -20
  30. package/dist/features/side-tool/index.js +30 -4
  31. package/dist/features/side-tool/index.jsx +46 -5
  32. package/package.json +1 -1
@@ -92,7 +92,8 @@ export default function NewBoard() {
92
92
  if (setState === null || setState === void 0 ? void 0 : setState.extraComponents) {
93
93
  setExtraComponents((_c = setState.extraComponents) !== null && _c !== void 0 ? _c : []);
94
94
  }
95
- }, extraComponentProps: extraComponents, defaultBackground: backgroundColor,
95
+ }, extraComponentProps: extraComponents,
96
+ // defaultBackground={backgroundColor}
96
97
  // dragOnly={true}
97
98
  statusKey: "status",
98
99
  // action={async (action: any) => {
@@ -100,7 +100,8 @@ export default function NewBoard() {
100
100
  if (setState === null || setState === void 0 ? void 0 : setState.extraComponents) {
101
101
  setExtraComponents((_c = setState.extraComponents) !== null && _c !== void 0 ? _c : []);
102
102
  }
103
- }} extraComponentProps={extraComponents} defaultBackground={backgroundColor}
103
+ }} extraComponentProps={extraComponents}
104
+ // defaultBackground={backgroundColor}
104
105
  // dragOnly={true}
105
106
  statusKey="status"
106
107
  // action={async (action: any) => {
@@ -12,18 +12,8 @@ const ButtonTools = (props) => {
12
12
  maxWidth: "fit-content",
13
13
  },
14
14
  }} {...popoverProps}>
15
- {/* <Popover
16
- title={buttonProps?.name}
17
- trigger={"hover"}
18
- placement="right"
19
- styles={{
20
- body: {
21
- minWidth: "max-content",
22
- },
23
- }}
24
- > */}
15
+
25
16
  <Button {...buttonProps}/>
26
- {/* </Popover> */}
27
17
  </Popover>);
28
18
  };
29
19
  export default ButtonTools;
@@ -9,6 +9,6 @@ const SectionLabel = () => {
9
9
  if (Number.isNaN(num))
10
10
  return 0;
11
11
  return Math.min(360, Math.max(0, num));
12
- } }) })] }), _jsxs(Flex, { gap: 5, children: [_jsx(Form.Item, { name: [field.name, "fontSize"], label: "Size", children: _jsx(InputNumber, { suffix: "px" }) }), _jsx(Form.Item, { name: [field.name, "fontColor"], label: "Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] })] }, field.key))) })) }) }), _jsx("div", { className: "divider-dashed" })] }));
12
+ } }) })] }), _jsxs(Flex, { gap: 5, children: [_jsx(Form.Item, { name: [field.name, "fontSize"], label: "Size", children: _jsx(InputNumber, { suffix: "px" }) }), _jsx(Form.Item, { name: [field.name, "fontColor"], label: "Text Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] })] }, field.key))) })) }) }), _jsx("div", { className: "divider-dashed" })] }));
13
13
  };
14
14
  export default SectionLabel;
@@ -36,7 +36,7 @@ const SectionLabel = () => {
36
36
  <Form.Item name={[field.name, "fontSize"]} label="Size">
37
37
  <InputNumber suffix="px"/>
38
38
  </Form.Item>
39
- <Form.Item name={[field.name, "fontColor"]} label="Color" getValueFromEvent={(color) => color.toHexString()}>
39
+ <Form.Item name={[field.name, "fontColor"]} label="Text Color" getValueFromEvent={(color) => color.toHexString()}>
40
40
  <ColorPicker allowClear format="hex" defaultFormat="hex"/>
41
41
  </Form.Item>
42
42
  </Flex>
@@ -77,7 +77,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
77
77
  if (Number.isNaN(num))
78
78
  return 0;
79
79
  return Math.min(360, Math.max(0, num));
80
- } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
80
+ } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "Opacity Fill", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
81
81
  if (value === undefined || value === null || value === "")
82
82
  return null;
83
83
  const cleaned = value.replace(/[^0-9.]/g, "");
@@ -126,7 +126,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
126
126
  </Form.Item>
127
127
  </Flex>
128
128
  <Flex>
129
- <Form.Item label="opacity" name={"opacity"} className="w-full">
129
+ <Form.Item label="Opacity Fill" name={"opacity"} className="w-full">
130
130
  <InputNumber step={10} max={100} min={0} name="opacity" parser={(value) => {
131
131
  if (value === undefined || value === null || value === "")
132
132
  return null;
@@ -439,7 +439,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
439
439
  }) })] }) }, id));
440
440
  }
441
441
  case "text":
442
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", { width: width, height: height, fill: "transparent", opacity: opacity }), _jsx("text", Object.assign({ x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity"]), { children: text }))] }) }, id));
442
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"]))), _jsx("text", Object.assign({ "data-text-raw": `${id}-text`, x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity", "stroke", "strokeWidth"]), { children: text }))] }) }, id));
443
443
  case "image-table":
444
444
  case "background":
445
445
  return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: {
@@ -547,8 +547,8 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
547
547
  case "text":
548
548
  return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
549
549
  <g transform={`rotate(${rotation}, 0, 0)`}>
550
- <rect width={width} height={height} fill="transparent" opacity={opacity}/>
551
- <text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
550
+ <rect width={width} height={height} fill="transparent" opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}/>
551
+ <text data-text-raw={`${id}-text`} x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity", "stroke", "strokeWidth"])}>
552
552
  {text}
553
553
  </text>
554
554
  </g>
@@ -2,6 +2,12 @@ export interface Component {
2
2
  id: string;
3
3
  [key: string]: any;
4
4
  }
5
+ export interface HistoryEntry {
6
+ components: Component[];
7
+ extraComponents: Component[];
8
+ boundingBox: any;
9
+ backgroundColor: string;
10
+ }
5
11
  export interface InitialState {
6
12
  components: Component[];
7
13
  backgroundColor: string;
@@ -9,7 +15,7 @@ export interface InitialState {
9
15
  extraComponents: Component[];
10
16
  boundingBox: any;
11
17
  flagChange: boolean;
12
- historyChanges: any[];
18
+ historyChanges: HistoryEntry[];
13
19
  pointer: number;
14
20
  updateBy: "global" | "local";
15
21
  isShowTagType: "default" | "type-1" | "type-2";
@@ -1,5 +1,6 @@
1
1
  import { createSlice, current } from "@reduxjs/toolkit";
2
2
  import { forEach } from "lodash";
3
+ const MAX_HISTORY_CHANGES = 20;
3
4
  const initialState = {
4
5
  components: [],
5
6
  backgroundColor: "#FFFFFF",
@@ -12,7 +13,26 @@ const initialState = {
12
13
  updateBy: "global",
13
14
  isShowTagType: "default",
14
15
  };
15
- const MAX_HISTORY_CHANGES = 20;
16
+ // ─── Helper ──────────────────────────────────────────────────────────────────
17
+ const pushHistory = (state) => {
18
+ if (state.pointer < state.historyChanges.length - 1) {
19
+ state.historyChanges = state.historyChanges.slice(0, state.pointer + 1);
20
+ }
21
+ state.historyChanges.push({
22
+ components: [...state.components],
23
+ extraComponents: [...state.extraComponents],
24
+ boundingBox: state.boundingBox,
25
+ backgroundColor: state.backgroundColor,
26
+ });
27
+ if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
28
+ state.historyChanges.shift();
29
+ state.pointer = MAX_HISTORY_CHANGES - 1;
30
+ }
31
+ else {
32
+ state.pointer = state.historyChanges.length - 1;
33
+ }
34
+ };
35
+ // ─── Slice ───────────────────────────────────────────────────────────────────
16
36
  const boardSlice = createSlice({
17
37
  name: "board",
18
38
  initialState,
@@ -23,65 +43,34 @@ const boardSlice = createSlice({
23
43
  setUpdateBy: (state, action) => {
24
44
  state.updateBy = action.payload;
25
45
  },
46
+ setFlagChange: (state, action) => {
47
+ state.flagChange = action.payload;
48
+ },
26
49
  addComponent: (state, action) => {
27
- const currentPointer = state.pointer;
28
- const totalHistory = state.historyChanges.length;
29
- if (currentPointer < totalHistory) {
30
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
31
- }
32
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
33
- state.historyChanges.shift();
34
- }
35
- state.pointer += 1;
36
50
  state.components.push(action.payload);
37
- const component = state.components;
38
- const extraComponent = state.extraComponents;
39
- const boundingBox = state.boundingBox;
40
- const backgroundColor = state.backgroundColor;
41
- state.historyChanges.push({
42
- component,
43
- extraComponent,
44
- boundingBox,
45
- backgroundColor,
46
- });
51
+ pushHistory(state);
47
52
  },
48
53
  removeComponent: (state, action) => {
49
- state.components = state.components.filter((component) => (component === null || component === void 0 ? void 0 : component.id) !== action.payload.id);
54
+ state.components = state.components.filter((c) => c.id !== action.payload.id);
50
55
  },
51
56
  removeExtraComponent: (state, action) => {
52
- state.extraComponents = state.extraComponents.filter((component) => component.id !== action.payload.id);
57
+ state.extraComponents = state.extraComponents.filter((c) => c.id !== action.payload.id);
53
58
  },
54
59
  updateComponent: (state, action) => {
55
- const index = state.components.findIndex((component) => String(component.id) == String(action.payload.id));
56
- const indexExtra = state.extraComponents.findIndex((extraComponent) => String(extraComponent.id) == String(action.payload.id));
57
- // state.historyChanges.push({
58
- // components: [...state.components],
59
- // extraComponents: [...state.extraComponents],
60
- // });
60
+ const index = state.components.findIndex((c) => String(c.id) === String(action.payload.id));
61
+ const indexExtra = state.extraComponents.findIndex((e) => String(e.id) === String(action.payload.id));
61
62
  if (index !== -1) {
62
- // Update component biasa
63
63
  state.components[index] = Object.assign(Object.assign({}, state.components[index]), action.payload);
64
64
  }
65
65
  else if (indexExtra !== -1) {
66
- // Update extraComponent
67
66
  state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), action.payload);
68
67
  }
69
- state.historyChanges.push({
70
- components: [...state.components],
71
- extraComponents: [...state.extraComponents],
72
- boundingBox: state.boundingBox,
73
- backgroundColor: state.backgroundColor,
74
- });
75
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
76
- state.historyChanges.shift();
77
- }
78
- state.pointer += 1;
68
+ pushHistory(state);
79
69
  },
80
70
  updateComponentsBulk: (state, action) => {
81
- const updates = action.payload;
82
- updates.forEach((update) => {
83
- const index = state.components.findIndex((component) => component.id == update.id);
84
- const indexExtra = state.extraComponents.findIndex((extra) => extra.id == update.id);
71
+ action.payload.forEach((update) => {
72
+ const index = state.components.findIndex((c) => c.id == update.id);
73
+ const indexExtra = state.extraComponents.findIndex((e) => e.id == update.id);
85
74
  if (index !== -1) {
86
75
  state.components[index] = Object.assign(Object.assign({}, state.components[index]), update);
87
76
  }
@@ -89,185 +78,75 @@ const boardSlice = createSlice({
89
78
  state.extraComponents[indexExtra] = Object.assign(Object.assign({}, state.extraComponents[indexExtra]), update);
90
79
  }
91
80
  });
92
- if (state.pointer < state.historyChanges.length - 1) {
93
- state.historyChanges = state.historyChanges.slice(0, state.pointer + 1);
94
- }
95
- state.historyChanges.push({
96
- components: [...state.components],
97
- extraComponents: [...state.extraComponents],
98
- boundingBox: state.boundingBox,
99
- backgroundColor: state.backgroundColor,
100
- });
101
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
102
- state.historyChanges.shift();
103
- }
104
- state.pointer += 1;
81
+ pushHistory(state);
105
82
  },
106
83
  updateSelectedGroupComponent: (state, action) => {
107
- const allComponents = action.payload;
108
- forEach(allComponents, (component) => {
84
+ forEach(action.payload, (component) => {
109
85
  const index = state.components.findIndex((c) => c.id == component.id);
110
86
  if (index !== -1) {
111
87
  state.components[index] = Object.assign(Object.assign({}, state.components[index]), component);
112
88
  }
113
89
  });
114
- state.historyChanges.push({
115
- components: [...state.components],
116
- extraComponents: [...state.extraComponents],
117
- boundingBox: state.boundingBox,
118
- backgroundColor: state.backgroundColor,
119
- });
120
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
121
- state.historyChanges.shift();
122
- }
123
- state.pointer += 1;
90
+ pushHistory(state);
124
91
  },
125
92
  setBackgroundColor: (state, action) => {
126
- const currentPointer = state.pointer;
127
- const totalHistory = state.historyChanges.length;
128
- if (currentPointer < totalHistory) {
129
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
130
- }
131
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
132
- state.historyChanges.shift();
133
- }
134
- state.pointer += 1;
135
93
  state.backgroundColor = action.payload;
136
- state.historyChanges.push({
137
- components: [...state.components],
138
- extraComponents: [...state.extraComponents],
139
- boundingBox: state.boundingBox,
140
- backgroundColor: state.backgroundColor,
141
- });
94
+ pushHistory(state);
95
+ },
96
+ setBoundingBox: (state, action) => {
97
+ state.boundingBox = action.payload;
98
+ pushHistory(state);
142
99
  },
143
100
  setNewComponents: (state, action) => {
144
- const currentPointer = state.pointer;
145
- const totalHistory = state.historyChanges.length;
146
- if (currentPointer < totalHistory) {
147
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
148
- }
149
101
  state.components = action.payload;
150
- state.historyChanges.push({
151
- components: [...state.components],
152
- extraComponents: [...state.extraComponents],
153
- boundingBox: state.boundingBox,
154
- backgroundColor: state.backgroundColor,
155
- });
156
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
157
- state.historyChanges.shift();
158
- }
159
- state.pointer += 1;
102
+ pushHistory(state);
160
103
  },
161
104
  setNewExtraComponents: (state, action) => {
162
- const currentPointer = state.pointer;
163
- const totalHistory = state.historyChanges.length;
164
- if (currentPointer < totalHistory) {
165
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
166
- }
167
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
168
- state.historyChanges.shift();
169
- }
170
- state.pointer += 1;
171
- state.extraComponents = action.payload.filter((item) => item.shape) || [];
172
- state.historyChanges.push({
173
- components: [...state.components],
174
- extraComponents: [...state.extraComponents],
175
- boundingBox: state.boundingBox,
176
- backgroundColor: state.backgroundColor,
177
- });
105
+ var _a;
106
+ state.extraComponents =
107
+ (_a = action.payload.filter((item) => item.shape)) !== null && _a !== void 0 ? _a : [];
108
+ pushHistory(state);
178
109
  },
179
110
  setExtraComponent: (state, action) => {
180
- const currentPointer = state.pointer;
181
- const totalHistory = state.historyChanges.length;
182
- if (currentPointer < totalHistory) {
183
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
184
- }
185
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
186
- state.historyChanges.shift();
187
- }
188
- state.pointer += 1;
189
111
  state.extraComponents.push(action.payload);
190
- const component = state.components;
191
- const extraComponent = state.extraComponents;
192
- state.historyChanges.push({
193
- components: [...component],
194
- extraComponents: [...extraComponent],
195
- boundingBox: state.boundingBox,
196
- backgroundColor: state.backgroundColor,
197
- });
198
- },
199
- setFlagChange: (state, action) => {
200
- state.flagChange = action.payload;
112
+ pushHistory(state);
201
113
  },
114
+ // ─── Undo / Redo ─────────────────────────────────────────────────────────
202
115
  undoHistory: (state) => {
203
- var _a, _b, _c, _d, _e, _f, _g, _h;
204
- if (state.pointer > 1) {
205
- const lengthHistory = state.historyChanges.length;
206
- if (lengthHistory == state.pointer) {
207
- state.pointer = lengthHistory - 2;
208
- }
209
- else {
210
- state.pointer -= 1;
211
- }
212
- const prev = state.historyChanges[state.pointer];
213
- state.components = prev === null || prev === void 0 ? void 0 : prev.components;
214
- state.extraComponents = prev === null || prev === void 0 ? void 0 : prev.extraComponents;
215
- state.boundingBox = prev === null || prev === void 0 ? void 0 : prev.boundingBox;
216
- state.backgroundColor = prev === null || prev === void 0 ? void 0 : prev.backgroundColor;
217
- }
218
- else if (state.pointer === 1) {
219
- state.components = (_b = (_a = state.historyChanges) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.components;
220
- state.extraComponents = (_d = (_c = state.historyChanges) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.extraComponents;
221
- state.boundingBox = (_f = (_e = state.historyChanges) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.boundingBox;
222
- state.backgroundColor = (_h = (_g = state.historyChanges) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.backgroundColor;
223
- state.pointer = 0;
224
- }
116
+ if (state.pointer <= 0)
117
+ return;
118
+ state.pointer -= 1;
119
+ const prev = state.historyChanges[state.pointer];
120
+ state.components = prev.components;
121
+ state.extraComponents = prev.extraComponents;
122
+ state.boundingBox = prev.boundingBox;
123
+ state.backgroundColor = prev.backgroundColor;
225
124
  state.updateBy = "global";
226
125
  },
227
126
  redoHistory: (state) => {
228
- if (state.pointer < state.historyChanges.length - 1) {
229
- const next = state.historyChanges[state.pointer + 1];
230
- state.components = current(next === null || next === void 0 ? void 0 : next.components);
231
- state.extraComponents = current(next === null || next === void 0 ? void 0 : next.extraComponents);
232
- state.boundingBox = next === null || next === void 0 ? void 0 : next.boundingBox;
233
- state.pointer += 1;
234
- state.updateBy = "global";
235
- }
127
+ if (state.pointer >= state.historyChanges.length - 1)
128
+ return;
129
+ state.pointer += 1;
130
+ const next = state.historyChanges[state.pointer];
131
+ state.components = current(next.components);
132
+ state.extraComponents = current(next.extraComponents);
133
+ state.boundingBox = next.boundingBox;
134
+ state.backgroundColor = next.backgroundColor;
135
+ state.updateBy = "global";
236
136
  },
237
137
  setInitialValue: (state, action) => {
138
+ var _a;
238
139
  const { components, extraComponents, backgroundColor, boundingBox } = action.payload;
239
140
  state.components = components;
240
- state.extraComponents = (extraComponents === null || extraComponents === void 0 ? void 0 : extraComponents.filter((item) => item.shape)) || [];
241
- state.pointer = 0;
141
+ state.extraComponents =
142
+ (_a = extraComponents === null || extraComponents === void 0 ? void 0 : extraComponents.filter((item) => item.shape)) !== null && _a !== void 0 ? _a : [];
242
143
  state.backgroundColor = backgroundColor;
243
144
  state.boundingBox = boundingBox;
145
+ state.pointer = 0;
244
146
  state.historyChanges = [
245
- {
246
- components,
247
- extraComponents,
248
- boundingBox,
249
- backgroundColor,
250
- },
147
+ { components, extraComponents, boundingBox, backgroundColor },
251
148
  ];
252
149
  },
253
- setBoundingBox: (state, action) => {
254
- const currentPointer = state.pointer;
255
- const totalHistory = state.historyChanges.length;
256
- if (currentPointer < totalHistory) {
257
- state.historyChanges = state.historyChanges.slice(0, currentPointer + 1);
258
- }
259
- if (state.historyChanges.length > MAX_HISTORY_CHANGES) {
260
- state.historyChanges.shift();
261
- }
262
- state.pointer += 1;
263
- state.boundingBox = action.payload;
264
- state.historyChanges.push({
265
- components: [...state.components],
266
- extraComponents: [...state.extraComponents],
267
- boundingBox: state.boundingBox,
268
- backgroundColor: state.backgroundColor,
269
- });
270
- },
271
150
  },
272
151
  });
273
152
  export const { addComponent, removeComponent, updateComponent, setBackgroundColor, removeExtraComponent, } = boardSlice.actions;
@@ -13,6 +13,7 @@ import { Button, Flex, Radio, Slider, Tag, } from "antd";
13
13
  import { getAttributeElement, getAttributeElements } from "./resize-element";
14
14
  import { applyResizeToSvgElement, arrayToSvgPointsAttr, createTableGhost, getGlobalBBox, getRotation, getSvgElementSize, getTranslate, isClosingPolygon, normalizeAngle, pointsStringToArray, resizeBox, resizeSeatCircle, resizeSeatRectCircle, resizeSeatRectSquare, resizeSeatSide, resizeSeatSquare, stabilizeRotation, stabilizeTranslateOnRotate, updateManyComponents, updateSelectionBox, updateSelectionGuides, updateSingleComponent, } from "./utils";
15
15
  import { getOS } from "../../utils/agent";
16
+ import { MIN_HEIGHT, MIN_WIDTH } from "./constant";
16
17
  const toolElement = ["square", "circle", "table-seat-circle"];
17
18
  const idSelectionBoxGhost = "selection-box-ghost";
18
19
  const nameShapeSelectionBoxGhost = "selection-box";
@@ -78,7 +79,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
78
79
  const [selectedLines, setSelectedLines] = useState(null);
79
80
  useEffect(() => {
80
81
  if (activeTool === "select" || activeTool !== "select") {
81
- handleUnSelectComponent();
82
+ (selectedComponentProps === null || selectedComponentProps === void 0 ? void 0 : selectedComponentProps.shape) !== "text" && handleUnSelectComponent();
82
83
  }
83
84
  if (activeTool !== "polygon") {
84
85
  isOnMakePolygonRef.current = false;
@@ -416,7 +417,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
416
417
  };
417
418
  }, [dataElementSelectionGroupRef.current]);
418
419
  const handlePointerDown = (e) => {
419
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
420
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
420
421
  const shiftActive = e.shiftKey;
421
422
  if (activeTool === "grab") {
422
423
  return;
@@ -466,15 +467,16 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
466
467
  isCreateElementRef.current = true;
467
468
  }
468
469
  else if (isInitialCreateText) {
469
- const tables = createTableGhost({
470
+ const [elTemp, el] = createTableGhost({
470
471
  x,
471
472
  y,
472
- width: 100 * scale,
473
- height: 50 * scale,
473
+ width: MIN_WIDTH,
474
+ height: MIN_HEIGHT,
474
475
  fill: "#000000",
475
476
  shape: activeTool,
476
477
  });
477
- (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(tables);
478
+ (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(elTemp);
479
+ (_d = svgRef.current) === null || _d === void 0 ? void 0 : _d.appendChild(el);
478
480
  isCreateElementRef.current = true;
479
481
  }
480
482
  const targetSelection = e.target.closest("g[id='selection-lines']");
@@ -485,14 +487,14 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
485
487
  }
486
488
  let positionSelection = null;
487
489
  if (activeTool === "select") {
488
- positionSelection = (_e = (_d = e.target.closest(`polyline[data-position]`)) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.position;
490
+ positionSelection = (_f = (_e = e.target.closest(`polyline[data-position]`)) === null || _e === void 0 ? void 0 : _e.dataset) === null || _f === void 0 ? void 0 : _f.position;
489
491
  }
490
492
  // RESIZE
491
493
  const targetGroup = e.target.closest("g[data-id]");
492
494
  const targetPointPolygon = e.target.closest("circle[data-point]");
493
495
  // TARGET ELEMENT
494
496
  let idTargetElement = JSON.parse((targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.getAttribute("data-id")) || "{}");
495
- const selectionTarget = (_g = (_f = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _f === void 0 ? void 0 : _f.selection) === null || _g === void 0 ? void 0 : _g.replace("selection-", "");
497
+ const selectionTarget = (_h = (_g = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _g === void 0 ? void 0 : _g.selection) === null || _h === void 0 ? void 0 : _h.replace("selection-", "");
496
498
  const activeId = selectionTarget !== null && selectionTarget !== void 0 ? selectionTarget : idTargetElement;
497
499
  const isInSelectionTarget = !isUndefined(selectionTarget);
498
500
  const isInTargetElement = !isPlainObject(idTargetElement);
@@ -500,7 +502,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
500
502
  const { g } = getAttributeElement(svg, activeId);
501
503
  if (targetGroup && shiftActive) {
502
504
  const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
503
- const currentSelection = (_h = dataElementSelectionGroupRef.current) !== null && _h !== void 0 ? _h : [];
505
+ const currentSelection = (_j = dataElementSelectionGroupRef.current) !== null && _j !== void 0 ? _j : [];
504
506
  if (currentSelection.length == 0 && selectedComponent) {
505
507
  currentSelection.push(selectedComponent);
506
508
  }
@@ -520,7 +522,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
520
522
  const hitPoint = document.elementFromPoint(clientX, clientY);
521
523
  // CHECK FOR HIT ON SVG FOR SELECTION BOX
522
524
  // MAKE AND UNMAKE SELECTION BOX START ------
523
- const hadSelectionBox = ((_j = dataElementSelectionGroupRef.current) === null || _j === void 0 ? void 0 : _j.length) > 0 && !isSingleSelection;
525
+ const hadSelectionBox = ((_k = dataElementSelectionGroupRef.current) === null || _k === void 0 ? void 0 : _k.length) > 0 && !isSingleSelection;
524
526
  const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
525
527
  const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
526
528
  const downBeforeHasSelectionBox = !downInSelectionBox &&
@@ -558,7 +560,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
558
560
  shape: nameShapeSelectionBoxGhost,
559
561
  id: idSelectionBoxGhost,
560
562
  });
561
- (_k = svgRef.current) === null || _k === void 0 ? void 0 : _k.appendChild(boxSelection);
563
+ (_l = svgRef.current) === null || _l === void 0 ? void 0 : _l.appendChild(boxSelection);
562
564
  }
563
565
  // MAKE AND UNMAKE SELECTION BOX END ------
564
566
  // RESIZE SELECTION BOX
@@ -830,7 +832,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
830
832
  updateSelectionBox(svg, resultSelection);
831
833
  const scaleX = resultSelection.width / oldSel.width;
832
834
  const scaleY = resultSelection.height / oldSel.height;
833
- allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text }, i) => {
835
+ allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text, textRaw }, i) => {
834
836
  var _a, _b;
835
837
  const activeId = JSON.parse(g === null || g === void 0 ? void 0 : g.getAttribute("data-id"));
836
838
  const elementOld = allDataRealSelection === null || allDataRealSelection === void 0 ? void 0 : allDataRealSelection.find((el) => el.id == activeId);
@@ -915,7 +917,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
915
917
  });
916
918
  }
917
919
  }
918
- applyResizeToSvgElement(element, g, newElement, text);
920
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
919
921
  });
920
922
  };
921
923
  if (downAtResizePositionAndHasSelectionBox)
@@ -1058,7 +1060,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1058
1060
  var _a, _b;
1059
1061
  const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
1060
1062
  const svg = svgRef.current;
1061
- const { g, element, seats, seatGroup, text } = getAttributeElement(svg, activeId);
1063
+ const { g, element, seats, seatGroup, text, textRaw } = getAttributeElement(svg, activeId);
1062
1064
  const isZeroRotate = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.rotation) === 0 &&
1063
1065
  !(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape.includes("circle"));
1064
1066
  const elementSelect = {
@@ -1197,7 +1199,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1197
1199
  });
1198
1200
  }
1199
1201
  }
1200
- applyResizeToSvgElement(element, g, newElement, text);
1202
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
1201
1203
  isResizeRef.current = true;
1202
1204
  };
1203
1205
  // const hasSelectedOneElement =
@@ -1605,7 +1607,8 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1605
1607
  if (isInitialCreateText) {
1606
1608
  const ghost = svg.querySelector("#ghost-element-create");
1607
1609
  const getBBox = getGlobalBBox(svg, ghost);
1608
- const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14 });
1610
+ console.log({ getBBox });
1611
+ const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14, rotation: 0 });
1609
1612
  addComponents(text);
1610
1613
  dispatch({
1611
1614
  type: "panel/setShow",
@@ -1615,6 +1618,11 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1615
1618
  type: "panel/setSelectedComponent",
1616
1619
  payload: text,
1617
1620
  });
1621
+ setSelectedComponent(text);
1622
+ dispatch({
1623
+ type: "tool/setActiveTool",
1624
+ payload: "select",
1625
+ });
1618
1626
  (_p = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelectorAll("#ghost-element-create")) === null || _p === void 0 ? void 0 : _p.forEach((el) => el.remove());
1619
1627
  isCreateElementRef.current = false;
1620
1628
  }
@@ -1944,7 +1952,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1944
1952
  if (activeTool === "grab") {
1945
1953
  setCursor("grabbing");
1946
1954
  }
1947
- }, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1955
+ }, doubleClick: { disabled: true }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1948
1956
  width: "100%",
1949
1957
  height: "100%",
1950
1958
  }, contentStyle: { width: boardSize.width, height: boardSize.height }, children: _jsxs("svg", { id: "workspace", ref: svgRef, width: boardSize.width, height: boardSize.height, viewBox: `${minCoords.x} ${minCoords.y} ${boardSize.width} ${boardSize.height}`, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {