form-input-fields
Version:
A customizable form field components built with TypeScript
61 lines • 1.75 kB
TypeScript
import { default as React } from 'react';
import { FieldProps } from 'formik';
import { SwitchProps } from '@mui/material/Switch';
export interface FormSwitchProps {
id: string;
/**
* Label text displayed next to the switch
*/
label?: string;
/**
* Position of the label relative to the switch
* @default 'end'
*/
labelPlacement?: 'top' | 'start' | 'bottom' | 'end';
/**
* Color of the switch when checked
* @default 'primary'
*/
color?: 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning' | 'default';
/**
* Size of the switch
* @default 'medium'
*/
size?: 'small' | 'medium';
/**
* Whether the switch is disabled
* @default false
*/
disabled?: boolean;
/**
* Whether the switch is required
* @default false
*/
required?: boolean;
/**
* Custom onChange handler with additional switch-related data
*/
onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean, context: {
fieldName: string;
formikValue: boolean;
}) => void;
/**
* Custom onBlur handler
*/
onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;
/**
* Helper text to display below the switch
*/
helperText?: string;
/**
* Error state of the switch
*/
error?: boolean;
/**
* Custom class name for the root element
*/
className?: string;
}
export type FormSwitchComponentProps = FieldProps & SwitchProps & FormSwitchProps;
export declare const FormSwitch: React.MemoExoticComponent<(props: FormSwitchComponentProps) => import("react/jsx-runtime").JSX.Element>;
//# sourceMappingURL=FormSwitch.d.ts.map