UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

25 lines (24 loc) 855 B
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useDialogRoot } from "./context.js"; import { useSlot } from "../../../hooks/use-slot/use-slot.js"; function DialogTriggerBase({ render, ...props }, ref) { const ctx = useDialogRoot(); const internalProps = { onClick: () => ctx.onOpenChange(!ctx.open), "data-ln-dialog-open": ctx.open, "aria-haspopup": "dialog", "aria-controls": ctx.open ? ctx.id : undefined, }; const final = useSlot({ props: [internalProps, props, { "data-ln-dialog-trigger": "true" }], ref: ref, slot: render ?? _jsx("button", {}), state: { open: ctx.open, openChange: ctx.onOpenChange, }, }); return final; } export const DialogTrigger = forwardRef(DialogTriggerBase);