carbon-react 142.11.6 → 142.11.8

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/esm/__internal__/checkable-input/checkable-input.component.js +3 -1
  2. package/esm/__internal__/utils/helpers/tags/tags-specs/index.d.ts +1 -1
  3. package/esm/__internal__/utils/helpers/tags/tags-specs/index.js +1 -1
  4. package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +2 -2
  5. package/esm/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +3 -11
  6. package/esm/__internal__/validation-message/validation-message.component.js +2 -1
  7. package/esm/components/accordion/accordion.component.js +4 -1
  8. package/esm/components/content/content.component.js +2 -0
  9. package/esm/components/detail/detail.component.js +1 -0
  10. package/esm/components/flat-table/__internal__/build-position-map.js +2 -0
  11. package/esm/components/flat-table/flat-table-row/flat-table-row.component.d.ts +2 -1
  12. package/esm/components/flat-table/flat-table-row/flat-table-row.component.js +13 -2
  13. package/esm/components/flat-table/flat-table-row/flat-table-row.style.js +2 -1
  14. package/esm/components/flat-table/flat-table.component.d.ts +2 -1
  15. package/esm/components/flat-table/flat-table.component.js +9 -4
  16. package/esm/components/switch/__internal__/switch-slider.component.js +5 -2
  17. package/esm/components/switch/switch.component.js +7 -1
  18. package/esm/components/textarea/textarea.component.js +1 -1
  19. package/esm/locales/fr-fr.js +3 -3
  20. package/lib/__internal__/checkable-input/checkable-input.component.js +3 -1
  21. package/lib/__internal__/utils/helpers/tags/tags-specs/index.d.ts +1 -1
  22. package/lib/__internal__/utils/helpers/tags/tags-specs/index.js +4 -9
  23. package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.d.ts +2 -2
  24. package/lib/__internal__/utils/helpers/tags/tags-specs/tags-specs.js +2 -12
  25. package/lib/__internal__/validation-message/validation-message.component.js +2 -1
  26. package/lib/components/accordion/accordion.component.js +4 -1
  27. package/lib/components/content/content.component.js +2 -0
  28. package/lib/components/detail/detail.component.js +1 -0
  29. package/lib/components/flat-table/__internal__/build-position-map.js +2 -0
  30. package/lib/components/flat-table/flat-table-row/flat-table-row.component.d.ts +2 -1
  31. package/lib/components/flat-table/flat-table-row/flat-table-row.component.js +13 -2
  32. package/lib/components/flat-table/flat-table-row/flat-table-row.style.js +2 -1
  33. package/lib/components/flat-table/flat-table.component.d.ts +2 -1
  34. package/lib/components/flat-table/flat-table.component.js +9 -4
  35. package/lib/components/switch/__internal__/switch-slider.component.js +5 -2
  36. package/lib/components/switch/switch.component.js +7 -1
  37. package/lib/components/textarea/textarea.component.js +1 -1
  38. package/lib/locales/fr-fr.js +3 -3
  39. package/package.json +1 -1
@@ -106,7 +106,9 @@ const CheckableInput = /*#__PURE__*/React.forwardRef(({
106
106
  reverse: reverse
107
107
  }, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({}, formFieldProps, {
108
108
  my: 0
109
- }), /*#__PURE__*/React.createElement(StyledCheckableInput, null, /*#__PURE__*/React.createElement(HiddenCheckableInput, inputProps), children))));
109
+ }), /*#__PURE__*/React.createElement(StyledCheckableInput, {
110
+ "data-role": "checkable-input"
111
+ }, /*#__PURE__*/React.createElement(HiddenCheckableInput, inputProps), children))));
110
112
  });
111
113
  if (process.env.NODE_ENV !== "production") {
112
114
  CheckableInput.propTypes = {
@@ -1 +1 @@
1
- export { elementsTagTest, rootTagTest } from "./tags-specs";
1
+ export { default } from "./tags-specs";
@@ -1 +1 @@
1
- export { elementsTagTest, rootTagTest } from "./tags-specs";
1
+ export { default } from "./tags-specs";
@@ -1,3 +1,3 @@
1
1
  import { ReactWrapper, ShallowWrapper } from "enzyme";
2
- export declare const elementsTagTest: (wrapper: ReactWrapper | ShallowWrapper, elements: string[]) => void;
3
- export declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
2
+ declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
3
+ export default rootTagTest;
@@ -1,14 +1,6 @@
1
- export const elementsTagTest = (wrapper, elements) => {
2
- elements.forEach(element => {
3
- it(`include 'data-element="${element}"'`, () => {
4
- expect(wrapper.find({
5
- "data-element": element
6
- }).length).toEqual(1);
7
- });
8
- });
9
- };
10
- export const rootTagTest = (rootNode, comp, elem, role) => {
1
+ const rootTagTest = (rootNode, comp, elem, role) => {
11
2
  expect(rootNode.prop("data-component")).toEqual(comp);
12
3
  expect(rootNode.prop("data-element")).toEqual(elem);
13
4
  expect(rootNode.prop("data-role")).toEqual(role);
14
- };
5
+ };
6
+ export default rootTagTest;
@@ -10,7 +10,8 @@ const ValidationMessage = ({
10
10
  const isStringValidation = typeof validation === "string";
11
11
  return isStringValidation ? /*#__PURE__*/React.createElement(StyledValidationMessage, {
12
12
  id: validationId,
13
- isWarning: !!(!error && warning)
13
+ isWarning: !!(!error && warning),
14
+ "data-role": "validation-message"
14
15
  }, validation) : null;
15
16
  };
16
17
  export default ValidationMessage;
@@ -79,6 +79,7 @@ const Accordion = /*#__PURE__*/React.forwardRef(({
79
79
  return /*#__PURE__*/React.createElement(StyledAccordionContainer, _extends({
80
80
  id: accordionId,
81
81
  "data-component": "accordion",
82
+ "data-role": "accordion-container",
82
83
  width: width,
83
84
  borders: variant === "subtle" ? "none" : borders,
84
85
  scheme: scheme,
@@ -125,10 +126,12 @@ const Accordion = /*#__PURE__*/React.forwardRef(({
125
126
  iconAlign: iconAlign || (variant === "standard" ? "right" : "left")
126
127
  })), /*#__PURE__*/React.createElement(StyledAccordionContentContainer, {
127
128
  isExpanded: isExpanded,
128
- maxHeight: contentHeight
129
+ maxHeight: contentHeight,
130
+ "data-role": "accordion-content-container"
129
131
  }, /*#__PURE__*/React.createElement(StyledAccordionContent, {
130
132
  role: "region",
131
133
  "data-element": "accordion-content",
134
+ "data-role": "accordion-content",
132
135
  id: contentId,
133
136
  "aria-labelledby": headerId,
134
137
  ref: accordionContent,
@@ -21,12 +21,14 @@ export const Content = ({
21
21
  variant: variant,
22
22
  inline: inline,
23
23
  "data-element": "content-title",
24
+ "data-role": "content-title",
24
25
  titleWidth: titleWidth,
25
26
  align: align
26
27
  }, title), /*#__PURE__*/React.createElement(StyledContentBody, {
27
28
  variant: variant,
28
29
  inline: inline,
29
30
  "data-element": "content-body",
31
+ "data-role": "content-body",
30
32
  bodyFullWidth: bodyFullWidth,
31
33
  titleWidth: titleWidth,
32
34
  align: align
@@ -20,6 +20,7 @@ export const Detail = ({
20
20
  hasIcon: !!icon
21
21
  }, children), footnote && /*#__PURE__*/React.createElement(StyledDetailFootnote, {
22
22
  "data-element": "footnote",
23
+ "data-role": "footnote",
23
24
  hasIcon: !!icon
24
25
  }, footnote));
25
26
  Detail.displayName = "Detail";
@@ -5,6 +5,8 @@ export default ((array, propertyName) => array.reduce((acc, _, index) => {
5
5
  acc[currentId] = 0;
6
6
  } else {
7
7
  const previousId = array[index - 1].getAttribute("id");
8
+
9
+ /* istanbul ignore else */
8
10
  if (previousId) {
9
11
  acc[currentId] = acc[previousId] + array[index - 1][propertyName];
10
12
  }
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
2
3
  import { TableBorderSize } from "..";
3
4
  import { FlatTableRowDraggableProps } from "./__internal__/flat-table-row-draggable.component";
4
- export interface FlatTableRowProps {
5
+ export interface FlatTableRowProps extends Omit<TagProps, "data-component"> {
5
6
  /** Overrides default cell color, provide design token, any color from palette or any valid css color value. */
6
7
  bgColor?: string;
7
8
  /** Array of FlatTableHeader or FlatTableCell. FlatTableRowHeader could also be passed. */
@@ -29,6 +29,8 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
29
29
  draggable,
30
30
  findItem,
31
31
  moveItem,
32
+ "data-element": dataElement,
33
+ "data-role": dataRole,
32
34
  ...rest
33
35
  }, ref) => {
34
36
  const internalId = useRef(id ? String(id) : guid());
@@ -158,12 +160,17 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
158
160
  };
159
161
  }, [addRow, removeRow]);
160
162
  const isFirstSubRow = firstRowId === internalId.current;
163
+ const getDataElement = () => {
164
+ if (dataElement) return dataElement;
165
+ return isSubRow ? "flat-table-sub-row" : "flat-table-row";
166
+ };
161
167
  const rowComponent = () => /*#__PURE__*/React.createElement(StyledFlatTableRow, _extends({
162
168
  isInSidebar: isInSidebar,
163
169
  expandable: expandable,
164
170
  isSubRow: isSubRow,
165
171
  isFirstSubRow: isFirstSubRow,
166
- "data-element": isSubRow ? "flat-table-sub-row" : "flat-table-row",
172
+ "data-element": getDataElement(),
173
+ "data-role": dataRole,
167
174
  highlighted: highlighted,
168
175
  selected: selected,
169
176
  onClick: handleClick,
@@ -183,7 +190,9 @@ const FlatTableRow = /*#__PURE__*/React.forwardRef(({
183
190
  "data-selected": selected && expandableArea === "wholeRow",
184
191
  "data-highlighted": highlighted && expandableArea === "wholeRow",
185
192
  rowHeight: rowRef?.current?.offsetHeight
186
- }, interactiveRowProps, rest), /*#__PURE__*/React.createElement(FlatTableRowContext.Provider, {
193
+ }, interactiveRowProps, rest, {
194
+ "data-component": "flat-table-row"
195
+ }), /*#__PURE__*/React.createElement(FlatTableRowContext.Provider, {
187
196
  value: {
188
197
  firstCellId,
189
198
  expandable,
@@ -208,6 +217,8 @@ if (process.env.NODE_ENV !== "production") {
208
217
  FlatTableRow.propTypes = {
209
218
  "bgColor": PropTypes.string,
210
219
  "children": PropTypes.node,
220
+ "data-element": PropTypes.string,
221
+ "data-role": PropTypes.string,
211
222
  "draggable": PropTypes.bool,
212
223
  "expandable": PropTypes.bool,
213
224
  "expandableArea": PropTypes.oneOf(["firstColumn", "wholeRow"]),
@@ -233,7 +233,8 @@ const StyledFlatTableRow = styled.tr`
233
233
  border: none;
234
234
  }
235
235
  `}
236
- ${!theme.focusRedesignOptOut && css`
236
+ ${!theme.focusRedesignOptOut && /* istanbul ignore next */
237
+ css`
237
238
  position: -webkit-sticky;
238
239
  :after {
239
240
  border: none;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import * as DesignTokens from "@sage/design-tokens/js/base/common";
4
- export interface FlatTableProps extends MarginProps {
4
+ import { TagProps } from "../../__internal__/utils/helpers/tags";
5
+ export interface FlatTableProps extends MarginProps, Omit<TagProps, "data-component"> {
5
6
  /** The HTML id of the element that contains a description of this table. */
6
7
  ariaDescribedby?: string;
7
8
  /** A string to render as the table's caption */
@@ -108,6 +108,8 @@ export const FlatTable = ({
108
108
  } else {
109
109
  // it may be that an element within the row currently has focus
110
110
  const index = findParentIndexOfFocusedChild(focusableElementsArray);
111
+
112
+ /* istanbul ignore else */
111
113
  if (index !== -1 && index < focusableElementsArray.length) {
112
114
  focusableElementsArray[index + 1]?.focus();
113
115
  }
@@ -135,7 +137,6 @@ export const FlatTable = ({
135
137
  };
136
138
  return /*#__PURE__*/React.createElement(StyledFlatTableWrapper, _extends({
137
139
  ref: wrapperRef,
138
- "data-component": "flat-table-wrapper",
139
140
  "data-role": "flat-table-wrapper",
140
141
  isInSidebar: isInSidebar,
141
142
  hasStickyHead: hasStickyHead,
@@ -160,7 +161,9 @@ export const FlatTable = ({
160
161
  lastColRowSpanIndex: lastColRowSpanIndex,
161
162
  onKeyDown: handleKeyDown,
162
163
  isFocused: focused
163
- }, rest), /*#__PURE__*/React.createElement(StyledTableContainer, {
164
+ }, rest, {
165
+ "data-component": "flat-table-wrapper"
166
+ }), /*#__PURE__*/React.createElement(StyledTableContainer, {
164
167
  ref: container,
165
168
  onFocus: () => {
166
169
  if (container.current === document.activeElement) {
@@ -170,7 +173,8 @@ export const FlatTable = ({
170
173
  onBlur: () => setFocused(false),
171
174
  tabIndex: 0,
172
175
  overflowX: overflowX,
173
- width: width
176
+ width: width,
177
+ "data-role": "flat-table-container"
174
178
  }, /*#__PURE__*/React.createElement(StyledFlatTable, _extends({
175
179
  ref: tableRef,
176
180
  "data-component": "flat-table"
@@ -181,7 +185,8 @@ export const FlatTable = ({
181
185
  getTabStopElementId
182
186
  }
183
187
  }, children))), footer && /*#__PURE__*/React.createElement(StyledFlatTableFooter, {
184
- hasStickyFooter: hasStickyFooter
188
+ hasStickyFooter: hasStickyFooter,
189
+ "data-role": "flat-table-footer"
185
190
  }, footer));
186
191
  };
187
192
  FlatTable.displayName = "FlatTable";
@@ -44,12 +44,15 @@ const SwitchSlider = ({
44
44
  isActive: checked,
45
45
  size
46
46
  };
47
- const sliderContent = /*#__PURE__*/React.createElement(SwitchSliderPanel, sliderPanelStyleProps, loading ? /*#__PURE__*/React.createElement(Loader, loaderProps) : panelContent);
47
+ const sliderContent = /*#__PURE__*/React.createElement(SwitchSliderPanel, _extends({
48
+ "data-role": "slider-panel"
49
+ }, sliderPanelStyleProps), loading ? /*#__PURE__*/React.createElement(Loader, loaderProps) : panelContent);
48
50
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HiddenContent, {
49
51
  size: size,
50
52
  "aria-hidden": true
51
53
  }, longestText), /*#__PURE__*/React.createElement(StyledSwitchSlider, _extends({
52
- "data-component": "slider"
54
+ "data-component": "slider",
55
+ "data-role": "slider"
53
56
  }, switchSliderStyleProps), sliderContent, useValidationIcon && /*#__PURE__*/React.createElement(ValidationIcon, {
54
57
  error: error,
55
58
  warning: warning,
@@ -58,6 +58,8 @@ const Switch = /*#__PURE__*/React.forwardRef(({
58
58
  }, [setCheckedInternal, onChange]);
59
59
  const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
60
60
  let shouldLabelBeInline = labelInline;
61
+ // Coverage has been ignored here as this functionality is covered in a Playwright test.
62
+ /* istanbul ignore next */
61
63
  if (adaptiveLabelBreakpoint) {
62
64
  shouldLabelBeInline = largeScreen;
63
65
  }
@@ -152,13 +154,17 @@ const Switch = /*#__PURE__*/React.forwardRef(({
152
154
  };
153
155
  const applyValidation = error || warning;
154
156
  return /*#__PURE__*/React.createElement(React.Fragment, null, validationRedesignOptIn ? /*#__PURE__*/React.createElement(StyledSwitch, switchStylePropsForNewValidation, /*#__PURE__*/React.createElement(Label, null, /*#__PURE__*/React.createElement(Box, {
157
+ "data-role": "hint-text-wrapper",
155
158
  mb: labelHelp ? 0 : 1
156
- }, label, labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp)), /*#__PURE__*/React.createElement(Box, {
159
+ }, label, labelHelp && /*#__PURE__*/React.createElement(StyledHintText, {
160
+ "data-role": "hint-text"
161
+ }, labelHelp)), /*#__PURE__*/React.createElement(Box, {
157
162
  position: "relative"
158
163
  }, /*#__PURE__*/React.createElement(ValidationMessage, {
159
164
  error: error,
160
165
  warning: warning
161
166
  }), applyValidation && /*#__PURE__*/React.createElement(ErrorBorder, {
167
+ "data-role": "error-border",
162
168
  warning: !!(!error && warning)
163
169
  }), /*#__PURE__*/React.createElement(CheckableInput, inputPropsForNewValidation, /*#__PURE__*/React.createElement(SwitchSlider, switchSliderPropsForNewValidation))))) : /*#__PURE__*/React.createElement(TooltipProvider, {
164
170
  helpAriaLabel: helpAriaLabel,
@@ -116,7 +116,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
116
116
  scrollElement = scrollElement?.parentElement || null;
117
117
  }
118
118
  const scrollPosition = scrollElement?.scrollTop;
119
- textarea.style.height = "0px";
119
+
120
120
  // Set the height so all content is shown
121
121
  textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
122
122
  if (scrollElement && scrollPosition) {
@@ -87,13 +87,13 @@ const frFR = {
87
87
  skipLinkLabel: () => "Passer au contenu principal"
88
88
  },
89
89
  loader: {
90
- loading: () => "Téléhargement"
90
+ loading: () => "Chargement en cours"
91
91
  },
92
92
  loaderSpinner: {
93
- loading: () => "Téléhargement..."
93
+ loading: () => "Chargement en cours..."
94
94
  },
95
95
  loaderStar: {
96
- loading: () => "Téléhargement..."
96
+ loading: () => "Chargement en cours..."
97
97
  },
98
98
  menuFullscreen: {
99
99
  ariaLabels: {
@@ -115,7 +115,9 @@ const CheckableInput = /*#__PURE__*/_react.default.forwardRef(({
115
115
  reverse: reverse
116
116
  }, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_formField.default, _extends({}, formFieldProps, {
117
117
  my: 0
118
- }), /*#__PURE__*/_react.default.createElement(_checkableInput.StyledCheckableInput, null, /*#__PURE__*/_react.default.createElement(_hiddenCheckableInput.default, inputProps), children))));
118
+ }), /*#__PURE__*/_react.default.createElement(_checkableInput.StyledCheckableInput, {
119
+ "data-role": "checkable-input"
120
+ }, /*#__PURE__*/_react.default.createElement(_hiddenCheckableInput.default, inputProps), children))));
119
121
  });
120
122
  if (process.env.NODE_ENV !== "production") {
121
123
  CheckableInput.propTypes = {
@@ -1 +1 @@
1
- export { elementsTagTest, rootTagTest } from "./tags-specs";
1
+ export { default } from "./tags-specs";
@@ -3,16 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "elementsTagTest", {
6
+ Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _tagsSpecs.elementsTagTest;
9
+ return _tagsSpecs.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "rootTagTest", {
13
- enumerable: true,
14
- get: function () {
15
- return _tagsSpecs.rootTagTest;
16
- }
17
- });
18
- var _tagsSpecs = require("./tags-specs");
12
+ var _tagsSpecs = _interopRequireDefault(require("./tags-specs"));
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -1,3 +1,3 @@
1
1
  import { ReactWrapper, ShallowWrapper } from "enzyme";
2
- export declare const elementsTagTest: (wrapper: ReactWrapper | ShallowWrapper, elements: string[]) => void;
3
- export declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
2
+ declare const rootTagTest: (rootNode: ReactWrapper | ShallowWrapper, comp: string, elem?: string, role?: string) => void;
3
+ export default rootTagTest;
@@ -3,20 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.rootTagTest = exports.elementsTagTest = void 0;
7
- const elementsTagTest = (wrapper, elements) => {
8
- elements.forEach(element => {
9
- it(`include 'data-element="${element}"'`, () => {
10
- expect(wrapper.find({
11
- "data-element": element
12
- }).length).toEqual(1);
13
- });
14
- });
15
- };
16
- exports.elementsTagTest = elementsTagTest;
6
+ exports.default = void 0;
17
7
  const rootTagTest = (rootNode, comp, elem, role) => {
18
8
  expect(rootNode.prop("data-component")).toEqual(comp);
19
9
  expect(rootNode.prop("data-element")).toEqual(elem);
20
10
  expect(rootNode.prop("data-role")).toEqual(role);
21
11
  };
22
- exports.rootTagTest = rootTagTest;
12
+ var _default = exports.default = rootTagTest;
@@ -17,7 +17,8 @@ const ValidationMessage = ({
17
17
  const isStringValidation = typeof validation === "string";
18
18
  return isStringValidation ? /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
19
19
  id: validationId,
20
- isWarning: !!(!error && warning)
20
+ isWarning: !!(!error && warning),
21
+ "data-role": "validation-message"
21
22
  }, validation) : null;
22
23
  };
23
24
  var _default = exports.default = ValidationMessage;
@@ -88,6 +88,7 @@ const Accordion = exports.Accordion = /*#__PURE__*/_react.default.forwardRef(({
88
88
  return /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContainer, _extends({
89
89
  id: accordionId,
90
90
  "data-component": "accordion",
91
+ "data-role": "accordion-container",
91
92
  width: width,
92
93
  borders: variant === "subtle" ? "none" : borders,
93
94
  scheme: scheme,
@@ -134,10 +135,12 @@ const Accordion = exports.Accordion = /*#__PURE__*/_react.default.forwardRef(({
134
135
  iconAlign: iconAlign || (variant === "standard" ? "right" : "left")
135
136
  })), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContentContainer, {
136
137
  isExpanded: isExpanded,
137
- maxHeight: contentHeight
138
+ maxHeight: contentHeight,
139
+ "data-role": "accordion-content-container"
138
140
  }, /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContent, {
139
141
  role: "region",
140
142
  "data-element": "accordion-content",
143
+ "data-role": "accordion-content",
141
144
  id: contentId,
142
145
  "aria-labelledby": headerId,
143
146
  ref: accordionContent,
@@ -28,12 +28,14 @@ const Content = ({
28
28
  variant: variant,
29
29
  inline: inline,
30
30
  "data-element": "content-title",
31
+ "data-role": "content-title",
31
32
  titleWidth: titleWidth,
32
33
  align: align
33
34
  }, title), /*#__PURE__*/_react.default.createElement(_content.StyledContentBody, {
34
35
  variant: variant,
35
36
  inline: inline,
36
37
  "data-element": "content-body",
38
+ "data-role": "content-body",
37
39
  bodyFullWidth: bodyFullWidth,
38
40
  titleWidth: titleWidth,
39
41
  align: align
@@ -27,6 +27,7 @@ const Detail = ({
27
27
  hasIcon: !!icon
28
28
  }, children), footnote && /*#__PURE__*/_react.default.createElement(_detail.StyledDetailFootnote, {
29
29
  "data-element": "footnote",
30
+ "data-role": "footnote",
30
31
  hasIcon: !!icon
31
32
  }, footnote));
32
33
  exports.Detail = Detail;
@@ -11,6 +11,8 @@ var _default = (array, propertyName) => array.reduce((acc, _, index) => {
11
11
  acc[currentId] = 0;
12
12
  } else {
13
13
  const previousId = array[index - 1].getAttribute("id");
14
+
15
+ /* istanbul ignore else */
14
16
  if (previousId) {
15
17
  acc[currentId] = acc[previousId] + array[index - 1][propertyName];
16
18
  }
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
+ import { TagProps } from "../../../__internal__/utils/helpers/tags";
2
3
  import { TableBorderSize } from "..";
3
4
  import { FlatTableRowDraggableProps } from "./__internal__/flat-table-row-draggable.component";
4
- export interface FlatTableRowProps {
5
+ export interface FlatTableRowProps extends Omit<TagProps, "data-component"> {
5
6
  /** Overrides default cell color, provide design token, any color from palette or any valid css color value. */
6
7
  bgColor?: string;
7
8
  /** Array of FlatTableHeader or FlatTableCell. FlatTableRowHeader could also be passed. */
@@ -38,6 +38,8 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
38
38
  draggable,
39
39
  findItem,
40
40
  moveItem,
41
+ "data-element": dataElement,
42
+ "data-role": dataRole,
41
43
  ...rest
42
44
  }, ref) => {
43
45
  const internalId = (0, _react.useRef)(id ? String(id) : (0, _guid.default)());
@@ -167,12 +169,17 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
167
169
  };
168
170
  }, [addRow, removeRow]);
169
171
  const isFirstSubRow = firstRowId === internalId.current;
172
+ const getDataElement = () => {
173
+ if (dataElement) return dataElement;
174
+ return isSubRow ? "flat-table-sub-row" : "flat-table-row";
175
+ };
170
176
  const rowComponent = () => /*#__PURE__*/_react.default.createElement(_flatTableRow.default, _extends({
171
177
  isInSidebar: isInSidebar,
172
178
  expandable: expandable,
173
179
  isSubRow: isSubRow,
174
180
  isFirstSubRow: isFirstSubRow,
175
- "data-element": isSubRow ? "flat-table-sub-row" : "flat-table-row",
181
+ "data-element": getDataElement(),
182
+ "data-role": dataRole,
176
183
  highlighted: highlighted,
177
184
  selected: selected,
178
185
  onClick: handleClick,
@@ -192,7 +199,9 @@ const FlatTableRow = exports.FlatTableRow = /*#__PURE__*/_react.default.forwardR
192
199
  "data-selected": selected && expandableArea === "wholeRow",
193
200
  "data-highlighted": highlighted && expandableArea === "wholeRow",
194
201
  rowHeight: rowRef?.current?.offsetHeight
195
- }, interactiveRowProps, rest), /*#__PURE__*/_react.default.createElement(_flatTableRow2.default.Provider, {
202
+ }, interactiveRowProps, rest, {
203
+ "data-component": "flat-table-row"
204
+ }), /*#__PURE__*/_react.default.createElement(_flatTableRow2.default.Provider, {
196
205
  value: {
197
206
  firstCellId,
198
207
  expandable,
@@ -217,6 +226,8 @@ if (process.env.NODE_ENV !== "production") {
217
226
  FlatTableRow.propTypes = {
218
227
  "bgColor": _propTypes.default.string,
219
228
  "children": _propTypes.default.node,
229
+ "data-element": _propTypes.default.string,
230
+ "data-role": _propTypes.default.string,
220
231
  "draggable": _propTypes.default.bool,
221
232
  "expandable": _propTypes.default.bool,
222
233
  "expandableArea": _propTypes.default.oneOf(["firstColumn", "wholeRow"]),
@@ -242,7 +242,8 @@ const StyledFlatTableRow = _styledComponents.default.tr`
242
242
  border: none;
243
243
  }
244
244
  `}
245
- ${!theme.focusRedesignOptOut && (0, _styledComponents.css)`
245
+ ${!theme.focusRedesignOptOut && /* istanbul ignore next */
246
+ (0, _styledComponents.css)`
246
247
  position: -webkit-sticky;
247
248
  :after {
248
249
  border: none;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { MarginProps } from "styled-system";
3
3
  import * as DesignTokens from "@sage/design-tokens/js/base/common";
4
- export interface FlatTableProps extends MarginProps {
4
+ import { TagProps } from "../../__internal__/utils/helpers/tags";
5
+ export interface FlatTableProps extends MarginProps, Omit<TagProps, "data-component"> {
5
6
  /** The HTML id of the element that contains a description of this table. */
6
7
  ariaDescribedby?: string;
7
8
  /** A string to render as the table's caption */
@@ -117,6 +117,8 @@ const FlatTable = ({
117
117
  } else {
118
118
  // it may be that an element within the row currently has focus
119
119
  const index = findParentIndexOfFocusedChild(focusableElementsArray);
120
+
121
+ /* istanbul ignore else */
120
122
  if (index !== -1 && index < focusableElementsArray.length) {
121
123
  focusableElementsArray[index + 1]?.focus();
122
124
  }
@@ -144,7 +146,6 @@ const FlatTable = ({
144
146
  };
145
147
  return /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableWrapper, _extends({
146
148
  ref: wrapperRef,
147
- "data-component": "flat-table-wrapper",
148
149
  "data-role": "flat-table-wrapper",
149
150
  isInSidebar: isInSidebar,
150
151
  hasStickyHead: hasStickyHead,
@@ -169,7 +170,9 @@ const FlatTable = ({
169
170
  lastColRowSpanIndex: lastColRowSpanIndex,
170
171
  onKeyDown: handleKeyDown,
171
172
  isFocused: focused
172
- }, rest), /*#__PURE__*/_react.default.createElement(_flatTable.StyledTableContainer, {
173
+ }, rest, {
174
+ "data-component": "flat-table-wrapper"
175
+ }), /*#__PURE__*/_react.default.createElement(_flatTable.StyledTableContainer, {
173
176
  ref: container,
174
177
  onFocus: () => {
175
178
  if (container.current === document.activeElement) {
@@ -179,7 +182,8 @@ const FlatTable = ({
179
182
  onBlur: () => setFocused(false),
180
183
  tabIndex: 0,
181
184
  overflowX: overflowX,
182
- width: width
185
+ width: width,
186
+ "data-role": "flat-table-container"
183
187
  }, /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTable, _extends({
184
188
  ref: tableRef,
185
189
  "data-component": "flat-table"
@@ -190,7 +194,8 @@ const FlatTable = ({
190
194
  getTabStopElementId
191
195
  }
192
196
  }, children))), footer && /*#__PURE__*/_react.default.createElement(_flatTable.StyledFlatTableFooter, {
193
- hasStickyFooter: hasStickyFooter
197
+ hasStickyFooter: hasStickyFooter,
198
+ "data-role": "flat-table-footer"
194
199
  }, footer));
195
200
  };
196
201
  exports.FlatTable = FlatTable;
@@ -51,12 +51,15 @@ const SwitchSlider = ({
51
51
  isActive: checked,
52
52
  size
53
53
  };
54
- const sliderContent = /*#__PURE__*/_react.default.createElement(_switchSliderPanel.default, sliderPanelStyleProps, loading ? /*#__PURE__*/_react.default.createElement(_loader.default, loaderProps) : panelContent);
54
+ const sliderContent = /*#__PURE__*/_react.default.createElement(_switchSliderPanel.default, _extends({
55
+ "data-role": "slider-panel"
56
+ }, sliderPanelStyleProps), loading ? /*#__PURE__*/_react.default.createElement(_loader.default, loaderProps) : panelContent);
55
57
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_switchSlider.HiddenContent, {
56
58
  size: size,
57
59
  "aria-hidden": true
58
60
  }, longestText), /*#__PURE__*/_react.default.createElement(_switchSlider.StyledSwitchSlider, _extends({
59
- "data-component": "slider"
61
+ "data-component": "slider",
62
+ "data-role": "slider"
60
63
  }, switchSliderStyleProps), sliderContent, useValidationIcon && /*#__PURE__*/_react.default.createElement(_validationIcon.default, {
61
64
  error: error,
62
65
  warning: warning,
@@ -67,6 +67,8 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
67
67
  }, [setCheckedInternal, onChange]);
68
68
  const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveLabelBreakpoint);
69
69
  let shouldLabelBeInline = labelInline;
70
+ // Coverage has been ignored here as this functionality is covered in a Playwright test.
71
+ /* istanbul ignore next */
70
72
  if (adaptiveLabelBreakpoint) {
71
73
  shouldLabelBeInline = largeScreen;
72
74
  }
@@ -161,13 +163,17 @@ const Switch = exports.Switch = /*#__PURE__*/_react.default.forwardRef(({
161
163
  };
162
164
  const applyValidation = error || warning;
163
165
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, validationRedesignOptIn ? /*#__PURE__*/_react.default.createElement(_switch.default, switchStylePropsForNewValidation, /*#__PURE__*/_react.default.createElement(_label.default, null, /*#__PURE__*/_react.default.createElement(_box.default, {
166
+ "data-role": "hint-text-wrapper",
164
167
  mb: labelHelp ? 0 : 1
165
- }, label, labelHelp && /*#__PURE__*/_react.default.createElement(_switch.StyledHintText, null, labelHelp)), /*#__PURE__*/_react.default.createElement(_box.default, {
168
+ }, label, labelHelp && /*#__PURE__*/_react.default.createElement(_switch.StyledHintText, {
169
+ "data-role": "hint-text"
170
+ }, labelHelp)), /*#__PURE__*/_react.default.createElement(_box.default, {
166
171
  position: "relative"
167
172
  }, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
168
173
  error: error,
169
174
  warning: warning
170
175
  }), applyValidation && /*#__PURE__*/_react.default.createElement(_switch.ErrorBorder, {
176
+ "data-role": "error-border",
171
177
  warning: !!(!error && warning)
172
178
  }), /*#__PURE__*/_react.default.createElement(_checkableInput.default, inputPropsForNewValidation, /*#__PURE__*/_react.default.createElement(_switchSlider.default, switchSliderPropsForNewValidation))))) : /*#__PURE__*/_react.default.createElement(_tooltipProvider.TooltipProvider, {
173
179
  helpAriaLabel: helpAriaLabel,
@@ -125,7 +125,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
125
125
  scrollElement = scrollElement?.parentElement || null;
126
126
  }
127
127
  const scrollPosition = scrollElement?.scrollTop;
128
- textarea.style.height = "0px";
128
+
129
129
  // Set the height so all content is shown
130
130
  textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
131
131
  if (scrollElement && scrollPosition) {
@@ -94,13 +94,13 @@ const frFR = {
94
94
  skipLinkLabel: () => "Passer au contenu principal"
95
95
  },
96
96
  loader: {
97
- loading: () => "Téléhargement"
97
+ loading: () => "Chargement en cours"
98
98
  },
99
99
  loaderSpinner: {
100
- loading: () => "Téléhargement..."
100
+ loading: () => "Chargement en cours..."
101
101
  },
102
102
  loaderStar: {
103
- loading: () => "Téléhargement..."
103
+ loading: () => "Chargement en cours..."
104
104
  },
105
105
  menuFullscreen: {
106
106
  ariaLabels: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "142.11.6",
3
+ "version": "142.11.8",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",