@cloud-app-dev/vidc 3.0.27 → 3.0.29

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.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import type { IDynamicListProps } from './interface';
3
3
  import './index.less';
4
- declare function DynamicDeviceList<T>({ renderItem, itemHeight, itemClassName, reloadDeps, loadPage }: IDynamicListProps<T>): JSX.Element;
5
- declare namespace DynamicDeviceList {
4
+ declare function DynamicList<T>({ renderItem, itemHeight, itemClassName, reloadDeps, loadPage }: IDynamicListProps<T>): JSX.Element;
5
+ declare namespace DynamicList {
6
6
  var defaultProps: {
7
7
  limit: number;
8
8
  itemHeight: number;
@@ -11,4 +11,4 @@ declare namespace DynamicDeviceList {
11
11
  itemClassName: string;
12
12
  };
13
13
  }
14
- export default DynamicDeviceList;
14
+ export default DynamicList;
@@ -20,7 +20,7 @@ import { LIMIT, skeletonList } from './utils';
20
20
  import useInfiniteScroll from '../../useInfiniteScroll';
21
21
  import "./index.css";
22
22
 
23
- function DynamicDeviceList(_ref) {
23
+ function DynamicList(_ref) {
24
24
  var renderItem = _ref.renderItem,
25
25
  itemHeight = _ref.itemHeight,
26
26
  itemClassName = _ref.itemClassName,
@@ -95,11 +95,11 @@ function DynamicDeviceList(_ref) {
95
95
  })));
96
96
  }
97
97
 
98
- DynamicDeviceList.defaultProps = {
98
+ DynamicList.defaultProps = {
99
99
  limit: LIMIT,
100
100
  itemHeight: 40,
101
101
  params: {},
102
102
  itemKey: 'id',
103
103
  itemClassName: ''
104
104
  };
105
- export default DynamicDeviceList;
105
+ export default DynamicList;
@@ -10,23 +10,33 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import React, { useState } from 'react';
13
+ import React, { useEffect, useState } from 'react';
14
14
  import MapDrawSelect from './index';
15
15
  import deviceList from '../points.json';
16
16
 
17
17
  var App = function App() {
18
- var _useState = useState(),
18
+ var _useState = useState([]),
19
19
  _useState2 = _slicedToArray(_useState, 2),
20
- type = _useState2[0],
21
- setType = _useState2[1];
20
+ points = _useState2[0],
21
+ setPoints = _useState2[1];
22
22
 
23
+ var _useState3 = useState(),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ type = _useState4[0],
26
+ setType = _useState4[1];
27
+
28
+ useEffect(function () {
29
+ setTimeout(function () {
30
+ return setPoints(deviceList);
31
+ }, 5000);
32
+ }, []);
23
33
  return /*#__PURE__*/React.createElement("div", {
24
34
  style: {
25
35
  width: '100%',
26
36
  height: 800
27
37
  }
28
38
  }, /*#__PURE__*/React.createElement(MapDrawSelect, {
29
- points: deviceList,
39
+ points: points,
30
40
  drawEnd: console.log,
31
41
  drawType: type,
32
42
  drawUi: /*#__PURE__*/React.createElement("div", {
@@ -8,6 +8,7 @@ export interface IMapDrawSelectProps {
8
8
  children?: React.ReactNode;
9
9
  drawUi?: React.ReactNode;
10
10
  drawType?: DrawType | 'clear' | 'close';
11
+ selectCenter?: [number, number];
11
12
  drawEnd?: (points: MapPoint[]) => void;
12
13
  onPointClick?: (point: MapPoint) => void;
13
14
  }
@@ -1,5 +1,5 @@
1
1
  import _useMount from "ahooks/es/useMount";
2
- import React, { useCallback, useContext, useMemo } from 'react';
2
+ import React, { useCallback, useContext, useEffect, useMemo } from 'react';
3
3
  import ClusterLayer from '../ClusterLayer';
4
4
  import ResetTools from '../ResetTools';
5
5
  import withMap from '../withMap';
@@ -14,6 +14,7 @@ function MapDrawSelect(_ref) {
14
14
  children = _ref.children,
15
15
  drawUi = _ref.drawUi,
16
16
  drawType = _ref.drawType,
17
+ selectCenter = _ref.selectCenter,
17
18
  drawEnd = _ref.drawEnd,
18
19
  onPointClick = _ref.onPointClick;
19
20
 
@@ -35,6 +36,11 @@ function MapDrawSelect(_ref) {
35
36
  return mapRest();
36
37
  });
37
38
 
39
+ useEffect(function () {
40
+ if (selectCenter) {
41
+ instance.setZoomAndCenter(defaultZoom, selectCenter);
42
+ }
43
+ }, [defaultZoom, instance, selectCenter]);
38
44
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ClusterLayer, {
39
45
  points: points,
40
46
  onPointClick: onPointClick
@@ -1,5 +1,5 @@
1
1
  import _useMount from "ahooks/es/useMount";
2
- import { useContext, useRef } from 'react';
2
+ import { useContext, useEffect, useRef } from 'react';
3
3
  import { mapContext } from '../Context';
4
4
 
5
5
  function useMouseTools(onDrawEnd) {
@@ -13,13 +13,21 @@ function useMouseTools(onDrawEnd) {
13
13
  var map = instance.map;
14
14
  AMap.plugin(['AMap.MouseTool'], function () {
15
15
  mouseRef.current = new AMap.MouseTool(map);
16
- mouseRef.current.on('draw', function (e) {
17
- overlayersRef.current.push(e.obj);
18
- onDrawEnd === null || onDrawEnd === void 0 ? void 0 : onDrawEnd(e.obj);
19
- });
20
16
  });
21
17
  });
22
18
 
19
+ useEffect(function () {
20
+ var fn = function fn(e) {
21
+ overlayersRef.current.push(e.obj);
22
+ onDrawEnd === null || onDrawEnd === void 0 ? void 0 : onDrawEnd(e.obj);
23
+ };
24
+
25
+ mouseRef.current.on('draw', fn);
26
+ return function () {
27
+ mouseRef.current.off('draw', fn);
28
+ };
29
+ }, [onDrawEnd]);
30
+
23
31
  var draw = function draw(type) {
24
32
  if (!mouseRef.current) {
25
33
  return;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "private": false,
3
3
  "name": "@cloud-app-dev/vidc",
4
4
  "description": "Video Image Data Componennts",
5
- "version": "3.0.27",
5
+ "version": "3.0.29",
6
6
  "scripts": {
7
7
  "start": "dumi dev",
8
8
  "docs:build": "dumi build",