@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
63 lines (62 loc) • 1.87 kB
JavaScript
import { jsx } from "react/jsx-runtime";
import { composeEventHandlers, withStaticProperties } from "@crossed/core";
import { Popover, useFloatingContext } from "../overlay";
import { memo } from "react";
import { MenuList } from "./MenuList";
import { Divider as D } from "../layout/Divider";
import { useMedia } from "../useMedia";
const DropDownRoot = memo(
({
children,
placement = "bottom-end",
triggerStrategy = "onPress",
...props
}) => {
return /* @__PURE__ */ jsx(
Popover,
{
placement,
triggerStrategy,
...props,
children
}
);
}
);
const DropDowmMenuTrigger = ({ ...props }) => {
return /* @__PURE__ */ jsx(Popover.Trigger, { ...props });
};
const DropDownMenuContent = ({ children, style }) => {
const { md } = useMedia();
return /* @__PURE__ */ jsx(Popover.Content, { children: /* @__PURE__ */ jsx(MenuList, { style, bordered: md, children }) });
};
const DropDownMenuItem = ({ children, onPress, ...props }) => {
const { onClose } = useFloatingContext();
return /* @__PURE__ */ jsx(
MenuList.Item,
{
...props,
onPress: composeEventHandlers(onPress, onClose),
children
}
);
};
const DropDownMenuItemLabel = ({ children, ...props }) => {
return /* @__PURE__ */ jsx(MenuList.Label, { ...props, children });
};
const DropDownMenuItemTitle = ({ children, ...props }) => {
return /* @__PURE__ */ jsx(MenuList.Title, { ...props, children });
};
const DropDownMenuDivider = (props) => /* @__PURE__ */ jsx(D, { ...props });
const DropDownMenu = withStaticProperties(DropDownRoot, {
Trigger: DropDowmMenuTrigger,
Content: DropDownMenuContent,
Item: DropDownMenuItem,
Label: DropDownMenuItemLabel,
Title: DropDownMenuItemTitle,
Divider: DropDownMenuDivider
});
export {
DropDownMenu
};
//# sourceMappingURL=DropDownMenu.js.map