2025-08-03 21:18:18 +03:00
|
|
|
interface FormCheckboxProps {
|
|
|
|
|
name: string;
|
|
|
|
|
label: string;
|
2025-08-05 15:13:09 +03:00
|
|
|
/**
|
|
|
|
|
* If set, the checkbox label will be underlined and dotted, indicating a hint. When hovered, it will show the hint text.
|
|
|
|
|
*/
|
|
|
|
|
hint?: string;
|
|
|
|
|
currentValue: boolean;
|
2025-08-03 21:18:18 +03:00
|
|
|
onChange(newValue: boolean): void;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-05 15:13:09 +03:00
|
|
|
export default function FormCheckbox({ name, label, currentValue, onChange, hint }: FormCheckboxProps) {
|
2025-08-03 21:18:18 +03:00
|
|
|
return (
|
2025-08-05 20:00:39 +03:00
|
|
|
<div className="form-checkbox">
|
2025-08-05 15:13:09 +03:00
|
|
|
<label
|
|
|
|
|
className="form-check-label tn-checkbox"
|
|
|
|
|
style={hint && { textDecoration: "underline dotted var(--main-text-color)" }} title={hint}>
|
2025-08-03 21:18:18 +03:00
|
|
|
<input
|
|
|
|
|
className="form-check-input"
|
|
|
|
|
type="checkbox"
|
|
|
|
|
name={name}
|
|
|
|
|
checked={currentValue || false}
|
|
|
|
|
value="1"
|
|
|
|
|
onChange={e => onChange((e.target as HTMLInputElement).checked)} />
|
|
|
|
|
{label}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|