fan-standard-comp 3.2.1 → 3.2.3

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 (293) hide show
  1. package/Readme.md +2 -32
  2. package/dist/09cd8e9be7081f2166444cce393fe968.svg +54 -0
  3. package/dist/e3378c145b7db195ad068735e15fb28a.svg +165 -0
  4. package/dist/fan-standard-comp.umd.js +183 -439
  5. package/dist/fonts/iconfont.ttf +0 -0
  6. package/dist/fonts/iconfont.woff +0 -0
  7. package/dist/fonts/lg.ttf +0 -0
  8. package/dist/fonts/lg.woff +0 -0
  9. package/dist/fonts/lg.woff2 +0 -0
  10. package/es/ButtonGroup/ButtonList.d.ts +2 -1
  11. package/es/ButtonGroup/ButtonMenu.d.ts +2 -1
  12. package/es/ButtonGroup/PopConfirmTitle.js +5 -5
  13. package/es/ButtonGroup/index.d.ts +3 -1
  14. package/es/ButtonGroup/index.js +146 -180
  15. package/es/ButtonGroup/style/index.less +4 -1
  16. package/es/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
  17. package/es/CalendarCoordPicker/CalendarMonthPicker.js +26 -0
  18. package/es/CalendarCoordPicker/index.d.ts +8 -0
  19. package/es/CalendarCoordPicker/index.js +296 -0
  20. package/es/CalendarCoordPicker/index.less +31 -0
  21. package/es/ConfigContext/index.d.ts +7 -0
  22. package/es/ConfigContext/index.js +12 -0
  23. package/es/DragContent/index.d.ts +1 -1
  24. package/es/DragContent/index.js +5 -5
  25. package/es/FormComp/ChunkUploader/api.js +14 -14
  26. package/es/FormComp/ChunkUploader/index.js +132 -139
  27. package/es/FormComp/ChunkUploader/lib.js +21 -21
  28. package/es/FormComp/ChunkUploader/upload-queue.class.js +64 -66
  29. package/es/FormComp/EditButton/index.d.ts +1 -1
  30. package/es/FormComp/EditButton/index.js +15 -17
  31. package/es/FormComp/FieldComponent/ReUpload.d.ts +1 -1
  32. package/es/FormComp/FieldComponent/ReUpload.js +37 -23
  33. package/es/FormComp/FieldComponent/RefactorTextarea.js +32 -0
  34. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +72 -19
  35. package/es/FormComp/FieldComponent/TitleNode.d.ts +2 -1
  36. package/es/FormComp/FieldComponent/index.d.ts +1 -1
  37. package/es/FormComp/FieldComponent/index.js +37 -26
  38. package/es/FormComp/FieldComponent/setReadonlyValues.js +6 -6
  39. package/es/FormComp/RenderItemGroup/index.js +24 -8
  40. package/es/FormComp/Uploader/index.d.ts +9 -2
  41. package/es/FormComp/Uploader/index.js +325 -156
  42. package/es/FormComp/VarTemplate/index.js +57 -64
  43. package/es/ImageGallery/ImagePreview.d.ts +13 -0
  44. package/es/ImageGallery/ImagePreview.js +168 -0
  45. package/es/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
  46. package/es/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
  47. package/es/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
  48. package/es/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
  49. package/es/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
  50. package/es/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
  51. package/es/ImageGallery/PreviewStyles/lg-video.css +144 -0
  52. package/es/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
  53. package/es/ImageGallery/PreviewStyles/lightgallery.css +728 -0
  54. package/es/ImageGallery/SliderContent.d.ts +7 -0
  55. package/es/ImageGallery/SliderContent.js +699 -0
  56. package/es/ImageGallery/Thumbnail.d.ts +3 -0
  57. package/es/ImageGallery/Thumbnail.js +296 -0
  58. package/es/ImageGallery/hook/uniqueId.d.ts +1 -0
  59. package/es/ImageGallery/hook/uniqueId.js +10 -0
  60. package/es/ImageGallery/index.d.ts +4 -0
  61. package/es/ImageGallery/index.js +29 -0
  62. package/es/ImageGallery/style/index.less +5 -0
  63. package/es/ImageGallery/types.d.ts +5 -0
  64. package/es/ImageGallery/types.js +1 -0
  65. package/es/NavLeafScroll/index.js +94 -50
  66. package/es/RefactorTree/index.d.ts +1 -1
  67. package/es/RefactorTree/index.js +6 -6
  68. package/es/RefactorTree/indexTreeNode.d.ts +1 -1
  69. package/es/RefactorTree/indexTreeNode.js +19 -17
  70. package/es/RefactorTree/util.js +18 -18
  71. package/es/SpecIcon/fonts/demo_index.html +559 -5
  72. package/es/SpecIcon/fonts/iconfont.css +101 -3
  73. package/es/SpecIcon/fonts/iconfont.js +34 -27
  74. package/es/SpecIcon/fonts/iconfont.json +168 -0
  75. package/es/SpecIcon/fonts/iconfont.svg +163 -171
  76. package/es/SpecIcon/fonts/iconfont.ttf +0 -0
  77. package/es/SpecIcon/fonts/iconfont.woff +0 -0
  78. package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
  79. package/es/SpecIcon/style/iconfont.less +106 -11
  80. package/es/SplitterLayout/Pane.d.ts +1 -1
  81. package/es/SplitterLayout/index.js +25 -26
  82. package/es/StandardContent/SplitterLayout/Pane.js +3 -3
  83. package/es/StandardContent/SplitterLayout/index.js +25 -26
  84. package/es/StandardContent/SubfieldContent.d.ts +1 -1
  85. package/es/StandardContent/WrapperContent.d.ts +1 -1
  86. package/es/StandardDragModal/index.d.ts +11 -3
  87. package/es/StandardDragModal/index.js +25 -3
  88. package/es/StandardFilter/index.d.ts +5 -16
  89. package/es/StandardFilter/index.js +212 -200
  90. package/es/StandardFilter/indexClass.d.ts +37 -0
  91. package/es/StandardFilter/indexClass.js +217 -0
  92. package/es/StandardFilter/style/index.less +82 -9
  93. package/es/StandardForm/StepForm.d.ts +1 -1
  94. package/es/StandardForm/StepForm.js +28 -22
  95. package/es/StandardForm/TabForm.d.ts +1 -1
  96. package/es/StandardForm/TabForm.js +41 -43
  97. package/es/StandardForm/index.d.ts +1 -1
  98. package/es/StandardForm/index.js +5 -5
  99. package/es/StandardModal/UpdateFormRef.js +0 -1
  100. package/es/StandardModal/index.d.ts +2 -1
  101. package/es/StandardModal/index.js +25 -39
  102. package/es/StandardPanel/index.d.ts +1 -1
  103. package/es/StandardPanel/index.js +7 -7
  104. package/es/StandardTable/index.d.ts +1 -0
  105. package/es/StandardTable/index.js +44 -26
  106. package/es/components/IconNode/index.d.ts +1 -1
  107. package/es/components/IconNode/index.js +0 -1
  108. package/es/data/general.config.js +31 -0
  109. package/es/index.d.ts +3 -1
  110. package/es/index.js +6 -2
  111. package/es/utils/filterPermission.js +7 -10
  112. package/es/utils/getParentNodes.js +101 -26
  113. package/es/utils/index.js +2 -3
  114. package/es/utils/urlUtils.js +76 -0
  115. package/lib/ButtonGroup/ButtonList.d.ts +2 -1
  116. package/lib/ButtonGroup/ButtonList.js +2 -3
  117. package/lib/ButtonGroup/ButtonMenu.d.ts +2 -1
  118. package/lib/ButtonGroup/ButtonMenu.js +2 -3
  119. package/lib/ButtonGroup/PopConfirmTitle.js +7 -8
  120. package/lib/ButtonGroup/index.d.ts +3 -1
  121. package/lib/ButtonGroup/index.js +150 -185
  122. package/lib/ButtonGroup/style/index.less +4 -1
  123. package/lib/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
  124. package/lib/CalendarCoordPicker/CalendarMonthPicker.js +36 -0
  125. package/lib/CalendarCoordPicker/index.d.ts +8 -0
  126. package/lib/CalendarCoordPicker/index.js +305 -0
  127. package/lib/CalendarCoordPicker/index.less +31 -0
  128. package/lib/ConfigContext/index.d.ts +7 -0
  129. package/lib/ConfigContext/index.js +17 -0
  130. package/lib/DragContent/DragBar.js +2 -3
  131. package/lib/DragContent/index.d.ts +1 -1
  132. package/lib/DragContent/index.js +9 -10
  133. package/lib/FormComp/ChunkUploader/api.js +15 -15
  134. package/lib/FormComp/ChunkUploader/index.js +135 -142
  135. package/lib/FormComp/ChunkUploader/lib.js +22 -22
  136. package/lib/FormComp/ChunkUploader/upload-queue.class.js +66 -69
  137. package/lib/FormComp/ChunkUploader/worker.js +1 -1
  138. package/lib/FormComp/EditButton/index.d.ts +1 -1
  139. package/lib/FormComp/EditButton/index.js +19 -22
  140. package/lib/FormComp/FieldComponent/ReUpload.d.ts +1 -1
  141. package/lib/FormComp/FieldComponent/ReUpload.js +40 -28
  142. package/lib/FormComp/FieldComponent/RefactorTextarea.js +42 -0
  143. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +75 -23
  144. package/lib/FormComp/FieldComponent/TitleNode.d.ts +2 -1
  145. package/lib/FormComp/FieldComponent/TitleNode.js +2 -3
  146. package/lib/FormComp/FieldComponent/index.d.ts +1 -1
  147. package/lib/FormComp/FieldComponent/index.js +41 -28
  148. package/lib/FormComp/FieldComponent/setReadonlyValues.js +15 -20
  149. package/lib/FormComp/RenderItemGroup/index.js +26 -11
  150. package/lib/FormComp/Uploader/index.d.ts +9 -2
  151. package/lib/FormComp/Uploader/index.js +325 -159
  152. package/lib/FormComp/VarTemplate/index.js +63 -71
  153. package/lib/FormComp/index.js +1 -1
  154. package/lib/ImageGallery/ImagePreview.d.ts +13 -0
  155. package/lib/ImageGallery/ImagePreview.js +178 -0
  156. package/lib/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
  157. package/lib/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
  158. package/lib/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
  159. package/lib/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
  160. package/lib/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
  161. package/lib/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
  162. package/lib/ImageGallery/PreviewStyles/lg-video.css +144 -0
  163. package/lib/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
  164. package/lib/ImageGallery/PreviewStyles/lightgallery.css +728 -0
  165. package/lib/ImageGallery/SliderContent.d.ts +7 -0
  166. package/lib/ImageGallery/SliderContent.js +708 -0
  167. package/lib/ImageGallery/Thumbnail.d.ts +3 -0
  168. package/lib/ImageGallery/Thumbnail.js +306 -0
  169. package/lib/ImageGallery/hook/uniqueId.d.ts +1 -0
  170. package/lib/ImageGallery/hook/uniqueId.js +17 -0
  171. package/lib/ImageGallery/index.d.ts +4 -0
  172. package/lib/ImageGallery/index.js +36 -0
  173. package/lib/ImageGallery/style/index.less +5 -0
  174. package/lib/ImageGallery/types.d.ts +5 -0
  175. package/lib/ImageGallery/types.js +5 -0
  176. package/lib/NavLeafScroll/index.js +98 -55
  177. package/lib/RefactorTree/index.d.ts +1 -1
  178. package/lib/RefactorTree/index.js +10 -11
  179. package/lib/RefactorTree/indexTreeNode.d.ts +1 -1
  180. package/lib/RefactorTree/indexTreeNode.js +23 -22
  181. package/lib/RefactorTree/util.js +18 -18
  182. package/lib/SpecIcon/fonts/demo_index.html +559 -5
  183. package/lib/SpecIcon/fonts/iconfont.css +101 -3
  184. package/lib/SpecIcon/fonts/iconfont.js +34 -27
  185. package/lib/SpecIcon/fonts/iconfont.json +168 -0
  186. package/lib/SpecIcon/fonts/iconfont.svg +163 -171
  187. package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
  188. package/lib/SpecIcon/fonts/iconfont.woff +0 -0
  189. package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
  190. package/lib/SpecIcon/index.js +2 -3
  191. package/lib/SpecIcon/style/iconfont.less +106 -11
  192. package/lib/SplitterLayout/Pane.d.ts +1 -1
  193. package/lib/SplitterLayout/Pane.js +2 -3
  194. package/lib/SplitterLayout/index.js +27 -29
  195. package/lib/StandardContent/SplitterLayout/Pane.js +5 -6
  196. package/lib/StandardContent/SplitterLayout/index.js +27 -29
  197. package/lib/StandardContent/SubfieldContent.d.ts +1 -1
  198. package/lib/StandardContent/SubfieldContent.js +2 -3
  199. package/lib/StandardContent/WrapperContent.d.ts +1 -1
  200. package/lib/StandardContent/WrapperContent.js +2 -3
  201. package/lib/StandardDragModal/index.d.ts +11 -3
  202. package/lib/StandardDragModal/index.js +27 -33
  203. package/lib/StandardFilter/index.d.ts +5 -16
  204. package/lib/StandardFilter/index.js +215 -201
  205. package/lib/StandardFilter/indexClass.d.ts +37 -0
  206. package/lib/StandardFilter/indexClass.js +223 -0
  207. package/lib/StandardFilter/style/index.less +82 -9
  208. package/lib/StandardForm/ActionList.js +2 -3
  209. package/lib/StandardForm/StepForm.d.ts +1 -1
  210. package/lib/StandardForm/StepForm.js +32 -27
  211. package/lib/StandardForm/TabForm.d.ts +1 -1
  212. package/lib/StandardForm/TabForm.js +45 -48
  213. package/lib/StandardForm/index.d.ts +1 -1
  214. package/lib/StandardForm/index.js +9 -10
  215. package/lib/StandardModal/UpdateFormRef.js +3 -4
  216. package/lib/StandardModal/index.d.ts +2 -1
  217. package/lib/StandardModal/index.js +29 -43
  218. package/lib/StandardPanel/index.d.ts +1 -1
  219. package/lib/StandardPanel/index.js +11 -12
  220. package/lib/StandardTable/index.d.ts +1 -0
  221. package/lib/StandardTable/index.js +49 -29
  222. package/lib/components/IconNode/index.d.ts +1 -1
  223. package/lib/components/IconNode/index.js +2 -4
  224. package/lib/components/index.js +1 -1
  225. package/lib/data/func.code.js +2 -3
  226. package/lib/data/general.config.js +33 -3
  227. package/lib/data/index.js +1 -1
  228. package/lib/index.d.ts +3 -1
  229. package/lib/index.js +30 -10
  230. package/lib/utils/ValueFormat.js +1 -2
  231. package/lib/utils/filterPermission.js +11 -18
  232. package/lib/utils/getParentNodes.js +103 -29
  233. package/lib/utils/index.js +5 -27
  234. package/lib/utils/urlUtils.js +82 -0
  235. package/package.json +15 -9
  236. package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
  237. package/dist/fonts/iconfont.eot +0 -0
  238. package/es/StandardDragModal/ChangeStandardModal.d.ts +0 -44
  239. package/es/StandardDragModal/ChangeStandardModal.js +0 -493
  240. package/es/StandardDragModal/DraggableModal.d.ts +0 -7
  241. package/es/StandardDragModal/DraggableModal.js +0 -31
  242. package/es/StandardDragModal/DraggableModalContext.d.ts +0 -9
  243. package/es/StandardDragModal/DraggableModalContext.js +0 -5
  244. package/es/StandardDragModal/DraggableModalInner.d.ts +0 -16
  245. package/es/StandardDragModal/DraggableModalInner.js +0 -114
  246. package/es/StandardDragModal/DraggableModalProvider.d.ts +0 -4
  247. package/es/StandardDragModal/DraggableModalProvider.js +0 -40
  248. package/es/StandardDragModal/Modal.d.ts +0 -11
  249. package/es/StandardDragModal/Modal.js +0 -24
  250. package/es/StandardDragModal/ResizeHandle.d.ts +0 -2
  251. package/es/StandardDragModal/ResizeHandle.js +0 -8
  252. package/es/StandardDragModal/clamp.d.ts +0 -1
  253. package/es/StandardDragModal/clamp.js +0 -3
  254. package/es/StandardDragModal/draggableModalReducer.d.ts +0 -66
  255. package/es/StandardDragModal/draggableModalReducer.js +0 -157
  256. package/es/StandardDragModal/getWindowSize.d.ts +0 -4
  257. package/es/StandardDragModal/getWindowSize.js +0 -6
  258. package/es/StandardDragModal/index.less +0 -65
  259. package/es/StandardDragModal/useDrag.d.ts +0 -5
  260. package/es/StandardDragModal/useDrag.js +0 -66
  261. package/es/StandardDragModal/usePrevious.d.ts +0 -1
  262. package/es/StandardDragModal/usePrevious.js +0 -8
  263. package/es/StandardDragModal/useResize.d.ts +0 -7
  264. package/es/StandardDragModal/useResize.js +0 -74
  265. package/es/utils/dictSelectUtil.js +0 -153
  266. package/lib/StandardDragModal/ChangeStandardModal.d.ts +0 -44
  267. package/lib/StandardDragModal/ChangeStandardModal.js +0 -502
  268. package/lib/StandardDragModal/DraggableModal.d.ts +0 -7
  269. package/lib/StandardDragModal/DraggableModal.js +0 -40
  270. package/lib/StandardDragModal/DraggableModalContext.d.ts +0 -9
  271. package/lib/StandardDragModal/DraggableModalContext.js +0 -15
  272. package/lib/StandardDragModal/DraggableModalInner.d.ts +0 -16
  273. package/lib/StandardDragModal/DraggableModalInner.js +0 -124
  274. package/lib/StandardDragModal/DraggableModalProvider.d.ts +0 -4
  275. package/lib/StandardDragModal/DraggableModalProvider.js +0 -48
  276. package/lib/StandardDragModal/Modal.d.ts +0 -11
  277. package/lib/StandardDragModal/Modal.js +0 -32
  278. package/lib/StandardDragModal/ResizeHandle.d.ts +0 -2
  279. package/lib/StandardDragModal/ResizeHandle.js +0 -18
  280. package/lib/StandardDragModal/clamp.d.ts +0 -1
  281. package/lib/StandardDragModal/clamp.js +0 -10
  282. package/lib/StandardDragModal/draggableModalReducer.d.ts +0 -66
  283. package/lib/StandardDragModal/draggableModalReducer.js +0 -167
  284. package/lib/StandardDragModal/getWindowSize.d.ts +0 -4
  285. package/lib/StandardDragModal/getWindowSize.js +0 -13
  286. package/lib/StandardDragModal/index.less +0 -65
  287. package/lib/StandardDragModal/useDrag.d.ts +0 -5
  288. package/lib/StandardDragModal/useDrag.js +0 -73
  289. package/lib/StandardDragModal/usePrevious.d.ts +0 -1
  290. package/lib/StandardDragModal/usePrevious.js +0 -15
  291. package/lib/StandardDragModal/useResize.d.ts +0 -7
  292. package/lib/StandardDragModal/useResize.js +0 -81
  293. package/lib/utils/dictSelectUtil.js +0 -161
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import './style/index.less';
2
3
  interface UploaderProps {
3
4
  extraExt?: string;
4
5
  accept?: string;
@@ -7,7 +8,10 @@ interface UploaderProps {
7
8
  className?: string;
8
9
  isOnly?: boolean;
9
10
  children?: React.ReactNode;
10
- onChange?: (file?: any) => void;
11
+ onChange?: (file?: any, defaultFile?: {
12
+ file: any;
13
+ fileList: any[];
14
+ }) => void;
11
15
  value?: any;
12
16
  size?: number;
13
17
  modalSize?: string;
@@ -16,6 +20,9 @@ interface UploaderProps {
16
20
  limit?: number;
17
21
  modalConfig?: any;
18
22
  modalZIndex?: number;
23
+ crop?: boolean;
24
+ cropConfig?: any;
25
+ [k: string]: any;
19
26
  }
20
- declare const Uploader: React.ForwardRefExoticComponent<UploaderProps & React.RefAttributes<unknown>>;
27
+ declare const Uploader: React.ForwardRefExoticComponent<Omit<UploaderProps, "ref"> & React.RefAttributes<unknown>>;
21
28
  export default Uploader;
@@ -5,30 +5,33 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- require("antd/es/upload/style");
9
- var _upload = _interopRequireDefault(require("antd/es/upload"));
10
8
  require("antd/es/button/style");
11
9
  var _button = _interopRequireDefault(require("antd/es/button"));
10
+ require("antd/es/upload/style");
11
+ var _upload = _interopRequireDefault(require("antd/es/upload"));
12
12
  require("antd/es/message/style");
13
13
  var _message2 = _interopRequireDefault(require("antd/es/message"));
14
14
  var _tslib = require("tslib");
15
15
  var _react = _interopRequireWildcard(require("react"));
16
16
  var _icons = require("@ant-design/icons");
17
17
  var _util = require("./util");
18
- var _StandardModal = _interopRequireDefault(require("../../StandardModal"));
19
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
18
+ require("./style/index.less");
19
+ var _ImagePreview = _interopRequireDefault(require("../../ImageGallery/ImagePreview"));
20
+ var _antdImgCrop = _interopRequireDefault(require("antd-img-crop"));
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
25
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
23
26
  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."); }
24
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
25
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
26
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
28
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
29
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
27
30
  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."); }
28
- 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); }
29
- 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; }
30
- 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; } }
31
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } // import RcUpload from 'rc-upload';
31
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
32
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
33
+ 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; } }
34
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /* eslint-disable */ // import StandardModal from "../../StandardModal";
32
35
  var Uploader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
33
36
  var accept = props.accept,
34
37
  extraExt = props.extraExt,
@@ -40,178 +43,302 @@ var Uploader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
40
43
  value = props.value,
41
44
  _props$size = props.size,
42
45
  size = _props$size === void 0 ? 2 * 1024 * 1024 : _props$size,
43
- _props$modalSize = props.modalSize,
44
- modalSize = _props$modalSize === void 0 ? 'md' : _props$modalSize,
45
- _props$modalConfig = props.modalConfig,
46
- modalConfig = _props$modalConfig === void 0 ? {} : _props$modalConfig,
47
46
  onPreview = props.onPreview,
48
47
  beforeUpload = props.beforeUpload,
49
- limit = props.limit; // 图片预览数据
50
- var _useState = (0, _react.useState)({
51
- visible: false,
52
- url: ''
53
- }),
48
+ limit = props.limit,
49
+ maxCount = props.maxCount,
50
+ viewOnly = props.viewOnly,
51
+ crop = props.crop,
52
+ cropConfig = props.cropConfig,
53
+ otherProps = (0, _tslib.__rest)(props, ["accept", "extraExt", "fileType", "className", "isOnly", "children", "onChange", "value", "size", "onPreview", "beforeUpload", "limit", "maxCount", "viewOnly", "crop", "cropConfig"]);
54
+ // 图片预览数据
55
+ // const [showConfig, setShowConfig] = useState({ visible: false, url: '' })
56
+ // 用于展示的缩略图
57
+ var _useState = (0, _react.useState)([]),
54
58
  _useState2 = _slicedToArray(_useState, 2),
55
- showConfig = _useState2[0],
56
- setShowConfig = _useState2[1]; // 用于展示的缩略图
57
- var _useState3 = (0, _react.useState)([]),
59
+ uploaderFileList = _useState2[0],
60
+ setUploaderFileList = _useState2[1];
61
+ // const [previewerList, setPreviewerList] = useState([])
62
+ var _useState3 = (0, _react.useState)(false),
58
63
  _useState4 = _slicedToArray(_useState3, 2),
59
- fileList = _useState4[0],
60
- setFileList = _useState4[1];
64
+ showPreview = _useState4[0],
65
+ setShowPreview = _useState4[1];
66
+ var _useState5 = (0, _react.useState)(-1),
67
+ _useState6 = _slicedToArray(_useState5, 2),
68
+ previewCurrent = _useState6[0],
69
+ setPreviewerCurrent = _useState6[1];
70
+ var _useState7 = (0, _react.useState)(null),
71
+ _useState8 = _slicedToArray(_useState7, 2),
72
+ cropFile = _useState8[0],
73
+ setCropFile = _useState8[1]; // 存储裁剪的图片file信息
74
+ var maxCountLimit = (0, _react.useMemo)(function () {
75
+ if (isOnly) {
76
+ return 1;
77
+ }
78
+ return maxCount || limit;
79
+ }, [isOnly, limit, maxCount]);
80
+ var splitAccept = (0, _react.useMemo)(function () {
81
+ var res = (0, _util.getAccept)(fileType);
82
+ if (extraExt) {
83
+ res = res + ',' + extraExt;
84
+ }
85
+ if (accept) {
86
+ res = res + ',' + accept;
87
+ }
88
+ return res;
89
+ }, [fileType, extraExt]);
61
90
  (0, _react.useEffect)(function () {
62
91
  if (!value) {
63
- setFileList([]);
92
+ setUploaderFileList([]);
64
93
  return;
65
94
  }
66
95
  var S4 = function S4() {
67
96
  return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
68
97
  };
69
98
  if (Object.prototype.toString.call(value) === '[object Array]') {
70
- setFileList(value.map(function (file, index) {
99
+ var newFilesValue = _toConsumableArray(value);
100
+ setUploaderFileList((newFilesValue || []).map(function (file) {
71
101
  file.uid = file.uid || "".concat(S4(), "-").concat(S4());
72
102
  file.url = file.downloadUrl || file.url;
73
103
  file.status = 'done';
104
+ file.previewUrl = file.previewUrl || file.downloadUrl || file.url; // 给预览地址
74
105
  return file;
75
106
  }));
76
107
  return;
77
108
  }
78
109
  if (Object.prototype.toString.call(value) === '[object Object]') {
79
- setFileList([Object.assign({
110
+ /* eslint-disable nwo-multi-spaces */
111
+ setUploaderFileList([Object.assign({
80
112
  uid: "".concat(S4(), "-").concat(S4()),
81
113
  url: value.downloadUrl || value.url,
82
- status: 'done'
114
+ status: 'done',
115
+ previewUrl: value.previewUrl || value.downloadUrl || value.url
83
116
  }, value)]);
117
+ /* eslint-enable no-multi-spaces */
84
118
  return;
85
119
  }
86
120
  if (Object.prototype.toString.call(value) === '[object String]') {
87
- setFileList([{
121
+ setUploaderFileList([{
88
122
  uid: "".concat(S4(), "-").concat(S4()),
89
123
  url: value,
90
124
  name: '附件',
91
- status: 'done'
125
+ status: 'done',
126
+ previewUrl: value
92
127
  }]);
93
128
  return;
94
129
  }
95
130
  }, [value]);
96
- var splitAccept = (0, _react.useMemo)(function () {
97
- var res = (0, _util.getAccept)(fileType);
98
- if (extraExt) {
99
- res = res + ',' + extraExt;
100
- }
101
- if (accept) {
102
- res = res + ',' + accept;
103
- }
104
- return res;
105
- }, [fileType, extraExt]);
106
131
  // 点击文件链接或预览图标时的回调
107
- var handlePreview = (0, _react.useCallback)(function (file) {
108
- return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
109
- var res;
110
- return regeneratorRuntime.wrap(function _callee$(_context) {
111
- while (1) {
112
- switch (_context.prev = _context.next) {
113
- case 0:
114
- if (!(!file.url && !file.preview)) {
115
- _context.next = 5;
116
- break;
117
- }
118
- _context.next = 3;
119
- return (0, _util.getBase64)(file.originFileObj);
120
- case 3:
121
- res = _context.sent;
122
- if (res && res.status === 'success') {
123
- file.preview = res.url;
124
- }
125
- case 5:
126
- setShowConfig({
127
- visible: true,
128
- url: file.url || file.preview
129
- });
130
- case 6:
131
- case "end":
132
- return _context.stop();
133
- }
132
+ var handlePreview = (0, _react.useCallback)(function (file, files) {
133
+ return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
134
+ var pList;
135
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
136
+ while (1) switch (_context.prev = _context.next) {
137
+ case 0:
138
+ // 方式一:直接全部转换成base64后再打开预览(问题:会出现时间过长)
139
+ // const pList: any = await fileListPreviewer([...files])
140
+ // 方式三:上传时已经转换过
141
+ pList = _toConsumableArray(files);
142
+ setUploaderFileList(pList);
143
+ setPreviewerCurrent(pList.findIndex(function (item) {
144
+ return item.uid === file.uid;
145
+ }));
146
+ setShowPreview(true);
147
+ /*
148
+ // 方式二:只先转换当前图片
149
+ const pList: any = [...files]
150
+ const matchIndex = pList.findIndex((item: FileTypeProps) => item.uid === file.uid)
151
+ const matchPreview = pList[matchIndex]
152
+ // 判断当前是否有预览图
153
+ if (!matchPreview.url && !matchPreview.previewUrl) {
154
+ // 无预览地址,需要先转换
155
+ const res = await getBase64(matchPreview.originFileObj);
156
+ if (res && res.status === 'success') {
157
+ matchPreview.previewUrl = res.url;
158
+ }
159
+ pList.splice(matchIndex, 1, matchPreview)
160
+ } else {
161
+ // 有预览地址,暂时不做处理
162
+ }
163
+ setUploaderFileList(pList)
164
+ setPreviewerCurrent(matchIndex)
165
+ setShowPreview(true)*/
166
+ // if (!file.url && !file.preview) {
167
+ // const res = await getBase64(file.originFileObj);
168
+ // if (res && res.status === 'success') {
169
+ // file.preview = res.url;
170
+ // }
171
+ // }
172
+ // console.log('file', file.uid)
173
+ // const previewItem = pList.find((item: FileTypeProps) => item.uid === file.uid)
174
+ // setShowConfig({ visible: true, url: previewItem.previewUrl })
175
+ case 4:
176
+ case "end":
177
+ return _context.stop();
134
178
  }
135
179
  }, _callee);
136
180
  }));
137
- }, [setShowConfig]);
181
+ }, []);
138
182
  // 检查文件是否规范
139
- var handleCheck = (0, _react.useCallback)(function (file) {
140
- var isLtSize = file.size < size;
141
- if (!isLtSize) {
142
- _message2.default.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(Math.round(size / 1024 / 1024 * 100) / 100, "MB!"));
143
- return false;
144
- }
145
- return true;
146
- }, [fileType, size]);
183
+ // const handleCheck = useCallback((file: any) => {
184
+ // const isLtSize = file.size < size;
185
+ // if (!isLtSize) {
186
+ // message.error(`文件大小不能超过${Math.round(((size / 1024) / 1024) * 100) / 100}MB!`);
187
+ // return false;
188
+ // }
189
+ // return true;
190
+ // }, [fileType, size])
147
191
  var handleChange = (0, _react.useCallback)(function (res) {
148
- return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
149
- var isOk, result, list;
150
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
151
- while (1) {
152
- switch (_context2.prev = _context2.next) {
153
- case 0:
154
- if (!(res.file.status === 'removed')) {
155
- _context2.next = 4;
156
- break;
157
- }
158
- setFileList(res.fileList);
159
- onChange && onChange(isOnly ? res.fileList[0] && res.fileList[0].originFileObj : res.fileList);
160
- return _context2.abrupt("return");
161
- case 4:
162
- isOk = handleCheck(res.file);
163
- if (isOk) {
164
- list = res.fileList.map(function (file) {
165
- if (!file.url) {
166
- file.url = file.thumbUrl;
167
- }
168
- return file;
169
- });
170
- result = _toConsumableArray(list);
171
- setFileList(list);
172
- onChange && onChange(isOnly ? result[0] && result[0].originFileObj : result);
173
- }
174
- case 6:
175
- case "end":
176
- return _context2.stop();
177
- }
192
+ return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
193
+ var result, fileRes, matchAddIndex, matchAdd;
194
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
195
+ while (1) switch (_context2.prev = _context2.next) {
196
+ case 0:
197
+ if (!(res.file.status === 'removed')) {
198
+ _context2.next = 4;
199
+ break;
200
+ }
201
+ setUploaderFileList(res.fileList);
202
+ // onChange && onChange(isOnly ? res.fileList[0] && res.fileList[0].originFileObj : res.fileList)
203
+ onChange && onChange(res.fileList, res);
204
+ return _context2.abrupt("return");
205
+ case 4:
206
+ result = []; // 裁剪模式下,把裁剪后的文件信息传过来
207
+ if (crop && cropFile) {
208
+ res.file = cropFile;
209
+ }
210
+ _context2.next = 8;
211
+ return (0, _util.getBase64)(res.file);
212
+ case 8:
213
+ fileRes = _context2.sent;
214
+ matchAddIndex = res.fileList.findIndex(function (item) {
215
+ return item.uid === res.file.uid;
216
+ });
217
+ matchAdd = res.fileList[matchAddIndex];
218
+ matchAdd.previewUrl = fileRes === null || fileRes === void 0 ? void 0 : fileRes.url; // 预览URL
219
+ if (crop && cropFile) {
220
+ // 将当前裁剪后的文件传出来
221
+ matchAdd.originFileObj = res.file;
222
+ matchAdd.size = res.file.size;
223
+ matchAdd.lastModified = res.file.lastModified;
224
+ matchAdd.lastModifiedDate = res.file.lastModifiedDate;
225
+ }
226
+ res.fileList.splice(matchAddIndex, 1, matchAdd);
227
+ result = _toConsumableArray(res.fileList || []);
228
+ setUploaderFileList(result);
229
+ setCropFile(null);
230
+ onChange && onChange(isOnly ? result[0] && result[0].originFileObj : result, res);
231
+ // const isOk = handleCheck(res.file)
232
+ // if (isOk) {
233
+ // let result: any = []
234
+ // const fileRes = await getBase64(res.file)
235
+ // const matchAddIndex = res.fileList.findIndex((item: any) => item.uid === res.file.uid)
236
+ // const matchAdd = res.fileList[matchAddIndex]
237
+ // console.log('matchAdd', matchAdd, maxCountLimit)
238
+ // matchAdd.previewUrl = fileRes?.url
239
+ // res.fileList.splice(matchAddIndex, 1, matchAdd)
240
+ // result = [...(res.fileList || [])]
241
+ // setUploaderFileList(result)
242
+ // onChange && onChange(isOnly ? result[0] && result[0].originFileObj : result, res)
243
+ // }
244
+ case 18:
245
+ case "end":
246
+ return _context2.stop();
178
247
  }
179
248
  }, _callee2);
180
249
  }));
181
- }, [isOnly, handleCheck]);
182
- // 渲染预览窗口
183
- var renderPreviewComponent = (0, _react.useMemo)(function () {
184
- if (fileType === 'image' || fileType === 'svg') {
185
- var visible = showConfig.visible,
186
- url = showConfig.url;
187
- return /*#__PURE__*/_react.default.createElement(_StandardModal.default, Object.assign({
188
- visible: visible,
189
- hideFooter: true,
190
- onCancel: function onCancel() {
191
- return setShowConfig({
192
- visible: false,
193
- url: ''
194
- });
195
- },
196
- size: modalSize,
197
- zIndex: 2000
198
- }, modalConfig), /*#__PURE__*/_react.default.createElement("div", {
199
- style: {
200
- textAlign: 'center'
250
+ }, [isOnly, uploaderFileList, maxCountLimit, crop, cropFile]);
251
+ //
252
+ // const getPreviewInfo = (file: any) => {
253
+ // return new Promise(async (resolve, reject) => {
254
+ // if (!file.url && !file.previewUrl) {
255
+ // const res = await getBase64(file.originFileObj);
256
+ // if (res && res.status === 'success') {
257
+ // file.previewUrl = res.url;
258
+ // }
259
+ // // console.log('转换成功', file)
260
+ // resolve({ ...file })
261
+ // } else {
262
+ // if (!file.previewUrl) {
263
+ // file.previewUrl = file.url
264
+ // }
265
+ // // 已经转换过,无需再转换
266
+ // // console.log('已经转换过,无需再转换', file)
267
+ // resolve({ ...file })
268
+ // }
269
+ // })
270
+ // }
271
+ // const fileListPreviewer = async (files?: any) => {
272
+ // const previewUrls = (files || []).map((item: any) => {
273
+ // return getPreviewInfo(item)
274
+ // });
275
+ // let resultList = await Promise.all(previewUrls).catch((err) => {
276
+ // console.log('Promise.all==>转换base64失败', err)
277
+ // });
278
+ // return resultList
279
+ // }
280
+ var handleClose = function handleClose() {
281
+ setShowPreview(false);
282
+ };
283
+ var handleBeforeUpload = (0, _react.useCallback)(function (file) {
284
+ return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
285
+ var isLtSize;
286
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
287
+ while (1) switch (_context3.prev = _context3.next) {
288
+ case 0:
289
+ //限制图片 格式、size、分辨率
290
+ // const isJPG = file.type === 'image/jpeg';
291
+ // const isJPEG = file.type === 'image/jpeg';
292
+ // const isGIF = file.type === 'image/gif';
293
+ // const isPNG = file.type === 'image/png';
294
+ // if (!(isJPG || isJPEG || isGIF || isPNG)) {
295
+ // message.error("上传图片的格式不正确,不是JPG、JPEG、GIF、PNG");
296
+ // return false;
297
+ // }
298
+ isLtSize = file.size < size;
299
+ if (isLtSize) {
300
+ _context3.next = 4;
301
+ break;
302
+ }
303
+ _message2.default.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(Math.round(size / 1024 / 1024 * 100) / 100, "MB!"));
304
+ // 如果直接返回false或者true,还是会触发额外的onChange,所以需要改成 Upload.LIST_IGNORE
305
+ return _context3.abrupt("return", _upload.default.LIST_IGNORE);
306
+ case 4:
307
+ // 存储裁剪后的文件信息(只有fileType=image,且在单选情况下才可以)
308
+ if (crop && fileType === 'image') {
309
+ setCropFile(file);
310
+ }
311
+ return _context3.abrupt("return", false);
312
+ case 6:
313
+ case "end":
314
+ return _context3.stop();
201
315
  }
202
- }, /*#__PURE__*/_react.default.createElement("img", {
203
- style: {
204
- maxWidth: '100%'
205
- },
206
- src: url,
207
- alt: ""
208
- })));
209
- }
210
- return null;
211
- }, [fileType, showConfig]);
316
+ }, _callee3);
317
+ }));
318
+ }, [fileType, size, crop]);
319
+ // 渲染预览窗口
320
+ /* const renderPreviewComponent = useMemo(
321
+ () => {
322
+ if (fileType === 'image' || fileType === 'svg') {
323
+ const { visible, url } = showConfig
324
+ return (
325
+ <StandardModal visible={visible} hideFooter={true}
326
+ onCancel={() => setShowConfig({ visible: false, url: '' })}
327
+ size={modalSize}
328
+ zIndex={2000}
329
+ {...modalConfig}
330
+ >
331
+ <div style={{ textAlign: 'center' }}><img style={{ maxWidth: '100%' }} src={url} alt=""/></div>
332
+ </StandardModal>
333
+ )
334
+ }
335
+ return null
336
+ },
337
+ [fileType, showConfig]
338
+ )*/
212
339
  var renderChildrenComponent = (0, _react.useMemo)(function () {
213
340
  var renderButton = function renderButton() {
214
- if (fileType === 'image' || fileType === 'svg') {
341
+ if (fileType === 'image' || fileType === 'svg' || fileType === 'video') {
215
342
  return /*#__PURE__*/_react.default.createElement("div", {
216
343
  className: 'spec-uploader-control'
217
344
  }, /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null), /*#__PURE__*/_react.default.createElement("div", {
@@ -222,26 +349,65 @@ var Uploader = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
222
349
  className: 'spec-uploader-button'
223
350
  }, /*#__PURE__*/_react.default.createElement(_icons.PlusOutlined, null), "\u70B9\u51FB\u9009\u62E9");
224
351
  };
352
+ if (maxCountLimit && uploaderFileList.length === maxCountLimit) {
353
+ return null;
354
+ }
225
355
  if (children) {
226
356
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, " ", children, " ");
227
357
  }
228
- if (isOnly && fileList.length === 1 || limit && fileList.length === limit) {
229
- return null;
230
- }
231
358
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, renderButton());
232
- }, [fileType, isOnly, children, fileList, limit]);
233
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_upload.default, Object.assign({}, props, {
234
- ref: ref,
235
- accept: splitAccept,
236
- fileList: fileList,
237
- listType: fileType === 'image' || fileType === 'svg' ? 'picture-card' : 'text',
238
- className: "spec-uploader ".concat(className),
239
- onPreview: onPreview ? onPreview : fileType === 'image' || fileType === 'svg' ? handlePreview : function () {},
240
- beforeUpload: beforeUpload ? beforeUpload : function () {
241
- return false;
242
- },
243
- onChange: handleChange
244
- }), renderChildrenComponent), renderPreviewComponent);
359
+ }, [fileType, children, uploaderFileList, maxCountLimit]);
360
+ var RenderUpload = function RenderUpload() {
361
+ return /*#__PURE__*/_react.default.createElement(_upload.default, Object.assign({}, otherProps, {
362
+ disabled: otherProps.disabled || viewOnly,
363
+ maxCount: maxCountLimit,
364
+ ref: ref,
365
+ accept: splitAccept,
366
+ fileList: uploaderFileList,
367
+ listType: fileType === 'image' || fileType === 'svg' ? 'picture-card' : 'text',
368
+ className: "spec-uploader ".concat(className),
369
+ onPreview: onPreview ? onPreview : fileType === 'image' || fileType === 'svg' ? function (file) {
370
+ return handlePreview(file, uploaderFileList);
371
+ } : function () {},
372
+ beforeUpload: beforeUpload ? beforeUpload : handleBeforeUpload,
373
+ onChange: handleChange
374
+ }), viewOnly ? null : renderChildrenComponent);
375
+ };
376
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
377
+ // multiple 情况下不可用
378
+ !(otherProps === null || otherProps === void 0 ? void 0 : otherProps.multiple) && fileType === 'image' && crop ? /*#__PURE__*/_react.default.createElement(_antdImgCrop.default, Object.assign({}, cropConfig || {}), RenderUpload()) : RenderUpload(), (fileType === 'image' || fileType === 'svg') && showPreview && /*#__PURE__*/_react.default.createElement(_ImagePreview.default, {
379
+ hasThumbnail: true,
380
+ open: showPreview,
381
+ onClose: handleClose,
382
+ current: previewCurrent,
383
+ galleryItems: uploaderFileList
384
+ }, (uploaderFileList || []).map(function (item, ind) {
385
+ // console.log('uploaderFileList=>item', item)
386
+ /* <!-- HTML5 Video --->
387
+ <a
388
+ data-lg-size="1280-720"
389
+ data-video='{"source": [{"src":"/videos/video1.mp4", "type":"video/mp4"}], "tracks": [{"src": "{/videos/title.txt", "kind":"captions", "srclang": "en", "label": "English", "default": "true"}], "attributes": {"preload": false, "playsinline": true, "controls": true}}'
390
+ data-poster="/images/demo/youtube-video-poster.jpg"
391
+ data-sub-html="<h4>'Peck Pocketed' by Kevin Herron | Disney Favorite</h4>"
392
+ >
393
+ <img
394
+ width="300"
395
+ height="100"
396
+ class="img-responsive"
397
+ src="/images/demo/youtube-video-poster.jpg"
398
+ />
399
+ </a>*/
400
+ return /*#__PURE__*/_react.default.createElement("a", {
401
+ key: (item === null || item === void 0 ? void 0 : item.uid) || ind,
402
+ "data-src": item === null || item === void 0 ? void 0 : item.previewUrl,
403
+ "data-thumb-src": (item === null || item === void 0 ? void 0 : item.thumbUrl) || (item === null || item === void 0 ? void 0 : item.url)
404
+ }, /*#__PURE__*/_react.default.createElement("img", {
405
+ src: (item === null || item === void 0 ? void 0 : item.thumbUrl) || (item === null || item === void 0 ? void 0 : item.url),
406
+ style: {
407
+ maxWidth: '100%'
408
+ }
409
+ }));
410
+ // return <img className={'test-image'} key={item?.uid || ind} alt={item.uid} src={item?.previewUrl}/>
411
+ })));
245
412
  }); // as IUploader
246
- var _default = Uploader;
247
- exports.default = _default;
413
+ var _default = exports.default = Uploader;