@hisptz/dhis2-analytics 1.0.9 → 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.
- package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +6 -6
- package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +2 -4
- package/build/cjs/components/ChartAnalytics/index.js +25 -17
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/cjs/components/Map/Map.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +3 -12
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/PivotTable/PivotTable.stories.js +277 -0
- package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +32 -0
- package/build/cjs/components/PivotTable/components/PivotTable.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableBody.js +41 -0
- package/build/cjs/components/PivotTable/components/PivotTableCell.js +40 -0
- package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +26 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +71 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableContainer.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +77 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +22 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableEngineContext.js +25 -0
- package/build/cjs/components/PivotTable/components/PivotTableHead.js +35 -0
- package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +37 -0
- package/build/cjs/components/PivotTable/components/PivotTableRow.js +65 -0
- package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +49 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +52 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +46 -0
- package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +69 -0
- package/build/cjs/components/PivotTable/constants/dataTypes.js +129 -0
- package/build/cjs/components/PivotTable/constants/pivotTable.js +64 -0
- package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +62 -0
- package/build/cjs/components/PivotTable/constants/valueTypes.js +55 -0
- package/build/cjs/components/PivotTable/data/column-data.json +210 -0
- package/build/cjs/components/PivotTable/hooks/useParentSize.js +41 -0
- package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +38 -0
- package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +34 -0
- package/build/cjs/components/PivotTable/hooks/useTableClipping.js +53 -0
- package/build/cjs/components/PivotTable/index.js +47 -0
- package/build/cjs/components/PivotTable/interfaces/index.js +1 -0
- package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +197 -0
- package/build/cjs/components/PivotTable/services/engine.js +901 -0
- package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +71 -0
- package/build/cjs/components/PivotTable/utils/index.js +322 -0
- package/build/cjs/components/PivotTable/utils/isColorBright.js +29 -0
- package/build/cjs/components/PivotTable/utils/layout/dimension.js +61 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +25 -0
- package/build/cjs/components/PivotTable/utils/legend.js +40 -0
- package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +27 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/cjs/index.js +11 -0
- package/build/cjs/locales/en/translations.json +33 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +3 -3
- package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +2 -3
- package/build/es/components/ChartAnalytics/index.js +2 -3
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/es/components/Map/Map.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +9 -8
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/es/components/PivotTable/PivotTable.stories.js +268 -0
- package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +24 -0
- package/build/es/components/PivotTable/components/PivotTable.js +51 -0
- package/build/es/components/PivotTable/components/PivotTableBody.js +33 -0
- package/build/es/components/PivotTable/components/PivotTableCell.js +32 -0
- package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +18 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +62 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +52 -0
- package/build/es/components/PivotTable/components/PivotTableContainer.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +68 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableEngineContext.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableHead.js +27 -0
- package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +29 -0
- package/build/es/components/PivotTable/components/PivotTableRow.js +57 -0
- package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +41 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRow.js +42 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRows.js +37 -0
- package/build/es/components/PivotTable/components/PivotTableValueCell.js +60 -0
- package/build/es/components/PivotTable/constants/dataTypes.js +98 -0
- package/build/es/components/PivotTable/constants/pivotTable.js +29 -0
- package/build/es/components/PivotTable/constants/predefinedDimensions.js +44 -0
- package/build/es/components/PivotTable/constants/valueTypes.js +27 -0
- package/build/es/components/PivotTable/data/column-data.json +210 -0
- package/build/es/components/PivotTable/hooks/useParentSize.js +33 -0
- package/build/es/components/PivotTable/hooks/useScrollPosition.js +30 -0
- package/build/es/components/PivotTable/hooks/useSortableColumns.js +27 -0
- package/build/es/components/PivotTable/hooks/useTableClipping.js +46 -0
- package/build/es/components/PivotTable/index.js +26 -0
- package/build/es/components/PivotTable/interfaces/index.js +1 -0
- package/build/es/components/PivotTable/services/adaptiveClippingController.js +191 -0
- package/build/es/components/PivotTable/services/engine.js +894 -0
- package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +63 -0
- package/build/es/components/PivotTable/utils/index.js +309 -0
- package/build/es/components/PivotTable/utils/isColorBright.js +22 -0
- package/build/es/components/PivotTable/utils/layout/dimension.js +48 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIs.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +18 -0
- package/build/es/components/PivotTable/utils/legend.js +27 -0
- package/build/es/components/PivotTable/utils/ouIdHelper/index.js +17 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +33 -0
- package/build/types/components/ChartAnalytics/components/DownloadMenu/index.d.ts +1 -2
- package/build/types/components/ChartAnalytics/index.d.ts +3 -3
- package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +3 -0
- package/build/types/components/PivotTable/components/PivotTable.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableBody.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableCell.d.ts +17 -0
- package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +11 -0
- package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +5 -0
- package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableHead.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +22 -0
- package/build/types/components/PivotTable/components/PivotTableRow.d.ts +19 -0
- package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +8 -0
- package/build/types/components/PivotTable/constants/dataTypes.d.ts +90 -0
- package/build/types/components/PivotTable/constants/pivotTable.d.ts +29 -0
- package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +80 -0
- package/build/types/components/PivotTable/constants/valueTypes.d.ts +22 -0
- package/build/types/components/PivotTable/hooks/useParentSize.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +5 -0
- package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +24 -0
- package/build/types/components/PivotTable/index.d.ts +26 -0
- package/build/types/components/PivotTable/interfaces/index.d.ts +72 -0
- package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +44 -0
- package/build/types/components/PivotTable/services/engine.d.ts +252 -0
- package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +1 -0
- package/build/types/components/PivotTable/utils/index.d.ts +38 -0
- package/build/types/components/PivotTable/utils/isColorBright.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimension.d.ts +35 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +5 -0
- package/build/types/components/PivotTable/utils/legend.d.ts +11 -0
- package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +10 -0
- package/build/types/index.d.ts +1 -0
- package/package.json +6 -3
|
@@ -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;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableColumnHeaders = void 0;
|
|
7
|
+
var _times = _interopRequireDefault(require("lodash/times"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _PivotTableClippedAxis = require("./PivotTableClippedAxis");
|
|
10
|
+
var _PivotTableColumnHeaderCell = require("./PivotTableColumnHeaderCell");
|
|
11
|
+
var _PivotTableDimensionLabelCell = require("./PivotTableDimensionLabelCell");
|
|
12
|
+
var _PivotTableEmptyCell = require("./PivotTableEmptyCell");
|
|
13
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
const PivotTableColumnHeaders = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
clippingResult,
|
|
18
|
+
onSortByColumn,
|
|
19
|
+
sortBy
|
|
20
|
+
} = _ref;
|
|
21
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
22
|
+
if (!engine) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const columns = (0, _times.default)(engine.columnDepth, x => x);
|
|
26
|
+
const rows = (0, _times.default)(engine.rowDepth, x => x);
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, columns.map(columnLevel => /*#__PURE__*/_react.default.createElement("tr", {
|
|
28
|
+
key: columnLevel
|
|
29
|
+
}, rows.map(rowLevel => /*#__PURE__*/_react.default.createElement(_PivotTableDimensionLabelCell.PivotTableDimensionLabelCell, {
|
|
30
|
+
key: rowLevel,
|
|
31
|
+
rowLevel: rowLevel,
|
|
32
|
+
columnLevel: columnLevel
|
|
33
|
+
})), /*#__PURE__*/_react.default.createElement(_PivotTableClippedAxis.PivotTableClippedAxis, {
|
|
34
|
+
axisClippingResult: clippingResult.columns,
|
|
35
|
+
EmptyComponent: _ref2 => {
|
|
36
|
+
let {
|
|
37
|
+
size
|
|
38
|
+
} = _ref2;
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableEmptyCell.PivotTableEmptyCell, {
|
|
40
|
+
classes: "column-header",
|
|
41
|
+
style: {
|
|
42
|
+
minWidth: size
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
ItemComponent: _ref3 => {
|
|
47
|
+
let {
|
|
48
|
+
index
|
|
49
|
+
} = _ref3;
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableColumnHeaderCell.PivotTableColumnHeaderCell, {
|
|
51
|
+
clippingResult: clippingResult,
|
|
52
|
+
index: index,
|
|
53
|
+
level: columnLevel,
|
|
54
|
+
onSortByColumn: onSortByColumn,
|
|
55
|
+
sortBy: sortBy
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}))));
|
|
59
|
+
};
|
|
60
|
+
exports.PivotTableColumnHeaders = PivotTableColumnHeaders;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableContainer = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
9
|
+
var _ui = require("@dhis2/ui");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const PivotTableContainer = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
width,
|
|
14
|
+
height,
|
|
15
|
+
children,
|
|
16
|
+
tableProps
|
|
17
|
+
} = _ref;
|
|
18
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
19
|
+
if (!engine) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
23
|
+
className: "pivot-table-container",
|
|
24
|
+
style: {
|
|
25
|
+
width,
|
|
26
|
+
height
|
|
27
|
+
},
|
|
28
|
+
ref: ref,
|
|
29
|
+
"data-test": "visualization-container"
|
|
30
|
+
}, width === 0 || height === 0 ? null : /*#__PURE__*/_react.default.createElement(_ui.DataTable, tableProps !== null && tableProps !== void 0 ? tableProps : {}, children));
|
|
31
|
+
});
|
|
32
|
+
exports.PivotTableContainer = PivotTableContainer;
|
|
33
|
+
PivotTableContainer.displayName = "PivotTableContainer";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableDimensionLabelCell = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _PivotTableCell = require("./PivotTableCell");
|
|
10
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
// @ts-nocheck
|
|
13
|
+
|
|
14
|
+
const PivotTableDimensionLabelCell = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
rowLevel,
|
|
17
|
+
columnLevel
|
|
18
|
+
} = _ref;
|
|
19
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
20
|
+
if (!engine) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const colCount = engine.rowDepth;
|
|
24
|
+
const rowCount = engine.columnDepth;
|
|
25
|
+
let colSpan = 1,
|
|
26
|
+
rowSpan = 1,
|
|
27
|
+
label;
|
|
28
|
+
if (!engine.visualization.showDimensionLabels) {
|
|
29
|
+
if (rowLevel > 0 || columnLevel > 0) {
|
|
30
|
+
colSpan = rowSpan = 0;
|
|
31
|
+
} else {
|
|
32
|
+
colSpan = colCount;
|
|
33
|
+
rowSpan = rowCount;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
label = engine.getDimensionLabel(rowLevel, columnLevel);
|
|
37
|
+
if (!label) {
|
|
38
|
+
if (rowLevel > 0 || columnLevel > 0) {
|
|
39
|
+
colSpan = rowSpan = 0;
|
|
40
|
+
} else {
|
|
41
|
+
colSpan = colCount - 1;
|
|
42
|
+
rowSpan = rowCount - 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!colSpan || !rowSpan) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const width = engine.adaptiveClippingController.columns.headerSizes[rowLevel];
|
|
50
|
+
const height = engine.adaptiveClippingController.rows.headerSizes[columnLevel];
|
|
51
|
+
const style = {
|
|
52
|
+
width,
|
|
53
|
+
height
|
|
54
|
+
};
|
|
55
|
+
if (engine.options.fixColumnHeaders || engine.options.fixRowHeaders) {
|
|
56
|
+
style.zIndex = engine.options.fixColumnHeaders && engine.options.fixRowHeaders ? 2 : 1;
|
|
57
|
+
style.top = engine.options.fixColumnHeaders ? columnLevel * (engine.fontSize + engine.cellPadding * 2 + 2) : 0;
|
|
58
|
+
style.left = engine.options.fixRowHeaders ?
|
|
59
|
+
// calculate the width of all row header cells on the left of current cell
|
|
60
|
+
engine.adaptiveClippingController.columns.headerSizes.slice(0, rowLevel).reduce((width, acc) => acc += width, 0) : 0;
|
|
61
|
+
}
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
|
|
63
|
+
isHeader: true,
|
|
64
|
+
classes: ["empty-header", "column-header", {
|
|
65
|
+
"fixed-header": engine.options.fixColumnHeaders || engine.options.fixRowHeaders
|
|
66
|
+
}],
|
|
67
|
+
colSpan: colSpan,
|
|
68
|
+
rowSpan: rowSpan,
|
|
69
|
+
title: label,
|
|
70
|
+
style: style
|
|
71
|
+
}, label);
|
|
72
|
+
};
|
|
73
|
+
exports.PivotTableDimensionLabelCell = PivotTableDimensionLabelCell;
|
|
74
|
+
PivotTableDimensionLabelCell.propTypes = {
|
|
75
|
+
columnLevel: _propTypes.default.number.isRequired,
|
|
76
|
+
rowLevel: _propTypes.default.number.isRequired
|
|
77
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableEmptyCell = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PivotTableCell = require("./PivotTableCell");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
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); }
|
|
11
|
+
const PivotTableEmptyCell = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
12
|
+
let {
|
|
13
|
+
onClick,
|
|
14
|
+
classes,
|
|
15
|
+
...props
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, _extends({
|
|
18
|
+
ref: ref
|
|
19
|
+
}, props));
|
|
20
|
+
});
|
|
21
|
+
exports.PivotTableEmptyCell = PivotTableEmptyCell;
|
|
22
|
+
PivotTableEmptyCell.displayName = "PivotTableEmptyCell";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableEmptyRow = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PivotTableCell = require("./PivotTableCell");
|
|
9
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const PivotTableEmptyRow = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
height,
|
|
14
|
+
columns
|
|
15
|
+
} = _ref;
|
|
16
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
17
|
+
if (!engine) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
|
|
21
|
+
isHeader: true,
|
|
22
|
+
colSpan: engine.rowDepth,
|
|
23
|
+
style: {
|
|
24
|
+
height
|
|
25
|
+
},
|
|
26
|
+
classes: ["row-header", {
|
|
27
|
+
"fixed-header": engine.options.fixRowHeaders
|
|
28
|
+
}]
|
|
29
|
+
}), columns.map(i => /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
|
|
30
|
+
key: i
|
|
31
|
+
})));
|
|
32
|
+
};
|
|
33
|
+
exports.PivotTableEmptyRow = PivotTableEmptyRow;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.usePivotTableEngine = exports.Provider = exports.PivotTableEngineContext = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
const PivotTableEngineContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
11
|
+
exports.PivotTableEngineContext = PivotTableEngineContext;
|
|
12
|
+
const Provider = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
engine,
|
|
15
|
+
children
|
|
16
|
+
} = _ref;
|
|
17
|
+
return /*#__PURE__*/_react.default.createElement(PivotTableEngineContext.Provider, {
|
|
18
|
+
value: engine
|
|
19
|
+
}, children);
|
|
20
|
+
};
|
|
21
|
+
exports.Provider = Provider;
|
|
22
|
+
const usePivotTableEngine = () => {
|
|
23
|
+
return (0, _react.useContext)(PivotTableEngineContext);
|
|
24
|
+
};
|
|
25
|
+
exports.usePivotTableEngine = usePivotTableEngine;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableHead = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _PivotTableColumnHeaders = require("./PivotTableColumnHeaders.js");
|
|
10
|
+
var _PivotTableTitleRows = require("./PivotTableTitleRows");
|
|
11
|
+
var _ui = require("@dhis2/ui");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
const PivotTableHead = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
clippingResult,
|
|
16
|
+
width,
|
|
17
|
+
sortBy,
|
|
18
|
+
onSortByColumn
|
|
19
|
+
} = _ref;
|
|
20
|
+
return /*#__PURE__*/_react.default.createElement(_ui.TableHead, null, /*#__PURE__*/_react.default.createElement(_PivotTableTitleRows.PivotTableTitleRows, {
|
|
21
|
+
clippingResult: clippingResult,
|
|
22
|
+
width: width
|
|
23
|
+
}), /*#__PURE__*/_react.default.createElement(_PivotTableColumnHeaders.PivotTableColumnHeaders, {
|
|
24
|
+
clippingResult: clippingResult,
|
|
25
|
+
sortBy: sortBy,
|
|
26
|
+
onSortByColumn: onSortByColumn
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
exports.PivotTableHead = PivotTableHead;
|
|
30
|
+
PivotTableHead.propTypes = {
|
|
31
|
+
clippingResult: _propTypes.default.object.isRequired,
|
|
32
|
+
width: _propTypes.default.number.isRequired,
|
|
33
|
+
onSortByColumn: _propTypes.default.func.isRequired,
|
|
34
|
+
sortBy: _propTypes.default.object
|
|
35
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableHeaderCell = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const PivotTableHeaderCell = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
axisClippingResult,
|
|
13
|
+
index,
|
|
14
|
+
level,
|
|
15
|
+
getHeader,
|
|
16
|
+
render,
|
|
17
|
+
showHierarchy
|
|
18
|
+
} = _ref;
|
|
19
|
+
const header = (0, _utils.getHeaderForDisplay)({
|
|
20
|
+
start: axisClippingResult.indices[0],
|
|
21
|
+
count: axisClippingResult.indices.length,
|
|
22
|
+
index,
|
|
23
|
+
dimensionLevel: level,
|
|
24
|
+
getHeader,
|
|
25
|
+
showHierarchy
|
|
26
|
+
});
|
|
27
|
+
return !header ? null : render(header);
|
|
28
|
+
};
|
|
29
|
+
exports.PivotTableHeaderCell = PivotTableHeaderCell;
|
|
30
|
+
PivotTableHeaderCell.propTypes = {
|
|
31
|
+
axisClippingResult: _propTypes.default.object.isRequired,
|
|
32
|
+
getHeader: _propTypes.default.func.isRequired,
|
|
33
|
+
index: _propTypes.default.number.isRequired,
|
|
34
|
+
level: _propTypes.default.number.isRequired,
|
|
35
|
+
render: _propTypes.default.func.isRequired,
|
|
36
|
+
showHierarchy: _propTypes.default.bool.isRequired
|
|
37
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableRow = void 0;
|
|
7
|
+
var _times = _interopRequireDefault(require("lodash/times"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _PivotTableClippedAxis = require("./PivotTableClippedAxis.js");
|
|
11
|
+
var _PivotTableEmptyCell = require("./PivotTableEmptyCell");
|
|
12
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
13
|
+
var _PivotTableRowHeaderCell = require("./PivotTableRowHeaderCell.js");
|
|
14
|
+
var _PivotTableValueCell = require("./PivotTableValueCell");
|
|
15
|
+
var _ui = require("@dhis2/ui");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
const PivotTableRow = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
clippingResult,
|
|
20
|
+
rowIndex,
|
|
21
|
+
onToggleContextualMenu
|
|
22
|
+
} = _ref;
|
|
23
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
24
|
+
if (!engine) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, null, (0, _times.default)(engine.rowDepth, x => x).map(rowLevel => /*#__PURE__*/_react.default.createElement(_PivotTableRowHeaderCell.PivotTableRowHeaderCell, {
|
|
28
|
+
key: rowLevel,
|
|
29
|
+
clippingResult: clippingResult,
|
|
30
|
+
rowIndex: rowIndex,
|
|
31
|
+
rowLevel: rowLevel
|
|
32
|
+
})), /*#__PURE__*/_react.default.createElement(_PivotTableClippedAxis.PivotTableClippedAxis, {
|
|
33
|
+
axisClippingResult: clippingResult.columns,
|
|
34
|
+
EmptyComponent: _ref2 => {
|
|
35
|
+
let {
|
|
36
|
+
size
|
|
37
|
+
} = _ref2;
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableEmptyCell.PivotTableEmptyCell, {
|
|
39
|
+
classes: "value",
|
|
40
|
+
style: {
|
|
41
|
+
width: size
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
ItemComponent: _ref3 => {
|
|
46
|
+
let {
|
|
47
|
+
index: columnIndex
|
|
48
|
+
} = _ref3;
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableValueCell.PivotTableValueCell, {
|
|
50
|
+
row: rowIndex,
|
|
51
|
+
column: columnIndex,
|
|
52
|
+
onToggleContextualMenu: onToggleContextualMenu
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
exports.PivotTableRow = PivotTableRow;
|
|
58
|
+
PivotTableRow.propTypes = {
|
|
59
|
+
clippingResult: _propTypes.default.shape({
|
|
60
|
+
columns: _propTypes.default.object.isRequired,
|
|
61
|
+
rows: _propTypes.default.object.isRequired
|
|
62
|
+
}).isRequired,
|
|
63
|
+
rowIndex: _propTypes.default.number.isRequired,
|
|
64
|
+
onToggleContextualMenu: _propTypes.default.func
|
|
65
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableRowHeaderCell = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _PivotTableCell = require("./PivotTableCell");
|
|
9
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
10
|
+
var _PivotTableHeaderCell = require("./PivotTableHeaderCell.js");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const PivotTableRowHeaderCell = _ref => {
|
|
13
|
+
var _engine$adaptiveClipp;
|
|
14
|
+
let {
|
|
15
|
+
clippingResult,
|
|
16
|
+
rowIndex,
|
|
17
|
+
rowLevel
|
|
18
|
+
} = _ref;
|
|
19
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
20
|
+
if (!engine) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const width = engine.adaptiveClippingController.columns.headerSizes[rowLevel];
|
|
24
|
+
const height = (_engine$adaptiveClipp = engine.adaptiveClippingController.rows.sizes[engine.rowMap[rowIndex]]) === null || _engine$adaptiveClipp === void 0 ? void 0 : _engine$adaptiveClipp.size;
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTableHeaderCell.PivotTableHeaderCell, {
|
|
26
|
+
axisClippingResult: clippingResult.rows,
|
|
27
|
+
index: rowIndex,
|
|
28
|
+
level: rowLevel,
|
|
29
|
+
getHeader: idx => engine.getRowHeader(idx),
|
|
30
|
+
showHierarchy: engine.visualization.showHierarchy,
|
|
31
|
+
render: header => /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
|
|
32
|
+
isHeader: true,
|
|
33
|
+
classes: [header.label && header.label !== "Total" && header.label !== "Subtotal" ? "row-header" : "empty-header", header.includesHierarchy && "row-header-hierarchy", {
|
|
34
|
+
"fixed-header": engine.options.fixRowHeaders
|
|
35
|
+
}],
|
|
36
|
+
rowSpan: header.span,
|
|
37
|
+
title: header.label,
|
|
38
|
+
style: {
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
left: rowLevel > 0 ?
|
|
42
|
+
// calculate the width of all row header cells on the left of current cell
|
|
43
|
+
engine.adaptiveClippingController.columns.headerSizes.slice(0, rowLevel).reduce((width, acc) => acc += width, 0) : 0
|
|
44
|
+
},
|
|
45
|
+
dataTest: "visualization-row-header"
|
|
46
|
+
}, header.label)
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
exports.PivotTableRowHeaderCell = PivotTableRowHeaderCell;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PivotTableTitleRow = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _PivotTableCell = require("./PivotTableCell");
|
|
10
|
+
var _PivotTableEngineContext = require("./PivotTableEngineContext");
|
|
11
|
+
var _ui = require("@dhis2/ui");
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
const PivotTableTitleRow = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
title,
|
|
18
|
+
scrollPosition,
|
|
19
|
+
containerWidth,
|
|
20
|
+
totalWidth
|
|
21
|
+
} = _ref;
|
|
22
|
+
const engine = (0, _PivotTableEngineContext.usePivotTableEngine)();
|
|
23
|
+
if (!engine) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const columnCount = engine.width + engine.rowDepth;
|
|
27
|
+
const [position, setPosition] = (0, _react.useState)(scrollPosition.x);
|
|
28
|
+
(0, _react.useEffect)(() => {
|
|
29
|
+
setPosition(Math.max(0, Math.min(scrollPosition.x, totalWidth - containerWidth)));
|
|
30
|
+
}, [containerWidth, scrollPosition.x, totalWidth]);
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_ui.DataTableRow, null, /*#__PURE__*/_react.default.createElement(_PivotTableCell.PivotTableCell, {
|
|
32
|
+
isHeader: true,
|
|
33
|
+
classes: ["column-header", "title"],
|
|
34
|
+
colSpan: columnCount
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
+
style: {
|
|
37
|
+
marginLeft: position,
|
|
38
|
+
maxWidth: containerWidth,
|
|
39
|
+
textAlign: "center"
|
|
40
|
+
},
|
|
41
|
+
"data-test": "visualization-title"
|
|
42
|
+
}, title)));
|
|
43
|
+
};
|
|
44
|
+
exports.PivotTableTitleRow = PivotTableTitleRow;
|
|
45
|
+
PivotTableTitleRow.propTypes = {
|
|
46
|
+
containerWidth: _propTypes.default.number.isRequired,
|
|
47
|
+
scrollPosition: _propTypes.default.shape({
|
|
48
|
+
x: _propTypes.default.number.isRequired
|
|
49
|
+
}).isRequired,
|
|
50
|
+
title: _propTypes.default.string.isRequired,
|
|
51
|
+
totalWidth: _propTypes.default.number.isRequired
|
|
52
|
+
};
|