import { createMemo, createSignal, For, JSX, Setter, createEffect, Show, ParentProps, children } from "solid-js"; import { FaSolidAngleDown } from "solid-icons/fa"; import css from './index.module.css'; export interface DropdownApi { show(): void; hide(): void; } interface DropdownProps { api?: (api: DropdownApi) => any, id: string; class?: string; open?: boolean; showCaret?: boolean; text: JSX.Element; children: JSX.Element; } export function Dropdown(props: DropdownProps) { const [dialog, setDialog] = createSignal(); const [open, setOpen] = createSignal(props.open ?? false); createEffect(() => { dialog()?.[open() ? 'showPopover' : 'hidePopover'](); }); createEffect(() => { props.api?.({ show() { dialog()?.showPopover(); }, hide() { dialog()?.hidePopover(); }, }); }); return
setOpen(e.newState === 'open')}> {props.children}
; }