@nocobase/plugin-map 1.2.14-alpha → 1.3.0-alpha.20240710141659
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 +23 -23
- package/dist/externalVersion.js +5 -6
- 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"),require("@emotion/css")):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","@emotion/css"],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"],D["@emotion/css"]))})(this,function(D,s,n,h,R,N,q,w,ae,ce,Ee,$e,Re,et){"use strict";var Vt=Object.defineProperty,Wt=Object.defineProperties;var Yt=Object.getOwnPropertyDescriptors;var Qe=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var Oe=(D,s,n)=>s in D?Vt(D,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):D[s]=n,F=(D,s)=>{for(var n in s||(s={}))Ht.call(s,n)&&Oe(D,n,s[n]);if(Qe)for(var n of Qe(s))Jt.call(s,n)&&Oe(D,n,s[n]);return D},H=(D,s)=>Wt(D,Yt(s));var O=(D,s,n)=>(Oe(D,typeof s!="symbol"?s+"":s,n),n);var Me=(D,s,n)=>new Promise((h,R)=>{var N=ae=>{try{w(n.next(ae))}catch(ce){R(ce)}},q=ae=>{try{w(n.throw(ae))}catch(ce){R(ce)}},w=ae=>ae.done?h(ae.value):Promise.resolve(ae.value).then(N,q);w((n=n.apply(D,s)).next())});const ge="map";function X(e){return`{{t('${e}', { ns: '${ge}', nsMode: 'fallback' })}}`}function _(){return ae.useTranslation([ge,"client"],{nsMode:"fallback"})}const Le=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],Ae="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/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==",Te=(e,o,t)=>{const r=o==null?void 0:o.reduce((l,i,a)=>a===o.length-1&&(t==="o2m"||t==="m2m")?l==null?void 0:l.map(m=>m[i]).filter(m=>m!=null):l==null?void 0:l[i],e);return t==="o2m"||t==="m2m"?r:[r]};var tt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ot(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var De={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(tt,function(){function t(c){var M=[];return c.AMapUI&&M.push(r(c.AMapUI)),c.Loca&&M.push(l(c.Loca)),Promise.all(M)}function r(c){return new Promise(function(M,p){var d=[];if(c.plugins)for(var S=0;S<c.plugins.length;S+=1)a.AMapUI.plugins.indexOf(c.plugins[S])==-1&&d.push(c.plugins[S]);if(m.AMapUI===i.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,a.AMapUI.version=c.version||a.AMapUI.version,S=a.AMapUI.version;var z=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+S+"/main.js",K.onerror=function(P){m.AMapUI=i.failed,p("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var P=0,G=d.length;P<G;P++){var j=d[P].split("/").slice(-1)[0];window.AMapUI[j]=arguments[P]}for(M();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()});else for(M();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()},z.appendChild(K)}else m.AMapUI===i.loaded?c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var P=0,G=d.length;P<G;P++){var j=d[P].split("/").slice(-1)[0];window.AMapUI[j]=arguments[P]}M()}):M():c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):b.AMapUI.push(function(P){P?p(P):d.length?window.AMapUI.loadUI(d,function(){for(var G=0,j=d.length;G<j;G++){var U=d[G].split("/").slice(-1)[0];window.AMapUI[U]=arguments[G]}M()}):M()})})}function l(c){return new Promise(function(M,p){if(m.Loca===i.failed)p("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,a.Loca.version=c.version||a.Loca.version;var d=a.Loca.version,S=a.AMap.version.startsWith("2"),z=d.startsWith("2");if(S&&!z||!S&&z)p("JSAPI 与 Loca 版本不对应!!");else{S=a.key,z=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+S,K.onerror=function(P){m.Loca=i.failed,p("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=i.loaded,M();b.Loca.length;)b.Loca.splice(0,1)[0]()},z.appendChild(K)}}else m.Loca===i.loaded?c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):M():c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):b.Loca.push(function(P){P?p(P):p()})})}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 a={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},b={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(M,p){if(m.AMap==i.failed)p("");else if(m.AMap==i.notload){var d=c.key,S=c.version,z=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),a.key=d,a.AMap.version=S||a.AMap.version,a.AMap.plugins=z||a.AMap.plugins,m.AMap=i.loading,S=document.body||document.head,window.___onAPILoaded=function(P){if(delete window.___onAPILoaded,P)m.AMap=i.failed,p(P);else for(m.AMap=i.loaded,t(c).then(function(){M(window.AMap)}).catch(p);A.length;)A.splice(0,1)[0]()},z=document.createElement("script"),z.type="text/javascript",z.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+a.AMap.version+"&key="+d+"&plugin="+a.AMap.plugins.join(","),z.onerror=function(P){m.AMap=i.failed,p(P)},S.appendChild(z)):p("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(S=0;S<c.plugins.length;S+=1)a.AMap.plugins.indexOf(c.plugins[S])==-1&&d.push(c.plugins[S]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){M(window.AMap)}).catch(p)}):t(c).then(function(){M(window.AMap)}).catch(p)}else if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{var K=[];if(c.plugins)for(S=0;S<c.plugins.length;S+=1)a.AMap.plugins.indexOf(c.plugins[S])==-1&&K.push(c.plugins[S]);C(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){M(window.AMap)}).catch(p)}):t(c).then(function(){M(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,a={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},b={AMap:[],AMapUI:[],Loca:[]}}}})})(De);var rt=De.exports;const ze=ot(rt),Be="map-configuration",Ce=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Se=e=>{const o=h.useMemo(()=>{const r=sessionStorage.getItem(Ce(e));return r&&JSON.parse(r)},[e]),{data:t}=n.useRequest({resource:Be,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(Ce(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},nt=e=>{const{aMap:o,toCenter:t}=e,{t:r}=_(),l=h.useRef(),[i,a]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{l.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=q.useDebounceFn(A=>{l.current&&l.current.search(A||" ",(C,c)=>{if(C==="complete")a(c.poiList.pois.map(M=>H(F({},M),{label:`${M.name}-${M.address}`,value:M.id})));else{if(C==="no_data"){a([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),b=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(z,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("lodash"),require("@formily/antd-v5"),require("@formily/shared"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","lodash","@formily/antd-v5","@formily/shared","@emotion/css"],s):(z=typeof globalThis!="undefined"?globalThis:z||self,s(z["@nocobase/plugin-map"]={},z.jsxRuntime,z["@nocobase/client"],z.react,z["@ant-design/icons"],z["@formily/react"],z.ahooks,z.antd,z["react-i18next"],z.lodash,z["@formily/antd-v5"],z["@formily/shared"],z["@emotion/css"]))})(this,function(z,s,r,h,R,N,j,w,ae,de,Qe,$e,Re){"use strict";var _t=Object.defineProperty,Vt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var Yt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var Oe=(z,s,r)=>s in z?_t(z,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):z[s]=r,F=(z,s)=>{for(var r in s||(s={}))Yt.call(s,r)&&Oe(z,r,s[r]);if(Xe)for(var r of Xe(s))Ht.call(s,r)&&Oe(z,r,s[r]);return z},H=(z,s)=>Vt(z,Wt(s));var O=(z,s,r)=>(Oe(z,typeof s!="symbol"?s+"":s,r),r);var Me=(z,s,r)=>new Promise((h,R)=>{var N=ae=>{try{w(r.next(ae))}catch(de){R(de)}},j=ae=>{try{w(r.throw(ae))}catch(de){R(de)}},w=ae=>ae.done?h(ae.value):Promise.resolve(ae.value).then(N,j);w((r=r.apply(z,s)).next())});const ge="map";function X(e){return`{{t('${e}', { ns: '${ge}', nsMode: 'fallback' })}}`}function _(){return ae.useTranslation([ge,"client"],{nsMode:"fallback"})}const Ee=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],Ae="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV3iEaCDnQ8F/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==",Le=(e,o,t)=>{const n=o==null?void 0:o.reduce((l,i,a)=>a===o.length-1&&(t==="o2m"||t==="m2m")?l==null?void 0:l.map(m=>m[i]).filter(m=>m!=null):l==null?void 0:l[i],e);return t==="o2m"||t==="m2m"?n:[n]};var et=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function tt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var De={exports:{}};(function(e,o){(function(t,n){e.exports=n()})(et,function(){function t(c){var M=[];return c.AMapUI&&M.push(n(c.AMapUI)),c.Loca&&M.push(l(c.Loca)),Promise.all(M)}function n(c){return new Promise(function(M,p){var d=[];if(c.plugins)for(var S=0;S<c.plugins.length;S+=1)a.AMapUI.plugins.indexOf(c.plugins[S])==-1&&d.push(c.plugins[S]);if(m.AMapUI===i.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,a.AMapUI.version=c.version||a.AMapUI.version,S=a.AMapUI.version;var T=document.body||document.head,U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/ui/"+S+"/main.js",U.onerror=function(P){m.AMapUI=i.failed,p("请求 AMapUI 失败")},U.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var P=0,G=d.length;P<G;P++){var q=d[P].split("/").slice(-1)[0];window.AMapUI[q]=arguments[P]}for(M();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()});else for(M();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()},T.appendChild(U)}else m.AMapUI===i.loaded?c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var P=0,G=d.length;P<G;P++){var q=d[P].split("/").slice(-1)[0];window.AMapUI[q]=arguments[P]}M()}):M():c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):b.AMapUI.push(function(P){P?p(P):d.length?window.AMapUI.loadUI(d,function(){for(var G=0,q=d.length;G<q;G++){var K=d[G].split("/").slice(-1)[0];window.AMapUI[K]=arguments[G]}M()}):M()})})}function l(c){return new Promise(function(M,p){if(m.Loca===i.failed)p("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,a.Loca.version=c.version||a.Loca.version;var d=a.Loca.version,S=a.AMap.version.startsWith("2"),T=d.startsWith("2");if(S&&!T||!S&&T)p("JSAPI 与 Loca 版本不对应!!");else{S=a.key,T=document.body||document.head;var U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/loca?v="+d+"&key="+S,U.onerror=function(P){m.Loca=i.failed,p("请求 AMapUI 失败")},U.onload=function(){for(m.Loca=i.loaded,M();b.Loca.length;)b.Loca.splice(0,1)[0]()},T.appendChild(U)}}else m.Loca===i.loaded?c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):M():c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):b.Loca.push(function(P){P?p(P):p()})})}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 a={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},b={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(M,p){if(m.AMap==i.failed)p("");else if(m.AMap==i.notload){var d=c.key,S=c.version,T=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),a.key=d,a.AMap.version=S||a.AMap.version,a.AMap.plugins=T||a.AMap.plugins,m.AMap=i.loading,S=document.body||document.head,window.___onAPILoaded=function(P){if(delete window.___onAPILoaded,P)m.AMap=i.failed,p(P);else for(m.AMap=i.loaded,t(c).then(function(){M(window.AMap)}).catch(p);A.length;)A.splice(0,1)[0]()},T=document.createElement("script"),T.type="text/javascript",T.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+a.AMap.version+"&key="+d+"&plugin="+a.AMap.plugins.join(","),T.onerror=function(P){m.AMap=i.failed,p(P)},S.appendChild(T)):p("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(S=0;S<c.plugins.length;S+=1)a.AMap.plugins.indexOf(c.plugins[S])==-1&&d.push(c.plugins[S]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){M(window.AMap)}).catch(p)}):t(c).then(function(){M(window.AMap)}).catch(p)}else if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{var U=[];if(c.plugins)for(S=0;S<c.plugins.length;S+=1)a.AMap.plugins.indexOf(c.plugins[S])==-1&&U.push(c.plugins[S]);C(function(){U.length?window.AMap.plugin(U,function(){t(c).then(function(){M(window.AMap)}).catch(p)}):t(c).then(function(){M(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,a={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},b={AMap:[],AMapUI:[],Loca:[]}}}})})(De);var ot=De.exports;const Te=tt(ot),ze="map-configuration",Ce=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Se=e=>{const o=h.useMemo(()=>{const n=sessionStorage.getItem(Ce(e));return n&&JSON.parse(n)},[e]),{data:t}=r.useRequest({resource:ze,action:"get",params:{type:e}},{onSuccess(n){sessionStorage.setItem(Ce(e),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Be=()=>{var C,c;const e=r.useDataBlockHeight(),{token:o}=w.theme.useToken(),{designable:t}=r.useDesignable(),{heightProps:n}=r.useBlockHeightProps()||{},{title:l}=n||{},i=N.useFieldSchema();if(!e)return;const a=Object.keys(((c=(C=i.parent)==null?void 0:C.properties.actions)==null?void 0:c.properties)||{}).length>0,m=t||a?o.paddingLG+o.controlHeight+o.margin:o.paddingLG+o.margin,b=o.paddingLG,A=l?o.fontSizeLG*o.lineHeightLG+o.padding*2-1:0;return e-m-b-A},rt=e=>{const{aMap:o,toCenter:t}=e,{t:n}=_(),l=h.useRef(),[i,a]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{l.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=j.useDebounceFn(A=>{l.current&&l.current.search(A||" ",(C,c)=>{if(C==="complete")a(c.poiList.pois.map(M=>H(F({},M),{label:`${M.name}-${M.address}`,value:M.id})));else{if(C==="no_data"){a([]);return}w.message.error(n("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),b=A=>{const C=i.find(c=>c.value===A);C!=null&&C.location&&t(C.location)};return s.jsx("div",{className:r.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:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:
|
|
16
|
+
`,children:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i,popupMatchSelectWidth:!1})})},xe={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"}},we=h.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:n}=Se(e.mapType)||{},{value:l,onChange:i,block:a=!1,readonly:m,disabled:b=a,zoom:A=13,overlayCommonOptions:C}=e,{t:c}=_(),M=N.useFieldSchema(),p=h.useRef(),d=h.useRef(),S=h.useRef(),[T,U]=h.useState([]),[P,G]=h.useState(""),{getField:q}=r.useCollection_deprecated(),K=h.useMemo(()=>{if(e.type)return e.type;const u=q(M==null?void 0:M.name);return u==null?void 0:u.interface},[e==null?void 0:e.type,M==null?void 0:M.name]),V=h.useRef(),k=h.useRef(null),Q=r.useNavigateNoUpdate(),J=h.useRef(`nocobase-map-${K||""}-${Date.now().toString(32)}`),{modal:ue}=w.App.useApp(),re=Be(),[W]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},C));h.useEffect(()=>{d.current&&d.current.setZoom(A)},[A]);const ne=j.useMemoizedFn(()=>{V.current&&V.current.remove()}),se=j.useMemoizedFn(()=>{(!b||a)&&K!=="point"&&k.current&&(k.current.setTarget(V.current),k.current.open())}),le=j.useMemoizedFn((u,f=!1)=>{let y=null;if(K==="point"){const{lat:g,lng:E}=u.getPosition();y=[E,g]}else if(K==="polygon"||K==="lineString"){if(y=u.getPath().map(g=>[g.lng,g.lat]),y.length<2)return}else if(K==="circle"){const g=u.getCenter(),E=u.getRadius();y=[g.lng,g.lat,E]}f||(ne(),V.current=u,se()),i==null||i(y)}),$=j.useMemoizedFn((u=K)=>{const f=xe[u];if(f&&"editor"in f&&!k.current)return k.current=new p.current[f.editor](d.current,null,{createOptions:W,editOptions:W,controlPoint:H(F({},W),{strokeWeight:3}),midControlPoint:H(F({},W),{strokeWeight:2,fillColor:"#fff"})}),k.current.on("adjust",function({target:y}){le(y,!0)}),k.current.on("move",function({target:y}){le(y,!0)}),k.current}),I=j.useMemoizedFn((u=K)=>{var y;if(!S.current||(y=k.current)!=null&&y.getTarget())return;const f=xe[u];f&&S.current[f.mouseTool](F({},W))}),Y=j.useMemoizedFn((u=K)=>{S.current||(S.current=new p.current.MouseTool(d.current),S.current.on("draw",function({obj:f}){le(f)}),I(u))}),B=(u,f)=>{d.current&&d.current.setZoomAndCenter(18,u,f)},Z=()=>{const u=()=>{ne(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)};ue.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(J.current),onOk(){u()}})},x=()=>{V.current&&d.current.setFitView([V.current])},L=h.useCallback((u=K,f=l,y)=>{const g=xe[u];if(!g)return;const E=F(F({},W),y);return"transformOptions"in g?Object.assign(E,g.transformOptions(f)):"propertyKey"in g&&(E[g.propertyKey]=f),new p.current[g.overlay](E)},[W]),v=(u=K,f=l,y)=>{if(!p.current)return;const g=L(u,f,y);return g.setMap(d.current),g};h.useEffect(()=>{if(!p.current||!l||!m&&V.current)return;const u=v();d.current.setFitView([u]),V.current=u,b||($(),se())},[l,T,K,W,b,m]),h.useEffect(()=>{var u,f,y;S.current&&(b?((u=S.current)==null||u.close(),(f=k.current)==null||f.close()):(I(),(y=k.current)==null||y.open()))},[b]),h.useEffect(()=>{!p.current||!K||b||(Y(),$())},[b,T,K]),h.useEffect(()=>{var f,y;if(!l&&(S.current||k.current)&&(ne(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)),!S.current||!k.current)return;k.current.getTarget()?(y=(f=S.current).close)==null||y.call(f):I()},[K,l]),h.useEffect(()=>{if(!t||d.current)return;n&&(window._AMapSecurityConfig={[n.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:n});const u=window.define;return window.define=void 0,Te.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(f=>(window.define=u,requestIdleCallback(()=>{d.current=new f.Map(J.current,{resizeEnable:!0,zoom:A}),p.current=f,G(""),U([])}))).catch(f=>{typeof f=="string"?f.includes("多个不一致的 key")?G(c("The AccessKey is incorrect, please check it")):G(f):(f==null?void 0:f.type)==="error"&&G("Something went wrong, please refresh the page and try again")}),()=>{var f;(f=d.current)==null||f.destroy(),p.current=null,d.current=null,S.current=null,k.current=null,Te.reset()}},[t,K,n]),h.useImperativeHandle(o,()=>({setOverlay:v,getOverlay:L,createMouseTool:Y,createEditor:$,executeMouseTool:I,aMap:p.current,map:d.current,overlay:V.current,mouseTool:()=>S.current,editor:()=>k.current,errMessage:P}));const D=r.useApp();return!t||P?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>Q(D.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:P||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):s.jsxs("div",{className:r.css`
|
|
17
17
|
position: relative;
|
|
18
18
|
height: ${re||500}px !important;
|
|
19
|
-
`,id:J.current,style:e==null?void 0:e.style,children:[!p.current&&s.jsx("div",{className:
|
|
19
|
+
`,id:J.current,style:e==null?void 0:e.style,children:[!p.current&&s.jsx("div",{className:r.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:s.jsx(w.Spin,{})}),b?null:s.jsxs(s.Fragment,{children:[s.jsx(
|
|
25
|
+
`,children:s.jsx(w.Spin,{})}),b?null:s.jsxs(s.Fragment,{children:[s.jsx(rt,{toCenter:B,aMap:p.current}),s.jsx("div",{className:r.css`
|
|
26
26
|
position: absolute;
|
|
27
27
|
bottom: 80px;
|
|
28
28
|
right: 20px;
|
|
29
29
|
z-index: 10;
|
|
30
|
-
`,children:s.jsx(w.Button,{onClick:x,disabled:!V.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),
|
|
30
|
+
`,children:s.jsx(w.Button,{onClick:x,disabled:!V.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),K!=="point"?s.jsx("div",{className:r.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:s.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:
|
|
36
|
+
`,children:s.jsx(w.Alert,{message:c("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:r.css`
|
|
37
37
|
position: absolute;
|
|
38
38
|
bottom: 20px;
|
|
39
39
|
right: 20px;
|
|
40
40
|
z-index: 2;
|
|
41
|
-
`,children:s.jsx(w.Button,{disabled:!l,style:{height:"40px"},onClick:Z,type:"primary",danger:!0,children:c("Clear")})})]})]})});we.displayName="AMapComponent";const
|
|
41
|
+
`,children:s.jsx(w.Button,{disabled:!l,style:{height:"40px"},onClick:Z,type:"primary",danger:!0,children:c("Clear")})})]})]})});we.displayName="AMapComponent";const nt=e=>{var $,I,Y,B,Z;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=r.useProps(e),{name:b,getPrimaryKey:A}=r.useCollection_deprecated(),{getCollectionJoinField:C}=r.useCollectionManager_deprecated(),c=A(),[M,p]=h.useState(!1),d=h.useRef(),S=(I=($=d.current)==null?void 0:$.aMap)==null?void 0:I.GeometryUtil,[T,U]=h.useState(),[P,G]=h.useState(""),{t:q}=_(),K=r.useCompile(),{isConnected:V,doFilter:k}=r.useFilterAPI(),[,Q]=h.useState(null),J=h.useRef(P);J.current=P;const{fields:ue}=r.useCollection(),re=(Y=ue.find(x=>x.name===(t==null?void 0:t.marker)))==null?void 0:Y.uiSchema,W=(x,L)=>{const v=x.getExtData(),D=typeof L=="undefined"?v.selected:!L;v.selected=!D,"setIcon"in x&&x.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:D?fe:Ae})),x.setOptions(F({extData:v},D?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},ne=()=>{var x,L,v;d.current&&((x=d.current)==null||x.mouseTool().close(!0),(L=d.current)==null||L.editor().setTarget(null),(v=d.current)==null||v.editor().close())};h.useEffect(()=>{var x,L,v,D;if(P==="selection")return(x=d.current)!=null&&x.editor()?(D=d.current)==null||D.executeMouseTool("polygon"):((L=d.current)==null||L.createEditor("polygon"),(v=d.current)==null||v.createMouseTool("polygon")),()=>{ne()}},[P]),h.useEffect(()=>{if(P)return()=>{var x;J.current||(x=d.current)==null||x.map.getAllOverlays().forEach(L=>{W(L,!1)})}},[P]);const se=j.useMemoizedFn(()=>{var u,f,y;const x=(u=d.current)==null?void 0:u.editor().getTarget(),L=(f=d.current)==null?void 0:f.map.getAllOverlays(),v=L==null?void 0:L.filter(g=>{if(!(g===x||g.getExtData().id===void 0))return"getPosition"in g?S.isPointInRing(g.getPosition(),x==null?void 0:x.getPath()):S.doesRingRingIntersect(g.getPath(),x==null?void 0:x.getPath())}),D=v==null?void 0:v.map(g=>(W(g,!0),g.getExtData().id));a(g=>D==null?void 0:D.concat(g)),x==null||x.remove(),(y=d.current)==null||y.editor().close()});h.useEffect(()=>{var u,f,y;if(!o||!d.current||!n)return;const x=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,L=C([b,...x].flat().join(".")),v=n.map(g=>{var te;const E=(te=Le(g,t==null?void 0:t.field,L==null?void 0:L.interface))==null?void 0:te.filter(Boolean),ee=r.getLabelFormatValue(re,g[t.marker]);return E!=null&&E.length?E.map(ie=>{var oe;return(oe=d.current)==null?void 0:oe.setOverlay(o.type,ie,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?K(ee):void 0},extData:{id:g[c]}})}):[]}).flat().filter(Boolean);(f=(u=d.current)==null?void 0:u.map)==null||f.setFitView(v);const D=v.map(g=>{const E=ee=>{const te=ee.target,ie=te.getExtData();if(!ie)return;if(J.current){J.current==="click"&&(a(oe=>ie.selected?oe.filter(Fe=>Fe!==ie.id):[...oe,ie.id]),W(te));return}const ve=n.find(oe=>ie.id===oe[c]);if(V){Q(oe=>(oe&&Ue(oe),oe===g?(Ue(g),k(null),null):(it(g),k(ve[c],Fe=>Fe.field||c,"$eq"),g)));return}ve&&U(ve)};return g.on("click",E),()=>g.off("click",E)});if(o.type==="point"&&(m!=null&&m.length)&&(v==null?void 0:v.length)>1){const g=v.map(ee=>ee.getPosition());v[0].setzIndex(13),v[v.length-1].setzIndex(13);const E=(ee=!0)=>{var te,ie;if((te=d.current)!=null&&te.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:q(ee?"Start point":"End point")},position:g[ee?0:g.length-1],map:(ie=d.current)==null?void 0:ie.map})};v.push(...[(y=d.current)==null?void 0:y.setOverlay("lineString",g,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),E(),E(!1)].filter(Boolean))}return()=>{v.forEach(g=>{g.remove()}),D.forEach(g=>g())}},[n,M,t,b,c,o.type,V,m]),h.useEffect(()=>{setTimeout(()=>{a([])})},[n]);const le=x=>{d.current=x,p(!!(x!=null&&x.map)&&!x.errMessage)};return s.jsxs("div",{className:r.css`
|
|
42
42
|
position: relative;
|
|
43
43
|
height: 100%;
|
|
44
|
-
`,children:[s.jsx("div",{className:
|
|
44
|
+
`,children:[s.jsx("div",{className:r.css`
|
|
45
45
|
position: absolute;
|
|
46
46
|
left: 10px;
|
|
47
47
|
top: 10px;
|
|
48
48
|
z-index: 999;
|
|
49
|
-
`,children:M&&!((B=d.current)!=null&&B.errMessage)?s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:P?void 0:"#F18b62",borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),G("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:P==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),G("selection")},icon:s.jsx(R.ExpandOutlined,{})}),P==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:
|
|
49
|
+
`,children:M&&!((B=d.current)!=null&&B.errMessage)?s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:P?void 0:"#F18b62",borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),G("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:P==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),G("selection")},icon:s.jsx(R.ExpandOutlined,{})}),P==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:q("Confirm selection"),onClick:se}):null]}):null}),s.jsx(st,{record:T,setVisible:U}),s.jsx(we,H(F({},(Z=o==null?void 0:o.uiSchema)==null?void 0:Z["x-component-props"]),{ref:le,style:{height:l?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},st=e=>{const{setVisible:o,record:t}=e;_();const n=r.useCollection(),l=r.useCollectionParentRecordData(),i=N.useFieldSchema(),a=h.useMemo(()=>i.reduceProperties((m,b)=>b.name==="drawer"?b:m,null),[i]);return a&&s.jsx(r.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(r.RecordProvider,{record:t,parent:l,children:s.jsx(r.VariablePopupRecordProvider,{recordData:t,collection:n,children:s.jsx(N.RecursionField,{schema:a,name:a.name})})})})};function Ue(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function it(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 Ke=({type:e,children:o})=>{const{t}=_(),[n,l]=j.useBoolean(!1),i=r.useAPIClient(),[a]=w.Form.useForm(),m=Se(e);h.useEffect(()=>{m&&(a.setFieldsValue(m),l.toggle())},[m]);const b=h.useMemo(()=>i.resource(ze),[i]),A=C=>{b.set(H(F({},C),{type:e})).then(c=>{sessionStorage.removeItem(Ce(e)),l.toggle(),w.message.success(t("Saved successfully"))}).catch(c=>{w.message.success(t("Saved failed"))})};return s.jsxs(w.Form,{disabled:n,form:a,layout:"vertical",onFinish:A,children:[o,n?s.jsx(w.Button,{disabled:!1,onClick:l.toggle,children:t("Edit")}):s.jsx(w.Form.Item,{children:s.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},at={amap:()=>{const{t:e}=_();return s.jsxs(Ke,{type:"amap",children:[s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:s.jsx(w.Input,{})}),s.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:s.jsx(w.Input,{})})]})},google:()=>{const{t:e}=_();return s.jsx(Ke,{type:"google",children:s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:s.jsx(w.Input,{})})})}},lt=Ee.map(e=>H(F({},e),{component:at[e.value]})),ct=()=>{const e=r.useCompile(),o=r.useLocationSearch(),t=new URLSearchParams(o);return s.jsx(w.Card,{bordered:!0,children:s.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:lt.map(n=>s.jsx(w.Tabs.TabPane,{tab:e(n.label),children:s.jsx(n.component,{type:n.value})},n.value))})})};/*! *****************************************************************************
|
|
50
50
|
Copyright (c) Microsoft Corporation.
|
|
51
51
|
|
|
52
52
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -59,66 +59,66 @@
|
|
|
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 pt(e,o,t,n){function l(i){return i instanceof t?i:new t(function(a){a(i)})}return new(t||(t=Promise))(function(i,a){function m(C){try{A(n.next(C))}catch(c){a(c)}}function b(C){try{A(n.throw(C))}catch(c){a(c)}}function A(C){C.done?i(C.value):l(C.value).then(m,b)}A((n=n.apply(e,o||[])).next())})}var ut=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 n,l,i;if(Array.isArray(o)){if(n=o.length,n!=t.length)return!1;for(l=n;l--!==0;)if(!e(o[l],t[l]))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),n=i.length,n!==Object.keys(t).length)return!1;for(l=n;l--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[l]))return!1;for(l=n;l--!==0;){var a=i[l];if(!e(o[a],t[a]))return!1}return!0}return o!==o&&t!==t};const Ne="__googleMapsScriptId";var me;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(me||(me={}));class ce{constructor({apiKey:o,authReferrerPolicy:t,channel:n,client:l,id:i=Ne,language:a,libraries:m=[],mapIds:b,nonce:A,region:C,retries:c=3,url:M="https://maps.googleapis.com/maps/api/js",version:p}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=o,this.authReferrerPolicy=t,this.channel=n,this.client=l,this.id=i||Ne,this.language=a,this.libraries=m,this.mapIds=b,this.nonce=A,this.region=C,this.retries=c,this.url=M,this.version=p,ce.instance){if(!ut(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?me.FAILURE:this.done?me.SUCCESS:this.loading?me.LOADING:me.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(n=>{n?t(n.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 n={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(n).forEach(i=>!n[i]&&delete n[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 a,m,b,A="The Google Maps JavaScript API",C="google",c="importLibrary",M="__ib__",p=document,d=window;d=d[C]||(d[C]={});const S=d.maps||(d.maps={}),T=new Set,U=new URLSearchParams,P=()=>a||(a=new Promise((G,q)=>pt(this,void 0,void 0,function*(){var K;yield m=p.createElement("script"),m.id=this.id,U.set("libraries",[...T]+"");for(b in i)U.set(b.replace(/[A-Z]/g,V=>"_"+V[0].toLowerCase()),i[b]);U.set("callback",C+".maps."+M),m.src=this.url+"?"+U,S[M]=G,m.onerror=()=>a=q(Error(A+" could not load.")),m.nonce=this.nonce||((K=p.querySelector("script[nonce]"))===null||K===void 0?void 0:K.nonce)||"",p.head.append(m)})));S[c]?console.warn(A+" only loads once. Ignoring:",i):S[c]=(G,...q)=>T.add(G)&&P().then(()=>S[c](G,...q))})(n);const l=this.libraries.map(i=>this.importLibrary(i));l.length||l.push(this.importLibrary("core")),Promise.all(l).then(()=>this.callback(),i=>{const a=new ErrorEvent("error",{error:i});this.loadErrorCallback(a)})}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 dt=e=>{const{toCenter:o,mapRef:t}=e,{t:n}=_(),l=h.useRef(),[i,a]=h.useState([]);h.useEffect(()=>{google.maps.importLibrary("places").then(A=>{l.current=new A.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[t]);const{run:m}=j.useDebounceFn(A=>{l.current&&l.current.getPlacePredictions({input:A||" "},(C,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)a(C.map(M=>{const p=M.structured_formatting;return H(F({},M),{label:`${p.main_text}${p.secondary_text?" "+p.secondary_text:""}`,value:M.place_id})}));else{a([]);return}})},{wait:300}),b=A=>{const C=i.find(M=>M.value===A);new google.maps.places.PlacesService(t.current).getDetails({placeId:C.place_id,fields:["geometry"]},(M,p)=>{p===google.maps.places.PlacesServiceStatus.OK&&o(M.geometry.location)})};return s.jsx("div",{className:r.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:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:
|
|
68
|
+
`,children:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:n("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),ft=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:n,longitude:l}=t.coords;e({lat:n,lng:l})},()=>{o()}):o()}),mt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,gt={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"}},Pe=h.forwardRef((e,o)=>{const{value:t,onChange:n,block:l=!1,readonly:i,disabled:a=l,zoom:m=13,overlayCommonOptions:b}=e,{accessKey:A}=Se(e.mapType)||{},{t:C}=_(),{getField:c}=r.useCollection_deprecated(),M=N.useFieldSchema(),p=h.useRef(),d=h.useRef(),S=h.useRef(),[T,U]=h.useState([]),[P,G]=h.useState(""),q=r.useAPIClient(),{modal:K}=w.App.useApp(),V=Be();h.useEffect(()=>{d.current&&d.current.setZoom(m)},[m]);const k=h.useMemo(()=>{if(e.type)return e.type;const u=c(M==null?void 0:M.name);return u==null?void 0:u.interface},[e==null?void 0:e.type,M==null?void 0:M.name]),Q=h.useRef(mt(k)),[J]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!a,draggable:!a},b)),ue=r.useNavigateNoUpdate(),re=h.useRef(),W=h.useRef(new Set),ne=j.useMemoizedFn(u=>{if(W.current.forEach(f=>{W.current.delete(f)}),"getPath"in u){const f=u.getPath();["insert_at","remove_at","set_at"].forEach(y=>{W.current.add(f.addListener(y,()=>{B(u,!0)}).remove)})}else u instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(f=>{W.current.add(u.addListener(f,()=>{B(u,!0)}).remove)})}),se=j.useMemoizedFn(()=>{var u;S.current&&(S.current.unbindAll(),S.current.setMap(null)),k!=="point"&&((u=p.current)==null||u.setDrawingMode(null))}),le=j.useMemoizedFn(u=>{d.current&&(d.current.setCenter(u),d.current.setZoom(m))}),$=j.useMemoizedFn(u=>{se(),ne(u),S.current=u}),I=j.useMemoizedFn(u=>{const f=new google.maps.LatLngBounds;u.forEach(y=>{if(y instanceof google.maps.Marker)f.extend(y.getPosition());else if(y instanceof google.maps.Polyline||y instanceof google.maps.Polygon){const g=y.getPath();for(let E=0;E<g.getLength();E++)f.extend(g.getAt(E))}else y instanceof google.maps.Circle&&f.union(y.getBounds())}),d.current.setCenter(f.getCenter())}),Y=()=>{S.current&&I([S.current])},B=j.useMemoizedFn((u,f=!1)=>{let y=null;if(k==="point"){const{lat:g,lng:E}=u.getPosition();y=[E(),g()]}else if(k==="polygon"||k==="lineString"){if(y=u.getPath().getArray().map(g=>[g.lng(),g.lat()]),y.length<2)return}else if(k==="circle"){const g=u.getCenter(),E=u.getRadius();y=[g.lng(),g.lat(),E]}f||$(u),n==null||n(y)}),Z=j.useMemoizedFn((u=!1,f)=>{const y=H(F(F({},J),f),{map:d.current});return p.current=new google.maps.drawing.DrawingManager({drawingMode:Q.current,drawingControl:!1,markerOptions:H(F({},y),{icon:pe(fe)}),polygonOptions:y,polylineOptions:y,circleOptions:y,map:d.current}),u||p.current.addListener("overlaycomplete",g=>{const E=g.overlay;B(E)}),p.current}),x=j.useMemoizedFn((u=k,f=t,y)=>{const g=gt[u];if(!g)return;const E=F(H(F({},J),{icon:pe(fe)}),y);return"transformOptions"in g?Object.assign(E,g.transformOptions(f)):"propertyKey"in g&&(E[g.propertyKey]=Array.isArray(f[0])?f.map(te=>new google.maps.LatLng(te[1],te[0])):new google.maps.LatLng(f[1],f[0])),new google.maps[g.overlay](E)}),L=j.useMemoizedFn((u=k,f=t,y)=>d.current?x(u,f,H(F({},y),{map:d.current})):void 0);h.useEffect(()=>{var f,y;if(!t&&d.current&&(se(),(y=(f=p==null?void 0:p.current)==null?void 0:f.setDrawingMode)==null||y.call(f,Q.current),n==null||n(null)),!d.current||!t||!i&&S.current)return;const u=L();$(u),I([u])},[t,T,k,a,i,L,I,$]),h.useEffect(()=>{if(!A||d.current||!re.current)return;let u;try{u=new ce({apiKey:A,version:"weekly",language:q.auth.getLocale()})}catch(y){G(C("Load google maps failed, Please check the Api key and refresh the page"));return}const f=console.error;return console.error=(y,...g)=>{y!=null&&y.includes("InvalidKeyMapError")&&G(C("Load google maps failed, Please check the Api key and refresh the page")),f(y,...g)},Promise.all([u.importLibrary("drawing"),u.importLibrary("core"),u.importLibrary("geometry")]).then(y=>Me(this,null,function*(){const g=yield ft();d.current=new google.maps.Map(re.current,{zoom:m,center:g,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),G(""),U([])})).catch(y=>{if(y instanceof Error){G(y.message);return}}),()=>{var y,g;(y=d.current)==null||y.unbindAll(),d.current=null,(g=p.current)==null||g.unbindAll()}},[A,q.auth,k,m]),h.useEffect(()=>{!d.current||!k||a||p.current||Z()},[Z,a,T,k]),h.useImperativeHandle(o,()=>({setOverlay:L,getOverlay:x,setFitView:I,createDraw:Z,map:d.current,overlay:S.current,drawingManager:p.current,errMessage:P}));const v=j.useMemoizedFn(()=>{const u=()=>{se(),p.current.setDrawingMode(Q.current),n==null||n(null)};K.confirm({title:C("Clear the canvas"),content:C("Are you sure to clear the canvas?"),okText:C("Confirm"),cancelText:C("Cancel"),getContainer:()=>re.current,onOk(){u()}})}),D=r.useApp();return!A||P?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>ue(D.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:C("Go to the configuration page")}),message:P||C("Please configure the Api key first"),type:"error"}):s.jsxs("div",{className:r.css`
|
|
69
69
|
position: relative;
|
|
70
70
|
height: ${V||500}px !important;
|
|
71
|
-
`,children:[!d.current&&s.jsx("div",{className:
|
|
71
|
+
`,children:[!d.current&&s.jsx("div",{className:r.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:s.jsx(w.Spin,{})}),a?null:s.jsxs(s.Fragment,{children:[d.current&&s.jsx(
|
|
77
|
+
`,children:s.jsx(w.Spin,{})}),a?null:s.jsxs(s.Fragment,{children:[d.current&&s.jsx(dt,{toCenter:le,mapRef:d}),s.jsx("div",{className:r.css`
|
|
78
78
|
position: absolute;
|
|
79
79
|
bottom: 80px;
|
|
80
80
|
right: 20px;
|
|
81
81
|
z-index: 10;
|
|
82
|
-
`,children:s.jsx(w.Button,{onClick:Y,disabled:!S.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),k==="lineString"||k==="polygon"?s.jsx("div",{className:
|
|
82
|
+
`,children:s.jsx(w.Button,{onClick:Y,disabled:!S.current,type:"primary",shape:"round",size:"large",icon:s.jsx(R.SyncOutlined,{})})}),k==="lineString"||k==="polygon"?s.jsx("div",{className:r.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:s.jsx(w.Alert,{message:C("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:
|
|
88
|
+
`,children:s.jsx(w.Alert,{message:C("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:r.css`
|
|
89
89
|
position: absolute;
|
|
90
90
|
bottom: 20px;
|
|
91
91
|
right: 20px;
|
|
92
92
|
z-index: 2;
|
|
93
|
-
`,children:s.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:v,type:"primary",danger:!0,children:C("Clear")})})]}),s.jsx("div",{ref:re,className:
|
|
93
|
+
`,children:s.jsx(w.Button,{disabled:!t,style:{height:"40px"},onClick:v,type:"primary",danger:!0,children:C("Clear")})})]}),s.jsx("div",{ref:re,className:r.css`
|
|
94
94
|
width: 100%;
|
|
95
95
|
height: 100%;
|
|
96
|
-
`,style:e==null?void 0:e.style})]})});Pe.displayName="GoogleMapsComponent";const he="google-maps-overlay-id",
|
|
96
|
+
`,style:e==null?void 0:e.style})]})});Pe.displayName="GoogleMapsComponent";const he="google-maps-overlay-id",Ge="google-maps-overlay-selected",ht=r.css`
|
|
97
97
|
margin-top: 6px;
|
|
98
98
|
padding: 2px 4px;
|
|
99
99
|
background: #fff;
|
|
100
100
|
border: 1px solid #0000f5;
|
|
101
|
-
`,
|
|
101
|
+
`,yt=r.css`
|
|
102
102
|
margin-top: -64px;
|
|
103
103
|
padding: 2px 4px;
|
|
104
104
|
background: #fff;
|
|
105
105
|
border: 1px solid #0000f5;
|
|
106
|
-
`,
|
|
106
|
+
`,bt=e=>{var $;const{collectionField:o,fieldNames:t,dataSource:n,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=r.useProps(e),{getPrimaryKey:b}=r.useCollection_deprecated(),A=b(),{marker:C="id"}=t,[c,M]=h.useState(!1),p=h.useRef(),[d,S]=h.useState(),[T,U]=h.useState(""),{t:P}=_(),G=r.useCompile(),{isConnected:q,doFilter:K}=r.useFilterAPI(),[,V]=h.useState(null),k=h.useRef(T),Q=h.useRef(null),J=h.useRef([]);k.current=T;const{fields:ue}=r.useCollection(),re=($=ue.find(I=>I.name===(t==null?void 0:t.marker)))==null?void 0:$.uiSchema,{getCollectionJoinField:W}=r.useCollectionManager_deprecated(),ne=(I,Y)=>{const B=typeof Y!="undefined"?!Y:I.get(Ge);I.set(Ge,!B),I.setOptions(F({},B?{icon:pe(fe),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:pe(Ae),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var Y,B,Z,x;if(T!=="selection")return;p.current&&!((Y=p.current)!=null&&Y.drawingManager)&&(p.current.drawingManager=(B=p.current)==null?void 0:B.createDraw(!0,{editable:!0,draggable:!0}));const I=new Set;return(Z=p.current)==null||Z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(x=p.current)==null||x.drawingManager.addListener("overlaycomplete",L=>{var u;const v=L.overlay;(u=p.current)==null||u.drawingManager.setDrawingMode(null),Q.current=v;const D=v.getPath();["insert_at","remove_at","set_at"].forEach(f=>{I.add(D.addListener(f,()=>{}).remove)})}),()=>{var L,v,D,u;I.forEach(f=>{f()}),p.current&&((L=Q.current)==null||L.unbindAll(),(v=Q.current)==null||v.setMap(null),Q.current=null,(D=p.current)==null||D.drawingManager.setDrawingMode(null),(u=p.current)==null||u.drawingManager.unbindAll())}},[T]),h.useEffect(()=>{if(T)return()=>{k.current||J.current.forEach(I=>{ne(I,!1)})}},[T]);const se=j.useMemoizedFn(()=>{var L;const I=Q.current,Y=J.current,B=google.maps.geometry.poly,x=Y.filter(v=>{if(!(v===I||v.get(he)===void 0))return v instanceof google.maps.Marker?B.containsLocation(v.getPosition(),I):v instanceof google.maps.Circle?B.containsLocation(v.getCenter(),I):v.getPath().getArray().some(D=>B.containsLocation(D,I))}).map(v=>(ne(v,!0),v.get(he)));a(v=>x.concat(v)),I==null||I.unbindAll(),I==null||I.setMap(null),(L=p.current)==null||L.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});h.useEffect(()=>{var x,L;if(!o||!(n!=null&&n.length)||!((x=p.current)!=null&&x.map))return;const I=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,Y=W([name,...I].flat().join(".")),B=n.map(v=>{const D=Le(v,t==null?void 0:t.field,Y==null?void 0:Y.interface),u=r.getLabelFormatValue(re,v[t.marker]);return D!=null&&D.length?D==null?void 0:D.filter(Boolean).map(f=>{var g;if(!D)return;const y=(g=p.current)==null?void 0:g.setOverlay(o.type,f,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:ht,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?G(u):void 0}});return y==null||y.set(he,v[A]),y}):[]}).flat().filter(Boolean);J.current=B;const Z=B.map(v=>{const D=u=>{const f=v,y=f.get(he);if(!y)return;const g=n==null?void 0:n.find(E=>y===E[A]);if(q){V(E=>(E&&je(f),E===v?(je(f),K(null),null):(Mt(f),K(g[A],ee=>ee.field||A,"$eq"),f)));return}g&&S(g)};return v.addListener("click",D),()=>v.unbindAll()});if(o.type==="point"&&(m!=null&&m.length)&&(B==null?void 0:B.length)>1){const v=B.map(u=>u.getPosition());B[0].setZIndex(138),B[B.length-1].setZIndex(138);const D=(u=!0)=>{var f;if((f=p.current)!=null&&f.map)return new google.maps.Marker({label:{className:yt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:P(u?"Start point":"End point")},icon:pe(fe),position:u?v[0]:v[v.length-1],map:p.current.map})};B.push(...[p.current.setOverlay("lineString",v.map(u=>[u.lng(),u.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),D(),D(!1)].filter(Boolean))}return(L=p.current)==null||L.setFitView(B),()=>{B.forEach(v=>{v.setMap(null),v.unbindAll()}),Z.forEach(v=>v())}},[n,c,C,o.type,q]),h.useEffect(()=>{setTimeout(()=>{a([])})},[n]);const le=I=>{p.current=I,M(!!(I!=null&&I.map)&&!I.errMessage)};return s.jsxs("div",{className:r.css`
|
|
107
107
|
position: relative;
|
|
108
108
|
height: 100%;
|
|
109
|
-
`,children:[c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:
|
|
109
|
+
`,children:[c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:r.css`
|
|
110
110
|
position: absolute;
|
|
111
111
|
left: 10px;
|
|
112
112
|
top: 10px;
|
|
113
113
|
z-index: 999;
|
|
114
|
-
`,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:
|
|
114
|
+
`,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:T?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),U("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:T==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),U("selection")},icon:s.jsx(R.ExpandOutlined,{})}),T==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:P("Confirm selection"),onClick:se}):null]})}),s.jsx(vt,{record:d,setVisible:S})]}),s.jsx(Pe,H(F({},e),{ref:le,style:{height:l?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},vt=e=>{const{setVisible:o,record:t}=e;_();const n=r.useCollection(),l=r.useCollectionParentRecordData(),i=N.useFieldSchema(),a=h.useMemo(()=>i.reduceProperties((m,b)=>b.name==="drawer"?b:m,null),[i]);return a&&s.jsx(r.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(r.RecordProvider,{record:t,parent:l,children:s.jsx(r.VariablePopupRecordProvider,{recordData:t,collection:n,children:s.jsx(N.RecursionField,{schema:a,name:a.name})})})})};function je(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(fe));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function Mt(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(Ae));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const At=()=>{var c;const{getCollectionJoinField:e}=r.useCollectionManager_deprecated(),{getField:o}=r.useCollection_deprecated(),{form:t}=r.useFormBlockContext(),n=N.useField(),l=N.useFieldSchema(),{t:i}=_(),{dn:a,refresh:m}=r.useDesignable(),b=o(l.name)||e(l["x-collection-field"]),A=(c=b==null?void 0:b.uiSchema)==null?void 0:c.title;n.title===A||n.title,n.readPretty||n.required;let C="editable";return l["x-disabled"]===!0&&(C="readonly"),l["x-read-pretty"]===!0&&(C="read-pretty"),s.jsxs(r.GeneralSchemaDesigner,{children:[s.jsx(r.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!r.isPatternDisabled(l)&&s.jsx(r.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:C,onChange:M=>{const p={"x-uid":l["x-uid"]};switch(M){case"readonly":{l["x-read-pretty"]=!1,l["x-disabled"]=!0,p["x-read-pretty"]=!1,p["x-disabled"]=!0,n.readPretty=!1,n.disabled=!0;break}case"read-pretty":{l["x-read-pretty"]=!0,l["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,n.readPretty=!0;break}default:{l["x-read-pretty"]=!1,l["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,n.readPretty=!1,n.disabled=!1;break}}a.emit("patch",{schema:p}),a.refresh()}},"pattern"),s.jsx(r.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:n.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:M})=>{M&&(de.set(l,"x-component-props.zoom",M),Object.assign(n.componentProps,l["x-component-props"]),a.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":n.componentProps}})),a.refresh()}},"map-zoom"),s.jsx(r.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},Ct={amap:we,google:Pe},Ie=h.forwardRef((e,o)=>{const{t}=_(),{mapType:n}=e,l=h.useMemo(()=>Ct[n],[n]);return l?s.jsx(l,F({ref:o},e)):s.jsx("div",{children:t(`The ${n} cannot found`)})});Ie.displayName="MapComponent";const St=e=>{var m,b;const{value:o}=e,t=N.useFieldSchema(),{getField:n}=r.useCollection_deprecated(),l=n(t.name),i=e.mapType||((m=l==null?void 0:l.uiSchema["x-component-props"])==null?void 0:m.mapType),a=N.useForm();return r.useFieldTitle(),a.readPretty?s.jsx(Ie,F({readonly:!0,mapType:i},e)):s.jsx("div",{children:s.jsx(r.EllipsisWithTooltip,{ellipsis:!0,children:(b=o==null?void 0:o.map)==null?void 0:b.call(o,A=>Array.isArray(A)?`(${A.join(",")})`:A).join(",")})})},qe=N.connect(e=>s.jsx("div",{className:r.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(Ie,F({},e))}),N.mapReadPretty(
|
|
120
|
+
`,children:s.jsx(Ie,F({},e))}),N.mapReadPretty(St));qe.Designer=At;const xt={amap:nt,google:bt},wt=e=>{const{t:o}=_(),{mapType:t}=e,n=h.useMemo(()=>xt[t],[t]);return n?s.jsx(n,F({},e)):s.jsx("div",{children:o(`The ${t} cannot found`)})},Pt=r.withDynamicSchemaProps(e=>{var a;const{fieldNames:o}=r.useProps(e),{getCollectionJoinField:t}=r.useCollectionManager_deprecated(),{name:n}=r.useCollection_deprecated(),l=h.useMemo(()=>t([n,o==null?void 0:o.field].flat().join(".")),[n,o==null?void 0:o.field]),i=(a=l==null?void 0:l.uiSchema)==null?void 0:a["x-component-props"];return s.jsx(wt,H(F(F({},i),e),{collectionField:l}))}),It=()=>{const{name:e,title:o}=r.useCollection(),t=r.useSchemaTemplate();return s.jsx(r.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},_e=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,n,l)=>{const i=t==null?void 0:t.find(a=>a.value===n);return l===e.length-1?i:i==null?void 0:i.children},o)),kt=e=>{const{collectionName:o,fieldNames:t,dataSource:n}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:n,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":{}},[$e.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"}}}}}}}}}}}},Ft=()=>{const e=r.useSchemaInitializerItem(),{insert:o}=r.useSchemaInitializer(),t=h.useContext(N.SchemaOptionsContext),{getCollectionFieldsOptions:n}=r.useCollectionManager_deprecated(),{t:l}=_(),{theme:i}=r.useGlobalTheme();return s.jsx(r.DataBlockInitializer,F({componentType:"Map",icon:s.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>Me(this,[m],function*({item:a}){const b=n(a.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:a.dataSource}),A=n(a.name,"string",{dataSource:a.dataSource}),C=yield r.FormDialog(l("Create map block"),()=>{var c;return s.jsx(r.SchemaComponentOptions,{scope:t.scope,components:F({},t.components),children:s.jsx(Qe.FormLayout,{layout:"vertical",children:s.jsx(r.SchemaComponent,{schema:{properties:{field:{title:l("Map field"),enum:b,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:b.length?[b[0].value,(c=b[0].children)==null?void 0:c[0].value].filter(M=>M!=null):[]},marker:{title:l("Marker field"),enum:A,"x-component":"Select","x-decorator":"FormItem","x-reactions":M=>{const p=M.form.values.field;if(!(p!=null&&p.length))return;const d=_e(p,b);d&&(M.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(kt({collectionName:a.name,dataSource:a.dataSource,fieldNames:F({},C)}))}),title:l("Map block")},e))},ke=h.createContext({});ke.displayName="MapBlockContext";const Ot=e=>{var A;const{fieldNames:o}=e,t=N.useFieldSchema(),n=N.useField(),{resource:l,service:i}=r.useBlockRequestContext(),[a,m]=h.useState([]),{token:b}=w.theme.useToken();return s.jsx(r.FixedBlockWrapper,{children:s.jsx(r.SchemaComponentOptions,{scope:{selectedRecordKeys:a},children:s.jsxs(ke.Provider,{value:{field:n,service:i,resource:l,fieldNames:o,fixedBlock:(A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fixedBlock,selectedRecordKeys:a,setSelectedRecordKeys:m},children:[" ",s.jsx("div",{className:Re.css`
|
|
121
121
|
.nb-action-bar {
|
|
122
122
|
margin-bottom: ${b.margin}px;
|
|
123
123
|
}
|
|
124
|
-
`,children:e.children})]})})})},
|
|
124
|
+
`,children:e.children})]})})})},Et=e=>{const{filter:o,parseVariableLoading:t}=r.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:H(F({},e),{filter:o}),parseVariableLoading:t}},Lt=e=>{const o=N.useField(),{fieldNames:t}=e,{params:n,parseVariableLoading:l}=Et(e.params);if(l)return null;const i=n.appends||[],{field:a}=t||{};return Array.isArray(a)&&a.length>1&&i.push(a[0]),s.jsx(r.BlockProvider,H(F({name:"map"},e),{runWhenParamsChanged:!0,params:H(F({},n),{appends:i,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(Ot,F({},e))}))},ye=()=>h.useContext(ke),Ve=()=>{var o,t,n,l,i,a;const e=ye();return H(F({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((l=(n=e==null?void 0:e.field)==null?void 0:n.componentProps)==null?void 0:l.zoom)||13,lineSort:(a=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:a.lineSort})},Dt=e=>s.jsx(r.SchemaComponentOptions,{scope:{useMapBlockProps:Ve},components:{MapBlockInitializer:Ft,MapBlockDesigner:It,MapBlockProvider:Lt,MapBlock:Pt},children:e.children}),We={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 r.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},Ye=new r.CompatibleSchemaInitializer(F({name:"MapActionInitializers"},We)),Tt=new r.CompatibleSchemaInitializer(F({name:"map:configureActions"},We),Ye),He={name:"defaultZoomLevel",Component:r.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=_(),o=N.useFieldSchema(),t=N.useField(),{dn:n}=r.useDesignable(),l=((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:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:a})=>{de.set(o,"x-component-props.zoom",a),t.componentProps.zoom=a,n.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),n.refresh()}}}},zt=new r.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:r.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:r.SchemaSettingsBlockHeightItem},{name:"mapField",Component:r.SchemaSettingsCascaderItem,useComponentProps(){var A;const{getCollectionFieldsOptions:e}=r.useCollectionManager_deprecated(),{t:o}=_(),t=N.useFieldSchema(),n=((A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fieldNames)||{},l=N.useField(),{dn:i}=r.useDesignable(),{service:a}=ye(),{name:m}=r.useCollection(),b=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:n.field,options:b,allowClear:!1,onChange:C=>{const c=l.decoratorProps.fieldNames||{};c.field=C,l.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,a.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":l.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:r.SchemaSettingsSelectItem,useComponentProps(){var A;const{t:e}=_(),o=N.useFieldSchema(),t=((A=o==null?void 0:o["x-decorator-props"])==null?void 0:A.fieldNames)||{},{service:n}=ye(),l=N.useField(),{dn:i}=r.useDesignable(),{getCollectionFieldsOptions:a}=r.useCollectionManager_deprecated(),{name:m}=r.useCollection(),b=a(m,"string");return{title:e("Marker field"),value:t.marker,options:b,onChange:C=>{const c=l.decoratorProps.fieldNames||{};c.marker=C,l.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,n.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":l.decoratorProps}}),i.refresh()}}},useVisible(){var a,m;const e=N.useFieldSchema(),{getCollectionFieldsOptions:o}=r.useCollectionManager_deprecated(),{name:t}=r.useCollection(),n=((a=e==null?void 0:e["x-decorator-props"])==null?void 0:a.fieldNames)||{},l=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=_e(n.field,l))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:r.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=_();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},r.setDataLoadingModeSettingsItem,He,{name:"dataScope",Component:r.SchemaSettingsDataScope,useComponentProps(){var a,m;const{name:e}=r.useCollection(),o=N.useFieldSchema(),{form:t}=r.useFormBlockContext(),n=N.useField(),{service:l}=ye(),{dn:i}=r.useDesignable();return{collectionName:e,defaultFilter:((m=(a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.params)==null?void 0:m.filter)||{},form:t,onSubmit:({filter:b})=>{var C,c;const A=n.decoratorProps.params||{};A.filter=b,n.decoratorProps.params=A,o["x-decorator-props"].params=A,(c=(C=l.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:r.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=_();return{type:r.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:r.SchemaSettingsTemplate,useComponentProps(){var n,l;const{name:e}=r.useCollection(),o=N.useFieldSchema(),t=((n=o==null?void 0:o["x-decorator-props"])==null?void 0:n.resource)||((l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Bt}=r.interfacesProperties;Array.isArray(r.interfacesProperties.type.enum)&&r.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class be extends r.CollectionFieldInterface{constructor(){super(...arguments);O(this,"properties",H(F({},Bt),{"uiSchema.x-component-props.mapType":{title:X("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:Ee}}))}schemaInitialize(t,{block:n}){n==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Ut extends be{constructor(){super(...arguments);O(this,"name","circle");O(this,"type","object");O(this,"group","map");O(this,"order",3);O(this,"title",X("Circle"));O(this,"availableTypes",["circle"]);O(this,"description",X("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 Kt extends be{constructor(){super(...arguments);O(this,"name","lineString");O(this,"type","object");O(this,"group","map");O(this,"order",2);O(this,"title",X("Line"));O(this,"description",X("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 Nt extends be{constructor(){super(...arguments);O(this,"name","point");O(this,"type","object");O(this,"group","map");O(this,"order",1);O(this,"title",X("Point"));O(this,"description",X("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 Gt extends be{constructor(){super(...arguments);O(this,"name","polygon");O(this,"type","object");O(this,"group","map");O(this,"order",4);O(this,"title",X("Polygon"));O(this,"description",X("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 jt=[Nt,Gt,Kt,Ut],qt=new r.SchemaSettings({name:"fieldSettings:component:Map",items:[He]}),Je=h.memo(e=>s.jsx(r.SchemaComponentOptions,{components:{Map:qe},children:s.jsx(Dt,{children:e.children})}));Je.displayName="MapProvider";class Ze extends r.Plugin{load(){return Me(this,null,function*(){this.app.use(Je),this.app.dataSourceManager.addFieldInterfaces(jt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(Ye),this.app.schemaInitializerManager.add(Tt),this.schemaSettingsManager.add(zt),this.schemaSettingsManager.add(qt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(ge,{title:`{{t("Map Manager", { ns: "${ge}" })}}`,icon:"EnvironmentOutlined",Component:ct,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ve})})}}z.PluginMapClient=Ze,z.default=Ze,Object.defineProperties(z,{__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.
|
|
11
|
+
"@nocobase/client": "1.3.0-alpha.20240710141659",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/server": "1.
|
|
14
|
-
"@nocobase/test": "1.
|
|
13
|
+
"@nocobase/server": "1.3.0-alpha.20240710141659",
|
|
14
|
+
"@nocobase/test": "1.3.0-alpha.20240710141659",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
@@ -20,9 +20,8 @@ module.exports = {
|
|
|
20
20
|
"antd": "5.12.8",
|
|
21
21
|
"@formily/shared": "2.3.0",
|
|
22
22
|
"ahooks": "3.7.8",
|
|
23
|
-
"react-router-dom": "6.21.0",
|
|
24
23
|
"@formily/core": "2.3.0",
|
|
25
24
|
"react-i18next": "11.18.6",
|
|
26
|
-
"@nocobase/actions": "1.
|
|
27
|
-
"@nocobase/database": "1.
|
|
25
|
+
"@nocobase/actions": "1.3.0-alpha.20240710141659",
|
|
26
|
+
"@nocobase/database": "1.3.0-alpha.20240710141659"
|
|
28
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.
|
|
5
|
+
"version": "1.3.0-alpha.20240710141659",
|
|
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": "cb8b234443034da0dfa57dd5d6cca1f3b3db6f08",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Blocks"
|
|
42
42
|
]
|