seat-editor 3.5.66 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/app/new-board/page.js +18 -1
  2. package/dist/app/new-board/page.jsx +18 -1
  3. package/dist/components/button-radio/index.d.ts +11 -0
  4. package/dist/components/button-radio/index.js +19 -0
  5. package/dist/components/button-radio/index.jsx +22 -0
  6. package/dist/components/form-tools/label.js +20 -2
  7. package/dist/components/form-tools/label.jsx +30 -2
  8. package/dist/components/layer-v3/index.d.ts +9 -1
  9. package/dist/components/layer-v3/index.js +65 -95
  10. package/dist/components/layer-v3/index.jsx +79 -115
  11. package/dist/components/layer-v4/constant.d.ts +16 -2
  12. package/dist/components/layer-v4/constant.js +57 -12
  13. package/dist/components/layer-v4/index.js +111 -188
  14. package/dist/components/layer-v4/index.jsx +124 -215
  15. package/dist/components/modal-preview/index.d.ts +3 -1
  16. package/dist/components/modal-preview/index.js +12 -2
  17. package/dist/components/modal-preview/index.jsx +13 -3
  18. package/dist/dto/table.d.ts +5 -0
  19. package/dist/features/board-v3/board-slice.d.ts +2 -1
  20. package/dist/features/board-v3/board-slice.js +4 -1
  21. package/dist/features/board-v3/constant.d.ts +5 -1
  22. package/dist/features/board-v3/constant.js +23 -1
  23. package/dist/features/board-v3/index.d.ts +6 -1
  24. package/dist/features/board-v3/index.js +59 -49
  25. package/dist/features/board-v3/index.jsx +105 -68
  26. package/dist/features/board-v3/utils.js +48 -28
  27. package/dist/features/package/index.d.ts +5 -0
  28. package/dist/features/package/index.js +1 -1
  29. package/dist/features/package/index.jsx +2 -2
  30. package/dist/features/panel/index.js +2 -2
  31. package/dist/features/panel/index.jsx +2 -2
  32. package/dist/features/panel/selected-group.js +2 -2
  33. package/dist/features/panel/selected-group.jsx +4 -2
  34. package/dist/features/side-tool/icons.d.ts +1 -0
  35. package/dist/features/side-tool/icons.js +2 -0
  36. package/dist/features/side-tool/icons.jsx +6 -0
  37. package/dist/features/side-tool/index.d.ts +6 -1
  38. package/dist/features/side-tool/index.js +31 -3
  39. package/dist/features/side-tool/index.jsx +32 -16
  40. package/dist/features/side-tool/side-tool-slice.d.ts +2 -0
  41. package/dist/features/side-tool/side-tool-slice.js +8 -1
  42. package/dist/features/view-only-3/index.js +0 -21
  43. package/dist/features/view-only-3/index.jsx +0 -21
  44. package/dist/provider/antd-provider.js +5 -2
  45. package/dist/provider/antd-provider.jsx +5 -2
  46. package/package.json +1 -1
@@ -99,5 +99,22 @@ export default function NewBoard() {
99
99
  defaultSeatCountKey: "capacity", hiddenStatusKey: {
100
100
  key: "status",
101
101
  value: 0,
102
- } }) })] }) }));
102
+ }, priviewActive: [
103
+ {
104
+ type: "default",
105
+ label: "Customer View",
106
+ },
107
+ {
108
+ type: "type-1",
109
+ label: "Layout view RSVP",
110
+ },
111
+ {
112
+ type: "type-2",
113
+ label: "next 3 reserve",
114
+ },
115
+ {
116
+ type: "type-3",
117
+ label: "Layout View POS",
118
+ },
119
+ ] }) })] }) }));
103
120
  }
@@ -107,7 +107,24 @@ export default function NewBoard() {
107
107
  defaultSeatCountKey="capacity" hiddenStatusKey={{
108
108
  key: "status",
109
109
  value: 0,
110
- }}/>
110
+ }} priviewActive={[
111
+ {
112
+ type: "default",
113
+ label: "Customer View",
114
+ },
115
+ {
116
+ type: "type-1",
117
+ label: "Layout view RSVP",
118
+ },
119
+ {
120
+ type: "type-2",
121
+ label: "next 3 reserve",
122
+ },
123
+ {
124
+ type: "type-3",
125
+ label: "Layout View POS",
126
+ },
127
+ ]}/>
111
128
  </div>
112
129
  </div>
113
130
  </>);
@@ -0,0 +1,11 @@
1
+ export type Option<T extends string> = {
2
+ label: string;
3
+ value: T;
4
+ };
5
+ type ButtonRadioProps<T extends string> = {
6
+ options: Option<T>[];
7
+ value?: T;
8
+ onChange?: (value: T) => void;
9
+ };
10
+ declare const ButtonRadio: <T extends string>({ options, value, onChange, }: ButtonRadioProps<T>) => import("react/jsx-runtime").JSX.Element;
11
+ export default ButtonRadio;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import clsx from "clsx";
5
+ const ButtonRadio = ({ options, value, onChange, }) => {
6
+ const [selected, setSelected] = useState(value);
7
+ const handleSelect = (val) => {
8
+ setSelected(val);
9
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
10
+ };
11
+ return (_jsx("div", { className: "flex items-center gap-[22px] p-1 rounded-xl w-fit", children: options.map((option) => {
12
+ const isSelected = selected === option.value;
13
+ return (_jsx("button", { type: "button", onClick: () => handleSelect(option.value), className: clsx("px-4 py-2.5 rounded-[6px] text-[12px] font-semibold transition-all duration-200", {
14
+ "bg-[#EEF6FF] text-[#3E97FF] shadow-sm": isSelected,
15
+ "text-[#7E8299]": !isSelected,
16
+ }), children: option.label }, option.value));
17
+ }) }));
18
+ };
19
+ export default ButtonRadio;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+ import clsx from "clsx";
4
+ const ButtonRadio = ({ options, value, onChange, }) => {
5
+ const [selected, setSelected] = useState(value);
6
+ const handleSelect = (val) => {
7
+ setSelected(val);
8
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
9
+ };
10
+ return (<div className="flex items-center gap-[22px] p-1 rounded-xl w-fit">
11
+ {options.map((option) => {
12
+ const isSelected = selected === option.value;
13
+ return (<button key={option.value} type="button" onClick={() => handleSelect(option.value)} className={clsx("px-4 py-2.5 rounded-[6px] text-[12px] font-semibold transition-all duration-200", {
14
+ "bg-[#EEF6FF] text-[#3E97FF] shadow-sm": isSelected,
15
+ "text-[#7E8299]": !isSelected,
16
+ })}>
17
+ {option.label}
18
+ </button>);
19
+ })}
20
+ </div>);
21
+ };
22
+ export default ButtonRadio;
@@ -1,8 +1,26 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { ColorPicker, Flex, Form, Input, InputNumber, Divider } from "antd";
3
+ import { ColorPicker, Flex, Form, Input, InputNumber, Divider, Segmented, } from "antd";
4
+ import { AlignCenterOutlined, AlignLeftOutlined, AlignRightOutlined, VerticalAlignTopOutlined, VerticalAlignMiddleOutlined, VerticalAlignBottomOutlined, } from "@ant-design/icons";
4
5
  const SectionLabel = () => {
5
- return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Section Labeling" }), _jsx(Divider, { style: { margin: 4 } }), _jsx(Form.Item, { label: "Labels in table", name: ["labels", 0, "label"], className: "w-full", children: _jsx(Form.List, { name: "labels", children: (fields, { add, remove }) => (_jsx(_Fragment, { children: fields.map((field) => (_jsxs("div", { className: "w-full flex-col mb-2", children: [_jsx(Flex, { gap: 5, className: "w-full flex justify-between", children: _jsx(Form.Item, { name: [field.name, "label"], label: "Text", className: "w-full", children: _jsx(Input, {}) }) }), _jsxs(Flex, { gap: 5, className: "w-full flex justify-between", children: [_jsx(Form.Item, { name: [field.name, "x"], label: "Position X", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { name: [field.name, "y"], label: "Position Y", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { name: [field.name, "rotation"], label: "Rotation", children: _jsx(InputNumber, { suffix: "\u00B0", min: 0, max: 360, parser: (value) => {
6
+ return (_jsxs("div", { className: "py-2", children: [_jsx("h1", { className: "heading-s", children: "Section Labeling" }), _jsx(Divider, { style: { margin: 4 } }), _jsx(Form.Item, { label: "Labels in table", name: ["labels", 0, "label"], className: "w-full", children: _jsx(Form.List, { name: "labels", children: (fields) => (_jsx(_Fragment, { children: fields.map((field) => (_jsxs("div", { className: "w-full flex-col mb-2", children: [_jsx(Flex, { gap: 5, className: "w-full flex justify-between", children: _jsx(Form.Item, { name: [field.name, "label"], label: "Text", className: "w-full", children: _jsx(Input, {}) }) }), _jsxs(Flex, { justify: "space-between", className: "w-full", children: [_jsx(Form.Item, { name: [field.name, "horizontalAlign"], children: _jsx(Segmented, { defaultValue: "middle", options: [
7
+ { label: _jsx(AlignLeftOutlined, {}), value: "start" },
8
+ { label: _jsx(AlignCenterOutlined, {}), value: "middle" },
9
+ { label: _jsx(AlignRightOutlined, {}), value: "end" },
10
+ ] }) }), _jsx(Form.Item, { name: [field.name, "verticalAlign"], children: _jsx(Segmented, { defaultValue: "middle", options: [
11
+ {
12
+ label: _jsx(VerticalAlignTopOutlined, {}),
13
+ value: "hanging",
14
+ },
15
+ {
16
+ label: _jsx(VerticalAlignMiddleOutlined, {}),
17
+ value: "middle",
18
+ },
19
+ {
20
+ label: _jsx(VerticalAlignBottomOutlined, {}),
21
+ value: "auto",
22
+ },
23
+ ] }) })] }), _jsxs(Flex, { gap: 5, className: "w-full flex justify-between", children: [_jsx(Form.Item, { name: [field.name, "x"], label: "Position X", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { name: [field.name, "y"], label: "Position Y", children: _jsx(InputNumber, {}) }), _jsx(Form.Item, { name: [field.name, "rotation"], label: "Rotation", children: _jsx(InputNumber, { suffix: "\u00B0", min: 0, max: 360, parser: (value) => {
6
24
  if (!value)
7
25
  return 0;
8
26
  const num = Number(value.replace(/\D/g, ""));
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { ColorPicker, Flex, Form, Input, InputNumber, Divider } from "antd";
2
+ import { ColorPicker, Flex, Form, Input, InputNumber, Divider, Segmented, } from "antd";
3
+ import { AlignCenterOutlined, AlignLeftOutlined, AlignRightOutlined, VerticalAlignTopOutlined, VerticalAlignMiddleOutlined, VerticalAlignBottomOutlined, } from "@ant-design/icons";
3
4
  const SectionLabel = () => {
4
5
  return (<div className="py-2">
5
6
  <h1 className="heading-s">Section Labeling</h1>
@@ -7,13 +8,39 @@ const SectionLabel = () => {
7
8
 
8
9
  <Form.Item label="Labels in table" name={["labels", 0, "label"]} className="w-full">
9
10
  <Form.List name="labels">
10
- {(fields, { add, remove }) => (<>
11
+ {(fields) => (<>
11
12
  {fields.map((field) => (<div key={field.key} className="w-full flex-col mb-2">
12
13
  <Flex gap={5} className="w-full flex justify-between">
13
14
  <Form.Item name={[field.name, "label"]} label="Text" className="w-full">
14
15
  <Input />
15
16
  </Form.Item>
16
17
  </Flex>
18
+ <Flex justify="space-between" className="w-full">
19
+ <Form.Item name={[field.name, "horizontalAlign"]}>
20
+ <Segmented defaultValue="middle" options={[
21
+ { label: <AlignLeftOutlined />, value: "start" },
22
+ { label: <AlignCenterOutlined />, value: "middle" },
23
+ { label: <AlignRightOutlined />, value: "end" },
24
+ ]}/>
25
+ </Form.Item>
26
+ <Form.Item name={[field.name, "verticalAlign"]}>
27
+ <Segmented defaultValue="middle" options={[
28
+ {
29
+ label: <VerticalAlignTopOutlined />,
30
+ value: "hanging",
31
+ },
32
+ {
33
+ label: <VerticalAlignMiddleOutlined />,
34
+ value: "middle",
35
+ },
36
+ {
37
+ label: <VerticalAlignBottomOutlined />,
38
+ value: "auto",
39
+ },
40
+ ]}/>
41
+ </Form.Item>
42
+ </Flex>
43
+
17
44
  <Flex gap={5} className="w-full flex justify-between">
18
45
  <Form.Item name={[field.name, "x"]} label="Position X">
19
46
  <InputNumber />
@@ -40,6 +67,7 @@ const SectionLabel = () => {
40
67
  <ColorPicker allowClear format="hex" defaultFormat="hex"/>
41
68
  </Form.Item>
42
69
  </Flex>
70
+
43
71
  {/* {fields.length > 1 && (
44
72
  <Flex gap={2} className="w-full">
45
73
  <Button
@@ -1,4 +1,4 @@
1
- import { PropertiesProps, BaseElement, Point } from "../../dto/table";
1
+ import { PropertiesProps, BaseElement, Label, Point } from "../../dto/table";
2
2
  export interface SelectionLines extends BaseElement {
3
3
  points?: Point[];
4
4
  id?: string | number;
@@ -10,4 +10,12 @@ interface LayersProps {
10
10
  selectionLines?: SelectionLines;
11
11
  }
12
12
  declare const Layers: ({ components, selectedComponent, activeTool, selectionLines, }: LayersProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const LabelItem: ({ id, width, height, labels, commonProps, rotation, }: {
14
+ id: string | number;
15
+ width: number;
16
+ height: number;
17
+ labels: Label[];
18
+ commonProps: any;
19
+ rotation?: number;
20
+ }) => import("react/jsx-runtime").JSX.Element;
13
21
  export default Layers;
@@ -19,13 +19,23 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
19
19
  }, [selectedGroup, selectedComponent]);
20
20
  const renderShape = (item) => {
21
21
  var _a, _b, _c, _d, _e, _f;
22
- const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, } = item;
22
+ const { id, x, y, width, height, fill, opacity, rotation = 0, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, label, seatFill, src, points, seatPositions, radius = 0, horizontalAlign, verticalAlign, } = item;
23
23
  const commonProps = {
24
24
  fill,
25
25
  opacity,
26
26
  stroke,
27
27
  strokeWidth,
28
28
  };
29
+ const labelProps = {
30
+ labels,
31
+ id,
32
+ width,
33
+ height,
34
+ commonProps,
35
+ horizontalAlign,
36
+ verticalAlign,
37
+ rotation,
38
+ };
29
39
  if (allSelectionId === null || allSelectionId === void 0 ? void 0 : allSelectionId.includes(id)) {
30
40
  commonProps.stroke = "#ffa39e";
31
41
  commonProps.strokeWidth = 4;
@@ -36,16 +46,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
36
46
  }
37
47
  switch (shape) {
38
48
  case "square":
39
- return (_jsx("g", { "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("rect", Object.assign({}, commonProps, { key: id, width: width, height: height, rx: radius })), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
40
- var _a, _b, _c, _d, _e, _f, _g;
41
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
42
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
43
- return (_createElement("text", Object.assign({}, omit(commonProps, [
44
- "opacity",
45
- "stroke",
46
- "strokeWidth",
47
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
48
- }) })] }) }, id));
49
+ return (_jsx("g", { "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("rect", Object.assign({}, commonProps, { key: id, width: width, height: height, rx: radius })), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
49
50
  case "polygon":
50
51
  if (!points)
51
52
  return null;
@@ -65,16 +66,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
65
66
  return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: finalPoint, x: "0", y: "0" })), (showPoints || !isClosed) &&
66
67
  points.map((_, index) => {
67
68
  return (_jsxs(_Fragment, { children: [_jsx("rect", { "data-point": JSON.stringify(_), id: `${index}`, x: (_ === null || _ === void 0 ? void 0 : _.x) - 5, y: (_ === null || _ === void 0 ? void 0 : _.y) - 5, width: 10, height: 10, fill: "#4a90e2", cursor: "pointer" }, `${id}-point-${index}`), _jsx("circle", { "data-point": JSON.stringify(_), id: `${index}`, cx: _ === null || _ === void 0 ? void 0 : _.x, cy: _ === null || _ === void 0 ? void 0 : _.y, r: 15, fill: "transparent", cursor: "pointer" }, `${id}-point-${index - 100}`)] }));
68
- }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${centerX}, ${centerY}) translate(${box === null || box === void 0 ? void 0 : box.x}, ${box === null || box === void 0 ? void 0 : box.y})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
69
- var _a, _b, _c, _d, _e, _f, _g;
70
- const cx = (box === null || box === void 0 ? void 0 : box.width) / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
71
- const cy = (box === null || box === void 0 ? void 0 : box.height) / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
72
- return (_createElement("text", Object.assign({}, omit(commonProps, [
73
- "opacity",
74
- "stroke",
75
- "strokeWidth",
76
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: (box === null || box === void 0 ? void 0 : box.width) / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: (box === null || box === void 0 ? void 0 : box.height) / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
77
- }) })] }) }, id));
69
+ }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${centerX}, ${centerY}) translate(${box === null || box === void 0 ? void 0 : box.x}, ${box === null || box === void 0 ? void 0 : box.y})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
78
70
  case "selection-box":
79
71
  const pointsFormat = rectToPolygonPoints(x, y, width, height);
80
72
  return (_jsx("g", { "data-table": JSON.stringify(item), "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})`, children: [_createElement("polygon", Object.assign({}, commonProps, { key: id, points: pointsFormat })), points.map((_, index) => {
@@ -84,16 +76,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
84
76
  return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { key: `${id}-label-${index}`, x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: `rotate(${rotation} ${x + width / 2} ${y + height / 2})` }), _ === null || _ === void 0 ? void 0 : _.label));
85
77
  })] }) }, id));
86
78
  case "circle":
87
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps), id), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
88
- var _a, _b, _c, _d, _e, _f, _g;
89
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
90
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
91
- return (_createElement("text", Object.assign({}, omit(commonProps, [
92
- "opacity",
93
- "stroke",
94
- "strokeWidth",
95
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
96
- }) })] }) }, id));
79
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps), id), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
97
80
  case "diamond":
98
81
  return (_jsxs("g", { "data-table": JSON.stringify(item), children: [_jsx("rect", Object.assign({ x: x, y: y, width: width, height: height, transform: `rotate(${rotation}, ${x}, ${y})` }, commonProps, { fill: fill }), id), _jsx("text", { x: x + width / 2, y: y + height / 2, fill: fontColor !== null && fontColor !== void 0 ? fontColor : "black", fontSize: `${fontSize !== null && fontSize !== void 0 ? fontSize : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", children: label })] }, id));
99
82
  case "table-seat-circle": {
@@ -116,16 +99,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
116
99
  const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
117
100
  return { cx, cy };
118
101
  });
119
- return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: fill }, commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", Object.assign({ cx: cx, cy: cy, r: seatRadius, fill: seatFill }, omit(commonProps, ["fill"])), `${id}-seat-${i}`))) }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
120
- var _a, _b, _c, _d, _e, _f, _g;
121
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
122
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
123
- return (_createElement("text", Object.assign({}, omit(commonProps, [
124
- "opacity",
125
- "stroke",
126
- "strokeWidth",
127
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
128
- }) })] }) }, id));
102
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: fill }, commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", Object.assign({ cx: cx, cy: cy, r: seatRadius, fill: seatFill }, omit(commonProps, ["fill"])), `${id}-seat-${i}`))) }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
129
103
  }
130
104
  case "table-seat-rect-circle": {
131
105
  const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
@@ -210,16 +184,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
210
184
  ...leftSeats,
211
185
  ...rightSeats,
212
186
  ];
213
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
214
- var _a, _b, _c, _d, _e, _f, _g;
215
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
216
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
217
- return (_createElement("text", Object.assign({}, omit(commonProps, [
218
- "opacity",
219
- "stroke",
220
- "strokeWidth",
221
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
222
- }) })] }) }, id));
187
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
223
188
  }
224
189
  case "table-seat-square": {
225
190
  const openSpace = item.openSpace || 0; // from 0 to 0.9
@@ -275,16 +240,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
275
240
  cy,
276
241
  id: "right",
277
242
  }));
278
- 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 }, commonProps, { rx: radius, fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
279
- var _a, _b, _c, _d, _e, _f, _g;
280
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
281
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
282
- return (_createElement("text", Object.assign({}, omit(commonProps, [
283
- "opacity",
284
- "stroke",
285
- "strokeWidth",
286
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
287
- }) })] }) }, id));
243
+ 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 }, commonProps, { rx: radius, fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
288
244
  }
289
245
  case "table-seat-half-square": {
290
246
  const openSpace = item.openSpace || 0;
@@ -344,16 +300,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
344
300
  direction: seat.id,
345
301
  fraction: 0.4,
346
302
  }) })));
347
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
348
- var _a, _b, _c, _d, _e, _f, _g;
349
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
350
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
351
- return (_createElement("text", Object.assign({}, omit(commonProps, [
352
- "opacity",
353
- "stroke",
354
- "strokeWidth",
355
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
356
- }) })] }) }, id));
303
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${0}, ${0})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
357
304
  }
358
305
  case "table-seat-rect-square": {
359
306
  const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
@@ -437,16 +384,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
437
384
  ...leftSeats,
438
385
  ...rightSeats,
439
386
  ];
440
- return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
441
- var _a, _b, _c, _d, _e, _f, _g;
442
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
443
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
444
- return (_createElement("text", Object.assign({}, omit(commonProps, [
445
- "opacity",
446
- "stroke",
447
- "strokeWidth",
448
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
449
- }) })] }) }, id));
387
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill })), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) })] }) }, id));
450
388
  }
451
389
  case "text":
452
390
  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, [
@@ -456,19 +394,11 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
456
394
  "strokeWidth",
457
395
  ]), { children: text }))] }) }, id));
458
396
  case "image-table":
397
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
459
398
  case "background":
460
399
  return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: {
461
400
  pointerEvents: lockBackground ? "none" : "auto",
462
- }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
463
- var _a, _b, _c, _d, _e, _f, _g;
464
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
465
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
466
- return (_createElement("text", Object.assign({}, omit(commonProps, [
467
- "opacity",
468
- "stroke",
469
- "strokeWidth",
470
- ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
471
- }) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
401
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", { href: src, width: width, height: height }), _jsx("g", { "data-text": `${id}-text`, transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: _jsx(LabelItem, Object.assign({}, labelProps)) }), _jsx("rect", Object.assign({ width: width, height: height, fill: "transparent", opacity: opacity }, omit(commonProps, ["fill", "opacity"])))] }) }, id));
472
402
  case "bounding-box": {
473
403
  const topLine = `${0},${0} ${width},${0}`;
474
404
  const rightLine = `${width},${0} ${width},${height}`;
@@ -494,10 +424,6 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
494
424
  };
495
425
  // let date = new Date();
496
426
  const nodesRaw = rectToPolygonNodes(selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.width, selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.height);
497
- // const nodesRawNew = rectToPolygonNodes(
498
- // selectionLinesPoints?.width,
499
- // selectionLinesPoints?.height
500
- // );
501
427
  return (_jsxs("g", { id: "selection-layer", children: [components === null || components === void 0 ? void 0 : components.map(renderShape), !isEmpty(selectionLines) && activeTool === "select" && (_jsxs(_Fragment, { children: [nodesRaw.map((p1, index) => {
502
428
  const p2 = nodesRaw[(index + 2) % nodesRaw.length];
503
429
  const side = index === 0
@@ -536,4 +462,48 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
536
462
  return (_jsxs(React.Fragment, { children: [_jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "transparent", style: { cursor: "pointer" } }, `circle-${index}`), _jsx("circle", { "data-position": corner(index), r: 5, cx: node.x, cy: node.y, fill: "#4a90e2", id: `circle-corner-${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`, style: { cursor: "pointer" } }, `circle-${index}`)] }, `corner-${index}`));
537
463
  }))] }) }, `selection-${Date.now()}`)] }))] }, `${selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id}`));
538
464
  };
465
+ export const LabelItem = ({ id, width, height, labels, commonProps, rotation = 0, }) => {
466
+ // const getEffectiveDimensions = (width: number, height: number, rotation: number) => {
467
+ // const rad = (rotation * Math.PI) / 180;
468
+ // const cos = Math.abs(Math.cos(rad));
469
+ // const sin = Math.abs(Math.sin(rad));
470
+ // return {
471
+ // effectiveWidth: width * cos + height * sin,
472
+ // effectiveHeight: width * sin + height * cos,
473
+ // };
474
+ // };
475
+ const PADDING = 0;
476
+ const getX = (labelX = 0, horizontalAlign = "middle") => {
477
+ // const { effectiveWidth } = getEffectiveDimensions(width, height, rotation);
478
+ if (horizontalAlign === "start")
479
+ return PADDING + labelX;
480
+ if (horizontalAlign === "end")
481
+ return width - PADDING + labelX;
482
+ return width / 2 + labelX;
483
+ };
484
+ const getY = (labelY = 0, verticalAlign = "middle") => {
485
+ // const { effectiveHeight } = getEffectiveDimensions(width, height, rotation);
486
+ if (verticalAlign === "hanging")
487
+ return PADDING + labelY;
488
+ if (verticalAlign === "auto")
489
+ return height - PADDING + labelY;
490
+ return height / 2 + labelY;
491
+ };
492
+ const textAnchorMap = {
493
+ start: "start",
494
+ middle: "middle",
495
+ end: "end",
496
+ };
497
+ const dominantBaselineMap = {
498
+ hanging: "hanging",
499
+ middle: "middle",
500
+ bottom: "auto",
501
+ };
502
+ return (_jsx(_Fragment, { children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
503
+ var _a, _b, _c, _d, _e;
504
+ const x = getX(_ === null || _ === void 0 ? void 0 : _.x, _ === null || _ === void 0 ? void 0 : _.horizontalAlign);
505
+ const y = getY(_ === null || _ === void 0 ? void 0 : _.y, _ === null || _ === void 0 ? void 0 : _.verticalAlign);
506
+ return (_createElement("text", Object.assign({}, omit(commonProps, ["opacity", "stroke", "strokeWidth"]), { transform: `rotate(${(_a = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _a !== void 0 ? _a : 0}, ${x}, ${y})`, key: `${id}-label-${index}`, x: x, y: y, fill: (_b = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _b !== void 0 ? _b : "black", fontSize: `${(_c = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _c !== void 0 ? _c : 10}px`, fontWeight: "bold", textAnchor: textAnchorMap[(_d = _ === null || _ === void 0 ? void 0 : _.horizontalAlign) !== null && _d !== void 0 ? _d : "middle"], dominantBaseline: dominantBaselineMap[(_e = _ === null || _ === void 0 ? void 0 : _.verticalAlign) !== null && _e !== void 0 ? _e : "middle"] }), _ === null || _ === void 0 ? void 0 : _.label));
507
+ }) }));
508
+ };
539
509
  export default Layers;