@cloud-app-dev/vidc 4.0.20 → 4.0.22
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/es/AppContext/Sync.js +42 -0
- package/es/AppContext/index.js +141 -0
- package/es/AppContext/interface.d.ts +41 -0
- package/es/AppContext/static.js +9 -0
- package/es/Auth/index.js +14 -0
- package/es/AutoExit/index.js +19 -0
- package/es/CheckGroupFixed/demo.js +22 -0
- package/es/CheckGroupFixed/index.js +140 -0
- package/es/CheckGroupFixed/index.less +56 -0
- package/es/Config/index.js +77 -0
- package/es/Config/interface.d.ts +65 -0
- package/es/Config/utils.js +33 -0
- package/es/ConfigContext/index.js +21 -0
- package/es/CustomRenderSelect/index.js +72 -0
- package/es/CustomRenderSelect/index.less +25 -0
- package/es/DBTools/index.js +336 -0
- package/es/DisableMark/index.js +19 -0
- package/es/DisableMark/index.less +9 -0
- package/es/DomMove/demo.js +16 -0
- package/es/DomMove/index.js +139 -0
- package/es/DomMove/utils.js +32 -0
- package/es/Drag/DragAndDropItem.js +133 -0
- package/es/Drag/DropItem.js +50 -0
- package/es/Drag/index.d.ts +9 -0
- package/es/Drag/index.js +7 -0
- package/es/Drag/interface.d.ts +16 -0
- package/es/DynamicGridList/Demo.js +77 -0
- package/es/DynamicGridList/index.js +67 -0
- package/es/DynamicList/demo.js +44 -0
- package/es/DynamicList/index.js +86 -0
- package/es/DynamicList/index.less +17 -0
- package/es/DynamicList/interface.d.ts +19 -0
- package/es/DynamicList/utils.js +6 -0
- package/es/ErrorFallback/index.js +31 -0
- package/es/ErrorFallback/inerface.d.ts +48 -0
- package/es/EventTools/index.js +12 -0
- package/es/FrontendPlayer/index.js +2 -0
- package/es/FullScreen/index.js +33 -0
- package/es/FullScreen/index.less +18 -0
- package/es/GridList/Demo.js +80 -0
- package/es/GridList/data.js +609 -0
- package/es/GridList/hook.js +270 -0
- package/es/GridList/index.js +44 -0
- package/es/GridList/index.less +8 -0
- package/es/GridList/interface.d.ts +59 -0
- package/es/GridList/utils.js +42 -0
- package/es/HightLevel/index.js +18 -0
- package/es/HightLevel/index.less +3 -0
- package/es/IconFont/index.js +54 -0
- package/es/ImageView/index.js +51 -0
- package/es/ImageView/index.less +11 -0
- package/es/InstanceHistory/index.js +7 -0
- package/es/LabelPlayer/111.png +0 -0
- package/es/LabelPlayer/demo.js +115 -0
- package/es/LabelPlayer/index.js +160 -0
- package/es/LabelPlayer/index.less +24 -0
- package/es/LabelValue/index.js +27 -0
- package/es/LabelValue/index.less +23 -0
- package/es/List/demo.js +23 -0
- package/es/List/index.js +28 -0
- package/es/List/index.less +20 -0
- package/es/ListWithSizeAnimate/demo.js +98 -0
- package/es/ListWithSizeAnimate/index.js +85 -0
- package/es/ListWithSizeAnimate/index.less +23 -0
- package/es/LoaderScript/index.js +34 -0
- package/es/LoaderScript/utils.js +179 -0
- package/es/Map/AMap.d.ts +7109 -0
- package/es/Map/BasicMap/AMapInstance.js +98 -0
- package/es/Map/BasicMap/LeafletInstance.js +111 -0
- package/es/Map/BasicMap/index.js +90 -0
- package/es/Map/BasicMap/index.less +29 -0
- package/es/Map/ClusterLayer/demo.js +18 -0
- package/es/Map/ClusterLayer/hook.js +123 -0
- package/es/Map/ClusterLayer/index.js +28 -0
- package/es/Map/ClusterLayer/index.less +29 -0
- package/es/Map/ClusterLayer/props.d.ts +8 -0
- package/es/Map/Config/index.js +48 -0
- package/es/Map/Config/utils.js +65 -0
- package/es/Map/Context/index.js +51 -0
- package/es/Map/FindPio/index.js +13 -0
- package/es/Map/FindPio/index.less +7 -0
- package/es/Map/InfoWindow/MakerLikeWindow.js +108 -0
- package/es/Map/InfoWindow/demo.js +70 -0
- package/es/Map/InfoWindow/index.js +62 -0
- package/es/Map/LevelCenter/DragMarker/index.js +42 -0
- package/es/Map/LevelCenter/demo.js +38 -0
- package/es/Map/LevelCenter/index.js +66 -0
- package/es/Map/LoaderMap/index.js +62 -0
- package/es/Map/MapDrawSelect/demo.js +71 -0
- package/es/Map/MapDrawSelect/index.js +56 -0
- package/es/Map/MouseTool/index.js +40 -0
- package/es/Map/MouseTool/useMouseTools.js +83 -0
- package/es/Map/ResetTools/index.js +57 -0
- package/es/Map/ResetTools/index.less +39 -0
- package/es/Map/SinglePoint/demo.js +14 -0
- package/es/Map/SinglePoint/index.js +52 -0
- package/es/Map/SinglePoint/index.less +41 -0
- package/es/Map/hook/useMapEvent.js +19 -0
- package/es/Map/hook/useMapType.js +12 -0
- package/es/Map/icon.js +10 -0
- package/es/Map/index.js +25 -0
- package/es/Map/interface.d.ts +74 -0
- package/es/Map/points.js +1 -0
- package/es/Map/useMarker/index.js +71 -0
- package/es/Map/withMap/index.js +10 -0
- package/es/Picture/component/DefaultRects/RectInfo.js +80 -0
- package/es/Picture/component/DefaultRects/index.js +52 -0
- package/es/Picture/component/DefaultRects/index.less +211 -0
- package/es/Picture/component/DefaultRects/utils.js +11 -0
- package/es/Picture/component/DrawRect/index.js +46 -0
- package/es/Picture/component/DrawRect/index.less +8 -0
- package/es/Picture/component/RectMenu/index.js +76 -0
- package/es/Picture/component/RectMenu/index.less +36 -0
- package/es/Picture/component/RectMenu/utils.js +19 -0
- package/es/Picture/component/Tools/index.js +73 -0
- package/es/Picture/component/Tools/index.less +49 -0
- package/es/Picture/component/WheelScale/index.js +27 -0
- package/es/Picture/demo.js +105 -0
- package/es/Picture/index.js +341 -0
- package/es/Picture/index.less +20 -0
- package/es/Picture/interface.d.ts +196 -0
- package/es/Picture/loadCaptureRectImage.js +99 -0
- package/es/Picture/useDraw.js +103 -0
- package/es/Picture/utils.js +143 -0
- package/es/Player/api/index.js +309 -0
- package/es/Player/context.js +24 -0
- package/es/Player/contraller_bar/bar.js +20 -0
- package/es/Player/contraller_bar/contraller_event.js +48 -0
- package/es/Player/contraller_bar/index.js +27 -0
- package/es/Player/contraller_bar/left_bar.js +83 -0
- package/es/Player/contraller_bar/right_bar.js +32 -0
- package/es/Player/contraller_bar/time.js +19 -0
- package/es/Player/contraller_bar/useBarStatus.js +43 -0
- package/es/Player/contraller_bar/volume.js +62 -0
- package/es/Player/demo.js +266 -0
- package/es/Player/empty.js +4 -0
- package/es/Player/event/errorEvent.js +88 -0
- package/es/Player/event/eventName.js +29 -0
- package/es/Player/event/index.js +205 -0
- package/es/Player/fps_play.js +83 -0
- package/es/Player/frontend_player.js +64 -0
- package/es/Player/frontend_timeline.js +132 -0
- package/es/Player/iconfont.js +16 -0
- package/es/Player/index.js +2 -0
- package/es/Player/live_heart.js +45 -0
- package/es/Player/message.js +133 -0
- package/es/Player/player.d.ts +233 -0
- package/es/Player/segment_player.js +228 -0
- package/es/Player/segment_timeline.js +173 -0
- package/es/Player/single_player.js +262 -0
- package/es/Player/style/bar.less +43 -0
- package/es/Player/style/iconfont.js +43 -0
- package/es/Player/style/index.less +34 -0
- package/es/Player/style/message.less +56 -0
- package/es/Player/style/slider.less +106 -0
- package/es/Player/style/timeline.less +117 -0
- package/es/Player/style/volume.less +24 -0
- package/es/Player/timeline.js +95 -0
- package/es/Player/util.js +189 -0
- package/es/PlayerExt/demo.js +154 -0
- package/es/PlayerExt/index.js +188 -0
- package/es/PlayerExt/index.less +10 -0
- package/es/Progress/index.d.ts +9 -0
- package/es/Progress/index.js +53 -0
- package/es/Progress/index.less +21 -0
- package/es/ROI/demo.js +16 -0
- package/es/ROI/index.js +54 -0
- package/es/ROI/index.less +33 -0
- package/es/RefDrawer/Footer.js +22 -0
- package/es/RefDrawer/demo.js +18 -0
- package/es/RefDrawer/index.js +71 -0
- package/es/RefModal/demo.js +18 -0
- package/es/RefModal/index.js +70 -0
- package/es/ScreenPlayer/Live.js +212 -0
- package/es/ScreenPlayer/LiveTools.js +151 -0
- package/es/ScreenPlayer/PlayerWithExt.js +231 -0
- package/es/ScreenPlayer/RatePick.js +29 -0
- package/es/ScreenPlayer/Record.js +442 -0
- package/es/ScreenPlayer/RecordTools.js +169 -0
- package/es/ScreenPlayer/ScreenSelect.js +46 -0
- package/es/ScreenPlayer/SegmentTimeLine.js +36 -0
- package/es/ScreenPlayer/TimeMode.js +26 -0
- package/es/ScreenPlayer/TimeSelect.js +88 -0
- package/es/ScreenPlayer/demo.js +21 -0
- package/es/ScreenPlayer/demo2.js +194 -0
- package/es/ScreenPlayer/index.js +9 -0
- package/es/ScreenPlayer/index.less +335 -0
- package/es/ScreenPlayer/interface.d.ts +216 -0
- package/es/ScreenPlayer/useTimeSlider.js +456 -0
- package/es/ScreenPlayer/useVideoFit.js +35 -0
- package/es/ScreenPlayer/utils.js +85 -0
- package/es/SegmentPlayer/index.js +2 -0
- package/es/Service/http.js +133 -0
- package/es/Service/index.js +11 -0
- package/es/Service/interface.d.ts +23 -0
- package/es/Service/middleware.js +22 -0
- package/es/SocketEmitter/eventEmitter.js +88 -0
- package/es/SocketEmitter/index.js +125 -0
- package/es/SocketEmitter/interface.d.ts +4 -0
- package/es/TableLayout/index.js +27 -0
- package/es/TableLayout/index.less +4 -0
- package/es/ThemeAntd/demo.js +81 -0
- package/es/ThemeAntd/demo.less +20 -0
- package/es/ThemeAntd/index.js +21 -0
- package/es/ThemeAntd/index.less +4 -0
- package/es/Timeout/index.js +65 -0
- package/es/bigNumberTransformCN/index.js +58 -0
- package/es/cache/index.js +94 -0
- package/es/copy/index.js +9 -0
- package/es/core.d.ts +0 -0
- package/es/getThemeStyle/index.js +5 -0
- package/es/index.js +62 -0
- package/es/likeGo/index.js +31 -0
- package/es/likeGoSync/index.js +10 -0
- package/es/logger/index.js +30 -0
- package/es/nextTick/index.js +3 -0
- package/es/recorder/demo.js +181 -0
- package/es/recorder/index.js +992 -0
- package/es/submidstr/index.js +14 -0
- package/es/treeHelper/index.js +188 -0
- package/es/typings.d.ts +2 -0
- package/es/useDrawROI/index.js +318 -0
- package/es/useEventEmitterHandle/index.js +17 -0
- package/es/useFullscreen/demo.js +43 -0
- package/es/useFullscreen/index.js +76 -0
- package/es/useHistory/index.js +9 -0
- package/es/useHistory/interface.d.ts +3 -0
- package/es/useInfiniteScroll/index.js +102 -0
- package/es/useRafInterval/index.js +70 -0
- package/es/useSimpleState/index.js +35 -0
- package/es/useVirtualList/index.js +136 -0
- package/es/utils.js +46 -0
- package/es/uuid/index.js +19 -0
- package/package.json +2 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function getPosition(obj) {
|
|
2
|
+
//获取某元素以浏览器左上角为原点的坐标
|
|
3
|
+
var t = obj.offsetTop; //获取该元素对应父容器的上边距
|
|
4
|
+
var l = obj.offsetLeft; //对应父容器的上边距
|
|
5
|
+
//判断是否有父容器,如果存在则累加其边距
|
|
6
|
+
while (obj = obj.offsetParent) {
|
|
7
|
+
//等效 obj = obj.offsetParent;while (obj != undefined)
|
|
8
|
+
t += obj.offsetTop; //叠加父容器的上边距
|
|
9
|
+
l += obj.offsetLeft; //叠加父容器的左边距
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
left: l,
|
|
13
|
+
top: t
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// 函数用于获取鼠标的位置
|
|
17
|
+
export function getMouseXY(e) {
|
|
18
|
+
var x = 0,
|
|
19
|
+
y = 0;
|
|
20
|
+
e = e || window.event;
|
|
21
|
+
if (e.pageX) {
|
|
22
|
+
x = e.pageX;
|
|
23
|
+
y = e.pageY;
|
|
24
|
+
} else {
|
|
25
|
+
x = e.clientX + document.body.scrollLeft - document.body.clientLeft;
|
|
26
|
+
y = e.clientY + document.body.scrollTop - document.body.clientTop;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
x: x,
|
|
30
|
+
y: y
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
14
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import uuid from "../uuid";
|
|
16
|
+
function DragAndDropItem(_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
dragData = _ref.dragData,
|
|
19
|
+
dragId = _ref.dragId,
|
|
20
|
+
style = _ref.style,
|
|
21
|
+
onDropEnd = _ref.onDropEnd,
|
|
22
|
+
_ref$disabledCopyElem = _ref.disabledCopyElement,
|
|
23
|
+
disabledCopyElement = _ref$disabledCopyElem === void 0 ? true : _ref$disabledCopyElem;
|
|
24
|
+
var id = useMemo(function () {
|
|
25
|
+
return dragId || "dragId-".concat(uuid());
|
|
26
|
+
}, [dragId]);
|
|
27
|
+
var _useState = useState(['', '']),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
status = _useState2[0],
|
|
30
|
+
setStatus = _useState2[1];
|
|
31
|
+
var _useState3 = useState([0, 0]),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
offset = _useState4[0],
|
|
34
|
+
setOffset = _useState4[1];
|
|
35
|
+
var domRef = useRef(null);
|
|
36
|
+
var dragDomTemp = useRef(null);
|
|
37
|
+
var onDrop = useCallback(function (event) {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
setStatus(function (old) {
|
|
40
|
+
return [old[0], 'droped'];
|
|
41
|
+
});
|
|
42
|
+
var data = JSON.parse(event.dataTransfer.getData('DATA'));
|
|
43
|
+
onDropEnd && onDropEnd(data);
|
|
44
|
+
}, [onDropEnd]);
|
|
45
|
+
var onDragEnter = useCallback(function (event) {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
setStatus(function (old) {
|
|
48
|
+
return [old[0], 'dragenter'];
|
|
49
|
+
});
|
|
50
|
+
}, []);
|
|
51
|
+
var onDragLeave = useCallback(function (event) {
|
|
52
|
+
event.stopPropagation();
|
|
53
|
+
setStatus(function (old) {
|
|
54
|
+
return [old[0], 'dragleave'];
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
var allowDrop = useCallback(function (event) {
|
|
58
|
+
return event.preventDefault();
|
|
59
|
+
}, []);
|
|
60
|
+
var onDragStart = useCallback(function (event) {
|
|
61
|
+
if (!domRef.current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!disabledCopyElement) {
|
|
65
|
+
var pageX = event.pageX,
|
|
66
|
+
pageY = event.pageY;
|
|
67
|
+
var _domRef$current$getBo = domRef.current.getBoundingClientRect(),
|
|
68
|
+
x = _domRef$current$getBo.x,
|
|
69
|
+
y = _domRef$current$getBo.y,
|
|
70
|
+
width = _domRef$current$getBo.width,
|
|
71
|
+
height = _domRef$current$getBo.height;
|
|
72
|
+
var offsetX = pageX - x;
|
|
73
|
+
var offsetY = pageY - y;
|
|
74
|
+
dragDomTemp.current = domRef.current.cloneNode(true);
|
|
75
|
+
domRef.current.after(dragDomTemp.current);
|
|
76
|
+
//初始化缓存dom位置
|
|
77
|
+
dragDomTemp.current.style.position = 'fixed';
|
|
78
|
+
dragDomTemp.current.style.left = "".concat(event.pageX - offsetX, "px");
|
|
79
|
+
dragDomTemp.current.style.top = "".concat(event.pageY - offsetY, "px");
|
|
80
|
+
dragDomTemp.current.style.draggable = false;
|
|
81
|
+
dragDomTemp.current.style.pointerEvents = 'none';
|
|
82
|
+
dragDomTemp.current.style.opacity = 0.5;
|
|
83
|
+
dragDomTemp.current.style.zIndex = 99;
|
|
84
|
+
dragDomTemp.current.style.width = "".concat(width, "px");
|
|
85
|
+
dragDomTemp.current.style.height = "".concat(height, "px");
|
|
86
|
+
setOffset([offsetX, offsetY]);
|
|
87
|
+
event.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
88
|
+
}
|
|
89
|
+
setStatus(function (old) {
|
|
90
|
+
return ['draging', old[1]];
|
|
91
|
+
});
|
|
92
|
+
var res = {
|
|
93
|
+
data: dragData,
|
|
94
|
+
_id: id
|
|
95
|
+
};
|
|
96
|
+
event.dataTransfer.setData('DATA', JSON.stringify(res));
|
|
97
|
+
}, [disabledCopyElement, dragData, id]);
|
|
98
|
+
var onDragEnd = useCallback(function () {
|
|
99
|
+
dragDomTemp.current && dragDomTemp.current.remove();
|
|
100
|
+
setStatus(function (old) {
|
|
101
|
+
return ['dragEnd', old[1]];
|
|
102
|
+
});
|
|
103
|
+
}, []);
|
|
104
|
+
var onDrag = useCallback(function (e) {
|
|
105
|
+
if (dragDomTemp.current) {
|
|
106
|
+
if (e.pageX === 0 && e.pageY === 0) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (e.pageX < offset[2] || e.pageY < offset[3]) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
dragDomTemp.current.style.position = 'fixed';
|
|
113
|
+
dragDomTemp.current.style.left = "".concat(e.pageX - offset[0], "px");
|
|
114
|
+
dragDomTemp.current.style.top = "".concat(e.pageY - offset[1], "px");
|
|
115
|
+
}
|
|
116
|
+
}, [offset]);
|
|
117
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
118
|
+
ref: domRef,
|
|
119
|
+
onDragStart: onDragStart,
|
|
120
|
+
onDrag: onDrag,
|
|
121
|
+
'data-dragId': id,
|
|
122
|
+
draggable: true,
|
|
123
|
+
onDragEnd: onDragEnd,
|
|
124
|
+
onDrop: onDrop,
|
|
125
|
+
onDragOver: allowDrop,
|
|
126
|
+
onDragEnter: onDragEnter,
|
|
127
|
+
onDragLeave: onDragLeave,
|
|
128
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
129
|
+
opacity: status[0] === 'draging' || status[1] === 'dragenter' ? 0.5 : 1
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
export default DragAndDropItem;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
14
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
15
|
+
function DropItem(_ref) {
|
|
16
|
+
var children = _ref.children,
|
|
17
|
+
style = _ref.style,
|
|
18
|
+
onDropEnd = _ref.onDropEnd;
|
|
19
|
+
var _useState = useState(''),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
status = _useState2[0],
|
|
22
|
+
setStatus = _useState2[1];
|
|
23
|
+
var domRef = useRef(null);
|
|
24
|
+
var onDrop = useCallback(function (event) {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
setStatus('droped');
|
|
27
|
+
var data = JSON.parse(event.dataTransfer.getData('DATA'));
|
|
28
|
+
onDropEnd && onDropEnd(data);
|
|
29
|
+
}, [onDropEnd]);
|
|
30
|
+
var onDragEnter = useCallback(function (event) {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
setStatus('dragenter');
|
|
33
|
+
}, []);
|
|
34
|
+
var onDragLeave = useCallback(function (event) {
|
|
35
|
+
event.stopPropagation();
|
|
36
|
+
setStatus('dragleave');
|
|
37
|
+
}, []);
|
|
38
|
+
var allowDrop = useCallback(function (event) {
|
|
39
|
+
return event.preventDefault();
|
|
40
|
+
}, []);
|
|
41
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
42
|
+
ref: domRef,
|
|
43
|
+
onDrop: onDrop,
|
|
44
|
+
onDragOver: allowDrop,
|
|
45
|
+
onDragEnter: onDragEnter,
|
|
46
|
+
onDragLeave: onDragLeave,
|
|
47
|
+
style: status === 'dragenter' ? _objectSpread({}, style) : undefined
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export default DropItem;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IDragAndDropItemProps, IDropItemProps } from './interface';
|
|
3
|
+
|
|
4
|
+
interface IDragInterface<T> {
|
|
5
|
+
DragAndDropItemProps: React.FC<IDragAndDropItemProps<T>>;
|
|
6
|
+
DropItem: React.FC<IDropItemProps<T>>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default IDragInterface;
|
package/es/Drag/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface IDragAndDropItemProps<T> {
|
|
4
|
+
children: JSX.Element;
|
|
5
|
+
dragData: T;
|
|
6
|
+
dragId?: string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onDropEnd: (params: { data: T; _id: string }) => void;
|
|
9
|
+
disabledCopyElement?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IDropItemProps<T> {
|
|
13
|
+
children: JSX.Element;
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
onDropEnd: (params: { data: T; _id?: string }) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import GridList from "./index";
|
|
10
|
+
function random(low, high) {
|
|
11
|
+
return Math.floor(Math.random() * high) + low;
|
|
12
|
+
}
|
|
13
|
+
var IMAGES = function IMAGES() {
|
|
14
|
+
return Array.from({
|
|
15
|
+
length: 20
|
|
16
|
+
}, function (_, index) {
|
|
17
|
+
var width = 300;
|
|
18
|
+
var height = random(200, 300);
|
|
19
|
+
return {
|
|
20
|
+
url: "https://picsum.photos/id/".concat(index + 1, "/").concat(width, "/").concat(height, ".jpg"),
|
|
21
|
+
width: width,
|
|
22
|
+
height: height
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
function loadPage(d) {
|
|
27
|
+
if (!d) {
|
|
28
|
+
// eslint-disable-next-line no-param-reassign
|
|
29
|
+
d = {};
|
|
30
|
+
}
|
|
31
|
+
var resultData = IMAGES();
|
|
32
|
+
d.page ? d.page++ : d.page = 1;
|
|
33
|
+
d.list ? d.list = [].concat(_toConsumableArray(d.list), _toConsumableArray(resultData)) : d.list = resultData;
|
|
34
|
+
return new Promise(function (resolve) {
|
|
35
|
+
console.log(d.page);
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
return resolve(d);
|
|
38
|
+
}, 10);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
var App = function App() {
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
style: {
|
|
44
|
+
height: 400
|
|
45
|
+
}
|
|
46
|
+
}, /*#__PURE__*/React.createElement(GridList, {
|
|
47
|
+
itemKey: "url",
|
|
48
|
+
itemHeight: 400,
|
|
49
|
+
itemWidth: 250,
|
|
50
|
+
renderItem: function renderItem(image) {
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
style: {
|
|
53
|
+
border: '1px solid gray',
|
|
54
|
+
height: '100%',
|
|
55
|
+
display: 'flex',
|
|
56
|
+
flexDirection: 'column'
|
|
57
|
+
}
|
|
58
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
style: {
|
|
60
|
+
flex: 1,
|
|
61
|
+
overflow: 'hidden'
|
|
62
|
+
}
|
|
63
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
64
|
+
src: image.url,
|
|
65
|
+
alt: "",
|
|
66
|
+
style: {
|
|
67
|
+
objectFit: 'cover',
|
|
68
|
+
display: 'block',
|
|
69
|
+
width: '100%',
|
|
70
|
+
height: '100%'
|
|
71
|
+
}
|
|
72
|
+
})), /*#__PURE__*/React.createElement("p", null, "\u6807\u9898"), /*#__PURE__*/React.createElement("p", null, "\u63CF\u8FF0"));
|
|
73
|
+
},
|
|
74
|
+
loadPage: loadPage
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
77
|
+
export default App;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var _excluded = ["renderItem", "itemHeight", "itemKey", "itemWidth", "reloadDeps", "getGridGap", "loadPage", "isNoMore", "threshold"];
|
|
2
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
+
import { useUpdateEffect } from 'ahooks';
|
|
5
|
+
import React, { useMemo, useRef } from 'react';
|
|
6
|
+
import GridList from "../GridList";
|
|
7
|
+
import useInfiniteScroll from "../useInfiniteScroll";
|
|
8
|
+
function DynamicGridList(_ref) {
|
|
9
|
+
var renderItem = _ref.renderItem,
|
|
10
|
+
_ref$itemHeight = _ref.itemHeight,
|
|
11
|
+
itemHeight = _ref$itemHeight === void 0 ? 300 : _ref$itemHeight,
|
|
12
|
+
itemKey = _ref.itemKey,
|
|
13
|
+
_ref$itemWidth = _ref.itemWidth,
|
|
14
|
+
itemWidth = _ref$itemWidth === void 0 ? 250 : _ref$itemWidth,
|
|
15
|
+
_ref$reloadDeps = _ref.reloadDeps,
|
|
16
|
+
reloadDeps = _ref$reloadDeps === void 0 ? [] : _ref$reloadDeps,
|
|
17
|
+
_ref$getGridGap = _ref.getGridGap,
|
|
18
|
+
getGridGap = _ref$getGridGap === void 0 ? function () {
|
|
19
|
+
return 20;
|
|
20
|
+
} : _ref$getGridGap,
|
|
21
|
+
loadPage = _ref.loadPage,
|
|
22
|
+
isNoMore = _ref.isNoMore,
|
|
23
|
+
_ref$threshold = _ref.threshold,
|
|
24
|
+
threshold = _ref$threshold === void 0 ? 50 : _ref$threshold,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
var containerRef = useRef(null);
|
|
27
|
+
var _useInfiniteScroll = useInfiniteScroll(loadPage, {
|
|
28
|
+
target: containerRef,
|
|
29
|
+
threshold: threshold,
|
|
30
|
+
isNoMore: isNoMore,
|
|
31
|
+
reloadDeps: reloadDeps
|
|
32
|
+
}),
|
|
33
|
+
data = _useInfiniteScroll.data,
|
|
34
|
+
noMore = _useInfiniteScroll.noMore;
|
|
35
|
+
useUpdateEffect(function () {
|
|
36
|
+
if (noMore) {
|
|
37
|
+
console.warn('数据已全部加载完成');
|
|
38
|
+
}
|
|
39
|
+
}, [noMore]);
|
|
40
|
+
function getItemData(data) {
|
|
41
|
+
return {
|
|
42
|
+
key: data[itemKey],
|
|
43
|
+
height: itemHeight,
|
|
44
|
+
width: itemWidth
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function getColumnCount(elementWidth, gridGap) {
|
|
48
|
+
return Math.floor((elementWidth + gridGap) / ((itemWidth !== null && itemWidth !== void 0 ? itemWidth : 0) + gridGap));
|
|
49
|
+
}
|
|
50
|
+
function getWindowMargin(windowHeight) {
|
|
51
|
+
return Math.round(windowHeight * 1.5);
|
|
52
|
+
}
|
|
53
|
+
var dataList = useMemo(function () {
|
|
54
|
+
return data ? data.list || [] : [];
|
|
55
|
+
}, [data]);
|
|
56
|
+
return /*#__PURE__*/React.createElement(GridList, {
|
|
57
|
+
className: "cloudapp-dynamic-grid-list ".concat(props.className || ''),
|
|
58
|
+
items: dataList,
|
|
59
|
+
ref: containerRef,
|
|
60
|
+
getItemData: getItemData,
|
|
61
|
+
getColumnCount: getColumnCount,
|
|
62
|
+
getWindowMargin: getWindowMargin,
|
|
63
|
+
renderItem: renderItem,
|
|
64
|
+
getGridGap: getGridGap
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export default DynamicGridList;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
8
|
+
import { ConfigProvider } from 'antd';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import DynamicList from "./index";
|
|
11
|
+
var resultData = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'];
|
|
12
|
+
function loadPage(d) {
|
|
13
|
+
if (!d) {
|
|
14
|
+
// eslint-disable-next-line no-param-reassign
|
|
15
|
+
d = {};
|
|
16
|
+
}
|
|
17
|
+
d.page ? d.page++ : d.page = 1;
|
|
18
|
+
d.list ? d.list = [].concat(_toConsumableArray(d.list), resultData) : d.list = resultData;
|
|
19
|
+
return new Promise(function (resolve) {
|
|
20
|
+
setTimeout(function () {
|
|
21
|
+
resolve(d);
|
|
22
|
+
}, 2000);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export default function () {
|
|
26
|
+
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
27
|
+
prefixCls: "cloudapp"
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
style: {
|
|
30
|
+
display: 'flex'
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
style: {
|
|
34
|
+
height: 400,
|
|
35
|
+
width: 300
|
|
36
|
+
}
|
|
37
|
+
}, /*#__PURE__*/React.createElement(DynamicList, {
|
|
38
|
+
loadPage: loadPage,
|
|
39
|
+
itemHeight: 40,
|
|
40
|
+
renderItem: function renderItem(item) {
|
|
41
|
+
return /*#__PURE__*/React.createElement("div", null, item.data);
|
|
42
|
+
}
|
|
43
|
+
}))));
|
|
44
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useUpdateEffect } from 'ahooks';
|
|
8
|
+
import { Skeleton } from 'antd';
|
|
9
|
+
import React, { useMemo, useRef } from 'react';
|
|
10
|
+
import useInfiniteScroll from "../useInfiniteScroll";
|
|
11
|
+
import useVirtualList from "../useVirtualList";
|
|
12
|
+
import { skeletonList } from "./utils";
|
|
13
|
+
|
|
14
|
+
//style
|
|
15
|
+
import "./index.less";
|
|
16
|
+
function DynamicList(_ref) {
|
|
17
|
+
var renderItem = _ref.renderItem,
|
|
18
|
+
_ref$itemHeight = _ref.itemHeight,
|
|
19
|
+
itemHeight = _ref$itemHeight === void 0 ? 40 : _ref$itemHeight,
|
|
20
|
+
_ref$itemClassName = _ref.itemClassName,
|
|
21
|
+
itemClassName = _ref$itemClassName === void 0 ? '' : _ref$itemClassName,
|
|
22
|
+
reloadDeps = _ref.reloadDeps,
|
|
23
|
+
loadPage = _ref.loadPage;
|
|
24
|
+
var containerRef = useRef(null);
|
|
25
|
+
var wrapperRef = useRef(null);
|
|
26
|
+
var _useInfiniteScroll = useInfiniteScroll(loadPage, {
|
|
27
|
+
target: containerRef,
|
|
28
|
+
threshold: 50,
|
|
29
|
+
isNoMore: function isNoMore(d) {
|
|
30
|
+
var _d$list$length, _d$list;
|
|
31
|
+
return ((_d$list$length = d === null || d === void 0 || (_d$list = d.list) === null || _d$list === void 0 ? void 0 : _d$list.length) !== null && _d$list$length !== void 0 ? _d$list$length : 0) >= (d === null || d === void 0 ? void 0 : d.count);
|
|
32
|
+
},
|
|
33
|
+
reloadDeps: reloadDeps
|
|
34
|
+
}),
|
|
35
|
+
data = _useInfiniteScroll.data,
|
|
36
|
+
loading = _useInfiniteScroll.loading,
|
|
37
|
+
noMore = _useInfiniteScroll.noMore;
|
|
38
|
+
var isSkeleton = useMemo(function () {
|
|
39
|
+
return !noMore && loading;
|
|
40
|
+
}, [noMore, loading]);
|
|
41
|
+
var dataList = useMemo(function () {
|
|
42
|
+
return data ? data.list || [] : [];
|
|
43
|
+
}, [data]);
|
|
44
|
+
var _useVirtualList = useVirtualList(dataList, {
|
|
45
|
+
containerTarget: containerRef,
|
|
46
|
+
wrapperTarget: wrapperRef,
|
|
47
|
+
itemHeight: itemHeight,
|
|
48
|
+
overscan: 10
|
|
49
|
+
}),
|
|
50
|
+
_useVirtualList2 = _slicedToArray(_useVirtualList, 2),
|
|
51
|
+
list = _useVirtualList2[0],
|
|
52
|
+
scrollTo = _useVirtualList2[1];
|
|
53
|
+
useUpdateEffect(function () {
|
|
54
|
+
return scrollTo(0);
|
|
55
|
+
}, reloadDeps ? reloadDeps : []);
|
|
56
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "l-c-dynamic-list-layout"
|
|
58
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: "l-c-dynamic-box",
|
|
60
|
+
ref: containerRef
|
|
61
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
ref: wrapperRef
|
|
63
|
+
}, list.map(function (item) {
|
|
64
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
65
|
+
key: item.index,
|
|
66
|
+
style: {
|
|
67
|
+
height: itemHeight
|
|
68
|
+
},
|
|
69
|
+
className: itemClassName
|
|
70
|
+
}, renderItem(item));
|
|
71
|
+
})), isSkeleton && skeletonList.map(function (_, index) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
key: index,
|
|
74
|
+
style: {
|
|
75
|
+
padding: '0 10px',
|
|
76
|
+
height: itemHeight
|
|
77
|
+
},
|
|
78
|
+
className: itemClassName
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Skeleton, {
|
|
80
|
+
paragraph: false,
|
|
81
|
+
loading: true,
|
|
82
|
+
active: true
|
|
83
|
+
}));
|
|
84
|
+
})));
|
|
85
|
+
}
|
|
86
|
+
export default DynamicList;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.l-c-dynamic-list-layout {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
border: 1px solid var(--gray2);
|
|
7
|
+
|
|
8
|
+
.dynamic-list-item {
|
|
9
|
+
padding: 0 10px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.l-c-dynamic-box {
|
|
13
|
+
flex: 1;
|
|
14
|
+
overflow: auto;
|
|
15
|
+
contain: strict;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TData } from '../../useInfiniteScroll';
|
|
2
|
+
export interface IDynamicListProps<T> {
|
|
3
|
+
itemHeight?: number;
|
|
4
|
+
|
|
5
|
+
itemClassName?: string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 重载条件
|
|
9
|
+
*/
|
|
10
|
+
reloadDeps?: any[];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* render列表
|
|
14
|
+
* @param options
|
|
15
|
+
*/
|
|
16
|
+
renderItem(options: { index: number; data: T }): JSX.Element;
|
|
17
|
+
|
|
18
|
+
loadPage(d: TData<T>): Promise<TData<T>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Button, Result } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
function ErrorFallback(_ref) {
|
|
4
|
+
var error = _ref.error,
|
|
5
|
+
resetErrorBoundary = _ref.resetErrorBoundary;
|
|
6
|
+
return /*#__PURE__*/React.createElement(Result, {
|
|
7
|
+
status: "warning",
|
|
8
|
+
title: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, "\u6E32\u67D3\u5931\u8D25\uFF0C\u8BF7\u5237\u65B0\u91CD\u8BD5!"), /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
style: {
|
|
10
|
+
color: 'var(--gray9)',
|
|
11
|
+
fontStyle: 'italic'
|
|
12
|
+
}
|
|
13
|
+
}, error.message)),
|
|
14
|
+
style: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
height: '100%'
|
|
17
|
+
},
|
|
18
|
+
extra: /*#__PURE__*/React.createElement(Button, {
|
|
19
|
+
type: "primary",
|
|
20
|
+
key: "refresh",
|
|
21
|
+
onClick: resetErrorBoundary
|
|
22
|
+
}, "\u70B9\u51FB\u5237\u65B0\uFF0C\u91CD\u8BD5")
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export var errorBoundaryOptions = {
|
|
26
|
+
FallbackComponent: ErrorFallback,
|
|
27
|
+
onReset: function onReset() {
|
|
28
|
+
return window.location.reload();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export default ErrorFallback;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface FallbackProps {
|
|
3
|
+
error: Error;
|
|
4
|
+
resetErrorBoundary: (...args: Array<unknown>) => void;
|
|
5
|
+
}
|
|
6
|
+
interface ErrorBoundaryPropsWithComponent {
|
|
7
|
+
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
8
|
+
onReset?: (...args: Array<unknown>) => void;
|
|
9
|
+
onError?: (
|
|
10
|
+
error: Error,
|
|
11
|
+
info: {
|
|
12
|
+
componentStack: string;
|
|
13
|
+
},
|
|
14
|
+
) => void;
|
|
15
|
+
resetKeys?: Array<unknown>;
|
|
16
|
+
fallback?: never;
|
|
17
|
+
FallbackComponent: React.ComponentType<FallbackProps>;
|
|
18
|
+
fallbackRender?: never;
|
|
19
|
+
}
|
|
20
|
+
interface ErrorBoundaryPropsWithRender {
|
|
21
|
+
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
22
|
+
onReset?: (...args: Array<unknown>) => void;
|
|
23
|
+
onError?: (
|
|
24
|
+
error: Error,
|
|
25
|
+
info: {
|
|
26
|
+
componentStack: string;
|
|
27
|
+
},
|
|
28
|
+
) => void;
|
|
29
|
+
resetKeys?: Array<unknown>;
|
|
30
|
+
fallback?: never;
|
|
31
|
+
FallbackComponent?: never;
|
|
32
|
+
fallbackRender: typeof FallbackRender;
|
|
33
|
+
}
|
|
34
|
+
interface ErrorBoundaryPropsWithFallback {
|
|
35
|
+
onResetKeysChange?: (prevResetKeys: Array<unknown> | undefined, resetKeys: Array<unknown> | undefined) => void;
|
|
36
|
+
onReset?: (...args: Array<unknown>) => void;
|
|
37
|
+
onError?: (
|
|
38
|
+
error: Error,
|
|
39
|
+
info: {
|
|
40
|
+
componentStack: string;
|
|
41
|
+
},
|
|
42
|
+
) => void;
|
|
43
|
+
resetKeys?: Array<unknown>;
|
|
44
|
+
fallback: React.ReactElement<unknown, string | React.FunctionComponent | typeof React.Component> | null;
|
|
45
|
+
FallbackComponent?: never;
|
|
46
|
+
fallbackRender?: never;
|
|
47
|
+
}
|
|
48
|
+
export declare type ErrorBoundaryProps = ErrorBoundaryPropsWithFallback | ErrorBoundaryPropsWithComponent | ErrorBoundaryPropsWithRender;
|