seat-editor 3.5.17 → 3.5.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,18 +12,8 @@ const ButtonTools = (props) => {
12
12
  maxWidth: "fit-content",
13
13
  },
14
14
  }} {...popoverProps}>
15
- {/* <Popover
16
- title={buttonProps?.name}
17
- trigger={"hover"}
18
- placement="right"
19
- styles={{
20
- body: {
21
- minWidth: "max-content",
22
- },
23
- }}
24
- > */}
15
+
25
16
  <Button {...buttonProps}/>
26
- {/* </Popover> */}
27
17
  </Popover>);
28
18
  };
29
19
  export default ButtonTools;
@@ -9,6 +9,6 @@ const SectionLabel = () => {
9
9
  if (Number.isNaN(num))
10
10
  return 0;
11
11
  return Math.min(360, Math.max(0, num));
12
- } }) })] }), _jsxs(Flex, { gap: 5, children: [_jsx(Form.Item, { name: [field.name, "fontSize"], label: "Size", children: _jsx(InputNumber, { suffix: "px" }) }), _jsx(Form.Item, { name: [field.name, "fontColor"], label: "Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] })] }, field.key))) })) }) }), _jsx("div", { className: "divider-dashed" })] }));
12
+ } }) })] }), _jsxs(Flex, { gap: 5, children: [_jsx(Form.Item, { name: [field.name, "fontSize"], label: "Size", children: _jsx(InputNumber, { suffix: "px" }) }), _jsx(Form.Item, { name: [field.name, "fontColor"], label: "Text Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] })] }, field.key))) })) }) }), _jsx("div", { className: "divider-dashed" })] }));
13
13
  };
14
14
  export default SectionLabel;
@@ -36,7 +36,7 @@ const SectionLabel = () => {
36
36
  <Form.Item name={[field.name, "fontSize"]} label="Size">
37
37
  <InputNumber suffix="px"/>
38
38
  </Form.Item>
39
- <Form.Item name={[field.name, "fontColor"]} label="Color" getValueFromEvent={(color) => color.toHexString()}>
39
+ <Form.Item name={[field.name, "fontColor"]} label="Text Color" getValueFromEvent={(color) => color.toHexString()}>
40
40
  <ColorPicker allowClear format="hex" defaultFormat="hex"/>
41
41
  </Form.Item>
42
42
  </Flex>
@@ -77,7 +77,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
77
77
  if (Number.isNaN(num))
78
78
  return 0;
79
79
  return Math.min(360, Math.max(0, num));
80
- } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
80
+ } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "Opacity Fill", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
81
81
  if (value === undefined || value === null || value === "")
82
82
  return null;
83
83
  const cleaned = value.replace(/[^0-9.]/g, "");
@@ -126,7 +126,7 @@ const SectionShape = ({ allowChangeShape = true, }) => {
126
126
  </Form.Item>
127
127
  </Flex>
128
128
  <Flex>
129
- <Form.Item label="opacity" name={"opacity"} className="w-full">
129
+ <Form.Item label="Opacity Fill" name={"opacity"} className="w-full">
130
130
  <InputNumber step={10} max={100} min={0} name="opacity" parser={(value) => {
131
131
  if (value === undefined || value === null || value === "")
132
132
  return null;
@@ -439,7 +439,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
439
439
  }) })] }) }, id));
440
440
  }
441
441
  case "text":
442
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", { width: width, height: height, fill: "transparent", opacity: opacity }), _jsx("text", Object.assign({ x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity"]), { children: text }))] }) }, id));
442
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"]))), _jsx("text", Object.assign({ "data-text-raw": `${id}-text`, x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity", "stroke", "strokeWidth"]), { children: text }))] }) }, id));
443
443
  case "image-table":
444
444
  case "background":
445
445
  return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: {
@@ -547,8 +547,8 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
547
547
  case "text":
548
548
  return (<g key={id} data-id={id} transform={`translate(${x}, ${y})`}>
549
549
  <g transform={`rotate(${rotation}, 0, 0)`}>
550
- <rect width={width} height={height} fill="transparent" opacity={opacity}/>
551
- <text x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}>
550
+ <rect width={width} height={height} fill="transparent" opacity={opacity} {...omit(commonProps, ["fill", "opacity"])}/>
551
+ <text data-text-raw={`${id}-text`} x={width / 2} y={height / 2} textAnchor="middle" dominantBaseline="middle" fill={fill !== null && fill !== void 0 ? fill : fontColor} fontSize={fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6} opacity={opacity} {...omit(commonProps, ["fill", "opacity", "stroke", "strokeWidth"])}>
552
552
  {text}
553
553
  </text>
554
554
  </g>
@@ -13,6 +13,7 @@ import { Button, Flex, Radio, Slider, Tag, } from "antd";
13
13
  import { getAttributeElement, getAttributeElements } from "./resize-element";
14
14
  import { applyResizeToSvgElement, arrayToSvgPointsAttr, createTableGhost, getGlobalBBox, getRotation, getSvgElementSize, getTranslate, isClosingPolygon, normalizeAngle, pointsStringToArray, resizeBox, resizeSeatCircle, resizeSeatRectCircle, resizeSeatRectSquare, resizeSeatSide, resizeSeatSquare, stabilizeRotation, stabilizeTranslateOnRotate, updateManyComponents, updateSelectionBox, updateSelectionGuides, updateSingleComponent, } from "./utils";
15
15
  import { getOS } from "../../utils/agent";
16
+ import { MIN_HEIGHT, MIN_WIDTH } from "./constant";
16
17
  const toolElement = ["square", "circle", "table-seat-circle"];
17
18
  const idSelectionBoxGhost = "selection-box-ghost";
18
19
  const nameShapeSelectionBoxGhost = "selection-box";
@@ -78,7 +79,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
78
79
  const [selectedLines, setSelectedLines] = useState(null);
79
80
  useEffect(() => {
80
81
  if (activeTool === "select" || activeTool !== "select") {
81
- handleUnSelectComponent();
82
+ (selectedComponentProps === null || selectedComponentProps === void 0 ? void 0 : selectedComponentProps.shape) !== "text" && handleUnSelectComponent();
82
83
  }
83
84
  if (activeTool !== "polygon") {
84
85
  isOnMakePolygonRef.current = false;
@@ -416,7 +417,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
416
417
  };
417
418
  }, [dataElementSelectionGroupRef.current]);
418
419
  const handlePointerDown = (e) => {
419
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
420
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
420
421
  const shiftActive = e.shiftKey;
421
422
  if (activeTool === "grab") {
422
423
  return;
@@ -466,15 +467,16 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
466
467
  isCreateElementRef.current = true;
467
468
  }
468
469
  else if (isInitialCreateText) {
469
- const tables = createTableGhost({
470
+ const [elTemp, el] = createTableGhost({
470
471
  x,
471
472
  y,
472
- width: 100 * scale,
473
- height: 50 * scale,
473
+ width: MIN_WIDTH,
474
+ height: MIN_HEIGHT,
474
475
  fill: "#000000",
475
476
  shape: activeTool,
476
477
  });
477
- (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(tables);
478
+ (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(elTemp);
479
+ (_d = svgRef.current) === null || _d === void 0 ? void 0 : _d.appendChild(el);
478
480
  isCreateElementRef.current = true;
479
481
  }
480
482
  const targetSelection = e.target.closest("g[id='selection-lines']");
@@ -485,14 +487,14 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
485
487
  }
486
488
  let positionSelection = null;
487
489
  if (activeTool === "select") {
488
- positionSelection = (_e = (_d = e.target.closest(`polyline[data-position]`)) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.position;
490
+ positionSelection = (_f = (_e = e.target.closest(`polyline[data-position]`)) === null || _e === void 0 ? void 0 : _e.dataset) === null || _f === void 0 ? void 0 : _f.position;
489
491
  }
490
492
  // RESIZE
491
493
  const targetGroup = e.target.closest("g[data-id]");
492
494
  const targetPointPolygon = e.target.closest("circle[data-point]");
493
495
  // TARGET ELEMENT
494
496
  let idTargetElement = JSON.parse((targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.getAttribute("data-id")) || "{}");
495
- const selectionTarget = (_g = (_f = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _f === void 0 ? void 0 : _f.selection) === null || _g === void 0 ? void 0 : _g.replace("selection-", "");
497
+ const selectionTarget = (_h = (_g = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _g === void 0 ? void 0 : _g.selection) === null || _h === void 0 ? void 0 : _h.replace("selection-", "");
496
498
  const activeId = selectionTarget !== null && selectionTarget !== void 0 ? selectionTarget : idTargetElement;
497
499
  const isInSelectionTarget = !isUndefined(selectionTarget);
498
500
  const isInTargetElement = !isPlainObject(idTargetElement);
@@ -500,7 +502,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
500
502
  const { g } = getAttributeElement(svg, activeId);
501
503
  if (targetGroup && shiftActive) {
502
504
  const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
503
- const currentSelection = (_h = dataElementSelectionGroupRef.current) !== null && _h !== void 0 ? _h : [];
505
+ const currentSelection = (_j = dataElementSelectionGroupRef.current) !== null && _j !== void 0 ? _j : [];
504
506
  if (currentSelection.length == 0 && selectedComponent) {
505
507
  currentSelection.push(selectedComponent);
506
508
  }
@@ -520,7 +522,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
520
522
  const hitPoint = document.elementFromPoint(clientX, clientY);
521
523
  // CHECK FOR HIT ON SVG FOR SELECTION BOX
522
524
  // MAKE AND UNMAKE SELECTION BOX START ------
523
- const hadSelectionBox = ((_j = dataElementSelectionGroupRef.current) === null || _j === void 0 ? void 0 : _j.length) > 0 && !isSingleSelection;
525
+ const hadSelectionBox = ((_k = dataElementSelectionGroupRef.current) === null || _k === void 0 ? void 0 : _k.length) > 0 && !isSingleSelection;
524
526
  const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
525
527
  const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
526
528
  const downBeforeHasSelectionBox = !downInSelectionBox &&
@@ -558,7 +560,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
558
560
  shape: nameShapeSelectionBoxGhost,
559
561
  id: idSelectionBoxGhost,
560
562
  });
561
- (_k = svgRef.current) === null || _k === void 0 ? void 0 : _k.appendChild(boxSelection);
563
+ (_l = svgRef.current) === null || _l === void 0 ? void 0 : _l.appendChild(boxSelection);
562
564
  }
563
565
  // MAKE AND UNMAKE SELECTION BOX END ------
564
566
  // RESIZE SELECTION BOX
@@ -830,7 +832,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
830
832
  updateSelectionBox(svg, resultSelection);
831
833
  const scaleX = resultSelection.width / oldSel.width;
832
834
  const scaleY = resultSelection.height / oldSel.height;
833
- allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text }, i) => {
835
+ allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text, textRaw }, i) => {
834
836
  var _a, _b;
835
837
  const activeId = JSON.parse(g === null || g === void 0 ? void 0 : g.getAttribute("data-id"));
836
838
  const elementOld = allDataRealSelection === null || allDataRealSelection === void 0 ? void 0 : allDataRealSelection.find((el) => el.id == activeId);
@@ -915,7 +917,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
915
917
  });
916
918
  }
917
919
  }
918
- applyResizeToSvgElement(element, g, newElement, text);
920
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
919
921
  });
920
922
  };
921
923
  if (downAtResizePositionAndHasSelectionBox)
@@ -1058,7 +1060,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1058
1060
  var _a, _b;
1059
1061
  const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
1060
1062
  const svg = svgRef.current;
1061
- const { g, element, seats, seatGroup, text } = getAttributeElement(svg, activeId);
1063
+ const { g, element, seats, seatGroup, text, textRaw } = getAttributeElement(svg, activeId);
1062
1064
  const isZeroRotate = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.rotation) === 0 &&
1063
1065
  !(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape.includes("circle"));
1064
1066
  const elementSelect = {
@@ -1197,7 +1199,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1197
1199
  });
1198
1200
  }
1199
1201
  }
1200
- applyResizeToSvgElement(element, g, newElement, text);
1202
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
1201
1203
  isResizeRef.current = true;
1202
1204
  };
1203
1205
  // const hasSelectedOneElement =
@@ -1605,7 +1607,8 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1605
1607
  if (isInitialCreateText) {
1606
1608
  const ghost = svg.querySelector("#ghost-element-create");
1607
1609
  const getBBox = getGlobalBBox(svg, ghost);
1608
- const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14 });
1610
+ console.log({ getBBox });
1611
+ const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14, rotation: 0 });
1609
1612
  addComponents(text);
1610
1613
  dispatch({
1611
1614
  type: "panel/setShow",
@@ -1615,6 +1618,11 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1615
1618
  type: "panel/setSelectedComponent",
1616
1619
  payload: text,
1617
1620
  });
1621
+ setSelectedComponent(text);
1622
+ dispatch({
1623
+ type: "tool/setActiveTool",
1624
+ payload: "select",
1625
+ });
1618
1626
  (_p = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelectorAll("#ghost-element-create")) === null || _p === void 0 ? void 0 : _p.forEach((el) => el.remove());
1619
1627
  isCreateElementRef.current = false;
1620
1628
  }
@@ -1944,7 +1952,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1944
1952
  if (activeTool === "grab") {
1945
1953
  setCursor("grabbing");
1946
1954
  }
1947
- }, doubleClick: { step: 1, disabled: activeTool === "select" }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1955
+ }, doubleClick: { disabled: true }, disablePadding: true, centerOnInit: true, children: _jsx(TransformComponent, { wrapperStyle: {
1948
1956
  width: "100%",
1949
1957
  height: "100%",
1950
1958
  }, contentStyle: { width: boardSize.width, height: boardSize.height }, children: _jsxs("svg", { id: "workspace", ref: svgRef, width: boardSize.width, height: boardSize.height, viewBox: `${minCoords.x} ${minCoords.y} ${boardSize.width} ${boardSize.height}`, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, xmlns: "http://www.w3.org/2000/svg", preserveAspectRatio: "xMidYMid meet", style: {
@@ -12,6 +12,7 @@ import { Button, Flex, Radio, Slider, Tag, } from "antd";
12
12
  import { getAttributeElement, getAttributeElements } from "./resize-element";
13
13
  import { applyResizeToSvgElement, arrayToSvgPointsAttr, createTableGhost, getGlobalBBox, getRotation, getSvgElementSize, getTranslate, isClosingPolygon, normalizeAngle, pointsStringToArray, resizeBox, resizeSeatCircle, resizeSeatRectCircle, resizeSeatRectSquare, resizeSeatSide, resizeSeatSquare, stabilizeRotation, stabilizeTranslateOnRotate, updateManyComponents, updateSelectionBox, updateSelectionGuides, updateSingleComponent, } from "./utils";
14
14
  import { getOS } from "../../utils/agent";
15
+ import { MIN_HEIGHT, MIN_WIDTH } from "./constant";
15
16
  const toolElement = ["square", "circle", "table-seat-circle"];
16
17
  const idSelectionBoxGhost = "selection-box-ghost";
17
18
  const nameShapeSelectionBoxGhost = "selection-box";
@@ -77,7 +78,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
77
78
  const [selectedLines, setSelectedLines] = useState(null);
78
79
  useEffect(() => {
79
80
  if (activeTool === "select" || activeTool !== "select") {
80
- handleUnSelectComponent();
81
+ (selectedComponentProps === null || selectedComponentProps === void 0 ? void 0 : selectedComponentProps.shape) !== "text" && handleUnSelectComponent();
81
82
  }
82
83
  if (activeTool !== "polygon") {
83
84
  isOnMakePolygonRef.current = false;
@@ -415,7 +416,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
415
416
  };
416
417
  }, [dataElementSelectionGroupRef.current]);
417
418
  const handlePointerDown = (e) => {
418
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
419
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
419
420
  const shiftActive = e.shiftKey;
420
421
  if (activeTool === "grab") {
421
422
  return;
@@ -465,15 +466,16 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
465
466
  isCreateElementRef.current = true;
466
467
  }
467
468
  else if (isInitialCreateText) {
468
- const tables = createTableGhost({
469
+ const [elTemp, el] = createTableGhost({
469
470
  x,
470
471
  y,
471
- width: 100 * scale,
472
- height: 50 * scale,
472
+ width: MIN_WIDTH,
473
+ height: MIN_HEIGHT,
473
474
  fill: "#000000",
474
475
  shape: activeTool,
475
476
  });
476
- (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(tables);
477
+ (_c = svgRef.current) === null || _c === void 0 ? void 0 : _c.appendChild(elTemp);
478
+ (_d = svgRef.current) === null || _d === void 0 ? void 0 : _d.appendChild(el);
477
479
  isCreateElementRef.current = true;
478
480
  }
479
481
  const targetSelection = e.target.closest("g[id='selection-lines']");
@@ -484,14 +486,14 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
484
486
  }
485
487
  let positionSelection = null;
486
488
  if (activeTool === "select") {
487
- positionSelection = (_e = (_d = e.target.closest(`polyline[data-position]`)) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.position;
489
+ positionSelection = (_f = (_e = e.target.closest(`polyline[data-position]`)) === null || _e === void 0 ? void 0 : _e.dataset) === null || _f === void 0 ? void 0 : _f.position;
488
490
  }
489
491
  // RESIZE
490
492
  const targetGroup = e.target.closest("g[data-id]");
491
493
  const targetPointPolygon = e.target.closest("circle[data-point]");
492
494
  // TARGET ELEMENT
493
495
  let idTargetElement = JSON.parse((targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.getAttribute("data-id")) || "{}");
494
- const selectionTarget = (_g = (_f = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _f === void 0 ? void 0 : _f.selection) === null || _g === void 0 ? void 0 : _g.replace("selection-", "");
496
+ const selectionTarget = (_h = (_g = targetSelection === null || targetSelection === void 0 ? void 0 : targetSelection.dataset) === null || _g === void 0 ? void 0 : _g.selection) === null || _h === void 0 ? void 0 : _h.replace("selection-", "");
495
497
  const activeId = selectionTarget !== null && selectionTarget !== void 0 ? selectionTarget : idTargetElement;
496
498
  const isInSelectionTarget = !isUndefined(selectionTarget);
497
499
  const isInTargetElement = !isPlainObject(idTargetElement);
@@ -499,7 +501,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
499
501
  const { g } = getAttributeElement(svg, activeId);
500
502
  if (targetGroup && shiftActive) {
501
503
  const findById = [...componentsState, ...extraComponentsState].find((comp) => comp.id == activeId);
502
- const currentSelection = (_h = dataElementSelectionGroupRef.current) !== null && _h !== void 0 ? _h : [];
504
+ const currentSelection = (_j = dataElementSelectionGroupRef.current) !== null && _j !== void 0 ? _j : [];
503
505
  if (currentSelection.length == 0 && selectedComponent) {
504
506
  currentSelection.push(selectedComponent);
505
507
  }
@@ -519,7 +521,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
519
521
  const hitPoint = document.elementFromPoint(clientX, clientY);
520
522
  // CHECK FOR HIT ON SVG FOR SELECTION BOX
521
523
  // MAKE AND UNMAKE SELECTION BOX START ------
522
- const hadSelectionBox = ((_j = dataElementSelectionGroupRef.current) === null || _j === void 0 ? void 0 : _j.length) > 0 && !isSingleSelection;
524
+ const hadSelectionBox = ((_k = dataElementSelectionGroupRef.current) === null || _k === void 0 ? void 0 : _k.length) > 0 && !isSingleSelection;
523
525
  const downInSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) !== "svg";
524
526
  const downOutSelectionBox = hadSelectionBox && (hitPoint === null || hitPoint === void 0 ? void 0 : hitPoint.nodeName) === "svg";
525
527
  const downBeforeHasSelectionBox = !downInSelectionBox &&
@@ -557,7 +559,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
557
559
  shape: nameShapeSelectionBoxGhost,
558
560
  id: idSelectionBoxGhost,
559
561
  });
560
- (_k = svgRef.current) === null || _k === void 0 ? void 0 : _k.appendChild(boxSelection);
562
+ (_l = svgRef.current) === null || _l === void 0 ? void 0 : _l.appendChild(boxSelection);
561
563
  }
562
564
  // MAKE AND UNMAKE SELECTION BOX END ------
563
565
  // RESIZE SELECTION BOX
@@ -829,7 +831,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
829
831
  updateSelectionBox(svg, resultSelection);
830
832
  const scaleX = resultSelection.width / oldSel.width;
831
833
  const scaleY = resultSelection.height / oldSel.height;
832
- allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text }, i) => {
834
+ allGroupsAttribute.forEach(({ g, element, seatGroup, seats, text, textRaw }, i) => {
833
835
  var _a, _b;
834
836
  const activeId = JSON.parse(g === null || g === void 0 ? void 0 : g.getAttribute("data-id"));
835
837
  const elementOld = allDataRealSelection === null || allDataRealSelection === void 0 ? void 0 : allDataRealSelection.find((el) => el.id == activeId);
@@ -914,7 +916,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
914
916
  });
915
917
  }
916
918
  }
917
- applyResizeToSvgElement(element, g, newElement, text);
919
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
918
920
  });
919
921
  };
920
922
  if (downAtResizePositionAndHasSelectionBox)
@@ -1057,7 +1059,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1057
1059
  var _a, _b;
1058
1060
  const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
1059
1061
  const svg = svgRef.current;
1060
- const { g, element, seats, seatGroup, text } = getAttributeElement(svg, activeId);
1062
+ const { g, element, seats, seatGroup, text, textRaw } = getAttributeElement(svg, activeId);
1061
1063
  const isZeroRotate = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.rotation) === 0 &&
1062
1064
  !(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.shape.includes("circle"));
1063
1065
  const elementSelect = {
@@ -1196,7 +1198,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1196
1198
  });
1197
1199
  }
1198
1200
  }
1199
- applyResizeToSvgElement(element, g, newElement, text);
1201
+ applyResizeToSvgElement(element, g, newElement, text, textRaw);
1200
1202
  isResizeRef.current = true;
1201
1203
  };
1202
1204
  // const hasSelectedOneElement =
@@ -1604,7 +1606,8 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1604
1606
  if (isInitialCreateText) {
1605
1607
  const ghost = svg.querySelector("#ghost-element-create");
1606
1608
  const getBBox = getGlobalBBox(svg, ghost);
1607
- const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14 });
1609
+ console.log({ getBBox });
1610
+ const text = Object.assign(Object.assign({}, getBBox), { id: `${Date.now()}`, shape: "text", fill: "#000000", text: "Text", fontSize: 14, rotation: 0 });
1608
1611
  addComponents(text);
1609
1612
  dispatch({
1610
1613
  type: "panel/setShow",
@@ -1614,6 +1617,11 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1614
1617
  type: "panel/setSelectedComponent",
1615
1618
  payload: text,
1616
1619
  });
1620
+ setSelectedComponent(text);
1621
+ dispatch({
1622
+ type: "tool/setActiveTool",
1623
+ payload: "select",
1624
+ });
1617
1625
  (_p = (_o = svgRef.current) === null || _o === void 0 ? void 0 : _o.querySelectorAll("#ghost-element-create")) === null || _p === void 0 ? void 0 : _p.forEach((el) => el.remove());
1618
1626
  isCreateElementRef.current = false;
1619
1627
  }
@@ -1981,7 +1989,7 @@ const BoardTemplate = ({ refs, loadingRender, disabled = false, }) => {
1981
1989
  if (activeTool === "grab") {
1982
1990
  setCursor("grabbing");
1983
1991
  }
1984
- }} doubleClick={{ step: 1, disabled: activeTool === "select" }} disablePadding centerOnInit>
1992
+ }} doubleClick={{ disabled: true }} disablePadding centerOnInit>
1985
1993
  {/* {scale !== 1 && ( */}
1986
1994
  {/* <div className="absolute bottom-[60px] left-1/2 transform -translate-x-1/2 z-10"> */}
1987
1995
  {/* {renderMiniMap()} */}
@@ -7,6 +7,7 @@ interface ResizeTarget {
7
7
  seatGroup?: SVGGElement;
8
8
  points?: any[];
9
9
  text?: SVGGElement | null;
10
+ textRaw?: SVGGElement | null;
10
11
  }
11
12
  export declare function getAttributeElement(root: SVGSVGElement, id: string): ResizeTarget | null;
12
13
  export declare function getAttributeElements(root: SVGSVGElement, id: string[]): ResizeTarget[];
@@ -6,6 +6,8 @@ export function getAttributeElement(root, id) {
6
6
  const seatGroup = root.querySelector(`g[data-seat="${id}-seats"]`);
7
7
  const boundingBox = root.querySelector(`g[data-bounding-box="${id}"]`);
8
8
  const text = root === null || root === void 0 ? void 0 : root.querySelector(`g[data-text="${id}-text"]`);
9
+ const textRaw = root === null || root === void 0 ? void 0 : root.querySelector(`text[data-text-raw="${id}-text"]`);
10
+ console.log({ textRaw });
9
11
  if (boundingBox) {
10
12
  const element = boundingBox.querySelector("rect");
11
13
  return { g: boundingBox, inner: null, element, seats, seatGroup };
@@ -42,7 +44,7 @@ export function getAttributeElement(root, id) {
42
44
  }
43
45
  if (!inner || !element)
44
46
  return null;
45
- return { g, inner, element, seats: listSeats, seatGroup, points, text };
47
+ return { g, inner, element, seats: listSeats, seatGroup, points, text, textRaw };
46
48
  }
47
49
  export function getAttributeElements(root, id) {
48
50
  return id.map((id) => getAttributeElement(root, id));
@@ -153,7 +153,7 @@ type ResizeResult = {
153
153
  rotation?: number;
154
154
  labels?: Label[];
155
155
  };
156
- export declare function applyResizeToSvgElement(element: SVGGraphicsElement, group: SVGGElement, resize: ResizeResult, text?: SVGGElement | null): void;
156
+ export declare function applyResizeToSvgElement(element: SVGGraphicsElement, group: SVGGElement, resize: ResizeResult, text?: SVGGElement | null, textRaw?: SVGGElement | null): void;
157
157
  type ResizeParams = {
158
158
  element: SVGGraphicsElement;
159
159
  group: SVGGElement;
@@ -713,6 +713,7 @@ export function createTableGhost({ x, y, width, height, fill, shape, id = "ghost
713
713
  // buat group dulu
714
714
  const SVG_NS = "http://www.w3.org/2000/svg";
715
715
  let el = null;
716
+ let elTemp = null;
716
717
  // tambahkan rectangle
717
718
  if (shape === "square" ||
718
719
  shape === "table-seat-circle" ||
@@ -757,10 +758,20 @@ export function createTableGhost({ x, y, width, height, fill, shape, id = "ghost
757
758
  }));
758
759
  }
759
760
  else if (shape === "text") {
761
+ elTemp = document.createElementNS(SVG_NS, "rect");
762
+ elTemp.setAttribute("id", id);
763
+ elTemp.setAttribute("x", Math.round(x - (width / 2)));
764
+ elTemp.setAttribute("y", Math.round(y - (height / 2)));
765
+ elTemp.setAttribute("width", width);
766
+ elTemp.setAttribute("height", height);
767
+ elTemp.setAttribute("fill", "transparent");
768
+ elTemp.setAttribute("stroke", "blue");
760
769
  el = document.createElementNS(SVG_NS, "text");
761
770
  el.setAttribute("id", id);
762
- el.setAttribute("x", x);
763
- el.setAttribute("y", y + height / 2);
771
+ el.setAttribute("x", Math.round(x - (width / 4)));
772
+ el.setAttribute("y", Math.round(y + (height / 15)));
773
+ el.setAttribute("width", width);
774
+ el.setAttribute("height", height);
764
775
  el.setAttribute("fill", "#000000");
765
776
  el.setAttribute("data-table", JSON.stringify({
766
777
  x,
@@ -777,7 +788,7 @@ export function createTableGhost({ x, y, width, height, fill, shape, id = "ghost
777
788
  el.setAttribute("color", "white");
778
789
  el.setAttribute("fontSize", "14px");
779
790
  }
780
- return el;
791
+ return elTemp ? [elTemp, el] : el;
781
792
  }
782
793
  export function updateSelectionBox(svg, boxSelection, id, unFollowCursor) {
783
794
  var _a, _b, _c, _d, _e;
@@ -1017,9 +1028,10 @@ const updateSvgAttrs = (el, attrs) => {
1017
1028
  }
1018
1029
  }
1019
1030
  };
1020
- export function applyResizeToSvgElement(element, group, resize, text) {
1031
+ export function applyResizeToSvgElement(element, group, resize, text, textRaw) {
1021
1032
  var _a, _b, _c, _d;
1022
1033
  const tagName = element.tagName.toLowerCase();
1034
+ console.log({ tagName, textRaw });
1023
1035
  switch (tagName) {
1024
1036
  case "rect":
1025
1037
  case "image": {
@@ -1036,6 +1048,8 @@ export function applyResizeToSvgElement(element, group, resize, text) {
1036
1048
  transform: `translate(${Math.round(resize.x)}, ${Math.round(resize.y)})`,
1037
1049
  });
1038
1050
  text === null || text === void 0 ? void 0 : text.setAttribute("transform", `rotate(${-rotation}, ${width / 2}, ${height / 2})`);
1051
+ textRaw === null || textRaw === void 0 ? void 0 : textRaw.setAttribute("x", String(width / 2));
1052
+ textRaw === null || textRaw === void 0 ? void 0 : textRaw.setAttribute("y", String(height / 2));
1039
1053
  const origintext = text === null || text === void 0 ? void 0 : text.querySelector("text");
1040
1054
  if (origintext) {
1041
1055
  origintext.setAttribute("x", String((width / 2) + ((_c = labelsDefault === null || labelsDefault === void 0 ? void 0 : labelsDefault[0]) === null || _c === void 0 ? void 0 : _c.x)));
@@ -329,7 +329,11 @@ const ControlPanels = (props) => {
329
329
  unsetPlaceholder,
330
330
  setPlaceholderBulk,
331
331
  resetPlaceholders,
332
- }, children: _jsx("div", { className: clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll mt-[78px]", open ? "right-0" : "right-[-1000px]"), children: _jsx("div", { className: "bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300", children: _jsxs(Form, { layout: "vertical", form: form, name: "table", colon: false, onValuesChange: handleChangeComponent, onFocus: (e) => {
332
+ }, children: _jsx("div", { className: clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll mt-[78px]", open ? "right-0" : "right-[-1000px]"), onTransitionEnd: (e) => {
333
+ if (open) {
334
+ form.focusField("text");
335
+ }
336
+ }, children: _jsx("div", { className: "bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300", children: _jsxs(Form, { layout: "vertical", form: form, name: "table", colon: false, onValuesChange: handleChangeComponent, onFocus: (e) => {
333
337
  var _a, _b, _c;
334
338
  e.stopPropagation();
335
339
  const name = e.target.name;
@@ -329,7 +329,11 @@ const ControlPanels = (props) => {
329
329
  setPlaceholderBulk,
330
330
  resetPlaceholders,
331
331
  }}>
332
- <div className={clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll mt-[78px]", open ? "right-0" : "right-[-1000px]")}>
332
+ <div className={clsx("w-[300px] h-full absolute top-0 z-50 transition-all duration-300 overflow-y-scroll mt-[78px]", open ? "right-0" : "right-[-1000px]")} onTransitionEnd={(e) => {
333
+ if (open) {
334
+ form.focusField("text");
335
+ }
336
+ }}>
333
337
  <div className="bg-white h-full max-h-screen w-full p-2 overflow-y-auto border-l border-gray-300">
334
338
  <Form layout="vertical" form={form} name="table" colon={false} onValuesChange={handleChangeComponent} onFocus={(e) => {
335
339
  var _a, _b, _c;
@@ -24,7 +24,7 @@ const PolygonTool = () => {
24
24
  if (Number.isNaN(num))
25
25
  return 0;
26
26
  return Math.min(360, Math.max(0, num));
27
- } }) }), _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
27
+ } }) }), _jsx(Form.Item, { label: "Opacity Fill", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
28
28
  if (value === undefined || value === null || value === "")
29
29
  return null;
30
30
  const cleaned = value.replace(/[^0-9.]/g, "");
@@ -40,7 +40,7 @@ const PolygonTool = () => {
40
40
  return Math.min(360, Math.max(0, num));
41
41
  }}/>
42
42
  </Form.Item>
43
- <Form.Item label="opacity" name={"opacity"} className="w-full">
43
+ <Form.Item label="Opacity Fill" name={"opacity"} className="w-full">
44
44
  <InputNumber step={10} max={100} min={0} name="opacity" parser={(value) => {
45
45
  if (value === undefined || value === null || value === "")
46
46
  return null;
@@ -46,7 +46,7 @@ const SelectedGroup = ({ action, }) => {
46
46
  return onlyNumber === ""
47
47
  ? 1
48
48
  : Math.max(1, Number(onlyNumber));
49
- } }) }))] }), !shapeAllIncludePolygon && (_jsx(_Fragment, { children: _jsxs(Flex, { gap: 2, vertical: true, children: [_jsx(Form.Item, { label: "Position X", name: "x", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { placeholder: placeholders["x"], style: { width: "100%" }, min: MIN_X, suffix: "px", name: "x" }) }), _jsx(Form.Item, { label: "Position Y", name: "y", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "y", min: MIN_Y, placeholder: placeholders["y"], style: { width: "100%" } }) }), _jsx(Form.Item, { label: "Rotation", name: "rotation", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "rotation", suffix: "\u00B0", max: 360, min: 0, style: { width: "100%" }, placeholder: placeholders["rotation"] }) })] }) })), _jsxs(Flex, { gap: 2, children: [!allImageSelected && (_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })), _jsx(Form.Item, { label: "Stroke", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] }), _jsxs(Flex, { vertical: true, children: [_jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "strokeWidth", suffix: "px", style: { width: "100%" }, placeholder: placeholders["strokeWidth"] }) }), _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { style: { width: "100%" }, step: 10, max: 100, min: 0, placeholder: placeholders["opacity"], parser: (value) => {
49
+ } }) }))] }), !shapeAllIncludePolygon && (_jsx(_Fragment, { children: _jsxs(Flex, { gap: 2, vertical: true, children: [_jsx(Form.Item, { label: "Position X", name: "x", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { placeholder: placeholders["x"], style: { width: "100%" }, min: MIN_X, suffix: "px", name: "x" }) }), _jsx(Form.Item, { label: "Position Y", name: "y", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { suffix: "px", name: "y", min: MIN_Y, placeholder: placeholders["y"], style: { width: "100%" } }) }), _jsx(Form.Item, { label: "Rotation", name: "rotation", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "rotation", suffix: "\u00B0", max: 360, min: 0, style: { width: "100%" }, placeholder: placeholders["rotation"] }) })] }) })), _jsxs(Flex, { gap: 2, children: [!allImageSelected && (_jsx(Form.Item, { label: "Fill", name: "fill", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })), _jsx(Form.Item, { label: "Stroke", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) })] }), _jsxs(Flex, { vertical: true, children: [_jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { name: "strokeWidth", suffix: "px", style: { width: "100%" }, placeholder: placeholders["strokeWidth"] }) }), _jsx(Form.Item, { label: "Opacity Fill", name: "opacity", className: "w-full", layout: "horizontal", labelCol: { style: { width: 100, textAlign: "left" } }, wrapperCol: { style: { flex: 1 } }, children: _jsx(InputNumber, { style: { width: "100%" }, step: 10, max: 100, min: 0, placeholder: placeholders["opacity"], parser: (value) => {
50
50
  if (value === undefined || value === null || value === "")
51
51
  return null;
52
52
  const cleaned = value.replace(/[^0-9.]/g, "");
@@ -121,7 +121,7 @@ const SelectedGroup = ({ action, }) => {
121
121
  <Form.Item label="Stroke Size" name={"strokeWidth"} className="w-full" layout="horizontal" labelCol={{ style: { width: 100, textAlign: "left" } }} wrapperCol={{ style: { flex: 1 } }}>
122
122
  <InputNumber name={"strokeWidth"} suffix="px" style={{ width: "100%" }} placeholder={placeholders["strokeWidth"]}/>
123
123
  </Form.Item>
124
- <Form.Item label="opacity" name={"opacity"} className="w-full" layout="horizontal" labelCol={{ style: { width: 100, textAlign: "left" } }} wrapperCol={{ style: { flex: 1 } }}>
124
+ <Form.Item label="Opacity Fill" name={"opacity"} className="w-full" layout="horizontal" labelCol={{ style: { width: 100, textAlign: "left" } }} wrapperCol={{ style: { flex: 1 } }}>
125
125
  <InputNumber style={{ width: "100%" }} step={10} max={100} min={0} placeholder={placeholders["opacity"]} parser={(value) => {
126
126
  if (value === undefined || value === null || value === "")
127
127
  return null;
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
4
4
  import { Button, ColorPicker, Flex, Form, Input, InputNumber } from "antd";
5
5
  const TextTool = () => {
6
+ const [form] = Form.useForm();
6
7
  const dispatch = useAppDispatch();
7
8
  const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
8
9
  const deleteText = () => {
@@ -17,7 +18,13 @@ const TextTool = () => {
17
18
  dispatch({ type: "panel/setShow", payload: false });
18
19
  dispatch({ type: "tool/setActiveTool", payload: "select" });
19
20
  };
20
- return (_jsxs("div", { className: "py-2", children: [_jsx(Form.Item, { label: "Name", name: "shape", className: "w-full hidden", children: _jsx(Input, { defaultValue: "text" }) }), _jsx(Form.Item, { name: "text", label: "Text", children: _jsx(Input, {}) }), _jsxs(Flex, { className: "w-full", gap: 2, children: [_jsx(Form.Item, { name: "fontColor", label: "Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { name: "fontSize", label: "Size", children: _jsx(InputNumber, { suffix: "px" }) })] }), _jsxs(Flex, { gap: 2, className: "w-full", children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", children: _jsx(InputNumber, { suffix: "px", controls: true, parser: (value) => {
21
+ // const textInputRef = useRef<InputRef>(null);
22
+ // useEffect(() => {
23
+ // if (textInputRef.current) {
24
+ // textInputRef.current.focus();
25
+ // }
26
+ // }, []);
27
+ return (_jsxs("div", { className: "py-2", children: [_jsx(Form.Item, { label: "Name", name: "shape", className: "w-full hidden", children: _jsx(Input, { defaultValue: "text" }) }), _jsx(Form.Item, { name: "text", label: "Text", children: _jsx(Input, {}) }), _jsxs(Flex, { className: "w-full", gap: 2, children: [_jsx(Form.Item, { name: "fontColor", label: "Text Color", getValueFromEvent: (color) => color.toHexString(), children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { name: "fontSize", label: "Size", children: _jsx(InputNumber, { suffix: "px" }) })] }), _jsxs(Flex, { gap: 2, className: "w-full", children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", children: _jsx(InputNumber, { suffix: "px", controls: true, parser: (value) => {
21
28
  var _a;
22
29
  const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
23
30
  return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
@@ -32,6 +39,6 @@ const TextTool = () => {
32
39
  if (Number.isNaN(num))
33
40
  return 0;
34
41
  return Math.min(360, Math.max(0, num));
35
- } }) })] }), _jsx(Button, { type: "default", onClick: deleteText, className: "w-full", children: "Delete" })] }));
42
+ } }) })] }), _jsx(Button, { type: "primary", onClick: deleteText, className: "w-full", children: "Delete" })] }));
36
43
  };
37
44
  export default TextTool;
@@ -2,6 +2,7 @@
2
2
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
3
3
  import { Button, ColorPicker, Flex, Form, Input, InputNumber } from "antd";
4
4
  const TextTool = () => {
5
+ const [form] = Form.useForm();
5
6
  const dispatch = useAppDispatch();
6
7
  const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
7
8
  const deleteText = () => {
@@ -16,6 +17,12 @@ const TextTool = () => {
16
17
  dispatch({ type: "panel/setShow", payload: false });
17
18
  dispatch({ type: "tool/setActiveTool", payload: "select" });
18
19
  };
20
+ // const textInputRef = useRef<InputRef>(null);
21
+ // useEffect(() => {
22
+ // if (textInputRef.current) {
23
+ // textInputRef.current.focus();
24
+ // }
25
+ // }, []);
19
26
  return (<div className="py-2">
20
27
  <Form.Item label="Name" name="shape" className="w-full hidden">
21
28
  <Input defaultValue={"text"}/>
@@ -25,7 +32,7 @@ const TextTool = () => {
25
32
  <Input />
26
33
  </Form.Item>
27
34
  <Flex className="w-full" gap={2}>
28
- <Form.Item name={"fontColor"} label="Color" getValueFromEvent={(color) => color.toHexString()}>
35
+ <Form.Item name={"fontColor"} label="Text Color" getValueFromEvent={(color) => color.toHexString()}>
29
36
  <ColorPicker allowClear format="hex" defaultFormat="hex"/>
30
37
  </Form.Item>
31
38
  <Form.Item name={"fontSize"} label="Size">
@@ -66,7 +73,7 @@ const TextTool = () => {
66
73
  }}/>
67
74
  </Form.Item>
68
75
  </Flex>
69
- <Button type="default" onClick={deleteText} className="w-full">
76
+ <Button type="primary" onClick={deleteText} className="w-full">
70
77
  Delete
71
78
  </Button>
72
79
  </div>);
@@ -55,6 +55,8 @@ const UploadTool = ({ name, type, action, transform, }) => {
55
55
  multiple: true,
56
56
  maxCount: 1,
57
57
  showUploadList: false,
58
+ // png jpg jpeg
59
+ accept: ".png,.jpg,.jpeg",
58
60
  onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
59
61
  setLoading(true);
60
62
  if (info.file) {
@@ -54,6 +54,8 @@ const UploadTool = ({ name, type, action, transform, }) => {
54
54
  multiple: true,
55
55
  maxCount: 1,
56
56
  showUploadList: false,
57
+ // png jpg jpeg
58
+ accept: ".png,.jpg,.jpeg",
57
59
  onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
58
60
  setLoading(true);
59
61
  if (info.file) {
@@ -62,6 +62,7 @@ const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
62
62
  multiple: true,
63
63
  maxCount: 1,
64
64
  showUploadList: false,
65
+ accept: ".png,.jpg,.jpeg",
65
66
  onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
66
67
  setLoading(true);
67
68
  if (info.file) {
@@ -168,13 +169,15 @@ const UploadToolForm = (props) => {
168
169
  const shape = Form.useWatch("shape");
169
170
  const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
170
171
  const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
172
+ const extraComponents = useAppSelector((state) => state.board.extraComponents);
173
+ const isExtraComponent = extraComponents.some((item) => item.id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id));
171
174
  const maxSeat = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey]) || 0;
172
- return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Shape" }), _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: optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
175
+ return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Shape" }), (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) && !isExtraComponent && (_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: optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
173
176
  const disabled = item.value === "table-seat-rect-circle" && maxSeat > 4;
174
177
  return (_jsx(Option, { value: item.value, disabled: disabled, className: "flex w-full items-center", children: _jsxs(Flex, { gap: 5, align: "center", justify: "between", children: [item.icon, _jsx("span", { children: item.value === "table-seat-rect-circle"
175
178
  ? `Circle Type 2 (only for 4 ${seatKey})`
176
179
  : item.label })] }) }, item.value));
177
- }) }) }) }), _jsx(UploadTool, Object.assign({}, props)), _jsxs(Flex, { gap: 2, className: "w-full", children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", children: _jsx(InputNumber, { suffix: "px", controls: true, name: "width", min: MIN_WIDTH, step: 1, parser: (value) => {
180
+ }) }) }) })), _jsx(UploadTool, Object.assign({}, props)), _jsxs(Flex, { gap: 2, className: "w-full", children: [_jsx(Form.Item, { label: "Width", name: "width", className: "w-full", children: _jsx(InputNumber, { suffix: "px", controls: true, name: "width", min: MIN_WIDTH, step: 1, parser: (value) => {
178
181
  var _a;
179
182
  const onlyNumber = (_a = value === null || value === void 0 ? void 0 : value.replace(/\D/g, "")) !== null && _a !== void 0 ? _a : "";
180
183
  return onlyNumber === "" ? 1 : Math.max(1, Number(onlyNumber));
@@ -193,7 +196,7 @@ const UploadToolForm = (props) => {
193
196
  if (Number.isNaN(num))
194
197
  return 0;
195
198
  return Math.min(360, Math.max(0, num));
196
- } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "opacity", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
199
+ } }) })] }), _jsxs(Flex, { gap: 2, children: [_jsx(Form.Item, { label: "Stroke Fill", name: "stroke", getValueFromEvent: (color) => color.toHexString(), className: "w-full ", children: _jsx(ColorPicker, { allowClear: true, format: "hex", defaultFormat: "hex" }) }), _jsx(Form.Item, { label: "Stroke Size", name: "strokeWidth", className: "w-full", children: _jsx(InputNumber, {}) })] }), _jsx(Flex, { children: _jsx(Form.Item, { label: "Opacity Fill", name: "opacity", className: "w-full", children: _jsx(InputNumber, { step: 10, max: 100, min: 0, name: "opacity", parser: (value) => {
197
200
  if (value === undefined || value === null || value === "")
198
201
  return null;
199
202
  const cleaned = value.replace(/[^0-9.]/g, "");
@@ -61,6 +61,7 @@ const UploadTool = ({ name, type, action, defaultValue, transform, }) => {
61
61
  multiple: true,
62
62
  maxCount: 1,
63
63
  showUploadList: false,
64
+ accept: ".png,.jpg,.jpeg",
64
65
  onChange: (info) => __awaiter(void 0, void 0, void 0, function* () {
65
66
  setLoading(true);
66
67
  if (info.file) {
@@ -196,28 +197,30 @@ const UploadToolForm = (props) => {
196
197
  const shape = Form.useWatch("shape");
197
198
  const seatKey = useAppSelector((state) => state.panel.seatDefaultKey);
198
199
  const selectedComponent = useAppSelector((state) => state.panel.selectedComponent);
200
+ const extraComponents = useAppSelector((state) => state.board.extraComponents);
201
+ const isExtraComponent = extraComponents.some((item) => item.id === (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id));
199
202
  const maxSeat = (selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent[seatKey]) || 0;
200
203
  return (<div className="py-2">
201
204
  <h1 className="heading-s">Shape</h1>
202
- <Flex gap={2} className="w-full">
203
- <Form.Item label="Name" name="shape" className="w-full">
204
- <Select className="w-full">
205
- {optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
206
- const disabled = item.value === "table-seat-rect-circle" && maxSeat > 4;
207
- return (<Option key={item.value} value={item.value} disabled={disabled} className="flex w-full items-center">
208
- <Flex gap={5} align="center" justify="between">
209
- {item.icon}
210
- <span>
211
- {item.value === "table-seat-rect-circle"
212
- ? `Circle Type 2 (only for 4 ${seatKey})`
213
- : item.label}
214
- </span>
215
- </Flex>
216
- </Option>);
217
- })}
218
- </Select>
219
- </Form.Item>
220
- </Flex>
205
+ {(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id) && !isExtraComponent && (<Flex gap={2} className="w-full">
206
+ <Form.Item label="Name" name="shape" className="w-full">
207
+ <Select className="w-full">
208
+ {optionsShape === null || optionsShape === void 0 ? void 0 : optionsShape.map((item) => {
209
+ const disabled = item.value === "table-seat-rect-circle" && maxSeat > 4;
210
+ return (<Option key={item.value} value={item.value} disabled={disabled} className="flex w-full items-center">
211
+ <Flex gap={5} align="center" justify="between">
212
+ {item.icon}
213
+ <span>
214
+ {item.value === "table-seat-rect-circle"
215
+ ? `Circle Type 2 (only for 4 ${seatKey})`
216
+ : item.label}
217
+ </span>
218
+ </Flex>
219
+ </Option>);
220
+ })}
221
+ </Select>
222
+ </Form.Item>
223
+ </Flex>)}
221
224
  <UploadTool {...props}/>
222
225
  <Flex gap={2} className="w-full">
223
226
  <Form.Item label="Width" name="width" className="w-full">
@@ -278,7 +281,7 @@ const UploadToolForm = (props) => {
278
281
  </Form.Item>
279
282
  </Flex>
280
283
  <Flex>
281
- <Form.Item label="opacity" name={"opacity"} className="w-full">
284
+ <Form.Item label="Opacity Fill" name={"opacity"} className="w-full">
282
285
  <InputNumber step={10} max={100} min={0} name="opacity" parser={(value) => {
283
286
  if (value === undefined || value === null || value === "")
284
287
  return null;
@@ -2,9 +2,10 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
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
- import { Divider, ColorPicker, Button, message, Popover, Flex, } from "antd";
5
+ import { Divider, ColorPicker, message, Popover, Flex, } from "antd";
6
6
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
7
7
  import { useState } from "react";
8
+ import clsx from "clsx";
8
9
  const SideTool = ({ dragOnly, deleteAutorized, }) => {
9
10
  const [color, setColor] = useState("#000000");
10
11
  const dispatch = useAppDispatch();
@@ -158,6 +159,8 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
158
159
  dispatch({ type: "board/setFlagChange", payload: true });
159
160
  };
160
161
  const handleOpenModalPreview = () => {
162
+ setOpenPreview(false);
163
+ hanldeSelectTool("select");
161
164
  dispatch({
162
165
  type: "tool/setTooglePreview",
163
166
  payload: true,
@@ -347,7 +350,27 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
347
350
  content: _jsx("div", { children: "Fill Tool" }),
348
351
  trigger: "hover",
349
352
  placement: "right",
350
- } }) }), _jsx(Popover, { trigger: "click", placement: "right", open: openPreview, onOpenChange: setOpenPreview, content: _jsxs(Flex, { vertical: true, children: [_jsx(Button, { icon: _jsx(Scan, {}), type: "text", name: "Bounding Box", onClick: () => hanldeSelectTool("bounding-box"), style: active === "bounding-box" ? { color: "red" } : {} }), _jsx(Button, { icon: preview ? _jsx(EyeOff, {}) : _jsx(Eye, {}), type: "text", name: "Preview", onClick: handleOpenModalPreview, style: active === "preview" ? { color: "red" } : {} })] }), children: _jsxs(Flex, { className: "relative", children: [_jsx(ButtonTools, { buttonProps: {
353
+ } }) }), _jsx(Popover, { trigger: "click", placement: "right", open: openPreview, onOpenChange: setOpenPreview, content: _jsxs(Flex, { vertical: true, children: [_jsx(ButtonTools, { buttonProps: {
354
+ icon: _jsx(Scan, {}),
355
+ type: "text",
356
+ name: "Bounding Box",
357
+ onClick: () => hanldeSelectTool("bounding-box"),
358
+ style: active === "bounding-box" ? { color: "red" } : {},
359
+ }, items: [], popoverProps: {
360
+ content: _jsx("div", { children: "Framing Tool" }),
361
+ trigger: "hover",
362
+ placement: "right",
363
+ } }), _jsx(ButtonTools, { buttonProps: {
364
+ icon: preview ? _jsx(EyeOff, {}) : _jsx(Eye, {}),
365
+ type: "text",
366
+ name: "Preview",
367
+ onClick: handleOpenModalPreview,
368
+ style: active === "preview" ? { color: "red" } : {},
369
+ }, items: [], popoverProps: {
370
+ content: _jsx("div", { children: "Preview Tool" }),
371
+ trigger: "hover",
372
+ placement: "right",
373
+ } })] }), children: _jsxs(Flex, { className: "relative", children: [_jsx(ButtonTools, { buttonProps: {
351
374
  icon: _jsx(ScanEye, {}),
352
375
  type: "text",
353
376
  name: "Preview",
@@ -356,10 +379,13 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
356
379
  ? { color: "red" }
357
380
  : {},
358
381
  }, items: [], popoverProps: {
359
- content: _jsx("div", { children: "Layour View Tool" }),
382
+ content: _jsx("div", { children: "Layout View Tool" }),
360
383
  trigger: "hover",
361
384
  placement: "right",
362
- } }), _jsx("span", { className: "absolute right-[-5px] top-[2px]", children: ">" })] }) }), _jsx(ButtonTools, { buttonProps: {
385
+ open: openPreview ? false : undefined,
386
+ } }), _jsx("span", { className: clsx("absolute right-[-5px] top-[2px]", {
387
+ "text-red-500": active === "bounding-box" || active === "preview",
388
+ }), children: ">" })] }) }), _jsx(ButtonTools, { buttonProps: {
363
389
  icon: _jsx(Grid, {}),
364
390
  onClick: () => toggleGrid(),
365
391
  type: "text",
@@ -1,9 +1,10 @@
1
1
  "use client";
2
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
- import { Divider, ColorPicker, Button, message, Popover, Flex, } from "antd";
4
+ import { Divider, ColorPicker, message, Popover, Flex, } from "antd";
5
5
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
6
6
  import { useState } from "react";
7
+ import clsx from "clsx";
7
8
  const SideTool = ({ dragOnly, deleteAutorized, }) => {
8
9
  const [color, setColor] = useState("#000000");
9
10
  const dispatch = useAppDispatch();
@@ -157,6 +158,8 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
157
158
  dispatch({ type: "board/setFlagChange", payload: true });
158
159
  };
159
160
  const handleOpenModalPreview = () => {
161
+ setOpenPreview(false);
162
+ hanldeSelectTool("select");
160
163
  dispatch({
161
164
  type: "tool/setTooglePreview",
162
165
  payload: true,
@@ -365,8 +368,41 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
365
368
  </ColorPicker>
366
369
 
367
370
  <Popover trigger={"click"} placement="right" open={openPreview} onOpenChange={setOpenPreview} content={<Flex vertical>
368
- <Button icon={<Scan />} type="text" name="Bounding Box" onClick={() => hanldeSelectTool("bounding-box")} style={active === "bounding-box" ? { color: "red" } : {}}/>
369
- <Button icon={preview ? <EyeOff /> : <Eye />} type="text" name="Preview" onClick={handleOpenModalPreview} style={active === "preview" ? { color: "red" } : {}}/>
371
+ <ButtonTools buttonProps={{
372
+ icon: <Scan />,
373
+ type: "text",
374
+ name: "Bounding Box",
375
+ onClick: () => hanldeSelectTool("bounding-box"),
376
+ style: active === "bounding-box" ? { color: "red" } : {},
377
+ }} items={[]} popoverProps={{
378
+ content: <div>Framing Tool</div>,
379
+ trigger: "hover",
380
+ placement: "right",
381
+ }}/>
382
+ {/* icon={<Scan />}
383
+ type="text"
384
+ name="Bounding Box"
385
+ onClick={() => hanldeSelectTool("bounding-box")}
386
+ style={active === "bounding-box" ? { color: "red" } : {}}
387
+ /> */}
388
+
389
+ <ButtonTools buttonProps={{
390
+ icon: preview ? <EyeOff /> : <Eye />,
391
+ type: "text",
392
+ name: "Preview",
393
+ onClick: handleOpenModalPreview,
394
+ style: active === "preview" ? { color: "red" } : {},
395
+ }} items={[]} popoverProps={{
396
+ content: <div>Preview Tool</div>,
397
+ trigger: "hover",
398
+ placement: "right",
399
+ }}/>
400
+ {/* icon={preview ? <EyeOff /> : <Eye />}
401
+ type="text"
402
+ name="Preview"
403
+ onClick={handleOpenModalPreview}
404
+ style={active === "preview" ? { color: "red" } : {}}
405
+ /> */}
370
406
  </Flex>}>
371
407
  <Flex className="relative">
372
408
  <ButtonTools buttonProps={{
@@ -378,11 +414,16 @@ const SideTool = ({ dragOnly, deleteAutorized, }) => {
378
414
  ? { color: "red" }
379
415
  : {},
380
416
  }} items={[]} popoverProps={{
381
- content: <div>Layour View Tool</div>,
417
+ content: <div>Layout View Tool</div>,
382
418
  trigger: "hover",
383
419
  placement: "right",
420
+ open: openPreview ? false : undefined,
384
421
  }}/>
385
- <span className="absolute right-[-5px] top-[2px]">{">"}</span>
422
+ <span className={clsx("absolute right-[-5px] top-[2px]", {
423
+ "text-red-500": active === "bounding-box" || active === "preview",
424
+ })}>
425
+ {">"}
426
+ </span>
386
427
  </Flex>
387
428
  </Popover>
388
429
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.5.17",
3
+ "version": "3.5.18",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",