nice-ui
Version:
React design system, components, and utilities
25 lines (24 loc) • 1.03 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextTitleNested = void 0;
const React = require("react");
const ContextTitle_1 = require("./ContextTitle");
const PopupControlled_1 = require("../Popup/PopupControlled");
const popup_1 = require("../../utils/popup");
const anchorSpec = {
gap: -4,
off: -16,
horizontal: true,
};
/**
* Renders a {@link ContextTitle} which has a nested sub-menu.
*/
const ContextTitleNested = ({ open, left, renderPane, children, ...rest }) => {
const handle = (0, popup_1.useAnchorPointHandle)(anchorSpec);
const item = React.createElement(ContextTitle_1.ContextTitle, { ...rest }, children);
if (!renderPane)
return item;
return (React.createElement(popup_1.anchorContext.Provider, { value: handle },
React.createElement(PopupControlled_1.PopupControlled, { fadeIn: true, refToggle: handle.ref, block: true, open: open, renderContext: renderPane }, item)));
};
exports.ContextTitleNested = ContextTitleNested;
;