seat-editor 2.1.2 → 3.0.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 (57) hide show
  1. package/dist/app/constant.d.ts +232 -0
  2. package/dist/app/constant.js +3683 -3045
  3. package/dist/app/new-board/page.js +5 -6
  4. package/dist/app/only-view/chair.d.ts +1 -0
  5. package/dist/app/only-view/chair.js +4 -0
  6. package/dist/app/only-view/constant.d.ts +22 -2
  7. package/dist/app/only-view/constant.js +4 -4
  8. package/dist/app/only-view/page.js +74 -37
  9. package/dist/app/only-view/user.d.ts +1 -0
  10. package/dist/app/only-view/user.js +4 -0
  11. package/dist/components/layer-v3/index.d.ts +23 -4
  12. package/dist/components/layer-v3/index.js +329 -146
  13. package/dist/components/layer-v4/index.d.ts +20 -0
  14. package/dist/components/layer-v4/index.js +445 -0
  15. package/dist/components/lib/index.d.ts +1 -1
  16. package/dist/components/lib/index.js +1 -1
  17. package/dist/features/board/index.js +1 -1
  18. package/dist/features/board-v2/index.js +1 -1
  19. package/dist/features/board-v3/board-slice.d.ts +1 -0
  20. package/dist/features/board-v3/board-slice.js +26 -3
  21. package/dist/features/board-v3/constant.d.ts +5 -0
  22. package/dist/features/board-v3/constant.js +5 -0
  23. package/dist/features/board-v3/index copy.d.ts +47 -0
  24. package/dist/features/board-v3/index copy.js +2073 -0
  25. package/dist/features/board-v3/index.js +1409 -647
  26. package/dist/features/board-v3/polygon.d.ts +28 -0
  27. package/dist/features/board-v3/polygon.js +109 -0
  28. package/dist/features/board-v3/rect.d.ts +9 -0
  29. package/dist/features/board-v3/rect.js +152 -0
  30. package/dist/features/board-v3/resize-element.d.ts +12 -0
  31. package/dist/features/board-v3/resize-element.js +40 -0
  32. package/dist/features/board-v3/utils.d.ts +162 -0
  33. package/dist/features/board-v3/utils.js +787 -0
  34. package/dist/features/package/index.js +1 -1
  35. package/dist/features/panel/index.js +130 -20
  36. package/dist/features/panel/panel-slice.d.ts +5 -0
  37. package/dist/features/panel/panel-slice.js +15 -0
  38. package/dist/features/panel/select-tool.js +11 -1
  39. package/dist/features/panel/selected-group.d.ts +2 -0
  40. package/dist/features/panel/selected-group.js +7 -0
  41. package/dist/features/panel/table-seat-square.d.ts +2 -0
  42. package/dist/features/panel/table-seat-square.js +9 -0
  43. package/dist/features/side-tool/index.js +13 -6
  44. package/dist/features/view-only/index.js +0 -1
  45. package/dist/features/view-only-2/index.js +0 -1
  46. package/dist/features/view-only-3/index.d.ts +68 -0
  47. package/dist/features/view-only-3/index.js +510 -0
  48. package/dist/features/view-only-3/utils.d.ts +1 -0
  49. package/dist/features/view-only-3/utils.js +3 -0
  50. package/dist/seat-editor.css +1 -1
  51. package/dist/utils/constant.d.ts +1 -0
  52. package/dist/utils/constant.js +11 -0
  53. package/dist/utils/format.d.ts +2 -0
  54. package/dist/utils/format.js +29 -0
  55. package/package.json +3 -1
  56. package/dist/features/view/index.d.ts +0 -19
  57. package/dist/features/view/index.js +0 -221
@@ -2,17 +2,16 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useEffect, useState } from "react";
4
4
  import SeatEditor from "../../features/package";
5
- import { data3 } from "../constant";
5
+ import { extraComponent } from "../constant";
6
+ import { data4 } from "../constant";
6
7
  export default function NewBoard() {
7
8
  const [initialValue, setInitialValue] = useState([]);
8
9
  const [extraComponents, setExtraComponents] = useState([]);
9
- const [backgroundColor, setBackgroundColor] = useState("#ffffff");
10
+ const [backgroundColor, setBackgroundColor] = useState("#000000");
10
11
  const [viewOnly, setViewOnly] = useState(true);
11
12
  useEffect(() => {
12
- setInitialValue(data3);
13
- setExtraComponents([
14
- {}
15
- ]);
13
+ setInitialValue(data4);
14
+ setExtraComponents(extraComponent);
16
15
  }, []);
17
16
  return (_jsx(_Fragment, { children: _jsxs("div", { className: "w-full h-screen flex flex-col relative justify-center", children: [_jsx("div", { className: "w-full h-[1000px] bg-white border-r border-gray-200" }), _jsx("div", { className: "flex-1 h-full", children: _jsx(SeatEditor, { componentProps: initialValue, viewOnly: false, dragOnly: true, deleteAutorized: {
18
17
  component: true,
@@ -0,0 +1 @@
1
+ export function ChairIcon(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const ChairIcon = () => {
3
+ return (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("g", { "clip-path": "url(#clip0_3019_14165)", children: _jsx("path", { d: "M15.9717 7.5339V4.70339C15.9717 3.07627 14.7076 2.5 13.5189 2.5H6.46226C5.27359 2.5 4.00943 3.07627 4.00943 4.70339V7.5339C3.14151 7.73729 2.5 8.4322 2.5 9.27966V13.822C2.5 15.161 3.5 15.6864 4.48113 15.7373V16.8898C4.48113 17.2288 4.78302 17.5 5.16038 17.5H5.85849C6.23585 17.5 6.53774 17.2288 6.53774 16.8898V15.7373H13.4623V16.8898C13.4623 17.2288 13.7642 17.5 14.1415 17.5H14.8396C15.217 17.5 15.5189 17.2288 15.5189 16.8898V15.7373C16.9717 15.6695 17.5 14.7203 17.5 13.822V9.26271C17.4623 8.4322 16.8208 7.72034 15.9717 7.5339ZM4.68868 4.70339C4.68868 3.31356 5.80189 3.09322 6.46226 3.09322H13.5189C14.1792 3.09322 15.2925 3.29661 15.2925 4.68644V7.4661C14.2736 7.55085 13.4623 8.31356 13.4623 9.26271V9.68644H6.51887V9.26271C6.51887 8.31356 5.70755 7.55085 4.68868 7.4661V4.70339ZM13.4434 10.2966V12.3983H6.51887V10.2966H13.4434ZM5.85849 16.8898H5.16038V15.7373H5.85849V16.8898ZM14.8208 16.8898H14.1226V15.7373H14.8208V16.8898ZM16.8208 13.822H16.8019C16.8019 14.4153 16.5566 15.1441 15.3302 15.1441H14.8208H14.1226H5.85849H5.16038H4.65094C3.99057 15.1441 3.17925 14.9237 3.17925 13.822V9.26271C3.17925 8.6017 3.78302 8.05932 4.51887 8.05932C5.25472 8.05932 5.85849 8.6017 5.85849 9.26271V12.7034C5.85849 12.8729 6.00943 13.0085 6.19811 13.0085H13.8019C13.9906 13.0085 14.1415 12.8729 14.1415 12.7034V9.26271C14.1415 8.6017 14.7453 8.05932 15.4811 8.05932C16.217 8.05932 16.8208 8.6017 16.8208 9.26271V13.822Z", fill: "#347ADB", stroke: "#347ADB", "stroke-width": "0.8" }) }), _jsx("defs", { children: _jsx("clipPath", { id: "clip0_3019_14165", children: _jsx("rect", { width: "16.6667", height: "16.6667", fill: "white", transform: "translate(1.66675 1.6665)" }) }) })] }));
4
+ };
@@ -17,7 +17,27 @@ export declare const dummyImage: {
17
17
  y: number;
18
18
  }[];
19
19
  }[];
20
- export declare const dataDummy: {
20
+ export declare const dataDummy: ({
21
+ x: number;
22
+ y: number;
23
+ width: number;
24
+ height: number;
25
+ shape: string;
26
+ id: string;
27
+ fill: string;
28
+ rotation: number;
29
+ seatCount: number;
30
+ text: string;
31
+ labels: ({
32
+ label: string;
33
+ fontSize: number;
34
+ y: number;
35
+ } | {
36
+ label: string;
37
+ y: number;
38
+ fontSize?: undefined;
39
+ })[];
40
+ } | {
21
41
  x: number;
22
42
  y: number;
23
43
  width: number;
@@ -37,4 +57,4 @@ export declare const dataDummy: {
37
57
  y: number;
38
58
  fontSize?: undefined;
39
59
  })[];
40
- }[];
60
+ })[];
@@ -28,7 +28,7 @@ export const dataDummy = [
28
28
  "width": 63,
29
29
  "height": 93,
30
30
  "shape": "square",
31
- "id": 1747655878536,
31
+ "id": "1747655878536",
32
32
  "fill": "#bca16a",
33
33
  "rotation": 0,
34
34
  "seatCount": 0,
@@ -51,7 +51,7 @@ export const dataDummy = [
51
51
  "width": 63,
52
52
  "height": 93,
53
53
  "shape": "square",
54
- "id": 1747655922755,
54
+ "id": "1747655922755",
55
55
  "fill": "#bca16a",
56
56
  "rotation": 0,
57
57
  "seatCount": 0,
@@ -74,7 +74,7 @@ export const dataDummy = [
74
74
  "width": 63,
75
75
  "height": 93,
76
76
  "shape": "square",
77
- "id": 1747656018493,
77
+ "id": "1747656018493",
78
78
  "fill": "#bca16a",
79
79
  "rotation": 0,
80
80
  "seatCount": 0,
@@ -97,7 +97,7 @@ export const dataDummy = [
97
97
  "width": 63,
98
98
  "height": 93,
99
99
  "shape": "square",
100
- "id": 1747656025256,
100
+ "id": "1747656025256",
101
101
  "fill": "#bca16a",
102
102
  "rotation": 0,
103
103
  "seatCount": 0,
@@ -1,41 +1,78 @@
1
1
  "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import LayerView from "@/features/view";
4
- import { useState, useEffect } from "react";
5
- import { dataDummy } from "./constant";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import LayerView from "@/features/view-only-3";
4
+ import { useState, useRef } from "react";
5
+ import { data4 } from "../constant";
6
+ import { ChairIcon } from "./chair";
7
+ import { UserIcon } from "./user";
8
+ import { Modal } from "antd";
9
+ import JsonView from '@uiw/react-json-view';
10
+ const Card = (item) => {
11
+ const handleDragStart = (e) => {
12
+ // Jangan preventDefault di drag start
13
+ e.dataTransfer.setData("application/json", JSON.stringify(item));
14
+ e.dataTransfer.effectAllowed = "move";
15
+ };
16
+ return (_jsxs("div", { className: "h-40 bg-gray-400 shadow-lg rounded-lg p-4 m-4", "data-table": JSON.stringify(item), draggable: true, onContextMenu: (e) => e.preventDefault(), onDragStart: handleDragStart, onClick: (e) => e.stopPropagation(), onPointerDown: (e) => e.stopPropagation(), children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Card Title" }), _jsx("p", { className: "text-gray-600", children: item === null || item === void 0 ? void 0 : item.name })] }));
17
+ };
6
18
  const TouchScrollDetect = () => {
7
- const [fingerCount, setFingerCount] = useState(0);
8
- const [scrollType, setScrollType] = useState(""); // untuk kondisi tampilan
9
- useEffect(() => {
10
- const container = document.getElementById("scroll-container");
11
- const handleTouchStart = (e) => {
12
- const count = e.touches.length;
13
- setFingerCount(count);
14
- if (count === 1) {
15
- setScrollType("one");
16
- }
17
- else if (count === 2) {
18
- setScrollType("two");
19
- }
20
- else {
21
- setScrollType("other");
22
- }
23
- };
24
- const handleTouchEnd = () => {
25
- setFingerCount(0);
26
- setScrollType(""); // reset saat tidak ada sentuhan
27
- };
28
- if (container) {
29
- container.addEventListener("touchstart", handleTouchStart);
30
- container.addEventListener("touchend", handleTouchEnd);
31
- }
32
- return () => {
33
- if (container) {
34
- container.removeEventListener("touchstart", handleTouchStart);
35
- container.removeEventListener("touchend", handleTouchEnd);
36
- }
37
- };
38
- }, []);
39
- return (_jsx(LayerView, { statusKey: "status", defaultBackground: "#000000", componentProps: dataDummy, extraComponentProps: [] }));
19
+ const refLayer = useRef(null);
20
+ const [open, setOpen] = useState(false);
21
+ const [table, setTable] = useState(null);
22
+ const handleZoomIn = () => {
23
+ var _a, _b;
24
+ (_b = (_a = refLayer === null || refLayer === void 0 ? void 0 : refLayer.current) === null || _a === void 0 ? void 0 : _a.transformRef) === null || _b === void 0 ? void 0 : _b.zoomIn(0.1);
25
+ };
26
+ const handleZoomOut = () => {
27
+ var _a, _b;
28
+ (_b = (_a = refLayer === null || refLayer === void 0 ? void 0 : refLayer.current) === null || _a === void 0 ? void 0 : _a.transformRef) === null || _b === void 0 ? void 0 : _b.zoomOut();
29
+ };
30
+ const handleSwitch = (e, data) => {
31
+ setOpen(!open);
32
+ setTable(data);
33
+ };
34
+ const handleDrop = (e, data) => {
35
+ e.preventDefault();
36
+ setOpen(!open);
37
+ setTable(data);
38
+ };
39
+ const handleSelectTable = (item) => {
40
+ setOpen(!open);
41
+ setTable(item);
42
+ };
43
+ const renderModal = () => {
44
+ return (_jsx(Modal, { open: open, onCancel: () => setOpen(false), width: 700, title: "Preview Board", centered: true, footer: null, children: _jsx("div", { className: "flex flex-col p-4 h-[500px] overflow-auto", children: _jsx(JsonView, { value: table }) }) }));
45
+ };
46
+ return (_jsxs("div", { className: "w-full h-screen border-2 border-black overflow-auto", id: "scroll-container", children: [renderModal(), _jsxs("div", { className: "flex", children: [_jsx("div", { className: "h-screen bg-gray-500 w-1/3", children: _jsx("div", { className: "p-4", children: data4.map((item, index) => (_jsx(Card, Object.assign({}, item), index))) }) }), _jsxs("div", { className: "h-screen w-2/3 relative", children: [_jsxs("div", { className: "absolute top-1 right-1 flex gap-4 z-[10]", children: [_jsx("button", { className: "p-4 bg-gray-400", onClick: () => handleZoomIn(), children: "+" }), _jsx("button", { className: "p-4 bg-gray-400", onClick: () => handleZoomOut(), children: "-" })] }), _jsx(LayerView, { refs: refLayer, statusKey: "status", defaultBackground: "#000000", mappingKey: "properties", componentProps: data4, onDrop: (e, data) => handleDrop(e, data), onSwitch: (e, data) => handleSwitch(e, data), extraComponentProps: [], onSelectComponent: (component) => {
47
+ handleSelectTable(component);
48
+ }, dragTableBlockKey: [
49
+ {
50
+ key: "is_lock",
51
+ value: 1,
52
+ },
53
+ ], tableMatchKey: [
54
+ {
55
+ key: 0,
56
+ properties: { fill: "white" },
57
+ },
58
+ ], eventMatchTable: [
59
+ {
60
+ event: "mouseenter",
61
+ properties: { fill: "red" },
62
+ },
63
+ {
64
+ event: "selected",
65
+ properties: { fill: "white" },
66
+ },
67
+ ], iconTags: [
68
+ {
69
+ icon: _jsx(ChairIcon, {}),
70
+ key: "chair",
71
+ },
72
+ {
73
+ icon: _jsx(UserIcon, {}),
74
+ key: "user",
75
+ },
76
+ ] })] })] })] }));
40
77
  };
41
78
  export default TouchScrollDetect;
@@ -0,0 +1 @@
1
+ export function UserIcon(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const UserIcon = () => {
3
+ return (_jsxs("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M7.61992 10.1625C9.00754 10.1625 10.1324 9.03757 10.1324 7.64995C10.1324 6.26234 9.00754 5.13745 7.61992 5.13745C6.23231 5.13745 5.10742 6.26234 5.10742 7.64995C5.10742 9.03757 6.23231 10.1625 7.61992 10.1625Z", fill: "#5E6278" }), _jsx("path", { d: "M7.62 14.9999C9.34313 14.9999 10.74 14.1168 10.74 13.0274C10.74 11.9381 9.34313 11.0549 7.62 11.0549C5.89687 11.0549 4.5 11.9381 4.5 13.0274C4.5 14.1168 5.89687 14.9999 7.62 14.9999Z", fill: "#5E6278" }), _jsx("path", { opacity: "0.3", d: "M11.595 4.23C12.7631 4.23 13.71 3.28308 13.71 2.115C13.71 0.946918 12.7631 0 11.595 0C10.4269 0 9.47998 0.946918 9.47998 2.115C9.47998 3.28308 10.4269 4.23 11.595 4.23Z", fill: "#5E6278" }), _jsx("path", { opacity: "0.3", d: "M3.62257 4.23C4.79065 4.23 5.73757 3.28308 5.73757 2.115C5.73757 0.946918 4.79065 0 3.62257 0C2.45449 0 1.50757 0.946918 1.50757 2.115C1.50757 3.28308 2.45449 4.23 3.62257 4.23Z", fill: "#5E6278" }), _jsxs("g", { opacity: "0.3", children: [_jsx("path", { d: "M11.4749 5.87256C11.2349 5.87256 11.0024 5.87256 10.7699 5.91006C11.1229 6.52313 11.2825 7.22856 11.2276 7.93388C11.1727 8.63919 10.906 9.31147 10.4624 9.86256C10.7984 9.92909 11.1399 9.96424 11.4824 9.96756C13.3874 9.96756 14.9249 9.04506 14.9249 7.92006C14.9249 6.79506 13.3799 5.87256 11.4749 5.87256Z", fill: "#5E6278" }), _jsx("path", { d: "M3.4499 6C3.6899 6 3.9224 6 4.1549 6.0375C3.80187 6.65057 3.64233 7.356 3.6972 8.06132C3.75208 8.76664 4.0188 9.43891 4.4624 9.99C4.12639 10.0565 3.78492 10.0917 3.4424 10.095C1.5374 10.095 -9.77516e-05 9.1725 -9.77516e-05 8.0475C-9.77516e-05 6.9225 1.5449 6 3.4499 6Z", fill: "#5E6278" })] })] }));
4
+ };
@@ -9,11 +9,30 @@ interface LayersProps {
9
9
  onBlur?: () => void;
10
10
  selectedTable?: any;
11
11
  selectedTableColor?: string;
12
+ selectionLines?: any;
12
13
  style?: any;
13
14
  mode?: "view" | "edit";
14
- onTouchStart?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement>, items: any, direction?: string) => void;
15
- onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement>) => void;
16
- onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement>) => void;
15
+ onTouchStart?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement | SVGEllipseElement>, items: any, direction?: string) => void;
16
+ onTouchMove?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement | SVGEllipseElement>) => void;
17
+ onTouchEnd?: (e: React.TouchEvent<SVGRectElement | SVGCircleElement | SVGTextElement | SVGImageElement | SVGPolygonElement | SVGEllipseElement>) => void;
17
18
  }
18
- declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, onTouchStart, }: LayersProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const Layers: ({ shadowShape, components, onClick, selectedComponent, selectedTable, activeTool, onMouseDown, onMouseUp, onBlur, selectedTableColor, mode, style, selectionLines, }: LayersProps) => import("react/jsx-runtime").JSX.Element;
19
20
  export default Layers;
21
+ export declare function rectToPolygonNodes(x: number, y: number, width: number, height: number): {
22
+ x: number;
23
+ y: number;
24
+ }[];
25
+ export declare function distributeWithSpacing({ start, length, count, radius, spacing, }: {
26
+ start: number;
27
+ length: number;
28
+ count: number;
29
+ radius: number;
30
+ spacing?: number;
31
+ }): number[];
32
+ export declare const arcByDirection: ({ cx, cy, r, direction, fraction, }: {
33
+ cx: number;
34
+ cy: number;
35
+ r: number;
36
+ direction?: string;
37
+ fraction?: number;
38
+ }) => string;