@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.
- package/AutoBox/index.js +72 -85
- package/AutoTips/index.js +72 -95
- package/Badge/index.js +17 -16
- package/Breadcrumbs/index.js +57 -73
- package/Button/index.js +90 -118
- package/ButtonGroup/index.js +30 -33
- package/Carousel/index.js +29 -33
- package/Cascader/index.js +9 -10
- package/Checkbox/index.js +28 -35
- package/CheckboxGroup/index.js +43 -58
- package/Collapse/index.js +52 -49
- package/CollapseBox/index.js +65 -70
- package/CollapseLayout/index.js +106 -101
- package/ColorPicker/index.js +3 -3
- package/ComboSelect/index.js +260 -337
- package/ComboSelect/lang/en_US.d.ts +1 -0
- package/ComboSelect/lang/index.d.ts +2 -0
- package/ComboSelect/lang/zh_CN.d.ts +1 -0
- package/ComboSelect/utils.d.ts +6 -0
- package/Container/index.js +17 -21
- package/CopyText/index.js +50 -83
- package/DatePicker/index.js +24 -27
- package/Descriptions/index.js +50 -59
- package/Desktop/index.js +161 -180
- package/DragVerify/index.js +77 -113
- package/Drawer/index.js +80 -95
- package/Dropdown/index.js +3 -3
- package/DynamicMultiBox/index.js +222 -224
- package/DynamicMultiBox/interface.d.ts +7 -0
- package/Empty/index.js +26 -28
- package/Form/index.js +70 -74
- package/FormItem/index.js +18 -15
- package/FunctionModal/index.js +7 -14
- package/GlobalContext/index.js +17 -20
- package/Help/index.js +9 -12
- package/HelperText/index.js +11 -11
- package/InputLang/index.js +104 -124
- package/InputNumber/index.js +62 -81
- package/Label/index.js +19 -21
- package/Loading/index.js +11 -10
- package/Menu/index.js +302 -371
- package/Message/index.js +104 -113
- package/Modal/index.js +122 -148
- package/MultiBox/index.d.ts +5 -0
- package/MultiBox/index.js +111 -115
- package/Notification/index.js +105 -103
- package/OperateBtn/index.d.ts +3 -0
- package/OperateBtn/index.js +77 -107
- package/PageHeader/index.js +327 -406
- package/Pagination/index.js +107 -137
- package/ParauiProvider/index.js +20 -22
- package/PasswordRules/index.js +36 -40
- package/PopConfirm/index.js +60 -77
- package/Popover/index.js +12 -12
- package/Progress/index.js +72 -74
- package/Querying/index.js +22 -23
- package/README.md +2 -0
- package/Radio/index.js +27 -34
- package/RadioGroup/index.js +38 -52
- package/Search/index.js +34 -43
- package/Select/index.js +281 -345
- package/SelectInput/index.js +8 -13
- package/Selector/index.js +582 -796
- package/SelectorPicker/index.js +113 -134
- package/SingleBox/index.d.ts +5 -0
- package/SingleBox/index.js +92 -88
- package/Slider/index.js +46 -57
- package/Status/index.js +14 -13
- package/Stepper/index.js +24 -25
- package/Styles/theme.scss +9 -9
- package/Switch/index.js +32 -35
- package/Table/index.js +360 -494
- package/Tabs/index.js +100 -100
- package/Tag/index.js +64 -82
- package/TextEditor/index.js +78 -100
- package/TextField/index.js +142 -183
- package/TimePicker/index.js +29 -28
- package/Timeline/index.js +50 -47
- package/Title/index.js +32 -34
- package/ToggleButton/index.js +29 -29
- package/Tooltip/index.js +52 -56
- package/Transfer/index.js +117 -154
- package/Tree/index.js +9 -10
- package/Upload/index.js +125 -143
- package/Upload/interface.d.ts +2 -0
- package/_verture/{constant-0d9802f7.js → constant-5317fc89.js} +2 -2
- package/_verture/{index-5a7e2438.js → index-3cdaba96.js} +967 -934
- package/_verture/{index-b1f80962.js → index-4fafd0a0.js} +6 -8
- package/_verture/{index-024bbc9b.js → index-775ad32d.js} +29 -25
- package/_verture/{index-05f7bf11.js → index-c568f272.js} +2 -2
- package/_verture/{index-232d890b.js → index-d63bd287.js} +1 -1
- package/_verture/index-da9097d3.js +239 -0
- package/_verture/{index-9331b116.js → index-e0f9064d.js} +125 -134
- package/_verture/intl-f2f27722.js +69 -0
- package/_verture/{modalContext-736ff215.js → modalContext-8534f23d.js} +36 -64
- package/_verture/{slicedToArray-a8206399.js → slicedToArray-75fa4188.js} +15 -2
- package/_verture/{toConsumableArray-8f4c9589.js → toConsumableArray-c7a8028f.js} +1 -1
- package/_verture/{useFormatMessage-703f8b20.js → useFormatMessage-eb13cf56.js} +5 -4
- package/_verture/{useGlobalProps-1b846a65.js → useGlobalProps-1e416658.js} +4 -3
- package/_verture/{usePopupContainer-87febeb9.js → usePopupContainer-635f66f4.js} +16 -15
- package/_verture/{util-7e1fb1e2.js → util-82646c4f.js} +5 -4
- package/_verture/utils-c17b5265.js +97 -0
- package/index.js +24 -23
- package/locale/en-US.d.ts +1 -0
- package/locale/index.d.ts +2 -0
- package/locale/index.js +10 -8
- package/locale/zh-CN.d.ts +1 -0
- package/package.json +11 -10
- package/umd/AutoBox.js +9 -8
- package/umd/AutoTips.js +9 -8
- package/umd/Badge.js +1 -1
- package/umd/Breadcrumbs.js +9 -8
- package/umd/Button.js +9 -8
- package/umd/ButtonGroup.js +9 -8
- package/umd/Carousel.js +5 -5
- package/umd/Cascader.js +9 -8
- package/umd/Checkbox.js +9 -8
- package/umd/CheckboxGroup.js +9 -8
- package/umd/Collapse.js +8 -7
- package/umd/CollapseBox.js +1 -1
- package/umd/CollapseLayout.js +4 -4
- package/umd/ColorPicker.js +1 -1
- package/umd/ComboSelect.js +9 -8
- package/umd/Container.js +1 -1
- package/umd/CopyText.js +9 -8
- package/umd/DatePicker.js +9 -8
- package/umd/Descriptions.js +9 -8
- package/umd/Desktop.js +9 -8
- package/umd/DragVerify.js +4 -4
- package/umd/Drawer.js +9 -8
- package/umd/Dropdown.js +6 -5
- package/umd/DynamicMultiBox.js +11 -10
- package/umd/Empty.js +1 -1
- package/umd/Form.js +9 -8
- package/umd/FormItem.js +9 -8
- package/umd/FunctionModal.js +9 -8
- package/umd/GlobalContext.js +1 -1
- package/umd/Help.js +9 -8
- package/umd/HelperText.js +1 -1
- package/umd/InputLang.js +9 -8
- package/umd/InputNumber.js +9 -8
- package/umd/Label.js +9 -8
- package/umd/Loading.js +4 -4
- package/umd/Menu.js +4 -4
- package/umd/Message.js +4 -4
- package/umd/Modal.js +9 -8
- package/umd/MultiBox.js +9 -8
- package/umd/Notification.js +8 -7
- package/umd/OperateBtn.js +9 -8
- package/umd/PageHeader.js +9 -8
- package/umd/Pagination.js +9 -8
- package/umd/ParauiProvider.js +1 -1
- package/umd/PasswordRules.js +4 -4
- package/umd/PopConfirm.js +9 -8
- package/umd/Popover.js +9 -8
- package/umd/Progress.js +5 -5
- package/umd/Querying.js +1 -1
- package/umd/Radio.js +9 -8
- package/umd/RadioGroup.js +9 -8
- package/umd/Search.js +9 -8
- package/umd/Select.js +9 -8
- package/umd/SelectInput.js +9 -8
- package/umd/Selector.js +9 -8
- package/umd/SelectorPicker.js +9 -8
- package/umd/SingleBox.js +9 -8
- package/umd/Slider.js +6 -5
- package/umd/Status.js +4 -4
- package/umd/Stepper.js +9 -8
- package/umd/Switch.js +9 -8
- package/umd/Table.js +9 -8
- package/umd/Tabs.js +9 -8
- package/umd/Tag.js +9 -8
- package/umd/TextEditor.js +22 -21
- package/umd/TextField.js +9 -8
- package/umd/TimePicker.js +9 -8
- package/umd/Timeline.js +1 -1
- package/umd/Title.js +9 -8
- package/umd/ToggleButton.js +9 -8
- package/umd/Tooltip.js +9 -8
- package/umd/Transfer.js +10 -9
- package/umd/Tree.js +9 -8
- package/umd/Upload.js +10 -9
- package/umd/locale.js +1 -1
- package/_verture/index-e9007d6a.js +0 -236
- package/_verture/intl-5c1ec055.js +0 -81
- package/_verture/unsupportedIterableToArray-cb478f24.js +0 -16
- package/_verture/utils-418da0a4.js +0 -73
- /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-
|
|
2
|
-
export { T as default } from '../_verture/index-
|
|
3
|
-
import '../_verture/toConsumableArray-
|
|
4
|
-
import '../_verture/
|
|
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/
|
|
8
|
-
import '../_verture/
|
|
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-
|
|
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-
|
|
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-
|
|
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 {
|
|
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-
|
|
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-
|
|
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/
|
|
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-
|
|
31
|
+
import '../_verture/index-da9097d3.js';
|
|
34
32
|
import 'rc-dropdown';
|
|
35
|
-
import '../_verture/usePopupContainer-
|
|
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-
|
|
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
|
-
|
|
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 &&
|
|
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
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
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
|
-
})
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
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
|
-
|
|
1195
|
-
beforeUpload
|
|
1196
|
-
if (restProps.action &&
|
|
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
|
-
|
|
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
|
|
1208
|
-
|
|
1192
|
+
onStart(file) {
|
|
1193
|
+
onStart === null || onStart === void 0 ? void 0 : onStart(file);
|
|
1209
1194
|
},
|
|
1210
|
-
onSuccess
|
|
1195
|
+
onSuccess(response, file, xhr) {
|
|
1211
1196
|
setShowLoading(false);
|
|
1212
1197
|
curFileRef.current = null;
|
|
1213
1198
|
errTip && showErrTip(false);
|
|
1214
|
-
|
|
1199
|
+
const nextFileList = updateFileList(file);
|
|
1215
1200
|
onInternalChange(nextFileList);
|
|
1216
|
-
|
|
1201
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response, file, xhr);
|
|
1217
1202
|
},
|
|
1218
|
-
onError
|
|
1203
|
+
onError(error, response, file) {
|
|
1219
1204
|
setShowLoading(false);
|
|
1220
1205
|
curFileRef.current = null;
|
|
1221
1206
|
showErrTip(!!showUploadError);
|
|
1222
|
-
|
|
1207
|
+
onError === null || onError === void 0 ? void 0 : onError(error, response, file);
|
|
1223
1208
|
},
|
|
1224
|
-
onProgress
|
|
1225
|
-
|
|
1209
|
+
onProgress(e, file) {
|
|
1210
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, file);
|
|
1226
1211
|
},
|
|
1227
|
-
onBatchStart
|
|
1212
|
+
onBatchStart(fileList) {
|
|
1228
1213
|
if (stash) {
|
|
1229
|
-
|
|
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
|
-
|
|
1219
|
+
const mList = mergedFileList(arr);
|
|
1237
1220
|
onInternalChange(mList);
|
|
1238
1221
|
}
|
|
1239
1222
|
}
|
|
1240
1223
|
});
|
|
1241
1224
|
//内部变化
|
|
1242
|
-
|
|
1243
|
-
|
|
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
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
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
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
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
|
-
|
|
1285
|
-
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1297
|
+
const showErrTip = flag => {
|
|
1317
1298
|
setErrTip(flag);
|
|
1318
1299
|
if (leaveDelay < 0) return;
|
|
1319
|
-
setTimeout(
|
|
1300
|
+
setTimeout(() => {
|
|
1320
1301
|
setErrTip(false);
|
|
1321
1302
|
}, leaveDelay);
|
|
1322
1303
|
};
|
|
1323
|
-
useEffect(
|
|
1304
|
+
useEffect(() => {
|
|
1324
1305
|
if (fileList) {
|
|
1325
|
-
setUploadFileList(
|
|
1306
|
+
setUploadFileList([...fileList]);
|
|
1326
1307
|
}
|
|
1327
1308
|
}, [fileList]);
|
|
1309
|
+
useEffect(() => {
|
|
1310
|
+
setShowLoading(loading);
|
|
1311
|
+
}, [loading]);
|
|
1328
1312
|
//渲染上传列表
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
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
|
-
|
|
1343
|
+
const renderDragArea = () => {
|
|
1362
1344
|
var _a;
|
|
1363
|
-
|
|
1364
|
-
|
|
1345
|
+
const icon = jsx(UploadIcon, {});
|
|
1346
|
+
const text = intl({
|
|
1365
1347
|
id: 'clickUploadFile'
|
|
1366
1348
|
});
|
|
1367
|
-
|
|
1349
|
+
const hint = intl({
|
|
1368
1350
|
id: 'dragFileUpload'
|
|
1369
1351
|
});
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
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
|
-
|
|
1416
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1429
|
+
const Upload = InternalUpload;
|
|
1448
1430
|
Upload.ImageUpload = ImageUpload;
|
|
1449
1431
|
Upload.Dragger = Dragger;
|
|
1450
1432
|
Upload.ImgCrop = ImgCrop;
|
package/Upload/interface.d.ts
CHANGED
|
@@ -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
|
/** 拖拽上传时 拖拽区域元素 */
|