react-kggraph 0.0.27 → 0.0.29

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.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
  };
package/lib/index.es45.js CHANGED
@@ -1,33 +1,42 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { useState as m, useEffect as w } from "react";
3
- import h from "./index.es50.js";
4
- const k = ({ relations: t, kgIds: s, viewMode: a = "list", source: c = "" }) => {
5
- const [d, l] = m(t);
6
- w(() => {
7
- t && t && l(p(t || []));
8
- }, [t]);
9
- const p = (e) => e.map((o) => {
10
- var r;
11
- const n = (r = o.content) == null ? void 0 : r.filter((f) => f.propertyKey !== "id");
12
- return {
13
- ...o,
14
- showContent: n.slice(0, 8)
15
- };
16
- });
17
- return /* @__PURE__ */ i("div", { className: "relation-section-wraper", children: d.map((e, u) => /* @__PURE__ */ i(
18
- h,
19
- {
20
- entity: e,
21
- viewMode: a,
22
- className: "shadow-none",
23
- source: c,
24
- onViewDetails: (o) => {
25
- const n = encodeURIComponent(e.uri);
26
- window.open(`#/ai-search/fulltext-detail?uri=${n}&kgId=${s}&keyword=${o.showValue}`, "_blank");
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useRef as s } from "react";
3
+ import { Image as t } from "antd";
4
+ const m = ({ images: o, forceSingleColumn: i = !1, source: d = "" }) => (s(0), /* @__PURE__ */ e("div", { className: d === "qa-card" ? "grid grid-cols-1" : `grid ${i ? "grid-cols-1 gap-y-3" : "grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-20px"}`, children: /* @__PURE__ */ e(
5
+ t.PreviewGroup,
6
+ {
7
+ preview: {
8
+ // onVisibleChange: (visible) => {
9
+ // if (visible) {
10
+ // handlePreviewOpen();
11
+ // } else {
12
+ // handlePreviewClose();
13
+ // }
14
+ // },
15
+ mask: !0,
16
+ zIndex: 9999,
17
+ getContainer: () => document.getElementById("root") || document.body
18
+ },
19
+ children: o.map((r, a) => /* @__PURE__ */ e("div", { className: "group rounded-lg overflow-hidden transition-shadow", children: /* @__PURE__ */ e("div", { className: "h-185px relative overflow-hidden", children: /* @__PURE__ */ e(
20
+ t,
21
+ {
22
+ src: r.propertyValue,
23
+ alt: r.propertyKey,
24
+ style: {
25
+ width: "100%",
26
+ height: "185px",
27
+ objectFit: "cover"
28
+ // cover 保证图片充满容器,可能会裁剪
29
+ // 或者使用 'contain' 保证图片完整显示,可能会有留白
30
+ // objectFit: 'contain',
31
+ },
32
+ className: "transition-transform duration-300 group-hover:scale-105 rounded-6px",
33
+ preview: {
34
+ cover: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-white text-14px", children: "点击查看" }) })
35
+ }
27
36
  }
28
- }
29
- )) });
30
- };
37
+ ) }) }, a))
38
+ }
39
+ ) }));
31
40
  export {
32
- k as default
41
+ m as default
33
42
  };
@@ -0,0 +1,91 @@
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
+ ] });
88
+ };
89
+ export {
90
+ R as default
91
+ };
@@ -0,0 +1,58 @@
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
+ }
16
+ };
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
+ );
55
+ };
56
+ export {
57
+ j as default
58
+ };
@@ -0,0 +1,33 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as w } from "react";
3
+ import h from "./index.es50.js";
4
+ const k = ({ relations: t, kgIds: s, viewMode: a = "list", source: c = "" }) => {
5
+ const [d, l] = m(t);
6
+ w(() => {
7
+ t && t && l(p(t || []));
8
+ }, [t]);
9
+ const p = (e) => e.map((o) => {
10
+ var r;
11
+ const n = (r = o.content) == null ? void 0 : r.filter((f) => f.propertyKey !== "id");
12
+ return {
13
+ ...o,
14
+ showContent: n.slice(0, 8)
15
+ };
16
+ });
17
+ return /* @__PURE__ */ i("div", { className: "relation-section-wraper", children: d.map((e, u) => /* @__PURE__ */ i(
18
+ h,
19
+ {
20
+ entity: e,
21
+ viewMode: a,
22
+ className: "shadow-none",
23
+ source: c,
24
+ onViewDetails: (o) => {
25
+ const n = encodeURIComponent(e.uri);
26
+ window.open(`#/ai-search/fulltext-detail?uri=${n}&kgId=${s}&keyword=${o.showValue}`, "_blank");
27
+ }
28
+ }
29
+ )) });
30
+ };
31
+ export {
32
+ k as default
33
+ };