import { Dropdown as BootstrapDropdown } from "bootstrap"; import { ComponentChildren } from "preact"; import Icon from "./Icon"; import { useEffect, useRef, type CSSProperties } from "preact/compat"; interface FormListOpts { children: ComponentChildren; onSelect?: (value: string) => void; style?: CSSProperties; } export default function FormList({ children, onSelect, style }: FormListOpts) { const wrapperRef = useRef(null); const triggerRef = useRef(null); useEffect(() => { if (!triggerRef.current || !wrapperRef.current) { return; } const $wrapperRef = $(wrapperRef.current); const dropdown = BootstrapDropdown.getOrCreateInstance(triggerRef.current); $wrapperRef.on("hide.bs.dropdown", (e) => e.preventDefault()); return () => { $wrapperRef.off("hide.bs.dropdown"); dropdown.dispose(); } }, [ triggerRef, wrapperRef ]); return (
); } interface FormListItemOpts { children: ComponentChildren; icon?: string; value?: string; title?: string; active?: boolean; } export function FormListItem({ children, icon, value, title, active }: FormListItemOpts) { return (   {children} ); } interface FormListHeaderOpts { text: string; } export function FormListHeader({ text }: FormListHeaderOpts) { return (
  • {text}
  • ) }