'use client';


import { useFormField } from "../FormField.mjs";
import { FormItemLayout } from "../layout/FormItemLayout.mjs";
import { Select } from "../../Select/Select.mjs";
import { Form } from "../Form.mjs";
import { jsx } from "react/jsx-runtime";
import { useFormContext } from "react-hook-form";

//#region src/components/Form/elements/SelectElement.tsx
const SelectFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
	const { error } = useFormField();
	return /* @__PURE__ */ jsx(FormItemLayout, {
		htmlFor: name,
		label,
		description,
		isRequired,
		info,
		showErrorMessage,
		"aria-invalid": !!error,
		children: /* @__PURE__ */ jsx(Select, {
			onValueChange: field.onChange,
			defaultValue: field.value,
			...props,
			children
		})
	});
};
const SelectElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
	const { control } = useFormContext();
	return /* @__PURE__ */ jsx(Form.Field, {
		control,
		name,
		render: ({ field }) => /* @__PURE__ */ jsx(SelectFieldContent, {
			field,
			name,
			label,
			description,
			isRequired,
			info,
			showErrorMessage,
			...props,
			children
		})
	});
};

//#endregion
export { SelectElement };
//# sourceMappingURL=SelectElement.mjs.map