carbon-react 109.2.1 → 109.2.4

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 (55) hide show
  1. package/esm/__internal__/validations/validation-icon.component.js +1 -1
  2. package/esm/components/accordion/accordion-group/accordion-group.component.js +1 -1
  3. package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
  4. package/esm/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
  5. package/esm/components/action-popover/action-popover.component.js +1 -1
  6. package/esm/components/anchor-navigation/anchor-navigation.component.js +2 -2
  7. package/esm/components/badge/badge.style.d.ts +1 -4
  8. package/esm/components/button/button.component.d.ts +1 -4
  9. package/esm/components/button/button.component.js +28 -14
  10. package/esm/components/button-bar/button-bar.component.js +1 -1
  11. package/esm/components/decimal/decimal.component.js +3 -3
  12. package/esm/components/drawer/drawer.component.js +1 -1
  13. package/esm/components/duelling-picklist/picklist-group/picklist-group.style.js +2 -2
  14. package/esm/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
  15. package/esm/components/icon/icon.component.js +1 -1
  16. package/esm/components/menu/__internal__/submenu/submenu.component.js +1 -0
  17. package/esm/components/multi-action-button/multi-action-button.component.js +1 -6
  18. package/esm/components/note/note.component.js +6 -6
  19. package/esm/components/numeral-date/numeral-date.component.js +1 -1
  20. package/esm/components/search/search.component.js +1 -1
  21. package/esm/components/select/filterable-select/filterable-select.component.js +3 -3
  22. package/esm/components/select/multi-select/multi-select.component.js +2 -2
  23. package/esm/components/select/simple-select/simple-select.component.js +2 -2
  24. package/esm/components/split-button/split-button.component.js +1 -6
  25. package/esm/components/tooltip/tooltip.component.js +1 -1
  26. package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +39 -37
  27. package/lib/__internal__/validations/validation-icon.component.js +1 -1
  28. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -1
  29. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
  30. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
  31. package/lib/components/action-popover/action-popover.component.js +1 -1
  32. package/lib/components/anchor-navigation/anchor-navigation.component.js +2 -2
  33. package/lib/components/badge/badge.style.d.ts +1 -4
  34. package/lib/components/button/button.component.d.ts +1 -4
  35. package/lib/components/button/button.component.js +31 -12
  36. package/lib/components/button-bar/button-bar.component.js +1 -1
  37. package/lib/components/decimal/decimal.component.js +3 -3
  38. package/lib/components/drawer/drawer.component.js +1 -1
  39. package/lib/components/duelling-picklist/picklist-group/picklist-group.style.js +4 -2
  40. package/lib/components/duelling-picklist/picklist-item/picklist-item.style.js +2 -2
  41. package/lib/components/icon/icon.component.js +1 -1
  42. package/lib/components/menu/__internal__/submenu/submenu.component.js +1 -0
  43. package/lib/components/multi-action-button/multi-action-button.component.js +1 -6
  44. package/lib/components/note/note.component.js +6 -6
  45. package/lib/components/numeral-date/numeral-date.component.js +1 -1
  46. package/lib/components/search/search.component.js +1 -1
  47. package/lib/components/select/filterable-select/filterable-select.component.js +3 -3
  48. package/lib/components/select/multi-select/multi-select.component.js +2 -2
  49. package/lib/components/select/simple-select/simple-select.component.js +2 -2
  50. package/lib/components/split-button/split-button.component.js +1 -6
  51. package/lib/components/tooltip/tooltip.component.js +1 -1
  52. package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +38 -36
  53. package/package.json +17 -14
  54. package/scripts/{check_carbon_version.js → check_carbon_version/check_carbon_version.js} +10 -2
  55. package/scripts/{check_rfcs.js → check_rfcs/check_rfcs.js} +8 -1
@@ -34,7 +34,7 @@ const AnchorNavigation = ({
34
34
  children,
35
35
  stickyNavigation
36
36
  }) => {
37
- (0, _invariant.default)((0, _reactIs.isFragment)(stickyNavigation), "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.");
37
+ !(0, _reactIs.isFragment)(stickyNavigation) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.") : (0, _invariant.default)(false) : void 0;
38
38
  const hasCorrectItemStructure = (0, _react.useMemo)(() => {
39
39
  const incorrectChild = _react.default.Children.toArray(stickyNavigation.props.children).find(child => {
40
40
  return ! /*#__PURE__*/_react.default.isValidElement(child) || child.type.displayName !== _anchorNavigationItem.default.displayName;
@@ -42,7 +42,7 @@ const AnchorNavigation = ({
42
42
 
43
43
  return !incorrectChild;
44
44
  }, [stickyNavigation]);
45
- (0, _invariant.default)(hasCorrectItemStructure, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${_anchorNavigationItem.default.displayName}\``);
45
+ !hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${_anchorNavigationItem.default.displayName}\``) : (0, _invariant.default)(false) : void 0;
46
46
  const [selectedIndex, setSelectedIndex] = (0, _react.useState)(0);
47
47
  const sectionRefs = (0, _react.useRef)(_react.default.Children.map(stickyNavigation.props.children, child => child.props.target));
48
48
  const anchorRefs = (0, _react.useRef)(Array.from({
@@ -1,9 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  declare const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- declare const StyledButton: import("styled-components").StyledComponent<{
5
- ({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: import("../button").ButtonProps): JSX.Element;
6
- displayName: string;
7
- }, any, {}, never>;
4
+ declare const StyledButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../button").ButtonProps & import("react").RefAttributes<HTMLButtonElement>>, any, {}, never>;
8
5
  declare const StyledCrossIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
9
6
  export { StyledBadgeWrapper, StyledButton, StyledCrossIcon, StyledCounter };
@@ -58,10 +58,7 @@ export interface ButtonProps extends SpaceProps {
58
58
  /** HTML rel attribute */
59
59
  rel?: string;
60
60
  }
61
- declare const Button: {
62
- ({ size, subtext, children, forwardRef, "aria-label": ariaLabel, disabled, destructive, buttonType: buttonTypeProp, iconType, iconPosition, href, m, px, noWrap, target, rel, iconTooltipMessage, iconTooltipPosition, fullWidth, ...rest }: ButtonProps): JSX.Element;
63
- displayName: string;
64
- };
61
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
65
62
  declare const ButtonWithForwardRef: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
66
63
  export { ButtonWithForwardRef };
67
64
  export default Button;
@@ -19,6 +19,8 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
19
19
 
20
20
  var _tooltipProvider = require("../../__internal__/tooltip-provider");
21
21
 
22
+ var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
23
+
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
25
 
24
26
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
@@ -92,8 +94,9 @@ renderChildren.propTypes = {
92
94
  }
93
95
  }
94
96
  };
97
+ let deprecatedForwardRefWarnTriggered = false;
95
98
 
96
- const Button = ({
99
+ const Button = /*#__PURE__*/_react.default.forwardRef(({
97
100
  size = "medium",
98
101
  subtext = "",
99
102
  children,
@@ -114,11 +117,17 @@ const Button = ({
114
117
  iconTooltipPosition,
115
118
  fullWidth = false,
116
119
  ...rest
117
- }) => {
118
- (0, _invariant.default)(!!(children || iconType), "Either prop `iconType` must be defined or this node must have children.");
120
+ }, ref) => {
121
+ !!!(children || iconType) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Either prop `iconType` must be defined or this node must have children.") : (0, _invariant.default)(false) : void 0;
119
122
 
120
123
  if (subtext) {
121
- (0, _invariant.default)(size === "large", "subtext prop has no effect unless the button is large.");
124
+ !(size === "large") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "subtext prop has no effect unless the button is large.") : (0, _invariant.default)(false) : void 0;
125
+ }
126
+
127
+ if (!deprecatedForwardRefWarnTriggered && forwardRef) {
128
+ deprecatedForwardRefWarnTriggered = true;
129
+
130
+ _logger.default.deprecate("The `forwardRef` prop in `Button` component is deprecated and will soon be removed. Please use `ref` instead.");
122
131
  }
123
132
 
124
133
  const [internalRef, setInternalRef] = (0, _react.useState)();
@@ -148,10 +157,11 @@ const Button = ({
148
157
 
149
158
  const setRefs = (0, _react.useCallback)(reference => {
150
159
  setInternalRef(reference);
151
- if (!forwardRef) return;
152
- if (typeof forwardRef === "object") forwardRef.current = reference;
153
- if (typeof forwardRef === "function") forwardRef(reference);
154
- }, [forwardRef]);
160
+ const activeRef = ref || forwardRef;
161
+ if (!activeRef) return;
162
+ if (typeof activeRef === "object") activeRef.current = reference;
163
+ if (typeof activeRef === "function") activeRef(reference);
164
+ }, [ref, forwardRef]);
155
165
  return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
156
166
  "aria-label": !children && iconType ? ariaLabel || iconType : undefined,
157
167
  as: !disabled && href ? "a" : "button",
@@ -188,7 +198,7 @@ const Button = ({
188
198
  iconTooltipPosition,
189
199
  tooltipTarget: internalRef
190
200
  }));
191
- };
201
+ });
192
202
 
193
203
  Button.propTypes = {
194
204
  "aria-label": _propTypes.default.string,
@@ -526,10 +536,19 @@ Button.propTypes = {
526
536
  "target": _propTypes.default.string,
527
537
  "type": _propTypes.default.string
528
538
  };
539
+ let deprecatedButtonForwardRefWarnTriggered = false;
540
+
541
+ const ButtonWithForwardRef = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
542
+ if (!deprecatedButtonForwardRefWarnTriggered) {
543
+ deprecatedButtonForwardRefWarnTriggered = true;
529
544
 
530
- const ButtonWithForwardRef = /*#__PURE__*/_react.default.forwardRef((props, ref) => /*#__PURE__*/_react.default.createElement(Button, _extends({
531
- forwardRef: ref
532
- }, props)));
545
+ _logger.default.deprecate("The `ButtonWithForwardRef` component is deprecated and will soon be removed. Please use a basic `Button` component with `ref` instead.");
546
+ }
547
+
548
+ return /*#__PURE__*/_react.default.createElement(Button, _extends({
549
+ ref: ref
550
+ }, props));
551
+ });
533
552
 
534
553
  exports.ButtonWithForwardRef = ButtonWithForwardRef;
535
554
  ButtonWithForwardRef.propTypes = {
@@ -43,7 +43,7 @@ const ButtonBar = ({
43
43
 
44
44
  return !incorrectChild;
45
45
  }, [children]);
46
- (0, _invariant.default)(hasProperChildren, "ButtonBar accepts only `Button` or `IconButton` elements.");
46
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ButtonBar accepts only `Button` or `IconButton` elements.") : (0, _invariant.default)(false) : void 0;
47
47
 
48
48
  const getBtnProps = child => {
49
49
  var _child$props, _child$props2, _child$props2$childre, _child$props2$childre2;
@@ -52,10 +52,10 @@ const Decimal = ({
52
52
  const emptyValue = allowEmptyValue ? "" : "0.00";
53
53
  const getSafeValueProp = (0, _react.useCallback)(initialValue => {
54
54
  // We're intentionally preventing the use of number values to help prevent any unintentional rounding issues
55
- (0, _invariant.default)(typeof initialValue === "string", "Decimal `value` prop must be a string");
55
+ !(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Decimal `value` prop must be a string") : (0, _invariant.default)(false) : void 0;
56
56
 
57
57
  if (initialValue && !allowEmptyValue) {
58
- (0, _invariant.default)(initialValue !== "", "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`");
58
+ !(initialValue !== "") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`") : (0, _invariant.default)(false) : void 0;
59
59
  }
60
60
 
61
61
  return initialValue;
@@ -185,7 +185,7 @@ const Decimal = ({
185
185
  const prevControlledRef = (0, _react.useRef)();
186
186
  (0, _react.useEffect)(() => {
187
187
  const message = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
188
- (0, _invariant.default)(prevControlledRef.current !== isControlled, message);
188
+ !(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, message) : (0, _invariant.default)(false) : void 0;
189
189
  prevControlledRef.current = isControlled;
190
190
  }, [isControlled]);
191
191
  const prevValue = (0, _usePrevious.default)(value);
@@ -93,7 +93,7 @@ const Drawer = ({
93
93
  const previousValue = (0, _usePrevious.default)(expanded);
94
94
  (0, _react.useEffect)(() => {
95
95
  const message = "Drawer should not switch from uncontrolled to controlled" + " (or vice versa). Decide between using a controlled or uncontrolled Drawer element" + " for the lifetime of the component";
96
- (0, _invariant.default)(isControlled.current === (expanded !== undefined), message);
96
+ !(isControlled.current === (expanded !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, message) : (0, _invariant.default)(false) : void 0;
97
97
 
98
98
  if (isControlled.current && previousValue !== expanded) {
99
99
  setIsExpanded(expanded);
@@ -7,10 +7,12 @@ exports.StyledGroupButton = exports.StyledPicklistGroup = exports.StyledPicklist
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _button = require("../../button");
10
+ var _button = _interopRequireDefault(require("../../button"));
11
11
 
12
12
  var _picklistItem = require("../picklist-item/picklist-item.style");
13
13
 
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
14
16
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
15
17
 
16
18
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -42,7 +44,7 @@ const StyledPicklistGroup = _styledComponents.default.li`
42
44
  margin-bottom: 4px;
43
45
  `;
44
46
  exports.StyledPicklistGroup = StyledPicklistGroup;
45
- const StyledGroupButton = (0, _styledComponents.default)(_button.ButtonWithForwardRef)`
47
+ const StyledGroupButton = (0, _styledComponents.default)(_button.default)`
46
48
  ${({
47
49
  iconType
48
50
  }) => (0, _styledComponents.css)`
@@ -7,7 +7,7 @@ exports.StyledLockIcon = exports.StyledButton = exports.StyledPicklistItem = voi
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _button = require("../../button");
10
+ var _button = _interopRequireDefault(require("../../button"));
11
11
 
12
12
  var _icon = _interopRequireDefault(require("../../icon"));
13
13
 
@@ -48,7 +48,7 @@ const StyledPicklistItem = _styledComponents.default.li`
48
48
  `}
49
49
  `;
50
50
  exports.StyledPicklistItem = StyledPicklistItem;
51
- const StyledButton = (0, _styledComponents.default)(_button.ButtonWithForwardRef)`
51
+ const StyledButton = (0, _styledComponents.default)(_button.default)`
52
52
  ${({
53
53
  iconType
54
54
  }) => (0, _styledComponents.css)`
@@ -58,7 +58,7 @@ const Icon = /*#__PURE__*/_react.default.forwardRef(({
58
58
  const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => _iconConfig.ICON_TOOLTIP_POSITIONS.includes(override));
59
59
 
60
60
  if (tooltipFlipOverrides) {
61
- (0, _invariant.default)(flipBehaviourCheck, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
61
+ !flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
62
62
  }
63
63
 
64
64
  const isInteractive = !!tooltipMessage && !disabled;
@@ -242,6 +242,7 @@ const Submenu = /*#__PURE__*/_react.default.forwardRef(({
242
242
  menuType: menuContext.menuType,
243
243
  asPassiveItem: asPassiveItem
244
244
  }, /*#__PURE__*/_react.default.createElement(_menuItem.default, _extends({}, rest, {
245
+ onClick: onClick,
245
246
  className: className,
246
247
  menuType: menuContext.menuType,
247
248
  ref: ref,
@@ -13,7 +13,7 @@ var _useClickAwayListener = _interopRequireDefault(require("../../hooks/__intern
13
13
 
14
14
  var _multiActionButton = require("./multi-action-button.style");
15
15
 
16
- var _button = _interopRequireWildcard(require("../button"));
16
+ var _button = _interopRequireDefault(require("../button"));
17
17
 
18
18
  var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
19
19
 
@@ -88,11 +88,6 @@ const MultiActionButton = ({
88
88
  (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
89
89
  }
90
90
  };
91
-
92
- if (child.type === _button.default) {
93
- return /*#__PURE__*/_react.default.createElement(_button.ButtonWithForwardRef, _extends({}, child.props, props));
94
- }
95
-
96
91
  return /*#__PURE__*/_react.default.cloneElement(child, props);
97
92
  });
98
93
  };
@@ -45,12 +45,12 @@ const Note = ({
45
45
  onLinkAdded,
46
46
  ...rest
47
47
  }) => {
48
- (0, _invariant.default)(width > 0, "<Note> width must be greater than 0");
49
- (0, _invariant.default)(createdDate, "<Note> createdDate is required");
50
- (0, _invariant.default)(noteContent, "<Note> noteContent is required");
51
- (0, _invariant.default)(!status || status.text, "<Note> status.text is required");
52
- (0, _invariant.default)(!status || status.timeStamp, "<Note> status.timeStamp is required");
53
- (0, _invariant.default)(!inlineControl || inlineControl.type === _actionPopover.ActionPopover, "<Note> inlineControl must be an instance of <ActionPopover>");
48
+ !(width > 0) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> width must be greater than 0") : (0, _invariant.default)(false) : void 0;
49
+ !createdDate ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> createdDate is required") : (0, _invariant.default)(false) : void 0;
50
+ !noteContent ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> noteContent is required") : (0, _invariant.default)(false) : void 0;
51
+ !(!status || status.text) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> status.text is required") : (0, _invariant.default)(false) : void 0;
52
+ !(!status || status.timeStamp) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> status.timeStamp is required") : (0, _invariant.default)(false) : void 0;
53
+ !(!inlineControl || inlineControl.type === _actionPopover.ActionPopover) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "<Note> inlineControl must be an instance of <ActionPopover>") : (0, _invariant.default)(false) : void 0;
54
54
 
55
55
  const renderStatus = () => {
56
56
  if (!status) {
@@ -108,7 +108,7 @@ const NumeralDate = ({
108
108
  const [internalMessages, setInternalMessages] = (0, _react.useState)({});
109
109
  (0, _react.useEffect)(() => {
110
110
  const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
111
- (0, _invariant.default)(isControlled.current === (value !== undefined), modeSwitchedMessage);
111
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
112
112
  }, [value]);
113
113
  const validationMessages = {
114
114
  dd: l.numeralDate.validation.day(),
@@ -57,7 +57,7 @@ const Search = ({
57
57
  }) => {
58
58
  const isControlled = value !== undefined;
59
59
  const initialValue = isControlled ? value : defaultValue;
60
- (0, _invariant.default)(typeof initialValue === "string", "This component has no initial value");
60
+ !(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "This component has no initial value") : (0, _invariant.default)(false) : void 0;
61
61
  const [searchValue, setSearchValue] = (0, _react.useState)(initialValue);
62
62
  const [isFocused, setIsFocused] = (0, _react.useState)(false);
63
63
  const [searchIsActive, setSearchIsActive] = (0, _react.useState)(initialValue.length >= threshold);
@@ -193,8 +193,8 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
193
193
  (0, _react.useEffect)(() => {
194
194
  const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
195
195
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
196
- (0, _invariant.default)(isControlled.current === (value !== undefined), modeSwitchedMessage);
197
- (0, _invariant.default)(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
196
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
197
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
198
198
 
199
199
  if (isControlled.current) {
200
200
  setSelectedValue(prevValue => {
@@ -228,7 +228,7 @@ const FilterableSelect = /*#__PURE__*/_react.default.forwardRef(({
228
228
  (0, _react.useEffect)(() => {
229
229
  const hasListActionButton = listActionButton !== undefined;
230
230
  const onListActionMissingMessage = "onListAction prop required when using listActionButton prop";
231
- (0, _invariant.default)(!hasListActionButton || hasListActionButton && onListAction, onListActionMissingMessage);
231
+ !(!hasListActionButton || hasListActionButton && onListAction) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onListActionMissingMessage) : (0, _invariant.default)(false) : void 0;
232
232
  }, [listActionButton, onListAction]);
233
233
  (0, _react.useEffect)(() => {
234
234
  if (isControlled.current) {
@@ -229,8 +229,8 @@ const MultiSelect = /*#__PURE__*/_react.default.forwardRef(({
229
229
  (0, _react.useEffect)(() => {
230
230
  const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
231
231
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
232
- (0, _invariant.default)(isControlled.current === (value !== undefined), modeSwitchedMessage);
233
- (0, _invariant.default)(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
232
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
233
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
234
234
 
235
235
  if (isControlled.current) {
236
236
  setSelectedValue(value);
@@ -174,8 +174,8 @@ const SimpleSelect = /*#__PURE__*/_react.default.forwardRef(({
174
174
  (0, _react.useEffect)(() => {
175
175
  const modeSwitchedMessage = "Input elements should not switch from uncontrolled to controlled (or vice versa). " + "Decide between using a controlled or uncontrolled input element for the lifetime of the component";
176
176
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
177
- (0, _invariant.default)(isControlled.current === (value !== undefined), modeSwitchedMessage);
178
- (0, _invariant.default)(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
177
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, modeSwitchedMessage) : (0, _invariant.default)(false) : void 0;
178
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, onChangeMissingMessage) : (0, _invariant.default)(false) : void 0;
179
179
 
180
180
  if (isControlled.current) {
181
181
  setSelectedValue(value);
@@ -17,7 +17,7 @@ var _useClickAwayListener = _interopRequireDefault(require("../../hooks/__intern
17
17
 
18
18
  var _icon = _interopRequireDefault(require("../icon"));
19
19
 
20
- var _button = _interopRequireWildcard(require("../button"));
20
+ var _button = _interopRequireDefault(require("../button"));
21
21
 
22
22
  var _splitButton = _interopRequireDefault(require("./split-button.style"));
23
23
 
@@ -249,11 +249,6 @@ const SplitButton = ({
249
249
  (_toggleButton$current = toggleButton.current) === null || _toggleButton$current === void 0 ? void 0 : _toggleButton$current.focus();
250
250
  }
251
251
  };
252
-
253
- if (child.type === _button.default) {
254
- return /*#__PURE__*/_react.default.createElement(_button.ButtonWithForwardRef, _extends({}, child.props, childProps));
255
- }
256
-
257
252
  return /*#__PURE__*/_react.default.cloneElement(child, childProps);
258
253
  });
259
254
  }
@@ -49,7 +49,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
49
49
  ...rest
50
50
  }, ref) => {
51
51
  const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => _tooltip2.TOOLTIP_POSITIONS.includes(placement));
52
- (0, _invariant.default)(isFlipOverridesValid, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`);
52
+ !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
53
53
 
54
54
  const tooltip = (attrs, content) => {
55
55
  const currentPosition = attrs["data-placement"] || position;
@@ -17,51 +17,53 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  // we can confirm that all Sage products use version 105.0.0^
18
18
  const scrollBlockManager = new _scrollBlockManager.default();
19
19
 
20
+ const getRules = () => {
21
+ /* istanbul ignore next */
22
+ const {
23
+ documentElement,
24
+ body
25
+ } = document || {};
26
+ const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
27
+ const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
28
+ return [// TODO: First two entries of this array with the documentElement can be removed
29
+ {
30
+ element: documentElement,
31
+ property: "position",
32
+ blockingValue: "relative"
33
+ }, {
34
+ element: documentElement,
35
+ property: "overflow",
36
+ blockingValue: "hidden"
37
+ }, {
38
+ element: body,
39
+ property: "position",
40
+ blockingValue: "relative"
41
+ }, {
42
+ element: body,
43
+ property: "overflow",
44
+ blockingValue: "hidden"
45
+ }, {
46
+ element: body,
47
+ property: "paddingRight",
48
+ blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
49
+ }];
50
+ };
51
+
20
52
  const useScrollBlock = () => {
21
53
  const {
22
54
  current: containerGuid
23
55
  } = (0, _react.useRef)((0, _guid.default)());
24
56
  const originalValuesRef = (0, _react.useRef)([]);
25
- const rules = (0, _react.useMemo)(() => {
26
- /* istanbul ignore next */
27
- const {
28
- documentElement,
29
- body
30
- } = document || {};
31
- const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
32
- const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
33
- return [// TODO: First two entries of this array with the documentElement can be removed
34
- {
35
- element: documentElement,
36
- property: "position",
37
- blockingValue: "relative"
38
- }, {
39
- element: documentElement,
40
- property: "overflow",
41
- blockingValue: "hidden"
42
- }, {
43
- element: body,
44
- property: "position",
45
- blockingValue: "relative"
46
- }, {
47
- element: body,
48
- property: "overflow",
49
- blockingValue: "hidden"
50
- }, {
51
- element: body,
52
- property: "paddingRight",
53
- blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
54
- }];
55
- }, []);
56
57
  const restoreValues = (0, _react.useCallback)(() => {
57
- rules.forEach(({
58
+ getRules().forEach(({
58
59
  element,
59
60
  property
60
61
  }, index) => {
61
62
  element.style[property] = originalValuesRef.current[index];
62
63
  });
63
- }, [rules]);
64
+ }, []);
64
65
  const blockScroll = (0, _react.useCallback)(() => {
66
+ const rules = getRules();
65
67
  const isBlocked = scrollBlockManager.isBlocked();
66
68
  scrollBlockManager.registerComponent(containerGuid);
67
69
 
@@ -85,7 +87,7 @@ const useScrollBlock = () => {
85
87
  }) => {
86
88
  element.style[property] = blockingValue;
87
89
  });
88
- }, [restoreValues, containerGuid, rules]);
90
+ }, [restoreValues, containerGuid]);
89
91
  const allowScroll = (0, _react.useCallback)(() => {
90
92
  scrollBlockManager.unregisterComponent(containerGuid);
91
93
  const isBlocked = scrollBlockManager.isBlocked();
@@ -100,14 +102,14 @@ const useScrollBlock = () => {
100
102
 
101
103
 
102
104
  const originalValues = scrollBlockManager.getOriginalValues();
103
- rules.forEach(({
105
+ getRules().forEach(({
104
106
  element,
105
107
  property
106
108
  }, index) => {
107
109
  element.style[property] = originalValues[index];
108
110
  });
109
111
  scrollBlockManager.saveOriginalValues([]);
110
- }, [containerGuid, rules]);
112
+ }, [containerGuid]);
111
113
  return {
112
114
  blockScroll,
113
115
  allowScroll
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "109.2.1",
3
+ "version": "109.2.4",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -10,8 +10,8 @@
10
10
  "files": [
11
11
  "lib",
12
12
  "esm",
13
- "scripts/check_carbon_version.js",
14
- "scripts/check_rfcs.js"
13
+ "scripts/check_carbon_version/check_carbon_version.js",
14
+ "scripts/check_rfcs/check_rfcs.js"
15
15
  ],
16
16
  "scripts": {
17
17
  "start": "node ./scripts/check_node_version.js && start-storybook -p 9001 -c .storybook",
@@ -27,7 +27,7 @@
27
27
  "copy-files": "node ./scripts/copy-files.js",
28
28
  "precompile": "npm run type-check && npm run clean-lib && npm run build && npm run build:types && npm run copy-files",
29
29
  "prepublishOnly": "npm run precompile",
30
- "postinstall": "node ./scripts/check_carbon_version.js && node ./scripts/check_rfcs.js",
30
+ "postinstall": "node ./scripts/check_carbon_version/check_carbon_version.js && node ./scripts/check_rfcs/check_rfcs.js",
31
31
  "watch": "npm run clean-lib && npm run copy-files -- --watch & npm run babel -- --watch",
32
32
  "build-storybook": "cross-env STORYBOOK_BUILD=true build-storybook -c .storybook",
33
33
  "start-storybook": "cross-env STORYBOOK_BUILD=true start-storybook -c .storybook",
@@ -109,6 +109,7 @@
109
109
  "axe-core": "^3.5.5",
110
110
  "babel-eslint": "10.0.3",
111
111
  "babel-jest": "^26.6.3",
112
+ "babel-plugin-dev-expression": "^0.2.3",
112
113
  "browserslist": "^4.16.6",
113
114
  "chalk": "^4.1.1",
114
115
  "chromatic": "^6.0.5",
@@ -117,9 +118,8 @@
117
118
  "core-js": "^3.20.3",
118
119
  "cross-env": "^5.2.0",
119
120
  "css-loader": "4.0.0",
120
- "cypress": "^10.1.0",
121
- "cypress-axe": "^0.14.0",
122
- "cypress-cucumber-preprocessor": "^4.3.1",
121
+ "cypress": "^10.3.0",
122
+ "cypress-axe": "^1.0.0",
123
123
  "cypress-each": "^1.11.0",
124
124
  "cypress-plugin-tab": "^1.0.5",
125
125
  "cypress-real-events": "^1.7.0",
@@ -151,6 +151,7 @@
151
151
  "jest-styled-components": "^6.3.1",
152
152
  "lint-staged": "^10.5.3",
153
153
  "mockdate": "^2.0.2",
154
+ "nock": "^13.2.8",
154
155
  "prettier": "^2.1.2",
155
156
  "raf": "^3.4.0",
156
157
  "react": "^17.0.2",
@@ -169,15 +170,19 @@
169
170
  "webpack-dev-server": "^4.0.0"
170
171
  },
171
172
  "dependencies": {
173
+ "@badeball/cypress-cucumber-preprocessor": "^11.4.0",
174
+ "@bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
172
175
  "@octokit/rest": "^18.12.0",
173
176
  "@popperjs/core": "^2.11.5",
174
177
  "@styled-system/prop-types": "^5.1.5",
175
178
  "@tippyjs/react": "^4.2.5",
176
179
  "@types/styled-system": "^5.1.11",
180
+ "ci-info": "^3.3.2",
177
181
  "classnames": "~2.2.6",
178
182
  "crypto-js": "~3.3.0",
179
183
  "date-fns": "^2.26.0",
180
184
  "dotenv": "^10.0.0",
185
+ "esbuild": "^0.14.47",
181
186
  "immutable": "~3.8.2",
182
187
  "invariant": "^2.2.4",
183
188
  "lodash": "^4.17.20",
@@ -193,13 +198,11 @@
193
198
  "wait-on": "^5.2.1"
194
199
  },
195
200
  "cypress-cucumber-preprocessor": {
196
- "step_definitions": "cypress/support/step-definitions/",
197
- "cucumberJson": {
198
- "generate": false,
199
- "outputFolder": "cypress/cucumber-json",
200
- "filePrefix": "",
201
- "fileSuffix": ".cucumber"
202
- }
201
+ "nonGlobalStepDefinitions": true,
202
+ "stepDefinitions": [
203
+ "cypress/support/step-definitions/*.{js,ts}",
204
+ "cypress/support/helper.js"
205
+ ]
203
206
  },
204
207
  "config": {
205
208
  "commitizen": {
@@ -2,12 +2,17 @@
2
2
  const fetch = require("node-fetch");
3
3
  const dotenv = require("dotenv");
4
4
  const chalk = require("chalk");
5
- const { version } = require("../package.json");
5
+ const ci = require("ci-info");
6
+ const { version } = require("../../package.json");
6
7
 
7
8
  dotenv.config();
8
9
  const majorVersion = version.split(".")[0];
9
10
 
10
11
  const checkCarbonVersion = () => {
12
+ if (ci.BITRISE) {
13
+ return;
14
+ }
15
+
11
16
  fetch("https://registry.npmjs.com/carbon-react")
12
17
  .then((res) => res.json())
13
18
  .then((data) => {
@@ -16,6 +21,7 @@ const checkCarbonVersion = () => {
16
21
 
17
22
  const diff = Number(latestMajor) - Number(majorVersion);
18
23
 
24
+ // This is ignored as coverage will fail when run in CI without it
19
25
  if (diff > 1) {
20
26
  console.log(
21
27
  `carbon-react version installed is currently ${chalk.yellow(
@@ -27,4 +33,6 @@ const checkCarbonVersion = () => {
27
33
  .catch((err) => console.log(err));
28
34
  };
29
35
 
30
- if (!process.env.CARBON_INSTALL) checkCarbonVersion();
36
+ checkCarbonVersion();
37
+
38
+ module.exports = checkCarbonVersion;