@quillsql/react 2.10.5 → 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 (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 +116 -27
  8. package/dist/cjs/Dashboard.d.ts.map +1 -1
  9. package/dist/cjs/Dashboard.js +85 -412
  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 +116 -27
  49. package/dist/esm/Dashboard.d.ts.map +1 -1
  50. package/dist/esm/Dashboard.js +81 -385
  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,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',
@@ -42,16 +46,6 @@ export const PRIMARY_OPTIONS = [
42
46
  { value: 'LAST_6_MONTHS', text: 'Last 6 months' },
43
47
  { value: 'ALL_TIME', text: 'All time' },
44
48
  ];
45
- export const VIDEO_ELEPHANT_OPTIONS = [
46
- { value: 'DECEMBER_2023', text: 'This Week' },
47
- { value: 'NOVEMBER_2023', text: 'This Month' },
48
- { value: 'OCTOBER_2023', text: 'This year' },
49
- { value: 'SEPTEMBER_2023', text: 'Last 7 days' },
50
- { value: 'AUGUST_2023', text: 'Last 30 days' },
51
- { value: 'LAST_90_DAYS', text: 'Last 90 days' },
52
- { value: 'LAST_6_MONTHS', text: 'Last 6 months' },
53
- { value: 'ALL_TIME', text: 'All time' },
54
- ];
55
49
  const FILTER_CODE_MAP = {
56
50
  wk: 'This week',
57
51
  m: 'This month',
@@ -79,7 +73,9 @@ export function DashboardFilter({ filter, onChangeFilter, SelectComponent, DateR
79
73
  setFilterValue(filter.selectedValue);
80
74
  }
81
75
  if (filter.filterType == 'date_range') {
82
- setDateFilter(FILTER_CODE_MAP[filter.selectedValue ? filter.selectedValue[2] : null]);
76
+ setDateFilter(filter.selectedValue
77
+ ? FILTER_CODE_MAP[filter.selectedValue[2]]
78
+ : null);
83
79
  if (filter?.comparisonRange?.value) {
84
80
  const newComparisonRange = COMPARISON_OPTIONS.find((option) => {
85
81
  return option.value === filter.comparisonRange.value;
@@ -228,7 +224,7 @@ const QuillDropdownComponent = ({ onChange, value, label, options, }) => {
228
224
  const isBetween = (date, startDate, endDate) => {
229
225
  return isAfter(date, startDate) && isBefore(date, endDate);
230
226
  };
231
- function Calendar({ anchorDate, selectedDateRange, onClickDate, theme, localStartDate, localEndDate, }) {
227
+ function Calendar({ anchorDate, onClickDate, theme, localStartDate, localEndDate, }) {
232
228
  const firstDayOfDisplayedMonth = startOfMonth(anchorDate);
233
229
  const lastDayOfDisplayedMonth = endOfMonth(anchorDate);
234
230
  const weekdays = getWeekdays(enUS).map((dayName) => capitalize(dayName, enUS));
@@ -341,17 +337,9 @@ function CalendarDropdown({ onChangeDateRange, dateRange }) {
341
337
  const [showModal, setShowModal] = useState(false);
342
338
  const modalRef = useRef(null);
343
339
  const parentRef = useRef(null);
344
- const handleOnChange = useCallback((event) => {
345
- onChangeDateRange(event.target.value);
346
- }, [onChangeDateRange]);
347
340
  const [anchorDate, setAnchorDate] = useState(null);
348
341
  const [localStartDate, setLocalStartDate] = useState(null);
349
342
  const [localEndDate, setLocalEndDate] = useState(null);
350
- // const firstDayOfFirstMonth = startOfMonth(value[0]);
351
- // const lastDayOfLastMonth = endOfMonth(value[1]);
352
- // const weekdays = getWeekdays(enUS).map(dayName =>
353
- // capitalize(dayName, locale)
354
- // );
355
343
  const prevMonthAnchor = subDays(startOfMonth(anchorDate), 1);
356
344
  const onClickDate = (date) => {
357
345
  if (localStartDate && isBefore(date, localStartDate)) {
@@ -533,10 +521,10 @@ export const QuillDateRangePicker = ({ label, dateRange, onChangeDateRange, pres
533
521
  }, children: [_jsx(MemoizedCalendarDropdown, { dateRange: dateRange, onChangeDateRange: onChangeDateRange, theme: theme }), _jsx(MemoizedDropdown, { options: presetOptions.map((option) => ({
534
522
  label: option.text,
535
523
  value: option.value,
536
- })), onChange: onChangePreset, value: preset })] })] }));
524
+ })), onChange: onChangePreset, value: preset, label: preset })] })] }));
537
525
  };
538
- const MemoizedCalendarDropdown = React.memo(CalendarDropdown);
539
- const MemoizedDropdown = React.memo(QuillDropdownComponent);
526
+ const MemoizedCalendarDropdown = memo(CalendarDropdown);
527
+ const MemoizedDropdown = memo(QuillDropdownComponent);
540
528
  const areEqual = (prevProps, nextProps) => {
541
529
  // This function returns true if passing nextProps to render would return
542
530
  // the same result as passing prevProps to render, otherwise it returns false
@@ -545,20 +533,21 @@ const areEqual = (prevProps, nextProps) => {
545
533
  prevProps.dateRange[0] === nextProps.dateRange[0] &&
546
534
  prevProps.dateRange[1] === nextProps.dateRange[1]);
547
535
  };
548
- const MemoizedDateRangePicker = React.memo(QuillDateRangePicker, areEqual);
536
+ const MemoizedDateRangePicker = memo(QuillDateRangePicker, areEqual);
549
537
  const QuillEmptyDashboardComponent = () => _jsx("div", {});
550
- function removeQuotes(str) {
551
- if (str.startsWith('"') && str.endsWith('"')) {
552
- return str.slice(1, -1);
553
- }
554
- else {
555
- return str;
556
- }
557
- }
558
- 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, }) {
559
548
  const { dateFilter } = useDateFilter();
560
549
  const { dispatch } = useContext(DashboardContext);
561
- const { isLoading: isDataLoading, data, reload } = useDashboard(name);
550
+ const { isLoading: isDataLoading, data, reload, } = useDashboard(name);
562
551
  const [dashboardSections, setDashboardSections] = useState(null);
563
552
  const { dashboard } = useContext(DashboardContext);
564
553
  const [client] = useContext(ClientContext);
@@ -577,12 +566,6 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
577
566
  useEffect(() => {
578
567
  reload();
579
568
  }, [name, client]);
580
- function hashCode(s) {
581
- return s.split('').reduce(function (a, b) {
582
- a = (a << 5) - a + b.charCodeAt(0);
583
- return a & a;
584
- }, 0);
585
- }
586
569
  const onDashboardDataChange = (resp) => {
587
570
  setDashboardSections(resp.sections);
588
571
  const bigFilterObj = {};
@@ -673,6 +656,14 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
673
656
  },
674
657
  });
675
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
+ }
676
667
  const processFilter = (filter, value = null) => {
677
668
  //for dateObjects only, since values are arrays for dateObjects
678
669
  const { selectedValue: _, ...filterWithoutSelectedValue } = filter; // _ is a throwaway variable
@@ -760,7 +751,8 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
760
751
  options: options,
761
752
  comparison: true,
762
753
  comparisonRange: {
763
- startDate: COMPARISON_RANGE[key](primaryRange)?.start,
754
+ startDate: COMPARISON_RANGE[key](primaryRange)
755
+ ?.start,
764
756
  endDate: COMPARISON_RANGE[key](primaryRange)?.end,
765
757
  value: key,
766
758
  },
@@ -803,10 +795,28 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
803
795
  return null;
804
796
  if (!dashboardSections || Object.keys(dashboardSections).length == 0)
805
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
+ };
806
807
  const sortedFilters = Object.values(dashboardFilters)
807
808
  .sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
808
809
  .filter((f) => !dateRangeFilterDisabled || f.filterType !== 'date_range');
809
- 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: {
810
820
  display: 'flex',
811
821
  boxSizing: 'content-box',
812
822
  flexDirection: 'row',
@@ -818,363 +828,49 @@ export default function Dashboard({ name, containerStyle, chartContainerStyle, m
818
828
  flexDirection: 'row',
819
829
  alignItems: 'center',
820
830
  gap: 12,
821
- }, children: sortedFilters.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: updateFilter, theme: theme, filterValue: dashboardFilters, SelectComponent: FilterDropdownComponent
822
- ? FilterDropdownComponent
823
- : 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
824
832
  ? DateRangePickerComponent
825
833
  : MemoizedDateRangePicker }, index))) }) })), Object.keys(dashboardSections)
826
834
  .sort(function (a, b) {
827
835
  return a.length - b.length;
828
836
  })
829
837
  .map((section, sectionIndex) => {
830
- return (_jsxs("div", { style: {
831
- width: '100%',
832
- }, 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: {
833
839
  fontSize: 22,
834
840
  color: theme.primaryTextColor,
835
841
  fontFamily: theme.fontFamily,
836
842
  fontWeight: 'bold',
837
- // fontWeight: theme.headerFontWeight,
838
843
  marginBottom: 16,
839
- // marginLeft: 25,
840
844
  textAlign: 'left',
841
845
  marginTop: 12,
842
- }, children: section }))] }), dashboardSections[section].filter((elem) => elem.chartType === 'metric').length ? (_jsx("div", { style: {
843
- boxSizing: 'content-box',
844
- width: `100%`,
845
- listStyleType: 'none',
846
- marginBottom: 50,
847
- display: 'grid',
848
- gridGap: 25,
849
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
850
- gridTemplateRows: `repeat(${170}px)`,
851
- }, children: dashboardSections[section]
852
- .filter((elem) => elem.chartType === 'metric')
853
- .sort((a, b) => {
854
- if (a.order === undefined && b.order === undefined)
855
- return 0; // both items don't have the 'order' field
856
- if (a.order === undefined)
857
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
858
- if (b.order === undefined)
859
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
860
- return a.order - b.order; // both items have the 'order' field, sort numerically
861
- })
862
- .map((elem, index) => {
863
- if (DashboardItemComponent) {
864
- return (_jsx("div", { onClick: onClickDashboardItem
865
- ? () => handleOnClickDashboardItem(elem)
866
- : void null, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
867
- padding: 0,
868
- // height: '100%',
869
- boxSizing: 'content-box',
870
- }, children: _jsx(Chart, { containerStyle: {
871
- display: 'flex',
872
- width: '100%',
873
- // height: '100%',
874
- }, chartId: elem._id, dateRangeFilterDisabled: dateRangeFilterDisabled, colors: theme.chartColors?.length
875
- ? theme.chartColors
876
- : undefined }) }) }) }, elem.name + '' + index));
877
- }
878
- return (_jsx("div", { onClick: onClickDashboardItem
879
- ? () => handleOnClickDashboardItem(elem)
880
- : undefined, style: {
881
- // background: theme.elevatedCardColor,
882
- // borderRadius: theme.borderRadius,
883
- // boxShadow: theme.boxShadow,
884
- paddingTop: 12,
885
- boxSizing: 'content-box',
886
- borderRadius: 8,
887
- height: '100%',
888
- cursor: 'pointer',
889
- width: '100%',
890
- ...metricContainerStyle,
891
- }, children: _jsx("div", {
892
- // className="group-hover:bg-black"
893
- 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',
894
851
  width: '100%',
895
- boxSizing: 'content-box',
896
- height: '100%',
897
- }, children: _jsx("div", { style: {
898
- width: '100%',
899
- boxSizing: 'content-box',
900
- height: '100%',
901
- }, children: _jsxs("div", { style: {
902
- display: 'flex',
903
- flexDirection: 'column',
904
- justifyContent: 'space-between',
905
- boxSizing: 'content-box',
906
- }, children: [_jsxs("div", {
907
- // className="group-hover:bg-black"
908
- style: {
909
- display: 'flex',
910
- flexDirection: 'row',
911
- justifyContent: 'space-between',
912
- boxSizing: 'content-box',
913
- // alignItems: 'center',
914
- // paddingLeft: theme.padding,
915
- // paddingRight: 25,
916
- // paddingTop: theme.padding,
917
- }, children: [_jsx("div", { title: elem.name, style: {
918
- fontFamily: theme.fontFamily,
919
- color: theme.primaryTextColor,
920
- boxSizing: 'content-box',
921
- // TODO: FIX SIZE
922
- fontSize: 18,
923
- // TODO: FIX WEIGHT
924
- fontWeight: '500',
925
- // fontSize: theme.headerFontSize,
926
- // color: theme.fontColor,
927
- // fontWeight: theme.headerFontWeight,
928
- textOverflow: 'ellipsis',
929
- // margin: 0,
930
- padding: 0,
931
- whiteSpace: 'nowrap',
932
- display: 'block',
933
- maxWidth: '100%',
934
- overflow: 'hidden',
935
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
936
- // className="hover:bg-black"
937
- style: {
938
- fontFamily: theme.fontFamily,
939
- boxSizing: 'content-box',
940
- color: theme.primaryTextColor,
941
- fontWeight: '500',
942
- fontSize: 14,
943
- minWidth: 14 * 7,
944
- // background: 'red',
945
- display: 'flex',
946
- alignItems: 'center',
947
- justifyContent: 'flex-end',
948
- }, children: 'view report →' })) : null] }), _jsx("div", { style: { padding: 0, paddingTop: 10 }, children: _jsx(Chart, { containerStyle: {
949
- // display: 'flex',
950
- // width: '100%',
951
- // height: 30,
952
- // marginBottom: 50,
953
- // marginTop: 50,
954
- },
955
- // chartFilters={elem.chartFilters}
956
- dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id }) })] }) }) }) }, elem.name + '' + index));
957
- }) })) : null, dashboardSections[section].filter((elem) => elem.chartType !== 'table' && elem.chartType !== 'metric').length ? (_jsx("div", { style: {
958
- listStyleType: 'none',
959
- display: 'grid',
960
- gridGap: 25,
961
- boxSizing: 'content-box',
962
- gridTemplateColumns: `repeat(auto-fill,minmax(${maxColumnWidth || 400}px, 1fr))`,
963
- gridTemplateRows: `repeat(auto-fill, ${rowHeight || 400}px)`,
964
- }, children: dashboardSections[section]
965
- .filter((elem) => elem.chartType !== 'metric' &&
966
- elem.chartType !== 'table')
967
- .sort((a, b) => {
968
- if (a.order === undefined && b.order === undefined)
969
- return 0; // both items don't have the 'order' field
970
- if (a.order === undefined)
971
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
972
- if (b.order === undefined)
973
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
974
- return a.order - b.order; // both items have the 'order' field, sort numerically
975
- })
976
- .map((elem, index) => {
977
- if (DashboardItemComponent) {
978
- return (_jsx("div", { onClick: onClickDashboardItem
979
- ? () => handleOnClickDashboardItem(elem)
980
- : undefined, style: { height: rowHeight || 400 }, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx(Chart, { containerStyle: {
981
- display: 'flex',
982
- width: '100%',
983
- // height: '100%',
984
- minHeight: 300,
985
- height: 300,
986
- // background: 'red',
987
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
988
- ? theme.chartColors
989
- : undefined }) }) }, elem.name + '' + index));
990
- }
991
- return (_jsx("div", { onClick: onClickDashboardItem
992
- ? () => handleOnClickDashboardItem(elem)
993
- : undefined, style: {
994
- height: '100%',
995
- cursor: 'pointer',
996
- boxSizing: 'content-box',
997
- paddingRight: 25,
998
- minHeight: rowHeight || 400,
999
- borderRadius: 8,
1000
- paddingTop: 20,
1001
- ...chartContainerStyle,
1002
- }, children: _jsx("div", { style: {
1003
- width: '100%',
1004
- height: '100%',
1005
- boxSizing: 'content-box',
1006
- }, children: _jsx("div", { style: {
1007
- width: '100%',
1008
- height: '100%',
1009
- boxSizing: 'content-box',
1010
- }, children: _jsxs("div", { style: {
1011
- display: 'flex',
1012
- flexDirection: 'column',
1013
- justifyContent: 'space-between',
1014
- height: '100%',
1015
- boxSizing: 'content-box',
1016
- }, children: [_jsxs("div", { style: {
1017
- display: 'flex',
1018
- flexDirection: 'row',
1019
- justifyContent: 'space-between',
1020
- boxSizing: 'content-box',
1021
- }, children: [_jsx("div", { style: {
1022
- fontFamily: theme.fontFamily,
1023
- color: theme.primaryTextColor,
1024
- boxSizing: 'content-box',
1025
- fontSize: 18,
1026
- fontWeight: '500',
1027
- textOverflow: 'ellipsis',
1028
- // marginLeft: 25,
1029
- padding: 0,
1030
- whiteSpace: 'nowrap',
1031
- display: 'block',
1032
- maxWidth: '100%',
1033
- overflow: 'hidden',
1034
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", { style: {
1035
- fontFamily: theme.fontFamily,
1036
- color: theme.primaryTextColor,
1037
- boxSizing: 'content-box',
1038
- fontWeight: '500',
1039
- fontSize: 14,
1040
- minWidth: 14 * 7,
1041
- display: 'flex',
1042
- alignItems: 'center',
1043
- justifyContent: 'flex-end',
1044
- }, children: 'view report →' })) : null] }), _jsx("div", { style: {
1045
- padding: 0,
1046
- height: '100%',
1047
- boxSizing: 'content-box',
1048
- }, children: _jsx(Chart, { containerStyle: {
1049
- display: 'flex',
1050
- width: '100%',
1051
- // TODO: fix fixed height
1052
- height: 300,
1053
- marginBottom: 50,
1054
- marginTop: 30,
1055
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1056
- ? theme.chartColors
1057
- : undefined }) })] }) }) }) }, elem.name + '' + index));
1058
- }) })) : 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: {
1059
861
  boxSizing: 'content-box',
1060
862
  width: `100%`,
1061
863
  gap: 20,
1062
864
  display: 'flex',
1063
865
  flexDirection: 'column',
1064
- }, children: [_jsx("div", { style: { height: 0 } }), dashboardSections[section]
1065
- .filter((elem) => elem.chartType === 'table')
1066
- .sort((a, b) => {
1067
- if (a.order === undefined && b.order === undefined)
1068
- return 0; // both items don't have the 'order' field
1069
- if (a.order === undefined)
1070
- return 1; // only 'a' doesn't have the 'order' field, place 'a' last
1071
- if (b.order === undefined)
1072
- return -1; // only 'b' doesn't have the 'order' field, place 'b' last
1073
- return a.order - b.order; // both items have the 'order' field, sort numerically
1074
- })
1075
- .map((elem, index) => {
1076
- if (DashboardItemComponent) {
1077
- return (_jsx("div", { onClick: onClickDashboardItem
1078
- ? () => handleOnClickDashboardItem(elem)
1079
- : undefined, children: _jsx(DashboardItemComponent, { dashboardItem: elem, children: _jsx("div", { style: {
1080
- padding: 0,
1081
- height: '100%',
1082
- boxSizing: 'content-box',
1083
- }, children: _jsx(Chart, { containerStyle: {
1084
- display: 'flex',
1085
- width: '100%',
1086
- height: '100%',
1087
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id, colors: theme.chartColors?.length
1088
- ? theme.chartColors
1089
- : undefined }) }) }) }, elem.name + '' + index));
1090
- }
1091
- return (_jsxs("div", { onClick: onClickDashboardItem
1092
- ? () => handleOnClickDashboardItem(elem)
1093
- : undefined, children: [_jsx("div", { onClick: onClickDashboardItem
1094
- ? () => handleOnClickDashboardItem(elem)
1095
- : undefined, style: {
1096
- // background: theme.elevatedCardColor,
1097
- // borderRadius: theme.borderRadius,
1098
- // boxShadow: theme.boxShadow,
1099
- paddingTop: 12,
1100
- boxSizing: 'content-box',
1101
- borderRadius: 8,
1102
- // height: '100%',
1103
- cursor: 'pointer',
1104
- width: '100%',
1105
- minHeight: 420,
1106
- height: 420,
1107
- // ...metricContainerStyle,
1108
- }, children: _jsx("div", {
1109
- // className="group-hover:bg-black"
1110
- style: {
1111
- width: '100%',
1112
- boxSizing: 'content-box',
1113
- height: '100%',
1114
- }, children: _jsx("div", { style: {
1115
- width: '100%',
1116
- boxSizing: 'content-box',
1117
- height: '100%',
1118
- }, children: _jsxs("div", { style: {
1119
- display: 'flex',
1120
- flexDirection: 'column',
1121
- justifyContent: 'space-between',
1122
- boxSizing: 'content-box',
1123
- height: '100%',
1124
- }, children: [_jsxs("div", {
1125
- // className="group-hover:bg-black"
1126
- style: {
1127
- display: 'flex',
1128
- flexDirection: 'row',
1129
- justifyContent: 'space-between',
1130
- boxSizing: 'content-box',
1131
- // alignItems: 'center',
1132
- // paddingLeft: theme.padding,
1133
- paddingRight: 25,
1134
- // paddingTop: theme.padding,
1135
- }, children: [_jsx("div", { title: elem.name, style: {
1136
- fontFamily: theme.fontFamily,
1137
- color: theme.primaryTextColor,
1138
- boxSizing: 'content-box',
1139
- // TODO: FIX SIZE
1140
- fontSize: 18,
1141
- // TODO: FIX WEIGHT
1142
- fontWeight: '500',
1143
- // fontSize: theme.headerFontSize,
1144
- // color: theme.fontColor,
1145
- // fontWeight: theme.headerFontWeight,
1146
- textOverflow: 'ellipsis',
1147
- // margin: 0,
1148
- // marginLeft: 25,
1149
- padding: 0,
1150
- whiteSpace: 'nowrap',
1151
- display: 'block',
1152
- maxWidth: '100%',
1153
- overflow: 'hidden',
1154
- }, children: elem.name }), onClickDashboardItem ? (_jsx("div", {
1155
- // className="hover:bg-black"
1156
- style: {
1157
- fontFamily: theme.fontFamily,
1158
- boxSizing: 'content-box',
1159
- color: theme.primaryTextColor,
1160
- fontWeight: '500',
1161
- fontSize: 14,
1162
- minWidth: 14 * 7,
1163
- // background: 'red',
1164
- display: 'flex',
1165
- alignItems: 'center',
1166
- justifyContent: 'flex-end',
1167
- }, children: 'view report →' })) : null] }), _jsxs("div", { style: {
1168
- padding: 0,
1169
- height: '400px',
1170
- }, children: [_jsx("div", { style: { height: 20 } }), _jsx(Chart, { containerStyle: {
1171
- // display: 'flex',
1172
- // width: '100%',
1173
- // height: 30,
1174
- // marginBottom: 50,
1175
- height: '100%',
1176
- // paddingLeft: 25,
1177
- }, dateRangeFilterDisabled: dateRangeFilterDisabled, chartId: elem._id })] })] }) }) }) }, elem.name + '' + index), _jsx("div", { style: { height: 40 } })] }, elem.name + '' + index));
1178
- })] })) : 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));
1179
875
  })] }));
1180
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)[];
@@ -1 +1 @@
1
- {"version":3,"file":"dateRangePickerUtils.d.ts","sourceRoot":"","sources":["../../../src/DateRangePicker/dateRangePickerUtils.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,eAAO,MAAM,WAAW,WAAY,MAAM,aAKzC,CAAC;AAEF,eAAO,MAAM,UAAU,MAAO,MAAM,UAAU,MAAM,WAEnD,CAAC;AAEF,eAAO,MAAM,2BAA2B,kBACvB,MAAM,GAAG,IAAI,GAAG,SAAS,oBACtB,qBAAqB,EAAE,gBAU1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,kBACrB,MAAM,GAAG,IAAI,GAAG,SAAS,oBACtB,qBAAqB,EAAE,SAU1C,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,IAAI,GAAG,IAAI,GAAG,SAAS,WACzB,IAAI,GAAG,IAAI,GAAG,SAAS,yBACT,MAAM,GAAG,IAAI,GAAG,SAAS,mBAC/B,qBAAqB,EAAE,gBAWzC,CAAC;AAEF,eAAO,MAAM,YAAY,YACd,IAAI,GAAG,IAAI,GAAG,SAAS,WACvB,IAAI,GAAG,IAAI,GAAG,SAAS,yBACT,MAAM,GAAG,IAAI,GAAG,SAAS,mBAC/B,qBAAqB,EAAE,gBASzC,CAAC;AAEF;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAA;CASjE,CAAC;AAEF;;GAEG;AACH,eAAO,M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