@datawheel/data-explorer 0.2.7 → 0.2.8
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.js +80 -20
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { keyframes, createStyles, Select, rem, Flex, Title, Text, Group, Button, Input, Box, Stack, SimpleGrid, ScrollArea, LoadingOverlay, Table, MultiSelect, Center, NumberInput, Menu, ActionIcon, UnstyledButton, Alert, Loader, Container, Modal, useMantineTheme, MantineProvider, Paper, useComponentDefaultProps, Anchor, Tabs, Switch, ThemeIcon, Tooltip, CloseButton, Drawer, Divider, Checkbox, packSx, Affix, Accordion, Popover } from '@mantine/core';
|
|
2
2
|
import { useClipboard, useClickOutside, useFullscreen, useDebouncedState, useMediaQuery, useDisclosure } from '@mantine/hooks';
|
|
3
|
-
import { IconWorld, IconExternalLink, IconClipboard, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconAlertCircle, IconAlertTriangle, IconCopy, IconDownload, IconDotsVertical,
|
|
3
|
+
import { IconWorld, IconExternalLink, IconClipboard, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconAlertCircle, IconAlertTriangle, IconCopy, IconDownload, IconDotsVertical, IconArrowRight, IconArrowLeft, IconArrowsMinimize, IconArrowsMaximize, IconTrash, IconInfoCircleFilled, IconSearch, IconPhotoDown, IconVectorTriangle, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconPlus, IconStack3, IconFilterOff, IconFilter, IconBox, IconClock, IconHelpCircle, IconLanguage } from '@tabler/icons-react';
|
|
4
4
|
import * as React13 from 'react';
|
|
5
|
-
import React13__default, { createContext, forwardRef, useMemo, useCallback, useContext,
|
|
5
|
+
import React13__default, { createContext, forwardRef, useMemo, useCallback, useContext, useRef, useEffect, useState, Suspense, useLayoutEffect } from 'react';
|
|
6
6
|
import { translationFactory } from '@datawheel/use-translation';
|
|
7
7
|
import { translationDict, generateCharts, createChartConfig } from '@datawheel/vizbuilder';
|
|
8
8
|
import { createSlice, createSelector, combineReducers, bindActionCreators, configureStore } from '@reduxjs/toolkit';
|
|
@@ -223,7 +223,9 @@ var defaultTranslation = {
|
|
|
223
223
|
formats: {
|
|
224
224
|
csv: "CSV",
|
|
225
225
|
json: "JSON",
|
|
226
|
-
|
|
226
|
+
tsv: "TSV",
|
|
227
|
+
parquet: "Parquet",
|
|
228
|
+
// jsonarrays: "JSON Arrays",
|
|
227
229
|
jsonrecords: "JSON Records",
|
|
228
230
|
xlsx: "XLSX"
|
|
229
231
|
},
|
|
@@ -569,7 +571,6 @@ var Comparison = /* @__PURE__ */ ((Comparison2) => {
|
|
|
569
571
|
})(Comparison || {});
|
|
570
572
|
var Format = /* @__PURE__ */ ((Format2) => {
|
|
571
573
|
Format2["csv"] = "csv";
|
|
572
|
-
Format2["jsonarrays"] = "jsonarrays";
|
|
573
574
|
Format2["jsonrecords"] = "jsonrecords";
|
|
574
575
|
Format2["parquet"] = "parquet";
|
|
575
576
|
Format2["tsv"] = "tsv";
|
|
@@ -1430,7 +1431,7 @@ var ComplexityModuleClient = class {
|
|
|
1430
1431
|
init_esm_shims();
|
|
1431
1432
|
var TesseractModuleClient = class {
|
|
1432
1433
|
constructor(baseURL, config) {
|
|
1433
|
-
this.baseURL = baseURL
|
|
1434
|
+
this.baseURL = baseURL ? baseURL.replace(/\/?$/, "/") : "";
|
|
1434
1435
|
this.requestConfig = config || { headers: new Headers() };
|
|
1435
1436
|
}
|
|
1436
1437
|
fetchStatus(params) {
|
|
@@ -1733,7 +1734,7 @@ function willDownloadQuery(format2) {
|
|
|
1733
1734
|
}
|
|
1734
1735
|
const queryParams = { ...params, pagiLimit: 0, pagiOffset: 0 };
|
|
1735
1736
|
return tesseract.fetchData({ request: queryParamsToRequest(queryParams), format: format2 }).then((response) => response.blob()).then((result) => ({
|
|
1736
|
-
content: result
|
|
1737
|
+
content: result,
|
|
1737
1738
|
extension: format2.replace(/json\w+/, "json"),
|
|
1738
1739
|
name: `${params.cube}_${(/* @__PURE__ */ new Date()).toISOString()}`
|
|
1739
1740
|
}));
|
|
@@ -1971,7 +1972,7 @@ function willReloadCube({ locale }) {
|
|
|
1971
1972
|
}
|
|
1972
1973
|
function willSetupClient(baseURL, defaultLocale, requestConfig) {
|
|
1973
1974
|
return (dispatch, getState, { tesseract }) => {
|
|
1974
|
-
tesseract.baseURL = baseURL;
|
|
1975
|
+
tesseract.baseURL = baseURL.replace(/\/?$/, "/");
|
|
1975
1976
|
getState();
|
|
1976
1977
|
const search = new URLSearchParams(location.search);
|
|
1977
1978
|
const locale = search.get("locale");
|
|
@@ -2556,10 +2557,9 @@ var ApiAndCsvButtons = (props) => {
|
|
|
2556
2557
|
Button,
|
|
2557
2558
|
{
|
|
2558
2559
|
id: "dex-api-btn",
|
|
2559
|
-
variant: "
|
|
2560
|
-
color: "dark",
|
|
2560
|
+
variant: "subtle",
|
|
2561
2561
|
leftIcon: /* @__PURE__ */ React13__default.createElement(IconCopy, { size: 20 }),
|
|
2562
|
-
sx: { height: 30
|
|
2562
|
+
sx: { height: 30 },
|
|
2563
2563
|
onClick: copyHandler
|
|
2564
2564
|
},
|
|
2565
2565
|
copied ? t("action_copy_done") : t("action_copy"),
|
|
@@ -2575,10 +2575,9 @@ var DownloadQuery = ({ data }) => {
|
|
|
2575
2575
|
/* @__PURE__ */ React13__default.createElement(
|
|
2576
2576
|
ButtonDownload,
|
|
2577
2577
|
{
|
|
2578
|
-
variant: "
|
|
2579
|
-
color: "dark",
|
|
2578
|
+
variant: "light",
|
|
2580
2579
|
leftIcon: /* @__PURE__ */ React13__default.createElement(IconDownload, { size: 20 }),
|
|
2581
|
-
sx: { height: 30
|
|
2580
|
+
sx: { height: 30 },
|
|
2582
2581
|
key: "download_csv",
|
|
2583
2582
|
provider: () => actions2.willDownloadQuery("csv")
|
|
2584
2583
|
},
|
|
@@ -3222,11 +3221,17 @@ function TableView({
|
|
|
3222
3221
|
}) {
|
|
3223
3222
|
const isData = Boolean(table.getRowModel().rows.length);
|
|
3224
3223
|
const loadingState = useSelector$1(selectLoadingState);
|
|
3224
|
+
const viewport = useRef(null);
|
|
3225
|
+
useEffect(() => {
|
|
3226
|
+
var _a;
|
|
3227
|
+
(_a = viewport.current) == null ? void 0 : _a.scrollTo({ top: 0, behavior: "smooth" });
|
|
3228
|
+
}, [pagination == null ? void 0 : pagination.pageIndex, pagination == null ? void 0 : pagination.pageSize]);
|
|
3225
3229
|
return /* @__PURE__ */ React13__default.createElement(Box, { sx: { height: "100%" } }, /* @__PURE__ */ React13__default.createElement(Flex, { direction: "column", justify: "space-between", sx: { height: "100%", flex: "1 1 auto" } }, /* @__PURE__ */ React13__default.createElement(MRT_ProgressBar, { isTopToolbar: false, table }), /* @__PURE__ */ React13__default.createElement(
|
|
3226
3230
|
ScrollArea,
|
|
3227
3231
|
{
|
|
3228
3232
|
id: "dex-table",
|
|
3229
3233
|
h: isData ? "100%" : "auto",
|
|
3234
|
+
viewportRef: viewport,
|
|
3230
3235
|
sx: {
|
|
3231
3236
|
flex: "1 1 auto",
|
|
3232
3237
|
position: "relative",
|
|
@@ -3960,12 +3965,12 @@ function Toolbar({
|
|
|
3960
3965
|
}) {
|
|
3961
3966
|
const { translate: t } = useTranslation();
|
|
3962
3967
|
const theme = useMantineTheme();
|
|
3963
|
-
const
|
|
3968
|
+
const smallerThanLg = useMediaQuery(`(max-width: ${theme.breakpoints.lg})`);
|
|
3964
3969
|
const { toolbarConfig } = useSettings();
|
|
3965
3970
|
const settings = /* @__PURE__ */ React13__default.createElement(
|
|
3966
3971
|
Flex,
|
|
3967
3972
|
{
|
|
3968
|
-
direction: { base: "column",
|
|
3973
|
+
direction: { base: "column", lg: "row" },
|
|
3969
3974
|
justify: "flex-start",
|
|
3970
3975
|
sx: toolbarSx,
|
|
3971
3976
|
p: "0.325rem",
|
|
@@ -3973,7 +3978,7 @@ function Toolbar({
|
|
|
3973
3978
|
wrap: "nowrap",
|
|
3974
3979
|
gap: "xs"
|
|
3975
3980
|
},
|
|
3976
|
-
toolbarConfig == null ? void 0 : toolbarConfig.buttons.map((b) => /* @__PURE__ */ React13__default.createElement(ToolbarButton, { ...b })),
|
|
3981
|
+
toolbarConfig == null ? void 0 : toolbarConfig.buttons.map((b) => /* @__PURE__ */ React13__default.createElement(ToolbarButton, { key: b.label, ...b })),
|
|
3977
3982
|
/* @__PURE__ */ React13__default.createElement(TourButton, null),
|
|
3978
3983
|
/* @__PURE__ */ React13__default.createElement(
|
|
3979
3984
|
ToolbarButton,
|
|
@@ -3984,7 +3989,7 @@ function Toolbar({
|
|
|
3984
3989
|
}
|
|
3985
3990
|
)
|
|
3986
3991
|
);
|
|
3987
|
-
return
|
|
3992
|
+
return smallerThanLg ? /* @__PURE__ */ React13__default.createElement(Menu, null, /* @__PURE__ */ React13__default.createElement(Menu.Target, null, /* @__PURE__ */ React13__default.createElement(ActionIcon, null, /* @__PURE__ */ React13__default.createElement(IconSettings, null))), /* @__PURE__ */ React13__default.createElement(Menu.Dropdown, null, settings)) : settings;
|
|
3988
3993
|
}
|
|
3989
3994
|
|
|
3990
3995
|
// src/components/ExplorerResults.tsx
|
|
@@ -4653,7 +4658,7 @@ var useStyles3 = createStyles((theme) => ({
|
|
|
4653
4658
|
},
|
|
4654
4659
|
linkActive: {
|
|
4655
4660
|
backgroundColor: theme.colorScheme === "dark" ? theme.fn.rgba(theme.colors[theme.primaryColor][9], 0.45) : theme.colors[theme.primaryColor][4],
|
|
4656
|
-
color: theme.
|
|
4661
|
+
color: theme.white,
|
|
4657
4662
|
fontWeight: 500
|
|
4658
4663
|
}
|
|
4659
4664
|
}));
|
|
@@ -5820,13 +5825,15 @@ var useTourSteps = (tourConfig) => {
|
|
|
5820
5825
|
// src/components/tour/ExplorerTour.tsx
|
|
5821
5826
|
function PrevButton(props) {
|
|
5822
5827
|
const { translate: t } = useTranslation();
|
|
5828
|
+
const theme = useMantineTheme();
|
|
5829
|
+
const isRtl = theme.dir === "rtl";
|
|
5823
5830
|
const handleClick = () => props.setCurrentStep(
|
|
5824
5831
|
(s) => s === 0 ? props.steps.length - 1 : s - 1
|
|
5825
5832
|
);
|
|
5826
5833
|
return /* @__PURE__ */ React13__default.createElement(
|
|
5827
5834
|
Button,
|
|
5828
5835
|
{
|
|
5829
|
-
leftIcon: /* @__PURE__ */ React13__default.createElement(IconArrowLeft, { size: "0.8rem" }),
|
|
5836
|
+
leftIcon: isRtl ? /* @__PURE__ */ React13__default.createElement(IconArrowRight, { size: "0.8rem" }) : /* @__PURE__ */ React13__default.createElement(IconArrowLeft, { size: "0.8rem" }),
|
|
5830
5837
|
onClick: handleClick,
|
|
5831
5838
|
radius: 0,
|
|
5832
5839
|
size: "lg",
|
|
@@ -5840,6 +5847,8 @@ function PrevButton(props) {
|
|
|
5840
5847
|
}
|
|
5841
5848
|
function NextButton(props) {
|
|
5842
5849
|
const { translate: t } = useTranslation();
|
|
5850
|
+
const theme = useMantineTheme();
|
|
5851
|
+
const isRtl = theme.dir === "rtl";
|
|
5843
5852
|
const handleClick = () => {
|
|
5844
5853
|
if (props.currentStep === props.steps.length - 1) {
|
|
5845
5854
|
props.setIsOpen(false);
|
|
@@ -5862,13 +5871,56 @@ function NextButton(props) {
|
|
|
5862
5871
|
size: "lg",
|
|
5863
5872
|
sx: { flex: "0 0 50%" },
|
|
5864
5873
|
onClick: handleClick,
|
|
5865
|
-
rightIcon: /* @__PURE__ */ React13__default.createElement(IconArrowRight, { size: "0.8rem" }),
|
|
5874
|
+
rightIcon: isRtl ? /* @__PURE__ */ React13__default.createElement(IconArrowLeft, { size: "0.8rem" }) : /* @__PURE__ */ React13__default.createElement(IconArrowRight, { size: "0.8rem" }),
|
|
5866
5875
|
radius: 0
|
|
5867
5876
|
},
|
|
5868
5877
|
t("tour.controls.next")
|
|
5869
5878
|
);
|
|
5870
5879
|
}
|
|
5871
5880
|
var withBase = (styles2) => (base) => ({ ...base, ...styles2 });
|
|
5881
|
+
var keyboardHandler = (rtl) => (e, clickProps) => {
|
|
5882
|
+
e.stopPropagation();
|
|
5883
|
+
if (!clickProps) return;
|
|
5884
|
+
function next() {
|
|
5885
|
+
if (clickProps.currentStep === clickProps.steps.length - 1) {
|
|
5886
|
+
clickProps.setIsOpen(false);
|
|
5887
|
+
clickProps.setCurrentStep(0);
|
|
5888
|
+
} else {
|
|
5889
|
+
const nextStep = clickProps.steps[clickProps.currentStep + 1];
|
|
5890
|
+
if (nextStep.hasOwnProperty("actionBefore")) {
|
|
5891
|
+
nextStep.actionBefore();
|
|
5892
|
+
setTimeout(() => clickProps.setCurrentStep((s) => s + 1), 250);
|
|
5893
|
+
} else {
|
|
5894
|
+
clickProps.setCurrentStep((s) => s + 1);
|
|
5895
|
+
}
|
|
5896
|
+
}
|
|
5897
|
+
}
|
|
5898
|
+
function prev() {
|
|
5899
|
+
clickProps.setCurrentStep(
|
|
5900
|
+
(s) => s === 0 ? clickProps.steps.length - 1 : s - 1
|
|
5901
|
+
);
|
|
5902
|
+
}
|
|
5903
|
+
if (e.keyCode === 27) {
|
|
5904
|
+
e.preventDefault();
|
|
5905
|
+
clickProps.setIsOpen(false);
|
|
5906
|
+
}
|
|
5907
|
+
if (e.keyCode === 39) {
|
|
5908
|
+
e.preventDefault();
|
|
5909
|
+
if (rtl) {
|
|
5910
|
+
prev();
|
|
5911
|
+
} else {
|
|
5912
|
+
next();
|
|
5913
|
+
}
|
|
5914
|
+
}
|
|
5915
|
+
if (e.keyCode === 37) {
|
|
5916
|
+
e.preventDefault();
|
|
5917
|
+
if (rtl) {
|
|
5918
|
+
next();
|
|
5919
|
+
} else {
|
|
5920
|
+
prev();
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
};
|
|
5872
5924
|
function ExplorerTour({ children, tourConfig }) {
|
|
5873
5925
|
const theme = useMantineTheme();
|
|
5874
5926
|
const steps = useTourSteps(tourConfig);
|
|
@@ -5880,8 +5932,15 @@ function ExplorerTour({ children, tourConfig }) {
|
|
|
5880
5932
|
order: -1,
|
|
5881
5933
|
width: "100%",
|
|
5882
5934
|
margin: `0 auto ${theme.spacing.xs}`
|
|
5935
|
+
}),
|
|
5936
|
+
dot: (base, { current }) => ({
|
|
5937
|
+
...base,
|
|
5938
|
+
background: current ? theme.fn.primaryColor() : "transparent",
|
|
5939
|
+
color: theme.fn.primaryColor(),
|
|
5940
|
+
borderColor: theme.colors.gray[5]
|
|
5883
5941
|
})
|
|
5884
5942
|
};
|
|
5943
|
+
const rtl = theme.dir === "rtl";
|
|
5885
5944
|
return /* @__PURE__ */ React13__default.createElement(
|
|
5886
5945
|
TourProvider,
|
|
5887
5946
|
{
|
|
@@ -5892,6 +5951,7 @@ function ExplorerTour({ children, tourConfig }) {
|
|
|
5892
5951
|
showBadge: false,
|
|
5893
5952
|
styles: styles2,
|
|
5894
5953
|
rtl: theme.dir === "rtl",
|
|
5954
|
+
keyboardHandler: keyboardHandler(rtl),
|
|
5895
5955
|
disableInteraction: true,
|
|
5896
5956
|
...tourConfig == null ? void 0 : tourConfig.tourProps
|
|
5897
5957
|
},
|