@hisptz/dhis2-analytics 2.1.26 → 2.1.28
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/Map/components/MapProvider/index.js +2 -1
- package/dist/components/Map/components/MapProvider/index.js.map +1 -1
- package/dist/components/Map/state/index.js.map +1 -1
- package/dist/esm/components/Map/components/MapProvider/index.js +2 -1
- package/dist/esm/components/Map/components/MapProvider/index.js.map +1 -1
- package/dist/esm/components/Map/state/index.js.map +1 -1
- package/dist/types/components/Map/components/MapProvider/index.d.ts.map +1 -1
- package/dist/types/components/Map/state/index.d.ts +2 -2
- package/dist/types/components/Map/state/index.d.ts.map +1 -1
- package/package.json +7 -15
|
@@ -48,7 +48,8 @@ function MapProvider({
|
|
|
48
48
|
const rawOrgUnitIds = utils.getOrgUnitsSelection(orgUnitSelection);
|
|
49
49
|
const data = await refetch({
|
|
50
50
|
orgUnitIds: rawOrgUnitIds,
|
|
51
|
-
periodIds: periodSelection?.periods
|
|
51
|
+
periodIds: !lodash.isEmpty(periodSelection?.periods) ? periodSelection?.periods : ["THIS_YEAR"]
|
|
52
|
+
// Just a placeholder so as the analytics query doesn't fail, when the period is empty, it means that this isn't a DHIS2 map plot
|
|
52
53
|
});
|
|
53
54
|
const { analytics, boundaries } = data ?? {};
|
|
54
55
|
const rawOrgUnits = utils.sanitizeOrgUnits(analytics?.metaData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["useState","useDataQuery","useEffect","getOrgUnitsSelection","sanitizeOrgUnits","toGeoJson","orgUnits","compact","periods","PeriodUtility","error","jsx","Center","CircularLoader","jsxs","i18n","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["useState","useDataQuery","useEffect","getOrgUnitsSelection","isEmpty","sanitizeOrgUnits","toGeoJson","orgUnits","compact","periods","PeriodUtility","error","jsx","Center","Circ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AA,CAAIA,MAAK,CAAC,CAAA;AAAA,KAC/C,CAAC,gBAAA,EAAkB,OAAS,EAAA,eAAA,EAAiB,OAAO,CAAC,CAAA;AAExD,EAAA,IAAI,OAAS,EAAA;AACZ,IAAA,sCACE,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,MAAA,EAAQ,QAAQ,KAAO,EAAA,MAAA,EACpC,EAAA,QAAA,kBAAAC,cAAA,CAACC,aACA,QAAC,kBAAAD,cAAA,CAAAE,iBAAA,EAAA,EAAe,KAAK,EAAA,IAAA,EAAC,GACvB,CACD,EAAA,CAAA;AAAA;AAIF,EAAA,IAAI,KAAO,EAAA;AACV,IAAA,uBACEF,cAAA,CAAA,KAAA,EAAA,EAAI,KAAO,EAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,KAAO,EAAA,MAAA,EACpC,EAAA,QAAA,kBAAAA,cAAA,CAACC,SACA,EAAA,EAAA,QAAA,kBAAAE,eAAA,CAAC,IACC,EAAA,EAAA,QAAA,EAAA;AAAA,MAAAC,qBAAA,CAAK,EAAE,OAAO,CAAA;AAAA,MAAE,IAAA;AAAA,MAAG,KAAM,CAAA;AAAA,KAAA,EAC3B,GACD,CACD,EAAA,CAAA;AAAA;AAIF,EAAI,IAAA,CAACZ,cAAQ,CAAA,QAAQ,CAAG,EAAA;AACvB,IACC,uBAAAQ,cAAA,CAACK,wBAAkB,QAAlB,EAAA,EAA2B,OAAO,EAAE,gBAAA,EAAkB,UACtD,EAAA,QAAA,kBAAAL,cAAA;AAAA,MAACM,sBAAiB,CAAA,QAAA;AAAA,MAAjB;AAAA,QACA,KAAO,EAAA,EAAE,GAAG,eAAA,EAAiB,OAAQ,EAAA;AAAA,QAEpC;AAAA;AAAA,KAEH,EAAA,CAAA;AAAA;AAIF,EAAO,OAAA,IAAA;AACR","file":"index.js","sourcesContent":["import { useDataQuery } from \"@dhis2/app-runtime\";\nimport i18n from \"@dhis2/d2-i18n\";\nimport { Center, CircularLoader } from \"@dhis2/ui\";\nimport { compact, isEmpty } from \"lodash\";\nimport { useEffect, useState } from \"react\";\nimport { MapOrgUnit, MapProviderProps } from \"../../interfaces\";\nimport { MapOrgUnitContext, MapPeriodContext } from \"../../state\";\nimport { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from \"../../utils\";\nimport { BasePeriod, PeriodUtility } from \"@hisptz/dhis2-utils\";\n\nconst boundaryQuery = {\n\tboundaries: {\n\t\tresource: \"geoFeatures\",\n\t\tparams: ({ orgUnitIds }: any) => ({\n\t\t\tou: `ou:${orgUnitIds?.join(\";\")}`,\n\t\t}),\n\t},\n\tanalytics: {\n\t\tresource: \"analytics\",\n\t\tparams: ({ orgUnitIds, periodIds }: any) => ({\n\t\t\tdimension: [\n\t\t\t\t`ou:${orgUnitIds.join(\";\")}`,\n\t\t\t\t`pe:${periodIds?.join(\";\")}`,\n\t\t\t],\n\t\t\tskipData: true,\n\t\t\thierarchyMeta: true,\n\t\t}),\n\t},\n};\n\nexport function MapProvider({\n\tchildren,\n\torgUnitSelection,\n\tperiodSelection,\n}: MapProviderProps) {\n\tconst [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);\n\tconst [periods, setPeriods] = useState<BasePeriod[]>([]);\n\tconst { refetch, loading, error } = useDataQuery(boundaryQuery, {\n\t\tlazy: true,\n\t});\n\n\tuseEffect(() => {\n\t\tasync function getOrgUnits() {\n\t\t\tconst rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);\n\t\t\tconst data = await refetch({\n\t\t\t\torgUnitIds: rawOrgUnitIds,\n\t\t\t\tperiodIds: !isEmpty(periodSelection?.periods)\n\t\t\t\t\t? periodSelection?.periods\n\t\t\t\t\t: [\"THIS_YEAR\"], // Just a placeholder so as the analytics query doesn't fail, when the period is empty, it means that this isn't a DHIS2 map plot\n\t\t\t});\n\t\t\tconst { analytics, boundaries } = (data as any) ?? {};\n\t\t\tconst rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);\n\t\t\tconst geoJSONObjects = toGeoJson(\n\t\t\t\tboundaries.filter((bound: any) => bound.co),\n\t\t\t);\n\t\t\tconst orgUnits: MapOrgUnit[] = compact(\n\t\t\t\trawOrgUnits.map((orgUnit: any) => {\n\t\t\t\t\tconst geoJSONObject: any = geoJSONObjects?.find(\n\t\t\t\t\t\t(geoJSON: any) => geoJSON.properties.id === orgUnit.id,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!geoJSONObject) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...orgUnit,\n\t\t\t\t\t\tgeoJSON: geoJSONObject,\n\t\t\t\t\t\tbounds: [],\n\t\t\t\t\t\tlevel: geoJSONObject.properties.level,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst periodIds =\n\t\t\t\tanalytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;\n\t\t\tconst periods = periodIds.map((pe: string) =>\n\t\t\t\tPeriodUtility.getPeriodById(pe),\n\t\t\t);\n\t\t\tsetPeriods(periods);\n\t\t\tsetOrgUnits(orgUnits);\n\t\t}\n\t\tgetOrgUnits().catch((error) => console.log(error));\n\t}, [orgUnitSelection, refetch, periodSelection?.periods]);\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<CircularLoader small />\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (error) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<h4>\n\t\t\t\t\t\t{i18n.t(\"Error\")}: {error.message}\n\t\t\t\t\t</h4>\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (!isEmpty(orgUnits)) {\n\t\treturn (\n\t\t\t<MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>\n\t\t\t\t<MapPeriodContext.Provider\n\t\t\t\t\tvalue={{ ...periodSelection, periods }}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</MapPeriodContext.Provider>\n\t\t\t</MapOrgUnitContext.Provider>\n\t\t);\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Map/state/index.tsx"],"names":["createContext"],"mappings":";;;;AAMO,MAAM,oBAAoBA,mBAG9B,CAAA;AAAA,EACF,gBAAkB,EAAA,EAAE,QAAU,EAAA,EAAG,EAAA;AAAA,EACjC,UAAU;AACX,CAAC;AAEM,MAAM,mBAAmBA,mBAM9B,CAAA;AAAA,EACD,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmBA,mBAG7B,CAAA;AAAA,EACF,QAAQ,EAAC;AAAA,EACT,aAAa,MAAM;AAAA;AACpB,CAAC","file":"index.js","sourcesContent":["import type { OrgUnitSelection } from \"@hisptz/dhis2-utils\";\nimport { BasePeriod } from \"@hisptz/dhis2-utils\";\nimport { createContext } from \"react\";\nimport { CustomMapLayer } from \"../components/MapLayer/interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Map/state/index.tsx"],"names":["createContext"],"mappings":";;;;AAMO,MAAM,oBAAoBA,mBAG9B,CAAA;AAAA,EACF,gBAAkB,EAAA,EAAE,QAAU,EAAA,EAAG,EAAA;AAAA,EACjC,UAAU;AACX,CAAC;AAEM,MAAM,mBAAmBA,mBAM9B,CAAA;AAAA,EACD,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmBA,mBAG7B,CAAA;AAAA,EACF,QAAQ,EAAC;AAAA,EACT,aAAa,MAAM;AAAA;AACpB,CAAC","file":"index.js","sourcesContent":["import type { OrgUnitSelection } from \"@hisptz/dhis2-utils\";\nimport { BasePeriod } from \"@hisptz/dhis2-utils\";\nimport { createContext } from \"react\";\nimport { CustomMapLayer } from \"../components/MapLayer/interfaces\";\nimport { MapOrgUnit } from \"../interfaces\";\n\nexport const MapOrgUnitContext = createContext<{\n\torgUnitSelection: OrgUnitSelection;\n\torgUnits?: MapOrgUnit[];\n}>({\n\torgUnitSelection: { orgUnits: [] },\n\torgUnits: [],\n});\n\nexport const MapPeriodContext = createContext<\n\t| {\n\t\t\tperiods?: BasePeriod[];\n\t\t\trange?: { start: Date; end: Date };\n\t }\n\t| undefined\n>({\n\tperiods: [],\n});\n\nexport const MapLayersContext = createContext<{\n\tlayers: CustomMapLayer[];\n\tupdateLayer: (id: string, updatedLayer: CustomMapLayer) => void;\n}>({\n\tlayers: [],\n\tupdateLayer: () => {},\n});\n"]}
|
|
@@ -42,7 +42,8 @@ function MapProvider({
|
|
|
42
42
|
const rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);
|
|
43
43
|
const data = await refetch({
|
|
44
44
|
orgUnitIds: rawOrgUnitIds,
|
|
45
|
-
periodIds: periodSelection?.periods
|
|
45
|
+
periodIds: !isEmpty(periodSelection?.periods) ? periodSelection?.periods : ["THIS_YEAR"]
|
|
46
|
+
// Just a placeholder so as the analytics query doesn't fail, when the period is empty, it means that this isn't a DHIS2 map plot
|
|
46
47
|
});
|
|
47
48
|
const { analytics, boundaries } = data ?? {};
|
|
48
49
|
const rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["orgUnits","periods","error"],"mappings":";;;;;;;;;;AAUA,MAAM,aAAgB,GAAA;AAAA,EACrB,UAAY,EAAA;AAAA,IACX,QAAU,EAAA,aAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAuB,MAAA;AAAA,MACjC,EAAI,EAAA,CAAA,GAAA,EAAM,UAAY,EAAA,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,KAChC;AAAA,GACD;AAAA,EACA,SAAW,EAAA;AAAA,IACV,QAAU,EAAA,WAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAY,WAAsB,MAAA;AAAA,MAC5C,SAAW,EAAA;AAAA,QACV,CAAM,GAAA,EAAA,UAAA,CAAW,IAAK,CAAA,GAAG,CAAC,CAAA,CAAA;AAAA,QAC1B,CAAM,GAAA,EAAA,SAAA,EAAW,IAAK,CAAA,GAAG,CAAC,CAAA;AAAA,OAC3B;AAAA,MACA,QAAU,EAAA,IAAA;AAAA,MACV,aAAe,EAAA;AAAA,KAChB;AAAA;AAEF,CAAA;AAEO,SAAS,WAAY,CAAA;AAAA,EAC3B,QAAA;AAAA,EACA,gBAAA;AAAA,EACA;AACD,CAAqB,EAAA;AACpB,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,QAAA,CAAuB,EAAE,CAAA;AACzD,EAAA,MAAM,CAAC,OAAS,EAAA,UAAU,CAAI,GAAA,QAAA,CAAuB,EAAE,CAAA;AACvD,EAAA,MAAM,EAAE,OAAS,EAAA,OAAA,EAAS,KAAM,EAAA,GAAI,aAAa,aAAe,EAAA;AAAA,IAC/D,IAAM,EAAA;AAAA,GACN,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,eAAe,WAAc,GAAA;AAC5B,MAAM,MAAA,aAAA,GAAgB,qBAAqB,gBAAgB,CAAA;AAC3D,MAAM,MAAA,IAAA,GAAO,MAAM,OAAQ,CAAA;AAAA,QAC1B,UAAY,EAAA,aAAA;AAAA,QACZ,
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":["orgUnits","periods","error"],"mappings":";;;;;;;;;;AAUA,MAAM,aAAgB,GAAA;AAAA,EACrB,UAAY,EAAA;AAAA,IACX,QAAU,EAAA,aAAA;AAAA,IACV,MAAQ,EAAA,CAAC,EAAE,UAAA,EAAuB,MAAA;AAAA,MACjC,EAAI,EAAA,CAAA,GAAA,EAAM,UAAY,EAAA,IAAA,CAAK,GAAG,CAAC,CAAA;AAAA,KAChC;AAAA,GACD;AAAA,EACA,SAAW,EAAA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,CACD,EAAA,CAAA;AAAA;AAIF,EAAA,IAAI,KAAO,EAAA;AACV,IAAA,uBACE,GAAA,CAAA,KAAA,EAAA,EAAI,KAAO,EAAA,EAAE,MAAQ,EAAA,MAAA,EAAQ,KAAO,EAAA,MAAA,EACpC,EAAA,QAAA,kBAAA,GAAA,CAAC,MACA,EAAA,EAAA,QAAA,kBAAA,IAAA,CAAC,IACC,EAAA,EAAA,QAAA,EAAA;AAAA,MAAA,IAAA,CAAK,EAAE,OAAO,CAAA;AAAA,MAAE,IAAA;AAAA,MAAG,KAAM,CAAA;AAAA,KAAA,EAC3B,GACD,CACD,EAAA,CAAA;AAAA;AAIF,EAAI,IAAA,CAAC,OAAQ,CAAA,QAAQ,CAAG,EAAA;AACvB,IACC,uBAAA,GAAA,CAAC,kBAAkB,QAAlB,EAAA,EAA2B,OAAO,EAAE,gBAAA,EAAkB,UACtD,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,gBAAiB,CAAA,QAAA;AAAA,MAAjB;AAAA,QACA,KAAO,EAAA,EAAE,GAAG,eAAA,EAAiB,OAAQ,EAAA;AAAA,QAEpC;AAAA;AAAA,KAEH,EAAA,CAAA;AAAA;AAIF,EAAO,OAAA,IAAA;AACR","file":"index.js","sourcesContent":["import { useDataQuery } from \"@dhis2/app-runtime\";\nimport i18n from \"@dhis2/d2-i18n\";\nimport { Center, CircularLoader } from \"@dhis2/ui\";\nimport { compact, isEmpty } from \"lodash\";\nimport { useEffect, useState } from \"react\";\nimport { MapOrgUnit, MapProviderProps } from \"../../interfaces\";\nimport { MapOrgUnitContext, MapPeriodContext } from \"../../state\";\nimport { getOrgUnitsSelection, sanitizeOrgUnits, toGeoJson } from \"../../utils\";\nimport { BasePeriod, PeriodUtility } from \"@hisptz/dhis2-utils\";\n\nconst boundaryQuery = {\n\tboundaries: {\n\t\tresource: \"geoFeatures\",\n\t\tparams: ({ orgUnitIds }: any) => ({\n\t\t\tou: `ou:${orgUnitIds?.join(\";\")}`,\n\t\t}),\n\t},\n\tanalytics: {\n\t\tresource: \"analytics\",\n\t\tparams: ({ orgUnitIds, periodIds }: any) => ({\n\t\t\tdimension: [\n\t\t\t\t`ou:${orgUnitIds.join(\";\")}`,\n\t\t\t\t`pe:${periodIds?.join(\";\")}`,\n\t\t\t],\n\t\t\tskipData: true,\n\t\t\thierarchyMeta: true,\n\t\t}),\n\t},\n};\n\nexport function MapProvider({\n\tchildren,\n\torgUnitSelection,\n\tperiodSelection,\n}: MapProviderProps) {\n\tconst [orgUnits, setOrgUnits] = useState<MapOrgUnit[]>([]);\n\tconst [periods, setPeriods] = useState<BasePeriod[]>([]);\n\tconst { refetch, loading, error } = useDataQuery(boundaryQuery, {\n\t\tlazy: true,\n\t});\n\n\tuseEffect(() => {\n\t\tasync function getOrgUnits() {\n\t\t\tconst rawOrgUnitIds = getOrgUnitsSelection(orgUnitSelection);\n\t\t\tconst data = await refetch({\n\t\t\t\torgUnitIds: rawOrgUnitIds,\n\t\t\t\tperiodIds: !isEmpty(periodSelection?.periods)\n\t\t\t\t\t? periodSelection?.periods\n\t\t\t\t\t: [\"THIS_YEAR\"], // Just a placeholder so as the analytics query doesn't fail, when the period is empty, it means that this isn't a DHIS2 map plot\n\t\t\t});\n\t\t\tconst { analytics, boundaries } = (data as any) ?? {};\n\t\t\tconst rawOrgUnits = sanitizeOrgUnits(analytics?.metaData);\n\t\t\tconst geoJSONObjects = toGeoJson(\n\t\t\t\tboundaries.filter((bound: any) => bound.co),\n\t\t\t);\n\t\t\tconst orgUnits: MapOrgUnit[] = compact(\n\t\t\t\trawOrgUnits.map((orgUnit: any) => {\n\t\t\t\t\tconst geoJSONObject: any = geoJSONObjects?.find(\n\t\t\t\t\t\t(geoJSON: any) => geoJSON.properties.id === orgUnit.id,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (!geoJSONObject) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...orgUnit,\n\t\t\t\t\t\tgeoJSON: geoJSONObject,\n\t\t\t\t\t\tbounds: [],\n\t\t\t\t\t\tlevel: geoJSONObject.properties.level,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t);\n\t\t\tconst periodIds =\n\t\t\t\tanalytics?.metaData?.dimensions?.pe ?? periodSelection?.periods;\n\t\t\tconst periods = periodIds.map((pe: string) =>\n\t\t\t\tPeriodUtility.getPeriodById(pe),\n\t\t\t);\n\t\t\tsetPeriods(periods);\n\t\t\tsetOrgUnits(orgUnits);\n\t\t}\n\t\tgetOrgUnits().catch((error) => console.log(error));\n\t}, [orgUnitSelection, refetch, periodSelection?.periods]);\n\n\tif (loading) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<CircularLoader small />\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (error) {\n\t\treturn (\n\t\t\t<div style={{ height: \"100%\", width: \"100%\" }}>\n\t\t\t\t<Center>\n\t\t\t\t\t<h4>\n\t\t\t\t\t\t{i18n.t(\"Error\")}: {error.message}\n\t\t\t\t\t</h4>\n\t\t\t\t</Center>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif (!isEmpty(orgUnits)) {\n\t\treturn (\n\t\t\t<MapOrgUnitContext.Provider value={{ orgUnitSelection, orgUnits }}>\n\t\t\t\t<MapPeriodContext.Provider\n\t\t\t\t\tvalue={{ ...periodSelection, periods }}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</MapPeriodContext.Provider>\n\t\t\t</MapOrgUnitContext.Provider>\n\t\t);\n\t}\n\n\treturn null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/Map/state/index.tsx"],"names":[],"mappings":";;AAMO,MAAM,oBAAoB,aAG9B,CAAA;AAAA,EACF,gBAAkB,EAAA,EAAE,QAAU,EAAA,EAAG,EAAA;AAAA,EACjC,UAAU;AACX,CAAC;AAEM,MAAM,mBAAmB,aAM9B,CAAA;AAAA,EACD,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmB,aAG7B,CAAA;AAAA,EACF,QAAQ,EAAC;AAAA,EACT,aAAa,MAAM;AAAA;AACpB,CAAC","file":"index.js","sourcesContent":["import type { OrgUnitSelection } from \"@hisptz/dhis2-utils\";\nimport { BasePeriod } from \"@hisptz/dhis2-utils\";\nimport { createContext } from \"react\";\nimport { CustomMapLayer } from \"../components/MapLayer/interfaces
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Map/state/index.tsx"],"names":[],"mappings":";;AAMO,MAAM,oBAAoB,aAG9B,CAAA;AAAA,EACF,gBAAkB,EAAA,EAAE,QAAU,EAAA,EAAG,EAAA;AAAA,EACjC,UAAU;AACX,CAAC;AAEM,MAAM,mBAAmB,aAM9B,CAAA;AAAA,EACD,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmB,aAG7B,CAAA;AAAA,EACF,QAAQ,EAAC;AAAA,EACT,aAAa,MAAM;AAAA;AACpB,CAAC","file":"index.js","sourcesContent":["import type { OrgUnitSelection } from \"@hisptz/dhis2-utils\";\nimport { BasePeriod } from \"@hisptz/dhis2-utils\";\nimport { createContext } from \"react\";\nimport { CustomMapLayer } from \"../components/MapLayer/interfaces\";\nimport { MapOrgUnit } from \"../interfaces\";\n\nexport const MapOrgUnitContext = createContext<{\n\torgUnitSelection: OrgUnitSelection;\n\torgUnits?: MapOrgUnit[];\n}>({\n\torgUnitSelection: { orgUnits: [] },\n\torgUnits: [],\n});\n\nexport const MapPeriodContext = createContext<\n\t| {\n\t\t\tperiods?: BasePeriod[];\n\t\t\trange?: { start: Date; end: Date };\n\t }\n\t| undefined\n>({\n\tperiods: [],\n});\n\nexport const MapLayersContext = createContext<{\n\tlayers: CustomMapLayer[];\n\tupdateLayer: (id: string, updatedLayer: CustomMapLayer) => void;\n}>({\n\tlayers: [],\n\tupdateLayer: () => {},\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAc,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAyBhE,wBAAgB,WAAW,CAAC,EAC3B,QAAQ,EACR,gBAAgB,EAChB,eAAe,GACf,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Map/components/MapProvider/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAc,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAyBhE,wBAAgB,WAAW,CAAC,EAC3B,QAAQ,EACR,gBAAgB,EAChB,eAAe,GACf,EAAE,gBAAgB,kDAoFlB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OrgUnitSelection } from "@hisptz/dhis2-utils";
|
|
2
2
|
import { BasePeriod } from "@hisptz/dhis2-utils";
|
|
3
|
-
import { CustomMapLayer } from "../components/MapLayer/interfaces
|
|
4
|
-
import { MapOrgUnit } from "../interfaces
|
|
3
|
+
import { CustomMapLayer } from "../components/MapLayer/interfaces";
|
|
4
|
+
import { MapOrgUnit } from "../interfaces";
|
|
5
5
|
export declare const MapOrgUnitContext: import("react").Context<{
|
|
6
6
|
orgUnitSelection: OrgUnitSelection;
|
|
7
7
|
orgUnits?: MapOrgUnit[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Map/state/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Map/state/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,eAAO,MAAM,iBAAiB;sBACX,gBAAgB;eACvB,UAAU,EAAE;EAItB,CAAC;AAEH,eAAO,MAAM,gBAAgB;cAEhB,UAAU,EAAE;YACd;QAAE,KAAK,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,IAAI,CAAA;KAAE;cAKnC,CAAC;AAEH,eAAO,MAAM,gBAAgB;YACpB,cAAc,EAAE;iBACX,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,KAAK,IAAI;EAI9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hisptz/dhis2-analytics",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.28",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -38,14 +38,16 @@
|
|
|
38
38
|
"concurrently": "^8.2.2",
|
|
39
39
|
"eslint": "^8.56.0",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
41
|
+
"react": "^18.3.1",
|
|
42
|
+
"react-dom": "^18.3.1",
|
|
41
43
|
"react-error-boundary": "^4.0.12",
|
|
42
44
|
"react-hook-form": "^7.43.9",
|
|
43
45
|
"styled-jsx": "^5.1.2",
|
|
44
46
|
"tsup": "^8.4.0",
|
|
45
47
|
"typescript": "^5.3.3",
|
|
46
48
|
"usehooks-ts": "^2.16.0",
|
|
47
|
-
"@repo/
|
|
48
|
-
"@repo/
|
|
49
|
+
"@repo/eslint-config": "0.0.0",
|
|
50
|
+
"@repo/typescript-config": "0.0.2"
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
51
53
|
"@react-leaflet/core": "^2.1.0",
|
|
@@ -72,24 +74,14 @@
|
|
|
72
74
|
"react-to-print": "^3.0.1",
|
|
73
75
|
"screenfull": "^6.0.2",
|
|
74
76
|
"xlsx": "^0.18.5",
|
|
75
|
-
"@hisptz/dhis2-
|
|
76
|
-
"@hisptz/dhis2-
|
|
77
|
+
"@hisptz/dhis2-ui": "2.0.50",
|
|
78
|
+
"@hisptz/dhis2-utils": "2.0.18"
|
|
77
79
|
},
|
|
78
80
|
"peerDependencies": {
|
|
79
|
-
"@dhis2/app-runtime": "^3",
|
|
80
|
-
"@dhis2/d2-i18n": "^1",
|
|
81
|
-
"@dhis2/multi-calendar-dates": "^1",
|
|
82
|
-
"@dhis2/ui": "^10",
|
|
83
81
|
"classnames": "^2",
|
|
84
82
|
"highcharts": "^12",
|
|
85
83
|
"highcharts-react-official": "^3",
|
|
86
84
|
"lodash": "^4",
|
|
87
|
-
"react": "^18 || ^19",
|
|
88
|
-
"react-dom": "^18 || ^19",
|
|
89
|
-
"react-hook-form": "^7",
|
|
90
|
-
"recoil": "0.7.7",
|
|
91
|
-
"styled-jsx": "^5",
|
|
92
|
-
"usehooks-ts": "^2",
|
|
93
85
|
"zod": "^3"
|
|
94
86
|
},
|
|
95
87
|
"publishConfig": {
|