@nocobase/plugin-map 0.9.4-alpha.2 → 0.10.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/block/MapBlock.d.ts +2 -1
- package/lib/client/block/MapBlock.js +1 -1
- package/lib/client/block/MapBlockDesigner.d.ts +2 -1
- package/lib/client/block/MapBlockInitializer.d.ts +2 -1
- package/lib/client/block/MapBlockProvider.d.ts +1 -1
- package/lib/client/block/utils.d.ts +1 -0
- package/lib/client/components/AMap.js +24 -12
- package/lib/client/components/Configuration.d.ts +2 -1
- package/lib/client/components/Designer.d.ts +2 -1
- package/lib/client/components/ReadPretty.d.ts +2 -1
- package/lib/client/components/Search.d.ts +2 -1
- package/lib/client/index.d.ts +2 -2
- package/lib/client/index.js +3 -1
- package/package.json +4 -4
- package/src/client/block/MapBlock.tsx +10 -3
- package/src/client/block/index.tsx +1 -1
- package/src/client/components/AMap.tsx +27 -10
- package/src/client/index.tsx +4 -1
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const MapBlock: (props: any) => React.JSX.Element;
|
|
@@ -322,7 +322,7 @@ const MapBlockDrawer = props => {
|
|
|
322
322
|
}
|
|
323
323
|
return buf;
|
|
324
324
|
}, null), [fieldSchema]);
|
|
325
|
-
return schema && _react2().default.createElement(_client().
|
|
325
|
+
return schema && _react2().default.createElement(_client().ActionContextProvider, {
|
|
326
326
|
value: {
|
|
327
327
|
visible: !!record,
|
|
328
328
|
setVisible
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const MapBlockDesigner: () => React.JSX.Element;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const MapBlockInitializer: (props: any) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const MapBlockContext: React.Context<any>;
|
|
3
|
-
export declare const MapBlockProvider: (props: any) => JSX.Element;
|
|
3
|
+
export declare const MapBlockProvider: (props: any) => React.JSX.Element;
|
|
4
4
|
export declare const useMapBlockContext: () => any;
|
|
5
5
|
export declare const useMapBlockProps: () => any;
|
|
@@ -61,9 +61,9 @@ function _react2() {
|
|
|
61
61
|
};
|
|
62
62
|
return data;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
const data = require("react-router");
|
|
66
|
-
|
|
64
|
+
function _reactRouterDom() {
|
|
65
|
+
const data = require("react-router-dom");
|
|
66
|
+
_reactRouterDom = function _reactRouterDom() {
|
|
67
67
|
return data;
|
|
68
68
|
};
|
|
69
69
|
return data;
|
|
@@ -152,8 +152,8 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
152
152
|
}, [props === null || props === void 0 ? void 0 : props.type, fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.name]);
|
|
153
153
|
const overlay = (0, _react2().useRef)();
|
|
154
154
|
const _editor = (0, _react2().useRef)(null);
|
|
155
|
-
const
|
|
156
|
-
const id = (0, _react2().useRef)(`nocobase-map-${type}-${Date.now().toString(32)}`);
|
|
155
|
+
const navigate = (0, _reactRouterDom().useNavigate)();
|
|
156
|
+
const id = (0, _react2().useRef)(`nocobase-map-${type || ''}-${Date.now().toString(32)}`);
|
|
157
157
|
const _useState5 = (0, _react2().useState)(_objectSpread({
|
|
158
158
|
strokeWeight: 5,
|
|
159
159
|
strokeColor: '#4e9bff',
|
|
@@ -348,7 +348,7 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
348
348
|
version: '2.0',
|
|
349
349
|
plugins: ['AMap.MouseTool', 'AMap.PolygonEditor', 'AMap.PolylineEditor', 'AMap.CircleEditor']
|
|
350
350
|
}).then(amap => {
|
|
351
|
-
requestIdleCallback(() => {
|
|
351
|
+
return requestIdleCallback(() => {
|
|
352
352
|
map.current = new amap.Map(id.current, {
|
|
353
353
|
resizeEnable: true,
|
|
354
354
|
zoom
|
|
@@ -358,10 +358,14 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
358
358
|
forceUpdate([]);
|
|
359
359
|
});
|
|
360
360
|
}).catch(err => {
|
|
361
|
-
if (err
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
if (typeof err === 'string') {
|
|
362
|
+
if (err.includes('多个不一致的 key')) {
|
|
363
|
+
setErrMessage(t('The AccessKey is incorrect, please check it'));
|
|
364
|
+
} else {
|
|
365
|
+
setErrMessage(err);
|
|
366
|
+
}
|
|
367
|
+
} else if ((err === null || err === void 0 ? void 0 : err.type) === 'error') {
|
|
368
|
+
setErrMessage('Something went wrong, please refresh the page and try again');
|
|
365
369
|
}
|
|
366
370
|
});
|
|
367
371
|
return () => {
|
|
@@ -389,7 +393,7 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
389
393
|
return _react2().default.createElement(_antd().Alert, {
|
|
390
394
|
action: _react2().default.createElement(_antd().Button, {
|
|
391
395
|
type: "primary",
|
|
392
|
-
onClick: () =>
|
|
396
|
+
onClick: () => navigate('/admin/settings/map-configuration/configuration')
|
|
393
397
|
}, t('Go to the configuration page')),
|
|
394
398
|
message: errMessage || t('Please configure the AccessKey and SecurityJsCode first'),
|
|
395
399
|
type: "error"
|
|
@@ -402,7 +406,15 @@ const AMapComponent = _react2().default.forwardRef((props, ref) => {
|
|
|
402
406
|
`,
|
|
403
407
|
id: id.current,
|
|
404
408
|
style: props === null || props === void 0 ? void 0 : props.style
|
|
405
|
-
}, !
|
|
409
|
+
}, !aMap.current && _react2().default.createElement("div", {
|
|
410
|
+
className: (0, _css().css)`
|
|
411
|
+
position: absolute;
|
|
412
|
+
inset: 0;
|
|
413
|
+
display: flex;
|
|
414
|
+
align-items: center;
|
|
415
|
+
justify-content: center;
|
|
416
|
+
`
|
|
417
|
+
}, _react2().default.createElement(_antd().Spin, null)), !disabled ? _react2().default.createElement(_react2().default.Fragment, null, _react2().default.createElement(_Search.default, {
|
|
406
418
|
toCenter: toCenter,
|
|
407
419
|
aMap: aMap.current
|
|
408
420
|
}), _react2().default.createElement("div", {
|
package/lib/client/index.d.ts
CHANGED
package/lib/client/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
32
32
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
33
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
34
34
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
35
|
-
|
|
35
|
+
const MapProvider = _react().default.memo(props => {
|
|
36
36
|
const ctx = (0, _react().useContext)(_client().CollectionManagerContext);
|
|
37
37
|
const _useMapTranslation = (0, _locale.useMapTranslation)(),
|
|
38
38
|
t = _useMapTranslation.t;
|
|
@@ -59,4 +59,6 @@ var _default = _react().default.memo(props => {
|
|
|
59
59
|
})
|
|
60
60
|
}, props.children))))));
|
|
61
61
|
});
|
|
62
|
+
MapProvider.displayName = 'MapProvider';
|
|
63
|
+
var _default = MapProvider;
|
|
62
64
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
"name": "@nocobase/plugin-map",
|
|
3
3
|
"displayName": "Map",
|
|
4
4
|
"displayName.zh-CN": "地图",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.10.0-alpha.2",
|
|
6
6
|
"description": "Provide map fields and blocks",
|
|
7
7
|
"description.zh-CN": "提供地图字段和区块",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./lib/index.js",
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@nocobase/server": "0.
|
|
13
|
-
"@nocobase/test": "0.
|
|
12
|
+
"@nocobase/server": "0.10.0-alpha.2",
|
|
13
|
+
"@nocobase/test": "0.10.0-alpha.2"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
17
17
|
"@amap/amap-jsapi-types": "^0.0.10"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
|
|
20
20
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { CheckOutlined, EnvironmentOutlined, ExpandOutlined } from '@ant-design/icons';
|
|
2
2
|
import { css } from '@emotion/css';
|
|
3
3
|
import { RecursionField, Schema, useFieldSchema } from '@formily/react';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ActionContextProvider,
|
|
6
|
+
RecordProvider,
|
|
7
|
+
useCollection,
|
|
8
|
+
useCompile,
|
|
9
|
+
useFilterAPI,
|
|
10
|
+
useProps,
|
|
11
|
+
} from '@nocobase/client';
|
|
5
12
|
import { useMemoizedFn } from 'ahooks';
|
|
6
13
|
import { Button, Space } from 'antd';
|
|
7
14
|
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -272,11 +279,11 @@ const MapBlockDrawer = (props) => {
|
|
|
272
279
|
|
|
273
280
|
return (
|
|
274
281
|
schema && (
|
|
275
|
-
<
|
|
282
|
+
<ActionContextProvider value={{ visible: !!record, setVisible }}>
|
|
276
283
|
<RecordProvider record={record}>
|
|
277
284
|
<RecursionField schema={schema} name={schema.name} />
|
|
278
285
|
</RecordProvider>
|
|
279
|
-
</
|
|
286
|
+
</ActionContextProvider>
|
|
280
287
|
)
|
|
281
288
|
);
|
|
282
289
|
};
|
|
@@ -8,7 +8,7 @@ import { MapBlockInitializer } from './MapBlockInitializer';
|
|
|
8
8
|
import { MapBlockProvider, useMapBlockProps } from './MapBlockProvider';
|
|
9
9
|
|
|
10
10
|
export const MapBlockOptions: React.FC = (props) => {
|
|
11
|
-
const items = useContext(SchemaInitializerContext);
|
|
11
|
+
const items = useContext<any>(SchemaInitializerContext);
|
|
12
12
|
const children = items.BlockInitializers.items[0].children;
|
|
13
13
|
|
|
14
14
|
useEffect(() => {
|
|
@@ -5,9 +5,9 @@ import { css } from '@emotion/css';
|
|
|
5
5
|
import { useFieldSchema } from '@formily/react';
|
|
6
6
|
import { useCollection } from '@nocobase/client';
|
|
7
7
|
import { useMemoizedFn } from 'ahooks';
|
|
8
|
-
import { Alert, Button, Modal } from 'antd';
|
|
8
|
+
import { Alert, Button, Modal, Spin } from 'antd';
|
|
9
9
|
import React, { useEffect, useCallback, useRef, useState, useMemo, useImperativeHandle } from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import { useNavigate } from 'react-router-dom';
|
|
11
11
|
import { useMapConfiguration } from '../hooks';
|
|
12
12
|
import { useMapTranslation } from '../locale';
|
|
13
13
|
import Search from './Search';
|
|
@@ -101,8 +101,8 @@ const AMapComponent = React.forwardRef<AMapForwardedRefProps, AMapComponentProps
|
|
|
101
101
|
|
|
102
102
|
const overlay = useRef<AMap.Polygon>();
|
|
103
103
|
const editor = useRef(null);
|
|
104
|
-
const
|
|
105
|
-
const id = useRef(`nocobase-map-${type}-${Date.now().toString(32)}`);
|
|
104
|
+
const navigate = useNavigate();
|
|
105
|
+
const id = useRef(`nocobase-map-${type || ''}-${Date.now().toString(32)}`);
|
|
106
106
|
|
|
107
107
|
const [commonOptions] = useState<AMap.PolylineOptions & AMap.PolygonOptions>({
|
|
108
108
|
strokeWeight: 5,
|
|
@@ -316,7 +316,7 @@ const AMapComponent = React.forwardRef<AMapForwardedRefProps, AMapComponentProps
|
|
|
316
316
|
plugins: ['AMap.MouseTool', 'AMap.PolygonEditor', 'AMap.PolylineEditor', 'AMap.CircleEditor'],
|
|
317
317
|
})
|
|
318
318
|
.then((amap) => {
|
|
319
|
-
requestIdleCallback(() => {
|
|
319
|
+
return requestIdleCallback(() => {
|
|
320
320
|
map.current = new amap.Map(id.current, {
|
|
321
321
|
resizeEnable: true,
|
|
322
322
|
zoom,
|
|
@@ -327,10 +327,14 @@ const AMapComponent = React.forwardRef<AMapForwardedRefProps, AMapComponentProps
|
|
|
327
327
|
});
|
|
328
328
|
})
|
|
329
329
|
.catch((err) => {
|
|
330
|
-
if (err
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
330
|
+
if (typeof err === 'string') {
|
|
331
|
+
if (err.includes('多个不一致的 key')) {
|
|
332
|
+
setErrMessage(t('The AccessKey is incorrect, please check it'));
|
|
333
|
+
} else {
|
|
334
|
+
setErrMessage(err);
|
|
335
|
+
}
|
|
336
|
+
} else if (err?.type === 'error') {
|
|
337
|
+
setErrMessage('Something went wrong, please refresh the page and try again');
|
|
334
338
|
}
|
|
335
339
|
});
|
|
336
340
|
|
|
@@ -360,7 +364,7 @@ const AMapComponent = React.forwardRef<AMapForwardedRefProps, AMapComponentProps
|
|
|
360
364
|
return (
|
|
361
365
|
<Alert
|
|
362
366
|
action={
|
|
363
|
-
<Button type="primary" onClick={() =>
|
|
367
|
+
<Button type="primary" onClick={() => navigate('/admin/settings/map-configuration/configuration')}>
|
|
364
368
|
{t('Go to the configuration page')}
|
|
365
369
|
</Button>
|
|
366
370
|
}
|
|
@@ -379,6 +383,19 @@ const AMapComponent = React.forwardRef<AMapForwardedRefProps, AMapComponentProps
|
|
|
379
383
|
id={id.current}
|
|
380
384
|
style={props?.style}
|
|
381
385
|
>
|
|
386
|
+
{!aMap.current && (
|
|
387
|
+
<div
|
|
388
|
+
className={css`
|
|
389
|
+
position: absolute;
|
|
390
|
+
inset: 0;
|
|
391
|
+
display: flex;
|
|
392
|
+
align-items: center;
|
|
393
|
+
justify-content: center;
|
|
394
|
+
`}
|
|
395
|
+
>
|
|
396
|
+
<Spin />
|
|
397
|
+
</div>
|
|
398
|
+
)}
|
|
382
399
|
{!disabled ? (
|
|
383
400
|
<>
|
|
384
401
|
<Search toCenter={toCenter} aMap={aMap.current} />
|
package/src/client/index.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { MapInitializer } from './initialize';
|
|
|
13
13
|
import { useMapTranslation } from './locale';
|
|
14
14
|
import './locale';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const MapProvider = React.memo((props) => {
|
|
17
17
|
const ctx = useContext(CollectionManagerContext);
|
|
18
18
|
const { t } = useMapTranslation();
|
|
19
19
|
return (
|
|
@@ -45,3 +45,6 @@ export default React.memo((props) => {
|
|
|
45
45
|
</CurrentAppInfoProvider>
|
|
46
46
|
);
|
|
47
47
|
});
|
|
48
|
+
MapProvider.displayName = 'MapProvider';
|
|
49
|
+
|
|
50
|
+
export default MapProvider;
|