UNPKG

mui-custom-form

Version:

A versatile React form component utilizing MUI components and react-hook-form.

8 lines 701 B
import { FormControlLabel, Switch as MuiSwitch } from "@mui/material"; import React from "react"; import { Controller } from "react-hook-form"; export const SwitchField = ({ field, formControl, }) => { const { control } = formControl; return (React.createElement(Controller, { name: field.name, control: control, rules: { required: field.required }, render: ({ field: controlField, fieldState: { error } }) => (React.createElement(FormControlLabel, { control: React.createElement(MuiSwitch, { ...controlField, checked: !!controlField.value, onChange: (e) => controlField.onChange(e.target.checked), ...field.otherProps }), label: field.label })) })); }; //# sourceMappingURL=SwitchField.js.map