@defra/interactive-map 0.0.31-alpha → 0.0.32-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 (98) hide show
  1. package/README.md +2 -2
  2. package/assets/images/bright-ofm-thumb.jpg +0 -0
  3. package/assets/images/dark-ofm-thumb.jpg +0 -0
  4. package/assets/images/road-ofm-thumb.jpg +0 -0
  5. package/assets/templates/add-polygons.njk +143 -0
  6. package/assets/templates/add-symbols.njk +119 -0
  7. package/assets/templates/{map.njk → basic-map.njk} +9 -17
  8. package/assets/templates/button-map.njk +56 -0
  9. package/assets/templates/draw-tools.njk +161 -0
  10. package/assets/templates/marker-panel.njk +91 -0
  11. package/assets/templates/place-marker.njk +104 -0
  12. package/assets/templates/search-control.njk +98 -0
  13. package/assets/templates/select-feature.njk +101 -0
  14. package/assets/templates/style-switcher.njk +87 -0
  15. package/assets/templates/toggle-marker-label.njk +74 -0
  16. package/dist/esm/im-core.js +1 -1
  17. package/dist/esm/im-shell.js +1 -1
  18. package/dist/umd/im-core.js +1 -1
  19. package/dist/umd/index.js +1 -1
  20. package/docs/api.md +55 -0
  21. package/docs/assets/css/docusaurus.scss +22 -6
  22. package/docs/assets/images/add-polygons.jpg +0 -0
  23. package/docs/assets/images/add-symbols.jpg +0 -0
  24. package/docs/assets/images/place-marker.jpg +0 -0
  25. package/docs/assets/images/screenshot.jpg +0 -0
  26. package/docs/examples/add-marker-with-panel.mdx +1 -1
  27. package/docs/examples/add-polygons.mdx +225 -0
  28. package/docs/examples/add-symbols.mdx +177 -0
  29. package/docs/examples/{draw.mdx → draw-tools.mdx} +2 -2
  30. package/docs/examples/index.mdx +38 -2
  31. package/docs/examples/place-marker.mdx +151 -0
  32. package/docs/plugins/datasets.md +144 -96
  33. package/docs/plugins/interact.md +1 -4
  34. package/docusaurus.config.cjs +5 -2
  35. package/govuk-prototype-kit.config.json +52 -2
  36. package/package.json +1 -1
  37. package/plugins/beta/datasets/dist/css/index.css +1 -2
  38. package/plugins/beta/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  39. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  40. package/plugins/beta/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  41. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
  42. package/plugins/beta/datasets/dist/umd/index.js +1 -1
  43. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +27 -9
  44. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +46 -4
  45. package/plugins/beta/datasets/src/api/setFeatureVisibility.js +10 -1
  46. package/plugins/beta/datasets/src/api/setFeatureVisibility.test.js +48 -6
  47. package/plugins/beta/datasets/src/components/LayersMenu/Layers.module.scss +12 -12
  48. package/plugins/beta/datasets/src/reducers/datasetsToMenu.js +11 -6
  49. package/plugins/beta/datasets/src/reducers/datasetsToMenu.test.js +49 -0
  50. package/plugins/beta/datasets/src/reducers/mappedDatasetsReducer.js +8 -1
  51. package/plugins/beta/datasets/src/reducers/pluginState.js +1 -1
  52. package/plugins/beta/datasets/src/registry/dataset.js +7 -3
  53. package/plugins/beta/datasets/src/registry/dataset.test.js +14 -0
  54. package/plugins/beta/datasets/src/registry/dynamicGeoJson.js +1 -1
  55. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  56. package/plugins/beta/draw-es/src/api/addFeature.js +12 -3
  57. package/plugins/beta/draw-es/src/events.js +8 -3
  58. package/plugins/beta/draw-es/src/events.test.js +2 -0
  59. package/plugins/beta/draw-es/src/graphic.js +26 -2
  60. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  61. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  62. package/plugins/beta/draw-ml/src/DrawInit.jsx +8 -0
  63. package/plugins/beta/draw-ml/src/api/newLine.js +1 -0
  64. package/plugins/beta/draw-ml/src/api/newPolygon.js +1 -0
  65. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +21 -12
  66. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +4 -0
  67. package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
  68. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
  69. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +4 -2
  70. package/plugins/beta/map-styles/src/mapStyles.scss +41 -41
  71. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  72. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  73. package/plugins/interact/dist/umd/index.js +1 -1
  74. package/plugins/interact/src/InteractInit.jsx +1 -3
  75. package/plugins/interact/src/InteractInit.test.js +0 -2
  76. package/plugins/interact/src/events.test.js +1 -1
  77. package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -10
  78. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +5 -10
  79. package/plugins/interact/src/hooks/useHighlightSync.js +1 -10
  80. package/plugins/interact/src/hooks/useHighlightSync.test.js +2 -21
  81. package/plugins/interact/src/hooks/useInteractionHandlers.js +5 -11
  82. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -25
  83. package/plugins/interact/src/reducer.js +4 -22
  84. package/plugins/interact/src/reducer.test.js +11 -39
  85. package/plugins/search/dist/css/index.css +5 -2
  86. package/plugins/search/src/components/Form/Form.module.scss +5 -2
  87. package/plugins/search/src/search.scss +4 -4
  88. package/src/App/components/CrossHair/CrossHair.module.scss +8 -8
  89. package/src/App/hooks/useLayoutMeasurements.js +10 -2
  90. package/src/App/hooks/useResizeObserver.js +4 -2
  91. package/src/InteractiveMap/InteractiveMap.js +4 -4
  92. package/src/InteractiveMap/InteractiveMap.test.js +3 -3
  93. package/src/InteractiveMap/behaviourController.js +3 -1
  94. package/src/InteractiveMap/behaviourController.test.js +6 -3
  95. package/src/InteractiveMap/domStateManager.js +2 -0
  96. package/src/config/events.js +21 -3
  97. package/docs/assets/images/screens-blue.jpg +0 -0
  98. package/docs/assets/images/screens-white.jpg +0 -0
@@ -7,7 +7,7 @@ import * as queryString from '../utils/queryString.js'
7
7
  import { updateDOMState } from './domStateManager.js'
8
8
 
9
9
  jest.mock('../utils/queryString.js')
10
- jest.mock('./domStateManager.js', () => ({ updateDOMState: jest.fn() }))
10
+ jest.mock('./domStateManager.js', () => ({ updateDOMState: jest.fn().mockReturnValue({ isFullscreen: false }) }))
11
11
 
12
12
  describe('shouldLoadComponent', () => {
13
13
  beforeEach(() => {
@@ -67,7 +67,8 @@ describe('setupBehavior', () => {
67
67
  loadApp: jest.fn(),
68
68
  removeApp: jest.fn(),
69
69
  hideApp: jest.fn(),
70
- showApp: jest.fn()
70
+ showApp: jest.fn(),
71
+ eventBus: { emit: jest.fn() }
71
72
  }
72
73
  // Default: viewport is wide
73
74
  window.matchMedia = jest.fn().mockImplementation(() => ({
@@ -187,14 +188,16 @@ describe('setupBehavior', () => {
187
188
  expect(mockMapInstance.showApp).not.toHaveBeenCalled()
188
189
  })
189
190
 
190
- it('calls updateDOMState when map is showing and should load', () => {
191
+ it('calls updateDOMState and emits APP_FULLSCREEN_CHANGE when map is showing and should load', () => {
191
192
  mockMapInstance._isHidden = false
192
193
  mockMapInstance._root = {} // has root
193
194
  queryString.getQueryParam.mockReturnValue(null)
195
+ updateDOMState.mockReturnValue({ isFullscreen: false })
194
196
 
195
197
  handleChange()
196
198
 
197
199
  expect(updateDOMState).toHaveBeenCalledWith(mockMapInstance)
200
+ expect(mockMapInstance.eventBus.emit).toHaveBeenCalledWith('app:fullscreenchange', { isFullscreen: false })
198
201
  expect(mockMapInstance.loadApp).not.toHaveBeenCalled()
199
202
  expect(mockMapInstance.showApp).not.toHaveBeenCalled()
200
203
  })
@@ -70,6 +70,8 @@ function updateDOMState (mapInstance, { isFullscreen: isFullscreenOverride } = {
70
70
  ? 'auto'
71
71
  : containerHeight
72
72
  rootEl.style.height = isFullscreen ? '100%' : height
73
+
74
+ return { isFullscreen }
73
75
  }
74
76
 
75
77
  /**
@@ -69,11 +69,13 @@ export const EVENTS = {
69
69
  * Fired after initial load (`loadApp`) and when the app is shown again after being hidden (`showApp`).
70
70
  * Subscribe to this event to react whenever the map becomes visible to the user.
71
71
  *
72
- * Payload: `{ statePreserved: boolean }` — `true` if the map state was preserved from a previous session.
72
+ * Payload:
73
+ * - `statePreserved: boolean` — `true` if the map state was preserved from a previous session.
74
+ * - `isFullscreen: boolean` — `true` if the map opened in fullscreen mode, `false` if inline.
73
75
  *
74
76
  * @example
75
- * map.on(EVENTS.APP_OPENED, ({ statePreserved }) => {
76
- * console.log('Map opened, state preserved:', statePreserved)
77
+ * map.on(EVENTS.APP_OPENED, ({ isFullscreen, statePreserved }) => {
78
+ * console.log('Map opened, fullscreen:', isFullscreen, 'state preserved:', statePreserved)
77
79
  * })
78
80
  */
79
81
  APP_OPENED: 'app:opened',
@@ -93,6 +95,22 @@ export const EVENTS = {
93
95
  */
94
96
  APP_CLOSED: 'app:closed',
95
97
 
98
+ /**
99
+ * Emitted when the map transitions between fullscreen and inline display while already visible.
100
+ *
101
+ * Fired during viewport resize in `hybrid` behaviour when the map crosses the fullscreen/inline
102
+ * threshold without being hidden and re-shown. Use this alongside `app:opened` and `app:closed`
103
+ * to track the map's display mode across all transitions.
104
+ *
105
+ * Payload: `{ isFullscreen: boolean }` — `true` if the map is now fullscreen, `false` if inline.
106
+ *
107
+ * @example
108
+ * map.on(EVENTS.APP_FULLSCREEN_CHANGE, ({ isFullscreen }) => {
109
+ * console.log('Display mode changed, fullscreen:', isFullscreen)
110
+ * })
111
+ */
112
+ APP_FULLSCREEN_CHANGE: 'app:fullscreenchange',
113
+
96
114
  /**
97
115
  * Emitted when a panel is opened.
98
116
  * Payload: { panelId: string }
Binary file