drizzle-cube 0.4.26 → 0.4.28
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/client/charts.js +1 -1
- package/dist/client/chunks/{analysis-builder-C2jqaLZs.js → analysis-builder-DMFoAkjT.js} +5 -5
- package/dist/client/chunks/{analysis-builder-C2jqaLZs.js.map → analysis-builder-DMFoAkjT.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-Bz9oSywd.js → analysis-builder-shared-CunrT3gi.js} +2 -2
- package/dist/client/chunks/{analysis-builder-shared-Bz9oSywd.js.map → analysis-builder-shared-CunrT3gi.js.map} +1 -1
- package/dist/client/chunks/chart-markdown-BT_-MBq1.js +2721 -0
- package/dist/client/chunks/chart-markdown-BT_-MBq1.js.map +1 -0
- package/dist/client/chunks/{charts-loader-Bv-IWHVd.js → charts-loader-goTYnavu.js} +2 -2
- package/dist/client/chunks/{charts-loader-Bv-IWHVd.js.map → charts-loader-goTYnavu.js.map} +1 -1
- package/dist/client/chunks/{components-CPqnw8o8.js → components-BFgYvFq6.js} +4 -4
- package/dist/client/chunks/{components-CPqnw8o8.js.map → components-BFgYvFq6.js.map} +1 -1
- package/dist/client/chunks/schema-visualization-B97a1Ybu.js +772 -0
- package/dist/client/chunks/schema-visualization-B97a1Ybu.js.map +1 -0
- package/dist/client/components/SchemaVisualization/CubeNode.d.ts +12 -1
- package/dist/client/components/SchemaVisualization/FieldDetailPanel.d.ts +15 -0
- package/dist/client/components/SchemaVisualization/xyflowContext.d.ts +11 -0
- package/dist/client/components.js +1 -1
- package/dist/client/index.js +43 -43
- package/dist/client/styles.css +1 -1
- package/dist/client-bundle-stats.html +1 -1
- package/package.json +2 -2
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js +0 -2695
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js.map +0 -1
- package/dist/client/chunks/schema-visualization-CzOuTQDu.js +0 -563
- package/dist/client/chunks/schema-visualization-CzOuTQDu.js.map +0 -1
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
import { jsx as e, jsxs as a, Fragment as _e } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as je, useContext as Oe, useState as k, useEffect as H, Suspense as ze, lazy as He, useMemo as V, useRef as j, useCallback as I } from "react";
|
|
3
|
+
import { u as Ae } from "./providers-Ds7DRmnO.js";
|
|
4
|
+
import { g as Z } from "./icons-CwvgmdIP.js";
|
|
5
|
+
const ge = je(null), We = ge.Provider;
|
|
6
|
+
function Q() {
|
|
7
|
+
const t = Oe(ge);
|
|
8
|
+
if (!t) throw new Error("useXyflow must be used within XyflowProvider");
|
|
9
|
+
return t;
|
|
10
|
+
}
|
|
11
|
+
let ae = !1;
|
|
12
|
+
function Be(t) {
|
|
13
|
+
return /* @__PURE__ */ e("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full dc:p-8", children: /* @__PURE__ */ a("div", { className: "dc:text-center dc:max-w-md", children: [
|
|
14
|
+
/* @__PURE__ */ e("div", { className: "dc:text-4xl dc:mb-4", children: "🔍" }),
|
|
15
|
+
/* @__PURE__ */ e("h3", { className: "dc:text-lg dc:font-semibold text-dc-text dc:mb-2", children: "Schema Visualization requires additional packages" }),
|
|
16
|
+
/* @__PURE__ */ e("p", { className: "dc:text-sm text-dc-text-secondary dc:mb-4", children: "Install the required dependencies to enable the interactive schema diagram:" }),
|
|
17
|
+
/* @__PURE__ */ e("code", { className: "dc:block dc:px-4 dc:py-2 dc:rounded bg-dc-surface-secondary dc:text-sm dc:font-mono text-dc-text dc:border border-dc-border", children: "npm install @xyflow/react elkjs" })
|
|
18
|
+
] }) });
|
|
19
|
+
}
|
|
20
|
+
function fe() {
|
|
21
|
+
return /* @__PURE__ */ e("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ a("div", { className: "dc:text-center", children: [
|
|
22
|
+
/* @__PURE__ */ e("div", { className: "dc:animate-spin dc:rounded-full dc:h-8 dc:w-8 dc:border-b-2 border-dc-accent dc:mx-auto dc:mb-2" }),
|
|
23
|
+
/* @__PURE__ */ e("p", { className: "dc:text-sm text-dc-text-muted", children: "Loading schema visualization..." })
|
|
24
|
+
] }) });
|
|
25
|
+
}
|
|
26
|
+
const Ve = He(async () => ({ default: (await Promise.resolve().then(() => st)).SchemaVisualization }));
|
|
27
|
+
function ut(t) {
|
|
28
|
+
const [n, r] = k(null), [d, s] = k(ae);
|
|
29
|
+
return H(() => {
|
|
30
|
+
if (ae) return;
|
|
31
|
+
let o = !1;
|
|
32
|
+
return import("@xyflow/react").then((f) => {
|
|
33
|
+
o || r(f);
|
|
34
|
+
}).catch(() => {
|
|
35
|
+
ae = !0, o || s(!0);
|
|
36
|
+
}), () => {
|
|
37
|
+
o = !0;
|
|
38
|
+
};
|
|
39
|
+
}, []), d ? /* @__PURE__ */ e(Be, { ...t }) : n ? /* @__PURE__ */ e(We, { value: n, children: /* @__PURE__ */ e(ze, { fallback: /* @__PURE__ */ e(fe, {}), children: /* @__PURE__ */ e(Ve, { ...t }) }) }) : /* @__PURE__ */ e(fe, {});
|
|
40
|
+
}
|
|
41
|
+
function Xe({ data: t }) {
|
|
42
|
+
const { Handle: n, Position: r } = Q(), { cube: d, onFieldClick: s, onCubeClick: o, isHighlighted: f, highlightedFields: p, searchTerm: g, selectedField: h } = t, x = (c, y, $) => {
|
|
43
|
+
s && s(d.name, y, $, { x: c.clientX, y: c.clientY });
|
|
44
|
+
}, m = Z("info"), D = (c) => {
|
|
45
|
+
c.stopPropagation(), o && o(d.name, { x: c.clientX, y: c.clientY });
|
|
46
|
+
}, L = (c) => h ? h.cubeName === d.name && h.fieldName === c : !1, l = h?.cubeName === d.name && h?.fieldName === null, N = (c) => p.includes(c), C = (c) => {
|
|
47
|
+
if (!g?.trim()) return !0;
|
|
48
|
+
const y = g.toLowerCase();
|
|
49
|
+
return c.name.toLowerCase().includes(y) || c.title && c.title.toLowerCase().includes(y);
|
|
50
|
+
}, P = g?.trim() ? d.measures.some((c) => C(c)) || d.dimensions.some((c) => C(c)) : !0, M = (c, y, $) => {
|
|
51
|
+
const E = c.name.split(".")[1] || c.name, X = L(E), T = "dc:px-4 dc:py-2 dc:text-xs dc:cursor-pointer dc:transition-all dc:border-b border-dc-border last:dc:border-b-0 nodrag nopan";
|
|
52
|
+
return X ? `${T} bg-dc-accent-bg text-dc-accent dc:font-semibold dc:ring-1 dc:ring-inset ring-dc-accent` : !P && g?.trim() ? y ? `${T} bg-dc-accent-bg text-dc-accent dc:font-semibold` : `${T} dc:hover:bg-dc-surface-hover text-dc-text-secondary` : g?.trim() && !C(c) ? `${T} dc:opacity-40 dc:hover:opacity-60 text-dc-text-muted` : g?.trim() && C(c) && !y ? `${T} dc:font-bold dc:hover:bg-dc-accent-bg` : y ? `${T} bg-dc-accent-bg text-dc-accent dc:font-semibold` : `${T} dc:hover:bg-dc-surface-hover text-dc-text-secondary`;
|
|
53
|
+
}, F = d.dimensions.filter((c) => c.type === "time"), R = d.dimensions.filter((c) => c.type !== "time");
|
|
54
|
+
return /* @__PURE__ */ a(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: `
|
|
58
|
+
dc:border-2 dc:rounded-lg dc:shadow-lg dc:min-w-[280px] dc:overflow-hidden dc:transition-all
|
|
59
|
+
${!P && g?.trim() ? "dc:opacity-30 dc:grayscale" : ""}
|
|
60
|
+
${f ? "border-dc-accent dc:ring-2 ring-dc-accent" : "border-dc-border"}
|
|
61
|
+
`,
|
|
62
|
+
style: { backgroundColor: "var(--dc-surface)" },
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ e("div", { className: `dc:px-4 dc:py-3 dc:transition-colors ${f ? "bg-dc-accent-bg" : "bg-dc-surface-secondary"}`, children: /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-between", children: [
|
|
65
|
+
/* @__PURE__ */ a("div", { children: [
|
|
66
|
+
/* @__PURE__ */ e("h3", { className: "dc:font-semibold text-dc-text dc:text-sm", children: d.title || d.name }),
|
|
67
|
+
d.description && /* @__PURE__ */ e("p", { className: "dc:text-xs text-dc-text-muted dc:mt-1 dc:line-clamp-2", children: d.description })
|
|
68
|
+
] }),
|
|
69
|
+
o && /* @__PURE__ */ e(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
className: `dc:ml-2 dc:p-1 dc:rounded dc:transition-colors nodrag nopan ${l ? "bg-dc-accent-bg text-dc-accent" : "text-dc-text-muted dc:hover:text-dc-text dc:hover:bg-dc-surface-hover"}`,
|
|
73
|
+
onClick: D,
|
|
74
|
+
title: "Cube info",
|
|
75
|
+
children: /* @__PURE__ */ e(m, { className: "dc:w-5 dc:h-5" })
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
!o && /* @__PURE__ */ a("div", { className: "dc:text-xs text-dc-text-muted dc:ml-2", children: [
|
|
79
|
+
/* @__PURE__ */ a("div", { children: [
|
|
80
|
+
d.measures.length,
|
|
81
|
+
"M"
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ a("div", { children: [
|
|
84
|
+
d.dimensions.length,
|
|
85
|
+
"D"
|
|
86
|
+
] })
|
|
87
|
+
] })
|
|
88
|
+
] }) }),
|
|
89
|
+
d.measures.length > 0 && /* @__PURE__ */ a("div", { className: "dc:border-t border-dc-border", children: [
|
|
90
|
+
/* @__PURE__ */ e("div", { className: "dc:px-4 dc:py-1.5 dc:border-b border-dc-border", style: { backgroundColor: "color-mix(in srgb, var(--dc-warning) 10%, var(--dc-surface))" }, children: /* @__PURE__ */ a("h4", { className: "dc:text-xs dc:font-medium text-dc-text-secondary dc:flex dc:items-center", children: [
|
|
91
|
+
/* @__PURE__ */ e("span", { className: "dc:w-2 dc:h-2 bg-dc-warning dc:rounded-full dc:mr-2" }),
|
|
92
|
+
"Measures (",
|
|
93
|
+
d.measures.length,
|
|
94
|
+
")"
|
|
95
|
+
] }) }),
|
|
96
|
+
/* @__PURE__ */ e("div", { className: "dc:max-h-64 dc:overflow-y-auto nowheel", children: d.measures.map((c) => {
|
|
97
|
+
const y = c.name.split(".")[1] || c.name, $ = N(c.name);
|
|
98
|
+
return /* @__PURE__ */ e(
|
|
99
|
+
"div",
|
|
100
|
+
{
|
|
101
|
+
className: M(c, $),
|
|
102
|
+
onClick: (E) => x(E, y, "measure"),
|
|
103
|
+
title: c.title,
|
|
104
|
+
children: /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-between", children: [
|
|
105
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono dc:truncate", children: c.shortTitle || c.title || y }),
|
|
106
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted dc:ml-2 dc:text-[10px] dc:uppercase", children: c.type })
|
|
107
|
+
] })
|
|
108
|
+
},
|
|
109
|
+
c.name
|
|
110
|
+
);
|
|
111
|
+
}) })
|
|
112
|
+
] }),
|
|
113
|
+
F.length > 0 && /* @__PURE__ */ a("div", { className: "dc:border-t border-dc-border", children: [
|
|
114
|
+
/* @__PURE__ */ e("div", { className: "dc:px-4 dc:py-1.5 dc:border-b border-dc-border", style: { backgroundColor: "color-mix(in srgb, var(--dc-accent) 10%, var(--dc-surface))" }, children: /* @__PURE__ */ a("h4", { className: "dc:text-xs dc:font-medium text-dc-text-secondary dc:flex dc:items-center", children: [
|
|
115
|
+
/* @__PURE__ */ e("span", { className: "dc:w-2 dc:h-2 bg-dc-accent dc:rounded-full dc:mr-2" }),
|
|
116
|
+
"Time Dimensions (",
|
|
117
|
+
F.length,
|
|
118
|
+
")"
|
|
119
|
+
] }) }),
|
|
120
|
+
/* @__PURE__ */ e("div", { className: "dc:max-h-64 dc:overflow-y-auto nowheel", children: F.map((c) => {
|
|
121
|
+
const y = c.name.split(".")[1] || c.name, $ = N(c.name);
|
|
122
|
+
return /* @__PURE__ */ e(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
className: M(c, $),
|
|
126
|
+
onClick: (E) => x(E, y, "dimension"),
|
|
127
|
+
title: c.title,
|
|
128
|
+
children: /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-between", children: [
|
|
129
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono dc:truncate", children: c.shortTitle || c.title || y }),
|
|
130
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted dc:ml-2 dc:text-[10px] dc:uppercase", children: c.type })
|
|
131
|
+
] })
|
|
132
|
+
},
|
|
133
|
+
c.name
|
|
134
|
+
);
|
|
135
|
+
}) })
|
|
136
|
+
] }),
|
|
137
|
+
R.length > 0 && /* @__PURE__ */ a("div", { className: "dc:border-t border-dc-border", children: [
|
|
138
|
+
/* @__PURE__ */ e("div", { className: "dc:px-4 dc:py-1.5 dc:border-b border-dc-border", style: { backgroundColor: "color-mix(in srgb, var(--dc-success) 10%, var(--dc-surface))" }, children: /* @__PURE__ */ a("h4", { className: "dc:text-xs dc:font-medium text-dc-text-secondary dc:flex dc:items-center", children: [
|
|
139
|
+
/* @__PURE__ */ e("span", { className: "dc:w-2 dc:h-2 bg-dc-success dc:rounded-full dc:mr-2" }),
|
|
140
|
+
"Dimensions (",
|
|
141
|
+
R.length,
|
|
142
|
+
")"
|
|
143
|
+
] }) }),
|
|
144
|
+
/* @__PURE__ */ e("div", { className: "dc:max-h-64 dc:overflow-y-auto nowheel", children: R.map((c) => {
|
|
145
|
+
const y = c.name.split(".")[1] || c.name, $ = N(c.name);
|
|
146
|
+
return /* @__PURE__ */ e(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
className: M(c, $),
|
|
150
|
+
onClick: (E) => x(E, y, "dimension"),
|
|
151
|
+
title: c.title,
|
|
152
|
+
children: /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-between", children: [
|
|
153
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono dc:truncate", children: c.shortTitle || c.title || y }),
|
|
154
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted dc:ml-2 dc:text-[10px] dc:uppercase", children: c.type })
|
|
155
|
+
] })
|
|
156
|
+
},
|
|
157
|
+
c.name
|
|
158
|
+
);
|
|
159
|
+
}) })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ e(n, { type: "source", position: r.Right, id: "right", className: "dc:opacity-0", isConnectable: !1 }),
|
|
162
|
+
/* @__PURE__ */ e(n, { type: "target", position: r.Left, id: "left", className: "dc:opacity-0", isConnectable: !1 }),
|
|
163
|
+
/* @__PURE__ */ e(n, { type: "source", position: r.Bottom, id: "bottom", className: "dc:opacity-0", isConnectable: !1 }),
|
|
164
|
+
/* @__PURE__ */ e(n, { type: "target", position: r.Top, id: "top", className: "dc:opacity-0", isConnectable: !1 })
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
function Ke({
|
|
170
|
+
sourceX: t,
|
|
171
|
+
sourceY: n,
|
|
172
|
+
targetX: r,
|
|
173
|
+
targetY: d,
|
|
174
|
+
sourcePosition: s,
|
|
175
|
+
targetPosition: o,
|
|
176
|
+
style: f = {},
|
|
177
|
+
data: p,
|
|
178
|
+
markerEnd: g
|
|
179
|
+
}) {
|
|
180
|
+
const { getBezierPath: h, BaseEdge: x, EdgeLabelRenderer: m } = Q(), [D, L, l] = h({
|
|
181
|
+
sourceX: t,
|
|
182
|
+
sourceY: n,
|
|
183
|
+
sourcePosition: s,
|
|
184
|
+
targetX: r,
|
|
185
|
+
targetY: d,
|
|
186
|
+
targetPosition: o
|
|
187
|
+
});
|
|
188
|
+
if (!p) return null;
|
|
189
|
+
const { relationship: N, joinFields: C } = p, _ = (R) => {
|
|
190
|
+
switch (R) {
|
|
191
|
+
case "belongsTo":
|
|
192
|
+
return "∈";
|
|
193
|
+
// belongs to
|
|
194
|
+
case "hasOne":
|
|
195
|
+
return "1:1";
|
|
196
|
+
case "hasMany":
|
|
197
|
+
return "1:M";
|
|
198
|
+
case "belongsToMany":
|
|
199
|
+
return "M:M";
|
|
200
|
+
default:
|
|
201
|
+
return "?";
|
|
202
|
+
}
|
|
203
|
+
}, M = ((R) => {
|
|
204
|
+
switch (R) {
|
|
205
|
+
case "belongsTo":
|
|
206
|
+
return "#10b981";
|
|
207
|
+
case "hasOne":
|
|
208
|
+
return "#3b82f6";
|
|
209
|
+
case "hasMany":
|
|
210
|
+
return "#f59e0b";
|
|
211
|
+
case "belongsToMany":
|
|
212
|
+
return "#8b5cf6";
|
|
213
|
+
default:
|
|
214
|
+
return "#6b7280";
|
|
215
|
+
}
|
|
216
|
+
})(N.relationship), F = _(N.relationship);
|
|
217
|
+
return /* @__PURE__ */ a(_e, { children: [
|
|
218
|
+
/* @__PURE__ */ e(x, { path: D, markerEnd: g, style: { ...f, stroke: M } }),
|
|
219
|
+
/* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(
|
|
220
|
+
"div",
|
|
221
|
+
{
|
|
222
|
+
style: {
|
|
223
|
+
position: "absolute",
|
|
224
|
+
transform: `translate(-50%, -50%) translate(${L}px,${l}px)`,
|
|
225
|
+
fontSize: 10,
|
|
226
|
+
pointerEvents: "all"
|
|
227
|
+
},
|
|
228
|
+
className: "nodrag nopan",
|
|
229
|
+
children: /* @__PURE__ */ e(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
className: "dc:border-2 dc:rounded-md dc:px-2 dc:py-1 dc:shadow-xs",
|
|
233
|
+
style: { backgroundColor: "var(--dc-surface)", borderColor: M },
|
|
234
|
+
children: /* @__PURE__ */ a("div", { className: "dc:text-center", children: [
|
|
235
|
+
/* @__PURE__ */ e("div", { className: "dc:font-bold dc:text-xs dc:mb-1", style: { color: M }, children: F }),
|
|
236
|
+
/* @__PURE__ */ e("div", { className: "dc:text-[9px] text-dc-text-muted dc:leading-tight", children: C.map((R, c) => /* @__PURE__ */ a("div", { className: "dc:font-mono", children: [
|
|
237
|
+
R.sourceField,
|
|
238
|
+
" → ",
|
|
239
|
+
R.targetField
|
|
240
|
+
] }, c)) })
|
|
241
|
+
] })
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
) })
|
|
246
|
+
] });
|
|
247
|
+
}
|
|
248
|
+
function S({ label: t, children: n }) {
|
|
249
|
+
return /* @__PURE__ */ a("div", { className: "dc:flex dc:items-start dc:gap-2 dc:text-xs", children: [
|
|
250
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted dc:w-20 dc:flex-shrink-0 dc:font-medium", children: t }),
|
|
251
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text dc:flex-1 dc:min-w-0", children: n })
|
|
252
|
+
] });
|
|
253
|
+
}
|
|
254
|
+
function le({ type: t, color: n }) {
|
|
255
|
+
return /* @__PURE__ */ e(
|
|
256
|
+
"span",
|
|
257
|
+
{
|
|
258
|
+
className: "dc:inline-flex dc:items-center dc:px-1.5 dc:py-0.5 dc:rounded dc:text-[10px] dc:font-medium dc:uppercase",
|
|
259
|
+
style: { backgroundColor: `color-mix(in srgb, ${n} 15%, var(--dc-surface))`, color: n },
|
|
260
|
+
children: t
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
function Ge({ measure: t, cube: n }) {
|
|
265
|
+
const r = {
|
|
266
|
+
count: "#f59e0b",
|
|
267
|
+
countDistinct: "#f59e0b",
|
|
268
|
+
countDistinctApprox: "#f59e0b",
|
|
269
|
+
sum: "#10b981",
|
|
270
|
+
avg: "#3b82f6",
|
|
271
|
+
min: "#8b5cf6",
|
|
272
|
+
max: "#ec4899",
|
|
273
|
+
runningTotal: "#06b6d4",
|
|
274
|
+
number: "#6b7280"
|
|
275
|
+
}[t.type] || "#6b7280";
|
|
276
|
+
return /* @__PURE__ */ a("div", { className: "dc:flex dc:flex-col dc:gap-2", children: [
|
|
277
|
+
/* @__PURE__ */ e(S, { label: "Cube", children: n.title || n.name }),
|
|
278
|
+
/* @__PURE__ */ e(S, { label: "Type", children: /* @__PURE__ */ e(le, { type: t.type, color: r }) }),
|
|
279
|
+
t.title && t.title !== t.shortTitle && /* @__PURE__ */ e(S, { label: "Title", children: t.title }),
|
|
280
|
+
t.drillMembers && t.drillMembers.length > 0 && /* @__PURE__ */ e(S, { label: "Drill into", children: /* @__PURE__ */ e("div", { className: "dc:flex dc:flex-wrap dc:gap-1", children: t.drillMembers.map((d) => /* @__PURE__ */ e("span", { className: "dc:font-mono dc:text-[10px] dc:px-1 dc:py-0.5 dc:rounded bg-dc-surface-secondary border-dc-border dc:border", children: d.split(".")[1] || d }, d)) }) })
|
|
281
|
+
] });
|
|
282
|
+
}
|
|
283
|
+
function Ye({ dimension: t, cube: n }) {
|
|
284
|
+
const r = t.type === "time" ? "#3b82f6" : "#10b981", d = n.hierarchies?.filter(
|
|
285
|
+
(s) => s.levels.some((o) => o === t.name || o === `${n.name}.${t.name.split(".")[1]}`)
|
|
286
|
+
) || [];
|
|
287
|
+
return /* @__PURE__ */ a("div", { className: "dc:flex dc:flex-col dc:gap-2", children: [
|
|
288
|
+
/* @__PURE__ */ e(S, { label: "Cube", children: n.title || n.name }),
|
|
289
|
+
/* @__PURE__ */ e(S, { label: "Type", children: /* @__PURE__ */ e(le, { type: t.type, color: r }) }),
|
|
290
|
+
t.title && t.title !== t.shortTitle && /* @__PURE__ */ e(S, { label: "Title", children: t.title }),
|
|
291
|
+
t.type === "time" && t.granularities && t.granularities.length > 0 && /* @__PURE__ */ e(S, { label: "Granularity", children: /* @__PURE__ */ e("div", { className: "dc:flex dc:flex-wrap dc:gap-1", children: t.granularities.map((s) => /* @__PURE__ */ e("span", { className: "dc:font-mono dc:text-[10px] dc:px-1 dc:py-0.5 dc:rounded bg-dc-surface-secondary border-dc-border dc:border", children: s }, s)) }) }),
|
|
292
|
+
d.length > 0 && /* @__PURE__ */ e(S, { label: "Hierarchy", children: d.map((s) => /* @__PURE__ */ a("div", { className: "dc:text-[10px]", children: [
|
|
293
|
+
/* @__PURE__ */ e("span", { className: "dc:font-medium", children: s.title }),
|
|
294
|
+
/* @__PURE__ */ a("span", { className: "text-dc-text-muted dc:ml-1", children: [
|
|
295
|
+
"(",
|
|
296
|
+
s.levels.map((o) => o.split(".")[1] || o).join(" > "),
|
|
297
|
+
")"
|
|
298
|
+
] })
|
|
299
|
+
] }, s.name)) })
|
|
300
|
+
] });
|
|
301
|
+
}
|
|
302
|
+
function Je({ cube: t }) {
|
|
303
|
+
const n = {
|
|
304
|
+
belongsTo: "#10b981",
|
|
305
|
+
hasOne: "#3b82f6",
|
|
306
|
+
hasMany: "#f59e0b",
|
|
307
|
+
belongsToMany: "#8b5cf6"
|
|
308
|
+
};
|
|
309
|
+
return /* @__PURE__ */ a("div", { className: "dc:flex dc:flex-col dc:gap-2", children: [
|
|
310
|
+
t.description && /* @__PURE__ */ e(S, { label: "Description", children: t.description }),
|
|
311
|
+
/* @__PURE__ */ a(S, { label: "Measures", children: [
|
|
312
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono", children: t.measures.length }),
|
|
313
|
+
t.measures.length > 0 && /* @__PURE__ */ a("span", { className: "text-dc-text-muted dc:ml-1", children: [
|
|
314
|
+
"(",
|
|
315
|
+
[...new Set(t.measures.map((r) => r.type))].join(", "),
|
|
316
|
+
")"
|
|
317
|
+
] })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ a(S, { label: "Dimensions", children: [
|
|
320
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono", children: t.dimensions.length }),
|
|
321
|
+
t.dimensions.some((r) => r.type === "time") && /* @__PURE__ */ a("span", { className: "text-dc-text-muted dc:ml-1", children: [
|
|
322
|
+
"(",
|
|
323
|
+
t.dimensions.filter((r) => r.type === "time").length,
|
|
324
|
+
" time)"
|
|
325
|
+
] })
|
|
326
|
+
] }),
|
|
327
|
+
t.relationships && t.relationships.length > 0 && /* @__PURE__ */ e(S, { label: "Joins", children: /* @__PURE__ */ e("div", { className: "dc:flex dc:flex-col dc:gap-1", children: t.relationships.map((r, d) => /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:gap-1.5 dc:text-[10px]", children: [
|
|
328
|
+
/* @__PURE__ */ e(le, { type: r.relationship, color: n[r.relationship] || "#6b7280" }),
|
|
329
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono", children: r.targetCube })
|
|
330
|
+
] }, d)) }) }),
|
|
331
|
+
t.hierarchies && t.hierarchies.length > 0 && /* @__PURE__ */ e(S, { label: "Hierarchies", children: /* @__PURE__ */ e("div", { className: "dc:flex dc:flex-col dc:gap-1", children: t.hierarchies.map((r) => /* @__PURE__ */ a("div", { className: "dc:text-[10px]", children: [
|
|
332
|
+
/* @__PURE__ */ e("span", { className: "dc:font-medium", children: r.title }),
|
|
333
|
+
/* @__PURE__ */ a("span", { className: "text-dc-text-muted dc:ml-1", children: [
|
|
334
|
+
"(",
|
|
335
|
+
r.levels.map((d) => d.split(".")[1] || d).join(" > "),
|
|
336
|
+
")"
|
|
337
|
+
] })
|
|
338
|
+
] }, r.name)) }) }),
|
|
339
|
+
t.meta?.eventStream && /* @__PURE__ */ e(S, { label: "Event Stream", children: /* @__PURE__ */ a("div", { className: "dc:text-[10px]", children: [
|
|
340
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted", children: "binding: " }),
|
|
341
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono", children: t.meta.eventStream.bindingKey.split(".")[1] || t.meta.eventStream.bindingKey }),
|
|
342
|
+
/* @__PURE__ */ e("span", { className: "text-dc-text-muted dc:ml-2", children: "time: " }),
|
|
343
|
+
/* @__PURE__ */ e("span", { className: "dc:font-mono", children: t.meta.eventStream.timeDimension.split(".")[1] || t.meta.eventStream.timeDimension })
|
|
344
|
+
] }) })
|
|
345
|
+
] });
|
|
346
|
+
}
|
|
347
|
+
function qe({ selection: t, meta: n, onClose: r }) {
|
|
348
|
+
const d = Z("close"), s = n.cubes.find((h) => h.name === t.cubeName);
|
|
349
|
+
if (!s) return null;
|
|
350
|
+
let o, f, p, g;
|
|
351
|
+
if (t.fieldType === "cube" || !t.fieldName)
|
|
352
|
+
o = s.title || s.name, f = "var(--dc-accent)", p = "color-mix(in srgb, var(--dc-accent) 10%, var(--dc-surface))", g = /* @__PURE__ */ e(Je, { cube: s });
|
|
353
|
+
else if (t.fieldType === "measure") {
|
|
354
|
+
const h = s.measures.find((x) => (x.name.split(".")[1] || x.name) === t.fieldName || x.name === t.fieldName);
|
|
355
|
+
if (!h) return null;
|
|
356
|
+
o = h.shortTitle || h.title || t.fieldName, f = "var(--dc-warning)", p = "color-mix(in srgb, var(--dc-warning) 10%, var(--dc-surface))", g = /* @__PURE__ */ e(Ge, { measure: h, cube: s });
|
|
357
|
+
} else {
|
|
358
|
+
const h = s.dimensions.find((x) => (x.name.split(".")[1] || x.name) === t.fieldName || x.name === t.fieldName);
|
|
359
|
+
if (!h) return null;
|
|
360
|
+
o = h.shortTitle || h.title || t.fieldName, f = h.type === "time" ? "var(--dc-accent)" : "var(--dc-success)", p = h.type === "time" ? "color-mix(in srgb, var(--dc-accent) 10%, var(--dc-surface))" : "color-mix(in srgb, var(--dc-success) 10%, var(--dc-surface))", g = /* @__PURE__ */ e(Ye, { dimension: h, cube: s });
|
|
361
|
+
}
|
|
362
|
+
return /* @__PURE__ */ a(
|
|
363
|
+
"div",
|
|
364
|
+
{
|
|
365
|
+
className: "dc:border-2 dc:rounded-lg dc:shadow-lg dc:min-w-[260px] dc:max-w-[320px] dc:overflow-hidden dc:transition-all border-dc-border",
|
|
366
|
+
style: { backgroundColor: "var(--dc-surface)" },
|
|
367
|
+
children: [
|
|
368
|
+
/* @__PURE__ */ a(
|
|
369
|
+
"div",
|
|
370
|
+
{
|
|
371
|
+
className: "dc:px-4 dc:py-2.5 dc:border-b border-dc-border dc:flex dc:items-center dc:justify-between",
|
|
372
|
+
style: { backgroundColor: p },
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:gap-2 dc:min-w-0", children: [
|
|
375
|
+
/* @__PURE__ */ e(
|
|
376
|
+
"span",
|
|
377
|
+
{
|
|
378
|
+
className: "dc:w-2 dc:h-2 dc:rounded-full dc:flex-shrink-0",
|
|
379
|
+
style: { backgroundColor: f }
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ e("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:truncate", children: o })
|
|
383
|
+
] }),
|
|
384
|
+
/* @__PURE__ */ e(
|
|
385
|
+
"button",
|
|
386
|
+
{
|
|
387
|
+
onClick: r,
|
|
388
|
+
className: "dc:ml-2 dc:flex-shrink-0 text-dc-text-muted dc:hover:text-dc-text dc:transition-colors",
|
|
389
|
+
children: /* @__PURE__ */ e(d, { className: "dc:w-3.5 dc:h-3.5" })
|
|
390
|
+
}
|
|
391
|
+
)
|
|
392
|
+
]
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
/* @__PURE__ */ e("div", { className: "dc:px-4 dc:py-3", children: g })
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
const Ze = {
|
|
401
|
+
direction: "LR",
|
|
402
|
+
nodeWidth: 340,
|
|
403
|
+
nodeSep: 150,
|
|
404
|
+
rankSep: 350
|
|
405
|
+
};
|
|
406
|
+
function xe(t) {
|
|
407
|
+
switch (t) {
|
|
408
|
+
case "TB":
|
|
409
|
+
return "top";
|
|
410
|
+
case "LR":
|
|
411
|
+
return "left";
|
|
412
|
+
default:
|
|
413
|
+
return "top";
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function be(t) {
|
|
417
|
+
switch (t) {
|
|
418
|
+
case "TB":
|
|
419
|
+
return "bottom";
|
|
420
|
+
case "LR":
|
|
421
|
+
return "right";
|
|
422
|
+
default:
|
|
423
|
+
return "bottom";
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function ye(t) {
|
|
427
|
+
const n = t.data?.cube;
|
|
428
|
+
if (!n) return 300;
|
|
429
|
+
const r = n.description ? 80 : 56, d = 36, s = 34, o = 256, f = 30;
|
|
430
|
+
let p = r;
|
|
431
|
+
const g = n.measures?.length ?? 0, h = n.dimensions?.filter((m) => m.type === "time").length ?? 0, x = n.dimensions?.filter((m) => m.type !== "time").length ?? 0;
|
|
432
|
+
return g > 0 && (p += d + Math.min(g * s, o)), h > 0 && (p += d + Math.min(h * s, o)), x > 0 && (p += d + Math.min(x * s, o)), p + f;
|
|
433
|
+
}
|
|
434
|
+
let U = null;
|
|
435
|
+
const Ue = import("elkjs/lib/elk.bundled.js").then((t) => {
|
|
436
|
+
const n = t.default || t;
|
|
437
|
+
return U = new n(), U;
|
|
438
|
+
}).catch(() => null);
|
|
439
|
+
async function Qe(t, n, r) {
|
|
440
|
+
if (await Ue, !U)
|
|
441
|
+
return { nodes: Ne(t, r), edges: n };
|
|
442
|
+
const d = r.direction === "LR" ? "EAST" : "SOUTH", s = r.direction === "LR" ? "WEST" : "NORTH", o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
443
|
+
n.forEach((l) => {
|
|
444
|
+
o.has(l.source) || o.set(l.source, []), o.get(l.source).push(l.id), f.has(l.target) || f.set(l.target, []), f.get(l.target).push(l.id);
|
|
445
|
+
});
|
|
446
|
+
const p = t.map((l) => {
|
|
447
|
+
const N = r.nodeWidth, C = ye(l), _ = o.get(l.id) || [], P = f.get(l.id) || [], M = [
|
|
448
|
+
..._.map((F) => ({
|
|
449
|
+
id: `${l.id}__src__${F}`,
|
|
450
|
+
layoutOptions: { "elk.port.side": d }
|
|
451
|
+
})),
|
|
452
|
+
...P.map((F) => ({
|
|
453
|
+
id: `${l.id}__tgt__${F}`,
|
|
454
|
+
layoutOptions: { "elk.port.side": s }
|
|
455
|
+
}))
|
|
456
|
+
];
|
|
457
|
+
return {
|
|
458
|
+
id: l.id,
|
|
459
|
+
width: N,
|
|
460
|
+
height: C,
|
|
461
|
+
layoutOptions: { "elk.portConstraints": "FIXED_SIDE" },
|
|
462
|
+
ports: M
|
|
463
|
+
};
|
|
464
|
+
}), g = n.map((l) => ({
|
|
465
|
+
id: l.id,
|
|
466
|
+
sources: [`${l.source}__src__${l.id}`],
|
|
467
|
+
targets: [`${l.target}__tgt__${l.id}`]
|
|
468
|
+
})), x = {
|
|
469
|
+
id: "root",
|
|
470
|
+
layoutOptions: {
|
|
471
|
+
"elk.algorithm": "layered",
|
|
472
|
+
"elk.direction": r.direction === "LR" ? "RIGHT" : "DOWN",
|
|
473
|
+
"elk.edgeRouting": "SPLINES",
|
|
474
|
+
"elk.layered.edgeRouting.splines.mode": "CONSERVATIVE",
|
|
475
|
+
"elk.spacing.nodeNode": String(r.nodeSep),
|
|
476
|
+
"elk.layered.spacing.nodeNodeBetweenLayers": String(r.rankSep),
|
|
477
|
+
"elk.spacing.edgeNode": "60",
|
|
478
|
+
"elk.layered.spacing.edgeNodeBetweenLayers": "60",
|
|
479
|
+
"elk.spacing.edgeEdge": "25",
|
|
480
|
+
"elk.layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
|
|
481
|
+
"elk.layered.crossingMinimization.strategy": "LAYER_SWEEP"
|
|
482
|
+
},
|
|
483
|
+
children: p,
|
|
484
|
+
edges: g
|
|
485
|
+
}, m = await U.layout(x), D = /* @__PURE__ */ new Map();
|
|
486
|
+
if (m.children)
|
|
487
|
+
for (const l of m.children)
|
|
488
|
+
D.set(l.id, { x: l.x, y: l.y });
|
|
489
|
+
return { nodes: t.map((l) => ({
|
|
490
|
+
...l,
|
|
491
|
+
position: D.get(l.id) || l.position,
|
|
492
|
+
targetPosition: xe(r.direction),
|
|
493
|
+
sourcePosition: be(r.direction)
|
|
494
|
+
})), edges: n };
|
|
495
|
+
}
|
|
496
|
+
function Ne(t, n) {
|
|
497
|
+
let d = 0, s = 0;
|
|
498
|
+
return t.map((o) => {
|
|
499
|
+
const f = ye(o);
|
|
500
|
+
s + f > 1200 && s > 0 && (d++, s = 0);
|
|
501
|
+
const p = { x: d * (n.nodeWidth + n.nodeSep), y: s };
|
|
502
|
+
return s += f + 40, {
|
|
503
|
+
...o,
|
|
504
|
+
position: p,
|
|
505
|
+
sourcePosition: be(n.direction),
|
|
506
|
+
targetPosition: xe(n.direction)
|
|
507
|
+
};
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function et(t, n, r = {}) {
|
|
511
|
+
const d = V(
|
|
512
|
+
() => ({ ...Ze, ...r }),
|
|
513
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
514
|
+
[r.direction, r.nodeWidth, r.nodeSep, r.rankSep]
|
|
515
|
+
), s = V(() => t.length === 0 ? "" : t.map((N) => N.id).sort().join(",") + "|" + n.map((N) => N.id).sort().join(","), [t, n]), o = j(t), f = j(n), p = j(d);
|
|
516
|
+
o.current = t, f.current = n, p.current = d;
|
|
517
|
+
const [g, h] = k("waiting"), [x, m] = k(null), [D, L] = k(""), l = j(0);
|
|
518
|
+
return H(() => {
|
|
519
|
+
if (!s) {
|
|
520
|
+
h("ready"), m(null), L("");
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
const N = ++l.current;
|
|
524
|
+
h("computing"), Qe(o.current, f.current, p.current).then((C) => {
|
|
525
|
+
N === l.current && (m(C), L(s), h("ready"));
|
|
526
|
+
}).catch(() => {
|
|
527
|
+
N === l.current && (m({
|
|
528
|
+
nodes: Ne(o.current, p.current),
|
|
529
|
+
edges: f.current
|
|
530
|
+
}), L(s), h("ready"));
|
|
531
|
+
});
|
|
532
|
+
}, [s]), g === "ready" && x && D === s ? { nodes: x.nodes, edges: x.edges, phase: "ready" } : { nodes: [], edges: [], phase: g };
|
|
533
|
+
}
|
|
534
|
+
const tt = { cubeNode: Xe }, ct = { relationshipEdge: Ke };
|
|
535
|
+
function nt({ token: t }) {
|
|
536
|
+
const { useNodesInitialized: n, useReactFlow: r } = Q(), d = n(), { fitView: s } = r(), o = j(0);
|
|
537
|
+
return H(() => {
|
|
538
|
+
t === 0 || t === o.current || d && (o.current = t, s({ padding: 0.1 }));
|
|
539
|
+
}, [t, d, s]), null;
|
|
540
|
+
}
|
|
541
|
+
const pe = [];
|
|
542
|
+
function dt(t) {
|
|
543
|
+
switch (t) {
|
|
544
|
+
case "belongsTo":
|
|
545
|
+
return "#10b981";
|
|
546
|
+
case "hasOne":
|
|
547
|
+
return "#3b82f6";
|
|
548
|
+
case "hasMany":
|
|
549
|
+
return "#f59e0b";
|
|
550
|
+
case "belongsToMany":
|
|
551
|
+
return "#8b5cf6";
|
|
552
|
+
default:
|
|
553
|
+
return "#6b7280";
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function rt({
|
|
557
|
+
className: t = "",
|
|
558
|
+
onFieldClick: n,
|
|
559
|
+
highlightedCubes: r,
|
|
560
|
+
highlightedFields: d,
|
|
561
|
+
searchTerm: s,
|
|
562
|
+
height: o = "100%"
|
|
563
|
+
}) {
|
|
564
|
+
const {
|
|
565
|
+
ReactFlow: f,
|
|
566
|
+
Controls: p,
|
|
567
|
+
MiniMap: g,
|
|
568
|
+
Background: h,
|
|
569
|
+
applyNodeChanges: x
|
|
570
|
+
} = Q(), { meta: m, metaLoading: D, metaError: L } = Ae(), l = r || pe, N = d || pe, [C, _] = k(null), [P, M] = k(s || ""), [F, R] = k(0), [c, y] = k(null), [$, E] = k(null), X = j(null), T = !n, [ee, te] = k({}), [ce, ve] = k(!1), Ce = Z("search"), we = Z("close"), K = s !== void 0 ? s : P;
|
|
571
|
+
H(() => {
|
|
572
|
+
try {
|
|
573
|
+
const i = localStorage.getItem("drizzle-cube-erd-node-positions");
|
|
574
|
+
i && te(JSON.parse(i));
|
|
575
|
+
} catch {
|
|
576
|
+
}
|
|
577
|
+
ve(!0);
|
|
578
|
+
}, []);
|
|
579
|
+
const { structuralNodes: ne, structuralEdges: de } = V(() => {
|
|
580
|
+
if (!m) return { structuralNodes: [], structuralEdges: [] };
|
|
581
|
+
const i = m.cubes.map((u, b) => ({
|
|
582
|
+
id: u.name,
|
|
583
|
+
type: "cubeNode",
|
|
584
|
+
// Placeholder position — ELK will override for auto-layout
|
|
585
|
+
position: { x: b % 3 * 400, y: Math.floor(b / 3) * 300 },
|
|
586
|
+
data: { cube: u }
|
|
587
|
+
})), v = [];
|
|
588
|
+
return m.cubes.forEach((u) => {
|
|
589
|
+
u.relationships && u.relationships.forEach((b, w) => {
|
|
590
|
+
b.relationship !== "belongsTo" && v.push({
|
|
591
|
+
id: `${u.name}-${b.targetCube}-${w}`,
|
|
592
|
+
source: u.name,
|
|
593
|
+
target: b.targetCube,
|
|
594
|
+
type: "relationshipEdge",
|
|
595
|
+
data: { relationship: b, joinFields: b.joinFields || [] },
|
|
596
|
+
animated: !1,
|
|
597
|
+
style: { stroke: dt(b.relationship), strokeWidth: 2 }
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
}), { structuralNodes: i, structuralEdges: v };
|
|
601
|
+
}, [m]), O = F > 0 || ce && Object.keys(ee).length === 0, { nodes: re, edges: se, phase: ke } = et(
|
|
602
|
+
O ? ne : [],
|
|
603
|
+
O ? de : [],
|
|
604
|
+
{ direction: "LR", nodeWidth: 340, nodeSep: 150, rankSep: 350 }
|
|
605
|
+
), G = I((i, v) => {
|
|
606
|
+
const u = X.current?.getBoundingClientRect();
|
|
607
|
+
if (!u) return { x: i, y: v };
|
|
608
|
+
const b = 300, w = 200;
|
|
609
|
+
let z = i - u.left + 12, B = v - u.top + 12;
|
|
610
|
+
return z + b > u.width && (z = i - u.left - b - 12), B + w > u.height && (B = u.height - w - 8), z < 0 && (z = 8), B < 0 && (B = 8), { x: z, y: B };
|
|
611
|
+
}, []), Se = I((i, v, u, b) => {
|
|
612
|
+
y((w) => w && w.cubeName === i && w.fieldName === v ? (E(null), null) : (b && E(G(b.x, b.y)), { cubeName: i, fieldName: v, fieldType: u }));
|
|
613
|
+
}, [G]), Ee = I((i, v) => {
|
|
614
|
+
y((u) => u && u.cubeName === i && u.fieldName === null ? (E(null), null) : (v && E(G(v.x, v.y)), { cubeName: i, fieldName: null, fieldType: "cube" }));
|
|
615
|
+
}, [G]), oe = T ? Se : n, ue = T ? Ee : void 0, A = I((i) => ({
|
|
616
|
+
cube: i,
|
|
617
|
+
onFieldClick: oe,
|
|
618
|
+
onCubeClick: ue,
|
|
619
|
+
isHighlighted: l.includes(i.name),
|
|
620
|
+
highlightedFields: N,
|
|
621
|
+
searchTerm: K,
|
|
622
|
+
selectedField: T ? c : null
|
|
623
|
+
}), [oe, ue, l, N, K, T, c]), W = !O || ke === "ready", Y = V(() => !m || !W || !ce ? [] : O && re.length > 0 ? re.map((i) => ({
|
|
624
|
+
...i,
|
|
625
|
+
data: A(i.data?.cube || m.cubes.find((v) => v.name === i.id))
|
|
626
|
+
})) : ne.map((i) => ({
|
|
627
|
+
...i,
|
|
628
|
+
position: ee[i.id] || i.position,
|
|
629
|
+
data: A(i.data?.cube)
|
|
630
|
+
})), [m, W, ce, O, re, ne, ee, A]), me = V(() => !m || !W ? [] : O && se.length > 0 ? se : de, [m, W, O, se, de]), [ie, J] = k([]), [Te, Me] = k([]), q = j(""), [Re, $e] = k(0);
|
|
631
|
+
H(() => {
|
|
632
|
+
if (Y.length === 0) return;
|
|
633
|
+
const i = Y.map((u) => `${u.id}:${Math.round(u.position.x)},${Math.round(u.position.y)}`).join("|");
|
|
634
|
+
if (i === q.current) return;
|
|
635
|
+
const v = q.current === "";
|
|
636
|
+
q.current = i, J(Y), Me(me), v && $e((u) => u + 1);
|
|
637
|
+
}, [Y, me]);
|
|
638
|
+
const he = j("");
|
|
639
|
+
H(() => {
|
|
640
|
+
const i = c ? `${c.cubeName}.${c.fieldName}` : "", v = `${l.join(",")}|${N.join(",")}|${K}|${String(n)}|${i}`;
|
|
641
|
+
v !== he.current && (he.current = v, !(ie.length === 0 || !m) && J((u) => u.map((b) => {
|
|
642
|
+
const w = m.cubes.find((z) => z.name === b.id);
|
|
643
|
+
return w ? { ...b, data: A(w) } : b;
|
|
644
|
+
})));
|
|
645
|
+
}, [l, N, K, n, c, ie.length, m, A]);
|
|
646
|
+
const Le = I((i) => {
|
|
647
|
+
J((u) => x(i, u)), i.filter(
|
|
648
|
+
(u) => u.type === "position" && "dragging" in u && u.dragging === !1
|
|
649
|
+
).length > 0 && J((u) => {
|
|
650
|
+
const b = {};
|
|
651
|
+
u.forEach((w) => {
|
|
652
|
+
w.position && (b[w.id] = w.position);
|
|
653
|
+
});
|
|
654
|
+
try {
|
|
655
|
+
localStorage.setItem("drizzle-cube-erd-node-positions", JSON.stringify(b));
|
|
656
|
+
} catch {
|
|
657
|
+
}
|
|
658
|
+
return te(b), u;
|
|
659
|
+
});
|
|
660
|
+
}, []), Fe = I((i) => {
|
|
661
|
+
}, []), De = I((i) => {
|
|
662
|
+
i.preventDefault(), i.stopPropagation(), _({ x: i.clientX, y: i.clientY });
|
|
663
|
+
}, []), Pe = I(() => {
|
|
664
|
+
C && _(null), c && (y(null), E(null));
|
|
665
|
+
}, [C, c]), Ie = I(() => {
|
|
666
|
+
te({}), q.current = "";
|
|
667
|
+
try {
|
|
668
|
+
localStorage.removeItem("drizzle-cube-erd-node-positions");
|
|
669
|
+
} catch {
|
|
670
|
+
}
|
|
671
|
+
R((i) => i + 1), _(null);
|
|
672
|
+
}, []);
|
|
673
|
+
return D ? /* @__PURE__ */ e("div", { className: `dc:flex dc:items-center dc:justify-center dc:h-96 ${t}`, children: /* @__PURE__ */ a("div", { className: "dc:text-center", children: [
|
|
674
|
+
/* @__PURE__ */ e("div", { className: "dc:animate-spin dc:rounded-full dc:h-8 dc:w-8 dc:border-b-2 border-dc-accent dc:mx-auto dc:mb-2" }),
|
|
675
|
+
/* @__PURE__ */ e("p", { className: "text-dc-text-muted", children: "Loading cube schema..." })
|
|
676
|
+
] }) }) : L ? /* @__PURE__ */ e("div", { className: `dc:flex dc:items-center dc:justify-center dc:h-96 ${t}`, children: /* @__PURE__ */ a("div", { className: "dc:text-center text-dc-error", children: [
|
|
677
|
+
/* @__PURE__ */ e("p", { className: "dc:font-medium", children: "Failed to load cube schema" }),
|
|
678
|
+
/* @__PURE__ */ e("p", { className: "dc:text-sm dc:mt-1", children: L })
|
|
679
|
+
] }) }) : !m || m.cubes.length === 0 ? /* @__PURE__ */ e("div", { className: `dc:flex dc:items-center dc:justify-center dc:h-96 ${t}`, children: /* @__PURE__ */ a("div", { className: "dc:text-center text-dc-text-muted", children: [
|
|
680
|
+
/* @__PURE__ */ e("p", { className: "dc:font-medium", children: "No cubes found" }),
|
|
681
|
+
/* @__PURE__ */ e("p", { className: "dc:text-sm dc:mt-1", children: "Register some cubes to see the relationship diagram" })
|
|
682
|
+
] }) }) : W ? /* @__PURE__ */ a("div", { className: `dc:flex dc:flex-col ${t}`, style: { height: o, minHeight: 400 }, children: [
|
|
683
|
+
s === void 0 && /* @__PURE__ */ a("div", { className: "dc:px-3 dc:py-2 dc:border-b border-dc-border bg-dc-surface dc:flex dc:items-center dc:gap-2 dc:flex-shrink-0", children: [
|
|
684
|
+
/* @__PURE__ */ e(Ce, { className: "dc:w-4 dc:h-4 text-dc-text-muted" }),
|
|
685
|
+
/* @__PURE__ */ e(
|
|
686
|
+
"input",
|
|
687
|
+
{
|
|
688
|
+
type: "text",
|
|
689
|
+
value: P,
|
|
690
|
+
onChange: (i) => M(i.target.value),
|
|
691
|
+
placeholder: "Search cubes and fields...",
|
|
692
|
+
className: "dc:flex-1 dc:text-sm dc:bg-transparent dc:outline-none text-dc-text dc:placeholder:text-dc-text-muted"
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
P && /* @__PURE__ */ e("button", { onClick: () => M(""), className: "text-dc-text-muted dc:hover:text-dc-text", children: /* @__PURE__ */ e(we, { className: "dc:w-3 dc:h-3" }) })
|
|
696
|
+
] }),
|
|
697
|
+
/* @__PURE__ */ a("div", { ref: X, className: "dc:relative dc:flex-1 dc:min-h-0", children: [
|
|
698
|
+
/* @__PURE__ */ e("div", { style: { position: "absolute", inset: 0 }, children: /* @__PURE__ */ a(
|
|
699
|
+
f,
|
|
700
|
+
{
|
|
701
|
+
nodes: ie,
|
|
702
|
+
edges: Te,
|
|
703
|
+
onNodesChange: Le,
|
|
704
|
+
onEdgesChange: Fe,
|
|
705
|
+
nodeTypes: tt,
|
|
706
|
+
edgeTypes: ct,
|
|
707
|
+
connectionMode: "loose",
|
|
708
|
+
minZoom: 0.1,
|
|
709
|
+
maxZoom: 2,
|
|
710
|
+
proOptions: { hideAttribution: !0 },
|
|
711
|
+
onPaneContextMenu: De,
|
|
712
|
+
onPaneClick: Pe,
|
|
713
|
+
children: [
|
|
714
|
+
/* @__PURE__ */ e(p, {}),
|
|
715
|
+
/* @__PURE__ */ e(
|
|
716
|
+
g,
|
|
717
|
+
{
|
|
718
|
+
nodeColor: (i) => l.includes(i.id) ? "#8b5cf6" : "#e5e7eb",
|
|
719
|
+
maskColor: "rgb(240, 242, 246, 0.7)"
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
/* @__PURE__ */ e(h, { variant: "dots", gap: 12, size: 1 }),
|
|
723
|
+
/* @__PURE__ */ e(nt, { token: Re })
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
) }),
|
|
727
|
+
T && c && $ && m && /* @__PURE__ */ e(
|
|
728
|
+
"div",
|
|
729
|
+
{
|
|
730
|
+
className: "dc:absolute dc:z-20",
|
|
731
|
+
style: { left: $.x, top: $.y },
|
|
732
|
+
children: /* @__PURE__ */ e(
|
|
733
|
+
qe,
|
|
734
|
+
{
|
|
735
|
+
selection: c,
|
|
736
|
+
meta: m,
|
|
737
|
+
onClose: () => {
|
|
738
|
+
y(null), E(null);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
}
|
|
743
|
+
)
|
|
744
|
+
] }),
|
|
745
|
+
C && /* @__PURE__ */ e(
|
|
746
|
+
"div",
|
|
747
|
+
{
|
|
748
|
+
className: "dc:fixed dc:z-50 bg-dc-surface dc:rounded-md dc:shadow-lg dc:border border-dc-border dc:py-1 dc:min-w-[120px]",
|
|
749
|
+
style: { left: C.x, top: C.y },
|
|
750
|
+
children: /* @__PURE__ */ e(
|
|
751
|
+
"button",
|
|
752
|
+
{
|
|
753
|
+
onClick: Ie,
|
|
754
|
+
className: "dc:w-full dc:px-3 dc:py-2 dc:text-sm text-dc-text-secondary dc:hover:bg-dc-surface-hover dc:text-left",
|
|
755
|
+
children: "Auto Layout"
|
|
756
|
+
}
|
|
757
|
+
)
|
|
758
|
+
}
|
|
759
|
+
)
|
|
760
|
+
] }) : /* @__PURE__ */ e("div", { className: `dc:flex dc:items-center dc:justify-center dc:h-96 ${t}`, children: /* @__PURE__ */ a("div", { className: "dc:text-center", children: [
|
|
761
|
+
/* @__PURE__ */ e("div", { className: "dc:animate-spin dc:rounded-full dc:h-8 dc:w-8 dc:border-b-2 border-dc-accent dc:mx-auto dc:mb-2" }),
|
|
762
|
+
/* @__PURE__ */ e("p", { className: "text-dc-text-muted", children: "Computing layout..." })
|
|
763
|
+
] }) });
|
|
764
|
+
}
|
|
765
|
+
const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
766
|
+
__proto__: null,
|
|
767
|
+
SchemaVisualization: rt
|
|
768
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
769
|
+
export {
|
|
770
|
+
ut as S
|
|
771
|
+
};
|
|
772
|
+
//# sourceMappingURL=schema-visualization-B97a1Ybu.js.map
|