@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.
Files changed (2) hide show
  1. package/dist/main.mjs +24 -27
  2. 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
- json: "application/json",
2601
+ jsonrecords: "application/json",
2602
2602
  tsv: "text/tab-separated-values",
2603
- txt: "text/plain",
2604
- xls: "application/vnd.ms-excel"
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, provider]
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
- e.preventDefault();
2664
- onClick(e).then(() => {
2665
- setOpened(false);
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 = useMemo(
2680
- () => 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
- [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),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/data-explorer",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "main": "./dist/main.mjs",
5
5
  "types": "./dist/main.d.mts",
6
6
  "files": [