| 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 rh_ui_error_fill_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/rh-ui-error-fill-icon')); |
| 11 |
const rh_ui_check_circle_fill_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/rh-ui-check-circle-fill-icon')); |
| 12 |
const rh_ui_warning_fill_icon_1 = tslib_1.__importDefault(require('@patternfly/react-icons/dist/js/icons/rh-ui-warning-fill-icon')); |
| 13 |
const helpers_1 = require("../../helpers"); |
| 14 |
const types_1 = require("./types"); |
| 15 |
const WizardNavItem = (_a) => { |
| 16 |
var { children = null, content = '', isCurrent = false, isDisabled = false, |
| 17 |
// eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 18 |
isVisited = false, stepIndex, onClick, component: NavItemComponent = 'button', href, isExpandable = false, id, status = 'default', target, ouiaId, ouiaSafe = true, className } = _a, props = tslib_1.__rest(_a, ["children", "content", "isCurrent", "isDisabled", "isVisited", "stepIndex", "onClick", "component", "href", "isExpandable", "id", "status", "target", "ouiaId", "ouiaSafe", "className"]); |
| 19 |
const [isExpanded, setIsExpanded] = (0, react_1.useState)(false); |
| 20 |
const ouiaProps = (0, helpers_1.useOUIAProps)(exports.WizardNavItem.displayName, ouiaId, ouiaSafe); |
| 21 |
(0, react_1.useEffect)(() => { |
| 22 |
setIsExpanded(isCurrent); |
| 23 |
}, [isCurrent]); |
| 24 |
if (NavItemComponent === 'a' && !href && process.env.NODE_ENV !== 'production') { |
| 25 |
// eslint-disable-next-line no-console |
| 26 |
console.error('WizardNavItem: When using an anchor, please provide an href'); |
| 27 |
} |
| 28 |
return ((0, jsx_runtime_1.jsxs)("li", Object.assign({ className: (0, react_styles_1.css)(wizard_1.default.wizardNavItem, isExpandable && wizard_1.default.modifiers.expandable, isExpandable && isExpanded && wizard_1.default.modifiers.expanded, className) }, props, { children: [(0, jsx_runtime_1.jsxs)(NavItemComponent, Object.assign({}, (NavItemComponent === 'a' |
| 29 |
? { tabIndex: isDisabled ? -1 : undefined, href, target } |
| 30 |
: { disabled: isDisabled }), (id && { id: id.toString() }), { onClick: (e) => { |
| 31 |
e.stopPropagation(); |
| 32 |
isExpandable ? setIsExpanded(!isExpanded || isCurrent) : onClick === null || onClick === void 0 ? void 0 : onClick(e, stepIndex); |
| 33 |
}, className: (0, react_styles_1.css)(wizard_1.default.wizardNavLink, isCurrent && wizard_1.default.modifiers.current, isDisabled && wizard_1.default.modifiers.disabled, status === types_1.WizardNavItemStatus.Error && wizard_1.default.modifiers.danger, status === types_1.WizardNavItemStatus.Success && wizard_1.default.modifiers.success, status === types_1.WizardNavItemStatus.Warning && wizard_1.default.modifiers.warning), "aria-disabled": isDisabled ? true : null, "aria-current": isCurrent && !children ? 'step' : false }, (isExpandable && { 'aria-expanded': isExpanded }), ouiaProps, { children: [status !== types_1.WizardNavItemStatus.Default && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { className: "pf-v6-screen-reader", children: [", ", status] }), (0, jsx_runtime_1.jsxs)("span", { className: (0, react_styles_1.css)(wizard_1.default.wizardNavLinkStatusIcon), children: [status === types_1.WizardNavItemStatus.Error && (0, jsx_runtime_1.jsx)(rh_ui_error_fill_icon_1.default, {}), status === types_1.WizardNavItemStatus.Success && (0, jsx_runtime_1.jsx)(rh_ui_check_circle_fill_icon_1.default, {}), status === types_1.WizardNavItemStatus.Warning && (0, jsx_runtime_1.jsx)(rh_ui_warning_fill_icon_1.default, {})] })] })), (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, { "aria-label": `${isCurrent ? 'Collapse' : 'Expand'} step icon` }) }) })] })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: content })) })] })), children] }))); |
| 34 |
}; |
| 35 |
exports.WizardNavItem = WizardNavItem; |
| 36 |
exports.WizardNavItem.displayName = 'WizardNavItem'; |
| 37 |
//# sourceMappingURL=WizardNavItem.js.map |