-
Notifications
You must be signed in to change notification settings - Fork 6
/
schema-form-interfaces.ts
55 lines (49 loc) · 1.57 KB
/
schema-form-interfaces.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Ajv from 'ajv';
import { ErrorObject } from '../error';
import _ from 'lodash';
import { ActionType } from './schema-form-value-context';
import { SchemaContext } from '../schema/schemaContext';
export interface ISchemaContainerProps {
schema: object,
path: string[],
value: object,
isRequired?: boolean,
errors: ErrorObject | Ajv.ErrorObject[],
onFocus(path: string[]): void,
onBlur(path: string[]): void,
onEditor?(data: object, path: string[]): any,
context: ISchemaFormContext
}
// export function containerPropsEqual(props0: ISchemaContainerProps, props1: ISchemaContainerProps): boolean {
// return _.isEqual(props0.value, props1.value)
// && props0.path === props1.path
// && props0.schema === props1.schema
// && props0.errors === props1.errors
// && props0.context === props1.context;
// }
export interface ISchemaComponentProps {
schema: object,
path: string[],
value: any,
isRequired?: boolean,
errors: Ajv.ErrorObject[]
onFocus(path: string[]): void,
onBlur(path: string[]): void,
onEditor?(data: object, path: string[]): any,
caption: string,
context?: object
}
export interface IComponentMap {
[fieldType: string]: React.FC<ISchemaComponentProps>
}
export interface IContainerMap {
[containerType: string]: React.FC<ISchemaContainerProps>
}
export interface ISchemaFormContext {
components: IComponentMap,
containers: IContainerMap,
collapsible?: boolean,
componentContext?: object,
schemaContext: SchemaContext,
outerPropsChange: boolean
}