@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
|
@@ -2879,6 +2879,7 @@
|
|
|
2879
2879
|
(function (ValidateErrors) {
|
|
2880
2880
|
ValidateErrors["MAX_FILE_SIZE"] = "MAX_FILE_SIZE";
|
|
2881
2881
|
ValidateErrors["MAX_FILE_LIMIT"] = "MAX_FILE_LIMIT";
|
|
2882
|
+
ValidateErrors["UNSUPPORTED_EXTENSION"] = "UNSUPPORTED_EXTENSION";
|
|
2882
2883
|
})(exports.ValidateErrors || (exports.ValidateErrors = {}));
|
|
2883
2884
|
|
|
2884
2885
|
var Breakpoints = {
|
|
@@ -2990,12 +2991,12 @@
|
|
|
2990
2991
|
var FileUploadComponent = /** @class */ (function () {
|
|
2991
2992
|
function FileUploadComponent(sanitizer) {
|
|
2992
2993
|
this.sanitizer = sanitizer;
|
|
2993
|
-
this.inputValue = "";
|
|
2994
2994
|
this.id = "s-file-upload-" + FileUploadComponent_1.nextId++;
|
|
2995
2995
|
this.chooseLabel = "Anexar arquivos";
|
|
2996
2996
|
this.removeLabel = "Remover";
|
|
2997
2997
|
this.cancelLabel = "Cancelar";
|
|
2998
2998
|
this.successTooltip = "Arquivo anexado com sucesso";
|
|
2999
|
+
this.supportedExtensions = [];
|
|
2999
3000
|
this.ariaLabelProgress = "Carregando arquivo";
|
|
3000
3001
|
this.disabled = false;
|
|
3001
3002
|
this.uploadHandler = new core.EventEmitter();
|
|
@@ -3005,8 +3006,29 @@
|
|
|
3005
3006
|
this.validateErros = new core.EventEmitter();
|
|
3006
3007
|
this._files = [];
|
|
3007
3008
|
this.ngUsubscribe = new rxjs.Subject();
|
|
3009
|
+
this.inputValue = "";
|
|
3008
3010
|
}
|
|
3009
3011
|
FileUploadComponent_1 = FileUploadComponent;
|
|
3012
|
+
Object.defineProperty(FileUploadComponent.prototype, "files", {
|
|
3013
|
+
get: function () {
|
|
3014
|
+
return this._files;
|
|
3015
|
+
},
|
|
3016
|
+
set: function (files) {
|
|
3017
|
+
var _this = this;
|
|
3018
|
+
this._files = files.map(function (file) {
|
|
3019
|
+
if (_this.isImage(file)) {
|
|
3020
|
+
file.objectURL = _this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
|
|
3021
|
+
}
|
|
3022
|
+
return file;
|
|
3023
|
+
});
|
|
3024
|
+
},
|
|
3025
|
+
enumerable: true,
|
|
3026
|
+
configurable: true
|
|
3027
|
+
});
|
|
3028
|
+
FileUploadComponent.prototype.ngOnInit = function () {
|
|
3029
|
+
this.supportedExtensions = this.supportedExtensions
|
|
3030
|
+
.map(function (extension) { return extension.replace(".", "").toLowerCase(); });
|
|
3031
|
+
};
|
|
3010
3032
|
FileUploadComponent.prototype.ngOnDestroy = function () {
|
|
3011
3033
|
this.ngUsubscribe.next();
|
|
3012
3034
|
this.ngUsubscribe.complete();
|
|
@@ -3030,9 +3052,13 @@
|
|
|
3030
3052
|
try {
|
|
3031
3053
|
for (var files_1 = __values(files), files_1_1 = files_1.next(); !files_1_1.done; files_1_1 = files_1.next()) {
|
|
3032
3054
|
var file = files_1_1.value;
|
|
3055
|
+
if (this.isUnsupportedFileExtension(file)) {
|
|
3056
|
+
this.validateErros.emit(exports.ValidateErrors.UNSUPPORTED_EXTENSION);
|
|
3057
|
+
continue;
|
|
3058
|
+
}
|
|
3033
3059
|
if (this.isFileSizeExceeded(file)) {
|
|
3034
3060
|
this.validateErros.emit(exports.ValidateErrors.MAX_FILE_SIZE);
|
|
3035
|
-
|
|
3061
|
+
continue;
|
|
3036
3062
|
}
|
|
3037
3063
|
newFiles.push(file);
|
|
3038
3064
|
}
|
|
@@ -3071,22 +3097,6 @@
|
|
|
3071
3097
|
anchor: this.anchor,
|
|
3072
3098
|
});
|
|
3073
3099
|
};
|
|
3074
|
-
Object.defineProperty(FileUploadComponent.prototype, "files", {
|
|
3075
|
-
get: function () {
|
|
3076
|
-
return this._files;
|
|
3077
|
-
},
|
|
3078
|
-
set: function (files) {
|
|
3079
|
-
var _this = this;
|
|
3080
|
-
this._files = files.map(function (file) {
|
|
3081
|
-
if (_this.isImage(file)) {
|
|
3082
|
-
file.objectURL = _this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
|
|
3083
|
-
}
|
|
3084
|
-
return file;
|
|
3085
|
-
});
|
|
3086
|
-
},
|
|
3087
|
-
enumerable: true,
|
|
3088
|
-
configurable: true
|
|
3089
|
-
});
|
|
3090
3100
|
FileUploadComponent.prototype.update = function () {
|
|
3091
3101
|
var windowWidth = window.innerWidth;
|
|
3092
3102
|
this.isSmallDevice = windowWidth <= Breakpoints.SM_MAX;
|
|
@@ -3106,6 +3116,16 @@
|
|
|
3106
3116
|
}
|
|
3107
3117
|
return file.size > this.maxFileSize;
|
|
3108
3118
|
};
|
|
3119
|
+
FileUploadComponent.prototype.isUnsupportedFileExtension = function (file) {
|
|
3120
|
+
var _a;
|
|
3121
|
+
if ((_a = this.supportedExtensions) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3122
|
+
var extension = file.name.split(".").pop().toLowerCase();
|
|
3123
|
+
if (!this.supportedExtensions.includes(extension)) {
|
|
3124
|
+
return true;
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
return false;
|
|
3128
|
+
};
|
|
3109
3129
|
var FileUploadComponent_1;
|
|
3110
3130
|
FileUploadComponent.nextId = 0;
|
|
3111
3131
|
FileUploadComponent.ctorParameters = function () { return [
|
|
@@ -3138,6 +3158,9 @@
|
|
|
3138
3158
|
__decorate([
|
|
3139
3159
|
core.Input()
|
|
3140
3160
|
], FileUploadComponent.prototype, "accept", void 0);
|
|
3161
|
+
__decorate([
|
|
3162
|
+
core.Input()
|
|
3163
|
+
], FileUploadComponent.prototype, "supportedExtensions", void 0);
|
|
3141
3164
|
__decorate([
|
|
3142
3165
|
core.Input()
|
|
3143
3166
|
], FileUploadComponent.prototype, "ariaLabelFileName", void 0);
|
|
@@ -3165,6 +3188,9 @@
|
|
|
3165
3188
|
__decorate([
|
|
3166
3189
|
core.Input()
|
|
3167
3190
|
], FileUploadComponent.prototype, "disabled", void 0);
|
|
3191
|
+
__decorate([
|
|
3192
|
+
core.Input()
|
|
3193
|
+
], FileUploadComponent.prototype, "files", null);
|
|
3168
3194
|
__decorate([
|
|
3169
3195
|
core.Output()
|
|
3170
3196
|
], FileUploadComponent.prototype, "uploadHandler", void 0);
|
|
@@ -3183,9 +3209,6 @@
|
|
|
3183
3209
|
__decorate([
|
|
3184
3210
|
core.HostListener("window:resize")
|
|
3185
3211
|
], FileUploadComponent.prototype, "onResize", null);
|
|
3186
|
-
__decorate([
|
|
3187
|
-
core.Input()
|
|
3188
|
-
], FileUploadComponent.prototype, "files", null);
|
|
3189
3212
|
FileUploadComponent = FileUploadComponent_1 = __decorate([
|
|
3190
3213
|
core.Component({
|
|
3191
3214
|
selector: "s-file-upload",
|