import { Dialog as DialogPrimitive } from "@kobalte/core/dialog"; import type { ComponentProps, ParentProps, ValidComponent } from "solid-js"; import { Show, splitProps } from "solid-js"; import { IconX } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; import { useT } from "@/stores/preferences-context"; export const Dialog = DialogPrimitive; export const DialogTrigger = DialogPrimitive.Trigger; export const DialogClose = DialogPrimitive.CloseButton; type DialogContentExtras = { dismissable?: boolean; closeButton?: boolean; /** "top" pins the dialog high on the screen, so a panel whose height * follows its content (the command palette's results) grows downward * instead of jumping up and down around the centre while you type. */ position?: "center" | "top"; }; export function DialogContent( props: ComponentProps> & DialogContentExtras, ) { const [local, rest] = splitProps( props as ComponentProps & DialogContentExtras, ["class", "children", "dismissable", "closeButton", "position"], ); // The close button speaks the app language; a bare render (unit tests, // no PreferencesProvider) falls back to English instead of throwing. let t: ReturnType | undefined; try { t = useT(); } catch { t = undefined; } const closeLabel = () => t?.("common.close") ?? "Close"; return ( {/* z-[70]: above the mobile nav sheet (z-60) and tab bar (z-40). */} {/* flex center — animate-fade-up must not own transform positioning */} {/* The centring box is inset by the system bars, so a tall dialog is never clipped by the status bar or the gesture bar. */}
e.preventDefault() : undefined} onInteractOutside={local.dismissable === false ? (e) => e.preventDefault() : undefined} onEscapeKeyDown={local.dismissable === false ? (e) => e.preventDefault() : undefined} {...rest} > {/* `closeButton={false}` lets a dialog draw its own close control (the command palette labels it, beside its clear-search ×). */} {local.children}
); } export function DialogHeader(props: ParentProps<{ class?: string }>) { return
{props.children}
; } export function DialogBody(props: ParentProps<{ class?: string }>) { return
{props.children}
; } export function DialogTitle( props: ComponentProps>, ) { const [local, rest] = splitProps(props as ComponentProps, ["class"]); return ( ); } export function DialogDescription( props: ComponentProps>, ) { const [local, rest] = splitProps(props as ComponentProps, ["class"]); return ( ); }