UNPKG

@wordpress/components

Version:
51 lines (47 loc) 1.27 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@wordpress/element"; /** * WordPress dependencies */ import { useMemo, memo } from '@wordpress/element'; /** * Internal dependencies */ import { VStack } from '../v-stack'; import { FormGroupContext } from './form-group-context'; import FormGroupHelp from './form-group-help'; import FormGroupLabel from './form-group-label'; /** * @param {import('../context').ViewOwnProps<import('./types').FormGroupContentProps, 'label'>} props */ function FormGroupContent({ alignLabel, children, help, horizontal = false, id, label, labelHidden, spacing = 2, truncate, ...props }) { const contextProps = useMemo(() => ({ id, horizontal }), [id, horizontal]); const content = help ? createElement(VStack, { expanded: false, spacing: spacing }, children, createElement(FormGroupHelp, null, help)) : children; return createElement(FormGroupContext.Provider, { value: contextProps }, createElement(FormGroupLabel, _extends({ align: alignLabel, id: id, labelHidden: labelHidden, truncate: truncate }, props), label), content); } export default memo(FormGroupContent); //# sourceMappingURL=form-group-content.js.map