@nocobase/plugin-map 0.14.0-alpha.7 → 0.14.0-alpha.8
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
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
(function(O,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@formily/shared"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","react-i18next","@ant-design/icons","@formily/react","ahooks","antd","react-router-dom","lodash","@formily/shared","@formily/antd-v5"],r):(O=typeof globalThis!="undefined"?globalThis:O||self,r(O["@nocobase/plugin-map"]={},O.jsxRuntime,O["@nocobase/client"],O.react,O["react-i18next"],O["@ant-design/icons"],O["@formily/react"],O.ahooks,O.antd,O["react-router-dom"],O.lodash,O["@formily/shared"],O["@formily/antd-v5"]))})(this,function(O,r,s,d,le,ee,X,N,x,re,be,We,Ye){"use strict";var Dt=Object.defineProperty,Tt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ge=(O,r,s)=>r in O?Dt(O,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):O[r]=s,I=(O,r)=>{for(var s in r||(r={}))qe.call(r,s)&&Ge(O,s,r[s]);if(de)for(var s of de(r))je.call(r,s)&&Ge(O,s,r[s]);return O},Y=(O,r)=>Tt(O,Kt(r));var Ve=(O,r)=>{var s={};for(var d in O)qe.call(O,d)&&r.indexOf(d)<0&&(s[d]=O[d]);if(O!=null&&de)for(var d of de(O))r.indexOf(d)<0&&je.call(O,d)&&(s[d]=O[d]);return s};var fe=(O,r,s)=>new Promise((d,le)=>{var ee=x=>{try{N(s.next(x))}catch(re){le(re)}},X=x=>{try{N(s.throw(x))}catch(re){le(re)}},N=x=>x.done?d(x.value):Promise.resolve(x.value).then(ee,X);N((s=s.apply(O,r)).next())});const Me="map";function R(e){return`{{t('${e}', { ns: '${Me}', nsMode: 'fallback' })}}`}function H(){return le.useTranslation(Me,{nsMode:"fallback"})}const _e={"data-testid":"configure-actions-button-of-map-block",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",children:[{type:"item",title:"{{t('Filter')}}",component:"FilterActionInitializer",schema:{"x-align":"left"}},{type:"item",title:"{{t('Add new')}}",component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},visible:function(){return s.useCollection().template!=="sql"}},{type:"item",title:"{{t('Refresh')}}",component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{type:"divider",visible:function(){return s.useCollection().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',children:[{type:"item",title:'{{t("Bulk update")}}',component:"CustomizeActionInitializer",schema:{type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-designer":"Action.Designer","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined",useProps:"{{ useCustomizeBulkUpdateActionProps }}"}}},{type:"item",title:'{{t("Bulk edit")}}',component:"CustomizeBulkEditActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"update","x-acl-action-props":{skipScopeCheck:!0}}}],visible:function(){return s.useCollection().template!=="sql"}}]},Ce=[{label:R("AMap"),value:"amap"},{label:R("Google Maps"),value:"google"}],ge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ae="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==";var Je=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xe={exports:{}};(function(e,n){(function(t,o){e.exports=o()})(Je,function(){function t(c){var g=[];return c.AMapUI&&g.push(o(c.AMapUI)),c.Loca&&g.push(a(c.Loca)),Promise.all(g)}function o(c){return new Promise(function(g,p){var m=[];if(c.plugins)for(var v=0;v<c.plugins.length;v+=1)l.AMapUI.plugins.indexOf(c.plugins[v])==-1&&m.push(c.plugins[v]);if(h.AMapUI===i.failed)p("前次请求 AMapUI 失败");else if(h.AMapUI===i.notload){h.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,v=l.AMapUI.version;var K=document.body||document.head,F=document.createElement("script");F.type="text/javascript",F.src="https://webapi.amap.com/ui/"+v+"/main.js",F.onerror=function(P){h.AMapUI=i.failed,p("请求 AMapUI 失败")},F.onload=function(){if(h.AMapUI=i.loaded,m.length)window.AMapUI.loadUI(m,function(){for(var P=0,T=m.length;P<T;P++){var V=m[P].split("/").slice(-1)[0];window.AMapUI[V]=arguments[P]}for(g();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(g();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},K.appendChild(F)}else h.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):m.length?window.AMapUI.loadUI(m,function(){for(var P=0,T=m.length;P<T;P++){var V=m[P].split("/").slice(-1)[0];window.AMapUI[V]=arguments[P]}g()}):g():c.version&&c.version!==l.AMapUI.version?p("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(P){P?p(P):m.length?window.AMapUI.loadUI(m,function(){for(var T=0,V=m.length;T<V;T++){var D=m[T].split("/").slice(-1)[0];window.AMapUI[D]=arguments[T]}g()}):g()})})}function a(c){return new Promise(function(g,p){if(h.Loca===i.failed)p("前次请求 Loca 失败");else if(h.Loca===i.notload){h.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var m=l.Loca.version,v=l.AMap.version.startsWith("2"),K=m.startsWith("2");if(v&&!K||!v&&K)p("JSAPI 与 Loca 版本不对应!!");else{v=l.key,K=document.body||document.head;var F=document.createElement("script");F.type="text/javascript",F.src="https://webapi.amap.com/loca?v="+m+"&key="+v,F.onerror=function(P){h.Loca=i.failed,p("请求 AMapUI 失败")},F.onload=function(){for(h.Loca=i.loaded,g();A.Loca.length;)A.Loca.splice(0,1)[0]()},K.appendChild(F)}}else h.Loca===i.loaded?c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):g():c.version&&c.version!==l.Loca.version?p("不允许多个版本 Loca 混用"):A.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 l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]},S=[],b=function(c){typeof c=="function"&&(h.AMap===i.loaded?c(window.AMap):S.push(c))};return{load:function(c){return new Promise(function(g,p){if(h.AMap==i.failed)p("");else if(h.AMap==i.notload){var m=c.key,v=c.version,K=c.plugins;m?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),l.key=m,l.AMap.version=v||l.AMap.version,l.AMap.plugins=K||l.AMap.plugins,h.AMap=i.loading,v=document.body||document.head,window.___onAPILoaded=function(P){if(delete window.___onAPILoaded,P)h.AMap=i.failed,p(P);else for(h.AMap=i.loaded,t(c).then(function(){g(window.AMap)}).catch(p);S.length;)S.splice(0,1)[0]()},K=document.createElement("script"),K.type="text/javascript",K.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+m+"&plugin="+l.AMap.plugins.join(","),K.onerror=function(P){h.AMap=i.failed,p(P)},v.appendChild(K)):p("请填写key")}else if(h.AMap==i.loaded)if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(m=[],c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&m.push(c.plugins[v]);m.length?window.AMap.plugin(m,function(){t(c).then(function(){g(window.AMap)}).catch(p)}):t(c).then(function(){g(window.AMap)}).catch(p)}else if(c.key&&c.key!==l.key)p("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)p("不允许多个版本 JSAPI 混用");else{var F=[];if(c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&F.push(c.plugins[v]);b(function(){F.length?window.AMap.plugin(F,function(){t(c).then(function(){g(window.AMap)}).catch(p)}):t(c).then(function(){g(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},h={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(xe);var Ze=xe.exports;const He=Xe(Ze),we="map-configuration",me=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,he=e=>{const n=d.useMemo(()=>{const o=sessionStorage.getItem(me(e));return o&&JSON.parse(o)},[e]),{data:t}=s.useRequest({resource:we,action:"get",params:{type:e}},{onSuccess(o){sessionStorage.setItem(me(e),JSON.stringify(o==null?void 0:o.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!n});return n||(t==null?void 0:t.data)},Qe=e=>{const{aMap:n,toCenter:t}=e,{t:o}=H(),a=d.useRef(),[i,l]=d.useState([]);d.useEffect(()=>{n==null||n.plugin("AMap.PlaceSearch",()=>{a.current=new n.PlaceSearch({city:"全国",pageSize:30})})},[n]);const{run:h}=N.useDebounceFn(S=>{a.current&&a.current.search(S||" ",(b,c)=>{if(b==="complete")l(c.poiList.pois.map(g=>Y(I({},g),{label:`${g.name}-${g.address}`,value:g.id})));else{if(b==="no_data"){l([]);return}x.message.error(o("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),A=S=>{const b=i.find(c=>c.value===S);b!=null&&b.location&&t(b.location)};return r.jsx("div",{className:s.css`
|
|
1
|
+
(function(F,r){typeof exports=="object"&&typeof module!="undefined"?r(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-router-dom"),require("lodash"),require("@formily/shared"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","react-i18next","@ant-design/icons","@formily/react","ahooks","antd","react-router-dom","lodash","@formily/shared","@formily/antd-v5"],r):(F=typeof globalThis!="undefined"?globalThis:F||self,r(F["@nocobase/plugin-map"]={},F.jsxRuntime,F["@nocobase/client"],F.react,F["react-i18next"],F["@ant-design/icons"],F["@formily/react"],F.ahooks,F.antd,F["react-router-dom"],F.lodash,F["@formily/shared"],F["@formily/antd-v5"]))})(this,function(F,r,s,d,le,te,X,N,x,re,be,We,Ye){"use strict";var Dt=Object.defineProperty,Tt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var qe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Ge=(F,r,s)=>r in F?Dt(F,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):F[r]=s,I=(F,r)=>{for(var s in r||(r={}))qe.call(r,s)&&Ge(F,s,r[s]);if(de)for(var s of de(r))je.call(r,s)&&Ge(F,s,r[s]);return F},Y=(F,r)=>Tt(F,Kt(r));var Ve=(F,r)=>{var s={};for(var d in F)qe.call(F,d)&&r.indexOf(d)<0&&(s[d]=F[d]);if(F!=null&&de)for(var d of de(F))r.indexOf(d)<0&&je.call(F,d)&&(s[d]=F[d]);return s};var fe=(F,r,s)=>new Promise((d,le)=>{var te=x=>{try{N(s.next(x))}catch(re){le(re)}},X=x=>{try{N(s.throw(x))}catch(re){le(re)}},N=x=>x.done?d(x.value):Promise.resolve(x.value).then(te,X);N((s=s.apply(F,r)).next())});const Me="map";function R(e){return`{{t('${e}', { ns: '${Me}', nsMode: 'fallback' })}}`}function H(){return le.useTranslation(Me,{nsMode:"fallback"})}const _e={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",children:[{type:"item",title:"{{t('Filter')}}",component:"FilterActionInitializer",schema:{"x-align":"left"}},{type:"item",title:"{{t('Add new')}}",component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},visible:function(){return s.useCollection().template!=="sql"}},{type:"item",title:"{{t('Refresh')}}",component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{type:"divider",visible:function(){return s.useCollection().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',children:[{type:"item",title:'{{t("Bulk update")}}',component:"CustomizeActionInitializer",schema:{type:"void",title:'{{ t("Bulk update") }}',"x-component":"Action","x-align":"right","x-acl-action":"update","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-action":"customize:bulkUpdate","x-designer":"Action.Designer","x-action-settings":{assignedValues:{},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component-props":{icon:"EditOutlined",useProps:"{{ useCustomizeBulkUpdateActionProps }}"}}},{type:"item",title:'{{t("Bulk edit")}}',component:"CustomizeBulkEditActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action":"update","x-acl-action-props":{skipScopeCheck:!0}}}],visible:function(){return s.useCollection().template!=="sql"}}]},Ce=[{label:R("AMap"),value:"amap"},{label:R("Google Maps"),value:"google"}],ge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ae="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==";var Je=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xe={exports:{}};(function(e,n){(function(t,o){e.exports=o()})(Je,function(){function t(u){var g=[];return u.AMapUI&&g.push(o(u.AMapUI)),u.Loca&&g.push(a(u.Loca)),Promise.all(g)}function o(u){return new Promise(function(g,c){var m=[];if(u.plugins)for(var v=0;v<u.plugins.length;v+=1)l.AMapUI.plugins.indexOf(u.plugins[v])==-1&&m.push(u.plugins[v]);if(y.AMapUI===i.failed)c("前次请求 AMapUI 失败");else if(y.AMapUI===i.notload){y.AMapUI=i.loading,l.AMapUI.version=u.version||l.AMapUI.version,v=l.AMapUI.version;var K=document.body||document.head,E=document.createElement("script");E.type="text/javascript",E.src="https://webapi.amap.com/ui/"+v+"/main.js",E.onerror=function(O){y.AMapUI=i.failed,c("请求 AMapUI 失败")},E.onload=function(){if(y.AMapUI=i.loaded,m.length)window.AMapUI.loadUI(m,function(){for(var O=0,T=m.length;O<T;O++){var V=m[O].split("/").slice(-1)[0];window.AMapUI[V]=arguments[O]}for(g();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(g();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},K.appendChild(E)}else y.AMapUI===i.loaded?u.version&&u.version!==l.AMapUI.version?c("不允许多个版本 AMapUI 混用"):m.length?window.AMapUI.loadUI(m,function(){for(var O=0,T=m.length;O<T;O++){var V=m[O].split("/").slice(-1)[0];window.AMapUI[V]=arguments[O]}g()}):g():u.version&&u.version!==l.AMapUI.version?c("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(O){O?c(O):m.length?window.AMapUI.loadUI(m,function(){for(var T=0,V=m.length;T<V;T++){var D=m[T].split("/").slice(-1)[0];window.AMapUI[D]=arguments[T]}g()}):g()})})}function a(u){return new Promise(function(g,c){if(y.Loca===i.failed)c("前次请求 Loca 失败");else if(y.Loca===i.notload){y.Loca=i.loading,l.Loca.version=u.version||l.Loca.version;var m=l.Loca.version,v=l.AMap.version.startsWith("2"),K=m.startsWith("2");if(v&&!K||!v&&K)c("JSAPI 与 Loca 版本不对应!!");else{v=l.key,K=document.body||document.head;var E=document.createElement("script");E.type="text/javascript",E.src="https://webapi.amap.com/loca?v="+m+"&key="+v,E.onerror=function(O){y.Loca=i.failed,c("请求 AMapUI 失败")},E.onload=function(){for(y.Loca=i.loaded,g();A.Loca.length;)A.Loca.splice(0,1)[0]()},K.appendChild(E)}}else y.Loca===i.loaded?u.version&&u.version!==l.Loca.version?c("不允许多个版本 Loca 混用"):g():u.version&&u.version!==l.Loca.version?c("不允许多个版本 Loca 混用"):A.Loca.push(function(O){O?c(O):c()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(u){u.notload="notload",u.loading="loading",u.loaded="loaded",u.failed="failed"})(i||(i={}));var l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},y={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]},S=[],b=function(u){typeof u=="function"&&(y.AMap===i.loaded?u(window.AMap):S.push(u))};return{load:function(u){return new Promise(function(g,c){if(y.AMap==i.failed)c("");else if(y.AMap==i.notload){var m=u.key,v=u.version,K=u.plugins;m?(window.AMap&&location.host!=="lbs.amap.com"&&c("禁止多种API加载方式混用"),l.key=m,l.AMap.version=v||l.AMap.version,l.AMap.plugins=K||l.AMap.plugins,y.AMap=i.loading,v=document.body||document.head,window.___onAPILoaded=function(O){if(delete window.___onAPILoaded,O)y.AMap=i.failed,c(O);else for(y.AMap=i.loaded,t(u).then(function(){g(window.AMap)}).catch(c);S.length;)S.splice(0,1)[0]()},K=document.createElement("script"),K.type="text/javascript",K.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+m+"&plugin="+l.AMap.plugins.join(","),K.onerror=function(O){y.AMap=i.failed,c(O)},v.appendChild(K)):c("请填写key")}else if(y.AMap==i.loaded)if(u.key&&u.key!==l.key)c("多个不一致的 key");else if(u.version&&u.version!==l.AMap.version)c("不允许多个版本 JSAPI 混用");else{if(m=[],u.plugins)for(v=0;v<u.plugins.length;v+=1)l.AMap.plugins.indexOf(u.plugins[v])==-1&&m.push(u.plugins[v]);m.length?window.AMap.plugin(m,function(){t(u).then(function(){g(window.AMap)}).catch(c)}):t(u).then(function(){g(window.AMap)}).catch(c)}else if(u.key&&u.key!==l.key)c("多个不一致的 key");else if(u.version&&u.version!==l.AMap.version)c("不允许多个版本 JSAPI 混用");else{var E=[];if(u.plugins)for(v=0;v<u.plugins.length;v+=1)l.AMap.plugins.indexOf(u.plugins[v])==-1&&E.push(u.plugins[v]);b(function(){E.length?window.AMap.plugin(E,function(){t(u).then(function(){g(window.AMap)}).catch(c)}):t(u).then(function(){g(window.AMap)}).catch(c)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,l={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},y={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(xe);var Ze=xe.exports;const He=Xe(Ze),we="map-configuration",me=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,he=e=>{const n=d.useMemo(()=>{const o=sessionStorage.getItem(me(e));return o&&JSON.parse(o)},[e]),{data:t}=s.useRequest({resource:we,action:"get",params:{type:e}},{onSuccess(o){sessionStorage.setItem(me(e),JSON.stringify(o==null?void 0:o.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!n});return n||(t==null?void 0:t.data)},Qe=e=>{const{aMap:n,toCenter:t}=e,{t:o}=H(),a=d.useRef(),[i,l]=d.useState([]);d.useEffect(()=>{n==null||n.plugin("AMap.PlaceSearch",()=>{a.current=new n.PlaceSearch({city:"全国",pageSize:30})})},[n]);const{run:y}=N.useDebounceFn(S=>{a.current&&a.current.search(S||" ",(b,u)=>{if(b==="complete")l(u.poiList.pois.map(g=>Y(I({},g),{label:`${g.name}-${g.address}`,value:g.id})));else{if(b==="no_data"){l([]);return}x.message.error(o("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),A=S=>{const b=i.find(u=>u.value===S);b!=null&&b.location&&t(b.location)};return r.jsx("div",{className:s.css`
|
|
2
2
|
position: absolute;
|
|
3
3
|
top: 10px;
|
|
4
4
|
left: 10px;
|
|
5
5
|
z-index: 10;
|
|
6
6
|
width: calc(100% - 20px);
|
|
7
|
-
`,children:r.jsx(x.Select,{
|
|
7
|
+
`,children:r.jsx(x.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:y,onSelect:A,options:i,popupMatchSelectWidth:!1})})},ye={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"}},Se=d.forwardRef((e,n)=>{const{accessKey:t,securityJsCode:o}=he(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:y,disabled:A=l,zoom:S=13,overlayCommonOptions:b}=e,{t:u}=H(),g=X.useFieldSchema(),c=d.useRef(),m=d.useRef(),v=d.useRef(),[K,E]=d.useState([]),[O,T]=d.useState(""),{getField:V}=s.useCollection(),D=d.useMemo(()=>{if(e.type)return e.type;const p=V(g==null?void 0:g.name);return p==null?void 0:p.interface},[e==null?void 0:e.type,g==null?void 0:g.name]),z=d.useRef(),P=d.useRef(null),G=re.useNavigate(),Q=d.useRef(`nocobase-map-${D||""}-${Date.now().toString(32)}`),{modal:$}=x.App.useApp(),[_]=d.useState(I({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},b)),ee=N.useMemoizedFn(()=>{z.current&&z.current.remove()}),k=N.useMemoizedFn(()=>{(!A||l)&&D!=="point"&&P.current&&(P.current.setTarget(z.current),P.current.open())}),J=N.useMemoizedFn((p,f=!1)=>{let h=null;if(D==="point"){const{lat:C,lng:U}=p.getPosition();h=[U,C]}else if(D==="polygon"||D==="lineString"){if(h=p.getPath().map(C=>[C.lng,C.lat]),h.length<2)return}else if(D==="circle"){const C=p.getCenter(),U=p.getRadius();h=[C.lng,C.lat,U]}f||(ee(),z.current=p,k()),i==null||i(h)}),q=N.useMemoizedFn((p=D)=>{const f=ye[p];if(f&&"editor"in f&&!P.current)return P.current=new c.current[f.editor](m.current,null,{createOptions:_,editOptions:_,controlPoint:Y(I({},_),{strokeWeight:3}),midControlPoint:Y(I({},_),{strokeWeight:2,fillColor:"#fff"})}),P.current.on("adjust",function({target:h}){J(h,!0)}),P.current.on("move",function({target:h}){J(h,!0)}),P.current}),Z=N.useMemoizedFn((p=D)=>{var h;if(!v.current||(h=P.current)!=null&&h.getTarget())return;const f=ye[p];f&&v.current[f.mouseTool](I({},_))}),w=N.useMemoizedFn((p=D)=>{v.current||(v.current=new c.current.MouseTool(m.current),v.current.on("draw",function({obj:f}){J(f)}),Z(p))}),L=(p,f)=>{m.current&&m.current.setZoomAndCenter(18,p,f)},M=()=>{const p=()=>{ee(),P.current&&(P.current.setTarget(),P.current.close()),i==null||i(null)};$.confirm({title:u("Clear the canvas"),content:u("Are you sure to clear the canvas?"),okText:u("Confirm"),cancelText:u("Cancel"),getContainer:()=>document.getElementById(Q.current),onOk(){p()}})},B=()=>{z.current&&m.current.setFitView([z.current])},W=d.useCallback((p=D,f=a,h)=>{const C=ye[p];if(!C)return;const U=I(I({},_),h);return"transformOptions"in C?Object.assign(U,C.transformOptions(f)):"propertyKey"in C&&(U[C.propertyKey]=f),new c.current[C.overlay](U)},[_]),j=(p=D,f=a,h)=>{if(!c.current)return;const C=W(p,f,h);return C.setMap(m.current),C};return d.useEffect(()=>{if(!c.current||!a||!y&&z.current)return;const p=j();m.current.setFitView([p]),z.current=p,A||(q(),k())},[a,K,D,_,A,y]),d.useEffect(()=>{var p,f,h;v.current&&(A?((p=v.current)==null||p.close(),(f=P.current)==null||f.close()):(Z(),(h=P.current)==null||h.open()))},[A]),d.useEffect(()=>{!c.current||!D||A||(w(),q())},[A,K,D]),d.useEffect(()=>{var f,h;if(!a&&(v.current||P.current)&&(ee(),P.current&&(P.current.setTarget(),P.current.close()),i==null||i(null)),!v.current||!P.current)return;P.current.getTarget()?(h=(f=v.current).close)==null||h.call(f):Z()},[D,a]),d.useEffect(()=>{if(!t||m.current)return;o&&(window._AMapSecurityConfig={[o.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:o});const p=window.define;return window.define=void 0,He.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(f=>(window.define=p,requestIdleCallback(()=>{m.current=new f.Map(Q.current,{resizeEnable:!0,zoom:S}),c.current=f,T(""),E([])}))).catch(f=>{typeof f=="string"?f.includes("多个不一致的 key")?T(u("The AccessKey is incorrect, please check it")):T(f):(f==null?void 0:f.type)==="error"&&T("Something went wrong, please refresh the page and try again")}),()=>{var f;(f=m.current)==null||f.destroy(),c.current=null,m.current=null,v.current=null,P.current=null}},[t,D,o]),d.useImperativeHandle(n,()=>({setOverlay:j,getOverlay:W,createMouseTool:w,createEditor:q,executeMouseTool:Z,aMap:c.current,map:m.current,overlay:z.current,mouseTool:()=>v.current,editor:()=>P.current,errMessage:O})),!t||O?r.jsx(x.Alert,{action:r.jsx(x.Button,{type:"primary",onClick:()=>G("/admin/settings/map/configuration"),children:u("Go to the configuration page")}),message:O||u("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):r.jsxs("div",{className:s.css`
|
|
8
8
|
position: relative;
|
|
9
9
|
height: 500px;
|
|
10
|
-
`,id:Q.current,style:e==null?void 0:e.style,children:[!
|
|
10
|
+
`,id:Q.current,style:e==null?void 0:e.style,children:[!c.current&&r.jsx("div",{className:s.css`
|
|
11
11
|
position: absolute;
|
|
12
12
|
inset: 0;
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
justify-content: center;
|
|
16
|
-
`,children:r.jsx(x.Spin,{})}),A?null:r.jsxs(r.Fragment,{children:[r.jsx(Qe,{toCenter:L,aMap:
|
|
16
|
+
`,children:r.jsx(x.Spin,{})}),A?null:r.jsxs(r.Fragment,{children:[r.jsx(Qe,{toCenter:L,aMap:c.current}),r.jsx("div",{className:s.css`
|
|
17
17
|
position: absolute;
|
|
18
18
|
bottom: 80px;
|
|
19
19
|
right: 20px;
|
|
20
20
|
z-index: 10;
|
|
21
|
-
`,children:r.jsx(x.Button,{onClick:B,disabled:!z.current,type:"primary",shape:"round",size:"large",icon:r.jsx(
|
|
21
|
+
`,children:r.jsx(x.Button,{onClick:B,disabled:!z.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),D!=="point"?r.jsx("div",{className:s.css`
|
|
22
22
|
position: absolute;
|
|
23
23
|
bottom: 20px;
|
|
24
24
|
left: 10px;
|
|
25
25
|
z-index: 2;
|
|
26
26
|
pointer-events: none;
|
|
27
|
-
`,children:r.jsx(x.Alert,{message:
|
|
27
|
+
`,children:r.jsx(x.Alert,{message:u("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,r.jsx("div",{className:s.css`
|
|
28
28
|
position: absolute;
|
|
29
29
|
bottom: 20px;
|
|
30
30
|
right: 20px;
|
|
31
31
|
z-index: 2;
|
|
32
|
-
`,children:r.jsx(x.Button,{disabled:!a,style:{height:"40px"},onClick:M,type:"primary",danger:!0,children:
|
|
32
|
+
`,children:r.jsx(x.Button,{disabled:!a,style:{height:"40px"},onClick:M,type:"primary",danger:!0,children:u("Clear")})})]})]})}),Ie=(e,n,t)=>{const o=n==null?void 0:n.reduce((a,i,l)=>l===n.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(y=>y[i]).filter(y=>y!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?o:[o]},$e=e=>{var k,J,q,Z;const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l}=s.useProps(e),{name:y,getPrimaryKey:A}=s.useCollection(),{getCollectionJoinField:S}=s.useCollectionManager(),b=A(),[u,g]=d.useState(!1),c=d.useRef(),m=(J=(k=c.current)==null?void 0:k.aMap)==null?void 0:J.GeometryUtil,[v,K]=d.useState(),[E,O]=d.useState(""),{t:T}=H(),V=s.useCompile(),{isConnected:D,doFilter:z}=s.useFilterAPI(),[,P]=d.useState(null),G=d.useRef(E);G.current=E;const Q=(w,L)=>{const M=w.getExtData(),B=typeof L=="undefined"?M.selected:!L;M.selected=!B,"setIcon"in w&&w.setIcon(new c.current.aMap.Icon({imageSize:[19,32],image:B?ae:ge})),w.setOptions(I({extData:M},B?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},$=()=>{var w,L,M;c.current&&((w=c.current)==null||w.mouseTool().close(!0),(L=c.current)==null||L.editor().setTarget(null),(M=c.current)==null||M.editor().close())};d.useEffect(()=>{var w,L,M,B;if(E==="selection")return(w=c.current)!=null&&w.editor()?(B=c.current)==null||B.executeMouseTool("polygon"):((L=c.current)==null||L.createEditor("polygon"),(M=c.current)==null||M.createMouseTool("polygon")),()=>{$()}},[E]),d.useEffect(()=>{if(E)return()=>{var w;G.current||(w=c.current)==null||w.map.getAllOverlays().forEach(L=>{Q(L,!1)})}},[E]);const _=N.useMemoizedFn(()=>{var W,j,p;const w=(W=c.current)==null?void 0:W.editor().getTarget(),L=(j=c.current)==null?void 0:j.map.getAllOverlays(),M=L==null?void 0:L.filter(f=>{if(!(f===w||f.getExtData().id===void 0))return"getPosition"in f?m.isPointInRing(f.getPosition(),w==null?void 0:w.getPath()):m.doesRingRingIntersect(f.getPath(),w==null?void 0:w.getPath())}),B=M==null?void 0:M.map(f=>(Q(f,!0),f.getExtData().id));l(f=>B==null?void 0:B.concat(f)),w==null||w.remove(),(p=c.current)==null||p.editor().close()});d.useEffect(()=>{var W,j;if(!n||!c.current||!o)return;const w=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=S([y,...w].flat().join(".")),M=o.map(p=>{const f=Ie(p,t==null?void 0:t.field,L==null?void 0:L.interface);return f!=null&&f.length?f==null?void 0:f.filter(Boolean).map(h=>{var U;return(U=c.current)==null?void 0:U.setOverlay(n.type,h,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?V(p[t.marker]):void 0},extData:{id:p[b]}})}):[]}).flat().filter(Boolean);(j=(W=c.current)==null?void 0:W.map)==null||j.setFitView(M);const B=M.map(p=>{const f=h=>{const C=h.target,U=C.getExtData();if(!U)return;if(G.current){G.current==="click"&&(l(oe=>U.selected?oe.filter(Ae=>Ae!==U.id):[...oe,U.id]),Q(C));return}const pe=o.find(oe=>U.id===oe[b]);if(D){P(oe=>(oe&&Pe(oe),oe===p?(Pe(p),z(null),null):(et(p),z(pe[b],Ae=>Ae.field||b,"$eq"),p)));return}pe&&K(pe)};return p.on("click",f),()=>p.off("click",f)});return()=>{M.forEach(p=>{p.remove()}),B.forEach(p=>p())}},[o,u,t,y,b,n.type,D]),d.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const ee=w=>{c.current=w,g(!!(w!=null&&w.map)&&!w.errMessage)};return r.jsxs("div",{className:s.css`
|
|
33
33
|
position: relative;
|
|
34
34
|
height: 100%;
|
|
35
35
|
`,children:[r.jsx("div",{className:s.css`
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
left: 10px;
|
|
38
38
|
top: 10px;
|
|
39
39
|
z-index: 999;
|
|
40
|
-
`,children:
|
|
40
|
+
`,children:u&&!((q=c.current)!=null&&q.errMessage)?r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:E?void 0:"#F18b62",borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),O("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(x.Button,{style:{color:E==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),O("selection")},icon:r.jsx(te.ExpandOutlined,{})}),E==="selection"?r.jsx(x.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:T("Confirm selection"),onClick:_}):null]}):null}),r.jsx(Re,{record:v,setVisible:K}),r.jsx(Se,Y(I({},(Z=n==null?void 0:n.uiSchema)==null?void 0:Z["x-component-props"]),{ref:ee,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},Re=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=d.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:n},children:r.jsx(s.RecordProvider,{record:t,children:r.jsx(X.RecursionField,{schema:a,name:a.name})})})};function Pe(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function et(e){e.dom?e.dom.style.filter="brightness(1.2) contrast(1.2) hue-rotate(180deg)":e.setOptions&&e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const ke=({type:e,children:n})=>{const{t}=H(),[o,a]=N.useBoolean(!1),i=s.useAPIClient(),[l]=x.Form.useForm(),y=he(e);d.useEffect(()=>{y&&(l.setFieldsValue(y),a.toggle())},[y]);const A=d.useMemo(()=>i.resource(we),[i]),S=b=>{A.set(Y(I({},b),{type:e})).then(u=>{sessionStorage.removeItem(me(e)),a.toggle(),x.message.success(t("Saved successfully"))}).catch(u=>{x.message.success(t("Saved failed"))})};return r.jsxs(x.Form,{disabled:o,form:l,layout:"vertical",onFinish:S,children:[n,o?r.jsx(x.Button,{disabled:!1,onClick:a.toggle,children:t("Edit")}):r.jsx(x.Form.Item,{children:r.jsx(x.Button,{disabled:!1,type:"primary",htmlType:"submit",children:t("Save")})})]})},tt={amap:()=>{const{t:e}=H();return r.jsxs(ke,{type:"amap",children:[r.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:r.jsx(x.Input,{})}),r.jsx(x.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:r.jsx(x.Input,{})})]})},google:()=>{const{t:e}=H();return r.jsx(ke,{type:"google",children:r.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:r.jsx(x.Input,{})})})}},ot=Ce.map(e=>Y(I({},e),{component:tt[e.value]})),rt=()=>{const e=s.useCompile(),n=re.useLocation(),t=new URLSearchParams(n.search);return r.jsx(x.Card,{bordered:!0,children:r.jsx(x.Tabs,{type:"card",defaultActiveKey:t.get("tab"),children:ot.map(o=>r.jsx(x.Tabs.TabPane,{tab:e(o.label),children:r.jsx(o.component,{type:o.value})},o.value))})})};/*! *****************************************************************************
|
|
41
41
|
Copyright (c) Microsoft Corporation.
|
|
42
42
|
|
|
43
43
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
51
51
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
52
52
|
PERFORMANCE OF THIS SOFTWARE.
|
|
53
|
-
***************************************************************************** */function nt(e,n,t,o){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function
|
|
53
|
+
***************************************************************************** */function nt(e,n,t,o){function a(i){return i instanceof t?i:new t(function(l){l(i)})}return new(t||(t=Promise))(function(i,l){function y(b){try{S(o.next(b))}catch(u){l(u)}}function A(b){try{S(o.throw(b))}catch(u){l(u)}}function S(b){b.done?i(b.value):a(b.value).then(y,A)}S((o=o.apply(e,n||[])).next())})}var st=function e(n,t){if(n===t)return!0;if(n&&t&&typeof n=="object"&&typeof t=="object"){if(n.constructor!==t.constructor)return!1;var o,a,i;if(Array.isArray(n)){if(o=n.length,o!=t.length)return!1;for(a=o;a--!==0;)if(!e(n[a],t[a]))return!1;return!0}if(n.constructor===RegExp)return n.source===t.source&&n.flags===t.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===t.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===t.toString();if(i=Object.keys(n),o=i.length,o!==Object.keys(t).length)return!1;for(a=o;a--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[a]))return!1;for(a=o;a--!==0;){var l=i[a];if(!e(n[l],t[l]))return!1}return!0}return n!==n&&t!==t};const Oe="__googleMapsScriptId";var se;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(se||(se={}));class ne{constructor({apiKey:n,authReferrerPolicy:t,channel:o,client:a,id:i=Oe,language:l,libraries:y=[],mapIds:A,nonce:S,region:b,retries:u=3,url:g="https://maps.googleapis.com/maps/api/js",version:c}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=n,this.authReferrerPolicy=t,this.channel=o,this.client=a,this.id=i||Oe,this.language=l,this.libraries=y,this.mapIds=A,this.nonce=S,this.region=b,this.retries=u,this.url=g,this.version=c,ne.instance){if(!st(this.options,ne.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ne.instance.options)}`);return ne.instance}ne.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?se.FAILURE:this.done?se.SUCCESS:this.loading?se.LOADING:se.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let n=this.url;return n+="?callback=__googleMapsCallback",this.apiKey&&(n+=`&key=${this.apiKey}`),this.channel&&(n+=`&channel=${this.channel}`),this.client&&(n+=`&client=${this.client}`),this.libraries.length>0&&(n+=`&libraries=${this.libraries.join(",")}`),this.language&&(n+=`&language=${this.language}`),this.region&&(n+=`®ion=${this.region}`),this.version&&(n+=`&v=${this.version}`),this.mapIds&&(n+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(n+=`&auth_referrer_policy=${this.authReferrerPolicy}`),n}deleteScript(){const n=document.getElementById(this.id);n&&n.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((n,t)=>{this.loadCallback(o=>{o?t(o.error):n(window.google)})})}importLibrary(n){return this.execute(),google.maps.importLibrary(n)}loadCallback(n){this.callbacks.push(n),this.execute()}setScript(){var n,t;if(document.getElementById(this.id)){this.callback();return}const o={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(o).forEach(i=>!o[i]&&delete o[i]),!((t=(n=window==null?void 0:window.google)===null||n===void 0?void 0:n.maps)===null||t===void 0)&&t.importLibrary||(i=>{let l,y,A,S="The Google Maps JavaScript API",b="google",u="importLibrary",g="__ib__",c=document,m=window;m=m[b]||(m[b]={});const v=m.maps||(m.maps={}),K=new Set,E=new URLSearchParams,O=()=>l||(l=new Promise((T,V)=>nt(this,void 0,void 0,function*(){var D;yield y=c.createElement("script"),y.id=this.id,E.set("libraries",[...K]+"");for(A in i)E.set(A.replace(/[A-Z]/g,z=>"_"+z[0].toLowerCase()),i[A]);E.set("callback",b+".maps."+g),y.src=this.url+"?"+E,v[g]=T,y.onerror=()=>l=V(Error(S+" could not load.")),y.nonce=this.nonce||((D=c.querySelector("script[nonce]"))===null||D===void 0?void 0:D.nonce)||"",c.head.append(y)})));v[u]?console.warn(S+" only loads once. Ignoring:",i):v[u]=(T,...V)=>K.add(T)&&O().then(()=>v[u](T,...V))})(o);const a=this.libraries.map(i=>this.importLibrary(i));a.length||a.push(this.importLibrary("core")),Promise.all(a).then(()=>this.callback(),i=>{const l=new ErrorEvent("error",{error:i});this.loadErrorCallback(l)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(n){if(this.errors.push(n),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=n,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(n=>{n(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 it=e=>{const{toCenter:n,mapRef:t}=e,{t:o}=H(),a=d.useRef(),[i,l]=d.useState([]);d.useEffect(()=>{google.maps.importLibrary("places").then(S=>{a.current=new S.AutocompleteService}).catch(()=>{x.message.error("Please configure the Google API Key correctly")})},[t]);const{run:y}=N.useDebounceFn(S=>{a.current&&a.current.getPlacePredictions({input:S||" "},(b,u)=>{if(u===google.maps.places.PlacesServiceStatus.OK)l(b.map(g=>{const c=g.structured_formatting;return Y(I({},g),{label:`${c.main_text}${c.secondary_text?" "+c.secondary_text:""}`,value:g.place_id})}));else{l([]);return}})},{wait:300}),A=S=>{const b=i.find(g=>g.value===S);new google.maps.places.PlacesService(t.current).getDetails({placeId:b.place_id,fields:["geometry"]},(g,c)=>{c===google.maps.places.PlacesServiceStatus.OK&&n(g.geometry.location)})};return r.jsx("div",{className:s.css`
|
|
54
54
|
position: absolute;
|
|
55
55
|
top: 10px;
|
|
56
56
|
left: 10px;
|
|
57
57
|
z-index: 10;
|
|
58
58
|
width: calc(100% - 20px);
|
|
59
|
-
`,children:r.jsx(x.Select,{
|
|
59
|
+
`,children:r.jsx(x.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:y,onSelect:A,options:i})})},ie=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,32+10)}),at=()=>new Promise(e=>{const n=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{const{latitude:o,longitude:a}=t.coords;e({lat:o,lng:a})},()=>{n()}):n()}),lt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ct={point:{propertyKey:"position",overlay:"Marker"},polygon:{propertyKey:"paths",overlay:"Polygon"},lineString:{propertyKey:"path",overlay:"Polyline"},circle:{transformOptions(e){return{center:new google.maps.LatLng(e[1],e[0]),radius:e[2]}},overlay:"Circle"}},Fe=d.forwardRef((e,n)=>{const{value:t,onChange:o,block:a=!1,readonly:i,disabled:l=a,zoom:y=13,overlayCommonOptions:A}=e,{accessKey:S}=he(e.mapType)||{},{t:b}=H(),{getField:u}=s.useCollection(),g=X.useFieldSchema(),c=d.useRef(),m=d.useRef(),v=d.useRef(),[K,E]=d.useState([]),[O,T]=d.useState(""),V=s.useAPIClient(),{modal:D}=x.App.useApp(),z=d.useMemo(()=>{if(e.type)return e.type;const p=u(g==null?void 0:g.name);return p==null?void 0:p.interface},[e==null?void 0:e.type,g==null?void 0:g.name]),P=d.useRef(lt(z)),[G]=d.useState(I({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},A)),Q=re.useNavigate(),$=d.useRef(),_=d.useRef(new Set),ee=N.useMemoizedFn(p=>{if(_.current.forEach(f=>{_.current.delete(f)}),"getPath"in p){const f=p.getPath();["insert_at","remove_at","set_at"].forEach(h=>{_.current.add(f.addListener(h,()=>{L(p,!0)}).remove)})}else p instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(f=>{_.current.add(p.addListener(f,()=>{L(p,!0)}).remove)})}),k=N.useMemoizedFn(()=>{var p;v.current&&(v.current.unbindAll(),v.current.setMap(null)),z!=="point"&&((p=c.current)==null||p.setDrawingMode(null))}),J=N.useMemoizedFn(p=>{m.current&&(m.current.setCenter(p),m.current.setZoom(y))}),q=N.useMemoizedFn(p=>{k(),ee(p),v.current=p}),Z=N.useMemoizedFn(p=>{const f=new google.maps.LatLngBounds;p.forEach(h=>{if(h instanceof google.maps.Marker)f.extend(h.getPosition());else if(h instanceof google.maps.Polyline||h instanceof google.maps.Polygon){const C=h.getPath();for(let U=0;U<C.getLength();U++)f.extend(C.getAt(U))}else h instanceof google.maps.Circle&&f.union(h.getBounds())}),m.current.setCenter(f.getCenter())}),w=()=>{v.current&&Z([v.current])},L=N.useMemoizedFn((p,f=!1)=>{let h=null;if(z==="point"){const{lat:C,lng:U}=p.getPosition();h=[U(),C()]}else if(z==="polygon"||z==="lineString"){if(h=p.getPath().getArray().map(C=>[C.lng(),C.lat()]),h.length<2)return}else if(z==="circle"){const C=p.getCenter(),U=p.getRadius();h=[C.lng(),C.lat(),U]}f||q(p),o==null||o(h)}),M=N.useMemoizedFn((p=!1,f)=>{const h=Y(I(I({},G),f),{map:m.current});return c.current=new google.maps.drawing.DrawingManager({drawingMode:P.current,drawingControl:!1,markerOptions:Y(I({},h),{icon:ie(ae)}),polygonOptions:h,polylineOptions:h,circleOptions:h,map:m.current}),p||c.current.addListener("overlaycomplete",C=>{const U=C.overlay;L(U)}),c.current}),B=N.useMemoizedFn((p=z,f=t,h)=>{const C=ct[p];if(!C)return;const U=I(Y(I({},G),{icon:ie(ae)}),h);return"transformOptions"in C?Object.assign(U,C.transformOptions(f)):"propertyKey"in C&&(U[C.propertyKey]=Array.isArray(f[0])?f.map(oe=>new google.maps.LatLng(oe[1],oe[0])):new google.maps.LatLng(f[1],f[0])),new google.maps[C.overlay](U)}),W=N.useMemoizedFn((p=z,f=t,h)=>m.current?B(p,f,Y(I({},h),{map:m.current})):void 0);d.useEffect(()=>{var f,h;if(!t&&m.current&&(k(),(h=(f=c==null?void 0:c.current)==null?void 0:f.setDrawingMode)==null||h.call(f,P.current),o==null||o(null)),!m.current||!t||!i&&v.current)return;const p=W();q(p),Z([p])},[t,K,z,l,i,W,Z,q]),d.useEffect(()=>{if(!S||m.current||!$.current)return;let p;try{p=new ne({apiKey:S,version:"weekly",language:V.auth.getLocale()})}catch(h){T(b("Load google maps failed, Please check the Api key and refresh the page"));return}const f=console.error;return console.error=(h,...C)=>{h!=null&&h.includes("InvalidKeyMapError")&&T(b("Load google maps failed, Please check the Api key and refresh the page")),f(h,...C)},Promise.all([p.importLibrary("drawing"),p.importLibrary("core"),p.importLibrary("geometry")]).then(h=>fe(this,null,function*(){const C=yield at();m.current=new google.maps.Map($.current,{zoom:y,center:C,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),T(""),E([])})).catch(h=>{if(h instanceof Error){T(h.message);return}}),()=>{var h,C;(h=m.current)==null||h.unbindAll(),m.current=null,(C=c.current)==null||C.unbindAll()}},[S,V.auth,z,y]),d.useEffect(()=>{!m.current||!z||l||c.current||M()},[M,l,K,z]),d.useImperativeHandle(n,()=>({setOverlay:W,getOverlay:B,setFitView:Z,createDraw:M,map:m.current,overlay:v.current,drawingManager:c.current,errMessage:O}));const j=N.useMemoizedFn(()=>{const p=()=>{k(),c.current.setDrawingMode(P.current),o==null||o(null)};D.confirm({title:b("Clear the canvas"),content:b("Are you sure to clear the canvas?"),okText:b("Confirm"),cancelText:b("Cancel"),getContainer:()=>$.current,onOk(){p()}})});return!S||O?r.jsx(x.Alert,{action:r.jsx(x.Button,{type:"primary",onClick:()=>Q("/admin/settings/map/configuration?tab=google"),children:b("Go to the configuration page")}),message:O||b("Please configure the Api key first"),type:"error"}):r.jsxs("div",{className:s.css`
|
|
60
60
|
position: relative;
|
|
61
61
|
height: 500px;
|
|
62
62
|
`,children:[!m.current&&r.jsx("div",{className:s.css`
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
bottom: 80px;
|
|
71
71
|
right: 20px;
|
|
72
72
|
z-index: 10;
|
|
73
|
-
`,children:r.jsx(x.Button,{onClick:w,disabled:!v.current,type:"primary",shape:"round",size:"large",icon:r.jsx(
|
|
73
|
+
`,children:r.jsx(x.Button,{onClick:w,disabled:!v.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),z==="lineString"||z==="polygon"?r.jsx("div",{className:s.css`
|
|
74
74
|
position: absolute;
|
|
75
75
|
bottom: 20px;
|
|
76
76
|
left: 10px;
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
padding: 2px 4px;
|
|
90
90
|
background: #fff;
|
|
91
91
|
border: 1px solid #0000f5;
|
|
92
|
-
`,pt=e=>{const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l}=s.useProps(e),{getPrimaryKey:
|
|
92
|
+
`,pt=e=>{const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l}=s.useProps(e),{getPrimaryKey:y}=s.useCollection(),A=y(),{marker:S="id"}=t,[b,u]=d.useState(!1),g=d.useRef(),[c,m]=d.useState(),[v,K]=d.useState(""),{t:E}=H(),O=s.useCompile(),{isConnected:T,doFilter:V}=s.useFilterAPI(),[,D]=d.useState(null),z=d.useRef(v),P=d.useRef(null),G=d.useRef([]);z.current=v;const{getCollectionJoinField:Q}=s.useCollectionManager(),$=(k,J)=>{const q=typeof J!="undefined"?!J:k.get(Ee);k.set(Ee,!q),k.setOptions(I({},q?{icon:ie(ae),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:ie(ge),strokeColor:"#F18b62",fillColor:"#F18b62"}))};d.useEffect(()=>{var J,q,Z,w;if(v!=="selection")return;g.current&&!((J=g.current)!=null&&J.drawingManager)&&(g.current.drawingManager=(q=g.current)==null?void 0:q.createDraw(!0,{editable:!0,draggable:!0}));const k=new Set;return(Z=g.current)==null||Z.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(w=g.current)==null||w.drawingManager.addListener("overlaycomplete",L=>{var W;const M=L.overlay;(W=g.current)==null||W.drawingManager.setDrawingMode(null),P.current=M;const B=M.getPath();["insert_at","remove_at","set_at"].forEach(j=>{k.add(B.addListener(j,()=>{}).remove)})}),()=>{var L,M,B,W;k.forEach(j=>{j()}),g.current&&((L=P.current)==null||L.unbindAll(),(M=P.current)==null||M.setMap(null),P.current=null,(B=g.current)==null||B.drawingManager.setDrawingMode(null),(W=g.current)==null||W.drawingManager.unbindAll())}},[v]),d.useEffect(()=>{if(v)return()=>{z.current||G.current.forEach(k=>{$(k,!1)})}},[v]);const _=N.useMemoizedFn(()=>{var L;const k=P.current,J=G.current,q=google.maps.geometry.poly,w=J.filter(M=>{if(!(M===k||M.get(ce)===void 0))return M instanceof google.maps.Marker?q.containsLocation(M.getPosition(),k):M instanceof google.maps.Circle?q.containsLocation(M.getCenter(),k):M.getPath().getArray().some(B=>q.containsLocation(B,k))}).map(M=>($(M,!0),M.get(ce)));l(M=>w.concat(M)),k==null||k.unbindAll(),k==null||k.setMap(null),(L=g.current)==null||L.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});d.useEffect(()=>{var w,L;if(!n||!(o!=null&&o.length)||!((w=g.current)!=null&&w.map))return;const k=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,J=Q([name,...k].flat().join(".")),q=o.map(M=>{const B=Ie(M,t==null?void 0:t.field,J==null?void 0:J.interface);return B!=null&&B.length?B==null?void 0:B.filter(Boolean).map(W=>{var p;if(!B)return;const j=(p=g.current)==null?void 0:p.setOverlay(n.type,W,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:ut,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?O(M[S]):void 0}});return j==null||j.set(ce,M[A]),j}):[]}).flat().filter(Boolean);G.current=q,(L=g.current)==null||L.setFitView(q);const Z=q.map(M=>{const B=W=>{const j=M,p=j.get(ce);if(!p)return;const f=o==null?void 0:o.find(h=>p===h[A]);if(T){D(h=>(h&&ze(j),h===M?(ze(j),V(null),null):(ft(j),V(f[A],C=>C.field||A,"$eq"),j)));return}f&&m(f)};return M.addListener("click",B),()=>M.unbindAll()});return()=>{q.forEach(M=>{M.setMap(null),M.unbindAll()}),Z.forEach(M=>M())}},[o,b,S,n.type,T]),d.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const ee=k=>{g.current=k,u(!!(k!=null&&k.map)&&!k.errMessage)};return r.jsxs("div",{className:s.css`
|
|
93
93
|
position: relative;
|
|
94
94
|
height: 100%;
|
|
95
95
|
`,children:[b&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:s.css`
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
left: 10px;
|
|
98
98
|
top: 10px;
|
|
99
99
|
z-index: 999;
|
|
100
|
-
`,children:r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:v?void 0:"#F18b62",borderColor:"currentcolor"},onClick:k=>{k.stopPropagation(),K("")},icon:r.jsx(
|
|
100
|
+
`,children:r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:v?void 0:"#F18b62",borderColor:"currentcolor"},onClick:k=>{k.stopPropagation(),K("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(x.Button,{style:{color:v==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:k=>{k.stopPropagation(),K("selection")},icon:r.jsx(te.ExpandOutlined,{})}),v==="selection"?r.jsx(x.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:E("Confirm selection"),onClick:_}):null]})}),r.jsx(dt,{record:c,setVisible:m})]}),r.jsx(Fe,Y(I({},e),{ref:ee,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},dt=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=d.useMemo(()=>o.reduceProperties((i,l)=>l.name==="drawer"?l:i,null),[o]);return a&&r.jsx(s.ActionContextProvider,{value:{visible:!!t,setVisible:n},children:r.jsx(s.RecordProvider,{record:t,children:r.jsx(X.RecursionField,{schema:a,name:a.name})})})};function ze(e){if(e instanceof google.maps.Marker)return e.setIcon(ie(ae));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ft(e){if(e instanceof google.maps.Marker)return e.setIcon(ie(ge));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const gt=()=>{var u;const{getCollectionJoinField:e}=s.useCollectionManager(),{getField:n}=s.useCollection(),{form:t}=s.useFormBlockContext(),o=X.useField(),a=X.useFieldSchema(),{t:i}=H(),{dn:l,refresh:y}=s.useDesignable(),A=n(a.name)||e(a["x-collection-field"]),S=(u=A==null?void 0:A.uiSchema)==null?void 0:u.title;o.title===S||o.title,o.readPretty||o.required;let b="editable";return a["x-disabled"]===!0&&(b="readonly"),a["x-read-pretty"]===!0&&(b="read-pretty"),r.jsxs(s.GeneralSchemaDesigner,{children:[r.jsx(s.GeneralSchemaItems,{}),t&&!(t!=null&&t.readPretty)&&!s.isPatternDisabled(a)&&r.jsx(s.SchemaSettings.SelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:b,onChange:g=>{const c={"x-uid":a["x-uid"]};switch(g){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,c["x-read-pretty"]=!1,c["x-disabled"]=!0,o.readPretty=!1,o.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,c["x-read-pretty"]=!0,c["x-disabled"]=!1,o.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,c["x-read-pretty"]=!1,c["x-disabled"]=!1,o.readPretty=!1,o.disabled=!1;break}}l.emit("patch",{schema:c}),l.refresh()}},"pattern"),r.jsx(s.SchemaSettings.ModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:o.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:g})=>{g&&(be.set(a,"x-component-props.zoom",g),Object.assign(o.componentProps,a["x-component-props"]),l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":o.componentProps}})),l.refresh()}},"map-zoom"),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},mt={amap:Se,google:Fe},Le=d.forwardRef((e,n)=>{const{t}=H(),{mapType:o}=e,a=d.useMemo(()=>mt[o],[o]);return a?r.jsx(a,I({ref:n},e)):r.jsx("div",{children:t(`The ${o} cannot found`)})}),ht=e=>{var y;const{value:n}=e,t=X.useFieldSchema(),{getField:o}=s.useCollection(),a=o(t.name),i=e.mapType||((y=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:y.mapType),l=X.useForm();return s.useFieldTitle(),l.readPretty?r.jsx(Le,I({readonly:!0,mapType:i},e)):r.jsx("div",{children:r.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:n==null?void 0:n.map(A=>Array.isArray(A)?`(${A.join(",")})`:A).join(",")})})},Be=X.connect(e=>r.jsx("div",{className:s.css`
|
|
101
101
|
height: 100%;
|
|
102
102
|
border: 1px solid transparent;
|
|
103
103
|
.ant-formily-item-error & {
|
|
104
104
|
border: 1px solid #ff4d4f;
|
|
105
105
|
}
|
|
106
|
-
`,children:r.jsx(Le,I({},e))}),X.mapReadPretty(ht));Be.Designer=gt;const yt={amap:$e,google:pt},vt=e=>{const{t:n}=H(),{mapType:t}=e,o=d.useMemo(()=>yt[t],[t]);return o?r.jsx(o,I({},e)):r.jsx("div",{children:n(`The ${t} cannot found`)})},At=e=>{var l;const{fieldNames:n}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager(),{name:o}=s.useCollection(),a=d.useMemo(()=>t([o,n==null?void 0:n.field].flat().join(".")),[o,n==null?void 0:n.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return r.jsx(vt,Y(I(I({},i),e),{collectionField:a}))},De=d.createContext({}),bt=e=>{var A;const{fieldNames:n}=e,t=X.useFieldSchema(),o=X.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,h]=d.useState([]);return r.jsx(s.FixedBlockWrapper,{children:r.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:r.jsx(De.Provider,{value:{field:o,service:i,resource:a,fieldNames:n,fixedBlock:(A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:h},children:e.children})})})},Mt=e=>{const{params:n,fieldNames:t}=e,o=n.appends||[],{field:a}=t||{};return Array.isArray(a)&&a.length>1&&o.push(a[0]),r.jsx(s.BlockProvider,Y(I({"data-testid":"map-block"},e),{params:Y(I({},n),{appends:o,paginate:!1}),children:r.jsx(bt,I({},e))}))},Te=()=>d.useContext(De),Ct=()=>{var n,t,o,a;const e=Te();return Y(I({},e),{dataSource:(t=(n=e==null?void 0:e.service)==null?void 0:n.data)==null?void 0:t.data,zoom:((a=(o=e==null?void 0:e.field)==null?void 0:o.componentProps)==null?void 0:a.zoom)||13})},xt=e=>{const l=e,{collection:n,resource:t,fieldNames:o}=l,a=Ve(l,["collection","resource","fieldNames"]);return{type:"void","x-acl-action":`${t||n}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":I({collection:n,resource:t||n,action:"list",fieldNames:o,params:{paginate:!1}},a),"x-designer":"MapBlockDesigner","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"MapActionInitializers","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},[We.uid()]:{type:"void","x-component":"MapBlock","x-component-props":{useProps:"{{ 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":"TabPaneInitializers",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":"RecordBlockInitializers",properties:{}}}}}}}}}}}}},Ke=(e,n=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,o,a)=>{const i=t==null?void 0:t.find(l=>l.value===o);return a===e.length-1?i:i==null?void 0:i.children},n)),wt=()=>{var F,P,T,V,D,z;const{name:e,title:n}=s.useCollection(),t=X.useField(),o=X.useFieldSchema(),{form:a}=s.useFormBlockContext(),{service:i}=Te(),{t:l}=H(),{dn:h}=s.useDesignable(),{getCollectionFieldsOptions:A}=s.useCollectionManager(),S=s.useCollection(),b=(F=o==null?void 0:o["x-decorator-props"])==null?void 0:F.resource,c=((P=o==null?void 0:o["x-decorator-props"])==null?void 0:P.fieldNames)||{},g=((T=o==null?void 0:o["x-component-props"])==null?void 0:T.zoom)||13,p=s.useSchemaTemplate(),m=A(S==null?void 0:S.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),v=A(S==null?void 0:S.name,"string"),K=((V=Ke(c.field,m))==null?void 0:V.type)==="point";return r.jsxs(s.GeneralSchemaDesigner,{template:p,title:n||e,children:[r.jsx(s.SchemaSettings.BlockTitleItem,{}),r.jsx(s.FixedBlockDesignerItem,{}),r.jsx(s.SchemaSettings.CascaderItem,{title:l("Map field"),value:c.field,options:m,allowClear:!1,onChange:E=>{const G=t.decoratorProps.fieldNames||{};G.field=E,t.decoratorProps.fieldNames=G,o["x-decorator-props"].fieldNames=G,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}),K?r.jsx(s.SchemaSettings.SelectItem,{title:l("Marker field"),value:c.marker,options:v,onChange:E=>{const G=t.decoratorProps.fieldNames||{};G.marker=E,t.decoratorProps.fieldNames=G,o["x-decorator-props"].fieldNames=G,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}):null,r.jsx(s.SchemaSettings.ModalItem,{title:l("The default zoom level of the map"),schema:{type:"object",title:l("Set default zoom level"),properties:{zoom:{title:l("Zoom"),default:g,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:E})=>{be.set(o,"x-component-props.zoom",E),Object.assign(t.componentProps,o["x-component-props"]),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),h.refresh()}}),r.jsx(s.SchemaSettings.DataScope,{collectionName:e,defaultFilter:((z=(D=o==null?void 0:o["x-decorator-props"])==null?void 0:D.params)==null?void 0:z.filter)||{},form:a,onSubmit:({filter:E})=>{var $,_,te;const G=t.decoratorProps.params||{};G.filter=E,t.decoratorProps.params=G,o["x-decorator-props"].params=G;const Q=((_=($=i.params)==null?void 0:$[1])==null?void 0:_.filters)||{};i.run(Y(I({},(te=i.params)==null?void 0:te[0]),{filter:s.mergeFilter([...Object.values(Q),E]),page:1}),{filters:Q}),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}),r.jsx(s.SchemaSettings.ConnectDataBlocks,{type:s.FilterBlockType.TABLE,emptyDescription:l("No blocks to connect")}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Template,{componentName:"Map",collectionName:e,resourceName:b}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},St=e=>{const{insert:n}=e,t=d.useContext(X.SchemaOptionsContext),{getCollectionFieldsOptions:o}=s.useCollectionManager(),{t:a}=H(),{theme:i}=s.useGlobalTheme();return r.jsx(s.DataBlockInitializer,Y(I({},e),{componentType:"Map",icon:r.jsx(ee.TableOutlined,{}),onCreateBlockSchema:h=>fe(this,[h],function*({item:l}){const A=o(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),S=o(l.name,"string"),b=yield s.FormDialog(a("Create map block"),()=>{var c;return r.jsx(s.SchemaComponentOptions,{scope:t.scope,components:I({},t.components),children:r.jsx(Ye.FormLayout,{layout:"vertical",children:r.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:A,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:A.length?[A[0].value,(c=A[0].children)==null?void 0:c[0].value].filter(g=>g!=null):[]},marker:{title:a("Marker field"),enum:S,"x-component":"Select","x-decorator":"FormItem","x-reactions":g=>{const p=g.form.values.field;if(!(p!=null&&p.length))return;const m=Ke(p,A);m&&(g.hidden=m.type!=="point")}}}}})})})},i).open({initialValues:{}});n(xt({collection:l.name,fieldNames:I({},b)}))}),title:a("Map block")}))},It=e=>{const t=d.useContext(s.SchemaInitializerContext).BlockInitializers.items[0].children;return d.useEffect(()=>{t.find(o=>o.component==="MapBlockInitializer")||t.push({key:"mapBlock",type:"item",title:R("Map"),component:"MapBlockInitializer"})},[]),r.jsx(s.SchemaInitializerProvider,{initializers:{MapActionInitializers:_e},children:r.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:Ct},components:{MapBlockInitializer:St,MapBlockDesigner:wt,MapBlockProvider:Mt,MapBlock:At},children:e.children})})},{defaultProps:Pt}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});const ue={properties:Y(I({},Pt),{"uiSchema.x-component-props.mapType":{title:R("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:Ce}}),schemaInitialize(e,{block:n}){n==="Form"&&Object.assign(e,{"x-designer":"Map.Designer"})}},kt=I({name:"circle",type:"object",group:"map",order:3,title:R("Circle"),description:R("Circle"),sortable:!0,default:{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Ot=I({name:"lineString",type:"object",group:"map",order:2,title:R("Line"),description:R("Line"),sortable:!0,default:{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Ft=I({name:"point",type:"object",group:"map",order:1,title:R("Point"),description:R("Point"),sortable:!0,default:{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Et=I({name:"polygon",type:"object",group:"map",order:4,title:R("Polygon"),description:R("Polygon"),sortable:!0,default:{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),ve=[Ft,Et,Ot,kt],zt=ve.reduce((e,n)=>(e[n.name]=n,e),{}),Lt=()=>{const{data:e}=s.useCurrentAppInfo()||{};d.useEffect(()=>{const n=e==null?void 0:e.database.dialect;n&&(s.registerGroup(ve[0].group,{label:R("Map-based geometry"),order:51}),ve.forEach(t=>{Array.isArray(t.dialects)&&!t.dialects.includes(n)||s.registerField(t.group,t.title,t)}))},[e])},Bt=e=>(Lt(),r.jsx(d.Fragment,{children:e.children})),Ue=d.memo(e=>{const n=d.useContext(s.CollectionManagerContext),{t}=H();return r.jsx(s.CurrentAppInfoProvider,{children:r.jsx(Bt,{children:r.jsx(s.SettingsCenterProvider,{settings:{map:{title:t("Map Manager"),icon:"EnvironmentOutlined",tabs:{configuration:{title:t("Configuration"),component:rt}}}},children:r.jsx(s.SchemaComponentOptions,{components:{Map:Be},children:r.jsx(It,{children:r.jsx(s.CollectionManagerContext.Provider,{value:Y(I({},n),{interfaces:I(I({},n.interfaces),zt)}),children:e.children})})})})})})});Ue.displayName="MapProvider";class Ne extends s.Plugin{load(){return fe(this,null,function*(){this.app.use(Ue)})}}O.MapPlugin=Ne,O.default=Ne,Object.defineProperties(O,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
106
|
+
`,children:r.jsx(Le,I({},e))}),X.mapReadPretty(ht));Be.Designer=gt;const yt={amap:$e,google:pt},vt=e=>{const{t:n}=H(),{mapType:t}=e,o=d.useMemo(()=>yt[t],[t]);return o?r.jsx(o,I({},e)):r.jsx("div",{children:n(`The ${t} cannot found`)})},At=e=>{var l;const{fieldNames:n}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager(),{name:o}=s.useCollection(),a=d.useMemo(()=>t([o,n==null?void 0:n.field].flat().join(".")),[o,n==null?void 0:n.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return r.jsx(vt,Y(I(I({},i),e),{collectionField:a}))},De=d.createContext({}),bt=e=>{var A;const{fieldNames:n}=e,t=X.useFieldSchema(),o=X.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,y]=d.useState([]);return r.jsx(s.FixedBlockWrapper,{children:r.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:r.jsx(De.Provider,{value:{field:o,service:i,resource:a,fieldNames:n,fixedBlock:(A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:y},children:e.children})})})},Mt=e=>{const{params:n,fieldNames:t}=e,o=n.appends||[],{field:a}=t||{};return Array.isArray(a)&&a.length>1&&o.push(a[0]),r.jsx(s.BlockProvider,Y(I({name:"map"},e),{params:Y(I({},n),{appends:o,paginate:!1}),children:r.jsx(bt,I({},e))}))},Te=()=>d.useContext(De),Ct=()=>{var n,t,o,a;const e=Te();return Y(I({},e),{dataSource:(t=(n=e==null?void 0:e.service)==null?void 0:n.data)==null?void 0:t.data,zoom:((a=(o=e==null?void 0:e.field)==null?void 0:o.componentProps)==null?void 0:a.zoom)||13})},xt=e=>{const l=e,{collection:n,resource:t,fieldNames:o}=l,a=Ve(l,["collection","resource","fieldNames"]);return{type:"void","x-acl-action":`${t||n}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":I({collection:n,resource:t||n,action:"list",fieldNames:o,params:{paginate:!1}},a),"x-designer":"MapBlockDesigner","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"MapActionInitializers","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{}},[We.uid()]:{type:"void","x-component":"MapBlock","x-component-props":{useProps:"{{ 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":"TabPaneInitializers",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":"RecordBlockInitializers",properties:{}}}}}}}}}}}}},Ke=(e,n=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,o,a)=>{const i=t==null?void 0:t.find(l=>l.value===o);return a===e.length-1?i:i==null?void 0:i.children},n)),wt=()=>{var E,O,T,V,D,z;const{name:e,title:n}=s.useCollection(),t=X.useField(),o=X.useFieldSchema(),{form:a}=s.useFormBlockContext(),{service:i}=Te(),{t:l}=H(),{dn:y}=s.useDesignable(),{getCollectionFieldsOptions:A}=s.useCollectionManager(),S=s.useCollection(),b=(E=o==null?void 0:o["x-decorator-props"])==null?void 0:E.resource,u=((O=o==null?void 0:o["x-decorator-props"])==null?void 0:O.fieldNames)||{},g=((T=o==null?void 0:o["x-component-props"])==null?void 0:T.zoom)||13,c=s.useSchemaTemplate(),m=A(S==null?void 0:S.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),v=A(S==null?void 0:S.name,"string"),K=((V=Ke(u.field,m))==null?void 0:V.type)==="point";return r.jsxs(s.GeneralSchemaDesigner,{template:c,title:n||e,children:[r.jsx(s.SchemaSettings.BlockTitleItem,{}),r.jsx(s.FixedBlockDesignerItem,{}),r.jsx(s.SchemaSettings.CascaderItem,{title:l("Map field"),value:u.field,options:m,allowClear:!1,onChange:P=>{const G=t.decoratorProps.fieldNames||{};G.field=P,t.decoratorProps.fieldNames=G,o["x-decorator-props"].fieldNames=G,i.refresh(),y.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),y.refresh()}}),K?r.jsx(s.SchemaSettings.SelectItem,{title:l("Marker field"),value:u.marker,options:v,onChange:P=>{const G=t.decoratorProps.fieldNames||{};G.marker=P,t.decoratorProps.fieldNames=G,o["x-decorator-props"].fieldNames=G,i.refresh(),y.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),y.refresh()}}):null,r.jsx(s.SchemaSettings.ModalItem,{title:l("The default zoom level of the map"),schema:{type:"object",title:l("Set default zoom level"),properties:{zoom:{title:l("Zoom"),default:g,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:P})=>{be.set(o,"x-component-props.zoom",P),Object.assign(t.componentProps,o["x-component-props"]),y.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),y.refresh()}}),r.jsx(s.SchemaSettings.DataScope,{collectionName:e,defaultFilter:((z=(D=o==null?void 0:o["x-decorator-props"])==null?void 0:D.params)==null?void 0:z.filter)||{},form:a,onSubmit:({filter:P})=>{var $,_,ee;const G=t.decoratorProps.params||{};G.filter=P,t.decoratorProps.params=G,o["x-decorator-props"].params=G;const Q=((_=($=i.params)==null?void 0:$[1])==null?void 0:_.filters)||{};i.run(Y(I({},(ee=i.params)==null?void 0:ee[0]),{filter:s.mergeFilter([...Object.values(Q),P]),page:1}),{filters:Q}),y.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}),r.jsx(s.SchemaSettings.ConnectDataBlocks,{type:s.FilterBlockType.TABLE,emptyDescription:l("No blocks to connect")}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Template,{componentName:"Map",collectionName:e,resourceName:b}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},St=e=>{const{insert:n}=e,t=d.useContext(X.SchemaOptionsContext),{getCollectionFieldsOptions:o}=s.useCollectionManager(),{t:a}=H(),{theme:i}=s.useGlobalTheme();return r.jsx(s.DataBlockInitializer,Y(I({},e),{componentType:"Map",icon:r.jsx(te.TableOutlined,{}),onCreateBlockSchema:y=>fe(this,[y],function*({item:l}){const A=o(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),S=o(l.name,"string"),b=yield s.FormDialog(a("Create map block"),()=>{var u;return r.jsx(s.SchemaComponentOptions,{scope:t.scope,components:I({},t.components),children:r.jsx(Ye.FormLayout,{layout:"vertical",children:r.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:A,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:A.length?[A[0].value,(u=A[0].children)==null?void 0:u[0].value].filter(g=>g!=null):[]},marker:{title:a("Marker field"),enum:S,"x-component":"Select","x-decorator":"FormItem","x-reactions":g=>{const c=g.form.values.field;if(!(c!=null&&c.length))return;const m=Ke(c,A);m&&(g.hidden=m.type!=="point")}}}}})})})},i).open({initialValues:{}});n(xt({collection:l.name,fieldNames:I({},b)}))}),title:a("Map block")}))},It=e=>{const t=d.useContext(s.SchemaInitializerContext).BlockInitializers.items[0].children;return d.useEffect(()=>{t.find(o=>o.component==="MapBlockInitializer")||t.push({key:"mapBlock",type:"item",title:R("Map"),component:"MapBlockInitializer"})},[]),r.jsx(s.SchemaInitializerProvider,{initializers:{MapActionInitializers:_e},children:r.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:Ct},components:{MapBlockInitializer:St,MapBlockDesigner:wt,MapBlockProvider:Mt,MapBlock:At},children:e.children})})},{defaultProps:Pt}=s.interfacesProperties;Array.isArray(s.interfacesProperties.type.enum)&&s.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});const ue={properties:Y(I({},Pt),{"uiSchema.x-component-props.mapType":{title:R("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:Ce}}),schemaInitialize(e,{block:n}){n==="Form"&&Object.assign(e,{"x-designer":"Map.Designer"})}},kt=I({name:"circle",type:"object",group:"map",order:3,title:R("Circle"),description:R("Circle"),sortable:!0,default:{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Ot=I({name:"lineString",type:"object",group:"map",order:2,title:R("Line"),description:R("Line"),sortable:!0,default:{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Ft=I({name:"point",type:"object",group:"map",order:1,title:R("Point"),description:R("Point"),sortable:!0,default:{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),Et=I({name:"polygon",type:"object",group:"map",order:4,title:R("Polygon"),description:R("Polygon"),sortable:!0,default:{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ue),ve=[Ft,Et,Ot,kt],zt=ve.reduce((e,n)=>(e[n.name]=n,e),{}),Lt=()=>{const{data:e}=s.useCurrentAppInfo()||{};d.useEffect(()=>{const n=e==null?void 0:e.database.dialect;n&&(s.registerGroup(ve[0].group,{label:R("Map-based geometry"),order:51}),ve.forEach(t=>{Array.isArray(t.dialects)&&!t.dialects.includes(n)||s.registerField(t.group,t.title,t)}))},[e])},Bt=e=>(Lt(),r.jsx(d.Fragment,{children:e.children})),Ue=d.memo(e=>{const n=d.useContext(s.CollectionManagerContext),{t}=H();return r.jsx(s.CurrentAppInfoProvider,{children:r.jsx(Bt,{children:r.jsx(s.SettingsCenterProvider,{settings:{map:{title:t("Map Manager"),icon:"EnvironmentOutlined",tabs:{configuration:{title:t("Configuration"),component:rt}}}},children:r.jsx(s.SchemaComponentOptions,{components:{Map:Be},children:r.jsx(It,{children:r.jsx(s.CollectionManagerContext.Provider,{value:Y(I({},n),{interfaces:I(I({},n.interfaces),zt)}),children:e.children})})})})})})});Ue.displayName="MapProvider";class Ne extends s.Plugin{load(){return fe(this,null,function*(){this.app.use(Ue)})}}F.MapPlugin=Ne,F.default=Ne,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.14.0-alpha.
|
|
2
|
+
"@nocobase/client": "0.14.0-alpha.8",
|
|
3
3
|
"react": "18.2.0",
|
|
4
|
-
"@nocobase/server": "0.14.0-alpha.
|
|
4
|
+
"@nocobase/server": "0.14.0-alpha.8",
|
|
5
5
|
"@formily/react": "2.2.27",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"@ant-design/icons": "5.1.4",
|
|
8
|
-
"@formily/antd-v5": "1.1.
|
|
8
|
+
"@formily/antd-v5": "1.1.7",
|
|
9
9
|
"@formily/shared": "2.2.27",
|
|
10
10
|
"ahooks": "3.7.8",
|
|
11
11
|
"antd": "5.8.6",
|
|
12
12
|
"react-router-dom": "6.14.1",
|
|
13
13
|
"@formily/core": "2.2.27",
|
|
14
14
|
"react-i18next": "11.18.6",
|
|
15
|
-
"@nocobase/actions": "0.14.0-alpha.
|
|
16
|
-
"@nocobase/database": "0.14.0-alpha.
|
|
15
|
+
"@nocobase/actions": "0.14.0-alpha.8",
|
|
16
|
+
"@nocobase/database": "0.14.0-alpha.8"
|
|
17
17
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Map",
|
|
4
4
|
"displayName.zh-CN": "地图",
|
|
5
|
-
"version": "0.14.0-alpha.
|
|
5
|
+
"version": "0.14.0-alpha.8",
|
|
6
6
|
"description": "Provides map fields and blocks",
|
|
7
7
|
"description.zh-CN": "提供地图字段和区块",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@nocobase/test": "0.x",
|
|
35
35
|
"@nocobase/utils": "0.x"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "59c82fef6e34707802b5841f5ec4d9b3b6b68abb"
|
|
38
38
|
}
|