@defra/interactive-map 0.0.14-alpha → 0.0.16-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/css/docusaurus.css +104 -0
- package/assets/images/favicon.svg +1 -0
- package/assets/images/hero.png +0 -0
- package/dist/css/index.css +1 -1
- 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/slot-map.svg +1 -0
- package/docs/api/slots.md +89 -6
- package/docs/api.md +1 -1
- package/docs/architecture.md +3 -1
- package/docs/{demo.mdx → examples.mdx} +1 -1
- package/docs/getting-started.md +1 -3
- package/docs/index.mdx +42 -0
- package/docs/plugins/interact.md +176 -55
- package/docs/plugins/map-styles.md +64 -7
- package/docs/plugins/search.md +207 -63
- package/docs/plugins.md +7 -15
- package/docusaurus.config.cjs +34 -34
- package/jest.setup.js +1 -1
- package/package.json +5 -4
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/beta/datasets/src/DatasetsInit.jsx +1 -1
- package/plugins/beta/datasets/src/api/addDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideDataset.js +1 -1
- package/plugins/beta/datasets/src/api/hideFeatures.js +1 -1
- package/plugins/beta/datasets/src/api/removeDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showDataset.js +1 -1
- package/plugins/beta/datasets/src/api/showFeatures.js +1 -1
- package/plugins/beta/datasets/src/datasets.js +4 -4
- package/plugins/beta/datasets/src/defaults.js +1 -1
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +5 -5
- package/plugins/beta/datasets/src/handleSetMapStyle.js +1 -1
- package/plugins/beta/datasets/src/manifest.js +7 -7
- package/plugins/beta/datasets/src/mapLayers.js +2 -3
- package/plugins/beta/datasets/src/panels/Key.jsx +31 -29
- package/plugins/beta/datasets/src/panels/Layers.jsx +8 -9
- package/plugins/beta/datasets/src/utils/bbox.js +4 -4
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/DrawInit.jsx +16 -16
- package/plugins/beta/draw-es/src/api/addFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/deleteFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/editFeature.js +3 -3
- package/plugins/beta/draw-es/src/api/newPolygon.js +3 -3
- package/plugins/beta/draw-es/src/events.js +52 -20
- package/plugins/beta/draw-es/src/events.test.js +301 -0
- package/plugins/beta/draw-es/src/graphic.js +1 -1
- package/plugins/beta/draw-es/src/manifest.js +4 -4
- package/plugins/beta/draw-es/src/reducer.js +1 -1
- package/plugins/beta/draw-es/src/sketchViewModel.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/src/DrawInit.jsx +49 -52
- package/plugins/beta/draw-ml/src/api/deleteFeature.js +1 -1
- package/plugins/beta/draw-ml/src/api/editFeature.js +8 -5
- package/plugins/beta/draw-ml/src/api/newLine.js +0 -1
- package/plugins/beta/draw-ml/src/api/newPolygon.js +0 -1
- package/plugins/beta/draw-ml/src/api/split.js +4 -4
- package/plugins/beta/draw-ml/src/defaults.js +1 -1
- package/plugins/beta/draw-ml/src/events.js +8 -6
- package/plugins/beta/draw-ml/src/manifest.js +15 -15
- package/plugins/beta/draw-ml/src/mapboxDraw.js +1 -1
- package/plugins/beta/draw-ml/src/mapboxSnap.js +17 -18
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +31 -31
- package/plugins/beta/draw-ml/src/modes/disabledMode.js +1 -1
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +11 -11
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +8 -8
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +7 -7
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +32 -24
- package/plugins/beta/draw-ml/src/reducer.js +1 -1
- package/plugins/beta/draw-ml/src/undoStack.js +4 -4
- package/plugins/beta/draw-ml/src/utils/snapHelpers.js +12 -12
- package/plugins/beta/draw-ml/src/utils/spatial.js +11 -11
- package/plugins/beta/frame/src/Frame.jsx +4 -4
- package/plugins/beta/frame/src/FrameInit.jsx +4 -4
- package/plugins/beta/frame/src/api/addFrame.js +1 -1
- package/plugins/beta/frame/src/api/editFeature.js +1 -1
- package/plugins/beta/frame/src/config.js +1 -1
- package/plugins/beta/frame/src/manifest.js +3 -3
- package/plugins/beta/frame/src/reducer.js +1 -1
- package/plugins/beta/frame/src/utils.js +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/src/MapStyles.jsx +18 -18
- package/plugins/beta/map-styles/src/manifest.js +2 -2
- package/plugins/beta/scale-bar/src/ScaleBar.jsx +5 -5
- package/plugins/beta/use-location/src/UseLocation.jsx +1 -1
- package/plugins/beta/use-location/src/defaults.js +1 -1
- package/plugins/beta/use-location/src/events.js +3 -3
- package/plugins/interact/src/InteractInit.jsx +1 -2
- package/plugins/interact/src/api/enable.js +8 -5
- package/plugins/interact/src/api/enable.test.js +2 -2
- package/plugins/interact/src/api/selectFeature.js +4 -4
- package/plugins/interact/src/api/unselectFeature.js +5 -5
- package/plugins/interact/src/defaults.js +0 -1
- package/plugins/interact/src/events.test.js +15 -15
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.js +2 -2
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -5
- package/plugins/interact/src/manifest.js +2 -2
- package/plugins/interact/src/manifest.test.js +3 -4
- package/plugins/interact/src/reducer.js +3 -3
- package/plugins/interact/src/reducer.test.js +0 -1
- package/plugins/interact/src/utils/spatial.js +10 -10
- package/plugins/interact/src/utils/spatial.test.js +14 -14
- package/plugins/search/dist/css/index.css +1 -1
- 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/Search.jsx +7 -6
- package/plugins/search/src/Search.test.jsx +23 -23
- package/plugins/search/src/components/CloseButton/CloseButton.jsx +15 -15
- package/plugins/search/src/components/CloseButton/CloseButton.test.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +14 -14
- package/plugins/search/src/components/Form/Form.test.jsx +11 -11
- package/plugins/search/src/components/OpenButton/OpenButton.jsx +16 -15
- package/plugins/search/src/components/OpenButton/OpenButton.test.jsx +6 -2
- package/plugins/search/src/components/SubmitButton/SubmitButton.jsx +15 -15
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +6 -6
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +4 -4
- package/plugins/search/src/datasets.js +12 -13
- package/plugins/search/src/datasets.test.js +1 -1
- package/plugins/search/src/defaults.js +1 -1
- package/plugins/search/src/events/fetchSuggestions.js +4 -4
- package/plugins/search/src/events/fetchSuggestions.test.js +5 -5
- package/plugins/search/src/events/formHandlers.js +3 -3
- package/plugins/search/src/events/formHandlers.test.js +1 -1
- package/plugins/search/src/events/index.js +2 -2
- package/plugins/search/src/events/index.test.js +2 -2
- package/plugins/search/src/events/inputHandlers.js +4 -4
- package/plugins/search/src/events/inputHandlers.test.js +1 -1
- package/plugins/search/src/events/suggestionHandlers.js +2 -2
- package/plugins/search/src/events/suggestionHandlers.test.js +1 -1
- package/plugins/search/src/index.js +2 -1
- package/plugins/search/src/index.test.js +3 -3
- package/plugins/search/src/manifest.js +6 -4
- package/plugins/search/src/reducer.js +1 -2
- package/plugins/search/src/reducer.test.js +2 -2
- package/plugins/search/src/search.scss +18 -6
- package/plugins/search/src/utils/parseOsNamesResults.js +1 -2
- package/plugins/search/src/utils/parseOsNamesResults.test.js +2 -2
- package/plugins/search/src/utils/updateMap.js +1 -1
- package/plugins/search/src/utils/updateMap.test.js +5 -5
- package/providers/beta/esri/dist/esm/im-esri-provider.js +1 -1
- package/providers/beta/esri/src/esriProvider.js +5 -5
- package/providers/beta/esri/src/utils/coords.js +1 -1
- package/providers/beta/esri/src/utils/esriFixes.js +1 -1
- package/providers/beta/esri/src/utils/query.js +4 -4
- package/providers/beta/esri/src/utils/spatial.js +1 -2
- package/providers/beta/esri/src/utils/spatial.test.js +4 -1
- package/providers/beta/open-names/src/utils/mapToLocationModel.test.js +1 -1
- package/providers/maplibre/src/appEvents.test.js +1 -1
- package/providers/maplibre/src/index.js +1 -1
- package/providers/maplibre/src/index.test.js +3 -5
- package/providers/maplibre/src/mapEvents.test.js +15 -5
- package/providers/maplibre/src/maplibreProvider.test.js +6 -2
- package/providers/maplibre/src/utils/calculateLinearTextSize.js +4 -4
- package/providers/maplibre/src/utils/calculateLinearTextSize.test.js +3 -3
- package/providers/maplibre/src/utils/detectWebgl.test.js +1 -1
- package/providers/maplibre/src/utils/highlightFeatures.js +2 -2
- package/providers/maplibre/src/utils/highlightFeatures.test.js +12 -6
- package/providers/maplibre/src/utils/labels.js +19 -20
- package/providers/maplibre/src/utils/labels.test.js +15 -13
- package/providers/maplibre/src/utils/maplibreFixes.test.js +1 -1
- package/providers/maplibre/src/utils/queryFeatures.js +6 -6
- package/providers/maplibre/src/utils/queryFeatures.test.js +13 -13
- package/providers/maplibre/src/utils/spatial.js +0 -1
- package/providers/maplibre/src/utils/spatial.test.js +26 -27
- package/src/App/components/Panel/Panel.module.scss +1 -0
- package/src/App/hooks/useLayoutMeasurements.js +1 -10
- package/src/App/hooks/useLayoutMeasurements.test.js +2 -5
- package/src/App/hooks/useVisibleGeometry.js +7 -13
- package/src/App/hooks/useVisibleGeometry.test.js +72 -47
- package/src/App/layout/Layout.jsx +0 -3
- package/src/App/layout/Layout.test.jsx +0 -1
- package/src/App/layout/layout.module.scss +11 -77
- package/src/App/registry/pluginRegistry.js +17 -0
- package/src/App/registry/pluginRegistry.test.js +33 -0
- package/src/App/renderer/HtmlElementHost.jsx +0 -1
- package/src/App/renderer/HtmlElementHost.test.jsx +20 -11
- package/src/App/renderer/mapButtons.js +3 -2
- package/src/App/renderer/mapPanels.test.js +3 -3
- package/src/App/renderer/slotHelpers.js +2 -2
- package/src/App/renderer/slotHelpers.test.js +3 -3
- package/src/App/renderer/slots.js +0 -3
- package/src/App/store/AppProvider.jsx +0 -1
- package/src/App/store/appDispatchMiddleware.js +33 -1
- package/src/App/store/appDispatchMiddleware.test.js +250 -222
- package/src/config/appConfig.js +4 -4
- package/src/utils/getSafeZoneInset.js +139 -42
- package/src/utils/getSafeZoneInset.test.js +298 -122
- package/src/utils/logger.js +6 -0
- package/src/utils/logger.test.js +32 -0
- package/webpack.dev.mjs +22 -18
- package/docs/govuk-prototype.md +0 -23
- package/docs/index.md +0 -19
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { logger } from './logger.js'
|
|
2
|
+
|
|
3
|
+
beforeEach(() => {
|
|
4
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
5
|
+
jest.spyOn(console, 'error').mockImplementation(() => {})
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
jest.restoreAllMocks()
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
describe('logger', () => {
|
|
13
|
+
it('logger.warn calls console.warn with the [interactive-map] prefix', () => {
|
|
14
|
+
logger.warn('something went wrong')
|
|
15
|
+
expect(console.warn).toHaveBeenCalledWith('[interactive-map]', 'something went wrong')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('logger.error calls console.error with the [interactive-map] prefix', () => {
|
|
19
|
+
logger.error('critical failure')
|
|
20
|
+
expect(console.error).toHaveBeenCalledWith('[interactive-map]', 'critical failure')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('logger.warn forwards multiple arguments', () => {
|
|
24
|
+
logger.warn('slot', 'invalid', { detail: true })
|
|
25
|
+
expect(console.warn).toHaveBeenCalledWith('[interactive-map]', 'slot', 'invalid', { detail: true })
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('logger.error forwards multiple arguments', () => {
|
|
29
|
+
logger.error('code', 42, null)
|
|
30
|
+
expect(console.error).toHaveBeenCalledWith('[interactive-map]', 'code', 42, null)
|
|
31
|
+
})
|
|
32
|
+
})
|
package/webpack.dev.mjs
CHANGED
|
@@ -12,6 +12,10 @@ dotenv.config({ path: path.join(__dirname, './.env'), quiet: true })
|
|
|
12
12
|
export default {
|
|
13
13
|
mode: 'development',
|
|
14
14
|
target: ['web', 'es5'],
|
|
15
|
+
devtool: [
|
|
16
|
+
// produce a source-map to aid debugging
|
|
17
|
+
{ type: 'javascript', use: 'source-map' }
|
|
18
|
+
],
|
|
15
19
|
entry: {
|
|
16
20
|
index: path.join(__dirname, 'demo/js/index.js'),
|
|
17
21
|
forms: path.join(__dirname, 'demo/js/forms.js'),
|
|
@@ -21,7 +25,7 @@ export default {
|
|
|
21
25
|
output: {
|
|
22
26
|
path: path.resolve(__dirname, 'public'),
|
|
23
27
|
filename: '[name].js',
|
|
24
|
-
clean: true
|
|
28
|
+
clean: true
|
|
25
29
|
},
|
|
26
30
|
resolve: {
|
|
27
31
|
extensions: ['.tsx', '.ts', '.jsx', '.js'],
|
|
@@ -84,28 +88,28 @@ export default {
|
|
|
84
88
|
test: /\.jsx?$/,
|
|
85
89
|
loader: 'babel-loader',
|
|
86
90
|
exclude: /node_modules/
|
|
87
|
-
},{
|
|
91
|
+
}, {
|
|
88
92
|
test: /\.s[ac]ss$/i,
|
|
89
|
-
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
|
|
90
|
-
},{
|
|
93
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
|
|
94
|
+
}, {
|
|
91
95
|
test: /\.css$/i,
|
|
92
|
-
use: [MiniCssExtractPlugin.loader, 'css-loader']
|
|
96
|
+
use: [MiniCssExtractPlugin.loader, 'css-loader']
|
|
93
97
|
}
|
|
94
|
-
]
|
|
98
|
+
]
|
|
95
99
|
},
|
|
96
100
|
devServer: {
|
|
97
101
|
static: [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
{
|
|
103
|
+
directory: path.join(__dirname, 'demo')
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
directory: path.join(__dirname, 'public')
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
directory: path.join(__dirname, 'assets'),
|
|
110
|
+
publicPath: '/assets' // Images served from here as used in both demo and prototype kit plugin
|
|
111
|
+
}
|
|
112
|
+
],
|
|
109
113
|
compress: true,
|
|
110
114
|
port: 8080,
|
|
111
115
|
open: true,
|
|
@@ -120,4 +124,4 @@ export default {
|
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
|
-
}
|
|
127
|
+
}
|
package/docs/govuk-prototype.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# GOV.UK Prototype Kit
|
|
2
|
-
|
|
3
|
-
This guide explains how to use the Interactive Map component in a GOV.UK Prototype Kit project.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Install the package in your prototype kit project:
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm install @defra/interactive-map
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
The InteractiveMap plugin will be automatically added to your prototype.
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
For detailed usage instructions, see the [GOV.UK Prototype Kit documentation](https://prototype-kit.service.gov.uk/docs/install-and-use-plugins).
|
|
18
|
-
|
|
19
|
-
## Next Steps
|
|
20
|
-
|
|
21
|
-
- [Getting Started](./getting-started.md) - Learn the basics
|
|
22
|
-
- [API Reference](./api.md) - Explore the full API
|
|
23
|
-
- [Plugins](./plugins.md) - Extend functionality
|
package/docs/index.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
## What's Inside
|
|
2
|
-
|
|
3
|
-
- **[Getting Started](getting-started)** - Installation and basic usage
|
|
4
|
-
- **[API Reference](api)** - Complete API documentation
|
|
5
|
-
- **[Plugins](plugins)** - Extend functionality with plugins
|
|
6
|
-
- **[Architecture](architecture)** - Learn about the design and structure
|
|
7
|
-
- **[GOV.UK Prototype](govuk-prototype)** - Use with GOV.UK Prototype Kit
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- ✅ Accessible and keyboard navigable
|
|
12
|
-
- 🗺️ Multiple map provider support (MapLibre, ESRI)
|
|
13
|
-
- 🔌 Extensible plugin system
|
|
14
|
-
- 🎨 Customizable styling and behaviors
|
|
15
|
-
- 📱 Responsive design
|
|
16
|
-
|
|
17
|
-
## Support
|
|
18
|
-
|
|
19
|
-
For issues and feature requests, visit our [GitHub repository](https://github.com/DEFRA/interactive-map).
|