UNPKG

@wordpress/components

Version:
52 lines (48 loc) 1.33 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').WordPressComponentProps<import('./types').FormGroupContentProps, 'label', false>} props */ function FormGroupContent(_ref) { let { alignLabel, children, help, horizontal = false, id, label, labelHidden, spacing = 2, truncate, ...props } = _ref; 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