@wix/design-system
Version:
@wix/design-system
55 lines • 2.62 kB
JavaScript
import React, { useContext, useMemo } from 'react';
import PropTypes from 'prop-types';
import { SidebarNextContext } from '../SidebarNext/SidebarNextContext';
import { st, classes } from './SidebarItemNext.st.css.js';
import SidebarItemButtonNext from './SidebarItemButtonNext';
import { dataHooks } from './constants';
/** An item for the section within the sidebar */
const SidebarItemNext = ({ as = 'button', role = 'link', ...propsWithNoDefaults }) => {
const { dataHook, onMouseEnter, onMouseLeave, ...rest } = {
as,
role,
...propsWithNoDefaults,
};
const context = useContext(SidebarNextContext);
return (React.createElement("li", { className: classes.listItem, "aria-level": context.level, "data-hook": dataHook, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave },
React.createElement(SidebarItemButtonNext, { ...rest, dataHook: dataHooks.button })));
};
SidebarItemNext.displayName = 'SidebarItemNext';
SidebarItemNext.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,
/** Specifies a CSS class name to be appended to the component’s root element.
* @internal
*/
className: PropTypes.string,
/** An element/array of elements to appear at the end of the text. max number of elements to pass is 2 */
suffix: PropTypes.oneOfType([
PropTypes.node,
PropTypes.arrayOf(PropTypes.node),
]),
/** An element to appear at the start of the text. */
prefix: PropTypes.node,
/** 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,
/** indicates whether the item is inside quickNavigation popover */
isInQuickNavigation: PropTypes.bool,
/** Defines one of the aria roles to provide semantic meaning to content */
role: PropTypes.string,
/** An element to appear as the content of the tooltip */
minimizedTooltipContent: PropTypes.node,
/** A callback to be triggered on mouse enter */
onMouseEnter: PropTypes.func,
/** A callback to be triggered on mouse leave */
onMouseLeave: PropTypes.func,
};
export default SidebarItemNext;
//# sourceMappingURL=SidebarItemNext.js.map