@nocobase/plugin-map 1.0.0-alpha.8 → 1.0.1-alpha.1
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/block/MapBlock.Settings.d.ts +68 -0
- package/dist/client/components/hook.d.ts +9 -0
- package/dist/client/constants.d.ts +1 -1
- package/dist/client/fields/fieldSettingsComponentMap.d.ts +10 -0
- package/dist/client/index.js +23 -19
- package/dist/externalVersion.js +7 -6
- package/dist/server/interfaces/index.d.ts +23 -0
- package/dist/server/interfaces/index.js +80 -0
- package/dist/server/plugin.js +5 -0
- package/package.json +2 -2
|
@@ -6,5 +6,73 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
/// <reference types="react" />
|
|
9
10
|
import { SchemaSettings } from '@nocobase/client';
|
|
11
|
+
export declare const defaultZoomLevel: {
|
|
12
|
+
name: string;
|
|
13
|
+
Component: import("react").FC<import("@nocobase/client").SchemaSettingsModalItemProps>;
|
|
14
|
+
useComponentProps(): {
|
|
15
|
+
title: string;
|
|
16
|
+
schema: import("@formily/react").Stringify<{
|
|
17
|
+
[key: symbol]: any;
|
|
18
|
+
[key: `x-${string}`]: any;
|
|
19
|
+
[key: `x-${number}`]: any;
|
|
20
|
+
version?: string;
|
|
21
|
+
name?: import("@formily/react").SchemaKey;
|
|
22
|
+
title?: any;
|
|
23
|
+
description?: any;
|
|
24
|
+
default?: any;
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
writeOnly?: boolean;
|
|
27
|
+
type?: import("@formily/react").SchemaTypes;
|
|
28
|
+
enum?: import("@formily/react").SchemaEnum<any>;
|
|
29
|
+
const?: any;
|
|
30
|
+
multipleOf?: number;
|
|
31
|
+
maximum?: number;
|
|
32
|
+
exclusiveMaximum?: number;
|
|
33
|
+
minimum?: number;
|
|
34
|
+
exclusiveMinimum?: number;
|
|
35
|
+
maxLength?: number;
|
|
36
|
+
minLength?: number;
|
|
37
|
+
pattern?: string | RegExp;
|
|
38
|
+
maxItems?: number;
|
|
39
|
+
minItems?: number;
|
|
40
|
+
uniqueItems?: boolean;
|
|
41
|
+
maxProperties?: number;
|
|
42
|
+
minProperties?: number;
|
|
43
|
+
required?: string | boolean | string[];
|
|
44
|
+
format?: string;
|
|
45
|
+
$ref?: string;
|
|
46
|
+
$namespace?: string;
|
|
47
|
+
definitions?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
48
|
+
properties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
49
|
+
items?: import("@formily/react").SchemaItems<any, any, any, any, any, any, any, any>;
|
|
50
|
+
additionalItems?: import("@formily/react").Stringify<any>;
|
|
51
|
+
patternProperties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
|
|
52
|
+
additionalProperties?: import("@formily/react").Stringify<any>;
|
|
53
|
+
"x-value"?: any;
|
|
54
|
+
"x-index"?: number;
|
|
55
|
+
"x-pattern"?: any;
|
|
56
|
+
"x-display"?: any;
|
|
57
|
+
"x-validator"?: any;
|
|
58
|
+
"x-decorator"?: any;
|
|
59
|
+
"x-decorator-props"?: any;
|
|
60
|
+
"x-component"?: any;
|
|
61
|
+
"x-component-props"?: any;
|
|
62
|
+
"x-reactions"?: import("@formily/react").SchemaReactions<any>;
|
|
63
|
+
"x-content"?: any;
|
|
64
|
+
"x-data"?: any;
|
|
65
|
+
"x-visible"?: boolean;
|
|
66
|
+
"x-hidden"?: boolean;
|
|
67
|
+
"x-disabled"?: boolean;
|
|
68
|
+
"x-editable"?: boolean;
|
|
69
|
+
"x-read-only"?: boolean;
|
|
70
|
+
"x-read-pretty"?: boolean;
|
|
71
|
+
"x-compile-omitted"?: string[];
|
|
72
|
+
}>;
|
|
73
|
+
onSubmit: ({ zoom }: {
|
|
74
|
+
zoom: any;
|
|
75
|
+
}) => void;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
10
78
|
export declare const mapBlockSettings: SchemaSettings<{}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const useMapHeight: () => number;
|
|
@@ -11,4 +11,4 @@ export declare const MapTypes: {
|
|
|
11
11
|
value: string;
|
|
12
12
|
}[];
|
|
13
13
|
export declare const selectedImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC";
|
|
14
|
-
export declare const defaultImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/
|
|
14
|
+
export declare const defaultImage = "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==";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { SchemaSettings } from '@nocobase/client';
|
|
10
|
+
export declare const fieldSettingsComponentMap: SchemaSettings<{}>;
|
package/dist/client/index.js
CHANGED
|
@@ -7,27 +7,27 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(D,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared"],s):(D=typeof globalThis!="undefined"?globalThis:D||self,s(D["@nocobase/plugin-map"]={},D.jsxRuntime,D["@nocobase/client"],D.react,D["@ant-design/icons"],D["@formily/react"],D.ahooks,D.antd,D["react-i18next"],D["react-router-dom"],D.lodash,D["@formily/antd-v5"],D["@formily/shared"]))})(this,function(D,s,n,h,R,G,V,w,ne,le,ke,We,Ye){"use strict";var Tt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var Ve=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable;var Pe=(D,s,n)=>s in D?Tt(D,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):D[s]=n,O=(D,s)=>{for(var n in s||(s={}))Ut.call(s,n)&&Pe(D,n,s[n]);if(Ve)for(var n of Ve(s))Nt.call(s,n)&&Pe(D,n,s[n]);return D},X=(D,s)=>Bt(D,Kt(s));var F=(D,s,n)=>(Pe(D,typeof s!="symbol"?s+"":s,n),n);var ye=(D,s,n)=>new Promise((h,R)=>{var G=ne=>{try{w(n.next(ne))}catch(le){R(le)}},V=ne=>{try{w(n.throw(ne))}catch(le){R(le)}},w=ne=>ne.done?h(ne.value):Promise.resolve(ne.value).then(G,V);w((n=n.apply(D,s)).next())});const fe="map";function Q(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function J(){return ne.useTranslation([fe,"client"],{nsMode:"fallback"})}const Fe=[{label:Q("AMap"),value:"amap"},{label:Q("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAYAAACM5Lr9AAAFkklEQVR42s3VaWxUVRjG8ddiEKPRxAQTCVSWLnZaWmjpTgulpYUBExP9Agou4IKAogUKAgItlNJCgUIXINFPfsFoDCjibkQRI0QIICAQWUpZugKtpcv0+DxyYqaTe2/vTLf58Etu7znnPf+0k44opQw5i5qsjIFs2APHoBZatFq+02vZeq94yyKs0dOjsAzOTCtuVtNKWtX0UpeaXqHU07tgt4ZnvuMa93Avz/CsniE2WIQV2iEaCDnQ8F/MTgZ4h2d4ljNgmZ4pFszDpmIRIuFP57YWDMcFu7uHMziLMyEKxJBl2MbbM6DZub2NQ3sUZ3K2vkMMGIdNKbi1ADqcZe1q2i7VKzibd8BCEE8GUQ3PQ4ez3KWcGNCbeAfv0neKm85hWRvqo+Hu1LJ2HuwTvAt3tkAciKbDIDO/7iE4l7X9rpqCA30pa3uLwt3nYRAIuIfV5mcWN6msnapf8G405IGQMGry+prB0DiloqPfwng3G3SLDltXnTt5S6PK3NnRr9jAFhDJyLsZAJcz8SGcjOr+xAa0XGGTpOfeSMrYUKcyKlx+gS1oSkbY9VXpm2+rjHKXX2ALm2TS2qq96duaVHp5u19gC5skbc3V05N23FWT8NIfsIVNkra6siGttE2llbX7h9JWhaZ6mfj+lfaJZW3Kn6DJJRNWXWqbgN+Y39jRqtDUKKkrL15PxfdjammrfyhpVmiqlNQVfx9KwX/cFJT6A7awSVLeu1CeUlinxu9o8QsphbUKTWUyfvn5Wcm511QSXvoDtrBJkpedewzaE/E58wdsYZMopSQ55+z+pKK6fo9KKqpXaDkAIgxLWnomK3H1JZVQ0tyv2ICW6XAvLHHJ6QD4K6GgRsVjQ3/g3WzQLffCKGHJqfHgisOXaNy2f/oU7+TdukGIUW5xJ0vic6+oWGzsS7yTd4NoncPiF594GC7FFlSrcVub+gTv4p36btE6h1Fc9nFn7IpzKmZrY5/gXbwTxI0O8xD77rGPYtZeVtE42Jt4B+8C8WAcNu6dPwZDzVh8PYzdcqdXcDbvgMdBPDHEOG7R0Xkxqy6oKAzpDZzNO0AMmIfFvH1kABwZk1epIotv9yjOxOyj+g4xYB4W/dbvlAAdozGsJ3Gmni0mzMPGLvyN6IMo/NojNt/qEZyFmR+CWLAIW3CYaDDUR+D/TTgGdwdncJaeKRbMw8bM/9XdosjlZ5VjU0O3cAZngXTBPCzqzV/cPQAXHeuqVBgu8IVj/TXFGXqWdME8LHLez55mRSw9qUI31fuEZzFjNogNFmFvHPQUACfC8IUbUlTvlbDcSsWzeobYYB42+vWfjDwbnn3c6zCewdnnQGwyD4t47UcjAXA2JO+qCi6ss4V7eUafFZuswn4wM8ex+LgKwqV2cC/OzAXxgnlY+KvfmxkIVaPyr6tRhbWWuId79RnxgnmYY+53VlaHLj2lRm6stRSSc0ph7xoQL1mEzfnWyhPQNrKgGgE1hrjGPTAExEvmYWGvfNOVPUErz6vhiDDCNez5GMQHVmFfd2Vq6MLD6smCGkNc4x4QH5iHPfXyV125H64NX1eFkOpO+I5reo/4wDws9KUDdhSPxFdNIGLc8R3XQHxkFfalHYnB8w6qYRuqO+E7roH4yDws5MX9dtwHlYF5lQi6qYjPfKfXxEcWYbO/sKtsBP50QxFFI/D/De8qQLrBPCwYizY9M2r+of/D+Mx3ID6zDJv1uaVwGfAIBDqGJsbhZ9eQ/BuK+OwYlhzPNe7hXh9Yhe0zwqBB4IAYouCZn1wIXH5GEZ/d1sjBMzzrBfOwoBf2GWFYBMS4C03JWRA087OaoBmf3uCz5zrP8Kx9lmF7jXiE2RbBs95ghB0MIo8/pS0OeJAzvOBLmKY//BAGURBN+jmMa3qPkLdh/wKOL8SpLbnYFgAAAABJRU5ErkJggg==",Oe=(e,o,t)=>{const r=o==null?void 0:o.reduce((a,i,l)=>l===o.length-1&&(t==="o2m"||t==="m2m")?a==null?void 0:a.map(m=>m[i]).filter(m=>m!=null):a==null?void 0:a[i],e);return t==="o2m"||t==="m2m"?r:[r]};var Je=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={exports:{}};(function(e,o){(function(t,r){e.exports=r()})(Je,function(){function t(c){var b=[];return c.AMapUI&&b.push(r(c.AMapUI)),c.Loca&&b.push(a(c.Loca)),Promise.all(b)}function r(c){return new Promise(function(b,u){var d=[];if(c.plugins)for(var M=0;M<c.plugins.length;M+=1)l.AMapUI.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);if(m.AMapUI===i.failed)u("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,l.AMapUI.version=c.version||l.AMapUI.version,M=l.AMapUI.version;var L=document.body||document.head,K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/ui/"+M+"/main.js",K.onerror=function(I){m.AMapUI=i.failed,u("请求 AMapUI 失败")},K.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},L.appendChild(K)}else m.AMapUI===i.loaded?c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}b()}):b():c.version&&c.version!==l.AMapUI.version?u("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?u(I):d.length?window.AMapUI.loadUI(d,function(){for(var q=0,Y=d.length;q<Y;q++){var U=d[q].split("/").slice(-1)[0];window.AMapUI[U]=arguments[q]}b()}):b()})})}function a(c){return new Promise(function(b,u){if(m.Loca===i.failed)u("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,l.Loca.version=c.version||l.Loca.version;var d=l.Loca.version,M=l.AMap.version.startsWith("2"),L=d.startsWith("2");if(M&&!L||!M&&L)u("JSAPI 与 Loca 版本不对应!!");else{M=l.key,L=document.body||document.head;var K=document.createElement("script");K.type="text/javascript",K.src="https://webapi.amap.com/loca?v="+d+"&key="+M,K.onerror=function(I){m.Loca=i.failed,u("请求 AMapUI 失败")},K.onload=function(){for(m.Loca=i.loaded,b();v.Loca.length;)v.Loca.splice(0,1)[0]()},L.appendChild(K)}}else m.Loca===i.loaded?c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):b():c.version&&c.version!==l.Loca.version?u("不允许多个版本 Loca 混用"):v.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"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]},A=[],C=function(c){typeof c=="function"&&(m.AMap===i.loaded?c(window.AMap):A.push(c))};return{load:function(c){return new Promise(function(b,u){if(m.AMap==i.failed)u("");else if(m.AMap==i.notload){var d=c.key,M=c.version,L=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&u("禁止多种API加载方式混用"),l.key=d,l.AMap.version=M||l.AMap.version,l.AMap.plugins=L||l.AMap.plugins,m.AMap=i.loading,M=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=i.failed,u(I);else for(m.AMap=i.loaded,t(c).then(function(){b(window.AMap)}).catch(u);A.length;)A.splice(0,1)[0]()},L=document.createElement("script"),L.type="text/javascript",L.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+l.AMap.version+"&key="+d+"&plugin="+l.AMap.plugins.join(","),L.onerror=function(I){m.AMap=i.failed,u(I)},M.appendChild(L)):u("请填写key")}else if(m.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(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&d.push(c.plugins[M]);d.length?window.AMap.plugin(d,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(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 K=[];if(c.plugins)for(M=0;M<c.plugins.length;M+=1)l.AMap.plugins.indexOf(c.plugins[M])==-1&&K.push(c.plugins[M]);C(function(){K.length?window.AMap.plugin(K,function(){t(c).then(function(){b(window.AMap)}).catch(u)}):t(c).then(function(){b(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"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Ee);var Xe=Ee.exports;const He=Ze(Xe),ze="map-configuration",ve=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Ae=e=>{const o=h.useMemo(()=>{const r=sessionStorage.getItem(ve(e));return r&&JSON.parse(r)},[e]),{data:t}=n.useRequest({resource:ze,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(ve(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!o});return o||(t==null?void 0:t.data)},Qe=e=>{const{aMap:o,toCenter:t}=e,{t:r}=J(),a=h.useRef(),[i,l]=h.useState([]);h.useEffect(()=>{o==null||o.plugin("AMap.PlaceSearch",()=>{a.current=new o.PlaceSearch({city:"全国",pageSize:30})})},[o]);const{run:m}=V.useDebounceFn(A=>{a.current&&a.current.search(A||" ",(C,c)=>{if(C==="complete")l(c.poiList.pois.map(b=>X(O({},b),{label:`${b.name}-${b.address}`,value:b.id})));else{if(C==="no_data"){l([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=A=>{const C=i.find(c=>c.value===A);C!=null&&C.location&&t(C.location)};return s.jsx("div",{className:n.css`
|
|
10
|
+
(function(T,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("react/jsx-runtime"),require("@nocobase/client"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("ahooks"),require("antd"),require("react-i18next"),require("react-router-dom"),require("lodash"),require("@formily/antd-v5"),require("@formily/shared"),require("@emotion/css")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@nocobase/client","react","@ant-design/icons","@formily/react","ahooks","antd","react-i18next","react-router-dom","lodash","@formily/antd-v5","@formily/shared","@emotion/css"],s):(T=typeof globalThis!="undefined"?globalThis:T||self,s(T["@nocobase/plugin-map"]={},T.jsxRuntime,T["@nocobase/client"],T.react,T["@ant-design/icons"],T["@formily/react"],T.ahooks,T.antd,T["react-i18next"],T["react-router-dom"],T.lodash,T["@formily/antd-v5"],T["@formily/shared"],T["@emotion/css"]))})(this,function(T,s,n,g,ee,G,V,w,se,le,ke,Je,Ze,Xe){"use strict";var qt=Object.defineProperty,jt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var He=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable;var Pe=(T,s,n)=>s in T?qt(T,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):T[s]=n,F=(T,s)=>{for(var n in s||(s={}))Vt.call(s,n)&&Pe(T,n,s[n]);if(He)for(var n of He(s))Wt.call(s,n)&&Pe(T,n,s[n]);return T},J=(T,s)=>jt(T,_t(s));var E=(T,s,n)=>(Pe(T,typeof s!="symbol"?s+"":s,n),n);var ye=(T,s,n)=>new Promise((g,ee)=>{var G=se=>{try{w(n.next(se))}catch(le){ee(le)}},V=se=>{try{w(n.throw(se))}catch(le){ee(le)}},w=se=>se.done?g(se.value):Promise.resolve(se.value).then(G,V);w((n=n.apply(T,s)).next())});const fe="map";function R(e){return`{{t('${e}', { ns: '${fe}', nsMode: 'fallback' })}}`}function H(){return se.useTranslation([fe,"client"],{nsMode:"fallback"})}const Fe=[{label:R("AMap"),value:"amap"},{label:R("Google Maps"),value:"google"}],be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAA/CAMAAAC7OkrPAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAEJQTFRFAAAA8Yti8Yti8Itj8Iti74tj8Itj8YtiKwADKwADKhw5Kh07KwADKwADKwADKwAD4odn1YBlKwADKwADKwADKwAD/5y7LQAAABZ0Uk5TAP/8/f/B/PYOHjY3CCozLP3XCSkvMhA05K4AAAC4SURBVHic7dXLDoIwEIXhwSsoLSrw/q8qbSAiMy3/oivj2czmS5omnVORdapVJJFKBSEL2mrrUurbpdXa5dTH5dXi9tTsGNtX0TFG1OT+7PdY2YdEGd0FuFmUwXWm5UAZbCTKYA3SUrXZQTHLHbUy2OlsMO0ultLsajLlbEWZMEUZ+ig5E6YKM2GqMBOmGKubW1D3ps6g1nnvA5uGa5Os85E9nmF2ebYkzeKhc9wre4V+GMeh317hDfXgCWigIGJbAAAAAElFTkSuQmCC",ue="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==",Oe=(e,t,o)=>{const r=t==null?void 0:t.reduce((l,i,a)=>a===t.length-1&&(o==="o2m"||o==="m2m")?l==null?void 0:l.map(m=>m[i]).filter(m=>m!=null):l==null?void 0:l[i],e);return o==="o2m"||o==="m2m"?r:[r]};var $e=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Qe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ee={exports:{}};(function(e,t){(function(o,r){e.exports=r()})($e,function(){function o(c){var b=[];return c.AMapUI&&b.push(r(c.AMapUI)),c.Loca&&b.push(l(c.Loca)),Promise.all(b)}function r(c){return new Promise(function(b,p){var d=[];if(c.plugins)for(var C=0;C<c.plugins.length;C+=1)a.AMapUI.plugins.indexOf(c.plugins[C])==-1&&d.push(c.plugins[C]);if(m.AMapUI===i.failed)p("前次请求 AMapUI 失败");else if(m.AMapUI===i.notload){m.AMapUI=i.loading,a.AMapUI.version=c.version||a.AMapUI.version,C=a.AMapUI.version;var D=document.body||document.head,U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/ui/"+C+"/main.js",U.onerror=function(I){m.AMapUI=i.failed,p("请求 AMapUI 失败")},U.onload=function(){if(m.AMapUI=i.loaded,d.length)window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()});else for(b();v.AMapUI.length;)v.AMapUI.splice(0,1)[0]()},D.appendChild(U)}else m.AMapUI===i.loaded?c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):d.length?window.AMapUI.loadUI(d,function(){for(var I=0,q=d.length;I<q;I++){var Y=d[I].split("/").slice(-1)[0];window.AMapUI[Y]=arguments[I]}b()}):b():c.version&&c.version!==a.AMapUI.version?p("不允许多个版本 AMapUI 混用"):v.AMapUI.push(function(I){I?p(I):d.length?window.AMapUI.loadUI(d,function(){for(var q=0,Y=d.length;q<Y;q++){var N=d[q].split("/").slice(-1)[0];window.AMapUI[N]=arguments[q]}b()}):b()})})}function l(c){return new Promise(function(b,p){if(m.Loca===i.failed)p("前次请求 Loca 失败");else if(m.Loca===i.notload){m.Loca=i.loading,a.Loca.version=c.version||a.Loca.version;var d=a.Loca.version,C=a.AMap.version.startsWith("2"),D=d.startsWith("2");if(C&&!D||!C&&D)p("JSAPI 与 Loca 版本不对应!!");else{C=a.key,D=document.body||document.head;var U=document.createElement("script");U.type="text/javascript",U.src="https://webapi.amap.com/loca?v="+d+"&key="+C,U.onerror=function(I){m.Loca=i.failed,p("请求 AMapUI 失败")},U.onload=function(){for(m.Loca=i.loaded,b();v.Loca.length;)v.Loca.splice(0,1)[0]()},D.appendChild(U)}}else m.Loca===i.loaded?c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):b():c.version&&c.version!==a.Loca.version?p("不允许多个版本 Loca 混用"):v.Loca.push(function(I){I?p(I):p()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var i;(function(c){c.notload="notload",c.loading="loading",c.loaded="loaded",c.failed="failed"})(i||(i={}));var a={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]},h=[],M=function(c){typeof c=="function"&&(m.AMap===i.loaded?c(window.AMap):h.push(c))};return{load:function(c){return new Promise(function(b,p){if(m.AMap==i.failed)p("");else if(m.AMap==i.notload){var d=c.key,C=c.version,D=c.plugins;d?(window.AMap&&location.host!=="lbs.amap.com"&&p("禁止多种API加载方式混用"),a.key=d,a.AMap.version=C||a.AMap.version,a.AMap.plugins=D||a.AMap.plugins,m.AMap=i.loading,C=document.body||document.head,window.___onAPILoaded=function(I){if(delete window.___onAPILoaded,I)m.AMap=i.failed,p(I);else for(m.AMap=i.loaded,o(c).then(function(){b(window.AMap)}).catch(p);h.length;)h.splice(0,1)[0]()},D=document.createElement("script"),D.type="text/javascript",D.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+a.AMap.version+"&key="+d+"&plugin="+a.AMap.plugins.join(","),D.onerror=function(I){m.AMap=i.failed,p(I)},C.appendChild(D)):p("请填写key")}else if(m.AMap==i.loaded)if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{if(d=[],c.plugins)for(C=0;C<c.plugins.length;C+=1)a.AMap.plugins.indexOf(c.plugins[C])==-1&&d.push(c.plugins[C]);d.length?window.AMap.plugin(d,function(){o(c).then(function(){b(window.AMap)}).catch(p)}):o(c).then(function(){b(window.AMap)}).catch(p)}else if(c.key&&c.key!==a.key)p("多个不一致的 key");else if(c.version&&c.version!==a.AMap.version)p("不允许多个版本 JSAPI 混用");else{var U=[];if(c.plugins)for(C=0;C<c.plugins.length;C+=1)a.AMap.plugins.indexOf(c.plugins[C])==-1&&U.push(c.plugins[C]);M(function(){U.length?window.AMap.plugin(U,function(){o(c).then(function(){b(window.AMap)}).catch(p)}):o(c).then(function(){b(window.AMap)}).catch(p)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,a={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},m={AMap:i.notload,AMapUI:i.notload,Loca:i.notload},v={AMap:[],AMapUI:[],Loca:[]}}}})})(Ee);var Re=Ee.exports;const Le=Qe(Re),Te="map-configuration",ve=e=>`NOCOBASE_PLUGIN_MAP_CONFIGURATION_${e}`,Me=e=>{const t=g.useMemo(()=>{const r=sessionStorage.getItem(ve(e));return r&&JSON.parse(r)},[e]),{data:o}=n.useRequest({resource:Te,action:"get",params:{type:e}},{onSuccess(r){sessionStorage.setItem(ve(e),JSON.stringify(r==null?void 0:r.data))},refreshOnWindowFocus:!1,refreshDeps:[],manual:!!t});return t||(o==null?void 0:o.data)},et=e=>{const{aMap:t,toCenter:o}=e,{t:r}=H(),l=g.useRef(),[i,a]=g.useState([]);g.useEffect(()=>{t==null||t.plugin("AMap.PlaceSearch",()=>{l.current=new t.PlaceSearch({city:"全国",pageSize:30})})},[t]);const{run:m}=V.useDebounceFn(h=>{l.current&&l.current.search(h||" ",(M,c)=>{if(M==="complete")a(c.poiList.pois.map(b=>J(F({},b),{label:`${b.name}-${b.address}`,value:b.id})));else{if(M==="no_data"){a([]);return}w.message.error(r("Please configure the AMap securityCode or securityHost correctly"))}})},{wait:300}),v=h=>{const M=i.find(c=>c.value===h);M!=null&&M.location&&o(M.location)};return s.jsx("div",{className:n.css`
|
|
11
11
|
position: absolute;
|
|
12
12
|
top: 10px;
|
|
13
13
|
left: 10px;
|
|
14
14
|
z-index: 10;
|
|
15
15
|
width: calc(100% - 20px);
|
|
16
|
-
`,children:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i,popupMatchSelectWidth:!1})})},
|
|
16
|
+
`,children:s.jsx(w.Select,{showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i,popupMatchSelectWidth:!1})})},tt=()=>{var M,c;const e=n.useDataBlockHeight(),{token:t}=w.theme.useToken(),{designable:o}=n.useDesignable(),{heightProps:r}=n.useBlockHeightProps()||{},{title:l}=r||{},i=G.useFieldSchema();if(!e)return;const a=Object.keys(((c=(M=i.parent)==null?void 0:M.properties.actions)==null?void 0:c.properties)||{}).length>0,m=o||a?t.paddingLG+t.controlHeight+t.margin:t.paddingLG+t.margin,v=t.paddingLG,h=l?t.fontSizeLG*t.lineHeightLG+t.padding*2-1:0;return e-m-v-h},Ae={point:{mouseTool:"marker",propertyKey:"position",overlay:"Marker"},polygon:{mouseTool:"polygon",editor:"PolygonEditor",propertyKey:"path",overlay:"Polygon"},lineString:{mouseTool:"polyline",editor:"PolylineEditor",propertyKey:"path",overlay:"Polyline"},circle:{mouseTool:"circle",editor:"CircleEditor",transformOptions(e){return{center:e.slice(0,2),radius:e[2]}},overlay:"Circle"}},Ce=g.forwardRef((e,t)=>{const{accessKey:o,securityJsCode:r}=Me(e.mapType)||{},{value:l,onChange:i,block:a=!1,readonly:m,disabled:v=a,zoom:h=13,overlayCommonOptions:M}=e,{t:c}=H(),b=G.useFieldSchema(),p=g.useRef(),d=g.useRef(),C=g.useRef(),[D,U]=g.useState([]),[I,q]=g.useState(""),{getField:Y}=n.useCollection_deprecated(),N=g.useMemo(()=>{if(e.type)return e.type;const u=Y(b==null?void 0:b.name);return u==null?void 0:u.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),B=g.useRef(),K=g.useRef(null),te=le.useNavigate(),$=g.useRef(`nocobase-map-${N||""}-${Date.now().toString(32)}`),{modal:oe}=w.App.useApp(),re=tt(),[Q]=g.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1},M));g.useEffect(()=>{d.current&&d.current.setZoom(h)},[h]);const ne=V.useMemoizedFn(()=>{B.current&&B.current.remove()}),P=V.useMemoizedFn(()=>{(!v||a)&&N!=="point"&&K.current&&(K.current.setTarget(B.current),K.current.open())}),W=V.useMemoizedFn((u,f=!1)=>{let A=null;if(N==="point"){const{lat:k,lng:Z}=u.getPosition();A=[Z,k]}else if(N==="polygon"||N==="lineString"){if(A=u.getPath().map(k=>[k.lng,k.lat]),A.length<2)return}else if(N==="circle"){const k=u.getCenter(),Z=u.getRadius();A=[k.lng,k.lat,Z]}f||(ne(),B.current=u,P()),i==null||i(A)}),z=V.useMemoizedFn((u=N)=>{const f=Ae[u];if(f&&"editor"in f&&!K.current)return K.current=new p.current[f.editor](d.current,null,{createOptions:Q,editOptions:Q,controlPoint:J(F({},Q),{strokeWeight:3}),midControlPoint:J(F({},Q),{strokeWeight:2,fillColor:"#fff"})}),K.current.on("adjust",function({target:A}){W(A,!0)}),K.current.on("move",function({target:A}){W(A,!0)}),K.current}),X=V.useMemoizedFn((u=N)=>{var A;if(!C.current||(A=K.current)!=null&&A.getTarget())return;const f=Ae[u];f&&C.current[f.mouseTool](F({},Q))}),x=V.useMemoizedFn((u=N)=>{C.current||(C.current=new p.current.MouseTool(d.current),C.current.on("draw",function({obj:f}){W(f)}),X(u))}),L=(u,f)=>{d.current&&d.current.setZoomAndCenter(18,u,f)},y=()=>{const u=()=>{ne(),K.current&&(K.current.setTarget(),K.current.close()),i==null||i(null)};oe.confirm({title:c("Clear the canvas"),content:c("Are you sure to clear the canvas?"),okText:c("Confirm"),cancelText:c("Cancel"),getContainer:()=>document.getElementById($.current),onOk(){u()}})},O=()=>{B.current&&d.current.setFitView([B.current])},_=g.useCallback((u=N,f=l,A)=>{const k=Ae[u];if(!k)return;const Z=F(F({},Q),A);return"transformOptions"in k?Object.assign(Z,k.transformOptions(f)):"propertyKey"in k&&(Z[k.propertyKey]=f),new p.current[k.overlay](Z)},[Q]),j=(u=N,f=l,A)=>{if(!p.current)return;const k=_(u,f,A);return k.setMap(d.current),k};g.useEffect(()=>{if(!p.current||!l||!m&&B.current)return;const u=j();d.current.setFitView([u]),B.current=u,v||(z(),P())},[l,D,N,Q,v,m]),g.useEffect(()=>{var u,f,A;C.current&&(v?((u=C.current)==null||u.close(),(f=K.current)==null||f.close()):(X(),(A=K.current)==null||A.open()))},[v]),g.useEffect(()=>{!p.current||!N||v||(x(),z())},[v,D,N]),g.useEffect(()=>{var f,A;if(!l&&(C.current||K.current)&&(ne(),K.current&&(K.current.setTarget(),K.current.close()),i==null||i(null)),!C.current||!K.current)return;K.current.getTarget()?(A=(f=C.current).close)==null||A.call(f):X()},[N,l]),g.useEffect(()=>{if(!o||d.current)return;r&&(window._AMapSecurityConfig={[r.endsWith("_AMapService")?"serviceHOST":"securityJsCode"]:r});const u=window.define;return window.define=void 0,Le.load({key:o,version:"2.0",plugins:["AMap.MouseTool","AMap.PolygonEditor","AMap.PolylineEditor","AMap.CircleEditor"]}).then(f=>(window.define=u,requestIdleCallback(()=>{d.current=new f.Map($.current,{resizeEnable:!0,zoom:h}),p.current=f,q(""),U([])}))).catch(f=>{typeof f=="string"?f.includes("多个不一致的 key")?q(c("The AccessKey is incorrect, please check it")):q(f):(f==null?void 0:f.type)==="error"&&q("Something went wrong, please refresh the page and try again")}),()=>{var f;(f=d.current)==null||f.destroy(),p.current=null,d.current=null,C.current=null,K.current=null,Le.reset()}},[o,N,r]),g.useImperativeHandle(t,()=>({setOverlay:j,getOverlay:_,createMouseTool:x,createEditor:z,executeMouseTool:X,aMap:p.current,map:d.current,overlay:B.current,mouseTool:()=>C.current,editor:()=>K.current,errMessage:I}));const S=n.useApp();return!o||I?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>te(S.pluginSettingsManager.getRoutePath("map")),children:c("Go to the configuration page")}),message:I||c("Please configure the AccessKey and SecurityJsCode first"),type:"error"}):s.jsxs("div",{className:n.css`
|
|
17
17
|
position: relative;
|
|
18
|
-
height:
|
|
19
|
-
`,id
|
|
18
|
+
height: ${re||500}px;
|
|
19
|
+
`,id:$.current,style:e==null?void 0:e.style,children:[!p.current&&s.jsx("div",{className:n.css`
|
|
20
20
|
position: absolute;
|
|
21
21
|
inset: 0;
|
|
22
22
|
display: flex;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
25
|
-
`,children:s.jsx(w.Spin,{})}),v?null:s.jsxs(s.Fragment,{children:[s.jsx(
|
|
25
|
+
`,children:s.jsx(w.Spin,{})}),v?null:s.jsxs(s.Fragment,{children:[s.jsx(et,{toCenter:L,aMap:p.current}),s.jsx("div",{className:n.css`
|
|
26
26
|
position: absolute;
|
|
27
27
|
bottom: 80px;
|
|
28
28
|
right: 20px;
|
|
29
29
|
z-index: 10;
|
|
30
|
-
`,children:s.jsx(w.Button,{onClick:
|
|
30
|
+
`,children:s.jsx(w.Button,{onClick:O,disabled:!B.current,type:"primary",shape:"round",size:"large",icon:s.jsx(ee.SyncOutlined,{})})}),N!=="point"?s.jsx("div",{className:n.css`
|
|
31
31
|
position: absolute;
|
|
32
32
|
bottom: 20px;
|
|
33
33
|
left: 10px;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
bottom: 20px;
|
|
39
39
|
right: 20px;
|
|
40
40
|
z-index: 2;
|
|
41
|
-
`,children:s.jsx(w.Button,{disabled:!
|
|
41
|
+
`,children:s.jsx(w.Button,{disabled:!l,style:{height:"40px"},onClick:y,type:"primary",danger:!0,children:c("Clear")})})]})]})});Ce.displayName="AMapComponent";const ot=e=>{var P,W,z,X;const{collectionField:t,fieldNames:o,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{name:v,getPrimaryKey:h}=n.useCollection_deprecated(),{getCollectionJoinField:M}=n.useCollectionManager_deprecated(),c=h(),[b,p]=g.useState(!1),d=g.useRef(),C=(W=(P=d.current)==null?void 0:P.aMap)==null?void 0:W.GeometryUtil,[D,U]=g.useState(),[I,q]=g.useState(""),{t:Y}=H(),N=n.useCompile(),{isConnected:B,doFilter:K}=n.useFilterAPI(),[,te]=g.useState(null),$=g.useRef(I);$.current=I;const oe=(x,L)=>{const y=x.getExtData(),O=typeof L=="undefined"?y.selected:!L;y.selected=!O,"setIcon"in x&&x.setIcon(new d.current.aMap.Icon({imageSize:[19,32],image:O?ue:be})),x.setOptions(F({extData:y},O?{strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{strokeColor:"#F18b62",fillColor:"#F18b62"}))},re=()=>{var x,L,y;d.current&&((x=d.current)==null||x.mouseTool().close(!0),(L=d.current)==null||L.editor().setTarget(null),(y=d.current)==null||y.editor().close())};g.useEffect(()=>{var x,L,y,O;if(I==="selection")return(x=d.current)!=null&&x.editor()?(O=d.current)==null||O.executeMouseTool("polygon"):((L=d.current)==null||L.createEditor("polygon"),(y=d.current)==null||y.createMouseTool("polygon")),()=>{re()}},[I]),g.useEffect(()=>{if(I)return()=>{var x;$.current||(x=d.current)==null||x.map.getAllOverlays().forEach(L=>{oe(L,!1)})}},[I]);const Q=V.useMemoizedFn(()=>{var _,j,S;const x=(_=d.current)==null?void 0:_.editor().getTarget(),L=(j=d.current)==null?void 0:j.map.getAllOverlays(),y=L==null?void 0:L.filter(u=>{if(!(u===x||u.getExtData().id===void 0))return"getPosition"in u?C.isPointInRing(u.getPosition(),x==null?void 0:x.getPath()):C.doesRingRingIntersect(u.getPath(),x==null?void 0:x.getPath())}),O=y==null?void 0:y.map(u=>(oe(u,!0),u.getExtData().id));a(u=>O==null?void 0:O.concat(u)),x==null||x.remove(),(S=d.current)==null||S.editor().close()});g.useEffect(()=>{var _,j,S;if(!t||!d.current||!r)return;const x=Array.isArray(o==null?void 0:o.field)&&(o==null?void 0:o.field.length)>1?o==null?void 0:o.field.slice(0,-1):o==null?void 0:o.field,L=M([v,...x].flat().join(".")),y=r.map(u=>{var A;const f=(A=Oe(u,o==null?void 0:o.field,L==null?void 0:L.interface))==null?void 0:A.filter(Boolean);return f!=null&&f.length?f.map(k=>{var ie;return(ie=d.current)==null?void 0:ie.setOverlay(t.type,k,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{direction:"bottom",offset:[0,5],content:o!=null&&o.marker?N(u[o.marker]):void 0},extData:{id:u[c]}})}):[]}).flat().filter(Boolean);(j=(_=d.current)==null?void 0:_.map)==null||j.setFitView(y);const O=y.map(u=>{const f=A=>{const k=A.target,Z=k.getExtData();if(!Z)return;if($.current){$.current==="click"&&(a(ae=>Z.selected?ae.filter(Ie=>Ie!==Z.id):[...ae,Z.id]),oe(k));return}const ie=r.find(ae=>Z.id===ae[c]);if(B){te(ae=>(ae&&De(ae),ae===u?(De(u),K(null),null):(nt(u),K(ie[c],Ie=>Ie.field||c,"$eq"),u)));return}ie&&U(ie)};return u.on("click",f),()=>u.off("click",f)});if(t.type==="point"&&(m!=null&&m.length)&&(y==null?void 0:y.length)>1){const u=y.map(A=>A.getPosition());y[0].setzIndex(13),y[y.length-1].setzIndex(13);const f=(A=!0)=>{var k,Z;if((k=d.current)!=null&&k.map)return new AMap.Text({label:{direction:"top",offset:[0,0],content:Y(A?"Start point":"End point")},position:u[A?0:u.length-1],map:(Z=d.current)==null?void 0:Z.map})};y.push(...[(S=d.current)==null?void 0:S.setOverlay("lineString",u,{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),f(),f(!1)].filter(Boolean))}return()=>{y.forEach(u=>{u.remove()}),O.forEach(u=>u())}},[r,b,o,v,c,t.type,B,m]),g.useEffect(()=>{setTimeout(()=>{a([])})},[r]);const ne=x=>{d.current=x,p(!!(x!=null&&x.map)&&!x.errMessage)};return s.jsxs("div",{className:n.css`
|
|
42
42
|
position: relative;
|
|
43
43
|
height: 100%;
|
|
44
44
|
`,children:[s.jsx("div",{className:n.css`
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
left: 10px;
|
|
47
47
|
top: 10px;
|
|
48
48
|
z-index: 999;
|
|
49
|
-
`,children:b&&!((
|
|
49
|
+
`,children:b&&!((z=d.current)!=null&&z.errMessage)?s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:I?void 0:"#F18b62",borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),q("")},icon:s.jsx(ee.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:I==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:x=>{x.stopPropagation(),q("selection")},icon:s.jsx(ee.ExpandOutlined,{})}),I==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(ee.CheckOutlined,{}),title:Y("Confirm selection"),onClick:Q}):null]}):null}),s.jsx(rt,{record:D,setVisible:U}),s.jsx(Ce,J(F({},(X=t==null?void 0:t.uiSchema)==null?void 0:X["x-component-props"]),{ref:ne,style:{height:l?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},rt=e=>{const{setVisible:t,record:o}=e,{t:r}=H(),l=n.useCollection(),i=n.useCollectionParentRecordData(),a=G.useFieldSchema(),m=g.useMemo(()=>a.reduceProperties((v,h)=>h.name==="drawer"?h:v,null),[a]);return m&&s.jsx(n.ActionContextProvider,{value:{visible:!!o,setVisible:t},children:s.jsx(n.RecordProvider,{record:o,parent:i,children:s.jsx(n.DeclareVariable,{name:"$nPopupRecord",title:r("Current popup record"),value:o,collection:l,children:s.jsx(G.RecursionField,{schema:m,name:m.name})})})})};function De(e){e.dom?e.dom.style.filter="none":e.setOptions&&e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function nt(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 ze=({type:e,children:t})=>{const{t:o}=H(),[r,l]=V.useBoolean(!1),i=n.useAPIClient(),[a]=w.Form.useForm(),m=Me(e);g.useEffect(()=>{m&&(a.setFieldsValue(m),l.toggle())},[m]);const v=g.useMemo(()=>i.resource(Te),[i]),h=M=>{v.set(J(F({},M),{type:e})).then(c=>{sessionStorage.removeItem(ve(e)),l.toggle(),w.message.success(o("Saved successfully"))}).catch(c=>{w.message.success(o("Saved failed"))})};return s.jsxs(w.Form,{disabled:r,form:a,layout:"vertical",onFinish:h,children:[t,r?s.jsx(w.Button,{disabled:!1,onClick:l.toggle,children:o("Edit")}):s.jsx(w.Form.Item,{children:s.jsx(w.Button,{disabled:!1,type:"primary",htmlType:"submit",children:o("Save")})})]})},st={amap:()=>{const{t:e}=H();return s.jsxs(ze,{type:"amap",children:[s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Access key"),children:s.jsx(w.Input,{})}),s.jsx(w.Form.Item,{required:!0,name:"securityJsCode",label:e("securityJsCode or serviceHost"),children:s.jsx(w.Input,{})})]})},google:()=>{const{t:e}=H();return s.jsx(ze,{type:"google",children:s.jsx(w.Form.Item,{required:!0,name:"accessKey",label:e("Api key"),children:s.jsx(w.Input,{})})})}},it=Fe.map(e=>J(F({},e),{component:st[e.value]})),at=()=>{const e=n.useCompile(),t=le.useLocation(),o=new URLSearchParams(t.search);return s.jsx(w.Card,{bordered:!0,children:s.jsx(w.Tabs,{type:"card",defaultActiveKey:o.get("tab"),children:it.map(r=>s.jsx(w.Tabs.TabPane,{tab:e(r.label),children:s.jsx(r.component,{type:r.value})},r.value))})})};/*! *****************************************************************************
|
|
50
50
|
Copyright (c) Microsoft Corporation.
|
|
51
51
|
|
|
52
52
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
60
60
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
61
61
|
PERFORMANCE OF THIS SOFTWARE.
|
|
62
|
-
***************************************************************************** */function
|
|
62
|
+
***************************************************************************** */function lt(e,t,o,r){function l(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function m(M){try{h(r.next(M))}catch(c){a(c)}}function v(M){try{h(r.throw(M))}catch(c){a(c)}}function h(M){M.done?i(M.value):l(M.value).then(m,v)}h((r=r.apply(e,t||[])).next())})}var ct=function e(t,o){if(t===o)return!0;if(t&&o&&typeof t=="object"&&typeof o=="object"){if(t.constructor!==o.constructor)return!1;var r,l,i;if(Array.isArray(t)){if(r=t.length,r!=o.length)return!1;for(l=r;l--!==0;)if(!e(t[l],o[l]))return!1;return!0}if(t.constructor===RegExp)return t.source===o.source&&t.flags===o.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===o.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===o.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(o).length)return!1;for(l=r;l--!==0;)if(!Object.prototype.hasOwnProperty.call(o,i[l]))return!1;for(l=r;l--!==0;){var a=i[l];if(!e(t[a],o[a]))return!1}return!0}return t!==t&&o!==o};const Be="__googleMapsScriptId";var de;(function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"})(de||(de={}));class ce{constructor({apiKey:t,authReferrerPolicy:o,channel:r,client:l,id:i=Be,language:a,libraries:m=[],mapIds:v,nonce:h,region:M,retries:c=3,url:b="https://maps.googleapis.com/maps/api/js",version:p}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=t,this.authReferrerPolicy=o,this.channel=r,this.client=l,this.id=i||Be,this.language=a,this.libraries=m,this.mapIds=v,this.nonce=h,this.region=M,this.retries=c,this.url=b,this.version=p,ce.instance){if(!ct(this.options,ce.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(ce.instance.options)}`);return ce.instance}ce.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?de.FAILURE:this.done?de.SUCCESS:this.loading?de.LOADING:de.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let t=this.url;return t+="?callback=__googleMapsCallback",this.apiKey&&(t+=`&key=${this.apiKey}`),this.channel&&(t+=`&channel=${this.channel}`),this.client&&(t+=`&client=${this.client}`),this.libraries.length>0&&(t+=`&libraries=${this.libraries.join(",")}`),this.language&&(t+=`&language=${this.language}`),this.region&&(t+=`®ion=${this.region}`),this.version&&(t+=`&v=${this.version}`),this.mapIds&&(t+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(t+=`&auth_referrer_policy=${this.authReferrerPolicy}`),t}deleteScript(){const t=document.getElementById(this.id);t&&t.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((t,o)=>{this.loadCallback(r=>{r?o(r.error):t(window.google)})})}importLibrary(t){return this.execute(),google.maps.importLibrary(t)}loadCallback(t){this.callbacks.push(t),this.execute()}setScript(){var t,o;if(document.getElementById(this.id)){this.callback();return}const r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach(i=>!r[i]&&delete r[i]),!((o=(t=window==null?void 0:window.google)===null||t===void 0?void 0:t.maps)===null||o===void 0)&&o.importLibrary||(i=>{let a,m,v,h="The Google Maps JavaScript API",M="google",c="importLibrary",b="__ib__",p=document,d=window;d=d[M]||(d[M]={});const C=d.maps||(d.maps={}),D=new Set,U=new URLSearchParams,I=()=>a||(a=new Promise((q,Y)=>lt(this,void 0,void 0,function*(){var N;yield m=p.createElement("script"),m.id=this.id,U.set("libraries",[...D]+"");for(v in i)U.set(v.replace(/[A-Z]/g,B=>"_"+B[0].toLowerCase()),i[v]);U.set("callback",M+".maps."+b),m.src=this.url+"?"+U,C[b]=q,m.onerror=()=>a=Y(Error(h+" could not load.")),m.nonce=this.nonce||((N=p.querySelector("script[nonce]"))===null||N===void 0?void 0:N.nonce)||"",p.head.append(m)})));C[c]?console.warn(h+" only loads once. Ignoring:",i):C[c]=(q,...Y)=>D.add(q)&&I().then(()=>C[c](q,...Y))})(r);const l=this.libraries.map(i=>this.importLibrary(i));l.length||l.push(this.importLibrary("core")),Promise.all(l).then(()=>this.callback(),i=>{const a=new ErrorEvent("error",{error:i});this.loadErrorCallback(a)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(t){if(this.errors.push(t),this.errors.length<=this.retries){const o=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${o} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},o)}else this.onerrorEvent=t,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(t=>{t(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 pt=e=>{const{toCenter:t,mapRef:o}=e,{t:r}=H(),l=g.useRef(),[i,a]=g.useState([]);g.useEffect(()=>{google.maps.importLibrary("places").then(h=>{l.current=new h.AutocompleteService}).catch(()=>{w.message.error("Please configure the Google API Key correctly")})},[o]);const{run:m}=V.useDebounceFn(h=>{l.current&&l.current.getPlacePredictions({input:h||" "},(M,c)=>{if(c===google.maps.places.PlacesServiceStatus.OK)a(M.map(b=>{const p=b.structured_formatting;return J(F({},b),{label:`${p.main_text}${p.secondary_text?" "+p.secondary_text:""}`,value:b.place_id})}));else{a([]);return}})},{wait:300}),v=h=>{const M=i.find(b=>b.value===h);new google.maps.places.PlacesService(o.current).getDetails({placeId:M.place_id,fields:["geometry"]},(b,p)=>{p===google.maps.places.PlacesServiceStatus.OK&&t(b.geometry.location)})};return s.jsx("div",{className:n.css`
|
|
63
63
|
position: absolute;
|
|
64
64
|
top: 10px;
|
|
65
65
|
left: 10px;
|
|
66
66
|
z-index: 10;
|
|
67
67
|
width: calc(100% - 20px);
|
|
68
|
-
`,children:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),
|
|
68
|
+
`,children:s.jsx(w.Select,{id:"google-map-search",showSearch:!0,allowClear:!0,style:{background:"rgba(255, 255, 255, 0.8)"},placeholder:r("Enter keywords to search"),filterOption:!1,onSearch:m,onSelect:v,options:i})})},pe=e=>({url:e,scaledSize:{width:19,height:32},labelOrigin:new google.maps.Point(19/2,42)}),ut=()=>new Promise(e=>{const t=()=>{e({lat:37.4224764,lng:-122.0842499})};navigator.geolocation?navigator.geolocation.getCurrentPosition(o=>{const{latitude:r,longitude:l}=o.coords;e({lat:r,lng:l})},()=>{t()}):t()}),dt=e=>e==="point"?"marker":e==="lineString"?"polyline":e,ft={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"}},Se=g.forwardRef((e,t)=>{const{value:o,onChange:r,block:l=!1,readonly:i,disabled:a=l,zoom:m=13,overlayCommonOptions:v}=e,{accessKey:h}=Me(e.mapType)||{},{t:M}=H(),{getField:c}=n.useCollection_deprecated(),b=G.useFieldSchema(),p=g.useRef(),d=g.useRef(),C=g.useRef(),[D,U]=g.useState([]),[I,q]=g.useState(""),Y=n.useAPIClient(),{modal:N}=w.App.useApp();g.useEffect(()=>{d.current&&d.current.setZoom(m)},[m]);const B=g.useMemo(()=>{if(e.type)return e.type;const S=c(b==null?void 0:b.name);return S==null?void 0:S.interface},[e==null?void 0:e.type,b==null?void 0:b.name]),K=g.useRef(dt(B)),[te]=g.useState(F({strokeWeight:5,strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeOpacity:1,editable:!a,draggable:!a},v)),$=le.useNavigate(),oe=g.useRef(),re=g.useRef(new Set),Q=V.useMemoizedFn(S=>{if(re.current.forEach(u=>{re.current.delete(u)}),"getPath"in S){const u=S.getPath();["insert_at","remove_at","set_at"].forEach(f=>{re.current.add(u.addListener(f,()=>{x(S,!0)}).remove)})}else S instanceof google.maps.Circle&&["center_changed","radius_changed"].forEach(u=>{re.current.add(S.addListener(u,()=>{x(S,!0)}).remove)})}),ne=V.useMemoizedFn(()=>{var S;C.current&&(C.current.unbindAll(),C.current.setMap(null)),B!=="point"&&((S=p.current)==null||S.setDrawingMode(null))}),P=V.useMemoizedFn(S=>{d.current&&(d.current.setCenter(S),d.current.setZoom(m))}),W=V.useMemoizedFn(S=>{ne(),Q(S),C.current=S}),z=V.useMemoizedFn(S=>{const u=new google.maps.LatLngBounds;S.forEach(f=>{if(f instanceof google.maps.Marker)u.extend(f.getPosition());else if(f instanceof google.maps.Polyline||f instanceof google.maps.Polygon){const A=f.getPath();for(let k=0;k<A.getLength();k++)u.extend(A.getAt(k))}else f instanceof google.maps.Circle&&u.union(f.getBounds())}),d.current.setCenter(u.getCenter())}),X=()=>{C.current&&z([C.current])},x=V.useMemoizedFn((S,u=!1)=>{let f=null;if(B==="point"){const{lat:A,lng:k}=S.getPosition();f=[k(),A()]}else if(B==="polygon"||B==="lineString"){if(f=S.getPath().getArray().map(A=>[A.lng(),A.lat()]),f.length<2)return}else if(B==="circle"){const A=S.getCenter(),k=S.getRadius();f=[A.lng(),A.lat(),k]}u||W(S),r==null||r(f)}),L=V.useMemoizedFn((S=!1,u)=>{const f=J(F(F({},te),u),{map:d.current});return p.current=new google.maps.drawing.DrawingManager({drawingMode:K.current,drawingControl:!1,markerOptions:J(F({},f),{icon:pe(ue)}),polygonOptions:f,polylineOptions:f,circleOptions:f,map:d.current}),S||p.current.addListener("overlaycomplete",A=>{const k=A.overlay;x(k)}),p.current}),y=V.useMemoizedFn((S=B,u=o,f)=>{const A=ft[S];if(!A)return;const k=F(J(F({},te),{icon:pe(ue)}),f);return"transformOptions"in A?Object.assign(k,A.transformOptions(u)):"propertyKey"in A&&(k[A.propertyKey]=Array.isArray(u[0])?u.map(ie=>new google.maps.LatLng(ie[1],ie[0])):new google.maps.LatLng(u[1],u[0])),new google.maps[A.overlay](k)}),O=V.useMemoizedFn((S=B,u=o,f)=>d.current?y(S,u,J(F({},f),{map:d.current})):void 0);g.useEffect(()=>{var u,f;if(!o&&d.current&&(ne(),(f=(u=p==null?void 0:p.current)==null?void 0:u.setDrawingMode)==null||f.call(u,K.current),r==null||r(null)),!d.current||!o||!i&&C.current)return;const S=O();W(S),z([S])},[o,D,B,a,i,O,z,W]),g.useEffect(()=>{if(!h||d.current||!oe.current)return;let S;try{S=new ce({apiKey:h,version:"weekly",language:Y.auth.getLocale()})}catch(f){q(M("Load google maps failed, Please check the Api key and refresh the page"));return}const u=console.error;return console.error=(f,...A)=>{f!=null&&f.includes("InvalidKeyMapError")&&q(M("Load google maps failed, Please check the Api key and refresh the page")),u(f,...A)},Promise.all([S.importLibrary("drawing"),S.importLibrary("core"),S.importLibrary("geometry")]).then(f=>ye(this,null,function*(){const A=yield ut();d.current=new google.maps.Map(oe.current,{zoom:m,center:A,mapTypeId:google.maps.MapTypeId.ROADMAP,zoomControl:!1,streetViewControl:!1,panControl:!1,mapTypeControl:!1,fullscreenControl:!1}),q(""),U([])})).catch(f=>{if(f instanceof Error){q(f.message);return}}),()=>{var f,A;(f=d.current)==null||f.unbindAll(),d.current=null,(A=p.current)==null||A.unbindAll()}},[h,Y.auth,B,m]),g.useEffect(()=>{!d.current||!B||a||p.current||L()},[L,a,D,B]),g.useImperativeHandle(t,()=>({setOverlay:O,getOverlay:y,setFitView:z,createDraw:L,map:d.current,overlay:C.current,drawingManager:p.current,errMessage:I}));const _=V.useMemoizedFn(()=>{const S=()=>{ne(),p.current.setDrawingMode(K.current),r==null||r(null)};N.confirm({title:M("Clear the canvas"),content:M("Are you sure to clear the canvas?"),okText:M("Confirm"),cancelText:M("Cancel"),getContainer:()=>oe.current,onOk(){S()}})}),j=n.useApp();return!h||I?s.jsx(w.Alert,{action:s.jsx(w.Button,{type:"primary",onClick:()=>$(j.pluginSettingsManager.getRoutePath("map")+"?tab=google"),children:M("Go to the configuration page")}),message:I||M("Please configure the Api key first"),type:"error"}):s.jsxs("div",{className:n.css`
|
|
69
69
|
position: relative;
|
|
70
70
|
height: 500px;
|
|
71
71
|
`,children:[!d.current&&s.jsx("div",{className:n.css`
|
|
@@ -74,36 +74,36 @@
|
|
|
74
74
|
display: flex;
|
|
75
75
|
align-items: center;
|
|
76
76
|
justify-content: center;
|
|
77
|
-
`,children:s.jsx(w.Spin,{})}),
|
|
77
|
+
`,children:s.jsx(w.Spin,{})}),a?null:s.jsxs(s.Fragment,{children:[d.current&&s.jsx(pt,{toCenter:P,mapRef:d}),s.jsx("div",{className:n.css`
|
|
78
78
|
position: absolute;
|
|
79
79
|
bottom: 80px;
|
|
80
80
|
right: 20px;
|
|
81
81
|
z-index: 10;
|
|
82
|
-
`,children:s.jsx(w.Button,{onClick
|
|
82
|
+
`,children:s.jsx(w.Button,{onClick:X,disabled:!C.current,type:"primary",shape:"round",size:"large",icon:s.jsx(ee.SyncOutlined,{})})}),B==="lineString"||B==="polygon"?s.jsx("div",{className:n.css`
|
|
83
83
|
position: absolute;
|
|
84
84
|
bottom: 20px;
|
|
85
85
|
left: 10px;
|
|
86
86
|
z-index: 2;
|
|
87
87
|
pointer-events: none;
|
|
88
|
-
`,children:s.jsx(w.Alert,{message:
|
|
88
|
+
`,children:s.jsx(w.Alert,{message:M("Click to select the starting point and double-click to end the drawing"),type:"info"})}):null,s.jsx("div",{className:n.css`
|
|
89
89
|
position: absolute;
|
|
90
90
|
bottom: 20px;
|
|
91
91
|
right: 20px;
|
|
92
92
|
z-index: 2;
|
|
93
|
-
`,children:s.jsx(w.Button,{disabled:!
|
|
93
|
+
`,children:s.jsx(w.Button,{disabled:!o,style:{height:"40px"},onClick:_,type:"primary",danger:!0,children:M("Clear")})})]}),s.jsx("div",{ref:oe,className:n.css`
|
|
94
94
|
width: 100%;
|
|
95
95
|
height: 100%;
|
|
96
|
-
`,style:e==null?void 0:e.style})]})});
|
|
96
|
+
`,style:e==null?void 0:e.style})]})});Se.displayName="GoogleMapsComponent";const me="google-maps-overlay-id",Ke="google-maps-overlay-selected",mt=n.css`
|
|
97
97
|
margin-top: 6px;
|
|
98
98
|
padding: 2px 4px;
|
|
99
99
|
background: #fff;
|
|
100
100
|
border: 1px solid #0000f5;
|
|
101
|
-
`,
|
|
101
|
+
`,gt=n.css`
|
|
102
102
|
margin-top: -64px;
|
|
103
103
|
padding: 2px 4px;
|
|
104
104
|
background: #fff;
|
|
105
105
|
border: 1px solid #0000f5;
|
|
106
|
-
`,
|
|
106
|
+
`,ht=e=>{const{collectionField:t,fieldNames:o,dataSource:r,fixedBlock:l,zoom:i,setSelectedRecordKeys:a,lineSort:m}=n.useProps(e),{getPrimaryKey:v}=n.useCollection_deprecated(),h=v(),{marker:M="id"}=o,[c,b]=g.useState(!1),p=g.useRef(),[d,C]=g.useState(),[D,U]=g.useState(""),{t:I}=H(),q=n.useCompile(),{isConnected:Y,doFilter:N}=n.useFilterAPI(),[,B]=g.useState(null),K=g.useRef(D),te=g.useRef(null),$=g.useRef([]);K.current=D;const{getCollectionJoinField:oe}=n.useCollectionManager_deprecated(),re=(P,W)=>{const z=typeof W!="undefined"?!W:P.get(Ke);P.set(Ke,!z),P.setOptions(F({},z?{icon:pe(ue),strokeColor:"#4e9bff",fillColor:"#4e9bff"}:{icon:pe(be),strokeColor:"#F18b62",fillColor:"#F18b62"}))};g.useEffect(()=>{var W,z,X,x;if(D!=="selection")return;p.current&&!((W=p.current)!=null&&W.drawingManager)&&(p.current.drawingManager=(z=p.current)==null?void 0:z.createDraw(!0,{editable:!0,draggable:!0}));const P=new Set;return(X=p.current)==null||X.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON),(x=p.current)==null||x.drawingManager.addListener("overlaycomplete",L=>{var _;const y=L.overlay;(_=p.current)==null||_.drawingManager.setDrawingMode(null),te.current=y;const O=y.getPath();["insert_at","remove_at","set_at"].forEach(j=>{P.add(O.addListener(j,()=>{}).remove)})}),()=>{var L,y,O,_;P.forEach(j=>{j()}),p.current&&((L=te.current)==null||L.unbindAll(),(y=te.current)==null||y.setMap(null),te.current=null,(O=p.current)==null||O.drawingManager.setDrawingMode(null),(_=p.current)==null||_.drawingManager.unbindAll())}},[D]),g.useEffect(()=>{if(D)return()=>{K.current||$.current.forEach(P=>{re(P,!1)})}},[D]);const Q=V.useMemoizedFn(()=>{var L;const P=te.current,W=$.current,z=google.maps.geometry.poly,x=W.filter(y=>{if(!(y===P||y.get(me)===void 0))return y instanceof google.maps.Marker?z.containsLocation(y.getPosition(),P):y instanceof google.maps.Circle?z.containsLocation(y.getCenter(),P):y.getPath().getArray().some(O=>z.containsLocation(O,P))}).map(y=>(re(y,!0),y.get(me)));a(y=>x.concat(y)),P==null||P.unbindAll(),P==null||P.setMap(null),(L=p.current)==null||L.drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON)});g.useEffect(()=>{var x,L;if(!t||!(r!=null&&r.length)||!((x=p.current)!=null&&x.map))return;const P=Array.isArray(o==null?void 0:o.field)&&(o==null?void 0:o.field.length)>1?o==null?void 0:o.field.slice(0,-1):o==null?void 0:o.field,W=oe([name,...P].flat().join(".")),z=r.map(y=>{const O=Oe(y,o==null?void 0:o.field,W==null?void 0:W.interface);return O!=null&&O.length?O==null?void 0:O.filter(Boolean).map(_=>{var S;if(!O)return;const j=(S=p.current)==null?void 0:S.setOverlay(t.type,_,{strokeColor:"#4e9bff",fillColor:"#4e9bff",cursor:"pointer",label:{className:mt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:o!=null&&o.marker?q(y[M]):void 0}});return j==null||j.set(me,y[h]),j}):[]}).flat().filter(Boolean);$.current=z;const X=z.map(y=>{const O=_=>{const j=y,S=j.get(me);if(!S)return;const u=r==null?void 0:r.find(f=>S===f[h]);if(Y){B(f=>(f&&Ue(j),f===y?(Ue(j),N(null),null):(bt(j),N(u[h],A=>A.field||h,"$eq"),j)));return}u&&C(u)};return y.addListener("click",O),()=>y.unbindAll()});if(t.type==="point"&&(m!=null&&m.length)&&(z==null?void 0:z.length)>1){const y=z.map(_=>_.getPosition());z[0].setZIndex(138),z[z.length-1].setZIndex(138);const O=(_=!0)=>{var j;if((j=p.current)!=null&&j.map)return new google.maps.Marker({label:{className:gt,fontFamily:"inherit",fontSize:"13px",color:"#333",text:I(_?"Start point":"End point")},icon:pe(ue),position:_?y[0]:y[y.length-1],map:p.current.map})};z.push(...[p.current.setOverlay("lineString",y.map(_=>[_.lng(),_.lat()]),{strokeColor:"#4e9bff",fillColor:"#4e9bff",strokeWeight:2,cursor:"pointer"}),O(),O(!1)].filter(Boolean))}return(L=p.current)==null||L.setFitView(z),()=>{z.forEach(y=>{y.setMap(null),y.unbindAll()}),X.forEach(y=>y())}},[r,c,M,t.type,Y]),g.useEffect(()=>{setTimeout(()=>{a([])})},[r]);const ne=P=>{p.current=P,b(!!(P!=null&&P.map)&&!P.errMessage)};return s.jsxs("div",{className:n.css`
|
|
107
107
|
position: relative;
|
|
108
108
|
height: 100%;
|
|
109
109
|
`,children:[c&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:n.css`
|
|
@@ -111,10 +111,14 @@
|
|
|
111
111
|
left: 10px;
|
|
112
112
|
top: 10px;
|
|
113
113
|
z-index: 999;
|
|
114
|
-
`,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:
|
|
114
|
+
`,children:s.jsxs(w.Space,{direction:"vertical",children:[s.jsx(w.Button,{style:{color:D?void 0:"#F18b62",borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),U("")},icon:s.jsx(ee.EnvironmentOutlined,{})}),s.jsx(w.Button,{style:{color:D==="selection"?"#F18b62":void 0,borderColor:"currentcolor"},onClick:P=>{P.stopPropagation(),U("selection")},icon:s.jsx(ee.ExpandOutlined,{})}),D==="selection"?s.jsx(w.Button,{type:"primary",icon:s.jsx(ee.CheckOutlined,{}),title:I("Confirm selection"),onClick:Q}):null]})}),s.jsx(yt,{record:d,setVisible:C})]}),s.jsx(Se,J(F({},e),{ref:ne,style:{height:l?"100%":null},zoom:i,disabled:!0,block:!0,overlayCommonOptions:{strokeColor:"#F18b62",fillColor:"#F18b62"}}))]})},yt=e=>{const{setVisible:t,record:o}=e,{t:r}=H(),l=n.useCollection(),i=n.useCollectionParentRecordData(),a=G.useFieldSchema(),m=g.useMemo(()=>a.reduceProperties((v,h)=>h.name==="drawer"?h:v,null),[a]);return m&&s.jsx(n.ActionContextProvider,{value:{visible:!!o,setVisible:t},children:s.jsx(n.RecordProvider,{record:o,parent:i,children:s.jsx(n.DeclareVariable,{name:"$nPopupRecord",title:r("Current popup record"),value:o,collection:l,children:s.jsx(G.RecursionField,{schema:m,name:m.name})})})})};function Ue(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(ue));e.setOptions({strokeColor:"#4e9bff",fillColor:"#4e9bff"})}function bt(e){if(e instanceof google.maps.Marker)return e.setIcon(pe(be));e.setOptions({strokeColor:"#F18b62",fillColor:"#F18b62"})}const vt=()=>{var c;const{getCollectionJoinField:e}=n.useCollectionManager_deprecated(),{getField:t}=n.useCollection_deprecated(),{form:o}=n.useFormBlockContext(),r=G.useField(),l=G.useFieldSchema(),{t:i}=H(),{dn:a,refresh:m}=n.useDesignable(),v=t(l.name)||e(l["x-collection-field"]),h=(c=v==null?void 0:v.uiSchema)==null?void 0:c.title;r.title===h||r.title,r.readPretty||r.required;let M="editable";return l["x-disabled"]===!0&&(M="readonly"),l["x-read-pretty"]===!0&&(M="read-pretty"),s.jsxs(n.GeneralSchemaDesigner,{children:[s.jsx(n.GeneralSchemaItems,{}),o&&!(o!=null&&o.readPretty)&&!n.isPatternDisabled(l)&&s.jsx(n.SchemaSettingsSelectItem,{title:i("Pattern"),options:[{label:i("Editable"),value:"editable"},{label:i("Readonly"),value:"readonly"},{label:i("Easy-reading"),value:"read-pretty"}],value:M,onChange:b=>{const p={"x-uid":l["x-uid"]};switch(b){case"readonly":{l["x-read-pretty"]=!1,l["x-disabled"]=!0,p["x-read-pretty"]=!1,p["x-disabled"]=!0,r.readPretty=!1,r.disabled=!0;break}case"read-pretty":{l["x-read-pretty"]=!0,l["x-disabled"]=!1,p["x-read-pretty"]=!0,p["x-disabled"]=!1,r.readPretty=!0;break}default:{l["x-read-pretty"]=!1,l["x-disabled"]=!1,p["x-read-pretty"]=!1,p["x-disabled"]=!1,r.readPretty=!1,r.disabled=!1;break}}a.emit("patch",{schema:p}),a.refresh()}},"pattern"),s.jsx(n.SchemaSettingsModalItem,{title:i("Set default zoom level"),schema:{type:"object",title:i("Set default zoom level"),properties:{zoom:{title:i("Zoom"),default:r.componentProps.zoom||13,description:i("The default zoom level of the map"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{precision:0}}}},onSubmit:({zoom:b})=>{b&&(ke.set(l,"x-component-props.zoom",b),Object.assign(r.componentProps,l["x-component-props"]),a.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":r.componentProps}})),a.refresh()}},"map-zoom"),s.jsx(n.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,confirm:{title:i("Delete field")},breakRemoveOn:{"x-component":"Grid"}},"remove")]})},Mt={amap:Ce,google:Se},xe=g.forwardRef((e,t)=>{const{t:o}=H(),{mapType:r}=e,l=g.useMemo(()=>Mt[r],[r]);return l?s.jsx(l,F({ref:t},e)):s.jsx("div",{children:o(`The ${r} cannot found`)})});xe.displayName="MapComponent";const At=e=>{var m,v;const{value:t}=e,o=G.useFieldSchema(),{getField:r}=n.useCollection_deprecated(),l=r(o.name),i=e.mapType||((m=l==null?void 0:l.uiSchema["x-component-props"])==null?void 0:m.mapType),a=G.useForm();return n.useFieldTitle(),a.readPretty?s.jsx(xe,F({readonly:!0,mapType:i},e)):s.jsx("div",{children:s.jsx(n.EllipsisWithTooltip,{ellipsis:!0,children:(v=t==null?void 0:t.map)==null?void 0:v.call(t,h=>Array.isArray(h)?`(${h.join(",")})`:h).join(",")})})},Ne=G.connect(e=>s.jsx("div",{className:n.css`
|
|
115
115
|
height: 100%;
|
|
116
116
|
border: 1px solid transparent;
|
|
117
117
|
.ant-formily-item-error & {
|
|
118
118
|
border: 1px solid #ff4d4f;
|
|
119
119
|
}
|
|
120
|
-
`,children:s.jsx(Se,O({},e))}),G.mapReadPretty(yt));Ue.Designer=gt;const bt={amap:$e,google:dt},vt=e=>{const{t:o}=J(),{mapType:t}=e,r=h.useMemo(()=>bt[t],[t]);return r?s.jsx(r,O({},e)):s.jsx("div",{children:o(`The ${t} cannot found`)})},At=n.withDynamicSchemaProps(e=>{var l;const{fieldNames:o}=n.useProps(e),{getCollectionJoinField:t}=n.useCollectionManager_deprecated(),{name:r}=n.useCollection_deprecated(),a=h.useMemo(()=>t([r,o==null?void 0:o.field].flat().join(".")),[r,o==null?void 0:o.field]),i=(l=a==null?void 0:a.uiSchema)==null?void 0:l["x-component-props"];return s.jsx(vt,X(O(O({},i),e),{collectionField:a}))}),Ct=()=>{const{name:e,title:o}=n.useCollection(),t=n.useSchemaTemplate();return s.jsx(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:t,title:o||e})},Ne=(e,o=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((t,r,a)=>{const i=t==null?void 0:t.find(l=>l.value===r);return a===e.length-1?i:i==null?void 0:i.children},o)),Mt=e=>{const{collectionName:o,fieldNames:t,dataSource:r}=e;return{type:"void","x-acl-action":`${o}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:o,dataSource:r,action:"list",fieldNames:t,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}}},[Ye.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},xt=()=>{const e=n.useSchemaInitializerItem(),{insert:o}=n.useSchemaInitializer(),t=h.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=n.useCollectionManager_deprecated(),{t:a}=J(),{theme:i}=n.useGlobalTheme();return s.jsx(n.DataBlockInitializer,O({componentType:"Map",icon:s.jsx(R.TableOutlined,{}),onCreateBlockSchema:m=>ye(this,[m],function*({item:l}){const v=r(l.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:l.dataSource}),A=r(l.name,"string",{dataSource:l.dataSource}),C=yield n.FormDialog(a("Create map block"),()=>{var c;return s.jsx(n.SchemaComponentOptions,{scope:t.scope,components:O({},t.components),children:s.jsx(We.FormLayout,{layout:"vertical",children:s.jsx(n.SchemaComponent,{schema:{properties:{field:{title:a("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(b=>b!=null):[]},marker:{title:a("Marker field"),enum:A,"x-component":"Select","x-decorator":"FormItem","x-reactions":b=>{const u=b.form.values.field;if(!(u!=null&&u.length))return;const d=Ne(u,v);d&&(b.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});o(Mt({collectionName:l.name,dataSource:l.dataSource,fieldNames:O({},C)}))}),title:a("Map block")},e))},we=h.createContext({});we.displayName="MapBlockContext";const St=e=>{var v;const{fieldNames:o}=e,t=G.useFieldSchema(),r=G.useField(),{resource:a,service:i}=n.useBlockRequestContext(),[l,m]=h.useState([]);return s.jsx(n.FixedBlockWrapper,{children:s.jsx(n.SchemaComponentOptions,{scope:{selectedRecordKeys:l},children:s.jsx(we.Provider,{value:{field:r,service:i,resource:a,fieldNames:o,fixedBlock:(v=t==null?void 0:t["x-decorator-props"])==null?void 0:v.fixedBlock,selectedRecordKeys:l,setSelectedRecordKeys:m},children:e.children})})})},wt=e=>{const o=G.useField(),{params:t,fieldNames:r}=e,a=t.appends||[],{field:i}=r||{};return Array.isArray(i)&&i.length>1&&a.push(i[0]),s.jsx(n.BlockProvider,X(O({name:"map"},e),{runWhenParamsChanged:!0,params:X(O({},t),{appends:a,paginate:!1,sort:o.componentProps.lineSort}),children:s.jsx(St,O({},e))}))},ge=()=>h.useContext(we),Ge=()=>{var o,t,r,a,i,l;const e=ge();return X(O({},e),{dataSource:(t=(o=e==null?void 0:e.service)==null?void 0:o.data)==null?void 0:t.data,zoom:((a=(r=e==null?void 0:e.field)==null?void 0:r.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=>s.jsx(n.SchemaComponentOptions,{scope:{useMapBlockProps:Ge},components:{MapBlockInitializer:xt,MapBlockDesigner:Ct,MapBlockProvider:wt,MapBlock:At},children:e.children}),qe=new n.CompatibleSchemaInitializer({name:"MapActionInitializers",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]}),Pt=new n.CompatibleSchemaInitializer({name:"map:configureActions",title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:"{{t('Enable actions')}}",name:"enableActions",children:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},{name:"divider",type:"divider",useVisible(){return n.useCollection_deprecated().template!=="sql"}},{type:"subMenu",title:'{{t("Customize")}}',name:"customize",children:[],useVisible(){return n.useCollection_deprecated().template!=="sql"}}]},qe),kt=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"fixBlock",Component:n.FixedBlockDesignerItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps(){var A;const{getCollectionFieldsOptions:e}=n.useCollectionManager_deprecated(),{t:o}=J(),t=G.useFieldSchema(),r=((A=t==null?void 0:t["x-decorator-props"])==null?void 0:A.fieldNames)||{},a=G.useField(),{dn:i}=n.useDesignable(),{service:l}=ge(),{name:m}=n.useCollection(),v=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:o("Map field"),value:r.field,options:v,allowClear:!1,onChange:C=>{const c=a.decoratorProps.fieldNames||{};c.field=C,a.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,l.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:n.SchemaSettingsSelectItem,useComponentProps(){var A;const{t:e}=J(),o=G.useFieldSchema(),t=((A=o==null?void 0:o["x-decorator-props"])==null?void 0:A.fieldNames)||{},{service:r}=ge(),a=G.useField(),{dn:i}=n.useDesignable(),{getCollectionFieldsOptions:l}=n.useCollectionManager_deprecated(),{name:m}=n.useCollection(),v=l(m,"string");return{title:e("Marker field"),value:t.marker,options:v,onChange:C=>{const c=a.decoratorProps.fieldNames||{};c.marker=C,a.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":a.decoratorProps}}),i.refresh()}}},useVisible(){var l,m;const e=G.useFieldSchema(),{getCollectionFieldsOptions:o}=n.useCollectionManager_deprecated(),{name:t}=n.useCollection(),r=((l=e==null?void 0:e["x-decorator-props"])==null?void 0:l.fieldNames)||{},a=o(t,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ne(r.field,a))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=J();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,{name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=J(),o=G.useFieldSchema(),t=G.useField(),{dn:r}=n.useDesignable(),a=((i=o==null?void 0:o["x-component-props"])==null?void 0:i.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:a,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:l})=>{ke.set(o,"x-component-props.zoom",l),Object.assign(t.componentProps,o["x-component-props"]),r.emit("patch",{schema:{"x-uid":o["x-uid"],"x-component-props":t.componentProps}}),r.refresh()}}}},{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps(){var l,m;const{name:e}=n.useCollection(),o=G.useFieldSchema(),{form:t}=n.useFormBlockContext(),r=G.useField(),{service:a}=ge(),{dn:i}=n.useDesignable();return{collectionName:e,defaultFilter:((m=(l=o==null?void 0:o["x-decorator-props"])==null?void 0:l.params)==null?void 0:m.filter)||{},form:t,onSubmit:({filter:v})=>{var C,c;const A=r.decoratorProps.params||{};A.filter=v,r.decoratorProps.params=A,o["x-decorator-props"].params=A,(c=(C=a.params)==null?void 0:C[1])!=null&&c.filters,i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":o["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:n.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=J();return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps(){var r,a;const{name:e}=n.useCollection(),o=G.useFieldSchema(),t=((r=o==null?void 0:o["x-decorator-props"])==null?void 0:r.resource)||((a=o==null?void 0:o["x-decorator-props"])==null?void 0:a.association);return{componentName:"Map",collectionName:e,resourceName:t}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Ft}=n.interfacesProperties;Array.isArray(n.interfacesProperties.type.enum)&&n.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class he extends n.CollectionFieldInterface{constructor(){super(...arguments);F(this,"properties",X(O({},Ft),{"uiSchema.x-component-props.mapType":{title:Q("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:Fe}}))}schemaInitialize(t,{block:r}){r==="Form"&&Object.assign(t,{"x-designer":"Map.Designer"})}}class Ot extends he{constructor(){super(...arguments);F(this,"name","circle");F(this,"type","object");F(this,"group","map");F(this,"order",3);F(this,"title",Q("Circle"));F(this,"availableTypes",["circle"]);F(this,"description",Q("Circle"));F(this,"sortable",!0);F(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Et extends he{constructor(){super(...arguments);F(this,"name","lineString");F(this,"type","object");F(this,"group","map");F(this,"order",2);F(this,"title",Q("Line"));F(this,"description",Q("Line"));F(this,"availableTypes",["lineString"]);F(this,"sortable",!0);F(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class zt extends he{constructor(){super(...arguments);F(this,"name","point");F(this,"type","object");F(this,"group","map");F(this,"order",1);F(this,"title",Q("Point"));F(this,"description",Q("Point"));F(this,"availableTypes",["point"]);F(this,"sortable",!0);F(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Lt extends he{constructor(){super(...arguments);F(this,"name","polygon");F(this,"type","object");F(this,"group","map");F(this,"order",4);F(this,"title",Q("Polygon"));F(this,"description",Q("Polygon"));F(this,"availableTypes",["polygon"]);F(this,"sortable",!0);F(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Dt=[zt,Lt,Et,Ot],_e=h.memo(e=>s.jsx(n.SchemaComponentOptions,{components:{Map:Ue},children:s.jsx(It,{children:e.children})}));_e.displayName="MapProvider";class je extends n.Plugin{load(){return ye(this,null,function*(){this.app.use(_e),this.app.dataSourceManager.addFieldInterfaces(Dt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:Q("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(qe),this.app.schemaInitializerManager.add(Pt),this.schemaSettingsManager.add(kt);const o=this.app.schemaInitializerManager.get("page:addBlock");o==null||o.add("dataBlocks.map",{title:Q("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:rt,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:Ge})})}}D.PluginMapClient=je,D.default=je,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
120
|
+
`,children:s.jsx(xe,F({},e))}),G.mapReadPretty(At));Ne.Designer=vt;const Ct={amap:ot,google:ht},St=e=>{const{t}=H(),{mapType:o}=e,r=g.useMemo(()=>Ct[o],[o]);return r?s.jsx(r,F({},e)):s.jsx("div",{children:t(`The ${o} cannot found`)})},xt=n.withDynamicSchemaProps(e=>{var a;const{fieldNames:t}=n.useProps(e),{getCollectionJoinField:o}=n.useCollectionManager_deprecated(),{name:r}=n.useCollection_deprecated(),l=g.useMemo(()=>o([r,t==null?void 0:t.field].flat().join(".")),[r,t==null?void 0:t.field]),i=(a=l==null?void 0:l.uiSchema)==null?void 0:a["x-component-props"];return s.jsx(St,J(F(F({},i),e),{collectionField:l}))}),wt=()=>{const{name:e,title:t}=n.useCollection(),o=n.useSchemaTemplate();return s.jsx(n.GeneralSchemaDesigner,{schemaSettings:"blockSettings:map",template:o,title:t||e})},Ge=(e,t=[])=>(typeof e=="string"&&(e=[e]),e==null?void 0:e.reduce((o,r,l)=>{const i=o==null?void 0:o.find(a=>a.value===r);return l===e.length-1?i:i==null?void 0:i.children},t)),It=e=>{const{collectionName:t,fieldNames:o,dataSource:r}=e;return{type:"void","x-acl-action":`${t}:list`,"x-decorator":"MapBlockProvider","x-decorator-props":{collection:t,dataSource:r,action:"list",fieldNames:o,params:{paginate:!1}},"x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:map","x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-initializer":"map:configureActions","x-component":"ActionBar","x-component-props":{}},[Ze.uid()]:{type:"void","x-component":"MapBlock","x-use-component-props":"useMapBlockProps",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-component-props":{className:"nb-action-popup"},title:'{{ t("View record") }}',properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:'{{t("Details")}}',"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}},Pt=()=>{const e=n.useSchemaInitializerItem(),{insert:t}=n.useSchemaInitializer(),o=g.useContext(G.SchemaOptionsContext),{getCollectionFieldsOptions:r}=n.useCollectionManager_deprecated(),{t:l}=H(),{theme:i}=n.useGlobalTheme();return s.jsx(n.DataBlockInitializer,F({componentType:"Map",icon:s.jsx(ee.TableOutlined,{}),onCreateBlockSchema:m=>ye(this,[m],function*({item:a}){const v=r(a.name,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"],dataSource:a.dataSource}),h=r(a.name,"string",{dataSource:a.dataSource}),M=yield n.FormDialog(l("Create map block"),()=>{var c;return s.jsx(n.SchemaComponentOptions,{scope:o.scope,components:F({},o.components),children:s.jsx(Je.FormLayout,{layout:"vertical",children:s.jsx(n.SchemaComponent,{schema:{properties:{field:{title:l("Map field"),enum:v,required:!0,"x-component":"Cascader","x-decorator":"FormItem",default:v.length?[v[0].value,(c=v[0].children)==null?void 0:c[0].value].filter(b=>b!=null):[]},marker:{title:l("Marker field"),enum:h,"x-component":"Select","x-decorator":"FormItem","x-reactions":b=>{const p=b.form.values.field;if(!(p!=null&&p.length))return;const d=Ge(p,v);d&&(b.hidden=d.type!=="point")}}}}})})})},i).open({initialValues:{}});t(It({collectionName:a.name,dataSource:a.dataSource,fieldNames:F({},M)}))}),title:l("Map block")},e))},we=g.createContext({});we.displayName="MapBlockContext";const kt=e=>{var h;const{fieldNames:t}=e,o=G.useFieldSchema(),r=G.useField(),{resource:l,service:i}=n.useBlockRequestContext(),[a,m]=g.useState([]),{token:v}=w.theme.useToken();return s.jsx(n.FixedBlockWrapper,{children:s.jsx(n.SchemaComponentOptions,{scope:{selectedRecordKeys:a},children:s.jsxs(we.Provider,{value:{field:r,service:i,resource:l,fieldNames:t,fixedBlock:(h=o==null?void 0:o["x-decorator-props"])==null?void 0:h.fixedBlock,selectedRecordKeys:a,setSelectedRecordKeys:m},children:[" ",s.jsx("div",{className:Xe.css`
|
|
121
|
+
.nb-action-bar {
|
|
122
|
+
margin-bottom: ${v.margin}px;
|
|
123
|
+
}
|
|
124
|
+
`,children:e.children})]})})})},Ft=e=>{const{filter:t,parseVariableLoading:o}=n.useParsedFilter({filterOption:e==null?void 0:e.filter});return{params:J(F({},e),{filter:t}),parseVariableLoading:o}},Ot=e=>{const t=G.useField(),{fieldNames:o}=e,{params:r,parseVariableLoading:l}=Ft(e.params);if(l)return null;const i=r.appends||[],{field:a}=o||{};return Array.isArray(a)&&a.length>1&&i.push(a[0]),s.jsx(n.BlockProvider,J(F({name:"map"},e),{runWhenParamsChanged:!0,params:J(F({},r),{appends:i,paginate:!1,sort:t.componentProps.lineSort}),children:s.jsx(kt,F({},e))}))},ge=()=>g.useContext(we),qe=()=>{var t,o,r,l,i,a;const e=ge();return J(F({},e),{dataSource:(o=(t=e==null?void 0:e.service)==null?void 0:t.data)==null?void 0:o.data,zoom:((l=(r=e==null?void 0:e.field)==null?void 0:r.componentProps)==null?void 0:l.zoom)||13,lineSort:(a=(i=e==null?void 0:e.field)==null?void 0:i.componentProps)==null?void 0:a.lineSort})},Et=e=>s.jsx(n.SchemaComponentOptions,{scope:{useMapBlockProps:qe},components:{MapBlockInitializer:Pt,MapBlockDesigner:wt,MapBlockProvider:Ot,MapBlock:xt},children:e.children}),je={title:"{{t('Configure actions')}}",icon:"SettingOutlined",style:{marginLeft:8},items:[{name:"filter",title:"{{t('Filter')}}",Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"addNew",title:"{{t('Add new')}}",Component:"CreateActionInitializer",schema:{"x-align":"right","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0}},useVisible(){return n.useCollection_deprecated().template!=="sql"}},{name:"refresh",title:"{{t('Refresh')}}",Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]},_e=new n.CompatibleSchemaInitializer(F({name:"MapActionInitializers"},je)),Lt=new n.CompatibleSchemaInitializer(F({name:"map:configureActions"},je),_e),Ve={name:"defaultZoomLevel",Component:n.SchemaSettingsModalItem,useComponentProps(){var i;const{t:e}=H(),t=G.useFieldSchema(),o=G.useField(),{dn:r}=n.useDesignable(),l=((i=t==null?void 0:t["x-component-props"])==null?void 0:i.zoom)||13;return{title:e("The default zoom level of the map"),schema:{type:"object",title:e("Set default zoom level"),properties:{zoom:{title:e("Zoom"),default:l,"x-component":"InputNumber","x-decorator":"FormItem","x-component-props":{precision:0}}}},onSubmit:({zoom:a})=>{ke.set(t,"x-component-props.zoom",a),o.componentProps.zoom=a,r.emit("patch",{schema:{"x-uid":t["x-uid"],"x-component-props":t["x-component-props"]}}),r.refresh()}}}},Tt=new n.SchemaSettings({name:"blockSettings:map",items:[{name:"title",Component:n.SchemaSettingsBlockTitleItem},{name:"setTheBlockHeight",Component:n.SchemaSettingsBlockHeightItem},{name:"mapField",Component:n.SchemaSettingsCascaderItem,useComponentProps(){var h;const{getCollectionFieldsOptions:e}=n.useCollectionManager_deprecated(),{t}=H(),o=G.useFieldSchema(),r=((h=o==null?void 0:o["x-decorator-props"])==null?void 0:h.fieldNames)||{},l=G.useField(),{dn:i}=n.useDesignable(),{service:a}=ge(),{name:m}=n.useCollection(),v=e(m,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return{title:t("Map field"),value:r.field,options:v,allowClear:!1,onChange:M=>{const c=l.decoratorProps.fieldNames||{};c.field=M,l.decoratorProps.fieldNames=c,o["x-decorator-props"].fieldNames=c,a.refresh(),i.emit("patch",{schema:{"x-uid":o["x-uid"],"x-decorator-props":l.decoratorProps}}),i.refresh()}}}},{name:"markerField",Component:n.SchemaSettingsSelectItem,useComponentProps(){var h;const{t:e}=H(),t=G.useFieldSchema(),o=((h=t==null?void 0:t["x-decorator-props"])==null?void 0:h.fieldNames)||{},{service:r}=ge(),l=G.useField(),{dn:i}=n.useDesignable(),{getCollectionFieldsOptions:a}=n.useCollectionManager_deprecated(),{name:m}=n.useCollection(),v=a(m,"string");return{title:e("Marker field"),value:o.marker,options:v,onChange:M=>{const c=l.decoratorProps.fieldNames||{};c.marker=M,l.decoratorProps.fieldNames=c,t["x-decorator-props"].fieldNames=c,r.refresh(),i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":l.decoratorProps}}),i.refresh()}}},useVisible(){var a,m;const e=G.useFieldSchema(),{getCollectionFieldsOptions:t}=n.useCollectionManager_deprecated(),{name:o}=n.useCollection(),r=((a=e==null?void 0:e["x-decorator-props"])==null?void 0:a.fieldNames)||{},l=t(o,["point","lineString","polygon"],{association:["o2o","obo","oho","o2m","m2o","m2m"]});return((m=Ge(r.field,l))==null?void 0:m.type)==="point"}},{name:"setDefaultSortingRules",Component:n.SchemaSettingsDefaultSortingRules,useComponentProps(){const{t:e}=H();return{path:"x-component-props.lineSort",title:e("Concatenation order field")}}},n.setDataLoadingModeSettingsItem,Ve,{name:"dataScope",Component:n.SchemaSettingsDataScope,useComponentProps(){var a,m;const{name:e}=n.useCollection(),t=G.useFieldSchema(),{form:o}=n.useFormBlockContext(),r=G.useField(),{service:l}=ge(),{dn:i}=n.useDesignable();return{collectionName:e,defaultFilter:((m=(a=t==null?void 0:t["x-decorator-props"])==null?void 0:a.params)==null?void 0:m.filter)||{},form:o,onSubmit:({filter:v})=>{var M,c;const h=r.decoratorProps.params||{};h.filter=v,r.decoratorProps.params=h,t["x-decorator-props"].params=h,(c=(M=l.params)==null?void 0:M[1])!=null&&c.filters,i.emit("patch",{schema:{"x-uid":t["x-uid"],"x-decorator-props":t["x-decorator-props"]}})}}}},{name:"ConnectDataBlocks",Component:n.SchemaSettingsConnectDataBlocks,useComponentProps(){const{t:e}=H();return{type:n.FilterBlockType.TABLE,emptyDescription:e("No blocks to connect")}}},{name:"divider",type:"divider"},{name:"template",Component:n.SchemaSettingsTemplate,useComponentProps(){var r,l;const{name:e}=n.useCollection(),t=G.useFieldSchema(),o=((r=t==null?void 0:t["x-decorator-props"])==null?void 0:r.resource)||((l=t==null?void 0:t["x-decorator-props"])==null?void 0:l.association);return{componentName:"Map",collectionName:e,resourceName:o}}},{name:"divider2",type:"divider"},{name:"remove",type:"remove",componentProps:{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}]}),{defaultProps:Dt}=n.interfacesProperties;Array.isArray(n.interfacesProperties.type.enum)&&n.interfacesProperties.type.enum.push({label:"Point",value:"point"},{label:"LineString",value:"lineString"},{label:"Polygon",value:"polygon"},{label:"Circle",value:"circle"});class he extends n.CollectionFieldInterface{constructor(){super(...arguments);E(this,"properties",J(F({},Dt),{"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:Fe}}))}schemaInitialize(o,{block:r}){r==="Form"&&Object.assign(o,{"x-designer":"Map.Designer"})}}class zt extends he{constructor(){super(...arguments);E(this,"name","circle");E(this,"type","object");E(this,"group","map");E(this,"order",3);E(this,"title",R("Circle"));E(this,"availableTypes",["circle"]);E(this,"description",R("Circle"));E(this,"sortable",!0);E(this,"default",{type:"circle",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Bt extends he{constructor(){super(...arguments);E(this,"name","lineString");E(this,"type","object");E(this,"group","map");E(this,"order",2);E(this,"title",R("Line"));E(this,"description",R("Line"));E(this,"availableTypes",["lineString"]);E(this,"sortable",!0);E(this,"default",{type:"lineString",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Kt extends he{constructor(){super(...arguments);E(this,"name","point");E(this,"type","object");E(this,"group","map");E(this,"order",1);E(this,"title",R("Point"));E(this,"description",R("Point"));E(this,"availableTypes",["point"]);E(this,"sortable",!0);E(this,"default",{type:"point",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}class Ut extends he{constructor(){super(...arguments);E(this,"name","polygon");E(this,"type","object");E(this,"group","map");E(this,"order",4);E(this,"title",R("Polygon"));E(this,"description",R("Polygon"));E(this,"availableTypes",["polygon"]);E(this,"sortable",!0);E(this,"default",{type:"polygon",uiSchema:{type:"void","x-component":"Map","x-component-designer":"Map.Designer","x-component-props":{}}})}}const Nt=[Kt,Ut,Bt,zt],Gt=new n.SchemaSettings({name:"fieldSettings:component:Map",items:[Ve]}),We=g.memo(e=>s.jsx(n.SchemaComponentOptions,{components:{Map:Ne},children:s.jsx(Et,{children:e.children})}));We.displayName="MapProvider";class Ye extends n.Plugin{load(){return ye(this,null,function*(){this.app.use(We),this.app.dataSourceManager.addFieldInterfaces(Nt),this.app.dataSourceManager.addFieldInterfaceGroups({map:{label:R("Map-based geometry"),order:51}}),this.app.schemaInitializerManager.add(_e),this.app.schemaInitializerManager.add(Lt),this.schemaSettingsManager.add(Tt),this.schemaSettingsManager.add(Gt);const t=this.app.schemaInitializerManager.get("page:addBlock");t==null||t.add("dataBlocks.map",{title:R("Map"),Component:"MapBlockInitializer"}),this.app.pluginSettingsManager.add(fe,{title:`{{t("Map Manager", { ns: "${fe}" })}}`,icon:"EnvironmentOutlined",Component:at,aclSnippet:"pm.map.configuration"}),this.app.addScopes({useMapBlockProps:qe})})}}T.PluginMapClient=Ye,T.default=Ye,Object.defineProperties(T,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "1.0.
|
|
11
|
+
"@nocobase/client": "1.0.1-alpha.1",
|
|
12
12
|
"react": "18.2.0",
|
|
13
|
-
"@nocobase/server": "1.0.
|
|
14
|
-
"@nocobase/test": "1.0.
|
|
13
|
+
"@nocobase/server": "1.0.1-alpha.1",
|
|
14
|
+
"@nocobase/test": "1.0.1-alpha.1",
|
|
15
15
|
"@formily/react": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@ant-design/icons": "5.2.6",
|
|
18
18
|
"@formily/antd-v5": "1.1.9",
|
|
19
|
+
"@emotion/css": "11.11.2",
|
|
20
|
+
"antd": "5.12.8",
|
|
19
21
|
"@formily/shared": "2.3.0",
|
|
20
22
|
"ahooks": "3.7.8",
|
|
21
|
-
"antd": "5.12.8",
|
|
22
23
|
"react-router-dom": "6.21.0",
|
|
23
24
|
"@formily/core": "2.3.0",
|
|
24
25
|
"react-i18next": "11.18.6",
|
|
25
|
-
"@nocobase/actions": "1.0.
|
|
26
|
-
"@nocobase/database": "1.0.
|
|
26
|
+
"@nocobase/actions": "1.0.1-alpha.1",
|
|
27
|
+
"@nocobase/database": "1.0.1-alpha.1"
|
|
27
28
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseInterface } from '@nocobase/database';
|
|
10
|
+
export declare class PointInterface extends BaseInterface {
|
|
11
|
+
toValue(str: any, ctx?: any): Promise<any>;
|
|
12
|
+
toString(value: any, ctx?: any): any;
|
|
13
|
+
}
|
|
14
|
+
export declare class PolygonInterface extends BaseInterface {
|
|
15
|
+
toValue(str: any, ctx?: any): Promise<any>;
|
|
16
|
+
toString(value: any, ctx?: any): string;
|
|
17
|
+
}
|
|
18
|
+
export declare class LineStringInterface extends PolygonInterface {
|
|
19
|
+
}
|
|
20
|
+
export declare class CircleInterface extends BaseInterface {
|
|
21
|
+
toValue(str: any, ctx?: any): Promise<any>;
|
|
22
|
+
toString(value: any, ctx?: any): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var interfaces_exports = {};
|
|
28
|
+
__export(interfaces_exports, {
|
|
29
|
+
CircleInterface: () => CircleInterface,
|
|
30
|
+
LineStringInterface: () => LineStringInterface,
|
|
31
|
+
PointInterface: () => PointInterface,
|
|
32
|
+
PolygonInterface: () => PolygonInterface
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
35
|
+
var import_database = require("@nocobase/database");
|
|
36
|
+
class PointInterface extends import_database.BaseInterface {
|
|
37
|
+
async toValue(str, ctx) {
|
|
38
|
+
if (!str)
|
|
39
|
+
return null;
|
|
40
|
+
return str.split(",").map((v) => parseFloat(v));
|
|
41
|
+
}
|
|
42
|
+
toString(value, ctx) {
|
|
43
|
+
if (!value)
|
|
44
|
+
return null;
|
|
45
|
+
return value.join(",");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class PolygonInterface extends import_database.BaseInterface {
|
|
49
|
+
async toValue(str, ctx) {
|
|
50
|
+
if (!str)
|
|
51
|
+
return null;
|
|
52
|
+
return str.substring(1, str.length - 1).split("),(").map((v) => v.split(",").map((v2) => parseFloat(v2)));
|
|
53
|
+
}
|
|
54
|
+
toString(value, ctx) {
|
|
55
|
+
if (!value)
|
|
56
|
+
return null;
|
|
57
|
+
return `(${value.map((v) => v.join(",")).join("),(")})`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class LineStringInterface extends PolygonInterface {
|
|
61
|
+
}
|
|
62
|
+
class CircleInterface extends import_database.BaseInterface {
|
|
63
|
+
async toValue(str, ctx) {
|
|
64
|
+
if (!str)
|
|
65
|
+
return null;
|
|
66
|
+
return str.split(",").map((v) => parseFloat(v));
|
|
67
|
+
}
|
|
68
|
+
toString(value, ctx) {
|
|
69
|
+
if (!value)
|
|
70
|
+
return null;
|
|
71
|
+
return value.join(",");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
CircleInterface,
|
|
77
|
+
LineStringInterface,
|
|
78
|
+
PointInterface,
|
|
79
|
+
PolygonInterface
|
|
80
|
+
});
|
package/dist/server/plugin.js
CHANGED
|
@@ -45,6 +45,7 @@ var import_path = __toESM(require("path"));
|
|
|
45
45
|
var import_actions = require("./actions");
|
|
46
46
|
var import_fields = require("./fields");
|
|
47
47
|
var import_value_parsers = require("./value-parsers");
|
|
48
|
+
var import_interfaces = require("./interfaces");
|
|
48
49
|
class PluginMapServer extends import_server.Plugin {
|
|
49
50
|
afterAdd() {
|
|
50
51
|
}
|
|
@@ -62,6 +63,10 @@ class PluginMapServer extends import_server.Plugin {
|
|
|
62
63
|
lineString: import_value_parsers.LineStringValueParser,
|
|
63
64
|
circle: import_value_parsers.CircleValueParser
|
|
64
65
|
});
|
|
66
|
+
this.db.interfaceManager.registerInterfaceType("point", import_interfaces.PointInterface);
|
|
67
|
+
this.db.interfaceManager.registerInterfaceType("polygon", import_interfaces.PolygonInterface);
|
|
68
|
+
this.db.interfaceManager.registerInterfaceType("lineString", import_interfaces.LineStringInterface);
|
|
69
|
+
this.db.interfaceManager.registerInterfaceType("circle", import_interfaces.CircleInterface);
|
|
65
70
|
}
|
|
66
71
|
async load() {
|
|
67
72
|
await this.importCollections(import_path.default.resolve(__dirname, "collections"));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Block: Map",
|
|
4
4
|
"displayName.zh-CN": "区块:地图",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.1-alpha.1",
|
|
6
6
|
"description": "Map block, support Gaode map and Google map, you can also extend more map types.",
|
|
7
7
|
"description.zh-CN": "地图区块,支持高德地图和 Google 地图,你也可以扩展更多地图类型。",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@nocobase/test": "1.x",
|
|
37
37
|
"@nocobase/utils": "1.x"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "d24aa16987a4068f857ae073fcce18f3cb490660",
|
|
40
40
|
"keywords": [
|
|
41
41
|
"Blocks"
|
|
42
42
|
]
|