wix-style-react
Version:
wix-style-react
46 lines • 2.04 kB
JavaScript
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { SidebarNextContext } from '../SidebarNext/SidebarNextContext';
import { ContextMenu } from './components/ContextMenu';
import { AccordionMenu } from './components/AccordionMenu';
const SidebarSubMenuNext = props => {
const context = useContext(SidebarNextContext);
if (context?.parent === 'inContextMenu') {
return React.createElement(ContextMenu, { ...props });
}
return React.createElement(AccordionMenu, { ...props });
};
SidebarSubMenuNext.displayName = 'SidebarSubMenuNext';
SidebarSubMenuNext.propTypes = {
/** render as some other component or DOM tag */
as: PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.string]),
/** URL of the page that link goes to */
href: PropTypes.string,
/** Applied as data-hook HTML attribute that can be used in the tests */
dataHook: PropTypes.string,
/** A css class to be applied to the component's root element */
className: PropTypes.string,
/** Indicates whether to display the item as disabled */
disabled: PropTypes.bool,
/** A callback to be triggered on click */
onClick: PropTypes.func,
/** unique identifier per item, used to mark it for navigation and selection */
itemKey: PropTypes.string,
/** An element to appear as the title of the submenu */
title: PropTypes.node,
/** A callback to be triggered when the sub menu expands */
onExpand: PropTypes.func,
/** A callback to be triggered when the sub menu collapses */
onCollapse: PropTypes.func,
/** An element to appear at the end of the text */
suffix: PropTypes.oneOfType([
PropTypes.node,
PropTypes.arrayOf(PropTypes.node),
]),
/** An element to appear at the start of the text. */
prefix: PropTypes.node,
/** A callback to be triggered when the quick nav opens */
onQuickNavOpen: PropTypes.func,
};
export default SidebarSubMenuNext;
//# sourceMappingURL=SidebarSubMenuNext.js.map