/** @license MIT | @cube-dev/ui-kit v0.127.1 | Cube Dev Team */
import { mergeProps } from "../../utils/react/mergeProps.js";
import { FieldWrapper } from "./FieldWrapper/FieldWrapper.js";
import { jsx } from "react/jsx-runtime";

//#region src/components/form/wrapper.tsx
function wrapWithField(component, ref, props) {
	let { forceField, label, extra, labelPosition = "top", labelStyles, isRequired, isDisabled, necessityIndicator, message, messageStyles, description, errorMessage, validationState, labelProps, fieldProps, fieldStyles, requiredMark = true, tooltip, isHidden, labelSuffix } = props;
	if (!label && !forceField) return component;
	const mergedFieldProps = fieldStyles ? mergeProps(fieldProps, { styles: fieldStyles }) : fieldProps;
	const mergedLabelProps = labelStyles ? mergeProps(labelProps, { styles: labelStyles }) : labelProps;
	const { id: _id, ...fieldPropsWithoutId } = mergedFieldProps || {};
	return /* @__PURE__ */ jsx(FieldWrapper, {
		label,
		extra,
		labelPosition,
		isRequired,
		isDisabled,
		necessityIndicator,
		labelProps: mergedLabelProps,
		fieldProps: fieldPropsWithoutId,
		message,
		messageStyles,
		description,
		errorMessage,
		validationState,
		requiredMark,
		tooltip,
		isHidden,
		labelSuffix,
		Component: component,
		ref
	});
}

//#endregion
export { wrapWithField };
//# sourceMappingURL=wrapper.js.map