Debian Codegraph @

node/@patternfly/react-core/dist/esm/deprecated/components/Wizard/WizardNavItem.js

raw
1 import { __rest } from "tslib";
2 import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3 import { useEffect, useState } from 'react';
4 import { css } from '@patternfly/react-styles';
5 import styles from '@patternfly/react-styles/css/components/Wizard/wizard.mjs';
6 import RhMicronsCaretDownIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-down-icon';
7 import { useOUIAProps } from '../../../helpers';
8 export const WizardNavItem = (_a) => {
9 var { children = null, content = '', isCurrent = false, isDisabled = false, step, onNavItemClick = () => undefined, navItemComponent = 'button', href = null, isExpandable = false, id, ouiaId, ouiaSafe = true } = _a, rest = __rest(_a, ["children", "content", "isCurrent", "isDisabled", "step", "onNavItemClick", "navItemComponent", "href", "isExpandable", "id", "ouiaId", "ouiaSafe"]);
10 const ouiaProps = useOUIAProps(WizardNavItem.displayName, ouiaId, ouiaSafe);
11 const NavItemComponent = navItemComponent;
12 const [isExpanded, setIsExpanded] = useState(false);
13 useEffect(() => {
14 setIsExpanded(isCurrent);
15 }, [isCurrent]);
16 if (navItemComponent === 'a' && !href && process.env.NODE_ENV !== 'production') {
17 // eslint-disable-next-line no-console
18 console.error('WizardNavItem: When using an anchor, please provide an href');
19 }
20 const btnProps = {
21 disabled: isDisabled,
22 type: 'button'
23 };
24 const linkProps = {
25 tabIndex: isDisabled ? -1 : undefined,
26 href
27 };
28 return (_jsxs("li", { className: css(styles.wizardNavItem, isExpandable && styles.modifiers.expandable, isExpandable && isExpanded && styles.modifiers.expanded), children: [_jsx(NavItemComponent, Object.assign({}, rest, (navItemComponent === 'a' ? Object.assign({}, linkProps) : Object.assign({}, btnProps)), (id && { id: id.toString() }), { onClick: () => (isExpandable ? setIsExpanded(!isExpanded || isCurrent) : onNavItemClick(step)), className: css(styles.wizardNavLink, isCurrent && styles.modifiers.current, isDisabled && styles.modifiers.disabled), "aria-disabled": isDisabled ? true : null, "aria-current": isCurrent && !children ? 'step' : false }, (isExpandable && { 'aria-expanded': isExpanded }), ouiaProps, { children: _jsx("span", { className: css(styles.wizardNavLinkMain), children: isExpandable ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "pf-v6-c-wizard__nav-link-text", children: content }), _jsx("span", { className: css(styles.wizardNavLinkToggle), children: _jsx("span", { className: css(styles.wizardNavLinkToggleIcon), children: _jsx(RhMicronsCaretDownIcon, {}) }) })] })) : (content) }) })), children] }));
29 };
30 WizardNavItem.displayName = 'WizardNavItem';
31 //# sourceMappingURL=WizardNavItem.js.map