@defra/forms-engine-plugin 5.0.0-alpha.12 → 5.0.0-alpha.13

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 (59) hide show
  1. package/.public/javascripts/shared.min.js +1 -1
  2. package/.public/javascripts/shared.min.js.map +1 -1
  3. package/.server/client/javascripts/geospatial-map.d.ts +153 -5
  4. package/.server/client/javascripts/geospatial-map.js +147 -46
  5. package/.server/client/javascripts/geospatial-map.js.map +1 -1
  6. package/.server/client/javascripts/location-map.d.ts +38 -0
  7. package/.server/client/javascripts/location-map.js +42 -2
  8. package/.server/client/javascripts/location-map.js.map +1 -1
  9. package/.server/client/javascripts/map-constants.d.ts +3 -0
  10. package/.server/client/javascripts/map-constants.js +4 -0
  11. package/.server/client/javascripts/map-constants.js.map +1 -0
  12. package/.server/client/javascripts/map.d.ts +4 -0
  13. package/.server/client/javascripts/map.js +5 -0
  14. package/.server/client/javascripts/map.js.map +1 -1
  15. package/.server/server/plugins/engine/__stubs__/definitions.d.ts +29 -0
  16. package/.server/server/plugins/engine/__stubs__/definitions.js +125 -0
  17. package/.server/server/plugins/engine/__stubs__/definitions.js.map +1 -0
  18. package/.server/server/plugins/engine/components/EastingNorthingField.d.ts +2 -0
  19. package/.server/server/plugins/engine/components/GeospatialField.d.ts +1 -0
  20. package/.server/server/plugins/engine/components/GeospatialField.js +1 -0
  21. package/.server/server/plugins/engine/components/GeospatialField.js.map +1 -1
  22. package/.server/server/plugins/engine/components/LatLongField.d.ts +2 -0
  23. package/.server/server/plugins/engine/components/LocationFieldBase.js +3 -0
  24. package/.server/server/plugins/engine/components/LocationFieldBase.js.map +1 -1
  25. package/.server/server/plugins/engine/components/LocationFieldHelpers.d.ts +2 -0
  26. package/.server/server/plugins/engine/components/LocationFieldHelpers.js +2 -1
  27. package/.server/server/plugins/engine/components/LocationFieldHelpers.js.map +1 -1
  28. package/.server/server/plugins/engine/components/helpers/components.js +2 -1
  29. package/.server/server/plugins/engine/components/helpers/components.js.map +1 -1
  30. package/.server/server/plugins/engine/errors.d.ts +49 -0
  31. package/.server/server/plugins/engine/errors.js +75 -0
  32. package/.server/server/plugins/engine/errors.js.map +1 -0
  33. package/.server/server/plugins/engine/i18n/translations/cy.json +51 -1
  34. package/.server/server/plugins/engine/i18n/translations/en-GB.json +51 -1
  35. package/.server/server/plugins/engine/models/FormModel.js +10 -2
  36. package/.server/server/plugins/engine/models/FormModel.js.map +1 -1
  37. package/.server/server/plugins/engine/pageControllers/helpers/pages.js +2 -1
  38. package/.server/server/plugins/engine/pageControllers/helpers/pages.js.map +1 -1
  39. package/.server/server/plugins/engine/views/components/_location-field-base.html +1 -0
  40. package/.server/server/plugins/engine/views/components/geospatialfield.html +1 -0
  41. package/.server/server/plugins/engine/views/components/osgridreffield.html +3 -1
  42. package/package.json +1 -1
  43. package/src/client/javascripts/geospatial-map.js +169 -47
  44. package/src/client/javascripts/location-map.js +50 -2
  45. package/src/client/javascripts/map-constants.js +3 -0
  46. package/src/client/javascripts/map.js +5 -0
  47. package/src/server/plugins/engine/__stubs__/definitions.ts +155 -0
  48. package/src/server/plugins/engine/components/GeospatialField.ts +1 -0
  49. package/src/server/plugins/engine/components/LocationFieldBase.ts +4 -0
  50. package/src/server/plugins/engine/components/LocationFieldHelpers.ts +2 -1
  51. package/src/server/plugins/engine/components/helpers/components.ts +2 -1
  52. package/src/server/plugins/engine/errors.ts +78 -0
  53. package/src/server/plugins/engine/i18n/translations/cy.json +51 -1
  54. package/src/server/plugins/engine/i18n/translations/en-GB.json +51 -1
  55. package/src/server/plugins/engine/models/FormModel.ts +12 -2
  56. package/src/server/plugins/engine/pageControllers/helpers/pages.ts +2 -1
  57. package/src/server/plugins/engine/views/components/_location-field-base.html +1 -0
  58. package/src/server/plugins/engine/views/components/geospatialfield.html +1 -0
  59. package/src/server/plugins/engine/views/components/osgridreffield.html +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"geospatial-map.js","names":["createDatasetsPlugin","createDrawPlugin","bbox","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","getMapCountryLayers","getMapLayers","sssiDataset","formatDelimtedList","helpPanelConfig","focus","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","mapLayers","maplayers","datasets","apiPath","includes","initConfig","map","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","geometryTypes","geometrytypes","options","uiManager","getUIManager","context","addEventListeners","addFeatureToMap","feature","geometry","addFeature","addMarker","id","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","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","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 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 getMapCountryLayers,\n getMapLayers\n} from '~/src/client/javascripts/map.js'\nimport sssiDataset from '~/src/client/javascripts/sssi-dataset.js'\nimport { formatDelimtedList } from '~/src/client/javascripts/utils.js'\n\nconst helpPanelConfig = {\n focus: false,\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 const mapLayers = getMapLayers(geospatial.dataset.maplayers)\n const datasets = getMapCountryLayers(config.apiPath, country)\n\n if (mapLayers.includes('sssi')) {\n datasets.push(...sssiDataset)\n }\n\n // Create a map dataset plugin if there are any present\n if (datasets.length) {\n plugins.push(createDatasetsPlugin({ datasets }))\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,OAAOC,gBAAgB,MAAM,wCAAwC;AACrE,SAASC,IAAI,QAAQ,YAAY;AAEjC,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB,EACpBC,mBAAmB,EACnBC,YAAY;AAEd,OAAOC,WAAW;AAClB,SAASC,kBAAkB;AAE3B,MAAMC,eAAe,GAAG;EACtBC,KAAK,EAAE,KAAK;EACZC,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;AAC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CAACC,IAAI,CAAC,CAAC;MACpDiG,WAAW,CAAC,CAAC;IACf;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASoD,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
+ {"version":3,"file":"geospatial-map.js","names":["createDatasetsPlugin","createDrawPlugin","bbox","DEFAULT_LANG","ENGLISH_LANG","WELSH_LANG","EVENTS","createMap","defaultConfig","getCentroidGridRef","getCoordinateGridRef","getMapCountryLayers","getMapLayers","sssiDataset","formatDelimtedList","cy","type","enGB","englishTranslations","components","geospatialField","map","welshTranslations","languageTexts","getTexts","lang","helpPanelConfig","focus","showLabel","mobile","slot","open","dismissible","modal","tablet","desktop","getLineOrShapeText","texts","allowLine","allowShape","lineOrShapeText","lineText","shapeText","getAllowedTypesPhrase","allowPoint","items","push","typesPhrasePoint","typesPhraseLine","typesPhraseShape","typesPhraseOr","getTypeDescription","feature","typeDescriptions","geometry","point","line","polygon","getHelpPanelHtml","point3","allowedTypesText","ledeIntro","ledeOutro","point1","point2","point4","lineFeatureProperties","stroke","fill","strokeWidth","polygonFeatureProperties","POINT_SVG","POLYGON_SVG","LINE_SVG","getGeoJSON","geospatialInput","value","trim","hasValue","features","JSON","parse","geojson","getBoundingBox","processGeospatial","config","geospatial","index","HTMLDivElement","querySelector","HTMLTextAreaElement","listEl","mapId","createContainers","bounds","length","undefined","drawPlugin","plugins","country","dataset","mapLayers","maplayers","datasets","apiPath","includes","initConfig","interactPlugin","featuresManager","getFeaturesManager","activeFeatureManager","getActiveFeatureManager","geometryTypes","geometrytypes","options","uiManager","getUIManager","languageManager","context","addEventListeners","addFeatureToMap","addFeature","addMarker","id","coordinates","createFeaturesHTML","disabled","readonly","createFeatureHTML","join","focusFeature","mapProvider","fitBounds","flattened","flat","points","i","slice","p","description","properties","changeAction","itemUpdateLink","itemVisuallyHidden","deleteAction","itemDeleteLink","focusAction","itemFocusLink","links","actions","typeDescription","itemLabel1","itemLabel2","details","summary","centroidGridReference","firstPointGridReference","coordinateGridReference","detailedCoordinates","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","toggleButtonState","focusDescriptionInput","inputs","querySelectorAll","lastInput","item","select","on","mapReady","onMapReadyFactory","mapEl","document","createElement","setAttribute","listId","after","classList","add","onMapReady","e","addPanel","label","helpPanel","addButton","variant","buttons","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 createDrawPlugin from '@defra/interactive-map/plugins/draw-ml'\nimport { bbox } from '@turf/bbox'\n\nimport {\n DEFAULT_LANG,\n ENGLISH_LANG,\n WELSH_LANG\n} from '~/src/client/javascripts/map-constants.js'\nimport {\n EVENTS,\n createMap,\n defaultConfig,\n getCentroidGridRef,\n getCoordinateGridRef,\n getMapCountryLayers,\n getMapLayers\n} from '~/src/client/javascripts/map.js'\nimport sssiDataset from '~/src/client/javascripts/sssi-dataset.js'\nimport { formatDelimtedList } from '~/src/client/javascripts/utils.js'\nimport cy from '~/src/server/plugins/engine/i18n/translations/cy.json' with { type: 'json' }\nimport enGB from '~/src/server/plugins/engine/i18n/translations/en-GB.json' with { type: 'json' }\n\nconst englishTranslations = enGB.components.geospatialField.map\nconst welshTranslations = cy.components.geospatialField.map\n\n/**\n * @type {Record<LanguageCode, GeospatialLanguageTexts>}\n */\nexport const languageTexts = {\n [ENGLISH_LANG]: englishTranslations,\n [WELSH_LANG]: welshTranslations\n}\n\n/**\n * Get the map texts for the given language code\n * @param {LanguageCode} lang - the lanugae code\n */\nexport function getTexts(lang = DEFAULT_LANG) {\n return languageTexts[lang]\n}\n\nconst helpPanelConfig = {\n focus: false,\n showLabel: true,\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 {GeospatialPanelTexts} texts\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getLineOrShapeText(texts, allowLine, allowShape) {\n if (allowLine && allowShape) {\n return texts.lineOrShapeText\n }\n if (allowLine) {\n return texts.lineText\n }\n if (allowShape) {\n return texts.shapeText\n }\n return ''\n}\n\n/**\n * @param {GeospatialPanelTexts} texts\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nfunction getAllowedTypesPhrase(texts, allowPoint, allowLine, allowShape) {\n const items = []\n\n if (allowPoint) {\n items.push(texts.typesPhrasePoint)\n }\n if (allowLine) {\n items.push(texts.typesPhraseLine)\n }\n if (allowShape) {\n items.push(texts.typesPhraseShape)\n }\n\n return formatDelimtedList(items, ',', texts.typesPhraseOr)\n}\n\n/**\n * Gets the type description for a given feature\n * @param {Feature} feature - the geojson feature\n * @param {GeometryTexts} typeDescriptions\n */\nfunction getTypeDescription(feature, typeDescriptions) {\n switch (feature.geometry.type) {\n case 'Point':\n return typeDescriptions.point\n case 'LineString':\n return typeDescriptions.line\n case 'Polygon':\n return typeDescriptions.polygon\n }\n}\n\n/**\n * @param {GeospatialPanelTexts} texts\n * @param {boolean} allowPoint\n * @param {boolean} allowLine\n * @param {boolean} allowShape\n */\nexport function getHelpPanelHtml(texts, allowPoint, allowLine, allowShape) {\n const lineOrShapeText = getLineOrShapeText(texts, allowLine, allowShape)\n const point3 = lineOrShapeText\n ? `<li>${texts.point3} ${lineOrShapeText}</li>`\n : ''\n const allowedTypesText = getAllowedTypesPhrase(\n texts,\n allowPoint,\n allowLine,\n allowShape\n )\n return `<p class=\"govuk-body-s govuk-!-margin-bottom-2\">${texts.ledeIntro} ${allowedTypesText} ${texts.ledeOutro}</p><ul class=\"govuk-list govuk-list--number govuk-body-s\"><li>${texts.point1}</li><li>${texts.point2}</li>${point3}<li>${texts.point4}</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\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 const mapLayers = getMapLayers(geospatial.dataset.maplayers)\n const datasets = getMapCountryLayers(config.apiPath, country)\n\n if (mapLayers.includes('sssi')) {\n datasets.push(...sssiDataset)\n }\n\n // Create a map dataset plugin if there are any present\n if (datasets.length) {\n plugins.push(createDatasetsPlugin({ datasets }))\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 lang = /** @type {LanguageCode} */ (\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n geospatial.dataset.lang || DEFAULT_LANG\n )\n const uiManager = getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options,\n lang\n )\n\n const languageManager = {\n lang,\n texts: getTexts(lang)\n }\n\n /**\n * @type {Context}\n */\n const context = {\n languageManager,\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 * @param {LanguageCode} [lang] - the language for the feature details\n */\nexport function createFeaturesHTML(\n features,\n mapId,\n disabled = false,\n readonly = false,\n lang = DEFAULT_LANG\n) {\n return `<dl class=\"govuk-summary-list\">\n ${features.map((feature, index) => createFeatureHTML(feature, index, mapId, disabled, readonly, lang)).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 * @param {LanguageCode} [lang] - the language for the feature details\n */\nexport function createFeatureHTML(\n feature,\n index,\n mapId,\n disabled = false,\n readonly = false,\n lang = DEFAULT_LANG\n) {\n const texts = getTexts(lang)\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}\">${texts.itemUpdateLink}<span class=\"govuk-visually-hidden\"> ${texts.itemVisuallyHidden}</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}\">${texts.itemDeleteLink}<span class=\"govuk-visually-hidden\"> ${texts.itemVisuallyHidden}</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}\">${texts.itemFocusLink}<span class=\"govuk-visually-hidden\"> ${texts.itemVisuallyHidden}</span></a>\n</li>`\n\n const links = readonly ? focusAction() : `${changeAction()}${deleteAction()}`\n const actions = `<ul class=\"govuk-summary-list__actions-list\">${links}</ul>`\n const typeDescription = getTypeDescription(feature, texts.typeDescriptions)\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}\"`}>${texts.itemLabel1} ${index + 1} ${texts.itemLabel2}</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\">${texts.details.summary}</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\">${texts.details.type}</dt>\n <dd class=\"govuk-summary-list__value\">${typeDescription}</dd>\n </div>\n <div class=\"govuk-summary-list__row\">\n <dt class=\"govuk-summary-list__key\">${texts.details.centroidGridReference}</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\">${texts.details.firstPointGridReference}</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\">${texts.details.detailedCoordinates}</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 * @param {LanguageCode} [lang] - the language for the feature details\n * @returns {RenderList}\n */\nfunction getListRenderer(\n geojson,\n mapId,\n listEl,\n renderValue,\n lang = DEFAULT_LANG\n) {\n return function renderList(disabled = false) {\n const html = createFeaturesHTML(\n geojson.features,\n mapId,\n disabled,\n false,\n lang\n )\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 * @param {LanguageCode} [lang] - the language for the feature details\n */\nexport function getUIManager(\n geojson,\n map,\n mapId,\n listEl,\n geospatialInput,\n options,\n lang = DEFAULT_LANG\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, lang)\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 const { texts } = context.languageManager\n\n // Add info panel\n map.addPanel('info', {\n ...helpPanelConfig,\n label: texts.helpPanel.label,\n html: getHelpPanelHtml(texts.helpPanel, allowPoint, allowLine, allowShape)\n })\n\n if (allowPoint) {\n map.addButton('btnAddPoint', {\n variant: 'tertiary',\n label: texts.buttons.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: texts.buttons.polygon,\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: texts.buttons.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 * @param {LanguageCode} [lang] - the language for the feature details\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} GeometryTexts\n * @property {string} point - the label for a point feature in the list\n * @property {string} line - the label for a line string feature in the list\n * @property {string} polygon - the label for a polygon feature in the list\n */\n\n/**\n * @typedef {object} GeospatialPanelTexts\n * @property {string} label - the label for the info panel\n * @property {string} ledeIntro - the lede intro text for the info panel\n * @property {string} ledeOutro - the lede outro text for the info panel\n * @property {string} lineText - the label for the info panel line text\n * @property {string} shapeText - the label for the info panel shape text\n * @property {string} point1 - the text for bullet point 1 in the info panel\n * @property {string} point2 - the text for bullet point 2 in the info panel\n * @property {string} point3 - the text for bullet point 3 in the info panel\n * @property {string} point4 - the text for bullet point 4 in the info panel\n * @property {string} lineOrShapeText - the label for the info panel line or shape text\n * @property {string} typesPhrasePoint - the label for the info panel types phrase point\n * @property {string} typesPhraseLine - the label for the info panel types phrase line\n * @property {string} typesPhraseShape - the label for the info panel types phrase shape\n * @property {string} typesPhraseOr - the label for the info panel types phrase \"or\"\n */\n\n/**\n * @typedef {object} GeospatialLanguageTexts\n * @property {GeometryTexts} typeDescriptions - the descriptions of the geometry types\n * @property {GeospatialPanelTexts} helpPanel - texts for the info panel\n * @property {GeometryTexts} buttons - the labels for the action buttons\n * @property {string} itemLabel1 - the first part of the label for a feature in the list\n * @property {string} itemLabel2 - the second part of the label for a feature in the list\n * @property {string} itemUpdateLink - the label for the \"update\" link for a feature in the list\n * @property {string} itemDeleteLink - the label for the \"delete\" link for a feature in the list\n * @property {string} itemFocusLink - the label for the \"focus\" link for a feature in the list\n * @property {string} itemVisuallyHidden - visually hidden text to add context to action links\n * @property {object} details - labels for the details section of a feature in the list\n * @property {string} details.summary - label for the summary of a feature in the list\n * @property {string} details.type - label for the type of a feature in the list\n * @property {string} details.centroidGridReference - label for the centroid grid reference of a feature in the list\n * @property {string} details.firstPointGridReference - label for the first point grid reference of a feature in the list\n * @property {string} details.detailedCoordinates - label for the detailed coordinates of a feature in the list\n */\n\n/**\n * @typedef {object} LanguageManager\n * @property {LanguageCode} lang - the language for the interactive map\n * @property {GeospatialLanguageTexts} texts - the descriptions of the geometry types\n */\n\n/**\n * @typedef {object} Context\n * @property {LanguageManager} languageManager - the language manager for the interactive map\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 { LanguageCode } from '~/src/client/javascripts/map.js'\n * @import { MapLibreMap, UIManagerOptions } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA;AACA,OAAOA,oBAAoB,MAAM,yCAAyC;AAC1E;AACA,OAAOC,gBAAgB,MAAM,wCAAwC;AACrE,SAASC,IAAI,QAAQ,YAAY;AAEjC,SACEC,YAAY,EACZC,YAAY,EACZC,UAAU;AAEZ,SACEC,MAAM,EACNC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,oBAAoB,EACpBC,mBAAmB,EACnBC,YAAY;AAEd,OAAOC,WAAW;AAClB,SAASC,kBAAkB;AAC3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AAI,CAACN,MAAM,CAACxJ,OAAO,CAACuB,EAAE,EAAE;MAC/D;IACF;IAEA,MAAM;MAAEA;IAAG,CAAC,GAAGiI,MAAM,CAACxJ,OAAO;IAC7B,MAAMhD,OAAO,GAAGyH,UAAU,CAAClD,EAAE,CAAC;IAE9B,IAAIvE,OAAO,EAAE;MACXA,OAAO,CAACwF,UAAU,CAACD,WAAW,GAAGiH,MAAM,CAAChL,KAAK,CAACC,IAAI,CAAC,CAAC;MACpDyG,WAAW,CAAC,CAAC;IACf;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASuD,sBAAsBA,CAAA,EAAG;EAChC;AACF;AACA;AACA;AACA;EACE,OAAO,UAAUzB,CAAC,EAAE;IAClB,MAAMwC,MAAM,GAAGxC,CAAC,CAACwC,MAAM;IAEvB,IAAI,EAAEA,MAAM,YAAYM,gBAAgB,CAAC,EAAE;MACzC;IACF;IAEA,IAAI9C,CAAC,CAAC+C,IAAI,KAAK,OAAO,IAAI/C,CAAC,CAAC+C,IAAI,KAAK,aAAa,EAAE;MAClD/C,CAAC,CAAC0C,cAAc,CAAC,CAAC;MAClB1C,CAAC,CAAC2C,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;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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Get the map texts for the given language code
3
+ * @param {LanguageCode} lang - the lanugae code
4
+ */
5
+ export function getTexts(lang?: LanguageCode): LocationLanguageTexts;
1
6
  /**
2
7
  * Processes a location field to add map capability
3
8
  * @param {MapsEnvironmentConfig} config - the location field element
@@ -5,4 +10,37 @@
5
10
  * @param {number} index - the 0-based index
6
11
  */
7
12
  export function processLocation(config: MapsEnvironmentConfig, location: Element, index: number): void;
13
+ /**
14
+ * @type {Record<LanguageCode, LocationLanguageTexts>}
15
+ */
16
+ export const languageTexts: Record<LanguageCode, LocationLanguageTexts>;
17
+ export type LocationPanelTexts = {
18
+ /**
19
+ * - the label for the info panel
20
+ */
21
+ label: string;
22
+ /**
23
+ * - the text for bullet point 1 in the info panel
24
+ */
25
+ point1: string;
26
+ /**
27
+ * - the text for bullet point 2 in the info panel
28
+ */
29
+ point2: string;
30
+ /**
31
+ * - the text for bullet point 3 in the info panel
32
+ */
33
+ point3: string;
34
+ /**
35
+ * - the text for bullet point 4 in the info panel
36
+ */
37
+ point4: string;
38
+ };
39
+ export type LocationLanguageTexts = {
40
+ /**
41
+ * - texts for the info panel
42
+ */
43
+ helpPanel: LocationPanelTexts;
44
+ };
45
+ import type { LanguageCode } from '../../client/javascripts/map.js';
8
46
  import type { MapsEnvironmentConfig } from '../../client/javascripts/map.js';
@@ -1,9 +1,30 @@
1
1
  // @ts-expect-error - no types
2
2
  import createDatasetsPlugin from '@defra/interactive-map/plugins/datasets';
3
+ import { DEFAULT_LANG, ENGLISH_LANG, WELSH_LANG } from "./map-constants.js";
3
4
  import { EVENTS, centerMap, createMap, defaultConfig, eastingNorthingToLatLong, getMapCountryLayers, getMapLayers, latLongToEastingNorthing, latLongToOsGridRef, osGridRefToLatLong } from "./map.js";
4
5
  import sssiDataset from "./sssi-dataset.js";
6
+ import cy from "../../server/plugins/engine/i18n/translations/cy.json" with { type: 'json' };
7
+ import enGB from "../../server/plugins/engine/i18n/translations/en-GB.json" with { type: 'json' };
8
+ const englishTranslations = enGB.components.locationFieldBase.map;
9
+ const welshTranslations = cy.components.locationFieldBase.map;
5
10
  const LOCATION_FIELD_SELECTOR = 'input.govuk-input';
6
11
 
12
+ /**
13
+ * @type {Record<LanguageCode, LocationLanguageTexts>}
14
+ */
15
+ export const languageTexts = {
16
+ [ENGLISH_LANG]: englishTranslations,
17
+ [WELSH_LANG]: welshTranslations
18
+ };
19
+
20
+ /**
21
+ * Get the map texts for the given language code
22
+ * @param {LanguageCode} lang - the lanugae code
23
+ */
24
+ export function getTexts(lang = DEFAULT_LANG) {
25
+ return languageTexts[lang];
26
+ }
27
+
7
28
  /**
8
29
  * Gets initial map config for a location field
9
30
  * @param {HTMLDivElement} locationField - the location field element
@@ -397,6 +418,9 @@ export function processLocation(config, location, index) {
397
418
  datasets
398
419
  })];
399
420
  }
421
+ const lang = /** @type {LanguageCode} */
422
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
423
+ location.dataset.lang || DEFAULT_LANG;
400
424
  const {
401
425
  map,
402
426
  interactPlugin
@@ -421,12 +445,13 @@ export function processLocation(config, location, index) {
421
445
  default:
422
446
  throw new Error('Not implemented');
423
447
  }
448
+ const texts = getTexts(lang);
424
449
 
425
450
  // Add info panel
426
451
  map.addPanel('info', {
427
452
  focus: false,
428
453
  showLabel: true,
429
- label: 'How to use the map',
454
+ label: texts.helpPanel.label,
430
455
  mobile: {
431
456
  slot: 'drawer',
432
457
  open: true,
@@ -445,7 +470,7 @@ export function processLocation(config, location, index) {
445
470
  dismissible: true,
446
471
  modal: false
447
472
  },
448
- html: '<ul><li>Search for a place or postcode</li><li>Use the + and - icons to zoom in and out</li><li>Use a mouse or keyboard to centre the point at the location</li><li>Click to add the location to the map</li></ul>'
473
+ html: `<ul><li>${texts.helpPanel.point1}</li><li>${texts.helpPanel.point2}</li><li>${texts.helpPanel.point3}</li><li>${texts.helpPanel.point4}</li></ul>`
449
474
  });
450
475
 
451
476
  // Enable the interact plugin
@@ -454,6 +479,21 @@ export function processLocation(config, location, index) {
454
479
  }
455
480
 
456
481
  /**
482
+ * @typedef {object} LocationPanelTexts
483
+ * @property {string} label - the label for the info panel
484
+ * @property {string} point1 - the text for bullet point 1 in the info panel
485
+ * @property {string} point2 - the text for bullet point 2 in the info panel
486
+ * @property {string} point3 - the text for bullet point 3 in the info panel
487
+ * @property {string} point4 - the text for bullet point 4 in the info panel
488
+ */
489
+
490
+ /**
491
+ * @typedef {object} LocationLanguageTexts
492
+ * @property {LocationPanelTexts} helpPanel - texts for the info panel
493
+ */
494
+
495
+ /**
496
+ * @import { LanguageCode } from '../../client/javascripts/map.js'
457
497
  * @import { InteractiveMap, InteractiveMapInitConfig, MapCenter, MapLibreMap, MapsEnvironmentConfig } from '../../client/javascripts/map.js'
458
498
  */
459
499
  //# sourceMappingURL=location-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"location-map.js","names":["createDatasetsPlugin","EVENTS","centerMap","createMap","defaultConfig","eastingNorthingToLatLong","getMapCountryLayers","getMapLayers","latLongToEastingNorthing","latLongToOsGridRef","osGridRefToLatLong","sssiDataset","LOCATION_FIELD_SELECTOR","getInitMapConfig","locationField","locationType","dataset","locationtype","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","Error","validateLatLong","strLat","strLong","lat","trim","Number","long","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","easting","northing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","osGridRef","pattern","match","exec","getLatLongInputs","inputs","querySelectorAll","length","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","querySelector","getInitMapCenterConfig","center","zoom","markers","id","coords","result","undefined","latlong","osGridRefInput","bindLatLongField","map","mapProvider","on","interactMarkerChange","onInteractMarkerChange","e","maxPrecision","toFixed","onUpdateInputs","addEventListener","bindEastingNorthingField","point","bindOsGridRefField","onUpdateInput","processLocation","config","location","index","HTMLDivElement","locationInputs","supportedLocations","includes","mapContainer","document","createElement","mapId","setAttribute","initConfig","after","country","mapLayers","maplayers","datasets","apiPath","push","plugins","interactPlugin","mapReady","onMapReady","addPanel","focus","showLabel","label","mobile","slot","open","dismissible","modal","tablet","desktop","html","enable"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'\n\nimport {\n EVENTS,\n centerMap,\n createMap,\n defaultConfig,\n eastingNorthingToLatLong,\n getMapCountryLayers,\n getMapLayers,\n latLongToEastingNorthing,\n latLongToOsGridRef,\n osGridRefToLatLong\n} from '~/src/client/javascripts/map.js'\nimport sssiDataset from '~/src/client/javascripts/sssi-dataset.js'\n\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {number} index - the 0-based index\n */\nexport function processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const country = location.dataset.country\n const mapLayers = getMapLayers(location.dataset.maplayers)\n const datasets = getMapCountryLayers(config.apiPath, country)\n\n if (mapLayers.includes('sssi')) {\n datasets.push(...sssiDataset)\n }\n\n // Create a map dataset plugin if there are any present\n if (datasets.length) {\n initConfig.plugins = [createDatasetsPlugin({ datasets })]\n }\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n EVENTS.mapReady,\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n // Add info panel\n map.addPanel('info', {\n focus: false,\n showLabel: true,\n label: 'How to use the 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 html: '<ul><li>Search for a place or postcode</li><li>Use the + and - icons to zoom in and out</li><li>Use a mouse or keyboard to centre the point at the location</li><li>Click to add the location to the map</li></ul>'\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * @import { InteractiveMap, InteractiveMapInitConfig, MapCenter, MapLibreMap, MapsEnvironmentConfig } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA;AACA,OAAOA,oBAAoB,MAAM,yCAAyC;AAE1E,SACEC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,EACnBC,YAAY,EACZC,wBAAwB,EACxBC,kBAAkB,EAClBC,kBAAkB;AAEpB,OAAOC,WAAW;AAElB,MAAMC,uBAAuB,GAAG,mBAAmB;;AAEnD;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,aAAa,EAAE;EACvC,MAAMC,YAAY,GAAGD,aAAa,CAACE,OAAO,CAACC,YAAY;EAEvD,QAAQF,YAAY;IAClB,KAAK,cAAc;MACjB,OAAOG,uBAAuB,CAACJ,aAAa,CAAC;IAC/C,KAAK,sBAAsB;MACzB,OAAOK,+BAA+B,CAACL,aAAa,CAAC;IACvD,KAAK,gBAAgB;MACnB,OAAOM,yBAAyB,CAACN,aAAa,CAAC;IACjD;MACE,MAAM,IAAIO,KAAK,CAAC,iBAAiB,CAAC;EACtC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAACC,MAAM,EAAEC,OAAO,EAAE;EACxC,MAAMC,GAAG,GAAGF,MAAM,CAACG,IAAI,CAAC,CAAC,I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Q,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACtC;MACF,KAAK,sBAAsB;QACzBU,wBAAwB,CAACM,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QAC9C;MACF,KAAK,gBAAgB;QACnBY,kBAAkB,CAACI,QAAQ,EAAEhB,GAAG,EAAEK,CAAC,CAACL,GAAG,CAAC;QACxC;MACF;QACE,MAAM,IAAIrD,KAAK,CAAC,iBAAiB,CAAC;IACtC;;IAEA;IACAqD,GAAG,CAACuC,QAAQ,CAAC,MAAM,EAAE;MACnBC,KAAK,EAAE,KAAK;MACZC,SAAS,EAAE,IAAI;MACfC,KAAK,EAAE,oBAAoB;MAC3BC,MAAM,EAAE;QACNC,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDC,MAAM,EAAE;QACNJ,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDE,OAAO,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdC,IAAI,EAAE,IAAI;QACVC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDG,IAAI,EAAE;IACR,CAAC,CAAC;;IAEF;IACAd,cAAc,CAACe,MAAM,CAAC,CAAC;EACzB,CACF,CAAC;AACH;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"location-map.js","names":["createDatasetsPlugin","DEFAULT_LANG","ENGLISH_LANG","WELSH_LANG","EVENTS","centerMap","createMap","defaultConfig","eastingNorthingToLatLong","getMapCountryLayers","getMapLayers","latLongToEastingNorthing","latLongToOsGridRef","osGridRefToLatLong","sssiDataset","cy","type","enGB","englishTranslations","components","locationFieldBase","map","welshTranslations","LOCATION_FIELD_SELECTOR","languageTexts","getTexts","lang","getInitMapConfig","locationField","locationType","dataset","locationtype","getInitLatLongMapConfig","getInitEastingNorthingMapConfig","getInitOsGridRefMapConfig","Error","validateLatLong","strLat","strLong","lat","trim","Number","long","valid","latMin","latMax","longMin","longMax","latInBounds","longInBounds","value","validateEastingNorthing","strEasting","strNorthing","easting","northing","eastingMin","eastingMax","northingMin","northingMax","validateOsGridRef","osGridRef","pattern","match","exec","getLatLongInputs","inputs","querySelectorAll","length","latInput","longInput","getEastingNorthingInputs","eastingInput","northingInput","getOsGridRefInput","input","querySelector","getInitMapCenterConfig","center","zoom","markers","id","coords","result","undefined","latlong","osGridRefInput","bindLatLongField","mapProvider","on","interactMarkerChange","onInteractMarkerChange","e","maxPrecision","toFixed","onUpdateInputs","addEventListener","bindEastingNorthingField","point","bindOsGridRefField","onUpdateInput","processLocation","config","location","index","HTMLDivElement","locationInputs","supportedLocations","includes","mapContainer","document","createElement","mapId","setAttribute","initConfig","after","country","mapLayers","maplayers","datasets","apiPath","push","plugins","interactPlugin","mapReady","onMapReady","texts","addPanel","focus","showLabel","label","helpPanel","mobile","slot","open","dismissible","modal","tablet","desktop","html","point1","point2","point3","point4","enable"],"sources":["../../../src/client/javascripts/location-map.js"],"sourcesContent":["// @ts-expect-error - no types\nimport createDatasetsPlugin from '@defra/interactive-map/plugins/datasets'\n\nimport {\n DEFAULT_LANG,\n ENGLISH_LANG,\n WELSH_LANG\n} from '~/src/client/javascripts/map-constants.js'\nimport {\n EVENTS,\n centerMap,\n createMap,\n defaultConfig,\n eastingNorthingToLatLong,\n getMapCountryLayers,\n getMapLayers,\n latLongToEastingNorthing,\n latLongToOsGridRef,\n osGridRefToLatLong\n} from '~/src/client/javascripts/map.js'\nimport sssiDataset from '~/src/client/javascripts/sssi-dataset.js'\nimport cy from '~/src/server/plugins/engine/i18n/translations/cy.json' with { type: 'json' }\nimport enGB from '~/src/server/plugins/engine/i18n/translations/en-GB.json' with { type: 'json' }\n\nconst englishTranslations = enGB.components.locationFieldBase.map\nconst welshTranslations = cy.components.locationFieldBase.map\n\nconst LOCATION_FIELD_SELECTOR = 'input.govuk-input'\n\n/**\n * @type {Record<LanguageCode, LocationLanguageTexts>}\n */\nexport const languageTexts = {\n [ENGLISH_LANG]: englishTranslations,\n [WELSH_LANG]: welshTranslations\n}\n\n/**\n * Get the map texts for the given language code\n * @param {LanguageCode} lang - the lanugae code\n */\nexport function getTexts(lang = DEFAULT_LANG) {\n return languageTexts[lang]\n}\n\n/**\n * Gets initial map config for a location field\n * @param {HTMLDivElement} locationField - the location field element\n */\nfunction getInitMapConfig(locationField) {\n const locationType = locationField.dataset.locationtype\n\n switch (locationType) {\n case 'latlongfield':\n return getInitLatLongMapConfig(locationField)\n case 'eastingnorthingfield':\n return getInitEastingNorthingMapConfig(locationField)\n case 'osgridreffield':\n return getInitOsGridRefMapConfig(locationField)\n default:\n throw new Error('Not implemented')\n }\n}\n\n/**\n * Validates lat and long is numeric and within UK bounds\n * @param {string} strLat - the latitude string\n * @param {string} strLong - the longitude string\n * @returns {{ valid: false } | { valid: true, value: { lat: number, long: number } }}\n */\nfunction validateLatLong(strLat, strLong) {\n const lat = strLat.trim() && Number(strLat.trim())\n const long = strLong.trim() && Number(strLong.trim())\n\n if (!lat || !long) {\n return { valid: false }\n }\n\n const latMin = 49.85\n const latMax = 60.859\n const longMin = -13.687\n const longMax = 1.767\n\n const latInBounds = lat >= latMin && lat <= latMax\n const longInBounds = long >= longMin && long <= longMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { lat, long } }\n}\n\n/**\n * Validates easting and northing is numeric and within UK bounds\n * @param {string} strEasting - the easting string\n * @param {string} strNorthing - the northing string\n * @returns {{ valid: false } | { valid: true, value: { easting: number, northing: number } }}\n */\nfunction validateEastingNorthing(strEasting, strNorthing) {\n const easting = strEasting.trim() && Number(strEasting.trim())\n const northing = strNorthing.trim() && Number(strNorthing.trim())\n\n if (!easting || !northing) {\n return { valid: false }\n }\n\n const eastingMin = 0\n const eastingMax = 700000\n const northingMin = 0\n const northingMax = 1300000\n\n const latInBounds = easting >= eastingMin && easting <= eastingMax\n const longInBounds = northing >= northingMin && northing <= northingMax\n\n if (!latInBounds || !longInBounds) {\n return { valid: false }\n }\n\n return { valid: true, value: { easting, northing } }\n}\n\n/**\n * Validates OS grid reference is correct\n * @param {string} osGridRef - the OsGridRef\n * @returns {{ valid: false } | { valid: true, value: string }}\n */\nfunction validateOsGridRef(osGridRef) {\n if (!osGridRef) {\n return { valid: false }\n }\n\n const pattern =\n /^((([sS]|[nN])[a-hA-Hj-zJ-Z])|(([tT]|[oO])[abfglmqrvwABFGLMQRVW])|([hH][l-zL-Z])|([jJ][lmqrvwLMQRVW]))\\s?(([0-9]{3})\\s?([0-9]{3})|([0-9]{4})\\s?([0-9]{4})|([0-9]{5})\\s?([0-9]{5}))$/\n\n const match = pattern.exec(osGridRef)\n\n if (match === null) {\n return { valid: false }\n }\n\n return { valid: true, value: match[0] }\n}\n\n/**\n * Gets the inputs for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n */\nfunction getLatLongInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for lat and long')\n }\n\n const latInput = /** @type {HTMLInputElement} */ (inputs[0])\n const longInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { latInput, longInput }\n}\n\n/**\n * Gets the inputs for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n */\nfunction getEastingNorthingInputs(locationField) {\n const inputs = locationField.querySelectorAll(LOCATION_FIELD_SELECTOR)\n\n if (inputs.length !== 2) {\n throw new Error('Expected 2 inputs for easting and northing')\n }\n\n const eastingInput = /** @type {HTMLInputElement} */ (inputs[0])\n const northingInput = /** @type {HTMLInputElement} */ (inputs[1])\n\n return { eastingInput, northingInput }\n}\n\n/**\n * Gets the input for a OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n */\nfunction getOsGridRefInput(locationField) {\n const input = locationField.querySelector(LOCATION_FIELD_SELECTOR)\n\n if (input === null) {\n throw new Error('Expected 1 input for osgridref')\n }\n\n return /** @type {HTMLInputElement} */ (input)\n}\n\n/**\n * Get the initial map config for a center point\n * @param {MapCenter} center - the point\n */\nfunction getInitMapCenterConfig(center) {\n return {\n zoom: '16',\n center,\n markers: [\n {\n id: 'location',\n coords: center\n }\n ]\n }\n}\n\n/**\n * Gets initial map config for a latlong location field\n * @param {HTMLDivElement} locationField - the latlong location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitLatLongMapConfig(locationField) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for a easting/northing location field\n * @param {HTMLDivElement} locationField - the eastingnorthing location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitEastingNorthingMapConfig(locationField) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Gets initial map config for an OS grid reference location field\n * @param {HTMLDivElement} locationField - the osgridref location field element\n * @returns {InteractiveMapInitConfig | undefined}\n */\nfunction getInitOsGridRefMapConfig(locationField) {\n const osGridRefInput = getOsGridRefInput(locationField)\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (!result.valid) {\n return undefined\n }\n\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n return getInitMapCenterConfig(center)\n}\n\n/**\n * Bind a latlong field to the map\n * @param {HTMLDivElement} locationField - the latlong location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindLatLongField(locationField, map, mapProvider) {\n const { latInput, longInput } = getLatLongInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 7\n latInput.value = e.coords[1].toFixed(maxPrecision)\n longInput.value = e.coords[0].toFixed(maxPrecision)\n }\n )\n\n /**\n * Lat & long input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateLatLong(latInput.value, longInput.value)\n\n if (result.valid) {\n /** @type {MapCenter} */\n const center = [result.value.long, result.value.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n latInput.addEventListener('change', onUpdateInputs, false)\n longInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an eastingnorthing field to the map\n * @param {HTMLDivElement} locationField - the eastingnorthing location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindEastingNorthingField(locationField, map, mapProvider) {\n const { eastingInput, northingInput } =\n getEastingNorthingInputs(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const maxPrecision = 0\n const point = latLongToEastingNorthing({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n eastingInput.value = point.easting.toFixed(maxPrecision)\n northingInput.value = point.northing.toFixed(maxPrecision)\n }\n )\n\n /**\n * Easting & northing input change event listener\n * Update the map view location when the inputs are changed\n */\n function onUpdateInputs() {\n const result = validateEastingNorthing(\n eastingInput.value,\n northingInput.value\n )\n\n if (result.valid) {\n const latlong = eastingNorthingToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n eastingInput.addEventListener('change', onUpdateInputs, false)\n northingInput.addEventListener('change', onUpdateInputs, false)\n}\n\n/**\n * Bind an OS grid reference field to the map\n * @param {HTMLDivElement} locationField - the osgridref location field\n * @param {InteractiveMap} map - the map component instance (of InteractiveMap)\n * @param {MapLibreMap} mapProvider - the map provider instance (of MapLibreMap)\n */\nfunction bindOsGridRefField(locationField, map, mapProvider) {\n const osGridRefInput = getOsGridRefInput(locationField)\n\n map.on(\n EVENTS.interactMarkerChange,\n /**\n * Callback function which fires when the map marker changes\n * @param {object} e - the event\n * @param {[number, number]} e.coords - the map marker coordinates\n */\n function onInteractMarkerChange(e) {\n const point = latLongToOsGridRef({\n lat: e.coords[1],\n long: e.coords[0]\n })\n\n osGridRefInput.value = point\n }\n )\n\n /**\n * OS grid reference input change event listener\n * Update the map view location when the input is changed\n */\n function onUpdateInput() {\n const result = validateOsGridRef(osGridRefInput.value)\n\n if (result.valid) {\n const latlong = osGridRefToLatLong(result.value)\n\n /** @type {MapCenter} */\n const center = [latlong.long, latlong.lat]\n\n centerMap(map, mapProvider, center)\n }\n }\n\n osGridRefInput.addEventListener('change', onUpdateInput, false)\n}\n\n/**\n * Processes a location field to add map capability\n * @param {MapsEnvironmentConfig} config - the location field element\n * @param {Element} location - the location field element\n * @param {number} index - the 0-based index\n */\nexport function processLocation(config, location, index) {\n if (!(location instanceof HTMLDivElement)) {\n return\n }\n\n const locationInputs = location.querySelector('.app-location-field-inputs')\n if (!(locationInputs instanceof HTMLDivElement)) {\n return\n }\n const locationType = location.dataset.locationtype\n\n // Check for support\n const supportedLocations = [\n 'latlongfield',\n 'eastingnorthingfield',\n 'osgridreffield'\n ]\n if (!locationType || !supportedLocations.includes(locationType)) {\n return\n }\n\n const mapContainer = document.createElement('div')\n const mapId = `map_${index}`\n\n mapContainer.setAttribute('id', mapId)\n mapContainer.setAttribute('class', 'map-container')\n\n const initConfig = getInitMapConfig(location) ?? defaultConfig\n\n locationInputs.after(mapContainer)\n\n const country = location.dataset.country\n const mapLayers = getMapLayers(location.dataset.maplayers)\n const datasets = getMapCountryLayers(config.apiPath, country)\n\n if (mapLayers.includes('sssi')) {\n datasets.push(...sssiDataset)\n }\n\n // Create a map dataset plugin if there are any present\n if (datasets.length) {\n initConfig.plugins = [createDatasetsPlugin({ datasets })]\n }\n\n const lang = /** @type {LanguageCode} */ (\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n location.dataset.lang || DEFAULT_LANG\n )\n\n const { map, interactPlugin } = createMap(mapId, initConfig, config)\n\n map.on(\n EVENTS.mapReady,\n /**\n * Callback function which fires when the map is ready\n * @param {object} e - the event\n * @param {MapLibreMap} e.map - the map provider instance\n */\n function onMapReady(e) {\n switch (locationType) {\n case 'latlongfield':\n bindLatLongField(location, map, e.map)\n break\n case 'eastingnorthingfield':\n bindEastingNorthingField(location, map, e.map)\n break\n case 'osgridreffield':\n bindOsGridRefField(location, map, e.map)\n break\n default:\n throw new Error('Not implemented')\n }\n\n const texts = getTexts(lang)\n\n // Add info panel\n map.addPanel('info', {\n focus: false,\n showLabel: true,\n label: texts.helpPanel.label,\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 html: `<ul><li>${texts.helpPanel.point1}</li><li>${texts.helpPanel.point2}</li><li>${texts.helpPanel.point3}</li><li>${texts.helpPanel.point4}</li></ul>`\n })\n\n // Enable the interact plugin\n interactPlugin.enable()\n }\n )\n}\n\n/**\n * @typedef {object} LocationPanelTexts\n * @property {string} label - the label for the info panel\n * @property {string} point1 - the text for bullet point 1 in the info panel\n * @property {string} point2 - the text for bullet point 2 in the info panel\n * @property {string} point3 - the text for bullet point 3 in the info panel\n * @property {string} point4 - the text for bullet point 4 in the info panel\n */\n\n/**\n * @typedef {object} LocationLanguageTexts\n * @property {LocationPanelTexts} helpPanel - texts for the info panel\n */\n\n/**\n * @import { LanguageCode } from '~/src/client/javascripts/map.js'\n * @import { InteractiveMap, InteractiveMapInitConfig, MapCenter, MapLibreMap, MapsEnvironmentConfig } from '~/src/client/javascripts/map.js'\n */\n"],"mappings":"AAAA;AACA,OAAOA,oBAAoB,MAAM,yCAAyC;AAE1E,SACEC,YAAY,EACZC,YAAY,EACZC,UAAU;AAEZ,SACEC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,EACnBC,YAAY,EACZC,wBAAwB,EACxBC,kBAAkB,EAClBC,kBAAkB;AAEpB,OAAOC,WAAW;AAClB,OAAOC,EAAE,qEAAqEC,IAAI,EAAE,MAAM;AAC1F,OAAOC,IAAI,wEAAwED,IAAI,EAAE,MAAM;AAE/F,MAAME,mBAAmB,GAAGD,IAAI,CAACE,UAAU,CAACC,iBAAiB,CAACC,GAAG;AACjE,MAAMC,iBAAiB,GAAGP,EAAE,CAACI,UAAU,CAACC,iBAAiB,CAACC,GAAG;AAE7D,MAAME,uBAAuB,GAAG,mBAAmB;;AAEnD;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG;EAC3B,CAACtB,YAAY,GAAGgB,mBAAmB;EACnC,CAACf,UAAU,GAAGmB;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,SAASG,QAAQA,CAACC,IAAI,GAAGzB,YAAY,EAAE;EAC5C,OAAOuB,aAAa,CAACE,IAAI,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAACC,aAAa,EAAE;EACvC,MAAMC,YAAY,GAAGD,aAAa,CAACE,OAAO,CAACC,YAAY;EAEvD,QAAQF,YAAY;IAClB,KAAK,cAAc;MACjB,OAAOG,uBAAuB,CAACJ,aAAa,CAAC;IAC/C,KAAK,sBAAsB;MACzB,OAAOK,+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E,IAAI;QACjBC,KAAK,EAAE;MACT,CAAC;MACDG,IAAI,EAAE,WAAWb,KAAK,CAACK,SAAS,CAACS,MAAM,YAAYd,KAAK,CAACK,SAAS,CAACU,MAAM,YAAYf,KAAK,CAACK,SAAS,CAACW,MAAM,YAAYhB,KAAK,CAACK,SAAS,CAACY,MAAM;IAC/I,CAAC,CAAC;;IAEF;IACApB,cAAc,CAACqB,MAAM,CAAC,CAAC;EACzB,CACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export const ENGLISH_LANG: "en-GB";
2
+ export const WELSH_LANG: "cy";
3
+ export const DEFAULT_LANG: "en-GB";
@@ -0,0 +1,4 @@
1
+ export const ENGLISH_LANG = 'en-GB';
2
+ export const WELSH_LANG = 'cy';
3
+ export const DEFAULT_LANG = ENGLISH_LANG;
4
+ //# sourceMappingURL=map-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-constants.js","names":["ENGLISH_LANG","WELSH_LANG","DEFAULT_LANG"],"sources":["../../../src/client/javascripts/map-constants.js"],"sourcesContent":["export const ENGLISH_LANG = 'en-GB'\nexport const WELSH_LANG = 'cy'\nexport const DEFAULT_LANG = ENGLISH_LANG\n"],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAG,OAAO;AACnC,OAAO,MAAMC,UAAU,GAAG,IAAI;AAC9B,OAAO,MAAMC,YAAY,GAAGF,YAAY","ignoreList":[]}