@carbon/ibm-products 2.43.2-canary.46 → 2.43.2-canary.54

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/es/components/Coachmark/Coachmark.js +12 -7
  2. package/es/components/CoachmarkFixed/CoachmarkFixed.js +13 -11
  3. package/es/components/CoachmarkStack/CoachmarkStack.js +7 -3
  4. package/es/components/CoachmarkStack/CoachmarkStackHome.js +8 -4
  5. package/es/components/CreateFullPage/CreateFullPage.js +2 -2
  6. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +2 -1
  7. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +3 -2
  8. package/es/components/Datagrid/useSelectRows.js +2 -1
  9. package/es/components/EditInPlace/EditInPlace.d.ts +4 -0
  10. package/es/components/EditInPlace/EditInPlace.js +21 -10
  11. package/es/components/Nav/NavItem.js +12 -3
  12. package/es/components/OptionsTile/OptionsTile.js +4 -5
  13. package/es/components/SidePanel/SidePanel.js +17 -20
  14. package/es/components/SidePanel/motion/variants.d.ts +4 -6
  15. package/es/components/SidePanel/motion/variants.js +10 -11
  16. package/es/components/Tearsheet/TearsheetShell.js +3 -1
  17. package/es/components/WebTerminal/WebTerminal.js +10 -12
  18. package/es/global/js/hooks/usePrefersReducedMotion.js +14 -8
  19. package/lib/components/Coachmark/Coachmark.js +12 -7
  20. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +13 -11
  21. package/lib/components/CoachmarkStack/CoachmarkStack.js +7 -3
  22. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +8 -4
  23. package/lib/components/CreateFullPage/CreateFullPage.js +2 -2
  24. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +2 -1
  25. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +3 -2
  26. package/lib/components/Datagrid/useSelectRows.js +2 -1
  27. package/lib/components/EditInPlace/EditInPlace.d.ts +4 -0
  28. package/lib/components/EditInPlace/EditInPlace.js +21 -10
  29. package/lib/components/Nav/NavItem.js +10 -1
  30. package/lib/components/OptionsTile/OptionsTile.js +4 -5
  31. package/lib/components/SidePanel/SidePanel.js +16 -19
  32. package/lib/components/SidePanel/motion/variants.d.ts +4 -6
  33. package/lib/components/SidePanel/motion/variants.js +10 -11
  34. package/lib/components/Tearsheet/TearsheetShell.js +3 -1
  35. package/lib/components/WebTerminal/WebTerminal.js +10 -12
  36. package/lib/global/js/hooks/usePrefersReducedMotion.js +13 -7
  37. package/package.json +3 -3
  38. package/es/global/js/utils/window.d.ts +0 -2
  39. package/es/global/js/utils/window.js +0 -12
  40. package/lib/global/js/utils/window.d.ts +0 -2
  41. package/lib/global/js/utils/window.js +0 -16
@@ -23,35 +23,34 @@ var overlayVariants = {
23
23
  }
24
24
  };
25
25
  var panelVariants = {
26
- visible: function visible(_ref) {
27
- var shouldReduceMotion = _ref.shouldReduceMotion;
26
+ visible: function visible() {
28
27
  return {
29
28
  x: 0,
30
29
  transition: {
31
30
  duration: DURATIONS.moderate02,
32
31
  ease: EASINGS.productive.standard
33
32
  },
34
- opacity: shouldReduceMotion && 1
33
+ opacity: 1
35
34
  };
36
35
  },
37
- hidden: function hidden(_ref2) {
38
- var placement = _ref2.placement,
39
- shouldReduceMotion = _ref2.shouldReduceMotion;
36
+ hidden: function hidden(_ref) {
37
+ var placement = _ref.placement,
38
+ shouldReduceMotion = _ref.shouldReduceMotion;
40
39
  return {
41
40
  x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
42
- opacity: shouldReduceMotion && 0
41
+ opacity: shouldReduceMotion ? 0 : 1
43
42
  };
44
43
  },
45
- exit: function exit(_ref3) {
46
- var placement = _ref3.placement,
47
- shouldReduceMotion = _ref3.shouldReduceMotion;
44
+ exit: function exit(_ref2) {
45
+ var placement = _ref2.placement,
46
+ shouldReduceMotion = _ref2.shouldReduceMotion;
48
47
  return {
49
48
  x: placement === 'right' ? shouldReduceMotion ? 0 : '100%' : shouldReduceMotion ? 0 : -320,
50
49
  transition: {
51
50
  duration: DURATIONS.moderate01,
52
51
  ease: EASINGS.productive.exit
53
52
  },
54
- opacity: shouldReduceMotion && 0
53
+ opacity: shouldReduceMotion ? 0 : 1
55
54
  };
56
55
  }
57
56
  };
@@ -313,7 +313,9 @@ var TearsheetShell = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
313
313
  // The display name of the component, used by React. Note that displayName
314
314
  // is used in preference to relying on function.name.
315
315
  TearsheetShell.displayName = componentName;
316
- var portalType = typeof Element === 'undefined' ? PropTypes.object : PropTypes.instanceOf(Element);
316
+ var portalType = typeof Element === 'undefined' ? PropTypes.object
317
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
318
+ : PropTypes.instanceOf(Element);
317
319
  var deprecatedProps = {
318
320
  /**
319
321
  * **Deprecated**
@@ -15,6 +15,7 @@ import { OverflowMenu, OverflowMenuItem, Button, Theme } from '@carbon/react';
15
15
  import { moderate02 } from '@carbon/motion';
16
16
  import { useWebTerminal } from './hooks/index.js';
17
17
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
18
+ import usePrefersReducedMotion from '../../global/js/hooks/usePrefersReducedMotion.js';
18
19
 
19
20
  var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen", "webTerminalAriaLabel"];
20
21
 
@@ -56,10 +57,7 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
56
57
  _useState2 = _slicedToArray(_useState, 2),
57
58
  shouldRender = _useState2[0],
58
59
  setRender = _useState2[1];
59
- var _ref2 = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
60
- matches: true
61
- },
62
- prefersReducedMotion = _ref2.matches;
60
+ var shouldReduceMotion = usePrefersReducedMotion();
63
61
  var webTerminalAnimationName = "".concat(open ? 'web-terminal-entrance' : 'web-terminal-exit forwards', " ").concat(moderate02);
64
62
  var showDocumentationLinks = useMemo(function () {
65
63
  return documentationLinks.length > 0;
@@ -92,7 +90,7 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
92
90
  If the user prefers reduced motion, we have to manually set render to false
93
91
  because onAnimationEnd will never be called.
94
92
  */
95
- if (prefersReducedMotion) {
93
+ if (shouldReduceMotion) {
96
94
  setRender(false);
97
95
  }
98
96
  closeWebTerminal === null || closeWebTerminal === void 0 || closeWebTerminal();
@@ -101,7 +99,7 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
101
99
  ref: ref,
102
100
  className: cx([blockClass, className, _defineProperty(_defineProperty({}, "".concat(blockClass, "--open"), open), "".concat(blockClass, "--closed"), !open)]),
103
101
  style: {
104
- animation: !prefersReducedMotion ? webTerminalAnimationName : ''
102
+ animation: !shouldReduceMotion ? webTerminalAnimationName : ''
105
103
  },
106
104
  onAnimationEnd: onAnimationEnd
107
105
  }), /*#__PURE__*/React__default.createElement("header", {
@@ -119,15 +117,15 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
119
117
  "aria-label": documentationLinksIconDescription,
120
118
  menuOptionsClass: "".concat(blockClass, "__documentation-overflow"),
121
119
  size: "lg"
122
- }, documentationLinks.map(function (_ref4, i) {
123
- var rest = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
120
+ }, documentationLinks.map(function (_ref3, i) {
121
+ var rest = _extends({}, (_objectDestructuringEmpty(_ref3), _ref3));
124
122
  return /*#__PURE__*/React__default.createElement(OverflowMenuItem, _extends({
125
123
  key: i
126
124
  }, rest));
127
- })), actions.map(function (_ref5) {
128
- var renderIcon = _ref5.renderIcon,
129
- onClick = _ref5.onClick,
130
- iconDescription = _ref5.iconDescription;
125
+ })), actions.map(function (_ref4) {
126
+ var renderIcon = _ref4.renderIcon,
127
+ onClick = _ref4.onClick,
128
+ iconDescription = _ref4.iconDescription;
131
129
  return /*#__PURE__*/React__default.createElement(Button, {
132
130
  key: iconDescription,
133
131
  hasIconOnly: true,
@@ -6,20 +6,26 @@
6
6
  */
7
7
 
8
8
  import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { useState, useEffect } from 'react';
10
- import { hasDocument } from '../utils/window.js';
9
+ import { useState } from 'react';
10
+ import { useIsomorphicEffect } from './useIsomorphicEffect.js';
11
11
 
12
12
  var usePrefersReducedMotion = function usePrefersReducedMotion() {
13
13
  var _useState = useState(false),
14
14
  _useState2 = _slicedToArray(_useState, 2),
15
15
  prefersReducedMotion = _useState2[0],
16
16
  setPrefersReducedMotion = _useState2[1];
17
- useEffect(function () {
18
- if (hasDocument()) {
19
- var _window$matchMedia = window.matchMedia('(prefers-reduced-motion: reduce)'),
20
- matches = _window$matchMedia.matches;
21
- setPrefersReducedMotion(matches);
22
- }
17
+ useIsomorphicEffect(function () {
18
+ var mediaQueryList = window.matchMedia('(prefers-reduced-motion: no-preference)');
19
+ var _window$matchMedia = window.matchMedia('(prefers-reduced-motion: no-preference)'),
20
+ matches = _window$matchMedia.matches;
21
+ setPrefersReducedMotion(!matches);
22
+ var listener = function listener(event) {
23
+ setPrefersReducedMotion(!event.matches);
24
+ };
25
+ mediaQueryList.addEventListener('change', listener);
26
+ return function () {
27
+ mediaQueryList.removeEventListener('change', listener);
28
+ };
23
29
  }, []);
24
30
  return prefersReducedMotion;
25
31
  };
@@ -21,6 +21,7 @@ var hooks = require('./utils/hooks.js');
21
21
  var devtools = require('../../global/js/utils/devtools.js');
22
22
  var settings = require('../../settings.js');
23
23
  var lodash = require('lodash');
24
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
24
25
 
25
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
27
 
@@ -45,7 +46,6 @@ var defaults = {
45
46
  */
46
47
 
47
48
  exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
48
- var _document$querySelect;
49
49
  var _ref$align = _ref.align,
50
50
  align = _ref$align === void 0 ? defaults.align : _ref$align,
51
51
  children = _ref.children,
@@ -64,7 +64,6 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
64
64
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
65
65
  var isBeacon = overlayKind === enums.COACHMARK_OVERLAY_KIND.TOOLTIP;
66
66
  var isStacked = overlayKind === enums.COACHMARK_OVERLAY_KIND.STACKED;
67
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
68
67
  var _useState = React.useState(isStacked),
69
68
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
70
69
  isOpen = _useState2[0],
@@ -88,6 +87,11 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
88
87
  var backupRef = React.useRef();
89
88
  var _coachmarkRef = ref || backupRef;
90
89
  var _overlayRef = overlayRef || overlayBackupRef;
90
+ var portalNode = React.useRef(null);
91
+ useIsomorphicEffect.useIsomorphicEffect(function () {
92
+ var _document$querySelect, _document, _document2, _document3;
93
+ portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
94
+ }, [portalTarget]);
91
95
  var closeOverlay = function closeOverlay() {
92
96
  setIsOpen(false);
93
97
  };
@@ -178,18 +182,19 @@ exports.Coachmark = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
178
182
  }, /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
179
183
  className: cx__default["default"](blockClass, "".concat(blockClass, "__").concat(theme), className),
180
184
  ref: _coachmarkRef
181
- }, rest, devtools.getDevtoolsProps(componentName)), target, isOpen && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
185
+ }, rest, devtools.getDevtoolsProps(componentName)), target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
182
186
  ref: _overlayRef,
183
187
  fixedIsVisible: false,
184
188
  kind: overlayKind,
185
189
  onClose: handleClose,
186
190
  theme: theme,
187
191
  className: cx__default["default"](overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
188
- }, children),
189
- // Default to `document.body` when `portalNode` is `null`
190
- portalNode || document.body)));
192
+ }, children), // Default to `document.body` when `portalNode` is `null`
193
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
191
194
  });
192
- var overlayRefType = typeof HTMLElement === 'undefined' ? index["default"].object : index["default"].instanceOf(HTMLElement);
195
+ var overlayRefType = typeof HTMLElement === 'undefined' ? index["default"].object :
196
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
197
+ index["default"].instanceOf(HTMLElement);
193
198
 
194
199
  // Return a placeholder if not released and not enabled by feature flag
195
200
  exports.Coachmark = settings.pkg.checkComponentEnabled(exports.Coachmark, componentName);
@@ -20,6 +20,8 @@ var CoachmarkOverlay = require('../Coachmark/CoachmarkOverlay.js');
20
20
  var CoachmarkTagline = require('../Coachmark/CoachmarkTagline.js');
21
21
  var context = require('../Coachmark/utils/context.js');
22
22
  var enums = require('../Coachmark/utils/enums.js');
23
+ var framerMotion = require('framer-motion');
24
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
23
25
 
24
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
25
27
 
@@ -48,7 +50,6 @@ var defaults = {
48
50
  * This variant allows the a coachmark overlay to be displayed by interacting with the tagline.
49
51
  */
50
52
  exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
51
- var _document$querySelect;
52
53
  var children = _ref.children,
53
54
  className = _ref.className,
54
55
  _ref$onClose = _ref.onClose,
@@ -60,7 +61,7 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
60
61
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
61
62
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
62
63
  var overlayRef = React.useRef(null);
63
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
64
+ var portalNode = React.useRef(null);
64
65
  var _useState = React.useState(false),
65
66
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
66
67
  isOpen = _useState2[0],
@@ -84,17 +85,19 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
84
85
  _useState10 = _rollupPluginBabelHelpers.slicedToArray(_useState9, 2),
85
86
  fixedIsVisible = _useState10[0],
86
87
  setFixedIsVisible = _useState10[1];
87
- var prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
88
+ var shouldReduceMotion = framerMotion.useReducedMotion();
89
+ useIsomorphicEffect.useIsomorphicEffect(function () {
90
+ var _document$querySelect, _document, _document2, _document3;
91
+ portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
92
+ }, [portalTarget]);
88
93
  var handleClose = React.useCallback(function () {
89
- console.log('HANDLING CLOSE HERE...');
90
- if (prefersReducedMotion.matches) {
94
+ if (shouldReduceMotion) {
91
95
  setIsOpen(false);
92
96
  } else {
93
97
  setFixedIsVisible(false);
94
98
  }
95
- }, [prefersReducedMotion.matches]);
99
+ }, [shouldReduceMotion]);
96
100
  var handleTransitionEnd = function handleTransitionEnd(e) {
97
- console.log('Here at transition end... ', e.propertyName === 'transform' && !fixedIsVisible);
98
101
  if (e.propertyName === 'transform' && !fixedIsVisible) {
99
102
  setIsOpen(false);
100
103
  onClose();
@@ -173,7 +176,7 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
173
176
  }, devtools.getDevtoolsProps(componentName)), /*#__PURE__*/React__default["default"].createElement(CoachmarkTagline.CoachmarkTagline, {
174
177
  title: tagline,
175
178
  onClose: onClose
176
- }), isOpen && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
179
+ }), isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement(CoachmarkOverlay.CoachmarkOverlay, {
177
180
  ref: overlayRef,
178
181
  fixedIsVisible: fixedIsVisible,
179
182
  kind: enums.COACHMARK_OVERLAY_KIND.FIXED,
@@ -181,9 +184,8 @@ exports.CoachmarkFixed = /*#__PURE__*/React__default["default"].forwardRef(funct
181
184
  onTransitionEnd: handleTransitionEnd,
182
185
  theme: theme,
183
186
  className: cx__default["default"](fixedIsVisible && "".concat(overlayBlockClass, "--is-visible"), overlayBlockClass)
184
- }, children),
185
- // Default to `document.body` when `portalNode` is `null`
186
- portalNode || document.body)));
187
+ }, children), // Default to `document.body` when `portalNode` is `null`
188
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
187
189
  });
188
190
 
189
191
  // Return a placeholder if not released and not enabled by feature flag
@@ -21,6 +21,7 @@ var CoachmarkStackHome = require('./CoachmarkStackHome.js');
21
21
  var CoachmarkTagline = require('../Coachmark/CoachmarkTagline.js');
22
22
  var context = require('../Coachmark/utils/context.js');
23
23
  var enums = require('../Coachmark/utils/enums.js');
24
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
24
25
 
25
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
26
27
 
@@ -56,7 +57,6 @@ var defaults = {
56
57
  * This variant allows the stacking of multiple coachmark overlays to be displayed by interacting with the tagline.
57
58
  */
58
59
  exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
59
- var _document$querySelect;
60
60
  var children = _ref.children,
61
61
  className = _ref.className,
62
62
  _ref$onClose = _ref.onClose,
@@ -72,7 +72,11 @@ exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(funct
72
72
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
73
73
  title = _ref.title,
74
74
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
75
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
75
+ var portalNode = React.useRef();
76
+ useIsomorphicEffect.useIsomorphicEffect(function () {
77
+ var _document$querySelect, _document, _document2, _document3;
78
+ portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
79
+ }, [portalTarget]);
76
80
  var stackHomeRef = React.useRef();
77
81
  var stackedCoachmarkRefs = React.useRef([]);
78
82
  var _useState = React.useState(false),
@@ -215,7 +219,7 @@ exports.CoachmarkStack = /*#__PURE__*/React__default["default"].forwardRef(funct
215
219
  portalTarget: portalTarget,
216
220
  closeButtonLabel: closeButtonLabel,
217
221
  title: title
218
- }), /*#__PURE__*/reactDom.createPortal(wrappedChildren, portalNode)));
222
+ }), portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/reactDom.createPortal(wrappedChildren, portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null));
219
223
  });
220
224
 
221
225
  // Return a placeholder if not released and not enabled by feature flag
@@ -20,6 +20,7 @@ var devtools = require('../../global/js/utils/devtools.js');
20
20
  var settings = require('../../settings.js');
21
21
  var reactDom = require('react-dom');
22
22
  var CoachmarkHeader = require('../Coachmark/CoachmarkHeader.js');
23
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
23
24
  var SteppedAnimatedMedia = require('../SteppedAnimatedMedia/SteppedAnimatedMedia.js');
24
25
 
25
26
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -42,7 +43,6 @@ var componentName = 'CoachmarkStackHome';
42
43
  * of other Onboarding components.
43
44
  */
44
45
  exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
45
- var _document$querySelect;
46
46
  var className = _ref.className,
47
47
  description = _ref.description,
48
48
  isOpen = _ref.isOpen,
@@ -66,11 +66,15 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
66
66
  }
67
67
  }, 100);
68
68
  }, [isOpen]);
69
+ var portalNode = React.useRef();
70
+ useIsomorphicEffect.useIsomorphicEffect(function () {
71
+ var _document$querySelect, _document, _document2, _document3;
72
+ portalNode.current = portalTarget ? (_document$querySelect = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : (_document2 = document) === null || _document2 === void 0 ? void 0 : _document2.querySelector('body') : (_document3 = document) === null || _document3 === void 0 ? void 0 : _document3.querySelector('body');
73
+ }, [portalTarget]);
69
74
  if (!navLinkLabels) {
70
75
  return pconsole["default"].warn("".concat(componentName, " is an Onboarding internal component and is not intended for general use."));
71
76
  }
72
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
73
- return /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
77
+ return portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
74
78
  className: cx__default["default"](blockClass, className),
75
79
  ref: ref,
76
80
  role: "main"
@@ -112,7 +116,7 @@ exports.CoachmarkStackHome = /*#__PURE__*/React.forwardRef(function (_ref, ref)
112
116
  setLinkFocusIndex(0);
113
117
  _onClose();
114
118
  }
115
- }, closeButtonLabel))))), portalNode);
119
+ }, closeButtonLabel))))), portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null;
116
120
  function renderNavLink(index, label) {
117
121
  var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
118
122
  return /*#__PURE__*/React__default["default"].createElement("li", {
@@ -98,6 +98,7 @@ exports.CreateFullPage = /*#__PURE__*/React__default["default"].forwardRef(funct
98
98
  _useState10 = _rollupPluginBabelHelpers.slicedToArray(_useState9, 2),
99
99
  modalIsOpen = _useState10[0],
100
100
  setModalIsOpen = _useState10[1];
101
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
101
102
  var previousState = usePreviousValue.usePreviousValue({
102
103
  currentStep: currentStep,
103
104
  open: open
@@ -155,8 +156,7 @@ exports.CreateFullPage = /*#__PURE__*/React__default["default"].forwardRef(funct
155
156
  useResetCreateComponent.useResetCreateComponent({
156
157
  firstIncludedStep: firstIncludedStep,
157
158
  previousState: previousState,
158
- /**@ts-ignore */
159
- open: open,
159
+ open: true,
160
160
  setCurrentStep: setCurrentStep,
161
161
  stepData: stepData,
162
162
  /**@ts-ignore */
@@ -25,11 +25,12 @@ var _excluded = ["onChange"];
25
25
  var blockClass = "".concat(settings.pkg.prefix, "--datagrid");
26
26
  var SelectAll = function SelectAll(datagridState) {
27
27
  var _columns$;
28
- var _useState = React.useState(typeof window !== 'undefined' ? window.innerWidth : ''),
28
+ var _useState = React.useState(),
29
29
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
30
30
  windowSize = _useState2[0],
31
31
  setWindowSize = _useState2[1];
32
32
  React.useLayoutEffect(function () {
33
+ setWindowSize(window.innerWidth);
33
34
  /* istanbul ignore next */
34
35
  function updateSize() {
35
36
  setWindowSize(window.innerWidth);
@@ -52,11 +52,12 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
52
52
  onSelectAllRows(isAllRowsSelected && selectAllMode === SELECT_ALL_ROWS);
53
53
  }
54
54
  }, [isAllRowsSelected, selectAllMode, onSelectAllRows]);
55
- var _useState3 = React.useState(window.innerWidth),
55
+ var _useState3 = React.useState(),
56
56
  _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
57
57
  windowSize = _useState4[0],
58
58
  setWindowSize = _useState4[1];
59
59
  React.useLayoutEffect(function () {
60
+ setWindowSize(window.innerWidth);
60
61
  function updateSize() {
61
62
  setWindowSize(window.innerWidth);
62
63
  }
@@ -77,7 +78,7 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
77
78
  var isFirstColumnStickyLeft = (columns === null || columns === void 0 || (_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
78
79
  return /*#__PURE__*/React__default["default"].createElement("th", {
79
80
  scope: "col",
80
- className: cx__default["default"]("".concat(blockClass, "__select-all-toggle-on"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
81
+ className: cx__default["default"]("".concat(blockClass, "__select-all-toggle-on"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && (windowSize !== null && windowSize !== void 0 ? windowSize : 0) > 671))
81
82
  }, /*#__PURE__*/React__default["default"].createElement("span", null, /*#__PURE__*/React__default["default"].createElement(react.Checkbox, _rollupPluginBabelHelpers["extends"]({}, selectProps, {
82
83
  name: "".concat(tableId, "-select-all-checkbox-name"),
83
84
  onClick: function onClick(e) {
@@ -90,11 +90,12 @@ var SelectRow = function SelectRow(datagridState) {
90
90
  withStickyColumn = datagridState.withStickyColumn,
91
91
  dispatch = datagridState.dispatch,
92
92
  getRowId = datagridState.getRowId;
93
- var _useState = React.useState(typeof window !== 'undefined' ? window.innerWidth : ''),
93
+ var _useState = React.useState(),
94
94
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
95
95
  windowSize = _useState2[0],
96
96
  setWindowSize = _useState2[1];
97
97
  React.useLayoutEffect(function () {
98
+ setWindowSize(window.innerWidth);
98
99
  function updateSize() {
99
100
  setWindowSize(window.innerWidth);
100
101
  }
@@ -50,6 +50,10 @@ interface EditInplaceProps extends PropsWithChildren {
50
50
  * Provide the text that will be read by a screen reader when visiting this control
51
51
  */
52
52
  labelText: string;
53
+ /**
54
+ * handler to add custom onBlur event
55
+ */
56
+ onBlur?: (value: string) => void;
53
57
  /**
54
58
  * handler that is called when the cancel button is pressed or when the user removes focus from the input and there is no new value
55
59
  */
@@ -24,7 +24,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
24
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
25
 
26
26
  var _Close, _Checkmark, _Edit;
27
- var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "size", "tooltipAlignment", "value"];
27
+ var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value"];
28
28
  var componentName = 'EditInPlace';
29
29
  var blockClass = "".concat(settings.pkg.prefix, "--edit-in-place");
30
30
  var defaults = {
@@ -45,6 +45,7 @@ exports.EditInPlace = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
45
45
  onCancel = _ref.onCancel,
46
46
  onChange = _ref.onChange,
47
47
  onSave = _ref.onSave,
48
+ onBlur = _ref.onBlur,
48
49
  saveLabel = _ref.saveLabel,
49
50
  _ref$size = _ref.size,
50
51
  size = _ref$size === void 0 ? 'sm' : _ref$size,
@@ -112,15 +113,21 @@ exports.EditInPlace = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
112
113
  onCancel(initialValue);
113
114
  };
114
115
  var onBlurHandler = function onBlurHandler(e) {
115
- // if (readOnly || escaping.current) {
116
- if (escaping.current) {
117
- return;
118
- }
119
- if (!isTargetingChild(e)) {
120
- if (canSave) {
121
- onSaveHandler();
122
- } else {
123
- onCancelHandler();
116
+ // Use custom function provided if passed through
117
+ if (typeof onBlur === 'function' && !isTargetingChild(e)) {
118
+ onBlur(initialValue);
119
+ setFocused(false);
120
+ } else {
121
+ // Use Default behavior if no custom function provided
122
+ if (escaping.current) {
123
+ return;
124
+ }
125
+ if (!isTargetingChild(e)) {
126
+ if (canSave) {
127
+ onSaveHandler();
128
+ } else {
129
+ onCancelHandler();
130
+ }
124
131
  }
125
132
  }
126
133
  };
@@ -260,6 +267,10 @@ exports.EditInPlace.propTypes = _rollupPluginBabelHelpers.objectSpread2({
260
267
  * Provide the text that will be read by a screen reader when visiting this control
261
268
  */
262
269
  labelText: index["default"].string.isRequired,
270
+ /**
271
+ * handler to add custom onBlur event
272
+ */
273
+ onBlur: index["default"].func,
263
274
  /**
264
275
  * handler that is called when the cancel button is pressed or when the user removes focus from the input and there is no new value
265
276
  */
@@ -60,11 +60,20 @@ var NavItem = function NavItem(_ref) {
60
60
  _ref$tabIndex = _ref.tabIndex,
61
61
  tabIndex = _ref$tabIndex === void 0 ? defaults.tabIndex : _ref$tabIndex,
62
62
  rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
63
+ var _useState = React.useState(false),
64
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
65
+ hrefHasDifferentHost = _useState2[0],
66
+ setHrefHasDifferentHost = _useState2[1];
67
+ React.useEffect(function () {
68
+ if (href.indexOf(window.location.host) === -1) {
69
+ setHrefHasDifferentHost(true);
70
+ }
71
+ }, [href]);
63
72
  var internalId = React.useRef(uuidv4["default"]());
64
73
  var instanceId = "".concat(blockClass, "__").concat(internalId.current);
65
74
  var navItemId = id || instanceId;
66
75
  var isAbsoluteLink = new RegExp('^([a-z]+://|//)', 'i');
67
- var externalLink = isAbsoluteLink.test(href) && href.indexOf(window.location.host) === -1;
76
+ var externalLink = isAbsoluteLink.test(href) && hrefHasDifferentHost;
68
77
  var linkClassName = "".concat(blockClass, "__link");
69
78
  var handleDisabled = function handleDisabled(action) {
70
79
  var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -19,6 +19,7 @@ var settings = require('../../settings.js');
19
19
  var react = require('@carbon/react');
20
20
  var icons = require('@carbon/react/icons');
21
21
  var carbonMotion = require('@carbon/motion');
22
+ var usePrefersReducedMotion = require('../../global/js/hooks/usePrefersReducedMotion.js');
22
23
  var useControllableState = require('../../global/js/hooks/useControllableState.js');
23
24
 
24
25
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -99,9 +100,7 @@ exports.OptionsTile = /*#__PURE__*/React__default["default"].forwardRef(function
99
100
  var isInvalid = invalid;
100
101
  var isWarn = !isInvalid && warn;
101
102
  var isLocked = !isInvalid && !isWarn && locked;
102
- var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
103
- matches: true
104
- };
103
+ var shouldReduceMotion = usePrefersReducedMotion["default"]();
105
104
  if (open !== prevIsOpen) {
106
105
  if (isOpen && !open) {
107
106
  collapse();
@@ -111,7 +110,7 @@ exports.OptionsTile = /*#__PURE__*/React__default["default"].forwardRef(function
111
110
  setPrevIsOpen(open);
112
111
  }
113
112
  function expand() {
114
- if (detailsRef.current && contentRef.current && !reducedMotion.matches) {
113
+ if (detailsRef.current && contentRef.current && !shouldReduceMotion) {
115
114
  setIsOpen(true);
116
115
  detailsRef.current.open = true;
117
116
  var _getComputedStyle = getComputedStyle(contentRef.current),
@@ -140,7 +139,7 @@ exports.OptionsTile = /*#__PURE__*/React__default["default"].forwardRef(function
140
139
  }
141
140
  }
142
141
  function collapse() {
143
- if (contentRef.current && !reducedMotion.matches) {
142
+ if (contentRef.current && !shouldReduceMotion) {
144
143
  setClosing(true);
145
144
  var _getComputedStyle2 = getComputedStyle(contentRef.current),
146
145
  paddingTop = _getComputedStyle2.paddingTop,