@defra/interactive-map 0.0.60-alpha → 0.0.61-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 (48) hide show
  1. package/dist/css/index.css +1 -1
  2. package/dist/esm/im-core.js +1 -1
  3. package/dist/umd/im-core.js +1 -1
  4. package/dist/umd/index.js +1 -1
  5. package/docs/api/button-definition.md +11 -0
  6. package/docs/api/context.md +2 -0
  7. package/docs/plugins/draw.md +26 -0
  8. package/package.json +1 -1
  9. package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
  10. package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
  11. package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
  12. package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
  13. package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
  14. package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
  15. package/plugins/draw/dist/umd/index.js +1 -1
  16. package/plugins/draw/src/DrawInit.jsx +3 -0
  17. package/plugins/draw/src/DrawInit.test.jsx +16 -0
  18. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +19 -3
  19. package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +27 -0
  20. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +10 -2
  21. package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +14 -0
  22. package/plugins/draw/src/defaults.js +4 -0
  23. package/plugins/draw/src/hooks/useSnapMinZoom.js +29 -0
  24. package/plugins/draw/src/hooks/useSnapMinZoom.test.js +82 -0
  25. package/plugins/draw/src/manifest.js +4 -1
  26. package/plugins/draw/src/manifest.test.js +15 -2
  27. package/plugins/draw/src/utils/snapMinZoom.js +8 -0
  28. package/plugins/draw/src/utils/snapMinZoom.test.js +22 -0
  29. package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
  30. package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
  31. package/plugins/map-key/src/manifest.js +1 -1
  32. package/src/App/components/MapButton/MapButton.jsx +20 -2
  33. package/src/App/components/MapButton/MapButton.module.scss +15 -1
  34. package/src/App/components/MapButton/MapButton.test.jsx +21 -3
  35. package/src/App/components/Tooltip/Tooltip.jsx +29 -11
  36. package/src/App/components/Tooltip/Tooltip.test.jsx +45 -3
  37. package/src/App/components/Viewport/MapController.jsx +2 -0
  38. package/src/App/components/Viewport/MapController.test.jsx +3 -0
  39. package/src/App/hooks/useUserMoveTracking.js +65 -0
  40. package/src/App/hooks/useUserMoveTracking.test.js +99 -0
  41. package/src/App/renderer/mapButtons.js +1 -0
  42. package/src/App/renderer/mapButtons.test.js +8 -0
  43. package/src/App/store/mapActionsMap.js +2 -1
  44. package/src/App/store/mapActionsMap.test.js +6 -0
  45. package/src/App/store/mapReducer.js +2 -0
  46. package/src/App/store/mapReducer.test.js +1 -0
  47. package/src/scss/settings/_colors.scss +4 -0
  48. package/src/types.js +4 -0
@@ -174,6 +174,14 @@ describe('mapButtons module', () => {
174
174
  expect(render(baseBtn).props.isBusy).toBeUndefined()
175
175
  })
176
176
 
177
+ it('evaluates description, a string or a function of the context', () => {
178
+ const evaluate = jest.fn((prop) => (typeof prop === 'function' ? prop() : prop))
179
+ const fromFunction = SlotButton({ buttonId: 'id', config: { ...baseBtn, description: () => 'Zoom in' }, appState, appConfig, evaluateProp: evaluate })
180
+ expect(fromFunction.props.description).toBe('Zoom in')
181
+ const fromString = SlotButton({ buttonId: 'id', config: { ...baseBtn, description: 'Fixed' }, appState, appConfig, evaluateProp: evaluate })
182
+ expect(fromString.props.description).toBe('Fixed')
183
+ })
184
+
177
185
  it.each([
178
186
  [{ slot: 'right-top', open: false }, 'dialog'],
179
187
  [{ slot: 'right-top', open: false, dismissible: false }, 'region'],
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Generic reducer action that shallow-merges the payload into state.
3
- * Shared by MAP_MOVE, MAP_MOVE_END and MAP_FIRST_IDLE.
3
+ * Shared by MAP_MOVE_START, MAP_MOVE, MAP_MOVE_END and MAP_FIRST_IDLE.
4
4
  */
5
5
  const mergePayload = (state, payload) => ({
6
6
  ...state,
@@ -68,6 +68,7 @@ const removeMarker = (state, payload) => {
68
68
 
69
69
  export const actionsMap = {
70
70
  SET_MAP_READY: setMapReady,
71
+ MAP_MOVE_START: mergePayload,
71
72
  MAP_MOVE: mergePayload,
72
73
  MAP_MOVE_END: mergePayload,
73
74
  MAP_FIRST_IDLE: mergePayload,
@@ -27,6 +27,12 @@ describe('actionsMap', () => {
27
27
  })
28
28
  })
29
29
 
30
+ test('MAP_MOVE_START merges payload into state', () => {
31
+ const payload = { isUserMove: true }
32
+ const result = actionsMap.MAP_MOVE_START(state, payload)
33
+ expect(result).toEqual({ ...state, ...payload })
34
+ })
35
+
30
36
  test('MAP_MOVE merges payload into state', () => {
31
37
  const payload = { center: [10, 20] }
32
38
  const result = actionsMap.MAP_MOVE(state, payload)
@@ -31,6 +31,8 @@ export const initialState = (config) => {
31
31
  resolution: null,
32
32
  isAtMaxZoom: null,
33
33
  isAtMinZoom: null,
34
+ // Whether the user started the latest move, rather than code (useUserMoveTracking)
35
+ isUserMove: false,
34
36
 
35
37
  // Full target marker state
36
38
  crossHair: {
@@ -47,6 +47,7 @@ describe('mapReducer', () => {
47
47
  resolution: null,
48
48
  isAtMaxZoom: null,
49
49
  isAtMinZoom: null,
50
+ isUserMove: false,
50
51
  crossHair: {
51
52
  isVisible: false,
52
53
  isPinnedToMap: false,
@@ -17,6 +17,8 @@
17
17
  --pressed-button-foreground-color: #ffffff;
18
18
  --pressed-button-border-color: #0b0c0c;
19
19
  --pressed-button-background-color: #0b0c0c;
20
+ --disabled-pressed-button-foreground-color: #ffffff;
21
+ --disabled-pressed-button-background-color: #9d9e9e;
20
22
 
21
23
  // Scrollable content
22
24
  --scrollable-outline: 3px solid #ffdd00;
@@ -68,6 +70,8 @@
68
70
  --pressed-button-foreground-color: #0b0c0c;
69
71
  --pressed-button-border-color: #ffffff;
70
72
  --pressed-button-background-color: #ffffff;
73
+ --disabled-pressed-button-foreground-color: #383f43;
74
+ --disabled-pressed-button-background-color: #888c8e;
71
75
 
72
76
  // Content
73
77
  --content-border-color: #505a5f;
package/src/types.js CHANGED
@@ -194,6 +194,10 @@
194
194
  * opens or expands a custom control rendered elsewhere by the plugin. Text or a function
195
195
  * returning the id.
196
196
  *
197
+ * @property {string | ((context: PluginContext) => string | undefined)} [description]
198
+ * Extra information read by screen readers after the label, set with aria-describedby. Text or a
199
+ * function returning the text; no description when it returns nothing.
200
+ *
197
201
  * @property {ButtonBreakpointConfig} [desktop]
198
202
  * Desktop breakpoint configuration.
199
203
  *