@nocobase/plugin-map 0.14.0-alpha.8 → 0.15.0-alpha.2
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 +25 -20
- package/dist/externalVersion.js +4 -4
- package/dist/locale/zh-CN.d.ts +3 -0
- package/dist/locale/zh-CN.js +4 -1
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
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`
|
|
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,f,pe,te,X,j,x,ie,xe,_e,Je){"use strict";var Ut=Object.defineProperty,Nt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var me=Object.getOwnPropertySymbols;var Ve=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var je=(F,r,s)=>r in F?Ut(F,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):F[r]=s,P=(F,r)=>{for(var s in r||(r={}))Ve.call(r,s)&&je(F,s,r[s]);if(me)for(var s of me(r))We.call(r,s)&&je(F,s,r[s]);return F},J=(F,r)=>Nt(F,Gt(r));var Ye=(F,r)=>{var s={};for(var f in F)Ve.call(F,f)&&r.indexOf(f)<0&&(s[f]=F[f]);if(F!=null&&me)for(var f of me(F))r.indexOf(f)<0&&We.call(F,f)&&(s[f]=F[f]);return s};var he=(F,r,s)=>new Promise((f,pe)=>{var te=x=>{try{j(s.next(x))}catch(ie){pe(ie)}},X=x=>{try{j(s.throw(x))}catch(ie){pe(ie)}},j=x=>x.done?f(x.value):Promise.resolve(x.value).then(te,X);j((s=s.apply(F,r)).next())});const de="map";function $(e){return`{{t('${e}', { ns: '${de}', nsMode: 'fallback' })}}`}function Q(){return pe.useTranslation(de,{nsMode:"fallback"})}const Xe={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"}}]},we=[{label:$("AMap"),value:"amap"},{label:$("Google Maps"),value:"google"}],ye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ce="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 Ze=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se={exports:{}};(function(e,n){(function(t,o){e.exports=o()})(Ze,function(){function t(c){var y=[];return c.AMapUI&&y.push(o(c.AMapUI)),c.Loca&&y.push(a(c.Loca)),Promise.all(y)}function o(c){return new Promise(function(y,u){var d=[];if(c.plugins)for(var v=0;v<c.plugins.length;v+=1)l.AMapUI.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);if(h.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(h.AMapUI===i.notload){h.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,v=l.AMapUI.version;var z=document.body||document.head,D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/ui/"+v+"/main.js",D.onerror=function(I){h.AMapUI=i.failed,u("请求 AMapUI 失败")},D.onload=function(){if(h.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,U=d.length;I<U;I++){var V=d[I].split("/").slice(-1)[0];window.AMapUI[V]=arguments[I]}for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()});else for(y();b.AMapUI.length;)b.AMapUI.splice(0,1)[0]()},z.appendChild(D)}else h.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,U=d.length;I<U;I++){var V=d[I].split("/").slice(-1)[0];window.AMapUI[V]=arguments[I]}y()}):y():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):b.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var U=0,V=d.length;U<V;U++){var K=d[U].split("/").slice(-1)[0];window.AMapUI[K]=arguments[U]}y()}):y()})})}function a(c){return new Promise(function(y,u){if(h.Loca===i.failed)u("前次请求 Loca 失败");else if(h.Loca===i.notload){h.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,v=l.AMap.version.startsWith("2"),z=d.startsWith("2");if(v&&!z||!v&&z)u("JSAPI 与 Loca 版本不对应!!");else{v=l.key,z=document.body||document.head;var D=document.createElement("script");D.type="text/javascript",D.src="https://webapi.amap.com/loca?v="+d+"&key="+v,D.onerror=function(I){h.Loca=i.failed,u("请求 AMapUI 失败")},D.onload=function(){for(h.Loca=i.loaded,y();b.Loca.length;)b.Loca.splice(0,1)[0]()},z.appendChild(D)}}else h.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):y():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b.Loca.push(function(I){I?u(I):u()})})}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},b={AMap:[],AMapUI:[],Loca:[]},S=[],C=function(c){typeof c=="function"&&(h.AMap===i.loaded?c(window.AMap):S.push(c))};return{load:function(c){return new Promise(function(y,u){if(h.AMap==i.failed)u("");else if(h.AMap==i.notload){var d=c.key,v=c.version,z=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=v||l.AMap.version,l.AMap.plugins=z||l.AMap.plugins,h.AMap=i.loading,v=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)h.AMap=i.failed,u(I);else for(h.AMap=i.loaded,t(c).then(function(){y(window.AMap)}).catch(u);S.length;)S.splice(0,1)[0]()},z=document.createElement("script"),z.type="text/javascript",z.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),z.onerror=function(I){h.AMap=i.failed,u(I)},v.appendChild(z)):u("请填写key")}else if(h.AMap==i.loaded)if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&d.push(c.plugins[v]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)}else if(c.key&&c.key!==l.key)u("多个不一致的 key");else if(c.version&&c.version!==l.AMap.version)u("不允许多个版本 JSAPI 混用");else{var D=[];if(c.plugins)for(v=0;v<c.plugins.length;v+=1)l.AMap.plugins.indexOf(c.plugins[v])==-1&&D.push(c.plugins[v]);C(function(){D.length?window.AMap.plugin(D,function(){t(c).then(function(){y(window.AMap)}).catch(u)}):t(c).then(function(){y(window.AMap)}).catch(u)})}})},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},b={AMap:[],AMapUI:[],Loca:[]}}}})})(Se);var Qe=Se.exports;const $e=He(Qe),Ie="map-configuration",Ae=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,ve=e=>{const n=f.useMemo(()=>{const o=sessionStorage.getItem(Ae(e));return o&&JSON.parse(o)},[e]),{data:t}=s.useRequest({resource:Ie,action:"get",params:{type:e}},{onSuccess(o){sessionStorage.setItem(Ae(e),JSON.stringify(o==null?void 0:o.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!n});return n||(t==null?void 0:t.data)},Re=e=>{const{aMap:n,toCenter:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.useEffect(()=>{n==null||n.plugin("AMap.PlaceSearch",()=>{a.current=new n.PlaceSearch({city:"全国",pageSize:30})})},[n]);const{run:h}=j.useDebounceFn(S=>{a.current&&a.current.search(S||" ",(C,c)=>{if(C==="complete")l(c.poiList.pois.map(y=>J(P({},y),{label:`${y.name}-${y.address}`,value:y.id})));else{if(C==="no_data"){l([]);return}x.message.error(o("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),b=S=>{const C=i.find(c=>c.value===S);C!=null&&C.location&&t(C.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,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:o("Enter keywords to search"),filterOption:!1,onSearch:
|
|
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:h,onSelect:b,options:i,popupMatchSelectWidth:!1})})},be={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"}},Pe=f.forwardRef((e,n)=>{const{accessKey:t,securityJsCode:o}=ve(e.mapType)||{},{value:a,onChange:i,block:l=!1,readonly:h,disabled:b=l,zoom:S=13,overlayCommonOptions:C}=e,{t:c}=Q(),y=X.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[I,U]=f.useState(""),{getField:V}=s.useCollection(),K=f.useMemo(()=>{if(e.type)return e.type;const g=V(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),L=f.useRef(),k=f.useRef(null),W=ie.useNavigate(),Z=f.useRef(`nocobase-map-${K||""}-${Date.now().toString(32)}`),{modal:H}=x.App.useApp(),[_]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},C)),ee=j.useMemoizedFn(()=>{L.current&&L.current.remove()}),oe=j.useMemoizedFn(()=>{(!b||l)&&K!=="point"&&k.current&&(k.current.setTarget(L.current),k.current.open())}),O=j.useMemoizedFn((g,p=!1)=>{let m=null;if(K==="point"){const{lat:M,lng:N}=g.getPosition();m=[N,M]}else if(K==="polygon"||K==="lineString"){if(m=g.getPath().map(M=>[M.lng,M.lat]),m.length<2)return}else if(K==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng,M.lat,N]}p||(ee(),L.current=g,oe()),i==null||i(m)}),Y=j.useMemoizedFn((g=K)=>{const p=be[g];if(p&&"editor"in p&&!k.current)return k.current=new u.current[p.editor](d.current,null,{createOptions:_,editOptions:_,controlPoint:J(P({},_),{strokeWeight:3}),midControlPoint:J(P({},_),{strokeWeight:2,fillColor:"#fff"})}),k.current.on("adjust",function({target:m}){O(m,!0)}),k.current.on("move",function({target:m}){O(m,!0)}),k.current}),T=j.useMemoizedFn((g=K)=>{var m;if(!v.current||(m=k.current)!=null&&m.getTarget())return;const p=be[g];p&&v.current[p.mouseTool](P({},_))}),R=j.useMemoizedFn((g=K)=>{v.current||(v.current=new u.current.MouseTool(d.current),v.current.on("draw",function({obj:p}){O(p)}),T(g))}),w=(g,p)=>{d.current&&d.current.setZoomAndCenter(18,g,p)},B=()=>{const g=()=>{ee(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)};H.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById(Z.current),onOk(){g()}})},A=()=>{L.current&&d.current.setFitView([L.current])},E=f.useCallback((g=K,p=a,m)=>{const M=be[g];if(!M)return;const N=P(P({},_),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=p),new u.current[M.overlay](N)},[_]),G=(g=K,p=a,m)=>{if(!u.current)return;const M=E(g,p,m);return M.setMap(d.current),M};f.useEffect(()=>{if(!u.current||!a||!h&&L.current)return;const g=G();d.current.setFitView([g]),L.current=g,b||(Y(),oe())},[a,z,K,_,b,h]),f.useEffect(()=>{var g,p,m;v.current&&(b?((g=v.current)==null||g.close(),(p=k.current)==null||p.close()):(T(),(m=k.current)==null||m.open()))},[b]),f.useEffect(()=>{!u.current||!K||b||(R(),Y())},[b,z,K]),f.useEffect(()=>{var p,m;if(!a&&(v.current||k.current)&&(ee(),k.current&&(k.current.setTarget(),k.current.close()),i==null||i(null)),!v.current||!k.current)return;k.current.getTarget()?(m=(p=v.current).close)==null||m.call(p):T()},[K,a]),f.useEffect(()=>{if(!t||d.current)return;o&&(window._AMapSecurityConfig={[o.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:o});const g=window.define;return window.define=void 0,$e.load({key:t,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(p=>(window.define=g,requestIdleCallback(()=>{d.current=new p.Map(Z.current,{resizeEnable:!0,zoom:S}),u.current=p,U(""),D([])}))).catch(p=>{typeof p=="string"?p.includes("多个不一致的 key")?U(c("The AccessKey is incorrect, please check it")):U(p):(p==null?void 0:p.type)==="error"&&U("Something went wrong, please refresh the page and try again")}),()=>{var p;(p=d.current)==null||p.destroy(),u.current=null,d.current=null,v.current=null,k.current=null}},[t,K,o]),f.useImperativeHandle(n,()=>({setOverlay:G,getOverlay:E,createMouseTool:R,createEditor:Y,executeMouseTool:T,aMap:u.current,map:d.current,overlay:L.current,mouseTool:()=>v.current,editor:()=>k.current,errMessage:I}));const q=s.useApp();return!t||I?r.jsx(x.Alert,{action:r.jsx(x.Button,{type:"primary",onClick:()=>W(q.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("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:
|
|
10
|
+
`,id:Z.current,style:e==null?void 0:e.style,children:[!u.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,{})}),
|
|
16
|
+
`,children:r.jsx(x.Spin,{})}),b?null:r.jsxs(r.Fragment,{children:[r.jsx(Re,{toCenter:w,aMap:u.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:
|
|
21
|
+
`,children:r.jsx(x.Button,{onClick:A,disabled:!L.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),K!=="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:c("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:
|
|
32
|
+
`,children:r.jsx(x.Button,{disabled:!a,style:{height:"40px"},onClick:B,type:"primary",danger:!0,children:c("Clear")})})]})]})}),ke=(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(h=>h[i]).filter(h=>h!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?o:[o]},et=e=>{var O,Y,T,R;const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{name:b,getPrimaryKey:S}=s.useCollection(),{getCollectionJoinField:C}=s.useCollectionManager(),c=S(),[y,u]=f.useState(!1),d=f.useRef(),v=(Y=(O=d.current)==null?void 0:O.aMap)==null?void 0:Y.GeometryUtil,[z,D]=f.useState(),[I,U]=f.useState(""),{t:V}=Q(),K=s.useCompile(),{isConnected:L,doFilter:k}=s.useFilterAPI(),[,W]=f.useState(null),Z=f.useRef(I);Z.current=I;const H=(w,B)=>{const A=w.getExtData(),E=typeof B=="undefined"?A.selected:!B;A.selected=!E,"setIcon"in w&&w.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:E?ce:ye})),w.setOptions(P({extData:A},E?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},_=()=>{var w,B,A;d.current&&((w=d.current)==null||w.mouseTool().close(!0),(B=d.current)==null||B.editor().setTarget(null),(A=d.current)==null||A.editor().close())};f.useEffect(()=>{var w,B,A,E;if(I==="selection")return(w=d.current)!=null&&w.editor()?(E=d.current)==null||E.executeMouseTool("polygon"):((B=d.current)==null||B.createEditor("polygon"),(A=d.current)==null||A.createMouseTool("polygon")),()=>{_()}},[I]),f.useEffect(()=>{if(I)return()=>{var w;Z.current||(w=d.current)==null||w.map.getAllOverlays().forEach(B=>{H(B,!1)})}},[I]);const ee=j.useMemoizedFn(()=>{var G,q,g;const w=(G=d.current)==null?void 0:G.editor().getTarget(),B=(q=d.current)==null?void 0:q.map.getAllOverlays(),A=B==null?void 0:B.filter(p=>{if(!(p===w||p.getExtData().id===void 0))return"getPosition"in p?v.isPointInRing(p.getPosition(),w==null?void 0:w.getPath()):v.doesRingRingIntersect(p.getPath(),w==null?void 0:w.getPath())}),E=A==null?void 0:A.map(p=>(H(p,!0),p.getExtData().id));l(p=>E==null?void 0:E.concat(p)),w==null||w.remove(),(g=d.current)==null||g.editor().close()});f.useEffect(()=>{var G,q,g;if(!n||!d.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,B=C([b,...w].flat().join(".")),A=o.map(p=>{var M;const m=(M=ke(p,t==null?void 0:t.field,B==null?void 0:B.interface))==null?void 0:M.filter(Boolean);return m!=null&&m.length?m.map(N=>{var ne;return(ne=d.current)==null?void 0:ne.setOverlay(n.type,N,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:t!=null&&t.marker?K(p[t.marker]):void 0},extData:{id:p[c]}})}):[]}).flat().filter(Boolean);(q=(G=d.current)==null?void 0:G.map)==null||q.setFitView(A);const E=A.map(p=>{const m=M=>{const N=M.target,re=N.getExtData();if(!re)return;if(Z.current){Z.current==="click"&&(l(se=>re.selected?se.filter(Ce=>Ce!==re.id):[...se,re.id]),H(N));return}const ne=o.find(se=>re.id===se[c]);if(L){W(se=>(se&&Oe(se),se===p?(Oe(p),k(null),null):(ot(p),k(ne[c],Ce=>Ce.field||c,"$eq"),p)));return}ne&&D(ne)};return p.on("click",m),()=>p.off("click",m)});if(n.type==="point"&&(h!=null&&h.length)&&(A==null?void 0:A.length)>1){const p=A.map(M=>M.getPosition());A[0].setzIndex(13),A[A.length-1].setzIndex(13);const m=(M=!0)=>{var N,re;if((N=d.current)!=null&&N.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:V(M?"Start point":"End point")},position:p[M?0:p.length-1],map:(re=d.current)==null?void 0:re.map})};A.push(...[(g=d.current)==null?void 0:g.setOverlay("lineString",p,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),m(),m(!1)].filter(Boolean))}return()=>{A.forEach(p=>{p.remove()}),E.forEach(p=>p())}},[o,y,t,b,c,n.type,L,h]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=w=>{d.current=w,u(!!(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:y&&!((T=d.current)!=null&&T.errMessage)?r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),U("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(x.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:w=>{w.stopPropagation(),U("selection")},icon:r.jsx(te.ExpandOutlined,{})}),I==="selection"?r.jsx(x.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:V("Confirm selection"),onClick:ee}):null]}):null}),r.jsx(tt,{record:z,setVisible:D}),r.jsx(Pe,J(P({},(R=n==null?void 0:n.uiSchema)==null?void 0:R["x-component-props"]),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},tt=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=f.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 Oe(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ot(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 Fe=({type:e,children:n})=>{const{t}=Q(),[o,a]=j.useBoolean(!1),i=s.useAPIClient(),[l]=x.Form.useForm(),h=ve(e);f.useEffect(()=>{h&&(l.setFieldsValue(h),a.toggle())},[h]);const b=f.useMemo(()=>i.resource(Ie),[i]),S=C=>{b.set(J(P({},C),{type:e})).then(c=>{sessionStorage.removeItem(Ae(e)),a.toggle(),x.message.success(t("Saved successfully"))}).catch(c=>{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")})})]})},rt={amap:()=>{const{t:e}=Q();return r.jsxs(Fe,{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}=Q();return r.jsx(Fe,{type:"google",children:r.jsx(x.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:r.jsx(x.Input,{})})})}},nt=we.map(e=>J(P({},e),{component:rt[e.value]})),st=()=>{const e=s.useCompile(),n=ie.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:nt.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,57 +50,62 @@
|
|
|
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
|
|
53
|
+
***************************************************************************** */function it(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 h(C){try{S(o.next(C))}catch(c){l(c)}}function b(C){try{S(o.throw(C))}catch(c){l(c)}}function S(C){C.done?i(C.value):a(C.value).then(h,b)}S((o=o.apply(e,n||[])).next())})}var at=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 Ee="__googleMapsScriptId";var ue;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(ue||(ue={}));class ae{constructor({apiKey:n,authReferrerPolicy:t,channel:o,client:a,id:i=Ee,language:l,libraries:h=[],mapIds:b,nonce:S,region:C,retries:c=3,url:y="https://maps.googleapis.com/maps/api/js",version:u}){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||Ee,this.language=l,this.libraries=h,this.mapIds=b,this.nonce=S,this.region=C,this.retries=c,this.url=y,this.version=u,ae.instance){if(!at(this.options,ae.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ae.instance.options)}`);return ae.instance}ae.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?ue.FAILURE:this.done?ue.SUCCESS:this.loading?ue.LOADING:ue.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let 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,h,b,S="The Google Maps JavaScript API",C="google",c="importLibrary",y="__ib__",u=document,d=window;d=d[C]||(d[C]={});const v=d.maps||(d.maps={}),z=new Set,D=new URLSearchParams,I=()=>l||(l=new Promise((U,V)=>it(this,void 0,void 0,function*(){var K;yield h=u.createElement("script"),h.id=this.id,D.set("libraries",[...z]+"");for(b in i)D.set(b.replace(/[A-Z]/g,L=>"_"+L[0].toLowerCase()),i[b]);D.set("callback",C+".maps."+y),h.src=this.url+"?"+D,v[y]=U,h.onerror=()=>l=V(Error(S+" could not load.")),h.nonce=this.nonce||((K=u.querySelector("script[nonce]"))===null||K===void 0?void 0:K.nonce)||"",u.head.append(h)})));v[c]?console.warn(S+" only loads once. Ignoring:",i):v[c]=(U,...V)=>z.add(U)&&I().then(()=>v[c](U,...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 lt=e=>{const{toCenter:n,mapRef:t}=e,{t:o}=Q(),a=f.useRef(),[i,l]=f.useState([]);f.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:h}=j.useDebounceFn(S=>{a.current&&a.current.getPlacePredictions({input:S||" "},(C,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)l(C.map(y=>{const u=y.structured_formatting;return J(P({},y),{label:`${u.main_text}${u.secondary_text?" "+u.secondary_text:""}`,value:y.place_id})}));else{l([]);return}})},{wait:300}),b=S=>{const C=i.find(y=>y.value===S);new google.maps.places.PlacesService(t.current).getDetails({placeId:C.place_id,fields:["geometry"]},(y,u)=>{u===google.maps.places.PlacesServiceStatus.OK&&n(y.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,{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:
|
|
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:h,onSelect:b,options:i})})},le=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,32+10)}),ct=()=>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()}),ut=e=>e==="point"?"marker":e==="lineString"?"polyline":e,pt={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"}},ze=f.forwardRef((e,n)=>{const{value:t,onChange:o,block:a=!1,readonly:i,disabled:l=a,zoom:h=13,overlayCommonOptions:b}=e,{accessKey:S}=ve(e.mapType)||{},{t:C}=Q(),{getField:c}=s.useCollection(),y=X.useFieldSchema(),u=f.useRef(),d=f.useRef(),v=f.useRef(),[z,D]=f.useState([]),[I,U]=f.useState(""),V=s.useAPIClient(),{modal:K}=x.App.useApp(),L=f.useMemo(()=>{if(e.type)return e.type;const g=c(y==null?void 0:y.name);return g==null?void 0:g.interface},[e==null?void 0:e.type,y==null?void 0:y.name]),k=f.useRef(ut(L)),[W]=f.useState(P({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!l,draggable:!l},b)),Z=ie.useNavigate(),H=f.useRef(),_=f.useRef(new Set),ee=j.useMemoizedFn(g=>{if(_.current.forEach(p=>{_.current.delete(p)}),"getPath"in g){const p=g.getPath();["insert_at","remove_at","set_at"].forEach(m=>{_.current.add(p.addListener(m,()=>{w(g,!0)}).remove)})}else g instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(p=>{_.current.add(g.addListener(p,()=>{w(g,!0)}).remove)})}),oe=j.useMemoizedFn(()=>{var g;v.current&&(v.current.unbindAll(),v.current.setMap(null)),L!=="point"&&((g=u.current)==null||g.setDrawingMode(null))}),O=j.useMemoizedFn(g=>{d.current&&(d.current.setCenter(g),d.current.setZoom(h))}),Y=j.useMemoizedFn(g=>{oe(),ee(g),v.current=g}),T=j.useMemoizedFn(g=>{const p=new google.maps.LatLngBounds;g.forEach(m=>{if(m instanceof google.maps.Marker)p.extend(m.getPosition());else if(m instanceof google.maps.Polyline||m instanceof google.maps.Polygon){const M=m.getPath();for(let N=0;N<M.getLength();N++)p.extend(M.getAt(N))}else m instanceof google.maps.Circle&&p.union(m.getBounds())}),d.current.setCenter(p.getCenter())}),R=()=>{v.current&&T([v.current])},w=j.useMemoizedFn((g,p=!1)=>{let m=null;if(L==="point"){const{lat:M,lng:N}=g.getPosition();m=[N(),M()]}else if(L==="polygon"||L==="lineString"){if(m=g.getPath().getArray().map(M=>[M.lng(),M.lat()]),m.length<2)return}else if(L==="circle"){const M=g.getCenter(),N=g.getRadius();m=[M.lng(),M.lat(),N]}p||Y(g),o==null||o(m)}),B=j.useMemoizedFn((g=!1,p)=>{const m=J(P(P({},W),p),{map:d.current});return u.current=new google.maps.drawing.DrawingManager({drawingMode:k.current,drawingControl:!1,markerOptions:J(P({},m),{icon:le(ce)}),polygonOptions:m,polylineOptions:m,circleOptions:m,map:d.current}),g||u.current.addListener("overlaycomplete",M=>{const N=M.overlay;w(N)}),u.current}),A=j.useMemoizedFn((g=L,p=t,m)=>{const M=pt[g];if(!M)return;const N=P(J(P({},W),{icon:le(ce)}),m);return"transformOptions"in M?Object.assign(N,M.transformOptions(p)):"propertyKey"in M&&(N[M.propertyKey]=Array.isArray(p[0])?p.map(ne=>new google.maps.LatLng(ne[1],ne[0])):new google.maps.LatLng(p[1],p[0])),new google.maps[M.overlay](N)}),E=j.useMemoizedFn((g=L,p=t,m)=>d.current?A(g,p,J(P({},m),{map:d.current})):void 0);f.useEffect(()=>{var p,m;if(!t&&d.current&&(oe(),(m=(p=u==null?void 0:u.current)==null?void 0:p.setDrawingMode)==null||m.call(p,k.current),o==null||o(null)),!d.current||!t||!i&&v.current)return;const g=E();Y(g),T([g])},[t,z,L,l,i,E,T,Y]),f.useEffect(()=>{if(!S||d.current||!H.current)return;let g;try{g=new ae({apiKey:S,version:"weekly",language:V.auth.getLocale()})}catch(m){U(C("Load google maps failed, Please check the Api key and refresh the page"));return}const p=console.error;return console.error=(m,...M)=>{m!=null&&m.includes("InvalidKeyMapError")&&U(C("Load google maps failed, Please check the Api key and refresh the page")),p(m,...M)},Promise.all([g.importLibrary("drawing"),g.importLibrary("core"),g.importLibrary("geometry")]).then(m=>he(this,null,function*(){const M=yield ct();d.current=new google.maps.Map(H.current,{zoom:h,center:M,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),U(""),D([])})).catch(m=>{if(m instanceof Error){U(m.message);return}}),()=>{var m,M;(m=d.current)==null||m.unbindAll(),d.current=null,(M=u.current)==null||M.unbindAll()}},[S,V.auth,L,h]),f.useEffect(()=>{!d.current||!L||l||u.current||B()},[B,l,z,L]),f.useImperativeHandle(n,()=>({setOverlay:E,getOverlay:A,setFitView:T,createDraw:B,map:d.current,overlay:v.current,drawingManager:u.current,errMessage:I}));const G=j.useMemoizedFn(()=>{const g=()=>{oe(),u.current.setDrawingMode(k.current),o==null||o(null)};K.confirm({title:C("Clear the canvas"),content:C("Are you sure to clear the canvas?"),okText:C("Confirm"),cancelText:C("Cancel"),getContainer:()=>H.current,onOk(){g()}})}),q=s.useApp();return!S||I?r.jsx(x.Alert,{action:r.jsx(x.Button,{type:"primary",onClick:()=>Z(q.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:C("Go to the configuration page")}),message:I||C("Please configure the Api key first"),type:"error"}):r.jsxs("div",{className:s.css`
|
|
60
60
|
position: relative;
|
|
61
61
|
height: 500px;
|
|
62
|
-
`,children:[!
|
|
62
|
+
`,children:[!d.current&&r.jsx("div",{className:s.css`
|
|
63
63
|
position: absolute;
|
|
64
64
|
inset: 0;
|
|
65
65
|
display: flex;
|
|
66
66
|
align-items: center;
|
|
67
67
|
justify-content: center;
|
|
68
|
-
`,children:r.jsx(x.Spin,{})}),l?null:r.jsxs(r.Fragment,{children:[
|
|
68
|
+
`,children:r.jsx(x.Spin,{})}),l?null:r.jsxs(r.Fragment,{children:[d.current&&r.jsx(lt,{toCenter:O,mapRef:d}),r.jsx("div",{className:s.css`
|
|
69
69
|
position: absolute;
|
|
70
70
|
bottom: 80px;
|
|
71
71
|
right: 20px;
|
|
72
72
|
z-index: 10;
|
|
73
|
-
`,children:r.jsx(x.Button,{onClick:
|
|
73
|
+
`,children:r.jsx(x.Button,{onClick:R,disabled:!v.current,type:"primary",shape:"round",size:"large",icon:r.jsx(te.SyncOutlined,{})})}),L==="lineString"||L==="polygon"?r.jsx("div",{className:s.css`
|
|
74
74
|
position: absolute;
|
|
75
75
|
bottom: 20px;
|
|
76
76
|
left: 10px;
|
|
77
77
|
z-index: 2;
|
|
78
78
|
pointer-events: none;
|
|
79
|
-
`,children:r.jsx(x.Alert,{message:
|
|
79
|
+
`,children:r.jsx(x.Alert,{message:C("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,r.jsx("div",{className:s.css`
|
|
80
80
|
position: absolute;
|
|
81
81
|
bottom: 20px;
|
|
82
82
|
right: 20px;
|
|
83
83
|
z-index: 2;
|
|
84
|
-
`,children:r.jsx(x.Button,{disabled:!t,style:{height:"40px"},onClick:
|
|
84
|
+
`,children:r.jsx(x.Button,{disabled:!t,style:{height:"40px"},onClick:G,type:"primary",danger:!0,children:C("Clear")})})]}),r.jsx("div",{ref:H,className:s.css`
|
|
85
85
|
width: 100%;
|
|
86
86
|
height: 100%;
|
|
87
|
-
`,style:e==null?void 0:e.style})]})}),
|
|
87
|
+
`,style:e==null?void 0:e.style})]})}),fe="google-maps-overlay-id",Le="google-maps-overlay-selected",dt=s.css`
|
|
88
88
|
margin-top: 6px;
|
|
89
89
|
padding: 2px 4px;
|
|
90
90
|
background: #fff;
|
|
91
91
|
border: 1px solid #0000f5;
|
|
92
|
-
`,
|
|
92
|
+
`,ft=s.css`
|
|
93
|
+
margin-top: -64px;
|
|
94
|
+
padding: 2px 4px;
|
|
95
|
+
background: #fff;
|
|
96
|
+
border: 1px solid #0000f5;
|
|
97
|
+
`,gt=e=>{const{collectionField:n,fieldNames:t,dataSource:o,fixedBlock:a,zoom:i,setSelectedRecordKeys:l,lineSort:h}=s.useProps(e),{getPrimaryKey:b}=s.useCollection(),S=b(),{marker:C="id"}=t,[c,y]=f.useState(!1),u=f.useRef(),[d,v]=f.useState(),[z,D]=f.useState(""),{t:I}=Q(),U=s.useCompile(),{isConnected:V,doFilter:K}=s.useFilterAPI(),[,L]=f.useState(null),k=f.useRef(z),W=f.useRef(null),Z=f.useRef([]);k.current=z;const{getCollectionJoinField:H}=s.useCollectionManager(),_=(O,Y)=>{const T=typeof Y!="undefined"?!Y:O.get(Le);O.set(Le,!T),O.setOptions(P({},T?{icon:le(ce),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:le(ye),strokeColor:"#F18b62",fillColor:"#F18b62"}))};f.useEffect(()=>{var Y,T,R,w;if(z!=="selection")return;u.current&&!((Y=u.current)!=null&&Y.drawingManager)&&(u.current.drawingManager=(T=u.current)==null?void 0:T.createDraw(!0,{editable:!0,draggable:!0}));const O=new Set;return(R=u.current)==null||R.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(w=u.current)==null||w.drawingManager.addListener("overlaycomplete",B=>{var G;const A=B.overlay;(G=u.current)==null||G.drawingManager.setDrawingMode(null),W.current=A;const E=A.getPath();["insert_at","remove_at","set_at"].forEach(q=>{O.add(E.addListener(q,()=>{}).remove)})}),()=>{var B,A,E,G;O.forEach(q=>{q()}),u.current&&((B=W.current)==null||B.unbindAll(),(A=W.current)==null||A.setMap(null),W.current=null,(E=u.current)==null||E.drawingManager.setDrawingMode(null),(G=u.current)==null||G.drawingManager.unbindAll())}},[z]),f.useEffect(()=>{if(z)return()=>{k.current||Z.current.forEach(O=>{_(O,!1)})}},[z]);const ee=j.useMemoizedFn(()=>{var B;const O=W.current,Y=Z.current,T=google.maps.geometry.poly,w=Y.filter(A=>{if(!(A===O||A.get(fe)===void 0))return A instanceof google.maps.Marker?T.containsLocation(A.getPosition(),O):A instanceof google.maps.Circle?T.containsLocation(A.getCenter(),O):A.getPath().getArray().some(E=>T.containsLocation(E,O))}).map(A=>(_(A,!0),A.get(fe)));l(A=>w.concat(A)),O==null||O.unbindAll(),O==null||O.setMap(null),(B=u.current)==null||B.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});f.useEffect(()=>{var w,B;if(!n||!(o!=null&&o.length)||!((w=u.current)!=null&&w.map))return;const O=Array.isArray(t==null?void 0:t.field)&&(t==null?void 0:t.field.length)>1?t==null?void 0:t.field.slice(0,-1):t==null?void 0:t.field,Y=H([name,...O].flat().join(".")),T=o.map(A=>{const E=ke(A,t==null?void 0:t.field,Y==null?void 0:Y.interface);return E!=null&&E.length?E==null?void 0:E.filter(Boolean).map(G=>{var g;if(!E)return;const q=(g=u.current)==null?void 0:g.setOverlay(n.type,G,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:dt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:t!=null&&t.marker?U(A[C]):void 0}});return q==null||q.set(fe,A[S]),q}):[]}).flat().filter(Boolean);Z.current=T;const R=T.map(A=>{const E=G=>{const q=A,g=q.get(fe);if(!g)return;const p=o==null?void 0:o.find(m=>g===m[S]);if(V){L(m=>(m&&Te(q),m===A?(Te(q),K(null),null):(ht(q),K(p[S],M=>M.field||S,"$eq"),q)));return}p&&v(p)};return A.addListener("click",E),()=>A.unbindAll()});if(n.type==="point"&&(h!=null&&h.length)&&(T==null?void 0:T.length)>1){const A=T.map(G=>G.getPosition());T[0].setZIndex(138),T[T.length-1].setZIndex(138);const E=(G=!0)=>{var q;if((q=u.current)!=null&&q.map)return new google.maps.Marker({label:{className:ft,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(G?"Start point":"End point")},icon:le(ce),position:G?A[0]:A[A.length-1],map:u.current.map})};T.push(...[u.current.setOverlay("lineString",A.map(G=>[G.lng(),G.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),E(),E(!1)].filter(Boolean))}return(B=u.current)==null||B.setFitView(T),()=>{T.forEach(A=>{A.setMap(null),A.unbindAll()}),R.forEach(A=>A())}},[o,c,C,n.type,V]),f.useEffect(()=>{setTimeout(()=>{l([])})},[o]);const oe=O=>{u.current=O,y(!!(O!=null&&O.map)&&!O.errMessage)};return r.jsxs("div",{className:s.css`
|
|
93
98
|
position: relative;
|
|
94
99
|
height: 100%;
|
|
95
|
-
`,children:[
|
|
100
|
+
`,children:[c&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:s.css`
|
|
96
101
|
position: absolute;
|
|
97
102
|
left: 10px;
|
|
98
103
|
top: 10px;
|
|
99
104
|
z-index: 999;
|
|
100
|
-
`,children:r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:
|
|
105
|
+
`,children:r.jsxs(x.Space,{direction:"vertical",children:[r.jsx(x.Button,{style:{color:z?void 0:"#F18b62",borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("")},icon:r.jsx(te.EnvironmentOutlined,{})}),r.jsx(x.Button,{style:{color:z==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:O=>{O.stopPropagation(),D("selection")},icon:r.jsx(te.ExpandOutlined,{})}),z==="selection"?r.jsx(x.Button,{type:"primary",icon:r.jsx(te.CheckOutlined,{}),title:I("Confirm selection"),onClick:ee}):null]})}),r.jsx(mt,{record:d,setVisible:v})]}),r.jsx(ze,J(P({},e),{ref:oe,style:{height:a?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},mt=e=>{const{setVisible:n,record:t}=e,o=X.useFieldSchema(),a=f.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 Te(e){if(e instanceof google.maps.Marker)return e.setIcon(le(ce));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function ht(e){if(e instanceof google.maps.Marker)return e.setIcon(le(ye));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const yt=()=>{var c;const{getCollectionJoinField:e}=s.useCollectionManager(),{getField:n}=s.useCollection(),{form:t}=s.useFormBlockContext(),o=X.useField(),a=X.useFieldSchema(),{t:i}=Q(),{dn:l,refresh:h}=s.useDesignable(),b=n(a.name)||e(a["x-collection-field"]),S=(c=b==null?void 0:b.uiSchema)==null?void 0:c.title;o.title===S||o.title,o.readPretty||o.required;let C="editable";return a["x-disabled"]===!0&&(C="readonly"),a["x-read-pretty"]===!0&&(C="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:C,onChange:y=>{const u={"x-uid":a["x-uid"]};switch(y){case"readonly":{a["x-read-pretty"]=!1,a["x-disabled"]=!0,u["x-read-pretty"]=!1,u["x-disabled"]=!0,o.readPretty=!1,o.disabled=!0;break}case"read-pretty":{a["x-read-pretty"]=!0,a["x-disabled"]=!1,u["x-read-pretty"]=!0,u["x-disabled"]=!1,o.readPretty=!0;break}default:{a["x-read-pretty"]=!1,a["x-disabled"]=!1,u["x-read-pretty"]=!1,u["x-disabled"]=!1,o.readPretty=!1,o.disabled=!1;break}}l.emit("patch",{schema:u}),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:y})=>{y&&(xe.set(a,"x-component-props.zoom",y),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")]})},At={amap:Pe,google:ze},Be=f.forwardRef((e,n)=>{const{t}=Q(),{mapType:o}=e,a=f.useMemo(()=>At[o],[o]);return a?r.jsx(a,P({ref:n},e)):r.jsx("div",{children:t(`The ${o} cannot found`)})}),vt=e=>{var h;const{value:n}=e,t=X.useFieldSchema(),{getField:o}=s.useCollection(),a=o(t.name),i=e.mapType||((h=a==null?void 0:a.uiSchema["x-component-props"])==null?void 0:h.mapType),l=X.useForm();return s.useFieldTitle(),l.readPretty?r.jsx(Be,P({readonly:!0,mapType:i},e)):r.jsx("div",{children:r.jsx(s.EllipsisWithTooltip,{ellipsis:!0,children:n==null?void 0:n.map(b=>Array.isArray(b)?`(${b.join(",")})`:b).join(",")})})},De=X.connect(e=>r.jsx("div",{className:s.css`
|
|
101
106
|
height: 100%;
|
|
102
107
|
border: 1px solid transparent;
|
|
103
108
|
.ant-formily-item-error & {
|
|
104
109
|
border: 1px solid #ff4d4f;
|
|
105
110
|
}
|
|
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"}})});
|
|
111
|
+
`,children:r.jsx(Be,P({},e))}),X.mapReadPretty(vt));De.Designer=yt;const bt={amap:et,google:gt},Mt=e=>{const{t:n}=Q(),{mapType:t}=e,o=f.useMemo(()=>bt[t],[t]);return o?r.jsx(o,P({},e)):r.jsx("div",{children:n(`The ${t} cannot found`)})},Ct=e=>{var l;const{fieldNames:n}=s.useProps(e),{getCollectionJoinField:t}=s.useCollectionManager(),{name:o}=s.useCollection(),a=f.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(Mt,J(P(P({},i),e),{collectionField:a}))},Ke=f.createContext({}),xt=e=>{var b;const{fieldNames:n}=e,t=X.useFieldSchema(),o=X.useField(),{resource:a,service:i}=s.useBlockRequestContext(),[l,h]=f.useState([]);return r.jsx(s.FixedBlockWrapper,{children:r.jsx(s.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:r.jsx(Ke.Provider,{value:{field:o,service:i,resource:a,fieldNames:n,fixedBlock:(b=t==null?void 0:t["x-decorator-props"])==null?void 0:b.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:h},children:e.children})})})},wt=e=>{const n=X.useField(),{params:t,fieldNames:o}=e,a=t.appends||[],{field:i}=o||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),r.jsx(s.BlockProvider,J(P({name:"map"},e),{runWhenParamsChanged:!0,params:J(P({},t),{appends:a,paginate:!1,sort:n.componentProps.lineSort}),children:r.jsx(xt,P({},e))}))},Ue=()=>f.useContext(Ke),St=()=>{var n,t,o,a,i,l;const e=Ue();return J(P({},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,lineSort:(l=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:l.lineSort})},It=e=>{const l=e,{collection:n,resource:t,fieldNames:o}=l,a=Ye(l,["collection","resource","fieldNames"]);return{type:"void","x-acl-action":`${t||n}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":P({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:{}},[_e.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:{}}}}}}}}}}}}},Ne=(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)),Pt=()=>{var D,I,U,V,K,L;const{name:e,title:n}=s.useCollection(),t=X.useField(),o=X.useFieldSchema(),{form:a}=s.useFormBlockContext(),{service:i}=Ue(),{t:l}=Q(),{dn:h}=s.useDesignable(),{getCollectionFieldsOptions:b}=s.useCollectionManager(),S=s.useCollection(),C=(D=o==null?void 0:o["x-decorator-props"])==null?void 0:D.resource,c=((I=o==null?void 0:o["x-decorator-props"])==null?void 0:I.fieldNames)||{},y=((U=o==null?void 0:o["x-component-props"])==null?void 0:U.zoom)||13,u=s.useSchemaTemplate(),d=b(S==null?void 0:S.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),v=b(S==null?void 0:S.name,"string"),z=((V=Ne(c.field,d))==null?void 0:V.type)==="point";return r.jsxs(s.GeneralSchemaDesigner,{template:u,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:d,allowClear:!1,onChange:k=>{const W=t.decoratorProps.fieldNames||{};W.field=k,t.decoratorProps.fieldNames=W,o["x-decorator-props"].fieldNames=W,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}),z?r.jsx(s.SchemaSettings.SelectItem,{title:l("Marker field"),value:c.marker,options:v,onChange:k=>{const W=t.decoratorProps.fieldNames||{};W.marker=k,t.decoratorProps.fieldNames=W,o["x-decorator-props"].fieldNames=W,i.refresh(),h.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":t.decoratorProps}}),h.refresh()}}):null,r.jsx(s.SchemaSettings.DefaultSortingRules,{path:"x-component-props.lineSort",title:l("Concatenation order field")}),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:y,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:k})=>{xe.set(o,"x-component-props.zoom",k),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:((L=(K=o==null?void 0:o["x-decorator-props"])==null?void 0:K.params)==null?void 0:L.filter)||{},form:a,onSubmit:({filter:k})=>{var H,_,ee;const W=t.decoratorProps.params||{};W.filter=k,t.decoratorProps.params=W,o["x-decorator-props"].params=W;const Z=((_=(H=i.params)==null?void 0:H[1])==null?void 0:_.filters)||{};i.run(J(P({},(ee=i.params)==null?void 0:ee[0]),{filter:s.mergeFilter([...Object.values(Z),k]),page:1}),{filters:Z}),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:C}),r.jsx(s.SchemaSettings.Divider,{}),r.jsx(s.SchemaSettings.Remove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},kt=e=>{const{insert:n}=e,t=f.useContext(X.SchemaOptionsContext),{getCollectionFieldsOptions:o}=s.useCollectionManager(),{t:a}=Q(),{theme:i}=s.useGlobalTheme();return r.jsx(s.DataBlockInitializer,J(P({},e),{componentType:"Map",icon:r.jsx(te.TableOutlined,{}),onCreateBlockSchema:h=>he(this,[h],function*({item:l}){const b=o(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]}),S=o(l.name,"string"),C=yield s.FormDialog(a("Create map block"),()=>{var c;return r.jsx(s.SchemaComponentOptions,{scope:t.scope,components:P({},t.components),children:r.jsx(Je.FormLayout,{layout:"vertical",children:r.jsx(s.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:b,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:b.length?[b[0].value,(c=b[0].children)==null?void 0:c[0].value].filter(y=>y!=null):[]},marker:{title:a("Marker field"),enum:S,"x-component":"Select","x-decorator":"FormItem","x-reactions":y=>{const u=y.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,b);d&&(y.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});n(It({collection:l.name,fieldNames:P({},C)}))}),title:a("Map block")}))},Ot=e=>{const t=f.useContext(s.SchemaInitializerContext).BlockInitializers.items[0].children;return f.useEffect(()=>{t.find(o=>o.component==="MapBlockInitializer")||t.push({key:"mapBlock",type:"item",title:$("Map"),component:"MapBlockInitializer"})},[]),r.jsx(s.SchemaInitializerProvider,{initializers:{MapActionInitializers:Xe},children:r.jsx(s.SchemaComponentOptions,{scope:{useMapBlockProps:St},components:{MapBlockInitializer:kt,MapBlockDesigner:Pt,MapBlockProvider:wt,MapBlock:Ct},children:e.children})})},{defaultProps:Ft}=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 ge={properties:J(P({},Ft),{"uiSchema.x-component-props.mapType":{title:$("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:we}}),schemaInitialize(e,{block:n}){n==="Form"&&Object.assign(e,{"x-designer":"Map.Designer"})}},Et=P({name:"circle",type:"object",group:"map",order:3,title:$("Circle"),description:$("Circle"),sortable:!0,default:{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),zt=P({name:"lineString",type:"object",group:"map",order:2,title:$("Line"),description:$("Line"),sortable:!0,default:{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Lt=P({name:"point",type:"object",group:"map",order:1,title:$("Point"),description:$("Point"),sortable:!0,default:{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Tt=P({name:"polygon",type:"object",group:"map",order:4,title:$("Polygon"),description:$("Polygon"),sortable:!0,default:{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}}},ge),Me=[Lt,Tt,zt,Et],Bt=Me.reduce((e,n)=>(e[n.name]=n,e),{}),Dt=()=>{const{data:e}=s.useCurrentAppInfo()||{};f.useEffect(()=>{const n=e==null?void 0:e.database.dialect;n&&(s.registerGroup(Me[0].group,{label:$("Map-based geometry"),order:51}),Me.forEach(t=>{Array.isArray(t.dialects)&&!t.dialects.includes(n)||s.registerField(t.group,t.title,t)}))},[e])},Kt=e=>(Dt(),r.jsx(f.Fragment,{children:e.children})),Ge=f.memo(e=>{const n=f.useContext(s.CollectionManagerContext);return r.jsx(s.CurrentAppInfoProvider,{children:r.jsx(Kt,{children:r.jsx(s.SchemaComponentOptions,{components:{Map:De},children:r.jsx(Ot,{children:r.jsx(s.CollectionManagerContext.Provider,{value:J(P({},n),{interfaces:P(P({},n.interfaces),Bt)}),children:e.children})})})})})});Ge.displayName="MapProvider";class qe extends s.Plugin{load(){return he(this,null,function*(){this.app.use(Ge),this.app.pluginSettingsManager.add(de,{title:`{{t("Map Manager", { ns: "${de}" })}}`,icon:"EnvironmentOutlined",Component:st,aclSnippet:"pm.map.configuration"})})}}F.MapPlugin=qe,F.default=qe,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.
|
|
2
|
+
"@nocobase/client": "0.15.0-alpha.2",
|
|
3
3
|
"react": "18.2.0",
|
|
4
|
-
"@nocobase/server": "0.
|
|
4
|
+
"@nocobase/server": "0.15.0-alpha.2",
|
|
5
5
|
"@formily/react": "2.2.27",
|
|
6
6
|
"lodash": "4.17.21",
|
|
7
7
|
"@ant-design/icons": "5.1.4",
|
|
@@ -12,6 +12,6 @@ module.exports = {
|
|
|
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.
|
|
16
|
-
"@nocobase/database": "0.
|
|
15
|
+
"@nocobase/actions": "0.15.0-alpha.2",
|
|
16
|
+
"@nocobase/database": "0.15.0-alpha.2"
|
|
17
17
|
};
|
package/dist/locale/zh-CN.d.ts
CHANGED
|
@@ -45,5 +45,8 @@ declare const locale: {
|
|
|
45
45
|
'Marker field': string;
|
|
46
46
|
'Load google maps failed, Please check the Api key and refresh the page': string;
|
|
47
47
|
'Create map block': string;
|
|
48
|
+
'Start point': string;
|
|
49
|
+
'End point': string;
|
|
50
|
+
'Concatenation order field': string;
|
|
48
51
|
};
|
|
49
52
|
export default locale;
|
package/dist/locale/zh-CN.js
CHANGED
|
@@ -67,6 +67,9 @@ const locale = {
|
|
|
67
67
|
"Map field": "\u5730\u56FE\u5B57\u6BB5",
|
|
68
68
|
"Marker field": "\u6807\u8BB0\u5B57\u6BB5",
|
|
69
69
|
"Load google maps failed, Please check the Api key and refresh the page": "\u52A0\u8F7D\u8C37\u6B4C\u5730\u56FE\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 Api key \u5E76\u5237\u65B0\u9875\u9762",
|
|
70
|
-
"Create map block": "\u521B\u5EFA\u5730\u56FE\u533A\u5757"
|
|
70
|
+
"Create map block": "\u521B\u5EFA\u5730\u56FE\u533A\u5757",
|
|
71
|
+
"Start point": "\u8D77\u70B9",
|
|
72
|
+
"End point": "\u7EC8\u70B9",
|
|
73
|
+
"Concatenation order field": "\u8FDE\u63A5\u987A\u5E8F\u5B57\u6BB5"
|
|
71
74
|
};
|
|
72
75
|
var zh_CN_default = locale;
|
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.
|
|
5
|
+
"version": "0.15.0-alpha.2",
|
|
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": "2504887cf82935200bf546b28adf2872cab3e452"
|
|
38
38
|
}
|