Skip to content

Commit 91e57db

Browse files
committed
Fix flow errors due to flow-bin upgrade
- Fix flow errors - Allow null type in custom form input matchIf
1 parent c3617bc commit 91e57db

33 files changed

+243
-158
lines changed

docs/Mods.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ declare type DataType =
9292
| 'boolean'
9393
| 'integer'
9494
| 'array'
95-
| '*'
96-
| null;
95+
| 'object'
96+
| 'null';
9797
```
9898

9999
`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.
@@ -152,7 +152,7 @@ declare export type CardBodyProps = {|
152152

153153
```react
154154
declare type Parameters = {|
155-
[string]: string | number | boolean | Array<string | number>,
155+
[string]: any,
156156
name: string,
157157
path: string,
158158
definitionData: { [string]: any, ... },

example/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flow-libdef/@ginkgo-bioworks/react-json-schema-form-builder_v2.x.x/flow_v0.92.x-/react-json-schema-form-builder_v2.x.x.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare module '@ginkgo-bioworks/react-json-schema-form-builder' {
22
declare type Parameters = {|
3-
[string]: string | number | boolean | Array<string | number>,
3+
[string]: any,
44
name: string,
55
path: string,
66
definitionData: { [string]: any, ... },
@@ -21,6 +21,7 @@ declare module '@ginkgo-bioworks/react-json-schema-form-builder' {
2121
| 'integer'
2222
| 'array'
2323
| 'object'
24+
| 'null';
2425

2526
declare type MatchType = {|
2627
types: Array<DataType>,

flow-libdef/@ginkgo-bioworks/react-json-schema-form-builder_v2.x.x/test_react-json-schema-form-builder_v2.x.x.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,23 @@ describe('@ginkgo-bioworks/react-json-schema-form-builder', () => {
5959
field: 'customFormInput1',
6060
}],
6161
},
62+
customFormInput2: {
63+
displayName: 'custom form input 2',
64+
defaultDataSchema: {
65+
'type': 'string',
66+
},
67+
defaultUiSchema: {
68+
'ui:field': 'customFormInput2',
69+
},
70+
type: 'string',
71+
cardBody: (props: CardBodyProps) => <div/>,
72+
modalBody: (props: CardBodyProps) => <div/>,
73+
matchIf: [{
74+
types: ['null'],
75+
field: 'customFormInput2',
76+
}],
77+
},
78+
6279
},
6380
tooltipDescriptions: {
6481
add: 'add text',

src/formBuilder/Add.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { faPlusSquare } from '@fortawesome/free-solid-svg-icons';
1313
import FontAwesomeIcon from './FontAwesomeIcon';
1414
import FBRadioGroup from './radio/FBRadioGroup';
1515
import { getRandomId } from './utils';
16+
import type { Node } from 'react';
1617

1718
const useStyles = createUseStyles({
1819
addDetails: {
@@ -39,7 +40,7 @@ export default function Add({
3940
}: {
4041
addElem: (choice: string) => void,
4142
hidden?: boolean,
42-
}) {
43+
}): Node {
4344
const classes = useStyles();
4445
const [popoverOpen, setPopoverOpen] = useState(false);
4546
const [createChoice, setCreateChoice] = useState('card');

src/formBuilder/Card.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Add from './Add';
1717
import FontAwesomeIcon from './FontAwesomeIcon';
1818
import Tooltip from './Tooltip';
1919
import { getRandomId } from './utils';
20+
import type { Node } from 'react';
2021
import type { Parameters, Mods, FormInput } from './types';
2122

2223
const useStyles = createUseStyles({
@@ -127,7 +128,7 @@ export default function Card({
127128
mods?: Mods,
128129
allFormInputs: { [string]: FormInput },
129130
showObjectNameInput?: boolean,
130-
}) {
131+
}): Node {
131132
const classes = useStyles();
132133
const [modalOpen, setModalOpen] = React.useState(false);
133134
const [elementId] = React.useState(getRandomId());

src/formBuilder/CardEnumOptions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Input } from 'reactstrap';
55
import { createUseStyles } from 'react-jss';
66
import { faPlus, faTimes } from '@fortawesome/free-solid-svg-icons';
77
import FontAwesomeIcon from './FontAwesomeIcon';
8+
import type { Node } from 'react';
89

910
const useStyles = createUseStyles({
1011
cardEnumOption: {
@@ -34,7 +35,7 @@ export default function CardEnumOptions({
3435
showNames: boolean,
3536
onChange: (newEnums: Array<any>, newEnumNames?: Array<string>) => void,
3637
type: string,
37-
}) {
38+
}): Node {
3839
const classes = useStyles();
3940

4041
const possibleValues = [];

src/formBuilder/CardGallery.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Card from './Card';
1111
import Section from './Section';
1212
import Add from './Add';
1313
import DEFAULT_FORM_INPUTS from './defaults/defaultFormInputs';
14+
import type { Node } from 'react';
1415
import type { Mods } from './types';
1516

1617
export default function CardGallery({
@@ -25,18 +26,19 @@ export default function CardGallery({
2526
onChange: ({ [string]: any }, { [string]: any }) => void,
2627
mods?: Mods,
2728
categoryHash: { [string]: string },
28-
}) {
29+
}): Node {
2930
const elementNum = countElementsFromSchema({
3031
properties: definitionSchema,
3132
});
3233
const defaultCollapseStates = [...Array(elementNum)].map(() => false);
3334
const [cardOpenArray, setCardOpenArray] = React.useState(
3435
defaultCollapseStates,
3536
);
36-
const allFormInputs = {
37-
...DEFAULT_FORM_INPUTS,
38-
...(mods && mods.customFormInputs),
39-
};
37+
const allFormInputs = Object.assign(
38+
{},
39+
DEFAULT_FORM_INPUTS,
40+
(mods && mods.customFormInputs) || {},
41+
);
4042
const componentArr = generateElementComponentsFromSchemas({
4143
schemaData: { properties: definitionSchema },
4244
uiSchemaData: definitionUiSchema,

src/formBuilder/CardGeneralParameterInputs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
subtractArray,
1414
getRandomId,
1515
} from './utils';
16+
import type { Node } from 'react';
1617
import type { Parameters, Mods, FormInput } from './types';
1718
import Tooltip from './Tooltip';
1819

@@ -29,7 +30,7 @@ export default function CardGeneralParameterInputs({
2930
mods?: Mods,
3031
allFormInputs: { [string]: FormInput },
3132
showObjectNameInput?: boolean,
32-
}) {
33+
}): Node {
3334
const [keyState, setKeyState] = React.useState(parameters.name);
3435
const [titleState, setTitleState] = React.useState(parameters.title);
3536
const [descriptionState, setDescriptionState] = React.useState(

src/formBuilder/CardModal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from 'react';
44
import { Modal, ModalHeader, Button, ModalBody, ModalFooter } from 'reactstrap';
55
import { createUseStyles } from 'react-jss';
66
import DependencyField from './dependencies/DependencyField';
7+
import type { Node } from 'react';
78
import type { Parameters } from './types';
89

910
const useStyles = createUseStyles({
@@ -46,7 +47,7 @@ export default function CardModal({
4647
parameters: Parameters,
4748
onChange: (newParams: Parameters) => void,
4849
}>,
49-
}) {
50+
}): Node {
5051
const classes = useStyles();
5152
// assign state values for parameters that should only change on hitting "Save"
5253
const [componentPropsState, setComponentProps] =

0 commit comments

Comments
 (0)