@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
@@ -17,6 +17,7 @@ import { useClickOutsideElement, useWindowEvent } from './utils/hooks.js';
17
17
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
18
18
  import { pkg } from '../../settings.js';
19
19
  import { throttle } from 'lodash';
20
+ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
20
21
 
21
22
  var _excluded = ["align", "children", "className", "onClose", "overlayClassName", "overlayKind", "overlayRef", "portalTarget", "positionTune", "target", "theme"];
22
23
  // The block part of our conventional BEM class names (blockClass__E--M).
@@ -36,7 +37,6 @@ var defaults = {
36
37
  */
37
38
 
38
39
  var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
- var _document$querySelect;
40
40
  var _ref$align = _ref.align,
41
41
  align = _ref$align === void 0 ? defaults.align : _ref$align,
42
42
  children = _ref.children,
@@ -55,7 +55,6 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
55
55
  rest = _objectWithoutProperties(_ref, _excluded);
56
56
  var isBeacon = overlayKind === COACHMARK_OVERLAY_KIND.TOOLTIP;
57
57
  var isStacked = overlayKind === COACHMARK_OVERLAY_KIND.STACKED;
58
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
59
58
  var _useState = useState(isStacked),
60
59
  _useState2 = _slicedToArray(_useState, 2),
61
60
  isOpen = _useState2[0],
@@ -79,6 +78,11 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
79
78
  var backupRef = useRef();
80
79
  var _coachmarkRef = ref || backupRef;
81
80
  var _overlayRef = overlayRef || overlayBackupRef;
81
+ var portalNode = useRef(null);
82
+ useIsomorphicEffect(function () {
83
+ var _document$querySelect, _document, _document2, _document3;
84
+ 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');
85
+ }, [portalTarget]);
82
86
  var closeOverlay = function closeOverlay() {
83
87
  setIsOpen(false);
84
88
  };
@@ -169,18 +173,19 @@ var Coachmark = /*#__PURE__*/forwardRef(function (_ref, ref) {
169
173
  }, /*#__PURE__*/React__default.createElement("div", _extends({
170
174
  className: cx(blockClass, "".concat(blockClass, "__").concat(theme), className),
171
175
  ref: _coachmarkRef
172
- }, rest, getDevtoolsProps(componentName)), target, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
176
+ }, rest, getDevtoolsProps(componentName)), target, isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
173
177
  ref: _overlayRef,
174
178
  fixedIsVisible: false,
175
179
  kind: overlayKind,
176
180
  onClose: handleClose,
177
181
  theme: theme,
178
182
  className: cx(overlayClassName, "".concat(overlayBlockClass, "--is-visible"))
179
- }, children),
180
- // Default to `document.body` when `portalNode` is `null`
181
- portalNode || document.body)));
183
+ }, children), // Default to `document.body` when `portalNode` is `null`
184
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
182
185
  });
183
- var overlayRefType = typeof HTMLElement === 'undefined' ? PropTypes.object : PropTypes.instanceOf(HTMLElement);
186
+ var overlayRefType = typeof HTMLElement === 'undefined' ? PropTypes.object :
187
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
188
+ PropTypes.instanceOf(HTMLElement);
184
189
 
185
190
  // Return a placeholder if not released and not enabled by feature flag
186
191
  Coachmark = pkg.checkComponentEnabled(Coachmark, componentName);
@@ -16,6 +16,8 @@ import { CoachmarkOverlay } from '../Coachmark/CoachmarkOverlay.js';
16
16
  import { CoachmarkTagline } from '../Coachmark/CoachmarkTagline.js';
17
17
  import { CoachmarkContext } from '../Coachmark/utils/context.js';
18
18
  import { COACHMARK_OVERLAY_KIND } from '../Coachmark/utils/enums.js';
19
+ import { useReducedMotion } from 'framer-motion';
20
+ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
19
21
 
20
22
  var _excluded = ["children", "className", "onClose", "portalTarget", "tagline", "theme"];
21
23
  // Carbon and package components we use.
@@ -39,7 +41,6 @@ var defaults = {
39
41
  * This variant allows the a coachmark overlay to be displayed by interacting with the tagline.
40
42
  */
41
43
  var CoachmarkFixed = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
42
- var _document$querySelect;
43
44
  var children = _ref.children,
44
45
  className = _ref.className,
45
46
  _ref$onClose = _ref.onClose,
@@ -51,7 +52,7 @@ var CoachmarkFixed = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
51
52
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
52
53
  rest = _objectWithoutProperties(_ref, _excluded);
53
54
  var overlayRef = useRef(null);
54
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
55
+ var portalNode = useRef(null);
55
56
  var _useState = useState(false),
56
57
  _useState2 = _slicedToArray(_useState, 2),
57
58
  isOpen = _useState2[0],
@@ -75,17 +76,19 @@ var CoachmarkFixed = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
75
76
  _useState10 = _slicedToArray(_useState9, 2),
76
77
  fixedIsVisible = _useState10[0],
77
78
  setFixedIsVisible = _useState10[1];
78
- var prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
79
+ var shouldReduceMotion = useReducedMotion();
80
+ useIsomorphicEffect(function () {
81
+ var _document$querySelect, _document, _document2, _document3;
82
+ 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');
83
+ }, [portalTarget]);
79
84
  var handleClose = useCallback(function () {
80
- console.log('HANDLING CLOSE HERE...');
81
- if (prefersReducedMotion.matches) {
85
+ if (shouldReduceMotion) {
82
86
  setIsOpen(false);
83
87
  } else {
84
88
  setFixedIsVisible(false);
85
89
  }
86
- }, [prefersReducedMotion.matches]);
90
+ }, [shouldReduceMotion]);
87
91
  var handleTransitionEnd = function handleTransitionEnd(e) {
88
- console.log('Here at transition end... ', e.propertyName === 'transform' && !fixedIsVisible);
89
92
  if (e.propertyName === 'transform' && !fixedIsVisible) {
90
93
  setIsOpen(false);
91
94
  onClose();
@@ -164,7 +167,7 @@ var CoachmarkFixed = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
164
167
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React__default.createElement(CoachmarkTagline, {
165
168
  title: tagline,
166
169
  onClose: onClose
167
- }), isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
170
+ }), isOpen && (portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) && /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement(CoachmarkOverlay, {
168
171
  ref: overlayRef,
169
172
  fixedIsVisible: fixedIsVisible,
170
173
  kind: COACHMARK_OVERLAY_KIND.FIXED,
@@ -172,9 +175,8 @@ var CoachmarkFixed = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
172
175
  onTransitionEnd: handleTransitionEnd,
173
176
  theme: theme,
174
177
  className: cx(fixedIsVisible && "".concat(overlayBlockClass, "--is-visible"), overlayBlockClass)
175
- }, children),
176
- // Default to `document.body` when `portalNode` is `null`
177
- portalNode || document.body)));
178
+ }, children), // Default to `document.body` when `portalNode` is `null`
179
+ portalNode === null || portalNode === void 0 ? void 0 : portalNode.current)));
178
180
  });
179
181
 
180
182
  // Return a placeholder if not released and not enabled by feature flag
@@ -17,6 +17,7 @@ import { CoachmarkStackHome } from './CoachmarkStackHome.js';
17
17
  import { CoachmarkTagline } from '../Coachmark/CoachmarkTagline.js';
18
18
  import { CoachmarkContext } from '../Coachmark/utils/context.js';
19
19
  import { COACHMARK_OVERLAY_KIND } from '../Coachmark/utils/enums.js';
20
+ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
20
21
 
21
22
  var _excluded = ["children", "className", "onClose", "description", "media", "navLinkLabels", "portalTarget", "closeButtonLabel", "tagline", "theme", "title"];
22
23
 
@@ -47,7 +48,6 @@ var defaults = {
47
48
  * This variant allows the stacking of multiple coachmark overlays to be displayed by interacting with the tagline.
48
49
  */
49
50
  var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
50
- var _document$querySelect;
51
51
  var children = _ref.children,
52
52
  className = _ref.className,
53
53
  _ref$onClose = _ref.onClose,
@@ -63,7 +63,11 @@ var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
63
63
  theme = _ref$theme === void 0 ? defaults.theme : _ref$theme,
64
64
  title = _ref.title,
65
65
  rest = _objectWithoutProperties(_ref, _excluded);
66
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
66
+ var portalNode = useRef();
67
+ useIsomorphicEffect(function () {
68
+ var _document$querySelect, _document, _document2, _document3;
69
+ 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');
70
+ }, [portalTarget]);
67
71
  var stackHomeRef = useRef();
68
72
  var stackedCoachmarkRefs = useRef([]);
69
73
  var _useState = useState(false),
@@ -206,7 +210,7 @@ var CoachmarkStack = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
206
210
  portalTarget: portalTarget,
207
211
  closeButtonLabel: closeButtonLabel,
208
212
  title: title
209
- }), /*#__PURE__*/createPortal(wrappedChildren, portalNode)));
213
+ }), portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/createPortal(wrappedChildren, portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null));
210
214
  });
211
215
 
212
216
  // Return a placeholder if not released and not enabled by feature flag
@@ -16,6 +16,7 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
16
16
  import { pkg } from '../../settings.js';
17
17
  import { createPortal } from 'react-dom';
18
18
  import { CoachmarkHeader } from '../Coachmark/CoachmarkHeader.js';
19
+ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
19
20
  import { SteppedAnimatedMedia } from '../SteppedAnimatedMedia/SteppedAnimatedMedia.js';
20
21
 
21
22
  var _excluded = ["className", "description", "isOpen", "media", "navLinkLabels", "onClickNavItem", "onClose", "portalTarget", "closeButtonLabel", "title"];
@@ -33,7 +34,6 @@ var componentName = 'CoachmarkStackHome';
33
34
  * of other Onboarding components.
34
35
  */
35
36
  var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
36
- var _document$querySelect;
37
37
  var className = _ref.className,
38
38
  description = _ref.description,
39
39
  isOpen = _ref.isOpen,
@@ -57,11 +57,15 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
57
57
  }
58
58
  }, 100);
59
59
  }, [isOpen]);
60
+ var portalNode = useRef();
61
+ useIsomorphicEffect(function () {
62
+ var _document$querySelect, _document, _document2, _document3;
63
+ 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');
64
+ }, [portalTarget]);
60
65
  if (!navLinkLabels) {
61
66
  return pconsole.warn("".concat(componentName, " is an Onboarding internal component and is not intended for general use."));
62
67
  }
63
- var portalNode = portalTarget ? (_document$querySelect = document.querySelector(portalTarget)) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('body') : document.querySelector('body');
64
- return /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
68
+ return portalNode !== null && portalNode !== void 0 && portalNode.current ? /*#__PURE__*/createPortal( /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
65
69
  className: cx(blockClass, className),
66
70
  ref: ref,
67
71
  role: "main"
@@ -103,7 +107,7 @@ var CoachmarkStackHome = /*#__PURE__*/forwardRef(function (_ref, ref) {
103
107
  setLinkFocusIndex(0);
104
108
  _onClose();
105
109
  }
106
- }, closeButtonLabel))))), portalNode);
110
+ }, closeButtonLabel))))), portalNode === null || portalNode === void 0 ? void 0 : portalNode.current) : null;
107
111
  function renderNavLink(index, label) {
108
112
  var ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
109
113
  return /*#__PURE__*/React__default.createElement("li", {
@@ -89,6 +89,7 @@ var CreateFullPage = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
89
89
  _useState10 = _slicedToArray(_useState9, 2),
90
90
  modalIsOpen = _useState10[0],
91
91
  setModalIsOpen = _useState10[1];
92
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
92
93
  var previousState = usePreviousValue({
93
94
  currentStep: currentStep,
94
95
  open: open
@@ -146,8 +147,7 @@ var CreateFullPage = /*#__PURE__*/React__default.forwardRef(function (_ref, ref)
146
147
  useResetCreateComponent({
147
148
  firstIncludedStep: firstIncludedStep,
148
149
  previousState: previousState,
149
- /**@ts-ignore */
150
- open: open,
150
+ open: true,
151
151
  setCurrentStep: setCurrentStep,
152
152
  stepData: stepData,
153
153
  /**@ts-ignore */
@@ -16,11 +16,12 @@ var _excluded = ["onChange"];
16
16
  var blockClass = "".concat(pkg.prefix, "--datagrid");
17
17
  var SelectAll = function SelectAll(datagridState) {
18
18
  var _columns$;
19
- var _useState = useState(typeof window !== 'undefined' ? window.innerWidth : ''),
19
+ var _useState = useState(),
20
20
  _useState2 = _slicedToArray(_useState, 2),
21
21
  windowSize = _useState2[0],
22
22
  setWindowSize = _useState2[1];
23
23
  useLayoutEffect(function () {
24
+ setWindowSize(window.innerWidth);
24
25
  /* istanbul ignore next */
25
26
  function updateSize() {
26
27
  setWindowSize(window.innerWidth);
@@ -43,11 +43,12 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
43
43
  onSelectAllRows(isAllRowsSelected && selectAllMode === SELECT_ALL_ROWS);
44
44
  }
45
45
  }, [isAllRowsSelected, selectAllMode, onSelectAllRows]);
46
- var _useState3 = useState(window.innerWidth),
46
+ var _useState3 = useState(),
47
47
  _useState4 = _slicedToArray(_useState3, 2),
48
48
  windowSize = _useState4[0],
49
49
  setWindowSize = _useState4[1];
50
50
  useLayoutEffect(function () {
51
+ setWindowSize(window.innerWidth);
51
52
  function updateSize() {
52
53
  setWindowSize(window.innerWidth);
53
54
  }
@@ -68,7 +69,7 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
68
69
  var isFirstColumnStickyLeft = (columns === null || columns === void 0 || (_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
69
70
  return /*#__PURE__*/React__default.createElement("th", {
70
71
  scope: "col",
71
- className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
72
+ className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && (windowSize !== null && windowSize !== void 0 ? windowSize : 0) > 671))
72
73
  }, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(Checkbox, _extends({}, selectProps, {
73
74
  name: "".concat(tableId, "-select-all-checkbox-name"),
74
75
  onClick: function onClick(e) {
@@ -81,11 +81,12 @@ var SelectRow = function SelectRow(datagridState) {
81
81
  withStickyColumn = datagridState.withStickyColumn,
82
82
  dispatch = datagridState.dispatch,
83
83
  getRowId = datagridState.getRowId;
84
- var _useState = useState(typeof window !== 'undefined' ? window.innerWidth : ''),
84
+ var _useState = useState(),
85
85
  _useState2 = _slicedToArray(_useState, 2),
86
86
  windowSize = _useState2[0],
87
87
  setWindowSize = _useState2[1];
88
88
  useLayoutEffect(function () {
89
+ setWindowSize(window.innerWidth);
89
90
  function updateSize() {
90
91
  setWindowSize(window.innerWidth);
91
92
  }
@@ -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
  */
@@ -15,7 +15,7 @@ import { pkg, carbon } from '../../settings.js';
15
15
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
16
16
 
17
17
  var _Close, _Checkmark, _Edit;
18
- var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "saveLabel", "size", "tooltipAlignment", "value"];
18
+ var _excluded = ["cancelLabel", "editAlwaysVisible", "editLabel", "id", "inheritTypography", "invalid", "invalidLabel", "invalidText", "labelText", "onCancel", "onChange", "onSave", "onBlur", "saveLabel", "size", "tooltipAlignment", "value"];
19
19
  var componentName = 'EditInPlace';
20
20
  var blockClass = "".concat(pkg.prefix, "--edit-in-place");
21
21
  var defaults = {
@@ -36,6 +36,7 @@ var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
36
36
  onCancel = _ref.onCancel,
37
37
  onChange = _ref.onChange,
38
38
  onSave = _ref.onSave,
39
+ onBlur = _ref.onBlur,
39
40
  saveLabel = _ref.saveLabel,
40
41
  _ref$size = _ref.size,
41
42
  size = _ref$size === void 0 ? 'sm' : _ref$size,
@@ -103,15 +104,21 @@ var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
103
104
  onCancel(initialValue);
104
105
  };
105
106
  var onBlurHandler = function onBlurHandler(e) {
106
- // if (readOnly || escaping.current) {
107
- if (escaping.current) {
108
- return;
109
- }
110
- if (!isTargetingChild(e)) {
111
- if (canSave) {
112
- onSaveHandler();
113
- } else {
114
- onCancelHandler();
107
+ // Use custom function provided if passed through
108
+ if (typeof onBlur === 'function' && !isTargetingChild(e)) {
109
+ onBlur(initialValue);
110
+ setFocused(false);
111
+ } else {
112
+ // Use Default behavior if no custom function provided
113
+ if (escaping.current) {
114
+ return;
115
+ }
116
+ if (!isTargetingChild(e)) {
117
+ if (canSave) {
118
+ onSaveHandler();
119
+ } else {
120
+ onCancelHandler();
121
+ }
115
122
  }
116
123
  }
117
124
  };
@@ -251,6 +258,10 @@ EditInPlace.propTypes = _objectSpread2({
251
258
  * Provide the text that will be read by a screen reader when visiting this control
252
259
  */
253
260
  labelText: PropTypes.string.isRequired,
261
+ /**
262
+ * handler to add custom onBlur event
263
+ */
264
+ onBlur: PropTypes.func,
254
265
  /**
255
266
  * 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
256
267
  */
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { useRef } from 'react';
8
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import React__default, { useState, useEffect, useRef } from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
12
12
  import { pkg } from '../../settings.js';
@@ -51,11 +51,20 @@ var NavItem = function NavItem(_ref) {
51
51
  _ref$tabIndex = _ref.tabIndex,
52
52
  tabIndex = _ref$tabIndex === void 0 ? defaults.tabIndex : _ref$tabIndex,
53
53
  rest = _objectWithoutProperties(_ref, _excluded);
54
+ var _useState = useState(false),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ hrefHasDifferentHost = _useState2[0],
57
+ setHrefHasDifferentHost = _useState2[1];
58
+ useEffect(function () {
59
+ if (href.indexOf(window.location.host) === -1) {
60
+ setHrefHasDifferentHost(true);
61
+ }
62
+ }, [href]);
54
63
  var internalId = useRef(uuidv4());
55
64
  var instanceId = "".concat(blockClass, "__").concat(internalId.current);
56
65
  var navItemId = id || instanceId;
57
66
  var isAbsoluteLink = new RegExp('^([a-z]+://|//)', 'i');
58
- var externalLink = isAbsoluteLink.test(href) && href.indexOf(window.location.host) === -1;
67
+ var externalLink = isAbsoluteLink.test(href) && hrefHasDifferentHost;
59
68
  var linkClassName = "".concat(blockClass, "__link");
60
69
  var handleDisabled = function handleDisabled(action) {
61
70
  var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -15,6 +15,7 @@ import { pkg } from '../../settings.js';
15
15
  import { Toggle, Layer } from '@carbon/react';
16
16
  import { ChevronDown, Locked, WarningFilled, WarningAltFilled } from '@carbon/react/icons';
17
17
  import * as carbonMotion from '@carbon/motion';
18
+ import usePrefersReducedMotion from '../../global/js/hooks/usePrefersReducedMotion.js';
18
19
  import { useControllableState } from '../../global/js/hooks/useControllableState.js';
19
20
 
20
21
  var _Locked;
@@ -71,9 +72,7 @@ var OptionsTile = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
71
72
  var isInvalid = invalid;
72
73
  var isWarn = !isInvalid && warn;
73
74
  var isLocked = !isInvalid && !isWarn && locked;
74
- var reducedMotion = window && window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
75
- matches: true
76
- };
75
+ var shouldReduceMotion = usePrefersReducedMotion();
77
76
  if (open !== prevIsOpen) {
78
77
  if (isOpen && !open) {
79
78
  collapse();
@@ -83,7 +82,7 @@ var OptionsTile = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
83
82
  setPrevIsOpen(open);
84
83
  }
85
84
  function expand() {
86
- if (detailsRef.current && contentRef.current && !reducedMotion.matches) {
85
+ if (detailsRef.current && contentRef.current && !shouldReduceMotion) {
87
86
  setIsOpen(true);
88
87
  detailsRef.current.open = true;
89
88
  var _getComputedStyle = getComputedStyle(contentRef.current),
@@ -112,7 +111,7 @@ var OptionsTile = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
112
111
  }
113
112
  }
114
113
  function collapse() {
115
- if (contentRef.current && !reducedMotion.matches) {
114
+ if (contentRef.current && !shouldReduceMotion) {
116
115
  setClosing(true);
117
116
  var _getComputedStyle2 = getComputedStyle(contentRef.current),
118
117
  paddingTop = _getComputedStyle2.paddingTop,
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, useRef, useEffect, useCallback } from 'react';
10
- import { motion, useReducedMotion, AnimatePresence } from 'framer-motion';
10
+ import { motion, AnimatePresence } from 'framer-motion';
11
11
  import PropTypes from '../../node_modules/prop-types/index.js';
12
12
  import cx from 'classnames';
13
13
  import { moderate02 } from '@carbon/motion';
@@ -19,6 +19,7 @@ import { Button, IconButton } from '@carbon/react';
19
19
  import { ArrowLeft, Close } from '@carbon/react/icons';
20
20
  import { actionSetVariants, overlayVariants, panelVariants } from './motion/variants.js';
21
21
  import pconsole from '../../global/js/utils/pconsole.js';
22
+ import usePrefersReducedMotion from '../../global/js/hooks/usePrefersReducedMotion.js';
22
23
  import { ActionSet } from '../ActionSet/ActionSet.js';
23
24
  import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
24
25
  import { useFocus } from '../../global/js/hooks/useFocus.js';
@@ -44,7 +45,6 @@ var defaults = {
44
45
  * Side panels keep users in-context of a page while performing tasks like navigating, editing, viewing details, or configuring something new.
45
46
  */
46
47
  var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
47
- var _window;
48
48
  var actionToolbarButtons = _ref.actionToolbarButtons,
49
49
  actions = _ref.actions,
50
50
  _ref$animateTitle = _ref.animateTitle,
@@ -111,7 +111,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
111
111
  keyDownListener = _useFocus.keyDownListener;
112
112
  var panelRefValue = sidePanelRef.current;
113
113
  var previousOpen = usePreviousValue(open);
114
- var shouldReduceMotion = useReducedMotion();
114
+ var shouldReduceMotion = usePrefersReducedMotion();
115
115
 
116
116
  // Title animation on scroll related state
117
117
  var _useState7 = useState(0),
@@ -154,9 +154,6 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
154
154
  titleItemsStyles(animationProgress);
155
155
  }
156
156
  }, [doAnimateTitle, panelRefValue === null || panelRefValue === void 0 ? void 0 : panelRefValue.style, scrollAnimationDistance, titleItemsStyles]);
157
- var reducedMotion = typeof document !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : {
158
- matches: true
159
- };
160
157
 
161
158
  // scroll panel to top going between steps
162
159
  useEffect(function () {
@@ -193,7 +190,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
193
190
  }, [launcherButtonRef, open, previousOpen]);
194
191
  var checkSetDoAnimateTitle = function checkSetDoAnimateTitle() {
195
192
  var canDoAnimateTitle = false;
196
- if (panelRefValue && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !reducedMotion.matches) {
193
+ if (panelRefValue && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !shouldReduceMotion) {
197
194
  var _labelTextRef$current3, _labelTextRef$current4, _subtitleRef$current$, _subtitleRef$current;
198
195
  var titleEl = titleRef.current;
199
196
  var labelHeight = (_labelTextRef$current3 = labelTextRef === null || labelTextRef === void 0 || (_labelTextRef$current4 = labelTextRef.current) === null || _labelTextRef$current4 === void 0 ? void 0 : _labelTextRef$current4.offsetHeight) !== null && _labelTextRef$current3 !== void 0 ? _labelTextRef$current3 : 0;
@@ -209,8 +206,8 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
209
206
  panelRefValue === null || panelRefValue === void 0 || panelRefValue.style.setProperty("--".concat(blockClass, "--scroll-animation-distance"), _scrollAnimationDistance.toString());
210
207
  var scrollEl = innerContentRef.current;
211
208
  if (scrollEl) {
212
- var _window2;
213
- var innerComputed = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.getComputedStyle(innerContentRef.current);
209
+ var _window;
210
+ var innerComputed = (_window = window) === null || _window === void 0 ? void 0 : _window.getComputedStyle(innerContentRef.current);
214
211
  var innerPaddingHeight = innerComputed ? parseFloat(innerComputed === null || innerComputed === void 0 ? void 0 : innerComputed.paddingTop) + parseFloat(innerComputed === null || innerComputed === void 0 ? void 0 : innerComputed.paddingBottom) : 0;
215
212
  canDoAnimateTitle = (!!labelText || !!actionToolbarButtons || !!subtitle) && scrollEl.scrollHeight - scrollEl.clientHeight >= _scrollAnimationDistance + innerPaddingHeight;
216
213
  }
@@ -228,12 +225,12 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
228
225
 
229
226
  // Calculate scroll distances
230
227
  useEffect(function () {
231
- if (panelRefValue && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !reducedMotion.matches) {
228
+ if (panelRefValue && open && animateTitle && animationComplete && titleRef !== null && titleRef !== void 0 && titleRef.current && title && title.length && !shouldReduceMotion) {
232
229
  checkSetDoAnimateTitle();
233
230
  }
234
231
 
235
232
  // eslint-disable-next-line react-hooks/exhaustive-deps
236
- }, [open, doAnimateTitle /* use do instead of animateTitle directly */, animationComplete, handleScroll, title, size, reducedMotion.matches, id]);
233
+ }, [open, doAnimateTitle /* use do instead of animateTitle directly */, animationComplete, handleScroll, title, size, shouldReduceMotion, id]);
237
234
 
238
235
  // click outside functionality if `includeOverlay` prop is set
239
236
  useEffect(function () {
@@ -269,10 +266,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
269
266
  // Set the internal state `animationComplete` to true if
270
267
  // prefers reduced motion is true
271
268
  useEffect(function () {
272
- if (reducedMotion.matches) {
269
+ if (shouldReduceMotion) {
273
270
  setAnimationComplete(true);
274
271
  }
275
- }, [reducedMotion.matches]);
272
+ }, [shouldReduceMotion]);
276
273
 
277
274
  // initializes the side panel to open
278
275
  var onAnimationStart = function onAnimationStart() {
@@ -291,10 +288,10 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
291
288
  }
292
289
  }, [open, placement, selectorPageContent, slideIn]);
293
290
  useEffect(function () {
294
- if (!open && previousState && previousState['open'] && reducedMotion.matches) {
291
+ if (!open && previousState && previousState['open'] && shouldReduceMotion) {
295
292
  onUnmount === null || onUnmount === void 0 || onUnmount();
296
293
  }
297
- }, [open, onUnmount, reducedMotion.matches, previousState]);
294
+ }, [open, onUnmount, shouldReduceMotion, previousState]);
298
295
 
299
296
  // used to set margins of content for slide in panel version
300
297
  useEffect(function () {
@@ -307,15 +304,15 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
307
304
  }
308
305
  if (placement && placement === 'right' && pageContentElement) {
309
306
  pageContentElement.style.marginInlineEnd = '0';
310
- pageContentElement.style.transition = !reducedMotion.matches ? "margin-inline-end ".concat(moderate02) : '';
307
+ pageContentElement.style.transition = !shouldReduceMotion ? "margin-inline-end ".concat(moderate02) : '';
311
308
  pageContentElement.style.marginInlineEnd = SIDE_PANEL_SIZES[size];
312
309
  } else if (pageContentElement) {
313
310
  pageContentElement.style.marginInlineStart = '0';
314
- pageContentElement.style.transition = !reducedMotion.matches ? "margin-inline-start ".concat(moderate02) : '';
311
+ pageContentElement.style.transition = !shouldReduceMotion ? "margin-inline-start ".concat(moderate02) : '';
315
312
  pageContentElement.style.marginInlineStart = SIDE_PANEL_SIZES[size];
316
313
  }
317
314
  }
318
- }, [slideIn, selectorPageContent, placement, size, reducedMotion.matches, open]);
315
+ }, [slideIn, selectorPageContent, placement, size, shouldReduceMotion, open]);
319
316
  useEffect(function () {
320
317
  if (open) {
321
318
  setTimeout(function () {
@@ -341,7 +338,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
341
338
  className: "".concat(blockClass, "__title-text"),
342
339
  title: title,
343
340
  "aria-hidden": false
344
- }, title), doAnimateTitle && !reducedMotion.matches && /*#__PURE__*/React__default.createElement("h2", {
341
+ }, title), doAnimateTitle && !shouldReduceMotion && /*#__PURE__*/React__default.createElement("h2", {
345
342
  className: "".concat(blockClass, "__collapsed-title-text"),
346
343
  title: title,
347
344
  "aria-hidden": true
@@ -358,7 +355,7 @@ var SidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
358
355
  });
359
356
  }
360
357
  return /*#__PURE__*/React__default.createElement("div", {
361
- className: cx("".concat(blockClass, "__header"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__header--on-detail-step"), currentStep > 0), "".concat(blockClass, "__header--no-title-animation"), !animateTitle), "".concat(blockClass, "__header--reduced-motion"), reducedMotion.matches), "".concat(blockClass, "__header--has-title"), title)),
358
+ className: cx("".concat(blockClass, "__header"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(blockClass, "__header--on-detail-step"), currentStep > 0), "".concat(blockClass, "__header--no-title-animation"), !animateTitle), "".concat(blockClass, "__header--reduced-motion"), shouldReduceMotion), "".concat(blockClass, "__header--has-title"), title)),
362
359
  ref: headerRef
363
360
  }, currentStep > 0 && /*#__PURE__*/React__default.createElement(Button, {
364
361
  "aria-label": navigationBackIconDescription,
@@ -16,15 +16,13 @@ export namespace overlayVariants {
16
16
  }
17
17
  }
18
18
  export namespace panelVariants {
19
- export function visible_1({ shouldReduceMotion }: {
20
- shouldReduceMotion: any;
21
- }): {
19
+ export function visible_1(): {
22
20
  x: number;
23
21
  transition: {
24
22
  duration: number;
25
23
  ease: number[];
26
24
  };
27
- opacity: any;
25
+ opacity: number;
28
26
  };
29
27
  export { visible_1 as visible };
30
28
  export function hidden_1({ placement, shouldReduceMotion }: {
@@ -32,7 +30,7 @@ export namespace panelVariants {
32
30
  shouldReduceMotion: any;
33
31
  }): {
34
32
  x: string | number;
35
- opacity: any;
33
+ opacity: number;
36
34
  };
37
35
  export { hidden_1 as hidden };
38
36
  export function exit_1({ placement, shouldReduceMotion }: {
@@ -44,7 +42,7 @@ export namespace panelVariants {
44
42
  duration: number;
45
43
  ease: number[];
46
44
  };
47
- opacity: any;
45
+ opacity: number;
48
46
  };
49
47
  export { exit_1 as exit };
50
48
  }