Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit d2d4628

Browse files
committed
feat(FormInputGroup): add inputProps prop
A new prop that adds shorthand creation of child Form.Input
1 parent 5582f88 commit d2d4628

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/components/Form/FormInputGroup.react.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,31 @@
22

33
import * as React from "react";
44
import cn from "classnames";
5+
import Form from "./Form.react";
56
import FormInputGroupAppend from "./FormInputGroupAppend.react";
67
import FormInputGroupPrepend from "./FormInputGroupPrepend.react";
8+
import type { Props as InputProps } from "./FormInput.react";
79

810
type Props = {|
911
+children?: React.Node,
1012
+className?: string,
11-
+input?: React.Node,
1213
+append?: React.Node,
1314
+prepend?: React.Node,
1415
+RootComponent?: React.ElementType,
16+
+inputProps?: InputProps,
1517
|};
1618

17-
function FormInputGroup({
18-
className,
19-
children,
20-
append,
21-
prepend,
22-
RootComponent,
23-
}: Props): React.Node {
19+
function FormInputGroup(props: Props): React.Node {
20+
const { className, append, prepend, RootComponent, inputProps } = props;
2421
const classes = cn(
2522
{
2623
"input-group": true,
2724
},
2825
className
2926
);
3027
const Component = RootComponent || "div";
28+
const children = inputProps ? <Form.Input {...inputProps} /> : props.children;
29+
3130
return (
3231
<Component className={classes}>
3332
{prepend && <FormInputGroupPrepend>{prepend}</FormInputGroupPrepend>}

0 commit comments

Comments
 (0)