@datawheel/data-explorer 1.0.8 → 1.0.10

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.d.mts CHANGED
@@ -1333,4 +1333,6 @@ declare function VizbuilderView(props: {
1333
1333
 
1334
1334
  declare function TourStep(props: TourStepsPropsType): React.JSX.Element;
1335
1335
 
1336
- export { DebugView, ExplorerComponent as Explorer, type ExplorerState, type ExplorerStepType, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, type Translation as TranslationDict, type ViewProps, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
1336
+ declare function RawResponseView(props: any): React.JSX.Element;
1337
+
1338
+ export { DebugView, ExplorerComponent as Explorer, type ExplorerState, type ExplorerStepType, PivotView, RawResponseView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, type Translation as TranslationDict, type ViewProps, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
package/dist/main.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { keyframes, createStyles, Select, rem, Input, Box, Text, Stack, Group, Button, SimpleGrid, Flex, ScrollArea, LoadingOverlay, Table, MultiSelect, Center, NumberInput, Menu, ActionIcon, UnstyledButton, Alert, Loader, Container, Title, useMantineTheme, MantineProvider, Modal, Space, useComponentDefaultProps, Anchor, Paper, Accordion, Tooltip, Tabs, Switch, ThemeIcon, CloseButton, Drawer, Divider, Checkbox, packSx, Affix, Popover } from '@mantine/core';
1
+ import { keyframes, createStyles, Select, rem, Input, Box, Text, Stack, Group, Button, SimpleGrid, Flex, ScrollArea, LoadingOverlay, Table, MultiSelect, Center, NumberInput, Menu, ActionIcon, UnstyledButton, Alert, Loader, Container, Title, useMantineTheme, TextInput, CopyButton, MantineProvider, Modal, Space, useComponentDefaultProps, Anchor, Paper, Accordion, Tooltip, Tabs, Switch, ThemeIcon, CloseButton, Drawer, Divider, Checkbox, packSx, Affix, Popover } from '@mantine/core';
2
2
  import { useClipboard, useFullscreen, useDebouncedState, useMediaQuery, useDisclosure } from '@mantine/hooks';
3
- import { IconWorld, IconExternalLink, IconClipboard, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconAlertCircle, IconAlertTriangle, IconCopy, IconDownload, IconDotsVertical, IconBox, IconArrowRight, IconArrowLeft, IconBrandGithub, IconCheck, IconShare, IconLanguage, IconTrash, IconInfoCircleFilled, IconChevronLeft, IconChevronRight, IconSearch, IconArrowsMinimize, IconArrowsMaximize, IconCircleOff, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconPlus, IconStack3, IconFilterOff, IconFilter, IconAdjustments, IconClock, IconHelpCircle, IconPhotoDown, IconVectorTriangle } from '@tabler/icons-react';
3
+ import { IconWorld, IconExternalLink, IconClipboard, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconAlertCircle, IconAlertTriangle, IconWorldWww, IconClipboardCheck, IconCopy, IconDownload, IconDotsVertical, IconBox, IconArrowRight, IconArrowLeft, IconBrandGithub, IconCheck, IconShare, IconLanguage, IconTrash, IconInfoCircleFilled, IconChevronLeft, IconChevronRight, IconSearch, IconArrowsMinimize, IconArrowsMaximize, IconCircleOff, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconPlus, IconStack3, IconFilterOff, IconFilter, IconAdjustments, IconClock, IconHelpCircle, IconPhotoDown, IconVectorTriangle } from '@tabler/icons-react';
4
4
  import * as React13 from 'react';
5
5
  import React13__default, { createContext, forwardRef, useMemo, useCallback, useContext, useRef, useEffect, useState, Suspense, Component, useLayoutEffect } from 'react';
6
6
  import { translationFactory } from '@datawheel/use-translation';
@@ -1886,7 +1886,7 @@ var selectOlapMeasureItems = createSelector(
1886
1886
  selectOlapCube,
1887
1887
  (cube) => cube ? cube.measures : []
1888
1888
  );
1889
- var selectOlapMeasureMap = createSelector(
1889
+ createSelector(
1890
1890
  selectOlapMeasureItems,
1891
1891
  (measures) => Object.fromEntries(measures.map((item) => [item.name, item]))
1892
1892
  );
@@ -2812,14 +2812,35 @@ var propertiesUpdateHandler = (actions2, item, activeProps) => {
2812
2812
  );
2813
2813
  actions2.updateDrilldown({ ...item, properties });
2814
2814
  };
2815
- var removeColumn = (actions2, entity, measures, drilldowns, type) => {
2815
+ var removeColumn = (actions2, entity, measures, drilldowns, type, queryItem, updateURL) => {
2816
+ const newQuery = buildQuery(_.cloneDeep(queryItem));
2816
2817
  if ("aggregator" in entity) {
2817
2818
  const measure = measures.find((d) => d.name === entity.name);
2818
- measure && actions2.updateMeasure({ ...measure, active: false });
2819
+ if (measure) {
2820
+ const newMeasure = { ...measure, active: false };
2821
+ actions2.updateMeasure(newMeasure);
2822
+ newQuery.params.measures[newMeasure.name] = newMeasure;
2823
+ updateURL({
2824
+ ...newQuery,
2825
+ params: {
2826
+ ...newQuery.params
2827
+ }
2828
+ });
2829
+ }
2819
2830
  }
2820
2831
  if ("depth" in entity) {
2821
2832
  const drilldown = drilldowns.find((d) => d.level === entity.name);
2822
- drilldown && actions2.updateDrilldown({ ...drilldown, active: false });
2833
+ if (drilldown) {
2834
+ const newDrilldown = { ...drilldown, active: false };
2835
+ actions2.updateDrilldown(newDrilldown);
2836
+ newQuery.params.drilldowns[newDrilldown.key] = newDrilldown;
2837
+ updateURL({
2838
+ ...newQuery,
2839
+ params: {
2840
+ ...newQuery.params
2841
+ }
2842
+ });
2843
+ }
2823
2844
  }
2824
2845
  if (isProperty(type)) {
2825
2846
  const activeDrilldowns = drilldowns.filter((d) => d.active);
@@ -3131,8 +3152,18 @@ function useTable({
3131
3152
  {
3132
3153
  label: `At least one ${getEntityText(entityType)} is required.`,
3133
3154
  key: `remove-${column2.columnDef.header}`,
3134
- disabled: !showTrashIcon(finalKeys, entityType),
3135
- onClick: () => removeColumn(actions2, entity, measures, drilldowns, entityType),
3155
+ disabled: !showTrashIcon(finalKeys, entityType) || isLoading || isFetching,
3156
+ onClick: () => {
3157
+ removeColumn(
3158
+ actions2,
3159
+ entity,
3160
+ measures,
3161
+ drilldowns,
3162
+ entityType,
3163
+ queryItem,
3164
+ updateURL
3165
+ );
3166
+ },
3136
3167
  showTooltip: !showTrashIcon(finalKeys, entityType),
3137
3168
  size: 25,
3138
3169
  ml: rem(5)
@@ -3148,7 +3179,7 @@ function useTable({
3148
3179
  return /* @__PURE__ */ React13__default.createElement("span", { style: { display: "block", textAlign: "right" } }, formatter2(cell.getValue(), locale));
3149
3180
  } : ({ cell, renderedCellValue, row }) => {
3150
3181
  const cellId = row.original[`${cell.column.id} ID`];
3151
- const idFormatter = idFormatters[`${cell.column.id} ID`];
3182
+ const idFormatter = idFormatters[`${column.localeLabel} ID`];
3152
3183
  return /* @__PURE__ */ React13__default.createElement(Flex, { justify: "space-between", sx: { width: "100%", maxWidth: 400 }, gap: "sm" }, /* @__PURE__ */ React13__default.createElement(
3153
3184
  Text,
3154
3185
  {
@@ -3264,6 +3295,7 @@ function useTable({
3264
3295
  table,
3265
3296
  isError,
3266
3297
  isLoading,
3298
+ isFetching,
3267
3299
  data: tableData,
3268
3300
  columns,
3269
3301
  pagination,
@@ -3427,7 +3459,7 @@ function MultiFilter({ header }) {
3427
3459
  const { translate: t } = useTranslation();
3428
3460
  const cutItems = useSelector$1(selectCutItems);
3429
3461
  const drilldownItems = useSelector$1(selectDrilldownItems);
3430
- const label = header.column.id;
3462
+ header.column.id;
3431
3463
  const localeLabel = header.column.columnDef.header;
3432
3464
  const drilldown = drilldownItems.find((d) => d.level === header.column.id);
3433
3465
  const actions2 = useActions();
@@ -3473,7 +3505,7 @@ function MultiFilter({ header }) {
3473
3505
  placeholder: t("params.filter_by", { name: localeLabel }),
3474
3506
  value: cut.members || [],
3475
3507
  data: drilldown.members.map((m) => {
3476
- const idFormatter = idFormatters[`${label} ID`];
3508
+ const idFormatter = idFormatters[`${localeLabel} ID`];
3477
3509
  const formattedKey = idFormatter ? idFormatter(m.key) : m.key;
3478
3510
  return {
3479
3511
  value: `${m.key}`,
@@ -4284,7 +4316,7 @@ function SuccessResult(props) {
4284
4316
  actions2.switchPanel(newTab);
4285
4317
  updateUrl({ ...queryItem, panel: newTab });
4286
4318
  };
4287
- const { table, isError, isLoading, data, columns, result, pagination, setPagination } = useTable({
4319
+ const { table, isError, isLoading, data, columns, result, pagination, isFetching, setPagination } = useTable({
4288
4320
  cube
4289
4321
  });
4290
4322
  if ((data == null ? void 0 : data.length) === 0 && !isLoading && !isError) {
@@ -4350,7 +4382,8 @@ function SuccessResult(props) {
4350
4382
  isLoading,
4351
4383
  columns,
4352
4384
  pagination,
4353
- setPagination
4385
+ setPagination,
4386
+ isFetching
4354
4387
  }
4355
4388
  ))))
4356
4389
  )
@@ -4806,16 +4839,24 @@ function QueryProvider({ children, defaultCube }) {
4806
4839
  newQuery.params.locale = defaultLocale || newQuery.params.locale;
4807
4840
  if (newQuery) {
4808
4841
  const promises = Object.values(newQuery.params.drilldowns).map((dd) => {
4809
- return fetchMembers(dd.level, newQuery == null ? void 0 : newQuery.params.locale, cube).then((levelMeta) => {
4810
- const cut = buildCut({ ...dd, active: false });
4811
- return {
4812
- drilldown: {
4813
- ...dd,
4814
- members: levelMeta.members
4815
- },
4816
- cut
4817
- };
4818
- });
4842
+ const currentDrilldown = queryItem.params.drilldowns[dd.key];
4843
+ if (currentDrilldown && currentDrilldown.members && currentDrilldown.members.length > 0) {
4844
+ return Promise.resolve({
4845
+ drilldown: currentDrilldown,
4846
+ cut: buildCut({ ...currentDrilldown, active: false })
4847
+ });
4848
+ } else {
4849
+ return fetchMembers(dd.level, newQuery == null ? void 0 : newQuery.params.locale, cube).then((levelMeta) => {
4850
+ const cut = buildCut({ ...dd, active: false });
4851
+ return {
4852
+ drilldown: {
4853
+ ...dd,
4854
+ members: levelMeta.members
4855
+ },
4856
+ cut
4857
+ };
4858
+ });
4859
+ }
4819
4860
  });
4820
4861
  runFetchMembers(Promise.all(promises)).then((data) => {
4821
4862
  const drilldowns = data.map((item) => item.drilldown);
@@ -5585,11 +5626,15 @@ var useStyles5 = createStyles((theme) => ({
5585
5626
  }
5586
5627
  }));
5587
5628
  function PivotView(props) {
5629
+ var _a;
5588
5630
  const { cube, params, result, isLoading, ...mantineReactTableProps } = props;
5589
- if (!result) return null;
5631
+ console.log("PivotView", props);
5590
5632
  const locale = params.locale;
5591
5633
  const { translate: t } = useTranslation();
5592
- const measureMap = useSelector$1(selectOlapMeasureMap);
5634
+ const { data: schema } = useServerSchema();
5635
+ const measures = (_a = schema == null ? void 0 : schema.cubeMap[cube.name]) == null ? void 0 : _a.measures;
5636
+ if (!result || !measures) return null;
5637
+ const measureMap = Object.fromEntries(measures.map((item) => [item.name, item]));
5593
5638
  const { classes, cx } = useStyles5();
5594
5639
  const measureOptions = useMemo(
5595
5640
  () => filterMap(Object.values(params.measures), (item) => {
@@ -7693,10 +7738,80 @@ function VizbuilderView(props) {
7693
7738
  }
7694
7739
  );
7695
7740
  }
7741
+
7742
+ // src/components/RawResponseView.tsx
7743
+ init_esm_shims();
7744
+ function RawResponseView(props) {
7745
+ const { result, isLoading, isFetching } = props;
7746
+ console.log(result);
7747
+ const theme = useMantineTheme();
7748
+ const token = "tokenValue";
7749
+ const tokenizedUrl = (result == null ? void 0 : result.url) ? `${result.url}${`&token=${token}` }` : "";
7750
+ const curlCommand = `curl "${tokenizedUrl}"`;
7751
+ return /* @__PURE__ */ React13__default.createElement(Container, { fluid: true, py: "xl" }, /* @__PURE__ */ React13__default.createElement(Stack, null, /* @__PURE__ */ React13__default.createElement(Group, { align: "flex-end", noWrap: true, w: "100%" }, /* @__PURE__ */ React13__default.createElement(
7752
+ TextInput,
7753
+ {
7754
+ icon: /* @__PURE__ */ React13__default.createElement(IconWorldWww, { size: 20 }),
7755
+ label: "API URL",
7756
+ readOnly: true,
7757
+ value: tokenizedUrl,
7758
+ w: "100%",
7759
+ mb: 0,
7760
+ disabled: isLoading || isFetching
7761
+ }
7762
+ ), /* @__PURE__ */ React13__default.createElement(Button.Group, null, /* @__PURE__ */ React13__default.createElement(
7763
+ Button,
7764
+ {
7765
+ component: "a",
7766
+ href: tokenizedUrl,
7767
+ target: "_blank",
7768
+ leftIcon: /* @__PURE__ */ React13__default.createElement(IconExternalLink, null),
7769
+ sx: {
7770
+ borderBottomRightRadius: 0,
7771
+ borderTopRightRadius: 0
7772
+ }
7773
+ },
7774
+ "Open"
7775
+ ), /* @__PURE__ */ React13__default.createElement(CopyButton, { value: tokenizedUrl }, ({ copied, copy }) => /* @__PURE__ */ React13__default.createElement(
7776
+ Button,
7777
+ {
7778
+ color: copied ? theme.colors.teal[5] : theme.colors.green[7],
7779
+ leftIcon: copied ? /* @__PURE__ */ React13__default.createElement(IconClipboardCheck, null) : /* @__PURE__ */ React13__default.createElement(IconClipboard, null),
7780
+ onClick: copy,
7781
+ sx: (theme2) => ({
7782
+ borderBottomLeftRadius: 0,
7783
+ borderTopLeftRadius: 0,
7784
+ "&:hover": {
7785
+ background: theme2.colors.green[7]
7786
+ }
7787
+ })
7788
+ },
7789
+ copied ? "Copied" : "Copy"
7790
+ )))), /* @__PURE__ */ React13__default.createElement(Group, { align: "flex-end", noWrap: true, w: "100%" }, /* @__PURE__ */ React13__default.createElement(
7791
+ TextInput,
7792
+ {
7793
+ icon: /* @__PURE__ */ React13__default.createElement(IconWorldWww, { size: 20 }),
7794
+ label: "Curl Command",
7795
+ readOnly: true,
7796
+ value: curlCommand,
7797
+ w: "100%",
7798
+ mb: 0,
7799
+ disabled: isLoading || isFetching
7800
+ }
7801
+ ), /* @__PURE__ */ React13__default.createElement(CopyButton, { value: curlCommand }, ({ copied, copy }) => /* @__PURE__ */ React13__default.createElement(
7802
+ Button,
7803
+ {
7804
+ color: copied ? theme.colors.teal[5] : theme.colors.green[7],
7805
+ leftIcon: copied ? /* @__PURE__ */ React13__default.createElement(IconClipboardCheck, null) : /* @__PURE__ */ React13__default.createElement(IconClipboard, null),
7806
+ onClick: copy
7807
+ },
7808
+ copied ? "Copied" : "Copy"
7809
+ )))));
7810
+ }
7696
7811
  /*! Bundled license information:
7697
7812
 
7698
7813
  file-saver/FileSaver.js:
7699
7814
  (*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js *)
7700
7815
  */
7701
7816
 
7702
- export { DebugView, ExplorerComponent as Explorer, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
7817
+ export { DebugView, ExplorerComponent as Explorer, PivotView, RawResponseView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/data-explorer",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "./dist/main.mjs",
5
5
  "types": "./dist/main.d.mts",
6
6
  "files": [