@muziehdesign/forms 0.0.1-191 → 0.0.1-207

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kZWwtc3RhdGUtb3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL211emllaGRlc2lnbi9mb3Jtcy9zcmMvbGliL21vZGVsLXN0YXRlLW9wdGlvbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEZpZWxkRXJyb3IgfSBmcm9tICcuL2ZpZWxkLWVycm9yJztcblxuZXhwb3J0IGludGVyZmFjZSBNb2RlbFN0YXRlT3B0aW9ucyB7XG4gIG9uVmFsaWRhdGU6IChlcnJvcnM6IEZpZWxkRXJyb3JbXSkgPT4gRmllbGRFcnJvcltdO1xufVxuIl19
@@ -1,5 +1,5 @@
1
1
  import { Injectable } from '@angular/core';
2
- import { BehaviorSubject, from, switchMap } from 'rxjs';
2
+ import { NgFormModelState } from './ngform-model-state';
3
3
  import * as i0 from "@angular/core";
4
4
  import * as i1 from "./model-schema.factory";
5
5
  export class NgFormModelStateFactory {
@@ -19,53 +19,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
19
19
  providedIn: 'root',
20
20
  }]
21
21
  }], ctorParameters: function () { return [{ type: i1.ModelSchemaFactory }]; } });
22
- export class NgFormModelState {
23
- constructor(form, modelValidator, model, options) {
24
- this.form = form;
25
- this.modelValidator = modelValidator;
26
- this.model = model;
27
- this.errors = new BehaviorSubject([]);
28
- this.errors$ = this.errors.asObservable();
29
- this.options = options;
30
- this.form.form.valueChanges
31
- .pipe(switchMap(async (x) => {
32
- this.model = x;
33
- return from(this.runValidations(this.options?.onValidate));
34
- }))
35
- .subscribe();
36
- this.errors$.subscribe((list) => {
37
- const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map());
38
- grouped.forEach((value, path) => {
39
- let validationErrors = {};
40
- value.forEach((v) => (validationErrors[v.type] = v.message));
41
- const control = this.form.form.get(path);
42
- if (!control) {
43
- // TODO: use actual logging service
44
- console.log(`cannot find path ${path}, which has errors`, validationErrors);
45
- }
46
- else {
47
- control.setErrors(validationErrors);
48
- }
49
- });
50
- });
51
- }
52
- isValid() {
53
- return this.errors.value.length == 0;
54
- }
55
- setErrors(errors) {
56
- this.errors.next(errors);
57
- }
58
- async validate() {
59
- return await this.runValidations(this.options?.onValidate);
60
- }
61
- async runValidations(callback) {
62
- this.removeCurrentErrors();
63
- const list = await this.modelValidator.validate(this.model);
64
- const final = callback?.(list) || list;
65
- this.errors.next(final);
66
- }
67
- removeCurrentErrors() {
68
- Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));
69
- }
70
- }
71
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctZm9ybS1tb2RlbC1zdGF0ZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbXV6aWVoZGVzaWduL2Zvcm1zL3NyYy9saWIvbmctZm9ybS1tb2RlbC1zdGF0ZS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQW9CLE1BQU0sZUFBZSxDQUFDO0FBRTdELE9BQU8sRUFBRSxlQUFlLEVBQVUsSUFBSSxFQUFFLFNBQVMsRUFBRSxNQUFNLE1BQU0sQ0FBQzs7O0FBUWhFLE1BQU0sT0FBTyx1QkFBdUI7SUFDbEMsWUFBb0IsT0FBMkI7UUFBM0IsWU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W9kZWxTdGF0ZUZhY3Rvcnkge1xuICBjb25zdHJ1Y3Rvcihwcml2YXRlIGZhY3Rvcnk6IE1vZGVsU2NoZW1hRmFjdG9yeSkge31cblxuICBjcmVhdGU8VD4oZm9ybTogTmdGb3JtLCBtb2RlbDogVCwgb3B0aW9ucz86IE1vZGVsU3RhdGVPcHRpb25zKSB7XG4gICAgY29uc3QgbW9kZWxTdGF0ZSA9IG5ldyBOZ0Zvcm1Nb2RlbFN0YXRlPFQ+KGZvcm0sIHRoaXMuZmFjdG9yeS5idWlsZChtb2RlbCksIG1vZGVsLCBvcHRpb25zKTtcbiAgICByZXR1cm4gbW9kZWxTdGF0ZTtcbiAgfVxufVxuIl19
@@ -0,0 +1,55 @@
1
+ import { BehaviorSubject, from, switchMap } from "rxjs";
2
+ export class NgFormModelState {
3
+ // TODO: remove model
4
+ constructor(form, modelValidator, model, options) {
5
+ this.form = form;
6
+ this.modelValidator = modelValidator;
7
+ this.model = model;
8
+ this.changesSubject = new BehaviorSubject(undefined);
9
+ this.changes = this.changesSubject.asObservable();
10
+ this.errors = new BehaviorSubject([]);
11
+ this.errors$ = this.errors.asObservable();
12
+ this.options = options;
13
+ this.form.form.valueChanges
14
+ .pipe(switchMap(async (x) => {
15
+ this.model = x;
16
+ return from(this.runValidations(this.options?.onValidate));
17
+ }))
18
+ .subscribe();
19
+ this.errors$.subscribe((list) => {
20
+ const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map());
21
+ grouped.forEach((value, path) => {
22
+ let validationErrors = {};
23
+ value.forEach((v) => (validationErrors[v.type] = v.message));
24
+ const control = this.form.form.get(path);
25
+ if (!control) {
26
+ // TODO: use actual logging service
27
+ console.log(`cannot find path ${path}, which has errors`, validationErrors);
28
+ }
29
+ else {
30
+ control.setErrors(validationErrors);
31
+ }
32
+ });
33
+ this.changesSubject.next(this.errors.value.length == 0);
34
+ });
35
+ }
36
+ isValid() {
37
+ return this.errors.value.length == 0;
38
+ }
39
+ setErrors(errors) {
40
+ this.errors.next(errors);
41
+ }
42
+ async validate() {
43
+ return await this.runValidations(this.options?.onValidate);
44
+ }
45
+ async runValidations(callback) {
46
+ this.removeCurrentErrors();
47
+ const list = await this.modelValidator.validate(this.model);
48
+ const final = callback?.(list) || list;
49
+ this.errors.next(final);
50
+ }
51
+ removeCurrentErrors() {
52
+ Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));
53
+ }
54
+ }
55
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmdmb3JtLW1vZGVsLXN0YXRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvbXV6aWVoZGVzaWduL2Zvcm1zL3NyYy9saWIvbmdmb3JtLW1vZGVsLXN0YXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxlQUFlLEVBQUUsSUFBSSxFQUFFLFNBQVMsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUt4RCxNQUFNLE9BQU8sZ0JBQWdCO0lBTzNCLHFCQUFxQjtJQUNyQixZQUFvQixJQUFZLEVBQVUsY0FBaUMsRUFBVSxLQUFRLEVBQUUsT0FBMkI7UUFBdEcsU0FBSSxHQUFKLElBQUksQ0FBUTtRQUFVLG1CQUFjLEdBQWQsY0FBYyxDQUFtQjtRQUFVLFVBQUssR0FBTCxLQUFLLENBQUc7UUFQckYsbUJBQWMsR0FBRyxJQUFJLGVBQWUsQ0FBc0IsU0FBUyxDQUFDLENBQUM7UUFDN0QsWUFBTyxHQUFHLElBQUksQ0FBQyxjQUFjLENBQUMsWUFBWSxFQUFFLENBQUM7UUFDckQsV0FBTSxHQUFrQyxJQUFJLGVBQWUsQ0FBZSxFQUFFLENBQUMsQ0FBQztRQUM5RSxZQUFPLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQyxZQUFZLEV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XG4gIH1cblxuICBwcml2YXRlIGFzeW5jIHJ1blZhbGlkYXRpb25zKGNhbGxiYWNrPzogKGxpc3Q6IEZpZWxkRXJyb3JbXSkgPT4gRmllbGRFcnJvcltdKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgdGhpcy5yZW1vdmVDdXJyZW50RXJyb3JzKCk7XG4gICAgY29uc3QgbGlzdCA9IGF3YWl0IHRoaXMubW9kZWxWYWxpZGF0b3IudmFsaWRhdGUodGhpcy5tb2RlbCk7XG4gICAgY29uc3QgZmluYWwgPSBjYWxsYmFjaz8uKGxpc3QpIHx8IGxpc3Q7XG4gICAgdGhpcy5lcnJvcnMubmV4dChmaW5hbCk7XG4gIH1cblxuICBwcml2YXRlIHJlbW92ZUN1cnJlbnRFcnJvcnMoKSB7XG4gICAgT2JqZWN0LmtleXModGhpcy5mb3JtLmNvbnRyb2xzKS5mb3JFYWNoKChrZXkpID0+IHRoaXMuZm9ybS5jb250cm9sc1trZXldLnNldEVycm9ycyhudWxsKSk7XG4gIH1cblxufVxuIl19
@@ -7,5 +7,6 @@ export * from './lib/model-validator';
7
7
  export * from './lib/type-annotations';
8
8
  export * from './lib/forms.module';
9
9
  export * from './lib/ng-form-model-state.service';
10
+ export * from './lib/ngform-model-state';
10
11
  export * from './lib/field-errors/field-errors.component';
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL211emllaGRlc2lnbi9mb3Jtcy9zcmMvcHVibGljLWFwaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILGNBQWMsbUJBQW1CLENBQUM7QUFDbEMsY0FBYyw0QkFBNEIsQ0FBQztBQUMzQyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsd0JBQXdCLENBQUM7QUFDdkMsY0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b250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgZm9ybXNcbiAqL1xuZXhwb3J0ICogZnJvbSAnLi9saWIvZmllbGQtZXJyb3InO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9kZWwtc2NoZW1hLmZhY3RvcnknO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvbW9kZWwtdmFsaWRhdG9yJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL3R5cGUtYW5ub3RhdGlvbnMnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvZm9ybXMubW9kdWxlJztcbmV4cG9ydCAqIGZyb20gJy4vbGliL25nLWZvcm0tbW9kZWwtc3RhdGUuc2VydmljZSc7XG5leHBvcnQgKiBmcm9tICcuL2xpYi9uZ2Zvcm0tbW9kZWwtc3RhdGUnO1xuZXhwb3J0ICogZnJvbSAnLi9saWIvZmllbGQtZXJyb3JzL2ZpZWxkLWVycm9ycy5jb21wb25lbnQnO1xuIl19
@@ -264,28 +264,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
264
264
  }]
265
265
  }] });
266
266
 
267
- class NgFormModelStateFactory {
268
- constructor(factory) {
269
- this.factory = factory;
270
- }
271
- create(form, model, options) {
272
- const modelState = new NgFormModelState(form, this.factory.build(model), model, options);
273
- return modelState;
274
- }
275
- }
276
- NgFormModelStateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable });
277
- NgFormModelStateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' });
278
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
279
- type: Injectable,
280
- args: [{
281
- providedIn: 'root',
282
- }]
283
- }], ctorParameters: function () { return [{ type: ModelSchemaFactory }]; } });
284
267
  class NgFormModelState {
268
+ // TODO: remove model
285
269
  constructor(form, modelValidator, model, options) {
286
270
  this.form = form;
287
271
  this.modelValidator = modelValidator;
288
272
  this.model = model;
273
+ this.changesSubject = new BehaviorSubject(undefined);
274
+ this.changes = this.changesSubject.asObservable();
289
275
  this.errors = new BehaviorSubject([]);
290
276
  this.errors$ = this.errors.asObservable();
291
277
  this.options = options;
@@ -310,6 +296,7 @@ class NgFormModelState {
310
296
  control.setErrors(validationErrors);
311
297
  }
312
298
  });
299
+ this.changesSubject.next(this.errors.value.length == 0);
313
300
  });
314
301
  }
315
302
  isValid() {
@@ -337,6 +324,24 @@ class NgFormModelState {
337
324
  }
338
325
  }
339
326
 
327
+ class NgFormModelStateFactory {
328
+ constructor(factory) {
329
+ this.factory = factory;
330
+ }
331
+ create(form, model, options) {
332
+ const modelState = new NgFormModelState(form, this.factory.build(model), model, options);
333
+ return modelState;
334
+ }
335
+ }
336
+ NgFormModelStateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable });
337
+ NgFormModelStateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' });
338
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
339
+ type: Injectable,
340
+ args: [{
341
+ providedIn: 'root',
342
+ }]
343
+ }], ctorParameters: function () { return [{ type: ModelSchemaFactory }]; } });
344
+
340
345
  /*
341
346
  * Public API Surface of forms
342
347
  */
@@ -1 +1 @@
1
- {"version":3,"file":"muziehdesign-forms.mjs","sources":["../../../../projects/muziehdesign/forms/src/lib/model-validator.ts","../../../../projects/muziehdesign/forms/src/lib/constants.ts","../../../../projects/muziehdesign/forms/src/lib/type-annotations.ts","../../../../projects/muziehdesign/forms/src/lib/model-schema.factory.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.html","../../../../projects/muziehdesign/forms/src/lib/forms.module.ts","../../../../projects/muziehdesign/forms/src/lib/ng-form-model-state.service.ts","../../../../projects/muziehdesign/forms/src/public-api.ts","../../../../projects/muziehdesign/forms/src/muziehdesign-forms.ts"],"sourcesContent":["import { SchemaOf, ValidationError } from 'yup';\nimport { FieldError } from './field-error';\n\nexport class ModelValidator<T> {\n private schema: SchemaOf<T>;\n constructor(modelSchema: SchemaOf<T>) {\n this.schema = modelSchema;\n }\n\n validate<T>(model: T): Promise<FieldError[]> {\n return this.schema\n .validate(model, { abortEarly: false })\n .then(() => {\n return [];\n })\n .catch((e: ValidationError) => {\n return e.inner.map((error) => <FieldError>{ path: error.path, type: error.type, message: error.message });\n });\n }\n}\n","export const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';\n","import 'reflect-metadata';\n\nconst METADATA_KEY = 'custom:muziehdesign:annotations';\n\nexport enum ConstraintType {\n string,\n boolean,\n date,\n object,\n number,\n}\n\nexport interface ConstraintAnnotations {\n constraintType: ConstraintType;\n}\n\nexport interface StringTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n length?: LengthAnnotation;\n pattern?: PatternAnnotation;\n maxLength?: MaxLengthAnnotation;\n minLength?: MinLengthAnnotation;\n}\n\nexport interface BooleanTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n equals?: EqualsAnnotation<boolean>;\n}\n\nexport interface DateTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n min?: MinimumAnnotation<Date>;\n max?: MaximumAnnotation<Date>;\n test?: TestAnnotation<Date>;\n}\n\nexport interface ObjectTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n getInstance: () => any;\n}\n\nexport interface NumberTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n}\n\nexport interface ValidationAnnotation {\n message?: string;\n}\n\nexport interface RequiredAnnotation extends ValidationAnnotation {\n required: boolean;\n}\n\nexport interface LengthAnnotation extends ValidationAnnotation {\n length: number;\n}\n\nexport interface PatternAnnotation extends ValidationAnnotation {\n pattern: RegExp;\n}\n\nexport interface OfValuesAnnotation extends ValidationAnnotation {\n values: [];\n}\n\nexport interface EqualsAnnotation<T> extends ValidationAnnotation {\n equals: T;\n}\n\nexport interface MinimumAnnotation<T> extends ValidationAnnotation {\n min: T;\n}\n\nexport interface MaximumAnnotation<T> extends ValidationAnnotation {\n max: T;\n}\n\nexport interface TestAnnotation<T> extends ValidationAnnotation {\n test: (d: T) => boolean;\n name: string;\n}\n\nexport interface MaxLengthAnnotation extends ValidationAnnotation {\n maxLength: number;\n}\n\nexport interface MinLengthAnnotation extends ValidationAnnotation {\n minLength: number;\n}\n\nconst registerMetadata = (target: Object, propertyKey: string, constraint: ConstraintAnnotations) => {\n const metadata: Map<string, any> = Reflect.getMetadata(METADATA_KEY, target) || new Map<string, any>();\n metadata.set(propertyKey, constraint);\n Reflect.defineMetadata(METADATA_KEY, metadata, target);\n};\n\nexport function StringType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as StringTypeAnnotations;\n o.constraintType = ConstraintType.string;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function BooleanType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as BooleanTypeAnnotations;\n o.constraintType = ConstraintType.boolean;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function DateType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as DateTypeAnnotations;\n o.constraintType = ConstraintType.date;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function NumberType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as NumberTypeAnnotations;\n o.constraintType = ConstraintType.number;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function ObjectType<T>(type: { new (): T }, ...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations, { getInstance: () => new type() } as Partial<ObjectTypeAnnotations>) as ObjectTypeAnnotations;\n o.constraintType = ConstraintType.object;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function required(message?: string): { [key: string]: RequiredAnnotation } {\n return { required: { required: true, message: message } };\n}\n\nexport function pattern(regex: RegExp, message?: string): { [key: string]: PatternAnnotation } {\n return { pattern: { pattern: regex, message: message } };\n}\n\nexport function length(length: number, message?: string): { [key: string]: LengthAnnotation } {\n return { length: { length: length, message: message } };\n}\n\nexport function maxLength(maxLength: number, message?: string): { [key: string]: MaxLengthAnnotation } {\n return { maxLength: { maxLength: maxLength, message: message } };\n}\n\nexport function minLength(minLength: number, message?: string): { [key: string]: MinLengthAnnotation } {\n return { minLength: { minLength: minLength, message: message } };\n}\n\nexport function ofValues(values: [], message?: string): { [key: string]: OfValuesAnnotation } {\n return { ofValues: { values: values, message: message } };\n}\n\nexport function equals<T>(value: T, message?: string): { [key: string]: EqualsAnnotation<T> } {\n return { equals: { equals: value, message: message } };\n}\n\nexport function min<T>(value: T, message?: string): { [key: string]: MinimumAnnotation<T> } {\n return { min: { min: value, message: message } };\n}\n\nexport function max<T>(value: T, message?: string): { [key: string]: MaximumAnnotation<T> } {\n return { max: { max: value, message: message } };\n}\n\nexport function test<T>(name: string, test: (d: T) => boolean, message?: string): { [key: string]: TestAnnotation<T> } {\n return { test: { name: name, test: test, message: message } };\n}\n","import { Injectable } from '@angular/core';\nimport { object, SchemaOf } from 'yup';\nimport { ModelValidator } from './model-validator';\nimport { SCHEMA_METADATA_NAMESPACE } from './constants';\nimport { ObjectShape } from 'yup/lib/object';\nimport { BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, ObjectTypeAnnotations, NumberTypeAnnotations, StringTypeAnnotations } from './type-annotations';\nimport * as Yup from 'yup';\n\n/*\nSchema rules need to be built in the order they need to be evaluated in.\nFor example,\n ```\n schema.required().max(...).matches(...);\n ```\nevaluates the 3 rules in this order\n - required\n - max\n - matches\n*/\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ModelSchemaFactory {\n constructor() {}\n\n build<T>(model: T): ModelValidator<T> {\n const schema = this.buildObjectSchema(model);\n return new ModelValidator(schema);\n }\n\n private buildObjectSchema<T>(model: T) {\n const metadata: Map<string, ConstraintAnnotations> = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);\n let shape: ObjectShape = {};\n metadata.forEach((value, key) => {\n if (value.constraintType == ConstraintType.string) {\n shape[key] = this.buildStringSchema(value as StringTypeAnnotations);\n } else if (value.constraintType == ConstraintType.boolean) {\n shape[key] = this.buildBooleanSchema(value as BooleanTypeAnnotations);\n } else if (value.constraintType == ConstraintType.date) {\n shape[key] = this.buildDateSchema(value as DateTypeAnnotations);\n } else if(value.constraintType == ConstraintType.object) {\n shape[key] = this.buildNestedObjectSchema(value as ObjectTypeAnnotations);\n } else if (value.constraintType == ConstraintType.number) {\n shape[key] = this.buildNumberSchema(value as NumberTypeAnnotations);\n }\n });\n return object(shape) as SchemaOf<T>;\n }\n\n private buildStringSchema(options: StringTypeAnnotations) {\n let schema = Yup.string();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.length) {\n schema = schema.length(options.length.length, options.length.message);\n }\n\n if (options.maxLength) {\n schema = schema.max(options.maxLength.maxLength, options.maxLength.message);\n }\n\n if (options.minLength) {\n schema = schema.min(options.minLength.minLength, options.minLength.message);\n }\n\n if (options.pattern) {\n schema = schema.matches(options.pattern.pattern, options.pattern.message);\n }\n\n return schema;\n }\n\n private buildBooleanSchema(options: BooleanTypeAnnotations) {\n let schema = Yup.boolean();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.equals) {\n if (options.equals.equals) {\n schema = schema.isTrue(options.equals.message);\n } else {\n schema = schema.isFalse(options.equals.message);\n }\n }\n\n return schema;\n }\n\n private buildDateSchema(options: DateTypeAnnotations) {\n let schema = Yup.date().typeError('Please enter a valid date');\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.min) {\n schema = schema.min(options.min.min, options.min.message);\n }\n if (options.max) {\n schema = schema.max(options.max.max, options.max.message);\n }\n if (options.test) {\n schema = schema.test({\n name: options.test.name,\n message: options.test.message,\n test: (d?: Date, context?: any) => {\n return options.test!.test(d!);\n }});\n }\n\n return schema;\n }\n\n private buildNumberSchema(options: NumberTypeAnnotations) {\n let schema = Yup.number();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n\n return schema;\n }\n\n private buildNestedObjectSchema(options: ObjectTypeAnnotations) {\n\n let nestedSchema = this.buildObjectSchema(options.getInstance());\n if(options.required) {\n nestedSchema = nestedSchema.required();\n }\n\n return nestedSchema;\n }\n}\n","import { Component, Input, OnInit } from '@angular/core';\nimport { NgControl, ValidationErrors } from '@angular/forms';\n\n@Component({\n selector: 'mz-field-errors',\n templateUrl: './field-errors.component.html',\n styleUrls: ['./field-errors.component.css'],\n})\nexport class FieldErrorsComponent {\n @Input() field?: NgControl;\n\n get errorMessage(): string {\n const errorKeys = Object.keys(this.field?.errors || {});\n return errorKeys.length > 0 ? (this.field?.errors as ValidationErrors)[errorKeys[0]] : '';\n }\n}\n","<div class=\"field-error\" *ngIf=\"errorMessage\">{{ errorMessage }}</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FieldErrorsComponent } from './field-errors/field-errors.component';\n\n\n\n@NgModule({\n providers: [],\n declarations: [\n FieldErrorsComponent\n ],\n exports: [\n FieldErrorsComponent\n ],\n imports: [\n CommonModule // TODO: can remove once done with temp error displaying\n ]\n})\nexport class FormsModule { }\n","import { Injectable, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { NgForm, ValidationErrors } from '@angular/forms';\nimport { BehaviorSubject, filter, from, switchMap } from 'rxjs';\nimport { FieldError } from './field-error';\nimport { ModelSchemaFactory } from './model-schema.factory';\nimport { ModelValidator } from './model-validator';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgFormModelStateFactory {\n constructor(private factory: ModelSchemaFactory) {}\n\n create<T>(form: NgForm, model: T, options?: ModelStateOptions) {\n const modelState = new NgFormModelState<T>(form, this.factory.build(model), model, options);\n return modelState;\n }\n}\n\nexport interface ModelStateOptions {\n onValidate: (errors: FieldError[]) => FieldError[];\n}\n\nexport class NgFormModelState<T> {\n private errors: BehaviorSubject<FieldError[]> = new BehaviorSubject<FieldError[]>([]);\n public errors$ = this.errors.asObservable();\n private options?: ModelStateOptions;\n\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.options = options;\n\n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(this.options?.onValidate));\n })\n )\n .subscribe();\n\n this.errors$.subscribe((list) => {\n const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map<string, FieldError[]>());\n\n grouped.forEach((value, path) => {\n let validationErrors = <ValidationErrors>{};\n value.forEach((v) => (validationErrors[v.type] = v.message));\n\n const control = this.form.form.get(path);\n if (!control) {\n // TODO: use actual logging service\n console.log(`cannot find path ${path}, which has errors`, validationErrors);\n } else {\n control.setErrors(validationErrors);\n }\n });\n });\n }\n\n isValid(): boolean {\n return this.errors.value.length == 0;\n }\n\n setErrors(errors: FieldError[]) {\n this.errors.next(errors);\n }\n\n async validate(): Promise<void> {\n return await this.runValidations(this.options?.onValidate);\n }\n\n private async runValidations(callback?: (list: FieldError[]) => FieldError[]): Promise<void> {\n this.removeCurrentErrors();\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n\n private removeCurrentErrors() {\n Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));\n }\n}\n","/*\n * Public API Surface of forms\n */\nexport * from './lib/field-error';\nexport * from './lib/model-schema.factory';\nexport * from './lib/model-validator';\nexport * from './lib/type-annotations';\nexport * from './lib/forms.module';\nexport * from './lib/ng-form-model-state.service';\nexport * from './lib/field-errors/field-errors.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ModelSchemaFactory"],"mappings":";;;;;;;;;;MAGa,cAAc,CAAA;AAEzB,IAAA,WAAA,CAAY,WAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC3B;AAED,IAAA,QAAQ,CAAI,KAAQ,EAAA;QAClB,OAAO,IAAI,CAAC,MAAM;aACf,QAAQ,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aACtC,IAAI,CAAC,MAAK;AACT,YAAA,OAAO,EAAE,CAAC;AACZ,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,CAAkB,KAAI;AAC5B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,MAAiB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA,CAAC,CAAC;AAC5G,SAAC,CAAC,CAAC;KACN;AACF;;ACnBM,MAAM,yBAAyB,GAAG,iCAAiC;;ACE1E,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAE3C,IAAA,eAMX;AAND,CAAA,UAAY,cAAc,EAAA;IACxB,cAAA,CAAA,cAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAM,CAAA;IACN,cAAA,CAAA,cAAA,CAAA,SAAA,C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AC,IAAI,CAAC,MAAM,CAAC,CAAC;KAC1B;IAEK,QAAQ,GAAA;;;AACZ,YAAA,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,CAAA,EAAA,GAAA,IAAI,CAAC,OAAO,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,UAAU,CAAC,CAAC;;AAC5D,KAAA;AAEa,IAAA,cAAc,CAAC,QAA+C,EAAA;;YAC1E,IAAI,CAAC,mBAAmB,EAAE,CAAC;AAC3B,YAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5D,YAAA,MAAM,KAAK,GAAG,CAAA,QAAQ,KAAR,IAAA,IAAA,QAAQ,KAAR,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,QAAQ,CAAG,IAAI,CAAC,KAAI,IAAI,CAAC;AACvC,YAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACzB,CAAA,CAAA;AAAA,KAAA;IAEO,mBAAmB,GAAA;AACzB,QAAA,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;KAC3F;AACF;;AChFD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"muziehdesign-forms.mjs","sources":["../../../../projects/muziehdesign/forms/src/lib/model-validator.ts","../../../../projects/muziehdesign/forms/src/lib/constants.ts","../../../../projects/muziehdesign/forms/src/lib/type-annotations.ts","../../../../projects/muziehdesign/forms/src/lib/model-schema.factory.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.html","../../../../projects/muziehdesign/forms/src/lib/forms.module.ts","../../../../projects/muziehdesign/forms/src/lib/ngform-model-state.ts","../../../../projects/muziehdesign/forms/src/lib/ng-form-model-state.service.ts","../../../../projects/muziehdesign/forms/src/public-api.ts","../../../../projects/muziehdesign/forms/src/muziehdesign-forms.ts"],"sourcesContent":["import { SchemaOf, ValidationError } from 'yup';\nimport { FieldError } from './field-error';\n\nexport class ModelValidator<T> {\n private schema: SchemaOf<T>;\n constructor(modelSchema: SchemaOf<T>) {\n this.schema = modelSchema;\n }\n\n validate<T>(model: T): Promise<FieldError[]> {\n return this.schema\n .validate(model, { abortEarly: false })\n .then(() => {\n return [];\n })\n .catch((e: ValidationError) => {\n return e.inner.map((error) => <FieldError>{ path: error.path, type: error.type, message: error.message });\n });\n }\n}\n","export const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';\n","import 'reflect-metadata';\n\nconst METADATA_KEY = 'custom:muziehdesign:annotations';\n\nexport enum ConstraintType {\n string,\n boolean,\n date,\n object,\n number,\n}\n\nexport interface ConstraintAnnotations {\n constraintType: ConstraintType;\n}\n\nexport interface StringTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n length?: LengthAnnotation;\n pattern?: PatternAnnotation;\n maxLength?: MaxLengthAnnotation;\n minLength?: MinLengthAnnotation;\n}\n\nexport interface BooleanTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n equals?: EqualsAnnotation<boolean>;\n}\n\nexport interface DateTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n min?: MinimumAnnotation<Date>;\n max?: MaximumAnnotation<Date>;\n test?: TestAnnotation<Date>;\n}\n\nexport interface ObjectTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n getInstance: () => any;\n}\n\nexport interface NumberTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n}\n\nexport interface ValidationAnnotation {\n message?: string;\n}\n\nexport interface RequiredAnnotation extends ValidationAnnotation {\n required: boolean;\n}\n\nexport interface LengthAnnotation extends ValidationAnnotation {\n length: number;\n}\n\nexport interface PatternAnnotation extends ValidationAnnotation {\n pattern: RegExp;\n}\n\nexport interface OfValuesAnnotation extends ValidationAnnotation {\n values: [];\n}\n\nexport interface EqualsAnnotation<T> extends ValidationAnnotation {\n equals: T;\n}\n\nexport interface MinimumAnnotation<T> extends ValidationAnnotation {\n min: T;\n}\n\nexport interface MaximumAnnotation<T> extends ValidationAnnotation {\n max: T;\n}\n\nexport interface TestAnnotation<T> extends ValidationAnnotation {\n test: (d: T) => boolean;\n name: string;\n}\n\nexport interface MaxLengthAnnotation extends ValidationAnnotation {\n maxLength: number;\n}\n\nexport interface MinLengthAnnotation extends ValidationAnnotation {\n minLength: number;\n}\n\nconst registerMetadata = (target: Object, propertyKey: string, constraint: ConstraintAnnotations) => {\n const metadata: Map<string, any> = Reflect.getMetadata(METADATA_KEY, target) || new Map<string, any>();\n metadata.set(propertyKey, constraint);\n Reflect.defineMetadata(METADATA_KEY, metadata, target);\n};\n\nexport function StringType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as StringTypeAnnotations;\n o.constraintType = ConstraintType.string;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function BooleanType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as BooleanTypeAnnotations;\n o.constraintType = ConstraintType.boolean;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function DateType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as DateTypeAnnotations;\n o.constraintType = ConstraintType.date;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function NumberType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as NumberTypeAnnotations;\n o.constraintType = ConstraintType.number;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function ObjectType<T>(type: { new (): T }, ...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations, { getInstance: () => new type() } as Partial<ObjectTypeAnnotations>) as ObjectTypeAnnotations;\n o.constraintType = ConstraintType.object;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function required(message?: string): { [key: string]: RequiredAnnotation } {\n return { required: { required: true, message: message } };\n}\n\nexport function pattern(regex: RegExp, message?: string): { [key: string]: PatternAnnotation } {\n return { pattern: { pattern: regex, message: message } };\n}\n\nexport function length(length: number, message?: string): { [key: string]: LengthAnnotation } {\n return { length: { length: length, message: message } };\n}\n\nexport function maxLength(maxLength: number, message?: string): { [key: string]: MaxLengthAnnotation } {\n return { maxLength: { maxLength: maxLength, message: message } };\n}\n\nexport function minLength(minLength: number, message?: string): { [key: string]: MinLengthAnnotation } {\n return { minLength: { minLength: minLength, message: message } };\n}\n\nexport function ofValues(values: [], message?: string): { [key: string]: OfValuesAnnotation } {\n return { ofValues: { values: values, message: message } };\n}\n\nexport function equals<T>(value: T, message?: string): { [key: string]: EqualsAnnotation<T> } {\n return { equals: { equals: value, message: message } };\n}\n\nexport function min<T>(value: T, message?: string): { [key: string]: MinimumAnnotation<T> } {\n return { min: { min: value, message: message } };\n}\n\nexport function max<T>(value: T, message?: string): { [key: string]: MaximumAnnotation<T> } {\n return { max: { max: value, message: message } };\n}\n\nexport function test<T>(name: string, test: (d: T) => boolean, message?: string): { [key: string]: TestAnnotation<T> } {\n return { test: { name: name, test: test, message: message } };\n}\n","import { Injectable } from '@angular/core';\nimport { object, SchemaOf } from 'yup';\nimport { ModelValidator } from './model-validator';\nimport { SCHEMA_METADATA_NAMESPACE } from './constants';\nimport { ObjectShape } from 'yup/lib/object';\nimport { BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, ObjectTypeAnnotations, NumberTypeAnnotations, StringTypeAnnotations } from './type-annotations';\nimport * as Yup from 'yup';\n\n/*\nSchema rules need to be built in the order they need to be evaluated in.\nFor example,\n ```\n schema.required().max(...).matches(...);\n ```\nevaluates the 3 rules in this order\n - required\n - max\n - matches\n*/\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ModelSchemaFactory {\n constructor() {}\n\n build<T>(model: T): ModelValidator<T> {\n const schema = this.buildObjectSchema(model);\n return new ModelValidator(schema);\n }\n\n private buildObjectSchema<T>(model: T) {\n const metadata: Map<string, ConstraintAnnotations> = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);\n let shape: ObjectShape = {};\n metadata.forEach((value, key) => {\n if (value.constraintType == ConstraintType.string) {\n shape[key] = this.buildStringSchema(value as StringTypeAnnotations);\n } else if (value.constraintType == ConstraintType.boolean) {\n shape[key] = this.buildBooleanSchema(value as BooleanTypeAnnotations);\n } else if (value.constraintType == ConstraintType.date) {\n shape[key] = this.buildDateSchema(value as DateTypeAnnotations);\n } else if(value.constraintType == ConstraintType.object) {\n shape[key] = this.buildNestedObjectSchema(value as ObjectTypeAnnotations);\n } else if (value.constraintType == ConstraintType.number) {\n shape[key] = this.buildNumberSchema(value as NumberTypeAnnotations);\n }\n });\n return object(shape) as SchemaOf<T>;\n }\n\n private buildStringSchema(options: StringTypeAnnotations) {\n let schema = Yup.string();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.length) {\n schema = schema.length(options.length.length, options.length.message);\n }\n\n if (options.maxLength) {\n schema = schema.max(options.maxLength.maxLength, options.maxLength.message);\n }\n\n if (options.minLength) {\n schema = schema.min(options.minLength.minLength, options.minLength.message);\n }\n\n if (options.pattern) {\n schema = schema.matches(options.pattern.pattern, options.pattern.message);\n }\n\n return schema;\n }\n\n private buildBooleanSchema(options: BooleanTypeAnnotations) {\n let schema = Yup.boolean();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.equals) {\n if (options.equals.equals) {\n schema = schema.isTrue(options.equals.message);\n } else {\n schema = schema.isFalse(options.equals.message);\n }\n }\n\n return schema;\n }\n\n private buildDateSchema(options: DateTypeAnnotations) {\n let schema = Yup.date().typeError('Please enter a valid date');\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.min) {\n schema = schema.min(options.min.min, options.min.message);\n }\n if (options.max) {\n schema = schema.max(options.max.max, options.max.message);\n }\n if (options.test) {\n schema = schema.test({\n name: options.test.name,\n message: options.test.message,\n test: (d?: Date, context?: any) => {\n return options.test!.test(d!);\n }});\n }\n\n return schema;\n }\n\n private buildNumberSchema(options: NumberTypeAnnotations) {\n let schema = Yup.number();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n\n return schema;\n }\n\n private buildNestedObjectSchema(options: ObjectTypeAnnotations) {\n\n let nestedSchema = this.buildObjectSchema(options.getInstance());\n if(options.required) {\n nestedSchema = nestedSchema.required();\n }\n\n return nestedSchema;\n }\n}\n","import { Component, Input, OnInit } from '@angular/core';\nimport { NgControl, ValidationErrors } from '@angular/forms';\n\n@Component({\n selector: 'mz-field-errors',\n templateUrl: './field-errors.component.html',\n styleUrls: ['./field-errors.component.css'],\n})\nexport class FieldErrorsComponent {\n @Input() field?: NgControl;\n\n get errorMessage(): string {\n const errorKeys = Object.keys(this.field?.errors || {});\n return errorKeys.length > 0 ? (this.field?.errors as ValidationErrors)[errorKeys[0]] : '';\n }\n}\n","<div class=\"field-error\" *ngIf=\"errorMessage\">{{ errorMessage }}</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FieldErrorsComponent } from './field-errors/field-errors.component';\n\n\n\n@NgModule({\n providers: [],\n declarations: [\n FieldErrorsComponent\n ],\n exports: [\n FieldErrorsComponent\n ],\n imports: [\n CommonModule // TODO: can remove once done with temp error displaying\n ]\n})\nexport class FormsModule { }\n","import { NgForm, ValidationErrors } from \"@angular/forms\";\nimport { BehaviorSubject, from, switchMap } from \"rxjs\";\nimport { FieldError } from \"./field-error\";\nimport { ModelStateOptions } from \"./model-state-options\";\nimport { ModelValidator } from \"./model-validator\";\n\nexport class NgFormModelState<T> {\n private changesSubject = new BehaviorSubject<boolean | undefined>(undefined);\n public readonly changes = this.changesSubject.asObservable();\n private errors: BehaviorSubject<FieldError[]> = new BehaviorSubject<FieldError[]>([]);\n private errors$ = this.errors.asObservable();\n private options?: ModelStateOptions;\n\n // TODO: remove model\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.options = options;\n\n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(this.options?.onValidate));\n })\n )\n .subscribe();\n\n this.errors$.subscribe((list) => {\n const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map<string, FieldError[]>());\n\n grouped.forEach((value, path) => {\n let validationErrors = <ValidationErrors>{};\n value.forEach((v) => (validationErrors[v.type] = v.message));\n\n const control = this.form.form.get(path);\n if (!control) {\n // TODO: use actual logging service\n console.log(`cannot find path ${path}, which has errors`, validationErrors);\n } else {\n control.setErrors(validationErrors);\n }\n });\n\n this.changesSubject.next(this.errors.value.length == 0);\n });\n }\n\n isValid(): boolean {\n return this.errors.value.length == 0;\n }\n\n setErrors(errors: FieldError[]) {\n this.errors.next(errors);\n }\n\n async validate(): Promise<void> {\n return await this.runValidations(this.options?.onValidate);\n }\n\n private async runValidations(callback?: (list: FieldError[]) => FieldError[]): Promise<void> {\n this.removeCurrentErrors();\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n\n private removeCurrentErrors() {\n Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));\n }\n\n}\n","import { Injectable, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { NgForm, ValidationErrors } from '@angular/forms';\nimport { BehaviorSubject, filter, from, switchMap } from 'rxjs';\nimport { FieldError } from './field-error';\nimport { ModelSchemaFactory } from './model-schema.factory';\nimport { ModelStateOptions } from './model-state-options';\nimport { ModelValidator } from './model-validator';\nimport { NgFormModelState } from './ngform-model-state';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgFormModelStateFactory {\n constructor(private factory: ModelSchemaFactory) {}\n\n create<T>(form: NgForm, model: T, options?: ModelStateOptions) {\n const modelState = new NgFormModelState<T>(form, this.factory.build(model), model, options);\n return modelState;\n }\n}\n","/*\n * Public API Surface of forms\n */\nexport * from './lib/field-error';\nexport * from './lib/model-schema.factory';\nexport * from './lib/model-validator';\nexport * from './lib/type-annotations';\nexport * from './lib/forms.module';\nexport * from './lib/ng-form-model-state.service';\nexport * from './lib/ngform-model-state';\nexport * from './lib/field-errors/field-errors.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ModelSchemaFactory"],"mappings":";;;;;;;;;;MAGa,cAAc,CAAA;AAEzB,IAAA,WAAA,CAAY,WAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC3B;AAED,IAAA,QAAQ,CAAI,KAAQ,EAAA;QAClB,OAAO,IAAI,CAAC,MAAM;aACf,QAAQ,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aACtC,IAAI,CAAC,MAAK;AACT,YAAA,OAAO,EAAE,CAAC;AACZ,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,CAAkB,KAAI;AAC5B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,MAAiB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA,CAAC,CAAC;AAC5G,SAAC,CAAC,CAAC;KACN;AACF;;ACnBM,MAAM,yBAAyB,GAAG,iCAAiC;;ACE1E,MAAM,YAAY,GAAG,iCAAiC,CAAC;AAE3C,IAAA,eAMX;AAND,CAAA,UAAY,c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,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;ACXD;;AAEG;;ACFH;;AAEG;;;;"}
@@ -262,28 +262,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImpor
262
262
  }]
263
263
  }] });
264
264
 
265
- class NgFormModelStateFactory {
266
- constructor(factory) {
267
- this.factory = factory;
268
- }
269
- create(form, model, options) {
270
- const modelState = new NgFormModelState(form, this.factory.build(model), model, options);
271
- return modelState;
272
- }
273
- }
274
- NgFormModelStateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable });
275
- NgFormModelStateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' });
276
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
277
- type: Injectable,
278
- args: [{
279
- providedIn: 'root',
280
- }]
281
- }], ctorParameters: function () { return [{ type: ModelSchemaFactory }]; } });
282
265
  class NgFormModelState {
266
+ // TODO: remove model
283
267
  constructor(form, modelValidator, model, options) {
284
268
  this.form = form;
285
269
  this.modelValidator = modelValidator;
286
270
  this.model = model;
271
+ this.changesSubject = new BehaviorSubject(undefined);
272
+ this.changes = this.changesSubject.asObservable();
287
273
  this.errors = new BehaviorSubject([]);
288
274
  this.errors$ = this.errors.asObservable();
289
275
  this.options = options;
@@ -307,6 +293,7 @@ class NgFormModelState {
307
293
  control.setErrors(validationErrors);
308
294
  }
309
295
  });
296
+ this.changesSubject.next(this.errors.value.length == 0);
310
297
  });
311
298
  }
312
299
  isValid() {
@@ -329,6 +316,24 @@ class NgFormModelState {
329
316
  }
330
317
  }
331
318
 
319
+ class NgFormModelStateFactory {
320
+ constructor(factory) {
321
+ this.factory = factory;
322
+ }
323
+ create(form, model, options) {
324
+ const modelState = new NgFormModelState(form, this.factory.build(model), model, options);
325
+ return modelState;
326
+ }
327
+ }
328
+ NgFormModelStateFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, deps: [{ token: ModelSchemaFactory }], target: i0.ɵɵFactoryTarget.Injectable });
329
+ NgFormModelStateFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, providedIn: 'root' });
330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.5", ngImport: i0, type: NgFormModelStateFactory, decorators: [{
331
+ type: Injectable,
332
+ args: [{
333
+ providedIn: 'root',
334
+ }]
335
+ }], ctorParameters: function () { return [{ type: ModelSchemaFactory }]; } });
336
+
332
337
  /*
333
338
  * Public API Surface of forms
334
339
  */
@@ -1 +1 @@
1
- {"version":3,"file":"muziehdesign-forms.mjs","sources":["../../../../projects/muziehdesign/forms/src/lib/model-validator.ts","../../../../projects/muziehdesign/forms/src/lib/constants.ts","../../../../projects/muziehdesign/forms/src/lib/type-annotations.ts","../../../../projects/muziehdesign/forms/src/lib/model-schema.factory.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.html","../../../../projects/muziehdesign/forms/src/lib/forms.module.ts","../../../../projects/muziehdesign/forms/src/lib/ng-form-model-state.service.ts","../../../../projects/muziehdesign/forms/src/public-api.ts","../../../../projects/muziehdesign/forms/src/muziehdesign-forms.ts"],"sourcesContent":["import { SchemaOf, ValidationError } from 'yup';\nimport { FieldError } from './field-error';\n\nexport class ModelValidator<T> {\n private schema: SchemaOf<T>;\n constructor(modelSchema: SchemaOf<T>) {\n this.schema = modelSchema;\n }\n\n validate<T>(model: T): Promise<FieldError[]> {\n return this.schema\n .validate(model, { abortEarly: false })\n .then(() => {\n return [];\n })\n .catch((e: ValidationError) => {\n return e.inner.map((error) => <FieldError>{ path: error.path, type: error.type, message: error.message });\n });\n }\n}\n","export const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';\n","import 'reflect-metadata';\n\nconst METADATA_KEY = 'custom:muziehdesign:annotations';\n\nexport enum ConstraintType {\n string,\n boolean,\n date,\n object,\n number,\n}\n\nexport interface ConstraintAnnotations {\n constraintType: ConstraintType;\n}\n\nexport interface StringTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n length?: LengthAnnotation;\n pattern?: PatternAnnotation;\n maxLength?: MaxLengthAnnotation;\n minLength?: MinLengthAnnotation;\n}\n\nexport interface BooleanTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n equals?: EqualsAnnotation<boolean>;\n}\n\nexport interface DateTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n min?: MinimumAnnotation<Date>;\n max?: MaximumAnnotation<Date>;\n test?: TestAnnotation<Date>;\n}\n\nexport interface ObjectTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n getInstance: () => any;\n}\n\nexport interface NumberTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n}\n\nexport interface ValidationAnnotation {\n message?: string;\n}\n\nexport interface RequiredAnnotation extends ValidationAnnotation {\n required: boolean;\n}\n\nexport interface LengthAnnotation extends ValidationAnnotation {\n length: number;\n}\n\nexport interface PatternAnnotation extends ValidationAnnotation {\n pattern: RegExp;\n}\n\nexport interface OfValuesAnnotation extends ValidationAnnotation {\n values: [];\n}\n\nexport interface EqualsAnnotation<T> extends ValidationAnnotation {\n equals: T;\n}\n\nexport interface MinimumAnnotation<T> extends ValidationAnnotation {\n min: T;\n}\n\nexport interface MaximumAnnotation<T> extends ValidationAnnotation {\n max: T;\n}\n\nexport interface TestAnnotation<T> extends ValidationAnnotation {\n test: (d: T) => boolean;\n name: string;\n}\n\nexport interface MaxLengthAnnotation extends ValidationAnnotation {\n maxLength: number;\n}\n\nexport interface MinLengthAnnotation extends ValidationAnnotation {\n minLength: number;\n}\n\nconst registerMetadata = (target: Object, propertyKey: string, constraint: ConstraintAnnotations) => {\n const metadata: Map<string, any> = Reflect.getMetadata(METADATA_KEY, target) || new Map<string, any>();\n metadata.set(propertyKey, constraint);\n Reflect.defineMetadata(METADATA_KEY, metadata, target);\n};\n\nexport function StringType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as StringTypeAnnotations;\n o.constraintType = ConstraintType.string;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function BooleanType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as BooleanTypeAnnotations;\n o.constraintType = ConstraintType.boolean;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function DateType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as DateTypeAnnotations;\n o.constraintType = ConstraintType.date;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function NumberType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as NumberTypeAnnotations;\n o.constraintType = ConstraintType.number;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function ObjectType<T>(type: { new (): T }, ...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations, { getInstance: () => new type() } as Partial<ObjectTypeAnnotations>) as ObjectTypeAnnotations;\n o.constraintType = ConstraintType.object;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function required(message?: string): { [key: string]: RequiredAnnotation } {\n return { required: { required: true, message: message } };\n}\n\nexport function pattern(regex: RegExp, message?: string): { [key: string]: PatternAnnotation } {\n return { pattern: { pattern: regex, message: message } };\n}\n\nexport function length(length: number, message?: string): { [key: string]: LengthAnnotation } {\n return { length: { length: length, message: message } };\n}\n\nexport function maxLength(maxLength: number, message?: string): { [key: string]: MaxLengthAnnotation } {\n return { maxLength: { maxLength: maxLength, message: message } };\n}\n\nexport function minLength(minLength: number, message?: string): { [key: string]: MinLengthAnnotation } {\n return { minLength: { minLength: minLength, message: message } };\n}\n\nexport function ofValues(values: [], message?: string): { [key: string]: OfValuesAnnotation } {\n return { ofValues: { values: values, message: message } };\n}\n\nexport function equals<T>(value: T, message?: string): { [key: string]: EqualsAnnotation<T> } {\n return { equals: { equals: value, message: message } };\n}\n\nexport function min<T>(value: T, message?: string): { [key: string]: MinimumAnnotation<T> } {\n return { min: { min: value, message: message } };\n}\n\nexport function max<T>(value: T, message?: string): { [key: string]: MaximumAnnotation<T> } {\n return { max: { max: value, message: message } };\n}\n\nexport function test<T>(name: string, test: (d: T) => boolean, message?: string): { [key: string]: TestAnnotation<T> } {\n return { test: { name: name, test: test, message: message } };\n}\n","import { Injectable } from '@angular/core';\nimport { object, SchemaOf } from 'yup';\nimport { ModelValidator } from './model-validator';\nimport { SCHEMA_METADATA_NAMESPACE } from './constants';\nimport { ObjectShape } from 'yup/lib/object';\nimport { BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, ObjectTypeAnnotations, NumberTypeAnnotations, StringTypeAnnotations } from './type-annotations';\nimport * as Yup from 'yup';\n\n/*\nSchema rules need to be built in the order they need to be evaluated in.\nFor example,\n ```\n schema.required().max(...).matches(...);\n ```\nevaluates the 3 rules in this order\n - required\n - max\n - matches\n*/\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ModelSchemaFactory {\n constructor() {}\n\n build<T>(model: T): ModelValidator<T> {\n const schema = this.buildObjectSchema(model);\n return new ModelValidator(schema);\n }\n\n private buildObjectSchema<T>(model: T) {\n const metadata: Map<string, ConstraintAnnotations> = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);\n let shape: ObjectShape = {};\n metadata.forEach((value, key) => {\n if (value.constraintType == ConstraintType.string) {\n shape[key] = this.buildStringSchema(value as StringTypeAnnotations);\n } else if (value.constraintType == ConstraintType.boolean) {\n shape[key] = this.buildBooleanSchema(value as BooleanTypeAnnotations);\n } else if (value.constraintType == ConstraintType.date) {\n shape[key] = this.buildDateSchema(value as DateTypeAnnotations);\n } else if(value.constraintType == ConstraintType.object) {\n shape[key] = this.buildNestedObjectSchema(value as ObjectTypeAnnotations);\n } else if (value.constraintType == ConstraintType.number) {\n shape[key] = this.buildNumberSchema(value as NumberTypeAnnotations);\n }\n });\n return object(shape) as SchemaOf<T>;\n }\n\n private buildStringSchema(options: StringTypeAnnotations) {\n let schema = Yup.string();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.length) {\n schema = schema.length(options.length.length, options.length.message);\n }\n\n if (options.maxLength) {\n schema = schema.max(options.maxLength.maxLength, options.maxLength.message);\n }\n\n if (options.minLength) {\n schema = schema.min(options.minLength.minLength, options.minLength.message);\n }\n\n if (options.pattern) {\n schema = schema.matches(options.pattern.pattern, options.pattern.message);\n }\n\n return schema;\n }\n\n private buildBooleanSchema(options: BooleanTypeAnnotations) {\n let schema = Yup.boolean();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.equals) {\n if (options.equals.equals) {\n schema = schema.isTrue(options.equals.message);\n } else {\n schema = schema.isFalse(options.equals.message);\n }\n }\n\n return schema;\n }\n\n private buildDateSchema(options: DateTypeAnnotations) {\n let schema = Yup.date().typeError('Please enter a valid date');\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.min) {\n schema = schema.min(options.min.min, options.min.message);\n }\n if (options.max) {\n schema = schema.max(options.max.max, options.max.message);\n }\n if (options.test) {\n schema = schema.test({\n name: options.test.name,\n message: options.test.message,\n test: (d?: Date, context?: any) => {\n return options.test!.test(d!);\n }});\n }\n\n return schema;\n }\n\n private buildNumberSchema(options: NumberTypeAnnotations) {\n let schema = Yup.number();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n\n return schema;\n }\n\n private buildNestedObjectSchema(options: ObjectTypeAnnotations) {\n\n let nestedSchema = this.buildObjectSchema(options.getInstance());\n if(options.required) {\n nestedSchema = nestedSchema.required();\n }\n\n return nestedSchema;\n }\n}\n","import { Component, Input, OnInit } from '@angular/core';\nimport { NgControl, ValidationErrors } from '@angular/forms';\n\n@Component({\n selector: 'mz-field-errors',\n templateUrl: './field-errors.component.html',\n styleUrls: ['./field-errors.component.css'],\n})\nexport class FieldErrorsComponent {\n @Input() field?: NgControl;\n\n get errorMessage(): string {\n const errorKeys = Object.keys(this.field?.errors || {});\n return errorKeys.length > 0 ? (this.field?.errors as ValidationErrors)[errorKeys[0]] : '';\n }\n}\n","<div class=\"field-error\" *ngIf=\"errorMessage\">{{ errorMessage }}</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FieldErrorsComponent } from './field-errors/field-errors.component';\n\n\n\n@NgModule({\n providers: [],\n declarations: [\n FieldErrorsComponent\n ],\n exports: [\n FieldErrorsComponent\n ],\n imports: [\n CommonModule // TODO: can remove once done with temp error displaying\n ]\n})\nexport class FormsModule { }\n","import { Injectable, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { NgForm, ValidationErrors } from '@angular/forms';\nimport { BehaviorSubject, filter, from, switchMap } from 'rxjs';\nimport { FieldError } from './field-error';\nimport { ModelSchemaFactory } from './model-schema.factory';\nimport { ModelValidator } from './model-validator';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgFormModelStateFactory {\n constructor(private factory: ModelSchemaFactory) {}\n\n create<T>(form: NgForm, model: T, options?: ModelStateOptions) {\n const modelState = new NgFormModelState<T>(form, this.factory.build(model), model, options);\n return modelState;\n }\n}\n\nexport interface ModelStateOptions {\n onValidate: (errors: FieldError[]) => FieldError[];\n}\n\nexport class NgFormModelState<T> {\n private errors: BehaviorSubject<FieldError[]> = new BehaviorSubject<FieldError[]>([]);\n public errors$ = this.errors.asObservable();\n private options?: ModelStateOptions;\n\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.options = options;\n\n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(this.options?.onValidate));\n })\n )\n .subscribe();\n\n this.errors$.subscribe((list) => {\n const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map<string, FieldError[]>());\n\n grouped.forEach((value, path) => {\n let validationErrors = <ValidationErrors>{};\n value.forEach((v) => (validationErrors[v.type] = v.message));\n\n const control = this.form.form.get(path);\n if (!control) {\n // TODO: use actual logging service\n console.log(`cannot find path ${path}, which has errors`, validationErrors);\n } else {\n control.setErrors(validationErrors);\n }\n });\n });\n }\n\n isValid(): boolean {\n return this.errors.value.length == 0;\n }\n\n setErrors(errors: FieldError[]) {\n this.errors.next(errors);\n }\n\n async validate(): Promise<void> {\n return await this.runValidations(this.options?.onValidate);\n }\n\n private async runValidations(callback?: (list: FieldError[]) => FieldError[]): Promise<void> {\n this.removeCurrentErrors();\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n\n private removeCurrentErrors() {\n Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));\n }\n}\n","/*\n * Public API Surface of forms\n */\nexport * from './lib/field-error';\nexport * from './lib/model-schema.factory';\nexport * from './lib/model-validator';\nexport * from './lib/type-annotations';\nexport * from './lib/forms.module';\nexport * from './lib/ng-form-model-state.service';\nexport * from './lib/field-errors/field-errors.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ModelSchemaFactory"],"mappings":";;;;;;;;;MAGa,cAAc,CAAA;AAEzB,IAAA,WAAA,CAAY,WAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC3B;AA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;"}
1
+ {"version":3,"file":"muziehdesign-forms.mjs","sources":["../../../../projects/muziehdesign/forms/src/lib/model-validator.ts","../../../../projects/muziehdesign/forms/src/lib/constants.ts","../../../../projects/muziehdesign/forms/src/lib/type-annotations.ts","../../../../projects/muziehdesign/forms/src/lib/model-schema.factory.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.ts","../../../../projects/muziehdesign/forms/src/lib/field-errors/field-errors.component.html","../../../../projects/muziehdesign/forms/src/lib/forms.module.ts","../../../../projects/muziehdesign/forms/src/lib/ngform-model-state.ts","../../../../projects/muziehdesign/forms/src/lib/ng-form-model-state.service.ts","../../../../projects/muziehdesign/forms/src/public-api.ts","../../../../projects/muziehdesign/forms/src/muziehdesign-forms.ts"],"sourcesContent":["import { SchemaOf, ValidationError } from 'yup';\nimport { FieldError } from './field-error';\n\nexport class ModelValidator<T> {\n private schema: SchemaOf<T>;\n constructor(modelSchema: SchemaOf<T>) {\n this.schema = modelSchema;\n }\n\n validate<T>(model: T): Promise<FieldError[]> {\n return this.schema\n .validate(model, { abortEarly: false })\n .then(() => {\n return [];\n })\n .catch((e: ValidationError) => {\n return e.inner.map((error) => <FieldError>{ path: error.path, type: error.type, message: error.message });\n });\n }\n}\n","export const SCHEMA_METADATA_NAMESPACE = 'custom:muziehdesign:annotations';\n","import 'reflect-metadata';\n\nconst METADATA_KEY = 'custom:muziehdesign:annotations';\n\nexport enum ConstraintType {\n string,\n boolean,\n date,\n object,\n number,\n}\n\nexport interface ConstraintAnnotations {\n constraintType: ConstraintType;\n}\n\nexport interface StringTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n length?: LengthAnnotation;\n pattern?: PatternAnnotation;\n maxLength?: MaxLengthAnnotation;\n minLength?: MinLengthAnnotation;\n}\n\nexport interface BooleanTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n equals?: EqualsAnnotation<boolean>;\n}\n\nexport interface DateTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n min?: MinimumAnnotation<Date>;\n max?: MaximumAnnotation<Date>;\n test?: TestAnnotation<Date>;\n}\n\nexport interface ObjectTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n getInstance: () => any;\n}\n\nexport interface NumberTypeAnnotations extends ConstraintAnnotations {\n required?: RequiredAnnotation;\n}\n\nexport interface ValidationAnnotation {\n message?: string;\n}\n\nexport interface RequiredAnnotation extends ValidationAnnotation {\n required: boolean;\n}\n\nexport interface LengthAnnotation extends ValidationAnnotation {\n length: number;\n}\n\nexport interface PatternAnnotation extends ValidationAnnotation {\n pattern: RegExp;\n}\n\nexport interface OfValuesAnnotation extends ValidationAnnotation {\n values: [];\n}\n\nexport interface EqualsAnnotation<T> extends ValidationAnnotation {\n equals: T;\n}\n\nexport interface MinimumAnnotation<T> extends ValidationAnnotation {\n min: T;\n}\n\nexport interface MaximumAnnotation<T> extends ValidationAnnotation {\n max: T;\n}\n\nexport interface TestAnnotation<T> extends ValidationAnnotation {\n test: (d: T) => boolean;\n name: string;\n}\n\nexport interface MaxLengthAnnotation extends ValidationAnnotation {\n maxLength: number;\n}\n\nexport interface MinLengthAnnotation extends ValidationAnnotation {\n minLength: number;\n}\n\nconst registerMetadata = (target: Object, propertyKey: string, constraint: ConstraintAnnotations) => {\n const metadata: Map<string, any> = Reflect.getMetadata(METADATA_KEY, target) || new Map<string, any>();\n metadata.set(propertyKey, constraint);\n Reflect.defineMetadata(METADATA_KEY, metadata, target);\n};\n\nexport function StringType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as StringTypeAnnotations;\n o.constraintType = ConstraintType.string;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function BooleanType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as BooleanTypeAnnotations;\n o.constraintType = ConstraintType.boolean;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function DateType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as DateTypeAnnotations;\n o.constraintType = ConstraintType.date;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function NumberType(...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations) as NumberTypeAnnotations;\n o.constraintType = ConstraintType.number;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function ObjectType<T>(type: { new (): T }, ...annotations: { [key: string]: ValidationAnnotation }[]) {\n return function (target: Object, propertyKey: string) {\n const o = Object.assign({}, ...annotations, { getInstance: () => new type() } as Partial<ObjectTypeAnnotations>) as ObjectTypeAnnotations;\n o.constraintType = ConstraintType.object;\n registerMetadata(target, propertyKey, o);\n };\n}\n\nexport function required(message?: string): { [key: string]: RequiredAnnotation } {\n return { required: { required: true, message: message } };\n}\n\nexport function pattern(regex: RegExp, message?: string): { [key: string]: PatternAnnotation } {\n return { pattern: { pattern: regex, message: message } };\n}\n\nexport function length(length: number, message?: string): { [key: string]: LengthAnnotation } {\n return { length: { length: length, message: message } };\n}\n\nexport function maxLength(maxLength: number, message?: string): { [key: string]: MaxLengthAnnotation } {\n return { maxLength: { maxLength: maxLength, message: message } };\n}\n\nexport function minLength(minLength: number, message?: string): { [key: string]: MinLengthAnnotation } {\n return { minLength: { minLength: minLength, message: message } };\n}\n\nexport function ofValues(values: [], message?: string): { [key: string]: OfValuesAnnotation } {\n return { ofValues: { values: values, message: message } };\n}\n\nexport function equals<T>(value: T, message?: string): { [key: string]: EqualsAnnotation<T> } {\n return { equals: { equals: value, message: message } };\n}\n\nexport function min<T>(value: T, message?: string): { [key: string]: MinimumAnnotation<T> } {\n return { min: { min: value, message: message } };\n}\n\nexport function max<T>(value: T, message?: string): { [key: string]: MaximumAnnotation<T> } {\n return { max: { max: value, message: message } };\n}\n\nexport function test<T>(name: string, test: (d: T) => boolean, message?: string): { [key: string]: TestAnnotation<T> } {\n return { test: { name: name, test: test, message: message } };\n}\n","import { Injectable } from '@angular/core';\nimport { object, SchemaOf } from 'yup';\nimport { ModelValidator } from './model-validator';\nimport { SCHEMA_METADATA_NAMESPACE } from './constants';\nimport { ObjectShape } from 'yup/lib/object';\nimport { BooleanTypeAnnotations, ConstraintAnnotations, ConstraintType, DateTypeAnnotations, ObjectTypeAnnotations, NumberTypeAnnotations, StringTypeAnnotations } from './type-annotations';\nimport * as Yup from 'yup';\n\n/*\nSchema rules need to be built in the order they need to be evaluated in.\nFor example,\n ```\n schema.required().max(...).matches(...);\n ```\nevaluates the 3 rules in this order\n - required\n - max\n - matches\n*/\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ModelSchemaFactory {\n constructor() {}\n\n build<T>(model: T): ModelValidator<T> {\n const schema = this.buildObjectSchema(model);\n return new ModelValidator(schema);\n }\n\n private buildObjectSchema<T>(model: T) {\n const metadata: Map<string, ConstraintAnnotations> = Reflect.getMetadata(SCHEMA_METADATA_NAMESPACE, model);\n let shape: ObjectShape = {};\n metadata.forEach((value, key) => {\n if (value.constraintType == ConstraintType.string) {\n shape[key] = this.buildStringSchema(value as StringTypeAnnotations);\n } else if (value.constraintType == ConstraintType.boolean) {\n shape[key] = this.buildBooleanSchema(value as BooleanTypeAnnotations);\n } else if (value.constraintType == ConstraintType.date) {\n shape[key] = this.buildDateSchema(value as DateTypeAnnotations);\n } else if(value.constraintType == ConstraintType.object) {\n shape[key] = this.buildNestedObjectSchema(value as ObjectTypeAnnotations);\n } else if (value.constraintType == ConstraintType.number) {\n shape[key] = this.buildNumberSchema(value as NumberTypeAnnotations);\n }\n });\n return object(shape) as SchemaOf<T>;\n }\n\n private buildStringSchema(options: StringTypeAnnotations) {\n let schema = Yup.string();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.length) {\n schema = schema.length(options.length.length, options.length.message);\n }\n\n if (options.maxLength) {\n schema = schema.max(options.maxLength.maxLength, options.maxLength.message);\n }\n\n if (options.minLength) {\n schema = schema.min(options.minLength.minLength, options.minLength.message);\n }\n\n if (options.pattern) {\n schema = schema.matches(options.pattern.pattern, options.pattern.message);\n }\n\n return schema;\n }\n\n private buildBooleanSchema(options: BooleanTypeAnnotations) {\n let schema = Yup.boolean();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.equals) {\n if (options.equals.equals) {\n schema = schema.isTrue(options.equals.message);\n } else {\n schema = schema.isFalse(options.equals.message);\n }\n }\n\n return schema;\n }\n\n private buildDateSchema(options: DateTypeAnnotations) {\n let schema = Yup.date().typeError('Please enter a valid date');\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n if (options.min) {\n schema = schema.min(options.min.min, options.min.message);\n }\n if (options.max) {\n schema = schema.max(options.max.max, options.max.message);\n }\n if (options.test) {\n schema = schema.test({\n name: options.test.name,\n message: options.test.message,\n test: (d?: Date, context?: any) => {\n return options.test!.test(d!);\n }});\n }\n\n return schema;\n }\n\n private buildNumberSchema(options: NumberTypeAnnotations) {\n let schema = Yup.number();\n if (options.required) {\n schema = schema.required(options.required.message);\n }\n\n return schema;\n }\n\n private buildNestedObjectSchema(options: ObjectTypeAnnotations) {\n\n let nestedSchema = this.buildObjectSchema(options.getInstance());\n if(options.required) {\n nestedSchema = nestedSchema.required();\n }\n\n return nestedSchema;\n }\n}\n","import { Component, Input, OnInit } from '@angular/core';\nimport { NgControl, ValidationErrors } from '@angular/forms';\n\n@Component({\n selector: 'mz-field-errors',\n templateUrl: './field-errors.component.html',\n styleUrls: ['./field-errors.component.css'],\n})\nexport class FieldErrorsComponent {\n @Input() field?: NgControl;\n\n get errorMessage(): string {\n const errorKeys = Object.keys(this.field?.errors || {});\n return errorKeys.length > 0 ? (this.field?.errors as ValidationErrors)[errorKeys[0]] : '';\n }\n}\n","<div class=\"field-error\" *ngIf=\"errorMessage\">{{ errorMessage }}</div>\n","import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { FieldErrorsComponent } from './field-errors/field-errors.component';\n\n\n\n@NgModule({\n providers: [],\n declarations: [\n FieldErrorsComponent\n ],\n exports: [\n FieldErrorsComponent\n ],\n imports: [\n CommonModule // TODO: can remove once done with temp error displaying\n ]\n})\nexport class FormsModule { }\n","import { NgForm, ValidationErrors } from \"@angular/forms\";\nimport { BehaviorSubject, from, switchMap } from \"rxjs\";\nimport { FieldError } from \"./field-error\";\nimport { ModelStateOptions } from \"./model-state-options\";\nimport { ModelValidator } from \"./model-validator\";\n\nexport class NgFormModelState<T> {\n private changesSubject = new BehaviorSubject<boolean | undefined>(undefined);\n public readonly changes = this.changesSubject.asObservable();\n private errors: BehaviorSubject<FieldError[]> = new BehaviorSubject<FieldError[]>([]);\n private errors$ = this.errors.asObservable();\n private options?: ModelStateOptions;\n\n // TODO: remove model\n constructor(private form: NgForm, private modelValidator: ModelValidator<T>, private model: T, options?: ModelStateOptions) {\n this.options = options;\n\n this.form.form.valueChanges\n .pipe(\n switchMap(async (x) => {\n this.model = x;\n return from(this.runValidations(this.options?.onValidate));\n })\n )\n .subscribe();\n\n this.errors$.subscribe((list) => {\n const grouped = list.reduce((grouped, v) => grouped.set(v.path, [...(grouped.get(v.path) || []), v]), new Map<string, FieldError[]>());\n\n grouped.forEach((value, path) => {\n let validationErrors = <ValidationErrors>{};\n value.forEach((v) => (validationErrors[v.type] = v.message));\n\n const control = this.form.form.get(path);\n if (!control) {\n // TODO: use actual logging service\n console.log(`cannot find path ${path}, which has errors`, validationErrors);\n } else {\n control.setErrors(validationErrors);\n }\n });\n\n this.changesSubject.next(this.errors.value.length == 0);\n });\n }\n\n isValid(): boolean {\n return this.errors.value.length == 0;\n }\n\n setErrors(errors: FieldError[]) {\n this.errors.next(errors);\n }\n\n async validate(): Promise<void> {\n return await this.runValidations(this.options?.onValidate);\n }\n\n private async runValidations(callback?: (list: FieldError[]) => FieldError[]): Promise<void> {\n this.removeCurrentErrors();\n const list = await this.modelValidator.validate(this.model);\n const final = callback?.(list) || list;\n this.errors.next(final);\n }\n\n private removeCurrentErrors() {\n Object.keys(this.form.controls).forEach((key) => this.form.controls[key].setErrors(null));\n }\n\n}\n","import { Injectable, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { NgForm, ValidationErrors } from '@angular/forms';\nimport { BehaviorSubject, filter, from, switchMap } from 'rxjs';\nimport { FieldError } from './field-error';\nimport { ModelSchemaFactory } from './model-schema.factory';\nimport { ModelStateOptions } from './model-state-options';\nimport { ModelValidator } from './model-validator';\nimport { NgFormModelState } from './ngform-model-state';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgFormModelStateFactory {\n constructor(private factory: ModelSchemaFactory) {}\n\n create<T>(form: NgForm, model: T, options?: ModelStateOptions) {\n const modelState = new NgFormModelState<T>(form, this.factory.build(model), model, options);\n return modelState;\n }\n}\n","/*\n * Public API Surface of forms\n */\nexport * from './lib/field-error';\nexport * from './lib/model-schema.factory';\nexport * from './lib/model-validator';\nexport * from './lib/type-annotations';\nexport * from './lib/forms.module';\nexport * from './lib/ng-form-model-state.service';\nexport * from './lib/ngform-model-state';\nexport * from './lib/field-errors/field-errors.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.ModelSchemaFactory"],"mappings":";;;;;;;;;MAGa,cAAc,CAAA;AAEzB,IAAA,WAAA,CAAY,WAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;KAC3B;AAED,IAAA,QAAQ,CAAI,KAAQ,EAAA;QAClB,OAAO,IAAI,CAAC,MAAM;aACf,QAAQ,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;aACtC,IAAI,CAAC,MAAK;AACT,YAAA,OAAO,EAAE,CAAC;AACZ,SAAC,CAAC;AACD,aAAA,KAAK,CAAC,CAAC,CAAkB,KAAI;AAC5B,YAAA,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,MAAiB,EAAE,IA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interface ModelStateOptions {
3
+ onValidate: (errors: FieldError[]) => FieldError[];
4
+ }
@@ -1,7 +1,7 @@
1
1
  import { NgForm } from '@angular/forms';
2
- import { FieldError } from './field-error';
3
2
  import { ModelSchemaFactory } from './model-schema.factory';
4
- import { ModelValidator } from './model-validator';
3
+ import { ModelStateOptions } from './model-state-options';
4
+ import { NgFormModelState } from './ngform-model-state';
5
5
  import * as i0 from "@angular/core";
6
6
  export declare class NgFormModelStateFactory {
7
7
  private factory;
@@ -10,20 +10,3 @@ export declare class NgFormModelStateFactory {
10
10
  static ɵfac: i0.ɵɵFactoryDeclaration<NgFormModelStateFactory, never>;
11
11
  static ɵprov: i0.ɵɵInjectableDeclaration<NgFormModelStateFactory>;
12
12
  }
13
- export interface ModelStateOptions {
14
- onValidate: (errors: FieldError[]) => FieldError[];
15
- }
16
- export declare class NgFormModelState<T> {
17
- private form;
18
- private modelValidator;
19
- private model;
20
- private errors;
21
- errors$: import("rxjs").Observable<FieldError[]>;
22
- private options?;
23
- constructor(form: NgForm, modelValidator: ModelValidator<T>, model: T, options?: ModelStateOptions);
24
- isValid(): boolean;
25
- setErrors(errors: FieldError[]): void;
26
- validate(): Promise<void>;
27
- private runValidations;
28
- private removeCurrentErrors;
29
- }
@@ -0,0 +1,20 @@
1
+ import { NgForm } from "@angular/forms";
2
+ import { FieldError } from "./field-error";
3
+ import { ModelStateOptions } from "./model-state-options";
4
+ import { ModelValidator } from "./model-validator";
5
+ export declare class NgFormModelState<T> {
6
+ private form;
7
+ private modelValidator;
8
+ private model;
9
+ private changesSubject;
10
+ readonly changes: import("rxjs").Observable<boolean | undefined>;
11
+ private errors;
12
+ private errors$;
13
+ private options?;
14
+ constructor(form: NgForm, modelValidator: ModelValidator<T>, model: T, options?: ModelStateOptions);
15
+ isValid(): boolean;
16
+ setErrors(errors: FieldError[]): void;
17
+ validate(): Promise<void>;
18
+ private runValidations;
19
+ private removeCurrentErrors;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muziehdesign/forms",
3
- "version": "0.0.1-191",
3
+ "version": "0.0.1-207",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^14.0.0",
6
6
  "@angular/core": "^14.0.0"
package/public-api.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './lib/model-validator';
4
4
  export * from './lib/type-annotations';
5
5
  export * from './lib/forms.module';
6
6
  export * from './lib/ng-form-model-state.service';
7
+ export * from './lib/ngform-model-state';
7
8
  export * from './lib/field-errors/field-errors.component';