@cccsaurora/clue-ui 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/fetchers/Fetcher.js +61 -59
- package/en/translation.json +1 -0
- package/fr/translation.json +1 -0
- package/package.json +1 -1
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { I as H } from "../../iconify-BBckr5AQ.js";
|
|
3
|
-
import { useTheme as V, Skeleton as I, Chip as q, Tooltip as J, Stack as
|
|
3
|
+
import { useTheme as V, Skeleton as I, Chip as q, Tooltip as J, Stack as f, Typography as K, LinearProgress as Q, Paper as U, Box as X, IconButton as Y } from "@mui/material";
|
|
4
4
|
import { F as L } from "../../FlexOne-BXWFOd1T.js";
|
|
5
5
|
import S from "../display/icons/Iconified.js";
|
|
6
6
|
import { J as Z } from "../../index-BK-zfYhR.js";
|
|
7
7
|
import { ClueComponentContext as $ } from "../../hooks/ClueComponentContext.js";
|
|
8
|
-
import { c as
|
|
8
|
+
import { c as s } from "../../ActionForm-DlOXqMUx.js";
|
|
9
9
|
import p, { useState as b, useRef as k, useMemo as P, useEffect as N, memo as ee } from "react";
|
|
10
|
-
import { u as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
10
|
+
import { u as te } from "../../index-Dj5C04IX.js";
|
|
11
|
+
import re from "../display/graph/index.js";
|
|
12
|
+
import ie from "../display/markdown/index.js";
|
|
13
|
+
import ne from "./PreviewModal.js";
|
|
14
14
|
import oe from "./StatusChip.js";
|
|
15
15
|
const ae = p.memo(
|
|
16
16
|
({
|
|
17
|
-
type:
|
|
17
|
+
type: h,
|
|
18
18
|
value: x,
|
|
19
19
|
classification: g,
|
|
20
20
|
fetcherId: a,
|
|
21
21
|
slotProps: {
|
|
22
|
-
paper:
|
|
22
|
+
paper: n = {},
|
|
23
23
|
preview: O = {},
|
|
24
24
|
stack: o = {},
|
|
25
25
|
image: W = {},
|
|
26
26
|
chip: v = {},
|
|
27
|
-
skeleton:
|
|
27
|
+
skeleton: i = {}
|
|
28
28
|
} = {}
|
|
29
29
|
}) => {
|
|
30
30
|
var z, M, T, j;
|
|
31
|
-
const d = V(), w =
|
|
31
|
+
const d = V(), w = s((r) => r.fetchers), F = s((r) => r.fetchSelector), R = s((r) => r.getFetcherStatus), D = s((r) => r.fetchCompleted), { t: m } = te($, (r) => r == null ? void 0 : r.i18next), [e, c] = b(null), [E, A] = b(!0), [G, _] = b(!1), y = k(null), C = P(() => e == null ? void 0 : e.task_id, [e == null ? void 0 : e.task_id]);
|
|
32
32
|
if (N(() => {
|
|
33
33
|
if ((e == null ? void 0 : e.outcome) !== "pending" || !C) return;
|
|
34
|
-
let
|
|
34
|
+
let r = !1;
|
|
35
35
|
const B = async () => {
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
|
|
39
|
-
else if (
|
|
40
|
-
|
|
36
|
+
const u = await R(a, C);
|
|
37
|
+
if (!u)
|
|
38
|
+
c({ outcome: "failure", done: !0, error: "Missing result", link: "" });
|
|
39
|
+
else if (u.outcome === "success" || u.outcome === "failure")
|
|
40
|
+
c({ ...u, done: !0 });
|
|
41
41
|
else {
|
|
42
|
-
if (
|
|
43
|
-
|
|
42
|
+
if (r) return;
|
|
43
|
+
c({ ...u }), y.current = setTimeout(B, 2e3);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
return B(), () => {
|
|
47
|
-
|
|
47
|
+
r = !0, y.current && clearTimeout(y.current);
|
|
48
48
|
};
|
|
49
49
|
}, [a, R, e == null ? void 0 : e.outcome, C]), N(() => {
|
|
50
50
|
(async () => {
|
|
51
51
|
try {
|
|
52
|
-
A(!0),
|
|
52
|
+
A(!0), c(await F(a, { type: h, value: x, classification: g }));
|
|
53
|
+
} catch {
|
|
54
|
+
c({ outcome: "failure", done: !0, error: m("fetcher.error.unexpected") });
|
|
53
55
|
} finally {
|
|
54
56
|
A(!1);
|
|
55
57
|
}
|
|
56
58
|
})();
|
|
57
|
-
}, [g, F, a,
|
|
59
|
+
}, [g, F, a, m, h, x]), D)
|
|
58
60
|
if (a)
|
|
59
61
|
if (a.includes(".")) {
|
|
60
62
|
if (!(a in w))
|
|
@@ -65,29 +67,29 @@ const ae = p.memo(
|
|
|
65
67
|
else return console.warn("Missing fetcher Id. Component will not render."), null;
|
|
66
68
|
else
|
|
67
69
|
return null;
|
|
68
|
-
return E ? ((z = w[a]) == null ? void 0 : z.format) === "status" ? /* @__PURE__ */
|
|
70
|
+
return E ? ((z = w[a]) == null ? void 0 : z.format) === "status" ? /* @__PURE__ */ t(
|
|
69
71
|
I,
|
|
70
72
|
{
|
|
71
73
|
variant: "rounded",
|
|
72
74
|
height: "32px",
|
|
73
75
|
width: "150px",
|
|
74
|
-
...
|
|
76
|
+
...i,
|
|
75
77
|
sx: [
|
|
76
78
|
{ borderRadius: "16px" },
|
|
77
|
-
...Array.isArray(
|
|
79
|
+
...Array.isArray(i == null ? void 0 : i.sx) ? i == null ? void 0 : i.sx : [i == null ? void 0 : i.sx]
|
|
78
80
|
]
|
|
79
81
|
}
|
|
80
|
-
) : /* @__PURE__ */
|
|
82
|
+
) : /* @__PURE__ */ t(I, { variant: "rounded", height: "325px", width: "300px", ...i }) : e ? e.outcome === "failure" && w[a].format === "status" ? /* @__PURE__ */ t(
|
|
81
83
|
q,
|
|
82
84
|
{
|
|
83
|
-
icon: /* @__PURE__ */
|
|
84
|
-
label:
|
|
85
|
+
icon: /* @__PURE__ */ t(J, { title: e.error, children: /* @__PURE__ */ t(H, { icon: "mdi:information-outline", fontSize: "1.25rem" }) }),
|
|
86
|
+
label: m("error"),
|
|
85
87
|
color: "error",
|
|
86
88
|
...v
|
|
87
89
|
}
|
|
88
|
-
) : e.outcome === "pending" ? /* @__PURE__ */
|
|
89
|
-
((M = e.data) == null ? void 0 : M.summary) && /* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
90
|
+
) : e.outcome === "pending" ? /* @__PURE__ */ l(f, { flex: 1, sx: { pt: 2, alignItems: "center" }, spacing: 1, children: [
|
|
91
|
+
((M = e.data) == null ? void 0 : M.summary) && /* @__PURE__ */ t(K, { variant: "caption", children: e.data.summary }),
|
|
92
|
+
/* @__PURE__ */ t(
|
|
91
93
|
Q,
|
|
92
94
|
{
|
|
93
95
|
variant: (T = e.data) != null && T.progress ? "determinate" : "indeterminate",
|
|
@@ -95,10 +97,10 @@ const ae = p.memo(
|
|
|
95
97
|
sx: { maxWidth: 500, width: "100%", borderRadius: d.shape.borderRadius }
|
|
96
98
|
}
|
|
97
99
|
)
|
|
98
|
-
] }) :
|
|
100
|
+
] }) : e.format === "status" ? /* @__PURE__ */ t(oe, { data: e.data, ...v }) : /* @__PURE__ */ t(
|
|
99
101
|
U,
|
|
100
102
|
{
|
|
101
|
-
...
|
|
103
|
+
...n,
|
|
102
104
|
sx: [
|
|
103
105
|
{
|
|
104
106
|
p: 1,
|
|
@@ -107,10 +109,10 @@ const ae = p.memo(
|
|
|
107
109
|
width: "100%",
|
|
108
110
|
minWidth: "300px"
|
|
109
111
|
},
|
|
110
|
-
...Array.isArray(
|
|
112
|
+
...Array.isArray(n == null ? void 0 : n.sx) ? n == null ? void 0 : n.sx : [n == null ? void 0 : n.sx]
|
|
111
113
|
],
|
|
112
|
-
children: /* @__PURE__ */
|
|
113
|
-
|
|
114
|
+
children: /* @__PURE__ */ l(
|
|
115
|
+
f,
|
|
114
116
|
{
|
|
115
117
|
sx: {
|
|
116
118
|
"& > img": {
|
|
@@ -124,14 +126,14 @@ const ae = p.memo(
|
|
|
124
126
|
}
|
|
125
127
|
},
|
|
126
128
|
children: [
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
|
|
129
|
+
e.outcome === "failure" && /* @__PURE__ */ t("code", { style: { color: d.palette.error.main }, children: /* @__PURE__ */ t("pre", { style: { marginTop: 0, marginBottom: 0 }, children: e.error }) }),
|
|
130
|
+
e.format === "markdown" && /* @__PURE__ */ t(ie, { md: e.data }),
|
|
131
|
+
e.format === "image" && /* @__PURE__ */ t("img", { src: e.data.image, alt: e.data.alt, ...W, onClick: () => _(!0) }),
|
|
132
|
+
e.format === "json" && /* @__PURE__ */ t(X, { sx: { ".react-json-view": { backgroundColor: "transparent !important" } }, children: /* @__PURE__ */ t(Z, { data: e.data }) }),
|
|
133
|
+
e.format === "graph" && /* @__PURE__ */ t(re, { graph: e.data, sx: { minHeight: "600px" } }),
|
|
134
|
+
/* @__PURE__ */ t(L, {}),
|
|
135
|
+
/* @__PURE__ */ l(
|
|
136
|
+
f,
|
|
135
137
|
{
|
|
136
138
|
direction: "row",
|
|
137
139
|
spacing: 1,
|
|
@@ -145,41 +147,41 @@ const ae = p.memo(
|
|
|
145
147
|
...Array.isArray(o == null ? void 0 : o.sx) ? o == null ? void 0 : o.sx : [o == null ? void 0 : o.sx]
|
|
146
148
|
],
|
|
147
149
|
children: [
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
+
/* @__PURE__ */ t(S, { icon: "ic:baseline-landscape", color: "primary", fontSize: "small" }),
|
|
151
|
+
/* @__PURE__ */ t(
|
|
150
152
|
J,
|
|
151
153
|
{
|
|
152
|
-
title: /* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
|
|
154
|
+
title: /* @__PURE__ */ l(f, { spacing: 0.5, children: [
|
|
155
|
+
/* @__PURE__ */ l("span", { children: [
|
|
156
|
+
m("type"),
|
|
155
157
|
": ",
|
|
156
|
-
|
|
158
|
+
h
|
|
157
159
|
] }),
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
|
|
160
|
+
/* @__PURE__ */ l("span", { children: [
|
|
161
|
+
m("value"),
|
|
160
162
|
": ",
|
|
161
163
|
x
|
|
162
164
|
] }),
|
|
163
|
-
/* @__PURE__ */
|
|
164
|
-
|
|
165
|
+
/* @__PURE__ */ l("span", { children: [
|
|
166
|
+
m("classification"),
|
|
165
167
|
": ",
|
|
166
168
|
g ?? "N/A"
|
|
167
169
|
] })
|
|
168
170
|
] }),
|
|
169
|
-
children: /* @__PURE__ */
|
|
171
|
+
children: /* @__PURE__ */ t(S, { icon: "ic:outline-info", fontSize: "small" })
|
|
170
172
|
}
|
|
171
173
|
),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
174
|
+
/* @__PURE__ */ t(L, {}),
|
|
175
|
+
e.link && /* @__PURE__ */ t(Y, { size: "small", component: "a", href: e.link, children: /* @__PURE__ */ t(S, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
|
|
174
176
|
]
|
|
175
177
|
}
|
|
176
178
|
),
|
|
177
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ t(ne, { ...O, open: G, result: e, onClose: () => _(!1) })
|
|
178
180
|
]
|
|
179
181
|
}
|
|
180
182
|
)
|
|
181
183
|
}
|
|
182
|
-
);
|
|
184
|
+
) : null;
|
|
183
185
|
}
|
|
184
186
|
), be = ee(ae);
|
|
185
187
|
export {
|
package/en/translation.json
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"drawer.mail.trash": "Trash",
|
|
52
52
|
"enrich": "Enrich",
|
|
53
53
|
"error": "Error",
|
|
54
|
+
"fetcher.error.unexpected": "An unexpected error occurred",
|
|
54
55
|
"graph.no.dataset": "No dataset has been selected!",
|
|
55
56
|
"graph.node.input.label": "Enter a node ID, and press [ctrl + enter] to select it. [ctrl + space] will open an autocomplete menu.",
|
|
56
57
|
"graph.show.more": "show more",
|
package/fr/translation.json
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"drawer.mail.trash": "Poubelle",
|
|
52
52
|
"enrich": "Enrichir",
|
|
53
53
|
"error": "Erreur",
|
|
54
|
+
"fetcher.error.unexpected": "Une erreur inattendue s'est produite",
|
|
54
55
|
"graph.no.dataset": "Aucun jeu de données n'a été sélectionné!",
|
|
55
56
|
"graph.node.input.label": "Entrez un ID de nœud et appuyez sur [ctrl + entrée] pour le sélectionner. [ctrl + espace] ouvrira un menu d'auto-complétion.",
|
|
56
57
|
"graph.show.more": "Afficher plus",
|