seat-editor 3.1.10 → 3.1.12

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.
@@ -100,6 +100,127 @@ export declare const data3: {
100
100
  is_fdc: number;
101
101
  max_pax_fdc: number;
102
102
  }[];
103
+ export declare const test4: ({
104
+ x: number;
105
+ y: number;
106
+ id: number;
107
+ fill: string;
108
+ tags: ({
109
+ gap: string;
110
+ key: string;
111
+ items: ({
112
+ type: string;
113
+ value: string;
114
+ fontSize: number;
115
+ } | {
116
+ type: string;
117
+ value: string;
118
+ fontSize?: undefined;
119
+ })[];
120
+ direction: string;
121
+ offsetY?: undefined;
122
+ offsetX?: undefined;
123
+ } | {
124
+ gap: string;
125
+ key: string;
126
+ items: ({
127
+ type: string;
128
+ value: string;
129
+ fontSize: number;
130
+ } | {
131
+ type: string;
132
+ value: string;
133
+ fontSize?: undefined;
134
+ })[];
135
+ direction: string;
136
+ offsetY: number;
137
+ offsetX: number;
138
+ })[];
139
+ shape: string;
140
+ width: number;
141
+ height: number;
142
+ labels: {
143
+ x: number;
144
+ y: number;
145
+ label: string;
146
+ fontSize: number;
147
+ fontColor: string;
148
+ }[];
149
+ opacity: number;
150
+ rotation: number;
151
+ seatCount: number;
152
+ uuid_table: string;
153
+ gapTags: number;
154
+ properties?: undefined;
155
+ } | {
156
+ properties: {
157
+ x: number;
158
+ y: number;
159
+ id: string;
160
+ fill: string;
161
+ stroke: string;
162
+ strokeWidth: number;
163
+ text: string;
164
+ shape: Shape;
165
+ width: number;
166
+ height: number;
167
+ gapTags: number;
168
+ labels: {
169
+ x: number;
170
+ y: number;
171
+ label: string;
172
+ fontSize: number;
173
+ fontColor: string;
174
+ }[];
175
+ tags: ({
176
+ key: string;
177
+ items: ({
178
+ type: TagType;
179
+ value: string;
180
+ fontSize: number;
181
+ fontWeight: number;
182
+ fill: string;
183
+ } | {
184
+ type: string;
185
+ value: string;
186
+ fontSize?: undefined;
187
+ fontWeight?: undefined;
188
+ fill?: undefined;
189
+ })[];
190
+ direction: string;
191
+ gap: number;
192
+ offsetX: number;
193
+ offsetY: number;
194
+ } | {
195
+ key: string;
196
+ items: {
197
+ value: string;
198
+ type: TagType;
199
+ }[];
200
+ direction: string;
201
+ gap: number;
202
+ offsetX?: undefined;
203
+ offsetY?: undefined;
204
+ })[];
205
+ opacity: number;
206
+ rotation: number;
207
+ seatCount: number;
208
+ };
209
+ x?: undefined;
210
+ y?: undefined;
211
+ id?: undefined;
212
+ fill?: undefined;
213
+ tags?: undefined;
214
+ shape?: undefined;
215
+ width?: undefined;
216
+ height?: undefined;
217
+ labels?: undefined;
218
+ opacity?: undefined;
219
+ rotation?: undefined;
220
+ seatCount?: undefined;
221
+ uuid_table?: undefined;
222
+ gapTags?: undefined;
223
+ })[];
103
224
  export declare const data4: ({
104
225
  uuid_table: string;
105
226
  status: number;
@@ -3062,6 +3062,159 @@ export const data3 = [
3062
3062
  max_pax_fdc: 0,
3063
3063
  },
3064
3064
  ];
3065
+ export const test4 = [{
3066
+ "x": 359.7921676635742,
3067
+ "y": 109.07066345214844,
3068
+ "id": 1753965738978,
3069
+ "fill": "#bca16a",
3070
+ "tags": [
3071
+ {
3072
+ "gap": "5",
3073
+ "key": "table",
3074
+ "items": [
3075
+ {
3076
+ "type": "text",
3077
+ "value": "VIP 1",
3078
+ "fontSize": 10
3079
+ },
3080
+ {
3081
+ "type": "icon",
3082
+ "value": "chair"
3083
+ }
3084
+ ],
3085
+ "direction": "column",
3086
+ },
3087
+ {
3088
+ "gap": "8",
3089
+ "key": "pax",
3090
+ "items": [
3091
+ {
3092
+ "type": "text",
3093
+ "value": "8/2",
3094
+ "fontSize": 10
3095
+ },
3096
+ {
3097
+ "type": "icon",
3098
+ "value": "user"
3099
+ }
3100
+ ],
3101
+ "direction": "flex",
3102
+ "offsetY": 1,
3103
+ "offsetX": 3
3104
+ },
3105
+ {
3106
+ "gap": "2",
3107
+ "key": "rsvp_time",
3108
+ "items": [
3109
+ {
3110
+ "type": "text",
3111
+ "value": "17:30"
3112
+ }
3113
+ ],
3114
+ "direction": "column",
3115
+ "offsetY": 1,
3116
+ "offsetX": 3
3117
+ }
3118
+ ],
3119
+ "shape": "square",
3120
+ "width": 50,
3121
+ "height": 80,
3122
+ "labels": [
3123
+ {
3124
+ "x": 0,
3125
+ "y": 4,
3126
+ "label": "V 1",
3127
+ "fontSize": 12,
3128
+ "fontColor": "#0d0c0c"
3129
+ }
3130
+ ],
3131
+ "opacity": 0.5,
3132
+ "rotation": 0,
3133
+ "seatCount": 0,
3134
+ "uuid_table": "d088bba0-e990-410e-aea9-08548175a0b9",
3135
+ "gapTags": 20
3136
+ },
3137
+ {
3138
+ properties: {
3139
+ x: 400,
3140
+ y: 20,
3141
+ id: "1761194669729223400",
3142
+ fill: "#D7F7D4",
3143
+ stroke: "#47B63D", //warna border
3144
+ strokeWidth: 1,
3145
+ text: "",
3146
+ shape: "square",
3147
+ width: 100,
3148
+ height: 100,
3149
+ gapTags: 20, //gap antara tags secara vertical,
3150
+ labels: [
3151
+ {
3152
+ x: 0,
3153
+ y: 27,
3154
+ label: "New Table 5",
3155
+ fontSize: 12,
3156
+ fontColor: "#0d0c0c",
3157
+ },
3158
+ ],
3159
+ tags: [
3160
+ {
3161
+ key: "table", //key untuk penamaan tag
3162
+ items: [
3163
+ {
3164
+ type: "text", //tipe text atau icon
3165
+ value: "V1", //value untuk text atau icon
3166
+ fontSize: 14,
3167
+ fontWeight: 600,
3168
+ fill: "#3F4254",
3169
+ },
3170
+ {
3171
+ "type": "icon",
3172
+ "value": "chair"
3173
+ }
3174
+ ],
3175
+ direction: "column", // flex untuk horizontal dan column untuk vertikal
3176
+ gap: 5, //gap antara item
3177
+ offsetX: 0, //offset x antara item
3178
+ offsetY: 0, //offset y antara item
3179
+ },
3180
+ {
3181
+ key: "status",
3182
+ items: [
3183
+ {
3184
+ value: "chair",
3185
+ type: "icon",
3186
+ },
3187
+ ],
3188
+ direction: "column",
3189
+ gap: 1,
3190
+ },
3191
+ {
3192
+ key: "pax",
3193
+ items: [
3194
+ {
3195
+ value: "user",
3196
+ type: "icon",
3197
+ },
3198
+ {
3199
+ value: "0/4",
3200
+ type: "text",
3201
+ fontSize: 12,
3202
+ fontWeight: 600,
3203
+ fill: "#3F4254",
3204
+ },
3205
+ ],
3206
+ direction: "flex",
3207
+ gap: 10,
3208
+ offsetX: 0,
3209
+ offsetY: 10,
3210
+ },
3211
+ ],
3212
+ opacity: 1,
3213
+ rotation: 0,
3214
+ seatCount: 0,
3215
+ },
3216
+ },
3217
+ ];
3065
3218
  export const data4 = [
3066
3219
  {
3067
3220
  uuid_table: "axxxxx",
@@ -184,7 +184,7 @@ const TouchScrollDetect = () => {
184
184
  <button className="p-4 bg-gray-400" onClick={() => handleZoomIn()}>+</button>
185
185
  <button className="p-4 bg-gray-400" onClick={() => handleZoomOut()}>-</button>
186
186
  </div>
187
- <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) => {
187
+ <LayerView refs={refLayer} statusKey="status" privilegedTags={["pax", "table"]} defaultBackground="#000000" mappingKey="properties" componentProps={data4} onDrop={(e, data) => handleDrop(e, data)} onSwitch={(e, data) => handleSwitch(e, data)} extraComponentProps={[]} onSelectComponent={(component) => {
188
188
  handleSelectTable(component);
189
189
  }} dragTableBlockKey={[
190
190
  {
@@ -15,6 +15,7 @@ interface LayersProps {
15
15
  onHighlightGroup?: (group: SVGGElement, eventType: EventHandleType) => void;
16
16
  onForceRestoreGroup?: (group: SVGGElement, eventType: EventHandleType) => void;
17
17
  selectedTableColor?: string;
18
+ privilegedTags?: string[];
18
19
  }
19
- declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, }: LayersProps) => import("react").JSX.Element;
20
+ declare const Layers: ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags }: LayersProps) => import("react").JSX.Element;
20
21
  export default Layers;
@@ -1,11 +1,12 @@
1
1
  "use client";
2
2
  import { isEmpty, omit } from "lodash";
3
3
  import { arcByDirection, distributeWithSpacing } from "../layer-v3/utils";
4
- const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, }) => {
4
+ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags }) => {
5
5
  const renderShape = (item) => {
6
6
  var _a, _b, _c, _d, _e, _f;
7
7
  const { id, x, y, width, height, fill, opacity, rotate = 0, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, seatFill, src, tags, gapTags, label, points, seatPositions, radius, } = item;
8
8
  const renderTags = (tags) => {
9
+ var _a;
9
10
  const gapBetweenTags = gapTags || 0;
10
11
  const defaultFontSize = fontSize || 12;
11
12
  // Hitung total tinggi semua grup tag (buat center vertikal)
@@ -21,7 +22,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
21
22
  }, 0)) - gapBetweenTags;
22
23
  const startY = height / 2 - totalTagHeight / 2; // titik awal supaya semua di tengah
23
24
  let currentY = startY;
24
- return tags === null || tags === void 0 ? void 0 : tags.map((tag, tagIndex) => {
25
+ return (_a = tags.filter((tag) => privilegedTags === null || privilegedTags === void 0 ? void 0 : privilegedTags.includes(tag.key))) === null || _a === void 0 ? void 0 : _a.map((tag, tagIndex) => {
25
26
  var _a;
26
27
  const direction = ((_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column")) ? "column" : "flex";
27
28
  const gap = Number(tag.gap) || 2;
@@ -32,7 +33,7 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
32
33
  ? items.length * fontSize + (items.length - 1) * gap
33
34
  : fontSize;
34
35
  const centerX = width / 2;
35
- const centerY = currentY + groupHeight / 2;
36
+ const centerY = currentY + groupHeight;
36
37
  // naikkan posisi Y untuk grup berikutnya
37
38
  currentY += groupHeight + gapBetweenTags;
38
39
  // kumpulkan elemen yang akan dirender (bisa mix text + icon)
@@ -235,20 +236,20 @@ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighli
235
236
  {...omit(item, ["x", "y", "label", "points"])} {...commonProps}/>
236
237
 
237
238
  {renderTags(tags)}
238
- <g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
239
- {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
240
- var _a, _b, _c, _d, _e, _f, _g;
241
- const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
242
- const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
243
- return (<text {...omit(commonProps, [
244
- "opacity",
245
- "stroke",
246
- "strokeWidth",
247
- ])} 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">
248
- {_ === null || _ === void 0 ? void 0 : _.label}
249
- </text>);
250
- })}
251
- </g>
239
+ {!iconTags && (<g transform={`rotate(${-rotation}, ${width / 2}, ${height / 2})`}>
240
+ {labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
241
+ var _a, _b, _c, _d, _e, _f, _g;
242
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
243
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
244
+ return (<text {...omit(commonProps, [
245
+ "opacity",
246
+ "stroke",
247
+ "strokeWidth",
248
+ ])} 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">
249
+ {_ === null || _ === void 0 ? void 0 : _.label}
250
+ </text>);
251
+ })}
252
+ </g>)}
252
253
  </g>
253
254
  </g>);
254
255
  case "polygon":
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useEffect, useState } from "react";
2
+ import { useEffect, useImperativeHandle, useRef, useState } from "react";
3
3
  import Board from "../board-v3";
4
4
  import SideTool from "../side-tool";
5
5
  import ControlPanels from "../panel";
@@ -11,6 +11,15 @@ const TableEditor = (props) => {
11
11
  const { componentProps, extraComponentProps, onCurrentStateChange, dragOnly, mappingKey, viewOnly, deleteAutorized, refs } = props;
12
12
  const { components, extraComponents, backgroundColor } = useAppSelector((state) => state.board);
13
13
  const dispatch = useAppDispatch();
14
+ const refsBoard = useRef(null);
15
+ useImperativeHandle(refs, () => {
16
+ var _a, _b, _c;
17
+ return ({
18
+ svgRef: (_a = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _a === void 0 ? void 0 : _a.svgRef,
19
+ transformRef: (_b = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _b === void 0 ? void 0 : _b.transformRef,
20
+ containerRef: (_c = refsBoard === null || refsBoard === void 0 ? void 0 : refsBoard.current) === null || _c === void 0 ? void 0 : _c.containerRef
21
+ });
22
+ });
14
23
  useEffect(() => {
15
24
  if (!viewOnly) {
16
25
  dispatch({
@@ -105,7 +114,7 @@ const TableEditor = (props) => {
105
114
  display: viewOnly ? "none" : "flex",
106
115
  }}>
107
116
  <SideTool dragOnly={dragOnly} deleteAutorized={deleteAutorized}/>
108
- <Board refs={refs}/>
117
+ <Board refs={refsBoard}/>
109
118
  <ControlPanels action={props.action} responseMapping={props.responseMapping}/>
110
119
  </div>
111
120
  </div>
@@ -47,6 +47,7 @@ export interface LayerViewProps {
47
47
  icon: React.JSX.Element;
48
48
  key: string;
49
49
  }[];
50
+ privilegedTags?: string[];
50
51
  tooltipProps?: {
51
52
  className?: string;
52
53
  style?: CSSProperties;
@@ -5,7 +5,7 @@ import { useAppDispatch, useAppSelector } from "../../hooks/use-redux";
5
5
  import Layers from "../../components/layer-v4";
6
6
  import { getTranslate } from "../board-v3/utils";
7
7
  const LayerView = (props) => {
8
- const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, statusKey, defaultBackground, iconTags, tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, } = props;
8
+ const { componentProps, extraComponentProps, onSelectComponent, onCurrentStateChange, mappingKey, statusKey, defaultBackground, iconTags, tooltipProps, onRightClick, allowTooltip = true, tableMatchKey, eventMatchTable, ghostAttributes, onDrop, onSwitch, refs, privilegedTags } = props;
9
9
  const widthTooltip = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.minWidth) || 168;
10
10
  const tableGhost = useRef(null);
11
11
  const hoverUnderghostId = useRef(null);
@@ -17,7 +17,6 @@ const LayerView = (props) => {
17
17
  y: 0,
18
18
  visible: false,
19
19
  });
20
- console.log("tooltip", tooltip);
21
20
  const isDragging = useRef(false);
22
21
  const [panningGroup, setPanningGroup] = useState(false);
23
22
  const [scale, setScale] = useState(1);
@@ -373,15 +372,12 @@ const LayerView = (props) => {
373
372
  else if (relY === centerY) {
374
373
  newY = relY;
375
374
  }
376
- console.log({ dataGroupEmty, }, e.button);
377
375
  const rightClick = e.button === 2 && !dataGroupEmty && allowTooltip;
378
- console.log({ rightClick });
379
376
  setTooltip({
380
377
  x: newX,
381
378
  y: newY,
382
379
  visible: rightClick,
383
380
  });
384
- // console.log("klik");
385
381
  const findDayaById = originalData({ id: dataId, type: "find" });
386
382
  handleSelectComponent(findDayaById, e);
387
383
  }
@@ -534,7 +530,7 @@ const LayerView = (props) => {
534
530
  <Layers components={[
535
531
  ...extraComponentsEditor,
536
532
  ...renderElements(componentsEditor, mappingKey, tableMatchKey),
537
- ]} selectedTable={selectedTable} iconTags={iconTags} eventMatchTable={eventMatchTable}/>
533
+ ]} selectedTable={selectedTable} iconTags={iconTags} eventMatchTable={eventMatchTable} privilegedTags={privilegedTags}/>
538
534
  </g>
539
535
  {/* 🧠 Ghost universal */}
540
536
  </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.1.10",
3
+ "version": "3.1.12",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",