seat-editor 3.4.4 → 3.4.6
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.
- package/dist/app/constant.d.ts +19 -19
- package/dist/app/constant.js +35 -20
- package/dist/app/only-view/page.js +6 -4
- package/dist/app/only-view/page.jsx +6 -4
- package/dist/components/form-tools/label.js +13 -13
- package/dist/components/form-tools/label.jsx +18 -11
- package/dist/components/form-tools/shape.js +1 -1
- package/dist/components/form-tools/shape.jsx +1 -1
- package/dist/components/layer-v4/index.js +3 -2
- package/dist/components/layer-v4/index.jsx +3 -2
- package/dist/features/board-v3/board-slice.js +4 -4
- package/dist/features/board-v3/index.js +24 -4
- package/dist/features/board-v3/index.jsx +24 -4
- package/dist/features/board-v3/utils.d.ts +2 -1
- package/dist/features/board-v3/utils.js +44 -18
- package/dist/features/panel/index.js +28 -4
- package/dist/features/panel/index.jsx +28 -4
- package/dist/features/panel/selected-group.js +16 -4
- package/dist/features/panel/selected-group.jsx +26 -7
- package/dist/features/panel/table-seat-circle.js +4 -1
- package/dist/features/panel/table-seat-circle.jsx +4 -1
- package/dist/features/panel/table-seat-square.js +8 -2
- package/dist/features/panel/table-seat-square.jsx +9 -3
- package/dist/features/panel/utils.js +3 -10
- package/dist/features/view-only-3/index.d.ts +7 -5
- package/dist/features/view-only-3/index.js +71 -16
- package/dist/features/view-only-3/index.jsx +71 -16
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ export const resizeElementSelection = ({ selectionStart, currentSelection, rotat
|
|
|
43
43
|
height,
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
-
export function resizeBox({ box, dx, dy, rotate, handle }) {
|
|
46
|
+
export function resizeBox({ box, dx, dy, rotate, handle, isZeroRotate = false, }) {
|
|
47
47
|
// 1. mouse → local
|
|
48
48
|
const local = toLocalDelta(dx, dy, rotate);
|
|
49
49
|
// 2. scale
|
|
@@ -52,11 +52,37 @@ export function resizeBox({ box, dx, dy, rotate, handle }) {
|
|
|
52
52
|
// 3. anchor
|
|
53
53
|
const { ax, ay } = getAnchor(handle, box);
|
|
54
54
|
// 4. ukuran baru
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
let newWidth = box.width * scale;
|
|
56
|
+
let newHeight = box.height * scale;
|
|
57
57
|
// 5. posisi baru dari anchor
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let newX = ax - newWidth * ((ax - box.x) / box.width);
|
|
59
|
+
let newY = ay - newHeight * ((ay - box.y) / box.height);
|
|
60
|
+
if (isZeroRotate) {
|
|
61
|
+
if (handle === "right") {
|
|
62
|
+
newWidth = box.width + local.x;
|
|
63
|
+
newHeight = box.height;
|
|
64
|
+
newX = box.x;
|
|
65
|
+
newY = box.y;
|
|
66
|
+
}
|
|
67
|
+
else if (handle === "left") {
|
|
68
|
+
newWidth = box.width - local.x;
|
|
69
|
+
newX = box.x + local.x;
|
|
70
|
+
newHeight = box.height;
|
|
71
|
+
newY = box.y;
|
|
72
|
+
}
|
|
73
|
+
else if (handle === "bottom") {
|
|
74
|
+
newHeight = box.height + local.y;
|
|
75
|
+
newWidth = box.width;
|
|
76
|
+
newX = box.x;
|
|
77
|
+
newY = box.y;
|
|
78
|
+
}
|
|
79
|
+
else if (handle === "top") {
|
|
80
|
+
newHeight = box.height - local.y;
|
|
81
|
+
newY = box.y + local.y;
|
|
82
|
+
newWidth = box.width;
|
|
83
|
+
newX = box.x;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
60
86
|
return {
|
|
61
87
|
x: newX,
|
|
62
88
|
y: newY,
|
|
@@ -366,17 +392,17 @@ export const resizeSeatSide = ({ seatsPositions, r = 10, openSpace, newElement,
|
|
|
366
392
|
start: newElement.y,
|
|
367
393
|
length: newElement.height,
|
|
368
394
|
count: rightCount,
|
|
369
|
-
radius:
|
|
395
|
+
radius: seatRaidus,
|
|
370
396
|
spacing: spacingHeight,
|
|
371
397
|
});
|
|
372
398
|
const rightSeats = rightYs.map((cy) => ({
|
|
373
|
-
cx: newElement.x + newElement.width +
|
|
399
|
+
cx: newElement.x + newElement.width + seatRaidus * 0.1,
|
|
374
400
|
cy,
|
|
375
401
|
id: "right",
|
|
376
402
|
d: arcByDirection({
|
|
377
|
-
cx: newElement.x + newElement.width +
|
|
403
|
+
cx: newElement.x + newElement.width + seatRaidus * 0.1,
|
|
378
404
|
cy,
|
|
379
|
-
r,
|
|
405
|
+
r: seatRaidus,
|
|
380
406
|
direction: "right",
|
|
381
407
|
fraction: 0.4,
|
|
382
408
|
}),
|
|
@@ -466,7 +492,7 @@ export const resizeSeatRectCircle = ({ seatsPositions, r = 10, openSpace, newEle
|
|
|
466
492
|
spacing: spacingHeight,
|
|
467
493
|
});
|
|
468
494
|
const leftSeats = leftYs.map((cy) => ({
|
|
469
|
-
x: -seatSizeLR.w,
|
|
495
|
+
x: x - seatSizeLR.w,
|
|
470
496
|
y: cy - seatSizeLR.h / 2,
|
|
471
497
|
width: seatSizeLR.w,
|
|
472
498
|
height: seatSizeLR.h,
|
|
@@ -494,7 +520,7 @@ export const resizeSeatRectCircle = ({ seatsPositions, r = 10, openSpace, newEle
|
|
|
494
520
|
spacing: spacingHeight,
|
|
495
521
|
});
|
|
496
522
|
const rightSeats = rightYs.map((cy) => ({
|
|
497
|
-
x: width,
|
|
523
|
+
x: x + width,
|
|
498
524
|
y: cy - seatSizeLR.h / 2,
|
|
499
525
|
width: seatSizeLR.w,
|
|
500
526
|
height: seatSizeLR.h,
|
|
@@ -583,22 +609,22 @@ export const resizeSeatRectSquare = ({ seatsPositions, r = 10, openSpace, newEle
|
|
|
583
609
|
spacing: spacingWidth,
|
|
584
610
|
});
|
|
585
611
|
const topSeats = topXs.map((cx) => ({
|
|
586
|
-
x:
|
|
612
|
+
x: cx - seatSizeTB.w / 2,
|
|
587
613
|
y: y - seatSizeTB.h,
|
|
588
614
|
width: seatSizeTB.w,
|
|
589
615
|
height: seatSizeTB.h,
|
|
590
616
|
id: "top",
|
|
591
617
|
}));
|
|
592
618
|
const leftYs = distributeWithSpacing({
|
|
593
|
-
start:
|
|
619
|
+
start: 0,
|
|
594
620
|
length: height,
|
|
595
621
|
count: leftCount,
|
|
596
622
|
radius: seatRadius,
|
|
597
623
|
spacing: spacingHeight,
|
|
598
624
|
});
|
|
599
625
|
const leftSeats = leftYs.map((cy) => ({
|
|
600
|
-
x: -seatSizeLR.w,
|
|
601
|
-
y: cy - seatSizeLR.h / 2,
|
|
626
|
+
x: x - seatSizeLR.w,
|
|
627
|
+
y: y + cy - seatSizeLR.h / 2,
|
|
602
628
|
width: seatSizeLR.w,
|
|
603
629
|
height: seatSizeLR.h,
|
|
604
630
|
id: "left",
|
|
@@ -618,15 +644,15 @@ export const resizeSeatRectSquare = ({ seatsPositions, r = 10, openSpace, newEle
|
|
|
618
644
|
id: "bottom",
|
|
619
645
|
}));
|
|
620
646
|
const rightYs = distributeWithSpacing({
|
|
621
|
-
start:
|
|
647
|
+
start: 0,
|
|
622
648
|
length: newElement.height,
|
|
623
649
|
count: rightCount,
|
|
624
650
|
radius: seatRadius,
|
|
625
651
|
spacing: spacingHeight,
|
|
626
652
|
});
|
|
627
653
|
const rightSeats = rightYs.map((cy) => ({
|
|
628
|
-
x: width,
|
|
629
|
-
y: cy - seatSizeLR.h / 2,
|
|
654
|
+
x: x + width,
|
|
655
|
+
y: y + cy - seatSizeLR.h / 2,
|
|
630
656
|
width: seatSizeLR.w,
|
|
631
657
|
height: seatSizeLR.h,
|
|
632
658
|
id: "right",
|
|
@@ -25,6 +25,7 @@ import { applyResizeToSvgElement, getGlobalBBox, updateSelectionBox, } from "../
|
|
|
25
25
|
import { SEAT_SHAPES } from "../../utils/constant";
|
|
26
26
|
import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
|
|
27
27
|
import SeatSquare from "./table-seat-square";
|
|
28
|
+
import _ from "lodash";
|
|
28
29
|
const ControlPanels = (props) => {
|
|
29
30
|
const { action, transform } = props;
|
|
30
31
|
const dispatch = useAppDispatch();
|
|
@@ -75,6 +76,12 @@ const ControlPanels = (props) => {
|
|
|
75
76
|
? Number(arr[0][key]) * 100
|
|
76
77
|
: undefined;
|
|
77
78
|
}
|
|
79
|
+
if (key === "labels") {
|
|
80
|
+
const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key]));
|
|
81
|
+
return (arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key])))
|
|
82
|
+
? arr[0][key]
|
|
83
|
+
: [];
|
|
84
|
+
}
|
|
78
85
|
return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
|
|
79
86
|
}
|
|
80
87
|
form.setFieldsValue({
|
|
@@ -90,6 +97,10 @@ const ControlPanels = (props) => {
|
|
|
90
97
|
radius: getValueIfSame(selectedGroup, "radius"),
|
|
91
98
|
shape: getValueIfSame(selectedGroup, "shape"),
|
|
92
99
|
labels: getValueIfSame(selectedGroup, "labels"),
|
|
100
|
+
seatCount: getValueIfSame(selectedGroup, "seatCount"),
|
|
101
|
+
seatPositions: getValueIfSame(selectedGroup, "seatPositions"),
|
|
102
|
+
seatFill: getValueIfSame(selectedGroup, "seatFill"),
|
|
103
|
+
openSpace: getValueIfSame(selectedGroup, "openSpace"),
|
|
93
104
|
});
|
|
94
105
|
}
|
|
95
106
|
else {
|
|
@@ -110,7 +121,9 @@ const ControlPanels = (props) => {
|
|
|
110
121
|
const seatDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
111
122
|
return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape: (_b = props.shape) !== null && _b !== void 0 ? _b : shape, height: (_c = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _c === void 0 ? void 0 : _c.height, width: (_d = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _d === void 0 ? void 0 : _d.width, fill: props.fill, seatCount: getSeatCount(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props, seatDefault), seatPositions: getSeatPosition(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props, seatDefault), openSpace: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
112
123
|
? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0
|
|
113
|
-
: undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
124
|
+
: undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
125
|
+
? (_f = props.seatFill) !== null && _f !== void 0 ? _f : theme === null || theme === void 0 ? void 0 : theme.primaryColor
|
|
126
|
+
: undefined, text: shape === "text" ? (_g = props.text) !== null && _g !== void 0 ? _g : defaults.text : undefined, fontColor: shape === "text" ? (_h = props.fontColor) !== null && _h !== void 0 ? _h : defaults.fontColor : undefined, radius: props.radius });
|
|
114
127
|
};
|
|
115
128
|
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
116
129
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -179,7 +192,7 @@ const ControlPanels = (props) => {
|
|
|
179
192
|
updateSelectionBox(svg, getBBox);
|
|
180
193
|
};
|
|
181
194
|
const handleChangeComponent = (values, allValues) => {
|
|
182
|
-
var _a, _b;
|
|
195
|
+
var _a, _b, _c;
|
|
183
196
|
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
184
197
|
const newValues = createShape(shape, restProps, selectedComponent);
|
|
185
198
|
if (selectedComponent) {
|
|
@@ -187,8 +200,19 @@ const ControlPanels = (props) => {
|
|
|
187
200
|
debouncedSyncComponents.current(Object.assign(Object.assign(Object.assign({}, (selectedComponent || {})), newValues), { opacity: ((_a = newValues === null || newValues === void 0 ? void 0 : newValues.opacity) !== null && _a !== void 0 ? _a : 100) / 100, openSpace: ((_b = newValues === null || newValues === void 0 ? void 0 : newValues.openSpace) !== null && _b !== void 0 ? _b : 0) / 100 }));
|
|
188
201
|
}
|
|
189
202
|
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
190
|
-
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels, } = newValues;
|
|
191
|
-
const
|
|
203
|
+
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels, openSpace, } = newValues;
|
|
204
|
+
const seatPositionsNew = (_c = Object.values(seatPositions)) === null || _c === void 0 ? void 0 : _c.some((item) => _.isNaN(item));
|
|
205
|
+
const updatedGroup = selectedGroup.map((comp) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, comp), (width !== undefined ? { width } : {})), (height !== undefined ? { height } : {})), (x !== undefined ? { x } : {})), (y !== undefined ? { y } : {})), (fill !== undefined ? { fill } : {})), (stroke !== undefined ? { stroke } : {})), (opacity !== undefined ? { opacity: Number(opacity) / 100 } : {})), (rotation !== undefined ? { rotation } : {})), (strokeWidth !== undefined ? { strokeWidth } : {})), (radius !== undefined ? { radius } : {})), (shape !== undefined ? { shape } : {})), (seatFill !== undefined ? { seatFill } : {})), (labels !== undefined ? { labels } : {})), (seatPositions !== undefined
|
|
206
|
+
? {
|
|
207
|
+
seatPositions: seatPositionsNew
|
|
208
|
+
? getSeatPosition(shape, comp, comp === null || comp === void 0 ? void 0 : comp[seatKey])
|
|
209
|
+
: seatPositions,
|
|
210
|
+
}
|
|
211
|
+
: {})), (seatCount !== undefined
|
|
212
|
+
? {
|
|
213
|
+
seatCount: seatCount !== null && seatCount !== void 0 ? seatCount : getSeatCount(shape, comp, comp === null || comp === void 0 ? void 0 : comp[seatKey]),
|
|
214
|
+
}
|
|
215
|
+
: {})), (openSpace !== undefined ? { openSpace } : {}))));
|
|
192
216
|
let minX = Infinity;
|
|
193
217
|
let minY = Infinity;
|
|
194
218
|
let maxX = -Infinity;
|
|
@@ -24,6 +24,7 @@ import { applyResizeToSvgElement, getGlobalBBox, updateSelectionBox, } from "../
|
|
|
24
24
|
import { SEAT_SHAPES } from "../../utils/constant";
|
|
25
25
|
import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
|
|
26
26
|
import SeatSquare from "./table-seat-square";
|
|
27
|
+
import _ from "lodash";
|
|
27
28
|
const ControlPanels = (props) => {
|
|
28
29
|
const { action, transform } = props;
|
|
29
30
|
const dispatch = useAppDispatch();
|
|
@@ -74,6 +75,12 @@ const ControlPanels = (props) => {
|
|
|
74
75
|
? Number(arr[0][key]) * 100
|
|
75
76
|
: undefined;
|
|
76
77
|
}
|
|
78
|
+
if (key === "labels") {
|
|
79
|
+
const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key]));
|
|
80
|
+
return (arr === null || arr === void 0 ? void 0 : arr.every((item) => _.isEqual(item[key], arr[0][key])))
|
|
81
|
+
? arr[0][key]
|
|
82
|
+
: [];
|
|
83
|
+
}
|
|
77
84
|
return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
|
|
78
85
|
}
|
|
79
86
|
form.setFieldsValue({
|
|
@@ -89,6 +96,10 @@ const ControlPanels = (props) => {
|
|
|
89
96
|
radius: getValueIfSame(selectedGroup, "radius"),
|
|
90
97
|
shape: getValueIfSame(selectedGroup, "shape"),
|
|
91
98
|
labels: getValueIfSame(selectedGroup, "labels"),
|
|
99
|
+
seatCount: getValueIfSame(selectedGroup, "seatCount"),
|
|
100
|
+
seatPositions: getValueIfSame(selectedGroup, "seatPositions"),
|
|
101
|
+
seatFill: getValueIfSame(selectedGroup, "seatFill"),
|
|
102
|
+
openSpace: getValueIfSame(selectedGroup, "openSpace"),
|
|
92
103
|
});
|
|
93
104
|
}
|
|
94
105
|
else {
|
|
@@ -109,7 +120,9 @@ const ControlPanels = (props) => {
|
|
|
109
120
|
const seatDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
110
121
|
return Object.assign(Object.assign(Object.assign({}, defaults), props), { shape: (_b = props.shape) !== null && _b !== void 0 ? _b : shape, height: (_c = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _c === void 0 ? void 0 : _c.height, width: (_d = adjustHeightWidthForSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props)) === null || _d === void 0 ? void 0 : _d.width, fill: props.fill, seatCount: getSeatCount(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props, seatDefault), seatPositions: getSeatPosition(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape, props, seatDefault), openSpace: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
111
122
|
? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0
|
|
112
|
-
: undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
123
|
+
: undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
|
|
124
|
+
? (_f = props.seatFill) !== null && _f !== void 0 ? _f : theme === null || theme === void 0 ? void 0 : theme.primaryColor
|
|
125
|
+
: undefined, text: shape === "text" ? (_g = props.text) !== null && _g !== void 0 ? _g : defaults.text : undefined, fontColor: shape === "text" ? (_h = props.fontColor) !== null && _h !== void 0 ? _h : defaults.fontColor : undefined, radius: props.radius });
|
|
113
126
|
};
|
|
114
127
|
const debouncedSyncComponents = useRef(debounce((data) => {
|
|
115
128
|
dispatch({ type: "board/setFlagChange", payload: true });
|
|
@@ -178,7 +191,7 @@ const ControlPanels = (props) => {
|
|
|
178
191
|
updateSelectionBox(svg, getBBox);
|
|
179
192
|
};
|
|
180
193
|
const handleChangeComponent = (values, allValues) => {
|
|
181
|
-
var _a, _b;
|
|
194
|
+
var _a, _b, _c;
|
|
182
195
|
const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
|
|
183
196
|
const newValues = createShape(shape, restProps, selectedComponent);
|
|
184
197
|
if (selectedComponent) {
|
|
@@ -186,8 +199,19 @@ const ControlPanels = (props) => {
|
|
|
186
199
|
debouncedSyncComponents.current(Object.assign(Object.assign(Object.assign({}, (selectedComponent || {})), newValues), { opacity: ((_a = newValues === null || newValues === void 0 ? void 0 : newValues.opacity) !== null && _a !== void 0 ? _a : 100) / 100, openSpace: ((_b = newValues === null || newValues === void 0 ? void 0 : newValues.openSpace) !== null && _b !== void 0 ? _b : 0) / 100 }));
|
|
187
200
|
}
|
|
188
201
|
if ((selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.length) > 0) {
|
|
189
|
-
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels, } = newValues;
|
|
190
|
-
const
|
|
202
|
+
const { width, height, x, y, fill, stroke, opacity, rotation, strokeWidth, radius, shape, seatCount, seatFill, seatPositions, labels, openSpace, } = newValues;
|
|
203
|
+
const seatPositionsNew = (_c = Object.values(seatPositions)) === null || _c === void 0 ? void 0 : _c.some((item) => _.isNaN(item));
|
|
204
|
+
const updatedGroup = selectedGroup.map((comp) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, comp), (width !== undefined ? { width } : {})), (height !== undefined ? { height } : {})), (x !== undefined ? { x } : {})), (y !== undefined ? { y } : {})), (fill !== undefined ? { fill } : {})), (stroke !== undefined ? { stroke } : {})), (opacity !== undefined ? { opacity: Number(opacity) / 100 } : {})), (rotation !== undefined ? { rotation } : {})), (strokeWidth !== undefined ? { strokeWidth } : {})), (radius !== undefined ? { radius } : {})), (shape !== undefined ? { shape } : {})), (seatFill !== undefined ? { seatFill } : {})), (labels !== undefined ? { labels } : {})), (seatPositions !== undefined
|
|
205
|
+
? {
|
|
206
|
+
seatPositions: seatPositionsNew
|
|
207
|
+
? getSeatPosition(shape, comp, comp === null || comp === void 0 ? void 0 : comp[seatKey])
|
|
208
|
+
: seatPositions,
|
|
209
|
+
}
|
|
210
|
+
: {})), (seatCount !== undefined
|
|
211
|
+
? {
|
|
212
|
+
seatCount: seatCount !== null && seatCount !== void 0 ? seatCount : getSeatCount(shape, comp, comp === null || comp === void 0 ? void 0 : comp[seatKey]),
|
|
213
|
+
}
|
|
214
|
+
: {})), (openSpace !== undefined ? { openSpace } : {}))));
|
|
191
215
|
let minX = Infinity;
|
|
192
216
|
let minY = Infinity;
|
|
193
217
|
let maxX = -Infinity;
|
|
@@ -5,9 +5,13 @@ import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
|
|
|
5
5
|
import SeatCircle from "./table-seat-circle";
|
|
6
6
|
import SeatSquare from "./table-seat-square";
|
|
7
7
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
8
|
+
import SectionLabel from "../../components/form-tools/label";
|
|
9
|
+
const { Option } = Select;
|
|
8
10
|
const SelectedGroup = () => {
|
|
11
|
+
var _a;
|
|
9
12
|
const shape = Form.useWatch("shape");
|
|
10
13
|
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
14
|
+
const allShapeSelected = selectedGroup.map((item) => item.shape);
|
|
11
15
|
const sameShape = [
|
|
12
16
|
"table-seat-circle",
|
|
13
17
|
"table-seat-rect-circle",
|
|
@@ -16,10 +20,18 @@ const SelectedGroup = () => {
|
|
|
16
20
|
"table-seat-rect-square",
|
|
17
21
|
"table-seat-half-square",
|
|
18
22
|
].includes(shape);
|
|
19
|
-
const allShapeSelected = selectedGroup.map((item) => item.shape);
|
|
20
23
|
const shapeIncludeImage = ["background", "image-table", "polygon"].some((shape) => allShapeSelected.includes(shape));
|
|
24
|
+
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
21
25
|
const shapeAllIncludePolygon = allShapeSelected.includes("polygon");
|
|
22
|
-
|
|
26
|
+
const optionsSelect = (_a = optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.slice(0, -1)) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
27
|
+
return Object.assign(Object.assign({}, item), { disabled: allShapeSelected.includes(item.value) });
|
|
28
|
+
});
|
|
29
|
+
const maxSeat = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.some((item) => (item === null || item === void 0 ? void 0 : item[seatKey]) > 4);
|
|
30
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: " Group Selection" }), _jsxs("div", { className: "py-2", children: [_jsx(Flex, { gap: 2, className: "w-full", children: _jsx(Form.Item, { label: "Name", name: "shape", className: "w-full", children: _jsx(Select, { className: "w-full", children: optionsSelect === null || optionsSelect === void 0 ? void 0 : optionsSelect.map((item) => {
|
|
31
|
+
const disabled = item.value === "table-seat-rect-circle" && maxSeat;
|
|
32
|
+
return (_jsx(Option, { value: item.value, disabled: disabled, children: item.value === "table-seat-rect-circle" ?
|
|
33
|
+
`Type 5 (only for 4 ${seatKey})` : item.label }, item.value));
|
|
34
|
+
}) }) }) }), _jsxs(Flex, { gap: 2, className: "w-full", children: [["table-seat-circle", "table-seat-rect-circle"].includes(shape) && _jsx(SeatCircle, {}), [
|
|
23
35
|
"table-seat-square",
|
|
24
36
|
"table-seat-square",
|
|
25
37
|
"table-seat-rect-square",
|
|
@@ -37,7 +49,7 @@ const SelectedGroup = () => {
|
|
|
37
49
|
const num = Number(cleaned);
|
|
38
50
|
if (Number.isNaN(num))
|
|
39
51
|
return null;
|
|
40
|
-
return Math.min(
|
|
41
|
-
}, suffix: "%" }) })] })] }))] })] }) }));
|
|
52
|
+
return Math.min(100, Math.max(0, num));
|
|
53
|
+
}, suffix: "%" }) })] }), _jsx(SectionLabel, {})] }))] })] }) }));
|
|
42
54
|
};
|
|
43
55
|
export default SelectedGroup;
|
|
@@ -4,9 +4,13 @@ import { ColorPicker, Flex, Form, InputNumber, Select } from "antd";
|
|
|
4
4
|
import SeatCircle from "./table-seat-circle";
|
|
5
5
|
import SeatSquare from "./table-seat-square";
|
|
6
6
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
7
|
+
import SectionLabel from "../../components/form-tools/label";
|
|
8
|
+
const { Option } = Select;
|
|
7
9
|
const SelectedGroup = () => {
|
|
10
|
+
var _a;
|
|
8
11
|
const shape = Form.useWatch("shape");
|
|
9
12
|
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
13
|
+
const allShapeSelected = selectedGroup.map((item) => item.shape);
|
|
10
14
|
const sameShape = [
|
|
11
15
|
"table-seat-circle",
|
|
12
16
|
"table-seat-rect-circle",
|
|
@@ -15,18 +19,32 @@ const SelectedGroup = () => {
|
|
|
15
19
|
"table-seat-rect-square",
|
|
16
20
|
"table-seat-half-square",
|
|
17
21
|
].includes(shape);
|
|
18
|
-
const allShapeSelected = selectedGroup.map((item) => item.shape);
|
|
19
22
|
const shapeIncludeImage = ["background", "image-table", "polygon"].some((shape) => allShapeSelected.includes(shape));
|
|
23
|
+
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
20
24
|
const shapeAllIncludePolygon = allShapeSelected.includes("polygon");
|
|
25
|
+
const optionsSelect = (_a = optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.slice(0, -1)) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
26
|
+
return Object.assign(Object.assign({}, item), { disabled: allShapeSelected.includes(item.value) });
|
|
27
|
+
});
|
|
28
|
+
const maxSeat = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.some((item) => (item === null || item === void 0 ? void 0 : item[seatKey]) > 4);
|
|
21
29
|
return (<>
|
|
22
30
|
<div className="py-2">
|
|
23
31
|
<h1 className="heading-s"> Group Selection</h1>
|
|
24
32
|
<div className="py-2">
|
|
25
|
-
{!shapeIncludeImage && (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
{/* {!shapeIncludeImage && ( */}
|
|
34
|
+
<Flex gap={2} className="w-full">
|
|
35
|
+
<Form.Item label="Name" name="shape" className="w-full">
|
|
36
|
+
<Select className="w-full">
|
|
37
|
+
{optionsSelect === null || optionsSelect === void 0 ? void 0 : optionsSelect.map((item) => {
|
|
38
|
+
const disabled = item.value === "table-seat-rect-circle" && maxSeat;
|
|
39
|
+
return (<Option key={item.value} value={item.value} disabled={disabled}>
|
|
40
|
+
{item.value === "table-seat-rect-circle" ?
|
|
41
|
+
`Type 5 (only for 4 ${seatKey})` : item.label}
|
|
42
|
+
</Option>);
|
|
43
|
+
})}
|
|
44
|
+
</Select>
|
|
45
|
+
</Form.Item>
|
|
46
|
+
</Flex>
|
|
47
|
+
{/* )} */}
|
|
30
48
|
<Flex gap={2} className="w-full">
|
|
31
49
|
{["table-seat-circle", "table-seat-rect-circle"].includes(shape) && <SeatCircle />}
|
|
32
50
|
{[
|
|
@@ -89,10 +107,11 @@ const SelectedGroup = () => {
|
|
|
89
107
|
const num = Number(cleaned);
|
|
90
108
|
if (Number.isNaN(num))
|
|
91
109
|
return null;
|
|
92
|
-
return Math.min(
|
|
110
|
+
return Math.min(100, Math.max(0, num));
|
|
93
111
|
}} suffix="%"/>
|
|
94
112
|
</Form.Item>
|
|
95
113
|
</Flex>
|
|
114
|
+
<SectionLabel />
|
|
96
115
|
</>)}
|
|
97
116
|
</div>
|
|
98
117
|
</div>
|
|
@@ -4,11 +4,14 @@ import { ColorPicker, Flex, Form, Divider, InputNumber } from "antd";
|
|
|
4
4
|
import SectionLabel from "../../components/form-tools/label";
|
|
5
5
|
import SectionShape from "../../components/form-tools/shape";
|
|
6
6
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
7
|
+
import { isEmpty } from "lodash";
|
|
7
8
|
const SeatCircle = () => {
|
|
8
9
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
9
10
|
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
10
11
|
const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
11
12
|
const disabled = seatCountDefault > 0;
|
|
12
|
-
|
|
13
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
14
|
+
const allShapeSelected = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.map((item) => item.shape);
|
|
15
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx(SectionShape, { allowChangeShape: isEmpty(allShapeSelected) }), _jsx("h1", { className: "heading-s", children: "Section Seating" }), _jsx(Divider, { style: { margin: 4 } }), _jsxs(Flex, { children: [_jsx(Form.Item, { name: "seatCount", label: "Seat Count", className: "w-full", children: _jsx(InputNumber, { min: 0, disabled: disabled }) }), _jsx(Form.Item, { name: "openSpace", label: "Open Space", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 10, suffix: "%" }) })] }), _jsx(Flex, { gap: 2, children: _jsx(Form.Item, { label: "Seat Fill", name: "seatFill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }) }), _jsx(SectionLabel, {})] }) }));
|
|
13
16
|
};
|
|
14
17
|
export default SeatCircle;
|
|
@@ -3,14 +3,17 @@ import { ColorPicker, Flex, Form, Divider, InputNumber } from "antd";
|
|
|
3
3
|
import SectionLabel from "../../components/form-tools/label";
|
|
4
4
|
import SectionShape from "../../components/form-tools/shape";
|
|
5
5
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
6
|
+
import { isEmpty } from "lodash";
|
|
6
7
|
const SeatCircle = () => {
|
|
7
8
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
8
9
|
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
9
10
|
const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
10
11
|
const disabled = seatCountDefault > 0;
|
|
12
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
13
|
+
const allShapeSelected = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.map((item) => item.shape);
|
|
11
14
|
return (<>
|
|
12
15
|
<div className="py-2">
|
|
13
|
-
<SectionShape />
|
|
16
|
+
<SectionShape allowChangeShape={isEmpty(allShapeSelected)}/>
|
|
14
17
|
<h1 className="heading-s">Section Seating</h1>
|
|
15
18
|
<Divider style={{ margin: 4 }}/>
|
|
16
19
|
<Flex>
|
|
@@ -4,12 +4,18 @@ import { Col, ColorPicker, Divider, Flex, Form, InputNumber, Row, } from "antd";
|
|
|
4
4
|
import SectionLabel from "../../components/form-tools/label";
|
|
5
5
|
import SectionShape from "../../components/form-tools/shape";
|
|
6
6
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
7
|
+
import { isEmpty } from "lodash";
|
|
7
8
|
const SeatSquare = () => {
|
|
8
9
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
10
|
+
const allGroups = useAppSelector((state) => state.panel.selectedGroup);
|
|
9
11
|
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
10
12
|
const isSeatCustom = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "table-seat-rect-circle";
|
|
13
|
+
const allGroupCustom = allGroups === null || allGroups === void 0 ? void 0 : allGroups.some((g) => g.shape === "table-seat-rect-circle");
|
|
14
|
+
const allGroupCount = allGroups === null || allGroups === void 0 ? void 0 : allGroups.some((g) => (g === null || g === void 0 ? void 0 : g[seatKey]) > 0);
|
|
11
15
|
const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
12
|
-
const disabled = seatCountDefault > 0;
|
|
13
|
-
|
|
16
|
+
const disabled = seatCountDefault > 0 || allGroupCount;
|
|
17
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
18
|
+
const allShapeSelected = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.map((item) => item.shape);
|
|
19
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "py-2", children: [_jsx(SectionShape, { allowChangeShape: isEmpty(allShapeSelected) }), _jsx("h1", { className: "heading-s", children: "Section Seating" }), _jsx(Divider, { style: { margin: 4 } }), _jsx(Flex, { className: "w-full", children: _jsx(Form.Item, { name: "openSpace", label: "Open Space", className: "w-full", children: _jsx(InputNumber, { max: 100, min: 0, step: 10, suffix: "%", disabled: isSeatCustom || allGroupCustom }) }) }), _jsxs(Row, { gutter: [16, 16], children: [_jsxs(Col, { span: 12, children: [_jsx(Form.Item, { name: ["seatPositions", "top"], label: "Top", className: "w-full", children: _jsx(InputNumber, { min: 0, step: 1, disabled: disabled }) }), _jsx(Form.Item, { name: ["seatPositions", "left"], label: "Left", className: "w-full", children: _jsx(InputNumber, { min: 0, step: 1, disabled: disabled }) })] }), _jsxs(Col, { span: 12, children: [_jsx(Form.Item, { name: ["seatPositions", "right"], label: "Right", className: "w-full", children: _jsx(InputNumber, { min: 0, step: 1, disabled: disabled }) }), _jsx(Form.Item, { name: ["seatPositions", "bottom"], label: "Bottom", className: "w-full", children: _jsx(InputNumber, { min: 0, step: 1, disabled: disabled }) })] })] }), _jsx(Flex, { gap: 2, children: _jsx(Form.Item, { label: "Seat Fill", name: "seatFill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }) }), _jsx(SectionLabel, {})] }) }));
|
|
14
20
|
};
|
|
15
21
|
export default SeatSquare;
|
|
@@ -3,20 +3,26 @@ import { Col, ColorPicker, Divider, Flex, Form, InputNumber, Row, } from "antd";
|
|
|
3
3
|
import SectionLabel from "../../components/form-tools/label";
|
|
4
4
|
import SectionShape from "../../components/form-tools/shape";
|
|
5
5
|
import { useAppSelector } from "../../hooks/use-redux";
|
|
6
|
+
import { isEmpty } from "lodash";
|
|
6
7
|
const SeatSquare = () => {
|
|
7
8
|
const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
|
|
9
|
+
const allGroups = useAppSelector((state) => state.panel.selectedGroup);
|
|
8
10
|
const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
|
|
9
11
|
const isSeatCustom = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape) === "table-seat-rect-circle";
|
|
12
|
+
const allGroupCustom = allGroups === null || allGroups === void 0 ? void 0 : allGroups.some((g) => g.shape === "table-seat-rect-circle");
|
|
13
|
+
const allGroupCount = allGroups === null || allGroups === void 0 ? void 0 : allGroups.some((g) => (g === null || g === void 0 ? void 0 : g[seatKey]) > 0);
|
|
10
14
|
const seatCountDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
|
|
11
|
-
const disabled = seatCountDefault > 0;
|
|
15
|
+
const disabled = seatCountDefault > 0 || allGroupCount;
|
|
16
|
+
const selectedGroup = useAppSelector((state) => state.panel.selectedGroup);
|
|
17
|
+
const allShapeSelected = selectedGroup === null || selectedGroup === void 0 ? void 0 : selectedGroup.map((item) => item.shape);
|
|
12
18
|
return (<>
|
|
13
19
|
<div className="py-2">
|
|
14
|
-
<SectionShape />
|
|
20
|
+
<SectionShape allowChangeShape={isEmpty(allShapeSelected)}/>
|
|
15
21
|
<h1 className="heading-s">Section Seating</h1>
|
|
16
22
|
<Divider style={{ margin: 4 }}/>
|
|
17
23
|
<Flex className="w-full">
|
|
18
24
|
<Form.Item name="openSpace" label="Open Space" className="w-full">
|
|
19
|
-
<InputNumber max={100} min={0} step={10} suffix="%" disabled={isSeatCustom}/>
|
|
25
|
+
<InputNumber max={100} min={0} step={10} suffix="%" disabled={isSeatCustom || allGroupCustom}/>
|
|
20
26
|
</Form.Item>
|
|
21
27
|
</Flex>
|
|
22
28
|
<Row gutter={[16, 16]}>
|
|
@@ -2,14 +2,6 @@ import { SEAT_SHAPES } from "../../utils/constant";
|
|
|
2
2
|
import { MIN_HEIGHT, MIN_WIDTH } from "../board-v3/constant";
|
|
3
3
|
export const isSeatShape = (shape) => SEAT_SHAPES.includes(shape);
|
|
4
4
|
export const getSeatCount = (shape, props, defaultValue) => {
|
|
5
|
-
// if (shape === "table-seat-circle") {
|
|
6
|
-
// if (props?.seatCount) {
|
|
7
|
-
// return props.seatCount;
|
|
8
|
-
// } else if (props?.seatPositions) {
|
|
9
|
-
// const { top = 0, bottom = 0, left = 0, right = 0 } = props.seatPositions;
|
|
10
|
-
// return top + bottom + left + right;
|
|
11
|
-
// }
|
|
12
|
-
// }
|
|
13
5
|
if (!defaultValue) {
|
|
14
6
|
if (props === null || props === void 0 ? void 0 : props.seatCount) {
|
|
15
7
|
return props.seatCount;
|
|
@@ -22,15 +14,16 @@ export const getSeatCount = (shape, props, defaultValue) => {
|
|
|
22
14
|
};
|
|
23
15
|
export const getSeatPosition = (shape, props, defaultValue) => {
|
|
24
16
|
let seatCountDefault = defaultValue;
|
|
17
|
+
// console.log({ seatCountDefault})
|
|
25
18
|
if (shape === "table-seat-rect-circle") {
|
|
26
19
|
if (seatCountDefault > 4) {
|
|
27
20
|
seatCountDefault = 4;
|
|
28
21
|
}
|
|
29
|
-
console.log(props
|
|
22
|
+
// console.log(props?.seatPositions);
|
|
30
23
|
if (getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) > 4) {
|
|
31
24
|
return distributeSeats(4);
|
|
32
25
|
}
|
|
33
|
-
console.log(
|
|
26
|
+
// console.log(distributeSeats(seatCountDefault),"haduh");
|
|
34
27
|
return (props === null || props === void 0 ? void 0 : props.seatPositions) &&
|
|
35
28
|
getTotalSeats(props === null || props === void 0 ? void 0 : props.seatPositions) <= seatCountDefault
|
|
36
29
|
? normalizeSeatPosition(props === null || props === void 0 ? void 0 : props.seatPositions)
|
|
@@ -39,6 +39,7 @@ export interface LayerViewProps<TMeta = undefined> {
|
|
|
39
39
|
extraComponentProps?: ComponentProps[];
|
|
40
40
|
onCurrentStateChange?: OnCurrentStateChange;
|
|
41
41
|
onSelectComponent?: (component: ComponentProps<TMeta>) => void;
|
|
42
|
+
onDoubleClick?: (component: ComponentProps<TMeta>) => void;
|
|
42
43
|
mappingKey?: string;
|
|
43
44
|
tableMatchKey?: TableMatchKey[];
|
|
44
45
|
eventMatchTable?: TableMatchEvent[];
|
|
@@ -84,11 +85,12 @@ export interface LayerViewProps<TMeta = undefined> {
|
|
|
84
85
|
defaultBoundingBox?: PropertiesProps;
|
|
85
86
|
viewOnly?: boolean;
|
|
86
87
|
actionPrivileged?: {
|
|
87
|
-
select
|
|
88
|
-
move
|
|
89
|
-
switch
|
|
90
|
-
drop
|
|
91
|
-
rightClick
|
|
88
|
+
select?: boolean;
|
|
89
|
+
move?: boolean;
|
|
90
|
+
switch?: boolean;
|
|
91
|
+
drop?: boolean;
|
|
92
|
+
rightClick?: boolean;
|
|
93
|
+
double?: boolean;
|
|
92
94
|
};
|
|
93
95
|
}
|
|
94
96
|
declare const LayerView: <TMeta>(props: LayerViewProps<TMeta>) => import("react/jsx-runtime").JSX.Element;
|