fat-design 0.0.1 → 0.0.2-beta.20251111003037
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/README.md +285 -285
- package/index.browser.js +21 -21
- package/index.js +6816 -6667
- package/index.umd.cjs +20 -20
- package/index.umd.js +20 -20
- package/libs/config-16.js +7 -7
- package/libs/config-17.js +7 -7
- package/libs/config-18.js +9 -9
- package/libs/config-19.js +9 -9
- package/libs/theme/theme-blue1.css +58 -58
- package/libs/theme/theme-blue2.css +63 -63
- package/libs/theme/theme-blue3.css +73 -73
- package/libs/theme/theme-blue4.css +53 -53
- package/libs/theme/theme-default.css +60 -60
- package/libs/theme/theme-green.css +96 -96
- package/libs/theme/theme-green2.css +96 -96
- package/libs/theme/theme-orange.css +58 -58
- package/libs/theme/theme-pink.css +53 -53
- package/libs/theme/theme-purple.css +53 -53
- package/libs/theme/theme-red.css +55 -55
- package/package.json +2 -2
- package/style.css +1 -1
- package/types/0buildTypes/config-provider/constants.d.ts +3 -3
- package/types/0buildTypes/config-provider/index.d.ts +4 -4
- package/types/0buildTypes/config-provider/v2/consumer.d.ts +3 -3
- package/types/0buildTypes/config-provider/v2/context.d.ts +6 -6
- package/types/0buildTypes/config-provider/v2/error-boundary.d.ts +27 -27
- package/types/0buildTypes/config-provider/v2/functions.d.ts +66 -66
- package/types/0buildTypes/config-provider/v2/index.d.ts +36 -36
- package/types/0buildTypes/config-provider/v2/provider.d.ts +4 -4
- package/types/0buildTypes/config-provider/v2/types.d.ts +22 -22
- package/types/0buildTypes/dependencies.d.ts +2 -2
- package/types/0buildTypes/empty/empty.d.ts +22 -22
- package/types/0buildTypes/empty/index.d.ts +2 -2
- package/types/0buildTypes/filter/filter-types.d.ts +21 -21
- package/types/0buildTypes/filter/filter.d.ts +10 -10
- package/types/0buildTypes/filter/index.d.ts +9 -9
- package/types/0buildTypes/form2/deps.d.ts +10 -10
- package/types/0buildTypes/form2/form-actions.d.ts +36 -36
- package/types/0buildTypes/form2/form-buttons.d.ts +28 -28
- package/types/0buildTypes/form2/form-context.d.ts +4 -4
- package/types/0buildTypes/form2/form-error.d.ts +3 -3
- package/types/0buildTypes/form2/form-item-card.d.ts +4 -4
- package/types/0buildTypes/form2/form-item-comp.d.ts +4 -4
- package/types/0buildTypes/form2/form-item-label.d.ts +4 -4
- package/types/0buildTypes/form2/form-item-preview.d.ts +4 -4
- package/types/0buildTypes/form2/form-item.d.ts +7 -7
- package/types/0buildTypes/form2/form-layout.d.ts +3 -3
- package/types/0buildTypes/form2/form-rules.d.ts +3 -3
- package/types/0buildTypes/form2/form-section.d.ts +25 -25
- package/types/0buildTypes/form2/form-types.d.ts +396 -396
- package/types/0buildTypes/form2/form.d.ts +36 -36
- package/types/0buildTypes/form2/helper/buildParams.d.ts +5 -5
- package/types/0buildTypes/form2/helper/constants.d.ts +24 -24
- package/types/0buildTypes/form2/helper/fixItemProps.d.ts +16 -16
- package/types/0buildTypes/form2/helper/fnInheritProps.d.ts +2 -2
- package/types/0buildTypes/form2/helper/linkageFormState.d.ts +16 -16
- package/types/0buildTypes/form2/helper/useDataSource.d.ts +14 -14
- package/types/0buildTypes/form2/helper/useFormChildren.d.ts +5 -5
- package/types/0buildTypes/form2/helper/useFormItemState.d.ts +3 -3
- package/types/0buildTypes/form2/helper/useGetXProps.d.ts +3 -3
- package/types/0buildTypes/form2/index.d.ts +20 -20
- package/types/0buildTypes/form2/layout/from-float-layout.d.ts +3 -3
- package/types/0buildTypes/hooks/index.d.ts +25 -25
- package/types/0buildTypes/hooks/useComparedState.d.ts +2 -2
- package/types/0buildTypes/hooks/useCurrentState.d.ts +11 -11
- package/types/0buildTypes/hooks/useOnKeyPressSave.d.ts +12 -12
- package/types/0buildTypes/hooks/usePersistFn.d.ts +3 -3
- package/types/0buildTypes/hooks/usePreciseStore.d.ts +53 -53
- package/types/0buildTypes/hooks/useSize.d.ts +6 -6
- package/types/0buildTypes/hooks/useUniqueId.d.ts +2 -2
- package/types/0buildTypes/hooks/useValueOnChange.d.ts +2 -2
- package/types/0buildTypes/image/Image.d.ts +42 -42
- package/types/0buildTypes/image/Operations.d.ts +25 -25
- package/types/0buildTypes/image/Preview.d.ts +64 -64
- package/types/0buildTypes/image/PreviewGroup.d.ts +32 -32
- package/types/0buildTypes/image/common.d.ts +2 -2
- package/types/0buildTypes/image/context.d.ts +7 -7
- package/types/0buildTypes/image/getFixScaleEleTransPosition.d.ts +17 -17
- package/types/0buildTypes/image/hooks/useImageTransform.d.ts +28 -28
- package/types/0buildTypes/image/hooks/useMouseEvent.d.ts +9 -9
- package/types/0buildTypes/image/hooks/usePreviewItems.d.ts +7 -7
- package/types/0buildTypes/image/hooks/useRegisterImage.d.ts +2 -2
- package/types/0buildTypes/image/hooks/useStatus.d.ts +14 -14
- package/types/0buildTypes/image/hooks/useTouchEvent.d.ts +8 -8
- package/types/0buildTypes/image/index.d.ts +6 -6
- package/types/0buildTypes/image/interface.d.ts +14 -14
- package/types/0buildTypes/image/previewConfig.d.ts +4 -4
- package/types/0buildTypes/image/util.d.ts +1 -1
- package/types/0buildTypes/image/utils/KeyCode.d.ts +23 -23
- package/types/0buildTypes/image/utils/addEventListener.d.ts +4 -4
- package/types/0buildTypes/image/utils/buildIcons.d.ts +2 -2
- package/types/0buildTypes/image/utils/css.d.ts +8 -8
- package/types/0buildTypes/image/utils/isEqual.d.ts +8 -8
- package/types/0buildTypes/image/utils/raf.d.ts +6 -6
- package/types/0buildTypes/image/utils/useEvent.d.ts +1 -1
- package/types/0buildTypes/image/utils/useLayoutEffect.d.ts +4 -4
- package/types/0buildTypes/image/utils/useMergedState.d.ts +12 -12
- package/types/0buildTypes/image/utils/useSafeState.d.ts +14 -14
- package/types/0buildTypes/index.d.ts +4 -4
- package/types/0buildTypes/libs.d.ts +67 -67
- package/types/0buildTypes/nav/group.d.ts +30 -30
- package/types/0buildTypes/nav/index.d.ts +4 -4
- package/types/0buildTypes/nav/item.d.ts +30 -30
- package/types/0buildTypes/nav/nav.d.ts +2 -2
- package/types/0buildTypes/nav/popup-item.d.ts +24 -24
- package/types/0buildTypes/nav/sub-nav.d.ts +30 -30
- package/types/0buildTypes/nav/types.d.ts +375 -375
- package/types/0buildTypes/others.d.ts +11 -10
- package/types/0buildTypes/pages/deps.d.ts +5 -5
- package/types/0buildTypes/pages/detail-page/detail-page-card-form.d.ts +12 -12
- package/types/0buildTypes/pages/detail-page/detail-page-form-item.d.ts +9 -9
- package/types/0buildTypes/pages/detail-page/detail-page-section.d.ts +19 -19
- package/types/0buildTypes/pages/detail-page/detail-page-summary.d.ts +9 -9
- package/types/0buildTypes/pages/detail-page/detail-page.d.ts +14 -14
- package/types/0buildTypes/pages/detail-page/index.d.ts +2 -2
- package/types/0buildTypes/pages/detail-page/types.d.ts +29 -29
- package/types/0buildTypes/pages/page-card/types.d.ts +6 -6
- package/types/0buildTypes/previews/renderFileImage.d.ts +40 -34
- package/types/0buildTypes/query-form/index.d.ts +2 -2
- package/types/0buildTypes/query-form/query-form-items.d.ts +4 -4
- package/types/0buildTypes/query-form/query-form-layout.d.ts +2 -2
- package/types/0buildTypes/query-form/query-form.d.ts +20 -20
- package/types/0buildTypes/query-form/types.d.ts +12 -12
- package/types/0buildTypes/sortable-list/helpers.d.ts +8 -8
- package/types/0buildTypes/sortable-list/hooks.d.ts +24 -24
- package/types/0buildTypes/sortable-list/index.d.ts +14 -14
- package/types/0buildTypes/sortable-list/sortable-editable-table.d.ts +2 -2
- package/types/0buildTypes/sortable-list/sortable-list.d.ts +560 -560
- package/types/0buildTypes/sortable-list/sortable-table.d.ts +2 -2
- package/types/0buildTypes/sortable-list/types.d.ts +15 -15
- package/types/0buildTypes/table-pro/index.d.ts +26 -26
- package/types/0buildTypes/table-pro/table-pro.d.ts +17 -17
- package/types/0buildTypes/table-pro/types.d.ts +95 -95
- package/types/0buildTypes/table-pro/useTablePro.d.ts +10 -10
- package/types/0buildTypes/table-pro/utils/formatQueryRes.d.ts +1 -1
- package/types/0buildTypes/table-pro/widget/column-setting.d.ts +5 -5
- package/types/0buildTypes/table-pro/widget/deps.d.ts +2 -2
- package/types/0buildTypes/table-pro/widget/index.d.ts +25 -25
- package/types/0buildTypes/table-pro/widget/operations.d.ts +5 -5
- package/types/0buildTypes/table-pro/widget/operationsActions.d.ts +2 -2
- package/types/0buildTypes/table-pro/widget/renderFormats.d.ts +17 -17
- package/types/0buildTypes/table-pro/widget/renderMultiFieldCell.d.ts +4 -4
- package/types/0buildTypes/table-pro/widget/renderOperationCell.d.ts +4 -4
- package/types/0buildTypes/table-pro/widget/renderToolbar.d.ts +6 -6
- package/types/0buildTypes/table-pro/widget/table-utils-types.d.ts +40 -40
- package/types/0buildTypes/util/comp.d.ts +16 -16
- package/types/0buildTypes/util/component.d.ts +1 -1
- package/types/0buildTypes/util/constants.d.ts +4 -4
- package/types/0buildTypes/util/dom.d.ts +116 -116
- package/types/0buildTypes/util/env.d.ts +7 -7
- package/types/0buildTypes/util/func-wrapper.d.ts +1 -1
- package/types/0buildTypes/util/func.d.ts +73 -73
- package/types/0buildTypes/util/guid.d.ts +11 -11
- package/types/0buildTypes/util/isStateEquals.d.ts +4 -4
- package/types/0buildTypes/util/localforage.d.ts +11 -11
- package/types/0buildTypes/util/log.d.ts +18 -18
- package/types/0buildTypes/util/pick-res-data.d.ts +28 -28
- package/types/0buildTypes/util/react-dom.d.ts +27 -27
- package/types/0buildTypes/util/shallowEqual.d.ts +3 -3
- package/types/0buildTypes/util/string.d.ts +37 -32
- package/types/0buildTypes/util/tiny-emitter.d.ts +10 -10
- package/types/0buildTypes/util/toMap.d.ts +7 -7
- package/types/affix/index.d.ts +33 -33
- package/types/animate/index.d.ts +80 -80
- package/types/avatar/index.d.ts +41 -41
- package/types/badge/index.d.ts +38 -38
- package/types/balloon/index.d.ts +254 -254
- package/types/balloon-confirm/index.d.ts +119 -119
- package/types/batch-input/index.d.ts +152 -152
- package/types/box/index.d.ts +25 -25
- package/types/breadcrumb/index.d.ts +60 -60
- package/types/button/index.d.ts +179 -179
- package/types/calendar/index.d.ts +76 -76
- package/types/card/index.d.ts +147 -147
- package/types/cascader/index.d.ts +135 -135
- package/types/cascader-select/index.d.ts +230 -230
- package/types/checkbox/index.d.ts +175 -175
- package/types/collapse/index.d.ts +96 -96
- package/types/comments/index.d.ts +278 -278
- package/types/config-provider/index.d.ts +3 -3
- package/types/date-picker/index.d.ts +123 -123
- package/types/dialog/index.d.ts +335 -328
- package/types/divider/index.d.ts +21 -21
- package/types/drawer/index.d.ts +121 -121
- package/types/dropdown/index.d.ts +198 -198
- package/types/editable-table/index.d.ts +121 -121
- package/types/empty/index.d.ts +78 -78
- package/types/field/index.d.ts +33 -33
- package/types/filter/index.d.ts +2 -2
- package/types/form/index.d.ts +5 -5
- package/types/grid/index.d.ts +142 -142
- package/types/hooks/index.d.ts +2 -2
- package/types/icon/index.d.ts +29 -29
- package/types/image/index.d.ts +3 -3
- package/types/index.d.ts +69 -69
- package/types/input/index.d.ts +458 -458
- package/types/list/index.d.ts +69 -69
- package/types/loading/index.d.ts +100 -100
- package/types/locale/default.d.ts +143 -143
- package/types/locale/en-us.d.ts +1 -1
- package/types/locale/id-id.d.ts +1 -1
- package/types/locale/it-it.d.ts +1 -1
- package/types/locale/ja-jp.d.ts +1 -1
- package/types/locale/ko-kr.d.ts +1 -1
- package/types/locale/ms-my.d.ts +1 -1
- package/types/locale/pt-pt.d.ts +1 -1
- package/types/locale/th-th.d.ts +1 -1
- package/types/locale/vi-vn.d.ts +1 -1
- package/types/locale/zh-cn.d.ts +1 -1
- package/types/locale/zh-hk.d.ts +1 -1
- package/types/locale/zh-tw.d.ts +1 -1
- package/types/menu/index.d.ts +336 -336
- package/types/menu-button/index.d.ts +100 -100
- package/types/message/index.d.ts +165 -165
- package/types/nav/index.d.ts +313 -313
- package/types/notification/index.d.ts +35 -35
- package/types/number-picker/index.d.ts +161 -161
- package/types/overlay/index.d.ts +363 -363
- package/types/pagination/index.d.ts +115 -115
- package/types/paragraph/index.d.ts +23 -23
- package/types/progress/index.d.ts +53 -53
- package/types/query-form/index.d.ts +3 -3
- package/types/radio/index.d.ts +180 -180
- package/types/range/index.d.ts +120 -120
- package/types/rating/index.d.ts +84 -84
- package/types/responsive-grid/index.d.ts +30 -30
- package/types/search/index.d.ts +219 -219
- package/types/select/index.d.ts +479 -479
- package/types/shell/index.d.ts +53 -53
- package/types/slider/index.d.ts +172 -172
- package/types/sortable-list/index.d.ts +165 -165
- package/types/split-button/index.d.ts +134 -134
- package/types/step/index.d.ts +108 -108
- package/types/switch/index.d.ts +85 -85
- package/types/tab/index.d.ts +170 -170
- package/types/table/index.d.ts +407 -407
- package/types/table-pro/index.d.ts +3 -3
- package/types/tag/index.d.ts +142 -142
- package/types/time-picker/index.d.ts +193 -193
- package/types/timeline/index.d.ts +95 -95
- package/types/transfer/index.d.ts +199 -199
- package/types/tree/index.d.ts +421 -421
- package/types/tree-select/index.d.ts +251 -251
- package/types/typography/index.d.ts +28 -28
- package/types/upload/index.d.ts +723 -711
- package/types/util.d.ts +80 -80
- package/types/virtual-list/index.d.ts +44 -44
package/types/upload/index.d.ts
CHANGED
|
@@ -1,711 +1,723 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import CommonProps from '../util';
|
|
5
|
-
import { ProgressProps } from '../progress';
|
|
6
|
-
|
|
7
|
-
interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
|
|
8
|
-
onError?: any;
|
|
9
|
-
onSelect?: any;
|
|
10
|
-
defaultValue?: any;
|
|
11
|
-
onChange?: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface UploadError extends Error {
|
|
15
|
-
code?: string;
|
|
16
|
-
status?: number;
|
|
17
|
-
method?: string;
|
|
18
|
-
url?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export interface UploadProgressEvent extends ProgressEvent {
|
|
23
|
-
percent?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface UploadOptions {
|
|
27
|
-
beforeUpload?: (file: UploadFile, data: unknown) => boolean | object | unknown;
|
|
28
|
-
onProgress?: (e: UploadProgressEvent, file?: UploadFile) => void;
|
|
29
|
-
onSuccess?: (ret: unknown, xhr?: XMLHttpRequest | UploadFile) => void;
|
|
30
|
-
onError?: (err: ProgressEvent | UploadError, param: unknown, file?: UploadFile) => void;
|
|
31
|
-
data?: UploadProps['data'];
|
|
32
|
-
name?: string;
|
|
33
|
-
method?: 'post' | 'put' | 'POST' | 'PUT';
|
|
34
|
-
action?: string;
|
|
35
|
-
headers?: { [key: string]: unknown; 'X-Requested-With'?: string | undefined };
|
|
36
|
-
withCredentials?: boolean;
|
|
37
|
-
request?: (option: object) => { abort?: (() => void) | undefined };
|
|
38
|
-
file?: UploadFile;
|
|
39
|
-
filename?: string;
|
|
40
|
-
timeout?: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export interface CommonModifiedFile {
|
|
45
|
-
uid?: string | number;
|
|
46
|
-
error?: unknown;
|
|
47
|
-
percent?: number;
|
|
48
|
-
state?: string;
|
|
49
|
-
lastModifiedDate?: Date;
|
|
50
|
-
filename?: string;
|
|
51
|
-
readonly name: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type BeforeUploadOption = {
|
|
55
|
-
action?: string;
|
|
56
|
-
headers?: object;
|
|
57
|
-
timeout?: number;
|
|
58
|
-
withCredentials?: boolean;
|
|
59
|
-
method?: string;
|
|
60
|
-
data?: object;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export interface UploadFile extends CommonModifiedFile, File {
|
|
64
|
-
url?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
export interface ObjectFile extends CommonModifiedFile {
|
|
70
|
-
lastModified?: number;
|
|
71
|
-
lastModifiedDate?: Date;
|
|
72
|
-
size?: number;
|
|
73
|
-
type?: string;
|
|
74
|
-
originFileObj?: UploadFile;
|
|
75
|
-
imgURL?: string;
|
|
76
|
-
downloadURL?: string;
|
|
77
|
-
url?: string;
|
|
78
|
-
errorMsg?: string;
|
|
79
|
-
errorText?: string;
|
|
80
|
-
fileURL?: string;
|
|
81
|
-
tempUrl?: string;
|
|
82
|
-
alt?: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export interface CardProps extends HTMLAttributesWeak, CommonProps {
|
|
88
|
-
/**
|
|
89
|
-
* 上传的地址
|
|
90
|
-
*/
|
|
91
|
-
action?: string;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件
|
|
95
|
-
*/
|
|
96
|
-
multiple?: boolean;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* 展示下载按钮
|
|
100
|
-
*/
|
|
101
|
-
showDownload?: boolean;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 接受上传的文件类型 (image/png, image/jpg, .doc, .ppt) 详见 [input accept attribute](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input#attr-accept)
|
|
105
|
-
*/
|
|
106
|
-
accept?: string;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 上传额外传参
|
|
111
|
-
* @en Upload extra parameters
|
|
112
|
-
*/
|
|
113
|
-
data?:
|
|
114
|
-
| { [key: string]: string | Blob }
|
|
115
|
-
| ((file: UploadFile) => { [key: string]: string | Blob });
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 设置上传的请求头部
|
|
119
|
-
*/
|
|
120
|
-
headers?: any;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* 是否允许请求携带 cookie
|
|
124
|
-
*/
|
|
125
|
-
withCredentials?: boolean;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 可选参数,详见 [beforeUpload](#beforeUpload)
|
|
129
|
-
* @en Optional parameters, see [beforeUpload](#beforeUpload)
|
|
130
|
-
* @param file - 所有文件 - all file
|
|
131
|
-
* @param options - 参数 - parameters
|
|
132
|
-
* @defaultValue func.noop
|
|
133
|
-
*/
|
|
134
|
-
beforeUpload?: (file: UploadFile, options: BeforeUploadOption) => boolean | object | unknown;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 上传中
|
|
139
|
-
* @en onProgress Callback
|
|
140
|
-
* @defaultValue func.noop
|
|
141
|
-
*/
|
|
142
|
-
onProgress?: (file: ObjectFile[], e: ObjectFile) => void;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* 可选参数,上传成功回调函数,参数为请求下响应信息以及文件
|
|
146
|
-
* @en Optional parameters, upload success callback function, the parameter is the response information and file
|
|
147
|
-
* @param file - 文件 - file
|
|
148
|
-
* @param value - 值 - value
|
|
149
|
-
* @defaultValue func.noop
|
|
150
|
-
*/
|
|
151
|
-
onSuccess?: (file: ObjectFile, value?: ObjectFile[]) => void;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 可选参数,上传失败回调函数,参数为上传失败的信息、响应信息以及文件
|
|
155
|
-
* @en Optional parameters, upload failure callback function, the parameter is the upload failure information, response information and file
|
|
156
|
-
* @param file - 出错的文件 - error file
|
|
157
|
-
* @param value - 当前值 - current value
|
|
158
|
-
* @defaultValue func.noop
|
|
159
|
-
*/
|
|
160
|
-
onError?: (file: ObjectFile, value: ObjectFile[]) => void;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* 子元素
|
|
164
|
-
*/
|
|
165
|
-
children?: any;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* 设置上传超时,单位ms
|
|
169
|
-
*/
|
|
170
|
-
timeout?: number;
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 上传方法
|
|
174
|
-
* @en Upload method
|
|
175
|
-
* @defaultValue 'post'
|
|
176
|
-
*/
|
|
177
|
-
method?: 'post' | 'put' | 'POST' | 'PUT';
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 自定义上传方法
|
|
181
|
-
* @en Custom upload method
|
|
182
|
-
* @param option - 参数 - parameters
|
|
183
|
-
* @returns - 返回值 - object with abort method
|
|
184
|
-
*/
|
|
185
|
-
request?: (option: any) => any;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 文件名字段
|
|
189
|
-
*/
|
|
190
|
-
name?: string;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* 选择文件回调
|
|
195
|
-
* @en Select file callback
|
|
196
|
-
* @defaultValue func.noop
|
|
197
|
-
*/
|
|
198
|
-
onSelect?: (uploadFiles: any[]) => any;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* 放文件
|
|
203
|
-
* @en Drop file
|
|
204
|
-
* @defaultValue func.noop
|
|
205
|
-
*/
|
|
206
|
-
onDrop?: (files: UploadFile[]) => void;
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* 样式前缀
|
|
210
|
-
*/
|
|
211
|
-
prefix?: string;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 文件列表
|
|
215
|
-
* @en File list
|
|
216
|
-
*/
|
|
217
|
-
value?: ObjectFile[] | ObjectFile;
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* 默认文件列表
|
|
221
|
-
*/
|
|
222
|
-
defaultValue?: ObjectFile[] | ObjectFile;
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 上传按钮形状
|
|
226
|
-
*/
|
|
227
|
-
shape?: 'card';
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* 上传列表的样式
|
|
231
|
-
*/
|
|
232
|
-
listType?: 'text' | 'image' | 'card';
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* 数据格式化函数,配合自定义 action 使用,参数为服务器的响应数据,详见 [formatter](#formater)
|
|
236
|
-
*/
|
|
237
|
-
formatter?: (response: {}, file: any) => void;
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* 最大文件上传个数
|
|
241
|
-
*/
|
|
242
|
-
limit?: number;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* 可选参数,是否支持拖拽上传,`ie10+` 支持。
|
|
246
|
-
*/
|
|
247
|
-
dragable?: boolean;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* 可选参数,是否本地预览
|
|
251
|
-
*/
|
|
252
|
-
useDataURL?: boolean;
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* 可选参数,是否禁用上传功能
|
|
256
|
-
*/
|
|
257
|
-
disabled?: boolean;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* 改变时候的回调
|
|
261
|
-
*/
|
|
262
|
-
onChange?: (value: File[], param2?: any) => void;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* 可选参数, 用于校验文件,afterSelect仅在 autoUpload=false 的时候生效,autoUpload=true时,可以使用beforeUpload完全可以替代该功能.
|
|
266
|
-
*/
|
|
267
|
-
afterSelect?: (file: {}) => boolean;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* 点击移除的回调
|
|
271
|
-
*/
|
|
272
|
-
onRemove?: () => void;
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* 自定义class
|
|
276
|
-
*/
|
|
277
|
-
className?: string;
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* 自定义内联样式
|
|
281
|
-
*/
|
|
282
|
-
style?: React.CSSProperties;
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* 自动上传
|
|
286
|
-
*/
|
|
287
|
-
autoUpload?: boolean;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* 透传给Progress props
|
|
291
|
-
*/
|
|
292
|
-
progressProps?: ProgressProps;
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* 点击图片回调
|
|
296
|
-
* @en Click image callback
|
|
297
|
-
* @skip
|
|
298
|
-
*/
|
|
299
|
-
onPreview?: (file: UploadFile, e?: MouseEvent<HTMLElement>) => void;
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* 取消上传的回调
|
|
303
|
-
*/
|
|
304
|
-
onCancel?: () => void;
|
|
305
|
-
/**
|
|
306
|
-
* 调用系统设备媒体
|
|
307
|
-
*/
|
|
308
|
-
capture?: string;
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* 自定义成功和失败的列表渲染方式
|
|
312
|
-
*/
|
|
313
|
-
itemRender?: (file: UploadFile, obj: { remove?: () => void }) => React.ReactNode;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* 选择新文件上传并替换
|
|
317
|
-
*/
|
|
318
|
-
reUpload?: boolean;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export class Card extends React.Component<CardProps, any> {}
|
|
322
|
-
|
|
323
|
-
export interface SimpleJSONUploadProps extends UploadProps, CardProps {
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
*
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
*
|
|
478
|
-
* @
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
*
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
*
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
*
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
*
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
*
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
*
|
|
611
|
-
*/
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
*
|
|
648
|
-
*/
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
*
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
*
|
|
659
|
-
* @
|
|
660
|
-
*/
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
*
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
*
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import CommonProps from '../util';
|
|
5
|
+
import { ProgressProps } from '../progress';
|
|
6
|
+
|
|
7
|
+
interface HTMLAttributesWeak extends React.HTMLAttributes<HTMLElement> {
|
|
8
|
+
onError?: any;
|
|
9
|
+
onSelect?: any;
|
|
10
|
+
defaultValue?: any;
|
|
11
|
+
onChange?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UploadError extends Error {
|
|
15
|
+
code?: string;
|
|
16
|
+
status?: number;
|
|
17
|
+
method?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export interface UploadProgressEvent extends ProgressEvent {
|
|
23
|
+
percent?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UploadOptions {
|
|
27
|
+
beforeUpload?: (file: UploadFile, data: unknown) => boolean | object | unknown;
|
|
28
|
+
onProgress?: (e: UploadProgressEvent, file?: UploadFile) => void;
|
|
29
|
+
onSuccess?: (ret: unknown, xhr?: XMLHttpRequest | UploadFile) => void;
|
|
30
|
+
onError?: (err: ProgressEvent | UploadError, param: unknown, file?: UploadFile) => void;
|
|
31
|
+
data?: UploadProps['data'];
|
|
32
|
+
name?: string;
|
|
33
|
+
method?: 'post' | 'put' | 'POST' | 'PUT';
|
|
34
|
+
action?: string;
|
|
35
|
+
headers?: { [key: string]: unknown; 'X-Requested-With'?: string | undefined };
|
|
36
|
+
withCredentials?: boolean;
|
|
37
|
+
request?: (option: object) => { abort?: (() => void) | undefined };
|
|
38
|
+
file?: UploadFile;
|
|
39
|
+
filename?: string;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
export interface CommonModifiedFile {
|
|
45
|
+
uid?: string | number;
|
|
46
|
+
error?: unknown;
|
|
47
|
+
percent?: number;
|
|
48
|
+
state?: string;
|
|
49
|
+
lastModifiedDate?: Date;
|
|
50
|
+
filename?: string;
|
|
51
|
+
readonly name: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type BeforeUploadOption = {
|
|
55
|
+
action?: string;
|
|
56
|
+
headers?: object;
|
|
57
|
+
timeout?: number;
|
|
58
|
+
withCredentials?: boolean;
|
|
59
|
+
method?: string;
|
|
60
|
+
data?: object;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export interface UploadFile extends CommonModifiedFile, File {
|
|
64
|
+
url?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export interface ObjectFile extends CommonModifiedFile {
|
|
70
|
+
lastModified?: number;
|
|
71
|
+
lastModifiedDate?: Date;
|
|
72
|
+
size?: number;
|
|
73
|
+
type?: string;
|
|
74
|
+
originFileObj?: UploadFile;
|
|
75
|
+
imgURL?: string;
|
|
76
|
+
downloadURL?: string;
|
|
77
|
+
url?: string;
|
|
78
|
+
errorMsg?: string;
|
|
79
|
+
errorText?: string;
|
|
80
|
+
fileURL?: string;
|
|
81
|
+
tempUrl?: string;
|
|
82
|
+
alt?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
export interface CardProps extends HTMLAttributesWeak, CommonProps {
|
|
88
|
+
/**
|
|
89
|
+
* 上传的地址
|
|
90
|
+
*/
|
|
91
|
+
action?: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件
|
|
95
|
+
*/
|
|
96
|
+
multiple?: boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 展示下载按钮
|
|
100
|
+
*/
|
|
101
|
+
showDownload?: boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 接受上传的文件类型 (image/png, image/jpg, .doc, .ppt) 详见 [input accept attribute](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input#attr-accept)
|
|
105
|
+
*/
|
|
106
|
+
accept?: string;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 上传额外传参
|
|
111
|
+
* @en Upload extra parameters
|
|
112
|
+
*/
|
|
113
|
+
data?:
|
|
114
|
+
| { [key: string]: string | Blob }
|
|
115
|
+
| ((file: UploadFile) => { [key: string]: string | Blob });
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 设置上传的请求头部
|
|
119
|
+
*/
|
|
120
|
+
headers?: any;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 是否允许请求携带 cookie
|
|
124
|
+
*/
|
|
125
|
+
withCredentials?: boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 可选参数,详见 [beforeUpload](#beforeUpload)
|
|
129
|
+
* @en Optional parameters, see [beforeUpload](#beforeUpload)
|
|
130
|
+
* @param file - 所有文件 - all file
|
|
131
|
+
* @param options - 参数 - parameters
|
|
132
|
+
* @defaultValue func.noop
|
|
133
|
+
*/
|
|
134
|
+
beforeUpload?: (file: UploadFile, options: BeforeUploadOption) => boolean | object | unknown;
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 上传中
|
|
139
|
+
* @en onProgress Callback
|
|
140
|
+
* @defaultValue func.noop
|
|
141
|
+
*/
|
|
142
|
+
onProgress?: (file: ObjectFile[], e: ObjectFile) => void;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 可选参数,上传成功回调函数,参数为请求下响应信息以及文件
|
|
146
|
+
* @en Optional parameters, upload success callback function, the parameter is the response information and file
|
|
147
|
+
* @param file - 文件 - file
|
|
148
|
+
* @param value - 值 - value
|
|
149
|
+
* @defaultValue func.noop
|
|
150
|
+
*/
|
|
151
|
+
onSuccess?: (file: ObjectFile, value?: ObjectFile[]) => void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 可选参数,上传失败回调函数,参数为上传失败的信息、响应信息以及文件
|
|
155
|
+
* @en Optional parameters, upload failure callback function, the parameter is the upload failure information, response information and file
|
|
156
|
+
* @param file - 出错的文件 - error file
|
|
157
|
+
* @param value - 当前值 - current value
|
|
158
|
+
* @defaultValue func.noop
|
|
159
|
+
*/
|
|
160
|
+
onError?: (file: ObjectFile, value: ObjectFile[]) => void;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 子元素
|
|
164
|
+
*/
|
|
165
|
+
children?: any;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 设置上传超时,单位ms
|
|
169
|
+
*/
|
|
170
|
+
timeout?: number;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 上传方法
|
|
174
|
+
* @en Upload method
|
|
175
|
+
* @defaultValue 'post'
|
|
176
|
+
*/
|
|
177
|
+
method?: 'post' | 'put' | 'POST' | 'PUT';
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* 自定义上传方法
|
|
181
|
+
* @en Custom upload method
|
|
182
|
+
* @param option - 参数 - parameters
|
|
183
|
+
* @returns - 返回值 - object with abort method
|
|
184
|
+
*/
|
|
185
|
+
request?: (option: any) => any;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 文件名字段
|
|
189
|
+
*/
|
|
190
|
+
name?: string;
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 选择文件回调
|
|
195
|
+
* @en Select file callback
|
|
196
|
+
* @defaultValue func.noop
|
|
197
|
+
*/
|
|
198
|
+
onSelect?: (uploadFiles: any[]) => any;
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* 放文件
|
|
203
|
+
* @en Drop file
|
|
204
|
+
* @defaultValue func.noop
|
|
205
|
+
*/
|
|
206
|
+
onDrop?: (files: UploadFile[]) => void;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 样式前缀
|
|
210
|
+
*/
|
|
211
|
+
prefix?: string;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 文件列表
|
|
215
|
+
* @en File list
|
|
216
|
+
*/
|
|
217
|
+
value?: ObjectFile[] | ObjectFile;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* 默认文件列表
|
|
221
|
+
*/
|
|
222
|
+
defaultValue?: ObjectFile[] | ObjectFile;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 上传按钮形状
|
|
226
|
+
*/
|
|
227
|
+
shape?: 'card';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 上传列表的样式
|
|
231
|
+
*/
|
|
232
|
+
listType?: 'text' | 'image' | 'card';
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 数据格式化函数,配合自定义 action 使用,参数为服务器的响应数据,详见 [formatter](#formater)
|
|
236
|
+
*/
|
|
237
|
+
formatter?: (response: {}, file: any) => void;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* 最大文件上传个数
|
|
241
|
+
*/
|
|
242
|
+
limit?: number;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 可选参数,是否支持拖拽上传,`ie10+` 支持。
|
|
246
|
+
*/
|
|
247
|
+
dragable?: boolean;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 可选参数,是否本地预览
|
|
251
|
+
*/
|
|
252
|
+
useDataURL?: boolean;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 可选参数,是否禁用上传功能
|
|
256
|
+
*/
|
|
257
|
+
disabled?: boolean;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 改变时候的回调
|
|
261
|
+
*/
|
|
262
|
+
onChange?: (value: File[], param2?: any) => void;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 可选参数, 用于校验文件,afterSelect仅在 autoUpload=false 的时候生效,autoUpload=true时,可以使用beforeUpload完全可以替代该功能.
|
|
266
|
+
*/
|
|
267
|
+
afterSelect?: (file: {}) => boolean;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 点击移除的回调
|
|
271
|
+
*/
|
|
272
|
+
onRemove?: () => void;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* 自定义class
|
|
276
|
+
*/
|
|
277
|
+
className?: string;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 自定义内联样式
|
|
281
|
+
*/
|
|
282
|
+
style?: React.CSSProperties;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 自动上传
|
|
286
|
+
*/
|
|
287
|
+
autoUpload?: boolean;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 透传给Progress props
|
|
291
|
+
*/
|
|
292
|
+
progressProps?: ProgressProps;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 点击图片回调
|
|
296
|
+
* @en Click image callback
|
|
297
|
+
* @skip
|
|
298
|
+
*/
|
|
299
|
+
onPreview?: (file: UploadFile, e?: MouseEvent<HTMLElement>) => void;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* 取消上传的回调
|
|
303
|
+
*/
|
|
304
|
+
onCancel?: () => void;
|
|
305
|
+
/**
|
|
306
|
+
* 调用系统设备媒体
|
|
307
|
+
*/
|
|
308
|
+
capture?: string;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* 自定义成功和失败的列表渲染方式
|
|
312
|
+
*/
|
|
313
|
+
itemRender?: (file: UploadFile, obj: { remove?: () => void }) => React.ReactNode;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 选择新文件上传并替换
|
|
317
|
+
*/
|
|
318
|
+
reUpload?: boolean;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export class Card extends React.Component<CardProps, any> {}
|
|
322
|
+
|
|
323
|
+
export interface SimpleJSONUploadProps extends UploadProps, CardProps {
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 可以指定上传组件
|
|
327
|
+
*/
|
|
328
|
+
uploadComponent?: any;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 上传文件改变时的状态。两个参数的OnChange函数,可以接收最原始的返回值。
|
|
332
|
+
*/
|
|
333
|
+
onChange2?: (value: File[], param2?: any) => void;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 在Preview模式下,如何显示 预览效果
|
|
337
|
+
* 默认:default
|
|
338
|
+
*/
|
|
339
|
+
previewMode?: 'default' | 'auto' | 'image' | 'download' | 'weboffice';
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
export class SimpleJSONUpload extends React.Component<SimpleJSONUploadProps, any> {} {
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
export interface DraggerProps extends UploadProps {
|
|
349
|
+
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export class Dragger extends React.Component<DraggerProps, any> {}
|
|
353
|
+
|
|
354
|
+
export interface SelecterProps extends HTMLAttributesWeak, CommonProps {
|
|
355
|
+
/**
|
|
356
|
+
* 是否禁用上传功能
|
|
357
|
+
*/
|
|
358
|
+
disabled?: boolean;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件
|
|
362
|
+
*/
|
|
363
|
+
multiple?: boolean;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* 是否支持拖拽上传,`ie10+` 支持。
|
|
367
|
+
*/
|
|
368
|
+
dragable?: boolean;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* 接受上传的文件类型 (image/png, image/jpg, .doc, .ppt) 详见 [input accept attribute](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input#attr-accept)
|
|
372
|
+
*/
|
|
373
|
+
accept?: string;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* 文件选择回调
|
|
377
|
+
*/
|
|
378
|
+
onSelect?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* 拖拽经过回调
|
|
382
|
+
*/
|
|
383
|
+
onDragOver?: () => void;
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 拖拽离开回调
|
|
387
|
+
*/
|
|
388
|
+
onDragLeave?: () => void;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 拖拽完成回调
|
|
392
|
+
*/
|
|
393
|
+
onDrop?: () => void;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* 是否支持上传文件夹,仅在 chorme 下生效
|
|
397
|
+
*/
|
|
398
|
+
webkitdirectory?: boolean;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export class Selecter extends React.Component<SelecterProps, any> {}
|
|
402
|
+
|
|
403
|
+
export class Uploader {
|
|
404
|
+
/**
|
|
405
|
+
* @param options 配置
|
|
406
|
+
*/
|
|
407
|
+
constructor(options?: any);
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* 配置选项
|
|
411
|
+
* @param options 配置
|
|
412
|
+
*/
|
|
413
|
+
setOptions(options: any): void;
|
|
414
|
+
/**
|
|
415
|
+
* 开始上传
|
|
416
|
+
* @param files 文件列表
|
|
417
|
+
*/
|
|
418
|
+
startUpload(files: Array<any>): void;
|
|
419
|
+
/**
|
|
420
|
+
* 中断某个文件上传
|
|
421
|
+
* @param file 文件
|
|
422
|
+
*/
|
|
423
|
+
abort(file: any): void;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
export interface UploadProps extends HTMLAttributesWeak, CommonProps {
|
|
428
|
+
/**
|
|
429
|
+
* 上传的地址
|
|
430
|
+
*/
|
|
431
|
+
action?: string;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* 接受上传的文件类型 (image/png, image/jpg, .doc, .ppt) 详见 [input accept attribute](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input#attr-accept)
|
|
435
|
+
*/
|
|
436
|
+
accept?: string;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* 上传额外传参
|
|
440
|
+
*/
|
|
441
|
+
data?: any | (() => void);
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件
|
|
445
|
+
*/
|
|
446
|
+
multiple?: boolean;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* 设置上传的请求头部
|
|
450
|
+
*/
|
|
451
|
+
headers?: any;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* 是否允许请求携带 cookie
|
|
455
|
+
*/
|
|
456
|
+
withCredentials?: boolean;
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* 可选参数,详见 [beforeUpload](#beforeUpload)
|
|
461
|
+
* @en Optional parameters, see [beforeUpload](#beforeUpload)
|
|
462
|
+
* @param file - 所有文件 - all file
|
|
463
|
+
* @param options - 参数 - parameters
|
|
464
|
+
* @defaultValue func.noop
|
|
465
|
+
*/
|
|
466
|
+
beforeUpload?: (file: UploadFile, options: BeforeUploadOption) => boolean | object | unknown;
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* 上传中
|
|
471
|
+
* @en onProgress Callback
|
|
472
|
+
* @defaultValue func.noop
|
|
473
|
+
*/
|
|
474
|
+
onProgress?: (file: ObjectFile[], e: ObjectFile) => void;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* 可选参数,上传成功回调函数,参数为请求下响应信息以及文件
|
|
478
|
+
* @en Optional parameters, upload success callback function, the parameter is the response information and file
|
|
479
|
+
* @param file - 文件 - file
|
|
480
|
+
* @param value - 值 - value
|
|
481
|
+
* @defaultValue func.noop
|
|
482
|
+
*/
|
|
483
|
+
onSuccess?: (file: ObjectFile, value?: ObjectFile[]) => void;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* 可选参数,上传失败回调函数,参数为上传失败的信息、响应信息以及文件
|
|
487
|
+
* @en Optional parameters, upload failure callback function, the parameter is the upload failure information, response information and file
|
|
488
|
+
* @param file - 出错的文件 - error file
|
|
489
|
+
* @param value - 当前值 - current value
|
|
490
|
+
* @defaultValue func.noop
|
|
491
|
+
*/
|
|
492
|
+
onError?: (error: UploadError, res?:any, file?:any) => void;
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* 子元素
|
|
497
|
+
*/
|
|
498
|
+
children?: React.ReactNode;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* 设置上传超时,单位ms
|
|
502
|
+
*/
|
|
503
|
+
timeout?: number;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* 上传方法
|
|
507
|
+
*/
|
|
508
|
+
method?: 'post' | 'put';
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* 自定义上传方法
|
|
512
|
+
*/
|
|
513
|
+
request?: (option: any) => any;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* 文件名字段
|
|
517
|
+
*/
|
|
518
|
+
name?: string;
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* 选择文件回调
|
|
523
|
+
* @en Select file callback
|
|
524
|
+
* @defaultValue func.noop
|
|
525
|
+
*/
|
|
526
|
+
onSelect?: (uploadFiles: any[]) => any;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* 放文件
|
|
530
|
+
* @en Drop file
|
|
531
|
+
* @defaultValue func.noop
|
|
532
|
+
*/
|
|
533
|
+
onDrop?: (files: UploadFile[]) => void;
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* 样式前缀
|
|
538
|
+
*/
|
|
539
|
+
prefix?: string;
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* 文件列表
|
|
543
|
+
*/
|
|
544
|
+
value?: Array<any>;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* 默认文件列表
|
|
548
|
+
*/
|
|
549
|
+
defaultValue?: Array<any>;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 上传按钮形状
|
|
553
|
+
*/
|
|
554
|
+
shape?: 'card';
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* 上传列表的样式
|
|
558
|
+
*/
|
|
559
|
+
listType?: 'text' | 'image' | 'card';
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* 数据格式化函数,配合自定义 action 使用,参数为服务器的响应数据,详见 [formatter](#formater)
|
|
563
|
+
*/
|
|
564
|
+
formatter?: (response: any, file: any) => void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* 自定义渲染List的图标
|
|
568
|
+
* @param img
|
|
569
|
+
* @param imgURL
|
|
570
|
+
* @param file
|
|
571
|
+
*/
|
|
572
|
+
thumbnailRender?: (img:any, imgURL:any, file:any)=> any;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* 最大文件上传个数
|
|
576
|
+
*/
|
|
577
|
+
limit?: number;
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* 可选参数,是否支持拖拽上传,`ie10+` 支持。
|
|
581
|
+
*/
|
|
582
|
+
dragable?: boolean;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 可选参数,是否本地预览
|
|
586
|
+
*/
|
|
587
|
+
useDataURL?: boolean;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* 可选参数,是否禁用上传功能
|
|
591
|
+
*/
|
|
592
|
+
disabled?: boolean;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* 上传文件改变时的状态
|
|
596
|
+
*/
|
|
597
|
+
onChange?: (value: File[]) => void;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* 可选参数, 用于校验文件,afterSelect仅在 autoUpload=false 的时候生效,autoUpload=true时,可以使用beforeUpload完全可以替代该功能.
|
|
601
|
+
*/
|
|
602
|
+
afterSelect?: (file: any) => boolean;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* 移除文件回调函数
|
|
606
|
+
*/
|
|
607
|
+
onRemove?: (file: any) => boolean | any;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* 自定义额外渲染
|
|
611
|
+
*/
|
|
612
|
+
extraRender?: (file: File) => any;
|
|
613
|
+
/**
|
|
614
|
+
* 自定义文件名渲染
|
|
615
|
+
*/
|
|
616
|
+
fileNameRender?: (file: File) => any;
|
|
617
|
+
/**
|
|
618
|
+
* 自定义操作区域渲染
|
|
619
|
+
*/
|
|
620
|
+
actionRender?: (file: ObjectFile) => any;
|
|
621
|
+
/**
|
|
622
|
+
* 自定义class
|
|
623
|
+
*/
|
|
624
|
+
className?: string;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* 自定义内联样式
|
|
628
|
+
*/
|
|
629
|
+
style?: React.CSSProperties;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* 自动上传
|
|
633
|
+
*/
|
|
634
|
+
autoUpload?: boolean;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* 透传给Progress props
|
|
638
|
+
*/
|
|
639
|
+
progressProps?: ProgressProps;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* 是否为预览态
|
|
643
|
+
*/
|
|
644
|
+
isPreview?: boolean;
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* 预览态模式下渲染的内容
|
|
648
|
+
*/
|
|
649
|
+
renderPreview?: (value: number) => void;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* 文件对象的 key name
|
|
653
|
+
*/
|
|
654
|
+
fileKeyName?: string;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* 点击图片回调
|
|
658
|
+
* @en Click image callback
|
|
659
|
+
* @skip
|
|
660
|
+
*/
|
|
661
|
+
onPreview?: (file: UploadFile, e?: MouseEvent<HTMLElement>) => void;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* 点击文件名时触发 onPreview
|
|
665
|
+
* @version 1.24
|
|
666
|
+
*/
|
|
667
|
+
previewOnFileName?: boolean;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* 自定义成功和失败的列表渲染方式,仅在 listType 是 card/image 时生效
|
|
671
|
+
* @en Customize success and failure list rendering, only in listType is card or image
|
|
672
|
+
*/
|
|
673
|
+
itemRender?: (file: UploadFile, action?: { remove?: () => void }) => ReactNode;
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* 选择新文件上传并替换
|
|
677
|
+
*/
|
|
678
|
+
reUpload?: boolean;
|
|
679
|
+
webkitdirectory?: boolean;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export enum ErrorCode {
|
|
683
|
+
EXCEED_LIMIT = 'EXCEED_LIMIT',
|
|
684
|
+
BEFOREUPLOAD_REJECT = 'BEFOREUPLOAD_REJECT',
|
|
685
|
+
RESPONSE_FAIL = 'RESPONSE_FAIL',
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export default class Upload extends React.Component<UploadProps, any> {
|
|
689
|
+
static Card: typeof Card;
|
|
690
|
+
static Dragger: typeof Dragger;
|
|
691
|
+
static Selecter: typeof Selecter;
|
|
692
|
+
static Uploader: typeof Uploader;
|
|
693
|
+
static SimpleJSONUpload: typeof SimpleJSONUpload;
|
|
694
|
+
static ErrorCode: typeof ErrorCode;
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* 添加文件
|
|
698
|
+
* @param files
|
|
699
|
+
*/
|
|
700
|
+
selectFiles: (file: File) => void;
|
|
701
|
+
/**
|
|
702
|
+
* 控制文件上传
|
|
703
|
+
*/
|
|
704
|
+
startUpload: () => void;
|
|
705
|
+
/**
|
|
706
|
+
* 控制文件上传
|
|
707
|
+
* @param file 文件
|
|
708
|
+
*/
|
|
709
|
+
uploadFiles: (file: File) => void;
|
|
710
|
+
/**
|
|
711
|
+
* 替换文件
|
|
712
|
+
*/
|
|
713
|
+
replaceFiles: (old: object, current: object) => void;
|
|
714
|
+
/**
|
|
715
|
+
* 上传状态
|
|
716
|
+
*/
|
|
717
|
+
isUploading: () => boolean;
|
|
718
|
+
/**
|
|
719
|
+
* 中断某个文件上传
|
|
720
|
+
* @param file 文件
|
|
721
|
+
*/
|
|
722
|
+
abort: (file: File) => void;
|
|
723
|
+
}
|