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