@carbon/ibm-products 2.79.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
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { forwardRef, useState, useRef, useEffect, useLayoutEffect, useCallback } from 'react';
9
+ import React__default, { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
10
10
  import PropTypes from '../../../_virtual/index.js';
11
11
  import cx from 'classnames';
12
12
  import { Grid, Column, Section, DefinitionTooltip, unstable_Text, Heading, Popover, PopoverContent, IconButton, BreadcrumbItem, usePrefix, Breadcrumb, MenuButton, MenuItem, AspectRatio } from '@carbon/react';
@@ -19,6 +19,7 @@ import { PageHeaderContext, usePageHeader } from './context.js';
19
19
  import { getHeaderOffset, scrollableAncestor } from './utils.js';
20
20
  import { pkg } from '../../../settings.js';
21
21
  import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver.js';
22
+ import { useIsomorphicEffect } from '../../../global/js/hooks/useIsomorphicEffect.js';
22
23
 
23
24
  /**
24
25
  * ----------
@@ -248,7 +249,7 @@ const PageHeaderContent = /*#__PURE__*/React__default.forwardRef(function PageHe
248
249
  setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
249
250
  return element.offsetHeight < element.scrollHeight;
250
251
  };
251
- useLayoutEffect(() => {
252
+ useIsomorphicEffect(() => {
252
253
  titleRef.current && isEllipsisActive(titleRef.current);
253
254
  }, [title]);
254
255
  return /*#__PURE__*/React__default.createElement(Section, _extends({
@@ -343,7 +344,7 @@ const PageHeaderContentPageActions = _ref4 => {
343
344
 
344
345
  // need to set the grid columns width based on the menu button's width
345
346
  // to avoid overlapping when resizing
346
- useLayoutEffect(() => {
347
+ useIsomorphicEffect(() => {
347
348
  if (menuButtonVisibility && offsetRef.current) {
348
349
  const width = offsetRef.current.offsetWidth;
349
350
  document.documentElement.style.setProperty('--page-header-title-grid-width', `${width}px`);
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { useState, useCallback, useEffect, useLayoutEffect } from 'react';
8
+ import { useState, useCallback, useEffect } from 'react';
9
+ import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
9
10
 
10
11
  const ScrollStates = {
11
12
  // No scrolling required because content fits within container.
@@ -38,7 +39,7 @@ const useIsOverflow = ref => {
38
39
  }
39
40
  };
40
41
  });
41
- useLayoutEffect(() => {
42
+ useIsomorphicEffect(() => {
42
43
  const {
43
44
  current
44
45
  } = ref;
@@ -14,7 +14,7 @@ import { pkg } from '../../settings.js';
14
14
  import pconsole from '../../global/js/utils/pconsole.js';
15
15
  import { getNodeTextContent } from '../../global/js/utils/getNodeTextContent.js';
16
16
  import { deprecateProp } from '../../global/js/utils/props-helper.js';
17
- import { Button, usePrefix, unstable_FeatureFlags, ComposedModal, ModalHeader, Layer, Section } from '@carbon/react';
17
+ import { Button, usePrefix, unstable_FeatureFlags, ComposedModal, ModalHeader, Section, Layer, Heading } from '@carbon/react';
18
18
  import { ActionSet } from '../ActionSet/ActionSet.js';
19
19
  import { Wrap } from '../../global/js/utils/Wrap.js';
20
20
  import { usePortalTarget } from '../../global/js/hooks/usePortalTarget.js';
@@ -270,18 +270,16 @@ const TearsheetShell = /*#__PURE__*/React__default.forwardRef((_ref2, ref) => {
270
270
  }),
271
271
  closeModal: onClose,
272
272
  iconDescription: effectiveHasCloseIcon ? closeIconDescription : undefined
273
- }, /*#__PURE__*/React__default.createElement(Wrap, {
273
+ }, /*#__PURE__*/React__default.createElement(Section, {
274
274
  className: `${bc}__header-content`,
275
275
  element: wide ? Layer : undefined
276
276
  }, /*#__PURE__*/React__default.createElement(Wrap, {
277
277
  className: `${bc}__header-fields`
278
278
  }, /*#__PURE__*/React__default.createElement(Wrap, {
279
- element: "h2",
280
279
  className: `${bcModalHeader}__label`
281
- }, label), /*#__PURE__*/React__default.createElement(Wrap, {
282
- element: "h3",
280
+ }, label), /*#__PURE__*/React__default.createElement(Section, {
283
281
  className: cx(`${bcModalHeader}__heading`, `${bc}__heading`)
284
- }, title), /*#__PURE__*/React__default.createElement(Wrap, {
282
+ }, /*#__PURE__*/React__default.createElement(Heading, null, title)), /*#__PURE__*/React__default.createElement(Wrap, {
285
283
  className: `${bc}__header-description`
286
284
  }, description)), /*#__PURE__*/React__default.createElement(Wrap, {
287
285
  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,94 @@
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
+ import React__default, { useContext, createContext, useState, useRef, useCallback } from 'react';
9
+ import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver.js';
10
+
11
+ const StackContext = /*#__PURE__*/createContext(undefined);
12
+ const StackProvider = _ref => {
13
+ let {
14
+ children,
15
+ stackStepSize = 'lg'
16
+ } = _ref;
17
+ const [stack, setStack] = useState([]);
18
+ const _containerRef = useRef(null);
19
+ const bufferMap = {
20
+ sm: 0.5,
21
+ md: 0.75,
22
+ lg: 1
23
+ };
24
+ const {
25
+ width
26
+ } = useResizeObserver(_containerRef);
27
+
28
+ // this method will register/ unregister tearsheet ids in a simple array based on open status
29
+ const notifyStack = useCallback((id, open, container) => {
30
+ _containerRef.current = container;
31
+ setStack(prev => {
32
+ if (open) {
33
+ // move to top if already exists
34
+ if (prev.includes(id)) {
35
+ return [...prev.filter(i => i !== id), id];
36
+ }
37
+ return [...prev, id];
38
+ } else {
39
+ // remove from stack
40
+ return prev.filter(i => i !== id);
41
+ }
42
+ });
43
+ }, []);
44
+
45
+ // method that calculates spacing factor for the stacked items
46
+ const getScaleFactor = id => {
47
+ const depth = getDepth(id);
48
+ const buffer = bufferMap[stackStepSize];
49
+ const bufferInPx = remToPx(buffer);
50
+ const scale = depth > -1 ? (width - bufferInPx * 2 * depth) / width : 1;
51
+ return scale;
52
+ };
53
+ const remToPx = rem => {
54
+ return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
55
+ };
56
+ const getDepth = useCallback(id => {
57
+ const index = stack.indexOf(id);
58
+ if (index === -1) {
59
+ return -1;
60
+ }
61
+ return stack.length - 1 - index; // topmost → 0
62
+ }, [stack]);
63
+ const getBlockSizeChange = id => {
64
+ const depth = getDepth(id);
65
+ const buffer = bufferMap[stackStepSize]; //to be changed
66
+ const bufferInPx = remToPx(buffer);
67
+ return `${bufferInPx * depth}px`;
68
+ };
69
+ const context = {
70
+ stack,
71
+ notifyStack,
72
+ getScaleFactor,
73
+ getBlockSizeChange,
74
+ getDepth
75
+ };
76
+ return /*#__PURE__*/React__default.createElement(StackContext.Provider, {
77
+ value: context
78
+ }, children);
79
+ };
80
+ const useStackContext = () => {
81
+ const context = useContext(StackContext);
82
+ if (context === undefined) {
83
+ return {
84
+ notifyStack: () => {},
85
+ stack: [],
86
+ getDepth: () => -1,
87
+ getScaleFactor: () => 1,
88
+ getBlockSizeChange: () => null
89
+ };
90
+ }
91
+ return context;
92
+ };
93
+
94
+ export { StackProvider, 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;
@@ -6,9 +6,9 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { forwardRef, useRef, useState, useLayoutEffect } from 'react';
9
+ import React__default, { forwardRef, useRef, useState, useEffect } from 'react';
10
10
  import cx from 'classnames';
11
- import { usePrefix, unstable_FeatureFlags, ComposedModal, ModalBody, Layer } from '@carbon/react';
11
+ import { usePrefix, unstable_FeatureFlags, ComposedModal, ModalBody } from '@carbon/react';
12
12
  import { TearsheetContext, blockClass } from './context.js';
13
13
  import TearsheetHeader, { TearsheetNavigationBar, TearsheetScrollButton } from './TearsheetHeader.js';
14
14
  import TearsheetHeaderContent from './TearsheetHeaderContent.js';
@@ -16,7 +16,10 @@ import TearsheetBody, { Influencer, MainContent, SummaryContent } from './Tearsh
16
16
  import { TearsheetHeaderActions, TearsheetHeaderActionItem } from './TearsheetHeaderActions.js';
17
17
  import { breakpoints } from '@carbon/layout';
18
18
  import { usePortalTarget } from '../../../global/js/hooks/usePortalTarget.js';
19
+ import { useStackContext } from './StackContext.js';
19
20
  import { useMatchMedia } from '../../../global/js/hooks/useMatchMedia.js';
21
+ import { useId } from '../../../global/js/utils/useId.js';
22
+ import { useIsomorphicEffect } from '../../../global/js/hooks/useIsomorphicEffect.js';
20
23
 
21
24
  /**
22
25
  * ----------
@@ -35,13 +38,15 @@ const Tearsheet = /*#__PURE__*/forwardRef((_ref, ref) => {
35
38
  ariaLabel,
36
39
  onClose,
37
40
  selectorPrimaryFocus,
38
- open,
41
+ open = false,
39
42
  portalTarget,
43
+ verticalGap,
44
+ containerClassName,
40
45
  ...rest
41
46
  } = _ref;
42
47
  const carbonPrefix = usePrefix();
43
48
  const localRef = useRef(undefined);
44
- const bodyRef = useRef(undefined);
49
+ const bodyRef = useRef(null);
45
50
  const modalRef = ref || localRef;
46
51
  const smMediaQuery = `(max-width: ${breakpoints.md.width})`;
47
52
  const isSm = useMatchMedia(smMediaQuery) || variant === 'narrow';
@@ -53,8 +58,17 @@ const Tearsheet = /*#__PURE__*/forwardRef((_ref, ref) => {
53
58
  const influencer = arr.find(child => child.type === Influencer);
54
59
  const body = arr.find(child => child.type === TearsheetBody);
55
60
  const footer = arr.find(child => child.type === Footer);
61
+ const uniqueId = useRef(useId());
62
+ const {
63
+ notifyStack,
64
+ stack,
65
+ getDepth,
66
+ getScaleFactor,
67
+ getBlockSizeChange
68
+ } = useStackContext();
69
+ const [depth, setDepth] = useState(0);
56
70
  const renderPortalUse = usePortalTarget(portalTarget);
57
- useLayoutEffect(() => {
71
+ useIsomorphicEffect(() => {
58
72
  const AILabelWidth = modalRef.current?.querySelector(`.${carbonPrefix}--ai-label`)?.clientWidth ?? 0;
59
73
  const headerActionMarginRight = AILabelWidth + 24 + (isSm ? 8 : 0); // 24 is to compeNsate for close button
60
74
  document.documentElement.style.setProperty('--tearsheet-header-action-offset', `${headerActionMarginRight}px`);
@@ -64,9 +78,31 @@ const Tearsheet = /*#__PURE__*/forwardRef((_ref, ref) => {
64
78
  if (summaryContentWidth) {
65
79
  document.documentElement.style.setProperty('--tearsheet-summary-content-width', `${summaryContentWidth}`);
66
80
  }
81
+ if (verticalGap) {
82
+ document.documentElement.style.setProperty('--tearsheet-vertical-gap', `${verticalGap}`);
83
+ }
67
84
 
68
85
  // eslint-disable-next-line react-hooks/exhaustive-deps
69
- }, [isSm]);
86
+ }, [isSm, rest.decorator, influencerWidth, summaryContentWidth, verticalGap]);
87
+ useIsomorphicEffect(() => {
88
+ if (bodyRef.current) {
89
+ notifyStack?.(uniqueId.current, open, bodyRef.current);
90
+ }
91
+
92
+ // eslint-disable-next-line react-hooks/exhaustive-deps
93
+ }, [open]);
94
+ useEffect(() => {
95
+ if (stack?.length > 0) {
96
+ const stackDepth = getDepth?.(uniqueId.current),
97
+ blockSizeChange = getBlockSizeChange?.(uniqueId.current),
98
+ scaleFactor = getScaleFactor?.(uniqueId.current);
99
+ setDepth(stackDepth);
100
+ modalRef.current.style.setProperty('--stack-depth', stackDepth + '');
101
+ modalRef.current.style.setProperty('--block-size-change', blockSizeChange);
102
+ modalRef.current.style.setProperty('--scale-factor', scaleFactor + '');
103
+ }
104
+ // eslint-disable-next-line react-hooks/exhaustive-deps
105
+ }, [stack]);
70
106
  return renderPortalUse(/*#__PURE__*/React__default.createElement(TearsheetContext.Provider, {
71
107
  value: {
72
108
  hasCloseIcon,
@@ -86,11 +122,13 @@ const Tearsheet = /*#__PURE__*/forwardRef((_ref, ref) => {
86
122
  className: cx(blockClass, className, {
87
123
  [`${blockClass}--wide`]: variant === 'wide',
88
124
  [`${blockClass}--narrow`]: variant === 'narrow',
125
+ [`${blockClass}--stacked`]: depth > 0,
126
+ [`${blockClass}--stack-activated`]: stack.length > 1,
89
127
  [`${blockClass}--has-ai-label`]: !!rest.decorator && rest.decorator['type']?.displayName === 'AILabel',
90
128
  [`${blockClass}--has-decorator`]: !!rest.decorator && rest.decorator['type']?.displayName !== 'AILabel',
91
129
  [`${blockClass}--has-close`]: hasCloseIcon
92
130
  }),
93
- containerClassName: cx(`${blockClass}__container`, {}),
131
+ containerClassName: cx(`${blockClass}__container`, containerClassName),
94
132
  onClose,
95
133
  open,
96
134
  selectorPrimaryFocus,
@@ -107,9 +145,7 @@ const Footer = /*#__PURE__*/forwardRef((_ref2, ref) => {
107
145
  let {
108
146
  children
109
147
  } = _ref2;
110
- return /*#__PURE__*/React__default.createElement(Layer, {
111
- as: "footer",
112
- withBackground: true,
148
+ return /*#__PURE__*/React__default.createElement("footer", {
113
149
  className: `${blockClass}__footer`,
114
150
  ref: ref
115
151
  }, 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;
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { forwardRef, useContext, useRef } from 'react';
10
+ import cx from 'classnames';
10
11
  import { blockClass, TearsheetContext } from './context.js';
11
12
  import { SidePanel } from '../../SidePanel/SidePanel.js';
12
13
  import { Layer } from '@carbon/react';
@@ -37,6 +38,7 @@ const MainContent = /*#__PURE__*/forwardRef((_ref2, ref) => {
37
38
  let {
38
39
  children,
39
40
  className,
41
+ isFlush,
40
42
  ...rest
41
43
  } = _ref2;
42
44
  const localRef = useRef(null);
@@ -67,7 +69,9 @@ const MainContent = /*#__PURE__*/forwardRef((_ref2, ref) => {
67
69
  });
68
70
  return /*#__PURE__*/React__default.createElement(Layer, _extends({
69
71
  withBackground: true,
70
- className: `${blockClass}__main-content ${className}`,
72
+ className: cx(`${blockClass}__main-content`, className, {
73
+ [`${blockClass}__flush`]: isFlush
74
+ }),
71
75
  ref: mainContentRef
72
76
  }, rest), children);
73
77
  });
@@ -83,18 +87,22 @@ const SummaryContent = /*#__PURE__*/forwardRef((_ref3, ref) => {
83
87
  children,
84
88
  className,
85
89
  summaryPanelOpen = false,
86
- onSummaryPanelClose
90
+ onSummaryPanelClose,
91
+ isFlush
87
92
  } = _ref3;
88
93
  const {
89
94
  isSm
90
95
  } = useContext(TearsheetContext);
91
96
  return !isSm ? /*#__PURE__*/React__default.createElement("div", {
92
- className: `${blockClass}__summary-content ${className}`,
97
+ className: cx(`${blockClass}__summary-content`, className, {
98
+ [`${blockClass}__flush`]: isFlush
99
+ }),
93
100
  ref: ref
94
101
  }, /*#__PURE__*/React__default.createElement("aside", null, children)) : /*#__PURE__*/React__default.createElement(SidePanel, {
95
102
  size: "sm",
96
103
  open: summaryPanelOpen,
97
- onRequestClose: onSummaryPanelClose
104
+ onRequestClose: onSummaryPanelClose,
105
+ className: className
98
106
  }, children);
99
107
  });
100
108
  const Influencer = /*#__PURE__*/forwardRef((_ref4, ref) => {
@@ -102,19 +110,23 @@ const Influencer = /*#__PURE__*/forwardRef((_ref4, ref) => {
102
110
  children,
103
111
  className,
104
112
  influencerPanelOpen = false,
105
- onInfluencerPanelClose
113
+ onInfluencerPanelClose,
114
+ isFlush
106
115
  } = _ref4;
107
116
  const {
108
117
  isSm
109
118
  } = useContext(TearsheetContext);
110
119
  return !isSm ? /*#__PURE__*/React__default.createElement("aside", {
111
- className: `${blockClass}__influencer ${className}`,
120
+ className: cx(`${blockClass}__influencer`, className, {
121
+ [`${blockClass}__flush`]: isFlush
122
+ }),
112
123
  ref: ref
113
124
  }, children) : /*#__PURE__*/React__default.createElement(SidePanel, {
114
125
  size: "sm",
115
126
  open: influencerPanelOpen,
116
127
  onRequestClose: onInfluencerPanelClose,
117
- placement: "left"
128
+ placement: "left",
129
+ className: className
118
130
  }, children);
119
131
  });
120
132
 
@@ -7,9 +7,11 @@
7
7
 
8
8
  import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import { MenuButton, MenuItem } from '@carbon/react';
10
- import React__default, { useRef, useState, useLayoutEffect } from 'react';
10
+ import React__default, { useRef, useState } from 'react';
11
11
  import { blockClass } from './context.js';
12
12
  import { createOverflowHandler } from '@carbon/utilities';
13
+ import cx from 'classnames';
14
+ import { useIsomorphicEffect } from '../../../global/js/hooks/useIsomorphicEffect.js';
13
15
 
14
16
  /**
15
17
  * ----------------
@@ -31,7 +33,7 @@ const TearsheetHeaderActions = _ref => {
31
33
 
32
34
  // need to set the grid columns width based on the menu button's width
33
35
  // to avoid overlapping when resizing
34
- useLayoutEffect(() => {
36
+ useIsomorphicEffect(() => {
35
37
  if (menuButtonVisibility && offsetRef.current) {
36
38
  const width = offsetRef.current.offsetWidth;
37
39
  document.documentElement.style.setProperty('--tearsheet-header-title-grid-width', `${width}px`);
@@ -43,7 +45,7 @@ const TearsheetHeaderActions = _ref => {
43
45
  }
44
46
  return /*#__PURE__*/React__default.isValidElement(child);
45
47
  });
46
- useLayoutEffect(() => {
48
+ useIsomorphicEffect(() => {
47
49
  //Menu button will be rendered only if they pass the items in TearsheetHeaderActionItem
48
50
  if (!containerRef.current || hasOtherChildType.current) {
49
51
  return;
@@ -65,7 +67,10 @@ const TearsheetHeaderActions = _ref => {
65
67
  }, children, !hasOtherChildType.current && /*#__PURE__*/React__default.createElement("span", {
66
68
  "data-offset": true,
67
69
  "data-hidden": true,
68
- ref: offsetRef
70
+ ref: offsetRef,
71
+ className: cx(`${blockClass}__header-actions-menuButton`, {
72
+ [`${blockClass}__header-actions-menuButton--hidden`]: hiddenItems.length === 0
73
+ })
69
74
  }, /*#__PURE__*/React__default.createElement(MenuButton, _extends({
70
75
  size: "sm"
71
76
  }, 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
  */
@@ -5,9 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import React__default, { useContext } from 'react';
8
+ import React__default from 'react';
9
9
  import cx from 'classnames';
10
- import { TearsheetContext, blockClass } from './context.js';
10
+ import { blockClass } from './context.js';
11
11
  import { TruncatedText } from '../../TruncatedText/TruncatedText.js';
12
12
 
13
13
  const TearsheetHeaderContent = /*#__PURE__*/React__default.forwardRef((props, ref) => {
@@ -16,48 +16,35 @@ const TearsheetHeaderContent = /*#__PURE__*/React__default.forwardRef((props, re
16
16
  label,
17
17
  title,
18
18
  description,
19
- descriptionExpandLabel = 'Read more',
20
- descriptionCollapseLabel = 'Read less',
21
- titleIcon: Icon,
22
- titleIconPosition = 'leading',
23
19
  headerActions,
20
+ titleStart,
21
+ titleEnd,
24
22
  ...rest
25
23
  } = props;
26
- const {
27
- isSm
28
- } = useContext(TearsheetContext);
29
24
  return /*#__PURE__*/React__default.createElement("div", {
30
25
  className: `${blockClass}__header-content-wrapper`,
31
26
  ref: ref
32
27
  }, /*#__PURE__*/React__default.createElement("div", {
33
28
  className: `${blockClass}__header-content`
34
- }, /*#__PURE__*/React__default.createElement("p", {
29
+ }, label ? /*#__PURE__*/React__default.createElement("div", {
35
30
  className: `${blockClass}__header-label`
36
- }, label), /*#__PURE__*/React__default.createElement("div", {
31
+ }, label) : null, /*#__PURE__*/React__default.createElement("div", {
37
32
  className: `${blockClass}__content__title-wrapper`
38
33
  }, /*#__PURE__*/React__default.createElement("h2", {
39
- className: cx(`${blockClass}__header-title`, {
40
- [`${blockClass}__leading-icon`]: Icon && titleIconPosition === 'leading'
41
- }, {
42
- [`${blockClass}__trailing-icon`]: Icon && titleIconPosition === 'trailing'
43
- })
44
- }, !isSm && Icon && /*#__PURE__*/React__default.createElement(Icon, {
45
- size: 32
46
- }), /*#__PURE__*/React__default.createElement(TruncatedText, {
34
+ className: cx(`${blockClass}__header-title`)
35
+ }, titleStart ? /*#__PURE__*/React__default.createElement("span", {
36
+ className: `${blockClass}__title-start`
37
+ }, titleStart) : null, /*#__PURE__*/React__default.createElement(TruncatedText, {
47
38
  id: `${blockClass}__header-title__truncatedText`,
48
39
  className: `${blockClass}__content__title`,
49
40
  align: "bottom",
50
41
  autoAlign: true,
51
42
  value: title
52
- }))), /*#__PURE__*/React__default.createElement("div", {
43
+ }), titleEnd ? /*#__PURE__*/React__default.createElement("span", {
44
+ className: `${blockClass}__title-end`
45
+ }, titleEnd) : null)), /*#__PURE__*/React__default.createElement("div", {
53
46
  className: `${blockClass}__header-description`
54
- }, /*#__PURE__*/React__default.createElement(TruncatedText, {
55
- id: `${blockClass}__header-description__truncatedText`,
56
- expandLabel: descriptionExpandLabel,
57
- collapseLabel: descriptionCollapseLabel,
58
- value: description,
59
- type: "expand"
60
- })), children && /*#__PURE__*/React__default.createElement("div", {
47
+ }, description), children && /*#__PURE__*/React__default.createElement("div", {
61
48
  className: `${blockClass}__header-content--extra`
62
49
  }, children)), headerActions && /*#__PURE__*/React__default.createElement("div", {
63
50
  className: `${blockClass}__header-actions`
@@ -4,7 +4,7 @@
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, { ReactNode } from 'react';
7
+ import React, { ReactNode, RefObject } from 'react';
8
8
  import { StepState } from '../../../StepFlow';
9
9
  interface Props {
10
10
  children?: ReactNode;
@@ -17,6 +17,7 @@ interface Props {
17
17
  selectorPrimaryFocus?: string;
18
18
  setOpen?: (open: boolean) => void;
19
19
  progressIndicator?: 'vertical' | 'horizontal';
20
+ launcherButtonRef?: RefObject<HTMLButtonElement | null>;
20
21
  }
21
- export declare const TearsheetWithSteps: ({ children, open, setOpen, onClose, influencer, title, hasCloseIcon, closeIconDescription, selectorPrimaryFocus, progressIndicator, ...rest }: Props) => React.JSX.Element;
22
+ export declare const TearsheetWithSteps: ({ children, open, setOpen, onClose, influencer, title, hasCloseIcon, closeIconDescription, selectorPrimaryFocus, progressIndicator, launcherButtonRef, ...rest }: Props) => React.JSX.Element;
22
23
  export {};
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export { Tearsheet } from './Tearsheet';
8
+ export { StackProvider, useStackContext } from './StackContext';
9
+ export type { StackContextType } from './StackContext';
8
10
  export type { TearsheetProps, TearsheetComponentType, FooterProps, } from './Tearsheet';
9
11
  export type { MainContentProps, SummaryContentProps, TearsheetBodyProps, InfluencerProps, } from './TearsheetBody';
10
12
  export type { TearsheetHeaderProps, TearsheetNavigationBarProps, TearsheetScrollButtonProps, } from './TearsheetHeader';
@@ -46,7 +46,8 @@ export * as preview__CoachmarkBeacon from './Coachmark/next/Coachmark/CoachmarkB
46
46
  export { TruncatedText as preview__TruncatedText, type TruncatedTextProps, } from './TruncatedText';
47
47
  export { FeatureFlags as preview__FeatureFlags, useFeatureFlag as preview__useFeatureFlag, useFeatureFlags as preview__useFeatureFlags, } from './FeatureFlags';
48
48
  export * as preview__PageHeader from './PageHeader/next';
49
- export * as preview__Tearsheet from './Tearsheet/next';
49
+ export { Tearsheet as preview__Tearsheet, StackProvider, } from './Tearsheet/next';
50
+ export type { TearsheetProps, TearsheetComponentType, FooterProps, MainContentProps, SummaryContentProps, TearsheetBodyProps, InfluencerProps, TearsheetHeaderProps, TearsheetNavigationBarProps, TearsheetScrollButtonProps, TearsheetHeaderActionItemProps, TearsheetHeaderActionsProps, TearsheetHeaderContentProps, StackContextType, } from './Tearsheet/next';
50
51
  export { BigNumber as previewCandidate__BigNumber, type BigNumberProps, } from './BigNumber';
51
52
  export { Coachmark as previewCandidate__Coachmark, BEACON_KIND, COACHMARK_OVERLAY_KIND, COACHMARK_ALIGNMENT, useCoachmark, type CoachmarkProps, } from './Coachmark';
52
53
  export { CoachmarkBeacon as previewCandidate__CoachmarkBeacon, type CoachmarkBeaconProps, } from './CoachmarkBeacon';