@carbon/react 1.102.0-rc.0 → 1.102.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 (36) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +953 -953
  2. package/es/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  3. package/es/components/CheckboxGroup/CheckboxGroup.js +2 -2
  4. package/es/components/ComboBox/ComboBox.js +1 -2
  5. package/es/components/ContentSwitcher/ContentSwitcher.js +3 -2
  6. package/es/components/DataTable/TableExpandRow.js +2 -2
  7. package/es/components/DataTable/tools/normalize.js +2 -1
  8. package/es/components/DatePicker/DatePicker.js +3 -2
  9. package/es/components/Dropdown/Dropdown.js +1 -3
  10. package/es/components/ProgressIndicator/ProgressIndicator.js +3 -3
  11. package/es/components/Slider/Slider.d.ts +1 -1
  12. package/es/components/Slider/Slider.js +2 -8
  13. package/es/components/TileGroup/TileGroup.d.ts +1 -1
  14. package/es/components/TileGroup/TileGroup.js +2 -1
  15. package/es/components/UIShell/HeaderPanel.js +3 -2
  16. package/es/components/UIShell/Switcher.js +5 -4
  17. package/es/internal/useOverflowItems.d.ts +1 -5
  18. package/es/internal/useOverflowItems.js +6 -27
  19. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  20. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  21. package/lib/components/ComboBox/ComboBox.js +1 -2
  22. package/lib/components/ContentSwitcher/ContentSwitcher.js +2 -1
  23. package/lib/components/DataTable/TableExpandRow.js +1 -1
  24. package/lib/components/DataTable/tools/normalize.js +2 -1
  25. package/lib/components/DatePicker/DatePicker.js +3 -2
  26. package/lib/components/Dropdown/Dropdown.js +1 -3
  27. package/lib/components/ProgressIndicator/ProgressIndicator.js +3 -3
  28. package/lib/components/Slider/Slider.d.ts +1 -1
  29. package/lib/components/Slider/Slider.js +2 -8
  30. package/lib/components/TileGroup/TileGroup.d.ts +1 -1
  31. package/lib/components/TileGroup/TileGroup.js +2 -1
  32. package/lib/components/UIShell/HeaderPanel.js +2 -1
  33. package/lib/components/UIShell/Switcher.js +4 -3
  34. package/lib/internal/useOverflowItems.d.ts +1 -5
  35. package/lib/internal/useOverflowItems.js +6 -27
  36. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2025, 2025
2
+ * Copyright IBM Corp. 2025, 2026
3
3
  *
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.
@@ -18,10 +18,6 @@ type Item = {
18
18
  * @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
19
19
  */
20
20
  declare const useOverflowItems: <T extends Item>(items: T[] | ReactNode, containerRef: RefObject<HTMLDivElement>, offsetRef?: RefObject<HTMLDivElement>, maxItems?: number, onChange?: (hiddenItems: T[]) => void) => {
21
- visibleItems: T[];
22
- hiddenItems: T[];
23
- itemRefHandler: () => void;
24
- } | {
25
21
  visibleItems: T[];
26
22
  itemRefHandler: (id: string, node: HTMLDivElement | null) => () => void;
27
23
  hiddenItems: T[];
@@ -22,17 +22,10 @@ var usePreviousValue = require('./usePreviousValue.js');
22
22
  * @param onChange - Optional callback called when hidden items change. Receives array of currently hidden items.
23
23
  * @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
24
24
  */
25
-
26
25
  const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) => {
27
26
  const itemsRef = React.useRef(null);
28
27
  const [maxWidth, setMaxWidth] = React.useState(0);
29
- if (!items || !Array.isArray(items)) {
30
- return {
31
- visibleItems: [],
32
- hiddenItems: [],
33
- itemRefHandler: () => {}
34
- };
35
- }
28
+ const overflowItems = React.useMemo(() => Array.isArray(items) ? items : [], [items]);
36
29
  const handleResize = () => {
37
30
  if (containerRef.current) {
38
31
  const offset = offsetRef?.current?.offsetWidth || 0;
@@ -40,7 +33,6 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
40
33
  setMaxWidth(newMax);
41
34
  }
42
35
  };
43
- // eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
44
36
  useResizeObserver.useResizeObserver({
45
37
  ref: containerRef,
46
38
  onResize: handleResize
@@ -63,16 +55,13 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
63
55
  };
64
56
  };
65
57
  const getVisibleItems = () => {
66
- if (!items || Array.isArray(items) === false) {
67
- return [];
68
- }
69
58
  if (!containerRef) {
70
- return items;
59
+ return overflowItems;
71
60
  }
72
61
  const map = getMap();
73
62
  let maxReached = false;
74
63
  let accumulatedWidth = 0;
75
- const visibleItems = items.slice(0, maxItems).reduce((prev, cur) => {
64
+ const visibleItems = overflowItems.slice(0, maxItems).reduce((prev, cur) => {
76
65
  if (maxReached) {
77
66
  return prev;
78
67
  }
@@ -90,30 +79,20 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
90
79
  };
91
80
 
92
81
  // Memoize visible items calculation to avoid recalculating on every render
93
- // eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
94
82
  const visibleItems = React.useMemo(() => {
95
- if (!Array.isArray(items)) {
96
- return [];
97
- }
98
83
  return getVisibleItems();
99
84
  // eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
100
- }, [items, maxWidth, maxItems]);
85
+ }, [overflowItems, maxWidth, maxItems]);
101
86
 
102
87
  // Memoize hidden items calculation
103
- // eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
104
88
  const hiddenItems = React.useMemo(() => {
105
- if (!Array.isArray(items)) {
106
- return [];
107
- }
108
- return items.slice(visibleItems.length);
109
- }, [items, visibleItems]);
89
+ return overflowItems.slice(visibleItems.length);
90
+ }, [overflowItems, visibleItems]);
110
91
 
111
92
  // Use previous value to compare and only call onChange when needed
112
- // eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
113
93
  const previousHiddenItems = usePreviousValue.usePreviousValue(hiddenItems);
114
94
 
115
95
  // Only call onChange if hidden items actually changed
116
- // eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
117
96
  React.useEffect(() => {
118
97
  }, [hiddenItems, previousHiddenItems, onChange]);
119
98
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.102.0-rc.0",
4
+ "version": "1.102.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -53,9 +53,9 @@
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.27.3",
55
55
  "@carbon/feature-flags": "^1.0.0",
56
- "@carbon/icons-react": "^11.76.0-rc.0",
57
- "@carbon/layout": "^11.48.0",
58
- "@carbon/styles": "^1.101.0-rc.0",
56
+ "@carbon/icons-react": "^11.76.0",
57
+ "@carbon/layout": "^11.49.0",
58
+ "@carbon/styles": "^1.101.0",
59
59
  "@carbon/utilities": "^0.16.0",
60
60
  "@floating-ui/react": "^0.27.4",
61
61
  "@ibm/telemetry-js": "^1.5.0",
@@ -79,7 +79,7 @@
79
79
  "@babel/preset-react": "^7.27.1",
80
80
  "@babel/preset-typescript": "^7.27.1",
81
81
  "@carbon/test-utils": "^10.40.0",
82
- "@carbon/themes": "^11.69.0-rc.0",
82
+ "@carbon/themes": "^11.69.0",
83
83
  "@figma/code-connect": "^1.3.13",
84
84
  "@rollup/plugin-babel": "^6.0.0",
85
85
  "@rollup/plugin-commonjs": "^28.0.3",
@@ -131,5 +131,5 @@
131
131
  "**/*.scss",
132
132
  "**/*.css"
133
133
  ],
134
- "gitHead": "be65faf18c90ab4e6e60afdfad77d412220bd077"
134
+ "gitHead": "4f48ac426be7302a57460b1c81d74dd5d6071ad6"
135
135
  }