@para-ui/core 4.0.0-rc.7 → 4.0.1
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/Button/index.js +1 -1
- package/ButtonGroup/index.js +1 -1
- package/Cascader/index.js +4 -5
- package/ComboSelect/index.js +14 -16
- 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/CopyText/index.js +8 -6
- package/DatePicker/index.js +2 -4
- package/Descriptions/index.js +1 -1
- package/Desktop/index.js +1 -1
- package/Drawer/index.js +1 -1
- package/Dropdown/index.js +1 -1
- package/DynamicMultiBox/index.js +6 -9
- package/Form/index.js +5 -9
- package/FormItem/index.js +5 -9
- package/FunctionModal/index.js +3 -3
- package/InputLang/index.js +1 -1
- package/Modal/index.js +1 -1
- package/MultiBox/index.js +1 -1
- package/OperateBtn/index.js +1 -1
- package/PageHeader/index.js +1 -1
- package/Pagination/index.js +1 -1
- package/PopConfirm/index.js +2 -2
- package/Popover/index.js +1 -1
- package/QuickReply/index.js +2 -2
- package/README.md +6 -105
- package/Search/index.d.ts +1 -1
- package/Search/index.js +5 -3
- package/Select/index.js +3 -2
- package/SelectInput/index.js +2 -2
- package/Selector/index.js +328 -5
- package/SelectorPicker/index.js +3 -4
- package/SingleBox/index.js +1 -1
- package/Switch/index.js +8 -8
- package/Table/index.js +411 -473
- package/Tabs/index.js +3 -3
- package/Tag/index.js +53 -82
- package/TextEditor/index.js +3 -3
- package/TextField/index.js +2 -2
- package/TimePicker/index.js +2 -4
- package/Timeline/index.js +20 -14
- package/ToggleButton/index.js +27 -26
- package/Tooltip/index.js +27 -26
- package/Transfer/index.js +45 -50
- package/Tree/index.js +4 -8
- package/Upload/index.js +409 -626
- package/_verture/{index-f518e244.js → index-00dc302a.js} +1 -1
- package/_verture/{index-da9097d3.js → index-389675ab.js} +1 -1
- package/_verture/{index-466a3496.js → index-9784b09c.js} +18 -3
- package/_verture/{index-3156e3ef.js → index-e3011376.js} +312 -394
- package/_verture/{slicedToArray-75fa4188.js → slicedToArray-8223a2ef.js} +1 -1
- package/index.js +8 -10
- package/locale/en-US.d.ts +1 -0
- package/locale/index.d.ts +2 -0
- package/locale/index.js +4 -2
- package/locale/zh-CN.d.ts +1 -0
- package/package.json +3 -2
- package/umd/AutoBox.js +1 -1
- package/umd/Breadcrumbs.js +1 -1
- package/umd/Button.js +1 -1
- package/umd/ButtonGroup.js +1 -1
- package/umd/ComboSelect.js +2 -2
- package/umd/CopyText.js +2 -2
- package/umd/DatePicker.js +1 -1
- package/umd/Descriptions.js +1 -1
- package/umd/Desktop.js +1 -1
- package/umd/Drawer.js +1 -1
- package/umd/Dropdown.js +1 -1
- package/umd/DynamicMultiBox.js +2 -2
- package/umd/Form.js +4 -4
- package/umd/FormItem.js +2 -2
- package/umd/FunctionModal.js +1 -1
- package/umd/InputLang.js +1 -1
- package/umd/Modal.js +1 -1
- package/umd/MultiBox.js +1 -1
- package/umd/OperateBtn.js +1 -1
- package/umd/PageHeader.js +1 -1
- package/umd/Pagination.js +2 -2
- package/umd/PopConfirm.js +1 -1
- package/umd/Popover.js +1 -1
- package/umd/QuickReply.js +1 -1
- package/umd/Search.js +2 -2
- package/umd/Select.js +2 -2
- package/umd/SelectInput.js +2 -2
- package/umd/Selector.js +2 -2
- package/umd/SelectorPicker.js +2 -2
- package/umd/SingleBox.js +1 -1
- package/umd/Switch.js +1 -1
- package/umd/Table.js +2 -2
- package/umd/Tabs.js +1 -1
- package/umd/TextField.js +1 -1
- package/umd/TimePicker.js +1 -1
- package/umd/ToggleButton.js +1 -1
- package/umd/Transfer.js +2 -2
- package/umd/Upload.js +1 -1
- package/umd/locale.js +1 -1
- package/_verture/index-d63bd287.js +0 -327
- package/_verture/toConsumableArray-c7a8028f.js +0 -19
- /package/_verture/{index-d6093d1c.js → index-28a6bc3a.js} +0 -0
- /package/_verture/{modalContext-7b512b0c.js → modalContext-ea977824.js} +0 -0
- /package/_verture/{typeof-b240b062.js → typeof-c310ee4a.js} +0 -0
package/Upload/index.js
CHANGED
|
@@ -4,10 +4,6 @@ import { useState, useEffect, useRef, memo, forwardRef, useCallback, useImperati
|
|
|
4
4
|
import RcUpload from 'rc-upload';
|
|
5
5
|
import UploadIcon from '@para-ui/icons/UploadFile';
|
|
6
6
|
import LoadingIcon from '@para-ui/icons/Loading';
|
|
7
|
-
import { _ as _toConsumableArray } from '../_verture/toConsumableArray-c7a8028f.js';
|
|
8
|
-
import { _ as _typeof } from '../_verture/typeof-adeedc13.js';
|
|
9
|
-
import { _ as _slicedToArray } from '../_verture/slicedToArray-75fa4188.js';
|
|
10
|
-
import { r as regenerator } from '../_verture/index-d63bd287.js';
|
|
11
7
|
import Delete from '@para-ui/icons/Delete';
|
|
12
8
|
import TextIcon from '@para-ui/icons/Text';
|
|
13
9
|
import PhotoIcon from '@para-ui/icons/Photo';
|
|
@@ -18,17 +14,17 @@ import Forbid from '@para-ui/icons/Forbid';
|
|
|
18
14
|
import { u as useFormatMessage } from '../_verture/useFormatMessage-eb13cf56.js';
|
|
19
15
|
import EditOutline from '@para-ui/icons/EditOutline';
|
|
20
16
|
import { Button } from '../Button/index.js';
|
|
17
|
+
import { b as _slicedToArray } from '../_verture/slicedToArray-8223a2ef.js';
|
|
21
18
|
import { Slider } from '../Slider/index.js';
|
|
22
19
|
import Cropper from 'react-easy-crop';
|
|
23
20
|
import { Modal } from '../Modal/index.js';
|
|
24
|
-
import '../_verture/typeof-b240b062.js';
|
|
25
21
|
import '@para-ui/core/GlobalContext';
|
|
26
22
|
import '@para-ui/icons/LoadingF';
|
|
27
23
|
import '../Tooltip/index.js';
|
|
28
24
|
import 'rc-tooltip';
|
|
29
25
|
import 'rc-tooltip/lib/placements';
|
|
30
26
|
import '@para-ui/icons/Down';
|
|
31
|
-
import '../_verture/index-
|
|
27
|
+
import '../_verture/index-389675ab.js';
|
|
32
28
|
import 'rc-dropdown';
|
|
33
29
|
import '../_verture/usePopupContainer-635f66f4.js';
|
|
34
30
|
import 'dayjs';
|
|
@@ -43,53 +39,44 @@ import '@para-ui/icons/CheckCircleF';
|
|
|
43
39
|
import '@para-ui/icons/WarningCircleF';
|
|
44
40
|
import '@para-ui/icons/CloseCircleF';
|
|
45
41
|
|
|
46
|
-
var css_248z$4 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午3:08\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-list-text .upload-list-item {\n margin-top: 8px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info {\n display: flex;\n align-items: center;\n padding: 0 8px;\n line-height: 28px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n border-radius: 4px;\n transition: background-color 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon {\n line-height: 0;\n opacity: 1;\n transition: opacity 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon svg {\n color: inherit;\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text-name {\n margin-left: 10px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions {\n position: absolute;\n opacity: 0;\n visibility: hidden;\n line-height: 0;\n transition: opacity 0.3s;\n cursor: pointer;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg {\n color: rgb(244, 66, 66);\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover {\n background-color: rgb(247, 248, 250);\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-actions {\n visibility: visible;\n opacity: 1;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-fileicon-active {\n opacity: 0;\n}\n.paraui-v4-upload-list-picture {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item {\n position: relative;\n display: inline-block;\n width: 100px;\n height: 100px;\n margin-right: 16px;\n border-radius: 4px;\n cursor: default;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly)::before {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-actions {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-picture-name {\n opacity: 0;\n}";
|
|
42
|
+
var css_248z$4 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午3:08\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-list-text .upload-list-item {\n margin-top: 8px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info {\n display: flex;\n align-items: center;\n padding: 0 8px;\n line-height: 28px;\n font-size: 14px;\n color: rgb(29, 33, 38);\n border-radius: 4px;\n transition: background-color 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text {\n position: relative;\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon {\n line-height: 0;\n opacity: 1;\n transition: opacity 0.3s;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-fileicon svg {\n color: inherit;\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text-name {\n margin-left: 10px;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions {\n position: absolute;\n left: 0;\n top: 50%;\n transform: translateY(-50%);\n z-index: -1;\n opacity: 0;\n visibility: hidden;\n line-height: 0;\n transition: opacity 0.3s;\n cursor: pointer;\n}\n.paraui-v4-upload-list-text .upload-list-item-info .upload-list-text .upload-list-actions svg {\n color: rgb(244, 66, 66);\n font-size: inherit;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover {\n background-color: rgb(247, 248, 250);\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-actions {\n visibility: visible;\n opacity: 1;\n z-index: 1;\n}\n.paraui-v4-upload-list-text .upload-list-item-info:hover .upload-list-text .upload-list-fileicon-active {\n opacity: 0;\n}\n.paraui-v4-upload-list-picture {\n display: inline-flex;\n align-items: center;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item {\n position: relative;\n display: inline-block;\n width: 100px;\n height: 100px;\n margin-right: 16px;\n border-radius: 4px;\n cursor: default;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item::before {\n content: \" \";\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-picture-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n font-size: 12px;\n line-height: 24px;\n text-align: center;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n color: rgb(255, 255, 255);\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n opacity: 0;\n line-height: 0;\n cursor: pointer;\n transition: 0.3s;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item .upload-list-actions svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly)::before {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-actions {\n opacity: 1;\n}\n.paraui-v4-upload-list-picture .upload-list-picture-item:hover:not(.upload-list-picture-item-readonly) .upload-list-picture-name {\n opacity: 0;\n}";
|
|
47
43
|
styleInject(css_248z$4);
|
|
48
44
|
|
|
49
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
50
|
-
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); }
|
|
51
|
-
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; }
|
|
52
45
|
//UploadList
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
listType =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var _useState = useState([]),
|
|
65
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
66
|
-
uploadList = _useState2[0],
|
|
67
|
-
setUploadList = _useState2[1];
|
|
46
|
+
const UploadList = props => {
|
|
47
|
+
const {
|
|
48
|
+
listType = 'text',
|
|
49
|
+
items = [],
|
|
50
|
+
onRemove,
|
|
51
|
+
showRemoveIcon = true,
|
|
52
|
+
removeIcon,
|
|
53
|
+
itemRender,
|
|
54
|
+
readonly
|
|
55
|
+
} = props;
|
|
56
|
+
const [uploadList, setUploadList] = useState([]);
|
|
68
57
|
//处理删除
|
|
69
|
-
|
|
58
|
+
const handleRemove = (file, evt) => {
|
|
70
59
|
evt.stopPropagation();
|
|
71
60
|
onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);
|
|
72
61
|
};
|
|
73
62
|
//渲染列表actions
|
|
74
|
-
|
|
63
|
+
const renderActions = file => {
|
|
75
64
|
return showRemoveIcon && !readonly && jsx("span", Object.assign({
|
|
76
65
|
className: 'upload-list-actions',
|
|
77
|
-
onClick:
|
|
78
|
-
return handleRemove(file, evt);
|
|
79
|
-
}
|
|
66
|
+
onClick: evt => handleRemove(file, evt)
|
|
80
67
|
}, {
|
|
81
68
|
children: removeIcon || jsx(Delete, {})
|
|
82
69
|
}));
|
|
83
70
|
};
|
|
84
71
|
//文件列表 text
|
|
85
|
-
|
|
72
|
+
const renderFileListText = () => {
|
|
86
73
|
if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
|
|
87
|
-
return uploadList.map(
|
|
74
|
+
return uploadList.map((file, idx) => {
|
|
88
75
|
var _a;
|
|
89
76
|
if (itemRender)
|
|
90
77
|
//自定义渲染
|
|
91
78
|
return itemRender(file, uploadList);
|
|
92
|
-
|
|
79
|
+
const isImage = !!((_a = file.type) === null || _a === void 0 ? void 0 : _a.includes('image/'));
|
|
93
80
|
return jsx("div", Object.assign({
|
|
94
81
|
className: 'upload-list-item'
|
|
95
82
|
}, {
|
|
@@ -114,9 +101,9 @@ var UploadList = function UploadList(props) {
|
|
|
114
101
|
});
|
|
115
102
|
};
|
|
116
103
|
//文件列表 picture-card
|
|
117
|
-
|
|
104
|
+
const renderFileListPicture = () => {
|
|
118
105
|
if (!(uploadList === null || uploadList === void 0 ? void 0 : uploadList.length)) return null;
|
|
119
|
-
return uploadList.map(
|
|
106
|
+
return uploadList.map((file, idx) => {
|
|
120
107
|
if (itemRender)
|
|
121
108
|
//自定义渲染
|
|
122
109
|
return itemRender(file, uploadList);
|
|
@@ -136,84 +123,31 @@ var UploadList = function UploadList(props) {
|
|
|
136
123
|
});
|
|
137
124
|
};
|
|
138
125
|
//处理文件
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} else resolve('');
|
|
165
|
-
}));
|
|
166
|
-
case 1:
|
|
167
|
-
case "end":
|
|
168
|
-
return _context.stop();
|
|
169
|
-
}
|
|
170
|
-
}, _callee);
|
|
171
|
-
}));
|
|
172
|
-
};
|
|
173
|
-
_iterator = _createForOfIteratorHelper(items);
|
|
174
|
-
_context2.prev = 4;
|
|
175
|
-
_iterator.s();
|
|
176
|
-
case 6:
|
|
177
|
-
if ((_step = _iterator.n()).done) {
|
|
178
|
-
_context2.next = 15;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
file = _step.value;
|
|
182
|
-
if (!file.originFileObj) {
|
|
183
|
-
_context2.next = 13;
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
_context2.next = 11;
|
|
187
|
-
return readerFileAsDataUrl(file);
|
|
188
|
-
case 11:
|
|
189
|
-
dataUrl = _context2.sent;
|
|
190
|
-
file.dataUrl = dataUrl;
|
|
191
|
-
case 13:
|
|
192
|
-
_context2.next = 6;
|
|
193
|
-
break;
|
|
194
|
-
case 15:
|
|
195
|
-
_context2.next = 20;
|
|
196
|
-
break;
|
|
197
|
-
case 17:
|
|
198
|
-
_context2.prev = 17;
|
|
199
|
-
_context2.t0 = _context2["catch"](4);
|
|
200
|
-
_iterator.e(_context2.t0);
|
|
201
|
-
case 20:
|
|
202
|
-
_context2.prev = 20;
|
|
203
|
-
_iterator.f();
|
|
204
|
-
return _context2.finish(20);
|
|
205
|
-
case 23:
|
|
206
|
-
setUploadList(_toConsumableArray(items));
|
|
207
|
-
case 24:
|
|
208
|
-
case "end":
|
|
209
|
-
return _context2.stop();
|
|
210
|
-
}
|
|
211
|
-
}, _callee2, null, [[4, 17, 20, 23]]);
|
|
212
|
-
}));
|
|
213
|
-
};
|
|
214
|
-
useEffect(function () {
|
|
215
|
-
if (listType === 'picture-card') handleFileFormat();else setUploadList(function (pre) {
|
|
216
|
-
if (items) return _toConsumableArray(items);
|
|
126
|
+
const handleFileFormat = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
+
if (!(items === null || items === void 0 ? void 0 : items.length)) return setUploadList([]);
|
|
128
|
+
//读取file as DataUrl
|
|
129
|
+
const readerFileAsDataUrl = file => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
return new Promise(resolve => {
|
|
131
|
+
const fileReader = new FileReader();
|
|
132
|
+
if (file.originFileObj) {
|
|
133
|
+
fileReader.onload = () => {
|
|
134
|
+
resolve(fileReader.result);
|
|
135
|
+
};
|
|
136
|
+
fileReader.readAsDataURL(file.originFileObj);
|
|
137
|
+
} else resolve('');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
for (const file of items) {
|
|
141
|
+
if (file.originFileObj) {
|
|
142
|
+
const dataUrl = yield readerFileAsDataUrl(file);
|
|
143
|
+
file.dataUrl = dataUrl;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
setUploadList([...items]);
|
|
147
|
+
});
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (listType === 'picture-card') handleFileFormat();else setUploadList(pre => {
|
|
150
|
+
if (items) return [...items];
|
|
217
151
|
return pre;
|
|
218
152
|
});
|
|
219
153
|
}, [items]);
|
|
@@ -234,7 +168,7 @@ var css_248z$3 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/15
|
|
|
234
168
|
styleInject(css_248z$3);
|
|
235
169
|
|
|
236
170
|
//error tip
|
|
237
|
-
|
|
171
|
+
const ErrorTip = props => {
|
|
238
172
|
return jsxs("div", Object.assign({
|
|
239
173
|
className: clsx("".concat($prefixCls, "-upload-error"), props.className)
|
|
240
174
|
}, {
|
|
@@ -267,144 +201,99 @@ var zh = {
|
|
|
267
201
|
};
|
|
268
202
|
|
|
269
203
|
var localeJson = {
|
|
270
|
-
zh
|
|
271
|
-
en
|
|
204
|
+
zh,
|
|
205
|
+
en
|
|
272
206
|
};
|
|
273
207
|
|
|
274
208
|
var css_248z$2 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/11/11 下午7:31\n* @description\n*/\n/**\n* @author linhd\n* @date 2023/4/11 14:16\n* @description 最新色卡\n*/\n.paraui-v4-upload-image {\n display: inline-flex;\n align-items: center;\n /* &-border {\n .upload-image-select{\n border: 2px dashed $NA1;\n\n &:hover {\n border: 2px dashed $NPT8;\n }\n }\n } */\n}\n.paraui-v4-upload-image .upload-image-select {\n position: relative;\n width: 100px;\n height: 100px;\n cursor: pointer;\n background-color: rgb(247, 248, 250);\n border-radius: 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-select-loading {\n pointer-events: none;\n}\n.paraui-v4-upload-image .upload-image-select .component-upload {\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.paraui-v4-upload-image .upload-image-select:hover .upload-image-picture-card {\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card {\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 14px;\n color: rgb(29, 33, 38);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper {\n position: relative;\n width: 100%;\n height: 100%;\n cursor: default;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper img {\n width: 100%;\n height: 100%;\n border-radius: 4px;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n content: \" \";\n background-color: rgb(29, 33, 38);\n border-radius: 4px;\n opacity: 0;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-name {\n position: absolute;\n bottom: 0;\n left: 0;\n width: 100%;\n padding: 0 10px;\n overflow: hidden;\n font-size: 12px;\n line-height: 24px;\n color: rgb(255, 255, 255);\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap;\n background-color: rgb(29, 33, 38);\n border-radius: 0 0 4px 4px;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action {\n position: absolute;\n top: 50%;\n left: 50%;\n line-height: 0;\n cursor: pointer;\n opacity: 0;\n transition: 0.3s;\n transform: translate(-50%, -50%);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper-action svg {\n color: rgb(255, 255, 255);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover::before {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-name {\n opacity: 0;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-img-wrapper:hover .upload-img-wrapper-action {\n opacity: 1;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-icon {\n font-size: 30px;\n color: rgb(46, 101, 230);\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-loading {\n font-size: 30px;\n color: rgb(46, 101, 230);\n animation: imageLoadingCircle 1s infinite linear;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text {\n margin-top: 6px;\n color: inherit;\n text-align: center;\n transition: 0.3s;\n}\n.paraui-v4-upload-image .upload-image-picture-card .upload-image-text-loading {\n color: rgb(46, 101, 230);\n}\n@keyframes imageLoadingCircle {\n 100% {\n transform: rotate(360deg);\n }\n}";
|
|
275
209
|
styleInject(css_248z$2);
|
|
276
210
|
|
|
277
211
|
//ImageUpload
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
_props$loading = props.loading,
|
|
304
|
-
loading = _props$loading === void 0 ? false : _props$loading,
|
|
305
|
-
_props$showLoading = props.showLoading,
|
|
306
|
-
showLoadingProp = _props$showLoading === void 0 ? false : _props$showLoading,
|
|
307
|
-
defaultImage = props.defaultImage,
|
|
308
|
-
readonly = props.readonly,
|
|
212
|
+
const ImageUpload = props => {
|
|
213
|
+
const {
|
|
214
|
+
className,
|
|
215
|
+
style,
|
|
216
|
+
onStart,
|
|
217
|
+
onSuccess,
|
|
218
|
+
onError,
|
|
219
|
+
onProgress,
|
|
220
|
+
onRemove,
|
|
221
|
+
beforeUpload,
|
|
222
|
+
onChange,
|
|
223
|
+
defaultFileList = [],
|
|
224
|
+
fileList,
|
|
225
|
+
showUploadList = true,
|
|
226
|
+
maxCount,
|
|
227
|
+
children = null,
|
|
228
|
+
itemRender,
|
|
229
|
+
showUploadError = true,
|
|
230
|
+
stash = false,
|
|
231
|
+
uploading = true,
|
|
232
|
+
loading = false,
|
|
233
|
+
showLoading: showLoadingProp = false,
|
|
234
|
+
defaultImage,
|
|
235
|
+
readonly
|
|
236
|
+
} = props,
|
|
309
237
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var _useState7 = useState({
|
|
324
|
-
imageUrl: ''
|
|
325
|
-
}),
|
|
326
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
327
|
-
avatar = _useState8[0],
|
|
328
|
-
setAvatar = _useState8[1]; //不显示列表时上传头像
|
|
329
|
-
var _ref = typeof showUploadList === 'boolean' ? {} : showUploadList,
|
|
330
|
-
showRemoveIcon = _ref.showRemoveIcon,
|
|
331
|
-
removeIcon = _ref.removeIcon; //显示上传列表
|
|
332
|
-
var _ref2 = typeof showUploadError === 'boolean' ? {} : showUploadError,
|
|
333
|
-
_ref2$uploadErrorMsg = _ref2.uploadErrorMsg,
|
|
334
|
-
uploadErrorMsg = _ref2$uploadErrorMsg === void 0 ? intl({
|
|
238
|
+
const intl = useFormatMessage('Upload', localeJson);
|
|
239
|
+
const [uploadFileList, setUploadFileList] = useState(defaultFileList); //文件列表
|
|
240
|
+
const [showLoading, setShowLoading] = useState(false); //upload loading
|
|
241
|
+
const [errTip, setErrTip] = useState(false); //upload error tip
|
|
242
|
+
const [avatar, setAvatar] = useState({
|
|
243
|
+
imageUrl: ''
|
|
244
|
+
}); //不显示列表时上传头像
|
|
245
|
+
const {
|
|
246
|
+
showRemoveIcon,
|
|
247
|
+
removeIcon
|
|
248
|
+
} = typeof showUploadList === 'boolean' ? {} : showUploadList; //显示上传列表
|
|
249
|
+
const {
|
|
250
|
+
uploadErrorMsg = intl({
|
|
335
251
|
id: 'uploadError'
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
useEffect(
|
|
252
|
+
}),
|
|
253
|
+
leaveDelay = 2000
|
|
254
|
+
} = typeof showUploadError === 'boolean' ? {} : showUploadError; //错误信息提示
|
|
255
|
+
const cropFileRef = useRef(); //裁剪文件
|
|
256
|
+
useEffect(() => {
|
|
341
257
|
setShowLoading(loading);
|
|
342
258
|
}, [loading]);
|
|
343
259
|
//复写属性
|
|
344
|
-
|
|
260
|
+
const overrideProps = Object.assign(Object.assign({
|
|
345
261
|
accept: 'image/*'
|
|
346
262
|
}, restProps), {
|
|
347
|
-
beforeUpload:
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
362
|
-
setShowLoading(false);
|
|
363
|
-
return _context.abrupt("return", false);
|
|
364
|
-
case 9:
|
|
365
|
-
if (!(_typeof(result) === 'object' && result)) {
|
|
366
|
-
_context.next = 16;
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
if (!(result instanceof File || result instanceof Blob)) {
|
|
370
|
-
_context.next = 12;
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
return _context.abrupt("return", result);
|
|
374
|
-
case 12:
|
|
375
|
-
cropFileRef.current = result.cropFile;
|
|
376
|
-
return _context.abrupt("return", result.isUpload);
|
|
377
|
-
case 16:
|
|
378
|
-
return _context.abrupt("return", true);
|
|
379
|
-
case 17:
|
|
380
|
-
case "end":
|
|
381
|
-
return _context.stop();
|
|
382
|
-
}
|
|
383
|
-
}, _callee);
|
|
384
|
-
}));
|
|
385
|
-
},
|
|
386
|
-
onStart: function onStart(file) {
|
|
387
|
-
_onStart === null || _onStart === void 0 ? void 0 : _onStart(file);
|
|
263
|
+
beforeUpload: (file, fileList) => __awaiter(void 0, void 0, void 0, function* () {
|
|
264
|
+
if (restProps.action && showLoadingProp && uploading) setShowLoading(true);
|
|
265
|
+
const result = yield beforeUpload === null || beforeUpload === void 0 ? void 0 : beforeUpload(file, fileList);
|
|
266
|
+
if (result === false) {
|
|
267
|
+
setShowLoading(false);
|
|
268
|
+
return false;
|
|
269
|
+
} else if (typeof result === 'object' && result) {
|
|
270
|
+
if (result instanceof File || result instanceof Blob) return result;
|
|
271
|
+
cropFileRef.current = result.cropFile;
|
|
272
|
+
return result.isUpload;
|
|
273
|
+
} else return true;
|
|
274
|
+
}),
|
|
275
|
+
onStart(file) {
|
|
276
|
+
onStart === null || onStart === void 0 ? void 0 : onStart(file);
|
|
388
277
|
},
|
|
389
|
-
onSuccess
|
|
278
|
+
onSuccess(response, file, xhr) {
|
|
390
279
|
setShowLoading(false);
|
|
391
280
|
errTip && showErrTip(false);
|
|
392
|
-
|
|
281
|
+
const nextFileList = updateFileList(file);
|
|
393
282
|
onInternalChange(nextFileList);
|
|
394
|
-
|
|
283
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(response, file, xhr);
|
|
395
284
|
},
|
|
396
|
-
onError
|
|
285
|
+
onError(error, response, file) {
|
|
397
286
|
setShowLoading(false);
|
|
398
287
|
showErrTip(!!showUploadError);
|
|
399
|
-
|
|
288
|
+
onError === null || onError === void 0 ? void 0 : onError(error, response, file);
|
|
400
289
|
},
|
|
401
|
-
onProgress
|
|
402
|
-
|
|
290
|
+
onProgress(e, file) {
|
|
291
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress(e, file);
|
|
403
292
|
},
|
|
404
|
-
onBatchStart
|
|
293
|
+
onBatchStart(fileList) {
|
|
405
294
|
if (stash) {
|
|
406
295
|
if (cropFileRef.current) {
|
|
407
|
-
|
|
296
|
+
const idx = fileList.findIndex(_ => {
|
|
408
297
|
var _a;
|
|
409
298
|
return _.file.uid === ((_a = cropFileRef.current) === null || _a === void 0 ? void 0 : _a.uid);
|
|
410
299
|
});
|
|
@@ -415,62 +304,40 @@ var ImageUpload = function ImageUpload(props) {
|
|
|
415
304
|
});
|
|
416
305
|
}
|
|
417
306
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
});
|
|
421
|
-
var mList = mergedFileList(arr);
|
|
307
|
+
const arr = fileList.map(_ => _.parsedFile || _.file);
|
|
308
|
+
const mList = mergedFileList(arr);
|
|
422
309
|
onInternalChange(mList);
|
|
423
310
|
}
|
|
424
311
|
}
|
|
425
312
|
});
|
|
426
313
|
//内部变化
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
avatar.imageName = file.name;
|
|
451
|
-
setAvatar(Object.assign({}, avatar));
|
|
452
|
-
case 11:
|
|
453
|
-
onChange === null || onChange === void 0 ? void 0 : onChange([file]);
|
|
454
|
-
return _context2.abrupt("return");
|
|
455
|
-
case 13:
|
|
456
|
-
if (maxCount === 1) {
|
|
457
|
-
cloneList = cloneList.slice(-1);
|
|
458
|
-
} else if (maxCount) {
|
|
459
|
-
cloneList = cloneList.slice(0, maxCount);
|
|
460
|
-
}
|
|
461
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
|
|
462
|
-
setUploadFileList(cloneList);
|
|
463
|
-
case 16:
|
|
464
|
-
case "end":
|
|
465
|
-
return _context2.stop();
|
|
466
|
-
}
|
|
467
|
-
}, _callee2);
|
|
468
|
-
}));
|
|
469
|
-
};
|
|
314
|
+
const onInternalChange = changedFileList => __awaiter(void 0, void 0, void 0, function* () {
|
|
315
|
+
let cloneList = [...changedFileList];
|
|
316
|
+
if (!showUploadList) {
|
|
317
|
+
//不显示上传列表
|
|
318
|
+
const file = cloneList.slice(-1)[0];
|
|
319
|
+
if (file) {
|
|
320
|
+
const imageUrl = yield readerFileAsDataUrl(file);
|
|
321
|
+
file.dataUrl = imageUrl;
|
|
322
|
+
avatar.imageUrl = imageUrl;
|
|
323
|
+
avatar.imageName = file.name;
|
|
324
|
+
setAvatar(Object.assign({}, avatar));
|
|
325
|
+
}
|
|
326
|
+
onChange === null || onChange === void 0 ? void 0 : onChange([file]);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (maxCount === 1) {
|
|
330
|
+
cloneList = cloneList.slice(-1);
|
|
331
|
+
} else if (maxCount) {
|
|
332
|
+
cloneList = cloneList.slice(0, maxCount);
|
|
333
|
+
}
|
|
334
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(cloneList);
|
|
335
|
+
setUploadFileList(cloneList);
|
|
336
|
+
});
|
|
470
337
|
//更新文件列表
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
338
|
+
const updateFileList = file => {
|
|
339
|
+
const cloneList = [...uploadFileList];
|
|
340
|
+
const fileObj = Object.assign(Object.assign({}, file), {
|
|
474
341
|
lastModified: file.lastModified,
|
|
475
342
|
lastModifiedDate: file.lastModifiedDate,
|
|
476
343
|
name: file.name,
|
|
@@ -482,9 +349,9 @@ var ImageUpload = function ImageUpload(props) {
|
|
|
482
349
|
return cloneList.concat(fileObj);
|
|
483
350
|
};
|
|
484
351
|
//合并文件列表
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
352
|
+
const mergedFileList = fileList => {
|
|
353
|
+
const cloneList = [...uploadFileList];
|
|
354
|
+
const newFileList = fileList.map(file => {
|
|
488
355
|
return Object.assign(Object.assign({}, file), {
|
|
489
356
|
lastModified: file.lastModified,
|
|
490
357
|
lastModifiedDate: file.lastModifiedDate,
|
|
@@ -498,71 +365,57 @@ var ImageUpload = function ImageUpload(props) {
|
|
|
498
365
|
return cloneList.concat(newFileList);
|
|
499
366
|
};
|
|
500
367
|
//删除文件
|
|
501
|
-
|
|
502
|
-
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(
|
|
368
|
+
const handleRemove = file => {
|
|
369
|
+
Promise.resolve(typeof onRemove === 'function' ? onRemove(file) : onRemove).then(ret => {
|
|
503
370
|
// Prevent removing file
|
|
504
371
|
if (ret === false) return;
|
|
505
|
-
|
|
506
|
-
return _.uid === file.uid;
|
|
507
|
-
});
|
|
372
|
+
const idx = uploadFileList.findIndex(_ => _.uid === file.uid);
|
|
508
373
|
if (idx > -1) uploadFileList.splice(idx, 1);
|
|
509
374
|
onInternalChange(uploadFileList);
|
|
510
375
|
});
|
|
511
376
|
};
|
|
512
377
|
//读取dataUrl
|
|
513
|
-
|
|
514
|
-
return
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
fileReader.readAsDataURL(file.originFileObj);
|
|
525
|
-
} else resolve('');
|
|
526
|
-
}));
|
|
527
|
-
case 1:
|
|
528
|
-
case "end":
|
|
529
|
-
return _context3.stop();
|
|
530
|
-
}
|
|
531
|
-
}, _callee3);
|
|
532
|
-
}));
|
|
533
|
-
};
|
|
378
|
+
const readerFileAsDataUrl = file => __awaiter(void 0, void 0, void 0, function* () {
|
|
379
|
+
return new Promise(resolve => {
|
|
380
|
+
const fileReader = new FileReader();
|
|
381
|
+
if (file.originFileObj) {
|
|
382
|
+
fileReader.onload = () => {
|
|
383
|
+
resolve(fileReader.result);
|
|
384
|
+
};
|
|
385
|
+
fileReader.readAsDataURL(file.originFileObj);
|
|
386
|
+
} else resolve('');
|
|
387
|
+
});
|
|
388
|
+
});
|
|
534
389
|
//显示错误提示
|
|
535
|
-
|
|
390
|
+
const showErrTip = flag => {
|
|
536
391
|
setErrTip(flag);
|
|
537
392
|
if (leaveDelay < 0) return;
|
|
538
|
-
setTimeout(
|
|
393
|
+
setTimeout(() => {
|
|
539
394
|
setErrTip(false);
|
|
540
395
|
}, leaveDelay);
|
|
541
396
|
};
|
|
542
|
-
useEffect(
|
|
397
|
+
useEffect(() => {
|
|
543
398
|
if (fileList) {
|
|
544
|
-
setUploadFileList(
|
|
399
|
+
setUploadFileList([...fileList]);
|
|
545
400
|
}
|
|
546
401
|
}, [fileList]);
|
|
547
|
-
useEffect(
|
|
402
|
+
useEffect(() => {
|
|
548
403
|
if (defaultImage) {
|
|
549
404
|
setAvatar(Object.assign({}, defaultImage));
|
|
550
405
|
}
|
|
551
406
|
}, [defaultImage]);
|
|
552
407
|
//渲染上传列表
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
});
|
|
563
|
-
};
|
|
408
|
+
const renderUploadList = () => showUploadList && jsx(UploadList, {
|
|
409
|
+
listType: 'picture-card',
|
|
410
|
+
readonly: readonly,
|
|
411
|
+
items: uploadFileList,
|
|
412
|
+
showRemoveIcon: showRemoveIcon,
|
|
413
|
+
removeIcon: removeIcon,
|
|
414
|
+
onRemove: handleRemove,
|
|
415
|
+
itemRender: itemRender
|
|
416
|
+
});
|
|
564
417
|
//渲染内容
|
|
565
|
-
|
|
418
|
+
const renderUploadContent = () => {
|
|
566
419
|
var _a;
|
|
567
420
|
if (!showUploadList && avatar.imageUrl && !showLoading) {
|
|
568
421
|
return jsxs("div", Object.assign({
|
|
@@ -597,7 +450,7 @@ var ImageUpload = function ImageUpload(props) {
|
|
|
597
450
|
});
|
|
598
451
|
};
|
|
599
452
|
//渲染上传控件
|
|
600
|
-
|
|
453
|
+
const renderUploadSelector = () => {
|
|
601
454
|
if (readonly) return null;
|
|
602
455
|
return jsxs("div", Object.assign({
|
|
603
456
|
className: clsx('upload-image-select', showLoading && 'upload-image-select-loading')
|
|
@@ -625,7 +478,7 @@ var ImageUpload = function ImageUpload(props) {
|
|
|
625
478
|
};
|
|
626
479
|
|
|
627
480
|
//Dragger upload
|
|
628
|
-
|
|
481
|
+
const Dragger = props => {
|
|
629
482
|
return jsx(Upload, Object.assign({}, props, {
|
|
630
483
|
type: 'drag'
|
|
631
484
|
}));
|
|
@@ -790,336 +643,266 @@ var css_248z$1 = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2022/4/20
|
|
|
790
643
|
styleInject(css_248z$1);
|
|
791
644
|
|
|
792
645
|
//图片裁剪组件
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
aspect =
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
modalCancel = props.modalCancel,
|
|
816
|
-
onModalOk = props.onModalOk,
|
|
817
|
-
onModalCancel = props.onModalCancel,
|
|
818
|
-
beforeCrop = props.beforeCrop,
|
|
819
|
-
onUploadFail = props.onUploadFail,
|
|
820
|
-
cropperProps = props.cropperProps,
|
|
821
|
-
children = props.children,
|
|
822
|
-
_props$fixedCropSize = props.fixedCropSize,
|
|
823
|
-
fixedCropSize = _props$fixedCropSize === void 0 ? {
|
|
646
|
+
const ImgCrop = /*#__PURE__*/forwardRef((props, ref) => {
|
|
647
|
+
const {
|
|
648
|
+
aspect = 1,
|
|
649
|
+
shape = 'rect',
|
|
650
|
+
grid = false,
|
|
651
|
+
quality = 0.4,
|
|
652
|
+
fillColor = 'transparent',
|
|
653
|
+
zoom = true,
|
|
654
|
+
rotate = false,
|
|
655
|
+
minZoom = 1,
|
|
656
|
+
maxZoom = 3,
|
|
657
|
+
modalTitle,
|
|
658
|
+
modalWidth,
|
|
659
|
+
modalOk,
|
|
660
|
+
modalCancel,
|
|
661
|
+
onModalOk,
|
|
662
|
+
onModalCancel,
|
|
663
|
+
beforeCrop,
|
|
664
|
+
onUploadFail,
|
|
665
|
+
cropperProps,
|
|
666
|
+
children,
|
|
667
|
+
fixedCropSize = {
|
|
824
668
|
width: 120,
|
|
825
669
|
height: 120
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
var resolveRef = useRef();
|
|
835
|
-
var rejectRef = useRef();
|
|
670
|
+
}
|
|
671
|
+
} = props;
|
|
672
|
+
const intl = useFormatMessage('Upload', localeJson);
|
|
673
|
+
const [image, setImage] = useState('');
|
|
674
|
+
const fileRef = useRef();
|
|
675
|
+
const beforeUploadRef = useRef();
|
|
676
|
+
const resolveRef = useRef();
|
|
677
|
+
const rejectRef = useRef();
|
|
836
678
|
//存储回调
|
|
837
|
-
|
|
679
|
+
const cbRef = useRef({});
|
|
838
680
|
cbRef.current.onModalOk = onModalOk;
|
|
839
681
|
cbRef.current.onModalCancel = onModalCancel;
|
|
840
682
|
cbRef.current.beforeCrop = beforeCrop;
|
|
841
683
|
cbRef.current.onUploadFail = onUploadFail;
|
|
842
|
-
|
|
684
|
+
const easyCropRef = useRef({});
|
|
843
685
|
//上传组件
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
686
|
+
const uploadComponent = useMemo(() => {
|
|
687
|
+
const upload = Array.isArray(children) ? children[0] : children;
|
|
688
|
+
const _a = upload.props,
|
|
689
|
+
{
|
|
690
|
+
beforeUpload,
|
|
691
|
+
accept
|
|
692
|
+
} = _a,
|
|
849
693
|
restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
|
|
850
694
|
beforeUploadRef.current = beforeUpload;
|
|
851
695
|
return Object.assign(Object.assign({}, upload), {
|
|
852
696
|
props: Object.assign(Object.assign({}, restUploadProps), {
|
|
853
697
|
accept: accept || 'image/*',
|
|
854
|
-
beforeUpload:
|
|
855
|
-
return new Promise(
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
return
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
881
|
-
var _a, _b;
|
|
882
|
-
(_b = (_a = cbRef.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, newFile);
|
|
883
|
-
if (!flag) return resolve({
|
|
884
|
-
cropFile: newFile,
|
|
885
|
-
isUpload: flag
|
|
886
|
-
});
|
|
887
|
-
resolve(newFile);
|
|
888
|
-
};
|
|
889
|
-
rejectRef.current = function (uploadErr) {
|
|
890
|
-
var _a, _b;
|
|
891
|
-
(_b = (_a = cbRef.current).onUploadFail) === null || _b === void 0 ? void 0 : _b.call(_a, uploadErr);
|
|
892
|
-
reject(uploadErr);
|
|
893
|
-
};
|
|
894
|
-
reader = new FileReader();
|
|
895
|
-
reader.addEventListener('load', function () {
|
|
896
|
-
return typeof reader.result === 'string' && setImage(reader.result);
|
|
897
|
-
});
|
|
898
|
-
reader.readAsDataURL(file);
|
|
899
|
-
case 14:
|
|
900
|
-
case "end":
|
|
901
|
-
return _context.stop();
|
|
902
|
-
}
|
|
903
|
-
}, _callee);
|
|
904
|
-
}));
|
|
905
|
-
});
|
|
698
|
+
beforeUpload: (file, fileList) => {
|
|
699
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
700
|
+
if (cbRef.current.beforeCrop && !(yield cbRef.current.beforeCrop(file, fileList))) {
|
|
701
|
+
reject();
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
fileRef.current = file;
|
|
705
|
+
resolveRef.current = function (newFile) {
|
|
706
|
+
let flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
707
|
+
var _a, _b;
|
|
708
|
+
(_b = (_a = cbRef.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, newFile);
|
|
709
|
+
if (!flag) return resolve({
|
|
710
|
+
cropFile: newFile,
|
|
711
|
+
isUpload: flag
|
|
712
|
+
});
|
|
713
|
+
resolve(newFile);
|
|
714
|
+
};
|
|
715
|
+
rejectRef.current = uploadErr => {
|
|
716
|
+
var _a, _b;
|
|
717
|
+
(_b = (_a = cbRef.current).onUploadFail) === null || _b === void 0 ? void 0 : _b.call(_a, uploadErr);
|
|
718
|
+
reject(uploadErr);
|
|
719
|
+
};
|
|
720
|
+
const reader = new FileReader();
|
|
721
|
+
reader.addEventListener('load', () => typeof reader.result === 'string' && setImage(reader.result));
|
|
722
|
+
reader.readAsDataURL(file);
|
|
723
|
+
}));
|
|
906
724
|
}
|
|
907
725
|
})
|
|
908
726
|
});
|
|
909
727
|
}, [children]);
|
|
910
728
|
//modal 关闭后操作
|
|
911
|
-
|
|
729
|
+
const onClose = () => {
|
|
912
730
|
setImage('');
|
|
913
731
|
easyCropRef.current.setZoomVal(INIT_ZOOM);
|
|
914
732
|
easyCropRef.current.setRotateVal(INIT_ROTATE);
|
|
915
733
|
};
|
|
916
734
|
//modal cancel
|
|
917
|
-
|
|
735
|
+
const onCancel = useCallback(() => {
|
|
918
736
|
var _a, _b;
|
|
919
737
|
(_b = (_a = cbRef.current).onModalCancel) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
920
738
|
onClose();
|
|
921
739
|
}, []);
|
|
922
740
|
//modal ok
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
case 14:
|
|
1053
|
-
if (!(res && res instanceof Promise)) {
|
|
1054
|
-
_context2.next = 27;
|
|
1055
|
-
break;
|
|
1056
|
-
}
|
|
1057
|
-
_context2.prev = 15;
|
|
1058
|
-
_context2.next = 18;
|
|
1059
|
-
return res;
|
|
1060
|
-
case 18:
|
|
1061
|
-
passedFile = _context2.sent;
|
|
1062
|
-
if (!(passedFile instanceof File || passedFile instanceof Blob)) {
|
|
1063
|
-
_context2.next = 21;
|
|
1064
|
-
break;
|
|
1065
|
-
}
|
|
1066
|
-
return _context2.abrupt("return", (_d = resolveRef.current) === null || _d === void 0 ? void 0 : _d.call(resolveRef, passedFile));
|
|
1067
|
-
case 21:
|
|
1068
|
-
(_e = resolveRef.current) === null || _e === void 0 ? void 0 : _e.call(resolveRef, changeFile, passedFile);
|
|
1069
|
-
_context2.next = 27;
|
|
1070
|
-
break;
|
|
1071
|
-
case 24:
|
|
1072
|
-
_context2.prev = 24;
|
|
1073
|
-
_context2.t0 = _context2["catch"](15);
|
|
1074
|
-
(_f = rejectRef.current) === null || _f === void 0 ? void 0 : _f.call(rejectRef, _context2.t0);
|
|
1075
|
-
case 27:
|
|
1076
|
-
case "end":
|
|
1077
|
-
return _context2.stop();
|
|
1078
|
-
}
|
|
1079
|
-
}, _callee2, null, [[15, 24]]);
|
|
1080
|
-
}));
|
|
1081
|
-
};
|
|
1082
|
-
canvas.toBlob(onBlob, type, quality);
|
|
1083
|
-
case 11:
|
|
1084
|
-
case "end":
|
|
1085
|
-
return _context3.stop();
|
|
741
|
+
const onOk = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
742
|
+
onClose();
|
|
743
|
+
const canvas = document.createElement('canvas');
|
|
744
|
+
const ctx = canvas.getContext('2d');
|
|
745
|
+
const imgSource = document.querySelector(".".concat(PREFIX, "-media"));
|
|
746
|
+
const {
|
|
747
|
+
width: cropWidth,
|
|
748
|
+
height: cropHeight,
|
|
749
|
+
x: cropX,
|
|
750
|
+
y: cropY
|
|
751
|
+
} = easyCropRef.current.cropPixelsRef.current;
|
|
752
|
+
if (rotate && easyCropRef.current.rotateVal !== INIT_ROTATE) {
|
|
753
|
+
const {
|
|
754
|
+
naturalWidth: imgWidth,
|
|
755
|
+
naturalHeight: imgHeight
|
|
756
|
+
} = imgSource;
|
|
757
|
+
const angle = easyCropRef.current.rotateVal * (Math.PI / 180);
|
|
758
|
+
// get container for rotated image
|
|
759
|
+
const sine = Math.abs(Math.sin(angle));
|
|
760
|
+
const cosine = Math.abs(Math.cos(angle));
|
|
761
|
+
const squareWidth = imgWidth * cosine + imgHeight * sine;
|
|
762
|
+
const squareHeight = imgHeight * cosine + imgWidth * sine;
|
|
763
|
+
canvas.width = squareWidth;
|
|
764
|
+
canvas.height = squareHeight;
|
|
765
|
+
ctx.fillStyle = fillColor;
|
|
766
|
+
ctx.fillRect(0, 0, squareWidth, squareHeight);
|
|
767
|
+
// rotate container
|
|
768
|
+
const squareHalfWidth = squareWidth / 2;
|
|
769
|
+
const squareHalfHeight = squareHeight / 2;
|
|
770
|
+
ctx.translate(squareHalfWidth, squareHalfHeight);
|
|
771
|
+
ctx.rotate(angle);
|
|
772
|
+
ctx.translate(-squareHalfWidth, -squareHalfHeight);
|
|
773
|
+
// draw rotated image
|
|
774
|
+
const imgX = (squareWidth - imgWidth) / 2;
|
|
775
|
+
const imgY = (squareHeight - imgHeight) / 2;
|
|
776
|
+
ctx.drawImage(imgSource, 0, 0, imgWidth, imgHeight, imgX, imgY, imgWidth, imgHeight);
|
|
777
|
+
// crop rotated image
|
|
778
|
+
const imgData = ctx.getImageData(0, 0, squareWidth, squareHeight);
|
|
779
|
+
canvas.width = cropWidth;
|
|
780
|
+
canvas.height = cropHeight;
|
|
781
|
+
ctx.putImageData(imgData, -cropX, -cropY);
|
|
782
|
+
} else {
|
|
783
|
+
canvas.width = cropWidth;
|
|
784
|
+
canvas.height = cropHeight;
|
|
785
|
+
ctx.fillStyle = fillColor;
|
|
786
|
+
ctx.fillRect(0, 0, cropWidth, cropHeight);
|
|
787
|
+
ctx.drawImage(imgSource, cropX, cropY, cropWidth, cropHeight, 0, 0, cropWidth, cropHeight);
|
|
788
|
+
}
|
|
789
|
+
//裁剪之后改变图片大小
|
|
790
|
+
const changeImageSizeAfterCrop = newFile => {
|
|
791
|
+
return new Promise(resolve => {
|
|
792
|
+
const {
|
|
793
|
+
name,
|
|
794
|
+
type,
|
|
795
|
+
uid
|
|
796
|
+
} = newFile;
|
|
797
|
+
const {
|
|
798
|
+
width,
|
|
799
|
+
height
|
|
800
|
+
} = fixedCropSize; //固定裁剪大小
|
|
801
|
+
const changeCanvas = document.createElement('canvas');
|
|
802
|
+
const changeCtx = changeCanvas.getContext('2d');
|
|
803
|
+
const img = new Image();
|
|
804
|
+
img.onload = () => {
|
|
805
|
+
changeCanvas.width = width;
|
|
806
|
+
changeCanvas.height = height;
|
|
807
|
+
changeCtx.drawImage(img, 0, 0, width, height);
|
|
808
|
+
changeCanvas.toBlob(cBlob => {
|
|
809
|
+
const changeFile = Object.assign(new File([cBlob], name, {
|
|
810
|
+
type
|
|
811
|
+
}), {
|
|
812
|
+
uid
|
|
813
|
+
});
|
|
814
|
+
resolve(changeFile);
|
|
815
|
+
}, type, quality);
|
|
816
|
+
};
|
|
817
|
+
img.onerror = () => {
|
|
818
|
+
resolve(newFile);
|
|
819
|
+
};
|
|
820
|
+
const fileReader = new FileReader();
|
|
821
|
+
fileReader.onload = () => {
|
|
822
|
+
img.src = fileReader.result;
|
|
823
|
+
};
|
|
824
|
+
fileReader.onerror = () => {
|
|
825
|
+
resolve(newFile);
|
|
826
|
+
};
|
|
827
|
+
fileReader.readAsDataURL(newFile);
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
// get the new image
|
|
831
|
+
let {
|
|
832
|
+
type,
|
|
833
|
+
name,
|
|
834
|
+
uid
|
|
835
|
+
} = fileRef.current;
|
|
836
|
+
if (/svg/gi.test(type)) {
|
|
837
|
+
//svg 转为 png
|
|
838
|
+
type = 'image/png';
|
|
839
|
+
const idx = name.lastIndexOf('.');
|
|
840
|
+
if (idx > -1) name = "".concat(name.substring(0, idx), ".png");
|
|
841
|
+
}
|
|
842
|
+
//转为blob
|
|
843
|
+
const onBlob = blob => __awaiter(void 0, void 0, void 0, function* () {
|
|
844
|
+
var _a, _b, _c, _d, _e, _f;
|
|
845
|
+
const newFile = Object.assign(new File([blob], name, {
|
|
846
|
+
type
|
|
847
|
+
}), {
|
|
848
|
+
uid
|
|
849
|
+
});
|
|
850
|
+
const changeFile = yield changeImageSizeAfterCrop(newFile);
|
|
851
|
+
if (typeof beforeUploadRef.current !== 'function') {
|
|
852
|
+
return (_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, changeFile);
|
|
853
|
+
}
|
|
854
|
+
const res = beforeUploadRef.current(changeFile, [changeFile]);
|
|
855
|
+
if (typeof res !== 'boolean' && !res) {
|
|
856
|
+
console.error('beforeUpload must return a boolean or Promise');
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
if (res === true) return (_b = resolveRef.current) === null || _b === void 0 ? void 0 : _b.call(resolveRef, changeFile);
|
|
860
|
+
if (res === false) return (_c = resolveRef.current) === null || _c === void 0 ? void 0 : _c.call(resolveRef, changeFile, false);
|
|
861
|
+
if (res && res instanceof Promise) {
|
|
862
|
+
try {
|
|
863
|
+
const passedFile = yield res;
|
|
864
|
+
if (passedFile instanceof File || passedFile instanceof Blob) {
|
|
865
|
+
return (_d = resolveRef.current) === null || _d === void 0 ? void 0 : _d.call(resolveRef, passedFile);
|
|
866
|
+
}
|
|
867
|
+
(_e = resolveRef.current) === null || _e === void 0 ? void 0 : _e.call(resolveRef, changeFile, passedFile);
|
|
868
|
+
} catch (err) {
|
|
869
|
+
(_f = rejectRef.current) === null || _f === void 0 ? void 0 : _f.call(rejectRef, err);
|
|
1086
870
|
}
|
|
1087
|
-
}
|
|
1088
|
-
}));
|
|
1089
|
-
}, [fillColor, quality, rotate]);
|
|
1090
|
-
//img crop 组件
|
|
1091
|
-
var getComponent = function getComponent(titleOfModal) {
|
|
1092
|
-
return jsxs(Fragment, {
|
|
1093
|
-
children: [uploadComponent, image && jsx(Modal, Object.assign({
|
|
1094
|
-
open: true,
|
|
1095
|
-
className: "".concat(PREFIX, "-modal"),
|
|
1096
|
-
size: 'md',
|
|
1097
|
-
title: titleOfModal !== null && titleOfModal !== void 0 ? titleOfModal : intl({
|
|
1098
|
-
id: 'editImage'
|
|
1099
|
-
}),
|
|
1100
|
-
onOk: onOk,
|
|
1101
|
-
onCancel: onCancel,
|
|
1102
|
-
okText: modalOk,
|
|
1103
|
-
cancelText: modalCancel,
|
|
1104
|
-
contentWidth: modalWidth
|
|
1105
|
-
}, {
|
|
1106
|
-
children: jsx(EasyCrop$1, {
|
|
1107
|
-
ref: easyCropRef,
|
|
1108
|
-
cropperRef: ref,
|
|
1109
|
-
image: image,
|
|
1110
|
-
aspect: aspect,
|
|
1111
|
-
shape: shape,
|
|
1112
|
-
grid: grid,
|
|
1113
|
-
zoom: zoom,
|
|
1114
|
-
rotate: rotate,
|
|
1115
|
-
minZoom: minZoom,
|
|
1116
|
-
maxZoom: maxZoom,
|
|
1117
|
-
fixedCropSize: fixedCropSize,
|
|
1118
|
-
cropperProps: cropperProps
|
|
1119
|
-
})
|
|
1120
|
-
}))]
|
|
871
|
+
}
|
|
1121
872
|
});
|
|
1122
|
-
|
|
873
|
+
canvas.toBlob(onBlob, type, quality);
|
|
874
|
+
}), [fillColor, quality, rotate]);
|
|
875
|
+
//img crop 组件
|
|
876
|
+
const getComponent = titleOfModal => jsxs(Fragment, {
|
|
877
|
+
children: [uploadComponent, image && jsx(Modal, Object.assign({
|
|
878
|
+
open: true,
|
|
879
|
+
className: "".concat(PREFIX, "-modal"),
|
|
880
|
+
size: 'md',
|
|
881
|
+
title: titleOfModal !== null && titleOfModal !== void 0 ? titleOfModal : intl({
|
|
882
|
+
id: 'editImage'
|
|
883
|
+
}),
|
|
884
|
+
onOk: onOk,
|
|
885
|
+
onCancel: onCancel,
|
|
886
|
+
okText: modalOk,
|
|
887
|
+
cancelText: modalCancel,
|
|
888
|
+
contentWidth: modalWidth
|
|
889
|
+
}, {
|
|
890
|
+
children: jsx(EasyCrop$1, {
|
|
891
|
+
ref: easyCropRef,
|
|
892
|
+
cropperRef: ref,
|
|
893
|
+
image: image,
|
|
894
|
+
aspect: aspect,
|
|
895
|
+
shape: shape,
|
|
896
|
+
grid: grid,
|
|
897
|
+
zoom: zoom,
|
|
898
|
+
rotate: rotate,
|
|
899
|
+
minZoom: minZoom,
|
|
900
|
+
maxZoom: maxZoom,
|
|
901
|
+
fixedCropSize: fixedCropSize,
|
|
902
|
+
cropperProps: cropperProps
|
|
903
|
+
})
|
|
904
|
+
}))]
|
|
905
|
+
});
|
|
1123
906
|
return jsx(Fragment, {
|
|
1124
907
|
children: getComponent(modalTitle)
|
|
1125
908
|
});
|