@uploadcare/file-uploader 1.15.0-alpha.12 → 1.15.0-alpha.13
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/abstract/ActivityBlock.d.ts +5 -5
- package/abstract/ActivityBlock.d.ts.map +1 -1
- package/abstract/Block.d.ts +3 -9
- package/abstract/Block.d.ts.map +1 -1
- package/abstract/CTX.d.ts +6 -6
- package/abstract/CTX.d.ts.map +1 -1
- package/abstract/LocaleManager.d.ts +3 -3
- package/abstract/LocaleManager.d.ts.map +1 -1
- package/abstract/ModalManager.d.ts +13 -18
- package/abstract/ModalManager.d.ts.map +1 -1
- package/abstract/ModalManager.js +19 -10
- package/abstract/SecureUploadsManager.d.ts +2 -2
- package/abstract/SecureUploadsManager.d.ts.map +1 -1
- package/abstract/SolutionBlock.d.ts +2 -2
- package/abstract/SolutionBlock.d.ts.map +1 -1
- package/abstract/TypedCollection.d.ts +44 -44
- package/abstract/TypedCollection.d.ts.map +1 -1
- package/abstract/TypedCollection.js +53 -33
- package/abstract/TypedData.d.ts +71 -25
- package/abstract/TypedData.d.ts.map +1 -1
- package/abstract/TypedData.js +74 -17
- package/abstract/UploaderBlock.d.ts +10 -10
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +22 -10
- package/abstract/UploaderPublicApi.d.ts +24 -23
- package/abstract/UploaderPublicApi.d.ts.map +1 -1
- package/abstract/UploaderPublicApi.js +21 -10
- package/abstract/ValidationManager.d.ts +121 -6
- package/abstract/ValidationManager.d.ts.map +1 -1
- package/abstract/ValidationManager.js +1 -1
- package/abstract/a11y.d.ts +2 -2
- package/abstract/a11y.d.ts.map +1 -1
- package/abstract/buildOutputCollectionState.d.ts +1 -1
- package/abstract/buildOutputCollectionState.d.ts.map +1 -1
- package/abstract/defineComponents.d.ts.map +1 -1
- package/abstract/l10nProcessor.d.ts.map +1 -1
- package/abstract/loadFileUploaderFrom.d.ts +1 -1
- package/abstract/loadFileUploaderFrom.d.ts.map +1 -1
- package/abstract/localeRegistry.d.ts.map +1 -1
- package/abstract/sharedConfigKey.d.ts.map +1 -1
- package/abstract/uploadEntrySchema.d.ts +119 -63
- package/abstract/uploadEntrySchema.d.ts.map +1 -1
- package/abstract/uploadEntrySchema.js +62 -81
- package/blocks/CameraSource/CameraSource.d.ts +9 -9
- package/blocks/CameraSource/CameraSource.d.ts.map +1 -1
- package/blocks/CameraSource/calcCameraModes.d.ts +1 -1
- package/blocks/CameraSource/constants.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CloudImageEditorBlock.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/CropFrame.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorImageCropper.d.ts +3 -3
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorImageFader.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorSlider.d.ts +1 -1
- package/blocks/CloudImageEditor/src/EditorSlider.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/EditorToolbar.d.ts +1 -1
- package/blocks/CloudImageEditor/src/crop-utils.d.ts +14 -14
- package/blocks/CloudImageEditor/src/crop-utils.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/cropper-constants.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts +1 -1
- package/blocks/CloudImageEditor/src/lib/applyFocusVisiblePolyfill.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/lib/parseCropPreset.d.ts +1 -1
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts +3 -3
- package/blocks/CloudImageEditor/src/lib/transformationUtils.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/state.d.ts +4 -4
- package/blocks/CloudImageEditor/src/svg-sprite.d.ts.map +1 -1
- package/blocks/CloudImageEditor/src/types.d.ts +8 -58
- package/blocks/CloudImageEditor/src/types.d.ts.map +1 -1
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts +5 -2
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.d.ts.map +1 -1
- package/blocks/CloudImageEditorActivity/CloudImageEditorActivity.js +7 -3
- package/blocks/Config/Config.d.ts +3 -12
- package/blocks/Config/Config.d.ts.map +1 -1
- package/blocks/Config/assertions.d.ts +1 -1
- package/blocks/Config/initialConfig.d.ts +1 -1
- package/blocks/Config/initialConfig.d.ts.map +1 -1
- package/blocks/Config/initialConfig.js +1 -1
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
- package/blocks/Config/side-effects.d.ts.map +1 -1
- package/blocks/Config/validatorsType.d.ts +1 -1
- package/blocks/Config/validatorsType.d.ts.map +1 -1
- package/blocks/DropArea/DropArea.d.ts +2 -2
- package/blocks/DropArea/DropArea.d.ts.map +1 -1
- package/blocks/DropArea/addDropzone.d.ts.map +1 -1
- package/blocks/DropArea/drop-area.css +4 -2
- package/blocks/DropArea/getDropItems.d.ts +2 -2
- package/blocks/DropArea/getDropItems.d.ts.map +1 -1
- package/blocks/ExternalSource/ExternalSource.d.ts +3 -3
- package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
- package/blocks/ExternalSource/MessageBridge.d.ts +3 -3
- package/blocks/ExternalSource/MessageBridge.d.ts.map +1 -1
- package/blocks/ExternalSource/query-string.d.ts.map +1 -1
- package/blocks/ExternalSource/types.d.ts +64 -64
- package/blocks/ExternalSource/types.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.d.ts +20 -24
- package/blocks/FileItem/FileItem.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.js +120 -121
- package/blocks/FileItem/file-item.css +29 -6
- package/blocks/Img/ImgBase.d.ts +3 -3
- package/blocks/Img/ImgBase.d.ts.map +1 -1
- package/blocks/Img/ImgBase.js +9 -9
- package/blocks/Img/ImgConfig.d.ts.map +1 -1
- package/blocks/Img/configurations.d.ts.map +1 -1
- package/blocks/Modal/Modal.d.ts +4 -4
- package/blocks/Modal/Modal.d.ts.map +1 -1
- package/blocks/ProgressBar/ProgressBar.d.ts +6 -1
- package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/blocks/ProgressBar/ProgressBar.js +44 -42
- package/blocks/Range/Range.d.ts.map +1 -1
- package/blocks/SimpleBtn/SimpleBtn.d.ts +2 -2
- package/blocks/SimpleBtn/SimpleBtn.d.ts.map +1 -1
- package/blocks/SourceBtn/SourceBtn.d.ts +2 -5
- package/blocks/SourceBtn/SourceBtn.d.ts.map +1 -1
- package/blocks/SourceBtn/SourceBtn.js +5 -5
- package/blocks/SourceList/SourceList.js +2 -2
- package/blocks/Spinner/Spinner.d.ts.map +1 -1
- package/blocks/Thumb/Thumb.d.ts +22 -6
- package/blocks/Thumb/Thumb.d.ts.map +1 -1
- package/blocks/Thumb/Thumb.js +73 -21
- package/blocks/UploadCtxProvider/EventEmitter.d.ts +20 -20
- package/blocks/UploadCtxProvider/EventEmitter.d.ts.map +1 -1
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts +4 -4
- package/blocks/UploadCtxProvider/UploadCtxProvider.d.ts.map +1 -1
- package/blocks/UploadList/UploadList.d.ts +3 -3
- package/blocks/UploadList/UploadList.d.ts.map +1 -1
- package/blocks/svg-backgrounds/svg-backgrounds.d.ts +3 -3
- package/blocks/svg-backgrounds/svg-backgrounds.d.ts.map +1 -1
- package/blocks/themes/uc-basic/svg-sprite.d.ts.map +1 -1
- package/blocks/utils/UploadSource.d.ts.map +1 -1
- package/blocks/utils/debounce.d.ts +3 -1
- package/blocks/utils/debounce.d.ts.map +1 -1
- package/blocks/utils/resizeImage.d.ts +1 -1
- package/blocks/utils/resizeImage.d.ts.map +1 -1
- package/blocks/utils/throttle.d.ts +3 -1
- package/blocks/utils/throttle.d.ts.map +1 -1
- package/blocks/utils/userAgent.d.ts +1 -1
- package/blocks/utils/userAgent.d.ts.map +1 -1
- package/env.d.ts.map +1 -1
- package/index.ssr.js +1 -1
- package/package.json +6 -5
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts +2 -2
- package/solutions/file-uploader/inline/FileUploaderInline.d.ts.map +1 -1
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +10 -10
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
- package/solutions/file-uploader/minimal/index.css +5 -0
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +2 -2
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
- package/types/jsx.d.ts +1 -1
- package/utils/browser-info.d.ts +13 -0
- package/utils/browser-info.d.ts.map +1 -0
- package/utils/browser-info.js +22 -0
- package/utils/browser-info.test.d.ts +2 -0
- package/utils/browser-info.test.d.ts.map +1 -0
- package/utils/browser-info.test.js +109 -0
- package/utils/cdn-utils.d.ts +3 -3
- package/utils/cdn-utils.d.ts.map +1 -1
- package/utils/fileTypes.d.ts +5 -1
- package/utils/fileTypes.d.ts.map +1 -1
- package/utils/fileTypes.js +18 -2
- package/utils/getPluralForm.d.ts.map +1 -1
- package/utils/isSecureTokenExpired.d.ts +1 -1
- package/utils/memoize.d.ts.map +1 -1
- package/utils/mixinClass.d.ts +3 -1
- package/utils/mixinClass.d.ts.map +1 -1
- package/utils/prettyBytes.d.ts.map +1 -1
- package/utils/template-utils.d.ts +1 -1
- package/utils/template-utils.d.ts.map +1 -1
- package/utils/toKebabCase.d.ts.map +1 -1
- package/utils/transparentPixelSrc.d.ts.map +1 -1
- package/utils/uniqueArray.d.ts.map +1 -1
- package/utils/validators/collection/validateCollectionUploadError.d.ts +1 -1
- package/utils/validators/collection/validateMultiple.d.ts +1 -1
- package/utils/validators/file/validateFileType.d.ts +1 -1
- package/utils/validators/file/validateIsImage.d.ts +1 -1
- package/utils/validators/file/validateMaxSizeLimit.d.ts +1 -1
- package/utils/validators/file/validateUploadError.d.ts +1 -1
- package/utils/waitForAttribute.d.ts +1 -1
- package/utils/waitForAttribute.d.ts.map +1 -1
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.min.js +4 -4
- package/web/uc-basic.min.css +1 -1
- package/web/uc-cloud-image-editor.min.js +2 -2
- package/web/uc-file-uploader-inline.min.css +1 -1
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-minimal.min.css +1 -1
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-regular.min.css +1 -1
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-img.min.js +1 -1
- package/blocks/utils/supportCapture.d.ts +0 -2
- package/blocks/utils/supportCapture.d.ts.map +0 -1
- package/blocks/utils/supportCapture.js +0 -3
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { CancelError, uploadFile } from '@uploadcare/upload-client';
|
|
3
2
|
import { shrinkFile } from '@uploadcare/image-shrink';
|
|
3
|
+
import { CancelError, UploadcareError, uploadFile } from '@uploadcare/upload-client';
|
|
4
4
|
import { ActivityBlock } from '../../abstract/ActivityBlock.js';
|
|
5
5
|
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
6
|
-
import { createCdnUrl, createCdnUrlModifiers, createOriginalUrl } from '../../utils/cdn-utils.js';
|
|
7
|
-
import { fileCssBg } from '../svg-backgrounds/svg-backgrounds.js';
|
|
8
6
|
import { debounce } from '../utils/debounce.js';
|
|
9
|
-
import { generateThumb } from '../utils/resizeImage.js';
|
|
10
7
|
import { parseShrink } from '../../utils/parseShrink.js';
|
|
11
8
|
import { UploadSource } from '../utils/UploadSource.js';
|
|
12
9
|
import { throttle } from '../utils/throttle.js';
|
|
@@ -26,16 +23,34 @@ export class FileItem extends UploaderBlock {
|
|
|
26
23
|
_entrySubs = new Set();
|
|
27
24
|
/**
|
|
28
25
|
* @private
|
|
29
|
-
* @type {
|
|
26
|
+
* @type {import('../../abstract/uploadEntrySchema.js').UploadEntryTypedData | null}
|
|
30
27
|
*/
|
|
31
28
|
_entry = null;
|
|
32
29
|
|
|
33
|
-
/** @private */
|
|
34
|
-
_debouncedCalculateState = debounce(this._calculateState.bind(this), 100);
|
|
35
|
-
|
|
36
30
|
/** @private */
|
|
37
31
|
_renderedOnce = false;
|
|
38
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @template {any[]} A
|
|
36
|
+
* @template {(entry: import('../../abstract/uploadEntrySchema.js').UploadEntryTypedData, ...args: A) => any} T
|
|
37
|
+
* @param {T} fn
|
|
38
|
+
* @returns {(...args: A) => ReturnType<T>}
|
|
39
|
+
*/
|
|
40
|
+
_withEntry(fn) {
|
|
41
|
+
const wrapperFn = /** @type {(...args: A) => ReturnType<T>} */ (
|
|
42
|
+
(...args) => {
|
|
43
|
+
const entry = this._entry;
|
|
44
|
+
if (!entry) {
|
|
45
|
+
console.warn('No entry found');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
return fn(entry, ...args);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
return wrapperFn;
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
constructor() {
|
|
40
55
|
super();
|
|
41
56
|
|
|
@@ -57,13 +72,13 @@ export class FileItem extends UploaderBlock {
|
|
|
57
72
|
showFileNames: false,
|
|
58
73
|
state: FileItemState.IDLE,
|
|
59
74
|
ariaLabelStatusFile: '',
|
|
60
|
-
onEdit: () => {
|
|
75
|
+
onEdit: this._withEntry((entry) => {
|
|
61
76
|
this.$['*currentActivityParams'] = {
|
|
62
|
-
internalId:
|
|
77
|
+
internalId: entry.uid,
|
|
63
78
|
};
|
|
64
79
|
this.modalManager.open(ActivityBlock.activities.CLOUD_IMG_EDIT);
|
|
65
80
|
this.$['*currentActivity'] = ActivityBlock.activities.CLOUD_IMG_EDIT;
|
|
66
|
-
},
|
|
81
|
+
}),
|
|
67
82
|
onRemove: () => {
|
|
68
83
|
this.uploadCollection.remove(this.$.uid);
|
|
69
84
|
},
|
|
@@ -100,11 +115,7 @@ export class FileItem extends UploaderBlock {
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
/** @private */
|
|
103
|
-
_calculateState() {
|
|
104
|
-
if (!this._entry) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
let entry = this._entry;
|
|
118
|
+
_calculateState = this._withEntry((entry) => {
|
|
108
119
|
let state = FileItemState.IDLE;
|
|
109
120
|
|
|
110
121
|
if (entry.getValue('errors').length > 0) {
|
|
@@ -116,81 +127,50 @@ export class FileItem extends UploaderBlock {
|
|
|
116
127
|
}
|
|
117
128
|
|
|
118
129
|
this.$.state = state;
|
|
119
|
-
}
|
|
130
|
+
});
|
|
120
131
|
|
|
121
132
|
/** @private */
|
|
122
|
-
|
|
123
|
-
if (!this._entry) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
let entry = this._entry;
|
|
127
|
-
|
|
128
|
-
if (entry.getValue('fileInfo') && entry.getValue('isImage')) {
|
|
129
|
-
let size = Math.max(
|
|
130
|
-
parseInt(String(this?._thumbRect?.height || 0)),
|
|
131
|
-
parseInt(String(this?._thumbRect?.width || 0)),
|
|
132
|
-
this.cfg.thumbSize,
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
let thumbUrl = await this.proxyUrl(
|
|
136
|
-
createCdnUrl(
|
|
137
|
-
createOriginalUrl(this.cfg.cdnCname, this._entry.getValue('uuid')),
|
|
138
|
-
createCdnUrlModifiers(entry.getValue('cdnUrlModifiers'), `scale_crop/${size}x${size}/center`),
|
|
139
|
-
),
|
|
140
|
-
);
|
|
141
|
-
let currentThumbUrl = entry.getValue('thumbUrl');
|
|
142
|
-
if (currentThumbUrl !== thumbUrl) {
|
|
143
|
-
entry.setValue('thumbUrl', thumbUrl);
|
|
144
|
-
currentThumbUrl?.startsWith('blob:') && URL.revokeObjectURL(currentThumbUrl);
|
|
145
|
-
}
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (entry.getValue('file')?.type.includes('image')) {
|
|
150
|
-
try {
|
|
151
|
-
let thumbUrl = await generateThumb(entry.getValue('file'), this.cfg.thumbSize);
|
|
152
|
-
entry.setValue('thumbUrl', thumbUrl);
|
|
153
|
-
} catch (err) {
|
|
154
|
-
let color = window.getComputedStyle(this).getPropertyValue('--uc-muted-foreground');
|
|
155
|
-
entry.setValue('thumbUrl', fileCssBg(color));
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
let color = window.getComputedStyle(this).getPropertyValue('--uc-muted-foreground');
|
|
159
|
-
entry.setValue('thumbUrl', fileCssBg(color));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
133
|
+
_debouncedCalculateState = debounce(this._calculateState.bind(this), 100);
|
|
162
134
|
|
|
163
135
|
/**
|
|
164
|
-
* @
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {(value:
|
|
136
|
+
* @template {import('../../abstract/uploadEntrySchema.js').UploadEntryKeys} K
|
|
137
|
+
* @param {K} prop_
|
|
138
|
+
* @param {(value: import('../../abstract/uploadEntrySchema.js').UploadEntryData[K]) => void} handler_
|
|
167
139
|
*/
|
|
168
|
-
_subEntry(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
140
|
+
_subEntry = (prop_, handler_) =>
|
|
141
|
+
this._withEntry(
|
|
142
|
+
/**
|
|
143
|
+
* @template {import('../../abstract/uploadEntrySchema.js').UploadEntryKeys} K
|
|
144
|
+
* @param {import('../../abstract/uploadEntrySchema.js').UploadEntryTypedData} entry
|
|
145
|
+
* @param {K} prop
|
|
146
|
+
* @param {(value: import('../../abstract/uploadEntrySchema.js').UploadEntryData[K]) => void} handler
|
|
147
|
+
*/
|
|
148
|
+
(entry, prop, handler) => {
|
|
149
|
+
let sub = entry.subscribe(prop, (value) => {
|
|
150
|
+
if (this.isConnected) {
|
|
151
|
+
handler(value);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
this._entrySubs.add(sub);
|
|
175
155
|
},
|
|
176
|
-
);
|
|
177
|
-
this._entrySubs.add(sub);
|
|
178
|
-
}
|
|
156
|
+
)(prop_, handler_);
|
|
179
157
|
|
|
180
|
-
_updateHint =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
158
|
+
_updateHint = this._withEntry(
|
|
159
|
+
throttle((entry) => {
|
|
160
|
+
const source = entry.getValue('source');
|
|
161
|
+
const showHint =
|
|
162
|
+
this.$.state === FileItemState.UPLOADING &&
|
|
163
|
+
entry.getValue('externalUrl') &&
|
|
164
|
+
source &&
|
|
165
|
+
source !== UploadSource.URL &&
|
|
166
|
+
entry.getValue('errors').length === 0 &&
|
|
167
|
+
this.$.progressValue === 0;
|
|
187
168
|
|
|
188
|
-
|
|
189
|
-
? this.l10n('waiting-for', { source: this.l10n(`src-type-${this._entry.getValue('source')}`) })
|
|
190
|
-
: '';
|
|
169
|
+
const hint = showHint ? this.l10n('waiting-for', { source: this.l10n(`src-type-${source}`) }) : '';
|
|
191
170
|
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
this.$.hint = hint;
|
|
172
|
+
}, 100),
|
|
173
|
+
);
|
|
194
174
|
|
|
195
175
|
/**
|
|
196
176
|
* @private
|
|
@@ -199,7 +179,6 @@ export class FileItem extends UploaderBlock {
|
|
|
199
179
|
_handleEntryId(id) {
|
|
200
180
|
this._reset();
|
|
201
181
|
|
|
202
|
-
/** @type {import('../../abstract/TypedData.js').TypedData} */
|
|
203
182
|
let entry = this.uploadCollection?.read(id);
|
|
204
183
|
this._entry = entry;
|
|
205
184
|
|
|
@@ -278,7 +257,7 @@ export class FileItem extends UploaderBlock {
|
|
|
278
257
|
'*uploadTrigger',
|
|
279
258
|
/** @param {Set<string>} itemsToUpload */
|
|
280
259
|
(itemsToUpload) => {
|
|
281
|
-
if (!itemsToUpload.has(this._entry.uid)) {
|
|
260
|
+
if (this._entry && !itemsToUpload.has(this._entry.uid)) {
|
|
282
261
|
return;
|
|
283
262
|
}
|
|
284
263
|
setTimeout(() => this.isConnected && this.upload());
|
|
@@ -287,33 +266,38 @@ export class FileItem extends UploaderBlock {
|
|
|
287
266
|
FileItem.activeInstances.add(this);
|
|
288
267
|
}
|
|
289
268
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (state === FileItemState.UPLOADING) {
|
|
299
|
-
this.$.isFocused = false;
|
|
300
|
-
}
|
|
269
|
+
_handleState = this._withEntry(
|
|
270
|
+
/** @param {(typeof FileItemState)[keyof typeof FileItemState]} state */
|
|
271
|
+
(entry, state) => {
|
|
272
|
+
if (state === FileItemState.FAILED) {
|
|
273
|
+
this.$.badgeIcon = 'badge-error';
|
|
274
|
+
} else if (state === FileItemState.FINISHED) {
|
|
275
|
+
this.$.badgeIcon = 'badge-success';
|
|
276
|
+
}
|
|
301
277
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
278
|
+
if (state === FileItemState.UPLOADING) {
|
|
279
|
+
this.$.isFocused = false;
|
|
280
|
+
}
|
|
281
|
+
const fileName = entry.getValue('fileName');
|
|
282
|
+
|
|
283
|
+
this.set$({
|
|
284
|
+
isFailed: state === FileItemState.FAILED,
|
|
285
|
+
isUploading: state === FileItemState.UPLOADING,
|
|
286
|
+
isFinished: state === FileItemState.FINISHED,
|
|
287
|
+
progressVisible: state === FileItemState.UPLOADING,
|
|
288
|
+
isEditable: this.cfg.useCloudImageEditor && this._entry?.getValue('isImage') && this._entry?.getValue('cdnUrl'),
|
|
289
|
+
errorText: entry.getValue('errors')?.[0]?.message,
|
|
290
|
+
ariaLabelStatusFile:
|
|
291
|
+
fileName &&
|
|
292
|
+
this.l10n('a11y-file-item-status', {
|
|
293
|
+
fileName,
|
|
294
|
+
status: this.l10n(state?.description?.toLocaleLowerCase() ?? '').toLocaleLowerCase(),
|
|
295
|
+
}),
|
|
296
|
+
});
|
|
314
297
|
|
|
315
|
-
|
|
316
|
-
|
|
298
|
+
this._updateHint();
|
|
299
|
+
},
|
|
300
|
+
);
|
|
317
301
|
|
|
318
302
|
destroyCallback() {
|
|
319
303
|
super.destroyCallback();
|
|
@@ -351,9 +335,7 @@ export class FileItem extends UploaderBlock {
|
|
|
351
335
|
return shrinkFile(file, this._settingsOfShrink());
|
|
352
336
|
}
|
|
353
337
|
|
|
354
|
-
async
|
|
355
|
-
let entry = this._entry;
|
|
356
|
-
|
|
338
|
+
upload = this._withEntry(async (entry) => {
|
|
357
339
|
if (!this.uploadCollection.read(entry.uid)) {
|
|
358
340
|
return;
|
|
359
341
|
}
|
|
@@ -367,26 +349,33 @@ export class FileItem extends UploaderBlock {
|
|
|
367
349
|
}
|
|
368
350
|
|
|
369
351
|
this._debouncedCalculateState();
|
|
370
|
-
|
|
371
|
-
entry.
|
|
352
|
+
|
|
353
|
+
entry.setMultipleValues({
|
|
354
|
+
isUploading: true,
|
|
355
|
+
errors: [],
|
|
356
|
+
});
|
|
372
357
|
|
|
373
358
|
try {
|
|
374
359
|
let abortController = new AbortController();
|
|
375
360
|
entry.setValue('abortController', abortController);
|
|
376
361
|
|
|
377
362
|
const uploadTask = async () => {
|
|
363
|
+
/** @type {Blob | File | null} */
|
|
378
364
|
let file = entry.getValue('file');
|
|
379
365
|
if (file && this.cfg.imageShrink) {
|
|
380
|
-
file = await this._processShrink(file).catch(() => file);
|
|
366
|
+
file = await this._processShrink(/** @type {File} */ (file)).catch(() => file);
|
|
381
367
|
}
|
|
382
368
|
|
|
383
369
|
const fileInput = file || entry.getValue('externalUrl') || entry.getValue('uuid');
|
|
370
|
+
if (!fileInput) {
|
|
371
|
+
throw new Error('No file input');
|
|
372
|
+
}
|
|
384
373
|
const baseUploadClientOptions = await this.getUploadClientOptions();
|
|
385
374
|
/** @type {import('@uploadcare/upload-client').FileFromOptions} */
|
|
386
375
|
const uploadClientOptions = {
|
|
387
376
|
...baseUploadClientOptions,
|
|
388
|
-
fileName: entry.getValue('fileName'),
|
|
389
|
-
source: entry.getValue('source'),
|
|
377
|
+
fileName: entry.getValue('fileName') ?? undefined,
|
|
378
|
+
source: entry.getValue('source') ?? undefined,
|
|
390
379
|
onProgress: (progress) => {
|
|
391
380
|
if (progress.isComputable) {
|
|
392
381
|
let percentage = progress.value * 100;
|
|
@@ -407,7 +396,7 @@ export class FileItem extends UploaderBlock {
|
|
|
407
396
|
isUploading: false,
|
|
408
397
|
fileName: fileInfo.originalFilename,
|
|
409
398
|
fileSize: fileInfo.size,
|
|
410
|
-
isImage: fileInfo.isImage,
|
|
399
|
+
isImage: fileInfo.isImage ?? false,
|
|
411
400
|
mimeType: fileInfo.contentInfo?.mime?.mime ?? fileInfo.mimeType,
|
|
412
401
|
uuid: fileInfo.uuid,
|
|
413
402
|
cdnUrl: entry.getValue('cdnUrl') ?? fileInfo.cdnUrl,
|
|
@@ -425,19 +414,29 @@ export class FileItem extends UploaderBlock {
|
|
|
425
414
|
isUploading: false,
|
|
426
415
|
uploadProgress: 0,
|
|
427
416
|
});
|
|
428
|
-
} else {
|
|
417
|
+
} else if (cause instanceof UploadcareError) {
|
|
429
418
|
entry.setMultipleValues({
|
|
430
419
|
isUploading: false,
|
|
431
420
|
uploadProgress: 0,
|
|
432
421
|
uploadError: cause,
|
|
433
422
|
});
|
|
423
|
+
} else {
|
|
424
|
+
console.error('Unknown upload error', cause);
|
|
425
|
+
entry.setMultipleValues({
|
|
426
|
+
isUploading: false,
|
|
427
|
+
uploadProgress: 0,
|
|
428
|
+
// TODO: Add translation?
|
|
429
|
+
uploadError: new Error('Something went wrong', {
|
|
430
|
+
cause,
|
|
431
|
+
}),
|
|
432
|
+
});
|
|
434
433
|
}
|
|
435
434
|
|
|
436
435
|
if (entry === this._entry) {
|
|
437
436
|
this._debouncedCalculateState();
|
|
438
437
|
}
|
|
439
438
|
}
|
|
440
|
-
}
|
|
439
|
+
});
|
|
441
440
|
}
|
|
442
441
|
|
|
443
442
|
FileItem.template = /* HTML */ `
|
|
@@ -472,7 +471,7 @@ FileItem.template = /* HTML */ `
|
|
|
472
471
|
</div>
|
|
473
472
|
<uc-progress-bar
|
|
474
473
|
class="uc-progress-bar"
|
|
475
|
-
set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames"
|
|
474
|
+
set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames;"
|
|
476
475
|
>
|
|
477
476
|
</uc-progress-bar>
|
|
478
477
|
</div>
|
|
@@ -74,6 +74,7 @@ uc-file-item .uc-file-error {
|
|
|
74
74
|
display: none;
|
|
75
75
|
color: var(--uc-destructive-foreground);
|
|
76
76
|
font-size: 0.85em;
|
|
77
|
+
z-index: 2;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
uc-file-item button.uc-remove-btn,
|
|
@@ -193,6 +194,17 @@ uc-file-item[mode='grid'] .uc-file-error {
|
|
|
193
194
|
padding: calc(var(--uc-padding) / 2) var(--uc-padding);
|
|
194
195
|
}
|
|
195
196
|
|
|
197
|
+
uc-file-item[mode='grid'] .uc-file-hint {
|
|
198
|
+
position: absolute;
|
|
199
|
+
background-color: var(--uc-background);
|
|
200
|
+
border-radius: var(--uc-radius);
|
|
201
|
+
color: var(--uc-foreground);
|
|
202
|
+
bottom: calc(var(--uc-padding) * 2);
|
|
203
|
+
left: var(--uc-padding);
|
|
204
|
+
right: var(--uc-padding);
|
|
205
|
+
padding: calc(var(--uc-padding) / 2) var(--uc-padding);
|
|
206
|
+
}
|
|
207
|
+
|
|
196
208
|
uc-file-item[mode='grid'] .uc-file-actions {
|
|
197
209
|
position: absolute;
|
|
198
210
|
top: var(--uc-padding);
|
|
@@ -216,19 +228,30 @@ uc-file-item[mode='grid'] .uc-progress-bar {
|
|
|
216
228
|
left: var(--uc-padding);
|
|
217
229
|
right: var(--uc-padding);
|
|
218
230
|
border-radius: var(--uc-radius);
|
|
219
|
-
background-color: var(--uc-background);
|
|
220
231
|
z-index: 1;
|
|
232
|
+
transition: background-color 0.3s;
|
|
233
|
+
background-color: transparent;
|
|
221
234
|
}
|
|
222
235
|
|
|
223
|
-
uc-file-item[mode='grid'] .uc-progress-bar.uc-progress-
|
|
224
|
-
|
|
236
|
+
uc-file-item[mode='grid'] .uc-progress-bar:not(:has(.uc-progress--hidden, .uc-fake-progress--hidden)) {
|
|
237
|
+
background-color: var(--uc-background);
|
|
225
238
|
}
|
|
226
239
|
|
|
227
|
-
uc-file-item[mode='grid'] .uc-progress-bar
|
|
228
|
-
|
|
240
|
+
uc-file-item[mode='grid'] .uc-progress-bar .uc-progress {
|
|
241
|
+
z-index: 3;
|
|
229
242
|
}
|
|
230
243
|
|
|
231
|
-
uc-file-item[mode='grid'] .uc-progress-bar .uc-progress {
|
|
244
|
+
uc-file-item[mode='grid'] .uc-progress-bar .uc-fake-progress {
|
|
245
|
+
z-index: 2;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
uc-file-item[mode='grid']
|
|
249
|
+
.uc-progress-bar
|
|
250
|
+
:is(.uc-fake-progress:not(.uc-fake-progress--hidden), .uc-progress:not(.uc-progress--hidden)) {
|
|
232
251
|
background-color: var(--uc-primary);
|
|
233
252
|
opacity: 0.7;
|
|
234
253
|
}
|
|
254
|
+
|
|
255
|
+
uc-file-item[mode='grid'] .uc-progress-bar[hasfilename] {
|
|
256
|
+
bottom: calc(var(--uc-padding) + var(--uc-font-size));
|
|
257
|
+
}
|
package/blocks/Img/ImgBase.d.ts
CHANGED
|
@@ -12,14 +12,14 @@ export class ImgBase extends ImgConfig {
|
|
|
12
12
|
* @param {String} [size]
|
|
13
13
|
* @returns {String | Number}
|
|
14
14
|
*/
|
|
15
|
-
_validateSize(size?: string
|
|
15
|
+
_validateSize(size?: string): string | number;
|
|
16
16
|
/**
|
|
17
17
|
* Image operations
|
|
18
18
|
*
|
|
19
19
|
* @param {String} [size]
|
|
20
20
|
* @param {String} [blur]
|
|
21
21
|
*/
|
|
22
|
-
_getCdnModifiers(size?: string
|
|
22
|
+
_getCdnModifiers(size?: string, blur?: string): string;
|
|
23
23
|
/**
|
|
24
24
|
* @private
|
|
25
25
|
* @param {String} [size]
|
|
@@ -38,7 +38,7 @@ export class ImgBase extends ImgConfig {
|
|
|
38
38
|
* @param {Number} [k]
|
|
39
39
|
* @param {Boolean} [wOnly]
|
|
40
40
|
*/
|
|
41
|
-
_getElSize(el: HTMLElement, k?: number
|
|
41
|
+
_getElSize(el: HTMLElement, k?: number, wOnly?: boolean): string | null;
|
|
42
42
|
/** @param {HTMLImageElement} img */
|
|
43
43
|
_setupEventProxy(img: HTMLImageElement): void;
|
|
44
44
|
/** @type {HTMLImageElement} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImgBase.d.ts","sourceRoot":"","sources":["ImgBase.js"],"names":[],"mappings":"AAgBA;IACE,uBAAmB;IACnB,8BAA0B;IAE1B;;;OAGG;IACH,gBAMC;IAED;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"ImgBase.d.ts","sourceRoot":"","sources":["ImgBase.js"],"names":[],"mappings":"AAgBA;IACE,uBAAmB;IACnB,8BAA0B;IAE1B;;;OAGG;IACH,gBAMC;IAED;;;;;OAKG;IACH,8BAFa,eAAe,CAoB3B;IAED;;;;;OAKG;IACH,uDAWC;IAED;;;;;OAKG;IACH,oBA6DC;IAED;;;;OAIG;IACH,kBAUC;IAED;;;;OAIG;IACH,eAJW,WAAW,8CAcrB;IAED,oCAAoC;IACpC,sBADY,gBAAgB,QAY3B;IAED,+BAA+B;IAC/B,WADW,gBAAgB,CAO1B;IAED;;;;;;MAUC;IAED,2BAEC;IAED,sBAEC;IAED,mCAOC;IAED,4BAEC;IAED,8BAA8B;IAC9B,aADY,WAAW,QAgBtB;IAED,oBAsBC;IAED,cAEC;IAED,yBAEC;IAED,yBAUC;IAED;;;;aAQC;IAED;;aAGC;IAED;;;;qBAqBC;IAED,6BA8DC;IAED,aAMC;CACF;0BAlZyB,gBAAgB"}
|
package/blocks/Img/ImgBase.js
CHANGED
|
@@ -103,8 +103,8 @@ export class ImgBase extends ImgConfig {
|
|
|
103
103
|
createCdnUrl(
|
|
104
104
|
//
|
|
105
105
|
createOriginalUrl(this.$$('cdn-cname'), this.$$('uuid')),
|
|
106
|
-
cdnModifiers
|
|
107
|
-
)
|
|
106
|
+
cdnModifiers,
|
|
107
|
+
),
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -114,8 +114,8 @@ export class ImgBase extends ImgConfig {
|
|
|
114
114
|
createCdnUrl(
|
|
115
115
|
//
|
|
116
116
|
createOriginalUrl(this.$$('cdn-cname'), this.$$('uuid')),
|
|
117
|
-
cdnModifiers
|
|
118
|
-
)
|
|
117
|
+
cdnModifiers,
|
|
118
|
+
),
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -126,8 +126,8 @@ export class ImgBase extends ImgConfig {
|
|
|
126
126
|
//
|
|
127
127
|
this.$$('proxy-cname'),
|
|
128
128
|
cdnModifiers,
|
|
129
|
-
this._fmtAbs(this.$$('src'))
|
|
130
|
-
)
|
|
129
|
+
this._fmtAbs(this.$$('src')),
|
|
130
|
+
),
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -138,8 +138,8 @@ export class ImgBase extends ImgConfig {
|
|
|
138
138
|
//
|
|
139
139
|
`https://${this.$$('pubkey')}.ucr.io/`,
|
|
140
140
|
cdnModifiers,
|
|
141
|
-
this._fmtAbs(this.$$('src'))
|
|
142
|
-
)
|
|
141
|
+
this._fmtAbs(this.$$('src')),
|
|
142
|
+
),
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -157,7 +157,7 @@ export class ImgBase extends ImgConfig {
|
|
|
157
157
|
return applyTemplateData(
|
|
158
158
|
this.$$('secure-delivery-proxy'),
|
|
159
159
|
{ previewUrl: url },
|
|
160
|
-
{ transform: (value) => window.encodeURIComponent(value) }
|
|
160
|
+
{ transform: (value) => window.encodeURIComponent(value) },
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImgConfig.d.ts","sourceRoot":"","sources":["ImgConfig.js"],"names":[],"mappings":"AAUA;IAkFE,0CAEC
|
|
1
|
+
{"version":3,"file":"ImgConfig.d.ts","sourceRoot":"","sources":["ImgConfig.js"],"names":[],"mappings":"AAUA;IAkFE,0CAEC;;IAnFD,cAAqB;IAErB;;;OAGG;IACH,iBAFa,GAAG,CAIf;IAED,qDAAqD;IACrD,wBAIC;IAED;;;OAGG;IACH,yBAFW,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,QAW5B;IAED,0BAEC;IAED,8BAMC;IAED;;;OAGG;IACH,qBAHW,WAAW,SACX,MAAM,IAAI,QAsBpB;IAfC,eAAe;IACf,qBAOQ;IAGN,eAAe;IACf,kBAA0B;IAoB9B,oEAIC;CACF;8BArGmC,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurations.d.ts","sourceRoot":"","sources":["configurations.js"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"configurations.d.ts","sourceRoot":"","sources":["configurations.js"],"names":[],"mappings":"AAAA,uBAAwB,WAAW,CAAC;AACpC,8BAA+B,YAAY,CAAC;AAC5C,uBAAwB,CAAC,CAAC;AAC1B,0BAA2B,CAAC,CAAC;AAC7B,+BACuH;AAEvH,wBAAyB,IAAI,CAAC;AAC9B,4BAA6B,IAAI,CAAC;AAElC;;;GAGG"}
|
package/blocks/Modal/Modal.d.ts
CHANGED
|
@@ -27,12 +27,12 @@ export class Modal extends Block {
|
|
|
27
27
|
/** @private */
|
|
28
28
|
private _handleModalCloseAll;
|
|
29
29
|
handleModalOpen: ((data: {
|
|
30
|
-
id:
|
|
31
|
-
modal
|
|
30
|
+
id: import("../../abstract/ModalManager.js").ModalId;
|
|
31
|
+
modal: import("../../abstract/ModalManager.js").ModalNode;
|
|
32
32
|
}) => void) | undefined;
|
|
33
33
|
handleModalClose: ((data: {
|
|
34
|
-
id:
|
|
35
|
-
modal
|
|
34
|
+
id: import("../../abstract/ModalManager.js").ModalId;
|
|
35
|
+
modal: import("../../abstract/ModalManager.js").ModalNode;
|
|
36
36
|
}) => void) | undefined;
|
|
37
37
|
handleModalCloseAll: (() => void) | undefined;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["Modal.js"],"names":[],"mappings":"AAIA;IAEE,kCAAoC;IAIlC;;MAGC;IAGH,iCAEE;IAEF,yBAME;IAEF,+BAEE;IAEF,uBAAuB;IACvB,
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["Modal.js"],"names":[],"mappings":"AAIA;IAEE,kCAAoC;IAIlC;;MAGC;IAGH,iCAEE;IAEF,yBAME;IAEF,+BAEE;IAEF,uBAAuB;IACvB,yBAA0B,GADd,KACe,UAGzB;IAFA,eAAe;IACf,yBAAgC;IAGlC,uBAAuB;IACvB,uBAAwB,GADZ,KACa,UAIvB;IAEF,aAWC;IAED,aAOC;IAED;;;OAGG;IACH,yBAMC;IAED;;;OAGG;IACH,0BAIC;IAED,eAAe;IACf,6BAEC;IAmBC;;;4BAAuD;IACvD;;;4BAAyD;IACzD,8CAA+D;CAmBlE;;;;sBAnIqB,yBAAyB"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export class ProgressBar extends Block {
|
|
2
2
|
/** @type {Number} */
|
|
3
3
|
_value: number;
|
|
4
|
+
/** @type {Number} */
|
|
5
|
+
_prevValue: number;
|
|
4
6
|
/** @type {Boolean} */
|
|
5
7
|
_visible: boolean;
|
|
6
|
-
init$:
|
|
8
|
+
init$: {
|
|
9
|
+
width: number;
|
|
10
|
+
opacity: number;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
8
13
|
export namespace ProgressBar {
|
|
9
14
|
let template: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"AAGA;IACE,qBAAqB;IACrB,eAAW;IAEX,qBAAqB;IACrB,mBAAe;IAEf,sBAAsB;IACtB,kBAAgB;IAId;;;MAIC;CA4CJ;;;;sBA9DqB,yBAAyB"}
|