@defra/interactive-map 0.0.55-alpha → 0.0.57-alpha

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 (502) hide show
  1. package/assets/templates/style-switcher.njk +2 -2
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/esm/im-shell.js +1 -1
  4. package/dist/umd/im-core.js +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/docs/api/button-definition.md +11 -0
  7. package/docs/api/context.md +4 -0
  8. package/docs/api.md +20 -2
  9. package/docs/architecture/interactive-map.likec4 +4 -4
  10. package/docs/plugins/datasets.md +11 -0
  11. package/docs/plugins/draw.md +197 -35
  12. package/docs/plugins/interact.md +24 -1
  13. package/docs/plugins/search.md +2 -2
  14. package/docusaurus.config.cjs +25 -3
  15. package/govuk-prototype-kit.config.json +6 -7
  16. package/package.json +20 -23
  17. package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
  18. package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  19. package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
  20. package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
  21. package/plugins/datasets/dist/esm/index.js +1 -1
  22. package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
  23. package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  24. package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
  25. package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
  26. package/plugins/datasets/dist/umd/index.js +1 -1
  27. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
  28. package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
  29. package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
  30. package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
  31. package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
  32. package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
  33. package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
  34. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
  35. package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
  36. package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
  37. package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
  38. package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
  39. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
  40. package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
  41. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
  42. package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
  43. package/plugins/datasets/src/api/getOpacity.js +1 -2
  44. package/plugins/datasets/src/api/getOpacity.test.js +9 -12
  45. package/plugins/datasets/src/api/getStyle.js +1 -2
  46. package/plugins/datasets/src/api/getStyle.test.js +5 -8
  47. package/plugins/datasets/src/api/removeDataset.js +2 -4
  48. package/plugins/datasets/src/api/removeDataset.test.js +5 -10
  49. package/plugins/datasets/src/api/setData.js +2 -4
  50. package/plugins/datasets/src/api/setData.test.js +6 -14
  51. package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
  52. package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
  53. package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
  54. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
  55. package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
  56. package/plugins/datasets/src/index.js +2 -2
  57. package/plugins/datasets/src/index.test.js +8 -1
  58. package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
  59. package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
  60. package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
  61. package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
  62. package/plugins/datasets/src/manifest.js +53 -44
  63. package/plugins/datasets/src/manifest.test.js +36 -4
  64. package/plugins/datasets/src/reducers/pluginState.js +5 -5
  65. package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
  66. package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
  67. package/plugins/datasets/src/registry/createDataset.js +2 -2
  68. package/plugins/datasets/src/registry/dataset.js +9 -10
  69. package/plugins/datasets/src/registry/dataset.test.js +63 -64
  70. package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
  71. package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
  72. package/plugins/datasets/src/registry/globalDataset.js +9 -17
  73. package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
  74. package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
  75. package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
  76. package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
  77. package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
  78. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  79. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  80. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  81. package/plugins/draw/dist/esm/index.js +1 -1
  82. package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
  83. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  84. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  85. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  86. package/plugins/draw/dist/umd/index.js +1 -1
  87. package/plugins/draw/src/DrawInit.jsx +53 -29
  88. package/plugins/draw/src/DrawInit.test.jsx +105 -2
  89. package/plugins/draw/src/adapterEvents.js +78 -44
  90. package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
  91. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
  92. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
  93. package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
  94. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
  95. package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
  96. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
  97. package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
  98. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
  99. package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
  100. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
  101. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
  102. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
  103. package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
  104. package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
  105. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
  106. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
  107. package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
  108. package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
  109. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
  110. package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
  111. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
  112. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
  113. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
  114. package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
  115. package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
  116. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
  117. package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
  118. package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
  119. package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
  120. package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
  121. package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
  122. package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
  123. package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
  124. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
  125. package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
  126. package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
  127. package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
  128. package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
  129. package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
  130. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
  131. package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
  132. package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
  133. package/plugins/draw/src/api/createNewShape.js +4 -4
  134. package/plugins/draw/src/api/createNewShape.test.js +1 -1
  135. package/plugins/draw/src/api/editFeature.js +8 -11
  136. package/plugins/draw/src/api/editFeature.test.js +33 -22
  137. package/plugins/draw/src/api/newLine.test.js +3 -3
  138. package/plugins/draw/src/api/newPoint.js +4 -5
  139. package/plugins/draw/src/api/newPoint.test.js +3 -3
  140. package/plugins/draw/src/api/newPolygon.test.js +3 -3
  141. package/plugins/draw/src/api/recheckGeometry.js +32 -0
  142. package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
  143. package/plugins/draw/src/api/setGeometry.js +33 -0
  144. package/plugins/draw/src/api/setGeometry.test.js +48 -0
  145. package/plugins/draw/src/api/split.js +23 -22
  146. package/plugins/draw/src/api/split.test.js +33 -18
  147. package/plugins/draw/src/events.js +265 -77
  148. package/plugins/draw/src/events.test.js +708 -34
  149. package/plugins/draw/src/hooks/useSpatialList.js +10 -11
  150. package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
  151. package/plugins/draw/src/manifest.js +33 -17
  152. package/plugins/draw/src/manifest.test.js +104 -10
  153. package/plugins/draw/src/reducer.js +31 -9
  154. package/plugins/draw/src/reducer.test.js +35 -3
  155. package/plugins/draw/src/utils/drawModes.js +27 -0
  156. package/plugins/draw/src/utils/drawModes.test.js +27 -0
  157. package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
  158. package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
  159. package/plugins/draw/src/utils/touchTarget.js +34 -26
  160. package/plugins/draw/src/utils/touchTarget.test.js +32 -20
  161. package/plugins/draw/src/validation/commitChecks.js +185 -0
  162. package/plugins/draw/src/validation/commitChecks.test.js +205 -0
  163. package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
  164. package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
  165. package/plugins/draw/src/validation/liveStroke.js +6 -6
  166. package/plugins/draw/src/validation/liveStroke.test.js +27 -27
  167. package/plugins/draw/src/validation/rules.js +16 -14
  168. package/plugins/draw/src/validation/rules.test.js +5 -5
  169. package/plugins/draw/src/validation/validateGeometry.js +58 -31
  170. package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
  171. package/plugins/draw-es/dist/esm/index.js +1 -0
  172. package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
  173. package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
  174. package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
  175. package/plugins/frame/dist/esm/index.js +1 -0
  176. package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
  177. package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
  178. package/plugins/{beta/frame → frame}/package.json +2 -2
  179. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  180. package/plugins/interact/dist/esm/index.js +1 -1
  181. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  182. package/plugins/interact/dist/umd/index.js +1 -1
  183. package/plugins/interact/src/InteractInit.jsx +3 -3
  184. package/plugins/interact/src/api/enable.test.js +13 -0
  185. package/plugins/interact/src/defaults.js +1 -0
  186. package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
  187. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
  188. package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
  189. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
  190. package/plugins/interact/src/hooks/useSpatialList.js +16 -17
  191. package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
  192. package/plugins/interact/src/manifest.js +4 -4
  193. package/plugins/interact/src/manifest.test.js +29 -0
  194. package/plugins/interact/src/reducer.js +7 -2
  195. package/plugins/interact/src/reducer.test.js +12 -2
  196. package/plugins/interact/src/utils/needsTarget.js +20 -0
  197. package/plugins/interact/src/utils/needsTarget.test.js +36 -0
  198. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  199. package/plugins/map-key/dist/esm/index.js +1 -1
  200. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  201. package/plugins/map-key/dist/umd/index.js +1 -1
  202. package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
  203. package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
  204. package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
  205. package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
  206. package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
  207. package/plugins/map-key/src/manifest.test.js +0 -1
  208. package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
  209. package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
  210. package/plugins/map-key/src/reducers/pluginState.js +6 -1
  211. package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
  212. package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
  213. package/plugins/map-styles/dist/esm/index.js +1 -0
  214. package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
  215. package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
  216. package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
  217. package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
  218. package/plugins/menu/dist/esm/index.js +1 -1
  219. package/plugins/scale-bar/dist/esm/index.js +1 -0
  220. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
  221. package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
  222. package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
  223. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  224. package/plugins/search/dist/esm/index.js +1 -1
  225. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  226. package/plugins/search/dist/umd/index.js +1 -1
  227. package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
  228. package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
  229. package/plugins/search/src/utils/markedToElements.jsx +25 -0
  230. package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
  231. package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
  232. package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
  233. package/plugins/use-location/dist/esm/index.js +1 -0
  234. package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
  235. package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
  236. package/providers/esri/dist/esm/index.js +1 -0
  237. package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
  238. package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
  239. package/providers/maplibre/dist/esm/index.js +1 -1
  240. package/providers/maplibre/dist/umd/index.js +1 -1
  241. package/providers/maplibre/src/index.js +11 -2
  242. package/providers/maplibre/src/index.test.js +23 -1
  243. package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
  244. package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
  245. package/providers/maplibre/src/utils/workerUrl.js +12 -0
  246. package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
  247. package/providers/open-names/dist/esm/index.js +1 -0
  248. package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
  249. package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
  250. package/providers/openlayers/dist/esm/index.js +1 -0
  251. package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
  252. package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
  253. package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
  254. package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
  255. package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
  256. package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
  257. package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
  258. package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
  259. package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
  260. package/rollup.esm.mjs +43 -47
  261. package/sonar-project.properties +1 -1
  262. package/src/App/App.jsx +4 -1
  263. package/src/App/App.test.jsx +6 -0
  264. package/src/App/components/MapButton/MapButton.jsx +6 -0
  265. package/src/App/components/MapButton/MapButton.test.jsx +10 -0
  266. package/src/App/components/Markers/Markers.jsx +3 -5
  267. package/src/App/components/Markers/Markers.test.jsx +9 -11
  268. package/src/App/components/Panel/Panel.jsx +2 -9
  269. package/src/App/hooks/useInterfaceAPI.js +16 -4
  270. package/src/App/hooks/useInterfaceAPI.test.js +66 -1
  271. package/src/App/renderer/PluginInits.jsx +8 -7
  272. package/src/App/renderer/PluginInits.test.jsx +20 -5
  273. package/src/App/renderer/SlotItemsProvider.jsx +33 -0
  274. package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
  275. package/src/App/renderer/SlotRenderer.jsx +3 -14
  276. package/src/App/renderer/SlotRenderer.test.jsx +11 -44
  277. package/src/App/renderer/mapButtons.js +24 -12
  278. package/src/App/renderer/mapButtons.test.js +32 -1
  279. package/src/App/renderer/mapControls.js +6 -8
  280. package/src/App/renderer/mapControls.test.js +10 -0
  281. package/src/App/renderer/mapPanels.js +16 -19
  282. package/src/App/renderer/mapPanels.test.js +37 -9
  283. package/src/App/renderer/pluginWrapper.js +10 -8
  284. package/src/App/renderer/pluginWrapper.test.js +23 -9
  285. package/src/App/renderer/slotAggregator.js +18 -5
  286. package/src/App/renderer/slotAggregator.test.js +68 -25
  287. package/src/App/renderer/slotHelpers.js +13 -0
  288. package/src/App/renderer/slotHelpers.test.js +16 -1
  289. package/src/App/store/AppProvider.jsx +19 -1
  290. package/src/App/store/AppProvider.test.jsx +41 -0
  291. package/src/App/store/MapProvider.jsx +3 -0
  292. package/src/App/store/MapProvider.test.jsx +24 -0
  293. package/src/App/store/appActionsMap.js +10 -1
  294. package/src/App/store/appActionsMap.test.js +21 -0
  295. package/src/App/store/appDispatchMiddleware.js +29 -17
  296. package/src/App/store/appDispatchMiddleware.test.js +31 -0
  297. package/src/InteractiveMap/parseDataProperties.js +4 -4
  298. package/src/InteractiveMap/parseDataProperties.test.js +62 -6
  299. package/src/config/events.js +4 -2
  300. package/src/config/mapSizeScales.js +3 -0
  301. package/src/scss/tools/_govuk-content.scss +4 -3
  302. package/src/types.js +4 -0
  303. package/src/utils/focusAfterPanelClose.js +9 -0
  304. package/src/utils/focusAfterPanelClose.test.js +40 -0
  305. package/webpack.dev.mjs +9 -3
  306. package/webpack.prod.mjs +11 -4
  307. package/webpack.umd.mjs +6 -7
  308. package/plugins/beta/draw-es/dist/esm/index.js +0 -1
  309. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
  310. package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
  311. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
  312. package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
  313. package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
  314. package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
  315. package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
  316. package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
  317. package/plugins/beta/draw-ml/src/api/merge.js +0 -9
  318. package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
  319. package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
  320. package/plugins/beta/draw-ml/src/api/split.js +0 -81
  321. package/plugins/beta/draw-ml/src/defaults.js +0 -17
  322. package/plugins/beta/draw-ml/src/draw.scss +0 -26
  323. package/plugins/beta/draw-ml/src/events.js +0 -185
  324. package/plugins/beta/draw-ml/src/index.js +0 -13
  325. package/plugins/beta/draw-ml/src/manifest.js +0 -110
  326. package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
  327. package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
  328. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
  329. package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
  330. package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
  331. package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
  332. package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
  333. package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
  334. package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
  335. package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
  336. package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
  337. package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
  338. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
  339. package/plugins/beta/draw-ml/src/reducer.js +0 -90
  340. package/plugins/beta/draw-ml/src/styles.js +0 -190
  341. package/plugins/beta/draw-ml/src/undoStack.js +0 -50
  342. package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
  343. package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
  344. package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
  345. package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
  346. package/plugins/beta/draw-ol/dist/css/index.css +0 -1
  347. package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
  348. package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
  349. package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
  350. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
  351. package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
  352. package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
  353. package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
  354. package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
  355. package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
  356. package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
  357. package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
  358. package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
  359. package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
  360. package/plugins/beta/draw-ol/src/core/styles.js +0 -98
  361. package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
  362. package/plugins/beta/draw-ol/src/defaults.js +0 -16
  363. package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
  364. package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
  365. package/plugins/beta/draw-ol/src/draw.scss +0 -17
  366. package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
  367. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
  368. package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
  369. package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
  370. package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
  371. package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
  372. package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
  373. package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
  374. package/plugins/beta/draw-ol/src/events.js +0 -114
  375. package/plugins/beta/draw-ol/src/index.js +0 -12
  376. package/plugins/beta/draw-ol/src/manifest.js +0 -125
  377. package/plugins/beta/draw-ol/src/olDraw.js +0 -38
  378. package/plugins/beta/draw-ol/src/reducer.js +0 -41
  379. package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
  380. package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
  381. package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
  382. package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
  383. package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
  384. package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
  385. package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
  386. package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
  387. package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
  388. package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
  389. package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
  390. package/plugins/beta/frame/dist/esm/index.js +0 -1
  391. package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
  392. package/plugins/beta/map-styles/dist/esm/index.js +0 -1
  393. package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
  394. package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
  395. package/plugins/beta/use-location/dist/esm/index.js +0 -1
  396. package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
  397. package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
  398. package/plugins/map-key/src/registry/index.js +0 -1
  399. package/plugins/map-key/src/registry/index.test.js +0 -7
  400. package/providers/beta/esri/dist/esm/index.js +0 -1
  401. package/providers/beta/open-names/dist/esm/index.js +0 -1
  402. package/providers/beta/openlayers/dist/esm/index.js +0 -1
  403. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
  404. package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
  405. /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
  406. /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
  407. /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
  408. /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
  409. /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
  410. /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
  411. /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
  412. /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
  413. /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
  414. /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
  415. /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
  416. /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
  417. /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
  418. /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
  419. /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
  420. /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
  421. /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
  422. /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
  423. /package/plugins/{beta/frame → frame}/src/config.js +0 -0
  424. /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
  425. /package/plugins/{beta/frame → frame}/src/index.js +0 -0
  426. /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
  427. /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
  428. /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
  429. /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
  430. /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
  431. /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
  432. /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
  433. /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
  434. /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
  435. /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
  436. /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
  437. /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
  438. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
  439. /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
  440. /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
  441. /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
  442. /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
  443. /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
  444. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
  445. /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
  446. /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
  447. /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
  448. /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
  449. /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
  450. /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
  451. /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
  452. /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
  453. /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
  454. /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
  455. /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
  456. /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
  457. /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
  458. /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
  459. /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
  460. /package/providers/{beta/esri → esri}/src/index.js +0 -0
  461. /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
  462. /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
  463. /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
  464. /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
  465. /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
  466. /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
  467. /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
  468. /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
  469. /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
  470. /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
  471. /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
  472. /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
  473. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
  474. /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
  475. /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
  476. /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
  477. /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
  478. /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
  479. /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
  480. /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
  481. /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
  482. /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
  483. /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
  484. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
  485. /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
  486. /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
  487. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
  488. /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
  489. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
  490. /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
  491. /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
  492. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
  493. /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
  494. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
  495. /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
  496. /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
  497. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
  498. /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
  499. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
  500. /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
  501. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
  502. /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
@@ -71,11 +71,19 @@ createDrawPlugin({
71
71
 
72
72
  ---
73
73
 
74
+ ### `onGeometryPreview`
75
+
76
+ **Type:** `Function`
77
+
78
+ Plugin-level synchronous check, called while a shape is drawn or dragged and when a vertex is about to be placed. Can be overridden per call. See [`onGeometryPreview`](#ongeometrypreviewevent).
79
+
80
+ ---
81
+
74
82
  ### `onGeometryChange`
75
83
 
76
84
  **Type:** `Function`
77
85
 
78
- Plugin-level validation callback, called throughout the draw/edit lifecycle so you can enforce your own rules (e.g. "shapes must stay inside a boundary") alongside the built-in ones. Can be overridden per call — see [Validation](#validation) below for the full contract, and `newPolygon`, `newLine`, `newPoint`, `editFeature` for the per-call override.
86
+ Plugin-level check, called after each committed change to a shape. Can return a Promise, so the shape can be checked against a service. Can be overridden per call. See [`onGeometryChange`](#ongeometrychangeevent-context).
79
87
 
80
88
  ---
81
89
 
@@ -113,7 +121,10 @@ createDrawPlugin({
113
121
 
114
122
  ## Validation
115
123
 
116
- Every geometry change — placing a vertex, dragging one, finishing a shape — is checked against a set of built-in rules before it's accepted, plus your own `onGeometryChange` callback if you provide one.
124
+ Every geometry change is checked against a set of built-in rules, plus your own callbacks if you provide them:
125
+
126
+ - [`onGeometryPreview`](#ongeometrypreviewevent) — synchronous. Gives live feedback while a shape is drawn or dragged, and can reject a vertex before it's placed.
127
+ - [`onGeometryChange`](#ongeometrychangeevent-context) — called after each committed change. Can be asynchronous. Its result for the latest change gates the Done button.
117
128
 
118
129
  ### Built-in rules
119
130
 
@@ -126,53 +137,138 @@ Every geometry change — placing a vertex, dragging one, finishing a shape —
126
137
 
127
138
  Rule failures gate the Done button (the shape can pass through interim invalid states while being built or reshaped, shown with a dashed outline) except the placement-time self-intersection check, which is a hard veto — that specific vertex is rejected and never placed.
128
139
 
129
- ### `onGeometryChange` callback
140
+ ### Setting the callbacks
130
141
 
131
- Set at the plugin level (`createDrawPlugin({ onGeometryChange })`) or per call (`newPolygon`/`newLine`/`newPoint`/`editFeature`'s `options.onGeometryChange`, which takes precedence when given). Not used by `split` (which validates that the line actually bisects the shape) or `merge`/`addFeature`/`setStyle` (no validation). For a `Point`, only the `'place'` phase applies — placing or dragging a point can be vetoed, but there's no minimum-vertices/self-intersection/area check.
142
+ Both callbacks are set at the plugin level (`createDrawPlugin({ onGeometryPreview, onGeometryChange })`) or per call, in the options of `newPolygon`, `newLine`, `newPoint` and `editFeature`. A per-call callback replaces the plugin-level one for that session. To run both, call the plugin-level callback from the per-call one.
132
143
 
133
- **Signature:** `onGeometryChange(event) => boolean | { valid: boolean, reason?: string } | undefined`
144
+ Each session has one of each callback. When more than one part of your app needs `onGeometryChange`, such as a measurements panel and a rules service, pass a single callback that calls each of them and returns the result that should gate Done:
145
+
146
+ ```js
147
+ createDrawPlugin({
148
+ onGeometryChange: (event, context) => {
149
+ measurements.update(event.feature)
150
+ return rules.check(event, context)
151
+ }
152
+ })
153
+ ```
154
+
155
+ Neither is used by `split` (which checks that the line divides the shape in two) or by `merge`, `addFeature` and `setStyle`.
156
+
157
+ Both return the same result:
134
158
 
135
159
  | Return value | Meaning |
136
160
  |---|---|
137
161
  | `true` / `undefined` | Valid |
138
162
  | `false` | Invalid, no reason shown |
139
- | `{ valid, reason }` | Valid or invalid, with an optional reason surfaced as a hint toast (except for placement, which never toasts — see `phase` below) |
163
+ | `{ valid, reason, announcement, recheckOnFinish }` | Valid or invalid, with these optional fields |
164
+
165
+ | Result field | Type | Description |
166
+ |---|---|---|
167
+ | `reason` | `string` | Why the shape is invalid. Shown as a hint toast and sent with [`draw:geometryinvalid`](#drawgeometryinvalid) |
168
+ | `announcement` | `string` | Announced to screen readers instead of draw's own message, whether the result is valid or not. When set, `reason` isn't shown as a hint toast, so you can present the issue yourself. From `onGeometryPreview`, only a rejected placement is announced |
169
+ | `recheckOnFinish` | `boolean` | `onGeometryChange` only. When the shape is finished, check it again with phase `'create'` or `'edit-finish'` rather than reusing this result. See [Checking once a shape is finished](#checking-once-a-shape-is-finished) |
140
170
 
141
- **Event payload:**
171
+ Both receive the same event:
142
172
 
143
173
  | Property | Type | Description |
144
174
  |----------|------|-------------|
145
- | `feature` | `GeoJSON.Feature` | The shape at this point — the in-progress feature during `'preview'`, the committed/candidate feature at every other phase |
146
- | `phase` | `string` | See table below |
175
+ | `feature` | `GeoJSON.Feature` | The shape being checked — the in-progress feature during `'preview'`, the committed or candidate feature in every other phase |
176
+ | `phase` | `string` | Why the callback was called — see each callback's phases below |
147
177
  | `mode` | `'draw_polygon' \| 'draw_line' \| 'draw_point' \| 'edit_vertex' \| 'edit_point'` | The active draw mode |
148
- | `vertexIndex` | `number` | Index of the vertex being placed/added/moved/inserted/deleted. Present on `'place'` and every `'commit-*'` phase |
178
+ | `vertexIndex` | `number` | Index of the vertex being placed, added, moved, inserted or deleted. Present on `'place'`, and on a `'change'` to a single vertex |
149
179
  | `numVertices` | `number` | Count of already-committed vertices, excluding any in-progress cursor point. Present on every `'preview'` call |
150
180
 
151
- **Phases:**
181
+ ### `onGeometryPreview(event)`
182
+
183
+ **Signature:** `onGeometryPreview(event) => boolean | { valid: boolean, reason?: string, announcement?: string } | undefined`
184
+
185
+ Must return synchronously. A returned Promise is treated as valid.
186
+
187
+ | Phase | When | Effect |
188
+ |-------|------|--------|
189
+ | `'preview'` | Every rubber-band move or drag, throttled to once per frame | Drives the dashed outline and the Add point button. While editing, also gates the Done button |
190
+ | `'place'` | A click, tap, <kbd>Enter</kbd> or Add point press, before the vertex is placed | Invalid rejects the vertex — it never appears |
191
+
192
+ It runs on every frame of a drag, so keep it quick, using only the shape and data already in the page. Rules about a single vertex, such as where the first point may go, belong here: `onGeometryChange` isn't called until the shape has its minimum number of vertices.
193
+
194
+ ### `onGeometryChange(event, context)`
152
195
 
153
- | Phase | When | Can veto? |
154
- |-------|------|-----------|
155
- | `'preview'` | Live feedback on every rubber-band move while drawing/dragging, throttled to once per frame. Drives both the dashed-outline check and the Add-point button | No — display only |
156
- | `'place'` | A real click/tap/Add-point press, evaluated once, synchronously | Yes — a hard rule or your callback returning invalid rejects the vertex outright; it never appears |
157
- | `'create'` | A whole new feature just finished being drawn | Gates whether it's accepted as-is or reopened in edit mode |
158
- | `'edit-start'` | An existing feature was just loaded into an edit session — the baseline check before anything has changed | Gates the initial Done state |
159
- | `'commit-add'` | A vertex was added while drawing | Gates Done |
160
- | `'commit-move'` | A vertex was dragged/nudged while editing | Gates Done |
161
- | `'commit-insert'` | A vertex was inserted at a midpoint while editing | Gates Done |
162
- | `'commit-delete'` | A vertex was removed while editing | Gates Done |
196
+ **Signature:** `onGeometryChange(event, { signal, revision }) => boolean | { valid: boolean, reason?: string, announcement?: string, recheckOnFinish?: boolean } | undefined | Promise<…>`
197
+
198
+ Called after each change to a shape. It can return a Promise, so you can check the shape with a service.
199
+
200
+ | Phase | When |
201
+ |-------|------|
202
+ | `'change'` | The shape changed, including with [`setGeometry`](#setgeometrygeometry) or undo |
203
+ | `'create'` | A new shape was finished without a passing result, such as a new point, or with [`recheckOnFinish`](#checking-once-a-shape-is-finished) |
204
+ | `'edit-start'` | `editFeature` opened the shape |
205
+ | `'edit-finish'` | Done was pressed on an edit, with [`recheckOnFinish`](#checking-once-a-shape-is-finished) |
206
+ | `'recheck'` | [`recheckGeometry`](#recheckgeometrydetail) was called. Its `detail` is on `event.detail` |
207
+
208
+ | Context property | Type | Description |
209
+ |----------|------|-------------|
210
+ | `signal` | `AbortSignal` | Aborted when the shape changes again or the session ends. Pass it to `fetch` to cancel the request |
211
+ | `revision` | `number` | Increases with every check |
212
+
213
+ - It's only called once the built-in rules pass.
214
+ - Only the result for the latest change counts.
215
+ - A shape that fails, or whose check throws or rejects, can't be finished. Call `recheckGeometry()` to retry.
216
+ - If the user finishes while a check is running, draw waits for it. A new shape that then fails is reopened in edit mode ([`draw:reopened`](#drawreopened)). An edit that fails stays open.
217
+
218
+ ### Checking once a shape is finished
219
+
220
+ When a shape is finished, the result for its last change is used. To check the whole shape once at the end instead, such as with a single service call, return `recheckOnFinish: true` for each change. `onGeometryChange` is then called again when the shape is finished, with phase `'create'` for a new shape or `'edit-finish'` when Done is pressed on an edit.
221
+
222
+ This updates a panel on every change, and calls a validation service once, when the shape is finished:
223
+
224
+ ```js
225
+ createDrawPlugin({
226
+ onGeometryChange: ({ feature, phase }, { signal }) => {
227
+ // Update the panel without waiting for it, so finishing never waits on it.
228
+ // The signal cancels the request if the shape changes again.
229
+ contextPanel.update(feature, { signal })
230
+
231
+ // Let each change through, and check once the shape is finished
232
+ if (phase === 'change' || phase === 'edit-start') {
233
+ return { valid: true, recheckOnFinish: true }
234
+ }
235
+ // 'create', 'edit-finish' and 'recheck' are checked by the service
236
+ return validateWithService(feature, { signal })
237
+ }
238
+ })
239
+ ```
240
+
241
+ This works with an `async` function too, as long as the panel update isn't awaited. Otherwise draw treats the check as pending until the panel replies.
242
+
243
+ In a reopened shape, Undo starts empty, and Cancel discards the shape, as it does while the shape is waiting on its check.
244
+
245
+ ### Debouncing
246
+
247
+ Debouncing and timeouts are up to you. Waiting on `signal` gives a debounce that cancels itself when the shape changes again:
163
248
 
164
249
  ```js
250
+ const wait = (ms, signal) => new Promise((resolve, reject) => {
251
+ const timer = setTimeout(resolve, ms)
252
+ signal.addEventListener('abort', () => { clearTimeout(timer); reject(signal.reason) }, { once: true })
253
+ })
254
+
165
255
  createDrawPlugin({
166
- onGeometryChange: (event) => ({
256
+ onGeometryPreview: (event) => ({
167
257
  valid: isEastOfWalesBorder(event.feature.geometry),
168
258
  reason: 'Points must be placed east of the England/Wales border'
169
- })
259
+ }),
260
+ onGeometryChange: async ({ feature }, { signal }) => {
261
+ infoPanel.update(measureArea(feature))
262
+ await wait(300, signal)
263
+ const response = await fetch('/api/boundary-checks', { method: 'POST', body: JSON.stringify(feature), signal })
264
+ return response.json() // { valid, reason }
265
+ }
170
266
  })
171
267
  ```
172
268
 
173
269
  ## Methods
174
270
 
175
- Methods are called on the plugin instance. `newPolygon`, `newLine`, `newPoint`, `editFeature`, `addFeature`, `setStyle`, `deleteFeature`, `split`, and `merge` all need `mapProvider.draw` to be ready — call them after [`draw:ready`](#drawready).
271
+ Methods are called on the plugin instance. `newPolygon`, `newLine`, `newPoint`, `editFeature`, `addFeature`, `setStyle`, `deleteFeature`, `split`, `merge`, `setGeometry` and `recheckGeometry` all need `mapProvider.draw` to be ready — call them after [`draw:ready`](#drawready).
176
272
 
177
273
  ---
178
274
 
@@ -184,7 +280,8 @@ Start drawing a new polygon.
184
280
  |----------|------|-------------|
185
281
  | `featureId` | `string` | **Required.** ID to assign the finished feature |
186
282
  | `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
187
- | `options.onGeometryChange` | `Function` | Overrides the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
283
+ | `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
284
+ | `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
188
285
  | `options.stroke` | `string \| Record<string, string>` | Stroke colour for this shape |
189
286
  | `options.fill` | `string \| Record<string, string>` | Fill colour for this shape |
190
287
  | `options.strokeWidth` | `number` | Stroke width in pixels for this shape |
@@ -220,7 +317,8 @@ Start drawing a new point. Unlike `newPolygon`/`newLine`, it commits as soon as
220
317
  |----------|------|-------------|
221
318
  | `featureId` | `string` | **Required.** ID to assign the finished feature |
222
319
  | `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
223
- | `options.onGeometryChange` | `Function` | Overrides the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
320
+ | `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
321
+ | `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
224
322
  | `options.properties` | `Object` | Custom GeoJSON properties to set on the finished feature |
225
323
  | `options.symbol` | `string` | Built-in symbol id — `'pin'`, `'circle'`, `'square'`, `'hexagon'`, `'triangle'`, or `'diamond'` |
226
324
  | `options.symbolSvgContent` | `string` | Custom SVG markup, used instead of `symbol` |
@@ -251,7 +349,8 @@ Open an existing feature in edit mode — vertex-edit for a `Polygon`/`LineStrin
251
349
  |----------|------|-------------|
252
350
  | `featureId` | `string` | **Required.** ID of the feature to edit |
253
351
  | `options.snapLayers` | `string[]` | Overrides the plugin-level `snapLayers` for this session |
254
- | `options.onGeometryChange` | `Function` | Overrides the plugin-level `onGeometryChange` for this session |
352
+ | `options.onGeometryPreview` | `Function` | Replaces the plugin-level `onGeometryPreview` for this session — see [Validation](#validation) |
353
+ | `options.onGeometryChange` | `Function` | Replaces the plugin-level `onGeometryChange` for this session — see [Validation](#validation) |
255
354
 
256
355
  ```js
257
356
  const editSuccess = drawPlugin.editFeature(selectedFeatureId)
@@ -382,6 +481,55 @@ interactiveMap.on('draw:merge', (event) => {
382
481
  })
383
482
  ```
384
483
 
484
+ ---
485
+
486
+ ### `setGeometry(geometry)`
487
+
488
+ Replace the shape in the current edit session, for example with a corrected boundary from a service. The change can be undone, and is checked like any other change, with phase `'change'`. Returns `false` (without doing anything) outside an edit session, or when the geometry type differs from the shape being edited.
489
+
490
+ | Argument | Type | Description |
491
+ |----------|------|-------------|
492
+ | `geometry` | `GeoJSON.Geometry` | **Required.** The new geometry, of the same type as the shape being edited |
493
+
494
+ ```js
495
+ drawPlugin.setGeometry(correctedBoundary)
496
+ ```
497
+
498
+ ---
499
+
500
+ ### `recheckGeometry(detail?)`
501
+
502
+ Call `onGeometryChange` again for the current shape, unchanged, with phase `'recheck'`. Use it when your answer may have changed without the shape changing — for example after the user chooses to ignore a warning — or to retry a check that failed. Returns `false` (without doing anything) outside a draw or edit session, or before the shape has been checked.
503
+
504
+ | Argument | Type | Description |
505
+ |----------|------|-------------|
506
+ | `detail` | `any` | Passed to `onGeometryChange` as `event.detail`, for example to tell an ignored warning from a retry |
507
+
508
+ ```js
509
+ const ignoredWarnings = new Set()
510
+
511
+ let warnings = []
512
+
513
+ createDrawPlugin({
514
+ onGeometryChange: async ({ feature, detail }, { signal }) => {
515
+ // Ignoring a warning reuses the last answer; anything else, including a retry, asks again
516
+ if (detail?.reason !== 'ignore') {
517
+ warnings = await checkBoundary(feature, { signal })
518
+ }
519
+ return { valid: warnings.every((warning) => ignoredWarnings.has(warning.id)) }
520
+ }
521
+ })
522
+
523
+ const onIgnoreWarning = (warning) => {
524
+ ignoredWarnings.add(warning.id)
525
+ drawPlugin.recheckGeometry({ reason: 'ignore' })
526
+ }
527
+
528
+ const onRetry = () => drawPlugin.recheckGeometry({ reason: 'retry' })
529
+ ```
530
+
531
+ ---
532
+
385
533
  ## Application mode
386
534
 
387
535
  While drawing or editing, the plugin sets the `'draw'` [application mode](../api.md#setapplicationmodeid-options), which gives the interface over to drawing: every button, panel and control, in every slot, is hidden except draw's own and these defaults:
@@ -405,11 +553,17 @@ new InteractiveMap('map', {
405
553
  Or set `draw: false` when every button on the map is deliberate — for example a single-task map that goes straight into editing a shape — so nothing is hidden.
406
554
 
407
555
  > [!NOTE]
408
- > The mode only changes the interface. Other plugins' own behaviour keeps running while their buttons are hidden, so disable any that shouldn't respond while drawing — for example, call `interactPlugin.disable()` on [`draw:started`](#drawstarted) and [`draw:editstart`](#draweditstart), and `interactPlugin.enable()` on [`draw:created`](#drawcreated), [`draw:edited`](#drawedited) and [`draw:cancelled`](#drawcancelled).
556
+ > The mode only changes the interface. Other plugins' own behaviour keeps running while their buttons are hidden, so disable any that shouldn't respond while drawing.
557
+
558
+ > [!IMPORTANT]
559
+ > If you use the [interact plugin](interact.md), disable it while drawing or editing. Otherwise map clicks select features as well as placing points, and both plugins show and hide the same crosshair. Call `interactPlugin.disable()` on [`draw:started`](#drawstarted) and [`draw:editstart`](#draweditstart), and `interactPlugin.enable()` on [`draw:created`](#drawcreated), [`draw:edited`](#drawedited) and [`draw:cancelled`](#drawcancelled).
409
560
 
410
561
  ## Buttons and keyboard shortcuts
411
562
 
412
- The plugin registers its own toolbar buttons automatically — Cancel, Add point (touch only) and Done in the actions bar, plus Undo, Snap and Delete point in the middle of the top row — which show and enable themselves based on the current draw/edit state. You don't need to render these yourself; augment them with your own trigger buttons (e.g. "Draw polygon", "Draw line") the way the [Draw tools example](../examples/draw-tools.mdx) does.
563
+ The plugin registers its own toolbar buttons automatically — Cancel, Add point and Done in the actions bar, plus Undo, Snap and Delete point in the middle of the top row — which show and enable themselves based on the current draw/edit state. You don't need to render these yourself; augment them with your own trigger buttons (e.g. "Draw polygon", "Draw line") the way the [Draw tools example](../examples/draw-tools.mdx) does.
564
+
565
+ > [!NOTE]
566
+ > While drawing, a crosshair marks where the next point is placed. On touch, it's shown with the Add point button. Keyboard users get the crosshair and press <kbd>Enter</kbd> to add a point. Opening the map controls shows the crosshair and Add point button for every input type. Edit modes don't use the crosshair: vertices and midpoints are selected directly.
413
567
 
414
568
  | Shortcut | Action |
415
569
  |----------|--------|
@@ -441,7 +595,7 @@ Emitted once the draw plugin has initialised. Safe to call API methods from here
441
595
 
442
596
  Emitted when `newPolygon`, `newLine`, or `newPoint` starts a new draw session.
443
597
 
444
- **Payload:** `{ mode: 'draw_polygon' | 'draw_line' | 'draw_point' }`
598
+ **Payload:** `{ mode: 'draw_polygon' | 'draw_line' | 'draw_point', featureId: string }`
445
599
 
446
600
  ---
447
601
 
@@ -449,13 +603,13 @@ Emitted when `newPolygon`, `newLine`, or `newPoint` starts a new draw session.
449
603
 
450
604
  Emitted when `editFeature` opens an existing feature for editing.
451
605
 
452
- **Payload:** `{ mode: 'edit_polygon' | 'edit_line' | 'edit_point' }`
606
+ **Payload:** `{ mode: 'edit_polygon' | 'edit_line' | 'edit_point', featureId: string }`
453
607
 
454
608
  ---
455
609
 
456
610
  ### `draw:created`
457
611
 
458
- Emitted when a new shape finishes drawing and passes validation. Also fires for a shape that finished invalid, was automatically reopened in edit mode, and was then fixed and finished — from the caller's perspective it's still a creation, not an edit.
612
+ Emitted when a new shape finishes drawing and passes its checks. Also fires for a shape that finished invalid, was automatically reopened in edit mode, and was then fixed and finished — from the caller's perspective it's still a creation, not an edit.
459
613
 
460
614
  **Payload:** the finished `GeoJSON.Feature`
461
615
 
@@ -469,9 +623,17 @@ Emitted when an existing feature finishes an edit session (via `editFeature`).
469
623
 
470
624
  ---
471
625
 
626
+ ### `draw:reopened`
627
+
628
+ Emitted when a new shape is finished, its `onGeometryChange` check fails, and it reopens in edit mode. See [Validation](#validation).
629
+
630
+ **Payload:** `{ feature, status: 'invalid' | 'error', reason }` — `reason` is `null` unless an invalid result gave one
631
+
632
+ ---
633
+
472
634
  ### `draw:cancelled`
473
635
 
474
- Emitted when the Cancel button is pressed during a draw or edit session.
636
+ Emitted when the Cancel button is pressed during a draw or edit session. Cancelling a new shape that's waiting on its check, or has reopened in edit mode, removes it from the map. Also emitted when a new session starts while a finished shape is still waiting on its check, which discards it.
475
637
 
476
638
  **Payload:** the feature being drawn/edited at the time of cancellation
477
639
 
@@ -503,9 +665,9 @@ Emitted when the input device changes mid-session (e.g. switching from mouse to
503
665
 
504
666
  ### `draw:geometryinvalid`
505
667
 
506
- Emitted whenever a validation check — a built-in rule or your `onGeometryChange` callback — fails, alongside the same hint toast shown to the user (skipped only for an in-progress shape that simply hasn't reached its minimum vertex count yet). See [Validation](#validation).
668
+ Emitted whenever a check — a built-in rule, a placement rejected by `onGeometryPreview`, or an invalid result from `onGeometryChange` for the latest change — fails. Not emitted for the `'edit-start'` check of a feature that was already invalid. The `reason` is also shown as a hint toast, unless the result has its own `announcement`, or the shape simply hasn't reached its minimum vertex count yet. See [Validation](#validation).
507
669
 
508
- **Payload:** `{ feature, reason, phase, mode, vertexIndex? }`
670
+ **Payload:** `{ feature, reason, source, phase, mode, vertexIndex? }` — `source` is `'rules'` for a built-in rule and `'callback'` for `onGeometryPreview` or `onGeometryChange`
509
671
 
510
672
  ---
511
673
 
@@ -37,7 +37,9 @@ Controls which interactions are active when the user clicks the map. Values can
37
37
  - `'placeMarker'` — if no feature is matched (or `selectFeature` is not active), places a location marker at the clicked coordinates
38
38
 
39
39
  > [!NOTE]
40
- > On touch and keyboard, a crosshair and "Select" action button are shown when interact is enabled. For touch users, this applies when `'placeMarker'` or `'selectFeature'` is included — modes where a precise point on the map needs to be chosen. When `'selectMarker'` is the only active mode, touch users tap markers directly and the crosshair is not shown.
40
+ > On touch, a crosshair and "Select" action button are shown when `'placeMarker'` or `'selectFeature'` is included — modes where a precise point on the map needs to be chosen. When `'selectMarker'` is the only active mode, touch users tap markers directly and neither is shown. [`touchTarget`](#touchtarget) turns them off for touch in every mode.
41
+ >
42
+ > Keyboard users get the crosshair while the map has focus, and press <kbd>Enter</kbd> to select. Opening the map controls shows the crosshair and "Select" button for every input type.
41
43
 
42
44
  **Common combinations:**
43
45
 
@@ -113,6 +115,27 @@ Click detection radius in pixels applied to line features. Lines have a 1px rend
113
115
 
114
116
  ---
115
117
 
118
+ ### `touchTarget`
119
+ **Type:** `boolean`
120
+ **Default:** `true`
121
+
122
+ When `false`, touch users don't get the crosshair and "Select" button, and tap features directly instead. Opening the map controls shows both again, for every input type. Keyboard behaviour is unchanged.
123
+
124
+ ```js
125
+ createInteractPlugin({
126
+ interactionModes: ['selectFeature'],
127
+ touchTarget: false
128
+ })
129
+ ```
130
+
131
+ > [!IMPORTANT]
132
+ > Only set `touchTarget: false` when the features users select are at least 44×44 CSS pixels at the zoom levels they use ([WCAG 2.2 Target Size (Enhanced)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced)), for example field parcels at a sensible zoom. Thin lines and small shapes are hard to tap accurately, especially for users with motor impairments, who rely on the crosshair to position the map instead.
133
+
134
+ > [!NOTE]
135
+ > If you also use the [draw plugin](draw.md), disable interact while drawing or editing, so the two plugins don't both control the crosshair. See [Application mode](draw.md#application-mode).
136
+
137
+ ---
138
+
116
139
  ### `closeOnAction`
117
140
  **Type:** `boolean`
118
141
  **Default:** `true`
@@ -205,7 +205,7 @@ Custom datasets let you add your own search sources alongside or instead of OS N
205
205
  const gridRefDataset = {
206
206
  name: 'gridref',
207
207
  includeRegex: /^[A-Z]{2}\d{6,10}$/i,
208
- buildRequest: (query) => `https://api.example.com/gridref?q=${query}`,
208
+ buildRequest: (query) => `https://api.example.com/gridref?q=${encodeURIComponent(query)}`,
209
209
  parseResults: (json, query) => [{
210
210
  id: query,
211
211
  text: query,
@@ -272,7 +272,7 @@ Each suggestion object must have:
272
272
  |----------|------|-------------|
273
273
  | `id` | `string` | Unique identifier for the suggestion |
274
274
  | `text` | `string` | Display text shown in the autocomplete list |
275
- | `marked` | `string` | Optional. HTML string with query terms wrapped in `<mark>` tags. If omitted, the suggestion label will be blank |
275
+ | `marked` | `string` | Optional. Label text with query terms wrapped in `<mark>` tags. Any other markup is shown as text, not rendered as HTML. If omitted, the suggestion label will be blank |
276
276
  | `point` | `[x, y]` | Centre coordinate for placing a marker |
277
277
  | `bounds` | `[minX, minY, maxX, maxY]` | Bounding box to fit the map to when selected |
278
278
  | `type` | `string` | Optional. Value to include in the `search:match` payload to identify the source dataset |
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
- const path = require('path');
2
+ const path = require('node:path');
3
+ const { getBabelOptions } = require('@docusaurus/babel');
3
4
  require('dotenv').config({ path: path.join(__dirname, '.env'), quiet: true });
4
5
 
5
6
  /** @type {import('@docusaurus/types').Config} */
@@ -31,8 +32,29 @@ const config = {
31
32
 
32
33
  presets: [],
33
34
 
35
+ // Docusaurus compiles the map's source with loose Babel, which assumes every iterable
36
+ // is an array: [...map.values()] becomes [].concat(map.values()), an array holding the
37
+ // iterator rather than its values. Turning off that one assumption spreads iterables
38
+ // properly and keeps the rest of the Docusaurus Babel setup.
39
+ //
40
+ // It's limited to the map's own source because Docusaurus also compiles its own
41
+ // CommonJS packages, where the helper imports this adds break their `exports`.
42
+ webpack: {
43
+ jsLoader: (isServer) => ({
44
+ loader: require.resolve('babel-loader'),
45
+ options: {
46
+ ...getBabelOptions({ isServer }),
47
+ overrides: [{
48
+ include: ['src', 'plugins', 'providers'].map((dir) => path.join(__dirname, dir)),
49
+ assumptions: { iterableIsArray: false },
50
+ }],
51
+ },
52
+ }),
53
+ },
54
+
34
55
  themes: [
35
- [
56
+ /** @type {import('@docusaurus/types').PluginConfig} */
57
+ ([
36
58
  require.resolve('@easyops-cn/docusaurus-search-local'),
37
59
  /** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
38
60
  ({
@@ -45,7 +67,7 @@ const config = {
45
67
  highlightSearchTermsOnTargetPage: true,
46
68
  searchResultContextMaxLength: 60,
47
69
  }),
48
- ],
70
+ ]),
49
71
  '@defra/docusaurus-theme-govuk',
50
72
  ],
51
73
 
@@ -64,15 +64,14 @@
64
64
  "/plugins/interact/dist",
65
65
  "/plugins/search/dist",
66
66
  "/plugins/draw/dist",
67
- "/providers/beta/open-names/dist",
68
- "/providers/beta/openlayers/dist",
67
+ "/providers/open-names/dist",
68
+ "/providers/openlayers/dist",
69
69
  "/plugins/datasets/dist",
70
70
  "/plugins/map-key/dist",
71
71
  "/plugins/menu/dist",
72
- "/plugins/beta/map-styles/dist",
73
- "/plugins/beta/scale-bar/dist",
74
- "/plugins/beta/use-location/dist",
75
- "/plugins/beta/draw-ml/dist",
76
- "/plugins/beta/frame/dist"
72
+ "/plugins/map-styles/dist",
73
+ "/plugins/scale-bar/dist",
74
+ "/plugins/use-location/dist",
75
+ "/plugins/frame/dist"
77
76
  ]
78
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/interactive-map",
3
- "version": "0.0.55-alpha",
3
+ "version": "0.0.57-alpha",
4
4
  "description": "An accessible map component",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,23 +18,23 @@
18
18
  "require": "./providers/maplibre/dist/umd/index.js"
19
19
  },
20
20
  "./providers/open-names": {
21
- "import": "./providers/beta/open-names/dist/esm/index.js",
22
- "require": "./providers/beta/open-names/dist/umd/index.js"
21
+ "import": "./providers/open-names/dist/esm/index.js",
22
+ "require": "./providers/open-names/dist/umd/index.js"
23
23
  },
24
24
  "./providers/esri": {
25
- "import": "./providers/beta/esri/dist/esm/index.js"
25
+ "import": "./providers/esri/dist/esm/index.js"
26
26
  },
27
27
  "./providers/openlayers": {
28
- "import": "./providers/beta/openlayers/dist/esm/index.js",
29
- "require": "./providers/beta/openlayers/dist/umd/index.js"
28
+ "import": "./providers/openlayers/dist/esm/index.js",
29
+ "require": "./providers/openlayers/dist/umd/index.js"
30
30
  },
31
31
  "./plugins/scale-bar": {
32
- "import": "./plugins/beta/scale-bar/dist/esm/index.js",
33
- "require": "./plugins/beta/scale-bar/dist/umd/index.js"
32
+ "import": "./plugins/scale-bar/dist/esm/index.js",
33
+ "require": "./plugins/scale-bar/dist/umd/index.js"
34
34
  },
35
35
  "./plugins/use-location": {
36
- "import": "./plugins/beta/use-location/dist/esm/index.js",
37
- "require": "./plugins/beta/use-location/dist/umd/index.js"
36
+ "import": "./plugins/use-location/dist/esm/index.js",
37
+ "require": "./plugins/use-location/dist/umd/index.js"
38
38
  },
39
39
  "./plugins/search": {
40
40
  "import": "./plugins/search/dist/esm/index.js",
@@ -54,34 +54,30 @@
54
54
  "import": "./plugins/map-key/dist/esm/index.js"
55
55
  },
56
56
  "./plugins/map-styles": {
57
- "import": "./plugins/beta/map-styles/dist/esm/index.js",
58
- "require": "./plugins/beta/map-styles/dist/umd/index.js"
59
- },
60
- "./plugins/draw-ml": {
61
- "import": "./plugins/beta/draw-ml/dist/esm/index.js",
62
- "require": "./plugins/beta/draw-ml/dist/umd/index.js"
57
+ "import": "./plugins/map-styles/dist/esm/index.js",
58
+ "require": "./plugins/map-styles/dist/umd/index.js"
63
59
  },
64
60
  "./plugins/draw-es": {
65
- "import": "./plugins/beta/draw-es/dist/esm/index.js"
61
+ "import": "./plugins/draw-es/dist/esm/index.js"
66
62
  },
67
63
  "./plugins/draw": {
68
64
  "import": "./plugins/draw/dist/esm/index.js",
69
65
  "require": "./plugins/draw/dist/umd/index.js"
70
66
  },
71
67
  "./plugins/frame": {
72
- "import": "./plugins/beta/frame/dist/esm/index.js",
73
- "require": "./plugins/beta/frame/dist/umd/index.js"
68
+ "import": "./plugins/frame/dist/esm/index.js",
69
+ "require": "./plugins/frame/dist/umd/index.js"
74
70
  },
75
71
  "./css": "./dist/css/index.css",
76
72
  "./plugins/draw/css": "./plugins/draw/dist/css/index.css",
77
- "./plugins/scale-bar/css": "./plugins/beta/scale-bar/dist/css/index.css",
73
+ "./plugins/scale-bar/css": "./plugins/scale-bar/dist/css/index.css",
78
74
  "./plugins/datasets/css": "./plugins/datasets/dist/css/index.css",
79
75
  "./plugins/menu/css": "./plugins/menu/dist/css/index.css",
80
76
  "./plugins/map-key/css": "./plugins/map-key/dist/css/index.css",
81
- "./plugins/frame/css": "./plugins/beta/frame/dist/css/index.css",
82
- "./plugins/map-styles/css": "./plugins/beta/map-styles/dist/css/index.css",
77
+ "./plugins/frame/css": "./plugins/frame/dist/css/index.css",
78
+ "./plugins/map-styles/css": "./plugins/map-styles/dist/css/index.css",
83
79
  "./plugins/search/css": "./plugins/search/dist/css/index.css",
84
- "./providers/esri/css": "./providers/beta/esri/dist/css/index.css"
80
+ "./providers/esri/css": "./providers/esri/dist/css/index.css"
85
81
  },
86
82
  "type": "module",
87
83
  "sideEffects": [
@@ -150,6 +146,7 @@
150
146
  "@babel/preset-env": "^7.28.0",
151
147
  "@babel/preset-react": "^7.27.1",
152
148
  "@defra/docusaurus-theme-govuk": "^0.0.22-alpha",
149
+ "@docusaurus/babel": "^3.10.1",
153
150
  "@docusaurus/core": "^3.10.1",
154
151
  "@docusaurus/module-type-aliases": "^3.10.1",
155
152
  "@docusaurus/plugin-content-docs": "^3.10.1",
@@ -1 +1 @@
1
- import e from"@arcgis/core/layers/VectorTileLayer.js";import t from"@arcgis/core/layers/FeatureLayer.js";import i from"@arcgis/core/layers/GroupLayer.js";import{g as a,L as r}from"./layerAdapter.js";import{D as s,d as y,l}from"./im-datasets-plugin.js";import"preact/compat";import"preact/jsx-runtime";class o extends s{applyLayerPaintProperties(e){const{mapStyle:t}=y;return this.hasStroke&&(e["line-color"]=a(this.style.stroke,t.id)),this.hasFill&&(e["fill-color"]=a(this.style.fill,t.id)),e}get esriGroupId(){return void 0===this._datasetDefinition.esriGroupId?this.parent?.esriGroupId:this._datasetDefinition.esriGroupId}get useServerStyle(){return Boolean(this._datasetDefinition.esriUseServerStyle)}get renderer(){if("FeatureService"!==this.type)return;const e=this._datasetDefinition.style?.renderer||this.parent?.renderer;if(!e)return;const{mapStyle:t}=y,i=structuredClone(e);return i.symbol?.color&&(i.symbol.color=a(i.symbol.color,t.id)),i.symbol?.outline?.color&&(i.symbol.outline.color=a(i.symbol.outline.color,t.id)),i}}const p=e=>{if("baseLayer"===e.id)return-1/0;if(e.id.includes("ketchLayer"))return 1/0;const t="group"===e.type?e.layers?.items?.[0]?.id:e.id;return y._orderedDatasets.indexOf(t)};class n extends r{constructor(e){super(),this.ready=new Promise(e=>{this.resolveReady=e}),this._mapProvider=e,this._map=e.map,this._mapVisibilityLayers={},this._mapOpacityLayers={},this._groupLayers={}}createDataset(e){return new o(e)}async init(){const e=y.topLevelDatasets(),t=async e=>this._addLayers(e).then(()=>{const t=this._mapVisibilityLayers[e.id];e.sublayers?.forEach(e=>{"visible"===e.visibility&&this._applyStyleLayerPaintProperties(e,t)}),this.applyDatasetVisibility(e.id)});for(const i of e)"visible"===i.visibility&&await t(i);this._reorderLayers();for(const i of e)"visible"!==i.visibility&&await t(i);await this.onMapStyleChange(),await this.applyGlobalOpacity(),await Promise.all(e.map(e=>this.applyDatasetVisibility(e.id))),this._reorderLayers(),this.resolveReady()}_reorderLayers(){const e=this._map?.allLayers?.items;if(!e?.length)return;[...e.filter(e=>"group"!==e.parent?.type)].sort((e,t)=>p(e)-p(t)).forEach((e,t)=>this._map.reorder(e,t)),this._reorderGroupLayers()}_reorderGroupLayers(){Object.values(this._groupLayers).forEach(e=>{[...e?.allLayers?.items||[]].filter(Boolean).sort((e,t)=>p(e)-p(t)).forEach((t,i)=>e?.reorder?.(t,i))})}_addGroupLayer(e){if(!this._groupLayers[e]){const t=new i({id:e,opacity:1,visible:!0});this._groupLayers[e]=t,this._map.add(t)}return this._groupLayers[e]}async _addFeatureLayers(e){const i=new t({id:e.id,url:e.tiles,renderer:e.renderer,opacity:1,visible:!1});this._mapVisibilityLayers[e.id]=i,this._mapOpacityLayers[e.id]=i;try{return this._map.add(i),i.when()}catch(t){l.error(`Error adding FeatureLayer for dataset ${e.id}:`,t)}return null}async _addLayers(t){const{type:i,esriGroupId:a,tiles:r}=t;if(!r)return null;if("FeatureService"===i)return this._addFeatureLayers(t);const s=a?this._addGroupLayer(a):this._map,y=new e({id:t.id,url:t.tiles,opacity:1,visible:!1});return this._mapVisibilityLayers[t.id]=y,this._mapOpacityLayers[t.id]=a?s:y,s.add(y),y.when()}async addDataset(e){const t=y.getDataset(e);if(!t)return void l.warn(`addDataset called, but Dataset with id ${e} not found in registry`);await this._addLayers(t);const{parentId:i}=t,a=this._mapVisibilityLayers[i||e];this._reorderLayers(),this.applyDatasetOpacity(e),this._applyStyleLayerPaintProperties(t,a),this.applyDatasetVisibility(e)}async removeDataset(e){const t=y.getDataset(e);if(!t)return;const{esriGroupId:i}=t,a=this._mapVisibilityLayers[e],r=i?this._groupLayers[i]:null,s=r||this._map;a&&(s.remove(a),delete this._mapVisibilityLayers[e],delete this._mapOpacityLayers[e]),0===r?.layers.length&&(this._map.remove(r),delete this._groupLayers[i])}_applyRegistryDatasetVisibility(e){const{id:t,isSublayer:i,parentId:a}=e,r="visible"===e.visibility,s=this._mapVisibilityLayers[i?a:t];s&&(i?this._applyStyleLayerVisibility(e,s):(r&&e.sublayers.forEach(e=>this._applyStyleLayerVisibility(e,s)),s.visible=r))}async applyDatasetVisibility(e){const t=y.getDataset(e);t&&this._applyRegistryDatasetVisibility(t)}async applyGlobalVisibility(){y.forEachDataset(e=>this._applyRegistryDatasetVisibility(e))}async applyDatasetOpacity(e){const t=this._mapOpacityLayers[e],i=y.getDataset(e);t&&i&&(t.opacity=i.opacity)}async applyGlobalOpacity(){Object.entries(this._mapOpacityLayers).forEach(([e,t])=>{const i=y.getDataset(e);i&&(t.opacity=i.opacity)})}_applyStyleLayerVisibility(e,t){const{esriStyleLayerId:i}=e;i&&t&&this.ready.then(()=>{t.setStyleLayerVisibility(i,e.visibility)})}_applyStyleLayerPaintProperties(e,t){const{esriStyleLayerId:i,useServerStyle:a}=e;if(a||!i||!t)return;const r=t.getPaintProperties(i);r&&t.setPaintProperties(i,e.applyLayerPaintProperties(r))}async onMapStyleChange(){y.forEach(e=>{const{id:t,isSublayer:i,parent:a}=e,r=this._mapVisibilityLayers[i?a.id:t];r&&("FeatureService"===e.type?r.renderer=e.renderer:(this._applyStyleLayerVisibility(e,r),this._applyStyleLayerPaintProperties(e,r)))})}async onMapSizeChange(){}async applyFeatureFilter(...e){console.log("TODO: applyFeatureFilter",e)}async setData(...e){console.log("TODO: setData",e)}async applyStyle(...e){console.log("TODO: applyStyle",e)}}export{n as default};
1
+ import t from"@arcgis/core/layers/VectorTileLayer.js";import e from"@arcgis/core/layers/FeatureLayer.js";import i from"@arcgis/core/layers/GroupLayer.js";import{g as s,L as a}from"./layerAdapter.js";import{D as r,l as y}from"./im-datasets-plugin.js";import"preact/compat";import"preact/jsx-runtime";class o extends r{applyLayerPaintProperties(t){const{mapStyle:e}=this._datasetRegistry;return this.hasStroke&&(t["line-color"]=s(this.style.stroke,e.id)),this.hasFill&&(t["fill-color"]=s(this.style.fill,e.id)),t}get esriGroupId(){return void 0===this._datasetDefinition.esriGroupId?this.parent?.esriGroupId:this._datasetDefinition.esriGroupId}get useServerStyle(){return Boolean(this._datasetDefinition.esriUseServerStyle)}get renderer(){if("FeatureService"!==this.type)return;const t=this._datasetDefinition.style?.renderer||this.parent?.renderer;if(!t)return;const{mapStyle:e}=this._datasetRegistry,i=structuredClone(t);return i.symbol?.color&&(i.symbol.color=s(i.symbol.color,e.id)),i.symbol?.outline?.color&&(i.symbol.outline.color=s(i.symbol.outline.color,e.id)),i}}const l=(t,e)=>{if("baseLayer"===t.id)return-1/0;if(t.id.includes("ketchLayer"))return 1/0;const i="group"===t.type?t.layers?.items?.[0]?.id:t.id;return e.indexOf(i)};class p extends a{constructor(t,e,i,s){super(),this._datasetRegistry=s,this.ready=new Promise(t=>{this.resolveReady=t}),this._mapProvider=t,this._map=t.map,this._mapVisibilityLayers={},this._mapOpacityLayers={},this._groupLayers={}}createDataset(t,e){return new o(t,e)}async init(){const t=this._datasetRegistry.topLevelDatasets(),e=async t=>this._addLayers(t).then(()=>{const e=this._mapVisibilityLayers[t.id];t.sublayers?.forEach(t=>{"visible"===t.visibility&&this._applyStyleLayerPaintProperties(t,e)}),this.applyDatasetVisibility(t.id)});for(const i of t)"visible"===i.visibility&&await e(i);this._reorderLayers();for(const i of t)"visible"!==i.visibility&&await e(i);await this.onMapStyleChange(),await this.applyGlobalOpacity(),await Promise.all(t.map(t=>this.applyDatasetVisibility(t.id))),this._reorderLayers(),this.resolveReady()}_reorderLayers(){const t=this._map?.allLayers?.items;if(!t?.length)return;const e=this._datasetRegistry._orderedDatasets;[...t.filter(t=>"group"!==t.parent?.type)].sort((t,i)=>l(t,e)-l(i,e)).forEach((t,e)=>this._map.reorder(t,e)),this._reorderGroupLayers()}_reorderGroupLayers(){const t=this._datasetRegistry._orderedDatasets;Object.values(this._groupLayers).forEach(e=>{[...e?.allLayers?.items||[]].filter(Boolean).sort((e,i)=>l(e,t)-l(i,t)).forEach((t,i)=>e?.reorder?.(t,i))})}_addGroupLayer(t){if(!this._groupLayers[t]){const e=new i({id:t,opacity:1,visible:!0});this._groupLayers[t]=e,this._map.add(e)}return this._groupLayers[t]}async _addFeatureLayers(t){const i=new e({id:t.id,url:t.tiles,renderer:t.renderer,opacity:1,visible:!1});this._mapVisibilityLayers[t.id]=i,this._mapOpacityLayers[t.id]=i;try{return this._map.add(i),i.when()}catch(e){y.error(`Error adding FeatureLayer for dataset ${t.id}:`,e)}return null}async _addLayers(e){const{type:i,esriGroupId:s,tiles:a}=e;if(!a)return null;if("FeatureService"===i)return this._addFeatureLayers(e);const r=s?this._addGroupLayer(s):this._map,y=new t({id:e.id,url:e.tiles,opacity:1,visible:!1});return this._mapVisibilityLayers[e.id]=y,this._mapOpacityLayers[e.id]=s?r:y,r.add(y),y.when()}async addDataset(t){const e=this._datasetRegistry.getDataset(t);if(!e)return void y.warn(`addDataset called, but Dataset with id ${t} not found in registry`);await this._addLayers(e);const{parentId:i}=e,s=this._mapVisibilityLayers[i||t];this._reorderLayers(),this.applyDatasetOpacity(t),this._applyStyleLayerPaintProperties(e,s),this.applyDatasetVisibility(t)}async removeDataset(t){const e=this._datasetRegistry.getDataset(t);if(!e)return;const{esriGroupId:i}=e,s=this._mapVisibilityLayers[t],a=i?this._groupLayers[i]:null,r=a||this._map;s&&(r.remove(s),delete this._mapVisibilityLayers[t],delete this._mapOpacityLayers[t]),0===a?.layers.length&&(this._map.remove(a),delete this._groupLayers[i])}_applyRegistryDatasetVisibility(t){const{id:e,isSublayer:i,parentId:s}=t,a="visible"===t.visibility,r=this._mapVisibilityLayers[i?s:e];r&&(i?this._applyStyleLayerVisibility(t,r):(a&&t.sublayers.forEach(t=>this._applyStyleLayerVisibility(t,r)),r.visible=a))}async applyDatasetVisibility(t){const e=this._datasetRegistry.getDataset(t);e&&this._applyRegistryDatasetVisibility(e)}async applyGlobalVisibility(){this._datasetRegistry.forEachDataset(t=>this._applyRegistryDatasetVisibility(t))}async applyDatasetOpacity(t){const e=this._mapOpacityLayers[t],i=this._datasetRegistry.getDataset(t);e&&i&&(e.opacity=i.opacity)}async applyGlobalOpacity(){Object.entries(this._mapOpacityLayers).forEach(([t,e])=>{const i=this._datasetRegistry.getDataset(t);i&&(e.opacity=i.opacity)})}_applyStyleLayerVisibility(t,e){const{esriStyleLayerId:i}=t;i&&e&&this.ready.then(()=>{e.setStyleLayerVisibility(i,t.visibility)})}_applyStyleLayerPaintProperties(t,e){const{esriStyleLayerId:i,useServerStyle:s}=t;if(s||!i||!e)return;const a=e.getPaintProperties(i);a&&e.setPaintProperties(i,t.applyLayerPaintProperties(a))}async onMapStyleChange(){this._datasetRegistry.forEach(t=>{const{id:e,isSublayer:i,parent:s}=t,a=this._mapVisibilityLayers[i?s.id:e];a&&("FeatureService"===t.type?a.renderer=t.renderer:(this._applyStyleLayerVisibility(t,a),this._applyStyleLayerPaintProperties(t,a)))})}async onMapSizeChange(){}async applyFeatureFilter(...t){console.log("TODO: applyFeatureFilter",t)}async setData(...t){console.log("TODO: setData",t)}async applyStyle(...t){console.log("TODO: applyStyle",t)}}export{p as default};