-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.d.ts
105 lines (82 loc) · 3 KB
/
index.d.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import * as React from 'react'
type IsRequiredOption = {
required?: boolean,
}
type BaseSchemaType<TOptions> = ((x: unknown) => boolean)
& { _isSchemaType: true, _type: string, } & TOptions
type SchemaTypeFactory<TOptions> = (options?: TOptions) => BaseSchemaType<TOptions>
type StringSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type StringSchemaType = BaseSchemaType<IsRequiredOption>
type BooleanSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type BooleanSchemaType = BaseSchemaType<IsRequiredOption>
type NumberSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type NumberSchemaType = BaseSchemaType<IsRequiredOption>
type FunctionSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type FunctionSchemaType = BaseSchemaType<IsRequiredOption>
type DateSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type DateSchemaType = BaseSchemaType<IsRequiredOption>
type ArraySchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type ArraySchemaType = BaseSchemaType<IsRequiredOption>
type AnyObjectSchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type AnyObjectSchemaType = BaseSchemaType<IsRequiredOption>
type ArrayOfSchemaTypeFactory = (type: SchemaType) => SchemaTypeFactory<IsRequiredOption>
type ArrayOfSchemaType = BaseSchemaType<IsRequiredOption>
type AnySchemaTypeFactory = SchemaTypeFactory<IsRequiredOption>
type AnySchemaType = BaseSchemaType<IsRequiredOption>
interface ObjectSchemaType {
[key: string]: SchemaType,
}
type SchemaType =
StringSchemaType
| BooleanSchemaType
| NumberSchemaType
| FunctionSchemaType
| DateSchemaType
| ArraySchemaType
| AnyObjectSchemaType
| ArrayOfSchemaType
| AnySchemaType
| ObjectSchemaType
export const SchemaTypes: {
any: AnySchemaTypeFactory,
string: StringSchemaTypeFactory,
boolean: BooleanSchemaTypeFactory,
function: FunctionSchemaTypeFactory,
number: NumberSchemaTypeFactory,
date: DateSchemaTypeFactory,
array: ArraySchemaTypeFactory,
object: AnyObjectSchemaTypeFactory,
arrayOf: ArrayOfSchemaTypeFactory,
}
export const matchesSchema: (schema: SchemaType, test: unknown) => boolean
type BaseEditorProps = {
type: SchemaType,
className?: string,
}
type EditablePrimitive = number | string | boolean
interface EditableObject {
[key: string]: Editable,
}
interface EditableArray {
[key: number]: Editable,
}
type Editable = EditablePrimitive | EditableObject | EditableArray
export class ObjectEditor<TObject extends Editable> extends React.Component<BaseEditorProps & {
object?: TObject,
onUpdateElement: (object: TObject) => void,
parentVisible?: boolean,
}> {
}
export class ArrayEditor<TObject extends Editable> extends React.Component<BaseEditorProps & {
object?: Array<TObject>,
onUpdateElement: (object: TObject, index: number) => void,
onRemoveElements: (indices: Array<Number>) => void,
onAddElement: (object: TObject) => void,
parentVisible?: boolean,
defaultRowsPerPage?: number,
}> {
}
export const PropTypes: {
SchemaType: unknown, // TODO
Schema: unknown, // TODO
}