You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix several issues with the flow-libdef
- Remove `CardProps`, `SectionProps`, and `ElementProps`, which were vestigial and not currently being used.
- Remove exactness in object definitions with indexer properties, as they are incompatible.
- Export a props type for `cardBody` and `modalBody` components so that these components can be defined externally.
- Use `React$ComponentType`, as `React$AbstractComponent` was incorrect.
Copy file name to clipboardExpand all lines: docs/Plugins.md
+41-35Lines changed: 41 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,52 +8,50 @@ Custom input types are encoded in exactly the same way the Default input types a
8
8
9
9
## Type Definition
10
10
11
-
Recall that the plugin input types are passed into `mods`, as a property called `customFormInputs`,into the `FormBuilder` (see [Usage](Usage.md)):
11
+
Flow type defintions are available via [flow-typed](https://github.com/flow-typed/flow-typed).
12
+
13
+
Recall that the plugin input types are passed into `mods`, as a property called `customFormInputs`,into the `FormBuilder` (see [Usage](Usage.md)). The type definition is as follows:
12
14
13
15
```react
14
-
export type Mods = {
16
+
declare type Mods = {|
15
17
customFormInputs?: {
16
-
[string]: FormInput
18
+
[string]: FormInput,
19
+
...
17
20
},
18
-
tooltipDescriptions?: {
21
+
tooltipDescriptions?: {|
19
22
add?: string,
20
23
cardObjectName?: string,
21
24
cardDisplayName?: string,
22
25
cardDescription?: string,
23
-
cardInputType?: string
24
-
}
25
-
}
26
+
cardInputType?: string,
27
+
|},
28
+
|};
26
29
```
27
30
28
31
A single `FormInput` has a type definition as follows:
29
32
30
33
```react
31
-
export type FormInput = {
34
+
declare type FormInput = {|
32
35
displayName: string,
33
36
// given a data and ui schema, determine if the object is of this input type
34
37
matchIf: Array<MatchType>,
35
38
// allowed keys for ui:options
36
39
possibleOptions?: Array<string>,
37
40
defaultDataSchema: {
38
-
[string]: any
41
+
[string]: any,
42
+
...
39
43
},
40
44
defaultUiSchema: {
41
-
[string]: any
45
+
[string]: any,
46
+
...
42
47
},
43
48
// the data schema type
44
49
type: DataType,
45
50
// inputs on the preview card
46
-
cardBody: React.AbstractComponent<{
47
-
parameters: Parameters,
48
-
onChange: (newParams: Parameters) => void,
49
-
mods: { [string]: any }
50
-
}>,
51
+
cardBody: React$ComponentType<CardBodyProps>,
51
52
// inputs for the modal
52
-
modalBody?: React.AbstractComponent<{
53
-
parameters: Parameters,
54
-
onChange: (newParams: Parameters) => void
55
-
}>
56
-
}
53
+
modalBody?: React$ComponentType<CardBodyProps>,
54
+
|};
57
55
```
58
56
59
57
The `displayName` is the full name of the desired form input. For example, **Short Answer** is the `displayName` for the `shortAnswer` form input.
@@ -68,15 +66,15 @@ The `displayName` is the full name of the desired form input. For example, **Sho
68
66
69
67
`type` is the Data Schema type that this input type defaults to. While a custom form input can have multiple types (would need to be defined in the `matchIf` array), this refers to the type that gets assigned immediately after a user selects this input type in the dropdown. The possible `DataType` options supported by `react-jsonschema-form` are as follows:
70
68
71
-
```typescript
72
-
typeDataType=
69
+
```react
70
+
declare type DataType =
73
71
| 'string'
74
72
| 'number'
75
73
| 'boolean'
76
74
| 'integer'
77
75
| 'array'
78
76
| '*'
79
-
|null
77
+
| null;
80
78
```
81
79
82
80
`cardBody` refers to a React component that gets rendered in the card itself, when expanded. This React component gets a set of `Parameters` that provide additional information about the FormInput, such as the `title` or the `default` properties. For more information, see the *Parameters* section.
@@ -87,16 +85,15 @@ type DataType =
87
85
88
86
The `matchIf` array in a `FormInput` contains a series of `MatchType` objects, which represent different possible 'scenarios' that the `FormBuilder` may encounter when parsing a set of Data and UI Schema. The `MatchType` is defined as follows:
89
87
90
-
```typescript
91
-
typeMatchType= {
88
+
```react
89
+
declare type MatchType = {|
92
90
types: Array<DataType>,
93
91
widget?: string,
94
92
field?: string,
95
-
option?: { [string]:any },
96
93
format?: string,
97
94
$ref?: boolean,
98
-
enum?:boolean
99
-
}
95
+
enum?: boolean,
96
+
|};
100
97
```
101
98
102
99
`types` refers to the set of possible input types that can register in a particular scenario.
@@ -111,20 +108,29 @@ type MatchType = {
111
108
112
109
`enum` is a boolean that evaluates to true if the component has a property `enum` in the Data Schema.
113
110
114
-
## Parameters
111
+
## Component Types
112
+
113
+
`cardBody` and `modalBody` are components whose props have a type of `CardBodyProps`:
114
+
115
+
```react
116
+
declare export type CardBodyProps = {|
117
+
parameters: Parameters,
118
+
onChange: (newParams: Parameters) => void,
119
+
|};
120
+
```
115
121
116
-
The following is a type definition for the Parameters object:
122
+
`Parameters`is defined as:
117
123
118
124
```react
119
-
exporttypeParameters= {
125
+
declare type Parameters = {|
120
126
[string]: string | number | boolean | Array<string | number>,
121
127
name: string,
122
128
path: string,
123
-
definitionData: { [string]:any },
124
-
definitionUi: { [string]:any },
129
+
definitionData: { [string]: any, ... },
130
+
definitionUi: { [string]: any, ... },
125
131
category: string,
126
-
'ui:option': { [string]:any }
127
-
}
132
+
'ui:option': { [string]: any, ... },
133
+
|};
128
134
```
129
135
130
136
It can hold any number of keys pointing to specific values. One common example is `parameters.default`, which stores the default value specified by the builder for this `FormInput`.
Copy file name to clipboardExpand all lines: flow-libdef/@ginkgo-bioworks/react-json-schema-form-builder_v1.x.x/flow_v0.92.x-/react-json-schema-form-builder_v1.x.x.js
Copy file name to clipboardExpand all lines: flow-libdef/@ginkgo-bioworks/react-json-schema-form-builder_v1.x.x/test_react-json-schema-form-builder_v1.x.x.js
0 commit comments