@reactables/forms 0.7.0-alpha.0 → 0.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Helpers/addAsyncValidationEffects.d.ts +2 -1
- package/dist/Helpers/buildFormState.d.ts +3 -2
- package/dist/Helpers/reverseObjectKeys.d.ts +2 -0
- package/dist/Models/Configs.d.ts +3 -4
- package/dist/Models/Validators.d.ts +2 -2
- package/dist/Reducers/Hub1/addControl.d.ts +2 -1
- package/dist/Reducers/Hub1/getErrors.d.ts +2 -1
- package/dist/Reducers/Hub1/pushControl.d.ts +2 -1
- package/dist/Reducers/Hub1/removeControl.d.ts +2 -1
- package/dist/Reducers/Hub1/resetControl.d.ts +2 -1
- package/dist/Reducers/Hub1/updateAncestorValues.d.ts +2 -1
- package/dist/Reducers/Hub1/updateAncestorValuesAddControl.d.ts +2 -1
- package/dist/Reducers/Hub1/updateAncestorValuesRemoveControl.d.ts +2 -1
- package/dist/Reducers/Hub1/updateValues.d.ts +2 -1
- package/dist/Reducers/Hub2/mergeControls.d.ts +1 -22
- package/dist/Reducers/Hub2/mergeRemoveControl.d.ts +1 -1
- package/dist/RxForm/RxForm.d.ts +15 -1
- package/dist/RxForm/Tests/load.test.d.ts +1 -0
- package/dist/RxForm/index.d.ts +1 -1
- package/dist/Testing/Models/initialState.d.ts +667 -0
- package/dist/Testing/Validators.d.ts +10 -0
- package/dist/Testing/asyncConfig.d.ts +0 -8
- package/dist/Testing/config.d.ts +0 -8
- package/dist/Validators/Validators.d.ts +0 -1
- package/dist/index.js +144 -73
- package/package.json +2 -2
- package/dist/Helpers/FormBuilder.d.ts +0 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Action, Effect } from '@reactables/core';
|
|
2
2
|
import { BaseControl } from '../Models/Controls';
|
|
3
3
|
import { ControlAsyncValidationResponse } from '../Models/Payloads';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../RxForm/RxForm';
|
|
5
|
+
export declare const getScopedEffectsForControl: <T>(formControl: BaseControl<T>, providers: RxFormProviders) => Effect<BaseControl<T>, ControlAsyncValidationResponse>[];
|
|
5
6
|
export declare const getAsyncValidationActions: (formControls: BaseControl<unknown>[]) => Action<BaseControl<unknown>>[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractControlConfig } from '../Models/Configs';
|
|
2
2
|
import { BaseForm, BaseFormState } from '../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../Models/ControlRef';
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
4
|
+
import { RxFormProviders } from '../RxForm/RxForm';
|
|
5
|
+
export declare const buildState: <T>(config: AbstractControlConfig, form: BaseForm<T>, controlRef: ControlRef, providers: RxFormProviders) => BaseForm<T>;
|
|
6
|
+
export declare const buildFormState: <T>(config: AbstractControlConfig, form: BaseForm<T>, controlRef: ControlRef, providers: RxFormProviders) => BaseFormState<T>;
|
package/dist/Models/Configs.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ValidatorFn, ValidatorAsyncFn } from './Validators';
|
|
2
1
|
interface ValidatorConfigs {
|
|
3
|
-
validators?:
|
|
4
|
-
asyncValidators?:
|
|
2
|
+
validators?: string[];
|
|
3
|
+
asyncValidators?: string[];
|
|
5
4
|
}
|
|
6
5
|
export interface FormGroupConfig extends ValidatorConfigs {
|
|
7
6
|
controls: {
|
|
@@ -13,7 +12,7 @@ export interface FormArrayConfig extends ValidatorConfigs {
|
|
|
13
12
|
}
|
|
14
13
|
export interface FormControlConfig<T> extends ValidatorConfigs {
|
|
15
14
|
initialValue: T;
|
|
16
|
-
normalizers?:
|
|
15
|
+
normalizers?: string[];
|
|
17
16
|
}
|
|
18
17
|
export type AbstractControlConfig = (FormControlConfig<unknown> | FormArrayConfig | FormGroupConfig) & {
|
|
19
18
|
controls?: AbstractControlConfig[] | {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseControl } from './Controls';
|
|
3
3
|
import { FormErrors } from './FormErrors';
|
|
4
4
|
export type ValidatorFn = (value: unknown) => FormErrors;
|
|
5
|
-
export type ValidatorAsyncFn = <T>(control$: Observable<
|
|
5
|
+
export type ValidatorAsyncFn = <T>(control$: Observable<BaseControl<T>>) => Observable<FormErrors>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseFormState } from '../../Models/Controls';
|
|
3
3
|
import { AddControlPayload } from '../../Models/Payloads';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
5
|
+
export declare const addControl: <T>(state: BaseFormState<T>, action: Action<AddControlPayload>, providers: RxFormProviders, mergeChanges?: boolean) => BaseFormState<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { BaseControl } from '../../Models/Controls';
|
|
2
2
|
import { FormErrors } from '../../Models';
|
|
3
|
-
|
|
3
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
4
|
+
export declare const getErrors: <T>(control: BaseControl<T>, value: T, { validators }: RxFormProviders) => FormErrors;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseFormState } from '../../Models/Controls';
|
|
3
3
|
import { AddControlPayload } from '../../Models/Payloads';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
5
|
+
export declare const pushControl: <T>(state: BaseFormState<T>, action: Action<AddControlPayload>, providers: RxFormProviders, mergeChanges?: boolean) => BaseFormState<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseFormState } from '../../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../../Models/ControlRef';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
5
|
+
export declare const removeControl: <T>(state: BaseFormState<T>, action: Action<ControlRef>, providers: RxFormProviders, mergeChanges?: boolean) => BaseFormState<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseFormState } from '../../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../../Models/ControlRef';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
5
|
+
export declare const resetControl: <T>(state: BaseFormState<T>, action: Action<ControlRef>, providers: RxFormProviders, mergeChanges?: boolean) => BaseFormState<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseForm } from '../../Models/Controls';
|
|
3
3
|
import { UpdateValuesPayload } from '../../Models/Payloads';
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
4
5
|
export declare const UPDATE_ANCESTOR_VALUES = "UPDATE_ANCESTOR_VALUES";
|
|
5
|
-
export declare const updateAncestorValues: <T>(form: BaseForm<T>, { payload: { controlRef, value } }: Action<UpdateValuesPayload<unknown
|
|
6
|
+
export declare const updateAncestorValues: <T>(form: BaseForm<T>, { payload: { controlRef, value } }: Action<UpdateValuesPayload<unknown>>, providers: RxFormProviders) => BaseForm<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseForm } from '../../Models/Controls';
|
|
3
3
|
import { UpdateValuesPayload } from '../../Models/Payloads';
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
4
5
|
export declare const UPDATE_ANCESTOR_VALUES_ADD_CONTROL = "UPDATE_ANCESTOR_VALUES_ADD_CONTROL";
|
|
5
|
-
export declare const updateAncestorValuesAddControl: <T>(form: BaseForm<T>, { payload: { controlRef, value } }: Action<UpdateValuesPayload<unknown
|
|
6
|
+
export declare const updateAncestorValuesAddControl: <T>(form: BaseForm<T>, { payload: { controlRef, value } }: Action<UpdateValuesPayload<unknown>>, providers: RxFormProviders) => BaseForm<T>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseForm } from '../../Models/Controls';
|
|
3
3
|
import { ControlRef } from '../../Models/ControlRef';
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
4
5
|
export declare const UPDATE_ANCESTOR_VALUES_REMOVE_CONTROL = "UPDATE_ANCESTOR_VALUES_REMOVE_CONTROL";
|
|
5
|
-
export declare const updateAncestorValuesRemoveControl: <T>(form: BaseForm<T>, { payload: controlRef }: Action<ControlRef
|
|
6
|
+
export declare const updateAncestorValuesRemoveControl: <T>(form: BaseForm<T>, { payload: controlRef }: Action<ControlRef>, providers: RxFormProviders) => BaseForm<T>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action } from '@reactables/core';
|
|
2
2
|
import { BaseFormState } from '../../Models/Controls';
|
|
3
3
|
import { UpdateValuesPayload } from '../../Models/Payloads';
|
|
4
|
-
|
|
4
|
+
import { RxFormProviders } from '../../RxForm/RxForm';
|
|
5
|
+
export declare const updateValues: <T>({ form, changedControls, removedControls }: BaseFormState<T>, action: Action<UpdateValuesPayload<unknown>>, providers: RxFormProviders, mergeChanges?: boolean) => BaseFormState<T>;
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { Form, FormControl, BaseFormState } from '../../Models/Controls';
|
|
2
|
-
import { FormErrors } from '../../Models/FormErrors';
|
|
3
2
|
export declare const mergeControls: <T>(state: Form<T>, { form, changedControls, removedControls }: BaseFormState<unknown>) => {
|
|
4
|
-
[x: string]: FormControl<unknown
|
|
5
|
-
errors: {
|
|
6
|
-
[x: string]: boolean;
|
|
7
|
-
};
|
|
8
|
-
valid: boolean;
|
|
9
|
-
childrenValid: boolean;
|
|
10
|
-
pristineValue: unknown;
|
|
11
|
-
controlRef: import("../..").ControlRef;
|
|
12
|
-
value: unknown;
|
|
13
|
-
dirty: boolean;
|
|
14
|
-
touched: boolean;
|
|
15
|
-
validatorErrors: FormErrors;
|
|
16
|
-
config: import("../..").AbstractControlConfig;
|
|
17
|
-
key: string;
|
|
18
|
-
asyncValidatorErrors: FormErrors;
|
|
19
|
-
asyncValidateInProgress: {
|
|
20
|
-
[key: string]: boolean;
|
|
21
|
-
[key: number]: boolean;
|
|
22
|
-
};
|
|
23
|
-
pending?: boolean;
|
|
24
|
-
};
|
|
3
|
+
[x: string]: FormControl<unknown>;
|
|
25
4
|
root?: FormControl<unknown>;
|
|
26
5
|
};
|
|
@@ -2,5 +2,5 @@ import { Form, BaseForm, FormControl } from '../../Models/Controls';
|
|
|
2
2
|
import { ControlRef } from '../../Models/ControlRef';
|
|
3
3
|
export declare const mergeRemoveControl: <T>(state: Form<T>, form: BaseForm<T>, controlRef: ControlRef) => {
|
|
4
4
|
[x: string]: FormControl<unknown>;
|
|
5
|
-
root?: FormControl<
|
|
5
|
+
root?: FormControl<unknown>;
|
|
6
6
|
};
|
package/dist/RxForm/RxForm.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ControlRef } from '../Models';
|
|
|
4
4
|
import { FormControlConfig, FormArrayConfig, FormGroupConfig, AbstractControlConfig } from '../Models/Configs';
|
|
5
5
|
import { ValidatorFn, ValidatorAsyncFn } from '../Models/Validators';
|
|
6
6
|
import { Form, BaseFormState } from '../Models/Controls';
|
|
7
|
-
type FbControl<T> = [T, (
|
|
7
|
+
type FbControl<T> = [T, (string | string[])?, (string | string[])?];
|
|
8
8
|
export declare const control: <T>(config: FormControlConfig<T> | FbControl<T>) => FormControlConfig<T>;
|
|
9
9
|
export declare const array: (config: FormArrayConfig) => FormArrayConfig;
|
|
10
10
|
export declare const group: (config: FormGroupConfig) => FormGroupConfig;
|
|
@@ -37,6 +37,20 @@ export interface CustomReducers {
|
|
|
37
37
|
}
|
|
38
38
|
export interface RxFormOptions<T extends CustomReducers> extends EffectsAndSources {
|
|
39
39
|
reducers?: T;
|
|
40
|
+
providers?: RxFormProviders;
|
|
41
|
+
}
|
|
42
|
+
type NormalizerFunction<T> = (value: T) => T;
|
|
43
|
+
export interface RxFormProviders {
|
|
44
|
+
normalizers?: {
|
|
45
|
+
[key: string]: NormalizerFunction<unknown>;
|
|
46
|
+
};
|
|
47
|
+
validators?: {
|
|
48
|
+
[key: string]: ValidatorFn;
|
|
49
|
+
};
|
|
50
|
+
asyncValidators?: {
|
|
51
|
+
[key: string]: ValidatorAsyncFn;
|
|
52
|
+
};
|
|
40
53
|
}
|
|
41
54
|
export declare const build: <T extends CustomReducers>(config: AbstractControlConfig, options?: RxFormOptions<T>) => Reactable<Form<unknown>, { [K in keyof T]: (payload?: any) => void; } & RxFormActions>;
|
|
55
|
+
export declare const load: <T extends CustomReducers>(state: Form<unknown>, options?: RxFormOptions<T>) => Reactable<Form<unknown>, { [K in keyof T]: (payload?: any) => void; } & RxFormActions>;
|
|
42
56
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/RxForm/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { build, group, array, control, RxFormActions, FormReducers } from './RxForm';
|
|
1
|
+
export { build, load, group, array, control, RxFormActions, FormReducers, RxFormOptions, RxFormProviders, } from './RxForm';
|