@hisptz/dhis2-analytics 2.0.37 → 2.0.39
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/dist/components/Scorecard/Scorecard.js +3 -1
- package/dist/components/Scorecard/Scorecard.js.map +1 -1
- package/dist/components/Scorecard/Scorecard.stories.js +6 -927
- package/dist/components/Scorecard/Scorecard.stories.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/ScorecardTable.js +38 -37
- package/dist/components/Scorecard/components/ScorecardTable/ScorecardTable.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/AverageCell.js +30 -8
- package/dist/components/Scorecard/components/ScorecardTable/components/AverageCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.js +7 -4
- package/dist/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/CellLoader.js +2 -2
- package/dist/components/Scorecard/components/ScorecardTable/components/CellLoader.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/DataContainer.js +5 -2
- package/dist/components/Scorecard/components/ScorecardTable/components/DataContainer.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/DataFooterCell.js +19 -10
- package/dist/components/Scorecard/components/ScorecardTable/components/DataFooterCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/DataRow.js +2 -8
- package/dist/components/Scorecard/components/ScorecardTable/components/DataRow.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/DraggableCell.js +29 -30
- package/dist/components/Scorecard/components/ScorecardTable/components/DraggableCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/DroppableCell.js +28 -16
- package/dist/components/Scorecard/components/ScorecardTable/components/DroppableCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.js +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/LinkedCell.js +2 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/LinkedCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.js +3 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.js +1 -0
- package/dist/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.js +51 -0
- package/dist/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.js.map +1 -0
- package/dist/components/Scorecard/components/ScorecardTable/components/SingleDataCell.js +4 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/SingleDataCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/TableBody.js +5 -14
- package/dist/components/Scorecard/components/ScorecardTable/components/TableBody.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/DataHeaderCell.js +1 -0
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/DataHeaderCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/ExpandCell.js +3 -2
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/ExpandCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/LabelCell.js +4 -3
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/LabelCell.js.map +1 -1
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/NumberCell.js +7 -4
- package/dist/components/Scorecard/components/ScorecardTable/components/TableHeader/components/NumberCell.js.map +1 -1
- package/dist/components/Scorecard/components/TableStateProvider.js +20 -1
- package/dist/components/Scorecard/components/TableStateProvider.js.map +1 -1
- package/dist/components/Scorecard/hooks/columns.js +4 -0
- package/dist/components/Scorecard/hooks/columns.js.map +1 -1
- package/dist/components/Scorecard/hooks/table.js +11 -2
- package/dist/components/Scorecard/hooks/table.js.map +1 -1
- package/dist/components/Scorecard/utils/columns.js +4 -0
- package/dist/components/Scorecard/utils/columns.js.map +1 -1
- package/dist/esm/components/Scorecard/Scorecard.js +3 -1
- package/dist/esm/components/Scorecard/Scorecard.js.map +1 -1
- package/dist/esm/components/Scorecard/Scorecard.stories.js +6 -927
- package/dist/esm/components/Scorecard/Scorecard.stories.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/ScorecardTable.js +39 -38
- package/dist/esm/components/Scorecard/components/ScorecardTable/ScorecardTable.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/AverageCell.js +30 -8
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/AverageCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.js +7 -4
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/CellLoader.js +2 -2
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/CellLoader.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataContainer.js +5 -2
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataContainer.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataFooterCell.js +19 -10
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataFooterCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataRow.js +3 -9
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DataRow.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DraggableCell.js +29 -30
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DraggableCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DroppableCell.js +28 -16
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/DroppableCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.js +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/LinkedCell.js +2 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/LinkedCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.js +3 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.js +1 -0
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.js +49 -0
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.js.map +1 -0
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/SingleDataCell.js +4 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/SingleDataCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableBody.js +7 -16
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableBody.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/DataHeaderCell.js +1 -0
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/DataHeaderCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/ExpandCell.js +3 -2
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/ExpandCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/LabelCell.js +4 -3
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/LabelCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/NumberCell.js +7 -4
- package/dist/esm/components/Scorecard/components/ScorecardTable/components/TableHeader/components/NumberCell.js.map +1 -1
- package/dist/esm/components/Scorecard/components/TableStateProvider.js +18 -2
- package/dist/esm/components/Scorecard/components/TableStateProvider.js.map +1 -1
- package/dist/esm/components/Scorecard/hooks/columns.js +4 -0
- package/dist/esm/components/Scorecard/hooks/columns.js.map +1 -1
- package/dist/esm/components/Scorecard/hooks/table.js +12 -3
- package/dist/esm/components/Scorecard/hooks/table.js.map +1 -1
- package/dist/esm/components/Scorecard/utils/columns.js +4 -0
- package/dist/esm/components/Scorecard/utils/columns.js.map +1 -1
- package/dist/types/components/Scorecard/Scorecard.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/ScorecardTable.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/AverageCell.d.ts +4 -2
- package/dist/types/components/Scorecard/components/ScorecardTable/components/AverageCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.d.ts +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/CellLoader.d.ts +3 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/CellLoader.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DataContainer.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DataFooterCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DataRow.d.ts +3 -5
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DataRow.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DraggableCell.d.ts +2 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DraggableCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/DroppableCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/LinkedCell.d.ts +2 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/LinkedCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.d.ts +2 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.d.ts +2 -0
- package/dist/types/components/Scorecard/components/ScorecardTable/components/PaginatedToolbar.d.ts.map +1 -0
- package/dist/types/components/Scorecard/components/ScorecardTable/components/SingleDataCell.d.ts +2 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/SingleDataCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/TableBody.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/TableHeader/components/DataHeaderCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/TableHeader/components/ExpandCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/TableHeader/components/LabelCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/ScorecardTable/components/TableHeader/components/NumberCell.d.ts.map +1 -1
- package/dist/types/components/Scorecard/components/TableStateProvider.d.ts +5 -0
- package/dist/types/components/Scorecard/components/TableStateProvider.d.ts.map +1 -1
- package/dist/types/components/Scorecard/hooks/columns.d.ts.map +1 -1
- package/dist/types/components/Scorecard/hooks/table.d.ts.map +1 -1
- package/dist/types/components/Scorecard/utils/columns.d.ts.map +1 -1
- package/package.json +4 -6
|
@@ -8,7 +8,10 @@ var react = require('react');
|
|
|
8
8
|
var columns = require('../../../utils/columns');
|
|
9
9
|
var CellLoader = require('./CellLoader');
|
|
10
10
|
|
|
11
|
-
function AverageFooterCell({
|
|
11
|
+
function AverageFooterCell({
|
|
12
|
+
column
|
|
13
|
+
}) {
|
|
14
|
+
const size = column.getSize();
|
|
12
15
|
const meta = MetaProvider.useScorecardMeta();
|
|
13
16
|
const [loading, setLoading] = react.useState(false);
|
|
14
17
|
const [average, setAverage] = react.useState();
|
|
@@ -42,12 +45,12 @@ function AverageFooterCell({}) {
|
|
|
42
45
|
};
|
|
43
46
|
}, []);
|
|
44
47
|
if (loading) {
|
|
45
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, {});
|
|
48
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, { size });
|
|
46
49
|
}
|
|
47
50
|
if (!average || isNaN(average)) {
|
|
48
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true });
|
|
51
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, bordered: true });
|
|
49
52
|
}
|
|
50
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: average?.toFixed(2).toString() }) });
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, bordered: true, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: average?.toFixed(2).toString() }) });
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
exports.AverageFooterCell = AverageFooterCell;
|
package/dist/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/AverageFooterCell.tsx"],"names":[],"mappings":"AAiDS;AAjDT,SAAS,qBAAqB;AAG9B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,WAAW,gBAAgB;AAEpC,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAEpB,SAAS,kBAAkB;AAAA,EACjC;AACD,GAA2C;AAC1C,QAAM,OAAO,OAAO,QAAQ;AAC5B,QAAM,OAAO,iBAAiB;AAC9B,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkB,KAAK;AACrD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAiB;AAC/C,QAAM,EAAE,MAAM,gBAAgB,IAAI,iBAAiB;AAEnD,YAAU,MAAM;AACf,eAAW,IAAI;AACf,UAAM,WAAW,CAAC,SAAmC;AACpD,UAAI,SAAS,QAAQ;AACpB;AAAA,UACC,gBAAgB;AAAA,YACf,YAAY,gBAAgB;AAAA,YAC5B;AAAA,UACD,CAAC;AAAA,QACF;AACA,mBAAW,KAAK;AAAA,MACjB;AAAA,IACD;AACA,QAAI,gBAAgB,QAAQ;AAC3B;AAAA,QACC,gBAAgB;AAAA,UACf,YAAY,gBAAgB;AAAA,UAC5B;AAAA,QACD,CAAC;AAAA,MACF;AACA,iBAAW,KAAK;AAAA,IACjB,OAAO;AACN,sBAAgB,YAAY,QAAQ;AAAA,IACrC;AACA,WAAO,MAAM;AACZ,sBAAgB,eAAe,QAAQ;AAAA,IACxC;AAAA,EACD,GAAG,CAAC,CAAC;AAEL,MAAI,SAAS;AACZ,WAAO,oBAAC,cAAW,MAAY;AAAA,EAChC;AAEA,MAAI,CAAC,WAAW,MAAM,OAAO,GAAG;AAC/B,WAAO,oBAAC,iBAAc,OAAO,EAAE,OAAO,KAAK,GAAG,UAAQ,MAAC;AAAA,EACxD;AAEA,SACC,oBAAC,iBAAc,OAAO,EAAE,OAAO,KAAK,GAAG,UAAQ,MAAC,OAAM,UACrD,8BAAC,OAAG,mBAAS,QAAQ,CAAC,EAAE,SAAS,GAAE,GACpC;AAEF","sourcesContent":["import { DataTableCell } from \"@dhis2/ui\";\nimport type { HeaderContext } from \"@tanstack/react-table\";\nimport type { ScorecardTableData } from \"../../../schemas/config\";\nimport { useScorecardMeta } from \"../../MetaProvider\";\nimport { useScorecardData } from \"../../DataProvider\";\nimport { useEffect, useState } from \"react\";\nimport type { AnalyticsData } from \"../../../utils/data\";\nimport { getAverageValue } from \"../../../utils/columns\";\nimport { CellLoader } from \"./CellLoader\";\n\nexport function AverageFooterCell({\n\tcolumn,\n}: HeaderContext<ScorecardTableData, any>) {\n\tconst size = column.getSize();\n\tconst meta = useScorecardMeta();\n\tconst [loading, setLoading] = useState<boolean>(false);\n\tconst [average, setAverage] = useState<number>();\n\tconst { data: scorecardEngine } = useScorecardData();\n\n\tuseEffect(() => {\n\t\tsetLoading(true);\n\t\tconst listener = (data: AnalyticsData[] | \"done\") => {\n\t\t\tif (data === \"done\") {\n\t\t\t\tsetAverage(\n\t\t\t\t\tgetAverageValue({\n\t\t\t\t\t\tdataValues: scorecardEngine.data,\n\t\t\t\t\t\tmeta: meta!,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tsetLoading(false);\n\t\t\t}\n\t\t};\n\t\tif (scorecardEngine.isDone) {\n\t\t\tsetAverage(\n\t\t\t\tgetAverageValue({\n\t\t\t\t\tdataValues: scorecardEngine.data,\n\t\t\t\t\tmeta: meta!,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\tscorecardEngine.addListener(listener);\n\t\t}\n\t\treturn () => {\n\t\t\tscorecardEngine.removeListener(listener);\n\t\t};\n\t}, []);\n\n\tif (loading) {\n\t\treturn <CellLoader size={size} />;\n\t}\n\n\tif (!average || isNaN(average)) {\n\t\treturn <DataTableCell style={{ width: size }} bordered />;\n\t}\n\n\treturn (\n\t\t<DataTableCell style={{ width: size }} bordered align=\"center\">\n\t\t\t<b>{average?.toFixed(2).toString()}</b>\n\t\t</DataTableCell>\n\t);\n}\n"]}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var ui = require('@dhis2/ui');
|
|
5
5
|
|
|
6
|
-
function CellLoader() {
|
|
7
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { align: "center", bordered: true });
|
|
6
|
+
function CellLoader({ size }) {
|
|
7
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, align: "center", bordered: true });
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
exports.CellLoader = CellLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/CellLoader.tsx"],"names":[],"mappings":"AAGQ;AAHR,SAAS,qBAAqB;AAEvB,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/CellLoader.tsx"],"names":[],"mappings":"AAGQ;AAHR,SAAS,qBAAqB;AAEvB,SAAS,WAAW,EAAE,KAAK,GAAqB;AACtD,SAAO,oBAAC,iBAAc,OAAO,EAAE,OAAO,KAAK,GAAG,OAAM,UAAS,UAAQ,MAAC;AACvE","sourcesContent":["import { DataTableCell } from \"@dhis2/ui\";\n\nexport function CellLoader({ size }: { size: number }) {\n\treturn <DataTableCell style={{ width: size }} align=\"center\" bordered />;\n}\n"]}
|
|
@@ -11,15 +11,16 @@ var value = require('../../../hooks/value');
|
|
|
11
11
|
var CellLoader = require('./CellLoader');
|
|
12
12
|
|
|
13
13
|
function DataContainerComponent(props) {
|
|
14
|
+
const size = props.cell.column.getSize();
|
|
14
15
|
const dataConfig = props.getValue();
|
|
15
16
|
const config = ConfigProvider.useScorecardConfig();
|
|
16
17
|
const meta = MetaProvider.useScorecardMeta();
|
|
17
18
|
const { loading, cellData } = value.useCellValue(props.getValue());
|
|
18
19
|
if (!config || !meta) {
|
|
19
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true });
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, bordered: true });
|
|
20
21
|
}
|
|
21
22
|
if (loading) {
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, {});
|
|
23
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, { size });
|
|
23
24
|
}
|
|
24
25
|
if (!dataConfig) {
|
|
25
26
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true });
|
|
@@ -29,6 +30,7 @@ function DataContainerComponent(props) {
|
|
|
29
30
|
SingleDataCell.SingleDataCell,
|
|
30
31
|
{
|
|
31
32
|
...dataConfig,
|
|
33
|
+
size,
|
|
32
34
|
period: dataConfig.currentPeriod,
|
|
33
35
|
dataSources: cellData
|
|
34
36
|
}
|
|
@@ -38,6 +40,7 @@ function DataContainerComponent(props) {
|
|
|
38
40
|
LinkedDataCell.LinkedDataCell,
|
|
39
41
|
{
|
|
40
42
|
...dataConfig,
|
|
43
|
+
size,
|
|
41
44
|
period: dataConfig.currentPeriod,
|
|
42
45
|
dataSources: cellData
|
|
43
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataContainer.tsx"],"names":["DataContainer"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataContainer.tsx"],"names":["DataContainer"],"mappings":"AAwBS;AApBT,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAE3B,SAAS,uBACR,OACC;AACD,QAAM,OAAO,MAAM,KAAK,OAAO,QAAQ;AACvC,QAAM,aAAa,MAAM,SAAS;AAClC,QAAM,SAAS,mBAAmB;AAClC,QAAM,OAAO,iBAAiB;AAC9B,QAAM,EAAE,SAAS,SAAS,IAAI,aAAa,MAAM,SAAS,CAAC;AAE3D,MAAI,CAAC,UAAU,CAAC,MAAM;AACrB,WAAO,oBAAC,iBAAc,OAAO,EAAE,OAAO,KAAK,GAAG,UAAQ,MAAC;AAAA,EACxD;AAEA,MAAI,SAAS;AACZ,WAAO,oBAAC,cAAW,MAAY;AAAA,EAChC;AAEA,MAAI,CAAC,YAAY;AAChB,WAAO,oBAAC,iBAAc,UAAQ,MAAC;AAAA,EAChC;AAEA,MAAI,UAAU,WAAW,GAAG;AAC3B,WACC;AAAA,MAAC;AAAA;AAAA,QACC,GAAG;AAAA,QACJ;AAAA,QACA,QAAQ,WAAW;AAAA,QACnB,aAAa;AAAA;AAAA,IACd;AAAA,EAEF;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACC,GAAG;AAAA,MACJ;AAAA,MACA,QAAQ,WAAW;AAAA,MACnB,aAAa;AAAA;AAAA,EACd;AAEF;AAEO,MAAM,gBAAgB,KAAK,SAASA,eAC1C,OACC;AACD,QAAM,SAAS,MAAM,SAAS;AAE9B,MAAI,CAAC,QAAQ;AACZ,WAAO,oBAAC,iBAAc,UAAQ,MAAC,KAAI,MAAK,OAAM,QAAO;AAAA,EACtD;AAEA,SAAO,oBAAC,0BAAwB,GAAG,OAAO;AAC3C,CAAC","sourcesContent":["import type {\n\tScorecardTableCellConfig,\n\tScorecardTableData,\n} from \"../../../schemas/config\";\nimport { useScorecardConfig } from \"../../ConfigProvider\";\nimport { useScorecardMeta } from \"../../MetaProvider\";\nimport { SingleDataCell } from \"./SingleDataCell\";\nimport { LinkedDataCell } from \"./LinkedDataCell\";\nimport type { CellContext } from \"@tanstack/react-table\";\nimport { DataTableCell } from \"@dhis2/ui\";\nimport { memo } from \"react\";\nimport { useCellValue } from \"../../../hooks/value\";\nimport { CellLoader } from \"./CellLoader\";\n\nfunction DataContainerComponent(\n\tprops: CellContext<ScorecardTableData, ScorecardTableCellConfig>,\n) {\n\tconst size = props.cell.column.getSize();\n\tconst dataConfig = props.getValue();\n\tconst config = useScorecardConfig();\n\tconst meta = useScorecardMeta();\n\tconst { loading, cellData } = useCellValue(props.getValue());\n\n\tif (!config || !meta) {\n\t\treturn <DataTableCell style={{ width: size }} bordered />;\n\t}\n\n\tif (loading) {\n\t\treturn <CellLoader size={size} />;\n\t}\n\n\tif (!dataConfig) {\n\t\treturn <DataTableCell bordered />;\n\t}\n\n\tif (cellData?.length === 1) {\n\t\treturn (\n\t\t\t<SingleDataCell\n\t\t\t\t{...dataConfig}\n\t\t\t\tsize={size}\n\t\t\t\tperiod={dataConfig.currentPeriod!}\n\t\t\t\tdataSources={cellData}\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<LinkedDataCell\n\t\t\t{...dataConfig}\n\t\t\tsize={size}\n\t\t\tperiod={dataConfig.currentPeriod!}\n\t\t\tdataSources={cellData}\n\t\t/>\n\t);\n}\n\nexport const DataContainer = memo(function DataContainer(\n\tprops: CellContext<ScorecardTableData, ScorecardTableCellConfig>,\n) {\n\tconst config = props.getValue();\n\n\tif (!config) {\n\t\treturn <DataTableCell bordered tag=\"th\" width=\"auto\" />;\n\t}\n\n\treturn <DataContainerComponent {...props} />;\n});\n"]}
|
|
@@ -29,7 +29,8 @@ function getOrgUnitAverage({
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
function OrgUnitFooterCell({
|
|
32
|
-
dataSourcesConfig
|
|
32
|
+
dataSourcesConfig,
|
|
33
|
+
size
|
|
33
34
|
}) {
|
|
34
35
|
const { data: scorecardEngine } = DataProvider.useScorecardData();
|
|
35
36
|
const [loading, setLoading] = react.useState(false);
|
|
@@ -63,19 +64,20 @@ function OrgUnitFooterCell({
|
|
|
63
64
|
};
|
|
64
65
|
}, [dataSourcesConfig]);
|
|
65
66
|
if (loading) {
|
|
66
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, {});
|
|
67
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, { size });
|
|
67
68
|
}
|
|
68
69
|
if (lodash.isEmpty(averageValues)) {
|
|
69
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true });
|
|
70
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, bordered: true });
|
|
70
71
|
}
|
|
71
72
|
if (averageValues?.length === 1) {
|
|
72
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AverageCell.SingleAverageCell, { dataSource: lodash.head(averageValues) });
|
|
73
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AverageCell.SingleAverageCell, { size, dataSource: lodash.head(averageValues) });
|
|
73
74
|
} else {
|
|
74
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AverageCell.LinkedAverageCell, { dataSources: averageValues });
|
|
75
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AverageCell.LinkedAverageCell, { size, dataSources: averageValues });
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
function DataHolderFooterCell({
|
|
78
|
-
dataSourcesConfig
|
|
79
|
+
dataSourcesConfig,
|
|
80
|
+
size
|
|
79
81
|
}) {
|
|
80
82
|
const { data: scorecardEngine } = DataProvider.useScorecardData();
|
|
81
83
|
const [loading, setLoading] = react.useState(false);
|
|
@@ -115,14 +117,15 @@ function DataHolderFooterCell({
|
|
|
115
117
|
};
|
|
116
118
|
}, [dataSourcesConfig]);
|
|
117
119
|
if (loading) {
|
|
118
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, {});
|
|
120
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CellLoader.CellLoader, { size });
|
|
119
121
|
}
|
|
120
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: average?.toFixed(2).toString() }) });
|
|
122
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { style: { width: size }, bordered: true, align: "center", children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: average?.toFixed(2).toString() }) });
|
|
121
123
|
}
|
|
122
124
|
function DataFooterCell({
|
|
123
125
|
table,
|
|
124
126
|
column
|
|
125
127
|
}) {
|
|
128
|
+
const size = column.getSize();
|
|
126
129
|
const showDataInRows = StateProvider.useScorecardStateSelector([
|
|
127
130
|
"options",
|
|
128
131
|
"showDataInRows"
|
|
@@ -133,9 +136,15 @@ function DataFooterCell({
|
|
|
133
136
|
);
|
|
134
137
|
}, [table.getRowModel().rows]);
|
|
135
138
|
if (showDataInRows) {
|
|
136
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
140
|
+
DataHolderFooterCell,
|
|
141
|
+
{
|
|
142
|
+
size,
|
|
143
|
+
dataSourcesConfig: dataSourceConfig
|
|
144
|
+
}
|
|
145
|
+
);
|
|
137
146
|
}
|
|
138
|
-
return /* @__PURE__ */ jsxRuntime.jsx(OrgUnitFooterCell, { dataSourcesConfig: dataSourceConfig });
|
|
147
|
+
return /* @__PURE__ */ jsxRuntime.jsx(OrgUnitFooterCell, { size, dataSourcesConfig: dataSourceConfig });
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
exports.DataFooterCell = DataFooterCell;
|
package/dist/components/Scorecard/components/ScorecardTable/components/DataFooterCell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataFooterCell.tsx"],"names":["average"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataFooterCell.tsx"],"names":["average"],"mappings":"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","sourcesContent":["import type { HeaderContext } from \"@tanstack/react-table\";\nimport type {\n\tScorecardAverageCellData,\n\tScorecardTableCellConfig,\n\tScorecardTableData,\n} from \"../../../schemas/config\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useScorecardStateSelector } from \"../../StateProvider\";\nimport { DataTableCell } from \"@dhis2/ui\";\nimport type { AnalyticsData } from \"../../../utils/data\";\nimport { useScorecardData } from \"../../DataProvider\";\nimport { head, isEmpty, meanBy } from \"lodash\";\nimport { CellLoader } from \"./CellLoader\";\nimport { LinkedAverageCell, SingleAverageCell } from \"./AverageCell\";\n\nfunction getOrgUnitAverage({\n\tdataSourcesConfig,\n\tdata,\n}: {\n\tdataSourcesConfig: ScorecardTableCellConfig[];\n\tdata: AnalyticsData[];\n}): ScorecardAverageCellData[] {\n\tconst dataSourceConfig = head(dataSourcesConfig)!;\n\n\treturn dataSourceConfig.dataSources?.map((config) => {\n\t\tconst period = dataSourceConfig.currentPeriod!;\n\t\tconst dataValues = data.filter(\n\t\t\t(datum) => datum.pe === period && datum.dx === config.id,\n\t\t);\n\t\tconst average = meanBy(dataValues, (value) => parseFloat(value.value!));\n\n\t\treturn {\n\t\t\t...config,\n\t\t\tdata: {\n\t\t\t\taverage,\n\t\t\t},\n\t\t};\n\t});\n}\n\nfunction OrgUnitFooterCell({\n\tdataSourcesConfig,\n\tsize,\n}: {\n\tdataSourcesConfig: ScorecardTableCellConfig[];\n\tsize: number;\n}) {\n\tconst { data: scorecardEngine } = useScorecardData();\n\tconst [loading, setLoading] = useState<boolean>(false);\n\tconst [averageValues, setAverageValues] =\n\t\tuseState<ScorecardAverageCellData[]>();\n\n\tuseEffect(() => {\n\t\tsetLoading(true);\n\t\tconst listener = (data: AnalyticsData[] | \"done\") => {\n\t\t\tif (data === \"done\") {\n\t\t\t\tsetAverageValues(\n\t\t\t\t\tgetOrgUnitAverage({\n\t\t\t\t\t\tdataSourcesConfig,\n\t\t\t\t\t\tdata: scorecardEngine.data,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tsetLoading(false);\n\t\t\t}\n\t\t};\n\t\tif (scorecardEngine.isDone) {\n\t\t\tsetAverageValues(\n\t\t\t\tgetOrgUnitAverage({\n\t\t\t\t\tdataSourcesConfig,\n\t\t\t\t\tdata: scorecardEngine.data,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\tscorecardEngine.addListener(listener);\n\t\t}\n\n\t\treturn () => {\n\t\t\tscorecardEngine.removeListener(listener);\n\t\t};\n\t}, [dataSourcesConfig]);\n\n\tif (loading) {\n\t\treturn <CellLoader size={size} />;\n\t}\n\n\tif (isEmpty(averageValues)) {\n\t\treturn <DataTableCell style={{ width: size }} bordered />;\n\t}\n\n\tif (averageValues?.length === 1) {\n\t\treturn (\n\t\t\t<SingleAverageCell size={size} dataSource={head(averageValues)!} />\n\t\t);\n\t} else {\n\t\treturn <LinkedAverageCell size={size} dataSources={averageValues!} />;\n\t}\n}\n\nfunction DataHolderFooterCell({\n\tdataSourcesConfig,\n\tsize,\n}: {\n\tdataSourcesConfig: ScorecardTableCellConfig[];\n\tsize: number;\n}) {\n\tconst { data: scorecardEngine } = useScorecardData();\n\tconst [loading, setLoading] = useState<boolean>(false);\n\tconst [average, setAverage] = useState<number>();\n\n\tuseEffect(() => {\n\t\tsetLoading(true);\n\t\tconst listener = (data: AnalyticsData[] | \"done\") => {\n\t\t\tif (data === \"done\") {\n\t\t\t\tsetLoading(false);\n\t\t\t\tconst orgUnitId = head(dataSourcesConfig)!;\n\t\t\t\tconst dataValues = scorecardEngine.data.filter(\n\t\t\t\t\t(datum) => datum.ou === orgUnitId.orgUnit.uid,\n\t\t\t\t);\n\t\t\t\tconst average = meanBy(dataValues, (value) =>\n\t\t\t\t\tparseFloat(value.value!),\n\t\t\t\t);\n\t\t\t\tsetAverage(average);\n\t\t\t}\n\t\t};\n\t\tif (scorecardEngine.isDone) {\n\t\t\tconst orgUnitId = head(dataSourcesConfig)!;\n\t\t\tconst dataValues = scorecardEngine.data.filter(\n\t\t\t\t(datum) => datum.ou === orgUnitId.orgUnit.uid,\n\t\t\t);\n\t\t\tconst average = meanBy(dataValues, (value) =>\n\t\t\t\tparseFloat(value.value!),\n\t\t\t);\n\t\t\tsetAverage(average);\n\t\t\tsetLoading(false);\n\t\t} else {\n\t\t\tscorecardEngine.addListener(listener);\n\t\t}\n\n\t\treturn () => {\n\t\t\tscorecardEngine.removeListener(listener);\n\t\t};\n\t}, [dataSourcesConfig]);\n\n\tif (loading) {\n\t\treturn <CellLoader size={size} />;\n\t}\n\treturn (\n\t\t<DataTableCell style={{ width: size }} bordered align=\"center\">\n\t\t\t<b>{average?.toFixed(2).toString()}</b>\n\t\t</DataTableCell>\n\t);\n}\n\nexport function DataFooterCell({\n\ttable,\n\tcolumn,\n}: HeaderContext<ScorecardTableData, ScorecardTableCellConfig>) {\n\tconst size = column.getSize();\n\tconst showDataInRows = useScorecardStateSelector<boolean>([\n\t\t\"options\",\n\t\t\"showDataInRows\",\n\t]);\n\tconst dataSourceConfig = useMemo(() => {\n\t\treturn table\n\t\t\t.getRowModel()\n\t\t\t.rows.map((row) =>\n\t\t\t\trow.getValue(column.id),\n\t\t\t) as ScorecardTableCellConfig[];\n\t}, [table.getRowModel().rows]);\n\n\tif (showDataInRows) {\n\t\treturn (\n\t\t\t<DataHolderFooterCell\n\t\t\t\tsize={size}\n\t\t\t\tdataSourcesConfig={dataSourceConfig}\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<OrgUnitFooterCell size={size} dataSourcesConfig={dataSourceConfig} />\n\t);\n}\n"]}
|
|
@@ -12,11 +12,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
|
|
13
13
|
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
14
14
|
|
|
15
|
-
function TableRowComponent({
|
|
16
|
-
row,
|
|
17
|
-
virtualRow,
|
|
18
|
-
virtualizer
|
|
19
|
-
}) {
|
|
15
|
+
function TableRowComponent({ row }) {
|
|
20
16
|
const [isPending, startTransition] = react.useTransition();
|
|
21
17
|
const orgUnit = react.useMemo(() => {
|
|
22
18
|
const dataCell = row.getVisibleCells().find((cell) => {
|
|
@@ -33,8 +29,6 @@ function TableRowComponent({
|
|
|
33
29
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
34
30
|
ui.DataTableRow,
|
|
35
31
|
{
|
|
36
|
-
"data-index": virtualRow ? virtualRow.index : void 0,
|
|
37
|
-
ref: virtualizer ? (node) => virtualizer.measureElement(node) : void 0,
|
|
38
32
|
className: styles__default.default.expandCell,
|
|
39
33
|
onExpandToggle: canExpand ? ({ expanded }) => {
|
|
40
34
|
startTransition(() => {
|
|
@@ -59,7 +53,7 @@ function TableRowComponent({
|
|
|
59
53
|
row.id
|
|
60
54
|
);
|
|
61
55
|
}
|
|
62
|
-
const TableRow = TableRowComponent;
|
|
56
|
+
const TableRow = react.memo(TableRowComponent);
|
|
63
57
|
|
|
64
58
|
exports.TableRow = TableRow;
|
|
65
59
|
//# sourceMappingURL=out.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataRow.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DataRow.tsx"],"names":[],"mappings":"AA0CK;AA1CL,SAAS,kBAA4B;AAKrC,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,OAAO,YAAY;AACnB,SAAS,8BAA8B;AACvC,SAAS,UAAU,MAAM,SAAS,qBAAqB;AAEvD,SAAS,kBAAkB,EAAE,IAAI,GAAqC;AACrE,QAAM,CAAC,WAAW,eAAe,IAAI,cAAc;AACnD,QAAM,UAAU,QAAQ,MAAM;AAC7B,UAAM,WAAW,IAAI,gBAAgB,EAAE,KAAK,CAAC,SAAS;AACrD,YAAM,OAAO,KAAK,SAAS;AAC3B,aAAO,CAAC,CAAC,MAAM;AAAA,IAChB,CAAC;AACD,WAAQ,UAAU,SAAS,GAAgC;AAAA,EAC5D,GAAG,CAAC,GAAG,CAAC;AAER,QAAM,eAAe,QAAQ,MAAM;AAClC,UAAM,aAAa,KAAK,IAAI,gBAAgB,CAAC;AAC7C,WAAQ,YAAY,SAAS,KAAiB;AAAA,EAC/C,GAAG,CAAC,GAAG,CAAC;AAER,QAAM,YAAY,WAAW;AAE7B,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAW,OAAO;AAAA,MAClB,gBACC,YACG,CAAC,EAAE,SAAS,MAAM;AAClB,wBAAgB,MAAM;AACrB,cAAI,eAAe,QAAQ;AAAA,QAC5B,CAAC;AAAA,MACF,IACC;AAAA,MAEJ,mBACC,WAAW,eACV;AAAA,QAAC;AAAA;AAAA,UACA,SAAS;AAAA,UACT;AAAA;AAAA,MACD,IACG;AAAA,MAEL,UAAU,aAAa,IAAI,cAAc;AAAA,MAGxC,cAAI,gBAAgB,EAAE,IAAI,CAAC,SAAS;AACpC,eACC,oBAAC,YACC;AAAA,UACA,KAAK,OAAO,UAAU;AAAA,UACtB,KAAK,WAAW;AAAA,QACjB,KAJc,KAAK,EAKpB;AAAA,MAEF,CAAC;AAAA;AAAA,IAXI,IAAI;AAAA,EAYV;AAEF;AAEO,MAAM,WAAW,KAAK,iBAAiB","sourcesContent":["import { flexRender, type Row } from \"@tanstack/react-table\";\nimport type {\n\tScorecardTableCellConfig,\n\tScorecardTableData,\n} from \"../../../schemas/config\";\nimport { head } from \"lodash\";\nimport { DataTableRow } from \"@dhis2/ui\";\nimport styles from \"../ScorecardTable.module.css\";\nimport { ExpandedScorecardTable } from \"./ExpandedScorecardTable\";\nimport { Fragment, memo, useMemo, useTransition } from \"react\";\n\nfunction TableRowComponent({ row }: { row: Row<ScorecardTableData> }) {\n\tconst [isPending, startTransition] = useTransition();\n\tconst orgUnit = useMemo(() => {\n\t\tconst dataCell = row.getVisibleCells().find((cell) => {\n\t\t\tconst data = cell.getValue() as ScorecardTableCellConfig;\n\t\t\treturn !!data?.orgUnit;\n\t\t});\n\t\treturn (dataCell?.getValue() as ScorecardTableCellConfig)?.orgUnit;\n\t}, [row]);\n\n\tconst shouldExpand = useMemo(() => {\n\t\tconst expandCell = head(row.getVisibleCells());\n\t\treturn (expandCell?.getValue() as boolean) ?? false;\n\t}, [row]);\n\n\tconst canExpand = orgUnit && shouldExpand;\n\n\treturn (\n\t\t<DataTableRow\n\t\t\tclassName={styles.expandCell}\n\t\t\tonExpandToggle={\n\t\t\t\tcanExpand\n\t\t\t\t\t? ({ expanded }) => {\n\t\t\t\t\t\t\tstartTransition(() => {\n\t\t\t\t\t\t\t\trow.toggleExpanded(expanded);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t\texpandableContent={\n\t\t\t\torgUnit && shouldExpand ? (\n\t\t\t\t\t<ExpandedScorecardTable\n\t\t\t\t\t\tpending={isPending}\n\t\t\t\t\t\torgUnit={orgUnit}\n\t\t\t\t\t/>\n\t\t\t\t) : undefined\n\t\t\t}\n\t\t\texpanded={canExpand && row.getIsExpanded()}\n\t\t\tkey={row.id}\n\t\t>\n\t\t\t{row.getVisibleCells().map((cell) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Fragment key={cell.id}>\n\t\t\t\t\t\t{flexRender(\n\t\t\t\t\t\t\tcell.column.columnDef.cell,\n\t\t\t\t\t\t\tcell.getContext(),\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Fragment>\n\t\t\t\t);\n\t\t\t})}\n\t\t</DataTableRow>\n\t);\n}\n\nexport const TableRow = memo(TableRowComponent);\n"]}
|
|
@@ -2,44 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var ui = require('@dhis2/ui');
|
|
5
|
-
var
|
|
6
|
-
var utilities = require('@dnd-kit/utilities');
|
|
5
|
+
var reactDnd = require('react-dnd');
|
|
7
6
|
|
|
8
7
|
function DraggableCell({
|
|
9
8
|
children,
|
|
10
9
|
type,
|
|
11
10
|
style,
|
|
11
|
+
id,
|
|
12
12
|
...props
|
|
13
13
|
}) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} : void 0;
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
-
"div",
|
|
22
|
-
{
|
|
23
|
-
id: type,
|
|
24
|
-
...props,
|
|
25
|
-
...attributes,
|
|
26
|
-
...listeners,
|
|
27
|
-
className: "column center",
|
|
28
|
-
style: {
|
|
29
|
-
...style ?? {},
|
|
30
|
-
...transformStyle,
|
|
31
|
-
background: isDragging ? ui.colors?.grey400 : void 0,
|
|
32
|
-
cursor: "move",
|
|
33
|
-
opacity: isDragging ? 0.5 : 1,
|
|
34
|
-
height: "100%",
|
|
35
|
-
width: "100%",
|
|
36
|
-
padding: "0 12px",
|
|
37
|
-
zIndex: isDragging ? 3 : void 0
|
|
14
|
+
const [collected, drag, dragPreview] = reactDnd.useDrag(() => {
|
|
15
|
+
return {
|
|
16
|
+
type,
|
|
17
|
+
item: {
|
|
18
|
+
id
|
|
38
19
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
collect: (monitor) => {
|
|
21
|
+
return {
|
|
22
|
+
isDragging: monitor.isDragging()
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
if (collected.isDragging) {
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
ref: dragPreview,
|
|
32
|
+
style: {
|
|
33
|
+
backgroundColor: ui.colors.grey400,
|
|
34
|
+
opacity: 0.5,
|
|
35
|
+
cursor: "move"
|
|
36
|
+
},
|
|
37
|
+
children
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { cursor: "move" }, id: type, ref: drag, children });
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
exports.DraggableCell = DraggableCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DraggableCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DraggableCell.tsx"],"names":[],"mappings":"AAiCG;AAjCH,SAAS,cAAc;AAGvB,SAAS,eAAe;AAEjB,SAAS,cAAc;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACJ,GAKG;AACF,QAAM,CAAC,WAAW,MAAM,WAAW,IAAI,QAAQ,MAAM;AACpD,WAAO;AAAA,MACN;AAAA,MACA,MAAM;AAAA,QACL;AAAA,MACD;AAAA,MACA,SAAS,CAAC,YAAY;AACrB,eAAO;AAAA,UACN,YAAY,QAAQ,WAAW;AAAA,QAChC;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAC;AAED,MAAI,UAAU,YAAY;AACzB,WACC;AAAA,MAAC;AAAA;AAAA,QACA,KAAK;AAAA,QACL,OAAO;AAAA,UACN,iBAAiB,OAAO;AAAA,UACxB,SAAS;AAAA,UACT,QAAQ;AAAA,QACT;AAAA,QAEC;AAAA;AAAA,IACF;AAAA,EAEF;AAEA,SACC,oBAAC,SAAI,OAAO,EAAE,QAAQ,OAAO,GAAG,IAAI,MAAM,KAAK,MAC7C,UACF;AAEF","sourcesContent":["import { colors } from \"@dhis2/ui\";\nimport React from \"react\";\nimport type { ScorecardDraggableItems } from \"../../../schemas/config\";\nimport { useDrag } from \"react-dnd\";\n\nexport function DraggableCell({\n\tchildren,\n\ttype,\n\tstyle,\n\tid,\n\t...props\n}: {\n\tchildren: React.ReactNode;\n\ttype: ScorecardDraggableItems;\n\tid: string;\n\tstyle?: React.CSSProperties;\n}) {\n\tconst [collected, drag, dragPreview] = useDrag(() => {\n\t\treturn {\n\t\t\ttype,\n\t\t\titem: {\n\t\t\t\tid,\n\t\t\t},\n\t\t\tcollect: (monitor) => {\n\t\t\t\treturn {\n\t\t\t\t\tisDragging: monitor.isDragging(),\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t});\n\n\tif (collected.isDragging) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={dragPreview}\n\t\t\t\tstyle={{\n\t\t\t\t\tbackgroundColor: colors.grey400,\n\t\t\t\t\topacity: 0.5,\n\t\t\t\t\tcursor: \"move\",\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div style={{ cursor: \"move\" }} id={type} ref={drag}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -2,32 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var ui = require('@dhis2/ui');
|
|
5
|
-
var
|
|
6
|
-
var core = require('@dnd-kit/core');
|
|
7
|
-
var lodash = require('lodash');
|
|
5
|
+
var reactDnd = require('react-dnd');
|
|
8
6
|
|
|
9
7
|
function DroppableCell({
|
|
10
8
|
accept,
|
|
11
9
|
children
|
|
12
10
|
}) {
|
|
13
|
-
const
|
|
14
|
-
|
|
11
|
+
const [collectedProps, drop] = reactDnd.useDrop(() => {
|
|
12
|
+
return {
|
|
13
|
+
accept,
|
|
14
|
+
collect: (monitor) => {
|
|
15
|
+
if (monitor.canDrop()) {
|
|
16
|
+
return {
|
|
17
|
+
style: {
|
|
18
|
+
border: `2px dashed ${ui.colors.grey700}`,
|
|
19
|
+
background: `${ui.colors.grey100}`,
|
|
20
|
+
width: "100%"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
} else {
|
|
24
|
+
return {
|
|
25
|
+
style: {
|
|
26
|
+
width: "100%",
|
|
27
|
+
border: `2px solid transparent`
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
drop: (results) => {
|
|
33
|
+
return results;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
15
36
|
});
|
|
16
|
-
const canDrop = react.useMemo(() => {
|
|
17
|
-
if (!active)
|
|
18
|
-
return false;
|
|
19
|
-
return accept.includes(active.id);
|
|
20
|
-
}, [accept, active]);
|
|
21
37
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22
38
|
"div",
|
|
23
39
|
{
|
|
24
|
-
ref:
|
|
40
|
+
ref: drop,
|
|
25
41
|
className: "column center align-items-center",
|
|
26
|
-
|
|
27
|
-
border: canDrop ? `2px dashed ${ui.colors.grey700}` : void 0,
|
|
28
|
-
background: canDrop ? `${ui.colors.grey100}` : void 0,
|
|
29
|
-
width: "100%"
|
|
30
|
-
},
|
|
42
|
+
...collectedProps,
|
|
31
43
|
children
|
|
32
44
|
}
|
|
33
45
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DroppableCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/DroppableCell.tsx"],"names":[],"mappings":"AAwCE;AAxCF,SAAS,cAAc;AAGvB,SAAS,eAAe;AAET,SAAR,cAA+B;AAAA,EACrC;AAAA,EACA;AACD,GAGG;AACF,QAAM,CAAC,gBAAgB,IAAI,IAAI,QAAQ,MAAM;AAC5C,WAAO;AAAA,MACN;AAAA,MACA,SAAS,CAAC,YAAY;AACrB,YAAI,QAAQ,QAAQ,GAAG;AACtB,iBAAO;AAAA,YACN,OAAO;AAAA,cACN,QAAQ,cAAc,OAAO,OAAO;AAAA,cACpC,YAAY,GAAG,OAAO,OAAO;AAAA,cAC7B,OAAO;AAAA,YACR;AAAA,UACD;AAAA,QACD,OAAO;AACN,iBAAO;AAAA,YACN,OAAO;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,YACT;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,MACA,MAAM,CAAC,YAA4B;AAClC,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD,CAAC;AAED,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAK;AAAA,MACL,WAAU;AAAA,MACT,GAAG;AAAA,MAEH;AAAA;AAAA,EACF;AAEF","sourcesContent":["import { colors } from \"@dhis2/ui\";\nimport React from \"react\";\nimport type { ScorecardDraggableItems } from \"../../../schemas/config\";\nimport { useDrop } from \"react-dnd\";\n\nexport default function DroppableCell({\n\taccept,\n\tchildren,\n}: {\n\taccept: ScorecardDraggableItems[];\n\tchildren: React.ReactNode;\n}) {\n\tconst [collectedProps, drop] = useDrop(() => {\n\t\treturn {\n\t\t\taccept,\n\t\t\tcollect: (monitor) => {\n\t\t\t\tif (monitor.canDrop()) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tborder: `2px dashed ${colors.grey700}`,\n\t\t\t\t\t\t\tbackground: `${colors.grey100}`,\n\t\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\t\tborder: `2px solid transparent`,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t\tdrop: (results: { id: string }) => {\n\t\t\t\treturn results;\n\t\t\t},\n\t\t};\n\t});\n\n\treturn (\n\t\t<div\n\t\t\tref={drop}\n\t\t\tclassName=\"column center align-items-center\"\n\t\t\t{...collectedProps}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var ui = require('@dhis2/ui');
|
|
5
5
|
|
|
6
6
|
function EmptyFooterCell(props) {
|
|
7
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, {});
|
|
7
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.DataTableCell, { bordered: true });
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
exports.EmptyFooterCell = EmptyFooterCell;
|
package/dist/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.tsx"],"names":[],"mappings":"AAOQ;AAPR,SAAS,qBAAqB;AAIvB,SAAS,gBACf,OACC;AACD,SAAO,oBAAC,iBAAc;
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/EmptyFooterCell.tsx"],"names":[],"mappings":"AAOQ;AAPR,SAAS,qBAAqB;AAIvB,SAAS,gBACf,OACC;AACD,SAAO,oBAAC,iBAAc,UAAQ,MAAC;AAChC","sourcesContent":["import { DataTableCell } from \"@dhis2/ui\";\nimport type { HeaderContext } from \"@tanstack/react-table\";\nimport type { ScorecardTableData } from \"../../../schemas/config\";\n\nexport function EmptyFooterCell(\n\tprops: HeaderContext<ScorecardTableData, unknown>,\n) {\n\treturn <DataTableCell bordered />;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
11
11
|
|
|
12
12
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
13
|
|
|
14
|
-
function LinkedCellComponent({ top, bottom, ...props }) {
|
|
14
|
+
function LinkedCellComponent({ top, bottom, size, ...props }) {
|
|
15
15
|
const [ref, { height, width }] = usehooksTs.useElementSize();
|
|
16
16
|
const {
|
|
17
17
|
legendDefinition: topLegendDefinition,
|
|
@@ -33,6 +33,7 @@ function LinkedCellComponent({ top, bottom, ...props }) {
|
|
|
33
33
|
ref,
|
|
34
34
|
style: {
|
|
35
35
|
padding: 8,
|
|
36
|
+
width: size,
|
|
36
37
|
minWidth: 120,
|
|
37
38
|
background: `linear-gradient(-${angle}rad, ${bottomLegendDefinition?.color ?? ui.colors.white} 0%, ${bottomLegendDefinition?.color ?? ui.colors.white} 49%, ${ui.colors.white} 49%, ${ui.colors.white} 50%, ${topLegendDefinition?.color ?? ui.colors.white} 50%, ${topLegendDefinition?.color ?? ui.colors.white} 100%)`
|
|
38
39
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/LinkedCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/LinkedCell.tsx"],"names":[],"mappings":"AAgEG,SAuBG,KAvBH;AAhEH,SAAS,QAAQ,qBAAqB;AACtC,SAAS,uCAAuC;AAChD,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,OAAO,SAAS,eAAe;AAsB/B,SAAS,oBAAoB,EAAE,KAAK,QAAQ,MAAM,GAAG,MAAM,GAAoB;AAC9E,QAAM,CAAC,KAAK,EAAE,QAAQ,MAAM,CAAC,IAAI,eAAe;AAEhD,QAAM;AAAA,IACL,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,OAAO;AAAA,EACR,IAAI;AACJ,QAAM;AAAA,IACL,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ,OAAO;AAAA,EACR,IAAI;AAEJ,QAAM,QAAQ,QAAQ,MAAM;AAC3B,WAAO,KAAK,IAAI,SAAS,KAAK;AAAA,EAC/B,GAAG,CAAC,QAAQ,KAAK,CAAC;AAElB,SACC;AAAA,IAAC;AAAA;AAAA,MACC,GAAG;AAAA,MAGJ;AAAA,MACA,OAAO;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY,oBAAoB,KAAK,QACpC,wBAAwB,SAAS,OAAO,KACzC,QAAQ,wBAAwB,SAAS,OAAO,KAAK,SACpD,OAAO,KACR,SAAS,OAAO,KAAK,SACpB,qBAAqB,SAAS,OAAO,KACtC,SAAS,qBAAqB,SAAS,OAAO,KAAK;AAAA,MACpD;AAAA,MACA,UAAQ;AAAA,MAER;AAAA,QAAC;AAAA;AAAA,UACA,OAAO;AAAA,YACN,SAAS;AAAA,YACT,OAAO;AAAA,YACP,QAAQ;AAAA,YACR,eAAe;AAAA,UAChB;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACA,OAAO;AAAA,kBACN,YAAY;AAAA,kBACZ,SAAS;AAAA,kBACT,OAAO;AAAA,kBACP,YAAY;AAAA,kBACZ,gBAAgB;AAAA,kBAChB,OAAO,sBACJ;AAAA,oBACA,qBAAqB,SAAS;AAAA,kBAC/B,IACC;AAAA,gBACJ;AAAA,gBAEC,2BACA;AAAA,kBAAC;AAAA;AAAA,oBACA,OAAO;AAAA,oBACP,YAAY;AAAA;AAAA,gBACb;AAAA;AAAA,YAEF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACA,OAAO;AAAA,kBACN,YAAY;AAAA,kBACZ,SAAS;AAAA,kBACT,OAAO;AAAA,kBACP,YAAY;AAAA,kBACZ,gBAAgB;AAAA,kBAChB,OAAO,yBACJ;AAAA,oBACA,wBAAwB,SAAS;AAAA,kBAClC,IACC;AAAA,gBACJ;AAAA,gBAEC,8BACA;AAAA,kBAAC;AAAA;AAAA,oBACA,OAAO;AAAA,oBACP,YAAY;AAAA;AAAA,gBACb;AAAA;AAAA,YAEF;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;AAEO,MAAM,aAAa,MAAM,KAAK,qBAAqB,CAAC,MAAM,SAAS;AACzE,SACC,KAAK,IAAI,UAAU,KAAK,IAAI,SAC5B,KAAK,OAAO,UAAU,KAAK,OAAO;AAEpC,CAAC","sourcesContent":["import { colors, DataTableCell } from \"@dhis2/ui\";\nimport { getTextColorFromBackgroundColor } from \"../../../utils/legends\";\nimport { DataValue } from \"./DataValue\";\nimport { useElementSize } from \"usehooks-ts\";\nimport React, { useMemo } from \"react\";\nimport type {\n\tLegendDefinition,\n\tScorecardCellData,\n} from \"../../../schemas/config\";\n\nexport interface LinkedCellProps {\n\ttop: {\n\t\tdataSource: ScorecardCellData;\n\t\tlegendDefinition?: LegendDefinition;\n\t\tvalue?: number;\n\t};\n\tbottom: {\n\t\tdataSource: ScorecardCellData;\n\t\tlegendDefinition?: LegendDefinition;\n\t\tvalue?: number;\n\t};\n\tsize: number;\n\n\t[key: string]: unknown;\n}\n\nfunction LinkedCellComponent({ top, bottom, size, ...props }: LinkedCellProps) {\n\tconst [ref, { height, width }] = useElementSize();\n\n\tconst {\n\t\tlegendDefinition: topLegendDefinition,\n\t\tdataSource: topDataSource,\n\t\tvalue: topValue,\n\t} = top;\n\tconst {\n\t\tlegendDefinition: bottomLegendDefinition,\n\t\tdataSource: bottomDataSource,\n\t\tvalue: bottomValue,\n\t} = bottom;\n\n\tconst angle = useMemo(() => {\n\t\treturn Math.tan(height / width);\n\t}, [height, width]);\n\n\treturn (\n\t\t<DataTableCell\n\t\t\t{...props}\n\t\t\t/*\n // @ts-ignore */\n\t\t\tref={ref}\n\t\t\tstyle={{\n\t\t\t\tpadding: 8,\n\t\t\t\twidth: size,\n\t\t\t\tminWidth: 120,\n\t\t\t\tbackground: `linear-gradient(-${angle}rad, ${\n\t\t\t\t\tbottomLegendDefinition?.color ?? colors.white\n\t\t\t\t} 0%, ${bottomLegendDefinition?.color ?? colors.white} 49%, ${\n\t\t\t\t\tcolors.white\n\t\t\t\t} 49%, ${colors.white} 50%, ${\n\t\t\t\t\ttopLegendDefinition?.color ?? colors.white\n\t\t\t\t} 50%, ${topLegendDefinition?.color ?? colors.white} 100%)`,\n\t\t\t}}\n\t\t\tbordered\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\theight: \"100%\",\n\t\t\t\t\tflexDirection: \"column\",\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: \"inherit\",\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\talignItems: \"flex-start\",\n\t\t\t\t\t\tjustifyContent: \"flex-start\",\n\t\t\t\t\t\tcolor: topLegendDefinition\n\t\t\t\t\t\t\t? getTextColorFromBackgroundColor(\n\t\t\t\t\t\t\t\t\ttopLegendDefinition?.color ?? \"#FFFFFF\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{topDataSource && (\n\t\t\t\t\t\t<DataValue\n\t\t\t\t\t\t\tvalue={topValue}\n\t\t\t\t\t\t\tdataSource={topDataSource}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tbackground: \"inherit\",\n\t\t\t\t\t\tdisplay: \"flex\",\n\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\talignItems: \"flex-end\",\n\t\t\t\t\t\tjustifyContent: \"flex-end\",\n\t\t\t\t\t\tcolor: bottomLegendDefinition\n\t\t\t\t\t\t\t? getTextColorFromBackgroundColor(\n\t\t\t\t\t\t\t\t\tbottomLegendDefinition?.color ?? \"#FFFFFF\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{bottomDataSource && (\n\t\t\t\t\t\t<DataValue\n\t\t\t\t\t\t\tvalue={bottomValue}\n\t\t\t\t\t\t\tdataSource={bottomDataSource}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</DataTableCell>\n\t);\n}\n\nexport const LinkedCell = React.memo(LinkedCellComponent, (prev, next) => {\n\treturn (\n\t\tprev.top.value === next.top.value &&\n\t\tprev.bottom.value === next.bottom.value\n\t);\n});\n"]}
|
|
@@ -10,7 +10,8 @@ var FurtherAnalysisModal = require('./FurtherAnalysisModal');
|
|
|
10
10
|
function LinkedDataCellComponent({
|
|
11
11
|
dataSources,
|
|
12
12
|
orgUnit,
|
|
13
|
-
period
|
|
13
|
+
period,
|
|
14
|
+
size
|
|
14
15
|
}) {
|
|
15
16
|
const [furtherAnalysisConfig, setFurtherAnalysisConfig] = react.useState(null);
|
|
16
17
|
const [stateActionRef, setStateActionRef] = react.useState(void 0);
|
|
@@ -39,6 +40,7 @@ function LinkedDataCellComponent({
|
|
|
39
40
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40
41
|
LinkedCell.LinkedCell,
|
|
41
42
|
{
|
|
43
|
+
size,
|
|
42
44
|
onContextMenu: (e) => {
|
|
43
45
|
e.preventDefault();
|
|
44
46
|
setStateActionRef(e.target);
|
package/dist/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/LinkedDataCell.tsx"],"names":[],"mappings":"AAyCE,mBAEE,KAFF;AAvCF,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,MAAM,gBAAgB;AAC/B,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,OAEM;AASP,SAAS,wBAAwB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAwB;AACvB,QAAM,CAAC,uBAAuB,wBAAwB,IACrD,SAAuC,IAAI;AAC5C,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,MAAS;AAE9D,QAAM,CAAC,KAAK,MAAM,IAAI,eAAe,CAAC;AACtC,QAAM,EAAE,kBAAkB,oBAAoB,IAAI,YAAY;AAAA,IAC7D,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACD,CAAC;AACD,QAAM,EAAE,kBAAkB,uBAAuB,IAAI,YAAY;AAAA,IAChE,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACD,CAAC;AAED,SACC,iCACE;AAAA,KAAC,CAAC,yBACF;AAAA,MAAC;AAAA;AAAA,QACA,SAAS,MAAM;AACd,mCAAyB,IAAI;AAAA,QAC9B;AAAA,QACA,MAAM,CAAC;AAAA,QACP,QAAQ;AAAA;AAAA,IACT;AAAA,IAED;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,eAAe,CAAC,MAAW;AAC1B,YAAE,eAAe;AACjB,4BAAkB,EAAE,MAAM;AAAA,QAC3B;AAAA,QACA,SAAS,CAAC,UAAsB;AAC/B,gBAAM,gBAAgB;AACtB,mCAAyB;AAAA,YACxB,iBAAiB;AAAA,cAChB,SAAS;AAAA,gBACR;AAAA,kBACC,IAAI;AAAA,gBACL;AAAA,cACD;AAAA,YACD;AAAA,YACA,kBAAkB;AAAA,cACjB,QAAQ,CAAC;AAAA,cACT,QAAQ,CAAC;AAAA,cACT,UAAU;AAAA,gBACT;AAAA,kBACC,IAAI,QAAQ;AAAA,gBACb;AAAA,cACD;AAAA,YACD;AAAA,YACA;AAAA,UACD,CAAC;AAAA,QACF;AAAA,QACA,KAAK;AAAA,UACJ,kBAAkB;AAAA,UAClB,YAAY;AAAA,QACb;AAAA,QACA,QAAQ;AAAA,UACP,kBAAkB;AAAA,UAClB,YAAY;AAAA,QACb;AAAA;AAAA,IACD;AAAA,IACC,kBACA;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAU;AAAA;AAAA,IACX;AAAA,KAEF;AAEF;AAEO,MAAM,iBAAiB,KAAK,uBAAuB","sourcesContent":["import type { ScorecardCellData } from \"../../../schemas/config\";\nimport type { ItemMeta } from \"../../../hooks/metadata\";\nimport { useCellData } from \"../../../hooks/cellData\";\nimport { LinkedCell } from \"./LinkedCell\";\nimport { memo, useState } from \"react\";\nimport { FurtherAnalysisMenu } from \"./FurtherAnalysisMenu\";\nimport {\n\tFurtherAnalysis,\n\ttype FurtherAnalysisConfig,\n} from \"./FurtherAnalysisModal\";\n\nexport interface LinkedDataCellProps {\n\tdataSources: ScorecardCellData[];\n\torgUnit: ItemMeta & { hierarchy: string };\n\tperiod: string;\n\tsize: number;\n}\n\nfunction LinkedDataCellComponent({\n\tdataSources,\n\torgUnit,\n\tperiod,\n\tsize,\n}: LinkedDataCellProps) {\n\tconst [furtherAnalysisConfig, setFurtherAnalysisConfig] =\n\t\tuseState<FurtherAnalysisConfig | null>(null);\n\tconst [stateActionRef, setStateActionRef] = useState(undefined);\n\n\tconst [top, bottom] = dataSources ?? [];\n\tconst { legendDefinition: topLegendDefinition } = useCellData({\n\t\tdataSource: top,\n\t\torgUnit,\n\t\tperiod,\n\t});\n\tconst { legendDefinition: bottomLegendDefinition } = useCellData({\n\t\tdataSource: bottom,\n\t\torgUnit,\n\t\tperiod,\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{!!furtherAnalysisConfig && (\n\t\t\t\t<FurtherAnalysis\n\t\t\t\t\tonClose={() => {\n\t\t\t\t\t\tsetFurtherAnalysisConfig(null);\n\t\t\t\t\t}}\n\t\t\t\t\thide={!furtherAnalysisConfig}\n\t\t\t\t\tconfig={furtherAnalysisConfig}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<LinkedCell\n\t\t\t\tsize={size}\n\t\t\t\tonContextMenu={(e: any) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tsetStateActionRef(e.target);\n\t\t\t\t}}\n\t\t\t\tonClick={(event: MouseEvent) => {\n\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\tsetFurtherAnalysisConfig({\n\t\t\t\t\t\tperiodSelection: {\n\t\t\t\t\t\t\tperiods: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: period,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t\torgUnitSelection: {\n\t\t\t\t\t\t\tlevels: [],\n\t\t\t\t\t\t\tgroups: [],\n\t\t\t\t\t\t\torgUnits: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: orgUnit.uid,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t\tdataSources,\n\t\t\t\t\t});\n\t\t\t\t}}\n\t\t\t\ttop={{\n\t\t\t\t\tlegendDefinition: topLegendDefinition,\n\t\t\t\t\tdataSource: top,\n\t\t\t\t}}\n\t\t\t\tbottom={{\n\t\t\t\t\tlegendDefinition: bottomLegendDefinition,\n\t\t\t\t\tdataSource: bottom,\n\t\t\t\t}}\n\t\t\t/>\n\t\t\t{stateActionRef && (\n\t\t\t\t<FurtherAnalysisMenu\n\t\t\t\t\tdataSources={dataSources}\n\t\t\t\t\tonSelect={setFurtherAnalysisConfig}\n\t\t\t\t\tstateActionRef={stateActionRef}\n\t\t\t\t\tsetStateActionRef={setStateActionRef}\n\t\t\t\t\torgUnit={orgUnit}\n\t\t\t\t\tperiodId={period}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</>\n\t);\n}\n\nexport const LinkedDataCell = memo(LinkedDataCellComponent);\n"]}
|
package/dist/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Scorecard/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"AAyBG;AAzBH,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AACjB,SAAS,iCAAiC;AAEnC,SAAS,iBAAiB;AAChC,QAAM,aAAa,0BAAmC;AAAA,IACrD;AAAA,IACA;AAAA,EACD,CAAC;AAED,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAQ;AAAA,MACR,OAAM;AAAA,MACN,OAAO;AAAA,QACN,OAAO;AAAA,QACP,UAAU;AAAA,MACX;AAAA,MACA,OAAM;AAAA,MACN,SAAS,aAAa,MAAM;AAAA,MAC5B,OAAK;AAAA,MAGL,MAAK;AAAA,MAEL,8BAAC,OAAE,OAAO,EAAE,SAAS,QAAQ,GAAI,eAAK,EAAE,SAAS,GAAE;AAAA;AAAA,EACpD;AAEF","sourcesContent":["import { DataTableCell } from \"@dhis2/ui\";\nimport i18n from \"@dhis2/d2-i18n\";\nimport { useScorecardStateSelector } from \"../../StateProvider\";\n\nexport function MetaFooterCell() {\n\tconst itemNumber = useScorecardStateSelector<boolean>([\n\t\t\"options\",\n\t\t\"itemNumber\",\n\t]);\n\n\treturn (\n\t\t<DataTableCell\n\t\t\tbordered\n\t\t\twidth=\"300px\"\n\t\t\tstyle={{\n\t\t\t\twidth: \"fit-content\",\n\t\t\t\tminWidth: 300,\n\t\t\t}}\n\t\t\talign=\"center\"\n\t\t\tcolSpan={itemNumber ? \"3\" : \"2\"}\n\t\t\tfixed\n\t\t\t/*\n // @ts-ignore */\n\t\t\tleft=\"0\"\n\t\t>\n\t\t\t<b style={{ padding: \"8px 0\" }}>{i18n.t(\"Average\")}</b>\n\t\t</DataTableCell>\n\t);\n}\n"]}
|