@malloydata/malloy-explorer 0.0.331-dev251231221803 → 0.0.331-dev260122023015
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/@flowtypes/components/MalloyExplorerProvider.flow.js +8 -0
- package/dist/cjs/index.cjs +33 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +33 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/MalloyExplorerProvider.d.ts +9 -1
- package/dist/types/components/ResultPanel/DownloadButton.d.ts +4 -2
- package/dist/types/contexts/QueryEditorContext.d.ts +2 -0
- package/package.json +8 -8
|
@@ -3,6 +3,13 @@ import * as Malloy from "@malloydata/malloy-interfaces";
|
|
|
3
3
|
import type { DrillData } from "@malloydata/render";
|
|
4
4
|
import { SearchValueMapResult } from "../hooks/useTopValues";
|
|
5
5
|
import { ColorTheme } from "./primitives/colors.stylex";
|
|
6
|
+
import { SubmittedQuery } from "./ResultPanel/SubmittedQuery";
|
|
7
|
+
declare export interface MalloyExplorerDownloadProps {
|
|
8
|
+
source: Malloy.SourceInfo;
|
|
9
|
+
submittedQuery: SubmittedQuery;
|
|
10
|
+
name: string;
|
|
11
|
+
format: "json" | "csv";
|
|
12
|
+
}
|
|
6
13
|
declare export interface MalloyExplorerProviderProps {
|
|
7
14
|
source: Malloy.SourceInfo;
|
|
8
15
|
query?: Malloy.Query | string;
|
|
@@ -14,6 +21,7 @@ declare export interface MalloyExplorerProviderProps {
|
|
|
14
21
|
onDrill?: ($$param0$: DrillData) => void;
|
|
15
22
|
theme?: ColorTheme;
|
|
16
23
|
dark?: boolean;
|
|
24
|
+
onDownload?: ($$param0$: MalloyExplorerDownloadProps) => void;
|
|
17
25
|
}
|
|
18
26
|
declare export function MalloyExplorerProvider(
|
|
19
27
|
$$param0$: MalloyExplorerProviderProps,
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3480,7 +3480,8 @@ function MalloyExplorerProvider({
|
|
|
3480
3480
|
topValues,
|
|
3481
3481
|
onDrill,
|
|
3482
3482
|
theme,
|
|
3483
|
-
dark
|
|
3483
|
+
dark,
|
|
3484
|
+
onDownload
|
|
3484
3485
|
}) {
|
|
3485
3486
|
const rootQuery = useQueryBuilder(source, query);
|
|
3486
3487
|
const updateQuery = React.useCallback(() => {
|
|
@@ -3508,6 +3509,7 @@ function MalloyExplorerProvider({
|
|
|
3508
3509
|
rootQuery,
|
|
3509
3510
|
setQuery: onQueryChange,
|
|
3510
3511
|
onDrill,
|
|
3512
|
+
onDownload,
|
|
3511
3513
|
query
|
|
3512
3514
|
},
|
|
3513
3515
|
children: /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, {
|
|
@@ -38569,14 +38571,26 @@ async function* dataIterator(result) {
|
|
|
38569
38571
|
}
|
|
38570
38572
|
function DownloadButton({
|
|
38571
38573
|
name = "malloy",
|
|
38572
|
-
|
|
38574
|
+
source,
|
|
38575
|
+
submittedQuery
|
|
38573
38576
|
}) {
|
|
38577
|
+
var _a2;
|
|
38574
38578
|
const [href, setHref] = React.useState("");
|
|
38575
38579
|
const [fileName, setFileName] = React.useState("");
|
|
38576
38580
|
const [format2, _setFormat] = React.useState("csv");
|
|
38581
|
+
const {
|
|
38582
|
+
onDownload
|
|
38583
|
+
} = React.useContext(QueryEditorContext);
|
|
38577
38584
|
React.useEffect(() => {
|
|
38585
|
+
var _a3;
|
|
38586
|
+
if (onDownload) return;
|
|
38587
|
+
const result = (_a3 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _a3.result;
|
|
38588
|
+
if (!result) {
|
|
38589
|
+
setHref("");
|
|
38590
|
+
return;
|
|
38591
|
+
}
|
|
38578
38592
|
const createBlob = async () => {
|
|
38579
|
-
if (!(
|
|
38593
|
+
if (!(submittedQuery == null ? void 0 : submittedQuery.response)) {
|
|
38580
38594
|
setHref("");
|
|
38581
38595
|
return;
|
|
38582
38596
|
}
|
|
@@ -38604,7 +38618,7 @@ function DownloadButton({
|
|
|
38604
38618
|
setFileName(fileName2);
|
|
38605
38619
|
};
|
|
38606
38620
|
void createBlob();
|
|
38607
|
-
}, [name, format2,
|
|
38621
|
+
}, [name, format2, onDownload, submittedQuery]);
|
|
38608
38622
|
React.useEffect(() => {
|
|
38609
38623
|
return () => {
|
|
38610
38624
|
if (href) {
|
|
@@ -38627,6 +38641,17 @@ function DownloadButton({
|
|
|
38627
38641
|
children: "Download CSV"
|
|
38628
38642
|
})]
|
|
38629
38643
|
});
|
|
38644
|
+
} else if (onDownload && ((_a2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _a2.result)) {
|
|
38645
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Button, {
|
|
38646
|
+
onClick: () => onDownload({
|
|
38647
|
+
source,
|
|
38648
|
+
submittedQuery,
|
|
38649
|
+
name,
|
|
38650
|
+
format: "csv"
|
|
38651
|
+
}),
|
|
38652
|
+
icon: "download",
|
|
38653
|
+
label: "Download CSV"
|
|
38654
|
+
});
|
|
38630
38655
|
} else {
|
|
38631
38656
|
return null;
|
|
38632
38657
|
}
|
|
@@ -38697,7 +38722,7 @@ function ResultPanel({
|
|
|
38697
38722
|
submittedQuery,
|
|
38698
38723
|
options
|
|
38699
38724
|
}) {
|
|
38700
|
-
var _a2, _b2, _c2
|
|
38725
|
+
var _a2, _b2, _c2;
|
|
38701
38726
|
const {
|
|
38702
38727
|
theme
|
|
38703
38728
|
} = React.useContext(ThemeContext);
|
|
@@ -38761,7 +38786,8 @@ function ResultPanel({
|
|
|
38761
38786
|
text: clipboardText,
|
|
38762
38787
|
label: "Copy Code"
|
|
38763
38788
|
}), tab === Tab.RESULTS && /* @__PURE__ */ jsxRuntime.jsx(DownloadButton, {
|
|
38764
|
-
|
|
38789
|
+
source,
|
|
38790
|
+
submittedQuery
|
|
38765
38791
|
})]
|
|
38766
38792
|
}), /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
38767
38793
|
...{
|
|
@@ -38811,7 +38837,7 @@ function ResultPanel({
|
|
|
38811
38837
|
...{
|
|
38812
38838
|
className: "mlywp4ipm mlyh8yej3 mly5yr21d mly9f619"
|
|
38813
38839
|
},
|
|
38814
|
-
children: ((
|
|
38840
|
+
children: ((_c2 = (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result) == null ? void 0 : _c2.sql) && /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, {
|
|
38815
38841
|
code: submittedQuery.response.result.sql,
|
|
38816
38842
|
language: "sql"
|
|
38817
38843
|
})
|