@seniorsistemas/angular-components 15.0.0 → 15.0.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/bundles/seniorsistemas-angular-components.umd.js +73 -65
- 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 +17 -33
- package/components/file-upload/index.d.ts +3 -2
- package/components/file-upload/models/file-dto.d.ts +11 -0
- package/components/file-upload/models/index.d.ts +2 -0
- package/components/file-upload/models/validate-errors.d.ts +4 -0
- package/components/token-list/index.d.ts +3 -2
- package/components/token-list/models/index.d.ts +1 -0
- package/components/token-list/models/token.d.ts +5 -0
- package/components/token-list/token-list.component.d.ts +1 -4
- package/esm2015/components/file-upload/file-upload.component.js +49 -63
- package/esm2015/components/file-upload/file-upload.module.js +7 -2
- package/esm2015/components/file-upload/index.js +4 -3
- package/esm2015/components/file-upload/models/file-dto.js +1 -0
- package/esm2015/components/file-upload/models/index.js +2 -0
- package/esm2015/components/file-upload/models/validate-errors.js +6 -0
- package/esm2015/components/token-list/index.js +3 -3
- package/esm2015/components/token-list/models/index.js +1 -0
- package/esm2015/components/token-list/models/token.js +1 -0
- package/esm2015/components/token-list/token-list.component.js +2 -2
- package/esm5/components/file-upload/file-upload.component.js +65 -67
- package/esm5/components/file-upload/file-upload.module.js +7 -2
- package/esm5/components/file-upload/index.js +4 -3
- package/esm5/components/file-upload/models/file-dto.js +1 -0
- package/esm5/components/file-upload/models/index.js +2 -0
- package/esm5/components/file-upload/models/validate-errors.js +6 -0
- package/esm5/components/token-list/index.js +3 -3
- package/esm5/components/token-list/models/index.js +1 -0
- package/esm5/components/token-list/models/token.js +1 -0
- package/esm5/components/token-list/token-list.component.js +2 -2
- package/fesm2015/seniorsistemas-angular-components.js +58 -62
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +73 -65
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -2516,6 +2516,12 @@ EmptyStateModule = __decorate([
|
|
|
2516
2516
|
})
|
|
2517
2517
|
], EmptyStateModule);
|
|
2518
2518
|
|
|
2519
|
+
var ValidateErrors;
|
|
2520
|
+
(function (ValidateErrors) {
|
|
2521
|
+
ValidateErrors["MAX_FILE_SIZE"] = "MAX_FILE_SIZE";
|
|
2522
|
+
ValidateErrors["MAX_FILE_LIMIT"] = "MAX_FILE_LIMIT";
|
|
2523
|
+
})(ValidateErrors || (ValidateErrors = {}));
|
|
2524
|
+
|
|
2519
2525
|
const Breakpoints = {
|
|
2520
2526
|
SM_MIN: 0,
|
|
2521
2527
|
SM_MAX: 767,
|
|
@@ -2617,14 +2623,10 @@ class ExportUtils {
|
|
|
2617
2623
|
}
|
|
2618
2624
|
|
|
2619
2625
|
var FileUploadComponent_1;
|
|
2620
|
-
var ValidateErrors;
|
|
2621
|
-
(function (ValidateErrors) {
|
|
2622
|
-
ValidateErrors["MAX_FILE_SIZE"] = "MAX_FILE_SIZE";
|
|
2623
|
-
ValidateErrors["MAX_FILE_LIMIT"] = "MAX_FILE_LIMIT";
|
|
2624
|
-
})(ValidateErrors || (ValidateErrors = {}));
|
|
2625
2626
|
let FileUploadComponent = FileUploadComponent_1 = class FileUploadComponent {
|
|
2626
2627
|
constructor(sanitizer) {
|
|
2627
2628
|
this.sanitizer = sanitizer;
|
|
2629
|
+
this.inputValue = "";
|
|
2628
2630
|
this.id = `s-file-upload-${FileUploadComponent_1.nextId++}`;
|
|
2629
2631
|
this.chooseLabel = "Anexar arquivos";
|
|
2630
2632
|
this.removeLabel = "Remover";
|
|
@@ -2637,11 +2639,9 @@ let FileUploadComponent = FileUploadComponent_1 = class FileUploadComponent {
|
|
|
2637
2639
|
this.cancelUpload = new EventEmitter();
|
|
2638
2640
|
this.downloadFile = new EventEmitter();
|
|
2639
2641
|
this.validateErros = new EventEmitter();
|
|
2640
|
-
this.uploadedFileCount = 0;
|
|
2641
2642
|
this._files = [];
|
|
2642
2643
|
this.ngUsubscribe = new Subject();
|
|
2643
2644
|
}
|
|
2644
|
-
ngOnInit() { }
|
|
2645
2645
|
ngOnDestroy() {
|
|
2646
2646
|
this.ngUsubscribe.next();
|
|
2647
2647
|
this.ngUsubscribe.complete();
|
|
@@ -2652,87 +2652,78 @@ let FileUploadComponent = FileUploadComponent_1 = class FileUploadComponent {
|
|
|
2652
2652
|
onResize() {
|
|
2653
2653
|
this.update();
|
|
2654
2654
|
}
|
|
2655
|
-
update() {
|
|
2656
|
-
const windowWidth = window.innerWidth;
|
|
2657
|
-
this.isSmallDevice = windowWidth <= Breakpoints.SM_MAX;
|
|
2658
|
-
}
|
|
2659
2655
|
onFileSelect(files) {
|
|
2660
|
-
const
|
|
2656
|
+
const newFiles = [];
|
|
2661
2657
|
if (!this.multiple) {
|
|
2662
2658
|
this.files = [];
|
|
2663
2659
|
}
|
|
2664
|
-
if (this.
|
|
2665
|
-
this.
|
|
2666
|
-
|
|
2667
|
-
this.uploadedFileCount -= this.files.length;
|
|
2668
|
-
this.validateErros.emit(ValidateErrors.MAX_FILE_LIMIT);
|
|
2669
|
-
return;
|
|
2670
|
-
}
|
|
2660
|
+
if (this.isFileLimitExceeded(files)) {
|
|
2661
|
+
this.validateErros.emit(ValidateErrors.MAX_FILE_LIMIT);
|
|
2662
|
+
return;
|
|
2671
2663
|
}
|
|
2672
|
-
for (
|
|
2673
|
-
const file = files[i];
|
|
2664
|
+
for (const file of files) {
|
|
2674
2665
|
if (this.isFileSizeExceeded(file)) {
|
|
2675
2666
|
this.validateErros.emit(ValidateErrors.MAX_FILE_SIZE);
|
|
2676
|
-
this.files = previousFiles;
|
|
2677
2667
|
return;
|
|
2678
2668
|
}
|
|
2679
|
-
|
|
2680
|
-
this.files.push(file);
|
|
2681
|
-
}
|
|
2669
|
+
newFiles.push(file);
|
|
2682
2670
|
}
|
|
2683
|
-
if (
|
|
2684
|
-
this.
|
|
2671
|
+
if (newFiles.length) {
|
|
2672
|
+
this.files = this.files.concat(newFiles);
|
|
2673
|
+
this.uploadHandler.emit({
|
|
2674
|
+
files: newFiles,
|
|
2675
|
+
});
|
|
2685
2676
|
this.inputUpload.nativeElement.value = "";
|
|
2686
2677
|
}
|
|
2687
2678
|
}
|
|
2688
|
-
onRemoveFile(
|
|
2689
|
-
this.files.
|
|
2690
|
-
this.
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
onCancelUpload(event, index) {
|
|
2695
|
-
this.uploadedFileCount -= 1;
|
|
2696
|
-
this.files.splice(index, 1);
|
|
2697
|
-
this.cancelUpload.emit(index);
|
|
2698
|
-
event.preventDefault();
|
|
2679
|
+
onRemoveFile(file) {
|
|
2680
|
+
const fileIndex = this.files.indexOf(file);
|
|
2681
|
+
const removedFiles = this.files.splice(fileIndex, 1);
|
|
2682
|
+
if (removedFiles.length) {
|
|
2683
|
+
this.removeFile.emit({ file });
|
|
2684
|
+
}
|
|
2699
2685
|
}
|
|
2700
|
-
|
|
2701
|
-
this.
|
|
2702
|
-
|
|
2686
|
+
onCancelUpload(index) {
|
|
2687
|
+
const removedFiles = this.files.splice(index, 1);
|
|
2688
|
+
if (removedFiles.length) {
|
|
2689
|
+
this.cancelUpload.emit(index);
|
|
2690
|
+
}
|
|
2703
2691
|
}
|
|
2704
|
-
|
|
2705
|
-
|
|
2692
|
+
onDowloadFile(index) {
|
|
2693
|
+
this.downloadFile.emit({
|
|
2694
|
+
index,
|
|
2695
|
+
anchor: this.anchor,
|
|
2696
|
+
});
|
|
2706
2697
|
}
|
|
2707
2698
|
set files(files) {
|
|
2708
|
-
this._files =
|
|
2709
|
-
for (let i = 0; i < files.length; i++) {
|
|
2710
|
-
const file = files[i];
|
|
2699
|
+
this._files = files.map(file => {
|
|
2711
2700
|
if (this.isImage(file)) {
|
|
2712
|
-
file.objectURL = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(
|
|
2701
|
+
file.objectURL = this.sanitizer.bypassSecurityTrustUrl(window.URL.createObjectURL(file));
|
|
2713
2702
|
}
|
|
2714
|
-
|
|
2715
|
-
}
|
|
2703
|
+
return file;
|
|
2704
|
+
});
|
|
2716
2705
|
}
|
|
2717
2706
|
get files() {
|
|
2718
2707
|
return this._files;
|
|
2719
2708
|
}
|
|
2720
|
-
|
|
2721
|
-
|
|
2709
|
+
update() {
|
|
2710
|
+
const windowWidth = window.innerWidth;
|
|
2711
|
+
this.isSmallDevice = windowWidth <= Breakpoints.SM_MAX;
|
|
2722
2712
|
}
|
|
2723
2713
|
isImage(file) {
|
|
2724
2714
|
return /^image\//.test(file.type);
|
|
2725
2715
|
}
|
|
2726
|
-
|
|
2727
|
-
this.
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
isFileLimitExceeded() {
|
|
2732
|
-
return this.fileLimit && this.fileLimit < this.files.length + this.uploadedFileCount;
|
|
2716
|
+
isFileLimitExceeded(files) {
|
|
2717
|
+
if (!this.fileLimit) {
|
|
2718
|
+
return false;
|
|
2719
|
+
}
|
|
2720
|
+
return this.files.length + files.length > this.fileLimit;
|
|
2733
2721
|
}
|
|
2734
2722
|
isFileSizeExceeded(file) {
|
|
2735
|
-
|
|
2723
|
+
if (!this.maxFileSize) {
|
|
2724
|
+
return false;
|
|
2725
|
+
}
|
|
2726
|
+
return file.size > this.maxFileSize;
|
|
2736
2727
|
}
|
|
2737
2728
|
};
|
|
2738
2729
|
FileUploadComponent.nextId = 0;
|
|
@@ -2817,7 +2808,7 @@ __decorate([
|
|
|
2817
2808
|
FileUploadComponent = FileUploadComponent_1 = __decorate([
|
|
2818
2809
|
Component({
|
|
2819
2810
|
selector: "s-file-upload",
|
|
2820
|
-
template: "<div
|
|
2811
|
+
template: "<div\n [id]=\"id\"\n class=\"s-fileupload\">\n <div class=\"s-fileupload-choose\">\n <input\n #inputUpload\n [id]=\"id+'input-upload'\"\n type=\"file\"\n name=\"file\"\n [accept]=\"accept\"\n [multiple]=\"multiple\"\n (change)=\"onFileSelect($event.dataTransfer\n ? $event.dataTransfer.files\n : $event.target.files)\"> \n <s-button\n [id]=\"id + 'upload-button'\"\n [label]=\"chooseLabel\"\n (onClick)=\"inputUpload.click()\"\n priority=\"primary\"\n [disabled]=\"disabled || !!formGroup?.disabled\"\n [auxiliary]=\"false\">\n </s-button>\n </div>\n\n <section\n *ngIf=\"files.length\" \n [id]=\"id + 'fileupload-list'\"\n class=\"s-fileupload-list\"\n role=\"grid\">\n <ng-container *ngFor=\"let file of files; let i = index\">\n <div\n class=\"s-fileupload-list-file\"\n role=\"row\">\n <div\n [id]=\"id + '-file-' + i + '-name'\"\n class=\"s-fileupload-list-file-name\"\n role=\"gridcell\">\n <ng-container *ngTemplateOutlet=\"file.savedFile || file.progress === 100\n ? descriptionUrl\n : description; context: {\n $implicit: file,\n index: i\n }\">\n </ng-container>\n </div>\n <div\n class=\"s-fileupload-list-file-status\"\n role=\"gridcell\">\n <p-progressBar\n *ngIf=\"file.isUploading && !isSmallDevice\"\n [style]=\"{ 'width': '250px', 'background-color': '#d8d8d8', 'border-radius': '0px', 'height': '14px'}\"\n [value]=\"file.progress\"\n [showValue]=\"false\"\n role=\"alert\"\n [attr.aria-label]=\"ariaLabelProgress\">\n </p-progressBar>\n <span\n *ngIf=\"file.isUploading && isSmallDevice\" \n [id]=\"id + '-file-' + i + '-spin'\"\n class=\"fas fa-circle-notch fa-spin\"\n [attr.aria-label]=\"ariaLabelProgress\">\n </span>\n <span\n *ngIf=\"!file.isUploading && !file.error && file.progress === 100\"\n [id]=\"id + '-file-' + i + '-check'\"\n class=\"fas fa-check\"\n role=\"alert\"\n [attr.aria-label]=\"ariaLabelSuccess || successTooltip\"\n [pTooltip]=\"successTooltip\"\n tooltipPosition=\"top\"\n showDelay=\"500\"\n [appendTo]=\"'body'\">\n </span>\n <span\n *ngIf=\"file.error?.message\" \n [id]=\"id + '-file-' + i + '-error'\"\n class=\"fas fa-times\"\n role=\"alert\"\n [pTooltip]=\"file.error?.message\"\n tooltipPosition=\"top\"\n showDelay=\"500\"\n [appendTo]=\"'body'\">\n </span>\n </div>\n <div\n class=\"s-fileupload-list-file-actions\"\n role=\"gridcell\">\n <a\n *ngIf=\"file.isUploading\"\n [id]=\"id + '-file-' + i + '-cancel'\"\n class=\"s-fileupload-list-file-actions-action\"\n (click)=\"onCancelUpload(i)\">\n {{cancelLabel}}\n </a>\n <a\n *ngIf=\"!file.isUploading && !(disabled || !!formGroup?.disabled)\"\n role=\"button\"\n tabindex=\"0\"\n [id]=\"id + '-file-' + i + '-remove'\"\n class=\"s-fileupload-list-file-actions-action\"\n (click)=\"onRemoveFile(file)\"\n [attr.aria-label]=\"ariaLabelRemove || removeLabel\">\n {{removeLabel}}\n </a>\n </div>\n </div>\n </ng-container>\n </section>\n</div>\n\n<ng-template\n #descriptionUrl\n let-file\n let-i = index>\n <a\n [id]=\"id + '-file-' + i + '-name-link'\"\n tabindex=\"0\"\n (click)=\"onDowloadFile(i)\"\n [attr.aria-label]=\"ariaLabelFileName || file.name\">{{file.name}}\n </a>\n <a\n style=\"display: none;\"\n [href]=\"file.objectURL\"\n target=\"_blank\"\n download\n #anchor>\n </a>\n</ng-template>\n\n<ng-template\n #description\n let-file>\n <span\n tabindex=\"0\"\n [attr.aria-label]=\"ariaLabelFileName || file.name\">\n {{file.name}}\n </span>\n</ng-template>\n",
|
|
2821
2812
|
styles: [".s-fileupload .s-fileupload-choose{position:relative;margin:15px 0;width:-webkit-max-content;width:max-content}.s-fileupload input[type=file]{display:none}.s-fileupload-list{border:1px solid #ccc}.s-fileupload-list-file:not(:first-child){border-top:1px solid #ccc}.s-fileupload-list .s-fileupload-list-file{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:justify;justify-content:space-between;padding:15px}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-name{-ms-flex-item-align:center;-ms-grid-row-align:center;align-self:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-name>a{cursor:pointer;text-decoration:none}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-status{-ms-flex-item-align:center;-ms-grid-row-align:center;align-self:center}.s-fileupload-list .s-fileupload-list-file .fas.fa-circle-notch{color:#d8d8d8;font-size:12px}.s-fileupload-list .s-fileupload-list-file .fas.fa-check{color:#0c9348;font-size:12px}.s-fileupload-list .s-fileupload-list-file .fas.fa-times{color:#c13018;font-size:12px}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions{margin-top:15px;-ms-flex-item-align:center;-ms-grid-row-align:center;align-self:center;width:100%}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions a.s-fileupload-list-file-actions-action{text-decoration:none;color:#428bca}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions a.s-fileupload-list-file-actions-action :focus,.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions a.s-fileupload-list-file-actions-action :visited,.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions a.s-fileupload-list-file-actions-action:hover{text-decoration:none}@media (min-width:768px){.s-fileupload-list .s-fileupload-list-file{-ms-flex-wrap:nowrap;flex-wrap:nowrap}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-name{width:auto;-ms-flex-positive:2;flex-grow:2}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-status{margin:0 15px}.s-fileupload-list .s-fileupload-list-file .s-fileupload-list-file-actions{margin:0;width:auto}}"]
|
|
2822
2813
|
})
|
|
2823
2814
|
], FileUploadComponent);
|
|
@@ -2827,7 +2818,12 @@ let FileUploadModule = class FileUploadModule {
|
|
|
2827
2818
|
FileUploadModule = __decorate([
|
|
2828
2819
|
NgModule({
|
|
2829
2820
|
declarations: [FileUploadComponent],
|
|
2830
|
-
imports: [
|
|
2821
|
+
imports: [
|
|
2822
|
+
CommonModule,
|
|
2823
|
+
ButtonModule,
|
|
2824
|
+
TooltipModule,
|
|
2825
|
+
ProgressBarModule,
|
|
2826
|
+
],
|
|
2831
2827
|
exports: [FileUploadComponent],
|
|
2832
2828
|
})
|
|
2833
2829
|
], FileUploadModule);
|
|
@@ -4045,7 +4041,7 @@ __decorate([
|
|
|
4045
4041
|
TokenListComponent = TokenListComponent_1 = __decorate([
|
|
4046
4042
|
Component({
|
|
4047
4043
|
selector: `s-token-list`,
|
|
4048
|
-
template: "<div\n [id]=\"id\"\n class=\"token-list\">\n <ng-container *ngFor=\"let token of tokens\">\n <span\n [id]=\"token.id\"\n class=\"token\"\n [ngClass]=\"{ 'no-pointer-events': hidePointerEvents }\">\n <a\n [id]=\"(token.id || 'token') + '-label'\"\n class=\"token-label\"\n (click)=\"tokenSelected.next(token)\">\n {{ token.label }}\n </a>\n <span\n *ngIf=\"removableTokens\"\n [id]=\"token.id + '-remove'\"\n class=\"token-icon fa fa-fw fa-close\"\n (click)=\"tokenRemoved.next(token)\">\n </span>\n </span>\n </ng-container>\n</div>",
|
|
4044
|
+
template: "<div\n [id]=\"id\"\n class=\"token-list\">\n <ng-container *ngFor=\"let token of tokens\">\n <span\n [id]=\"token.id\"\n class=\"token\"\n [ngClass]=\"{ 'no-pointer-events': hidePointerEvents }\">\n <a\n [id]=\"(token.id || 'token') + '-label'\"\n class=\"token-label\"\n (click)=\"tokenSelected.next(token)\">\n {{ token.label }}\n </a>\n <span\n *ngIf=\"removableTokens && !token.notRemovable\"\n [id]=\"token.id + '-remove'\"\n class=\"token-icon fa fa-fw fa-close\"\n (click)=\"tokenRemoved.next(token)\">\n </span>\n </span>\n </ng-container>\n</div>",
|
|
4049
4045
|
styles: [".no-pointer-events{pointer-events:none}.token-list{-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;padding:0 10px;text-transform:none}.token-list .token{-ms-flex-align:center;align-items:center;background-color:#ccc;border-radius:4px;color:#333;display:-ms-flexbox;display:flex;font:400 12px/150% \"Open Sans\",sans-serif;margin:2px 5px 0 0;max-width:100%;padding:2px 8px}.token-list .token-label{max-width:50ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.token-list .token:focus,.token-list .token:hover{background-color:#e5eaea}.token-list .token a{text-decoration:none;color:#333}"]
|
|
4050
4046
|
})
|
|
4051
4047
|
], TokenListComponent);
|