{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"lib-portal","type":"registry:lib","title":"portal helpers","description":"Where menus, dialogs, popovers and tooltips put themselves: document.body unless something says otherwise. A themed","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/dashral/lib/portal.tsx","type":"registry:file","target":"components/dashral/lib/portal.tsx","content":"\"use client\"\n\n// Where menus, dialogs, popovers and tooltips put themselves: document.body unless something says otherwise. A themed\n// part of a page (a preview in another look, a section with its own theme) gives its own element, carrying the same\n// theme attributes, so what opens from inside it wears its look while still opening over the whole page.\n\nimport * as React from \"react\"\n\nconst PortalContainerContext = React.createContext<HTMLElement | null>(null)\n\n/** Everything inside opens its overlays in `container` instead of document.body. */\nexport function PortalContainer({ container, children }: { container: HTMLElement | null; children: React.ReactNode }) {\n  return <PortalContainerContext value={container}>{children}</PortalContainerContext>\n}\n\n/** The element overlays open in here, or undefined for document.body (as a Radix Portal's container takes it). */\nexport function usePortalContainer() {\n  return React.useContext(PortalContainerContext) ?? undefined\n}\n"}]}