assui 3.1.55 → 3.1.57
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/es/index.d.ts +2 -0
- package/es/index.js +2 -1
- package/es/label-select/index.d.ts +1 -0
- package/es/label-select/index.js +14 -3
- package/es/label-select/style/index.css +1 -0
- package/es/label-select/style/index.less +1 -0
- package/es/multipart-upload/getMultipartUploadHandler.d.ts +2 -0
- package/es/multipart-upload/getMultipartUploadHandler.js +38 -0
- package/es/multipart-upload/index.d.ts +43 -0
- package/es/multipart-upload/index.js +220 -0
- package/es/multipart-upload/parse2RegexOption.d.ts +13 -0
- package/es/multipart-upload/parse2RegexOption.js +46 -0
- package/es/multipart-upload/style/index.css +1323 -0
- package/es/multipart-upload/style/index.d.ts +2 -0
- package/es/multipart-upload/style/index.js +2 -0
- package/es/multipart-upload/style/index.less +102 -0
- package/es/style/variables.less +6 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -1
- package/lib/label-select/index.d.ts +1 -0
- package/lib/label-select/index.js +14 -3
- package/lib/label-select/style/index.css +1 -0
- package/lib/label-select/style/index.less +1 -0
- package/lib/multipart-upload/getMultipartUploadHandler.d.ts +2 -0
- package/lib/multipart-upload/getMultipartUploadHandler.js +43 -0
- package/lib/multipart-upload/index.d.ts +43 -0
- package/lib/multipart-upload/index.js +263 -0
- package/lib/multipart-upload/parse2RegexOption.d.ts +13 -0
- package/lib/multipart-upload/parse2RegexOption.js +56 -0
- package/lib/multipart-upload/style/index.css +1323 -0
- package/lib/multipart-upload/style/index.d.ts +2 -0
- package/lib/multipart-upload/style/index.js +7 -0
- package/lib/multipart-upload/style/index.less +102 -0
- package/lib/style/variables.less +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
@import '~antd/lib/style/index.less';
|
|
2
|
+
@import '../../style/variables.less';
|
|
3
|
+
|
|
4
|
+
.multipart-upload-container {
|
|
5
|
+
width: 130px;
|
|
6
|
+
height: 100px;
|
|
7
|
+
border-radius: 4px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.multipart-uploading-file-container {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
color: @color_9f9f9f;
|
|
19
|
+
font-size: @font-size-sm;
|
|
20
|
+
background-color: @color_f5f5f5;
|
|
21
|
+
border-radius: 8px;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
|
|
24
|
+
.spotecicon {
|
|
25
|
+
width: 30px;
|
|
26
|
+
height: 30px;
|
|
27
|
+
color: @color_d4d4d4;
|
|
28
|
+
fill: @white;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.multipart-uploading-file-container-disabled {
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.multipart-uploading-container {
|
|
37
|
+
position: relative;
|
|
38
|
+
z-index: @zindex-modal-mask;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
background-color: @white;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.multipart-package-icon-files {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
width: 100%;
|
|
51
|
+
height: 100%;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.multipart-upload-file-name {
|
|
56
|
+
width: 85%;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
text-overflow: ellipsis;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.multipart-upload-progress {
|
|
63
|
+
position: absolute !important;
|
|
64
|
+
top: 50%;
|
|
65
|
+
left: 0;
|
|
66
|
+
z-index: @zindex-table-fixed;
|
|
67
|
+
transform: translateY(-34%);
|
|
68
|
+
|
|
69
|
+
.@{ant-prefix}-progress-outer {
|
|
70
|
+
margin-right: 0;
|
|
71
|
+
padding-right: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.@{ant-prefix}-progress-text {
|
|
75
|
+
display: inline-block;
|
|
76
|
+
width: 100%;
|
|
77
|
+
text-align: center;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.multipart-package-upload-close-button {
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: 0;
|
|
84
|
+
right: 0;
|
|
85
|
+
z-index: @zindex-affix;
|
|
86
|
+
width: 20px;
|
|
87
|
+
height: 20px;
|
|
88
|
+
text-align: center;
|
|
89
|
+
background-color: @color_9f9f9f;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
opacity: 0.6;
|
|
92
|
+
|
|
93
|
+
.spotecicon {
|
|
94
|
+
width: 15px;
|
|
95
|
+
height: 15px;
|
|
96
|
+
color: @white;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.multipart-upload-icon-files {
|
|
101
|
+
text-align: center;
|
|
102
|
+
}
|
package/es/style/variables.less
CHANGED
|
@@ -22,9 +22,15 @@
|
|
|
22
22
|
@color_dc4946: #dc4946;
|
|
23
23
|
@color_a3daff: #a3daff;
|
|
24
24
|
@color_bfbfbf: #bfbfbf;
|
|
25
|
+
@color_d4d4d4: #d4d4d4;
|
|
26
|
+
@color_9f9f9f: #9f9f9f;
|
|
25
27
|
|
|
28
|
+
@font-size-sm: 12px;
|
|
26
29
|
@font-size-base: 14px;
|
|
27
30
|
@font-size-lg: @font-size-base + 2px;
|
|
28
31
|
@font-size_18: 18px;
|
|
29
32
|
|
|
30
33
|
@font-weight-500: 500;
|
|
34
|
+
|
|
35
|
+
@zindex-affix: 10;
|
|
36
|
+
@zindex-modal-mask: 1010;
|
package/lib/index.d.ts
CHANGED
|
@@ -80,3 +80,5 @@ export type { FlexProps } from './flex';
|
|
|
80
80
|
export { default as Flex } from './flex';
|
|
81
81
|
export type { LabelConditionSelectInputProps } from './label-condition-select-input';
|
|
82
82
|
export { default as LabelConditionSelectInput } from './label-condition-select-input';
|
|
83
|
+
export type { MultipartUploadProps } from './multipart-upload';
|
|
84
|
+
export { default as MultipartUpload } from './multipart-upload';
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
|
10
10
|
});
|
|
11
|
-
exports.LabelConditionSelectInput = exports.Flex = exports.Resizable = exports.BeautifulDnd = exports.RichTextEditor = exports.LabelCustomizeRangePicker = exports.TableCol = exports.LabelTreeSelect = exports.LabelConditionInput = exports.LabelNumberInput = exports.LabelAutoComplete = exports.LabelDatePicker = exports.LabelRangePicker = exports.JsonEditor = exports.AreaText = exports.LabelTextArea = exports.ASelect = exports.LabelSelect = exports.ColorSelect = exports.LabelInput = exports.TextInput = exports.TextArea = exports.SplitPane = exports.sortableHoc = exports.SingleImgUpload = exports.RcTransitionGroup = exports.RcQRcode = exports.RcEcharts = exports.StepNumberInput = exports.LabelRangeNumber = exports.NumberInput = exports.RcMotion = exports.KeepTab = exports.ImgCrop = exports.HighlightWords = exports.HighlightTextarea = exports.CopyToClipboard = exports.NumberFormatInput = exports.ConfigProvider = exports.ConditionSelectInput = exports.ConditionInput = exports.ButtonModal = exports.ButtonDrawer = void 0;
|
|
11
|
+
exports.MultipartUpload = exports.LabelConditionSelectInput = exports.Flex = exports.Resizable = exports.BeautifulDnd = exports.RichTextEditor = exports.LabelCustomizeRangePicker = exports.TableCol = exports.LabelTreeSelect = exports.LabelConditionInput = exports.LabelNumberInput = exports.LabelAutoComplete = exports.LabelDatePicker = exports.LabelRangePicker = exports.JsonEditor = exports.AreaText = exports.LabelTextArea = exports.ASelect = exports.LabelSelect = exports.ColorSelect = exports.LabelInput = exports.TextInput = exports.TextArea = exports.SplitPane = exports.sortableHoc = exports.SingleImgUpload = exports.RcTransitionGroup = exports.RcQRcode = exports.RcEcharts = exports.StepNumberInput = exports.LabelRangeNumber = exports.NumberInput = exports.RcMotion = exports.KeepTab = exports.ImgCrop = exports.HighlightWords = exports.HighlightTextarea = exports.CopyToClipboard = exports.NumberFormatInput = exports.ConfigProvider = exports.ConditionSelectInput = exports.ConditionInput = exports.ButtonModal = exports.ButtonDrawer = void 0;
|
|
12
12
|
var button_drawer_1 = require("./button-drawer");
|
|
13
13
|
Object.defineProperty(exports, "ButtonDrawer", {
|
|
14
14
|
enumerable: true,
|
|
@@ -309,4 +309,11 @@ Object.defineProperty(exports, "LabelConditionSelectInput", {
|
|
|
309
309
|
get: function get() {
|
|
310
310
|
return __importDefault(label_condition_select_input_1)["default"];
|
|
311
311
|
}
|
|
312
|
+
});
|
|
313
|
+
var multipart_upload_1 = require("./multipart-upload");
|
|
314
|
+
Object.defineProperty(exports, "MultipartUpload", {
|
|
315
|
+
enumerable: true,
|
|
316
|
+
get: function get() {
|
|
317
|
+
return __importDefault(multipart_upload_1)["default"];
|
|
318
|
+
}
|
|
312
319
|
});
|
|
@@ -4,6 +4,7 @@ declare const Option: import("rc-select/lib/Option").OptionFC;
|
|
|
4
4
|
export { Option };
|
|
5
5
|
export interface LabelSelectProps extends SelectProps {
|
|
6
6
|
label?: React.ReactNode;
|
|
7
|
+
onBlur?: (value: SelectProps['value']) => void;
|
|
7
8
|
}
|
|
8
9
|
declare const ForwardRefLabelSelect: React.ForwardRefExoticComponent<LabelSelectProps & React.RefAttributes<unknown>>;
|
|
9
10
|
export default ForwardRefLabelSelect;
|
|
@@ -48,7 +48,9 @@ exports.Option = void 0;
|
|
|
48
48
|
var react_1 = __importDefault(require("react"));
|
|
49
49
|
var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
|
|
50
50
|
var select_1 = __importDefault(require("antd/lib/select"));
|
|
51
|
-
var
|
|
51
|
+
var isArray_1 = __importDefault(require("lodash/isArray"));
|
|
52
|
+
var isUndefined_1 = __importDefault(require("lodash/isUndefined"));
|
|
53
|
+
var isNull_1 = __importDefault(require("lodash/isNull"));
|
|
52
54
|
var classnames_1 = __importDefault(require("classnames"));
|
|
53
55
|
var ArrowDropDownFilled_1 = __importDefault(require("a-icons/lib/ArrowDropDownFilled"));
|
|
54
56
|
var omit_1 = __importDefault(require("lodash/omit"));
|
|
@@ -56,7 +58,8 @@ var Option = select_1["default"].Option;
|
|
|
56
58
|
exports.Option = Option;
|
|
57
59
|
var LabelSelect = function LabelSelect(props, ref) {
|
|
58
60
|
var className = props.className,
|
|
59
|
-
label = props.label
|
|
61
|
+
label = props.label,
|
|
62
|
+
onBlur = props.onBlur;
|
|
60
63
|
var selectRef = react_1["default"].useRef(null);
|
|
61
64
|
var _a = __read((0, useControllableValue_1["default"])(props, {
|
|
62
65
|
valuePropName: 'open',
|
|
@@ -82,10 +85,13 @@ var LabelSelect = function LabelSelect(props, ref) {
|
|
|
82
85
|
var onDropdownVisibleChange = function onDropdownVisibleChange(nextOpen) {
|
|
83
86
|
setOpen(nextOpen);
|
|
84
87
|
};
|
|
88
|
+
var handleBlur = function handleBlur() {
|
|
89
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(value);
|
|
90
|
+
};
|
|
85
91
|
return react_1["default"].createElement("div", {
|
|
86
92
|
className: (0, classnames_1["default"])({
|
|
87
93
|
'label-select': true,
|
|
88
|
-
'label-select-label-scale': open || !(0,
|
|
94
|
+
'label-select-label-scale': open || !(0, isArray_1["default"])(value) && !(0, isUndefined_1["default"])(value) && !(0, isNull_1["default"])(value) || (0, isArray_1["default"])(value) && value.length
|
|
89
95
|
}, className)
|
|
90
96
|
}, react_1["default"].createElement(select_1["default"], __assign({
|
|
91
97
|
maxTagCount: 3,
|
|
@@ -96,6 +102,11 @@ var LabelSelect = function LabelSelect(props, ref) {
|
|
|
96
102
|
size: "large",
|
|
97
103
|
className: "label-select-selector",
|
|
98
104
|
onChange: handleChange,
|
|
105
|
+
onBlur: handleBlur,
|
|
106
|
+
onDeselect: function onDeselect() {
|
|
107
|
+
var _a;
|
|
108
|
+
(_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
109
|
+
},
|
|
99
110
|
onDropdownVisibleChange: onDropdownVisibleChange,
|
|
100
111
|
suffixIcon: react_1["default"].createElement(ArrowDropDownFilled_1["default"], null)
|
|
101
112
|
})), react_1["default"].createElement("label", {
|
|
@@ -1256,6 +1256,7 @@ html {
|
|
|
1256
1256
|
.label-select .ant-select-multiple .ant-select-selection-overflow {
|
|
1257
1257
|
display: flex;
|
|
1258
1258
|
width: 100%;
|
|
1259
|
+
height: 36px;
|
|
1259
1260
|
transform: translateY(8px);
|
|
1260
1261
|
}
|
|
1261
1262
|
.label-select .ant-select-multiple .ant-select-selection-overflow-item {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
/* eslint-disable prefer-promise-reject-errors */
|
|
7
|
+
var aa_utils_1 = require("aa-utils");
|
|
8
|
+
var getMultipartUploadHandler = function getMultipartUploadHandler(resultUrl) {
|
|
9
|
+
var multipartUploadHandler = function multipartUploadHandler(file, progress) {
|
|
10
|
+
return new Promise(function (resolve, reject) {
|
|
11
|
+
var xhr = new XMLHttpRequest();
|
|
12
|
+
xhr.open('POST', resultUrl);
|
|
13
|
+
xhr.setRequestHeader('token', aa_utils_1.localStorage.get('token') || '');
|
|
14
|
+
xhr.upload.onprogress = function (e) {
|
|
15
|
+
progress && progress(e.loaded / e.total * 100);
|
|
16
|
+
};
|
|
17
|
+
xhr.onload = function () {
|
|
18
|
+
if (xhr.status === 403) {
|
|
19
|
+
reject("HTTP Error: ".concat(xhr.status));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
23
|
+
reject("HTTP Error: ".concat(xhr.status));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var json = JSON.parse(xhr.responseText);
|
|
27
|
+
if (!json || json.header.code !== 200) {
|
|
28
|
+
reject("Invalid JSON: ".concat(xhr.responseText));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
resolve(json.body);
|
|
32
|
+
};
|
|
33
|
+
xhr.onerror = function () {
|
|
34
|
+
reject("Image upload failed due to a XHR Transport error. Code: ".concat(xhr.status));
|
|
35
|
+
};
|
|
36
|
+
var formData = new FormData();
|
|
37
|
+
formData.append('file', file);
|
|
38
|
+
xhr.send(formData);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return multipartUploadHandler;
|
|
42
|
+
};
|
|
43
|
+
exports["default"] = getMultipartUploadHandler;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { UploadProps } from 'rc-upload';
|
|
3
|
+
export interface RcFile extends File {
|
|
4
|
+
uid: string;
|
|
5
|
+
}
|
|
6
|
+
export interface UploadProgressEvent extends ProgressEvent {
|
|
7
|
+
percent: number;
|
|
8
|
+
}
|
|
9
|
+
export interface MultipartUploadProps extends Omit<UploadProps, 'onSuccess'> {
|
|
10
|
+
value?: string;
|
|
11
|
+
wrapperClassName?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
/** 上传文字 */
|
|
15
|
+
uploadText?: string;
|
|
16
|
+
onSuccess?: (res: string, fileName: string) => void;
|
|
17
|
+
uploadIcon: React.ReactElement;
|
|
18
|
+
cancelUpload?: () => void;
|
|
19
|
+
/** 分片大小 */
|
|
20
|
+
chunkSize?: number;
|
|
21
|
+
/** 第一步 获取ID */
|
|
22
|
+
getInitUploadIdAPI: ({ fileName }: {
|
|
23
|
+
fileName: string;
|
|
24
|
+
}) => Promise<string>;
|
|
25
|
+
/** 第二步 获取url 进行分片上传 */
|
|
26
|
+
getInProgressUploadUrl: ({ fileName, partNumber, uploadId, }: {
|
|
27
|
+
fileName: string;
|
|
28
|
+
partNumber: number;
|
|
29
|
+
uploadId: string;
|
|
30
|
+
}) => string;
|
|
31
|
+
/** 第三步 合并上传文件 完成上传 */
|
|
32
|
+
completeRequest: ({ fileName, uploadId, list, }: {
|
|
33
|
+
fileName: string;
|
|
34
|
+
uploadId: string;
|
|
35
|
+
list: string[];
|
|
36
|
+
}) => Promise<string>;
|
|
37
|
+
errorCatch?: (error: any) => void;
|
|
38
|
+
}
|
|
39
|
+
declare const MultipartUpload: {
|
|
40
|
+
(props: MultipartUploadProps): JSX.Element;
|
|
41
|
+
displayName: string;
|
|
42
|
+
};
|
|
43
|
+
export default MultipartUpload;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return m[k];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
} : function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
value: v
|
|
35
|
+
});
|
|
36
|
+
} : function (o, v) {
|
|
37
|
+
o["default"] = v;
|
|
38
|
+
});
|
|
39
|
+
var __importStar = this && this.__importStar || function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k in mod) {
|
|
43
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
44
|
+
}
|
|
45
|
+
__setModuleDefault(result, mod);
|
|
46
|
+
return result;
|
|
47
|
+
};
|
|
48
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
52
|
+
}
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
55
|
+
}
|
|
56
|
+
return t;
|
|
57
|
+
};
|
|
58
|
+
var __read = this && this.__read || function (o, n) {
|
|
59
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
60
|
+
if (!m) return o;
|
|
61
|
+
var i = m.call(o),
|
|
62
|
+
r,
|
|
63
|
+
ar = [],
|
|
64
|
+
e;
|
|
65
|
+
try {
|
|
66
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
67
|
+
ar.push(r.value);
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
e = {
|
|
71
|
+
error: error
|
|
72
|
+
};
|
|
73
|
+
} finally {
|
|
74
|
+
try {
|
|
75
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
76
|
+
} finally {
|
|
77
|
+
if (e) throw e.error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return ar;
|
|
81
|
+
};
|
|
82
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
83
|
+
return mod && mod.__esModule ? mod : {
|
|
84
|
+
"default": mod
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
Object.defineProperty(exports, "__esModule", {
|
|
88
|
+
value: true
|
|
89
|
+
});
|
|
90
|
+
var react_1 = __importStar(require("react"));
|
|
91
|
+
var rc_upload_1 = __importDefault(require("rc-upload"));
|
|
92
|
+
var ahooks_1 = require("ahooks");
|
|
93
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
94
|
+
var antd_1 = require("antd");
|
|
95
|
+
var a_icons_1 = require("a-icons");
|
|
96
|
+
var getMultipartUploadHandler_1 = __importDefault(require("./getMultipartUploadHandler"));
|
|
97
|
+
var MultipartUpload = function MultipartUpload(props) {
|
|
98
|
+
var className = props.className,
|
|
99
|
+
wrapperClassName = props.wrapperClassName,
|
|
100
|
+
accept = props.accept,
|
|
101
|
+
method = props.method,
|
|
102
|
+
_a = props.fileName,
|
|
103
|
+
fileName = _a === void 0 ? '' : _a,
|
|
104
|
+
onSuccess = props.onSuccess,
|
|
105
|
+
onError = props.onError,
|
|
106
|
+
onStart = props.onStart,
|
|
107
|
+
cancelUpload = props.cancelUpload,
|
|
108
|
+
uploadIcon = props.uploadIcon,
|
|
109
|
+
disabled = props.disabled,
|
|
110
|
+
getInProgressUploadUrl = props.getInProgressUploadUrl,
|
|
111
|
+
getInitUploadIdAPI = props.getInitUploadIdAPI,
|
|
112
|
+
completeRequest = props.completeRequest,
|
|
113
|
+
chunkSize = props.chunkSize,
|
|
114
|
+
uploadText = props.uploadText,
|
|
115
|
+
customRequest = props.customRequest,
|
|
116
|
+
value = props.value,
|
|
117
|
+
errorCatch = props.errorCatch,
|
|
118
|
+
restProps = __rest(props, ["className", "wrapperClassName", "accept", "method", "fileName", "onSuccess", "onError", "onStart", "cancelUpload", "uploadIcon", "disabled", "getInProgressUploadUrl", "getInitUploadIdAPI", "completeRequest", "chunkSize", "uploadText", "customRequest", "value", "errorCatch"]);
|
|
119
|
+
var fileNameRef = (0, react_1.useRef)('');
|
|
120
|
+
var uploadRef = (0, react_1.useRef)();
|
|
121
|
+
var fileRef = (0, react_1.useRef)();
|
|
122
|
+
var uploadIdRef = (0, react_1.useRef)('');
|
|
123
|
+
var _b = __read((0, react_1.useState)('init'), 2),
|
|
124
|
+
uploadStatus = _b[0],
|
|
125
|
+
setUploadStatus = _b[1];
|
|
126
|
+
var _c = __read((0, react_1.useState)(0), 2),
|
|
127
|
+
uploadPercent = _c[0],
|
|
128
|
+
setUploadPercent = _c[1];
|
|
129
|
+
var resChunkSize = chunkSize || 1024 * 1024 * 50; // 50MB
|
|
130
|
+
var currentChunk = 0;
|
|
131
|
+
var totalChunks = 0;
|
|
132
|
+
var uploadList = [];
|
|
133
|
+
(0, ahooks_1.useUpdateEffect)(function () {
|
|
134
|
+
if (value) {
|
|
135
|
+
setUploadStatus('done');
|
|
136
|
+
} else {
|
|
137
|
+
setUploadStatus('init');
|
|
138
|
+
}
|
|
139
|
+
}, [value]);
|
|
140
|
+
(0, ahooks_1.useMount)(function () {
|
|
141
|
+
fileNameRef.current = fileName;
|
|
142
|
+
});
|
|
143
|
+
(0, ahooks_1.useUpdateEffect)(function () {
|
|
144
|
+
fileNameRef.current = fileName;
|
|
145
|
+
}, [fileName]);
|
|
146
|
+
var handleStart = function handleStart(file) {
|
|
147
|
+
fileRef.current = file;
|
|
148
|
+
setUploadPercent(0);
|
|
149
|
+
fileNameRef.current = file.name;
|
|
150
|
+
totalChunks = Math.ceil(fileRef.current.size / resChunkSize);
|
|
151
|
+
setUploadStatus('uploading');
|
|
152
|
+
onStart && onStart(file);
|
|
153
|
+
};
|
|
154
|
+
var handleError = function handleError(error, ret, file) {
|
|
155
|
+
setUploadStatus('init');
|
|
156
|
+
onError && onError(error, ret, file);
|
|
157
|
+
};
|
|
158
|
+
var uploadCls = (0, classnames_1["default"])(className, {
|
|
159
|
+
'not-upload-init': uploadStatus !== 'init'
|
|
160
|
+
});
|
|
161
|
+
var handleCancelUpload = function handleCancelUpload() {
|
|
162
|
+
var _a;
|
|
163
|
+
if (fileRef.current) {
|
|
164
|
+
(_a = uploadRef.current) === null || _a === void 0 ? void 0 : _a.abort(fileRef.current);
|
|
165
|
+
setUploadStatus('init');
|
|
166
|
+
cancelUpload && cancelUpload();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var progress = function progress(progressNumber) {
|
|
170
|
+
var currentProgressNumber = parseInt("".concat(progressNumber * (currentChunk + 1) / totalChunks), 10);
|
|
171
|
+
if (currentProgressNumber >= currentChunk / totalChunks * 100) {
|
|
172
|
+
setUploadPercent(currentProgressNumber);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var uploadNextChunk = function uploadNextChunk() {
|
|
176
|
+
/** 第二步 获取url 进行分片上传 */
|
|
177
|
+
if (fileRef.current) {
|
|
178
|
+
var resultUrl = getInProgressUploadUrl({
|
|
179
|
+
fileName: fileNameRef.current,
|
|
180
|
+
partNumber: currentChunk + 1,
|
|
181
|
+
uploadId: uploadIdRef.current
|
|
182
|
+
});
|
|
183
|
+
var multipartUploadHandler = (0, getMultipartUploadHandler_1["default"])(resultUrl);
|
|
184
|
+
var start = currentChunk * resChunkSize;
|
|
185
|
+
var end = Math.min(fileRef.current.size, start + resChunkSize);
|
|
186
|
+
var chunk = fileRef.current.slice(start, end);
|
|
187
|
+
multipartUploadHandler(chunk, progress).then(function (res) {
|
|
188
|
+
uploadList.push(res);
|
|
189
|
+
currentChunk += 1;
|
|
190
|
+
if (currentChunk < totalChunks) {
|
|
191
|
+
uploadNextChunk();
|
|
192
|
+
} else {
|
|
193
|
+
/** 分片上传完成 进行文件合并 上传完成 */
|
|
194
|
+
completeRequest({
|
|
195
|
+
fileName: fileNameRef.current,
|
|
196
|
+
uploadId: uploadIdRef.current,
|
|
197
|
+
list: uploadList
|
|
198
|
+
}).then(function (fileUrl) {
|
|
199
|
+
setUploadStatus('done');
|
|
200
|
+
onSuccess && onSuccess(fileUrl, fileNameRef.current);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
})["catch"](function (error) {
|
|
204
|
+
errorCatch && errorCatch(error);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var customMultipartRequest = function customMultipartRequest() {
|
|
209
|
+
if (fileRef.current) {
|
|
210
|
+
totalChunks = Math.ceil(fileRef.current.size / resChunkSize);
|
|
211
|
+
/** 第一步 获取ID */
|
|
212
|
+
getInitUploadIdAPI({
|
|
213
|
+
fileName: fileNameRef.current
|
|
214
|
+
}).then(function (id) {
|
|
215
|
+
uploadIdRef.current = id;
|
|
216
|
+
uploadNextChunk();
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
return react_1["default"].createElement("div", {
|
|
221
|
+
className: (0, classnames_1["default"])('multipart-upload-container', wrapperClassName)
|
|
222
|
+
}, uploadStatus === 'uploading' && react_1["default"].createElement("div", {
|
|
223
|
+
className: "multipart-uploading-container"
|
|
224
|
+
}, react_1["default"].createElement("div", {
|
|
225
|
+
className: "multipart-package-icon-files"
|
|
226
|
+
}, uploadIcon, react_1["default"].createElement("div", {
|
|
227
|
+
className: "multipart-upload-file-name",
|
|
228
|
+
title: fileNameRef.current
|
|
229
|
+
}, fileNameRef.current)), react_1["default"].createElement(antd_1.Progress, {
|
|
230
|
+
className: "multipart-upload-progress",
|
|
231
|
+
percent: uploadPercent,
|
|
232
|
+
size: "small",
|
|
233
|
+
status: "active"
|
|
234
|
+
}), react_1["default"].createElement("div", {
|
|
235
|
+
className: "multipart-package-upload-close-button",
|
|
236
|
+
onClick: handleCancelUpload
|
|
237
|
+
}, react_1["default"].createElement(a_icons_1.CloseOutlined, null))), uploadStatus === 'done' && react_1["default"].createElement("div", {
|
|
238
|
+
className: "multipart-upload-container"
|
|
239
|
+
}, react_1["default"].createElement("div", {
|
|
240
|
+
className: "multipart-upload-icon-files"
|
|
241
|
+
}, uploadIcon, react_1["default"].createElement("div", {
|
|
242
|
+
className: "multipart-upload-file-name",
|
|
243
|
+
title: fileNameRef.current
|
|
244
|
+
}, fileNameRef.current))), react_1["default"].createElement(rc_upload_1["default"], __assign({
|
|
245
|
+
ref: function ref(uploader) {
|
|
246
|
+
uploadRef.current = uploader;
|
|
247
|
+
},
|
|
248
|
+
name: "file",
|
|
249
|
+
accept: accept,
|
|
250
|
+
disabled: disabled,
|
|
251
|
+
method: method,
|
|
252
|
+
className: uploadCls,
|
|
253
|
+
onStart: handleStart,
|
|
254
|
+
onError: handleError,
|
|
255
|
+
customRequest: customMultipartRequest
|
|
256
|
+
}, restProps), uploadStatus === 'init' && react_1["default"].createElement("div", {
|
|
257
|
+
className: (0, classnames_1["default"])('multipart-uploading-file-container', {
|
|
258
|
+
'multipart-uploading-file-container-disabled': disabled
|
|
259
|
+
})
|
|
260
|
+
}, react_1["default"].createElement(a_icons_1.CirclePlusFilled, null), react_1["default"].createElement("span", null, uploadText))));
|
|
261
|
+
};
|
|
262
|
+
MultipartUpload.displayName = 'MultipartUpload';
|
|
263
|
+
exports["default"] = MultipartUpload;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface RegexOptionType {
|
|
2
|
+
isValid: boolean;
|
|
3
|
+
replacement: string;
|
|
4
|
+
}
|
|
5
|
+
declare type regexParamsType = RegExp | string | {
|
|
6
|
+
pattern: RegExp;
|
|
7
|
+
replacement?: string;
|
|
8
|
+
};
|
|
9
|
+
export interface ResultType extends RegexOptionType {
|
|
10
|
+
pattern: RegExp;
|
|
11
|
+
}
|
|
12
|
+
declare const parse2RegexOption: (regex: regexParamsType) => ResultType;
|
|
13
|
+
export default parse2RegexOption;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
16
|
+
return mod && mod.__esModule ? mod : {
|
|
17
|
+
"default": mod
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
var isRegExp_1 = __importDefault(require("lodash/isRegExp"));
|
|
24
|
+
var isString_1 = __importDefault(require("lodash/isString"));
|
|
25
|
+
var isObject_1 = __importDefault(require("lodash/isObject"));
|
|
26
|
+
var defaultOptionValues = {
|
|
27
|
+
isValid: true,
|
|
28
|
+
replacement: ''
|
|
29
|
+
};
|
|
30
|
+
var parseRegex2RegexOption = function parseRegex2RegexOption(regex, options) {
|
|
31
|
+
return __assign(__assign(__assign({}, defaultOptionValues), {
|
|
32
|
+
pattern: regex
|
|
33
|
+
}), options);
|
|
34
|
+
};
|
|
35
|
+
var parseString2RegexOption = function parseString2RegexOption(regexString, options) {
|
|
36
|
+
return parseRegex2RegexOption(new RegExp(regexString), options);
|
|
37
|
+
};
|
|
38
|
+
var parse2RegexOption = function parse2RegexOption(regex) {
|
|
39
|
+
if ((0, isRegExp_1["default"])(regex)) {
|
|
40
|
+
return parseRegex2RegexOption(regex);
|
|
41
|
+
}
|
|
42
|
+
if ((0, isString_1["default"])(regex)) {
|
|
43
|
+
return parseString2RegexOption(regex);
|
|
44
|
+
}
|
|
45
|
+
if ((0, isObject_1["default"])(regex)) {
|
|
46
|
+
return __assign(__assign(__assign({}, defaultOptionValues), {
|
|
47
|
+
isValid: !!regex.pattern
|
|
48
|
+
}), regex);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
isValid: false,
|
|
52
|
+
replacement: '',
|
|
53
|
+
pattern: /./
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports["default"] = parse2RegexOption;
|