@arco-design/mobile-react 2.30.9 → 2.31.0
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/CHANGELOG.md +32 -0
- package/README.en-US.md +70 -2
- package/README.md +69 -2
- package/cjs/carousel/index.js +3 -0
- package/cjs/form/form-item.d.ts +3 -0
- package/cjs/form/form-item.js +38 -10
- package/cjs/form/style/css/index.css +13 -0
- package/cjs/form/style/index.less +18 -0
- package/cjs/icon/IconCheck/index.js +1 -2
- package/cjs/icon/IconDownload/index.d.ts +7 -0
- package/cjs/icon/IconDownload/index.js +41 -0
- package/cjs/icon/IconFile/index.d.ts +7 -0
- package/cjs/icon/IconFile/index.js +41 -0
- package/cjs/icon/IconKeyboard/index.js +1 -0
- package/cjs/icon/IconQuestionCircle/index.js +1 -2
- package/cjs/icon/IconUpload/index.js +6 -4
- package/cjs/icon/IconUserFill/index.js +1 -2
- package/cjs/icon/index.d.ts +3 -1
- package/cjs/icon/index.js +17 -7
- package/cjs/icon/type.d.ts +3 -1
- package/cjs/image-picker/index.js +15 -161
- package/cjs/image-picker/type.d.ts +4 -73
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +6 -2
- package/cjs/input/hooks.js +2 -2
- package/cjs/input/props.d.ts +2 -2
- package/cjs/picker/index.js +60 -19
- package/cjs/picker/type.d.ts +7 -2
- package/cjs/picker-view/components/cascader.d.ts +1 -0
- package/cjs/picker-view/components/cascader.js +8 -1
- package/cjs/picker-view/components/picker-cell.d.ts +1 -0
- package/cjs/picker-view/components/picker-cell.js +6 -1
- package/cjs/picker-view/index.d.ts +6 -1
- package/cjs/picker-view/index.js +25 -13
- package/cjs/style.d.ts +1 -0
- package/cjs/style.js +3 -1
- package/cjs/tabs/tab-cell.js +54 -29
- package/cjs/tabs/type.d.ts +5 -0
- package/cjs/uploader/index.d.ts +16 -0
- package/cjs/uploader/index.js +180 -0
- package/cjs/uploader/style/css/index.css +650 -0
- package/cjs/uploader/style/css/index.d.ts +4 -0
- package/cjs/uploader/style/css/index.js +9 -0
- package/cjs/uploader/style/index.d.ts +4 -0
- package/cjs/uploader/style/index.js +9 -0
- package/cjs/uploader/style/index.less +161 -0
- package/cjs/uploader/type.d.ts +108 -0
- package/cjs/uploader/type.js +3 -0
- package/cjs/uploader/upload/index.d.ts +2 -0
- package/cjs/uploader/upload/index.js +19 -0
- package/cjs/uploader/upload/type.d.ts +107 -0
- package/cjs/uploader/upload/type.js +3 -0
- package/cjs/uploader/upload/upload.d.ts +20 -0
- package/cjs/uploader/upload/upload.js +189 -0
- package/dist/index.js +679 -310
- package/dist/index.min.js +4 -4
- package/dist/style.css +593 -0
- package/dist/style.min.css +1 -1
- package/esm/carousel/index.js +3 -0
- package/esm/form/form-item.d.ts +3 -0
- package/esm/form/form-item.js +36 -10
- package/esm/form/style/css/index.css +13 -0
- package/esm/form/style/index.less +18 -0
- package/esm/icon/IconCheck/index.js +1 -2
- package/esm/icon/IconDownload/index.d.ts +7 -0
- package/esm/icon/IconDownload/index.js +30 -0
- package/esm/icon/IconFile/index.d.ts +7 -0
- package/esm/icon/IconFile/index.js +30 -0
- package/esm/icon/IconKeyboard/index.js +1 -0
- package/esm/icon/IconQuestionCircle/index.js +1 -2
- package/esm/icon/IconUpload/index.js +6 -4
- package/esm/icon/IconUserFill/index.js +1 -2
- package/esm/icon/index.d.ts +3 -1
- package/esm/icon/index.js +3 -1
- package/esm/icon/type.d.ts +3 -1
- package/esm/image-picker/index.js +14 -160
- package/esm/image-picker/type.d.ts +4 -73
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -1
- package/esm/input/hooks.js +2 -2
- package/esm/input/props.d.ts +2 -2
- package/esm/picker/index.js +61 -20
- package/esm/picker/type.d.ts +7 -2
- package/esm/picker-view/components/cascader.d.ts +1 -0
- package/esm/picker-view/components/cascader.js +8 -1
- package/esm/picker-view/components/picker-cell.d.ts +1 -0
- package/esm/picker-view/components/picker-cell.js +6 -1
- package/esm/picker-view/index.d.ts +6 -1
- package/esm/picker-view/index.js +26 -13
- package/esm/style.d.ts +1 -0
- package/esm/style.js +2 -1
- package/esm/tabs/tab-cell.js +56 -30
- package/esm/tabs/type.d.ts +5 -0
- package/esm/uploader/index.d.ts +16 -0
- package/esm/uploader/index.js +150 -0
- package/esm/uploader/style/css/index.css +650 -0
- package/esm/uploader/style/css/index.d.ts +4 -0
- package/esm/uploader/style/css/index.js +4 -0
- package/esm/uploader/style/index.d.ts +4 -0
- package/esm/uploader/style/index.js +4 -0
- package/esm/uploader/style/index.less +161 -0
- package/esm/uploader/type.d.ts +108 -0
- package/esm/uploader/type.js +1 -0
- package/esm/uploader/upload/index.d.ts +2 -0
- package/esm/uploader/upload/index.js +2 -0
- package/esm/uploader/upload/type.d.ts +107 -0
- package/esm/uploader/upload/type.js +1 -0
- package/esm/uploader/upload/upload.d.ts +20 -0
- package/esm/uploader/upload/upload.js +175 -0
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +27 -0
- package/tokens/app/arcodesign/default/index.d.ts +27 -0
- package/tokens/app/arcodesign/default/index.js +28 -1
- package/tokens/app/arcodesign/default/index.json +292 -0
- package/tokens/app/arcodesign/default/index.less +27 -0
- package/umd/carousel/index.js +3 -0
- package/umd/form/form-item.d.ts +3 -0
- package/umd/form/form-item.js +38 -10
- package/umd/form/style/css/index.css +13 -0
- package/umd/form/style/index.less +18 -0
- package/umd/icon/IconCheck/index.js +1 -2
- package/umd/icon/IconDownload/index.d.ts +7 -0
- package/umd/icon/IconDownload/index.js +49 -0
- package/umd/icon/IconFile/index.d.ts +7 -0
- package/umd/icon/IconFile/index.js +49 -0
- package/umd/icon/IconKeyboard/index.js +1 -0
- package/umd/icon/IconQuestionCircle/index.js +1 -2
- package/umd/icon/IconUpload/index.js +6 -4
- package/umd/icon/IconUserFill/index.js +1 -2
- package/umd/icon/index.d.ts +3 -1
- package/umd/icon/index.js +15 -9
- package/umd/icon/type.d.ts +3 -1
- package/umd/image-picker/index.js +17 -163
- package/umd/image-picker/type.d.ts +4 -73
- package/umd/index.d.ts +1 -0
- package/umd/index.js +7 -5
- package/umd/input/hooks.js +2 -2
- package/umd/input/props.d.ts +2 -2
- package/umd/picker/index.js +60 -19
- package/umd/picker/type.d.ts +7 -2
- package/umd/picker-view/components/cascader.d.ts +1 -0
- package/umd/picker-view/components/cascader.js +8 -1
- package/umd/picker-view/components/picker-cell.d.ts +1 -0
- package/umd/picker-view/components/picker-cell.js +6 -1
- package/umd/picker-view/index.d.ts +6 -1
- package/umd/picker-view/index.js +25 -13
- package/umd/style.d.ts +1 -0
- package/umd/style.js +4 -4
- package/umd/tabs/tab-cell.js +54 -29
- package/umd/tabs/type.d.ts +5 -0
- package/umd/uploader/index.d.ts +16 -0
- package/umd/uploader/index.js +178 -0
- package/umd/uploader/style/css/index.css +650 -0
- package/umd/uploader/style/css/index.d.ts +4 -0
- package/umd/uploader/style/css/index.js +15 -0
- package/umd/uploader/style/index.d.ts +4 -0
- package/umd/uploader/style/index.js +15 -0
- package/umd/uploader/style/index.less +161 -0
- package/umd/uploader/type.d.ts +108 -0
- package/umd/uploader/type.js +17 -0
- package/umd/uploader/upload/index.d.ts +2 -0
- package/umd/uploader/upload/index.js +27 -0
- package/umd/uploader/upload/type.d.ts +107 -0
- package/umd/uploader/upload/type.js +17 -0
- package/umd/uploader/upload/upload.d.ts +20 -0
- package/umd/uploader/upload/upload.js +200 -0
@@ -0,0 +1,161 @@
|
|
1
|
+
@import '../../../style/mixin.less';
|
2
|
+
|
3
|
+
.@{prefix}-uploader {
|
4
|
+
&-container {
|
5
|
+
display: flex;
|
6
|
+
flex-wrap: wrap;
|
7
|
+
}
|
8
|
+
&-add {
|
9
|
+
position: relative;
|
10
|
+
input {
|
11
|
+
position: absolute;
|
12
|
+
opacity: 0;
|
13
|
+
left: 0;
|
14
|
+
top: 0;
|
15
|
+
width: 100%;
|
16
|
+
height: 100%;
|
17
|
+
display: none;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
&-list {
|
21
|
+
width: 100%;
|
22
|
+
&-item {
|
23
|
+
display: flex;
|
24
|
+
align-items: center;
|
25
|
+
.use-var(height, uploader-item-height);
|
26
|
+
.use-var(margin-top, uploader-item-margin-top);
|
27
|
+
&-container {
|
28
|
+
flex: 1;
|
29
|
+
display: flex;
|
30
|
+
align-items: center;
|
31
|
+
height: 100%;
|
32
|
+
.use-var(border-radius, uploader-item-border-radius);
|
33
|
+
.use-var(background-color, uploader-item-background-color);
|
34
|
+
.use-var(padding, uploader-item-padding);
|
35
|
+
}
|
36
|
+
&-wrapper {
|
37
|
+
display: flex;
|
38
|
+
flex: 1;
|
39
|
+
align-items: center;
|
40
|
+
}
|
41
|
+
&-file {
|
42
|
+
display: flex;
|
43
|
+
.use-var(font-size, uploader-file-icon-font-size);
|
44
|
+
.use-var-with-rtl(margin-right, uploader-file-icon-margin-right);
|
45
|
+
&-icon {
|
46
|
+
.use-var(color, uploader-file-icon-color);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
&-text {
|
50
|
+
font-weight: 400;
|
51
|
+
.use-var(font-size, uploader-item-text-font-size);
|
52
|
+
.use-var(color, uploader-item-text-color);
|
53
|
+
&-error {
|
54
|
+
.use-var(color, uploader-item-text-error-color);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
&-loaded {
|
58
|
+
display: flex;
|
59
|
+
.use-var(font-size, uploader-loaded-icon-font-size);
|
60
|
+
.use-var(color, uploader-loaded-icon-color);
|
61
|
+
}
|
62
|
+
&-error {
|
63
|
+
font-weight: 400;
|
64
|
+
.use-var(font-size, uploader-error-text-font-size);
|
65
|
+
.use-var(color, uploader-error-text-color);
|
66
|
+
}
|
67
|
+
&-delete {
|
68
|
+
display: flex;
|
69
|
+
height: 100%;
|
70
|
+
align-items: center;
|
71
|
+
.use-var-with-rtl(padding-left, uploader-delete-icon-padding-left);
|
72
|
+
.use-var(font-size, uploader-delete-icon-font-size);
|
73
|
+
&-icon {
|
74
|
+
.use-var(color, uploader-delete-icon-color);
|
75
|
+
&-disabled {
|
76
|
+
.use-var(color, uploader-disabled-delete-icon-color);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
.@{prefix}-uploader-disabled {
|
85
|
+
pointer-events: none;
|
86
|
+
}
|
87
|
+
|
88
|
+
/***************************************************
|
89
|
+
* *
|
90
|
+
* Arco Theme Style *
|
91
|
+
* *
|
92
|
+
***************************************************/
|
93
|
+
& when (@use-dark-mode = 1) {
|
94
|
+
|
95
|
+
.process-bg-color-with-config,
|
96
|
+
.process-custom-icon-bg-color-with-config {
|
97
|
+
@{arco-dark-mode-selector} & {
|
98
|
+
.use-var(color, dark-steps-process-with-config-item-icon-color);
|
99
|
+
.use-var(color, dark-steps-process-with-config-item-icon-color);
|
100
|
+
}
|
101
|
+
}
|
102
|
+
.wait-custom-icon-bg-color-with-config {
|
103
|
+
@{arco-dark-mode-selector} & {
|
104
|
+
.use-var(background, dark-steps-wait-icon-num-background);
|
105
|
+
.use-var(color, dark-sub-info-font-color);
|
106
|
+
.use-var(background, dark-steps-wait-icon-num-background);
|
107
|
+
.use-var(color, dark-sub-info-font-color);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
.@{prefix}-uploader {
|
111
|
+
&-list {
|
112
|
+
&-item {
|
113
|
+
&-container {
|
114
|
+
@{arco-dark-mode-selector} & {
|
115
|
+
.use-var(background-color, dark-uploader-item-background-color);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
&-file {
|
119
|
+
&-icon {
|
120
|
+
@{arco-dark-mode-selector} & {
|
121
|
+
.use-var(color, dark-uploader-file-icon-color);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
&-text {
|
126
|
+
@{arco-dark-mode-selector} & {
|
127
|
+
.use-var(color, dark-uploader-item-text-color);
|
128
|
+
}
|
129
|
+
&-error {
|
130
|
+
@{arco-dark-mode-selector} & {
|
131
|
+
.use-var(color, dark-uploader-item-text-error-color);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
&-loaded {
|
136
|
+
@{arco-dark-mode-selector} & {
|
137
|
+
.use-var(color, dark-uploader-loaded-icon-color);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
&-error {
|
141
|
+
@{arco-dark-mode-selector} & {
|
142
|
+
.use-var(color, dark-uploader-error-text-color);
|
143
|
+
}
|
144
|
+
}
|
145
|
+
&-delete {
|
146
|
+
&-icon {
|
147
|
+
@{arco-dark-mode-selector} & {
|
148
|
+
.use-var(color, dark-uploader-delete-icon-color);
|
149
|
+
}
|
150
|
+
&-disabled {
|
151
|
+
@{arco-dark-mode-selector} & {
|
152
|
+
.use-var(color, dark-uploader-disabled-delete-icon-color);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
/********************* End *************************/
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
2
|
+
import { UploadCommonProps, CommonFileItem } from './upload/type';
|
3
|
+
export interface FileItem extends CommonFileItem {
|
4
|
+
/**
|
5
|
+
* 文件
|
6
|
+
* @en File
|
7
|
+
*/
|
8
|
+
file: File;
|
9
|
+
}
|
10
|
+
export interface UploaderProps extends UploadCommonProps {
|
11
|
+
/**
|
12
|
+
* 自定义类名
|
13
|
+
* @en Custom className
|
14
|
+
*/
|
15
|
+
className?: string;
|
16
|
+
/**
|
17
|
+
* 自定义样式
|
18
|
+
* @en Custom stylesheet
|
19
|
+
*/
|
20
|
+
style?: React.CSSProperties;
|
21
|
+
/**
|
22
|
+
* 可以选择的文件类型
|
23
|
+
* @en Available file types
|
24
|
+
* @default undefined
|
25
|
+
*/
|
26
|
+
accept?: InputHTMLAttributes<unknown>['accept'];
|
27
|
+
/**
|
28
|
+
* 是否支持多选
|
29
|
+
* @en Whether to support multiple selection
|
30
|
+
*/
|
31
|
+
multiple?: boolean;
|
32
|
+
/**
|
33
|
+
* 文件选取模式 File selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
34
|
+
* @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
35
|
+
*/
|
36
|
+
capture?: InputHTMLAttributes<unknown>['capture'];
|
37
|
+
/**
|
38
|
+
* 是否隐藏文件上传状态
|
39
|
+
* @en Whether to hide file upload status
|
40
|
+
* @default false
|
41
|
+
*/
|
42
|
+
hideStatus?: boolean;
|
43
|
+
/**
|
44
|
+
* 是否总是展示选择Icon,默认情况下当文件数量超出limit值时会自动隐藏选择Icon
|
45
|
+
* @en Whether to always show Select Icon
|
46
|
+
* @default false
|
47
|
+
*/
|
48
|
+
alwaysShowSelect?: boolean;
|
49
|
+
/**
|
50
|
+
* 禁用选择和删除图片
|
51
|
+
* @en Disable select & delete image
|
52
|
+
*/
|
53
|
+
disabled?: boolean;
|
54
|
+
/**
|
55
|
+
* 自定义删除区域
|
56
|
+
* @en Defined delete area
|
57
|
+
*/
|
58
|
+
renderDeleteArea?: (fileItem: FileItem, index: number) => React.ReactNode;
|
59
|
+
/**
|
60
|
+
* 自定义上传成功区域
|
61
|
+
* @en Defined loaded area
|
62
|
+
*/
|
63
|
+
renderLoadedArea?: (fileItem: FileItem, index: number) => React.ReactNode;
|
64
|
+
/**
|
65
|
+
* 自定义上传中区域
|
66
|
+
* @en Defined loading area
|
67
|
+
*/
|
68
|
+
renderLoadingArea?: (fileItem: FileItem, index: number) => React.ReactNode;
|
69
|
+
/**
|
70
|
+
* 自定义上传失败区域
|
71
|
+
* @en Defined error area
|
72
|
+
*/
|
73
|
+
renderErrorArea?: (fileItem: FileItem, index: number) => React.ReactNode;
|
74
|
+
/**
|
75
|
+
* 自定义文件索引区域
|
76
|
+
* @en Defined file index area
|
77
|
+
*/
|
78
|
+
renderFileIndexArea?: (fileItem: FileItem, index: number) => React.ReactNode;
|
79
|
+
/**
|
80
|
+
* 自定义上传按钮区域
|
81
|
+
* @en Defined upload button area
|
82
|
+
*/
|
83
|
+
renderUploadArea?: () => React.ReactNode;
|
84
|
+
/**
|
85
|
+
* 自定义上传文件列表展示
|
86
|
+
* @en Defined file list display
|
87
|
+
*/
|
88
|
+
renderFileList?: (methods: FileListMethods) => React.ReactNode;
|
89
|
+
}
|
90
|
+
export interface UploaderRef {
|
91
|
+
/**
|
92
|
+
* 最外层 DOM 元素
|
93
|
+
* @en The outer DOM element of the component
|
94
|
+
*/
|
95
|
+
dom: HTMLDivElement | null;
|
96
|
+
}
|
97
|
+
export interface FileListMethods {
|
98
|
+
/**
|
99
|
+
* 重新上传
|
100
|
+
* @en Retry to upload
|
101
|
+
*/
|
102
|
+
retryUpload: (index: number) => void;
|
103
|
+
/**
|
104
|
+
* 删除文件
|
105
|
+
* @en Delete file
|
106
|
+
*/
|
107
|
+
deleteFile: (index: number) => void;
|
108
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
export interface AdapterFile {
|
3
|
+
/**
|
4
|
+
* 文件 url
|
5
|
+
* @en Url of file
|
6
|
+
*/
|
7
|
+
url?: string;
|
8
|
+
/**
|
9
|
+
* 文件大小
|
10
|
+
* @en File size
|
11
|
+
*/
|
12
|
+
size: number;
|
13
|
+
/**
|
14
|
+
* 文件名
|
15
|
+
* @en File name
|
16
|
+
*/
|
17
|
+
name: string;
|
18
|
+
}
|
19
|
+
export interface SelectCallback {
|
20
|
+
/**
|
21
|
+
* 文件列表
|
22
|
+
* @en File list
|
23
|
+
*/
|
24
|
+
files: AdapterFile[];
|
25
|
+
}
|
26
|
+
export interface CommonFileItem {
|
27
|
+
/**
|
28
|
+
* 文件地址
|
29
|
+
* @en file Url
|
30
|
+
*/
|
31
|
+
url?: string;
|
32
|
+
/**
|
33
|
+
* 文件
|
34
|
+
* @en File
|
35
|
+
*/
|
36
|
+
file?: File;
|
37
|
+
/**
|
38
|
+
* 文件状态
|
39
|
+
* @en Image Status
|
40
|
+
* @default 以文件自身加载状态而定
|
41
|
+
* @default_en According to inner status of the image
|
42
|
+
*/
|
43
|
+
status?: 'loaded' | 'loading' | 'error';
|
44
|
+
}
|
45
|
+
export interface UploadCommonProps<FileItem extends CommonFileItem = CommonFileItem> {
|
46
|
+
/**
|
47
|
+
* 上传方法
|
48
|
+
* @en Upload function
|
49
|
+
*/
|
50
|
+
upload?: (file: FileItem) => Promise<FileItem | null>;
|
51
|
+
/**
|
52
|
+
* 已选文件列表发生变化
|
53
|
+
* @en The list of selected files changes
|
54
|
+
*/
|
55
|
+
onChange?: (fileList: FileItem[]) => void;
|
56
|
+
/**
|
57
|
+
* 文件大小限制,单位为K
|
58
|
+
* @en File size limit, in K
|
59
|
+
*/
|
60
|
+
maxSize?: number;
|
61
|
+
/**
|
62
|
+
* 文件超过限制大小
|
63
|
+
* @en Image exceeds size limit
|
64
|
+
*/
|
65
|
+
onMaxSizeExceed?: (file: File) => void;
|
66
|
+
/**
|
67
|
+
* 最多选择文件数,超出数量自动隐藏上传按钮,0表示不做限制
|
68
|
+
* @en Max pictures can choose, 0 means no restriction
|
69
|
+
* @default 0
|
70
|
+
*/
|
71
|
+
limit?: number;
|
72
|
+
/**
|
73
|
+
* 选择文件数超过限制
|
74
|
+
* @en The number of pictures exceeds the limit
|
75
|
+
*/
|
76
|
+
onLimitExceed?: (files: File[]) => void;
|
77
|
+
/**
|
78
|
+
* 已选择文件列表
|
79
|
+
* @en Selected files list
|
80
|
+
*/
|
81
|
+
files: FileItem[];
|
82
|
+
/**
|
83
|
+
* 删除点击事件
|
84
|
+
* @en Delete area click event
|
85
|
+
*/
|
86
|
+
onDeleteClick?: (index: number) => void;
|
87
|
+
/**
|
88
|
+
* 上传文件点击事件
|
89
|
+
* @en Upload area click event
|
90
|
+
*/
|
91
|
+
onUploadClick?: () => void;
|
92
|
+
/**
|
93
|
+
* 文件选择适配器
|
94
|
+
* @en Select adaptor
|
95
|
+
*/
|
96
|
+
selectAdapter?: () => Promise<SelectCallback>;
|
97
|
+
/**
|
98
|
+
* 文件点击
|
99
|
+
* @en click event
|
100
|
+
*/
|
101
|
+
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, file: FileItem, index: number) => void;
|
102
|
+
/**
|
103
|
+
* 文件长按事件
|
104
|
+
* @en long press event
|
105
|
+
*/
|
106
|
+
onLongPress?: (e: React.TouchEvent<HTMLElement>, file: FileItem, index: number) => void;
|
107
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import React from 'react';
|
3
|
+
import { Promise } from 'es6-promise';
|
4
|
+
import { AdapterFile, CommonFileItem, UploadCommonProps } from './type';
|
5
|
+
export declare class Upload<FileItem extends CommonFileItem = CommonFileItem> {
|
6
|
+
props: UploadCommonProps<FileItem>;
|
7
|
+
fileRef: React.MutableRefObject<HTMLInputElement | null>;
|
8
|
+
cacheRef: React.MutableRefObject<FileItem[]>;
|
9
|
+
timeOutEvent: NodeJS.Timeout | number;
|
10
|
+
constructor(props: UploadCommonProps<FileItem>, fileRef: React.MutableRefObject<HTMLInputElement | null>, cacheRef: React.MutableRefObject<FileItem[]>);
|
11
|
+
init(): void;
|
12
|
+
handleFile: (newFiles: File[]) => void;
|
13
|
+
handleChange: (event: any, fromAdapter?: boolean | undefined) => void;
|
14
|
+
deleteFile: (index: number) => void;
|
15
|
+
retryUpload: (index: number) => void;
|
16
|
+
handleSelect: (e: React.MouseEvent) => void;
|
17
|
+
handleClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, file: FileItem, index: number) => void;
|
18
|
+
handleTouchStart: (e: React.TouchEvent<HTMLDivElement>, image: FileItem, index: number) => void;
|
19
|
+
}
|
20
|
+
export declare const parseFile: (file: AdapterFile) => Promise<unknown>;
|
@@ -0,0 +1,175 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import { Promise } from 'es6-promise';
|
3
|
+
export var Upload = /*#__PURE__*/function () {
|
4
|
+
// click && longPress
|
5
|
+
function Upload(props, fileRef, cacheRef) {
|
6
|
+
var _this = this;
|
7
|
+
|
8
|
+
this.props = void 0;
|
9
|
+
this.fileRef = void 0;
|
10
|
+
this.cacheRef = void 0;
|
11
|
+
this.timeOutEvent = void 0;
|
12
|
+
|
13
|
+
this.handleFile = function (newFiles) {
|
14
|
+
Promise.all(newFiles.map(function (file) {
|
15
|
+
return parseFile(file);
|
16
|
+
})).then(function (parseFiles) {
|
17
|
+
var res = parseFiles.map(function (url, index) {
|
18
|
+
return {
|
19
|
+
url: url,
|
20
|
+
status: typeof _this.props.upload === 'function' ? 'loading' : 'loaded',
|
21
|
+
file: newFiles[index]
|
22
|
+
};
|
23
|
+
});
|
24
|
+
_this.cacheRef.current = [].concat(_this.cacheRef.current, res);
|
25
|
+
|
26
|
+
_this.props.onChange([].concat(_this.cacheRef.current)); // 执行upload
|
27
|
+
|
28
|
+
|
29
|
+
if (typeof _this.props.upload === 'function') {
|
30
|
+
newFiles.forEach(function (_file) {
|
31
|
+
_this.props.upload(_this.cacheRef.current.find(function (_ref) {
|
32
|
+
var file = _ref.file;
|
33
|
+
return file === _file;
|
34
|
+
})).then(function (data) {
|
35
|
+
var index = _this.cacheRef.current.findIndex(function (_ref2) {
|
36
|
+
var file = _ref2.file;
|
37
|
+
return file === _file;
|
38
|
+
});
|
39
|
+
|
40
|
+
if (index !== -1) {
|
41
|
+
_this.cacheRef.current[index] = _extends({}, _this.cacheRef.current[index], data, {
|
42
|
+
status: 'loaded'
|
43
|
+
});
|
44
|
+
}
|
45
|
+
}).catch(function () {
|
46
|
+
var index = _this.cacheRef.current.findIndex(function (_ref3) {
|
47
|
+
var file = _ref3.file;
|
48
|
+
return file === _file;
|
49
|
+
});
|
50
|
+
|
51
|
+
if (index !== -1) {
|
52
|
+
_this.cacheRef.current[index].status = 'error';
|
53
|
+
}
|
54
|
+
}).finally(function () {
|
55
|
+
_this.props.onChange([].concat(_this.cacheRef.current));
|
56
|
+
});
|
57
|
+
});
|
58
|
+
}
|
59
|
+
});
|
60
|
+
};
|
61
|
+
|
62
|
+
this.handleChange = function (event, fromAdapter) {
|
63
|
+
var newFiles = Array.prototype.filter.call(event.target.files || [], function (file) {
|
64
|
+
// 过滤maxSize
|
65
|
+
if (_this.props.maxSize && file.size > _this.props.maxSize * 1024) {
|
66
|
+
_this.props.onMaxSizeExceed && _this.props.onMaxSizeExceed(file);
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
|
70
|
+
return true;
|
71
|
+
}) || [];
|
72
|
+
|
73
|
+
if (!fromAdapter) {
|
74
|
+
event.target.value = '';
|
75
|
+
} // 截断limit
|
76
|
+
|
77
|
+
|
78
|
+
if (_this.props.limit !== 0 && newFiles.length + _this.props.files.length > _this.props.limit) {
|
79
|
+
_this.props.onLimitExceed && _this.props.onLimitExceed(newFiles);
|
80
|
+
newFiles.length = _this.props.limit - _this.props.files.length;
|
81
|
+
}
|
82
|
+
|
83
|
+
_this.handleFile(newFiles);
|
84
|
+
};
|
85
|
+
|
86
|
+
this.deleteFile = function (index) {
|
87
|
+
_this.props.onDeleteClick && _this.props.onDeleteClick(index);
|
88
|
+
|
89
|
+
_this.props.onChange(_this.props.files.filter(function (_i, j) {
|
90
|
+
return j !== index;
|
91
|
+
}));
|
92
|
+
};
|
93
|
+
|
94
|
+
this.retryUpload = function (index) {
|
95
|
+
_this.deleteFile(index);
|
96
|
+
|
97
|
+
_this.handleFile([_this.props.files[index].file]);
|
98
|
+
};
|
99
|
+
|
100
|
+
this.handleSelect = function (e) {
|
101
|
+
if (e.target !== _this.fileRef.current) {
|
102
|
+
var _this$fileRef$current;
|
103
|
+
|
104
|
+
_this.props.onUploadClick && _this.props.onUploadClick();
|
105
|
+
_this.props.selectAdapter ? _this.props.selectAdapter().then(function (value) {
|
106
|
+
return _this.handleChange({
|
107
|
+
target: {
|
108
|
+
files: value.files
|
109
|
+
}
|
110
|
+
}, true);
|
111
|
+
}) : (_this$fileRef$current = _this.fileRef.current) == null ? void 0 : _this$fileRef$current.click();
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
this.handleClick = function (e, file, index) {
|
116
|
+
clearTimeout(_this.timeOutEvent);
|
117
|
+
|
118
|
+
if (_this.timeOutEvent !== 0) {
|
119
|
+
_this.props.onClick == null ? void 0 : _this.props.onClick(e, file, index);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
this.handleTouchStart = function (e, image, index) {
|
124
|
+
_this.timeOutEvent = setTimeout(function () {
|
125
|
+
_this.timeOutEvent = 0;
|
126
|
+
_this.props.onLongPress == null ? void 0 : _this.props.onLongPress(e, image, index);
|
127
|
+
}, 750);
|
128
|
+
};
|
129
|
+
|
130
|
+
this.props = _extends({}, props);
|
131
|
+
this.fileRef = fileRef;
|
132
|
+
this.cacheRef = cacheRef;
|
133
|
+
this.init();
|
134
|
+
}
|
135
|
+
|
136
|
+
var _proto = Upload.prototype;
|
137
|
+
|
138
|
+
_proto.init = function init() {
|
139
|
+
!this.props.files && (this.props.files = []);
|
140
|
+
!this.props.limit && (this.props.limit = 0);
|
141
|
+
!this.props.onChange && (this.props.onChange = function () {
|
142
|
+
return null;
|
143
|
+
});
|
144
|
+
} // 解析文件生成预览
|
145
|
+
;
|
146
|
+
|
147
|
+
return Upload;
|
148
|
+
}();
|
149
|
+
export var parseFile = function parseFile(file) {
|
150
|
+
return new Promise(function (resolve, reject) {
|
151
|
+
if (file.url) {
|
152
|
+
resolve(file.url);
|
153
|
+
} else {
|
154
|
+
var reader = new FileReader();
|
155
|
+
|
156
|
+
reader.onload = function (e) {
|
157
|
+
var _e$target;
|
158
|
+
|
159
|
+
var dataURL = (_e$target = e.target) == null ? void 0 : _e$target.result;
|
160
|
+
|
161
|
+
if (!dataURL) {
|
162
|
+
reject(new Error('file parse error'));
|
163
|
+
}
|
164
|
+
|
165
|
+
resolve(dataURL);
|
166
|
+
};
|
167
|
+
|
168
|
+
reader.onerror = function () {
|
169
|
+
reject(new Error('file parse error'));
|
170
|
+
};
|
171
|
+
|
172
|
+
reader.readAsDataURL(file);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arco-design/mobile-react",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.31.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "esm/index.js",
|
@@ -15,7 +15,7 @@
|
|
15
15
|
"author": "taoyiyue@bytedance.com",
|
16
16
|
"license": "ISC",
|
17
17
|
"dependencies": {
|
18
|
-
"@arco-design/mobile-utils": "2.
|
18
|
+
"@arco-design/mobile-utils": "2.18.0",
|
19
19
|
"@arco-design/transformable": "^1.0.0",
|
20
20
|
"lodash.throttle": "^4.1.1",
|
21
21
|
"resize-observer-polyfill": "^1.5.1"
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "d531e333e595adbbfc5f78552d07f983a4978d0a"
|
53
53
|
}
|
@@ -1064,4 +1064,31 @@
|
|
1064
1064
|
--skeleton-grid-text-height: ~`pxtorem(16)`;
|
1065
1065
|
--skeleton-medium-gutter: ~`pxtorem(8)`;
|
1066
1066
|
--skeleton-large-gutter: ~`pxtorem(20)`;
|
1067
|
+
--uploader-item-height: ~`pxtorem(36)`;
|
1068
|
+
--uploader-item-margin-top: ~`pxtorem(16)`;
|
1069
|
+
--uploader-item-padding: 0 ~`pxtorem(12)`;
|
1070
|
+
--dark-uploader-item-background-color: var(--dark-card-background-color);
|
1071
|
+
--uploader-item-background-color: var(--card-background-color);
|
1072
|
+
--uploader-file-icon-font-size: ~`pxtorem(16)`;
|
1073
|
+
--uploader-file-icon-margin-right: ~`pxtorem(12)`;
|
1074
|
+
--dark-uploader-file-icon-color: var(--dark-sub-font-color);
|
1075
|
+
--uploader-file-icon-color: var(--sub-font-color);
|
1076
|
+
--uploader-item-text-font-size: ~`pxtorem(14)`;
|
1077
|
+
--uploader-item-border-radius: ~`pxtorem(2)`;
|
1078
|
+
--dark-uploader-item-text-color: var(--dark-font-color);
|
1079
|
+
--uploader-item-text-color: var(--font-color);
|
1080
|
+
--uploader-loaded-icon-font-size: ~`pxtorem(16)`;
|
1081
|
+
--dark-uploader-loaded-icon-color: var(--dark-success-color);
|
1082
|
+
--uploader-loaded-icon-color: var(--success-color);
|
1083
|
+
--uploader-error-text-font-size: ~`pxtorem(12)`;
|
1084
|
+
--dark-uploader-error-text-color: var(--dark-primary-color);
|
1085
|
+
--uploader-error-text-color: var(--primary-color);
|
1086
|
+
--uploader-delete-icon-font-size: ~`pxtorem(12)`;
|
1087
|
+
--uploader-delete-icon-padding-left: ~`pxtorem(12)`;
|
1088
|
+
--dark-uploader-delete-icon-color: var(--dark-sub-font-color);
|
1089
|
+
--uploader-delete-icon-color: var(--sub-font-color);
|
1090
|
+
--dark-uploader-disabled-delete-icon-color: var(--dark-disabled-color);
|
1091
|
+
--uploader-disabled-delete-icon-color: var(--disabled-color);
|
1092
|
+
--dark-uploader-item-text-error-color: var(--dark-danger-color);
|
1093
|
+
--uploader-item-text-error-color: var(--danger-color);
|
1067
1094
|
}
|
@@ -1063,6 +1063,33 @@ export interface ArcodesignToken extends Record<string, string> {
|
|
1063
1063
|
'skeleton-grid-text-height': string;
|
1064
1064
|
'skeleton-medium-gutter': string;
|
1065
1065
|
'skeleton-large-gutter': string;
|
1066
|
+
'uploader-item-height': string;
|
1067
|
+
'uploader-item-margin-top': string;
|
1068
|
+
'uploader-item-padding': string;
|
1069
|
+
'dark-uploader-item-background-color': string;
|
1070
|
+
'uploader-item-background-color': string;
|
1071
|
+
'uploader-file-icon-font-size': string;
|
1072
|
+
'uploader-file-icon-margin-right': string;
|
1073
|
+
'dark-uploader-file-icon-color': string;
|
1074
|
+
'uploader-file-icon-color': string;
|
1075
|
+
'uploader-item-text-font-size': string;
|
1076
|
+
'uploader-item-border-radius': string;
|
1077
|
+
'dark-uploader-item-text-color': string;
|
1078
|
+
'uploader-item-text-color': string;
|
1079
|
+
'uploader-loaded-icon-font-size': string;
|
1080
|
+
'dark-uploader-loaded-icon-color': string;
|
1081
|
+
'uploader-loaded-icon-color': string;
|
1082
|
+
'uploader-error-text-font-size': string;
|
1083
|
+
'dark-uploader-error-text-color': string;
|
1084
|
+
'uploader-error-text-color': string;
|
1085
|
+
'uploader-delete-icon-font-size': string;
|
1086
|
+
'uploader-delete-icon-padding-left': string;
|
1087
|
+
'dark-uploader-delete-icon-color': string;
|
1088
|
+
'uploader-delete-icon-color': string;
|
1089
|
+
'dark-uploader-disabled-delete-icon-color': string;
|
1090
|
+
'uploader-disabled-delete-icon-color': string;
|
1091
|
+
'dark-uploader-item-text-error-color': string;
|
1092
|
+
'uploader-item-text-error-color': string;
|
1066
1093
|
}
|
1067
1094
|
declare const tokens: ArcodesignToken;
|
1068
1095
|
export default tokens;
|