carbon-react 125.10.0 → 125.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/esm/components/heading/heading.style.d.ts +1 -1
  3. package/esm/components/select/option/option.component.d.ts +1 -1
  4. package/esm/components/select/option/option.component.js +5 -3
  5. package/esm/components/select/option-group-header/option-group-header.component.js +6 -2
  6. package/esm/components/select/option-row/option-row.component.js +6 -4
  7. package/esm/components/select/select-list/select-list.component.js +26 -29
  8. package/esm/components/step-flow/index.d.ts +2 -0
  9. package/esm/components/step-flow/index.js +1 -0
  10. package/esm/components/step-flow/step-flow.component.d.ts +33 -0
  11. package/esm/components/step-flow/step-flow.component.js +277 -0
  12. package/esm/components/step-flow/step-flow.style.d.ts +12 -0
  13. package/esm/components/step-flow/step-flow.style.js +42 -0
  14. package/esm/components/typography/index.d.ts +1 -1
  15. package/esm/components/typography/typography.component.d.ts +3 -1
  16. package/esm/components/typography/typography.component.js +3 -1
  17. package/esm/locales/__internal__/pl-pl.js +5 -0
  18. package/esm/locales/en-gb.js +5 -0
  19. package/esm/locales/locale.d.ts +5 -0
  20. package/lib/components/heading/heading.style.d.ts +1 -1
  21. package/lib/components/select/option/option.component.d.ts +1 -1
  22. package/lib/components/select/option/option.component.js +4 -2
  23. package/lib/components/select/option-group-header/option-group-header.component.js +8 -2
  24. package/lib/components/select/option-row/option-row.component.js +5 -3
  25. package/lib/components/select/select-list/select-list.component.js +26 -29
  26. package/lib/components/step-flow/index.d.ts +2 -0
  27. package/lib/components/step-flow/index.js +13 -0
  28. package/lib/components/step-flow/package.json +6 -0
  29. package/lib/components/step-flow/step-flow.component.d.ts +33 -0
  30. package/lib/components/step-flow/step-flow.component.js +285 -0
  31. package/lib/components/step-flow/step-flow.style.d.ts +12 -0
  32. package/lib/components/step-flow/step-flow.style.js +48 -0
  33. package/lib/components/typography/index.d.ts +1 -1
  34. package/lib/components/typography/typography.component.d.ts +3 -1
  35. package/lib/components/typography/typography.component.js +3 -1
  36. package/lib/locales/__internal__/pl-pl.js +5 -0
  37. package/lib/locales/en-gb.js +5 -0
  38. package/lib/locales/locale.d.ts +5 -0
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Carbon [![npm](https://img.shields.io/npm/v/carbon-react.svg)](https://www.npmjs.com/package/carbon-react) [![Cypress](https://github.com/Sage/carbon/actions/workflows/cypress.yml/badge.svg)](https://github.com/Sage/carbon/actions/workflows/cypress.yml) [![Playwright](https://github.com/Sage/carbon/actions/workflows/playwright.yml/badge.svg)](https://github.com/Sage/carbon/actions/workflows/playwright.yml)
2
2
 
3
- Carbon is a [React](https://facebook.github.io/react/) component library developed by Sage.
3
+ Carbon is a [React](https://react.dev/) component library developed by Sage.
4
4
 
5
5
  ## Getting started
6
6
 
@@ -8,7 +8,7 @@ Our [getting started guide](https://carbon.sage.com/?path=/story/getting-started
8
8
 
9
9
  ## Examples
10
10
 
11
- See the [storybook](https://carbon.sage.com/) for live examples.
11
+ See our [docs](https://carbon.sage.com/) for live examples.
12
12
 
13
13
  ## Browser Support
14
14
 
@@ -12,7 +12,7 @@ declare type StyledHeadingTitleProps = {
12
12
  withMargin?: boolean;
13
13
  };
14
14
  declare const StyledHeadingTitle: import("styled-components").StyledComponent<{
15
- ({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, isDisabled, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
15
+ ({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, isDisabled, "aria-hidden": ariaHidden, ...rest }: import("../typography").TypographyProps): import("react").JSX.Element;
16
16
  displayName: string;
17
17
  }, any, StyledHeadingTitleProps, never>;
18
18
  declare const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { TagProps } from "__internal__/utils/helpers/tags";
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
3
3
  export interface OptionProps extends Omit<React.InputHTMLAttributes<HTMLLIElement>, "value" | "onSelect" | "onClick">, TagProps {
4
4
  /**
5
5
  * Unique identifier for the component.
@@ -1,6 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React, { useContext } from "react";
2
+ import React, { useContext, useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import guid from "../../../__internal__/utils/helpers/guid";
4
5
  import StyledOption from "./option.style";
5
6
  import SelectListContext from "../__internal__/select-list-context";
6
7
  const Option = /*#__PURE__*/React.forwardRef(({
@@ -18,6 +19,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
18
19
  }, ref) => {
19
20
  const selectListContext = useContext(SelectListContext);
20
21
  let isSelected = selectListContext.currentOptionsListIndex === index;
22
+ const internalIdRef = useRef(id || guid());
21
23
  if (selectListContext.multiselectValues) {
22
24
  isSelected = selectListContext.multiselectValues.includes(value);
23
25
  }
@@ -29,7 +31,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
29
31
  onSelect?.({
30
32
  text,
31
33
  value,
32
- id
34
+ id: internalIdRef.current
33
35
  });
34
36
  } else {
35
37
  onSelect?.();
@@ -37,7 +39,7 @@ const Option = /*#__PURE__*/React.forwardRef(({
37
39
  }
38
40
  }
39
41
  return /*#__PURE__*/React.createElement(StyledOption, _extends({
40
- id: id,
42
+ id: internalIdRef.current,
41
43
  ref: ref,
42
44
  "aria-selected": isSelected,
43
45
  "aria-disabled": disabled,
@@ -1,16 +1,20 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React from "react";
2
+ import React, { useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import guid from "../../../__internal__/utils/helpers/guid";
4
5
  import StyledOptionGroupHeader from "./option-group-header.style";
5
6
  import Icon from "../../icon";
6
7
  const OptionGroupHeader = /*#__PURE__*/React.forwardRef(({
7
8
  label,
8
9
  icon,
9
10
  style,
11
+ id,
10
12
  ...rest
11
13
  }, ref) => {
14
+ const internalIdRef = useRef(id || guid());
12
15
  return /*#__PURE__*/React.createElement(StyledOptionGroupHeader, _extends({
13
- style: style
16
+ style: style,
17
+ id: internalIdRef.current
14
18
  }, rest, {
15
19
  ref: ref
16
20
  }), icon && /*#__PURE__*/React.createElement(Icon, {
@@ -1,6 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React, { useContext } from "react";
2
+ import React, { useContext, useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
+ import guid from "../../../__internal__/utils/helpers/guid";
4
5
  import StyledOptionRow from "./option-row.style";
5
6
  import SelectListContext from "../__internal__/select-list-context";
6
7
  const OptionRow = /*#__PURE__*/React.forwardRef(({
@@ -15,14 +16,15 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
15
16
  style,
16
17
  ...rest
17
18
  }, ref) => {
19
+ const internalIdRef = useRef(id || guid());
18
20
  const handleClick = () => {
19
21
  if (disabled) {
20
22
  return;
21
23
  }
22
24
  onSelect?.({
23
- id,
24
25
  text,
25
- value
26
+ value,
27
+ id: internalIdRef.current
26
28
  });
27
29
  };
28
30
  const selectListContext = useContext(SelectListContext);
@@ -31,7 +33,7 @@ const OptionRow = /*#__PURE__*/React.forwardRef(({
31
33
  isSelected = selectListContext.multiselectValues.includes(value);
32
34
  }
33
35
  return /*#__PURE__*/React.createElement(StyledOptionRow, _extends({
34
- id: id,
36
+ id: internalIdRef.current,
35
37
  ref: ref,
36
38
  "aria-selected": isSelected,
37
39
  "aria-disabled": disabled,
@@ -17,7 +17,6 @@ import ListActionButton from "../list-action-button";
17
17
  import StyledSelectListContainer from "./select-list-container.style";
18
18
  import Loader from "../../loader";
19
19
  import Option from "../option";
20
- import guid from "../../../__internal__/utils/helpers/guid";
21
20
  import SelectListContext from "../__internal__/select-list-context";
22
21
  const TABLE_HEADER_HEIGHT = 48;
23
22
  const SCROLL_OPTIONS = {
@@ -92,16 +91,23 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
92
91
  rangeExtractor
93
92
  });
94
93
  const items = virtualizer.getVirtualItems();
94
+ const childrenList = useMemo(() => React.Children.toArray(children), [children]);
95
+ const getIndexOfMatch = useCallback(valueToMatch => {
96
+ return childrenList.findIndex(child => /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch);
97
+ }, [childrenList]);
95
98
 
96
99
  // getVirtualItems returns an empty array of items if the select list is currently closed - which is correct visually but
97
100
  // we need to ensure that any currently-selected option is still in the DOM to avoid any accessibility issues.
98
101
  // The isOpen prop will ensure that no options are visible regardless of what is in the items array.
99
- if (items.length === 0 && currentOptionsListIndex !== -1) {
100
- // only index property is required with the item not visible so the following type assertion, even though incorrect,
101
- // should be OK
102
- items.push({
103
- index: currentOptionsListIndex
104
- });
102
+ if (items.length === 0) {
103
+ const currentIndex = highlightedValue ? getIndexOfMatch(highlightedValue) : currentOptionsListIndex;
104
+ if (currentIndex > -1) {
105
+ // only index property is required with the item not visible so the following type assertion, even though incorrect,
106
+ // should be OK
107
+ items.push({
108
+ index: currentIndex
109
+ });
110
+ }
105
111
  }
106
112
  const listHeight = virtualizer.getTotalSize();
107
113
  useEffect(() => {
@@ -129,18 +135,9 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
129
135
  selectionConfirmed: true
130
136
  });
131
137
  }, [onSelect]);
132
- const childIdsRef = useRef(null);
133
-
134
- // childIds should be stable except when children are added or removed - can't use useMemo
135
- // as that isn't absolutely guaranteed to never rerun when dependencies haven't changed.
136
- const setChildIds = () => {
137
- childIdsRef.current = React.Children.map(children, child => /*#__PURE__*/React.isValidElement(child) && child?.props.id || guid()) || /* istanbul ignore next */null;
138
- };
139
- if (childIdsRef.current?.length !== React.Children.count(children)) {
140
- setChildIds();
141
- }
142
- const childIds = childIdsRef.current;
143
- const childrenList = useMemo(() => React.Children.toArray(children), [children]);
138
+ const childElementRefs = useRef(Array.from({
139
+ length: React.Children.count(children)
140
+ }));
144
141
  const optionChildrenList = useMemo(() => childrenList.filter(child => /*#__PURE__*/React.isValidElement(child) && (child.type === Option || child.type === OptionRow)), [childrenList]);
145
142
  const {
146
143
  measureElement
@@ -166,7 +163,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
166
163
  const isOption = optionChildIndex > -1;
167
164
  const newProps = {
168
165
  index,
169
- id: childIds ? childIds[index] : /* istanbul ignore next */undefined,
170
166
  onSelect: handleSelect,
171
167
  hidden: isLoading && childrenList.length === 1,
172
168
  // these need to be inline styles rather than implemented in styled-components to avoid it generating thousands of classes
@@ -175,8 +171,12 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
175
171
  },
176
172
  "aria-setsize": isOption ? optionChildrenList.length : undefined,
177
173
  "aria-posinset": isOption ? optionChildIndex + 1 : undefined,
178
- // needed to dynamically compute the size
179
- ref: measureCallback,
174
+ ref: optionElement => {
175
+ // needed to dynamically compute the size
176
+ measureCallback(optionElement);
177
+ // add the DOM element to the array of refs
178
+ childElementRefs.current[index] = optionElement;
179
+ },
180
180
  "data-index": index
181
181
  };
182
182
  return /*#__PURE__*/React.cloneElement(child, newProps);
@@ -194,9 +194,6 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
194
194
  }
195
195
  return nextIndex;
196
196
  }, [childrenList, lastOptionIndex, isLoading]);
197
- const getIndexOfMatch = useCallback(valueToMatch => {
198
- return childrenList.findIndex(child => /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch);
199
- }, [childrenList]);
200
197
  const highlightNextItem = useCallback(key => {
201
198
  let currentIndex = currentOptionsListIndex;
202
199
  if (highlightedValue) {
@@ -215,10 +212,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
215
212
  text,
216
213
  value,
217
214
  selectionType: "navigationKey",
218
- id: childIds ? childIds[nextIndex] : /* istanbul ignore next */undefined,
215
+ id: childElementRefs.current[nextIndex]?.id,
219
216
  selectionConfirmed: false
220
217
  });
221
- }, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect, childIds]);
218
+ }, [childrenList, currentOptionsListIndex, getIndexOfMatch, getNextHighlightableItemIndex, highlightedValue, onSelect]);
222
219
  const handleActionButtonTab = useCallback((event, isActionButtonFocused) => {
223
220
  if (isActionButtonFocused) {
224
221
  onSelect({
@@ -262,7 +259,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
262
259
  value
263
260
  } = currentOption.props;
264
261
  onSelect({
265
- id: childIds ? childIds[currentOptionsListIndex] : /* istanbul ignore next */undefined,
262
+ id: childElementRefs.current[currentOptionsListIndex]?.id,
266
263
  text,
267
264
  value,
268
265
  selectionType: "enterKey",
@@ -272,7 +269,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
272
269
  focusOnAnchor();
273
270
  highlightNextItem(key);
274
271
  }
275
- }, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen, childIds]);
272
+ }, [childrenList, listActionButton, handleActionButtonTab, onSelectListClose, currentOptionsListIndex, onSelect, highlightNextItem, focusOnAnchor, isOpen]);
276
273
  const handleEscapeKey = useCallback(event => {
277
274
  if (event.key === "Escape") {
278
275
  onSelectListClose();
@@ -0,0 +1,2 @@
1
+ export { default as StepFlow } from "./step-flow.component";
2
+ export type { StepFlowProps } from "./step-flow.component";
@@ -0,0 +1 @@
1
+ export { default as StepFlow } from "./step-flow.component";
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
4
+ export declare type Steps = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
5
+ export interface StepFlowProps extends MarginProps, TagProps {
6
+ /** A category for the user journey. */
7
+ category?: string;
8
+ /** The title of the current step. */
9
+ title: string;
10
+ /** Set the variant of the internal 'Typography' component which contains the title.
11
+ * However, despite the chosen variant the styling will always be overridden.
12
+ */
13
+ titleVariant?: "h1" | "h2";
14
+ /** The total steps in the user journey. */
15
+ totalSteps: Steps;
16
+ /**
17
+ * The current step of the user journey. If the set `currentStep` is higher than
18
+ * `totalSteps`the value of `currentStep` will be that of `totalSteps` instead.
19
+ */
20
+ currentStep: Steps;
21
+ /** Determines if the progress indicator is shown. */
22
+ showProgressIndicator?: boolean;
23
+ /** Determines if the close icon button is shown */
24
+ showCloseIcon?: boolean;
25
+ /** function runs when user click dismiss button */
26
+ onDismiss?: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement>) => void;
27
+ }
28
+ export declare type StepFlowHandle = {
29
+ /** Programmatically focus on root container of Dialog. */
30
+ focus: () => void;
31
+ } | null;
32
+ export declare const StepFlow: React.ForwardRefExoticComponent<StepFlowProps & React.RefAttributes<StepFlowHandle>>;
33
+ export default StepFlow;
@@ -0,0 +1,277 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React, { useImperativeHandle, useRef, forwardRef } from "react";
3
+ import PropTypes from "prop-types";
4
+ import Icon from "../icon";
5
+ import IconButton from "../icon-button";
6
+ import { StyledStepFlow, StyledStepContent, StyledStepContentText, StyledStepLabelAndProgress, StyledProgressIndicatorBar, StyledProgressIndicator, StyledTitleFocusWrapper } from "./step-flow.style";
7
+ import tagComponent from "../../__internal__/utils/helpers/tags/tags";
8
+ import Typography from "../typography";
9
+ import useLocale from "../../hooks/__internal__/useLocale";
10
+ const StepFlow = /*#__PURE__*/forwardRef(({
11
+ category,
12
+ title,
13
+ titleVariant,
14
+ totalSteps,
15
+ currentStep,
16
+ showProgressIndicator = false,
17
+ showCloseIcon = false,
18
+ onDismiss,
19
+ ...rest
20
+ }, ref) => {
21
+ const totalStepsArray = Array.from({
22
+ length: totalSteps
23
+ }, (_, index) => index + 1);
24
+ const validatedCurrentStep = currentStep > totalSteps ? totalSteps : currentStep;
25
+ let currentStepWarnTriggered = false;
26
+ let noRefWarnTriggered = false;
27
+
28
+ /* eslint-disable no-console */
29
+ if (!currentStepWarnTriggered && currentStep > totalSteps) {
30
+ currentStepWarnTriggered = true;
31
+ console.warn("[WARNING] The `currentStep` prop should not be higher than the `totalSteps`prop in `StepFlow`." + " Please ensure `currentStep`s value does not exceed that of `totalSteps`, in the meantime" + " we have set `currentStep` value to that of `totalSteps`, and all indicators have been marked as completed.");
32
+ }
33
+ if (!noRefWarnTriggered && !ref) {
34
+ noRefWarnTriggered = true;
35
+ console.warn("[WARNING] A `ref` should be provided to ensure focus is programmatically focused back to a title div," + " this ensures screen reader users are informed regarding any changes and can navigate back down the page.");
36
+ }
37
+ const progressIndicators = totalStepsArray.map(step => {
38
+ const generateDataState = () => {
39
+ if (step === validatedCurrentStep) {
40
+ return "in-progress";
41
+ }
42
+ if (step < validatedCurrentStep) {
43
+ return "is-completed";
44
+ }
45
+ return "not-completed";
46
+ };
47
+ return /*#__PURE__*/React.createElement(StyledProgressIndicator, {
48
+ key: step,
49
+ "aria-hidden": "true",
50
+ "data-element": "progress-indicator",
51
+ isCompleted: step < validatedCurrentStep,
52
+ isInProgress: step === validatedCurrentStep,
53
+ "data-state": generateDataState()
54
+ }, "\xA0");
55
+ });
56
+ const locale = useLocale();
57
+ const closeIcon = /*#__PURE__*/React.createElement(IconButton, {
58
+ "data-element": "close",
59
+ "aria-label": locale.stepFlow.closeIconAriaLabel?.(),
60
+ onClick: onDismiss
61
+ }, /*#__PURE__*/React.createElement(Icon, {
62
+ type: "close"
63
+ }));
64
+ const titleRef = useRef(null);
65
+ useImperativeHandle(ref, () => ({
66
+ focus() {
67
+ titleRef.current?.focus();
68
+ }
69
+ }), []);
70
+ const stepFlowTitle = /*#__PURE__*/React.createElement(StyledTitleFocusWrapper, {
71
+ "data-element": "title-text-wrapper",
72
+ tabIndex: -1,
73
+ ref: titleRef
74
+ }, /*#__PURE__*/React.createElement(Typography, {
75
+ variant: titleVariant || "h1",
76
+ "data-element": "title-text"
77
+ }, /*#__PURE__*/React.createElement(Typography, {
78
+ fontWeight: "900",
79
+ fontSize: "var(--fontSizes600)",
80
+ lineHeight: "var(--sizing375)",
81
+ variant: "span",
82
+ "aria-hidden": "true",
83
+ "data-element": "visible-title-text"
84
+ }, title), /*#__PURE__*/React.createElement(Typography, {
85
+ variant: "span",
86
+ "data-element": "visually-hidden-title-text",
87
+ screenReaderOnly: true
88
+ }, locale.stepFlow.screenReaderOnlyTitle(title, validatedCurrentStep, totalSteps, category))));
89
+ const stepFlowLabel = /*#__PURE__*/React.createElement(Typography, {
90
+ variant: "span",
91
+ fontWeight: "400",
92
+ fontSize: "var(--fontSizes200)",
93
+ lineHeight: "var(--sizing300)",
94
+ "data-element": "step-label",
95
+ "aria-hidden": "true"
96
+ }, locale.stepFlow.stepLabel(validatedCurrentStep, totalSteps));
97
+ return /*#__PURE__*/React.createElement(StyledStepFlow, _extends({}, rest, tagComponent("step-flow", rest)), /*#__PURE__*/React.createElement(StyledStepContent, null, category ? /*#__PURE__*/React.createElement(StyledStepContentText, null, /*#__PURE__*/React.createElement(Typography, {
98
+ fontWeight: "500",
99
+ fontSize: "var(--fontSizes100)",
100
+ lineHeight: "var(--sizing250)",
101
+ variant: "span",
102
+ "data-element": "category-text",
103
+ "aria-hidden": "true"
104
+ }, category), stepFlowTitle) : stepFlowTitle, showCloseIcon ? closeIcon : null), showProgressIndicator ? /*#__PURE__*/React.createElement(StyledStepLabelAndProgress, null, stepFlowLabel, /*#__PURE__*/React.createElement(StyledProgressIndicatorBar, {
105
+ "data-element": "progress-indicator-bar"
106
+ }, progressIndicators)) : stepFlowLabel);
107
+ });
108
+ StepFlow.propTypes = {
109
+ "category": PropTypes.string,
110
+ "children": PropTypes.node,
111
+ "currentStep": PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8]).isRequired,
112
+ "data-component": PropTypes.string,
113
+ "data-element": PropTypes.string,
114
+ "data-role": PropTypes.string,
115
+ "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
116
+ "__@toStringTag": PropTypes.string.isRequired,
117
+ "description": PropTypes.string,
118
+ "toString": PropTypes.func.isRequired,
119
+ "valueOf": PropTypes.func.isRequired
120
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
121
+ "__@toStringTag": PropTypes.string.isRequired,
122
+ "description": PropTypes.string,
123
+ "toString": PropTypes.func.isRequired,
124
+ "valueOf": PropTypes.func.isRequired
125
+ }), PropTypes.string]),
126
+ "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
127
+ "__@toStringTag": PropTypes.string.isRequired,
128
+ "description": PropTypes.string,
129
+ "toString": PropTypes.func.isRequired,
130
+ "valueOf": PropTypes.func.isRequired
131
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
132
+ "__@toStringTag": PropTypes.string.isRequired,
133
+ "description": PropTypes.string,
134
+ "toString": PropTypes.func.isRequired,
135
+ "valueOf": PropTypes.func.isRequired
136
+ }), PropTypes.string]),
137
+ "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
138
+ "__@toStringTag": PropTypes.string.isRequired,
139
+ "description": PropTypes.string,
140
+ "toString": PropTypes.func.isRequired,
141
+ "valueOf": PropTypes.func.isRequired
142
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
143
+ "__@toStringTag": PropTypes.string.isRequired,
144
+ "description": PropTypes.string,
145
+ "toString": PropTypes.func.isRequired,
146
+ "valueOf": PropTypes.func.isRequired
147
+ }), PropTypes.string]),
148
+ "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
149
+ "__@toStringTag": PropTypes.string.isRequired,
150
+ "description": PropTypes.string,
151
+ "toString": PropTypes.func.isRequired,
152
+ "valueOf": PropTypes.func.isRequired
153
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
154
+ "__@toStringTag": PropTypes.string.isRequired,
155
+ "description": PropTypes.string,
156
+ "toString": PropTypes.func.isRequired,
157
+ "valueOf": PropTypes.func.isRequired
158
+ }), PropTypes.string]),
159
+ "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
160
+ "__@toStringTag": PropTypes.string.isRequired,
161
+ "description": PropTypes.string,
162
+ "toString": PropTypes.func.isRequired,
163
+ "valueOf": PropTypes.func.isRequired
164
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
165
+ "__@toStringTag": PropTypes.string.isRequired,
166
+ "description": PropTypes.string,
167
+ "toString": PropTypes.func.isRequired,
168
+ "valueOf": PropTypes.func.isRequired
169
+ }), PropTypes.string]),
170
+ "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
171
+ "__@toStringTag": PropTypes.string.isRequired,
172
+ "description": PropTypes.string,
173
+ "toString": PropTypes.func.isRequired,
174
+ "valueOf": PropTypes.func.isRequired
175
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
176
+ "__@toStringTag": PropTypes.string.isRequired,
177
+ "description": PropTypes.string,
178
+ "toString": PropTypes.func.isRequired,
179
+ "valueOf": PropTypes.func.isRequired
180
+ }), PropTypes.string]),
181
+ "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
182
+ "__@toStringTag": PropTypes.string.isRequired,
183
+ "description": PropTypes.string,
184
+ "toString": PropTypes.func.isRequired,
185
+ "valueOf": PropTypes.func.isRequired
186
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
187
+ "__@toStringTag": PropTypes.string.isRequired,
188
+ "description": PropTypes.string,
189
+ "toString": PropTypes.func.isRequired,
190
+ "valueOf": PropTypes.func.isRequired
191
+ }), PropTypes.string]),
192
+ "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
193
+ "__@toStringTag": PropTypes.string.isRequired,
194
+ "description": PropTypes.string,
195
+ "toString": PropTypes.func.isRequired,
196
+ "valueOf": PropTypes.func.isRequired
197
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
198
+ "__@toStringTag": PropTypes.string.isRequired,
199
+ "description": PropTypes.string,
200
+ "toString": PropTypes.func.isRequired,
201
+ "valueOf": PropTypes.func.isRequired
202
+ }), PropTypes.string]),
203
+ "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
204
+ "__@toStringTag": PropTypes.string.isRequired,
205
+ "description": PropTypes.string,
206
+ "toString": PropTypes.func.isRequired,
207
+ "valueOf": PropTypes.func.isRequired
208
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
209
+ "__@toStringTag": PropTypes.string.isRequired,
210
+ "description": PropTypes.string,
211
+ "toString": PropTypes.func.isRequired,
212
+ "valueOf": PropTypes.func.isRequired
213
+ }), PropTypes.string]),
214
+ "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
215
+ "__@toStringTag": PropTypes.string.isRequired,
216
+ "description": PropTypes.string,
217
+ "toString": PropTypes.func.isRequired,
218
+ "valueOf": PropTypes.func.isRequired
219
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
220
+ "__@toStringTag": PropTypes.string.isRequired,
221
+ "description": PropTypes.string,
222
+ "toString": PropTypes.func.isRequired,
223
+ "valueOf": PropTypes.func.isRequired
224
+ }), PropTypes.string]),
225
+ "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
226
+ "__@toStringTag": PropTypes.string.isRequired,
227
+ "description": PropTypes.string,
228
+ "toString": PropTypes.func.isRequired,
229
+ "valueOf": PropTypes.func.isRequired
230
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
231
+ "__@toStringTag": PropTypes.string.isRequired,
232
+ "description": PropTypes.string,
233
+ "toString": PropTypes.func.isRequired,
234
+ "valueOf": PropTypes.func.isRequired
235
+ }), PropTypes.string]),
236
+ "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
237
+ "__@toStringTag": PropTypes.string.isRequired,
238
+ "description": PropTypes.string,
239
+ "toString": PropTypes.func.isRequired,
240
+ "valueOf": PropTypes.func.isRequired
241
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
242
+ "__@toStringTag": PropTypes.string.isRequired,
243
+ "description": PropTypes.string,
244
+ "toString": PropTypes.func.isRequired,
245
+ "valueOf": PropTypes.func.isRequired
246
+ }), PropTypes.string]),
247
+ "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
248
+ "__@toStringTag": PropTypes.string.isRequired,
249
+ "description": PropTypes.string,
250
+ "toString": PropTypes.func.isRequired,
251
+ "valueOf": PropTypes.func.isRequired
252
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
253
+ "__@toStringTag": PropTypes.string.isRequired,
254
+ "description": PropTypes.string,
255
+ "toString": PropTypes.func.isRequired,
256
+ "valueOf": PropTypes.func.isRequired
257
+ }), PropTypes.string]),
258
+ "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
259
+ "__@toStringTag": PropTypes.string.isRequired,
260
+ "description": PropTypes.string,
261
+ "toString": PropTypes.func.isRequired,
262
+ "valueOf": PropTypes.func.isRequired
263
+ }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
264
+ "__@toStringTag": PropTypes.string.isRequired,
265
+ "description": PropTypes.string,
266
+ "toString": PropTypes.func.isRequired,
267
+ "valueOf": PropTypes.func.isRequired
268
+ }), PropTypes.string]),
269
+ "onDismiss": PropTypes.func,
270
+ "showCloseIcon": PropTypes.bool,
271
+ "showProgressIndicator": PropTypes.bool,
272
+ "title": PropTypes.string.isRequired,
273
+ "titleVariant": PropTypes.oneOf(["h1", "h2"]),
274
+ "totalSteps": PropTypes.oneOf([1, 2, 3, 4, 5, 6, 7, 8]).isRequired
275
+ };
276
+ export { StepFlow };
277
+ export default StepFlow;
@@ -0,0 +1,12 @@
1
+ declare const StyledStepFlow: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ declare const StyledStepContent: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ declare const StyledStepContentText: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ declare const StyledTitleFocusWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ declare const StyledStepLabelAndProgress: import("styled-components").StyledComponent<"div", any, {}, never>;
6
+ declare const StyledProgressIndicatorBar: import("styled-components").StyledComponent<"div", any, {}, never>;
7
+ interface StyledProgressIndicatorProps {
8
+ isCompleted: boolean;
9
+ isInProgress: boolean;
10
+ }
11
+ declare const StyledProgressIndicator: import("styled-components").StyledComponent<"span", any, StyledProgressIndicatorProps, never>;
12
+ export { StyledStepFlow, StyledStepContent, StyledStepContentText, StyledTitleFocusWrapper, StyledStepLabelAndProgress, StyledProgressIndicatorBar, StyledProgressIndicator, };
@@ -0,0 +1,42 @@
1
+ import styled from "styled-components";
2
+ import { margin } from "styled-system";
3
+ const StyledStepFlow = styled.div`
4
+ ${margin}
5
+ `;
6
+ const StyledStepContent = styled.div`
7
+ display: flex;
8
+ justify-content: space-between;
9
+ margin-bottom: var(--sizing200);
10
+ `;
11
+ const StyledStepContentText = styled.div`
12
+ display: flex;
13
+ flex-direction: column;
14
+ `;
15
+ const StyledTitleFocusWrapper = styled.div``;
16
+ const StyledStepLabelAndProgress = styled.div`
17
+ margin-top: var(--sizing125);
18
+ `;
19
+ const StyledProgressIndicatorBar = styled.div`
20
+ display: flex;
21
+ margin-top: var(--sizing100);
22
+ `;
23
+ function calculateProgressIndicatorColor({
24
+ isCompleted,
25
+ isInProgress
26
+ }) {
27
+ if (isInProgress) {
28
+ return "var(--colorsUtilityYin090)";
29
+ }
30
+ if (isCompleted) {
31
+ return "var(--colorsSemanticPositive500)";
32
+ }
33
+ return "var(--colorsActionDisabled600)";
34
+ }
35
+ const StyledProgressIndicator = styled.span`
36
+ background-color: ${calculateProgressIndicatorColor};
37
+ width: 100%;
38
+ height: 8px;
39
+ border-radius: 8px;
40
+ margin-right: 12px;
41
+ `;
42
+ export { StyledStepFlow, StyledStepContent, StyledStepContentText, StyledTitleFocusWrapper, StyledStepLabelAndProgress, StyledProgressIndicatorBar, StyledProgressIndicator };
@@ -1,4 +1,4 @@
1
1
  export { default } from "./typography.component";
2
2
  export { List, ListItem } from "./list.component";
3
- export type { TypographyProps } from "./typography.component";
3
+ export type { TypographyProps, VariantTypes } from "./typography.component";
4
4
  export type { ListProps, ListItemProps } from "./list.component";
@@ -55,9 +55,11 @@ export interface TypographyProps extends SpaceProps, TagProps {
55
55
  * Override the default color of the rendered element to match disabled styling
56
56
  * */
57
57
  isDisabled?: boolean;
58
+ /** @private @ignore Set whether the component should be recognised by assistive technologies */
59
+ "aria-hidden"?: "true" | "false";
58
60
  }
59
61
  export declare const Typography: {
60
- ({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, isDisabled, ...rest }: TypographyProps): React.JSX.Element;
62
+ ({ "data-component": dataComponent, variant, as, id, fontSize, fontWeight, textTransform, lineHeight, textDecoration, display, listStyleType, whiteSpace, wordWrap, textAlign, textOverflow, truncate, color, backgroundColor, bg, opacity, children, className, screenReaderOnly, isDisabled, "aria-hidden": ariaHidden, ...rest }: TypographyProps): React.JSX.Element;
61
63
  displayName: string;
62
64
  };
63
65
  export default Typography;