@uzum-tech/ui 2.3.1 → 2.3.2
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/dist/index.js +373 -340
- package/dist/index.mjs +373 -340
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +2 -2
- package/es/components.d.ts +10 -7
- package/es/image/src/ImagePreview.d.ts +1 -0
- package/es/image/src/ImagePreview.mjs +7 -35
- package/es/image/src/public-types.d.ts +4 -4
- package/es/message-bubble/src/MessageBubble.mjs +10 -3
- package/es/upload/index.d.ts +2 -1
- package/es/upload/index.mjs +2 -1
- package/es/upload/src/Upload.d.ts +73 -1007
- package/es/upload/src/Upload.mjs +43 -124
- package/es/upload/src/UploadFile.d.ts +1 -1
- package/es/upload/src/UploadFile.mjs +8 -2
- package/es/upload/src/UploadFileList.mjs +17 -2
- package/es/upload/src/UploadProgress.d.ts +3 -2
- package/es/upload/src/interface.d.ts +1086 -92
- package/es/upload/src/interface.mjs +117 -1
- package/es/upload/src/public-types.d.ts +17 -2
- package/es/upload/src/useUploadActionsRender.d.ts +2 -27
- package/es/upload/src/useUploadActionsRender.mjs +2 -2
- package/es/upload/src/useUploadInternals.d.ts +2 -25
- package/es/upload/src/utils.d.ts +2 -0
- package/es/upload/src/utils.mjs +7 -0
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/components.d.ts +10 -7
- package/lib/image/src/ImagePreview.d.ts +1 -0
- package/lib/image/src/ImagePreview.js +3 -19
- package/lib/image/src/public-types.d.ts +4 -4
- package/lib/message-bubble/src/MessageBubble.js +10 -4
- package/lib/upload/index.d.ts +2 -1
- package/lib/upload/index.js +2 -1
- package/lib/upload/src/Upload.d.ts +73 -1007
- package/lib/upload/src/Upload.js +40 -68
- package/lib/upload/src/UploadFile.d.ts +1 -1
- package/lib/upload/src/UploadFile.js +12 -4
- package/lib/upload/src/UploadFileList.js +8 -1
- package/lib/upload/src/UploadProgress.d.ts +3 -2
- package/lib/upload/src/interface.d.ts +1086 -92
- package/lib/upload/src/interface.js +59 -1
- package/lib/upload/src/public-types.d.ts +17 -2
- package/lib/upload/src/useUploadActionsRender.d.ts +2 -27
- package/lib/upload/src/useUploadActionsRender.js +2 -2
- package/lib/upload/src/useUploadInternals.d.ts +2 -25
- package/lib/upload/src/utils.d.ts +2 -0
- package/lib/upload/src/utils.js +10 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/web-types.json +104 -23
package/es/upload/src/Upload.mjs
CHANGED
|
@@ -30,128 +30,14 @@ import { computed, defineComponent, Fragment, h, nextTick, provide, ref, Telepor
|
|
|
30
30
|
import { useConfig, useFormItem, useLocale, useTheme, useThemeClass } from "../../_mixins/index.mjs";
|
|
31
31
|
import { call, createKey, throwError, warn } from "../../_utils/index.mjs";
|
|
32
32
|
import { uploadLight } from "../styles/index.mjs";
|
|
33
|
-
import { uploadInjectionKey } from "./interface.mjs";
|
|
33
|
+
import { uploadInjectionKey, uploadProps } from "./interface.mjs";
|
|
34
34
|
import style from "./styles/index.cssr.mjs";
|
|
35
35
|
import { uploadDraggerKey } from "./UploadDragger.mjs";
|
|
36
36
|
import UUploadFileList from "./UploadFileList.mjs";
|
|
37
37
|
import UUploadTrigger from "./UploadTrigger.mjs";
|
|
38
38
|
import { useUpload } from "./useUpload.mjs";
|
|
39
39
|
import { useUploadInternals } from "./useUploadInternals.mjs";
|
|
40
|
-
import { createImageDataUrl, createSettledFileInfo,
|
|
41
|
-
export const uploadProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
42
|
-
name: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'file'
|
|
45
|
-
},
|
|
46
|
-
accept: String,
|
|
47
|
-
action: String,
|
|
48
|
-
customRequest: Function,
|
|
49
|
-
directory: Boolean,
|
|
50
|
-
directoryDnd: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: undefined
|
|
53
|
-
},
|
|
54
|
-
method: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: 'POST'
|
|
57
|
-
},
|
|
58
|
-
multiple: Boolean,
|
|
59
|
-
showFileList: {
|
|
60
|
-
type: Boolean,
|
|
61
|
-
default: true
|
|
62
|
-
},
|
|
63
|
-
data: [Object, Function],
|
|
64
|
-
headers: [Object, Function],
|
|
65
|
-
withCredentials: Boolean,
|
|
66
|
-
responseType: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: ''
|
|
69
|
-
},
|
|
70
|
-
disabled: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: undefined
|
|
73
|
-
},
|
|
74
|
-
vertical: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
default: false
|
|
77
|
-
},
|
|
78
|
-
icon: Object,
|
|
79
|
-
onChange: Function,
|
|
80
|
-
onRemove: Function,
|
|
81
|
-
onFinish: Function,
|
|
82
|
-
onError: Function,
|
|
83
|
-
onRetry: Function,
|
|
84
|
-
onBeforeUpload: Function,
|
|
85
|
-
isErrorState: Function,
|
|
86
|
-
/** currently not used */
|
|
87
|
-
onDownload: Function,
|
|
88
|
-
defaultUpload: {
|
|
89
|
-
type: Boolean,
|
|
90
|
-
default: true
|
|
91
|
-
},
|
|
92
|
-
fileList: Array,
|
|
93
|
-
'onUpdate:fileList': [Function, Array],
|
|
94
|
-
onUpdateFileList: [Function, Array],
|
|
95
|
-
fileListClass: String,
|
|
96
|
-
fileListStyle: [String, Object],
|
|
97
|
-
defaultFileList: {
|
|
98
|
-
type: Array,
|
|
99
|
-
default: () => []
|
|
100
|
-
},
|
|
101
|
-
showCancelButton: {
|
|
102
|
-
type: Boolean,
|
|
103
|
-
default: true
|
|
104
|
-
},
|
|
105
|
-
showRemoveButton: {
|
|
106
|
-
type: Boolean,
|
|
107
|
-
default: true
|
|
108
|
-
},
|
|
109
|
-
showDownloadButton: Boolean,
|
|
110
|
-
showRetryButton: {
|
|
111
|
-
type: Boolean,
|
|
112
|
-
default: true
|
|
113
|
-
},
|
|
114
|
-
customDownload: Function,
|
|
115
|
-
showPreviewButton: {
|
|
116
|
-
type: Boolean,
|
|
117
|
-
default: true
|
|
118
|
-
},
|
|
119
|
-
listType: {
|
|
120
|
-
type: String,
|
|
121
|
-
default: 'text'
|
|
122
|
-
},
|
|
123
|
-
onPreview: Function,
|
|
124
|
-
shouldUseThumbnailUrl: {
|
|
125
|
-
type: Function,
|
|
126
|
-
default: file => {
|
|
127
|
-
if (!environmentSupportFile) return false;
|
|
128
|
-
return isImageFile(file);
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
createThumbnailUrl: Function,
|
|
132
|
-
abstract: Boolean,
|
|
133
|
-
max: Number,
|
|
134
|
-
showTrigger: {
|
|
135
|
-
type: Boolean,
|
|
136
|
-
default: true
|
|
137
|
-
},
|
|
138
|
-
imageGroupProps: Object,
|
|
139
|
-
inputProps: Object,
|
|
140
|
-
triggerClass: String,
|
|
141
|
-
triggerStyle: [String, Object],
|
|
142
|
-
renderIcon: Function,
|
|
143
|
-
label: String,
|
|
144
|
-
size: {
|
|
145
|
-
type: String,
|
|
146
|
-
default: 'medium'
|
|
147
|
-
},
|
|
148
|
-
title: String,
|
|
149
|
-
subtitle: String,
|
|
150
|
-
noIcon: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: false
|
|
153
|
-
}
|
|
154
|
-
});
|
|
40
|
+
import { createImageDataUrl, createSettledFileInfo, getFilePreviewSrc, isFileSizeExceeded, matchType } from "./utils.mjs";
|
|
155
41
|
export default defineComponent({
|
|
156
42
|
name: 'Upload',
|
|
157
43
|
props: uploadProps,
|
|
@@ -197,14 +83,13 @@ export default defineComponent({
|
|
|
197
83
|
var _a;
|
|
198
84
|
(_a = inputElRef.value) === null || _a === void 0 ? void 0 : _a.click();
|
|
199
85
|
}
|
|
200
|
-
function handleFileInputChange(
|
|
201
|
-
const target =
|
|
86
|
+
function handleFileInputChange(event) {
|
|
87
|
+
const target = event.target;
|
|
202
88
|
handleFileAddition(target.files ? Array.from(target.files).map(file => ({
|
|
203
89
|
file,
|
|
204
90
|
entry: null,
|
|
205
91
|
source: 'input'
|
|
206
|
-
})) : null,
|
|
207
|
-
// May have bug! set to null?
|
|
92
|
+
})) : null, event);
|
|
208
93
|
target.value = '';
|
|
209
94
|
}
|
|
210
95
|
function doUpdateFileList(files) {
|
|
@@ -222,7 +107,7 @@ export default defineComponent({
|
|
|
222
107
|
uploadKeyIndexRef.value += 1;
|
|
223
108
|
return key;
|
|
224
109
|
}
|
|
225
|
-
function handleFileAddition(fileAndEntries,
|
|
110
|
+
function handleFileAddition(fileAndEntries, event) {
|
|
226
111
|
if (!fileAndEntries || fileAndEntries.length === 0) return;
|
|
227
112
|
const {
|
|
228
113
|
onBeforeUpload
|
|
@@ -230,7 +115,8 @@ export default defineComponent({
|
|
|
230
115
|
fileAndEntries = mergedMultipleRef.value ? fileAndEntries : [fileAndEntries[0]];
|
|
231
116
|
const {
|
|
232
117
|
max,
|
|
233
|
-
accept
|
|
118
|
+
accept,
|
|
119
|
+
maxSize
|
|
234
120
|
} = props;
|
|
235
121
|
fileAndEntries = fileAndEntries.filter(({
|
|
236
122
|
file,
|
|
@@ -263,6 +149,10 @@ export default defineComponent({
|
|
|
263
149
|
thumbnailUrl: null,
|
|
264
150
|
fullPath: (_b = entry === null || entry === void 0 ? void 0 : entry.fullPath) !== null && _b !== void 0 ? _b : `/${file.webkitRelativePath || file.name}`
|
|
265
151
|
};
|
|
152
|
+
if (isFileSizeExceeded(file, maxSize)) {
|
|
153
|
+
fileInfo.status = 'error';
|
|
154
|
+
return fileInfo;
|
|
155
|
+
}
|
|
266
156
|
if (!onBeforeUpload || (yield onBeforeUpload({
|
|
267
157
|
file: fileInfo,
|
|
268
158
|
fileList: mergedFileListRef.value
|
|
@@ -274,7 +164,7 @@ export default defineComponent({
|
|
|
274
164
|
let nextTickChain = Promise.resolve();
|
|
275
165
|
fileInfos.forEach(fileInfo => {
|
|
276
166
|
nextTickChain = nextTickChain.then(nextTick).then(() => {
|
|
277
|
-
fileInfo && doChange(fileInfo,
|
|
167
|
+
fileInfo && doChange(fileInfo, event, {
|
|
278
168
|
append: true
|
|
279
169
|
});
|
|
280
170
|
});
|
|
@@ -303,6 +193,15 @@ export default defineComponent({
|
|
|
303
193
|
status
|
|
304
194
|
} = file;
|
|
305
195
|
if (status === 'pending' || status === 'error' && shouldReupload) {
|
|
196
|
+
if (isFileSizeExceeded(file.file, props.maxSize)) {
|
|
197
|
+
if (status === 'pending') {
|
|
198
|
+
const fileAfterChange = Object.assign({}, file, {
|
|
199
|
+
status: 'error'
|
|
200
|
+
});
|
|
201
|
+
doChange(fileAfterChange);
|
|
202
|
+
}
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
306
205
|
if (props.customRequest) {
|
|
307
206
|
customSubmitImpl({
|
|
308
207
|
inst: {
|
|
@@ -383,6 +282,21 @@ export default defineComponent({
|
|
|
383
282
|
}
|
|
384
283
|
return '';
|
|
385
284
|
}
|
|
285
|
+
function isFilePreviewable(file) {
|
|
286
|
+
return props.shouldUseThumbnailUrl(file) && getFilePreviewSrc(file) !== null;
|
|
287
|
+
}
|
|
288
|
+
const previewFileListRef = computed(() => mergedFileListRef.value.filter(isFilePreviewable));
|
|
289
|
+
const previewSrcListRef = computed(() => previewFileListRef.value.map(file => getFilePreviewSrc(file)));
|
|
290
|
+
const previewShowRef = ref(false);
|
|
291
|
+
const previewCurrentRef = ref(0);
|
|
292
|
+
function openFilePreview(file) {
|
|
293
|
+
const index = previewFileListRef.value.findIndex(({
|
|
294
|
+
id
|
|
295
|
+
}) => id === file.id);
|
|
296
|
+
if (index < 0) return;
|
|
297
|
+
previewCurrentRef.value = index;
|
|
298
|
+
previewShowRef.value = true;
|
|
299
|
+
}
|
|
386
300
|
const cssVarsRef = computed(() => {
|
|
387
301
|
const {
|
|
388
302
|
value: size
|
|
@@ -504,7 +418,12 @@ export default defineComponent({
|
|
|
504
418
|
mergedDirectoryDndRef: computed(() => {
|
|
505
419
|
var _a;
|
|
506
420
|
return (_a = props.directoryDnd) !== null && _a !== void 0 ? _a : props.directory;
|
|
507
|
-
})
|
|
421
|
+
}),
|
|
422
|
+
previewSrcListRef,
|
|
423
|
+
previewShowRef,
|
|
424
|
+
previewCurrentRef,
|
|
425
|
+
isFilePreviewable,
|
|
426
|
+
openFilePreview
|
|
508
427
|
});
|
|
509
428
|
const exposedMethods = {
|
|
510
429
|
clear: () => {
|
|
@@ -601,7 +601,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
601
601
|
showRemoveButton: import("vue").ComputedRef<boolean>;
|
|
602
602
|
showDownloadButton: import("vue").ComputedRef<boolean>;
|
|
603
603
|
showRetryButton: import("vue").ComputedRef<boolean>;
|
|
604
|
-
showPreviewButton: import("vue").ComputedRef<boolean
|
|
604
|
+
showPreviewButton: import("vue").ComputedRef<boolean>;
|
|
605
605
|
mergedThumbnailUrl: import("vue").ComputedRef<string | null>;
|
|
606
606
|
shouldUseThumbnailUrl: import("vue").Ref<import("./interface").ShouldUseThumbnailUrl, import("./interface").ShouldUseThumbnailUrl>;
|
|
607
607
|
renderIcon: import("vue").Ref<import("./interface").RenderIcon | undefined, import("./interface").RenderIcon | undefined>;
|
|
@@ -117,7 +117,11 @@ export default defineComponent({
|
|
|
117
117
|
},
|
|
118
118
|
listType
|
|
119
119
|
} = props;
|
|
120
|
-
|
|
120
|
+
if (!['finished'].includes(status)) return false;
|
|
121
|
+
if (listType === 'preview-list') {
|
|
122
|
+
return UUpload.isFilePreviewable(props.file);
|
|
123
|
+
}
|
|
124
|
+
return !!mergedThumbnailUrlRef.value && listType === 'image-card';
|
|
121
125
|
});
|
|
122
126
|
function handleRetryClick() {
|
|
123
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -211,6 +215,8 @@ export default defineComponent({
|
|
|
211
215
|
} = UUpload;
|
|
212
216
|
if (onPreview) {
|
|
213
217
|
onPreview(props.file);
|
|
218
|
+
} else if (props.listType === 'preview-list') {
|
|
219
|
+
UUpload.openFilePreview(props.file);
|
|
214
220
|
} else if (props.listType === 'image-card') {
|
|
215
221
|
const {
|
|
216
222
|
value
|
|
@@ -295,7 +301,7 @@ export default defineComponent({
|
|
|
295
301
|
class: [!this.vertical && !imageCardTypes.includes(listType) && `${clsPrefix}-upload-file-loader--default`]
|
|
296
302
|
}, {
|
|
297
303
|
default: () => h("div", {
|
|
298
|
-
class: [`${clsPrefix}-upload-file`, `${clsPrefix}-upload-file--${this.progressStatus}-status`, file.url && file.status !== 'error' && imageCardTypes.includes(listType) && `${clsPrefix}-upload-file--with-url`, `${clsPrefix}-upload-file--${listType === 'image' || listType === 'image-card' ? 'image-card' : 'text'}-type`]
|
|
304
|
+
class: [`${clsPrefix}-upload-file`, `${clsPrefix}-upload-file--${this.progressStatus}-status`, file.url && file.status !== 'error' && imageCardTypes.includes(listType) && `${clsPrefix}-upload-file--with-url`, `${clsPrefix}-upload-file--${listType === 'image' || listType === 'image-card' ? 'image-card' : 'text'}-type`, listType === 'preview-list' && `${clsPrefix}-upload-file--preview-list-type`]
|
|
299
305
|
}, h("div", {
|
|
300
306
|
class: [`${clsPrefix}-upload-file-info`, imageCardTypes.includes(listType) && `${clsPrefix}-upload-file-info--vertical`]
|
|
301
307
|
}, icon, h("div", {
|
|
@@ -25,9 +25,13 @@ export default defineComponent({
|
|
|
25
25
|
themeClassRef,
|
|
26
26
|
maxReachedRef,
|
|
27
27
|
showTriggerRef,
|
|
28
|
-
imageGroupPropsRef
|
|
28
|
+
imageGroupPropsRef,
|
|
29
|
+
previewSrcListRef,
|
|
30
|
+
previewShowRef,
|
|
31
|
+
previewCurrentRef
|
|
29
32
|
} = UUpload;
|
|
30
33
|
const isImageCardTypeRef = computed(() => listTypeRef.value === 'image-card' || listTypeRef.value === 'image');
|
|
34
|
+
const isPreviewListTypeRef = computed(() => listTypeRef.value === 'preview-list');
|
|
31
35
|
const renderFileList = () => mergedFileListRef.value.map(file => h(UUploadFile, {
|
|
32
36
|
clsPrefix: mergedClsPrefixRef.value,
|
|
33
37
|
key: file.id,
|
|
@@ -41,6 +45,17 @@ export default defineComponent({
|
|
|
41
45
|
}, {
|
|
42
46
|
default: renderFileList
|
|
43
47
|
});
|
|
48
|
+
const renderPreview = () => h(UImageGroup, Object.assign({}, imageGroupPropsRef.value, {
|
|
49
|
+
srcList: previewSrcListRef.value,
|
|
50
|
+
show: previewShowRef.value,
|
|
51
|
+
current: previewCurrentRef.value,
|
|
52
|
+
onUpdateShow: show => {
|
|
53
|
+
previewShowRef.value = show;
|
|
54
|
+
},
|
|
55
|
+
onUpdateCurrent: current => {
|
|
56
|
+
previewCurrentRef.value = current;
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
44
59
|
return () => {
|
|
45
60
|
const {
|
|
46
61
|
value: mergedClsPrefix
|
|
@@ -51,7 +66,7 @@ export default defineComponent({
|
|
|
51
66
|
return h("div", {
|
|
52
67
|
class: [`${mergedClsPrefix}-upload-file-list`, isImageCardTypeRef.value && `${mergedClsPrefix}-upload-file-list--grid`, fileListClassRef.value, abstract ? themeClassRef === null || themeClassRef === void 0 ? void 0 : themeClassRef.value : undefined],
|
|
53
68
|
style: [abstract && cssVarsRef ? cssVarsRef.value : '', fileListStyleRef.value]
|
|
54
|
-
}, renderUploadFileList(), showTriggerRef.value && !maxReachedRef.value && isImageCardTypeRef.value && h(UUploadTrigger, null, slots));
|
|
69
|
+
}, renderUploadFileList(), isPreviewListTypeRef.value && renderPreview(), showTriggerRef.value && !maxReachedRef.value && isImageCardTypeRef.value && h(UUploadTrigger, null, slots));
|
|
55
70
|
};
|
|
56
71
|
}
|
|
57
72
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
+
import type { ProgressStatus } from './interface';
|
|
2
3
|
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
4
|
show: BooleanConstructor;
|
|
4
5
|
percentage: {
|
|
@@ -6,7 +7,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
6
7
|
required: true;
|
|
7
8
|
};
|
|
8
9
|
status: {
|
|
9
|
-
type: PropType<
|
|
10
|
+
type: PropType<ProgressStatus>;
|
|
10
11
|
required: true;
|
|
11
12
|
};
|
|
12
13
|
}>, {
|
|
@@ -594,7 +595,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
594
595
|
required: true;
|
|
595
596
|
};
|
|
596
597
|
status: {
|
|
597
|
-
type: PropType<
|
|
598
|
+
type: PropType<ProgressStatus>;
|
|
598
599
|
required: true;
|
|
599
600
|
};
|
|
600
601
|
}>> & Readonly<{}>, {
|