@datawheel/data-explorer 0.2.11 → 0.3.0

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 -300
  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, 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
  };
@@ -3723,8 +3827,8 @@ function PropertiesMultiSelect({ item }) {
3723
3827
  (item2) => isActiveItem(item2) ? item2.key : null
3724
3828
  );
3725
3829
  const label = useMemo(() => {
3726
- const triad = levelTriadMap[`${item.level}`];
3727
- const triadCaptions = triad.map((item2) => getCaption(item2, locale.code));
3830
+ const triad = levelTriadMap[item.level] || [];
3831
+ const triadCaptions = triad.map((item2) => getCaption(item2, locale.code)).reverse();
3728
3832
  return t("params.tag_drilldowns", {
3729
3833
  abbr: abbreviateFullName(triadCaptions, t("params.tag_drilldowns_abbrjoint")),
3730
3834
  dimension: triadCaptions[0],
@@ -3732,7 +3836,7 @@ function PropertiesMultiSelect({ item }) {
3732
3836
  level: triadCaptions[2],
3733
3837
  propCount: activeProperties.length
3734
3838
  });
3735
- }, [activeProperties.join("-"), item, locale.code]);
3839
+ }, [activeProperties.length, levelTriadMap, item, locale.code, t]);
3736
3840
  return /* @__PURE__ */ React13__default.createElement(Box, { pt: "md" }, /* @__PURE__ */ React13__default.createElement(
3737
3841
  MultiSelect,
3738
3842
  {
@@ -3947,9 +4051,9 @@ function FilterItem2({
3947
4051
  }
3948
4052
  var getIconForDimensionType = (dimensionType) => {
3949
4053
  switch (dimensionType) {
3950
- case "geo":
4054
+ case "geo" /* GEO */:
3951
4055
  return /* @__PURE__ */ React13__default.createElement(IconWorld, { size: 20 });
3952
- case "time":
4056
+ case "time" /* TIME */:
3953
4057
  return /* @__PURE__ */ React13__default.createElement(IconClock, { size: 20 });
3954
4058
  default:
3955
4059
  return /* @__PURE__ */ React13__default.createElement(IconBox, { size: 20 });
@@ -4587,7 +4691,7 @@ function SideBar(props) {
4587
4691
  id: "dex-sidebar",
4588
4692
  py: "md",
4589
4693
  sx: (t2) => ({
4590
- height: "calc(100vh - 50px)",
4694
+ height: "100%",
4591
4695
  backgroundColor: t2.colorScheme === "dark" ? t2.colors.dark[8] : t2.colors.gray[1],
4592
4696
  boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
4593
4697
  maxWidth: expanded ? 300 : 54,
@@ -4597,7 +4701,7 @@ function SideBar(props) {
4597
4701
  [t2.fn.smallerThan("md")]: {
4598
4702
  position: "absolute",
4599
4703
  width: expanded ? 300 : 0,
4600
- height: expanded ? "calc(100vh - 50px)" : 0,
4704
+ height: expanded ? "100%" : 0,
4601
4705
  bottom: expanded ? "unset" : t2.spacing.md,
4602
4706
  left: expanded ? "unset" : t2.spacing.md,
4603
4707
  overflow: "hidden",
@@ -4850,7 +4954,7 @@ function AccordionControl(props) {
4850
4954
  }
4851
4955
  function getKeys2(items, k, locale, filter) {
4852
4956
  let cubes = items;
4853
- const keys = cubes.reduce((prev, curr) => {
4957
+ const keys2 = cubes.reduce((prev, curr) => {
4854
4958
  const key = getAnnotation(curr, k, locale);
4855
4959
  if (key) {
4856
4960
  prev.add(key);
@@ -4858,7 +4962,7 @@ function getKeys2(items, k, locale, filter) {
4858
4962
  }
4859
4963
  return prev;
4860
4964
  }, /* @__PURE__ */ new Set());
4861
- return Array.from(keys);
4965
+ return Array.from(keys2);
4862
4966
  }
4863
4967
  function isSelected(selectedItem, currentItem) {
4864
4968
  if (selectedItem && currentItem) {
@@ -5084,7 +5188,7 @@ var useStyles4 = createStyles((theme, params) => ({
5084
5188
  display: "flex",
5085
5189
  flexFlow: "column nowrap",
5086
5190
  position: "relative",
5087
- height: "calc(100% - 70px)",
5191
+ height: "100%",
5088
5192
  [theme.fn.largerThan("md")]: {
5089
5193
  flexDirection: "row"
5090
5194
  // height: params.height,
@@ -5093,7 +5197,7 @@ var useStyles4 = createStyles((theme, params) => ({
5093
5197
  },
5094
5198
  flexCol: {
5095
5199
  flex: "1 1 auto",
5096
- height: "calc(100vh - 70px)",
5200
+ height: "100%",
5097
5201
  [theme.fn.largerThan("md")]: {
5098
5202
  width: 0,
5099
5203
  paddingLeft: 0
@@ -5479,7 +5583,7 @@ function PivotView(props) {
5479
5583
  const drilldownOptions = useMemo(() => {
5480
5584
  const levelMap = mapDimensionHierarchyLevels(cube);
5481
5585
  return Object.values(params.drilldowns).filter(isActiveItem).flatMap((item) => {
5482
- const [dimension, hierarchy, level] = levelMap[item.level];
5586
+ const [level, hierarchy, dimension] = levelMap[item.level];
5483
5587
  const caption = getCaption(level, locale);
5484
5588
  const type = dimension.type;
5485
5589
  const propertyMap = keyBy(level.properties, "name");
@@ -5533,7 +5637,7 @@ function PivotView(props) {
5533
5637
  const drilldownCount = Object.values(params.drilldowns).filter(isActiveItem).length;
5534
5638
  if (drilldownCount > 2) {
5535
5639
  warnings2.push(
5536
- valProp.type !== "sum" /* sum */ ? /* @__PURE__ */ React13__default.createElement(
5640
+ valProp.type !== "Sum" /* SUM */ ? /* @__PURE__ */ React13__default.createElement(
5537
5641
  Alert,
5538
5642
  {
5539
5643
  color: "yellow",
@@ -5993,7 +6097,7 @@ var withBase = (styles2) => (base) => ({ ...base, ...styles2 });
5993
6097
  var keyboardHandler = (rtl) => (e, clickProps) => {
5994
6098
  e.stopPropagation();
5995
6099
  if (!clickProps) return;
5996
- function next() {
6100
+ function next2() {
5997
6101
  if (clickProps.currentStep === clickProps.steps.length - 1) {
5998
6102
  clickProps.setIsOpen(false);
5999
6103
  clickProps.setCurrentStep(0);
@@ -6021,13 +6125,13 @@ var keyboardHandler = (rtl) => (e, clickProps) => {
6021
6125
  if (rtl) {
6022
6126
  prev();
6023
6127
  } else {
6024
- next();
6128
+ next2();
6025
6129
  }
6026
6130
  }
6027
6131
  if (e.keyCode === 37) {
6028
6132
  e.preventDefault();
6029
6133
  if (rtl) {
6030
- next();
6134
+ next2();
6031
6135
  } else {
6032
6136
  prev();
6033
6137
  }
@@ -6174,9 +6278,70 @@ function ExplorerComponent(props) {
6174
6278
  }
6175
6279
  ExplorerComponent.displayName = "TesseractExplorer";
6176
6280
 
6281
+ // src/vizbuilder/index.ts
6282
+ init_esm_shims();
6283
+
6177
6284
  // src/vizbuilder/components/VizbuilderView.tsx
6178
6285
  init_esm_shims();
6179
6286
 
6287
+ // src/vizbuilder/tooling/columns.ts
6288
+ init_esm_shims();
6289
+ function buildColumn(cube, name4, columns) {
6290
+ const nameWithoutID = name4.replace(/\sID$/, "");
6291
+ const nameWithID = `${nameWithoutID} ID`;
6292
+ const maybeMeasure = next(yieldMeasures(cube), (item) => item[0].name === name4);
6293
+ if (maybeMeasure) {
6294
+ const [measure, parentMeasure] = maybeMeasure;
6295
+ return {
6296
+ name: name4,
6297
+ type: "measure",
6298
+ measure,
6299
+ parentMeasure,
6300
+ parentRelationship: void 0
6301
+ // TODO
6302
+ };
6303
+ }
6304
+ const maybeLevel = next(
6305
+ yieldLevels(cube),
6306
+ (item) => item[0].name === nameWithoutID || item[0].name === nameWithID
6307
+ );
6308
+ if (maybeLevel) {
6309
+ const [level, hierarchy, dimension] = maybeLevel;
6310
+ const hasID = columns.includes(nameWithID);
6311
+ return {
6312
+ name: name4,
6313
+ type: "level",
6314
+ dimension,
6315
+ hierarchy,
6316
+ level,
6317
+ isID: !hasID || name4 === nameWithID,
6318
+ hasID
6319
+ };
6320
+ }
6321
+ const maybeProperty = next(yieldProperties(cube), (item) => item[0].name === name4);
6322
+ if (maybeProperty) {
6323
+ const [property, level, hierarchy, dimension] = maybeProperty;
6324
+ return {
6325
+ name: name4,
6326
+ type: "property",
6327
+ dimension,
6328
+ hierarchy,
6329
+ level,
6330
+ property
6331
+ };
6332
+ }
6333
+ throw new Error(`Missing entity in cube '${cube.name}': ${nameWithoutID}`);
6334
+ }
6335
+ function getColumnEntity(column) {
6336
+ if (column.type === "measure") return column.measure;
6337
+ if (column.type === "level") return column.level;
6338
+ if (column.type === "property") return column.property;
6339
+ throw new Error("Invalid column object");
6340
+ }
6341
+
6342
+ // src/vizbuilder/components/Vizbuilder.tsx
6343
+ init_esm_shims();
6344
+
6180
6345
  // node_modules/clsx/dist/clsx.m.js
6181
6346
  init_esm_shims();
6182
6347
  function r(e) {
@@ -6192,38 +6357,6 @@ function clsx() {
6192
6357
  }
6193
6358
  var clsx_m_default = clsx;
6194
6359
 
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
6360
  // src/vizbuilder/components/ChartCard.tsx
6228
6361
  init_esm_shims();
6229
6362
 
@@ -7053,9 +7186,902 @@ function saveElement_default(elem) {
7053
7186
  }
7054
7187
  }
7055
7188
 
7189
+ // src/vizbuilder/hooks/useD3plusConfig.ts
7190
+ init_esm_shims();
7191
+
7192
+ // node_modules/lodash-es/lodash.js
7193
+ init_esm_shims();
7194
+
7195
+ // node_modules/lodash-es/_baseGetTag.js
7196
+ init_esm_shims();
7197
+
7198
+ // node_modules/lodash-es/_Symbol.js
7199
+ init_esm_shims();
7200
+
7201
+ // node_modules/lodash-es/_root.js
7202
+ init_esm_shims();
7203
+
7204
+ // node_modules/lodash-es/_freeGlobal.js
7205
+ init_esm_shims();
7206
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
7207
+ var freeGlobal_default = freeGlobal;
7208
+
7209
+ // node_modules/lodash-es/_root.js
7210
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
7211
+ var root = freeGlobal_default || freeSelf || Function("return this")();
7212
+ var root_default = root;
7213
+
7214
+ // node_modules/lodash-es/_Symbol.js
7215
+ var Symbol2 = root_default.Symbol;
7216
+ var Symbol_default = Symbol2;
7217
+
7218
+ // node_modules/lodash-es/_getRawTag.js
7219
+ init_esm_shims();
7220
+ var objectProto = Object.prototype;
7221
+ var hasOwnProperty2 = objectProto.hasOwnProperty;
7222
+ var nativeObjectToString = objectProto.toString;
7223
+ var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
7224
+ function getRawTag(value) {
7225
+ var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
7226
+ try {
7227
+ value[symToStringTag] = void 0;
7228
+ var unmasked = true;
7229
+ } catch (e) {
7230
+ }
7231
+ var result = nativeObjectToString.call(value);
7232
+ if (unmasked) {
7233
+ if (isOwn) {
7234
+ value[symToStringTag] = tag;
7235
+ } else {
7236
+ delete value[symToStringTag];
7237
+ }
7238
+ }
7239
+ return result;
7240
+ }
7241
+ var getRawTag_default = getRawTag;
7242
+
7243
+ // node_modules/lodash-es/_objectToString.js
7244
+ init_esm_shims();
7245
+ var objectProto2 = Object.prototype;
7246
+ var nativeObjectToString2 = objectProto2.toString;
7247
+ function objectToString(value) {
7248
+ return nativeObjectToString2.call(value);
7249
+ }
7250
+ var objectToString_default = objectToString;
7251
+
7252
+ // node_modules/lodash-es/_baseGetTag.js
7253
+ var nullTag = "[object Null]";
7254
+ var undefinedTag = "[object Undefined]";
7255
+ var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
7256
+ function baseGetTag(value) {
7257
+ if (value == null) {
7258
+ return value === void 0 ? undefinedTag : nullTag;
7259
+ }
7260
+ return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
7261
+ }
7262
+ var baseGetTag_default = baseGetTag;
7263
+
7264
+ // node_modules/lodash-es/isObjectLike.js
7265
+ init_esm_shims();
7266
+ function isObjectLike(value) {
7267
+ return value != null && typeof value == "object";
7268
+ }
7269
+ var isObjectLike_default = isObjectLike;
7270
+
7271
+ // node_modules/lodash-es/isArray.js
7272
+ init_esm_shims();
7273
+ var isArray = Array.isArray;
7274
+ var isArray_default = isArray;
7275
+
7276
+ // node_modules/lodash-es/isObject.js
7277
+ init_esm_shims();
7278
+ function isObject(value) {
7279
+ var type = typeof value;
7280
+ return value != null && (type == "object" || type == "function");
7281
+ }
7282
+ var isObject_default = isObject;
7283
+
7284
+ // node_modules/lodash-es/identity.js
7285
+ init_esm_shims();
7286
+ function identity2(value) {
7287
+ return value;
7288
+ }
7289
+ var identity_default = identity2;
7290
+
7291
+ // node_modules/lodash-es/_getNative.js
7292
+ init_esm_shims();
7293
+
7294
+ // node_modules/lodash-es/_baseIsNative.js
7295
+ init_esm_shims();
7296
+
7297
+ // node_modules/lodash-es/isFunction.js
7298
+ init_esm_shims();
7299
+ var asyncTag = "[object AsyncFunction]";
7300
+ var funcTag = "[object Function]";
7301
+ var genTag = "[object GeneratorFunction]";
7302
+ var proxyTag = "[object Proxy]";
7303
+ function isFunction(value) {
7304
+ if (!isObject_default(value)) {
7305
+ return false;
7306
+ }
7307
+ var tag = baseGetTag_default(value);
7308
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
7309
+ }
7310
+ var isFunction_default = isFunction;
7311
+
7312
+ // node_modules/lodash-es/_isMasked.js
7313
+ init_esm_shims();
7314
+
7315
+ // node_modules/lodash-es/_coreJsData.js
7316
+ init_esm_shims();
7317
+ var coreJsData = root_default["__core-js_shared__"];
7318
+ var coreJsData_default = coreJsData;
7319
+
7320
+ // node_modules/lodash-es/_isMasked.js
7321
+ var maskSrcKey = function() {
7322
+ var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
7323
+ return uid ? "Symbol(src)_1." + uid : "";
7324
+ }();
7325
+ function isMasked(func) {
7326
+ return !!maskSrcKey && maskSrcKey in func;
7327
+ }
7328
+ var isMasked_default = isMasked;
7329
+
7330
+ // node_modules/lodash-es/_toSource.js
7331
+ init_esm_shims();
7332
+ var funcProto = Function.prototype;
7333
+ var funcToString = funcProto.toString;
7334
+ function toSource(func) {
7335
+ if (func != null) {
7336
+ try {
7337
+ return funcToString.call(func);
7338
+ } catch (e) {
7339
+ }
7340
+ try {
7341
+ return func + "";
7342
+ } catch (e) {
7343
+ }
7344
+ }
7345
+ return "";
7346
+ }
7347
+ var toSource_default = toSource;
7348
+
7349
+ // node_modules/lodash-es/_baseIsNative.js
7350
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
7351
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
7352
+ var funcProto2 = Function.prototype;
7353
+ var objectProto3 = Object.prototype;
7354
+ var funcToString2 = funcProto2.toString;
7355
+ var hasOwnProperty3 = objectProto3.hasOwnProperty;
7356
+ var reIsNative = RegExp(
7357
+ "^" + funcToString2.call(hasOwnProperty3).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
7358
+ );
7359
+ function baseIsNative(value) {
7360
+ if (!isObject_default(value) || isMasked_default(value)) {
7361
+ return false;
7362
+ }
7363
+ var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
7364
+ return pattern.test(toSource_default(value));
7365
+ }
7366
+ var baseIsNative_default = baseIsNative;
7367
+
7368
+ // node_modules/lodash-es/_getValue.js
7369
+ init_esm_shims();
7370
+ function getValue(object, key) {
7371
+ return object == null ? void 0 : object[key];
7372
+ }
7373
+ var getValue_default = getValue;
7374
+
7375
+ // node_modules/lodash-es/_getNative.js
7376
+ function getNative(object, key) {
7377
+ var value = getValue_default(object, key);
7378
+ return baseIsNative_default(value) ? value : void 0;
7379
+ }
7380
+ var getNative_default = getNative;
7381
+
7382
+ // node_modules/lodash-es/_apply.js
7383
+ init_esm_shims();
7384
+ function apply(func, thisArg, args) {
7385
+ switch (args.length) {
7386
+ case 0:
7387
+ return func.call(thisArg);
7388
+ case 1:
7389
+ return func.call(thisArg, args[0]);
7390
+ case 2:
7391
+ return func.call(thisArg, args[0], args[1]);
7392
+ case 3:
7393
+ return func.call(thisArg, args[0], args[1], args[2]);
7394
+ }
7395
+ return func.apply(thisArg, args);
7396
+ }
7397
+ var apply_default = apply;
7398
+
7399
+ // node_modules/lodash-es/_shortOut.js
7400
+ init_esm_shims();
7401
+ var HOT_COUNT = 800;
7402
+ var HOT_SPAN = 16;
7403
+ var nativeNow = Date.now;
7404
+ function shortOut(func) {
7405
+ var count = 0, lastCalled = 0;
7406
+ return function() {
7407
+ var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
7408
+ lastCalled = stamp;
7409
+ if (remaining > 0) {
7410
+ if (++count >= HOT_COUNT) {
7411
+ return arguments[0];
7412
+ }
7413
+ } else {
7414
+ count = 0;
7415
+ }
7416
+ return func.apply(void 0, arguments);
7417
+ };
7418
+ }
7419
+ var shortOut_default = shortOut;
7420
+
7421
+ // node_modules/lodash-es/_setToString.js
7422
+ init_esm_shims();
7423
+
7424
+ // node_modules/lodash-es/_baseSetToString.js
7425
+ init_esm_shims();
7426
+
7427
+ // node_modules/lodash-es/constant.js
7428
+ init_esm_shims();
7429
+ function constant(value) {
7430
+ return function() {
7431
+ return value;
7432
+ };
7433
+ }
7434
+ var constant_default = constant;
7435
+
7436
+ // node_modules/lodash-es/_defineProperty.js
7437
+ init_esm_shims();
7438
+ var defineProperty = function() {
7439
+ try {
7440
+ var func = getNative_default(Object, "defineProperty");
7441
+ func({}, "", {});
7442
+ return func;
7443
+ } catch (e) {
7444
+ }
7445
+ }();
7446
+ var defineProperty_default = defineProperty;
7447
+
7448
+ // node_modules/lodash-es/_baseSetToString.js
7449
+ var baseSetToString = !defineProperty_default ? identity_default : function(func, string) {
7450
+ return defineProperty_default(func, "toString", {
7451
+ "configurable": true,
7452
+ "enumerable": false,
7453
+ "value": constant_default(string),
7454
+ "writable": true
7455
+ });
7456
+ };
7457
+ var baseSetToString_default = baseSetToString;
7458
+
7459
+ // node_modules/lodash-es/_setToString.js
7460
+ var setToString = shortOut_default(baseSetToString_default);
7461
+ var setToString_default = setToString;
7462
+
7463
+ // node_modules/lodash-es/_isIndex.js
7464
+ init_esm_shims();
7465
+ var MAX_SAFE_INTEGER = 9007199254740991;
7466
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
7467
+ function isIndex(value, length) {
7468
+ var type = typeof value;
7469
+ length = length == null ? MAX_SAFE_INTEGER : length;
7470
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
7471
+ }
7472
+ var isIndex_default = isIndex;
7473
+
7474
+ // node_modules/lodash-es/assign.js
7475
+ init_esm_shims();
7476
+
7477
+ // node_modules/lodash-es/_assignValue.js
7478
+ init_esm_shims();
7479
+
7480
+ // node_modules/lodash-es/_baseAssignValue.js
7481
+ init_esm_shims();
7482
+ function baseAssignValue(object, key, value) {
7483
+ if (key == "__proto__" && defineProperty_default) {
7484
+ defineProperty_default(object, key, {
7485
+ "configurable": true,
7486
+ "enumerable": true,
7487
+ "value": value,
7488
+ "writable": true
7489
+ });
7490
+ } else {
7491
+ object[key] = value;
7492
+ }
7493
+ }
7494
+ var baseAssignValue_default = baseAssignValue;
7495
+
7496
+ // node_modules/lodash-es/eq.js
7497
+ init_esm_shims();
7498
+ function eq(value, other) {
7499
+ return value === other || value !== value && other !== other;
7500
+ }
7501
+ var eq_default = eq;
7502
+
7503
+ // node_modules/lodash-es/_assignValue.js
7504
+ var objectProto4 = Object.prototype;
7505
+ var hasOwnProperty4 = objectProto4.hasOwnProperty;
7506
+ function assignValue(object, key, value) {
7507
+ var objValue = object[key];
7508
+ if (!(hasOwnProperty4.call(object, key) && eq_default(objValue, value)) || value === void 0 && !(key in object)) {
7509
+ baseAssignValue_default(object, key, value);
7510
+ }
7511
+ }
7512
+ var assignValue_default = assignValue;
7513
+
7514
+ // node_modules/lodash-es/_copyObject.js
7515
+ init_esm_shims();
7516
+ function copyObject(source, props, object, customizer) {
7517
+ var isNew = !object;
7518
+ object || (object = {});
7519
+ var index = -1, length = props.length;
7520
+ while (++index < length) {
7521
+ var key = props[index];
7522
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
7523
+ if (newValue === void 0) {
7524
+ newValue = source[key];
7525
+ }
7526
+ if (isNew) {
7527
+ baseAssignValue_default(object, key, newValue);
7528
+ } else {
7529
+ assignValue_default(object, key, newValue);
7530
+ }
7531
+ }
7532
+ return object;
7533
+ }
7534
+ var copyObject_default = copyObject;
7535
+
7536
+ // node_modules/lodash-es/_createAssigner.js
7537
+ init_esm_shims();
7538
+
7539
+ // node_modules/lodash-es/_baseRest.js
7540
+ init_esm_shims();
7541
+
7542
+ // node_modules/lodash-es/_overRest.js
7543
+ init_esm_shims();
7544
+ var nativeMax = Math.max;
7545
+ function overRest(func, start, transform) {
7546
+ start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
7547
+ return function() {
7548
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
7549
+ while (++index < length) {
7550
+ array[index] = args[start + index];
7551
+ }
7552
+ index = -1;
7553
+ var otherArgs = Array(start + 1);
7554
+ while (++index < start) {
7555
+ otherArgs[index] = args[index];
7556
+ }
7557
+ otherArgs[start] = transform(array);
7558
+ return apply_default(func, this, otherArgs);
7559
+ };
7560
+ }
7561
+ var overRest_default = overRest;
7562
+
7563
+ // node_modules/lodash-es/_baseRest.js
7564
+ function baseRest(func, start) {
7565
+ return setToString_default(overRest_default(func, start, identity_default), func + "");
7566
+ }
7567
+ var baseRest_default = baseRest;
7568
+
7569
+ // node_modules/lodash-es/_isIterateeCall.js
7570
+ init_esm_shims();
7571
+
7572
+ // node_modules/lodash-es/isArrayLike.js
7573
+ init_esm_shims();
7574
+
7575
+ // node_modules/lodash-es/isLength.js
7576
+ init_esm_shims();
7577
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
7578
+ function isLength(value) {
7579
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
7580
+ }
7581
+ var isLength_default = isLength;
7582
+
7583
+ // node_modules/lodash-es/isArrayLike.js
7584
+ function isArrayLike(value) {
7585
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
7586
+ }
7587
+ var isArrayLike_default = isArrayLike;
7588
+
7589
+ // node_modules/lodash-es/_isIterateeCall.js
7590
+ function isIterateeCall(value, index, object) {
7591
+ if (!isObject_default(object)) {
7592
+ return false;
7593
+ }
7594
+ var type = typeof index;
7595
+ if (type == "number" ? isArrayLike_default(object) && isIndex_default(index, object.length) : type == "string" && index in object) {
7596
+ return eq_default(object[index], value);
7597
+ }
7598
+ return false;
7599
+ }
7600
+ var isIterateeCall_default = isIterateeCall;
7601
+
7602
+ // node_modules/lodash-es/_createAssigner.js
7603
+ function createAssigner(assigner) {
7604
+ return baseRest_default(function(object, sources) {
7605
+ var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
7606
+ customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
7607
+ if (guard && isIterateeCall_default(sources[0], sources[1], guard)) {
7608
+ customizer = length < 3 ? void 0 : customizer;
7609
+ length = 1;
7610
+ }
7611
+ object = Object(object);
7612
+ while (++index < length) {
7613
+ var source = sources[index];
7614
+ if (source) {
7615
+ assigner(object, source, index, customizer);
7616
+ }
7617
+ }
7618
+ return object;
7619
+ });
7620
+ }
7621
+ var createAssigner_default = createAssigner;
7622
+
7623
+ // node_modules/lodash-es/_isPrototype.js
7624
+ init_esm_shims();
7625
+ var objectProto5 = Object.prototype;
7626
+ function isPrototype(value) {
7627
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
7628
+ return value === proto;
7629
+ }
7630
+ var isPrototype_default = isPrototype;
7631
+
7632
+ // node_modules/lodash-es/keys.js
7633
+ init_esm_shims();
7634
+
7635
+ // node_modules/lodash-es/_arrayLikeKeys.js
7636
+ init_esm_shims();
7637
+
7638
+ // node_modules/lodash-es/_baseTimes.js
7639
+ init_esm_shims();
7640
+ function baseTimes(n, iteratee) {
7641
+ var index = -1, result = Array(n);
7642
+ while (++index < n) {
7643
+ result[index] = iteratee(index);
7644
+ }
7645
+ return result;
7646
+ }
7647
+ var baseTimes_default = baseTimes;
7648
+
7649
+ // node_modules/lodash-es/isArguments.js
7650
+ init_esm_shims();
7651
+
7652
+ // node_modules/lodash-es/_baseIsArguments.js
7653
+ init_esm_shims();
7654
+ var argsTag = "[object Arguments]";
7655
+ function baseIsArguments(value) {
7656
+ return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
7657
+ }
7658
+ var baseIsArguments_default = baseIsArguments;
7659
+
7660
+ // node_modules/lodash-es/isArguments.js
7661
+ var objectProto6 = Object.prototype;
7662
+ var hasOwnProperty5 = objectProto6.hasOwnProperty;
7663
+ var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
7664
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
7665
+ return arguments;
7666
+ }()) ? baseIsArguments_default : function(value) {
7667
+ return isObjectLike_default(value) && hasOwnProperty5.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
7668
+ };
7669
+ var isArguments_default = isArguments;
7670
+
7671
+ // node_modules/lodash-es/isBuffer.js
7672
+ init_esm_shims();
7673
+
7674
+ // node_modules/lodash-es/stubFalse.js
7675
+ init_esm_shims();
7676
+ function stubFalse() {
7677
+ return false;
7678
+ }
7679
+ var stubFalse_default = stubFalse;
7680
+
7681
+ // node_modules/lodash-es/isBuffer.js
7682
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
7683
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
7684
+ var moduleExports = freeModule && freeModule.exports === freeExports;
7685
+ var Buffer2 = moduleExports ? root_default.Buffer : void 0;
7686
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
7687
+ var isBuffer = nativeIsBuffer || stubFalse_default;
7688
+ var isBuffer_default = isBuffer;
7689
+
7690
+ // node_modules/lodash-es/isTypedArray.js
7691
+ init_esm_shims();
7692
+
7693
+ // node_modules/lodash-es/_baseIsTypedArray.js
7694
+ init_esm_shims();
7695
+ var argsTag2 = "[object Arguments]";
7696
+ var arrayTag = "[object Array]";
7697
+ var boolTag = "[object Boolean]";
7698
+ var dateTag = "[object Date]";
7699
+ var errorTag = "[object Error]";
7700
+ var funcTag2 = "[object Function]";
7701
+ var mapTag = "[object Map]";
7702
+ var numberTag = "[object Number]";
7703
+ var objectTag = "[object Object]";
7704
+ var regexpTag = "[object RegExp]";
7705
+ var setTag = "[object Set]";
7706
+ var stringTag = "[object String]";
7707
+ var weakMapTag = "[object WeakMap]";
7708
+ var arrayBufferTag = "[object ArrayBuffer]";
7709
+ var dataViewTag = "[object DataView]";
7710
+ var float32Tag = "[object Float32Array]";
7711
+ var float64Tag = "[object Float64Array]";
7712
+ var int8Tag = "[object Int8Array]";
7713
+ var int16Tag = "[object Int16Array]";
7714
+ var int32Tag = "[object Int32Array]";
7715
+ var uint8Tag = "[object Uint8Array]";
7716
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
7717
+ var uint16Tag = "[object Uint16Array]";
7718
+ var uint32Tag = "[object Uint32Array]";
7719
+ var typedArrayTags = {};
7720
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
7721
+ 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;
7722
+ function baseIsTypedArray(value) {
7723
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
7724
+ }
7725
+ var baseIsTypedArray_default = baseIsTypedArray;
7726
+
7727
+ // node_modules/lodash-es/_baseUnary.js
7728
+ init_esm_shims();
7729
+ function baseUnary(func) {
7730
+ return function(value) {
7731
+ return func(value);
7732
+ };
7733
+ }
7734
+ var baseUnary_default = baseUnary;
7735
+
7736
+ // node_modules/lodash-es/_nodeUtil.js
7737
+ init_esm_shims();
7738
+ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
7739
+ var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
7740
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
7741
+ var freeProcess = moduleExports2 && freeGlobal_default.process;
7742
+ var nodeUtil = function() {
7743
+ try {
7744
+ var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
7745
+ if (types) {
7746
+ return types;
7747
+ }
7748
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
7749
+ } catch (e) {
7750
+ }
7751
+ }();
7752
+ var nodeUtil_default = nodeUtil;
7753
+
7754
+ // node_modules/lodash-es/isTypedArray.js
7755
+ var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
7756
+ var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
7757
+ var isTypedArray_default = isTypedArray;
7758
+
7759
+ // node_modules/lodash-es/_arrayLikeKeys.js
7760
+ var objectProto7 = Object.prototype;
7761
+ var hasOwnProperty6 = objectProto7.hasOwnProperty;
7762
+ function arrayLikeKeys(value, inherited) {
7763
+ 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;
7764
+ for (var key in value) {
7765
+ if ((inherited || hasOwnProperty6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
7766
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
7767
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
7768
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
7769
+ isIndex_default(key, length)))) {
7770
+ result.push(key);
7771
+ }
7772
+ }
7773
+ return result;
7774
+ }
7775
+ var arrayLikeKeys_default = arrayLikeKeys;
7776
+
7777
+ // node_modules/lodash-es/_baseKeys.js
7778
+ init_esm_shims();
7779
+
7780
+ // node_modules/lodash-es/_nativeKeys.js
7781
+ init_esm_shims();
7782
+
7783
+ // node_modules/lodash-es/_overArg.js
7784
+ init_esm_shims();
7785
+ function overArg(func, transform) {
7786
+ return function(arg) {
7787
+ return func(transform(arg));
7788
+ };
7789
+ }
7790
+ var overArg_default = overArg;
7791
+
7792
+ // node_modules/lodash-es/_nativeKeys.js
7793
+ var nativeKeys = overArg_default(Object.keys, Object);
7794
+ var nativeKeys_default = nativeKeys;
7795
+
7796
+ // node_modules/lodash-es/_baseKeys.js
7797
+ var objectProto8 = Object.prototype;
7798
+ var hasOwnProperty7 = objectProto8.hasOwnProperty;
7799
+ function baseKeys(object) {
7800
+ if (!isPrototype_default(object)) {
7801
+ return nativeKeys_default(object);
7802
+ }
7803
+ var result = [];
7804
+ for (var key in Object(object)) {
7805
+ if (hasOwnProperty7.call(object, key) && key != "constructor") {
7806
+ result.push(key);
7807
+ }
7808
+ }
7809
+ return result;
7810
+ }
7811
+ var baseKeys_default = baseKeys;
7812
+
7813
+ // node_modules/lodash-es/keys.js
7814
+ function keys(object) {
7815
+ return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
7816
+ }
7817
+ var keys_default = keys;
7818
+
7819
+ // node_modules/lodash-es/assign.js
7820
+ var objectProto9 = Object.prototype;
7821
+ var hasOwnProperty8 = objectProto9.hasOwnProperty;
7822
+ var assign = createAssigner_default(function(object, source) {
7823
+ if (isPrototype_default(source) || isArrayLike_default(source)) {
7824
+ copyObject_default(source, keys_default(source), object);
7825
+ return;
7826
+ }
7827
+ for (var key in source) {
7828
+ if (hasOwnProperty8.call(source, key)) {
7829
+ assignValue_default(object, key, source[key]);
7830
+ }
7831
+ }
7832
+ });
7833
+ var assign_default = assign;
7834
+ function useD3plusConfig(chart, params) {
7835
+ const { fullMode, getMeasureConfig, showConfidenceInt, t } = params;
7836
+ const measures = useMemo(() => {
7837
+ return (chart == null ? void 0 : chart.datagroup.measureColumns.map((item) => item.measure)) || [];
7838
+ }, [chart == null ? void 0 : chart.datagroup]);
7839
+ const { getFormatter } = useFormatter(measures);
7840
+ return useMemo(() => {
7841
+ if (!chart) return [null, { data: "", locale: "" }];
7842
+ const params2 = { fullMode, getFormatter, getMeasureConfig, showConfidenceInt, t };
7843
+ const { locale } = chart.datagroup;
7844
+ if (chart.type === "barchart") {
7845
+ return [BarChart, buildBarchartConfig(chart, params2)];
7846
+ }
7847
+ if (chart.type === "choropleth") {
7848
+ return [Geomap, buildChoroplethConfig(chart, params2)];
7849
+ }
7850
+ if (chart.type === "donut") {
7851
+ return [Donut, buildDonutConfig(chart, params2)];
7852
+ }
7853
+ if (chart.type === "lineplot") {
7854
+ return [LinePlot, buildLineplotConfig(chart, params2)];
7855
+ }
7856
+ if (chart.type === "stackedarea") {
7857
+ return [StackedArea, buildStackedareaConfig(chart, params2)];
7858
+ }
7859
+ if (chart.type === "treemap") {
7860
+ return [Treemap, buildTreemapConfig(chart, params2)];
7861
+ }
7862
+ return [null, { data: "", locale }];
7863
+ }, [chart, fullMode, getFormatter, getMeasureConfig, showConfidenceInt, t]);
7864
+ }
7865
+ function buildBarchartConfig(chart, params) {
7866
+ const { fullMode, getFormatter, t } = params;
7867
+ const { datagroup, values, series, timeline, orientation } = chart;
7868
+ const { columns, dataset, locale } = datagroup;
7869
+ const [mainSeries, stackedSeries] = series;
7870
+ const collate = new Intl.Collator(locale, { numeric: true, ignorePunctuation: true });
7871
+ const measureFormatter = getFormatter(values.measure.name);
7872
+ const measureAggregator = values.measure.annotations.aggregation_method || values.measure.aggregator;
7873
+ const measureUnits = values.measure.annotations.units_of_measurement || "";
7874
+ const isPercentage = ["Percentage", "Rate"].includes(measureUnits);
7875
+ const config = {
7876
+ barPadding: fullMode ? 5 : 1,
7877
+ data: dataset,
7878
+ discrete: chart.orientation === "horizontal" ? "y" : "x",
7879
+ groupBy: stackedSeries == null ? void 0 : stackedSeries.name,
7880
+ groupPadding: fullMode ? 5 : 1,
7881
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
7882
+ legend: fullMode,
7883
+ locale,
7884
+ stacked: stackedSeries && isIn(measureAggregator.toUpperCase(), ["COUNT", "SUM"]) || isPercentage,
7885
+ time: (timeline == null ? void 0 : timeline.name) === "Quarter ID" ? timeline.level.name : timeline == null ? void 0 : timeline.name,
7886
+ timeline: timeline && fullMode,
7887
+ timelineConfig: {
7888
+ brushing: false,
7889
+ playButton: false
7890
+ },
7891
+ tooltipConfig: {
7892
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7893
+ },
7894
+ total: !timeline
7895
+ };
7896
+ if (orientation === "horizontal") {
7897
+ Object.assign(config, {
7898
+ x: values.measure.name,
7899
+ xConfig: {
7900
+ title: values.measure.caption,
7901
+ tickFormat: (d) => measureFormatter(d, locale)
7902
+ },
7903
+ y: mainSeries.level.name,
7904
+ yConfig: {
7905
+ title: mainSeries.level.caption
7906
+ },
7907
+ ySort: collate.compare
7908
+ });
7909
+ } else {
7910
+ Object.assign(config, {
7911
+ x: mainSeries.level.name,
7912
+ xConfig: {
7913
+ title: mainSeries.level.caption
7914
+ },
7915
+ y: values.measure.name,
7916
+ yConfig: {
7917
+ title: values.measure.caption,
7918
+ tickFormat: (d) => measureFormatter(d, locale)
7919
+ }
7920
+ });
7921
+ }
7922
+ return config;
7923
+ }
7924
+ function buildChoroplethConfig(chart, params) {
7925
+ const { datagroup, values, series, timeline } = chart;
7926
+ const { fullMode, getFormatter, t } = params;
7927
+ const { columns, dataset, locale } = datagroup;
7928
+ const { members: firstSeriesMembers } = series[0];
7929
+ const lastSeries = getLast(series);
7930
+ const measureFormatter = getFormatter(values.measure.name);
7931
+ const config = {
7932
+ colorScale: values.measure.name,
7933
+ colorScaleConfig: {
7934
+ axisConfig: {
7935
+ tickFormat: (d) => measureFormatter(d, locale)
7936
+ },
7937
+ scale: "jenks"
7938
+ },
7939
+ colorScalePosition: fullMode ? "right" : false,
7940
+ data: dataset,
7941
+ fitFilter: (d) => {
7942
+ var _a;
7943
+ return firstSeriesMembers.includes((_a = d.id) != null ? _a : d.properties.id);
7944
+ },
7945
+ groupBy: series.map((series2) => series2.name),
7946
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
7947
+ locale,
7948
+ ocean: "transparent",
7949
+ projectionRotate: [0, 0],
7950
+ tiles: false,
7951
+ time: timeline == null ? void 0 : timeline.level.name,
7952
+ timeline: fullMode && (timeline == null ? void 0 : timeline.level.name),
7953
+ timelineConfig: {
7954
+ brushing: false,
7955
+ playButton: false
7956
+ },
7957
+ tooltip: true,
7958
+ tooltipConfig: {
7959
+ title(d) {
7960
+ return d[lastSeries.level.name];
7961
+ },
7962
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7963
+ },
7964
+ zoomScroll: false
7965
+ };
7966
+ assign_default(config, chart.extraConfig);
7967
+ return config;
7968
+ }
7969
+ function buildDonutConfig(chart, params) {
7970
+ const { datagroup, series, timeline, values } = chart;
7971
+ const { fullMode, getFormatter, t } = params;
7972
+ const { columns, dataset, locale } = datagroup;
7973
+ const [mainSeries] = series;
7974
+ const measureFormatter = getFormatter(values.measure.name);
7975
+ const config = {
7976
+ data: dataset,
7977
+ groupBy: [mainSeries.name],
7978
+ label: (d) => d[mainSeries.level.name],
7979
+ locale,
7980
+ time: timeline == null ? void 0 : timeline.name,
7981
+ timeline: fullMode && timeline,
7982
+ timelineConfig: {
7983
+ brushing: false,
7984
+ playButton: false
7985
+ },
7986
+ tooltipConfig: {
7987
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
7988
+ },
7989
+ total: !timeline,
7990
+ value: values.measure.name
7991
+ };
7992
+ return config;
7993
+ }
7994
+ function buildLineplotConfig(chart, params) {
7995
+ const { datagroup, values, series, time } = chart;
7996
+ const { fullMode, getFormatter, t } = params;
7997
+ const { columns, dataset, locale } = datagroup;
7998
+ const measureFormatter = getFormatter(values.measure.name);
7999
+ const config = {
8000
+ data: dataset,
8001
+ discrete: "x",
8002
+ label: (d) => {
8003
+ return series.map((series2) => d[series2.level.name]).join("\n");
8004
+ },
8005
+ legend: fullMode,
8006
+ locale,
8007
+ groupBy: series.map((series2) => series2.name),
8008
+ time: time.level.name,
8009
+ timeline: fullMode,
8010
+ timelineConfig: {
8011
+ brushing: true,
8012
+ playButton: false
8013
+ },
8014
+ tooltipConfig: {
8015
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8016
+ },
8017
+ total: false,
8018
+ x: time.level.name,
8019
+ xConfig: {
8020
+ title: time.level.caption
8021
+ },
8022
+ y: values.measure.name,
8023
+ yConfig: {
8024
+ scale: "auto",
8025
+ tickFormat: (d) => measureFormatter(d, locale),
8026
+ title: values.measure.caption
8027
+ }
8028
+ };
8029
+ return config;
8030
+ }
8031
+ function buildStackedareaConfig(chart, params) {
8032
+ const { datagroup, series, timeline, values } = chart;
8033
+ const { fullMode, getFormatter, t } = params;
8034
+ const { columns, dataset, locale } = datagroup;
8035
+ const measureFormatter = getFormatter(values.measure.name);
8036
+ const config = {
8037
+ data: dataset,
8038
+ groupBy: series.map((series2) => series2.name),
8039
+ locale,
8040
+ time: timeline == null ? void 0 : timeline.name,
8041
+ timeline: timeline && fullMode,
8042
+ tooltipConfig: {
8043
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8044
+ },
8045
+ value: values.measure.name
8046
+ };
8047
+ return config;
8048
+ }
8049
+ function buildTreemapConfig(chart, params) {
8050
+ const { datagroup, series, timeline, values } = chart;
8051
+ const { fullMode, getFormatter, t } = params;
8052
+ const { columns, dataset, locale } = datagroup;
8053
+ const measureFormatter = getFormatter(values.measure.name);
8054
+ const config = {
8055
+ data: dataset,
8056
+ label: (d) => series.map((series2) => d[series2.level.name]).join("\n"),
8057
+ locale,
8058
+ groupBy: series.map((series2) => series2.name),
8059
+ sum: values.measure.name,
8060
+ threshold: 5e-3,
8061
+ thresholdName: series[0].name,
8062
+ time: timeline == null ? void 0 : timeline.name,
8063
+ timeline: timeline && fullMode,
8064
+ tooltipConfig: {
8065
+ tbody: _buildTooltipTbody(columns, values.measure, measureFormatter, locale)
8066
+ }
8067
+ };
8068
+ return config;
8069
+ }
8070
+ function _buildTooltipTbody(columns, measure, measureFormatter, locale) {
8071
+ return (d) => {
8072
+ const { caption: meaCaption, name: meaName } = measure;
8073
+ return filterMap(Object.values(columns), (column) => {
8074
+ if (column.type === "measure") return null;
8075
+ if (column.type === "level" && column.hasID && column.isID) return null;
8076
+ const { caption, name: name4 } = getColumnEntity(column);
8077
+ return [caption, d[name4]];
8078
+ }).concat([[meaCaption, measureFormatter(d[meaName], locale)]]);
8079
+ };
8080
+ }
8081
+
7056
8082
  // src/vizbuilder/components/ErrorBoundary.tsx
7057
8083
  init_esm_shims();
7058
- var ErrorBoundary = class extends React13__default.Component {
8084
+ var ErrorBoundary = class extends Component {
7059
8085
  constructor() {
7060
8086
  super(...arguments);
7061
8087
  this.state = {
@@ -7073,92 +8099,92 @@ var ErrorBoundary = class extends React13__default.Component {
7073
8099
  return this.props.children;
7074
8100
  }
7075
8101
  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,
8102
+ const detailText = t("vizbuilder.error.detail");
8103
+ return /* @__PURE__ */ React13__default.createElement(
8104
+ Flex,
7079
8105
  {
7080
- onClick: this.clearError,
7081
- size: "xs",
7082
- variant: "light"
8106
+ p: "xl",
8107
+ align: "center",
8108
+ justify: "center",
8109
+ direction: "column",
8110
+ className: "chart-card error"
7083
8111
  },
7084
- t("action_retry")
7085
- ), /* @__PURE__ */ React13__default.createElement(Button, { error: name4, message })));
8112
+ /* @__PURE__ */ React13__default.createElement(Title, { order: 3 }, t("vizbuilder.error.title")),
8113
+ detailText.length ? /* @__PURE__ */ React13__default.createElement(Text, null, detailText) : null,
8114
+ /* @__PURE__ */ React13__default.createElement(Text, null, t("vizbuilder.error.message", { message })),
8115
+ /* @__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 }))
8116
+ );
7086
8117
  });
7087
8118
  }
7088
8119
  };
8120
+ function IssueButton(props) {
8121
+ const { error, message } = props;
8122
+ const { translate: t } = useTranslation();
8123
+ const location2 = typeof window === "object" ? window.location : { href: "<SSR>" };
8124
+ const issueParams = new URLSearchParams({
8125
+ title: `[report/vizbuilder] ${error}`,
8126
+ body: [
8127
+ `**URL**: ${location2.href}`,
8128
+ `**Error**: ${error}`,
8129
+ message ? `**Error details:** ${message}
8130
+ ` : "",
8131
+ "**Detail of the issue:**\n"
8132
+ ].join("\n")
8133
+ });
8134
+ return /* @__PURE__ */ React13__default.createElement(
8135
+ Button,
8136
+ {
8137
+ component: "a",
8138
+ href: `https://github.com/Datawheel/vizbuilder/issues/new?${issueParams}`,
8139
+ leftIcon: /* @__PURE__ */ React13__default.createElement(IconBrandGithub, { size: "1rem" }),
8140
+ rel: "noopener noreferrer",
8141
+ role: "button",
8142
+ size: "xs",
8143
+ tabIndex: 0,
8144
+ target: "_blank",
8145
+ variant: "subtle"
8146
+ },
8147
+ t("vizbuilder.action_fileissue")
8148
+ );
8149
+ }
7089
8150
 
7090
8151
  // 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
8152
  var iconByFormat = {
7103
8153
  jpg: IconPhotoDown,
7104
8154
  png: IconPhotoDown,
7105
8155
  svg: IconVectorTriangle
7106
8156
  };
7107
8157
  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();
8158
+ const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt } = props;
8159
+ const { translate } = useTranslation();
7118
8160
  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
- );
8161
+ const [ChartComponent, config] = useD3plusConfig(chart, {
8162
+ fullMode: !!isFullMode,
8163
+ showConfidenceInt: !!showConfidenceInt,
8164
+ getMeasureConfig: props.measureConfig,
8165
+ t: translate
8166
+ });
7140
8167
  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) => {
8168
+ const filename = (typeof config.title === "function" ? config.title() : config.title || "").replace(/[^\w]/g, "_").replace(/[_]+/g, "_");
8169
+ return asArray(downloadFormats).map((format2) => {
7144
8170
  const formatLower = format2.toLowerCase();
7145
8171
  const Icon = iconByFormat[formatLower] || IconDownload;
7146
8172
  return /* @__PURE__ */ React13__default.createElement(
7147
8173
  Button,
7148
8174
  {
7149
- compact: true,
7150
8175
  key: format2,
8176
+ compact: true,
7151
8177
  leftIcon: /* @__PURE__ */ React13__default.createElement(Icon, { size: 16 }),
7152
8178
  onClick: () => {
7153
8179
  const { current: boxElement } = nodeRef;
7154
8180
  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
- );
8181
+ if (svgElement) {
8182
+ saveElement_default(
8183
+ svgElement,
8184
+ { filename, type: formatLower },
8185
+ { background: getBackground(svgElement) }
8186
+ );
8187
+ }
7162
8188
  },
7163
8189
  size: "sm",
7164
8190
  variant: "light"
@@ -7166,24 +8192,24 @@ function ChartCard(props) {
7166
8192
  format2.toUpperCase()
7167
8193
  );
7168
8194
  });
7169
- }, [isFocused, isSingleChart, props.downloadFormats, config.title]);
8195
+ }, [config, downloadFormats]);
7170
8196
  const focusButton = useMemo(() => {
7171
- if (!isFocused && isSingleChart) return null;
7172
- const Icon = isFocused ? IconArrowsMinimize : IconArrowsMaximize;
8197
+ const Icon = isFullMode ? IconArrowsMinimize : IconArrowsMaximize;
7173
8198
  return /* @__PURE__ */ React13__default.createElement(
7174
8199
  Button,
7175
8200
  {
7176
8201
  compact: true,
7177
8202
  leftIcon: /* @__PURE__ */ React13__default.createElement(Icon, { size: 16 }),
7178
- onClick: props.onToggle,
8203
+ onClick: onFocus,
7179
8204
  size: "sm",
7180
- variant: isFocused ? "filled" : "light"
8205
+ variant: isFullMode ? "filled" : "light"
7181
8206
  },
7182
- isFocused ? translate("vizbuilder.action_close") : translate("vizbuilder.action_enlarge")
8207
+ isFullMode ? translate("vizbuilder.action_close") : translate("vizbuilder.action_enlarge")
7183
8208
  );
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 })))));
8209
+ }, [isFullMode, translate, onFocus]);
8210
+ const height = isFullMode ? "calc(100vh - 3rem)" : 300;
8211
+ if (!ChartComponent) return null;
8212
+ 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
8213
  }
7188
8214
  var getBackground = (node) => {
7189
8215
  if (node.nodeType !== Node.ELEMENT_NODE) return "white";
@@ -7192,150 +8218,178 @@ var getBackground = (node) => {
7192
8218
  return color && color !== "rgba(0, 0, 0, 0)" && color !== "transparent" ? color : getBackground(node.parentNode);
7193
8219
  };
7194
8220
 
7195
- // src/vizbuilder/components/VizbuilderView.tsx
7196
- function createVizbuilderView(settings) {
8221
+ // src/vizbuilder/components/NonIdealState.tsx
8222
+ init_esm_shims();
8223
+ function NonIdealState2() {
8224
+ const { translate: t } = useTranslation();
8225
+ return /* @__PURE__ */ React13__default.createElement("div", { className: "vb-nonidealstate" }, /* @__PURE__ */ React13__default.createElement("h1", { className: "vb-nonidealstate-header" }, t("title.nonidealstate")));
8226
+ }
8227
+
8228
+ // src/vizbuilder/components/Vizbuilder.tsx
8229
+ function Vizbuilder(props) {
7197
8230
  const {
8231
+ datasets,
8232
+ chartLimits,
7198
8233
  chartTypes,
7199
8234
  datacap,
7200
- defaultLocale = "en",
7201
8235
  downloadFormats,
7202
- nonIdealState: Notice = NonIdealState2,
7203
- showConfidenceInt = false,
8236
+ measureConfig,
8237
+ nonIdealState,
8238
+ showConfidenceInt,
7204
8239
  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
- }
8240
+ userConfig
8241
+ } = props;
8242
+ const [currentChart, setCurrentChart] = useState("");
8243
+ const getMeasureConfig = useMemo(() => {
8244
+ const config = measureConfig || {};
8245
+ return typeof config === "function" ? config : (item) => config[item.name];
8246
+ }, [measureConfig]);
8247
+ const getTopojsonConfig = useMemo(() => {
8248
+ const config = topojsonConfig || {};
8249
+ return typeof config === "function" ? config : (item) => config[item.name];
8250
+ }, [topojsonConfig]);
8251
+ const charts = useMemo(() => {
8252
+ const charts2 = generateCharts(asArray(datasets), {
8253
+ chartLimits,
8254
+ chartTypes,
8255
+ datacap,
8256
+ getTopojsonConfig
8257
+ });
8258
+ return Object.fromEntries(charts2.map((chart) => [chart.key, chart]));
8259
+ }, [chartLimits, chartTypes, datacap, datasets, getTopojsonConfig]);
8260
+ const content = useMemo(() => {
8261
+ const chartList = Object.values(charts);
8262
+ if (chartList.length === 0) {
8263
+ const Notice = nonIdealState || NonIdealState2;
8264
+ return /* @__PURE__ */ React13__default.createElement(Notice, null);
8265
+ }
8266
+ const isSingleChart = chartList.length === 1;
8267
+ return /* @__PURE__ */ React13__default.createElement(
8268
+ SimpleGrid,
8269
+ {
8270
+ breakpoints: [
8271
+ { minWidth: "xs", cols: 1 },
8272
+ { minWidth: "md", cols: 2 },
8273
+ { minWidth: "lg", cols: 3 },
8274
+ { minWidth: "xl", cols: 4 }
7256
8275
  ],
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(
8276
+ className: clsx_m_default({ unique: isSingleChart })
8277
+ },
8278
+ chartList.map((chart) => /* @__PURE__ */ React13__default.createElement(
7299
8279
  ChartCard,
7300
8280
  {
8281
+ key: chart.key,
7301
8282
  chart,
7302
- currentChart,
7303
8283
  downloadFormats,
7304
- isSingleChart: true,
7305
- key: `${chart.key}-focus`,
7306
8284
  measureConfig: getMeasureConfig,
7307
- onToggle: resetCurrentPanel,
8285
+ onFocus: () => setCurrentChart(chart.key),
7308
8286
  showConfidenceInt,
7309
8287
  userConfig
7310
8288
  }
7311
- );
7312
- }, [currentChart, charts, resetCurrentPanel]);
7313
- return /* @__PURE__ */ React13__default.createElement(Box, { className: props.className, p: "sm" }, content, /* @__PURE__ */ React13__default.createElement(
7314
- Modal,
8289
+ ))
8290
+ );
8291
+ }, [
8292
+ charts,
8293
+ getMeasureConfig,
8294
+ nonIdealState,
8295
+ downloadFormats,
8296
+ userConfig,
8297
+ showConfidenceInt
8298
+ ]);
8299
+ const focusContent = useMemo(() => {
8300
+ const chart = charts[currentChart];
8301
+ if (!chart) return null;
8302
+ return /* @__PURE__ */ React13__default.createElement(
8303
+ ChartCard,
7315
8304
  {
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
8305
+ key: `${chart.key}-focus`,
8306
+ chart,
8307
+ downloadFormats,
8308
+ measureConfig: getMeasureConfig,
8309
+ onFocus: () => setCurrentChart(""),
8310
+ showConfidenceInt,
8311
+ userConfig,
8312
+ isFullMode: true
8313
+ }
8314
+ );
8315
+ }, [
8316
+ charts,
8317
+ currentChart,
8318
+ downloadFormats,
8319
+ getMeasureConfig,
8320
+ showConfidenceInt,
8321
+ userConfig
8322
+ ]);
8323
+ return /* @__PURE__ */ React13__default.createElement("div", { className: clsx_m_default("vb-wrapper", props.className) }, props.customHeader, content, props.customFooter, /* @__PURE__ */ React13__default.createElement(
8324
+ Modal,
8325
+ {
8326
+ centered: true,
8327
+ onClose: useCallback(() => setCurrentChart(""), []),
8328
+ opened: currentChart !== "",
8329
+ padding: 0,
8330
+ size: "calc(100vw - 3rem)",
8331
+ styles: {
8332
+ content: { maxHeight: "none !important" },
8333
+ inner: { padding: "0 !important" }
7326
8334
  },
7327
- focusContent
7328
- ));
7329
- }
8335
+ withCloseButton: false
8336
+ },
8337
+ focusContent
8338
+ ));
7330
8339
  }
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")));
8340
+
8341
+ // src/vizbuilder/components/VizbuilderView.tsx
8342
+ var CHART_LIMITS = {
8343
+ BARCHART_MAX_BARS: 20,
8344
+ BARCHART_YEAR_MAX_BARS: 20,
8345
+ BARCHART_MAX_STACKED_BARS: 10,
8346
+ DONUT_SHAPE_MAX: 30,
8347
+ LINEPLOT_LINE_POINT_MIN: 2,
8348
+ LINEPLOT_LINE_MAX: 20,
8349
+ STACKED_SHAPE_MAX: 200,
8350
+ STACKED_TIME_MEMBER_MIN: 2,
8351
+ TREE_MAP_SHAPE_MAX: 1e3
8352
+ };
8353
+ var DOWNLOAD_FORMATS = ["SVG", "PNG"];
8354
+ function VizbuilderView(props) {
8355
+ const { cube, params, result } = props;
8356
+ const dataset = useMemo(() => {
8357
+ const columns = Object.keys(result.types);
8358
+ return {
8359
+ columns: Object.fromEntries(
8360
+ columns.map((columnName) => [
8361
+ columnName,
8362
+ buildColumn(cube, columnName, columns)
8363
+ ])
8364
+ ),
8365
+ data: result.data,
8366
+ locale: params.locale || "en"
8367
+ };
8368
+ }, [cube, result, params.locale]);
8369
+ return /* @__PURE__ */ React13__default.createElement(
8370
+ Vizbuilder,
8371
+ {
8372
+ datasets: dataset,
8373
+ chartLimits: CHART_LIMITS,
8374
+ downloadFormats: DOWNLOAD_FORMATS
8375
+ }
8376
+ );
7334
8377
  }
7335
8378
  /*! Bundled license information:
7336
8379
 
7337
8380
  file-saver/FileSaver.js:
7338
8381
  (*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js *)
8382
+
8383
+ lodash-es/lodash.js:
8384
+ (**
8385
+ * @license
8386
+ * Lodash (Custom Build) <https://lodash.com/>
8387
+ * Build: `lodash modularize exports="es" -o ./`
8388
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
8389
+ * Released under MIT license <https://lodash.com/license>
8390
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8391
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8392
+ *)
7339
8393
  */
7340
8394
 
7341
- export { DebugView, ExplorerComponent as Explorer, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, createVizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
8395
+ export { DebugView, ExplorerComponent as Explorer, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };