carbon-react 139.0.0 → 140.0.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.
@@ -83,7 +83,8 @@ export const ValidationIcon = ({
83
83
  isPartOfInput: isPartOfInput,
84
84
  inputSize: size,
85
85
  id: iconId,
86
- focusable: tabIndex !== -1
86
+ focusable: tabIndex !== -1,
87
+ "data-role": `icon-${validationType}`
87
88
  }));
88
89
  };
89
90
  export default ValidationIcon;
@@ -30,11 +30,11 @@ export const DatePicker = ({
30
30
  setOpen,
31
31
  pickerTabGuardId
32
32
  }) => {
33
- const l = useLocale();
33
+ const locale = useLocale();
34
34
  const {
35
35
  localize,
36
36
  options
37
- } = l.date.dateFnsLocale();
37
+ } = locale.date.dateFnsLocale();
38
38
  const {
39
39
  weekStartsOn
40
40
  } = options || /* istanbul ignore next */{};
@@ -53,7 +53,7 @@ export const DatePicker = ({
53
53
  length: 7
54
54
  }).map((_, i) => localize?.day(i)), [localize]);
55
55
  const weekdaysShort = useMemo(() => {
56
- const isGivenLocale = str => l.locale().includes(str);
56
+ const isGivenLocale = str => locale.locale().includes(str);
57
57
  return Array.from({
58
58
  length: 7
59
59
  }).map((_, i) => localize?.day(i, ["de", "pl"].some(isGivenLocale) ? {
@@ -61,7 +61,7 @@ export const DatePicker = ({
61
61
  } : {
62
62
  width: "abbreviated"
63
63
  }).substring(0, isGivenLocale("de") ? 2 : 3));
64
- }, [l, localize]);
64
+ }, [locale, localize]);
65
65
  const ref = useRef(null);
66
66
  useEffect(() => {
67
67
  if (open) {
@@ -178,7 +178,7 @@ export const DatePicker = ({
178
178
  fixedWeeks: true,
179
179
  initialMonth: selectedDays || undefined,
180
180
  disabledDays: getDisabledDays(minDate, maxDate),
181
- locale: l.locale(),
181
+ locale: locale.locale(),
182
182
  localeUtils: localeUtils,
183
183
  onDayKeyDown: handleOnDayKeyDown
184
184
  }, pickerProps))));
@@ -22,7 +22,8 @@ export const Navbar = ({
22
22
  }
23
23
  };
24
24
  return /*#__PURE__*/React.createElement(StyledNavbar, {
25
- className: className
25
+ className: className,
26
+ "data-role": "date-navbar"
26
27
  }, /*#__PURE__*/React.createElement(StyledButton, {
27
28
  "aria-label": previousMonthButton(),
28
29
  onClick: () => onPreviousClick?.(),
@@ -48,10 +48,10 @@ const DateInput = /*#__PURE__*/React.forwardRef(({
48
48
  const alreadyFocused = useRef(false);
49
49
  const isBlurBlocked = useRef(false);
50
50
  const focusedViaPicker = useRef(false);
51
- const l = useLocale();
51
+ const locale = useLocale();
52
52
  const {
53
53
  dateFnsLocale
54
- } = l.date;
54
+ } = locale.date;
55
55
  const {
56
56
  format,
57
57
  formats
@@ -10,7 +10,7 @@ export interface ContentPaddingInterface {
10
10
  py?: PaddingValues;
11
11
  px?: PaddingValues;
12
12
  }
13
- export interface DialogProps extends ModalProps, TagProps {
13
+ export interface DialogProps extends ModalProps, Omit<TagProps, "data-component"> {
14
14
  /** Custom class name */
15
15
  className?: string;
16
16
  /** Prop to specify the aria-describedby property of the Dialog component */
@@ -16,6 +16,8 @@ import useModalAria from "../../hooks/__internal__/useModalAria/useModalAria";
16
16
  const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
17
17
  const Dialog = /*#__PURE__*/forwardRef(({
18
18
  className,
19
+ "data-element": dataElement = "dialog",
20
+ "data-role": dataRole,
19
21
  children,
20
22
  open,
21
23
  height,
@@ -148,19 +150,14 @@ const Dialog = /*#__PURE__*/forwardRef(({
148
150
  "aria-describedby": subtitle && typeof subtitle === "string" ? subtitleId : rest["aria-describedby"],
149
151
  "aria-label": rest["aria-label"]
150
152
  };
151
- const componentTags = {
152
- "data-component": rest["data-component"] || "dialog",
153
- "data-element": rest["data-element"],
154
- "data-role": rest["data-role"]
155
- };
156
- return /*#__PURE__*/React.createElement(Modal, _extends({
153
+ return /*#__PURE__*/React.createElement(Modal, {
157
154
  open: open,
158
155
  onCancel: onCancel,
159
156
  disableEscKey: disableEscKey,
160
157
  disableClose: disableClose,
161
158
  className: className ? `${className} carbon-dialog` : "carbon-dialog",
162
159
  topModalOverride: topModalOverride
163
- }, componentTags), /*#__PURE__*/React.createElement(FocusTrap, {
160
+ }, /*#__PURE__*/React.createElement(FocusTrap, {
164
161
  autoFocus: !disableAutoFocus,
165
162
  focusFirstElement: focusFirstElement,
166
163
  bespokeTrap: bespokeFocusTrap,
@@ -169,18 +166,21 @@ const Dialog = /*#__PURE__*/forwardRef(({
169
166
  isOpen: open,
170
167
  additionalWrapperRefs: focusableContainers
171
168
  }, /*#__PURE__*/React.createElement(StyledDialog, _extends({
169
+ "data-component": "dialog",
170
+ "data-element": dataElement,
171
+ "data-role": dataRole,
172
172
  "aria-modal": isTopModal ? true : undefined,
173
173
  ref: containerRef,
174
174
  topMargin: TOP_MARGIN
175
175
  }, dialogProps, {
176
- "data-component": "dialog",
177
- "data-element": "dialog",
178
- "data-role": rest["data-role"],
179
176
  role: role,
180
177
  tabIndex: -1
181
178
  }, contentPadding, {
182
179
  backgroundColor: greyBackground ? "var(--colorsUtilityMajor025)" : "var(--colorsUtilityYang100)"
183
- }), dialogTitle(), closeIcon(), /*#__PURE__*/React.createElement(StyledDialogContent, contentPadding, /*#__PURE__*/React.createElement(StyledDialogInnerContent, _extends({
180
+ }), dialogTitle(), closeIcon(), /*#__PURE__*/React.createElement(StyledDialogContent, _extends({}, contentPadding, {
181
+ "data-role": "dialog-content"
182
+ }), /*#__PURE__*/React.createElement(StyledDialogInnerContent, _extends({
183
+ "data-role": "dialog-inner-content",
184
184
  ref: innerContentRef
185
185
  }, contentPadding), children)))));
186
186
  });
@@ -202,7 +202,6 @@ if (process.env.NODE_ENV !== "production") {
202
202
  "px": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
203
203
  "py": PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
204
204
  }),
205
- "data-component": PropTypes.string,
206
205
  "data-element": PropTypes.string,
207
206
  "data-role": PropTypes.string,
208
207
  "disableAutoFocus": PropTypes.bool,
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { TagProps } from "../../__internal__/utils/helpers/tags";
3
- export interface ModalProps extends TagProps {
3
+ export interface ModalProps extends Omit<TagProps, "data-component"> {
4
4
  /** Custom class name */
5
5
  className?: string;
6
6
  /** Modal content */
@@ -22,5 +22,5 @@ export interface ModalProps extends TagProps {
22
22
  /** Manually override the internal modal stacking order to set this as top */
23
23
  topModalOverride?: boolean;
24
24
  }
25
- declare const Modal: ({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
25
+ declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
26
26
  export default Modal;
@@ -10,6 +10,8 @@ import { StyledModal, StyledModalBackground } from "./modal.style";
10
10
  import ModalContext from "./__internal__/modal.context";
11
11
  const Modal = ({
12
12
  children,
13
+ "data-element": dataElement,
14
+ "data-role": dataRole = "modal",
13
15
  open,
14
16
  onCancel,
15
17
  disableEscKey = false,
@@ -70,6 +72,9 @@ const Modal = ({
70
72
  content = children;
71
73
  }
72
74
  return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledModal, _extends({
75
+ "data-component": "modal",
76
+ "data-element": dataElement,
77
+ "data-role": dataRole,
73
78
  "data-state": open ? "open" : "closed",
74
79
  transitionName: "modal",
75
80
  transitionTime: timeout,
@@ -60,8 +60,9 @@ const StyledProgressBar = styled.span`
60
60
  })};
61
61
  border-radius: ${theme.roundedCornersOptOut ? "25px" : "var(--borderRadius400)"};
62
62
  overflow-x: hidden;
63
- height: ${getHeight(size)};
64
- width: 100%;
63
+ width: 100%
64
+ min-height: fit-content;
65
+ box-sizing: border-box;
65
66
  `}
66
67
  `;
67
68
  const fontSizes = {
@@ -161,6 +161,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
161
161
  ref: handleTargetRef
162
162
  }), showTooltip ? /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledTooltip, _extends({
163
163
  "data-element": "tooltip",
164
+ "data-role": "tooltip",
164
165
  role: "tooltip",
165
166
  tabIndex: -1,
166
167
  type: type,
@@ -92,7 +92,8 @@ const ValidationIcon = ({
92
92
  isPartOfInput: isPartOfInput,
93
93
  inputSize: size,
94
94
  id: iconId,
95
- focusable: tabIndex !== -1
95
+ focusable: tabIndex !== -1,
96
+ "data-role": `icon-${validationType}`
96
97
  }));
97
98
  };
98
99
  exports.ValidationIcon = ValidationIcon;
@@ -38,11 +38,11 @@ const DatePicker = ({
38
38
  setOpen,
39
39
  pickerTabGuardId
40
40
  }) => {
41
- const l = (0, _useLocale.default)();
41
+ const locale = (0, _useLocale.default)();
42
42
  const {
43
43
  localize,
44
44
  options
45
- } = l.date.dateFnsLocale();
45
+ } = locale.date.dateFnsLocale();
46
46
  const {
47
47
  weekStartsOn
48
48
  } = options || /* istanbul ignore next */{};
@@ -61,7 +61,7 @@ const DatePicker = ({
61
61
  length: 7
62
62
  }).map((_, i) => localize?.day(i)), [localize]);
63
63
  const weekdaysShort = (0, _react.useMemo)(() => {
64
- const isGivenLocale = str => l.locale().includes(str);
64
+ const isGivenLocale = str => locale.locale().includes(str);
65
65
  return Array.from({
66
66
  length: 7
67
67
  }).map((_, i) => localize?.day(i, ["de", "pl"].some(isGivenLocale) ? {
@@ -69,7 +69,7 @@ const DatePicker = ({
69
69
  } : {
70
70
  width: "abbreviated"
71
71
  }).substring(0, isGivenLocale("de") ? 2 : 3));
72
- }, [l, localize]);
72
+ }, [locale, localize]);
73
73
  const ref = (0, _react.useRef)(null);
74
74
  (0, _react.useEffect)(() => {
75
75
  if (open) {
@@ -186,7 +186,7 @@ const DatePicker = ({
186
186
  fixedWeeks: true,
187
187
  initialMonth: selectedDays || undefined,
188
188
  disabledDays: (0, _utils.getDisabledDays)(minDate, maxDate),
189
- locale: l.locale(),
189
+ locale: locale.locale(),
190
190
  localeUtils: localeUtils,
191
191
  onDayKeyDown: handleOnDayKeyDown
192
192
  }, pickerProps))));
@@ -29,7 +29,8 @@ const Navbar = ({
29
29
  }
30
30
  };
31
31
  return /*#__PURE__*/_react.default.createElement(_navbar.default, {
32
- className: className
32
+ className: className,
33
+ "data-role": "date-navbar"
33
34
  }, /*#__PURE__*/_react.default.createElement(_button.default, {
34
35
  "aria-label": previousMonthButton(),
35
36
  onClick: () => onPreviousClick?.(),
@@ -57,10 +57,10 @@ const DateInput = exports.DateInput = /*#__PURE__*/_react.default.forwardRef(({
57
57
  const alreadyFocused = (0, _react.useRef)(false);
58
58
  const isBlurBlocked = (0, _react.useRef)(false);
59
59
  const focusedViaPicker = (0, _react.useRef)(false);
60
- const l = (0, _useLocale.default)();
60
+ const locale = (0, _useLocale.default)();
61
61
  const {
62
62
  dateFnsLocale
63
- } = l.date;
63
+ } = locale.date;
64
64
  const {
65
65
  format,
66
66
  formats
@@ -10,7 +10,7 @@ export interface ContentPaddingInterface {
10
10
  py?: PaddingValues;
11
11
  px?: PaddingValues;
12
12
  }
13
- export interface DialogProps extends ModalProps, TagProps {
13
+ export interface DialogProps extends ModalProps, Omit<TagProps, "data-component"> {
14
14
  /** Custom class name */
15
15
  className?: string;
16
16
  /** Prop to specify the aria-describedby property of the Dialog component */
@@ -25,6 +25,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
25
25
  const PADDING_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
26
26
  const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
27
27
  className,
28
+ "data-element": dataElement = "dialog",
29
+ "data-role": dataRole,
28
30
  children,
29
31
  open,
30
32
  height,
@@ -157,19 +159,14 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
157
159
  "aria-describedby": subtitle && typeof subtitle === "string" ? subtitleId : rest["aria-describedby"],
158
160
  "aria-label": rest["aria-label"]
159
161
  };
160
- const componentTags = {
161
- "data-component": rest["data-component"] || "dialog",
162
- "data-element": rest["data-element"],
163
- "data-role": rest["data-role"]
164
- };
165
- return /*#__PURE__*/_react.default.createElement(_modal.default, _extends({
162
+ return /*#__PURE__*/_react.default.createElement(_modal.default, {
166
163
  open: open,
167
164
  onCancel: onCancel,
168
165
  disableEscKey: disableEscKey,
169
166
  disableClose: disableClose,
170
167
  className: className ? `${className} carbon-dialog` : "carbon-dialog",
171
168
  topModalOverride: topModalOverride
172
- }, componentTags), /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
169
+ }, /*#__PURE__*/_react.default.createElement(_focusTrap.default, {
173
170
  autoFocus: !disableAutoFocus,
174
171
  focusFirstElement: focusFirstElement,
175
172
  bespokeTrap: bespokeFocusTrap,
@@ -178,18 +175,21 @@ const Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(({
178
175
  isOpen: open,
179
176
  additionalWrapperRefs: focusableContainers
180
177
  }, /*#__PURE__*/_react.default.createElement(_dialog.StyledDialog, _extends({
178
+ "data-component": "dialog",
179
+ "data-element": dataElement,
180
+ "data-role": dataRole,
181
181
  "aria-modal": isTopModal ? true : undefined,
182
182
  ref: containerRef,
183
183
  topMargin: _dialog2.TOP_MARGIN
184
184
  }, dialogProps, {
185
- "data-component": "dialog",
186
- "data-element": "dialog",
187
- "data-role": rest["data-role"],
188
185
  role: role,
189
186
  tabIndex: -1
190
187
  }, contentPadding, {
191
188
  backgroundColor: greyBackground ? "var(--colorsUtilityMajor025)" : "var(--colorsUtilityYang100)"
192
- }), dialogTitle(), closeIcon(), /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogContent, contentPadding, /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogInnerContent, _extends({
189
+ }), dialogTitle(), closeIcon(), /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogContent, _extends({}, contentPadding, {
190
+ "data-role": "dialog-content"
191
+ }), /*#__PURE__*/_react.default.createElement(_dialog.StyledDialogInnerContent, _extends({
192
+ "data-role": "dialog-inner-content",
193
193
  ref: innerContentRef
194
194
  }, contentPadding), children)))));
195
195
  });
@@ -211,7 +211,6 @@ if (process.env.NODE_ENV !== "production") {
211
211
  "px": _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]),
212
212
  "py": _propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8])
213
213
  }),
214
- "data-component": _propTypes.default.string,
215
214
  "data-element": _propTypes.default.string,
216
215
  "data-role": _propTypes.default.string,
217
216
  "disableAutoFocus": _propTypes.default.bool,
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { TagProps } from "../../__internal__/utils/helpers/tags";
3
- export interface ModalProps extends TagProps {
3
+ export interface ModalProps extends Omit<TagProps, "data-component"> {
4
4
  /** Custom class name */
5
5
  className?: string;
6
6
  /** Modal content */
@@ -22,5 +22,5 @@ export interface ModalProps extends TagProps {
22
22
  /** Manually override the internal modal stacking order to set this as top */
23
23
  topModalOverride?: boolean;
24
24
  }
25
- declare const Modal: ({ children, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
25
+ declare const Modal: ({ children, "data-element": dataElement, "data-role": dataRole, open, onCancel, disableEscKey, disableClose, enableBackgroundUI, timeout, topModalOverride, ...rest }: ModalProps) => React.JSX.Element;
26
26
  export default Modal;
@@ -19,6 +19,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
19
19
  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); }
20
20
  const Modal = ({
21
21
  children,
22
+ "data-element": dataElement,
23
+ "data-role": dataRole = "modal",
22
24
  open,
23
25
  onCancel,
24
26
  disableEscKey = false,
@@ -79,6 +81,9 @@ const Modal = ({
79
81
  content = children;
80
82
  }
81
83
  return /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_modal.StyledModal, _extends({
84
+ "data-component": "modal",
85
+ "data-element": dataElement,
86
+ "data-role": dataRole,
82
87
  "data-state": open ? "open" : "closed",
83
88
  transitionName: "modal",
84
89
  transitionTime: timeout,
@@ -69,8 +69,9 @@ const StyledProgressBar = exports.StyledProgressBar = _styledComponents.default.
69
69
  })};
70
70
  border-radius: ${theme.roundedCornersOptOut ? "25px" : "var(--borderRadius400)"};
71
71
  overflow-x: hidden;
72
- height: ${getHeight(size)};
73
- width: 100%;
72
+ width: 100%
73
+ min-height: fit-content;
74
+ box-sizing: border-box;
74
75
  `}
75
76
  `;
76
77
  const fontSizes = {
@@ -170,6 +170,7 @@ const Tooltip = exports.Tooltip = /*#__PURE__*/_react.default.forwardRef(({
170
170
  ref: handleTargetRef
171
171
  }), showTooltip ? /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
172
172
  "data-element": "tooltip",
173
+ "data-role": "tooltip",
173
174
  role: "tooltip",
174
175
  tabIndex: -1,
175
176
  type: type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "139.0.0",
3
+ "version": "140.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",