@reactables/forms 2.0.0-beta.9 → 2.0.1

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.
@@ -1,9 +1,11 @@
1
- import { Action, Effect } from '@reactables/core';
1
+ import { Effect } from '@reactables/core';
2
2
  import { BaseControl } from '../Models/Controls';
3
- import { ControlAsyncValidationResponse } from '../Models/Payloads';
4
3
  import { RxFormProviders } from '../RxForm/RxForm';
5
- import { ControlRef } from '../Models';
6
- type ControlScopedEffect<T> = Effect<BaseControl<T>, ControlAsyncValidationResponse | ControlRef>;
4
+ type ControlScopedEffect<T> = Effect;
7
5
  export declare const getScopedEffectsForControl: <T>(formControl: BaseControl<T>, providers: RxFormProviders) => ControlScopedEffect<T>[];
8
- export declare const getAsyncValidationEffects: (formControls: BaseControl<unknown>[]) => Action<BaseControl<unknown>>[];
6
+ export declare const getAsyncValidationEffects: (formControls: BaseControl<unknown>[]) => {
7
+ type: string;
8
+ scopedEffects?: import("@reactables/core").ScopedEffects;
9
+ payload: BaseControl<unknown>;
10
+ }[];
9
11
  export {};
@@ -2,5 +2,5 @@ import { AbstractControlConfig } from '../Models/Configs';
2
2
  import { BaseForm, BaseFormState } from '../Models/Controls';
3
3
  import { ControlRef } from '../Models/ControlRef';
4
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>;
5
+ export declare const buildState: <T>(config: AbstractControlConfig, controlRef: ControlRef | undefined, providers: RxFormProviders, form?: BaseForm<T>) => BaseForm<T>;
6
+ export declare const buildFormState: <T>(config: AbstractControlConfig, controlRef: ControlRef | undefined, providers: RxFormProviders, form?: BaseForm<T>) => BaseFormState<T>;
@@ -1,4 +1,4 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { Action } from '@reactables/core';
3
3
  import { BaseFormState } from '../Models/Controls';
4
- export declare const buildHub2Source: <T>(hub1State$: Observable<BaseFormState<T>>, initialBaseState: BaseFormState<T>) => Observable<Action<T>>;
4
+ export declare const buildHub2Source: (hub1State$: Observable<BaseFormState<any>>, initialBaseState: BaseFormState<any>) => Observable<Action<any>>;
@@ -19,9 +19,9 @@ interface AsyncFields {
19
19
  pending?: boolean;
20
20
  }
21
21
  interface ValidatedFields {
22
- valid: boolean;
22
+ valid: boolean | null;
23
23
  errors: FormErrors;
24
- childrenValid: boolean;
24
+ childrenValid: boolean | null;
25
25
  }
26
26
  export interface Hub2Fields extends AsyncFields, ValidatedFields {
27
27
  }
@@ -36,13 +36,15 @@ export interface BaseFormState<T> {
36
36
  [key: string]: BaseControl<unknown>;
37
37
  };
38
38
  }
39
- export interface BaseForm<T> {
40
- root?: BaseControl<T>;
39
+ export type BaseForm<T> = {
40
+ root: BaseControl<T>;
41
41
  [key: string]: BaseControl<unknown>;
42
- }
43
- export interface Form<T> {
44
- root?: FormControl<T>;
42
+ };
43
+ export type Form<T> = {
44
+ root: FormControl<T>;
45
+ } & {
45
46
  [key: string]: FormControl<unknown>;
46
- }
47
+ };
47
48
  export declare const DEFAULT_HUB2_FIELDS: Hub2Fields;
49
+ export declare const cloneHub2Fields: () => Hub2Fields;
48
50
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { BaseControl } from './Controls';
3
3
  import { FormErrors } from './FormErrors';
4
- export type ValidatorFn = (value: unknown) => FormErrors;
4
+ export type ValidatorFn = (value: any) => FormErrors;
5
5
  export type ValidatorAsyncFn = <T>(control$: Observable<BaseControl<T>>) => Observable<Observable<FormErrors>>;
@@ -1,4 +1,4 @@
1
1
  import { Action } from '@reactables/core';
2
2
  import { Form } from '../../Models/Controls';
3
3
  import { ControlRef } from '../../Models';
4
- export declare const asyncValidation: <T>(form: Form<T>, { payload: controlRef }: Action<ControlRef>) => Form<T>;
4
+ export declare const asyncValidation: (form: Form<any> | null, { payload: controlRef }: Action<ControlRef>) => Form<any>;
@@ -1,4 +1,4 @@
1
1
  import { Action } from '@reactables/core';
2
2
  import { Form } from '../../Models/Controls';
3
3
  import { ControlAsyncValidationResponse } from '../../Models/Payloads';
4
- export declare const asyncValidationResponse: <T>(form: Form<T>, { payload: { key, validatorIndex, errors } }: Action<ControlAsyncValidationResponse>) => Form<T>;
4
+ export declare const asyncValidationResponse: (form: Form<any> | null, { payload: { key, validatorIndex, errors } }: Action<ControlAsyncValidationResponse>) => Form<any>;
@@ -1,3 +1,3 @@
1
- import { Reducer } from '@reactables/core';
2
- import { Form } from '../../Models/Controls';
3
- export declare const formChange: Reducer<Form<unknown>>;
1
+ import { Action } from '@reactables/core';
2
+ import { BaseFormState, Form } from '../../Models/Controls';
3
+ export declare const formChange: (state: (Form<any> | null) | undefined, { payload }: Action<BaseFormState<any>>) => Form<any>;
@@ -1,5 +1,5 @@
1
1
  import { Form, FormControl, BaseFormState } from '../../Models/Controls';
2
2
  export declare const mergeControls: <T>(state: Form<T>, { form, _changedControls, _removedControls }: BaseFormState<unknown>) => {
3
3
  [x: string]: FormControl<unknown>;
4
- root?: FormControl<unknown>;
4
+ root: FormControl<unknown>;
5
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<unknown>;
5
+ root: FormControl<unknown>;
6
6
  };
@@ -29,27 +29,27 @@ export interface FormReducers {
29
29
  markControlAsUntouched: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
30
30
  resetControl: <T>(state: BaseFormState<T>, payload: ControlRef) => BaseFormState<T>;
31
31
  }
32
- export type CustomReducerFunc<FormValue = unknown, Payload = unknown> = (reducers: FormReducers, state: BaseFormState<FormValue>, action: Action<Payload>) => BaseFormState<unknown>;
33
- export type CustomReducer<FormValue = unknown, Payload = unknown> = CustomReducerFunc<FormValue, Payload> | {
34
- reducer: CustomReducerFunc<FormValue, Payload>;
35
- effects?: Effect<unknown, unknown>[] | ((payload?: unknown) => ScopedEffects<unknown>);
32
+ export type CustomReducerFunc<FormValue = unknown> = (reducers: FormReducers, state: BaseFormState<FormValue>, action: any) => BaseFormState<unknown>;
33
+ export type CustomReducer<FormValue = unknown> = CustomReducerFunc<FormValue> | {
34
+ reducer: CustomReducerFunc<FormValue>;
35
+ effects?: Effect[] | ((payload?: unknown) => ScopedEffects);
36
36
  };
37
- export type ActionCreatorTypeFromCustomReducer<T> = T extends (reducers: FormReducers, state: BaseFormState<unknown>) => BaseFormState<unknown> ? () => void : T extends CustomReducerFunc<unknown, infer P> ? (payload: P) => void : T extends {
38
- reducer: (reducers: FormReducers, state: BaseFormState<unknown>) => BaseFormState<unknown>;
37
+ export type ActionCreatorTypeFromCustomReducer<T> = T extends (formReducers: FormReducers, state: any) => unknown ? () => void : T extends (formReducers: FormReducers, state: any, action: Action<infer P>) => unknown ? (payload: P) => void : T extends {
38
+ reducer: (formReducers: FormReducers, state: any) => unknown;
39
39
  } ? () => void : T extends {
40
- reducer: CustomReducerFunc<unknown, infer P>;
40
+ reducer: (formReducers: FormReducers, state: any, action: Action<infer P>) => unknown;
41
41
  } ? (payload: P) => void : never;
42
- export interface RxFormOptions<T extends Record<string, CustomReducer> = Record<string, CustomReducer>> {
42
+ export interface RxFormOptions<T extends Record<string, CustomReducer<any>> = Record<string, CustomReducer<any>>> {
43
43
  reducers?: T;
44
44
  providers?: RxFormProviders;
45
45
  name?: string;
46
46
  debug?: boolean;
47
- sources?: Observable<Action<unknown>>[];
47
+ sources?: Observable<Action<any>>[];
48
48
  }
49
49
  type NormalizerFunction<T> = (value: T) => T;
50
50
  export interface RxFormProviders {
51
51
  normalizers?: {
52
- [key: string]: NormalizerFunction<unknown>;
52
+ [key: string]: NormalizerFunction<any>;
53
53
  };
54
54
  validators?: {
55
55
  [key: string]: ValidatorFn;
@@ -58,7 +58,7 @@ export interface RxFormProviders {
58
58
  [key: string]: ValidatorAsyncFn;
59
59
  };
60
60
  }
61
- export declare const build: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue, unknown>> = Record<string, CustomReducer<FormValue, unknown>>>(config: AbstractControlConfig, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
61
+ export declare const build: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue>> = Record<string, CustomReducer<FormValue>>>(config: AbstractControlConfig, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
62
62
  updateValues: <T>(payload: UpdateValuesPayload<T>) => void;
63
63
  addControl: (payload: AddControlPayload) => void;
64
64
  pushControl: (payload: PushControlPayload) => void;
@@ -68,9 +68,9 @@ export declare const build: <FormValue, CustomReducers extends Record<string, Cu
68
68
  markControlAsUntouched: (payload: ControlRef) => void;
69
69
  resetControl: (payload: ControlRef) => void;
70
70
  } & ActionMap & DestroyAction, CustomReducerActionTypes<CustomReducers> & FormActionTypes & {
71
- destroy: 'destroy';
71
+ destroy: "destroy";
72
72
  }>;
73
- export declare const load: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue, unknown>> = Record<string, CustomReducer<FormValue, unknown>>>(state: Form<FormValue>, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
73
+ export declare const load: <FormValue, CustomReducers extends Record<string, CustomReducer<FormValue>> = Record<string, CustomReducer<FormValue>>>(state: Form<FormValue>, options?: RxFormOptions<CustomReducers>) => Reactable<Form<FormValue>, { [K in keyof CustomReducers]: ActionCreatorTypeFromCustomReducer<CustomReducers[K]>; } & {
74
74
  updateValues: <T>(payload: UpdateValuesPayload<T>) => void;
75
75
  addControl: (payload: AddControlPayload) => void;
76
76
  pushControl: (payload: PushControlPayload) => void;
@@ -80,7 +80,7 @@ export declare const load: <FormValue, CustomReducers extends Record<string, Cus
80
80
  markControlAsUntouched: (payload: ControlRef) => void;
81
81
  resetControl: (payload: ControlRef) => void;
82
82
  } & ActionMap & DestroyAction, CustomReducerActionTypes<CustomReducers> & FormActionTypes & {
83
- destroy: 'destroy';
83
+ destroy: "destroy";
84
84
  }>;
85
85
  type CustomReducerActionTypes<T extends Record<string, CustomReducer>> = {
86
86
  [K in keyof T as `${K & string}`]: `${K & string}`;
@@ -44,7 +44,7 @@ export declare const initialState: {
44
44
  email: string;
45
45
  };
46
46
  };
47
- controlRef: any[];
47
+ controlRef: never[];
48
48
  validatorErrors: {
49
49
  firstNameNotSameAsLast: boolean;
50
50
  };