@uploadcare/file-uploader 1.15.0-alpha.0 → 1.15.0-alpha.10
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.js +1 -1
- package/abstract/Block.js +1 -1
- package/abstract/ModalManager.d.ts +23 -9
- package/abstract/ModalManager.d.ts.map +1 -1
- package/abstract/ModalManager.js +14 -9
- package/abstract/UploaderBlock.d.ts +1 -0
- package/abstract/UploaderBlock.d.ts.map +1 -1
- package/abstract/UploaderBlock.js +24 -1
- package/abstract/UploaderPublicApi.d.ts.map +1 -1
- package/abstract/UploaderPublicApi.js +1 -0
- package/blocks/Config/Config.d.ts +1 -1
- package/blocks/Config/Config.d.ts.map +1 -1
- package/blocks/Config/initialConfig.d.ts.map +1 -1
- package/blocks/Config/initialConfig.js +3 -2
- package/blocks/Config/normalizeConfigValue.d.ts +2 -1
- package/blocks/Config/normalizeConfigValue.d.ts.map +1 -1
- package/blocks/Config/normalizeConfigValue.js +18 -109
- package/blocks/Config/validatorsType.d.ts +37 -0
- package/blocks/Config/validatorsType.d.ts.map +1 -0
- package/blocks/Config/validatorsType.js +134 -0
- package/blocks/DropArea/DropArea.d.ts +1 -0
- package/blocks/DropArea/DropArea.d.ts.map +1 -1
- package/blocks/DropArea/DropArea.js +20 -2
- package/blocks/ExternalSource/ExternalSource.d.ts.map +1 -1
- package/blocks/ExternalSource/ExternalSource.js +0 -1
- package/blocks/FileItem/FileItem.d.ts +1 -1
- package/blocks/FileItem/FileItem.d.ts.map +1 -1
- package/blocks/FileItem/FileItem.js +30 -20
- package/blocks/FileItem/file-item.css +30 -0
- package/blocks/Modal/Modal.d.ts +21 -2
- package/blocks/Modal/Modal.d.ts.map +1 -1
- package/blocks/Modal/Modal.js +37 -20
- package/blocks/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/blocks/ProgressBar/ProgressBar.js +1 -0
- package/blocks/ProgressBar/progress-bar.css +1 -0
- package/blocks/SimpleBtn/SimpleBtn.js +1 -1
- package/blocks/Thumb/Thumb.d.ts +36 -0
- package/blocks/Thumb/Thumb.d.ts.map +1 -0
- package/blocks/Thumb/Thumb.js +84 -0
- package/blocks/Thumb/thumb.css +4 -0
- package/blocks/UploadList/UploadList.d.ts +2 -0
- package/blocks/UploadList/UploadList.d.ts.map +1 -1
- package/blocks/UploadList/UploadList.js +3 -1
- package/blocks/UploadList/upload-list.css +3 -2
- package/blocks/themes/uc-basic/common.css +1 -1
- package/blocks/themes/uc-basic/index.css +1 -0
- package/blocks/themes/uc-basic/theme.css +1 -2
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.ssr.d.ts +59 -0
- package/index.ssr.d.ts.map +1 -1
- package/index.ssr.js +79 -11
- package/package.json +1 -1
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts +35 -0
- package/solutions/file-uploader/minimal/FileUploaderMinimal.d.ts.map +1 -1
- package/solutions/file-uploader/minimal/FileUploaderMinimal.js +104 -15
- package/solutions/file-uploader/minimal/index.css +9 -27
- package/solutions/file-uploader/minimal/index.d.ts +1 -16
- package/solutions/file-uploader/minimal/index.js +1 -18
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts +1 -3
- package/solutions/file-uploader/regular/FileUploaderRegular.d.ts.map +1 -1
- package/solutions/file-uploader/regular/FileUploaderRegular.js +1 -15
- package/types/exported.d.ts +5 -2
- 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.css +1 -1
- package/web/uc-cloud-image-editor.min.js +4 -4
- 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
|
@@ -4,7 +4,7 @@ import { Data } from '@symbiotejs/symbiote';
|
|
|
4
4
|
import { ActivityBlock } from '../../abstract/ActivityBlock.js';
|
|
5
5
|
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
6
6
|
import { stringToArray } from '../../utils/stringToArray.js';
|
|
7
|
-
import { asBoolean } from '../Config/
|
|
7
|
+
import { asBoolean } from '../Config/validatorsType.js';
|
|
8
8
|
import { UploadSource } from '../utils/UploadSource.js';
|
|
9
9
|
import { DropzoneState, addDropzone } from './addDropzone.js';
|
|
10
10
|
|
|
@@ -24,6 +24,7 @@ export class DropArea extends UploaderBlock {
|
|
|
24
24
|
isFullscreen: false,
|
|
25
25
|
isEnabled: true,
|
|
26
26
|
isVisible: true,
|
|
27
|
+
isInitFlow: false,
|
|
27
28
|
text: '',
|
|
28
29
|
[REGISTRY_KEY]: null,
|
|
29
30
|
};
|
|
@@ -69,6 +70,12 @@ export class DropArea extends UploaderBlock {
|
|
|
69
70
|
this.set$({ isClickable: asBoolean(value) });
|
|
70
71
|
},
|
|
71
72
|
);
|
|
73
|
+
this.defineAccessor(
|
|
74
|
+
'initflow',
|
|
75
|
+
/** @param {unknown} value */ (value) => {
|
|
76
|
+
this.set$({ isInitFlow: asBoolean(value) });
|
|
77
|
+
},
|
|
78
|
+
);
|
|
72
79
|
this.defineAccessor(
|
|
73
80
|
'with-icon',
|
|
74
81
|
/** @param {unknown} value */ (value) => {
|
|
@@ -119,7 +126,6 @@ export class DropArea extends UploaderBlock {
|
|
|
119
126
|
this.set$({
|
|
120
127
|
'*currentActivity': ActivityBlock.activities.UPLOAD_LIST,
|
|
121
128
|
});
|
|
122
|
-
// this.setOrAddState('*modalActive', true);
|
|
123
129
|
}
|
|
124
130
|
},
|
|
125
131
|
});
|
|
@@ -174,9 +180,19 @@ export class DropArea extends UploaderBlock {
|
|
|
174
180
|
if (event.type === 'keydown') {
|
|
175
181
|
// @ts-ignore
|
|
176
182
|
if (event.code === 'Space' || event.code === 'Enter') {
|
|
183
|
+
if (this.$.isInitFlow) {
|
|
184
|
+
this.api.initFlow();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
177
188
|
this.api.openSystemDialog();
|
|
178
189
|
}
|
|
179
190
|
} else if (event.type === 'click') {
|
|
191
|
+
if (this.$.isInitFlow) {
|
|
192
|
+
this.api.initFlow();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
180
196
|
this.api.openSystemDialog();
|
|
181
197
|
}
|
|
182
198
|
};
|
|
@@ -271,4 +287,6 @@ DropArea.bindAttributes({
|
|
|
271
287
|
fullscreen: null,
|
|
272
288
|
// @ts-expect-error TODO: fix types inside symbiote
|
|
273
289
|
disabled: null,
|
|
290
|
+
// @ts-expect-error TODO: fix types inside symbiote
|
|
291
|
+
initflow: null,
|
|
274
292
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalSource.d.ts","sourceRoot":"","sources":["ExternalSource.js"],"names":[],"mappings":"AAWA,+DAA+D;AAE/D;IAEE,yBAAiD;IAK/C;;;QAKE,6FAA6F;sBAAlF,OAAO,YAAY,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;MAkC1F;IAGH,6BAA6B;IAC7B,qCAMC;
|
|
1
|
+
{"version":3,"file":"ExternalSource.d.ts","sourceRoot":"","sources":["ExternalSource.js"],"names":[],"mappings":"AAWA,+DAA+D;AAE/D;IAEE,yBAAiD;IAK/C;;;QAKE,6FAA6F;sBAAlF,OAAO,YAAY,EAAE,eAAe,CAAC,uBAAuB,CAAC,CAAC,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;MAkC1F;IAGH,6BAA6B;IAC7B,qCAMC;IAgDD;;;OAGG;IACH,mCAcC;IAED;;;OAGG;IACH,kCAsBC;IAED,eAAe;IACf,yBAIC;IAED,eAAe;IACf,mBAKC;IAED;;;OAGG;IACH,sBAKC;IAED,eAAe;IACf,kBAKC;IAED,eAAe;IACf,kBAeC;IAED,eAAe;IACf,oBA6BC;IALC,eAAe;IACf,uBAA6D;IAM/D,eAAe;IACf,sBAMC;IAED,eAAe;IACf,6BASC;CACF;;;;6BAlQa;IAAE,kBAAkB,EAAE,MAAM,CAAA;CAAE;8BAPd,iCAAiC"}
|
|
@@ -78,7 +78,6 @@ export class ExternalSource extends UploaderBlock {
|
|
|
78
78
|
if (!externalSourceType) {
|
|
79
79
|
this.modalManager.close(this.$['*currentActivity']);
|
|
80
80
|
this.$['*currentActivity'] = null;
|
|
81
|
-
// this.setOrAddState('*modalActive', false);
|
|
82
81
|
console.error(`Param "externalSourceType" is required for activity "${this.activityType}"`);
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["FileItem.js"],"names":[],"mappings":"AAoBA;IAIE,eAAe;IACf,mBAAuB;IACvB;;;OAGG;IACH,eAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,gCAA4E;IAC5E,eAAe;IACf,iCAA0E;IAE1E,eAAe;IACf,sBAAsB;IAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+BC;IAGH,eASC;IAED;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"FileItem.d.ts","sourceRoot":"","sources":["FileItem.js"],"names":[],"mappings":"AAoBA;IAIE,eAAe;IACf,mBAAuB;IACvB;;;OAGG;IACH,eAAc;IACd,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,gCAA4E;IAC5E,eAAe;IACf,iCAA0E;IAE1E,eAAe;IACf,sBAAsB;IAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA+BC;IAGH,eASC;IAED;;;OAGG;IACH,0BAeC;IAXC,wCAA0C;IAa5C,eAAe;IACf,wBAgBC;IAED,eAAe;IACf,2BAuCC;IAED;;;;OAIG;IACH,kBAUC;IAED;;MAaQ;IAER;;;OAGG;IACH,uBAmDC;IAyDD,wEAAwE;IACxE,oBADY,CAAC,oBAAoB,CAAC,CAAC,MAAM,oBAAoB,CAAC,QA0B7D;IAaC,eAAe;IACf,kBAEE;IAWJ;;;MAEC;IAED;;;OAGG;IACH,uBAEC;IAED,wBAsFC;CACF;;;;;8BA/c6B,iCAAiC;AAS/D;;;;;GAKG"}
|
|
@@ -57,7 +57,7 @@ export class FileItem extends UploaderBlock {
|
|
|
57
57
|
isUploading: false,
|
|
58
58
|
isFocused: false,
|
|
59
59
|
isEditable: false,
|
|
60
|
-
|
|
60
|
+
showFileNames: false,
|
|
61
61
|
state: FileItemState.IDLE,
|
|
62
62
|
ariaLabelStatusFile: '',
|
|
63
63
|
onEdit: () => {
|
|
@@ -93,6 +93,7 @@ export class FileItem extends UploaderBlock {
|
|
|
93
93
|
*/
|
|
94
94
|
_observerCallback(entries) {
|
|
95
95
|
let [entry] = entries;
|
|
96
|
+
|
|
96
97
|
this._isIntersecting = entry.isIntersecting;
|
|
97
98
|
this._thumbRect = entry.boundingClientRect;
|
|
98
99
|
|
|
@@ -100,11 +101,11 @@ export class FileItem extends UploaderBlock {
|
|
|
100
101
|
this.render();
|
|
101
102
|
this._renderedOnce = true;
|
|
102
103
|
}
|
|
103
|
-
if (entry.intersectionRatio === 0) {
|
|
104
|
-
|
|
105
|
-
} else {
|
|
106
|
-
|
|
107
|
-
}
|
|
104
|
+
// if (entry.intersectionRatio === 0) {
|
|
105
|
+
// this._debouncedGenerateThumb.cancel();
|
|
106
|
+
// } else {
|
|
107
|
+
// this._debouncedGenerateThumb();
|
|
108
|
+
// }
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/** @private */
|
|
@@ -154,10 +155,6 @@ export class FileItem extends UploaderBlock {
|
|
|
154
155
|
return;
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
if (entry.getValue('thumbUrl')) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
158
|
if (entry.getValue('file')?.type.includes('image')) {
|
|
162
159
|
try {
|
|
163
160
|
let thumbUrl = await generateThumb(entry.getValue('file'), this.cfg.thumbSize);
|
|
@@ -273,14 +270,26 @@ export class FileItem extends UploaderBlock {
|
|
|
273
270
|
});
|
|
274
271
|
|
|
275
272
|
this.subConfigValue('useCloudImageEditor', () => this._debouncedCalculateState());
|
|
276
|
-
this.subConfigValue('
|
|
277
|
-
if (
|
|
278
|
-
this
|
|
273
|
+
this.subConfigValue('filesViewMode', (mode) => {
|
|
274
|
+
if (this.cfg.filesViewMode === 'grid') {
|
|
275
|
+
this.$.showFileNames = this.cfg.gridShowFileNames;
|
|
276
|
+
}
|
|
277
|
+
if (this.cfg.filesViewMode === 'list') {
|
|
278
|
+
this.$.showFileNames = true;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
this.setAttribute('mode', mode);
|
|
282
282
|
});
|
|
283
283
|
|
|
284
|
+
this.subConfigValue('gridShowFileNames', (value) => {
|
|
285
|
+
if (this.cfg.filesViewMode === 'grid') {
|
|
286
|
+
this.$.showFileNames = value;
|
|
287
|
+
}
|
|
288
|
+
if (this.cfg.filesViewMode === 'list') {
|
|
289
|
+
this.$.showFileNames = true;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
284
293
|
this.onclick = () => {
|
|
285
294
|
FileItem.activeInstances.forEach((inst) => {
|
|
286
295
|
if (inst === this) {
|
|
@@ -460,13 +469,10 @@ export class FileItem extends UploaderBlock {
|
|
|
460
469
|
|
|
461
470
|
FileItem.template = /* HTML */ `
|
|
462
471
|
<div class="uc-inner" set="@finished: isFinished; @uploading: isUploading; @failed: isFailed; @focused: isFocused">
|
|
463
|
-
<
|
|
464
|
-
|
|
465
|
-
<uc-icon set="@name: badgeIcon"></uc-icon>
|
|
466
|
-
</div>
|
|
467
|
-
</div>
|
|
472
|
+
<uc-thumb set="uid:uid;thumbUrl:thumbUrl;badgeIcon:badgeIcon"></uc-thumb>
|
|
473
|
+
|
|
468
474
|
<div aria-atomic="true" aria-live="polite" class="uc-file-name-wrapper" set="@aria-label:ariaLabelStatusFile;">
|
|
469
|
-
<span class="uc-file-name" set="@hidden:
|
|
475
|
+
<span class="uc-file-name" set="@hidden: !showFileNames">{{itemName}}</span>
|
|
470
476
|
<span class="uc-file-error" set="@hidden: !errorText;">{{errorText}}</span>
|
|
471
477
|
<span class="uc-file-hint" set="@hidden: !hint">{{hint}}</span>
|
|
472
478
|
</div>
|
|
@@ -491,7 +497,11 @@ FileItem.template = /* HTML */ `
|
|
|
491
497
|
<uc-icon name="upload"></uc-icon>
|
|
492
498
|
</button>
|
|
493
499
|
</div>
|
|
494
|
-
<uc-progress-bar
|
|
500
|
+
<uc-progress-bar
|
|
501
|
+
class="uc-progress-bar"
|
|
502
|
+
set="value: progressValue; visible: progressVisible; @hasFileName: showFileNames"
|
|
503
|
+
>
|
|
504
|
+
</uc-progress-bar>
|
|
495
505
|
</div>
|
|
496
506
|
`;
|
|
497
507
|
FileItem.activeInstances = new Set();
|
|
@@ -202,3 +202,33 @@ uc-file-item[mode='grid'] .uc-file-actions {
|
|
|
202
202
|
uc-file-item[mode='grid'] button {
|
|
203
203
|
background-color: var(--uc-background);
|
|
204
204
|
}
|
|
205
|
+
|
|
206
|
+
uc-file-item[mode='grid'] button:hover {
|
|
207
|
+
background-color: var(--uc-muted);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
uc-file-item[mode='grid'] .uc-progress-bar {
|
|
211
|
+
width: initial;
|
|
212
|
+
height: 4px !important;
|
|
213
|
+
opacity: 1;
|
|
214
|
+
top: initial !important;
|
|
215
|
+
bottom: var(--uc-padding);
|
|
216
|
+
left: var(--uc-padding);
|
|
217
|
+
right: var(--uc-padding);
|
|
218
|
+
border-radius: var(--uc-radius);
|
|
219
|
+
background-color: var(--uc-background);
|
|
220
|
+
z-index: 1;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
uc-file-item[mode='grid'] .uc-progress-bar.uc-progress-bar--hidden {
|
|
224
|
+
opacity: 0;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
uc-file-item[mode='grid'] .uc-progress-bar[hasfilename] {
|
|
228
|
+
bottom: calc(var(--uc-padding) + var(--uc-font-size));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
uc-file-item[mode='grid'] .uc-progress-bar .uc-progress {
|
|
232
|
+
background-color: var(--uc-primary);
|
|
233
|
+
opacity: 0.7;
|
|
234
|
+
}
|
package/blocks/Modal/Modal.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export class Modal extends Block {
|
|
2
2
|
static StateConsumerScope: string;
|
|
3
3
|
init$: {
|
|
4
|
-
'*modalActive': boolean;
|
|
5
|
-
isOpen: boolean;
|
|
6
4
|
closeClicked: () => void;
|
|
7
5
|
};
|
|
8
6
|
_handleBackdropClick: () => void;
|
|
@@ -16,6 +14,27 @@ export class Modal extends Block {
|
|
|
16
14
|
_handleDialogMouseUp: (e: Event) => void;
|
|
17
15
|
show(): void;
|
|
18
16
|
hide(): void;
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
* @type {import('../../abstract/ModalManager.js').ModalCb}
|
|
20
|
+
*/
|
|
21
|
+
private _handleModalOpen;
|
|
22
|
+
/**
|
|
23
|
+
* @private
|
|
24
|
+
* @type {import('../../abstract/ModalManager.js').ModalCb}
|
|
25
|
+
*/
|
|
26
|
+
private _handleModalClose;
|
|
27
|
+
/** @private */
|
|
28
|
+
private _handleModalCloseAll;
|
|
29
|
+
handleModalOpen: ((data: {
|
|
30
|
+
id: string;
|
|
31
|
+
modal?: Modal | undefined;
|
|
32
|
+
}) => void) | undefined;
|
|
33
|
+
handleModalClose: ((data: {
|
|
34
|
+
id: string;
|
|
35
|
+
modal?: Modal | undefined;
|
|
36
|
+
}) => void) | undefined;
|
|
37
|
+
handleModalCloseAll: (() => void) | undefined;
|
|
19
38
|
}
|
|
20
39
|
export namespace Modal {
|
|
21
40
|
let template: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["Modal.js"],"names":[],"mappings":"AAIA;IAEE,kCAAoC;IAIlC
|
|
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,4BADY,KAAK,UAIf;IAFA,eAAe;IACf,yBAAgC;IAGlC,uBAAuB;IACvB,0BADY,KAAK,UAKf;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"}
|
package/blocks/Modal/Modal.js
CHANGED
|
@@ -10,8 +10,6 @@ export class Modal extends Block {
|
|
|
10
10
|
super();
|
|
11
11
|
this.init$ = {
|
|
12
12
|
...this.init$,
|
|
13
|
-
'*modalActive': false,
|
|
14
|
-
isOpen: false,
|
|
15
13
|
closeClicked: this._handleDialogClose,
|
|
16
14
|
};
|
|
17
15
|
}
|
|
@@ -21,8 +19,6 @@ export class Modal extends Block {
|
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
_closeDialog = () => {
|
|
24
|
-
// this.setOrAddState('*modalActive', false);
|
|
25
|
-
|
|
26
22
|
this.modalManager?.close(this.id);
|
|
27
23
|
|
|
28
24
|
if (!this.modalManager.hasActiveModals) {
|
|
@@ -69,6 +65,33 @@ export class Modal extends Block {
|
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @private
|
|
70
|
+
* @type {import('../../abstract/ModalManager.js').ModalCb}
|
|
71
|
+
*/
|
|
72
|
+
_handleModalOpen({ id }) {
|
|
73
|
+
if (id === this.id) {
|
|
74
|
+
this.show();
|
|
75
|
+
} else {
|
|
76
|
+
this.hide();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @private
|
|
82
|
+
* @type {import('../../abstract/ModalManager.js').ModalCb}
|
|
83
|
+
*/
|
|
84
|
+
_handleModalClose({ id }) {
|
|
85
|
+
if (id === this.id) {
|
|
86
|
+
this.hide();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @private */
|
|
91
|
+
_handleModalCloseAll() {
|
|
92
|
+
this.hide();
|
|
93
|
+
}
|
|
94
|
+
|
|
72
95
|
initCallback() {
|
|
73
96
|
super.initCallback();
|
|
74
97
|
|
|
@@ -86,23 +109,13 @@ export class Modal extends Block {
|
|
|
86
109
|
}
|
|
87
110
|
});
|
|
88
111
|
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} else {
|
|
93
|
-
this.hide();
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
this.modalManager.subscribe(ModalEvents.CLOSE, (/** @type {{ id: string }} */ { id }) => {
|
|
98
|
-
if (id === this.id) {
|
|
99
|
-
this.hide();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
112
|
+
this.handleModalOpen = this._handleModalOpen.bind(this);
|
|
113
|
+
this.handleModalClose = this._handleModalClose.bind(this);
|
|
114
|
+
this.handleModalCloseAll = this._handleModalCloseAll.bind(this);
|
|
102
115
|
|
|
103
|
-
this.modalManager.subscribe(ModalEvents.
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
this.modalManager.subscribe(ModalEvents.OPEN, this.handleModalOpen);
|
|
117
|
+
this.modalManager.subscribe(ModalEvents.CLOSE, this.handleModalClose);
|
|
118
|
+
this.modalManager.subscribe(ModalEvents.CLOSE_ALL, this.handleModalCloseAll);
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
destroyCallback() {
|
|
@@ -112,6 +125,10 @@ export class Modal extends Block {
|
|
|
112
125
|
this.ref.dialog.removeEventListener('close', this._handleDialogClose);
|
|
113
126
|
this.ref.dialog.removeEventListener('mousedown', this._handleDialogMouseDown);
|
|
114
127
|
this.ref.dialog.removeEventListener('mouseup', this._handleDialogMouseUp);
|
|
128
|
+
|
|
129
|
+
this.modalManager.unsubscribe(ModalEvents.OPEN, this.handleModalOpen);
|
|
130
|
+
this.modalManager.unsubscribe(ModalEvents.CLOSE, this.handleModalClose);
|
|
131
|
+
this.modalManager.unsubscribe(ModalEvents.CLOSE_ALL, this.handleModalCloseAll);
|
|
115
132
|
}
|
|
116
133
|
}
|
|
117
134
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"AAEA;IACE,qBAAqB;IACrB,eAAW;IAEX,sBAAsB;IACtB,kBAAgB;IAEhB,WAIE;
|
|
1
|
+
{"version":3,"file":"ProgressBar.d.ts","sourceRoot":"","sources":["ProgressBar.js"],"names":[],"mappings":"AAEA;IACE,qBAAqB;IACrB,eAAW;IAEX,sBAAsB;IACtB,kBAAgB;IAEhB,WAIE;CA+CH;;;;sBA5DqB,yBAAyB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
3
|
-
import { asBoolean } from '../Config/
|
|
3
|
+
import { asBoolean } from '../Config/validatorsType.js';
|
|
4
4
|
|
|
5
5
|
export class SimpleBtn extends UploaderBlock {
|
|
6
6
|
static styleAttrs = [...super.styleAttrs, 'uc-simple-btn'];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class Thumb extends UploaderBlock {
|
|
2
|
+
_debouncedGenerateThumb: (() => Promise<void>) & {
|
|
3
|
+
cancel: () => void;
|
|
4
|
+
};
|
|
5
|
+
init$: {
|
|
6
|
+
thumbUrl: string;
|
|
7
|
+
badgeIcon: string;
|
|
8
|
+
uid: string;
|
|
9
|
+
'*commonProgress': number;
|
|
10
|
+
'*uploadList': never[];
|
|
11
|
+
'*uploadQueue': import("@uploadcare/upload-client").Queue;
|
|
12
|
+
'*collectionErrors': any[];
|
|
13
|
+
'*collectionState': import("../../index.js").OutputCollectionState<import("../../index.js").OutputCollectionStatus, "maybe-has-group"> | null;
|
|
14
|
+
'*groupInfo': import("@uploadcare/upload-client").UploadcareGroup | null;
|
|
15
|
+
'*uploadTrigger': Set<string>;
|
|
16
|
+
'*secureUploadsManager': import("../../abstract/SecureUploadsManager.js").SecureUploadsManager | null;
|
|
17
|
+
'*currentActivity': null;
|
|
18
|
+
'*currentActivityParams': {};
|
|
19
|
+
'*history': never[];
|
|
20
|
+
'*historyBack': null;
|
|
21
|
+
'*closeModal': () => void;
|
|
22
|
+
};
|
|
23
|
+
/** @private */
|
|
24
|
+
private _generateThumbnail;
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @param {IntersectionObserverEntry[]} entries
|
|
28
|
+
*/
|
|
29
|
+
private _observerCallback;
|
|
30
|
+
_observer: IntersectionObserver | undefined;
|
|
31
|
+
}
|
|
32
|
+
export namespace Thumb {
|
|
33
|
+
let template: string;
|
|
34
|
+
}
|
|
35
|
+
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
36
|
+
//# sourceMappingURL=Thumb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thumb.d.ts","sourceRoot":"","sources":["Thumb.js"],"names":[],"mappings":"AAKA;IACE;;MAA4E;IAK1E;;;;;;;;;;;;;;;;;MAKC;IAGH,eAAe;IACf,2BAEC;IAED;;;OAGG;IACH,0BAUC;IAkBC,4CAAuG;CAU1G;;;;8BAhE6B,iCAAiC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//@ts-check
|
|
2
|
+
|
|
3
|
+
import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
4
|
+
import { debounce } from '../utils/debounce.js';
|
|
5
|
+
|
|
6
|
+
export class Thumb extends UploaderBlock {
|
|
7
|
+
_debouncedGenerateThumb = debounce(this._generateThumbnail.bind(this), 100);
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.init$ = {
|
|
13
|
+
...this.init$,
|
|
14
|
+
thumbUrl: '',
|
|
15
|
+
badgeIcon: '',
|
|
16
|
+
uid: '',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @private */
|
|
21
|
+
async _generateThumbnail() {
|
|
22
|
+
console.log('Generating thumbnail for', this.$.uid);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @private
|
|
27
|
+
* @param {IntersectionObserverEntry[]} entries
|
|
28
|
+
*/
|
|
29
|
+
_observerCallback(entries) {
|
|
30
|
+
const [entry] = entries;
|
|
31
|
+
if (entry.isIntersecting) {
|
|
32
|
+
this._debouncedGenerateThumb();
|
|
33
|
+
this._observer?.disconnect();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (entry.intersectionRatio === 0) {
|
|
37
|
+
this._debouncedGenerateThumb.cancel();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
initCallback() {
|
|
42
|
+
super.initCallback();
|
|
43
|
+
|
|
44
|
+
this.defineAccessor('thumbUrl', (/** @type {string} */ val) => (this.$.thumbUrl = val));
|
|
45
|
+
this.defineAccessor('badgeIcon', (/** @type {string} */ val) => (this.$.badgeIcon = val));
|
|
46
|
+
|
|
47
|
+
this.defineAccessor('uid', (/** @type {string} */ value) => {
|
|
48
|
+
this.set$({ uid: value });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.setAttribute('role', 'img');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
super.connectedCallback();
|
|
56
|
+
|
|
57
|
+
this._observer = new window.IntersectionObserver(this._observerCallback.bind(this), { threshold: 0.1 });
|
|
58
|
+
|
|
59
|
+
this._observer.observe(this);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
disconnectedCallback() {
|
|
63
|
+
super.disconnectedCallback();
|
|
64
|
+
|
|
65
|
+
this._observer?.disconnect();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Thumb.template = /* html */ `
|
|
70
|
+
<div class="uc-thumb" set="style.backgroundImage: thumbUrl">
|
|
71
|
+
<div class="uc-badge">
|
|
72
|
+
<uc-icon set="@name: badgeIcon"></uc-icon>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
Thumb.bindAttributes({
|
|
78
|
+
// @ts-expect-error TODO: fix types inside symbiote
|
|
79
|
+
thumbUrl: null,
|
|
80
|
+
// @ts-expect-error TODO: fix types inside symbiote
|
|
81
|
+
badgeIcon: null,
|
|
82
|
+
// @ts-expect-error TODO: fix types inside symbiote
|
|
83
|
+
uid: null,
|
|
84
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @typedef {'grid' | 'list'} FilesViewMode */
|
|
1
2
|
/**
|
|
2
3
|
* @typedef {{
|
|
3
4
|
* total: number;
|
|
@@ -48,6 +49,7 @@ export class UploadList extends UploaderBlock {
|
|
|
48
49
|
export namespace UploadList {
|
|
49
50
|
let template: string;
|
|
50
51
|
}
|
|
52
|
+
export type FilesViewMode = 'grid' | 'list';
|
|
51
53
|
export type Summary = {
|
|
52
54
|
total: number;
|
|
53
55
|
succeed: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadList.d.ts","sourceRoot":"","sources":["UploadList.js"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AAEH;IAKE,4BAAoD;IAKlD;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BC;IAGH,eAAe;IACf,yCASQ;IAER,eAAe;IACf,4BAuCC;IAED;;;OAGG;IACH,uBAmBC;CAwEF;;;;
|
|
1
|
+
{"version":3,"file":"UploadList.d.ts","sourceRoot":"","sources":["UploadList.js"],"names":[],"mappings":"AAMA,+CAA+C;AAE/C;;;;;;;GAOG;AAEH;IAKE,4BAAoD;IAKlD;;;;;;;;;;;;;;;;;;;;;;;;;;MA0BC;IAGH,eAAe;IACf,yCASQ;IAER,eAAe;IACf,4BAuCC;IAED;;;OAGG;IACH,uBAmBC;CAwEF;;;;4BAvMa,MAAM,GAAG,MAAM;sBAGhB;IACZ,KAAS,EAAE,MAAM,CAAC;IAClB,OAAW,EAAE,MAAM,CAAC;IACpB,SAAa,EAAE,MAAM,CAAC;IACtB,MAAU,EAAE,MAAM,CAAC;CAChB;8BAZ0B,iCAAiC"}
|
|
@@ -4,6 +4,8 @@ import { UploaderBlock } from '../../abstract/UploaderBlock.js';
|
|
|
4
4
|
import { EventType } from '../UploadCtxProvider/EventEmitter.js';
|
|
5
5
|
import { throttle } from '../utils/throttle.js';
|
|
6
6
|
|
|
7
|
+
/** @typedef {'grid' | 'list'} FilesViewMode */
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @typedef {{
|
|
9
11
|
* total: number;
|
|
@@ -149,7 +151,7 @@ export class UploadList extends UploaderBlock {
|
|
|
149
151
|
}
|
|
150
152
|
});
|
|
151
153
|
|
|
152
|
-
this.subConfigValue('
|
|
154
|
+
this.subConfigValue('filesViewMode', (mode) => {
|
|
153
155
|
this.setAttribute('mode', mode);
|
|
154
156
|
});
|
|
155
157
|
|
|
@@ -77,9 +77,10 @@ uc-upload-list[mode='grid'] .uc-files {
|
|
|
77
77
|
|
|
78
78
|
uc-upload-list .uc-files .uc-add-more-btn,
|
|
79
79
|
uc-upload-list[mode='grid'] uc-file-item {
|
|
80
|
-
|
|
80
|
+
flex: 0 0 calc((100% - (var(--uc-grid-gap) * (var(--uc-grid-col) - 1))) / var(--uc-grid-col));
|
|
81
|
+
max-width: calc((100% - (var(--uc-grid-gap) * (var(--uc-grid-col) - 1))) / var(--uc-grid-col));
|
|
81
82
|
height: var(--uc-grid-preview-image-height);
|
|
82
|
-
aspect-ratio:
|
|
83
|
+
aspect-ratio: var(--uc-grid-aspect-ratio);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
uc-upload-list .uc-files .uc-add-more-btn {
|
|
@@ -18,10 +18,9 @@
|
|
|
18
18
|
--uc-simple-btn-padding: 7px 14px;
|
|
19
19
|
|
|
20
20
|
--uc-grid-col: 3;
|
|
21
|
-
|
|
22
|
-
/* --uc-grid-preview-image-width: 200px; */
|
|
23
21
|
--uc-grid-preview-image-height: auto;
|
|
24
22
|
--uc-grid-gap: calc(var(--uc-padding) / 2);
|
|
23
|
+
--uc-grid-aspect-ratio: 1 / 1;
|
|
25
24
|
|
|
26
25
|
/* Default colors, in case of media query failure */
|
|
27
26
|
--uc-background: var(--uc-background-light);
|
package/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export { ActivityHeader } from "./blocks/ActivityHeader/ActivityHeader.js";
|
|
|
28
28
|
export { Select } from "./blocks/Select/Select.js";
|
|
29
29
|
export { Copyright } from "./blocks/Copyright/Copyright.js";
|
|
30
30
|
export { Spinner } from "./blocks/Spinner/Spinner.js";
|
|
31
|
+
export { Thumb } from "./blocks/Thumb/Thumb.js";
|
|
31
32
|
export { FileUploaderRegular } from "./solutions/file-uploader/regular/FileUploaderRegular.js";
|
|
32
33
|
export { FileUploaderMinimal } from "./solutions/file-uploader/minimal/FileUploaderMinimal.js";
|
|
33
34
|
export { FileUploaderInline } from "./solutions/file-uploader/inline/FileUploaderInline.js";
|
|
@@ -36,6 +37,7 @@ export { defineComponents } from "./abstract/defineComponents.js";
|
|
|
36
37
|
export { defineLocale } from "./abstract/localeRegistry.js";
|
|
37
38
|
export { loadFileUploaderFrom } from "./abstract/loadFileUploaderFrom.js";
|
|
38
39
|
export { toKebabCase } from "./utils/toKebabCase.js";
|
|
40
|
+
export { ModalEvents } from "./abstract/ModalManager.js";
|
|
39
41
|
export { BaseComponent, Data, UID } from "@symbiotejs/symbiote";
|
|
40
42
|
export { UploadSource, ExternalUploadSource } from "./blocks/utils/UploadSource.js";
|
|
41
43
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export { ActivityHeader } from './blocks/ActivityHeader/ActivityHeader.js';
|
|
|
33
33
|
export { Select } from './blocks/Select/Select.js';
|
|
34
34
|
export { Copyright } from './blocks/Copyright/Copyright.js';
|
|
35
35
|
export { Spinner } from './blocks/Spinner/Spinner.js';
|
|
36
|
+
export { Thumb } from './blocks/Thumb/Thumb.js';
|
|
36
37
|
|
|
37
38
|
// Solutions:
|
|
38
39
|
export { FileUploaderRegular } from './solutions/file-uploader/regular/FileUploaderRegular.js';
|
|
@@ -46,6 +47,7 @@ export { defineLocale } from './abstract/localeRegistry.js';
|
|
|
46
47
|
export { loadFileUploaderFrom } from './abstract/loadFileUploaderFrom.js';
|
|
47
48
|
export { toKebabCase } from './utils/toKebabCase.js';
|
|
48
49
|
export { UploadSource, ExternalUploadSource } from './blocks/utils/UploadSource.js';
|
|
50
|
+
export { ModalEvents } from './abstract/ModalManager.js';
|
|
49
51
|
|
|
50
52
|
export * from './env.js';
|
|
51
53
|
|