@cloud-app-dev/vidc 4.0.17 → 4.1.0

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.
Files changed (299) hide show
  1. package/.dumirc.ts +1 -1
  2. package/.eslintrc.js +3 -0
  3. package/.fatherrc.ts +0 -6
  4. package/es/AppContext/Sync.d.ts +7 -0
  5. package/es/AppContext/Sync.js +44 -0
  6. package/es/AppContext/index.d.ts +17 -0
  7. package/es/AppContext/index.js +154 -0
  8. package/es/AppContext/interface.d.ts +42 -0
  9. package/es/AppContext/static.d.ts +8 -0
  10. package/es/AppContext/static.js +9 -0
  11. package/es/CheckGroupFixed/demo.d.ts +2 -0
  12. package/es/CheckGroupFixed/demo.js +20 -0
  13. package/es/CheckGroupFixed/index.d.ts +22 -0
  14. package/es/CheckGroupFixed/index.js +150 -0
  15. package/es/CheckGroupFixed/style.d.ts +6 -0
  16. package/es/CheckGroupFixed/style.js +9 -0
  17. package/es/Config/index.d.ts +4 -0
  18. package/es/Config/index.js +77 -0
  19. package/es/Config/interface.d.ts +65 -0
  20. package/es/Config/utils.d.ts +4 -0
  21. package/es/Config/utils.js +33 -0
  22. package/es/CustomRenderSelect/index.d.ts +13 -0
  23. package/es/CustomRenderSelect/index.js +86 -0
  24. package/es/DBTools/index.d.ts +25 -0
  25. package/es/DBTools/index.js +336 -0
  26. package/es/DisableMark/index.d.ts +8 -0
  27. package/es/DisableMark/index.js +25 -0
  28. package/es/DomMove/demo.d.ts +1 -0
  29. package/es/DomMove/demo.js +19 -0
  30. package/es/DomMove/index.d.ts +16 -0
  31. package/es/DomMove/index.js +148 -0
  32. package/es/DomMove/utils.d.ts +8 -0
  33. package/es/DomMove/utils.js +33 -0
  34. package/es/Drag/DragAndDropItem.d.ts +4 -0
  35. package/es/Drag/DragAndDropItem.js +133 -0
  36. package/es/Drag/DropItem.d.ts +4 -0
  37. package/es/Drag/DropItem.js +50 -0
  38. package/es/Drag/index.d.ts +7 -0
  39. package/es/Drag/index.js +7 -0
  40. package/es/Drag/interface.d.ts +16 -0
  41. package/es/DynamicGridList/demo.d.ts +2 -0
  42. package/es/DynamicGridList/demo.js +86 -0
  43. package/es/DynamicGridList/index.d.ts +27 -0
  44. package/es/DynamicGridList/index.js +71 -0
  45. package/es/DynamicList/demo.d.ts +1 -0
  46. package/es/DynamicList/demo.js +45 -0
  47. package/es/DynamicList/index.d.ts +30 -0
  48. package/es/DynamicList/index.js +98 -0
  49. package/es/DynamicList/interface.d.ts +19 -0
  50. package/es/DynamicList/utils.d.ts +4 -0
  51. package/es/DynamicList/utils.js +6 -0
  52. package/es/ErrorFallback/index.d.ts +8 -0
  53. package/es/ErrorFallback/index.js +38 -0
  54. package/es/ErrorFallback/inerface.d.ts +48 -0
  55. package/es/EventTools/index.d.ts +3 -0
  56. package/es/EventTools/index.js +12 -0
  57. package/es/FrontendPlayer/index.d.ts +4 -0
  58. package/es/FrontendPlayer/index.js +2 -0
  59. package/es/GridList/data.d.ts +16 -0
  60. package/es/GridList/data.js +609 -0
  61. package/es/GridList/demo.d.ts +2 -0
  62. package/es/GridList/demo.js +89 -0
  63. package/es/GridList/hook.d.ts +13 -0
  64. package/es/GridList/hook.js +270 -0
  65. package/es/GridList/index.d.ts +14 -0
  66. package/es/GridList/index.js +51 -0
  67. package/es/GridList/interface.d.ts +59 -0
  68. package/es/GridList/utils.d.ts +9 -0
  69. package/es/GridList/utils.js +42 -0
  70. package/es/HightLevel/index.d.ts +8 -0
  71. package/es/HightLevel/index.js +20 -0
  72. package/es/IconFont/index.d.ts +12 -0
  73. package/es/IconFont/index.js +63 -0
  74. package/es/InstanceHistory/index.d.ts +3 -0
  75. package/es/InstanceHistory/index.js +7 -0
  76. package/es/LabelValue/index.d.ts +14 -0
  77. package/es/LabelValue/index.js +35 -0
  78. package/es/List/demo.d.ts +2 -0
  79. package/es/List/demo.js +25 -0
  80. package/es/List/index.d.ts +27 -0
  81. package/es/List/index.js +38 -0
  82. package/es/ListWithSizeAnimate/demo.d.ts +1 -0
  83. package/es/ListWithSizeAnimate/demo.js +128 -0
  84. package/es/ListWithSizeAnimate/index.d.ts +13 -0
  85. package/es/ListWithSizeAnimate/index.js +106 -0
  86. package/es/LoaderScript/index.d.ts +47 -0
  87. package/es/LoaderScript/index.js +38 -0
  88. package/es/LoaderScript/utils.d.ts +13 -0
  89. package/es/LoaderScript/utils.js +179 -0
  90. package/es/Picture/component/DefaultRects/RectInfo.d.ts +7 -0
  91. package/es/Picture/component/DefaultRects/RectInfo.js +90 -0
  92. package/es/Picture/component/DefaultRects/index.d.ts +11 -0
  93. package/es/Picture/component/DefaultRects/index.js +58 -0
  94. package/es/Picture/component/DefaultRects/style.d.ts +10 -0
  95. package/es/Picture/component/DefaultRects/style.js +28 -0
  96. package/es/Picture/component/DefaultRects/utils.d.ts +2 -0
  97. package/es/Picture/component/DefaultRects/utils.js +11 -0
  98. package/es/Picture/component/DrawRect/index.d.ts +11 -0
  99. package/es/Picture/component/DrawRect/index.js +54 -0
  100. package/es/Picture/component/RectMenu/index.d.ts +10 -0
  101. package/es/Picture/component/RectMenu/index.js +84 -0
  102. package/es/Picture/component/RectMenu/utils.d.ts +12 -0
  103. package/es/Picture/component/RectMenu/utils.js +19 -0
  104. package/es/Picture/component/Tools/index.d.ts +11 -0
  105. package/es/Picture/component/Tools/index.js +105 -0
  106. package/es/Picture/component/Tools/style.d.ts +2 -0
  107. package/es/Picture/component/Tools/style.js +5 -0
  108. package/es/Picture/component/WheelScale/index.d.ts +6 -0
  109. package/es/Picture/component/WheelScale/index.js +29 -0
  110. package/es/Picture/demo.d.ts +1 -0
  111. package/es/Picture/demo.js +114 -0
  112. package/es/Picture/index.d.ts +17 -0
  113. package/es/Picture/index.js +356 -0
  114. package/es/Picture/interface.d.ts +196 -0
  115. package/es/Picture/loadCaptureRectImage.d.ts +3 -0
  116. package/es/Picture/loadCaptureRectImage.js +99 -0
  117. package/es/Picture/useDraw.d.ts +1 -0
  118. package/es/Picture/useDraw.js +103 -0
  119. package/es/Picture/utils.d.ts +26 -0
  120. package/es/Picture/utils.js +143 -0
  121. package/es/Player/api/index.d.ts +68 -0
  122. package/es/Player/api/index.js +309 -0
  123. package/es/Player/context.d.ts +21 -0
  124. package/es/Player/context.js +25 -0
  125. package/es/Player/contraller_bar/bar.d.ts +8 -0
  126. package/es/Player/contraller_bar/bar.js +32 -0
  127. package/es/Player/contraller_bar/contraller_event.d.ts +6 -0
  128. package/es/Player/contraller_bar/contraller_event.js +52 -0
  129. package/es/Player/contraller_bar/index.d.ts +13 -0
  130. package/es/Player/contraller_bar/index.js +39 -0
  131. package/es/Player/contraller_bar/left_bar.d.ts +10 -0
  132. package/es/Player/contraller_bar/left_bar.js +97 -0
  133. package/es/Player/contraller_bar/right_bar.d.ts +8 -0
  134. package/es/Player/contraller_bar/right_bar.js +36 -0
  135. package/es/Player/contraller_bar/time.d.ts +2 -0
  136. package/es/Player/contraller_bar/time.js +24 -0
  137. package/es/Player/contraller_bar/useBarStatus.d.ts +2 -0
  138. package/es/Player/contraller_bar/useBarStatus.js +43 -0
  139. package/es/Player/contraller_bar/volume.d.ts +8 -0
  140. package/es/Player/contraller_bar/volume.js +70 -0
  141. package/es/Player/demo.d.ts +2 -0
  142. package/es/Player/demo.js +289 -0
  143. package/es/Player/empty.d.ts +1 -0
  144. package/es/Player/empty.js +5 -0
  145. package/es/Player/event/errorEvent.d.ts +14 -0
  146. package/es/Player/event/errorEvent.js +88 -0
  147. package/es/Player/event/eventName.d.ts +18 -0
  148. package/es/Player/event/eventName.js +30 -0
  149. package/es/Player/event/index.d.ts +24 -0
  150. package/es/Player/event/index.js +205 -0
  151. package/es/Player/fps_play.d.ts +10 -0
  152. package/es/Player/fps_play.js +88 -0
  153. package/es/Player/frontend_player.d.ts +7 -0
  154. package/es/Player/frontend_player.js +71 -0
  155. package/es/Player/frontend_timeline.d.ts +8 -0
  156. package/es/Player/frontend_timeline.js +153 -0
  157. package/es/Player/iconfont.d.ts +4 -0
  158. package/es/Player/iconfont.js +21 -0
  159. package/es/Player/index.d.ts +2 -0
  160. package/es/Player/index.js +2 -0
  161. package/es/Player/live_heart.d.ts +8 -0
  162. package/es/Player/live_heart.js +45 -0
  163. package/es/Player/message.d.ts +3 -0
  164. package/es/Player/message.js +147 -0
  165. package/es/Player/player.d.ts +233 -0
  166. package/es/Player/segment_player.d.ts +8 -0
  167. package/es/Player/segment_player.js +229 -0
  168. package/es/Player/segment_timeline.d.ts +10 -0
  169. package/es/Player/segment_timeline.js +200 -0
  170. package/es/Player/single_player.d.ts +4 -0
  171. package/es/Player/single_player.js +278 -0
  172. package/es/Player/style/iconfont.js +43 -0
  173. package/es/Player/timeline.d.ts +7 -0
  174. package/es/Player/timeline.js +104 -0
  175. package/es/Player/util.d.ts +43 -0
  176. package/es/Player/util.js +189 -0
  177. package/es/PlayerExt/demo.d.ts +2 -0
  178. package/es/PlayerExt/demo.js +170 -0
  179. package/es/PlayerExt/index.d.ts +47 -0
  180. package/es/PlayerExt/index.js +212 -0
  181. package/es/Progress/index.d.ts +10 -0
  182. package/es/Progress/index.js +60 -0
  183. package/es/ROI/demo.d.ts +2 -0
  184. package/es/ROI/demo.js +17 -0
  185. package/es/ROI/index.d.ts +32 -0
  186. package/es/ROI/index.js +67 -0
  187. package/es/RefDrawer/Footer.d.ts +9 -0
  188. package/es/RefDrawer/Footer.js +27 -0
  189. package/es/RefDrawer/demo.d.ts +3 -0
  190. package/es/RefDrawer/demo.js +32 -0
  191. package/es/RefDrawer/index.d.ts +26 -0
  192. package/es/RefDrawer/index.js +73 -0
  193. package/es/RefModal/demo.d.ts +2 -0
  194. package/es/RefModal/demo.js +32 -0
  195. package/es/RefModal/index.d.ts +17 -0
  196. package/es/RefModal/index.js +71 -0
  197. package/es/ScreenPlayer/Live.d.ts +8 -0
  198. package/es/ScreenPlayer/Live.js +219 -0
  199. package/es/ScreenPlayer/LiveTools.d.ts +33 -0
  200. package/es/ScreenPlayer/LiveTools.js +172 -0
  201. package/es/ScreenPlayer/PlayerWithExt.d.ts +34 -0
  202. package/es/ScreenPlayer/PlayerWithExt.js +241 -0
  203. package/es/ScreenPlayer/RatePick.d.ts +7 -0
  204. package/es/ScreenPlayer/RatePick.js +35 -0
  205. package/es/ScreenPlayer/Record.d.ts +8 -0
  206. package/es/ScreenPlayer/Record.js +452 -0
  207. package/es/ScreenPlayer/RecordTools.d.ts +38 -0
  208. package/es/ScreenPlayer/RecordTools.js +214 -0
  209. package/es/ScreenPlayer/ScreenSelect.d.ts +6 -0
  210. package/es/ScreenPlayer/ScreenSelect.js +59 -0
  211. package/es/ScreenPlayer/SegmentTimeLine.d.ts +16 -0
  212. package/es/ScreenPlayer/SegmentTimeLine.js +44 -0
  213. package/es/ScreenPlayer/TimeMode.d.ts +6 -0
  214. package/es/ScreenPlayer/TimeMode.js +34 -0
  215. package/es/ScreenPlayer/TimeSelect.d.ts +6 -0
  216. package/es/ScreenPlayer/TimeSelect.js +99 -0
  217. package/es/ScreenPlayer/containerStyle.d.ts +13 -0
  218. package/es/ScreenPlayer/containerStyle.js +32 -0
  219. package/es/ScreenPlayer/demo.d.ts +1 -0
  220. package/es/ScreenPlayer/demo.js +19 -0
  221. package/es/ScreenPlayer/demo2.d.ts +1 -0
  222. package/es/ScreenPlayer/demo2.js +196 -0
  223. package/es/ScreenPlayer/index.d.ts +6 -0
  224. package/es/ScreenPlayer/index.js +9 -0
  225. package/es/ScreenPlayer/interface.d.ts +216 -0
  226. package/es/ScreenPlayer/useTimeSlider.d.ts +25 -0
  227. package/es/ScreenPlayer/useTimeSlider.js +451 -0
  228. package/es/ScreenPlayer/useVideoFit.d.ts +5 -0
  229. package/es/ScreenPlayer/useVideoFit.js +35 -0
  230. package/es/ScreenPlayer/utils.d.ts +17 -0
  231. package/es/ScreenPlayer/utils.js +85 -0
  232. package/es/SegmentPlayer/index.d.ts +2 -0
  233. package/es/SegmentPlayer/index.js +2 -0
  234. package/es/Service/http.d.ts +6 -0
  235. package/es/Service/http.js +125 -0
  236. package/es/Service/index.d.ts +3 -0
  237. package/es/Service/index.js +10 -0
  238. package/es/Service/interface.d.ts +22 -0
  239. package/es/Service/middleware.d.ts +5 -0
  240. package/es/Service/middleware.js +15 -0
  241. package/es/SocketEmitter/eventEmitter.d.ts +27 -0
  242. package/es/SocketEmitter/eventEmitter.js +88 -0
  243. package/es/SocketEmitter/index.d.ts +24 -0
  244. package/es/SocketEmitter/index.js +125 -0
  245. package/es/SocketEmitter/interface.d.ts +4 -0
  246. package/es/TableLayout/index.d.ts +9 -0
  247. package/es/TableLayout/index.js +32 -0
  248. package/es/Timeout/index.d.ts +31 -0
  249. package/es/Timeout/index.js +69 -0
  250. package/es/cache/index.d.ts +34 -0
  251. package/es/cache/index.js +94 -0
  252. package/es/copy/index.d.ts +1 -0
  253. package/es/copy/index.js +9 -0
  254. package/es/core.d.ts +0 -0
  255. package/es/getThemeStyle/index.d.ts +2 -0
  256. package/es/getThemeStyle/index.js +5 -0
  257. package/es/index.d.ts +52 -0
  258. package/es/index.js +52 -0
  259. package/es/likeGo/index.d.ts +2 -0
  260. package/es/likeGo/index.js +31 -0
  261. package/es/likeGoSync/index.d.ts +2 -0
  262. package/es/likeGoSync/index.js +10 -0
  263. package/es/logger/index.d.ts +7 -0
  264. package/es/logger/index.js +30 -0
  265. package/es/nextTick/index.d.ts +1 -0
  266. package/es/nextTick/index.js +3 -0
  267. package/es/recorder/demo.d.ts +2 -0
  268. package/es/recorder/demo.js +200 -0
  269. package/es/recorder/index.d.ts +294 -0
  270. package/es/recorder/index.js +991 -0
  271. package/es/submidstr/index.d.ts +5 -0
  272. package/es/submidstr/index.js +14 -0
  273. package/es/treeHelper/index.d.ts +11 -0
  274. package/es/treeHelper/index.js +189 -0
  275. package/es/typings.d.ts +2 -0
  276. package/es/useDrawROI/index.d.ts +16 -0
  277. package/es/useDrawROI/index.js +318 -0
  278. package/es/useEventEmitterHandle/index.d.ts +2 -0
  279. package/es/useEventEmitterHandle/index.js +17 -0
  280. package/es/useHistory/index.d.ts +3 -0
  281. package/es/useHistory/index.js +9 -0
  282. package/es/useHistory/interface.d.ts +3 -0
  283. package/es/useInfiniteScroll/index.d.ts +16 -0
  284. package/es/useInfiniteScroll/index.js +102 -0
  285. package/es/useRafInterval/index.d.ts +5 -0
  286. package/es/useRafInterval/index.js +70 -0
  287. package/es/useSimpleState/index.d.ts +3 -0
  288. package/es/useSimpleState/index.js +35 -0
  289. package/es/useVirtualList/index.d.ts +13 -0
  290. package/es/useVirtualList/index.js +136 -0
  291. package/es/utils.d.ts +14 -0
  292. package/es/utils.js +46 -0
  293. package/es/uuid/index.d.ts +5 -0
  294. package/es/uuid/index.js +6 -0
  295. package/package.json +16 -21
  296. package/release-build.sh +2 -0
  297. package/scripts/{entry.js → entry.mjs} +4 -6
  298. package/{icon-fix.js → scripts/icon-fix.mjs} +4 -3
  299. package/tsconfig.json +1 -1
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { PositionType, SizeType } from '../Picture/interface';
3
+ interface IDomMoveProps {
4
+ children: React.ReactNode;
5
+ onDrag?: (e: MouseEvent, position: PositionType) => void;
6
+ onDragChange?: (position: PositionType) => void;
7
+ onDragEnd?: (e: MouseEvent, position: PositionType) => void;
8
+ position?: PositionType;
9
+ size?: SizeType;
10
+ disabled?: boolean;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ forwordRef?: React.MutableRefObject<any>;
14
+ }
15
+ declare const _default: React.ForwardRefExoticComponent<IDomMoveProps & React.RefAttributes<unknown>>;
16
+ export default _default;
@@ -0,0 +1,148 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ 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); }
7
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
8
+ import { useEventListener, useSize, useUpdate } from 'ahooks';
9
+ import React, { useEffect, useImperativeHandle, useRef } from 'react';
10
+ import { getMouseXY, getPosition } from "./utils";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ function DomMove(_ref) {
13
+ var onDrag = _ref.onDrag,
14
+ position = _ref.position,
15
+ className = _ref.className,
16
+ size = _ref.size,
17
+ children = _ref.children,
18
+ onDragChange = _ref.onDragChange,
19
+ onDragEnd = _ref.onDragEnd,
20
+ forwordRef = _ref.forwordRef,
21
+ disabled = _ref.disabled;
22
+ var dragRef = useRef(null);
23
+ var ref = useRef({
24
+ position: {
25
+ x: 0,
26
+ y: 0
27
+ },
28
+ DA: {
29
+ x: 0,
30
+ y: 0
31
+ },
32
+ isDrag: false,
33
+ deviation: {
34
+ offsetX: 0,
35
+ offsetY: 0,
36
+ width: 0,
37
+ height: 0
38
+ }
39
+ });
40
+ var reSize = useSize(dragRef) || {};
41
+ var update = useUpdate();
42
+ var updatePosition = function updatePosition(_ref2) {
43
+ var x = _ref2.x,
44
+ y = _ref2.y;
45
+ ref.current.position = {
46
+ x: x,
47
+ y: y
48
+ };
49
+ update();
50
+ onDragChange === null || onDragChange === void 0 ? void 0 : onDragChange({
51
+ x: x,
52
+ y: y
53
+ });
54
+ };
55
+ useEffect(function () {
56
+ var offset = getPosition(dragRef === null || dragRef === void 0 ? void 0 : dragRef.current);
57
+ ref.current.deviation = {
58
+ offsetX: offset.left,
59
+ offsetY: offset.top,
60
+ width: reSize.width,
61
+ height: reSize.height
62
+ };
63
+ }, [reSize.width, reSize.height]);
64
+
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ useImperativeHandle(forwordRef, function () {
67
+ return {
68
+ updatePosition: updatePosition
69
+ };
70
+ }, []);
71
+ useEventListener('mousemove', function (event) {
72
+ if (ref.current.isDrag) {
73
+ // let maxX, maxY;
74
+ var moveX, moveY;
75
+ var _getMouseXY = getMouseXY(event),
76
+ _x = _getMouseXY.x,
77
+ _y = _getMouseXY.y;
78
+ moveX = _x - ref.current.deviation.offsetX;
79
+ moveY = _y - ref.current.deviation.offsetY;
80
+
81
+ // 计算可移动位置的大小, 保证元素不会超过可移动范围
82
+ // maxX = document.documentElement.clientWidth - this.deviation.width;
83
+ // maxY = document.documentElement.clientHeight - this.deviation.height;
84
+
85
+ // min方法保证不会超过右边界,max保证不会超过左边界
86
+ // moveX = Math.min(Math.max(0, moveX), maxX);
87
+ // moveY = Math.min(Math.max(0, moveY), maxY);
88
+ var _position = {
89
+ x: moveX,
90
+ y: moveY
91
+ };
92
+ onDrag ? onDrag(event, _position) : updatePosition(_position);
93
+ }
94
+ }, {
95
+ target: document.body
96
+ });
97
+ useEventListener('mouseup', function (event) {
98
+ if (ref.current.isDrag) {
99
+ ref.current.isDrag = false;
100
+ onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(event, ref.current.position);
101
+ }
102
+ }, {
103
+ target: document.body
104
+ });
105
+ useEventListener('mousedown', function (event) {
106
+ if (!disabled) {
107
+ var _getMouseXY2 = getMouseXY(event),
108
+ _x2 = _getMouseXY2.x,
109
+ _y2 = _getMouseXY2.y;
110
+ ref.current.deviation.offsetX = _x2 - ref.current.position.x;
111
+ ref.current.deviation.offsetY = _y2 - ref.current.position.y;
112
+ ref.current.isDrag = true;
113
+ }
114
+ }, {
115
+ target: dragRef
116
+ });
117
+ var _ref3 = onDrag ? {
118
+ x: position === null || position === void 0 ? void 0 : position.x,
119
+ y: position === null || position === void 0 ? void 0 : position.y
120
+ } : {
121
+ x: ref.current.position.x,
122
+ y: ref.current.position.y
123
+ },
124
+ x = _ref3.x,
125
+ y = _ref3.y;
126
+ return /*#__PURE__*/_jsx("div", {
127
+ ref: dragRef,
128
+ className: "drag-move-Content ".concat(className),
129
+ style: {
130
+ transform: "translate(".concat(x, "px,").concat(y, "px)"),
131
+ width: size === null || size === void 0 ? void 0 : size.width,
132
+ height: size === null || size === void 0 ? void 0 : size.height
133
+ },
134
+ children: children
135
+ });
136
+ }
137
+ DomMove.defaultProps = {
138
+ className: '',
139
+ size: {
140
+ width: '100%',
141
+ height: '100%'
142
+ }
143
+ };
144
+ export default /*#__PURE__*/React.forwardRef(function (props, ref) {
145
+ return /*#__PURE__*/_jsx(DomMove, _objectSpread(_objectSpread({}, props), {}, {
146
+ forwordRef: ref
147
+ }));
148
+ });
@@ -0,0 +1,8 @@
1
+ export declare function getPosition(obj: any): {
2
+ left: any;
3
+ top: any;
4
+ };
5
+ export declare function getMouseXY(e: MouseEvent): {
6
+ x: number;
7
+ y: number;
8
+ };
@@ -0,0 +1,33 @@
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
+
12
+ return {
13
+ left: l,
14
+ top: t
15
+ };
16
+ }
17
+ // 函数用于获取鼠标的位置
18
+ export function getMouseXY(e) {
19
+ var x = 0,
20
+ y = 0;
21
+ e = e || window.event;
22
+ if (e.pageX) {
23
+ x = e.pageX;
24
+ y = e.pageY;
25
+ } else {
26
+ x = e.clientX + document.body.scrollLeft - document.body.clientLeft;
27
+ y = e.clientY + document.body.scrollTop - document.body.clientTop;
28
+ }
29
+ return {
30
+ x: x,
31
+ y: y
32
+ };
33
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { IDragAndDropItemProps } from './interface';
3
+ declare function DragAndDropItem<T>({ children, dragData, dragId, style, onDropEnd, disabledCopyElement }: IDragAndDropItemProps<T>): React.FunctionComponentElement<any>;
4
+ export default DragAndDropItem;
@@ -0,0 +1,133 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ 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); }
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
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,4 @@
1
+ import React from 'react';
2
+ import { IDropItemProps } from './interface';
3
+ declare function DropItem<T>({ children, style, onDropEnd }: IDropItemProps<T>): React.FunctionComponentElement<any>;
4
+ export default DropItem;
@@ -0,0 +1,50 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ 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); }
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
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,7 @@
1
+ import DragAndDropItem from './DragAndDropItem';
2
+ import DropItem from './DropItem';
3
+ declare const Drag: {
4
+ DragAndDropItem: typeof DragAndDropItem;
5
+ DropItem: typeof DropItem;
6
+ };
7
+ export default Drag;
@@ -0,0 +1,7 @@
1
+ import DragAndDropItem from "./DragAndDropItem";
2
+ import DropItem from "./DropItem";
3
+ var Drag = {
4
+ DragAndDropItem: DragAndDropItem,
5
+ DropItem: DropItem
6
+ };
7
+ export default Drag;
@@ -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,2 @@
1
+ declare const App: () => import("react/jsx-runtime").JSX.Element;
2
+ export default App;
@@ -0,0 +1,86 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ function random(low, high) {
13
+ return Math.floor(Math.random() * high) + low;
14
+ }
15
+ var IMAGES = function IMAGES() {
16
+ return Array.from({
17
+ length: 20
18
+ }, function (_, index) {
19
+ var width = 300;
20
+ var height = random(200, 300);
21
+ return {
22
+ url: "https://picsum.photos/id/".concat(index + 1, "/").concat(width, "/").concat(height, ".jpg"),
23
+ width: width,
24
+ height: height
25
+ };
26
+ });
27
+ };
28
+ function loadPage(d) {
29
+ if (!d) {
30
+ // eslint-disable-next-line no-param-reassign
31
+ d = {};
32
+ }
33
+ var resultData = IMAGES();
34
+ d.page ? d.page++ : d.page = 1;
35
+ d.list ? d.list = [].concat(_toConsumableArray(d.list), _toConsumableArray(resultData)) : d.list = resultData;
36
+ return new Promise(function (resolve) {
37
+ console.log(d.page);
38
+ setTimeout(function () {
39
+ return resolve(d);
40
+ }, 10);
41
+ });
42
+ }
43
+ var App = function App() {
44
+ return /*#__PURE__*/_jsx("div", {
45
+ style: {
46
+ height: 400
47
+ },
48
+ children: /*#__PURE__*/_jsx(GridList, {
49
+ itemKey: "url",
50
+ itemHeight: 400,
51
+ itemWidth: 250,
52
+ renderItem: function renderItem(image) {
53
+ return /*#__PURE__*/_jsxs("div", {
54
+ style: {
55
+ border: '1px solid gray',
56
+ height: '100%',
57
+ display: 'flex',
58
+ flexDirection: 'column'
59
+ },
60
+ children: [/*#__PURE__*/_jsx("div", {
61
+ style: {
62
+ flex: 1,
63
+ overflow: 'hidden'
64
+ },
65
+ children: /*#__PURE__*/_jsx("img", {
66
+ src: image.url,
67
+ alt: "",
68
+ style: {
69
+ objectFit: 'cover',
70
+ display: 'block',
71
+ width: '100%',
72
+ height: '100%'
73
+ }
74
+ })
75
+ }), /*#__PURE__*/_jsx("p", {
76
+ children: "\u6807\u9898"
77
+ }), /*#__PURE__*/_jsx("p", {
78
+ children: "\u63CF\u8FF0"
79
+ })]
80
+ });
81
+ },
82
+ loadPage: loadPage
83
+ })
84
+ });
85
+ };
86
+ export default App;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { GridListCell } from '../GridList/interface';
3
+ import { TData } from '../useInfiniteScroll';
4
+ export interface IDynamicGridListProps<T> {
5
+ itemHeight?: number;
6
+ className?: string;
7
+ /**
8
+ * 重载条件
9
+ */
10
+ reloadDeps?: any[];
11
+ /**
12
+ * render列表
13
+ * @param options
14
+ */
15
+ renderItem: (item: T, cell: GridListCell<T>) => React.ReactNode;
16
+ loadPage(d?: TData<T>): Promise<TData<T>>;
17
+ itemWidth?: number;
18
+ itemKey: string;
19
+ getGridGap?: (...args: any) => number;
20
+ isNoMore?: (data?: TData<T>) => boolean;
21
+ threshold?: number;
22
+ }
23
+ declare function DynamicGridList<T>({ renderItem, itemHeight, itemKey, itemWidth, reloadDeps, getGridGap, loadPage, isNoMore, threshold, ...props }: IDynamicGridListProps<T>): import("react/jsx-runtime").JSX.Element;
24
+ declare namespace DynamicGridList {
25
+ var defaultProps: any;
26
+ }
27
+ export default DynamicGridList;
@@ -0,0 +1,71 @@
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
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ function DynamicGridList(_ref) {
10
+ var renderItem = _ref.renderItem,
11
+ itemHeight = _ref.itemHeight,
12
+ itemKey = _ref.itemKey,
13
+ itemWidth = _ref.itemWidth,
14
+ reloadDeps = _ref.reloadDeps,
15
+ getGridGap = _ref.getGridGap,
16
+ loadPage = _ref.loadPage,
17
+ isNoMore = _ref.isNoMore,
18
+ threshold = _ref.threshold,
19
+ props = _objectWithoutProperties(_ref, _excluded);
20
+ var containerRef = useRef(null);
21
+ var _useInfiniteScroll = useInfiniteScroll(loadPage, {
22
+ target: containerRef,
23
+ threshold: threshold,
24
+ isNoMore: isNoMore,
25
+ reloadDeps: reloadDeps
26
+ }),
27
+ data = _useInfiniteScroll.data,
28
+ noMore = _useInfiniteScroll.noMore;
29
+ useUpdateEffect(function () {
30
+ if (noMore) {
31
+ console.warn('数据已全部加载完成');
32
+ }
33
+ }, [noMore]);
34
+ function getItemData(data) {
35
+ return {
36
+ key: data[itemKey],
37
+ height: itemHeight,
38
+ width: itemWidth
39
+ };
40
+ }
41
+ function getColumnCount(elementWidth, gridGap) {
42
+ return Math.floor((elementWidth + gridGap) / ((itemWidth !== null && itemWidth !== void 0 ? itemWidth : 0) + gridGap));
43
+ }
44
+ function getWindowMargin(windowHeight) {
45
+ return Math.round(windowHeight * 1.5);
46
+ }
47
+ var dataList = useMemo(function () {
48
+ return data ? data.list || [] : [];
49
+ }, [data]);
50
+ return /*#__PURE__*/_jsx(GridList, {
51
+ className: "dynamic-grid-list ".concat(props.className),
52
+ items: dataList,
53
+ ref: containerRef,
54
+ getItemData: getItemData,
55
+ getColumnCount: getColumnCount,
56
+ getWindowMargin: getWindowMargin,
57
+ renderItem: renderItem,
58
+ getGridGap: getGridGap
59
+ });
60
+ }
61
+ DynamicGridList.defaultProps = {
62
+ reloadDeps: [],
63
+ className: '',
64
+ getGridGap: function getGridGap() {
65
+ return 20;
66
+ },
67
+ itemHeight: 300,
68
+ itemWidth: 250,
69
+ threshold: 50
70
+ };
71
+ export default DynamicGridList;
@@ -0,0 +1 @@
1
+ export default function (): import("react/jsx-runtime").JSX.Element;