@masterteam/components 0.0.225 → 0.0.226
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/assets/i18n/ar.json +2 -0
- package/assets/i18n/en.json +2 -0
- package/fesm2022/masterteam-components-business-fields.mjs +4 -4
- package/fesm2022/masterteam-components-business-fields.mjs.map +1 -1
- package/fesm2022/masterteam-components-entities.mjs +4 -4
- package/fesm2022/masterteam-components-entities.mjs.map +1 -1
- package/fesm2022/masterteam-components-field-validation.mjs.map +1 -1
- package/fesm2022/masterteam-components-sidebar.mjs +2 -2
- package/fesm2022/masterteam-components-sidebar.mjs.map +1 -1
- package/fesm2022/masterteam-components-table.mjs.map +1 -1
- package/fesm2022/masterteam-components-textarea-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-treeselect-field.mjs +2 -2
- package/fesm2022/masterteam-components-treeselect-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-upload-field.mjs +97 -46
- package/fesm2022/masterteam-components-upload-field.mjs.map +1 -1
- package/fesm2022/masterteam-components-uploader.mjs +399 -0
- package/fesm2022/masterteam-components-uploader.mjs.map +1 -0
- package/package.json +5 -1
- package/types/masterteam-components-table.d.ts +2 -2
- package/types/masterteam-components-upload-field.d.ts +8 -8
- package/types/masterteam-components-uploader.d.ts +53 -0
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ChangeDetectorRef, Pipe, input, output, model, computed, Component, signal } from '@angular/core';
|
|
2
|
+
import { inject, ChangeDetectorRef, Pipe, input, output, model, computed, Component, signal, DestroyRef, effect } from '@angular/core';
|
|
3
3
|
import { Button } from '@masterteam/components/button';
|
|
4
4
|
import { map, tap, finalize, shareReplay, distinctUntilChanged, switchMap, filter, catchError } from 'rxjs/operators';
|
|
5
5
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
6
|
-
import { Subscription, BehaviorSubject, of, finalize as finalize$1,
|
|
6
|
+
import { Subscription, BehaviorSubject, of, take, finalize as finalize$1, forkJoin, map as map$1, catchError as catchError$1 } from 'rxjs';
|
|
7
7
|
import { HttpClient, HttpContext } from '@angular/common/http';
|
|
8
8
|
import { Avatar } from '@masterteam/components/avatar';
|
|
9
9
|
import * as i1 from '@jsverse/transloco';
|
|
10
10
|
import { TranslocoModule, TranslocoService } from '@jsverse/transloco';
|
|
11
11
|
import { Tooltip } from '@masterteam/components/tooltip';
|
|
12
12
|
import { Icon } from '@masterteam/icons';
|
|
13
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
13
14
|
import { Validators, NgControl } from '@angular/forms';
|
|
14
15
|
import { FieldValidation } from '@masterteam/components/field-validation';
|
|
15
16
|
import { Card } from '@masterteam/components/card';
|
|
16
17
|
import { ConfirmationService } from '@masterteam/components/confirmation';
|
|
18
|
+
import { UploaderService, UploaderPolicyError } from '@masterteam/components/uploader';
|
|
17
19
|
|
|
18
20
|
class SecureImagePipe {
|
|
19
21
|
static cachedBlobUrls = new Map();
|
|
@@ -272,14 +274,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
272
274
|
args: [{ selector: 'mt-upload-user-preview', standalone: true, imports: [Icon, SecureImagePipe, Button, Icon, Avatar, TranslocoModule], template: "<div\r\n class=\"rounded-full p-1 w-fit\"\r\n [style.background]=\"\r\n 'conic-gradient(var(--p-primary-300) ' +\r\n uploadProgress() +\r\n '%, transparent ' +\r\n uploadProgress() +\r\n '%)'\r\n \"\r\n>\r\n <div\r\n class=\"relative rounded-full w-fit border-2 border-dashed border-gray-300 bg-white\"\r\n [class.opacity-50]=\"isDragging()\"\r\n >\r\n <mt-avatar\r\n [size]=\"size()\"\r\n [image]=\"imgPath() ? (imgPath() | secureImage: context()) : ''\"\r\n [icon]=\"defaultIcon()\"\r\n [styleClass]=\"userImgClass()\"\r\n >\r\n </mt-avatar>\r\n\r\n @if (!loading()) {\r\n <div\r\n class=\"absolute inset-0 flex items-center justify-center rounded-full bg-surface-400/50 opacity-0 hover:opacity-100 transition-opacity\"\r\n [class]=\"!imgPath() && !disabled() ? 'cursor-pointer' : ''\"\r\n (click)=\"OnUploadInputClicked()\"\r\n (dragover)=\"OnDragOver($event)\"\r\n (dragleave)=\"OnDragLeave($event)\"\r\n (drop)=\"OnDrop($event)\"\r\n >\r\n @if (!disabled() && !!imgPath()) {\r\n <mt-button\r\n variant=\"text\"\r\n icon=\"general.download-01\"\r\n [tooltip]=\"'components.upload.download' | transloco\"\r\n (onClick)=\"ondDownloadFile.emit(value())\"\r\n >\r\n </mt-button>\r\n <mt-button\r\n variant=\"text\"\r\n icon=\"general.trash-01\"\r\n [tooltip]=\"'components.upload.delete' | transloco\"\r\n severity=\"danger\"\r\n (onClick)=\"onDeleteFile.emit($event)\"\r\n >\r\n </mt-button>\r\n }\r\n @if (!imgPath() && !disabled()) {\r\n <mt-icon\r\n icon=\"general.upload-01\"\r\n class=\"text-primary-400 text-xl\"\r\n ></mt-icon>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div\r\n class=\"absolute inset-0 flex items-center justify-center rounded-full bg-surface-400/50\"\r\n >\r\n @if (uploadProgress() === 100) {\r\n <mt-icon\r\n icon=\"general.check\"\r\n class=\"text-primary-400 text-2xl\"\r\n ></mt-icon>\r\n } @else {\r\n <small class=\"text-primary-300 font-bold text-lg\">{{\r\n uploadProgress() + \"%\"\r\n }}</small>\r\n }\r\n </div>\r\n }\r\n </div>\r\n</div>\r\n" }]
|
|
273
275
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], imgPath: [{ type: i0.Input, args: [{ isSignal: true, alias: "imgPath", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], uploadProgress: [{ type: i0.Input, args: [{ isSignal: true, alias: "uploadProgress", required: false }] }], isDragging: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDragging", required: false }] }], onUploadInputClicked: [{ type: i0.Output, args: ["onUploadInputClicked"] }], ondDownloadFile: [{ type: i0.Output, args: ["ondDownloadFile"] }], onDeleteFile: [{ type: i0.Output, args: ["onDeleteFile"] }], onDragOver: [{ type: i0.Output, args: ["onDragOver"] }], onDragLeave: [{ type: i0.Output, args: ["onDragLeave"] }], onDrop: [{ type: i0.Output, args: ["onDrop"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userImgClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "userImgClass", required: false }] }] } });
|
|
274
276
|
|
|
275
|
-
/**
|
|
276
|
-
* Fallback maximum upload size (100 MB) applied when a consumer does not pass
|
|
277
|
-
* an explicit `fileSizeLimit`. Acts as a safety net so unconfigured usages
|
|
278
|
-
* (e.g. the Close Escalation attachment) can never stream pathologically large
|
|
279
|
-
* files to the backend. Forms that legitimately need more can override the
|
|
280
|
-
* `fileSizeLimit` input upward.
|
|
281
|
-
*/
|
|
282
|
-
const DEFAULT_MAX_FILE_SIZE = 100 * 1024 * 1024;
|
|
283
277
|
const ACCEPT_TYPE_LABELS = {
|
|
284
278
|
'image/*': 'Images',
|
|
285
279
|
'application/pdf': 'PDF',
|
|
@@ -325,14 +319,8 @@ class UploadField {
|
|
|
325
319
|
readonly = input(false, ...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
326
320
|
context = input(undefined, ...(ngDevMode ? [{ debugName: "context" }] : /* istanbul ignore next */ []));
|
|
327
321
|
isMultipleEnabled = computed(() => this.shape() !== 'circle' && this.multiple(), ...(ngDevMode ? [{ debugName: "isMultipleEnabled" }] : /* istanbul ignore next */ []));
|
|
328
|
-
/**
|
|
329
|
-
|
|
330
|
-
* no explicit `fileSizeLimit` is provided. A `computed` (rather than an input
|
|
331
|
-
* default) is required because `dynamic-field` binds `[fileSizeLimit]` to a
|
|
332
|
-
* possibly-`undefined` config value, which would otherwise clobber the
|
|
333
|
-
* default.
|
|
334
|
-
*/
|
|
335
|
-
effectiveSizeLimit = computed(() => this.fileSizeLimit() ?? DEFAULT_MAX_FILE_SIZE, ...(ngDevMode ? [{ debugName: "effectiveSizeLimit" }] : /* istanbul ignore next */ []));
|
|
322
|
+
/** Optional feature-specific limit. The backend capability is authoritative. */
|
|
323
|
+
effectiveSizeLimit = computed(() => this.fileSizeLimit(), ...(ngDevMode ? [{ debugName: "effectiveSizeLimit" }] : /* istanbul ignore next */ []));
|
|
336
324
|
/**
|
|
337
325
|
* The native `accept` attribute is only a UI hint — users can switch the OS
|
|
338
326
|
* file dialog to "All files" and pick anything. This is the spec we re-check
|
|
@@ -393,9 +381,18 @@ class UploadField {
|
|
|
393
381
|
primaryFile = computed(() => this.files()[0] ?? null, ...(ngDevMode ? [{ debugName: "primaryFile" }] : /* istanbul ignore next */ []));
|
|
394
382
|
imgPath = computed(() => this.resolveImgPath(this.primaryFile()), ...(ngDevMode ? [{ debugName: "imgPath" }] : /* istanbul ignore next */ []));
|
|
395
383
|
disabled = signal(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
384
|
+
policyChecking = signal(true, ...(ngDevMode ? [{ debugName: "policyChecking" }] : /* istanbul ignore next */ []));
|
|
385
|
+
policyUnavailable = signal(false, ...(ngDevMode ? [{ debugName: "policyUnavailable" }] : /* istanbul ignore next */ []));
|
|
396
386
|
uploadProgress = signal(0, ...(ngDevMode ? [{ debugName: "uploadProgress" }] : /* istanbul ignore next */ []));
|
|
397
387
|
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
388
|
+
uploadInteractionDisabled = computed(() => this.disabled() ||
|
|
389
|
+
this.readonly() ||
|
|
390
|
+
this.loading() ||
|
|
391
|
+
this.policyChecking() ||
|
|
392
|
+
this.policyUnavailable(), ...(ngDevMode ? [{ debugName: "uploadInteractionDisabled" }] : /* istanbul ignore next */ []));
|
|
398
393
|
httpClient = inject(HttpClient);
|
|
394
|
+
uploader = inject(UploaderService);
|
|
395
|
+
destroyRef = inject(DestroyRef);
|
|
399
396
|
pendingUploads = signal(0, ...(ngDevMode ? [{ debugName: "pendingUploads" }] : /* istanbul ignore next */ []));
|
|
400
397
|
onTouched = () => { };
|
|
401
398
|
onModelChange = () => { };
|
|
@@ -404,6 +401,26 @@ class UploadField {
|
|
|
404
401
|
if (this.ngControl) {
|
|
405
402
|
this.ngControl.valueAccessor = this;
|
|
406
403
|
}
|
|
404
|
+
effect((onCleanup) => {
|
|
405
|
+
const endpoint = this.endPoint();
|
|
406
|
+
const context = this.context();
|
|
407
|
+
this.policyChecking.set(true);
|
|
408
|
+
this.policyUnavailable.set(false);
|
|
409
|
+
const subscription = this.uploader
|
|
410
|
+
.getCapabilities(endpoint, context)
|
|
411
|
+
.pipe(take(1))
|
|
412
|
+
.subscribe({
|
|
413
|
+
next: (capabilities) => {
|
|
414
|
+
this.policyUnavailable.set(!capabilities.uploadEnabled);
|
|
415
|
+
this.policyChecking.set(false);
|
|
416
|
+
},
|
|
417
|
+
error: () => {
|
|
418
|
+
this.policyUnavailable.set(true);
|
|
419
|
+
this.policyChecking.set(false);
|
|
420
|
+
},
|
|
421
|
+
});
|
|
422
|
+
onCleanup(() => subscription.unsubscribe());
|
|
423
|
+
});
|
|
407
424
|
}
|
|
408
425
|
writeValue(value) {
|
|
409
426
|
if (Array.isArray(value)) {
|
|
@@ -494,10 +511,10 @@ class UploadField {
|
|
|
494
511
|
return;
|
|
495
512
|
}
|
|
496
513
|
const sizeLimit = this.effectiveSizeLimit();
|
|
497
|
-
const oversized = files.filter((file) => file.size > sizeLimit);
|
|
514
|
+
const oversized = sizeLimit == null ? [] : files.filter((file) => file.size > sizeLimit);
|
|
498
515
|
if (oversized.length) {
|
|
499
516
|
this.ngControl.control?.setErrors({
|
|
500
|
-
fileSizeLimited: { size: formatFileSize(sizeLimit) },
|
|
517
|
+
fileSizeLimited: { size: formatFileSize(sizeLimit ?? 0) },
|
|
501
518
|
});
|
|
502
519
|
this.ngControl.control?.markAsTouched();
|
|
503
520
|
return;
|
|
@@ -509,15 +526,9 @@ class UploadField {
|
|
|
509
526
|
this.pendingUploads.update((count) => count + 1);
|
|
510
527
|
this.loading.set(true);
|
|
511
528
|
this.uploadProgress.set(10);
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
.post(this.endPoint(), formData, {
|
|
516
|
-
reportProgress: true,
|
|
517
|
-
observe: 'events',
|
|
518
|
-
context: this.context(),
|
|
519
|
-
})
|
|
520
|
-
.pipe(finalize$1(() => {
|
|
529
|
+
this.uploader
|
|
530
|
+
.upload(file, this.endPoint(), this.context())
|
|
531
|
+
.pipe(takeUntilDestroyed(this.destroyRef), finalize$1(() => {
|
|
521
532
|
const pending = Math.max(this.pendingUploads() - 1, 0);
|
|
522
533
|
this.pendingUploads.set(pending);
|
|
523
534
|
if (!pending) {
|
|
@@ -526,19 +537,24 @@ class UploadField {
|
|
|
526
537
|
this.loading.set(false);
|
|
527
538
|
}, 700);
|
|
528
539
|
}
|
|
529
|
-
}), catchError$1(() => {
|
|
530
|
-
this.uploadProgress.set(0);
|
|
531
|
-
return throwError(() => new Error('Upload failed'));
|
|
532
540
|
}))
|
|
533
|
-
.subscribe(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
541
|
+
.subscribe({
|
|
542
|
+
next: (event) => {
|
|
543
|
+
this.uploadProgress.set(event.progress);
|
|
544
|
+
if (!event.completed || !event.file)
|
|
545
|
+
return;
|
|
546
|
+
this.handleUploadDone({
|
|
547
|
+
...event.file.payload,
|
|
548
|
+
id: event.file.fileId,
|
|
549
|
+
fileId: event.file.fileId,
|
|
550
|
+
name: event.file.fileName,
|
|
551
|
+
fileName: event.file.fileId,
|
|
552
|
+
originalFileName: event.file.fileName,
|
|
553
|
+
contentType: event.file.contentType,
|
|
554
|
+
size: event.file.size,
|
|
555
|
+
});
|
|
556
|
+
},
|
|
557
|
+
error: (error) => this.handleUploadError(error),
|
|
542
558
|
});
|
|
543
559
|
}
|
|
544
560
|
handleUploadDone(file) {
|
|
@@ -577,7 +593,7 @@ class UploadField {
|
|
|
577
593
|
onDragOver(event) {
|
|
578
594
|
event.preventDefault();
|
|
579
595
|
event.stopPropagation();
|
|
580
|
-
if (!this.
|
|
596
|
+
if (!this.uploadInteractionDisabled()) {
|
|
581
597
|
this.isDragging.set(true);
|
|
582
598
|
}
|
|
583
599
|
}
|
|
@@ -590,7 +606,7 @@ class UploadField {
|
|
|
590
606
|
event.preventDefault();
|
|
591
607
|
event.stopPropagation();
|
|
592
608
|
this.isDragging.set(false);
|
|
593
|
-
if (this.
|
|
609
|
+
if (this.uploadInteractionDisabled()) {
|
|
594
610
|
return;
|
|
595
611
|
}
|
|
596
612
|
const files = Array.from(event.dataTransfer?.files ?? []);
|
|
@@ -603,7 +619,42 @@ class UploadField {
|
|
|
603
619
|
this.prepareFiles(files);
|
|
604
620
|
}
|
|
605
621
|
resolveImgPath(value) {
|
|
606
|
-
|
|
622
|
+
const fileId = value?.fileId ?? value?.id ?? value?.fileName;
|
|
623
|
+
return fileId
|
|
624
|
+
? `${this.endPoint().replace(/\/$/, '')}/${encodeURIComponent(fileId)}`
|
|
625
|
+
: undefined;
|
|
626
|
+
}
|
|
627
|
+
handleUploadError(error) {
|
|
628
|
+
this.uploadProgress.set(0);
|
|
629
|
+
const control = this.ngControl.control;
|
|
630
|
+
if (error instanceof UploaderPolicyError) {
|
|
631
|
+
if (error.code === 'FILE_TOO_LARGE') {
|
|
632
|
+
control?.setErrors({
|
|
633
|
+
fileSizeLimited: {
|
|
634
|
+
size: formatFileSize(error.maxFileSizeBytes ?? 0),
|
|
635
|
+
},
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
if (error.code === 'UPLOAD_DISABLED' ||
|
|
640
|
+
error.code === 'INVALID_CAPABILITIES') {
|
|
641
|
+
this.policyUnavailable.set(true);
|
|
642
|
+
}
|
|
643
|
+
control?.setErrors({
|
|
644
|
+
uploadUnavailable: {
|
|
645
|
+
message: this.transloco.translate('components.validation.uploadUnavailable'),
|
|
646
|
+
},
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
control?.setErrors({
|
|
652
|
+
uploadFailed: {
|
|
653
|
+
message: this.transloco.translate('components.validation.uploadFailed'),
|
|
654
|
+
},
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
control?.markAsTouched();
|
|
607
658
|
}
|
|
608
659
|
fetchMetadata(fileIds, existingFiles = [], forceArray = false) {
|
|
609
660
|
const normalizedIds = fileIds
|
|
@@ -638,7 +689,7 @@ class UploadField {
|
|
|
638
689
|
});
|
|
639
690
|
}
|
|
640
691
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UploadField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
641
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UploadField, isStandalone: true, selector: "mt-upload-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, endPoint: { classPropertyName: "endPoint", publicName: "endPoint", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userImgClass: { classPropertyName: "userImgClass", publicName: "userImgClass", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, isDragging: { classPropertyName: "isDragging", publicName: "isDragging", isSignal: true, isRequired: false, transformFunction: null }, fileSizeLimit: { classPropertyName: "fileSizeLimit", publicName: "fileSizeLimit", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isDragging: "isDraggingChange", onChange: "onChange" }, ngImport: i0, template: "<input\r\n #uploadInput\r\n type=\"file\"\r\n name=\"file[]\"\r\n (change)=\"onFileSelect($event)\"\r\n style=\"display: none\"\r\n [multiple]=\"isMultipleEnabled()\"\r\n [accept]=\"effectiveAccept()\"\r\n/>\r\n\r\n@if (shape() === \"circle\") {\r\n <div class=\"flex flex-col items-center gap-2 w-full\">\r\n <div class=\"flex\">\r\n <div class=\"flex flex-col items-center\">\r\n <mt-upload-user-preview\r\n [value]=\"primaryFile()\"\r\n [imgPath]=\"imgPath()\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [size]=\"size()\"\r\n [context]=\"context()\"\r\n [userImgClass]=\"userImgClass()\"\r\n [isDragging]=\"isDragging()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile($event)\"\r\n (onDeleteFile)=\"onDelete(primaryFile(), $event)\"\r\n (onDragOver)=\"onDragOver($event)\"\r\n (onDragLeave)=\"onDragLeave($event)\"\r\n (onDrop)=\"onDrop($event)\"\r\n ></mt-upload-user-preview>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"\r\n ngControl?.control?.hasValidator(requiredValidator)\r\n \"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"mt-1 text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n} @else if (shape() === \"card\") {\r\n <mt-card\r\n headless\r\n class=\"border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:bg-gray-50\"\r\n >\r\n <div class=\"content flex flex-col gap-5 items-center text-center\">\r\n @if (!files().length && !loading()) {\r\n <div class=\"flex flex-col gap-1\">\r\n @if (title()) {\r\n <div class=\"title text-lg font-semibold\">\r\n {{ title() }}\r\n </div>\r\n }\r\n @if (description()) {\r\n <div\r\n class=\"description text-sm text-muted-foreground secondary text-surface-500\"\r\n >\r\n {{ description() }}\r\n </div>\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <div class=\"mt-1 flex items-center justify-center gap-1.5\">\r\n <mt-icon\r\n icon=\"general.info-circle\"\r\n class=\"text-xs text-surface-400\"\r\n />\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (files().length) {\r\n <div class=\"flex w-full flex-col gap-2\">\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (\r\n isMultipleEnabled() && !disabled() && !readonly() && !loading()\r\n ) {\r\n <div class=\"flex flex-col items-center gap-1\">\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.addMore' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"uploadInput.click()\"\r\n />\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else {\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.upload' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"\r\n !loading() && !disabled() && !readonly() ? uploadInput.click() : ''\r\n \"\r\n [disabled]=\"disabled() || loading() || readonly()\"\r\n />\r\n }\r\n </div>\r\n </mt-card>\r\n} @else {\r\n <div class=\"flex flex-col items-start gap-2 w-full\">\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n\r\n <div\r\n class=\"w-full flex gap-3 items-center justify-center border-2 border-dashed border-gray-300 rounded-lg\"\r\n [class]=\"\r\n (readonly() || disabled() ? '' : 'cursor-pointer hover:bg-gray-50') +\r\n (disabled() ? ' bg-gray-50' : '')\r\n \"\r\n (click)=\"\r\n !loading() && !disabled() && !readonly() ? uploadInput.click() : ''\r\n \"\r\n [class.border-blue-500]=\"isDragging()\"\r\n [class.bg-blue-50]=\"isDragging()\"\r\n (dragover)=\"onDragOver($event)\"\r\n (dragleave)=\"onDragLeave($event)\"\r\n (drop)=\"onDrop($event)\"\r\n >\r\n @if (files().length) {\r\n <div\r\n class=\"flex w-full flex-col gap-2 p-2\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (\r\n isMultipleEnabled() && !disabled() && !readonly() && !loading()\r\n ) {\r\n <div\r\n class=\"flex w-full flex-col border-t border-dashed border-gray-300\"\r\n >\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-2 cursor-pointer hover:bg-gray-100 rounded-b-lg transition-colors\"\r\n (click)=\"uploadInput.click()\"\r\n >\r\n <mt-icon icon=\"general.upload-01\" />\r\n <span class=\"text-sm text-gray-500\">\r\n {{ \"components.upload.addMore\" | transloco }}\r\n </span>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else if (!readonly()) {\r\n <div class=\"w-full flex flex-col gap-1 items-center justify-center p-3\">\r\n <div class=\"flex gap-3 items-center\">\r\n <mt-icon icon=\"general.upload-01\" />\r\n <p class=\"text-lg text-gray-500\">\r\n {{ \"components.upload.clickOrDrop\" | transloco }}\r\n </p>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else {\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-3 text-gray-400\"\r\n >\r\n <mt-icon icon=\"file.file-x-02\" />\r\n <p class=\"text-sm\">{{ \"components.upload.noFile\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n", dependencies: [{ kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: UploadUserPreview, selector: "mt-upload-user-preview", inputs: ["value", "imgPath", "context", "loading", "uploadProgress", "isDragging", "disabled", "readonly", "size", "userImgClass"], outputs: ["onUploadInputClicked", "ondDownloadFile", "onDeleteFile", "onDragOver", "onDragLeave", "onDrop", "disabledChange"] }, { kind: "component", type: UploadFilePreview, selector: "mt-upload-file-preview", inputs: ["value", "imgPath", "context", "loading", "uploadProgress", "disabled", "readonly", "size"], outputs: ["onUploadInputClicked", "ondDownloadFile", "onDeleteFile", "disabledChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i1.TranslocoPipe, name: "transloco" }] });
|
|
692
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UploadField, isStandalone: true, selector: "mt-upload-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, endPoint: { classPropertyName: "endPoint", publicName: "endPoint", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userImgClass: { classPropertyName: "userImgClass", publicName: "userImgClass", isSignal: true, isRequired: false, transformFunction: null }, shape: { classPropertyName: "shape", publicName: "shape", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, isDragging: { classPropertyName: "isDragging", publicName: "isDragging", isSignal: true, isRequired: false, transformFunction: null }, fileSizeLimit: { classPropertyName: "fileSizeLimit", publicName: "fileSizeLimit", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isDragging: "isDraggingChange", onChange: "onChange" }, ngImport: i0, template: "<input\r\n #uploadInput\r\n type=\"file\"\r\n name=\"file[]\"\r\n (change)=\"onFileSelect($event)\"\r\n style=\"display: none\"\r\n [multiple]=\"isMultipleEnabled()\"\r\n [accept]=\"effectiveAccept()\"\r\n [disabled]=\"uploadInteractionDisabled()\"\r\n/>\r\n\r\n@if (shape() === \"circle\") {\r\n <div class=\"flex flex-col items-center gap-2 w-full\">\r\n <div class=\"flex\">\r\n <div class=\"flex flex-col items-center\">\r\n <mt-upload-user-preview\r\n [value]=\"primaryFile()\"\r\n [imgPath]=\"imgPath()\"\r\n [disabled]=\"disabled() || (!imgPath() && policyUnavailable())\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [size]=\"size()\"\r\n [context]=\"context()\"\r\n [userImgClass]=\"userImgClass()\"\r\n [isDragging]=\"isDragging()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile($event)\"\r\n (onDeleteFile)=\"onDelete(primaryFile(), $event)\"\r\n (onDragOver)=\"onDragOver($event)\"\r\n (onDragLeave)=\"onDragLeave($event)\"\r\n (onDrop)=\"onDrop($event)\"\r\n ></mt-upload-user-preview>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"\r\n ngControl?.control?.hasValidator(requiredValidator)\r\n \"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"mt-1 text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n} @else if (shape() === \"card\") {\r\n <mt-card\r\n headless\r\n class=\"border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:bg-gray-50\"\r\n >\r\n <div class=\"content flex flex-col gap-5 items-center text-center\">\r\n @if (!files().length && !loading()) {\r\n <div class=\"flex flex-col gap-1\">\r\n @if (title()) {\r\n <div class=\"title text-lg font-semibold\">\r\n {{ title() }}\r\n </div>\r\n }\r\n @if (description()) {\r\n <div\r\n class=\"description text-sm text-muted-foreground secondary text-surface-500\"\r\n >\r\n {{ description() }}\r\n </div>\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <div class=\"mt-1 flex items-center justify-center gap-1.5\">\r\n <mt-icon\r\n icon=\"general.info-circle\"\r\n class=\"text-xs text-surface-400\"\r\n />\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (files().length) {\r\n <div class=\"flex w-full flex-col gap-2\">\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (isMultipleEnabled() && !uploadInteractionDisabled()) {\r\n <div class=\"flex flex-col items-center gap-1\">\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.addMore' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"uploadInput.click()\"\r\n />\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else {\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.upload' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"!uploadInteractionDisabled() ? uploadInput.click() : ''\"\r\n [disabled]=\"uploadInteractionDisabled()\"\r\n />\r\n }\r\n </div>\r\n </mt-card>\r\n} @else {\r\n <div class=\"flex flex-col items-start gap-2 w-full\">\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n\r\n <div\r\n class=\"w-full flex gap-3 items-center justify-center border-2 border-dashed border-gray-300 rounded-lg\"\r\n [class]=\"\r\n (uploadInteractionDisabled() ? '' : 'cursor-pointer hover:bg-gray-50') +\r\n (disabled() || policyUnavailable() ? ' bg-gray-50' : '')\r\n \"\r\n (click)=\"!uploadInteractionDisabled() ? uploadInput.click() : ''\"\r\n [class.border-blue-500]=\"isDragging()\"\r\n [class.bg-blue-50]=\"isDragging()\"\r\n (dragover)=\"onDragOver($event)\"\r\n (dragleave)=\"onDragLeave($event)\"\r\n (drop)=\"onDrop($event)\"\r\n >\r\n @if (files().length) {\r\n <div\r\n class=\"flex w-full flex-col gap-2 p-2\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (isMultipleEnabled() && !uploadInteractionDisabled()) {\r\n <div\r\n class=\"flex w-full flex-col border-t border-dashed border-gray-300\"\r\n >\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-2 cursor-pointer hover:bg-gray-100 rounded-b-lg transition-colors\"\r\n (click)=\"\r\n !uploadInteractionDisabled() ? uploadInput.click() : ''\r\n \"\r\n >\r\n <mt-icon icon=\"general.upload-01\" />\r\n <span class=\"text-sm text-gray-500\">\r\n {{ \"components.upload.addMore\" | transloco }}\r\n </span>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else if (!readonly()) {\r\n <div class=\"w-full flex flex-col gap-1 items-center justify-center p-3\">\r\n <div class=\"flex gap-3 items-center\">\r\n <mt-icon icon=\"general.upload-01\" />\r\n <p class=\"text-lg text-gray-500\">\r\n {{ \"components.upload.clickOrDrop\" | transloco }}\r\n </p>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else {\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-3 text-gray-400\"\r\n >\r\n <mt-icon icon=\"file.file-x-02\" />\r\n <p class=\"text-sm\">{{ \"components.upload.noFile\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n@if (policyUnavailable() && !readonly()) {\r\n <p class=\"mt-1 text-sm text-red-500\" role=\"status\">\r\n {{ \"components.validation.uploadUnavailable\" | transloco }}\r\n </p>\r\n}\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n", dependencies: [{ kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: UploadUserPreview, selector: "mt-upload-user-preview", inputs: ["value", "imgPath", "context", "loading", "uploadProgress", "isDragging", "disabled", "readonly", "size", "userImgClass"], outputs: ["onUploadInputClicked", "ondDownloadFile", "onDeleteFile", "onDragOver", "onDragLeave", "onDrop", "disabledChange"] }, { kind: "component", type: UploadFilePreview, selector: "mt-upload-file-preview", inputs: ["value", "imgPath", "context", "loading", "uploadProgress", "disabled", "readonly", "size"], outputs: ["onUploadInputClicked", "ondDownloadFile", "onDeleteFile", "disabledChange"] }, { kind: "component", type: FieldValidation, selector: "mt-field-validation", inputs: ["control", "touched"] }, { kind: "component", type: Card, selector: "mt-card", inputs: ["class", "title", "paddingless"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: TranslocoModule }, { kind: "pipe", type: i1.TranslocoPipe, name: "transloco" }] });
|
|
642
693
|
}
|
|
643
694
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UploadField, decorators: [{
|
|
644
695
|
type: Component,
|
|
@@ -650,7 +701,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
650
701
|
Card,
|
|
651
702
|
Button,
|
|
652
703
|
TranslocoModule,
|
|
653
|
-
], template: "<input\r\n #uploadInput\r\n type=\"file\"\r\n name=\"file[]\"\r\n (change)=\"onFileSelect($event)\"\r\n style=\"display: none\"\r\n [multiple]=\"isMultipleEnabled()\"\r\n [accept]=\"effectiveAccept()\"\r\n/>\r\n\r\n@if (shape() === \"circle\") {\r\n <div class=\"flex flex-col items-center gap-2 w-full\">\r\n <div class=\"flex\">\r\n <div class=\"flex flex-col items-center\">\r\n <mt-upload-user-preview\r\n [value]=\"primaryFile()\"\r\n [imgPath]=\"imgPath()\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [size]=\"size()\"\r\n [context]=\"context()\"\r\n [userImgClass]=\"userImgClass()\"\r\n [isDragging]=\"isDragging()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile($event)\"\r\n (onDeleteFile)=\"onDelete(primaryFile(), $event)\"\r\n (onDragOver)=\"onDragOver($event)\"\r\n (onDragLeave)=\"onDragLeave($event)\"\r\n (onDrop)=\"onDrop($event)\"\r\n ></mt-upload-user-preview>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"\r\n ngControl?.control?.hasValidator(requiredValidator)\r\n \"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"mt-1 text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n} @else if (shape() === \"card\") {\r\n <mt-card\r\n headless\r\n class=\"border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:bg-gray-50\"\r\n >\r\n <div class=\"content flex flex-col gap-5 items-center text-center\">\r\n @if (!files().length && !loading()) {\r\n <div class=\"flex flex-col gap-1\">\r\n @if (title()) {\r\n <div class=\"title text-lg font-semibold\">\r\n {{ title() }}\r\n </div>\r\n }\r\n @if (description()) {\r\n <div\r\n class=\"description text-sm text-muted-foreground secondary text-surface-500\"\r\n >\r\n {{ description() }}\r\n </div>\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <div class=\"mt-1 flex items-center justify-center gap-1.5\">\r\n <mt-icon\r\n icon=\"general.info-circle\"\r\n class=\"text-xs text-surface-400\"\r\n />\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (files().length) {\r\n <div class=\"flex w-full flex-col gap-2\">\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (\r\n isMultipleEnabled() && !disabled() && !readonly() && !loading()\r\n ) {\r\n <div class=\"flex flex-col items-center gap-1\">\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.addMore' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"uploadInput.click()\"\r\n />\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else {\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.upload' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"\r\n !loading() && !disabled() && !readonly() ? uploadInput.click() : ''\r\n \"\r\n [disabled]=\"disabled() || loading() || readonly()\"\r\n />\r\n }\r\n </div>\r\n </mt-card>\r\n} @else {\r\n <div class=\"flex flex-col items-start gap-2 w-full\">\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n\r\n <div\r\n class=\"w-full flex gap-3 items-center justify-center border-2 border-dashed border-gray-300 rounded-lg\"\r\n [class]=\"\r\n (readonly() || disabled() ? '' : 'cursor-pointer hover:bg-gray-50') +\r\n (disabled() ? ' bg-gray-50' : '')\r\n \"\r\n (click)=\"\r\n !loading() && !disabled() && !readonly() ? uploadInput.click() : ''\r\n \"\r\n [class.border-blue-500]=\"isDragging()\"\r\n [class.bg-blue-50]=\"isDragging()\"\r\n (dragover)=\"onDragOver($event)\"\r\n (dragleave)=\"onDragLeave($event)\"\r\n (drop)=\"onDrop($event)\"\r\n >\r\n @if (files().length) {\r\n <div\r\n class=\"flex w-full flex-col gap-2 p-2\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (\r\n isMultipleEnabled() && !disabled() && !readonly() && !loading()\r\n ) {\r\n <div\r\n class=\"flex w-full flex-col border-t border-dashed border-gray-300\"\r\n >\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-2 cursor-pointer hover:bg-gray-100 rounded-b-lg transition-colors\"\r\n (click)=\"uploadInput.click()\"\r\n >\r\n <mt-icon icon=\"general.upload-01\" />\r\n <span class=\"text-sm text-gray-500\">\r\n {{ \"components.upload.addMore\" | transloco }}\r\n </span>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else if (!readonly()) {\r\n <div class=\"w-full flex flex-col gap-1 items-center justify-center p-3\">\r\n <div class=\"flex gap-3 items-center\">\r\n <mt-icon icon=\"general.upload-01\" />\r\n <p class=\"text-lg text-gray-500\">\r\n {{ \"components.upload.clickOrDrop\" | transloco }}\r\n </p>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else {\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-3 text-gray-400\"\r\n >\r\n <mt-icon icon=\"file.file-x-02\" />\r\n <p class=\"text-sm\">{{ \"components.upload.noFile\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n" }]
|
|
704
|
+
], template: "<input\r\n #uploadInput\r\n type=\"file\"\r\n name=\"file[]\"\r\n (change)=\"onFileSelect($event)\"\r\n style=\"display: none\"\r\n [multiple]=\"isMultipleEnabled()\"\r\n [accept]=\"effectiveAccept()\"\r\n [disabled]=\"uploadInteractionDisabled()\"\r\n/>\r\n\r\n@if (shape() === \"circle\") {\r\n <div class=\"flex flex-col items-center gap-2 w-full\">\r\n <div class=\"flex\">\r\n <div class=\"flex flex-col items-center\">\r\n <mt-upload-user-preview\r\n [value]=\"primaryFile()\"\r\n [imgPath]=\"imgPath()\"\r\n [disabled]=\"disabled() || (!imgPath() && policyUnavailable())\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [size]=\"size()\"\r\n [context]=\"context()\"\r\n [userImgClass]=\"userImgClass()\"\r\n [isDragging]=\"isDragging()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile($event)\"\r\n (onDeleteFile)=\"onDelete(primaryFile(), $event)\"\r\n (onDragOver)=\"onDragOver($event)\"\r\n (onDragLeave)=\"onDragLeave($event)\"\r\n (onDrop)=\"onDrop($event)\"\r\n ></mt-upload-user-preview>\r\n @if (label()) {\r\n <label\r\n [class.required]=\"\r\n ngControl?.control?.hasValidator(requiredValidator)\r\n \"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"mt-1 text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n} @else if (shape() === \"card\") {\r\n <mt-card\r\n headless\r\n class=\"border-2 border-dashed border-gray-300 rounded-lg cursor-pointer hover:bg-gray-50\"\r\n >\r\n <div class=\"content flex flex-col gap-5 items-center text-center\">\r\n @if (!files().length && !loading()) {\r\n <div class=\"flex flex-col gap-1\">\r\n @if (title()) {\r\n <div class=\"title text-lg font-semibold\">\r\n {{ title() }}\r\n </div>\r\n }\r\n @if (description()) {\r\n <div\r\n class=\"description text-sm text-muted-foreground secondary text-surface-500\"\r\n >\r\n {{ description() }}\r\n </div>\r\n }\r\n @if (acceptedTypesLabel()) {\r\n <div class=\"mt-1 flex items-center justify-center gap-1.5\">\r\n <mt-icon\r\n icon=\"general.info-circle\"\r\n class=\"text-xs text-surface-400\"\r\n />\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n @if (files().length) {\r\n <div class=\"flex w-full flex-col gap-2\">\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (isMultipleEnabled() && !uploadInteractionDisabled()) {\r\n <div class=\"flex flex-col items-center gap-1\">\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.addMore' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"uploadInput.click()\"\r\n />\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else {\r\n <mt-button\r\n [size]=\"'small'\"\r\n [label]=\"'components.upload.upload' | transloco\"\r\n [icon]=\"'general.upload-01'\"\r\n (onClick)=\"!uploadInteractionDisabled() ? uploadInput.click() : ''\"\r\n [disabled]=\"uploadInteractionDisabled()\"\r\n />\r\n }\r\n </div>\r\n </mt-card>\r\n} @else {\r\n <div class=\"flex flex-col items-start gap-2 w-full\">\r\n @if (label()) {\r\n <label\r\n [class.required]=\"ngControl?.control?.hasValidator(requiredValidator)\"\r\n [for]=\"ngControl?.name || label()\"\r\n >{{ label() }}</label\r\n >\r\n }\r\n\r\n <div\r\n class=\"w-full flex gap-3 items-center justify-center border-2 border-dashed border-gray-300 rounded-lg\"\r\n [class]=\"\r\n (uploadInteractionDisabled() ? '' : 'cursor-pointer hover:bg-gray-50') +\r\n (disabled() || policyUnavailable() ? ' bg-gray-50' : '')\r\n \"\r\n (click)=\"!uploadInteractionDisabled() ? uploadInput.click() : ''\"\r\n [class.border-blue-500]=\"isDragging()\"\r\n [class.bg-blue-50]=\"isDragging()\"\r\n (dragover)=\"onDragOver($event)\"\r\n (dragleave)=\"onDragLeave($event)\"\r\n (drop)=\"onDrop($event)\"\r\n >\r\n @if (files().length) {\r\n <div\r\n class=\"flex w-full flex-col gap-2 p-2\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n @for (file of files(); track $index) {\r\n <mt-upload-file-preview\r\n style=\"width: 100%\"\r\n [value]=\"file\"\r\n [imgPath]=\"resolveImgPath(file)\"\r\n [disabled]=\"disabled()\"\r\n [readonly]=\"readonly()\"\r\n [loading]=\"loading()\"\r\n [context]=\"context()\"\r\n [uploadProgress]=\"uploadProgress()\"\r\n (onUploadInputClicked)=\"uploadInput.click()\"\r\n (ondDownloadFile)=\"downloadFile(file)\"\r\n (onDeleteFile)=\"onDelete(file, $event)\"\r\n />\r\n }\r\n @if (isMultipleEnabled() && !uploadInteractionDisabled()) {\r\n <div\r\n class=\"flex w-full flex-col border-t border-dashed border-gray-300\"\r\n >\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-2 cursor-pointer hover:bg-gray-100 rounded-b-lg transition-colors\"\r\n (click)=\"\r\n !uploadInteractionDisabled() ? uploadInput.click() : ''\r\n \"\r\n >\r\n <mt-icon icon=\"general.upload-01\" />\r\n <span class=\"text-sm text-gray-500\">\r\n {{ \"components.upload.addMore\" | transloco }}\r\n </span>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (acceptedTypesLabel()) {\r\n <span class=\"px-2 pb-2 text-center text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else if (loading()) {\r\n <div class=\"w-full flex gap-3 items-center justify-center p-3\">\r\n <p class=\"text-lg text-gray-500\">\r\n {{\r\n (\"components.upload.uploading\" | transloco) +\r\n uploadProgress() +\r\n \"%\"\r\n }}\r\n </p>\r\n </div>\r\n } @else if (!readonly()) {\r\n <div class=\"w-full flex flex-col gap-1 items-center justify-center p-3\">\r\n <div class=\"flex gap-3 items-center\">\r\n <mt-icon icon=\"general.upload-01\" />\r\n <p class=\"text-lg text-gray-500\">\r\n {{ \"components.upload.clickOrDrop\" | transloco }}\r\n </p>\r\n </div>\r\n @if (acceptedTypesLabel()) {\r\n <span class=\"text-xs text-surface-400\">\r\n {{\r\n \"components.upload.allowedTypes\"\r\n | transloco: { types: acceptedTypesLabel() }\r\n }}\r\n </span>\r\n }\r\n </div>\r\n } @else {\r\n <div\r\n class=\"w-full flex gap-2 items-center justify-center p-3 text-gray-400\"\r\n >\r\n <mt-icon icon=\"file.file-x-02\" />\r\n <p class=\"text-sm\">{{ \"components.upload.noFile\" | transloco }}</p>\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n}\r\n@if (policyUnavailable() && !readonly()) {\r\n <p class=\"mt-1 text-sm text-red-500\" role=\"status\">\r\n {{ \"components.validation.uploadUnavailable\" | transloco }}\r\n </p>\r\n}\r\n<mt-field-validation [control]=\"ngControl?.control\"></mt-field-validation>\r\n" }]
|
|
654
705
|
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], endPoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "endPoint", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userImgClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "userImgClass", required: false }] }], shape: [{ type: i0.Input, args: [{ isSignal: true, alias: "shape", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], isDragging: [{ type: i0.Input, args: [{ isSignal: true, alias: "isDragging", required: false }] }, { type: i0.Output, args: ["isDraggingChange"] }], fileSizeLimit: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileSizeLimit", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }], onChange: [{ type: i0.Output, args: ["onChange"] }] } });
|
|
655
706
|
/**
|
|
656
707
|
* Re-validates a picked/dropped file against the `accept` spec on the client,
|