@tachybase/plugin-block-map 1.3.16 → 1.3.17
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 +14 -14
- package/dist/externalVersion.js +6 -6
- package/dist/index.js +4 -4
- package/package.json +9 -9
package/dist/client/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(N,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react/jsx-runtime"),require("react"),require("@tachybase/client"),require("@tachybase/schema"),require("@ant-design/icons"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tachybase/client","@tachybase/schema","@ant-design/icons","ahooks","antd","react-router-dom","lodash","@tachybase/components"],i):(N=typeof globalThis!="undefined"?globalThis:N||self,i(N["@tachybase/plugin-block-map"]={},N.jsxRuntime,N.react,N["@tachybase/client"],N["@tachybase/schema"],N["@ant-design/icons"],N.ahooks,N.antd,N["react-router-dom"],N.lodash,N["@tachybase/components"]))})(this,function(N,i,f,a,B,ee,q,P,te,ce,je){"use strict";var Tt=Object.defineProperty,Dt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var Ge=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var _e=(N,i,f)=>i in N?Tt(N,i,{enumerable:!0,configurable:!0,writable:!0,value:f}):N[i]=f,F=(N,i)=>{for(var f in i||(i={}))Bt.call(i,f)&&_e(N,f,i[f]);if(Ge)for(var f of Ge(i))Kt.call(i,f)&&_e(N,f,i[f]);return N},Y=(N,i)=>Dt(N,zt(i));var me=(N,i,f)=>new Promise((a,B)=>{var ee=te=>{try{P(f.next(te))}catch(ce){B(ce)}},q=te=>{try{P(f.throw(te))}catch(ce){B(ce)}},P=te=>te.done?a(te.value):Promise.resolve(te.value).then(ee,q);P((f=f.apply(N,i)).next())});const he="block-map";function X(e){return a.tval(e,{ns:[he,"core"]})}function J(){return a.useTranslation([he,"core"])}const Pe=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],ye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",pe="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==",Ie=(e,o,t)=>{const r=o==null?void 0:o.reduce((n,s,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?n==null?void 0:n.map(m=>m[s]).filter(m=>m!=null):n==null?void 0:n[s],e);return t==="o2m"||t==="m2m"?r:[r]};var qe=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ke={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(qe,function(){function t(c){var y=[];return c.AMapUI&&y.push(r(c.AMapUI)),c.Loca&&y.push(n(c.Loca)),Promise.all(y)}function r(c){return new Promise(function(y,p){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===s.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===s.notload){m.AMapUI=s.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(w){m.AMapUI=s.failed,p("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=s.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var w=0,G=d.length;w<G;w++){var W=d[w].split("/").slice(-1)[0];window.AMapUI[W]=arguments[w]}for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},L.appendChild(K)}else m.AMapUI===s.loaded?c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var w=0,G=d.length;w<G;w++){var W=d[w].split("/").slice(-1)[0];window.AMapUI[W]=arguments[w]}y()}):y():c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(w){w?p(w):d.length?window.AMapUI.loadUI(d,function(){for(var G=0,W=d.length;G<W;G++){var U=d[G].split("/").slice(-1)[0];window.AMapUI[U]=arguments[G]}y()}):y()})})}function n(c){return new Promise(function(y,p){if(m.Loca===s.failed)p("前次请求 Loca 失败");else if(m.Loca===s.notload){m.Loca=s.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)p("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(w){m.Loca=s.failed,p("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=s.loaded,y();v.Loca.length;)v.Loca.splice(0,1)[0]()},L.appendChild(K)}}else m.Loca===s.loaded?c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):v.Loca.push(function(w){w?p(w):p()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var s;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(s||(s={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMapUI:[],Loca:[]},S=[],A=function(c){typeof c=="function"&&(m.AMap===s.loaded?c(window.AMap):S.push(c))};return{load:function(c){return new Promise(function(y,p){if(m.AMap==s.failed)p("");else if(m.AMap==s.notload){var d=c.key,M=c.version,L=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=L||l.AMap.plugins,m.AMap=s.loading,M=document.body||document.head,window.___onAPILoaded=function(w){if(delete window.___onAPILoaded,w)m.AMap=s.failed,p(w);else for(m.AMap=s.loaded,t(c).then(function(){y(window.AMap)}).catch(p);S.length;)S.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(w){m.AMap=s.failed,p(w)},M.appendChild(L)):p("请填写key")}else if(m.AMap==s.loaded)if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 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(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)}else if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 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]);A(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)})}})},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:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(ke);var We=ke.exports;const Ye=Ve(We),Fe="map-configuration",be=e=>`TACHYBASE_PLUGIN_MAP_CONFIGURATION_${e}`,ve=(e,o=!0)=>{const t=f.useMemo(()=>{const n=sessionStorage.getItem(be(e));return n&&JSON.parse(n)},[e]),{data:r}=a.useRequest({resource:Fe,action:"get",params:{isRaw:!o,type:e}},{onSuccess(n){o&&sessionStorage.setItem(be(e),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!(t&&o)});return t&&o?t:r==null?void 0:r.data},Je=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),n=f.useRef(),[s,l]=f.useState([]);f.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{n.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=q.useDebounceFn(S=>{n.current&&n.current.search(S||" ",(A,c)=>{if(A==="complete")l(c.poiList.pois.map(y=>Y(F({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(A==="no_data"){l([]);return}P.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=S=>{const A=s.find(c=>c.value===S);A!=null&&A.location&&t(A.location)};return i.jsx("div",{className:a.css`
|
|
1
|
+
(function(N,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react/jsx-runtime"),require("react"),require("@tachybase/client"),require("@tachybase/schema"),require("@ant-design/icons"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@tachybase/client","@tachybase/schema","@ant-design/icons","ahooks","antd","react-router-dom","lodash","@tachybase/components"],i):(N=typeof globalThis!="undefined"?globalThis:N||self,i(N["@tachybase/plugin-block-map"]={},N.jsxRuntime,N.react,N["@tachybase/client"],N["@tachybase/schema"],N["@ant-design/icons"],N.ahooks,N.antd,N["react-router-dom"],N.lodash,N["@tachybase/components"]))})(this,function(N,i,f,a,B,ee,j,P,te,ce,je){"use strict";var zt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var _e=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var qe=(N,i,f)=>i in N?zt(N,i,{enumerable:!0,configurable:!0,writable:!0,value:f}):N[i]=f,F=(N,i)=>{for(var f in i||(i={}))Ut.call(i,f)&&qe(N,f,i[f]);if(_e)for(var f of _e(i))Nt.call(i,f)&&qe(N,f,i[f]);return N},Y=(N,i)=>Bt(N,Kt(i));var he=(N,i,f)=>new Promise((a,B)=>{var ee=te=>{try{P(f.next(te))}catch(ce){B(ce)}},j=te=>{try{P(f.throw(te))}catch(ce){B(ce)}},P=te=>te.done?a(te.value):Promise.resolve(te.value).then(ee,j);P((f=f.apply(N,i)).next())});const ye="block-map";function X(e){return a.tval(e,{ns:[ye,"core"]})}function J(){return a.useTranslation([ye,"core"])}const Ie=[{label:X("AMap"),value:"amap"},{label:X("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",pe="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==",ke=(e,o,t)=>{const r=o==null?void 0:o.reduce((n,s,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?n==null?void 0:n.map(m=>m[s]).filter(m=>m!=null):n==null?void 0:n[s],e);return t==="o2m"||t==="m2m"?r:[r]};function Ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var de={exports:{}},We=de.exports,Fe;function Ye(){return Fe||(Fe=1,function(e,o){(function(t,r){e.exports=r()})(We,function(){function t(c){var y=[];return c.AMapUI&&y.push(r(c.AMapUI)),c.Loca&&y.push(n(c.Loca)),Promise.all(y)}function r(c){return new Promise(function(y,p){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===s.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===s.notload){m.AMapUI=s.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var D=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(w){m.AMapUI=s.failed,p("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=s.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var w=0,G=d.length;w<G;w++){var W=d[w].split("/").slice(-1)[0];window.AMapUI[W]=arguments[w]}for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(y();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},D.appendChild(K)}else m.AMapUI===s.loaded?c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var w=0,G=d.length;w<G;w++){var W=d[w].split("/").slice(-1)[0];window.AMapUI[W]=arguments[w]}y()}):y():c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(w){w?p(w):d.length?window.AMapUI.loadUI(d,function(){for(var G=0,W=d.length;G<W;G++){var U=d[G].split("/").slice(-1)[0];window.AMapUI[U]=arguments[G]}y()}):y()})})}function n(c){return new Promise(function(y,p){if(m.Loca===s.failed)p("前次请求 Loca 失败");else if(m.Loca===s.notload){m.Loca=s.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),D=d.startsWith("2");if(M&&!D||!M&&D)p("JSAPI 与 Loca 版本不对应!!");else{M=l.key,D=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(w){m.Loca=s.failed,p("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=s.loaded,y();v.Loca.length;)v.Loca.splice(0,1)[0]()},D.appendChild(K)}}else m.Loca===s.loaded?c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):v.Loca.push(function(w){w?p(w):p()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var s;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(s||(s={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMapUI:[],Loca:[]},x=[],A=function(c){typeof c=="function"&&(m.AMap===s.loaded?c(window.AMap):x.push(c))};return{load:function(c){return new Promise(function(y,p){if(m.AMap==s.failed)p("");else if(m.AMap==s.notload){var d=c.key,M=c.version,D=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=D||l.AMap.plugins,m.AMap=s.loading,M=document.body||document.head,window.___onAPILoaded=function(w){if(delete window.___onAPILoaded,w)m.AMap=s.failed,p(w);else for(m.AMap=s.loaded,t(c).then(function(){y(window.AMap)}).catch(p);x.length;)x.splice(0,1)[0]()},D=document.createElement("script"),D.type="text/javascript",D.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),D.onerror=function(w){m.AMap=s.failed,p(w)},M.appendChild(D)):p("请填写key")}else if(m.AMap==s.loaded)if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 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(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)}else if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 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]);A(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){y(window.AMap)}).catch(p)}):t(c).then(function(){y(window.AMap)}).catch(p)})}})},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:s.notload,AMapUI:s.notload,Loca:s.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})}(de)),de.exports}var Je=Ye();const Ze=Ve(Je),Oe="map-configuration",ve=e=>`TACHYBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Ae=(e,o=!0)=>{const t=f.useMemo(()=>{const n=sessionStorage.getItem(ve(e));return n&&JSON.parse(n)},[e]),{data:r}=a.useRequest({resource:Oe,action:"get",params:{isRaw:!o,type:e}},{onSuccess(n){o&&sessionStorage.setItem(ve(e),JSON.stringify(n==null?void 0:n.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!(t&&o)});return t&&o?t:r==null?void 0:r.data},Xe=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),n=f.useRef(),[s,l]=f.useState([]);f.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{n.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=j.useDebounceFn(x=>{n.current&&n.current.search(x||" ",(A,c)=>{if(A==="complete")l(c.poiList.pois.map(y=>Y(F({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(A==="no_data"){l([]);return}P.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=x=>{const A=s.find(c=>c.value===x);A!=null&&A.location&&t(A.location)};return i.jsx("div",{className:a.css`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 10px;
|
|
4
4
|
left: 10px;
|
|
5
5
|
z-index: 10;
|
|
6
6
|
width: calc(100% - 20px);
|
|
7
|
-
`,children:i.jsx(P.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:s,popupMatchSelectWidth:!1})})},
|
|
7
|
+
`,children:i.jsx(P.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:s,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=f.forwardRef((e,o)=>{const{accessKey:t,securityJsCode:r}=Ae(e.mapType)||{},{value:n,onChange:s,block:l=!1,readonly:m,disabled:v=l,zoom:x=13,overlayCommonOptions:A}=e,{t:c}=J(),y=B.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[D,K]=f.useState([]),[w,G]=f.useState(""),{getField:W}=a.useCollection_deprecated(),U=f.useMemo(()=>{if(e.type)return e.type;const g=W(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),L=f.useRef(),T=f.useRef(null),$=te.useNavigate(),H=f.useRef(`tachybase-map-${U||""}-${Date.now().toString(32)}`),{modal:R}=P.App.useApp(),[Z]=f.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},A)),ne=j.useMemoizedFn(()=>{L.current&&L.current.remove()}),oe=j.useMemoizedFn(()=>{(!v||l)&&U!=="point"&&T.current&&(T.current.setTarget(L.current),T.current.open())}),I=j.useMemoizedFn((g,u=!1)=>{let h=null;if(U==="point"){const{lat:C,lng:z}=g.getPosition();h=[z,C]}else if(U==="polygon"||U==="lineString"){if(h=g.getPath().map(C=>[C.lng,C.lat]),h.length<2)return}else if(U==="circle"){const C=g.getCenter(),z=g.getRadius();h=[C.lng,C.lat,z]}u||(ne(),L.current=g,oe()),s==null||s(h)}),V=j.useMemoizedFn((g=U)=>{const u=Me[g];if(u&&"editor"in u&&!T.current)return T.current=new p.current[u.editor](d.current,null,{createOptions:Z,editOptions:Z,controlPoint:Y(F({},Z),{strokeWeight:3}),midControlPoint:Y(F({},Z),{strokeWeight:2,fillColor:"#fff"})}),T.current.on("adjust",function({target:h}){I(h,!0)}),T.current.on("move",function({target:h}){I(h,!0)}),T.current}),O=j.useMemoizedFn((g=U)=>{var h;if(!M.current||(h=T.current)!=null&&h.getTarget())return;const u=Me[g];u&&M.current[u.mouseTool](F({},Z))}),Q=j.useMemoizedFn((g=U)=>{M.current||(M.current=new p.current.MouseTool(d.current),M.current.on("draw",function({obj:u}){I(u)}),O(g))}),S=(g,u)=>{d.current&&d.current.setZoomAndCenter(18,g,u)},E=()=>{const g=()=>{ne(),T.current&&(T.current.setTarget(),T.current.close()),s==null||s(null)};R.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(){g()}})},b=()=>{L.current&&d.current.setFitView([L.current])},k=f.useCallback((g=U,u=n,h)=>{const C=Me[g];if(!C)return;const z=F(F({},Z),h);return"transformOptions"in C?Object.assign(z,C.transformOptions(u)):"propertyKey"in C&&(z[C.propertyKey]=u),new p.current[C.overlay](z)},[Z]),_=(g=U,u=n,h)=>{if(!p.current)return;const C=k(g,u,h);return C.setMap(d.current),C};f.useEffect(()=>{if(!p.current||!n||!m&&L.current)return;const g=_();d.current.setFitView([g]),L.current=g,v||(V(),oe())},[n,D,U,Z,v,m]),f.useEffect(()=>{var g,u,h;M.current&&(v?((g=M.current)==null||g.close(),(u=T.current)==null||u.close()):(O(),(h=T.current)==null||h.open()))},[v]),f.useEffect(()=>{!p.current||!U||v||(Q(),V())},[v,D,U]),f.useEffect(()=>{var u,h;if(!n&&(M.current||T.current)&&(ne(),T.current&&(T.current.setTarget(),T.current.close()),s==null||s(null)),!M.current||!T.current)return;T.current.getTarget()?(h=(u=M.current).close)==null||h.call(u):O()},[U,n]),f.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const g=window.define;return window.define=void 0,Ze.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(u=>(window.define=g,requestIdleCallback(()=>{d.current=new u.Map(H.current,{resizeEnable:!0,zoom:x}),p.current=u,G(""),K([])}))).catch(u=>{typeof u=="string"?u.includes("多个不一致的 key")?G(c("The AccessKey is incorrect, please check it")):G(u):(u==null?void 0:u.type)==="error"&&G("Something went wrong, please refresh the page and try again")}),()=>{var u;(u=d.current)==null||u.destroy(),p.current=null,d.current=null,M.current=null,T.current=null}},[t,U,r]),f.useImperativeHandle(o,()=>({setOverlay:_,getOverlay:k,createMouseTool:Q,createEditor:V,executeMouseTool:O,aMap:p.current,map:d.current,overlay:L.current,mouseTool:()=>M.current,editor:()=>T.current,errMessage:w}));const q=a.useApp();return!t||w?i.jsx(P.Alert,{action:i.jsx(P.Button,{type:"primary",onClick:()=>$(q.systemSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:w||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):i.jsxs("div",{className:a.css`
|
|
8
8
|
position: relative;
|
|
9
9
|
height: 500px;
|
|
10
10
|
`,id:H.current,style:e==null?void 0:e.style,children:[!p.current&&i.jsx("div",{className:a.css`
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
justify-content: center;
|
|
16
|
-
`,children:i.jsx(P.Spin,{})}),v?null:i.jsxs(i.Fragment,{children:[i.jsx(
|
|
16
|
+
`,children:i.jsx(P.Spin,{})}),v?null:i.jsxs(i.Fragment,{children:[i.jsx(Xe,{toCenter:S,aMap:p.current}),i.jsx("div",{className:a.css`
|
|
17
17
|
position: absolute;
|
|
18
18
|
bottom: 80px;
|
|
19
19
|
right: 20px;
|
|
20
20
|
z-index: 10;
|
|
21
|
-
`,children:i.jsx(P.Button,{onClick:b,disabled:!
|
|
21
|
+
`,children:i.jsx(P.Button,{onClick:b,disabled:!L.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),U!=="point"?i.jsx("div",{className:a.css`
|
|
22
22
|
position: absolute;
|
|
23
23
|
bottom: 20px;
|
|
24
24
|
left: 10px;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
bottom: 20px;
|
|
30
30
|
right: 20px;
|
|
31
31
|
z-index: 2;
|
|
32
|
-
`,children:i.jsx(P.Button,{disabled:!n,style:{height:"40px"},onClick:E,type:"primary",danger:!0,children:c("Clear")})})]})]})});
|
|
32
|
+
`,children:i.jsx(P.Button,{disabled:!n,style:{height:"40px"},onClick:E,type:"primary",danger:!0,children:c("Clear")})})]})]})});Ce.displayName="AMapComponent";const He=e=>{var I,V,O,Q;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:n,zoom:s,setSelectedRecordKeys:l,lineSort:m}=a.useProps(e),{name:v,getPrimaryKey:x}=a.useCollection_deprecated(),{getCollectionJoinField:A}=a.useCollectionManager_deprecated(),c=x(),[y,p]=f.useState(!1),d=f.useRef(),M=(V=(I=d.current)==null?void 0:I.aMap)==null?void 0:V.GeometryUtil,[D,K]=f.useState(),[w,G]=f.useState(""),{t:W}=J(),U=a.useCompile(),{isConnected:L,doFilter:T}=a.useFilterAPI(),[,$]=f.useState(null),H=f.useRef(w);H.current=w;const R=(S,E)=>{const b=S.getExtData(),k=typeof E=="undefined"?b.selected:!E;b.selected=!k,"setIcon"in S&&S.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:k?pe:be})),S.setOptions(F({extData:b},k?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},Z=()=>{var S,E,b;d.current&&((S=d.current)==null||S.mouseTool().close(!0),(E=d.current)==null||E.editor().setTarget(null),(b=d.current)==null||b.editor().close())};f.useEffect(()=>{var S,E,b,k;if(w==="selection")return(S=d.current)!=null&&S.editor()?(k=d.current)==null||k.executeMouseTool("polygon"):((E=d.current)==null||E.createEditor("polygon"),(b=d.current)==null||b.createMouseTool("polygon")),()=>{Z()}},[w]),f.useEffect(()=>{if(w)return()=>{var S;H.current||(S=d.current)==null||S.map.getAllOverlays().forEach(E=>{R(E,!1)})}},[w]);const ne=j.useMemoizedFn(()=>{var _,q,g;const S=(_=d.current)==null?void 0:_.editor().getTarget(),E=(q=d.current)==null?void 0:q.map.getAllOverlays(),b=E==null?void 0:E.filter(u=>{if(!(u===S||u.getExtData().id===void 0))return"getPosition"in u?M.isPointInRing(u.getPosition(),S==null?void 0:S.getPath()):M.doesRingRingIntersect(u.getPath(),S==null?void 0:S.getPath())}),k=b==null?void 0:b.map(u=>(R(u,!0),u.getExtData().id));l(u=>k==null?void 0:k.concat(u)),S==null||S.remove(),(g=d.current)==null||g.editor().close()});f.useEffect(()=>{var _,q,g;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,E=A([v,...S].flat().join(".")),b=r.map(u=>{var C;const h=(C=ke(u,t==null?void 0:t.field,E==null?void 0:E.interface))==null?void 0:C.filter(Boolean);return h!=null&&h.length?h.map(z=>{var se;return(se=d.current)==null?void 0:se.setOverlay(o.type,z,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?U(u[t.marker]):void 0},extData:{id:u[c]}})}):[]}).flat().filter(Boolean);(q=(_=d.current)==null?void 0:_.map)==null||q.setFitView(b);const k=b.map(u=>{const h=C=>{const z=C.target,re=z.getExtData();if(!re)return;if(H.current){H.current==="click"&&(l(ie=>re.selected?ie.filter(Pe=>Pe!==re.id):[...ie,re.id]),R(z));return}const se=r.find(ie=>re.id===ie[c]);if(L){$(ie=>(ie&&Ee(ie),ie===u?(Ee(u),T(null),null):($e(u),T(se[c],Pe=>Pe.field||c,"$eq"),u)));return}se&&K(se)};return u.on("click",h),()=>u.off("click",h)});if(o.type==="point"&&(m!=null&&m.length)&&(b==null?void 0:b.length)>1){const u=b.map(C=>C.getPosition());b[0].setzIndex(13),b[b.length-1].setzIndex(13);const h=(C=!0)=>{var z,re;if((z=d.current)!=null&&z.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:W(C?"Start point":"End point")},position:u[C?0:u.length-1],map:(re=d.current)==null?void 0:re.map})};b.push(...[(g=d.current)==null?void 0:g.setOverlay("lineString",u,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),h(),h(!1)].filter(Boolean))}return()=>{b.forEach(u=>{u.remove()}),k.forEach(u=>u())}},[r,y,t,v,c,o.type,L,m]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=S=>{d.current=S,p(!!(S!=null&&S.map)&&!S.errMessage)};return i.jsxs("div",{className:a.css`
|
|
33
33
|
position: relative;
|
|
34
34
|
height: 100%;
|
|
35
35
|
`,children:[i.jsx("div",{className:a.css`
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
left: 10px;
|
|
38
38
|
top: 10px;
|
|
39
39
|
z-index: 999;
|
|
40
|
-
`,children:y&&!((O=d.current)!=null&&O.errMessage)?i.jsxs(P.Space,{direction:"vertical",children:[i.jsx(P.Button,{style:{color:w?void 0:"#F18b62",borderColor:"currentcolor"},onClick:
|
|
40
|
+
`,children:y&&!((O=d.current)!=null&&O.errMessage)?i.jsxs(P.Space,{direction:"vertical",children:[i.jsx(P.Button,{style:{color:w?void 0:"#F18b62",borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),G("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(P.Button,{style:{color:w==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:S=>{S.stopPropagation(),G("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),w==="selection"?i.jsx(P.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:W("Confirm selection"),onClick:ne}):null]}):null}),i.jsx(Qe,{record:D,setVisible:K}),i.jsx(Ce,Y(F({},(Q=o==null?void 0:o.uiSchema)==null?void 0:Q["x-component-props"]),{ref:oe,style:{height:n?"100%":null},zoom:s,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},Qe=e=>{const{setVisible:o,record:t}=e,r=a.useCollectionParentRecordData(),n=B.useFieldSchema(),s=f.useMemo(()=>n.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[n]);return s&&i.jsx(a.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:i.jsx(a.RecordProvider,{record:t,parent:r,children:i.jsx(B.RecursionField,{schema:s,name:s.name})})})};function Ee(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function $e(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 De=({type:e,children:o})=>{const{t}=J(),[r,n]=j.useBoolean(!1),s=a.useAPIClient(),[l]=P.Form.useForm(),m=Ae(e);f.useEffect(()=>{m&&(l.setFieldsValue(m),n.toggle())},[m]);const v=f.useMemo(()=>s.resource(Oe),[s]),x=A=>{v.set(Y(F({},A),{type:e})).then(c=>{sessionStorage.removeItem(ve(e)),n.toggle(),P.message.success(t("Saved successfully"))}).catch(c=>{P.message.success(t("Saved failed"))})};return i.jsxs(P.Form,{disabled:r,form:l,layout:"vertical",onFinish:x,children:[o,r?i.jsx(P.Button,{disabled:!1,onClick:n.toggle,children:t("Edit")}):i.jsx(P.Form.Item,{children:i.jsx(P.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},Re={amap:()=>{const{t:e}=J();return i.jsxs(De,{type:"amap",children:[i.jsx(P.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:i.jsx(a.TextAreaWithGlobalScope,{})}),i.jsx(P.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:i.jsx(a.TextAreaWithGlobalScope,{})})]})},google:()=>{const{t:e}=J();return i.jsx(De,{type:"google",children:i.jsx(P.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:i.jsx(a.TextAreaWithGlobalScope,{})})})}},et=Ie.map(e=>Y(F({},e),{component:Re[e.value]})),tt=()=>{const e=a.useCompile(),o=te.useLocation(),t=new URLSearchParams(o.search);return i.jsx(P.Card,{bordered:!0,children:i.jsx(P.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:et.map(r=>i.jsx(P.Tabs.TabPane,{tab:e(r.label),children:i.jsx(r.component,{type:r.value})},r.value))})})};function ot(e,o,t,r){function n(s){return s instanceof t?s:new t(function(l){l(s)})}return new(t||(t=Promise))(function(s,l){function m(A){try{x(r.next(A))}catch(c){l(c)}}function v(A){try{x(r.throw(A))}catch(c){l(c)}}function x(A){A.done?s(A.value):n(A.value).then(m,v)}x((r=r.apply(e,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;function rt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nt=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,n,s;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(n=r;n--!==0;)if(!e(o[n],t[n]))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(s=Object.keys(o),r=s.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[n]))return!1;for(n=r;n--!==0;){var l=s[n];if(!e(o[l],t[l]))return!1}return!0}return o!==o&&t!==t},st=rt(nt);const Le="__googleMapsScriptId";var ue;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(ue||(ue={}));class ae{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:n,id:s=Le,language:l,libraries:m=[],mapIds:v,nonce:x,region:A,retries:c=3,url:y="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=r,this.client=n,this.id=s||Le,this.language=l,this.libraries=m,this.mapIds=v,this.nonce=x,this.region=A,this.retries=c,this.url=y,this.version=p,ae.instance){if(!st(this.options,ae.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ae.instance.options)}`);return ae.instance}ae.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?ue.FAILURE:this.done?ue.SUCCESS:this.loading?ue.LOADING:ue.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let o=this.url;return o+="?callback=__googleMapsCallback&loading=async",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(s=>!r[s]&&delete r[s]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(s=>{let l,m,v,x="The Google Maps JavaScript API",A="google",c="importLibrary",y="__ib__",p=document,d=window;d=d[A]||(d[A]={});const M=d.maps||(d.maps={}),D=new Set,K=new URLSearchParams,w=()=>l||(l=new Promise((G,W)=>ot(this,void 0,void 0,function*(){var U;yield m=p.createElement("script"),m.id=this.id,K.set("libraries",[...D]+"");for(v in s)K.set(v.replace(/[A-Z]/g,L=>"_"+L[0].toLowerCase()),s[v]);K.set("callback",A+".maps."+y),m.src=this.url+"?"+K,M[y]=G,m.onerror=()=>l=W(Error(x+" could not load.")),m.nonce=this.nonce||((U=p.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",p.head.append(m)})));M[c]?console.warn(x+" only loads once. Ignoring:",s):M[c]=(G,...W)=>D.add(G)&&w().then(()=>M[c](G,...W))})(r);const n=this.libraries.map(s=>this.importLibrary(s));n.length||n.push(this.importLibrary("core")),Promise.all(n).then(()=>this.callback(),s=>{const l=new ErrorEvent("error",{error:s});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.loading)if(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=!0,this.setScript()}}}const it=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=J(),n=f.useRef(),[s,l]=f.useState([]);f.useEffect(()=>{google.maps.importLibrary("places").then(x=>{n.current=new x.AutocompleteService}).catch(()=>{P.message.error("Please configure the Google API Key correctly")})},[t]);const{run:m}=j.useDebounceFn(x=>{n.current&&n.current.getPlacePredictions({input:x||" "},(A,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(A.map(y=>{const p=y.structured_formatting;return Y(F({},y),{label:`${p.main_text}${p.secondary_text?" "+p.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),v=x=>{const A=s.find(y=>y.value===x);new google.maps.places.PlacesService(t.current).getDetails({placeId:A.place_id,fields:["geometry"]},(y,p)=>{p===google.maps.places.PlacesServiceStatus.OK&&o(y.geometry.location)})};return i.jsx("div",{className:a.css`
|
|
41
41
|
position: absolute;
|
|
42
42
|
top: 10px;
|
|
43
43
|
left: 10px;
|
|
44
44
|
z-index: 10;
|
|
45
45
|
width: calc(100% - 20px);
|
|
46
|
-
`,children:i.jsx(P.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:s})})},le=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),
|
|
46
|
+
`,children:i.jsx(P.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:s})})},le=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),at=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:n}=t.coords;e({lat:r,lng:n})},()=>{o()}):o()}),lt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ct={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=f.forwardRef((e,o)=>{const{value:t,onChange:r,block:n=!1,readonly:s,disabled:l=n,zoom:m=13,overlayCommonOptions:v}=e,{accessKey:x}=Ae(e.mapType)||{},{t:A}=J(),{getField:c}=a.useCollection_deprecated(),y=B.useFieldSchema(),p=f.useRef(),d=f.useRef(),M=f.useRef(),[D,K]=f.useState([]),[w,G]=f.useState(""),W=a.useAPIClient(),{modal:U}=P.App.useApp(),L=f.useMemo(()=>{if(e.type)return e.type;const g=c(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),T=f.useRef(lt(L)),[$]=f.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},v)),H=te.useNavigate(),R=f.useRef(),Z=f.useRef(new Set),ne=j.useMemoizedFn(g=>{if(Z.current.forEach(u=>{Z.current.delete(u)}),"getPath"in g){const u=g.getPath();["insert_at","remove_at","set_at"].forEach(h=>{Z.current.add(u.addListener(h,()=>{S(g,!0)}).remove)})}else g instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{Z.current.add(g.addListener(u,()=>{S(g,!0)}).remove)})}),oe=j.useMemoizedFn(()=>{var g;M.current&&(M.current.unbindAll(),M.current.setMap(null)),L!=="point"&&((g=p.current)==null||g.setDrawingMode(null))}),I=j.useMemoizedFn(g=>{d.current&&(d.current.setCenter(g),d.current.setZoom(m))}),V=j.useMemoizedFn(g=>{oe(),ne(g),M.current=g}),O=j.useMemoizedFn(g=>{const u=new google.maps.LatLngBounds;g.forEach(h=>{if(h instanceof google.maps.Marker)u.extend(h.getPosition());else if(h instanceof google.maps.Polyline||h instanceof google.maps.Polygon){const C=h.getPath();for(let z=0;z<C.getLength();z++)u.extend(C.getAt(z))}else h instanceof google.maps.Circle&&u.union(h.getBounds())}),d.current.setCenter(u.getCenter())}),Q=()=>{M.current&&O([M.current])},S=j.useMemoizedFn((g,u=!1)=>{let h=null;if(L==="point"){const{lat:C,lng:z}=g.getPosition();h=[z(),C()]}else if(L==="polygon"||L==="lineString"){if(h=g.getPath().getArray().map(C=>[C.lng(),C.lat()]),h.length<2)return}else if(L==="circle"){const C=g.getCenter(),z=g.getRadius();h=[C.lng(),C.lat(),z]}u||V(g),r==null||r(h)}),E=j.useMemoizedFn((g=!1,u)=>{const h=Y(F(F({},$),u),{map:d.current});return p.current=new google.maps.drawing.DrawingManager({drawingMode:T.current,drawingControl:!1,markerOptions:Y(F({},h),{icon:le(pe)}),polygonOptions:h,polylineOptions:h,circleOptions:h,map:d.current}),g||p.current.addListener("overlaycomplete",C=>{const z=C.overlay;S(z)}),p.current}),b=j.useMemoizedFn((g=L,u=t,h)=>{const C=ct[g];if(!C)return;const z=F(Y(F({},$),{icon:le(pe)}),h);return"transformOptions"in C?Object.assign(z,C.transformOptions(u)):"propertyKey"in C&&(z[C.propertyKey]=Array.isArray(u[0])?u.map(se=>new google.maps.LatLng(se[1],se[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[C.overlay](z)}),k=j.useMemoizedFn((g=L,u=t,h)=>d.current?b(g,u,Y(F({},h),{map:d.current})):void 0);f.useEffect(()=>{var u,h;if(!t&&d.current&&(oe(),(h=(u=p==null?void 0:p.current)==null?void 0:u.setDrawingMode)==null||h.call(u,T.current),r==null||r(null)),!d.current||!t||!s&&M.current)return;const g=k();V(g),O([g])},[t,D,L,l,s,k,O,V]),f.useEffect(()=>{if(!x||d.current||!R.current)return;let g;try{g=new ae({apiKey:x,version:"weekly",language:W.auth.getLocale()})}catch(h){G(A("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(h,...C)=>{var z;(z=h==null?void 0:h.includes)!=null&&z.call(h,"InvalidKeyMapError")&&G(A("Load google maps failed, Please check the Api key and refresh the page")),u(h,...C)},Promise.all([g.importLibrary("drawing"),g.importLibrary("core"),g.importLibrary("geometry")]).then(h=>he(null,null,function*(){const C=yield at();d.current=new google.maps.Map(R.current,{zoom:m,center:C,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),G(""),K([])})).catch(h=>{if(h instanceof Error){G(h.message);return}}),()=>{var h,C;(h=d.current)==null||h.unbindAll(),d.current=null,(C=p.current)==null||C.unbindAll()}},[x,W.auth,L,m]),f.useEffect(()=>{!d.current||!L||l||p.current||E()},[E,l,D,L]),f.useImperativeHandle(o,()=>({setOverlay:k,getOverlay:b,setFitView:O,createDraw:E,map:d.current,overlay:M.current,drawingManager:p.current,errMessage:w}));const _=j.useMemoizedFn(()=>{const g=()=>{oe(),p.current.setDrawingMode(T.current),r==null||r(null)};U.confirm({title:A("Clear the canvas"),content:A("Are you sure to clear the canvas?"),okText:A("Confirm"),cancelText:A("Cancel"),getContainer:()=>R.current,onOk(){g()}})}),q=a.useApp();return!x||w?i.jsx(P.Alert,{action:i.jsx(P.Button,{type:"primary",onClick:()=>H(q.systemSettingsManager.getRoutePath("map")+"?tab=google"),children:A("Go to the configuration page")}),message:w||A("Please configure the Api key first"),type:"error"}):i.jsxs("div",{className:a.css`
|
|
47
47
|
position: relative;
|
|
48
48
|
height: 500px;
|
|
49
49
|
`,children:[!d.current&&i.jsx("div",{className:a.css`
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
display: flex;
|
|
53
53
|
align-items: center;
|
|
54
54
|
justify-content: center;
|
|
55
|
-
`,children:i.jsx(P.Spin,{})}),l?null:i.jsxs(i.Fragment,{children:[d.current&&i.jsx(
|
|
55
|
+
`,children:i.jsx(P.Spin,{})}),l?null:i.jsxs(i.Fragment,{children:[d.current&&i.jsx(it,{toCenter:I,mapRef:d}),i.jsx("div",{className:a.css`
|
|
56
56
|
position: absolute;
|
|
57
57
|
bottom: 80px;
|
|
58
58
|
right: 20px;
|
|
59
59
|
z-index: 10;
|
|
60
|
-
`,children:i.jsx(P.Button,{onClick:Q,disabled:!M.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),
|
|
60
|
+
`,children:i.jsx(P.Button,{onClick:Q,disabled:!M.current,type:"primary",shape:"round",size:"large",icon:i.jsx(ee.SyncOutlined,{})})}),L==="lineString"||L==="polygon"?i.jsx("div",{className:a.css`
|
|
61
61
|
position: absolute;
|
|
62
62
|
bottom: 20px;
|
|
63
63
|
left: 10px;
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
`,children:i.jsx(P.Button,{disabled:!t,style:{height:"40px"},onClick:_,type:"primary",danger:!0,children:A("Clear")})})]}),i.jsx("div",{ref:R,className:a.css`
|
|
72
72
|
width: 100%;
|
|
73
73
|
height: 100%;
|
|
74
|
-
`,style:e==null?void 0:e.style})]})});
|
|
74
|
+
`,style:e==null?void 0:e.style})]})});xe.displayName="GoogleMapsComponent";const fe="google-maps-overlay-id",Te="google-maps-overlay-selected",pt=a.css`
|
|
75
75
|
margin-top: 6px;
|
|
76
76
|
padding: 2px 4px;
|
|
77
77
|
background: #fff;
|
|
78
78
|
border: 1px solid #0000f5;
|
|
79
|
-
`,
|
|
79
|
+
`,ut=a.css`
|
|
80
80
|
margin-top: -64px;
|
|
81
81
|
padding: 2px 4px;
|
|
82
82
|
background: #fff;
|
|
83
83
|
border: 1px solid #0000f5;
|
|
84
|
-
`,
|
|
84
|
+
`,dt=e=>{const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:n,zoom:s,setSelectedRecordKeys:l,lineSort:m}=a.useProps(e),{getPrimaryKey:v}=a.useCollection_deprecated(),x=v(),{marker:A="id"}=t,[c,y]=f.useState(!1),p=f.useRef(),[d,M]=f.useState(),[D,K]=f.useState(""),{t:w}=J(),G=a.useCompile(),{isConnected:W,doFilter:U}=a.useFilterAPI(),[,L]=f.useState(null),T=f.useRef(D),$=f.useRef(null),H=f.useRef([]);T.current=D;const{getCollectionJoinField:R}=a.useCollectionManager_deprecated(),Z=(I,V)=>{const O=typeof V!="undefined"?!V:I.get(Te);I.set(Te,!O),I.setOptions(F({},O?{icon:le(pe),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:le(be),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var V,O,Q,S;if(D!=="selection")return;p.current&&!((V=p.current)!=null&&V.drawingManager)&&(p.current.drawingManager=(O=p.current)==null?void 0:O.createDraw(!0,{editable:!0,draggable:!0}));const I=new Set;return(Q=p.current)==null||Q.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(S=p.current)==null||S.drawingManager.addListener("overlaycomplete",E=>{var _;const b=E.overlay;(_=p.current)==null||_.drawingManager.setDrawingMode(null),$.current=b;const k=b.getPath();["insert_at","remove_at","set_at"].forEach(q=>{I.add(k.addListener(q,()=>{}).remove)})}),()=>{var E,b,k,_;I.forEach(q=>{q()}),p.current&&((E=$.current)==null||E.unbindAll(),(b=$.current)==null||b.setMap(null),$.current=null,(k=p.current)==null||k.drawingManager.setDrawingMode(null),(_=p.current)==null||_.drawingManager.unbindAll())}},[D]),f.useEffect(()=>{if(D)return()=>{T.current||H.current.forEach(I=>{Z(I,!1)})}},[D]);const ne=j.useMemoizedFn(()=>{var E;const I=$.current,V=H.current,O=google.maps.geometry.poly,S=V.filter(b=>{if(!(b===I||b.get(fe)===void 0))return b instanceof google.maps.Marker?O.containsLocation(b.getPosition(),I):b instanceof google.maps.Circle?O.containsLocation(b.getCenter(),I):b.getPath().getArray().some(k=>O.containsLocation(k,I))}).map(b=>(Z(b,!0),b.get(fe)));l(b=>S.concat(b)),I==null||I.unbindAll(),I==null||I.setMap(null),(E=p.current)==null||E.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var S,E;if(!o||!(r!=null&&r.length)||!((S=p.current)!=null&&S.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,V=R([name,...I].flat().join(".")),O=r.map(b=>{const k=ke(b,t==null?void 0:t.field,V==null?void 0:V.interface);return k!=null&&k.length?k==null?void 0:k.filter(Boolean).map(_=>{var g;if(!k)return;const q=(g=p.current)==null?void 0:g.setOverlay(o.type,_,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:pt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?G(b[A]):void 0}});return q==null||q.set(fe,b[x]),q}):[]}).flat().filter(Boolean);H.current=O;const Q=O.map(b=>{const k=_=>{const q=b,g=q.get(fe);if(!g)return;const u=r==null?void 0:r.find(h=>g===h[x]);if(W){L(h=>(h&&ze(q),h===b?(ze(q),U(null),null):(gt(q),U(u[x],C=>C.field||x,"$eq"),q)));return}u&&M(u)};return b.addListener("click",k),()=>b.unbindAll()});if(o.type==="point"&&(m!=null&&m.length)&&(O==null?void 0:O.length)>1){const b=O.map(_=>_.getPosition());O[0].setZIndex(138),O[O.length-1].setZIndex(138);const k=(_=!0)=>{var q;if((q=p.current)!=null&&q.map)return new google.maps.Marker({label:{className:ut,fontFamily:"inherit",fontSize:"13px",color:"#333",text:w(_?"Start point":"End point")},icon:le(pe),position:_?b[0]:b[b.length-1],map:p.current.map})};O.push(...[p.current.setOverlay("lineString",b.map(_=>[_.lng(),_.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),k(),k(!1)].filter(Boolean))}return(E=p.current)==null||E.setFitView(O),()=>{O.forEach(b=>{b.setMap(null),b.unbindAll()}),Q.forEach(b=>b())}},[r,c,A,o.type,W]),f.useEffect(()=>{setTimeout(()=>{l([])})},[r]);const oe=I=>{p.current=I,y(!!(I!=null&&I.map)&&!I.errMessage)};return i.jsxs("div",{className:a.css`
|
|
85
85
|
position: relative;
|
|
86
86
|
height: 100%;
|
|
87
87
|
`,children:[c&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:a.css`
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
left: 10px;
|
|
90
90
|
top: 10px;
|
|
91
91
|
z-index: 999;
|
|
92
|
-
`,children:i.jsxs(P.Space,{direction:"vertical",children:[i.jsx(P.Button,{style:{color:
|
|
92
|
+
`,children:i.jsxs(P.Space,{direction:"vertical",children:[i.jsx(P.Button,{style:{color:D?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("")},icon:i.jsx(ee.EnvironmentOutlined,{})}),i.jsx(P.Button,{style:{color:D==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("selection")},icon:i.jsx(ee.ExpandOutlined,{})}),D==="selection"?i.jsx(P.Button,{type:"primary",icon:i.jsx(ee.CheckOutlined,{}),title:w("Confirm selection"),onClick:ne}):null]})}),i.jsx(ft,{record:d,setVisible:M})]}),i.jsx(xe,Y(F({},e),{ref:oe,style:{height:n?"100%":null},zoom:s,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},ft=e=>{const{setVisible:o,record:t}=e,r=a.useCollectionParentRecordData(),n=B.useFieldSchema(),s=f.useMemo(()=>n.reduceProperties((l,m)=>m.name==="drawer"?m:l,null),[n]);return s&&i.jsx(a.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:i.jsx(a.RecordProvider,{record:t,parent:r,children:i.jsx(B.RecursionField,{schema:s,name:s.name})})})};function ze(e){if(e instanceof google.maps.Marker)return e.setIcon(le(pe));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function gt(e){if(e instanceof google.maps.Marker)return e.setIcon(le(be));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const mt=()=>{var c;const{getCollectionJoinField:e}=a.useCollectionManager_deprecated(),{getField:o}=a.useCollection_deprecated(),{form:t}=a.useFormBlockContext(),r=B.useField(),n=B.useFieldSchema(),{t:s}=J(),{dn:l,refresh:m}=a.useDesignable(),v=o(n.name)||e(n["x-collection-field"]),x=(c=v==null?void 0:v.uiSchema)==null?void 0:c.title;r.title===x||r.title,r.readPretty||r.required;let A="editable";return n["x-disabled"]===!0&&(A="readonly"),n["x-read-pretty"]===!0&&(A="read-pretty"),i.jsxs(a.GeneralSchemaDesigner,{children:[i.jsx(a.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!a.isPatternDisabled(n)&&i.jsx(a.SchemaSettingsSelectItem,{title:s("Pattern"),options:[{label:s("Editable"),value:"editable"},{label:s("Readonly"),value:"readonly"},{label:s("Easy-reading"),value:"read-pretty"}],value:A,onChange:y=>{const p={"x-uid":n["x-uid"]};switch(y){case"readonly":{n["x-read-pretty"]=!1,n["x-disabled"]=!0,p["x-read-pretty"]=!1,p["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{n["x-read-pretty"]=!0,n["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,r.readPretty=!0;break}default:{n["x-read-pretty"]=!1,n["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}l.emit("patch",{schema:p}),l.refresh()}},"pattern"),i.jsx(a.SchemaSettingsModalItem,{title:s("Set default zoom level"),schema:{type:"object",title:s("Set default zoom level"),properties:{zoom:{title:s("Zoom"),default:r.componentProps.zoom||13,description:s("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:y})=>{y&&(ce.set(n,"x-component-props.zoom",y),Object.assign(r.componentProps,n["x-component-props"]),l.emit("patch",{schema:{"x-uid":n["x-uid"],"x-component-props":r.componentProps}})),l.refresh()}},"map-zoom"),i.jsx(a.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:s("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},ht={amap:Ce,google:xe},Se=f.forwardRef((e,o)=>{const{t}=J(),{mapType:r}=e,n=f.useMemo(()=>ht[r],[r]);return n?i.jsx(n,F({ref:o},e)):i.jsx("div",{children:t(`The ${r} cannot found`)})});Se.displayName="MapComponent";const yt=e=>{var m,v;const{value:o}=e,t=B.useFieldSchema(),{getField:r}=a.useCollection_deprecated(),n=r(t.name),s=e.mapType||((m=n==null?void 0:n.uiSchema["x-component-props"])==null?void 0:m.mapType),l=B.useForm();return a.useFieldTitle(),l.readPretty?i.jsx(Se,F({readonly:!0,mapType:s},e)):i.jsx("div",{children:i.jsx(a.EllipsisWithTooltip,{ellipsis:!0,children:(v=o==null?void 0:o.map)==null?void 0:v.call(o,x=>Array.isArray(x)?`(${x.join(",")})`:x).join(",")})})},Be=B.connect(e=>i.jsx("div",{className:a.css`
|
|
93
93
|
height: 100%;
|
|
94
94
|
border: 1px solid transparent;
|
|
95
95
|
.ant-formily-item-error & {
|
|
96
96
|
border: 1px solid #ff4d4f;
|
|
97
97
|
}
|
|
98
|
-
`,children:i.jsx(Se,F({},e))}),B.mapReadPretty(mt));ze.Designer=ft;const ht={amap:Ze,google:pt},yt=e=>{const{t:o}=J(),{mapType:t}=e,r=f.useMemo(()=>ht[t],[t]);return r?i.jsx(r,F({},e)):i.jsx("div",{children:o(`The ${t} cannot found`)})},bt=a.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=a.useProps(e),{getCollectionJoinField:t}=a.useCollectionManager_deprecated(),{name:r}=a.useCollection_deprecated(),n=f.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),s=(l=n==null?void 0:n.uiSchema)==null?void 0:l["x-component-props"];return i.jsx(yt,Y(F(F({},s),e),{collectionField:n}))}),vt=()=>{const{name:e,title:o}=a.useCollection(),t=a.useSchemaTemplate();return i.jsx(a.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},At=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}}},[B.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-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"}}}}}}}}}}}},Be=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,n)=>{const s=t==null?void 0:t.find(l=>l.value===r);return n===e.length-1?s:s==null?void 0:s.children},o)),Mt=()=>{const e=a.useSchemaInitializerItem(),{insert:o}=a.useSchemaInitializer(),t=f.useContext(B.SchemaOptionsContext),{getCollectionFieldsOptions:r}=a.useCollectionManager_deprecated(),{t:n}=J(),{theme:s}=a.useGlobalTheme();return i.jsx(a.DataBlockInitializer,F({componentType:"Map",icon:i.jsx(ee.TableOutlined,{}),onCreateBlockSchema:m=>me(this,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),S=r(l.name,"string",{dataSource:l.dataSource}),A=yield a.FormDialog(n("Create map block"),()=>{var c;return i.jsx(a.SchemaComponentOptions,{scope:t.scope,components:F({},t.components),children:i.jsx(je.FormLayout,{layout:"vertical",children:i.jsx(a.SchemaComponent,{schema:{properties:{field:{title:n("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(y=>y!=null):[]},marker:{title:n("Marker field"),enum:S,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const p=y.form.values.field;if(!(p!=null&&p.length))return;const d=Be(p,v);d&&(y.hidden=d.type!=="point")}}}}})})})},s).open({initialValues:{}});o(At({collectionName:l.name,dataSource:l.dataSource,fieldNames:F({},A)}))}),title:n("Map block")},e))},xe=f.createContext({});xe.displayName="MapBlockContext";const Ct=e=>{var v;const{fieldNames:o}=e,t=B.useFieldSchema(),r=B.useField(),{resource:n,service:s}=a.useBlockRequestContext(),[l,m]=f.useState([]);return i.jsx(a.FixedBlockWrapper,{children:i.jsx(a.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:i.jsx(xe.Provider,{value:{field:r,service:s,resource:n,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},St=e=>{const o=B.useField(),{params:t,fieldNames:r}=e,n=t.appends||[],{field:s}=r||{};return Array.isArray(s)&&s.length>1&&n.push(s[0]),i.jsx(a.BlockProvider,Y(F({name:"map"},e),{runWhenParamsChanged:!0,params:Y(F({},t),{appends:n,paginate:!1,sort:o.componentProps.lineSort}),children:i.jsx(Ct,F({},e))}))},fe=()=>f.useContext(xe),Ke=()=>{var o,t,r,n,s,l;const e=fe();return Y(F({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((n=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:n.zoom)||13,lineSort:(l=(s=e==null?void 0:e.field)==null?void 0:s.componentProps)==null?void 0:l.lineSort})},xt=e=>i.jsx(a.SchemaComponentOptions,{scope:{useMapBlockProps:Ke},components:{MapBlockInitializer:Mt,MapBlockDesigner:vt,MapBlockProvider:St,MapBlock:bt},children:e.children}),wt=new a.SchemaInitializer({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 a.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return a.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return a.useCollection_deprecated().template!=="sql"}}]}),Pt=new a.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:a.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:a.FixedBlockDesignerItem},{name:"mapField",Component:a.SchemaSettingsCascaderItem,useComponentProps(){var S;const{getCollectionFieldsOptions:e}=a.useCollectionManager_deprecated(),{t:o}=J(),t=B.useFieldSchema(),r=((S=t==null?void 0:t["x-decorator-props"])==null?void 0:S.fieldNames)||{},n=B.useField(),{dn:s}=a.useDesignable(),{service:l}=fe(),{name:m}=a.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:A=>{const c=n.decoratorProps.fieldNames||{};c.field=A,n.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),s.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}}),s.refresh()}}}},{name:"markerField",Component:a.SchemaSettingsSelectItem,useComponentProps(){var S;const{t:e}=J(),o=B.useFieldSchema(),t=((S=o==null?void 0:o["x-decorator-props"])==null?void 0:S.fieldNames)||{},{service:r}=fe(),n=B.useField(),{dn:s}=a.useDesignable(),{getCollectionFieldsOptions:l}=a.useCollectionManager_deprecated(),{name:m}=a.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:A=>{const c=n.decoratorProps.fieldNames||{};c.marker=A,n.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":n.decoratorProps}}),s.refresh()}}},useVisible(){var l,m;const e=B.useFieldSchema(),{getCollectionFieldsOptions:o}=a.useCollectionManager_deprecated(),{name:t}=a.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},n=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Be(r.field,n))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:a.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},{name:"setDataLoadingMode",Component:a.SetDataLoadingMode},{name:"defaultZoomLevel",Component:a.SchemaSettingsModalItem,useComponentProps(){var s;const{t:e}=J(),o=B.useFieldSchema(),t=B.useField(),{dn:r}=a.useDesignable(),n=((s=o==null?void 0:o["x-component-props"])==null?void 0:s.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:n,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ce.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:a.SchemaSettingsDataScope,useComponentProps(){var m,v;const{name:e}=a.useCollection(),o=B.useFieldSchema(),{form:t}=a.useFormBlockContext(),r=B.useField(),{service:n}=fe(),{dn:s}=a.useDesignable(),l=a.useDataLoadingMode();return{collectionName:e,defaultFilter:((v=(m=o==null?void 0:o["x-decorator-props"])==null?void 0:m.params)==null?void 0:v.filter)||{},form:t,onSubmit:({filter:S})=>{var y,p,d;const A=r.decoratorProps.params||{};A.filter=S,r.decoratorProps.params=A,o["x-decorator-props"].params=A;const c=((p=(y=n.params)==null?void 0:y[1])==null?void 0:p.filters)||{};l==="auto"&&n.run(Y(F({},(d=n.params)==null?void 0:d[0]),{filter:a.mergeFilter([...Object.values(c),S]),page:1}),{filters:c}),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:a.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:a.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:a.SchemaSettingsTemplate,useComponentProps(){var r,n;const{name:e}=a.useCollection(),o=B.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((n=o==null?void 0:o["x-decorator-props"])==null?void 0:n.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:It}=a.interfacesProperties;Array.isArray(a.interfacesProperties.type.enum)&&a.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class ge extends a.CollectionFieldInterface{constructor(){super(...arguments),this.properties=Y(F({},It),{"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:Pe}})}schemaInitialize(o,{block:t}){t==="Form"&&Object.assign(o,{"x-designer":"Map.Designer"})}}class kt extends ge{constructor(){super(...arguments),this.name="circle",this.type="object",this.group="map",this.order=3,this.title=X("Circle"),this.availableTypes=["circle"],this.description=X("Circle"),this.sortable=!0,this.default={type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Ft extends ge{constructor(){super(...arguments),this.name="lineString",this.type="object",this.group="map",this.order=2,this.title=X("Line"),this.description=X("Line"),this.availableTypes=["lineString"],this.sortable=!0,this.default={type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Ot extends ge{constructor(){super(...arguments),this.name="point",this.type="object",this.group="map",this.order=1,this.title=X("Point"),this.description=X("Point"),this.availableTypes=["point"],this.sortable=!0,this.default={type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Et extends ge{constructor(){super(...arguments),this.name="polygon",this.type="object",this.group="map",this.order=4,this.title=X("Polygon"),this.description=X("Polygon"),this.availableTypes=["polygon"],this.sortable=!0,this.default={type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}const Lt=[Ot,Et,Ft,kt],Ue=f.memo(e=>i.jsx(a.SchemaComponentOptions,{components:{Map:ze},children:i.jsx(xt,{children:e.children})}));Ue.displayName="MapProvider";class Ne extends a.Plugin{load(){return me(this,null,function*(){this.app.use(Ue),this.app.dataSourceManager.addFieldInterfaces(Lt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(wt),this.schemaSettingsManager.add(Pt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.systemSettingsManager.add("business-components."+he,{title:X("Map Manager"),icon:"EnvironmentOutlined",Component:Re,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ke})})}}N.MapPlugin=Ne,N.default=Ne,Object.defineProperties(N,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
98
|
+
`,children:i.jsx(Se,F({},e))}),B.mapReadPretty(yt));Be.Designer=mt;const bt={amap:He,google:dt},vt=e=>{const{t:o}=J(),{mapType:t}=e,r=f.useMemo(()=>bt[t],[t]);return r?i.jsx(r,F({},e)):i.jsx("div",{children:o(`The ${t} cannot found`)})},At=a.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=a.useProps(e),{getCollectionJoinField:t}=a.useCollectionManager_deprecated(),{name:r}=a.useCollection_deprecated(),n=f.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),s=(l=n==null?void 0:n.uiSchema)==null?void 0:l["x-component-props"];return i.jsx(vt,Y(F(F({},s),e),{collectionField:n}))}),Mt=()=>{const{name:e,title:o}=a.useCollection(),t=a.useSchemaTemplate();return i.jsx(a.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ct=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}}},[B.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"tb-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"}}}}}}}}}}}},Ke=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,n)=>{const s=t==null?void 0:t.find(l=>l.value===r);return n===e.length-1?s:s==null?void 0:s.children},o)),xt=()=>{const e=a.useSchemaInitializerItem(),{insert:o}=a.useSchemaInitializer(),t=f.useContext(B.SchemaOptionsContext),{getCollectionFieldsOptions:r}=a.useCollectionManager_deprecated(),{t:n}=J(),{theme:s}=a.useGlobalTheme();return i.jsx(a.DataBlockInitializer,F({componentType:"Map",icon:i.jsx(ee.TableOutlined,{}),onCreateBlockSchema:m=>he(null,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),x=r(l.name,"string",{dataSource:l.dataSource}),A=yield a.FormDialog(n("Create map block"),()=>{var c;return i.jsx(a.SchemaComponentOptions,{scope:t.scope,components:F({},t.components),children:i.jsx(je.FormLayout,{layout:"vertical",children:i.jsx(a.SchemaComponent,{schema:{properties:{field:{title:n("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(y=>y!=null):[]},marker:{title:n("Marker field"),enum:x,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const p=y.form.values.field;if(!(p!=null&&p.length))return;const d=Ke(p,v);d&&(y.hidden=d.type!=="point")}}}}})})})},s).open({initialValues:{}});o(Ct({collectionName:l.name,dataSource:l.dataSource,fieldNames:F({},A)}))}),title:n("Map block")},e))},we=f.createContext({});we.displayName="MapBlockContext";const St=e=>{var v;const{fieldNames:o}=e,t=B.useFieldSchema(),r=B.useField(),{resource:n,service:s}=a.useBlockRequestContext(),[l,m]=f.useState([]);return i.jsx(a.FixedBlockWrapper,{children:i.jsx(a.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:i.jsx(we.Provider,{value:{field:r,service:s,resource:n,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=B.useField(),{params:t,fieldNames:r}=e,n=t.appends||[],{field:s}=r||{};return Array.isArray(s)&&s.length>1&&n.push(s[0]),i.jsx(a.BlockProvider,Y(F({name:"map"},e),{runWhenParamsChanged:!0,params:Y(F({},t),{appends:n,paginate:!1,sort:o.componentProps.lineSort}),children:i.jsx(St,F({},e))}))},ge=()=>f.useContext(we),Ue=()=>{var o,t,r,n,s,l;const e=ge();return Y(F({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((n=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:n.zoom)||13,lineSort:(l=(s=e==null?void 0:e.field)==null?void 0:s.componentProps)==null?void 0:l.lineSort})},Pt=e=>i.jsx(a.SchemaComponentOptions,{scope:{useMapBlockProps:Ue},components:{MapBlockInitializer:xt,MapBlockDesigner:Mt,MapBlockProvider:wt,MapBlock:At},children:e.children}),It=new a.SchemaInitializer({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 a.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return a.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return a.useCollection_deprecated().template!=="sql"}}]}),kt=new a.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:a.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:a.FixedBlockDesignerItem},{name:"mapField",Component:a.SchemaSettingsCascaderItem,useComponentProps(){var x;const{getCollectionFieldsOptions:e}=a.useCollectionManager_deprecated(),{t:o}=J(),t=B.useFieldSchema(),r=((x=t==null?void 0:t["x-decorator-props"])==null?void 0:x.fieldNames)||{},n=B.useField(),{dn:s}=a.useDesignable(),{service:l}=ge(),{name:m}=a.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:A=>{const c=n.decoratorProps.fieldNames||{};c.field=A,n.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),s.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":n.decoratorProps}}),s.refresh()}}}},{name:"markerField",Component:a.SchemaSettingsSelectItem,useComponentProps(){var x;const{t:e}=J(),o=B.useFieldSchema(),t=((x=o==null?void 0:o["x-decorator-props"])==null?void 0:x.fieldNames)||{},{service:r}=ge(),n=B.useField(),{dn:s}=a.useDesignable(),{getCollectionFieldsOptions:l}=a.useCollectionManager_deprecated(),{name:m}=a.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:A=>{const c=n.decoratorProps.fieldNames||{};c.marker=A,n.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":n.decoratorProps}}),s.refresh()}}},useVisible(){var l,m;const e=B.useFieldSchema(),{getCollectionFieldsOptions:o}=a.useCollectionManager_deprecated(),{name:t}=a.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},n=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ke(r.field,n))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:a.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},{name:"setDataLoadingMode",Component:a.SetDataLoadingMode},{name:"defaultZoomLevel",Component:a.SchemaSettingsModalItem,useComponentProps(){var s;const{t:e}=J(),o=B.useFieldSchema(),t=B.useField(),{dn:r}=a.useDesignable(),n=((s=o==null?void 0:o["x-component-props"])==null?void 0:s.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:n,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ce.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:a.SchemaSettingsDataScope,useComponentProps(){var m,v;const{name:e}=a.useCollection(),o=B.useFieldSchema(),{form:t}=a.useFormBlockContext(),r=B.useField(),{service:n}=ge(),{dn:s}=a.useDesignable(),l=a.useDataLoadingMode();return{collectionName:e,defaultFilter:((v=(m=o==null?void 0:o["x-decorator-props"])==null?void 0:m.params)==null?void 0:v.filter)||{},form:t,onSubmit:({filter:x})=>{var y,p,d;const A=r.decoratorProps.params||{};A.filter=x,r.decoratorProps.params=A,o["x-decorator-props"].params=A;const c=((p=(y=n.params)==null?void 0:y[1])==null?void 0:p.filters)||{};l==="auto"&&n.run(Y(F({},(d=n.params)==null?void 0:d[0]),{filter:a.mergeFilter([...Object.values(c),x]),page:1}),{filters:c}),s.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:a.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:a.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:a.SchemaSettingsTemplate,useComponentProps(){var r,n;const{name:e}=a.useCollection(),o=B.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((n=o==null?void 0:o["x-decorator-props"])==null?void 0:n.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}=a.interfacesProperties;Array.isArray(a.interfacesProperties.type.enum)&&a.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class me extends a.CollectionFieldInterface{constructor(){super(...arguments),this.properties=Y(F({},Ft),{"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:Ie}})}schemaInitialize(o,{block:t}){t==="Form"&&Object.assign(o,{"x-designer":"Map.Designer"})}}class Ot extends me{constructor(){super(...arguments),this.name="circle",this.type="object",this.group="map",this.order=3,this.title=X("Circle"),this.availableTypes=["circle"],this.description=X("Circle"),this.sortable=!0,this.default={type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Et extends me{constructor(){super(...arguments),this.name="lineString",this.type="object",this.group="map",this.order=2,this.title=X("Line"),this.description=X("Line"),this.availableTypes=["lineString"],this.sortable=!0,this.default={type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Dt extends me{constructor(){super(...arguments),this.name="point",this.type="object",this.group="map",this.order=1,this.title=X("Point"),this.description=X("Point"),this.availableTypes=["point"],this.sortable=!0,this.default={type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}class Lt extends me{constructor(){super(...arguments),this.name="polygon",this.type="object",this.group="map",this.order=4,this.title=X("Polygon"),this.description=X("Polygon"),this.availableTypes=["polygon"],this.sortable=!0,this.default={type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}}}const Tt=[Dt,Lt,Et,Ot],Ne=f.memo(e=>i.jsx(a.SchemaComponentOptions,{components:{Map:Be},children:i.jsx(Pt,{children:e.children})}));Ne.displayName="MapProvider";class Ge extends a.Plugin{load(){return he(this,null,function*(){this.app.use(Ne),this.app.dataSourceManager.addFieldInterfaces(Tt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(It),this.schemaSettingsManager.add(kt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:X("Map"),Component:"MapBlockInitializer"}),this.app.systemSettingsManager.add("business-components."+ye,{title:X("Map Manager"),icon:"EnvironmentOutlined",Component:tt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ue})})}}N.MapPlugin=Ge,N.default=Ge,Object.defineProperties(N,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.3.
|
|
4
|
-
"@tachybase/server": "1.3.
|
|
5
|
-
"@tachybase/schema": "1.3.
|
|
3
|
+
"@tachybase/client": "1.3.17",
|
|
4
|
+
"@tachybase/server": "1.3.17",
|
|
5
|
+
"@tachybase/schema": "1.3.17",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
|
-
"@tachybase/components": "1.3.
|
|
7
|
+
"@tachybase/components": "1.3.17",
|
|
8
8
|
"@ant-design/icons": "5.3.7",
|
|
9
9
|
"ahooks": "3.8.4",
|
|
10
10
|
"antd": "5.22.5",
|
|
11
11
|
"react-router-dom": "6.28.1",
|
|
12
|
-
"@tachybase/actions": "1.3.
|
|
13
|
-
"@tachybase/database": "1.3.
|
|
12
|
+
"@tachybase/actions": "1.3.17",
|
|
13
|
+
"@tachybase/database": "1.3.17"
|
|
14
14
|
};
|
package/dist/index.js
CHANGED
|
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
default: () => import_server.default
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
34
|
-
__reExport(
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
__reExport(index_exports, require("./server"), module.exports);
|
|
35
35
|
var import_server = __toESM(require("./server"));
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-block-map",
|
|
3
3
|
"displayName": "Block: Map",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.17",
|
|
5
5
|
"description": "Map block, support Gaode map and Google map, you can also extend more map types.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Blocks"
|
|
@@ -24,16 +24,16 @@
|
|
|
24
24
|
"react-dom": "~18.3.1",
|
|
25
25
|
"react-i18next": "^15.2.0",
|
|
26
26
|
"react-router-dom": "6.28.1",
|
|
27
|
-
"@tachybase/
|
|
28
|
-
"@tachybase/
|
|
27
|
+
"@tachybase/schema": "1.3.17",
|
|
28
|
+
"@tachybase/components": "1.3.17"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@tachybase/actions": "1.3.
|
|
32
|
-
"@tachybase/client": "1.3.
|
|
33
|
-
"@tachybase/database": "1.3.
|
|
34
|
-
"@tachybase/
|
|
35
|
-
"@tachybase/
|
|
36
|
-
"@tachybase/
|
|
31
|
+
"@tachybase/actions": "1.3.17",
|
|
32
|
+
"@tachybase/client": "1.3.17",
|
|
33
|
+
"@tachybase/database": "1.3.17",
|
|
34
|
+
"@tachybase/utils": "1.3.17",
|
|
35
|
+
"@tachybase/server": "1.3.17",
|
|
36
|
+
"@tachybase/test": "1.3.17"
|
|
37
37
|
},
|
|
38
38
|
"description.zh-CN": "地图卡片,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
|
|
39
39
|
"displayName.zh-CN": "卡片:地图",
|