seat-editor 3.5.5 → 3.5.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.
@@ -1878,6 +1878,15 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1878
1878
  };
1879
1879
  }, []);
1880
1880
  const hasSelectionBox = !isEmpty(selectedLines);
1881
+ const [cursor, setCursor] = useState("auto");
1882
+ useEffect(() => {
1883
+ if (activeTool === "grab") {
1884
+ setCursor("grab");
1885
+ }
1886
+ else {
1887
+ setCursor("auto");
1888
+ }
1889
+ }, [activeTool]);
1881
1890
  return (_jsxs(_Fragment, { children: [_jsxs(ModalPreview, { children: [_jsx(LayerView, { statusKey: "status", loadingRender: loadingRender, actionPrivileged: {
1882
1891
  select: false,
1883
1892
  move: false,
@@ -1922,13 +1931,21 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1922
1931
  },
1923
1932
  // centerZoomedOut={true}
1924
1933
  // onTransformed={handleTransformed}
1925
- minScale: 0.2, maxScale: 2, initialScale: scale, pinch: { step: 1 }, wheel: { disabled: true }, smooth: true, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1934
+ minScale: 0.2, maxScale: 2, initialScale: scale, pinch: { step: 1 }, wheel: { disabled: true }, smooth: true, onPanning: (e) => { }, onPanningStop: (e) => {
1935
+ if (activeTool === "grab") {
1936
+ setCursor("grab");
1937
+ }
1938
+ }, onPanningStart: (e) => {
1939
+ if (activeTool === "grab") {
1940
+ setCursor("grabbing");
1941
+ }
1942
+ }, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1926
1943
  width: "100%",
1927
1944
  height: "100%",
1928
1945
  }, contentStyle: { width: boardSize.width, height: boardSize.height }, children: _jsxs("svg", { id: "workspace", ref: svgRef, width: boardSize.width, height: boardSize.height, viewBox: `${minCoords.x} ${minCoords.y} ${boardSize.width} ${boardSize.height}`, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
1929
1946
  background: backgroundColor,
1930
1947
  display: "block",
1931
- cursor: activeTool === "ruler" ? "crosshair" : "auto",
1948
+ cursor,
1932
1949
  touchAction: "none",
1933
1950
  pointerEvents: "all",
1934
1951
  userSelect: "none",
@@ -1877,6 +1877,15 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1877
1877
  };
1878
1878
  }, []);
1879
1879
  const hasSelectionBox = !isEmpty(selectedLines);
1880
+ const [cursor, setCursor] = useState("auto");
1881
+ useEffect(() => {
1882
+ if (activeTool === "grab") {
1883
+ setCursor("grab");
1884
+ }
1885
+ else {
1886
+ setCursor("auto");
1887
+ }
1888
+ }, [activeTool]);
1880
1889
  return (<>
1881
1890
  <ModalPreview>
1882
1891
  <LayerView statusKey="status" loadingRender={loadingRender} actionPrivileged={{
@@ -1958,7 +1967,15 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1958
1967
  // centerZoomedOut={true}
1959
1968
  // onTransformed={handleTransformed}
1960
1969
  minScale={0.2} // sangat kecil = bisa zoom out jauh
1961
- maxScale={2} initialScale={scale} pinch={{ step: 1 }} wheel={{ disabled: true }} smooth={true} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding centerOnInit>
1970
+ maxScale={2} initialScale={scale} pinch={{ step: 1 }} wheel={{ disabled: true }} smooth={true} onPanning={(e) => { }} onPanningStop={(e) => {
1971
+ if (activeTool === "grab") {
1972
+ setCursor("grab");
1973
+ }
1974
+ }} onPanningStart={(e) => {
1975
+ if (activeTool === "grab") {
1976
+ setCursor("grabbing");
1977
+ }
1978
+ }} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding centerOnInit>
1962
1979
  {/* {scale !== 1 && ( */}
1963
1980
  {/* <div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10"> */}
1964
1981
  {/* {renderMiniMap()} */}
@@ -1971,7 +1988,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1971
1988
  <svg id="workspace" ref={svgRef} width={boardSize.width} height={boardSize.height} viewBox={`${minCoords.x} ${minCoords.y} ${boardSize.width} ${boardSize.height}`} onPointerDown={handlePointerDown} onPointerMove={handlePointerMove} xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" style={{
1972
1989
  background: backgroundColor,
1973
1990
  display: "block",
1974
- cursor: activeTool === "ruler" ? "crosshair" : "auto",
1991
+ cursor,
1975
1992
  touchAction: "none",
1976
1993
  pointerEvents: "all",
1977
1994
  userSelect: "none",
@@ -23,7 +23,7 @@ import clsx from "clsx";
23
23
  import { getAttributeElement } from "../board-v3/resize-element";
24
24
  import { applyResizeToSvgElement, getGlobalBBox, updateSelectionBox, } from "../board-v3/utils";
25
25
  import { SEAT_SHAPES } from "../../utils/constant";
26
- import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
26
+ import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, getValueIfSame, isSeatShape, showAllValueNotSame, } from "./utils";
27
27
  import SeatSquare from "./table-seat-square";
28
28
  import _ from "lodash";
29
29
  const FormPlaceholderContext = createContext(null);
@@ -105,50 +105,6 @@ const ControlPanels = (props) => {
105
105
  setOpen(true);
106
106
  if (!show)
107
107
  setOpen(false);
108
- function isSameAllByKey(arr, key) {
109
- if (!arr || arr.length === 0)
110
- return false;
111
- const firstValue = arr[0][key];
112
- return arr.every((item) => (item === null || item === void 0 ? void 0 : item[key]) === firstValue);
113
- }
114
- function getValueIfSame(arr, key) {
115
- var _a;
116
- if (key === "opacity") {
117
- return isSameAllByKey(arr, key)
118
- ? Number(arr[0][key]) * 100
119
- : undefined;
120
- }
121
- if (key === "labels") {
122
- const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); });
123
- return (arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); }))
124
- ? (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]
125
- : [];
126
- }
127
- return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
128
- }
129
- function getAllValuesKey(arr, key) {
130
- return arr
131
- .map((item) => item === null || item === void 0 ? void 0 : item[key])
132
- .filter((value) => value !== undefined)
133
- .sort((a, b) => {
134
- if (typeof a === "number" && typeof b === "number")
135
- return a - b;
136
- return String(a).localeCompare(String(b));
137
- })
138
- .filter((value, index, self) => self.indexOf(value) === index);
139
- }
140
- function showAllValueNotSame(arr, key) {
141
- if (key === "opacity") {
142
- return !isSameAllByKey(arr, key)
143
- ? `${getAllValuesKey(arr, key)
144
- .map((value) => Number(value) * 100)
145
- .join(", ")}`
146
- : `${Number(arr[0][key]) * 100}`;
147
- }
148
- return !isSameAllByKey(arr, key)
149
- ? `${getAllValuesKey(arr, key)}`
150
- : `${arr[0][key]}`;
151
- }
152
108
  const fields = [
153
109
  "width",
154
110
  "height",
@@ -203,11 +159,11 @@ const ControlPanels = (props) => {
203
159
  setOpen(false);
204
160
  }
205
161
  }, [selectedComponent, selectedGroup, show, groupBufferSelected, tool]);
206
- const createShape = (shape, props = {}, selectedComponent) => {
162
+ const createShape = (shape, props = {}, selectedComponent, valuesChanges) => {
207
163
  var _a, _b, _c, _d, _e, _f, _g, _h;
208
164
  const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
209
165
  const seatDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
210
- 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)
166
+ 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, valuesChanges)) === 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, valuesChanges)) === 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)
211
167
  ? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0
212
168
  : undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
213
169
  ? (_f = props.seatFill) !== null && _f !== void 0 ? _f : theme === null || theme === void 0 ? void 0 : theme.primaryColor
@@ -282,7 +238,7 @@ const ControlPanels = (props) => {
282
238
  const handleChangeComponent = (values, allValues) => {
283
239
  var _a, _b, _c;
284
240
  const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
285
- const newValues = createShape(shape, restProps, selectedComponent);
241
+ const newValues = createShape(shape, restProps, selectedComponent, values);
286
242
  if (selectedComponent) {
287
243
  updateElement(allValues.id, values);
288
244
  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 }));
@@ -22,7 +22,7 @@ import clsx from "clsx";
22
22
  import { getAttributeElement } from "../board-v3/resize-element";
23
23
  import { applyResizeToSvgElement, getGlobalBBox, updateSelectionBox, } from "../board-v3/utils";
24
24
  import { SEAT_SHAPES } from "../../utils/constant";
25
- import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, isSeatShape, } from "./utils";
25
+ import { adjustHeightWidthForSeatShape, getSeatCount, getSeatPosition, getValueIfSame, isSeatShape, showAllValueNotSame, } from "./utils";
26
26
  import SeatSquare from "./table-seat-square";
27
27
  import _ from "lodash";
28
28
  const FormPlaceholderContext = createContext(null);
@@ -104,50 +104,6 @@ const ControlPanels = (props) => {
104
104
  setOpen(true);
105
105
  if (!show)
106
106
  setOpen(false);
107
- function isSameAllByKey(arr, key) {
108
- if (!arr || arr.length === 0)
109
- return false;
110
- const firstValue = arr[0][key];
111
- return arr.every((item) => (item === null || item === void 0 ? void 0 : item[key]) === firstValue);
112
- }
113
- function getValueIfSame(arr, key) {
114
- var _a;
115
- if (key === "opacity") {
116
- return isSameAllByKey(arr, key)
117
- ? Number(arr[0][key]) * 100
118
- : undefined;
119
- }
120
- if (key === "labels") {
121
- const test = arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); });
122
- return (arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); }))
123
- ? (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]
124
- : [];
125
- }
126
- return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
127
- }
128
- function getAllValuesKey(arr, key) {
129
- return arr
130
- .map((item) => item === null || item === void 0 ? void 0 : item[key])
131
- .filter((value) => value !== undefined)
132
- .sort((a, b) => {
133
- if (typeof a === "number" && typeof b === "number")
134
- return a - b;
135
- return String(a).localeCompare(String(b));
136
- })
137
- .filter((value, index, self) => self.indexOf(value) === index);
138
- }
139
- function showAllValueNotSame(arr, key) {
140
- if (key === "opacity") {
141
- return !isSameAllByKey(arr, key)
142
- ? `${getAllValuesKey(arr, key)
143
- .map((value) => Number(value) * 100)
144
- .join(", ")}`
145
- : `${Number(arr[0][key]) * 100}`;
146
- }
147
- return !isSameAllByKey(arr, key)
148
- ? `${getAllValuesKey(arr, key)}`
149
- : `${arr[0][key]}`;
150
- }
151
107
  const fields = [
152
108
  "width",
153
109
  "height",
@@ -202,11 +158,11 @@ const ControlPanels = (props) => {
202
158
  setOpen(false);
203
159
  }
204
160
  }, [selectedComponent, selectedGroup, show, groupBufferSelected, tool]);
205
- const createShape = (shape, props = {}, selectedComponent) => {
161
+ const createShape = (shape, props = {}, selectedComponent, valuesChanges) => {
206
162
  var _a, _b, _c, _d, _e, _f, _g, _h;
207
163
  const defaults = (_a = SEAT_SHAPES[shape]) !== null && _a !== void 0 ? _a : {};
208
164
  const seatDefault = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey];
209
- 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)
165
+ 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, valuesChanges)) === 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, valuesChanges)) === 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)
210
166
  ? (_e = props.openSpace) !== null && _e !== void 0 ? _e : 0
211
167
  : undefined, seatFill: isSeatShape(shape !== null && shape !== void 0 ? shape : props === null || props === void 0 ? void 0 : props.shape)
212
168
  ? (_f = props.seatFill) !== null && _f !== void 0 ? _f : theme === null || theme === void 0 ? void 0 : theme.primaryColor
@@ -281,7 +237,7 @@ const ControlPanels = (props) => {
281
237
  const handleChangeComponent = (values, allValues) => {
282
238
  var _a, _b, _c;
283
239
  const { shape } = allValues, restProps = __rest(allValues, ["shape"]);
284
- const newValues = createShape(shape, restProps, selectedComponent);
240
+ const newValues = createShape(shape, restProps, selectedComponent, values);
285
241
  if (selectedComponent) {
286
242
  updateElement(allValues.id, values);
287
243
  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 }));
@@ -39,7 +39,7 @@ const SelectedGroup = () => {
39
39
  return (_jsx(Option, { value: item.value, disabled: disabled, children: item.value === "table-seat-rect-circle"
40
40
  ? `Type 5 (only for 4 ${seatKey})`
41
41
  : item.label }, item.value));
42
- }) }) }) })), _jsxs(Flex, { gap: 2, className: "w-full", vertical: true, children: [!shapeAllIncludePolygon && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "width", placeholder: placeholders["width"], style: { width: "100%" } }) }), _jsx(Form.Item, { label: "Height", name: "height", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "height", placeholder: placeholders["height"], style: { width: "100%" } }) })] })), !(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && !shapeAllIncludePolygon && (_jsx(Form.Item, { label: "Radius", name: "radius", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "radius", suffix: "px", style: { width: "100%" }, placeholder: placeholders["radius"], parser: (value) => {
42
+ }) }) }) })), _jsxs(Flex, { gap: 2, className: "w-full", vertical: true, children: [!shapeAllIncludePolygon && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "width", changeOnWheel: true, placeholder: placeholders["width"], style: { width: "100%" } }) }), _jsx(Form.Item, { label: "Height", name: "height", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "height", placeholder: placeholders["height"], style: { width: "100%" } }) })] })), !(shape === null || shape === void 0 ? void 0 : shape.includes("circle")) && !shapeAllIncludePolygon && (_jsx(Form.Item, { label: "Radius", name: "radius", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "radius", suffix: "px", style: { width: "100%" }, placeholder: placeholders["radius"], parser: (value) => {
43
43
  var _a;
44
44
  const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
45
45
  return onlyNumber === ""
@@ -73,7 +73,7 @@ const SelectedGroup = () => {
73
73
  <Flex gap={2} className="w-full" vertical>
74
74
  {!shapeAllIncludePolygon && (<>
75
75
  <Form.Item label="Width" name="width" className="w-full" layout="horizontal" labelCol={{ style: { width: 100, textAlign: "left" } }} wrapperCol={{ style: { flex: 1 } }}>
76
- <InputNumber suffix="px" name="width" placeholder={placeholders["width"]} style={{ width: "100%" }}/>
76
+ <InputNumber suffix="px" name="width" changeOnWheel placeholder={placeholders["width"]} style={{ width: "100%" }}/>
77
77
  </Form.Item>
78
78
  <Form.Item label="Height" name="height" className="w-full" layout="horizontal" labelCol={{ style: { width: 100, textAlign: "left" } }} wrapperCol={{ style: { flex: 1 } }}>
79
79
  <InputNumber suffix="px" name="height" placeholder={placeholders["height"]} style={{ width: "100%" }}/>
@@ -13,7 +13,6 @@ import { useState, useEffect } from "react";
13
13
  import { Upload, Image, Button, Form, Flex } from "antd";
14
14
  import { InboxOutlined, LoadingOutlined } from "@ant-design/icons";
15
15
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
16
- import SectionLabel from "../../components/form-tools/label";
17
16
  import SectionShape from "../../components/form-tools/shape";
18
17
  const { Dragger } = Upload;
19
18
  const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
@@ -161,6 +160,6 @@ const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
161
160
  dispatch({ type: "panel/setShow", payload: false });
162
161
  dispatch({ type: "tool/setActiveTool", payload: "select" });
163
162
  };
164
- return (_jsxs(Form.Item, { label: "", name: "src", className: "w-full", children: [defaultSrc ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "w-full flex flex-col items-center gap-2 max-h-[200px] overflow-y-auto", children: _jsx(Image, { src: defaultSrc }) }), _jsxs(Flex, { vertical: true, gap: 5, children: [_jsx(Button, { type: "primary", onClick: handleDelete, className: "w-full mt-4", loading: loading, children: "Edit" }), _jsx(Button, { type: "default", onClick: deleteImages, className: "w-full", loading: loading, children: "Delete" })] })] })) : (_jsx(Dragger, Object.assign({ beforeUpload: () => false }, propsUpload, { children: loading ? (_jsx("div", { className: "w-full flex flex-col items-center gap-2 max-h-[200px]", children: _jsx(LoadingOutlined, {}) })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "ant-upload-drag-icon", children: _jsx(InboxOutlined, {}) }), _jsx("p", { className: "ant-upload-text", children: "Click or drag file to this area to upload" }), _jsx("p", { className: "ant-upload-hint", children: "Support for a single or bulk upload. Strictly prohibited from uploading company data or other banned files." })] })) }))), (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) && (_jsxs(_Fragment, { children: [_jsx(SectionShape, { allowChangeShape: type === "component" }), _jsx(SectionLabel, {})] }))] }));
163
+ return (_jsxs(Form.Item, { label: "", name: "src", className: "w-full", children: [defaultSrc ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "w-full flex flex-col items-center gap-2 max-h-[200px] overflow-y-auto", children: _jsx(Image, { src: defaultSrc }) }), _jsxs(Flex, { vertical: true, gap: 5, children: [_jsx(Button, { type: "primary", onClick: handleDelete, className: "w-full mt-4", loading: loading, children: "Edit" }), _jsx(Button, { type: "default", onClick: deleteImages, className: "w-full", loading: loading, children: "Delete" })] })] })) : (_jsx(Dragger, Object.assign({ beforeUpload: () => false }, propsUpload, { children: loading ? (_jsx("div", { className: "w-full flex flex-col items-center gap-2 max-h-[200px]", children: _jsx(LoadingOutlined, {}) })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "ant-upload-drag-icon", children: _jsx(InboxOutlined, {}) }), _jsx("p", { className: "ant-upload-text", children: "Click or drag file to this area to upload" }), _jsx("p", { className: "ant-upload-hint", children: "Support for a single or bulk upload. Strictly prohibited from uploading company data or other banned files." })] })) }))), (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) && (_jsx(_Fragment, { children: _jsx(SectionShape, { allowChangeShape: type === "component" }) }))] }));
165
164
  };
166
165
  export default UploadTool;
@@ -12,7 +12,6 @@ import { useState, useEffect } from "react";
12
12
  import { Upload, Image, Button, Form, Flex } from "antd";
13
13
  import { InboxOutlined, LoadingOutlined } from "@ant-design/icons";
14
14
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
15
- import SectionLabel from "../../components/form-tools/label";
16
15
  import SectionShape from "../../components/form-tools/shape";
17
16
  const { Dragger } = Upload;
18
17
  const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
@@ -191,7 +190,7 @@ const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
191
190
  </Dragger>)}
192
191
  {(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) && (<>
193
192
  <SectionShape allowChangeShape={type === "component"}/>
194
- <SectionLabel />
193
+ {/* <SectionLabel /> */}
195
194
  </>)}
196
195
  </Form.Item>);
197
196
  };
@@ -8,4 +8,19 @@ export declare const getSeatPosition: (shape: string, props: PropertiesProps, de
8
8
  bottom: number;
9
9
  left: number;
10
10
  };
11
- export declare const adjustHeightWidthForSeatShape: (shape: string, props: any) => any;
11
+ export declare const adjustHeightWidthForSeatShape: (shape: string, props: any, valuesChanges: {
12
+ [key: string]: any;
13
+ }) => any;
14
+ type SeatPosition = {
15
+ top: number;
16
+ right: number;
17
+ bottom: number;
18
+ left: number;
19
+ };
20
+ export declare function normalizeSeatPosition(input: SeatPosition): SeatPosition;
21
+ export declare function getTotalSeats(position: SeatPosition): number;
22
+ export declare function isSameAllByKey<T>(arr: T[] | undefined, key: keyof T): boolean;
23
+ export declare function getValueIfSame<T>(arr: T[], key: keyof T): number | any[] | T[keyof T];
24
+ export declare function getAllValuesKey<T>(arr: T[], key: keyof T): T[keyof T][];
25
+ export declare function showAllValueNotSame(arr: any[], key: string): string;
26
+ export {};
@@ -1,3 +1,4 @@
1
+ import _ from "lodash";
1
2
  import { SEAT_SHAPES } from "../../utils/constant";
2
3
  import { MIN_HEIGHT, MIN_WIDTH } from "../board-v3/constant";
3
4
  export const isSeatShape = (shape) => SEAT_SHAPES.includes(shape);
@@ -56,10 +57,13 @@ export const getSeatPosition = (shape, props, defaultValue) => {
56
57
  }
57
58
  return distributeSeats(seatCountDefault);
58
59
  };
59
- export const adjustHeightWidthForSeatShape = (shape, props) => {
60
+ export const adjustHeightWidthForSeatShape = (shape, props, valuesChanges) => {
60
61
  if (shape === null || shape === void 0 ? void 0 : shape.includes("circle")) {
61
62
  const sizeDefault = Math.min(props.width, props.height);
62
- const sizeFinal = sizeDefault < MIN_WIDTH ? MIN_WIDTH : sizeDefault;
63
+ let sizeFinal = sizeDefault < MIN_WIDTH ? MIN_WIDTH : sizeDefault;
64
+ if ((valuesChanges === null || valuesChanges === void 0 ? void 0 : valuesChanges.width) || (valuesChanges === null || valuesChanges === void 0 ? void 0 : valuesChanges.height)) {
65
+ sizeFinal = (valuesChanges === null || valuesChanges === void 0 ? void 0 : valuesChanges.width) || (valuesChanges === null || valuesChanges === void 0 ? void 0 : valuesChanges.height) || sizeDefault;
66
+ }
63
67
  return Object.assign(Object.assign({}, props), { height: isNaN(sizeFinal) ? MIN_WIDTH : sizeFinal, width: isNaN(sizeFinal) ? MIN_HEIGHT : sizeFinal });
64
68
  }
65
69
  return props;
@@ -82,7 +86,7 @@ function distributeSeats(seatCount) {
82
86
  }
83
87
  return result;
84
88
  }
85
- function normalizeSeatPosition(input) {
89
+ export function normalizeSeatPosition(input) {
86
90
  const clamp = (value) => Math.max(0, Math.min(1, value));
87
91
  return {
88
92
  top: clamp(input.top),
@@ -91,7 +95,7 @@ function normalizeSeatPosition(input) {
91
95
  left: clamp(input.left),
92
96
  };
93
97
  }
94
- function getTotalSeats(position) {
98
+ export function getTotalSeats(position) {
95
99
  const { top, right, bottom, left } = position || {
96
100
  top: 0,
97
101
  right: 0,
@@ -100,3 +104,46 @@ function getTotalSeats(position) {
100
104
  };
101
105
  return top + right + bottom + left;
102
106
  }
107
+ export function isSameAllByKey(arr, key) {
108
+ if (!arr || arr.length === 0)
109
+ return false;
110
+ const firstValue = arr[0][key];
111
+ return arr.every((item) => (item === null || item === void 0 ? void 0 : item[key]) === firstValue);
112
+ }
113
+ export function getValueIfSame(arr, key) {
114
+ var _a;
115
+ if (key === "opacity") {
116
+ return isSameAllByKey(arr, key)
117
+ ? Number(arr[0][key]) * 100
118
+ : undefined;
119
+ }
120
+ if (key === "labels") {
121
+ return (arr === null || arr === void 0 ? void 0 : arr.every((item) => { var _a; return _.isEqual(item === null || item === void 0 ? void 0 : item[key], (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]); }))
122
+ ? (_a = arr === null || arr === void 0 ? void 0 : arr[0]) === null || _a === void 0 ? void 0 : _a[key]
123
+ : [];
124
+ }
125
+ return isSameAllByKey(arr, key) ? arr[0][key] : undefined;
126
+ }
127
+ export function getAllValuesKey(arr, key) {
128
+ return arr
129
+ .map((item) => item === null || item === void 0 ? void 0 : item[key])
130
+ .filter((value) => value !== undefined)
131
+ .sort((a, b) => {
132
+ if (typeof a === "number" && typeof b === "number")
133
+ return a - b;
134
+ return String(a).localeCompare(String(b));
135
+ })
136
+ .filter((value, index, self) => self.indexOf(value) === index);
137
+ }
138
+ export function showAllValueNotSame(arr, key) {
139
+ if (key === "opacity") {
140
+ return !isSameAllByKey(arr, key)
141
+ ? `${getAllValuesKey(arr, key)
142
+ .map((value) => Number(value) * 100)
143
+ .join(", ")}`
144
+ : `${Number(arr[0][key]) * 100}`;
145
+ }
146
+ return !isSameAllByKey(arr, key)
147
+ ? `${getAllValuesKey(arr, key)}`
148
+ : `${arr[0][key]}`;
149
+ }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan, ScanEye, } from "lucide-react";
3
+ import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan, ScanEye, } from "lucide-react";
4
4
  import ButtonTools from "../../components/button-tools";
5
5
  import { Divider, ColorPicker, Button, message, Popover, Flex, } from "antd";
6
6
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
@@ -367,15 +367,6 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
367
367
  content: _jsx("div", { children: "Grid Tool" }),
368
368
  trigger: "hover",
369
369
  placement: "right",
370
- } }), _jsx(ButtonTools, { buttonProps: {
371
- onClick: () => handleRemoveComponent(),
372
- icon: _jsx(Trash, {}),
373
- type: "text",
374
- name: "trash",
375
- }, items: [], popoverProps: {
376
- content: _jsx("div", { children: "Trash Tool" }),
377
- trigger: "hover",
378
- placement: "right",
379
370
  } }), _jsx(ButtonTools, { buttonProps: {
380
371
  onClick: () => toogleSetLockBackground(),
381
372
  icon: lockBackground ? _jsx(Lock, {}) : _jsx(LockOpen, {}),
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Trash, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan, ScanEye, } from "lucide-react";
2
+ import { Circle, CopyPlus, Eye, EyeOff, Image, Layers2, MousePointer, PaintBucket, Ratio, SquareMousePointer, Type, Upload, Hand, Layers, Grid, Lock, LockOpen, Undo2, Redo2, PenTool, Scan, ScanEye, } from "lucide-react";
3
3
  import ButtonTools from "../../components/button-tools";
4
4
  import { Divider, ColorPicker, Button, message, Popover, Flex, } from "antd";
5
5
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
@@ -392,16 +392,20 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
392
392
  trigger: "hover",
393
393
  placement: "right",
394
394
  }}/>
395
- <ButtonTools buttonProps={{
395
+ {/* <ButtonTools
396
+ buttonProps={{
396
397
  onClick: () => handleRemoveComponent(),
397
398
  icon: <Trash />,
398
399
  type: "text",
399
400
  name: "trash",
400
- }} items={[]} popoverProps={{
401
+ }}
402
+ items={[]}
403
+ popoverProps={{
401
404
  content: <div>Trash Tool</div>,
402
405
  trigger: "hover",
403
406
  placement: "right",
404
- }}/>
407
+ }}
408
+ /> */}
405
409
  <ButtonTools buttonProps={{
406
410
  onClick: () => toogleSetLockBackground(),
407
411
  icon: lockBackground ? <Lock /> : <LockOpen />,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.5.5",
3
+ "version": "3.5.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",