wix-style-react
Version:
wix-style-react
43 lines • 2.19 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';
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, ...rest } = { as, role, ...propsWithNoDefaults };
const context = useContext(SidebarNextContext);
return (React.createElement("li", { className: classes.listItem, "aria-level": context.level, "data-hook": dataHook },
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,
/** A css class to be applied to the component's root element */
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,
};
export default SidebarItemNext;
//# sourceMappingURL=SidebarItemNext.js.map