seat-editor 3.3.35 → 3.3.36

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 (81) hide show
  1. package/dist/app/layout.d.ts +1 -1
  2. package/dist/app/layout.js +22 -0
  3. package/dist/app/new-board/page.d.ts +1 -1
  4. package/dist/app/new-board/page.js +58 -0
  5. package/dist/app/old-board/page.d.ts +1 -2
  6. package/dist/app/old-board/page.js +377 -0
  7. package/dist/app/only-view/chair.d.ts +1 -1
  8. package/dist/app/only-view/chair.js +2 -10
  9. package/dist/app/only-view/page.d.ts +1 -1
  10. package/dist/app/only-view/page.js +226 -0
  11. package/dist/app/only-view/user.d.ts +1 -1
  12. package/dist/app/only-view/user.js +2 -10
  13. package/dist/app/page.d.ts +1 -1
  14. package/dist/app/page.js +8 -0
  15. package/dist/app/test/page.d.ts +1 -2
  16. package/dist/app/test/page.js +43 -0
  17. package/dist/app/v2/page.d.ts +1 -1
  18. package/dist/app/v2/page.js +8 -0
  19. package/dist/components/button-tools/index.d.ts +1 -1
  20. package/dist/components/button-tools/index.js +11 -0
  21. package/dist/components/form-tools/label.d.ts +1 -1
  22. package/dist/components/form-tools/label.js +21 -0
  23. package/dist/components/form-tools/shape.d.ts +1 -1
  24. package/dist/components/form-tools/shape.js +69 -0
  25. package/dist/components/input/number-indicator.d.ts +1 -1
  26. package/dist/components/input/number-indicator.js +27 -0
  27. package/dist/components/joystick/index.d.ts +1 -2
  28. package/dist/components/joystick/index.js +48 -0
  29. package/dist/components/layer/index.d.ts +1 -1
  30. package/dist/components/layer/index.js +295 -0
  31. package/dist/components/layer-v2/index.d.ts +1 -1
  32. package/dist/components/layer-v2/index.js +282 -0
  33. package/dist/components/layer-v3/index.d.ts +1 -1
  34. package/dist/components/layer-v3/index.js +483 -0
  35. package/dist/components/layer-v4/index.d.ts +1 -1
  36. package/dist/components/layer-v4/index.js +924 -0
  37. package/dist/components/lib/index.d.ts +1 -1
  38. package/dist/components/lib/index.js +28 -0
  39. package/dist/components/modal-preview/index.d.ts +1 -1
  40. package/dist/components/modal-preview/index.js +10 -0
  41. package/dist/features/board/index.d.ts +1 -1
  42. package/dist/features/board/index.js +666 -0
  43. package/dist/features/board-v2/index.d.ts +1 -2
  44. package/dist/features/board-v2/index.js +807 -0
  45. package/dist/features/board-v3/icons.js +16 -0
  46. package/dist/features/board-v3/index.d.ts +1 -1
  47. package/dist/features/board-v3/index.js +1587 -0
  48. package/dist/features/navbar/index.d.ts +1 -1
  49. package/dist/features/navbar/index.js +6 -0
  50. package/dist/features/package/index.d.ts +1 -1
  51. package/dist/features/package/index.js +166 -0
  52. package/dist/features/panel/index.d.ts +1 -1
  53. package/dist/features/panel/index.js +243 -0
  54. package/dist/features/panel/select-tool.d.ts +1 -1
  55. package/dist/features/panel/select-tool.js +57 -0
  56. package/dist/features/panel/selected-group.d.ts +1 -1
  57. package/dist/features/panel/selected-group.js +35 -0
  58. package/dist/features/panel/square-circle-tool.d.ts +1 -1
  59. package/dist/features/panel/square-circle-tool.js +8 -0
  60. package/dist/features/panel/table-seat-circle.d.ts +1 -1
  61. package/dist/features/panel/table-seat-circle.js +9 -0
  62. package/dist/features/panel/table-seat-square.d.ts +1 -1
  63. package/dist/features/panel/table-seat-square.js +9 -0
  64. package/dist/features/panel/text-tool.d.ts +1 -1
  65. package/dist/features/panel/text-tool.js +22 -0
  66. package/dist/features/panel/upload-tool.d.ts +1 -1
  67. package/dist/features/panel/upload-tool.js +150 -0
  68. package/dist/features/side-tool/index.d.ts +1 -1
  69. package/dist/features/side-tool/index.js +365 -0
  70. package/dist/features/view-only/index.d.ts +1 -1
  71. package/dist/features/view-only/index.js +198 -0
  72. package/dist/features/view-only-2/index.d.ts +1 -1
  73. package/dist/features/view-only-2/index.js +187 -0
  74. package/dist/features/view-only-3/index.d.ts +1 -1
  75. package/dist/features/view-only-3/index.js +577 -0
  76. package/dist/provider/antd-provider.js +43 -0
  77. package/dist/provider/redux-provider.d.ts +1 -1
  78. package/dist/provider/redux-provider.js +7 -0
  79. package/dist/provider/store-provider.d.ts +1 -1
  80. package/dist/provider/store-provider.js +9 -0
  81. package/package.json +1 -1
@@ -0,0 +1,577 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState, useImperativeHandle, } 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-v4";
7
+ import { getTranslate } from "../board-v3/utils";
8
+ import { Spin } from "antd";
9
+ const LayerView = (props) => {
10
+ const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, statusKey, defaultBackground, defaultBoundingBox, iconTags, tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags, disabled, loadingRender, } = props;
11
+ const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
12
+ const tableGhost = useRef(null);
13
+ const hoverUnderghostId = useRef(null);
14
+ const transformRef = useRef(null);
15
+ const containerRef = useRef(null);
16
+ const svgRef = useRef(null);
17
+ const hasBoundingBoxRef = useRef(false);
18
+ const [tooltip, setTooltip] = useState({
19
+ x: 0,
20
+ y: 0,
21
+ visible: false,
22
+ });
23
+ const isDragging = useRef(false);
24
+ const [panningGroup, setPanningGroup] = useState(false);
25
+ const [scale, setScale] = useState(1);
26
+ const [selectedTable, setSelectedTable] = useState(null);
27
+ const { components: componentsEditor, extraComponents: extraComponentsEditor, boundingBox: boundingBoxProps, } = useAppSelector((state) => state.board);
28
+ const backgroundColor = useAppSelector((state) => state.board.backgroundColor);
29
+ const { loading } = useAppSelector((state) => state.panel);
30
+ useImperativeHandle(refs, () => ({
31
+ svgRef: svgRef === null || svgRef === void 0 ? void 0 : svgRef.current,
32
+ transformRef: transformRef === null || transformRef === void 0 ? void 0 : transformRef.current,
33
+ containerRef: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current,
34
+ tableGhost: tableGhost === null || tableGhost === void 0 ? void 0 : tableGhost.current,
35
+ hoverUnderghost: originalData({
36
+ id: hoverUnderghostId === null || hoverUnderghostId === void 0 ? void 0 : hoverUnderghostId.current,
37
+ type: "find",
38
+ }),
39
+ }));
40
+ const dispatch = useAppDispatch();
41
+ useEffect(() => {
42
+ if (!loading && (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state)) {
43
+ dispatch({ type: "panel/setLoading", payload: true });
44
+ }
45
+ // check in null
46
+ const isEmptyComponents = (componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) === 0;
47
+ const isEmptyExtraComponents = (extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) === 0;
48
+ // const isEmptyBoundingBox = boundingBox === null;
49
+ if (isEmptyComponents) {
50
+ dispatch({
51
+ type: "board/setNewComponents",
52
+ payload: [],
53
+ });
54
+ setTooltip(Object.assign(Object.assign({}, tooltip), { visible: false }));
55
+ }
56
+ if (isEmptyExtraComponents) {
57
+ dispatch({
58
+ type: "board/setNewExtraComponents",
59
+ payload: [],
60
+ });
61
+ }
62
+ if ((componentProps === null || componentProps === void 0 ? void 0 : componentProps.length) > 0) {
63
+ dispatch({
64
+ type: "board/setNewComponents",
65
+ payload: componentProps,
66
+ });
67
+ setTooltip(Object.assign(Object.assign({}, tooltip), { visible: false }));
68
+ }
69
+ if ((extraComponentProps === null || extraComponentProps === void 0 ? void 0 : extraComponentProps.length) > 0) {
70
+ dispatch({
71
+ type: "board/setNewExtraComponents",
72
+ payload: extraComponentProps,
73
+ });
74
+ }
75
+ if (defaultBackground) {
76
+ dispatch({
77
+ type: "board/setBackgroundColor",
78
+ payload: defaultBackground,
79
+ });
80
+ }
81
+ // if(boundingBoxProps) {
82
+ dispatch({
83
+ type: "board/setBoundingBox",
84
+ payload: defaultBoundingBox,
85
+ });
86
+ // }
87
+ setTimeout(() => {
88
+ dispatch({ type: "panel/setLoading", payload: false });
89
+ }, 1000);
90
+ }, [
91
+ componentProps,
92
+ extraComponentProps,
93
+ defaultBackground,
94
+ loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state,
95
+ props === null || props === void 0 ? void 0 : props.viewOnly,
96
+ defaultBoundingBox
97
+ ]);
98
+ useEffect(() => {
99
+ setTooltip(Object.assign(Object.assign({}, tooltip), { visible: false }));
100
+ }, [privilegedTags]);
101
+ useEffect(() => {
102
+ onCurrentStateChange &&
103
+ onCurrentStateChange({
104
+ components: componentsEditor,
105
+ extraComponents: extraComponentsEditor,
106
+ background: backgroundColor,
107
+ boundingBox: boundingBoxProps,
108
+ });
109
+ }, [componentsEditor, extraComponentsEditor, boundingBoxProps]);
110
+ const originalData = ({ id, type, dataParams, }) => {
111
+ let data;
112
+ if (type === "find") {
113
+ data = componentsEditor.find((item) => {
114
+ if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
115
+ return item[mappingKey].id == id;
116
+ }
117
+ return (item === null || item === void 0 ? void 0 : item.id) == id;
118
+ });
119
+ }
120
+ if (type === "get" && dataParams) {
121
+ const mapped = mappingKey ? dataParams[mappingKey] : undefined;
122
+ data = mapped !== undefined ? mapped : dataParams;
123
+ }
124
+ return data;
125
+ };
126
+ const handleSelectComponent = (items, e) => {
127
+ const find = componentsEditor.find((item) => {
128
+ var _a;
129
+ if (mappingKey && (item === null || item === void 0 ? void 0 : item[mappingKey])) {
130
+ return item[mappingKey].id == ((_a = items[mappingKey]) === null || _a === void 0 ? void 0 : _a.id);
131
+ }
132
+ return (item === null || item === void 0 ? void 0 : item.id) == (items === null || items === void 0 ? void 0 : items.id);
133
+ });
134
+ const rightClick = e.button === 2;
135
+ const click = e.button === 0;
136
+ onRightClick && rightClick && onRightClick(e, find);
137
+ onSelectComponent && !rightClick && onSelectComponent(find);
138
+ const seletedTable = mappingKey ? find[mappingKey] : find;
139
+ setSelectedTable(seletedTable);
140
+ };
141
+ const boundingBox = useMemo(() => {
142
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
143
+ if (!componentsEditor && (componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.length) === 0) {
144
+ return { minX: 0, minY: 0, width: 500, height: 500 };
145
+ }
146
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
147
+ componentsEditor === null || componentsEditor === void 0 ? void 0 : componentsEditor.forEach((_, i) => {
148
+ let values = mappingKey ? _[mappingKey] : _;
149
+ if (!values)
150
+ return;
151
+ if (values === null || values === void 0 ? void 0 : values.shape) {
152
+ minX = Math.min(minX, values.x);
153
+ minY = Math.min(minY, values.y);
154
+ maxX = Math.max(maxX, values.x + values.width);
155
+ maxY = Math.max(maxY, values.y + values.height);
156
+ }
157
+ if (i === componentsEditor.length - 1 &&
158
+ (extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 0) {
159
+ minX = minX > 10 ? minX - 10 : minX;
160
+ minY = minY > 10 ? minY - 10 : minY;
161
+ maxX = maxX + 10;
162
+ maxY = maxY + 10;
163
+ }
164
+ });
165
+ extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.forEach((values) => {
166
+ var _a, _b, _c, _d, _e;
167
+ if (values === null || values === void 0 ? void 0 : values.shape) {
168
+ minX = Math.min(minX, values.x);
169
+ minY = Math.min(minY, values.y);
170
+ maxX = Math.max(maxX, values.x + values.width);
171
+ maxY = Math.max(maxY, values.y + values.height);
172
+ }
173
+ if ((_a = values === null || values === void 0 ? void 0 : values.shape) === null || _a === void 0 ? void 0 : _a.includes("polygon")) {
174
+ minX = Math.min(minX, (_b = values === null || values === void 0 ? void 0 : values.points) === null || _b === void 0 ? void 0 : _b.reduce((min, point) => Math.min(min, point.x), Infinity));
175
+ minY = Math.min(minY, (_c = values === null || values === void 0 ? void 0 : values.points) === null || _c === void 0 ? void 0 : _c.reduce((min, point) => Math.min(min, point.y), Infinity));
176
+ maxX = Math.max(maxX, (_d = values === null || values === void 0 ? void 0 : values.points) === null || _d === void 0 ? void 0 : _d.reduce((max, point) => Math.max(max, point.x), -Infinity));
177
+ maxY = Math.max(maxY, (_e = values === null || values === void 0 ? void 0 : values.points) === null || _e === void 0 ? void 0 : _e.reduce((max, point) => Math.max(max, point.y), -Infinity));
178
+ }
179
+ });
180
+ let backgroundHasOne = false;
181
+ if ((extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 1 &&
182
+ ((_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"))) {
183
+ backgroundHasOne = true;
184
+ // console.log({ backgroundHasOne },"shini")
185
+ minX = (_c = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _c === void 0 ? void 0 : _c.x;
186
+ minY = (_d = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _d === void 0 ? void 0 : _d.y;
187
+ maxX = (_e = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _e === void 0 ? void 0 : _e.width;
188
+ maxY = (_f = extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor[0]) === null || _f === void 0 ? void 0 : _f.height;
189
+ }
190
+ const hasBoundingBox = boundingBoxProps;
191
+ // const paddingY =
192
+ // maxY * (props?.viewStyles?.paddingY || 0) +
193
+ // minY * (props?.viewStyles?.paddingY || 0);
194
+ // const paddingX =
195
+ // maxX * (props?.viewStyles?.paddingX || 0) +
196
+ // minX * (props?.viewStyles?.paddingX || 0);
197
+ if (hasBoundingBox) {
198
+ hasBoundingBoxRef.current = true;
199
+ return {
200
+ minX: boundingBoxProps.x,
201
+ minY: boundingBoxProps.y,
202
+ width: boundingBoxProps.width,
203
+ height: boundingBoxProps.height,
204
+ };
205
+ }
206
+ // return {
207
+ // minX: minX - paddingX - (minX - paddingX) * 0.5,
208
+ // minY: minY - paddingY * 2,
209
+ // width: maxX + paddingX * 2,
210
+ // height: maxY + paddingY + (maxY + paddingY) * 0.5,
211
+ // };
212
+ // console.log(minX, minY, maxX, maxY,props?.viewStyles, "bounding box");
213
+ return {
214
+ minX: minX - (((_g = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _g === void 0 ? void 0 : _g.paddingLeft) || 0),
215
+ minY: minY - (((_h = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _h === void 0 ? void 0 : _h.paddingTop) || 0),
216
+ width: maxX + (((_j = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _j === void 0 ? void 0 : _j.paddingRight) || 0),
217
+ height: maxY + (((_k = props === null || props === void 0 ? void 0 : props.viewStyles) === null || _k === void 0 ? void 0 : _k.paddingBottom) || 0),
218
+ };
219
+ }, [componentsEditor, extraComponentsEditor, boundingBoxProps]);
220
+ const renderElements = (elementEditor, mappingKey, tableMatchKey) => {
221
+ return elementEditor.map((editorItem) => {
222
+ const isUsingMapping = mappingKey &&
223
+ typeof editorItem[mappingKey] === "object" &&
224
+ editorItem[mappingKey] !== null;
225
+ let finalProps = isUsingMapping ? editorItem[mappingKey] : editorItem;
226
+ if (tableMatchKey) {
227
+ const tableMatch = tableMatchKey.find((item) => item.key == (editorItem === null || editorItem === void 0 ? void 0 : editorItem[statusKey]));
228
+ finalProps = Object.assign(Object.assign(Object.assign({}, finalProps), tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.properties), { className: tableMatch === null || tableMatch === void 0 ? void 0 : tableMatch.className });
229
+ }
230
+ return finalProps;
231
+ });
232
+ };
233
+ const [fingerCount, setFingerCount] = useState(0);
234
+ useEffect(() => {
235
+ const container = document.getElementById("workspace");
236
+ const handleTouchStart = (e) => {
237
+ const count = e.touches.length;
238
+ setFingerCount(count);
239
+ };
240
+ const handleTouchEnd = () => {
241
+ setFingerCount(0);
242
+ };
243
+ if (container) {
244
+ container.addEventListener("touchstart", handleTouchStart);
245
+ container.addEventListener("touchend", handleTouchEnd);
246
+ }
247
+ return () => {
248
+ if (container) {
249
+ container.removeEventListener("touchstart", handleTouchStart);
250
+ container.removeEventListener("touchend", handleTouchEnd);
251
+ }
252
+ };
253
+ }, []);
254
+ const handleTableEvent = (event, type) => {
255
+ var _a;
256
+ event.preventDefault();
257
+ // cari elemen yg diklik
258
+ const elementTarget = event.target;
259
+ if (!elementTarget)
260
+ return;
261
+ // cari group data-id terdekat
262
+ const group = elementTarget.closest("g[data-id]");
263
+ if (!group)
264
+ return;
265
+ try {
266
+ const tableId = JSON.parse(group.getAttribute("data-id") || "{}");
267
+ const dragEvent = event;
268
+ const dataTransfer = JSON.parse(((_a = dragEvent.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData("application/json")) || "{}");
269
+ const data = {
270
+ targetTable: originalData({ id: tableId, type: "find" }),
271
+ sourceTable: originalData({ dataParams: dataTransfer, type: "get" }),
272
+ };
273
+ // drop from out layout editor
274
+ if (type === "drop") {
275
+ onDrop && onDrop(event, data);
276
+ }
277
+ // cari elemen bentuk (rect / circle / path)
278
+ const shape = group.querySelector("rect") ||
279
+ group.querySelector("circle") ||
280
+ group.querySelector("path");
281
+ if (!shape)
282
+ return;
283
+ }
284
+ catch (err) {
285
+ console.error("Invalid data-id JSON:", err);
286
+ }
287
+ };
288
+ const getSvgCoords = (e) => {
289
+ var _a;
290
+ const svg = svgRef.current;
291
+ const point = svg.createSVGPoint();
292
+ point.x = e.clientX;
293
+ point.y = e.clientY;
294
+ const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
295
+ return { x: transformed.x, y: transformed.y };
296
+ };
297
+ const handlePointerDown = (e) => {
298
+ var _a;
299
+ const svg = svgRef.current;
300
+ if (!e.isPrimary)
301
+ return;
302
+ if (!svg)
303
+ return;
304
+ isDragging.current = false;
305
+ let hasMoved = false;
306
+ const startX = e.clientX;
307
+ const startY = e.clientY;
308
+ const { x, y } = getSvgCoords(e);
309
+ const targetGroup = e.target.closest("g[data-id]");
310
+ if (!targetGroup) {
311
+ setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
312
+ return;
313
+ }
314
+ setPanningGroup(true);
315
+ // clone element yang diklik
316
+ let ghost = targetGroup.cloneNode(true);
317
+ const ghostId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
318
+ const allowedDrag = !(props === null || props === void 0 ? void 0 : props.dragTableBlockKey)
319
+ ? true
320
+ : (_a = props === null || props === void 0 ? void 0 : props.dragTableBlockKey) === null || _a === void 0 ? void 0 : _a.some((_) => {
321
+ const dataRaw = originalData({ id: ghostId, type: "find" });
322
+ return _.value !== (dataRaw === null || dataRaw === void 0 ? void 0 : dataRaw[_.key]);
323
+ });
324
+ if (ghostAttributes) {
325
+ Object.keys(ghostAttributes).forEach((key) => {
326
+ ghost.setAttribute(key, ghostAttributes[key]);
327
+ });
328
+ }
329
+ ghost.setAttribute("opacity", "0.5");
330
+ ghost.setAttribute("pointer-events", "none");
331
+ ghost.setAttribute("stroke-width", "1");
332
+ svg.appendChild(ghost);
333
+ tableGhost.current = ghost;
334
+ const pt = svg.createSVGPoint();
335
+ pt.x = e.clientX;
336
+ pt.y = e.clientY;
337
+ const startBox = getTranslate(targetGroup);
338
+ const groupCTM = targetGroup.getCTM();
339
+ if (!groupCTM) {
340
+ setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
341
+ return;
342
+ }
343
+ const offset = {
344
+ x: x - startBox.x,
345
+ y: y - startBox.y,
346
+ };
347
+ const pointerMoveGhost = (ev) => {
348
+ var _a;
349
+ isDragging.current = true;
350
+ const p = svg.createSVGPoint();
351
+ p.x = ev.clientX;
352
+ p.y = ev.clientY;
353
+ const dx = ev.clientX - startX;
354
+ const dy = ev.clientY - startY;
355
+ const distance = Math.sqrt(dx * dx + dy * dy);
356
+ onPanning(ev);
357
+ if (!hasMoved && distance > 0) {
358
+ // transformRef?.current?.instance
359
+ // only move ghost if the mouse has moved more than 5 pixels
360
+ hasMoved = true;
361
+ isDragging.current = true;
362
+ }
363
+ // ✅ DETEKSI ELEMEN YANG DILEWATI POINTER
364
+ ghost.style.display = "none";
365
+ const elemUnderPointer = document.elementFromPoint(ev.clientX, ev.clientY);
366
+ ghost.style.display = "";
367
+ const hoveredGroup = elemUnderPointer === null || elemUnderPointer === void 0 ? void 0 : elemUnderPointer.closest("g[data-id]");
368
+ const dataHoveredGhostId = JSON.parse((hoveredGroup === null || hoveredGroup === void 0 ? void 0 : hoveredGroup.getAttribute("data-id")) || "{}");
369
+ const dataGhostId = JSON.parse(ghost.getAttribute("data-id") || "{}");
370
+ if (dataHoveredGhostId !== dataGhostId) {
371
+ hoverUnderghostId.current = dataHoveredGhostId;
372
+ }
373
+ const posSVG = p.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
374
+ // posisi awal ghost di bawah kursor tanpa matrix dulu
375
+ const newX = posSVG.x - offset.x;
376
+ const newY = posSVG.y - offset.y;
377
+ if (allowedDrag) {
378
+ ghost.setAttribute("transform", `translate(${newX}, ${newY})`);
379
+ }
380
+ };
381
+ // tampilkan ghost di posisi awal
382
+ pointerMoveGhost(e.nativeEvent);
383
+ const pointerHandleUp = (e) => {
384
+ var _a;
385
+ if (!hasMoved) {
386
+ const dataId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
387
+ isDragging.current = false;
388
+ const dataGroupEmty = !dataId;
389
+ // TOOLTIP ACTION
390
+ const svgSize = svg.getBoundingClientRect();
391
+ const widthScreeen = svgSize.width;
392
+ const heightScreen = svgSize.height;
393
+ const clientX = e.clientX;
394
+ const clientY = e.clientY;
395
+ const relX = clientX - svgSize.left;
396
+ const relY = clientY - svgSize.top;
397
+ const centerX = widthScreeen / 2;
398
+ const centerY = heightScreen / 2;
399
+ let newX = 0;
400
+ let newY = 0;
401
+ if (relX > centerX) {
402
+ newX = relX - widthTooltip;
403
+ }
404
+ else if (relX < centerX) {
405
+ newX = relX;
406
+ }
407
+ else if (relX === centerX) {
408
+ newX = relX;
409
+ }
410
+ if (relY > centerY) {
411
+ newY = relY;
412
+ }
413
+ else if (relY < centerY) {
414
+ newY = relY;
415
+ }
416
+ else if (relY === centerY) {
417
+ newY = relY;
418
+ }
419
+ const rightClick = e.button === 2 && !dataGroupEmty && allowTooltip;
420
+ setTooltip({
421
+ x: newX / scale,
422
+ y: newY / scale,
423
+ visible: rightClick,
424
+ });
425
+ const findDayaById = originalData({ id: dataId, type: "find" });
426
+ handleSelectComponent(findDayaById, e);
427
+ }
428
+ if (isDragging.current && hasMoved && allowedDrag) {
429
+ // drag between group
430
+ const dataHoveredGhost = hoverUnderghostId.current;
431
+ hoverUnderghostId.current = null;
432
+ const sourceTable = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
433
+ const data = {
434
+ targetTable: originalData({ id: dataHoveredGhost, type: "find" }),
435
+ sourceTable: originalData({ id: sourceTable, type: "find" }),
436
+ };
437
+ const allowToSwitch = onSwitch && (data === null || data === void 0 ? void 0 : data.sourceTable) && (data === null || data === void 0 ? void 0 : data.targetTable);
438
+ allowToSwitch && onSwitch(e, data);
439
+ ghost.remove();
440
+ isDragging.current = false;
441
+ (_a = tableGhost.current) === null || _a === void 0 ? void 0 : _a.remove();
442
+ tableGhost.current = null;
443
+ }
444
+ setPanningGroup(false);
445
+ tableGhost.current = null;
446
+ isDragging.current = false;
447
+ window.removeEventListener("pointermove", pointerMoveGhost);
448
+ window.removeEventListener("pointerup", pointerHandleUp);
449
+ };
450
+ window.addEventListener("pointermove", pointerMoveGhost);
451
+ window.addEventListener("pointerup", pointerHandleUp);
452
+ };
453
+ const handleMouseUp = () => {
454
+ var _a;
455
+ // isDragging.current = false;
456
+ (_a = tableGhost.current) === null || _a === void 0 ? void 0 : _a.remove();
457
+ tableGhost.current = null;
458
+ };
459
+ useEffect(() => {
460
+ return () => {
461
+ var _a;
462
+ (_a = tableGhost.current) === null || _a === void 0 ? void 0 : _a.remove();
463
+ };
464
+ }, []);
465
+ const handlePan = (dx, dy) => {
466
+ var _a, _b;
467
+ const instance = (_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.instance;
468
+ const setTransform = (_b = transformRef === null || transformRef === void 0 ? void 0 : transformRef.current) === null || _b === void 0 ? void 0 : _b.setTransform;
469
+ if (!instance)
470
+ return;
471
+ const bounds = instance.bounds;
472
+ const { positionX, positionY, scale } = instance.transformState;
473
+ let x = positionX + dx;
474
+ let y = positionY + dy;
475
+ if (x >= bounds.maxPositionX)
476
+ x = bounds.maxPositionX;
477
+ if (y >= bounds.maxPositionY)
478
+ y = bounds.maxPositionY;
479
+ if (y <= bounds.minPositionY)
480
+ y = bounds.minPositionY;
481
+ if (x <= bounds.minPositionX)
482
+ x = bounds.minPositionX;
483
+ setTransform(x, y, scale, 100, "linear");
484
+ };
485
+ // const instance = transformRef.current?.instance;
486
+ // console.log({ instance })
487
+ const getCoords = (e) => {
488
+ var _a;
489
+ const svg = svgRef.current;
490
+ const instance = (_a = transformRef.current) === null || _a === void 0 ? void 0 : _a.instance;
491
+ if (!svg || !instance)
492
+ return null;
493
+ const { positionX, positionY, scale } = instance.transformState;
494
+ let clientX, clientY;
495
+ if ("touches" in e && e.touches.length > 0) {
496
+ clientX = e.touches[0].clientX;
497
+ clientY = e.touches[0].clientY;
498
+ }
499
+ else if ("clientX" in e) {
500
+ clientX = e.clientX;
501
+ clientY = e.clientY;
502
+ }
503
+ else {
504
+ return null;
505
+ }
506
+ const svgRect = svg.getBoundingClientRect();
507
+ // const viewBox = svg.viewBox.baseVal;
508
+ const xLeft = (clientX - svgRect.left + positionX) / scale;
509
+ const yTop = (clientY - svgRect.top + positionY) / scale;
510
+ const xRight = clientX - svgRect.left + positionX - svgRect.width / scale;
511
+ const yBottom = clientY - svgRect.top + positionY - svgRect.height / scale;
512
+ const minX = svgRect.left + positionX;
513
+ const minY = svgRect.top + positionY;
514
+ const maxX = svgRect.right;
515
+ const maxY = svgRect.bottom;
516
+ return [
517
+ xLeft,
518
+ yTop,
519
+ Math.abs(xRight),
520
+ Math.abs(yBottom),
521
+ minX,
522
+ minY,
523
+ maxX,
524
+ maxY,
525
+ ];
526
+ };
527
+ const onPanning = (e) => {
528
+ const [xLeft, yTop, xRight, yBottom, minX, minY, maxX, maxY] = getCoords(e);
529
+ const edgeThreshold = 100;
530
+ const speedPanning = 50;
531
+ if (scale !== 1) {
532
+ if (xLeft < edgeThreshold)
533
+ handlePan(speedPanning, 0);
534
+ if (xRight < edgeThreshold)
535
+ handlePan(-speedPanning, 0);
536
+ if (yTop < edgeThreshold)
537
+ handlePan(0, speedPanning);
538
+ if (yBottom < edgeThreshold)
539
+ handlePan(0, -speedPanning);
540
+ }
541
+ };
542
+ const hasBoundingBox = hasBoundingBoxRef.current;
543
+ return (_jsxs("div", Object.assign({ className: "relative w-full h-full flex-1", ref: containerRef, style: {
544
+ overflow: "auto",
545
+ WebkitOverflowScrolling: "touch",
546
+ filter: disabled ? "grayscale(100%)" : "none",
547
+ pointerEvents: disabled ? "none" : "auto",
548
+ } }, props.containerProps, { children: [loading && (_jsx("div", { className: "absolute z-10 top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-opacity-50 bg-white w-full h-full flex items-center justify-center", children: (loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.element) || _jsx(Spin, {}) })), _jsx(TransformWrapper, Object.assign({ ref: transformRef,
549
+ // disabled={fingerCount === 1 && scale === 1}
550
+ disablePadding: true, centerZoomedOut: true, panning: {
551
+ disabled: panningGroup,
552
+ wheelPanning: true,
553
+ }, wheel: {
554
+ disabled: false,
555
+ }, onTransformed: ({ state: { scale } }) => setScale(scale), minScale: 1, maxScale: 1000, initialScale: 1, smooth: true, centerOnInit: true }, props.transformProps, { children: _jsxs(TransformComponent, { wrapperStyle: {
556
+ width: "100%",
557
+ height: "100%",
558
+ // overflow: "visible",
559
+ pointerEvents: disabled ? "none" : "auto",
560
+ }, contentStyle: {
561
+ width: "100%",
562
+ height: "100%",
563
+ pointerEvents: disabled ? "none" : "auto",
564
+ }, children: [_jsxs("svg", Object.assign({ id: "workspace", onContextMenu: (e) => e.preventDefault(), onDrop: (e) => handleTableEvent(e, "drop"), onPointerDown: handlePointerDown, onPointerUp: handleMouseUp, ref: svgRef, width: "100%", height: "100%",
565
+ // scale={5}
566
+ overflow: "hidden", viewBox: `${boundingBox.minX} ${boundingBox.minY} ${boundingBox.width} ${boundingBox.height}`, className: "h-full", xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
567
+ background: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : defaultBackground,
568
+ display: "block",
569
+ pointerEvents: disabled ? "none" : "all",
570
+ touchAction: "none",
571
+ userSelect: "none",
572
+ } }, props.svgProps, { children: [hasBoundingBox && (_jsx("defs", { children: _jsx("clipPath", { id: "contentCrop", children: _jsx("rect", { x: boundingBox.minX, y: boundingBox.minY, width: boundingBox.width, height: boundingBox.height }) }) })), _jsx("g", { id: "main-layer", "clip-path": "url(#contentCrop)", children: _jsx(Layers, { components: [
573
+ ...extraComponentsEditor,
574
+ ...renderElements(componentsEditor, mappingKey, tableMatchKey),
575
+ ], selectedTable: selectedTable, iconTags: iconTags, eventMatchTable: eventMatchTable, privilegedTags: privilegedTags }) })] })), tooltip.visible && (_jsx("div", { className: `seat-editor tooltip-container ${tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.className}`, style: Object.assign({ top: tooltip.y, left: tooltip.x, transform: `scale(${1 / scale})`, transformOrigin: "top left", minWidth: widthTooltip + "px" }, tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.style), children: tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.children }))] }) }))] })));
576
+ };
577
+ export default LayerView;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useEffect } from "react";
4
+ import { ConfigProvider } from "antd";
5
+ import { AntdRegistry } from "@ant-design/nextjs-registry";
6
+ import { useAppSelector, useAppDispatch } from "../hooks/use-redux";
7
+ export const AntdProvider = ({ children, themeColor }) => {
8
+ const dispatch = useAppDispatch();
9
+ const theme = useAppSelector((state) => state.theme);
10
+ useEffect(() => {
11
+ if (themeColor !== theme.primaryColor) {
12
+ dispatch({
13
+ type: "theme/setPrimaryColor",
14
+ payload: themeColor
15
+ });
16
+ }
17
+ }, [themeColor]);
18
+ return (_jsx(AntdRegistry, { children: _jsx(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
+ }, children: children }) }));
43
+ };
@@ -1,3 +1,3 @@
1
1
  export declare const ReduxProvider: ({ children }: {
2
2
  children: React.ReactNode;
3
- }) => import("react").JSX.Element;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { store } from "../libs/store";
4
+ import { Provider } from "react-redux";
5
+ export const ReduxProvider = ({ children }) => {
6
+ return _jsx(Provider, { store: store, children: children });
7
+ };
@@ -1,4 +1,4 @@
1
1
  export declare const StoreProvider: ({ children, themeColor, }: {
2
2
  children: React.ReactNode;
3
3
  themeColor?: string;
4
- }) => import("react").JSX.Element;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { ReduxProvider } from "./redux-provider";
4
+ import { AntdProvider } from "./antd-provider";
5
+ import { injectSeatEditorCSS } from "../utils/injectCss";
6
+ export const StoreProvider = ({ children, themeColor = "red", }) => {
7
+ injectSeatEditorCSS();
8
+ return (_jsx(ReduxProvider, { children: _jsx(AntdProvider, { themeColor: themeColor, children: children }) }));
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.3.35",
3
+ "version": "3.3.36",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",