@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/components/JoinEdge.d.ts +4 -0
- package/dist/components/JoinEdge.d.ts.map +1 -1
- package/dist/components/MermaidER.d.ts +59 -6
- package/dist/components/MermaidER.d.ts.map +1 -1
- package/dist/components/TableNode.d.ts +4 -1
- package/dist/components/TableNode.d.ts.map +1 -1
- package/dist/core/model.d.ts +13 -0
- package/dist/core/model.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +249 -157
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,
|
|
3
|
-
import { Background as
|
|
4
|
-
import { Fragment as
|
|
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
|
|
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
|
-
|
|
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
|
|
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(
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
|
102
|
-
let { table: t } = e, n =
|
|
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__ */
|
|
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__ */
|
|
143
|
+
/* @__PURE__ */ D(S, {
|
|
128
144
|
id: "__default-target",
|
|
129
145
|
type: "target",
|
|
130
|
-
position:
|
|
131
|
-
style:
|
|
146
|
+
position: C.Left,
|
|
147
|
+
style: b({ top: 32 / 2 })
|
|
132
148
|
}),
|
|
133
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ D(S, {
|
|
134
150
|
id: "__default-source",
|
|
135
151
|
type: "source",
|
|
136
|
-
position:
|
|
137
|
-
style:
|
|
152
|
+
position: C.Right,
|
|
153
|
+
style: b({ top: 32 / 2 })
|
|
138
154
|
}),
|
|
139
|
-
/* @__PURE__ */
|
|
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__ */
|
|
171
|
+
children: [/* @__PURE__ */ O("span", {
|
|
156
172
|
style: {
|
|
173
|
+
display: "flex",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
gap: 6,
|
|
157
176
|
overflow: "hidden",
|
|
158
|
-
|
|
159
|
-
whiteSpace: "nowrap"
|
|
177
|
+
minWidth: 0
|
|
160
178
|
},
|
|
161
|
-
children:
|
|
162
|
-
|
|
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__ */
|
|
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__ */
|
|
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}`,
|
|
208
|
-
return /* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
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:
|
|
213
|
-
style:
|
|
254
|
+
position: C.Left,
|
|
255
|
+
style: b({ top: i })
|
|
214
256
|
}),
|
|
215
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ D(S, {
|
|
216
258
|
id: `${e.name}__source`,
|
|
217
259
|
type: "source",
|
|
218
|
-
position:
|
|
219
|
-
style:
|
|
260
|
+
position: C.Right,
|
|
261
|
+
style: b({ top: i })
|
|
220
262
|
}),
|
|
221
|
-
/* @__PURE__ */
|
|
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:
|
|
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
|
-
}),
|
|
235
|
-
let [l, u, d] =
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
-
}),
|
|
297
|
-
function
|
|
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
|
|
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
|
|
331
|
-
let
|
|
332
|
-
|
|
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
|
-
} :
|
|
387
|
+
} : n == null ? {
|
|
335
388
|
model: null,
|
|
336
389
|
error: null
|
|
337
|
-
} :
|
|
338
|
-
|
|
339
|
-
if (!
|
|
340
|
-
|
|
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(
|
|
345
|
-
algorithm:
|
|
346
|
-
direction:
|
|
347
|
-
aspectRatio:
|
|
397
|
+
return i(V, {
|
|
398
|
+
algorithm: a,
|
|
399
|
+
direction: o,
|
|
400
|
+
aspectRatio: s
|
|
348
401
|
}).then((t) => {
|
|
349
|
-
e ||
|
|
402
|
+
e || W(t);
|
|
350
403
|
}), () => {
|
|
351
404
|
e = !0;
|
|
352
405
|
};
|
|
353
406
|
}, [
|
|
354
|
-
|
|
355
|
-
r,
|
|
407
|
+
V,
|
|
356
408
|
a,
|
|
357
|
-
o
|
|
409
|
+
o,
|
|
410
|
+
s
|
|
358
411
|
]);
|
|
359
|
-
let
|
|
360
|
-
if (!
|
|
361
|
-
let e = new Map(
|
|
362
|
-
for (let n of
|
|
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 =
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
]), [
|
|
386
|
-
|
|
387
|
-
J(
|
|
388
|
-
}, [
|
|
389
|
-
let
|
|
390
|
-
if (!
|
|
391
|
-
let r = { ...
|
|
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
|
-
|
|
397
|
-
}, [
|
|
398
|
-
if (!(!
|
|
399
|
-
}, [
|
|
400
|
-
if (!
|
|
401
|
-
let e =
|
|
402
|
-
return
|
|
403
|
-
}, [
|
|
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 (!
|
|
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
|
-
|
|
416
|
-
]), Z =
|
|
417
|
-
if (!
|
|
418
|
-
let r =
|
|
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
|
-
|
|
474
|
+
p([...r, {
|
|
422
475
|
table: e,
|
|
423
476
|
column: t
|
|
424
477
|
}]);
|
|
425
|
-
} else
|
|
426
|
-
}, [
|
|
427
|
-
|
|
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
|
-
|
|
501
|
+
u,
|
|
502
|
+
N,
|
|
432
503
|
Z,
|
|
433
|
-
Q
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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 ===
|
|
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
|
|
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 ===
|
|
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:
|
|
543
|
+
color: o,
|
|
544
|
+
strokeWidth: a?.strokeWidth,
|
|
545
|
+
strokeDasharray: a?.strokeDasharray,
|
|
472
546
|
hovered: i,
|
|
473
|
-
onDelete:
|
|
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:
|
|
557
|
+
data: s
|
|
484
558
|
});
|
|
485
559
|
}
|
|
486
560
|
return [...n, ...r];
|
|
487
561
|
}, [
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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
|
-
}, [
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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
|
-
...
|
|
597
|
+
...z
|
|
514
598
|
},
|
|
515
599
|
children: [
|
|
516
|
-
|
|
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:
|
|
616
|
+
children: H.message
|
|
533
617
|
}),
|
|
534
|
-
!
|
|
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__ */
|
|
547
|
-
value:
|
|
548
|
-
children: /* @__PURE__ */
|
|
549
|
-
value:
|
|
550
|
-
children: /* @__PURE__ */
|
|
551
|
-
value:
|
|
552
|
-
children: /* @__PURE__ */
|
|
553
|
-
value:
|
|
554
|
-
children: /* @__PURE__ */
|
|
555
|
-
nodes:
|
|
556
|
-
edges:
|
|
557
|
-
nodeTypes:
|
|
558
|
-
edgeTypes:
|
|
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:
|
|
561
|
-
onNodeDragStop:
|
|
562
|
-
onNodeClick:
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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:
|
|
658
|
+
deleteKeyCode: ae,
|
|
571
659
|
minZoom: .1,
|
|
572
660
|
maxZoom: 4,
|
|
573
661
|
children: [
|
|
574
|
-
/* @__PURE__ */
|
|
575
|
-
/* @__PURE__ */
|
|
576
|
-
/* @__PURE__ */
|
|
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
|
|