@seniorsistemas/angular-components 15.2.0 → 15.3.0
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/bundles/seniorsistemas-angular-components.umd.js +44 -21
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +2 -2
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/file-upload/file-upload.component.d.ts +8 -5
- package/components/file-upload/models/validate-errors.d.ts +2 -1
- package/esm2015/components/file-upload/file-upload.component.js +37 -15
- package/esm2015/components/file-upload/models/validate-errors.js +2 -1
- package/esm5/components/file-upload/file-upload.component.js +45 -23
- package/esm5/components/file-upload/models/validate-errors.js +2 -1
- package/fesm2015/seniorsistemas-angular-components.js +36 -13
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +44 -21
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -2706,6 +2706,7 @@ var ValidateErrors;
|
|
|
2706
2706
|
(function (ValidateErrors) {
|
|
2707
2707
|
ValidateErrors["MAX_FILE_SIZE"] = "MAX_FILE_SIZE";
|
|
2708
2708
|
ValidateErrors["MAX_FILE_LIMIT"] = "MAX_FILE_LIMIT";
|
|
2709
|
+
ValidateErrors["UNSUPPORTED_EXTENSION"] = "UNSUPPORTED_EXTENSION";
|
|
2709
2710
|
})(ValidateErrors || (ValidateErrors = {}));
|
|
2710
2711
|
|
|
2711
2712
|
var Breakpoints = {
|
|
@@ -2817,12 +2818,12 @@ var ExportUtils = /** @class */ (function () {
|
|
|
2817
2818
|
var FileUploadComponent = /** @class */ (function () {
|
|
2818
2819
|
function FileUploadComponent(sanitizer) {
|
|
2819
2820
|
this.sanitizer = sanitizer;
|
|
2820
|
-
this.inputValue = "";
|
|
2821
2821
|
this.id = "s-file-upload-" + FileUploadComponent_1.nextId++;
|
|
2822
2822
|
this.chooseLabel = "Anexar arquivos";
|
|
2823
2823
|
this.removeLabel = "Remover";
|
|
2824
2824
|
this.cancelLabel = "Cancelar";
|
|
2825
2825
|
this.successTooltip = "Arquivo anexado com sucesso";
|
|
2826
|
+
this.supportedExtensions = [];
|
|
2826
2827
|
this.ariaLabelProgress = "Carregando arquivo";
|
|
2827
2828
|
this.disabled = false;
|
|
2828
2829
|
this.uploadHandler = new EventEmitter();
|
|
@@ -2832,8 +2833,29 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2832
2833
|
this.validateErros = new EventEmitter();
|
|
2833
2834
|
this._files = [];
|
|
2834
2835
|
this.ngUsubscribe = new Subject();
|
|
2836
|
+
this.inputValue = "";
|
|
2835
2837
|
}
|
|
2836
2838
|
FileUploadComponent_1 = FileUploadComponent;
|
|
2839
|
+
Object.defineProperty(FileUploadComponent.prototype, "files", {
|
|
2840
|
+
get: function () {
|
|
2841
|
+
return this._files;
|
|
2842
|
+
},
|
|
2843
|
+
set: function (files) {
|
|
2844
|
+
var _this = this;
|
|
2845
|
+
this._files = files.map(function (file) {
|
|
2846
|
+
if (_this.isImage(file)) {
|
|
2847
|
+
file.objectURL = _this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
|
|
2848
|
+
}
|
|
2849
|
+
return file;
|
|
2850
|
+
});
|
|
2851
|
+
},
|
|
2852
|
+
enumerable: true,
|
|
2853
|
+
configurable: true
|
|
2854
|
+
});
|
|
2855
|
+
FileUploadComponent.prototype.ngOnInit = function () {
|
|
2856
|
+
this.supportedExtensions = this.supportedExtensions
|
|
2857
|
+
.map(function (extension) { return extension.replace(".", "").toLowerCase(); });
|
|
2858
|
+
};
|
|
2837
2859
|
FileUploadComponent.prototype.ngOnDestroy = function () {
|
|
2838
2860
|
this.ngUsubscribe.next();
|
|
2839
2861
|
this.ngUsubscribe.complete();
|
|
@@ -2857,9 +2879,13 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2857
2879
|
try {
|
|
2858
2880
|
for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
|
|
2859
2881
|
var file = files_1_1.value;
|
|
2882
|
+
if (this.isUnsupportedFileExtension(file)) {
|
|
2883
|
+
this.validateErros.emit(ValidateErrors.UNSUPPORTED_EXTENSION);
|
|
2884
|
+
continue;
|
|
2885
|
+
}
|
|
2860
2886
|
if (this.isFileSizeExceeded(file)) {
|
|
2861
2887
|
this.validateErros.emit(ValidateErrors.MAX_FILE_SIZE);
|
|
2862
|
-
|
|
2888
|
+
continue;
|
|
2863
2889
|
}
|
|
2864
2890
|
newFiles.push(file);
|
|
2865
2891
|
}
|
|
@@ -2898,22 +2924,6 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2898
2924
|
anchor: this.anchor,
|
|
2899
2925
|
});
|
|
2900
2926
|
};
|
|
2901
|
-
Object.defineProperty(FileUploadComponent.prototype, "files", {
|
|
2902
|
-
get: function () {
|
|
2903
|
-
return this._files;
|
|
2904
|
-
},
|
|
2905
|
-
set: function (files) {
|
|
2906
|
-
var _this = this;
|
|
2907
|
-
this._files = files.map(function (file) {
|
|
2908
|
-
if (_this.isImage(file)) {
|
|
2909
|
-
file.objectURL = _this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
|
|
2910
|
-
}
|
|
2911
|
-
return file;
|
|
2912
|
-
});
|
|
2913
|
-
},
|
|
2914
|
-
enumerable: true,
|
|
2915
|
-
configurable: true
|
|
2916
|
-
});
|
|
2917
2927
|
FileUploadComponent.prototype.update = function () {
|
|
2918
2928
|
var windowWidth = window.innerWidth;
|
|
2919
2929
|
this.isSmallDevice = windowWidth <= Breakpoints.SM_MAX;
|
|
@@ -2933,6 +2943,16 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2933
2943
|
}
|
|
2934
2944
|
return file.size > this.maxFileSize;
|
|
2935
2945
|
};
|
|
2946
|
+
FileUploadComponent.prototype.isUnsupportedFileExtension = function (file) {
|
|
2947
|
+
var _a;
|
|
2948
|
+
if ((_a = this.supportedExtensions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2949
|
+
var extension = file.name.split(".").pop().toLowerCase();
|
|
2950
|
+
if (!this.supportedExtensions.includes(extension)) {
|
|
2951
|
+
return true;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
return false;
|
|
2955
|
+
};
|
|
2936
2956
|
var FileUploadComponent_1;
|
|
2937
2957
|
FileUploadComponent.nextId = 0;
|
|
2938
2958
|
FileUploadComponent.ctorParameters = function () { return [
|
|
@@ -2965,6 +2985,9 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2965
2985
|
__decorate([
|
|
2966
2986
|
Input()
|
|
2967
2987
|
], FileUploadComponent.prototype, "accept", void 0);
|
|
2988
|
+
__decorate([
|
|
2989
|
+
Input()
|
|
2990
|
+
], FileUploadComponent.prototype, "supportedExtensions", void 0);
|
|
2968
2991
|
__decorate([
|
|
2969
2992
|
Input()
|
|
2970
2993
|
], FileUploadComponent.prototype, "ariaLabelFileName", void 0);
|
|
@@ -2992,6 +3015,9 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
2992
3015
|
__decorate([
|
|
2993
3016
|
Input()
|
|
2994
3017
|
], FileUploadComponent.prototype, "disabled", void 0);
|
|
3018
|
+
__decorate([
|
|
3019
|
+
Input()
|
|
3020
|
+
], FileUploadComponent.prototype, "files", null);
|
|
2995
3021
|
__decorate([
|
|
2996
3022
|
Output()
|
|
2997
3023
|
], FileUploadComponent.prototype, "uploadHandler", void 0);
|
|
@@ -3010,9 +3036,6 @@ var FileUploadComponent = /** @class */ (function () {
|
|
|
3010
3036
|
__decorate([
|
|
3011
3037
|
HostListener("window:resize")
|
|
3012
3038
|
], FileUploadComponent.prototype, "onResize", null);
|
|
3013
|
-
__decorate([
|
|
3014
|
-
Input()
|
|
3015
|
-
], FileUploadComponent.prototype, "files", null);
|
|
3016
3039
|
FileUploadComponent = FileUploadComponent_1 = __decorate([
|
|
3017
3040
|
Component({
|
|
3018
3041
|
selector: "s-file-upload",
|