@muziehdesign/forms 0.0.1-alpha.99 → 0.0.394

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.
@@ -3,9 +3,12 @@ import * as i0 from "@angular/core";
3
3
  export declare class ModelSchemaFactory {
4
4
  constructor();
5
5
  build<T>(model: T): ModelValidator<T>;
6
+ private buildObjectSchema;
6
7
  private buildStringSchema;
7
8
  private buildBooleanSchema;
8
9
  private buildDateSchema;
10
+ private buildNumberSchema;
11
+ private buildNestedObjectSchema;
9
12
  static ɵfac: i0.ɵɵFactoryDeclaration<ModelSchemaFactory, never>;
10
13
  static ɵprov: i0.ɵɵInjectableDeclaration<ModelSchemaFactory>;
11
14
  }
@@ -0,0 +1,4 @@
1
+ import { FieldError } from './field-error';
2
+ export interface ModelStateOptions {
3
+ onValidate: (errors: FieldError[]) => FieldError[];
4
+ }
@@ -0,0 +1,6 @@
1
+ import { FieldError } from "./field-error";
2
+ export interface ModelStateResult<T> {
3
+ valid: boolean;
4
+ errors: FieldError[];
5
+ model: T;
6
+ }
@@ -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,18 +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
- constructor(form: NgForm, modelValidator: ModelValidator<T>, model: T, options?: ModelStateOptions);
23
- isValid(): boolean;
24
- setErrors(errors: FieldError[]): void;
25
- validate(): Promise<void>;
26
- private runValidations;
27
- }
@@ -0,0 +1,25 @@
1
+ import { NgForm } from '@angular/forms';
2
+ import { FieldError } from './field-error';
3
+ import { ModelStateOptions } from './model-state-options';
4
+ import { ModelStateResult } from './model-state-result';
5
+ import { ModelValidator } from './model-validator';
6
+ export declare class NgFormModelState<T> {
7
+ private form;
8
+ private modelValidator;
9
+ private options?;
10
+ private changesSubject;
11
+ readonly changes: import("rxjs").Observable<ModelStateResult<T> | undefined>;
12
+ constructor(form: NgForm, modelValidator: ModelValidator<T>, options?: ModelStateOptions | undefined);
13
+ getCurrent(): ModelStateResult<T> | undefined;
14
+ setState(model: T, errors: FieldError[]): void;
15
+ setErrors(errors: FieldError[]): void;
16
+ appendErrors(errors: FieldError[], skipEmit?: boolean): void;
17
+ validate(): Promise<ModelStateResult<T>>;
18
+ private setStateInternal;
19
+ private deleteFormErrors;
20
+ private deleteErrors;
21
+ private deleteErrorsFromControl;
22
+ private isParentControl;
23
+ private loopFormArray;
24
+ private runValidations;
25
+ }
@@ -2,7 +2,9 @@ import 'reflect-metadata';
2
2
  export declare enum ConstraintType {
3
3
  string = 0,
4
4
  boolean = 1,
5
- date = 2
5
+ date = 2,
6
+ object = 3,
7
+ number = 4
6
8
  }
7
9
  export interface ConstraintAnnotations {
8
10
  constraintType: ConstraintType;
@@ -22,7 +24,14 @@ export interface DateTypeAnnotations extends ConstraintAnnotations {
22
24
  required?: RequiredAnnotation;
23
25
  min?: MinimumAnnotation<Date>;
24
26
  max?: MaximumAnnotation<Date>;
25
- test?: TestAnnotation;
27
+ test?: TestAnnotation<Date>;
28
+ }
29
+ export interface ObjectTypeAnnotations extends ConstraintAnnotations {
30
+ required?: RequiredAnnotation;
31
+ getInstance: () => any;
32
+ }
33
+ export interface NumberTypeAnnotations extends ConstraintAnnotations {
34
+ required?: RequiredAnnotation;
26
35
  }
27
36
  export interface ValidationAnnotation {
28
37
  message?: string;
@@ -48,8 +57,8 @@ export interface MinimumAnnotation<T> extends ValidationAnnotation {
48
57
  export interface MaximumAnnotation<T> extends ValidationAnnotation {
49
58
  max: T;
50
59
  }
51
- export interface TestAnnotation extends ValidationAnnotation {
52
- test: (d: Date) => boolean;
60
+ export interface TestAnnotation<T> extends ValidationAnnotation {
61
+ test: (d: T) => boolean;
53
62
  name: string;
54
63
  }
55
64
  export interface MaxLengthAnnotation extends ValidationAnnotation {
@@ -58,13 +67,23 @@ export interface MaxLengthAnnotation extends ValidationAnnotation {
58
67
  export interface MinLengthAnnotation extends ValidationAnnotation {
59
68
  minLength: number;
60
69
  }
61
- export declare function Annotate<T extends ConstraintAnnotations>(a: AnnotationType<T>): (target: Object, propertyKey: string) => void;
62
70
  export declare function StringType(...annotations: {
63
71
  [key: string]: ValidationAnnotation;
64
72
  }[]): (target: Object, propertyKey: string) => void;
65
73
  export declare function BooleanType(...annotations: {
66
74
  [key: string]: ValidationAnnotation;
67
75
  }[]): (target: Object, propertyKey: string) => void;
76
+ export declare function DateType(...annotations: {
77
+ [key: string]: ValidationAnnotation;
78
+ }[]): (target: Object, propertyKey: string) => void;
79
+ export declare function NumberType(...annotations: {
80
+ [key: string]: ValidationAnnotation;
81
+ }[]): (target: Object, propertyKey: string) => void;
82
+ export declare function ObjectType<T>(type: {
83
+ new (): T;
84
+ }, ...annotations: {
85
+ [key: string]: ValidationAnnotation;
86
+ }[]): (target: Object, propertyKey: string) => void;
68
87
  export declare function required(message?: string): {
69
88
  [key: string]: RequiredAnnotation;
70
89
  };
@@ -86,30 +105,12 @@ export declare function ofValues(values: [], message?: string): {
86
105
  export declare function equals<T>(value: T, message?: string): {
87
106
  [key: string]: EqualsAnnotation<T>;
88
107
  };
89
- export declare abstract class AnnotationType<T> {
90
- abstract readonly name: string;
91
- abstract annotations?: T;
92
- }
93
- export declare class StringType2 extends AnnotationType<StringTypeAnnotations> {
94
- readonly name: string;
95
- annotations: StringTypeAnnotations;
96
- required(message?: string): this;
97
- pattern(pattern: RegExp, message?: string): this;
98
- }
99
- export declare class BooleanType2 extends AnnotationType<BooleanTypeAnnotations> {
100
- readonly name: string;
101
- annotations: BooleanTypeAnnotations;
102
- required(message?: string): this;
103
- equals(v: boolean, message?: string): this;
104
- }
105
- export declare function string(): StringType2;
106
- export declare function boolean(): BooleanType2;
107
- export declare class DateType extends AnnotationType<DateTypeAnnotations> {
108
- readonly name: string;
109
- annotations: DateTypeAnnotations;
110
- required(message?: string): this;
111
- min(v: Date, message?: string): this;
112
- max(v: Date, message?: string): this;
113
- test(name: string, v: (d: Date) => boolean, message?: string): this;
114
- }
115
- export declare function date(): DateType;
108
+ export declare function min<T>(value: T, message?: string): {
109
+ [key: string]: MinimumAnnotation<T>;
110
+ };
111
+ export declare function max<T>(value: T, message?: string): {
112
+ [key: string]: MaximumAnnotation<T>;
113
+ };
114
+ export declare function test<T>(name: string, test: (d: T) => boolean, message?: string): {
115
+ [key: string]: TestAnnotation<T>;
116
+ };
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@muziehdesign/forms",
3
- "version": "0.0.1-alpha.99",
3
+ "version": "0.0.394",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^14.0.0",
6
- "@angular/core": "^14.0.0"
6
+ "@angular/core": "^14.0.0",
7
+ "@angular/forms": "^14.0.0",
8
+ "date-fns": "^2.29.2",
9
+ "angular-imask": "^6.4.0",
10
+ "reflect-metadata": "^0.1.13",
11
+ "yup": "^0.32.11"
7
12
  },
8
13
  "dependencies": {
9
14
  "tslib": "^2.3.0"
package/public-api.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export * from './lib/field-error';
2
+ export * from './lib/model-state-result';
2
3
  export * from './lib/model-schema.factory';
3
4
  export * from './lib/model-validator';
4
5
  export * from './lib/type-annotations';
5
6
  export * from './lib/forms.module';
6
7
  export * from './lib/ng-form-model-state.service';
8
+ export * from './lib/ngform-model-state';
7
9
  export * from './lib/field-errors/field-errors.component';
10
+ export * from './lib/masks';