@defra/forms-engine-plugin 4.0.57 → 4.0.59

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.
@@ -117,7 +117,7 @@ export function initMaps(config = {}) {
117
117
  // If there are location components on the page fix up the main form submit
118
118
  // handler so it doesn't fire when using the integrated map search feature
119
119
  if (locations.length) {
120
- const form = document.querySelector('form');
120
+ const form = locations[0].closest('form');
121
121
  if (form === null) {
122
122
  return;
123
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"location-map.js","names":["OsGridRef","LatLon","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","DEFAULT_LAT","DEFAULT_LONG","defaultConfig","zoom","center","COMPANY_SYMBOL_CODE","LOCATION_FIELD_SELECTOR","EVENTS","interactMarkerChange","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","length","form","querySelector","Array","from","addEventListener","forEach","location","index","processLocation","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","HTMLDivElement","locationInputs","locationType","dataset","locationtype","supportedLocations","mapContainer","createElement","mapId","setAttribute","initConfig","getInitMapConfig","after","map","interactPlugin","createMap","on","onMapReady","bindLatLongField","bindEastingNorthingField","bindOsGridRefField","Error","addPanel","showLabel","label","mobile","slot","initiallyOpen","dismissable","modal","tablet","desktop","html","enable","mapsConfig","logoAltText","defra","dataLayers","markerColor","outdoor","dark","interactionMode","multiSelect","InteractiveMap","mapProvider","maplibreProvider","reverseGeocodeProvider","openNamesProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStylesPlugin","mapStyles","id","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","searchPlugin","osNamesURL","width","showMarker","scaleBarPlugin","units","locationField","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","validateLatLong","strLat","strLong","trim","Number","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","pattern","match","exec","getLatLongInputs","inputs","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","getInitMapCenterConfig","markers","coords","result","undefined","latlong","osGridRefInput","onInteractMarkerChange","maxPrecision","toFixed","onUpdateInputs","centerMap","onUpdateInput","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\n/**\n * Converts lat long to easting and northing\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {{ easting: number, northing: number }}\n */\nfunction latLongToEastingNorthing({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid()\n}\n\n/**\n * Converts easting and northing to lat long\n * @param {object} param\n * @param {number} param.easting\n * @param {number} param.northing\n * @returns {{ lat: number, long: number }}\n */\nfunction eastingNorthingToLatLong({ easting, northing }) {\n const point = new OsGridRef(easting, northing)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Converts lat long to an ordnance survey grid reference\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {string}\n */\nfunction latLongToOsGridRef({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n}\n\n/**\n * Converts an ordnance survey grid reference to lat long\n * @param {string} osGridRef\n * @returns {{ lat: number, long: number }}\n */\nfunction osGridRefToLatLong(osGridRef) {\n const point = OsGridRef.parse(osGridRef)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\n\n/** @type {InteractiveMapInitConfig} */\nconst defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nconst COMPANY_SYMBOL_CODE = 169\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\nconst EVENTS = {\n interactMarkerChange: 'interact:markerchange'\n}\n\nconst defaultData = {\n VTS_OUTDOOR_URL: '/api/maps/vts/OS_VTS_3857_Outdoor.json',\n VTS_DARK_URL: '/api/maps/vts/OS_VTS_3857_Dark.json',\n VTS_BLACK_AND_WHITE_URL: '/api/maps/vts/OS_VTS_3857_Black_and_White.json'\n}\n\n/**\n * Make a form submit handler that only allows submissions from allowed buttons\n * @param {HTMLButtonElement[]} buttons - the form buttons to allow submissions\n */\nexport function formSubmitFactory(buttons) {\n /**\n * The submit handler\n * @param {SubmitEvent} e\n */\n const onFormSubmit = function (e) {\n if (\n !(e.submitter instanceof HTMLButtonElement) ||\n !buttons.includes(e.submitter)\n ) {\n e.preventDefault()\n }\n }\n\n return onFormSubmit\n}\n\n/**\n * Initialise location maps\n * @param {Partial<MapsEnvironmentConfig>} config - the map configuration\n */\nexport function initMaps(config = {}) {\n const {\n assetPath = '/assets',\n apiPath = '/form/api',\n data = defaultData\n } = config\n const locations = document.querySelectorAll('.app-location-field')\n\n // TODO: Fix this in `interactive-map`\n // If there are location components on the page fix up the main form submit\n // handler so it doesn't fire when using the integrated map search feature\n if (locations.length) {\n const form = document.querySelector('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n locations.forEach((location, index) => {\n processLocation({ assetPath, apiPath, data }, location, index)\n })\n}\n\n/**\n * OS API request proxy factory\n * @param {string} apiPath - the root API path\n */\nexport function makeTileRequestTransformer(apiPath) {\n /**\n * Proxy OS API requests via our server\n * @param {string} url - the request URL\n * @param {string} resourceType - the resource type\n */\n return function transformTileRequest(url, resourceType) {\n if (url.startsWith('https://api.os.uk')) {\n if (resourceType === 'Tile') {\n return {\n url: url.replace(\n 'https://api.os.uk/maps/vector/v1/vts',\n `${window.location.origin}${apiPath}`\n ),\n headers: {}\n }\n }\n\n if (resourceType !== 'Style') {\n return {\n url: `${apiPath}/map-proxy?url=${encodeURIComponent(url)}`,\n headers: {}\n }\n }\n }\n\n const spritesPath =\n 'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main'\n\n // Proxy sprite requests\n if (url.startsWith(spritesPath)) {\n const path = url.substring(spritesPath.length)\n return {\n url: `${apiPath}/maps/vts${path}`,\n headers: {}\n }\n }\n\n return { url, headers: {} }\n }\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {*} index - the 0-based index\n */\nfunction processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n 'map:ready',\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n // Add info panel\n map.addPanel('info', {\n showLabel: true,\n label: 'How to use the map',\n mobile: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n tablet: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n desktop: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n html: 'If using a map click on a point to update the location.<br><br>If using a keyboard, navigate to the point, centering the crosshair at the location and press enter.'\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * Create a Defra map instance\n * @param {string} mapId - the map id\n * @param {InteractiveMapInitConfig} initConfig - the map initial configuration\n * @param {MapsEnvironmentConfig} mapsConfig - the map environment params\n */\nfunction createMap(mapId, initConfig, mapsConfig) {\n const { assetPath, apiPath, data = defaultData } = mapsConfig\n const logoAltText = 'Ordnance survey logo'\n\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n const interactPlugin = defra.interactPlugin({\n dataLayers: [],\n markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionMode: 'marker',\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new defra.InteractiveMap(mapId, {\n ...initConfig,\n mapProvider: defra.maplibreProvider(),\n reverseGeocodeProvider: defra.openNamesProvider({\n url: `${apiPath}/reverse-geocode-proxy?easting={easting}&northing={northing}`\n }),\n behaviour: 'inline',\n minZoom: 6,\n maxZoom: 18,\n containerHeight: '400px',\n enableZoomControls: true,\n transformRequest: makeTileRequestTransformer(apiPath),\n plugins: [\n defra.mapStylesPlugin({\n mapStyles: [\n {\n id: 'outdoor',\n label: 'Outdoor',\n url: data.VTS_OUTDOOR_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/outdoor-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`,\n backgroundColor: '#f5f5f0'\n },\n {\n id: 'dark',\n label: 'Dark',\n url: data.VTS_DARK_URL,\n mapColorScheme: 'dark',\n appColorScheme: 'dark',\n thumbnail: `${assetPath}/interactive-map/assets/images/dark-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-white.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n },\n {\n id: 'black-and-white',\n label: 'Black/White',\n url: data.VTS_BLACK_AND_WHITE_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/black-and-white-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-black.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n }\n ]\n }),\n interactPlugin,\n defra.searchPlugin({\n osNamesURL: `${apiPath}/geocode-proxy?query={query}`,\n width: '300px',\n showMarker: false\n }),\n defra.scaleBarPlugin({\n units: 'metric'\n })\n ]\n })\n\n return { map, interactPlugin }\n}\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Updates the marker position and moves the map view port the new location\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n * @param {MapCenter} center - the point\n */\nfunction centerMap(map, mapProvider, center) {\n // Move the 'location' marker to the new point\n map.addMarker('location', center)\n\n // Pan & zoom the map to the new valid location\n mapProvider.flyTo({\n center,\n zoom: 14,\n essential: true\n })\n}\n\n/**\n * @typedef {object} InteractiveMap - an instance of a InteractiveMap\n * @property {Function} on - register callback listeners to map events\n * @property {Function} addPanel - adds a new panel to the map\n * @property {Function} addMarker - adds/updates a marker\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n */\n\n/**\n * @typedef {[number, number]} MapCenter - Map center point as [long, lat]\n */\n\n/**\n * @typedef {object} InteractiveMapInitConfig - additional config that can be provided to InteractiveMap\n * @property {string} zoom - the zoom level of the map\n * @property {MapCenter} center - the center point of the map\n * @property {{ id: string, coords: MapCenter}[]} [markers] - the markers to add to the map\n */\n\n/**\n * @typedef {object} TileData\n * @property {string} VTS_OUTDOOR_URL - the outdoor tile URL\n * @property {string} VTS_DARK_URL - the dark tile URL\n * @property {string} VTS_BLACK_AND_WHITE_URL - the black and white tile URL\n */\n\n/**\n * @typedef {object} MapsEnvironmentConfig\n * @property {string} assetPath - the root asset path\n * @property {string} apiPath - the root API path\n * @property {TileData} data - the tile data config\n */\n"],"mappings":"AAAA;AACA,OAAOA,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAAC;EAAEC,GAAG;EAAEC;AAAK,CAAC,EAAE;EAC/C,MAAMC,KAAK,GAAG,IAAIJ,MAAM,CAACE,GAAG,EAAEC,IAAI,CAAC;EA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AE;IACjC,MAAM9B,KAAK,GAAGS,kBAAkB,CAAC;MAC/BX,GAAG,EAAEgC,CAAC,CAACqJ,MAAM,CAAC,CAAC,CAAC;MAChBpL,IAAI,EAAE+B,CAAC,CAACqJ,MAAM,CAAC,CAAC;IAClB,CAAC,CAAC;IAEFI,cAAc,CAAC3B,KAAK,GAAG5J,KAAK;EAC9B,CACF,CAAC;;EAED;AACF;AACA;AACA;EACE,SAAS6L,aAAaA,CAAA,EAAG;IACvB,MAAMT,MAAM,GAAGhB,iBAAiB,CAACmB,cAAc,CAAC3B,KAAK,CAAC;IAEtD,IAAIwB,MAAM,CAAC/B,KAAK,EAAE;MAChB,MAAMiC,OAAO,GAAG3K,kBAAkB,CAACyK,MAAM,CAACxB,KAAK,CAAC;;MAEhD;MACA,MAAM1I,MAAM,GAAG,CAACoK,OAAO,CAACvL,IAAI,EAAEuL,OAAO,CAACxL,GAAG,CAAC;MAE1C8L,SAAS,CAAC7G,GAAG,EAAE+B,WAAW,EAAE5F,MAAM,CAAC;IACrC;EACF;EAEAqK,cAAc,CAACvI,gBAAgB,CAAC,QAAQ,EAAE6I,aAAa,EAAE,KAAK,CAAC;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASD,SAASA,CAAC7G,GAAG,EAAE+B,WAAW,EAAE5F,MAAM,EAAE;EAC3C;EACA6D,GAAG,CAAC+G,SAAS,CAAC,UAAU,EAAE5K,MAAM,CAAC;;EAEjC;EACA4F,WAAW,CAACiF,KAAK,CAAC;IAChB7K,MAAM;IACND,IAAI,EAAE,EAAE;IACR+K,SAAS,EAAE;EACb,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"location-map.js","names":["OsGridRef","LatLon","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","DEFAULT_LAT","DEFAULT_LONG","defaultConfig","zoom","center","COMPANY_SYMBOL_CODE","LOCATION_FIELD_SELECTOR","EVENTS","interactMarkerChange","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","length","form","closest","Array","from","addEventListener","forEach","location","index","processLocation","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","HTMLDivElement","locationInputs","querySelector","locationType","dataset","locationtype","supportedLocations","mapContainer","createElement","mapId","setAttribute","initConfig","getInitMapConfig","after","map","interactPlugin","createMap","on","onMapReady","bindLatLongField","bindEastingNorthingField","bindOsGridRefField","Error","addPanel","showLabel","label","mobile","slot","initiallyOpen","dismissable","modal","tablet","desktop","html","enable","mapsConfig","logoAltText","defra","dataLayers","markerColor","outdoor","dark","interactionMode","multiSelect","InteractiveMap","mapProvider","maplibreProvider","reverseGeocodeProvider","openNamesProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStylesPlugin","mapStyles","id","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","searchPlugin","osNamesURL","width","showMarker","scaleBarPlugin","units","locationField","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","validateLatLong","strLat","strLong","trim","Number","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","pattern","match","exec","getLatLongInputs","inputs","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","getInitMapCenterConfig","markers","coords","result","undefined","latlong","osGridRefInput","onInteractMarkerChange","maxPrecision","toFixed","onUpdateInputs","centerMap","onUpdateInput","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\n/**\n * Converts lat long to easting and northing\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {{ easting: number, northing: number }}\n */\nfunction latLongToEastingNorthing({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid()\n}\n\n/**\n * Converts easting and northing to lat long\n * @param {object} param\n * @param {number} param.easting\n * @param {number} param.northing\n * @returns {{ lat: number, long: number }}\n */\nfunction eastingNorthingToLatLong({ easting, northing }) {\n const point = new OsGridRef(easting, northing)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n/**\n * Converts lat long to an ordnance survey grid reference\n * @param {object} param\n * @param {number} param.lat\n * @param {number} param.long\n * @returns {string}\n */\nfunction latLongToOsGridRef({ lat, long }) {\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n}\n\n/**\n * Converts an ordnance survey grid reference to lat long\n * @param {string} osGridRef\n * @returns {{ lat: number, long: number }}\n */\nfunction osGridRefToLatLong(osGridRef) {\n const point = OsGridRef.parse(osGridRef)\n const latLong = point.toLatLon()\n\n return { lat: latLong.latitude, long: latLong.longitude }\n}\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\n\n/** @type {InteractiveMapInitConfig} */\nconst defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nconst COMPANY_SYMBOL_CODE = 169\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\nconst EVENTS = {\n interactMarkerChange: 'interact:markerchange'\n}\n\nconst defaultData = {\n VTS_OUTDOOR_URL: '/api/maps/vts/OS_VTS_3857_Outdoor.json',\n VTS_DARK_URL: '/api/maps/vts/OS_VTS_3857_Dark.json',\n VTS_BLACK_AND_WHITE_URL: '/api/maps/vts/OS_VTS_3857_Black_and_White.json'\n}\n\n/**\n * Make a form submit handler that only allows submissions from allowed buttons\n * @param {HTMLButtonElement[]} buttons - the form buttons to allow submissions\n */\nexport function formSubmitFactory(buttons) {\n /**\n * The submit handler\n * @param {SubmitEvent} e\n */\n const onFormSubmit = function (e) {\n if (\n !(e.submitter instanceof HTMLButtonElement) ||\n !buttons.includes(e.submitter)\n ) {\n e.preventDefault()\n }\n }\n\n return onFormSubmit\n}\n\n/**\n * Initialise location maps\n * @param {Partial<MapsEnvironmentConfig>} config - the map configuration\n */\nexport function initMaps(config = {}) {\n const {\n assetPath = '/assets',\n apiPath = '/form/api',\n data = defaultData\n } = config\n const locations = document.querySelectorAll('.app-location-field')\n\n // TODO: Fix this in `interactive-map`\n // If there are location components on the page fix up the main form submit\n // handler so it doesn't fire when using the integrated map search feature\n if (locations.length) {\n const form = locations[0].closest('form')\n\n if (form === null) {\n return\n }\n\n const buttons = Array.from(form.querySelectorAll('button'))\n form.addEventListener('submit', formSubmitFactory(buttons), false)\n }\n\n locations.forEach((location, index) => {\n processLocation({ assetPath, apiPath, data }, location, index)\n })\n}\n\n/**\n * OS API request proxy factory\n * @param {string} apiPath - the root API path\n */\nexport function makeTileRequestTransformer(apiPath) {\n /**\n * Proxy OS API requests via our server\n * @param {string} url - the request URL\n * @param {string} resourceType - the resource type\n */\n return function transformTileRequest(url, resourceType) {\n if (url.startsWith('https://api.os.uk')) {\n if (resourceType === 'Tile') {\n return {\n url: url.replace(\n 'https://api.os.uk/maps/vector/v1/vts',\n `${window.location.origin}${apiPath}`\n ),\n headers: {}\n }\n }\n\n if (resourceType !== 'Style') {\n return {\n url: `${apiPath}/map-proxy?url=${encodeURIComponent(url)}`,\n headers: {}\n }\n }\n }\n\n const spritesPath =\n 'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main'\n\n // Proxy sprite requests\n if (url.startsWith(spritesPath)) {\n const path = url.substring(spritesPath.length)\n return {\n url: `${apiPath}/maps/vts${path}`,\n headers: {}\n }\n }\n\n return { url, headers: {} }\n }\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {*} index - the 0-based index\n */\nfunction processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n 'map:ready',\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n // Add info panel\n map.addPanel('info', {\n showLabel: true,\n label: 'How to use the map',\n mobile: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n tablet: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n desktop: {\n slot: 'bottom',\n initiallyOpen: true,\n dismissable: true,\n modal: false\n },\n html: 'If using a map click on a point to update the location.<br><br>If using a keyboard, navigate to the point, centering the crosshair at the location and press enter.'\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * Create a Defra map instance\n * @param {string} mapId - the map id\n * @param {InteractiveMapInitConfig} initConfig - the map initial configuration\n * @param {MapsEnvironmentConfig} mapsConfig - the map environment params\n */\nfunction createMap(mapId, initConfig, mapsConfig) {\n const { assetPath, apiPath, data = defaultData } = mapsConfig\n const logoAltText = 'Ordnance survey logo'\n\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n const interactPlugin = defra.interactPlugin({\n dataLayers: [],\n markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionMode: 'marker',\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new defra.InteractiveMap(mapId, {\n ...initConfig,\n mapProvider: defra.maplibreProvider(),\n reverseGeocodeProvider: defra.openNamesProvider({\n url: `${apiPath}/reverse-geocode-proxy?easting={easting}&northing={northing}`\n }),\n behaviour: 'inline',\n minZoom: 6,\n maxZoom: 18,\n containerHeight: '400px',\n enableZoomControls: true,\n transformRequest: makeTileRequestTransformer(apiPath),\n plugins: [\n defra.mapStylesPlugin({\n mapStyles: [\n {\n id: 'outdoor',\n label: 'Outdoor',\n url: data.VTS_OUTDOOR_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/outdoor-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`,\n backgroundColor: '#f5f5f0'\n },\n {\n id: 'dark',\n label: 'Dark',\n url: data.VTS_DARK_URL,\n mapColorScheme: 'dark',\n appColorScheme: 'dark',\n thumbnail: `${assetPath}/interactive-map/assets/images/dark-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-white.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n },\n {\n id: 'black-and-white',\n label: 'Black/White',\n url: data.VTS_BLACK_AND_WHITE_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/black-and-white-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/os-logo-black.svg`,\n logoAltText,\n attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`\n }\n ]\n }),\n interactPlugin,\n defra.searchPlugin({\n osNamesURL: `${apiPath}/geocode-proxy?query={query}`,\n width: '300px',\n showMarker: false\n }),\n defra.scaleBarPlugin({\n units: 'metric'\n })\n ]\n })\n\n return { map, interactPlugin }\n}\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Updates the marker position and moves the map view port the new location\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n * @param {MapCenter} center - the point\n */\nfunction centerMap(map, mapProvider, center) {\n // Move the 'location' marker to the new point\n map.addMarker('location', center)\n\n // Pan & zoom the map to the new valid location\n mapProvider.flyTo({\n center,\n zoom: 14,\n essential: true\n })\n}\n\n/**\n * @typedef {object} InteractiveMap - an instance of a InteractiveMap\n * @property {Function} on - register callback listeners to map events\n * @property {Function} addPanel - adds a new panel to the map\n * @property {Function} addMarker - adds/updates a marker\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n */\n\n/**\n * @typedef {[number, number]} MapCenter - Map center point as [long, lat]\n */\n\n/**\n * @typedef {object} InteractiveMapInitConfig - additional config that can be provided to InteractiveMap\n * @property {string} zoom - the zoom level of the map\n * @property {MapCenter} center - the center point of the map\n * @property {{ id: string, coords: MapCenter}[]} [markers] - the markers to add to the map\n */\n\n/**\n * @typedef {object} TileData\n * @property {string} VTS_OUTDOOR_URL - the outdoor tile URL\n * @property {string} VTS_DARK_URL - the dark tile URL\n * @property {string} VTS_BLACK_AND_WHITE_URL - the black and white tile URL\n */\n\n/**\n * @typedef {object} MapsEnvironmentConfig\n * @property {string} assetPath - the root asset path\n * @property {string} apiPath - the root API path\n * @property {TileData} data - the tile data config\n */\n"],"mappings":"AAAA;AACA,OAAOA,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAAC;EAAEC,GAAG;EAAEC;AAAK,CAAC,EAAE;EAC/C,MAAMC,KAAK,GAAG,IAAIJ,MAAM,CAACE,GAAG,EAAEC,IAAI,CAAC;EAEnC,OAAOC,KAAK,CAACC,QAAQ,CAAC,CAAC;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAAC;EAAEC,OAAO;EAAEC;AAAS,CAAC,EAAE;EACvD,MAAMJ,KAAK,GAAG,IAAIL,SAAS,CAACQ,OAAO,EAAEC,QAAQ,CAAC;EAC9C,MAAMC,OAAO,GAAGL,KAAK,CAACM,QAAQ,CAAC,CAAC;EAEhC,OAAO;IAAER,GAAG,EAAEO,OAAO,CAACE,QAAQ;IAAER,IAAI,EAAEM,OAA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,KAAK,CAAC;IAEtD,IAAIwB,MAAM,CAAC/B,KAAK,EAAE;MAChB,MAAMiC,OAAO,GAAG5K,kBAAkB,CAAC0K,MAAM,CAACxB,KAAK,CAAC;;MAEhD;MACA,MAAM3I,MAAM,GAAG,CAACqK,OAAO,CAACxL,IAAI,EAAEwL,OAAO,CAACzL,GAAG,CAAC;MAE1C+L,SAAS,CAAC7G,GAAG,EAAE+B,WAAW,EAAE7F,MAAM,CAAC;IACrC;EACF;EAEAsK,cAAc,CAACxI,gBAAgB,CAAC,QAAQ,EAAE8I,aAAa,EAAE,KAAK,CAAC;AACjE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASD,SAASA,CAAC7G,GAAG,EAAE+B,WAAW,EAAE7F,MAAM,EAAE;EAC3C;EACA8D,GAAG,CAAC+G,SAAS,CAAC,UAAU,EAAE7K,MAAM,CAAC;;EAEjC;EACA6F,WAAW,CAACiF,KAAK,CAAC;IAChB9K,MAAM;IACND,IAAI,EAAE,EAAE;IACRgL,SAAS,EAAE;EACb,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-engine-plugin",
3
- "version": "4.0.57",
3
+ "version": "4.0.59",
4
4
  "description": "Defra forms engine",
5
5
  "type": "module",
6
6
  "files": [
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "license": "SEE LICENSE IN LICENSE",
72
72
  "dependencies": {
73
- "@defra/forms-model": "^3.0.614",
73
+ "@defra/forms-model": "^3.0.622",
74
74
  "@defra/hapi-tracing": "^1.29.0",
75
75
  "@defra/interactive-map": "^0.0.4-alpha",
76
76
  "@elastic/ecs-pino-format": "^1.5.0",
@@ -112,7 +112,7 @@ export function initMaps(config = {}) {
112
112
  // If there are location components on the page fix up the main form submit
113
113
  // handler so it doesn't fire when using the integrated map search feature
114
114
  if (locations.length) {
115
- const form = document.querySelector('form')
115
+ const form = locations[0].closest('form')
116
116
 
117
117
  if (form === null) {
118
118
  return