File tree Expand file tree Collapse file tree 10 files changed +47
-19
lines changed
packages/react-form-renderer/src/files Expand file tree Collapse file tree 10 files changed +47
-19
lines changed Original file line number Diff line number Diff line change
1
+ export interface AnyObject {
2
+ [ key : string ] : any ;
3
+ }
Original file line number Diff line number Diff line change 1
- export interface ExtendedMapperComponent extends Object {
2
- component : string ;
1
+ import { AnyObject } from "./common" ;
2
+
3
+ export interface ExtendedMapperComponent extends AnyObject {
4
+ component : React . ComponentType | React . FunctionComponent | React . ElementType ;
3
5
}
4
6
5
7
interface ComponentMapper {
6
- [ key : string ] : string | ExtendedMapperComponent ;
8
+ [ key : string ] : React . ComponentType | React . FunctionComponent | React . ElementType | ExtendedMapperComponent ;
7
9
}
8
10
9
11
export default ComponentMapper ;
Original file line number Diff line number Diff line change 1
1
import { Validator } from "./validators" ;
2
2
import { ConditionDefinition } from './condition' ;
3
3
import { DataType } from "./data-types" ;
4
+ import { AnyObject } from "./common" ;
4
5
5
6
export type FieldAction = [ string , ...any [ ] ] ;
6
7
7
- interface Field extends Object {
8
+ interface Field extends AnyObject {
8
9
name : string ;
9
10
component : string ;
10
11
validate ?: Validator [ ] ;
Original file line number Diff line number Diff line change 1
- import { ComponentType } from 'react' ;
1
+ import { ComponentType , FunctionComponent } from 'react' ;
2
2
import { FormApi } from 'final-form' ;
3
3
import Schema from './schema' ;
4
4
import ComponentMapper from './component-mapper' ;
5
5
import ValidatorMapper from './validator-mapper' ;
6
6
import ActionMapper from './action-mapper' ;
7
7
import SchemaValidatorMapper from './schema-validator-mapper' ;
8
+ import { FormTemplateRenderProps } from '../../dist/cjs' ;
8
9
9
10
export interface FormSubscription {
10
11
[ key : string ] : boolean ;
@@ -20,7 +21,7 @@ export interface FormRendererProps {
20
21
subscription ?: FormSubscription ;
21
22
clearedValue ?: any ;
22
23
componentMapper : ComponentMapper ;
23
- FormTemplate : ComponentType ;
24
+ FormTemplate : ComponentType < FormTemplateRenderProps > | FunctionComponent < FormTemplateRenderProps > ;
24
25
validatorMapper ?: ValidatorMapper ;
25
26
actionMapper ?: ActionMapper ;
26
27
schemaValidatorMapper ?: SchemaValidatorMapper ;
Original file line number Diff line number Diff line change
1
+ import { ComponentType } from 'react' ;
1
2
import { FormSpyProps } from 'react-final-form' ;
2
3
3
- export default FormSpyProps ;
4
+ declare const FormSpy : ComponentType < FormSpyProps > ;
5
+
6
+ export default FormSpy ;
Original file line number Diff line number Diff line change
1
+ import { ComponentType , ElementType } from "react" ;
2
+ import Schema from "./schema" ;
3
+
4
+ export interface FormTemplateRenderProps {
5
+ formFields : ElementType [ ] ;
6
+ schema : Schema ;
7
+ }
8
+
9
+ export default FormTemplateRenderProps ;
Original file line number Diff line number Diff line change 1
1
import { ReactNode } from 'react' ;
2
2
import { FormApi } from 'final-form' ;
3
+ import { FormRenderProps } from 'react-final-form' ;
3
4
import ComponentMapper from './component-mapper' ;
4
5
import ValidatorMapper from './validator-mapper' ;
5
6
import ActionMapper from './action-mapper' ;
6
7
import Field from './field' ;
8
+ import { AnyObject } from './common' ;
7
9
8
10
export interface FormOptions extends FormApi {
9
11
registerInputFile ?: ( name : string ) => void ;
10
12
unRegisterInputFile ?: ( name : string ) => void ;
11
13
onCancel ?: ( values : object , ...args : any [ ] ) => void ;
12
14
onReset ?: ( ) => void ;
15
+ handleSubmit : ( ) => Promise < AnyObject | undefined > | undefined ;
13
16
clearedValue ?: any ;
14
17
renderForm : ( fields : Field [ ] ) => ReactNode [ ] ;
15
18
}
Original file line number Diff line number Diff line change 1
1
import { ReactNode } from 'react' ;
2
- import { FieldInputProps , FieldMetaState } from 'react-final-form' ;
2
+ import { FieldMetaState , FieldInputProps } from 'react-final-form' ;
3
+ import { AnyObject } from './common' ;
3
4
4
5
export interface ValidatorType extends Object {
5
6
type : string ;
6
7
message ?: ReactNode ;
7
8
}
8
9
9
- export interface UseFieldApiConfig extends Object {
10
+ export interface UseFieldApiConfig extends AnyObject {
10
11
name : string ;
11
12
component : string ;
12
13
validate ?: ValidatorType [ ] ;
13
14
}
14
15
15
- export interface UseFieldApiProps extends Object {
16
- input : FieldInputProps < any > ;
17
- meta : FieldMetaState < any > ;
16
+ export interface UseFieldApiProps <
17
+ FieldValue ,
18
+ T extends HTMLElement = HTMLElement > extends AnyObject {
19
+ input : FieldInputProps < FieldValue , T > ;
20
+ meta : FieldMetaState < FieldValue > ;
18
21
}
19
22
20
- export default function ( options : UseFieldApiConfig ) : UseFieldApiProps ;
23
+ export default function ( options : UseFieldApiConfig ) : UseFieldApiProps < string > ;
Original file line number Diff line number Diff line change 1
- import { RendererContextValue } from './renderer-context' ;
1
+ import { FormOptions } from './renderer-context' ;
2
2
3
- export default function ( ) : RendererContextValue ;
3
+ export default function ( ) : FormOptions ;
Original file line number Diff line number Diff line change 1
1
import { ReactNode } from 'react' ;
2
+ import { AnyObject } from './common' ;
2
3
3
4
export type DataTypeValidators = "string" | "integer" | "boolean" | "number" | "float" ;
4
5
5
6
export type ValidatorFunction = ( value : any , allValues ?: object ) => Promise < any > | ReactNode | undefined ;
6
7
7
- export interface Validator extends Object {
8
+ export interface ValidatorConfiguration extends AnyObject {
9
+ type : string ;
8
10
message ?: string ;
9
11
msg ?: string ;
10
12
}
11
13
12
- export interface LenghtOptions extends Validator {
14
+ export type Validator = ValidatorConfiguration | ValidatorFunction ;
15
+ export interface LenghtOptions extends ValidatorConfiguration {
13
16
'=' ?: string ;
14
17
is ?: number ;
15
18
max ?: number ;
@@ -18,12 +21,12 @@ export interface LenghtOptions extends Validator {
18
21
minimum ?: number ;
19
22
}
20
23
21
- export interface PatternOptions extends Validator {
24
+ export interface PatternOptions extends ValidatorConfiguration {
22
25
pattern ?: string | RegExp ;
23
26
flags ?: string ;
24
27
}
25
28
26
- export interface NumericalityOptions extends Validator {
29
+ export interface NumericalityOptions extends ValidatorConfiguration {
27
30
even ?: boolean ;
28
31
odd ?: boolean ;
29
32
equalTo ?: number ;
You can’t perform that action at this time.
0 commit comments