Debian Codegraph @

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

raw
1 import styles from '@patternfly/react-styles/css/components/HelperText/helper-text';
2 import { css } from '@patternfly/react-styles';
3
4 export interface HelperTextProps extends React.HTMLProps<HTMLDivElement | HTMLUListElement> {
5 /** Content rendered inside the helper text container. */
6 children?: React.ReactNode;
7 /** Additional classes applied to the helper text container. */
8 className?: string;
9 /** Component type of the helper text container */
10 component?: 'div' | 'ul';
11 /** ID for the helper text container. The value of this prop can be passed into a form component's
12 * aria-describedby prop when you intend for all helper text items to be announced to
13 * assistive technologies.
14 */
15 id?: string;
16 /** Flag for indicating whether the helper text container is a live region. Use this prop when you
17 * expect or intend for any helper text items within the container to be dynamically updated.
18 */
19 isLiveRegion?: boolean;
20 /** Adds an accessible label to the helper text when component is a "ul". */
21 'aria-label'?: string;
22 }
23
24 export const HelperText: React.FunctionComponent<HelperTextProps> = ({
25 children,
26 className,
27 component = 'div',
28 id,
29 isLiveRegion = false,
30 'aria-label': ariaLabel,
31 ...props
32 }: HelperTextProps) => {
33 const Component = component as any;
34 return (
35 <Component
36 id={id}
37 className={css(styles.helperText, className)}
38 {...(isLiveRegion && { 'aria-live': 'polite' })}
39 {...(component === 'ul' && { role: 'list', 'aria-label': ariaLabel })}
40 {...props}
41 >
42 {children}
43 </Component>
44 );
45 };
46 HelperText.displayName = 'HelperText';