@quillsql/react 2.10.4 → 2.10.6

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 (120) hide show
  1. package/dist/cjs/Chart.d.ts +2 -2
  2. package/dist/cjs/Chart.d.ts.map +1 -1
  3. package/dist/cjs/Chart.js +22 -30
  4. package/dist/cjs/ChartBuilder.d.ts.map +1 -1
  5. package/dist/cjs/ChartBuilder.js +18 -9
  6. package/dist/cjs/ChartEditor.js +1 -1
  7. package/dist/cjs/Context.d.ts +22 -39
  8. package/dist/cjs/Context.d.ts.map +1 -1
  9. package/dist/cjs/Context.js +11 -9
  10. package/dist/cjs/Dashboard.d.ts +116 -26
  11. package/dist/cjs/Dashboard.d.ts.map +1 -1
  12. package/dist/cjs/Dashboard.js +92 -402
  13. package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
  14. package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
  15. package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +9 -9
  16. package/dist/cjs/SQLEditor.d.ts.map +1 -1
  17. package/dist/cjs/SQLEditor.js +2 -4
  18. package/dist/cjs/Table.d.ts.map +1 -1
  19. package/dist/cjs/Table.js +12 -2
  20. package/dist/cjs/components/Chart/BarChart.d.ts +2 -2
  21. package/dist/cjs/components/Chart/BarChart.js +2 -2
  22. package/dist/cjs/components/Chart/ChartError.d.ts +3 -0
  23. package/dist/cjs/components/Chart/ChartError.d.ts.map +1 -0
  24. package/dist/cjs/components/Chart/ChartError.js +29 -0
  25. package/dist/cjs/components/Chart/ChartSkeleton.d.ts +3 -0
  26. package/dist/cjs/components/Chart/ChartSkeleton.d.ts.map +1 -0
  27. package/dist/cjs/components/Chart/ChartSkeleton.js +20 -0
  28. package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
  29. package/dist/cjs/components/Chart/ChartTooltipFrame.js +1 -0
  30. package/dist/cjs/components/Chart/LineChart.d.ts +2 -2
  31. package/dist/cjs/components/Chart/LineChart.js +2 -2
  32. package/dist/cjs/components/Dashboard/DashboardGroup.d.ts +3 -0
  33. package/dist/cjs/components/Dashboard/DashboardGroup.d.ts.map +1 -0
  34. package/dist/cjs/components/Dashboard/DashboardGroup.js +16 -0
  35. package/dist/cjs/components/Dashboard/DashboardItem.d.ts +3 -0
  36. package/dist/cjs/components/Dashboard/DashboardItem.d.ts.map +1 -0
  37. package/dist/cjs/components/Dashboard/DashboardItem.js +64 -0
  38. package/dist/cjs/components/Dashboard/DashboardSection.d.ts +3 -0
  39. package/dist/cjs/components/Dashboard/DashboardSection.d.ts.map +1 -0
  40. package/dist/cjs/components/Dashboard/DashboardSection.js +7 -0
  41. package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
  42. package/dist/cjs/hooks/useQuill.js +15 -9
  43. package/dist/cjs/index.d.ts +1 -1
  44. package/dist/cjs/index.d.ts.map +1 -1
  45. package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -1
  46. package/dist/cjs/internals/ReportBuilder/PivotModal.js +1 -1
  47. package/dist/cjs/utils/axisFormatter.d.ts.map +1 -1
  48. package/dist/cjs/utils/axisFormatter.js +7 -18
  49. package/dist/cjs/utils/dashboard.d.ts +12 -0
  50. package/dist/cjs/utils/dashboard.d.ts.map +1 -0
  51. package/dist/cjs/utils/dashboard.js +150 -0
  52. package/dist/cjs/utils/styles.d.ts +17 -0
  53. package/dist/cjs/utils/styles.d.ts.map +1 -0
  54. package/dist/cjs/utils/styles.js +20 -0
  55. package/dist/cjs/utils/valueFormatter.d.ts +1 -1
  56. package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
  57. package/dist/cjs/utils/valueFormatter.js +7 -18
  58. package/dist/cjs/utils/valueFormatterCSV.d.ts.map +1 -1
  59. package/dist/cjs/utils/valueFormatterCSV.js +7 -15
  60. package/dist/esm/Chart.d.ts +2 -2
  61. package/dist/esm/Chart.d.ts.map +1 -1
  62. package/dist/esm/Chart.js +23 -31
  63. package/dist/esm/ChartBuilder.d.ts.map +1 -1
  64. package/dist/esm/ChartBuilder.js +18 -9
  65. package/dist/esm/ChartEditor.js +1 -1
  66. package/dist/esm/Context.d.ts +22 -39
  67. package/dist/esm/Context.d.ts.map +1 -1
  68. package/dist/esm/Context.js +11 -9
  69. package/dist/esm/Dashboard.d.ts +116 -26
  70. package/dist/esm/Dashboard.d.ts.map +1 -1
  71. package/dist/esm/Dashboard.js +89 -376
  72. package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
  73. package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
  74. package/dist/esm/DateRangePicker/dateRangePickerUtils.js +9 -9
  75. package/dist/esm/SQLEditor.d.ts.map +1 -1
  76. package/dist/esm/SQLEditor.js +2 -4
  77. package/dist/esm/Table.d.ts.map +1 -1
  78. package/dist/esm/Table.js +12 -2
  79. package/dist/esm/components/Chart/BarChart.d.ts +2 -2
  80. package/dist/esm/components/Chart/BarChart.js +2 -2
  81. package/dist/esm/components/Chart/ChartError.d.ts +3 -0
  82. package/dist/esm/components/Chart/ChartError.d.ts.map +1 -0
  83. package/dist/esm/components/Chart/ChartError.js +26 -0
  84. package/dist/esm/components/Chart/ChartSkeleton.d.ts +3 -0
  85. package/dist/esm/components/Chart/ChartSkeleton.d.ts.map +1 -0
  86. package/dist/esm/components/Chart/ChartSkeleton.js +17 -0
  87. package/dist/esm/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
  88. package/dist/esm/components/Chart/ChartTooltipFrame.js +1 -0
  89. package/dist/esm/components/Chart/LineChart.d.ts +2 -2
  90. package/dist/esm/components/Chart/LineChart.js +2 -2
  91. package/dist/esm/components/Dashboard/DashboardGroup.d.ts +3 -0
  92. package/dist/esm/components/Dashboard/DashboardGroup.d.ts.map +1 -0
  93. package/dist/esm/components/Dashboard/DashboardGroup.js +13 -0
  94. package/dist/esm/components/Dashboard/DashboardItem.d.ts +3 -0
  95. package/dist/esm/components/Dashboard/DashboardItem.d.ts.map +1 -0
  96. package/dist/esm/components/Dashboard/DashboardItem.js +61 -0
  97. package/dist/esm/components/Dashboard/DashboardSection.d.ts +3 -0
  98. package/dist/esm/components/Dashboard/DashboardSection.d.ts.map +1 -0
  99. package/dist/esm/components/Dashboard/DashboardSection.js +4 -0
  100. package/dist/esm/hooks/useQuill.d.ts.map +1 -1
  101. package/dist/esm/hooks/useQuill.js +16 -10
  102. package/dist/esm/index.d.ts +1 -1
  103. package/dist/esm/index.d.ts.map +1 -1
  104. package/dist/esm/index.js +1 -1
  105. package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -1
  106. package/dist/esm/internals/ReportBuilder/PivotModal.js +1 -1
  107. package/dist/esm/utils/axisFormatter.d.ts.map +1 -1
  108. package/dist/esm/utils/axisFormatter.js +7 -18
  109. package/dist/esm/utils/dashboard.d.ts +12 -0
  110. package/dist/esm/utils/dashboard.d.ts.map +1 -0
  111. package/dist/esm/utils/dashboard.js +146 -0
  112. package/dist/esm/utils/styles.d.ts +17 -0
  113. package/dist/esm/utils/styles.d.ts.map +1 -0
  114. package/dist/esm/utils/styles.js +16 -0
  115. package/dist/esm/utils/valueFormatter.d.ts +1 -1
  116. package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
  117. package/dist/esm/utils/valueFormatter.js +7 -18
  118. package/dist/esm/utils/valueFormatterCSV.d.ts.map +1 -1
  119. package/dist/esm/utils/valueFormatterCSV.js +7 -15
  120. package/package.json +2 -5
@@ -1,36 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
28
5
  Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.QuillDateRangePicker = exports.DashboardFilter = exports.PRIMARY_OPTIONS = exports.COMPARISON_OPTIONS = void 0;
30
7
  const jsx_runtime_1 = require("react/jsx-runtime");
31
- // @ts-nocheck
32
- /* eslint-disable @typescript-eslint/ban-ts-comment */
33
- const react_1 = __importStar(require("react"));
8
+ const react_1 = require("react");
34
9
  const Chart_1 = __importDefault(require("./Chart"));
35
10
  const dateRangePickerUtils_1 = require("./DateRangePicker/dateRangePickerUtils");
36
11
  const Context_1 = require("./Context");
@@ -39,6 +14,12 @@ const assets_1 = require("./assets");
39
14
  const hooks_1 = require("./hooks");
40
15
  const locale_1 = require("date-fns/locale");
41
16
  const useDashboard_1 = require("./hooks/useDashboard");
17
+ const crypto_1 = require("./utils/crypto");
18
+ const DashboardSection_1 = __importDefault(require("./components/Dashboard/DashboardSection"));
19
+ const DashboardItem_1 = __importDefault(require("./components/Dashboard/DashboardItem"));
20
+ const DashboardGroup_1 = __importDefault(require("./components/Dashboard/DashboardGroup"));
21
+ const styles_1 = require("./utils/styles");
22
+ const dashboard_1 = require("./utils/dashboard");
42
23
  exports.COMPARISON_OPTIONS = [
43
24
  {
44
25
  value: 'PREV_PERIOD',
@@ -98,7 +79,9 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
98
79
  setFilterValue(filter.selectedValue);
99
80
  }
100
81
  if (filter.filterType == 'date_range') {
101
- setDateFilter(FILTER_CODE_MAP[filter.selectedValue ? filter.selectedValue[2] : null]);
82
+ setDateFilter(filter.selectedValue
83
+ ? FILTER_CODE_MAP[filter.selectedValue[2]]
84
+ : null);
102
85
  if (filter?.comparisonRange?.value) {
103
86
  const newComparisonRange = exports.COMPARISON_OPTIONS.find((option) => {
104
87
  return option.value === filter.comparisonRange.value;
@@ -248,7 +231,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
248
231
  const isBetween = (date, startDate, endDate) => {
249
232
  return (0, date_fns_1.isAfter)(date, startDate) && (0, date_fns_1.isBefore)(date, endDate);
250
233
  };
251
- function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
234
+ function Calendar({ anchorDate, onClickDate, theme, localStartDate, localEndDate, }) {
252
235
  const firstDayOfDisplayedMonth = (0, date_fns_1.startOfMonth)(anchorDate);
253
236
  const lastDayOfDisplayedMonth = (0, date_fns_1.endOfMonth)(anchorDate);
254
237
  const weekdays = (0, dateRangePickerUtils_1.getWeekdays)(locale_1.enUS).map((dayName) => (0, dateRangePickerUtils_1.capitalize)(dayName, locale_1.enUS));
@@ -361,17 +344,9 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
361
344
  const [showModal, setShowModal] = (0, react_1.useState)(false);
362
345
  const modalRef = (0, react_1.useRef)(null);
363
346
  const parentRef = (0, react_1.useRef)(null);
364
- const handleOnChange = (0, react_1.useCallback)((event) => {
365
- onChangeDateRange(event.target.value);
366
- }, [onChangeDateRange]);
367
347
  const [anchorDate, setAnchorDate] = (0, react_1.useState)(null);
368
348
  const [localStartDate, setLocalStartDate] = (0, react_1.useState)(null);
369
349
  const [localEndDate, setLocalEndDate] = (0, react_1.useState)(null);
370
- // const firstDayOfFirstMonth = startOfMonth(value[0]);
371
- // const lastDayOfLastMonth = endOfMonth(value[1]);
372
- // const weekdays = getWeekdays(enUS).map(dayName =>
373
- // capitalize(dayName, locale)
374
- // );
375
350
  const prevMonthAnchor = (0, date_fns_1.subDays)((0, date_fns_1.startOfMonth)(anchorDate), 1);
376
351
  const onClickDate = (date) => {
377
352
  if (localStartDate && (0, date_fns_1.isBefore)(date, localStartDate)) {
@@ -553,11 +528,11 @@ const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptio
553
528
  }, children: [(0, jsx_runtime_1.jsx)(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), (0, jsx_runtime_1.jsx)(MemoizedDropdown, { options: presetOptions.map((option) => ({
554
529
  label: option.text,
555
530
  value: option.value,
556
- })), onChange: onChangePreset, value: preset })] })] }));
531
+ })), onChange: onChangePreset, value: preset, label: preset })] })] }));
557
532
  };
558
533
  exports.QuillDateRangePicker = QuillDateRangePicker;
559
- const MemoizedCalendarDropdown = react_1.default.memo(CalendarDropdown);
560
- const MemoizedDropdown = react_1.default.memo(QuillDropdownComponent);
534
+ const MemoizedCalendarDropdown = (0, react_1.memo)(CalendarDropdown);
535
+ const MemoizedDropdown = (0, react_1.memo)(QuillDropdownComponent);
561
536
  const areEqual = (prevProps, nextProps) => {
562
537
  // This function returns true if passing nextProps to render would return
563
538
  // the same result as passing prevProps to render, otherwise it returns false
@@ -566,19 +541,21 @@ const areEqual = (prevProps, nextProps) => {
566
541
  prevProps.dateRange[0] === nextProps.dateRange[0] &&
567
542
  prevProps.dateRange[1] === nextProps.dateRange[1]);
568
543
  };
569
- const MemoizedDateRangePicker = react_1.default.memo(exports.QuillDateRangePicker, areEqual);
544
+ const MemoizedDateRangePicker = (0, react_1.memo)(exports.QuillDateRangePicker, areEqual);
570
545
  const QuillEmptyDashboardComponent = () => (0, jsx_runtime_1.jsx)("div", {});
571
- function removeQuotes(str) {
572
- if (str.startsWith('"') && str.endsWith('"')) {
573
- return str.slice(1, -1);
574
- }
575
- else {
576
- return str;
577
- }
578
- }
579
- function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, dateRangeFilterDisabled = false, FilterDropdownComponent, EmptyDashboardComponent = QuillEmptyDashboardComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
546
+ const defaultChartContainerStyles = {
547
+ display: 'flex',
548
+ width: '100%',
549
+ minHeight: 300,
550
+ height: 300,
551
+ };
552
+ /**
553
+ * Quill Dashboard.
554
+ */
555
+ function Dashboard({ name, containerStyle, chartContainerStyle = defaultChartContainerStyles, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, dateRangeFilterDisabled = false, SelectComponent, EmptyDashboardComponent = QuillEmptyDashboardComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent = DashboardItem_1.default, DashboardSectionComponent = DashboardSection_1.default, DashboardGroupComponent = DashboardGroup_1.default, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, }) {
580
556
  const { dateFilter } = (0, Context_1.useDateFilter)();
581
- const { isLoading: isDataLoading, data, reload } = (0, useDashboard_1.useDashboard)(name);
557
+ const { dispatch } = (0, react_1.useContext)(Context_1.DashboardContext);
558
+ const { isLoading: isDataLoading, data, reload, } = (0, useDashboard_1.useDashboard)(name);
582
559
  const [dashboardSections, setDashboardSections] = (0, react_1.useState)(null);
583
560
  const { dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
584
561
  const [client] = (0, react_1.useContext)(Context_1.ClientContext);
@@ -597,12 +574,6 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
597
574
  (0, react_1.useEffect)(() => {
598
575
  reload();
599
576
  }, [name, client]);
600
- function hashCode(s) {
601
- return s.split('').reduce(function (a, b) {
602
- a = (a << 5) - a + b.charCodeAt(0);
603
- return a & a;
604
- }, 0);
605
- }
606
577
  const onDashboardDataChange = (resp) => {
607
578
  setDashboardSections(resp.sections);
608
579
  const bigFilterObj = {};
@@ -634,8 +605,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
634
605
  else {
635
606
  filter.comparison = false;
636
607
  }
637
- if (hashCode(JSON.stringify(dashboardFilters?.date_range ?? '')) !==
638
- hashCode(JSON.stringify(filter))) {
608
+ if ((0, crypto_1.hashCode)(JSON.stringify(dashboardFilters?.date_range ?? '')) !==
609
+ (0, crypto_1.hashCode)(JSON.stringify(filter))) {
639
610
  dashboardFiltersDispatch({
640
611
  type: 'ADD_DASHBOARD_FILTER',
641
612
  id: 'date_range',
@@ -653,8 +624,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
653
624
  bigFilterObj[filter.field] = processFilter(filter);
654
625
  });
655
626
  }
656
- if (hashCode(JSON.stringify(dashboardFilters)) !==
657
- hashCode(JSON.stringify(bigFilterObj))) {
627
+ if ((0, crypto_1.hashCode)(JSON.stringify(dashboardFilters)) !==
628
+ (0, crypto_1.hashCode)(JSON.stringify(bigFilterObj))) {
658
629
  dashboardFiltersDispatch({
659
630
  type: 'ADD_DASHBOARD_FILTERS',
660
631
  id: 'tons',
@@ -663,12 +634,18 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
663
634
  }
664
635
  };
665
636
  const handleOnClickDashboardItem = (elem) => {
666
- if (dashboard[elem._id]._id && onClickDashboardItem) {
637
+ if (dashboard[elem._id]?._id && onClickDashboardItem) {
667
638
  onClickDashboardItem(dashboard[elem._id]);
668
639
  }
669
640
  else if (onClickDashboardItem) {
641
+ dispatch({
642
+ type: 'UPDATE_DASHBOARD_ITEM',
643
+ id: elem._id,
644
+ data: { ...elem, filtersApplied: dashboardFilters },
645
+ });
670
646
  onClickDashboardItem({
671
647
  ...dashboard[elem._id],
648
+ _id: elem._id,
672
649
  error_id: elem._id,
673
650
  name: elem.name,
674
651
  query: elem.queryString,
@@ -687,6 +664,14 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
687
664
  },
688
665
  });
689
666
  };
667
+ function removeQuotes(str) {
668
+ if (str.startsWith('"') && str.endsWith('"')) {
669
+ return str.slice(1, -1);
670
+ }
671
+ else {
672
+ return str;
673
+ }
674
+ }
690
675
  const processFilter = (filter, value = null) => {
691
676
  //for dateObjects only, since values are arrays for dateObjects
692
677
  const { selectedValue: _, ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
@@ -774,7 +759,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
774
759
  options: options,
775
760
  comparison: true,
776
761
  comparisonRange: {
777
- startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.start,
762
+ startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)
763
+ ?.start,
778
764
  endDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.end,
779
765
  value: key,
780
766
  },
@@ -817,10 +803,28 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
817
803
  return null;
818
804
  if (!dashboardSections || Object.keys(dashboardSections).length == 0)
819
805
  return (0, jsx_runtime_1.jsx)(EmptyDashboardComponent, {});
806
+ const sortByOrdering = (a, b) => {
807
+ if (a.order === undefined && b.order === undefined)
808
+ return 0; // both items don't have the 'order' field
809
+ if (a.order === undefined)
810
+ return 1; // only 'a' doesn't have the 'order' field, place 'a' last
811
+ if (b.order === undefined)
812
+ return -1; // only 'b' doesn't have the 'order' field, place 'b' last
813
+ return a.order - b.order; // both items have the 'order' field, sort numerically
814
+ };
820
815
  const sortedFilters = Object.values(dashboardFilters)
821
816
  .sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
822
817
  .filter((f) => !dateRangeFilterDisabled || f.filterType !== 'date_range');
823
- return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyle, children: [!hideFilters && sortedFilters.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
818
+ const metrics = (section) => dashboardSections[section]
819
+ .filter(({ chartType }) => chartType === 'metric')
820
+ .sort(sortByOrdering);
821
+ const charts = (section) => dashboardSections[section]
822
+ .filter(({ chartType }) => !['metric', 'table'].includes(chartType))
823
+ .sort(sortByOrdering);
824
+ const tables = (section) => dashboardSections[section]
825
+ .filter(({ chartType }) => chartType === 'table')
826
+ .sort(sortByOrdering);
827
+ return ((0, jsx_runtime_1.jsxs)("div", { ...(0, styles_1.styleToProps)(containerStyle), children: [!hideFilters && ((0, jsx_runtime_1.jsx)("div", { style: {
824
828
  display: 'flex',
825
829
  boxSizing: 'content-box',
826
830
  flexDirection: 'row',
@@ -832,364 +836,50 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
832
836
  flexDirection: 'row',
833
837
  alignItems: 'center',
834
838
  gap: 12,
835
- }, children: sortedFilters.map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
836
- ? FilterDropdownComponent
837
- : MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
839
+ }, children: sortedFilters.map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: SelectComponent ? SelectComponent : MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
838
840
  ? DateRangePickerComponent
839
841
  : MemoizedDateRangePicker }, index))) }) })), Object.keys(dashboardSections)
840
842
  .sort(function (a, b) {
841
843
  return a.length - b.length;
842
844
  })
843
845
  .map((section, sectionIndex) => {
844
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
845
- width: '100%',
846
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && ((0, jsx_runtime_1.jsx)("h1", { style: {
846
+ return ((0, jsx_runtime_1.jsxs)(DashboardSectionComponent, { children: [section && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), (0, jsx_runtime_1.jsx)("h1", { style: {
847
847
  fontSize: 22,
848
848
  color: theme.primaryTextColor,
849
849
  fontFamily: theme.fontFamily,
850
850
  fontWeight: 'bold',
851
- // fontWeight: theme.headerFontWeight,
852
851
  marginBottom: 16,
853
- // marginLeft: 25,
854
852
  textAlign: 'left',
855
853
  marginTop: 12,
856
- }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
857
- boxSizing: 'content-box',
858
- width: `100%`,
859
- listStyleType: 'none',
860
- marginBottom: 50,
861
- display: 'grid',
862
- gridGap: 25,
863
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
864
- gridTemplateRows: `repeat(${170}px)`,
865
- }, children: dashboardSections[section]
866
- .filter((elem) => elem.chartType === 'metric')
867
- .sort((a, b) => {
868
- if (a.order === undefined && b.order === undefined)
869
- return 0; // both items don't have the 'order' field
870
- if (a.order === undefined)
871
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
872
- if (b.order === undefined)
873
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
874
- return a.order - b.order; // both items have the 'order' field, sort numerically
875
- })
876
- .map((elem, index) => {
877
- if (DashboardItemComponent) {
878
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
879
- ? () => handleOnClickDashboardItem(elem)
880
- : void null, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
881
- padding: 0,
882
- // height: '100%',
883
- boxSizing: 'content-box',
884
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
885
- display: 'flex',
886
- width: '100%',
887
- // height: '100%',
888
- }, chartId: elem._id, dateRangeFilterDisabled: dateRangeFilterDisabled, colors: theme.chartColors?.length
889
- ? theme.chartColors
890
- : undefined }) }) }) }, elem.name + '' + index));
891
- }
892
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
893
- ? () => handleOnClickDashboardItem(elem)
894
- : undefined, style: {
895
- // background: theme.elevatedCardColor,
896
- // borderRadius: theme.borderRadius,
897
- // boxShadow: theme.boxShadow,
898
- paddingTop: 12,
899
- boxSizing: 'content-box',
900
- borderRadius: 8,
901
- height: '100%',
902
- cursor: 'pointer',
903
- width: '100%',
904
- ...metricContainerStyle,
905
- }, children: (0, jsx_runtime_1.jsx)("div", {
906
- // className="group-hover:bg-black"
907
- style: {
854
+ }, children: section })] })), metrics(section).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardGroupComponent, { children: metrics(section).map((item, index) => {
855
+ (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: (0, dashboard_1.cleanDashboardItem)(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
856
+ ? () => handleOnClickDashboardItem(item)
857
+ : void null, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
858
+ display: 'flex',
908
859
  width: '100%',
909
- boxSizing: 'content-box',
910
- height: '100%',
911
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
912
- width: '100%',
913
- boxSizing: 'content-box',
914
- height: '100%',
915
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
916
- display: 'flex',
917
- flexDirection: 'column',
918
- justifyContent: 'space-between',
919
- boxSizing: 'content-box',
920
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
921
- // className="group-hover:bg-black"
922
- style: {
923
- display: 'flex',
924
- flexDirection: 'row',
925
- justifyContent: 'space-between',
926
- boxSizing: 'content-box',
927
- // alignItems: 'center',
928
- // paddingLeft: theme.padding,
929
- // paddingRight: 25,
930
- // paddingTop: theme.padding,
931
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
932
- fontFamily: theme.fontFamily,
933
- color: theme.primaryTextColor,
934
- boxSizing: 'content-box',
935
- // TODO: FIX SIZE
936
- fontSize: 18,
937
- // TODO: FIX WEIGHT
938
- fontWeight: '500',
939
- // fontSize: theme.headerFontSize,
940
- // color: theme.fontColor,
941
- // fontWeight: theme.headerFontWeight,
942
- textOverflow: 'ellipsis',
943
- // margin: 0,
944
- padding: 0,
945
- whiteSpace: 'nowrap',
946
- display: 'block',
947
- maxWidth: '100%',
948
- overflow: 'hidden',
949
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
950
- // className="hover:bg-black"
951
- style: {
952
- fontFamily: theme.fontFamily,
953
- boxSizing: 'content-box',
954
- color: theme.primaryTextColor,
955
- fontWeight: '500',
956
- fontSize: 14,
957
- minWidth: 14 * 7,
958
- // background: 'red',
959
- display: 'flex',
960
- alignItems: 'center',
961
- justifyContent: 'flex-end',
962
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: { padding: 0, paddingTop: 10 }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
963
- // display: 'flex',
964
- // width: '100%',
965
- // height: 30,
966
- // marginBottom: 50,
967
- // marginTop: 50,
968
- },
969
- // chartFilters={elem.chartFilters}
970
- dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
971
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
972
- listStyleType: 'none',
973
- display: 'grid',
974
- gridGap: 25,
975
- boxSizing: 'content-box',
976
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
977
- gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
978
- }, children: dashboardSections[section]
979
- .filter((elem) => elem.chartType !== 'metric' &&
980
- elem.chartType !== 'table')
981
- .sort((a, b) => {
982
- if (a.order === undefined && b.order === undefined)
983
- return 0; // both items don't have the 'order' field
984
- if (a.order === undefined)
985
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
986
- if (b.order === undefined)
987
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
988
- return a.order - b.order; // both items have the 'order' field, sort numerically
989
- })
990
- .map((elem, index) => {
991
- if (DashboardItemComponent) {
992
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
993
- ? () => handleOnClickDashboardItem(elem)
994
- : undefined, style: { height: rowHeight || 400 }, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
995
- display: 'flex',
996
- width: '100%',
997
- // height: '100%',
998
- minHeight: 300,
999
- height: 300,
1000
- // background: 'red',
1001
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1002
- ? theme.chartColors
1003
- : undefined }) }) }, elem.name + '' + index));
1004
- }
1005
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1006
- ? () => handleOnClickDashboardItem(elem)
1007
- : undefined, style: {
1008
- height: '100%',
1009
- cursor: 'pointer',
1010
- boxSizing: 'content-box',
1011
- paddingRight: 25,
1012
- minHeight: rowHeight || 400,
1013
- borderRadius: 8,
1014
- paddingTop: 20,
1015
- ...chartContainerStyle,
1016
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1017
- width: '100%',
1018
- height: '100%',
1019
- boxSizing: 'content-box',
1020
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1021
- width: '100%',
1022
- height: '100%',
1023
- boxSizing: 'content-box',
1024
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1025
- display: 'flex',
1026
- flexDirection: 'column',
1027
- justifyContent: 'space-between',
1028
- height: '100%',
1029
- boxSizing: 'content-box',
1030
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1031
- display: 'flex',
1032
- flexDirection: 'row',
1033
- justifyContent: 'space-between',
1034
- boxSizing: 'content-box',
1035
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1036
- fontFamily: theme.fontFamily,
1037
- color: theme.primaryTextColor,
1038
- boxSizing: 'content-box',
1039
- fontSize: 18,
1040
- fontWeight: '500',
1041
- textOverflow: 'ellipsis',
1042
- // marginLeft: 25,
1043
- padding: 0,
1044
- whiteSpace: 'nowrap',
1045
- display: 'block',
1046
- maxWidth: '100%',
1047
- overflow: 'hidden',
1048
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", { style: {
1049
- fontFamily: theme.fontFamily,
1050
- color: theme.primaryTextColor,
1051
- boxSizing: 'content-box',
1052
- fontWeight: '500',
1053
- fontSize: 14,
1054
- minWidth: 14 * 7,
1055
- display: 'flex',
1056
- alignItems: 'center',
1057
- justifyContent: 'flex-end',
1058
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: {
1059
- padding: 0,
1060
- height: '100%',
1061
- boxSizing: 'content-box',
1062
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1063
- display: 'flex',
1064
- width: '100%',
1065
- // TODO: fix fixed height
1066
- height: 300,
1067
- marginBottom: 50,
1068
- marginTop: 30,
1069
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1070
- ? theme.chartColors
1071
- : undefined }) })] }) }) }) }, elem.name + '' + index));
1072
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType === 'table').length ? ((0, jsx_runtime_1.jsxs)("div", { style: {
860
+ // height: '100%',
861
+ }, chartId: item._id, colors: theme.chartColors?.length
862
+ ? theme.chartColors
863
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index);
864
+ }) })), charts(section).length > 0 && ((0, jsx_runtime_1.jsx)(DashboardGroupComponent, { children: charts(section).map((item, index) => ((0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: (0, dashboard_1.cleanDashboardItem)(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
865
+ ? () => handleOnClickDashboardItem(item)
866
+ : void null, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: chartContainerStyle, chartId: item._id, colors: theme.chartColors?.length
867
+ ? theme.chartColors
868
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index))) })), tables(section).length > 0 && ((0, jsx_runtime_1.jsxs)("div", { style: {
1073
869
  boxSizing: 'content-box',
1074
870
  width: `100%`,
1075
871
  gap: 20,
1076
872
  display: 'flex',
1077
873
  flexDirection: 'column',
1078
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 0 } }), dashboardSections[section]
1079
- .filter((elem) => elem.chartType === 'table')
1080
- .sort((a, b) => {
1081
- if (a.order === undefined && b.order === undefined)
1082
- return 0; // both items don't have the 'order' field
1083
- if (a.order === undefined)
1084
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
1085
- if (b.order === undefined)
1086
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
1087
- return a.order - b.order; // both items have the 'order' field, sort numerically
1088
- })
1089
- .map((elem, index) => {
1090
- if (DashboardItemComponent) {
1091
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1092
- ? () => handleOnClickDashboardItem(elem)
1093
- : undefined, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
1094
- padding: 0,
1095
- height: '100%',
1096
- boxSizing: 'content-box',
1097
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1098
- display: 'flex',
1099
- width: '100%',
1100
- height: '100%',
1101
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1102
- ? theme.chartColors
1103
- : undefined }) }) }) }, elem.name + '' + index));
1104
- }
1105
- return ((0, jsx_runtime_1.jsxs)("div", { onClick: onClickDashboardItem
1106
- ? () => handleOnClickDashboardItem(elem)
1107
- : undefined, children: [(0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1108
- ? () => handleOnClickDashboardItem(elem)
1109
- : undefined, style: {
1110
- // background: theme.elevatedCardColor,
1111
- // borderRadius: theme.borderRadius,
1112
- // boxShadow: theme.boxShadow,
1113
- paddingTop: 12,
1114
- boxSizing: 'content-box',
1115
- borderRadius: 8,
1116
- // height: '100%',
1117
- cursor: 'pointer',
1118
- width: '100%',
1119
- minHeight: 420,
1120
- height: 420,
1121
- // ...metricContainerStyle,
1122
- }, children: (0, jsx_runtime_1.jsx)("div", {
1123
- // className="group-hover:bg-black"
1124
- style: {
1125
- width: '100%',
1126
- boxSizing: 'content-box',
1127
- height: '100%',
1128
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1129
- width: '100%',
1130
- boxSizing: 'content-box',
1131
- height: '100%',
1132
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1133
- display: 'flex',
1134
- flexDirection: 'column',
1135
- justifyContent: 'space-between',
1136
- boxSizing: 'content-box',
1137
- height: '100%',
1138
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
1139
- // className="group-hover:bg-black"
1140
- style: {
1141
- display: 'flex',
1142
- flexDirection: 'row',
1143
- justifyContent: 'space-between',
1144
- boxSizing: 'content-box',
1145
- // alignItems: 'center',
1146
- // paddingLeft: theme.padding,
1147
- paddingRight: 25,
1148
- // paddingTop: theme.padding,
1149
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
1150
- fontFamily: theme.fontFamily,
1151
- color: theme.primaryTextColor,
1152
- boxSizing: 'content-box',
1153
- // TODO: FIX SIZE
1154
- fontSize: 18,
1155
- // TODO: FIX WEIGHT
1156
- fontWeight: '500',
1157
- // fontSize: theme.headerFontSize,
1158
- // color: theme.fontColor,
1159
- // fontWeight: theme.headerFontWeight,
1160
- textOverflow: 'ellipsis',
1161
- // margin: 0,
1162
- // marginLeft: 25,
1163
- padding: 0,
1164
- whiteSpace: 'nowrap',
1165
- display: 'block',
1166
- maxWidth: '100%',
1167
- overflow: 'hidden',
1168
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
1169
- // className="hover:bg-black"
1170
- style: {
1171
- fontFamily: theme.fontFamily,
1172
- boxSizing: 'content-box',
1173
- color: theme.primaryTextColor,
1174
- fontWeight: '500',
1175
- fontSize: 14,
1176
- minWidth: 14 * 7,
1177
- // background: 'red',
1178
- display: 'flex',
1179
- alignItems: 'center',
1180
- justifyContent: 'flex-end',
1181
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsxs)("div", { style: {
1182
- padding: 0,
1183
- height: '400px',
1184
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1185
- // display: 'flex',
1186
- // width: '100%',
1187
- // height: 30,
1188
- // marginBottom: 50,
1189
- height: '100%',
1190
- // paddingLeft: 25,
1191
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), (0, jsx_runtime_1.jsx)("div", { style: { height: 40 } })] }, elem.name + '' + index));
1192
- })] })) : null, (0, jsx_runtime_1.jsx)("div", { style: { height: 40 } })] }, section + '' + sectionIndex));
874
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 0 } }), tables(section).map((item, index) => ((0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: (0, dashboard_1.cleanDashboardItem)(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
875
+ ? () => handleOnClickDashboardItem(item)
876
+ : void null, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
877
+ display: 'flex',
878
+ width: '100%',
879
+ height: '100%',
880
+ }, chartId: item._id, colors: theme.chartColors?.length
881
+ ? theme.chartColors
882
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index)))] }))] }, section + '' + sectionIndex));
1193
883
  })] }));
1194
884
  }
1195
885
  exports.default = Dashboard;