@defra/interactive-map 0.0.57-alpha → 0.0.59-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/docs/assets/css/docusaurus.scss +7 -1
- package/docs/plugins/draw.md +317 -186
- package/package.json +1 -1
- 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/adapterEvents.js +15 -9
- package/plugins/draw/src/adapters/adapterContract.test.js +1 -0
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +15 -3
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +27 -0
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.js +8 -19
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointerHandlers.test.js +20 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +6 -17
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.test.js +19 -0
- package/plugins/draw/src/adapters/maplibre/utils/editModeEvents.js +29 -1
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +13 -3
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +28 -0
- package/plugins/draw/src/api/addFeature.js +9 -6
- package/plugins/draw/src/api/addFeature.test.js +37 -10
- package/plugins/draw/src/api/createNewShape.js +2 -2
- package/plugins/draw/src/api/editFeature.js +1 -1
- package/plugins/draw/src/api/newPoint.js +2 -2
- package/plugins/draw/src/api/newPoint.test.js +8 -0
- package/plugins/draw/src/api/newPolygon.test.js +8 -0
- package/plugins/draw/src/api/recheckGeometry.js +1 -1
- package/plugins/draw/src/api/recheckGeometry.test.js +2 -2
- package/plugins/draw/src/api/setProperties.js +39 -0
- package/plugins/draw/src/api/setProperties.test.js +74 -0
- package/plugins/draw/src/api/setStyle.js +16 -19
- package/plugins/draw/src/api/setStyle.test.js +17 -2
- package/plugins/draw/src/api/split.js +10 -4
- package/plugins/draw/src/api/split.test.js +30 -2
- package/plugins/draw/src/events.js +110 -64
- package/plugins/draw/src/events.test.js +494 -4
- package/plugins/draw/src/manifest.js +6 -4
- package/plugins/draw/src/manifest.test.js +20 -26
- package/plugins/draw/src/reducer.js +7 -0
- package/plugins/draw/src/reducer.test.js +11 -0
- package/plugins/draw/src/utils/flattenStyleProperties.js +54 -2
- package/plugins/draw/src/utils/flattenStyleProperties.test.js +74 -1
- package/plugins/draw/src/utils/isPlainObject.js +14 -0
- package/plugins/draw/src/utils/isPlainObject.test.js +24 -0
- package/plugins/draw/src/utils/mergeFeatureProperties.js +45 -0
- package/plugins/draw/src/utils/mergeFeatureProperties.test.js +48 -0
- package/plugins/draw/src/utils/stripInternalProperties.js +3 -2
- package/plugins/draw/src/validation/commitChecks.js +32 -12
- package/plugins/draw/src/validation/commitChecks.test.js +73 -13
- package/plugins/draw/src/validation/validateGeometry.js +12 -5
- package/plugins/draw/src/validation/validateGeometry.test.js +18 -0
- package/src/App/store/MapProvider.jsx +1 -0
- package/src/App/store/MapProvider.test.jsx +25 -0
- package/src/App/store/mapActionsMap.js +6 -0
- package/src/App/store/mapActionsMap.test.js +7 -0
- package/src/App/store/mapReducer.js +2 -0
- package/src/App/store/mapReducer.test.js +2 -0
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* All MapLibre / OL specifics live in the adapter.
|
|
7
7
|
*/
|
|
8
8
|
import { ADAPTER_EVENTS } from './adapterEvents.js'
|
|
9
|
-
import { getCommitChecks, isSameGeometry } from './validation/commitChecks.js'
|
|
9
|
+
import { getCommitChecks, isSameGeometry, canFinishCheck } from './validation/commitChecks.js'
|
|
10
10
|
import { MIN_VERTICES_REASONS } from './validation/rules.js'
|
|
11
11
|
import { stripInternalProperties } from './utils/stripInternalProperties.js'
|
|
12
|
+
import { mergeFeatureProperties } from './utils/mergeFeatureProperties.js'
|
|
13
|
+
import { mapStyleIds } from './utils/flattenStyleProperties.js'
|
|
12
14
|
import { isEditMode, isCheckedMode } from './utils/drawModes.js'
|
|
13
15
|
|
|
14
16
|
const EDIT_VERTEX_MODE = 'edit_vertex'
|
|
@@ -25,10 +27,39 @@ const pendingCreateIds = new WeakMap()
|
|
|
25
27
|
// apart from a held new shape, which a new session discards — an edited feature must stay.
|
|
26
28
|
const editFinishRevisions = new WeakMap()
|
|
27
29
|
|
|
28
|
-
// A
|
|
29
|
-
//
|
|
30
|
+
// A finished shape is checked again, rather than reusing the latest result, when there's an
|
|
31
|
+
// onGeometryFinish, or the result asked for it (recheckOnFinish, deprecated). Never on that
|
|
32
|
+
// finishing check itself. onGeometryFinish runs the finishing check; without it, onGeometryChange.
|
|
30
33
|
const FINISH_PHASES = new Set(['create', 'edit-finish'])
|
|
31
|
-
const
|
|
34
|
+
const needsFinishCheck = (draw, { result, context }) =>
|
|
35
|
+
!FINISH_PHASES.has(context?.phase) && (typeof draw._finishValidator === 'function' || !!result?.recheckOnFinish)
|
|
36
|
+
const finishValidatorFor = (draw) => draw._finishValidator ?? draw._commitValidator
|
|
37
|
+
|
|
38
|
+
// The latest onGeometryFinish result, if it passed for this shape; otherwise null.
|
|
39
|
+
// onGeometryChange standing in for it, or a result for different geometry, doesn't count.
|
|
40
|
+
const getPassingFinishResult = (draw, { status, result, context, feature: checkedFeature }, feature) => {
|
|
41
|
+
const isPassingFinishResult = typeof draw._finishValidator === 'function' && FINISH_PHASES.has(context?.phase) &&
|
|
42
|
+
status === 'valid' && isSameGeometry(checkedFeature, feature)
|
|
43
|
+
return isPassingFinishResult ? result : null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// A passing onGeometryFinish result's properties are merged into the finished shape, in
|
|
47
|
+
// draw's store, before any listener sees it. Called before resetState(), which ends the
|
|
48
|
+
// check session. Returns the shape to emit.
|
|
49
|
+
const applyFinishProperties = (draw, feature, mapState) => {
|
|
50
|
+
const properties = getPassingFinishResult(draw, getCommitChecks(draw).state, feature)?.properties
|
|
51
|
+
if (!properties) { return feature }
|
|
52
|
+
mergeFeatureProperties(draw, feature.id, properties, { caller: 'onGeometryFinish', styleIds: mapStyleIds(mapState) })
|
|
53
|
+
return draw.get(feature.id)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The Done button and the map's finish gestures (double-click, clicking the first vertex)
|
|
57
|
+
// follow the same check state
|
|
58
|
+
const applyCanFinish = (draw, dispatch, state) => {
|
|
59
|
+
const canFinish = canFinishCheck(state)
|
|
60
|
+
draw.setCanFinish?.(canFinish)
|
|
61
|
+
dispatch({ type: 'SET_CAN_FINISH', payload: canFinish })
|
|
62
|
+
}
|
|
32
63
|
|
|
33
64
|
// A shape that simply hasn't reached its minimum vertex count yet isn't a mistake —
|
|
34
65
|
// it's the normal, expected state of "still being drawn" — so it's excluded below
|
|
@@ -58,13 +89,13 @@ const buildVertexMoveTarget = (draw) => ({
|
|
|
58
89
|
// Vertex-selection handlers: sync pluginState.selectedVertexIndex, and claim/release
|
|
59
90
|
// MapControls' D-pad via buildVertexMoveTarget above.
|
|
60
91
|
const createVertexSelectionHandlers = ({ draw, pluginState, mapProvider, eventBus }) => ({
|
|
61
|
-
onVertexSelection: (
|
|
62
|
-
pluginState.dispatch({ type: 'SET_SELECTED_VERTEX_INDEX', payload:
|
|
63
|
-
mapProvider.activeMoveTarget =
|
|
64
|
-
eventBus.emit('draw:vertexselection',
|
|
92
|
+
onVertexSelection: (event) => {
|
|
93
|
+
pluginState.dispatch({ type: 'SET_SELECTED_VERTEX_INDEX', payload: event })
|
|
94
|
+
mapProvider.activeMoveTarget = event.index >= 0 ? buildVertexMoveTarget(draw) : null
|
|
95
|
+
eventBus.emit('draw:vertexselection', event)
|
|
65
96
|
},
|
|
66
|
-
onVertexChange: (
|
|
67
|
-
pluginState.dispatch({ type: 'SET_SELECTED_VERTEX_INDEX', payload: { index: -1, numVertices:
|
|
97
|
+
onVertexChange: (event) => {
|
|
98
|
+
pluginState.dispatch({ type: 'SET_SELECTED_VERTEX_INDEX', payload: { index: -1, numVertices: event.numVertices } })
|
|
68
99
|
mapProvider.activeMoveTarget = null
|
|
69
100
|
}
|
|
70
101
|
})
|
|
@@ -86,11 +117,12 @@ const enterEditMode = ({ draw, appState, appConfig, mapState, dispatch, eventBus
|
|
|
86
117
|
getSnapEnabled: () => draw.isSnapEnabled()
|
|
87
118
|
})
|
|
88
119
|
const editing = draw.get(featureId)
|
|
89
|
-
const
|
|
120
|
+
const state = getCommitChecks(draw).state
|
|
121
|
+
const { status, result } = state
|
|
90
122
|
dispatch({ type: 'SET_FEATURE', payload: { feature: editing, tempFeature: editing } })
|
|
91
123
|
dispatch({ type: 'SET_MODE', payload: mode })
|
|
92
124
|
dispatch({ type: 'SET_VALIDATION_STATUS', payload: status })
|
|
93
|
-
draw
|
|
125
|
+
applyCanFinish(draw, dispatch, state)
|
|
94
126
|
draw.setInvalid?.(status === 'invalid')
|
|
95
127
|
eventBus.emit('draw:reopened', { feature: stripInternalProperties(editing), status, reason: result?.reason ?? null })
|
|
96
128
|
}
|
|
@@ -127,10 +159,9 @@ const createCheckStateHandler = ({ draw, dispatch, emitGeometryInvalid, announce
|
|
|
127
159
|
// A slow check is the same pending check, now shown as "Checking…"
|
|
128
160
|
dispatch(state.slow ? { type: 'SET_CHECK_SLOW' } : { type: 'SET_VALIDATION_STATUS', payload: status })
|
|
129
161
|
announceCheck(announce, state)
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
draw.setCanFinish?.(valid || status === 'pending')
|
|
162
|
+
// A shape finished while its check is pending is held until it settles (see
|
|
163
|
+
// createFinishHandlers).
|
|
164
|
+
applyCanFinish(draw, dispatch, state)
|
|
134
165
|
if (status === 'pending' || status === 'error') { return }
|
|
135
166
|
// The invalid stroke is committed-validity-driven in edit mode only; in draw mode the
|
|
136
167
|
// adapters drive it live from the displayed geometry (placed vertices + cursor).
|
|
@@ -144,25 +175,38 @@ const createCheckStateHandler = ({ draw, dispatch, emitGeometryInvalid, announce
|
|
|
144
175
|
}
|
|
145
176
|
}
|
|
146
177
|
|
|
147
|
-
// Finishing a new shape: created when its check passes, otherwise reopened in edit mode
|
|
148
|
-
//
|
|
149
|
-
//
|
|
178
|
+
// Finishing a new shape: created when its check passes, otherwise reopened in edit mode —
|
|
179
|
+
// as is a shape whose passing onGeometryFinish result asks to reopen it. A shape finished
|
|
180
|
+
// while its check is pending is held until it settles, with Done reading "Checking…" — for
|
|
181
|
+
// a point, Done shows just for that.
|
|
150
182
|
function createFinishHandlers ({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }) {
|
|
151
183
|
const checks = getCommitChecks(draw)
|
|
152
184
|
|
|
153
|
-
const
|
|
185
|
+
const createFeature = (feature) => {
|
|
186
|
+
const finished = applyFinishProperties(draw, feature, mapState)
|
|
154
187
|
resetState()
|
|
155
188
|
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
156
|
-
eventBus.emit(CREATED_EVENT, stripInternalProperties(
|
|
189
|
+
eventBus.emit(CREATED_EVENT, stripInternalProperties(finished))
|
|
157
190
|
}
|
|
158
191
|
|
|
159
|
-
const
|
|
192
|
+
const reopenFeature = (featureId, geometryType) => {
|
|
160
193
|
pendingCreateIds.set(draw, featureId)
|
|
161
194
|
setTimeout(() => enterEditMode({ draw, appState, appConfig, mapState, dispatch, eventBus }, featureId, geometryType), 0)
|
|
162
195
|
}
|
|
163
196
|
|
|
197
|
+
// A passing result creates the shape, unless its onGeometryFinish result asked to reopen it,
|
|
198
|
+
// valid. Finishing it again, unchanged, creates it from that same result.
|
|
199
|
+
const createOrReopenFeature = (feature, state) => {
|
|
200
|
+
const shouldReopen = state.context?.phase === 'create' && !!getPassingFinishResult(draw, state, feature)?.reopen
|
|
201
|
+
if (shouldReopen) {
|
|
202
|
+
reopenFeature(feature.id, feature.geometry?.type)
|
|
203
|
+
} else {
|
|
204
|
+
createFeature(feature)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
164
208
|
// The map leaves draw mode; Done stays, disabled and reading "Checking…" once the check is slow
|
|
165
|
-
const
|
|
209
|
+
const holdFeature = (featureId) => {
|
|
166
210
|
checks.hold(featureId)
|
|
167
211
|
dispatch({ type: 'SET_HOLDING', payload: true })
|
|
168
212
|
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
@@ -172,62 +216,64 @@ function createFinishHandlers ({ appState, appConfig, mapState, draw, dispatch,
|
|
|
172
216
|
// the first vertex, Enter), so the latest check is re-applied here — a shape without a
|
|
173
217
|
// passing check must never be finalised. A passing or still-pending result for this
|
|
174
218
|
// 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
|
|
176
|
-
//
|
|
177
|
-
const
|
|
219
|
+
// point, which has no commits before it's created, a failed result, or a finishing check
|
|
220
|
+
// — see needsFinishCheck) the shape is checked now with phase 'create'.
|
|
221
|
+
const checkFinishedFeature = (feature) => {
|
|
178
222
|
const { status, feature: checkedFeature } = checks.state
|
|
179
|
-
const isReusable = (status === 'valid' || status === 'pending') && isSameGeometry(checkedFeature,
|
|
223
|
+
const isReusable = (status === 'valid' || status === 'pending') && isSameGeometry(checkedFeature, feature) && !needsFinishCheck(draw, checks.state)
|
|
180
224
|
if (!isReusable) {
|
|
181
|
-
checks.run({ feature
|
|
225
|
+
checks.run({ feature, context: { phase: 'create', mode: draw.getMode() }, consumerCheck: finishValidatorFor(draw) })
|
|
182
226
|
}
|
|
183
227
|
return checks.state
|
|
184
228
|
}
|
|
185
229
|
|
|
186
|
-
const
|
|
187
|
-
const state =
|
|
230
|
+
const finishFeature = (feature) => {
|
|
231
|
+
const state = checkFinishedFeature(feature)
|
|
188
232
|
if (state.status === 'valid') {
|
|
189
|
-
|
|
233
|
+
createOrReopenFeature(feature, state)
|
|
190
234
|
} else if (state.status === 'pending') {
|
|
191
|
-
|
|
235
|
+
holdFeature(feature.id)
|
|
192
236
|
} else {
|
|
193
|
-
|
|
237
|
+
reopenFeature(feature.id, feature.geometry?.type)
|
|
194
238
|
}
|
|
195
239
|
}
|
|
196
240
|
|
|
197
241
|
return {
|
|
198
|
-
onCreate:
|
|
242
|
+
onCreate: finishFeature,
|
|
199
243
|
// A held shape is created once its check passes, or reopened in edit mode. A result that
|
|
200
|
-
//
|
|
244
|
+
// needs a finishing check, unknown until the pending check settled, is checked again.
|
|
201
245
|
onCheckSettled: (state) => {
|
|
202
246
|
const heldId = checks.heldId
|
|
203
247
|
if (heldId === undefined || state.status === 'pending') { return }
|
|
204
248
|
checks.release()
|
|
205
249
|
const finished = draw.get(heldId)
|
|
206
|
-
if (
|
|
207
|
-
|
|
250
|
+
if (needsFinishCheck(draw, state)) {
|
|
251
|
+
finishFeature(finished)
|
|
208
252
|
} else if (state.status === 'valid') {
|
|
209
|
-
|
|
253
|
+
createOrReopenFeature(finished, state)
|
|
210
254
|
} else {
|
|
211
|
-
|
|
255
|
+
reopenFeature(heldId, finished?.geometry?.type)
|
|
212
256
|
}
|
|
213
257
|
},
|
|
214
|
-
onEditFinish: (
|
|
258
|
+
onEditFinish: (feature) => {
|
|
259
|
+
const finished = applyFinishProperties(draw, feature, mapState)
|
|
215
260
|
resetState()
|
|
216
261
|
setTimeout(() => draw.changeMode('disabled'), 0)
|
|
217
262
|
// A shape that was drawn-then-fixed reports as a creation, not an edit.
|
|
218
|
-
if (pendingCreateIds.get(draw) ===
|
|
263
|
+
if (pendingCreateIds.get(draw) === feature.id) {
|
|
219
264
|
pendingCreateIds.delete(draw)
|
|
220
|
-
eventBus.emit(CREATED_EVENT, stripInternalProperties(
|
|
265
|
+
eventBus.emit(CREATED_EVENT, stripInternalProperties(finished))
|
|
221
266
|
} else {
|
|
222
|
-
eventBus.emit('draw:edited', stripInternalProperties(
|
|
267
|
+
eventBus.emit('draw:edited', stripInternalProperties(finished))
|
|
223
268
|
}
|
|
224
269
|
}
|
|
225
270
|
}
|
|
226
271
|
}
|
|
227
272
|
|
|
228
273
|
// 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.
|
|
230
|
-
//
|
|
274
|
+
// that check (see editFinishRevisions above) instead of finishing straight away. With an
|
|
275
|
+
// onGeometryFinish, or a result asking for recheckOnFinish, the shape is checked again first,
|
|
276
|
+
// with phase 'edit-finish' — straight away for onGeometryFinish, which decides on its own.
|
|
231
277
|
function createEditFinishHandlers ({ draw, dispatch }) {
|
|
232
278
|
const checks = getCommitChecks(draw)
|
|
233
279
|
|
|
@@ -237,15 +283,15 @@ function createEditFinishHandlers ({ draw, dispatch }) {
|
|
|
237
283
|
}
|
|
238
284
|
|
|
239
285
|
const finishEdit = (state) => {
|
|
240
|
-
if (state.status === 'pending') {
|
|
286
|
+
if (state.status === 'pending' && !draw._finishValidator) {
|
|
241
287
|
waitFor(state.revision)
|
|
242
288
|
return
|
|
243
289
|
}
|
|
244
|
-
if (!
|
|
290
|
+
if (!needsFinishCheck(draw, state)) {
|
|
245
291
|
draw.done()
|
|
246
292
|
return
|
|
247
293
|
}
|
|
248
|
-
checks.run({ feature: state.feature, context: { phase: 'edit-finish', mode: draw.getMode() },
|
|
294
|
+
checks.run({ feature: state.feature, context: { phase: 'edit-finish', mode: draw.getMode() }, consumerCheck: finishValidatorFor(draw) })
|
|
249
295
|
const next = checks.state
|
|
250
296
|
if (next.status === 'pending') {
|
|
251
297
|
waitFor(next.revision)
|
|
@@ -310,12 +356,12 @@ function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvid
|
|
|
310
356
|
onCancel: () => { checks.reset() },
|
|
311
357
|
...createFinishHandlers({ appState, appConfig, mapState, draw, dispatch, eventBus, resetState }),
|
|
312
358
|
...createVertexSelectionHandlers({ draw, pluginState, mapProvider, eventBus }),
|
|
313
|
-
onUndoChange: (
|
|
314
|
-
onUpdate: (
|
|
315
|
-
onGeometryChange: (
|
|
359
|
+
onUndoChange: (undoStackLength) => { pluginState.dispatch({ type: 'SET_UNDO_STACK_LENGTH', payload: undoStackLength }) },
|
|
360
|
+
onUpdate: (updatedFeature) => { eventBus.emit('draw:updated', stripInternalProperties(updatedFeature)) },
|
|
361
|
+
onGeometryChange: (event) => {
|
|
316
362
|
// Only commit-level changes carry a `phase` ('change').
|
|
317
363
|
// Preview events (e.g. split's live preview) have none and are ignored.
|
|
318
|
-
if (!
|
|
364
|
+
if (!event?.phase) { return }
|
|
319
365
|
|
|
320
366
|
// A commit that lands after the session has ended (the adapters defer them a tick)
|
|
321
367
|
// is dropped rather than calling onGeometryChange.
|
|
@@ -326,32 +372,32 @@ function createHandlers ({ appState, appConfig, mapState, pluginState, mapProvid
|
|
|
326
372
|
// interim invalid states while being built or reshaped. The result is applied
|
|
327
373
|
// by the check-state handler once it settles.
|
|
328
374
|
checks.run({
|
|
329
|
-
feature:
|
|
330
|
-
context: { phase:
|
|
331
|
-
|
|
375
|
+
feature: event.feature,
|
|
376
|
+
context: { phase: event.phase, vertexIndex: event.vertexIndex, mode },
|
|
377
|
+
consumerCheck: draw._commitValidator
|
|
332
378
|
})
|
|
333
379
|
},
|
|
334
380
|
// A vertex placement was rejected (placement rule or user callback veto). Surface it
|
|
335
381
|
// on the public bus with phase 'place', and as a hint toast, so the reason is visible.
|
|
336
|
-
onPlacementBlocked: (
|
|
337
|
-
if (
|
|
338
|
-
emitGeometryInvalid({ ...
|
|
382
|
+
onPlacementBlocked: (event) => {
|
|
383
|
+
if (event.announcement) { announce?.(event.announcement, 'action') }
|
|
384
|
+
emitGeometryInvalid({ ...event, feature: stripInternalProperties(event.feature) })
|
|
339
385
|
},
|
|
340
386
|
// Live (mid-drag) validity flip while editing — the displayed shape is exactly
|
|
341
387
|
// what Done finishes there, so it gates the Done button in real time alongside
|
|
342
388
|
// the commit-level check. Emitted by the adapters' edit wiring only, on flips only.
|
|
343
|
-
onValidityChange: (
|
|
344
|
-
pluginState.dispatch({ type: 'SET_PREVIEW_VALID', payload:
|
|
389
|
+
onValidityChange: (event) => {
|
|
390
|
+
pluginState.dispatch({ type: 'SET_PREVIEW_VALID', payload: event.valid })
|
|
345
391
|
},
|
|
346
392
|
// Live placement-veto flip while drawing — gates the Add point button so it
|
|
347
393
|
// never looks active when a tap would be rejected.
|
|
348
|
-
onCanPlaceChange: (
|
|
349
|
-
pluginState.dispatch({ type: 'SET_CAN_ADD_POINT', payload:
|
|
394
|
+
onCanPlaceChange: (event) => {
|
|
395
|
+
pluginState.dispatch({ type: 'SET_CAN_ADD_POINT', payload: event.canPlace })
|
|
350
396
|
},
|
|
351
397
|
// The mode's interface type changed (device switch mid-draw, or the final
|
|
352
398
|
// value on mode exit) — relay so the app can sync appState.interfaceType.
|
|
353
|
-
onInterfaceTypeChange: (
|
|
354
|
-
eventBus.emit('draw:interfacetypechange', { interfaceType:
|
|
399
|
+
onInterfaceTypeChange: (event) => {
|
|
400
|
+
eventBus.emit('draw:interfacetypechange', { interfaceType: event.interfaceType })
|
|
355
401
|
}
|
|
356
402
|
}
|
|
357
403
|
}
|