UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

1 lines 1.11 kB
{"version":3,"file":"Portal.cjs","sources":["../../src/utils/Portal.tsx"],"sourcesContent":["\"use client\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { forwardRef } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport type { ComponentPropsWithSlot } from \"../types\";\n\nconst PORTAL_NAME = \"Portal\";\n\ninterface PortalProps extends ComponentPropsWithSlot<\"div\"> {\n /**\n * The container to render the portal into.\n */\n container?: HTMLElement | null;\n}\n\nconst Portal = forwardRef<HTMLDivElement, PortalProps>(\n ({ container = document?.body, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? Slot : \"div\";\n\n return container\n ? createPortal(\n <Component data-liveblocks-portal=\"\" {...props} ref={forwardedRef} />,\n container\n )\n : null;\n }\n);\n\nif (process.env.NODE_ENV !== \"production\") {\n Portal.displayName = PORTAL_NAME;\n}\n\nexport { Portal };\n"],"names":[],"mappings":";;;;;;;;;AAQA;AASA;AAAe;AAEX;AAEA;AACI;AACG;AAAiC;AAAO;AAAY;AAAc;AACnE;AAEF;AAER;AAEA;AACE;AACF;;"}