UNPKG

@brizy/ui

Version:
37 lines (36 loc) 1.62 kB
import React, { useContext } from "react"; import AntPopover from "antd/lib/popover"; import { FrameContentContext } from "../Frame/FrameContent"; import { ToolbarOverlay } from "./ToolbarOverlay"; import { ToolbarItem } from "./ToolbarItem"; import { BRZ_PREFIX } from "../constants"; export const Toolbar = (props) => { const context = useContext(FrameContentContext); const { opened, onOpenedChange, children, content, getContainer } = props; const handleGetContainer = () => { if (typeof getContainer === "function") { return getContainer(); } if (context.node) { return context.node; } return document.body; }; const selectedProps = {}; if (opened !== undefined) { selectedProps.visible = opened; } return (React.createElement(AntPopover, Object.assign({ overlayClassName: `${BRZ_PREFIX}-toolbar`, content: content, trigger: "click", getPopupContainer: handleGetContainer, onVisibleChange: onOpenedChange }, selectedProps), children)); }; Toolbar.Overlay = ToolbarOverlay; Toolbar.Item = ToolbarItem; export { ToolbarPopover } from "./Options/Popover"; export { ToolbarInput } from "./Options/Input"; export { ToolbarNumber } from "./Options/Number"; export { ToolbarOption } from "./Options/Option"; export { ToolbarSwitch } from "./Options/Switch"; export { ToolbarTabs } from "./Options/Tabs"; export { ToolbarTabPane } from "./Options/TabPane"; export { ToolbarSelect } from "./Options/Select"; export { ToolbarSelectOption } from "./Options/SelectOption"; export { ToolbarTextarea } from "./Options/Textarea";