UNPKG

@breakaway/react-core

Version:

This library provides a set of common React components for use with the PatternFly reference implementation.

23 lines 1.32 kB
import { __rest } from "tslib"; import * as React from 'react'; import styles from '@breakaway/react-styles/css/components/InputGroup/input-group'; import { css } from '@breakaway/react-styles'; import { FormSelect } from '../FormSelect'; import { TextArea } from '../TextArea'; import { TextInput } from '../TextInput'; export const InputGroup = (_a) => { var { className = '', children, innerRef } = _a, props = __rest(_a, ["className", "children", "innerRef"]); const formCtrls = [FormSelect, TextArea, TextInput].map(comp => comp.displayName); const idItem = React.Children.toArray(children).find((child) => !formCtrls.includes(child.type.displayName) && child.props.id); const ref = React.useRef(null); const inputGroupRef = innerRef || ref; return (React.createElement("div", Object.assign({ ref: inputGroupRef, className: css(styles.inputGroup, className) }, props), idItem ? React.Children.map(children, (child) => !formCtrls.includes(child.type.displayName) || child.props['aria-describedby'] ? child : React.cloneElement(child, { 'aria-describedby': child.props['aria-describedby'] === '' ? undefined : idItem.props.id })) : children)); }; InputGroup.displayName = 'InputGroup'; //# sourceMappingURL=InputGroup.js.map