@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,15 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // @ts-nocheck
3
- /* eslint-disable @typescript-eslint/ban-ts-comment */
4
- import React, { useContext, useEffect, useState, useRef, useCallback, } from 'react';
2
+ import { useContext, useEffect, useState, useRef, useCallback, memo, } from 'react';
5
3
  import Chart from './Chart';
6
4
  import { capitalize, defaultOptions, getWeekdays, getRangeFromPreset, PRIMARY_RANGE, COMPARISON_RANGE, PRIMARY_CODES, } from './DateRangePicker/dateRangePickerUtils';
7
5
  import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, DateFilterContext, useComparisonRange, useDateFilter, } from './Context';
8
6
  import { addDays, eachDayOfInterval, endOfMonth, format, isAfter, isBefore, isEqual, isSaturday, isSunday, nextSaturday, previousSunday, startOfMonth, startOfToday, startOfWeek, startOfYear, sub, subDays, } from 'date-fns';
9
7
  import { ArrowDownHeadIcon, ArrowLeftHeadIcon, ArrowRightHeadIcon, CalendarNormalIcon, } from './assets';
10
- import { useOnClickOutside, } from './hooks';
8
+ import { useOnClickOutside } from './hooks';
11
9
  import { enUS } from 'date-fns/locale';
12
10
  import { useDashboard } from './hooks/useDashboard';
11
+ import { hashCode } from './utils/crypto';
12
+ import DashboardSection from './components/Dashboard/DashboardSection';
13
+ import DashboardItem from './components/Dashboard/DashboardItem';
14
+ import DashboardGroup from './components/Dashboard/DashboardGroup';
15
+ import { styleToProps } from './utils/styles';
16
+ import { cleanDashboardItem } from './utils/dashboard';
13
17
  export const COMPARISON_OPTIONS = [
14
18
  {
15
19
  value: 'PREV_PERIOD',
@@ -69,7 +73,9 @@ export function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateR
69
73
  setFilterValue(filter.selectedValue);
70
74
  }
71
75
  if (filter.filterType == 'date_range') {
72
- setDateFilter(FILTER_CODE_MAP[filter.selectedValue ? filter.selectedValue[2] : null]);
76
+ setDateFilter(filter.selectedValue
77
+ ? FILTER_CODE_MAP[filter.selectedValue[2]]
78
+ : null);
73
79
  if (filter?.comparisonRange?.value) {
74
80
  const newComparisonRange = COMPARISON_OPTIONS.find((option) => {
75
81
  return option.value === filter.comparisonRange.value;
@@ -218,7 +224,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
218
224
  const isBetween = (date, startDate, endDate) => {
219
225
  return isAfter(date, startDate) && isBefore(date, endDate);
220
226
  };
221
- function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
227
+ function Calendar({ anchorDate, onClickDate, theme, localStartDate, localEndDate, }) {
222
228
  const firstDayOfDisplayedMonth = startOfMonth(anchorDate);
223
229
  const lastDayOfDisplayedMonth = endOfMonth(anchorDate);
224
230
  const weekdays = getWeekdays(enUS).map((dayName) => capitalize(dayName, enUS));
@@ -331,17 +337,9 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
331
337
  const [showModal, setShowModal] = useState(false);
332
338
  const modalRef = useRef(null);
333
339
  const parentRef = useRef(null);
334
- const handleOnChange = useCallback((event) => {
335
- onChangeDateRange(event.target.value);
336
- }, [onChangeDateRange]);
337
340
  const [anchorDate, setAnchorDate] = useState(null);
338
341
  const [localStartDate, setLocalStartDate] = useState(null);
339
342
  const [localEndDate, setLocalEndDate] = useState(null);
340
- // const firstDayOfFirstMonth = startOfMonth(value[0]);
341
- // const lastDayOfLastMonth = endOfMonth(value[1]);
342
- // const weekdays = getWeekdays(enUS).map(dayName =>
343
- // capitalize(dayName, locale)
344
- // );
345
343
  const prevMonthAnchor = subDays(startOfMonth(anchorDate), 1);
346
344
  const onClickDate = (date) => {
347
345
  if (localStartDate && isBefore(date, localStartDate)) {
@@ -523,10 +521,10 @@ export const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, pres
523
521
  }, children: [_jsx(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), _jsx(MemoizedDropdown, { options: presetOptions.map((option) => ({
524
522
  label: option.text,
525
523
  value: option.value,
526
- })), onChange: onChangePreset, value: preset })] })] }));
524
+ })), onChange: onChangePreset, value: preset, label: preset })] })] }));
527
525
  };
528
- const MemoizedCalendarDropdown = React.memo(CalendarDropdown);
529
- const MemoizedDropdown = React.memo(QuillDropdownComponent);
526
+ const MemoizedCalendarDropdown = memo(CalendarDropdown);
527
+ const MemoizedDropdown = memo(QuillDropdownComponent);
530
528
  const areEqual = (prevProps, nextProps) => {
531
529
  // This function returns true if passing nextProps to render would return
532
530
  // the same result as passing prevProps to render, otherwise it returns false
@@ -535,19 +533,21 @@ const areEqual = (prevProps, nextProps) => {
535
533
  prevProps.dateRange[0] === nextProps.dateRange[0] &&
536
534
  prevProps.dateRange[1] === nextProps.dateRange[1]);
537
535
  };
538
- const MemoizedDateRangePicker = React.memo(QuillDateRangePicker, areEqual);
536
+ const MemoizedDateRangePicker = memo(QuillDateRangePicker, areEqual);
539
537
  const QuillEmptyDashboardComponent = () => _jsx("div", {});
540
- function removeQuotes(str) {
541
- if (str.startsWith('"') && str.endsWith('"')) {
542
- return str.slice(1, -1);
543
- }
544
- else {
545
- return str;
546
- }
547
- }
548
- export default function Dashboard({ name, containerStyle, chartContainerStyle, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, dateRangeFilterDisabled = false, FilterDropdownComponent, EmptyDashboardComponent = QuillEmptyDashboardComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent, }) {
538
+ const defaultChartContainerStyles = {
539
+ display: 'flex',
540
+ width: '100%',
541
+ minHeight: 300,
542
+ height: 300,
543
+ };
544
+ /**
545
+ * Quill Dashboard.
546
+ */
547
+ export default function Dashboard({ name, containerStyle, chartContainerStyle = defaultChartContainerStyles, metricContainerStyle, maxColumnWidth, rowHeight, onClickDashboardItem, hideFilters, dateRangeFilterDisabled = false, SelectComponent, EmptyDashboardComponent = QuillEmptyDashboardComponent, DateRangePickerComponent, FilterButtonComponent, FilterModalComponent, onChangeLoading, DashboardItemComponent = DashboardItem, DashboardSectionComponent = DashboardSection, DashboardGroupComponent = DashboardGroup, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, }) {
549
548
  const { dateFilter } = useDateFilter();
550
- const { isLoading: isDataLoading, data, reload } = useDashboard(name);
549
+ const { dispatch } = useContext(DashboardContext);
550
+ const { isLoading: isDataLoading, data, reload, } = useDashboard(name);
551
551
  const [dashboardSections, setDashboardSections] = useState(null);
552
552
  const { dashboard } = useContext(DashboardContext);
553
553
  const [client] = useContext(ClientContext);
@@ -566,12 +566,6 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
566
566
  useEffect(() => {
567
567
  reload();
568
568
  }, [name, client]);
569
- function hashCode(s) {
570
- return s.split('').reduce(function (a, b) {
571
- a = (a << 5) - a + b.charCodeAt(0);
572
- return a & a;
573
- }, 0);
574
- }
575
569
  const onDashboardDataChange = (resp) => {
576
570
  setDashboardSections(resp.sections);
577
571
  const bigFilterObj = {};
@@ -632,12 +626,18 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
632
626
  }
633
627
  };
634
628
  const handleOnClickDashboardItem = (elem) => {
635
- if (dashboard[elem._id]._id && onClickDashboardItem) {
629
+ if (dashboard[elem._id]?._id && onClickDashboardItem) {
636
630
  onClickDashboardItem(dashboard[elem._id]);
637
631
  }
638
632
  else if (onClickDashboardItem) {
633
+ dispatch({
634
+ type: 'UPDATE_DASHBOARD_ITEM',
635
+ id: elem._id,
636
+ data: { ...elem, filtersApplied: dashboardFilters },
637
+ });
639
638
  onClickDashboardItem({
640
639
  ...dashboard[elem._id],
640
+ _id: elem._id,
641
641
  error_id: elem._id,
642
642
  name: elem.name,
643
643
  query: elem.queryString,
@@ -656,6 +656,14 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
656
656
  },
657
657
  });
658
658
  };
659
+ function removeQuotes(str) {
660
+ if (str.startsWith('"') && str.endsWith('"')) {
661
+ return str.slice(1, -1);
662
+ }
663
+ else {
664
+ return str;
665
+ }
666
+ }
659
667
  const processFilter = (filter, value = null) => {
660
668
  //for dateObjects only, since values are arrays for dateObjects
661
669
  const { selectedValue: _, ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
@@ -743,7 +751,8 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
743
751
  options: options,
744
752
  comparison: true,
745
753
  comparisonRange: {
746
- startDate: COMPARISON_RANGE[key](primaryRange)?.start,
754
+ startDate: COMPARISON_RANGE[key](primaryRange)
755
+ ?.start,
747
756
  endDate: COMPARISON_RANGE[key](primaryRange)?.end,
748
757
  value: key,
749
758
  },
@@ -786,10 +795,28 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
786
795
  return null;
787
796
  if (!dashboardSections || Object.keys(dashboardSections).length == 0)
788
797
  return _jsx(EmptyDashboardComponent, {});
798
+ const sortByOrdering = (a, b) => {
799
+ if (a.order === undefined && b.order === undefined)
800
+ return 0; // both items don't have the 'order' field
801
+ if (a.order === undefined)
802
+ return 1; // only 'a' doesn't have the 'order' field, place 'a' last
803
+ if (b.order === undefined)
804
+ return -1; // only 'b' doesn't have the 'order' field, place 'b' last
805
+ return a.order - b.order; // both items have the 'order' field, sort numerically
806
+ };
789
807
  const sortedFilters = Object.values(dashboardFilters)
790
808
  .sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
791
809
  .filter((f) => !dateRangeFilterDisabled || f.filterType !== 'date_range');
792
- return (_jsxs("div", { style: containerStyle, children: [!hideFilters && sortedFilters.length > 0 && (_jsx("div", { style: {
810
+ const metrics = (section) => dashboardSections[section]
811
+ .filter(({ chartType }) => chartType === 'metric')
812
+ .sort(sortByOrdering);
813
+ const charts = (section) => dashboardSections[section]
814
+ .filter(({ chartType }) => !['metric', 'table'].includes(chartType))
815
+ .sort(sortByOrdering);
816
+ const tables = (section) => dashboardSections[section]
817
+ .filter(({ chartType }) => chartType === 'table')
818
+ .sort(sortByOrdering);
819
+ return (_jsxs("div", { ...styleToProps(containerStyle), children: [!hideFilters && (_jsx("div", { style: {
793
820
  display: 'flex',
794
821
  boxSizing: 'content-box',
795
822
  flexDirection: 'row',
@@ -801,363 +828,49 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
801
828
  flexDirection: 'row',
802
829
  alignItems: 'center',
803
830
  gap: 12,
804
- }, children: sortedFilters.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
805
- ? FilterDropdownComponent
806
- : MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
831
+ }, children: sortedFilters.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: SelectComponent ? SelectComponent : MemoizedDropdown, DateRangePickerComponent: DateRangePickerComponent
807
832
  ? DateRangePickerComponent
808
833
  : MemoizedDateRangePicker }, index))) }) })), Object.keys(dashboardSections)
809
834
  .sort(function (a, b) {
810
835
  return a.length - b.length;
811
836
  })
812
837
  .map((section, sectionIndex) => {
813
- return (_jsxs("div", { style: {
814
- width: '100%',
815
- }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && (_jsx("h1", { style: {
838
+ return (_jsxs(DashboardSectionComponent, { children: [section && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), _jsx("h1", { style: {
816
839
  fontSize: 22,
817
840
  color: theme.primaryTextColor,
818
841
  fontFamily: theme.fontFamily,
819
842
  fontWeight: 'bold',
820
- // fontWeight: theme.headerFontWeight,
821
843
  marginBottom: 16,
822
- // marginLeft: 25,
823
844
  textAlign: 'left',
824
845
  marginTop: 12,
825
- }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? (_jsx("div", { style: {
826
- boxSizing: 'content-box',
827
- width: `100%`,
828
- listStyleType: 'none',
829
- marginBottom: 50,
830
- display: 'grid',
831
- gridGap: 25,
832
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
833
- gridTemplateRows: `repeat(${170}px)`,
834
- }, children: dashboardSections[section]
835
- .filter((elem) => elem.chartType === 'metric')
836
- .sort((a, b) => {
837
- if (a.order === undefined && b.order === undefined)
838
- return 0; // both items don't have the 'order' field
839
- if (a.order === undefined)
840
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
841
- if (b.order === undefined)
842
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
843
- return a.order - b.order; // both items have the 'order' field, sort numerically
844
- })
845
- .map((elem, index) => {
846
- if (DashboardItemComponent) {
847
- return (_jsx("div", { onClick: onClickDashboardItem
848
- ? () => handleOnClickDashboardItem(elem)
849
- : void null, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
850
- padding: 0,
851
- // height: '100%',
852
- boxSizing: 'content-box',
853
- }, children: _jsx(Chart, { containerStyle: {
854
- display: 'flex',
855
- width: '100%',
856
- // height: '100%',
857
- }, chartId: elem._id, dateRangeFilterDisabled: dateRangeFilterDisabled, colors: theme.chartColors?.length
858
- ? theme.chartColors
859
- : undefined }) }) }) }, elem.name + '' + index));
860
- }
861
- return (_jsx("div", { onClick: onClickDashboardItem
862
- ? () => handleOnClickDashboardItem(elem)
863
- : undefined, style: {
864
- // background: theme.elevatedCardColor,
865
- // borderRadius: theme.borderRadius,
866
- // boxShadow: theme.boxShadow,
867
- paddingTop: 12,
868
- boxSizing: 'content-box',
869
- borderRadius: 8,
870
- height: '100%',
871
- cursor: 'pointer',
872
- width: '100%',
873
- ...metricContainerStyle,
874
- }, children: _jsx("div", {
875
- // className="group-hover:bg-black"
876
- style: {
877
- width: '100%',
878
- boxSizing: 'content-box',
879
- height: '100%',
880
- }, children: _jsx("div", { style: {
881
- width: '100%',
882
- boxSizing: 'content-box',
883
- height: '100%',
884
- }, children: _jsxs("div", { style: {
885
- display: 'flex',
886
- flexDirection: 'column',
887
- justifyContent: 'space-between',
888
- boxSizing: 'content-box',
889
- }, children: [_jsxs("div", {
890
- // className="group-hover:bg-black"
891
- style: {
892
- display: 'flex',
893
- flexDirection: 'row',
894
- justifyContent: 'space-between',
895
- boxSizing: 'content-box',
896
- // alignItems: 'center',
897
- // paddingLeft: theme.padding,
898
- // paddingRight: 25,
899
- // paddingTop: theme.padding,
900
- }, children: [_jsx("div", { title: elem.name, style: {
901
- fontFamily: theme.fontFamily,
902
- color: theme.primaryTextColor,
903
- boxSizing: 'content-box',
904
- // TODO: FIX SIZE
905
- fontSize: 18,
906
- // TODO: FIX WEIGHT
907
- fontWeight: '500',
908
- // fontSize: theme.headerFontSize,
909
- // color: theme.fontColor,
910
- // fontWeight: theme.headerFontWeight,
911
- textOverflow: 'ellipsis',
912
- // margin: 0,
913
- padding: 0,
914
- whiteSpace: 'nowrap',
915
- display: 'block',
916
- maxWidth: '100%',
917
- overflow: 'hidden',
918
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
919
- // className="hover:bg-black"
920
- style: {
921
- fontFamily: theme.fontFamily,
922
- boxSizing: 'content-box',
923
- color: theme.primaryTextColor,
924
- fontWeight: '500',
925
- fontSize: 14,
926
- minWidth: 14 * 7,
927
- // background: 'red',
928
- display: 'flex',
929
- alignItems: 'center',
930
- justifyContent: 'flex-end',
931
- }, children: 'view report →' })) : null] }), _jsx("div", { style: { padding: 0, paddingTop: 10 }, children: _jsx(Chart, { containerStyle: {
932
- // display: 'flex',
933
- // width: '100%',
934
- // height: 30,
935
- // marginBottom: 50,
936
- // marginTop: 50,
937
- },
938
- // chartFilters={elem.chartFilters}
939
- dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
940
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? (_jsx("div", { style: {
941
- listStyleType: 'none',
942
- display: 'grid',
943
- gridGap: 25,
944
- boxSizing: 'content-box',
945
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
946
- gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
947
- }, children: dashboardSections[section]
948
- .filter((elem) => elem.chartType !== 'metric' &&
949
- elem.chartType !== 'table')
950
- .sort((a, b) => {
951
- if (a.order === undefined && b.order === undefined)
952
- return 0; // both items don't have the 'order' field
953
- if (a.order === undefined)
954
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
955
- if (b.order === undefined)
956
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
957
- return a.order - b.order; // both items have the 'order' field, sort numerically
958
- })
959
- .map((elem, index) => {
960
- if (DashboardItemComponent) {
961
- return (_jsx("div", { onClick: onClickDashboardItem
962
- ? () => handleOnClickDashboardItem(elem)
963
- : undefined, style: { height: rowHeight || 400 }, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx(Chart, { containerStyle: {
964
- display: 'flex',
965
- width: '100%',
966
- // height: '100%',
967
- minHeight: 300,
968
- height: 300,
969
- // background: 'red',
970
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
971
- ? theme.chartColors
972
- : undefined }) }) }, elem.name + '' + index));
973
- }
974
- return (_jsx("div", { onClick: onClickDashboardItem
975
- ? () => handleOnClickDashboardItem(elem)
976
- : undefined, style: {
977
- height: '100%',
978
- cursor: 'pointer',
979
- boxSizing: 'content-box',
980
- paddingRight: 25,
981
- minHeight: rowHeight || 400,
982
- borderRadius: 8,
983
- paddingTop: 20,
984
- ...chartContainerStyle,
985
- }, children: _jsx("div", { style: {
846
+ }, children: section })] })), metrics(section).length > 0 && (_jsx(DashboardGroupComponent, { children: metrics(section).map((item, index) => {
847
+ _jsx(DashboardItemComponent, { dashboardItem: cleanDashboardItem(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
848
+ ? () => handleOnClickDashboardItem(item)
849
+ : void null, children: _jsx(Chart, { containerStyle: {
850
+ display: 'flex',
986
851
  width: '100%',
987
- height: '100%',
988
- boxSizing: 'content-box',
989
- }, children: _jsx("div", { style: {
990
- width: '100%',
991
- height: '100%',
992
- boxSizing: 'content-box',
993
- }, children: _jsxs("div", { style: {
994
- display: 'flex',
995
- flexDirection: 'column',
996
- justifyContent: 'space-between',
997
- height: '100%',
998
- boxSizing: 'content-box',
999
- }, children: [_jsxs("div", { style: {
1000
- display: 'flex',
1001
- flexDirection: 'row',
1002
- justifyContent: 'space-between',
1003
- boxSizing: 'content-box',
1004
- }, children: [_jsx("div", { style: {
1005
- fontFamily: theme.fontFamily,
1006
- color: theme.primaryTextColor,
1007
- boxSizing: 'content-box',
1008
- fontSize: 18,
1009
- fontWeight: '500',
1010
- textOverflow: 'ellipsis',
1011
- // marginLeft: 25,
1012
- padding: 0,
1013
- whiteSpace: 'nowrap',
1014
- display: 'block',
1015
- maxWidth: '100%',
1016
- overflow: 'hidden',
1017
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", { style: {
1018
- fontFamily: theme.fontFamily,
1019
- color: theme.primaryTextColor,
1020
- boxSizing: 'content-box',
1021
- fontWeight: '500',
1022
- fontSize: 14,
1023
- minWidth: 14 * 7,
1024
- display: 'flex',
1025
- alignItems: 'center',
1026
- justifyContent: 'flex-end',
1027
- }, children: 'view report →' })) : null] }), _jsx("div", { style: {
1028
- padding: 0,
1029
- height: '100%',
1030
- boxSizing: 'content-box',
1031
- }, children: _jsx(Chart, { containerStyle: {
1032
- display: 'flex',
1033
- width: '100%',
1034
- // TODO: fix fixed height
1035
- height: 300,
1036
- marginBottom: 50,
1037
- marginTop: 30,
1038
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1039
- ? theme.chartColors
1040
- : undefined }) })] }) }) }) }, elem.name + '' + index));
1041
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType === 'table').length ? (_jsxs("div", { style: {
852
+ // height: '100%',
853
+ }, chartId: item._id, colors: theme.chartColors?.length
854
+ ? theme.chartColors
855
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index);
856
+ }) })), charts(section).length > 0 && (_jsx(DashboardGroupComponent, { children: charts(section).map((item, index) => (_jsx(DashboardItemComponent, { dashboardItem: cleanDashboardItem(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
857
+ ? () => handleOnClickDashboardItem(item)
858
+ : void null, children: _jsx(Chart, { containerStyle: chartContainerStyle, chartId: item._id, colors: theme.chartColors?.length
859
+ ? theme.chartColors
860
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index))) })), tables(section).length > 0 && (_jsxs("div", { style: {
1042
861
  boxSizing: 'content-box',
1043
862
  width: `100%`,
1044
863
  gap: 20,
1045
864
  display: 'flex',
1046
865
  flexDirection: 'column',
1047
- }, children: [_jsx("div", { style: { height: 0 } }), dashboardSections[section]
1048
- .filter((elem) => elem.chartType === 'table')
1049
- .sort((a, b) => {
1050
- if (a.order === undefined && b.order === undefined)
1051
- return 0; // both items don't have the 'order' field
1052
- if (a.order === undefined)
1053
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
1054
- if (b.order === undefined)
1055
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
1056
- return a.order - b.order; // both items have the 'order' field, sort numerically
1057
- })
1058
- .map((elem, index) => {
1059
- if (DashboardItemComponent) {
1060
- return (_jsx("div", { onClick: onClickDashboardItem
1061
- ? () => handleOnClickDashboardItem(elem)
1062
- : undefined, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
1063
- padding: 0,
1064
- height: '100%',
1065
- boxSizing: 'content-box',
1066
- }, children: _jsx(Chart, { containerStyle: {
1067
- display: 'flex',
1068
- width: '100%',
1069
- height: '100%',
1070
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1071
- ? theme.chartColors
1072
- : undefined }) }) }) }, elem.name + '' + index));
1073
- }
1074
- return (_jsxs("div", { onClick: onClickDashboardItem
1075
- ? () => handleOnClickDashboardItem(elem)
1076
- : undefined, children: [_jsx("div", { onClick: onClickDashboardItem
1077
- ? () => handleOnClickDashboardItem(elem)
1078
- : undefined, style: {
1079
- // background: theme.elevatedCardColor,
1080
- // borderRadius: theme.borderRadius,
1081
- // boxShadow: theme.boxShadow,
1082
- paddingTop: 12,
1083
- boxSizing: 'content-box',
1084
- borderRadius: 8,
1085
- // height: '100%',
1086
- cursor: 'pointer',
1087
- width: '100%',
1088
- minHeight: 420,
1089
- height: 420,
1090
- // ...metricContainerStyle,
1091
- }, children: _jsx("div", {
1092
- // className="group-hover:bg-black"
1093
- style: {
1094
- width: '100%',
1095
- boxSizing: 'content-box',
1096
- height: '100%',
1097
- }, children: _jsx("div", { style: {
1098
- width: '100%',
1099
- boxSizing: 'content-box',
1100
- height: '100%',
1101
- }, children: _jsxs("div", { style: {
1102
- display: 'flex',
1103
- flexDirection: 'column',
1104
- justifyContent: 'space-between',
1105
- boxSizing: 'content-box',
1106
- height: '100%',
1107
- }, children: [_jsxs("div", {
1108
- // className="group-hover:bg-black"
1109
- style: {
1110
- display: 'flex',
1111
- flexDirection: 'row',
1112
- justifyContent: 'space-between',
1113
- boxSizing: 'content-box',
1114
- // alignItems: 'center',
1115
- // paddingLeft: theme.padding,
1116
- paddingRight: 25,
1117
- // paddingTop: theme.padding,
1118
- }, children: [_jsx("div", { title: elem.name, style: {
1119
- fontFamily: theme.fontFamily,
1120
- color: theme.primaryTextColor,
1121
- boxSizing: 'content-box',
1122
- // TODO: FIX SIZE
1123
- fontSize: 18,
1124
- // TODO: FIX WEIGHT
1125
- fontWeight: '500',
1126
- // fontSize: theme.headerFontSize,
1127
- // color: theme.fontColor,
1128
- // fontWeight: theme.headerFontWeight,
1129
- textOverflow: 'ellipsis',
1130
- // margin: 0,
1131
- // marginLeft: 25,
1132
- padding: 0,
1133
- whiteSpace: 'nowrap',
1134
- display: 'block',
1135
- maxWidth: '100%',
1136
- overflow: 'hidden',
1137
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
1138
- // className="hover:bg-black"
1139
- style: {
1140
- fontFamily: theme.fontFamily,
1141
- boxSizing: 'content-box',
1142
- color: theme.primaryTextColor,
1143
- fontWeight: '500',
1144
- fontSize: 14,
1145
- minWidth: 14 * 7,
1146
- // background: 'red',
1147
- display: 'flex',
1148
- alignItems: 'center',
1149
- justifyContent: 'flex-end',
1150
- }, children: 'view report →' })) : null] }), _jsxs("div", { style: {
1151
- padding: 0,
1152
- height: '400px',
1153
- }, children: [_jsx("div", { style: { height: 20 } }), _jsx(Chart, { containerStyle: {
1154
- // display: 'flex',
1155
- // width: '100%',
1156
- // height: 30,
1157
- // marginBottom: 50,
1158
- height: '100%',
1159
- // paddingLeft: 25,
1160
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), _jsx("div", { style: { height: 40 } })] }, elem.name + '' + index));
1161
- })] })) : null, _jsx("div", { style: { height: 40 } })] }, section + '' + sectionIndex));
866
+ }, children: [_jsx("div", { style: { height: 0 } }), tables(section).map((item, index) => (_jsx(DashboardItemComponent, { dashboardItem: cleanDashboardItem(dashboard[item._id]), onClickDashboardItem: onClickDashboardItem
867
+ ? () => handleOnClickDashboardItem(item)
868
+ : void null, children: _jsx(Chart, { containerStyle: {
869
+ display: 'flex',
870
+ width: '100%',
871
+ height: '100%',
872
+ }, chartId: item._id, colors: theme.chartColors?.length
873
+ ? theme.chartColors
874
+ : undefined, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }) }, item.name + '' + index)))] }))] }, section + '' + sectionIndex));
1162
875
  })] }));
1163
876
  }
@@ -31,8 +31,25 @@ export declare const PRIMARY_CODES: {
31
31
  * comparison range) and returns a QuillDateRange based on that key and date.
32
32
  */
33
33
  export declare const COMPARISON_RANGE: {
34
- [key: string]: (range: QuillDateRange) => QuillDateRange | null;
34
+ readonly PREV_PERIOD: ({ start, end }: QuillDateRange) => {
35
+ start: Date;
36
+ end: Date;
37
+ };
38
+ readonly PREV_7_DAYS: ({ start }: QuillDateRange) => {
39
+ start: Date;
40
+ end: Date;
41
+ };
42
+ readonly PREV_30_DAYS: ({ start }: QuillDateRange) => {
43
+ start: Date;
44
+ end: Date;
45
+ };
46
+ readonly PREV_90_DAYS: ({ start }: QuillDateRange) => {
47
+ start: Date;
48
+ end: Date;
49
+ };
50
+ readonly NO_COMPARISON: (_: any) => null;
35
51
  };
52
+ export type ComparisonRangeKey = keyof typeof COMPARISON_RANGE;
36
53
  export declare const defaultOptions: DateRangePickerOption[];
37
54
  export declare const reportBuilderOptions: DateRangePickerOption[];
38
55
  export declare const getRangeFromPreset: (preset: string) => (string | Date | null)[];