import { jsx as _jsx } from "react/jsx-runtime";
import { FormControlLabel, Switch } from "@mui/material";
import { Controller } from "react-hook-form";
import "./style.scss";
export default function SwitchField({ attr, label, createdForm, disabled = false, onChange, }) {
    const fieldName = attr;
    const { control } = createdForm;
    return (_jsx(Controller, { name: fieldName, control: control, render: ({ field }) => (_jsx(FormControlLabel, { className: "ds-switch", disabled: disabled, control: _jsx(Switch, { ...field, checked: !!field.value, onChange: (e) => {
                    const checked = e.target.checked;
                    field.onChange(checked);
                    onChange?.(checked);
                } }), label: label })) }));
}
