@datawheel/data-explorer 1.0.14 → 1.0.15
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 +24 -27
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -2598,10 +2598,10 @@ var DownloadQuery = ({ data }) => {
|
|
|
2598
2598
|
};
|
|
2599
2599
|
var mimeTypes = {
|
|
2600
2600
|
csv: "text/csv",
|
|
2601
|
-
|
|
2601
|
+
jsonrecords: "application/json",
|
|
2602
2602
|
tsv: "text/tab-separated-values",
|
|
2603
|
-
|
|
2604
|
-
|
|
2603
|
+
parquet: "application/octet-stream",
|
|
2604
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
2605
2605
|
};
|
|
2606
2606
|
function useDownload(props) {
|
|
2607
2607
|
const { provider } = props;
|
|
@@ -2637,12 +2637,13 @@ function useDownload(props) {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
}, [error]);
|
|
2639
2639
|
const onClick = useCallback(
|
|
2640
|
-
(evt) => {
|
|
2640
|
+
(evt, cb = () => {
|
|
2641
|
+
}) => {
|
|
2641
2642
|
evt.stopPropagation();
|
|
2642
2643
|
evt.preventDefault();
|
|
2643
|
-
return run(provider());
|
|
2644
|
+
return run(provider()).then(cb);
|
|
2644
2645
|
},
|
|
2645
|
-
[run
|
|
2646
|
+
[run]
|
|
2646
2647
|
);
|
|
2647
2648
|
return { onClick, isLoading, data: file, error };
|
|
2648
2649
|
}
|
|
@@ -2659,14 +2660,13 @@ var ItemDownload = (props) => {
|
|
|
2659
2660
|
{
|
|
2660
2661
|
...itemProps,
|
|
2661
2662
|
icon: icon(isLoading),
|
|
2662
|
-
onClick: (e) => {
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
}).catch((error) => {
|
|
2663
|
+
onClick: async (e) => {
|
|
2664
|
+
try {
|
|
2665
|
+
onClick(e, () => setOpened(false));
|
|
2666
|
+
} catch (error) {
|
|
2667
2667
|
console.error("Download error:", error);
|
|
2668
2668
|
setOpened(false);
|
|
2669
|
-
}
|
|
2669
|
+
}
|
|
2670
2670
|
}
|
|
2671
2671
|
},
|
|
2672
2672
|
/* @__PURE__ */ React13__default.createElement(Text, { fz: "sm" }, props.children)
|
|
@@ -2676,21 +2676,18 @@ function MenuOpts({ formats }) {
|
|
|
2676
2676
|
const { translate: t } = useTranslation();
|
|
2677
2677
|
const [opened, setOpened] = useState(false);
|
|
2678
2678
|
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(
|
|
2679
|
+
const buttons = formats.map((format2) => /* @__PURE__ */ React13__default.createElement(
|
|
2680
|
+
ItemDownload,
|
|
2681
|
+
{
|
|
2682
|
+
component: "a",
|
|
2683
|
+
key: format2,
|
|
2684
|
+
provider: () => downloadQuery({ format: format2 }),
|
|
2685
|
+
icon: (loading) => loading ? /* @__PURE__ */ React13__default.createElement(Loader, { size: 15 }) : /* @__PURE__ */ React13__default.createElement(IconDownload, { size: 15 }),
|
|
2686
|
+
setOpened
|
|
2687
|
+
},
|
|
2688
|
+
/* @__PURE__ */ React13__default.createElement(Text, { size: "xs" }, t(`formats.${format2}`))
|
|
2689
|
+
));
|
|
2690
|
+
return /* @__PURE__ */ React13__default.createElement(Menu, { shadow: "md", width: 200, opened }, /* @__PURE__ */ React13__default.createElement(Menu.Target, null, /* @__PURE__ */ React13__default.createElement(
|
|
2694
2691
|
ActionIcon,
|
|
2695
2692
|
{
|
|
2696
2693
|
onClick: () => setOpened((o) => !o),
|