@defra/forms-engine-plugin 4.14.3 → 4.15.0

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 (46) hide show
  1. package/.public/assets-manifest.json +10 -1
  2. package/.public/javascripts/im-search-plugin.min.js +2 -0
  3. package/.public/javascripts/im-search-plugin.min.js.map +1 -0
  4. package/.public/javascripts/shared.min.js +1 -1
  5. package/.public/javascripts/shared.min.js.map +1 -1
  6. package/.public/javascripts/vendor/@defra.min.js +2 -0
  7. package/.public/javascripts/vendor/@defra.min.js.map +1 -0
  8. package/.public/javascripts/vendor/maplibre-gl.min.js +3 -0
  9. package/.public/javascripts/vendor/maplibre-gl.min.js.LICENSE.txt +4 -0
  10. package/.public/javascripts/vendor/maplibre-gl.min.js.map +1 -0
  11. package/.public/javascripts/vendor/preact.min.js +2 -0
  12. package/.public/javascripts/vendor/preact.min.js.map +1 -0
  13. package/.public/stylesheets/application.min.css +1 -1
  14. package/.public/stylesheets/application.min.css.map +1 -1
  15. package/.server/client/javascripts/geospatial-map.js +9 -4
  16. package/.server/client/javascripts/geospatial-map.js.map +1 -1
  17. package/.server/client/javascripts/map.js +18 -12
  18. package/.server/client/javascripts/map.js.map +1 -1
  19. package/.server/client/stylesheets/shared.scss +7 -0
  20. package/.server/server/plugins/engine/components/TelephoneNumberField.js +2 -4
  21. package/.server/server/plugins/engine/components/TelephoneNumberField.js.map +1 -1
  22. package/.server/server/plugins/engine/components/helpers/telephone.d.ts +0 -4
  23. package/.server/server/plugins/engine/components/helpers/telephone.js +6 -20
  24. package/.server/server/plugins/engine/components/helpers/telephone.js.map +1 -1
  25. package/.server/server/plugins/engine/components/helpers/telephone.test.js +5 -5
  26. package/.server/server/plugins/engine/components/helpers/telephone.test.js.map +1 -1
  27. package/.server/server/plugins/map/routes/index.d.ts +1 -2
  28. package/.server/server/plugins/map/routes/index.js +2 -32
  29. package/.server/server/plugins/map/routes/index.js.map +1 -1
  30. package/.server/server/plugins/map/service.d.ts +0 -7
  31. package/.server/server/plugins/map/service.js +0 -12
  32. package/.server/server/plugins/map/service.js.map +1 -1
  33. package/.server/server/plugins/map/service.test.js +0 -43
  34. package/.server/server/plugins/map/service.test.js.map +1 -1
  35. package/package.json +2 -1
  36. package/src/client/javascripts/geospatial-map.js +9 -5
  37. package/src/client/javascripts/map.js +18 -13
  38. package/src/client/stylesheets/shared.scss +7 -0
  39. package/src/server/plugins/engine/components/TelephoneNumberField.ts +1 -5
  40. package/src/server/plugins/engine/components/helpers/telephone.ts +11 -35
  41. package/src/server/plugins/map/routes/index.js +1 -37
  42. package/src/server/plugins/map/service.js +0 -13
  43. package/.server/server/plugins/map/test/__stubs__/nearest.d.ts +0 -37
  44. package/.server/server/plugins/map/test/__stubs__/nearest.js +0 -38
  45. package/.server/server/plugins/map/test/__stubs__/nearest.js.map +0 -1
  46. package/src/server/plugins/map/test/__stubs__/nearest.js +0 -46
@@ -1,3 +1,9 @@
1
+ // @ts-expect-error - no types
2
+ import createDatasetsPlugin from '@defra/interactive-map/plugins/datasets';
3
+ // @ts-expect-error - no types
4
+ import { maplibreLayerAdapter } from '@defra/interactive-map/plugins/datasets/adapters/maplibre';
5
+ // @ts-expect-error - no types
6
+ import createDrawPlugin from '@defra/interactive-map/plugins/draw-ml';
1
7
  import { bbox } from '@turf/bbox';
2
8
  import { EVENTS, createMap, defaultConfig, getCentroidGridRef, getCoordinateGridRef } from "./map.js";
3
9
  import { formatDelimtedList } from "./utils.js";
@@ -128,8 +134,6 @@ export function getBoundingBox(geojson) {
128
134
  * @param {number} index - the 0-based index
129
135
  */
130
136
  export function processGeospatial(config, geospatial, index) {
131
- // @ts-expect-error - Defra namespace currently comes from UMD support files
132
- const defra = window.defra;
133
137
  if (!(geospatial instanceof HTMLDivElement)) {
134
138
  return;
135
139
  }
@@ -143,13 +147,14 @@ export function processGeospatial(config, geospatial, index) {
143
147
  } = createContainers(geospatialInput, index);
144
148
  const geojson = getGeoJSON(geospatialInput);
145
149
  const bounds = geojson.features.length ? getBoundingBox(geojson) : undefined;
146
- const drawPlugin = defra.drawMLPlugin();
150
+ const drawPlugin = createDrawPlugin();
147
151
  const plugins = [drawPlugin];
148
152
  const country = geospatial.dataset.country;
149
153
  if (country) {
150
154
  // Add the country bounds as a dataset plugin to show the valid area on the map
151
155
  // and provide feedback to the user when they add features outside of the bounds.
152
- const datasetsPlugin = defra.datasetsMaplibrePlugin({
156
+ const datasetsPlugin = createDatasetsPlugin({
157
+ layerAdapter: maplibreLayerAdapter,
153
158
  datasets: [{
154
159
  id: 'invalid-area',
155
160
  label: 'Invalid areas',
@@ -1 +1 @@
1
- {"version":3,"file":"geospatial-map.js","names":["bbox","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","formatDelimtedList","helpPanelConfig","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","getLineOrShapeText","allowLine","allowShape","getAllowedTypesPhrase","allowPoint","items","push","getHelpPanelHtml","lineOrShapeText","doneExtra","allowedTypesText","lineFeatureProperties","stroke","fill","strokeWidth","polygonFeatureProperties","typeDescriptions","Point","LineString","Polygon","POINT_SVG","POLYGON_SVG","LINE_SVG","getGeoJSON","geospatialInput","value","trim","hasValue","features","JSON","parse","geojson","type","getBoundingBox","processGeospatial","config","geospatial","index","defra","window","HTMLDivElement","querySelector","HTMLTextAreaElement","listEl","mapId","createContainers","bounds","length","undefined","drawPlugin","drawMLPlugin","plugins","country","dataset","datasetsPlugin","datasetsMaplibrePlugin","datasets","id","apiPath","showInKey","showInMenu","style","initConfig","map","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","geometryTypes","geometrytypes","options","uiManager","getUIManager","context","addEventListeners","addFeatureToMap","feature","geometry","addFeature","addMarker","coordinates","createFeaturesHTML","disabled","readonly","createFeatureHTML","join","focusFeature","mapProvider","fitBounds","flattened","flat","points","i","slice","p","description","properties","changeAction","deleteAction","focusAction","links","actions","centroidGridReference","coordinateGridReference","generateID","crypto","randomUUID","activeFeature","getActiveFeature","setActiveFeature","resetActiveFeature","prepareGeometry","maxPrecision","formatPrecision","toFixed","forEach","getFeatures","getFeature","find","f","updateFeature","removeFeature","idx","findIndex","splice","getListRenderer","renderValue","renderList","html","innerHTML","getValueRenderer","stringify","getAllowableGeometryTypes","split","toggleActionButtons","hidden","types","includes","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","focus","select","on","mapReady","onMapReadyFactory","mapEl","document","createElement","setAttribute","listId","after","classList","add","onMapReady","e","addPanel","addButton","variant","iconSvgContent","onClick","enable","newPolygon","newLine","drawReady","onDrawReadyFactory","drawCreated","onDrawCreatedFactory","drawEdited","onDrawEditedFactory","drawCancelled","onDrawCancelledFactory","interactMarkerChange","onInteractMarkerChangedFactory","addEventListener","onListElClickFactory","onListElChangeFactory","onListElKeydownFactory","onDrawReady","onDrawCreated","onDrawEdited","changedFeature","featureId","onDrawCancelled","onInteractMarkerChange","activeFeatureId","coords","removeMarker","disable","deleteFeature","editFeature","selectFeature","target","HTMLElement","preventDefault","stopPropagation","tagName","action","HTMLInputElement","code"],"sources":["../../../src/client/javascripts/geospatial-map.js"],"sourcesContent":["import { bbox } from '@turf/bbox'\n\nimport {\n EVENTS,\n createMap,\n defaultConfig,\n getCentroidGridRef,\n getCoordinateGridRef\n} from '~/src/client/javascripts/map.js'\nimport { formatDelimtedList } from '~/src/client/javascripts/utils.js'\n\nconst helpPanelConfig = {\n showLabel: true,\n label: 'How to use this map',\n mobile: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n }\n}\n\n/**\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getLineOrShapeText(allowLine, allowShape) {\n if (allowLine && allowShape) {\n return 'a line or shape'\n }\n if (allowLine) {\n return 'a line'\n }\n if (allowShape) {\n return 'a shape'\n }\n return ''\n}\n\n/**\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getAllowedTypesPhrase(allowPoint, allowLine, allowShape) {\n const items = []\n\n if (allowPoint) {\n items.push('points')\n }\n if (allowLine) {\n items.push('lines')\n }\n if (allowShape) {\n items.push('shapes')\n }\n\n return formatDelimtedList(items, ',', 'or')\n}\n\n/**\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nexport function getHelpPanelHtml(allowPoint, allowLine, allowShape) {\n const lineOrShapeText = getLineOrShapeText(allowLine, allowShape)\n const doneExtra = lineOrShapeText\n ? `<li>Double‑click, or select 'Done', when you have finished drawing ${lineOrShapeText}</li>`\n : ''\n const allowedTypesText = getAllowedTypesPhrase(\n allowPoint,\n allowLine,\n allowShape\n )\n return `<p class=\"govuk-body-s govuk-!-margin-bottom-2\">You can add ${allowedTypesText} to the map.</p><ul class=\"govuk-list govuk-list--number govuk-body-s\"><li>Search for a county, place or postcode</li><li>Use the + and - icons to zoom in and out</li>${doneExtra}<li>Give the location a name</li></ul>`\n}\n\nconst lineFeatureProperties = {\n stroke: 'rgba(0, 11, 112, 1)',\n fill: 'rgba(0, 11, 112, 0.2)',\n strokeWidth: 2\n}\n\nconst polygonFeatureProperties = {\n stroke: 'rgb(0, 0, 0)',\n fill: 'rgba(255, 221, 0, 0.2)',\n strokeWidth: 2\n}\n\n/**\n * @type {Record<'Point' | 'LineString' | 'Polygon', string>}\n */\nconst typeDescriptions = {\n Point: 'Point',\n LineString: 'Line',\n Polygon: 'Shape'\n}\n\nconst POINT_SVG =\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\" /><circle cx=\"12\" cy=\"10\" r=\"3\" />'\nconst POLYGON_SVG =\n '<path d=\"M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10\"/><path d=\"M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z\"/>'\nconst LINE_SVG =\n '<path d=\"M5.706 16.294L16.294 5.706\"/><path d=\"M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z\"/>'\n\n/**\n * Extract and parses the GeoJSON from the textarea\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n */\nexport function getGeoJSON(geospatialInput) {\n const value = geospatialInput.value.trim()\n const hasValue = !!value\n\n /** @type {FeatureCollection} */\n const features = hasValue ? JSON.parse(value) : []\n\n /** @type {GeoJSON} */\n const geojson = {\n type: 'FeatureCollection',\n features\n }\n\n return geojson\n}\n\n/**\n * Gets the bounding box covering a feature collection\n * @param {GeoJSON} geojson - the geojson\n */\nexport function getBoundingBox(geojson) {\n return bbox(geojson)\n}\n\n/**\n * Processes a geospatial field to add map capability\n * @param {MapsEnvironmentConfig} config - the geospatial field element\n * @param {Element} geospatial - the geospatial field element\n * @param {number} index - the 0-based index\n */\nexport function processGeospatial(config, geospatial, index) {\n // @ts-expect-error - Defra namespace currently comes from UMD support files\n const defra = window.defra\n\n if (!(geospatial instanceof HTMLDivElement)) {\n return\n }\n\n const geospatialInput = geospatial.querySelector('.govuk-textarea')\n if (!(geospatialInput instanceof HTMLTextAreaElement)) {\n return\n }\n\n const { listEl, mapId } = createContainers(geospatialInput, index)\n const geojson = getGeoJSON(geospatialInput)\n const bounds = geojson.features.length ? getBoundingBox(geojson) : undefined\n const drawPlugin = defra.drawMLPlugin()\n const plugins = [drawPlugin]\n const country = geospatial.dataset.country\n\n if (country) {\n // Add the country bounds as a dataset plugin to show the valid area on the map\n // and provide feedback to the user when they add features outside of the bounds.\n const datasetsPlugin = defra.datasetsMaplibrePlugin({\n datasets: [\n {\n id: 'invalid-area',\n label: 'Invalid areas',\n geojson: `${config.apiPath}/maps/countries.geojson?omit=${country}`,\n showInKey: false,\n showInMenu: false,\n style: {\n stroke: 'gray',\n strokeWidth: 1,\n fill: 'rgba(211,211,211,0.8)'\n }\n },\n {\n id: 'valid-area',\n label: 'Valid areas',\n geojson: `${config.apiPath}/maps/countries.geojson?only=${country}`,\n showInKey: false,\n showInMenu: false,\n style: {\n stroke: 'rgba(0,112,60,1)',\n strokeWidth: 1\n }\n }\n ]\n })\n\n plugins.push(datasetsPlugin)\n }\n\n const initConfig = {\n ...defaultConfig,\n bounds,\n plugins\n }\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n const featuresManager = getFeaturesManager(geojson)\n const activeFeatureManager = getActiveFeatureManager()\n const geometryTypes = geospatial.dataset.geometrytypes\n const options = {\n geometryTypes\n }\n const uiManager = getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options\n )\n\n /**\n * @type {Context}\n */\n const context = {\n map,\n featuresManager,\n activeFeatureManager,\n uiManager,\n interactPlugin,\n drawPlugin\n }\n\n addEventListeners(context)\n}\n\n/**\n * Adds a feature to the map\n * @param {Feature} feature - the geojson feature\n * @param {any} drawPlugin - the map draw plugin\n * @param {InteractiveMap} map - the interactive map\n */\nexport function addFeatureToMap(feature, drawPlugin, map) {\n switch (feature.geometry.type) {\n case 'Polygon':\n drawPlugin.addFeature({ ...feature, ...polygonFeatureProperties })\n break\n case 'LineString':\n drawPlugin.addFeature({ ...feature, ...lineFeatureProperties })\n break\n case 'Point':\n map.addMarker(feature.id, feature.geometry.coordinates)\n break\n default:\n break\n }\n}\n\n/**\n * Returns HTML summary list for the features\n * @param {FeatureCollection} features - the features\n * @param {string} mapId - the ID of the map\n * @param {boolean} [disabled] - render the list with disabled links\n * @param {boolean} [readonly] - render the list in readonly mode\n */\nexport function createFeaturesHTML(\n features,\n mapId,\n disabled = false,\n readonly = false\n) {\n return `<dl class=\"govuk-summary-list\">\n ${features.map((feature, index) => createFeatureHTML(feature, index, mapId, disabled, readonly)).join('\\n')}\n </dl>`\n}\n\n/**\n * Focus feature\n * @param {Feature} feature - the feature\n * @param {MapLibreMap} mapProvider - the feature id\n */\nexport function focusFeature(feature, mapProvider) {\n mapProvider.fitBounds(bbox(feature))\n}\n\n/**\n * Returns HTML summary row for an single feature\n * @param {Feature} feature - the geo feature\n * @param {number} index - the feature index\n * @param {string} mapId - the ID of the map\n * @param {boolean} [disabled] - render the list with disabled links\n * @param {boolean} [readonly] - render the list item in readonly mode\n */\nexport function createFeatureHTML(\n feature,\n index,\n mapId,\n disabled = false,\n readonly = false\n) {\n const flattened = feature.geometry.coordinates.flat(2)\n\n const points = []\n for (let i = 0; i < flattened.length; i += 2) {\n points.push(flattened.slice(i, i + 2).join(', '))\n }\n const coordinates = points.map((p) => `<li>${p}</li>`).join('')\n\n const description = readonly\n ? `<p class=\"govuk-body govuk-!-margin-bottom-0\">${feature.properties.description}</p>`\n : `<input class=\"govuk-input govuk-!-width-two-thirds\" type=\"text\" id=\"description_${index}\" value=\"${feature.properties.description}\" data-id=\"${feature.id}\">`\n\n // Change action link\n const changeAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state ${disabled ? 'govuk-link--disabled' : ''}\" href=\"#${mapId}\" data-action=\"edit\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Update<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Delete action link\n const deleteAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state ${disabled ? 'govuk-link--disabled' : ''}\" href=\"#\" data-action=\"delete\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Delete<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Focus action link\n const focusAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"focus\" data-id=\"${feature.id}\">Show<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n const links = readonly ? focusAction() : `${changeAction()}${deleteAction()}`\n\n const actions = `<ul class=\"govuk-summary-list__actions-list\">${links}</ul>`\n\n return `<div class=\"govuk-summary-list__row govuk-summary-list__row--no-border\">\n <dt class=\"govuk-summary-list__key\">\n <div class=\"govuk-form-group\">\n <label class=\"govuk-label govuk-label--s\" ${readonly ? '' : `for=\"description_${index}\"`}>Location ${index + 1} description</label>\n ${description}\n </div>\n </dt>\n <dd class=\"govuk-summary-list__actions\">\n ${actions}\n </dd>\n</div>\n<div class=\"govuk-summary-list__row\">\n <details class=\"govuk-details govuk-!-margin-bottom-2\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">Coordinates</span>\n </summary>\n <div class=\"govuk-details__text\">\n <dl class=\"govuk-summary-list\">\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Type</dt>\n <dd class=\"govuk-summary-list__value\">${typeDescriptions[feature.geometry.type]}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Centre grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.centroidGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">First point grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.coordinateGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Detailed coordinates</dt>\n <dd class=\"govuk-summary-list__value\">\n <ol class=\"govuk-list govuk-list--number\">${coordinates}</ol>\n </dd>\n </div>\n </dl>\n </div>\n </details>\n</div>`\n}\n\n/**\n * Generate a random id\n */\nfunction generateID() {\n return window.crypto.randomUUID()\n}\n\n/**\n * Factory closure to track the active feature id\n * @returns {ActiveFeatureManager}\n */\nfunction getActiveFeatureManager() {\n /** @type {string | undefined} */\n let activeFeature\n\n /**\n * Returns the active feature id\n * @type {GetActiveFeature}\n */\n function getActiveFeature() {\n return activeFeature\n }\n\n /**\n * Sets the active feature id\n * @type {SetActiveFeature}\n */\n function setActiveFeature(id) {\n activeFeature = id\n }\n\n /**\n * Resets the active feature id\n * @type {ResetActiveFeature}\n */\n function resetActiveFeature() {\n activeFeature = undefined\n }\n\n return {\n getActiveFeature,\n setActiveFeature,\n resetActiveFeature\n }\n}\n\n/**\n * Reduce coordinate precision to 7 dps\n * @param {Feature} feature\n */\nfunction prepareGeometry(feature) {\n const { geometry } = feature\n const maxPrecision = 7\n\n /**\n * @param {Coordinates} coordinates\n */\n function formatPrecision(coordinates) {\n coordinates[0] = +coordinates[0].toFixed(maxPrecision)\n coordinates[1] = +coordinates[1].toFixed(maxPrecision)\n }\n\n if (geometry.type === 'Point') {\n formatPrecision(geometry.coordinates)\n } else if (geometry.type === 'LineString') {\n geometry.coordinates.forEach(formatPrecision)\n } else {\n geometry.coordinates.flat().forEach(formatPrecision)\n }\n}\n\n/**\n * Factory closure to return a features manager\n * @param {GeoJSON} geojson\n * @returns {FeaturesManager}\n */\nfunction getFeaturesManager(geojson) {\n /**\n * Get a feature from the geojson by id\n * @type {GetFeatures}\n */\n function getFeatures() {\n return geojson.features\n }\n\n /**\n * Get a feature from the geojson by id\n * @type {GetFeature}\n */\n function getFeature(id) {\n return geojson.features.find((f) => f.id === id)\n }\n\n /**\n * Add a feature to the geojson\n * @type {AddFeature}\n */\n function addFeature(feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n prepareGeometry(feature)\n\n geojson.features.push(feature)\n }\n\n /**\n * Updates a feature in the geojson\n * @type {UpdateFeature}\n */\n function updateFeature(id, geometry) {\n const feature = getFeature(id)\n\n // Ensure the feature exists in the geojson\n if (feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n feature.geometry = geometry\n prepareGeometry(feature)\n }\n\n return feature\n }\n\n /**\n * Removes a feature from the geojson\n * @type {RemoveFeature}\n */\n function removeFeature(id) {\n const idx = geojson.features.findIndex((f) => f.id === id)\n\n return idx > -1 ? geojson.features.splice(idx, 1) : undefined\n }\n\n return {\n getFeatures,\n getFeature,\n addFeature,\n updateFeature,\n removeFeature\n }\n}\n\n/**\n * Factory to render features into the list and hidden textarea\n * @param {GeoJSON} geojson - the geojson of features\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {Function} renderValue - function that renders the features JSON into the hidden textarea\n * @returns {RenderList}\n */\nfunction getListRenderer(geojson, mapId, listEl, renderValue) {\n return function renderList(disabled = false) {\n const html = createFeaturesHTML(geojson.features, mapId, disabled)\n\n listEl.innerHTML = html\n\n renderValue()\n }\n}\n\n/**\n * Factory to render features JSON into the hidden textarea\n * @param {GeoJSON} geojson - the features\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @returns {RenderValue}\n */\nfunction getValueRenderer(geojson, geospatialInput) {\n return function renderValue() {\n geospatialInput.value = JSON.stringify(geojson.features, null, 2)\n }\n}\n\n/**\n * Factory closure to manage the UI\n * @param {GeoJSON} geojson - the features\n * @param {InteractiveMap} map - the map\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @param { UIManagerOptions | undefined } options - extra options such as allowable geometry types\n */\nexport function getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options\n) {\n /**\n * Get a CSV list of geometry types the user can create\n * @returns {string[]}\n */\n function getAllowableGeometryTypes() {\n return options?.geometryTypes\n ? options.geometryTypes.split(',')\n : ['point', 'line', 'shape']\n }\n\n /**\n * Toggle the hidden state of the action buttons\n * @type {ToggleActionButtons}\n */\n function toggleActionButtons(hidden) {\n const types = getAllowableGeometryTypes()\n if (types.includes('point')) {\n map.toggleButtonState('btnAddPoint', 'hidden', hidden)\n }\n if (types.includes('shape')) {\n map.toggleButtonState('btnAddPolygon', 'hidden', hidden)\n }\n if (types.includes('line')) {\n map.toggleButtonState('btnAddLine', 'hidden', hidden)\n }\n }\n\n /**\n * Set focus to the last description input\n * @type {FocusDescriptionInput}\n */\n function focusDescriptionInput() {\n const inputs = listEl.querySelectorAll('input')\n if (inputs.length) {\n const lastInput = /** @type {HTMLInputElement} */ inputs.item(\n inputs.length - 1\n )\n lastInput.focus()\n lastInput.select()\n }\n }\n\n const renderValue = getValueRenderer(geojson, geospatialInput)\n const renderList = getListRenderer(geojson, mapId, listEl, renderValue)\n\n /** @type {UIManager} */\n return {\n renderList,\n renderValue,\n listEl,\n toggleActionButtons,\n focusDescriptionInput,\n getAllowableGeometryTypes\n }\n}\n\n/**\n * Setup the UI event listeners\n * @param {Context} context - the context\n */\nfunction addEventListeners(context) {\n const { map } = context\n\n map.on(EVENTS.mapReady, onMapReadyFactory(context))\n}\n\n/**\n * Create the map and list containers and adds them to the DOM\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n * @param {number} index - the 0 based index\n */\nfunction createContainers(geospatialInput, index) {\n const mapEl = document.createElement('div')\n const mapId = `geospatialmap_${index}`\n\n mapEl.setAttribute('id', mapId)\n mapEl.setAttribute('class', 'map-container')\n\n const listEl = document.createElement('div')\n const listId = `${mapId}_list`\n listEl.setAttribute('id', listId)\n\n geospatialInput.after(mapEl)\n mapEl.after(listEl)\n geospatialInput.classList.add('js-hidden')\n\n return { mapEl, listEl, mapId }\n}\n\n/**\n * Callback factory function which fires when the map is ready\n * @param {Context} context - the UI context\n */\nfunction onMapReadyFactory(context) {\n const { map, activeFeatureManager, uiManager, interactPlugin, drawPlugin } =\n context\n const { toggleActionButtons, renderList, getAllowableGeometryTypes } =\n uiManager\n const { resetActiveFeature } = activeFeatureManager\n\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 return function onMapReady(e) {\n const types = getAllowableGeometryTypes()\n const allowPoint = types.includes('point')\n const allowLine = types.includes('line')\n const allowShape = types.includes('shape')\n\n // Add info panel\n map.addPanel('info', {\n ...helpPanelConfig,\n html: getHelpPanelHtml(allowPoint, allowLine, allowShape)\n })\n\n if (allowPoint) {\n map.addButton('btnAddPoint', {\n variant: 'tertiary',\n label: 'Add point',\n iconSvgContent: POINT_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n interactPlugin.enable()\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n if (allowShape) {\n map.addButton('btnAddPolygon', {\n variant: 'tertiary',\n label: 'Add shape',\n iconSvgContent: POLYGON_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n drawPlugin.newPolygon(generateID(), polygonFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n if (allowLine) {\n map.addButton('btnAddLine', {\n variant: 'tertiary',\n label: 'Add line',\n iconSvgContent: LINE_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n drawPlugin.newLine(generateID(), lineFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n // Set the map provider on the context\n context.mapProvider = e.map\n\n map.on(EVENTS.drawReady, onDrawReadyFactory(context))\n map.on(EVENTS.drawCreated, onDrawCreatedFactory(context))\n map.on(EVENTS.drawEdited, onDrawEditedFactory(context))\n map.on(EVENTS.drawCancelled, onDrawCancelledFactory(context))\n map.on(EVENTS.interactMarkerChange, onInteractMarkerChangedFactory(context))\n\n const { listEl } = uiManager\n listEl.addEventListener('click', onListElClickFactory(context), false)\n listEl.addEventListener('change', onListElChangeFactory(context), false)\n listEl.addEventListener('keydown', onListElKeydownFactory(), false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin is ready\n * @param {Context} context - the UI context\n */\nfunction onDrawReadyFactory(context) {\n const { featuresManager, uiManager, drawPlugin, map } = context\n const { renderList } = uiManager\n const { getFeatures } = featuresManager\n\n /**\n * Callback when the draw plugin is ready\n */\n return function onDrawReady() {\n getFeatures().forEach((feature) =>\n addFeatureToMap(feature, drawPlugin, map)\n )\n\n // Update the features\n renderList()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin creates a new feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCreatedFactory(context) {\n const { featuresManager, uiManager } = context\n const { addFeature } = featuresManager\n const { renderList, toggleActionButtons, focusDescriptionInput } = uiManager\n\n /**\n * Callback when a draw feature has been created\n * @param {Feature} e\n */\n return function onDrawCreated(e) {\n // New feature\n addFeature({\n ...e,\n properties: {\n description: ''\n }\n })\n\n // Update the features\n renderList()\n toggleActionButtons(false)\n focusDescriptionInput()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin edits a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawEditedFactory(context) {\n const { featuresManager, activeFeatureManager, uiManager } = context\n const { updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Callback when a draw feature has been edited\n * @param {{ id: string, geometry: Geometry }} e\n */\n return function onDrawEdited(e) {\n const changedFeature = e\n const featureId = changedFeature.id\n\n if (getActiveFeature() === featureId) {\n updateFeature(featureId, changedFeature.geometry)\n\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin cancels the editing of a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCancelledFactory(context) {\n const { uiManager, activeFeatureManager } = context\n const { toggleActionButtons, renderList } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback when a draw feature has been cancelled\n */\n return function onDrawCancelled() {\n toggleActionButtons(false)\n resetActiveFeature()\n renderList()\n }\n}\n\n/**\n * Callback factory function that fires when an interact marker has been changed\n * @param {Context} context - the UI context\n */\nfunction onInteractMarkerChangedFactory(context) {\n const {\n featuresManager,\n activeFeatureManager,\n map,\n interactPlugin,\n uiManager\n } = context\n const { addFeature, updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, focusDescriptionInput, toggleActionButtons } = uiManager\n\n /**\n * Callback when an interact marker has been changed\n * @param {{ coords: Coordinates }} e\n */\n return function onInteractMarkerChange(e) {\n const activeFeatureId = getActiveFeature()\n\n if (activeFeatureId) {\n // Editing an existing point\n const feature = updateFeature(activeFeatureId, {\n type: 'Point',\n coordinates: e.coords\n })\n\n map.addMarker(activeFeatureId, e.coords)\n\n if (feature) {\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n } else {\n // Adding a new point\n const id = generateID()\n addFeature({\n type: 'Feature',\n properties: {\n description: ''\n },\n geometry: {\n type: 'Point',\n coordinates: e.coords\n },\n id\n })\n\n map.addMarker(id, e.coords)\n\n // Update the features\n renderList()\n\n focusDescriptionInput()\n }\n map.removeMarker('location')\n\n interactPlugin.disable()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function that fires a 'click' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElClickFactory(context) {\n const {\n map,\n mapProvider,\n featuresManager,\n activeFeatureManager,\n interactPlugin,\n uiManager,\n drawPlugin\n } = context\n const { getFeature, removeFeature } = featuresManager\n const { getActiveFeature, setActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Delete a feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function deleteFeature(id, type) {\n if (type === 'Point') {\n map.removeMarker(id)\n removeFeature(id)\n } else {\n drawPlugin.deleteFeature(id)\n removeFeature(id)\n }\n\n renderList()\n }\n\n /**\n * Start editing feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function editFeature(id, type) {\n setActiveFeature(id)\n\n // \"Change\" feature link was clicked\n if (type === 'Point') {\n interactPlugin.selectFeature({ featureId: id })\n interactPlugin.enable()\n } else {\n drawPlugin.editFeature(id)\n }\n\n const feature = getFeature(id)\n if (feature && mapProvider) {\n focusFeature(feature, mapProvider)\n }\n\n toggleActionButtons(true)\n renderList(true)\n }\n\n /**\n * List container delegated 'click' events handler\n * @param {MouseEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n if (getActiveFeature()) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (\n target.tagName === 'A' &&\n target.dataset.action &&\n target.dataset.id &&\n target.dataset.type\n ) {\n const { action, id, type } = target.dataset\n\n if (action === 'edit') {\n // \"Update\" feature link was clicked\n editFeature(id, type)\n } else {\n e.preventDefault()\n e.stopPropagation()\n\n if (action === 'delete') {\n // \"Remove\" feature link was clicked\n deleteFeature(id, type)\n }\n }\n }\n }\n}\n\n/**\n * Callback factory function that fires when a 'change' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElChangeFactory(context) {\n const { featuresManager, uiManager } = context\n const { getFeature } = featuresManager\n const { renderValue } = uiManager\n\n /**\n * List container delegated 'change' events handler\n * Used to update the description of features\n * @param {Event} e\n */\n return function (e) {\n e.preventDefault()\n e.stopPropagation()\n\n const target = e.target\n if (!(target instanceof HTMLInputElement) || !target.dataset.id) {\n return\n }\n\n const { id } = target.dataset\n const feature = getFeature(id)\n\n if (feature) {\n feature.properties.description = target.value.trim()\n renderValue()\n }\n }\n}\n\n/**\n * Callback factory function that fires when a 'keydown' event is fired on the list container\n */\nfunction onListElKeydownFactory() {\n /**\n * List container delegated 'keydown' events handler\n * Fixes the issue of pressing \"Enter\" key in the description input triggering the map search\n * @param {KeyboardEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLInputElement)) {\n return\n }\n\n if (e.code === 'Enter' || e.code === 'NumpadEnter') {\n e.preventDefault()\n e.stopPropagation()\n }\n }\n}\n\n/**\n * @import { MapsEnvironmentConfig, InteractiveMap } from '~/src/client/javascripts/map.js'\n */\n\n/**\n * @import { Geometry, FeatureCollection, Feature, Coordinates } from '~/src/server/plugins/engine/types.js'\n */\n\n/**\n * @typedef {object} GeoJSON\n * @property {'FeatureCollection'} type - the GeoJSON type string\n * @property {FeatureCollection} features - the features\n */\n\n/**\n * Gets all the features\n * @callback GetFeatures\n * @returns {FeatureCollection}\n */\n\n/**\n * Gets a feature from the geojson by id\n * @callback GetFeature\n * @param {string} id - the feature id\n * @returns {Feature | undefined}\n */\n\n/**\n * Add a feature to the geojson\n * @callback AddFeature\n * @param {Feature} feature - the feature to add\n */\n\n/**\n * Update a feature in the geojson\n * @callback UpdateFeature\n * @param {string} id - the feature id\n * @param {Geometry} geometry - the feature geometry\n * @returns {Feature | undefined}\n */\n\n/**\n * Removes a feature from the geojson\n * @callback RemoveFeature\n * @param {string} id - the feature id\n */\n\n/**\n * Gets the active feature id\n * @callback GetActiveFeature\n * @returns {string | undefined}\n */\n\n/**\n * Set the active feature id\n * @callback SetActiveFeature\n * @param {string} id - the feature id\n * @returns {void}\n */\n\n/**\n * Resets the active feature id\n * @callback ResetActiveFeature\n * @returns {void}\n */\n\n/**\n * Renders the features into the list\n * @callback RenderList\n * @param {boolean} [disabled] - whether to render the list with disabled links\n * @returns {void}\n */\n\n/**\n * Renders the features JSON into the hidden textarea\n * @callback RenderValue\n * @returns {void}\n */\n\n/**\n * Toggles the action button hidden state\n * @callback ToggleActionButtons\n * @param {boolean} hidden - whether to hide the action buttons\n * @returns {void}\n */\n\n/**\n * Returns the list of geometry types a user can create\n * @callback GetAllowableGeometryTypes\n * @returns {string[]}\n */\n\n/**\n * Set focus to the last description input\n * @callback FocusDescriptionInput\n * @returns {void}\n */\n\n/**\n * @typedef {object} FeaturesManager\n * @property {GetFeatures} getFeatures - function that gets all the features\n * @property {GetFeature} getFeature - function that gets a feature from the geojson\n * @property {AddFeature} addFeature - function that adds feature to the geojson\n * @property {UpdateFeature} updateFeature - function that updates a feature in the geojson\n * @property {RemoveFeature} removeFeature - function that removes a feature from the geojson\n */\n\n/**\n * @typedef {object} ActiveFeatureManager\n * @property {GetActiveFeature} getActiveFeature - function that returns the current active feature id\n * @property {SetActiveFeature} setActiveFeature - function that sets the current active feature id\n * @property {ResetActiveFeature} resetActiveFeature - function that resets the current active feature id\n */\n\n/**\n * @typedef {object} UIManager\n * @property {RenderValue} renderValue - function that renders the features JSON into the hidden textarea\n * @property {RenderList} renderList - function that renders the features into the list\n * @property {HTMLDivElement} listEl - the summary list of features\n * @property {ToggleActionButtons} toggleActionButtons - function that toggles the action buttons\n * @property {FocusDescriptionInput} focusDescriptionInput - function that sets focus to a description input element\n * @property {GetAllowableGeometryTypes} getAllowableGeometryTypes - function that returns the array of geometry types a user can create\n */\n\n/**\n * @typedef {object} Context\n * @property {InteractiveMap} map - the interactive map\n * @property {MapLibreMap} [mapProvider] - the interactive map provider\n * @property {FeaturesManager} featuresManager - the features manager\n * @property {ActiveFeatureManager} activeFeatureManager - the active feature manager\n * @property {UIManager} uiManager - the UI manager\n * @property {any} interactPlugin - the map interact plugin\n * @property {any} drawPlugin - the map draw plugin\n */\n\n/**\n * @import { MapLibreMap, UIManagerOptions } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAY;AAEjC,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB;AAEtB,SAASC,kBAAkB;AAE3B,MAAMC,eAAe,GAAG;EACtBC,SAAS,EAAE,IAAI;EACfC,K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,CAACwC,eAAe,CAAC,CAAC;IACrB;EACF,CAAC;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"geospatial-map.js","names":["createDatasetsPlugin","maplibreLayerAdapter","createDrawPlugin","bbox","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","formatDelimtedList","helpPanelConfig","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","getLineOrShapeText","allowLine","allowShape","getAllowedTypesPhrase","allowPoint","items","push","getHelpPanelHtml","lineOrShapeText","doneExtra","allowedTypesText","lineFeatureProperties","stroke","fill","strokeWidth","polygonFeatureProperties","typeDescriptions","Point","LineString","Polygon","POINT_SVG","POLYGON_SVG","LINE_SVG","getGeoJSON","geospatialInput","value","trim","hasValue","features","JSON","parse","geojson","type","getBoundingBox","processGeospatial","config","geospatial","index","HTMLDivElement","querySelector","HTMLTextAreaElement","listEl","mapId","createContainers","bounds","length","undefined","drawPlugin","plugins","country","dataset","datasetsPlugin","layerAdapter","datasets","id","apiPath","showInKey","showInMenu","style","initConfig","map","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","geometryTypes","geometrytypes","options","uiManager","getUIManager","context","addEventListeners","addFeatureToMap","feature","geometry","addFeature","addMarker","coordinates","createFeaturesHTML","disabled","readonly","createFeatureHTML","join","focusFeature","mapProvider","fitBounds","flattened","flat","points","i","slice","p","description","properties","changeAction","deleteAction","focusAction","links","actions","centroidGridReference","coordinateGridReference","generateID","window","crypto","randomUUID","activeFeature","getActiveFeature","setActiveFeature","resetActiveFeature","prepareGeometry","maxPrecision","formatPrecision","toFixed","forEach","getFeatures","getFeature","find","f","updateFeature","removeFeature","idx","findIndex","splice","getListRenderer","renderValue","renderList","html","innerHTML","getValueRenderer","stringify","getAllowableGeometryTypes","split","toggleActionButtons","hidden","types","includes","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","focus","select","on","mapReady","onMapReadyFactory","mapEl","document","createElement","setAttribute","listId","after","classList","add","onMapReady","e","addPanel","addButton","variant","iconSvgContent","onClick","enable","newPolygon","newLine","drawReady","onDrawReadyFactory","drawCreated","onDrawCreatedFactory","drawEdited","onDrawEditedFactory","drawCancelled","onDrawCancelledFactory","interactMarkerChange","onInteractMarkerChangedFactory","addEventListener","onListElClickFactory","onListElChangeFactory","onListElKeydownFactory","onDrawReady","onDrawCreated","onDrawEdited","changedFeature","featureId","onDrawCancelled","onInteractMarkerChange","activeFeatureId","coords","removeMarker","disable","deleteFeature","editFeature","selectFeature","target","HTMLElement","preventDefault","stopPropagation","tagName","action","HTMLInputElement","code"],"sources":["../../../src/client/javascripts/geospatial-map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'\n// @ts-expect-error - no types\nimport { maplibreLayerAdapter } from '@defra/interactive-map/plugins/datasets/adapters/maplibre'\n// @ts-expect-error - no types\nimport createDrawPlugin from '@defra/interactive-map/plugins/draw-ml'\nimport { bbox } from '@turf/bbox'\n\nimport {\n EVENTS,\n createMap,\n defaultConfig,\n getCentroidGridRef,\n getCoordinateGridRef\n} from '~/src/client/javascripts/map.js'\nimport { formatDelimtedList } from '~/src/client/javascripts/utils.js'\n\nconst helpPanelConfig = {\n showLabel: true,\n label: 'How to use this map',\n mobile: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n tablet: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n },\n desktop: {\n slot: 'drawer',\n open: true,\n dismissible: true,\n modal: false\n }\n}\n\n/**\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getLineOrShapeText(allowLine, allowShape) {\n if (allowLine && allowShape) {\n return 'a line or shape'\n }\n if (allowLine) {\n return 'a line'\n }\n if (allowShape) {\n return 'a shape'\n }\n return ''\n}\n\n/**\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getAllowedTypesPhrase(allowPoint, allowLine, allowShape) {\n const items = []\n\n if (allowPoint) {\n items.push('points')\n }\n if (allowLine) {\n items.push('lines')\n }\n if (allowShape) {\n items.push('shapes')\n }\n\n return formatDelimtedList(items, ',', 'or')\n}\n\n/**\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nexport function getHelpPanelHtml(allowPoint, allowLine, allowShape) {\n const lineOrShapeText = getLineOrShapeText(allowLine, allowShape)\n const doneExtra = lineOrShapeText\n ? `<li>Double‑click, or select 'Done', when you have finished drawing ${lineOrShapeText}</li>`\n : ''\n const allowedTypesText = getAllowedTypesPhrase(\n allowPoint,\n allowLine,\n allowShape\n )\n return `<p class=\"govuk-body-s govuk-!-margin-bottom-2\">You can add ${allowedTypesText} to the map.</p><ul class=\"govuk-list govuk-list--number govuk-body-s\"><li>Search for a county, place or postcode</li><li>Use the + and - icons to zoom in and out</li>${doneExtra}<li>Give the location a name</li></ul>`\n}\n\nconst lineFeatureProperties = {\n stroke: 'rgba(0, 11, 112, 1)',\n fill: 'rgba(0, 11, 112, 0.2)',\n strokeWidth: 2\n}\n\nconst polygonFeatureProperties = {\n stroke: 'rgb(0, 0, 0)',\n fill: 'rgba(255, 221, 0, 0.2)',\n strokeWidth: 2\n}\n\n/**\n * @type {Record<'Point' | 'LineString' | 'Polygon', string>}\n */\nconst typeDescriptions = {\n Point: 'Point',\n LineString: 'Line',\n Polygon: 'Shape'\n}\n\nconst POINT_SVG =\n '<path d=\"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0\" /><circle cx=\"12\" cy=\"10\" r=\"3\" />'\nconst POLYGON_SVG =\n '<path d=\"M19.5 7v10M4.5 7v10M7 19.5h10M7 4.5h10\"/><path d=\"M22 18v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zm0-15v3a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 18v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1zM7 3v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1z\"/>'\nconst LINE_SVG =\n '<path d=\"M5.706 16.294L16.294 5.706\"/><path d=\"M21 2v3c0 .549-.451 1-1 1h-3c-.549 0-1-.451-1-1V2c0-.549.451-1 1-1h3c.549 0 1 .451 1 1zM6 17v3c0 .549-.451 1-1 1H2c-.549 0-1-.451-1-1v-3c0-.549.451-1 1-1h3c.549 0 1 .451 1 1z\"/>'\n\n/**\n * Extract and parses the GeoJSON from the textarea\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n */\nexport function getGeoJSON(geospatialInput) {\n const value = geospatialInput.value.trim()\n const hasValue = !!value\n\n /** @type {FeatureCollection} */\n const features = hasValue ? JSON.parse(value) : []\n\n /** @type {GeoJSON} */\n const geojson = {\n type: 'FeatureCollection',\n features\n }\n\n return geojson\n}\n\n/**\n * Gets the bounding box covering a feature collection\n * @param {GeoJSON} geojson - the geojson\n */\nexport function getBoundingBox(geojson) {\n return bbox(geojson)\n}\n\n/**\n * Processes a geospatial field to add map capability\n * @param {MapsEnvironmentConfig} config - the geospatial field element\n * @param {Element} geospatial - the geospatial field element\n * @param {number} index - the 0-based index\n */\nexport function processGeospatial(config, geospatial, index) {\n if (!(geospatial instanceof HTMLDivElement)) {\n return\n }\n\n const geospatialInput = geospatial.querySelector('.govuk-textarea')\n if (!(geospatialInput instanceof HTMLTextAreaElement)) {\n return\n }\n\n const { listEl, mapId } = createContainers(geospatialInput, index)\n const geojson = getGeoJSON(geospatialInput)\n const bounds = geojson.features.length ? getBoundingBox(geojson) : undefined\n const drawPlugin = createDrawPlugin()\n const plugins = [drawPlugin]\n const country = geospatial.dataset.country\n\n if (country) {\n // Add the country bounds as a dataset plugin to show the valid area on the map\n // and provide feedback to the user when they add features outside of the bounds.\n const datasetsPlugin = createDatasetsPlugin({\n layerAdapter: maplibreLayerAdapter,\n datasets: [\n {\n id: 'invalid-area',\n label: 'Invalid areas',\n geojson: `${config.apiPath}/maps/countries.geojson?omit=${country}`,\n showInKey: false,\n showInMenu: false,\n style: {\n stroke: 'gray',\n strokeWidth: 1,\n fill: 'rgba(211,211,211,0.8)'\n }\n },\n {\n id: 'valid-area',\n label: 'Valid areas',\n geojson: `${config.apiPath}/maps/countries.geojson?only=${country}`,\n showInKey: false,\n showInMenu: false,\n style: {\n stroke: 'rgba(0,112,60,1)',\n strokeWidth: 1\n }\n }\n ]\n })\n\n plugins.push(datasetsPlugin)\n }\n\n const initConfig = {\n ...defaultConfig,\n bounds,\n plugins\n }\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n const featuresManager = getFeaturesManager(geojson)\n const activeFeatureManager = getActiveFeatureManager()\n const geometryTypes = geospatial.dataset.geometrytypes\n const options = {\n geometryTypes\n }\n const uiManager = getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options\n )\n\n /**\n * @type {Context}\n */\n const context = {\n map,\n featuresManager,\n activeFeatureManager,\n uiManager,\n interactPlugin,\n drawPlugin\n }\n\n addEventListeners(context)\n}\n\n/**\n * Adds a feature to the map\n * @param {Feature} feature - the geojson feature\n * @param {any} drawPlugin - the map draw plugin\n * @param {InteractiveMap} map - the interactive map\n */\nexport function addFeatureToMap(feature, drawPlugin, map) {\n switch (feature.geometry.type) {\n case 'Polygon':\n drawPlugin.addFeature({ ...feature, ...polygonFeatureProperties })\n break\n case 'LineString':\n drawPlugin.addFeature({ ...feature, ...lineFeatureProperties })\n break\n case 'Point':\n map.addMarker(feature.id, feature.geometry.coordinates)\n break\n default:\n break\n }\n}\n\n/**\n * Returns HTML summary list for the features\n * @param {FeatureCollection} features - the features\n * @param {string} mapId - the ID of the map\n * @param {boolean} [disabled] - render the list with disabled links\n * @param {boolean} [readonly] - render the list in readonly mode\n */\nexport function createFeaturesHTML(\n features,\n mapId,\n disabled = false,\n readonly = false\n) {\n return `<dl class=\"govuk-summary-list\">\n ${features.map((feature, index) => createFeatureHTML(feature, index, mapId, disabled, readonly)).join('\\n')}\n </dl>`\n}\n\n/**\n * Focus feature\n * @param {Feature} feature - the feature\n * @param {MapLibreMap} mapProvider - the feature id\n */\nexport function focusFeature(feature, mapProvider) {\n mapProvider.fitBounds(bbox(feature))\n}\n\n/**\n * Returns HTML summary row for an single feature\n * @param {Feature} feature - the geo feature\n * @param {number} index - the feature index\n * @param {string} mapId - the ID of the map\n * @param {boolean} [disabled] - render the list with disabled links\n * @param {boolean} [readonly] - render the list item in readonly mode\n */\nexport function createFeatureHTML(\n feature,\n index,\n mapId,\n disabled = false,\n readonly = false\n) {\n const flattened = feature.geometry.coordinates.flat(2)\n\n const points = []\n for (let i = 0; i < flattened.length; i += 2) {\n points.push(flattened.slice(i, i + 2).join(', '))\n }\n const coordinates = points.map((p) => `<li>${p}</li>`).join('')\n\n const description = readonly\n ? `<p class=\"govuk-body govuk-!-margin-bottom-0\">${feature.properties.description}</p>`\n : `<input class=\"govuk-input govuk-!-width-two-thirds\" type=\"text\" id=\"description_${index}\" value=\"${feature.properties.description}\" data-id=\"${feature.id}\">`\n\n // Change action link\n const changeAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state ${disabled ? 'govuk-link--disabled' : ''}\" href=\"#${mapId}\" data-action=\"edit\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Update<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Delete action link\n const deleteAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state ${disabled ? 'govuk-link--disabled' : ''}\" href=\"#\" data-action=\"delete\" data-id=\"${feature.id}\"\n data-type=\"${feature.geometry.type}\">Delete<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n // Focus action link\n const focusAction = () => `<li class=\"govuk-summary-list__actions-list-item\">\n <a class=\"govuk-link govuk-link--no-visited-state\" href=\"#${mapId}\" data-action=\"focus\" data-id=\"${feature.id}\">Show<span class=\"govuk-visually-hidden\"> location</span></a>\n</li>`\n\n const links = readonly ? focusAction() : `${changeAction()}${deleteAction()}`\n\n const actions = `<ul class=\"govuk-summary-list__actions-list\">${links}</ul>`\n\n return `<div class=\"govuk-summary-list__row govuk-summary-list__row--no-border\">\n <dt class=\"govuk-summary-list__key\">\n <div class=\"govuk-form-group\">\n <label class=\"govuk-label govuk-label--s\" ${readonly ? '' : `for=\"description_${index}\"`}>Location ${index + 1} description</label>\n ${description}\n </div>\n </dt>\n <dd class=\"govuk-summary-list__actions\">\n ${actions}\n </dd>\n</div>\n<div class=\"govuk-summary-list__row\">\n <details class=\"govuk-details govuk-!-margin-bottom-2\">\n <summary class=\"govuk-details__summary\">\n <span class=\"govuk-details__summary-text\">Coordinates</span>\n </summary>\n <div class=\"govuk-details__text\">\n <dl class=\"govuk-summary-list\">\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Type</dt>\n <dd class=\"govuk-summary-list__value\">${typeDescriptions[feature.geometry.type]}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Centre grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.centroidGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">First point grid reference</dt>\n <dd class=\"govuk-summary-list__value\">${feature.properties.coordinateGridReference}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">Detailed coordinates</dt>\n <dd class=\"govuk-summary-list__value\">\n <ol class=\"govuk-list govuk-list--number\">${coordinates}</ol>\n </dd>\n </div>\n </dl>\n </div>\n </details>\n</div>`\n}\n\n/**\n * Generate a random id\n */\nfunction generateID() {\n return window.crypto.randomUUID()\n}\n\n/**\n * Factory closure to track the active feature id\n * @returns {ActiveFeatureManager}\n */\nfunction getActiveFeatureManager() {\n /** @type {string | undefined} */\n let activeFeature\n\n /**\n * Returns the active feature id\n * @type {GetActiveFeature}\n */\n function getActiveFeature() {\n return activeFeature\n }\n\n /**\n * Sets the active feature id\n * @type {SetActiveFeature}\n */\n function setActiveFeature(id) {\n activeFeature = id\n }\n\n /**\n * Resets the active feature id\n * @type {ResetActiveFeature}\n */\n function resetActiveFeature() {\n activeFeature = undefined\n }\n\n return {\n getActiveFeature,\n setActiveFeature,\n resetActiveFeature\n }\n}\n\n/**\n * Reduce coordinate precision to 7 dps\n * @param {Feature} feature\n */\nfunction prepareGeometry(feature) {\n const { geometry } = feature\n const maxPrecision = 7\n\n /**\n * @param {Coordinates} coordinates\n */\n function formatPrecision(coordinates) {\n coordinates[0] = +coordinates[0].toFixed(maxPrecision)\n coordinates[1] = +coordinates[1].toFixed(maxPrecision)\n }\n\n if (geometry.type === 'Point') {\n formatPrecision(geometry.coordinates)\n } else if (geometry.type === 'LineString') {\n geometry.coordinates.forEach(formatPrecision)\n } else {\n geometry.coordinates.flat().forEach(formatPrecision)\n }\n}\n\n/**\n * Factory closure to return a features manager\n * @param {GeoJSON} geojson\n * @returns {FeaturesManager}\n */\nfunction getFeaturesManager(geojson) {\n /**\n * Get a feature from the geojson by id\n * @type {GetFeatures}\n */\n function getFeatures() {\n return geojson.features\n }\n\n /**\n * Get a feature from the geojson by id\n * @type {GetFeature}\n */\n function getFeature(id) {\n return geojson.features.find((f) => f.id === id)\n }\n\n /**\n * Add a feature to the geojson\n * @type {AddFeature}\n */\n function addFeature(feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n prepareGeometry(feature)\n\n geojson.features.push(feature)\n }\n\n /**\n * Updates a feature in the geojson\n * @type {UpdateFeature}\n */\n function updateFeature(id, geometry) {\n const feature = getFeature(id)\n\n // Ensure the feature exists in the geojson\n if (feature) {\n feature.properties.coordinateGridReference = getCoordinateGridRef(feature)\n feature.properties.centroidGridReference = getCentroidGridRef(feature)\n feature.geometry = geometry\n prepareGeometry(feature)\n }\n\n return feature\n }\n\n /**\n * Removes a feature from the geojson\n * @type {RemoveFeature}\n */\n function removeFeature(id) {\n const idx = geojson.features.findIndex((f) => f.id === id)\n\n return idx > -1 ? geojson.features.splice(idx, 1) : undefined\n }\n\n return {\n getFeatures,\n getFeature,\n addFeature,\n updateFeature,\n removeFeature\n }\n}\n\n/**\n * Factory to render features into the list and hidden textarea\n * @param {GeoJSON} geojson - the geojson of features\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {Function} renderValue - function that renders the features JSON into the hidden textarea\n * @returns {RenderList}\n */\nfunction getListRenderer(geojson, mapId, listEl, renderValue) {\n return function renderList(disabled = false) {\n const html = createFeaturesHTML(geojson.features, mapId, disabled)\n\n listEl.innerHTML = html\n\n renderValue()\n }\n}\n\n/**\n * Factory to render features JSON into the hidden textarea\n * @param {GeoJSON} geojson - the features\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @returns {RenderValue}\n */\nfunction getValueRenderer(geojson, geospatialInput) {\n return function renderValue() {\n geospatialInput.value = JSON.stringify(geojson.features, null, 2)\n }\n}\n\n/**\n * Factory closure to manage the UI\n * @param {GeoJSON} geojson - the features\n * @param {InteractiveMap} map - the map\n * @param {string} mapId - the ID of the map\n * @param {HTMLDivElement} listEl - where to render the feature list\n * @param {HTMLTextAreaElement} geospatialInput - the geospatial textarea\n * @param { UIManagerOptions | undefined } options - extra options such as allowable geometry types\n */\nexport function getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options\n) {\n /**\n * Get a CSV list of geometry types the user can create\n * @returns {string[]}\n */\n function getAllowableGeometryTypes() {\n return options?.geometryTypes\n ? options.geometryTypes.split(',')\n : ['point', 'line', 'shape']\n }\n\n /**\n * Toggle the hidden state of the action buttons\n * @type {ToggleActionButtons}\n */\n function toggleActionButtons(hidden) {\n const types = getAllowableGeometryTypes()\n if (types.includes('point')) {\n map.toggleButtonState('btnAddPoint', 'hidden', hidden)\n }\n if (types.includes('shape')) {\n map.toggleButtonState('btnAddPolygon', 'hidden', hidden)\n }\n if (types.includes('line')) {\n map.toggleButtonState('btnAddLine', 'hidden', hidden)\n }\n }\n\n /**\n * Set focus to the last description input\n * @type {FocusDescriptionInput}\n */\n function focusDescriptionInput() {\n const inputs = listEl.querySelectorAll('input')\n if (inputs.length) {\n const lastInput = /** @type {HTMLInputElement} */ inputs.item(\n inputs.length - 1\n )\n lastInput.focus()\n lastInput.select()\n }\n }\n\n const renderValue = getValueRenderer(geojson, geospatialInput)\n const renderList = getListRenderer(geojson, mapId, listEl, renderValue)\n\n /** @type {UIManager} */\n return {\n renderList,\n renderValue,\n listEl,\n toggleActionButtons,\n focusDescriptionInput,\n getAllowableGeometryTypes\n }\n}\n\n/**\n * Setup the UI event listeners\n * @param {Context} context - the context\n */\nfunction addEventListeners(context) {\n const { map } = context\n\n map.on(EVENTS.mapReady, onMapReadyFactory(context))\n}\n\n/**\n * Create the map and list containers and adds them to the DOM\n * @param {HTMLTextAreaElement} geospatialInput - the textarea containing the geojson\n * @param {number} index - the 0 based index\n */\nfunction createContainers(geospatialInput, index) {\n const mapEl = document.createElement('div')\n const mapId = `geospatialmap_${index}`\n\n mapEl.setAttribute('id', mapId)\n mapEl.setAttribute('class', 'map-container')\n\n const listEl = document.createElement('div')\n const listId = `${mapId}_list`\n listEl.setAttribute('id', listId)\n\n geospatialInput.after(mapEl)\n mapEl.after(listEl)\n geospatialInput.classList.add('js-hidden')\n\n return { mapEl, listEl, mapId }\n}\n\n/**\n * Callback factory function which fires when the map is ready\n * @param {Context} context - the UI context\n */\nfunction onMapReadyFactory(context) {\n const { map, activeFeatureManager, uiManager, interactPlugin, drawPlugin } =\n context\n const { toggleActionButtons, renderList, getAllowableGeometryTypes } =\n uiManager\n const { resetActiveFeature } = activeFeatureManager\n\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 return function onMapReady(e) {\n const types = getAllowableGeometryTypes()\n const allowPoint = types.includes('point')\n const allowLine = types.includes('line')\n const allowShape = types.includes('shape')\n\n // Add info panel\n map.addPanel('info', {\n ...helpPanelConfig,\n html: getHelpPanelHtml(allowPoint, allowLine, allowShape)\n })\n\n if (allowPoint) {\n map.addButton('btnAddPoint', {\n variant: 'tertiary',\n label: 'Add point',\n iconSvgContent: POINT_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n interactPlugin.enable()\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n if (allowShape) {\n map.addButton('btnAddPolygon', {\n variant: 'tertiary',\n label: 'Add shape',\n iconSvgContent: POLYGON_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n drawPlugin.newPolygon(generateID(), polygonFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n if (allowLine) {\n map.addButton('btnAddLine', {\n variant: 'tertiary',\n label: 'Add line',\n iconSvgContent: LINE_SVG,\n onClick: () => {\n resetActiveFeature()\n toggleActionButtons(true)\n renderList(true)\n drawPlugin.newLine(generateID(), lineFeatureProperties)\n },\n mobile: { slot: 'actions' },\n tablet: { slot: 'actions' },\n desktop: { slot: 'actions' }\n })\n }\n\n // Set the map provider on the context\n context.mapProvider = e.map\n\n map.on(EVENTS.drawReady, onDrawReadyFactory(context))\n map.on(EVENTS.drawCreated, onDrawCreatedFactory(context))\n map.on(EVENTS.drawEdited, onDrawEditedFactory(context))\n map.on(EVENTS.drawCancelled, onDrawCancelledFactory(context))\n map.on(EVENTS.interactMarkerChange, onInteractMarkerChangedFactory(context))\n\n const { listEl } = uiManager\n listEl.addEventListener('click', onListElClickFactory(context), false)\n listEl.addEventListener('change', onListElChangeFactory(context), false)\n listEl.addEventListener('keydown', onListElKeydownFactory(), false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin is ready\n * @param {Context} context - the UI context\n */\nfunction onDrawReadyFactory(context) {\n const { featuresManager, uiManager, drawPlugin, map } = context\n const { renderList } = uiManager\n const { getFeatures } = featuresManager\n\n /**\n * Callback when the draw plugin is ready\n */\n return function onDrawReady() {\n getFeatures().forEach((feature) =>\n addFeatureToMap(feature, drawPlugin, map)\n )\n\n // Update the features\n renderList()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin creates a new feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCreatedFactory(context) {\n const { featuresManager, uiManager } = context\n const { addFeature } = featuresManager\n const { renderList, toggleActionButtons, focusDescriptionInput } = uiManager\n\n /**\n * Callback when a draw feature has been created\n * @param {Feature} e\n */\n return function onDrawCreated(e) {\n // New feature\n addFeature({\n ...e,\n properties: {\n description: ''\n }\n })\n\n // Update the features\n renderList()\n toggleActionButtons(false)\n focusDescriptionInput()\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin edits a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawEditedFactory(context) {\n const { featuresManager, activeFeatureManager, uiManager } = context\n const { updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Callback when a draw feature has been edited\n * @param {{ id: string, geometry: Geometry }} e\n */\n return function onDrawEdited(e) {\n const changedFeature = e\n const featureId = changedFeature.id\n\n if (getActiveFeature() === featureId) {\n updateFeature(featureId, changedFeature.geometry)\n\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function which fires when the map draw plugin cancels the editing of a feature\n * @param {Context} context - the UI context\n */\nfunction onDrawCancelledFactory(context) {\n const { uiManager, activeFeatureManager } = context\n const { toggleActionButtons, renderList } = uiManager\n const { resetActiveFeature } = activeFeatureManager\n\n /**\n * Callback when a draw feature has been cancelled\n */\n return function onDrawCancelled() {\n toggleActionButtons(false)\n resetActiveFeature()\n renderList()\n }\n}\n\n/**\n * Callback factory function that fires when an interact marker has been changed\n * @param {Context} context - the UI context\n */\nfunction onInteractMarkerChangedFactory(context) {\n const {\n featuresManager,\n activeFeatureManager,\n map,\n interactPlugin,\n uiManager\n } = context\n const { addFeature, updateFeature } = featuresManager\n const { getActiveFeature, resetActiveFeature } = activeFeatureManager\n const { renderList, focusDescriptionInput, toggleActionButtons } = uiManager\n\n /**\n * Callback when an interact marker has been changed\n * @param {{ coords: Coordinates }} e\n */\n return function onInteractMarkerChange(e) {\n const activeFeatureId = getActiveFeature()\n\n if (activeFeatureId) {\n // Editing an existing point\n const feature = updateFeature(activeFeatureId, {\n type: 'Point',\n coordinates: e.coords\n })\n\n map.addMarker(activeFeatureId, e.coords)\n\n if (feature) {\n // Update the features\n renderList()\n }\n\n resetActiveFeature()\n } else {\n // Adding a new point\n const id = generateID()\n addFeature({\n type: 'Feature',\n properties: {\n description: ''\n },\n geometry: {\n type: 'Point',\n coordinates: e.coords\n },\n id\n })\n\n map.addMarker(id, e.coords)\n\n // Update the features\n renderList()\n\n focusDescriptionInput()\n }\n map.removeMarker('location')\n\n interactPlugin.disable()\n toggleActionButtons(false)\n }\n}\n\n/**\n * Callback factory function that fires a 'click' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElClickFactory(context) {\n const {\n map,\n mapProvider,\n featuresManager,\n activeFeatureManager,\n interactPlugin,\n uiManager,\n drawPlugin\n } = context\n const { getFeature, removeFeature } = featuresManager\n const { getActiveFeature, setActiveFeature } = activeFeatureManager\n const { renderList, toggleActionButtons } = uiManager\n\n /**\n * Delete a feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function deleteFeature(id, type) {\n if (type === 'Point') {\n map.removeMarker(id)\n removeFeature(id)\n } else {\n drawPlugin.deleteFeature(id)\n removeFeature(id)\n }\n\n renderList()\n }\n\n /**\n * Start editing feature\n * @param {string} id - the feature id\n * @param {string} type - the feature type\n */\n function editFeature(id, type) {\n setActiveFeature(id)\n\n // \"Change\" feature link was clicked\n if (type === 'Point') {\n interactPlugin.selectFeature({ featureId: id })\n interactPlugin.enable()\n } else {\n drawPlugin.editFeature(id)\n }\n\n const feature = getFeature(id)\n if (feature && mapProvider) {\n focusFeature(feature, mapProvider)\n }\n\n toggleActionButtons(true)\n renderList(true)\n }\n\n /**\n * List container delegated 'click' events handler\n * @param {MouseEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n if (getActiveFeature()) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (\n target.tagName === 'A' &&\n target.dataset.action &&\n target.dataset.id &&\n target.dataset.type\n ) {\n const { action, id, type } = target.dataset\n\n if (action === 'edit') {\n // \"Update\" feature link was clicked\n editFeature(id, type)\n } else {\n e.preventDefault()\n e.stopPropagation()\n\n if (action === 'delete') {\n // \"Remove\" feature link was clicked\n deleteFeature(id, type)\n }\n }\n }\n }\n}\n\n/**\n * Callback factory function that fires when a 'change' event is fired on the list container\n * @param {Context} context - the UI context\n */\nfunction onListElChangeFactory(context) {\n const { featuresManager, uiManager } = context\n const { getFeature } = featuresManager\n const { renderValue } = uiManager\n\n /**\n * List container delegated 'change' events handler\n * Used to update the description of features\n * @param {Event} e\n */\n return function (e) {\n e.preventDefault()\n e.stopPropagation()\n\n const target = e.target\n if (!(target instanceof HTMLInputElement) || !target.dataset.id) {\n return\n }\n\n const { id } = target.dataset\n const feature = getFeature(id)\n\n if (feature) {\n feature.properties.description = target.value.trim()\n renderValue()\n }\n }\n}\n\n/**\n * Callback factory function that fires when a 'keydown' event is fired on the list container\n */\nfunction onListElKeydownFactory() {\n /**\n * List container delegated 'keydown' events handler\n * Fixes the issue of pressing \"Enter\" key in the description input triggering the map search\n * @param {KeyboardEvent} e\n */\n return function (e) {\n const target = e.target\n\n if (!(target instanceof HTMLInputElement)) {\n return\n }\n\n if (e.code === 'Enter' || e.code === 'NumpadEnter') {\n e.preventDefault()\n e.stopPropagation()\n }\n }\n}\n\n/**\n * @import { MapsEnvironmentConfig, InteractiveMap } from '~/src/client/javascripts/map.js'\n */\n\n/**\n * @import { Geometry, FeatureCollection, Feature, Coordinates } from '~/src/server/plugins/engine/types.js'\n */\n\n/**\n * @typedef {object} GeoJSON\n * @property {'FeatureCollection'} type - the GeoJSON type string\n * @property {FeatureCollection} features - the features\n */\n\n/**\n * Gets all the features\n * @callback GetFeatures\n * @returns {FeatureCollection}\n */\n\n/**\n * Gets a feature from the geojson by id\n * @callback GetFeature\n * @param {string} id - the feature id\n * @returns {Feature | undefined}\n */\n\n/**\n * Add a feature to the geojson\n * @callback AddFeature\n * @param {Feature} feature - the feature to add\n */\n\n/**\n * Update a feature in the geojson\n * @callback UpdateFeature\n * @param {string} id - the feature id\n * @param {Geometry} geometry - the feature geometry\n * @returns {Feature | undefined}\n */\n\n/**\n * Removes a feature from the geojson\n * @callback RemoveFeature\n * @param {string} id - the feature id\n */\n\n/**\n * Gets the active feature id\n * @callback GetActiveFeature\n * @returns {string | undefined}\n */\n\n/**\n * Set the active feature id\n * @callback SetActiveFeature\n * @param {string} id - the feature id\n * @returns {void}\n */\n\n/**\n * Resets the active feature id\n * @callback ResetActiveFeature\n * @returns {void}\n */\n\n/**\n * Renders the features into the list\n * @callback RenderList\n * @param {boolean} [disabled] - whether to render the list with disabled links\n * @returns {void}\n */\n\n/**\n * Renders the features JSON into the hidden textarea\n * @callback RenderValue\n * @returns {void}\n */\n\n/**\n * Toggles the action button hidden state\n * @callback ToggleActionButtons\n * @param {boolean} hidden - whether to hide the action buttons\n * @returns {void}\n */\n\n/**\n * Returns the list of geometry types a user can create\n * @callback GetAllowableGeometryTypes\n * @returns {string[]}\n */\n\n/**\n * Set focus to the last description input\n * @callback FocusDescriptionInput\n * @returns {void}\n */\n\n/**\n * @typedef {object} FeaturesManager\n * @property {GetFeatures} getFeatures - function that gets all the features\n * @property {GetFeature} getFeature - function that gets a feature from the geojson\n * @property {AddFeature} addFeature - function that adds feature to the geojson\n * @property {UpdateFeature} updateFeature - function that updates a feature in the geojson\n * @property {RemoveFeature} removeFeature - function that removes a feature from the geojson\n */\n\n/**\n * @typedef {object} ActiveFeatureManager\n * @property {GetActiveFeature} getActiveFeature - function that returns the current active feature id\n * @property {SetActiveFeature} setActiveFeature - function that sets the current active feature id\n * @property {ResetActiveFeature} resetActiveFeature - function that resets the current active feature id\n */\n\n/**\n * @typedef {object} UIManager\n * @property {RenderValue} renderValue - function that renders the features JSON into the hidden textarea\n * @property {RenderList} renderList - function that renders the features into the list\n * @property {HTMLDivElement} listEl - the summary list of features\n * @property {ToggleActionButtons} toggleActionButtons - function that toggles the action buttons\n * @property {FocusDescriptionInput} focusDescriptionInput - function that sets focus to a description input element\n * @property {GetAllowableGeometryTypes} getAllowableGeometryTypes - function that returns the array of geometry types a user can create\n */\n\n/**\n * @typedef {object} Context\n * @property {InteractiveMap} map - the interactive map\n * @property {MapLibreMap} [mapProvider] - the interactive map provider\n * @property {FeaturesManager} featuresManager - the features manager\n * @property {ActiveFeatureManager} activeFeatureManager - the active feature manager\n * @property {UIManager} uiManager - the UI manager\n * @property {any} interactPlugin - the map interact plugin\n * @property {any} drawPlugin - the map draw plugin\n */\n\n/**\n * @import { MapLibreMap, UIManagerOptions } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA;AACA,OAAOA,oBAAoB,MAAM,yCAAyC;AAC1E;AACA,SAASC,oBAAoB,QAAQ,2DAA2D;AAChG;AACA,OAAOC,gBAAgB,MAAM,wCAAwC;AACrE,SAASC,IAAI,QAAQ,YAAY;AAEjC,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB;AAEtB,SAASC,kBAAkB;AAE3B,MAAMC,eAAe,GAAG;EACtBC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,qBAAqB;EAC5BC,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE,IAAI;IACjBC,KAAK,EAAE;EACT,CAAC;EACDC,MAAM,EAAE;IACNJ,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE,IAAI;IACjBC,KAAK,EAAE;EACT,CAAC;EACDE,OAAO,EAAE;IACPL,IAAI,EAAE,QAAQ;IACdC,IAAI,EAAE,IAAI;IACVC,WAAW,EAAE,IAAI;IACjBC,KAAK,EAAE;EACT;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASG,kBAAkBA,CAACC,SAAS,EAAEC,UAAU,EAAE;EACjD,IAAID,SAAS,IAAIC,UAAU,EAAE;IAC3B,OAAO,iBAAiB;EAC1B;EACA,IAAID,SAAS,EAAE;IACb,OAAO,QAAQ;EACjB;EACA,IAAIC,UAAU,EAAE;IACd,OAAO,SAAS;EAClB;EACA,OAAO,EAAE;AACX;;AAEA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OAAO,EAAE;MACXA,OAAO,CAACoB,UAAU,CAACD,WAAW,GAAGqG,MAAM,CAACzK,KAAK,CAACC,IAAI,CAAC,CAAC;MACpDmG,WAAW,CAAC,CAAC;IACf;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASsD,sBAAsBA,CAAA,EAAG;EAChC;AACF;AACA;AACA;AACA;EACE,OAAO,UAAUtB,CAAC,EAAE;IAClB,MAAMqC,MAAM,GAAGrC,CAAC,CAACqC,MAAM;IAEvB,IAAI,EAAEA,MAAM,YAAYM,gBAAgB,CAAC,EAAE;MACzC;IACF;IAEA,IAAI3C,CAAC,CAAC4C,IAAI,KAAK,OAAO,IAAI5C,CAAC,CAAC4C,IAAI,KAAK,aAAa,EAAE;MAClD5C,CAAC,CAACuC,cAAc,CAAC,CAAC;MAClBvC,CAAC,CAACwC,eAAe,CAAC,CAAC;IACrB;EACF,CAAC;AACH;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
@@ -1,3 +1,15 @@
1
+ // @ts-expect-error - no types
2
+ import InteractiveMap from '@defra/interactive-map';
3
+ // @ts-expect-error - no types
4
+ import createInteractPlugin from '@defra/interactive-map/plugins/interact';
5
+ // @ts-expect-error - no types
6
+ import createMapStylesPlugin from '@defra/interactive-map/plugins/map-styles';
7
+ // @ts-expect-error - no types
8
+ import createScaleBarPlugin from '@defra/interactive-map/plugins/scale-bar';
9
+ // @ts-expect-error - no types
10
+ import createSearchPlugin from '@defra/interactive-map/plugins/search';
11
+ // @ts-expect-error - no types
12
+ import maplibreProvider from '@defra/interactive-map/providers/maplibre';
1
13
  import { centroid } from '@turf/centroid';
2
14
  // @ts-expect-error - no types
3
15
  import OsGridRef, { LatLon } from 'geodesy/osgridref.js';
@@ -249,10 +261,7 @@ export function createMap(mapId, initConfig, mapsConfig) {
249
261
  data = defaultData
250
262
  } = mapsConfig;
251
263
  const logoAltText = 'Ordnance survey logo';
252
-
253
- // @ts-expect-error - Defra namespace currently comes from UMD support files
254
- const defra = window.defra;
255
- const interactPlugin = defra.interactPlugin({
264
+ const interactPlugin = createInteractPlugin({
256
265
  markerColor: {
257
266
  outdoor: '#ff0000',
258
267
  dark: '#00ff00'
@@ -262,13 +271,10 @@ export function createMap(mapId, initConfig, mapsConfig) {
262
271
  });
263
272
 
264
273
  /** @type {InteractiveMap} */
265
- const map = new defra.InteractiveMap(mapId, {
274
+ const map = new InteractiveMap(mapId, {
266
275
  enableFullscreen: true,
267
276
  autoColorScheme: false,
268
- mapProvider: defra.maplibreProvider(),
269
- reverseGeocodeProvider: defra.openNamesProvider({
270
- url: `${apiPath}/reverse-geocode-proxy?easting={easting}&northing={northing}`
271
- }),
277
+ mapProvider: maplibreProvider(),
272
278
  behaviour: 'inline',
273
279
  minZoom: 6,
274
280
  maxZoom: 18,
@@ -276,7 +282,7 @@ export function createMap(mapId, initConfig, mapsConfig) {
276
282
  enableZoomControls: true,
277
283
  transformRequest: makeTileRequestTransformer(apiPath),
278
284
  ...initConfig,
279
- plugins: [defra.mapStylesPlugin({
285
+ plugins: [createMapStylesPlugin({
280
286
  mapStyles: [{
281
287
  id: 'outdoor',
282
288
  label: 'Outdoor',
@@ -313,11 +319,11 @@ export function createMap(mapId, initConfig, mapsConfig) {
313
319
  logoAltText: 'Powered by Esri',
314
320
  attribution: `Tiles ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community ${new Date().getFullYear()}`
315
321
  }]
316
- }), interactPlugin, defra.searchPlugin({
322
+ }), interactPlugin, createSearchPlugin({
317
323
  osNamesURL: `${apiPath}/geocode-proxy?query={query}`,
318
324
  width: '300px',
319
325
  showMarker: false
320
- }), defra.scaleBarPlugin({
326
+ }), createScaleBarPlugin({
321
327
  units: 'metric'
322
328
  }), ...(initConfig.plugins ?? [])]
323
329
  });
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["centroid","OsGridRef","LatLon","processGeospatial","processLocation","DEFAULT_LAT","DEFAULT_LONG","COMPANY_SYMBOL_CODE","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","VTS_AERIAL_URL","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","getCoordinateGridRef","feature","geometry","type","coordinates","getCentroidGridRef","centre","defaultConfig","zoom","center","EVENTS","mapReady","interactMarkerChange","drawReady","drawCreated","drawEdited","drawCancelled","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","geospatials","length","form","closest","Array","from","addEventListener","forEach","location","index","geospatial","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","createMap","mapId","initConfig","mapsConfig","logoAltText","defra","interactPlugin","markerColor","outdoor","dark","interactionModes","multiSelect","map","InteractiveMap","enableFullscreen","autoColorScheme","mapProvider","maplibreProvider","reverseGeocodeProvider","openNamesProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStylesPlugin","mapStyles","id","label","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","searchPlugin","osNamesURL","width","showMarker","scaleBarPlugin","units","centerMap","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/map.js"],"sourcesContent":["import { centroid } from '@turf/centroid'\n// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\nimport { processGeospatial } from '~/src/client/javascripts/geospatial-map.js'\nimport { processLocation } from '~/src/client/javascripts/location-map.js'\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\nconst COMPANY_SYMBOL_CODE = 169\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 VTS_AERIAL_URL: '/api/maps/vts/esri-aerial.json'\n}\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 */\nexport function 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 */\nexport function 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 */\nexport function 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 */\nexport function 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/**\n * Get the grid ref from the first coordinate of a long/lat feature\n * @param {Feature} feature\n */\nexport function getCoordinateGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else if (feature.geometry.type === 'LineString') {\n const [long, lat] = feature.geometry.coordinates[0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const [long, lat] = feature.geometry.coordinates[0][0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/**\n * Get the centroid grid ref from a long/lat feature\n * @param {Feature} feature\n */\nexport function getCentroidGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const centre = centroid(feature)\n const [long, lat] = centre.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/** @type {InteractiveMapInitConfig} */\nexport const defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nexport const EVENTS = {\n mapReady: 'map:ready',\n interactMarkerChange: 'interact:markerchange',\n drawReady: 'draw:ready',\n drawCreated: 'draw:created',\n drawEdited: 'draw:edited',\n drawCancelled: 'draw:cancelled'\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 const geospatials = document.querySelectorAll('.app-geospatial-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 if (geospatials.length) {\n const form = geospatials[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 geospatials.forEach((geospatial, index) => {\n processGeospatial({ assetPath, apiPath, data }, geospatial, 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 * 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 */\nexport function 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 markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionModes: ['placeMarker'],\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new defra.InteractiveMap(mapId, {\n enableFullscreen: true,\n autoColorScheme: false,\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 ...initConfig,\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 id: 'aerial',\n label: 'Aerial',\n url: data.VTS_AERIAL_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/aerial-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/esri-logo.png`,\n logoAltText: 'Powered by Esri',\n attribution: `Tiles ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community ${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 ...(initConfig.plugins ?? [])\n ]\n })\n\n return { map, interactPlugin }\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 */\nexport function 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 * @property {Function} removeMarker - removes a marker\n * @property {Function} addButton - adds/updates a button\n * @property {Function} toggleButtonState - toggle the state of a button\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n * @property {Function} fitBounds - fits the my to the new bounds\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 * @property {any[]} [plugins] - additional plugins\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 * @property {string} VTS_AERIAL_URL - the aerial 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\n/**\n * @typedef {object} UIManagerOptions\n * @property {string} [geometryTypes] - the CSV list of geometry types that a user can create\n */\n\n/**\n * @import { Feature } from '~/src/server/plugins/engine/types.js'\n */\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC;AACA,OAAOC,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;AAExD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;;AAExB;AACA,MAAMC,WAAW,GAAG,SAAS;AAC7B,MAAMC,YAAY,GAAG,CAAC,QAAQ;AAC9B,MAAMC,mBAAmB,GAAG,GAAG;AAE/B,MAAMC,WAAW,GAAG;EAClBC,eAAe,EAAE,wCAAwC;EACzDC,YAAY,EAAE,qCAAqC;EACnDC,uBAAuB,EAAE,gDAAgD;EACzEC,cAAc,EAAE;AAClB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CAAC;EAAEC,GAAG;EAAEC;AAAK,CAAC,EAAE;EACtD,MAAMC,KAAK,GAAG,IAAId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C,SAAS,CAAC,UAAU,EAAEhG,MAAM,CAAC;;EAEjC;EACAgE,WAAW,CAACiC,KAAK,CAAC;IAChBjG,MAAM;IACND,IAAI,EAAE,EAAE;IACRmG,SAAS,EAAE;EACb,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"map.js","names":["InteractiveMap","createInteractPlugin","createMapStylesPlugin","createScaleBarPlugin","createSearchPlugin","maplibreProvider","centroid","OsGridRef","LatLon","processGeospatial","processLocation","DEFAULT_LAT","DEFAULT_LONG","COMPANY_SYMBOL_CODE","defaultData","VTS_OUTDOOR_URL","VTS_DARK_URL","VTS_BLACK_AND_WHITE_URL","VTS_AERIAL_URL","latLongToEastingNorthing","lat","long","point","toOsGrid","eastingNorthingToLatLong","easting","northing","latLong","toLatLon","latitude","longitude","latLongToOsGridRef","toString","osGridRefToLatLong","osGridRef","parse","getCoordinateGridRef","feature","geometry","type","coordinates","getCentroidGridRef","centre","defaultConfig","zoom","center","EVENTS","mapReady","interactMarkerChange","drawReady","drawCreated","drawEdited","drawCancelled","formSubmitFactory","buttons","onFormSubmit","e","submitter","HTMLButtonElement","includes","preventDefault","initMaps","config","assetPath","apiPath","data","locations","document","querySelectorAll","geospatials","length","form","closest","Array","from","addEventListener","forEach","location","index","geospatial","makeTileRequestTransformer","transformTileRequest","url","resourceType","startsWith","replace","window","origin","headers","encodeURIComponent","spritesPath","path","substring","createMap","mapId","initConfig","mapsConfig","logoAltText","interactPlugin","markerColor","outdoor","dark","interactionModes","multiSelect","map","enableFullscreen","autoColorScheme","mapProvider","behaviour","minZoom","maxZoom","containerHeight","enableZoomControls","transformRequest","plugins","mapStyles","id","label","thumbnail","logo","attribution","String","fromCodePoint","Date","getFullYear","backgroundColor","mapColorScheme","appColorScheme","osNamesURL","width","showMarker","units","centerMap","addMarker","flyTo","essential"],"sources":["../../../src/client/javascripts/map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport InteractiveMap from '@defra/interactive-map'\n// @ts-expect-error - no types\nimport createInteractPlugin from '@defra/interactive-map/plugins/interact'\n// @ts-expect-error - no types\nimport createMapStylesPlugin from '@defra/interactive-map/plugins/map-styles'\n// @ts-expect-error - no types\nimport createScaleBarPlugin from '@defra/interactive-map/plugins/scale-bar'\n// @ts-expect-error - no types\nimport createSearchPlugin from '@defra/interactive-map/plugins/search'\n// @ts-expect-error - no types\nimport maplibreProvider from '@defra/interactive-map/providers/maplibre'\nimport { centroid } from '@turf/centroid'\n// @ts-expect-error - no types\nimport OsGridRef, { LatLon } from 'geodesy/osgridref.js'\n\nimport { processGeospatial } from '~/src/client/javascripts/geospatial-map.js'\nimport { processLocation } from '~/src/client/javascripts/location-map.js'\n\n// Center of UK\nconst DEFAULT_LAT = 53.825564\nconst DEFAULT_LONG = -2.421975\nconst COMPANY_SYMBOL_CODE = 169\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 VTS_AERIAL_URL: '/api/maps/vts/esri-aerial.json'\n}\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 */\nexport function 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 */\nexport function 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 */\nexport function 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 */\nexport function 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/**\n * Get the grid ref from the first coordinate of a long/lat feature\n * @param {Feature} feature\n */\nexport function getCoordinateGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else if (feature.geometry.type === 'LineString') {\n const [long, lat] = feature.geometry.coordinates[0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const [long, lat] = feature.geometry.coordinates[0][0]\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/**\n * Get the centroid grid ref from a long/lat feature\n * @param {Feature} feature\n */\nexport function getCentroidGridRef(feature) {\n if (feature.geometry.type === 'Point') {\n const [long, lat] = feature.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n } else {\n const centre = centroid(feature)\n const [long, lat] = centre.geometry.coordinates\n const point = new LatLon(lat, long)\n\n return point.toOsGrid().toString()\n }\n}\n\n/** @type {InteractiveMapInitConfig} */\nexport const defaultConfig = {\n zoom: '6',\n center: [DEFAULT_LONG, DEFAULT_LAT]\n}\n\nexport const EVENTS = {\n mapReady: 'map:ready',\n interactMarkerChange: 'interact:markerchange',\n drawReady: 'draw:ready',\n drawCreated: 'draw:created',\n drawEdited: 'draw:edited',\n drawCancelled: 'draw:cancelled'\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 const geospatials = document.querySelectorAll('.app-geospatial-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 if (geospatials.length) {\n const form = geospatials[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 geospatials.forEach((geospatial, index) => {\n processGeospatial({ assetPath, apiPath, data }, geospatial, 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 * 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 */\nexport function createMap(mapId, initConfig, mapsConfig) {\n const { assetPath, apiPath, data = defaultData } = mapsConfig\n const logoAltText = 'Ordnance survey logo'\n const interactPlugin = createInteractPlugin({\n markerColor: { outdoor: '#ff0000', dark: '#00ff00' },\n interactionModes: ['placeMarker'],\n multiSelect: false\n })\n\n /** @type {InteractiveMap} */\n const map = new InteractiveMap(mapId, {\n enableFullscreen: true,\n autoColorScheme: false,\n mapProvider: maplibreProvider(),\n behaviour: 'inline',\n minZoom: 6,\n maxZoom: 18,\n containerHeight: '400px',\n enableZoomControls: true,\n transformRequest: makeTileRequestTransformer(apiPath),\n ...initConfig,\n plugins: [\n createMapStylesPlugin({\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 id: 'aerial',\n label: 'Aerial',\n url: data.VTS_AERIAL_URL,\n thumbnail: `${assetPath}/interactive-map/assets/images/aerial-map-thumb.jpg`,\n logo: `${assetPath}/interactive-map/assets/images/esri-logo.png`,\n logoAltText: 'Powered by Esri',\n attribution: `Tiles ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Esri — Source: Esri, Maxar, Earthstar Geographics, and the GIS User Community ${new Date().getFullYear()}`\n }\n ]\n }),\n interactPlugin,\n createSearchPlugin({\n osNamesURL: `${apiPath}/geocode-proxy?query={query}`,\n width: '300px',\n showMarker: false\n }),\n createScaleBarPlugin({\n units: 'metric'\n }),\n ...(initConfig.plugins ?? [])\n ]\n })\n\n return { map, interactPlugin }\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 */\nexport function 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 * @property {Function} removeMarker - removes a marker\n * @property {Function} addButton - adds/updates a button\n * @property {Function} toggleButtonState - toggle the state of a button\n */\n\n/**\n * @typedef {object} MapLibreMap\n * @property {Function} flyTo - pans/zooms to a new location\n * @property {Function} fitBounds - fits the my to the new bounds\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 * @property {any[]} [plugins] - additional plugins\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 * @property {string} VTS_AERIAL_URL - the aerial 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\n/**\n * @typedef {object} UIManagerOptions\n * @property {string} [geometryTypes] - the CSV list of geometry types that a user can create\n */\n\n/**\n * @import { Feature } from '~/src/server/plugins/engine/types.js'\n */\n"],"mappings":"AAAA;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD;AACA,OAAOC,oBAAoB,MAAM,yCAAyC;AAC1E;AACA,OAAOC,qBAAqB,MAAM,2CAA2C;AAC7E;AACA,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E;AACA,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE;AACA,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,SAASC,QAAQ,QAAQ,gBAAgB;AACzC;AACA,OAAOC,SAAS,IAAIC,MAAM,QAAQ,sBAAsB;AAExD,SAASC,iBAAiB;AAC1B,SAASC,eAAe;;AAExB;AACA,MAAMC,WAAW,GAAG,SAAS;AAC7B,MAAMC,YAAY,GAAG,CAAC,QAAQ;AA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ACA;AACA;AACA,OAAO,SAASkC,SAASA,CAAC5B,GAAG,EAAEG,WAAW,EAAE9D,MAAM,EAAE;EAClD;EACA2D,GAAG,CAAC6B,SAAS,CAAC,UAAU,EAAExF,MAAM,CAAC;;EAEjC;EACA8D,WAAW,CAAC2B,KAAK,CAAC;IAChBzF,MAAM;IACND,IAAI,EAAE,EAAE;IACR2F,SAAS,EAAE;EACb,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA","ignoreList":[]}
@@ -4,6 +4,13 @@
4
4
  @use "summary-list";
5
5
  @use "location-fields";
6
6
 
7
+ @use "@defra/interactive-map/css" as core;
8
+ @use "@defra/interactive-map/plugins/interact/css" as interact;
9
+ @use "@defra/interactive-map/plugins/map-styles/css" as mapStyles;
10
+ @use "@defra/interactive-map/plugins/search/css" as search;
11
+ @use "@defra/interactive-map/plugins/scale-bar/css" as scaleBar;
12
+ @use "@defra/interactive-map/plugins/draw-ml/css" as drawMl;
13
+
7
14
  // Use default GDS Transport font for autocomplete
8
15
  .autocomplete__hint,
9
16
  .autocomplete__input,
@@ -1,6 +1,6 @@
1
1
  import { FormComponent } from "./FormComponent.js";
2
2
  import { addClassOptionIfNone } from "./helpers/index.js";
3
- import { INTERNATIONAL_ERROR_CODE, INVALID_ERROR_CODE, UK_ERROR_CODE, joi } from "./helpers/telephone.js";
3
+ import { INVALID_ERROR_CODE, joi } from "./helpers/telephone.js";
4
4
  import { messageTemplate } from "../pageControllers/validationOptions.js";
5
5
  export class TelephoneNumberField extends FormComponent {
6
6
  constructor(def, props) {
@@ -23,9 +23,7 @@ export class TelephoneNumberField extends FormComponent {
23
23
  'any.required': message,
24
24
  'string.empty': message,
25
25
  'string.pattern.base': message,
26
- [INVALID_ERROR_CODE]: message,
27
- [UK_ERROR_CODE]: message,
28
- [INTERNATIONAL_ERROR_CODE]: message
26
+ [INVALID_ERROR_CODE]: message
29
27
  });
30
28
  } else if (options.customValidationMessages) {
31
29
  formSchema = formSchema.messages(options.customValidationMessages);
@@ -1 +1 @@
1
- {"version":3,"file":"TelephoneNumberField.js","names":["FormComponent","addClassOptionIfNone","INTERNATIONAL_ERROR_CODE","INVALID_ERROR_CODE","UK_ERROR_CODE","joi","messageTemplate","TelephoneNumberField","constructor","def","props","options","format","formSchema","string","trim","phoneNumber","label","required","allow","customValidationMessage","message","messages","customValidationMessages","default","stateSchema","getViewModel","payload","errors","viewModel","attributes","autocomplete","type","getAllPossibleErrors","baseErrors","template","advancedSettingsErrors"],"sources":["../../../../../src/server/plugins/engine/components/TelephoneNumberField.ts"],"sourcesContent":["import { type TelephoneNumberFieldComponent } from '@defra/forms-model'\nimport { type StringSchema } from 'joi'\n\nimport { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js'\nimport { addClassOptionIfNone } from '~/src/server/plugins/engine/components/helpers/index.js'\nimport {\n INTERNATIONAL_ERROR_CODE,\n INVALID_ERROR_CODE,\n UK_ERROR_CODE,\n joi\n} from '~/src/server/plugins/engine/components/helpers/telephone.js'\nimport { messageTemplate } from '~/src/server/plugins/engine/pageControllers/validationOptions.js'\nimport {\n type ErrorMessageTemplateList,\n type FormPayload,\n type FormSubmissionError\n} from '~/src/server/plugins/engine/types.js'\n\nexport class TelephoneNumberField extends FormComponent {\n declare options: TelephoneNumberFieldComponent['options']\n declare formSchema: StringSchema\n declare stateSchema: StringSchema\n\n constructor(\n def: TelephoneNumberFieldComponent,\n props: ConstructorParameters<typeof FormComponent>[1]\n ) {\n super(def, props)\n\n const { options } = def\n const { format } = options\n\n let formSchema = joi\n .string()\n .trim()\n .phoneNumber({ format })\n .label(this.label)\n .required()\n\n if (options.required === false) {\n formSchema = formSchema.allow('')\n }\n\n if (options.customValidationMessage) {\n const message = options.customValidationMessage\n\n formSchema = formSchema.messages({\n 'any.required': message,\n 'string.empty': message,\n 'string.pattern.base': message,\n [INVALID_ERROR_CODE]: message,\n [UK_ERROR_CODE]: message,\n [INTERNATIONAL_ERROR_CODE]: message\n })\n } else if (options.customValidationMessages) {\n formSchema = formSchema.messages(options.customValidationMessages)\n }\n\n addClassOptionIfNone(options, 'govuk-input--width-20')\n\n this.formSchema = formSchema.default('')\n this.stateSchema = formSchema.default(null).allow(null)\n this.options = options\n }\n\n getViewModel(payload: FormPayload, errors?: FormSubmissionError[]) {\n const viewModel = super.getViewModel(payload, errors)\n const { attributes } = viewModel\n\n attributes.autocomplete = 'tel'\n\n return {\n ...viewModel,\n type: 'tel'\n }\n }\n\n /**\n * For error preview page that shows all possible errors on a component\n */\n getAllPossibleErrors(): ErrorMessageTemplateList {\n return TelephoneNumberField.getAllPossibleErrors()\n }\n\n /**\n * Static version of getAllPossibleErrors that doesn't require a component instance.\n */\n static getAllPossibleErrors(): ErrorMessageTemplateList {\n return {\n baseErrors: [\n { type: 'required', template: messageTemplate.required },\n { type: 'format', template: messageTemplate.format }\n ],\n advancedSettingsErrors: []\n }\n }\n}\n"],"mappings":"AAGA,SAASA,aAAa;AACtB,SAASC,oBAAoB;AAC7B,SACEC,wBAAwB,EACxBC,kBAAkB,EAClBC,aAAa,EACbC,GAAG;AAEL,SAASC,eAAe;AAOxB,OAAO,MAAMC,oBAAoB,SAASP,aAAa,CAAC;EAKtDQ,WAAWA,CACTC,GAAkC,EAClCC,KAAqD,EACrD;IACA,KAAK,CAACD,GAAG,EAAEC,KAAK,CAAC;IAEjB,MAAM;MAAEC;IAAQ,CAAC,GAAGF,GAAG;IACvB,MAAM;MAAEG;IAAO,CAAC,GAAGD,OAAO;IAE1B,IAAIE,UAAU,GAAGR,GAAG,CACjBS,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,WAAW,CAAC;MAAEJ;IAAO,CA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B;IAC/C,OAAO1B,oBAAoB,CAAC0B,oBAAoB,CAAC,CAAC;EACpD;;EAEA;AACF;AACA;EACE,OAAOA,oBAAoBA,CAAA,EAA6B;IACtD,OAAO;MACLC,UAAU,EAAE,CACV;QAAEF,IAAI,EAAE,UAAU;QAAEG,QAAQ,EAAE7B,eAAe,CAACY;MAAS,CAAC,EACxD;QAAEc,IAAI,EAAE,QAAQ;QAAEG,QAAQ,EAAE7B,eAAe,CAACM;MAAO,CAAC,CACrD;MACDwB,sBAAsB,EAAE;IAC1B,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"TelephoneNumberField.js","names":["FormComponent","addClassOptionIfNone","INVALID_ERROR_CODE","joi","messageTemplate","TelephoneNumberField","constructor","def","props","options","format","formSchema","string","trim","phoneNumber","label","required","allow","customValidationMessage","message","messages","customValidationMessages","default","stateSchema","getViewModel","payload","errors","viewModel","attributes","autocomplete","type","getAllPossibleErrors","baseErrors","template","advancedSettingsErrors"],"sources":["../../../../../src/server/plugins/engine/components/TelephoneNumberField.ts"],"sourcesContent":["import { type TelephoneNumberFieldComponent } from '@defra/forms-model'\nimport { type StringSchema } from 'joi'\n\nimport { FormComponent } from '~/src/server/plugins/engine/components/FormComponent.js'\nimport { addClassOptionIfNone } from '~/src/server/plugins/engine/components/helpers/index.js'\nimport {\n INVALID_ERROR_CODE,\n joi\n} from '~/src/server/plugins/engine/components/helpers/telephone.js'\nimport { messageTemplate } from '~/src/server/plugins/engine/pageControllers/validationOptions.js'\nimport {\n type ErrorMessageTemplateList,\n type FormPayload,\n type FormSubmissionError\n} from '~/src/server/plugins/engine/types.js'\n\nexport class TelephoneNumberField extends FormComponent {\n declare options: TelephoneNumberFieldComponent['options']\n declare formSchema: StringSchema\n declare stateSchema: StringSchema\n\n constructor(\n def: TelephoneNumberFieldComponent,\n props: ConstructorParameters<typeof FormComponent>[1]\n ) {\n super(def, props)\n\n const { options } = def\n const { format } = options\n\n let formSchema = joi\n .string()\n .trim()\n .phoneNumber({ format })\n .label(this.label)\n .required()\n\n if (options.required === false) {\n formSchema = formSchema.allow('')\n }\n\n if (options.customValidationMessage) {\n const message = options.customValidationMessage\n\n formSchema = formSchema.messages({\n 'any.required': message,\n 'string.empty': message,\n 'string.pattern.base': message,\n [INVALID_ERROR_CODE]: message\n })\n } else if (options.customValidationMessages) {\n formSchema = formSchema.messages(options.customValidationMessages)\n }\n\n addClassOptionIfNone(options, 'govuk-input--width-20')\n\n this.formSchema = formSchema.default('')\n this.stateSchema = formSchema.default(null).allow(null)\n this.options = options\n }\n\n getViewModel(payload: FormPayload, errors?: FormSubmissionError[]) {\n const viewModel = super.getViewModel(payload, errors)\n const { attributes } = viewModel\n\n attributes.autocomplete = 'tel'\n\n return {\n ...viewModel,\n type: 'tel'\n }\n }\n\n /**\n * For error preview page that shows all possible errors on a component\n */\n getAllPossibleErrors(): ErrorMessageTemplateList {\n return TelephoneNumberField.getAllPossibleErrors()\n }\n\n /**\n * Static version of getAllPossibleErrors that doesn't require a component instance.\n */\n static getAllPossibleErrors(): ErrorMessageTemplateList {\n return {\n baseErrors: [\n { type: 'required', template: messageTemplate.required },\n { type: 'format', template: messageTemplate.format }\n ],\n advancedSettingsErrors: []\n }\n }\n}\n"],"mappings":"AAGA,SAASA,aAAa;AACtB,SAASC,oBAAoB;AAC7B,SACEC,kBAAkB,EAClBC,GAAG;AAEL,SAASC,eAAe;AAOxB,OAAO,MAAMC,oBAAoB,SAASL,aAAa,CAAC;EAKtDM,WAAWA,CACTC,GAAkC,EAClCC,KAAqD,EACrD;IACA,KAAK,CAACD,GAAG,EAAEC,KAAK,CAAC;IAEjB,MAAM;MAAEC;IAAQ,CAAC,GAAGF,GAAG;IACvB,MAAM;MAAEG;IAAO,CAAC,GAAGD,OAAO;IAE1B,IAAIE,UAAU,GAAGR,GAAG,CACjBS,MAAM,CAAC,CAAC,CACRC,IAAI,CAAC,CAAC,CACNC,WAAW,CAAC;MAAEJ;IAAO,CAAC,CAAC,CACvBK,KAA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