@redsift/dashboard 8.0.0-alpha.8 → 8.0.1

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 (156) hide show
  1. package/.env +2 -0
  2. package/coverage/clover.xml +509 -0
  3. package/coverage/coverage-final.json +22 -0
  4. package/coverage/lcov-report/ConnectedDataGrid/ConnectedDataGrid.tsx.html +193 -0
  5. package/coverage/lcov-report/ConnectedDataGrid/index.html +131 -0
  6. package/coverage/lcov-report/ConnectedDataGrid/index.ts.html +85 -0
  7. package/coverage/lcov-report/Dashboard/Dashboard.tsx.html +229 -0
  8. package/coverage/lcov-report/Dashboard/context.ts.html +118 -0
  9. package/coverage/lcov-report/Dashboard/index.html +176 -0
  10. package/coverage/lcov-report/Dashboard/index.ts.html +97 -0
  11. package/coverage/lcov-report/Dashboard/reducer.ts.html +139 -0
  12. package/coverage/lcov-report/Dashboard/types.ts.html +190 -0
  13. package/coverage/lcov-report/HorizontalBarChart/HorizontalBarChart.tsx.html +430 -0
  14. package/coverage/lcov-report/HorizontalBarChart/index.html +161 -0
  15. package/coverage/lcov-report/HorizontalBarChart/index.ts.html +88 -0
  16. package/coverage/lcov-report/HorizontalBarChart/styles.ts.html +217 -0
  17. package/coverage/lcov-report/HorizontalBarChart/types.ts.html +184 -0
  18. package/coverage/lcov-report/PieChart/PieChart.tsx.html +736 -0
  19. package/coverage/lcov-report/PieChart/index.html +161 -0
  20. package/coverage/lcov-report/PieChart/index.ts.html +88 -0
  21. package/coverage/lcov-report/PieChart/styles.ts.html +244 -0
  22. package/coverage/lcov-report/PieChart/types.ts.html +184 -0
  23. package/coverage/lcov-report/base.css +224 -0
  24. package/coverage/lcov-report/block-navigation.js +87 -0
  25. package/coverage/lcov-report/components/ChartEmptyState/ChartEmptyState.tsx.html +679 -0
  26. package/coverage/lcov-report/components/ChartEmptyState/index.html +146 -0
  27. package/coverage/lcov-report/components/ChartEmptyState/index.ts.html +91 -0
  28. package/coverage/lcov-report/components/ChartEmptyState/styles.ts.html +184 -0
  29. package/coverage/lcov-report/components/ConnectedDataGrid/ConnectedDataGrid.tsx.html +181 -0
  30. package/coverage/lcov-report/components/ConnectedDataGrid/index.html +131 -0
  31. package/coverage/lcov-report/components/ConnectedDataGrid/index.ts.html +85 -0
  32. package/coverage/lcov-report/components/CrossfilterRegistry/CrossfilterRegistry.ts.html +163 -0
  33. package/coverage/lcov-report/components/CrossfilterRegistry/index.html +131 -0
  34. package/coverage/lcov-report/components/CrossfilterRegistry/index.ts.html +88 -0
  35. package/coverage/lcov-report/components/Dashboard/Dashboard.tsx.html +289 -0
  36. package/coverage/lcov-report/components/Dashboard/context.ts.html +115 -0
  37. package/coverage/lcov-report/components/Dashboard/index.html +176 -0
  38. package/coverage/lcov-report/components/Dashboard/index.ts.html +97 -0
  39. package/coverage/lcov-report/components/Dashboard/reducer.ts.html +382 -0
  40. package/coverage/lcov-report/components/Dashboard/types.ts.html +226 -0
  41. package/coverage/lcov-report/components/DataGrid/DataGrid.tsx.html +202 -0
  42. package/coverage/lcov-report/components/DataGrid/index.html +131 -0
  43. package/coverage/lcov-report/components/DataGrid/index.ts.html +91 -0
  44. package/coverage/lcov-report/components/EmptyChart/EmptyChart.tsx.html +244 -0
  45. package/coverage/lcov-report/components/EmptyChart/index.html +146 -0
  46. package/coverage/lcov-report/components/EmptyChart/index.ts.html +91 -0
  47. package/coverage/lcov-report/components/EmptyChart/styles.ts.html +241 -0
  48. package/coverage/lcov-report/components/HorizontalBarChart/HorizontalBarChart.tsx.html +1063 -0
  49. package/coverage/lcov-report/components/HorizontalBarChart/index.html +161 -0
  50. package/coverage/lcov-report/components/HorizontalBarChart/index.ts.html +91 -0
  51. package/coverage/lcov-report/components/HorizontalBarChart/styles.ts.html +385 -0
  52. package/coverage/lcov-report/components/HorizontalBarChart/types.ts.html +328 -0
  53. package/coverage/lcov-report/components/PDFExportButton/PdfDocument.tsx.html +688 -0
  54. package/coverage/lcov-report/components/PDFExportButton/PdfExportButton.tsx.html +583 -0
  55. package/coverage/lcov-report/components/PDFExportButton/index.html +161 -0
  56. package/coverage/lcov-report/components/PDFExportButton/index.ts.html +88 -0
  57. package/coverage/lcov-report/components/PDFExportButton/styles.ts.html +532 -0
  58. package/coverage/lcov-report/components/PDFExportButton/utils.ts.html +283 -0
  59. package/coverage/lcov-report/components/PieChart/PieChart.tsx.html +1363 -0
  60. package/coverage/lcov-report/components/PieChart/index.html +161 -0
  61. package/coverage/lcov-report/components/PieChart/index.ts.html +91 -0
  62. package/coverage/lcov-report/components/PieChart/styles.ts.html +388 -0
  63. package/coverage/lcov-report/components/PieChart/types.ts.html +325 -0
  64. package/coverage/lcov-report/components/ResetButton/ResetButton.tsx.html +160 -0
  65. package/coverage/lcov-report/components/ResetButton/index.html +131 -0
  66. package/coverage/lcov-report/components/ResetButton/index.ts.html +91 -0
  67. package/coverage/lcov-report/components/ScatterPlot/ScatterPlot.tsx.html +2881 -0
  68. package/coverage/lcov-report/components/ScatterPlot/index.html +176 -0
  69. package/coverage/lcov-report/components/ScatterPlot/index.ts.html +91 -0
  70. package/coverage/lcov-report/components/ScatterPlot/styles.ts.html +505 -0
  71. package/coverage/lcov-report/components/ScatterPlot/types.ts.html +370 -0
  72. package/coverage/lcov-report/components/ScatterPlot/utils.ts.html +136 -0
  73. package/coverage/lcov-report/components/StaticPieChart/StaticPieChart.tsx.html +286 -0
  74. package/coverage/lcov-report/components/StaticPieChart/index.html +131 -0
  75. package/coverage/lcov-report/components/StaticPieChart/index.ts.html +88 -0
  76. package/coverage/lcov-report/components/TimeSeriesBarChart/TimeSeriesBarChart.tsx.html +1744 -0
  77. package/coverage/lcov-report/components/TimeSeriesBarChart/index.html +161 -0
  78. package/coverage/lcov-report/components/TimeSeriesBarChart/index.ts.html +91 -0
  79. package/coverage/lcov-report/components/TimeSeriesBarChart/styles.ts.html +361 -0
  80. package/coverage/lcov-report/components/TimeSeriesBarChart/types.ts.html +319 -0
  81. package/coverage/lcov-report/components/WithFilters/FilterableBarChart.tsx.html +628 -0
  82. package/coverage/lcov-report/components/WithFilters/FilterableDataGrid.tsx.html +220 -0
  83. package/coverage/lcov-report/components/WithFilters/FilterablePieChart.tsx.html +622 -0
  84. package/coverage/lcov-report/components/WithFilters/FilterableScatterPlot.tsx.html +1090 -0
  85. package/coverage/lcov-report/components/WithFilters/WithFilters.tsx.html +172 -0
  86. package/coverage/lcov-report/components/WithFilters/index.html +191 -0
  87. package/coverage/lcov-report/components/WithFilters/index.ts.html +91 -0
  88. package/coverage/lcov-report/components/index.html +116 -0
  89. package/coverage/lcov-report/components/index.ts.html +97 -0
  90. package/coverage/lcov-report/favicon.png +0 -0
  91. package/coverage/lcov-report/hooks/index.html +116 -0
  92. package/coverage/lcov-report/hooks/useCategoricalChartAsListbox.ts.html +478 -0
  93. package/coverage/lcov-report/hooks/useChartAsListbox.ts.html +655 -0
  94. package/coverage/lcov-report/index.html +206 -0
  95. package/coverage/lcov-report/prettify.css +1 -0
  96. package/coverage/lcov-report/prettify.js +2 -0
  97. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  98. package/coverage/lcov-report/sorter.js +196 -0
  99. package/coverage/lcov-report/utils/groupReduceCount.ts.html +94 -0
  100. package/coverage/lcov-report/utils/groupReduceSum.ts.html +97 -0
  101. package/coverage/lcov-report/utils/groupReducers/groupReduceCount.ts.html +100 -0
  102. package/coverage/lcov-report/utils/groupReducers/groupReduceSum.ts.html +103 -0
  103. package/coverage/lcov-report/utils/groupReducers/index.html +146 -0
  104. package/coverage/lcov-report/utils/groupReducers/index.ts.html +91 -0
  105. package/coverage/lcov-report/utils/index.html +116 -0
  106. package/coverage/lcov-report/utils/index.ts.html +88 -0
  107. package/coverage/lcov.info +1070 -0
  108. package/{index.js → dist/index.js} +144 -20
  109. package/dist/index.js.map +1 -0
  110. package/dist/package.json +113 -0
  111. package/index.ts +1 -0
  112. package/jest.config.js +3 -0
  113. package/package.json +6 -12
  114. package/rollup.config.js +13 -0
  115. package/src/components/ChartEmptyState/ChartEmptyState.stories.tsx +23 -0
  116. package/src/components/ChartEmptyState/ChartEmptyState.tsx +198 -0
  117. package/src/components/ChartEmptyState/index.ts +2 -0
  118. package/src/components/ChartEmptyState/styles.ts +33 -0
  119. package/src/components/ChartEmptyState/types.ts +15 -0
  120. package/src/components/CrossfilterRegistry/CrossfilterRegistry.ts +26 -0
  121. package/src/components/CrossfilterRegistry/index.ts +1 -0
  122. package/src/components/Dashboard/Dashboard.stories.tsx +602 -0
  123. package/src/components/Dashboard/Dashboard.test.tsx +19 -0
  124. package/src/components/Dashboard/Dashboard.tsx +68 -0
  125. package/src/components/Dashboard/__snapshots__/Dashboard.stories.storyshot +24646 -0
  126. package/src/components/Dashboard/context.ts +10 -0
  127. package/src/components/Dashboard/index.ts +4 -0
  128. package/src/components/Dashboard/reducer.ts +99 -0
  129. package/src/components/Dashboard/types.ts +47 -0
  130. package/src/components/PdfExportButton/PdfDocument.tsx +203 -0
  131. package/src/components/PdfExportButton/PdfExportButton.tsx +168 -0
  132. package/src/components/PdfExportButton/index.ts +3 -0
  133. package/src/components/PdfExportButton/styles.ts +151 -0
  134. package/src/components/PdfExportButton/types.ts +59 -0
  135. package/src/components/TimeSeriesBarChart/TimeSeriesBarChart.tsx +565 -0
  136. package/src/components/TimeSeriesBarChart/index.ts +4 -0
  137. package/src/components/TimeSeriesBarChart/styles.ts +94 -0
  138. package/src/components/TimeSeriesBarChart/types.ts +82 -0
  139. package/src/components/WithFilters/FilterableBarChart.tsx +181 -0
  140. package/src/components/WithFilters/FilterableDataGrid.tsx +45 -0
  141. package/src/components/WithFilters/FilterablePieChart.tsx +179 -0
  142. package/src/components/WithFilters/FilterableScatterPlot.tsx +335 -0
  143. package/src/components/WithFilters/WithFilters.tsx +29 -0
  144. package/src/components/WithFilters/index.ts +2 -0
  145. package/src/components/WithFilters/types.ts +45 -0
  146. package/src/hooks/useCategoricalChartAsListbox.ts +131 -0
  147. package/src/index.ts +8 -0
  148. package/src/types.ts +39 -0
  149. package/src/utils/groupReducers/groupReduceCount.ts +5 -0
  150. package/src/utils/groupReducers/groupReduceSum.ts +6 -0
  151. package/src/utils/groupReducers/index.ts +2 -0
  152. package/src/utils/index.ts +1 -0
  153. package/tsconfig.json +3 -0
  154. package/index.js.map +0 -1
  155. /package/{CONTRIBUTING.md → dist/CONTRIBUTING.md} +0 -0
  156. /package/{index.d.ts → dist/index.d.ts} +0 -0
@@ -197,7 +197,7 @@ const ChartEmptyState = /*#__PURE__*/forwardRef((props, ref) => {
197
197
  }, subtitle), onReset ? /*#__PURE__*/React.createElement(StyledResetButton, {
198
198
  variant: "unstyled",
199
199
  leftIcon: mdiRefresh,
200
- onPress: onReset
200
+ onClick: onReset
201
201
  }, resetLabel) : null);
202
202
  });
203
203
  ChartEmptyState.className = CLASSNAME$3;
@@ -310,14 +310,18 @@ const DashboardContext = /*#__PURE__*/React.createContext({
310
310
  * Reducer props.
311
311
  */
312
312
 
313
- let DashboardReducerActionType;
314
- (function (DashboardReducerActionType) {
313
+ let DashboardReducerActionType = /*#__PURE__*/function (DashboardReducerActionType) {
315
314
  DashboardReducerActionType["ResetFilter"] = "reset-filter";
316
315
  DashboardReducerActionType["ResetFilters"] = "reset-filters";
317
316
  DashboardReducerActionType["FilterTable"] = "filter-table";
318
317
  DashboardReducerActionType["FilterTableBatch"] = "filter-table-batch";
319
318
  DashboardReducerActionType["AppendFilterTableBatch"] = "append-filter-table-batch";
320
- })(DashboardReducerActionType || (DashboardReducerActionType = {}));
319
+ return DashboardReducerActionType;
320
+ }({});
321
+
322
+ /**
323
+ * Component props.
324
+ */
321
325
 
322
326
  const areEquals = (tableFilter, actionFilter) => {
323
327
  return tableFilter.columnField === actionFilter.columnField && tableFilter.operatorValue === actionFilter.operatorValue;
@@ -826,7 +830,7 @@ const PdfExportButton = /*#__PURE__*/forwardRef((props, ref) => {
826
830
  };
827
831
  return /*#__PURE__*/React.createElement(Button, _extends({
828
832
  className: classNames(PdfExportButton.className, className),
829
- onPress: exportPdf,
833
+ onClick: exportPdf,
830
834
  isDisabled: isLoading
831
835
  }, forwardedProps, {
832
836
  ref: ref
@@ -852,6 +856,10 @@ const TimeSeriesBarChartSize = {
852
856
  */
853
857
  const TimeSeriesBarChartTheme = ColorTheme;
854
858
 
859
+ /**
860
+ * Component props.
861
+ */
862
+
855
863
  // istanbul ignore file
856
864
  /**
857
865
  * Component style.
@@ -1241,7 +1249,7 @@ const TimeSeriesBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1241
1249
  id: `id${id}__title`
1242
1250
  }, title) : null, chart && isResetable ? /*#__PURE__*/React.createElement(Button, {
1243
1251
  variant: "unstyled",
1244
- onPress: () => {
1252
+ onClick: () => {
1245
1253
  chart.filter(null);
1246
1254
  redrawAll();
1247
1255
  if (columnToFilter) {
@@ -1289,6 +1297,96 @@ TimeSeriesBarChart.className = CLASSNAME;
1289
1297
  TimeSeriesBarChart.defaultProps = DEFAULT_PROPS;
1290
1298
  TimeSeriesBarChart.displayName = COMPONENT_NAME;
1291
1299
 
1300
+ /**
1301
+ * Hook to give to a chart the roles, events and attributes of a listbox.
1302
+ */
1303
+ const useCategoricalChartAsListbox = _ref => {
1304
+ let {
1305
+ id,
1306
+ ref,
1307
+ type,
1308
+ ndxGroup,
1309
+ orientation = 'horizontal'
1310
+ } = _ref;
1311
+ const currentIndexRef = useRef(0);
1312
+ const props = useMemo(() => {
1313
+ const numberOfGroups = ndxGroup === null || ndxGroup === void 0 ? void 0 : ndxGroup.all().filter(datum => datum.value).length;
1314
+ if (ref && numberOfGroups) {
1315
+ const getCurrentOption = () => ref.current.querySelector(`._${currentIndexRef.current}`);
1316
+ const next = () => {
1317
+ getCurrentOption().classList.remove('focused');
1318
+ const index = currentIndexRef.current === numberOfGroups - 1 ? 0 : currentIndexRef.current + 1;
1319
+ currentIndexRef.current = index;
1320
+ ref.current.setAttribute('aria-activedescendant', `id${id}__${type}-${currentIndexRef.current}`);
1321
+ getCurrentOption().classList.add('focused');
1322
+ };
1323
+ const previous = () => {
1324
+ getCurrentOption().classList.remove('focused');
1325
+ const index = currentIndexRef.current === 0 ? numberOfGroups - 1 : currentIndexRef.current - 1;
1326
+ currentIndexRef.current = index;
1327
+ ref.current.setAttribute('aria-activedescendant', `id${id}__${type}-${currentIndexRef.current}`);
1328
+ getCurrentOption().classList.add('focused');
1329
+ };
1330
+ const focus = () => {
1331
+ ref.current.setAttribute('aria-activedescendant', `id${id}__${type}-0`);
1332
+ getCurrentOption().classList.add('focused');
1333
+ };
1334
+ const blur = () => {
1335
+ getCurrentOption().classList.remove('focused');
1336
+ currentIndexRef.current = 0;
1337
+ ref.current.setAttribute('aria-activedescendant', '');
1338
+ };
1339
+ const keydown = e => {
1340
+ e.stopPropagation();
1341
+ switch (e.code) {
1342
+ case 'ArrowRight':
1343
+ if (orientation === 'horizontal') {
1344
+ e.preventDefault();
1345
+ next();
1346
+ }
1347
+ break;
1348
+ case 'ArrowLeft':
1349
+ if (orientation === 'horizontal') {
1350
+ e.preventDefault();
1351
+ previous();
1352
+ }
1353
+ break;
1354
+ case 'ArrowDown':
1355
+ if (orientation === 'vertical') {
1356
+ e.preventDefault();
1357
+ next();
1358
+ }
1359
+ break;
1360
+ case 'ArrowUp':
1361
+ if (orientation === 'vertical') {
1362
+ e.preventDefault();
1363
+ previous();
1364
+ }
1365
+ break;
1366
+ case 'Enter':
1367
+ case 'Space':
1368
+ e.preventDefault();
1369
+ getCurrentOption().dispatchEvent(new Event('click'));
1370
+ break;
1371
+ }
1372
+ };
1373
+ return {
1374
+ 'aria-activedescendant': '',
1375
+ 'aria-multiselectable': 'true',
1376
+ 'aria-orientation': orientation,
1377
+ role: 'listbox',
1378
+ tabIndex: 0,
1379
+ onFocus: focus,
1380
+ onBlur: blur,
1381
+ onMouseDown: event => event.preventDefault(),
1382
+ onMouseLeave: blur,
1383
+ onKeyDown: keydown
1384
+ };
1385
+ }
1386
+ }, [ref, ref.current, ndxGroup, JSON.parse(JSON.stringify((ndxGroup === null || ndxGroup === void 0 ? void 0 : ndxGroup.all()) || ''))]);
1387
+ return props;
1388
+ };
1389
+
1292
1390
  const FilterableBarChart = props => {
1293
1391
  const {
1294
1392
  children,
@@ -1301,7 +1399,8 @@ const FilterableBarChart = props => {
1301
1399
  localeText,
1302
1400
  onFilter
1303
1401
  } = props;
1304
- const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1402
+ const id = (propsId !== null && propsId !== void 0 ? propsId : useId()).replace(/:/g, '');
1403
+ const ref = useRef();
1305
1404
  const {
1306
1405
  emptyChartTitle,
1307
1406
  emptyChartSubtitle,
@@ -1396,18 +1495,30 @@ const FilterableBarChart = props => {
1396
1495
  resetLabel: emptyChartResetLabel,
1397
1496
  onReset: resetFilters
1398
1497
  });
1498
+ const chartProps = useCategoricalChartAsListbox({
1499
+ id,
1500
+ ref: ref,
1501
+ type: 'bar',
1502
+ ndxGroup,
1503
+ orientation: 'vertical'
1504
+ });
1399
1505
  const filterProps = {
1506
+ barProps: {
1507
+ tabIndex: -1
1508
+ },
1509
+ barRole: 'option',
1510
+ chartProps: chartProps,
1511
+ chartRef: ref,
1400
1512
  data: ndxGroup ? JSON.parse(JSON.stringify(ndxGroup.all())) : undefined,
1401
- id,
1402
- onReset: isResetable ? resetFilters : undefined,
1403
1513
  emptyComponent,
1404
- onBarClick: datum => {
1405
- handleFilter(datum.data.key);
1406
- },
1514
+ id,
1407
1515
  isBarSelected: datum => {
1408
1516
  return filters.length === 0 || filters.includes(datum.data.key);
1409
1517
  },
1410
- barRole: 'option'
1518
+ onBarClick: datum => {
1519
+ handleFilter(datum.data.key);
1520
+ },
1521
+ onReset: isResetable ? resetFilters : undefined
1411
1522
  };
1412
1523
  if ( /*#__PURE__*/isValidElement(children)) {
1413
1524
  return /*#__PURE__*/React.cloneElement(children, _objectSpread2({}, filterProps));
@@ -1472,7 +1583,8 @@ const FilterablePieChart = props => {
1472
1583
  localeText,
1473
1584
  onFilter
1474
1585
  } = props;
1475
- const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1586
+ const id = (propsId !== null && propsId !== void 0 ? propsId : useId()).replace(/:/g, '');
1587
+ const ref = useRef();
1476
1588
  const {
1477
1589
  emptyChartTitle,
1478
1590
  emptyChartSubtitle,
@@ -1563,18 +1675,30 @@ const FilterablePieChart = props => {
1563
1675
  resetLabel: emptyChartResetLabel,
1564
1676
  onReset: resetFilters
1565
1677
  });
1678
+ const chartProps = useCategoricalChartAsListbox({
1679
+ id,
1680
+ ref: ref,
1681
+ type: 'bar',
1682
+ ndxGroup,
1683
+ orientation: 'horizontal'
1684
+ });
1566
1685
  const filterProps = {
1686
+ sliceProps: {
1687
+ tabIndex: -1
1688
+ },
1689
+ sliceRole: 'option',
1690
+ chartProps: chartProps,
1691
+ chartRef: ref,
1567
1692
  data: ndxGroup ? JSON.parse(JSON.stringify(ndxGroup.all())) : undefined,
1568
- id,
1569
- onReset: isResetable ? resetFilters : undefined,
1570
1693
  emptyComponent,
1571
- onSliceClick: datum => {
1572
- handleFilter(datum.data.key);
1573
- },
1694
+ id,
1574
1695
  isSliceSelected: datum => {
1575
1696
  return filters.length === 0 || filters.includes(datum.data.key);
1576
1697
  },
1577
- sliceRole: 'option'
1698
+ onSliceClick: datum => {
1699
+ handleFilter(datum.data.key);
1700
+ },
1701
+ onReset: isResetable ? resetFilters : undefined
1578
1702
  };
1579
1703
  if ( /*#__PURE__*/isValidElement(children)) {
1580
1704
  return /*#__PURE__*/React.cloneElement(children, _objectSpread2({}, filterProps));