@para-ui/core 4.0.0-rc.4 → 4.0.0-rc.6

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 (188) hide show
  1. package/AutoBox/index.js +72 -85
  2. package/AutoTips/index.js +72 -95
  3. package/Badge/index.js +17 -16
  4. package/Breadcrumbs/index.js +57 -73
  5. package/Button/index.js +90 -118
  6. package/ButtonGroup/index.js +30 -33
  7. package/Carousel/index.js +29 -33
  8. package/Cascader/index.js +9 -10
  9. package/Checkbox/index.js +28 -35
  10. package/CheckboxGroup/index.js +43 -58
  11. package/Collapse/index.js +52 -49
  12. package/CollapseBox/index.js +65 -70
  13. package/CollapseLayout/index.js +106 -101
  14. package/ColorPicker/index.js +3 -3
  15. package/ComboSelect/index.js +260 -337
  16. package/ComboSelect/lang/en_US.d.ts +1 -0
  17. package/ComboSelect/lang/index.d.ts +2 -0
  18. package/ComboSelect/lang/zh_CN.d.ts +1 -0
  19. package/ComboSelect/utils.d.ts +6 -0
  20. package/Container/index.js +17 -21
  21. package/CopyText/index.js +50 -83
  22. package/DatePicker/index.js +24 -27
  23. package/Descriptions/index.js +50 -59
  24. package/Desktop/index.js +161 -180
  25. package/DragVerify/index.js +77 -113
  26. package/Drawer/index.js +80 -95
  27. package/Dropdown/index.js +3 -3
  28. package/DynamicMultiBox/index.js +222 -224
  29. package/DynamicMultiBox/interface.d.ts +7 -0
  30. package/Empty/index.js +26 -28
  31. package/Form/index.js +70 -74
  32. package/FormItem/index.js +18 -15
  33. package/FunctionModal/index.js +7 -14
  34. package/GlobalContext/index.js +17 -20
  35. package/Help/index.js +9 -12
  36. package/HelperText/index.js +11 -11
  37. package/InputLang/index.js +104 -124
  38. package/InputNumber/index.js +62 -81
  39. package/Label/index.js +19 -21
  40. package/Loading/index.js +11 -10
  41. package/Menu/index.js +302 -371
  42. package/Message/index.js +104 -113
  43. package/Modal/index.js +122 -148
  44. package/MultiBox/index.d.ts +5 -0
  45. package/MultiBox/index.js +111 -115
  46. package/Notification/index.js +105 -103
  47. package/OperateBtn/index.d.ts +3 -0
  48. package/OperateBtn/index.js +77 -107
  49. package/PageHeader/index.js +327 -406
  50. package/Pagination/index.js +107 -137
  51. package/ParauiProvider/index.js +20 -22
  52. package/PasswordRules/index.js +36 -40
  53. package/PopConfirm/index.js +60 -77
  54. package/Popover/index.js +12 -12
  55. package/Progress/index.js +72 -74
  56. package/Querying/index.js +22 -23
  57. package/README.md +2 -0
  58. package/Radio/index.js +27 -34
  59. package/RadioGroup/index.js +38 -52
  60. package/Search/index.js +34 -43
  61. package/Select/index.js +281 -345
  62. package/SelectInput/index.js +8 -13
  63. package/Selector/index.js +582 -796
  64. package/SelectorPicker/index.js +113 -134
  65. package/SingleBox/index.d.ts +5 -0
  66. package/SingleBox/index.js +92 -88
  67. package/Slider/index.js +46 -57
  68. package/Status/index.js +14 -13
  69. package/Stepper/index.js +24 -25
  70. package/Styles/theme.scss +9 -9
  71. package/Switch/index.js +32 -35
  72. package/Table/index.js +360 -494
  73. package/Tabs/index.js +100 -100
  74. package/Tag/index.js +64 -82
  75. package/TextEditor/index.js +78 -100
  76. package/TextField/index.js +142 -183
  77. package/TimePicker/index.js +29 -28
  78. package/Timeline/index.js +50 -47
  79. package/Title/index.js +32 -34
  80. package/ToggleButton/index.js +29 -29
  81. package/Tooltip/index.js +52 -56
  82. package/Transfer/index.js +117 -154
  83. package/Tree/index.js +9 -10
  84. package/Upload/index.js +125 -143
  85. package/Upload/interface.d.ts +2 -0
  86. package/_verture/{constant-0d9802f7.js → constant-5317fc89.js} +2 -2
  87. package/_verture/{index-5a7e2438.js → index-3cdaba96.js} +967 -934
  88. package/_verture/{index-b1f80962.js → index-4fafd0a0.js} +6 -8
  89. package/_verture/{index-024bbc9b.js → index-775ad32d.js} +29 -25
  90. package/_verture/{index-05f7bf11.js → index-c568f272.js} +2 -2
  91. package/_verture/{index-232d890b.js → index-d63bd287.js} +1 -1
  92. package/_verture/index-da9097d3.js +239 -0
  93. package/_verture/{index-9331b116.js → index-e0f9064d.js} +125 -134
  94. package/_verture/intl-f2f27722.js +69 -0
  95. package/_verture/{modalContext-736ff215.js → modalContext-8534f23d.js} +36 -64
  96. package/_verture/{slicedToArray-a8206399.js → slicedToArray-75fa4188.js} +15 -2
  97. package/_verture/{toConsumableArray-8f4c9589.js → toConsumableArray-c7a8028f.js} +1 -1
  98. package/_verture/{useFormatMessage-703f8b20.js → useFormatMessage-eb13cf56.js} +5 -4
  99. package/_verture/{useGlobalProps-1b846a65.js → useGlobalProps-1e416658.js} +4 -3
  100. package/_verture/{usePopupContainer-87febeb9.js → usePopupContainer-635f66f4.js} +16 -15
  101. package/_verture/{util-7e1fb1e2.js → util-82646c4f.js} +5 -4
  102. package/_verture/utils-c17b5265.js +97 -0
  103. package/index.js +24 -23
  104. package/locale/en-US.d.ts +1 -0
  105. package/locale/index.d.ts +2 -0
  106. package/locale/index.js +10 -8
  107. package/locale/zh-CN.d.ts +1 -0
  108. package/package.json +11 -10
  109. package/umd/AutoBox.js +9 -8
  110. package/umd/AutoTips.js +9 -8
  111. package/umd/Badge.js +1 -1
  112. package/umd/Breadcrumbs.js +9 -8
  113. package/umd/Button.js +9 -8
  114. package/umd/ButtonGroup.js +9 -8
  115. package/umd/Carousel.js +5 -5
  116. package/umd/Cascader.js +9 -8
  117. package/umd/Checkbox.js +9 -8
  118. package/umd/CheckboxGroup.js +9 -8
  119. package/umd/Collapse.js +8 -7
  120. package/umd/CollapseBox.js +1 -1
  121. package/umd/CollapseLayout.js +4 -4
  122. package/umd/ColorPicker.js +1 -1
  123. package/umd/ComboSelect.js +9 -8
  124. package/umd/Container.js +1 -1
  125. package/umd/CopyText.js +9 -8
  126. package/umd/DatePicker.js +9 -8
  127. package/umd/Descriptions.js +9 -8
  128. package/umd/Desktop.js +9 -8
  129. package/umd/DragVerify.js +4 -4
  130. package/umd/Drawer.js +9 -8
  131. package/umd/Dropdown.js +6 -5
  132. package/umd/DynamicMultiBox.js +11 -10
  133. package/umd/Empty.js +1 -1
  134. package/umd/Form.js +9 -8
  135. package/umd/FormItem.js +9 -8
  136. package/umd/FunctionModal.js +9 -8
  137. package/umd/GlobalContext.js +1 -1
  138. package/umd/Help.js +9 -8
  139. package/umd/HelperText.js +1 -1
  140. package/umd/InputLang.js +9 -8
  141. package/umd/InputNumber.js +9 -8
  142. package/umd/Label.js +9 -8
  143. package/umd/Loading.js +4 -4
  144. package/umd/Menu.js +4 -4
  145. package/umd/Message.js +4 -4
  146. package/umd/Modal.js +9 -8
  147. package/umd/MultiBox.js +9 -8
  148. package/umd/Notification.js +8 -7
  149. package/umd/OperateBtn.js +9 -8
  150. package/umd/PageHeader.js +9 -8
  151. package/umd/Pagination.js +9 -8
  152. package/umd/ParauiProvider.js +1 -1
  153. package/umd/PasswordRules.js +4 -4
  154. package/umd/PopConfirm.js +9 -8
  155. package/umd/Popover.js +9 -8
  156. package/umd/Progress.js +5 -5
  157. package/umd/Querying.js +1 -1
  158. package/umd/Radio.js +9 -8
  159. package/umd/RadioGroup.js +9 -8
  160. package/umd/Search.js +9 -8
  161. package/umd/Select.js +9 -8
  162. package/umd/SelectInput.js +9 -8
  163. package/umd/Selector.js +9 -8
  164. package/umd/SelectorPicker.js +9 -8
  165. package/umd/SingleBox.js +9 -8
  166. package/umd/Slider.js +6 -5
  167. package/umd/Status.js +4 -4
  168. package/umd/Stepper.js +9 -8
  169. package/umd/Switch.js +9 -8
  170. package/umd/Table.js +9 -8
  171. package/umd/Tabs.js +9 -8
  172. package/umd/Tag.js +9 -8
  173. package/umd/TextEditor.js +22 -21
  174. package/umd/TextField.js +9 -8
  175. package/umd/TimePicker.js +9 -8
  176. package/umd/Timeline.js +1 -1
  177. package/umd/Title.js +9 -8
  178. package/umd/ToggleButton.js +9 -8
  179. package/umd/Tooltip.js +9 -8
  180. package/umd/Transfer.js +10 -9
  181. package/umd/Tree.js +9 -8
  182. package/umd/Upload.js +10 -9
  183. package/umd/locale.js +1 -1
  184. package/_verture/index-e9007d6a.js +0 -236
  185. package/_verture/intl-5c1ec055.js +0 -81
  186. package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
  187. package/_verture/utils-418da0a4.js +0 -73
  188. /package/_verture/{typeof-c310ee4a.js → typeof-b240b062.js} +0 -0
package/Tree/index.js CHANGED
@@ -1,12 +1,11 @@
1
- import { T as Tree } from '../_verture/index-b1f80962.js';
2
- export { T as default } from '../_verture/index-b1f80962.js';
3
- import '../_verture/toConsumableArray-8f4c9589.js';
4
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
1
+ import { T as Tree } from '../_verture/index-4fafd0a0.js';
2
+ export { T as default } from '../_verture/index-4fafd0a0.js';
3
+ import '../_verture/toConsumableArray-c7a8028f.js';
4
+ import '../_verture/slicedToArray-75fa4188.js';
5
5
  import '../_verture/defineProperty-1d116156.js';
6
6
  import '../_verture/typeof-adeedc13.js';
7
- import '../_verture/slicedToArray-a8206399.js';
8
- import '../_verture/index-232d890b.js';
9
- import '../_verture/typeof-c310ee4a.js';
7
+ import '../_verture/index-d63bd287.js';
8
+ import '../_verture/typeof-b240b062.js';
10
9
  import '../_verture/tslib.es6-55ed4bd2.js';
11
10
  import 'react/jsx-runtime';
12
11
  import 'react';
@@ -21,7 +20,7 @@ import '../Help/index.js';
21
20
  import '../Tooltip/index.js';
22
21
  import 'rc-tooltip';
23
22
  import 'rc-tooltip/lib/placements';
24
- import '../_verture/constant-0d9802f7.js';
23
+ import '../_verture/constant-5317fc89.js';
25
24
  import '@para-ui/icons/Forbid';
26
25
  import '../_verture/style-inject.es-300983ab.js';
27
26
  import '@para-ui/icons/Help';
@@ -30,10 +29,10 @@ import '@para-ui/icons/EditFile';
30
29
  import '@para-ui/icons/PlusCircle';
31
30
  import '@para-ui/icons/Delete';
32
31
  import '@paraview/lib';
33
- import '../_verture/useFormatMessage-703f8b20.js';
32
+ import '../_verture/useFormatMessage-eb13cf56.js';
34
33
  import '@para-ui/core/GlobalContext';
35
34
  import '@para-ui/icons/MoreCircle';
36
35
  import '../Empty/index.js';
37
- import '../_verture/useGlobalProps-1b846a65.js';
36
+ import '../_verture/useGlobalProps-1e416658.js';
38
37
  import '../Loading/index.js';
39
38
  import '../AutoTips/index.js';
package/Upload/index.js CHANGED
@@ -1,45 +1,43 @@
1
- import { _ as _defineProperty } from '../_verture/defineProperty-1d116156.js';
2
- import { _ as _toConsumableArray } from '../_verture/toConsumableArray-8f4c9589.js';
3
- import { _ as _slicedToArray } from '../_verture/slicedToArray-a8206399.js';
4
1
  import { a as __awaiter, _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
5
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
3
  import { useState, useEffect, useRef, memo, forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';
7
4
  import RcUpload from 'rc-upload';
8
5
  import UploadIcon from '@para-ui/icons/UploadFile';
9
6
  import LoadingIcon from '@para-ui/icons/Loading';
7
+ import { _ as _toConsumableArray } from '../_verture/toConsumableArray-c7a8028f.js';
10
8
  import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
11
- import { r as regenerator } from '../_verture/index-232d890b.js';
9
+ import { _ as _slicedToArray } from '../_verture/slicedToArray-75fa4188.js';
10
+ import { r as regenerator } from '../_verture/index-d63bd287.js';
12
11
  import Delete from '@para-ui/icons/Delete';
13
12
  import TextIcon from '@para-ui/icons/Text';
14
13
  import PhotoIcon from '@para-ui/icons/Photo';
15
14
  import clsx from 'clsx';
16
- import { $ as $prefixCls, a as $rcPrefixCls } from '../_verture/constant-0d9802f7.js';
15
+ import { $ as $prefixCls, a as $rcPrefixCls } from '../_verture/constant-5317fc89.js';
17
16
  import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
18
17
  import Forbid from '@para-ui/icons/Forbid';
19
- import { u as useFormatMessage } from '../_verture/useFormatMessage-703f8b20.js';
18
+ import { u as useFormatMessage } from '../_verture/useFormatMessage-eb13cf56.js';
20
19
  import EditIcon from '@para-ui/icons/EditOutline';
21
20
  import { Button } from '../Button/index.js';
22
21
  import { Slider } from '../Slider/index.js';
23
22
  import Cropper from 'react-easy-crop';
24
23
  import { Modal } from '../Modal/index.js';
25
- import '../_verture/unsupportedIterableToArray-cb478f24.js';
26
- import '../_verture/typeof-c310ee4a.js';
24
+ import '../_verture/typeof-b240b062.js';
27
25
  import '@para-ui/core/GlobalContext';
28
26
  import '@para-ui/icons/LoadingF';
29
27
  import '../Tooltip/index.js';
30
28
  import 'rc-tooltip';
31
29
  import 'rc-tooltip/lib/placements';
32
30
  import '@para-ui/icons/Down';
33
- import '../_verture/index-e9007d6a.js';
31
+ import '../_verture/index-da9097d3.js';
34
32
  import 'rc-dropdown';
35
- import '../_verture/usePopupContainer-87febeb9.js';
33
+ import '../_verture/usePopupContainer-635f66f4.js';
36
34
  import 'dayjs';
37
35
  import '@paraview/lib';
38
36
  import '../AutoTips/index.js';
39
37
  import 'rc-slider';
40
38
  import 'rc-dialog';
41
39
  import '@para-ui/icons/Close';
42
- import '../_verture/index-05f7bf11.js';
40
+ import '../_verture/index-c568f272.js';
43
41
  import 'react-dom';
44
42
  import '@para-ui/icons/CheckCircleF';
45
43
  import '@para-ui/icons/WarningCircleF';
@@ -302,11 +300,13 @@ var ImageUpload = function ImageUpload(props) {
302
300
  stash = _props$stash === void 0 ? false : _props$stash,
303
301
  _props$uploading = props.uploading,
304
302
  uploading = _props$uploading === void 0 ? true : _props$uploading,
303
+ _props$loading = props.loading,
304
+ loading = _props$loading === void 0 ? false : _props$loading,
305
305
  _props$showLoading = props.showLoading,
306
- loading = _props$showLoading === void 0 ? true : _props$showLoading,
306
+ showLoadingProp = _props$showLoading === void 0 ? false : _props$showLoading,
307
307
  defaultImage = props.defaultImage,
308
308
  readonly = props.readonly,
309
- restProps = __rest(props, ["className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "stash", "uploading", "showLoading", "defaultImage", "readonly"]);
309
+ restProps = __rest(props, ["className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "stash", "uploading", "loading", "showLoading", "defaultImage", "readonly"]);
310
310
  var intl = useFormatMessage('Upload', localeJson);
311
311
  var _useState = useState(defaultFileList),
312
312
  _useState2 = _slicedToArray(_useState, 2),
@@ -337,6 +337,9 @@ var ImageUpload = function ImageUpload(props) {
337
337
  _ref2$leaveDelay = _ref2.leaveDelay,
338
338
  leaveDelay = _ref2$leaveDelay === void 0 ? 2000 : _ref2$leaveDelay; //错误信息提示
339
339
  var cropFileRef = useRef(); //裁剪文件
340
+ useEffect(function () {
341
+ setShowLoading(loading);
342
+ }, [loading]);
340
343
  //复写属性
341
344
  var overrideProps = Object.assign(Object.assign({
342
345
  accept: 'image/*'
@@ -347,7 +350,7 @@ var ImageUpload = function ImageUpload(props) {
347
350
  return regenerator.wrap(function _callee$(_context) {
348
351
  while (1) switch (_context.prev = _context.next) {
349
352
  case 0:
350
- if (restProps.action && loading && uploading) setShowLoading(true);
353
+ if (restProps.action && showLoadingProp && uploading) setShowLoading(true);
351
354
  _context.next = 3;
352
355
  return _beforeUpload === null || _beforeUpload === void 0 ? void 0 : _beforeUpload(file, fileList);
353
356
  case 3:
@@ -1126,121 +1129,101 @@ var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下
1126
1129
  styleInject(css_248z);
1127
1130
 
1128
1131
  //upload
1129
- var InternalUpload = function InternalUpload(props) {
1130
- var _props$type = props.type,
1131
- type = _props$type === void 0 ? 'select' : _props$type,
1132
- className = props.className,
1133
- style = props.style,
1134
- _onStart = props.onStart,
1135
- _onSuccess = props.onSuccess,
1136
- _onError = props.onError,
1137
- _onProgress = props.onProgress,
1138
- onRemove = props.onRemove,
1139
- _beforeUpload = props.beforeUpload,
1140
- onChange = props.onChange,
1141
- onDrop = props.onDrop,
1142
- _props$defaultFileLis = props.defaultFileList,
1143
- defaultFileList = _props$defaultFileLis === void 0 ? [] : _props$defaultFileLis,
1144
- fileList = props.fileList,
1145
- _props$showUploadList = props.showUploadList,
1146
- showUploadList = _props$showUploadList === void 0 ? true : _props$showUploadList,
1147
- maxCount = props.maxCount,
1148
- _props$children = props.children,
1149
- children = _props$children === void 0 ? null : _props$children,
1150
- itemRender = props.itemRender,
1151
- _props$showUploadErro = props.showUploadError,
1152
- showUploadError = _props$showUploadErro === void 0 ? true : _props$showUploadErro,
1153
- _props$size = props.size,
1154
- size = _props$size === void 0 ? 'large' : _props$size,
1155
- _props$stash = props.stash,
1156
- stash = _props$stash === void 0 ? false : _props$stash,
1157
- _props$uploading = props.uploading,
1158
- uploading = _props$uploading === void 0 ? true : _props$uploading,
1159
- _props$showLoading = props.showLoading,
1160
- loading = _props$showLoading === void 0 ? true : _props$showLoading,
1161
- dragArea = props.dragArea,
1162
- disabledTooltip = props.disabledTooltip,
1163
- restProps = __rest(props, ["type", "className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "onDrop", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "size", "stash", "uploading", "showLoading", "dragArea", "disabledTooltip"]);
1164
- var intl = useFormatMessage('Upload', localeJson);
1165
- var _useState = useState(defaultFileList),
1166
- _useState2 = _slicedToArray(_useState, 2),
1167
- uploadFileList = _useState2[0],
1168
- setUploadFileList = _useState2[1]; //文件列表
1169
- var _useState3 = useState(false),
1170
- _useState4 = _slicedToArray(_useState3, 2),
1171
- showLoading = _useState4[0],
1172
- setShowLoading = _useState4[1]; //upload loading
1173
- var _useState5 = useState(false),
1174
- _useState6 = _slicedToArray(_useState5, 2),
1175
- errTip = _useState6[0],
1176
- setErrTip = _useState6[1]; //upload error tip
1177
- var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
1178
- showRemoveIcon = _ref.showRemoveIcon,
1179
- removeIcon = _ref.removeIcon; //显示上传列表
1180
- var _ref2 = typeof showUploadError === 'boolean' ? {} : showUploadError,
1181
- _ref2$uploadErrorMsg = _ref2.uploadErrorMsg,
1182
- uploadErrorMsg = _ref2$uploadErrorMsg === void 0 ? intl({
1132
+ const InternalUpload = props => {
1133
+ const {
1134
+ type = 'select',
1135
+ className,
1136
+ style,
1137
+ onStart,
1138
+ onSuccess,
1139
+ onError,
1140
+ onProgress,
1141
+ onRemove,
1142
+ beforeUpload,
1143
+ onChange,
1144
+ onDrop,
1145
+ defaultFileList = [],
1146
+ fileList,
1147
+ showUploadList = true,
1148
+ maxCount,
1149
+ children = null,
1150
+ itemRender,
1151
+ showUploadError = true,
1152
+ size = 'large',
1153
+ stash = false,
1154
+ uploading = true,
1155
+ showLoading: showLoadingProp = true,
1156
+ loading = false,
1157
+ dragArea,
1158
+ disabledTooltip
1159
+ } = props,
1160
+ restProps = __rest(props, ["type", "className", "style", "onStart", "onSuccess", "onError", "onProgress", "onRemove", "beforeUpload", "onChange", "onDrop", "defaultFileList", "fileList", "showUploadList", "maxCount", "children", "itemRender", "showUploadError", "size", "stash", "uploading", "showLoading", "loading", "dragArea", "disabledTooltip"]);
1161
+ const intl = useFormatMessage('Upload', localeJson);
1162
+ const [uploadFileList, setUploadFileList] = useState(defaultFileList); //文件列表
1163
+ const [showLoading, setShowLoading] = useState(false); //upload loading
1164
+ const [errTip, setErrTip] = useState(false); //upload error tip
1165
+ const {
1166
+ showRemoveIcon,
1167
+ removeIcon
1168
+ } = typeof showUploadList === 'boolean' ? {} : showUploadList; //显示上传列表
1169
+ const {
1170
+ uploadErrorMsg = intl({
1183
1171
  id: 'uploadError'
1184
- }) : _ref2$uploadErrorMsg,
1185
- _ref2$leaveDelay = _ref2.leaveDelay,
1186
- leaveDelay = _ref2$leaveDelay === void 0 ? 3000 : _ref2$leaveDelay; //错误信息提示
1187
- var _useState7 = useState('drop'),
1188
- _useState8 = _slicedToArray(_useState7, 2),
1189
- dragState = _useState8[0],
1190
- setDragState = _useState8[1]; //拖拽状态
1191
- var curFileRef = useRef(); //正上传文件
1192
- var recordNonAcceptFileRef = useRef(); //记录非accept推荐文件
1172
+ }),
1173
+ leaveDelay = 3000
1174
+ } = typeof showUploadError === 'boolean' ? {} : showUploadError; //错误信息提示
1175
+ const [dragState, setDragState] = useState('drop'); //拖拽状态
1176
+ const curFileRef = useRef(); //正上传文件
1177
+ const recordNonAcceptFileRef = useRef(); //记录非accept推荐文件
1193
1178
  //复写属性
1194
- var overrideProps = Object.assign(Object.assign({}, restProps), {
1195
- beforeUpload: function beforeUpload(file, fileList) {
1196
- if (restProps.action && loading && uploading) {
1179
+ const overrideProps = Object.assign(Object.assign({}, restProps), {
1180
+ beforeUpload(file, fileList) {
1181
+ if (restProps.action && showLoadingProp && uploading) {
1197
1182
  setShowLoading(true);
1198
1183
  curFileRef.current = file;
1199
1184
  }
1200
- var val = _beforeUpload === null || _beforeUpload === void 0 ? void 0 : _beforeUpload(file, fileList);
1185
+ const val = beforeUpload === null || beforeUpload === void 0 ? void 0 : beforeUpload(file, fileList);
1201
1186
  if (val === false) {
1202
1187
  setShowLoading(false);
1203
1188
  curFileRef.current = null;
1204
1189
  return false;
1205
1190
  } else if (val instanceof Promise) return val;else return true;
1206
1191
  },
1207
- onStart: function onStart(file) {
1208
- _onStart === null || _onStart === void 0 ? void 0 : _onStart(file);
1192
+ onStart(file) {
1193
+ onStart === null || onStart === void 0 ? void 0 : onStart(file);
1209
1194
  },
1210
- onSuccess: function onSuccess(response, file, xhr) {
1195
+ onSuccess(response, file, xhr) {
1211
1196
  setShowLoading(false);
1212
1197
  curFileRef.current = null;
1213
1198
  errTip && showErrTip(false);
1214
- var nextFileList = updateFileList(file);
1199
+ const nextFileList = updateFileList(file);
1215
1200
  onInternalChange(nextFileList);
1216
- _onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(response, file, xhr);
1201
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response, file, xhr);
1217
1202
  },
1218
- onError: function onError(error, response, file) {
1203
+ onError(error, response, file) {
1219
1204
  setShowLoading(false);
1220
1205
  curFileRef.current = null;
1221
1206
  showErrTip(!!showUploadError);
1222
- _onError === null || _onError === void 0 ? void 0 : _onError(error, response, file);
1207
+ onError === null || onError === void 0 ? void 0 : onError(error, response, file);
1223
1208
  },
1224
- onProgress: function onProgress(e, file) {
1225
- _onProgress === null || _onProgress === void 0 ? void 0 : _onProgress(e, file);
1209
+ onProgress(e, file) {
1210
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, file);
1226
1211
  },
1227
- onBatchStart: function onBatchStart(fileList) {
1212
+ onBatchStart(fileList) {
1228
1213
  if (stash) {
1229
- var arr = fileList.map(function (_) {
1230
- return _.file;
1231
- });
1214
+ const arr = fileList.map(_ => _.file);
1232
1215
  if (type === 'drag' && restProps.accept && recordNonAcceptFileRef.current) {
1233
1216
  arr.push(recordNonAcceptFileRef.current);
1234
1217
  recordNonAcceptFileRef.current = null;
1235
1218
  }
1236
- var mList = mergedFileList(arr);
1219
+ const mList = mergedFileList(arr);
1237
1220
  onInternalChange(mList);
1238
1221
  }
1239
1222
  }
1240
1223
  });
1241
1224
  //内部变化
1242
- var onInternalChange = function onInternalChange(changedFileList) {
1243
- var cloneList = _toConsumableArray(changedFileList);
1225
+ const onInternalChange = changedFileList => {
1226
+ let cloneList = [...changedFileList];
1244
1227
  // Cut to match count
1245
1228
  if (maxCount === 1) {
1246
1229
  cloneList = cloneList.slice(-1);
@@ -1251,9 +1234,9 @@ var InternalUpload = function InternalUpload(props) {
1251
1234
  setUploadFileList(cloneList);
1252
1235
  };
1253
1236
  //更新文件列表
1254
- var updateFileList = function updateFileList(file) {
1255
- var cloneList = _toConsumableArray(uploadFileList);
1256
- var fileObj = Object.assign(Object.assign({}, file), {
1237
+ const updateFileList = file => {
1238
+ const cloneList = [...uploadFileList];
1239
+ const fileObj = Object.assign(Object.assign({}, file), {
1257
1240
  lastModified: file.lastModified,
1258
1241
  lastModifiedDate: file.lastModifiedDate,
1259
1242
  name: file.name,
@@ -1265,9 +1248,9 @@ var InternalUpload = function InternalUpload(props) {
1265
1248
  return cloneList.concat(fileObj);
1266
1249
  };
1267
1250
  //合并文件列表
1268
- var mergedFileList = function mergedFileList(fileList) {
1269
- var cloneList = _toConsumableArray(uploadFileList);
1270
- var newFileList = fileList.map(function (file) {
1251
+ const mergedFileList = fileList => {
1252
+ const cloneList = [...uploadFileList];
1253
+ const newFileList = fileList.map(file => {
1271
1254
  return Object.assign(Object.assign({}, file), {
1272
1255
  lastModified: file.lastModified,
1273
1256
  lastModifiedDate: file.lastModifiedDate,
@@ -1281,19 +1264,17 @@ var InternalUpload = function InternalUpload(props) {
1281
1264
  return cloneList.concat(newFileList);
1282
1265
  };
1283
1266
  //删除文件
1284
- var handleRemove = function handleRemove(file) {
1285
- Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(function (ret) {
1267
+ const handleRemove = file => {
1268
+ Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(ret => {
1286
1269
  // Prevent removing file
1287
1270
  if (ret === false) return;
1288
- var idx = uploadFileList.findIndex(function (_) {
1289
- return _.uid === file.uid;
1290
- });
1271
+ const idx = uploadFileList.findIndex(_ => _.uid === file.uid);
1291
1272
  if (idx > -1) uploadFileList.splice(idx, 1);
1292
1273
  onInternalChange(uploadFileList);
1293
1274
  });
1294
1275
  };
1295
1276
  //拖拽区域
1296
- var onFileDrop = function onFileDrop(e) {
1277
+ const onFileDrop = e => {
1297
1278
  var _a, _b;
1298
1279
  e.preventDefault();
1299
1280
  e.stopPropagation();
@@ -1302,9 +1283,9 @@ var InternalUpload = function InternalUpload(props) {
1302
1283
  onDrop === null || onDrop === void 0 ? void 0 : onDrop(e);
1303
1284
  //拖拽且设置accept
1304
1285
  if (type === 'drag' && restProps.accept) {
1305
- var dropFile = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
1286
+ const dropFile = (_b = (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
1306
1287
  if (dropFile) {
1307
- var reg = new RegExp(restProps.accept, 'ig');
1288
+ const reg = new RegExp(restProps.accept, 'ig');
1308
1289
  if (!reg.test(dropFile.type)) {
1309
1290
  recordNonAcceptFileRef.current = dropFile;
1310
1291
  }
@@ -1313,33 +1294,34 @@ var InternalUpload = function InternalUpload(props) {
1313
1294
  }
1314
1295
  };
1315
1296
  //显示错误提示
1316
- var showErrTip = function showErrTip(flag) {
1297
+ const showErrTip = flag => {
1317
1298
  setErrTip(flag);
1318
1299
  if (leaveDelay < 0) return;
1319
- setTimeout(function () {
1300
+ setTimeout(() => {
1320
1301
  setErrTip(false);
1321
1302
  }, leaveDelay);
1322
1303
  };
1323
- useEffect(function () {
1304
+ useEffect(() => {
1324
1305
  if (fileList) {
1325
- setUploadFileList(_toConsumableArray(fileList));
1306
+ setUploadFileList([...fileList]);
1326
1307
  }
1327
1308
  }, [fileList]);
1309
+ useEffect(() => {
1310
+ setShowLoading(loading);
1311
+ }, [loading]);
1328
1312
  //渲染上传列表
1329
- var renderUploadList = function renderUploadList() {
1330
- return showUploadList && jsx(UploadList, {
1331
- listType: 'text',
1332
- items: uploadFileList,
1333
- showRemoveIcon: showRemoveIcon,
1334
- removeIcon: removeIcon,
1335
- onRemove: handleRemove,
1336
- itemRender: itemRender
1337
- });
1338
- };
1313
+ const renderUploadList = () => showUploadList && jsx(UploadList, {
1314
+ listType: 'text',
1315
+ items: uploadFileList,
1316
+ showRemoveIcon: showRemoveIcon,
1317
+ removeIcon: removeIcon,
1318
+ onRemove: handleRemove,
1319
+ itemRender: itemRender
1320
+ });
1339
1321
  //渲染上传按钮
1340
- var renderButton = function renderButton() {
1341
- var icon = jsx(UploadIcon, {});
1342
- var text = children;
1322
+ const renderButton = () => {
1323
+ let icon = jsx(UploadIcon, {});
1324
+ let text = children;
1343
1325
  if (showLoading) {
1344
1326
  text = intl({
1345
1327
  id: 'uploading'
@@ -1358,22 +1340,20 @@ var InternalUpload = function InternalUpload(props) {
1358
1340
  }));
1359
1341
  };
1360
1342
  //渲染拖拽区域
1361
- var renderDragArea = function renderDragArea() {
1343
+ const renderDragArea = () => {
1362
1344
  var _a;
1363
- var icon = jsx(UploadIcon, {});
1364
- var text = intl({
1345
+ const icon = jsx(UploadIcon, {});
1346
+ const text = intl({
1365
1347
  id: 'clickUploadFile'
1366
1348
  });
1367
- var hint = intl({
1349
+ const hint = intl({
1368
1350
  id: 'dragFileUpload'
1369
1351
  });
1370
- var _ref3 = dragArea !== null && dragArea !== void 0 ? dragArea : {},
1371
- _ref3$areaIcon = _ref3.areaIcon,
1372
- areaIcon = _ref3$areaIcon === void 0 ? icon : _ref3$areaIcon,
1373
- _ref3$areaText = _ref3.areaText,
1374
- areaText = _ref3$areaText === void 0 ? text : _ref3$areaText,
1375
- _ref3$areaDesc = _ref3.areaDesc,
1376
- areaDesc = _ref3$areaDesc === void 0 ? hint : _ref3$areaDesc;
1352
+ let {
1353
+ areaIcon = icon,
1354
+ areaText = text,
1355
+ areaDesc = hint
1356
+ } = dragArea !== null && dragArea !== void 0 ? dragArea : {};
1377
1357
  if (showLoading) {
1378
1358
  areaIcon = jsx(LoadingIcon, {
1379
1359
  className: 'upload-drag-loading'
@@ -1412,8 +1392,10 @@ var InternalUpload = function InternalUpload(props) {
1412
1392
  };
1413
1393
  //拖拽上传
1414
1394
  if (type === 'drag') {
1415
- var _clsx;
1416
- var dragCls = clsx("".concat($prefixCls, "-upload-drag"), className, (_clsx = {}, _defineProperty(_clsx, "".concat($prefixCls, "-upload-drag-loading"), showLoading), _defineProperty(_clsx, "".concat($prefixCls, "-upload-drag-hover"), dragState === 'dragover'), _clsx));
1395
+ const dragCls = clsx("".concat($prefixCls, "-upload-drag"), className, {
1396
+ ["".concat($prefixCls, "-upload-drag-loading")]: showLoading,
1397
+ ["".concat($prefixCls, "-upload-drag-hover")]: dragState === 'dragover'
1398
+ });
1417
1399
  return jsxs("div", Object.assign({
1418
1400
  className: dragCls,
1419
1401
  onDrop: onFileDrop,
@@ -1430,7 +1412,7 @@ var InternalUpload = function InternalUpload(props) {
1430
1412
  })]
1431
1413
  }));
1432
1414
  }
1433
- var makeCls = clsx("".concat($prefixCls, "-upload"), className, showLoading && "".concat($prefixCls, "-upload-loading"));
1415
+ const makeCls = clsx("".concat($prefixCls, "-upload"), className, showLoading && "".concat($prefixCls, "-upload-loading"));
1434
1416
  return jsxs("div", Object.assign({
1435
1417
  className: makeCls,
1436
1418
  style: style
@@ -1444,7 +1426,7 @@ var InternalUpload = function InternalUpload(props) {
1444
1426
  })), renderUploadList()]
1445
1427
  }));
1446
1428
  };
1447
- var Upload = InternalUpload;
1429
+ const Upload = InternalUpload;
1448
1430
  Upload.ImageUpload = ImageUpload;
1449
1431
  Upload.Dragger = Dragger;
1450
1432
  Upload.ImgCrop = ImgCrop;
@@ -109,6 +109,8 @@ export interface UploadProps<T = any> {
109
109
  showLoading?: boolean;
110
110
  /** 是否显示上传loading,后期删除*/
111
111
  uploading?: boolean;
112
+ /** 是否展示loading */
113
+ loading?: boolean;
112
114
  /** 当文件被拖入上传区域时执行的回调功能 */
113
115
  onDrop?: (event: React.DragEvent) => void;
114
116
  /** 拖拽上传时 拖拽区域元素 */
@@ -4,7 +4,7 @@
4
4
  * @description 全局变量
5
5
  */
6
6
  /** 组件全局class前缀 */
7
- var $prefixCls = 'paraui-v4';
8
- var $rcPrefixCls = 'component';
7
+ const $prefixCls = 'paraui-v4';
8
+ const $rcPrefixCls = 'component';
9
9
 
10
10
  export { $prefixCls as $, $rcPrefixCls as a };