@carbon/ibm-products 2.79.0-rc.0 → 2.80.0-rc.0

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 (142) hide show
  1. package/css/carbon.css +39 -19
  2. package/css/carbon.css.map +1 -1
  3. package/css/index-full-carbon.css +186 -80
  4. package/css/index-full-carbon.css.map +1 -1
  5. package/css/index-full-carbon.min.css +1 -1
  6. package/css/index-full-carbon.min.css.map +1 -1
  7. package/css/index-without-carbon-released-only.css +147 -61
  8. package/css/index-without-carbon-released-only.css.map +1 -1
  9. package/css/index-without-carbon-released-only.min.css +1 -1
  10. package/css/index-without-carbon-released-only.min.css.map +1 -1
  11. package/css/index-without-carbon.css +147 -61
  12. package/css/index-without-carbon.css.map +1 -1
  13. package/css/index-without-carbon.min.css +1 -1
  14. package/css/index-without-carbon.min.css.map +1 -1
  15. package/css/index.css +150 -66
  16. package/css/index.css.map +1 -1
  17. package/css/index.min.css +1 -1
  18. package/css/index.min.css.map +1 -1
  19. package/es/components/Coachmark/Coachmark.d.ts +2 -1
  20. package/es/components/Coachmark/Coachmark.js +6 -0
  21. package/es/components/Coachmark/CoachmarkDragbar.d.ts +2 -1
  22. package/es/components/Coachmark/CoachmarkDragbar.js +7 -0
  23. package/es/components/Coachmark/CoachmarkHeader.d.ts +2 -1
  24. package/es/components/Coachmark/CoachmarkHeader.js +7 -0
  25. package/es/components/Coachmark/CoachmarkOverlay.d.ts +2 -1
  26. package/es/components/Coachmark/CoachmarkOverlay.js +1 -0
  27. package/es/components/Coachmark/CoachmarkTagline.d.ts +2 -1
  28. package/es/components/Coachmark/CoachmarkTagline.js +7 -0
  29. package/es/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +3 -2
  30. package/es/components/Coachmark/utils/hooks.js +4 -3
  31. package/es/components/CoachmarkBeacon/CoachmarkBeacon.d.ts +2 -1
  32. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +7 -0
  33. package/es/components/CoachmarkButton/CoachmarkButton.d.ts +2 -1
  34. package/es/components/CoachmarkButton/CoachmarkButton.js +1 -0
  35. package/es/components/CoachmarkFixed/CoachmarkFixed.d.ts +1 -0
  36. package/es/components/CoachmarkFixed/CoachmarkFixed.js +7 -0
  37. package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +2 -1
  38. package/es/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +1 -0
  39. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +2 -1
  40. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +1 -0
  41. package/es/components/CoachmarkStack/CoachmarkStack.d.ts +2 -1
  42. package/es/components/CoachmarkStack/CoachmarkStack.js +7 -0
  43. package/es/components/CreateFullPage/CreateFullPage.js +1 -1
  44. package/es/components/CreateTearsheet/CreateTearsheet.js +2 -2
  45. package/es/components/CreateTearsheet/CreateTearsheetStep.js +2 -21
  46. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +3 -2
  47. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +3 -2
  48. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +4 -0
  49. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +2 -1
  50. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +2 -1
  51. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.d.ts +1 -1
  52. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +6 -1
  53. package/es/components/Datagrid/useResizeTable.js +2 -2
  54. package/es/components/Datagrid/useSelectRows.js +3 -2
  55. package/es/components/Datagrid/useStickyColumn.js +3 -2
  56. package/es/components/PageHeader/next/PageHeader.js +4 -3
  57. package/es/components/ScrollGradient/constants.js +3 -2
  58. package/es/components/Tearsheet/TearsheetShell.js +4 -6
  59. package/es/components/Tearsheet/next/StackContext.d.ts +21 -0
  60. package/es/components/Tearsheet/next/StackContext.js +94 -0
  61. package/es/components/Tearsheet/next/Tearsheet.d.ts +13 -2
  62. package/es/components/Tearsheet/next/Tearsheet.js +46 -10
  63. package/es/components/Tearsheet/next/TearsheetBody.d.ts +6 -0
  64. package/es/components/Tearsheet/next/TearsheetBody.js +19 -7
  65. package/es/components/Tearsheet/next/TearsheetHeaderActions.js +9 -4
  66. package/es/components/Tearsheet/next/TearsheetHeaderContent.d.ts +22 -8
  67. package/es/components/Tearsheet/next/TearsheetHeaderContent.js +14 -27
  68. package/es/components/Tearsheet/next/_story-assets/StepTearsheet.d.ts +3 -2
  69. package/es/components/Tearsheet/next/index.d.ts +2 -0
  70. package/es/components/index.d.ts +2 -1
  71. package/es/global/js/hooks/useCreateComponentFocus.js +34 -4
  72. package/es/global/js/hooks/useIsomorphicEffect.d.ts +7 -1
  73. package/es/global/js/hooks/useIsomorphicEffect.js +1 -2
  74. package/es/global/js/hooks/useResizeObserver.js +4 -3
  75. package/es/global/js/hooks/useWindowResize.js +3 -2
  76. package/es/global/js/hooks/useWindowScroll.js +3 -2
  77. package/es/index.js +2 -2
  78. package/lib/components/Coachmark/Coachmark.d.ts +2 -1
  79. package/lib/components/Coachmark/Coachmark.js +6 -0
  80. package/lib/components/Coachmark/CoachmarkDragbar.d.ts +2 -1
  81. package/lib/components/Coachmark/CoachmarkDragbar.js +7 -0
  82. package/lib/components/Coachmark/CoachmarkHeader.d.ts +2 -1
  83. package/lib/components/Coachmark/CoachmarkHeader.js +7 -0
  84. package/lib/components/Coachmark/CoachmarkOverlay.d.ts +2 -1
  85. package/lib/components/Coachmark/CoachmarkOverlay.js +1 -0
  86. package/lib/components/Coachmark/CoachmarkTagline.d.ts +2 -1
  87. package/lib/components/Coachmark/CoachmarkTagline.js +7 -0
  88. package/lib/components/Coachmark/next/Coachmark/CoachmarkBubble/CoachmarkBubble.js +2 -1
  89. package/lib/components/Coachmark/utils/hooks.js +3 -2
  90. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.d.ts +2 -1
  91. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +7 -0
  92. package/lib/components/CoachmarkButton/CoachmarkButton.d.ts +2 -1
  93. package/lib/components/CoachmarkButton/CoachmarkButton.js +1 -0
  94. package/lib/components/CoachmarkFixed/CoachmarkFixed.d.ts +1 -0
  95. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +7 -0
  96. package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.d.ts +2 -1
  97. package/lib/components/CoachmarkOverlayElement/CoachmarkOverlayElement.js +1 -0
  98. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.d.ts +2 -1
  99. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +1 -0
  100. package/lib/components/CoachmarkStack/CoachmarkStack.d.ts +2 -1
  101. package/lib/components/CoachmarkStack/CoachmarkStack.js +7 -0
  102. package/lib/components/CreateFullPage/CreateFullPage.js +1 -1
  103. package/lib/components/CreateTearsheet/CreateTearsheet.js +2 -2
  104. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +2 -21
  105. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +2 -1
  106. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -1
  107. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +4 -0
  108. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +2 -1
  109. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +2 -1
  110. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.d.ts +1 -1
  111. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +6 -1
  112. package/lib/components/Datagrid/useResizeTable.js +2 -2
  113. package/lib/components/Datagrid/useSelectRows.js +2 -1
  114. package/lib/components/Datagrid/useStickyColumn.js +2 -1
  115. package/lib/components/PageHeader/next/PageHeader.js +3 -2
  116. package/lib/components/ScrollGradient/constants.js +2 -1
  117. package/lib/components/Tearsheet/TearsheetShell.js +3 -5
  118. package/lib/components/Tearsheet/next/StackContext.d.ts +21 -0
  119. package/lib/components/Tearsheet/next/StackContext.js +97 -0
  120. package/lib/components/Tearsheet/next/Tearsheet.d.ts +13 -2
  121. package/lib/components/Tearsheet/next/Tearsheet.js +44 -8
  122. package/lib/components/Tearsheet/next/TearsheetBody.d.ts +6 -0
  123. package/lib/components/Tearsheet/next/TearsheetBody.js +19 -7
  124. package/lib/components/Tearsheet/next/TearsheetHeaderActions.js +8 -3
  125. package/lib/components/Tearsheet/next/TearsheetHeaderContent.d.ts +22 -8
  126. package/lib/components/Tearsheet/next/TearsheetHeaderContent.js +12 -25
  127. package/lib/components/Tearsheet/next/_story-assets/StepTearsheet.d.ts +3 -2
  128. package/lib/components/Tearsheet/next/index.d.ts +2 -0
  129. package/lib/components/index.d.ts +2 -1
  130. package/lib/global/js/hooks/useCreateComponentFocus.js +34 -4
  131. package/lib/global/js/hooks/useIsomorphicEffect.d.ts +7 -1
  132. package/lib/global/js/hooks/useIsomorphicEffect.js +1 -2
  133. package/lib/global/js/hooks/useResizeObserver.js +3 -2
  134. package/lib/global/js/hooks/useWindowResize.js +2 -1
  135. package/lib/global/js/hooks/useWindowScroll.js +2 -1
  136. package/lib/index.js +15 -13
  137. package/package.json +14 -14
  138. package/scss/components/Tearsheet/_tearsheet.scss +11 -6
  139. package/scss/components/Tearsheet/_tearsheet_next.scss +218 -96
  140. package/telemetry.yml +11 -7
  141. package/es/components/Tearsheet/next/index.js +0 -8
  142. package/lib/components/Tearsheet/next/index.js +0 -14
@@ -93,7 +93,8 @@ const FilterFlyout = _ref => {
93
93
  const [shouldDisableButtons, setShouldDisableButtons] = useShouldDisableButtons.default({
94
94
  initialValue: true,
95
95
  filtersState,
96
- prevFiltersRef
96
+ prevFiltersRef,
97
+ open
97
98
  });
98
99
 
99
100
  // Skip resize testing
@@ -101,7 +101,8 @@ const FilterPanel = _ref => {
101
101
  const [shouldDisableButtons, setShouldDisableButtons] = useShouldDisableButtons.default({
102
102
  initialValue: true,
103
103
  filtersState,
104
- prevFiltersRef
104
+ prevFiltersRef,
105
+ open: panelOpen
105
106
  });
106
107
  const shouldReduceMotion = usePrefersReducedMotion.usePrefersReducedMotion();
107
108
  const exitAnimationName = shouldReduceMotion ? 'filter-panel-exit-reduced' : 'filter-panel-exit-left';
@@ -6,4 +6,4 @@ export default useShouldDisableButtons;
6
6
  * @param {object} prevFiltersRef - reference of the prev filterState
7
7
  * @returns {Array} returns a tuple of the state and setter function
8
8
  */
9
- declare function useShouldDisableButtons({ initialValue, filtersState, prevFiltersRef, }: string): any[];
9
+ declare function useShouldDisableButtons({ initialValue, filtersState, prevFiltersRef, open, }: string): any[];
@@ -27,10 +27,15 @@ const useShouldDisableButtons = _ref => {
27
27
  initialValue,
28
28
  // initially the buttons should be disabled
29
29
  filtersState,
30
- prevFiltersRef
30
+ prevFiltersRef,
31
+ open
31
32
  } = _ref;
32
33
  const [shouldDisableButtons, setShouldDisableButtons] = React.useState(initialValue);
33
34
  React.useEffect(function updateDisabledButtonsState() {
35
+ // prevent this effect from running when columns are being resized
36
+ if (!open) {
37
+ return;
38
+ }
34
39
  setShouldDisableButtons(deepCompareObject.deepCompareObject(filtersState, JSON.parse(prevFiltersRef.current)));
35
40
  }, [filtersState, prevFiltersRef]);
36
41
  return [shouldDisableButtons, setShouldDisableButtons];
@@ -9,7 +9,7 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var React = require('react');
12
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
13
13
 
14
14
  const useResizeTable = hooks => {
15
15
  const useInstanceBeforeDimensions = instance => {
@@ -18,7 +18,7 @@ const useResizeTable = hooks => {
18
18
  handleResize
19
19
  } = instance;
20
20
  const parent = rootRef && rootRef.current && rootRef.current.parentElement;
21
- React.useLayoutEffect(() => {
21
+ useIsomorphicEffect.useIsomorphicEffect(() => {
22
22
  if (!parent) {
23
23
  return () => {};
24
24
  }
@@ -17,6 +17,7 @@ var DatagridSelectAll = require('./Datagrid/DatagridSelectAll.js');
17
17
  var commonColumnIds = require('./common-column-ids.js');
18
18
  var settings = require('../../settings.js');
19
19
  var stateReducer = require('./Datagrid/addons/stateReducer.js');
20
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
20
21
 
21
22
  const blockClass = `${settings.pkg.prefix}--datagrid`;
22
23
  const checkboxClass = `${settings.pkg.prefix}--datagrid__checkbox-cell`;
@@ -89,7 +90,7 @@ const SelectRow = datagridState => {
89
90
  getRowId
90
91
  } = datagridState;
91
92
  const [windowSize, setWindowSize] = React.useState();
92
- React.useLayoutEffect(() => {
93
+ useIsomorphicEffect.useIsomorphicEffect(() => {
93
94
  setWindowSize(window.innerWidth);
94
95
  function updateSize() {
95
96
  setWindowSize(window.innerWidth);
@@ -13,6 +13,7 @@ var React = require('react');
13
13
  var debounce = require('../../global/js/utils/debounce.js');
14
14
  var cx = require('classnames');
15
15
  var settings = require('../../settings.js');
16
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
16
17
 
17
18
  const blockClass = `${settings.pkg.prefix}--datagrid`;
18
19
  const styleClassPrefix = `${blockClass}__right-sticky-column`;
@@ -25,7 +26,7 @@ const useStickyColumn = hooks => {
25
26
  React.useEffect(() => {
26
27
  setWindowSize(window?.innerWidth);
27
28
  }, []);
28
- React.useLayoutEffect(() => {
29
+ useIsomorphicEffect.useIsomorphicEffect(() => {
29
30
  /* istanbul ignore next */
30
31
  function updateSize() {
31
32
  setWindowSize(window.innerWidth);
@@ -21,6 +21,7 @@ var context = require('./context.js');
21
21
  var utils = require('./utils.js');
22
22
  var settings = require('../../../settings.js');
23
23
  var useResizeObserver = require('../../../global/js/hooks/useResizeObserver.js');
24
+ var useIsomorphicEffect = require('../../../global/js/hooks/useIsomorphicEffect.js');
24
25
 
25
26
  /**
26
27
  * ----------
@@ -250,7 +251,7 @@ const PageHeaderContent = /*#__PURE__*/React.forwardRef(function PageHeaderConte
250
251
  setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
251
252
  return element.offsetHeight < element.scrollHeight;
252
253
  };
253
- React.useLayoutEffect(() => {
254
+ useIsomorphicEffect.useIsomorphicEffect(() => {
254
255
  titleRef.current && isEllipsisActive(titleRef.current);
255
256
  }, [title]);
256
257
  return /*#__PURE__*/React.createElement(react.Section, _rollupPluginBabelHelpers.extends({
@@ -345,7 +346,7 @@ const PageHeaderContentPageActions = _ref4 => {
345
346
 
346
347
  // need to set the grid columns width based on the menu button's width
347
348
  // to avoid overlapping when resizing
348
- React.useLayoutEffect(() => {
349
+ useIsomorphicEffect.useIsomorphicEffect(() => {
349
350
  if (menuButtonVisibility && offsetRef.current) {
350
351
  const width = offsetRef.current.offsetWidth;
351
352
  document.documentElement.style.setProperty('--page-header-title-grid-width', `${width}px`);
@@ -8,6 +8,7 @@
8
8
  'use strict';
9
9
 
10
10
  var React = require('react');
11
+ var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
11
12
 
12
13
  const ScrollStates = {
13
14
  // No scrolling required because content fits within container.
@@ -40,7 +41,7 @@ const useIsOverflow = ref => {
40
41
  }
41
42
  };
42
43
  });
43
- React.useLayoutEffect(() => {
44
+ useIsomorphicEffect.useIsomorphicEffect(() => {
44
45
  const {
45
46
  current
46
47
  } = ref;
@@ -272,18 +272,16 @@ const TearsheetShell = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
272
272
  }),
273
273
  closeModal: onClose,
274
274
  iconDescription: effectiveHasCloseIcon ? closeIconDescription : undefined
275
- }, /*#__PURE__*/React.createElement(Wrap.Wrap, {
275
+ }, /*#__PURE__*/React.createElement(react.Section, {
276
276
  className: `${bc}__header-content`,
277
277
  element: wide ? react.Layer : undefined
278
278
  }, /*#__PURE__*/React.createElement(Wrap.Wrap, {
279
279
  className: `${bc}__header-fields`
280
280
  }, /*#__PURE__*/React.createElement(Wrap.Wrap, {
281
- element: "h2",
282
281
  className: `${bcModalHeader}__label`
283
- }, label), /*#__PURE__*/React.createElement(Wrap.Wrap, {
284
- element: "h3",
282
+ }, label), /*#__PURE__*/React.createElement(react.Section, {
285
283
  className: cx(`${bcModalHeader}__heading`, `${bc}__heading`)
286
- }, title), /*#__PURE__*/React.createElement(Wrap.Wrap, {
284
+ }, /*#__PURE__*/React.createElement(react.Heading, null, title)), /*#__PURE__*/React.createElement(Wrap.Wrap, {
287
285
  className: `${bc}__header-description`
288
286
  }, description)), /*#__PURE__*/React.createElement(Wrap.Wrap, {
289
287
  className: `${bc}__header-actions`
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { ReactNode } from 'react';
8
+ export interface StackContextType {
9
+ stack: string[];
10
+ notifyStack: (id: string, open: boolean, container: HTMLDivElement) => void;
11
+ getScaleFactor: (id: string) => number | null;
12
+ getBlockSizeChange: (id: string) => string | null;
13
+ getDepth: (id: string) => number | null;
14
+ }
15
+ interface StepProviderProps {
16
+ children: ReactNode;
17
+ stackStepSize?: 'sm' | 'md' | 'lg';
18
+ }
19
+ export declare const StackProvider: React.FC<StepProviderProps>;
20
+ export declare const useStackContext: () => StackContextType;
21
+ export {};
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2025
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var useResizeObserver = require('../../../global/js/hooks/useResizeObserver.js');
12
+
13
+ const StackContext = /*#__PURE__*/React.createContext(undefined);
14
+ const StackProvider = _ref => {
15
+ let {
16
+ children,
17
+ stackStepSize = 'lg'
18
+ } = _ref;
19
+ const [stack, setStack] = React.useState([]);
20
+ const _containerRef = React.useRef(null);
21
+ const bufferMap = {
22
+ sm: 0.5,
23
+ md: 0.75,
24
+ lg: 1
25
+ };
26
+ const {
27
+ width
28
+ } = useResizeObserver.useResizeObserver(_containerRef);
29
+
30
+ // this method will register/ unregister tearsheet ids in a simple array based on open status
31
+ const notifyStack = React.useCallback((id, open, container) => {
32
+ _containerRef.current = container;
33
+ setStack(prev => {
34
+ if (open) {
35
+ // move to top if already exists
36
+ if (prev.includes(id)) {
37
+ return [...prev.filter(i => i !== id), id];
38
+ }
39
+ return [...prev, id];
40
+ } else {
41
+ // remove from stack
42
+ return prev.filter(i => i !== id);
43
+ }
44
+ });
45
+ }, []);
46
+
47
+ // method that calculates spacing factor for the stacked items
48
+ const getScaleFactor = id => {
49
+ const depth = getDepth(id);
50
+ const buffer = bufferMap[stackStepSize];
51
+ const bufferInPx = remToPx(buffer);
52
+ const scale = depth > -1 ? (width - bufferInPx * 2 * depth) / width : 1;
53
+ return scale;
54
+ };
55
+ const remToPx = rem => {
56
+ return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
57
+ };
58
+ const getDepth = React.useCallback(id => {
59
+ const index = stack.indexOf(id);
60
+ if (index === -1) {
61
+ return -1;
62
+ }
63
+ return stack.length - 1 - index; // topmost → 0
64
+ }, [stack]);
65
+ const getBlockSizeChange = id => {
66
+ const depth = getDepth(id);
67
+ const buffer = bufferMap[stackStepSize]; //to be changed
68
+ const bufferInPx = remToPx(buffer);
69
+ return `${bufferInPx * depth}px`;
70
+ };
71
+ const context = {
72
+ stack,
73
+ notifyStack,
74
+ getScaleFactor,
75
+ getBlockSizeChange,
76
+ getDepth
77
+ };
78
+ return /*#__PURE__*/React.createElement(StackContext.Provider, {
79
+ value: context
80
+ }, children);
81
+ };
82
+ const useStackContext = () => {
83
+ const context = React.useContext(StackContext);
84
+ if (context === undefined) {
85
+ return {
86
+ notifyStack: () => {},
87
+ stack: [],
88
+ getDepth: () => -1,
89
+ getScaleFactor: () => 1,
90
+ getBlockSizeChange: () => null
91
+ };
92
+ }
93
+ return context;
94
+ };
95
+
96
+ exports.StackProvider = StackProvider;
97
+ exports.useStackContext = useStackContext;
@@ -16,13 +16,24 @@ import { TearsheetHeaderActionItemProps, TearsheetHeaderActionsProps } from './T
16
16
  * Tearsheet
17
17
  * ----------
18
18
  */
19
- export interface TearsheetProps {
19
+ export interface TearsheetProps extends ComposedModalProps {
20
20
  children?: React.ReactNode;
21
21
  /**
22
22
  * Specifies whether the tearsheet is currently open.
23
23
  */
24
24
  open?: boolean;
25
+ /**
26
+ * User can pass any class names to add to the modal wrapper
27
+ */
25
28
  className?: string;
29
+ /**
30
+ * User can pass any class names that will added to the modal container, rather than the wrapper
31
+ */
32
+ containerClassName?: string;
33
+ /**
34
+ * the defines the gap from top of the view port. Defaulted to 3rem
35
+ */
36
+ verticalGap?: string;
26
37
  /**
27
38
  * Default influencer takes 256px, this allow to override eg: 300px , 20rem
28
39
  */
@@ -77,7 +88,7 @@ export type TearsheetComponentType = React.ForwardRefExoticComponent<TearsheetPr
77
88
  SummaryContent: FC<SummaryContentProps>;
78
89
  Body: FC<TearsheetBodyProps>;
79
90
  Footer: FC<FooterProps>;
80
- } & ComposedModalProps;
91
+ };
81
92
  export declare const Tearsheet: TearsheetComponentType;
82
93
  export interface FooterProps {
83
94
  children: ReactNode;
@@ -18,7 +18,10 @@ var TearsheetBody = require('./TearsheetBody.js');
18
18
  var TearsheetHeaderActions = require('./TearsheetHeaderActions.js');
19
19
  var layout = require('@carbon/layout');
20
20
  var usePortalTarget = require('../../../global/js/hooks/usePortalTarget.js');
21
+ var StackContext = require('./StackContext.js');
21
22
  var useMatchMedia = require('../../../global/js/hooks/useMatchMedia.js');
23
+ var useId = require('../../../global/js/utils/useId.js');
24
+ var useIsomorphicEffect = require('../../../global/js/hooks/useIsomorphicEffect.js');
22
25
 
23
26
  /**
24
27
  * ----------
@@ -37,13 +40,15 @@ const Tearsheet = /*#__PURE__*/React.forwardRef((_ref, ref) => {
37
40
  ariaLabel,
38
41
  onClose,
39
42
  selectorPrimaryFocus,
40
- open,
43
+ open = false,
41
44
  portalTarget,
45
+ verticalGap,
46
+ containerClassName,
42
47
  ...rest
43
48
  } = _ref;
44
49
  const carbonPrefix = react.usePrefix();
45
50
  const localRef = React.useRef(undefined);
46
- const bodyRef = React.useRef(undefined);
51
+ const bodyRef = React.useRef(null);
47
52
  const modalRef = ref || localRef;
48
53
  const smMediaQuery = `(max-width: ${layout.breakpoints.md.width})`;
49
54
  const isSm = useMatchMedia.useMatchMedia(smMediaQuery) || variant === 'narrow';
@@ -55,8 +60,17 @@ const Tearsheet = /*#__PURE__*/React.forwardRef((_ref, ref) => {
55
60
  const influencer = arr.find(child => child.type === TearsheetBody.Influencer);
56
61
  const body = arr.find(child => child.type === TearsheetBody.default);
57
62
  const footer = arr.find(child => child.type === Footer);
63
+ const uniqueId = React.useRef(useId.useId());
64
+ const {
65
+ notifyStack,
66
+ stack,
67
+ getDepth,
68
+ getScaleFactor,
69
+ getBlockSizeChange
70
+ } = StackContext.useStackContext();
71
+ const [depth, setDepth] = React.useState(0);
58
72
  const renderPortalUse = usePortalTarget.usePortalTarget(portalTarget);
59
- React.useLayoutEffect(() => {
73
+ useIsomorphicEffect.useIsomorphicEffect(() => {
60
74
  const AILabelWidth = modalRef.current?.querySelector(`.${carbonPrefix}--ai-label`)?.clientWidth ?? 0;
61
75
  const headerActionMarginRight = AILabelWidth + 24 + (isSm ? 8 : 0); // 24 is to compeNsate for close button
62
76
  document.documentElement.style.setProperty('--tearsheet-header-action-offset', `${headerActionMarginRight}px`);
@@ -66,9 +80,31 @@ const Tearsheet = /*#__PURE__*/React.forwardRef((_ref, ref) => {
66
80
  if (summaryContentWidth) {
67
81
  document.documentElement.style.setProperty('--tearsheet-summary-content-width', `${summaryContentWidth}`);
68
82
  }
83
+ if (verticalGap) {
84
+ document.documentElement.style.setProperty('--tearsheet-vertical-gap', `${verticalGap}`);
85
+ }
69
86
 
70
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
- }, [isSm]);
88
+ }, [isSm, rest.decorator, influencerWidth, summaryContentWidth, verticalGap]);
89
+ useIsomorphicEffect.useIsomorphicEffect(() => {
90
+ if (bodyRef.current) {
91
+ notifyStack?.(uniqueId.current, open, bodyRef.current);
92
+ }
93
+
94
+ // eslint-disable-next-line react-hooks/exhaustive-deps
95
+ }, [open]);
96
+ React.useEffect(() => {
97
+ if (stack?.length > 0) {
98
+ const stackDepth = getDepth?.(uniqueId.current),
99
+ blockSizeChange = getBlockSizeChange?.(uniqueId.current),
100
+ scaleFactor = getScaleFactor?.(uniqueId.current);
101
+ setDepth(stackDepth);
102
+ modalRef.current.style.setProperty('--stack-depth', stackDepth + '');
103
+ modalRef.current.style.setProperty('--block-size-change', blockSizeChange);
104
+ modalRef.current.style.setProperty('--scale-factor', scaleFactor + '');
105
+ }
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ }, [stack]);
72
108
  return renderPortalUse(/*#__PURE__*/React.createElement(context.TearsheetContext.Provider, {
73
109
  value: {
74
110
  hasCloseIcon,
@@ -88,11 +124,13 @@ const Tearsheet = /*#__PURE__*/React.forwardRef((_ref, ref) => {
88
124
  className: cx(context.blockClass, className, {
89
125
  [`${context.blockClass}--wide`]: variant === 'wide',
90
126
  [`${context.blockClass}--narrow`]: variant === 'narrow',
127
+ [`${context.blockClass}--stacked`]: depth > 0,
128
+ [`${context.blockClass}--stack-activated`]: stack.length > 1,
91
129
  [`${context.blockClass}--has-ai-label`]: !!rest.decorator && rest.decorator['type']?.displayName === 'AILabel',
92
130
  [`${context.blockClass}--has-decorator`]: !!rest.decorator && rest.decorator['type']?.displayName !== 'AILabel',
93
131
  [`${context.blockClass}--has-close`]: hasCloseIcon
94
132
  }),
95
- containerClassName: cx(`${context.blockClass}__container`, {}),
133
+ containerClassName: cx(`${context.blockClass}__container`, containerClassName),
96
134
  onClose,
97
135
  open,
98
136
  selectorPrimaryFocus,
@@ -109,9 +147,7 @@ const Footer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
109
147
  let {
110
148
  children
111
149
  } = _ref2;
112
- return /*#__PURE__*/React.createElement(react.Layer, {
113
- as: "footer",
114
- withBackground: true,
150
+ return /*#__PURE__*/React.createElement("footer", {
115
151
  className: `${context.blockClass}__footer`,
116
152
  ref: ref
117
153
  }, children);
@@ -24,6 +24,8 @@ declare const TearsheetBody: React.ForwardRefExoticComponent<TearsheetBodyProps
24
24
  export interface MainContentProps {
25
25
  children: ReactNode;
26
26
  className?: string;
27
+ /** this can be set take full width without any padding */
28
+ isFlush?: boolean;
27
29
  }
28
30
  /**
29
31
  * ----------------
@@ -48,6 +50,8 @@ export interface SummaryContentProps {
48
50
  * This handler closes the modal, e.g. changing `open` prop.
49
51
  */
50
52
  onSummaryPanelClose?(): void;
53
+ /** this can be set take full width without any padding */
54
+ isFlush?: boolean;
51
55
  }
52
56
  export declare const SummaryContent: React.ForwardRefExoticComponent<SummaryContentProps & React.RefAttributes<HTMLDivElement>>;
53
57
  export interface InfluencerProps {
@@ -62,6 +66,8 @@ export interface InfluencerProps {
62
66
  * This handler closes the modal, e.g. changing `open` prop.
63
67
  */
64
68
  onInfluencerPanelClose?(): void;
69
+ /** this can be set take full width without any padding */
70
+ isFlush?: boolean;
65
71
  }
66
72
  export declare const Influencer: React.ForwardRefExoticComponent<InfluencerProps & React.RefAttributes<HTMLDivElement>>;
67
73
  export default TearsheetBody;
@@ -11,6 +11,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
13
  var React = require('react');
14
+ var cx = require('classnames');
14
15
  var context = require('./context.js');
15
16
  var SidePanel = require('../../SidePanel/SidePanel.js');
16
17
  var react = require('@carbon/react');
@@ -41,6 +42,7 @@ const MainContent = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
41
42
  let {
42
43
  children,
43
44
  className,
45
+ isFlush,
44
46
  ...rest
45
47
  } = _ref2;
46
48
  const localRef = React.useRef(null);
@@ -71,7 +73,9 @@ const MainContent = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
71
73
  });
72
74
  return /*#__PURE__*/React.createElement(react.Layer, _rollupPluginBabelHelpers.extends({
73
75
  withBackground: true,
74
- className: `${context.blockClass}__main-content ${className}`,
76
+ className: cx(`${context.blockClass}__main-content`, className, {
77
+ [`${context.blockClass}__flush`]: isFlush
78
+ }),
75
79
  ref: mainContentRef
76
80
  }, rest), children);
77
81
  });
@@ -87,18 +91,22 @@ const SummaryContent = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
87
91
  children,
88
92
  className,
89
93
  summaryPanelOpen = false,
90
- onSummaryPanelClose
94
+ onSummaryPanelClose,
95
+ isFlush
91
96
  } = _ref3;
92
97
  const {
93
98
  isSm
94
99
  } = React.useContext(context.TearsheetContext);
95
100
  return !isSm ? /*#__PURE__*/React.createElement("div", {
96
- className: `${context.blockClass}__summary-content ${className}`,
101
+ className: cx(`${context.blockClass}__summary-content`, className, {
102
+ [`${context.blockClass}__flush`]: isFlush
103
+ }),
97
104
  ref: ref
98
105
  }, /*#__PURE__*/React.createElement("aside", null, children)) : /*#__PURE__*/React.createElement(SidePanel.SidePanel, {
99
106
  size: "sm",
100
107
  open: summaryPanelOpen,
101
- onRequestClose: onSummaryPanelClose
108
+ onRequestClose: onSummaryPanelClose,
109
+ className: className
102
110
  }, children);
103
111
  });
104
112
  const Influencer = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
@@ -106,19 +114,23 @@ const Influencer = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
106
114
  children,
107
115
  className,
108
116
  influencerPanelOpen = false,
109
- onInfluencerPanelClose
117
+ onInfluencerPanelClose,
118
+ isFlush
110
119
  } = _ref4;
111
120
  const {
112
121
  isSm
113
122
  } = React.useContext(context.TearsheetContext);
114
123
  return !isSm ? /*#__PURE__*/React.createElement("aside", {
115
- className: `${context.blockClass}__influencer ${className}`,
124
+ className: cx(`${context.blockClass}__influencer`, className, {
125
+ [`${context.blockClass}__flush`]: isFlush
126
+ }),
116
127
  ref: ref
117
128
  }, children) : /*#__PURE__*/React.createElement(SidePanel.SidePanel, {
118
129
  size: "sm",
119
130
  open: influencerPanelOpen,
120
131
  onRequestClose: onInfluencerPanelClose,
121
- placement: "left"
132
+ placement: "left",
133
+ className: className
122
134
  }, children);
123
135
  });
124
136
 
@@ -12,6 +12,8 @@ var react = require('@carbon/react');
12
12
  var React = require('react');
13
13
  var context = require('./context.js');
14
14
  var utilities = require('@carbon/utilities');
15
+ var cx = require('classnames');
16
+ var useIsomorphicEffect = require('../../../global/js/hooks/useIsomorphicEffect.js');
15
17
 
16
18
  /**
17
19
  * ----------------
@@ -33,7 +35,7 @@ const TearsheetHeaderActions = _ref => {
33
35
 
34
36
  // need to set the grid columns width based on the menu button's width
35
37
  // to avoid overlapping when resizing
36
- React.useLayoutEffect(() => {
38
+ useIsomorphicEffect.useIsomorphicEffect(() => {
37
39
  if (menuButtonVisibility && offsetRef.current) {
38
40
  const width = offsetRef.current.offsetWidth;
39
41
  document.documentElement.style.setProperty('--tearsheet-header-title-grid-width', `${width}px`);
@@ -45,7 +47,7 @@ const TearsheetHeaderActions = _ref => {
45
47
  }
46
48
  return /*#__PURE__*/React.isValidElement(child);
47
49
  });
48
- React.useLayoutEffect(() => {
50
+ useIsomorphicEffect.useIsomorphicEffect(() => {
49
51
  //Menu button will be rendered only if they pass the items in TearsheetHeaderActionItem
50
52
  if (!containerRef.current || hasOtherChildType.current) {
51
53
  return;
@@ -67,7 +69,10 @@ const TearsheetHeaderActions = _ref => {
67
69
  }, children, !hasOtherChildType.current && /*#__PURE__*/React.createElement("span", {
68
70
  "data-offset": true,
69
71
  "data-hidden": true,
70
- ref: offsetRef
72
+ ref: offsetRef,
73
+ className: cx(`${context.blockClass}__header-actions-menuButton`, {
74
+ [`${context.blockClass}__header-actions-menuButton--hidden`]: hiddenItems.length === 0
75
+ })
71
76
  }, /*#__PURE__*/React.createElement(react.MenuButton, _rollupPluginBabelHelpers.extends({
72
77
  size: "sm"
73
78
  }, menuButtonProps), hiddenItems.map(item => {
@@ -4,21 +4,35 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React from 'react';
8
- import { CarbonIconType } from '@carbon/react/icons';
7
+ import React, { ReactNode } from 'react';
9
8
  export interface TearsheetHeaderContentProps {
10
9
  /**
11
10
  * Provide the optional content for header section and will be render after header titles and before progress indicator.
12
11
  * People can make use of this if they want to have custom header.
13
12
  */
14
13
  children?: React.ReactNode;
14
+ /**
15
+ * The main title of the tearsheet.
16
+ */
15
17
  title: string;
16
- label?: string;
17
- description?: string;
18
- descriptionExpandLabel?: string;
19
- descriptionCollapseLabel?: string;
20
- titleIcon?: CarbonIconType;
21
- titleIconPosition?: 'leading' | 'trailing';
18
+ /**
19
+ * A label for the tearsheet, displayed above the title
20
+ * to maintain context for the tearsheet (e.g. as the title changes from page
21
+ * to page of a multi-page task).
22
+ */
23
+ label?: ReactNode;
24
+ /**
25
+ * A description of the flow, displayed in the header area of the tearsheet.
26
+ */
27
+ description?: ReactNode;
28
+ /**
29
+ * This can be used to render a content just before the title like an icon
30
+ */
31
+ titleStart?: ReactNode;
32
+ /**
33
+ * This can be used to render a content just after the title like an icon
34
+ */
35
+ titleEnd?: ReactNode;
22
36
  /**
23
37
  * The PageHeaderContent's page actions
24
38
  */