import { Checkbox as e } from "../../ui/checkbox.js";
import { Label as t } from "../../ui/label.js";
import { useFieldConfig as n } from "../hooks/useFieldConfig.js";
import { BaseFieldWrapper as r } from "./BaseFieldWrapper.js";
import "react";
import { jsx as i, jsxs as a } from "react/jsx-runtime";
import { Controller as o } from "react-hook-form";
//#region src/components/dynamic-form/fields/CheckboxField.tsx
var s = ({ name: s, schema: c, ui: l, required: u, form: d, disabled: f }) => {
	let p = n(s, c, l, f);
	return /* @__PURE__ */ i(o, {
		name: s,
		control: d.control,
		defaultValue: p.defaultValue || !1,
		rules: { validate: u ? (e) => e === !0 || "This field is required" : void 0 },
		render: ({ field: { onChange: n, value: o, ref: c } }) => /* @__PURE__ */ i(r, {
			name: s,
			label: p.fieldLabel,
			required: u,
			error: p.error,
			helpText: p.helpText,
			description: p.description,
			children: /* @__PURE__ */ a("div", {
				className: "flex items-center space-x-2",
				children: [/* @__PURE__ */ i(e, {
					id: s,
					checked: !!o,
					onCheckedChange: p.isReadOnly ? void 0 : (e) => n(e || !1),
					disabled: p.isDisabled,
					ref: c,
					name: s,
					required: u,
					...p.getAriaProps()
				}), /* @__PURE__ */ i(t, {
					htmlFor: s,
					className: "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
					children: p.fieldLabel
				})]
			})
		})
	});
};
//#endregion
export { s as CheckboxField };
