carbon-react 109.2.3 → 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 (41) 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/button/button.component.js +2 -2
  8. package/esm/components/button-bar/button-bar.component.js +1 -1
  9. package/esm/components/decimal/decimal.component.js +3 -3
  10. package/esm/components/drawer/drawer.component.js +1 -1
  11. package/esm/components/icon/icon.component.js +1 -1
  12. package/esm/components/note/note.component.js +6 -6
  13. package/esm/components/numeral-date/numeral-date.component.js +1 -1
  14. package/esm/components/search/search.component.js +1 -1
  15. package/esm/components/select/filterable-select/filterable-select.component.js +3 -3
  16. package/esm/components/select/multi-select/multi-select.component.js +2 -2
  17. package/esm/components/select/simple-select/simple-select.component.js +2 -2
  18. package/esm/components/tooltip/tooltip.component.js +1 -1
  19. package/esm/hooks/__internal__/useScrollBlock/useScrollBlock.js +39 -37
  20. package/lib/__internal__/validations/validation-icon.component.js +1 -1
  21. package/lib/components/accordion/accordion-group/accordion-group.component.js +1 -1
  22. package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +2 -2
  23. package/lib/components/action-popover/action-popover-menu/action-popover-menu.component.js +3 -3
  24. package/lib/components/action-popover/action-popover.component.js +1 -1
  25. package/lib/components/anchor-navigation/anchor-navigation.component.js +2 -2
  26. package/lib/components/button/button.component.js +2 -2
  27. package/lib/components/button-bar/button-bar.component.js +1 -1
  28. package/lib/components/decimal/decimal.component.js +3 -3
  29. package/lib/components/drawer/drawer.component.js +1 -1
  30. package/lib/components/icon/icon.component.js +1 -1
  31. package/lib/components/note/note.component.js +6 -6
  32. package/lib/components/numeral-date/numeral-date.component.js +1 -1
  33. package/lib/components/search/search.component.js +1 -1
  34. package/lib/components/select/filterable-select/filterable-select.component.js +3 -3
  35. package/lib/components/select/multi-select/multi-select.component.js +2 -2
  36. package/lib/components/select/simple-select/simple-select.component.js +2 -2
  37. package/lib/components/tooltip/tooltip.component.js +1 -1
  38. package/lib/hooks/__internal__/useScrollBlock/useScrollBlock.js +38 -36
  39. package/package.json +7 -4
  40. package/scripts/{check_carbon_version.js → check_carbon_version/check_carbon_version.js} +10 -2
  41. package/scripts/{check_rfcs.js → check_rfcs/check_rfcs.js} +8 -1
@@ -38,7 +38,7 @@ const ValidationIcon = ({
38
38
  const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ["bottom", "left", "right", "top"].includes(override));
39
39
 
40
40
  if (tooltipFlipOverrides) {
41
- invariant(flipBehaviourCheck, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`);
41
+ !flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? invariant(false, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
42
42
  }
43
43
 
44
44
  const {
@@ -18,7 +18,7 @@ const AccordionGroup = ({
18
18
  });
19
19
  return hasAccordionChildren;
20
20
  }, [children]);
21
- invariant(hasProperChildren, `AccordionGroup accepts only children of type \`${Accordion.displayName}\`.`);
21
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `AccordionGroup accepts only children of type \`${Accordion.displayName}\`.`) : invariant(false) : void 0;
22
22
  const filteredChildren = useMemo(() => React.Children.toArray(children).filter(child => {
23
23
  return /*#__PURE__*/React.isValidElement(child);
24
24
  }), [children]);
@@ -60,8 +60,8 @@ const ActionPopoverItem = ({
60
60
  }) => {
61
61
  const l = useLocale();
62
62
  const context = useContext(ActionPopoverContext);
63
- invariant(context, "ActionPopoverItem must be used within an ActionPopover component");
64
- invariant( /*#__PURE__*/React.isValidElement(submenu) ? submenu.type === ActionPopoverMenu : true, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`");
63
+ !context ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverItem must be used within an ActionPopover component") : invariant(false) : void 0;
64
+ !( /*#__PURE__*/React.isValidElement(submenu) ? submenu.type === ActionPopoverMenu : true) ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`") : invariant(false) : void 0;
65
65
  const {
66
66
  setOpenPopover,
67
67
  isOpenPopover,
@@ -21,11 +21,11 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
21
21
  ...rest
22
22
  }, ref) => {
23
23
  const context = useContext(ActionPopoverContext);
24
- invariant(context, "ActionPopoverMenu must be used within an ActionPopover component");
24
+ !context ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverMenu must be used within an ActionPopover component") : invariant(false) : void 0;
25
25
  const {
26
26
  focusButton
27
27
  } = context;
28
- invariant(setOpen && setFocusIndex && typeof focusIndex !== "undefined", "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component");
28
+ !(setOpen && setFocusIndex && typeof focusIndex !== "undefined") ? process.env.NODE_ENV !== "production" ? invariant(false, "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component") : invariant(false) : void 0;
29
29
  const hasProperChildren = useMemo(() => {
30
30
  const incorrectChild = React.Children.toArray(children).find(child => {
31
31
  if (! /*#__PURE__*/React.isValidElement(child)) {
@@ -36,7 +36,7 @@ const ActionPopoverMenu = /*#__PURE__*/React.forwardRef(({
36
36
  });
37
37
  return !incorrectChild;
38
38
  }, [children]);
39
- invariant(hasProperChildren, `ActionPopoverMenu only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`);
39
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `ActionPopoverMenu only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`) : invariant(false) : void 0;
40
40
  const items = useMemo(() => {
41
41
  return React.Children.toArray(children).filter(child => {
42
42
  return /*#__PURE__*/React.isValidElement(child) && child.type === ActionPopoverItem;
@@ -49,7 +49,7 @@ const ActionPopover = ({
49
49
  });
50
50
  return !incorrectChild;
51
51
  }, [children]);
52
- invariant(hasProperChildren, `ActionPopover only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`);
52
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, `ActionPopover only accepts children of type \`${ActionPopoverItem.displayName}\`` + ` and \`${ActionPopoverDivider.displayName}\`.`) : invariant(false) : void 0;
53
53
  const mappedPlacement = useMemo(() => {
54
54
  if (placement === "top" && !rightAlignMenu) {
55
55
  return "top-end";
@@ -13,14 +13,14 @@ const AnchorNavigation = ({
13
13
  children,
14
14
  stickyNavigation
15
15
  }) => {
16
- invariant(isFragment(stickyNavigation), "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.");
16
+ !isFragment(stickyNavigation) ? process.env.NODE_ENV !== "production" ? invariant(false, "`stickyNavigation` prop in `AnchorNavigation` should be a React Fragment.") : invariant(false) : void 0;
17
17
  const hasCorrectItemStructure = useMemo(() => {
18
18
  const incorrectChild = React.Children.toArray(stickyNavigation.props.children).find(child => {
19
19
  return ! /*#__PURE__*/React.isValidElement(child) || child.type.displayName !== AnchorNavigationItem.displayName;
20
20
  });
21
21
  return !incorrectChild;
22
22
  }, [stickyNavigation]);
23
- invariant(hasCorrectItemStructure, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${AnchorNavigationItem.displayName}\``);
23
+ !hasCorrectItemStructure ? process.env.NODE_ENV !== "production" ? invariant(false, `\`stickyNavigation\` prop in \`AnchorNavigation\` should be a React Fragment that only contains children of type \`${AnchorNavigationItem.displayName}\``) : invariant(false) : void 0;
24
24
  const [selectedIndex, setSelectedIndex] = useState(0);
25
25
  const sectionRefs = useRef(React.Children.map(stickyNavigation.props.children, child => child.props.target));
26
26
  const anchorRefs = useRef(Array.from({
@@ -97,10 +97,10 @@ const Button = /*#__PURE__*/React.forwardRef(({
97
97
  fullWidth = false,
98
98
  ...rest
99
99
  }, ref) => {
100
- invariant(!!(children || iconType), "Either prop `iconType` must be defined or this node must have children.");
100
+ !!!(children || iconType) ? process.env.NODE_ENV !== "production" ? invariant(false, "Either prop `iconType` must be defined or this node must have children.") : invariant(false) : void 0;
101
101
 
102
102
  if (subtext) {
103
- invariant(size === "large", "subtext prop has no effect unless the button is large.");
103
+ !(size === "large") ? process.env.NODE_ENV !== "production" ? invariant(false, "subtext prop has no effect unless the button is large.") : invariant(false) : void 0;
104
104
  }
105
105
 
106
106
  if (!deprecatedForwardRefWarnTriggered && forwardRef) {
@@ -24,7 +24,7 @@ const ButtonBar = ({
24
24
  });
25
25
  return !incorrectChild;
26
26
  }, [children]);
27
- invariant(hasProperChildren, "ButtonBar accepts only `Button` or `IconButton` elements.");
27
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? invariant(false, "ButtonBar accepts only `Button` or `IconButton` elements.") : invariant(false) : void 0;
28
28
 
29
29
  const getBtnProps = child => {
30
30
  var _child$props, _child$props2, _child$props2$childre, _child$props2$childre2;
@@ -31,10 +31,10 @@ const Decimal = ({
31
31
  const emptyValue = allowEmptyValue ? "" : "0.00";
32
32
  const getSafeValueProp = useCallback(initialValue => {
33
33
  // We're intentionally preventing the use of number values to help prevent any unintentional rounding issues
34
- invariant(typeof initialValue === "string", "Decimal `value` prop must be a string");
34
+ !(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "Decimal `value` prop must be a string") : invariant(false) : void 0;
35
35
 
36
36
  if (initialValue && !allowEmptyValue) {
37
- invariant(initialValue !== "", "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`");
37
+ !(initialValue !== "") ? process.env.NODE_ENV !== "production" ? invariant(false, "Decimal `value` must not be an empty string. Please use `allowEmptyValue` or `0.00`") : invariant(false) : void 0;
38
38
  }
39
39
 
40
40
  return initialValue;
@@ -164,7 +164,7 @@ const Decimal = ({
164
164
  const prevControlledRef = useRef();
165
165
  useEffect(() => {
166
166
  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";
167
- invariant(prevControlledRef.current !== isControlled, message);
167
+ !(prevControlledRef.current !== isControlled) ? process.env.NODE_ENV !== "production" ? invariant(false, message) : invariant(false) : void 0;
168
168
  prevControlledRef.current = isControlled;
169
169
  }, [isControlled]);
170
170
  const prevValue = usePrevious(value);
@@ -69,7 +69,7 @@ const Drawer = ({
69
69
  const previousValue = usePrevious(expanded);
70
70
  useEffect(() => {
71
71
  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";
72
- invariant(isControlled.current === (expanded !== undefined), message);
72
+ !(isControlled.current === (expanded !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, message) : invariant(false) : void 0;
73
73
 
74
74
  if (isControlled.current && previousValue !== expanded) {
75
75
  setIsExpanded(expanded);
@@ -36,7 +36,7 @@ const Icon = /*#__PURE__*/React.forwardRef(({
36
36
  const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ICON_TOOLTIP_POSITIONS.includes(override));
37
37
 
38
38
  if (tooltipFlipOverrides) {
39
- invariant(flipBehaviourCheck, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`);
39
+ !flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? invariant(false, `The tooltipFlipOverrides prop supplied to \`Icon\` must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
40
40
  }
41
41
 
42
42
  const isInteractive = !!tooltipMessage && !disabled;
@@ -25,12 +25,12 @@ const Note = ({
25
25
  onLinkAdded,
26
26
  ...rest
27
27
  }) => {
28
- invariant(width > 0, "<Note> width must be greater than 0");
29
- invariant(createdDate, "<Note> createdDate is required");
30
- invariant(noteContent, "<Note> noteContent is required");
31
- invariant(!status || status.text, "<Note> status.text is required");
32
- invariant(!status || status.timeStamp, "<Note> status.timeStamp is required");
33
- invariant(!inlineControl || inlineControl.type === ActionPopover, "<Note> inlineControl must be an instance of <ActionPopover>");
28
+ !(width > 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> width must be greater than 0") : invariant(false) : void 0;
29
+ !createdDate ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> createdDate is required") : invariant(false) : void 0;
30
+ !noteContent ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> noteContent is required") : invariant(false) : void 0;
31
+ !(!status || status.text) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.text is required") : invariant(false) : void 0;
32
+ !(!status || status.timeStamp) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> status.timeStamp is required") : invariant(false) : void 0;
33
+ !(!inlineControl || inlineControl.type === ActionPopover) ? process.env.NODE_ENV !== "production" ? invariant(false, "<Note> inlineControl must be an instance of <ActionPopover>") : invariant(false) : void 0;
34
34
 
35
35
  const renderStatus = () => {
36
36
  if (!status) {
@@ -78,7 +78,7 @@ const NumeralDate = ({
78
78
  const [internalMessages, setInternalMessages] = useState({});
79
79
  useEffect(() => {
80
80
  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";
81
- invariant(isControlled.current === (value !== undefined), modeSwitchedMessage);
81
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
82
82
  }, [value]);
83
83
  const validationMessages = {
84
84
  dd: l.numeralDate.validation.day(),
@@ -34,7 +34,7 @@ const Search = ({
34
34
  }) => {
35
35
  const isControlled = value !== undefined;
36
36
  const initialValue = isControlled ? value : defaultValue;
37
- invariant(typeof initialValue === "string", "This component has no initial value");
37
+ !(typeof initialValue === "string") ? process.env.NODE_ENV !== "production" ? invariant(false, "This component has no initial value") : invariant(false) : void 0;
38
38
  const [searchValue, setSearchValue] = useState(initialValue);
39
39
  const [isFocused, setIsFocused] = useState(false);
40
40
  const [searchIsActive, setSearchIsActive] = useState(initialValue.length >= threshold);
@@ -168,8 +168,8 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
168
168
  useEffect(() => {
169
169
  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";
170
170
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
171
- invariant(isControlled.current === (value !== undefined), modeSwitchedMessage);
172
- invariant(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
171
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
172
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
173
173
 
174
174
  if (isControlled.current) {
175
175
  setSelectedValue(prevValue => {
@@ -203,7 +203,7 @@ const FilterableSelect = /*#__PURE__*/React.forwardRef(({
203
203
  useEffect(() => {
204
204
  const hasListActionButton = listActionButton !== undefined;
205
205
  const onListActionMissingMessage = "onListAction prop required when using listActionButton prop";
206
- invariant(!hasListActionButton || hasListActionButton && onListAction, onListActionMissingMessage);
206
+ !(!hasListActionButton || hasListActionButton && onListAction) ? process.env.NODE_ENV !== "production" ? invariant(false, onListActionMissingMessage) : invariant(false) : void 0;
207
207
  }, [listActionButton, onListAction]);
208
208
  useEffect(() => {
209
209
  if (isControlled.current) {
@@ -201,8 +201,8 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
201
201
  useEffect(() => {
202
202
  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";
203
203
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
204
- invariant(isControlled.current === (value !== undefined), modeSwitchedMessage);
205
- invariant(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
204
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
205
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
206
206
 
207
207
  if (isControlled.current) {
208
208
  setSelectedValue(value);
@@ -149,8 +149,8 @@ const SimpleSelect = /*#__PURE__*/React.forwardRef(({
149
149
  useEffect(() => {
150
150
  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";
151
151
  const onChangeMissingMessage = "onChange prop required when using a controlled input element";
152
- invariant(isControlled.current === (value !== undefined), modeSwitchedMessage);
153
- invariant(!isControlled.current || isControlled.current && onChange, onChangeMissingMessage);
152
+ !(isControlled.current === (value !== undefined)) ? process.env.NODE_ENV !== "production" ? invariant(false, modeSwitchedMessage) : invariant(false) : void 0;
153
+ !(!isControlled.current || isControlled.current && onChange) ? process.env.NODE_ENV !== "production" ? invariant(false, onChangeMissingMessage) : invariant(false) : void 0;
154
154
 
155
155
  if (isControlled.current) {
156
156
  setSelectedValue(value);
@@ -29,7 +29,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
29
29
  ...rest
30
30
  }, ref) => {
31
31
  const isFlipOverridesValid = !flipOverrides || Array.isArray(flipOverrides) && flipOverrides.every(placement => TOOLTIP_POSITIONS.includes(placement));
32
- invariant(isFlipOverridesValid, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`);
32
+ !isFlipOverridesValid ? process.env.NODE_ENV !== "production" ? invariant(false, `The flipOverrides prop supplied to Tooltip must be an array containing some or all of ["top", "bottom", "left", "right"].`) : invariant(false) : void 0;
33
33
 
34
34
  const tooltip = (attrs, content) => {
35
35
  const currentPosition = attrs["data-placement"] || position;
@@ -1,55 +1,57 @@
1
- import { useRef, useCallback, useMemo } from "react";
1
+ import { useRef, useCallback } from "react";
2
2
  import guid from "../../../__internal__/utils/helpers/guid";
3
3
  import ScrollBlockManager from "./scroll-block-manager"; // TODO: This component can be refactored to remove redundant code after
4
4
  // we can confirm that all Sage products use version 105.0.0^
5
5
 
6
6
  const scrollBlockManager = new ScrollBlockManager();
7
7
 
8
+ const getRules = () => {
9
+ /* istanbul ignore next */
10
+ const {
11
+ documentElement,
12
+ body
13
+ } = document || {};
14
+ const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
15
+ const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
16
+ return [// TODO: First two entries of this array with the documentElement can be removed
17
+ {
18
+ element: documentElement,
19
+ property: "position",
20
+ blockingValue: "relative"
21
+ }, {
22
+ element: documentElement,
23
+ property: "overflow",
24
+ blockingValue: "hidden"
25
+ }, {
26
+ element: body,
27
+ property: "position",
28
+ blockingValue: "relative"
29
+ }, {
30
+ element: body,
31
+ property: "overflow",
32
+ blockingValue: "hidden"
33
+ }, {
34
+ element: body,
35
+ property: "paddingRight",
36
+ blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
37
+ }];
38
+ };
39
+
8
40
  const useScrollBlock = () => {
9
41
  const {
10
42
  current: containerGuid
11
43
  } = useRef(guid());
12
44
  const originalValuesRef = useRef([]);
13
- const rules = useMemo(() => {
14
- /* istanbul ignore next */
15
- const {
16
- documentElement,
17
- body
18
- } = document || {};
19
- const scrollBarWidth = window.innerWidth - documentElement.clientWidth;
20
- const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
21
- return [// TODO: First two entries of this array with the documentElement can be removed
22
- {
23
- element: documentElement,
24
- property: "position",
25
- blockingValue: "relative"
26
- }, {
27
- element: documentElement,
28
- property: "overflow",
29
- blockingValue: "hidden"
30
- }, {
31
- element: body,
32
- property: "position",
33
- blockingValue: "relative"
34
- }, {
35
- element: body,
36
- property: "overflow",
37
- blockingValue: "hidden"
38
- }, {
39
- element: body,
40
- property: "paddingRight",
41
- blockingValue: `${bodyPaddingRight + scrollBarWidth}px`
42
- }];
43
- }, []);
44
45
  const restoreValues = useCallback(() => {
45
- rules.forEach(({
46
+ getRules().forEach(({
46
47
  element,
47
48
  property
48
49
  }, index) => {
49
50
  element.style[property] = originalValuesRef.current[index];
50
51
  });
51
- }, [rules]);
52
+ }, []);
52
53
  const blockScroll = useCallback(() => {
54
+ const rules = getRules();
53
55
  const isBlocked = scrollBlockManager.isBlocked();
54
56
  scrollBlockManager.registerComponent(containerGuid);
55
57
 
@@ -73,7 +75,7 @@ const useScrollBlock = () => {
73
75
  }) => {
74
76
  element.style[property] = blockingValue;
75
77
  });
76
- }, [restoreValues, containerGuid, rules]);
78
+ }, [restoreValues, containerGuid]);
77
79
  const allowScroll = useCallback(() => {
78
80
  scrollBlockManager.unregisterComponent(containerGuid);
79
81
  const isBlocked = scrollBlockManager.isBlocked();
@@ -88,14 +90,14 @@ const useScrollBlock = () => {
88
90
 
89
91
 
90
92
  const originalValues = scrollBlockManager.getOriginalValues();
91
- rules.forEach(({
93
+ getRules().forEach(({
92
94
  element,
93
95
  property
94
96
  }, index) => {
95
97
  element.style[property] = originalValues[index];
96
98
  });
97
99
  scrollBlockManager.saveOriginalValues([]);
98
- }, [containerGuid, rules]);
100
+ }, [containerGuid]);
99
101
  return {
100
102
  blockScroll,
101
103
  allowScroll
@@ -57,7 +57,7 @@ const ValidationIcon = ({
57
57
  const flipBehaviourCheck = Array.isArray(tooltipFlipOverrides) && tooltipFlipOverrides.every(override => ["bottom", "left", "right", "top"].includes(override));
58
58
 
59
59
  if (tooltipFlipOverrides) {
60
- (0, _invariant.default)(flipBehaviourCheck, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`);
60
+ !flipBehaviourCheck ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `The tooltipFlipOverrides prop supplied to ValidationIcon must be an array containing some or all of ["top", "bottom", "left", "right"].`) : (0, _invariant.default)(false) : void 0;
61
61
  }
62
62
 
63
63
  const {
@@ -38,7 +38,7 @@ const AccordionGroup = ({
38
38
 
39
39
  return hasAccordionChildren;
40
40
  }, [children]);
41
- (0, _invariant.default)(hasProperChildren, `AccordionGroup accepts only children of type \`${_accordion.default.displayName}\`.`);
41
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `AccordionGroup accepts only children of type \`${_accordion.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
42
42
  const filteredChildren = (0, _react.useMemo)(() => _react.default.Children.toArray(children).filter(child => {
43
43
  return /*#__PURE__*/_react.default.isValidElement(child);
44
44
  }), [children]);
@@ -82,8 +82,8 @@ const ActionPopoverItem = ({
82
82
  }) => {
83
83
  const l = (0, _useLocale.default)();
84
84
  const context = (0, _react.useContext)(_actionPopoverContext.default);
85
- (0, _invariant.default)(context, "ActionPopoverItem must be used within an ActionPopover component");
86
- (0, _invariant.default)( /*#__PURE__*/_react.default.isValidElement(submenu) ? submenu.type === _actionPopoverMenu.default : true, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`");
85
+ !context ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverItem must be used within an ActionPopover component") : (0, _invariant.default)(false) : void 0;
86
+ !( /*#__PURE__*/_react.default.isValidElement(submenu) ? submenu.type === _actionPopoverMenu.default : true) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverItem only accepts submenu of type `ActionPopoverMenu`") : (0, _invariant.default)(false) : void 0;
87
87
  const {
88
88
  setOpenPopover,
89
89
  isOpenPopover,
@@ -42,11 +42,11 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
42
42
  ...rest
43
43
  }, ref) => {
44
44
  const context = (0, _react.useContext)(_actionPopoverContext.default);
45
- (0, _invariant.default)(context, "ActionPopoverMenu must be used within an ActionPopover component");
45
+ !context ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverMenu must be used within an ActionPopover component") : (0, _invariant.default)(false) : void 0;
46
46
  const {
47
47
  focusButton
48
48
  } = context;
49
- (0, _invariant.default)(setOpen && setFocusIndex && typeof focusIndex !== "undefined", "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component");
49
+ !(setOpen && setFocusIndex && typeof focusIndex !== "undefined") ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, "ActionPopoverMenu must be used within an ActionPopover or ActionPopoverItem component") : (0, _invariant.default)(false) : void 0;
50
50
  const hasProperChildren = (0, _react.useMemo)(() => {
51
51
  const incorrectChild = _react.default.Children.toArray(children).find(child => {
52
52
  if (! /*#__PURE__*/_react.default.isValidElement(child)) {
@@ -58,7 +58,7 @@ const ActionPopoverMenu = /*#__PURE__*/_react.default.forwardRef(({
58
58
 
59
59
  return !incorrectChild;
60
60
  }, [children]);
61
- (0, _invariant.default)(hasProperChildren, `ActionPopoverMenu only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`);
61
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `ActionPopoverMenu only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
62
62
  const items = (0, _react.useMemo)(() => {
63
63
  return _react.default.Children.toArray(children).filter(child => {
64
64
  return /*#__PURE__*/_react.default.isValidElement(child) && child.type === _actionPopoverItem.default;
@@ -74,7 +74,7 @@ const ActionPopover = ({
74
74
 
75
75
  return !incorrectChild;
76
76
  }, [children]);
77
- (0, _invariant.default)(hasProperChildren, `ActionPopover only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`);
77
+ !hasProperChildren ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, `ActionPopover only accepts children of type \`${_actionPopoverItem.default.displayName}\`` + ` and \`${_actionPopoverDivider.default.displayName}\`.`) : (0, _invariant.default)(false) : void 0;
78
78
  const mappedPlacement = (0, _react.useMemo)(() => {
79
79
  if (placement === "top" && !rightAlignMenu) {
80
80
  return "top-end";
@@ -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({
@@ -118,10 +118,10 @@ const Button = /*#__PURE__*/_react.default.forwardRef(({
118
118
  fullWidth = false,
119
119
  ...rest
120
120
  }, ref) => {
121
- (0, _invariant.default)(!!(children || iconType), "Either prop `iconType` must be defined or this node must have children.");
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;
122
122
 
123
123
  if (subtext) {
124
- (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
125
  }
126
126
 
127
127
  if (!deprecatedForwardRefWarnTriggered && forwardRef) {
@@ -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);
@@ -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;
@@ -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);
@@ -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.3",
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",
@@ -150,6 +151,7 @@
150
151
  "jest-styled-components": "^6.3.1",
151
152
  "lint-staged": "^10.5.3",
152
153
  "mockdate": "^2.0.2",
154
+ "nock": "^13.2.8",
153
155
  "prettier": "^2.1.2",
154
156
  "raf": "^3.4.0",
155
157
  "react": "^17.0.2",
@@ -175,6 +177,7 @@
175
177
  "@styled-system/prop-types": "^5.1.5",
176
178
  "@tippyjs/react": "^4.2.5",
177
179
  "@types/styled-system": "^5.1.11",
180
+ "ci-info": "^3.3.2",
178
181
  "classnames": "~2.2.6",
179
182
  "crypto-js": "~3.3.0",
180
183
  "date-fns": "^2.26.0",
@@ -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;
@@ -2,6 +2,7 @@
2
2
  const { Octokit } = require("@octokit/rest");
3
3
  const dotenv = require("dotenv");
4
4
  const chalk = require("chalk");
5
+ const ci = require("ci-info");
5
6
 
6
7
  dotenv.config();
7
8
  const octokit = new Octokit({
@@ -33,6 +34,10 @@ const getOpenRfcs = async () => {
33
34
  const getRfcTitle = (rfc) => rfc.title.split(": ")[1];
34
35
 
35
36
  const checkRfcs = async () => {
37
+ if (ci.BITRISE) {
38
+ return;
39
+ }
40
+
36
41
  const openRfcs = await getOpenRfcs();
37
42
 
38
43
  if (openRfcs.length > 0) {
@@ -46,4 +51,6 @@ const checkRfcs = async () => {
46
51
  }
47
52
  };
48
53
 
49
- if (!process.env.CARBON_INSTALL) checkRfcs();
54
+ checkRfcs();
55
+
56
+ module.exports = checkRfcs;