seat-editor 3.3.16 → 3.3.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.
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  import { useEffect, useState } from "react";
3
3
  import SeatEditor from "../../features/package";
4
- import { dummyExtra6 } from "../constant";
5
4
  export default function NewBoard() {
6
5
  const [initialValue, setInitialValue] = useState([]);
7
6
  const [extraComponents, setExtraComponents] = useState([]);
@@ -9,7 +8,7 @@ export default function NewBoard() {
9
8
  const [viewOnly, setViewOnly] = useState(false);
10
9
  useEffect(() => {
11
10
  setInitialValue([]);
12
- setExtraComponents(dummyExtra6);
11
+ setExtraComponents([]);
13
12
  }, []);
14
13
  const handleUploadImage = (file) => {
15
14
  const test = new Promise((resolve, reject) => {
@@ -20,6 +19,23 @@ export default function NewBoard() {
20
19
  });
21
20
  return test;
22
21
  };
22
+ const test = [{
23
+ test: "test",
24
+ properties: {
25
+ shape: "image-table",
26
+ width: 200,
27
+ height: 200,
28
+ x: 100,
29
+ y: 100,
30
+ backgroundColor: "#ffffff",
31
+ src: "dummyImage",
32
+ }
33
+ }];
34
+ // const ayo =test?.map((item) => {
35
+ // return {
36
+ // properties: item?.properties?.
37
+ // }
38
+ // })
23
39
  return (<>
24
40
  <div className="w-full h-screen flex flex-col relative justify-center">
25
41
  <div className="w-full h-[1000px] bg-white border-r border-gray-200">
@@ -31,7 +47,7 @@ export default function NewBoard() {
31
47
  {viewOnly ? "Edit Mode ddd" : "View Mode"}
32
48
  </button> */}
33
49
  <div className="flex-1 h-full">
34
- <SeatEditor componentProps={initialValue} viewOnly={viewOnly} dragOnly={true} deleteAutorized={{
50
+ <SeatEditor componentProps={test} viewOnly={viewOnly} dragOnly={true} deleteAutorized={{
35
51
  component: true,
36
52
  extraComponent: true,
37
53
  }} action={handleUploadImage} mappingKey="properties" onCurrentStateChange={(setState) => {
@@ -45,7 +61,7 @@ export default function NewBoard() {
45
61
  if (((_c = setState === null || setState === void 0 ? void 0 : setState.extraComponents) === null || _c === void 0 ? void 0 : _c.length) > 0) {
46
62
  setExtraComponents((_d = setState.extraComponents) !== null && _d !== void 0 ? _d : []);
47
63
  }
48
- }} extraComponentProps={dummyExtra6} defaultBackground={backgroundColor}
64
+ }} extraComponentProps={extraComponents} defaultBackground={backgroundColor}
49
65
  // dragOnly={true}
50
66
  statusKey="status"/>
51
67
  </div>
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import LayerView from "../../features/view-only-3";
3
3
  import { useState, useRef } from "react";
4
- import { data4, test1 } from "../constant";
4
+ // import { data4, test4, test1 } from "../constant";
5
5
  import { ChairIcon } from "./chair";
6
6
  import { UserIcon } from "./user";
7
7
  import { Modal } from "antd";
@@ -154,9 +154,8 @@ const TouchScrollDetect = () => {
154
154
  setTable(data);
155
155
  };
156
156
  const handleDrop = (e, data) => {
157
- var _a;
158
157
  console.log("data drop", data);
159
- const targetData = (_a = data === null || data === void 0 ? void 0 : data.targetTable) === null || _a === void 0 ? void 0 : _a.test;
158
+ const targetData = data === null || data === void 0 ? void 0 : data.targetTable;
160
159
  e.preventDefault();
161
160
  setOpen(!open);
162
161
  setTable(data);
@@ -172,12 +171,15 @@ const TouchScrollDetect = () => {
172
171
  </div>
173
172
  </Modal>);
174
173
  };
174
+ const testData = [];
175
175
  return (<div className="w-full h-screen border-2 border-black overflow-auto" id="scroll-container">
176
176
  {renderModal()}
177
177
  <div className="flex">
178
178
  <div className="h-screen bg-gray-500 w-1/3">
179
179
  <div className="p-4">
180
- {data4.map((item, index) => (<Card key={index} {...item}/>))}
180
+ {/* {data4.map((item, index) => (
181
+ <Card key={index} {...item} />
182
+ ))} */}
181
183
  </div>
182
184
  </div>
183
185
  <div className="h-screen w-2/3 relative">
@@ -198,7 +200,12 @@ const TouchScrollDetect = () => {
198
200
  key: "rsvp_time",
199
201
  items: ["text", "icon"],
200
202
  },
201
- ]} defaultBackground="#000000" mappingKey="properties" componentProps={test1} onDrop={(e, data) => handleDrop(e, data)} onSwitch={(e, data) => handleSwitch(e, data)} extraComponentProps={[]} onSelectComponent={(component) => {
203
+ ]} defaultBackground="#000000" mappingKey="properties" componentProps={testData === null || testData === void 0 ? void 0 : testData.map((item) => {
204
+ return {
205
+ properties: item === null || item === void 0 ? void 0 : item.properties,
206
+ test: item === null || item === void 0 ? void 0 : item.test,
207
+ };
208
+ })} onDrop={(e, data) => handleDrop(e, data)} onSwitch={(e, data) => handleSwitch(e, data)} extraComponentProps={[]} onSelectComponent={(component) => {
202
209
  handleSelectTable(component);
203
210
  }}
204
211
  // dragTableBlockKey={[
@@ -1,7 +1,7 @@
1
1
  import { PropertiesProps, BaseElement, Point } from "../../dto/table";
2
2
  export interface SelectionLines extends BaseElement {
3
3
  points?: Point[];
4
- id?: string;
4
+ id?: string | number;
5
5
  }
6
6
  interface LayersProps {
7
7
  components?: PropertiesProps[];
@@ -17,7 +17,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
17
17
  };
18
18
  switch (shape) {
19
19
  case "square":
20
- return (<g key={id} data-id={id} id={id} transform={`translate(${x}, ${y})`}>
20
+ return (<g key={id} data-id={id} id={`${id}`} transform={`translate(${x}, ${y})`}>
21
21
  <g transform={`rotate(${rotation}, 0, 0)`}>
22
22
  <rect {...commonProps} key={id} width={width} height={height} rx={radius}/>
23
23
  <g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
@@ -534,7 +534,7 @@ const Layers = ({ components, selectedComponent, activeTool, selectionLines, })
534
534
  </g>);
535
535
  case "image-table":
536
536
  case "background":
537
- return (<g key={id} id={id} data-id={id} transform={`translate(${x}, ${y})`} style={{
537
+ return (<g key={id} id={`${id}`} data-id={id} transform={`translate(${x}, ${y})`} style={{
538
538
  pointerEvents: lockBackground ? "none" : "auto",
539
539
  }}>
540
540
  <g transform={`rotate(${rotation}, 0, 0)`}>
@@ -242,7 +242,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
242
242
  const transformRotate = `rotate(${rotate} ${x + width / 2} ${y + height / 2})`;
243
243
  switch (shape) {
244
244
  case "square":
245
- return (<g key={id} id={id} data-id={id} transform={`translate(${x}, ${y})`} style={{ pointerEvents: "all" }} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
245
+ return (<g key={id} id={`${id}`} data-id={id} transform={`translate(${x}, ${y})`} style={{ pointerEvents: "all" }} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
246
246
  const group = e.currentTarget;
247
247
  highlightGroup(group, "dragenter");
248
248
  }} onDragOver={(e) => {
@@ -389,7 +389,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
389
389
  const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
390
390
  return { cx, cy };
391
391
  });
392
- return (<g key={id} style={{ pointerEvents: "all" }} data-id={id} id={id} transform={`translate(${x}, ${y})`} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
392
+ return (<g key={id} style={{ pointerEvents: "all" }} data-id={id} id={`${id}`} transform={`translate(${x}, ${y})`} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
393
393
  e.preventDefault(); // penting
394
394
  const group = e.currentTarget;
395
395
  highlightGroup(group, "dragenter");
@@ -982,7 +982,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
982
982
  </g>
983
983
  </g>);
984
984
  case "image-table":
985
- return (<g key={id} id={id} data-id={id} transform={`translate(${x}, ${y})`} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
985
+ return (<g key={id} id={`${id}`} data-id={id} transform={`translate(${x}, ${y})`} onContextMenu={(e) => e.preventDefault()} onDragEnter={(e) => {
986
986
  e.preventDefault(); // penting
987
987
  const group = e.currentTarget;
988
988
  highlightGroup(group, "dragenter");
@@ -33,7 +33,7 @@ export interface Tag {
33
33
  gap?: number;
34
34
  }
35
35
  export interface TableProps {
36
- id?: string;
36
+ id?: string | number;
37
37
  labels?: Label[];
38
38
  fontColor?: string;
39
39
  src?: string;
@@ -599,7 +599,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
599
599
  const { tx, ty } = stabilizeRotation(x0, y0, w0, h0, 0, newAngle);
600
600
  selectionLines === null || selectionLines === void 0 ? void 0 : selectionLines.setAttribute("transform", `translate(${tx}, ${ty}) `);
601
601
  // ROTATE ALL ELEMENT IN SELECTION
602
- const allID = (_d = dataElementSelectionGroupRef.current) === null || _d === void 0 ? void 0 : _d.map((el) => el.id);
602
+ const allID = (_d = dataElementSelectionGroupRef.current) === null || _d === void 0 ? void 0 : _d.map((el) => String(el.id));
603
603
  const deltaAngle = newAngle - 0;
604
604
  const rad = (deltaAngle * Math.PI) / 180;
605
605
  const cosA = Math.cos(rad);
@@ -638,11 +638,11 @@ const BoardTemplate = ({ refs, loadingRender }) => {
638
638
  width: selectedLines === null || selectedLines === void 0 ? void 0 : selectedLines.width,
639
639
  height: selectedLines === null || selectedLines === void 0 ? void 0 : selectedLines.height,
640
640
  };
641
- const allID = (_a = dataElementSelectionGroupRef.current) === null || _a === void 0 ? void 0 : _a.map((el) => el.id);
641
+ const allID = (_a = dataElementSelectionGroupRef.current) === null || _a === void 0 ? void 0 : _a.map((el) => String(el.id));
642
642
  const allDataRealSelection = (_b = [
643
643
  ...componentsState,
644
644
  ...(lockBackground ? [] : extraComponentsState),
645
- ]) === null || _b === void 0 ? void 0 : _b.filter((el) => allID.includes(el.id));
645
+ ]) === null || _b === void 0 ? void 0 : _b.filter((el) => allID.includes(String(el.id)));
646
646
  const allGroupsAttribute = getAttributeElements(svg, allID);
647
647
  const resultSelection = resizeBox({
648
648
  box: oldSel,
@@ -721,7 +721,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
721
721
  ...(lockBackground ? [] : extraComponentsState),
722
722
  ]) === null || _b === void 0 ? void 0 : _b.filter((el) => allID.includes(el.id));
723
723
  allDataRealSelection.forEach((item) => {
724
- const { g } = getAttributeElement(svg, item.id);
724
+ const { g } = getAttributeElement(svg, String(item.id));
725
725
  const newX = pos.x - x;
726
726
  const newY = pos.y - y;
727
727
  g.setAttribute("transform", `translate(${item.x + newX}, ${item.y + newY})`);
@@ -780,7 +780,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
780
780
  ...(lockBackground ? [] : extraComponentsState),
781
781
  ]
782
782
  .filter((c) => selectedIds.map(String).includes(String(c.id)))) === null || _b === void 0 ? void 0 : _b.map((item) => {
783
- const { g } = getAttributeElement(svg, item.id);
783
+ const { g } = getAttributeElement(svg, String(item.id));
784
784
  // const { x, y } = getTranslate(g);
785
785
  const box = getGlobalBBox(svg, g);
786
786
  return Object.assign(Object.assign({}, item), {
@@ -978,7 +978,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
978
978
  return;
979
979
  const lineHelper = svg.querySelector("#line-help");
980
980
  const circleHelper = svg.querySelector("#circle-help");
981
- const { inner, g } = getAttributeElement(svg, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id);
981
+ const { inner, g } = getAttributeElement(svg, String(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id));
982
982
  if (!inner || !g)
983
983
  return;
984
984
  // mouse → SVG space
@@ -1130,7 +1130,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1130
1130
  const newPoints = Object.assign(Object.assign({}, selectedComponent), { points: [...selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points, newCoord] });
1131
1131
  (_c = svg.querySelector("#polyline-helper")) === null || _c === void 0 ? void 0 : _c.setAttribute("opacity", "1");
1132
1132
  if (closing && ((_d = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.points) === null || _d === void 0 ? void 0 : _d.length) > 2) {
1133
- const { g, inner } = getAttributeElement(svg, selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id);
1133
+ const { g, inner } = getAttributeElement(svg, String(selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id));
1134
1134
  const { height, width } = getGlobalBBox(svg, inner);
1135
1135
  isOnMakePolygonRef.current = false;
1136
1136
  setSelectedComponent(null);
@@ -1160,7 +1160,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1160
1160
  // ROTATE
1161
1161
  if (targetRotate && !isRotateSelectionBox) {
1162
1162
  const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
1163
- const { g } = getAttributeElement(svg, activeId);
1163
+ const { g } = getAttributeElement(svg, String(activeId));
1164
1164
  const boxLines = getGlobalBBox(svg, g);
1165
1165
  const findById = [...componentsState, ...extraComponentsState].find((c) => c.id == activeId);
1166
1166
  const { x, y } = getTranslate(g);
@@ -1226,7 +1226,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1226
1226
  let y2 = [];
1227
1227
  allElementSelectionGroup.forEach((element) => {
1228
1228
  const activeId = element.id;
1229
- const { g } = getAttributeElement(svg, activeId);
1229
+ const { g } = getAttributeElement(svg, String(activeId));
1230
1230
  const { x, y, width, height } = getGlobalBBox(svg, g);
1231
1231
  xs.push(x);
1232
1232
  ys.push(y);
@@ -1279,7 +1279,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1279
1279
  if (isMightResizeElement) {
1280
1280
  const activeId = selectedComponent === null || selectedComponent === void 0 ? void 0 : selectedComponent.id;
1281
1281
  const svg = svgRef.current;
1282
- const { g, element, points } = getAttributeElement(svg, activeId);
1282
+ const { g, element, points } = getAttributeElement(svg, String(activeId));
1283
1283
  const selectionBox = getGlobalBBox(svg, g);
1284
1284
  const { width, height } = getSvgElementSize(element);
1285
1285
  const { x, y } = getTranslate(g);
@@ -1311,7 +1311,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1311
1311
  let y2 = [];
1312
1312
  allElementSelectionGroup.forEach((element) => {
1313
1313
  const activeId = element.id;
1314
- const { g, inner, element: el } = getAttributeElement(svg, activeId);
1314
+ const { g, inner, element: el } = getAttributeElement(svg, String(activeId));
1315
1315
  const { x, y, width, height } = getGlobalBBox(svg, g);
1316
1316
  xs.push(x);
1317
1317
  ys.push(y);
@@ -1377,7 +1377,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1377
1377
  if (downAtResizePositionAndHasSelectionBox || isRotateSelectionBox) {
1378
1378
  isResizeSelectionRef.current = false;
1379
1379
  const results = (_q = dataElementSelectionGroupRef.current) === null || _q === void 0 ? void 0 : _q.map((item) => {
1380
- const { g, element, inner, points } = getAttributeElement(svg, item.id);
1380
+ const { g, element, inner, points } = getAttributeElement(svg, String(item.id));
1381
1381
  const { x, y } = getTranslate(g);
1382
1382
  const { width, height } = getSvgElementSize(element);
1383
1383
  const rotate = getRotation(inner.transform.baseVal);
@@ -1425,7 +1425,7 @@ const BoardTemplate = ({ refs, loadingRender }) => {
1425
1425
  !isRotateSelectionBox) {
1426
1426
  isResizeSelectionRef.current = false;
1427
1427
  const results = (_r = dataElementSelectionGroupRef.current) === null || _r === void 0 ? void 0 : _r.map((item) => {
1428
- const { g } = getAttributeElement(svg, item.id);
1428
+ const { g } = getAttributeElement(svg, String(item.id));
1429
1429
  const { x, y } = getTranslate(g);
1430
1430
  const getBBox = getGlobalBBox(svg, g);
1431
1431
  const findComponent = [
@@ -67,13 +67,13 @@ export declare const resizeSeatSide: ({ seatsPositions, r, openSpace, newElement
67
67
  export declare const resizeSeatRectCircle: ({ seatsPositions, r, openSpace, newElement, seats, seatGroup, }: ResizeSeatSquare) => void;
68
68
  export declare const resizeSeatRectSquare: ({ seatsPositions, r, openSpace, newElement, seats, seatGroup, }: ResizeSeatSquare) => void;
69
69
  export declare function mergeById<T extends {
70
- id?: string;
70
+ id?: string | number;
71
71
  }>(base: T[], updates: Partial<T>[]): T[];
72
72
  export declare function updateSingleComponent<T extends {
73
73
  id?: any;
74
74
  }>(state: T[], component: Partial<T>, setState: (v: T[]) => void): T[];
75
75
  export declare function updateManyComponents<T extends {
76
- id?: string;
76
+ id?: string | number;
77
77
  }>(state: T[], components: Partial<T>[], setState: (v: T[]) => void): T[];
78
78
  export declare function normalizeAngle(angle: number): number;
79
79
  export declare function createTableGhost({ x, y, width, height, fill, shape, id, }: {
@@ -90,7 +90,7 @@ export declare function updateSelectionBox(svg: SVGSVGElement, boxSelection: {
90
90
  y: number;
91
91
  width: number;
92
92
  height: number;
93
- }, id?: string, unFollowCursor?: boolean): void;
93
+ }, id?: string | number, unFollowCursor?: boolean): void;
94
94
  export declare function getGlobalBBox(svg: SVGSVGElement, el: SVGGraphicsElement): {
95
95
  x: number;
96
96
  y: number;
@@ -15,9 +15,7 @@ export type TableMatchEvent = {
15
15
  event: EventHandleType;
16
16
  properties: PropertiesProps;
17
17
  };
18
- export type ComponentProps<T = undefined> = PropertiesProps & T & {
19
- [key: string]: PropertiesProps;
20
- };
18
+ export type ComponentProps<T = undefined> = T extends undefined ? PropertiesProps : Omit<PropertiesProps, keyof T> & T;
21
19
  export type OnCurrentStateChange<TMeta = undefined> = ({ components, extraComponents, background, boundingBox, }: {
22
20
  components: ComponentProps<TMeta>[];
23
21
  extraComponents: ComponentProps[];
@@ -80,7 +80,12 @@ const LayerView = (props) => {
80
80
  setTimeout(() => {
81
81
  dispatch({ type: "panel/setLoading", payload: false });
82
82
  }, 1000);
83
- }, [componentProps, extraComponentProps, defaultBackground, loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state]);
83
+ }, [
84
+ componentProps,
85
+ extraComponentProps,
86
+ defaultBackground,
87
+ loadingRender === null || loadingRender === void 0 ? void 0 : loadingRender.state,
88
+ ]);
84
89
  useEffect(() => {
85
90
  setTooltip(Object.assign(Object.assign({}, tooltip), { visible: false }));
86
91
  }, [privilegedTags]);
@@ -140,7 +145,8 @@ const LayerView = (props) => {
140
145
  maxX = Math.max(maxX, values.x + values.width);
141
146
  maxY = Math.max(maxY, values.y + values.height);
142
147
  }
143
- if ((i === componentsEditor.length - 1) && (extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 0) {
148
+ if (i === componentsEditor.length - 1 &&
149
+ (extraComponentsEditor === null || extraComponentsEditor === void 0 ? void 0 : extraComponentsEditor.length) === 0) {
144
150
  minX = minX > 10 ? minX - 10 : minX;
145
151
  minY = minY > 10 ? minY - 10 : minY;
146
152
  maxX = maxX + 10;
@@ -300,8 +306,9 @@ const LayerView = (props) => {
300
306
  // clone element yang diklik
301
307
  let ghost = targetGroup.cloneNode(true);
302
308
  const ghostId = JSON.parse(targetGroup.getAttribute("data-id") || "{}");
303
- const allowedDrag = !(props === null || props === void 0 ? void 0 : props.dragTableBlockKey) ? true :
304
- (_a = props === null || props === void 0 ? void 0 : props.dragTableBlockKey) === null || _a === void 0 ? void 0 : _a.some((_) => {
309
+ const allowedDrag = !(props === null || props === void 0 ? void 0 : props.dragTableBlockKey)
310
+ ? true
311
+ : (_a = props === null || props === void 0 ? void 0 : props.dragTableBlockKey) === null || _a === void 0 ? void 0 : _a.some((_) => {
305
312
  const dataRaw = originalData({ id: ghostId, type: "find" });
306
313
  return _.value !== (dataRaw === null || dataRaw === void 0 ? void 0 : dataRaw[_.key]);
307
314
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.3.16",
3
+ "version": "3.3.18",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",