@sumaris-net/ngx-components 1.12.13 → 1.13.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sumaris-net/ngx-components",
3
3
  "description": "SUMARiS Angular components",
4
- "version": "1.12.13",
4
+ "version": "1.13.0",
5
5
  "author": "contact@e-is.pro",
6
6
  "license": "AGPL-3.0",
7
7
  "readmeFilename": "README.md",
@@ -22,3 +22,4 @@ export declare function firstFalse(obs: Observable<boolean>): Observable<void>;
22
22
  */
23
23
  export declare function waitFor(predicate: Predicate<void>, opts?: WaitForOptions): Promise<void>;
24
24
  export declare function waitForTrue(observable: Observable<boolean>, opts?: WaitForOptions): Promise<void>;
25
+ export declare function fromPromise<T>(promise: Promise<T>): Observable<T>;
@@ -1,5 +1,6 @@
1
- import { AbstractControl, FormControl, ValidationErrors, ValidatorFn } from '@angular/forms';
1
+ import { AbstractControl, AsyncValidatorFn, FormControl, ValidationErrors, ValidatorFn } from '@angular/forms';
2
2
  import { Moment, unitOfTime } from 'moment';
3
+ import { Observable, Subscription } from 'rxjs';
3
4
  export declare class SharedValidators {
4
5
  private static _REGEXP_CACHE;
5
6
  private static getDoubleRegexp;
@@ -71,3 +72,36 @@ export declare class SharedFormArrayValidators {
71
72
  */
72
73
  static validSumMaxValue(controlName: string, max: number): ValidatorFn;
73
74
  }
75
+ export declare type ObservableValidatorFn = (control: AbstractControl) => Observable<ValidationErrors | null>;
76
+ export declare type PromiseValidatorFn = (control: AbstractControl) => Promise<ValidationErrors | null>;
77
+ export declare class SharedAsyncValidators {
78
+ /**
79
+ * Create an observable validator function. Will execute the validator, then cnvert the result into an observable
80
+ * @param validatorFn any validator
81
+ */
82
+ static of(validatorFn: ValidatorFn | AsyncValidatorFn): ObservableValidatorFn;
83
+ private static DEBOUNCE_TIME_VALIDATOR_ID;
84
+ /**
85
+ * Add a debounce time to a validator.
86
+ * @param form
87
+ * @param validatorFn
88
+ * @param opts Use opts.stopSubject to stop the validator, before end
89
+ */
90
+ static debounceTime(validatorFn: ValidatorFn | AsyncValidatorFn, opts?: {
91
+ dispose?: Observable<any>;
92
+ debounceTime?: number;
93
+ markForCheck?: () => void;
94
+ debug?: boolean;
95
+ }): ObservableValidatorFn;
96
+ /**
97
+ * Add an async validator, that can be disposed by the returned subscription
98
+ * @param form
99
+ * @param validatorFn the validator or job to execute
100
+ * @param opts
101
+ */
102
+ static registerAsyncValidator(form: AbstractControl, validatorFn: ValidatorFn | AsyncValidatorFn, opts?: {
103
+ debounceTime?: number;
104
+ markForCheck?: () => void;
105
+ debug?: boolean;
106
+ }): Subscription;
107
+ }