import { Tooltip } from "bootstrap"; import { useEffect, useRef } from "preact/compat"; import { escapeQuotes } from "../../services/utils"; import { ComponentChildren } from "preact"; interface FormCheckboxProps { name: string; label: string | ComponentChildren; /** * 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; disabled?: boolean; onChange(newValue: boolean): void; } export default function FormCheckbox({ name, disabled, label, currentValue, onChange, hint }: FormCheckboxProps) { const labelRef = useRef(null); if (hint) { useEffect(() => { let tooltipInstance: Tooltip | null = null; if (labelRef.current) { tooltipInstance = Tooltip.getOrCreateInstance(labelRef.current, { html: true, template: '' }); } return () => tooltipInstance?.dispose(); }, [labelRef.current]); } return (
); }