react-kggraph 0.0.37 → 0.0.39

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/lib/index.es3.js CHANGED
@@ -1,45 +1,45 @@
1
- import { jsx as g, jsxs as ne } from "react/jsx-runtime";
1
+ import { jsx as p, jsxs as se } from "react/jsx-runtime";
2
2
  import { useRef as k, useState as m, useEffect as T } from "react";
3
3
  import C from "cytoscape";
4
- import Ne from "cytoscape-cose-bilkent";
5
- import Pe from "cytoscape-cise";
6
- import je from "cytoscape-fcose";
7
- import we from "storm-layout";
8
- import Le from "./index.es7.js";
4
+ import Pe from "cytoscape-cose-bilkent";
5
+ import je from "cytoscape-cise";
6
+ import we from "cytoscape-fcose";
7
+ import Le from "storm-layout";
8
+ import Se from "./index.es7.js";
9
9
  /* empty css */
10
- import { handleCalcPath as Se, resDetailData as F } from "./index.es8.js";
11
- import { fixNodesToEdges as Oe, coseBilkentLayout as De } from "./index.es9.js";
12
- import { edgeNodeStyles as Re, defaultColors as se, nodeSize as Te } from "./index.es10.js";
13
- import $e from "cytoscape-layout-utilities";
14
- import { Spin as Ie, message as j } from "antd";
15
- import { menuItemsConfig as Be } from "./index.es11.js";
16
- import { jsonStringify as w } from "./index.es12.js";
17
- import Me from "./index.es13.js";
18
- import Ae from "./index.es14.js";
19
- import { GraphProvider as We } from "./index.es15.js";
20
- import He from "./index.es16.js";
21
- import Ze from "./index.es17.js";
22
- C.use($e);
23
- C.use(Pe);
10
+ import { handleCalcPath as Oe, resDetailData as F } from "./index.es8.js";
11
+ import { fixNodesToEdges as Re, coseBilkentLayout as De } from "./index.es9.js";
12
+ import { edgeNodeStyles as Te, defaultColors as ae, nodeSize as $e } from "./index.es10.js";
13
+ import Ie from "cytoscape-layout-utilities";
14
+ import { Row as Be, Spin as Me, message as $ } from "antd";
15
+ import { menuItemsConfig as Ae } from "./index.es11.js";
16
+ import { jsonStringify as j } from "./index.es12.js";
17
+ import We from "./index.es13.js";
18
+ import He from "./index.es14.js";
19
+ import { GraphProvider as Ze } from "./index.es15.js";
20
+ import Fe from "./index.es16.js";
21
+ import re from "./index.es17.js";
22
+ C.use(Ie);
24
23
  C.use(je);
25
24
  C.use(we);
26
- C.use(Ne);
27
- const pt = ({
25
+ C.use(Le);
26
+ C.use(Pe);
27
+ const gt = ({
28
28
  data: z,
29
- getAllGraphData: $,
29
+ getAllGraphData: I,
30
30
  highPathAnalysis: X = [],
31
31
  graphInfo: u,
32
- stepNextApi: ae,
33
- knowledgeCardApi: re,
32
+ stepNextApi: ie,
33
+ knowledgeCardApi: de,
34
34
  colors: E,
35
- actionBar: ie,
36
- actionCircle: de,
37
- queryStatisticsConfig: le = [{ label: "实体", key: "entity" }, { label: "关系", key: "relation" }],
38
- className: ce,
39
- noDataDesc: Fe = "暂无数据"
35
+ actionBar: le,
36
+ actionCircle: ce,
37
+ queryStatisticsConfig: pe = [{ label: "实体", key: "entity" }, { label: "关系", key: "relation" }],
38
+ className: ge,
39
+ noDataDesc: Xe = "暂无数据"
40
40
  }) => {
41
- var V, G;
42
- const L = k(null), [h, q] = m([]), c = k(null), K = k(null), U = 1, [pe, I] = m(!1), [v, B] = m({}), [S, M] = m({}), [ge, ue] = m("cose-bilkent"), Y = k(null), _ = k(null), [fe, J] = m(["", ""]), A = k(E);
41
+ var G, ee;
42
+ const w = k(null), [h, q] = m([]), c = k(null), K = k(null), U = 1, [Y, L] = m(!1), [v, B] = m({}), [S, M] = m({}), [ue, fe] = m("cose-bilkent"), _ = k(null), J = k(null), [ye, Q] = m(["", ""]), A = k(E);
43
43
  T(() => {
44
44
  A.current = E;
45
45
  }, [E]);
@@ -49,31 +49,31 @@ const pt = ({
49
49
  y: 0,
50
50
  targetNode: null,
51
51
  bgColor: ""
52
- }), [O, Q] = m({
52
+ }), [O, V] = m({
53
53
  visible: !1,
54
54
  x: 0,
55
55
  y: 0,
56
56
  content: ""
57
- }), ye = Be({ cyRef: c, setContextMenu: N, onPathAnalysis: (V = K.current) == null ? void 0 : V.onPathAnalysis, setPathNodes: J, actionCircle: de });
57
+ }), me = Ae({ cyRef: c, setContextMenu: N, onPathAnalysis: (G = K.current) == null ? void 0 : G.onPathAnalysis, setPathNodes: Q, actionCircle: ce });
58
58
  T(() => {
59
59
  const { nodes: e, links: t } = X || {};
60
- ((e == null ? void 0 : e.length) > 0 || (t == null ? void 0 : t.length) > 0) && Se(c, { nodes: e, links: t, isGrayed: !1 });
61
- }, [w(X), w(h)]), T(() => {
60
+ ((e == null ? void 0 : e.length) > 0 || (t == null ? void 0 : t.length) > 0) && Oe(c, { nodes: e, links: t, isGrayed: !1 });
61
+ }, [j(X), j(h)]), T(() => {
62
62
  const e = [], t = [];
63
63
  h.forEach((d) => {
64
64
  d.group === "nodes" ? e.push(d.data) : d.group === "edges" && t.push(d.data);
65
- }), $ == null || $({ graphData: h, nodeStatic: v, relationStatic: S, data: { nodes: e, links: t }, paths: z.paths, data2: z.data2, logId: z.logId, costtime: z.costtime });
66
- }, [w(h), w(v), w(S)]), T(() => {
65
+ }), I == null || I({ graphData: h, nodeStatic: v, relationStatic: S, data: { nodes: e, links: t }, paths: z.paths, data2: z.data2, logId: z.logId, costtime: z.costtime });
66
+ }, [j(h), j(v), j(S)]), T(() => {
67
67
  var i;
68
- if (!L.current || c.current) return;
68
+ if (!w.current || c.current) return;
69
69
  const { elements: e, typeListObj: t, relationListObj: d } = F(z, { typeObj: v, graphInfo: u });
70
70
  B(t), q(e), M(d), document.addEventListener("contextmenu", function(a) {
71
71
  a.preventDefault();
72
72
  });
73
73
  const s = C({
74
- container: L.current,
74
+ container: w.current,
75
75
  elements: e,
76
- style: Re({ elements: e, colors: E }),
76
+ style: Te({ elements: e, colors: E }),
77
77
  autounselectify: !1,
78
78
  autolock: !1,
79
79
  maxZoom: 1,
@@ -83,7 +83,7 @@ const pt = ({
83
83
  }
84
84
  });
85
85
  if (c.current = s, ((i = u == null ? void 0 : u.searchNodes) == null ? void 0 : i.length) === 2)
86
- Oe(
86
+ Re(
87
87
  s,
88
88
  u.searchNodes[0],
89
89
  u.searchNodes[1]
@@ -98,7 +98,7 @@ const pt = ({
98
98
  var n;
99
99
  const o = a.target;
100
100
  if (!o.hasClass("path-edge")) {
101
- const r = ((n = A.current) == null ? void 0 : n.edgeHoverColor) ?? se.edgeHoverColor;
101
+ const r = ((n = A.current) == null ? void 0 : n.edgeHoverColor) ?? ae.edgeHoverColor;
102
102
  o.style({
103
103
  "line-color": r,
104
104
  "target-arrow-color": r,
@@ -109,7 +109,7 @@ const pt = ({
109
109
  var n;
110
110
  const o = a.target;
111
111
  if (!o.hasClass("path-edge")) {
112
- const r = ((n = A.current) == null ? void 0 : n.edgeDefaultColor) ?? se.edgeDefaultColor;
112
+ const r = ((n = A.current) == null ? void 0 : n.edgeDefaultColor) ?? ae.edgeDefaultColor;
113
113
  o.style({
114
114
  "line-color": r,
115
115
  "target-arrow-color": r,
@@ -121,14 +121,14 @@ const pt = ({
121
121
  o.hasClass("selected") || o.addClass("hover");
122
122
  }), s.on("mouseover", "node", (a) => {
123
123
  const o = a.target, n = o.renderedPosition(), r = o.data("name") || "";
124
- o.addClass("hover"), Q({
124
+ o.addClass("hover"), V({
125
125
  visible: !0,
126
126
  x: n.x,
127
127
  y: n.y - 60,
128
128
  content: r
129
129
  });
130
130
  }), s.on("mouseout", "node", (a) => {
131
- a.target.removeClass("hover"), Q((n) => ({ ...n, visible: !1 }));
131
+ a.target.removeClass("hover"), V((n) => ({ ...n, visible: !1 }));
132
132
  }), s.on("cxttap", "node", (a) => {
133
133
  a.preventDefault(), a.stopPropagation(), a.stopImmediatePropagation(), a.originalEvent && (a.originalEvent.preventDefault(), a.originalEvent.stopPropagation(), a.originalEvent.stopImmediatePropagation());
134
134
  const o = a.target, n = o.renderedPosition();
@@ -142,18 +142,18 @@ const pt = ({
142
142
  }), c.current = s, s.on("click", "node", (a) => {
143
143
  const o = a.target;
144
144
  s.nodes().removeClass("selected grayed highlighted"), s.edges().removeClass("selected grayed highlighted"), o.addClass("selected");
145
- const r = o.neighborhood().nodes().add(o), p = r.edgesWith(r);
146
- console.log("cy.nodes().not(relatedNodes):::", r), s.nodes().not(r).addClass("grayed"), s.edges().not(p).addClass("grayed"), r.addClass("highlighted"), p.addClass("highlighted");
145
+ const r = o.neighborhood().nodes().add(o), g = r.edgesWith(r);
146
+ console.log("cy.nodes().not(relatedNodes):::", r), s.nodes().not(r).addClass("grayed"), s.edges().not(g).addClass("grayed"), r.addClass("highlighted"), g.addClass("highlighted");
147
147
  }), s.on("tap", (a) => {
148
148
  a.target === s && (N((o) => ({ ...o, visible: !1 })), s.nodes().removeClass("grayed highlighted highlight selected correlationStyle path-node level-highlight level-selected level-grayed"), s.edges().removeClass("grayed highlighted highlight selected correlationStyle path-edge level-highlightedge level-grayed"));
149
149
  }), () => {
150
150
  c.current && (c.current.destroy(), c.current = null);
151
151
  };
152
152
  }, []);
153
- const me = ({ addedNodes: e, currentNode: t, cy: d, currentZoom: s }) => {
153
+ const he = ({ addedNodes: e, currentNode: t, cy: d, currentZoom: s }) => {
154
154
  const i = e == null ? void 0 : e.length;
155
155
  t.data("originalPosition") || t.data("originalPosition", { ...t.position() });
156
- const a = Math.max(0.1, 18 / (i || 1)), o = d.layout({
156
+ const a = Math.max(0.1, i > 10 ? 8 / (i || 1) : 0.7), o = d.layout({
157
157
  name: "concentric",
158
158
  spacingFactor: a,
159
159
  // 节点越多间距越小,防止溢出
@@ -176,16 +176,16 @@ const pt = ({
176
176
  // },
177
177
  // 添加随机偏移,打破完美圆环
178
178
  transform: function(n, r) {
179
- const p = (Math.random() - 0.5) * 40, b = (Math.random() - 0.5) * 10;
179
+ const g = (Math.random() - 0.5) * 40, b = (Math.random() - 0.5) * 10;
180
180
  return {
181
- x: r.x + p,
181
+ x: r.x + g,
182
182
  y: r.y + b
183
183
  };
184
184
  }
185
185
  });
186
186
  o.one("layoutstop", () => {
187
- e.forEach((p) => {
188
- p.style("z-index", Math.floor(Math.random() * 500) + 1);
187
+ e.forEach((g) => {
188
+ g.style("z-index", Math.floor(Math.random() * 500) + 1);
189
189
  }), t.style("z-index", 1e3);
190
190
  const n = t.data("originalPosition"), r = { ...t.position() };
191
191
  n && (t.position(n), t.animate({
@@ -202,9 +202,9 @@ const pt = ({
202
202
  easing: "ease-out"
203
203
  });
204
204
  }
205
- })), I(!1);
205
+ })), L(!1);
206
206
  }), o.run(), d.nodes().forEach((n) => n.unlock());
207
- }, he = async (e) => {
207
+ }, ve = async (e) => {
208
208
  const { id: t, kgId: d } = e, s = c.current;
209
209
  if (!s) return;
210
210
  const i = s.$id(t);
@@ -214,30 +214,30 @@ const pt = ({
214
214
  }
215
215
  const a = s.nodes().filter((n) => n.data("parentId") ? (n.data("parentId") === t || n.data("idLabel") === `${t}-${n.data("name")}`) && n.data("zktype") === e.zktype : !1);
216
216
  if (a.length > 0) {
217
- const n = a.map((l) => l.id()), r = a.connectedEdges(), p = s.edges().filter(
217
+ const n = a.map((l) => l.id()), r = a.connectedEdges(), g = s.edges().filter(
218
218
  (l) => l.data("source") === t && n.includes(l.data("target"))
219
- ), b = s.edges().filter((l) => l.data("appendedBy") === t), W = r.merge(p).merge(b).filter((l) => l.data().zktype === e.zktype);
219
+ ), b = s.edges().filter((l) => l.data("appendedBy") === t), W = r.merge(g).merge(b).filter((l) => l.data().zktype === e.zktype);
220
220
  a.animate({
221
221
  style: { opacity: 0 }
222
222
  }, {
223
223
  duration: 200,
224
224
  complete: () => {
225
- s.remove(a), s.remove(W), q((ee) => {
226
- const P = ee.filter((x) => {
227
- var te, oe;
228
- const R = x.data.zktype;
229
- if (x.group === "nodes" && n.includes((te = x.data) == null ? void 0 : te.id) && R && R === e.zktype)
225
+ s.remove(a), s.remove(W), q((te) => {
226
+ const P = te.filter((x) => {
227
+ var oe, ne;
228
+ const D = x.data.zktype;
229
+ if (x.group === "nodes" && n.includes((oe = x.data) == null ? void 0 : oe.id) && D && D === e.zktype)
230
230
  return !1;
231
- if (x.group === "edges" && R && R === e.zktype) {
232
- const ke = Array.from(b).map((Ee) => {
233
- const Z = Ee.data();
231
+ if (x.group === "edges" && D && D === e.zktype) {
232
+ const Ce = Array.from(b).map((Ne) => {
233
+ const Z = Ne.data();
234
234
  return `${Z.source}-${Z.target}-${Z.label}`;
235
- }), H = x.data, Ce = ke.includes(`${H.source}-${H.target}-${H.label}`), ze = ((oe = x.data) == null ? void 0 : oe.appendedBy) === t;
236
- return !Ce && !ze;
235
+ }), H = x.data, ze = Ce.includes(`${H.source}-${H.target}-${H.label}`), Ee = ((ne = x.data) == null ? void 0 : ne.appendedBy) === t;
236
+ return !ze && !Ee;
237
237
  }
238
238
  return !0;
239
- }), { typeListObj: y, relationListObj: D } = F({}, { graphData: P, typeObj: {} });
240
- return B(y), M(D), P;
239
+ }), { typeListObj: y, relationListObj: R } = F({}, { graphData: P, typeObj: {} });
240
+ return B(y), M(R), P;
241
241
  }), i.data("appendedNodes", []), i.data("isExpanded", !1);
242
242
  const l = i.data("originalPosition");
243
243
  l && (i.animate({
@@ -249,11 +249,11 @@ const pt = ({
249
249
  }, 300);
250
250
  } else {
251
251
  try {
252
- I(!0);
253
- const n = await ae({ uri: t, queryType: 1, kgId: d, zktype: e.zktype }), { elements: r, typeListObj: p, relationListObj: b } = F(n.data, { graphData: h, typeObj: v, relationObj: S, zktype: e.zktype });
254
- if (B(p), M(b), !((r == null ? void 0 : r.length) > 0)) {
252
+ L(!0);
253
+ const n = await ie({ uri: t, queryType: 1, kgId: d, zktype: e.zktype }), { elements: r, typeListObj: g, relationListObj: b } = F(n.data, { graphData: h, typeObj: v, relationObj: S, zktype: e.zktype });
254
+ if (B(g), M(b), !((r == null ? void 0 : r.length) > 0)) {
255
255
  setTimeout(() => {
256
- j.destroy(), j.warning("暂无数据");
256
+ L(!1), $.warning("暂无数据");
257
257
  }, 2e3);
258
258
  return;
259
259
  }
@@ -261,11 +261,11 @@ const pt = ({
261
261
  if ((r == null ? void 0 : r.length) > 0) {
262
262
  const l = r.map((y) => {
263
263
  if (y.group === "nodes") {
264
- const D = Te * U;
264
+ const R = $e * U;
265
265
  return {
266
266
  ...y,
267
267
  // position,
268
- style: { opacity: 0, width: D, height: D },
268
+ style: { opacity: 0, width: R, height: R },
269
269
  data: {
270
270
  ...y.data,
271
271
  parentId: t,
@@ -285,27 +285,27 @@ const pt = ({
285
285
  });
286
286
  s.nodes().lock(), i.unlock();
287
287
  const P = s.add(l).filter(":node");
288
- P.style("opacity", 0), me({ addedNodes: P, currentNode: i, cy: s, currentZoom: W });
288
+ P.style("opacity", 0), he({ addedNodes: P, currentNode: i, cy: s, currentZoom: W });
289
289
  } else
290
290
  console.log("没有找到相关节点数据");
291
- j.destroy();
291
+ $.destroy();
292
292
  } catch (n) {
293
- j.destroy(), j.error("请求接口失败"), console.error("22请求接口失败:", n);
293
+ $.destroy(), $.error("请求接口失败"), console.error("22请求接口失败:", n);
294
294
  }
295
- I(!1);
295
+ L(!1);
296
296
  }
297
297
  N({ visible: !1 });
298
- }, ve = {
298
+ }, be = {
299
299
  expanded: "typed-literal",
300
300
  contract: "uri"
301
- }, be = (e, t) => {
301
+ }, xe = (e, t) => {
302
302
  var s;
303
303
  console.log("handleMenuAction:::", e, t);
304
304
  const d = t || f.targetNode;
305
305
  if (d) {
306
306
  const i = e.ids, a = d.data();
307
307
  if (["expanded", "contract"].includes(i))
308
- he({ kgId: u.kgId, ...a, zktype: ve[i] });
308
+ ve({ kgId: u.kgId, ...a, zktype: be[i] });
309
309
  else if (i === "nodeInfo") {
310
310
  const o = d, n = {
311
311
  id: o.id(),
@@ -317,34 +317,34 @@ const pt = ({
317
317
  classes: o.classes(),
318
318
  style: o.style()
319
319
  };
320
- Y.current.open(n);
321
- } else i === "knowledgeCard" && _.current.open(d.data());
320
+ _.current.open(n);
321
+ } else i === "knowledgeCard" && J.current.open(d.data());
322
322
  (s = e.onClick) == null || s.call(e, d), N({ visible: !1, x: 0, y: 0, targetNode: null });
323
323
  }
324
- }, xe = () => {
324
+ }, ke = () => {
325
325
  const e = {};
326
326
  return Object.keys(v).forEach((t) => {
327
327
  t !== "_" && (e[t] = v[t]);
328
328
  }), e;
329
329
  };
330
- return /* @__PURE__ */ g(We, { value: { pathNodes: fe, setPathNodes: J, graphInfo: u, graphData: h, layoutType: ge, setLayoutType: ue, knowledgeCardApi: re, queryStatisticsConfig: le, actionBar: ie }, children: /* @__PURE__ */ ne("div", { className: Ze("cytoscape-container relative", ce), children: [
331
- /* @__PURE__ */ g("div", { className: "btn-group" }),
332
- /* @__PURE__ */ g(
333
- Le,
330
+ return /* @__PURE__ */ p(Ze, { value: { pathNodes: ye, setPathNodes: Q, graphInfo: u, graphData: h, layoutType: ue, setLayoutType: fe, knowledgeCardApi: de, queryStatisticsConfig: pe, actionBar: le }, children: /* @__PURE__ */ se("div", { className: re("cytoscape-container relative", ge), children: [
331
+ /* @__PURE__ */ p("div", { className: "btn-group" }),
332
+ /* @__PURE__ */ p(
333
+ Se,
334
334
  {
335
335
  ref: K,
336
336
  cyRef: c,
337
337
  graphInfo: u,
338
338
  initNodeScale: U,
339
- cyContainerRef: L,
340
- typeObj: xe(),
339
+ cyContainerRef: w,
340
+ typeObj: ke(),
341
341
  relationObj: S,
342
342
  colors: E
343
343
  }
344
344
  ),
345
- /* @__PURE__ */ ne("div", { className: "relative h-100", children: [
346
- /* @__PURE__ */ g("div", { ref: L, className: "cy-container" }),
347
- f.visible && f.targetNode && /* @__PURE__ */ g(
345
+ /* @__PURE__ */ se("div", { className: "relative h-100", children: [
346
+ /* @__PURE__ */ p("div", { ref: w, className: "cy-container" }),
347
+ f.visible && f.targetNode && /* @__PURE__ */ p(
348
348
  "div",
349
349
  {
350
350
  style: {
@@ -364,10 +364,10 @@ const pt = ({
364
364
  overflow: "hidden"
365
365
  },
366
366
  onClick: (e) => e.stopPropagation(),
367
- children: /* @__PURE__ */ g(Me, { items: ye, centerImage: (G = f == null ? void 0 : f.targetNode) == null ? void 0 : G.data().image, targetNode: f.targetNode, onClick: (e, t) => be(e, t) })
367
+ children: /* @__PURE__ */ p(We, { items: me, centerImage: (ee = f == null ? void 0 : f.targetNode) == null ? void 0 : ee.data().image, targetNode: f.targetNode, onClick: (e, t) => xe(e, t) })
368
368
  }
369
369
  ),
370
- O.visible && /* @__PURE__ */ g(
370
+ O.visible && /* @__PURE__ */ p(
371
371
  "div",
372
372
  {
373
373
  style: {
@@ -391,11 +391,13 @@ const pt = ({
391
391
  }
392
392
  )
393
393
  ] }),
394
- /* @__PURE__ */ g(Ae, { ref: Y, cyRef: c }),
395
- /* @__PURE__ */ g(He, { ref: _ }),
396
- /* @__PURE__ */ g(Ie, { spinning: pe, className: "Spin-loading", description: "Loading", size: "large", fullscreen: !0 })
394
+ /* @__PURE__ */ p(He, { ref: _, cyRef: c }),
395
+ /* @__PURE__ */ p(Fe, { ref: J }),
396
+ /* @__PURE__ */ p(Be, { className: re("Spin-loading", {
397
+ "Spin-loading-hidden": !Y
398
+ }), justify: "center", align: "middle", children: /* @__PURE__ */ p(Me, { spinning: Y, description: "Loading", size: "large" }) })
397
399
  ] }) });
398
400
  };
399
401
  export {
400
- pt as default
402
+ gt as default
401
403
  };
package/lib/index.es39.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsxs as c, jsx as r, Fragment as o } from "react/jsx-runtime";
2
- import N from "./index.es40.js";
3
- import k from "./index.es41.js";
4
- import y from "./index.es42.js";
5
- import C from "./index.es43.js";
6
- import S from "./index.es44.js";
7
- import v from "./index.es45.js";
2
+ import N from "./index.es43.js";
3
+ import k from "./index.es44.js";
4
+ import y from "./index.es45.js";
5
+ import C from "./index.es46.js";
6
+ import S from "./index.es47.js";
7
+ import v from "./index.es48.js";
8
8
  import { Row as x, Col as f, Empty as q } from "antd";
9
9
  /* empty css */
10
10
  const i = (e) => {
package/lib/index.es43.js CHANGED
@@ -1,91 +1,21 @@
1
- import { jsxs as m, Fragment as x, jsx as a } from "react/jsx-runtime";
2
- import { useState as u, useRef as p, useEffect as f } from "react";
3
- import { Modal as C } from "antd";
4
- const R = ({ videos: c, forceSingleColumn: V = !1, source: j = "" }) => {
5
- const [n, l] = u(null), [i, h] = u({}), v = p({}), s = p(null), g = () => {
6
- s.current && (s.current.pause(), s.current.currentTime = 0), l(null);
7
- };
8
- f(() => {
9
- n && s.current && s.current.play().catch(() => {
10
- });
11
- }, [n]);
12
- const y = (t, r) => {
13
- if (i[r]) return;
14
- const e = document.createElement("video");
15
- e.src = t, e.crossOrigin = "anonymous", e.muted = !0, e.preload = "metadata", e.onloadeddata = () => {
16
- e.currentTime = 0.1;
17
- }, e.onseeked = () => {
18
- const o = document.createElement("canvas");
19
- o.width = e.videoWidth, o.height = e.videoHeight;
20
- const d = o.getContext("2d");
21
- if (d) {
22
- d.drawImage(e, 0, 0, o.width, o.height);
23
- const w = o.toDataURL("image/jpeg", 0.8);
24
- h((N) => ({ ...N, [r]: w }));
25
- }
26
- e.src = "";
27
- }, e.onerror = () => {
28
- e.src = "";
29
- };
30
- };
31
- return f(() => {
32
- c.forEach((t, r) => {
33
- y(t.propertyValue, r);
34
- });
35
- }, [c]), /* @__PURE__ */ m(x, { children: [
36
- /* @__PURE__ */ a("div", { className: "video-wraper", children: c.map((t, r) => {
37
- t.propertyValue.split("/").pop();
38
- const e = i[r];
39
- return /* @__PURE__ */ a("div", { className: "rounded-lg overflow-hidden transition-shadow", children: /* @__PURE__ */ m("div", { className: "video-item", children: [
40
- /* @__PURE__ */ a(
41
- "video",
42
- {
43
- ref: (o) => {
44
- v.current[r] = o;
45
- },
46
- src: t.propertyValue,
47
- poster: e,
48
- className: "video-item-video",
49
- muted: !0,
50
- playsInline: !0,
51
- preload: "metadata",
52
- onClick: () => l(t.propertyValue)
53
- }
54
- ),
55
- !n && /* @__PURE__ */ a("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ a(
56
- "div",
57
- {
58
- className: "w-8 h-8 rounded-full flex items-center justify-center cursor-pointer hover:scale-110 transition-transform",
59
- onClick: () => l(t.propertyValue),
60
- children: /* @__PURE__ */ a("span", { className: "w-24px h-24px i-custom-video-play inline-block" })
61
- }
62
- ) })
63
- ] }) }, r);
64
- }) }),
65
- /* @__PURE__ */ a(
66
- C,
67
- {
68
- open: !!n,
69
- footer: null,
70
- onCancel: g,
71
- width: "auto",
72
- centered: !0,
73
- className: "video-modal",
74
- wrapClassName: "modal-wrapClassName",
75
- getContainer: () => document.getElementById("root"),
76
- children: n && /* @__PURE__ */ a(
77
- "video",
78
- {
79
- ref: s,
80
- src: n,
81
- controls: !0,
82
- className: "max-w-[80vw] max-h-[80vh] mt-10px"
83
- }
84
- )
85
- }
86
- )
87
- ] });
1
+ import { jsx as o, jsxs as r } from "react/jsx-runtime";
2
+ import { Row as i, Col as p } from "antd";
3
+ const d = ({ properties: t, excludedKeys: l = [] }) => {
4
+ const s = t.filter(
5
+ (e) => !l.includes(e.propertyKey)
6
+ );
7
+ return /* @__PURE__ */ o(i, { className: "property-section-wraper", children: s.map((e, a) => /* @__PURE__ */ r(p, { span: 24, className: "section-item", children: [
8
+ /* @__PURE__ */ r("div", { className: "detail-label", children: [
9
+ e.propertyKey,
10
+ ":"
11
+ ] }),
12
+ /* @__PURE__ */ r("div", { className: "detail-value", children: [
13
+ " ",
14
+ e.propertyValue,
15
+ " "
16
+ ] })
17
+ ] }, a)) });
88
18
  };
89
19
  export {
90
- R as default
20
+ d as default
91
21
  };
package/lib/index.es44.js CHANGED
@@ -1,58 +1,43 @@
1
- import { jsx as l, jsxs as o } from "react/jsx-runtime";
2
- import { useState as g, useRef as y } from "react";
3
- import { Row as d, Flex as h, Button as p } from "antd";
4
- const j = ({ audios: m, forceSingleColumn: u = !1, source: f = "" }) => {
5
- const [s, a] = g(null), n = y({}), x = (e) => {
6
- var t, i;
7
- if (s === e)
8
- (t = n.current[e]) == null || t.pause(), a(null);
9
- else {
10
- if (s && ((i = n.current[s]) == null || i.pause()), a(e), !n.current[e]) {
11
- const c = new Audio(e);
12
- n.current[e] = c;
13
- }
14
- n.current[e].play(), n.current[e].onended = () => a(null);
15
- }
1
+ import { jsx as s, jsxs as o } from "react/jsx-runtime";
2
+ import { Space as d, Button as i } from "antd";
3
+ import { downloadFile as x } from "./index.es12.js";
4
+ const w = ({ documents: l, forceSingleColumn: c = !1, source: r }) => {
5
+ const a = (e) => e.toLowerCase().endsWith(".pdf") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-pdf-doc inline-block" }) : e.toLowerCase().endsWith(".docx") || e.toLowerCase().endsWith(".doc") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-doc-doc inline-block" }) : e.toLowerCase().endsWith(".pptx") || e.toLowerCase().endsWith(".ppt") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-ppt-doc inline-block" }) : e.toLowerCase().endsWith(".txt") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-txt-doc inline-block" }) : e.toLowerCase().endsWith(".csv") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-csv-doc inline-block" }) : e.toLowerCase().endsWith(".xls") || e.toLowerCase().endsWith(".xlsx") ? /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-xls-doc inline-block" }) : /* @__PURE__ */ s("span", { className: "w-24px h-30px i-custom-else-doc inline-block" }), p = (e) => {
6
+ const n = e.split("/");
7
+ return n[n.length - 1];
16
8
  };
17
- return /* @__PURE__ */ l(
18
- "div",
19
- {
20
- className: f === "qa-card" ? "grid grid-cols-1" : `grid ${u ? "grid-cols-1 gap-y-3" : "grid-cols-2 gap-x-100px gap-y-20px"}`,
21
- children: m.map((e, t) => {
22
- const i = e.propertyValue.split("/").pop() || "未命名音频", c = s === e.propertyValue;
23
- return /* @__PURE__ */ o(d, { className: "flex items-center justify-between transition-all", justify: "space-between", align: "middle", children: [
24
- /* @__PURE__ */ o(d, { className: "flex items-center min-w-0 flex-1", align: "middle", children: [
25
- /* @__PURE__ */ l("div", { className: "mr-3 text-xl flex-shrink-0", children: /* @__PURE__ */ l("span", { className: "w-24px h-30px i-custom-audio inline-block" }) }),
26
- /* @__PURE__ */ l("div", { className: "min-w-0", children: /* @__PURE__ */ l("div", { className: "truncate", title: i, children: i }) })
27
- ] }),
28
- /* @__PURE__ */ o(h, { className: "flex-shrink-0 ml-3", children: [
29
- /* @__PURE__ */ l(
30
- p,
31
- {
32
- className: "px-0",
33
- type: "link",
34
- onClick: () => x(e.propertyValue),
35
- children: c ? "暂停" : "播放"
36
- }
37
- ),
38
- /* @__PURE__ */ l(
39
- p,
40
- {
41
- className: "px-0",
42
- type: "link",
43
- onClick: () => {
44
- const r = document.createElement("a");
45
- r.href = e.propertyValue, r.download = i, r.click();
46
- },
47
- children: "下载"
48
- }
49
- )
50
- ] })
51
- ] }, t);
52
- })
53
- }
54
- );
9
+ return /* @__PURE__ */ s("div", { className: r === "qa-card" ? "grid grid-cols-1" : `grid ${c ? "grid-cols-1 gap-y-5" : "grid-cols-1 md:grid-cols-2 gap-x-100px gap-y-10px"}`, children: l.map((e, n) => {
10
+ const t = p(e.propertyValue);
11
+ return /* @__PURE__ */ o("div", { className: "flex items-center justify-between transition-all", children: [
12
+ /* @__PURE__ */ o("div", { className: "flex items-center min-w-0 flex-1", children: [
13
+ /* @__PURE__ */ s("div", { className: "mr-3 text-xl flex-shrink-0", children: a(t) }),
14
+ /* @__PURE__ */ s("div", { className: "min-w-0", children: /* @__PURE__ */ s("div", { className: "truncate", title: decodeURIComponent(t), children: decodeURIComponent(t) }) })
15
+ ] }),
16
+ /* @__PURE__ */ o(d, { className: "flex-shrink-0", children: [
17
+ /* @__PURE__ */ s(
18
+ i,
19
+ {
20
+ className: "px-0px",
21
+ type: "link",
22
+ onClick: () => window.open(e.propertyValue, "_blank"),
23
+ children: "查看"
24
+ }
25
+ ),
26
+ /* @__PURE__ */ s(
27
+ i,
28
+ {
29
+ type: "link",
30
+ className: "px-0px",
31
+ onClick: () => {
32
+ x(e.propertyValue, t);
33
+ },
34
+ children: "下载"
35
+ }
36
+ )
37
+ ] })
38
+ ] }, n);
39
+ }) });
55
40
  };
56
41
  export {
57
- j as default
42
+ w as default
58
43
  };