@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.
- package/assets/templates/style-switcher.njk +2 -2
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +11 -0
- package/docs/api/context.md +4 -0
- package/docs/api.md +20 -2
- package/docs/architecture/interactive-map.likec4 +4 -4
- package/docs/plugins/datasets.md +11 -0
- package/docs/plugins/draw.md +197 -35
- package/docs/plugins/interact.md +24 -1
- package/docs/plugins/search.md +2 -2
- package/docusaurus.config.cjs +25 -3
- package/govuk-prototype-kit.config.json +6 -7
- package/package.json +20 -23
- package/plugins/datasets/dist/esm/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/esm/index.js +1 -1
- package/plugins/datasets/dist/esm/mapboxStyleLayerAdapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/index.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +18 -16
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.js +2 -3
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/loadLayerAdapter.js +2 -20
- package/plugins/datasets/src/adapters/loadLayerAdapter.test.js +9 -9
- package/plugins/datasets/src/adapters/mapboxStyleLayerAdapter.js +7 -7
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.js +19 -19
- package/plugins/datasets/src/adapters/maplibre/maplibreLayerAdapter.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/layerBuilders.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.js +21 -21
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +5 -5
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +2 -3
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +2 -2
- package/plugins/datasets/src/api/getOpacity.js +1 -2
- package/plugins/datasets/src/api/getOpacity.test.js +9 -12
- package/plugins/datasets/src/api/getStyle.js +1 -2
- package/plugins/datasets/src/api/getStyle.test.js +5 -8
- package/plugins/datasets/src/api/removeDataset.js +2 -4
- package/plugins/datasets/src/api/removeDataset.test.js +5 -10
- package/plugins/datasets/src/api/setData.js +2 -4
- package/plugins/datasets/src/api/setData.test.js +6 -14
- package/plugins/datasets/src/api/setFeatureVisibility.js +1 -2
- package/plugins/datasets/src/api/setFeatureVisibility.test.js +8 -11
- package/plugins/datasets/src/components/LayersMenu/LayersMenu.jsx +1 -0
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.jsx +1 -3
- package/plugins/datasets/src/components/LayersMenu/LayersMenuCheckbox.test.jsx +13 -18
- package/plugins/datasets/src/index.js +2 -2
- package/plugins/datasets/src/index.test.js +8 -1
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +37 -26
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +120 -89
- package/plugins/datasets/src/initialise/initialiseDatasets.js +2 -3
- package/plugins/datasets/src/initialise/initialiseDatasets.test.js +23 -10
- package/plugins/datasets/src/manifest.js +53 -44
- package/plugins/datasets/src/manifest.test.js +36 -4
- package/plugins/datasets/src/reducers/pluginState.js +5 -5
- package/plugins/datasets/src/reducers/pluginState.test.js +21 -20
- package/plugins/datasets/src/registry/__mocks__/datasetRegistry.js +7 -6
- package/plugins/datasets/src/registry/createDataset.js +2 -2
- package/plugins/datasets/src/registry/dataset.js +9 -10
- package/plugins/datasets/src/registry/dataset.test.js +63 -64
- package/plugins/datasets/src/registry/datasetRegistry.js +39 -10
- package/plugins/datasets/src/registry/datasetRegistry.test.js +83 -1
- package/plugins/datasets/src/registry/globalDataset.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.js +9 -17
- package/plugins/datasets/src/registry/isVisibleWhen.test.js +27 -20
- package/plugins/datasets/src/registry/mapboxStyleDataset.test.js +26 -27
- package/plugins/datasets/src/utils/hasLayersMenu.js +13 -0
- package/plugins/datasets/src/utils/hasLayersMenu.test.js +25 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/esm/liveDrawChecks.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +53 -29
- package/plugins/draw/src/DrawInit.test.jsx +105 -2
- package/plugins/draw/src/adapterEvents.js +78 -44
- package/plugins/draw/src/adapters/adapterContract.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +18 -10
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +31 -22
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +2 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +13 -12
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +6 -9
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.js +8 -14
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/undoHandlers.test.js +37 -8
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +14 -19
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +41 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +12 -1
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.js +9 -10
- package/plugins/draw/src/adapters/maplibre/utils/geometryValidation.test.js +5 -24
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -7
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +12 -7
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +5 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +7 -3
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +11 -11
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +15 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +21 -28
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +26 -5
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +5 -6
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +9 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +7 -0
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +6 -9
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +18 -9
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +29 -4
- package/plugins/draw/src/adapters/openlayers/point/pointOps.js +3 -2
- package/plugins/draw/src/adapters/openlayers/point/pointOps.test.js +6 -0
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.js +3 -4
- package/plugins/draw/src/adapters/openlayers/point/pointSelectionState.test.js +2 -12
- package/plugins/draw/src/adapters/openlayers/point/pointSymbolImages.test.js +1 -1
- package/plugins/draw/src/api/createNewShape.js +4 -4
- package/plugins/draw/src/api/createNewShape.test.js +1 -1
- package/plugins/draw/src/api/editFeature.js +8 -11
- package/plugins/draw/src/api/editFeature.test.js +33 -22
- package/plugins/draw/src/api/newLine.test.js +3 -3
- package/plugins/draw/src/api/newPoint.js +4 -5
- package/plugins/draw/src/api/newPoint.test.js +3 -3
- package/plugins/draw/src/api/newPolygon.test.js +3 -3
- package/plugins/draw/src/api/recheckGeometry.js +32 -0
- package/plugins/draw/src/api/recheckGeometry.test.js +55 -0
- package/plugins/draw/src/api/setGeometry.js +33 -0
- package/plugins/draw/src/api/setGeometry.test.js +48 -0
- package/plugins/draw/src/api/split.js +23 -22
- package/plugins/draw/src/api/split.test.js +33 -18
- package/plugins/draw/src/events.js +265 -77
- package/plugins/draw/src/events.test.js +708 -34
- package/plugins/draw/src/hooks/useSpatialList.js +10 -11
- package/plugins/draw/src/hooks/useSpatialList.test.js +3 -3
- package/plugins/draw/src/manifest.js +33 -17
- package/plugins/draw/src/manifest.test.js +104 -10
- package/plugins/draw/src/reducer.js +31 -9
- package/plugins/draw/src/reducer.test.js +35 -3
- package/plugins/draw/src/utils/drawModes.js +27 -0
- package/plugins/draw/src/utils/drawModes.test.js +27 -0
- package/plugins/draw/src/utils/needsDrawTarget.js +18 -0
- package/plugins/draw/src/utils/needsDrawTarget.test.js +32 -0
- package/plugins/draw/src/utils/touchTarget.js +34 -26
- package/plugins/draw/src/utils/touchTarget.test.js +32 -20
- package/plugins/draw/src/validation/commitChecks.js +185 -0
- package/plugins/draw/src/validation/commitChecks.test.js +205 -0
- package/plugins/draw/src/validation/liveDrawChecks.js +11 -11
- package/plugins/draw/src/validation/liveDrawChecks.test.js +37 -37
- package/plugins/draw/src/validation/liveStroke.js +6 -6
- package/plugins/draw/src/validation/liveStroke.test.js +27 -27
- package/plugins/draw/src/validation/rules.js +16 -14
- package/plugins/draw/src/validation/rules.test.js +5 -5
- package/plugins/draw/src/validation/validateGeometry.js +58 -31
- package/plugins/draw/src/validation/validateGeometry.test.js +68 -44
- package/plugins/draw-es/dist/esm/index.js +1 -0
- package/plugins/{beta/draw-es → draw-es}/src/DrawInit.jsx +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/events.test.js +1 -1
- package/plugins/{beta/draw-es → draw-es}/src/graphic.js +1 -1
- package/plugins/frame/dist/esm/index.js +1 -0
- package/plugins/{beta/frame → frame}/dist/umd/im-frame-plugin.js +1 -1
- package/plugins/{beta/frame → frame}/dist/umd/index.js +1 -1
- package/plugins/{beta/frame → frame}/package.json +2 -2
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +3 -3
- package/plugins/interact/src/api/enable.test.js +13 -0
- package/plugins/interact/src/defaults.js +1 -0
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +27 -17
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +72 -7
- package/plugins/interact/src/hooks/useInteractionHandlers.js +3 -5
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +4 -3
- package/plugins/interact/src/hooks/useSpatialList.js +16 -17
- package/plugins/interact/src/hooks/useSpatialList.test.js +9 -9
- package/plugins/interact/src/manifest.js +4 -4
- package/plugins/interact/src/manifest.test.js +29 -0
- package/plugins/interact/src/reducer.js +7 -2
- package/plugins/interact/src/reducer.test.js +12 -2
- package/plugins/interact/src/utils/needsTarget.js +20 -0
- package/plugins/interact/src/utils/needsTarget.test.js +36 -0
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/esm/index.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/KeySvgSymbol.jsx +4 -0
- package/plugins/map-key/src/components/Key/MapKey.jsx +15 -15
- package/plugins/map-key/src/components/Key/MapKey.test.jsx +29 -15
- package/plugins/map-key/src/initialise/MapKeyInit.jsx +5 -8
- package/plugins/map-key/src/initialise/MapKeyInit.test.jsx +9 -7
- package/plugins/map-key/src/manifest.test.js +0 -1
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.js +14 -33
- package/plugins/map-key/src/reducers/mergeKeyGroupItems.test.js +34 -50
- package/plugins/map-key/src/reducers/pluginState.js +6 -1
- package/plugins/map-key/src/reducers/pluginState.test.js +13 -4
- package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
- package/plugins/map-styles/dist/esm/index.js +1 -0
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/{beta/map-styles → map-styles}/dist/umd/index.js +1 -1
- package/plugins/{beta/map-styles → map-styles}/src/MapStyles.jsx +3 -3
- package/plugins/{beta/map-styles → map-styles}/src/MapStylesInit.jsx +1 -1
- package/plugins/menu/dist/esm/index.js +1 -1
- package/plugins/scale-bar/dist/esm/index.js +1 -0
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/im-scale-bar-plugin.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/dist/umd/index.js +1 -1
- package/plugins/{beta/scale-bar → scale-bar}/package.json +2 -2
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +3 -1
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +11 -0
- package/plugins/search/src/utils/markedToElements.jsx +25 -0
- package/plugins/search/src/utils/markedToElements.test.jsx +49 -0
- package/plugins/search/src/utils/parseOsNamesResults.js +6 -4
- package/plugins/search/src/utils/parseOsNamesResults.test.js +18 -0
- package/plugins/use-location/dist/esm/index.js +1 -0
- package/plugins/{beta/use-location → use-location}/dist/umd/im-use-location-plugin.js +1 -1
- package/plugins/{beta/use-location → use-location}/dist/umd/index.js +1 -1
- package/providers/esri/dist/esm/index.js +1 -0
- package/providers/{beta/esri → esri}/src/esriProvider.js +1 -1
- package/providers/{beta/esri → esri}/src/mapEvents.js +2 -2
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/index.js +11 -2
- package/providers/maplibre/src/index.test.js +23 -1
- package/providers/maplibre/src/utils/detectModuleWorker.js +8 -19
- package/providers/maplibre/src/utils/detectModuleWorker.test.js +19 -23
- package/providers/maplibre/src/utils/workerUrl.js +12 -0
- package/providers/maplibre/src/utils/workerUrl.test.js +14 -1
- package/providers/open-names/dist/esm/index.js +1 -0
- package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js +1 -1
- package/providers/{beta/open-names → open-names}/dist/umd/index.js +1 -1
- package/providers/openlayers/dist/esm/index.js +1 -0
- package/providers/openlayers/dist/umd/im-openlayers-provider.js +2 -0
- package/providers/{beta/openlayers → openlayers}/dist/umd/index.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/index.js +4 -4
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/mapEvents.test.js +2 -2
- package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.js +3 -3
- package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.js +1 -1
- package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.js +1 -1
- package/rollup.esm.mjs +43 -47
- package/sonar-project.properties +1 -1
- package/src/App/App.jsx +4 -1
- package/src/App/App.test.jsx +6 -0
- package/src/App/components/MapButton/MapButton.jsx +6 -0
- package/src/App/components/MapButton/MapButton.test.jsx +10 -0
- package/src/App/components/Markers/Markers.jsx +3 -5
- package/src/App/components/Markers/Markers.test.jsx +9 -11
- package/src/App/components/Panel/Panel.jsx +2 -9
- package/src/App/hooks/useInterfaceAPI.js +16 -4
- package/src/App/hooks/useInterfaceAPI.test.js +66 -1
- package/src/App/renderer/PluginInits.jsx +8 -7
- package/src/App/renderer/PluginInits.test.jsx +20 -5
- package/src/App/renderer/SlotItemsProvider.jsx +33 -0
- package/src/App/renderer/SlotItemsProvider.test.jsx +59 -0
- package/src/App/renderer/SlotRenderer.jsx +3 -14
- package/src/App/renderer/SlotRenderer.test.jsx +11 -44
- package/src/App/renderer/mapButtons.js +24 -12
- package/src/App/renderer/mapButtons.test.js +32 -1
- package/src/App/renderer/mapControls.js +6 -8
- package/src/App/renderer/mapControls.test.js +10 -0
- package/src/App/renderer/mapPanels.js +16 -19
- package/src/App/renderer/mapPanels.test.js +37 -9
- package/src/App/renderer/pluginWrapper.js +10 -8
- package/src/App/renderer/pluginWrapper.test.js +23 -9
- package/src/App/renderer/slotAggregator.js +18 -5
- package/src/App/renderer/slotAggregator.test.js +68 -25
- package/src/App/renderer/slotHelpers.js +13 -0
- package/src/App/renderer/slotHelpers.test.js +16 -1
- package/src/App/store/AppProvider.jsx +19 -1
- package/src/App/store/AppProvider.test.jsx +41 -0
- package/src/App/store/MapProvider.jsx +3 -0
- package/src/App/store/MapProvider.test.jsx +24 -0
- package/src/App/store/appActionsMap.js +10 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appDispatchMiddleware.js +29 -17
- package/src/App/store/appDispatchMiddleware.test.js +31 -0
- package/src/InteractiveMap/parseDataProperties.js +4 -4
- package/src/InteractiveMap/parseDataProperties.test.js +62 -6
- package/src/config/events.js +4 -2
- package/src/config/mapSizeScales.js +3 -0
- package/src/scss/tools/_govuk-content.scss +4 -3
- package/src/types.js +4 -0
- package/src/utils/focusAfterPanelClose.js +9 -0
- package/src/utils/focusAfterPanelClose.test.js +40 -0
- package/webpack.dev.mjs +9 -3
- package/webpack.prod.mjs +11 -4
- package/webpack.umd.mjs +6 -7
- package/plugins/beta/draw-es/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/beta/draw-ml/dist/umd/index.js +0 -2
- package/plugins/beta/draw-ml/src/DrawInit.jsx +0 -85
- package/plugins/beta/draw-ml/src/api/addFeature.js +0 -27
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +0 -13
- package/plugins/beta/draw-ml/src/api/editFeature.js +0 -75
- package/plugins/beta/draw-ml/src/api/merge.js +0 -9
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -68
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -68
- package/plugins/beta/draw-ml/src/api/split.js +0 -81
- package/plugins/beta/draw-ml/src/defaults.js +0 -17
- package/plugins/beta/draw-ml/src/draw.scss +0 -26
- package/plugins/beta/draw-ml/src/events.js +0 -185
- package/plugins/beta/draw-ml/src/index.js +0 -13
- package/plugins/beta/draw-ml/src/manifest.js +0 -110
- package/plugins/beta/draw-ml/src/mapboxDraw.js +0 -143
- package/plugins/beta/draw-ml/src/mapboxSnap.js +0 -321
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +0 -552
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +0 -23
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +0 -18
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +0 -16
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +0 -135
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +0 -2
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +0 -133
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +0 -142
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +0 -121
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +0 -495
- package/plugins/beta/draw-ml/src/reducer.js +0 -90
- package/plugins/beta/draw-ml/src/styles.js +0 -190
- package/plugins/beta/draw-ml/src/undoStack.js +0 -50
- package/plugins/beta/draw-ml/src/utils/debounce.js +0 -16
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +0 -49
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +0 -200
- package/plugins/beta/draw-ml/src/utils/spatial.js +0 -258
- package/plugins/beta/draw-ol/dist/css/index.css +0 -1
- package/plugins/beta/draw-ol/dist/esm/DrawMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/EditMode.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/geometryHelpers.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +0 -1
- package/plugins/beta/draw-ol/dist/esm/index.js +0 -1
- package/plugins/beta/draw-ol/src/DrawInit.jsx +0 -65
- package/plugins/beta/draw-ol/src/api/addFeature.js +0 -29
- package/plugins/beta/draw-ol/src/api/deleteFeature.js +0 -11
- package/plugins/beta/draw-ol/src/api/editFeature.js +0 -50
- package/plugins/beta/draw-ol/src/api/newLine.js +0 -44
- package/plugins/beta/draw-ol/src/api/newPolygon.js +0 -44
- package/plugins/beta/draw-ol/src/core/OLDrawManager.js +0 -153
- package/plugins/beta/draw-ol/src/core/featureStore.js +0 -65
- package/plugins/beta/draw-ol/src/core/styles.js +0 -98
- package/plugins/beta/draw-ol/src/core/undoStack.js +0 -31
- package/plugins/beta/draw-ol/src/defaults.js +0 -16
- package/plugins/beta/draw-ol/src/draw/DrawMode.js +0 -121
- package/plugins/beta/draw-ol/src/draw/drawInput.js +0 -243
- package/plugins/beta/draw-ol/src/draw.scss +0 -17
- package/plugins/beta/draw-ol/src/edit/EditMode.js +0 -424
- package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +0 -229
- package/plugins/beta/draw-ol/src/edit/midpointLayer.js +0 -57
- package/plugins/beta/draw-ol/src/edit/touchHandler.js +0 -171
- package/plugins/beta/draw-ol/src/edit/undoOps.js +0 -95
- package/plugins/beta/draw-ol/src/edit/vertexHitTest.js +0 -72
- package/plugins/beta/draw-ol/src/edit/vertexLayer.js +0 -49
- package/plugins/beta/draw-ol/src/edit/vertexOps.js +0 -99
- package/plugins/beta/draw-ol/src/events.js +0 -114
- package/plugins/beta/draw-ol/src/index.js +0 -12
- package/plugins/beta/draw-ol/src/manifest.js +0 -125
- package/plugins/beta/draw-ol/src/olDraw.js +0 -38
- package/plugins/beta/draw-ol/src/reducer.js +0 -41
- package/plugins/beta/draw-ol/src/snap/snapEngine.js +0 -153
- package/plugins/beta/draw-ol/src/snap/snapGeometry.js +0 -177
- package/plugins/beta/draw-ol/src/snap/snapIndicator.js +0 -81
- package/plugins/beta/draw-ol/src/snap/snapInteraction.js +0 -57
- package/plugins/beta/draw-ol/src/snap/snapManager.js +0 -99
- package/plugins/beta/draw-ol/src/utils/flattenStyleProperties.js +0 -47
- package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +0 -103
- package/plugins/beta/draw-ol/src/utils/olCoords.js +0 -35
- package/plugins/beta/draw-ol/src/utils/resolveColors.js +0 -39
- package/plugins/beta/draw-ol/src/utils/spatial.js +0 -24
- package/plugins/beta/draw-ol/src/utils/touchTarget.js +0 -61
- package/plugins/beta/frame/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/beta/map-styles/dist/esm/index.js +0 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/beta/scale-bar/dist/esm/index.js +0 -1
- package/plugins/beta/use-location/dist/esm/index.js +0 -1
- package/plugins/map-key/src/registry/getDatasetRegistry.js +0 -6
- package/plugins/map-key/src/registry/getDatasetRegistry.test.js +0 -23
- package/plugins/map-key/src/registry/index.js +0 -1
- package/plugins/map-key/src/registry/index.test.js +0 -7
- package/providers/beta/esri/dist/esm/index.js +0 -1
- package/providers/beta/open-names/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/esm/index.js +0 -1
- package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +0 -2
- package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +0 -1
- /package/plugins/{beta/draw-es → draw-es}/dist/esm/im-draw-es-plugin.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/api/removeSafeZone.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/events.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/index.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/manifest.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/reducer.js +0 -0
- /package/plugins/{beta/draw-es → draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{beta/frame → frame}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → frame}/dist/esm/im-frame-plugin.js +0 -0
- /package/plugins/{beta/draw-ml → frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/frame → frame}/src/Frame.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{beta/frame → frame}/src/api/addFrame.js +0 -0
- /package/plugins/{beta/frame → frame}/src/api/editFeature.js +0 -0
- /package/plugins/{beta/frame → frame}/src/config.js +0 -0
- /package/plugins/{beta/frame → frame}/src/frame.scss +0 -0
- /package/plugins/{beta/frame → frame}/src/index.js +0 -0
- /package/plugins/{beta/frame → frame}/src/manifest.js +0 -0
- /package/plugins/{beta/frame → frame}/src/reducer.js +0 -0
- /package/plugins/{beta/frame → frame}/src/utils.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/dist/css/index.css +0 -0
- /package/plugins/{beta/frame → map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/config.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/index.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/manifest.js +0 -0
- /package/plugins/{beta/map-styles → map-styles}/src/mapStyles.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/dist/esm/im-scale-bar-plugin.js +0 -0
- /package/plugins/{beta/map-styles → scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/index.test.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/manifest.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.js +0 -0
- /package/plugins/{beta/scale-bar → scale-bar}/src/utils.test.js +0 -0
- /package/plugins/{beta/use-location → use-location}/dist/esm/im-use-location-plugin.js +0 -0
- /package/plugins/{beta/scale-bar → use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{beta/use-location → use-location}/src/defaults.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/events.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/index.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/manifest.js +0 -0
- /package/plugins/{beta/use-location → use-location}/src/reducer.js +0 -0
- /package/providers/{beta/esri → esri}/dist/css/index.css +0 -0
- /package/providers/{beta/esri → esri}/dist/esm/im-esri-provider.js +0 -0
- /package/providers/{beta/esri → esri}/src/appEvents.js +0 -0
- /package/providers/{beta/esri → esri}/src/defaults.js +0 -0
- /package/providers/{beta/esri → esri}/src/esriProvider.scss +0 -0
- /package/providers/{beta/esri → esri}/src/index.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/coords.test.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/query.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.js +0 -0
- /package/providers/{beta/esri → esri}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/esm/im-reverse-geocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/dist/umd/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/{plugins/beta/use-location → providers/open-names}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → open-names}/src/index.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.js +0 -0
- /package/providers/{beta/open-names → open-names}/src/utils/mapToLocationModel.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/esm/im-openlayers-provider.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/dist/umd/im-openlayers-provider.js.LICENSE.txt +0 -0
- /package/providers/{beta/open-names → openlayers}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/appEvents.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/defaults.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/index.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/openlayersProvider.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/bngProjection.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/filterEvaluator.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/highlightFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/hoverCursor.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/openLayersFixes.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/patternImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/queryFeatures.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/spatial.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/symbolImages.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/tileLayers.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/vtTileFragments.test.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.js +0 -0
- /package/providers/{beta/openlayers → openlayers}/src/utils/zoom.test.js +0 -0
|
@@ -6,23 +6,33 @@
|
|
|
6
6
|
* All MapLibre / OL specifics live in the adapter.
|
|
7
7
|
*/
|
|
8
8
|
import { ADAPTER_EVENTS } from './adapterEvents.js'
|
|
9
|
-
import {
|
|
9
|
+
import { getCommitChecks, isSameGeometry } from './validation/commitChecks.js'
|
|
10
10
|
import { MIN_VERTICES_REASONS } from './validation/rules.js'
|
|
11
|
-
import { MAP_SIZE_SCALES } from './defaults.js'
|
|
12
11
|
import { stripInternalProperties } from './utils/stripInternalProperties.js'
|
|
12
|
+
import { isEditMode, isCheckedMode } from './utils/drawModes.js'
|
|
13
13
|
|
|
14
14
|
const EDIT_VERTEX_MODE = 'edit_vertex'
|
|
15
15
|
const GEOMETRY_INVALID_EVENT = 'draw:geometryinvalid'
|
|
16
|
+
const CREATED_EVENT = 'draw:created'
|
|
16
17
|
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// A shape that finished without a passing check is reopened in edit mode, and its
|
|
19
|
+
// eventual edit-finish must report as a creation. Kept per draw adapter, not in
|
|
20
|
+
// createHandlers, which is rebuilt on every plugin state change.
|
|
21
|
+
const pendingCreateIds = new WeakMap()
|
|
22
|
+
|
|
23
|
+
// While editing, Done pressed during a pending check waits for that check (by revision): the
|
|
24
|
+
// edit finishes if it passes, and stays open if it fails or the shape changes again. Kept
|
|
25
|
+
// apart from a held new shape, which a new session discards — an edited feature must stay.
|
|
26
|
+
const editFinishRevisions = new WeakMap()
|
|
27
|
+
|
|
28
|
+
// A result can ask for the shape to be checked again once it's finished (recheckOnFinish),
|
|
29
|
+
// e.g. when the consumer skips its own check while drawing. Ignored on that finishing check.
|
|
30
|
+
const FINISH_PHASES = new Set(['create', 'edit-finish'])
|
|
31
|
+
const wantsRecheckOnFinish = ({ result, context }) => !!result?.recheckOnFinish && !FINISH_PHASES.has(context?.phase)
|
|
22
32
|
|
|
23
33
|
// A shape that simply hasn't reached its minimum vertex count yet isn't a mistake —
|
|
24
34
|
// it's the normal, expected state of "still being drawn" — so it's excluded below
|
|
25
|
-
// even though it's a genuine
|
|
35
|
+
// even though it's a genuine COMMIT_RULES failure like any other.
|
|
26
36
|
const isIncompleteShape = (reason) => Object.values(MIN_VERTICES_REASONS).includes(reason)
|
|
27
37
|
|
|
28
38
|
// A discrete, one-shot invalid result (a rejected placement, a finished-but-invalid
|
|
@@ -31,9 +41,10 @@ const isIncompleteShape = (reason) => Object.values(MIN_VERTICES_REASONS).includ
|
|
|
31
41
|
// alongside the existing public event, so the reason is visible without every
|
|
32
42
|
// consumer having to wire up their own listener for it. The public event still
|
|
33
43
|
// fires either way — only the hint is skipped for an incomplete shape.
|
|
34
|
-
|
|
44
|
+
// A result with its own `announcement` is presented by the consumer, so it gets no hint.
|
|
45
|
+
const createGeometryInvalidEmitter = (eventBus, hints) => ({ announcement, ...payload }) => {
|
|
35
46
|
eventBus.emit(GEOMETRY_INVALID_EVENT, payload)
|
|
36
|
-
if (payload.reason && !isIncompleteShape(payload.reason)) { hints.show(payload.reason) }
|
|
47
|
+
if (!announcement && payload.reason && !isIncompleteShape(payload.reason)) { hints.show(payload.reason) }
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
// Claims MapControls' D-pad for the currently selected vertex — see the generic
|
|
@@ -58,44 +69,236 @@ const createVertexSelectionHandlers = ({ draw, pluginState, mapProvider, eventBu
|
|
|
58
69
|
}
|
|
59
70
|
})
|
|
60
71
|
|
|
61
|
-
// Re-open a feature in
|
|
62
|
-
// Mirrors the options built by api/editFeature.js. Edit-mode Done is
|
|
63
|
-
// same
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
// Re-open a feature in edit mode (used when a drawn shape finishes and its check is
|
|
73
|
+
// invalid or errored). Mirrors the options built by api/editFeature.js. Edit-mode Done is
|
|
74
|
+
// gated by the same check, so the shape can't be finished until it passes.
|
|
75
|
+
// Emits draw:reopened so a consumer knows to show the shape's issues.
|
|
76
|
+
const enterEditMode = ({ draw, appState, appConfig, mapState, dispatch, eventBus }, featureId, geometryType) => {
|
|
77
|
+
const mode = geometryType === 'Point' ? 'edit_point' : EDIT_VERTEX_MODE
|
|
78
|
+
draw.changeMode(mode, {
|
|
66
79
|
container: appState?.layoutRefs?.viewportRef?.current,
|
|
67
80
|
deleteVertexButtonId: `${appConfig?.id}-draw-delete-point`,
|
|
68
81
|
undoButtonId: `${appConfig?.id}-draw-undo`,
|
|
69
82
|
isPanEnabled: appState?.interfaceType !== 'keyboard',
|
|
70
83
|
interfaceType: appState?.interfaceType,
|
|
71
|
-
scale:
|
|
84
|
+
scale: mapState?.mapSizeScale,
|
|
72
85
|
featureId,
|
|
73
86
|
getSnapEnabled: () => draw.isSnapEnabled()
|
|
74
87
|
})
|
|
75
88
|
const editing = draw.get(featureId)
|
|
89
|
+
const { status, result } = getCommitChecks(draw).state
|
|
76
90
|
dispatch({ type: 'SET_FEATURE', payload: { feature: editing, tempFeature: editing } })
|
|
77
|
-
dispatch({ type: 'SET_MODE', payload:
|
|
78
|
-
dispatch({ type: '
|
|
79
|
-
draw.
|
|
80
|
-
draw.setInvalid?.(
|
|
91
|
+
dispatch({ type: 'SET_MODE', payload: mode })
|
|
92
|
+
dispatch({ type: 'SET_VALIDATION_STATUS', payload: status })
|
|
93
|
+
draw.setCanFinish?.(status === 'valid' || status === 'pending')
|
|
94
|
+
draw.setInvalid?.(status === 'invalid')
|
|
95
|
+
eventBus.emit('draw:reopened', { feature: stripInternalProperties(editing), status, reason: result?.reason ?? null })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Screen reader messages for a slow check (see SLOW_CHECK_MS). A check that settles quickly
|
|
99
|
+
// says nothing new — Done enabling, or the hint for a failure, is enough. A result's own
|
|
100
|
+
// `announcement` replaces these, however quickly it settles.
|
|
101
|
+
const CHECK_MESSAGES = {
|
|
102
|
+
pending: 'Checking shape',
|
|
103
|
+
valid: 'Shape check passed',
|
|
104
|
+
invalid: 'Shape check failed',
|
|
105
|
+
error: 'Shape could not be checked'
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Announced as an 'action' so a run of quick changes collapses to the latest message,
|
|
109
|
+
// and so the failure hint's own ambient announcement yields rather than repeating it.
|
|
110
|
+
const announceCheck = (announce, { status, result, slow, afterPending }) => {
|
|
111
|
+
if (result?.announcement) {
|
|
112
|
+
announce?.(result.announcement, 'action')
|
|
113
|
+
} else if (status === 'pending') {
|
|
114
|
+
if (slow) { announce?.(CHECK_MESSAGES.pending, 'action') }
|
|
115
|
+
} else if (afterPending) {
|
|
116
|
+
announce?.((status === 'invalid' && result.reason) || CHECK_MESSAGES[status], 'action')
|
|
117
|
+
} else {
|
|
118
|
+
// Settled straight away
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Applies each settled commit-level check (validation/commitChecks.js). Only the
|
|
123
|
+
// latest revision ever reaches here, so a stale reply can't change the Done gate.
|
|
124
|
+
const createCheckStateHandler = ({ draw, dispatch, emitGeometryInvalid, announce }) => (state) => {
|
|
125
|
+
const { status, result, context, feature } = state
|
|
126
|
+
const valid = status === 'valid'
|
|
127
|
+
// A slow check is the same pending check, now shown as "Checking…"
|
|
128
|
+
dispatch(state.slow ? { type: 'SET_CHECK_SLOW' } : { type: 'SET_VALIDATION_STATUS', payload: status })
|
|
129
|
+
announceCheck(announce, state)
|
|
130
|
+
// Also blocks the adapters' finish gestures (double-click, clicking the first vertex)
|
|
131
|
+
// while the check is failing. A shape finished while its check is pending is held
|
|
132
|
+
// until it settles (see createFinishHandlers).
|
|
133
|
+
draw.setCanFinish?.(valid || status === 'pending')
|
|
134
|
+
if (status === 'pending' || status === 'error') { return }
|
|
135
|
+
// The invalid stroke is committed-validity-driven in edit mode only; in draw mode the
|
|
136
|
+
// adapters drive it live from the displayed geometry (placed vertices + cursor).
|
|
137
|
+
if (isEditMode(draw.getMode())) {
|
|
138
|
+
draw.setInvalid?.(!valid)
|
|
139
|
+
}
|
|
140
|
+
// edit-start is the baseline check on opening a feature, not a change the user made
|
|
141
|
+
if (!valid && context?.phase !== 'edit-start') {
|
|
142
|
+
const { reason, source, announcement } = result
|
|
143
|
+
emitGeometryInvalid({ reason, source, announcement, ...context, feature: stripInternalProperties(feature) })
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Finishing a new shape: created when its check passes, otherwise reopened in edit mode.
|
|
148
|
+
// A shape finished while its check is pending is held until it settles, with Done reading
|
|
149
|
+
// "Checking…" — for a point, Done shows just for that.
|
|
150
|
+
function createFinishHandlers ({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }) {
|
|
151
|
+
const checks = getCommitChecks(draw)
|
|
152
|
+
|
|
153
|
+
const create = (f) => {
|
|
154
|
+
resetState()
|
|
155
|
+
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
156
|
+
eventBus.emit(CREATED_EVENT, stripInternalProperties(f))
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const reopen = (featureId, geometryType) => {
|
|
160
|
+
pendingCreateIds.set(draw, featureId)
|
|
161
|
+
setTimeout(() => enterEditMode({ draw, appState, appConfig, mapState, dispatch, eventBus }, featureId, geometryType), 0)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// The map leaves draw mode; Done stays, disabled and reading "Checking…" once the check is slow
|
|
165
|
+
const hold = (featureId) => {
|
|
166
|
+
checks.hold(featureId)
|
|
167
|
+
dispatch({ type: 'SET_HOLDING', payload: true })
|
|
168
|
+
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// A shape can be finished by the Done button OR a map gesture (double-click, clicking
|
|
172
|
+
// the first vertex, Enter), so the latest check is re-applied here — a shape without a
|
|
173
|
+
// passing check must never be finalised. A passing or still-pending result for this
|
|
174
|
+
// same geometry is reused, so finishing doesn't repeat a server call; otherwise (a
|
|
175
|
+
// point, which has no commits before it's created, a failed result, or a result asking
|
|
176
|
+
// for recheckOnFinish) the shape is checked now with phase 'create'.
|
|
177
|
+
const checkFinished = (f) => {
|
|
178
|
+
const { status, feature: checkedFeature } = checks.state
|
|
179
|
+
const isReusable = (status === 'valid' || status === 'pending') && isSameGeometry(checkedFeature, f) && !wantsRecheckOnFinish(checks.state)
|
|
180
|
+
if (!isReusable) {
|
|
181
|
+
checks.run({ feature: f, context: { phase: 'create', mode: draw.getMode() }, onGeometryChange: draw._commitValidator })
|
|
182
|
+
}
|
|
183
|
+
return checks.state
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const finish = (f) => {
|
|
187
|
+
const state = checkFinished(f)
|
|
188
|
+
if (state.status === 'valid') {
|
|
189
|
+
create(f)
|
|
190
|
+
} else if (state.status === 'pending') {
|
|
191
|
+
hold(f.id)
|
|
192
|
+
} else {
|
|
193
|
+
reopen(f.id, f.geometry?.type)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
onCreate: finish,
|
|
199
|
+
// A held shape is created once its check passes, or reopened in edit mode. A result that
|
|
200
|
+
// asks for recheckOnFinish, unknown until the pending check settled, is checked again.
|
|
201
|
+
onCheckSettled: (state) => {
|
|
202
|
+
const heldId = checks.heldId
|
|
203
|
+
if (heldId === undefined || state.status === 'pending') { return }
|
|
204
|
+
checks.release()
|
|
205
|
+
const finished = draw.get(heldId)
|
|
206
|
+
if (wantsRecheckOnFinish(state)) {
|
|
207
|
+
finish(finished)
|
|
208
|
+
} else if (state.status === 'valid') {
|
|
209
|
+
create(finished)
|
|
210
|
+
} else {
|
|
211
|
+
reopen(heldId, finished?.geometry?.type)
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
onEditFinish: (f) => {
|
|
215
|
+
resetState()
|
|
216
|
+
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
217
|
+
// A shape that was drawn-then-fixed reports as a creation, not an edit.
|
|
218
|
+
if (pendingCreateIds.get(draw) === f.id) {
|
|
219
|
+
pendingCreateIds.delete(draw)
|
|
220
|
+
eventBus.emit(CREATED_EVENT, stripInternalProperties(f))
|
|
221
|
+
} else {
|
|
222
|
+
eventBus.emit('draw:edited', stripInternalProperties(f))
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
81
226
|
}
|
|
82
227
|
|
|
83
|
-
|
|
228
|
+
// Done, and finishing an edit: pressed while editing with a check pending, Done waits for
|
|
229
|
+
// that check (see editFinishRevisions above) instead of finishing straight away. A result
|
|
230
|
+
// that asks for recheckOnFinish is checked again first, with phase 'edit-finish'.
|
|
231
|
+
function createEditFinishHandlers ({ draw, dispatch }) {
|
|
232
|
+
const checks = getCommitChecks(draw)
|
|
233
|
+
|
|
234
|
+
const waitFor = (revision) => {
|
|
235
|
+
editFinishRevisions.set(draw, revision)
|
|
236
|
+
dispatch({ type: 'SET_HOLDING', payload: true })
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const finishEdit = (state) => {
|
|
240
|
+
if (state.status === 'pending') {
|
|
241
|
+
waitFor(state.revision)
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
if (!wantsRecheckOnFinish(state)) {
|
|
245
|
+
draw.done()
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
checks.run({ feature: state.feature, context: { phase: 'edit-finish', mode: draw.getMode() }, onGeometryChange: draw._commitValidator })
|
|
249
|
+
const next = checks.state
|
|
250
|
+
if (next.status === 'pending') {
|
|
251
|
+
waitFor(next.revision)
|
|
252
|
+
} else if (next.status === 'valid') {
|
|
253
|
+
draw.done()
|
|
254
|
+
} else {
|
|
255
|
+
dispatch({ type: 'SET_HOLDING', payload: false })
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
handleDone: () => {
|
|
261
|
+
if (isEditMode(draw.getMode())) {
|
|
262
|
+
finishEdit(checks.state)
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
draw.done()
|
|
266
|
+
},
|
|
267
|
+
onEditCheckSettled: (state) => {
|
|
268
|
+
if (!editFinishRevisions.has(draw)) { return }
|
|
269
|
+
const isAwaitedCheck = editFinishRevisions.get(draw) === state.revision
|
|
270
|
+
if (isAwaitedCheck && state.status === 'pending') { return }
|
|
271
|
+
editFinishRevisions.delete(draw)
|
|
272
|
+
if (isAwaitedCheck && state.status === 'valid') {
|
|
273
|
+
finishEdit(state)
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
dispatch({ type: 'SET_HOLDING', payload: false })
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, emitGeometryInvalid, announce, resetState }) {
|
|
84
282
|
const { draw } = mapProvider
|
|
85
|
-
const emitGeometryInvalid = createGeometryInvalidEmitter(eventBus, hints)
|
|
86
283
|
const { feature, tempFeature } = pluginState
|
|
87
284
|
const { dispatch } = pluginState
|
|
88
|
-
|
|
89
|
-
// edit-finish must report as a creation, not an edit.
|
|
90
|
-
let pendingCreateId = null
|
|
285
|
+
const checks = getCommitChecks(draw)
|
|
91
286
|
|
|
92
287
|
return {
|
|
93
|
-
|
|
288
|
+
...createEditFinishHandlers({ draw, dispatch }),
|
|
94
289
|
handleCancel: () => {
|
|
95
290
|
const mode = draw.getMode()
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
291
|
+
const isEditing = isEditMode(mode) && !!tempFeature?.id
|
|
292
|
+
const isReopened = isEditing && pendingCreateIds.get(draw) === tempFeature.id
|
|
293
|
+
// A new shape that's finished but not yet created (held, or reopened for fixing) has
|
|
294
|
+
// no earlier version to restore, so it's discarded
|
|
295
|
+
const unfinishedId = checks.heldId ?? (isReopened ? tempFeature.id : undefined)
|
|
296
|
+
if (isEditing && !isReopened) { draw.add(feature) }
|
|
297
|
+
pendingCreateIds.delete(draw)
|
|
298
|
+
checks.release()
|
|
299
|
+
draw.cancel()
|
|
300
|
+
if (unfinishedId !== undefined) { draw.delete(unfinishedId) }
|
|
301
|
+
resetState()
|
|
99
302
|
eventBus.emit('draw:cancelled', stripInternalProperties(feature))
|
|
100
303
|
},
|
|
101
304
|
handleUndo: () => draw.undo(),
|
|
@@ -104,68 +307,41 @@ function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvid
|
|
|
104
307
|
pluginState.dispatch({ type: 'TOGGLE_SNAP' })
|
|
105
308
|
draw.setSnapEnabled(!pluginState.snap)
|
|
106
309
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// clicking the first vertex, Enter). Only the button is gated, so re-validate
|
|
110
|
-
// here to catch the gesture paths — an invalid shape must never be finalised.
|
|
111
|
-
const { valid, reason } = validateGeometry(f, { phase: 'create', mode: draw.getMode() }, { onGeometryChange: draw._geometryValidator })
|
|
112
|
-
if (!valid) {
|
|
113
|
-
pendingCreateId = f.id
|
|
114
|
-
emitGeometryInvalid({ feature: stripInternalProperties(f), reason, phase: 'create', mode: EDIT_VERTEX_MODE })
|
|
115
|
-
setTimeout(() => enterEditVertexMode({ draw, appState, appConfig, mapState, dispatch }, f.id), 0)
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
resetState(); setTimeout(() => draw.changeMode('disabled'), 0); eventBus.emit('draw:created', stripInternalProperties(f))
|
|
119
|
-
},
|
|
120
|
-
onEditFinish: (f) => {
|
|
121
|
-
resetState()
|
|
122
|
-
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
123
|
-
// A shape that was drawn-then-fixed reports as a creation, not an edit.
|
|
124
|
-
if (pendingCreateId && f.id === pendingCreateId) {
|
|
125
|
-
pendingCreateId = null
|
|
126
|
-
eventBus.emit('draw:created', stripInternalProperties(f))
|
|
127
|
-
} else {
|
|
128
|
-
eventBus.emit('draw:edited', stripInternalProperties(f))
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
onCancel: () => {},
|
|
310
|
+
onCancel: () => { checks.reset() },
|
|
311
|
+
...createFinishHandlers({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }),
|
|
132
312
|
...createVertexSelectionHandlers({ draw, pluginState, mapProvider, eventBus }),
|
|
133
313
|
onUndoChange: (l) => { pluginState.dispatch({ type: 'SET_UNDO_STACK_LENGTH', payload: l }) },
|
|
134
314
|
onUpdate: (f) => { eventBus.emit('draw:updated', stripInternalProperties(f)) },
|
|
135
315
|
onGeometryChange: (e) => {
|
|
136
|
-
// Only commit-level changes
|
|
316
|
+
// Only commit-level changes carry a `phase` ('change').
|
|
137
317
|
// Preview events (e.g. split's live preview) have none and are ignored.
|
|
138
318
|
if (!e?.phase) { return }
|
|
139
319
|
|
|
320
|
+
// A commit that lands after the session has ended (the adapters defer them a tick)
|
|
321
|
+
// is dropped rather than calling onGeometryChange.
|
|
140
322
|
const mode = draw.getMode()
|
|
141
|
-
|
|
142
|
-
const { valid, reason } = validateGeometry(e.feature, context, { onGeometryChange: draw._geometryValidator })
|
|
323
|
+
if (!isCheckedMode(mode)) { return }
|
|
143
324
|
|
|
144
325
|
// Rules only gate the Done button — never revert. A shape can pass through
|
|
145
|
-
// interim invalid states while being built or reshaped.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
draw.setInvalid?.(!valid)
|
|
153
|
-
}
|
|
154
|
-
if (!valid) {
|
|
155
|
-
emitGeometryInvalid({ reason, ...context, feature: stripInternalProperties(e.feature) })
|
|
156
|
-
}
|
|
326
|
+
// interim invalid states while being built or reshaped. The result is applied
|
|
327
|
+
// by the check-state handler once it settles.
|
|
328
|
+
checks.run({
|
|
329
|
+
feature: e.feature,
|
|
330
|
+
context: { phase: e.phase, vertexIndex: e.vertexIndex, mode },
|
|
331
|
+
onGeometryChange: draw._commitValidator
|
|
332
|
+
})
|
|
157
333
|
},
|
|
158
|
-
// A vertex placement was rejected (
|
|
334
|
+
// A vertex placement was rejected (placement rule or user callback veto). Surface it
|
|
159
335
|
// on the public bus with phase 'place', and as a hint toast, so the reason is visible.
|
|
160
336
|
onPlacementBlocked: (e) => {
|
|
337
|
+
if (e.announcement) { announce?.(e.announcement, 'action') }
|
|
161
338
|
emitGeometryInvalid({ ...e, feature: stripInternalProperties(e.feature) })
|
|
162
339
|
},
|
|
163
340
|
// Live (mid-drag) validity flip while editing — the displayed shape is exactly
|
|
164
|
-
// what Done finishes there, so it gates the Done button in real time
|
|
165
|
-
// by the adapters' edit wiring only, on flips only.
|
|
341
|
+
// what Done finishes there, so it gates the Done button in real time alongside
|
|
342
|
+
// the commit-level check. Emitted by the adapters' edit wiring only, on flips only.
|
|
166
343
|
onValidityChange: (e) => {
|
|
167
|
-
pluginState.dispatch({ type: '
|
|
168
|
-
draw.setGeometryValid?.(e.valid)
|
|
344
|
+
pluginState.dispatch({ type: 'SET_PREVIEW_VALID', payload: e.valid })
|
|
169
345
|
},
|
|
170
346
|
// Live placement-veto flip while drawing — gates the Add point button so it
|
|
171
347
|
// never looks active when a tap would be rejected.
|
|
@@ -228,7 +404,7 @@ function detachDrawEvents (draw, handlers) {
|
|
|
228
404
|
draw.off(ADAPTER_EVENTS.INTERFACE_TYPE_CHANGE, handlers.onInterfaceTypeChange)
|
|
229
405
|
}
|
|
230
406
|
|
|
231
|
-
export function attachEvents ({ appState, appConfig, mapState, pluginState, mapProvider, buttonConfig, eventBus, hints }) {
|
|
407
|
+
export function attachEvents ({ appState, appConfig, mapState, pluginState, mapProvider, buttonConfig, eventBus, hints, announce }) {
|
|
232
408
|
const { draw } = mapProvider
|
|
233
409
|
const resetState = () => {
|
|
234
410
|
pluginState.dispatch({ type: 'SET_MODE', payload: null })
|
|
@@ -236,9 +412,21 @@ export function attachEvents ({ appState, appConfig, mapState, pluginState, mapP
|
|
|
236
412
|
// Release MapControls' D-pad back to panning the map whenever a draw/edit
|
|
237
413
|
// session ends — a stale claim here would silently hijack it for good.
|
|
238
414
|
mapProvider.activeMoveTarget = null
|
|
415
|
+
// Ends the check session too, so a reply still in flight is dropped, along with any
|
|
416
|
+
// Done that was waiting on it.
|
|
417
|
+
getCommitChecks(draw).reset()
|
|
418
|
+
editFinishRevisions.delete(draw)
|
|
239
419
|
}
|
|
240
|
-
const
|
|
420
|
+
const emitGeometryInvalid = createGeometryInvalidEmitter(eventBus, hints)
|
|
421
|
+
const handlers = createHandlers({ appState, appConfig, mapState, pluginState, mapProvider, eventBus, emitGeometryInvalid, announce, resetState })
|
|
422
|
+
const checks = getCommitChecks(draw)
|
|
423
|
+
const applyCheckState = createCheckStateHandler({ draw, dispatch: pluginState.dispatch, emitGeometryInvalid, announce })
|
|
424
|
+
checks.setOnSettle((state) => {
|
|
425
|
+
applyCheckState(state)
|
|
426
|
+
handlers.onCheckSettled(state)
|
|
427
|
+
handlers.onEditCheckSettled(state)
|
|
428
|
+
})
|
|
241
429
|
attachButtonHandlers(buttonConfig, handlers)
|
|
242
430
|
attachDrawEvents(draw, handlers)
|
|
243
|
-
return () => { detachButtonHandlers(buttonConfig); detachDrawEvents(draw, handlers) }
|
|
431
|
+
return () => { checks.setOnSettle(null); detachButtonHandlers(buttonConfig); detachDrawEvents(draw, handlers) }
|
|
244
432
|
}
|