@hisptz/dhis2-analytics 1.0.10 → 1.0.12

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 (129) hide show
  1. package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
  2. package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
  3. package/build/cjs/components/CustomPivotTable/CustomPivotTable.stories.js +69 -0
  4. package/build/cjs/components/CustomPivotTable/components/Table/index.js +16 -0
  5. package/build/cjs/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
  6. package/build/cjs/components/CustomPivotTable/components/TableBody/index.js +109 -0
  7. package/build/cjs/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
  8. package/build/cjs/components/CustomPivotTable/components/TableHeaders/index.js +89 -0
  9. package/build/cjs/components/CustomPivotTable/index.js +30 -0
  10. package/build/cjs/components/CustomPivotTable/interfaces/index.js +1 -0
  11. package/build/cjs/components/CustomPivotTable/services/engine.js +89 -0
  12. package/build/cjs/components/CustomPivotTable/state/engine.js +23 -0
  13. package/build/cjs/components/Map/Map.stories.js +1 -1
  14. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  15. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  16. package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  17. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  18. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  19. package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  20. package/build/cjs/dataProviders/map.js +1 -1
  21. package/build/cjs/index.js +11 -0
  22. package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
  23. package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
  24. package/build/es/components/CustomPivotTable/CustomPivotTable.stories.js +59 -0
  25. package/build/es/components/CustomPivotTable/components/Table/index.js +9 -0
  26. package/build/es/components/CustomPivotTable/components/TableBody/TableBody.module.css +12 -0
  27. package/build/es/components/CustomPivotTable/components/TableBody/index.js +100 -0
  28. package/build/es/components/CustomPivotTable/components/TableHeaders/TableHeaders.module.css +10 -0
  29. package/build/es/components/CustomPivotTable/components/TableHeaders/index.js +82 -0
  30. package/build/es/components/CustomPivotTable/index.js +22 -0
  31. package/build/es/components/CustomPivotTable/interfaces/index.js +1 -0
  32. package/build/es/components/CustomPivotTable/services/engine.js +82 -0
  33. package/build/es/components/CustomPivotTable/state/engine.js +14 -0
  34. package/build/es/components/Map/Map.stories.js +1 -1
  35. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  36. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  37. package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  38. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  39. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  40. package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  41. package/build/es/dataProviders/map.js +1 -1
  42. package/build/es/index.js +1 -0
  43. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/components/Menu.d.ts +0 -0
  44. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/constants/menu.d.ts +0 -0
  45. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/index.d.ts +0 -0
  46. package/build/types/{components → src/components}/ChartAnalytics/components/DownloadMenu/interfaces/menu.d.ts +0 -0
  47. package/build/types/{components → src/components}/ChartAnalytics/hooks/useChart.d.ts +0 -0
  48. package/build/types/{components → src/components}/ChartAnalytics/index.d.ts +0 -0
  49. package/build/types/{components → src/components}/ChartAnalytics/models/column.d.ts +0 -0
  50. package/build/types/{components → src/components}/ChartAnalytics/models/index.d.ts +0 -0
  51. package/build/types/{components → src/components}/ChartAnalytics/models/line.d.ts +0 -0
  52. package/build/types/{components → src/components}/ChartAnalytics/models/multi-series.d.ts +0 -0
  53. package/build/types/{components → src/components}/ChartAnalytics/models/pie.d.ts +0 -0
  54. package/build/types/{components → src/components}/ChartAnalytics/services/export.d.ts +0 -0
  55. package/build/types/{components → src/components}/ChartAnalytics/types/props.d.ts +0 -0
  56. package/build/types/{components → src/components}/ChartAnalytics/utils/chart.d.ts +0 -0
  57. package/build/types/{components → src/components}/CircularProgressDashboard/index.d.ts +0 -0
  58. package/build/types/{components → src/components}/CircularProgressDashboard/types/props.d.ts +0 -0
  59. package/build/types/src/components/CustomPivotTable/components/Table/index.d.ts +11 -0
  60. package/build/types/src/components/CustomPivotTable/components/TableBody/index.d.ts +2 -0
  61. package/build/types/src/components/CustomPivotTable/components/TableHeaders/index.d.ts +2 -0
  62. package/build/types/src/components/CustomPivotTable/index.d.ts +40 -0
  63. package/build/types/src/components/CustomPivotTable/interfaces/index.d.ts +1 -0
  64. package/build/types/src/components/CustomPivotTable/services/engine.d.ts +58 -0
  65. package/build/types/src/components/CustomPivotTable/state/engine.d.ts +7 -0
  66. package/build/types/{components → src/components}/Map/components/EarthEngineLayerConfiguration/index.d.ts +0 -0
  67. package/build/types/{components → src/components}/Map/components/MapArea/index.d.ts +0 -0
  68. package/build/types/{components → src/components}/Map/components/MapArea/interfaces/index.d.ts +0 -0
  69. package/build/types/{components → src/components}/Map/components/MapControls/components/CustomControl/index.d.ts +0 -0
  70. package/build/types/{components → src/components}/Map/components/MapControls/components/DownloadControl/index.d.ts +0 -0
  71. package/build/types/{components → src/components}/Map/components/MapControls/components/FullscreenControl/index.d.ts +0 -0
  72. package/build/types/{components → src/components}/Map/components/MapControls/index.d.ts +0 -0
  73. package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.d.ts +0 -0
  74. package/build/types/{components → src/components}/Map/components/MapLayer/components/BoundaryLayer/index.d.ts +0 -0
  75. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.d.ts +0 -0
  76. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.d.ts +0 -0
  77. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.d.ts +0 -0
  78. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/index.d.ts +0 -0
  79. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.d.ts +0 -0
  80. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/api.d.ts +0 -0
  81. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.d.ts +0 -0
  82. package/build/types/{components → src/components}/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.d.ts +0 -0
  83. package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.d.ts +0 -0
  84. package/build/types/{components → src/components}/Map/components/MapLayer/components/LegendArea/index.d.ts +0 -0
  85. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.d.ts +0 -0
  86. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/hooks/index.d.ts +0 -0
  87. package/build/types/{components → src/components}/Map/components/MapLayer/components/PointLayer/index.d.ts +0 -0
  88. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.d.ts +0 -0
  89. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.d.ts +0 -0
  90. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.d.ts +0 -0
  91. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.d.ts +0 -0
  92. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.d.ts +0 -0
  93. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +0 -0
  94. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.d.ts +0 -0
  95. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/hooks/config.d.ts +0 -0
  96. package/build/types/{components → src/components}/Map/components/MapLayer/components/ThematicLayer/index.d.ts +0 -0
  97. package/build/types/{components → src/components}/Map/components/MapLayer/index.d.ts +0 -0
  98. package/build/types/{components → src/components}/Map/components/MapLayer/interfaces/index.d.ts +0 -0
  99. package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/hooks/index.d.ts +0 -0
  100. package/build/types/{components → src/components}/Map/components/MapProvider/components/MapLayerProvider/index.d.ts +0 -0
  101. package/build/types/{components → src/components}/Map/components/MapProvider/hooks/index.d.ts +0 -0
  102. package/build/types/{components → src/components}/Map/components/MapProvider/index.d.ts +0 -0
  103. package/build/types/{components → src/components}/Map/components/MapUpdater/index.d.ts +0 -0
  104. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.d.ts +0 -0
  105. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.d.ts +0 -0
  106. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.d.ts +0 -0
  107. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.d.ts +0 -0
  108. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.d.ts +0 -0
  109. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.d.ts +0 -0
  110. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.d.ts +0 -0
  111. package/build/types/{components → src/components}/Map/components/ThematicLayerConfiguration/index.d.ts +0 -0
  112. package/build/types/{components → src/components}/Map/constants/colors.d.ts +0 -0
  113. package/build/types/{components → src/components}/Map/constants/legendSet.d.ts +0 -0
  114. package/build/types/{components → src/components}/Map/hooks/map.d.ts +0 -0
  115. package/build/types/{components → src/components}/Map/index.d.ts +0 -0
  116. package/build/types/{components → src/components}/Map/interfaces/index.d.ts +0 -0
  117. package/build/types/{components → src/components}/Map/state/index.d.ts +0 -0
  118. package/build/types/{components → src/components}/Map/utils/colors.d.ts +0 -0
  119. package/build/types/{components → src/components}/Map/utils/helpers.d.ts +0 -0
  120. package/build/types/{components → src/components}/Map/utils/map.d.ts +0 -0
  121. package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValueItem.d.ts +0 -0
  122. package/build/types/{components → src/components}/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.d.ts +0 -0
  123. package/build/types/{components → src/components}/SingleValueContainer/index.d.ts +0 -0
  124. package/build/types/{components → src/components}/SingleValueContainer/types/props.d.ts +0 -0
  125. package/build/types/{dataProviders → src/dataProviders}/map.d.ts +0 -0
  126. package/build/types/{index.d.ts → src/index.d.ts} +1 -0
  127. package/package.json +6 -3
  128. package/build/cjs/data/map.json +0 -5984
  129. package/build/es/data/map.json +0 -5984
@@ -225,7 +225,7 @@ ComplexMultiSeries.args = {
225
225
  }
226
226
  };
227
227
  var _default = {
228
- title: "Components/Chart Analytics",
228
+ title: "Analytics/Chart Analytics",
229
229
  component: _.ChartAnalytics,
230
230
  decorators: [ChartStory => {
231
231
  const [chartRef, setChartRef] = (0, _react.useState)(null);
@@ -39,7 +39,7 @@ WithTextStyling.args = {
39
39
  }
40
40
  };
41
41
  var _default = {
42
- title: "Components/Circular Progress Indicator",
42
+ title: "Analytics/Circular Progress Indicator",
43
43
  component: _.CircularProgressDashboard
44
44
  };
45
45
  exports.default = _default;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.WithManyData = exports.Default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ = require(".");
9
+ var _largeTableData = _interopRequireDefault(require("../../../data/large-table-data.json"));
10
+ var _simpleData = _interopRequireDefault(require("../../../data/simple-data.json"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const Template = args => /*#__PURE__*/_react.default.createElement(_.CustomPivotTable, args);
13
+ const Default = Template.bind({});
14
+ exports.Default = Default;
15
+ Default.args = {
16
+ analytics: _simpleData.default,
17
+ config: {
18
+ layout: {
19
+ columns: [{
20
+ dimension: "ou"
21
+ }, {
22
+ dimension: "pe",
23
+ label: "Period"
24
+ }],
25
+ rows: [{
26
+ dimension: "dx",
27
+ label: "Services"
28
+ }],
29
+ filter: []
30
+ },
31
+ options: {}
32
+ },
33
+ tableProps: {}
34
+ };
35
+ const WithManyData = Template.bind({});
36
+ exports.WithManyData = WithManyData;
37
+ WithManyData.args = {
38
+ analytics: _largeTableData.default,
39
+ config: {
40
+ layout: {
41
+ columns: [{
42
+ dimension: "dx"
43
+ }, {
44
+ dimension: "J5jldMd8OHv",
45
+ label: "Facility Type"
46
+ }],
47
+ rows: [{
48
+ dimension: "pe",
49
+ label: "Period"
50
+ }, {
51
+ dimension: "ou",
52
+ label: "Organisation unit"
53
+ }],
54
+ filter: []
55
+ },
56
+ options: {
57
+ fixColumnHeaders: false
58
+ }
59
+ },
60
+ tableProps: {
61
+ scrollHeight: "800px",
62
+ scrollWidth: "1400px"
63
+ }
64
+ };
65
+ var _default = {
66
+ title: "Analytics/Pivot table",
67
+ component: _.CustomPivotTable
68
+ };
69
+ exports.default = _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTable = PivotTable;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ui = require("@dhis2/ui");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function PivotTable(_ref) {
11
+ let {
12
+ tableProps,
13
+ children
14
+ } = _ref;
15
+ return /*#__PURE__*/_react.default.createElement(_ui.DataTable, tableProps !== null && tableProps !== void 0 ? tableProps : {}, children);
16
+ }
@@ -0,0 +1,12 @@
1
+ .nested-table-cell {
2
+ padding: 0 !important;
3
+ }
4
+
5
+ .nested-table {
6
+ margin: 0;
7
+ padding: 0;
8
+ }
9
+
10
+ .header-cell {
11
+ border-right: 1px solid rgb(232, 237, 242) !important;
12
+ }
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomPivotTableBody = CustomPivotTableBody;
7
+ var _lodash = require("lodash");
8
+ var _engine = require("../../state/engine");
9
+ var _ui = require("@dhis2/ui");
10
+ var _react = _interopRequireWildcard(require("react"));
11
+ var _TableBodyModule = _interopRequireDefault(require("./TableBody.module.css"));
12
+ var _usehooksTs = require("usehooks-ts");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function DataRowRenderer(_ref) {
17
+ let {
18
+ mapper,
19
+ item,
20
+ dimension
21
+ } = _ref;
22
+ const engine = (0, _engine.useCustomPivotTableEngine)();
23
+ const columnMappers = engine === null || engine === void 0 ? void 0 : engine.columnMap;
24
+ const completeMapper = columnMappers === null || columnMappers === void 0 ? void 0 : columnMappers.map(map => ({
25
+ ...map,
26
+ ...mapper,
27
+ [dimension]: item.uid
28
+ }));
29
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, completeMapper === null || completeMapper === void 0 ? void 0 : completeMapper.map(mapper => {
30
+ var _engine$getValue;
31
+ return /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
32
+ key: `${Object.values(mapper).join('-')}-value`,
33
+ align: "center",
34
+ bordered: true
35
+ }, (_engine$getValue = engine === null || engine === void 0 ? void 0 : engine.getValue(mapper)) !== null && _engine$getValue !== void 0 ? _engine$getValue : '');
36
+ }));
37
+ }
38
+ function RowRenderer(_ref2) {
39
+ var _row$items;
40
+ let {
41
+ row,
42
+ index,
43
+ config: {
44
+ rows,
45
+ columns,
46
+ mapper,
47
+ prevWidth,
48
+ fixRowHeaders
49
+ }
50
+ } = _ref2;
51
+ const [cellRef, {
52
+ width
53
+ }] = (0, _usehooksTs.useElementSize)();
54
+ const rowSpan = (0, _lodash.slice)(rows, index + 1).reduce((acc, column) => {
55
+ var _column$items$length, _column$items;
56
+ return acc * ((_column$items$length = (_column$items = column.items) === null || _column$items === void 0 ? void 0 : _column$items.length) !== null && _column$items$length !== void 0 ? _column$items$length : 1);
57
+ }, 1);
58
+ const hasSubRows = !(0, _lodash.isEmpty)(rows[index + 1]);
59
+ const nextRow = rows[index + 1];
60
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, row === null || row === void 0 ? void 0 : (_row$items = row.items) === null || _row$items === void 0 ? void 0 : _row$items.map(item => {
61
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
62
+ key: `${item.name}-${row.dimension}-fragment`
63
+ }, /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, {
64
+ key: `${item.name}-${row.dimension}-row`
65
+ }, /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
66
+ ref: cellRef,
67
+ fixed: fixRowHeaders,
68
+ left: `${prevWidth}px`,
69
+ className: _TableBodyModule.default['header-cell'],
70
+ tag: "th",
71
+ bordered: true,
72
+ rowSpan: (rowSpan + (hasSubRows ? 1 : 0)).toString()
73
+ }, item.name), !hasSubRows ? /*#__PURE__*/_react.default.createElement(DataRowRenderer, {
74
+ dimension: row.dimension,
75
+ mapper: mapper,
76
+ item: item
77
+ }) : null), hasSubRows ? /*#__PURE__*/_react.default.createElement(RowRenderer, {
78
+ row: nextRow,
79
+ index: index + 1,
80
+ config: {
81
+ rows,
82
+ columns,
83
+ prevWidth: width,
84
+ mapper: {
85
+ ...mapper,
86
+ [row.dimension]: item.uid
87
+ }
88
+ }
89
+ }) : null);
90
+ }));
91
+ }
92
+ function CustomPivotTableBody() {
93
+ const engine = (0, _engine.useCustomPivotTableEngine)();
94
+ const rows = engine === null || engine === void 0 ? void 0 : engine.rowHeaders;
95
+ const columns = engine === null || engine === void 0 ? void 0 : engine.columnHeaders;
96
+ const fixRowHeaders = engine === null || engine === void 0 ? void 0 : engine.fixRowHeaders;
97
+ if (!rows || (0, _lodash.isEmpty)(rows)) {
98
+ return null;
99
+ }
100
+ return /*#__PURE__*/_react.default.createElement(_ui.TableBody, null, /*#__PURE__*/_react.default.createElement(RowRenderer, {
101
+ row: rows[0],
102
+ index: 0,
103
+ config: {
104
+ rows,
105
+ columns,
106
+ fixRowHeaders
107
+ }
108
+ }));
109
+ }
@@ -0,0 +1,10 @@
1
+ .table-header{
2
+ border-right: 1px solid rgb(232, 237, 242);
3
+ }
4
+ .table-header:last-child{
5
+ border-right: none;
6
+ }
7
+
8
+ .table-header > span > span{
9
+ justify-content: center;
10
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TableHeaders = TableHeaders;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _engine = require("../../state/engine");
9
+ var _ui = require("@dhis2/ui");
10
+ var _lodash = require("lodash");
11
+ var _TableHeadersModule = _interopRequireDefault(require("./TableHeaders.module.css"));
12
+ var _usehooksTs = require("usehooks-ts");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function ColumnRenderer(_ref) {
15
+ let {
16
+ column,
17
+ index,
18
+ config: {
19
+ fixColumnHeaders,
20
+ rowHeaders,
21
+ prevHeight = 0,
22
+ columns
23
+ }
24
+ } = _ref;
25
+ const [columnHeaderRef, {
26
+ height
27
+ }] = (0, _usehooksTs.useElementSize)();
28
+ if (!column) {
29
+ return null;
30
+ }
31
+ const colSpan = (0, _lodash.slice)(columns, index + 1).reduce((acc, column) => {
32
+ var _column$items$length, _column$items;
33
+ return acc * ((_column$items$length = (_column$items = column.items) === null || _column$items === void 0 ? void 0 : _column$items.length) !== null && _column$items$length !== void 0 ? _column$items$length : 1);
34
+ }, 1);
35
+ const hasSubColumns = !(0, _lodash.isEmpty)(columns[index + 1]);
36
+ const nextColumn = columns[index + 1];
37
+ const multiplicationFactor = (0, _lodash.slice)(columns, 0, index).reduce((acc, column) => {
38
+ var _column$items$length2, _column$items2;
39
+ return acc * ((_column$items$length2 = (_column$items2 = column.items) === null || _column$items2 === void 0 ? void 0 : _column$items2.length) !== null && _column$items$length2 !== void 0 ? _column$items$length2 : 1);
40
+ }, 1);
41
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, null, index === 0 && (rowHeaders === null || rowHeaders === void 0 ? void 0 : rowHeaders.map(header => {
42
+ var _header$label;
43
+ return /*#__PURE__*/_react.default.createElement(_ui.DataTableColumnHeader, {
44
+ fixed: fixColumnHeaders,
45
+ top: "0",
46
+ className: _TableHeadersModule.default['table-header'],
47
+ rowSpan: columns.length.toString(),
48
+ key: `${header.dimension}-header-column`
49
+ }, (_header$label = header.label) !== null && _header$label !== void 0 ? _header$label : "");
50
+ })), (0, _lodash.times)(multiplicationFactor, colNo => {
51
+ var _column$items3;
52
+ return (_column$items3 = column.items) === null || _column$items3 === void 0 ? void 0 : _column$items3.map(item => /*#__PURE__*/_react.default.createElement(_ui.DataTableColumnHeader, {
53
+ fixed: fixColumnHeaders,
54
+ top: `${prevHeight.toString()}px`,
55
+ ref: index === 0 ? columnHeaderRef : undefined,
56
+ className: _TableHeadersModule.default['table-header'],
57
+ align: "center",
58
+ colSpan: colSpan.toString(),
59
+ key: `${colNo}-${item.name}-column-header`
60
+ }, item.name));
61
+ })), hasSubColumns ? /*#__PURE__*/_react.default.createElement(ColumnRenderer, {
62
+ column: nextColumn,
63
+ index: index + 1,
64
+ config: {
65
+ columns,
66
+ rowHeaders,
67
+ prevHeight: height,
68
+ fixColumnHeaders
69
+ }
70
+ }) : null);
71
+ }
72
+ function TableHeaders() {
73
+ const engine = (0, _engine.useCustomPivotTableEngine)();
74
+ const columns = engine === null || engine === void 0 ? void 0 : engine.columnHeaders;
75
+ const rowHeaders = engine === null || engine === void 0 ? void 0 : engine.rowHeaders;
76
+ const fixColumnHeaders = engine === null || engine === void 0 ? void 0 : engine.fixColumnHeaders;
77
+ if (!columns || (0, _lodash.isEmpty)(columns)) {
78
+ return null;
79
+ }
80
+ return /*#__PURE__*/_react.default.createElement(_ui.TableHead, null, /*#__PURE__*/_react.default.createElement(ColumnRenderer, {
81
+ column: columns[0],
82
+ index: 0,
83
+ config: {
84
+ rowHeaders,
85
+ columns,
86
+ fixColumnHeaders
87
+ }
88
+ }));
89
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomPivotTable = CustomPivotTable;
7
+ var _engine = require("./services/engine");
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _engine2 = require("./state/engine");
10
+ var _Table = require("./components/Table");
11
+ var _TableHeaders = require("./components/TableHeaders");
12
+ var _TableBody = require("./components/TableBody");
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+ function CustomPivotTable(_ref) {
16
+ let {
17
+ analytics,
18
+ config,
19
+ tableProps
20
+ } = _ref;
21
+ const engine = (0, _react.useMemo)(() => new _engine.CustomPivotTableEngine({
22
+ analytics,
23
+ config
24
+ }), [analytics, config]);
25
+ return /*#__PURE__*/_react.default.createElement(_engine2.CustomPivotTableEngineProvider, {
26
+ engine: engine
27
+ }, /*#__PURE__*/_react.default.createElement(_Table.PivotTable, {
28
+ tableProps: tableProps
29
+ }, /*#__PURE__*/_react.default.createElement(_TableHeaders.TableHeaders, null), /*#__PURE__*/_react.default.createElement(_TableBody.CustomPivotTableBody, null)));
30
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomPivotTableEngine = void 0;
7
+ var _lodash = require("lodash");
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
11
+ class CustomPivotTableEngine {
12
+ constructor(_ref) {
13
+ let {
14
+ analytics,
15
+ config
16
+ } = _ref;
17
+ _defineProperty(this, "analyticsData", void 0);
18
+ _defineProperty(this, "valueIndex", void 0);
19
+ _defineProperty(this, "config", void 0);
20
+ _defineProperty(this, "rowHeaders", void 0);
21
+ _defineProperty(this, "columnHeaders", void 0);
22
+ _defineProperty(this, "columnMap", void 0);
23
+ this.config = config;
24
+ this.analyticsData = analytics;
25
+ this.valueIndex = (0, _lodash.findIndex)(this.analyticsData.headers, ['name', 'value']);
26
+ this.getHeaders();
27
+ this.getColumnMap();
28
+ }
29
+ get fixColumnHeaders() {
30
+ var _this$config$options$, _this$config$options;
31
+ return (_this$config$options$ = (_this$config$options = this.config.options) === null || _this$config$options === void 0 ? void 0 : _this$config$options.fixColumnHeaders) !== null && _this$config$options$ !== void 0 ? _this$config$options$ : true;
32
+ }
33
+ get fixRowHeaders() {
34
+ var _this$config$options$2, _this$config$options2;
35
+ return (_this$config$options$2 = (_this$config$options2 = this.config.options) === null || _this$config$options2 === void 0 ? void 0 : _this$config$options2.fixRowHeaders) !== null && _this$config$options$2 !== void 0 ? _this$config$options$2 : true;
36
+ }
37
+ getDimensionItems(dimension) {
38
+ var _this$analyticsData$m, _this$analyticsData$m2;
39
+ return (_this$analyticsData$m = (_this$analyticsData$m2 = this.analyticsData.metaData) === null || _this$analyticsData$m2 === void 0 ? void 0 : _this$analyticsData$m2.dimensions[dimension]) !== null && _this$analyticsData$m !== void 0 ? _this$analyticsData$m : [];
40
+ }
41
+ getItem(id) {
42
+ var _this$analyticsData$m3;
43
+ return (_this$analyticsData$m3 = this.analyticsData.metaData) === null || _this$analyticsData$m3 === void 0 ? void 0 : _this$analyticsData$m3.items[id];
44
+ }
45
+ getValue(mapper) {
46
+ var _this$analyticsData$r;
47
+ const dimensions = Object.values(mapper);
48
+ const data = (_this$analyticsData$r = this.analyticsData.rows) === null || _this$analyticsData$r === void 0 ? void 0 : _this$analyticsData$r.filter(row => (0, _lodash.intersection)(row, dimensions).length >= dimensions.length);
49
+ return data === null || data === void 0 ? void 0 : data.reduce((acc, row) => {
50
+ return acc + parseFloat(row[this.valueIndex]);
51
+ }, 0);
52
+ }
53
+ getHeaders() {
54
+ this.rowHeaders = this.config.layout.rows.map(rowConfig => {
55
+ return {
56
+ ...rowConfig,
57
+ items: (0, _lodash.compact)(this.getDimensionItems(rowConfig.dimension).map(itemId => this.getItem(itemId)))
58
+ };
59
+ });
60
+ this.columnHeaders = this.config.layout.columns.map(columnConfig => {
61
+ return {
62
+ ...columnConfig,
63
+ items: (0, _lodash.compact)(this.getDimensionItems(columnConfig.dimension).map(itemId => this.getItem(itemId)))
64
+ };
65
+ });
66
+ }
67
+ getColumnMap() {
68
+ var _compact;
69
+ const columns = this.columnHeaders;
70
+ const sanitizedColumns = (_compact = (0, _lodash.compact)(columns === null || columns === void 0 ? void 0 : columns.map(column => {
71
+ var _column$items;
72
+ return (_column$items = column.items) === null || _column$items === void 0 ? void 0 : _column$items.map(item => ({
73
+ [column.dimension]: item.uid
74
+ }));
75
+ }))) !== null && _compact !== void 0 ? _compact : [];
76
+ const size = sanitizedColumns.reduce((acc, items) => {
77
+ var _items$length;
78
+ return acc * ((_items$length = items === null || items === void 0 ? void 0 : items.length) !== null && _items$length !== void 0 ? _items$length : 1);
79
+ }, 1);
80
+ const standardiseColumns = sanitizedColumns.map(items => [...(0, _lodash.times)(size / items.length, () => items).flat()]);
81
+ this.columnMap = (0, _lodash.compact)((0, _lodash.zip)(...standardiseColumns).map(arr => arr.reduce((obj, value) => {
82
+ return {
83
+ ...obj,
84
+ ...value
85
+ };
86
+ })));
87
+ }
88
+ }
89
+ exports.CustomPivotTableEngine = CustomPivotTableEngine;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CustomPivotTableEngineProvider = CustomPivotTableEngineProvider;
7
+ exports.useCustomPivotTableEngine = useCustomPivotTableEngine;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
+ const CustomPivotTableEngineContext = /*#__PURE__*/(0, _react.createContext)(null);
12
+ function useCustomPivotTableEngine() {
13
+ return (0, _react.useContext)(CustomPivotTableEngineContext);
14
+ }
15
+ function CustomPivotTableEngineProvider(_ref) {
16
+ let {
17
+ children,
18
+ engine
19
+ } = _ref;
20
+ return /*#__PURE__*/_react.default.createElement(CustomPivotTableEngineContext.Provider, {
21
+ value: engine
22
+ }, children);
23
+ }
@@ -338,7 +338,7 @@ GoogleEarthEngineLayers.args = {
338
338
  }
339
339
  };
340
340
  var _default = {
341
- title: "Components/Map",
341
+ title: "Analytics/Map",
342
342
  component: _index.Map,
343
343
  decorators: [MapStory => {
344
344
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -18,7 +18,7 @@ Basic.args = {
18
18
  open: true
19
19
  };
20
20
  var _default = {
21
- title: "Components/Map/Earth Engine Config Modal",
21
+ title: "Analytics/Map/Earth Engine Config Modal",
22
22
  component: _index.EarthEngineLayerConfiguration,
23
23
  decorators: [MapStory => {
24
24
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -26,7 +26,7 @@ const Basic = Template.bind({});
26
26
  exports.Basic = Basic;
27
27
  Basic.args = {};
28
28
  var _default = {
29
- title: "Components/Map/Earth Engine Configuration",
29
+ title: "Analytics/Map/Earth Engine Configuration",
30
30
  component: _index.EarthEngineLayerConfiguration,
31
31
  decorators: [MapStory => {
32
32
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -171,7 +171,7 @@ function useThematicLayers() {
171
171
  scale: _colors.defaultClasses,
172
172
  colorClass: _colors.defaultColorScaleName
173
173
  };
174
- const sortedData = (0, _lodash.sortBy)(layer.data, "data");
174
+ const sortedData = (0, _lodash.sortBy)(layer.data.filter(datum => !!datum.data), "data");
175
175
  const autoLegends = (0, _map.generateLegends)((_last$data = (_last = (0, _lodash.last)(sortedData)) === null || _last === void 0 ? void 0 : _last.data) !== null && _last$data !== void 0 ? _last$data : 0, (_head$data = (_head = (0, _lodash.head)(sortedData)) === null || _head === void 0 ? void 0 : _head.data) !== null && _head$data !== void 0 ? _head$data : 0, {
176
176
  classesCount: scale,
177
177
  colorClass
@@ -346,10 +346,17 @@ function useGoogleEngineLayers() {
346
346
  }
347
347
  }
348
348
  const sanitizeLayers = (0, _react.useCallback)(async layers => {
349
+ if ((0, _lodash.isEmpty)(layers)) {
350
+ return [];
351
+ }
349
352
  try {
350
353
  const {
351
354
  token
352
355
  } = await refresh();
356
+ if (!token) {
357
+ console.error(`Google token not available in this instance`);
358
+ return [];
359
+ }
353
360
  await _engine.EarthEngine.setToken(token, refresh);
354
361
  return (0, _asyncEs.map)(layers, (0, _asyncEs.asyncify)(async layer => {
355
362
  try {
@@ -18,7 +18,7 @@ Basic.args = {
18
18
  open: true
19
19
  };
20
20
  var _default = {
21
- title: "Components/Map/Thematic Layer Config Modal",
21
+ title: "Analytics/Map/Thematic Layer Config Modal",
22
22
  component: _index.ThematicLayerConfigModal,
23
23
  decorators: [MapStory => {
24
24
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -26,7 +26,7 @@ const Basic = Template.bind({});
26
26
  exports.Basic = Basic;
27
27
  Basic.args = {};
28
28
  var _default = {
29
- title: "Components/Map/Thematic Layer Configuration",
29
+ title: "Analytics/Map/Thematic Layer Configuration",
30
30
  component: _index.ThematicLayerConfiguration,
31
31
  decorators: [MapStory => {
32
32
  return /*#__PURE__*/_react.default.createElement("div", {
@@ -118,7 +118,7 @@ SingleValuesWithDecimalPlaces.args = {
118
118
  }]
119
119
  };
120
120
  var _default = {
121
- title: "Components/Single Value Container",
121
+ title: "Analytics/Single Value Container",
122
122
  component: _.SingleValueContainer,
123
123
  decorators: [SingleValueStory => {
124
124
  return /*#__PURE__*/_react.default.createElement(SingleValueStory, null);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = MapDataProvider;
7
7
  var _appRuntime = require("@dhis2/app-runtime");
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _map = _interopRequireDefault(require("../data/map.json"));
9
+ var _map = _interopRequireDefault(require("../../data/map.json"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  function MapDataProvider(_ref) {
12
12
  let {
@@ -46,4 +46,15 @@ Object.keys(_SingleValueContainer).forEach(function (key) {
46
46
  return _SingleValueContainer[key];
47
47
  }
48
48
  });
49
+ });
50
+ var _CustomPivotTable = require("./components/CustomPivotTable");
51
+ Object.keys(_CustomPivotTable).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _CustomPivotTable[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _CustomPivotTable[key];
58
+ }
59
+ });
49
60
  });
@@ -208,7 +208,7 @@ ComplexMultiSeries.args = {
208
208
  }
209
209
  };
210
210
  export default {
211
- title: "Components/Chart Analytics",
211
+ title: "Analytics/Chart Analytics",
212
212
  component: ChartAnalytics,
213
213
  decorators: [ChartStory => {
214
214
  const [chartRef, setChartRef] = useState(null);
@@ -29,6 +29,6 @@ WithTextStyling.args = {
29
29
  }
30
30
  };
31
31
  export default {
32
- title: "Components/Circular Progress Indicator",
32
+ title: "Analytics/Circular Progress Indicator",
33
33
  component: CircularProgressDashboard
34
34
  };