@nocobase/plugin-map 1.2.34-alpha → 1.2.36-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +10 -10
- package/dist/externalVersion.js +5 -5
- package/dist/server/fields/circle.js +1 -2
- package/dist/server/fields/lineString.js +1 -2
- package/dist/server/fields/point.js +1 -2
- package/dist/server/fields/polygon.js +1 -2
- package/dist/server/helpers/index.js +2 -4
- package/dist/server/interfaces/index.js +6 -12
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,13 +7,13 @@
|
|
|
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(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 j(){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 _=d[P].split("/").slice(-1)[0];window.AMapUI[_]=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 _=d[P].split("/").slice(-1)[0];window.AMapUI[_]=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,_=d.length;G<_;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}=j(),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`
|
|
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:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i,popupMatchSelectWidth:!1})})},Ke=()=>{var C,c;const e=n.useDataBlockHeight(),{token:o}=w.theme.useToken(),{designable:t}=n.useDesignable(),{heightProps:r}=n.useBlockHeightProps()||{},{title:l}=r||{},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},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:r}=Se(e.mapType)||{},{value:l,onChange:i,block:a=!1,readonly:m,disabled:b=a,zoom:A=13,overlayCommonOptions:C}=e,{t:c}=
|
|
16
|
+
`,children:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i,popupMatchSelectWidth:!1})})},Ke=()=>{var C,c;const e=n.useDataBlockHeight(),{token:o}=w.theme.useToken(),{designable:t}=n.useDesignable(),{heightProps:r}=n.useBlockHeightProps()||{},{title:l}=r||{},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},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:r}=Se(e.mapType)||{},{value:l,onChange:i,block:a=!1,readonly:m,disabled:b=a,zoom:A=13,overlayCommonOptions:C}=e,{t:c}=j(),M=N.useFieldSchema(),p=h.useRef(),d=h.useRef(),S=h.useRef(),[z,K]=h.useState([]),[P,G]=h.useState(""),{getField:_}=n.useCollection_deprecated(),U=h.useMemo(()=>{if(e.type)return e.type;const u=_(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=ce.useNavigate(),J=h.useRef(`nocobase-map-${U||""}-${Date.now().toString(32)}`),{modal:de}=w.App.useApp(),re=Ke(),[W]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},C));h.useEffect(()=>{d.current&&d.current.setZoom(A)},[A]);const ne=q.useMemoizedFn(()=>{V.current&&V.current.remove()}),se=q.useMemoizedFn(()=>{(!b||a)&&U!=="point"&&k.current&&(k.current.setTarget(V.current),k.current.open())}),le=q.useMemoizedFn((u,f=!1)=>{let y=null;if(U==="point"){const{lat:g,lng:E}=u.getPosition();y=[E,g]}else if(U==="polygon"||U==="lineString"){if(y=u.getPath().map(g=>[g.lng,g.lat]),y.length<2)return}else if(U==="circle"){const g=u.getCenter(),E=u.getRadius();y=[g.lng,g.lat,E]}f||(ne(),V.current=u,se()),i==null||i(y)}),$=q.useMemoizedFn((u=U)=>{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=q.useMemoizedFn((u=U)=>{var y;if(!S.current||(y=k.current)!=null&&y.getTarget())return;const f=xe[u];f&&S.current[f.mouseTool](F({},W))}),Y=q.useMemoizedFn((u=U)=>{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)};de.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=U,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=U,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,z,U,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||!U||b||(Y(),$())},[b,z,U]),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()},[U,l]),h.useEffect(()=>{if(!t||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const u=window.define;return window.define=void 0,ze.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(""),K([])}))).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,ze.reset()}},[t,U,r]),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 T=n.useApp();return!t||P?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>Q(T.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:n.css`
|
|
17
17
|
position: relative;
|
|
18
18
|
height: ${re||500}px !important;
|
|
19
19
|
`,id:J.current,style:e==null?void 0:e.style,children:[!p.current&&s.jsx("div",{className:n.css`
|
|
@@ -38,7 +38,7 @@
|
|
|
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 st=e=>{var $,I,Y,B,Z;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{name:b,getPrimaryKey:A}=n.useCollection_deprecated(),{getCollectionJoinField:C}=n.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,[z,K]=h.useState(),[P,G]=h.useState(""),{t:
|
|
41
|
+
`,children:s.jsx(w.Button,{disabled:!l,style:{height:"40px"},onClick:Z,type:"primary",danger:!0,children:c("Clear")})})]})]})});we.displayName="AMapComponent";const st=e=>{var $,I,Y,B,Z;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{name:b,getPrimaryKey:A}=n.useCollection_deprecated(),{getCollectionJoinField:C}=n.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,[z,K]=h.useState(),[P,G]=h.useState(""),{t:_}=j(),U=n.useCompile(),{isConnected:V,doFilter:k}=n.useFilterAPI(),[,Q]=h.useState(null),J=h.useRef(P);J.current=P;const{fields:de}=n.useCollection(),re=(Y=de.find(x=>x.name===(t==null?void 0:t.marker)))==null?void 0:Y.uiSchema,W=(x,L)=>{const v=x.getExtData(),T=typeof L=="undefined"?v.selected:!L;v.selected=!T,"setIcon"in x&&x.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:T?fe:Ae})),x.setOptions(F({extData:v},T?{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,T;if(P==="selection")return(x=d.current)!=null&&x.editor()?(T=d.current)==null||T.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=q.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())}),T=v==null?void 0:v.map(g=>(W(g,!0),g.getExtData().id));a(g=>T==null?void 0:T.concat(g)),x==null||x.remove(),(y=d.current)==null||y.editor().close()});h.useEffect(()=>{var u,f,y;if(!o||!d.current||!r)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=r.map(g=>{var te;const E=(te=Te(g,t==null?void 0:t.field,L==null?void 0:L.interface))==null?void 0:te.filter(Boolean),ee=n.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?U(ee):void 0},extData:{id:g[c]}})}):[]}).flat().filter(Boolean);(f=(u=d.current)==null?void 0:u.map)==null||f.setFitView(v);const T=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=r.find(oe=>ie.id===oe[c]);if(V){Q(oe=>(oe&&Ue(oe),oe===g?(Ue(g),k(null),null):(at(g),k(ve[c],Fe=>Fe.field||c,"$eq"),g)));return}ve&&K(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:_(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()}),T.forEach(g=>g())}},[r,M,t,b,c,o.type,V,m]),h.useEffect(()=>{setTimeout(()=>{a([])})},[r]);const le=x=>{d.current=x,p(!!(x!=null&&x.map)&&!x.errMessage)};return s.jsxs("div",{className:n.css`
|
|
42
42
|
position: relative;
|
|
43
43
|
height: 100%;
|
|
44
44
|
`,children:[s.jsx("div",{className:n.css`
|
|
@@ -46,7 +46,7 @@
|
|
|
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:_("Confirm selection"),onClick:se}):null]}):null}),s.jsx(it,{record:z,setVisible:K}),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"}}))]})},it=e=>{const{setVisible:o,record:t}=e;j();const r=n.useCollection(),l=n.useCollectionParentRecordData(),i=N.useFieldSchema(),a=h.useMemo(()=>i.reduceProperties((m,b)=>b.name==="drawer"?b:m,null),[i]);return a&&s.jsx(n.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(n.RecordProvider,{record:t,parent:l,children:s.jsx(n.VariablePopupRecordProvider,{recordData:t,collection:r,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 at(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 Ne=({type:e,children:o})=>{const{t}=j(),[r,l]=q.useBoolean(!1),i=n.useAPIClient(),[a]=w.Form.useForm(),m=Se(e);h.useEffect(()=>{m&&(a.setFieldsValue(m),l.toggle())},[m]);const b=h.useMemo(()=>i.resource(Be),[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:r,form:a,layout:"vertical",onFinish:A,children:[o,r?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")})})]})},lt={amap:()=>{const{t:e}=j();return s.jsxs(Ne,{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}=j();return s.jsx(Ne,{type:"google",children:s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:s.jsx(w.Input,{})})})}},ct=Le.map(e=>H(F({},e),{component:lt[e.value]})),pt=()=>{const e=n.useCompile(),o=ce.useLocation(),t=new URLSearchParams(o.search);return s.jsx(w.Card,{bordered:!0,children:s.jsx(w.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:ct.map(r=>s.jsx(w.Tabs.TabPane,{tab:e(r.label),children:s.jsx(r.component,{type:r.value})},r.value))})})};/*! *****************************************************************************
|
|
50
50
|
Copyright (c) Microsoft Corporation.
|
|
51
51
|
|
|
52
52
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -59,13 +59,13 @@
|
|
|
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 ut(e,o,t,r){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(r.next(C))}catch(c){a(c)}}function b(C){try{A(r.throw(C))}catch(c){a(c)}}function A(C){C.done?i(C.value):l(C.value).then(m,b)}A((r=r.apply(e,
|
|
62
|
+
***************************************************************************** */function ut(e,o,t,r){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(r.next(C))}catch(c){a(c)}}function b(C){try{A(r.throw(C))}catch(c){a(c)}}function A(C){C.done?i(C.value):l(C.value).then(m,b)}A((r=r.apply(e,[])).next())})}var dt=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,l,i;if(Array.isArray(o)){if(r=o.length,r!=t.length)return!1;for(l=r;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),r=i.length,r!==Object.keys(t).length)return!1;for(l=r;l--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[l]))return!1;for(l=r;l--!==0;){var a=i[l];if(!e(o[a],t[a]))return!1}return!0}return o!==o&&t!==t};const Ge="__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 pe{constructor({apiKey:o,authReferrerPolicy:t,channel:r,client:l,id:i=Ge,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=r,this.client=l,this.id=i||Ge,this.language=a,this.libraries=m,this.mapIds=b,this.nonce=A,this.region=C,this.retries=c,this.url=M,this.version=p,pe.instance){if(!dt(this.options,pe.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(pe.instance.options)}`);return pe.instance}pe.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(r=>{r?t(r.error):o(window.google)})})}importLibrary(o){return this.execute(),google.maps.importLibrary(o)}loadCallback(o){this.callbacks.push(o),this.execute()}setScript(){var o,t;if(document.getElementById(this.id)){this.callback();return}const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach(i=>!r[i]&&delete r[i]),!((t=(o=window==null?void 0:window.google)===null||o===void 0?void 0:o.maps)===null||t===void 0)&&t.importLibrary||(i=>{let 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={}),z=new Set,K=new URLSearchParams,P=()=>a||(a=new Promise((G,_)=>ut(this,void 0,void 0,function*(){var U;yield m=p.createElement("script"),m.id=this.id,K.set("libraries",[...z]+"");for(b in i)K.set(b.replace(/[A-Z]/g,V=>"_"+V[0].toLowerCase()),i[b]);K.set("callback",C+".maps."+M),m.src=this.url+"?"+K,S[M]=G,m.onerror=()=>a=_(Error(A+" could not load.")),m.nonce=this.nonce||((U=p.querySelector("script[nonce]"))===null||U===void 0?void 0:U.nonce)||"",p.head.append(m)})));S[c]?console.warn(A+" only loads once. Ignoring:",i):S[c]=(G,..._)=>z.add(G)&&P().then(()=>S[c](G,..._))})(r);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 ft=e=>{const{toCenter:o,mapRef:t}=e,{t:r}=j(),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}=q.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:n.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:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i})})},ue=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),mt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:l}=t.coords;e({lat:r,lng:l})},()=>{o()}):o()}),gt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ht={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:r,block:l=!1,readonly:i,disabled:a=l,zoom:m=13,overlayCommonOptions:b}=e,{accessKey:A}=Se(e.mapType)||{},{t:C}=
|
|
68
|
+
`,children:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:b,options:i})})},ue=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),mt=()=>new Promise(e=>{const o=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:r,longitude:l}=t.coords;e({lat:r,lng:l})},()=>{o()}):o()}),gt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ht={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:r,block:l=!1,readonly:i,disabled:a=l,zoom:m=13,overlayCommonOptions:b}=e,{accessKey:A}=Se(e.mapType)||{},{t:C}=j(),{getField:c}=n.useCollection_deprecated(),M=N.useFieldSchema(),p=h.useRef(),d=h.useRef(),S=h.useRef(),[z,K]=h.useState([]),[P,G]=h.useState(""),_=n.useAPIClient(),{modal:U}=w.App.useApp(),V=Ke();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(gt(k)),[J]=h.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!a,draggable:!a},b)),de=ce.useNavigate(),re=h.useRef(),W=h.useRef(new Set),ne=q.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=q.useMemoizedFn(()=>{var u;S.current&&(S.current.unbindAll(),S.current.setMap(null)),k!=="point"&&((u=p.current)==null||u.setDrawingMode(null))}),le=q.useMemoizedFn(u=>{d.current&&(d.current.setCenter(u),d.current.setZoom(m))}),$=q.useMemoizedFn(u=>{se(),ne(u),S.current=u}),I=q.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=q.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),r==null||r(y)}),Z=q.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:ue(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=q.useMemoizedFn((u=k,f=t,y)=>{const g=ht[u];if(!g)return;const E=F(H(F({},J),{icon:ue(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=q.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),r==null||r(null)),!d.current||!t||!i&&S.current)return;const u=L();$(u),I([u])},[t,z,k,a,i,L,I,$]),h.useEffect(()=>{if(!A||d.current||!re.current)return;let u;try{u=new pe({apiKey:A,version:"weekly",language:_.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 mt();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(""),K([])})).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,_.auth,k,m]),h.useEffect(()=>{!d.current||!k||a||p.current||Z()},[Z,a,z,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=q.useMemoizedFn(()=>{const u=()=>{se(),p.current.setDrawingMode(Q.current),r==null||r(null)};U.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()}})}),T=n.useApp();return!A||P?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>de(T.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:n.css`
|
|
69
69
|
position: relative;
|
|
70
70
|
height: ${V||500}px !important;
|
|
71
71
|
`,children:[!d.current&&s.jsx("div",{className:n.css`
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
padding: 2px 4px;
|
|
104
104
|
background: #fff;
|
|
105
105
|
border: 1px solid #0000f5;
|
|
106
|
-
`,vt=e=>{var $;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{getPrimaryKey:b}=n.useCollection_deprecated(),A=b(),{marker:C="id"}=t,[c,M]=h.useState(!1),p=h.useRef(),[d,S]=h.useState(),[z,K]=h.useState(""),{t:P}=
|
|
106
|
+
`,vt=e=>{var $;const{collectionField:o,fieldNames:t,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{getPrimaryKey:b}=n.useCollection_deprecated(),A=b(),{marker:C="id"}=t,[c,M]=h.useState(!1),p=h.useRef(),[d,S]=h.useState(),[z,K]=h.useState(""),{t:P}=j(),G=n.useCompile(),{isConnected:_,doFilter:U}=n.useFilterAPI(),[,V]=h.useState(null),k=h.useRef(z),Q=h.useRef(null),J=h.useRef([]);k.current=z;const{fields:de}=n.useCollection(),re=($=de.find(I=>I.name===(t==null?void 0:t.marker)))==null?void 0:$.uiSchema,{getCollectionJoinField:W}=n.useCollectionManager_deprecated(),ne=(I,Y)=>{const B=typeof Y!="undefined"?!Y:I.get(qe);I.set(qe,!B),I.setOptions(F({},B?{icon:ue(fe),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ue(Ae),strokeColor:"#F18b62",fillColor:"#F18b62"}))};h.useEffect(()=>{var Y,B,Z,x;if(z!=="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 T=v.getPath();["insert_at","remove_at","set_at"].forEach(f=>{I.add(T.addListener(f,()=>{}).remove)})}),()=>{var L,v,T,u;I.forEach(f=>{f()}),p.current&&((L=Q.current)==null||L.unbindAll(),(v=Q.current)==null||v.setMap(null),Q.current=null,(T=p.current)==null||T.drawingManager.setDrawingMode(null),(u=p.current)==null||u.drawingManager.unbindAll())}},[z]),h.useEffect(()=>{if(z)return()=>{k.current||J.current.forEach(I=>{ne(I,!1)})}},[z]);const se=q.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(T=>B.containsLocation(T,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||!(r!=null&&r.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=r.map(v=>{const T=Te(v,t==null?void 0:t.field,Y==null?void 0:Y.interface),u=n.getLabelFormatValue(re,v[t.marker]);return T!=null&&T.length?T==null?void 0:T.filter(Boolean).map(f=>{var g;if(!T)return;const y=(g=p.current)==null?void 0:g.setOverlay(o.type,f,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:yt,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 T=u=>{const f=v,y=f.get(he);if(!y)return;const g=r==null?void 0:r.find(E=>y===E[A]);if(_){V(E=>(E&&_e(f),E===v?(_e(f),U(null),null):(At(f),U(g[A],ee=>ee.field||A,"$eq"),f)));return}g&&S(g)};return v.addListener("click",T),()=>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 T=(u=!0)=>{var f;if((f=p.current)!=null&&f.map)return new google.maps.Marker({label:{className:bt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:P(u?"Start point":"End point")},icon:ue(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"}),T(),T(!1)].filter(Boolean))}return(L=p.current)==null||L.setFitView(B),()=>{B.forEach(v=>{v.setMap(null),v.unbindAll()}),Z.forEach(v=>v())}},[r,c,C,o.type,_]),h.useEffect(()=>{setTimeout(()=>{a([])})},[r]);const le=I=>{p.current=I,M(!!(I!=null&&I.map)&&!I.errMessage)};return s.jsxs("div",{className:n.css`
|
|
107
107
|
position: relative;
|
|
108
108
|
height: 100%;
|
|
109
109
|
`,children:[c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:n.css`
|
|
@@ -111,14 +111,14 @@
|
|
|
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:z?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:z==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("selection")},icon:s.jsx(R.ExpandOutlined,{})}),z==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:P("Confirm selection"),onClick:se}):null]})}),s.jsx(Mt,{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"}}))]})},Mt=e=>{const{setVisible:o,record:t}=e;
|
|
114
|
+
`,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:z?void 0:"#F18b62",borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("")},icon:s.jsx(R.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:z==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:I=>{I.stopPropagation(),K("selection")},icon:s.jsx(R.ExpandOutlined,{})}),z==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(R.CheckOutlined,{}),title:P("Confirm selection"),onClick:se}):null]})}),s.jsx(Mt,{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"}}))]})},Mt=e=>{const{setVisible:o,record:t}=e;j();const r=n.useCollection(),l=n.useCollectionParentRecordData(),i=N.useFieldSchema(),a=h.useMemo(()=>i.reduceProperties((m,b)=>b.name==="drawer"?b:m,null),[i]);return a&&s.jsx(n.ActionContextProvider,{value:{visible:!!t,setVisible:o},children:s.jsx(n.RecordProvider,{record:t,parent:l,children:s.jsx(n.VariablePopupRecordProvider,{recordData:t,collection:r,children:s.jsx(N.RecursionField,{schema:a,name:a.name})})})})};function _e(e){if(e instanceof google.maps.Marker)return e.setIcon(ue(fe));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function At(e){if(e instanceof google.maps.Marker)return e.setIcon(ue(Ae));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const Ct=()=>{var c;const{getCollectionJoinField:e}=n.useCollectionManager_deprecated(),{getField:o}=n.useCollection_deprecated(),{form:t}=n.useFormBlockContext(),r=N.useField(),l=N.useFieldSchema(),{t:i}=j(),{dn:a,refresh:m}=n.useDesignable(),b=o(l.name)||e(l["x-collection-field"]),A=(c=b==null?void 0:b.uiSchema)==null?void 0:c.title;r.title===A||r.title,r.readPretty||r.required;let C="editable";return l["x-disabled"]===!0&&(C="readonly"),l["x-read-pretty"]===!0&&(C="read-pretty"),s.jsxs(n.GeneralSchemaDesigner,{children:[s.jsx(n.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!n.isPatternDisabled(l)&&s.jsx(n.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,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{l["x-read-pretty"]=!0,l["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,r.readPretty=!0;break}default:{l["x-read-pretty"]=!1,l["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}a.emit("patch",{schema:p}),a.refresh()}},"pattern"),s.jsx(n.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:r.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:M})=>{M&&(Ee.set(l,"x-component-props.zoom",M),Object.assign(r.componentProps,l["x-component-props"]),a.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":r.componentProps}})),a.refresh()}},"map-zoom"),s.jsx(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},St={amap:we,google:Pe},Ie=h.forwardRef((e,o)=>{const{t}=j(),{mapType:r}=e,l=h.useMemo(()=>St[r],[r]);return l?s.jsx(l,F({ref:o},e)):s.jsx("div",{children:t(`The ${r} cannot found`)})});Ie.displayName="MapComponent";const xt=e=>{var m,b;const{value:o}=e,t=N.useFieldSchema(),{getField:r}=n.useCollection_deprecated(),l=r(t.name),i=e.mapType||((m=l==null?void 0:l.uiSchema["x-component-props"])==null?void 0:m.mapType),a=N.useForm();return n.useFieldTitle(),a.readPretty?s.jsx(Ie,F({readonly:!0,mapType:i},e)):s.jsx("div",{children:s.jsx(n.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(",")})})},je=N.connect(e=>s.jsx("div",{className:n.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(xt));
|
|
120
|
+
`,children:s.jsx(Ie,F({},e))}),N.mapReadPretty(xt));je.Designer=Ct;const wt={amap:st,google:vt},Pt=e=>{const{t:o}=j(),{mapType:t}=e,r=h.useMemo(()=>wt[t],[t]);return r?s.jsx(r,F({},e)):s.jsx("div",{children:o(`The ${t} cannot found`)})},It=n.withDynamicSchemaProps(e=>{var a;const{fieldNames:o}=n.useProps(e),{getCollectionJoinField:t}=n.useCollectionManager_deprecated(),{name:r}=n.useCollection_deprecated(),l=h.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(a=l==null?void 0:l.uiSchema)==null?void 0:a["x-component-props"];return s.jsx(Pt,H(F(F({},i),e),{collectionField:l}))}),kt=()=>{const{name:e,title:o}=n.useCollection(),t=n.useSchemaTemplate();return s.jsx(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ve=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,l)=>{const i=t==null?void 0:t.find(a=>a.value===r);return l===e.length-1?i:i==null?void 0:i.children},o)),Ft=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":{}},[Re.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"}}}}}}}}}}}},Ot=()=>{const e=n.useSchemaInitializerItem(),{insert:o}=n.useSchemaInitializer(),t=h.useContext(N.SchemaOptionsContext),{getCollectionFieldsOptions:r}=n.useCollectionManager_deprecated(),{t:l}=j(),{theme:i}=n.useGlobalTheme();return s.jsx(n.DataBlockInitializer,F({componentType:"Map",icon:s.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>Me(this,[m],function*({item:a}){const b=r(a.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:a.dataSource}),A=r(a.name,"string",{dataSource:a.dataSource}),C=yield n.FormDialog(l("Create map block"),()=>{var c;return s.jsx(n.SchemaComponentOptions,{scope:t.scope,components:F({},t.components),children:s.jsx($e.FormLayout,{layout:"vertical",children:s.jsx(n.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=Ve(p,b);d&&(M.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(Ft({collectionName:a.name,dataSource:a.dataSource,fieldNames:F({},C)}))}),title:l("Map block")},e))},ke=h.createContext({});ke.displayName="MapBlockContext";const Et=e=>{var A;const{fieldNames:o}=e,t=N.useFieldSchema(),r=N.useField(),{resource:l,service:i}=n.useBlockRequestContext(),[a,m]=h.useState([]),{token:b}=w.theme.useToken();return s.jsx(n.FixedBlockWrapper,{children:s.jsx(n.SchemaComponentOptions,{scope:{selectedRecordKeys:a},children:s.jsxs(ke.Provider,{value:{field:r,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:et.css`
|
|
121
121
|
.nb-action-bar {
|
|
122
122
|
margin-bottom: ${b.margin}px;
|
|
123
123
|
}
|
|
124
|
-
`,children:e.children})]})})})},Lt=e=>{const{filter:o,parseVariableLoading:t}=n.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:H(F({},e),{filter:o}),parseVariableLoading:t}},Tt=e=>{const o=N.useField(),{fieldNames:t}=e,{params:r,parseVariableLoading:l}=Lt(e.params);if(l)return null;const i=r.appends||[],{field:a}=t||{};return Array.isArray(a)&&a.length>1&&i.push(a[0]),s.jsx(n.BlockProvider,H(F({name:"map"},e),{runWhenParamsChanged:!0,params:H(F({},r),{appends:i,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(Et,F({},e))}))},ye=()=>h.useContext(ke),We=()=>{var o,t,r,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=(r=e==null?void 0:e.field)==null?void 0:r.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(n.SchemaComponentOptions,{scope:{useMapBlockProps:We},components:{MapBlockInitializer:Ot,MapBlockDesigner:kt,MapBlockProvider:Tt,MapBlock:It},children:e.children}),Ye={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 n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},He=new n.CompatibleSchemaInitializer(F({name:"MapActionInitializers"},Ye)),zt=new n.CompatibleSchemaInitializer(F({name:"map:configureActions"},Ye),He),Je={name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=
|
|
124
|
+
`,children:e.children})]})})})},Lt=e=>{const{filter:o,parseVariableLoading:t}=n.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:H(F({},e),{filter:o}),parseVariableLoading:t}},Tt=e=>{const o=N.useField(),{fieldNames:t}=e,{params:r,parseVariableLoading:l}=Lt(e.params);if(l)return null;const i=r.appends||[],{field:a}=t||{};return Array.isArray(a)&&a.length>1&&i.push(a[0]),s.jsx(n.BlockProvider,H(F({name:"map"},e),{runWhenParamsChanged:!0,params:H(F({},r),{appends:i,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(Et,F({},e))}))},ye=()=>h.useContext(ke),We=()=>{var o,t,r,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=(r=e==null?void 0:e.field)==null?void 0:r.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(n.SchemaComponentOptions,{scope:{useMapBlockProps:We},components:{MapBlockInitializer:Ot,MapBlockDesigner:kt,MapBlockProvider:Tt,MapBlock:It},children:e.children}),Ye={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 n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},He=new n.CompatibleSchemaInitializer(F({name:"MapActionInitializers"},Ye)),zt=new n.CompatibleSchemaInitializer(F({name:"map:configureActions"},Ye),He),Je={name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=j(),o=N.useFieldSchema(),t=N.useField(),{dn:r}=n.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})=>{Ee.set(o,"x-component-props.zoom",a),t.componentProps.zoom=a,r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":o["x-component-props"]}}),r.refresh()}}}},Bt=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:n.SchemaSettingsBlockHeightItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps(){var A;const{getCollectionFieldsOptions:e}=n.useCollectionManager_deprecated(),{t:o}=j(),t=N.useFieldSchema(),r=((A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fieldNames)||{},l=N.useField(),{dn:i}=n.useDesignable(),{service:a}=ye(),{name:m}=n.useCollection(),b=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.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:n.SchemaSettingsSelectItem,useComponentProps(){var A;const{t:e}=j(),o=N.useFieldSchema(),t=((A=o==null?void 0:o["x-decorator-props"])==null?void 0:A.fieldNames)||{},{service:r}=ye(),l=N.useField(),{dn:i}=n.useDesignable(),{getCollectionFieldsOptions:a}=n.useCollectionManager_deprecated(),{name:m}=n.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,r.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}=n.useCollectionManager_deprecated(),{name:t}=n.useCollection(),r=((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=Ve(r.field,l))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=j();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,Je,{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps(){var a,m;const{name:e}=n.useCollection(),o=N.useFieldSchema(),{form:t}=n.useFormBlockContext(),r=N.useField(),{service:l}=ye(),{dn:i}=n.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=r.decoratorProps.params||{};A.filter=b,r.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:n.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=j();return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps(){var r,l;const{name:e}=n.useCollection(),o=N.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.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:Kt}=n.interfacesProperties;Array.isArray(n.interfacesProperties.type.enum)&&n.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class be extends n.CollectionFieldInterface{constructor(){super(...arguments);O(this,"properties",H(F({},Kt),{"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:Le}}))}schemaInitialize(t,{block:r}){r==="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 Nt 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 Gt 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 qt 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 _t=[Gt,qt,Nt,Ut],jt=new n.SchemaSettings({name:"fieldSettings:component:Map",items:[Je]}),Ze=h.memo(e=>s.jsx(n.SchemaComponentOptions,{components:{Map:je},children:s.jsx(Dt,{children:e.children})}));Ze.displayName="MapProvider";class Xe extends n.Plugin{load(){return Me(this,null,function*(){this.app.use(Ze),this.app.dataSourceManager.addFieldInterfaces(_t),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:X("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(He),this.app.schemaInitializerManager.add(zt),this.schemaSettingsManager.add(Bt),this.schemaSettingsManager.add(jt);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:pt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:We})})}}D.PluginMapClient=Xe,D.default=Xe,Object.defineProperties(D,{__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.2.
|
|
11
|
+
"@nocobase/client": "1.2.36-alpha",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/server": "1.2.
|
|
14
|
-
"@nocobase/test": "1.2.
|
|
13
|
+
"@nocobase/server": "1.2.36-alpha",
|
|
14
|
+
"@nocobase/test": "1.2.36-alpha",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
@@ -23,6 +23,6 @@ module.exports = {
|
|
|
23
23
|
"react-router-dom": "6.21.0",
|
|
24
24
|
"@formily/core": "2.3.0",
|
|
25
25
|
"react-i18next": "11.18.6",
|
|
26
|
-
"@nocobase/actions": "1.2.
|
|
27
|
-
"@nocobase/database": "1.2.
|
|
26
|
+
"@nocobase/actions": "1.2.36-alpha",
|
|
27
|
+
"@nocobase/database": "1.2.36-alpha"
|
|
28
28
|
};
|
|
@@ -51,8 +51,7 @@ class CircleField extends import_database.Field {
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
set(value) {
|
|
54
|
-
if (!(value == null ? void 0 : value.length))
|
|
55
|
-
value = null;
|
|
54
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
56
55
|
else if ((0, import_helpers.isPg)(context)) {
|
|
57
56
|
value = value.join(",");
|
|
58
57
|
}
|
|
@@ -50,8 +50,7 @@ class LineStringField extends import_database.Field {
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
set(value) {
|
|
53
|
-
if (!(value == null ? void 0 : value.length))
|
|
54
|
-
value = null;
|
|
53
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
55
54
|
else if ((0, import_helpers.isPg)(context)) {
|
|
56
55
|
value = (0, import_helpers.joinComma)(value.map(import_helpers.joinComma));
|
|
57
56
|
} else if ((0, import_helpers.isMysql)(context)) {
|
|
@@ -53,8 +53,7 @@ class PointField extends import_database.Field {
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
set(value) {
|
|
56
|
-
if (!(value == null ? void 0 : value.length))
|
|
57
|
-
value = null;
|
|
56
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
58
57
|
else if ((0, import_helpers.isPg)(context)) {
|
|
59
58
|
value = (0, import_helpers.joinComma)(value);
|
|
60
59
|
} else if ((0, import_helpers.isMysql)(context)) {
|
|
@@ -50,8 +50,7 @@ class PolygonField extends import_database.Field {
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
set(value) {
|
|
53
|
-
if (!(value == null ? void 0 : value.length))
|
|
54
|
-
value = null;
|
|
53
|
+
if (!(value == null ? void 0 : value.length)) value = null;
|
|
55
54
|
else if ((0, import_helpers.isPg)(context)) {
|
|
56
55
|
value = (0, import_helpers.joinComma)(value.map((item) => (0, import_helpers.joinComma)(item)));
|
|
57
56
|
} else if ((0, import_helpers.isMysql)(context)) {
|
|
@@ -35,13 +35,11 @@ __export(helpers_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(helpers_exports);
|
|
37
37
|
const joinComma = (value) => {
|
|
38
|
-
if (!value)
|
|
39
|
-
return null;
|
|
38
|
+
if (!value) return null;
|
|
40
39
|
return `(${value.join(",")})`;
|
|
41
40
|
};
|
|
42
41
|
const toValue = (value) => {
|
|
43
|
-
if (!value)
|
|
44
|
-
return null;
|
|
42
|
+
if (!value) return null;
|
|
45
43
|
return JSON.parse(value.replace(/\(/g, "[").replace(/\)/g, "]"));
|
|
46
44
|
};
|
|
47
45
|
const getDialect = (ctx) => {
|
|
@@ -35,25 +35,21 @@ module.exports = __toCommonJS(interfaces_exports);
|
|
|
35
35
|
var import_database = require("@nocobase/database");
|
|
36
36
|
class PointInterface extends import_database.BaseInterface {
|
|
37
37
|
async toValue(str, ctx) {
|
|
38
|
-
if (!str)
|
|
39
|
-
return null;
|
|
38
|
+
if (!str) return null;
|
|
40
39
|
return str.split(",").map((v) => parseFloat(v));
|
|
41
40
|
}
|
|
42
41
|
toString(value, ctx) {
|
|
43
|
-
if (!value)
|
|
44
|
-
return null;
|
|
42
|
+
if (!value) return null;
|
|
45
43
|
return value.join(",");
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
class PolygonInterface extends import_database.BaseInterface {
|
|
49
47
|
async toValue(str, ctx) {
|
|
50
|
-
if (!str)
|
|
51
|
-
return null;
|
|
48
|
+
if (!str) return null;
|
|
52
49
|
return str.substring(1, str.length - 1).split("),(").map((v) => v.split(",").map((v2) => parseFloat(v2)));
|
|
53
50
|
}
|
|
54
51
|
toString(value, ctx) {
|
|
55
|
-
if (!value)
|
|
56
|
-
return null;
|
|
52
|
+
if (!value) return null;
|
|
57
53
|
return `(${value.map((v) => v.join(",")).join("),(")})`;
|
|
58
54
|
}
|
|
59
55
|
}
|
|
@@ -61,13 +57,11 @@ class LineStringInterface extends PolygonInterface {
|
|
|
61
57
|
}
|
|
62
58
|
class CircleInterface extends import_database.BaseInterface {
|
|
63
59
|
async toValue(str, ctx) {
|
|
64
|
-
if (!str)
|
|
65
|
-
return null;
|
|
60
|
+
if (!str) return null;
|
|
66
61
|
return str.split(",").map((v) => parseFloat(v));
|
|
67
62
|
}
|
|
68
63
|
toString(value, ctx) {
|
|
69
|
-
if (!value)
|
|
70
|
-
return null;
|
|
64
|
+
if (!value) return null;
|
|
71
65
|
return value.join(",");
|
|
72
66
|
}
|
|
73
67
|
}
|
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.2.
|
|
5
|
+
"version": "1.2.36-alpha",
|
|
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": "850d812db1d8e7c0b62b77c6a262ab9faf9e203f",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Blocks"
|
|
42
42
|
]
|