@defra/interactive-map 0.0.53-alpha → 0.0.54-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/context.md +12 -0
- package/docs/api.md +11 -3
- package/docs/plugins/datasets.md +2 -0
- package/docs/plugins/map-key.md +41 -0
- package/package.json +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-ol-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +6 -6
- package/plugins/datasets/src/adapters/esri/registry/esriDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.js +1 -1
- package/plugins/datasets/src/adapters/maplibre/layerBuilders.test.js +3 -3
- package/plugins/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +1 -1
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.js +1 -3
- package/plugins/datasets/src/adapters/openlayers/canvasPatternStyle.test.js +0 -12
- package/plugins/datasets/src/adapters/openlayers/openlayersLayerAdapter.test.js +2 -2
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.js +1 -2
- package/plugins/datasets/src/adapters/openlayers/registry/openLayersDataset.test.js +3 -3
- package/plugins/datasets/src/fetch/createDynamicSource.js +2 -2
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
- package/plugins/datasets/src/initialise/defaults.js +12 -24
- package/plugins/datasets/src/initialise/defaults.test.js +25 -57
- package/plugins/datasets/src/initialise/initialiseDatasets.js +1 -4
- package/plugins/datasets/src/reducers/mappedDatasetsReducer.test.js +1 -1
- package/plugins/datasets/src/registry/dataset.js +21 -16
- package/plugins/datasets/src/registry/dataset.test.js +101 -11
- package/plugins/map-key/dist/css/index.css +1 -1
- package/plugins/map-key/dist/esm/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/im-map-key-plugin.js +1 -1
- package/plugins/map-key/dist/umd/index.js +1 -1
- package/plugins/map-key/src/components/Key/Key.module.scss +144 -53
- package/plugins/map-key/src/components/Key/KeyGroupItem.jsx +34 -3
- package/plugins/map-key/src/components/Key/KeyGroupItem.test.jsx +44 -2
- package/plugins/map-key/src/components/Key/KeySvg.jsx +5 -5
- package/plugins/map-key/src/components/Key/KeySvg.test.jsx +4 -4
- package/plugins/map-key/src/components/Key/KeySvgRamp.jsx +35 -6
- package/plugins/map-key/src/components/Key/KeySvgRamp.test.jsx +56 -16
- package/plugins/map-key/src/components/Key/useRampOrientation.js +61 -0
- package/plugins/map-key/src/components/Key/useRampOrientation.test.jsx +155 -0
- package/plugins/map-key/src/index.js +34 -0
- package/plugins/map-key/src/utils/groupStyles.js +5 -2
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +0 -1
- package/plugins/search/src/components/Form/Form.jsx +3 -3
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +2 -0
- package/plugins/search/src/components/Suggestions/Suggestions.test.jsx +6 -0
- package/plugins/search/src/defaults.js +3 -0
- package/plugins/search/src/events/formHandlers.js +3 -9
- package/plugins/search/src/events/formHandlers.test.js +6 -9
- package/plugins/search/src/events/inputHandlers.js +8 -2
- package/plugins/search/src/events/inputHandlers.test.js +20 -0
- package/plugins/search/src/events/suggestionHandlers.js +3 -5
- package/plugins/search/src/events/suggestionHandlers.test.js +5 -8
- package/plugins/search/src/utils/showResult.js +9 -0
- package/plugins/search/src/utils/showResult.test.js +16 -0
- package/src/App/components/Hints/Hints.module.scss +1 -1
- package/src/App/components/Viewport/Viewport.jsx +6 -4
- package/src/App/components/Viewport/Viewport.test.jsx +18 -1
- package/src/App/hooks/useMapAnnouncements.js +7 -2
- package/src/App/hooks/useMapAnnouncements.test.js +13 -2
- package/src/App/hooks/useModalPanelBehaviour.js +3 -1
- package/src/App/initialiseApp.js +1 -1
- package/src/App/store/ServiceProvider.jsx +7 -1
- package/src/App/store/ServiceProvider.test.jsx +15 -0
- package/src/InteractiveMap/InteractiveMap.js +3 -3
- package/src/services/mapFocus.js +64 -0
- package/src/services/mapFocus.test.js +76 -0
- package/src/types.js +2 -2
- package/src/utils/detectInterfaceType.js +16 -5
- package/src/utils/detectInterfaceType.test.js +32 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[414],{377(t,e,r){r.r(e),r.d(e,{manifest:()=>mt});var n=r(738),o=null,i=function(t){return o=t};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach(function(e){f(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function f(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s={},p=null,b=[],m=r(287),v=function(t){var e=t.text;return(0,m.jsx)("div",{className:"im-c-map-key",children:(0,m.jsx)("p",{className:"im-c-map-key__empty-message",children:e})})};function g(t){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},g(t)}var d=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===g(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function O(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach(function(e){j(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function j(t,e,r){return(e=function(t){var e=function(t){if("object"!=h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var w=20,P=44,k={xmlns:"http://www.w3.org/2000/svg",width:w,height:w,viewBox:"0 0 ".concat(w," ").concat(w),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},D=O(O({},k),{},{width:P,height:P,viewBox:"0 0 ".concat(P," ").concat(P),className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function A(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){I(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function I(t,e,r){return(e=function(t){var e=function(t){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var R=function(t){var e=t.keyDefinition,r=t.mapStyle,n=t.patternRegistry,o=e.style,i=n.getKeyPatternPaths(o,r.id);return i?(0,m.jsxs)("svg",A(A({},k),{},{children:[(0,m.jsx)("g",{dangerouslySetInnerHTML:{__html:i.border}}),(0,m.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:i.content}})]})):null};function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){K(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function K(t,e,r){return(e=function(t){var e=function(t){if("object"!=_(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var C=function(t){var e=t.keySymbol,r=null!=e?e:{},n=r.svg,o=r.viewBox;if(!n||!o)return null;var i,u,l=(i=o.split(" ").map(Number),u=4,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}(i,u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=l[2],c=l[3],y=Math.min(1,56/Math.max(a,c)),f=a*y,s=c*y;return(0,m.jsx)("svg",T(T({},D),{},{overflow:"visible",children:(0,m.jsx)("svg",{x:.5*(P-f),y:.5*(P-s),width:f,height:s,viewBox:o,overflow:"hidden",children:(0,m.jsx)("g",{dangerouslySetInnerHTML:{__html:n}})})}))};function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?B(Object(r),!0).forEach(function(e){G(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function G(t,e,r){return(e=function(t){var e=function(t){if("object"!=N(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var U=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=d(r.stroke,e.id);return(0,m.jsx)("svg",Y(Y({},k),{},{children:(0,m.jsx)("line",{x1:n/2,y1:10,x2:w-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function H(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){q(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function q(t,e,r){return(e=function(t){var e=function(t){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var z=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=d(r.fill,e.id),i=d(r.stroke,e.id);return(0,m.jsx)("svg",H(H({},k),{},{children:(0,m.jsx)("rect",{x:n/2,y:n/2,width:w-n,height:w-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},V=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=d(r.fill,e.id),o=d(r.fill,e.id);return(0,m.jsx)("svg",{viewBox:"0 0 5 5",preserveAspectRatio:"none",fill:n,stroke:o,strokeWidth:"1",children:(0,m.jsx)("path",{d:"M0 0h5v5H0z"})})},F="horizontal-ramp",J=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=function(t,e,r,n){if(!t)return{symbolShape:null,keySymbol:null};var o=t.hasSymbol,i=t.hasPattern,u=t.style;if(e===F)return{symbolShape:F,keySymbol:null};if(o){var l=n.getKeySymbol(u,r);return{symbolShape:l?"symbol":"rect",keySymbol:l}}return i?{symbolShape:"pattern",keySymbol:null}:null==u.fill&&u.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}}(e,r,n,o),l=u.symbolShape,a=u.keySymbol;return l?"symbol"===l?(0,m.jsx)(C,{keySymbol:a}):"pattern"===l?(0,m.jsx)(R,{mapStyle:n,keyDefinition:e,patternRegistry:i}):"line"===l?(0,m.jsx)(U,{mapStyle:n,keyDefinition:e}):l===F?(0,m.jsx)(V,{mapStyle:n,keyDefinition:e}):(0,m.jsx)(z,{mapStyle:n,keyDefinition:e}):null},Q=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=e.label,l=d(e.symbolDescription,n.id);return(0,m.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,m.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,m.jsx)(J,{keyDefinition:e,groupStyle:r,mapStyle:n,symbolRegistry:o,patternRegistry:i})}),(0,m.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[u,l&&(0,m.jsxs)("span",{className:"govuk-visually-hidden",children:["(",l,")"]})]})]})},X=function(t){var e=t.headingId,r=t.label,n=t.groupStyle,o=t.keyDefinitions,i=t.mapStyle,u=t.symbolRegistry,l=t.patternRegistry,a="im-c-map-key-list"+(n?" im-c-map-key-list-".concat(n):"");return(0,m.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[(0,m.jsx)("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),(0,m.jsx)("dl",{className:a,children:o.map(function(t){return(0,m.jsx)(Q,{keyDefinition:t,mapStyle:i,symbolRegistry:u,patternRegistry:l,groupStyle:n},"".concat(t.id))})})]})},Z="im-c-map-key",tt=function(t){var e=t.item,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry;return"group"===e.type?(0,m.jsx)(X,{headingId:"key-heading-".concat(e.id),label:e.groupLabel,groupStyle:r,keyDefinitions:e.keyDefinitions,mapStyle:n,symbolRegistry:o,patternRegistry:i}):(0,m.jsx)(Q,{keyDefinition:e.keyDefinition,mapStyle:n,symbolRegistry:o,patternRegistry:i})},et=function(t){var e=t.noKeyItemText,r=t.keyGroups,n=t.hasGroups,o=t.mapStyle,i=t.symbolRegistry,u=t.patternRegistry;if(null==r||!r.length)return(0,m.jsx)(v,{text:e});var l=n?"".concat(Z," ").concat("im-c-map-key--has-groups"):Z;return(0,m.jsx)("div",{className:l,children:r.map(function(t){return(0,m.jsx)(tt,{item:t,mapStyle:o,symbolRegistry:i,patternRegistry:u,groupStyle:t.groupStyle},t.id)})})};function rt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return nt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nt(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ot(t){return ot="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ot(t)}function it(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ut(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?it(Object(r),!0).forEach(function(e){lt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):it(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function lt(t,e,r){return(e=function(t){var e=function(t){if("object"!=ot(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ot(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ot(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ct(t){return ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ct(t)}function yt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ft(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?yt(Object(r),!0).forEach(function(e){st(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function st(t,e,r){return(e=function(t){var e=function(t){if("object"!=ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ct(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pt(t){return function(t){if(Array.isArray(t))return bt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return bt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?bt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var mt={InitComponent:function(t){var e=t.pluginConfig,r=t.pluginState,o=t.mapState,u=t.services,l=r.dispatch,a=u.eventBus,c=(0,n.useRef)(r);c.current=r,(0,n.useEffect)(function(){o.isMapReady&&(function(t){s=t}(c),a.requestOnce("datasets:registry",i),a.emit("map-key:ready"))},[o.isMapReady]),(0,n.useEffect)(function(){if(e.groups){var t=Object.entries(e.groups).map(function(t){var e,r,n=(r=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(e,r)||function(t,e){if(t){if("string"==typeof t)return at(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?at(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=n[0],i=n[1];return ut(ut({},i),{},{id:o,label:i.groupLabel})});l({type:"ADD_KEY_GROUPS",payload:t})}},[e.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_SYMBOL:function(t,e){var r,n=e.id,o=e.groupLabel,i=e.groupId||((r=o)?r.toLowerCase().replace(/\s+/g,"-"):null),u=function(t,e,r){return t.groups.find(function(t){return"group"===t.type&&t.id===r||"flat"===t.type&&t.id===e})}(t,n,i),l=u?null:function(t,e,r){return e?{id:e,type:"group",groupLabel:r}:{id:t,type:"flat"}}(n,i,o),a=l?[].concat(pt(t.groups),[l]):t.groups,c=[].concat(pt(t.keyDefinitions),[ft(ft({},e),{},{type:"manual"},i?{groupId:i}:{})]);return ft(ft({},t),{},{keyDefinitions:c,groups:a})},REMOVE_KEY_SYMBOL:function(t,e){var r=e.id;return ft(ft({},t),{},{keyDefinitions:t.keyDefinitions.filter(function(t){return t.id!==r})})},ADD_KEY_GROUPS:function(t,e){return ft(ft({},t),{},{groups:[].concat(pt(t.groups),pt(e))})}}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var e=t.mapState.mapStyle,r=t.pluginConfig.noKeyItemText,i=t.pluginState,u=t.services,a=u.eventBus,c=u.symbolRegistry,f=u.patternRegistry,v=rt((0,n.useState)(o),2),g=v[0],d=v[1],h=rt((0,n.useState)(function(){var t;return null!==(t=null==g?void 0:g.keyItems().items)&&void 0!==t?t:[]}),2),S=h[0],O=h[1],j=rt((0,n.useState)(function(){var t;return null!==(t=null==g?void 0:g.keyItems().hasGroups)&&void 0!==t&&t}),2),w=j[0],P=j[1],k=function(){var t=g.keyItems(),e=t.items,r=t.hasGroups,n=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=l(function(){var t;if(null===(t=s)||void 0===t||!t.current)return[];if(p===s.current)return b;p=s.current;var e=s.current,r=e.groups,n=void 0===r?[]:r,o=e.keyDefinitions,i=void 0===o?[]:o;return b=n.map(function(t){return"flat"===t.type?y(y({},t),{},{keyDefinition:i.find(function(e){return e.id===t.id})}):y(y({},t),{},{keyDefinitions:i.filter(function(e){return e.groupId===t.id})})})}());if(0===e.length)return t;var r=t.map(function(t){var r=e.findIndex(function(e){return e.id===t.id});if(-1===r)return t;var n=e.splice(r,1)[0];return y(y(y({},t),n),{},{keyDefinitions:[].concat(l(n.keyDefinitions||[]),l(t.keyDefinitions||[]))})});return[].concat(l(r),l(e)).filter(function(t){var e;return"flat"===t.type&&t.keyDefinition||"group"===t.type&&(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)})}(e);O(n),P(r)},D=function(t){g.invalidateKeyItemsOnMenuStateChange(t),k()};return(0,n.useEffect)(function(){return g?(k(),a.on("menu:changed",D).on("datasets:changed",k),function(){return a.off("menu:changed",D).off("datasets:changed",k)}):(a.requestOnce("datasets:registry",d),function(){})},[g]),(0,n.useEffect)(function(){g&&k()},[i]),(0,m.jsx)(et,{noKeyItemText:r,keyGroups:S,hasGroups:w,mapStyle:e,symbolRegistry:c,patternRegistry:f})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"ADD_KEY_SYMBOL",payload:e})},removeSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"REMOVE_KEY_SYMBOL",payload:e})}}}}}]);
|
|
1
|
+
"use strict";(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[414],{718(t,e,r){r.r(e),r.d(e,{manifest:()=>gt});var n=r(738),o=null,i=function(t){return o=t};function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}function l(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return a(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach(function(e){f(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function f(t,e,r){return(e=function(t){var e=function(t){if("object"!=u(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=u(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==u(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s={},p=null,m=[],b=r(287),d=function(t){var e=t.text;return(0,b.jsx)("div",{className:"im-c-map-key",children:(0,b.jsx)("p",{className:"im-c-map-key__empty-message",children:e})})};function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}var g=function(t,e){if(!t)return null;if("string"==typeof t)return t.trim();if("object"===v(t)){if(e&&t[e])return t[e];var r=Object.values(t)[0];return null!=r?r:null}return null};function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function S(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function O(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?S(Object(r),!0).forEach(function(e){j(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function j(t,e,r){return(e=function(t){var e=function(t){if("object"!=h(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==h(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var w=20,k=44,P={xmlns:"http://www.w3.org/2000/svg",width:w,height:w,viewBox:"0 0 ".concat(w," ").concat(w),className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false"},D=O(O({},P),{},{width:k,height:k,viewBox:"0 0 ".concat(k," ").concat(k),className:"im-c-map-key-symbol im-c-map-key-symbol--point"});function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function A(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach(function(e){I(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function I(t,e,r){return(e=function(t){var e=function(t){if("object"!=x(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=x(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==x(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var R=function(t){var e=t.keyDefinition,r=t.mapStyle,n=t.patternRegistry,o=e.style,i=n.getKeyPatternPaths(o,r.id);return i?(0,b.jsxs)("svg",A(A({},P),{},{children:[(0,b.jsx)("g",{dangerouslySetInnerHTML:{__html:i.border}}),(0,b.jsx)("g",{transform:"translate(".concat(2,", ").concat(2,")"),dangerouslySetInnerHTML:{__html:i.content}})]})):null};function _(t){return _="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_(t)}function M(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?M(Object(r),!0).forEach(function(e){C(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function C(t,e,r){return(e=function(t){var e=function(t){if("object"!=_(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function L(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var K=function(t){var e=t.keySymbol,r=null!=e?e:{},n=r.svg,o=r.viewBox;if(!n||!o)return null;var i,u,l=(i=o.split(" ").map(Number),u=4,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return L(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(t,e):void 0}}(i,u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=l[2],c=l[3],y=Math.min(1,56/Math.max(a,c)),f=a*y,s=c*y;return(0,b.jsx)("svg",T(T({},D),{},{overflow:"visible",children:(0,b.jsx)("svg",{x:.5*(k-f),y:.5*(k-s),width:f,height:s,viewBox:o,overflow:"hidden",children:(0,b.jsx)("g",{dangerouslySetInnerHTML:{__html:n}})})}))};function N(t){return N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N(t)}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function G(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?B(Object(r),!0).forEach(function(e){U(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function U(t,e,r){return(e=function(t){var e=function(t){if("object"!=N(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=N(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==N(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Y=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=g(r.stroke,e.id);return(0,b.jsx)("svg",G(G({},P),{},{children:(0,b.jsx)("line",{x1:n/2,y1:10,x2:w-n/2,y2:10,stroke:o,strokeWidth:n,strokeLinecap:"round"})}))};function W(t){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W(t)}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function F(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){H(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function H(t,e,r){return(e=function(t){var e=function(t){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var z=function(t){var e=t.mapStyle,r=t.keyDefinition.style,n=r.strokeWidth,o=g(r.fill,e.id),i=g(r.stroke,e.id);return(0,b.jsx)("svg",F(F({},P),{},{children:(0,b.jsx)("rect",{x:n/2,y:n/2,width:w-n,height:w-n,rx:n,ry:n,fill:o,stroke:i,strokeWidth:n,strokeLinejoin:"round"})}))},q=function(t){var e=t.mapStyle,r=t.keyDefinition,o=t.patternRegistry,i=r.style,u=r.hasPattern,l="im-c-map-key-ramp-"+(0,n.useId)().replace(/[^\w-]/g,""),a=u?o.getKeyPatternPaths(i,e.id):null,c=g(i.stroke,e.id),y=a?"url(#".concat(l,")"):g(i.fill,e.id);return(0,b.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"im-c-map-key-symbol","aria-hidden":"true",focusable:"false",children:[a&&(0,b.jsx)("defs",{children:(0,b.jsx)("pattern",{id:l,patternUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,dangerouslySetInnerHTML:{__html:a.content}})}),(0,b.jsx)("rect",{width:"100%",height:"100%",fill:y||"none",stroke:c,strokeWidth:c?4:void 0})]})},V="ramp",J=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=function(t,e,r,n){if(!t)return{symbolShape:null,keySymbol:null};var o=t.hasSymbol,i=t.hasPattern,u=t.style;if(e===V)return{symbolShape:V,keySymbol:null};if(o){var l=n.getKeySymbol(u,r);return{symbolShape:l?"symbol":"rect",keySymbol:l}}return i?{symbolShape:"pattern",keySymbol:null}:null==u.fill&&u.stroke?{symbolShape:"line",keySymbol:null}:{symbolShape:"rect",keySymbol:null}}(e,r,n,o),l=u.symbolShape,a=u.keySymbol;return l?"symbol"===l?(0,b.jsx)(K,{keySymbol:a}):"pattern"===l?(0,b.jsx)(R,{mapStyle:n,keyDefinition:e,patternRegistry:i}):"line"===l?(0,b.jsx)(Y,{mapStyle:n,keyDefinition:e}):l===V?(0,b.jsx)(q,{mapStyle:n,keyDefinition:e,patternRegistry:i}):(0,b.jsx)(z,{mapStyle:n,keyDefinition:e}):null},Q=function(t){var e=t.keyDefinition,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry,u=e.label,l=g(e.symbolDescription,n.id);return(0,b.jsxs)("div",{className:"im-c-map-key-list__item",children:[(0,b.jsx)("dt",{className:"im-c-map-key-list__item-symbol",children:(0,b.jsx)(J,{keyDefinition:e,groupStyle:r,mapStyle:n,symbolRegistry:o,patternRegistry:i})}),(0,b.jsxs)("dd",{className:"im-c-map-key-list__item-label",children:[u,l&&(0,b.jsxs)("span",{className:"govuk-visually-hidden",children:["(",l,")"]})]})]})},X=(new Set,new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),function(t){return!!(null!=t&&t.symbol||null!=t&&t.symbolSvgContent)});function Z(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var tt,et=function(t){var e=t.headingId,r=t.label,o=t.groupStyle,i=t.keyDefinitions,u=t.mapStyle,l=t.symbolRegistry,a=t.patternRegistry,c=(0,n.useRef)(null),y=function(t,e){return t===V&&e.some(function(t){return X(t.style)})?void 0:t}(o,i),f=y===V,s=f&&i.some(function(t){var e;return g(null===(e=t.style)||void 0===e?void 0:e.stroke,u.id)}),p=function(t,e,r,o){var i,u,l=(i=(0,n.useState)(!0),u=2,function(t){if(Array.isArray(t))return t}(i)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(i,u)||function(t,e){if(t){if("string"==typeof t)return Z(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Z(t,e):void 0}}(i,u)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=l[0],c=l[1],y=e.join("\n");return(0,n.useLayoutEffect)(function(){var n,o=t.current;if(r&&o){var i=!0,u=function(){var t=i?function(t,e){var r,n=t.querySelector(".im-c-map-key-list__item-label"),o=(void 0===tt&&(tt=null!==(r=document.createElement("canvas").getContext("2d"))&&void 0!==r?r:null),tt);if(!n||!o||!t.clientWidth)return null;var i=getComputedStyle(n),u=i.fontStyle,l=i.fontWeight,a=i.fontSize,c=i.fontFamily;o.font="".concat(u," ").concat(l," ").concat(a," ").concat(c);var y=getComputedStyle(t),f=Number.parseFloat(y.columnGap)||0,s=(Number.parseFloat(y.paddingLeft)||0)+(Number.parseFloat(y.paddingRight)||0),p=(t.clientWidth-s-f*(e.length-1))/e.length;return e.every(function(t){return o.measureText(t).width<=p})}(o,e):null;null!==t&&c(t)};u();var l="function"==typeof ResizeObserver?new ResizeObserver(u):null;return null==l||l.observe(o),null===(n=document.fonts)||void 0===n||n.ready.then(u,function(){}),function(){i=!1,null==l||l.disconnect()}}},[r,o,y]),a?"horizontal":"vertical"}(c,i.map(function(t){var e;return null!==(e=t.label)&&void 0!==e?e:""}),f,s),m=function(t,e,r){if(!t)return"im-c-map-key-list";var n="im-c-map-key-list im-c-map-key-list--".concat(t);if(t!==V)return n;var o="".concat(n," im-c-map-key-list--ramp-").concat(e);return r?"".concat(o," im-c-map-key-list--has-stroke"):o}(y,p,s);return(0,b.jsxs)("section",{className:"im-c-map-key__group","aria-labelledby":e,children:[(0,b.jsx)("h3",{id:e,className:"im-c-map-key__group-heading",children:r}),(0,b.jsx)("dl",{ref:c,className:m,children:i.map(function(t){return(0,b.jsx)(Q,{keyDefinition:t,mapStyle:u,symbolRegistry:l,patternRegistry:a,groupStyle:y},"".concat(t.id))})})]})},rt="im-c-map-key",nt=function(t){var e=t.item,r=t.groupStyle,n=t.mapStyle,o=t.symbolRegistry,i=t.patternRegistry;return"group"===e.type?(0,b.jsx)(et,{headingId:"key-heading-".concat(e.id),label:e.groupLabel,groupStyle:r,keyDefinitions:e.keyDefinitions,mapStyle:n,symbolRegistry:o,patternRegistry:i}):(0,b.jsx)(Q,{keyDefinition:e.keyDefinition,mapStyle:n,symbolRegistry:o,patternRegistry:i})},ot=function(t){var e=t.noKeyItemText,r=t.keyGroups,n=t.hasGroups,o=t.mapStyle,i=t.symbolRegistry,u=t.patternRegistry;if(null==r||!r.length)return(0,b.jsx)(d,{text:e});var l=n?"".concat(rt," ").concat("im-c-map-key--has-groups"):rt;return(0,b.jsx)("div",{className:l,children:r.map(function(t){return(0,b.jsx)(nt,{item:t,mapStyle:o,symbolRegistry:i,patternRegistry:u,groupStyle:t.groupStyle},t.id)})})};function it(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ut(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ut(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function lt(t){return lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lt(t)}function at(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?at(Object(r),!0).forEach(function(e){yt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):at(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function yt(t,e,r){return(e=function(t){var e=function(t){if("object"!=lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function st(t){return st="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},st(t)}function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function mt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?pt(Object(r),!0).forEach(function(e){bt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function bt(t,e,r){return(e=function(t){var e=function(t){if("object"!=st(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=st(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==st(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function dt(t){return function(t){if(Array.isArray(t))return vt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return vt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vt(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var gt={InitComponent:function(t){var e=t.pluginConfig,r=t.pluginState,o=t.mapState,u=t.services,l=r.dispatch,a=u.eventBus,c=(0,n.useRef)(r);c.current=r,(0,n.useEffect)(function(){o.isMapReady&&(function(t){s=t}(c),a.requestOnce("datasets:registry",i),a.emit("map-key:ready"))},[o.isMapReady]),(0,n.useEffect)(function(){if(e.groups){var t=Object.entries(e.groups).map(function(t){var e,r,n=(r=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],a=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{if(!a&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return l}}(e,r)||function(t,e){if(t){if("string"==typeof t)return ft(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ft(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=n[0],i=n[1];return ct(ct({},i),{},{id:o,label:i.groupLabel})});l({type:"ADD_KEY_GROUPS",payload:t})}},[e.groups])},reducer:{initialState:{keyDefinitions:[],groups:[]},actions:{ADD_KEY_SYMBOL:function(t,e){var r,n=e.id,o=e.groupLabel,i=e.groupId||((r=o)?r.toLowerCase().replace(/\s+/g,"-"):null),u=function(t,e,r){return t.groups.find(function(t){return"group"===t.type&&t.id===r||"flat"===t.type&&t.id===e})}(t,n,i),l=u?null:function(t,e,r){return e?{id:e,type:"group",groupLabel:r}:{id:t,type:"flat"}}(n,i,o),a=l?[].concat(dt(t.groups),[l]):t.groups,c=[].concat(dt(t.keyDefinitions),[mt(mt({},e),{},{type:"manual"},i?{groupId:i}:{})]);return mt(mt({},t),{},{keyDefinitions:c,groups:a})},REMOVE_KEY_SYMBOL:function(t,e){var r=e.id;return mt(mt({},t),{},{keyDefinitions:t.keyDefinitions.filter(function(t){return t.id!==r})})},ADD_KEY_GROUPS:function(t,e){return mt(mt({},t),{},{groups:[].concat(dt(t.groups),dt(e))})}}},panels:[{id:"mapKey",label:"Key",mobile:{slot:"drawer",modal:!0},tablet:{slot:"left-top",width:"260px"},desktop:{slot:"left-top",width:"280px"},render:function(t){var e=t.mapState.mapStyle,r=t.pluginConfig.noKeyItemText,i=t.pluginState,u=t.services,a=u.eventBus,c=u.symbolRegistry,f=u.patternRegistry,d=it((0,n.useState)(o),2),v=d[0],g=d[1],h=it((0,n.useState)(function(){var t;return null!==(t=null==v?void 0:v.keyItems().items)&&void 0!==t?t:[]}),2),S=h[0],O=h[1],j=it((0,n.useState)(function(){var t;return null!==(t=null==v?void 0:v.keyItems().hasGroups)&&void 0!==t&&t}),2),w=j[0],k=j[1],P=function(){var t=v.keyItems(),e=t.items,r=t.hasGroups,n=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=l(function(){var t;if(null===(t=s)||void 0===t||!t.current)return[];if(p===s.current)return m;p=s.current;var e=s.current,r=e.groups,n=void 0===r?[]:r,o=e.keyDefinitions,i=void 0===o?[]:o;return m=n.map(function(t){return"flat"===t.type?y(y({},t),{},{keyDefinition:i.find(function(e){return e.id===t.id})}):y(y({},t),{},{keyDefinitions:i.filter(function(e){return e.groupId===t.id})})})}());if(0===e.length)return t;var r=t.map(function(t){var r=e.findIndex(function(e){return e.id===t.id});if(-1===r)return t;var n=e.splice(r,1)[0];return y(y(y({},t),n),{},{keyDefinitions:[].concat(l(n.keyDefinitions||[]),l(t.keyDefinitions||[]))})});return[].concat(l(r),l(e)).filter(function(t){var e;return"flat"===t.type&&t.keyDefinition||"group"===t.type&&(null===(e=t.keyDefinitions)||void 0===e?void 0:e.length)})}(e);O(n),k(r)},D=function(t){v.invalidateKeyItemsOnMenuStateChange(t),P()};return(0,n.useEffect)(function(){return v?(P(),a.on("menu:changed",D).on("datasets:changed",P),function(){return a.off("menu:changed",D).off("datasets:changed",P)}):(a.requestOnce("datasets:registry",g),function(){})},[v]),(0,n.useEffect)(function(){v&&P()},[i]),(0,b.jsx)(ot,{noKeyItemText:r,keyGroups:S,hasGroups:w,mapStyle:e,symbolRegistry:c,patternRegistry:f})}}],buttons:[{id:"mapKey",panelId:"mapKey",label:"Key",iconId:"key",mobile:{slot:"top-left",showLabel:!0},tablet:{slot:"top-left",showLabel:!0},desktop:{slot:"top-left",showLabel:!0}}],icons:[{id:"key",svgContent:'<path d="M3 5h.01"/><path d="M3 12h.01"/><path d="M3 19h.01"/><path d="M8 5h13"/><path d="M8 12h13"/><path d="M8 19h13"/>'}],api:{addSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"ADD_KEY_SYMBOL",payload:e})},removeSymbol:function(t,e){(0,t.pluginState.dispatch)({type:"REMOVE_KEY_SYMBOL",payload:e})}}}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-map-key-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.mapKeyPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("defra",[],t):"object"==typeof exports?exports.defra=t():(e.defra=e.defra||{},e.defra.mapKeyPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat},287(e){e.exports=preactJsxRuntime}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.m=r,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((t,r)=>(o.f[r](e,t),t),[])),o.u=e=>"im-map-key-plugin.js",o.miniCssF=e=>{},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="defra.mapKeyPlugin:",o.l=(r,n,i,a)=>{if(e[r])e[r].push(n);else{var u,c;if(void 0!==i)for(var f=document.getElementsByTagName("script"),p=0;p<f.length;p++){var l=f[p];if(l.getAttribute("src")==r||l.getAttribute("data-webpack")==t+i){u=l;break}}u||(c=!0,(u=document.createElement("script")).charset="utf-8",o.nc&&u.setAttribute("nonce",o.nc),u.setAttribute("data-webpack",t+i),u.src=r),e[r]=[n];var s=(t,n)=>{u.onerror=u.onload=null,clearTimeout(d);var o=e[r];if(delete e[r],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach(e=>e(n)),t)return t(n)},d=setTimeout(s.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=s.bind(null,u.onerror),u.onload=s.bind(null,u.onload),c&&document.head.appendChild(u)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={57:0};o.f.j=(t,r)=>{var n=o.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise((r,o)=>n=e[t]=[r,o]);r.push(n[2]=i);var a=o.p+o.u(t),u=new Error;o.l(a,r=>{if(o.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;u.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",u.name="ChunkLoadError",u.type=i,u.request=a,n[1](u)}},"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[a,u,c]=r,f=0;if(a.some(t=>0!==e[t])){for(n in u)o.o(u,n)&&(o.m[n]=u[n]);c&&c(o)}for(t&&t(r);f<a.length;f++)i=a[f],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function u(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof f?n:f,p=Object.create(u.prototype);return c(p,"_invoke",function(r,n,o){var i,u,c,f=0,p=o||[],l=!1,s={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,r){return i=t,u=0,c=e,s.n=r,a}};function d(r,n){for(u=r,c=n,t=0;!l&&f&&!o&&t<p.length;t++){var o,i=p[t],d=s.p,b=i[2];r>3?(o=b===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(u=0,s.v=n,s.n=i[1]):d<b&&(o=r<3||i[0]>n||n>b)&&(i[4]=r,i[5]=n,s.n=b,u=0))}if(o||r>1)return a;throw l=!0,n}return function(o,p,b){if(f>1)throw TypeError("Generator is already running");for(l&&1===p&&d(p,b),u=p,c=b;(t=u<2?e:c)||!l;){i||(u?u<3?(u>1&&(s.n=-1),d(u,c)):s.n=c:s.v=c);try{if(f=2,i){if(u||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,u<2&&(u=0)}else 1===u&&(t=i.return)&&t.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=e}else if((t=(l=s.n<0)?c:r.call(n,s))!==a)break}catch(t){i=e,u=1,c=t}finally{f=1}}return{value:t,done:l}}}(r,o,i),!0),p}var a={};function f(){}function p(){}function l(){}t=Object.getPrototypeOf;var s=[][n]?t(t([][n]())):(c(t={},n,function(){return this}),t),d=l.prototype=f.prototype=Object.create(s);function b(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return p.prototype=l,c(d,"constructor",l),c(l,"constructor",p),p.displayName="GeneratorFunction",c(l,o,"GeneratorFunction"),c(d),c(d,o,"Generator"),c(d,n,function(){return this}),c(d,"toString",function(){return"[object Generator]"}),(u=function(){return{w:i,m:b}})()}function c(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}c=function(e,t,r,n){function i(t,r){c(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},c(e,t,r,n)}function f(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(){var e,t;return l(l({noKeyItemText:"No features displayed"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"mapKey",load:(e=u().m(function e(){var t;return u().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,o.e(414).then(o.bind(o,718));case 1:return t=e.v.manifest,e.a(2,t)}},e)}),t=function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){f(i,n,o,a,u,"next",e)}function u(e){f(i,n,o,a,u,"throw",e)}a(void 0)})},function(){return t.apply(this,arguments)})})}return o.d(i,{default:()=>d}),i.default})());
|
|
@@ -47,9 +47,11 @@
|
|
|
47
47
|
padding-bottom: 15px;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
$map-key-item-padding: 10px;
|
|
51
|
+
|
|
50
52
|
.im-c-map-key__group > .im-c-map-key-list .im-c-map-key-list__item {
|
|
51
|
-
padding-top:
|
|
52
|
-
padding-bottom:
|
|
53
|
+
padding-top: $map-key-item-padding;
|
|
54
|
+
padding-bottom: $map-key-item-padding;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
// Last item in all scenarios — flat or inside the last group
|
|
@@ -60,66 +62,155 @@
|
|
|
60
62
|
|
|
61
63
|
// Symbol
|
|
62
64
|
|
|
65
|
+
$map-key-symbol-inset: 3px;
|
|
66
|
+
$map-key-symbol-label-gap: 13px;
|
|
67
|
+
|
|
68
|
+
// Block, not inline, so the symbol cell is exactly the symbol's height, with no space below
|
|
69
|
+
// it for the text baseline
|
|
63
70
|
.im-c-map-key-symbol {
|
|
71
|
+
display: block;
|
|
64
72
|
position: relative;
|
|
65
73
|
flex-shrink: 0;
|
|
66
|
-
margin: 0
|
|
74
|
+
margin: 0 $map-key-symbol-label-gap 0 $map-key-symbol-inset;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
.im-c-map-key-symbol--point {
|
|
70
78
|
margin: -12px 1px -12px -9px;
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
// Ramp: bands butt up to each other unless any band has a stroke, then they're separated by a
|
|
82
|
+
// gap. Horizontal when every label fits on one line under its band (see useRampOrientation.js),
|
|
83
|
+
// otherwise vertical.
|
|
84
|
+
|
|
85
|
+
$map-key-symbol-size: 20px;
|
|
86
|
+
$map-key-ramp-gap: 2px;
|
|
87
|
+
$map-key-ramp-radius: 3px;
|
|
88
|
+
|
|
89
|
+
// Inset on both sides by the standard symbol's left margin, so the ramp lines up with the
|
|
90
|
+
// symbols in other groups. Both orientations share this padding and gap, so the available
|
|
91
|
+
// width measured for the labels is the same whichever orientation is rendered.
|
|
92
|
+
.im-c-map-key-list--ramp {
|
|
93
|
+
display: flex;
|
|
94
|
+
padding: 0 $map-key-symbol-inset;
|
|
95
|
+
|
|
96
|
+
&.im-c-map-key-list--has-stroke {
|
|
97
|
+
gap: $map-key-ramp-gap;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.im-c-map-key-symbol {
|
|
101
|
+
margin: 0;
|
|
102
|
+
overflow: hidden;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Horizontal: each item is an equal-width band in a row, with its label centred below
|
|
107
|
+
|
|
108
|
+
.im-c-map-key-list--ramp-horizontal {
|
|
109
|
+
padding-bottom: 10px;
|
|
110
|
+
|
|
79
111
|
.im-c-map-key-list__item {
|
|
80
|
-
|
|
81
|
-
position: relative !important;
|
|
82
|
-
display: flex;
|
|
112
|
+
flex: 1 1 0;
|
|
83
113
|
flex-direction: column;
|
|
114
|
+
align-items: stretch;
|
|
115
|
+
min-width: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.im-c-map-key-symbol {
|
|
119
|
+
display: block;
|
|
120
|
+
width: 100%;
|
|
121
|
+
height: $map-key-symbol-size;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Butted bands sit at fractional pixel positions, and each svg anti-aliases its own edges,
|
|
125
|
+
// so the panel shows through as a hairline at each seam. Extending every band but the last
|
|
126
|
+
// 1px under the next one puts a band, not the panel, behind each seam.
|
|
127
|
+
&:not(.im-c-map-key-list--has-stroke) .im-c-map-key-list__item:not(:last-child) .im-c-map-key-symbol {
|
|
128
|
+
width: calc(100% + 1px);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.im-c-map-key-list__item:first-child .im-c-map-key-symbol {
|
|
132
|
+
border-top-left-radius: $map-key-ramp-radius;
|
|
133
|
+
border-bottom-left-radius: $map-key-ramp-radius;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.im-c-map-key-list__item:last-child .im-c-map-key-symbol {
|
|
137
|
+
border-top-right-radius: $map-key-ramp-radius;
|
|
138
|
+
border-bottom-right-radius: $map-key-ramp-radius;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.im-c-map-key-list__item-label {
|
|
142
|
+
margin-top: 4px;
|
|
143
|
+
text-align: center;
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
84
147
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.im-c-map-key .im-c-map-
|
|
124
|
-
|
|
125
|
-
}
|
|
148
|
+
// Same specificity as the standard list item rules above, so horizontal items have no padding
|
|
149
|
+
.im-c-map-key__group > .im-c-map-key-list--ramp-horizontal .im-c-map-key-list__item,
|
|
150
|
+
.im-c-map-key__group:last-child > .im-c-map-key-list--ramp-horizontal .im-c-map-key-list__item:last-child {
|
|
151
|
+
padding-top: 0;
|
|
152
|
+
padding-bottom: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.im-c-map-key__group:last-child > .im-c-map-key-list--ramp-horizontal {
|
|
156
|
+
padding-bottom: 5px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Vertical: bands the width of a standard symbol, stacked, with the label beside each one.
|
|
160
|
+
// Rows have the standard item padding, so labels sit where they would in other groups, and
|
|
161
|
+
// each band is drawn over its whole item, padding included.
|
|
162
|
+
|
|
163
|
+
.im-c-map-key-list--ramp-vertical {
|
|
164
|
+
flex-direction: column;
|
|
165
|
+
|
|
166
|
+
.im-c-map-key-list__item {
|
|
167
|
+
position: relative;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.im-c-map-key-list__item-symbol {
|
|
171
|
+
flex-shrink: 0;
|
|
172
|
+
width: $map-key-symbol-size;
|
|
173
|
+
height: $map-key-symbol-size;
|
|
174
|
+
margin-right: $map-key-symbol-label-gap;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.im-c-map-key-symbol {
|
|
178
|
+
position: absolute;
|
|
179
|
+
top: 0;
|
|
180
|
+
left: 0;
|
|
181
|
+
width: $map-key-symbol-size;
|
|
182
|
+
height: 100%;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// As for horizontal, extend every band but the last 1px under the next one
|
|
186
|
+
&:not(.im-c-map-key-list--has-stroke) .im-c-map-key-list__item:not(:last-child) .im-c-map-key-symbol {
|
|
187
|
+
height: calc(100% + 1px);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.im-c-map-key-list__item:first-child .im-c-map-key-symbol {
|
|
191
|
+
border-top-left-radius: $map-key-ramp-radius;
|
|
192
|
+
border-top-right-radius: $map-key-ramp-radius;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.im-c-map-key-list__item:last-child .im-c-map-key-symbol {
|
|
196
|
+
border-bottom-left-radius: $map-key-ramp-radius;
|
|
197
|
+
border-bottom-right-radius: $map-key-ramp-radius;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Same specificity as the standard last item rule above, so the last band is full height
|
|
202
|
+
.im-c-map-key__group:last-child > .im-c-map-key-list--ramp-vertical .im-c-map-key-list__item:last-child {
|
|
203
|
+
padding-bottom: $map-key-item-padding;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Stroked bands are separated by the gap, so the padding either side of it gives up half the
|
|
207
|
+
// gap each, keeping the label spacing the same as in other groups
|
|
208
|
+
.im-c-map-key__group > .im-c-map-key-list--ramp-vertical.im-c-map-key-list--has-stroke .im-c-map-key-list__item {
|
|
209
|
+
&:not(:first-child) {
|
|
210
|
+
padding-top: $map-key-item-padding - $map-key-ramp-gap * 0.5;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&:not(:last-child) {
|
|
214
|
+
padding-bottom: $map-key-item-padding - $map-key-ramp-gap * 0.5;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import { getValueForStyle } from '../../../../../src/utils/getValueForStyle.js'
|
|
3
|
+
import { hasSymbol } from '../../../../../src/utils/symbolUtils.js'
|
|
1
4
|
import { KeyItem } from './KeyItem.jsx'
|
|
5
|
+
import { RAMP } from '../../utils/groupStyles.js'
|
|
6
|
+
import { useRampOrientation } from './useRampOrientation.js'
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
const getListClassName = (groupStyle, orientation, hasStroke) => {
|
|
9
|
+
if (!groupStyle) {
|
|
10
|
+
return 'im-c-map-key-list'
|
|
11
|
+
}
|
|
12
|
+
const className = `im-c-map-key-list im-c-map-key-list--${groupStyle}`
|
|
13
|
+
if (groupStyle !== RAMP) {
|
|
14
|
+
return className
|
|
15
|
+
}
|
|
16
|
+
// Stroked ramp bands are separated by a gap; unstroked bands butt up to each other
|
|
17
|
+
const rampClassName = `${className} im-c-map-key-list--ramp-${orientation}`
|
|
18
|
+
return hasStroke ? `${rampClassName} im-c-map-key-list--has-stroke` : rampClassName
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// A ramp's bands stretch to fill their row or column, which point symbols can't, so a ramp
|
|
22
|
+
// group with any symbol entries is shown as a standard group
|
|
23
|
+
const getGroupStyle = (groupStyle, keyDefinitions) =>
|
|
24
|
+
groupStyle === RAMP && keyDefinitions.some(keyDefinition => hasSymbol(keyDefinition.style))
|
|
25
|
+
? undefined
|
|
26
|
+
: groupStyle
|
|
27
|
+
|
|
28
|
+
export const KeyGroupItem = ({ headingId, label, groupStyle: configuredGroupStyle, keyDefinitions, mapStyle, symbolRegistry, patternRegistry }) => {
|
|
29
|
+
const listRef = useRef(null)
|
|
30
|
+
const groupStyle = getGroupStyle(configuredGroupStyle, keyDefinitions)
|
|
31
|
+
const isRamp = groupStyle === RAMP
|
|
32
|
+
const hasStroke = isRamp &&
|
|
33
|
+
keyDefinitions.some(keyDefinition => getValueForStyle(keyDefinition.style?.stroke, mapStyle.id))
|
|
34
|
+
const orientation = useRampOrientation(listRef, keyDefinitions.map(keyDefinition => keyDefinition.label ?? ''), isRamp, hasStroke)
|
|
35
|
+
const className = getListClassName(groupStyle, orientation, hasStroke)
|
|
5
36
|
return (
|
|
6
37
|
<section className='im-c-map-key__group' aria-labelledby={headingId}>
|
|
7
38
|
<h3 id={headingId} className='im-c-map-key__group-heading'>{label}</h3>
|
|
8
|
-
<dl className={className}>
|
|
39
|
+
<dl ref={listRef} className={className}>
|
|
9
40
|
{keyDefinitions.map(keyDefinition =>
|
|
10
41
|
<KeyItem
|
|
11
42
|
key={`${keyDefinition.id}`}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react'
|
|
2
2
|
import { KeyGroupItem } from './KeyGroupItem'
|
|
3
|
+
import { useRampOrientation } from './useRampOrientation.js'
|
|
4
|
+
|
|
5
|
+
jest.mock('./useRampOrientation.js', () => ({
|
|
6
|
+
useRampOrientation: jest.fn(() => 'horizontal')
|
|
7
|
+
}))
|
|
3
8
|
|
|
4
9
|
jest.mock('./KeyItem.jsx', () => ({
|
|
5
10
|
KeyItem: ({ keyDefinition }) => <div data-testid='key-item'>{keyDefinition.id}</div>
|
|
@@ -52,8 +57,45 @@ describe('KeyGroupItem', () => {
|
|
|
52
57
|
})
|
|
53
58
|
|
|
54
59
|
it('appends the groupStyle modifier class to the dl when groupStyle is provided', () => {
|
|
55
|
-
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='
|
|
56
|
-
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list
|
|
60
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='other' />)
|
|
61
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list--other')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('adds the measured orientation to a ramp', () => {
|
|
65
|
+
const keyDefinitions = [{ id: 'a', label: 'Low', style: {} }, { id: 'b', label: 'High', style: {} }]
|
|
66
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='ramp' keyDefinitions={keyDefinitions} />)
|
|
67
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list--ramp im-c-map-key-list--ramp-horizontal')
|
|
68
|
+
expect(useRampOrientation).toHaveBeenLastCalledWith(expect.anything(), ['Low', 'High'], true, false)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('renders a vertical ramp when the labels do not fit', () => {
|
|
72
|
+
useRampOrientation.mockReturnValueOnce('vertical')
|
|
73
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='ramp' />)
|
|
74
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list--ramp im-c-map-key-list--ramp-vertical')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('shows a ramp with any symbol entries as a standard group', () => {
|
|
78
|
+
const keyDefinitions = [{ id: 'a', label: 'Low', style: { fill: '#000' } }, { id: 'b', label: 'High', style: { symbol: 'pin' } }]
|
|
79
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='ramp' keyDefinitions={keyDefinitions} />)
|
|
80
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list')
|
|
81
|
+
expect(useRampOrientation).toHaveBeenLastCalledWith(expect.anything(), ['Low', 'High'], false, false)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('does not measure groups that are not ramps', () => {
|
|
85
|
+
render(<KeyGroupItem {...baseProps} />)
|
|
86
|
+
expect(useRampOrientation).toHaveBeenLastCalledWith(expect.anything(), [], false, false)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('adds the has-stroke modifier to a ramp when any item has a stroke', () => {
|
|
90
|
+
const keyDefinitions = [{ id: 'a', style: { fill: '#000' } }, { id: 'b', style: { stroke: { default: '#123' } } }]
|
|
91
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='ramp' keyDefinitions={keyDefinitions} />)
|
|
92
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list--ramp im-c-map-key-list--ramp-horizontal im-c-map-key-list--has-stroke')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('omits the has-stroke modifier when no ramp item has a stroke', () => {
|
|
96
|
+
const keyDefinitions = [{ id: 'a', style: { fill: '#000' } }, { id: 'b', style: { fillPattern: 'dot' } }]
|
|
97
|
+
const { container } = render(<KeyGroupItem {...baseProps} groupStyle='ramp' keyDefinitions={keyDefinitions} />)
|
|
98
|
+
expect(container.querySelector('dl').className).toBe('im-c-map-key-list im-c-map-key-list--ramp im-c-map-key-list--ramp-horizontal')
|
|
57
99
|
})
|
|
58
100
|
|
|
59
101
|
it('uses the base dl class when groupStyle is not provided', () => {
|
|
@@ -3,7 +3,7 @@ import { KeySvgSymbol } from './KeySvgSymbol.jsx'
|
|
|
3
3
|
import { KeySvgLine } from './KeySvgLine.jsx'
|
|
4
4
|
import { KeySvgRect } from './KeySvgRect.jsx'
|
|
5
5
|
import { KeySvgRamp } from './KeySvgRamp.jsx'
|
|
6
|
-
import {
|
|
6
|
+
import { RAMP } from '../../utils/groupStyles.js'
|
|
7
7
|
|
|
8
8
|
// Pure derivation of keyDefinition — computed directly during render (see KeyItem.jsx for why:
|
|
9
9
|
// staging this through useState/useEffect meant every fresh mount painted a blank symbol first).
|
|
@@ -13,8 +13,8 @@ const getSymbolShape = (keyDefinition, groupStyle, mapStyle, symbolRegistry) =>
|
|
|
13
13
|
return { symbolShape: null, keySymbol: null }
|
|
14
14
|
}
|
|
15
15
|
const { hasSymbol, hasPattern, style } = keyDefinition
|
|
16
|
-
if (groupStyle ===
|
|
17
|
-
return { symbolShape:
|
|
16
|
+
if (groupStyle === RAMP) {
|
|
17
|
+
return { symbolShape: RAMP, keySymbol: null }
|
|
18
18
|
}
|
|
19
19
|
if (hasSymbol) {
|
|
20
20
|
const keySymbol = symbolRegistry.getKeySymbol(style, mapStyle)
|
|
@@ -42,8 +42,8 @@ export const KeySvg = ({ keyDefinition, groupStyle, mapStyle, symbolRegistry, pa
|
|
|
42
42
|
return <KeySvgPattern mapStyle={mapStyle} keyDefinition={keyDefinition} patternRegistry={patternRegistry} />
|
|
43
43
|
} else if (symbolShape === 'line') {
|
|
44
44
|
return <KeySvgLine mapStyle={mapStyle} keyDefinition={keyDefinition} />
|
|
45
|
-
} else if (symbolShape ===
|
|
46
|
-
return <KeySvgRamp mapStyle={mapStyle} keyDefinition={keyDefinition} />
|
|
45
|
+
} else if (symbolShape === RAMP) {
|
|
46
|
+
return <KeySvgRamp mapStyle={mapStyle} keyDefinition={keyDefinition} patternRegistry={patternRegistry} />
|
|
47
47
|
} else {
|
|
48
48
|
return <KeySvgRect mapStyle={mapStyle} keyDefinition={keyDefinition} />
|
|
49
49
|
}
|
|
@@ -23,7 +23,7 @@ jest.mock('./KeySvgRect.jsx', () => ({
|
|
|
23
23
|
}))
|
|
24
24
|
|
|
25
25
|
jest.mock('./KeySvgRamp.jsx', () => ({
|
|
26
|
-
KeySvgRamp: () => <svg data-testid='key-svg-
|
|
26
|
+
KeySvgRamp: () => <svg data-testid='key-svg-ramp' />
|
|
27
27
|
}))
|
|
28
28
|
|
|
29
29
|
const baseKeyDefinition = {
|
|
@@ -98,8 +98,8 @@ describe('KeySvg', () => {
|
|
|
98
98
|
expect(container.firstChild).toBeNull()
|
|
99
99
|
})
|
|
100
100
|
|
|
101
|
-
it('renders KeySvgRamp when groupStyle is
|
|
102
|
-
const { getByTestId } = render(<KeySvg {...baseProps} keyDefinition={{ ...baseKeyDefinition }} groupStyle='
|
|
103
|
-
expect(getByTestId('key-svg-
|
|
101
|
+
it('renders KeySvgRamp when groupStyle is ramp', () => {
|
|
102
|
+
const { getByTestId } = render(<KeySvg {...baseProps} keyDefinition={{ ...baseKeyDefinition }} groupStyle='ramp' />)
|
|
103
|
+
expect(getByTestId('key-svg-ramp')).toBeTruthy()
|
|
104
104
|
})
|
|
105
105
|
})
|
|
@@ -1,13 +1,42 @@
|
|
|
1
|
+
import { useId } from 'react'
|
|
1
2
|
import { getValueForStyle } from '../../../../../src/utils/getValueForStyle.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// Matches the 2px border and 16×16 tile inset of the standard pattern key symbol.
|
|
5
|
+
const BORDER_WIDTH = 2
|
|
6
|
+
const PATTERN_TILE_SIZE = 16
|
|
7
|
+
|
|
8
|
+
// No viewBox: the band stretches to its column's width, and a viewBox would scale the
|
|
9
|
+
// pattern tile and stroke with it. Shapes and userSpaceOnUse tiles resolve in real pixels.
|
|
10
|
+
export const KeySvgRamp = ({ mapStyle, keyDefinition, patternRegistry }) => {
|
|
11
|
+
const { style, hasPattern } = keyDefinition
|
|
12
|
+
const patternId = 'im-c-map-key-ramp-' + useId().replace(/[^\w-]/g, '')
|
|
13
|
+
const paths = hasPattern ? patternRegistry.getKeyPatternPaths(style, mapStyle.id) : null
|
|
14
|
+
const stroke = getValueForStyle(style.stroke, mapStyle.id)
|
|
15
|
+
const fill = paths ? `url(#${patternId})` : getValueForStyle(style.fill, mapStyle.id)
|
|
7
16
|
|
|
8
17
|
return (
|
|
9
|
-
<svg
|
|
10
|
-
|
|
18
|
+
<svg xmlns='http://www.w3.org/2000/svg' className='im-c-map-key-symbol' aria-hidden='true' focusable='false'>
|
|
19
|
+
{paths && (
|
|
20
|
+
<defs>
|
|
21
|
+
<pattern
|
|
22
|
+
id={patternId}
|
|
23
|
+
patternUnits='userSpaceOnUse'
|
|
24
|
+
x={BORDER_WIDTH}
|
|
25
|
+
y={BORDER_WIDTH}
|
|
26
|
+
width={PATTERN_TILE_SIZE}
|
|
27
|
+
height={PATTERN_TILE_SIZE}
|
|
28
|
+
dangerouslySetInnerHTML={{ __html: paths.content }}
|
|
29
|
+
/>
|
|
30
|
+
</defs>
|
|
31
|
+
)}
|
|
32
|
+
{/* The stroke is drawn at double width on a flush rect; the svg clips the outer half */}
|
|
33
|
+
<rect
|
|
34
|
+
width='100%'
|
|
35
|
+
height='100%'
|
|
36
|
+
fill={fill || 'none'}
|
|
37
|
+
stroke={stroke}
|
|
38
|
+
strokeWidth={stroke ? BORDER_WIDTH * 2 : undefined}
|
|
39
|
+
/>
|
|
11
40
|
</svg>
|
|
12
41
|
)
|
|
13
42
|
}
|