seat-editor 3.6.41 → 3.6.42

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.
@@ -162,33 +162,23 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
162
162
  }, [deleteSelectedEdge, cancelConnect, cancelDragAnchor, clearSelection]);
163
163
  // ── onEdgesChange ────────────────────────────────────────────────
164
164
  const onUpdateEdges = () => {
165
- const sourceToTargets = new Map();
166
- edges.forEach((e) => {
167
- if (!sourceToTargets.has(e.from))
168
- sourceToTargets.set(e.from, []);
169
- sourceToTargets.get(e.from).push(e.to);
170
- });
171
165
  onEdgesChange === null || onEdgesChange === void 0 ? void 0 : onEdgesChange(edges);
172
166
  };
173
167
  const hasInitialEdges = useRef(false);
174
- // 1. useEffect Inisialisasi: Jalankan HANYA jika belum diinisialisasi
168
+ const prevInitialEdgesRef = useRef(initialEdges);
175
169
  useEffect(() => {
176
- // Jika sudah pernah inisialisasi atau data belum siap, jangan jalankan lagi
177
- // if (hasInitialEdges.current || !initialEdges?.length || !components) return;
178
170
  const allElements = components === null || components === void 0 ? void 0 : components.map((table) => {
179
171
  if (mappingKey && (table === null || table === void 0 ? void 0 : table[mappingKey])) {
180
172
  return Object.assign({}, table === null || table === void 0 ? void 0 : table[mappingKey]);
181
173
  }
182
174
  return Object.assign({}, table);
183
175
  });
184
- console.log("allElements", allElements, components);
185
176
  const transformAllEdges = initialEdges === null || initialEdges === void 0 ? void 0 : initialEdges.map((edge) => {
186
177
  var _a, _b;
187
178
  const fromElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => { var _a; return ((_a = el === null || el === void 0 ? void 0 : el[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _a !== void 0 ? _a : el.id) === edge.from; });
188
- console.log("fromElement", fromElement);
189
179
  if (!fromElement)
190
180
  return null;
191
- const { x: fromX, y: fromY, rotation: fromRotation, width: fromWidth, height: fromHeight } = fromElement;
181
+ const { x: fromX, y: fromY, rotation: fromRotation, width: fromWidth, height: fromHeight, } = fromElement;
192
182
  const fromRotated = rotatePoint(fromWidth / 2, fromHeight / 2, fromRotation !== null && fromRotation !== void 0 ? fromRotation : 0);
193
183
  const fromCx = fromX + fromRotated.x;
194
184
  const fromCy = fromY + fromRotated.y;
@@ -220,7 +210,7 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
220
210
  const toElement = allElements === null || allElements === void 0 ? void 0 : allElements.find((el) => { var _a; return ((_a = el === null || el === void 0 ? void 0 : el[groupSelection === null || groupSelection === void 0 ? void 0 : groupSelection.dataKey]) !== null && _a !== void 0 ? _a : el.id) === edge.to; });
221
211
  if (!toElement)
222
212
  return null;
223
- const { x: toX, y: toY, rotation: toRotation, width: toWidth, height: toHeight } = toElement;
213
+ const { x: toX, y: toY, rotation: toRotation, width: toWidth, height: toHeight, } = toElement;
224
214
  const toRotated = rotatePoint(toWidth / 2, toHeight / 2, toRotation !== null && toRotation !== void 0 ? toRotation : 0);
225
215
  const toCx = toX + toRotated.x;
226
216
  const toCy = toY + toRotated.y;
@@ -253,18 +243,18 @@ export const useConnectionGraph = ({ svgRef, onEdgesChange, keyNode, mappingKey,
253
243
  toPos });
254
244
  });
255
245
  const filteredEdges = transformAllEdges === null || transformAllEdges === void 0 ? void 0 : transformAllEdges.filter((el) => el !== null);
256
- // Tandai bahwa inisialisasi sukses sebelum setEdges agar useEffect kedua tidak kaget
257
246
  hasInitialEdges.current = true;
258
- console.log("filteredEdges", filteredEdges, transformAllEdges);
247
+ prevInitialEdgesRef.current = initialEdges; // simpan referensi initialEdges yang dipakai
259
248
  setEdges(filteredEdges);
260
- }, [initialEdges, components, groupSelection, mappingKey]); // Hapus 'edges' dari sini
261
- // 2. useEffect Trigger Perubahan: Hanya kirim ke parent jika user memicu perubahan baru
249
+ }, [initialEdges, components, groupSelection, mappingKey]);
262
250
  useEffect(() => {
263
- // Hanya panggil onUpdateEdges jika inisialisasi awal sudah selesai
264
- // DAN data edges saat ini memang berbeda dari initialEdges bawaan parent
265
- if (hasInitialEdges.current && !isEqual(edges, initialEdges)) {
266
- onUpdateEdges === null || onUpdateEdges === void 0 ? void 0 : onUpdateEdges();
267
- }
251
+ // Skip kalau belum ada inisialisasi awal
252
+ if (!hasInitialEdges.current)
253
+ return;
254
+ // Skip kalau edges berubah karena useEffect pertama (bukan aksi user)
255
+ if (isEqual(edges, prevInitialEdgesRef.current))
256
+ return;
257
+ onUpdateEdges === null || onUpdateEdges === void 0 ? void 0 : onUpdateEdges();
268
258
  }, [edges]);
269
259
  return {
270
260
  edges,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seat-editor",
3
- "version": "3.6.41",
3
+ "version": "3.6.42",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",