@malloydata/malloy-explorer 0.0.331-dev260103000551 → 0.0.337-dev260213014950
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 +37 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +38 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/types/components/CodeEditor/lsp/stub_compile.d.ts +1 -0
- package/dist/types/components/MalloyExplorerProvider.d.ts +9 -1
- package/dist/types/components/ResultPanel/DownloadButton.d.ts +4 -2
- package/dist/types/components/primitives/Badge.spec.d.ts +3 -0
- package/dist/types/contexts/QueryEditorContext.d.ts +2 -0
- package/jest.config.cjs +1 -1
- package/package.json +8 -8
package/dist/esm/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import React__default, { useLayoutEffect, useEffect, useMemo, createContext, use
|
|
|
19
19
|
import { Runtime, Malloy, malloyToQuery, MalloyError } from "@malloydata/malloy";
|
|
20
20
|
import { malloyToQuery as malloyToQuery2, modelDefToModelInfo } from "@malloydata/malloy";
|
|
21
21
|
import { ASTQuery, ASTArrowQueryDefinition, ASTArrowViewDefinition, ASTSegmentViewDefinition, ASTNestViewOperation, ASTRefinementViewDefinition, ASTFilterWithLiteralEquality, ASTAnnotation, ASTLimitViewOperation, ASTOrderByViewOperation, ASTGroupByViewOperation, ASTAggregateViewOperation, ASTCalculateViewOperation, ASTTimeTruncationExpression, ASTFilterWithFilterString, ASTReferenceExpression, ASTWhereViewOperation, ASTHavingViewOperation, ASTDrillViewOperation, ASTReferenceQueryArrowSource } from "@malloydata/malloy-query-builder";
|
|
22
|
-
import {
|
|
22
|
+
import { parseTag } from "@malloydata/malloy-tag";
|
|
23
23
|
import { MalloyRenderer, isCoreVizPluginInstance } from "@malloydata/render";
|
|
24
24
|
import { TemporalFilterExpression, BooleanFilterExpression, NumberFilterExpression, StringFilterExpression } from "@malloydata/malloy-filter";
|
|
25
25
|
import * as ReactDOM from "react-dom";
|
|
@@ -3463,7 +3463,8 @@ function MalloyExplorerProvider({
|
|
|
3463
3463
|
topValues,
|
|
3464
3464
|
onDrill,
|
|
3465
3465
|
theme,
|
|
3466
|
-
dark
|
|
3466
|
+
dark,
|
|
3467
|
+
onDownload
|
|
3467
3468
|
}) {
|
|
3468
3469
|
const rootQuery = useQueryBuilder(source, query);
|
|
3469
3470
|
const updateQuery = useCallback(() => {
|
|
@@ -3491,6 +3492,7 @@ function MalloyExplorerProvider({
|
|
|
3491
3492
|
rootQuery,
|
|
3492
3493
|
setQuery: onQueryChange,
|
|
3493
3494
|
onDrill,
|
|
3495
|
+
onDownload,
|
|
3494
3496
|
query
|
|
3495
3497
|
},
|
|
3496
3498
|
children: /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
@@ -32322,7 +32324,7 @@ function Visualization({
|
|
|
32322
32324
|
}) {
|
|
32323
32325
|
const {
|
|
32324
32326
|
tag
|
|
32325
|
-
} =
|
|
32327
|
+
} = parseTag(annotations.map((annotation) => annotation.value));
|
|
32326
32328
|
const renderer = tagToRenderer(tag) ?? "table";
|
|
32327
32329
|
return /* @__PURE__ */ jsx(Token, {
|
|
32328
32330
|
label: snakeToTitle(renderer),
|
|
@@ -36166,6 +36168,9 @@ class StubConnection extends BaseConnection {
|
|
|
36166
36168
|
this.name = "stub";
|
|
36167
36169
|
this.dialectName = dialectName;
|
|
36168
36170
|
}
|
|
36171
|
+
getDigest() {
|
|
36172
|
+
return "stub";
|
|
36173
|
+
}
|
|
36169
36174
|
runSQL() {
|
|
36170
36175
|
throw new Error("Stub connection cannot run SQL.");
|
|
36171
36176
|
}
|
|
@@ -38552,14 +38557,26 @@ async function* dataIterator(result) {
|
|
|
38552
38557
|
}
|
|
38553
38558
|
function DownloadButton({
|
|
38554
38559
|
name = "malloy",
|
|
38555
|
-
|
|
38560
|
+
source,
|
|
38561
|
+
submittedQuery
|
|
38556
38562
|
}) {
|
|
38563
|
+
var _a2;
|
|
38557
38564
|
const [href, setHref] = useState("");
|
|
38558
38565
|
const [fileName, setFileName] = useState("");
|
|
38559
38566
|
const [format2, _setFormat] = useState("csv");
|
|
38567
|
+
const {
|
|
38568
|
+
onDownload
|
|
38569
|
+
} = useContext(QueryEditorContext);
|
|
38560
38570
|
useEffect(() => {
|
|
38571
|
+
var _a3;
|
|
38572
|
+
if (onDownload) return;
|
|
38573
|
+
const result = (_a3 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _a3.result;
|
|
38574
|
+
if (!result) {
|
|
38575
|
+
setHref("");
|
|
38576
|
+
return;
|
|
38577
|
+
}
|
|
38561
38578
|
const createBlob = async () => {
|
|
38562
|
-
if (!(
|
|
38579
|
+
if (!(submittedQuery == null ? void 0 : submittedQuery.response)) {
|
|
38563
38580
|
setHref("");
|
|
38564
38581
|
return;
|
|
38565
38582
|
}
|
|
@@ -38587,7 +38604,7 @@ function DownloadButton({
|
|
|
38587
38604
|
setFileName(fileName2);
|
|
38588
38605
|
};
|
|
38589
38606
|
void createBlob();
|
|
38590
|
-
}, [name, format2,
|
|
38607
|
+
}, [name, format2, onDownload, submittedQuery]);
|
|
38591
38608
|
useEffect(() => {
|
|
38592
38609
|
return () => {
|
|
38593
38610
|
if (href) {
|
|
@@ -38610,6 +38627,17 @@ function DownloadButton({
|
|
|
38610
38627
|
children: "Download CSV"
|
|
38611
38628
|
})]
|
|
38612
38629
|
});
|
|
38630
|
+
} else if (onDownload && ((_a2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _a2.result)) {
|
|
38631
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
38632
|
+
onClick: () => onDownload({
|
|
38633
|
+
source,
|
|
38634
|
+
submittedQuery,
|
|
38635
|
+
name,
|
|
38636
|
+
format: "csv"
|
|
38637
|
+
}),
|
|
38638
|
+
icon: "download",
|
|
38639
|
+
label: "Download CSV"
|
|
38640
|
+
});
|
|
38613
38641
|
} else {
|
|
38614
38642
|
return null;
|
|
38615
38643
|
}
|
|
@@ -38680,7 +38708,7 @@ function ResultPanel({
|
|
|
38680
38708
|
submittedQuery,
|
|
38681
38709
|
options
|
|
38682
38710
|
}) {
|
|
38683
|
-
var _a2, _b2, _c2
|
|
38711
|
+
var _a2, _b2, _c2;
|
|
38684
38712
|
const {
|
|
38685
38713
|
theme
|
|
38686
38714
|
} = useContext(ThemeContext);
|
|
@@ -38744,7 +38772,8 @@ function ResultPanel({
|
|
|
38744
38772
|
text: clipboardText,
|
|
38745
38773
|
label: "Copy Code"
|
|
38746
38774
|
}), tab === Tab.RESULTS && /* @__PURE__ */ jsx(DownloadButton, {
|
|
38747
|
-
|
|
38775
|
+
source,
|
|
38776
|
+
submittedQuery
|
|
38748
38777
|
})]
|
|
38749
38778
|
}), /* @__PURE__ */ jsxs("div", {
|
|
38750
38779
|
...{
|
|
@@ -38794,7 +38823,7 @@ function ResultPanel({
|
|
|
38794
38823
|
...{
|
|
38795
38824
|
className: "mlywp4ipm mlyh8yej3 mly5yr21d mly9f619"
|
|
38796
38825
|
},
|
|
38797
|
-
children: ((
|
|
38826
|
+
children: ((_c2 = (_b2 = submittedQuery == null ? void 0 : submittedQuery.response) == null ? void 0 : _b2.result) == null ? void 0 : _c2.sql) && /* @__PURE__ */ jsx(CodeBlock, {
|
|
38798
38827
|
code: submittedQuery.response.result.sql,
|
|
38799
38828
|
language: "sql"
|
|
38800
38829
|
})
|