@hisptz/dhis2-scorecard 1.0.8 → 1.0.10
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/Scorecard.stories.js +10 -3
- package/dist/Scorecard.stories.js.map +1 -1
- package/dist/ScorecardPrintArea.stories.js +1 -1
- package/dist/ScorecardPrintArea.stories.js.map +1 -1
- package/dist/components/ScorecardHeader.js +6 -1
- package/dist/components/ScorecardHeader.js.map +1 -1
- package/dist/components/ScorecardPrint/components/ScorecardDownloadButton.js +23 -25
- package/dist/components/ScorecardPrint/components/ScorecardDownloadButton.js.map +1 -1
- package/dist/components/ScorecardPrint/components/ScorecardPreviewArea.js +17 -2
- package/dist/components/ScorecardPrint/components/ScorecardPreviewArea.js.map +1 -1
- package/dist/components/ScorecardTable/components/DataFooterCell.js +3 -0
- package/dist/components/ScorecardTable/components/DataFooterCell.js.map +1 -1
- package/dist/components/ScorecardTable/components/MetaFooterCell.js +10 -12
- package/dist/components/ScorecardTable/components/MetaFooterCell.js.map +1 -1
- package/dist/components/StateProvider.js +18 -2
- package/dist/components/StateProvider.js.map +1 -1
- package/dist/esm/Scorecard.stories.js +10 -3
- package/dist/esm/Scorecard.stories.js.map +1 -1
- package/dist/esm/ScorecardPrintArea.stories.js +1 -1
- package/dist/esm/ScorecardPrintArea.stories.js.map +1 -1
- package/dist/esm/components/ScorecardHeader.js +1 -0
- package/dist/esm/components/ScorecardHeader.js.map +1 -1
- package/dist/esm/components/ScorecardPrint/components/ScorecardDownloadButton.js +24 -26
- package/dist/esm/components/ScorecardPrint/components/ScorecardDownloadButton.js.map +1 -1
- package/dist/esm/components/ScorecardPrint/components/ScorecardPreviewArea.js +17 -2
- package/dist/esm/components/ScorecardPrint/components/ScorecardPreviewArea.js.map +1 -1
- package/dist/esm/components/ScorecardTable/components/DataFooterCell.js +3 -0
- package/dist/esm/components/ScorecardTable/components/DataFooterCell.js.map +1 -1
- package/dist/esm/components/ScorecardTable/components/MetaFooterCell.js +10 -12
- package/dist/esm/components/ScorecardTable/components/MetaFooterCell.js.map +1 -1
- package/dist/esm/components/StateProvider.js +19 -3
- package/dist/esm/components/StateProvider.js.map +1 -1
- package/dist/types/components/ScorecardHeader.d.ts.map +1 -1
- package/dist/types/components/ScorecardPrint/components/ScorecardDownloadButton.d.ts.map +1 -1
- package/dist/types/components/ScorecardPrint/components/ScorecardPreviewArea.d.ts.map +1 -1
- package/dist/types/components/ScorecardTable/components/DataFooterCell.d.ts.map +1 -1
- package/dist/types/components/ScorecardTable/components/MetaFooterCell.d.ts +3 -1
- package/dist/types/components/ScorecardTable/components/MetaFooterCell.d.ts.map +1 -1
- package/dist/types/components/StateProvider.d.ts +2 -1
- package/dist/types/components/StateProvider.d.ts.map +1 -1
- package/package.json +7 -6
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { DataTableCell } from '@dhis2/ui';
|
|
3
3
|
import i18n from '@dhis2/d2-i18n';
|
|
4
|
-
import {
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
5
|
|
|
6
|
-
function MetaFooterCell(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function MetaFooterCell({
|
|
7
|
+
column,
|
|
8
|
+
table
|
|
9
|
+
}) {
|
|
10
|
+
const colSpan = useMemo(() => {
|
|
11
|
+
return table.getVisibleLeafColumns().findIndex(({ id }) => id === column.id) + 1;
|
|
12
|
+
}, [table.getVisibleLeafColumns(), column.id]);
|
|
11
13
|
return /* @__PURE__ */ jsx(
|
|
12
14
|
DataTableCell,
|
|
13
15
|
{
|
|
14
16
|
bordered: true,
|
|
15
|
-
width:
|
|
16
|
-
style: {
|
|
17
|
-
width: "fit-content",
|
|
18
|
-
minWidth: 300
|
|
19
|
-
},
|
|
17
|
+
width: `${column.getSize()}px`,
|
|
20
18
|
align: "center",
|
|
21
|
-
colSpan:
|
|
19
|
+
colSpan: colSpan.toString(),
|
|
22
20
|
fixed: true,
|
|
23
21
|
left: "0",
|
|
24
22
|
children: /* @__PURE__ */ jsx("b", { style: { padding: "8px 0" }, children: i18n.t("Average") })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"AA6BG;AA7BH,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAGjB,SAAS,eAAe;AAEjB,SAAS,eAAe;AAAA,EAC9B;AAAA,EACA;AACD,GAA2C;AAC1C,QAAM,UAAU,QAAQ,MAAM;AAC7B,WACC,MACE,sBAAsB,EACtB,UAAU,CAAC,EAAE,GAAG,MAAM,OAAO,OAAO,EAAE,IAAI;AAAA,EAE9C,GAAG,CAAC,MAAM,sBAAsB,GAAG,OAAO,EAAE,CAAC;AAE7C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAQ;AAAA,MACR,OAAO,GAAG,OAAO,QAAQ,CAAC;AAAA,MAC1B,OAAM;AAAA,MACN,SAAS,QAAQ,SAAS;AAAA,MAC1B,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 type { ScorecardTableData } from \"../../../schemas/config\";\nimport type { HeaderContext } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\n\nexport function MetaFooterCell({\n\tcolumn,\n\ttable,\n}: HeaderContext<ScorecardTableData, any>) {\n\tconst colSpan = useMemo(() => {\n\t\treturn (\n\t\t\ttable\n\t\t\t\t.getVisibleLeafColumns()\n\t\t\t\t.findIndex(({ id }) => id === column.id) + 1\n\t\t);\n\t}, [table.getVisibleLeafColumns(), column.id]);\n\n\treturn (\n\t\t<DataTableCell\n\t\t\tbordered\n\t\t\twidth={`${column.getSize()}px`}\n\t\t\talign=\"center\"\n\t\t\tcolSpan={colSpan.toString()}\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"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { RecoilRoot } from 'recoil';
|
|
3
|
+
import { useRecoilCallback, RecoilRoot } from 'recoil';
|
|
4
4
|
import { scorecardStateAtom } from '../state';
|
|
5
5
|
import { getInitialStateFromConfig } from '../utils';
|
|
6
6
|
|
|
7
7
|
function ScorecardStateProvider({
|
|
8
8
|
children,
|
|
9
9
|
initialState,
|
|
10
|
-
config
|
|
10
|
+
config,
|
|
11
|
+
withRecoilRoot
|
|
11
12
|
}) {
|
|
12
13
|
const initState = useCallback(
|
|
13
14
|
({ set }) => {
|
|
@@ -18,7 +19,22 @@ function ScorecardStateProvider({
|
|
|
18
19
|
},
|
|
19
20
|
[initialState, config]
|
|
20
21
|
);
|
|
21
|
-
|
|
22
|
+
const initializeStateWithoutRecoil = useRecoilCallback(
|
|
23
|
+
({ set, snapshot }) => (initialState2) => {
|
|
24
|
+
if (snapshot.getLoadable(scorecardStateAtom).contents === null) {
|
|
25
|
+
set(scorecardStateAtom, initialState2);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
if (!withRecoilRoot) {
|
|
30
|
+
initializeStateWithoutRecoil(
|
|
31
|
+
initialState ?? getInitialStateFromConfig(config)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
if (withRecoilRoot) {
|
|
35
|
+
return /* @__PURE__ */ jsx(RecoilRoot, { initializeState: initState, children });
|
|
36
|
+
}
|
|
37
|
+
return children;
|
|
22
38
|
}
|
|
23
39
|
|
|
24
40
|
export { ScorecardStateProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/StateProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/StateProvider.tsx"],"names":["initialState"],"mappings":"AA8CS;AA7CT,SAAyB,mBAAmB;AAC5C,SAA0B,YAAY,yBAAyB;AAC/D,SAAS,0BAA0B;AACnC,SAAS,iCAAiC;AASnC,SAAS,uBAAuB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAgC;AAC/B,QAAM,YAAY;AAAA,IACjB,CAAC,EAAE,IAAI,MAAuB;AAC7B;AAAA,QACC;AAAA,QACA,gBAAgB,0BAA0B,MAAM;AAAA,MACjD;AAAA,IACD;AAAA,IACA,CAAC,cAAc,MAAM;AAAA,EACtB;AACA,QAAM,+BAA+B;AAAA,IACpC,CAAC,EAAE,KAAK,SAAS,MAChB,CAACA,kBAAiC;AACjC,UACC,SAAS,YAAY,kBAAkB,EAAE,aAAa,MACrD;AACD,YAAI,oBAAoBA,aAAY;AAAA,MACrC;AAAA,IACD;AAAA,EACF;AAEA,MAAI,CAAC,gBAAgB;AACpB;AAAA,MACC,gBAAgB,0BAA0B,MAAM;AAAA,IACjD;AAAA,EACD;AAEA,MAAI,gBAAgB;AACnB,WAAO,oBAAC,cAAW,iBAAiB,WAAY,UAAS;AAAA,EAC1D;AAEA,SAAO;AACR","sourcesContent":["import type { ScorecardConfig, ScorecardState } from \"../schemas/config\";\nimport { type ReactNode, useCallback } from \"react\";\nimport { MutableSnapshot, RecoilRoot, useRecoilCallback } from \"recoil\";\nimport { scorecardStateAtom } from \"../state\";\nimport { getInitialStateFromConfig } from \"../utils\";\n\nexport interface ScorecardStateProviderProps {\n\tinitialState?: ScorecardState;\n\tconfig: ScorecardConfig;\n\tchildren: ReactNode;\n\twithRecoilRoot?: boolean;\n}\n\nexport function ScorecardStateProvider({\n\tchildren,\n\tinitialState,\n\tconfig,\n\twithRecoilRoot,\n}: ScorecardStateProviderProps) {\n\tconst initState = useCallback(\n\t\t({ set }: MutableSnapshot) => {\n\t\t\tset(\n\t\t\t\tscorecardStateAtom,\n\t\t\t\tinitialState ?? getInitialStateFromConfig(config),\n\t\t\t);\n\t\t},\n\t\t[initialState, config],\n\t);\n\tconst initializeStateWithoutRecoil = useRecoilCallback(\n\t\t({ set, snapshot }) =>\n\t\t\t(initialState: ScorecardState) => {\n\t\t\t\tif (\n\t\t\t\t\tsnapshot.getLoadable(scorecardStateAtom).contents === null\n\t\t\t\t) {\n\t\t\t\t\tset(scorecardStateAtom, initialState);\n\t\t\t\t}\n\t\t\t},\n\t);\n\n\tif (!withRecoilRoot) {\n\t\tinitializeStateWithoutRecoil(\n\t\t\tinitialState ?? getInitialStateFromConfig(config),\n\t\t);\n\t}\n\n\tif (withRecoilRoot) {\n\t\treturn <RecoilRoot initializeState={initState}>{children}</RecoilRoot>;\n\t}\n\n\treturn children;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardHeader.d.ts","sourceRoot":"","sources":["../../../src/components/ScorecardHeader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScorecardHeader.d.ts","sourceRoot":"","sources":["../../../src/components/ScorecardHeader.tsx"],"names":[],"mappings":"AASA,wBAAgB,eAAe,mDAoE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardDownloadButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardPrint/components/ScorecardDownloadButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScorecardDownloadButton.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardPrint/components/ScorecardDownloadButton.tsx"],"names":[],"mappings":"AAoFA,wBAAgB,uBAAuB,4CAgCtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScorecardPreviewArea.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardPrint/components/ScorecardPreviewArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ScorecardPreviewArea.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardPrint/components/ScorecardPreviewArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAapD,eAAO,MAAM,oBAAoB;gBAGpB,UAAU,cAAc,CAAC;EA2CpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataFooterCell.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardTable/components/DataFooterCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAEX,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DataFooterCell.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardTable/components/DataFooterCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAEX,wBAAwB,EACxB,kBAAkB,EAClB,MAAM,yBAAyB,CAAC;AAmJjC,wBAAgB,cAAc,CAAC,EAC9B,KAAK,EACL,MAAM,GACN,EAAE,aAAa,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,2CA0B7D"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ScorecardTableData } from "../../../schemas/config";
|
|
2
|
+
import type { HeaderContext } from "@tanstack/react-table";
|
|
3
|
+
export declare function MetaFooterCell({ column, table, }: HeaderContext<ScorecardTableData, any>): import("react/jsx-runtime").JSX.Element;
|
|
2
4
|
//# sourceMappingURL=MetaFooterCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetaFooterCell.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MetaFooterCell.d.ts","sourceRoot":"","sources":["../../../../../src/components/ScorecardTable/components/MetaFooterCell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,wBAAgB,cAAc,CAAC,EAC9B,MAAM,EACN,KAAK,GACL,EAAE,aAAa,CAAC,kBAAkB,EAAE,GAAG,CAAC,2CAuBxC"}
|
|
@@ -4,6 +4,7 @@ export interface ScorecardStateProviderProps {
|
|
|
4
4
|
initialState?: ScorecardState;
|
|
5
5
|
config: ScorecardConfig;
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
withRecoilRoot?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function ScorecardStateProvider({ children, initialState, config, }: ScorecardStateProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function ScorecardStateProvider({ children, initialState, config, withRecoilRoot, }: ScorecardStateProviderProps): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
9
10
|
//# sourceMappingURL=StateProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateProvider.d.ts","sourceRoot":"","sources":["../../../src/components/StateProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAKpD,MAAM,WAAW,2BAA2B;IAC3C,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"StateProvider.d.ts","sourceRoot":"","sources":["../../../src/components/StateProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAKpD,MAAM,WAAW,2BAA2B;IAC3C,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,sBAAsB,CAAC,EACtC,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,cAAc,GACd,EAAE,2BAA2B,gHAgC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hisptz/dhis2-scorecard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"tsup": "^8.0.1",
|
|
47
47
|
"typescript": "^5.3.3",
|
|
48
48
|
"usehooks-ts": "^2.9.2",
|
|
49
|
-
"@repo/
|
|
50
|
-
"@repo/
|
|
49
|
+
"@repo/eslint-config": "0.0.0",
|
|
50
|
+
"@repo/typescript-config": "0.0.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@tanstack/react-table": "^8.19.3",
|
|
@@ -57,13 +57,14 @@
|
|
|
57
57
|
"react-dnd": "^16.0.1",
|
|
58
58
|
"react-dnd-html5-backend": "^16.0.1",
|
|
59
59
|
"react-error-boundary": "^4.0.12",
|
|
60
|
+
"react-jsx-parser": "^2.2.0",
|
|
60
61
|
"react-to-print": "^3.0.1",
|
|
61
62
|
"recoil": "^0.7.7",
|
|
62
63
|
"xlsx": "^0.18.5",
|
|
63
64
|
"zod": "^3.23.8",
|
|
64
|
-
"@hisptz/dhis2-utils": "2.0.8",
|
|
65
65
|
"@hisptz/dhis2-analytics": "2.0.46",
|
|
66
|
-
"@hisptz/dhis2-ui": "2.0.27"
|
|
66
|
+
"@hisptz/dhis2-ui": "2.0.27",
|
|
67
|
+
"@hisptz/dhis2-utils": "2.0.8"
|
|
67
68
|
},
|
|
68
69
|
"peerDependencies": {
|
|
69
70
|
"@dhis2/app-runtime": "^3.10.2",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
"classnames": "^2.5.1",
|
|
74
75
|
"eslint": "^8.56.0",
|
|
75
76
|
"lodash": "^4.17.21",
|
|
76
|
-
"react": "^18
|
|
77
|
+
"react": "^18",
|
|
77
78
|
"styled-jsx": "^5.1.2",
|
|
78
79
|
"tsup": "^8.0.1",
|
|
79
80
|
"typescript": "^5.3.3",
|