@quillsql/react 2.10.5 → 2.10.7

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 (84) 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 +11 -16
  4. package/dist/cjs/Context.d.ts +22 -39
  5. package/dist/cjs/Context.d.ts.map +1 -1
  6. package/dist/cjs/Context.js +11 -9
  7. package/dist/cjs/Dashboard.d.ts +117 -28
  8. package/dist/cjs/Dashboard.d.ts.map +1 -1
  9. package/dist/cjs/Dashboard.js +84 -411
  10. package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
  11. package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
  12. package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +8 -8
  13. package/dist/cjs/Table.d.ts.map +1 -1
  14. package/dist/cjs/Table.js +11 -1
  15. package/dist/cjs/components/Chart/BarChart.d.ts +2 -2
  16. package/dist/cjs/components/Chart/BarChart.js +2 -2
  17. package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
  18. package/dist/cjs/components/Chart/ChartTooltipFrame.js +1 -0
  19. package/dist/cjs/components/Chart/LineChart.d.ts +2 -2
  20. package/dist/cjs/components/Chart/LineChart.js +2 -2
  21. package/dist/cjs/components/Dashboard/DashboardGroup.d.ts +3 -0
  22. package/dist/cjs/components/Dashboard/DashboardGroup.d.ts.map +1 -0
  23. package/dist/cjs/components/Dashboard/DashboardGroup.js +16 -0
  24. package/dist/cjs/components/Dashboard/DashboardItem.d.ts +3 -0
  25. package/dist/cjs/components/Dashboard/DashboardItem.d.ts.map +1 -0
  26. package/dist/cjs/components/Dashboard/DashboardItem.js +64 -0
  27. package/dist/cjs/components/Dashboard/DashboardSection.d.ts +3 -0
  28. package/dist/cjs/components/Dashboard/DashboardSection.d.ts.map +1 -0
  29. package/dist/cjs/components/Dashboard/DashboardSection.js +7 -0
  30. package/dist/cjs/index.d.ts +1 -1
  31. package/dist/cjs/index.d.ts.map +1 -1
  32. package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -1
  33. package/dist/cjs/internals/ReportBuilder/PivotModal.js +1 -1
  34. package/dist/cjs/utils/dashboard.d.ts +12 -0
  35. package/dist/cjs/utils/dashboard.d.ts.map +1 -0
  36. package/dist/cjs/utils/dashboard.js +150 -0
  37. package/dist/cjs/utils/styles.d.ts +17 -0
  38. package/dist/cjs/utils/styles.d.ts.map +1 -0
  39. package/dist/cjs/utils/styles.js +20 -0
  40. package/dist/cjs/utils/valueFormatter.d.ts +1 -1
  41. package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
  42. package/dist/esm/Chart.d.ts +2 -2
  43. package/dist/esm/Chart.d.ts.map +1 -1
  44. package/dist/esm/Chart.js +11 -16
  45. package/dist/esm/Context.d.ts +22 -39
  46. package/dist/esm/Context.d.ts.map +1 -1
  47. package/dist/esm/Context.js +11 -9
  48. package/dist/esm/Dashboard.d.ts +117 -28
  49. package/dist/esm/Dashboard.d.ts.map +1 -1
  50. package/dist/esm/Dashboard.js +80 -384
  51. package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
  52. package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
  53. package/dist/esm/DateRangePicker/dateRangePickerUtils.js +8 -8
  54. package/dist/esm/Table.d.ts.map +1 -1
  55. package/dist/esm/Table.js +11 -1
  56. package/dist/esm/components/Chart/BarChart.d.ts +2 -2
  57. package/dist/esm/components/Chart/BarChart.js +2 -2
  58. package/dist/esm/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
  59. package/dist/esm/components/Chart/ChartTooltipFrame.js +1 -0
  60. package/dist/esm/components/Chart/LineChart.d.ts +2 -2
  61. package/dist/esm/components/Chart/LineChart.js +2 -2
  62. package/dist/esm/components/Dashboard/DashboardGroup.d.ts +3 -0
  63. package/dist/esm/components/Dashboard/DashboardGroup.d.ts.map +1 -0
  64. package/dist/esm/components/Dashboard/DashboardGroup.js +13 -0
  65. package/dist/esm/components/Dashboard/DashboardItem.d.ts +3 -0
  66. package/dist/esm/components/Dashboard/DashboardItem.d.ts.map +1 -0
  67. package/dist/esm/components/Dashboard/DashboardItem.js +61 -0
  68. package/dist/esm/components/Dashboard/DashboardSection.d.ts +3 -0
  69. package/dist/esm/components/Dashboard/DashboardSection.d.ts.map +1 -0
  70. package/dist/esm/components/Dashboard/DashboardSection.js +4 -0
  71. package/dist/esm/index.d.ts +1 -1
  72. package/dist/esm/index.d.ts.map +1 -1
  73. package/dist/esm/index.js +1 -1
  74. package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -1
  75. package/dist/esm/internals/ReportBuilder/PivotModal.js +1 -1
  76. package/dist/esm/utils/dashboard.d.ts +12 -0
  77. package/dist/esm/utils/dashboard.d.ts.map +1 -0
  78. package/dist/esm/utils/dashboard.js +146 -0
  79. package/dist/esm/utils/styles.d.ts +17 -0
  80. package/dist/esm/utils/styles.d.ts.map +1 -0
  81. package/dist/esm/utils/styles.js +16 -0
  82. package/dist/esm/utils/valueFormatter.d.ts +1 -1
  83. package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
  84. 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
- exports.QuillDateRangePicker = exports.DashboardFilter = exports.VIDEO_ELEPHANT_OPTIONS = exports.PRIMARY_OPTIONS = exports.COMPARISON_OPTIONS = void 0;
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',
@@ -71,16 +52,6 @@ exports.PRIMARY_OPTIONS = [
71
52
  { value: 'LAST_6_MONTHS', text: 'Last 6 months' },
72
53
  { value: 'ALL_TIME', text: 'All time' },
73
54
  ];
74
- exports.VIDEO_ELEPHANT_OPTIONS = [
75
- { value: 'DECEMBER_2023', text: 'This Week' },
76
- { value: 'NOVEMBER_2023', text: 'This Month' },
77
- { value: 'OCTOBER_2023', text: 'This year' },
78
- { value: 'SEPTEMBER_2023', text: 'Last 7 days' },
79
- { value: 'AUGUST_2023', text: 'Last 30 days' },
80
- { value: 'LAST_90_DAYS', text: 'Last 90 days' },
81
- { value: 'LAST_6_MONTHS', text: 'Last 6 months' },
82
- { value: 'ALL_TIME', text: 'All time' },
83
- ];
84
55
  const FILTER_CODE_MAP = {
85
56
  wk: 'This week',
86
57
  m: 'This month',
@@ -108,7 +79,9 @@ function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateRangePic
108
79
  setFilterValue(filter.selectedValue);
109
80
  }
110
81
  if (filter.filterType == 'date_range') {
111
- setDateFilter(FILTER_CODE_MAP[filter.selectedValue ? filter.selectedValue[2] : null]);
82
+ setDateFilter(filter.selectedValue
83
+ ? FILTER_CODE_MAP[filter.selectedValue[2]]
84
+ : null);
112
85
  if (filter?.comparisonRange?.value) {
113
86
  const newComparisonRange = exports.COMPARISON_OPTIONS.find((option) => {
114
87
  return option.value === filter.comparisonRange.value;
@@ -258,7 +231,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
258
231
  const isBetween = (date, startDate, endDate) => {
259
232
  return (0, date_fns_1.isAfter)(date, startDate) && (0, date_fns_1.isBefore)(date, endDate);
260
233
  };
261
- function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
234
+ function Calendar({ anchorDate, onClickDate, theme, localStartDate, localEndDate, }) {
262
235
  const firstDayOfDisplayedMonth = (0, date_fns_1.startOfMonth)(anchorDate);
263
236
  const lastDayOfDisplayedMonth = (0, date_fns_1.endOfMonth)(anchorDate);
264
237
  const weekdays = (0, dateRangePickerUtils_1.getWeekdays)(locale_1.enUS).map((dayName) => (0, dateRangePickerUtils_1.capitalize)(dayName, locale_1.enUS));
@@ -371,17 +344,9 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
371
344
  const [showModal, setShowModal] = (0, react_1.useState)(false);
372
345
  const modalRef = (0, react_1.useRef)(null);
373
346
  const parentRef = (0, react_1.useRef)(null);
374
- const handleOnChange = (0, react_1.useCallback)((event) => {
375
- onChangeDateRange(event.target.value);
376
- }, [onChangeDateRange]);
377
347
  const [anchorDate, setAnchorDate] = (0, react_1.useState)(null);
378
348
  const [localStartDate, setLocalStartDate] = (0, react_1.useState)(null);
379
349
  const [localEndDate, setLocalEndDate] = (0, react_1.useState)(null);
380
- // const firstDayOfFirstMonth = startOfMonth(value[0]);
381
- // const lastDayOfLastMonth = endOfMonth(value[1]);
382
- // const weekdays = getWeekdays(enUS).map(dayName =>
383
- // capitalize(dayName, locale)
384
- // );
385
350
  const prevMonthAnchor = (0, date_fns_1.subDays)((0, date_fns_1.startOfMonth)(anchorDate), 1);
386
351
  const onClickDate = (date) => {
387
352
  if (localStartDate && (0, date_fns_1.isBefore)(date, localStartDate)) {
@@ -566,8 +531,8 @@ const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, presetOptio
566
531
  })), onChange: onChangePreset, value: preset })] })] }));
567
532
  };
568
533
  exports.QuillDateRangePicker = QuillDateRangePicker;
569
- const MemoizedCalendarDropdown = react_1.default.memo(CalendarDropdown);
570
- const MemoizedDropdown = react_1.default.memo(QuillDropdownComponent);
534
+ const MemoizedCalendarDropdown = (0, react_1.memo)(CalendarDropdown);
535
+ const MemoizedDropdown = (0, react_1.memo)(QuillDropdownComponent);
571
536
  const areEqual = (prevProps, nextProps) => {
572
537
  // This function returns true if passing nextProps to render would return
573
538
  // the same result as passing prevProps to render, otherwise it returns false
@@ -576,20 +541,21 @@ const areEqual = (prevProps, nextProps) => {
576
541
  prevProps.dateRange[0] === nextProps.dateRange[0] &&
577
542
  prevProps.dateRange[1] === nextProps.dateRange[1]);
578
543
  };
579
- const MemoizedDateRangePicker = react_1.default.memo(exports.QuillDateRangePicker, areEqual);
544
+ const MemoizedDateRangePicker = (0, react_1.memo)(exports.QuillDateRangePicker, areEqual);
580
545
  const QuillEmptyDashboardComponent = () => (0, jsx_runtime_1.jsx)("div", {});
581
- function removeQuotes(str) {
582
- if (str.startsWith('"') && str.endsWith('"')) {
583
- return str.slice(1, -1);
584
- }
585
- else {
586
- return str;
587
- }
588
- }
589
- 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, }) {
590
556
  const { dateFilter } = (0, Context_1.useDateFilter)();
591
557
  const { dispatch } = (0, react_1.useContext)(Context_1.DashboardContext);
592
- const { isLoading: isDataLoading, data, reload } = (0, useDashboard_1.useDashboard)(name);
558
+ const { isLoading: isDataLoading, data, reload, } = (0, useDashboard_1.useDashboard)(name);
593
559
  const [dashboardSections, setDashboardSections] = (0, react_1.useState)(null);
594
560
  const { dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
595
561
  const [client] = (0, react_1.useContext)(Context_1.ClientContext);
@@ -608,12 +574,6 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
608
574
  (0, react_1.useEffect)(() => {
609
575
  reload();
610
576
  }, [name, client]);
611
- function hashCode(s) {
612
- return s.split('').reduce(function (a, b) {
613
- a = (a << 5) - a + b.charCodeAt(0);
614
- return a & a;
615
- }, 0);
616
- }
617
577
  const onDashboardDataChange = (resp) => {
618
578
  setDashboardSections(resp.sections);
619
579
  const bigFilterObj = {};
@@ -645,8 +605,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
645
605
  else {
646
606
  filter.comparison = false;
647
607
  }
648
- if (hashCode(JSON.stringify(dashboardFilters?.date_range ?? '')) !==
649
- hashCode(JSON.stringify(filter))) {
608
+ if ((0, crypto_1.hashCode)(JSON.stringify(dashboardFilters?.date_range ?? '')) !==
609
+ (0, crypto_1.hashCode)(JSON.stringify(filter))) {
650
610
  dashboardFiltersDispatch({
651
611
  type: 'ADD_DASHBOARD_FILTER',
652
612
  id: 'date_range',
@@ -664,8 +624,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
664
624
  bigFilterObj[filter.field] = processFilter(filter);
665
625
  });
666
626
  }
667
- if (hashCode(JSON.stringify(dashboardFilters)) !==
668
- hashCode(JSON.stringify(bigFilterObj))) {
627
+ if ((0, crypto_1.hashCode)(JSON.stringify(dashboardFilters)) !==
628
+ (0, crypto_1.hashCode)(JSON.stringify(bigFilterObj))) {
669
629
  dashboardFiltersDispatch({
670
630
  type: 'ADD_DASHBOARD_FILTERS',
671
631
  id: 'tons',
@@ -704,6 +664,14 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
704
664
  },
705
665
  });
706
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
+ }
707
675
  const processFilter = (filter, value = null) => {
708
676
  //for dateObjects only, since values are arrays for dateObjects
709
677
  const { selectedValue: _, ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
@@ -791,7 +759,8 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
791
759
  options: options,
792
760
  comparison: true,
793
761
  comparisonRange: {
794
- startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.start,
762
+ startDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)
763
+ ?.start,
795
764
  endDate: dateRangePickerUtils_1.COMPARISON_RANGE[key](primaryRange)?.end,
796
765
  value: key,
797
766
  },
@@ -834,10 +803,28 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
834
803
  return null;
835
804
  if (!dashboardSections || Object.keys(dashboardSections).length == 0)
836
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
+ };
837
815
  const sortedFilters = Object.values(dashboardFilters)
838
816
  .sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
839
817
  .filter((f) => !dateRangeFilterDisabled || f.filterType !== 'date_range');
840
- 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: {
841
828
  display: 'flex',
842
829
  boxSizing: 'content-box',
843
830
  flexDirection: 'row',
@@ -849,364 +836,50 @@ function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerS
849
836
  flexDirection: 'row',
850
837
  alignItems: 'center',
851
838
  gap: 12,
852
- }, children: sortedFilters.map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
853
- ? FilterDropdownComponent
854
- : 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
855
840
  ? DateRangePickerComponent
856
841
  : MemoizedDateRangePicker }, index))) }) })), Object.keys(dashboardSections)
857
842
  .sort(function (a, b) {
858
843
  return a.length - b.length;
859
844
  })
860
845
  .map((section, sectionIndex) => {
861
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
862
- width: '100%',
863
- }, 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: {
864
847
  fontSize: 22,
865
848
  color: theme.primaryTextColor,
866
849
  fontFamily: theme.fontFamily,
867
850
  fontWeight: 'bold',
868
- // fontWeight: theme.headerFontWeight,
869
851
  marginBottom: 16,
870
- // marginLeft: 25,
871
852
  textAlign: 'left',
872
853
  marginTop: 12,
873
- }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
874
- boxSizing: 'content-box',
875
- width: `100%`,
876
- listStyleType: 'none',
877
- marginBottom: 50,
878
- display: 'grid',
879
- gridGap: 25,
880
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
881
- gridTemplateRows: `repeat(${170}px)`,
882
- }, children: dashboardSections[section]
883
- .filter((elem) => elem.chartType === 'metric')
884
- .sort((a, b) => {
885
- if (a.order === undefined && b.order === undefined)
886
- return 0; // both items don't have the 'order' field
887
- if (a.order === undefined)
888
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
889
- if (b.order === undefined)
890
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
891
- return a.order - b.order; // both items have the 'order' field, sort numerically
892
- })
893
- .map((elem, index) => {
894
- if (DashboardItemComponent) {
895
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
896
- ? () => handleOnClickDashboardItem(elem)
897
- : void null, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
898
- padding: 0,
899
- // height: '100%',
900
- boxSizing: 'content-box',
901
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
902
- display: 'flex',
903
- width: '100%',
904
- // height: '100%',
905
- }, chartId: elem._id, dateRangeFilterDisabled: dateRangeFilterDisabled, colors: theme.chartColors?.length
906
- ? theme.chartColors
907
- : undefined }) }) }) }, elem.name + '' + index));
908
- }
909
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
910
- ? () => handleOnClickDashboardItem(elem)
911
- : undefined, style: {
912
- // background: theme.elevatedCardColor,
913
- // borderRadius: theme.borderRadius,
914
- // boxShadow: theme.boxShadow,
915
- paddingTop: 12,
916
- boxSizing: 'content-box',
917
- borderRadius: 8,
918
- height: '100%',
919
- cursor: 'pointer',
920
- width: '100%',
921
- ...metricContainerStyle,
922
- }, children: (0, jsx_runtime_1.jsx)("div", {
923
- // className="group-hover:bg-black"
924
- 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',
925
859
  width: '100%',
926
- boxSizing: 'content-box',
927
- height: '100%',
928
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
929
- width: '100%',
930
- boxSizing: 'content-box',
931
- height: '100%',
932
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
933
- display: 'flex',
934
- flexDirection: 'column',
935
- justifyContent: 'space-between',
936
- boxSizing: 'content-box',
937
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
938
- // className="group-hover:bg-black"
939
- style: {
940
- display: 'flex',
941
- flexDirection: 'row',
942
- justifyContent: 'space-between',
943
- boxSizing: 'content-box',
944
- // alignItems: 'center',
945
- // paddingLeft: theme.padding,
946
- // paddingRight: 25,
947
- // paddingTop: theme.padding,
948
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
949
- fontFamily: theme.fontFamily,
950
- color: theme.primaryTextColor,
951
- boxSizing: 'content-box',
952
- // TODO: FIX SIZE
953
- fontSize: 18,
954
- // TODO: FIX WEIGHT
955
- fontWeight: '500',
956
- // fontSize: theme.headerFontSize,
957
- // color: theme.fontColor,
958
- // fontWeight: theme.headerFontWeight,
959
- textOverflow: 'ellipsis',
960
- // margin: 0,
961
- padding: 0,
962
- whiteSpace: 'nowrap',
963
- display: 'block',
964
- maxWidth: '100%',
965
- overflow: 'hidden',
966
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
967
- // className="hover:bg-black"
968
- style: {
969
- fontFamily: theme.fontFamily,
970
- boxSizing: 'content-box',
971
- color: theme.primaryTextColor,
972
- fontWeight: '500',
973
- fontSize: 14,
974
- minWidth: 14 * 7,
975
- // background: 'red',
976
- display: 'flex',
977
- alignItems: 'center',
978
- justifyContent: 'flex-end',
979
- }, 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: {
980
- // display: 'flex',
981
- // width: '100%',
982
- // height: 30,
983
- // marginBottom: 50,
984
- // marginTop: 50,
985
- },
986
- // chartFilters={elem.chartFilters}
987
- dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
988
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? ((0, jsx_runtime_1.jsx)("div", { style: {
989
- listStyleType: 'none',
990
- display: 'grid',
991
- gridGap: 25,
992
- boxSizing: 'content-box',
993
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
994
- gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
995
- }, children: dashboardSections[section]
996
- .filter((elem) => elem.chartType !== 'metric' &&
997
- elem.chartType !== 'table')
998
- .sort((a, b) => {
999
- if (a.order === undefined && b.order === undefined)
1000
- return 0; // both items don't have the 'order' field
1001
- if (a.order === undefined)
1002
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
1003
- if (b.order === undefined)
1004
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
1005
- return a.order - b.order; // both items have the 'order' field, sort numerically
1006
- })
1007
- .map((elem, index) => {
1008
- if (DashboardItemComponent) {
1009
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1010
- ? () => handleOnClickDashboardItem(elem)
1011
- : undefined, style: { height: rowHeight || 400 }, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1012
- display: 'flex',
1013
- width: '100%',
1014
- // height: '100%',
1015
- minHeight: 300,
1016
- height: 300,
1017
- // background: 'red',
1018
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1019
- ? theme.chartColors
1020
- : undefined }) }) }, elem.name + '' + index));
1021
- }
1022
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1023
- ? () => handleOnClickDashboardItem(elem)
1024
- : undefined, style: {
1025
- height: '100%',
1026
- cursor: 'pointer',
1027
- boxSizing: 'content-box',
1028
- paddingRight: 25,
1029
- minHeight: rowHeight || 400,
1030
- borderRadius: 8,
1031
- paddingTop: 20,
1032
- ...chartContainerStyle,
1033
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1034
- width: '100%',
1035
- height: '100%',
1036
- boxSizing: 'content-box',
1037
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1038
- width: '100%',
1039
- height: '100%',
1040
- boxSizing: 'content-box',
1041
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1042
- display: 'flex',
1043
- flexDirection: 'column',
1044
- justifyContent: 'space-between',
1045
- height: '100%',
1046
- boxSizing: 'content-box',
1047
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1048
- display: 'flex',
1049
- flexDirection: 'row',
1050
- justifyContent: 'space-between',
1051
- boxSizing: 'content-box',
1052
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1053
- fontFamily: theme.fontFamily,
1054
- color: theme.primaryTextColor,
1055
- boxSizing: 'content-box',
1056
- fontSize: 18,
1057
- fontWeight: '500',
1058
- textOverflow: 'ellipsis',
1059
- // marginLeft: 25,
1060
- padding: 0,
1061
- whiteSpace: 'nowrap',
1062
- display: 'block',
1063
- maxWidth: '100%',
1064
- overflow: 'hidden',
1065
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", { style: {
1066
- fontFamily: theme.fontFamily,
1067
- color: theme.primaryTextColor,
1068
- boxSizing: 'content-box',
1069
- fontWeight: '500',
1070
- fontSize: 14,
1071
- minWidth: 14 * 7,
1072
- display: 'flex',
1073
- alignItems: 'center',
1074
- justifyContent: 'flex-end',
1075
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsx)("div", { style: {
1076
- padding: 0,
1077
- height: '100%',
1078
- boxSizing: 'content-box',
1079
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1080
- display: 'flex',
1081
- width: '100%',
1082
- // TODO: fix fixed height
1083
- height: 300,
1084
- marginBottom: 50,
1085
- marginTop: 30,
1086
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1087
- ? theme.chartColors
1088
- : undefined }) })] }) }) }) }, elem.name + '' + index));
1089
- }) })) : 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: {
1090
869
  boxSizing: 'content-box',
1091
870
  width: `100%`,
1092
871
  gap: 20,
1093
872
  display: 'flex',
1094
873
  flexDirection: 'column',
1095
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 0 } }), dashboardSections[section]
1096
- .filter((elem) => elem.chartType === 'table')
1097
- .sort((a, b) => {
1098
- if (a.order === undefined && b.order === undefined)
1099
- return 0; // both items don't have the 'order' field
1100
- if (a.order === undefined)
1101
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
1102
- if (b.order === undefined)
1103
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
1104
- return a.order - b.order; // both items have the 'order' field, sort numerically
1105
- })
1106
- .map((elem, index) => {
1107
- if (DashboardItemComponent) {
1108
- return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1109
- ? () => handleOnClickDashboardItem(elem)
1110
- : undefined, children: (0, jsx_runtime_1.jsx)(DashboardItemComponent, { dashboardItem: elem, children: (0, jsx_runtime_1.jsx)("div", { style: {
1111
- padding: 0,
1112
- height: '100%',
1113
- boxSizing: 'content-box',
1114
- }, children: (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1115
- display: 'flex',
1116
- width: '100%',
1117
- height: '100%',
1118
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1119
- ? theme.chartColors
1120
- : undefined }) }) }) }, elem.name + '' + index));
1121
- }
1122
- return ((0, jsx_runtime_1.jsxs)("div", { onClick: onClickDashboardItem
1123
- ? () => handleOnClickDashboardItem(elem)
1124
- : undefined, children: [(0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
1125
- ? () => handleOnClickDashboardItem(elem)
1126
- : undefined, style: {
1127
- // background: theme.elevatedCardColor,
1128
- // borderRadius: theme.borderRadius,
1129
- // boxShadow: theme.boxShadow,
1130
- paddingTop: 12,
1131
- boxSizing: 'content-box',
1132
- borderRadius: 8,
1133
- // height: '100%',
1134
- cursor: 'pointer',
1135
- width: '100%',
1136
- minHeight: 420,
1137
- height: 420,
1138
- // ...metricContainerStyle,
1139
- }, children: (0, jsx_runtime_1.jsx)("div", {
1140
- // className="group-hover:bg-black"
1141
- style: {
1142
- width: '100%',
1143
- boxSizing: 'content-box',
1144
- height: '100%',
1145
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
1146
- width: '100%',
1147
- boxSizing: 'content-box',
1148
- height: '100%',
1149
- }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1150
- display: 'flex',
1151
- flexDirection: 'column',
1152
- justifyContent: 'space-between',
1153
- boxSizing: 'content-box',
1154
- height: '100%',
1155
- }, children: [(0, jsx_runtime_1.jsxs)("div", {
1156
- // className="group-hover:bg-black"
1157
- style: {
1158
- display: 'flex',
1159
- flexDirection: 'row',
1160
- justifyContent: 'space-between',
1161
- boxSizing: 'content-box',
1162
- // alignItems: 'center',
1163
- // paddingLeft: theme.padding,
1164
- paddingRight: 25,
1165
- // paddingTop: theme.padding,
1166
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.name, style: {
1167
- fontFamily: theme.fontFamily,
1168
- color: theme.primaryTextColor,
1169
- boxSizing: 'content-box',
1170
- // TODO: FIX SIZE
1171
- fontSize: 18,
1172
- // TODO: FIX WEIGHT
1173
- fontWeight: '500',
1174
- // fontSize: theme.headerFontSize,
1175
- // color: theme.fontColor,
1176
- // fontWeight: theme.headerFontWeight,
1177
- textOverflow: 'ellipsis',
1178
- // margin: 0,
1179
- // marginLeft: 25,
1180
- padding: 0,
1181
- whiteSpace: 'nowrap',
1182
- display: 'block',
1183
- maxWidth: '100%',
1184
- overflow: 'hidden',
1185
- }, children: elem.name }), onClickDashboardItem ? ((0, jsx_runtime_1.jsx)("div", {
1186
- // className="hover:bg-black"
1187
- style: {
1188
- fontFamily: theme.fontFamily,
1189
- boxSizing: 'content-box',
1190
- color: theme.primaryTextColor,
1191
- fontWeight: '500',
1192
- fontSize: 14,
1193
- minWidth: 14 * 7,
1194
- // background: 'red',
1195
- display: 'flex',
1196
- alignItems: 'center',
1197
- justifyContent: 'flex-end',
1198
- }, children: 'view report →' })) : null] }), (0, jsx_runtime_1.jsxs)("div", { style: {
1199
- padding: 0,
1200
- height: '400px',
1201
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)(Chart_1.default, { containerStyle: {
1202
- // display: 'flex',
1203
- // width: '100%',
1204
- // height: 30,
1205
- // marginBottom: 50,
1206
- height: '100%',
1207
- // paddingLeft: 25,
1208
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), (0, jsx_runtime_1.jsx)("div", { style: { height: 40 } })] }, elem.name + '' + index));
1209
- })] })) : 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));
1210
883
  })] }));
1211
884
  }
1212
885
  exports.default = Dashboard;