@yuku123/z-graph-component 0.1.1 → 0.1.2

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,11 +1,12 @@
1
- import { D as p, G as s, a as i, c as o, g, b as h, i as t, d as e } from "./GraphApp-BWZfTdAD.js";
1
+ import { C as p, D as s, G as o, a as i, c as e, g, b as t, i as h, d as n } from "./ComponentDoc-yLmdiyDK.js";
2
2
  export {
3
- p as DEFAULT_BRANCH,
4
- s as GraphApp,
3
+ p as ComponentDocPage,
4
+ s as DEFAULT_BRANCH,
5
+ o as GraphApp,
5
6
  i as api,
6
- o as configureGraph,
7
+ e as configureGraph,
7
8
  g as graphApi,
8
- h as graphErrorText,
9
- t as isMutatingCypher,
10
- e as isNotBoundError
9
+ t as graphErrorText,
10
+ h as isMutatingCypher,
11
+ n as isNotBoundError
11
12
  };
package/dist/pages.js CHANGED
@@ -1,11 +1,11 @@
1
- import { j as e, a as W, s as Y, f as ae, G as Ne, I as Se } from "./GraphApp-BWZfTdAD.js";
2
- import { c as bt } from "./GraphApp-BWZfTdAD.js";
3
- import { UserOutlined as ve, LockOutlined as Te, HomeOutlined as Ee, DashboardOutlined as Ce, PartitionOutlined as Ae, BranchesOutlined as we, HistoryOutlined as ke, CodeOutlined as Ie, DatabaseOutlined as Le, ProfileOutlined as Re, FileTextOutlined as Oe } from "@ant-design/icons";
1
+ import { j as e, a as W, s as Y, f as ae, C as Ne, G as Se, I as ve } from "./ComponentDoc-yLmdiyDK.js";
2
+ import { c as St } from "./ComponentDoc-yLmdiyDK.js";
3
+ import { UserOutlined as Te, LockOutlined as Ee, HomeOutlined as Ce, DashboardOutlined as Ae, PartitionOutlined as we, BranchesOutlined as ke, HistoryOutlined as Ie, CodeOutlined as Re, DatabaseOutlined as Le, ProfileOutlined as Oe, FileTextOutlined as De, ReadOutlined as Me } from "@ant-design/icons";
4
4
  import { useState as N, useEffect as $, useRef as te, useCallback as K, useMemo as X } from "react";
5
- import { Typography as Me, Card as re, Space as oe, Tag as De, Row as He, Col as Pe, Form as Z, Input as le, Button as ze, message as ie } from "antd";
6
- import { useNavigate as We } from "react-router-dom";
5
+ import { Typography as He, Card as re, Space as oe, Tag as Pe, Row as ze, Col as We, Form as Z, Input as le, Button as Ge, message as ie } from "antd";
6
+ import { useNavigate as qe } from "react-router-dom";
7
7
  import "@yuku123/z-frontend-common/ui";
8
- function Ge(t) {
8
+ function $e(t) {
9
9
  const [r, o] = N({
10
10
  status: "unknown",
11
11
  head: null,
@@ -43,7 +43,7 @@ function Ge(t) {
43
43
  }
44
44
  function je(t) {
45
45
  return function() {
46
- const { server: o, metrics: a } = Ge();
46
+ const { server: o, metrics: a } = $e();
47
47
  return /* @__PURE__ */ e.jsx(t, { server: o, metrics: a });
48
48
  };
49
49
  }
@@ -53,7 +53,7 @@ function F(t) {
53
53
  return /* @__PURE__ */ e.jsx("div", { className: "zgc", children: /* @__PURE__ */ e.jsx(r, {}) });
54
54
  };
55
55
  }
56
- function qe({ server: t }) {
56
+ function Ue({ server: t }) {
57
57
  const [r, o] = N([]), [a, d] = N([]), [p, S] = N(null), [f, x] = N(!0), [l, C] = N(null), [j, v] = N([]), A = te(null);
58
58
  $(() => {
59
59
  let s = !1;
@@ -283,7 +283,7 @@ function ce({ data: t, dataKey: r, title: o, color: a, unit: d, format: p }) {
283
283
  ] });
284
284
  }
285
285
  const de = ["#3b82f6", "#10b981", "#f59e0b", "#ef4444", "#8b5cf6", "#06b6d4", "#ec4899", "#84cc16"], B = 24;
286
- function $e({ server: t }) {
286
+ function Be({ server: t }) {
287
287
  const [r, o] = N(null), [a, d] = N(!1), [p, S] = N(null), [f, x] = N(null), [l, C] = N(null), j = te(null), [v, A] = N({ width: 800, height: 500 });
288
288
  $(() => {
289
289
  var c;
@@ -310,14 +310,14 @@ function $e({ server: t }) {
310
310
  const y = w.Name || w.name || "";
311
311
  if (y)
312
312
  try {
313
- const L = await W.query(`MATCH (a)-[r:${y}]->(b) RETURN a, r, b`, "main");
314
- for (const R of L || []) {
315
- const O = typeof R.a == "string" ? V(R.a) : R.a, z = typeof R.b == "string" ? V(R.b) : R.b, D = typeof R.r == "string" ? Ue(R.r) : R.r;
313
+ const R = await W.query(`MATCH (a)-[r:${y}]->(b) RETURN a, r, b`, "main");
314
+ for (const L of R || []) {
315
+ const O = typeof L.a == "string" ? V(L.a) : L.a, z = typeof L.b == "string" ? V(L.b) : L.b, M = typeof L.r == "string" ? Fe(L.r) : L.r;
316
316
  b.push({
317
317
  source: O._id,
318
318
  target: z._id,
319
319
  type: y,
320
- props: D
320
+ props: M
321
321
  });
322
322
  }
323
323
  } catch {
@@ -328,9 +328,9 @@ function $e({ server: t }) {
328
328
  try {
329
329
  const y = await W.query(`MATCH (a)-[r:${w}]->(b) RETURN a, r, b`, "main");
330
330
  if (Array.isArray(y) && y.length > 0)
331
- for (const L of y) {
332
- const R = typeof L.a == "string" ? V(L.a) : L.a, O = typeof L.b == "string" ? V(L.b) : L.b;
333
- b.push({ source: R._id, target: O._id, type: w, props: {} });
331
+ for (const R of y) {
332
+ const L = typeof R.a == "string" ? V(R.a) : R.a, O = typeof R.b == "string" ? V(R.b) : R.b;
333
+ b.push({ source: L._id, target: O._id, type: w, props: {} });
334
334
  }
335
335
  } catch {
336
336
  }
@@ -364,14 +364,14 @@ function $e({ server: t }) {
364
364
  for (let T = 0; T < 120; T++) {
365
365
  const w = 1 - T / 120;
366
366
  for (let y = 0; y < i.length; y++)
367
- for (let L = y + 1; L < i.length; L++) {
368
- let R = i[L].x - i[y].x, O = i[L].y - i[y].y, z = Math.sqrt(R * R + O * O) || 1, D = 800 * w / z;
369
- i[y].vx -= R / z * D, i[y].vy -= O / z * D, i[L].vx += R / z * D, i[L].vy += O / z * D;
367
+ for (let R = y + 1; R < i.length; R++) {
368
+ let L = i[R].x - i[y].x, O = i[R].y - i[y].y, z = Math.sqrt(L * L + O * O) || 1, M = 800 * w / z;
369
+ i[y].vx -= L / z * M, i[y].vy -= O / z * M, i[R].vx += L / z * M, i[R].vy += O / z * M;
370
370
  }
371
371
  for (const y of c) {
372
- const L = i[y.sourceIdx], R = i[y.targetIdx];
373
- let O = R.x - L.x, z = R.y - L.y, D = Math.sqrt(O * O + z * z) || 1, G = (D - 120) * 0.05 * w;
374
- L.vx += O / D * G, L.vy += z / D * G, R.vx -= O / D * G, R.vy -= z / D * G;
372
+ const R = i[y.sourceIdx], L = i[y.targetIdx];
373
+ let O = L.x - R.x, z = L.y - R.y, M = Math.sqrt(O * O + z * z) || 1, G = (M - 120) * 0.05 * w;
374
+ R.vx += O / M * G, R.vy += z / M * G, L.vx -= O / M * G, L.vy -= z / M * G;
375
375
  }
376
376
  for (const y of i)
377
377
  y.vx += (b - y.x) * 0.01 * w, y.vy += (E - y.y) * 0.01 * w;
@@ -405,11 +405,11 @@ function $e({ server: t }) {
405
405
  function m(i, c) {
406
406
  const b = l.nodes[i.sourceIdx], E = l.nodes[i.targetIdx];
407
407
  if (!b || !E) return null;
408
- const T = E.x - b.x, w = E.y - b.y, y = Math.sqrt(T * T + w * w) || 1, L = T / y, R = w / y, O = b.x + L * B, z = b.y + R * B, D = E.x - L * B, G = E.y - R * B, u = f !== null && (i.sourceIdx === f || i.targetIdx === f), P = f !== null && !u, I = 10, M = Math.atan2(G - z, D - O), H = D - I * Math.cos(M - 0.35), q = G - I * Math.sin(M - 0.35), se = D - I * Math.cos(M + 0.35), be = G - I * Math.sin(M + 0.35);
408
+ const T = E.x - b.x, w = E.y - b.y, y = Math.sqrt(T * T + w * w) || 1, R = T / y, L = w / y, O = b.x + R * B, z = b.y + L * B, M = E.x - R * B, G = E.y - L * B, u = f !== null && (i.sourceIdx === f || i.targetIdx === f), P = f !== null && !u, I = 10, D = Math.atan2(G - z, M - O), H = M - I * Math.cos(D - 0.35), q = G - I * Math.sin(D - 0.35), se = M - I * Math.cos(D + 0.35), be = G - I * Math.sin(D + 0.35);
409
409
  return /* @__PURE__ */ e.jsxs("g", { style: { opacity: P ? 0.15 : 1 }, children: [
410
- /* @__PURE__ */ e.jsx("line", { x1: O, y1: z, x2: D, y2: G, stroke: u ? "#60a5fa" : "#475569", strokeWidth: u ? 2.5 : 1.5 }),
411
- /* @__PURE__ */ e.jsx("polygon", { points: `${D},${G} ${H},${q} ${se},${be}`, fill: u ? "#60a5fa" : "#475569" }),
412
- i.type && /* @__PURE__ */ e.jsx("text", { x: (O + D) / 2, y: (z + G) / 2 - 6, textAnchor: "middle", fill: "#64748b", fontSize: "9", style: { pointerEvents: "none" }, children: i.type })
410
+ /* @__PURE__ */ e.jsx("line", { x1: O, y1: z, x2: M, y2: G, stroke: u ? "#60a5fa" : "#475569", strokeWidth: u ? 2.5 : 1.5 }),
411
+ /* @__PURE__ */ e.jsx("polygon", { points: `${M},${G} ${H},${q} ${se},${be}`, fill: u ? "#60a5fa" : "#475569" }),
412
+ i.type && /* @__PURE__ */ e.jsx("text", { x: (O + M) / 2, y: (z + G) / 2 - 6, textAnchor: "middle", fill: "#64748b", fontSize: "9", style: { pointerEvents: "none" }, children: i.type })
413
413
  ] }, c);
414
414
  }
415
415
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
@@ -461,14 +461,14 @@ function V(t) {
461
461
  S && f && (d[S] = isNaN(f) ? f.replace(/^'|'$/g, "") : Number(f));
462
462
  }), d;
463
463
  }
464
- function Ue(t) {
464
+ function Fe(t) {
465
465
  const r = t.match(/\}\s*\{(.*?)\}/) || t.match(/\{(.*)\}/), o = {};
466
466
  return r && r[1] && r[1].split(",").forEach((a) => {
467
467
  const [d, p] = a.split("=").map((S) => S.trim());
468
468
  d && p && (o[d] = isNaN(p) ? p.replace(/^'|'$/g, "") : Number(p));
469
469
  }), o;
470
470
  }
471
- function Be({ server: t }) {
471
+ function _e({ server: t }) {
472
472
  const [r, o] = N([]), [a, d] = N({}), [p, S] = N([]), [f, x] = N(!0), [l, C] = N(null);
473
473
  $(() => {
474
474
  let v = !1;
@@ -560,7 +560,7 @@ const he = [
560
560
  "#f472b6"
561
561
  // pink
562
562
  ];
563
- function Fe({ server: t }) {
563
+ function Ke({ server: t }) {
564
564
  const [r, o] = N([]), [a, d] = N(!0), [p, S] = N(null), [f, x] = N(""), [l, C] = N(""), [j, v] = N(null);
565
565
  $(() => {
566
566
  let g = !1;
@@ -608,7 +608,7 @@ function Fe({ server: t }) {
608
608
  p && /* @__PURE__ */ e.jsx("div", { className: "error-banner", children: p }),
609
609
  !a && k.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "empty", children: "没有匹配的 commit" }),
610
610
  !a && k.length > 0 && /* @__PURE__ */ e.jsx(
611
- _e,
611
+ Je,
612
612
  {
613
613
  commits: k,
614
614
  branches: A,
@@ -679,7 +679,7 @@ function _(t, r) {
679
679
  const o = t.indexOf(r);
680
680
  return he[o % he.length];
681
681
  }
682
- function _e({ commits: t, branches: r, selected: o, onSelect: a }) {
682
+ function Je({ commits: t, branches: r, selected: o, onSelect: a }) {
683
683
  const d = X(
684
684
  () => [...t].sort((h, n) => (n.timestamp || 0) - (h.timestamp || 0)),
685
685
  [t]
@@ -794,7 +794,7 @@ function _e({ commits: t, branches: r, selected: o, onSelect: a }) {
794
794
  ),
795
795
  A.map((h, n) => {
796
796
  var P, I;
797
- const { from: s, to: m, color: i, isMerge: c, isMainParent: b } = h, E = (o == null ? void 0 : o.id) === ((P = s.commit) == null ? void 0 : P.id) || (o == null ? void 0 : o.id) === ((I = m.commit) == null ? void 0 : I.id), T = s.x - f - 2, w = s.y, y = m.x + f + 2, L = m.y;
797
+ const { from: s, to: m, color: i, isMerge: c, isMainParent: b } = h, E = (o == null ? void 0 : o.id) === ((P = s.commit) == null ? void 0 : P.id) || (o == null ? void 0 : o.id) === ((I = m.commit) == null ? void 0 : I.id), T = s.x - f - 2, w = s.y, y = m.x + f + 2, R = m.y;
798
798
  if (s.lane === m.lane)
799
799
  return /* @__PURE__ */ e.jsx(
800
800
  "line",
@@ -802,14 +802,14 @@ function _e({ commits: t, branches: r, selected: o, onSelect: a }) {
802
802
  x1: T,
803
803
  y1: w,
804
804
  x2: y,
805
- y2: L,
805
+ y2: R,
806
806
  stroke: E ? "#60a5fa" : i,
807
807
  strokeWidth: E ? 2.5 : 2,
808
808
  markerEnd: E ? "url(#arrowhead-active)" : "url(#arrowhead)"
809
809
  },
810
810
  n
811
811
  );
812
- const R = y - T, O = T + R * 0.3, z = w, D = y - R * 0.3, u = `M ${T},${w} C ${O},${z} ${D},${L} ${y},${L}`;
812
+ const L = y - T, O = T + L * 0.3, z = w, M = y - L * 0.3, u = `M ${T},${w} C ${O},${z} ${M},${R} ${y},${R}`;
813
813
  return /* @__PURE__ */ e.jsx(
814
814
  "path",
815
815
  {
@@ -1017,7 +1017,7 @@ function _e({ commits: t, branches: r, selected: o, onSelect: a }) {
1017
1017
  ] })
1018
1018
  ] });
1019
1019
  }
1020
- const Ke = /* @__PURE__ */ new Set([
1020
+ const Xe = /* @__PURE__ */ new Set([
1021
1021
  "MATCH",
1022
1022
  "RETURN",
1023
1023
  "CREATE",
@@ -1091,7 +1091,7 @@ const Ke = /* @__PURE__ */ new Set([
1091
1091
  "db.tags",
1092
1092
  "db.edges",
1093
1093
  "db.indexes"
1094
- ]), Je = [
1094
+ ]), Ve = [
1095
1095
  // 关键字
1096
1096
  { text: "MATCH", desc: "模式匹配", category: "keyword" },
1097
1097
  { text: "RETURN", desc: "返回结果", category: "keyword" },
@@ -1157,7 +1157,7 @@ const Ke = /* @__PURE__ */ new Set([
1157
1157
  pattern: "#86efac",
1158
1158
  ddl: "#fbbf24"
1159
1159
  };
1160
- function Xe({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1160
+ function Ye({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1161
1161
  const d = te(null), p = te(null), [S, f] = N([]), [x, l] = N(0), [C, j] = N(!1), [v, A] = N({ top: 0, left: 0 }), k = K(() => {
1162
1162
  d.current && p.current && (d.current.scrollTop = p.current.scrollTop, d.current.scrollLeft = p.current.scrollLeft);
1163
1163
  }, []);
@@ -1178,7 +1178,7 @@ function Xe({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1178
1178
  r(b);
1179
1179
  const E = c.target.selectionStart, T = g(b, E);
1180
1180
  if (T.length >= 1) {
1181
- const w = Je.filter(
1181
+ const w = Ve.filter(
1182
1182
  (y) => y.text.toLowerCase().startsWith(T.toLowerCase()) || y.desc.includes(T)
1183
1183
  ).slice(0, 12);
1184
1184
  w.length > 0 ? (f(w), l(0), j(!0), A(h(c.target, E))) : j(!1);
@@ -1208,8 +1208,8 @@ function Xe({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1208
1208
  function m(c) {
1209
1209
  const b = p.current;
1210
1210
  if (!b) return;
1211
- const E = b.selectionStart, T = b.value, w = g(T, E), y = T.substring(0, E - w.length), L = T.substring(E), R = y + c.text + L;
1212
- r(R), j(!1), setTimeout(() => {
1211
+ const E = b.selectionStart, T = b.value, w = g(T, E), y = T.substring(0, E - w.length), R = T.substring(E), L = y + c.text + R;
1212
+ r(L), j(!1), setTimeout(() => {
1213
1213
  const O = E - w.length + c.text.length;
1214
1214
  b.setSelectionRange(O, O), b.focus();
1215
1215
  }, 0);
@@ -1221,7 +1221,7 @@ function Xe({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1221
1221
  }
1222
1222
  return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
1223
1223
  }, [C]);
1224
- const i = Ve(t || "");
1224
+ const i = Ze(t || "");
1225
1225
  return /* @__PURE__ */ e.jsxs("div", { className: "cypher-editor-wrap", style: { position: "relative" }, children: [
1226
1226
  /* @__PURE__ */ e.jsx(
1227
1227
  "pre",
@@ -1340,7 +1340,7 @@ function Xe({ value: t, onChange: r, onKeyDown: o, rows: a = 10 }) {
1340
1340
  )
1341
1341
  ] });
1342
1342
  }
1343
- function Ve(t) {
1343
+ function Ze(t) {
1344
1344
  const r = [];
1345
1345
  let o = 0;
1346
1346
  for (; o < t.length; ) {
@@ -1374,7 +1374,7 @@ function Ve(t) {
1374
1374
  let a = o;
1375
1375
  for (; a < t.length && /[a-zA-Z0-9_]/.test(t[a]); ) a++;
1376
1376
  const d = t.substring(o, a), p = d.toUpperCase();
1377
- Ke.has(p) ? r.push(`<span class="hl-keyword">${U(d)}</span>`) : me.has(p) || me.has(d.toLowerCase()) ? r.push(`<span class="hl-builtin">${U(d)}</span>`) : a < t.length && t[a] === "(" ? r.push(`<span class="hl-function">${U(d)}</span>`) : p === "ASC" || p === "DESC" ? r.push(`<span class="hl-keyword">${U(d)}</span>`) : r.push(U(d)), o = a;
1377
+ Xe.has(p) ? r.push(`<span class="hl-keyword">${U(d)}</span>`) : me.has(p) || me.has(d.toLowerCase()) ? r.push(`<span class="hl-builtin">${U(d)}</span>`) : a < t.length && t[a] === "(" ? r.push(`<span class="hl-function">${U(d)}</span>`) : p === "ASC" || p === "DESC" ? r.push(`<span class="hl-keyword">${U(d)}</span>`) : r.push(U(d)), o = a;
1378
1378
  continue;
1379
1379
  }
1380
1380
  if ("-><-[]{}(),:.;=<>!+".includes(t[o])) {
@@ -1407,7 +1407,7 @@ const ne = {
1407
1407
  "SHOW STATS": "CALL db.stats()",
1408
1408
  EXPLAIN: "EXPLAIN MATCH (n:Person) WHERE n.age > 20 RETURN n"
1409
1409
  };
1410
- function Ye({ server: t }) {
1410
+ function Qe({ server: t }) {
1411
1411
  const [r, o] = N(ne.节点与边), [a, d] = N("main"), [p, S] = N(""), [f, x] = N([]), [l, C] = N([]), [j, v] = N("branch"), [A, k] = N(!1), [g, h] = N(null), [n, s] = N(null), [m, i] = N(null), [c, b] = N(() => {
1412
1412
  try {
1413
1413
  return JSON.parse(localStorage.getItem("z-graph-history") || "[]");
@@ -1419,7 +1419,7 @@ function Ye({ server: t }) {
1419
1419
  let u = !1;
1420
1420
  async function P() {
1421
1421
  try {
1422
- const [I, M] = await Promise.all([W.branches(), W.commits()]), H = Array.isArray(I) ? I : I && I.Name ? [I.Name] : [], q = Array.isArray(M) ? M : [];
1422
+ const [I, D] = await Promise.all([W.branches(), W.commits()]), H = Array.isArray(I) ? I : I && I.Name ? [I.Name] : [], q = Array.isArray(D) ? D : [];
1423
1423
  x(H), C(q), H.length && !H.find((se) => se === a) && d(H[0]);
1424
1424
  } catch {
1425
1425
  }
@@ -1427,10 +1427,10 @@ function Ye({ server: t }) {
1427
1427
  P();
1428
1428
  }, [t.head]);
1429
1429
  function w(u, P) {
1430
- const I = { cypher: u.substring(0, 200), time: Date.now(), elapsed: P, branch: a }, M = [I, ...c.filter((H) => H.cypher !== I.cypher)].slice(0, 50);
1431
- b(M);
1430
+ const I = { cypher: u.substring(0, 200), time: Date.now(), elapsed: P, branch: a }, D = [I, ...c.filter((H) => H.cypher !== I.cypher)].slice(0, 50);
1431
+ b(D);
1432
1432
  try {
1433
- localStorage.setItem("z-graph-history", JSON.stringify(M));
1433
+ localStorage.setItem("z-graph-history", JSON.stringify(D));
1434
1434
  } catch {
1435
1435
  }
1436
1436
  }
@@ -1451,10 +1451,10 @@ function Ye({ server: t }) {
1451
1451
  k(!1);
1452
1452
  }
1453
1453
  }, [r, a, p, j]);
1454
- function L(u) {
1454
+ function R(u) {
1455
1455
  o(ne[u]);
1456
1456
  }
1457
- function R(u) {
1457
+ function L(u) {
1458
1458
  o(u.cypher), u.branch && d(u.branch), T(!1);
1459
1459
  }
1460
1460
  function O(u) {
@@ -1462,20 +1462,20 @@ function Ye({ server: t }) {
1462
1462
  if (typeof u == "string") return /* @__PURE__ */ e.jsx("pre", { children: u });
1463
1463
  if (Array.isArray(u)) {
1464
1464
  if (u.length === 0) return /* @__PURE__ */ e.jsx("div", { className: "empty", children: "0 行结果" });
1465
- const P = Array.from(u.reduce((I, M) => (M && typeof M == "object" && Object.keys(M).forEach((H) => I.add(H)), I), /* @__PURE__ */ new Set()));
1465
+ const P = Array.from(u.reduce((I, D) => (D && typeof D == "object" && Object.keys(D).forEach((H) => I.add(H)), I), /* @__PURE__ */ new Set()));
1466
1466
  return /* @__PURE__ */ e.jsxs("table", { children: [
1467
1467
  /* @__PURE__ */ e.jsx("thead", { children: /* @__PURE__ */ e.jsx("tr", { children: P.map((I) => /* @__PURE__ */ e.jsx("th", { children: I }, I)) }) }),
1468
- /* @__PURE__ */ e.jsx("tbody", { children: u.map((I, M) => /* @__PURE__ */ e.jsx("tr", { children: P.map((H) => /* @__PURE__ */ e.jsx("td", { className: "mono", children: Ze(I[H]) }, H)) }, M)) })
1468
+ /* @__PURE__ */ e.jsx("tbody", { children: u.map((I, D) => /* @__PURE__ */ e.jsx("tr", { children: P.map((H) => /* @__PURE__ */ e.jsx("td", { className: "mono", children: et(I[H]) }, H)) }, D)) })
1469
1469
  ] });
1470
1470
  }
1471
1471
  return /* @__PURE__ */ e.jsx("pre", { children: JSON.stringify(u, null, 2) });
1472
1472
  }
1473
1473
  function z() {
1474
1474
  if (!g || !Array.isArray(g) || g.length === 0) return;
1475
- const u = Array.from(g.reduce((I, M) => (M && typeof M == "object" && Object.keys(M).forEach((H) => I.add(H)), I), /* @__PURE__ */ new Set())), P = [u.join(",")];
1475
+ const u = Array.from(g.reduce((I, D) => (D && typeof D == "object" && Object.keys(D).forEach((H) => I.add(H)), I), /* @__PURE__ */ new Set())), P = [u.join(",")];
1476
1476
  for (const I of g)
1477
- P.push(u.map((M) => {
1478
- const H = I[M];
1477
+ P.push(u.map((D) => {
1478
+ const H = I[D];
1479
1479
  if (H == null) return "";
1480
1480
  const q = typeof H == "object" ? JSON.stringify(H) : String(H);
1481
1481
  return q.includes(",") || q.includes('"') || q.includes(`
@@ -1484,13 +1484,13 @@ function Ye({ server: t }) {
1484
1484
  G(P.join(`
1485
1485
  `), "z-graph-query.csv", "text/csv;charset=utf-8");
1486
1486
  }
1487
- function D() {
1487
+ function M() {
1488
1488
  if (!g) return;
1489
1489
  const u = JSON.stringify(g, null, 2);
1490
1490
  G(u, "z-graph-query.json", "application/json;charset=utf-8");
1491
1491
  }
1492
1492
  function G(u, P, I) {
1493
- const M = new Blob([u], { type: I }), H = URL.createObjectURL(M), q = document.createElement("a");
1493
+ const D = new Blob([u], { type: I }), H = URL.createObjectURL(D), q = document.createElement("a");
1494
1494
  q.href = H, q.download = P, document.body.appendChild(q), q.click(), document.body.removeChild(q), URL.revokeObjectURL(H);
1495
1495
  }
1496
1496
  return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
@@ -1498,7 +1498,7 @@ function Ye({ server: t }) {
1498
1498
  /* @__PURE__ */ e.jsxs("div", { className: "toolbar", children: [
1499
1499
  /* @__PURE__ */ e.jsx("button", { className: "primary", disabled: A || !r.trim(), onClick: y, children: A ? "执行中…" : "执行" }),
1500
1500
  /* @__PURE__ */ e.jsx("button", { onClick: () => o(""), disabled: A, children: "清空" }),
1501
- /* @__PURE__ */ e.jsxs("select", { onChange: (u) => L(u.target.value), value: "", children: [
1501
+ /* @__PURE__ */ e.jsxs("select", { onChange: (u) => R(u.target.value), value: "", children: [
1502
1502
  /* @__PURE__ */ e.jsx("option", { value: "", disabled: !0, children: "载入示例…" }),
1503
1503
  Object.keys(ne).map((u) => /* @__PURE__ */ e.jsx("option", { value: u, children: u }, u))
1504
1504
  ] }),
@@ -1515,7 +1515,7 @@ function Ye({ server: t }) {
1515
1515
  ] }),
1516
1516
  E && /* @__PURE__ */ e.jsxs("div", { className: "history-panel", children: [
1517
1517
  c.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "muted", children: "暂无历史" }),
1518
- c.slice(0, 20).map((u, P) => /* @__PURE__ */ e.jsxs("div", { className: "history-item", onClick: () => R(u), children: [
1518
+ c.slice(0, 20).map((u, P) => /* @__PURE__ */ e.jsxs("div", { className: "history-item", onClick: () => L(u), children: [
1519
1519
  /* @__PURE__ */ e.jsxs("span", { className: "history-cypher mono", children: [
1520
1520
  u.cypher.substring(0, 80),
1521
1521
  u.cypher.length > 80 ? "…" : ""
@@ -1537,7 +1537,7 @@ function Ye({ server: t }) {
1537
1537
  ] }, u.id))
1538
1538
  ] }) }),
1539
1539
  /* @__PURE__ */ e.jsx(
1540
- Xe,
1540
+ Ye,
1541
1541
  {
1542
1542
  value: r,
1543
1543
  onChange: o,
@@ -1561,7 +1561,7 @@ function Ye({ server: t }) {
1561
1561
  ] }),
1562
1562
  g && Array.isArray(g) && g.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "toolbar", children: [
1563
1563
  /* @__PURE__ */ e.jsx("button", { onClick: z, children: "📥 CSV" }),
1564
- /* @__PURE__ */ e.jsx("button", { onClick: D, children: "📥 JSON" })
1564
+ /* @__PURE__ */ e.jsx("button", { onClick: M, children: "📥 JSON" })
1565
1565
  ] })
1566
1566
  ] }),
1567
1567
  n && /* @__PURE__ */ e.jsx("div", { className: "results", children: /* @__PURE__ */ e.jsx("pre", { className: "error", children: n }) }),
@@ -1570,7 +1570,7 @@ function Ye({ server: t }) {
1570
1570
  ] })
1571
1571
  ] });
1572
1572
  }
1573
- function Ze(t) {
1573
+ function et(t) {
1574
1574
  return t == null ? "" : typeof t == "object" ? JSON.stringify(t) : String(t);
1575
1575
  }
1576
1576
  const ue = [
@@ -1592,7 +1592,7 @@ RETURN n.age AS age, count(n) AS count ORDER BY age`, category: "查询" },
1592
1592
  { label: "OPTIONAL MATCH", cypher: `MATCH (a:Person)-[r?:KNOWS]->(b:Person)
1593
1593
  RETURN a.name AS from, b.name AS to`, category: "查询" }
1594
1594
  ];
1595
- function Qe({ server: t }) {
1595
+ function tt({ server: t }) {
1596
1596
  const [r, o] = N("TAGS"), [a, d] = N([]), [p, S] = N(!1), [f, x] = N(null), [l, C] = N(null), [j, v] = N(null), [A, k] = N(!1), g = K(async () => {
1597
1597
  S(!0), x(null);
1598
1598
  try {
@@ -1658,29 +1658,29 @@ function Qe({ server: t }) {
1658
1658
  "尚无 ",
1659
1659
  r.toLowerCase()
1660
1660
  ] }),
1661
- !f && a.length > 0 && /* @__PURE__ */ e.jsx(et, { rows: a })
1661
+ !f && a.length > 0 && /* @__PURE__ */ e.jsx(st, { rows: a })
1662
1662
  ] })
1663
1663
  ] });
1664
1664
  }
1665
1665
  function xe(t) {
1666
1666
  return t === "TAGS" ? "SHOW TAGS" : t === "EDGES" ? "SHOW EDGES" : "SHOW INDEXES";
1667
1667
  }
1668
- function et({ rows: t }) {
1668
+ function st({ rows: t }) {
1669
1669
  const r = Array.from(t.reduce((o, a) => (Object.keys(a || {}).forEach((d) => o.add(d)), o), /* @__PURE__ */ new Set()));
1670
1670
  return /* @__PURE__ */ e.jsxs("table", { children: [
1671
1671
  /* @__PURE__ */ e.jsx("thead", { children: /* @__PURE__ */ e.jsx("tr", { children: r.map((o) => /* @__PURE__ */ e.jsx("th", { children: o }, o)) }) }),
1672
- /* @__PURE__ */ e.jsx("tbody", { children: t.map((o, a) => /* @__PURE__ */ e.jsx("tr", { children: r.map((d) => /* @__PURE__ */ e.jsx("td", { className: "mono", children: tt(o[d]) }, d)) }, a)) })
1672
+ /* @__PURE__ */ e.jsx("tbody", { children: t.map((o, a) => /* @__PURE__ */ e.jsx("tr", { children: r.map((d) => /* @__PURE__ */ e.jsx("td", { className: "mono", children: nt(o[d]) }, d)) }, a)) })
1673
1673
  ] });
1674
1674
  }
1675
- function tt(t) {
1675
+ function nt(t) {
1676
1676
  return t == null ? "" : typeof t == "object" ? JSON.stringify(t) : String(t);
1677
1677
  }
1678
- const st = {
1678
+ const rt = {
1679
1679
  GET: "#86efac",
1680
1680
  POST: "#93c5fd",
1681
1681
  OPTIONS: "#94a3b8"
1682
1682
  };
1683
- function nt() {
1683
+ function at() {
1684
1684
  var g, h;
1685
1685
  const [t, r] = N(null), [o, a] = N(!0), [d, p] = N(null), [S, f] = N(!0), [x, l] = N({ method: "", status: "", path: "", requestId: "" }), [C, j] = N(null), v = K(async () => {
1686
1686
  try {
@@ -1812,7 +1812,7 @@ function nt() {
1812
1812
  "span",
1813
1813
  {
1814
1814
  className: "log-method",
1815
- style: { color: st[n.method] || "#94a3b8" },
1815
+ style: { color: rt[n.method] || "#94a3b8" },
1816
1816
  children: n.method
1817
1817
  }
1818
1818
  ) }),
@@ -1958,7 +1958,7 @@ const ge = [
1958
1958
  response: "{ imported, branch, elapsedMs }"
1959
1959
  }
1960
1960
  ];
1961
- function rt() {
1961
+ function ot() {
1962
1962
  const [t, r] = N(null), [o, a] = N(null), [d, p] = N(!1), [S, f] = N(null);
1963
1963
  async function x(l) {
1964
1964
  p(!0), a(null), f(null);
@@ -2047,9 +2047,9 @@ async function fe(t, r = {}) {
2047
2047
  return a;
2048
2048
  }
2049
2049
  }
2050
- const { Title: at, Paragraph: ot } = Me;
2051
- function lt() {
2052
- const t = We(), [r, o] = N(null);
2050
+ const { Title: lt, Paragraph: it } = He;
2051
+ function ct() {
2052
+ const t = qe(), [r, o] = N(null);
2053
2053
  $(() => {
2054
2054
  const d = localStorage.getItem("userInfo");
2055
2055
  if (d)
@@ -2059,17 +2059,17 @@ function lt() {
2059
2059
  o({ name: d });
2060
2060
  }
2061
2061
  }, []);
2062
- const a = it.filter((d) => d.key !== "/z-graph/home");
2062
+ const a = dt.filter((d) => d.key !== "/z-graph/home");
2063
2063
  return /* @__PURE__ */ e.jsxs("div", { children: [
2064
2064
  /* @__PURE__ */ e.jsx(re, { style: { marginBottom: 16, background: "linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%)", border: "none" }, children: /* @__PURE__ */ e.jsxs(oe, { direction: "vertical", size: 4, style: { color: "#fff" }, children: [
2065
- /* @__PURE__ */ e.jsxs(at, { level: 3, style: { color: "#fff", margin: 0 }, children: [
2065
+ /* @__PURE__ */ e.jsxs(lt, { level: 3, style: { color: "#fff", margin: 0 }, children: [
2066
2066
  "欢迎",
2067
2067
  r != null && r.name ? `,${r.name}` : ""
2068
2068
  ] }),
2069
- /* @__PURE__ */ e.jsx(ot, { style: { color: "rgba(255,255,255,0.85)", margin: 0 }, children: "z-graph 图存储控制台 管理台" }),
2070
- (r == null ? void 0 : r.role) && /* @__PURE__ */ e.jsx(De, { style: { marginTop: 8, background: "rgba(255,255,255,0.2)", color: "#fff", border: "none" }, children: r.role })
2069
+ /* @__PURE__ */ e.jsx(it, { style: { color: "rgba(255,255,255,0.85)", margin: 0 }, children: "z-graph 图存储控制台 管理台" }),
2070
+ (r == null ? void 0 : r.role) && /* @__PURE__ */ e.jsx(Pe, { style: { marginTop: 8, background: "rgba(255,255,255,0.2)", color: "#fff", border: "none" }, children: r.role })
2071
2071
  ] }) }),
2072
- /* @__PURE__ */ e.jsx(He, { gutter: [16, 16], children: a.map((d) => /* @__PURE__ */ e.jsx(Pe, { xs: 24, sm: 12, md: 12, lg: 8, children: /* @__PURE__ */ e.jsx(re, { hoverable: !0, onClick: () => t(d.key), style: { borderTop: "3px solid #7c3aed" }, children: /* @__PURE__ */ e.jsxs(oe, { align: "start", size: 12, children: [
2072
+ /* @__PURE__ */ e.jsx(ze, { gutter: [16, 16], children: a.map((d) => /* @__PURE__ */ e.jsx(We, { xs: 24, sm: 12, md: 12, lg: 8, children: /* @__PURE__ */ e.jsx(re, { hoverable: !0, onClick: () => t(d.key), style: { borderTop: "3px solid #7c3aed" }, children: /* @__PURE__ */ e.jsxs(oe, { align: "start", size: 12, children: [
2073
2073
  /* @__PURE__ */ e.jsx("div", { style: {
2074
2074
  width: 44,
2075
2075
  height: 44,
@@ -2090,7 +2090,7 @@ function lt() {
2090
2090
  ] });
2091
2091
  }
2092
2092
  const J = { username: "admin", password: "123456", user: { name: "admin", role: "管理员" } };
2093
- function xt() {
2093
+ function yt() {
2094
2094
  const [t, r] = N(!1), o = async (a) => {
2095
2095
  r(!0);
2096
2096
  try {
@@ -2123,10 +2123,10 @@ function xt() {
2123
2123
  /* @__PURE__ */ e.jsx("div", { style: { fontSize: 18, fontWeight: 600, color: "#0f172a" }, children: "z-graph 管理台" })
2124
2124
  ] }),
2125
2125
  /* @__PURE__ */ e.jsxs(Z, { onFinish: o, size: "large", children: [
2126
- /* @__PURE__ */ e.jsx(Z.Item, { name: "username", rules: [{ required: !0, message: "请输入用户名" }], children: /* @__PURE__ */ e.jsx(le, { prefix: /* @__PURE__ */ e.jsx(ve, {}), placeholder: "用户名" }) }),
2127
- /* @__PURE__ */ e.jsx(Z.Item, { name: "password", rules: [{ required: !0, message: "请输入密码" }], children: /* @__PURE__ */ e.jsx(le.Password, { prefix: /* @__PURE__ */ e.jsx(Te, {}), placeholder: "密码" }) }),
2126
+ /* @__PURE__ */ e.jsx(Z.Item, { name: "username", rules: [{ required: !0, message: "请输入用户名" }], children: /* @__PURE__ */ e.jsx(le, { prefix: /* @__PURE__ */ e.jsx(Te, {}), placeholder: "用户名" }) }),
2127
+ /* @__PURE__ */ e.jsx(Z.Item, { name: "password", rules: [{ required: !0, message: "请输入密码" }], children: /* @__PURE__ */ e.jsx(le.Password, { prefix: /* @__PURE__ */ e.jsx(Ee, {}), placeholder: "密码" }) }),
2128
2128
  /* @__PURE__ */ e.jsx(Z.Item, { style: { marginBottom: 8 }, children: /* @__PURE__ */ e.jsx(
2129
- ze,
2129
+ Ge,
2130
2130
  {
2131
2131
  type: "primary",
2132
2132
  htmlType: "submit",
@@ -2145,42 +2145,45 @@ function xt() {
2145
2145
  ] })
2146
2146
  ] }) });
2147
2147
  }
2148
- const gt = { title: "z-graph 图存储控制台", short: "z-graph" }, it = [
2149
- { key: "/z-graph/home", label: "首页", icon: /* @__PURE__ */ e.jsx(Ee, {}) },
2150
- { key: "/z-graph/dashboard", label: "总览", icon: /* @__PURE__ */ e.jsx(Ce, {}) },
2151
- { key: "/z-graph/graph", label: "图视图", icon: /* @__PURE__ */ e.jsx(Ae, {}) },
2152
- { key: "/z-graph/branches", label: "分支", icon: /* @__PURE__ */ e.jsx(we, {}) },
2153
- { key: "/z-graph/commits", label: "提交历史", icon: /* @__PURE__ */ e.jsx(ke, {}) },
2154
- { key: "/z-graph/query", label: "Cypher 查询", icon: /* @__PURE__ */ e.jsx(Ie, {}) },
2148
+ const ft = { title: "z-graph 图存储控制台", short: "z-graph" }, dt = [
2149
+ { key: "/z-graph/home", label: "首页", icon: /* @__PURE__ */ e.jsx(Ce, {}) },
2150
+ { key: "/z-graph/dashboard", label: "总览", icon: /* @__PURE__ */ e.jsx(Ae, {}) },
2151
+ { key: "/z-graph/graph", label: "图视图", icon: /* @__PURE__ */ e.jsx(we, {}) },
2152
+ { key: "/z-graph/branches", label: "分支", icon: /* @__PURE__ */ e.jsx(ke, {}) },
2153
+ { key: "/z-graph/commits", label: "提交历史", icon: /* @__PURE__ */ e.jsx(Ie, {}) },
2154
+ { key: "/z-graph/query", label: "Cypher 查询", icon: /* @__PURE__ */ e.jsx(Re, {}) },
2155
2155
  { key: "/z-graph/schema", label: "Schema", icon: /* @__PURE__ */ e.jsx(Le, {}) },
2156
- { key: "/z-graph/logs", label: "请求日志", icon: /* @__PURE__ */ e.jsx(Re, {}) },
2157
- { key: "/z-graph/api-docs", label: "API 文档", icon: /* @__PURE__ */ e.jsx(Oe, {}) }
2158
- ], yt = [
2159
- { path: "/z-graph/home", Component: lt },
2156
+ { key: "/z-graph/logs", label: "请求日志", icon: /* @__PURE__ */ e.jsx(Oe, {}) },
2157
+ { key: "/z-graph/api-docs", label: "API 文档", icon: /* @__PURE__ */ e.jsx(De, {}) },
2158
+ { key: "/z-graph/docs", label: "组件文档", icon: /* @__PURE__ */ e.jsx(Me, {}) }
2159
+ ], jt = [
2160
+ { path: "/z-graph/home", Component: ct },
2160
2161
  // 旧版 console 页面(吃 src/console/styles.css)⇒ 必须走 withGraphConsole,
2161
2162
  // 否则那份样式表里的裸元素选择器会泄漏到主壳(详见 console/serverHook.jsx 注释)。
2162
- { path: "/z-graph/dashboard", Component: F(qe) },
2163
- { path: "/z-graph/graph", Component: F($e) },
2164
- { path: "/z-graph/branches", Component: F(Be) },
2165
- { path: "/z-graph/commits", Component: F(Fe) },
2166
- { path: "/z-graph/query", Component: F(Ye) },
2167
- { path: "/z-graph/schema", Component: F(Qe) },
2168
- { path: "/z-graph/logs", Component: F(nt) },
2169
- { path: "/z-graph/api-docs", Component: F(rt) },
2163
+ { path: "/z-graph/dashboard", Component: F(Ue) },
2164
+ { path: "/z-graph/graph", Component: F(Be) },
2165
+ { path: "/z-graph/branches", Component: F(_e) },
2166
+ { path: "/z-graph/commits", Component: F(Ke) },
2167
+ { path: "/z-graph/query", Component: F(Qe) },
2168
+ { path: "/z-graph/schema", Component: F(tt) },
2169
+ { path: "/z-graph/logs", Component: F(at) },
2170
+ { path: "/z-graph/api-docs", Component: F(ot) },
2170
2171
  // 新版页面(antd 实现)不吃 console 样式表 ⇒ 不加作用域
2171
- { path: "/z-graph/instance", Component: je(Se) },
2172
+ { path: "/z-graph/instance", Component: je(ve) },
2173
+ { path: "/z-graph/docs", Component: Ne },
2172
2174
  // catchall 放最后 —— 否则 `:rest*` 会先于具体路由匹配,导致 /z-graph/query
2173
2175
  // 全部跳进 GraphApp 的内层 /schema 路由(URL 变成 /z-graph/query/schema)。
2174
- { path: "/z-graph/:rest*", Component: Ne }
2176
+ { path: "/z-graph/:rest*", Component: Se }
2175
2177
  ];
2176
2178
  export {
2177
- lt as HomePage,
2178
- xt as LoginPage,
2179
+ Ne as ComponentDocPage,
2180
+ ct as HomePage,
2181
+ yt as LoginPage,
2179
2182
  W as api,
2180
- gt as appMeta,
2181
- bt as configureGraph,
2182
- it as menuItems,
2183
- yt as routes,
2184
- Ge as useGraphServer,
2183
+ ft as appMeta,
2184
+ St as configureGraph,
2185
+ dt as menuItems,
2186
+ jt as routes,
2187
+ $e as useGraphServer,
2185
2188
  je as withGraphServer
2186
2189
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuku123/z-graph-component",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "z-graph 可复用前端组件:图视图/分支/提交/Cypher 查询/Schema/日志(原 console 内化,lead 005 §9)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,11 +14,12 @@
14
14
  "dist"
15
15
  ],
16
16
  "scripts": {
17
- "build": "vite build"
17
+ "build": "vite build && node scripts/check-css-scope.mjs",
18
+ "check:css-scope": "node scripts/check-css-scope.mjs"
18
19
  },
19
20
  "dependencies": {
20
- "@yuku123/z-frontend-common": "^1.1.1",
21
21
  "@ant-design/pro-components": "^3.1.12-0",
22
+ "@yuku123/z-frontend-common": "^1.1.4",
22
23
  "axios": "^1.16.1"
23
24
  },
24
25
  "peerDependencies": {