carbon-addons-iot-react 2.148.0-next.2 → 2.148.0-next.3

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.
@@ -3,6 +3,13 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import 'core-js/modules/es.array.map.js';
5
5
  import 'core-js/modules/es.object.assign.js';
6
+ import 'core-js/modules/es.array.concat.js';
7
+ import 'core-js/modules/es.object.keys.js';
8
+ import 'core-js/modules/es.symbol.js';
9
+ import 'core-js/modules/es.array.filter.js';
10
+ import 'core-js/modules/es.object.get-own-property-descriptor.js';
11
+ import 'core-js/modules/web.dom-collections.for-each.js';
12
+ import 'core-js/modules/es.object.get-own-property-descriptors.js';
6
13
  import React__default, { useState, useRef, useCallback, useEffect, useLayoutEffect, useMemo } from 'react';
7
14
  import PropTypes from 'prop-types';
8
15
  import { unstable_Menu } from 'carbon-components-react';
@@ -13,9 +20,13 @@ import { settings } from '../../constants/Settings.js';
13
20
  import deprecate from '../../internal/deprecate.js';
14
21
  import { SplitMenuButton } from './SplitMenuButton.js';
15
22
  import { SingleMenuButton } from './SingleMenuButton.js';
16
- import { getMenuPosition } from './utils.js';
23
+ import { getMenuPosition, getShadowBlockerConfig } from './utils.js';
17
24
 
25
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
26
+
27
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
28
  var iotPrefix = settings.iotPrefix;
29
+ var GHOST = 'ghost';
19
30
  var propTypes = {
20
31
  // eslint-disable-next-line react/require-default-props
21
32
  testID: deprecate(PropTypes.string, "The 'testID' prop has been deprecated. Please use 'testId' instead."),
@@ -67,7 +78,17 @@ var propTypes = {
67
78
 
68
79
  return undefined;
69
80
  },
70
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired
81
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
82
+
83
+ /**
84
+ * The size of the button and the dropdown items
85
+ */
86
+ size: PropTypes.oneOf(['sm', 'md', 'default']),
87
+
88
+ /**
89
+ * The kind of button.
90
+ */
91
+ kind: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'ghost'])
71
92
  };
72
93
  var defaultProps = {
73
94
  testId: 'menu-button',
@@ -76,10 +97,14 @@ var defaultProps = {
76
97
  openIconDescription: 'open menu button',
77
98
  closeIconDescription: 'close menu button',
78
99
  renderOpenIcon: ChevronDown16,
79
- renderCloseIcon: ChevronUp16
100
+ renderCloseIcon: ChevronUp16,
101
+ size: 'default',
102
+ kind: 'primary'
80
103
  };
81
104
 
82
105
  var MenuButton = function MenuButton(_ref) {
106
+ var _shadowBlockerButtonC, _classnames;
107
+
83
108
  var testID = _ref.testID,
84
109
  testId = _ref.testId,
85
110
  onPrimaryActionClick = _ref.onPrimaryActionClick,
@@ -88,7 +113,9 @@ var MenuButton = function MenuButton(_ref) {
88
113
  closeIconDescription = _ref.closeIconDescription,
89
114
  renderOpenIcon = _ref.renderOpenIcon,
90
115
  renderCloseIcon = _ref.renderCloseIcon,
91
- children = _ref.children;
116
+ children = _ref.children,
117
+ buttonSize = _ref.size,
118
+ kind = _ref.kind;
92
119
 
93
120
  var _useState = useState(false),
94
121
  _useState2 = _slicedToArray(_useState, 2),
@@ -103,6 +130,11 @@ var MenuButton = function MenuButton(_ref) {
103
130
  position = _useState4[0],
104
131
  setPosition = _useState4[1];
105
132
 
133
+ var _useState5 = useState({}),
134
+ _useState6 = _slicedToArray(_useState5, 2),
135
+ shadowBlockerConf = _useState6[0],
136
+ setShadowBlockerConf = _useState6[1];
137
+
106
138
  var buttonRef = useRef(null);
107
139
  var langDir = useLangDirection();
108
140
  var handleResize = useCallback(function () {
@@ -121,9 +153,10 @@ var MenuButton = function MenuButton(_ref) {
121
153
  x: x,
122
154
  y: y
123
155
  });
156
+ setShadowBlockerConf(getShadowBlockerConfig(buttonRef));
124
157
  } // eslint-disable-next-line react-hooks/exhaustive-deps
125
158
 
126
- }, [label, langDir, onPrimaryActionClick, isMenuOpen]);
159
+ }, [label, langDir, onPrimaryActionClick, isMenuOpen, buttonSize]);
127
160
  /**
128
161
  * This is a hacky work-around, because the current Menu (7.42.1) won't allow us
129
162
  * to set classNames or a target for where the menu should be placed via the portal
@@ -196,11 +229,31 @@ var MenuButton = function MenuButton(_ref) {
196
229
  }));
197
230
  });
198
231
  }, [children, handleChildClick]);
232
+ var menuSize = buttonSize === 'default' ? 'lg' : buttonSize;
233
+ var buttonKind = !label ? GHOST : kind;
234
+ /**
235
+ * This shadow-blocker is needed to remove the menu shadow covering the button.
236
+ * We can't use a pure CSS solution (like ::after) for this since the shadow-blocker styling
237
+ * needs to get the position and dimensions of the menu and it is not possible to
238
+ * pass that info as css attributes (vars) to the menu since the component internally use
239
+ * the style attribute to set the x & y attributes.
240
+ */
241
+
242
+ var menuHeight = shadowBlockerConf.menuHeight,
243
+ flippedX = shadowBlockerConf.flippedX,
244
+ flippedY = shadowBlockerConf.flippedY,
245
+ opensHorizontally = shadowBlockerConf.opensHorizontally;
246
+ var shadowBlockerButtonClasses = (_shadowBlockerButtonC = {}, _defineProperty(_shadowBlockerButtonC, "".concat(iotPrefix, "--menu-button--flip-y"), flippedY), _defineProperty(_shadowBlockerButtonC, "".concat(iotPrefix, "--menu-button--flip-x"), flippedX), _defineProperty(_shadowBlockerButtonC, "".concat(iotPrefix, "--menu-button--opens-horizontally"), opensHorizontally), _shadowBlockerButtonC);
247
+ var showShadowBlocker = buttonKind === GHOST && isMenuOpen && !label;
248
+ var shadowBlocker = showShadowBlocker ? /*#__PURE__*/React__default.createElement("div", {
249
+ style: _defineProperty({}, "--menu-height", "".concat(menuHeight, "px")),
250
+ className: classnames((_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--menu__shadow-blocker--flip-y"), flippedY), _defineProperty(_classnames, "".concat(iotPrefix, "--menu__shadow-blocker--flip-x"), flippedX), _defineProperty(_classnames, "".concat(iotPrefix, "--menu__shadow-blocker--opens-horizontally"), opensHorizontally), _classnames), "".concat(iotPrefix, "--menu__shadow-blocker"), "".concat(iotPrefix, "--menu__shadow-blocker--").concat(menuSize))
251
+ }) : null;
199
252
  var ButtonComponent = typeof onPrimaryActionClick === 'function' && label ? SplitMenuButton : SingleMenuButton;
200
253
  return /*#__PURE__*/React__default.createElement("div", {
201
254
  // TODO: remove deprecated 'testID' in v3.
202
255
  "data-testid": "".concat(testID || testId, "-wrapper"),
203
- className: classnames("".concat(iotPrefix, "--menu-button"), _defineProperty({}, "".concat(iotPrefix, "--menu-button--open"), isMenuOpen))
256
+ className: classnames("".concat(iotPrefix, "--menu-button"), _objectSpread(_defineProperty({}, "".concat(iotPrefix, "--menu-button--open"), isMenuOpen), shadowBlockerButtonClasses))
204
257
  }, /*#__PURE__*/React__default.createElement(ButtonComponent, {
205
258
  ref: buttonRef,
206
259
  onPrimaryActionClick: handlePrimaryClick,
@@ -209,10 +262,14 @@ var MenuButton = function MenuButton(_ref) {
209
262
  renderIcon: isMenuOpen ? renderCloseIcon : renderOpenIcon,
210
263
  label: label // TODO: remove deprecated 'testID' in v3.
211
264
  ,
212
- testId: testID || testId
265
+ testId: testID || testId,
266
+ size: buttonSize,
267
+ kind: buttonKind
213
268
  }), /*#__PURE__*/React__default.createElement(unstable_Menu, _extends({
269
+ className: classnames(_defineProperty({}, "".concat(iotPrefix, "--menu-button--icon-only"), buttonKind === GHOST), "".concat(iotPrefix, "--menu-button__menu")),
270
+ size: menuSize,
214
271
  open: isMenuOpen
215
- }, position), contextMenuItems));
272
+ }, position), contextMenuItems, shadowBlocker));
216
273
  };
217
274
 
218
275
  MenuButton.propTypes = propTypes;
@@ -311,6 +368,51 @@ MenuButton.__docgenInfo = {
311
368
  "required": false,
312
369
  "description": "Optional prop to change the closed state icon on the button\nCan be a React component class"
313
370
  },
371
+ "size": {
372
+ "defaultValue": {
373
+ "value": "'default'",
374
+ "computed": false
375
+ },
376
+ "type": {
377
+ "name": "enum",
378
+ "value": [{
379
+ "value": "'sm'",
380
+ "computed": false
381
+ }, {
382
+ "value": "'md'",
383
+ "computed": false
384
+ }, {
385
+ "value": "'default'",
386
+ "computed": false
387
+ }]
388
+ },
389
+ "required": false,
390
+ "description": "The size of the button and the dropdown items"
391
+ },
392
+ "kind": {
393
+ "defaultValue": {
394
+ "value": "'primary'",
395
+ "computed": false
396
+ },
397
+ "type": {
398
+ "name": "enum",
399
+ "value": [{
400
+ "value": "'primary'",
401
+ "computed": false
402
+ }, {
403
+ "value": "'secondary'",
404
+ "computed": false
405
+ }, {
406
+ "value": "'tertiary'",
407
+ "computed": false
408
+ }, {
409
+ "value": "'ghost'",
410
+ "computed": false
411
+ }]
412
+ },
413
+ "required": false,
414
+ "description": "The kind of button."
415
+ },
314
416
  "testID": {
315
417
  "type": {
316
418
  "name": "custom",
@@ -27,7 +27,17 @@ var propTypes = {
27
27
  * be read by screen readers
28
28
  */
29
29
  iconDescription: PropTypes.string.isRequired,
30
- testId: PropTypes.string.isRequired
30
+ testId: PropTypes.string.isRequired,
31
+
32
+ /**
33
+ * The size of the button and the dropdown items
34
+ */
35
+ size: PropTypes.oneOf(['sm', 'md', 'default']).isRequired,
36
+
37
+ /**
38
+ * The kind of button to render
39
+ */
40
+ kind: PropTypes.oneOf(['primary', 'secondary', 'tertiary', 'ghost']).isRequired
31
41
  };
32
42
  var defaultProps = {
33
43
  label: '',
@@ -40,7 +50,9 @@ var SingleMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, re
40
50
  label = _ref.label,
41
51
  iconDescription = _ref.iconDescription,
42
52
  renderIcon = _ref.renderIcon,
43
- testId = _ref.testId;
53
+ testId = _ref.testId,
54
+ size = _ref.size,
55
+ kind = _ref.kind;
44
56
  return /*#__PURE__*/React__default.createElement(Button, {
45
57
  ref: ref,
46
58
  className: "".concat(iotPrefix, "--menu-button__trigger"),
@@ -48,8 +60,9 @@ var SingleMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, re
48
60
  iconDescription: iconDescription,
49
61
  renderIcon: renderIcon,
50
62
  hasIconOnly: !label,
51
- kind: !label ? 'ghost' : 'primary',
52
- testId: label ? "".concat(testId, "-single") : "".concat(testId, "-icon")
63
+ kind: kind,
64
+ testId: label ? "".concat(testId, "-single") : "".concat(testId, "-icon"),
65
+ size: size
53
66
  }, label);
54
67
  });
55
68
  SingleMenuButton.propTypes = propTypes;
@@ -116,6 +129,43 @@ SingleMenuButton.__docgenInfo = {
116
129
  },
117
130
  "required": true,
118
131
  "description": ""
132
+ },
133
+ "size": {
134
+ "type": {
135
+ "name": "enum",
136
+ "value": [{
137
+ "value": "'sm'",
138
+ "computed": false
139
+ }, {
140
+ "value": "'md'",
141
+ "computed": false
142
+ }, {
143
+ "value": "'default'",
144
+ "computed": false
145
+ }]
146
+ },
147
+ "required": true,
148
+ "description": "The size of the button and the dropdown items"
149
+ },
150
+ "kind": {
151
+ "type": {
152
+ "name": "enum",
153
+ "value": [{
154
+ "value": "'primary'",
155
+ "computed": false
156
+ }, {
157
+ "value": "'secondary'",
158
+ "computed": false
159
+ }, {
160
+ "value": "'tertiary'",
161
+ "computed": false
162
+ }, {
163
+ "value": "'ghost'",
164
+ "computed": false
165
+ }]
166
+ },
167
+ "required": true,
168
+ "description": "The kind of button to render"
119
169
  }
120
170
  }
121
171
  };
@@ -34,7 +34,17 @@ var propTypes = {
34
34
  * If specifying the `renderIcon` prop, provide a description for that icon that can
35
35
  * be read by screen readers
36
36
  */
37
- iconDescription: PropTypes.string.isRequired
37
+ iconDescription: PropTypes.string.isRequired,
38
+
39
+ /**
40
+ * The size of the button and the dropdown items
41
+ */
42
+ size: PropTypes.oneOf(['sm', 'md', 'default']).isRequired,
43
+
44
+ /**
45
+ * The kind of button to render
46
+ */
47
+ kind: PropTypes.oneOf(['primary', 'secondary', 'tertiary']).isRequired
38
48
  };
39
49
  var SplitMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
40
50
  var label = _ref.label,
@@ -42,11 +52,15 @@ var SplitMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
42
52
  renderIcon = _ref.renderIcon,
43
53
  onPrimaryActionClick = _ref.onPrimaryActionClick,
44
54
  onSecondaryActionClick = _ref.onSecondaryActionClick,
45
- testId = _ref.testId;
55
+ size = _ref.size,
56
+ testId = _ref.testId,
57
+ kind = _ref.kind;
46
58
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
47
59
  className: classnames("".concat(iotPrefix, "--menu-button__primary")),
48
60
  onClick: onPrimaryActionClick,
49
- testId: "".concat(testId, "-primary")
61
+ testId: "".concat(testId, "-primary"),
62
+ size: size,
63
+ kind: kind
50
64
  }, label), /*#__PURE__*/React__default.createElement(Button, {
51
65
  ref: ref,
52
66
  className: classnames("".concat(iotPrefix, "--menu-button__secondary"), "".concat(iotPrefix, "--menu-button__trigger")),
@@ -54,7 +68,9 @@ var SplitMenuButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
54
68
  iconDescription: iconDescription,
55
69
  renderIcon: renderIcon,
56
70
  onClick: onSecondaryActionClick,
57
- testId: "".concat(testId, "-secondary")
71
+ testId: "".concat(testId, "-secondary"),
72
+ size: size,
73
+ kind: kind
58
74
  }));
59
75
  });
60
76
  SplitMenuButton.propTypes = propTypes;
@@ -108,6 +124,40 @@ SplitMenuButton.__docgenInfo = {
108
124
  },
109
125
  "required": true,
110
126
  "description": "If specifying the `renderIcon` prop, provide a description for that icon that can\nbe read by screen readers"
127
+ },
128
+ "size": {
129
+ "type": {
130
+ "name": "enum",
131
+ "value": [{
132
+ "value": "'sm'",
133
+ "computed": false
134
+ }, {
135
+ "value": "'md'",
136
+ "computed": false
137
+ }, {
138
+ "value": "'default'",
139
+ "computed": false
140
+ }]
141
+ },
142
+ "required": true,
143
+ "description": "The size of the button and the dropdown items"
144
+ },
145
+ "kind": {
146
+ "type": {
147
+ "name": "enum",
148
+ "value": [{
149
+ "value": "'primary'",
150
+ "computed": false
151
+ }, {
152
+ "value": "'secondary'",
153
+ "computed": false
154
+ }, {
155
+ "value": "'tertiary'",
156
+ "computed": false
157
+ }]
158
+ },
159
+ "required": true,
160
+ "description": "The kind of button to render"
111
161
  }
112
162
  }
113
163
  };
@@ -1,24 +1,88 @@
1
1
  import 'core-js/modules/es.array.concat.js';
2
2
  import 'core-js/modules/es.array.join.js';
3
3
  import 'core-js/modules/es.array.filter.js';
4
+ import 'core-js/modules/es.array.includes.js';
5
+ import 'core-js/modules/es.string.includes.js';
4
6
  import { settings } from '../../constants/Settings.js';
5
7
 
6
8
  var prefix = settings.prefix;
7
- var getMenuPosition = function getMenuPosition(_ref) {
8
- var _buttonRef$current, _buttonRef$current$pr, _buttonRef$current$ne, _buttonRef$current2, _menuRect$height, _menuRect$width;
9
9
 
10
+ var getBoundingClientRects = function getBoundingClientRects(buttonRef, isSplitButton) {
11
+ var _buttonRef$current, _buttonRef$current$pr, _buttonRef$current$ne, _buttonRef$current2;
12
+
13
+ var buttonRect = buttonRef.current.getBoundingClientRect();
14
+ var primaryButtonRect = isSplitButton ? buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : (_buttonRef$current$pr = _buttonRef$current.previousSibling) === null || _buttonRef$current$pr === void 0 ? void 0 : _buttonRef$current$pr.getBoundingClientRect() : null; // Once the menuButton can accept a target for the react portal, we can
15
+ // use this method again once the menu is placed within the same div as the
16
+ // button.
17
+ // const menuRect = buttonRef.current.nextSibling?.getBoundingClientRect();
18
+
19
+ var node = (_buttonRef$current$ne = (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.nextSibling) !== null && _buttonRef$current$ne !== void 0 ? _buttonRef$current$ne : document.querySelector(".".concat(prefix, "--menu.").concat(prefix, "--menu--open.").concat(prefix, "--menu--root"));
20
+ var menuRect = node === null || node === void 0 ? void 0 : node.getBoundingClientRect();
21
+ return {
22
+ buttonRect: buttonRect,
23
+ primaryButtonRect: primaryButtonRect,
24
+ menuRect: menuRect
25
+ };
26
+ };
27
+
28
+ var getMenuDimensions = function getMenuDimensions(menuRect) {
29
+ var _menuRect$height, _menuRect$width;
30
+
31
+ return {
32
+ menuHeight: (_menuRect$height = menuRect === null || menuRect === void 0 ? void 0 : menuRect.height) !== null && _menuRect$height !== void 0 ? _menuRect$height : 0,
33
+ menuWidth: (_menuRect$width = menuRect === null || menuRect === void 0 ? void 0 : menuRect.width) !== null && _menuRect$width !== void 0 ? _menuRect$width : 0
34
+ };
35
+ };
36
+
37
+ var getOverflow = function getOverflow(menuRect, buttonRect) {
38
+ var windowWidth = window.innerWidth || document.documentElement.clientWidth;
39
+ var windowHeight = window.innerHeight || document.documentElement.clientHeight;
40
+
41
+ var _getMenuDimensions = getMenuDimensions(menuRect),
42
+ menuHeight = _getMenuDimensions.menuHeight,
43
+ menuWidth = _getMenuDimensions.menuWidth;
44
+
45
+ var offTop = buttonRect.top - menuHeight < 0;
46
+ var offLeft = buttonRect.left - menuWidth < 0;
47
+ var offRight = buttonRect.right + menuWidth > windowWidth;
48
+ var offBottom = buttonRect.bottom + menuHeight > windowHeight;
49
+ var T = offTop ? 'top' : '';
50
+ var R = offRight ? 'right' : '';
51
+ var B = offBottom ? 'bottom' : '';
52
+ var L = offLeft ? 'left' : '';
53
+ return [T, R, B, L].filter(Boolean).join('-');
54
+ };
55
+
56
+ var getShadowBlockerConfig = function getShadowBlockerConfig(buttonRef) {
57
+ var _getBoundingClientRec = getBoundingClientRects(buttonRef),
58
+ buttonRect = _getBoundingClientRec.buttonRect,
59
+ menuRect = _getBoundingClientRec.menuRect;
60
+
61
+ var _getMenuDimensions2 = getMenuDimensions(menuRect),
62
+ menuHeight = _getMenuDimensions2.menuHeight;
63
+
64
+ var overflow = getOverflow(menuRect, buttonRect);
65
+ var flippedX = (overflow === null || overflow === void 0 ? void 0 : overflow.includes('bottom')) && !(overflow !== null && overflow !== void 0 && overflow.includes('top'));
66
+ var flippedY = overflow === null || overflow === void 0 ? void 0 : overflow.includes('right');
67
+ var opensHorizontally = (overflow === null || overflow === void 0 ? void 0 : overflow.includes('top')) && (overflow === null || overflow === void 0 ? void 0 : overflow.includes('bottom'));
68
+ return {
69
+ menuHeight: menuHeight,
70
+ flippedX: flippedX,
71
+ flippedY: flippedY,
72
+ opensHorizontally: opensHorizontally
73
+ };
74
+ };
75
+ var getMenuPosition = function getMenuPosition(_ref) {
10
76
  var label = _ref.label,
11
77
  buttonRef = _ref.buttonRef,
12
78
  onPrimaryActionClick = _ref.onPrimaryActionClick,
13
79
  langDir = _ref.langDir;
14
80
  var isSplitButton = label && typeof onPrimaryActionClick === 'function';
15
- var buttonRect = buttonRef.current.getBoundingClientRect();
16
- var primaryButtonRect = isSplitButton ? buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : (_buttonRef$current$pr = _buttonRef$current.previousSibling) === null || _buttonRef$current$pr === void 0 ? void 0 : _buttonRef$current$pr.getBoundingClientRect() : null;
17
- var node = (_buttonRef$current$ne = (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.nextSibling) !== null && _buttonRef$current$ne !== void 0 ? _buttonRef$current$ne : document.querySelector(".".concat(prefix, "--menu.").concat(prefix, "--menu--open.").concat(prefix, "--menu--root"));
18
- var menuRect = node === null || node === void 0 ? void 0 : node.getBoundingClientRect(); // Once the menuButton can accept a target for the react portal, we can
19
- // use this method again once the menu is placed within the same div as the
20
- // button.
21
- // const menuRect = buttonRef.current.nextSibling?.getBoundingClientRect();
81
+
82
+ var _getBoundingClientRec2 = getBoundingClientRects(buttonRef, isSplitButton),
83
+ buttonRect = _getBoundingClientRec2.buttonRect,
84
+ primaryButtonRect = _getBoundingClientRec2.primaryButtonRect,
85
+ menuRect = _getBoundingClientRec2.menuRect;
22
86
 
23
87
  var isRtl = langDir === 'rtl';
24
88
  var buttonX = buttonRect.x,
@@ -36,19 +100,12 @@ var getMenuPosition = function getMenuPosition(_ref) {
36
100
  var scrollXOffset = hasScrollY ? 15 : 0;
37
101
  var y = buttonY + buttonHeight;
38
102
  var x = isSplitButton ? buttonX + primaryButtonWidth : buttonX;
39
- var windowWidth = window.innerWidth || document.documentElement.clientWidth;
40
- var windowHeight = window.innerHeight || document.documentElement.clientHeight;
41
- var menuHeight = (_menuRect$height = menuRect === null || menuRect === void 0 ? void 0 : menuRect.height) !== null && _menuRect$height !== void 0 ? _menuRect$height : 0;
42
- var menuWidth = (_menuRect$width = menuRect === null || menuRect === void 0 ? void 0 : menuRect.width) !== null && _menuRect$width !== void 0 ? _menuRect$width : 0;
43
- var offTop = buttonRect.top - menuHeight < 0;
44
- var offLeft = buttonRect.left - menuWidth < 0;
45
- var offRight = buttonRect.right + menuWidth > windowWidth;
46
- var offBottom = buttonRect.bottom + menuHeight > windowHeight;
47
- var T = offTop ? 'top' : '';
48
- var R = offRight ? 'right' : '';
49
- var B = offBottom ? 'bottom' : '';
50
- var L = offLeft ? 'left' : '';
51
- var overflow = [T, R, B, L].filter(Boolean).join('-');
103
+
104
+ var _getMenuDimensions3 = getMenuDimensions(menuRect),
105
+ menuHeight = _getMenuDimensions3.menuHeight,
106
+ menuWidth = _getMenuDimensions3.menuWidth;
107
+
108
+ var overflow = getOverflow(menuRect, buttonRect);
52
109
  /* istanbul ignore else */
53
110
 
54
111
  if (menuRect) {
@@ -112,4 +169,4 @@ var getMenuPosition = function getMenuPosition(_ref) {
112
169
  };
113
170
  };
114
171
 
115
- export { getMenuPosition };
172
+ export { getMenuPosition, getShadowBlockerConfig };