@redsift/dashboard 11.6.0-muiv5-alpha.11 → 11.6.0-muiv5-alpha.13

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 (75) hide show
  1. package/_internal/ChartEmptyState.js +2 -0
  2. package/{components/ChartEmptyState/_internal → _internal}/ChartEmptyState2.js +33 -2
  3. package/_internal/ChartEmptyState2.js.map +1 -0
  4. package/_internal/CrossfilterRegistry.js +2 -0
  5. package/{components/CrossfilterRegistry/_internal → _internal}/CrossfilterRegistry2.js +1 -1
  6. package/_internal/CrossfilterRegistry2.js.map +1 -0
  7. package/_internal/Dashboard.js +4 -0
  8. package/{components/Dashboard/_internal → _internal}/Dashboard.js.map +1 -1
  9. package/{components/Dashboard/_internal/reducer.js → _internal/Dashboard2.js} +44 -4
  10. package/_internal/Dashboard2.js.map +1 -0
  11. package/_internal/PdfExportButton.js +2 -0
  12. package/_internal/PdfExportButton2.js +417 -0
  13. package/_internal/PdfExportButton2.js.map +1 -0
  14. package/_internal/TimeSeriesBarChart.js +2 -0
  15. package/{components/TimeSeriesBarChart/_internal → _internal}/TimeSeriesBarChart.js.map +1 -1
  16. package/{components/TimeSeriesBarChart/_internal → _internal}/TimeSeriesBarChart2.js +119 -10
  17. package/_internal/TimeSeriesBarChart2.js.map +1 -0
  18. package/_internal/WithFilters.js +2 -0
  19. package/_internal/WithFilters2.js +701 -0
  20. package/_internal/WithFilters2.js.map +1 -0
  21. package/{_virtual/_internal/_rollupPluginBabelHelpers.js → _internal/context.js} +11 -2
  22. package/_internal/context.js.map +1 -0
  23. package/{components/Dashboard/_internal → _internal}/types.js +1 -1
  24. package/_internal/types.js.map +1 -0
  25. package/index.js +15 -11
  26. package/index.js.map +1 -1
  27. package/package.json +2 -2
  28. package/_virtual/_internal/_rollupPluginBabelHelpers.js.map +0 -1
  29. package/components/ChartEmptyState/_internal/ChartEmptyState.js +0 -2
  30. package/components/ChartEmptyState/_internal/ChartEmptyState2.js.map +0 -1
  31. package/components/ChartEmptyState/_internal/styles.js +0 -35
  32. package/components/ChartEmptyState/_internal/styles.js.map +0 -1
  33. package/components/CrossfilterRegistry/_internal/CrossfilterRegistry.js +0 -2
  34. package/components/CrossfilterRegistry/_internal/CrossfilterRegistry2.js.map +0 -1
  35. package/components/Dashboard/_internal/Dashboard.js +0 -5
  36. package/components/Dashboard/_internal/Dashboard2.js +0 -46
  37. package/components/Dashboard/_internal/Dashboard2.js.map +0 -1
  38. package/components/Dashboard/_internal/context.js +0 -11
  39. package/components/Dashboard/_internal/context.js.map +0 -1
  40. package/components/Dashboard/_internal/reducer.js.map +0 -1
  41. package/components/Dashboard/_internal/types.js.map +0 -1
  42. package/components/PdfExportButton/_internal/PdfDocument.js +0 -173
  43. package/components/PdfExportButton/_internal/PdfDocument.js.map +0 -1
  44. package/components/PdfExportButton/_internal/PdfExportButton.js +0 -2
  45. package/components/PdfExportButton/_internal/PdfExportButton2.js +0 -110
  46. package/components/PdfExportButton/_internal/PdfExportButton2.js.map +0 -1
  47. package/components/PdfExportButton/_internal/styles.js +0 -146
  48. package/components/PdfExportButton/_internal/styles.js.map +0 -1
  49. package/components/TimeSeriesBarChart/_internal/TimeSeriesBarChart.js +0 -3
  50. package/components/TimeSeriesBarChart/_internal/TimeSeriesBarChart2.js.map +0 -1
  51. package/components/TimeSeriesBarChart/_internal/styles.js +0 -98
  52. package/components/TimeSeriesBarChart/_internal/styles.js.map +0 -1
  53. package/components/TimeSeriesBarChart/_internal/types.js +0 -22
  54. package/components/TimeSeriesBarChart/_internal/types.js.map +0 -1
  55. package/components/WithFilters/_internal/FilterableBarChart.js +0 -152
  56. package/components/WithFilters/_internal/FilterableBarChart.js.map +0 -1
  57. package/components/WithFilters/_internal/FilterableDataGrid.js +0 -51
  58. package/components/WithFilters/_internal/FilterableDataGrid.js.map +0 -1
  59. package/components/WithFilters/_internal/FilterablePieChart.js +0 -160
  60. package/components/WithFilters/_internal/FilterablePieChart.js.map +0 -1
  61. package/components/WithFilters/_internal/FilterableScatterPlot.js +0 -252
  62. package/components/WithFilters/_internal/FilterableScatterPlot.js.map +0 -1
  63. package/components/WithFilters/_internal/WithFilters.js +0 -2
  64. package/components/WithFilters/_internal/WithFilters2.js +0 -36
  65. package/components/WithFilters/_internal/WithFilters2.js.map +0 -1
  66. package/hooks/_internal/useCategoricalChartAsListbox.js +0 -94
  67. package/hooks/_internal/useCategoricalChartAsListbox.js.map +0 -1
  68. package/utils/groupReducers/_internal/groupReduceCount.js +0 -5
  69. package/utils/groupReducers/_internal/groupReduceCount.js.map +0 -1
  70. package/utils/groupReducers/_internal/groupReduceSum.js +0 -5
  71. package/utils/groupReducers/_internal/groupReduceSum.js.map +0 -1
  72. /package/{components/ChartEmptyState/_internal → _internal}/ChartEmptyState.js.map +0 -0
  73. /package/{components/CrossfilterRegistry/_internal → _internal}/CrossfilterRegistry.js.map +0 -0
  74. /package/{components/PdfExportButton/_internal → _internal}/PdfExportButton.js.map +0 -0
  75. /package/{components/WithFilters/_internal → _internal}/WithFilters.js.map +0 -0
@@ -0,0 +1,2 @@
1
+ export { C as ChartEmptyState } from './ChartEmptyState2.js';
2
+ //# sourceMappingURL=ChartEmptyState.js.map
@@ -1,6 +1,37 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import { mdiRefresh } from '@redsift/icons';
3
- import { StyledChartEmptyState, StyledResetButton } from './styles.js';
3
+ import styled from 'styled-components';
4
+ import { Button } from '@redsift/design-system';
5
+
6
+ /**
7
+ * Component style.
8
+ */
9
+ const StyledChartEmptyState = styled.div`
10
+ display: flex;
11
+ flex-direction: column;
12
+ justify-content: center;
13
+ align-items: center;
14
+ margin-top: 16px;
15
+
16
+ .redsift-chart-empty-state__title {
17
+ font-family: var(--redsift-typography-h4-font-family);
18
+ font-size: var(--redsift-typography-h4-font-size);
19
+ font-weight: var(--redsift-typography-h4-font-weight);
20
+ line-height: var(--redsift-typography-h4-line-height);
21
+ }
22
+
23
+ .redsift-chart-empty-state__subtitle {
24
+ font-family: var(--redsift-typography-body-font-family);
25
+ font-size: var(--redsift-typography-body-font-size);
26
+ font-weight: var(--redsift-typography-body-font-weight);
27
+ line-height: var(--redsift-typography-body-line-height);
28
+ margin-top: 8px;
29
+ text-align: center;
30
+ }
31
+ `;
32
+ const StyledResetButton = styled(Button)`
33
+ margin-top: 8px;
34
+ `;
4
35
 
5
36
  const COMPONENT_NAME = 'ChartEmptyState';
6
37
  const CLASSNAME = 'redsift-chart-empty-state';
@@ -119,5 +150,5 @@ const ChartEmptyState = /*#__PURE__*/forwardRef((props, ref) => {
119
150
  ChartEmptyState.className = CLASSNAME;
120
151
  ChartEmptyState.displayName = COMPONENT_NAME;
121
152
 
122
- export { ChartEmptyState };
153
+ export { ChartEmptyState as C };
123
154
  //# sourceMappingURL=ChartEmptyState2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartEmptyState2.js","sources":["../../src/components/ChartEmptyState/styles.ts","../../src/components/ChartEmptyState/ChartEmptyState.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport { Button } from '@redsift/design-system';\n\n/**\n * Component style.\n */\nexport const StyledChartEmptyState = styled.div`\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n margin-top: 16px;\n\n .redsift-chart-empty-state__title {\n font-family: var(--redsift-typography-h4-font-family);\n font-size: var(--redsift-typography-h4-font-size);\n font-weight: var(--redsift-typography-h4-font-weight);\n line-height: var(--redsift-typography-h4-line-height);\n }\n\n .redsift-chart-empty-state__subtitle {\n font-family: var(--redsift-typography-body-font-family);\n font-size: var(--redsift-typography-body-font-size);\n font-weight: var(--redsift-typography-body-font-weight);\n line-height: var(--redsift-typography-body-line-height);\n margin-top: 8px;\n text-align: center;\n }\n`;\n\nexport const StyledResetButton = styled(Button)`\n margin-top: 8px;\n`;\n","import React, { forwardRef, RefObject } from 'react';\nimport { mdiRefresh } from '@redsift/icons';\nimport { Comp } from '@redsift/design-system';\n\nimport { ChartEmptyStateProps } from './types';\nimport { StyledChartEmptyState, StyledResetButton } from './styles';\n\nconst COMPONENT_NAME = 'ChartEmptyState';\nconst CLASSNAME = 'redsift-chart-empty-state';\n\nexport const ChartEmptyState: Comp<ChartEmptyStateProps, HTMLDivElement> = forwardRef((props, ref) => {\n const {\n onReset,\n title = 'No Data Available',\n subtitle = 'Please check the applied filters',\n resetLabel = 'Reset all filters',\n } = props;\n\n return (\n <StyledChartEmptyState ref={ref as RefObject<HTMLDivElement>} className=\"redsift-chart-empty-state\">\n <div className={`${ChartEmptyState.className}__img`}>\n <svg width=\"86\" height=\"86\" viewBox=\"0 0 86 86\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n opacity=\"0.2\"\n d=\"M43 86C66.7482 86 86 66.7482 86 43C86 19.2518 66.7482 0 43 0C19.2518 0 0 19.2518 0 43C0 66.7482 19.2518 86 43 86Z\"\n fill=\"#4285F4\"\n />\n <path\n opacity=\"0.4\"\n d=\"M13.4479 45.9299C13.4479 44.8254 14.3434 43.9299 15.4479 43.9299H29.3785C30.4831 43.9299 31.3785 44.8254 31.3785 45.9299V60.0675H13.4479V45.9299Z\"\n fill=\"#4285F4\"\n />\n <path\n opacity=\"0.4\"\n d=\"M34.0681 27.9993C34.0681 26.8948 34.9636 25.9993 36.0681 25.9993H49.9987C51.1033 25.9993 51.9987 26.8948 51.9987 27.9993V60.0675H34.0681V27.9993Z\"\n fill=\"#4285F4\"\n />\n <path\n opacity=\"0.4\"\n d=\"M54.6883 53.1022C54.6883 51.9976 55.5837 51.1022 56.6883 51.1022H70.6189C71.7235 51.1022 72.6189 51.9976 72.6189 53.1022V60.0675H54.6883V53.1022Z\"\n fill=\"#4285F4\"\n />\n <line x1=\"10.3618\" y1=\"60.464\" x2=\"75.705\" y2=\"60.464\" stroke=\"#305AA2\" strokeLinecap=\"round\" />\n <path d=\"M48.7345 25.9993H46.9414L51.9987 28.9192V27.8839L48.7345 25.9993Z\" fill=\"#4285F4\" />\n <path d=\"M41.5622 25.9993L51.9987 32.0249V30.9896L43.3553 25.9993H41.5622Z\" fill=\"#4285F4\" />\n <path d=\"M36.183 25.9993L51.9987 35.1305V34.0953L37.9761 25.9993H36.183Z\" fill=\"#4285F4\" />\n <path\n d=\"M34.0771 27.622C34.0681 27.6758 34.0681 27.7296 34.0681 27.7924V27.8839L51.9987 38.2362V37.201L34.281 26.9716C34.1776 27.171 34.097 27.3834 34.0771 27.622Z\"\n fill=\"#4285F4\"\n />\n <path d=\"M34.0681 30.9896L51.9987 41.3418V40.3066L34.0681 29.9544V30.9896Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 34.0953L51.9987 44.4475V43.4123L34.0681 33.06V34.0953Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 37.2009L51.9987 47.5531V46.518L34.0681 36.1657V37.2009Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 40.3066L51.9987 50.6588V49.6236L34.0681 39.2714V40.3066Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 43.4123L51.9987 53.7645V52.7293L34.0681 42.377V43.4123Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 46.518L51.9987 56.8702V55.835L34.0681 45.4827V46.518Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 49.6236L51.9987 59.9759V58.9407L34.0681 48.5884V49.6236Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 52.7293L46.7782 60.0675H48.5712L34.0681 51.6941V52.7293Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 55.835L41.399 60.0675H43.192L34.0681 54.7997V55.835Z\" fill=\"#4285F4\" />\n <path d=\"M34.0681 58.9406L36.0198 60.0675H37.8129L34.0681 57.9054V58.9406Z\" fill=\"#4285F4\" />\n <circle\n opacity=\"0.6\"\n cx=\"50.5506\"\n cy=\"29.9304\"\n r=\"10.1549\"\n transform=\"rotate(-45 50.5506 29.9304)\"\n fill=\"white\"\n stroke=\"#305AA2\"\n strokeWidth=\"3\"\n />\n <circle\n cx=\"50.5506\"\n cy=\"29.9304\"\n r=\"10.1549\"\n transform=\"rotate(-45 50.5506 29.9304)\"\n stroke=\"#305AA2\"\n strokeWidth=\"3\"\n />\n <path\n d=\"M59.2186 36.4771L58.1579 35.4164L56.0366 37.5377L57.0973 38.5984L59.2186 36.4771ZM65.9725 47.4736C66.5582 48.0594 67.508 48.0594 68.0938 47.4736C68.6796 46.8878 68.6796 45.938 68.0938 45.3522L65.9725 47.4736ZM57.0973 38.5984L65.9725 47.4736L68.0938 45.3522L59.2186 36.4771L57.0973 38.5984Z\"\n fill=\"#305AA2\"\n />\n </svg>\n </div>\n <div className={`${ChartEmptyState.className}__title`}>{title}</div>\n <div className={`${ChartEmptyState.className}__subtitle`}>{subtitle}</div>\n {onReset ? (\n <StyledResetButton variant=\"unstyled\" leftIcon={mdiRefresh} onClick={onReset}>\n {resetLabel}\n </StyledResetButton>\n ) : null}\n </StyledChartEmptyState>\n );\n});\n\nChartEmptyState.className = CLASSNAME;\nChartEmptyState.displayName = COMPONENT_NAME;\n"],"names":["StyledChartEmptyState","styled","div","StyledResetButton","Button","COMPONENT_NAME","CLASSNAME","ChartEmptyState","forwardRef","props","ref","onReset","title","subtitle","resetLabel","React","createElement","className","width","height","viewBox","fill","xmlns","opacity","d","x1","y1","x2","y2","stroke","strokeLinecap","cx","cy","r","transform","strokeWidth","variant","leftIcon","mdiRefresh","onClick","displayName"],"mappings":";;;;;AAGA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAGC,MAAM,CAACC,GAAI,CAAA;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAA;AAEM,MAAMC,iBAAiB,GAAGF,MAAM,CAACG,MAAM,CAAE,CAAA;AAChD;AACA,CAAC;;ACzBD,MAAMC,cAAc,GAAG,iBAAiB,CAAA;AACxC,MAAMC,SAAS,GAAG,2BAA2B,CAAA;AAEtC,MAAMC,eAA2D,gBAAGC,UAAU,CA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GAChB,CAAC,eACFpB,KAAA,CAAAC,aAAA,CAAA,QAAA,EAAA;AACEe,IAAAA,EAAE,EAAC,SAAS;AACZC,IAAAA,EAAE,EAAC,SAAS;AACZC,IAAAA,CAAC,EAAC,SAAS;AACXC,IAAAA,SAAS,EAAC,6BAA6B;AACvCL,IAAAA,MAAM,EAAC,SAAS;AAChBM,IAAAA,WAAW,EAAC,GAAA;AAAG,GAChB,CAAC,eACFpB,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;AACEQ,IAAAA,CAAC,EAAC,mSAAmS;AACrSH,IAAAA,IAAI,EAAC,SAAA;AAAS,GACf,CACE,CACF,CAAC,eACNN,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAG,CAAA,EAAEV,eAAe,CAACU,SAAU,CAAA,OAAA,CAAA;AAAS,GAAA,EAAEL,KAAW,CAAC,eACpEG,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAKC,IAAAA,SAAS,EAAG,CAAA,EAAEV,eAAe,CAACU,SAAU,CAAA,UAAA,CAAA;GAAcJ,EAAAA,QAAc,CAAC,EACzEF,OAAO,gBACNI,KAAA,CAAAC,aAAA,CAACb,iBAAiB,EAAA;AAACiC,IAAAA,OAAO,EAAC,UAAU;AAACC,IAAAA,QAAQ,EAAEC,UAAW;AAACC,IAAAA,OAAO,EAAE5B,OAAAA;AAAQ,GAAA,EAC1EG,UACgB,CAAC,GAClB,IACiB,CAAC,CAAA;AAE5B,CAAC,EAAC;AAEFP,eAAe,CAACU,SAAS,GAAGX,SAAS,CAAA;AACrCC,eAAe,CAACiC,WAAW,GAAGnC,cAAc;;;;"}
@@ -0,0 +1,2 @@
1
+ export { C as CrossfilterRegistry } from './CrossfilterRegistry2.js';
2
+ //# sourceMappingURL=CrossfilterRegistry.js.map
@@ -19,5 +19,5 @@ const CrossfilterRegistry = (() => {
19
19
  };
20
20
  })();
21
21
 
22
- export { CrossfilterRegistry };
22
+ export { CrossfilterRegistry as C };
23
23
  //# sourceMappingURL=CrossfilterRegistry2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CrossfilterRegistry2.js","sources":["../../src/components/CrossfilterRegistry/CrossfilterRegistry.ts"],"sourcesContent":["import { JSONArray, TNdx } from '../../types';\nimport crossfilter from 'crossfilter2';\n\nexport const CrossfilterRegistry = (() => {\n const instances = new WeakMap<JSONArray, TNdx>();\n\n const get = (data: JSONArray): TNdx => {\n let instance = instances.get(data);\n\n if (!instance) {\n instance = crossfilter(data);\n instances.set(data, instance);\n }\n\n return instance;\n };\n\n const remove = (data: JSONArray): void => {\n instances.delete(data);\n };\n\n return {\n get,\n remove,\n };\n})();\n"],"names":["CrossfilterRegistry","instances","WeakMap","get","data","instance","crossfilter","set","remove","delete"],"mappings":";;AAGaA,MAAAA,mBAAmB,GAAG,CAAC,MAAM;AACxC,EAAA,MAAMC,SAAS,GAAG,IAAIC,OAAO,EAAmB,CAAA;EAEhD,MAAMC,GAAG,GAAIC,IAAe,IAAW;AACrC,IAAA,IAAIC,QAAQ,GAAGJ,SAAS,CAACE,GAAG,CAACC,IAAI,CAAC,CAAA;IAElC,IAAI,CAACC,QAAQ,EAAE;AACbA,MAAAA,QAAQ,GAAGC,WAAW,CAACF,IAAI,CAAC,CAAA;AAC5BH,MAAAA,SAAS,CAACM,GAAG,CAACH,IAAI,EAAEC,QAAQ,CAAC,CAAA;AAC/B,KAAA;AAEA,IAAA,OAAOA,QAAQ,CAAA;GAChB,CAAA;EAED,MAAMG,MAAM,GAAIJ,IAAe,IAAW;AACxCH,IAAAA,SAAS,CAACQ,MAAM,CAACL,IAAI,CAAC,CAAA;GACvB,CAAA;EAED,OAAO;IACLD,GAAG;AACHK,IAAAA,MAAAA;GACD,CAAA;AACH,CAAC;;;;"}
@@ -0,0 +1,4 @@
1
+ export { D as Dashboard, a as DashboardReducer } from './Dashboard2.js';
2
+ export { D as DashboardContext, i as initialState } from './context.js';
3
+ export { D as DashboardReducerActionType } from './types.js';
4
+ //# sourceMappingURL=Dashboard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
1
+ {"version":3,"file":"Dashboard.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,5 +1,9 @@
1
- import { objectSpread2 as _objectSpread2 } from '../../../_virtual/_internal/_rollupPluginBabelHelpers.js';
2
- import { DashboardReducerActionType } from './types.js';
1
+ import { _ as _objectSpread2, a as _objectWithoutProperties, b as _extends, D as DashboardContext } from './context.js';
2
+ import React, { forwardRef, useRef, useState, useReducer, useMemo } from 'react';
3
+ import classNames from 'classnames';
4
+ import { useGridApiRef } from '@mui/x-data-grid-pro';
5
+ import { D as DashboardReducerActionType } from './types.js';
6
+ import { C as CrossfilterRegistry } from './CrossfilterRegistry2.js';
3
7
 
4
8
  const areEquals = (tableFilter, actionFilter) => {
5
9
  return tableFilter.columnField === actionFilter.columnField && tableFilter.operatorValue === actionFilter.operatorValue;
@@ -57,5 +61,41 @@ const DashboardReducer = (state, action) => {
57
61
  }
58
62
  };
59
63
 
60
- export { DashboardReducer };
61
- //# sourceMappingURL=reducer.js.map
64
+ const _excluded = ["children", "className", "data", "dataGridApiRef"];
65
+ const COMPONENT_NAME = 'Dashboard';
66
+ const CLASSNAME = 'redsift-dashboard-container';
67
+ const Dashboard = /*#__PURE__*/forwardRef((props, ref) => {
68
+ const {
69
+ children,
70
+ className,
71
+ data,
72
+ dataGridApiRef: propsDataGridApiRef
73
+ } = props,
74
+ forwardedProps = _objectWithoutProperties(props, _excluded);
75
+ const providerRef = ref || useRef();
76
+ const dataGridApiRef = propsDataGridApiRef || useGridApiRef();
77
+ const [updateContext, setUpdateContext] = useState(false);
78
+ const [state, dispatch] = useReducer(DashboardReducer, {
79
+ tableFilters: []
80
+ });
81
+ const value = useMemo(() => ({
82
+ dashboardRef: providerRef,
83
+ data,
84
+ dataGridApiRef,
85
+ dispatch,
86
+ ndx: CrossfilterRegistry.get(data),
87
+ state,
88
+ toggleUpdateContext: () => setUpdateContext(!updateContext)
89
+ }), [data, state, updateContext]);
90
+ return /*#__PURE__*/React.createElement("div", _extends({}, forwardedProps, {
91
+ className: classNames(Dashboard.className, className),
92
+ ref: providerRef
93
+ }), /*#__PURE__*/React.createElement(DashboardContext.Provider, {
94
+ value: value
95
+ }, children));
96
+ });
97
+ Dashboard.className = CLASSNAME;
98
+ Dashboard.displayName = COMPONENT_NAME;
99
+
100
+ export { Dashboard as D, DashboardReducer as a };
101
+ //# sourceMappingURL=Dashboard2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard2.js","sources":["../../src/components/Dashboard/reducer.ts","../../src/components/Dashboard/Dashboard.tsx"],"sourcesContent":["import { GridFilterItem } from '@redsift/table';\nimport {\n DashboardReducerState,\n DashboardReducerAction,\n DashboardReducerActionType,\n} from './types';\n\nconst areEquals = (\n tableFilter: GridFilterItem,\n actionFilter: GridFilterItem\n) => {\n return (\n tableFilter.columnField === actionFilter.columnField &&\n tableFilter.operatorValue === actionFilter.operatorValue\n );\n};\n\nconst addOrUpdateFilter = (\n oldFilters: GridFilterItem[],\n newFilter: GridFilterItem\n) => {\n if (oldFilters.find((f) => areEquals(f, newFilter))) {\n return oldFilters.map((f) => {\n if (areEquals(f, newFilter)) {\n return newFilter;\n }\n return f;\n });\n } else {\n return [...oldFilters, newFilter];\n }\n};\n\nconst addOrUpdateFilters = (\n oldFilters: GridFilterItem[],\n newFilters: GridFilterItem[]\n) => {\n let updatedFilters = oldFilters;\n for (let i = 0; i < newFilters.length; i++) {\n updatedFilters = addOrUpdateFilter(updatedFilters, newFilters[i]);\n }\n return updatedFilters;\n};\n\nconst replaceFilters = (newFilters: GridFilterItem | GridFilterItem[]) => {\n return Array.isArray(newFilters) ? newFilters : [newFilters];\n};\n\nconst removeFilter = (\n oldFilters: GridFilterItem[],\n newFilter: GridFilterItem\n) => {\n return oldFilters.filter((f) => !areEquals(f, newFilter));\n};\n\nconst removeAllFilters = () => {\n return [] as GridFilterItem[];\n};\n\nexport const DashboardReducer = (\n state: DashboardReducerState,\n action: DashboardReducerAction\n): DashboardReducerState => {\n switch (action.type) {\n case DashboardReducerActionType.ResetFilter:\n return {\n ...state,\n tableFilters: removeFilter(\n state.tableFilters,\n action.filter as GridFilterItem\n ),\n };\n case DashboardReducerActionType.ResetFilters:\n return { ...state, tableFilters: removeAllFilters() };\n case DashboardReducerActionType.FilterTable:\n return {\n ...state,\n tableFilters: addOrUpdateFilter(\n state.tableFilters,\n action.filter as GridFilterItem\n ),\n };\n\n case DashboardReducerActionType.FilterTableBatch:\n return {\n ...state,\n tableFilters: replaceFilters(action.filter!),\n };\n\n case DashboardReducerActionType.AppendFilterTableBatch:\n return {\n ...state,\n tableFilters: addOrUpdateFilters(\n state.tableFilters,\n action.filter as GridFilterItem[]\n ),\n };\n }\n};\n","import React, { forwardRef, RefObject, useMemo, useReducer, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { useGridApiRef } from '@mui/x-data-grid-pro';\n\nimport { Comp } from '@redsift/design-system';\nimport { DashboardContext } from './context';\nimport { DashboardContextProps, DashboardProps } from './types';\nimport { DashboardReducer } from './reducer';\nimport { CrossfilterRegistry } from '../CrossfilterRegistry';\n\nconst COMPONENT_NAME = 'Dashboard';\nconst CLASSNAME = 'redsift-dashboard-container';\n\nexport const Dashboard: Comp<DashboardProps, HTMLDivElement> = forwardRef((props, ref) => {\n const { children, className, data, dataGridApiRef: propsDataGridApiRef, ...forwardedProps } = props;\n\n const providerRef = ref || useRef<HTMLDivElement>();\n const dataGridApiRef = propsDataGridApiRef || useGridApiRef();\n const [updateContext, setUpdateContext] = useState(false);\n\n const [state, dispatch] = useReducer(DashboardReducer, {\n tableFilters: [],\n });\n\n const value = useMemo<DashboardContextProps>(\n () => ({\n dashboardRef: providerRef as RefObject<HTMLDivElement>,\n data,\n dataGridApiRef,\n dispatch,\n ndx: CrossfilterRegistry.get(data),\n state,\n toggleUpdateContext: () => setUpdateContext(!updateContext),\n }),\n [data, state, updateContext]\n );\n\n return (\n <div\n {...forwardedProps}\n className={classNames(Dashboard.className, className)}\n ref={providerRef as RefObject<HTMLDivElement>}\n >\n <DashboardContext.Provider value={value as DashboardContextProps}>{children}</DashboardContext.Provider>\n </div>\n );\n});\nDashboard.className = CLASSNAME;\nDashboard.displayName = COMPONENT_NAME;\n"],"names":["areEquals","tableFilter","actionFilter","columnField","operatorValue","addOrUpdateFilter","oldFilters","newFilter","find","f","map","addOrUpdateFilters","newFilters","updatedFilters","i","length","replaceFilters","Array","isArray","removeFilter","filter","removeAllFilters","DashboardReducer","state","action","type","DashboardReducerActionType","ResetFilter","_objectSpread","tableFilters","ResetFilters","FilterTable","FilterTableBatch","AppendFilterTableBatch","COMPONENT_NAME","CLASSNAME","Dashboard","forwardRef","props","ref","children","className","data","dataGridApiRef","propsDataGridApiRef","forwardedProps","_objectWithoutProperties","_excluded","providerRef","useRef","useGridApiRef","updateContext","setUpdateContext","useState","dispatch","useReducer","value","useMemo","dashboardRef","ndx","CrossfilterRegistry","get","toggleUpdateContext","React","createElement","_extends","classNames","DashboardContext","Provider","displayName"],"mappings":";;;;;;;AAOA,MAAMA,SAAS,GAAGA,CAChBC,WAA2B,EAC3BC,YAA4B,KACzB;AACH,EAAA,OACED,WAAW,CAACE,WAAW,KAAKD,YAAY,CAACC,WAAW,IACpDF,WAAW,CAACG,aAAa,KAAKF,YAAY,CAACE,aAAa,CAAA;AAE5D,CAAC,CAAA;AAED,MAAMC,iBAAiB,GAAGA,CACxBC,UAA4B,EAC5BC,SAAyB,KACtB;AACH,EAAA,IAAID,UAAU,CAACE,IAAI,CAAEC,CAAC,IAAKT,SAAS,CAACS,CAAC,EAAEF,SAAS,CAAC,CAAC,EAAE;AACnD,IAAA,OAAOD,UAAU,CAACI,GAAG,CAAED,CAAC,IAAK;AAC3B,MAAA,IAAIT,SAAS,CAACS,CAAC,EAAEF,SAAS,CAAC,EAAE;AAC3B,QAAA,OAAOA,S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+ export { P as PdfExportButton } from './PdfExportButton2.js';
2
+ //# sourceMappingURL=PdfExportButton.js.map
@@ -0,0 +1,417 @@
1
+ import { a as _objectWithoutProperties, D as DashboardContext, b as _extends } from './context.js';
2
+ import React, { forwardRef, useState, useContext, useEffect } from 'react';
3
+ import { gridFilteredSortedRowEntriesSelector, gridVisibleColumnDefinitionsSelector, gridColumnsTotalWidthSelector } from '@mui/x-data-grid-pro';
4
+ import classNames from 'classnames';
5
+ import { saveAs } from 'file-saver';
6
+ import { Font, StyleSheet, Document, Page, View, Image, Text, pdf } from '@react-pdf/renderer';
7
+ import domToImage from 'dom-to-image';
8
+ import { Button, Spinner, RedsiftColorBlueD1 } from '@redsift/design-system';
9
+
10
+ // istanbul ignore file
11
+ const BACKGROUND_COLOR = '#F8F8F8';
12
+ const GREY_1 = '#E2E6EA';
13
+ const GREY_2 = '#bff0fd';
14
+ const getPdfStyles = primaryColor => {
15
+ Font.register({
16
+ family: 'Source Code Pro',
17
+ fonts: [{
18
+ src: 'https://fonts.gstatic.com/s/sourcecodepro/v7/HI_SiYsKILxRpg3hIP6sJ7fM7PqlM-vT.ttf'
19
+ }]
20
+ });
21
+ Font.register({
22
+ family: 'Roboto',
23
+ fonts: [{
24
+ fontWeight: 700,
25
+ src: 'https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/fonts/roboto/Roboto-Regular.ttf'
26
+ }, {
27
+ fontWeight: 400,
28
+ src: 'https://cdnjs.cloudflare.com/ajax/libs/ink/3.1.10/fonts/Roboto/roboto-light-webfont.ttf'
29
+ }]
30
+ });
31
+ return StyleSheet.create({
32
+ page: {
33
+ borderTopStyle: 'solid',
34
+ borderTopWidth: 32,
35
+ borderTopColor: primaryColor,
36
+ borderBottomStyle: 'solid',
37
+ borderBottomWidth: 6,
38
+ borderBottomColor: primaryColor,
39
+ backgroundColor: BACKGROUND_COLOR,
40
+ paddingTop: 20,
41
+ paddingBottom: 40
42
+ },
43
+ logoContainer: {
44
+ margin: 0,
45
+ paddingBottom: 10,
46
+ alignItems: 'center',
47
+ width: '100%'
48
+ },
49
+ logo: {
50
+ width: 'auto',
51
+ height: 30
52
+ },
53
+ introductionContainer: {
54
+ lineHeight: 1.4,
55
+ textAlign: 'center',
56
+ marginHorizontal: 40,
57
+ marginVertical: 10
58
+ },
59
+ introductionText: {
60
+ fontSize: 8,
61
+ fontFamily: 'Roboto',
62
+ fontWeight: 400,
63
+ color: 'black'
64
+ },
65
+ pageNumber: {
66
+ fontFamily: 'Source Code Pro',
67
+ position: 'absolute',
68
+ fontSize: 6,
69
+ bottom: 5,
70
+ right: 20,
71
+ left: 0,
72
+ textAlign: 'right',
73
+ color: 'black'
74
+ },
75
+ pageContinue: {
76
+ fontSize: 8,
77
+ fontFamily: 'Roboto',
78
+ fontWeight: 400,
79
+ top: -10,
80
+ left: 20
81
+ },
82
+ tableContainer: {
83
+ backgroundColor: 'white',
84
+ marginHorizontal: 20,
85
+ marginVertical: 10,
86
+ paddingTop: 10,
87
+ paddingLeft: 10,
88
+ borderRightWidth: 1,
89
+ borderBottomWidth: 1,
90
+ borderRightColor: BACKGROUND_COLOR,
91
+ borderBottomColor: GREY_1,
92
+ width: 'auto'
93
+ },
94
+ tableRowContainer: {
95
+ flexDirection: 'row',
96
+ borderBottomColor: GREY_2,
97
+ alignItems: 'flex-start',
98
+ fontSize: 8,
99
+ marginLeft: 16,
100
+ marginRight: 24,
101
+ height: 'auto'
102
+ },
103
+ tableHeaderContainer: {
104
+ flexDirection: 'row',
105
+ alignItems: 'flex-start',
106
+ fontSize: 7,
107
+ fontFamily: 'Roboto',
108
+ fontWeight: 700,
109
+ marginLeft: 16,
110
+ marginRight: 24,
111
+ marginBottom: 12,
112
+ paddingTop: 12,
113
+ paddingBottom: 12,
114
+ borderBottomWidth: 2,
115
+ borderBottomColor: primaryColor
116
+ },
117
+ tableCellHeaderText: {
118
+ fontSize: 7,
119
+ fontFamily: 'Roboto',
120
+ fontWeight: 700,
121
+ color: 'black',
122
+ overflow: 'hidden'
123
+ },
124
+ tableCellText: {
125
+ fontSize: 6,
126
+ lineHeight: 1.5,
127
+ fontFamily: 'Roboto',
128
+ fontWeight: 400,
129
+ color: 'black',
130
+ overflow: 'hidden'
131
+ },
132
+ dashboardImageContainer: {
133
+ marginHorizontal: 20,
134
+ marginTop: 0,
135
+ marginBottom: 10
136
+ },
137
+ constraintsContainer: {
138
+ width: 'auto',
139
+ height: 'auto',
140
+ paddingVertical: 30,
141
+ textAlign: 'center'
142
+ },
143
+ constraints: {
144
+ fontSize: 6,
145
+ fontFamily: 'Roboto',
146
+ fontWeight: 700,
147
+ color: 'black'
148
+ }
149
+ });
150
+ };
151
+
152
+ // istanbul ignore file
153
+ const DEFAULT_COLUMN_WIDTH = 100;
154
+ const getWidthColumn = (width, totalW, nrColumns) => {
155
+ // calculation width column where the 7px margin between the columns is included
156
+ return `${Math.round(width * 100 / (totalW - 7 * (nrColumns - 1)))}%`;
157
+ };
158
+ const PdfTableRow = _ref => {
159
+ let {
160
+ rowIndex,
161
+ rowData,
162
+ columns,
163
+ styles,
164
+ totalWidth
165
+ } = _ref;
166
+ return /*#__PURE__*/React.createElement(View, {
167
+ style: styles.tableRowContainer,
168
+ key: `row-${rowIndex}`
169
+ }, columns.map((column, index) => {
170
+ const {
171
+ field,
172
+ width
173
+ } = column;
174
+ let totalW = totalWidth;
175
+ let nrColumns = columns.length;
176
+
177
+ // The checkbox in the table will not be printed
178
+ if (field === '__check__') {
179
+ totalW = totalW - (width || 50);
180
+ nrColumns = nrColumns - 1;
181
+ return;
182
+ }
183
+ const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);
184
+
185
+ // Empty value will print '-'
186
+ if (!rowData[field]) {
187
+ return /*#__PURE__*/React.createElement(View, {
188
+ style: {
189
+ width: widthColumn,
190
+ paddingVertical: 2,
191
+ marginRight: 7
192
+ },
193
+ key: `cell-${rowIndex}-${index}`
194
+ }, /*#__PURE__*/React.createElement(Text, {
195
+ style: styles.tableCellText
196
+ }, '-'));
197
+ }
198
+ return /*#__PURE__*/React.createElement(View, {
199
+ style: {
200
+ width: widthColumn,
201
+ paddingVertical: 2,
202
+ marginRight: 7
203
+ },
204
+ key: `cell-${rowIndex}-${index}`
205
+ }, /*#__PURE__*/React.createElement(Text, {
206
+ style: styles.tableCellText
207
+ }, Array.isArray(rowData[field]) ? rowData[field].join(', ') : rowData[field]));
208
+ }));
209
+ };
210
+ const PdfTable = _ref2 => {
211
+ let {
212
+ dataTable,
213
+ styles,
214
+ localeText
215
+ } = _ref2;
216
+ const {
217
+ data,
218
+ columns,
219
+ totalWidth
220
+ } = dataTable;
221
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
222
+ style: styles.tableHeaderContainer
223
+ }, columns.map(column => {
224
+ let totalW = totalWidth;
225
+ let nrColumns = columns.length;
226
+ const {
227
+ field,
228
+ headerName,
229
+ width
230
+ } = column;
231
+
232
+ // The checkbox in the table will not be printed
233
+ if (field === '__check__') {
234
+ totalW = totalW - (width || 50);
235
+ nrColumns = nrColumns - 1;
236
+ return;
237
+ }
238
+ const widthColumn = getWidthColumn(width || DEFAULT_COLUMN_WIDTH, totalW, nrColumns);
239
+ return /*#__PURE__*/React.createElement(View, {
240
+ style: {
241
+ width: widthColumn,
242
+ paddingVertical: 2,
243
+ marginRight: 7
244
+ },
245
+ key: `heading-${field}`
246
+ }, /*#__PURE__*/React.createElement(Text, {
247
+ style: styles.tableCellHeaderText
248
+ }, headerName));
249
+ })), /*#__PURE__*/React.createElement(View, null, data.map((row, index) => {
250
+ if (index < 1000) {
251
+ return /*#__PURE__*/React.createElement(PdfTableRow, {
252
+ key: index,
253
+ rowIndex: index,
254
+ rowData: data[index],
255
+ columns: columns,
256
+ styles: styles,
257
+ totalWidth: totalWidth
258
+ });
259
+ }
260
+ })), data.length >= 1000 ? /*#__PURE__*/React.createElement(View, {
261
+ style: styles.constraintsContainer
262
+ }, /*#__PURE__*/React.createElement(Text, {
263
+ style: styles.constraints
264
+ }, (localeText === null || localeText === void 0 ? void 0 : localeText.maxSizeDisclaimer) || 'Due to processing constraints this pdf is limited to the first 1000 rows of data.')) : null);
265
+ };
266
+ const Pagination = _ref3 => {
267
+ let {
268
+ styles
269
+ } = _ref3;
270
+ return /*#__PURE__*/React.createElement(Text, {
271
+ style: styles.pageNumber,
272
+ render: _ref4 => {
273
+ let {
274
+ pageNumber,
275
+ totalPages
276
+ } = _ref4;
277
+ return `${pageNumber}/${totalPages}`;
278
+ },
279
+ fixed: true
280
+ });
281
+ };
282
+ const PdfDocument = _ref5 => {
283
+ let {
284
+ dashboardImage,
285
+ introduction,
286
+ localeText,
287
+ logo,
288
+ dataTable,
289
+ primaryColor
290
+ } = _ref5;
291
+ const styles = getPdfStyles(primaryColor);
292
+ return /*#__PURE__*/React.createElement(Document, null, /*#__PURE__*/React.createElement(Page, {
293
+ size: "A4",
294
+ style: styles.page
295
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, logo ? /*#__PURE__*/React.createElement(View, {
296
+ style: styles.logoContainer
297
+ }, /*#__PURE__*/React.createElement(Image, {
298
+ src: logo,
299
+ style: styles.logo
300
+ })) : null, introduction ? /*#__PURE__*/React.createElement(View, {
301
+ style: styles.introductionContainer
302
+ }, /*#__PURE__*/React.createElement(Text, {
303
+ style: styles.introductionText
304
+ }, introduction)) : null, dashboardImage ? /*#__PURE__*/React.createElement(View, {
305
+ style: styles.dashboardImageContainer
306
+ }, /*#__PURE__*/React.createElement(Image, {
307
+ src: dashboardImage
308
+ })) : null, dataTable ? /*#__PURE__*/React.createElement(View, {
309
+ style: styles.tableContainer
310
+ }, /*#__PURE__*/React.createElement(PdfTable, {
311
+ dataTable: dataTable,
312
+ styles: styles,
313
+ localeText: localeText
314
+ })) : null, /*#__PURE__*/React.createElement(Pagination, {
315
+ styles: styles
316
+ }))));
317
+ };
318
+
319
+ const _excluded = ["children", "className", "componentRef", "fileName", "introduction", "localeText", "logo", "onClick", "primaryColor"];
320
+ const COMPONENT_NAME = 'PdfExportButton';
321
+ const CLASSNAME = 'redsift-pdf-export-button';
322
+ const getDashboardImage = async componentRef => {
323
+ var _componentRef$current, _componentRef$current2, _componentRef$current3, _componentRef$current4;
324
+ const filter = el => {
325
+ const classList = el.classList;
326
+ return !(classList !== null && classList !== void 0 && classList.contains('redsift-datagrid') || classList !== null && classList !== void 0 && classList.contains('redsift-button'));
327
+ };
328
+ const dashboardHeight = componentRef.current.getBoundingClientRect().height;
329
+ const datagridHeight = ((_componentRef$current = componentRef.current) === null || _componentRef$current === void 0 ? void 0 : (_componentRef$current2 = _componentRef$current.getElementsByClassName('redsift-datagrid')) === null || _componentRef$current2 === void 0 ? void 0 : (_componentRef$current3 = _componentRef$current2[0]) === null || _componentRef$current3 === void 0 ? void 0 : (_componentRef$current4 = _componentRef$current3.getBoundingClientRect()) === null || _componentRef$current4 === void 0 ? void 0 : _componentRef$current4.height) || 0;
330
+ return new Promise(resolve => {
331
+ domToImage.toPng(componentRef.current, {
332
+ filter,
333
+ height: dashboardHeight - datagridHeight
334
+ }).then(function (dataUrl) {
335
+ resolve(dataUrl);
336
+ }).catch(() => {
337
+ resolve('');
338
+ });
339
+ });
340
+ };
341
+ const PdfExportButton = /*#__PURE__*/forwardRef((props, ref) => {
342
+ const {
343
+ children,
344
+ className,
345
+ componentRef: propComponentRef,
346
+ fileName,
347
+ introduction,
348
+ localeText,
349
+ logo,
350
+ onClick,
351
+ primaryColor
352
+ } = props,
353
+ forwardedProps = _objectWithoutProperties(props, _excluded);
354
+ const [componentRef, setComponentRef] = useState(propComponentRef);
355
+ const [isLoading, setIsLoading] = useState(false);
356
+ const {
357
+ dashboardRef,
358
+ dataGridApiRef
359
+ } = useContext(DashboardContext);
360
+ useEffect(() => {
361
+ if (!componentRef || !componentRef.current) {
362
+ setComponentRef(dashboardRef);
363
+ }
364
+ }, [dashboardRef]);
365
+ const exportPdf = async () => {
366
+ if (onClick) {
367
+ onClick();
368
+ }
369
+ setIsLoading(true);
370
+ try {
371
+ const dashboardImage = await getDashboardImage(componentRef || dashboardRef);
372
+ let dataTable;
373
+ if (dataGridApiRef && dataGridApiRef.current && Object.keys(dataGridApiRef.current).length) {
374
+ dataTable = {
375
+ data: gridFilteredSortedRowEntriesSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId).slice(0, 1000).map(_ref => {
376
+ let {
377
+ model
378
+ } = _ref;
379
+ return model;
380
+ }),
381
+ columns: gridVisibleColumnDefinitionsSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId),
382
+ totalWidth: gridColumnsTotalWidthSelector(dataGridApiRef.current.state, dataGridApiRef.current.instanceId)
383
+ };
384
+ }
385
+ const doc = /*#__PURE__*/React.createElement(PdfDocument, {
386
+ localeText: localeText,
387
+ dashboardImage: dashboardImage,
388
+ introduction: introduction,
389
+ logo: logo,
390
+ primaryColor: primaryColor || RedsiftColorBlueD1,
391
+ dataTable: dataTable
392
+ });
393
+ const asPdf = pdf([]);
394
+ asPdf.updateContainer(doc);
395
+ const blob = await asPdf.toBlob();
396
+ saveAs(blob, fileName || 'redsift-dashboard.pdf');
397
+ } catch (e) {
398
+ console.log('error:', e);
399
+ }
400
+ setIsLoading(false);
401
+ };
402
+ return /*#__PURE__*/React.createElement(Button, _extends({
403
+ className: classNames(PdfExportButton.className, className),
404
+ onClick: exportPdf,
405
+ isDisabled: isLoading
406
+ }, forwardedProps, {
407
+ ref: ref
408
+ }), isLoading ? /*#__PURE__*/React.createElement(Spinner, {
409
+ size: "xsmall",
410
+ isColored: false
411
+ }) : null, " ", children);
412
+ });
413
+ PdfExportButton.className = CLASSNAME;
414
+ PdfExportButton.displayName = COMPONENT_NAME;
415
+
416
+ export { PdfExportButton as P };
417
+ //# sourceMappingURL=PdfExportButton2.js.map