@defra/interactive-map 0.0.56-alpha → 0.0.58-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/dist/esm/im-core.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 +2 -0
- package/docs/api.md +3 -1
- package/docs/assets/css/docusaurus.scss +7 -1
- package/docs/plugins/draw.md +326 -121
- package/package.json +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.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/initialise/DatasetsInit.jsx +6 -17
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +3 -43
- 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 +9 -6
- package/plugins/draw/src/DrawInit.test.jsx +15 -0
- package/plugins/draw/src/adapterEvents.js +82 -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/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/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 +11 -3
- package/plugins/draw/src/api/newPolygon.test.js +11 -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 +26 -22
- package/plugins/draw/src/api/split.test.js +38 -18
- package/plugins/draw/src/events.js +269 -77
- package/plugins/draw/src/events.test.js +779 -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 +30 -15
- package/plugins/draw/src/manifest.test.js +91 -9
- 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 +1 -5
- package/plugins/draw/src/utils/needsDrawTarget.test.js +1 -11
- 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 +187 -0
- package/plugins/draw/src/validation/commitChecks.test.js +209 -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/interact/dist/esm/im-interact-plugin.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/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/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/map-styles/src/MapStyles.jsx +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/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/mapButtons.js +2 -1
- package/src/App/renderer/mapButtons.test.js +9 -0
- package/src/App/store/MapProvider.jsx +3 -0
- package/src/App/store/MapProvider.test.jsx +24 -0
- package/src/config/mapSizeScales.js +3 -0
- package/src/types.js +4 -0
- package/src/utils/focusAfterPanelClose.js +9 -0
- package/src/utils/focusAfterPanelClose.test.js +40 -0
|
@@ -55,7 +55,6 @@ const makeProps = (overrides = {}) => {
|
|
|
55
55
|
mapProvider: { isBaseMapReady: jest.fn().mockReturnValue(true) },
|
|
56
56
|
services: {
|
|
57
57
|
eventBus: makeEventBus(),
|
|
58
|
-
focusMap: jest.fn(),
|
|
59
58
|
symbolRegistry: {},
|
|
60
59
|
patternRegistry: {}
|
|
61
60
|
},
|
|
@@ -80,20 +79,6 @@ describe('DatasetsInit', () => {
|
|
|
80
79
|
|
|
81
80
|
describe('menu panel management', () => {
|
|
82
81
|
const openPanelState = { openPanels: { datasetsLayers: {} } }
|
|
83
|
-
let panelEl
|
|
84
|
-
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
jest.useFakeTimers()
|
|
87
|
-
panelEl = document.createElement('div')
|
|
88
|
-
panelEl.id = 'test-map-panel-datasets-layers'
|
|
89
|
-
panelEl.tabIndex = -1
|
|
90
|
-
document.body.appendChild(panelEl)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
afterEach(() => {
|
|
94
|
-
panelEl.remove()
|
|
95
|
-
jest.useRealTimers()
|
|
96
|
-
})
|
|
97
82
|
|
|
98
83
|
it('does not remove the panel or hide the button when there is no menu', () => {
|
|
99
84
|
const props = makeProps({ pluginConfig: { datasets: [] } })
|
|
@@ -103,28 +88,13 @@ describe('DatasetsInit', () => {
|
|
|
103
88
|
expect(props.services.eventBus.emit).not.toHaveBeenCalledWith(EVENTS.APP_TOGGLE_BUTTON_STATE, expect.anything())
|
|
104
89
|
})
|
|
105
90
|
|
|
106
|
-
it('closes the open panel
|
|
107
|
-
const props = makeProps({ appState: openPanelState })
|
|
108
|
-
const { eventBus, focusMap } = props.services
|
|
109
|
-
const { rerender } = render(<DatasetsInit {...props} />)
|
|
110
|
-
panelEl.focus()
|
|
111
|
-
|
|
112
|
-
rerender(<DatasetsInit {...props} pluginState={makePluginState()} />)
|
|
113
|
-
expect(eventBus.emit).toHaveBeenCalledWith(EVENTS.APP_HIDE_PANEL, 'datasetsLayers')
|
|
114
|
-
expect(focusMap).not.toHaveBeenCalled()
|
|
115
|
-
act(() => jest.runOnlyPendingTimers())
|
|
116
|
-
expect(focusMap).toHaveBeenCalledTimes(1)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it('closes the open panel without moving focus when focus is outside it', () => {
|
|
91
|
+
it('closes the open panel when the menu empties', () => {
|
|
120
92
|
const props = makeProps({ appState: openPanelState })
|
|
121
|
-
const { eventBus, focusMap } = props.services
|
|
122
93
|
const { rerender } = render(<DatasetsInit {...props} />)
|
|
94
|
+
expect(props.services.eventBus.emit).not.toHaveBeenCalledWith(EVENTS.APP_HIDE_PANEL, 'datasetsLayers')
|
|
123
95
|
|
|
124
96
|
rerender(<DatasetsInit {...props} pluginState={makePluginState()} />)
|
|
125
|
-
|
|
126
|
-
expect(eventBus.emit).toHaveBeenCalledWith(EVENTS.APP_HIDE_PANEL, 'datasetsLayers')
|
|
127
|
-
expect(focusMap).not.toHaveBeenCalled()
|
|
97
|
+
expect(props.services.eventBus.emit).toHaveBeenCalledWith(EVENTS.APP_HIDE_PANEL, 'datasetsLayers')
|
|
128
98
|
})
|
|
129
99
|
|
|
130
100
|
it('closes a panel that is open on load when there is no menu', () => {
|
|
@@ -142,16 +112,6 @@ describe('DatasetsInit', () => {
|
|
|
142
112
|
render(<DatasetsInit {...props} pluginState={pluginState} />)
|
|
143
113
|
expect(props.services.eventBus.emit).not.toHaveBeenCalledWith(EVENTS.APP_HIDE_PANEL, 'datasetsLayers')
|
|
144
114
|
})
|
|
145
|
-
|
|
146
|
-
it('cancels a pending map focus on unmount', () => {
|
|
147
|
-
const props = makeProps({ appState: openPanelState })
|
|
148
|
-
const { rerender, unmount } = render(<DatasetsInit {...props} />)
|
|
149
|
-
panelEl.focus()
|
|
150
|
-
rerender(<DatasetsInit {...props} pluginState={makePluginState()} />)
|
|
151
|
-
unmount()
|
|
152
|
-
act(() => jest.runOnlyPendingTimers())
|
|
153
|
-
expect(props.services.focusMap).not.toHaveBeenCalled()
|
|
154
|
-
})
|
|
155
115
|
})
|
|
156
116
|
|
|
157
117
|
// ─── initialisation ──────────────────────────────────────────────────────────
|