@praxisui/files-upload 8.0.0-beta.0 → 8.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/praxisui-files-upload.mjs +25 -10
- package/index.d.ts +3 -1
- package/package.json +4 -4
|
@@ -1063,7 +1063,7 @@ function createPraxisFilesUploadI18nConfig(options = {}) {
|
|
|
1063
1063
|
};
|
|
1064
1064
|
}
|
|
1065
1065
|
return {
|
|
1066
|
-
locale: options.locale,
|
|
1066
|
+
locale: options.locale ?? 'pt-BR',
|
|
1067
1067
|
fallbackLocale: options.fallbackLocale ?? 'pt-BR',
|
|
1068
1068
|
dictionaries,
|
|
1069
1069
|
};
|
|
@@ -3775,7 +3775,7 @@ class PraxisFilesUpload {
|
|
|
3775
3775
|
return this.t('selectFiles', 'Selecionar arquivo(s)');
|
|
3776
3776
|
}
|
|
3777
3777
|
get policySummaryAriaLabel() {
|
|
3778
|
-
return this.t('policySummaryAction', '
|
|
3778
|
+
return this.t('policySummaryAction', 'Informações sobre políticas de upload');
|
|
3779
3779
|
}
|
|
3780
3780
|
pendingFileRemoveAriaLabel(file) {
|
|
3781
3781
|
return `${this.t('removePendingFile', 'Remover arquivo selecionado')}: ${file.name}`;
|
|
@@ -3976,14 +3976,15 @@ class PraxisFilesUpload {
|
|
|
3976
3976
|
}
|
|
3977
3977
|
const optionsJson = this.buildOptionsJson(metadataObj);
|
|
3978
3978
|
const strategy = this.config?.strategy ?? 'direct';
|
|
3979
|
+
const isBulkMode = this.shouldUseBulkMode(files);
|
|
3979
3980
|
this.uploadStart.emit({
|
|
3980
3981
|
files,
|
|
3981
|
-
mode:
|
|
3982
|
+
mode: isBulkMode ? 'bulk' : 'single',
|
|
3982
3983
|
strategy,
|
|
3983
3984
|
filesUploadId: this.filesUploadId || undefined,
|
|
3984
3985
|
baseUrl: this.baseUrl,
|
|
3985
3986
|
});
|
|
3986
|
-
if (
|
|
3987
|
+
if (isBulkMode) {
|
|
3987
3988
|
this.uploadMultipleFiles(files, strategy, metadataObj, optionsJson);
|
|
3988
3989
|
}
|
|
3989
3990
|
else if (strategy === 'presign' || strategy === 'auto') {
|
|
@@ -4060,6 +4061,13 @@ class PraxisFilesUpload {
|
|
|
4060
4061
|
});
|
|
4061
4062
|
}
|
|
4062
4063
|
}
|
|
4064
|
+
shouldUseBulkMode(files) {
|
|
4065
|
+
const maxFilesPerBulk = this.config?.limits?.maxFilesPerBulk;
|
|
4066
|
+
const allowsBulk = maxFilesPerBulk !== undefined
|
|
4067
|
+
? maxFilesPerBulk > 1
|
|
4068
|
+
: this.allowMultiple;
|
|
4069
|
+
return files.length > 1 && allowsBulk;
|
|
4070
|
+
}
|
|
4063
4071
|
directUpload(file, options) {
|
|
4064
4072
|
const api = this.requireApiClient();
|
|
4065
4073
|
const baseUrl = this.requireBaseUrl();
|
|
@@ -5622,8 +5630,8 @@ class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
5622
5630
|
this.control().markAsTouched();
|
|
5623
5631
|
this.control().markAsDirty();
|
|
5624
5632
|
}
|
|
5625
|
-
clearUploadState() {
|
|
5626
|
-
this.updateUploadValidationState();
|
|
5633
|
+
clearUploadState(externalErrors) {
|
|
5634
|
+
this.updateUploadValidationState(undefined, externalErrors);
|
|
5627
5635
|
this.uploadError = null;
|
|
5628
5636
|
}
|
|
5629
5637
|
applyUploadErrorState(message, validationKey) {
|
|
@@ -5640,8 +5648,9 @@ class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
5640
5648
|
return `${extraFiles} ${this.t('fieldChipAria', 'arquivos adicionais selecionados')}`;
|
|
5641
5649
|
}
|
|
5642
5650
|
onUploadSuccess(file) {
|
|
5651
|
+
const externalErrors = this.getNonUploadErrors();
|
|
5643
5652
|
this.applyResolvedValue(file);
|
|
5644
|
-
this.clearUploadState();
|
|
5653
|
+
this.clearUploadState(externalErrors);
|
|
5645
5654
|
this.batchCount = 1;
|
|
5646
5655
|
this.uploadSuccess.emit(file);
|
|
5647
5656
|
}
|
|
@@ -5784,6 +5793,7 @@ class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
5784
5793
|
onOpenInfo() { }
|
|
5785
5794
|
onOpenMenu() { }
|
|
5786
5795
|
onClear() {
|
|
5796
|
+
const externalErrors = this.getNonUploadErrors();
|
|
5787
5797
|
this.lastFileName = null;
|
|
5788
5798
|
this.batchCount = 0;
|
|
5789
5799
|
this.uploadError = null;
|
|
@@ -5794,7 +5804,7 @@ class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
5794
5804
|
const c = this.control();
|
|
5795
5805
|
c.markAsPristine();
|
|
5796
5806
|
c.markAsUntouched();
|
|
5797
|
-
this.updateUploadValidationState();
|
|
5807
|
+
this.updateUploadValidationState(undefined, externalErrors);
|
|
5798
5808
|
}
|
|
5799
5809
|
catch { }
|
|
5800
5810
|
}
|
|
@@ -5840,14 +5850,19 @@ class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
5840
5850
|
this.pendingPanel?.nativeElement.focus();
|
|
5841
5851
|
});
|
|
5842
5852
|
}
|
|
5843
|
-
|
|
5853
|
+
getNonUploadErrors() {
|
|
5844
5854
|
const currentErrors = { ...(this.control().errors ?? {}) };
|
|
5845
5855
|
delete currentErrors.upload;
|
|
5846
5856
|
delete currentErrors.uploadPartial;
|
|
5857
|
+
return currentErrors;
|
|
5858
|
+
}
|
|
5859
|
+
updateUploadValidationState(validationKey, baseErrors) {
|
|
5860
|
+
const control = this.control();
|
|
5861
|
+
const currentErrors = { ...(baseErrors ?? this.getNonUploadErrors()) };
|
|
5847
5862
|
if (validationKey) {
|
|
5848
5863
|
currentErrors[validationKey] = true;
|
|
5849
5864
|
}
|
|
5850
|
-
|
|
5865
|
+
control.setErrors(Object.keys(currentErrors).length ? currentErrors : null);
|
|
5851
5866
|
}
|
|
5852
5867
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: PdxFilesUploadFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
5853
5868
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.17", type: PdxFilesUploadFieldComponent, isStandalone: true, selector: "pdx-material-files-upload", inputs: { config: "config", valueMode: "valueMode", baseUrl: "baseUrl" }, outputs: { uploadSuccess: "uploadSuccess", bulkComplete: "bulkComplete", error: "error" }, host: { properties: { "class": "componentCssClasses()", "attr.data-field-type": "\"files-upload\"", "attr.data-field-name": "metadata()?.name", "attr.data-component-id": "componentId()" } }, providers: [providePraxisFilesUploadI18n()], viewQueries: [{ propertyName: "uploader", first: true, predicate: ["uploader"], descendants: true }, { propertyName: "pendingTrigger", first: true, predicate: ["pendingTrigger"], descendants: true }, { propertyName: "pendingPanel", first: true, predicate: ["pendingPanel"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
|
package/index.d.ts
CHANGED
|
@@ -384,7 +384,7 @@ declare const FILES_UPLOAD_TEXTS: InjectionToken<FilesUploadTexts>;
|
|
|
384
384
|
/** @deprecated Transitional compatibility token. Prefer PraxisI18nService. */
|
|
385
385
|
declare const TRANSLATE_LIKE: InjectionToken<TranslateLike>;
|
|
386
386
|
declare function createPraxisFilesUploadI18nConfig(options?: PraxisFilesUploadI18nOptions): Partial<PraxisI18nConfig>;
|
|
387
|
-
declare function providePraxisFilesUploadI18n(options?: PraxisFilesUploadI18nOptions): i0.Provider;
|
|
387
|
+
declare function providePraxisFilesUploadI18n(options?: PraxisFilesUploadI18nOptions): i0.Provider[];
|
|
388
388
|
declare function resolvePraxisFilesUploadText(i18n: PraxisI18nService, key: string, fallback: string, legacyTexts?: FilesUploadTexts, legacyTranslate?: TranslateLike): string;
|
|
389
389
|
|
|
390
390
|
interface RateLimitInfo {
|
|
@@ -631,6 +631,7 @@ declare class PraxisFilesUpload implements OnInit, OnChanges, AfterViewInit, OnD
|
|
|
631
631
|
removePendingFile(file: File): void;
|
|
632
632
|
private emitPendingState;
|
|
633
633
|
private startUpload;
|
|
634
|
+
private shouldUseBulkMode;
|
|
634
635
|
private directUpload;
|
|
635
636
|
private uploadMultipleFiles;
|
|
636
637
|
private uploadMultipleFilesDirect;
|
|
@@ -732,6 +733,7 @@ declare class PdxFilesUploadFieldComponent extends SimpleBaseInputComponent {
|
|
|
732
733
|
pendingFileSummary(file: File): string;
|
|
733
734
|
formatBytes(bytes: number): string;
|
|
734
735
|
private focusPendingPanelSoon;
|
|
736
|
+
private getNonUploadErrors;
|
|
735
737
|
private updateUploadValidationState;
|
|
736
738
|
static ɵfac: i0.ɵɵFactoryDeclaration<PdxFilesUploadFieldComponent, never>;
|
|
737
739
|
static ɵcmp: i0.ɵɵComponentDeclaration<PdxFilesUploadFieldComponent, "pdx-material-files-upload", never, { "config": { "alias": "config"; "required": false; }; "valueMode": { "alias": "valueMode"; "required": false; }; "baseUrl": { "alias": "baseUrl"; "required": false; }; }, { "uploadSuccess": "uploadSuccess"; "bulkComplete": "bulkComplete"; "error": "error"; }, never, never, true, never>;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praxisui/files-upload",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.2",
|
|
4
4
|
"description": "File upload components and services for Praxis UI with presigned and direct strategies, quotas and rate-limit handling.",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": "^20.0.0",
|
|
7
7
|
"@angular/cdk": "^20.0.0",
|
|
8
8
|
"@angular/core": "^20.0.0",
|
|
9
9
|
"@angular/material": "^20.0.0",
|
|
10
|
-
"@praxisui/core": "^8.0.0-beta.
|
|
11
|
-
"@praxisui/dynamic-fields": "^8.0.0-beta.
|
|
12
|
-
"@praxisui/settings-panel": "^8.0.0-beta.
|
|
10
|
+
"@praxisui/core": "^8.0.0-beta.2",
|
|
11
|
+
"@praxisui/dynamic-fields": "^8.0.0-beta.2",
|
|
12
|
+
"@praxisui/settings-panel": "^8.0.0-beta.2"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"tslib": "^2.3.0"
|