@aura-react-comp/ui 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +67 -2
- package/esm/alert/index.d.ts +28 -0
- package/esm/alert/index.js +76 -0
- package/esm/alert/index.less +172 -0
- package/esm/avatar/index.d.ts +41 -0
- package/esm/avatar/index.js +117 -0
- package/esm/avatar/index.less +162 -0
- package/esm/badge/index.d.ts +29 -0
- package/esm/badge/index.js +84 -0
- package/esm/badge/index.less +215 -0
- package/esm/breadcrumb/index.d.ts +31 -0
- package/esm/breadcrumb/index.js +91 -0
- package/esm/breadcrumb/index.less +108 -0
- package/esm/button/index.d.ts +28 -0
- package/esm/button/index.js +59 -0
- package/esm/button/index.less +191 -0
- package/esm/card/index.d.ts +67 -0
- package/esm/card/index.js +156 -0
- package/esm/card/index.less +231 -0
- package/esm/checkbox/index.d.ts +35 -0
- package/esm/checkbox/index.js +118 -0
- package/esm/checkbox/index.less +141 -0
- package/esm/collapse/index.d.ts +45 -0
- package/esm/collapse/index.js +157 -0
- package/esm/collapse/index.less +144 -0
- package/esm/divider/index.d.ts +16 -0
- package/esm/divider/index.js +37 -0
- package/esm/divider/index.less +115 -0
- package/esm/dropdown/index.d.ts +38 -0
- package/esm/dropdown/index.js +108 -0
- package/esm/dropdown/index.less +245 -0
- package/esm/empty/index.d.ts +35 -0
- package/esm/empty/index.js +87 -0
- package/esm/empty/index.less +67 -0
- package/esm/flex/index.d.ts +24 -0
- package/esm/flex/index.js +64 -0
- package/esm/flex/index.less +9 -0
- package/esm/form/index.d.ts +121 -0
- package/esm/form/index.js +443 -0
- package/esm/form/index.less +257 -0
- package/esm/global.d.ts +6 -0
- package/esm/index.d.ts +78 -0
- package/esm/index.js +41 -0
- package/esm/input/index.d.ts +51 -0
- package/esm/input/index.js +217 -0
- package/esm/input/index.less +369 -0
- package/esm/layout/index.d.ts +46 -0
- package/esm/layout/index.js +135 -0
- package/esm/layout/index.less +132 -0
- package/esm/menu/index.d.ts +91 -0
- package/esm/menu/index.js +294 -0
- package/esm/menu/index.less +340 -0
- package/esm/message/index.d.ts +33 -0
- package/esm/message/index.js +199 -0
- package/esm/message/index.less +113 -0
- package/esm/notification/index.d.ts +33 -0
- package/esm/notification/index.js +229 -0
- package/esm/notification/index.less +175 -0
- package/esm/pagination/index.d.ts +38 -0
- package/esm/pagination/index.js +180 -0
- package/esm/pagination/index.less +238 -0
- package/esm/popconfirm/index.d.ts +37 -0
- package/esm/popconfirm/index.js +115 -0
- package/esm/popconfirm/index.less +229 -0
- package/esm/radio/index.d.ts +33 -0
- package/esm/radio/index.js +122 -0
- package/esm/radio/index.less +119 -0
- package/esm/rate/index.d.ts +30 -0
- package/esm/rate/index.js +143 -0
- package/esm/rate/index.less +87 -0
- package/esm/result/index.d.ts +19 -0
- package/esm/result/index.js +69 -0
- package/esm/result/index.less +103 -0
- package/esm/scrollbar/index.d.ts +18 -0
- package/esm/scrollbar/index.js +35 -0
- package/esm/scrollbar/index.less +67 -0
- package/esm/select/index.d.ts +63 -0
- package/esm/select/index.js +358 -0
- package/esm/select/index.less +427 -0
- package/esm/slider/index.d.ts +36 -0
- package/esm/slider/index.js +255 -0
- package/esm/slider/index.less +154 -0
- package/esm/space/index.d.ts +16 -0
- package/esm/space/index.js +34 -0
- package/esm/space/index.less +34 -0
- package/esm/spin/index.d.ts +44 -0
- package/esm/spin/index.js +152 -0
- package/esm/spin/index.less +170 -0
- package/esm/steps/index.d.ts +55 -0
- package/esm/steps/index.js +165 -0
- package/esm/steps/index.less +394 -0
- package/esm/switch/index.d.ts +30 -0
- package/esm/switch/index.js +56 -0
- package/esm/switch/index.less +135 -0
- package/esm/tabs/index.d.ts +45 -0
- package/esm/tabs/index.js +170 -0
- package/esm/tabs/index.less +226 -0
- package/esm/tag/index.d.ts +52 -0
- package/esm/tag/index.js +120 -0
- package/esm/tag/index.less +227 -0
- package/esm/textarea/index.d.ts +27 -0
- package/esm/textarea/index.js +84 -0
- package/esm/textarea/index.less +224 -0
- package/esm/theme/ThemeProvider.d.ts +15 -0
- package/esm/theme/ThemeProvider.js +32 -0
- package/esm/theme/index.d.ts +2 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/tokens.css +183 -0
- package/esm/theme/useTheme.d.ts +1 -0
- package/esm/theme/useTheme.js +1 -0
- package/esm/tooltip/index.d.ts +38 -0
- package/esm/tooltip/index.js +149 -0
- package/esm/tooltip/index.less +244 -0
- package/esm/typography/index.d.ts +26 -0
- package/esm/typography/index.js +92 -0
- package/esm/typography/index.less +106 -0
- package/esm/upload/index.d.ts +68 -0
- package/esm/upload/index.js +447 -0
- package/esm/upload/index.less +371 -0
- package/esm/upload/request.d.ts +26 -0
- package/esm/upload/request.js +38 -0
- package/package.json +56 -3
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
.aura-upload {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--aura-spacing-2);
|
|
5
|
+
|
|
6
|
+
/* ===== 隐藏原生 input ===== */
|
|
7
|
+
&-input {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/* ===== 触发按钮 ===== */
|
|
12
|
+
&-trigger {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--aura-spacing-2);
|
|
16
|
+
padding: var(--aura-spacing-2) var(--aura-spacing-4);
|
|
17
|
+
font-size: var(--aura-font-size-sm);
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
color: var(--aura-text);
|
|
21
|
+
background: var(--aura-bg);
|
|
22
|
+
border: 1px solid var(--aura-border);
|
|
23
|
+
border-radius: var(--aura-radius-md);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
transition: all var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
26
|
+
user-select: none;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
color: var(--aura-primary-700);
|
|
30
|
+
border-color: var(--aura-primary-700);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:active {
|
|
34
|
+
transform: scale(0.97);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* ===== 禁用状态 ===== */
|
|
39
|
+
&&-disabled {
|
|
40
|
+
.aura-upload-trigger {
|
|
41
|
+
color: var(--aura-text-tertiary);
|
|
42
|
+
border-color: var(--aura-border);
|
|
43
|
+
background: var(--aura-bg-secondary);
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
color: var(--aura-text-tertiary);
|
|
48
|
+
border-color: var(--aura-border);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:active {
|
|
52
|
+
transform: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ===== 文件列表 ===== */
|
|
58
|
+
&-list {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
gap: var(--aura-spacing-1);
|
|
62
|
+
margin-top: var(--aura-spacing-2);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* ===== 文件列表项 ===== */
|
|
66
|
+
&-file {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: var(--aura-spacing-2);
|
|
70
|
+
padding: var(--aura-spacing-2) var(--aura-spacing-3);
|
|
71
|
+
background: var(--aura-bg-secondary);
|
|
72
|
+
border-radius: var(--aura-radius-sm);
|
|
73
|
+
font-size: var(--aura-font-size-sm);
|
|
74
|
+
color: var(--aura-text);
|
|
75
|
+
transition: all var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
76
|
+
animation: aura-upload-fade-in var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
77
|
+
|
|
78
|
+
&:hover {
|
|
79
|
+
background: var(--aura-bg-tertiary);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* 缩略图 */
|
|
83
|
+
&-thumbnail {
|
|
84
|
+
width: 40px;
|
|
85
|
+
height: 40px;
|
|
86
|
+
border-radius: var(--aura-radius-sm);
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
background: var(--aura-bg-tertiary);
|
|
92
|
+
flex-shrink: 0;
|
|
93
|
+
color: var(--aura-text-tertiary);
|
|
94
|
+
|
|
95
|
+
img {
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
object-fit: cover;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* 文件信息 */
|
|
103
|
+
&-info {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: var(--aura-spacing-2);
|
|
107
|
+
flex: 1;
|
|
108
|
+
min-width: 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* 文件名 */
|
|
112
|
+
&-name {
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
text-overflow: ellipsis;
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
flex: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* 状态图标 */
|
|
120
|
+
&-uploading .aura-upload-status-icon {
|
|
121
|
+
animation: aura-upload-spin 1s linear infinite;
|
|
122
|
+
color: var(--aura-primary-700);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&-done {
|
|
126
|
+
/* 完成状态 */
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&-error {
|
|
130
|
+
.aura-upload-file-name {
|
|
131
|
+
color: var(--aura-error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ===== 状态图标 ===== */
|
|
137
|
+
&-status-icon {
|
|
138
|
+
flex-shrink: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&-status-done {
|
|
142
|
+
color: var(--aura-success);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&-status-error {
|
|
146
|
+
color: var(--aura-error);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* ===== 删除按钮 ===== */
|
|
150
|
+
&-file-remove {
|
|
151
|
+
display: inline-flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: center;
|
|
154
|
+
flex-shrink: 0;
|
|
155
|
+
padding: 2px;
|
|
156
|
+
border: none;
|
|
157
|
+
background: transparent;
|
|
158
|
+
color: var(--aura-text-tertiary);
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
border-radius: var(--aura-radius-sm);
|
|
161
|
+
transition: all var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
162
|
+
opacity: 0;
|
|
163
|
+
|
|
164
|
+
&:hover {
|
|
165
|
+
color: var(--aura-error);
|
|
166
|
+
transform: scale(1.15);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&:active {
|
|
170
|
+
transform: scale(0.9);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&-file:hover .aura-upload-file-remove {
|
|
175
|
+
opacity: 1;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* ===== picture-card 卡片模式 ===== */
|
|
179
|
+
&&-picture-card {
|
|
180
|
+
.aura-upload-list {
|
|
181
|
+
display: flex;
|
|
182
|
+
flex-wrap: wrap;
|
|
183
|
+
gap: var(--aura-spacing-2);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.aura-upload-file {
|
|
187
|
+
width: 104px;
|
|
188
|
+
height: 104px;
|
|
189
|
+
flex-direction: column;
|
|
190
|
+
padding: var(--aura-spacing-1);
|
|
191
|
+
border: 1px solid var(--aura-border);
|
|
192
|
+
border-radius: var(--aura-radius-md);
|
|
193
|
+
position: relative;
|
|
194
|
+
background: var(--bg);
|
|
195
|
+
justify-content: center;
|
|
196
|
+
|
|
197
|
+
.aura-upload-file-thumbnail {
|
|
198
|
+
width: 100%;
|
|
199
|
+
height: 100%;
|
|
200
|
+
border-radius: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.aura-upload-file-info {
|
|
204
|
+
display: none;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.aura-upload-file-remove {
|
|
208
|
+
position: absolute;
|
|
209
|
+
top: 4px;
|
|
210
|
+
right: 4px;
|
|
211
|
+
opacity: 1;
|
|
212
|
+
background: rgba(0, 0, 0, 0.5);
|
|
213
|
+
color: #fff;
|
|
214
|
+
border-radius: var(--aura-radius-full);
|
|
215
|
+
width: 20px;
|
|
216
|
+
height: 20px;
|
|
217
|
+
|
|
218
|
+
&:hover {
|
|
219
|
+
background: var(--aura-error);
|
|
220
|
+
color: #fff;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.aura-upload-trigger {
|
|
226
|
+
width: 104px;
|
|
227
|
+
height: 104px;
|
|
228
|
+
flex-direction: column;
|
|
229
|
+
justify-content: center;
|
|
230
|
+
border-style: dashed;
|
|
231
|
+
background: transparent;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* ===== Dragger 拖拽区域 ===== */
|
|
236
|
+
&-dragger {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: var(--aura-spacing-3);
|
|
240
|
+
|
|
241
|
+
&-area {
|
|
242
|
+
display: flex;
|
|
243
|
+
flex-direction: column;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: center;
|
|
246
|
+
gap: var(--aura-spacing-2);
|
|
247
|
+
padding: var(--aura-spacing-8) var(--aura-spacing-4);
|
|
248
|
+
border: 2px dashed var(--aura-border);
|
|
249
|
+
border-radius: var(--aura-radius-lg);
|
|
250
|
+
background: var(--aura-bg-secondary);
|
|
251
|
+
cursor: pointer;
|
|
252
|
+
transition: all var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
253
|
+
|
|
254
|
+
&:hover {
|
|
255
|
+
border-color: var(--aura-primary-700);
|
|
256
|
+
background: var(--aura-primary-50);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&-hover {
|
|
261
|
+
.aura-upload-dragger-area {
|
|
262
|
+
border-color: var(--aura-primary-700);
|
|
263
|
+
background: var(--aura-primary-50);
|
|
264
|
+
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&-disabled {
|
|
269
|
+
.aura-upload-dragger-area {
|
|
270
|
+
cursor: not-allowed;
|
|
271
|
+
border-color: var(--aura-border);
|
|
272
|
+
background: var(--aura-bg-tertiary);
|
|
273
|
+
color: var(--aura-text-tertiary);
|
|
274
|
+
|
|
275
|
+
&:hover {
|
|
276
|
+
border-color: var(--aura-border);
|
|
277
|
+
background: var(--aura-bg-tertiary);
|
|
278
|
+
box-shadow: none;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&-icon {
|
|
284
|
+
color: var(--aura-text-tertiary);
|
|
285
|
+
transition: color var(--aura-duration-normal) cubic-bezier(0.4, 0, 0.2, 1);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
&-text {
|
|
289
|
+
font-size: var(--aura-font-size-md);
|
|
290
|
+
color: var(--aura-text);
|
|
291
|
+
margin: 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
&-hint {
|
|
295
|
+
font-size: var(--aura-font-size-xs);
|
|
296
|
+
color: var(--aura-text-tertiary);
|
|
297
|
+
margin: 0;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* ===== hover 时 Dragger 图标变色 ===== */
|
|
302
|
+
&-dragger-area:hover &-dragger-icon,
|
|
303
|
+
&-dragger-hover &-drgger-icon {
|
|
304
|
+
color: var(--aura-primary-700);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* ===== 动画关键帧 ===== */
|
|
309
|
+
@keyframes aura-upload-spin {
|
|
310
|
+
from { transform: rotate(0deg); }
|
|
311
|
+
to { transform: rotate(360deg); }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@keyframes aura-upload-fade-in {
|
|
315
|
+
from {
|
|
316
|
+
opacity: 0;
|
|
317
|
+
transform: translateY(4px);
|
|
318
|
+
}
|
|
319
|
+
to {
|
|
320
|
+
opacity: 1;
|
|
321
|
+
transform: translateY(0);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* ===== 暗色模式 ===== */
|
|
326
|
+
[data-theme="dark"] {
|
|
327
|
+
.aura-upload {
|
|
328
|
+
&-trigger {
|
|
329
|
+
background: var(--aura-bg-secondary);
|
|
330
|
+
border-color: var(--aura-border);
|
|
331
|
+
|
|
332
|
+
&:hover {
|
|
333
|
+
color: var(--aura-primary-400);
|
|
334
|
+
border-color: var(--aura-primary-400);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
&&-picture-card {
|
|
339
|
+
.aura-upload-file {
|
|
340
|
+
border-color: var(--aura-border);
|
|
341
|
+
background: var(--aura-bg-secondary);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
&-drgger-area {
|
|
346
|
+
background: var(--aura-bg-secondary);
|
|
347
|
+
border-color: var(--aura-border);
|
|
348
|
+
|
|
349
|
+
&:hover {
|
|
350
|
+
border-color: var(--aura-primary-400);
|
|
351
|
+
background: var(--aura-bg-tertiary);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
&-dragger-hover {
|
|
356
|
+
.aura-upload-dragger-area {
|
|
357
|
+
border-color: var(--aura-primary-400);
|
|
358
|
+
background: var(--aura-bg-tertiary);
|
|
359
|
+
box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
&-file {
|
|
364
|
+
background: var(--aura-bg-secondary);
|
|
365
|
+
|
|
366
|
+
&:hover {
|
|
367
|
+
background: var(--aura-bg-tertiary);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload 的真实上传请求,与组件渲染解耦以便单独 mock / 单测。
|
|
3
|
+
*/
|
|
4
|
+
export interface UploadRequestOptions {
|
|
5
|
+
/** 待上传的文件对象 */
|
|
6
|
+
file: File;
|
|
7
|
+
/** 上传接口地址 */
|
|
8
|
+
action: string;
|
|
9
|
+
/** 附加请求头 */
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
/** 文件字段名
|
|
12
|
+
* @default 'file'
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/** 随文件一同提交的额外表单字段 */
|
|
16
|
+
data?: Record<string, string | Blob>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 以 XHR 把文件 POST 到 `action`。
|
|
20
|
+
*
|
|
21
|
+
* - 响应处于 2xx 区间视为成功(resolve)
|
|
22
|
+
* - 其余状态码或网络错误视为失败(reject)
|
|
23
|
+
*
|
|
24
|
+
* 返回原始 XHR 便于调用方读取响应体。
|
|
25
|
+
*/
|
|
26
|
+
export declare function requestUpload(options: UploadRequestOptions): Promise<XMLHttpRequest>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload 的真实上传请求,与组件渲染解耦以便单独 mock / 单测。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 以 XHR 把文件 POST 到 `action`。
|
|
7
|
+
*
|
|
8
|
+
* - 响应处于 2xx 区间视为成功(resolve)
|
|
9
|
+
* - 其余状态码或网络错误视为失败(reject)
|
|
10
|
+
*
|
|
11
|
+
* 返回原始 XHR 便于调用方读取响应体。
|
|
12
|
+
*/
|
|
13
|
+
export function requestUpload(options) {
|
|
14
|
+
const {
|
|
15
|
+
file,
|
|
16
|
+
action,
|
|
17
|
+
headers,
|
|
18
|
+
name = 'file',
|
|
19
|
+
data
|
|
20
|
+
} = options;
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const xhr = new XMLHttpRequest();
|
|
23
|
+
const formData = new FormData();
|
|
24
|
+
formData.append(name, file, file.name);
|
|
25
|
+
if (data) {
|
|
26
|
+
Object.entries(data).forEach(([key, value]) => formData.append(key, value));
|
|
27
|
+
}
|
|
28
|
+
xhr.open('POST', action);
|
|
29
|
+
if (headers) {
|
|
30
|
+
Object.entries(headers).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
31
|
+
}
|
|
32
|
+
xhr.onload = () => {
|
|
33
|
+
if (xhr.status >= 200 && xhr.status < 300) resolve(xhr);else reject(xhr);
|
|
34
|
+
};
|
|
35
|
+
xhr.onerror = () => reject(xhr);
|
|
36
|
+
xhr.send(formData);
|
|
37
|
+
});
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aura-react-comp/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Aura 组件库",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"aura",
|
|
7
|
+
"react",
|
|
8
|
+
"ui",
|
|
9
|
+
"component-library",
|
|
10
|
+
"design-system"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://asbeforelandy.github.io/aura/",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/AsBeforeLandy/aura/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/AsBeforeLandy/aura.git",
|
|
19
|
+
"directory": "packages/ui"
|
|
20
|
+
},
|
|
21
|
+
"author": "Aura Team",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "esm/index.js",
|
|
25
|
+
"module": "esm/index.js",
|
|
26
|
+
"types": "esm/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"esm"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"**/*.less",
|
|
32
|
+
"**/*.css"
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./esm/index.d.ts",
|
|
37
|
+
"import": "./esm/index.js",
|
|
38
|
+
"default": "./esm/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./style.css": "./esm/theme/tokens.css",
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react": ">=18.0.0",
|
|
45
|
+
"react-dom": ">=18.0.0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@aura-react-comp/icons": "0.1.0",
|
|
49
|
+
"@aura-react-comp/shared": "0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"registry": "https://registry.npmjs.org/"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "father build",
|
|
57
|
+
"dev": "father dev"
|
|
58
|
+
}
|
|
6
59
|
}
|