@msdshsk/react-er-canvas 0.0.1 → 0.0.3

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.
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { a as e, c as t, i as n, n as r, o as i, r as a, s as o, t as s } from "./core-DZ30VgUT.js";
2
- import { Fragment as c, createContext as l, memo as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useState as h } from "react";
3
- import { Background as ee, BaseEdge as g, Controls as _, EdgeLabelRenderer as v, Handle as y, MiniMap as te, Position as b, ReactFlow as ne, getSmoothStepPath as x, useNodesState as S } from "@xyflow/react";
4
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
2
+ import { Fragment as c, createContext as l, forwardRef as u, memo as d, useCallback as f, useContext as p, useEffect as m, useImperativeHandle as h, useMemo as g, useRef as _, useState as v } from "react";
3
+ import { Background as y, BaseEdge as b, Controls as ee, EdgeLabelRenderer as x, Handle as S, MiniMap as te, Position as C, ReactFlow as ne, getSmoothStepPath as w, useNodesState as re, useReactFlow as T } from "@xyflow/react";
4
+ import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
5
5
  //#region src/components/TableNode.tsx
6
- var E = l(/* @__PURE__ */ new Map()), D = l({
6
+ var k = l(/* @__PURE__ */ new Map()), A = l({
7
7
  enabled: !1,
8
+ showSelectAll: !1,
8
9
  selected: /* @__PURE__ */ new Set(),
9
- onToggle: () => void 0
10
- }), O = l(!1), k = l({}), A = {
10
+ onToggle: () => void 0,
11
+ onToggleAll: () => void 0
12
+ }), ie = l(!1), j = l({}), M = {
11
13
  pk: {
12
14
  label: "PK",
13
15
  bg: "#f59e0b"
@@ -21,9 +23,9 @@ var E = l(/* @__PURE__ */ new Map()), D = l({
21
23
  bg: "#10b981"
22
24
  }
23
25
  };
24
- function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabled: i, selected: a, onSelectToggle: o }) {
26
+ function N({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabled: i, selected: a, onSelectToggle: o }) {
25
27
  let s = [];
26
- return t.keys.pk && s.push(A.pk), t.keys.fk && s.push(A.fk), t.keys.uk && s.push(A.uk), /* @__PURE__ */ T("div", {
28
+ return t.keys.pk && s.push(M.pk), t.keys.fk && s.push(M.fk), t.keys.uk && s.push(M.uk), /* @__PURE__ */ O("div", {
27
29
  title: t.comment,
28
30
  onClick: r ? () => r(e, t.name) : void 0,
29
31
  style: {
@@ -41,7 +43,7 @@ function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabl
41
43
  transition: "background 0.15s"
42
44
  },
43
45
  children: [
44
- i && /* @__PURE__ */ w("input", {
46
+ i && /* @__PURE__ */ D("input", {
45
47
  type: "checkbox",
46
48
  checked: a,
47
49
  onChange: (e) => o(e.target.checked),
@@ -54,14 +56,14 @@ function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabl
54
56
  cursor: "pointer"
55
57
  }
56
58
  }),
57
- /* @__PURE__ */ w("span", {
59
+ /* @__PURE__ */ D("span", {
58
60
  style: {
59
61
  display: "flex",
60
62
  gap: 2,
61
63
  flexShrink: 0,
62
64
  minWidth: 18
63
65
  },
64
- children: s.map((e) => /* @__PURE__ */ w("span", {
66
+ children: s.map((e) => /* @__PURE__ */ D("span", {
65
67
  style: {
66
68
  display: "inline-block",
67
69
  padding: "0 4px",
@@ -75,7 +77,7 @@ function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabl
75
77
  children: e.label
76
78
  }, e.label))
77
79
  }),
78
- /* @__PURE__ */ w("span", {
80
+ /* @__PURE__ */ D("span", {
79
81
  style: {
80
82
  flexShrink: 0,
81
83
  fontWeight: t.keys.pk ? 600 : 400,
@@ -83,7 +85,7 @@ function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabl
83
85
  },
84
86
  children: t.name
85
87
  }),
86
- t.type && /* @__PURE__ */ w("span", {
88
+ t.type && /* @__PURE__ */ D("span", {
87
89
  style: {
88
90
  flex: 1,
89
91
  textAlign: "right",
@@ -98,8 +100,22 @@ function j({ tableName: e, column: t, highlighted: n, onClick: r, selectionEnabl
98
100
  ]
99
101
  });
100
102
  }
101
- var M = u(function({ data: e }) {
102
- let { table: t } = e, n = f(E), r = f(D), i = f(O), a = f(k), o = a.onColumnClick, s = n.get(t.name), l = t.group ? "#1e40af" : "#374151", u = (e) => ({
103
+ var ae = d(function({ data: e }) {
104
+ let { table: t } = e, n = p(k), r = p(A), i = p(ie), a = p(j), o = a.onColumnClick, s = n.get(t.name), l = t.group ? "#1e40af" : "#374151", u = r.enabled && r.showSelectAll && t.columns.length > 0, d = g(() => t.columns.map((e) => e.name), [t.columns]), f = g(() => {
105
+ if (!u) return 0;
106
+ let e = 0;
107
+ for (let n of d) r.selected.has(`${t.name}.${n}`) && e++;
108
+ return e;
109
+ }, [
110
+ u,
111
+ d,
112
+ r.selected,
113
+ t.name
114
+ ]), h = u && f === d.length, v = u && f > 0 && f < d.length, y = _(null);
115
+ m(() => {
116
+ y.current && (y.current.indeterminate = v);
117
+ }, [v]);
118
+ let b = (e) => ({
103
119
  ...e,
104
120
  width: i ? 9 : 6,
105
121
  height: i ? 9 : 6,
@@ -110,7 +126,7 @@ var M = u(function({ data: e }) {
110
126
  pointerEvents: i ? "auto" : "none",
111
127
  cursor: i ? "crosshair" : "default"
112
128
  });
113
- return /* @__PURE__ */ T("div", {
129
+ return /* @__PURE__ */ O("div", {
114
130
  style: {
115
131
  background: "#fff",
116
132
  border: "1px solid #c4c4c4",
@@ -124,19 +140,19 @@ var M = u(function({ data: e }) {
124
140
  position: "relative"
125
141
  },
126
142
  children: [
127
- /* @__PURE__ */ w(y, {
143
+ /* @__PURE__ */ D(S, {
128
144
  id: "__default-target",
129
145
  type: "target",
130
- position: b.Left,
131
- style: u({ top: 32 / 2 })
146
+ position: C.Left,
147
+ style: b({ top: 32 / 2 })
132
148
  }),
133
- /* @__PURE__ */ w(y, {
149
+ /* @__PURE__ */ D(S, {
134
150
  id: "__default-source",
135
151
  type: "source",
136
- position: b.Right,
137
- style: u({ top: 32 / 2 })
152
+ position: C.Right,
153
+ style: b({ top: 32 / 2 })
138
154
  }),
139
- /* @__PURE__ */ T("div", {
155
+ /* @__PURE__ */ O("div", {
140
156
  style: {
141
157
  padding: "6px 10px",
142
158
  background: l,
@@ -152,21 +168,47 @@ var M = u(function({ data: e }) {
152
168
  borderTopLeftRadius: 6,
153
169
  borderTopRightRadius: 6
154
170
  },
155
- children: [/* @__PURE__ */ w("span", {
171
+ children: [/* @__PURE__ */ O("span", {
156
172
  style: {
173
+ display: "flex",
174
+ alignItems: "center",
175
+ gap: 6,
157
176
  overflow: "hidden",
158
- textOverflow: "ellipsis",
159
- whiteSpace: "nowrap"
177
+ minWidth: 0
160
178
  },
161
- children: t.name
162
- }), /* @__PURE__ */ T("span", {
179
+ children: [u && /* @__PURE__ */ D("input", {
180
+ ref: y,
181
+ type: "checkbox",
182
+ className: "nodrag",
183
+ checked: h,
184
+ onChange: (e) => r.onToggleAll(t.name, d, e.target.checked),
185
+ onClick: (e) => e.stopPropagation(),
186
+ onMouseDown: (e) => e.stopPropagation(),
187
+ title: h ? "Deselect all columns" : v ? "Some columns selected — click to select all" : "Select all columns",
188
+ style: {
189
+ width: 13,
190
+ height: 13,
191
+ margin: 0,
192
+ flexShrink: 0,
193
+ cursor: "pointer",
194
+ accentColor: "#3b82f6"
195
+ }
196
+ }), /* @__PURE__ */ D("span", {
197
+ style: {
198
+ overflow: "hidden",
199
+ textOverflow: "ellipsis",
200
+ whiteSpace: "nowrap"
201
+ },
202
+ children: t.name
203
+ })]
204
+ }), /* @__PURE__ */ O("span", {
163
205
  style: {
164
206
  display: "flex",
165
207
  alignItems: "center",
166
208
  gap: 4,
167
209
  flexShrink: 0
168
210
  },
169
- children: [t.group && /* @__PURE__ */ w("span", {
211
+ children: [t.group && /* @__PURE__ */ D("span", {
170
212
  style: {
171
213
  fontSize: 10,
172
214
  opacity: .75,
@@ -176,10 +218,10 @@ var M = u(function({ data: e }) {
176
218
  borderRadius: 3
177
219
  },
178
220
  children: t.group
179
- }), a.onTableRemove && /* @__PURE__ */ w("button", {
221
+ }), a.onTableRemove && /* @__PURE__ */ D("button", {
180
222
  className: "nodrag",
181
223
  onClick: (e) => {
182
- e.stopPropagation(), a.onTableRemove?.(t.name);
224
+ e.stopPropagation(), a.onTableRemove?.(t.name, t.meta);
183
225
  },
184
226
  onMouseDown: (e) => e.stopPropagation(),
185
227
  title: "Remove this table",
@@ -204,35 +246,35 @@ var M = u(function({ data: e }) {
204
246
  })]
205
247
  }),
206
248
  t.columns.map((e, n) => {
207
- let i = 32 + n * 22 + 22 / 2, a = s?.has(e.name) ?? !1, l = `${t.name}.${e.name}`, d = r.enabled && r.selected.has(l);
208
- return /* @__PURE__ */ T(c, { children: [
209
- /* @__PURE__ */ w(y, {
249
+ let i = 32 + n * 22 + 22 / 2, a = s?.has(e.name) ?? !1, l = `${t.name}.${e.name}`, u = r.enabled && r.selected.has(l);
250
+ return /* @__PURE__ */ O(c, { children: [
251
+ /* @__PURE__ */ D(S, {
210
252
  id: `${e.name}__target`,
211
253
  type: "target",
212
- position: b.Left,
213
- style: u({ top: i })
254
+ position: C.Left,
255
+ style: b({ top: i })
214
256
  }),
215
- /* @__PURE__ */ w(y, {
257
+ /* @__PURE__ */ D(S, {
216
258
  id: `${e.name}__source`,
217
259
  type: "source",
218
- position: b.Right,
219
- style: u({ top: i })
260
+ position: C.Right,
261
+ style: b({ top: i })
220
262
  }),
221
- /* @__PURE__ */ w(j, {
263
+ /* @__PURE__ */ D(N, {
222
264
  tableName: t.name,
223
265
  column: e,
224
266
  highlighted: a,
225
267
  onClick: o,
226
268
  selectionEnabled: r.enabled,
227
- selected: d,
269
+ selected: u,
228
270
  onSelectToggle: (n) => r.onToggle(t.name, e.name, n)
229
271
  })
230
272
  ] }, `${e.name}-${n}`);
231
273
  })
232
274
  ]
233
275
  });
234
- }), N = u(function({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, data: s, selected: c }) {
235
- let [l, u, d] = x({
276
+ }), P = d(function({ id: e, sourceX: t, sourceY: n, targetX: r, targetY: i, sourcePosition: a, targetPosition: o, data: s, selected: c }) {
277
+ let [l, u, d] = w({
236
278
  sourceX: t,
237
279
  sourceY: n,
238
280
  sourcePosition: a,
@@ -240,15 +282,15 @@ var M = u(function({ data: e }) {
240
282
  targetY: i,
241
283
  targetPosition: o
242
284
  }), f = s ?? {}, p = !!c || !!f.hovered, m = f.color || "#3b82f6";
243
- return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(g, {
285
+ return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(b, {
244
286
  id: e,
245
287
  path: l,
246
288
  style: {
247
289
  stroke: m,
248
- strokeWidth: p ? 2.5 : 2,
249
- strokeDasharray: "6 3"
290
+ strokeWidth: f.strokeWidth ?? (p ? 2.5 : 2),
291
+ strokeDasharray: f.strokeDasharray ?? "6 3"
250
292
  }
251
- }), /* @__PURE__ */ w(v, { children: /* @__PURE__ */ T("div", {
293
+ }), /* @__PURE__ */ D(x, { children: /* @__PURE__ */ O("div", {
252
294
  className: "nodrag nopan",
253
295
  style: {
254
296
  position: "absolute",
@@ -267,7 +309,7 @@ var M = u(function({ data: e }) {
267
309
  boxShadow: p ? "0 0 0 2px rgba(0,0,0,0.4)" : "0 1px 2px rgba(0,0,0,0.15)",
268
310
  userSelect: "none"
269
311
  },
270
- children: [/* @__PURE__ */ w("span", { children: f.type }), f.onDelete && /* @__PURE__ */ w("button", {
312
+ children: [/* @__PURE__ */ D("span", { children: f.type }), f.onDelete && /* @__PURE__ */ D("button", {
271
313
  type: "button",
272
314
  onClick: (e) => {
273
315
  e.stopPropagation(), f.onDelete?.();
@@ -293,8 +335,8 @@ var M = u(function({ data: e }) {
293
335
  children: "×"
294
336
  })]
295
337
  }) })] });
296
- }), P = { table: M }, re = { joinEdge: N };
297
- function ie(e) {
338
+ }), oe = { table: ae }, se = { joinEdge: P };
339
+ function ce(e) {
298
340
  try {
299
341
  return {
300
342
  model: t(e),
@@ -320,49 +362,60 @@ function L(e) {
320
362
  function R(e) {
321
363
  return `${e.table}.${e.column}`;
322
364
  }
323
- var ae = {
365
+ var le = {
324
366
  INNER: "#3b82f6",
325
367
  LEFT: "#8b5cf6",
326
368
  RIGHT: "#a855f7",
327
369
  FULL: "#ec4899",
328
370
  CROSS: "#6b7280"
329
371
  };
330
- function z(e) {
331
- let { source: t, model: n, algorithm: r, direction: a, aspectRatio: o, positions: s, onPositionsChange: c, showColumnCheckboxes: l, selectedColumns: u, onColumnSelectionChange: f, enableManualJoins: g, joins: v, onJoinConnect: y, onJoinDelete: b, onTableRemove: x, onColumnClick: C, onTableClick: A, deleteKeyCode: j = "Delete", className: M, style: N, highlightReferencesOnHover: z = !0 } = e, { model: B, error: V } = m(() => n ? {
332
- model: n,
372
+ function ue({ apiRef: e, wrapperRef: t }) {
373
+ let n = T();
374
+ return h(e, () => ({
375
+ fitView: (e) => n.fitView(e),
376
+ getViewport: () => n.getViewport(),
377
+ setViewport: (e) => n.setViewport(e),
378
+ getNodesBounds: () => n.getNodesBounds(n.getNodes()),
379
+ getWrapperElement: () => t.current,
380
+ getViewportElement: () => t.current?.querySelector(".react-flow__viewport") ?? null
381
+ }), [n, t]), null;
382
+ }
383
+ var z = u(function(e, t) {
384
+ let { source: n, model: r, algorithm: a, direction: o, aspectRatio: s, positions: c, onPositionsChange: l, showColumnCheckboxes: u, selectedColumns: d, onColumnSelectionChange: p, enableManualJoins: h, joins: b, onJoinConnect: x, onJoinDelete: S, onJoinClick: C, joinStyle: w, onTableRemove: T, onColumnClick: E, onTableClick: M, showSelectAllPerTable: N, deleteKeyCode: ae = "Delete", className: P, style: z, highlightReferencesOnHover: B = !0 } = e, { model: V, error: H } = g(() => r ? {
385
+ model: r,
333
386
  error: null
334
- } : t == null ? {
387
+ } : n == null ? {
335
388
  model: null,
336
389
  error: null
337
- } : ie(t), [t, n]), [H, U] = h(null), [W, G] = h(null);
338
- p(() => {
339
- if (!B) {
340
- U(null);
390
+ } : ce(n), [n, r]), [U, W] = v(null), [G, K] = v(null);
391
+ m(() => {
392
+ if (!V) {
393
+ W(null);
341
394
  return;
342
395
  }
343
396
  let e = !1;
344
- return i(B, {
345
- algorithm: r,
346
- direction: a,
347
- aspectRatio: o
397
+ return i(V, {
398
+ algorithm: a,
399
+ direction: o,
400
+ aspectRatio: s
348
401
  }).then((t) => {
349
- e || U(t);
402
+ e || W(t);
350
403
  }), () => {
351
404
  e = !0;
352
405
  };
353
406
  }, [
354
- B,
355
- r,
407
+ V,
356
408
  a,
357
- o
409
+ o,
410
+ s
358
411
  ]);
359
- let K = m(() => {
360
- if (!H || !B) return [];
361
- let e = new Map(B.tables.map((e) => [e.name, e])), t = [];
362
- for (let n of H.nodes) {
412
+ let q = g(() => {
413
+ if (!U || !V) return [];
414
+ let e = new Map(V.tables.map((e) => [e.name, e])), t = [];
415
+ for (let n of U.nodes) {
363
416
  let r = e.get(n.id);
364
417
  if (!r) continue;
365
- let i = s?.[n.id], a = { table: r };
418
+ let i = c?.[n.id], a = { table: r };
366
419
  t.push({
367
420
  id: n.id,
368
421
  type: "table",
@@ -379,30 +432,30 @@ function z(e) {
379
432
  }
380
433
  return t;
381
434
  }, [
382
- H,
383
- B,
384
- s
385
- ]), [q, J, oe] = S(K);
386
- p(() => {
387
- J(K);
388
- }, [K, J]);
389
- let se = d((e, t, n) => {
390
- if (!c) return;
391
- let r = { ...s ?? {} };
435
+ U,
436
+ V,
437
+ c
438
+ ]), [de, J, fe] = re(q);
439
+ m(() => {
440
+ J(q);
441
+ }, [q, J]);
442
+ let pe = f((e, t, n) => {
443
+ if (!l) return;
444
+ let r = { ...c ?? {} };
392
445
  for (let e of n) r[e.id] = {
393
446
  x: e.position.x,
394
447
  y: e.position.y
395
448
  };
396
- c(r);
397
- }, [s, c]), Y = m(() => {
398
- if (!(!W || !B)) return B.relations.find((e) => e.id === W);
399
- }, [W, B]), X = m(() => {
400
- if (!W || !v || !W.startsWith(I)) return;
401
- let e = W.slice(5);
402
- return v.find((t) => t.id === e);
403
- }, [W, v]), ce = m(() => {
449
+ l(r);
450
+ }, [c, l]), Y = g(() => {
451
+ if (!(!G || !V)) return V.relations.find((e) => e.id === G);
452
+ }, [G, V]), X = g(() => {
453
+ if (!G || !b || !G.startsWith(I)) return;
454
+ let e = G.slice(5);
455
+ return b.find((t) => t.id === e);
456
+ }, [G, b]), me = g(() => {
404
457
  let e = /* @__PURE__ */ new Map();
405
- if (!z) return e;
458
+ if (!B) return e;
406
459
  let t = (t, n) => {
407
460
  if (!n) return;
408
461
  let r = e.get(t) ?? /* @__PURE__ */ new Set();
@@ -412,31 +465,50 @@ function z(e) {
412
465
  }, [
413
466
  Y,
414
467
  X,
415
- z
416
- ]), Z = m(() => new Set((u ?? []).map(R)), [u]), Q = d((e, t, n) => {
417
- if (!f) return;
418
- let r = u ?? [];
468
+ B
469
+ ]), Z = g(() => new Set((d ?? []).map(R)), [d]), Q = f((e, t, n) => {
470
+ if (!p) return;
471
+ let r = d ?? [];
419
472
  if (n) {
420
473
  if (r.some((n) => n.table === e && n.column === t)) return;
421
- f([...r, {
474
+ p([...r, {
422
475
  table: e,
423
476
  column: t
424
477
  }]);
425
- } else f(r.filter((n) => !(n.table === e && n.column === t)));
426
- }, [u, f]), le = m(() => ({
427
- enabled: l ?? !1,
478
+ } else p(r.filter((n) => !(n.table === e && n.column === t)));
479
+ }, [d, p]), he = f((e, t, n) => {
480
+ if (!p) return;
481
+ let r = d ?? [];
482
+ if (n) {
483
+ let n = new Set(r.map(R)), i = [];
484
+ for (let r of t) n.has(`${e}.${r}`) || i.push({
485
+ table: e,
486
+ column: r
487
+ });
488
+ if (i.length === 0) return;
489
+ p([...r, ...i]);
490
+ } else {
491
+ let n = new Set(t);
492
+ p(r.filter((t) => !(t.table === e && n.has(t.column))));
493
+ }
494
+ }, [d, p]), ge = g(() => ({
495
+ enabled: u ?? !1,
496
+ showSelectAll: N ?? !1,
428
497
  selected: Z,
429
- onToggle: Q
498
+ onToggle: Q,
499
+ onToggleAll: he
430
500
  }), [
431
- l,
501
+ u,
502
+ N,
432
503
  Z,
433
- Q
434
- ]), ue = m(() => {
435
- if (!H || !B) return [];
436
- let e = new Set(B.tables.map((e) => e.name)), t = new Map(B.relations.map((e) => [e.id, e])), n = [];
437
- for (let r of H.edges) {
504
+ Q,
505
+ he
506
+ ]), _e = g(() => {
507
+ if (!U || !V) return [];
508
+ let e = new Set(V.tables.map((e) => e.name)), t = new Map(V.relations.map((e) => [e.id, e])), n = [];
509
+ for (let r of U.edges) {
438
510
  if (!e.has(r.source) || !e.has(r.target)) continue;
439
- let i = t.get(r.id), a = r.id === W;
511
+ let i = t.get(r.id), a = r.id === G;
440
512
  n.push({
441
513
  id: r.id,
442
514
  source: r.source,
@@ -464,13 +536,15 @@ function z(e) {
464
536
  });
465
537
  }
466
538
  let r = [];
467
- for (let t of v ?? []) {
539
+ for (let t of b ?? []) {
468
540
  if (!e.has(t.source.table) || !e.has(t.target.table)) continue;
469
- let n = `${I}${t.id}`, i = n === W, a = ae[t.type] ?? "#3b82f6", o = {
541
+ let n = `${I}${t.id}`, i = n === G, a = w?.(t), o = a?.stroke ?? le[t.type] ?? "#3b82f6", s = {
470
542
  type: t.type,
471
- color: a,
543
+ color: o,
544
+ strokeWidth: a?.strokeWidth,
545
+ strokeDasharray: a?.strokeDasharray,
472
546
  hovered: i,
473
- onDelete: b ? () => b(t.id) : void 0
547
+ onDelete: S ? () => S(t.id, t.meta) : void 0
474
548
  };
475
549
  r.push({
476
550
  id: n,
@@ -480,40 +554,50 @@ function z(e) {
480
554
  targetHandle: F("target", t.target.column),
481
555
  type: "joinEdge",
482
556
  deletable: !0,
483
- data: o
557
+ data: s
484
558
  });
485
559
  }
486
560
  return [...n, ...r];
487
561
  }, [
488
- H,
489
- B,
490
- v,
491
- W,
492
- b
493
- ]), de = d((e) => {
494
- y && (!e.source || !e.target || y({
562
+ U,
563
+ V,
564
+ b,
565
+ G,
566
+ S,
567
+ w
568
+ ]), ve = f((e) => {
569
+ x && (!e.source || !e.target || x({
495
570
  table: e.source,
496
571
  column: L(e.sourceHandle)
497
572
  }, {
498
573
  table: e.target,
499
574
  column: L(e.targetHandle)
500
575
  }));
501
- }, [y]), fe = d((e) => {
502
- if (b) for (let t of e) t.id.startsWith(I) && b(t.id.slice(5));
503
- }, [b]), $ = !!g, pe = m(() => ({
504
- onTableRemove: x,
505
- onColumnClick: C
506
- }), [x, C]);
507
- return /* @__PURE__ */ T("div", {
508
- className: M,
576
+ }, [x]), ye = f((e) => {
577
+ if (S) for (let t of e) {
578
+ if (!t.id.startsWith(I)) continue;
579
+ let e = t.id.slice(5), n = b?.find((t) => t.id === e);
580
+ S(e, n?.meta);
581
+ }
582
+ }, [S, b]), be = f((e, t) => {
583
+ if (!C || !t.id.startsWith(I)) return;
584
+ let n = t.id.slice(5), r = b?.find((e) => e.id === n);
585
+ C(n, r?.meta);
586
+ }, [C, b]), xe = !!h, Se = g(() => ({
587
+ onTableRemove: T,
588
+ onColumnClick: E
589
+ }), [T, E]), $ = _(null);
590
+ return /* @__PURE__ */ O("div", {
591
+ ref: $,
592
+ className: P,
509
593
  style: {
510
594
  width: "100%",
511
595
  height: "100%",
512
596
  position: "relative",
513
- ...N
597
+ ...z
514
598
  },
515
599
  children: [
516
- V && /* @__PURE__ */ w("div", {
600
+ H && /* @__PURE__ */ D("div", {
517
601
  style: {
518
602
  position: "absolute",
519
603
  top: 8,
@@ -529,9 +613,9 @@ function z(e) {
529
613
  fontSize: 12,
530
614
  whiteSpace: "pre-wrap"
531
615
  },
532
- children: V.message
616
+ children: H.message
533
617
  }),
534
- !V && !H && /* @__PURE__ */ w("div", {
618
+ !H && !U && /* @__PURE__ */ D("div", {
535
619
  style: {
536
620
  position: "absolute",
537
621
  inset: 0,
@@ -543,39 +627,47 @@ function z(e) {
543
627
  },
544
628
  children: "Computing layout…"
545
629
  }),
546
- /* @__PURE__ */ w(E.Provider, {
547
- value: ce,
548
- children: /* @__PURE__ */ w(D.Provider, {
549
- value: le,
550
- children: /* @__PURE__ */ w(O.Provider, {
551
- value: $,
552
- children: /* @__PURE__ */ w(k.Provider, {
553
- value: pe,
554
- children: /* @__PURE__ */ T(ne, {
555
- nodes: q,
556
- edges: ue,
557
- nodeTypes: P,
558
- edgeTypes: re,
630
+ /* @__PURE__ */ D(k.Provider, {
631
+ value: me,
632
+ children: /* @__PURE__ */ D(A.Provider, {
633
+ value: ge,
634
+ children: /* @__PURE__ */ D(ie.Provider, {
635
+ value: xe,
636
+ children: /* @__PURE__ */ D(j.Provider, {
637
+ value: Se,
638
+ children: /* @__PURE__ */ O(ne, {
639
+ nodes: de,
640
+ edges: _e,
641
+ nodeTypes: oe,
642
+ edgeTypes: se,
559
643
  fitView: !0,
560
- onNodesChange: oe,
561
- onNodeDragStop: se,
562
- onNodeClick: A ? (e, t) => A(t.id) : void 0,
563
- onEdgeMouseEnter: (e, t) => G(t.id),
564
- onEdgeMouseLeave: () => G(null),
565
- onConnect: de,
566
- onEdgesDelete: fe,
644
+ onNodesChange: fe,
645
+ onNodeDragStop: pe,
646
+ onNodeClick: M ? (e, t) => {
647
+ let n = t.data?.table?.meta;
648
+ M(t.id, n);
649
+ } : void 0,
650
+ onEdgeMouseEnter: (e, t) => K(t.id),
651
+ onEdgeMouseLeave: () => K(null),
652
+ onEdgeClick: C ? be : void 0,
653
+ onConnect: ve,
654
+ onEdgesDelete: ye,
567
655
  nodesDraggable: !0,
568
- nodesConnectable: $,
656
+ nodesConnectable: xe,
569
657
  elementsSelectable: !0,
570
- deleteKeyCode: j,
658
+ deleteKeyCode: ae,
571
659
  minZoom: .1,
572
660
  maxZoom: 4,
573
661
  children: [
574
- /* @__PURE__ */ w(ee, {}),
575
- /* @__PURE__ */ w(_, {}),
576
- /* @__PURE__ */ w(te, {
662
+ /* @__PURE__ */ D(y, {}),
663
+ /* @__PURE__ */ D(ee, {}),
664
+ /* @__PURE__ */ D(te, {
577
665
  pannable: !0,
578
666
  zoomable: !0
667
+ }),
668
+ /* @__PURE__ */ D(ue, {
669
+ apiRef: t,
670
+ wrapperRef: $
579
671
  })
580
672
  ]
581
673
  })
@@ -585,7 +677,7 @@ function z(e) {
585
677
  })
586
678
  ]
587
679
  });
588
- }
680
+ });
589
681
  //#endregion
590
682
  export { s as HEADER_HEIGHT, z as MermaidER, o as MermaidERParseError, r as NODE_WIDTH, a as ROW_HEIGHT, n as VERTICAL_PADDING, e as estimateNodeHeight, i as layoutER, t as parseMermaidER };
591
683