@wordpress/components
Version:
UI components for WordPress.
46 lines (42 loc) • 966 B
JavaScript
import { cx as _cx } from "emotion";
/**
* Internal dependencies
*/
import { useContextSystem } from '../context';
import * as styles from './form-group-styles';
import { useInstanceId } from '../utils';
/**
* @param {import('../context').ViewOwnProps<import('./types').FormGroupProps, 'div'>} props
*/
export function useFormGroup(props) {
const {
alignLabel = 'left',
children,
className,
help,
horizontal = false,
id: idProp,
label,
labelHidden = false,
truncate = false,
...otherProps
} = useContextSystem(props, 'FormGroup');
const id = useInstanceId(useFormGroup, 'form-group', idProp);
const classes = _cx(styles.FormGroup, className);
const contentProps = {
alignLabel,
children,
help,
id,
horizontal,
label,
labelHidden,
truncate
};
return { ...otherProps,
className: classes,
contentProps,
horizontal
};
}
//# sourceMappingURL=use-form-group.js.map