Debian Codegraph @

node/@patternfly/react-core/src/components/InputGroup/InputGroup.tsx

raw
1 import { forwardRef, useRef } from 'react';
2 import styles from '@patternfly/react-styles/css/components/InputGroup/input-group';
3 import { css } from '@patternfly/react-styles';
4
5 export interface InputGroupProps extends React.HTMLProps<HTMLDivElement> {
6 /** Additional classes added to the input group. */
7 className?: string;
8 /** Content rendered inside the input group. */
9 children: React.ReactNode;
10 /** @hide A reference object to attach to the input box */
11 innerRef?: React.Ref<any>;
12 }
13
14 export const InputGroupBase: React.FunctionComponent<InputGroupProps> = ({
15 className,
16 children,
17 innerRef,
18 ...props
19 }: InputGroupProps) => {
20 const ref = useRef(null);
21 const inputGroupRef = innerRef || ref;
22
23 return (
24 <div ref={inputGroupRef} className={css(styles.inputGroup, className)} {...props}>
25 {children}
26 </div>
27 );
28 };
29 InputGroupBase.displayName = 'InputGroupBase';
30
31 export const InputGroup = forwardRef((props: InputGroupProps, ref: React.Ref<HTMLDivElement>) => (
32 <InputGroupBase innerRef={ref} {...props} />
33 ));
34 InputGroup.displayName = 'InputGroup';