carbon-react 141.0.7 → 141.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import React, { useCallback, useEffect, useRef, useState, useMemo } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import { Transition } from "react-transition-group";
5
5
  import { flip, offset } from "@floating-ui/dom";
@@ -56,14 +56,14 @@ export const renderClose = ({
56
56
  })), /*#__PURE__*/React.createElement(Icon, {
57
57
  type: "close"
58
58
  }));
59
- function getPopoverMiddleware(shouldCoverButton) {
60
- return [offset(shouldCoverButton ? ({
59
+ function usePopoverMiddleware(shouldCoverButton) {
60
+ return useMemo(() => [offset(shouldCoverButton ? ({
61
61
  rects
62
62
  }) => ({
63
63
  mainAxis: -rects.reference.height
64
64
  }) : 6), flip({
65
65
  fallbackStrategy: "initialPlacement"
66
- })];
66
+ })], [shouldCoverButton]);
67
67
  }
68
68
  export const PopoverContainer = ({
69
69
  children,
@@ -93,6 +93,7 @@ export const PopoverContainer = ({
93
93
  const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
94
94
  const isOpen = isControlled ? open : isOpenInternal;
95
95
  const reduceMotion = !useMediaQuery("screen and (prefers-reduced-motion: no-preference)");
96
+ const popoverMiddleware = usePopoverMiddleware(shouldCoverButton);
96
97
  const closePopover = useCallback(ev => {
97
98
  if (!isControlled) {
98
99
  setIsOpenInternal(false);
@@ -198,7 +199,7 @@ export const PopoverContainer = ({
198
199
  reference: popoverReference,
199
200
  placement: position === "right" ? "bottom-start" : "bottom-end",
200
201
  popoverStrategy: disableAnimation || reduceMotion ? "fixed" : "absolute",
201
- middleware: getPopoverMiddleware(shouldCoverButton),
202
+ middleware: popoverMiddleware,
202
203
  childRefOverride: popoverContentNodeRef
203
204
  }, childrenToRender(state))));
204
205
  };
@@ -67,14 +67,14 @@ const renderClose = ({
67
67
  type: "close"
68
68
  }));
69
69
  exports.renderClose = renderClose;
70
- function getPopoverMiddleware(shouldCoverButton) {
71
- return [(0, _dom.offset)(shouldCoverButton ? ({
70
+ function usePopoverMiddleware(shouldCoverButton) {
71
+ return (0, _react.useMemo)(() => [(0, _dom.offset)(shouldCoverButton ? ({
72
72
  rects
73
73
  }) => ({
74
74
  mainAxis: -rects.reference.height
75
75
  }) : 6), (0, _dom.flip)({
76
76
  fallbackStrategy: "initialPlacement"
77
- })];
77
+ })], [shouldCoverButton]);
78
78
  }
79
79
  const PopoverContainer = ({
80
80
  children,
@@ -104,6 +104,7 @@ const PopoverContainer = ({
104
104
  const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
105
105
  const isOpen = isControlled ? open : isOpenInternal;
106
106
  const reduceMotion = !(0, _useMediaQuery.default)("screen and (prefers-reduced-motion: no-preference)");
107
+ const popoverMiddleware = usePopoverMiddleware(shouldCoverButton);
107
108
  const closePopover = (0, _react.useCallback)(ev => {
108
109
  if (!isControlled) {
109
110
  setIsOpenInternal(false);
@@ -209,7 +210,7 @@ const PopoverContainer = ({
209
210
  reference: popoverReference,
210
211
  placement: position === "right" ? "bottom-start" : "bottom-end",
211
212
  popoverStrategy: disableAnimation || reduceMotion ? "fixed" : "absolute",
212
- middleware: getPopoverMiddleware(shouldCoverButton),
213
+ middleware: popoverMiddleware,
213
214
  childRefOverride: popoverContentNodeRef
214
215
  }, childrenToRender(state))));
215
216
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "141.0.7",
3
+ "version": "141.0.8",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",