@datawheel/data-explorer 0.2.12 → 0.3.1

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.js +1354 -305
  2. package/package.json +3 -5
package/dist/main.js CHANGED
@@ -1,10 +1,9 @@
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';
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, useComponentDefaultProps, Anchor, Paper, 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, IconArrowRight, IconArrowLeft, IconArrowsMinimize, IconArrowsMaximize, IconTrash, IconInfoCircleFilled, IconSearch, IconPhotoDown, IconVectorTriangle, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconPlus, IconStack3, IconFilterOff, IconFilter, IconAdjustments, IconBox, IconClock, IconHelpCircle, IconLanguage } from '@tabler/icons-react';
3
+ import { IconWorld, IconExternalLink, IconClipboard, IconSettings, IconMathGreater, IconMathLower, IconArrowsLeftRight, IconAlertCircle, IconAlertTriangle, IconCopy, IconDownload, IconDotsVertical, IconArrowRight, IconArrowLeft, IconTrash, IconInfoCircleFilled, IconChevronLeft, IconChevronRight, IconSearch, IconBrandGithub, IconArrowsMinimize, IconArrowsMaximize, IconArrowsSort, IconSortDescendingNumbers, IconSortDescendingLetters, IconSortAscendingNumbers, IconSortAscendingLetters, IconPlus, IconStack3, IconFilterOff, IconFilter, IconAdjustments, IconBox, IconClock, IconHelpCircle, IconLanguage, IconPhotoDown, IconVectorTriangle } from '@tabler/icons-react';
4
4
  import * as React13 from 'react';
5
- import React13__default, { createContext, forwardRef, useMemo, useCallback, useContext, useRef, useEffect, useState, Suspense, useLayoutEffect } from 'react';
5
+ import React13__default, { createContext, forwardRef, useMemo, useCallback, useContext, useRef, useEffect, useState, Suspense, useLayoutEffect, Component } from 'react';
6
6
  import { translationFactory } from '@datawheel/use-translation';
7
- import { translationDict, generateCharts, createChartConfig } from '@datawheel/vizbuilder';
8
7
  import { createSlice, createSelector, combineReducers, bindActionCreators, configureStore } from '@reduxjs/toolkit';
9
8
  import { useSelector as useSelector$1, useStore, Provider as Provider$1 } from 'react-redux';
10
9
  import ISO6391 from 'iso-639-1';
@@ -15,7 +14,8 @@ import { formatAbbreviate, format } from 'd3plus-format';
15
14
  import { TourProvider, useTour } from '@reactour/tour';
16
15
  import yn from 'yn';
17
16
  import { matchSorter } from 'match-sorter';
18
- import { BarChart, Donut, Geomap, LinePlot, Pie, StackedArea, Treemap } from 'd3plus-react';
17
+ import { generateCharts } from '@datawheel/vizbuilder';
18
+ import { BarChart, Geomap, Donut, LinePlot, StackedArea, Treemap } from 'd3plus-react';
19
19
 
20
20
  var __create = Object.create;
21
21
  var __defProp = Object.defineProperty;
@@ -58,7 +58,7 @@ var init_esm_shims = __esm({
58
58
 
59
59
  // node_modules/file-saver/FileSaver.js
60
60
  var require_FileSaver = __commonJS({
61
- "node_modules/file-saver/FileSaver.js"(exports, module) {
61
+ "node_modules/file-saver/FileSaver.js"(exports2, module2) {
62
62
  init_esm_shims();
63
63
  var saveAs2 = saveAs2 || function(view) {
64
64
  if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
@@ -170,10 +170,10 @@ var require_FileSaver = __commonJS({
170
170
  FS_proto.error = FS_proto.onwritestart = FS_proto.onprogress = FS_proto.onwrite = FS_proto.onabort = FS_proto.onerror = FS_proto.onwriteend = null;
171
171
  return saveAs3;
172
172
  }(
173
- typeof self !== "undefined" && self || typeof window !== "undefined" && window || exports.content
173
+ typeof self !== "undefined" && self || typeof window !== "undefined" && window || exports2.content
174
174
  );
175
- if (typeof module !== "undefined" && module.exports) {
176
- module.exports.saveAs = saveAs2;
175
+ if (typeof module2 !== "undefined" && module2.exports) {
176
+ module2.exports.saveAs = saveAs2;
177
177
  } else if (typeof define !== "undefined" && define !== null && define.amd !== null) {
178
178
  define("FileSaver.js", function() {
179
179
  return saveAs2;
@@ -441,7 +441,41 @@ var defaultTranslation = {
441
441
  selected_items: "Selected items",
442
442
  unselected_items: "Unselected items"
443
443
  },
444
- vizbuilder: translationDict
444
+ vizbuilder: {
445
+ action_close: "Close",
446
+ action_enlarge: "Enlarge",
447
+ action_fileissue: "File an issue",
448
+ action_retry: "Retry",
449
+ aggregators: {
450
+ avg: "Average",
451
+ max: "Max",
452
+ min: "Min",
453
+ sum: ""
454
+ },
455
+ chart_labels: {
456
+ ci: "Confidence Interval",
457
+ moe: "Margin of Error",
458
+ source: "Source",
459
+ collection: "Collection"
460
+ },
461
+ error: {
462
+ detail: "",
463
+ message: 'Details: "{{message}}".',
464
+ title: "Error"
465
+ },
466
+ sentence_connectors: {
467
+ and: "and"
468
+ },
469
+ title: {
470
+ nonidealstate: "No results",
471
+ of_selected_cut_members: "of Selected {{members}} Members",
472
+ top_drilldowns: "for Top {{drilldowns}}",
473
+ by_drilldowns: "by {{drilldowns}}",
474
+ over_time: "Over Time",
475
+ measure_and_modifier: "{{modifier}} {{measure}}",
476
+ total: "Total"
477
+ }
478
+ }
445
479
  };
446
480
  var { useTranslation, TranslationConsumer, TranslationProvider } = translationFactory({
447
481
  defaultLocale: "en",
@@ -542,6 +576,17 @@ function sortByDate(array, key, descendent = true) {
542
576
  const sorterFunction = descendent ? (a, b) => Date.parse(b[key]) - Date.parse(a[key]) : (a, b) => Date.parse(a[key]) - Date.parse(b[key]);
543
577
  return array.slice().sort(sorterFunction);
544
578
  }
579
+ function next(iterable, condition) {
580
+ let result = iterable.next();
581
+ while (!result.done) {
582
+ if (condition(result.value)) return result.value;
583
+ result = iterable.next();
584
+ }
585
+ }
586
+ function getLast(array) {
587
+ if (array.length === 0) throw new Error("Attempt to get last element from empty array");
588
+ return array[array.length - 1];
589
+ }
545
590
 
546
591
  // src/utils/structs.ts
547
592
  init_esm_shims();
@@ -844,55 +889,117 @@ init_esm_shims();
844
889
 
845
890
  // src/api/traverse.ts
846
891
  init_esm_shims();
847
- function mapCubeEntities(cube) {
848
- return {
849
- ...mapLevels(cube),
850
- ...mapProperties(cube),
851
- ...mapAllMeasures(cube)
852
- };
892
+ function entityFinder(cube, name4) {
893
+ const nameWithoutID = name4.replace(/\sID$/, "");
894
+ const nameWithID = `${nameWithoutID} ID`;
895
+ const maybeMeasure = next(yieldMeasures(cube), (item) => item[0].name === name4);
896
+ if (maybeMeasure) return maybeMeasure;
897
+ const maybeLevel = next(
898
+ yieldLevels(cube),
899
+ (item) => item[0].name === nameWithoutID || item[0].name === nameWithID
900
+ );
901
+ if (maybeLevel) return maybeLevel;
902
+ const maybeProperty = next(yieldProperties(cube), (item) => item[0].name === name4);
903
+ if (maybeProperty) return maybeProperty;
904
+ throw new Error(`Missing entity in cube '${cube.name}': ${nameWithoutID}`);
853
905
  }
854
906
  function mapDimensionHierarchyLevels(cube) {
855
907
  return Object.fromEntries(
856
- Array.from(yieldDimensionHierarchyLevels(cube), (tuple) => [tuple[2].name, tuple])
908
+ Array.from(yieldLevels(cube), (tuple) => [tuple[0].name, tuple])
857
909
  );
858
910
  }
859
- function mapLevels(cube) {
860
- return Object.fromEntries(
861
- Array.from(yieldDimensionHierarchyLevels(cube), (tuple) => [tuple[2].name, tuple[2]])
911
+ function yieldDimensions(cube) {
912
+ let i = 0;
913
+ return {
914
+ next() {
915
+ if (i < cube.dimensions.length) {
916
+ const dimension = cube.dimensions[i++];
917
+ return { value: [dimension], done: false };
918
+ }
919
+ return { value: void 0, done: true };
920
+ },
921
+ [Symbol.iterator]() {
922
+ return this.next();
923
+ }
924
+ };
925
+ }
926
+ function yieldHierarchies(cube) {
927
+ return createGenerator(
928
+ () => yieldDimensions(cube),
929
+ (item) => item[0].hierarchies
862
930
  );
863
931
  }
864
- function mapProperties(cube) {
865
- return Object.fromEntries(
866
- Object.values(mapLevels(cube)).flatMap(
867
- (level) => level.properties.map((prop) => [prop.name, prop])
868
- )
932
+ function yieldLevels(cube) {
933
+ return createGenerator(
934
+ () => yieldHierarchies(cube),
935
+ (item) => item[0].levels
869
936
  );
870
937
  }
871
- function mapAllMeasures(cube) {
872
- return Object.fromEntries(
873
- Array.from(yieldAllMeasures(cube), (item) => [item.name, item])
938
+ function yieldProperties(cube) {
939
+ return createGenerator(
940
+ () => yieldLevels(cube),
941
+ (item) => item[0].properties
874
942
  );
875
943
  }
876
- function* yieldDimensionHierarchyLevels(cube) {
877
- for (const dimension of cube.dimensions) {
878
- for (const hierarchy of dimension.hierarchies) {
879
- for (const level of hierarchy.levels) {
880
- yield [dimension, hierarchy, level];
944
+ function createGenerator(baseIterator, extractItems) {
945
+ const iterator = baseIterator();
946
+ let currentItem = iterator.next();
947
+ let index = 0;
948
+ return {
949
+ next() {
950
+ while (!currentItem.done) {
951
+ const item = currentItem.value;
952
+ const items = extractItems(item);
953
+ if (index < items.length) {
954
+ return { value: [items[index++], ...item], done: false };
955
+ }
956
+ index = 0;
957
+ currentItem = iterator.next();
881
958
  }
959
+ return { value: void 0, done: true };
960
+ },
961
+ [Symbol.iterator]() {
962
+ return this;
882
963
  }
883
- }
964
+ };
884
965
  }
885
- function* yieldAllMeasures(cube) {
886
- for (const measure of cube.measures) {
887
- yield measure;
888
- yield* measure.attached;
889
- }
966
+ function yieldMeasures(cube) {
967
+ let measureIndex = 0;
968
+ let attachedIndex = 0;
969
+ let inAttached = false;
970
+ return {
971
+ next() {
972
+ if (inAttached) {
973
+ const measure = cube.measures[measureIndex];
974
+ if (attachedIndex < measure.attached.length) {
975
+ return {
976
+ value: [measure.attached[attachedIndex++], measure],
977
+ done: false
978
+ };
979
+ }
980
+ inAttached = false;
981
+ attachedIndex = 0;
982
+ measureIndex++;
983
+ }
984
+ if (measureIndex < cube.measures.length) {
985
+ inAttached = true;
986
+ return { value: [cube.measures[measureIndex], void 0], done: false };
987
+ }
988
+ return { done: true };
989
+ },
990
+ [Symbol.iterator]() {
991
+ return this;
992
+ }
993
+ };
890
994
  }
891
995
 
892
996
  // src/utils/validation.ts
893
997
  init_esm_shims();
894
998
  function noop() {
895
999
  }
1000
+ function isIn(property, container) {
1001
+ return Object.prototype.hasOwnProperty.call(container, property);
1002
+ }
896
1003
  function hasProperty(container, property) {
897
1004
  return typeof container === "object" && container != null && Object.hasOwn(container, property);
898
1005
  }
@@ -971,18 +1078,14 @@ function getOrderValue(schemaObject) {
971
1078
  const value = schemaObject.annotations.order || "NaN";
972
1079
  return parseNumeric(value, 99);
973
1080
  }
974
- function describeData(cube, params, data) {
1081
+ function describeData(cube, params, result) {
975
1082
  const { locale } = params;
976
- const entityMap = mapCubeEntities(cube);
977
- const entityFinder = (name4) => {
978
- const nameWoId = name4.replace(/^ID\s|\sID$/, "");
979
- return entityMap[name4] || entityMap[nameWoId];
980
- };
981
1083
  return Object.fromEntries(
982
- filterMap(Object.keys(data[0] || {}), (column) => {
983
- const entity = entityFinder(column);
984
- if (!entity) return null;
985
- const typeSet = new Set(data.map((item) => typeof item[column]));
1084
+ filterMap(result.columns, (column) => {
1085
+ const entityResult = entityFinder(cube, column);
1086
+ if (!entityResult) return null;
1087
+ const [entity] = entityResult;
1088
+ const typeSet = new Set(result.data.map((item) => typeof item[column]));
986
1089
  const valueType = typeSet.size === 1 ? typeSet.has("number") ? "number" : typeSet.has("boolean") ? "boolean" : (
987
1090
  /* else */
988
1091
  "string"
@@ -997,7 +1100,7 @@ function describeData(cube, params, data) {
997
1100
  entity,
998
1101
  entityType,
999
1102
  isId,
1000
- range: valueType === "number" ? getDomain(data, column) : void 0,
1103
+ range: valueType === "number" ? getDomain(result.data, column) : void 0,
1001
1104
  valueType
1002
1105
  }
1003
1106
  ];
@@ -1796,7 +1899,7 @@ function willFetchQuery(params) {
1796
1899
  return {
1797
1900
  data: content.data,
1798
1901
  page: content.page,
1799
- types: describeData(cube, params2, content.data),
1902
+ types: describeData(cube, params2, content),
1800
1903
  headers: Object.fromEntries(response.headers),
1801
1904
  status: response.status || 200,
1802
1905
  url: response.url
@@ -1837,7 +1940,7 @@ function willHydrateParams(suggestedCube = "") {
1837
1940
  )
1838
1941
  );
1839
1942
  const resolvedDrilldowns = filterMap(Object.values(params.drilldowns), (item) => {
1840
- const [dimension, hierarchy, level] = levelMap[item.level] || [];
1943
+ const [level, hierarchy, dimension] = levelMap[item.level] || [];
1841
1944
  if (!level) return null;
1842
1945
  const activeProperties = filterMap(
1843
1946
  item.properties,
@@ -1893,7 +1996,8 @@ function willParseQueryUrl(url) {
1893
1996
  return Promise.resolve();
1894
1997
  };
1895
1998
  }
1896
- function willReloadCubes({ locale } = {}) {
1999
+ function willReloadCubes(params) {
2000
+ const { locale } = params || {};
1897
2001
  return (dispatch, getState, { tesseract }) => {
1898
2002
  const state = getState();
1899
2003
  const newLocale = locale || selectLocale(state);
@@ -2429,14 +2533,14 @@ var SelectObject = forwardRef(function(props, ref) {
2429
2533
  var _a;
2430
2534
  const {
2431
2535
  getLabel,
2432
- getValue = identity,
2536
+ getValue: getValue2 = identity,
2433
2537
  items,
2434
2538
  onItemSelect,
2435
2539
  selectedItem,
2436
2540
  selectProps = {}
2437
2541
  } = props;
2438
2542
  const [itemList, itemMap] = useMemo(() => {
2439
- const valueAccessor = accesorFactory(getValue);
2543
+ const valueAccessor = accesorFactory(getValue2);
2440
2544
  const labelAccessor = getLabel ? accesorFactory(getLabel) : valueAccessor;
2441
2545
  const list = items.map((item) => ({
2442
2546
  label: labelAccessor(item),
@@ -2444,13 +2548,13 @@ var SelectObject = forwardRef(function(props, ref) {
2444
2548
  item
2445
2549
  }));
2446
2550
  return [list, keyBy(list, (option) => option.value)];
2447
- }, [items, getLabel, getValue]);
2551
+ }, [items, getLabel, getValue2]);
2448
2552
  const selected = useMemo(() => {
2449
2553
  if (selectedItem == null) return null;
2450
2554
  if (typeof selectedItem === "string") return selectedItem;
2451
- const valueAccessor = accesorFactory(getValue);
2555
+ const valueAccessor = accesorFactory(getValue2);
2452
2556
  return valueAccessor(selectedItem);
2453
- }, [selectedItem, getValue]);
2557
+ }, [selectedItem, getValue2]);
2454
2558
  const itemSelectHandler = (value) => {
2455
2559
  onItemSelect && onItemSelect(itemMap[value].item);
2456
2560
  };
@@ -2695,12 +2799,6 @@ var TableFooter_default = TableFooter;
2695
2799
 
2696
2800
  // src/components/icons/index.tsx
2697
2801
  init_esm_shims();
2698
- function IconChevronLeft() {
2699
- return /* @__PURE__ */ React13__default.createElement("svg", { width: "9", height: "13", viewBox: "0 0 6 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13__default.createElement("path", { d: "M5.5 1L1 5.5L5.5 10", stroke: "black", strokeLinecap: "round" }));
2700
- }
2701
- function IconChevronRight() {
2702
- return /* @__PURE__ */ React13__default.createElement("svg", { width: "9", height: "13", viewBox: "0 0 7 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React13__default.createElement("path", { d: "M1 10L5.5 5.5L1 1", stroke: "black", strokeLinecap: "round" }));
2703
- }
2704
2802
  function DataSetSVG() {
2705
2803
  return /* @__PURE__ */ React13__default.createElement(
2706
2804
  "svg",
@@ -3723,8 +3821,8 @@ function PropertiesMultiSelect({ item }) {
3723
3821
  (item2) => isActiveItem(item2) ? item2.key : null
3724
3822
  );
3725
3823
  const label = useMemo(() => {
3726
- const triad = levelTriadMap[`${item.level}`];
3727
- const triadCaptions = triad.map((item2) => getCaption(item2, locale.code));
3824
+ const triad = levelTriadMap[item.level] || [];
3825
+ const triadCaptions = triad.map((item2) => getCaption(item2, locale.code)).reverse();
3728
3826
  return t("params.tag_drilldowns", {
3729
3827
  abbr: abbreviateFullName(triadCaptions, t("params.tag_drilldowns_abbrjoint")),
3730
3828
  dimension: triadCaptions[0],
@@ -3732,7 +3830,7 @@ function PropertiesMultiSelect({ item }) {
3732
3830
  level: triadCaptions[2],
3733
3831
  propCount: activeProperties.length
3734
3832
  });
3735
- }, [activeProperties.join("-"), item, locale.code]);
3833
+ }, [activeProperties.length, levelTriadMap, item, locale.code, t]);
3736
3834
  return /* @__PURE__ */ React13__default.createElement(Box, { pt: "md" }, /* @__PURE__ */ React13__default.createElement(
3737
3835
  MultiSelect,
3738
3836
  {
@@ -3947,9 +4045,9 @@ function FilterItem2({
3947
4045
  }
3948
4046
  var getIconForDimensionType = (dimensionType) => {
3949
4047
  switch (dimensionType) {
3950
- case "geo":
4048
+ case "geo" /* GEO */:
3951
4049
  return /* @__PURE__ */ React13__default.createElement(IconWorld, { size: 20 });
3952
- case "time":
4050
+ case "time" /* TIME */:
3953
4051
  return /* @__PURE__ */ React13__default.createElement(IconClock, { size: 20 });
3954
4052
  default:
3955
4053
  return /* @__PURE__ */ React13__default.createElement(IconBox, { size: 20 });
@@ -4660,9 +4758,10 @@ function SideBar(props) {
4660
4758
  onClick: () => setExpanded(!expanded),
4661
4759
  variant: "subtle",
4662
4760
  mt: "auto",
4663
- sx: (t2) => ({ alignSelf: "flex-end", color: t2.colors.gray[7] })
4761
+ color: "primaryColor",
4762
+ sx: (t2) => ({ alignSelf: "flex-end" })
4664
4763
  },
4665
- expanded ? /* @__PURE__ */ React13__default.createElement(IconChevronLeft, null) : /* @__PURE__ */ React13__default.createElement(IconChevronRight, null)
4764
+ expanded ? /* @__PURE__ */ React13__default.createElement(IconChevronLeft, { size: "1.5rem" }) : /* @__PURE__ */ React13__default.createElement(IconChevronRight, { size: "1.5rem" })
4666
4765
  )
4667
4766
  ))
4668
4767
  ));
@@ -4850,7 +4949,7 @@ function AccordionControl(props) {
4850
4949
  }
4851
4950
  function getKeys2(items, k, locale, filter) {
4852
4951
  let cubes = items;
4853
- const keys = cubes.reduce((prev, curr) => {
4952
+ const keys2 = cubes.reduce((prev, curr) => {
4854
4953
  const key = getAnnotation(curr, k, locale);
4855
4954
  if (key) {
4856
4955
  prev.add(key);
@@ -4858,7 +4957,7 @@ function getKeys2(items, k, locale, filter) {
4858
4957
  }
4859
4958
  return prev;
4860
4959
  }, /* @__PURE__ */ new Set());
4861
- return Array.from(keys);
4960
+ return Array.from(keys2);
4862
4961
  }
4863
4962
  function isSelected(selectedItem, currentItem) {
4864
4963
  if (selectedItem && currentItem) {
@@ -5035,7 +5134,7 @@ function SubtopicAccordion({
5035
5134
  control: {
5036
5135
  fontSize: t.fontSizes.sm,
5037
5136
  background: t.colorScheme === "dark" ? t.colors.dark[7] : t.colors.gray[2],
5038
- borderLeft: 8,
5137
+ borderLeft: 18,
5039
5138
  borderLeftColor: "transparent",
5040
5139
  borderLeftStyle: "solid",
5041
5140
  "&[data-active] span": {
@@ -5479,7 +5578,7 @@ function PivotView(props) {
5479
5578
  const drilldownOptions = useMemo(() => {
5480
5579
  const levelMap = mapDimensionHierarchyLevels(cube);
5481
5580
  return Object.values(params.drilldowns).filter(isActiveItem).flatMap((item) => {
5482
- const [dimension, hierarchy, level] = levelMap[item.level];
5581
+ const [level, hierarchy, dimension] = levelMap[item.level];
5483
5582
  const caption = getCaption(level, locale);
5484
5583
  const type = dimension.type;
5485
5584
  const propertyMap = keyBy(level.properties, "name");
@@ -5533,7 +5632,7 @@ function PivotView(props) {
5533
5632
  const drilldownCount = Object.values(params.drilldowns).filter(isActiveItem).length;
5534
5633
  if (drilldownCount > 2) {
5535
5634
  warnings2.push(
5536
- valProp.type !== "sum" /* sum */ ? /* @__PURE__ */ React13__default.createElement(
5635
+ valProp.type !== "Sum" /* SUM */ ? /* @__PURE__ */ React13__default.createElement(
5537
5636
  Alert,
5538
5637
  {
5539
5638
  color: "yellow",
@@ -5993,7 +6092,7 @@ var withBase = (styles2) => (base) => ({ ...base, ...styles2 });
5993
6092
  var keyboardHandler = (rtl) => (e, clickProps) => {
5994
6093
  e.stopPropagation();
5995
6094
  if (!clickProps) return;
5996
- function next() {
6095
+ function next2() {
5997
6096
  if (clickProps.currentStep === clickProps.steps.length - 1) {
5998
6097
  clickProps.setIsOpen(false);
5999
6098
  clickProps.setCurrentStep(0);
@@ -6021,13 +6120,13 @@ var keyboardHandler = (rtl) => (e, clickProps) => {
6021
6120
  if (rtl) {
6022
6121
  prev();
6023
6122
  } else {
6024
- next();
6123
+ next2();
6025
6124
  }
6026
6125
  }
6027
6126
  if (e.keyCode === 37) {
6028
6127
  e.preventDefault();
6029
6128
  if (rtl) {
6030
- next();
6129
+ next2();
6031
6130
  } else {
6032
6131
  prev();
6033
6132
  }
@@ -6174,9 +6273,70 @@ function ExplorerComponent(props) {
6174
6273
  }
6175
6274
  ExplorerComponent.displayName = "TesseractExplorer";
6176
6275
 
6276
+ // src/vizbuilder/index.ts
6277
+ init_esm_shims();
6278
+
6177
6279
  // src/vizbuilder/components/VizbuilderView.tsx
6178
6280
  init_esm_shims();
6179
6281
 
6282
+ // src/vizbuilder/tooling/columns.ts
6283
+ init_esm_shims();
6284
+ function buildColumn(cube, name4, columns) {
6285
+ const nameWithoutID = name4.replace(/\sID$/, "");
6286
+ const nameWithID = `${nameWithoutID} ID`;
6287
+ const maybeMeasure = next(yieldMeasures(cube), (item) => item[0].name === name4);
6288
+ if (maybeMeasure) {
6289
+ const [measure, parentMeasure] = maybeMeasure;
6290
+ return {
6291
+ name: name4,
6292
+ type: "measure",
6293
+ measure,
6294
+ parentMeasure,
6295
+ parentRelationship: void 0
6296
+ // TODO
6297
+ };
6298
+ }
6299
+ const maybeLevel = next(
6300
+ yieldLevels(cube),
6301
+ (item) => item[0].name === nameWithoutID || item[0].name === nameWithID
6302
+ );
6303
+ if (maybeLevel) {
6304
+ const [level, hierarchy, dimension] = maybeLevel;
6305
+ const hasID = columns.includes(nameWithID);
6306
+ return {
6307
+ name: name4,
6308
+ type: "level",
6309
+ dimension,
6310
+ hierarchy,
6311
+ level,
6312
+ isID: !hasID || name4 === nameWithID,
6313
+ hasID
6314
+ };
6315
+ }
6316
+ const maybeProperty = next(yieldProperties(cube), (item) => item[0].name === name4);
6317
+ if (maybeProperty) {
6318
+ const [property, level, hierarchy, dimension] = maybeProperty;
6319
+ return {
6320
+ name: name4,
6321
+ type: "property",
6322
+ dimension,
6323
+ hierarchy,
6324
+ level,
6325
+ property
6326
+ };
6327
+ }
6328
+ throw new Error(`Missing entity in cube '${cube.name}': ${nameWithoutID}`);
6329
+ }
6330
+ function getColumnEntity(column) {
6331
+ if (column.type === "measure") return column.measure;
6332
+ if (column.type === "level") return column.level;
6333
+ if (column.type === "property") return column.property;
6334
+ throw new Error("Invalid column object");
6335
+ }
6336
+
6337
+ // src/vizbuilder/components/Vizbuilder.tsx
6338
+ init_esm_shims();
6339
+
6180
6340
  // node_modules/clsx/dist/clsx.m.js
6181
6341
  init_esm_shims();
6182
6342
  function r(e) {
@@ -6192,38 +6352,6 @@ function clsx() {
6192
6352
  }
6193
6353
  var clsx_m_default = clsx;
6194
6354
 
6195
- // src/vizbuilder/tooling/accesor.ts
6196
- init_esm_shims();
6197
- function measureConfigAccessor(config) {
6198
- if (typeof config === "function") {
6199
- return config;
6200
- }
6201
- return (item) => config[item.name];
6202
- }
6203
-
6204
- // src/vizbuilder/tooling/collection.ts
6205
- init_esm_shims();
6206
- function asArray2(value) {
6207
- const target = [];
6208
- return target.concat(value).filter((item) => item != null);
6209
- }
6210
- function mapActives(dict, mapFn) {
6211
- return Object.values(dict).filter((item) => item.active).map(mapFn);
6212
- }
6213
-
6214
- // src/vizbuilder/tooling/constants.ts
6215
- init_esm_shims();
6216
- var DEFAULT_CHART_LIMITS = {
6217
- BARCHART_MAX_BARS: 20,
6218
- BARCHART_YEAR_MAX_BARS: 20,
6219
- DONUT_SHAPE_MAX: 30,
6220
- LINEPLOT_LINE_POINT_MIN: 2,
6221
- LINEPLOT_LINE_MAX: 20,
6222
- STACKED_SHAPE_MAX: 200,
6223
- STACKED_TIME_MEMBER_MIN: 2,
6224
- TREE_MAP_SHAPE_MAX: 1e3
6225
- };
6226
-
6227
6355
  // src/vizbuilder/components/ChartCard.tsx
6228
6356
  init_esm_shims();
6229
6357
 
@@ -7053,9 +7181,902 @@ function saveElement_default(elem) {
7053
7181
  }
7054
7182
  }
7055
7183
 
7184
+ // src/vizbuilder/hooks/useD3plusConfig.ts
7185
+ init_esm_shims();
7186
+
7187
+ // node_modules/lodash-es/lodash.js
7188
+ init_esm_shims();
7189
+
7190
+ // node_modules/lodash-es/_baseGetTag.js
7191
+ init_esm_shims();
7192
+
7193
+ // node_modules/lodash-es/_Symbol.js
7194
+ init_esm_shims();
7195
+
7196
+ // node_modules/lodash-es/_root.js
7197
+ init_esm_shims();
7198
+
7199
+ // node_modules/lodash-es/_freeGlobal.js
7200
+ init_esm_shims();
7201
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
7202
+ var freeGlobal_default = freeGlobal;
7203
+
7204
+ // node_modules/lodash-es/_root.js
7205
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
7206
+ var root = freeGlobal_default || freeSelf || Function("return this")();
7207
+ var root_default = root;
7208
+
7209
+ // node_modules/lodash-es/_Symbol.js
7210
+ var Symbol2 = root_default.Symbol;
7211
+ var Symbol_default = Symbol2;
7212
+
7213
+ // node_modules/lodash-es/_getRawTag.js
7214
+ init_esm_shims();
7215
+ var objectProto = Object.prototype;
7216
+ var hasOwnProperty2 = objectProto.hasOwnProperty;
7217
+ var nativeObjectToString = objectProto.toString;
7218
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
7219
+ function getRawTag(value) {
7220
+ var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
7221
+ try {
7222
+ value[symToStringTag] = void 0;
7223
+ var unmasked = true;
7224
+ } catch (e) {
7225
+ }
7226
+ var result = nativeObjectToString.call(value);
7227
+ if (unmasked) {
7228
+ if (isOwn) {
7229
+ value[symToStringTag] = tag;
7230
+ } else {
7231
+ delete value[symToStringTag];
7232
+ }
7233
+ }
7234
+ return result;
7235
+ }
7236
+ var getRawTag_default = getRawTag;
7237
+
7238
+ // node_modules/lodash-es/_objectToString.js
7239
+ init_esm_shims();
7240
+ var objectProto2 = Object.prototype;
7241
+ var nativeObjectToString2 = objectProto2.toString;
7242
+ function objectToString(value) {
7243
+ return nativeObjectToString2.call(value);
7244
+ }
7245
+ var objectToString_default = objectToString;
7246
+
7247
+ // node_modules/lodash-es/_baseGetTag.js
7248
+ var nullTag = "[object Null]";
7249
+ var undefinedTag = "[object Undefined]";
7250
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
7251
+ function baseGetTag(value) {
7252
+ if (value == null) {
7253
+ return value === void 0 ? undefinedTag : nullTag;
7254
+ }
7255
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
7256
+ }
7257
+ var baseGetTag_default = baseGetTag;
7258
+
7259
+ // node_modules/lodash-es/isObjectLike.js
7260
+ init_esm_shims();
7261
+ function isObjectLike(value) {
7262
+ return value != null && typeof value == "object";
7263
+ }
7264
+ var isObjectLike_default = isObjectLike;
7265
+
7266
+ // node_modules/lodash-es/isArray.js
7267
+ init_esm_shims();
7268
+ var isArray = Array.isArray;
7269
+ var isArray_default = isArray;
7270
+
7271
+ // node_modules/lodash-es/isObject.js
7272
+ init_esm_shims();
7273
+ function isObject(value) {
7274
+ var type = typeof value;
7275
+ return value != null && (type == "object" || type == "function");
7276
+ }
7277
+ var isObject_default = isObject;
7278
+
7279
+ // node_modules/lodash-es/identity.js
7280
+ init_esm_shims();
7281
+ function identity2(value) {
7282
+ return value;
7283
+ }
7284
+ var identity_default = identity2;
7285
+
7286
+ // node_modules/lodash-es/_getNative.js
7287
+ init_esm_shims();
7288
+
7289
+ // node_modules/lodash-es/_baseIsNative.js
7290
+ init_esm_shims();
7291
+
7292
+ // node_modules/lodash-es/isFunction.js
7293
+ init_esm_shims();
7294
+ var asyncTag = "[object AsyncFunction]";
7295
+ var funcTag = "[object Function]";
7296
+ var genTag = "[object GeneratorFunction]";
7297
+ var proxyTag = "[object Proxy]";
7298
+ function isFunction(value) {
7299
+ if (!isObject_default(value)) {
7300
+ return false;
7301
+ }
7302
+ var tag = baseGetTag_default(value);
7303
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
7304
+ }
7305
+ var isFunction_default = isFunction;
7306
+
7307
+ // node_modules/lodash-es/_isMasked.js
7308
+ init_esm_shims();
7309
+
7310
+ // node_modules/lodash-es/_coreJsData.js
7311
+ init_esm_shims();
7312
+ var coreJsData = root_default["__core-js_shared__"];
7313
+ var coreJsData_default = coreJsData;
7314
+
7315
+ // node_modules/lodash-es/_isMasked.js
7316
+ var maskSrcKey = function() {
7317
+ var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
7318
+ return uid ? "Symbol(src)_1." + uid : "";
7319
+ }();
7320
+ function isMasked(func) {
7321
+ return !!maskSrcKey && maskSrcKey in func;
7322
+ }
7323
+ var isMasked_default = isMasked;
7324
+
7325
+ // node_modules/lodash-es/_toSource.js
7326
+ init_esm_shims();
7327
+ var funcProto = Function.prototype;
7328
+ var funcToString = funcProto.toString;
7329
+ function toSource(func) {
7330
+ if (func != null) {
7331
+ try {
7332
+ return funcToString.call(func);
7333
+ } catch (e) {
7334
+ }
7335
+ try {
7336
+ return func + "";
7337
+ } catch (e) {
7338
+ }
7339
+ }
7340
+ return "";
7341
+ }
7342
+ var toSource_default = toSource;
7343
+
7344
+ // node_modules/lodash-es/_baseIsNative.js
7345
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
7346
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
7347
+ var funcProto2 = Function.prototype;
7348
+ var objectProto3 = Object.prototype;
7349
+ var funcToString2 = funcProto2.toString;
7350
+ var hasOwnProperty3 = objectProto3.hasOwnProperty;
7351
+ var reIsNative = RegExp(
7352
+ "^" + funcToString2.call(hasOwnProperty3).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
7353
+ );
7354
+ function baseIsNative(value) {
7355
+ if (!isObject_default(value) || isMasked_default(value)) {
7356
+ return false;
7357
+ }
7358
+ var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
7359
+ return pattern.test(toSource_default(value));
7360
+ }
7361
+ var baseIsNative_default = baseIsNative;
7362
+
7363
+ // node_modules/lodash-es/_getValue.js
7364
+ init_esm_shims();
7365
+ function getValue(object, key) {
7366
+ return object == null ? void 0 : object[key];
7367
+ }
7368
+ var getValue_default = getValue;
7369
+
7370
+ // node_modules/lodash-es/_getNative.js
7371
+ function getNative(object, key) {
7372
+ var value = getValue_default(object, key);
7373
+ return baseIsNative_default(value) ? value : void 0;
7374
+ }
7375
+ var getNative_default = getNative;
7376
+
7377
+ // node_modules/lodash-es/_apply.js
7378
+ init_esm_shims();
7379
+ function apply(func, thisArg, args) {
7380
+ switch (args.length) {
7381
+ case 0:
7382
+ return func.call(thisArg);
7383
+ case 1:
7384
+ return func.call(thisArg, args[0]);
7385
+ case 2:
7386
+ return func.call(thisArg, args[0], args[1]);
7387
+ case 3:
7388
+ return func.call(thisArg, args[0], args[1], args[2]);
7389
+ }
7390
+ return func.apply(thisArg, args);
7391
+ }
7392
+ var apply_default = apply;
7393
+
7394
+ // node_modules/lodash-es/_shortOut.js
7395
+ init_esm_shims();
7396
+ var HOT_COUNT = 800;
7397
+ var HOT_SPAN = 16;
7398
+ var nativeNow = Date.now;
7399
+ function shortOut(func) {
7400
+ var count = 0, lastCalled = 0;
7401
+ return function() {
7402
+ var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
7403
+ lastCalled = stamp;
7404
+ if (remaining > 0) {
7405
+ if (++count >= HOT_COUNT) {
7406
+ return arguments[0];
7407
+ }
7408
+ } else {
7409
+ count = 0;
7410
+ }
7411
+ return func.apply(void 0, arguments);
7412
+ };
7413
+ }
7414
+ var shortOut_default = shortOut;
7415
+
7416
+ // node_modules/lodash-es/_setToString.js
7417
+ init_esm_shims();
7418
+
7419
+ // node_modules/lodash-es/_baseSetToString.js
7420
+ init_esm_shims();
7421
+
7422
+ // node_modules/lodash-es/constant.js
7423
+ init_esm_shims();
7424
+ function constant(value) {
7425
+ return function() {
7426
+ return value;
7427
+ };
7428
+ }
7429
+ var constant_default = constant;
7430
+
7431
+ // node_modules/lodash-es/_defineProperty.js
7432
+ init_esm_shims();
7433
+ var defineProperty = function() {
7434
+ try {
7435
+ var func = getNative_default(Object, "defineProperty");
7436
+ func({}, "", {});
7437
+ return func;
7438
+ } catch (e) {
7439
+ }
7440
+ }();
7441
+ var defineProperty_default = defineProperty;
7442
+
7443
+ // node_modules/lodash-es/_baseSetToString.js
7444
+ var baseSetToString = !defineProperty_default ? identity_default : function(func, string) {
7445
+ return defineProperty_default(func, "toString", {
7446
+ "configurable": true,
7447
+ "enumerable": false,
7448
+ "value": constant_default(string),
7449
+ "writable": true
7450
+ });
7451
+ };
7452
+ var baseSetToString_default = baseSetToString;
7453
+
7454
+ // node_modules/lodash-es/_setToString.js
7455
+ var setToString = shortOut_default(baseSetToString_default);
7456
+ var setToString_default = setToString;
7457
+
7458
+ // node_modules/lodash-es/_isIndex.js
7459
+ init_esm_shims();
7460
+ var MAX_SAFE_INTEGER = 9007199254740991;
7461
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
7462
+ function isIndex(value, length) {
7463
+ var type = typeof value;
7464
+ length = length == null ? MAX_SAFE_INTEGER : length;
7465
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
7466
+ }
7467
+ var isIndex_default = isIndex;
7468
+
7469
+ // node_modules/lodash-es/assign.js
7470
+ init_esm_shims();
7471
+
7472
+ // node_modules/lodash-es/_assignValue.js
7473
+ init_esm_shims();
7474
+
7475
+ // node_modules/lodash-es/_baseAssignValue.js
7476
+ init_esm_shims();
7477
+ function baseAssignValue(object, key, value) {
7478
+ if (key == "__proto__" && defineProperty_default) {
7479
+ defineProperty_default(object, key, {
7480
+ "configurable": true,
7481
+ "enumerable": true,
7482
+ "value": value,
7483
+ "writable": true
7484
+ });
7485
+ } else {
7486
+ object[key] = value;
7487
+ }
7488
+ }
7489
+ var baseAssignValue_default = baseAssignValue;
7490
+
7491
+ // node_modules/lodash-es/eq.js
7492
+ init_esm_shims();
7493
+ function eq(value, other) {
7494
+ return value === other || value !== value && other !== other;
7495
+ }
7496
+ var eq_default = eq;
7497
+
7498
+ // node_modules/lodash-es/_assignValue.js
7499
+ var objectProto4 = Object.prototype;
7500
+ var hasOwnProperty4 = objectProto4.hasOwnProperty;
7501
+ function assignValue(object, key, value) {
7502
+ var objValue = object[key];
7503
+ if (!(hasOwnProperty4.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
7504
+ baseAssignValue_default(object, key, value);
7505
+ }
7506
+ }
7507
+ var assignValue_default = assignValue;
7508
+
7509
+ // node_modules/lodash-es/_copyObject.js
7510
+ init_esm_shims();
7511
+ function copyObject(source, props, object, customizer) {
7512
+ var isNew = !object;
7513
+ object || (object = {});
7514
+ var index = -1, length = props.length;
7515
+ while (++index < length) {
7516
+ var key = props[index];
7517
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
7518
+ if (newValue === void 0) {
7519
+ newValue = source[key];
7520
+ }
7521
+ if (isNew) {
7522
+ baseAssignValue_default(object, key, newValue);
7523
+ } else {
7524
+ assignValue_default(object, key, newValue);
7525
+ }
7526
+ }
7527
+ return object;
7528
+ }
7529
+ var copyObject_default = copyObject;
7530
+
7531
+ // node_modules/lodash-es/_createAssigner.js
7532
+ init_esm_shims();
7533
+
7534
+ // node_modules/lodash-es/_baseRest.js
7535
+ init_esm_shims();
7536
+
7537
+ // node_modules/lodash-es/_overRest.js
7538
+ init_esm_shims();
7539
+ var nativeMax = Math.max;
7540
+ function overRest(func, start, transform) {
7541
+ start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
7542
+ return function() {
7543
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
7544
+ while (++index < length) {
7545
+ array[index] = args[start + index];
7546
+ }
7547
+ index = -1;
7548
+ var otherArgs = Array(start + 1);
7549
+ while (++index < start) {
7550
+ otherArgs[index] = args[index];
7551
+ }
7552
+ otherArgs[start] = transform(array);
7553
+ return apply_default(func, this, otherArgs);
7554
+ };
7555
+ }
7556
+ var overRest_default = overRest;
7557
+
7558
+ // node_modules/lodash-es/_baseRest.js
7559
+ function baseRest(func, start) {
7560
+ return setToString_default(overRest_default(func, start, identity_default), func + "");
7561
+ }
7562
+ var baseRest_default = baseRest;
7563
+
7564
+ // node_modules/lodash-es/_isIterateeCall.js
7565
+ init_esm_shims();
7566
+
7567
+ // node_modules/lodash-es/isArrayLike.js
7568
+ init_esm_shims();
7569
+
7570
+ // node_modules/lodash-es/isLength.js
7571
+ init_esm_shims();
7572
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
7573
+ function isLength(value) {
7574
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
7575
+ }
7576
+ var isLength_default = isLength;
7577
+
7578
+ // node_modules/lodash-es/isArrayLike.js
7579
+ function isArrayLike(value) {
7580
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
7581
+ }
7582
+ var isArrayLike_default = isArrayLike;
7583
+
7584
+ // node_modules/lodash-es/_isIterateeCall.js
7585
+ function isIterateeCall(value, index, object) {
7586
+ if (!isObject_default(object)) {
7587
+ return false;
7588
+ }
7589
+ var type = typeof index;
7590
+ if (type == "number" ? isArrayLike_default(object) && isIndex_default(index, object.length) : type == "string" && index in object) {
7591
+ return eq_default(object[index], value);
7592
+ }
7593
+ return false;
7594
+ }
7595
+ var isIterateeCall_default = isIterateeCall;
7596
+
7597
+ // node_modules/lodash-es/_createAssigner.js
7598
+ function createAssigner(assigner) {
7599
+ return baseRest_default(function(object, sources) {
7600
+ var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
7601
+ customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
7602
+ if (guard && isIterateeCall_default(sources[0], sources[1], guard)) {
7603
+ customizer = length < 3 ? void 0 : customizer;
7604
+ length = 1;
7605
+ }
7606
+ object = Object(object);
7607
+ while (++index < length) {
7608
+ var source = sources[index];
7609
+ if (source) {
7610
+ assigner(object, source, index, customizer);
7611
+ }
7612
+ }
7613
+ return object;
7614
+ });
7615
+ }
7616
+ var createAssigner_default = createAssigner;
7617
+
7618
+ // node_modules/lodash-es/_isPrototype.js
7619
+ init_esm_shims();
7620
+ var objectProto5 = Object.prototype;
7621
+ function isPrototype(value) {
7622
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
7623
+ return value === proto;
7624
+ }
7625
+ var isPrototype_default = isPrototype;
7626
+
7627
+ // node_modules/lodash-es/keys.js
7628
+ init_esm_shims();
7629
+
7630
+ // node_modules/lodash-es/_arrayLikeKeys.js
7631
+ init_esm_shims();
7632
+
7633
+ // node_modules/lodash-es/_baseTimes.js
7634
+ init_esm_shims();
7635
+ function baseTimes(n, iteratee) {
7636
+ var index = -1, result = Array(n);
7637
+ while (++index < n) {
7638
+ result[index] = iteratee(index);
7639
+ }
7640
+ return result;
7641
+ }
7642
+ var baseTimes_default = baseTimes;
7643
+
7644
+ // node_modules/lodash-es/isArguments.js
7645
+ init_esm_shims();
7646
+
7647
+ // node_modules/lodash-es/_baseIsArguments.js
7648
+ init_esm_shims();
7649
+ var argsTag = "[object Arguments]";
7650
+ function baseIsArguments(value) {
7651
+ return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
7652
+ }
7653
+ var baseIsArguments_default = baseIsArguments;
7654
+
7655
+ // node_modules/lodash-es/isArguments.js
7656
+ var objectProto6 = Object.prototype;
7657
+ var hasOwnProperty5 = objectProto6.hasOwnProperty;
7658
+ var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
7659
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
7660
+ return arguments;
7661
+ }()) ? baseIsArguments_default : function(value) {
7662
+ return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
7663
+ };
7664
+ var isArguments_default = isArguments;
7665
+
7666
+ // node_modules/lodash-es/isBuffer.js
7667
+ init_esm_shims();
7668
+
7669
+ // node_modules/lodash-es/stubFalse.js
7670
+ init_esm_shims();
7671
+ function stubFalse() {
7672
+ return false;
7673
+ }
7674
+ var stubFalse_default = stubFalse;
7675
+
7676
+ // node_modules/lodash-es/isBuffer.js
7677
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
7678
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
7679
+ var moduleExports = freeModule && freeModule.exports === freeExports;
7680
+ var Buffer2 = moduleExports ? root_default.Buffer : void 0;
7681
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
7682
+ var isBuffer = nativeIsBuffer || stubFalse_default;
7683
+ var isBuffer_default = isBuffer;
7684
+
7685
+ // node_modules/lodash-es/isTypedArray.js
7686
+ init_esm_shims();
7687
+
7688
+ // node_modules/lodash-es/_baseIsTypedArray.js
7689
+ init_esm_shims();
7690
+ var argsTag2 = "[object Arguments]";
7691
+ var arrayTag = "[object Array]";
7692
+ var boolTag = "[object Boolean]";
7693
+ var dateTag = "[object Date]";
7694
+ var errorTag = "[object Error]";
7695
+ var funcTag2 = "[object Function]";
7696
+ var mapTag = "[object Map]";
7697
+ var numberTag = "[object Number]";
7698
+ var objectTag = "[object Object]";
7699
+ var regexpTag = "[object RegExp]";
7700
+ var setTag = "[object Set]";
7701
+ var stringTag = "[object String]";
7702
+ var weakMapTag = "[object WeakMap]";
7703
+ var arrayBufferTag = "[object ArrayBuffer]";
7704
+ var dataViewTag = "[object DataView]";
7705
+ var float32Tag = "[object Float32Array]";
7706
+ var float64Tag = "[object Float64Array]";
7707
+ var int8Tag = "[object Int8Array]";
7708
+ var int16Tag = "[object Int16Array]";
7709
+ var int32Tag = "[object Int32Array]";
7710
+ var uint8Tag = "[object Uint8Array]";
7711
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
7712
+ var uint16Tag = "[object Uint16Array]";
7713
+ var uint32Tag = "[object Uint32Array]";
7714
+ var typedArrayTags = {};
7715
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
7716
+ typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
7717
+ function baseIsTypedArray(value) {
7718
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
7719
+ }
7720
+ var baseIsTypedArray_default = baseIsTypedArray;
7721
+
7722
+ // node_modules/lodash-es/_baseUnary.js
7723
+ init_esm_shims();
7724
+ function baseUnary(func) {
7725
+ return function(value) {
7726
+ return func(value);
7727
+ };
7728
+ }
7729
+ var baseUnary_default = baseUnary;
7730
+
7731
+ // node_modules/lodash-es/_nodeUtil.js
7732
+ init_esm_shims();
7733
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
7734
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
7735
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
7736
+ var freeProcess = moduleExports2 && freeGlobal_default.process;
7737
+ var nodeUtil = function() {
7738
+ try {
7739
+ var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
7740
+ if (types) {
7741
+ return types;
7742
+ }
7743
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
7744
+ } catch (e) {
7745
+ }
7746
+ }();
7747
+ var nodeUtil_default = nodeUtil;
7748
+
7749
+ // node_modules/lodash-es/isTypedArray.js
7750
+ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
7751
+ var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
7752
+ var isTypedArray_default = isTypedArray;
7753
+
7754
+ // node_modules/lodash-es/_arrayLikeKeys.js
7755
+ var objectProto7 = Object.prototype;
7756
+ var hasOwnProperty6 = objectProto7.hasOwnProperty;
7757
+ function arrayLikeKeys(value, inherited) {
7758
+ var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length = result.length;
7759
+ for (var key in value) {
7760
+ if ((inherited || hasOwnProperty6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
7761
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
7762
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
7763
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
7764
+ isIndex_default(key, length)))) {
7765
+ result.push(key);
7766
+ }
7767
+ }
7768
+ return result;
7769
+ }
7770
+ var arrayLikeKeys_default = arrayLikeKeys;
7771
+
7772
+ // node_modules/lodash-es/_baseKeys.js
7773
+ init_esm_shims();
7774
+
7775
+ // node_modules/lodash-es/_nativeKeys.js
7776
+ init_esm_shims();
7777
+
7778
+ // node_modules/lodash-es/_overArg.js
7779
+ init_esm_shims();
7780
+ function overArg(func, transform) {
7781
+ return function(arg) {
7782
+ return func(transform(arg));
7783
+ };
7784
+ }
7785
+ var overArg_default = overArg;
7786
+
7787
+ // node_modules/lodash-es/_nativeKeys.js
7788
+ var nativeKeys = overArg_default(Object.keys, Object);
7789
+ var nativeKeys_default = nativeKeys;
7790
+
7791
+ // node_modules/lodash-es/_baseKeys.js
7792
+ var objectProto8 = Object.prototype;
7793
+ var hasOwnProperty7 = objectProto8.hasOwnProperty;
7794
+ function baseKeys(object) {
7795
+ if (!isPrototype_default(object)) {
7796
+ return nativeKeys_default(object);
7797
+ }
7798
+ var result = [];
7799
+ for (var key in Object(object)) {
7800
+ if (hasOwnProperty7.call(object, key) && key != "constructor") {
7801
+ result.push(key);
7802
+ }
7803
+ }
7804
+ return result;
7805
+ }
7806
+ var baseKeys_default = baseKeys;
7807
+
7808
+ // node_modules/lodash-es/keys.js
7809
+ function keys(object) {
7810
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
7811
+ }
7812
+ var keys_default = keys;
7813
+
7814
+ // node_modules/lodash-es/assign.js
7815
+ var objectProto9 = Object.prototype;
7816
+ var hasOwnProperty8 = objectProto9.hasOwnProperty;
7817
+ var assign = createAssigner_default(function(object, source) {
7818
+ if (isPrototype_default(source) || isArrayLike_default(source)) {
7819
+ copyObject_default(source, keys_default(source), object);
7820
+ return;
7821
+ }
7822
+ for (var key in source) {
7823
+ if (hasOwnProperty8.call(source, key)) {
7824
+ assignValue_default(object, key, source[key]);
7825
+ }
7826
+ }
7827
+ });
7828
+ var assign_default = assign;
7829
+ function useD3plusConfig(chart, params) {
7830
+ const { fullMode, getMeasureConfig, showConfidenceInt, t } = params;
7831
+ const measures = useMemo(() => {
7832
+ return (chart == null ? void 0 : chart.datagroup.measureColumns.map((item) => item.measure)) || [];
7833
+ }, [chart == null ? void 0 : chart.datagroup]);
7834
+ const { getFormatter } = useFormatter(measures);
7835
+ return useMemo(() => {
7836
+ if (!chart) return [null, { data: "", locale: "" }];
7837
+ const params2 = { fullMode, getFormatter, getMeasureConfig, showConfidenceInt, t };
7838
+ const { locale } = chart.datagroup;
7839
+ if (chart.type === "barchart") {
7840
+ return [BarChart, buildBarchartConfig(chart, params2)];
7841
+ }
7842
+ if (chart.type === "choropleth") {
7843
+ return [Geomap, buildChoroplethConfig(chart, params2)];
7844
+ }
7845
+ if (chart.type === "donut") {
7846
+ return [Donut, buildDonutConfig(chart, params2)];
7847
+ }
7848
+ if (chart.type === "lineplot") {
7849
+ return [LinePlot, buildLineplotConfig(chart, params2)];
7850
+ }
7851
+ if (chart.type === "stackedarea") {
7852
+ return [StackedArea, buildStackedareaConfig(chart, params2)];
7853
+ }
7854
+ if (chart.type === "treemap") {
7855
+ return [Treemap, buildTreemapConfig(chart, params2)];
7856
+ }
7857
+ return [null, { data: "", locale }];
7858
+ }, [chart, fullMode, getFormatter, getMeasureConfig, showConfidenceInt, t]);
7859
+ }
7860
+ function buildBarchartConfig(chart, params) {
7861
+ const { fullMode, getFormatter, t } = params;
7862
+ const { datagroup, values, series, timeline, orientation } = chart;
7863
+ const { columns, dataset, locale } = datagroup;
7864
+ const [mainSeries, stackedSeries] = series;
7865
+ const collate = new Intl.Collator(locale, { numeric: true, ignorePunctuation: true });
7866
+ const measureFormatter = getFormatter(values.measure.name);
7867
+ const measureAggregator = values.measure.annotations.aggregation_method || values.measure.aggregator;
7868
+ const measureUnits = values.measure.annotations.units_of_measurement || "";
7869
+ const isPercentage = ["Percentage", "Rate"].includes(measureUnits);
7870
+ const config = {
7871
+ barPadding: fullMode ? 5 : 1,
7872
+ data: dataset,
7873
+ discrete: chart.orientation === "horizontal" ? "y" : "x",
7874
+ groupBy: stackedSeries == null ? void 0 : stackedSeries.name,
7875
+ groupPadding: fullMode ? 5 : 1,
7876
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
7877
+ legend: fullMode,
7878
+ locale,
7879
+ stacked: stackedSeries && isIn(measureAggregator.toUpperCase(), ["COUNT", "SUM"]) || isPercentage,
7880
+ time: (timeline == null ? void 0 : timeline.name) === "Quarter ID" ? timeline.level.name : timeline == null ? void 0 : timeline.name,
7881
+ timeline: timeline && fullMode,
7882
+ timelineConfig: {
7883
+ brushing: false,
7884
+ playButton: false
7885
+ },
7886
+ tooltipConfig: {
7887
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7888
+ },
7889
+ total: !timeline
7890
+ };
7891
+ if (orientation === "horizontal") {
7892
+ Object.assign(config, {
7893
+ x: values.measure.name,
7894
+ xConfig: {
7895
+ title: values.measure.caption,
7896
+ tickFormat: (d) => measureFormatter(d, locale)
7897
+ },
7898
+ y: mainSeries.level.name,
7899
+ yConfig: {
7900
+ title: mainSeries.level.caption
7901
+ },
7902
+ ySort: collate.compare
7903
+ });
7904
+ } else {
7905
+ Object.assign(config, {
7906
+ x: mainSeries.level.name,
7907
+ xConfig: {
7908
+ title: mainSeries.level.caption
7909
+ },
7910
+ y: values.measure.name,
7911
+ yConfig: {
7912
+ title: values.measure.caption,
7913
+ tickFormat: (d) => measureFormatter(d, locale)
7914
+ }
7915
+ });
7916
+ }
7917
+ return config;
7918
+ }
7919
+ function buildChoroplethConfig(chart, params) {
7920
+ const { datagroup, values, series, timeline } = chart;
7921
+ const { fullMode, getFormatter, t } = params;
7922
+ const { columns, dataset, locale } = datagroup;
7923
+ const { members: firstSeriesMembers } = series[0];
7924
+ const lastSeries = getLast(series);
7925
+ const measureFormatter = getFormatter(values.measure.name);
7926
+ const config = {
7927
+ colorScale: values.measure.name,
7928
+ colorScaleConfig: {
7929
+ axisConfig: {
7930
+ tickFormat: (d) => measureFormatter(d, locale)
7931
+ },
7932
+ scale: "jenks"
7933
+ },
7934
+ colorScalePosition: fullMode ? "right" : false,
7935
+ data: dataset,
7936
+ fitFilter: (d) => {
7937
+ var _a;
7938
+ return firstSeriesMembers.includes((_a = d.id) != null ? _a : d.properties.id);
7939
+ },
7940
+ groupBy: series.map((series2) => series2.name),
7941
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
7942
+ locale,
7943
+ ocean: "transparent",
7944
+ projectionRotate: [0, 0],
7945
+ tiles: false,
7946
+ time: timeline == null ? void 0 : timeline.level.name,
7947
+ timeline: fullMode && (timeline == null ? void 0 : timeline.level.name),
7948
+ timelineConfig: {
7949
+ brushing: false,
7950
+ playButton: false
7951
+ },
7952
+ tooltip: true,
7953
+ tooltipConfig: {
7954
+ title(d) {
7955
+ return d[lastSeries.level.name];
7956
+ },
7957
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7958
+ },
7959
+ zoomScroll: false
7960
+ };
7961
+ assign_default(config, chart.extraConfig);
7962
+ return config;
7963
+ }
7964
+ function buildDonutConfig(chart, params) {
7965
+ const { datagroup, series, timeline, values } = chart;
7966
+ const { fullMode, getFormatter, t } = params;
7967
+ const { columns, dataset, locale } = datagroup;
7968
+ const [mainSeries] = series;
7969
+ const measureFormatter = getFormatter(values.measure.name);
7970
+ const config = {
7971
+ data: dataset,
7972
+ groupBy: [mainSeries.name],
7973
+ label: (d) => d[mainSeries.level.name],
7974
+ locale,
7975
+ time: timeline == null ? void 0 : timeline.name,
7976
+ timeline: fullMode && timeline,
7977
+ timelineConfig: {
7978
+ brushing: false,
7979
+ playButton: false
7980
+ },
7981
+ tooltipConfig: {
7982
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7983
+ },
7984
+ total: !timeline,
7985
+ value: values.measure.name
7986
+ };
7987
+ return config;
7988
+ }
7989
+ function buildLineplotConfig(chart, params) {
7990
+ const { datagroup, values, series, time } = chart;
7991
+ const { fullMode, getFormatter, t } = params;
7992
+ const { columns, dataset, locale } = datagroup;
7993
+ const measureFormatter = getFormatter(values.measure.name);
7994
+ const config = {
7995
+ data: dataset,
7996
+ discrete: "x",
7997
+ label: (d) => {
7998
+ return series.map((series2) => d[series2.level.name]).join("\n");
7999
+ },
8000
+ legend: fullMode,
8001
+ locale,
8002
+ groupBy: series.map((series2) => series2.name),
8003
+ time: time.level.name,
8004
+ timeline: fullMode,
8005
+ timelineConfig: {
8006
+ brushing: true,
8007
+ playButton: false
8008
+ },
8009
+ tooltipConfig: {
8010
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8011
+ },
8012
+ total: false,
8013
+ x: time.level.name,
8014
+ xConfig: {
8015
+ title: time.level.caption
8016
+ },
8017
+ y: values.measure.name,
8018
+ yConfig: {
8019
+ scale: "auto",
8020
+ tickFormat: (d) => measureFormatter(d, locale),
8021
+ title: values.measure.caption
8022
+ }
8023
+ };
8024
+ return config;
8025
+ }
8026
+ function buildStackedareaConfig(chart, params) {
8027
+ const { datagroup, series, timeline, values } = chart;
8028
+ const { fullMode, getFormatter, t } = params;
8029
+ const { columns, dataset, locale } = datagroup;
8030
+ const measureFormatter = getFormatter(values.measure.name);
8031
+ const config = {
8032
+ data: dataset,
8033
+ groupBy: series.map((series2) => series2.name),
8034
+ locale,
8035
+ time: timeline == null ? void 0 : timeline.name,
8036
+ timeline: timeline && fullMode,
8037
+ tooltipConfig: {
8038
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8039
+ },
8040
+ value: values.measure.name
8041
+ };
8042
+ return config;
8043
+ }
8044
+ function buildTreemapConfig(chart, params) {
8045
+ const { datagroup, series, timeline, values } = chart;
8046
+ const { fullMode, getFormatter, t } = params;
8047
+ const { columns, dataset, locale } = datagroup;
8048
+ const measureFormatter = getFormatter(values.measure.name);
8049
+ const config = {
8050
+ data: dataset,
8051
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
8052
+ locale,
8053
+ groupBy: series.map((series2) => series2.name),
8054
+ sum: values.measure.name,
8055
+ threshold: 5e-3,
8056
+ thresholdName: series[0].name,
8057
+ time: timeline == null ? void 0 : timeline.name,
8058
+ timeline: timeline && fullMode,
8059
+ tooltipConfig: {
8060
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8061
+ }
8062
+ };
8063
+ return config;
8064
+ }
8065
+ function _buildTooltipTbody(columns, measure, measureFormatter, locale) {
8066
+ return (d) => {
8067
+ const { caption: meaCaption, name: meaName } = measure;
8068
+ return filterMap(Object.values(columns), (column) => {
8069
+ if (column.type === "measure") return null;
8070
+ if (column.type === "level" && column.hasID && column.isID) return null;
8071
+ const { caption, name: name4 } = getColumnEntity(column);
8072
+ return [caption, d[name4]];
8073
+ }).concat([[meaCaption, measureFormatter(d[meaName], locale)]]);
8074
+ };
8075
+ }
8076
+
7056
8077
  // src/vizbuilder/components/ErrorBoundary.tsx
7057
8078
  init_esm_shims();
7058
- var ErrorBoundary = class extends React13__default.Component {
8079
+ var ErrorBoundary = class extends Component {
7059
8080
  constructor() {
7060
8081
  super(...arguments);
7061
8082
  this.state = {
@@ -7073,92 +8094,92 @@ var ErrorBoundary = class extends React13__default.Component {
7073
8094
  return this.props.children;
7074
8095
  }
7075
8096
  return /* @__PURE__ */ React13__default.createElement(TranslationConsumer, null, ({ translate: t }) => {
7076
- const detailText = t("error.detail");
7077
- return /* @__PURE__ */ React13__default.createElement(Flex, { p: "xl", align: "center", justify: "center", direction: "column", className: "chart-card error" }, /* @__PURE__ */ React13__default.createElement(Title, { order: 3 }, t("error.title")), detailText.length ? /* @__PURE__ */ React13__default.createElement(Text, null, detailText) : null, /* @__PURE__ */ React13__default.createElement(Text, null, t("error.message", { message })), /* @__PURE__ */ React13__default.createElement(Group, { spacing: "xs", my: "sm" }, /* @__PURE__ */ React13__default.createElement(
7078
- Button,
8097
+ const detailText = t("vizbuilder.error.detail");
8098
+ return /* @__PURE__ */ React13__default.createElement(
8099
+ Flex,
7079
8100
  {
7080
- onClick: this.clearError,
7081
- size: "xs",
7082
- variant: "light"
8101
+ p: "xl",
8102
+ align: "center",
8103
+ justify: "center",
8104
+ direction: "column",
8105
+ className: "chart-card error"
7083
8106
  },
7084
- t("action_retry")
7085
- ), /* @__PURE__ */ React13__default.createElement(Button, { error: name4, message })));
8107
+ /* @__PURE__ */ React13__default.createElement(Title, { order: 3 }, t("vizbuilder.error.title")),
8108
+ detailText.length ? /* @__PURE__ */ React13__default.createElement(Text, null, detailText) : null,
8109
+ /* @__PURE__ */ React13__default.createElement(Text, null, t("vizbuilder.error.message", { message })),
8110
+ /* @__PURE__ */ React13__default.createElement(Group, { spacing: "xs", my: "sm" }, /* @__PURE__ */ React13__default.createElement(Button, { onClick: this.clearError, size: "xs", variant: "light" }, t("vizbuilder.action_retry")), /* @__PURE__ */ React13__default.createElement(IssueButton, { error: name4, message }))
8111
+ );
7086
8112
  });
7087
8113
  }
7088
8114
  };
8115
+ function IssueButton(props) {
8116
+ const { error, message } = props;
8117
+ const { translate: t } = useTranslation();
8118
+ const location2 = typeof window === "object" ? window.location : { href: "<SSR>" };
8119
+ const issueParams = new URLSearchParams({
8120
+ title: `[report/vizbuilder] ${error}`,
8121
+ body: [
8122
+ `**URL**: ${location2.href}`,
8123
+ `**Error**: ${error}`,
8124
+ message ? `**Error details:** ${message}
8125
+ ` : "",
8126
+ "**Detail of the issue:**\n"
8127
+ ].join("\n")
8128
+ });
8129
+ return /* @__PURE__ */ React13__default.createElement(
8130
+ Button,
8131
+ {
8132
+ component: "a",
8133
+ href: `https://github.com/Datawheel/vizbuilder/issues/new?${issueParams}`,
8134
+ leftIcon: /* @__PURE__ */ React13__default.createElement(IconBrandGithub, { size: "1rem" }),
8135
+ rel: "noopener noreferrer",
8136
+ role: "button",
8137
+ size: "xs",
8138
+ tabIndex: 0,
8139
+ target: "_blank",
8140
+ variant: "subtle"
8141
+ },
8142
+ t("vizbuilder.action_fileissue")
8143
+ );
8144
+ }
7089
8145
 
7090
8146
  // src/vizbuilder/components/ChartCard.tsx
7091
- var chartComponents = {
7092
- barchart: BarChart,
7093
- barchartyear: BarChart,
7094
- donut: Donut,
7095
- geomap: Geomap,
7096
- histogram: BarChart,
7097
- lineplot: LinePlot,
7098
- pie: Pie,
7099
- stacked: StackedArea,
7100
- treemap: Treemap
7101
- };
7102
8147
  var iconByFormat = {
7103
8148
  jpg: IconPhotoDown,
7104
8149
  png: IconPhotoDown,
7105
8150
  svg: IconVectorTriangle
7106
8151
  };
7107
8152
  function ChartCard(props) {
7108
- const {
7109
- chart,
7110
- currentChart,
7111
- isSingleChart,
7112
- measureConfig,
7113
- showConfidenceInt,
7114
- userConfig
7115
- } = props;
7116
- const isFocused = currentChart === chart.key;
7117
- const { translate, locale } = useTranslation();
8153
+ const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt } = props;
8154
+ const { translate } = useTranslation();
7118
8155
  const nodeRef = useRef(null);
7119
- const ChartComponent = chartComponents[chart.chartType];
7120
- const config = useMemo(
7121
- () => createChartConfig(chart, {
7122
- currentChart,
7123
- isSingleChart,
7124
- isUniqueChart: isSingleChart,
7125
- measureConfig,
7126
- showConfidenceInt: !!showConfidenceInt,
7127
- translate: (template, data) => translate(`vizbuilder.${template}`, data),
7128
- userConfig: userConfig || {}
7129
- }),
7130
- [
7131
- chart,
7132
- currentChart,
7133
- isSingleChart,
7134
- translate,
7135
- measureConfig,
7136
- userConfig,
7137
- showConfidenceInt
7138
- ]
7139
- );
8156
+ const [ChartComponent, config] = useD3plusConfig(chart, {
8157
+ fullMode: !!isFullMode,
8158
+ showConfidenceInt: !!showConfidenceInt,
8159
+ getMeasureConfig: props.measureConfig,
8160
+ t: translate
8161
+ });
7140
8162
  const downloadButtons = useMemo(() => {
7141
- if (!isFocused && !isSingleChart) return [];
7142
- const filename = (config.title instanceof Function ? config.title() : config.title).replace(/[^\w]/g, "_").replace(/[_]+/g, "_");
7143
- return asArray2(props.downloadFormats).map((format2) => {
8163
+ const filename = (typeof config.title === "function" ? config.title() : config.title || "").replace(/[^\w]/g, "_").replace(/[_]+/g, "_");
8164
+ return asArray(downloadFormats).map((format2) => {
7144
8165
  const formatLower = format2.toLowerCase();
7145
8166
  const Icon = iconByFormat[formatLower] || IconDownload;
7146
8167
  return /* @__PURE__ */ React13__default.createElement(
7147
8168
  Button,
7148
8169
  {
7149
- compact: true,
7150
8170
  key: format2,
8171
+ compact: true,
7151
8172
  leftIcon: /* @__PURE__ */ React13__default.createElement(Icon, { size: 16 }),
7152
8173
  onClick: () => {
7153
8174
  const { current: boxElement } = nodeRef;
7154
8175
  const svgElement = boxElement == null ? void 0 : boxElement.querySelector("svg");
7155
- svgElement && saveElement_default(
7156
- svgElement,
7157
- { filename, type: formatLower },
7158
- {
7159
- background: getBackground(svgElement)
7160
- }
7161
- );
8176
+ if (svgElement) {
8177
+ saveElement_default(
8178
+ svgElement,
8179
+ { filename, type: formatLower },
8180
+ { background: getBackground(svgElement) }
8181
+ );
8182
+ }
7162
8183
  },
7163
8184
  size: "sm",
7164
8185
  variant: "light"
@@ -7166,24 +8187,24 @@ function ChartCard(props) {
7166
8187
  format2.toUpperCase()
7167
8188
  );
7168
8189
  });
7169
- }, [isFocused, isSingleChart, props.downloadFormats, config.title]);
8190
+ }, [config, downloadFormats]);
7170
8191
  const focusButton = useMemo(() => {
7171
- if (!isFocused && isSingleChart) return null;
7172
- const Icon = isFocused ? IconArrowsMinimize : IconArrowsMaximize;
8192
+ const Icon = isFullMode ? IconArrowsMinimize : IconArrowsMaximize;
7173
8193
  return /* @__PURE__ */ React13__default.createElement(
7174
8194
  Button,
7175
8195
  {
7176
8196
  compact: true,
7177
8197
  leftIcon: /* @__PURE__ */ React13__default.createElement(Icon, { size: 16 }),
7178
- onClick: props.onToggle,
8198
+ onClick: onFocus,
7179
8199
  size: "sm",
7180
- variant: isFocused ? "filled" : "light"
8200
+ variant: isFullMode ? "filled" : "light"
7181
8201
  },
7182
- isFocused ? translate("vizbuilder.action_close") : translate("vizbuilder.action_enlarge")
8202
+ isFullMode ? translate("vizbuilder.action_close") : translate("vizbuilder.action_enlarge")
7183
8203
  );
7184
- }, [isFocused, isSingleChart, translate, props.onToggle]);
7185
- const height = isFocused ? "calc(100vh - 3rem)" : isSingleChart ? "75vh" : 300;
7186
- return /* @__PURE__ */ React13__default.createElement(Paper, { h: height, w: "100%", style: { overflow: "hidden" } }, /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement(Stack, { spacing: 0, h: height, style: { position: "relative" }, w: "100%" }, /* @__PURE__ */ React13__default.createElement(Group, { position: "right", p: "xs", spacing: "xs", align: "center" }, downloadButtons, focusButton), /* @__PURE__ */ React13__default.createElement(Box, { style: { flex: "1 1 auto" }, ref: nodeRef, pb: "xs", px: "xs" }, /* @__PURE__ */ React13__default.createElement(ChartComponent, { config })))));
8204
+ }, [isFullMode, translate, onFocus]);
8205
+ const height = isFullMode ? "calc(100vh - 3rem)" : 300;
8206
+ if (!ChartComponent) return null;
8207
+ return /* @__PURE__ */ React13__default.createElement(Paper, { h: height, w: "100%", style: { overflow: "hidden" } }, /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement(Stack, { spacing: 0, h: height, style: { position: "relative" }, w: "100%" }, /* @__PURE__ */ React13__default.createElement(Group, { position: "right", p: "xs", spacing: "xs", align: "center" }, downloadButtons, onFocus && focusButton), /* @__PURE__ */ React13__default.createElement(Box, { style: { flex: "1 1 auto" }, ref: nodeRef, pb: "xs", px: "xs" }, /* @__PURE__ */ React13__default.createElement(ChartComponent, { config })))));
7187
8208
  }
7188
8209
  var getBackground = (node) => {
7189
8210
  if (node.nodeType !== Node.ELEMENT_NODE) return "white";
@@ -7192,150 +8213,178 @@ var getBackground = (node) => {
7192
8213
  return color && color !== "rgba(0, 0, 0, 0)" && color !== "transparent" ? color : getBackground(node.parentNode);
7193
8214
  };
7194
8215
 
7195
- // src/vizbuilder/components/VizbuilderView.tsx
7196
- function createVizbuilderView(settings) {
8216
+ // src/vizbuilder/components/NonIdealState.tsx
8217
+ init_esm_shims();
8218
+ function NonIdealState2() {
8219
+ const { translate: t } = useTranslation();
8220
+ return /* @__PURE__ */ React13__default.createElement("div", { className: "vb-nonidealstate" }, /* @__PURE__ */ React13__default.createElement("h1", { className: "vb-nonidealstate-header" }, t("title.nonidealstate")));
8221
+ }
8222
+
8223
+ // src/vizbuilder/components/Vizbuilder.tsx
8224
+ function Vizbuilder(props) {
7197
8225
  const {
8226
+ datasets,
8227
+ chartLimits,
7198
8228
  chartTypes,
7199
8229
  datacap,
7200
- defaultLocale = "en",
7201
8230
  downloadFormats,
7202
- nonIdealState: Notice = NonIdealState2,
7203
- showConfidenceInt = false,
8231
+ measureConfig,
8232
+ nonIdealState,
8233
+ showConfidenceInt,
7204
8234
  topojsonConfig,
7205
- userConfig = {}
7206
- } = settings;
7207
- const getMeasureConfig = measureConfigAccessor(settings.measureConfig || {});
7208
- const chartLimits = { ...DEFAULT_CHART_LIMITS, ...settings.chartLimits };
7209
- const chartGenOptions = { chartLimits, chartTypes, datacap, topojsonConfig };
7210
- return VizbuilderView;
7211
- function VizbuilderView(props) {
7212
- const { cube, panelKey, params, result } = props;
7213
- const { actions: actions2, formatters } = useSettings();
7214
- const [panelName, currentChart] = useMemo(
7215
- () => `${panelKey || ""}-`.split("-"),
7216
- [panelKey]
7217
- );
7218
- const resetCurrentPanel = useCallback(() => {
7219
- actions2.switchPanel(panelName);
7220
- }, [panelName]);
7221
- const charts = useMemo(
7222
- () => generateCharts(
7223
- [
7224
- {
7225
- cube,
7226
- dataset: result.data,
7227
- params: {
7228
- locale: params.locale || defaultLocale,
7229
- booleans: params.booleans,
7230
- cuts: mapActives(params.cuts, (item) => ({
7231
- dimension: item.dimension,
7232
- hierarchy: item.hierarchy,
7233
- level: item.level,
7234
- members: item.members
7235
- })),
7236
- drilldowns: mapActives(params.drilldowns, (item) => ({
7237
- caption: item.captionProperty,
7238
- dimension: item.dimension,
7239
- hierarchy: item.hierarchy,
7240
- level: item.level,
7241
- properties: item.properties.map((item2) => item2.name)
7242
- })),
7243
- filters: mapActives(params.filters, (item) => ({
7244
- constraint1: [item.conditionOne[0], item.conditionOne[2]],
7245
- constraint2: item.conditionTwo ? [item.conditionTwo[0], item.conditionTwo[2]] : void 0,
7246
- formatter: formatters[item.measure],
7247
- joint: item.joint,
7248
- measure: item.measure
7249
- })),
7250
- measures: mapActives(params.measures, (item) => ({
7251
- formatter: formatters[item.name],
7252
- measure: item.name
7253
- }))
7254
- }
7255
- }
8235
+ userConfig
8236
+ } = props;
8237
+ const [currentChart, setCurrentChart] = useState("");
8238
+ const getMeasureConfig = useMemo(() => {
8239
+ const config = measureConfig || {};
8240
+ return typeof config === "function" ? config : (item) => config[item.name];
8241
+ }, [measureConfig]);
8242
+ const getTopojsonConfig = useMemo(() => {
8243
+ const config = topojsonConfig || {};
8244
+ return typeof config === "function" ? config : (item) => config[item.name];
8245
+ }, [topojsonConfig]);
8246
+ const charts = useMemo(() => {
8247
+ const charts2 = generateCharts(asArray(datasets), {
8248
+ chartLimits,
8249
+ chartTypes,
8250
+ datacap,
8251
+ getTopojsonConfig
8252
+ });
8253
+ return Object.fromEntries(charts2.map((chart) => [chart.key, chart]));
8254
+ }, [chartLimits, chartTypes, datacap, datasets, getTopojsonConfig]);
8255
+ const content = useMemo(() => {
8256
+ const chartList = Object.values(charts);
8257
+ if (chartList.length === 0) {
8258
+ const Notice = nonIdealState || NonIdealState2;
8259
+ return /* @__PURE__ */ React13__default.createElement(Notice, null);
8260
+ }
8261
+ const isSingleChart = chartList.length === 1;
8262
+ return /* @__PURE__ */ React13__default.createElement(
8263
+ SimpleGrid,
8264
+ {
8265
+ breakpoints: [
8266
+ { minWidth: "xs", cols: 1 },
8267
+ { minWidth: "md", cols: 2 },
8268
+ { minWidth: "lg", cols: 3 },
8269
+ { minWidth: "xl", cols: 4 }
7256
8270
  ],
7257
- chartGenOptions
7258
- ),
7259
- [cube, result.data, params]
7260
- );
7261
- const content = useMemo(() => {
7262
- const isSingleChart = charts.length === 1;
7263
- const chartMap = new Map(charts.map((item) => [item.key, item]));
7264
- const filteredCharts = [...chartMap.values()];
7265
- if (filteredCharts.length === 0) return /* @__PURE__ */ React13__default.createElement(Notice, null);
7266
- return /* @__PURE__ */ React13__default.createElement(
7267
- SimpleGrid,
7268
- {
7269
- breakpoints: [
7270
- { minWidth: "xs", cols: Math.min(1, filteredCharts.length) },
7271
- { minWidth: "md", cols: Math.min(2, filteredCharts.length) },
7272
- { minWidth: "lg", cols: Math.min(3, filteredCharts.length) },
7273
- { minWidth: "xl", cols: Math.min(4, filteredCharts.length) }
7274
- ],
7275
- className: clsx_m_default({ unique: filteredCharts.length === 1 })
7276
- },
7277
- filteredCharts.map((chart) => /* @__PURE__ */ React13__default.createElement(
7278
- ChartCard,
7279
- {
7280
- chart,
7281
- currentChart: "",
7282
- downloadFormats,
7283
- isSingleChart,
7284
- key: chart.key,
7285
- measureConfig: getMeasureConfig,
7286
- onToggle: () => {
7287
- actions2.switchPanel(`${panelName}-${chart.key}`);
7288
- },
7289
- showConfidenceInt,
7290
- userConfig
7291
- }
7292
- ))
7293
- );
7294
- }, [panelName, charts]);
7295
- const focusContent = useMemo(() => {
7296
- const chart = charts.find((chart2) => currentChart && chart2.key === currentChart);
7297
- if (!chart) return null;
7298
- return /* @__PURE__ */ React13__default.createElement(
8271
+ className: clsx_m_default({ unique: isSingleChart })
8272
+ },
8273
+ chartList.map((chart) => /* @__PURE__ */ React13__default.createElement(
7299
8274
  ChartCard,
7300
8275
  {
8276
+ key: chart.key,
7301
8277
  chart,
7302
- currentChart,
7303
8278
  downloadFormats,
7304
- isSingleChart: true,
7305
- key: `${chart.key}-focus`,
7306
8279
  measureConfig: getMeasureConfig,
7307
- onToggle: resetCurrentPanel,
8280
+ onFocus: () => setCurrentChart(chart.key),
7308
8281
  showConfidenceInt,
7309
8282
  userConfig
7310
8283
  }
7311
- );
7312
- }, [currentChart, charts, resetCurrentPanel]);
7313
- return /* @__PURE__ */ React13__default.createElement(Box, { className: props.className, p: "sm" }, content, /* @__PURE__ */ React13__default.createElement(
7314
- Modal,
8284
+ ))
8285
+ );
8286
+ }, [
8287
+ charts,
8288
+ getMeasureConfig,
8289
+ nonIdealState,
8290
+ downloadFormats,
8291
+ userConfig,
8292
+ showConfidenceInt
8293
+ ]);
8294
+ const focusContent = useMemo(() => {
8295
+ const chart = charts[currentChart];
8296
+ if (!chart) return null;
8297
+ return /* @__PURE__ */ React13__default.createElement(
8298
+ ChartCard,
7315
8299
  {
7316
- centered: true,
7317
- onClose: resetCurrentPanel,
7318
- opened: currentChart !== "",
7319
- padding: 0,
7320
- size: "calc(100vw - 3rem)",
7321
- styles: {
7322
- content: { maxHeight: "none !important" },
7323
- inner: { padding: "0 !important" }
7324
- },
7325
- withCloseButton: false
8300
+ key: `${chart.key}-focus`,
8301
+ chart,
8302
+ downloadFormats,
8303
+ measureConfig: getMeasureConfig,
8304
+ onFocus: () => setCurrentChart(""),
8305
+ showConfidenceInt,
8306
+ userConfig,
8307
+ isFullMode: true
8308
+ }
8309
+ );
8310
+ }, [
8311
+ charts,
8312
+ currentChart,
8313
+ downloadFormats,
8314
+ getMeasureConfig,
8315
+ showConfidenceInt,
8316
+ userConfig
8317
+ ]);
8318
+ return /* @__PURE__ */ React13__default.createElement("div", { className: clsx_m_default("vb-wrapper", props.className) }, props.customHeader, content, props.customFooter, /* @__PURE__ */ React13__default.createElement(
8319
+ Modal,
8320
+ {
8321
+ centered: true,
8322
+ onClose: useCallback(() => setCurrentChart(""), []),
8323
+ opened: currentChart !== "",
8324
+ padding: 0,
8325
+ size: "calc(100vw - 3rem)",
8326
+ styles: {
8327
+ content: { maxHeight: "none !important" },
8328
+ inner: { padding: "0 !important" }
7326
8329
  },
7327
- focusContent
7328
- ));
7329
- }
8330
+ withCloseButton: false
8331
+ },
8332
+ focusContent
8333
+ ));
7330
8334
  }
7331
- function NonIdealState2() {
7332
- const { translate: t } = useTranslation();
7333
- return /* @__PURE__ */ React13__default.createElement(Box, { className: "vizbuilder-nonidealstate" }, /* @__PURE__ */ React13__default.createElement(Title, { order: 1, className: "vizbuilder-nonidealstate-header" }, t("nonidealstate_msg")));
8335
+
8336
+ // src/vizbuilder/components/VizbuilderView.tsx
8337
+ var CHART_LIMITS = {
8338
+ BARCHART_MAX_BARS: 20,
8339
+ BARCHART_YEAR_MAX_BARS: 20,
8340
+ BARCHART_MAX_STACKED_BARS: 10,
8341
+ DONUT_SHAPE_MAX: 30,
8342
+ LINEPLOT_LINE_POINT_MIN: 2,
8343
+ LINEPLOT_LINE_MAX: 20,
8344
+ STACKED_SHAPE_MAX: 200,
8345
+ STACKED_TIME_MEMBER_MIN: 2,
8346
+ TREE_MAP_SHAPE_MAX: 1e3
8347
+ };
8348
+ var DOWNLOAD_FORMATS = ["SVG", "PNG"];
8349
+ function VizbuilderView(props) {
8350
+ const { cube, params, result } = props;
8351
+ const dataset = useMemo(() => {
8352
+ const columns = Object.keys(result.types);
8353
+ return {
8354
+ columns: Object.fromEntries(
8355
+ columns.map((columnName) => [
8356
+ columnName,
8357
+ buildColumn(cube, columnName, columns)
8358
+ ])
8359
+ ),
8360
+ data: result.data,
8361
+ locale: params.locale || "en"
8362
+ };
8363
+ }, [cube, result, params.locale]);
8364
+ return /* @__PURE__ */ React13__default.createElement(
8365
+ Vizbuilder,
8366
+ {
8367
+ datasets: dataset,
8368
+ chartLimits: CHART_LIMITS,
8369
+ downloadFormats: DOWNLOAD_FORMATS
8370
+ }
8371
+ );
7334
8372
  }
7335
8373
  /*! Bundled license information:
7336
8374
 
7337
8375
  file-saver/FileSaver.js:
7338
8376
  (*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js *)
8377
+
8378
+ lodash-es/lodash.js:
8379
+ (**
8380
+ * @license
8381
+ * Lodash (Custom Build) <https://lodash.com/>
8382
+ * Build: `lodash modularize exports="es" -o ./`
8383
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
8384
+ * Released under MIT license <https://lodash.com/license>
8385
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8386
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8387
+ *)
7339
8388
  */
7340
8389
 
7341
- export { DebugView, ExplorerComponent as Explorer, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, createVizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
8390
+ export { DebugView, ExplorerComponent as Explorer, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };