nice-ui
Version:
React design system, components, and utilities
25 lines (24 loc) • 1.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextItemNested = void 0;
const React = require("react");
const ContextItem_1 = require("./ContextItem");
const PopupControlled_1 = require("../Popup/PopupControlled");
const popup_1 = require("../../utils/popup");
const anchorSpec = {
gap: -4,
off: -8,
horizontal: true,
};
/**
* Renders a {@link ContextItem} which has a nested sub-menu.
*/
const ContextItemNested = ({ open, left, renderPane, children, ...rest }) => {
const handle = (0, popup_1.useAnchorPointHandle)(anchorSpec);
const item = (React.createElement(ContextItem_1.ContextItem, { ...rest, open: open, selected: renderPane ? open : rest.selected }, 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.ContextItemNested = ContextItemNested;
;