Debian Codegraph @

node/@patternfly/react-core/src/components/Form/FormFieldGroupToggle.tsx

raw
1 import styles from '@patternfly/react-styles/css/components/Form/form';
2 import { css } from '@patternfly/react-styles';
3 import RhMicronsCaretDownIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-down-icon';
4 import { Button } from '../Button';
5
6 export interface FormFieldGroupToggleProps extends React.HTMLProps<HTMLDivElement> {
7 /** Additional classes added to the section */
8 className?: string;
9 /** Callback for onClick */
10 onToggle: () => void;
11 /** Flag indicating if the toggle is expanded */
12 isExpanded: boolean;
13 /** Aria label of the toggle button */
14 'aria-label'?: string;
15 /** Sets the aria-labelledby attribute on the toggle button element */
16 'aria-labelledby'?: string;
17 /** The id applied to the toggle button */
18 toggleId?: string;
19 }
20
21 export const FormFieldGroupToggle: React.FunctionComponent<FormFieldGroupToggleProps> = ({
22 className,
23 onToggle,
24 isExpanded,
25 'aria-label': ariaLabel,
26 'aria-labelledby': ariaLabelledby,
27 toggleId,
28 ...props
29 }: FormFieldGroupToggleProps) => (
30 <div className={css(styles.formFieldGroupToggle, className)} {...props}>
31 <div className={css(styles.formFieldGroupToggleButton)}>
32 <Button
33 variant="plain"
34 aria-label={ariaLabel}
35 onClick={onToggle}
36 aria-expanded={isExpanded}
37 aria-labelledby={ariaLabelledby}
38 id={toggleId}
39 icon={
40 <span className={css(styles.formFieldGroupToggleIcon)}>
41 <RhMicronsCaretDownIcon />
42 </span>
43 }
44 />
45 </div>
46 </div>
47 );
48 FormFieldGroupToggle.displayName = 'FormFieldGroupToggle';