seat-editor 3.3.13 → 3.3.14

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 (136) hide show
  1. package/dist/app/constant.d.ts +1 -0
  2. package/dist/app/constant.js +1 -0
  3. package/dist/app/layout.d.ts +6 -0
  4. package/dist/app/layout.jsx +27 -0
  5. package/dist/app/new-board/page.jsx +55 -0
  6. package/dist/app/old-board/page.d.ts +3 -0
  7. package/dist/app/old-board/page.jsx +510 -0
  8. package/dist/app/only-view/chair.d.ts +1 -0
  9. package/dist/app/only-view/chair.js +12 -0
  10. package/dist/app/only-view/constant.d.ts +60 -0
  11. package/dist/app/only-view/constant.js +1336 -0
  12. package/dist/app/only-view/page.jsx +248 -0
  13. package/dist/app/only-view/user.d.ts +1 -0
  14. package/dist/app/only-view/user.js +12 -0
  15. package/dist/app/page.d.ts +2 -0
  16. package/dist/app/page.jsx +13 -0
  17. package/dist/app/test/page.d.ts +2 -0
  18. package/dist/app/test/page.jsx +45 -0
  19. package/dist/app/v2/page.d.ts +2 -0
  20. package/dist/app/v2/page.jsx +13 -0
  21. package/dist/components/button-tools/index.d.ts +11 -0
  22. package/dist/components/button-tools/index.jsx +17 -0
  23. package/dist/components/form-tools/label.d.ts +2 -0
  24. package/dist/components/form-tools/label.jsx +63 -0
  25. package/dist/components/form-tools/shape.d.ts +8 -0
  26. package/dist/components/form-tools/shape.jsx +113 -0
  27. package/dist/components/input/number-indicator.d.ts +7 -0
  28. package/dist/components/input/number-indicator.jsx +36 -0
  29. package/dist/components/joystick/index.d.ts +12 -0
  30. package/dist/components/joystick/index.jsx +49 -0
  31. package/dist/components/layer/index.d.ts +19 -0
  32. package/dist/components/layer/index.jsx +383 -0
  33. package/dist/components/layer-v2/index.d.ts +19 -0
  34. package/dist/components/layer-v2/index.jsx +370 -0
  35. package/dist/components/layer-v3/index.d.ts +13 -0
  36. package/dist/components/layer-v3/index.jsx +631 -0
  37. package/dist/components/layer-v3/utils.d.ts +19 -0
  38. package/dist/components/layer-v3/utils.js +72 -0
  39. package/dist/components/layer-v4/constant.d.ts +60 -0
  40. package/dist/components/layer-v4/constant.js +93 -0
  41. package/dist/components/layer-v4/index.d.ts +24 -0
  42. package/dist/components/layer-v4/index.jsx +1046 -0
  43. package/dist/components/lib/index.d.ts +8 -0
  44. package/dist/components/lib/index.jsx +33 -0
  45. package/dist/components/modal-preview/index.d.ts +4 -0
  46. package/dist/components/modal-preview/index.jsx +11 -0
  47. package/dist/dto/event-handler.d.ts +1 -0
  48. package/dist/dto/event-handler.js +1 -0
  49. package/dist/dto/table.d.ts +79 -0
  50. package/dist/dto/table.js +1 -0
  51. package/dist/features/board/board-slice.d.ts +14 -0
  52. package/dist/features/board/board-slice.js +52 -0
  53. package/dist/features/board/index.d.ts +6 -0
  54. package/dist/features/board/index.jsx +725 -0
  55. package/dist/features/board-v2/board-slice.d.ts +14 -0
  56. package/dist/features/board-v2/board-slice.js +52 -0
  57. package/dist/features/board-v2/index.d.ts +8 -0
  58. package/dist/features/board-v2/index.jsx +869 -0
  59. package/dist/features/board-v3/board-slice.d.ts +19 -0
  60. package/dist/features/board-v3/board-slice.js +274 -0
  61. package/dist/features/board-v3/constant.d.ts +5 -0
  62. package/dist/features/board-v3/constant.js +5 -0
  63. package/dist/features/board-v3/history-slice.d.ts +27 -0
  64. package/dist/features/board-v3/history-slice.js +27 -0
  65. package/dist/features/board-v3/icons.d.ts +4 -0
  66. package/dist/features/board-v3/icons.jsx +100 -0
  67. package/dist/features/board-v3/index.d.ts +16 -0
  68. package/dist/features/board-v3/index.jsx +1678 -0
  69. package/dist/features/board-v3/polygon.d.ts +28 -0
  70. package/dist/features/board-v3/polygon.js +109 -0
  71. package/dist/features/board-v3/rect.d.ts +9 -0
  72. package/dist/features/board-v3/rect.js +152 -0
  73. package/dist/features/board-v3/resize-element.d.ts +12 -0
  74. package/dist/features/board-v3/resize-element.js +43 -0
  75. package/dist/features/board-v3/utils.d.ts +180 -0
  76. package/dist/features/board-v3/utils.js +1235 -0
  77. package/dist/features/navbar/index.d.ts +2 -0
  78. package/dist/features/navbar/index.jsx +5 -0
  79. package/dist/features/panel/index.d.ts +6 -0
  80. package/dist/features/panel/index.jsx +251 -0
  81. package/dist/features/panel/panel-slice.d.ts +23 -0
  82. package/dist/features/panel/panel-slice.js +46 -0
  83. package/dist/features/panel/select-tool.d.ts +6 -0
  84. package/dist/features/panel/select-tool.jsx +70 -0
  85. package/dist/features/panel/selected-group.d.ts +2 -0
  86. package/dist/features/panel/selected-group.jsx +93 -0
  87. package/dist/features/panel/square-circle-tool.d.ts +2 -0
  88. package/dist/features/panel/square-circle-tool.jsx +10 -0
  89. package/dist/features/panel/table-seat-circle.d.ts +2 -0
  90. package/dist/features/panel/table-seat-circle.jsx +36 -0
  91. package/dist/features/panel/table-seat-square.d.ts +2 -0
  92. package/dist/features/panel/table-seat-square.jsx +51 -0
  93. package/dist/features/panel/text-tool.d.ts +2 -0
  94. package/dist/features/panel/text-tool.jsx +57 -0
  95. package/dist/features/panel/upload-tool.d.ts +10 -0
  96. package/dist/features/panel/upload-tool.jsx +176 -0
  97. package/dist/features/panel/utils.d.ts +5 -0
  98. package/dist/features/panel/utils.js +47 -0
  99. package/dist/features/side-tool/index.d.ts +8 -0
  100. package/dist/features/side-tool/index.jsx +390 -0
  101. package/dist/features/side-tool/side-tool-slice.d.ts +16 -0
  102. package/dist/features/side-tool/side-tool-slice.js +28 -0
  103. package/dist/features/theme/theme-slice.d.ts +12 -0
  104. package/dist/features/theme/theme-slice.js +15 -0
  105. package/dist/features/view-only/index.d.ts +19 -0
  106. package/dist/features/view-only/index.jsx +205 -0
  107. package/dist/features/view-only-2/index.d.ts +19 -0
  108. package/dist/features/view-only-2/index.jsx +190 -0
  109. package/dist/features/view-only-3/index.d.ts +89 -0
  110. package/dist/features/view-only-3/index.jsx +590 -0
  111. package/dist/features/view-only-3/utils.d.ts +1 -0
  112. package/dist/features/view-only-3/utils.js +3 -0
  113. package/dist/hooks/use-redux.d.ts +4 -0
  114. package/dist/hooks/use-redux.js +3 -0
  115. package/dist/index.js +10 -0
  116. package/dist/libs/middleware.d.ts +2 -0
  117. package/dist/libs/middleware.js +5 -0
  118. package/dist/libs/rootReducer.d.ts +12 -0
  119. package/dist/libs/rootReducer.js +14 -0
  120. package/dist/libs/store.d.ts +18 -0
  121. package/dist/libs/store.js +19 -0
  122. package/dist/provider/antd-provider.d.ts +4 -0
  123. package/dist/provider/antd-provider.jsx +46 -0
  124. package/dist/provider/redux-provider.d.ts +3 -0
  125. package/dist/provider/redux-provider.jsx +6 -0
  126. package/dist/provider/store-provider.d.ts +4 -0
  127. package/dist/provider/store-provider.jsx +10 -0
  128. package/dist/utils/constant.d.ts +3 -0
  129. package/dist/utils/constant.js +13 -0
  130. package/dist/utils/format.d.ts +2 -0
  131. package/dist/utils/format.js +29 -0
  132. package/dist/utils/injectCss.d.ts +1 -0
  133. package/dist/utils/injectCss.js +13 -0
  134. package/dist/utils/regex.d.ts +3 -0
  135. package/dist/utils/regex.js +3 -0
  136. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ // Joystick.tsx
2
+ import React, { useRef, useState } from "react";
3
+ export const Joystick = ({ size = 120, onMove, onEnd, }) => {
4
+ const baseRef = useRef(null);
5
+ const [position, setPosition] = useState({ x: 0, y: 0 });
6
+ const handleMove = (e) => {
7
+ const base = baseRef.current;
8
+ if (!base)
9
+ return;
10
+ const rect = base.getBoundingClientRect();
11
+ const isTouch = "touches" in e;
12
+ const clientX = isTouch ? e.touches[0].clientX : e.clientX;
13
+ const clientY = isTouch ? e.touches[0].clientY : e.clientY;
14
+ const centerX = rect.left + rect.width / 2;
15
+ const centerY = rect.top + rect.height / 2;
16
+ const dx = clientX - centerX;
17
+ const dy = clientY - centerY;
18
+ const distance = Math.min(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)), size / 2 - 20);
19
+ const angle = Math.atan2(dy, dx);
20
+ const x = Math.cos(angle) * distance;
21
+ const y = Math.sin(angle) * distance;
22
+ setPosition({ x, y });
23
+ onMove === null || onMove === void 0 ? void 0 : onMove({ x, y });
24
+ };
25
+ const handleEnd = () => {
26
+ setPosition({ x: 0, y: 0 });
27
+ onEnd === null || onEnd === void 0 ? void 0 : onEnd();
28
+ };
29
+ return (<div ref={baseRef} onMouseMove={(e) => e.buttons === 1 && handleMove(e)} onMouseUp={handleEnd} onMouseLeave={handleEnd} onTouchMove={handleMove} onTouchEnd={handleEnd} style={{
30
+ width: size,
31
+ height: size,
32
+ background: "#ddd",
33
+ borderRadius: "50%",
34
+ position: "relative",
35
+ touchAction: "none",
36
+ userSelect: "none",
37
+ }}>
38
+ <div onMouseDown={handleMove} onTouchStart={handleMove} style={{
39
+ width: 40,
40
+ height: 40,
41
+ background: "#3E97FF",
42
+ borderRadius: "50%",
43
+ position: "absolute",
44
+ left: `calc(50% + ${position.x}px - 20px)`,
45
+ top: `calc(50% + ${position.y}px - 20px)`,
46
+ touchAction: "none",
47
+ }}/>
48
+ </div>);
49
+ };
@@ -0,0 +1,19 @@
1
+ interface LayersProps {
2
+ shadowShape?: any[];
3
+ components?: any[];
4
+ onClick?: (items: any) => void;
5
+ selectedComponent?: any;
6
+ activeTool?: string;
7
+ onMouseDown?: (e: React.MouseEvent, item: any, direction?: string) => void;
8
+ onMouseUp?: (e: React.MouseEvent) => void;
9
+ onBlur?: () => void;
10
+ selectedTable?: any;
11
+ selectedTableColor?: string;
12
+ style?: any;
13
+ mode?: "view" | "edit";
14
+ onTouchStart?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>, items: any, direction?: string) => void;
15
+ onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
16
+ onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
17
+ }
18
+ declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchEnd, onTouchMove, onTouchStart }: LayersProps) => import("react").JSX.Element;
19
+ export default Layers;
@@ -0,0 +1,383 @@
1
+ "use client";
2
+ import { useRef } from "react";
3
+ import { omit } from "lodash";
4
+ const Layers = ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode = "edit", style, onTouchEnd, onTouchMove, onTouchStart }) => {
5
+ const refItemTemp = useRef(null);
6
+ const handleOnHover = (item) => {
7
+ if (mode === "edit") {
8
+ refItemTemp.current = item;
9
+ }
10
+ };
11
+ const renderShadowShape = (item) => {
12
+ const { id, x, y, width, height, fill, opacity, rotation, shape, fontColor, text, seatFill, labels, } = item;
13
+ const commonProps = { fill, opacity };
14
+ switch (shape) {
15
+ case "square":
16
+ return (<rect key={id} x={x} y={y} width={width} height={height} {...commonProps}/>);
17
+ case "circle":
18
+ return (<circle key={id} cx={x + width / 2} cy={y + height / 2} r={width / 2} {...commonProps}/>);
19
+ case "diamond":
20
+ return (<rect key={id} x={x} y={y} width={width} height={height} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps}/>);
21
+ case "table-seat-circle": {
22
+ const seatCount = item.seatCount;
23
+ const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
24
+ const centerX = x + width / 2;
25
+ const centerY = y + height / 2;
26
+ const radius = width;
27
+ const seatRadius = width / 4;
28
+ const fullAngle = 2 * Math.PI;
29
+ const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
30
+ const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
31
+ const angleStep = availableAngle / seatCount;
32
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
33
+ const angle = angleStart + i * angleStep;
34
+ const cx = centerX + radius * Math.cos(angle);
35
+ const cy = centerY + radius * Math.sin(angle);
36
+ return { cx, cy };
37
+ });
38
+ return (<g key={id} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
39
+ <circle cx={centerX} cy={centerY} r={width - 15} {...commonProps} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity}/>
40
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
41
+ var _a, _b, _c, _d;
42
+ return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
43
+ {_ === null || _ === void 0 ? void 0 : _.label}
44
+ </text>);
45
+ })}
46
+ <g fill="#e6b9c0" opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
47
+ {seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
48
+ </g>
49
+ </g>);
50
+ }
51
+ case "table-seat-square": {
52
+ const seatCount = item.seatCount || 6;
53
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
54
+ const seatRadius = width / 6;
55
+ // split seats evenly on top and bottom
56
+ const seatCountPerSide = Math.ceil(seatCount / 2);
57
+ const availableWidth = width * (1 - openSpace);
58
+ const startX = x + (width * openSpace) / 2;
59
+ const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
60
+ const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
61
+ cx: startX + i * spacing,
62
+ cy: y - seatRadius * 1.5,
63
+ }));
64
+ const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
65
+ (_, i) => ({
66
+ cx: startX + i * spacing,
67
+ cy: y + height + seatRadius * 1.5,
68
+ }));
69
+ return (<g key={id}>
70
+ {/* Square Table */}
71
+ <rect x={x} y={y} width={width} height={height} {...commonProps}/>
72
+
73
+ {/* Seats */}
74
+ <g fill="#e6b9c0" fillOpacity="0.5" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
75
+ {[...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius}/>))}
76
+ </g>
77
+ </g>);
78
+ }
79
+ case "text":
80
+ return (<g key={id} onClick={() => {
81
+ onClick && onClick(item);
82
+ }}>
83
+ <rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity}/>
84
+ <text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={height * 0.6} opacity={opacity}>
85
+ {text}
86
+ </text>
87
+ </g>);
88
+ case "ruler":
89
+ return (<g key={id}>
90
+ <rect x={x - (window.innerWidth * 3) / 2} y={y} width={window.innerWidth * 3} height={1} fill="black"/>
91
+ <rect x={x} y={y - (window.innerHeight * 3) / 2} width={1} height={window.innerHeight * 3} fill="black"/>
92
+
93
+ </g>);
94
+ default:
95
+ return null;
96
+ }
97
+ };
98
+ const renderShape = (item) => {
99
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, } = item;
100
+ const commonProps = {
101
+ fill,
102
+ opacity,
103
+ stroke,
104
+ strokeWidth,
105
+ onMouseDown: (e) => {
106
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(e, item || refItemTemp.current);
107
+ },
108
+ onMouseEnter: (e) => {
109
+ // e.stopPropagation();
110
+ handleOnHover === null || handleOnHover === void 0 ? void 0 : handleOnHover(item);
111
+ },
112
+ onClick: (e) => {
113
+ // e.stopPropagation();
114
+ onClick === null || onClick === void 0 ? void 0 : onClick(item);
115
+ },
116
+ onMouseUp: (e) => {
117
+ // e.stopPropagation();
118
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(e);
119
+ },
120
+ onBlur: (e) => {
121
+ // e.stopPropagation();
122
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur();
123
+ },
124
+ onTouchMove: (e) => {
125
+ // e.stopPropagation();
126
+ onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(e);
127
+ },
128
+ onTouchStart: (e) => {
129
+ // e.stopPropagation();
130
+ onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e, item);
131
+ },
132
+ onTouchEnd: (e) => {
133
+ // e.stopPropagation();
134
+ onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
135
+ },
136
+ onDoubleClick: (e) => {
137
+ // e.stopPropagation();
138
+ onClick === null || onClick === void 0 ? void 0 : onClick(item);
139
+ },
140
+ };
141
+ switch (shape) {
142
+ case "square":
143
+ return (<g key={id}>
144
+ <rect key={id} x={x} y={y} width={width} height={height} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} {...omit(commonProps, "opacity")} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}/>
145
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
146
+ var _a, _b, _c, _d;
147
+ return (<text {...omit(commonProps, ["opacity", "stroke", "strokeWidth"])} key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
148
+ e.stopPropagation();
149
+ onClick && onClick(item);
150
+ }}>
151
+ {_ === null || _ === void 0 ? void 0 : _.label}
152
+ </text>);
153
+ })}
154
+ </g>);
155
+ case "circle":
156
+ return (<g key={id}>
157
+ <circle key={id} cx={x + width / 2} cy={y + height / 2} r={width / 2} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} {...omit(commonProps, "opacity")}/>
158
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
159
+ var _a, _b, _c, _d;
160
+ return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
161
+ e.stopPropagation();
162
+ onClick && onClick(item);
163
+ }}>
164
+ {_ === null || _ === void 0 ? void 0 : _.label}
165
+ </text>);
166
+ })}
167
+ </g>);
168
+ case "diamond":
169
+ return (<g key={id}>
170
+ <rect key={id} x={x} y={y} width={width} height={height} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} transform={`rotate(${rotation}, ${x}, ${y})`} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
171
+ <text x={x + width / 2} y={y + height / 2} fill={fontColor !== null && fontColor !== void 0 ? fontColor : "black"} fontSize={`${fontSize !== null && fontSize !== void 0 ? fontSize : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
172
+ {label}
173
+ </text>
174
+ </g>);
175
+ case "table-seat-circle": {
176
+ const seatCount = item.seatCount;
177
+ const openSpace = item.openSpace; // nilai antara 0 (tidak ada ruang) sampai maksimal ~0.9
178
+ const centerX = x + width / 2;
179
+ const centerY = y + height / 2;
180
+ const radius = width;
181
+ const seatRadius = width / 4;
182
+ const fullAngle = 2 * Math.PI;
183
+ const availableAngle = fullAngle * (1 - openSpace); // sudut yang dipakai untuk kursi
184
+ const angleStart = (fullAngle - availableAngle) / 2; // agar tetap seimbang
185
+ const angleStep = availableAngle / seatCount;
186
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
187
+ const angle = angleStart + i * angleStep;
188
+ const cx = centerX + radius * Math.cos(angle);
189
+ const cy = centerY + radius * Math.sin(angle);
190
+ return { cx, cy };
191
+ });
192
+ return (<g key={id} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
193
+ <circle cx={centerX} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} cy={centerY} r={width - 15} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill} {...commonProps} opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity}/>
194
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
195
+ var _a, _b, _c, _d;
196
+ return (<text key={`${id}-label-${index}`} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} onClick={(e) => {
197
+ e.stopPropagation();
198
+ onClick && onClick(item);
199
+ }}>
200
+ {_ === null || _ === void 0 ? void 0 : _.label}
201
+ </text>);
202
+ })}
203
+ <g fill="#e6b9c0" opacity={id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) ? 0.5 : opacity} stroke="#c49ba3" key={`${id}-seats`} strokeWidth="1">
204
+ {seatCircles.map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius} fill={seatFill}/>))}
205
+ </g>
206
+ </g>);
207
+ }
208
+ case "table-seat-square": {
209
+ const seatCount = item.seatCount || 6;
210
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
211
+ const seatRadius = width / 6;
212
+ // split seats evenly on top and bottom
213
+ const seatCountPerSide = Math.ceil(seatCount / 2);
214
+ const availableWidth = width * (1 - openSpace);
215
+ const startX = x + (width * openSpace) / 2;
216
+ const spacing = seatCountPerSide > 1 ? availableWidth / (seatCountPerSide - 1) : 0;
217
+ const topSeats = Array.from({ length: seatCountPerSide }, (_, i) => ({
218
+ cx: startX + i * spacing,
219
+ cy: y - seatRadius * 1.5,
220
+ }));
221
+ const bottomSeats = Array.from({ length: seatCount - seatCountPerSide }, // in case it's odd
222
+ (_, i) => ({
223
+ cx: startX + i * spacing,
224
+ cy: y + height + seatRadius * 1.5,
225
+ }));
226
+ return (<g key={id} transform={`rotate(${rotation}, ${x}, ${y})`}>
227
+ {/* Square Table */}
228
+ <rect x={x} y={y} style={Object.assign({ cursor: mode === "view" ? "pointer" : "default" }, style)} width={width} height={height} {...commonProps} fill={selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill}/>
229
+ <text x={x + width / 2} y={y + height / 2} fill={fontColor !== null && fontColor !== void 0 ? fontColor : "black"} fontSize={`${fontSize !== null && fontSize !== void 0 ? fontSize : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle">
230
+ {label}
231
+ </text>
232
+ {/* Seats */}
233
+ <g fill="#e6b9c0" fillOpacity="0.5" stroke="#c49ba3" strokeWidth="1" key={`${id}-seats`}>
234
+ {[...topSeats, ...bottomSeats].map(({ cx, cy }, i) => (<circle key={`${id}-seat-${i}`} cx={cx} cy={cy} r={seatRadius}/>))}
235
+ </g>
236
+ </g>);
237
+ }
238
+ case "text":
239
+ return (<g key={id}>
240
+ <rect x={x} y={y} width={width} height={height} fill="transparent" opacity={opacity} onClick={(e) => {
241
+ e.stopPropagation();
242
+ onClick && onClick(item);
243
+ }}/>
244
+ <text x={x + width / 2} y={y + height / 2} textAnchor="middle" dominantBaseline="middle" fill={fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
245
+ {text}
246
+ </text>
247
+ </g>);
248
+ case "image-table":
249
+ case "background":
250
+ return (<g key={id} onClick={() => {
251
+ onClick && onClick(item);
252
+ }}>
253
+ <image href={src} x={x} y={y} width={width} height={height} transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`} {...commonProps}/>
254
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
255
+ var _a, _b, _c, _d;
256
+ return (<text key={index} x={x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} y={y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0)} fill={(_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black"} fontSize={`${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`} fontWeight="bold" textAnchor="middle" dominantBaseline="middle" transform={`rotate(${rotation} ${x + width / 2} ${y + height / 2})`}>
257
+ {_ === null || _ === void 0 ? void 0 : _.label}
258
+ </text>);
259
+ })}
260
+ </g>);
261
+ default:
262
+ return <g key={id}/>;
263
+ }
264
+ };
265
+ let date = new Date();
266
+ return (<g key={`${date}`}>
267
+ {components === null || components === void 0 ? void 0 : components.map(renderShape)}
268
+ {shadowShape === null || shadowShape === void 0 ? void 0 : shadowShape.map(renderShadowShape)}
269
+
270
+ {selectedComponent && (<>
271
+ {[
272
+ "square",
273
+ "circle",
274
+ "diamond",
275
+ "text",
276
+ "background",
277
+ "image-table",
278
+ ].includes(selectedComponent.shape) && (<g key={`${selectedComponent.id}-selection`}>
279
+ <rect x={selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2"
280
+ // transform={`scale(${selectedComponent.scale})`}
281
+ onMouseDown={(e) => {
282
+ e.stopPropagation();
283
+ onMouseDown(e, selectedComponent, "top-left");
284
+ }} onTouchStart={(e) => {
285
+ e.stopPropagation();
286
+ onTouchStart(e, selectedComponent, "top-left");
287
+ }} onTouchMove={(e) => {
288
+ e.stopPropagation();
289
+ onTouchMove(e);
290
+ }}/>
291
+ <rect x={selectedComponent.x + (selectedComponent.width - 15) / 2} y={selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
292
+ e.stopPropagation();
293
+ onMouseDown(e, selectedComponent, "top-center");
294
+ }} onTouchStart={(e) => {
295
+ e.stopPropagation();
296
+ onTouchStart(e, selectedComponent, "top-center");
297
+ }} onTouchMove={(e) => {
298
+ e.stopPropagation();
299
+ onTouchMove(e);
300
+ }}/>
301
+ <rect x={selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y + (selectedComponent.height - 15) / 2} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
302
+ e.stopPropagation();
303
+ onMouseDown(e, selectedComponent, "left-center");
304
+ }} onTouchStart={(e) => {
305
+ e.stopPropagation();
306
+ onTouchStart(e, selectedComponent, "left-center");
307
+ }} onTouchMove={(e) => {
308
+ e.stopPropagation();
309
+ onTouchMove(e);
310
+ }}/>
311
+ <rect x={selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
312
+ e.stopPropagation();
313
+ onMouseDown(e, selectedComponent, "top-right");
314
+ }} onTouchStart={(e) => {
315
+ e.stopPropagation();
316
+ onTouchStart(e, selectedComponent, "top-right");
317
+ }} onTouchMove={(e) => {
318
+ e.stopPropagation();
319
+ onTouchMove(e);
320
+ }}/>
321
+ <rect x={selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
322
+ e.stopPropagation();
323
+ onMouseDown(e, selectedComponent, "bottom-right");
324
+ }} onTouchStart={(e) => {
325
+ e.stopPropagation();
326
+ onTouchStart(e, selectedComponent, "bottom-right");
327
+ }} onTouchMove={(e) => {
328
+ e.stopPropagation();
329
+ onTouchMove(e);
330
+ }}/>
331
+ <rect x={selectedComponent.x + (selectedComponent.width - 15) / 2} y={selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
332
+ e.stopPropagation();
333
+ onMouseDown(e, selectedComponent, "bottom-center");
334
+ }} onTouchStart={(e) => {
335
+ e.stopPropagation();
336
+ onTouchStart(e, selectedComponent, "bottom-center");
337
+ }} onTouchMove={(e) => {
338
+ e.stopPropagation();
339
+ onTouchMove(e);
340
+ }}/>
341
+ <rect x={selectedComponent.x + selectedComponent.width + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y + (selectedComponent.height - 15) / 2} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
342
+ e.stopPropagation();
343
+ onMouseDown(e, selectedComponent, "right-center");
344
+ }} onTouchStart={(e) => {
345
+ e.stopPropagation();
346
+ onTouchStart(e, selectedComponent, "right-center");
347
+ }} onTouchMove={(e) => {
348
+ e.stopPropagation();
349
+ onTouchMove(e);
350
+ }}/>
351
+ <rect x={selectedComponent.x - 25 - ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} y={selectedComponent.y + selectedComponent.height + 5 + ((selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.strokeWidth) || 0)} width={20} height={20} fill="black" stroke="white" strokeWidth="2" onMouseDown={(e) => {
352
+ e.stopPropagation();
353
+ onMouseDown(e, selectedComponent, "bottom-left");
354
+ }} onTouchStart={(e) => {
355
+ e.stopPropagation();
356
+ onTouchStart(e, selectedComponent, "bottom-left");
357
+ }} onTouchMove={(e) => {
358
+ e.stopPropagation();
359
+ onTouchMove(e);
360
+ }}/>
361
+ </g>)}
362
+ {["table-seat-circle", "table-seat-square"].includes(selectedComponent.shape) && (<g key={selectedComponent.id}>
363
+ <rect x={selectedComponent.x - selectedComponent.width} y={selectedComponent.y - selectedComponent.height} width={20} height={20} fill="black" stroke="white" strokeWidth="2" transform={`scale(${selectedComponent.scale})`} onMouseDown={(e) => {
364
+ e.stopPropagation();
365
+ onMouseDown(e, selectedComponent, "top-left");
366
+ }}/>
367
+ <rect x={selectedComponent.x + selectedComponent.width * 2 - 10} y={selectedComponent.y - selectedComponent.height} width={20} height={20} fill="black" stroke="white" strokeWidth="2" transform={`scale(${selectedComponent.scale})`} onMouseDown={(e) => {
368
+ e.stopPropagation();
369
+ onMouseDown(e, selectedComponent, "top-right");
370
+ }}/>
371
+ <rect x={selectedComponent.x + selectedComponent.width * 2 - 10} y={selectedComponent.y + selectedComponent.height * 2} width={20} height={20} fill="black" stroke="white" strokeWidth="2" transform={`scale(${selectedComponent.scale})`} onMouseDown={(e) => {
372
+ e.stopPropagation();
373
+ onMouseDown(e, selectedComponent, "bottom-right");
374
+ }}/>
375
+ <rect x={selectedComponent.x - selectedComponent.width} y={selectedComponent.y + selectedComponent.height * 2} width={20} height={20} fill="black" stroke="white" strokeWidth="2" transform={`scale(${selectedComponent.scale})`} onMouseDown={(e) => {
376
+ e.stopPropagation();
377
+ onMouseDown(e, selectedComponent, "b-left");
378
+ }}/>
379
+ </g>)}
380
+ </>)}
381
+ </g>);
382
+ };
383
+ export default Layers;
@@ -0,0 +1,19 @@
1
+ interface LayersProps {
2
+ shadowShape?: any[];
3
+ components?: any[];
4
+ onClick?: (items: any) => void;
5
+ selectedComponent?: any;
6
+ activeTool?: string;
7
+ onMouseDown?: (e: React.MouseEvent, item: any, direction?: string) => void;
8
+ onMouseUp?: (e: React.MouseEvent) => void;
9
+ onBlur?: () => void;
10
+ selectedTable?: any;
11
+ selectedTableColor?: string;
12
+ style?: any;
13
+ mode?: "view" | "edit";
14
+ onTouchStart?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>, items: any, direction?: string) => void;
15
+ onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
16
+ onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement>) => void;
17
+ }
18
+ declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchStart }: LayersProps) => import("react").JSX.Element;
19
+ export default Layers;