blob: 8f33a42c26f44da49cd377542fed450b20afc6a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import { FC, InputHTMLAttributes } from 'react';
import styles from './boolean-field.module.scss';
export type BooleanFieldProps = Omit<
InputHTMLAttributes<HTMLInputElement>,
'checked' | 'hidden' | 'name' | 'type' | 'value'
> & {
/**
* True if the field should be checked.
*/
checked: boolean;
/**
* True if the field should be visually hidden. Default: false.
*/
hidden?: boolean;
/**
* Field name attribute.
*/
name: string;
/**
* The input type.
*/
type: 'checkbox' | 'radio';
/**
* Field name attribute.
*/
value: string;
};
/**
* BooleanField component
*
* Render a checkbox or a radio input type.
*/
export const BooleanField: FC<BooleanFieldProps> = ({
className = '',
hidden = false,
...props
}) => {
const modifier = hidden ? 'hidden' : '';
const inputClass = `${styles[modifier]} ${className}`;
return <input {...props} className={inputClass} />;
};
|