@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
@@ -18,10 +18,8 @@ const HALF_SIZE = SIZES.touchTargetSize / 2
18
18
  */
19
19
  function generateSvgHtml () {
20
20
  const size = SIZES.touchTargetSize
21
- const half = HALF_SIZE
22
21
  return `
23
22
  <svg width='${size}' height='${size}' viewBox='0 0 48 48' fill-rule='evenodd'
24
- style='display:none;position:absolute;top:0;left:0;margin:${half}px 0 0 -${half}px;cursor:grab'
25
23
  class='im-draw-touch-target' data-im-draw-touch-target>
26
24
  <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>
27
25
  <path d="M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z" fill='var(--draw-bg, #fff)'/>
@@ -35,61 +33,71 @@ function generateSvgHtml () {
35
33
  * @returns {SVGElement} The touch target element
36
34
  */
37
35
  export const createTouchTarget = (container) => {
38
- let el = container.querySelector('[data-im-draw-touch-target]')
39
- if (!el) {
36
+ let element = container.querySelector('[data-im-draw-touch-target]')
37
+ if (!element) {
40
38
  container.insertAdjacentHTML('beforeend', generateSvgHtml())
41
- el = container.querySelector('[data-im-draw-touch-target]')
39
+ element = container.querySelector('[data-im-draw-touch-target]')
40
+ // Set through the element rather than a style attribute, which a Content Security Policy
41
+ // without 'unsafe-inline' blocks
42
+ Object.assign(element.style, {
43
+ display: 'none',
44
+ position: 'absolute',
45
+ top: '0',
46
+ left: '0',
47
+ margin: `${HALF_SIZE}px 0 0 -${HALF_SIZE}px`,
48
+ cursor: 'grab'
49
+ })
42
50
  }
43
- return el
51
+ return element
44
52
  }
45
53
 
46
54
  /**
47
55
  * Apply color scheme to touch target SVG
48
- * @param {SVGElement} el - Touch target element
56
+ * @param {SVGElement} element - Touch target element
49
57
  * @param {object} colors - Color object with editActive, editHalo, editVertex properties
50
58
  */
51
- export const applyTouchTargetColors = (el, colors) => {
52
- if (!el) {
59
+ export const applyTouchTargetColors = (element, colors) => {
60
+ if (!element) {
53
61
  return
54
62
  }
55
- el.style.setProperty('--draw-halo', colors.editActive)
56
- el.style.setProperty('--draw-bg', colors.editHalo)
57
- el.style.setProperty('--draw-primary', colors.editVertex)
63
+ element.style.setProperty('--draw-halo', colors.editActive)
64
+ element.style.setProperty('--draw-bg', colors.editHalo)
65
+ element.style.setProperty('--draw-primary', colors.editVertex)
58
66
  }
59
67
 
60
68
  /**
61
69
  * Show touch target at specified pixel position
62
- * @param {SVGElement} el - Touch target element
70
+ * @param {SVGElement} element - Touch target element
63
71
  * @param {object} pixel - Position object with x, y properties
64
72
  */
65
- export const showTouchTarget = (el, pixel) => {
66
- if (!pixel || !el) {
73
+ export const showTouchTarget = (element, pixel) => {
74
+ if (!pixel || !element) {
67
75
  return
68
76
  }
69
- el.style.left = `${pixel.x}px`
70
- el.style.top = `${pixel.y}px`
71
- el.style.display = 'block'
77
+ element.style.left = `${pixel.x}px`
78
+ element.style.top = `${pixel.y}px`
79
+ element.style.display = 'block'
72
80
  }
73
81
 
74
82
  /**
75
83
  * Hide touch target
76
- * @param {SVGElement} el - Touch target element
84
+ * @param {SVGElement} element - Touch target element
77
85
  */
78
- export const hideTouchTarget = (el) => {
79
- if (el) {
80
- el.style.display = 'none'
86
+ export const hideTouchTarget = (element) => {
87
+ if (element) {
88
+ element.style.display = 'none'
81
89
  }
82
90
  }
83
91
 
84
92
  /**
85
93
  * Check if event target is part of the touch target SVG
86
- * @param {HTMLElement} el - Element to check
94
+ * @param {HTMLElement} element - Element to check
87
95
  * @returns {boolean} True if element is part of touch target
88
96
  */
89
- export const isOnTouchTarget = (el) => {
90
- if (!el) {
97
+ export const isOnTouchTarget = (element) => {
98
+ if (!element) {
91
99
  return false
92
100
  }
93
- const parent = el.parentNode
101
+ const parent = element.parentNode
94
102
  return (parent instanceof globalThis.SVGElement) || (parent?.ownerSVGElement != null)
95
103
  }
@@ -12,13 +12,25 @@ describe('createTouchTarget', () => {
12
12
  test('inserts the SVG target once and returns it', () => {
13
13
  const container = document.createElement('div')
14
14
 
15
- const el = createTouchTarget(container)
15
+ const element = createTouchTarget(container)
16
16
 
17
- expect(el).not.toBeNull()
18
- expect(el.hasAttribute('data-im-draw-touch-target')).toBe(true)
17
+ expect(element).not.toBeNull()
18
+ expect(element.hasAttribute('data-im-draw-touch-target')).toBe(true)
19
19
  expect(container.querySelectorAll('[data-im-draw-touch-target]')).toHaveLength(1)
20
20
  })
21
21
 
22
+ test('styles the target through the element, not a style attribute in the markup', () => {
23
+ const container = document.createElement('div')
24
+ const insertAdjacentHTML = jest.spyOn(container, 'insertAdjacentHTML')
25
+
26
+ const element = createTouchTarget(container)
27
+
28
+ expect(insertAdjacentHTML.mock.calls[0][1]).not.toMatch(/style=/)
29
+ expect(element.style.display).toBe('none')
30
+ expect(element.style.position).toBe('absolute')
31
+ expect(element.style.margin).toBe('24px 0px 0px -24px')
32
+ })
33
+
22
34
  test('returns the existing target without inserting a second one', () => {
23
35
  const container = document.createElement('div')
24
36
  const first = createTouchTarget(container)
@@ -31,13 +43,13 @@ describe('createTouchTarget', () => {
31
43
 
32
44
  describe('applyTouchTargetColors', () => {
33
45
  test('sets the CSS custom properties from the colours', () => {
34
- const el = document.createElement('div')
46
+ const element = document.createElement('div')
35
47
 
36
- applyTouchTargetColors(el, { editActive: 'a', editHalo: 'h', editVertex: 'v' })
48
+ applyTouchTargetColors(element, { editActive: 'a', editHalo: 'h', editVertex: 'v' })
37
49
 
38
- expect(el.style.getPropertyValue('--draw-halo')).toBe('a')
39
- expect(el.style.getPropertyValue('--draw-bg')).toBe('h')
40
- expect(el.style.getPropertyValue('--draw-primary')).toBe('v')
50
+ expect(element.style.getPropertyValue('--draw-halo')).toBe('a')
51
+ expect(element.style.getPropertyValue('--draw-bg')).toBe('h')
52
+ expect(element.style.getPropertyValue('--draw-primary')).toBe('v')
41
53
  })
42
54
 
43
55
  test('does nothing for a null element', () => {
@@ -47,19 +59,19 @@ describe('applyTouchTargetColors', () => {
47
59
 
48
60
  describe('showTouchTarget', () => {
49
61
  test('positions and shows the element', () => {
50
- const el = document.createElement('div')
62
+ const element = document.createElement('div')
51
63
 
52
- showTouchTarget(el, { x: 10, y: 20 })
64
+ showTouchTarget(element, { x: 10, y: 20 })
53
65
 
54
- expect(el.style.left).toBe('10px')
55
- expect(el.style.top).toBe('20px')
56
- expect(el.style.display).toBe('block')
66
+ expect(element.style.left).toBe('10px')
67
+ expect(element.style.top).toBe('20px')
68
+ expect(element.style.display).toBe('block')
57
69
  })
58
70
 
59
71
  test('does nothing without a pixel or an element', () => {
60
- const el = document.createElement('div')
61
- showTouchTarget(el, null)
62
- expect(el.style.display).toBe('')
72
+ const element = document.createElement('div')
73
+ showTouchTarget(element, null)
74
+ expect(element.style.display).toBe('')
63
75
 
64
76
  expect(() => showTouchTarget(null, { x: 0, y: 0 })).not.toThrow()
65
77
  })
@@ -67,12 +79,12 @@ describe('showTouchTarget', () => {
67
79
 
68
80
  describe('hideTouchTarget', () => {
69
81
  test('hides the element', () => {
70
- const el = document.createElement('div')
71
- el.style.display = 'block'
82
+ const element = document.createElement('div')
83
+ element.style.display = 'block'
72
84
 
73
- hideTouchTarget(el)
85
+ hideTouchTarget(element)
74
86
 
75
- expect(el.style.display).toBe('none')
87
+ expect(element.style.display).toBe('none')
76
88
  })
77
89
 
78
90
  test('does nothing for a null element', () => {
@@ -0,0 +1,185 @@
1
+ import { validateGeometry, normaliseResult, withSource } from './validateGeometry.js'
2
+ import { COMMIT_RULES } from './rules.js'
3
+ import { logger } from '../../../../src/services/logger.js'
4
+ import { stripInternalProperties } from '../utils/stripInternalProperties.js'
5
+
6
+ const IDLE = { revision: 0, status: 'idle', result: null, feature: null, context: null, slow: false, afterPending: false }
7
+
8
+ // How long an async check runs before it counts as slow: Done reads "Checking…" and the
9
+ // check is announced. A quicker reply settles without either.
10
+ export const SLOW_CHECK_MS = 300
11
+
12
+ const isThenable = (value) => typeof value?.then === 'function'
13
+
14
+ const statusFor = (result) => (result.valid ? 'valid' : 'invalid')
15
+
16
+ /**
17
+ * Runs the commit-level check for each committed change: the built-in COMMIT_RULES first,
18
+ * synchronously, then the consumer's `onGeometryChange`, which may return a Promise.
19
+ *
20
+ * Every run gets a new revision and aborts the previous run's signal. A result only
21
+ * settles if its revision is still the latest, so a slow reply for an older shape can
22
+ * never overwrite the verdict for the current one. `onSettle(state)` fires for each
23
+ * settled state, including 'pending' as soon as an async check starts, and 'pending' again
24
+ * with `slow: true` once it has run for SLOW_CHECK_MS. A result that follows a slow
25
+ * 'pending' state for the same revision has `afterPending: true`.
26
+ *
27
+ * A finished shape waiting on the latest check can be held (`hold`), and is released when
28
+ * that check settles or the session ends — `reset` returns its id, so it can be discarded.
29
+ *
30
+ * Lives per draw adapter (see getCommitChecks) rather than in events.js's handlers,
31
+ * which are rebuilt on every plugin state change.
32
+ *
33
+ * States: 'idle' | 'pending' | 'valid' | 'invalid' | 'error'
34
+ *
35
+ * @returns {{ run: Function, reset: Function, setOnSettle: Function, hold: Function, release: Function, readonly heldId: string|undefined, readonly state: object }}
36
+ */
37
+ export const createCommitChecks = () => {
38
+ let revision = 0
39
+ let slowRevision = null
40
+ let slowTimer = null
41
+ let abortController = null
42
+ let latest = IDLE
43
+ let onSettle = null
44
+ let held = null
45
+
46
+ const abortPending = () => {
47
+ abortController?.abort()
48
+ abortController = null
49
+ clearTimeout(slowTimer)
50
+ }
51
+
52
+ const settle = (rev, next) => {
53
+ if (rev !== revision) { return }
54
+ if (next.status !== 'pending') {
55
+ abortController = null
56
+ clearTimeout(slowTimer)
57
+ }
58
+ const slow = !!next.slow
59
+ const afterPending = next.status !== 'pending' && slowRevision === rev
60
+ slowRevision = slow ? rev : null
61
+ latest = { ...next, revision: rev, slow, afterPending }
62
+ onSettle?.(latest)
63
+ }
64
+
65
+ return {
66
+ get state () { return latest },
67
+
68
+ setOnSettle (fn) { onSettle = fn },
69
+
70
+ // The finished shape held for the latest check, if any
71
+ get heldId () { return held?.revision === revision ? held.id : undefined },
72
+
73
+ hold (featureId) { held = { id: featureId, revision } },
74
+
75
+ release () { held = null },
76
+
77
+ /**
78
+ * @param {object} params
79
+ * @param {object} params.feature - the committed GeoJSON feature
80
+ * @param {object} params.context - { phase, mode, vertexIndex }
81
+ * @param {Function} [params.onGeometryChange] - consumer callback
82
+ * @param {Array<Function>} [params.rules] - built-in rules, defaults to COMMIT_RULES
83
+ */
84
+ run ({ feature, context, onGeometryChange, rules = COMMIT_RULES }) {
85
+ abortPending()
86
+ revision++
87
+ const rev = revision
88
+ const base = { feature, context }
89
+
90
+ const builtIn = validateGeometry(feature, context, { rules })
91
+ if (!builtIn.valid || typeof onGeometryChange !== 'function') {
92
+ settle(rev, { ...base, status: statusFor(builtIn), result: builtIn })
93
+ return
94
+ }
95
+
96
+ abortController = new AbortController()
97
+ const onError = (error) => {
98
+ // A superseded check rejecting (e.g. on its aborted signal) isn't a failure
99
+ if (rev !== revision) { return }
100
+ logger.warn('[draw] onGeometryChange failed', error)
101
+ settle(rev, { ...base, status: 'error', result: { valid: false, reason: null, source: 'callback' }, error })
102
+ }
103
+
104
+ let output
105
+ try {
106
+ output = onGeometryChange({ feature, ...context }, { signal: abortController.signal, revision: rev })
107
+ } catch (error) {
108
+ onError(error)
109
+ return
110
+ }
111
+
112
+ const settleResult = (value) => {
113
+ const result = withSource(normaliseResult(value), 'callback')
114
+ settle(rev, { ...base, status: statusFor(result), result })
115
+ }
116
+
117
+ if (!isThenable(output)) { settleResult(output); return }
118
+
119
+ settle(rev, { ...base, status: 'pending', result: null })
120
+ slowTimer = setTimeout(() => settle(rev, { ...base, status: 'pending', result: null, slow: true }), SLOW_CHECK_MS)
121
+ output.then(settleResult, onError)
122
+ },
123
+
124
+ // Ends the session: aborts any check in flight and drops whatever it returns. Returns
125
+ // the id of a shape that was held for it, which nothing will now create.
126
+ reset () {
127
+ const heldId = held?.revision === revision ? held.id : undefined
128
+ abortPending()
129
+ revision++
130
+ latest = IDLE
131
+ held = null
132
+ return heldId
133
+ }
134
+ }
135
+ }
136
+
137
+ const checksByDraw = new WeakMap()
138
+
139
+ // One controller per draw adapter, so each map on a page keeps its own revisions.
140
+ export const getCommitChecks = (draw) => {
141
+ let checks = checksByDraw.get(draw)
142
+ if (!checks) {
143
+ checks = createCommitChecks()
144
+ checksByDraw.set(draw, checks)
145
+ }
146
+ return checks
147
+ }
148
+
149
+ // Ring closure differs between a placed-vertices commit (open ring) and the finished
150
+ // feature (closed ring), so the closing coordinate is ignored when comparing.
151
+ const openRing = (ring) => {
152
+ const first = ring[0]
153
+ const last = ring[ring.length - 1]
154
+ return ring.length > 1 && first[0] === last[0] && first[1] === last[1] ? ring.slice(0, -1) : ring
155
+ }
156
+
157
+ const comparableCoords = (geometry) =>
158
+ geometry.type === 'Polygon' ? geometry.coordinates.map(openRing) : geometry.coordinates
159
+
160
+ export const isSameGeometry = (a, b) => {
161
+ const geomA = a?.geometry
162
+ const geomB = b?.geometry
163
+ if (!geomA || !geomB || geomA.type !== geomB.type) { return false }
164
+ return JSON.stringify(comparableCoords(geomA)) === JSON.stringify(comparableCoords(geomB))
165
+ }
166
+
167
+ /**
168
+ * Starts a draw/edit session's checks: installs the session's two callbacks on the
169
+ * adapter and ends any previous session's check. A per-call callback replaces the
170
+ * plugin-level one. A shape still waiting on that check is discarded, as Cancel would.
171
+ *
172
+ * - `draw._previewValidator` — onGeometryPreview, read by the adapters for the
173
+ * 'preview' and 'place' phases
174
+ * - `draw._commitValidator` — onGeometryChange, read by events.js for committed changes
175
+ */
176
+ export const startCheckSession = (draw, options = {}, pluginConfig = {}, eventBus = null) => {
177
+ draw._previewValidator = options.onGeometryPreview ?? pluginConfig.onGeometryPreview
178
+ draw._commitValidator = options.onGeometryChange ?? pluginConfig.onGeometryChange
179
+ const heldId = getCommitChecks(draw).reset()
180
+ if (heldId !== undefined) {
181
+ const discarded = draw.get(heldId)
182
+ draw.delete(heldId)
183
+ eventBus?.emit('draw:cancelled', stripInternalProperties(discarded))
184
+ }
185
+ }
@@ -0,0 +1,205 @@
1
+ import { createCommitChecks, getCommitChecks, isSameGeometry, startCheckSession, SLOW_CHECK_MS } from './commitChecks.js'
2
+
3
+ const square = { type: 'Feature', geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]] } }
4
+ const context = { phase: 'change', mode: 'draw_polygon', vertexIndex: 3 }
5
+ const flush = () => Promise.resolve()
6
+
7
+ describe('createCommitChecks', () => {
8
+ test('starts idle', () => {
9
+ expect(createCommitChecks().state).toEqual(expect.objectContaining({ status: 'idle', revision: 0 }))
10
+ })
11
+
12
+ test('settles a passing built-in check straight away when there is no callback', () => {
13
+ const checks = createCommitChecks()
14
+ const onSettle = jest.fn()
15
+ checks.setOnSettle(onSettle)
16
+ checks.run({ feature: square, context })
17
+ expect(onSettle).toHaveBeenCalledWith(expect.objectContaining({ status: 'valid', feature: square, context, revision: 1 }))
18
+ })
19
+
20
+ test('passes the event and a { signal, revision } second argument to the callback', () => {
21
+ const checks = createCommitChecks()
22
+ const onGeometryChange = jest.fn(() => true)
23
+ checks.run({ feature: square, context, onGeometryChange })
24
+ expect(onGeometryChange).toHaveBeenCalledWith({ feature: square, ...context }, { signal: expect.any(AbortSignal), revision: 1 })
25
+ })
26
+
27
+ test('normalises a synchronous result', () => {
28
+ const checks = createCommitChecks()
29
+ checks.run({ feature: square, context, onGeometryChange: () => ({ valid: false, reason: 'too big' }) })
30
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'invalid', result: { valid: false, reason: 'too big', source: 'callback' } }))
31
+ })
32
+
33
+ test('goes pending for a Promise, turns slow, then settles with its result', async () => {
34
+ jest.useFakeTimers()
35
+ const checks = createCommitChecks()
36
+ const onSettle = jest.fn()
37
+ checks.setOnSettle(onSettle)
38
+ let resolve
39
+ checks.run({ feature: square, context, onGeometryChange: () => new Promise((_resolve) => { resolve = _resolve }) })
40
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'pending', slow: false }))
41
+
42
+ jest.advanceTimersByTime(SLOW_CHECK_MS)
43
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'pending', slow: true }))
44
+
45
+ resolve(false)
46
+ await flush()
47
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'invalid', afterPending: true }))
48
+ expect(onSettle.mock.calls.map(([state]) => [state.status, state.slow])).toEqual([['pending', false], ['pending', true], ['invalid', false]])
49
+
50
+ // The next check settles straight away, so it doesn't follow a pending state
51
+ checks.run({ feature: square, context, onGeometryChange: () => true })
52
+ expect(checks.state.afterPending).toBe(false)
53
+ jest.useRealTimers()
54
+ })
55
+
56
+ test('a quick async reply settles without turning slow', async () => {
57
+ jest.useFakeTimers()
58
+ const checks = createCommitChecks()
59
+ const onSettle = jest.fn()
60
+ checks.setOnSettle(onSettle)
61
+ checks.run({ feature: square, context, onGeometryChange: () => Promise.resolve(true) })
62
+ await flush()
63
+ jest.advanceTimersByTime(SLOW_CHECK_MS)
64
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'valid', afterPending: false }))
65
+ expect(onSettle.mock.calls.map(([state]) => state.status)).toEqual(['pending', 'valid'])
66
+ jest.useRealTimers()
67
+ })
68
+
69
+ test('marks a built-in rule failure and a callback error with their source', () => {
70
+ const checks = createCommitChecks()
71
+ const partDrawn = { type: 'Feature', geometry: { type: 'Polygon', coordinates: [[[0, 0], [1, 0], [0, 0]]] } }
72
+ checks.run({ feature: partDrawn, context })
73
+ expect(checks.state.result.source).toBe('rules')
74
+
75
+ jest.spyOn(console, 'warn').mockImplementation(() => {})
76
+ checks.run({ feature: square, context, onGeometryChange: () => { throw new Error('503') } })
77
+ expect(checks.state).toEqual(expect.objectContaining({ status: 'error', result: { valid: false, reason: null, source: 'callback' } }))
78
+ console.warn.mockRestore()
79
+ })
80
+
81
+ test('reset aborts the check in flight, drops its reply and returns to idle', async () => {
82
+ const checks = createCommitChecks()
83
+ let resolve
84
+ let signal
85
+ checks.run({ feature: square, context, onGeometryChange: (_event, ctx) => { signal = ctx.signal; return new Promise((_resolve) => { resolve = _resolve }) } })
86
+ checks.reset()
87
+ expect(signal.aborted).toBe(true)
88
+
89
+ resolve(true)
90
+ await flush()
91
+ expect(checks.state.status).toBe('idle')
92
+ })
93
+
94
+ test('a superseded check that rejects on its aborted signal is dropped silently', async () => {
95
+ const checks = createCommitChecks()
96
+ const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
97
+ const onGeometryChange = (_event, { signal }) => new Promise((_resolve, reject) => {
98
+ signal.addEventListener('abort', () => reject(new Error('aborted')))
99
+ })
100
+ checks.run({ feature: square, context, onGeometryChange })
101
+ checks.run({ feature: square, context, onGeometryChange: () => true })
102
+ await flush()
103
+ expect(checks.state.status).toBe('valid')
104
+ expect(warn).not.toHaveBeenCalled()
105
+ warn.mockRestore()
106
+ })
107
+
108
+ test('a held shape belongs to the latest check, and is released or returned on reset', () => {
109
+ const checks = createCommitChecks()
110
+ checks.run({ feature: square, context })
111
+ checks.hold('a')
112
+ expect(checks.heldId).toBe('a')
113
+ checks.release()
114
+ expect(checks.heldId).toBeUndefined()
115
+
116
+ checks.hold('b')
117
+ checks.run({ feature: square, context }) // a newer check
118
+ expect(checks.heldId).toBeUndefined()
119
+ expect(checks.reset()).toBeUndefined()
120
+
121
+ checks.hold('c')
122
+ expect(checks.reset()).toBe('c')
123
+ })
124
+
125
+ test('works without an onSettle callback', () => {
126
+ const checks = createCommitChecks()
127
+ expect(() => checks.run({ feature: square, context })).not.toThrow()
128
+ })
129
+ })
130
+
131
+ describe('getCommitChecks', () => {
132
+ test('keeps one controller per draw adapter', () => {
133
+ const drawA = {}
134
+ const drawB = {}
135
+ expect(getCommitChecks(drawA)).toBe(getCommitChecks(drawA))
136
+ expect(getCommitChecks(drawA)).not.toBe(getCommitChecks(drawB))
137
+ })
138
+ })
139
+
140
+ describe('isSameGeometry', () => {
141
+ const ring = (coordinates) => ({ geometry: { type: 'Polygon', coordinates: [coordinates] } })
142
+
143
+ test('ignores the closing coordinate of a polygon ring', () => {
144
+ expect(isSameGeometry(ring([[0, 0], [0, 1], [1, 1]]), ring([[0, 0], [0, 1], [1, 1], [0, 0]]))).toBe(true)
145
+ })
146
+
147
+ test('tells different shapes apart', () => {
148
+ expect(isSameGeometry(ring([[0, 0], [0, 1], [1, 1]]), ring([[0, 0], [0, 2], [2, 2]]))).toBe(false)
149
+ expect(isSameGeometry(ring([[0, 0], [0, 1], [1, 1]]), { geometry: { type: 'LineString', coordinates: [[0, 0], [0, 1], [1, 1]] } })).toBe(false)
150
+ })
151
+
152
+ test('compares lines and points directly', () => {
153
+ const line = { geometry: { type: 'LineString', coordinates: [[0, 0], [1, 1]] } }
154
+ expect(isSameGeometry(line, { geometry: { type: 'LineString', coordinates: [[0, 0], [1, 1]] } })).toBe(true)
155
+ expect(isSameGeometry({ geometry: { type: 'Point', coordinates: [0, 0] } }, { geometry: { type: 'Point', coordinates: [0, 0] } })).toBe(true)
156
+ })
157
+
158
+ test('is false when either side has no geometry', () => {
159
+ expect(isSameGeometry(null, ring([[0, 0]]))).toBe(false)
160
+ expect(isSameGeometry(ring([[0, 0]]), { id: 'x' })).toBe(false)
161
+ })
162
+ })
163
+
164
+ describe('startCheckSession', () => {
165
+ test('prefers per-call callbacks over the plugin-level ones', () => {
166
+ const draw = {}
167
+ const onGeometryChange = jest.fn()
168
+ const onGeometryPreview = jest.fn(() => true)
169
+ startCheckSession(draw, { onGeometryChange, onGeometryPreview }, { onGeometryChange: jest.fn(), onGeometryPreview: jest.fn() })
170
+ expect(draw._commitValidator).toBe(onGeometryChange)
171
+ expect(draw._previewValidator).toBe(onGeometryPreview)
172
+ })
173
+
174
+ test('falls back to the plugin-level callbacks', () => {
175
+ const draw = {}
176
+ const onGeometryChange = jest.fn()
177
+ startCheckSession(draw, {}, { onGeometryChange })
178
+ expect(draw._commitValidator).toBe(onGeometryChange)
179
+ expect(draw._previewValidator).toBeUndefined()
180
+ })
181
+
182
+ test('discards a shape still held for the previous session\u2019s check, as Cancel would', () => {
183
+ const shape = { id: 'held', type: 'Feature', properties: {}, geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [0, 0]]] } }
184
+ const draw = { get: jest.fn(() => shape), delete: jest.fn() }
185
+ const eventBus = { emit: jest.fn() }
186
+ const checks = getCommitChecks(draw)
187
+ checks.run({ feature: shape, context: { phase: 'change' }, onGeometryChange: () => new Promise(() => {}) })
188
+ checks.hold('held')
189
+ expect(checks.heldId).toBe('held')
190
+
191
+ startCheckSession(draw, {}, {}, eventBus)
192
+ expect(draw.delete).toHaveBeenCalledWith('held')
193
+ expect(eventBus.emit).toHaveBeenCalledWith('draw:cancelled', shape)
194
+ expect(checks.heldId).toBeUndefined()
195
+ })
196
+
197
+ test('ends the previous session’s check', () => {
198
+ const draw = {}
199
+ const checks = getCommitChecks(draw)
200
+ checks.run({ feature: { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 0] } }, context: { phase: 'edit-start' } })
201
+ expect(checks.state.status).toBe('valid')
202
+ startCheckSession(draw)
203
+ expect(checks.state.status).toBe('idle')
204
+ })
205
+ })
@@ -1,22 +1,22 @@
1
1
  import { validateGeometry } from './validateGeometry.js'
2
- import { LIVE_RULES, HARD_RULES, MIN_VERTICES } from './rules.js'
2
+ import { PREVIEW_RULES, PLACE_RULES, MIN_VERTICES } from './rules.js'
3
3
  import { requestFrame, cancelFrame } from './liveStroke.js'
4
4
 
5
5
  /**
6
6
  * Live validation driver for DRAW mode (draw_polygon/draw_line) only — edit mode
7
7
  * has no Add-point gate and keeps using the plain createLiveStroke (liveStroke.js).
8
8
  *
9
- * On every rubber-band move, a user `onGeometryChange` callback is called ONCE,
9
+ * On every rubber-band move, a user `onGeometryPreview` callback is called ONCE,
10
10
  * throttled to one call per animation frame (phase 'preview', with NO
11
11
  * vertex-count floor — a location-based rule is meaningful even against the
12
12
  * very first candidate point, before any vertex is committed). Its verdict is
13
13
  * combined with two INDEPENDENTLY-floored built-in rule checks, each flip-guarded
14
14
  * and reported through its own callback — `onChange(invalid, reason)` fires only
15
15
  * when THAT gate's own state flips, same contract as createLiveStroke:
16
- * - LIVE_RULES (closed-ring self-intersect/area), floored at the geometry
16
+ * - PREVIEW_RULES (closed-ring self-intersect/area), floored at the geometry
17
17
  * type's minimum vertex count — self-intersection/area are meaningless
18
18
  * below that — reported via onStrokeChange (dashed stroke / Done gate).
19
- * - HARD_RULES (open-path self-intersect), never floored, so it still
19
+ * - PLACE_RULES (open-path self-intersect), never floored, so it still
20
20
  * protects placing an invalid first vertex — reported via onPlaceChange
21
21
  * (Add-point gate).
22
22
  * Previously each gate ran its own independently-throttled call to the same
@@ -76,15 +76,15 @@ export const createLiveDrawChecks = ({ onStrokeChange, onPlaceChange }) => {
76
76
  if (!pending) { return }
77
77
  const { feature, context } = pending
78
78
  const min = MIN_VERTICES[feature?.geometry?.type] ?? 0
79
- evaluateGate(feature, context, LIVE_RULES, min, flipStroke)
80
- evaluateGate(feature, context, HARD_RULES, 0, flipPlace)
79
+ evaluateGate(feature, context, PREVIEW_RULES, min, flipStroke)
80
+ evaluateGate(feature, context, PLACE_RULES, 0, flipPlace)
81
81
  }
82
82
 
83
83
  const runUserRule = () => {
84
84
  frame = null
85
85
  if (!pending) { return }
86
- const { feature, context, onGeometryChange } = pending
87
- const result = validateGeometry(feature, { ...context, phase: 'preview' }, { rules: [], onGeometryChange })
86
+ const { feature, context, onGeometryPreview } = pending
87
+ const result = validateGeometry(feature, { ...context, phase: 'preview' }, { rules: [], onGeometryPreview })
88
88
  customInvalid = !result.valid
89
89
  customReason = result.reason
90
90
  recompute()
@@ -92,13 +92,13 @@ export const createLiveDrawChecks = ({ onStrokeChange, onPlaceChange }) => {
92
92
 
93
93
  return {
94
94
  // Re-evaluate the displayed geometry after a rubber-band move.
95
- update ({ feature, context = {}, numVertices, onGeometryChange }) {
96
- pending = { feature, context: { ...context, numVertices }, onGeometryChange }
95
+ update ({ feature, context = {}, numVertices, onGeometryPreview }) {
96
+ pending = { feature, context: { ...context, numVertices }, onGeometryPreview }
97
97
  // Built-in rules first, synchronously — immediate feedback either gate.
98
98
  recompute()
99
99
  // A user rule (if any) decides last, throttled to one frame; its cached
100
100
  // verdict (customInvalid) feeds the next recompute() once it lands.
101
- if (typeof onGeometryChange === 'function' && frame == null) {
101
+ if (typeof onGeometryPreview === 'function' && frame == null) {
102
102
  frame = requestFrame(runUserRule)
103
103
  }
104
104
  },