@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/lib/upload/src/Upload.js
CHANGED
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.uploadProps = void 0;
|
|
16
15
|
const vooks_1 = require("vooks");
|
|
17
16
|
const vue_1 = require("vue");
|
|
18
17
|
const _mixins_1 = require("../../_mixins");
|
|
@@ -26,67 +25,9 @@ const UploadTrigger_1 = __importDefault(require("./UploadTrigger"));
|
|
|
26
25
|
const useUpload_1 = require("./useUpload");
|
|
27
26
|
const useUploadInternals_1 = require("./useUploadInternals");
|
|
28
27
|
const utils_1 = require("./utils");
|
|
29
|
-
exports.uploadProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), { name: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: 'file'
|
|
32
|
-
}, accept: String, action: String, customRequest: Function, directory: Boolean, directoryDnd: { type: Boolean, default: undefined }, method: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: 'POST'
|
|
35
|
-
}, multiple: Boolean, showFileList: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: true
|
|
38
|
-
}, data: [Object, Function], headers: [Object, Function], withCredentials: Boolean, responseType: {
|
|
39
|
-
type: String,
|
|
40
|
-
default: ''
|
|
41
|
-
}, disabled: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
default: undefined
|
|
44
|
-
}, vertical: {
|
|
45
|
-
type: Boolean,
|
|
46
|
-
default: false
|
|
47
|
-
}, icon: Object, onChange: Function, onRemove: Function, onFinish: Function, onError: Function, onRetry: Function, onBeforeUpload: Function, isErrorState: Function,
|
|
48
|
-
/** currently not used */
|
|
49
|
-
onDownload: Function, defaultUpload: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
default: true
|
|
52
|
-
}, fileList: Array, 'onUpdate:fileList': [Function, Array], onUpdateFileList: [Function, Array], fileListClass: String, fileListStyle: [String, Object], defaultFileList: {
|
|
53
|
-
type: Array,
|
|
54
|
-
default: () => []
|
|
55
|
-
}, showCancelButton: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: true
|
|
58
|
-
}, showRemoveButton: {
|
|
59
|
-
type: Boolean,
|
|
60
|
-
default: true
|
|
61
|
-
}, showDownloadButton: Boolean, showRetryButton: {
|
|
62
|
-
type: Boolean,
|
|
63
|
-
default: true
|
|
64
|
-
}, customDownload: Function, showPreviewButton: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: true
|
|
67
|
-
}, listType: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: 'text'
|
|
70
|
-
}, onPreview: Function, shouldUseThumbnailUrl: {
|
|
71
|
-
type: Function,
|
|
72
|
-
default: (file) => {
|
|
73
|
-
if (!utils_1.environmentSupportFile)
|
|
74
|
-
return false;
|
|
75
|
-
return (0, utils_1.isImageFile)(file);
|
|
76
|
-
}
|
|
77
|
-
}, createThumbnailUrl: Function, abstract: Boolean, max: Number, showTrigger: {
|
|
78
|
-
type: Boolean,
|
|
79
|
-
default: true
|
|
80
|
-
}, imageGroupProps: Object, inputProps: Object, triggerClass: String, triggerStyle: [String, Object], renderIcon: Function, label: String, size: {
|
|
81
|
-
type: String,
|
|
82
|
-
default: 'medium'
|
|
83
|
-
}, title: String, subtitle: String, noIcon: {
|
|
84
|
-
type: Boolean,
|
|
85
|
-
default: false
|
|
86
|
-
} });
|
|
87
28
|
exports.default = (0, vue_1.defineComponent)({
|
|
88
29
|
name: 'Upload',
|
|
89
|
-
props:
|
|
30
|
+
props: interface_1.uploadProps,
|
|
90
31
|
setup(props) {
|
|
91
32
|
const uploadId = (0, vue_1.useId)();
|
|
92
33
|
const uploadKeyIndexRef = (0, vue_1.ref)(0);
|
|
@@ -119,16 +60,15 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
119
60
|
var _a;
|
|
120
61
|
(_a = inputElRef.value) === null || _a === void 0 ? void 0 : _a.click();
|
|
121
62
|
}
|
|
122
|
-
function handleFileInputChange(
|
|
123
|
-
const target =
|
|
63
|
+
function handleFileInputChange(event) {
|
|
64
|
+
const target = event.target;
|
|
124
65
|
handleFileAddition(target.files
|
|
125
66
|
? Array.from(target.files).map(file => ({
|
|
126
67
|
file,
|
|
127
68
|
entry: null,
|
|
128
69
|
source: 'input'
|
|
129
70
|
}))
|
|
130
|
-
: null,
|
|
131
|
-
// May have bug! set to null?
|
|
71
|
+
: null, event);
|
|
132
72
|
target.value = '';
|
|
133
73
|
}
|
|
134
74
|
function doUpdateFileList(files) {
|
|
@@ -145,14 +85,14 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
145
85
|
uploadKeyIndexRef.value += 1;
|
|
146
86
|
return key;
|
|
147
87
|
}
|
|
148
|
-
function handleFileAddition(fileAndEntries,
|
|
88
|
+
function handleFileAddition(fileAndEntries, event) {
|
|
149
89
|
if (!fileAndEntries || fileAndEntries.length === 0)
|
|
150
90
|
return;
|
|
151
91
|
const { onBeforeUpload } = props;
|
|
152
92
|
fileAndEntries = mergedMultipleRef.value
|
|
153
93
|
? fileAndEntries
|
|
154
94
|
: [fileAndEntries[0]];
|
|
155
|
-
const { max, accept } = props;
|
|
95
|
+
const { max, accept, maxSize } = props;
|
|
156
96
|
fileAndEntries = fileAndEntries.filter(({ file, source }) => {
|
|
157
97
|
if (source === 'dnd' && (accept === null || accept === void 0 ? void 0 : accept.trim())) {
|
|
158
98
|
return (0, utils_1.matchType)(file.name, file.type, accept);
|
|
@@ -179,6 +119,10 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
179
119
|
thumbnailUrl: null,
|
|
180
120
|
fullPath: (_b = entry === null || entry === void 0 ? void 0 : entry.fullPath) !== null && _b !== void 0 ? _b : `/${file.webkitRelativePath || file.name}`
|
|
181
121
|
};
|
|
122
|
+
if ((0, utils_1.isFileSizeExceeded)(file, maxSize)) {
|
|
123
|
+
fileInfo.status = 'error';
|
|
124
|
+
return fileInfo;
|
|
125
|
+
}
|
|
182
126
|
if (!onBeforeUpload
|
|
183
127
|
|| (yield onBeforeUpload({
|
|
184
128
|
file: fileInfo,
|
|
@@ -193,7 +137,7 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
193
137
|
fileInfos.forEach((fileInfo) => {
|
|
194
138
|
nextTickChain = nextTickChain.then(vue_1.nextTick).then(() => {
|
|
195
139
|
fileInfo
|
|
196
|
-
&& doChange(fileInfo,
|
|
140
|
+
&& doChange(fileInfo, event, {
|
|
197
141
|
append: true
|
|
198
142
|
});
|
|
199
143
|
});
|
|
@@ -216,6 +160,15 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
216
160
|
filesToUpload.forEach((file) => {
|
|
217
161
|
const { status } = file;
|
|
218
162
|
if (status === 'pending' || (status === 'error' && shouldReupload)) {
|
|
163
|
+
if ((0, utils_1.isFileSizeExceeded)(file.file, props.maxSize)) {
|
|
164
|
+
if (status === 'pending') {
|
|
165
|
+
const fileAfterChange = Object.assign({}, file, {
|
|
166
|
+
status: 'error'
|
|
167
|
+
});
|
|
168
|
+
doChange(fileAfterChange);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
219
172
|
if (props.customRequest) {
|
|
220
173
|
customSubmitImpl({
|
|
221
174
|
inst: {
|
|
@@ -295,6 +248,20 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
295
248
|
}
|
|
296
249
|
return '';
|
|
297
250
|
}
|
|
251
|
+
function isFilePreviewable(file) {
|
|
252
|
+
return (props.shouldUseThumbnailUrl(file) && (0, utils_1.getFilePreviewSrc)(file) !== null);
|
|
253
|
+
}
|
|
254
|
+
const previewFileListRef = (0, vue_1.computed)(() => mergedFileListRef.value.filter(isFilePreviewable));
|
|
255
|
+
const previewSrcListRef = (0, vue_1.computed)(() => previewFileListRef.value.map(file => (0, utils_1.getFilePreviewSrc)(file)));
|
|
256
|
+
const previewShowRef = (0, vue_1.ref)(false);
|
|
257
|
+
const previewCurrentRef = (0, vue_1.ref)(0);
|
|
258
|
+
function openFilePreview(file) {
|
|
259
|
+
const index = previewFileListRef.value.findIndex(({ id }) => id === file.id);
|
|
260
|
+
if (index < 0)
|
|
261
|
+
return;
|
|
262
|
+
previewCurrentRef.value = index;
|
|
263
|
+
previewShowRef.value = true;
|
|
264
|
+
}
|
|
298
265
|
const cssVarsRef = (0, vue_1.computed)(() => {
|
|
299
266
|
const { value: size } = formItem.mergedSizeRef;
|
|
300
267
|
const { common: { cubicBezierEaseInOut }, self: { draggerColor, draggerBorder, draggerBorderHover, draggerShadowFocus, itemColorHover, itemColorHoverError, itemTextColorError, itemTextColorSuccess, itemTextColor, itemIconColor, itemDisabledOpacity, lineHeight, borderRadius, fontSize, itemBorderImageCardError, itemBorderImageCard, baseColor, draggerIconBgColor, draggerIconColor, draggerTextColor, draggerTitleColor, labelColor, containerSecondary, brandPrimary300, elementsQuaternary, [(0, _utils_1.createKey)('width', size)]: width } } = themeRef.value;
|
|
@@ -382,7 +349,12 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
382
349
|
mergedDirectoryDndRef: (0, vue_1.computed)(() => {
|
|
383
350
|
var _a;
|
|
384
351
|
return (_a = props.directoryDnd) !== null && _a !== void 0 ? _a : props.directory;
|
|
385
|
-
})
|
|
352
|
+
}),
|
|
353
|
+
previewSrcListRef,
|
|
354
|
+
previewShowRef,
|
|
355
|
+
previewCurrentRef,
|
|
356
|
+
isFilePreviewable,
|
|
357
|
+
openFilePreview
|
|
386
358
|
});
|
|
387
359
|
const exposedMethods = {
|
|
388
360
|
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>;
|
|
@@ -90,9 +90,12 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
90
90
|
if (!UUpload.showPreviewButtonRef.value)
|
|
91
91
|
return false;
|
|
92
92
|
const { file: { status }, listType } = props;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
if (!['finished'].includes(status))
|
|
94
|
+
return false;
|
|
95
|
+
if (listType === 'preview-list') {
|
|
96
|
+
return UUpload.isFilePreviewable(props.file);
|
|
97
|
+
}
|
|
98
|
+
return !!mergedThumbnailUrlRef.value && listType === 'image-card';
|
|
96
99
|
});
|
|
97
100
|
function handleRetryClick() {
|
|
98
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -165,6 +168,9 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
165
168
|
if (onPreview) {
|
|
166
169
|
onPreview(props.file);
|
|
167
170
|
}
|
|
171
|
+
else if (props.listType === 'preview-list') {
|
|
172
|
+
UUpload.openFilePreview(props.file);
|
|
173
|
+
}
|
|
168
174
|
else if (props.listType === 'image-card') {
|
|
169
175
|
const { value } = imageRef;
|
|
170
176
|
if (!value)
|
|
@@ -245,7 +251,9 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
245
251
|
&& `${clsPrefix}-upload-file--with-url`,
|
|
246
252
|
`${clsPrefix}-upload-file--${listType === 'image' || listType === 'image-card'
|
|
247
253
|
? 'image-card'
|
|
248
|
-
: 'text'}-type
|
|
254
|
+
: 'text'}-type`,
|
|
255
|
+
listType === 'preview-list'
|
|
256
|
+
&& `${clsPrefix}-upload-file--preview-list-type`
|
|
249
257
|
] },
|
|
250
258
|
(0, vue_1.h)("div", { class: [
|
|
251
259
|
`${clsPrefix}-upload-file-info`,
|
|
@@ -17,12 +17,18 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
17
17
|
if (!UUpload) {
|
|
18
18
|
(0, _utils_1.throwError)('upload-file-list', '`u-upload-file-list` must be placed inside `u-upload`.');
|
|
19
19
|
}
|
|
20
|
-
const { abstractRef, mergedClsPrefixRef, listTypeRef, mergedFileListRef, fileListClassRef, fileListStyleRef, cssVarsRef, themeClassRef, maxReachedRef, showTriggerRef, imageGroupPropsRef } = UUpload;
|
|
20
|
+
const { abstractRef, mergedClsPrefixRef, listTypeRef, mergedFileListRef, fileListClassRef, fileListStyleRef, cssVarsRef, themeClassRef, maxReachedRef, showTriggerRef, imageGroupPropsRef, previewSrcListRef, previewShowRef, previewCurrentRef } = UUpload;
|
|
21
21
|
const isImageCardTypeRef = (0, vue_1.computed)(() => listTypeRef.value === 'image-card' || listTypeRef.value === 'image');
|
|
22
|
+
const isPreviewListTypeRef = (0, vue_1.computed)(() => listTypeRef.value === 'preview-list');
|
|
22
23
|
const renderFileList = () => mergedFileListRef.value.map(file => ((0, vue_1.h)(UploadFile_1.default, { clsPrefix: mergedClsPrefixRef.value, key: file.id, file: file, listType: listTypeRef.value }, slots)));
|
|
23
24
|
const renderUploadFileList = () => isImageCardTypeRef.value ? ((0, vue_1.h)(image_1.UImageGroup, Object.assign({}, imageGroupPropsRef.value), { default: renderFileList })) : ((0, vue_1.h)(_internal_1.UFadeInExpandTransition, { group: true }, {
|
|
24
25
|
default: renderFileList
|
|
25
26
|
}));
|
|
27
|
+
const renderPreview = () => ((0, vue_1.h)(image_1.UImageGroup, Object.assign({}, imageGroupPropsRef.value, { srcList: previewSrcListRef.value, show: previewShowRef.value, current: previewCurrentRef.value, onUpdateShow: (show) => {
|
|
28
|
+
previewShowRef.value = show;
|
|
29
|
+
}, onUpdateCurrent: (current) => {
|
|
30
|
+
previewCurrentRef.value = current;
|
|
31
|
+
} })));
|
|
26
32
|
return () => {
|
|
27
33
|
const { value: mergedClsPrefix } = mergedClsPrefixRef;
|
|
28
34
|
const { value: abstract } = abstractRef;
|
|
@@ -37,6 +43,7 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
37
43
|
fileListStyleRef.value
|
|
38
44
|
] },
|
|
39
45
|
renderUploadFileList(),
|
|
46
|
+
isPreviewListTypeRef.value && renderPreview(),
|
|
40
47
|
showTriggerRef.value
|
|
41
48
|
&& !maxReachedRef.value
|
|
42
49
|
&& isImageCardTypeRef.value && ((0, vue_1.h)(UploadTrigger_1.default, null, slots))));
|
|
@@ -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<{}>, {
|