@hisptz/dhis2-analytics 2.0.12 → 2.0.14
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/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +1 -1
- package/dist/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js.map +1 -1
- package/dist/components/Map/utils/map.js +1 -1
- package/dist/components/Map/utils/map.js.map +1 -1
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +1 -1
- package/dist/esm/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js.map +1 -1
- package/dist/esm/components/Map/utils/map.js +1 -1
- package/dist/esm/components/Map/utils/map.js.map +1 -1
- package/package.json +3 -3
|
@@ -15,7 +15,7 @@ function CustomTooltip({
|
|
|
15
15
|
const { dataItem, orgUnit, data } = dataObject ?? {};
|
|
16
16
|
const { periods } = index_js.useMapPeriods() ?? {};
|
|
17
17
|
const formatter = Intl.NumberFormat(navigator.language, {}).format;
|
|
18
|
-
const formattedData = formatter(data);
|
|
18
|
+
const formattedData = data ? formatter(data) : "";
|
|
19
19
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
20
20
|
reactLeaflet.Pane,
|
|
21
21
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx"],"names":[],"mappings":"AAuBG,SAIC,KAJD;AAvBH,OAAO,UAAU;AAEjB,SAAS,MAAM,OAAO,eAAe;AACrC,SAAS,qBAAqB;AAGf,SAAR,cAA+B;AAAA,EACrC,MAAM;AACP,GAEG;AACF,QAAM,EAAE,UAAU,SAAS,KAAK,IAAI,cAAc,CAAC;AACnD,QAAM,EAAE,QAAQ,IAAI,cAAc,KAAK,CAAC;AAExC,QAAM,YAAY,KAAK,aAAa,UAAU,UAAU,CAAC,CAAC,EAAE;AAE5D,QAAM,gBAAgB,UAAU,IAAc;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx"],"names":[],"mappings":"AAuBG,SAIC,KAJD;AAvBH,OAAO,UAAU;AAEjB,SAAS,MAAM,OAAO,eAAe;AACrC,SAAS,qBAAqB;AAGf,SAAR,cAA+B;AAAA,EACrC,MAAM;AACP,GAEG;AACF,QAAM,EAAE,UAAU,SAAS,KAAK,IAAI,cAAc,CAAC;AACnD,QAAM,EAAE,QAAQ,IAAI,cAAc,KAAK,CAAC;AAExC,QAAM,YAAY,KAAK,aAAa,UAAU,UAAU,CAAC,CAAC,EAAE;AAE5D,QAAM,gBAAgB,OAAO,UAAU,IAAc,IAAI;AAEzD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAM,GAAG,SAAS,WAAW,IAAI,QAAQ,EAAE;AAAA,MAC3C,MAAK;AAAA,MAEL;AAAA,6BAAC,WACC;AAAA,mBAAS;AAAA,UAAK;AAAA,UAAG;AAAA,UAAc;AAAA,WACjC;AAAA,QACA,qBAAC,SAAM,UAAU,IAChB;AAAA,8BAAC,QAAG,OAAO,EAAE,QAAQ,EAAE,GAAI,mBAAS,MAAK;AAAA,UACzC,oBAAC,SAAK,oBAAU,aAAY;AAAA,UAC5B,oBAAC,SAAK,mBAAS,IAAI,CAAC,WAAW,OAAO,IAAI,EAAE,KAAK,GAAG,GAAE;AAAA,UACtD,qBAAC,SACC;AAAA,iBAAK,EAAE,OAAO;AAAA,YAAE;AAAA,YAAG;AAAA,aACrB;AAAA,WACD;AAAA;AAAA;AAAA,EACD;AAEF","sourcesContent":["import i18n from \"@dhis2/d2-i18n\";\nimport React from \"react\";\nimport { Pane, Popup, Tooltip } from \"react-leaflet\";\nimport { useMapPeriods } from \"../../../../../MapProvider/hooks/index.js\";\nimport { ThematicLayerData } from \"../../../../interfaces/index.js\";\n\nexport default function CustomTooltip({\n\tdata: dataObject,\n}: {\n\tdata: ThematicLayerData;\n}) {\n\tconst { dataItem, orgUnit, data } = dataObject ?? {};\n\tconst { periods } = useMapPeriods() ?? {};\n\n\tconst formatter = Intl.NumberFormat(navigator.language, {}).format;\n\n\tconst formattedData = data ? formatter(data as number) : \"\";\n\n\treturn (\n\t\t<Pane\n\t\t\tname={`${dataItem.displayName}-${orgUnit.id}-popup-pane`}\n\t\t\tpane=\"popupPane\"\n\t\t>\n\t\t\t<Tooltip>\n\t\t\t\t{orgUnit?.name} ({formattedData})\n\t\t\t</Tooltip>\n\t\t\t<Popup minWidth={80}>\n\t\t\t\t<h3 style={{ margin: 0 }}>{orgUnit?.name}</h3>\n\t\t\t\t<div>{dataItem?.displayName}</div>\n\t\t\t\t<div>{periods?.map((period) => period.name).join(\",\")}</div>\n\t\t\t\t<div>\n\t\t\t\t\t{i18n.t(\"Value\")}: {formattedData}\n\t\t\t\t</div>\n\t\t\t</Popup>\n\t\t</Pane>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Map/utils/map.ts"],"names":["legend"],"mappings":"AAMA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,SAAS,iBAAiB,GAAsB,OAAY;AAClE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,KAAK;AAErB;AAEO,SAAS,eAAe,GAAsB,cAAmB;AACvE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,YAAY;AAE5B;AAEO,SAAS,sBACf,SACA,OACS;AACT,MAAI,CAAC,OAAO;AACX,WAAO;AAAA,EACR;AACA,QAAM,SACL;AAAA,IACC,WAAW,CAAC;AAAA,IACZ,CAACA,YACAA,SAAQ,cAAc,SAASA,SAAQ,YAAY;AAAA,EACrD,KAAK,CAAC;AACP,SAAO,OAAO,QAAQ,OAAO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WAAW,CAAC;AACjD,QAAM,QAAQ,iBAAiB;AAE/B,QAAM,SAAS,CAAC;AAChB,MAAI,uBAAuB,WAAW,SAAS;AAC/C,WAAS,IAAI,GAAG,IAAI,gBAAgB,KAAK,OAAO;AAC/C,UAAM,KAAK,WAAW,oBAAoB;AAC1C,WAAO,KAAK;AAAA,MACX,YAAY,KAAK,MAAM,CAAC;AAAA,MACxB,UAAU,KAAK,MAAM,IAAI,KAAK;AAAA,MAC9B;AAAA,MACA,OAAO;AAAA,IACR,CAAC;AACD;AAAA,EACD;AAEA,SAAO,OAAO,QAAQ;AACvB","sourcesContent":["import type {\n\tLegend,\n\tOrganisationUnit,\n\tOrgUnitSelection,\n} from \"@hisptz/dhis2-utils\";\nimport { LeafletMouseEvent } from \"leaflet\";\nimport {\n\tcompact,\n\tfilter,\n\tfind,\n\tforEach,\n\tisEmpty,\n\tisString,\n\tsortBy,\n} from \"lodash\";\nimport {\n\tdefaultClasses,\n\tdefaultColorScaleName,\n\tgetColorPalette,\n} from \"./colors.js\";\n\nexport function highlightFeature(e: LeafletMouseEvent, style: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(style);\n\t// layer.bringToFront();\n}\n\nexport function resetHighlight(e: LeafletMouseEvent, defaultStyle: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(defaultStyle);\n\t// layer.bringToBack();\n}\n\nexport function getColorFromLegendSet(\n\tlegends: Legend[],\n\tvalue?: number,\n): string {\n\tif (!value) {\n\t\treturn \"\";\n\t}\n\tconst legend: any =\n\t\tfind(\n\t\t\tlegends ?? [],\n\t\t\t(legend: any) =>\n\t\t\t\tlegend?.startValue <= value && legend?.endValue >= value,\n\t\t) ?? {};\n\treturn legend.color ? legend.color : \"transparent\";\n}\n\nexport function getLegendCount(legend: any, data: any) {\n\tconst { startValue, endValue } = legend;\n\treturn filter(data, (d: any) => d.data >= startValue && d.data <= endValue)\n\t\t.length;\n}\n\nexport function getOrgUnitsSelection(orgUnitSelection: OrgUnitSelection) {\n\tconst orgUnits = [];\n\tif (orgUnitSelection.userOrgUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT\");\n\t}\n\n\tif (orgUnitSelection.userSubUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT_CHILDREN\");\n\t}\n\n\tif (orgUnitSelection.userSubX2Unit) {\n\t\torgUnits.push(\"USER_ORGUNIT_GRANDCHILDREN\");\n\t}\n\tif (!isEmpty(orgUnitSelection.levels)) {\n\t\tforEach(orgUnitSelection.levels, (level) =>\n\t\t\torgUnits.push(`LEVEL-${level}`),\n\t\t);\n\t}\n\n\treturn [\n\t\t...orgUnits,\n\t\t...(orgUnitSelection?.orgUnits?.map(\n\t\t\t(ou: OrganisationUnit) => `${ou.id}`,\n\t\t) ?? []),\n\t];\n}\n\nexport function sanitizeOrgUnits(metaData: any) {\n\tif (metaData) {\n\t\treturn metaData?.dimensions?.ou?.map((ouId: string) => ({\n\t\t\tid: ouId,\n\t\t\tname: metaData?.items[ouId]?.name,\n\t\t\tpath: metaData?.ouHierarchy?.[ouId],\n\t\t}));\n\t}\n\treturn [];\n}\n\nexport function toGeoJson(organisationUnits: any) {\n\treturn sortBy(organisationUnits, \"le\").map((ou: any) => {\n\t\ttry {\n\t\t\tconst coord = JSON.parse(ou.co);\n\t\t\tlet gpid = \"\";\n\t\t\tlet gppg = \"\";\n\t\t\tlet type = \"Point\";\n\n\t\t\tif (ou.ty === 2) {\n\t\t\t\ttype = \"Polygon\";\n\t\t\t\tif (ou.co.substring(0, 4) === \"[[[[\") {\n\t\t\t\t\ttype = \"MultiPolygon\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Grand parent\n\t\t\tif (isString(ou.pg) && ou.pg.length) {\n\t\t\t\tconst ids = compact(ou.pg.split(\"/\"));\n\n\t\t\t\t// Grand parent id\n\t\t\t\tif (ids.length >= 2) {\n\t\t\t\t\tgpid = ids[ids.length - 2] as string;\n\t\t\t\t}\n\n\t\t\t\t// Grand parent parent graph\n\t\t\t\tif (ids.length > 2) {\n\t\t\t\t\tgppg = \"/\" + ids.slice(0, ids.length - 2).join(\"/\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid: ou.id,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype,\n\t\t\t\t\tcoordinates: coord,\n\t\t\t\t},\n\t\t\t\tproperties: {\n\t\t\t\t\ttype,\n\t\t\t\t\tid: ou.id,\n\t\t\t\t\tname: ou.na,\n\t\t\t\t\thasCoordinatesDown: ou.hcd,\n\t\t\t\t\thasCoordinatesUp: ou.hcu,\n\t\t\t\t\tlevel: ou.le,\n\t\t\t\t\tgrandParentParentGraph: gppg,\n\t\t\t\t\tgrandParentId: gpid,\n\t\t\t\t\tparentGraph: ou.pg,\n\t\t\t\t\tparentId: ou.pi,\n\t\t\t\t\tparentName: ou.pn,\n\t\t\t\t\tdimensions: ou.dimensions,\n\t\t\t\t},\n\t\t\t};\n\t\t} catch (e) {\n\t\t\treturn {};\n\t\t}\n\t});\n}\n\nexport function sanitizeDate(startDate: string): string {\n\tif (startDate?.split(\"-\")?.[0]?.length < 4) {\n\t\treturn startDate?.split(\"-\")?.reverse()?.join(\"-\");\n\t}\n\treturn startDate;\n}\n\nexport function generateLegends(\n\tmaxValue: number,\n\tminValue: number,\n\t{ classesCount, colorClass }: { classesCount: number; colorClass: string },\n): Array<Legend> {\n\tconst count: number = classesCount ?? defaultClasses;\n\tconst color = colorClass ?? defaultColorScaleName;\n\n\tconst colorScale = [...getColorPalette(color, count)].reverse();\n\n\tconst maxLegendValue = 5 * Math.ceil(maxValue / 5);\n\tconst range = maxLegendValue / count;\n\n\tconst values = [];\n\tlet legendColorsIterator = colorScale.length - 1;\n\tfor (let i = 0; i < maxLegendValue; i += range) {\n\t\tconst id = colorScale[legendColorsIterator];\n\t\tvalues.push({\n\t\t\tstartValue: Math.floor(i),\n\t\t\tendValue: Math.floor(i + range),\n\t\t\tid,\n\t\t\tcolor: id,\n\t\t});\n\t\tlegendColorsIterator--;\n\t}\n\n\treturn values.reverse();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Map/utils/map.ts"],"names":["legend"],"mappings":"AAMA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,SAAS,iBAAiB,GAAsB,OAAY;AAClE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,KAAK;AAErB;AAEO,SAAS,eAAe,GAAsB,cAAmB;AACvE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,YAAY;AAE5B;AAEO,SAAS,sBACf,SACA,OACS;AACT,MAAI,CAAC,OAAO;AACX,WAAO;AAAA,EACR;AACA,QAAM,SACL;AAAA,IACC,WAAW,CAAC;AAAA,IACZ,CAACA,YACAA,SAAQ,cAAc,SAASA,SAAQ,YAAY;AAAA,EACrD,KAAK,CAAC;AACP,SAAO,OAAO,QAAQ,OAAO,QAAQ;AACtC;AAEO,SAAS,eAAe,QAAa,MAAW;AACtD,QAAM,EAAE,YAAY,SAAS,IAAI;AACjC,SAAO,OAAO,MAAM,CAAC,MAAW,EAAE,QAAQ,cAAc,EAAE,QAAQ,QAAQ,EACxE;AACH;AAEO,SAAS,qBAAqB,kBAAoC;AACxE,QAAM,WAAW,CAAC;AAClB,MAAI,iBAAiB,aAAa;AACjC,aAAS,KAAK,cAAc;AAAA,EAC7B;AAEA,MAAI,iBAAiB,aAAa;AACjC,aAAS,KAAK,uBAAuB;AAAA,EACtC;AAEA,MAAI,iBAAiB,eAAe;AACnC,aAAS,KAAK,4BAA4B;AAAA,EAC3C;AACA,MAAI,CAAC,QAAQ,iBAAiB,MAAM,GAAG;AACtC;AAAA,MAAQ,iBAAiB;AAAA,MAAQ,CAAC,UACjC,SAAS,KAAK,SAAS,KAAK,EAAE;AAAA,IAC/B;AAAA,EACD;AA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AA,UACvB,kBAAkB,GAAG;AAAA,UACrB,OAAO,GAAG;AAAA,UACV,wBAAwB;AAAA,UACxB,eAAe;AAAA,UACf,aAAa,GAAG;AAAA,UAChB,UAAU,GAAG;AAAA,UACb,YAAY,GAAG;AAAA,UACf,YAAY,GAAG;AAAA,QAChB;AAAA,MACD;AAAA,IACD,SAAS,GAAG;AACX,aAAO,CAAC;AAAA,IACT;AAAA,EACD,CAAC;AACF;AAEO,SAAS,aAAa,WAA2B;AACvD,MAAI,WAAW,MAAM,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG;AAC3C,WAAO,WAAW,MAAM,GAAG,GAAG,QAAQ,GAAG,KAAK,GAAG;AAAA,EAClD;AACA,SAAO;AACR;AAEO,SAAS,gBACf,UACA,UACA,EAAE,cAAc,WAAW,GACX;AAChB,QAAM,QAAgB,gBAAgB;AACtC,QAAM,QAAQ,cAAc;AAE5B,QAAM,aAAa,CAAC,GAAG,gBAAgB,OAAO,KAAK,CAAC,EAAE,QAAQ;AAE9D,QAAM,iBAAiB,IAAI,KAAK,KAAK,WAAW,CAAC;AACjD,QAAM,QAAQ,iBAAiB;AAE/B,QAAM,SAAS,CAAC;AAChB,MAAI,uBAAuB,WAAW,SAAS;AAC/C,WAAS,IAAI,GAAG,IAAI,gBAAgB,KAAK,OAAO;AAC/C,UAAM,KAAK,WAAW,oBAAoB;AAC1C,WAAO,KAAK;AAAA,MACX,YAAY,KAAK,MAAM,CAAC;AAAA,MACxB,UAAU,KAAK,MAAM,IAAI,KAAK;AAAA,MAC9B;AAAA,MACA,OAAO;AAAA,IACR,CAAC;AACD;AAAA,EACD;AAEA,SAAO,OAAO,QAAQ;AACvB","sourcesContent":["import type {\n\tLegend,\n\tOrganisationUnit,\n\tOrgUnitSelection,\n} from \"@hisptz/dhis2-utils\";\nimport { LeafletMouseEvent } from \"leaflet\";\nimport {\n\tcompact,\n\tfilter,\n\tfind,\n\tforEach,\n\tisEmpty,\n\tisString,\n\tsortBy,\n} from \"lodash\";\nimport {\n\tdefaultClasses,\n\tdefaultColorScaleName,\n\tgetColorPalette,\n} from \"./colors.js\";\n\nexport function highlightFeature(e: LeafletMouseEvent, style: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(style);\n\t// layer.bringToFront();\n}\n\nexport function resetHighlight(e: LeafletMouseEvent, defaultStyle: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(defaultStyle);\n\t// layer.bringToBack();\n}\n\nexport function getColorFromLegendSet(\n\tlegends: Legend[],\n\tvalue?: number,\n): string {\n\tif (!value) {\n\t\treturn \"transparent\";\n\t}\n\tconst legend: any =\n\t\tfind(\n\t\t\tlegends ?? [],\n\t\t\t(legend: any) =>\n\t\t\t\tlegend?.startValue <= value && legend?.endValue >= value,\n\t\t) ?? {};\n\treturn legend.color ? legend.color : \"transparent\";\n}\n\nexport function getLegendCount(legend: any, data: any) {\n\tconst { startValue, endValue } = legend;\n\treturn filter(data, (d: any) => d.data >= startValue && d.data <= endValue)\n\t\t.length;\n}\n\nexport function getOrgUnitsSelection(orgUnitSelection: OrgUnitSelection) {\n\tconst orgUnits = [];\n\tif (orgUnitSelection.userOrgUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT\");\n\t}\n\n\tif (orgUnitSelection.userSubUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT_CHILDREN\");\n\t}\n\n\tif (orgUnitSelection.userSubX2Unit) {\n\t\torgUnits.push(\"USER_ORGUNIT_GRANDCHILDREN\");\n\t}\n\tif (!isEmpty(orgUnitSelection.levels)) {\n\t\tforEach(orgUnitSelection.levels, (level) =>\n\t\t\torgUnits.push(`LEVEL-${level}`),\n\t\t);\n\t}\n\n\treturn [\n\t\t...orgUnits,\n\t\t...(orgUnitSelection?.orgUnits?.map(\n\t\t\t(ou: OrganisationUnit) => `${ou.id}`,\n\t\t) ?? []),\n\t];\n}\n\nexport function sanitizeOrgUnits(metaData: any) {\n\tif (metaData) {\n\t\treturn metaData?.dimensions?.ou?.map((ouId: string) => ({\n\t\t\tid: ouId,\n\t\t\tname: metaData?.items[ouId]?.name,\n\t\t\tpath: metaData?.ouHierarchy?.[ouId],\n\t\t}));\n\t}\n\treturn [];\n}\n\nexport function toGeoJson(organisationUnits: any) {\n\treturn sortBy(organisationUnits, \"le\").map((ou: any) => {\n\t\ttry {\n\t\t\tconst coord = JSON.parse(ou.co);\n\t\t\tlet gpid = \"\";\n\t\t\tlet gppg = \"\";\n\t\t\tlet type = \"Point\";\n\n\t\t\tif (ou.ty === 2) {\n\t\t\t\ttype = \"Polygon\";\n\t\t\t\tif (ou.co.substring(0, 4) === \"[[[[\") {\n\t\t\t\t\ttype = \"MultiPolygon\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Grand parent\n\t\t\tif (isString(ou.pg) && ou.pg.length) {\n\t\t\t\tconst ids = compact(ou.pg.split(\"/\"));\n\n\t\t\t\t// Grand parent id\n\t\t\t\tif (ids.length >= 2) {\n\t\t\t\t\tgpid = ids[ids.length - 2] as string;\n\t\t\t\t}\n\n\t\t\t\t// Grand parent parent graph\n\t\t\t\tif (ids.length > 2) {\n\t\t\t\t\tgppg = \"/\" + ids.slice(0, ids.length - 2).join(\"/\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid: ou.id,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype,\n\t\t\t\t\tcoordinates: coord,\n\t\t\t\t},\n\t\t\t\tproperties: {\n\t\t\t\t\ttype,\n\t\t\t\t\tid: ou.id,\n\t\t\t\t\tname: ou.na,\n\t\t\t\t\thasCoordinatesDown: ou.hcd,\n\t\t\t\t\thasCoordinatesUp: ou.hcu,\n\t\t\t\t\tlevel: ou.le,\n\t\t\t\t\tgrandParentParentGraph: gppg,\n\t\t\t\t\tgrandParentId: gpid,\n\t\t\t\t\tparentGraph: ou.pg,\n\t\t\t\t\tparentId: ou.pi,\n\t\t\t\t\tparentName: ou.pn,\n\t\t\t\t\tdimensions: ou.dimensions,\n\t\t\t\t},\n\t\t\t};\n\t\t} catch (e) {\n\t\t\treturn {};\n\t\t}\n\t});\n}\n\nexport function sanitizeDate(startDate: string): string {\n\tif (startDate?.split(\"-\")?.[0]?.length < 4) {\n\t\treturn startDate?.split(\"-\")?.reverse()?.join(\"-\");\n\t}\n\treturn startDate;\n}\n\nexport function generateLegends(\n\tmaxValue: number,\n\tminValue: number,\n\t{ classesCount, colorClass }: { classesCount: number; colorClass: string },\n): Array<Legend> {\n\tconst count: number = classesCount ?? defaultClasses;\n\tconst color = colorClass ?? defaultColorScaleName;\n\n\tconst colorScale = [...getColorPalette(color, count)].reverse();\n\n\tconst maxLegendValue = 5 * Math.ceil(maxValue / 5);\n\tconst range = maxLegendValue / count;\n\n\tconst values = [];\n\tlet legendColorsIterator = colorScale.length - 1;\n\tfor (let i = 0; i < maxLegendValue; i += range) {\n\t\tconst id = colorScale[legendColorsIterator];\n\t\tvalues.push({\n\t\t\tstartValue: Math.floor(i),\n\t\t\tendValue: Math.floor(i + range),\n\t\t\tid,\n\t\t\tcolor: id,\n\t\t});\n\t\tlegendColorsIterator--;\n\t}\n\n\treturn values.reverse();\n}\n"]}
|
|
@@ -9,7 +9,7 @@ function CustomTooltip({
|
|
|
9
9
|
const { dataItem, orgUnit, data } = dataObject ?? {};
|
|
10
10
|
const { periods } = useMapPeriods() ?? {};
|
|
11
11
|
const formatter = Intl.NumberFormat(navigator.language, {}).format;
|
|
12
|
-
const formattedData = formatter(data);
|
|
12
|
+
const formattedData = data ? formatter(data) : "";
|
|
13
13
|
return /* @__PURE__ */ jsxs(
|
|
14
14
|
Pane,
|
|
15
15
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx"],"names":[],"mappings":"AAuBG,SAIC,KAJD;AAvBH,OAAO,UAAU;AAEjB,SAAS,MAAM,OAAO,eAAe;AACrC,SAAS,qBAAqB;AAGf,SAAR,cAA+B;AAAA,EACrC,MAAM;AACP,GAEG;AACF,QAAM,EAAE,UAAU,SAAS,KAAK,IAAI,cAAc,CAAC;AACnD,QAAM,EAAE,QAAQ,IAAI,cAAc,KAAK,CAAC;AAExC,QAAM,YAAY,KAAK,aAAa,UAAU,UAAU,CAAC,CAAC,EAAE;AAE5D,QAAM,gBAAgB,UAAU,IAAc;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx"],"names":[],"mappings":"AAuBG,SAIC,KAJD;AAvBH,OAAO,UAAU;AAEjB,SAAS,MAAM,OAAO,eAAe;AACrC,SAAS,qBAAqB;AAGf,SAAR,cAA+B;AAAA,EACrC,MAAM;AACP,GAEG;AACF,QAAM,EAAE,UAAU,SAAS,KAAK,IAAI,cAAc,CAAC;AACnD,QAAM,EAAE,QAAQ,IAAI,cAAc,KAAK,CAAC;AAExC,QAAM,YAAY,KAAK,aAAa,UAAU,UAAU,CAAC,CAAC,EAAE;AAE5D,QAAM,gBAAgB,OAAO,UAAU,IAAc,IAAI;AAEzD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAM,GAAG,SAAS,WAAW,IAAI,QAAQ,EAAE;AAAA,MAC3C,MAAK;AAAA,MAEL;AAAA,6BAAC,WACC;AAAA,mBAAS;AAAA,UAAK;AAAA,UAAG;AAAA,UAAc;AAAA,WACjC;AAAA,QACA,qBAAC,SAAM,UAAU,IAChB;AAAA,8BAAC,QAAG,OAAO,EAAE,QAAQ,EAAE,GAAI,mBAAS,MAAK;AAAA,UACzC,oBAAC,SAAK,oBAAU,aAAY;AAAA,UAC5B,oBAAC,SAAK,mBAAS,IAAI,CAAC,WAAW,OAAO,IAAI,EAAE,KAAK,GAAG,GAAE;AAAA,UACtD,qBAAC,SACC;AAAA,iBAAK,EAAE,OAAO;AAAA,YAAE;AAAA,YAAG;AAAA,aACrB;AAAA,WACD;AAAA;AAAA;AAAA,EACD;AAEF","sourcesContent":["import i18n from \"@dhis2/d2-i18n\";\nimport React from \"react\";\nimport { Pane, Popup, Tooltip } from \"react-leaflet\";\nimport { useMapPeriods } from \"../../../../../MapProvider/hooks/index.js\";\nimport { ThematicLayerData } from \"../../../../interfaces/index.js\";\n\nexport default function CustomTooltip({\n\tdata: dataObject,\n}: {\n\tdata: ThematicLayerData;\n}) {\n\tconst { dataItem, orgUnit, data } = dataObject ?? {};\n\tconst { periods } = useMapPeriods() ?? {};\n\n\tconst formatter = Intl.NumberFormat(navigator.language, {}).format;\n\n\tconst formattedData = data ? formatter(data as number) : \"\";\n\n\treturn (\n\t\t<Pane\n\t\t\tname={`${dataItem.displayName}-${orgUnit.id}-popup-pane`}\n\t\t\tpane=\"popupPane\"\n\t\t>\n\t\t\t<Tooltip>\n\t\t\t\t{orgUnit?.name} ({formattedData})\n\t\t\t</Tooltip>\n\t\t\t<Popup minWidth={80}>\n\t\t\t\t<h3 style={{ margin: 0 }}>{orgUnit?.name}</h3>\n\t\t\t\t<div>{dataItem?.displayName}</div>\n\t\t\t\t<div>{periods?.map((period) => period.name).join(\",\")}</div>\n\t\t\t\t<div>\n\t\t\t\t\t{i18n.t(\"Value\")}: {formattedData}\n\t\t\t\t</div>\n\t\t\t</Popup>\n\t\t</Pane>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/Map/utils/map.ts"],"names":["legend"],"mappings":"AAMA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,SAAS,iBAAiB,GAAsB,OAAY;AAClE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,KAAK;AAErB;AAEO,SAAS,eAAe,GAAsB,cAAmB;AACvE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,YAAY;AAE5B;AAEO,SAAS,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SAAS,gBACf,UACA,UACA,EAAE,cAAc,WAAW,GACX;AAChB,QAAM,QAAgB,gBAAgB;AACtC,QAAM,QAAQ,cAAc;AAE5B,QAAM,aAAa,CAAC,GAAG,gBAAgB,OAAO,KAAK,CAAC,EAAE,QAAQ;AAE9D,QAAM,iBAAiB,IAAI,KAAK,KAAK,WAAW,CAAC;AACjD,QAAM,QAAQ,iBAAiB;AAE/B,QAAM,SAAS,CAAC;AAChB,MAAI,uBAAuB,WAAW,SAAS;AAC/C,WAAS,IAAI,GAAG,IAAI,gBAAgB,KAAK,OAAO;AAC/C,UAAM,KAAK,WAAW,oBAAoB;AAC1C,WAAO,KAAK;AAAA,MACX,YAAY,KAAK,MAAM,CAAC;AAAA,MACxB,UAAU,KAAK,MAAM,IAAI,KAAK;AAAA,MAC9B;AAAA,MACA,OAAO;AAAA,IACR,CAAC;AACD;AAAA,EACD;AAEA,SAAO,OAAO,QAAQ;AACvB","sourcesContent":["import type {\n\tLegend,\n\tOrganisationUnit,\n\tOrgUnitSelection,\n} from \"@hisptz/dhis2-utils\";\nimport { LeafletMouseEvent } from \"leaflet\";\nimport {\n\tcompact,\n\tfilter,\n\tfind,\n\tforEach,\n\tisEmpty,\n\tisString,\n\tsortBy,\n} from \"lodash\";\nimport {\n\tdefaultClasses,\n\tdefaultColorScaleName,\n\tgetColorPalette,\n} from \"./colors.js\";\n\nexport function highlightFeature(e: LeafletMouseEvent, style: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(style);\n\t// layer.bringToFront();\n}\n\nexport function resetHighlight(e: LeafletMouseEvent, defaultStyle: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(defaultStyle);\n\t// layer.bringToBack();\n}\n\nexport function getColorFromLegendSet(\n\tlegends: Legend[],\n\tvalue?: number,\n): string {\n\tif (!value) {\n\t\treturn \"\";\n\t}\n\tconst legend: any =\n\t\tfind(\n\t\t\tlegends ?? [],\n\t\t\t(legend: any) =>\n\t\t\t\tlegend?.startValue <= value && legend?.endValue >= value,\n\t\t) ?? {};\n\treturn legend.color ? legend.color : \"transparent\";\n}\n\nexport function getLegendCount(legend: any, data: any) {\n\tconst { startValue, endValue } = legend;\n\treturn filter(data, (d: any) => d.data >= startValue && d.data <= endValue)\n\t\t.length;\n}\n\nexport function getOrgUnitsSelection(orgUnitSelection: OrgUnitSelection) {\n\tconst orgUnits = [];\n\tif (orgUnitSelection.userOrgUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT\");\n\t}\n\n\tif (orgUnitSelection.userSubUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT_CHILDREN\");\n\t}\n\n\tif (orgUnitSelection.userSubX2Unit) {\n\t\torgUnits.push(\"USER_ORGUNIT_GRANDCHILDREN\");\n\t}\n\tif (!isEmpty(orgUnitSelection.levels)) {\n\t\tforEach(orgUnitSelection.levels, (level) =>\n\t\t\torgUnits.push(`LEVEL-${level}`),\n\t\t);\n\t}\n\n\treturn [\n\t\t...orgUnits,\n\t\t...(orgUnitSelection?.orgUnits?.map(\n\t\t\t(ou: OrganisationUnit) => `${ou.id}`,\n\t\t) ?? []),\n\t];\n}\n\nexport function sanitizeOrgUnits(metaData: any) {\n\tif (metaData) {\n\t\treturn metaData?.dimensions?.ou?.map((ouId: string) => ({\n\t\t\tid: ouId,\n\t\t\tname: metaData?.items[ouId]?.name,\n\t\t\tpath: metaData?.ouHierarchy?.[ouId],\n\t\t}));\n\t}\n\treturn [];\n}\n\nexport function toGeoJson(organisationUnits: any) {\n\treturn sortBy(organisationUnits, \"le\").map((ou: any) => {\n\t\ttry {\n\t\t\tconst coord = JSON.parse(ou.co);\n\t\t\tlet gpid = \"\";\n\t\t\tlet gppg = \"\";\n\t\t\tlet type = \"Point\";\n\n\t\t\tif (ou.ty === 2) {\n\t\t\t\ttype = \"Polygon\";\n\t\t\t\tif (ou.co.substring(0, 4) === \"[[[[\") {\n\t\t\t\t\ttype = \"MultiPolygon\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Grand parent\n\t\t\tif (isString(ou.pg) && ou.pg.length) {\n\t\t\t\tconst ids = compact(ou.pg.split(\"/\"));\n\n\t\t\t\t// Grand parent id\n\t\t\t\tif (ids.length >= 2) {\n\t\t\t\t\tgpid = ids[ids.length - 2] as string;\n\t\t\t\t}\n\n\t\t\t\t// Grand parent parent graph\n\t\t\t\tif (ids.length > 2) {\n\t\t\t\t\tgppg = \"/\" + ids.slice(0, ids.length - 2).join(\"/\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid: ou.id,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype,\n\t\t\t\t\tcoordinates: coord,\n\t\t\t\t},\n\t\t\t\tproperties: {\n\t\t\t\t\ttype,\n\t\t\t\t\tid: ou.id,\n\t\t\t\t\tname: ou.na,\n\t\t\t\t\thasCoordinatesDown: ou.hcd,\n\t\t\t\t\thasCoordinatesUp: ou.hcu,\n\t\t\t\t\tlevel: ou.le,\n\t\t\t\t\tgrandParentParentGraph: gppg,\n\t\t\t\t\tgrandParentId: gpid,\n\t\t\t\t\tparentGraph: ou.pg,\n\t\t\t\t\tparentId: ou.pi,\n\t\t\t\t\tparentName: ou.pn,\n\t\t\t\t\tdimensions: ou.dimensions,\n\t\t\t\t},\n\t\t\t};\n\t\t} catch (e) {\n\t\t\treturn {};\n\t\t}\n\t});\n}\n\nexport function sanitizeDate(startDate: string): string {\n\tif (startDate?.split(\"-\")?.[0]?.length < 4) {\n\t\treturn startDate?.split(\"-\")?.reverse()?.join(\"-\");\n\t}\n\treturn startDate;\n}\n\nexport function generateLegends(\n\tmaxValue: number,\n\tminValue: number,\n\t{ classesCount, colorClass }: { classesCount: number; colorClass: string },\n): Array<Legend> {\n\tconst count: number = classesCount ?? defaultClasses;\n\tconst color = colorClass ?? defaultColorScaleName;\n\n\tconst colorScale = [...getColorPalette(color, count)].reverse();\n\n\tconst maxLegendValue = 5 * Math.ceil(maxValue / 5);\n\tconst range = maxLegendValue / count;\n\n\tconst values = [];\n\tlet legendColorsIterator = colorScale.length - 1;\n\tfor (let i = 0; i < maxLegendValue; i += range) {\n\t\tconst id = colorScale[legendColorsIterator];\n\t\tvalues.push({\n\t\t\tstartValue: Math.floor(i),\n\t\t\tendValue: Math.floor(i + range),\n\t\t\tid,\n\t\t\tcolor: id,\n\t\t});\n\t\tlegendColorsIterator--;\n\t}\n\n\treturn values.reverse();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/Map/utils/map.ts"],"names":["legend"],"mappings":"AAMA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,SAAS,iBAAiB,GAAsB,OAAY;AAClE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,KAAK;AAErB;AAEO,SAAS,eAAe,GAAsB,cAAmB;AACvE,QAAM,QAAQ,EAAE;AAChB,QAAM,SAAS,YAAY;AAE5B;AAEO,SAAS,sBACf,SACA,OACS;AACT,MAAI,CAAC,OAAO;AACX,WAAO;AAAA,EACR;AACA,QAAM,SACL;AAAA,IACC,WAAW,CAAC;AAAA,IACZ,CAACA,YACAA,SAAQ,cAAc,SAASA,SAAQ,YAAY;AAAA,EACrD,KAAK,CAAC;AACP,SAAO,OAAO,QAAQ,OAAO,QAAQ;AACtC;AAEO,SAAS,eAAe,QAAa,MAAW;AACtD,QAAM,EAAE,YAAY,SAAS,IAAI;AACjC,SAAO,OAAO,MAAM,CAAC,MAAW,EAAE,QAAQ,cAAc,EAAE,QAAQ,QAAQ,EACxE;AACH;AAEO,SAAS,qBAAqB,kBAAoC;AACxE,QAAM,WAAW,CAAC;AAClB,MAAI,iBAAiB,aAAa;AACjC,aAAS,KAAK,cAAc;AAAA,EAC7B;AAEA,MAAI,iBAAiB,aAAa;AACjC,aAAS,KAAK,uBAAuB;AAAA,EACtC;AAEA,MAAI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QAAQ;AACvB","sourcesContent":["import type {\n\tLegend,\n\tOrganisationUnit,\n\tOrgUnitSelection,\n} from \"@hisptz/dhis2-utils\";\nimport { LeafletMouseEvent } from \"leaflet\";\nimport {\n\tcompact,\n\tfilter,\n\tfind,\n\tforEach,\n\tisEmpty,\n\tisString,\n\tsortBy,\n} from \"lodash\";\nimport {\n\tdefaultClasses,\n\tdefaultColorScaleName,\n\tgetColorPalette,\n} from \"./colors.js\";\n\nexport function highlightFeature(e: LeafletMouseEvent, style: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(style);\n\t// layer.bringToFront();\n}\n\nexport function resetHighlight(e: LeafletMouseEvent, defaultStyle: any) {\n\tconst layer = e.target;\n\tlayer.setStyle(defaultStyle);\n\t// layer.bringToBack();\n}\n\nexport function getColorFromLegendSet(\n\tlegends: Legend[],\n\tvalue?: number,\n): string {\n\tif (!value) {\n\t\treturn \"transparent\";\n\t}\n\tconst legend: any =\n\t\tfind(\n\t\t\tlegends ?? [],\n\t\t\t(legend: any) =>\n\t\t\t\tlegend?.startValue <= value && legend?.endValue >= value,\n\t\t) ?? {};\n\treturn legend.color ? legend.color : \"transparent\";\n}\n\nexport function getLegendCount(legend: any, data: any) {\n\tconst { startValue, endValue } = legend;\n\treturn filter(data, (d: any) => d.data >= startValue && d.data <= endValue)\n\t\t.length;\n}\n\nexport function getOrgUnitsSelection(orgUnitSelection: OrgUnitSelection) {\n\tconst orgUnits = [];\n\tif (orgUnitSelection.userOrgUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT\");\n\t}\n\n\tif (orgUnitSelection.userSubUnit) {\n\t\torgUnits.push(\"USER_ORGUNIT_CHILDREN\");\n\t}\n\n\tif (orgUnitSelection.userSubX2Unit) {\n\t\torgUnits.push(\"USER_ORGUNIT_GRANDCHILDREN\");\n\t}\n\tif (!isEmpty(orgUnitSelection.levels)) {\n\t\tforEach(orgUnitSelection.levels, (level) =>\n\t\t\torgUnits.push(`LEVEL-${level}`),\n\t\t);\n\t}\n\n\treturn [\n\t\t...orgUnits,\n\t\t...(orgUnitSelection?.orgUnits?.map(\n\t\t\t(ou: OrganisationUnit) => `${ou.id}`,\n\t\t) ?? []),\n\t];\n}\n\nexport function sanitizeOrgUnits(metaData: any) {\n\tif (metaData) {\n\t\treturn metaData?.dimensions?.ou?.map((ouId: string) => ({\n\t\t\tid: ouId,\n\t\t\tname: metaData?.items[ouId]?.name,\n\t\t\tpath: metaData?.ouHierarchy?.[ouId],\n\t\t}));\n\t}\n\treturn [];\n}\n\nexport function toGeoJson(organisationUnits: any) {\n\treturn sortBy(organisationUnits, \"le\").map((ou: any) => {\n\t\ttry {\n\t\t\tconst coord = JSON.parse(ou.co);\n\t\t\tlet gpid = \"\";\n\t\t\tlet gppg = \"\";\n\t\t\tlet type = \"Point\";\n\n\t\t\tif (ou.ty === 2) {\n\t\t\t\ttype = \"Polygon\";\n\t\t\t\tif (ou.co.substring(0, 4) === \"[[[[\") {\n\t\t\t\t\ttype = \"MultiPolygon\";\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Grand parent\n\t\t\tif (isString(ou.pg) && ou.pg.length) {\n\t\t\t\tconst ids = compact(ou.pg.split(\"/\"));\n\n\t\t\t\t// Grand parent id\n\t\t\t\tif (ids.length >= 2) {\n\t\t\t\t\tgpid = ids[ids.length - 2] as string;\n\t\t\t\t}\n\n\t\t\t\t// Grand parent parent graph\n\t\t\t\tif (ids.length > 2) {\n\t\t\t\t\tgppg = \"/\" + ids.slice(0, ids.length - 2).join(\"/\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttype: \"Feature\",\n\t\t\t\tid: ou.id,\n\t\t\t\tgeometry: {\n\t\t\t\t\ttype,\n\t\t\t\t\tcoordinates: coord,\n\t\t\t\t},\n\t\t\t\tproperties: {\n\t\t\t\t\ttype,\n\t\t\t\t\tid: ou.id,\n\t\t\t\t\tname: ou.na,\n\t\t\t\t\thasCoordinatesDown: ou.hcd,\n\t\t\t\t\thasCoordinatesUp: ou.hcu,\n\t\t\t\t\tlevel: ou.le,\n\t\t\t\t\tgrandParentParentGraph: gppg,\n\t\t\t\t\tgrandParentId: gpid,\n\t\t\t\t\tparentGraph: ou.pg,\n\t\t\t\t\tparentId: ou.pi,\n\t\t\t\t\tparentName: ou.pn,\n\t\t\t\t\tdimensions: ou.dimensions,\n\t\t\t\t},\n\t\t\t};\n\t\t} catch (e) {\n\t\t\treturn {};\n\t\t}\n\t});\n}\n\nexport function sanitizeDate(startDate: string): string {\n\tif (startDate?.split(\"-\")?.[0]?.length < 4) {\n\t\treturn startDate?.split(\"-\")?.reverse()?.join(\"-\");\n\t}\n\treturn startDate;\n}\n\nexport function generateLegends(\n\tmaxValue: number,\n\tminValue: number,\n\t{ classesCount, colorClass }: { classesCount: number; colorClass: string },\n): Array<Legend> {\n\tconst count: number = classesCount ?? defaultClasses;\n\tconst color = colorClass ?? defaultColorScaleName;\n\n\tconst colorScale = [...getColorPalette(color, count)].reverse();\n\n\tconst maxLegendValue = 5 * Math.ceil(maxValue / 5);\n\tconst range = maxLegendValue / count;\n\n\tconst values = [];\n\tlet legendColorsIterator = colorScale.length - 1;\n\tfor (let i = 0; i < maxLegendValue; i += range) {\n\t\tconst id = colorScale[legendColorsIterator];\n\t\tvalues.push({\n\t\t\tstartValue: Math.floor(i),\n\t\t\tendValue: Math.floor(i + range),\n\t\t\tid,\n\t\t\tcolor: id,\n\t\t});\n\t\tlegendColorsIterator--;\n\t}\n\n\treturn values.reverse();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hisptz/dhis2-analytics",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"react-query": "^3.39.3",
|
|
56
56
|
"react-spring": "^9.6.1",
|
|
57
57
|
"screenfull": "^6.0.2",
|
|
58
|
-
"@hisptz/dhis2-ui": "2.0.
|
|
59
|
-
"@hisptz/dhis2-utils": "2.0.
|
|
58
|
+
"@hisptz/dhis2-ui": "2.0.13",
|
|
59
|
+
"@hisptz/dhis2-utils": "2.0.5"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@dhis2/app-runtime": "^3.10.2",
|