@burdenoff/microfe-bigconsole 2026.1103.6 → 2026.1103.8
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/bigconsole/components/insights/PromptAnalysisPreview.d.ts +21 -0
- package/dist/bigconsole/components/insights/PromptAnalysisPreview.js +203 -0
- package/dist/bigconsole/hooks/useDashboardImageExport.js +44 -64
- package/dist/bigconsole/hooks/useWidgetExport.js +37 -51
- package/dist/bigconsole/pages/InsightsPage.js +242 -237
- package/dist/bigconsole/utils/elementToCanvas.d.ts +9 -0
- package/dist/bigconsole/utils/elementToCanvas.js +16 -0
- package/dist/node_modules/html-to-image/es/apply-style.js +11 -0
- package/dist/node_modules/html-to-image/es/clone-node.js +82 -0
- package/dist/node_modules/html-to-image/es/clone-pseudos.js +30 -0
- package/dist/node_modules/html-to-image/es/dataurl.js +49 -0
- package/dist/node_modules/html-to-image/es/embed-images.js +41 -0
- package/dist/node_modules/html-to-image/es/embed-resources.js +39 -0
- package/dist/node_modules/html-to-image/es/embed-webfonts.js +115 -0
- package/dist/node_modules/html-to-image/es/index.js +16 -0
- package/dist/node_modules/html-to-image/es/mimes.js +23 -0
- package/dist/node_modules/html-to-image/es/util.js +75 -0
- package/package.json +3 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface PromptAnalysis {
|
|
3
|
+
detectedIntent: string;
|
|
4
|
+
suggestedCategory: string;
|
|
5
|
+
estimatedWidgetCount: number;
|
|
6
|
+
suggestedWidgetTypes: string[];
|
|
7
|
+
detectedMetrics: string[];
|
|
8
|
+
dataRequirements: string[];
|
|
9
|
+
confidence: number;
|
|
10
|
+
suggestedRefinements?: string[] | null;
|
|
11
|
+
}
|
|
12
|
+
/** `BAR_CHART` -> `Bar chart`; a short single word stays an acronym (`KPI`). */
|
|
13
|
+
export declare function humanizeEnum(value: string): string;
|
|
14
|
+
interface Props {
|
|
15
|
+
/** The prompt as currently typed. */
|
|
16
|
+
prompt: string;
|
|
17
|
+
/** Disable the control while a generation is being submitted. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const PromptAnalysisPreview: FC<Props>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { reportBigConsoleQuotaError as e } from "../../utils/quota.js";
|
|
2
|
+
import { SECTION_FOCUS_RING as t } from "../common/sectionStyles.js";
|
|
3
|
+
import "../common/index.js";
|
|
4
|
+
import { memo as n, useCallback as r, useState as i } from "react";
|
|
5
|
+
import { Loader2 as a, ScanSearch as o } from "lucide-react";
|
|
6
|
+
import { useI18n as s } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
7
|
+
import { useApolloClient as c } from "@apollo/client/react";
|
|
8
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
import { gql as d } from "@apollo/client";
|
|
10
|
+
//#region src/bigconsole/components/insights/PromptAnalysisPreview.tsx
|
|
11
|
+
var f = d`
|
|
12
|
+
query PreviewPromptAnalysis($prompt: String!) {
|
|
13
|
+
previewPromptAnalysis(prompt: $prompt) {
|
|
14
|
+
detectedIntent
|
|
15
|
+
suggestedCategory
|
|
16
|
+
estimatedWidgetCount
|
|
17
|
+
suggestedWidgetTypes
|
|
18
|
+
detectedMetrics
|
|
19
|
+
dataRequirements
|
|
20
|
+
confidence
|
|
21
|
+
suggestedRefinements
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
function p(e) {
|
|
26
|
+
let t = e.split("_").filter(Boolean);
|
|
27
|
+
if (t.length === 1 && t[0].length <= 3) return t[0].toUpperCase();
|
|
28
|
+
let n = t.join(" ").toLowerCase();
|
|
29
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
30
|
+
}
|
|
31
|
+
var m = {
|
|
32
|
+
display: "inline-flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
gap: "var(--space-iconGap)",
|
|
35
|
+
minHeight: "var(--size-controlHeight-md)",
|
|
36
|
+
padding: "0 var(--space-formGap)",
|
|
37
|
+
borderRadius: "var(--radius-button)",
|
|
38
|
+
border: "1px solid var(--color-border-default)",
|
|
39
|
+
backgroundColor: "transparent",
|
|
40
|
+
color: "var(--color-text-primary)",
|
|
41
|
+
fontSize: "var(--font-size-body-sm)",
|
|
42
|
+
fontWeight: "var(--font-weight-medium)"
|
|
43
|
+
}, h = {
|
|
44
|
+
display: "flex",
|
|
45
|
+
flexDirection: "column",
|
|
46
|
+
gap: "var(--space-iconGap)",
|
|
47
|
+
padding: "var(--space-controlGap) var(--space-formGap)",
|
|
48
|
+
borderRadius: "var(--radius-input)",
|
|
49
|
+
border: "1px solid var(--color-border-subtle)",
|
|
50
|
+
backgroundColor: "var(--color-bg-sunken)",
|
|
51
|
+
fontSize: "var(--font-size-body-sm)",
|
|
52
|
+
color: "var(--color-text-secondary)"
|
|
53
|
+
}, g = {
|
|
54
|
+
padding: "0 var(--space-iconGap)",
|
|
55
|
+
borderRadius: "var(--radius-button)",
|
|
56
|
+
border: "1px solid var(--color-border-subtle)",
|
|
57
|
+
color: "var(--color-text-primary)"
|
|
58
|
+
}, _ = n(function({ prompt: n, disabled: d = !1 }) {
|
|
59
|
+
let { t: _ } = s(), v = c(), [y, b] = i(null), [x, S] = i(null), [C, w] = i(!1), T = n.trim(), E = r(async () => {
|
|
60
|
+
if (!(!T || C)) {
|
|
61
|
+
w(!0), S(null);
|
|
62
|
+
try {
|
|
63
|
+
let t = await v.query({
|
|
64
|
+
query: f,
|
|
65
|
+
variables: { prompt: T },
|
|
66
|
+
fetchPolicy: "network-only"
|
|
67
|
+
});
|
|
68
|
+
if (e(t, "command")) return;
|
|
69
|
+
let n = t.data?.previewPromptAnalysis;
|
|
70
|
+
n ? b({
|
|
71
|
+
prompt: T,
|
|
72
|
+
result: n
|
|
73
|
+
}) : S(_("bigconsole.insights.analysis.failed", "Could not analyse this prompt. Please try again."));
|
|
74
|
+
} catch (t) {
|
|
75
|
+
if (e(t, "command")) return;
|
|
76
|
+
S(t instanceof Error ? t.message : _("bigconsole.insights.analysis.failed", "Could not analyse this prompt. Please try again."));
|
|
77
|
+
} finally {
|
|
78
|
+
w(!1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, [
|
|
82
|
+
C,
|
|
83
|
+
v,
|
|
84
|
+
_,
|
|
85
|
+
T
|
|
86
|
+
]), D = y && y.prompt === T ? y.result : null, O = y !== null && D === null, k = "prompt-analysis-hint";
|
|
87
|
+
return /* @__PURE__ */ u("div", {
|
|
88
|
+
style: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
flexDirection: "column",
|
|
91
|
+
gap: "var(--space-controlGap)"
|
|
92
|
+
},
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ u("div", {
|
|
95
|
+
style: {
|
|
96
|
+
display: "flex",
|
|
97
|
+
alignItems: "center",
|
|
98
|
+
flexWrap: "wrap",
|
|
99
|
+
gap: "var(--space-controlGap)"
|
|
100
|
+
},
|
|
101
|
+
children: [/* @__PURE__ */ u("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
onClick: () => void E(),
|
|
104
|
+
disabled: !T || C || d,
|
|
105
|
+
"aria-describedby": k,
|
|
106
|
+
className: t,
|
|
107
|
+
style: {
|
|
108
|
+
...m,
|
|
109
|
+
cursor: !T || C || d ? "not-allowed" : "pointer",
|
|
110
|
+
opacity: !T || C || d ? .5 : 1
|
|
111
|
+
},
|
|
112
|
+
children: [C ? /* @__PURE__ */ l(a, {
|
|
113
|
+
size: 16,
|
|
114
|
+
className: "animate-spin",
|
|
115
|
+
"aria-hidden": "true"
|
|
116
|
+
}) : /* @__PURE__ */ l(o, {
|
|
117
|
+
size: 16,
|
|
118
|
+
"aria-hidden": "true"
|
|
119
|
+
}), _("bigconsole.insights.analysis.button", "Preview analysis")]
|
|
120
|
+
}), /* @__PURE__ */ l("span", {
|
|
121
|
+
id: k,
|
|
122
|
+
style: {
|
|
123
|
+
fontSize: "var(--font-size-body-sm)",
|
|
124
|
+
color: "var(--color-text-muted)"
|
|
125
|
+
},
|
|
126
|
+
children: _("bigconsole.insights.analysis.hint", "See the detected intent and widget estimate. Uses 1 AI command.")
|
|
127
|
+
})]
|
|
128
|
+
}),
|
|
129
|
+
x && /* @__PURE__ */ l("p", {
|
|
130
|
+
role: "alert",
|
|
131
|
+
style: {
|
|
132
|
+
margin: 0,
|
|
133
|
+
fontSize: "var(--font-size-body-sm)",
|
|
134
|
+
color: "var(--color-status-error-text)"
|
|
135
|
+
},
|
|
136
|
+
children: x
|
|
137
|
+
}),
|
|
138
|
+
O && !x && /* @__PURE__ */ l("p", {
|
|
139
|
+
style: {
|
|
140
|
+
margin: 0,
|
|
141
|
+
fontSize: "var(--font-size-body-sm)",
|
|
142
|
+
color: "var(--color-text-muted)"
|
|
143
|
+
},
|
|
144
|
+
children: _("bigconsole.insights.analysis.stale", "The prompt changed since the last analysis. Preview it again.")
|
|
145
|
+
}),
|
|
146
|
+
D && /* @__PURE__ */ u("div", {
|
|
147
|
+
role: "status",
|
|
148
|
+
"data-testid": "prompt-analysis",
|
|
149
|
+
style: h,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ u("div", { children: [
|
|
152
|
+
/* @__PURE__ */ u("strong", {
|
|
153
|
+
style: { color: "var(--color-text-primary)" },
|
|
154
|
+
children: [_("bigconsole.insights.analysis.intent", "Detected intent"), ":"]
|
|
155
|
+
}),
|
|
156
|
+
" ",
|
|
157
|
+
D.detectedIntent,
|
|
158
|
+
" (",
|
|
159
|
+
p(D.suggestedCategory),
|
|
160
|
+
")"
|
|
161
|
+
] }),
|
|
162
|
+
/* @__PURE__ */ u("div", { children: [
|
|
163
|
+
/* @__PURE__ */ u("strong", {
|
|
164
|
+
style: { color: "var(--color-text-primary)" },
|
|
165
|
+
children: [_("bigconsole.insights.analysis.widgetCount", "Estimated widgets"), ":"]
|
|
166
|
+
}),
|
|
167
|
+
" ",
|
|
168
|
+
D.estimatedWidgetCount
|
|
169
|
+
] }),
|
|
170
|
+
D.suggestedWidgetTypes.length > 0 && /* @__PURE__ */ l("div", {
|
|
171
|
+
style: {
|
|
172
|
+
display: "flex",
|
|
173
|
+
flexWrap: "wrap",
|
|
174
|
+
gap: "var(--space-iconGap)"
|
|
175
|
+
},
|
|
176
|
+
children: D.suggestedWidgetTypes.map((e) => /* @__PURE__ */ l("span", {
|
|
177
|
+
style: g,
|
|
178
|
+
children: p(e)
|
|
179
|
+
}, e))
|
|
180
|
+
}),
|
|
181
|
+
D.detectedMetrics.length > 0 && /* @__PURE__ */ u("div", { children: [
|
|
182
|
+
/* @__PURE__ */ u("strong", {
|
|
183
|
+
style: { color: "var(--color-text-primary)" },
|
|
184
|
+
children: [_("bigconsole.insights.analysis.metrics", "Metrics"), ":"]
|
|
185
|
+
}),
|
|
186
|
+
" ",
|
|
187
|
+
D.detectedMetrics.join(", ")
|
|
188
|
+
] }),
|
|
189
|
+
(D.suggestedRefinements?.length ?? 0) > 0 && /* @__PURE__ */ u("div", { children: [
|
|
190
|
+
/* @__PURE__ */ u("strong", {
|
|
191
|
+
style: { color: "var(--color-text-primary)" },
|
|
192
|
+
children: [_("bigconsole.insights.analysis.suggestions", "Suggestions"), ":"]
|
|
193
|
+
}),
|
|
194
|
+
" ",
|
|
195
|
+
D.suggestedRefinements?.join("; ")
|
|
196
|
+
] })
|
|
197
|
+
]
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
//#endregion
|
|
203
|
+
export { _ as PromptAnalysisPreview, p as humanizeEnum };
|
|
@@ -1,90 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { elementToCanvas as e } from "../utils/elementToCanvas.js";
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
4
|
+
import { toast as i } from "sonner";
|
|
2
5
|
//#region src/bigconsole/hooks/useDashboardImageExport.ts
|
|
3
|
-
function
|
|
6
|
+
function a(e, t) {
|
|
4
7
|
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
5
8
|
r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
|
|
6
9
|
}
|
|
7
|
-
function
|
|
8
|
-
let t =
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
async function i(e) {
|
|
12
|
-
if (typeof window < "u" && "html2canvas" in window) return await window.html2canvas(e, {
|
|
13
|
-
backgroundColor: r(e),
|
|
14
|
-
scale: 2,
|
|
15
|
-
useCORS: !0
|
|
16
|
-
});
|
|
17
|
-
let t = document.createElement("canvas"), n = t.getContext("2d");
|
|
18
|
-
if (!n) throw Error("Could not get canvas context");
|
|
19
|
-
let i = e.getBoundingClientRect();
|
|
20
|
-
t.width = i.width * 2, t.height = i.height * 2, n.scale(2, 2), n.fillStyle = r(e), n.fillRect(0, 0, i.width, i.height);
|
|
21
|
-
let a = e.querySelectorAll("svg");
|
|
22
|
-
for (let e of a) {
|
|
23
|
-
let t = new XMLSerializer().serializeToString(e), r = new Blob([t], { type: "image/svg+xml;charset=utf-8" }), a = URL.createObjectURL(r);
|
|
24
|
-
try {
|
|
25
|
-
await new Promise((t) => {
|
|
26
|
-
let r = new Image();
|
|
27
|
-
r.onload = () => {
|
|
28
|
-
let a = e.getBoundingClientRect();
|
|
29
|
-
n.drawImage(r, a.left - i.left, a.top - i.top), t();
|
|
30
|
-
}, r.onerror = () => t(), r.src = a;
|
|
31
|
-
});
|
|
32
|
-
} finally {
|
|
33
|
-
URL.revokeObjectURL(a);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return t;
|
|
37
|
-
}
|
|
38
|
-
function a(r) {
|
|
39
|
-
let { containerRef: a, name: o = "dashboard" } = r, [s, c] = t(!1);
|
|
10
|
+
function o(o) {
|
|
11
|
+
let { containerRef: s, name: c = "dashboard" } = o, [l, u] = n(!1), { t: d } = r(), f = t(() => {
|
|
12
|
+
i.error(d("bigconsole.dashboards.export.failed", "Could not export the dashboard. Please try again."));
|
|
13
|
+
}, [d]);
|
|
40
14
|
return {
|
|
41
|
-
exportPNG:
|
|
42
|
-
let
|
|
43
|
-
if (!(!
|
|
44
|
-
|
|
15
|
+
exportPNG: t(async (t) => {
|
|
16
|
+
let n = s.current;
|
|
17
|
+
if (!(!n || l)) {
|
|
18
|
+
u(!0);
|
|
45
19
|
try {
|
|
46
|
-
let r = await
|
|
20
|
+
let r = await e(n), i = await new Promise((e, t) => {
|
|
47
21
|
r.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("Failed to create image blob")), "image/png");
|
|
48
|
-
}),
|
|
49
|
-
|
|
22
|
+
}), o = c.replace(/\s+/g, "_").toLowerCase();
|
|
23
|
+
a(i, t || `${o}_board.png`);
|
|
24
|
+
} catch {
|
|
25
|
+
f();
|
|
50
26
|
} finally {
|
|
51
|
-
|
|
27
|
+
u(!1);
|
|
52
28
|
}
|
|
53
29
|
}
|
|
54
30
|
}, [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
s,
|
|
32
|
+
c,
|
|
33
|
+
l,
|
|
34
|
+
f
|
|
58
35
|
]),
|
|
59
|
-
exportPDF:
|
|
60
|
-
let
|
|
61
|
-
if (!(!
|
|
62
|
-
|
|
36
|
+
exportPDF: t(async () => {
|
|
37
|
+
let t = s.current;
|
|
38
|
+
if (!(!t || l)) {
|
|
39
|
+
u(!0);
|
|
63
40
|
try {
|
|
64
|
-
let
|
|
41
|
+
let n = await e(t), r = n.toDataURL("image/png"), i = `${c} — board`, a = window.open("", "_blank");
|
|
65
42
|
if (!a) {
|
|
66
43
|
window.print();
|
|
67
44
|
return;
|
|
68
45
|
}
|
|
69
|
-
let
|
|
70
|
-
|
|
71
|
-
let l =
|
|
72
|
-
l.textContent = `@page{size:${
|
|
73
|
-
let u =
|
|
74
|
-
u.alt =
|
|
46
|
+
let o = n.width >= n.height ? "landscape" : "portrait", s = a.document;
|
|
47
|
+
s.title = i;
|
|
48
|
+
let l = s.createElement("style");
|
|
49
|
+
l.textContent = `@page{size:${o};margin:12mm}html,body{margin:0;padding:0}img{width:100%;height:auto;display:block}`, s.head.appendChild(l);
|
|
50
|
+
let u = s.createElement("img");
|
|
51
|
+
u.alt = i, u.addEventListener("load", () => {
|
|
75
52
|
a.focus(), a.print();
|
|
76
|
-
}), u.src =
|
|
53
|
+
}), u.src = r, s.body.appendChild(u);
|
|
54
|
+
} catch {
|
|
55
|
+
f();
|
|
77
56
|
} finally {
|
|
78
|
-
|
|
57
|
+
u(!1);
|
|
79
58
|
}
|
|
80
59
|
}
|
|
81
60
|
}, [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
61
|
+
s,
|
|
62
|
+
c,
|
|
63
|
+
l,
|
|
64
|
+
f
|
|
85
65
|
]),
|
|
86
|
-
isExporting:
|
|
66
|
+
isExporting: l
|
|
87
67
|
};
|
|
88
68
|
}
|
|
89
69
|
//#endregion
|
|
90
|
-
export {
|
|
70
|
+
export { o as default, o as useDashboardImageExport };
|
|
@@ -1,75 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { elementToCanvas as e } from "../utils/elementToCanvas.js";
|
|
2
|
+
import { useCallback as t, useRef as n } from "react";
|
|
3
|
+
import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
4
|
+
import { toast as i } from "sonner";
|
|
2
5
|
//#region src/bigconsole/hooks/useWidgetExport.ts
|
|
3
|
-
function
|
|
6
|
+
function a(e) {
|
|
4
7
|
if (!e.length) return "";
|
|
5
8
|
let t = Object.keys(e[0]), n = [];
|
|
6
|
-
n.push(t.map(
|
|
7
|
-
for (let
|
|
9
|
+
n.push(t.map(o).join(","));
|
|
10
|
+
for (let r of e) {
|
|
8
11
|
let e = t.map((e) => {
|
|
9
|
-
let t =
|
|
10
|
-
return
|
|
12
|
+
let t = r[e];
|
|
13
|
+
return o(t);
|
|
11
14
|
});
|
|
12
15
|
n.push(e.join(","));
|
|
13
16
|
}
|
|
14
17
|
return n.join("\n");
|
|
15
18
|
}
|
|
16
|
-
function
|
|
19
|
+
function o(e) {
|
|
17
20
|
if (e == null) return "";
|
|
18
21
|
let t = String(e);
|
|
19
22
|
return t.includes(",") || t.includes("\"") || t.includes("\n") || t.includes("\r") ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
20
23
|
}
|
|
21
|
-
function
|
|
24
|
+
function s(e, t, n) {
|
|
22
25
|
let r = e instanceof Blob ? e : new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
23
26
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), setTimeout(() => URL.revokeObjectURL(i), 100);
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
backgroundColor: null,
|
|
28
|
-
scale: 2,
|
|
29
|
-
logging: !1,
|
|
30
|
-
useCORS: !0
|
|
31
|
-
});
|
|
32
|
-
let t = document.createElement("canvas"), n = t.getContext("2d");
|
|
33
|
-
if (!n) throw Error("Could not get canvas context");
|
|
34
|
-
let r = e.getBoundingClientRect();
|
|
35
|
-
t.width = r.width * 2, t.height = r.height * 2, n.scale(2, 2);
|
|
36
|
-
let i = e.querySelectorAll("svg");
|
|
37
|
-
if (i.length > 0) for (let e of i) {
|
|
38
|
-
let t = new XMLSerializer().serializeToString(e), i = new Blob([t], { type: "image/svg+xml;charset=utf-8" }), a = URL.createObjectURL(i), o = new Image();
|
|
39
|
-
await new Promise((t, i) => {
|
|
40
|
-
o.onload = () => {
|
|
41
|
-
let i = e.getBoundingClientRect(), s = i.left - r.left, c = i.top - r.top;
|
|
42
|
-
n.drawImage(o, s, c), URL.revokeObjectURL(a), t();
|
|
43
|
-
}, o.onerror = i, o.src = a;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return n.globalCompositeOperation = "destination-over", n.fillStyle = getComputedStyle(e).backgroundColor || "#ffffff", n.fillRect(0, 0, t.width / 2, t.height / 2), t;
|
|
47
|
-
}
|
|
48
|
-
function o(r, o = {}) {
|
|
49
|
-
let { data: s, containerRef: c } = o, l = t(!1);
|
|
28
|
+
function c(o, c = {}) {
|
|
29
|
+
let { data: l, containerRef: u } = c, d = n(!1), { t: f } = r();
|
|
50
30
|
return {
|
|
51
|
-
exportCSV:
|
|
52
|
-
if (!
|
|
53
|
-
let t =
|
|
54
|
-
|
|
55
|
-
}, [
|
|
56
|
-
exportPNG:
|
|
57
|
-
if (
|
|
58
|
-
|
|
31
|
+
exportCSV: t((e) => {
|
|
32
|
+
if (!l?.length) return;
|
|
33
|
+
let t = a(l), n = `${o.title.replace(/\s+/g, "_").toLowerCase()}_${Date.now()}.csv`;
|
|
34
|
+
s(t, e || n, "text/csv;charset=utf-8");
|
|
35
|
+
}, [l, o.title]),
|
|
36
|
+
exportPNG: t(async (t) => {
|
|
37
|
+
if (u?.current && !d.current) {
|
|
38
|
+
d.current = !0;
|
|
59
39
|
try {
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
let n = await e(u.current), r = await new Promise((e, t) => {
|
|
41
|
+
n.toBlob((n) => {
|
|
42
|
+
n ? e(n) : t(/* @__PURE__ */ Error("Failed to create image blob"));
|
|
63
43
|
}, "image/png");
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
} catch {
|
|
67
|
-
|
|
44
|
+
}), i = `${o.title.replace(/\s+/g, "_").toLowerCase()}_${Date.now()}.png`;
|
|
45
|
+
s(r, t || i, "image/png");
|
|
46
|
+
} catch {
|
|
47
|
+
i.error(f("bigconsole.widget.export.failed", "Could not export the widget image. Please try again."));
|
|
48
|
+
} finally {
|
|
49
|
+
d.current = !1;
|
|
68
50
|
}
|
|
69
51
|
}
|
|
70
|
-
}, [
|
|
71
|
-
|
|
52
|
+
}, [
|
|
53
|
+
u,
|
|
54
|
+
o.title,
|
|
55
|
+
f
|
|
56
|
+
]),
|
|
57
|
+
isExporting: d.current
|
|
72
58
|
};
|
|
73
59
|
}
|
|
74
60
|
//#endregion
|
|
75
|
-
export {
|
|
61
|
+
export { c as default, c as useWidgetExport };
|