@nocobase/plugin-map 1.0.0-alpha.13 → 1.0.0-alpha.15
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/client/index.js +22 -22
- package/dist/externalVersion.js +5 -5
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,46 +7,46 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(D,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared"],s):(D=typeof globalThis!="undefined"?globalThis:D||self,s(D["@nocobase/plugin-map"]={},D.jsxRuntime,D["@nocobase/client"],D.react,D["@ant-design/icons"],D["@formily/react"],D.ahooks,D.antd,D["react-i18next"],D["react-router-dom"],D.lodash,D["@formily/antd-v5"],D["@formily/shared"]))})(this,function(D,s,n,h,R,G,V,w,ne,le,ke,We,Ye){"use strict";var Tt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ve=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var Pe=(D,s,n)=>s in D?Tt(D,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):D[s]=n,O=(D,s)=>{for(var n in s||(s={}))Ut.call(s,n)&&Pe(D,n,s[n]);if(Ve)for(var n of Ve(s))Nt.call(s,n)&&Pe(D,n,s[n]);return D},X=(D,s)=>Bt(D,Kt(s));var F=(D,s,n)=>(Pe(D,typeof s!="symbol"?s+"":s,n),n);var ye=(D,s,n)=>new Promise((h,R)=>{var G=ne=>{try{w(n.next(ne))}catch(le){R(le)}},V=ne=>{try{w(n.throw(ne))}catch(le){R(le)}},w=ne=>ne.done?h(ne.value):Promise.resolve(ne.value).then(G,V);w((n=n.apply(D,s)).next())});const fe="map";function Q(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function J(){return ne.useTranslation([fe,"client"],{nsMode:"fallback"})}const Fe=[{label:Q("AMap"),value:"amap"},{label:Q("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==",Oe=(e,o,t)=>{const r=o==null?void 0:o.reduce((a,i,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(m=>m[i]).filter(m=>m!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?r:[r]};var Je=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Je,function(){function t(c){var b=[];return c.AMapUI&&b.push(r(c.AMapUI)),c.Loca&&b.push(a(c.Loca)),Promise.all(b)}function r(c){return new Promise(function(b,u){var d=[];if(c.plugins)for(var M=0;M<c.plugins.length;M+=1)l.AMapUI.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);if(m.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var L=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+M+"/main.js",K.onerror=function(I){m.AMapUI=i.failed,u("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},L.appendChild(K)}else m.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}b()}):b():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var q=0,Y=d.length;q<Y;q++){var U=d[q].split("/").slice(-1)[0];window.AMapUI[U]=arguments[q]}b()}):b()})})}function a(c){return new Promise(function(b,u){if(m.Loca===i.failed)u("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),L=d.startsWith("2");if(M&&!L||!M&&L)u("JSAPI 与 Loca 版本不对应!!");else{M=l.key,L=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+M,K.onerror=function(I){m.Loca=i.failed,u("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=i.loaded,b();v.Loca.length;)v.Loca.splice(0,1)[0]()},L.appendChild(K)}}else m.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):v.Loca.push(function(I){I?u(I):u()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]},A=[],C=function(c){typeof c=="function"&&(m.AMap===i.loaded?c(window.AMap):A.push(c))};return{load:function(c){return new Promise(function(b,u){if(m.AMap==i.failed)u("");else if(m.AMap==i.notload){var d=c.key,M=c.version,L=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=L||l.AMap.plugins,m.AMap=i.loading,M=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=i.failed,u(I);else for(m.AMap=i.loaded,t(c).then(function(){b(window.AMap)}).catch(u);A.length;)A.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),L.onerror=function(I){m.AMap=i.failed,u(I)},M.appendChild(L)):u("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var K=[];if(c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&K.push(c.plugins[M]);C(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Ee);var Xe=Ee.exports;const He=Ze(Xe),ze="map-configuration",ve=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Ae=e=>{const o=h.useMemo(()=>{const r=sessionStorage.getItem(ve(e));return r&&JSON.parse(r)},[e]),{data:t}=n.useRequest({resource:ze,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(ve(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Qe=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{a.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=V.useDebounceFn(A=>{a.current&&a.current.search(A||" ",(C,c)=>{if(C==="complete")l(c.poiList.pois.map(b=>X(O({},b),{label:`${b.name}-${b.address}`,value:b.id})));else{if(C==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=A=>{const C=i.find(c=>c.value===A);C!=null&&C.location&&t(C.location)};return s.jsx("div",{className:n.css`
|
|
10
|
+
(function(T,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared"],n):(T=typeof globalThis!="undefined"?globalThis:T||self,n(T["@nocobase/plugin-map"]={},T.jsxRuntime,T["@nocobase/client"],T.react,T["@ant-design/icons"],T["@formily/react"],T.ahooks,T.antd,T["react-i18next"],T["react-router-dom"],T.lodash,T["@formily/antd-v5"],T["@formily/shared"]))})(this,function(T,n,s,h,R,G,V,w,ne,le,ke,Ye,Je){"use strict";var Bt=Object.defineProperty,Kt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var We=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Pe=(T,n,s)=>n in T?Bt(T,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):T[n]=s,F=(T,n)=>{for(var s in n||(n={}))Nt.call(n,s)&&Pe(T,s,n[s]);if(We)for(var s of We(n))Gt.call(n,s)&&Pe(T,s,n[s]);return T},X=(T,n)=>Kt(T,Ut(n));var O=(T,n,s)=>(Pe(T,typeof n!="symbol"?n+"":n,s),s);var ye=(T,n,s)=>new Promise((h,R)=>{var G=ne=>{try{w(s.next(ne))}catch(le){R(le)}},V=ne=>{try{w(s.throw(ne))}catch(le){R(le)}},w=ne=>ne.done?h(ne.value):Promise.resolve(ne.value).then(G,V);w((s=s.apply(T,n)).next())});const fe="map";function Q(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function J(){return ne.useTranslation([fe,"client"],{nsMode:"fallback"})}const Fe=[{label:Q("AMap"),value:"amap"},{label:Q("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==",Oe=(e,o,t)=>{const r=o==null?void 0:o.reduce((a,i,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(m=>m[i]).filter(m=>m!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?r:[r]};var Ze=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Ze,function(){function t(c){var b=[];return c.AMapUI&&b.push(r(c.AMapUI)),c.Loca&&b.push(a(c.Loca)),Promise.all(b)}function r(c){return new Promise(function(b,u){var d=[];if(c.plugins)for(var C=0;C<c.plugins.length;C+=1)l.AMapUI.plugins.indexOf(c.plugins[C])==-1&&d.push(c.plugins[C]);if(m.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,C=l.AMapUI.version;var L=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+C+"/main.js",K.onerror=function(I){m.AMapUI=i.failed,u("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,j=d.length;I<j;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},L.appendChild(K)}else m.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,j=d.length;I<j;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}b()}):b():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var j=0,Y=d.length;j<Y;j++){var U=d[j].split("/").slice(-1)[0];window.AMapUI[U]=arguments[j]}b()}):b()})})}function a(c){return new Promise(function(b,u){if(m.Loca===i.failed)u("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,C=l.AMap.version.startsWith("2"),L=d.startsWith("2");if(C&&!L||!C&&L)u("JSAPI 与 Loca 版本不对应!!");else{C=l.key,L=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+C,K.onerror=function(I){m.Loca=i.failed,u("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=i.loaded,b();v.Loca.length;)v.Loca.splice(0,1)[0]()},L.appendChild(K)}}else m.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):v.Loca.push(function(I){I?u(I):u()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]},A=[],M=function(c){typeof c=="function"&&(m.AMap===i.loaded?c(window.AMap):A.push(c))};return{load:function(c){return new Promise(function(b,u){if(m.AMap==i.failed)u("");else if(m.AMap==i.notload){var d=c.key,C=c.version,L=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=C||l.AMap.version,l.AMap.plugins=L||l.AMap.plugins,m.AMap=i.loading,C=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=i.failed,u(I);else for(m.AMap=i.loaded,t(c).then(function(){b(window.AMap)}).catch(u);A.length;)A.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),L.onerror=function(I){m.AMap=i.failed,u(I)},C.appendChild(L)):u("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(C=0;C<c.plugins.length;C+=1)l.AMap.plugins.indexOf(c.plugins[C])==-1&&d.push(c.plugins[C]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var K=[];if(c.plugins)for(C=0;C<c.plugins.length;C+=1)l.AMap.plugins.indexOf(c.plugins[C])==-1&&K.push(c.plugins[C]);M(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(window.AMap)}).catch(u)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Ee);var He=Ee.exports;const Qe=Xe(He),De="map-configuration",ve=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Ae=e=>{const o=h.useMemo(()=>{const r=sessionStorage.getItem(ve(e));return r&&JSON.parse(r)},[e]),{data:t}=s.useRequest({resource:De,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(ve(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},$e=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{a.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=V.useDebounceFn(A=>{a.current&&a.current.search(A||" ",(M,c)=>{if(M==="complete")l(c.poiList.pois.map(b=>X(F({},b),{label:`${b.name}-${b.address}`,value:b.id})));else{if(M==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=A=>{const M=i.find(c=>c.value===A);M!=null&&M.location&&t(M.location)};return n.jsx("div",{className:s.css`
|
|
11
11
|
position: absolute;
|
|
12
12
|
top: 10px;
|
|
13
13
|
left: 10px;
|
|
14
14
|
z-index: 10;
|
|
15
15
|
width: calc(100% - 20px);
|
|
16
|
-
`,children:
|
|
16
|
+
`,children:n.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i,popupMatchSelectWidth:!1})})},Me={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},Ce=h.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:r}=Ae(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:m,disabled:v=l,zoom:A=13,overlayCommonOptions:M}=e,{t:c}=J(),b=G.useFieldSchema(),u=h.useRef(),d=h.useRef(),C=h.useRef(),[L,K]=h.useState([]),[I,j]=h.useState(""),{getField:Y}=s.useCollection_deprecated(),U=h.useMemo(()=>{if(e.type)return e.type;const f=Y(b==null?void 0:b.name);return f==null?void 0:f.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),z=h.useRef(),B=h.useRef(null),ee=le.useNavigate(),H=h.useRef(`nocobase-map-${U||""}-${Date.now().toString(32)}`),{modal:te}=w.App.useApp(),[Z]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},M)),se=V.useMemoizedFn(()=>{z.current&&z.current.remove()}),oe=V.useMemoizedFn(()=>{(!v||l)&&U!=="point"&&B.current&&(B.current.setTarget(z.current),B.current.open())}),P=V.useMemoizedFn((f,p=!1)=>{let g=null;if(U==="point"){const{lat:x,lng:N}=f.getPosition();g=[N,x]}else if(U==="polygon"||U==="lineString"){if(g=f.getPath().map(x=>[x.lng,x.lat]),g.length<2)return}else if(U==="circle"){const x=f.getCenter(),N=f.getRadius();g=[x.lng,x.lat,N]}p||(se(),z.current=f,oe()),i==null||i(g)}),W=V.useMemoizedFn((f=U)=>{const p=Me[f];if(p&&"editor"in p&&!B.current)return B.current=new u.current[p.editor](d.current,null,{createOptions:Z,editOptions:Z,controlPoint:X(F({},Z),{strokeWeight:3}),midControlPoint:X(F({},Z),{strokeWeight:2,fillColor:"#fff"})}),B.current.on("adjust",function({target:g}){P(g,!0)}),B.current.on("move",function({target:g}){P(g,!0)}),B.current}),E=V.useMemoizedFn((f=U)=>{var g;if(!C.current||(g=B.current)!=null&&g.getTarget())return;const p=Me[f];p&&C.current[p.mouseTool](F({},Z))}),$=V.useMemoizedFn((f=U)=>{C.current||(C.current=new u.current.MouseTool(d.current),C.current.on("draw",function({obj:p}){P(p)}),E(f))}),S=(f,p)=>{d.current&&d.current.setZoomAndCenter(18,f,p)},D=()=>{const f=()=>{se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)};te.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(H.current),onOk(){f()}})},y=()=>{z.current&&d.current.setFitView([z.current])},k=h.useCallback((f=U,p=a,g)=>{const x=Me[f];if(!x)return;const N=F(F({},Z),g);return"transformOptions"in x?Object.assign(N,x.transformOptions(p)):"propertyKey"in x&&(N[x.propertyKey]=p),new u.current[x.overlay](N)},[Z]),q=(f=U,p=a,g)=>{if(!u.current)return;const x=k(f,p,g);return x.setMap(d.current),x};h.useEffect(()=>{if(!u.current||!a||!m&&z.current)return;const f=q();d.current.setFitView([f]),z.current=f,v||(W(),oe())},[a,L,U,Z,v,m]),h.useEffect(()=>{var f,p,g;C.current&&(v?((f=C.current)==null||f.close(),(p=B.current)==null||p.close()):(E(),(g=B.current)==null||g.open()))},[v]),h.useEffect(()=>{!u.current||!U||v||($(),W())},[v,L,U]),h.useEffect(()=>{var p,g;if(!a&&(C.current||B.current)&&(se(),B.current&&(B.current.setTarget(),B.current.close()),i==null||i(null)),!C.current||!B.current)return;B.current.getTarget()?(g=(p=C.current).close)==null||g.call(p):E()},[U,a]),h.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const f=window.define;return window.define=void 0,Qe.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(p=>(window.define=f,requestIdleCallback(()=>{d.current=new p.Map(H.current,{resizeEnable:!0,zoom:A}),u.current=p,j(""),K([])}))).catch(p=>{typeof p=="string"?p.includes("多个不一致的 key")?j(c("The AccessKey is incorrect, please check it")):j(p):(p==null?void 0:p.type)==="error"&&j("Something went wrong, please refresh the page and try again")}),()=>{var p;(p=d.current)==null||p.destroy(),u.current=null,d.current=null,C.current=null,B.current=null}},[t,U,r]),h.useImperativeHandle(o,()=>({setOverlay:q,getOverlay:k,createMouseTool:$,createEditor:W,executeMouseTool:E,aMap:u.current,map:d.current,overlay:z.current,mouseTool:()=>C.current,editor:()=>B.current,errMessage:I}));const _=s.useApp();return!t||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>ee(_.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):n.jsxs("div",{className:s.css`
|
|
17
17
|
position: relative;
|
|
18
18
|
height: 500px;
|
|
19
|
-
`,id:H.current,style:e==null?void 0:e.style,children:[!u.current&&
|
|
19
|
+
`,id:H.current,style:e==null?void 0:e.style,children:[!u.current&&n.jsx("div",{className:s.css`
|
|
20
20
|
position: absolute;
|
|
21
21
|
inset: 0;
|
|
22
22
|
display: flex;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
25
|
-
`,children:
|
|
25
|
+
`,children:n.jsx(w.Spin,{})}),v?null:n.jsxs(n.Fragment,{children:[n.jsx($e,{toCenter:S,aMap:u.current}),n.jsx("div",{className:s.css`
|
|
26
26
|
position: absolute;
|
|
27
27
|
bottom: 80px;
|
|
28
28
|
right: 20px;
|
|
29
29
|
z-index: 10;
|
|
30
|
-
`,children:
|
|
30
|
+
`,children:n.jsx(w.Button,{onClick:y,disabled:!z.current,type:"primary",shape:"round",size:"large",icon:n.jsx(R.SyncOutlined,{})})}),U!=="point"?n.jsx("div",{className:s.css`
|
|
31
31
|
position: absolute;
|
|
32
32
|
bottom: 20px;
|
|
33
33
|
left: 10px;
|
|
34
34
|
z-index: 2;
|
|
35
35
|
pointer-events: none;
|
|
36
|
-
`,children:
|
|
36
|
+
`,children:n.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
|
|
37
37
|
position: absolute;
|
|
38
38
|
bottom: 20px;
|
|
39
39
|
right: 20px;
|
|
40
40
|
z-index: 2;
|
|
41
|
-
`,children:
|
|
41
|
+
`,children:n.jsx(w.Button,{disabled:!a,style:{height:"40px"},onClick:D,type:"primary",danger:!0,children:c("Clear")})})]})]})});Ce.displayName="AMapComponent";const Re=e=>{var P,W,E,$;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:m}=s.useProps(e),{name:v,getPrimaryKey:A}=s.useCollection_deprecated(),{getCollectionJoinField:M}=s.useCollectionManager_deprecated(),c=A(),[b,u]=h.useState(!1),d=h.useRef(),C=(W=(P=d.current)==null?void 0:P.aMap)==null?void 0:W.GeometryUtil,[L,K]=h.useState(),[I,j]=h.useState(""),{t:Y}=J(),U=s.useCompile(),{isConnected:z,doFilter:B}=s.useFilterAPI(),[,ee]=h.useState(null),H=h.useRef(I);H.current=I;const te=(S,D)=>{const y=S.getExtData(),k=typeof D=="undefined"?y.selected:!D;y.selected=!k,"setIcon"in S&&S.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:k?ue:be})),S.setOptions(F({extData:y},k?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},Z=()=>{var S,D,y;d.current&&((S=d.current)==null||S.mouseTool().close(!0),(D=d.current)==null||D.editor().setTarget(null),(y=d.current)==null||y.editor().close())};h.useEffect(()=>{var S,D,y,k;if(I==="selection")return(S=d.current)!=null&&S.editor()?(k=d.current)==null||k.executeMouseTool("polygon"):((D=d.current)==null||D.createEditor("polygon"),(y=d.current)==null||y.createMouseTool("polygon")),()=>{Z()}},[I]),h.useEffect(()=>{if(I)return()=>{var S;H.current||(S=d.current)==null||S.map.getAllOverlays().forEach(D=>{te(D,!1)})}},[I]);const se=V.useMemoizedFn(()=>{var q,_,f;const S=(q=d.current)==null?void 0:q.editor().getTarget(),D=(_=d.current)==null?void 0:_.map.getAllOverlays(),y=D==null?void 0:D.filter(p=>{if(!(p===S||p.getExtData().id===void 0))return"getPosition"in p?C.isPointInRing(p.getPosition(),S==null?void 0:S.getPath()):C.doesRingRingIntersect(p.getPath(),S==null?void 0:S.getPath())}),k=y==null?void 0:y.map(p=>(te(p,!0),p.getExtData().id));l(p=>k==null?void 0:k.concat(p)),S==null||S.remove(),(f=d.current)==null||f.editor().close()});h.useEffect(()=>{var q,_,f;if(!o||!d.current||!r)return;const S=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,D=M([v,...S].flat().join(".")),y=r.map(p=>{var x;const g=(x=Oe(p,t==null?void 0:t.field,D==null?void 0:D.interface))==null?void 0:x.filter(Boolean);return g!=null&&g.length?g.map(N=>{var ie;return(ie=d.current)==null?void 0:ie.setOverlay(o.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?U(p[t.marker]):void 0},extData:{id:p[c]}})}):[]}).flat().filter(Boolean);(_=(q=d.current)==null?void 0:q.map)==null||_.setFitView(y);const k=y.map(p=>{const g=x=>{const N=x.target,re=N.getExtData();if(!re)return;if(H.current){H.current==="click"&&(l(ae=>re.selected?ae.filter(Ie=>Ie!==re.id):[...ae,re.id]),te(N));return}const ie=r.find(ae=>re.id===ae[c]);if(z){ee(ae=>(ae&&Le(ae),ae===p?(Le(p),B(null),null):(tt(p),B(ie[c],Ie=>Ie.field||c,"$eq"),p)));return}ie&&K(ie)};return p.on("click",g),()=>p.off("click",g)});if(o.type==="point"&&(m!=null&&m.length)&&(y==null?void 0:y.length)>1){const p=y.map(x=>x.getPosition());y[0].setzIndex(13),y[y.length-1].setzIndex(13);const g=(x=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:Y(x?"Start point":"End point")},position:p[x?0:p.length-1],map:(re=d.current)==null?void 0:re.map})};y.push(...[(f=d.current)==null?void 0:f.setOverlay("lineString",p,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),g(),g(!1)].filter(Boolean))}return()=>{y.forEach(p=>{p.remove()}),k.forEach(p=>p())}},[r,b,t,v,c,o.type,z,m]),h.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=S=>{d.current=S,u(!!(S!=null&&S.map)&&!S.errMessage)};return n.jsxs("div",{className:s.css`
|
|
42
42
|
position: relative;
|
|
43
43
|
height: 100%;
|
|
44
|
-
`,children:[
|
|
44
|
+
`,children:[n.jsx("div",{className:s.css`
|
|
45
45
|
position: absolute;
|
|
46
46
|
left: 10px;
|
|
47
47
|
top: 10px;
|
|
48
48
|
z-index: 999;
|
|
49
|
-
`,children:b&&!((E=d.current)!=null&&E.errMessage)?
|
|
49
|
+
`,children:b&&!((E=d.current)!=null&&E.errMessage)?n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),j("")},icon:n.jsx(R.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),j("selection")},icon:n.jsx(R.ExpandOutlined,{})}),I==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(R.CheckOutlined,{}),title:Y("Confirm selection"),onClick:se}):null]}):null}),n.jsx(et,{record:L,setVisible:K}),n.jsx(Ce,X(F({},($=o==null?void 0:o.uiSchema)==null?void 0:$["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},et=e=>{const{setVisible:o,record:t}=e,{t:r}=J(),a=s.useCollection(),i=s.useCollectionParentRecordData(),l=G.useFieldSchema(),m=h.useMemo(()=>l.reduceProperties((v,A)=>A.name==="drawer"?A:v,null),[l]);return m&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(s.RecordProvider,{record:t,parent:i,children:n.jsx(s.DeclareVariable,{name:"$nPopupRecord",title:r("Current popup record"),value:t,collection:a,children:n.jsx(G.RecursionField,{schema:m,name:m.name})})})})};function Le(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function tt(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Te=({type:e,children:o})=>{const{t}=J(),[r,a]=V.useBoolean(!1),i=s.useAPIClient(),[l]=w.Form.useForm(),m=Ae(e);h.useEffect(()=>{m&&(l.setFieldsValue(m),a.toggle())},[m]);const v=h.useMemo(()=>i.resource(De),[i]),A=M=>{v.set(X(F({},M),{type:e})).then(c=>{sessionStorage.removeItem(ve(e)),a.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return n.jsxs(w.Form,{disabled:r,form:l,layout:"vertical",onFinish:A,children:[o,r?n.jsx(w.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):n.jsx(w.Form.Item,{children:n.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},ot={amap:()=>{const{t:e}=J();return n.jsxs(Te,{type:"amap",children:[n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:n.jsx(w.Input,{})}),n.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:n.jsx(w.Input,{})})]})},google:()=>{const{t:e}=J();return n.jsx(Te,{type:"google",children:n.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:n.jsx(w.Input,{})})})}},rt=Fe.map(e=>X(F({},e),{component:ot[e.value]})),nt=()=>{const e=s.useCompile(),o=le.useLocation(),t=new URLSearchParams(o.search);return n.jsx(w.Card,{bordered:!0,children:n.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:rt.map(r=>n.jsx(w.Tabs.TabPane,{tab:e(r.label),children:n.jsx(r.component,{type:r.value})},r.value))})})};/*! *****************************************************************************
|
|
50
50
|
Copyright (c) Microsoft Corporation.
|
|
51
51
|
|
|
52
52
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -59,62 +59,62 @@
|
|
|
59
59
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
60
60
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
61
61
|
PERFORMANCE OF THIS SOFTWARE.
|
|
62
|
-
***************************************************************************** */function
|
|
62
|
+
***************************************************************************** */function st(e,o,t,r){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function m(M){try{A(r.next(M))}catch(c){l(c)}}function v(M){try{A(r.throw(M))}catch(c){l(c)}}function A(M){M.done?i(M.value):a(M.value).then(m,v)}A((r=r.apply(e,o||[])).next())})}var it=function e(o,t){if(o===t)return!0;if(o&&t&&typeof o=="object"&&typeof t=="object"){if(o.constructor!==t.constructor)return!1;var r,a,i;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(a=r;a--!==0;)if(!e(o[a],t[a]))return!1;return!0}if(o.constructor===RegExp)return o.source===t.source&&o.flags===t.flags;if(o.valueOf!==Object.prototype.valueOf)return o.valueOf()===t.valueOf();if(o.toString!==Object.prototype.toString)return o.toString()===t.toString();if(i=Object.keys(o),r=i.length,r!==Object.keys(t).length)return!1;for(a=r;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=r;a--!==0;){var l=i[a];if(!e(o[l],t[l]))return!1}return!0}return o!==o&&t!==t};const ze="__googleMapsScriptId";var de;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(de||(de={}));class ce{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:a,id:i=ze,language:l,libraries:m=[],mapIds:v,nonce:A,region:M,retries:c=3,url:b="https://maps.googleapis.com/maps/api/js",version:u}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=r,this.client=a,this.id=i||ze,this.language=l,this.libraries=m,this.mapIds=v,this.nonce=A,this.region=M,this.retries=c,this.url=b,this.version=u,ce.instance){if(!it(this.options,ce.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ce.instance.options)}`);return ce.instance}ce.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?de.FAILURE:this.done?de.SUCCESS:this.loading?de.LOADING:de.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let o=this.url;return o+="?callback=__googleMapsCallback",this.apiKey&&(o+=`&key=${this.apiKey}`),this.channel&&(o+=`&channel=${this.channel}`),this.client&&(o+=`&client=${this.client}`),this.libraries.length>0&&(o+=`&libraries=${this.libraries.join(",")}`),this.language&&(o+=`&language=${this.language}`),this.region&&(o+=`®ion=${this.region}`),this.version&&(o+=`&v=${this.version}`),this.mapIds&&(o+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(o+=`&auth_referrer_policy=${this.authReferrerPolicy}`),o}deleteScript(){const o=document.getElementById(this.id);o&&o.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((o,t)=>{this.loadCallback(r=>{r?t(r.error):o(window.google)})})}importLibrary(o){return this.execute(),google.maps.importLibrary(o)}loadCallback(o){this.callbacks.push(o),this.execute()}setScript(){var o,t;if(document.getElementById(this.id)){this.callback();return}const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach(i=>!r[i]&&delete r[i]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,m,v,A="The Google Maps JavaScript API",M="google",c="importLibrary",b="__ib__",u=document,d=window;d=d[M]||(d[M]={});const C=d.maps||(d.maps={}),L=new Set,K=new URLSearchParams,I=()=>l||(l=new Promise((j,Y)=>st(this,void 0,void 0,function*(){var U;yield m=u.createElement("script"),m.id=this.id,K.set("libraries",[...L]+"");for(v in i)K.set(v.replace(/[A-Z]/g,z=>"_"+z[0].toLowerCase()),i[v]);K.set("callback",M+".maps."+b),m.src=this.url+"?"+K,C[b]=j,m.onerror=()=>l=Y(Error(A+" could not load.")),m.nonce=this.nonce||((U=u.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",u.head.append(m)})));C[c]?console.warn(A+" only loads once. Ignoring:",i):C[c]=(j,...Y)=>L.add(j)&&I().then(()=>C[c](j,...Y))})(r);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(o){if(this.errors.push(o),this.errors.length<=this.retries){const t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=o,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(o=>{o(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}}const at=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{google.maps.importLibrary("places").then(A=>{a.current=new A.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:m}=V.useDebounceFn(A=>{a.current&&a.current.getPlacePredictions({input:A||" "},(M,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(M.map(b=>{const u=b.structured_formatting;return X(F({},b),{label:`${u.main_text}${u.secondary_text?" "+u.secondary_text:""}`,value:b.place_id})}));else{l([]);return}})},{wait:300}),v=A=>{const M=i.find(b=>b.value===A);new google.maps.places.PlacesService(t.current).getDetails({placeId:M.place_id,fields:["geometry"]},(b,u)=>{u===google.maps.places.PlacesServiceStatus.OK&&o(b.geometry.location)})};return n.jsx("div",{className:s.css`
|
|
63
63
|
position: absolute;
|
|
64
64
|
top: 10px;
|
|
65
65
|
left: 10px;
|
|
66
66
|
z-index: 10;
|
|
67
67
|
width: calc(100% - 20px);
|
|
68
|
-
`,children:
|
|
68
|
+
`,children:n.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),lt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:a}=t.coords;e({lat:r,lng:a})},()=>{o()}):o()}),ct=e=>e==="point"?"marker":e==="lineString"?"polyline":e,pt={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},xe=h.forwardRef((e,o)=>{const{value:t,onChange:r,block:a=!1,readonly:i,disabled:l=a,zoom:m=13,overlayCommonOptions:v}=e,{accessKey:A}=Ae(e.mapType)||{},{t:M}=J(),{getField:c}=s.useCollection_deprecated(),b=G.useFieldSchema(),u=h.useRef(),d=h.useRef(),C=h.useRef(),[L,K]=h.useState([]),[I,j]=h.useState(""),Y=s.useAPIClient(),{modal:U}=w.App.useApp(),z=h.useMemo(()=>{if(e.type)return e.type;const f=c(b==null?void 0:b.name);return f==null?void 0:f.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),B=h.useRef(ct(z)),[ee]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},v)),H=le.useNavigate(),te=h.useRef(),Z=h.useRef(new Set),se=V.useMemoizedFn(f=>{if(Z.current.forEach(p=>{Z.current.delete(p)}),"getPath"in f){const p=f.getPath();["insert_at","remove_at","set_at"].forEach(g=>{Z.current.add(p.addListener(g,()=>{S(f,!0)}).remove)})}else f instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(p=>{Z.current.add(f.addListener(p,()=>{S(f,!0)}).remove)})}),oe=V.useMemoizedFn(()=>{var f;C.current&&(C.current.unbindAll(),C.current.setMap(null)),z!=="point"&&((f=u.current)==null||f.setDrawingMode(null))}),P=V.useMemoizedFn(f=>{d.current&&(d.current.setCenter(f),d.current.setZoom(m))}),W=V.useMemoizedFn(f=>{oe(),se(f),C.current=f}),E=V.useMemoizedFn(f=>{const p=new google.maps.LatLngBounds;f.forEach(g=>{if(g instanceof google.maps.Marker)p.extend(g.getPosition());else if(g instanceof google.maps.Polyline||g instanceof google.maps.Polygon){const x=g.getPath();for(let N=0;N<x.getLength();N++)p.extend(x.getAt(N))}else g instanceof google.maps.Circle&&p.union(g.getBounds())}),d.current.setCenter(p.getCenter())}),$=()=>{C.current&&E([C.current])},S=V.useMemoizedFn((f,p=!1)=>{let g=null;if(z==="point"){const{lat:x,lng:N}=f.getPosition();g=[N(),x()]}else if(z==="polygon"||z==="lineString"){if(g=f.getPath().getArray().map(x=>[x.lng(),x.lat()]),g.length<2)return}else if(z==="circle"){const x=f.getCenter(),N=f.getRadius();g=[x.lng(),x.lat(),N]}p||W(f),r==null||r(g)}),D=V.useMemoizedFn((f=!1,p)=>{const g=X(F(F({},ee),p),{map:d.current});return u.current=new google.maps.drawing.DrawingManager({drawingMode:B.current,drawingControl:!1,markerOptions:X(F({},g),{icon:pe(ue)}),polygonOptions:g,polylineOptions:g,circleOptions:g,map:d.current}),f||u.current.addListener("overlaycomplete",x=>{const N=x.overlay;S(N)}),u.current}),y=V.useMemoizedFn((f=z,p=t,g)=>{const x=pt[f];if(!x)return;const N=F(X(F({},ee),{icon:pe(ue)}),g);return"transformOptions"in x?Object.assign(N,x.transformOptions(p)):"propertyKey"in x&&(N[x.propertyKey]=Array.isArray(p[0])?p.map(ie=>new google.maps.LatLng(ie[1],ie[0])):new google.maps.LatLng(p[1],p[0])),new google.maps[x.overlay](N)}),k=V.useMemoizedFn((f=z,p=t,g)=>d.current?y(f,p,X(F({},g),{map:d.current})):void 0);h.useEffect(()=>{var p,g;if(!t&&d.current&&(oe(),(g=(p=u==null?void 0:u.current)==null?void 0:p.setDrawingMode)==null||g.call(p,B.current),r==null||r(null)),!d.current||!t||!i&&C.current)return;const f=k();W(f),E([f])},[t,L,z,l,i,k,E,W]),h.useEffect(()=>{if(!A||d.current||!te.current)return;let f;try{f=new ce({apiKey:A,version:"weekly",language:Y.auth.getLocale()})}catch(g){j(M("Load google maps failed, Please check the Api key and refresh the page"));return}const p=console.error;return console.error=(g,...x)=>{g!=null&&g.includes("InvalidKeyMapError")&&j(M("Load google maps failed, Please check the Api key and refresh the page")),p(g,...x)},Promise.all([f.importLibrary("drawing"),f.importLibrary("core"),f.importLibrary("geometry")]).then(g=>ye(this,null,function*(){const x=yield lt();d.current=new google.maps.Map(te.current,{zoom:m,center:x,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),j(""),K([])})).catch(g=>{if(g instanceof Error){j(g.message);return}}),()=>{var g,x;(g=d.current)==null||g.unbindAll(),d.current=null,(x=u.current)==null||x.unbindAll()}},[A,Y.auth,z,m]),h.useEffect(()=>{!d.current||!z||l||u.current||D()},[D,l,L,z]),h.useImperativeHandle(o,()=>({setOverlay:k,getOverlay:y,setFitView:E,createDraw:D,map:d.current,overlay:C.current,drawingManager:u.current,errMessage:I}));const q=V.useMemoizedFn(()=>{const f=()=>{oe(),u.current.setDrawingMode(B.current),r==null||r(null)};U.confirm({title:M("Clear the canvas"),content:M("Are you sure to clear the canvas?"),okText:M("Confirm"),cancelText:M("Cancel"),getContainer:()=>te.current,onOk(){f()}})}),_=s.useApp();return!A||I?n.jsx(w.Alert,{action:n.jsx(w.Button,{type:"primary",onClick:()=>H(_.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:M("Go to the configuration page")}),message:I||M("Please configure the Api key first"),type:"error"}):n.jsxs("div",{className:s.css`
|
|
69
69
|
position: relative;
|
|
70
70
|
height: 500px;
|
|
71
|
-
`,children:[!d.current&&
|
|
71
|
+
`,children:[!d.current&&n.jsx("div",{className:s.css`
|
|
72
72
|
position: absolute;
|
|
73
73
|
inset: 0;
|
|
74
74
|
display: flex;
|
|
75
75
|
align-items: center;
|
|
76
76
|
justify-content: center;
|
|
77
|
-
`,children:
|
|
77
|
+
`,children:n.jsx(w.Spin,{})}),l?null:n.jsxs(n.Fragment,{children:[d.current&&n.jsx(at,{toCenter:P,mapRef:d}),n.jsx("div",{className:s.css`
|
|
78
78
|
position: absolute;
|
|
79
79
|
bottom: 80px;
|
|
80
80
|
right: 20px;
|
|
81
81
|
z-index: 10;
|
|
82
|
-
`,children:
|
|
82
|
+
`,children:n.jsx(w.Button,{onClick:$,disabled:!C.current,type:"primary",shape:"round",size:"large",icon:n.jsx(R.SyncOutlined,{})})}),z==="lineString"||z==="polygon"?n.jsx("div",{className:s.css`
|
|
83
83
|
position: absolute;
|
|
84
84
|
bottom: 20px;
|
|
85
85
|
left: 10px;
|
|
86
86
|
z-index: 2;
|
|
87
87
|
pointer-events: none;
|
|
88
|
-
`,children:
|
|
88
|
+
`,children:n.jsx(w.Alert,{message:M("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,n.jsx("div",{className:s.css`
|
|
89
89
|
position: absolute;
|
|
90
90
|
bottom: 20px;
|
|
91
91
|
right: 20px;
|
|
92
92
|
z-index: 2;
|
|
93
|
-
`,children:
|
|
93
|
+
`,children:n.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:q,type:"primary",danger:!0,children:M("Clear")})})]}),n.jsx("div",{ref:te,className:s.css`
|
|
94
94
|
width: 100%;
|
|
95
95
|
height: 100%;
|
|
96
|
-
`,style:e==null?void 0:e.style})]})});xe.displayName="GoogleMapsComponent";const me="google-maps-overlay-id",Be="google-maps-overlay-selected",
|
|
96
|
+
`,style:e==null?void 0:e.style})]})});xe.displayName="GoogleMapsComponent";const me="google-maps-overlay-id",Be="google-maps-overlay-selected",ut=s.css`
|
|
97
97
|
margin-top: 6px;
|
|
98
98
|
padding: 2px 4px;
|
|
99
99
|
background: #fff;
|
|
100
100
|
border: 1px solid #0000f5;
|
|
101
|
-
`,
|
|
101
|
+
`,dt=s.css`
|
|
102
102
|
margin-top: -64px;
|
|
103
103
|
padding: 2px 4px;
|
|
104
104
|
background: #fff;
|
|
105
105
|
border: 1px solid #0000f5;
|
|
106
|
-
`,
|
|
106
|
+
`,ft=e=>{const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:m}=s.useProps(e),{getPrimaryKey:v}=s.useCollection_deprecated(),A=v(),{marker:M="id"}=t,[c,b]=h.useState(!1),u=h.useRef(),[d,C]=h.useState(),[L,K]=h.useState(""),{t:I}=J(),j=s.useCompile(),{isConnected:Y,doFilter:U}=s.useFilterAPI(),[,z]=h.useState(null),B=h.useRef(L),ee=h.useRef(null),H=h.useRef([]);B.current=L;const{getCollectionJoinField:te}=s.useCollectionManager_deprecated(),Z=(P,W)=>{const E=typeof W!="undefined"?!W:P.get(Be);P.set(Be,!E),P.setOptions(F({},E?{icon:pe(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:pe(be),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var W,E,$,S;if(L!=="selection")return;u.current&&!((W=u.current)!=null&&W.drawingManager)&&(u.current.drawingManager=(E=u.current)==null?void 0:E.createDraw(!0,{editable:!0,draggable:!0}));const P=new Set;return($=u.current)==null||$.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=u.current)==null||S.drawingManager.addListener("overlaycomplete",D=>{var q;const y=D.overlay;(q=u.current)==null||q.drawingManager.setDrawingMode(null),ee.current=y;const k=y.getPath();["insert_at","remove_at","set_at"].forEach(_=>{P.add(k.addListener(_,()=>{}).remove)})}),()=>{var D,y,k,q;P.forEach(_=>{_()}),u.current&&((D=ee.current)==null||D.unbindAll(),(y=ee.current)==null||y.setMap(null),ee.current=null,(k=u.current)==null||k.drawingManager.setDrawingMode(null),(q=u.current)==null||q.drawingManager.unbindAll())}},[L]),h.useEffect(()=>{if(L)return()=>{B.current||H.current.forEach(P=>{Z(P,!1)})}},[L]);const se=V.useMemoizedFn(()=>{var D;const P=ee.current,W=H.current,E=google.maps.geometry.poly,S=W.filter(y=>{if(!(y===P||y.get(me)===void 0))return y instanceof google.maps.Marker?E.containsLocation(y.getPosition(),P):y instanceof google.maps.Circle?E.containsLocation(y.getCenter(),P):y.getPath().getArray().some(k=>E.containsLocation(k,P))}).map(y=>(Z(y,!0),y.get(me)));l(y=>S.concat(y)),P==null||P.unbindAll(),P==null||P.setMap(null),(D=u.current)==null||D.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});h.useEffect(()=>{var S,D;if(!o||!(r!=null&&r.length)||!((S=u.current)!=null&&S.map))return;const P=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,W=te([name,...P].flat().join(".")),E=r.map(y=>{const k=Oe(y,t==null?void 0:t.field,W==null?void 0:W.interface);return k!=null&&k.length?k==null?void 0:k.filter(Boolean).map(q=>{var f;if(!k)return;const _=(f=u.current)==null?void 0:f.setOverlay(o.type,q,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:ut,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?j(y[M]):void 0}});return _==null||_.set(me,y[A]),_}):[]}).flat().filter(Boolean);H.current=E;const $=E.map(y=>{const k=q=>{const _=y,f=_.get(me);if(!f)return;const p=r==null?void 0:r.find(g=>f===g[A]);if(Y){z(g=>(g&&Ke(_),g===y?(Ke(_),U(null),null):(gt(_),U(p[A],x=>x.field||A,"$eq"),_)));return}p&&C(p)};return y.addListener("click",k),()=>y.unbindAll()});if(o.type==="point"&&(m!=null&&m.length)&&(E==null?void 0:E.length)>1){const y=E.map(q=>q.getPosition());E[0].setZIndex(138),E[E.length-1].setZIndex(138);const k=(q=!0)=>{var _;if((_=u.current)!=null&&_.map)return new google.maps.Marker({label:{className:dt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(q?"Start point":"End point")},icon:pe(ue),position:q?y[0]:y[y.length-1],map:u.current.map})};E.push(...[u.current.setOverlay("lineString",y.map(q=>[q.lng(),q.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),k(),k(!1)].filter(Boolean))}return(D=u.current)==null||D.setFitView(E),()=>{E.forEach(y=>{y.setMap(null),y.unbindAll()}),$.forEach(y=>y())}},[r,c,M,o.type,Y]),h.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=P=>{u.current=P,b(!!(P!=null&&P.map)&&!P.errMessage)};return n.jsxs("div",{className:s.css`
|
|
107
107
|
position: relative;
|
|
108
108
|
height: 100%;
|
|
109
|
-
`,children:[c&&
|
|
109
|
+
`,children:[c&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:s.css`
|
|
110
110
|
position: absolute;
|
|
111
111
|
left: 10px;
|
|
112
112
|
top: 10px;
|
|
113
113
|
z-index: 999;
|
|
114
|
-
`,children:
|
|
114
|
+
`,children:n.jsxs(w.Space,{direction:"vertical",children:[n.jsx(w.Button,{style:{color:L?void 0:"#F18b62",borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),K("")},icon:n.jsx(R.EnvironmentOutlined,{})}),n.jsx(w.Button,{style:{color:L==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),K("selection")},icon:n.jsx(R.ExpandOutlined,{})}),L==="selection"?n.jsx(w.Button,{type:"primary",icon:n.jsx(R.CheckOutlined,{}),title:I("Confirm selection"),onClick:se}):null]})}),n.jsx(mt,{record:d,setVisible:C})]}),n.jsx(xe,X(F({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},mt=e=>{const{setVisible:o,record:t}=e,{t:r}=J(),a=s.useCollection(),i=s.useCollectionParentRecordData(),l=G.useFieldSchema(),m=h.useMemo(()=>l.reduceProperties((v,A)=>A.name==="drawer"?A:v,null),[l]);return m&&n.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:n.jsx(s.RecordProvider,{record:t,parent:i,children:n.jsx(s.DeclareVariable,{name:"$nPopupRecord",title:r("Current popup record"),value:t,collection:a,children:n.jsx(G.RecursionField,{schema:m,name:m.name})})})})};function Ke(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function gt(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(be));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const ht=()=>{var c;const{getCollectionJoinField:e}=s.useCollectionManager_deprecated(),{getField:o}=s.useCollection_deprecated(),{form:t}=s.useFormBlockContext(),r=G.useField(),a=G.useFieldSchema(),{t:i}=J(),{dn:l,refresh:m}=s.useDesignable(),v=o(a.name)||e(a["x-collection-field"]),A=(c=v==null?void 0:v.uiSchema)==null?void 0:c.title;r.title===A||r.title,r.readPretty||r.required;let M="editable";return a["x-disabled"]===!0&&(M="readonly"),a["x-read-pretty"]===!0&&(M="read-pretty"),n.jsxs(s.GeneralSchemaDesigner,{children:[n.jsx(s.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!s.isPatternDisabled(a)&&n.jsx(s.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:M,onChange:b=>{const u={"x-uid":a["x-uid"]};switch(b){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,u["x-read-pretty"]=!1,u["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,u["x-read-pretty"]=!0,u["x-disabled"]=!1,r.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,u["x-read-pretty"]=!1,u["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}l.emit("patch",{schema:u}),l.refresh()}},"pattern"),n.jsx(s.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:r.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:b})=>{b&&(ke.set(a,"x-component-props.zoom",b),Object.assign(r.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":r.componentProps}})),l.refresh()}},"map-zoom"),n.jsx(s.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},yt={amap:Ce,google:xe},Se=h.forwardRef((e,o)=>{const{t}=J(),{mapType:r}=e,a=h.useMemo(()=>yt[r],[r]);return a?n.jsx(a,F({ref:o},e)):n.jsx("div",{children:t(`The ${r} cannot found`)})});Se.displayName="MapComponent";const bt=e=>{var m,v;const{value:o}=e,t=G.useFieldSchema(),{getField:r}=s.useCollection_deprecated(),a=r(t.name),i=e.mapType||((m=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:m.mapType),l=G.useForm();return s.useFieldTitle(),l.readPretty?n.jsx(Se,F({readonly:!0,mapType:i},e)):n.jsx("div",{children:n.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,A=>Array.isArray(A)?`(${A.join(",")})`:A).join(",")})})},Ue=G.connect(e=>n.jsx("div",{className:s.css`
|
|
115
115
|
height: 100%;
|
|
116
116
|
border: 1px solid transparent;
|
|
117
117
|
.ant-formily-item-error & {
|
|
118
118
|
border: 1px solid #ff4d4f;
|
|
119
119
|
}
|
|
120
|
-
`,children:s.jsx(Se,O({},e))}),G.mapReadPretty(yt));Ue.Designer=gt;const bt={amap:$e,google:dt},vt=e=>{const{t:o}=J(),{mapType:t}=e,r=h.useMemo(()=>bt[t],[t]);return r?s.jsx(r,O({},e)):s.jsx("div",{children:o(`The ${t} cannot found`)})},At=n.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=n.useProps(e),{getCollectionJoinField:t}=n.useCollectionManager_deprecated(),{name:r}=n.useCollection_deprecated(),a=h.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return s.jsx(vt,X(O(O({},i),e),{collectionField:a}))}),Ct=()=>{const{name:e,title:o}=n.useCollection(),t=n.useSchemaTemplate();return s.jsx(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ne=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,a)=>{const i=t==null?void 0:t.find(l=>l.value===r);return a===e.length-1?i:i==null?void 0:i.children},o)),Mt=e=>{const{collectionName:o,fieldNames:t,dataSource:r}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:r,action:"list",fieldNames:t,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}}},[Ye.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},xt=()=>{const e=n.useSchemaInitializerItem(),{insert:o}=n.useSchemaInitializer(),t=h.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=n.useCollectionManager_deprecated(),{t:a}=J(),{theme:i}=n.useGlobalTheme();return s.jsx(n.DataBlockInitializer,O({componentType:"Map",icon:s.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>ye(this,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),A=r(l.name,"string",{dataSource:l.dataSource}),C=yield n.FormDialog(a("Create map block"),()=>{var c;return s.jsx(n.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:s.jsx(We.FormLayout,{layout:"vertical",children:s.jsx(n.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(b=>b!=null):[]},marker:{title:a("Marker field"),enum:A,"x-component":"Select","x-decorator":"FormItem","x-reactions":b=>{const u=b.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,v);d&&(b.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(Mt({collectionName:l.name,dataSource:l.dataSource,fieldNames:O({},C)}))}),title:a("Map block")},e))},we=h.createContext({});we.displayName="MapBlockContext";const St=e=>{var v;const{fieldNames:o}=e,t=G.useFieldSchema(),r=G.useField(),{resource:a,service:i}=n.useBlockRequestContext(),[l,m]=h.useState([]);return s.jsx(n.FixedBlockWrapper,{children:s.jsx(n.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:s.jsx(we.Provider,{value:{field:r,service:i,resource:a,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},wt=e=>{const o=G.useField(),{params:t,fieldNames:r}=e,a=t.appends||[],{field:i}=r||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),s.jsx(n.BlockProvider,X(O({name:"map"},e),{runWhenParamsChanged:!0,params:X(O({},t),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(St,O({},e))}))},ge=()=>h.useContext(we),Ge=()=>{var o,t,r,a,i,l;const e=ge();return X(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((a=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},It=e=>s.jsx(n.SchemaComponentOptions,{scope:{useMapBlockProps:Ge},components:{MapBlockInitializer:xt,MapBlockDesigner:Ct,MapBlockProvider:wt,MapBlock:At},children:e.children}),qe=new n.CompatibleSchemaInitializer({name:"MapActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]}),Pt=new n.CompatibleSchemaInitializer({name:"map:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]},qe),kt=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:n.FixedBlockDesignerItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps(){var A;const{getCollectionFieldsOptions:e}=n.useCollectionManager_deprecated(),{t:o}=J(),t=G.useFieldSchema(),r=((A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fieldNames)||{},a=G.useField(),{dn:i}=n.useDesignable(),{service:l}=ge(),{name:m}=n.useCollection(),v=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:v,allowClear:!1,onChange:C=>{const c=a.decoratorProps.fieldNames||{};c.field=C,a.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:n.SchemaSettingsSelectItem,useComponentProps(){var A;const{t:e}=J(),o=G.useFieldSchema(),t=((A=o==null?void 0:o["x-decorator-props"])==null?void 0:A.fieldNames)||{},{service:r}=ge(),a=G.useField(),{dn:i}=n.useDesignable(),{getCollectionFieldsOptions:l}=n.useCollectionManager_deprecated(),{name:m}=n.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:C=>{const c=a.decoratorProps.fieldNames||{};c.marker=C,a.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}},useVisible(){var l,m;const e=G.useFieldSchema(),{getCollectionFieldsOptions:o}=n.useCollectionManager_deprecated(),{name:t}=n.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ne(r.field,a))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,{name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=J(),o=G.useFieldSchema(),t=G.useField(),{dn:r}=n.useDesignable(),a=((i=o==null?void 0:o["x-component-props"])==null?void 0:i.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:a,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ke.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps(){var l,m;const{name:e}=n.useCollection(),o=G.useFieldSchema(),{form:t}=n.useFormBlockContext(),r=G.useField(),{service:a}=ge(),{dn:i}=n.useDesignable();return{collectionName:e,defaultFilter:((m=(l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.params)==null?void 0:m.filter)||{},form:t,onSubmit:({filter:v})=>{var C,c;const A=r.decoratorProps.params||{};A.filter=v,r.decoratorProps.params=A,o["x-decorator-props"].params=A,(c=(C=a.params)==null?void 0:C[1])!=null&&c.filters,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:n.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps(){var r,a;const{name:e}=n.useCollection(),o=G.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ft}=n.interfacesProperties;Array.isArray(n.interfacesProperties.type.enum)&&n.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class he extends n.CollectionFieldInterface{constructor(){super(...arguments);F(this,"properties",X(O({},Ft),{"uiSchema.x-component-props.mapType":{title:Q("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:Fe}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Ot extends he{constructor(){super(...arguments);F(this,"name","circle");F(this,"type","object");F(this,"group","map");F(this,"order",3);F(this,"title",Q("Circle"));F(this,"availableTypes",["circle"]);F(this,"description",Q("Circle"));F(this,"sortable",!0);F(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Et extends he{constructor(){super(...arguments);F(this,"name","lineString");F(this,"type","object");F(this,"group","map");F(this,"order",2);F(this,"title",Q("Line"));F(this,"description",Q("Line"));F(this,"availableTypes",["lineString"]);F(this,"sortable",!0);F(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class zt extends he{constructor(){super(...arguments);F(this,"name","point");F(this,"type","object");F(this,"group","map");F(this,"order",1);F(this,"title",Q("Point"));F(this,"description",Q("Point"));F(this,"availableTypes",["point"]);F(this,"sortable",!0);F(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Lt extends he{constructor(){super(...arguments);F(this,"name","polygon");F(this,"type","object");F(this,"group","map");F(this,"order",4);F(this,"title",Q("Polygon"));F(this,"description",Q("Polygon"));F(this,"availableTypes",["polygon"]);F(this,"sortable",!0);F(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Dt=[zt,Lt,Et,Ot],_e=h.memo(e=>s.jsx(n.SchemaComponentOptions,{components:{Map:Ue},children:s.jsx(It,{children:e.children})}));_e.displayName="MapProvider";class je extends n.Plugin{load(){return ye(this,null,function*(){this.app.use(_e),this.app.dataSourceManager.addFieldInterfaces(Dt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:Q("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(qe),this.app.schemaInitializerManager.add(Pt),this.schemaSettingsManager.add(kt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:Q("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:rt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ge})})}}D.PluginMapClient=je,D.default=je,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
120
|
+
`,children:n.jsx(Se,F({},e))}),G.mapReadPretty(bt));Ue.Designer=ht;const vt={amap:Re,google:ft},At=e=>{const{t:o}=J(),{mapType:t}=e,r=h.useMemo(()=>vt[t],[t]);return r?n.jsx(r,F({},e)):n.jsx("div",{children:o(`The ${t} cannot found`)})},Mt=s.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager_deprecated(),{name:r}=s.useCollection_deprecated(),a=h.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return n.jsx(At,X(F(F({},i),e),{collectionField:a}))}),Ct=()=>{const{name:e,title:o}=s.useCollection(),t=s.useSchemaTemplate();return n.jsx(s.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ne=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,a)=>{const i=t==null?void 0:t.find(l=>l.value===r);return a===e.length-1?i:i==null?void 0:i.children},o)),xt=e=>{const{collectionName:o,fieldNames:t,dataSource:r}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:r,action:"list",fieldNames:t,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}}},[Je.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},St=()=>{const e=s.useSchemaInitializerItem(),{insert:o}=s.useSchemaInitializer(),t=h.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=s.useCollectionManager_deprecated(),{t:a}=J(),{theme:i}=s.useGlobalTheme();return n.jsx(s.DataBlockInitializer,F({componentType:"Map",icon:n.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>ye(this,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),A=r(l.name,"string",{dataSource:l.dataSource}),M=yield s.FormDialog(a("Create map block"),()=>{var c;return n.jsx(s.SchemaComponentOptions,{scope:t.scope,components:F({},t.components),children:n.jsx(Ye.FormLayout,{layout:"vertical",children:n.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(b=>b!=null):[]},marker:{title:a("Marker field"),enum:A,"x-component":"Select","x-decorator":"FormItem","x-reactions":b=>{const u=b.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,v);d&&(b.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(xt({collectionName:l.name,dataSource:l.dataSource,fieldNames:F({},M)}))}),title:a("Map block")},e))},we=h.createContext({});we.displayName="MapBlockContext";const wt=e=>{var v;const{fieldNames:o}=e,t=G.useFieldSchema(),r=G.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,m]=h.useState([]);return n.jsx(s.FixedBlockWrapper,{children:n.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:n.jsx(we.Provider,{value:{field:r,service:i,resource:a,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},It=e=>{const o=G.useField(),{params:t,fieldNames:r}=e,a=t.appends||[],{field:i}=r||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),n.jsx(s.BlockProvider,X(F({name:"map"},e),{runWhenParamsChanged:!0,params:X(F({},t),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:n.jsx(wt,F({},e))}))},ge=()=>h.useContext(we),Ge=()=>{var o,t,r,a,i,l;const e=ge();return X(F({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((a=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:a.zoom)||13,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},Pt=e=>n.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:Ge},components:{MapBlockInitializer:St,MapBlockDesigner:Ct,MapBlockProvider:It,MapBlock:Mt},children:e.children}),je={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return s.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},qe=new s.CompatibleSchemaInitializer(F({name:"MapActionInitializers"},je)),kt=new s.CompatibleSchemaInitializer(F({name:"map:configureActions"},je),qe),Ft=new s.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:s.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:s.FixedBlockDesignerItem},{name:"mapField",Component:s.SchemaSettingsCascaderItem,useComponentProps(){var A;const{getCollectionFieldsOptions:e}=s.useCollectionManager_deprecated(),{t:o}=J(),t=G.useFieldSchema(),r=((A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fieldNames)||{},a=G.useField(),{dn:i}=s.useDesignable(),{service:l}=ge(),{name:m}=s.useCollection(),v=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:v,allowClear:!1,onChange:M=>{const c=a.decoratorProps.fieldNames||{};c.field=M,a.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:s.SchemaSettingsSelectItem,useComponentProps(){var A;const{t:e}=J(),o=G.useFieldSchema(),t=((A=o==null?void 0:o["x-decorator-props"])==null?void 0:A.fieldNames)||{},{service:r}=ge(),a=G.useField(),{dn:i}=s.useDesignable(),{getCollectionFieldsOptions:l}=s.useCollectionManager_deprecated(),{name:m}=s.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:M=>{const c=a.decoratorProps.fieldNames||{};c.marker=M,a.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}},useVisible(){var l,m;const e=G.useFieldSchema(),{getCollectionFieldsOptions:o}=s.useCollectionManager_deprecated(),{name:t}=s.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ne(r.field,a))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:s.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},s.setDataLoadingModeSettingsItem,{name:"defaultZoomLevel",Component:s.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=J(),o=G.useFieldSchema(),t=G.useField(),{dn:r}=s.useDesignable(),a=((i=o==null?void 0:o["x-component-props"])==null?void 0:i.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:a,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ke.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:s.SchemaSettingsDataScope,useComponentProps(){var l,m;const{name:e}=s.useCollection(),o=G.useFieldSchema(),{form:t}=s.useFormBlockContext(),r=G.useField(),{service:a}=ge(),{dn:i}=s.useDesignable();return{collectionName:e,defaultFilter:((m=(l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.params)==null?void 0:m.filter)||{},form:t,onSubmit:({filter:v})=>{var M,c;const A=r.decoratorProps.params||{};A.filter=v,r.decoratorProps.params=A,o["x-decorator-props"].params=A,(c=(M=a.params)==null?void 0:M[1])!=null&&c.filters,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:s.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:s.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:s.SchemaSettingsTemplate,useComponentProps(){var r,a;const{name:e}=s.useCollection(),o=G.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ot}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class he extends s.CollectionFieldInterface{constructor(){super(...arguments);O(this,"properties",X(F({},Ot),{"uiSchema.x-component-props.mapType":{title:Q("Map type"),type:"string",required:!0,"x-decorator":"FormItem","x-component":"Select","x-component-props":{showSearch:!1,allowClear:!1},"x-disabled":"{{ isOverride || !createOnly }}",default:"amap",enum:Fe}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Et extends he{constructor(){super(...arguments);O(this,"name","circle");O(this,"type","object");O(this,"group","map");O(this,"order",3);O(this,"title",Q("Circle"));O(this,"availableTypes",["circle"]);O(this,"description",Q("Circle"));O(this,"sortable",!0);O(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Dt extends he{constructor(){super(...arguments);O(this,"name","lineString");O(this,"type","object");O(this,"group","map");O(this,"order",2);O(this,"title",Q("Line"));O(this,"description",Q("Line"));O(this,"availableTypes",["lineString"]);O(this,"sortable",!0);O(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Lt extends he{constructor(){super(...arguments);O(this,"name","point");O(this,"type","object");O(this,"group","map");O(this,"order",1);O(this,"title",Q("Point"));O(this,"description",Q("Point"));O(this,"availableTypes",["point"]);O(this,"sortable",!0);O(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Tt extends he{constructor(){super(...arguments);O(this,"name","polygon");O(this,"type","object");O(this,"group","map");O(this,"order",4);O(this,"title",Q("Polygon"));O(this,"description",Q("Polygon"));O(this,"availableTypes",["polygon"]);O(this,"sortable",!0);O(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const zt=[Lt,Tt,Dt,Et],_e=h.memo(e=>n.jsx(s.SchemaComponentOptions,{components:{Map:Ue},children:n.jsx(Pt,{children:e.children})}));_e.displayName="MapProvider";class Ve extends s.Plugin{load(){return ye(this,null,function*(){this.app.use(_e),this.app.dataSourceManager.addFieldInterfaces(zt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:Q("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(qe),this.app.schemaInitializerManager.add(kt),this.schemaSettingsManager.add(Ft);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:Q("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:nt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ge})})}}T.PluginMapClient=Ve,T.default=Ve,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.0.0-alpha.
|
|
11
|
+
"@nocobase/client": "1.0.0-alpha.15",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/server": "1.0.0-alpha.
|
|
14
|
-
"@nocobase/test": "1.0.0-alpha.
|
|
13
|
+
"@nocobase/server": "1.0.0-alpha.15",
|
|
14
|
+
"@nocobase/test": "1.0.0-alpha.15",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
@@ -22,6 +22,6 @@ module.exports = {
|
|
|
22
22
|
"react-router-dom": "6.21.0",
|
|
23
23
|
"@formily/core": "2.3.0",
|
|
24
24
|
"react-i18next": "11.18.6",
|
|
25
|
-
"@nocobase/actions": "1.0.0-alpha.
|
|
26
|
-
"@nocobase/database": "1.0.0-alpha.
|
|
25
|
+
"@nocobase/actions": "1.0.0-alpha.15",
|
|
26
|
+
"@nocobase/database": "1.0.0-alpha.15"
|
|
27
27
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Block: Map",
|
|
4
4
|
"displayName.zh-CN": "区块:地图",
|
|
5
|
-
"version": "1.0.0-alpha.
|
|
5
|
+
"version": "1.0.0-alpha.15",
|
|
6
6
|
"description": "Map block, support Gaode map and Google map, you can also extend more map types.",
|
|
7
7
|
"description.zh-CN": "地图区块,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@nocobase/test": "1.x",
|
|
37
37
|
"@nocobase/utils": "1.x"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "2793d371368e094ea2bba04cfbe9b9b73c44edba",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Blocks"
|
|
42
42
|
]
|