@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.1 kB
Source Map (JSON)
{"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 { useLiveblocksUiConfig } from \"../config\";\nimport type { ComponentPropsWithSlot } from \"../types\";\n\nconst PORTAL_NAME = \"Portal\";\n\nconst Portal = forwardRef<HTMLDivElement, ComponentPropsWithSlot<\"div\">>(\n ({ asChild, ...props }, forwardedRef) => {\n const { portalContainer } = useLiveblocksUiConfig();\n const container = portalContainer ?? document?.body;\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":";;;;;;;;;;AASA;AAEA;AAAe;AAEX;AACA;AACA;AAEA;AACI;AACqE;AACnE;AAEF;AAER;AAEA;AACE;AACF;;"}