@hisptz/dhis2-analytics 1.0.5 → 1.0.7

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.
Files changed (367) hide show
  1. package/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +253 -0
  2. package/build/cjs/components/ChartAnalytics/ChartAnalytics.test.js +51 -0
  3. package/build/cjs/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +48 -0
  4. package/build/cjs/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +34 -0
  5. package/build/cjs/components/ChartAnalytics/components/DownloadMenu/index.js +67 -0
  6. package/build/cjs/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
  7. package/{src → build/cjs}/components/ChartAnalytics/data/column-data.json +0 -0
  8. package/{src → build/cjs}/components/ChartAnalytics/data/complex-multi-series-data.json +0 -0
  9. package/{src → build/cjs}/components/ChartAnalytics/data/multi-series-data.json +0 -0
  10. package/{src → build/cjs}/components/ChartAnalytics/data/pie-data.json +0 -0
  11. package/{src → build/cjs}/components/ChartAnalytics/data/stacked-chart-data.json +0 -0
  12. package/build/cjs/components/ChartAnalytics/hooks/useChart.js +38 -0
  13. package/build/cjs/components/ChartAnalytics/index.js +69 -0
  14. package/build/cjs/components/ChartAnalytics/models/column.js +53 -0
  15. package/build/cjs/components/ChartAnalytics/models/index.js +102 -0
  16. package/build/cjs/components/ChartAnalytics/models/line.js +35 -0
  17. package/build/cjs/components/ChartAnalytics/models/multi-series.js +111 -0
  18. package/build/cjs/components/ChartAnalytics/models/pie.js +53 -0
  19. package/build/cjs/components/ChartAnalytics/services/export.js +50 -0
  20. package/{src → build/cjs}/components/ChartAnalytics/styles/custom-highchart.css +0 -0
  21. package/build/cjs/components/ChartAnalytics/types/props.js +1 -0
  22. package/build/cjs/components/ChartAnalytics/utils/chart.js +133 -0
  23. package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +45 -0
  24. package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.test.js +13 -0
  25. package/build/cjs/components/CircularProgressDashboard/index.js +49 -0
  26. package/build/cjs/components/CircularProgressDashboard/types/props.js +1 -0
  27. package/build/cjs/components/Map/Map.stories.js +352 -0
  28. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +32 -0
  29. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +40 -0
  30. package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/index.js +458 -0
  31. package/build/cjs/components/Map/components/MapArea/index.js +101 -0
  32. package/build/cjs/components/Map/components/MapArea/interfaces/index.js +1 -0
  33. package/build/cjs/components/Map/components/MapControls/components/CustomControl/index.js +32 -0
  34. package/build/cjs/components/Map/components/MapControls/components/DownloadControl/index.js +25 -0
  35. package/build/cjs/components/Map/components/MapControls/components/FullscreenControl/index.js +13 -0
  36. package/build/cjs/components/Map/components/MapControls/index.js +42 -0
  37. package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +13 -0
  38. package/build/cjs/components/Map/components/MapLayer/components/BoundaryLayer/index.js +51 -0
  39. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +106 -0
  40. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +379 -0
  41. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +36 -0
  42. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +200 -0
  43. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
  44. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +14 -0
  45. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +412 -0
  46. package/build/cjs/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +124 -0
  47. package/{src → build/cjs}/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +0 -0
  48. package/build/cjs/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +26 -0
  49. package/build/cjs/components/Map/components/MapLayer/components/LegendArea/index.js +181 -0
  50. package/build/cjs/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +86 -0
  51. package/build/cjs/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +14 -0
  52. package/build/cjs/components/Map/components/MapLayer/components/PointLayer/index.js +46 -0
  53. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +57 -0
  54. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js +145 -0
  55. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +43 -0
  56. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +56 -0
  57. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +61 -0
  58. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +43 -0
  59. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +35 -0
  60. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +15 -0
  61. package/build/cjs/components/Map/components/MapLayer/components/ThematicLayer/index.js +57 -0
  62. package/{src → build/cjs}/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +0 -0
  63. package/build/cjs/components/Map/components/MapLayer/index.js +40 -0
  64. package/build/cjs/components/Map/components/MapLayer/interfaces/index.js +8 -0
  65. package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +389 -0
  66. package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/index.js +116 -0
  67. package/build/cjs/components/Map/components/MapProvider/hooks/index.js +19 -0
  68. package/build/cjs/components/Map/components/MapProvider/index.js +121 -0
  69. package/build/cjs/components/Map/components/MapUpdater/index.js +24 -0
  70. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +32 -0
  71. package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +40 -0
  72. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +40 -0
  73. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js +428 -0
  74. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +63 -0
  75. package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +0 -0
  76. package/{src → build/cjs}/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +0 -0
  77. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +72 -0
  78. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +71 -0
  79. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +47 -0
  80. package/build/cjs/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +79 -0
  81. package/build/cjs/components/Map/components/ThematicLayerConfiguration/index.js +265 -0
  82. package/build/cjs/components/Map/constants/colors.js +428 -0
  83. package/build/cjs/components/Map/constants/legendSet.js +22 -0
  84. package/build/cjs/components/Map/hooks/map.js +52 -0
  85. package/build/cjs/components/Map/index.js +108 -0
  86. package/build/cjs/components/Map/interfaces/index.js +1 -0
  87. package/build/cjs/components/Map/state/index.js +23 -0
  88. package/build/cjs/components/Map/utils/colors.js +78 -0
  89. package/build/cjs/components/Map/utils/helpers.js +25 -0
  90. package/build/cjs/components/Map/utils/map.js +161 -0
  91. package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +127 -0
  92. package/build/cjs/components/SingleValueContainer/SingleValueContainer.test.js +23 -0
  93. package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +54 -0
  94. package/build/cjs/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +24 -0
  95. package/build/cjs/components/SingleValueContainer/index.js +43 -0
  96. package/{src → build/cjs}/components/SingleValueContainer/styles/SingleValueContainer.module.css +0 -0
  97. package/build/cjs/components/SingleValueContainer/types/props.js +1 -0
  98. package/{src → build/cjs}/data/map.json +0 -0
  99. package/build/cjs/dataProviders/map.js +31 -0
  100. package/build/cjs/index.js +49 -0
  101. package/build/cjs/locales/en/translations.json +128 -0
  102. package/build/cjs/locales/index.js +22 -0
  103. package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +235 -0
  104. package/build/es/components/ChartAnalytics/ChartAnalytics.test.js +46 -0
  105. package/build/es/components/ChartAnalytics/components/DownloadMenu/components/Menu.js +41 -0
  106. package/build/es/components/ChartAnalytics/components/DownloadMenu/constants/menu.js +26 -0
  107. package/build/es/components/ChartAnalytics/components/DownloadMenu/index.js +58 -0
  108. package/build/es/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.js +1 -0
  109. package/build/es/components/ChartAnalytics/data/column-data.json +210 -0
  110. package/build/es/components/ChartAnalytics/data/complex-multi-series-data.json +124 -0
  111. package/build/es/components/ChartAnalytics/data/multi-series-data.json +536 -0
  112. package/build/es/components/ChartAnalytics/data/pie-data.json +115 -0
  113. package/build/es/components/ChartAnalytics/data/stacked-chart-data.json +415 -0
  114. package/build/es/components/ChartAnalytics/hooks/useChart.js +32 -0
  115. package/build/es/components/ChartAnalytics/index.js +40 -0
  116. package/build/es/components/ChartAnalytics/models/column.js +45 -0
  117. package/build/es/components/ChartAnalytics/models/index.js +95 -0
  118. package/build/es/components/ChartAnalytics/models/line.js +28 -0
  119. package/build/es/components/ChartAnalytics/models/multi-series.js +104 -0
  120. package/build/es/components/ChartAnalytics/models/pie.js +46 -0
  121. package/build/es/components/ChartAnalytics/services/export.js +36 -0
  122. package/build/es/components/ChartAnalytics/styles/custom-highchart.css +48 -0
  123. package/build/es/components/ChartAnalytics/types/props.js +1 -0
  124. package/build/es/components/ChartAnalytics/utils/chart.js +122 -0
  125. package/{src/components/CircularProgressDashboard/CircularProgressIndicator.stories.tsx → build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js} +9 -16
  126. package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.test.js +10 -0
  127. package/build/es/components/CircularProgressDashboard/index.js +41 -0
  128. package/build/es/components/CircularProgressDashboard/types/props.js +1 -0
  129. package/build/es/components/Map/Map.stories.js +334 -0
  130. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +23 -0
  131. package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +31 -0
  132. package/build/es/components/Map/components/EarthEngineLayerConfiguration/index.js +448 -0
  133. package/build/es/components/Map/components/MapArea/index.js +91 -0
  134. package/build/es/components/Map/components/MapArea/interfaces/index.js +1 -0
  135. package/build/es/components/Map/components/MapControls/components/CustomControl/index.js +25 -0
  136. package/build/es/components/Map/components/MapControls/components/DownloadControl/index.js +18 -0
  137. package/build/es/components/Map/components/MapControls/components/FullscreenControl/index.js +6 -0
  138. package/build/es/components/Map/components/MapControls/index.js +35 -0
  139. package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.js +7 -0
  140. package/build/es/components/Map/components/MapLayer/components/BoundaryLayer/index.js +41 -0
  141. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.js +95 -0
  142. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.js +369 -0
  143. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.js +29 -0
  144. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/index.js +191 -0
  145. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.js +1 -0
  146. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +14 -0
  147. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.js +403 -0
  148. package/build/es/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.js +111 -0
  149. package/build/es/components/Map/components/MapLayer/components/LegendArea/LegendArea.module.css +12 -0
  150. package/build/es/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.js +19 -0
  151. package/build/es/components/Map/components/MapLayer/components/LegendArea/index.js +172 -0
  152. package/build/es/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.js +76 -0
  153. package/build/es/components/Map/components/MapLayer/components/PointLayer/hooks/index.js +8 -0
  154. package/build/es/components/Map/components/MapLayer/components/PointLayer/index.js +39 -0
  155. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.js +49 -0
  156. package/{src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.tsx → build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.js} +57 -74
  157. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.js +33 -0
  158. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.js +47 -0
  159. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.js +50 -0
  160. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.js +36 -0
  161. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.js +28 -0
  162. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.js +9 -0
  163. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/index.js +50 -0
  164. package/build/es/components/Map/components/MapLayer/components/ThematicLayer/styles/legends.css +62 -0
  165. package/build/es/components/Map/components/MapLayer/index.js +33 -0
  166. package/build/es/components/Map/components/MapLayer/interfaces/index.js +1 -0
  167. package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +381 -0
  168. package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/index.js +107 -0
  169. package/{src/components/Map/components/MapProvider/hooks/index.ts → build/es/components/Map/components/MapProvider/hooks/index.js} +3 -6
  170. package/build/es/components/Map/components/MapProvider/index.js +112 -0
  171. package/build/es/components/Map/components/MapUpdater/index.js +17 -0
  172. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +23 -0
  173. package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +31 -0
  174. package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.js +33 -0
  175. package/{src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.ts → build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.js} +46 -59
  176. package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.js +53 -0
  177. package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScale.module.css +15 -0
  178. package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/styles/ColorScaleSelect.module.css +12 -0
  179. package/build/es/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.js +56 -0
  180. package/build/es/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.js +64 -0
  181. package/build/es/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.js +38 -0
  182. package/build/es/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.js +70 -0
  183. package/build/es/components/Map/components/ThematicLayerConfiguration/index.js +254 -0
  184. package/{src/components/Map/constants/colors.ts → build/es/components/Map/constants/colors.js} +46 -59
  185. package/build/es/components/Map/constants/legendSet.js +15 -0
  186. package/build/es/components/Map/hooks/map.js +44 -0
  187. package/build/es/components/Map/index.js +51 -0
  188. package/build/es/components/Map/interfaces/index.js +1 -0
  189. package/build/es/components/Map/state/index.js +14 -0
  190. package/build/es/components/Map/utils/colors.js +61 -0
  191. package/build/es/components/Map/utils/helpers.js +14 -0
  192. package/build/es/components/Map/utils/map.js +147 -0
  193. package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +115 -0
  194. package/build/es/components/SingleValueContainer/SingleValueContainer.test.js +20 -0
  195. package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.js +47 -0
  196. package/build/es/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.js +17 -0
  197. package/build/es/components/SingleValueContainer/index.js +29 -0
  198. package/build/es/components/SingleValueContainer/styles/SingleValueContainer.module.css +39 -0
  199. package/build/es/components/SingleValueContainer/types/props.js +1 -0
  200. package/build/es/data/map.json +5984 -0
  201. package/build/es/dataProviders/map.js +24 -0
  202. package/build/es/index.js +5 -0
  203. package/build/es/locales/en/translations.json +128 -0
  204. package/build/es/locales/index.js +13 -0
  205. package/build/types/components/ChartAnalytics/components/DownloadMenu/components/Menu.d.ts +8 -0
  206. package/build/types/components/ChartAnalytics/components/DownloadMenu/constants/menu.d.ts +7 -0
  207. package/build/types/components/ChartAnalytics/components/DownloadMenu/index.d.ts +9 -0
  208. package/{src/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.ts → build/types/components/ChartAnalytics/components/DownloadMenu/interfaces/menu.d.ts} +0 -0
  209. package/build/types/components/ChartAnalytics/hooks/useChart.d.ts +11 -0
  210. package/build/types/components/ChartAnalytics/index.d.ts +9 -0
  211. package/build/types/components/ChartAnalytics/models/column.d.ts +12 -0
  212. package/build/types/components/ChartAnalytics/models/index.d.ts +17 -0
  213. package/build/types/components/ChartAnalytics/models/line.d.ts +8 -0
  214. package/build/types/components/ChartAnalytics/models/multi-series.d.ts +9 -0
  215. package/build/types/components/ChartAnalytics/models/pie.d.ts +8 -0
  216. package/build/types/components/ChartAnalytics/services/export.d.ts +8 -0
  217. package/build/types/components/ChartAnalytics/types/props.d.ts +43 -0
  218. package/build/types/components/ChartAnalytics/utils/chart.d.ts +15 -0
  219. package/build/types/components/CircularProgressDashboard/index.d.ts +3 -0
  220. package/build/types/components/CircularProgressDashboard/types/props.d.ts +17 -0
  221. package/build/types/components/Map/components/EarthEngineLayerConfiguration/index.d.ts +17 -0
  222. package/build/types/components/Map/components/MapArea/index.d.ts +5 -0
  223. package/build/types/components/Map/components/MapArea/interfaces/index.d.ts +30 -0
  224. package/build/types/components/Map/components/MapControls/components/CustomControl/index.d.ts +7 -0
  225. package/build/types/components/Map/components/MapControls/components/DownloadControl/index.d.ts +8 -0
  226. package/build/types/components/Map/components/MapControls/components/FullscreenControl/index.d.ts +5 -0
  227. package/build/types/components/Map/components/MapControls/index.d.ts +6 -0
  228. package/build/types/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.d.ts +1 -0
  229. package/build/types/components/Map/components/MapLayer/components/BoundaryLayer/index.d.ts +15 -0
  230. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.d.ts +17 -0
  231. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.d.ts +4 -0
  232. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.d.ts +9 -0
  233. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/index.d.ts +4 -0
  234. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.d.ts +58 -0
  235. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.d.ts +1 -0
  236. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.d.ts +55 -0
  237. package/build/types/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.d.ts +20 -0
  238. package/build/types/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.d.ts +6 -0
  239. package/build/types/components/Map/components/MapLayer/components/LegendArea/index.d.ts +9 -0
  240. package/build/types/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.d.ts +3 -0
  241. package/build/types/components/Map/components/MapLayer/components/PointLayer/hooks/index.d.ts +2 -0
  242. package/build/types/components/Map/components/MapLayer/components/PointLayer/index.d.ts +2 -0
  243. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.d.ts +13 -0
  244. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubbles.d.ts +10 -0
  245. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.d.ts +16 -0
  246. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.d.ts +12 -0
  247. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.d.ts +21 -0
  248. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.d.ts +12 -0
  249. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.d.ts +5 -0
  250. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.d.ts +2 -0
  251. package/build/types/components/Map/components/MapLayer/components/ThematicLayer/index.d.ts +5 -0
  252. package/build/types/components/Map/components/MapLayer/index.d.ts +6 -0
  253. package/build/types/components/Map/components/MapLayer/interfaces/index.d.ts +123 -0
  254. package/build/types/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.d.ts +9 -0
  255. package/build/types/components/Map/components/MapProvider/components/MapLayerProvider/index.d.ts +6 -0
  256. package/build/types/components/Map/components/MapProvider/hooks/index.d.ts +15 -0
  257. package/build/types/components/Map/components/MapProvider/index.d.ts +3 -0
  258. package/build/types/components/Map/components/MapUpdater/index.d.ts +5 -0
  259. package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.d.ts +8 -0
  260. package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/constants/colors.d.ts +419 -0
  261. package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.d.ts +9 -0
  262. package/build/types/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.d.ts +11 -0
  263. package/build/types/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.d.ts +2 -0
  264. package/build/types/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.d.ts +8 -0
  265. package/build/types/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.d.ts +9 -0
  266. package/build/types/components/Map/components/ThematicLayerConfiguration/index.d.ts +18 -0
  267. package/build/types/components/Map/constants/colors.d.ts +419 -0
  268. package/build/types/components/Map/constants/legendSet.d.ts +7 -0
  269. package/build/types/components/Map/hooks/map.d.ts +9 -0
  270. package/build/types/components/Map/index.d.ts +8 -0
  271. package/build/types/components/Map/interfaces/index.d.ts +65 -0
  272. package/build/types/components/Map/state/index.d.ts +20 -0
  273. package/build/types/components/Map/utils/colors.d.ts +12 -0
  274. package/build/types/components/Map/utils/helpers.d.ts +6 -0
  275. package/build/types/components/Map/utils/map.d.ts +40 -0
  276. package/build/types/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.d.ts +8 -0
  277. package/build/types/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.d.ts +2 -0
  278. package/build/types/components/SingleValueContainer/index.d.ts +5 -0
  279. package/build/types/components/SingleValueContainer/types/props.d.ts +15 -0
  280. package/build/types/dataProviders/map.d.ts +4 -0
  281. package/{src/index.ts → build/types/index.d.ts} +0 -0
  282. package/package.json +26 -5
  283. package/d2.config.js +0 -8
  284. package/i18n/en.pot +0 -409
  285. package/src/components/ChartAnalytics/ChartAnalytics.stories.tsx +0 -250
  286. package/src/components/ChartAnalytics/ChartAnalytics.test.tsx +0 -51
  287. package/src/components/ChartAnalytics/components/DownloadMenu/components/Menu.tsx +0 -48
  288. package/src/components/ChartAnalytics/components/DownloadMenu/constants/menu.ts +0 -38
  289. package/src/components/ChartAnalytics/components/DownloadMenu/index.tsx +0 -67
  290. package/src/components/ChartAnalytics/hooks/useChart.ts +0 -35
  291. package/src/components/ChartAnalytics/index.tsx +0 -23
  292. package/src/components/ChartAnalytics/models/column.ts +0 -50
  293. package/src/components/ChartAnalytics/models/index.ts +0 -78
  294. package/src/components/ChartAnalytics/models/line.ts +0 -31
  295. package/src/components/ChartAnalytics/models/multi-series.ts +0 -115
  296. package/src/components/ChartAnalytics/models/pie.ts +0 -54
  297. package/src/components/ChartAnalytics/services/export.ts +0 -38
  298. package/src/components/ChartAnalytics/types/props.tsx +0 -48
  299. package/src/components/ChartAnalytics/utils/chart.ts +0 -123
  300. package/src/components/CircularProgressDashboard/CircularProgressIndicator.test.tsx +0 -9
  301. package/src/components/CircularProgressDashboard/index.tsx +0 -35
  302. package/src/components/CircularProgressDashboard/types/props.tsx +0 -17
  303. package/src/components/Map/Map.stories.tsx +0 -339
  304. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.tsx +0 -28
  305. package/src/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.tsx +0 -34
  306. package/src/components/Map/components/EarthEngineLayerConfiguration/index.tsx +0 -412
  307. package/src/components/Map/components/MapArea/index.tsx +0 -83
  308. package/src/components/Map/components/MapArea/interfaces/index.ts +0 -39
  309. package/src/components/Map/components/MapControls/components/CustomControl/index.tsx +0 -24
  310. package/src/components/Map/components/MapControls/components/DownloadControl/index.tsx +0 -10
  311. package/src/components/Map/components/MapControls/components/FullscreenControl/index.tsx +0 -7
  312. package/src/components/Map/components/MapControls/index.tsx +0 -24
  313. package/src/components/Map/components/MapLayer/components/BoundaryLayer/hooks/useBoundaryData.ts +0 -7
  314. package/src/components/Map/components/MapLayer/components/BoundaryLayer/index.tsx +0 -55
  315. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx +0 -76
  316. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/constants/index.ts +0 -430
  317. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/hooks/index.ts +0 -34
  318. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/index.tsx +0 -185
  319. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/interfaces/index.ts +0 -56
  320. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/api.js +0 -34233
  321. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/services/engine.ts +0 -431
  322. package/src/components/Map/components/MapLayer/components/GoogleEngineLayer/utils/index.ts +0 -105
  323. package/src/components/Map/components/MapLayer/components/LegendArea/components/LegendCardHeader/index.tsx +0 -17
  324. package/src/components/Map/components/MapLayer/components/LegendArea/index.tsx +0 -168
  325. package/src/components/Map/components/MapLayer/components/PointLayer/components/PointLegend/index.tsx +0 -44
  326. package/src/components/Map/components/MapLayer/components/PointLayer/hooks/index.ts +0 -8
  327. package/src/components/Map/components/MapLayer/components/PointLayer/index.tsx +0 -36
  328. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/components/Bubble.tsx +0 -48
  329. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/components/BubbleLegend/index.tsx +0 -39
  330. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Bubble/index.tsx +0 -57
  331. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/components/ChoroplethLegend.tsx +0 -43
  332. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/Choropleth/index.tsx +0 -38
  333. package/src/components/Map/components/MapLayer/components/ThematicLayer/components/CustomTooltip/index.tsx +0 -26
  334. package/src/components/Map/components/MapLayer/components/ThematicLayer/hooks/config.ts +0 -10
  335. package/src/components/Map/components/MapLayer/components/ThematicLayer/index.tsx +0 -46
  336. package/src/components/Map/components/MapLayer/index.tsx +0 -32
  337. package/src/components/Map/components/MapLayer/interfaces/index.ts +0 -139
  338. package/src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx +0 -359
  339. package/src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx +0 -105
  340. package/src/components/Map/components/MapProvider/index.tsx +0 -93
  341. package/src/components/Map/components/MapUpdater/index.tsx +0 -8
  342. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.tsx +0 -28
  343. package/src/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.tsx +0 -34
  344. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/components/ColorScale/index.tsx +0 -24
  345. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/index.tsx +0 -50
  346. package/src/components/Map/components/ThematicLayerConfiguration/components/ColorScaleSelect/utils/colors.ts +0 -91
  347. package/src/components/Map/components/ThematicLayerConfiguration/components/CustomLegend/index.tsx +0 -45
  348. package/src/components/Map/components/ThematicLayerConfiguration/components/IndicatorSelectorModal/index.tsx +0 -47
  349. package/src/components/Map/components/ThematicLayerConfiguration/components/LegendSetSelector/index.tsx +0 -57
  350. package/src/components/Map/components/ThematicLayerConfiguration/index.tsx +0 -248
  351. package/src/components/Map/constants/legendSet.ts +0 -19
  352. package/src/components/Map/hooks/map.ts +0 -47
  353. package/src/components/Map/index.tsx +0 -65
  354. package/src/components/Map/interfaces/index.ts +0 -57
  355. package/src/components/Map/state/index.tsx +0 -31
  356. package/src/components/Map/utils/colors.ts +0 -95
  357. package/src/components/Map/utils/helpers.ts +0 -15
  358. package/src/components/Map/utils/map.ts +0 -150
  359. package/src/components/SingleValueContainer/SingleValueContainer.stories.tsx +0 -146
  360. package/src/components/SingleValueContainer/SingleValueContainer.test.tsx +0 -24
  361. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValueItem.tsx +0 -46
  362. package/src/components/SingleValueContainer/components/SingleValueItem/SingleValuePercentage.tsx +0 -12
  363. package/src/components/SingleValueContainer/index.tsx +0 -30
  364. package/src/components/SingleValueContainer/types/props.tsx +0 -16
  365. package/src/dataProviders/map.tsx +0 -24
  366. package/src/index.test.ts +0 -7
  367. package/tsconfig.json +0 -45
@@ -1,412 +0,0 @@
1
- import {EarthEngineLayerConfig} from "../MapLayer/interfaces";
2
- import {Controller, FormProvider, useForm, useFormContext, UseFormReturn, useWatch} from "react-hook-form";
3
- import React, {useEffect, useMemo} from "react";
4
- import {EARTH_ENGINE_LAYERS, SUPPORTED_EARTH_ENGINE_LAYERS} from "../MapLayer/components/GoogleEngineLayer/constants";
5
- import {capitalize, filter, find, head, isEmpty} from "lodash";
6
- import i18n from "@dhis2/d2-i18n";
7
- import {
8
- Button,
9
- ButtonStrip,
10
- CenteredContent,
11
- CircularLoader,
12
- Field,
13
- InputField,
14
- Modal,
15
- ModalActions,
16
- ModalContent,
17
- ModalTitle,
18
- MultiSelectField,
19
- MultiSelectOption,
20
- SingleSelectField,
21
- SingleSelectOption,
22
- } from "@dhis2/ui";
23
- import {useGoogleEngineToken} from "../MapLayer/components/GoogleEngineLayer/hooks";
24
- import {EarthEngineOptions} from "../MapLayer/components/GoogleEngineLayer/interfaces";
25
- import {EarthEngine} from "../MapLayer/components/GoogleEngineLayer/services/engine";
26
- import {useQuery} from "react-query";
27
- import ColorScaleSelect from "../ThematicLayerConfiguration/components/ColorScaleSelect";
28
- import {
29
- defaultClasses,
30
- defaultColorScaleName,
31
- getColorClasses,
32
- getColorPalette,
33
- getColorScale
34
- } from "../../utils/colors";
35
-
36
- export interface EarthEngineLayerConfigurationProps {
37
- form: UseFormReturn<EarthEngineLayerConfig>;
38
- excluded?: string[];
39
- [key: string]: any;
40
- }
41
-
42
- function useType() {
43
- const type = useWatch({
44
- name: "type",
45
- });
46
- return find(EARTH_ENGINE_LAYERS, ["id", type]);
47
- }
48
-
49
- function AggregationSelector() {
50
- const config = useType();
51
-
52
- if (!config?.defaultAggregations) {
53
- return null;
54
- }
55
-
56
- const supportedAggregations = config?.defaultAggregations ?? [];
57
-
58
- const maxAggregations = config?.maxAggregations;
59
-
60
- return (
61
- <Controller
62
- render={({ field, fieldState }) => {
63
- return maxAggregations === 1 ? (
64
- <SingleSelectField
65
- clearable
66
- error={Boolean(fieldState.error)}
67
- validationText={fieldState?.error?.message}
68
- selected={supportedAggregations.includes(head(field.value) ?? "") ? head(field.value) : undefined}
69
- onChange={({ selected }: { selected: string }) => field.onChange([selected])}
70
- label={i18n.t("Aggregation")}>
71
- {supportedAggregations.map((aggregation) => (
72
- <SingleSelectOption key={`${aggregation}-option`} label={capitalize(aggregation)} value={aggregation} />
73
- ))}
74
- </SingleSelectField>
75
- ) : (
76
- <MultiSelectField
77
- error={Boolean(fieldState.error)}
78
- validationText={fieldState?.error?.message}
79
- selected={field.value?.filter((value: string) => supportedAggregations?.includes(value))}
80
- onChange={({ selected }: { selected: string[] }) => field.onChange(selected)}
81
- label={i18n.t("Aggregations")}>
82
- {supportedAggregations.map((aggregation) => (
83
- <MultiSelectOption key={`${aggregation}-option`} label={capitalize(aggregation)} value={aggregation} />
84
- ))}
85
- </MultiSelectField>
86
- );
87
- }}
88
- name={"aggregations"}
89
- />
90
- );
91
- }
92
-
93
- function useDatasetInfo(shouldRun: boolean, config?: EarthEngineOptions) {
94
- const { refresh } = useGoogleEngineToken();
95
-
96
- async function getInfo() {
97
- if (config) {
98
- const tokenData = await refresh();
99
- await EarthEngine.setToken(tokenData.token, refresh);
100
- const engine = new EarthEngine({
101
- options: config,
102
- });
103
- return engine.getPeriod();
104
- }
105
- }
106
-
107
- const { data, error, isLoading } = useQuery([config], getInfo);
108
-
109
- const periods = useMemo(() => {
110
- const features = (data as any)?.features;
111
- return features?.map((feature: any) => {
112
- return new Date(feature?.properties["system:time_start"])?.getFullYear();
113
- });
114
- }, [data]);
115
-
116
- return {
117
- loading: isLoading,
118
- error: error as any,
119
- periods,
120
- };
121
- }
122
-
123
- function PeriodSelector() {
124
- const config = useType();
125
- const { setValue, getValues } = useFormContext();
126
- const filters = config?.filters ?? [];
127
- const hasPeriodFilter = filters.includes("period");
128
- const { loading, error, periods } = useDatasetInfo(hasPeriodFilter, config);
129
- const initialPeriod = getValues("filters.period");
130
-
131
- useEffect(() => {
132
- if (!isEmpty(periods) && !initialPeriod) {
133
- setValue("filters.period", head(periods));
134
- }
135
- }, [periods]);
136
-
137
- if (!hasPeriodFilter) {
138
- return null;
139
- }
140
-
141
- if (error) {
142
- return (
143
- <div style={{ minWidth: "100%", minHeight: 100 }}>
144
- <CenteredContent>
145
- <p>{error?.message ?? error?.toString()}</p>
146
- </CenteredContent>
147
- </div>
148
- );
149
- }
150
-
151
- return (
152
- <Controller
153
- name="filters.period"
154
- rules={{
155
- required: i18n.t("Period is required"),
156
- }}
157
- render={({ field, fieldState }) => (
158
- <div style={{ gap: 4 }} className="row align-items-center">
159
- <div style={{ flex: 1 }}>
160
- <SingleSelectField
161
- helpText={i18n.t("Available periods are set by the source data")}
162
- loading={loading}
163
- filterable
164
- label={i18n.t("Period")}
165
- required
166
- error={Boolean(fieldState.error)}
167
- validationText={fieldState.error?.message}
168
- onChange={({ selected }: { selected: string }) => field.onChange(parseInt(selected))}
169
- selected={periods?.includes(field.value) ? field.value?.toString() : undefined}>
170
- {periods?.map((period: number) => (
171
- <SingleSelectOption key={`${period}-option`} value={period.toString()} label={period.toString()} />
172
- ))}
173
- </SingleSelectField>
174
- </div>
175
- {loading && <CircularLoader extrasmall />}
176
- </div>
177
- )}
178
- />
179
- );
180
- }
181
-
182
- function ColorConfig() {
183
- return (
184
- <div className="column gap-16">
185
- <div className="row gap-8">
186
- <Controller
187
- render={({ field, fieldState }) => (
188
- <InputField
189
- {...field}
190
- error={Boolean(fieldState.error)}
191
- validationText={fieldState.error?.message}
192
- value={field.value?.toString()}
193
- onChange={({ value }: { value: string }) => field.onChange(parseInt(value))}
194
- label={i18n.t("Min")}
195
- type="number"
196
- />
197
- )}
198
- name={"params.min"}
199
- />
200
- <Controller
201
- render={({ field, fieldState }) => (
202
- <InputField
203
- {...field}
204
- error={Boolean(fieldState.error)}
205
- validationText={fieldState.error?.message}
206
- value={field.value?.toString()}
207
- onChange={({ value }: { value: string }) => field.onChange(parseInt(value))}
208
- label={i18n.t("Max")}
209
- type="number"
210
- />
211
- )}
212
- name={"params.max"}
213
- />
214
- <Controller
215
- name="params.palette"
216
- render={({ field, fieldState }) => {
217
- const palette = field.value;
218
- const scale = getColorClasses(palette);
219
- const colorClass = getColorScale(palette ?? "");
220
-
221
- const onChange = ({ selected }: { selected: string }) => {
222
- const palette = getColorPalette(colorClass as string, parseInt(selected))?.join(",");
223
- field.onChange(palette);
224
- };
225
-
226
- return (
227
- <SingleSelectField
228
- validationText={fieldState.error?.message}
229
- error={Boolean(fieldState.error)}
230
- selected={scale?.toString() ?? defaultClasses.toString()}
231
- label={i18n.t("Steps")}
232
- onChange={onChange}
233
- name="scale">
234
- {[3, 4, 5, 6, 7, 8, 9].map((value) => (
235
- <SingleSelectOption key={`${value}-classes-option`} label={`${value}`} value={value?.toString()} />
236
- ))}
237
- </SingleSelectField>
238
- );
239
- }}
240
- />
241
- </div>
242
- <div>
243
- <Controller
244
- name="params.palette"
245
- render={({ field, fieldState }) => {
246
- const palette = field.value;
247
- const scale = getColorClasses(palette);
248
- const colorClass = getColorScale(palette ?? "");
249
-
250
- const onChange = (colorClass: string) => {
251
- const palette = getColorPalette(colorClass, scale)?.join(",");
252
- field.onChange(palette);
253
- };
254
-
255
- return (
256
- <Field error={Boolean(fieldState.error)} validationText={fieldState.error?.message} label={i18n.t("Colors")}>
257
- <ColorScaleSelect count={scale ?? defaultClasses} colorClass={colorClass ?? defaultColorScaleName} width={300} onChange={onChange} />
258
- </Field>
259
- );
260
- }}
261
- />
262
- </div>
263
- </div>
264
- );
265
- }
266
-
267
- function StylesConfig() {
268
- const config = useType();
269
- const hasParams = Boolean(config?.params);
270
-
271
- if (!hasParams) {
272
- return null;
273
- }
274
-
275
- return (
276
- <div style={{ minWidth: 200, minHeight: 100 }} className="row gap-16">
277
- <div className="column">
278
- <p>
279
- {i18n.t("Unit")}: {config?.unit}
280
- </p>
281
- <ColorConfig />
282
- </div>
283
- </div>
284
- );
285
- }
286
-
287
- function Name() {
288
- const config = useType();
289
- const { setValue } = useFormContext();
290
- useEffect(() => {
291
- setValue("name", config?.name);
292
- setValue("id", config?.id);
293
- }, [config]);
294
-
295
- return (
296
- <Controller
297
- name="name"
298
- rules={{
299
- required: i18n.t("Name is required"),
300
- }}
301
- render={({ field, fieldState }) => (
302
- <InputField
303
- label={i18n.t("Layer name")}
304
- type="text"
305
- required
306
- error={Boolean(fieldState.error)}
307
- validationText={fieldState.error?.message}
308
- onChange={({ value }: { value: string }) => field.onChange(value)}
309
- value={field.value}
310
- />
311
- )}
312
- />
313
- );
314
- }
315
-
316
- function TypeField({ excluded }: { excluded?: string[] }) {
317
- const supportedLayers = filter(EARTH_ENGINE_LAYERS, ({ id }) => SUPPORTED_EARTH_ENGINE_LAYERS.includes(id) && !(excluded?.includes(id) ?? false));
318
- const { setValue } = useFormContext();
319
- const setConfigDefaults = (selected: string) => {
320
- const config = find(supportedLayers, ["id", selected]);
321
- if (!config) return;
322
-
323
- if (config?.defaultAggregations) {
324
- setValue("aggregations", config?.defaultAggregations);
325
- } else {
326
- setValue("aggregations", undefined);
327
- }
328
-
329
- if (config?.params) {
330
- const { max, min, palette } = config.params;
331
- setValue("params.max", max);
332
- setValue("params.min", min);
333
- setValue("params.palette", palette);
334
- } else {
335
- setValue("params", undefined);
336
- }
337
- };
338
-
339
- return (
340
- <Controller
341
- name="type"
342
- rules={{
343
- required: i18n.t("Type is required"),
344
- }}
345
- render={({ field, fieldState }) => (
346
- <SingleSelectField
347
- label={i18n.t("Layer type")}
348
- required
349
- error={Boolean(fieldState.error)}
350
- validationText={fieldState.error?.message}
351
- onChange={({ selected }: { selected: string }) => {
352
- setConfigDefaults(selected);
353
- field.onChange(selected);
354
- }}
355
- selected={Boolean(find(supportedLayers, "id", field.value)) ? field.value : undefined}>
356
- {supportedLayers?.map((layer) => (
357
- <SingleSelectOption key={`${layer.id}-option`} value={layer.id} label={layer.name} />
358
- ))}
359
- </SingleSelectField>
360
- )}
361
- />
362
- );
363
- }
364
-
365
- export function EarthEngineLayerConfiguration({ form, excluded }: EarthEngineLayerConfigurationProps) {
366
- return (
367
- <FormProvider {...form}>
368
- <div className="column gap-16">
369
- <TypeField excluded={excluded} />
370
- <Name />
371
- <AggregationSelector />
372
- <PeriodSelector />
373
- <StylesConfig />
374
- </div>
375
- </FormProvider>
376
- );
377
- }
378
-
379
- export interface EarthEngineLayerConfigModalProps {
380
- open: boolean;
381
- config?: EarthEngineLayerConfig;
382
- exclude?: string[];
383
- onClose: () => void;
384
- onChange: (config: EarthEngineLayerConfig) => void;
385
- }
386
-
387
- export function EarthEngineLayerConfigModal({ open, exclude, config, onClose, onChange, ...props }: EarthEngineLayerConfigModalProps) {
388
- const form = useForm<EarthEngineLayerConfig>({
389
- defaultValues: config ?? {},
390
- });
391
- const onSubmitClick = (values: EarthEngineLayerConfig) => {
392
- onClose();
393
- onChange(values);
394
- };
395
-
396
- return (
397
- <Modal {...props} open={open} onClose={onClose}>
398
- <ModalTitle>{i18n.t("Configure Earth Engine Layer")}</ModalTitle>
399
- <ModalContent>
400
- <EarthEngineLayerConfiguration form={form} excluded={exclude} />
401
- </ModalContent>
402
- <ModalActions>
403
- <ButtonStrip>
404
- <Button onClick={onClose}>{i18n.t("Cancel")}</Button>
405
- <Button primary onClick={form.handleSubmit(onSubmitClick)}>
406
- {i18n.t("Save")}
407
- </Button>
408
- </ButtonStrip>
409
- </ModalActions>
410
- </Modal>
411
- );
412
- }
@@ -1,83 +0,0 @@
1
- import {uid} from "@hisptz/dhis2-utils";
2
- import {Map as LeafletMap} from "leaflet";
3
- import {isEmpty} from "lodash";
4
- import React, {forwardRef, useRef} from "react";
5
- import {LayersControl, MapContainer, TileLayer} from "react-leaflet";
6
- import {useMapBounds} from "../../hooks/map";
7
- import MapControl from "../MapControls";
8
- import MapLayer from "../MapLayer";
9
- import LegendArea from "../MapLayer/components/LegendArea";
10
- import {CustomThematicLayer} from "../MapLayer/interfaces";
11
- import {MapLayersProvider} from "../MapProvider/components/MapLayerProvider";
12
- import {useMapLayers} from "../MapProvider/hooks";
13
- import {MapAreaProps, MapControls, MapLegendConfig} from "./interfaces";
14
- import MapUpdater from "../MapUpdater";
15
-
16
- function MapLayerArea({
17
- id,
18
- base,
19
- controls,
20
- legends,
21
- }: {
22
- id: string;
23
- base?: {
24
- url: string;
25
- attribution: string;
26
- };
27
- controls?: MapControls[];
28
- legends?: MapLegendConfig;
29
- }) {
30
- const { layers } = useMapLayers();
31
-
32
- return (
33
- <>
34
- <TileLayer
35
- id={id}
36
- attribution={
37
- base?.attribution ??
38
- '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> | &copy; <a href="https://carto.com/attribution">CARTO</a>'
39
- }
40
- url={base?.url ?? "https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png"}
41
- />
42
- {controls?.map((control) => (
43
- <MapControl mapId={id} key={`${control.type}-control`} {...control} />
44
- ))}
45
- {!isEmpty(layers) && (
46
- <LayersControl hideSingleBase position={"topleft"}>
47
- {(layers as CustomThematicLayer[]).map((layer: CustomThematicLayer, index) => (
48
- <MapLayer key={layer.id} layer={layer} index={index} />
49
- ))}
50
- </LayersControl>
51
- )}
52
- {!isEmpty(layers) && <LegendArea legends={legends} layers={layers as CustomThematicLayer[]} position={"topright"} />}
53
- </>
54
- );
55
- }
56
-
57
- const MapArea = ({ base, controls, mapOptions, key, legends, layers }: MapAreaProps, ref: React.Ref<LeafletMap> | undefined) => {
58
- const { center, bounds } = useMapBounds();
59
- const { current: id } = useRef<string>(uid());
60
-
61
- return (
62
- <div id={`${id}-"map-container`} style={{ height: "100%", width: "100%" }}>
63
- <MapContainer
64
- attributionControl
65
- ref={ref}
66
- id={id}
67
- center={center}
68
- bounceAtZoomLimits
69
- bounds={bounds}
70
- style={{ height: "100%", width: "100%", minHeight: 500 }}
71
- key={key}
72
- trackResize
73
- {...mapOptions}>
74
- <MapUpdater bounds={bounds} />
75
- <MapLayersProvider layers={layers}>
76
- <MapLayerArea base={base} id={id} controls={controls} legends={legends} />
77
- </MapLayersProvider>
78
- </MapContainer>
79
- </div>
80
- );
81
- };
82
-
83
- export default forwardRef(MapArea);
@@ -1,39 +0,0 @@
1
- import {ControlPosition} from "leaflet";
2
- import type {MapContainerProps} from "react-leaflet";
3
- import {
4
- CustomBoundaryLayer,
5
- CustomPointLayer,
6
- EarthEngineLayerConfig,
7
- ThematicLayerConfig
8
- } from "../../MapLayer/interfaces";
9
-
10
- export interface MapControls {
11
- position: ControlPosition;
12
- type: "zoom" | "rotate" | "fullscreen" | "compass" | "scale" | "print";
13
- options?: Record<string, any>;
14
- }
15
-
16
- export interface MapLegendConfig {
17
- enabled: boolean;
18
- position: ControlPosition;
19
- collapsible: boolean;
20
- }
21
-
22
- export interface MapLayerConfig {
23
- thematicLayers?: ThematicLayerConfig[];
24
- boundaryLayers?: CustomBoundaryLayer[];
25
- pointLayers?: CustomPointLayer[];
26
- earthEngineLayers?: EarthEngineLayerConfig[];
27
- }
28
-
29
- export interface MapAreaProps {
30
- base?: {
31
- url: string;
32
- attribution: string;
33
- };
34
- controls?: MapControls[];
35
- mapOptions?: MapContainerProps;
36
- legends?: MapLegendConfig;
37
- layers: MapLayerConfig;
38
- key?: string;
39
- }
@@ -1,24 +0,0 @@
1
- import {ControlOptions} from "leaflet";
2
- import React from "react";
3
-
4
- const POSITION_CLASSES = {
5
- bottomleft: "leaflet-bottom leaflet-left",
6
- bottomright: "leaflet-bottom leaflet-right",
7
- topleft: "leaflet-top leaflet-left",
8
- topright: "leaflet-top leaflet-right",
9
- };
10
-
11
- interface CustomControlOptions extends ControlOptions {
12
- children: React.ReactNode;
13
- }
14
-
15
- export function CustomControl({ children, position, ...options }: CustomControlOptions) {
16
- const positionClass = (position && POSITION_CLASSES[position]) || POSITION_CLASSES.topright;
17
- return (
18
- <div {...options} className={`${positionClass}`}>
19
- <div style={{ overflow: "hidden", border: "none" }} className="leaflet-control leaflet-bar">
20
- {children}
21
- </div>
22
- </div>
23
- );
24
- }
@@ -1,10 +0,0 @@
1
- import {createControlComponent} from "@react-leaflet/core";
2
- import L, {ControlPosition} from "leaflet";
3
- import "leaflet-easyprint";
4
-
5
- const DownloadControlComponent = createControlComponent((props) => {
6
- return (L as any).easyPrint(props);
7
- });
8
- export default function DownloadControl({ options, position, mapId }: { options: any; position: ControlPosition; mapId: string }) {
9
- return <DownloadControlComponent {...{ ...options, position }} />;
10
- }
@@ -1,7 +0,0 @@
1
- import {createControlComponent} from "@react-leaflet/core";
2
- import {control} from "leaflet";
3
- import "leaflet.fullscreen";
4
- import "leaflet.fullscreen/Control.FullScreen.css";
5
-
6
- const FullscreenControl = createControlComponent((props) => (control as any).fullscreen(props));
7
- export default FullscreenControl;
@@ -1,24 +0,0 @@
1
- import React from "react";
2
- import {ScaleControl, ZoomControl} from "react-leaflet";
3
- import {MapControls} from "../MapArea/interfaces";
4
- import FullscreenControl from "./components/FullscreenControl";
5
- import DownloadControl from "./components/DownloadControl";
6
-
7
- export interface MapControlProps extends MapControls {
8
- mapId: string;
9
- }
10
-
11
- export default function MapControl({ type, options, position, mapId }: MapControlProps) {
12
- switch (type) {
13
- case "zoom":
14
- return <ZoomControl position={position} {...options} />;
15
- case "scale":
16
- return <ScaleControl position={position} {...options} />;
17
- case "fullscreen":
18
- return <FullscreenControl position={position} {...options} />;
19
- case "print":
20
- return <DownloadControl mapId={mapId} position={position} options={options} />;
21
- default:
22
- return null;
23
- }
24
- }
@@ -1,7 +0,0 @@
1
- import {useMapOrganisationUnit} from "../../../../MapProvider/hooks";
2
-
3
- export function useBoundaryData() {
4
- const { orgUnits } = useMapOrganisationUnit();
5
-
6
- return orgUnits;
7
- }
@@ -1,55 +0,0 @@
1
- import i18n from "@dhis2/d2-i18n";
2
- import {colors} from "@dhis2/ui";
3
- import React from "react";
4
- import {GeoJSON, LayerGroup, LayersControl, Popup, Tooltip} from "react-leaflet";
5
- import {MapOrgUnit} from "../../../../interfaces";
6
- import {highlightFeature, resetHighlight} from "../../../../utils/map";
7
- import {CustomBoundaryLayer as BoundaryLayerInterface} from "../../interfaces";
8
- import {useBoundaryData} from "./hooks/useBoundaryData";
9
-
10
- export const defaultStyle = {
11
- weight: 1,
12
- color: colors.grey900,
13
- fillColor: colors.grey900,
14
- fillOpacity: 0.0,
15
- };
16
- export const highlightStyle = {
17
- weight: 2,
18
- color: colors.grey900,
19
- dashArray: "",
20
- fillOpacity: 0.1,
21
- };
22
-
23
- export default function BoundaryLayer(props: BoundaryLayerInterface) {
24
- const { enabled } = props ?? {};
25
- const orgUnits = useBoundaryData();
26
-
27
- return (
28
- <LayersControl.Overlay checked={enabled} name={i18n.t("Boundaries")}>
29
- <LayerGroup>
30
- {orgUnits?.map((area: MapOrgUnit) => {
31
- return (
32
- <GeoJSON
33
- data={area.geoJSON}
34
- interactive
35
- eventHandlers={{
36
- mouseover: (e) => highlightFeature(e, highlightStyle),
37
- mouseout: (e) => resetHighlight(e, defaultStyle),
38
- }}
39
- key={`${area.id}-polygon`}
40
- pathOptions={defaultStyle}>
41
- <Tooltip>{area.name}</Tooltip>
42
- <Popup minWidth={80}>
43
- <h3>{area.name}</h3>
44
- <div>
45
- <b>Level: </b>
46
- {area.level}
47
- </div>
48
- </Popup>
49
- </GeoJSON>
50
- );
51
- })}
52
- </LayerGroup>
53
- </LayersControl.Overlay>
54
- );
55
- }