@hisptz/dhis2-analytics 1.0.10 → 1.0.11

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 (154) 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/Map/Map.stories.js +1 -1
  4. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  5. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  6. package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  7. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  8. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  9. package/build/cjs/components/PivotTable/PivotTable.stories.js +277 -0
  10. package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +32 -0
  11. package/build/cjs/components/PivotTable/components/PivotTable.js +60 -0
  12. package/build/cjs/components/PivotTable/components/PivotTableBody.js +41 -0
  13. package/build/cjs/components/PivotTable/components/PivotTableCell.js +40 -0
  14. package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +26 -0
  15. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +71 -0
  16. package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +60 -0
  17. package/build/cjs/components/PivotTable/components/PivotTableContainer.js +33 -0
  18. package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +77 -0
  19. package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +22 -0
  20. package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +33 -0
  21. package/build/cjs/components/PivotTable/components/PivotTableEngineContext.js +25 -0
  22. package/build/cjs/components/PivotTable/components/PivotTableHead.js +35 -0
  23. package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +37 -0
  24. package/build/cjs/components/PivotTable/components/PivotTableRow.js +65 -0
  25. package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +49 -0
  26. package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +52 -0
  27. package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +46 -0
  28. package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +69 -0
  29. package/build/cjs/components/PivotTable/constants/dataTypes.js +129 -0
  30. package/build/cjs/components/PivotTable/constants/pivotTable.js +64 -0
  31. package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +62 -0
  32. package/build/cjs/components/PivotTable/constants/valueTypes.js +55 -0
  33. package/build/cjs/components/PivotTable/data/column-data.json +210 -0
  34. package/build/cjs/components/PivotTable/hooks/useParentSize.js +41 -0
  35. package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +38 -0
  36. package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +34 -0
  37. package/build/cjs/components/PivotTable/hooks/useTableClipping.js +53 -0
  38. package/build/cjs/components/PivotTable/index.js +47 -0
  39. package/build/cjs/components/PivotTable/interfaces/index.js +1 -0
  40. package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +197 -0
  41. package/build/cjs/components/PivotTable/services/engine.js +901 -0
  42. package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +71 -0
  43. package/build/cjs/components/PivotTable/utils/index.js +322 -0
  44. package/build/cjs/components/PivotTable/utils/isColorBright.js +29 -0
  45. package/build/cjs/components/PivotTable/utils/layout/dimension.js +61 -0
  46. package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +12 -0
  47. package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +12 -0
  48. package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +9 -0
  49. package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +9 -0
  50. package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +25 -0
  51. package/build/cjs/components/PivotTable/utils/legend.js +40 -0
  52. package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +27 -0
  53. package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  54. package/build/cjs/index.js +11 -0
  55. package/build/cjs/locales/en/translations.json +33 -0
  56. package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
  57. package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
  58. package/build/es/components/Map/Map.stories.js +1 -1
  59. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
  60. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
  61. package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
  62. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
  63. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
  64. package/build/es/components/PivotTable/PivotTable.stories.js +268 -0
  65. package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +24 -0
  66. package/build/es/components/PivotTable/components/PivotTable.js +51 -0
  67. package/build/es/components/PivotTable/components/PivotTableBody.js +33 -0
  68. package/build/es/components/PivotTable/components/PivotTableCell.js +32 -0
  69. package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +18 -0
  70. package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +62 -0
  71. package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +52 -0
  72. package/build/es/components/PivotTable/components/PivotTableContainer.js +25 -0
  73. package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +68 -0
  74. package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +14 -0
  75. package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +25 -0
  76. package/build/es/components/PivotTable/components/PivotTableEngineContext.js +14 -0
  77. package/build/es/components/PivotTable/components/PivotTableHead.js +27 -0
  78. package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +29 -0
  79. package/build/es/components/PivotTable/components/PivotTableRow.js +57 -0
  80. package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +41 -0
  81. package/build/es/components/PivotTable/components/PivotTableTitleRow.js +42 -0
  82. package/build/es/components/PivotTable/components/PivotTableTitleRows.js +37 -0
  83. package/build/es/components/PivotTable/components/PivotTableValueCell.js +60 -0
  84. package/build/es/components/PivotTable/constants/dataTypes.js +98 -0
  85. package/build/es/components/PivotTable/constants/pivotTable.js +29 -0
  86. package/build/es/components/PivotTable/constants/predefinedDimensions.js +44 -0
  87. package/build/es/components/PivotTable/constants/valueTypes.js +27 -0
  88. package/build/es/components/PivotTable/data/column-data.json +210 -0
  89. package/build/es/components/PivotTable/hooks/useParentSize.js +33 -0
  90. package/build/es/components/PivotTable/hooks/useScrollPosition.js +30 -0
  91. package/build/es/components/PivotTable/hooks/useSortableColumns.js +27 -0
  92. package/build/es/components/PivotTable/hooks/useTableClipping.js +46 -0
  93. package/build/es/components/PivotTable/index.js +26 -0
  94. package/build/es/components/PivotTable/interfaces/index.js +1 -0
  95. package/build/es/components/PivotTable/services/adaptiveClippingController.js +191 -0
  96. package/build/es/components/PivotTable/services/engine.js +894 -0
  97. package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +63 -0
  98. package/build/es/components/PivotTable/utils/index.js +309 -0
  99. package/build/es/components/PivotTable/utils/isColorBright.js +22 -0
  100. package/build/es/components/PivotTable/utils/layout/dimension.js +48 -0
  101. package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +5 -0
  102. package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +5 -0
  103. package/build/es/components/PivotTable/utils/layout/dimensionIs.js +2 -0
  104. package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +2 -0
  105. package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +18 -0
  106. package/build/es/components/PivotTable/utils/legend.js +27 -0
  107. package/build/es/components/PivotTable/utils/ouIdHelper/index.js +17 -0
  108. package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
  109. package/build/es/index.js +1 -0
  110. package/build/es/locales/en/translations.json +33 -0
  111. package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +3 -0
  112. package/build/types/components/PivotTable/components/PivotTable.d.ts +12 -0
  113. package/build/types/components/PivotTable/components/PivotTableBody.d.ts +7 -0
  114. package/build/types/components/PivotTable/components/PivotTableCell.d.ts +17 -0
  115. package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +7 -0
  116. package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +13 -0
  117. package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +11 -0
  118. package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +8 -0
  119. package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +13 -0
  120. package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +7 -0
  121. package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +5 -0
  122. package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +8 -0
  123. package/build/types/components/PivotTable/components/PivotTableHead.d.ts +21 -0
  124. package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +22 -0
  125. package/build/types/components/PivotTable/components/PivotTableRow.d.ts +19 -0
  126. package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +8 -0
  127. package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +21 -0
  128. package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +12 -0
  129. package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +8 -0
  130. package/build/types/components/PivotTable/constants/dataTypes.d.ts +90 -0
  131. package/build/types/components/PivotTable/constants/pivotTable.d.ts +29 -0
  132. package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +80 -0
  133. package/build/types/components/PivotTable/constants/valueTypes.d.ts +22 -0
  134. package/build/types/components/PivotTable/hooks/useParentSize.d.ts +8 -0
  135. package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +5 -0
  136. package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +8 -0
  137. package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +24 -0
  138. package/build/types/components/PivotTable/index.d.ts +26 -0
  139. package/build/types/components/PivotTable/interfaces/index.d.ts +72 -0
  140. package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +44 -0
  141. package/build/types/components/PivotTable/services/engine.d.ts +252 -0
  142. package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +1 -0
  143. package/build/types/components/PivotTable/utils/index.d.ts +38 -0
  144. package/build/types/components/PivotTable/utils/isColorBright.d.ts +1 -0
  145. package/build/types/components/PivotTable/utils/layout/dimension.d.ts +35 -0
  146. package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +3 -0
  147. package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +3 -0
  148. package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +1 -0
  149. package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +3 -0
  150. package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +5 -0
  151. package/build/types/components/PivotTable/utils/legend.d.ts +11 -0
  152. package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +10 -0
  153. package/build/types/index.d.ts +1 -0
  154. package/package.json +6 -3
@@ -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;
@@ -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", {
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _ = require(".");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ const Template = args => /*#__PURE__*/_react.default.createElement(_.CustomPivotTable, args);
11
+ const Default = Template.bind({});
12
+ exports.Default = Default;
13
+ Default.args = {
14
+ analytics: {
15
+ "headers": [{
16
+ "name": "dx",
17
+ "column": "Data",
18
+ "valueType": "TEXT",
19
+ "type": "java.lang.String",
20
+ "hidden": false,
21
+ "meta": true
22
+ }, {
23
+ "name": "pe",
24
+ "column": "Period",
25
+ "valueType": "TEXT",
26
+ "type": "java.lang.String",
27
+ "hidden": false,
28
+ "meta": true
29
+ }, {
30
+ "name": "ou",
31
+ "column": "Organisation unit",
32
+ "valueType": "TEXT",
33
+ "type": "java.lang.String",
34
+ "hidden": false,
35
+ "meta": true
36
+ }, {
37
+ "name": "value",
38
+ "column": "Value",
39
+ "valueType": "NUMBER",
40
+ "type": "java.lang.Double",
41
+ "hidden": false,
42
+ "meta": false
43
+ }, {
44
+ "name": "numerator",
45
+ "column": "Numerator",
46
+ "valueType": "NUMBER",
47
+ "type": "java.lang.Double",
48
+ "hidden": false,
49
+ "meta": false
50
+ }, {
51
+ "name": "denominator",
52
+ "column": "Denominator",
53
+ "valueType": "NUMBER",
54
+ "type": "java.lang.Double",
55
+ "hidden": false,
56
+ "meta": false
57
+ }, {
58
+ "name": "factor",
59
+ "column": "Factor",
60
+ "valueType": "NUMBER",
61
+ "type": "java.lang.Double",
62
+ "hidden": false,
63
+ "meta": false
64
+ }, {
65
+ "name": "multiplier",
66
+ "column": "Multiplier",
67
+ "valueType": "NUMBER",
68
+ "type": "java.lang.Double",
69
+ "hidden": false,
70
+ "meta": false
71
+ }, {
72
+ "name": "divisor",
73
+ "column": "Divisor",
74
+ "valueType": "NUMBER",
75
+ "type": "java.lang.Double",
76
+ "hidden": false,
77
+ "meta": false
78
+ }],
79
+ "metaData": {
80
+ "items": {
81
+ "ou": {
82
+ "uid": "ou",
83
+ "name": "Organisation unit",
84
+ "dimensionType": "ORGANISATION_UNIT"
85
+ },
86
+ "202208": {
87
+ "uid": "202208",
88
+ "code": "202208",
89
+ "name": "August 2022",
90
+ "dimensionItemType": "PERIOD",
91
+ "valueType": "NUMBER",
92
+ "totalAggregationType": "SUM",
93
+ "startDate": "2022-08-01T00:00:00.000",
94
+ "endDate": "2022-08-31T00:00:00.000"
95
+ },
96
+ "202209": {
97
+ "uid": "202209",
98
+ "code": "202209",
99
+ "name": "September 2022",
100
+ "dimensionItemType": "PERIOD",
101
+ "valueType": "NUMBER",
102
+ "totalAggregationType": "SUM",
103
+ "startDate": "2022-09-01T00:00:00.000",
104
+ "endDate": "2022-09-30T00:00:00.000"
105
+ },
106
+ "202206": {
107
+ "uid": "202206",
108
+ "code": "202206",
109
+ "name": "June 2022",
110
+ "dimensionItemType": "PERIOD",
111
+ "valueType": "NUMBER",
112
+ "totalAggregationType": "SUM",
113
+ "startDate": "2022-06-01T00:00:00.000",
114
+ "endDate": "2022-06-30T00:00:00.000"
115
+ },
116
+ "fbfJHSPpUQD": {
117
+ "uid": "fbfJHSPpUQD",
118
+ "code": "DE_359596",
119
+ "name": "ANC 1st visit",
120
+ "legendSet": "fqs276KXCXi",
121
+ "dimensionItemType": "DATA_ELEMENT",
122
+ "valueType": "NUMBER",
123
+ "aggregationType": "SUM",
124
+ "totalAggregationType": "SUM"
125
+ },
126
+ "202207": {
127
+ "uid": "202207",
128
+ "code": "202207",
129
+ "name": "July 2022",
130
+ "dimensionItemType": "PERIOD",
131
+ "valueType": "NUMBER",
132
+ "totalAggregationType": "SUM",
133
+ "startDate": "2022-07-01T00:00:00.000",
134
+ "endDate": "2022-07-31T00:00:00.000"
135
+ },
136
+ "202204": {
137
+ "uid": "202204",
138
+ "code": "202204",
139
+ "name": "April 2022",
140
+ "dimensionItemType": "PERIOD",
141
+ "valueType": "NUMBER",
142
+ "totalAggregationType": "SUM",
143
+ "startDate": "2022-04-01T00:00:00.000",
144
+ "endDate": "2022-04-30T00:00:00.000"
145
+ },
146
+ "202205": {
147
+ "uid": "202205",
148
+ "code": "202205",
149
+ "name": "May 2022",
150
+ "dimensionItemType": "PERIOD",
151
+ "valueType": "NUMBER",
152
+ "totalAggregationType": "SUM",
153
+ "startDate": "2022-05-01T00:00:00.000",
154
+ "endDate": "2022-05-31T00:00:00.000"
155
+ },
156
+ "202202": {
157
+ "uid": "202202",
158
+ "code": "202202",
159
+ "name": "February 2022",
160
+ "dimensionItemType": "PERIOD",
161
+ "valueType": "NUMBER",
162
+ "totalAggregationType": "SUM",
163
+ "startDate": "2022-02-01T00:00:00.000",
164
+ "endDate": "2022-02-28T00:00:00.000"
165
+ },
166
+ "202301": {
167
+ "uid": "202301",
168
+ "code": "202301",
169
+ "name": "January 2023",
170
+ "dimensionItemType": "PERIOD",
171
+ "valueType": "NUMBER",
172
+ "totalAggregationType": "SUM",
173
+ "startDate": "2023-01-01T00:00:00.000",
174
+ "endDate": "2023-01-31T00:00:00.000"
175
+ },
176
+ "202203": {
177
+ "uid": "202203",
178
+ "code": "202203",
179
+ "name": "March 2022",
180
+ "dimensionItemType": "PERIOD",
181
+ "valueType": "NUMBER",
182
+ "totalAggregationType": "SUM",
183
+ "startDate": "2022-03-01T00:00:00.000",
184
+ "endDate": "2022-03-31T00:00:00.000"
185
+ },
186
+ "LAST_12_MONTHS": {
187
+ "name": "Last 12 months"
188
+ },
189
+ "202211": {
190
+ "uid": "202211",
191
+ "code": "202211",
192
+ "name": "November 2022",
193
+ "dimensionItemType": "PERIOD",
194
+ "valueType": "NUMBER",
195
+ "totalAggregationType": "SUM",
196
+ "startDate": "2022-11-01T00:00:00.000",
197
+ "endDate": "2022-11-30T00:00:00.000"
198
+ },
199
+ "202212": {
200
+ "uid": "202212",
201
+ "code": "202212",
202
+ "name": "December 2022",
203
+ "dimensionItemType": "PERIOD",
204
+ "valueType": "NUMBER",
205
+ "totalAggregationType": "SUM",
206
+ "startDate": "2022-12-01T00:00:00.000",
207
+ "endDate": "2022-12-31T00:00:00.000"
208
+ },
209
+ "ImspTQPwCqd": {
210
+ "uid": "ImspTQPwCqd",
211
+ "code": "OU_525",
212
+ "name": "Sierra Leone",
213
+ "dimensionItemType": "ORGANISATION_UNIT",
214
+ "valueType": "NUMBER",
215
+ "totalAggregationType": "SUM"
216
+ },
217
+ "202210": {
218
+ "uid": "202210",
219
+ "code": "202210",
220
+ "name": "October 2022",
221
+ "dimensionItemType": "PERIOD",
222
+ "valueType": "NUMBER",
223
+ "totalAggregationType": "SUM",
224
+ "startDate": "2022-10-01T00:00:00.000",
225
+ "endDate": "2022-10-31T00:00:00.000"
226
+ },
227
+ "dx": {
228
+ "uid": "dx",
229
+ "name": "Data",
230
+ "dimensionType": "DATA_X"
231
+ },
232
+ "pq2XI5kz2BY": {
233
+ "uid": "pq2XI5kz2BY",
234
+ "code": "COC_167661",
235
+ "name": "Fixed",
236
+ "valueType": "NUMBER",
237
+ "totalAggregationType": "SUM"
238
+ },
239
+ "pe": {
240
+ "uid": "pe",
241
+ "name": "Period",
242
+ "dimensionType": "PERIOD"
243
+ },
244
+ "PT59n8BQbqM": {
245
+ "uid": "PT59n8BQbqM",
246
+ "code": "COC_167660",
247
+ "name": "Outreach",
248
+ "valueType": "NUMBER",
249
+ "totalAggregationType": "SUM"
250
+ }
251
+ },
252
+ "dimensions": {
253
+ "dx": ["fbfJHSPpUQD"],
254
+ "pe": ["202202", "202203", "202204", "202205", "202206", "202207", "202208", "202209", "202210", "202211", "202212", "202301"],
255
+ "ou": ["ImspTQPwCqd"],
256
+ "co": ["pq2XI5kz2BY", "PT59n8BQbqM"]
257
+ }
258
+ },
259
+ "rows": [["fbfJHSPpUQD", "202209", "ImspTQPwCqd", "22308", "", "", "", "", ""], ["fbfJHSPpUQD", "202301", "ImspTQPwCqd", "20020", "", "", "", "", ""], ["fbfJHSPpUQD", "202206", "ImspTQPwCqd", "23813", "", "", "", "", ""], ["fbfJHSPpUQD", "202210", "ImspTQPwCqd", "17926", "", "", "", "", ""], ["fbfJHSPpUQD", "202207", "ImspTQPwCqd", "22356", "", "", "", "", ""], ["fbfJHSPpUQD", "202208", "ImspTQPwCqd", "22004", "", "", "", "", ""], ["fbfJHSPpUQD", "202212", "ImspTQPwCqd", "16445", "", "", "", "", ""], ["fbfJHSPpUQD", "202202", "ImspTQPwCqd", "18786", "", "", "", "", ""], ["fbfJHSPpUQD", "202211", "ImspTQPwCqd", "19691", "", "", "", "", ""], ["fbfJHSPpUQD", "202205", "ImspTQPwCqd", "29461", "", "", "", "", ""], ["fbfJHSPpUQD", "202203", "ImspTQPwCqd", "21877", "", "", "", "", ""], ["fbfJHSPpUQD", "202204", "ImspTQPwCqd", "18576", "", "", "", "", ""]],
260
+ "height": 0,
261
+ "width": 0,
262
+ "headerWidth": 0
263
+ },
264
+ config: {
265
+ layout: {
266
+ columns: ["dx"],
267
+ rows: ["ou", "pe"],
268
+ filter: []
269
+ },
270
+ options: {}
271
+ }
272
+ };
273
+ var _default = {
274
+ title: "Analytics/Pivot table",
275
+ component: _.CustomPivotTable
276
+ };
277
+ exports.default = _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const AssignedCategoriesIcon = () => {
10
+ return /*#__PURE__*/_react.default.createElement("svg", {
11
+ height: "16",
12
+ viewBox: "0 0 16 16",
13
+ width: "16"
14
+ }, /*#__PURE__*/_react.default.createElement("g", {
15
+ fill: "#212934",
16
+ fillRule: "evenodd"
17
+ }, /*#__PURE__*/_react.default.createElement("path", {
18
+ d: "m2 7h11v1h-11z"
19
+ }), /*#__PURE__*/_react.default.createElement("path", {
20
+ d: "m2 13h11v1h-11z"
21
+ }), /*#__PURE__*/_react.default.createElement("path", {
22
+ d: "m2 2h11v1h-11z"
23
+ }), /*#__PURE__*/_react.default.createElement("path", {
24
+ d: "m7 8h1v5h-1z"
25
+ }), /*#__PURE__*/_react.default.createElement("path", {
26
+ d: "m12 3h1v10h-1z"
27
+ }), /*#__PURE__*/_react.default.createElement("path", {
28
+ d: "m2 3h1v10h-1z"
29
+ })));
30
+ };
31
+ var _default = AssignedCategoriesIcon;
32
+ exports.default = _default;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTable = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _engine = require("../services/engine");
9
+ var _PivotTableBody = require("./PivotTableBody");
10
+ var _PivotTableContainer = require("./PivotTableContainer");
11
+ var _PivotTableEngineContext = require("./PivotTableEngineContext");
12
+ var _PivotTableHead = require("./PivotTableHead");
13
+ var _useTableClipping = require("../hooks/useTableClipping");
14
+ var _useSortableColumns = require("../hooks/useSortableColumns");
15
+ var _useParentSize = require("../hooks/useParentSize");
16
+ 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); }
17
+ 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; }
18
+ const PivotTable = _ref => {
19
+ let {
20
+ visualization,
21
+ data,
22
+ legendSets,
23
+ renderCounter,
24
+ tableProps,
25
+ onToggleContextualMenu
26
+ } = _ref;
27
+ const containerRef = (0, _react.useRef)(null);
28
+ const {
29
+ width,
30
+ height
31
+ } = (0, _useParentSize.useParentSize)(containerRef, renderCounter !== null && renderCounter !== void 0 ? renderCounter : 1);
32
+ const engine = (0, _react.useMemo)(() => new _engine.PivotTableEngine(visualization, data, legendSets), [visualization, data, legendSets]);
33
+ const {
34
+ sortBy,
35
+ onSortByColumn
36
+ } = (0, _useSortableColumns.useSortableColumns)(engine);
37
+ const clippingResult = (0, _useTableClipping.useTableClipping)({
38
+ containerRef,
39
+ width,
40
+ height,
41
+ engine
42
+ });
43
+ return /*#__PURE__*/_react.default.createElement(_PivotTableEngineContext.Provider, {
44
+ engine: engine
45
+ }, /*#__PURE__*/_react.default.createElement(_PivotTableContainer.PivotTableContainer, {
46
+ tableProps: tableProps,
47
+ ref: containerRef,
48
+ width: width,
49
+ height: height
50
+ }, /*#__PURE__*/_react.default.createElement(_PivotTableHead.PivotTableHead, {
51
+ clippingResult: clippingResult,
52
+ width: width,
53
+ sortBy: sortBy,
54
+ onSortByColumn: onSortByColumn
55
+ }), /*#__PURE__*/_react.default.createElement(_PivotTableBody.PivotTableBody, {
56
+ clippingResult: clippingResult,
57
+ onToggleContextualMenu: onToggleContextualMenu
58
+ })));
59
+ };
60
+ exports.PivotTable = PivotTable;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTableBody = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _PivotTableClippedAxis = require("./PivotTableClippedAxis.js");
9
+ var _PivotTableEmptyRow = require("./PivotTableEmptyRow");
10
+ var _PivotTableRow = require("./PivotTableRow.js");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ const PivotTableBody = _ref => {
13
+ let {
14
+ clippingResult,
15
+ onToggleContextualMenu
16
+ } = _ref;
17
+ return /*#__PURE__*/_react.default.createElement("tbody", null, /*#__PURE__*/_react.default.createElement(_PivotTableClippedAxis.PivotTableClippedAxis, {
18
+ axisClippingResult: clippingResult.rows,
19
+ EmptyComponent: _ref2 => {
20
+ let {
21
+ size
22
+ } = _ref2;
23
+ return /*#__PURE__*/_react.default.createElement(_PivotTableEmptyRow.PivotTableEmptyRow, {
24
+ height: size,
25
+ columns: clippingResult.columns.indices
26
+ });
27
+ },
28
+ ItemComponent: _ref3 => {
29
+ let {
30
+ index
31
+ } = _ref3;
32
+ return /*#__PURE__*/_react.default.createElement(_PivotTableRow.PivotTableRow, {
33
+ key: index,
34
+ clippingResult: clippingResult,
35
+ rowIndex: index,
36
+ onToggleContextualMenu: onToggleContextualMenu
37
+ });
38
+ }
39
+ }));
40
+ };
41
+ exports.PivotTableBody = PivotTableBody;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTableCell = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _PivotTableEngineContext = require("./PivotTableEngineContext.js");
9
+ var _ui = require("@dhis2/ui");
10
+ var _pivotTable = require("../constants/pivotTable");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
13
+ const PivotTableCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
14
+ let {
15
+ classes,
16
+ isHeader = false,
17
+ index,
18
+ isSortable,
19
+ sortBy,
20
+ children,
21
+ dataTest,
22
+ onSortClick,
23
+ style = {},
24
+ ...props
25
+ } = _ref;
26
+ const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
27
+ if (!engine) {
28
+ return null;
29
+ }
30
+ style.width = style.minWidth = style.maxWidth = style.width;
31
+ style.height = style.minHeight = style.maxHeight = style.height || engine.fontSize + engine.cellPadding * 2 + 2;
32
+ return isHeader ? /*#__PURE__*/_react.default.createElement(_ui.DataTableColumnHeader, _extends({
33
+ onSortIconClick: isSortable ? onSortClick : undefined,
34
+ sortDirection: isSortable ? (sortBy === null || sortBy === void 0 ? void 0 : sortBy.column) === index ? (sortBy === null || sortBy === void 0 ? void 0 : sortBy.order) === _pivotTable.SORT_ORDER_DESCENDING ? "desc" : sortBy.order === _pivotTable.SORT_ORDER_ASCENDING ? "asc" : "default" : undefined : undefined
35
+ }, props), children) : /*#__PURE__*/_react.default.createElement(_ui.DataTableCell, {
36
+ ref: ref
37
+ }, children);
38
+ });
39
+ exports.PivotTableCell = PivotTableCell;
40
+ PivotTableCell.displayName = "PivotTableCell";
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTableClippedAxis = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ const PivotTableClippedAxis = _ref => {
10
+ let {
11
+ axisClippingResult,
12
+ EmptyComponent,
13
+ ItemComponent
14
+ } = _ref;
15
+ return [axisClippingResult.pre ? /*#__PURE__*/_react.default.createElement(EmptyComponent, {
16
+ key: "pre",
17
+ size: axisClippingResult.pre
18
+ }) : null, axisClippingResult.indices.map(index => /*#__PURE__*/_react.default.createElement(ItemComponent, {
19
+ key: index,
20
+ index: index
21
+ })), axisClippingResult.post ? /*#__PURE__*/_react.default.createElement(EmptyComponent, {
22
+ key: "post",
23
+ size: axisClippingResult.post
24
+ }) : null];
25
+ };
26
+ exports.PivotTableClippedAxis = PivotTableClippedAxis;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PivotTableColumnHeaderCell = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _PivotTableCell = require("./PivotTableCell");
9
+ var _PivotTableEngineContext = require("./PivotTableEngineContext");
10
+ var _PivotTableHeaderCell = require("./PivotTableHeaderCell");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ // @ts-nocheck
13
+
14
+ const PivotTableColumnHeaderCell = _ref => {
15
+ var _engine$adaptiveClipp;
16
+ let {
17
+ clippingResult,
18
+ index,
19
+ level,
20
+ onSortByColumn,
21
+ sortBy
22
+ } = _ref;
23
+ const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
24
+ if (!engine) {
25
+ return null;
26
+ }
27
+ const width = (_engine$adaptiveClipp = engine.adaptiveClippingController.columns.sizes[engine.columnMap[index]]) === null || _engine$adaptiveClipp === void 0 ? void 0 : _engine$adaptiveClipp.size;
28
+ const height = engine.adaptiveClippingController.rows.headerSizes[level];
29
+ return /*#__PURE__*/_react.default.createElement(_PivotTableHeaderCell.PivotTableHeaderCell, {
30
+ axisClippingResult: clippingResult.columns,
31
+ index: index,
32
+ level: level,
33
+ getHeader: idx => engine.getColumnHeader(idx),
34
+ showHierarchy: engine.visualization.showHierarchy,
35
+ render: header => {
36
+ const isSortable = level === engine.columnDepth - 1 && header.span === 1 && engine.isSortable(index);
37
+ const style = {
38
+ cursor: isSortable ? "pointer" : "default",
39
+ width,
40
+ height,
41
+ whiteSpace: level === engine.columnDepth - 1 ? "pre-line" : "nowrap"
42
+ };
43
+ if (engine.options.fixColumnHeaders) {
44
+ style.top = level * (engine.fontSize + engine.cellPadding * 2 + 2);
45
+ // left value for the column header cells should be sum of row headers' width when engine.options.fixRowHeaders is true
46
+ style.left = engine.options.fixRowHeaders ? engine.rowHeaderPixelWidth : 0;
47
+ }
48
+ return /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
49
+ index: index,
50
+ isSortable: isSortable,
51
+ sortOrder: sortBy,
52
+ onSortClick: isSortable ? () => onSortByColumn(index) : undefined,
53
+ isHeader: true,
54
+ classes: [header.label && header.label !== "Total" && header.label !== "Subtotal" // TODO: Actually look up the column type!
55
+ ? "column-header" : "empty-header", {
56
+ "fixed-header": engine.options.fixColumnHeaders
57
+ }],
58
+ colSpan: header.span,
59
+ title: header.label,
60
+ style: style,
61
+ onClick: isSortable ? () => onSortByColumn(index) : undefined
62
+ }, /*#__PURE__*/_react.default.createElement("div", {
63
+ className: "column-header-inner"
64
+ }, /*#__PURE__*/_react.default.createElement("span", {
65
+ className: "column-header-label",
66
+ "data-test": "visualization-column-header"
67
+ }, header.label)));
68
+ }
69
+ });
70
+ };
71
+ exports.PivotTableColumnHeaderCell = PivotTableColumnHeaderCell;