@defra/interactive-map 0.0.43-alpha → 0.0.44-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.md +16 -8
- package/docs/plugins/draw.md +1 -1
- package/package.json +1 -1
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/datasets/dist/css/index.css +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/components/LayersMenu/Layers.module.scss +1 -0
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +6 -5
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +31 -26
- package/plugins/draw/src/DrawInit.test.jsx +55 -12
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +113 -114
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +82 -9
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/__helpers__/harness.js +18 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +9 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +8 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +35 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +29 -19
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +17 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +35 -29
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +24 -6
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.js +22 -20
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.js +31 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.test.js +8 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +38 -30
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +20 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +7 -7
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +14 -14
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.js +12 -32
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.test.js +10 -10
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +48 -22
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +74 -6
- package/plugins/draw/src/adapters/maplibre/utils/snapMovement.js +2 -2
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +6 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +9 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +15 -2
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +27 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +31 -17
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +55 -1
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.js +13 -7
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.test.js +7 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +36 -4
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +41 -1
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +35 -25
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +40 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +2 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +2 -2
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +32 -57
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +14 -13
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +1 -1
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +17 -1
- package/plugins/draw/src/events.js +4 -4
- package/plugins/draw/src/events.test.js +1 -1
- package/plugins/draw/src/hooks/useSpatialList.js +180 -0
- package/plugins/draw/src/hooks/useSpatialList.test.js +339 -0
- package/plugins/draw/src/utils/spatial.js +1 -31
- package/plugins/draw/src/utils/spatial.test.js +1 -24
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +2 -2
- package/plugins/interact/src/InteractInit.test.js +3 -3
- package/plugins/interact/src/events.js +5 -0
- package/plugins/interact/src/hooks/useAttachEvents.js +20 -0
- package/plugins/interact/src/hooks/useAttachEvents.test.js +44 -1
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -4
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +7 -7
- package/plugins/interact/src/hooks/{useMapItemList.js → useSpatialList.js} +87 -52
- package/plugins/interact/src/hooks/{useMapItemList.test.js → useSpatialList.test.js} +152 -71
- package/plugins/interact/src/manifest.js +12 -1
- package/plugins/interact/src/manifest.test.js +20 -0
- package/plugins/interact/src/utils/spatial.js +1 -1
- package/providers/beta/openlayers/src/utils/queryFeatures.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/utils/labels.js +2 -2
- package/providers/maplibre/src/utils/labels.test.js +5 -5
- package/providers/maplibre/src/utils/spatial.js +0 -57
- package/providers/maplibre/src/utils/spatial.test.js +0 -27
- package/src/App/components/CrossHair/CrossHair.jsx +10 -4
- package/src/App/components/CrossHair/CrossHair.module.scss +16 -12
- package/src/App/components/CrossHair/CrossHair.test.jsx +9 -4
- package/src/App/components/Hints/Hints.jsx +3 -3
- package/src/App/components/Hints/Hints.test.jsx +3 -3
- package/src/App/components/MapButton/MapButton.module.scss +1 -2
- package/src/App/components/{MoveControls/MoveControls.jsx → MapControls/MapControls.jsx} +10 -10
- package/src/App/components/{MoveControls/MoveControls.module.scss → MapControls/MapControls.module.scss} +25 -25
- package/src/App/components/{MoveControls/MoveControls.test.jsx → MapControls/MapControls.test.jsx} +48 -48
- package/src/App/components/Markers/Markers.jsx +2 -2
- package/src/App/components/Markers/Markers.test.jsx +3 -3
- package/src/App/components/Markers/SymbolMarker.test.jsx +2 -2
- package/src/App/components/Viewport/MapStatus.jsx +1 -1
- package/src/App/components/Viewport/SpatialList.jsx +47 -0
- package/src/App/components/Viewport/{Features.module.scss → SpatialList.module.scss} +3 -3
- package/src/App/components/Viewport/{Features.test.jsx → SpatialList.test.jsx} +60 -43
- package/src/App/components/Viewport/Viewport.jsx +20 -10
- package/src/App/components/Viewport/Viewport.test.jsx +18 -2
- package/src/App/hooks/useCrossHairAPI.js +5 -5
- package/src/App/hooks/useCrossHairAPI.test.js +5 -5
- package/src/App/hooks/useHintsAPI.js +5 -5
- package/src/App/hooks/useSpatialListFocus.js +296 -0
- package/src/App/hooks/{useFeatureFocus.test.js → useSpatialListFocus.test.js} +318 -163
- package/src/App/hooks/useSpatialListItems.js +51 -0
- package/src/App/hooks/useSpatialListItems.test.js +217 -0
- package/src/App/initialiseApp.js +6 -3
- package/src/App/initialiseApp.test.js +11 -0
- package/src/App/registry/spatialListRegistry.js +104 -0
- package/src/App/registry/spatialListRegistry.test.js +218 -0
- package/src/App/store/AppProvider.jsx +3 -2
- package/src/config/appConfig.js +14 -14
- package/src/config/appConfig.test.js +19 -19
- package/src/config/defaults.js +2 -2
- package/src/config/events.js +8 -8
- package/src/scss/main.scss +2 -2
- package/src/test-utils.js +8 -0
- package/src/types.js +11 -9
- package/src/utils/findNearestItemInDirection.js +29 -0
- package/src/utils/findNearestItemInDirection.test.js +67 -0
- package/src/utils/globalAltShortcuts.js +12 -0
- package/src/utils/globalAltShortcuts.test.js +27 -0
- package/src/utils/spatialNavigate.js +49 -0
- package/src/utils/spatialNavigate.test.js +42 -0
- package/src/App/components/Viewport/Features.jsx +0 -49
- package/src/App/hooks/useFeatureFocus.js +0 -257
- package/src/App/hooks/useFeatureItems.js +0 -39
- package/src/App/hooks/useFeatureItems.test.js +0 -155
|
@@ -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.drawPlugin=t())}(this,()=>(()=>{"use strict";var e,t,r={738(e){e.exports=preactCompat}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={exports:{}};return r[e].call(i.exports,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=>({356:"im-draw-ml-adapter",568:"im-draw-plugin",722:"im-draw-ol-adapter"}[e]+".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.drawPlugin:",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({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",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(568).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.drawPlugin=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].call(i.exports,i,i.exports,o),i.exports}o.m=r,o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},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=>({356:"im-draw-ml-adapter",568:"im-draw-plugin",722:"im-draw-ol-adapter"}[e]+".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.drawPlugin:",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({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),{},{id:"draw",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(568).then(o.bind(o,646));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})());
|
|
@@ -2,22 +2,11 @@ import { useEffect, useRef } from 'react'
|
|
|
2
2
|
import { EVENTS } from '../../../src/config/events.js'
|
|
3
3
|
import { loadDrawAdapter } from './adapters/loadDrawAdapter.js'
|
|
4
4
|
import { attachEvents } from './events.js'
|
|
5
|
+
import { useSpatialList } from './hooks/useSpatialList.js'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const isTouchOrKeyboard = ['touch', 'keyboard'].includes(appState.interfaceType)
|
|
10
|
-
|
|
11
|
-
// Mirrored directly in the render body (not a separate effect — matches useVisibleGeometry.js's
|
|
12
|
-
// own latestRef convention) so the crosshair effect's cleanup below can read the CURRENT
|
|
13
|
-
// shouldShowCrosshair decision rather than the stale one captured when that effect last ran.
|
|
14
|
-
// Without this, closing MoveControls (or leaving touch/keyboard) would fail to hide it: React
|
|
15
|
-
// runs the old effect's cleanup with its original closure, which still sees the OLD
|
|
16
|
-
// expandedButtons/interfaceType that made it visible in the first place.
|
|
17
|
-
const shouldShowCrosshairRef = useRef(false)
|
|
18
|
-
shouldShowCrosshairRef.current = ['draw_polygon', 'draw_line', 'draw_point'].includes(pluginState.mode) &&
|
|
19
|
-
(isTouchOrKeyboard || appState.expandedButtons?.has('moveControls'))
|
|
20
|
-
|
|
7
|
+
// Loads the draw adapter once the map is ready and this plugin instance is in scope for the
|
|
8
|
+
// current app mode; tears it down (and releases MapControls' D-pad) on cleanup.
|
|
9
|
+
function useLoadDrawAdapter ({ mapState, appState, pluginConfig, pluginState, mapProvider, eventBus }) {
|
|
21
10
|
useEffect(() => {
|
|
22
11
|
const inModeWhitelist = pluginConfig.includeModes?.includes(appState.mode) ?? true
|
|
23
12
|
const inExcludeModes = pluginConfig.excludeModes?.includes(appState.mode) ?? false
|
|
@@ -45,16 +34,35 @@ export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginSt
|
|
|
45
34
|
isMounted = false
|
|
46
35
|
mapProvider.draw?.remove()
|
|
47
36
|
mapProvider.draw = null
|
|
48
|
-
// Release
|
|
37
|
+
// Release MapControls' D-pad if this plugin instance still held it.
|
|
49
38
|
mapProvider.activeMoveTarget = null
|
|
50
39
|
}
|
|
51
40
|
}, [mapState.isMapReady, appState.mode])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginState, services, mapProvider, buttonConfig }) => {
|
|
44
|
+
const { eventBus, hints } = services
|
|
45
|
+
const { crossHair } = mapState
|
|
46
|
+
const isTouchOrKeyboard = ['touch', 'keyboard'].includes(appState.interfaceType)
|
|
47
|
+
|
|
48
|
+
useSpatialList({ mapState, pluginState, services, mapProvider, spatialListRegistry: appState.spatialListRegistry, viewportRef: appState.layoutRefs.viewportRef })
|
|
49
|
+
|
|
50
|
+
// Mirrored in the render body so the crosshair effect's cleanup below can read the CURRENT
|
|
51
|
+
// shouldShowCrosshair decision, not the stale one its closure captured when it last ran.
|
|
52
|
+
const shouldShowCrosshairRef = useRef(false)
|
|
53
|
+
shouldShowCrosshairRef.current = ['draw_polygon', 'draw_line', 'draw_point'].includes(pluginState.mode) &&
|
|
54
|
+
(isTouchOrKeyboard || appState.expandedButtons?.has('mapControls'))
|
|
55
|
+
|
|
56
|
+
useLoadDrawAdapter({ mapState, appState, pluginConfig, pluginState, mapProvider, eventBus })
|
|
52
57
|
|
|
53
|
-
// Suppresses the accessible
|
|
58
|
+
// Suppresses the accessible spatial list for every draw/edit mode except edit_vertex, which
|
|
59
|
+
// supplies its own list instead (useSpatialList.js above, claimed exclusively via the
|
|
60
|
+
// registry) — every other mode still has nothing meaningful to show.
|
|
54
61
|
useEffect(() => {
|
|
55
|
-
|
|
62
|
+
const suppressed = pluginState.mode !== null && pluginState.mode !== 'edit_vertex'
|
|
63
|
+
eventBus.emit(EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed })
|
|
56
64
|
return () => {
|
|
57
|
-
eventBus.emit(EVENTS.
|
|
65
|
+
eventBus.emit(EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false })
|
|
58
66
|
}
|
|
59
67
|
}, [pluginState.mode, eventBus])
|
|
60
68
|
|
|
@@ -65,19 +73,16 @@ export const DrawInit = ({ appState, appConfig, mapState, pluginConfig, pluginSt
|
|
|
65
73
|
const wasAlreadyVisible = crossHair.isVisible
|
|
66
74
|
crossHair.fixAtCenter()
|
|
67
75
|
return () => {
|
|
68
|
-
// Only hide
|
|
69
|
-
//
|
|
70
|
-
// have switched input devices, or opened/closed MoveControls, since this effect last ran).
|
|
76
|
+
// Only hide it if it wasn't visible before AND isn't still needed now (checked live via
|
|
77
|
+
// the ref, since input device or MapControls state may have changed since this ran).
|
|
71
78
|
if (!wasAlreadyVisible && !shouldShowCrosshairRef.current) {
|
|
72
79
|
crossHair.hide()
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
}, [pluginState.mode, appState.interfaceType, appState.expandedButtons])
|
|
76
83
|
|
|
77
|
-
// Keep the active draw/edit session in sync
|
|
78
|
-
//
|
|
79
|
-
// map, immediately when the input device changes mid-session (e.g. the user
|
|
80
|
-
// starts drawing with the mouse then switches to touch and pans via MoveControls).
|
|
84
|
+
// Keep the active draw/edit session's interface type in sync so the touch offset target and
|
|
85
|
+
// rubber band update immediately if the input device changes mid-session.
|
|
81
86
|
useEffect(() => {
|
|
82
87
|
if (!['edit_vertex', 'edit_point', 'draw_polygon', 'draw_line', 'draw_point'].includes(pluginState.mode) || !mapProvider.draw) {
|
|
83
88
|
return undefined
|
|
@@ -3,16 +3,18 @@ import { EVENTS } from '../../../src/config/events.js'
|
|
|
3
3
|
import { DrawInit } from './DrawInit.jsx'
|
|
4
4
|
import { loadDrawAdapter } from './adapters/loadDrawAdapter.js'
|
|
5
5
|
import { attachEvents } from './events.js'
|
|
6
|
+
import { useSpatialList } from './hooks/useSpatialList.js'
|
|
6
7
|
|
|
7
8
|
jest.mock('./adapters/loadDrawAdapter.js', () => ({ loadDrawAdapter: jest.fn() }))
|
|
8
9
|
jest.mock('./events.js', () => ({ attachEvents: jest.fn(() => jest.fn()) }))
|
|
10
|
+
jest.mock('./hooks/useSpatialList.js', () => ({ useSpatialList: jest.fn() }))
|
|
9
11
|
|
|
10
12
|
const makeProps = (overrides = {}) => {
|
|
11
13
|
const adapter = { remove: jest.fn(), setInterfaceType: jest.fn() }
|
|
12
14
|
loadDrawAdapter.mockResolvedValue(adapter)
|
|
13
15
|
|
|
14
16
|
const props = {
|
|
15
|
-
appState: { interfaceType: 'mouse', mode: null },
|
|
17
|
+
appState: { interfaceType: 'mouse', mode: null, spatialListRegistry: { registerItemProvider: jest.fn() }, layoutRefs: { viewportRef: { current: null } } },
|
|
16
18
|
appConfig: { id: 'app' },
|
|
17
19
|
mapState: {
|
|
18
20
|
isMapReady: true,
|
|
@@ -60,7 +62,7 @@ describe('adapter lifecycle', () => {
|
|
|
60
62
|
|
|
61
63
|
test('does not load when the app mode is excluded', async () => {
|
|
62
64
|
const { props } = makeProps({
|
|
63
|
-
appState: { interfaceType: 'mouse', mode: 'measure' },
|
|
65
|
+
appState: { interfaceType: 'mouse', mode: 'measure', layoutRefs: { viewportRef: { current: null } } },
|
|
64
66
|
pluginConfig: { snapLayers: [], excludeModes: ['measure'] }
|
|
65
67
|
})
|
|
66
68
|
await renderInit(props)
|
|
@@ -69,7 +71,7 @@ describe('adapter lifecycle', () => {
|
|
|
69
71
|
|
|
70
72
|
test('does not load when the app mode is outside the include list', async () => {
|
|
71
73
|
const { props } = makeProps({
|
|
72
|
-
appState: { interfaceType: 'mouse', mode: 'other' },
|
|
74
|
+
appState: { interfaceType: 'mouse', mode: 'other', layoutRefs: { viewportRef: { current: null } } },
|
|
73
75
|
pluginConfig: { snapLayers: [], includeModes: ['draw'] }
|
|
74
76
|
})
|
|
75
77
|
await renderInit(props)
|
|
@@ -108,7 +110,17 @@ describe('features list suppression', () => {
|
|
|
108
110
|
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' } })
|
|
109
111
|
await renderInit(props)
|
|
110
112
|
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
111
|
-
EVENTS.
|
|
113
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: true }
|
|
114
|
+
)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
// edit_vertex is the one exception — useSpatialList.js supplies its own list there
|
|
118
|
+
// (claimed exclusively via the registry) instead of hiding it.
|
|
119
|
+
test('does not suppress during edit_vertex', async () => {
|
|
120
|
+
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: 'edit_vertex' } })
|
|
121
|
+
await renderInit(props)
|
|
122
|
+
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
123
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false }
|
|
112
124
|
)
|
|
113
125
|
})
|
|
114
126
|
|
|
@@ -116,15 +128,15 @@ describe('features list suppression', () => {
|
|
|
116
128
|
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: null } })
|
|
117
129
|
await renderInit(props)
|
|
118
130
|
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
119
|
-
EVENTS.
|
|
131
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false }
|
|
120
132
|
)
|
|
121
133
|
})
|
|
122
134
|
|
|
123
135
|
test('re-suppresses/unsuppresses as the mode changes across re-renders', async () => {
|
|
124
|
-
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: '
|
|
136
|
+
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' } })
|
|
125
137
|
const result = await renderInit(props)
|
|
126
138
|
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
127
|
-
EVENTS.
|
|
139
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: true }
|
|
128
140
|
)
|
|
129
141
|
|
|
130
142
|
props.services.eventBus.emit.mockClear()
|
|
@@ -132,7 +144,23 @@ describe('features list suppression', () => {
|
|
|
132
144
|
result.rerender(<DrawInit {...props} />)
|
|
133
145
|
|
|
134
146
|
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
135
|
-
EVENTS.
|
|
147
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false }
|
|
148
|
+
)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('unsuppresses on entering edit_vertex, then re-suppresses leaving it for another mode', async () => {
|
|
152
|
+
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: 'edit_vertex' } })
|
|
153
|
+
const result = await renderInit(props)
|
|
154
|
+
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
155
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false }
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
props.services.eventBus.emit.mockClear()
|
|
159
|
+
props.pluginState = { ...props.pluginState, mode: 'draw_polygon' }
|
|
160
|
+
result.rerender(<DrawInit {...props} />)
|
|
161
|
+
|
|
162
|
+
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
163
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: true }
|
|
136
164
|
)
|
|
137
165
|
})
|
|
138
166
|
|
|
@@ -144,15 +172,30 @@ describe('features list suppression', () => {
|
|
|
144
172
|
result.unmount()
|
|
145
173
|
|
|
146
174
|
expect(props.services.eventBus.emit).toHaveBeenCalledWith(
|
|
147
|
-
EVENTS.
|
|
175
|
+
EVENTS.MAP_SET_SPATIAL_LIST_SUPPRESSED, { suppressed: false }
|
|
148
176
|
)
|
|
149
177
|
})
|
|
150
178
|
})
|
|
151
179
|
|
|
180
|
+
describe('useSpatialList wiring', () => {
|
|
181
|
+
test('is called with the plugin state/services/mapProvider, the app-level spatialListRegistry, and the viewport ref', async () => {
|
|
182
|
+
const { props } = makeProps({ pluginState: { dispatch: jest.fn(), mode: 'edit_vertex' } })
|
|
183
|
+
await renderInit(props)
|
|
184
|
+
expect(useSpatialList).toHaveBeenCalledWith({
|
|
185
|
+
mapState: props.mapState,
|
|
186
|
+
pluginState: props.pluginState,
|
|
187
|
+
services: props.services,
|
|
188
|
+
mapProvider: props.mapProvider,
|
|
189
|
+
spatialListRegistry: props.appState.spatialListRegistry,
|
|
190
|
+
viewportRef: props.appState.layoutRefs.viewportRef
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
|
|
152
195
|
describe('crosshair', () => {
|
|
153
196
|
test('fixes the crosshair at centre while drawing on a touch interface', async () => {
|
|
154
197
|
const { props } = makeProps({
|
|
155
|
-
appState: { interfaceType: 'touch', mode: null },
|
|
198
|
+
appState: { interfaceType: 'touch', mode: null, layoutRefs: { viewportRef: { current: null } } },
|
|
156
199
|
pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' }
|
|
157
200
|
})
|
|
158
201
|
await renderInit(props)
|
|
@@ -161,7 +204,7 @@ describe('crosshair', () => {
|
|
|
161
204
|
|
|
162
205
|
test('leaves the crosshair alone when not drawing', async () => {
|
|
163
206
|
const { props } = makeProps({
|
|
164
|
-
appState: { interfaceType: 'touch', mode: null },
|
|
207
|
+
appState: { interfaceType: 'touch', mode: null, layoutRefs: { viewportRef: { current: null } } },
|
|
165
208
|
pluginState: { dispatch: jest.fn(), mode: 'edit_vertex' }
|
|
166
209
|
})
|
|
167
210
|
await renderInit(props)
|
|
@@ -170,7 +213,7 @@ describe('crosshair', () => {
|
|
|
170
213
|
|
|
171
214
|
test('hides the crosshair on cleanup when it was hidden before and the interface has left touch/keyboard', async () => {
|
|
172
215
|
const { props } = makeProps({
|
|
173
|
-
appState: { interfaceType: 'touch', mode: null },
|
|
216
|
+
appState: { interfaceType: 'touch', mode: null, layoutRefs: { viewportRef: { current: null } } },
|
|
174
217
|
pluginState: { dispatch: jest.fn(), mode: 'draw_polygon' }
|
|
175
218
|
})
|
|
176
219
|
const result = await renderInit(props)
|