@datawheel/data-explorer 1.0.14 → 1.0.16
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/main.mjs +53 -44
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -484,6 +484,7 @@ var vizbuilderTranslation = {
|
|
|
484
484
|
total: "Total: {{value}}"
|
|
485
485
|
},
|
|
486
486
|
transient: {
|
|
487
|
+
title_one_row: "The dataset has only one row and can't be used to generate charts.",
|
|
487
488
|
title_loading: "Generating charts...",
|
|
488
489
|
title_empty: "No results",
|
|
489
490
|
description_empty: "The selected combination of parameters can't be used to generate a meaningful set of charts. Try changing some parameters (maybe applying some restriction in a column) and generating charts again."
|
|
@@ -2598,10 +2599,10 @@ var DownloadQuery = ({ data }) => {
|
|
|
2598
2599
|
};
|
|
2599
2600
|
var mimeTypes = {
|
|
2600
2601
|
csv: "text/csv",
|
|
2601
|
-
|
|
2602
|
+
jsonrecords: "application/json",
|
|
2602
2603
|
tsv: "text/tab-separated-values",
|
|
2603
|
-
|
|
2604
|
-
|
|
2604
|
+
parquet: "application/octet-stream",
|
|
2605
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2605
2606
|
};
|
|
2606
2607
|
function useDownload(props) {
|
|
2607
2608
|
const { provider } = props;
|
|
@@ -2637,12 +2638,13 @@ function useDownload(props) {
|
|
|
2637
2638
|
}
|
|
2638
2639
|
}, [error]);
|
|
2639
2640
|
const onClick = useCallback(
|
|
2640
|
-
(evt) => {
|
|
2641
|
+
(evt, cb = () => {
|
|
2642
|
+
}) => {
|
|
2641
2643
|
evt.stopPropagation();
|
|
2642
2644
|
evt.preventDefault();
|
|
2643
|
-
return run(provider());
|
|
2645
|
+
return run(provider()).then(cb);
|
|
2644
2646
|
},
|
|
2645
|
-
[run
|
|
2647
|
+
[run]
|
|
2646
2648
|
);
|
|
2647
2649
|
return { onClick, isLoading, data: file, error };
|
|
2648
2650
|
}
|
|
@@ -2659,14 +2661,13 @@ var ItemDownload = (props) => {
|
|
|
2659
2661
|
{
|
|
2660
2662
|
...itemProps,
|
|
2661
2663
|
icon: icon(isLoading),
|
|
2662
|
-
onClick: (e) => {
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}).catch((error) => {
|
|
2664
|
+
onClick: async (e) => {
|
|
2665
|
+
try {
|
|
2666
|
+
onClick(e, () => setOpened(false));
|
|
2667
|
+
} catch (error) {
|
|
2667
2668
|
console.error("Download error:", error);
|
|
2668
2669
|
setOpened(false);
|
|
2669
|
-
}
|
|
2670
|
+
}
|
|
2670
2671
|
}
|
|
2671
2672
|
},
|
|
2672
2673
|
/* @__PURE__ */ React13__default.createElement(Text, { fz: "sm" }, props.children)
|
|
@@ -2676,21 +2677,18 @@ function MenuOpts({ formats }) {
|
|
|
2676
2677
|
const { translate: t } = useTranslation();
|
|
2677
2678
|
const [opened, setOpened] = useState(false);
|
|
2678
2679
|
const { mutateAsync: downloadQuery } = useDownloadQuery();
|
|
2679
|
-
const buttons =
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
[formats, t]
|
|
2692
|
-
);
|
|
2693
|
-
return /* @__PURE__ */ React13__default.createElement(Menu, { shadow: "md", width: 200, opened, onClose: () => setOpened(false) }, /* @__PURE__ */ React13__default.createElement(Menu.Target, null, /* @__PURE__ */ React13__default.createElement(
|
|
2680
|
+
const buttons = formats.map((format2) => /* @__PURE__ */ React13__default.createElement(
|
|
2681
|
+
ItemDownload,
|
|
2682
|
+
{
|
|
2683
|
+
component: "a",
|
|
2684
|
+
key: format2,
|
|
2685
|
+
provider: () => downloadQuery({ format: format2 }),
|
|
2686
|
+
icon: (loading) => loading ? /* @__PURE__ */ React13__default.createElement(Loader, { size: 15 }) : /* @__PURE__ */ React13__default.createElement(IconDownload, { size: 15 }),
|
|
2687
|
+
setOpened
|
|
2688
|
+
},
|
|
2689
|
+
/* @__PURE__ */ React13__default.createElement(Text, { size: "xs" }, t(`formats.${format2}`))
|
|
2690
|
+
));
|
|
2691
|
+
return /* @__PURE__ */ React13__default.createElement(Menu, { shadow: "md", width: 200, opened }, /* @__PURE__ */ React13__default.createElement(Menu.Target, null, /* @__PURE__ */ React13__default.createElement(
|
|
2694
2692
|
ActionIcon,
|
|
2695
2693
|
{
|
|
2696
2694
|
onClick: () => setOpened((o) => !o),
|
|
@@ -4923,6 +4921,7 @@ function SideBarItem({ children }) {
|
|
|
4923
4921
|
function Auto() {
|
|
4924
4922
|
const { translate: t } = useTranslation();
|
|
4925
4923
|
const { expanded, input, setInput } = useSideBar();
|
|
4924
|
+
const [inputValue, setInputValue] = useState(input);
|
|
4926
4925
|
return /* @__PURE__ */ React13__default.createElement(
|
|
4927
4926
|
Input,
|
|
4928
4927
|
{
|
|
@@ -4931,8 +4930,11 @@ function Auto() {
|
|
|
4931
4930
|
radius: "xl",
|
|
4932
4931
|
size: "md",
|
|
4933
4932
|
placeholder: t("params.label_search"),
|
|
4934
|
-
|
|
4935
|
-
onInput: (e) =>
|
|
4933
|
+
value: inputValue,
|
|
4934
|
+
onInput: (e) => {
|
|
4935
|
+
setInputValue(e.currentTarget.value);
|
|
4936
|
+
setInput(e.currentTarget.value);
|
|
4937
|
+
},
|
|
4936
4938
|
styles: {
|
|
4937
4939
|
wrapper: {
|
|
4938
4940
|
width: expanded ? "100%" : 0,
|
|
@@ -4947,7 +4949,10 @@ function Auto() {
|
|
|
4947
4949
|
CloseButton,
|
|
4948
4950
|
{
|
|
4949
4951
|
"aria-label": "Clear input",
|
|
4950
|
-
onClick: () =>
|
|
4952
|
+
onClick: () => {
|
|
4953
|
+
setInput("");
|
|
4954
|
+
setInputValue("");
|
|
4955
|
+
},
|
|
4951
4956
|
style: { display: input ? void 0 : "none" }
|
|
4952
4957
|
}
|
|
4953
4958
|
)
|
|
@@ -7552,6 +7557,9 @@ function NonIdealState2(props) {
|
|
|
7552
7557
|
if (status === "loading") {
|
|
7553
7558
|
return /* @__PURE__ */ React13__default.createElement(Flex, { justify: "center", align: "center", direction: "column" }, /* @__PURE__ */ React13__default.createElement(Loader, { size: "xl" }), /* @__PURE__ */ React13__default.createElement(Title, { mt: "md", order: 4 }, t("vizbuilder.transient.title_loading")));
|
|
7554
7559
|
}
|
|
7560
|
+
if (status === "one-row") {
|
|
7561
|
+
return /* @__PURE__ */ React13__default.createElement(Flex, { justify: "center", align: "center", direction: "column", w: "50%" }, /* @__PURE__ */ React13__default.createElement(IconCircleOff, { size: 92 }), /* @__PURE__ */ React13__default.createElement(Title, { mt: "md", mb: "md", order: 4 }, t("vizbuilder.transient.title_one_row")));
|
|
7562
|
+
}
|
|
7555
7563
|
return /* @__PURE__ */ React13__default.createElement(Flex, { justify: "center", align: "center", direction: "column", w: "50%" }, /* @__PURE__ */ React13__default.createElement(IconCircleOff, { size: 92 }), /* @__PURE__ */ React13__default.createElement(Title, { mt: "md", mb: "md", order: 4 }, t("vizbuilder.transient.title_empty")), /* @__PURE__ */ React13__default.createElement(Text, null, t("vizbuilder.transient.description_empty")));
|
|
7556
7564
|
}, [status, t]);
|
|
7557
7565
|
return /* @__PURE__ */ React13__default.createElement(Center, { h: "100%" }, description);
|
|
@@ -7572,9 +7580,12 @@ function Vizbuilder(props) {
|
|
|
7572
7580
|
const queryItem = useSelector$1(selectCurrentQueryItem);
|
|
7573
7581
|
const currentChart = (queryItem == null ? void 0 : queryItem.chart) || "";
|
|
7574
7582
|
const { actions: actions2 } = useSettings();
|
|
7575
|
-
const setCurrentChart = useCallback(
|
|
7576
|
-
|
|
7577
|
-
|
|
7583
|
+
const setCurrentChart = useCallback(
|
|
7584
|
+
(chart) => {
|
|
7585
|
+
actions2.updateChart(chart);
|
|
7586
|
+
},
|
|
7587
|
+
[actions2]
|
|
7588
|
+
);
|
|
7578
7589
|
const getMeasureConfig = useMemo(() => {
|
|
7579
7590
|
const config = measureConfig || {};
|
|
7580
7591
|
return typeof config === "function" ? config : (item) => config[item.name];
|
|
@@ -7601,9 +7612,14 @@ function Vizbuilder(props) {
|
|
|
7601
7612
|
console.debug("Loading datasets...", datasets);
|
|
7602
7613
|
return /* @__PURE__ */ React13__default.createElement(Notice, { status: "loading" });
|
|
7603
7614
|
}
|
|
7604
|
-
|
|
7615
|
+
let chartList = Object.values(charts);
|
|
7616
|
+
if (chartList.length === 0 && !Array.isArray(datasets) && datasets.data.length === 1)
|
|
7617
|
+
return /* @__PURE__ */ React13__default.createElement(Notice, { status: "one-row" });
|
|
7605
7618
|
if (chartList.length === 0) return /* @__PURE__ */ React13__default.createElement(Notice, { status: "empty" });
|
|
7606
7619
|
const isSingleChart = chartList.length === 1;
|
|
7620
|
+
if (chartList.length > 10) {
|
|
7621
|
+
chartList = chartList.slice(0, 10);
|
|
7622
|
+
}
|
|
7607
7623
|
return /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement(
|
|
7608
7624
|
SimpleGrid,
|
|
7609
7625
|
{
|
|
@@ -7653,14 +7669,7 @@ function Vizbuilder(props) {
|
|
|
7653
7669
|
isFullMode: true
|
|
7654
7670
|
}
|
|
7655
7671
|
);
|
|
7656
|
-
}, [
|
|
7657
|
-
charts,
|
|
7658
|
-
currentChart,
|
|
7659
|
-
downloadFormats,
|
|
7660
|
-
getMeasureConfig,
|
|
7661
|
-
showConfidenceInt,
|
|
7662
|
-
userConfig
|
|
7663
|
-
]);
|
|
7672
|
+
}, [charts, currentChart, downloadFormats, getMeasureConfig, showConfidenceInt, userConfig]);
|
|
7664
7673
|
return /* @__PURE__ */ React13__default.createElement("div", { style: { height: "100%" }, className: clsx_m_default("vb-wrapper", props.className) }, props.customHeader, content, props.customFooter, /* @__PURE__ */ React13__default.createElement(
|
|
7665
7674
|
Modal,
|
|
7666
7675
|
{
|
|
@@ -7743,14 +7752,14 @@ function VizbuilderView(props) {
|
|
|
7743
7752
|
data: (data == null ? void 0 : data.data) || [],
|
|
7744
7753
|
locale: params.locale || "en"
|
|
7745
7754
|
};
|
|
7746
|
-
return !query.isLoading && /* @__PURE__ */ React13__default.createElement(
|
|
7755
|
+
return !query.isLoading && /* @__PURE__ */ React13__default.createElement(React13__default.Fragment, null, /* @__PURE__ */ React13__default.createElement(
|
|
7747
7756
|
Vizbuilder,
|
|
7748
7757
|
{
|
|
7749
7758
|
datasets: dataset,
|
|
7750
7759
|
chartLimits: CHART_LIMITS,
|
|
7751
7760
|
downloadFormats: DOWNLOAD_FORMATS
|
|
7752
7761
|
}
|
|
7753
|
-
);
|
|
7762
|
+
));
|
|
7754
7763
|
}
|
|
7755
7764
|
|
|
7756
7765
|
// src/components/RawResponseView.tsx
|