Debian Codegraph @

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

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.WizardNavItem = void 0;
4 const tslib_1 = require("tslib");
5 const jsx_runtime_1 = require("react/jsx-runtime");
6 const react_1 = require("react");
7 const react_styles_1 = require("@patternfly/react-styles");
8 const wizard_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Wizard/wizard"));
9 const rh_microns_caret_down_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/rh-microns-caret-down-icon'));
10 const helpers_1 = require("../../../helpers");
11 const WizardNavItem = (_a) => {
12 var { children = null, content = '', isCurrent = false, isDisabled = false, step, onNavItemClick = () => undefined, navItemComponent = 'button', href = null, isExpandable = false, id, ouiaId, ouiaSafe = true } = _a, rest = tslib_1.__rest(_a, ["children", "content", "isCurrent", "isDisabled", "step", "onNavItemClick", "navItemComponent", "href", "isExpandable", "id", "ouiaId", "ouiaSafe"]);
13 const ouiaProps = (0, helpers_1.useOUIAProps)(exports.WizardNavItem.displayName, ouiaId, ouiaSafe);
14 const NavItemComponent = navItemComponent;
15 const [isExpanded, setIsExpanded] = (0, react_1.useState)(false);
16 (0, react_1.useEffect)(() => {
17 setIsExpanded(isCurrent);
18 }, [isCurrent]);
19 if (navItemComponent === 'a' && !href && process.env.NODE_ENV !== 'production') {
20 // eslint-disable-next-line no-console
21 console.error('WizardNavItem: When using an anchor, please provide an href');
22 }
23 const btnProps = {
24 disabled: isDisabled,
25 type: 'button'
26 };
27 const linkProps = {
28 tabIndex: isDisabled ? -1 : undefined,
29 href
30 };
31 return ((0, jsx_runtime_1.jsxs)("li", { className: (0, react_styles_1.css)(wizard_1.default.wizardNavItem, isExpandable && wizard_1.default.modifiers.expandable, isExpandable && isExpanded && wizard_1.default.modifiers.expanded), children: [(0, jsx_runtime_1.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: (0, react_styles_1.css)(wizard_1.default.wizardNavLink, isCurrent && wizard_1.default.modifiers.current, isDisabled && wizard_1.default.modifiers.disabled), "aria-disabled": isDisabled ? true : null, "aria-current": isCurrent && !children ? 'step' : false }, (isExpandable && { 'aria-expanded': isExpanded }), ouiaProps, { children: (0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)(wizard_1.default.wizardNavLinkMain), children: isExpandable ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "pf-v6-c-wizard__nav-link-text", children: content }), (0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)(wizard_1.default.wizardNavLinkToggle), children: (0, jsx_runtime_1.jsx)("span", { className: (0, react_styles_1.css)(wizard_1.default.wizardNavLinkToggleIcon), children: (0, jsx_runtime_1.jsx)(rh_microns_caret_down_icon_1.default, {}) }) })] })) : (content) }) })), children] }));
32 };
33 exports.WizardNavItem = WizardNavItem;
34 exports.WizardNavItem.displayName = 'WizardNavItem';
35 //# sourceMappingURL=WizardNavItem.js.map