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.

68 lines (64 loc) 2.03 kB
"use client"; import { jsxs, jsx } from 'react/jsx-runtime'; import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'; export { DropdownMenuTrigger as DropdownTrigger } from '@radix-ui/react-dropdown-menu'; import { forwardRef } from 'react'; import { useLiveblocksUIConfig } from '../../config.js'; import { FLOATING_ELEMENT_SIDE_OFFSET, FLOATING_ELEMENT_COLLISION_PADDING } from '../../constants.js'; import { useOverrides } from '../../overrides.js'; import { classNames } from '../../utils/class-names.js'; function Dropdown({ children, content, defaultOpen, open, onOpenChange, className, ...props }) { const $ = useOverrides(); const { portalContainer } = useLiveblocksUIConfig(); return /* @__PURE__ */ jsxs(DropdownMenuPrimitive.Root, { defaultOpen, open, onOpenChange, dir: $.dir, children: [ children, /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { container: portalContainer, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Content, { className: classNames( "lb-root lb-portal lb-elevation lb-dropdown", className ), sideOffset: FLOATING_ELEMENT_SIDE_OFFSET, collisionPadding: FLOATING_ELEMENT_COLLISION_PADDING, ...props, children: content }) }) ] }); } const DropdownItem = forwardRef( ({ children, className, icon, ...props }, forwardedRef) => { return /* @__PURE__ */ jsxs(DropdownMenuPrimitive.DropdownMenuItem, { className: classNames("lb-dropdown-item", className), ...props, ref: forwardedRef, children: [ icon ? /* @__PURE__ */ jsx("span", { className: "lb-dropdown-item-icon lb-icon-container", children: icon }) : null, children ? /* @__PURE__ */ jsx("span", { className: "lb-dropdown-item-label", children }) : null ] }); } ); export { Dropdown, DropdownItem }; //# sourceMappingURL=Dropdown.js.map