seat-editor 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3068,7 +3068,7 @@ export const data4 = [
3068
3068
  status: 0,
3069
3069
  properties: {
3070
3070
  x: 100,
3071
- y: 20,
3071
+ y: 520,
3072
3072
  id: "1761194669729132000",
3073
3073
  stroke: "#347ADB", //warna border
3074
3074
  fill: "#E1F4FF", //warna latar belakang
@@ -1,13 +1,13 @@
1
1
  export const dummyImage = [
2
2
  {
3
3
  "id": 1747388267450,
4
- "x": 0,
5
- "y": 0,
6
- "width": 973.391304347826,
4
+ "x": 368,
5
+ "y": 77.54706573486328,
6
+ "width": 751.9405198530717,
7
7
  "height": 812,
8
8
  "rotation": 0,
9
9
  "shape": "background",
10
- "src": "http://192.168.88.99:9106/v1/public/5bf923de-2366-4a11-9b8b-e92de0afbf05/3a65cb36-7d85-4c38-9403-a15f94641920/1745396181_floor_boi.jpeg",
10
+ "src": "https://cdn.table.link/prod/5bf923de-2366-4a11-9b8b-e92de0afbf05/3a65cb36-7d85-4c38-9403-a15f94641920/68d45207-d66b-4bb5-92a2-4e5a87715e98/rsvp/1753965985769725756_BOI Reg.png",
11
11
  "fill": "#bca16a",
12
12
  "opacity": 1,
13
13
  "labels": [
@@ -229,14 +229,19 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
229
229
  }} onMouseLeave={(e) => {
230
230
  const group = e.currentTarget;
231
231
  unhighlightGroup(group);
232
- }}>
233
- <rect key={`${id}-rect`} x={x} y={y} width={width} height={height} fill={fill} className="blink-2" transform={transformRotate} {...omit(item, TABLE_KEYS)} {...commonProps}/>
232
+ }} transform={`translate(${x}, ${y})`}>
233
+ <rect key={`${id}-rect`}
234
+ // x={}
235
+ // y={y}
236
+ width={width} height={height} fill={fill} className="blink-2"
237
+ // transform={transformRotate}
238
+ {...omit(item, [...TABLE_KEYS, "x", "y", "label"])} {...commonProps}/>
234
239
 
235
240
  {renderTags(tags)}
236
241
 
237
242
  {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
238
243
  var _a, _b, _c, _d;
239
- return (<text {...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={transformRotate} {..._}>
244
+ return (<text {...omit(commonProps, ["opacity", "stroke", "strokeWidth"])} key={`${id}-label-${index}`} x={width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0)} 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={transformRotate} {..._}>
240
245
  {_ === null || _ === void 0 ? void 0 : _.label}
241
246
  </text>);
242
247
  })}
@@ -4,6 +4,7 @@ import { TransformWrapper, TransformComponent, } from "react-zoom-pan-pinch";
4
4
  import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
5
5
  import Layers from "../../components/layer-v4";
6
6
  import { isEmpty } from "lodash";
7
+ import { getTranslate } from "../board-v3/utils";
7
8
  const LayerView = (props) => {
8
9
  const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, statusKey, defaultBackground, iconTags, tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, } = props;
9
10
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
@@ -154,11 +155,13 @@ const LayerView = (props) => {
154
155
  minX = minX - minX * 0.5;
155
156
  minY = minY - minY * 0.5;
156
157
  }
158
+ const paddingY = maxY * 0.2 + minY * 0.2;
159
+ const paddingX = maxX * 0.2 + minX * 0.1;
157
160
  return {
158
- minX: backgroundHasOne ? minX : minX - minX * 0.5,
159
- minY: backgroundHasOne ? minY : minY - minY * 0.5,
160
- width: maxX,
161
- height: maxY,
161
+ minX: (minX - paddingX) - (minX - paddingX) * 0.5,
162
+ minY: minY - paddingY * 2,
163
+ width: maxX + paddingX * 2,
164
+ height: maxY + paddingY + (maxY + paddingY) * 0.5,
162
165
  };
163
166
  }, [componentsEditor, extraComponentsEditor]);
164
167
  const renderElements = (elementEditor, mappingKey, tableMatchKey) => {
@@ -198,7 +201,6 @@ const LayerView = (props) => {
198
201
  const handleTableEvent = (event, type) => {
199
202
  var _a;
200
203
  event.preventDefault();
201
- console.log("drop");
202
204
  // cari elemen yg diklik
203
205
  const elementTarget = event.target;
204
206
  if (!elementTarget)
@@ -230,8 +232,17 @@ const LayerView = (props) => {
230
232
  console.error("Invalid data-id JSON:", err);
231
233
  }
232
234
  };
235
+ const getSvgCoords = (e) => {
236
+ var _a;
237
+ const svg = svgRef.current;
238
+ const point = svg.createSVGPoint();
239
+ point.x = e.clientX;
240
+ point.y = e.clientY;
241
+ const transformed = point.matrixTransform((_a = svg.getScreenCTM()) === null || _a === void 0 ? void 0 : _a.inverse());
242
+ return { x: transformed.x, y: transformed.y };
243
+ };
233
244
  const handlePointerDown = (e) => {
234
- var _a, _b;
245
+ var _a;
235
246
  const svg = svgRef.current;
236
247
  if (!e.isPrimary)
237
248
  return;
@@ -241,6 +252,7 @@ const LayerView = (props) => {
241
252
  let hasMoved = false;
242
253
  const startX = e.clientX;
243
254
  const startY = e.clientY;
255
+ const { x, y } = getSvgCoords(e);
244
256
  const targetGroup = e.target.closest("g[data-id]");
245
257
  if (!targetGroup) {
246
258
  setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
@@ -267,20 +279,15 @@ const LayerView = (props) => {
267
279
  const pt = svg.createSVGPoint();
268
280
  pt.x = e.clientX;
269
281
  pt.y = e.clientY;
270
- const pointerSVG = pt.matrixTransform((_b = svg.getScreenCTM()) === null || _b === void 0 ? void 0 : _b.inverse());
271
- const box = targetGroup.getBBox();
272
- const mousePositionInGroup = {
273
- x: pointerSVG.x - box.x,
274
- y: pointerSVG.y - box.y,
275
- };
282
+ const startBox = getTranslate(targetGroup);
276
283
  const groupCTM = targetGroup.getCTM();
277
284
  if (!groupCTM) {
278
285
  setTooltip((prev) => (Object.assign(Object.assign({}, prev), { visible: false })));
279
286
  return;
280
287
  }
281
288
  const offset = {
282
- x: box.x + mousePositionInGroup.x,
283
- y: box.y + mousePositionInGroup.y,
289
+ x: x - startBox.x,
290
+ y: y - startBox.y,
284
291
  };
285
292
  const pointerMoveGhost = (ev) => {
286
293
  var _a;
@@ -477,7 +484,10 @@ const LayerView = (props) => {
477
484
  handlePan(0, -speedPanning);
478
485
  }
479
486
  };
480
- return (<div className="relative w-full h-full flex-1" ref={containerRef} {...props.containerProps}>
487
+ return (<div className="relative w-full h-full flex-1" ref={containerRef} style={{
488
+ overflow: "auto",
489
+ WebkitOverflowScrolling: "touch",
490
+ }} {...props.containerProps}>
481
491
  {/* {isDragging?.current && (
482
492
  <div className="absolute bottom-1/2 left-1 flex gap-4 z-[10]">
483
493
  <button className="p-4 bg-gray-400">+</button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",