Debian Codegraph @

node/@patternfly/react-core/dist/esm/components/ProgressStepper/ProgressStep.js

raw
1 import { __rest } from "tslib";
2 import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3 import { useRef } from 'react';
4 import styles from '@patternfly/react-styles/css/components/ProgressStepper/progress-stepper.mjs';
5 import { css } from '@patternfly/react-styles';
6 import RhUiCheckCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-check-circle-fill-icon';
7 import ResourcesFullIcon from '@patternfly/react-icons/dist/esm/icons/resources-full-icon';
8 import RhUiWarningFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-warning-fill-icon';
9 import RhUiErrorFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-error-fill-icon';
10 export var ProgressStepVariant;
11 (function (ProgressStepVariant) {
12 ProgressStepVariant["default"] = "default";
13 ProgressStepVariant["pending"] = "pending";
14 ProgressStepVariant["success"] = "success";
15 ProgressStepVariant["info"] = "info";
16 ProgressStepVariant["danger"] = "danger";
17 ProgressStepVariant["warning"] = "warning";
18 })(ProgressStepVariant || (ProgressStepVariant = {}));
19 const variantIcons = {
20 default: undefined,
21 pending: undefined,
22 success: _jsx(RhUiCheckCircleFillIcon, {}),
23 info: _jsx(ResourcesFullIcon, {}),
24 warning: _jsx(RhUiWarningFillIcon, {}),
25 danger: _jsx(RhUiErrorFillIcon, {})
26 };
27 const variantStyle = {
28 default: '',
29 info: styles.modifiers.info,
30 success: styles.modifiers.success,
31 pending: styles.modifiers.pending,
32 warning: styles.modifiers.warning,
33 danger: styles.modifiers.danger
34 };
35 export const ProgressStep = (_a) => {
36 var { children, className, variant, isCurrent, description, icon, titleId, 'aria-label': ariaLabel, popoverRender } = _a, props = __rest(_a, ["children", "className", "variant", "isCurrent", "description", "icon", "titleId", 'aria-label', "popoverRender"]);
37 const _icon = icon !== undefined ? icon : variantIcons[variant];
38 const Component = popoverRender !== undefined ? 'button' : 'div';
39 const stepRef = useRef(undefined);
40 if (props.id === undefined || titleId === undefined) {
41 /* eslint-disable no-console */
42 console.warn('ProgressStep: The titleId and id properties are required to make this component accessible, and one or both of these properties are missing.');
43 }
44 return (_jsxs("li", Object.assign({ className: css(styles.progressStepperStep, variantStyle[variant], isCurrent && styles.modifiers.current, className), "aria-label": ariaLabel,
45 // CSS style `display: contents` gives this li a generic role, we need to override that
46 role: "listitem" }, (isCurrent && { 'aria-current': 'step' }), props, { children: [_jsx("div", { className: css(styles.progressStepperStepConnector), children: _jsx("span", { className: css(styles.progressStepperStepIcon), children: _icon && _icon }) }), _jsxs("div", { className: css(styles.progressStepperStepMain), children: [_jsxs(Component, Object.assign({ className: css(styles.progressStepperStepTitle, popoverRender && styles.modifiers.helpText), id: titleId, ref: stepRef }, (popoverRender && { type: 'button' }), (props.id !== undefined &&
47 titleId !== undefined &&
48 popoverRender && { 'aria-labelledby': `${props.id} ${titleId}` }), { children: [children, popoverRender && popoverRender(stepRef)] })), description && _jsx("div", { className: css(styles.progressStepperStepDescription), children: description })] })] })));
49 };
50 ProgressStep.displayName = 'ProgressStep';
51 //# sourceMappingURL=ProgressStep.js.map