@porscheinformatik/material-addons 18.0.3 → 18.0.5
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/esm2022/lib/file-upload/file-upload.component.mjs +49 -24
- package/esm2022/lib/numeric-field/number-format.service.mjs +11 -4
- package/esm2022/lib/numeric-field/numeric-field.directive.mjs +2 -2
- package/esm2022/lib/numeric-field/numeric-field.module.mjs +2 -5
- package/esm2022/version.mjs +2 -2
- package/fesm2022/porscheinformatik-material-addons.mjs +60 -30
- package/fesm2022/porscheinformatik-material-addons.mjs.map +1 -1
- package/lib/file-upload/file-upload.component.d.ts +12 -5
- package/lib/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/numeric-field/number-format.service.d.ts +5 -0
- package/lib/numeric-field/number-format.service.d.ts.map +1 -1
- package/lib/numeric-field/numeric-field.directive.d.ts.map +1 -1
- package/lib/numeric-field/numeric-field.module.d.ts.map +1 -1
- package/package.json +1 -1
- package/version.d.ts +1 -1
|
@@ -404,6 +404,13 @@ class NumberFormatService {
|
|
|
404
404
|
static { this.DEFAULT_REMOVE_LEADING_ZEROS = false; }
|
|
405
405
|
constructor(locale) {
|
|
406
406
|
this.allowedKeys = [];
|
|
407
|
+
this.prepareSeparators(locale);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Call this if the locale is changed to update the separators.
|
|
411
|
+
* @param locale the new locale
|
|
412
|
+
*/
|
|
413
|
+
prepareSeparators(locale) {
|
|
407
414
|
// try to get the current formatting
|
|
408
415
|
const localeDecimalSeparator = (1.1).toLocaleString(locale).charAt(1);
|
|
409
416
|
this.decimalSeparator = localeDecimalSeparator === ',' ? ',' : '.';
|
|
@@ -520,12 +527,12 @@ class NumberFormatService {
|
|
|
520
527
|
return NumberFormatService.valueIsSet(value) ? value : defaultValue;
|
|
521
528
|
}
|
|
522
529
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumberFormatService, deps: [{ token: LOCALE_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
523
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumberFormatService, providedIn: '
|
|
530
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumberFormatService, providedIn: 'root' }); }
|
|
524
531
|
}
|
|
525
532
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumberFormatService, decorators: [{
|
|
526
533
|
type: Injectable,
|
|
527
534
|
args: [{
|
|
528
|
-
providedIn: '
|
|
535
|
+
providedIn: 'root',
|
|
529
536
|
}]
|
|
530
537
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
531
538
|
type: Inject,
|
|
@@ -1210,7 +1217,7 @@ class NumericFieldDirective {
|
|
|
1210
1217
|
if (this.roundValue) {
|
|
1211
1218
|
return Math.round(value * Math.pow(10, this.decimalPlaces)) / Math.pow(10, this.decimalPlaces);
|
|
1212
1219
|
}
|
|
1213
|
-
const method = value < 0 ?
|
|
1220
|
+
const method = value < 0 ? 'ceil' : 'floor';
|
|
1214
1221
|
return Math[method](+(value * Math.pow(10, this.decimalPlaces)).toFixed(this.decimalPlaces)) / Math.pow(10, this.decimalPlaces);
|
|
1215
1222
|
}
|
|
1216
1223
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: NumberFormatService }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
@@ -1271,18 +1278,16 @@ class NumericFieldModule {
|
|
|
1271
1278
|
static forRoot() {
|
|
1272
1279
|
return {
|
|
1273
1280
|
ngModule: NumericFieldModule,
|
|
1274
|
-
providers: [NumberFormatService],
|
|
1275
1281
|
};
|
|
1276
1282
|
}
|
|
1277
1283
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1278
1284
|
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldModule, imports: [NumericFieldDirective], exports: [NumericFieldDirective] }); }
|
|
1279
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldModule
|
|
1285
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldModule }); }
|
|
1280
1286
|
}
|
|
1281
1287
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NumericFieldModule, decorators: [{
|
|
1282
1288
|
type: NgModule,
|
|
1283
1289
|
args: [{
|
|
1284
1290
|
imports: [NumericFieldDirective],
|
|
1285
|
-
providers: [NumberFormatService],
|
|
1286
1291
|
exports: [NumericFieldDirective],
|
|
1287
1292
|
}]
|
|
1288
1293
|
}] });
|
|
@@ -4251,52 +4256,75 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
|
4251
4256
|
class FileUploadComponent {
|
|
4252
4257
|
constructor() {
|
|
4253
4258
|
this.showFileList = false;
|
|
4259
|
+
this.removable = true;
|
|
4254
4260
|
this.fileEmitter = new EventEmitter();
|
|
4255
4261
|
this.errorEmitter = new EventEmitter();
|
|
4256
4262
|
this.fileList = [];
|
|
4257
|
-
this.
|
|
4258
|
-
this.uploadError = false;
|
|
4263
|
+
this.acceptedFileTypes = [];
|
|
4259
4264
|
}
|
|
4260
4265
|
ngOnInit() {
|
|
4266
|
+
this.setAcceptedFileTypes();
|
|
4267
|
+
}
|
|
4268
|
+
setAcceptedFileTypes() {
|
|
4261
4269
|
if (this.accept?.length) {
|
|
4262
|
-
this.accept.
|
|
4270
|
+
this.acceptedFileTypes = this.accept.map((ext) => `.${ext.toLowerCase()}`);
|
|
4263
4271
|
}
|
|
4264
4272
|
}
|
|
4265
|
-
uploadFile(
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
this.uploadError = false;
|
|
4273
|
+
uploadFile(files) {
|
|
4274
|
+
const fileArray = Array.from(files);
|
|
4275
|
+
if (!this.validateFileList(fileArray)) {
|
|
4269
4276
|
return;
|
|
4270
4277
|
}
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4278
|
+
this.addFiles(fileArray);
|
|
4279
|
+
this.fileEmitter.emit(this.createFileListFromArray(this.fileList));
|
|
4280
|
+
}
|
|
4281
|
+
validateFileList(fileArray) {
|
|
4282
|
+
if (!this.multiple && fileArray.length > 1) {
|
|
4283
|
+
this.emitError('ONLY_SINGLE_FILE');
|
|
4284
|
+
return false;
|
|
4275
4285
|
}
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
this.
|
|
4286
|
+
for (const file of fileArray) {
|
|
4287
|
+
if (!this.isAcceptedFileType(file.name)) {
|
|
4288
|
+
this.emitError('FILETYPE_NOT_SUPPORTED');
|
|
4289
|
+
return false;
|
|
4279
4290
|
}
|
|
4280
|
-
this.fileEmitter.emit(fileList);
|
|
4281
4291
|
}
|
|
4282
|
-
|
|
4292
|
+
return true;
|
|
4293
|
+
}
|
|
4294
|
+
emitError(errorType) {
|
|
4295
|
+
this.errorEmitter.emit(errorType);
|
|
4283
4296
|
}
|
|
4284
|
-
|
|
4285
|
-
const
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4297
|
+
isAcceptedFileType(fileName) {
|
|
4298
|
+
const fileExtension = fileName.split('.').pop()?.toLowerCase();
|
|
4299
|
+
return this.acceptedFileTypes.includes(`.${fileExtension}`);
|
|
4300
|
+
}
|
|
4301
|
+
addFiles(fileArray) {
|
|
4302
|
+
if (!this.multiple) {
|
|
4303
|
+
this.fileList = [];
|
|
4289
4304
|
}
|
|
4305
|
+
this.fileList.push(...fileArray);
|
|
4290
4306
|
}
|
|
4291
4307
|
openFile(file) {
|
|
4292
4308
|
window.open(window.URL.createObjectURL(file));
|
|
4293
4309
|
}
|
|
4310
|
+
remove(file) {
|
|
4311
|
+
this.fileList = this.fileList.filter((f) => f !== file);
|
|
4312
|
+
this.fileEmitter.emit(this.createFileListFromArray(this.fileList));
|
|
4313
|
+
}
|
|
4314
|
+
createFileListFromArray(files) {
|
|
4315
|
+
const dataTransfer = new DataTransfer();
|
|
4316
|
+
files.forEach((file) => dataTransfer.items.add(file));
|
|
4317
|
+
return dataTransfer.files;
|
|
4318
|
+
}
|
|
4319
|
+
hasSingleFile() {
|
|
4320
|
+
return !this.multiple && this.fileList.length === 1;
|
|
4321
|
+
}
|
|
4294
4322
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FileUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
4295
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.2", 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\n (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\"\n>\n <input\n #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"
|
|
4323
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.2", type: FileUploadComponent, isStandalone: true, selector: "mad-file-upload", inputs: { id: "id", multiple: "multiple", accept: "accept", text: "text", showFileList: "showFileList", removable: "removable" }, outputs: { fileEmitter: "fileEmitter", errorEmitter: "errorEmitter" }, ngImport: i0, template: "<mat-card\n (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\"\n>\n <input\n #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"acceptedFileTypes\"\n [id]=\"id\"\n [multiple]=\"multiple\"\n hidden\n type=\"file\"\n />\n <mat-card-content>\n <ng-container *ngIf=\"hasSingleFile(); else uploadDefault\">\n {{ fileList[0].name }}\n </ng-container>\n\n <ng-template #uploadDefault>\n <mat-icon>vertical_align_top</mat-icon>\n {{ text ? text : 'Upload' }}\n </ng-template>\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\" [removable]=\"removable\" (removed)=\"remove(file)\">\n {{ file.name }}\n <mat-icon matChipRemove *ngIf=\"removable\">delete_forever</mat-icon>\n </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$4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i1$2.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i1$2.MatCardContent, selector: "mat-card-content" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$1.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$3.MatChip, selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]", inputs: ["role", "id", "aria-label", "aria-description", "value", "color", "removable", "highlighted", "disableRipple", "disabled", "tabIndex"], outputs: ["removed", "destroyed"], exportAs: ["matChip"] }, { kind: "component", type: i4$3.MatChipListbox, selector: "mat-chip-listbox", inputs: ["multiple", "aria-orientation", "selectable", "compareWith", "required", "hideSingleSelectionIndicator", "value"], outputs: ["change"] }, { kind: "directive", type: i4$3.MatChipRemove, selector: "[matChipRemove]" }] }); }
|
|
4296
4324
|
}
|
|
4297
4325
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FileUploadComponent, decorators: [{
|
|
4298
4326
|
type: Component,
|
|
4299
|
-
args: [{ selector: 'mad-file-upload', standalone: true, imports: [CommonModule, MatCardModule, MatIconModule, ButtonModule, TranslateModule, DragAndDropDirectiveDirective, MatChipsModule], template: "<mat-card\n (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\"\n>\n <input\n #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"
|
|
4327
|
+
args: [{ selector: 'mad-file-upload', standalone: true, imports: [CommonModule, MatCardModule, MatIconModule, ButtonModule, TranslateModule, DragAndDropDirectiveDirective, MatChipsModule], template: "<mat-card\n (click)=\"fileInput.click()\"\n (onFileDropped)=\"uploadFile($event)\"\n class=\"uploadFileContainer\"\n madDragAndDrop\n id=\"uploadFileContainer\"\n>\n <input\n #fileInput\n (change)=\"uploadFile($event.target.files)\"\n (click)=\"fileInput.value = null\"\n [accept]=\"acceptedFileTypes\"\n [id]=\"id\"\n [multiple]=\"multiple\"\n hidden\n type=\"file\"\n />\n <mat-card-content>\n <ng-container *ngIf=\"hasSingleFile(); else uploadDefault\">\n {{ fileList[0].name }}\n </ng-container>\n\n <ng-template #uploadDefault>\n <mat-icon>vertical_align_top</mat-icon>\n {{ text ? text : 'Upload' }}\n </ng-template>\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\" [removable]=\"removable\" (removed)=\"remove(file)\">\n {{ file.name }}\n <mat-icon matChipRemove *ngIf=\"removable\">delete_forever</mat-icon>\n </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"] }]
|
|
4300
4328
|
}], propDecorators: { id: [{
|
|
4301
4329
|
type: Input
|
|
4302
4330
|
}], multiple: [{
|
|
@@ -4307,13 +4335,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImpor
|
|
|
4307
4335
|
type: Input
|
|
4308
4336
|
}], showFileList: [{
|
|
4309
4337
|
type: Input
|
|
4338
|
+
}], removable: [{
|
|
4339
|
+
type: Input
|
|
4310
4340
|
}], fileEmitter: [{
|
|
4311
4341
|
type: Output
|
|
4312
4342
|
}], errorEmitter: [{
|
|
4313
4343
|
type: Output
|
|
4314
4344
|
}] } });
|
|
4315
4345
|
|
|
4316
|
-
const VERSION = '
|
|
4346
|
+
const VERSION = '18.0.4';
|
|
4317
4347
|
|
|
4318
4348
|
const MAD_ALERT_DEFAULT_CONFIGURATION = new InjectionToken('mad-alert-configuration', {
|
|
4319
4349
|
providedIn: 'root',
|