@carbon/ibm-products 2.70.1 → 2.71.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 (175) hide show
  1. package/css/carbon.css +317 -216
  2. package/css/carbon.css.map +1 -1
  3. package/css/index-full-carbon.css +546 -270
  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 +387 -43
  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 +229 -54
  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 +242 -56
  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/_virtual/_commonjsHelpers.js +1 -3
  20. package/es/_virtual/index2.js +2 -6
  21. package/es/components/APIKeyModal/APIKeyDownloader.d.ts +61 -19
  22. package/es/components/APIKeyModal/APIKeyDownloader.js +3 -3
  23. package/es/components/APIKeyModal/APIKeyModal.js +1 -1
  24. package/es/components/ActionSet/ActionSet.d.ts +4 -0
  25. package/es/components/ActionSet/ActionSet.js +46 -44
  26. package/es/components/AddSelect/AddSelectBody.js +1 -1
  27. package/es/components/Card/Card.d.ts +1 -0
  28. package/es/components/Coachmark/CoachmarkOverlay.js +5 -5
  29. package/es/components/Coachmark/CoachmarkTagline.js +2 -2
  30. package/es/components/Coachmark/utils/context.d.ts +28 -2
  31. package/es/components/Coachmark/utils/context.js +1 -1
  32. package/es/components/CoachmarkStack/CoachmarkStack.js +11 -8
  33. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +18 -12
  34. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
  35. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +5 -3
  36. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +2 -1
  37. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +5 -2
  38. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.d.ts +2 -1
  39. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +5 -2
  40. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +9 -1
  41. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +24 -5
  42. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -1
  43. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +6 -4
  44. package/es/components/ConditionBuilder/utils/util.d.ts +1 -1
  45. package/es/components/ConditionBuilder/utils/util.js +11 -4
  46. package/es/components/CreateModal/CreateModal.d.ts +4 -7
  47. package/es/components/CreateModal/CreateModal.js +4 -19
  48. package/es/components/CreateTearsheet/CreateTearsheetStep.d.ts +6 -0
  49. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +12 -3
  50. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +43 -18
  51. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +1 -1
  52. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +1 -1
  53. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +2 -2
  54. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.d.ts +7 -1
  55. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +11 -3
  56. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +15 -19
  57. package/es/components/EditTearsheet/EditTearsheetForm.d.ts +2 -0
  58. package/es/components/EditTearsheet/EditTearsheetForm.js +16 -4
  59. package/es/components/EmptyStates/EmptyState.js +0 -1
  60. package/es/components/FilterSummary/FilterSummary.d.ts +1 -0
  61. package/es/components/FilterSummary/FilterSummary.js +2 -1
  62. package/es/components/Guidebanner/Guidebanner.js +4 -20
  63. package/es/components/InterstitialScreen/InterstitialScreen.d.ts +4 -3
  64. package/es/components/InterstitialScreen/InterstitialScreen.js +21 -21
  65. package/es/components/InterstitialScreen/InterstitialScreenBody.d.ts +9 -3
  66. package/es/components/InterstitialScreen/InterstitialScreenBody.js +16 -11
  67. package/es/components/InterstitialScreen/InterstitialScreenFooter.js +15 -13
  68. package/es/components/InterstitialScreen/InterstitialScreenHeader.js +13 -8
  69. package/es/components/InterstitialScreen/index.d.ts +4 -1
  70. package/es/components/Nav/NavItemLink.js +1 -4
  71. package/es/components/PageHeader/PageHeaderTitle.js +1 -1
  72. package/es/components/PageHeader/next/PageHeader.d.ts +277 -0
  73. package/es/components/PageHeader/next/PageHeader.js +475 -0
  74. package/es/components/PageHeader/next/index.d.ts +8 -0
  75. package/es/components/ScrollGradient/ScrollGradient.js +4 -4
  76. package/es/components/SidePanel/SidePanel.js +25 -20
  77. package/es/components/StringFormatter/StringFormatter.js +3 -0
  78. package/es/components/Tearsheet/Tearsheet.js +4 -7
  79. package/es/components/Tearsheet/TearsheetNarrow.js +1 -4
  80. package/es/components/Tearsheet/TearsheetShell.js +1 -1
  81. package/es/components/UserAvatar/UserAvatar.js +5 -7
  82. package/es/components/UserProfileImage/UserProfileImage.d.ts +1 -0
  83. package/es/components/UserProfileImage/UserProfileImage.js +12 -6
  84. package/es/components/index.d.ts +1 -0
  85. package/es/global/js/package-settings.js +1 -1
  86. package/es/index.js +3 -0
  87. package/es/node_modules/@carbon/icons-react/es/Icon.js +1 -1
  88. package/es/node_modules/prop-types/index.js +1 -1
  89. package/lib/_virtual/_commonjsHelpers.js +0 -3
  90. package/lib/_virtual/index2.js +2 -8
  91. package/lib/components/APIKeyModal/APIKeyDownloader.d.ts +61 -19
  92. package/lib/components/APIKeyModal/APIKeyDownloader.js +3 -3
  93. package/lib/components/APIKeyModal/APIKeyModal.js +1 -1
  94. package/lib/components/ActionSet/ActionSet.d.ts +4 -0
  95. package/lib/components/ActionSet/ActionSet.js +46 -43
  96. package/lib/components/AddSelect/AddSelectBody.js +1 -1
  97. package/lib/components/Card/Card.d.ts +1 -0
  98. package/lib/components/Coachmark/CoachmarkOverlay.js +5 -5
  99. package/lib/components/Coachmark/CoachmarkTagline.js +2 -2
  100. package/lib/components/Coachmark/utils/context.d.ts +28 -2
  101. package/lib/components/Coachmark/utils/context.js +1 -1
  102. package/lib/components/CoachmarkStack/CoachmarkStack.js +11 -8
  103. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +18 -12
  104. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.d.ts +1 -1
  105. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +5 -3
  106. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +2 -1
  107. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +5 -2
  108. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.d.ts +2 -1
  109. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +5 -2
  110. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.d.ts +9 -1
  111. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +24 -5
  112. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.d.ts +1 -1
  113. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +6 -4
  114. package/lib/components/ConditionBuilder/utils/util.d.ts +1 -1
  115. package/lib/components/ConditionBuilder/utils/util.js +11 -4
  116. package/lib/components/CreateModal/CreateModal.d.ts +4 -7
  117. package/lib/components/CreateModal/CreateModal.js +4 -19
  118. package/lib/components/CreateTearsheet/CreateTearsheetStep.d.ts +6 -0
  119. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +12 -3
  120. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.d.ts +43 -18
  121. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +1 -1
  122. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.d.ts +1 -1
  123. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +2 -2
  124. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.d.ts +7 -1
  125. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +11 -3
  126. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +15 -19
  127. package/lib/components/EditTearsheet/EditTearsheetForm.d.ts +2 -0
  128. package/lib/components/EditTearsheet/EditTearsheetForm.js +16 -4
  129. package/lib/components/EmptyStates/EmptyState.js +0 -1
  130. package/lib/components/FilterSummary/FilterSummary.d.ts +1 -0
  131. package/lib/components/FilterSummary/FilterSummary.js +2 -1
  132. package/lib/components/Guidebanner/Guidebanner.js +4 -20
  133. package/lib/components/InterstitialScreen/InterstitialScreen.d.ts +4 -3
  134. package/lib/components/InterstitialScreen/InterstitialScreen.js +21 -20
  135. package/lib/components/InterstitialScreen/InterstitialScreenBody.d.ts +9 -3
  136. package/lib/components/InterstitialScreen/InterstitialScreenBody.js +19 -14
  137. package/lib/components/InterstitialScreen/InterstitialScreenFooter.js +20 -18
  138. package/lib/components/InterstitialScreen/InterstitialScreenHeader.js +15 -10
  139. package/lib/components/InterstitialScreen/index.d.ts +4 -1
  140. package/lib/components/Nav/NavItemLink.js +1 -4
  141. package/lib/components/PageHeader/PageHeaderTitle.js +1 -1
  142. package/lib/components/PageHeader/next/PageHeader.d.ts +277 -0
  143. package/lib/components/PageHeader/next/PageHeader.js +490 -0
  144. package/lib/components/PageHeader/next/index.d.ts +8 -0
  145. package/lib/components/ScrollGradient/ScrollGradient.js +4 -4
  146. package/lib/components/SidePanel/SidePanel.js +26 -21
  147. package/lib/components/StringFormatter/StringFormatter.js +3 -0
  148. package/lib/components/Tearsheet/Tearsheet.js +4 -7
  149. package/lib/components/Tearsheet/TearsheetNarrow.js +1 -4
  150. package/lib/components/Tearsheet/TearsheetShell.js +1 -1
  151. package/lib/components/UserAvatar/UserAvatar.js +5 -7
  152. package/lib/components/UserProfileImage/UserProfileImage.d.ts +1 -0
  153. package/lib/components/UserProfileImage/UserProfileImage.js +12 -6
  154. package/lib/components/index.d.ts +1 -0
  155. package/lib/global/js/package-settings.js +1 -1
  156. package/lib/index.js +5 -2
  157. package/lib/node_modules/@carbon/icons-react/es/Icon.js +1 -1
  158. package/lib/node_modules/prop-types/index.js +1 -1
  159. package/package.json +22 -30
  160. package/scss/components/CoachmarkStack/_coachmark-stack.scss +12 -1
  161. package/scss/components/InterstitialScreen/_interstitial-screen.scss +7 -11
  162. package/scss/components/PageHeader/_page-header.scss +198 -0
  163. package/scss/components/SidePanel/_side-panel.scss +2 -52
  164. package/scss/components/_index-released-only.scss +1 -0
  165. package/telemetry.yml +12 -13
  166. package/es/_virtual/index3.js +0 -10
  167. package/es/components/SidePanel/resizer/Resizer.d.ts +0 -21
  168. package/es/components/SidePanel/resizer/Resizer.js +0 -271
  169. package/es/node_modules/lodash.debounce/index.js +0 -367
  170. package/lib/_virtual/index3.js +0 -12
  171. package/lib/components/SidePanel/resizer/Resizer.d.ts +0 -21
  172. package/lib/components/SidePanel/resizer/Resizer.js +0 -277
  173. package/lib/node_modules/lodash.debounce/index.js +0 -369
  174. /package/es/node_modules/@carbon/{icons-react/node_modules/@carbon/icon-helpers → icon-helpers}/es/index.js +0 -0
  175. /package/lib/node_modules/@carbon/{icons-react/node_modules/@carbon/icon-helpers → icon-helpers}/es/index.js +0 -0
@@ -16,6 +16,7 @@
16
16
  @use '@carbon/styles/scss/type';
17
17
  @use '@carbon/styles/scss/breakpoint' as *;
18
18
  @use '@carbon/styles/scss/utilities';
19
+ @use '@carbon-labs/react-resizer/scss/resizer';
19
20
  @use '@carbon/styles/scss/components/button/tokens' as *;
20
21
 
21
22
  // Standard imports.
@@ -30,7 +31,7 @@
30
31
 
31
32
  $block-class: #{c4p-settings.$pkg-prefix}--side-panel;
32
33
  $action-set-block-class: #{c4p-settings.$pkg-prefix}--action-set;
33
- $clabs-prefix: 'clabs'; // TODO: remove when resizer available in labs
34
+ $clabs-prefix: 'clabs';
34
35
 
35
36
  @property --panel-transform {
36
37
  inherits: true;
@@ -638,54 +639,3 @@ $clabs-prefix: 'clabs'; // TODO: remove when resizer available in labs
638
639
  .#{$block-class}--has-decorator + .#{$block-class}__overlay {
639
640
  background-color: $ai-overlay;
640
641
  }
641
-
642
- // TODO: remove along with prefix after resizer available in labs
643
- .#{$clabs-prefix}__resizer {
644
- position: relative;
645
- flex: none;
646
- background-color: $border-subtle-01;
647
-
648
- &:hover {
649
- @media (prefers-reduced-motion: no-preference) {
650
- background-color: $border-interactive;
651
- transition: background-color $duration-moderate-01;
652
- }
653
- }
654
-
655
- &:focus {
656
- background-color: $border-interactive;
657
- outline: none;
658
- }
659
-
660
- &:active {
661
- background-color: $border-interactive;
662
- }
663
-
664
- &:focus:not(:focus-visible) {
665
- box-shadow: none;
666
- outline: none;
667
- }
668
-
669
- &--horizontal {
670
- block-size: $spacing-02;
671
- cursor: ns-resize;
672
- }
673
-
674
- &--vertical {
675
- cursor: ew-resize;
676
- inline-size: $spacing-02;
677
- }
678
- }
679
-
680
- .sr-only {
681
- position: absolute;
682
- overflow: hidden;
683
- padding: 0;
684
- border: 0;
685
- margin: -1px;
686
- block-size: 1px;
687
- clip: rect(0, 0, 0, 0);
688
- inline-size: 1px;
689
- white-space: nowrap;
690
- }
691
- // END TODO: remove along with prefix after resizer available in labs
@@ -40,3 +40,4 @@
40
40
  @use './UserProfileImage';
41
41
  @use './WebTerminal';
42
42
  @use './UserAvatar';
43
+ @use './InterstitialScreen';
package/telemetry.yml CHANGED
@@ -40,6 +40,7 @@ collect:
40
40
  - batchActionMenuButtonLabel
41
41
  - batchActions
42
42
  - body
43
+ - border
43
44
  - breadcrumbOverflowTooltipAlign
44
45
  - breadcrumbs
45
46
  - button
@@ -51,6 +52,7 @@ collect:
51
52
  - clickZone
52
53
  - closeButtonLabel
53
54
  - closeIconDescription
55
+ - closePopover
54
56
  - collapseButtonLabel
55
57
  - collapsible
56
58
  - column
@@ -99,6 +101,7 @@ collect:
99
101
  - ExpandedRowContentComponent
100
102
  - expandedRowIds
101
103
  - fetchMoreData
104
+ - fieldsetLegendId
102
105
  - fieldsetLegendText
103
106
  - filterByLabel
104
107
  - filterProps
@@ -267,6 +270,7 @@ collect:
267
270
  - overflowTags
268
271
  - overflowTooltipAlign
269
272
  - overflowType
273
+ - pageActions
270
274
  - parentId
271
275
  - path
272
276
  - pictogram
@@ -600,7 +604,6 @@ collect:
600
604
  - experimentalSecondarySubmitText
601
605
  # CreateTearsheetStep
602
606
  - experimentalSecondarySubmit
603
- - fieldsetLegendId
604
607
  # CustomizeColumnsTearsheet
605
608
  - columnDefinitions
606
609
  - onSaveColumnPrefs
@@ -628,8 +631,6 @@ collect:
628
631
  - magnitude
629
632
  # DelimitedList
630
633
  - delimiter
631
- # DescriptionList
632
- - border
633
634
  # DraggableElement
634
635
  - classList
635
636
  - elementId
@@ -742,7 +743,6 @@ collect:
742
743
  - narrow
743
744
  - tertiaryButtonLabel
744
745
  # InterstitialScreen
745
- - interstitialAriaLabel
746
746
  - isFullScreen
747
747
  # InterstitialScreenBody
748
748
  - contentRenderer
@@ -840,10 +840,17 @@ collect:
840
840
  - hasBackgroundAlways
841
841
  - hasCollapseHeaderToggle
842
842
  - narrowGrid
843
- - pageActions
844
843
  - pageActionsMenuOptionsClass
845
844
  - pageActionsOverflowLabel
846
845
  - withoutBackground
846
+ # PageHeaderBreadcrumbBar
847
+ - contentActions
848
+ - contentActionsFlush
849
+ - pageActionsFlush
850
+ # PageHeaderContent
851
+ - contextualActions
852
+ # PageHeaderContentPageActions
853
+ - menuButtonLabel
847
854
  # PageHeaderTitle
848
855
  - blockClass
849
856
  - hasBreadcrumbRow
@@ -854,11 +861,6 @@ collect:
854
861
  - primaryDangerDescription
855
862
  - resourceName
856
863
  - textConfirmation
857
- # Resizer
858
- - onDoubleClick
859
- - onResize
860
- - onResizeEnd
861
- - orientation
862
864
  # RowSizeDropdown
863
865
  - datagridName
864
866
  - light
@@ -1199,9 +1201,6 @@ collect:
1199
1201
  - short
1200
1202
  # PageHeader - fullWidthGrid
1201
1203
  - xl
1202
- # Resizer - orientation
1203
- - horizontal
1204
- - vertical
1205
1204
  npm:
1206
1205
  dependencies: null
1207
1206
  js:
@@ -1,10 +0,0 @@
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
- var propTypes = {exports: {}};
9
-
10
- export { propTypes as __module };
@@ -1,21 +0,0 @@
1
- /**
2
- * @license
3
- *
4
- * Copyright IBM Corp. 2025
5
- *
6
- * This source code is licensed under the Apache-2.0 license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- import React from 'react';
10
- export declare const DEBOUNCE_DELAY = 100;
11
- /** Primary UI component for user interaction */
12
- interface ResizerProps {
13
- orientation: 'horizontal' | 'vertical';
14
- onResize?: (event: MouseEvent | KeyboardEvent, delta: number) => void;
15
- onResizeEnd?: (event: MouseEvent | KeyboardEvent, ref: React.RefObject<HTMLDivElement>) => void;
16
- onDoubleClick?: (event: MouseEvent) => string | void;
17
- className?: string;
18
- [key: string]: any;
19
- }
20
- export declare const Resizer: React.ForwardRefExoticComponent<Omit<ResizerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
21
- export default Resizer;
@@ -1,271 +0,0 @@
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 { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React__default, { forwardRef, useRef, useState, useEffect, useCallback } from 'react';
10
- import cx from 'classnames';
11
- import debounce from '../../../_virtual/index2.js';
12
-
13
- var _span;
14
- const DEBOUNCE_DELAY = 100;
15
- /** Primary UI component for user interaction */
16
-
17
- const getRefElement = ref => {
18
- if (!ref || !('current' in ref)) {
19
- return null;
20
- }
21
- return ref.current;
22
- };
23
- const Resizer = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
24
- let {
25
- orientation,
26
- onResize,
27
- onResizeEnd,
28
- onDoubleClick,
29
- className,
30
- ...rest
31
- } = _ref;
32
- const prefix = 'clabs';
33
- const blockClass = `${prefix}__resizer`;
34
- const internalRef = useRef(null);
35
- const ref = forwardedRef || internalRef; // combine refs, forwarded ref takes priority over internal ref
36
- const [isResizing, setIsResizing] = useState(false);
37
- const startPos = useRef({
38
- x: 0,
39
- y: 0
40
- });
41
- // Sizes of the previous and next siblings, gets modified during resizing
42
- const sizes = useRef({
43
- prevSiblingSize: {
44
- width: 0,
45
- height: 0
46
- },
47
- nextSiblingSize: {
48
- width: 0,
49
- height: 0
50
- }
51
- });
52
- // Initial sizes of the previous and next siblings, a static reference
53
- const initialSizes = useRef({
54
- prevSiblingSize: {
55
- width: 0,
56
- height: 0
57
- },
58
- nextSiblingSize: {
59
- width: 0,
60
- height: 0
61
- }
62
- });
63
-
64
- // Debounced function to handle resize end events
65
- // This is used to prevent multiple calls during a resize operation especially from keyboard when the key is held down
66
- // It will only call the onResizeEnd after the user has stopped resizing
67
- const debouncedResizeEnd = useRef(debounce(event => {
68
- const element = getRefElement(ref);
69
- if (element && onResizeEnd) {
70
- onResizeEnd(event, ref);
71
- }
72
- }, DEBOUNCE_DELAY));
73
- useEffect(() => {
74
- const element = getRefElement(ref);
75
- if (!element) {
76
- return;
77
- }
78
- const prevSibling = element.previousElementSibling;
79
- const nextSibling = element.nextElementSibling;
80
- const rect = el => el?.getBoundingClientRect();
81
- initialSizes.current = {
82
- prevSiblingSize: prevSibling ? {
83
- width: rect(prevSibling).width,
84
- height: rect(prevSibling).height
85
- } : {
86
- width: 0,
87
- height: 0
88
- },
89
- nextSiblingSize: nextSibling ? {
90
- width: rect(nextSibling).width,
91
- height: rect(nextSibling).height
92
- } : {
93
- width: 0,
94
- height: 0
95
- }
96
- };
97
- }, [ref]);
98
- const updateSizes = useCallback((event, delta) => {
99
- const element = getRefElement(ref);
100
- if (!element) {
101
- return;
102
- }
103
- if (onResize) {
104
- onResize(event, delta);
105
- return;
106
- }
107
- const prevSibling = element.previousElementSibling;
108
- const nextSibling = element.nextElementSibling;
109
- const prop = orientation === 'horizontal' ? 'height' : 'width';
110
- if (prevSibling) {
111
- const newSize = sizes.current.prevSiblingSize[prop] + delta;
112
- prevSibling.style[prop] = `${newSize}px`;
113
- }
114
- if (nextSibling) {
115
- const newSize = sizes.current.nextSiblingSize[prop] - delta;
116
- nextSibling.style[prop] = `${newSize}px`;
117
- }
118
- }, [onResize, orientation, ref]);
119
- const handleMouseMove = useCallback(event => {
120
- event.preventDefault();
121
- event.stopPropagation();
122
- const delta = orientation === 'horizontal' ? event.clientY - startPos.current.y : event.clientX - startPos.current.x;
123
- updateSizes(event, delta);
124
- }, [orientation, updateSizes]);
125
- const handleMouseUp = useCallback(event => {
126
- const element = getRefElement(ref);
127
- if (!element) {
128
- return;
129
- }
130
- setIsResizing(false);
131
- if (onResizeEnd) {
132
- onResizeEnd(event, ref);
133
- }
134
- const prevSibling = element.previousElementSibling;
135
- const nextSibling = element.nextElementSibling;
136
- if (prevSibling) {
137
- prevSibling.style.transition = '';
138
- }
139
- if (nextSibling) {
140
- nextSibling.style.transition = '';
141
- }
142
- }, [onResizeEnd, ref]);
143
-
144
- // Effect to add/remove mousemove and mouseup listeners during resizing
145
- useEffect(() => {
146
- if (!isResizing) {
147
- return;
148
- }
149
- window.addEventListener('mousemove', handleMouseMove);
150
- window.addEventListener('mouseup', handleMouseUp);
151
- return () => {
152
- window.removeEventListener('mousemove', handleMouseMove);
153
- window.removeEventListener('mouseup', handleMouseUp);
154
- };
155
- }, [isResizing, handleMouseMove, handleMouseUp]);
156
- const handleMouseDown = useCallback(event => {
157
- event.preventDefault();
158
- event.stopPropagation();
159
- const element = getRefElement(ref);
160
- if (!element) {
161
- return;
162
- }
163
- const prevSibling = element.previousElementSibling;
164
- const nextSibling = element.nextElementSibling;
165
- const rect = el => el?.getBoundingClientRect();
166
- prevSibling && (prevSibling.style.transition = 'none');
167
- nextSibling && (nextSibling.style.transition = 'none');
168
- setIsResizing(true);
169
- startPos.current = {
170
- x: event.clientX,
171
- y: event.clientY
172
- };
173
- sizes.current = {
174
- prevSiblingSize: prevSibling ? {
175
- width: rect(prevSibling).width,
176
- height: rect(prevSibling).height
177
- } : {
178
- width: 0,
179
- height: 0
180
- },
181
- nextSiblingSize: nextSibling ? {
182
- width: rect(nextSibling).width,
183
- height: rect(nextSibling).height
184
- } : {
185
- width: 0,
186
- height: 0
187
- }
188
- };
189
- }, [ref]);
190
- const handleKeyDown = useCallback(event => {
191
- const navigationKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End'];
192
- if (![...navigationKeys, 'PageUp', 'PageDown'].includes(event.key)) {
193
- return;
194
- }
195
- const element = getRefElement(ref);
196
- if (!element) {
197
- return;
198
- }
199
- event.preventDefault();
200
- event.stopPropagation();
201
- const prevSibling = element.previousElementSibling;
202
- const nextSibling = element.nextElementSibling;
203
- const getSize = el => {
204
- const rect = el?.getBoundingClientRect();
205
- return {
206
- width: rect?.width || 0,
207
- height: rect?.height || 0
208
- };
209
- };
210
- sizes.current = {
211
- prevSiblingSize: getSize(prevSibling),
212
- nextSiblingSize: getSize(nextSibling)
213
- };
214
- const step = event.shiftKey ? 25 : 5;
215
- let delta = 0;
216
- const isHorizontal = orientation === 'horizontal';
217
- const keyMap = {
218
- ArrowUp: () => isHorizontal ? delta = -step : null,
219
- ArrowDown: () => isHorizontal ? delta = step : null,
220
- ArrowLeft: () => !isHorizontal ? delta = -step : null,
221
- ArrowRight: () => !isHorizontal ? delta = step : null,
222
- Home: () => delta = isHorizontal ? -sizes.current.prevSiblingSize.height : -sizes.current.prevSiblingSize.width,
223
- End: () => delta = isHorizontal ? sizes.current.nextSiblingSize.height : sizes.current.nextSiblingSize.width
224
- };
225
- keyMap[event.key]?.();
226
- updateSizes(event, delta);
227
- debouncedResizeEnd?.current(event);
228
- }, [orientation, updateSizes, debouncedResizeEnd, ref]);
229
- const handleDoubleClick = event => {
230
- event.preventDefault();
231
- const element = getRefElement(ref);
232
- if (!element) {
233
- return;
234
- }
235
- const prevSibling = element.previousElementSibling;
236
- const nextSibling = element.nextElementSibling;
237
- if (onDoubleClick) {
238
- onDoubleClick(event);
239
- } else {
240
- const prop = orientation === 'horizontal' ? 'height' : 'width';
241
- if (prevSibling) {
242
- prevSibling.style[prop] = `${initialSizes.current.prevSiblingSize[prop]}px`;
243
- }
244
- if (nextSibling) {
245
- nextSibling.style[prop] = `${initialSizes.current.nextSiblingSize[prop]}px`;
246
- }
247
- }
248
- };
249
- return (
250
- /*#__PURE__*/
251
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
252
- React__default.createElement("div", _extends({}, rest, {
253
- ref: ref,
254
- role: "separator"
255
- // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
256
- ,
257
- tabIndex: 0,
258
- "aria-orientation": orientation,
259
- "aria-live": "assertive",
260
- onMouseDown: handleMouseDown,
261
- onDoubleClick: handleDoubleClick,
262
- onKeyDown: handleKeyDown,
263
- className: cx([className, blockClass, `${blockClass}--${orientation}`])
264
- }), _span || (_span = /*#__PURE__*/React__default.createElement("span", {
265
- className: "sr-only"
266
- }, "Use arrow keys to resize, hold Shift for larger steps. Double-click to reset.")))
267
- );
268
- });
269
- Resizer.displayName = 'Resizer';
270
-
271
- export { DEBOUNCE_DELAY, Resizer, Resizer as default };