@porscheinformatik/material-addons 17.0.0 → 17.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.
@@ -54,6 +54,8 @@ import * as i1$5 from '@angular/cdk/a11y';
54
54
  import * as i3$2 from '@angular/cdk/bidi';
55
55
  import * as i2$4 from '@angular/material/stepper';
56
56
  import { MatStepperModule } from '@angular/material/stepper';
57
+ import * as i4$1 from '@angular/material/chips';
58
+ import { MatChipsModule } from '@angular/material/chips';
57
59
 
58
60
  class MaterialActionButtonComponent {
59
61
  constructor() {
@@ -2193,7 +2195,9 @@ class DataTableComponent {
2193
2195
  return this.selectionModel.isSelected(rowId);
2194
2196
  }
2195
2197
  setFilterValue(value) {
2196
- this.dataSource.filter = value?.trim().toLowerCase();
2198
+ if (this.dataSource) {
2199
+ this.dataSource.filter = value?.trim().toLowerCase();
2200
+ }
2197
2201
  }
2198
2202
  onRowEvent(event, row, action = this.defaultAction) {
2199
2203
  if (row?.parentId) {
@@ -2352,7 +2356,7 @@ class DataTableComponent {
2352
2356
  }
2353
2357
  unsetPageSizeIfNecessary() {
2354
2358
  if (!this.useAsync && !this.isPaginationEnabled) {
2355
- const dataCount = this.dataSource.data ? this.dataSource.data.length : 0;
2359
+ const dataCount = this.dataSource?.data ? this.dataSource.data.length : 0;
2356
2360
  this.paginatorPageSize = dataCount;
2357
2361
  this.paginatorLength = dataCount;
2358
2362
  }
@@ -3071,6 +3075,124 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImpor
3071
3075
  }]
3072
3076
  }] });
3073
3077
 
3078
+ class DragAndDropDirectiveDirective {
3079
+ constructor() {
3080
+ this.onFileDropped = new EventEmitter();
3081
+ this.background = '$background-color';
3082
+ this.opacity = '1';
3083
+ }
3084
+ //Dragover listener
3085
+ onDragOver(event) {
3086
+ event.preventDefault();
3087
+ event.stopPropagation();
3088
+ this.background = '$selection-background';
3089
+ this.opacity = '0.8';
3090
+ }
3091
+ //Dragleave listener
3092
+ onDragLeave(event) {
3093
+ event.preventDefault();
3094
+ event.stopPropagation();
3095
+ this.background = '$background-color';
3096
+ this.opacity = '1';
3097
+ }
3098
+ //Drop listener
3099
+ ondrop(event) {
3100
+ event.preventDefault();
3101
+ event.stopPropagation();
3102
+ this.background = '$background-color';
3103
+ this.opacity = '1';
3104
+ let files = event.dataTransfer.files;
3105
+ if (files.length > 0) {
3106
+ this.onFileDropped.emit(files);
3107
+ }
3108
+ }
3109
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DragAndDropDirectiveDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
3110
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.4", type: DragAndDropDirectiveDirective, isStandalone: true, selector: "[madDragAndDrop]", outputs: { onFileDropped: "onFileDropped" }, host: { listeners: { "dragover": "onDragOver($event)", "dragleave": "onDragLeave($event)", "drop": "ondrop($event)" }, properties: { "style.background-color": "this.background", "style.opacity": "this.opacity" } }, ngImport: i0 }); }
3111
+ }
3112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DragAndDropDirectiveDirective, decorators: [{
3113
+ type: Directive,
3114
+ args: [{
3115
+ selector: '[madDragAndDrop]',
3116
+ standalone: true
3117
+ }]
3118
+ }], propDecorators: { onFileDropped: [{
3119
+ type: Output
3120
+ }], background: [{
3121
+ type: HostBinding,
3122
+ args: ['style.background-color']
3123
+ }], opacity: [{
3124
+ type: HostBinding,
3125
+ args: ['style.opacity']
3126
+ }], onDragOver: [{
3127
+ type: HostListener,
3128
+ args: ['dragover', ['$event']]
3129
+ }], onDragLeave: [{
3130
+ type: HostListener,
3131
+ args: ['dragleave', ['$event']]
3132
+ }], ondrop: [{
3133
+ type: HostListener,
3134
+ args: ['drop', ['$event']]
3135
+ }] } });
3136
+
3137
+ class FileUploadComponent {
3138
+ constructor() {
3139
+ this.showFileList = false;
3140
+ this.fileEmitter = new EventEmitter();
3141
+ this.errorEmitter = new EventEmitter();
3142
+ this.fileList = [];
3143
+ this.uploadError = false;
3144
+ }
3145
+ uploadFile(fileList) {
3146
+ if (!this.multiple && (fileList.length > 1 || this.fileList.length === 1)) {
3147
+ this.errorEmitter.emit("ONLY_SINGLE_FILE");
3148
+ this.uploadError = false;
3149
+ return;
3150
+ }
3151
+ if (this.accept && this.accept.length > 0) {
3152
+ for (let i = 0; i < fileList.length; i++) {
3153
+ this.getFileEnding(fileList.item(i).name);
3154
+ }
3155
+ }
3156
+ if (!this.uploadError) {
3157
+ for (let i = 0; i < fileList.length; i++) {
3158
+ this.fileList.push(fileList.item(i));
3159
+ }
3160
+ this.fileEmitter.emit(fileList);
3161
+ }
3162
+ this.uploadError = false;
3163
+ }
3164
+ getFileEnding(name) {
3165
+ const ending = name.substring(name.lastIndexOf('.') + 1);
3166
+ if (this.accept.filter(a => a.toLowerCase() === ending.toLowerCase()).length === 0) {
3167
+ this.errorEmitter.emit("FILETYPE_NOT_SUPPORTED");
3168
+ this.uploadError = true;
3169
+ }
3170
+ }
3171
+ openFile(file) {
3172
+ window.open(window.URL.createObjectURL(file));
3173
+ }
3174
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: FileUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
3175
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: FileUploadComponent, isStandalone: true, selector: "mad-file-upload", inputs: { id: "id", multiple: "multiple", accept: "accept", text: "text", showFileList: "showFileList" }, outputs: { fileEmitter: "fileEmitter", errorEmitter: "errorEmitter" }, ngImport: i0, template: "<mat-card (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\">\n <input #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"accept\"\n [id]=\"id\"\n [multiple]=\"multiple\"\n hidden type=\"file\">\n <mat-card-content>\n <mat-icon>vertical_align_top</mat-icon>\n {{text ? text : 'Upload'}}\n </mat-card-content>\n</mat-card>\n\n<ng-container *ngIf=\"showFileList\">\n <mat-chip-listbox>\n <mat-chip *ngFor=\"let file of fileList\" (click)=\"openFile(file)\" class=\"download\">{{file.name}}</mat-chip>\n </mat-chip-listbox>\n</ng-container>\n", styles: [".uploadFileContainer{background-repeat:no-repeat;background-position:center;height:100px;margin:0;border:2px dashed var(--main-primary)}.uploadFileContainer:hover{cursor:pointer;background-color:var(--selection-background)!important;opacity:.8}.uploadFileContainer,.mat-mdc-card-content{display:flex;justify-content:center;align-items:center}.download{width:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i2$3.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i2$3.MatCardContent, selector: "mat-card-content" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "directive", type: DragAndDropDirectiveDirective, selector: "[madDragAndDrop]", outputs: ["onFileDropped"] }, { kind: "ngmodule", type: MatChipsModule }, { kind: "component", type: i4$1.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["color", "disabled", "disableRipple", "tabIndex", "role", "id", "aria-label", "aria-description", "value", "removable", "highlighted"], outputs: ["removed", "destroyed"], exportAs: ["matChip"] }, { kind: "component", type: i4$1.MatChipListbox, selector: "mat-chip-listbox", inputs: ["tabIndex", "multiple", "aria-orientation", "selectable", "compareWith", "required", "hideSingleSelectionIndicator", "value"], outputs: ["change"] }] }); }
3176
+ }
3177
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: FileUploadComponent, decorators: [{
3178
+ type: Component,
3179
+ args: [{ selector: 'mad-file-upload', standalone: true, imports: [CommonModule, MatCardModule, MatIconModule, ButtonModule, TranslateModule, DragAndDropDirectiveDirective, MatChipsModule], template: "<mat-card (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\">\n <input #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"accept\"\n [id]=\"id\"\n [multiple]=\"multiple\"\n hidden type=\"file\">\n <mat-card-content>\n <mat-icon>vertical_align_top</mat-icon>\n {{text ? text : 'Upload'}}\n </mat-card-content>\n</mat-card>\n\n<ng-container *ngIf=\"showFileList\">\n <mat-chip-listbox>\n <mat-chip *ngFor=\"let file of fileList\" (click)=\"openFile(file)\" class=\"download\">{{file.name}}</mat-chip>\n </mat-chip-listbox>\n</ng-container>\n", styles: [".uploadFileContainer{background-repeat:no-repeat;background-position:center;height:100px;margin:0;border:2px dashed var(--main-primary)}.uploadFileContainer:hover{cursor:pointer;background-color:var(--selection-background)!important;opacity:.8}.uploadFileContainer,.mat-mdc-card-content{display:flex;justify-content:center;align-items:center}.download{width:100%}\n"] }]
3180
+ }], propDecorators: { id: [{
3181
+ type: Input
3182
+ }], multiple: [{
3183
+ type: Input
3184
+ }], accept: [{
3185
+ type: Input
3186
+ }], text: [{
3187
+ type: Input
3188
+ }], showFileList: [{
3189
+ type: Input
3190
+ }], fileEmitter: [{
3191
+ type: Output
3192
+ }], errorEmitter: [{
3193
+ type: Output
3194
+ }] } });
3195
+
3074
3196
  /*
3075
3197
  * Public API Surface of material-addons
3076
3198
  */
@@ -3079,5 +3201,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImpor
3079
3201
  * Generated bundle index. Do not edit.
3080
3202
  */
3081
3203
 
3082
- export { BaseQuickListComponent, ButtonModule, CardComponent, CardModule, ContentHeaderComponent, ContentPanelContainerComponent, ContentPanelContainerContentComponent, ContentPanelContainerFooterComponent, ContentPanelModule, DangerButtonComponent, DataTableColumnsModalComponent, DataTableComponent, DataTableModule, FlowbarComponent, FlowbarModule, IconButtonComponent, LinkButtonComponent, MadBasicButton, MainContainerComponent, MaterialActionButtonComponent, MaterialActionButtonModule, MaterialAddonsModule, NumberFormatService, NumericFieldDirective, NumericFieldModule, OutlineButtonComponent, PrimaryButtonComponent, QuickListCompactComponent, QuickListComponent, QuickListModule, ReactiveFormQuickListCompactComponent, ReactiveFormQuickListComponent, ReadOnlyFormFieldComponent, ReadOnlyFormFieldModule, ReadOnlyFormFieldWrapperComponent, StepComponent, StepHeaderComponent, StepperComponent, StepperModule, TableComponent, TableModule, ThrottleClickDirective, ThrottleClickModule, ToolbarComponent, ToolbarModule, ToolbarService, madStepperAnimations };
3204
+ export { BaseQuickListComponent, ButtonModule, CardComponent, CardModule, ContentHeaderComponent, ContentPanelContainerComponent, ContentPanelContainerContentComponent, ContentPanelContainerFooterComponent, ContentPanelModule, DangerButtonComponent, DataTableColumnsModalComponent, DataTableComponent, DataTableModule, FileUploadComponent, FlowbarComponent, FlowbarModule, IconButtonComponent, LinkButtonComponent, MadBasicButton, MainContainerComponent, MaterialActionButtonComponent, MaterialActionButtonModule, MaterialAddonsModule, NumberFormatService, NumericFieldDirective, NumericFieldModule, OutlineButtonComponent, PrimaryButtonComponent, QuickListCompactComponent, QuickListComponent, QuickListModule, ReactiveFormQuickListCompactComponent, ReactiveFormQuickListComponent, ReadOnlyFormFieldComponent, ReadOnlyFormFieldModule, ReadOnlyFormFieldWrapperComponent, StepComponent, StepHeaderComponent, StepperComponent, StepperModule, TableComponent, TableModule, ThrottleClickDirective, ThrottleClickModule, ToolbarComponent, ToolbarModule, ToolbarService, madStepperAnimations };
3083
3205
  //# sourceMappingURL=porscheinformatik-material-addons.mjs.map