@carbon/react 1.84.0-rc.0 → 1.85.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +943 -943
- package/es/components/AILabel/index.js +6 -1
- package/es/components/Checkbox/Checkbox.d.ts +2 -2
- package/es/components/Checkbox/Checkbox.js +8 -8
- package/es/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/es/components/CheckboxGroup/CheckboxGroup.js +9 -8
- package/es/components/CodeSnippet/CodeSnippet.js +2 -4
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +8 -7
- package/es/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.js +34 -12
- package/es/components/ContainedList/ContainedList.d.ts +1 -1
- package/es/components/ContainedList/ContainedList.js +4 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +6 -5
- package/es/components/DataTable/DataTable.js +3 -0
- package/es/components/DataTable/TableDecoratorRow.d.ts +2 -2
- package/es/components/DataTable/TableDecoratorRow.js +8 -8
- package/es/components/DataTable/TableExpandRow.d.ts +1 -1
- package/es/components/DataTable/TableExpandRow.js +15 -6
- package/es/components/DataTable/TableHeader.js +10 -10
- package/es/components/DataTable/TableRow.js +12 -4
- package/es/components/DataTable/tools/normalize.js +2 -1
- package/es/components/DatePickerInput/DatePickerInput.js +8 -7
- package/es/components/Dialog/index.d.ts +5 -1
- package/es/components/Dialog/index.js +20 -0
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +8 -10
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.js +2 -2
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/Layer/index.d.ts +1 -3
- package/es/components/Layer/index.js +9 -8
- package/es/components/Menu/Menu.js +0 -6
- package/es/components/Modal/Modal.d.ts +2 -2
- package/es/components/Modal/Modal.js +39 -11
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +29 -7
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +8 -7
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +9 -8
- package/es/components/OverflowMenu/OverflowMenu.js +4 -5
- package/es/components/PageHeader/PageHeader.d.ts +10 -9
- package/es/components/PageHeader/PageHeader.js +94 -34
- package/es/components/PageHeader/index.d.ts +2 -2
- package/es/components/PageHeader/index.js +1 -1
- package/es/components/Popover/index.js +2 -1
- package/es/components/RadioButton/RadioButton.d.ts +2 -2
- package/es/components/RadioButton/RadioButton.js +8 -8
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
- package/es/components/RadioTile/RadioTile.d.ts +1 -1
- package/es/components/RadioTile/RadioTile.js +8 -7
- package/es/components/Search/Search.js +0 -1
- package/es/components/Select/Select.d.ts +2 -2
- package/es/components/Select/Select.js +8 -7
- package/es/components/Slider/Slider.js +6 -0
- package/es/components/Tag/DismissibleTag.d.ts +1 -1
- package/es/components/Tag/DismissibleTag.js +9 -8
- package/es/components/Tag/Tag.d.ts +1 -1
- package/es/components/Tag/Tag.js +9 -8
- package/es/components/TextArea/TextArea.js +12 -11
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +20 -9
- package/es/components/Tile/Tile.d.ts +2 -2
- package/es/components/Tile/Tile.js +30 -36
- package/es/components/TileGroup/TileGroup.d.ts +4 -4
- package/es/components/TileGroup/TileGroup.js +45 -53
- package/es/components/TileGroup/index.d.ts +3 -3
- package/es/components/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/TreeView/TreeNode.js +3 -3
- package/es/components/TreeView/TreeView.js +3 -3
- package/es/components/UIShell/Content.d.ts +5 -3
- package/es/components/UIShell/HeaderMenuItem.js +2 -1
- package/es/components/UIShell/HeaderPanel.d.ts +2 -2
- package/es/components/UIShell/HeaderPanel.js +9 -5
- package/es/index.js +1 -1
- package/es/internal/Selection.js +8 -3
- package/es/internal/environment.js +1 -12
- package/es/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
- package/es/internal/useOverflowItems.d.ts +29 -0
- package/es/internal/useOverflowItems.js +122 -0
- package/es/internal/useResizeObserver.d.ts +1 -1
- package/es/internal/utils.d.ts +14 -0
- package/es/internal/utils.js +18 -0
- package/es/tools/uniqueId.d.ts +1 -6
- package/lib/components/AILabel/index.js +6 -1
- package/lib/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/components/Checkbox/Checkbox.js +7 -7
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
- package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +11 -10
- package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +35 -13
- package/lib/components/ContainedList/ContainedList.d.ts +1 -1
- package/lib/components/ContainedList/ContainedList.js +4 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
- package/lib/components/DataTable/DataTable.js +3 -0
- package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
- package/lib/components/DataTable/TableDecoratorRow.js +8 -8
- package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
- package/lib/components/DataTable/TableExpandRow.js +14 -5
- package/lib/components/DataTable/TableHeader.js +9 -9
- package/lib/components/DataTable/TableRow.js +11 -3
- package/lib/components/DataTable/tools/normalize.js +2 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
- package/lib/components/Dialog/index.d.ts +5 -1
- package/lib/components/Dialog/index.js +20 -0
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +12 -14
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/Layer/index.d.ts +1 -3
- package/lib/components/Layer/index.js +9 -8
- package/lib/components/Menu/Menu.js +0 -6
- package/lib/components/Modal/Modal.d.ts +2 -2
- package/lib/components/Modal/Modal.js +47 -19
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +33 -11
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +13 -12
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +8 -7
- package/lib/components/OverflowMenu/OverflowMenu.js +4 -5
- package/lib/components/PageHeader/PageHeader.d.ts +10 -9
- package/lib/components/PageHeader/PageHeader.js +92 -34
- package/lib/components/PageHeader/index.d.ts +2 -2
- package/lib/components/PageHeader/index.js +0 -2
- package/lib/components/Popover/index.js +2 -1
- package/lib/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/components/RadioButton/RadioButton.js +7 -7
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
- package/lib/components/RadioTile/RadioTile.d.ts +1 -1
- package/lib/components/RadioTile/RadioTile.js +7 -6
- package/lib/components/Search/Search.js +0 -1
- package/lib/components/Select/Select.d.ts +2 -2
- package/lib/components/Select/Select.js +7 -6
- package/lib/components/Slider/Slider.js +6 -0
- package/lib/components/Tag/DismissibleTag.d.ts +1 -1
- package/lib/components/Tag/DismissibleTag.js +8 -7
- package/lib/components/Tag/Tag.d.ts +1 -1
- package/lib/components/Tag/Tag.js +8 -7
- package/lib/components/TextArea/TextArea.js +11 -10
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +19 -8
- package/lib/components/Tile/Tile.d.ts +2 -2
- package/lib/components/Tile/Tile.js +29 -35
- package/lib/components/TileGroup/TileGroup.d.ts +4 -4
- package/lib/components/TileGroup/TileGroup.js +44 -52
- package/lib/components/TileGroup/index.d.ts +3 -3
- package/lib/components/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/TreeView/TreeNode.js +3 -3
- package/lib/components/TreeView/TreeView.js +3 -3
- package/lib/components/UIShell/Content.d.ts +5 -3
- package/lib/components/UIShell/HeaderMenuItem.js +2 -1
- package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
- package/lib/components/UIShell/HeaderPanel.js +8 -4
- package/lib/index.js +1 -1
- package/lib/internal/Selection.js +8 -3
- package/lib/internal/environment.js +1 -12
- package/lib/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
- package/lib/internal/useOverflowItems.d.ts +29 -0
- package/lib/internal/useOverflowItems.js +126 -0
- package/lib/internal/useResizeObserver.d.ts +1 -1
- package/lib/internal/utils.d.ts +14 -0
- package/lib/internal/utils.js +22 -0
- package/lib/tools/uniqueId.d.ts +1 -6
- package/package.json +14 -23
- package/telemetry.yml +3 -0
- package/es/tools/uniqueId.js +0 -14
- package/lib/tools/uniqueId.js +0 -18
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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 { useRef, useState, useMemo, useEffect } from 'react';
|
|
9
|
+
import { useResizeObserver } from './useResizeObserver.js';
|
|
10
|
+
import { usePreviousValue } from './usePreviousValue.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Manages overflow items in a container by automatically hiding items that don't fit.
|
|
14
|
+
* @param items - Array of items to manage for overflow, each must have an `id` property.
|
|
15
|
+
* @param containerRef - React ref to the container element that holds the items.
|
|
16
|
+
* @param offsetRef - Optional ref to an offset element (like a "more" button) whose width is reserved when calculating available space.
|
|
17
|
+
* @param maxItems - Optional maximum number of visible items. If undefined, only container space constrains visibility.
|
|
18
|
+
* @param onChange - Optional callback called when hidden items change. Receives array of currently hidden items.
|
|
19
|
+
* @returns Object with `visibleItems` (items to display), `hiddenItems` (items that don't fit), and `itemRefHandler` (function to attach refs to items for width measurement).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) => {
|
|
23
|
+
const itemsRef = useRef(null);
|
|
24
|
+
const [maxWidth, setMaxWidth] = useState(0);
|
|
25
|
+
if (!items || !Array.isArray(items)) {
|
|
26
|
+
return {
|
|
27
|
+
visibleItems: [],
|
|
28
|
+
hiddenItems: [],
|
|
29
|
+
itemRefHandler: () => {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const handleResize = () => {
|
|
33
|
+
if (containerRef.current) {
|
|
34
|
+
const offset = offsetRef?.current?.offsetWidth || 0;
|
|
35
|
+
const newMax = containerRef.current.offsetWidth - offset;
|
|
36
|
+
setMaxWidth(newMax);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
useResizeObserver({
|
|
40
|
+
ref: containerRef,
|
|
41
|
+
onResize: handleResize
|
|
42
|
+
});
|
|
43
|
+
const getMap = () => {
|
|
44
|
+
if (!itemsRef.current) {
|
|
45
|
+
itemsRef.current = new Map();
|
|
46
|
+
}
|
|
47
|
+
return itemsRef.current;
|
|
48
|
+
};
|
|
49
|
+
const itemRefHandler = (id, node) => {
|
|
50
|
+
const map = getMap();
|
|
51
|
+
if (node) {
|
|
52
|
+
const style = getComputedStyle?.(node);
|
|
53
|
+
const totalWidth = node.offsetWidth + parseInt(style.marginLeft) + parseInt(style.marginRight);
|
|
54
|
+
map.set(id, totalWidth);
|
|
55
|
+
}
|
|
56
|
+
return () => {
|
|
57
|
+
map.delete(id);
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const getVisibleItems = () => {
|
|
61
|
+
if (!items || Array.isArray(items) === false) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
if (!containerRef) {
|
|
65
|
+
return items;
|
|
66
|
+
}
|
|
67
|
+
const map = getMap();
|
|
68
|
+
let maxReached = false;
|
|
69
|
+
let accumulatedWidth = 0;
|
|
70
|
+
const visibleItems = items.slice(0, maxItems).reduce((prev, cur) => {
|
|
71
|
+
if (maxReached) {
|
|
72
|
+
return prev;
|
|
73
|
+
}
|
|
74
|
+
const itemWidth = map.get(cur.id) || 0;
|
|
75
|
+
const willFit = accumulatedWidth + itemWidth <= maxWidth;
|
|
76
|
+
if (willFit) {
|
|
77
|
+
accumulatedWidth += itemWidth;
|
|
78
|
+
prev.push(cur);
|
|
79
|
+
} else {
|
|
80
|
+
maxReached = true;
|
|
81
|
+
}
|
|
82
|
+
return prev;
|
|
83
|
+
}, []);
|
|
84
|
+
return visibleItems;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Memoize visible items calculation to avoid recalculating on every render
|
|
88
|
+
const visibleItems = useMemo(() => {
|
|
89
|
+
if (!Array.isArray(items)) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
return getVisibleItems();
|
|
93
|
+
}, [items, maxWidth, maxItems]);
|
|
94
|
+
|
|
95
|
+
// Memoize hidden items calculation
|
|
96
|
+
const hiddenItems = useMemo(() => {
|
|
97
|
+
if (!Array.isArray(items)) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return items.slice(visibleItems.length);
|
|
101
|
+
}, [items, visibleItems]);
|
|
102
|
+
|
|
103
|
+
// Use previous value to compare and only call onChange when needed
|
|
104
|
+
const previousHiddenItems = usePreviousValue(hiddenItems);
|
|
105
|
+
|
|
106
|
+
// Only call onChange if hidden items actually changed
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (previousHiddenItems && onChange) {
|
|
109
|
+
const hasChanged = hiddenItems.length !== previousHiddenItems.length || hiddenItems.some((item, index) => item !== previousHiddenItems[index]);
|
|
110
|
+
if (hasChanged) {
|
|
111
|
+
onChange(hiddenItems);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, [hiddenItems, previousHiddenItems, onChange]);
|
|
115
|
+
return {
|
|
116
|
+
visibleItems,
|
|
117
|
+
itemRefHandler,
|
|
118
|
+
hiddenItems
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { useOverflowItems as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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 { type ComponentType, type ReactElement, type ReactNode } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* Checks if an element is a valid React element of a given component type.
|
|
10
|
+
*
|
|
11
|
+
* @param element - The element to test.
|
|
12
|
+
* @param component - The component to match.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isComponentElement: <P>(element: ReactNode, component: ComponentType<P>) => element is ReactElement<P>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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 { isValidElement } from 'react';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if an element is a valid React element of a given component type.
|
|
12
|
+
*
|
|
13
|
+
* @param element - The element to test.
|
|
14
|
+
* @param component - The component to match.
|
|
15
|
+
*/
|
|
16
|
+
const isComponentElement = (element, component) => /*#__PURE__*/isValidElement(element) && element.type === component;
|
|
17
|
+
|
|
18
|
+
export { isComponentElement };
|
package/es/tools/uniqueId.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Copyright IBM Corp. 2016, 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
|
-
*/
|
|
1
|
+
export declare const uniqueIdDeprecationMessage = "The `uniqueId()` helper function from @carbon/react was called. This function should no longer be used.\n\n@carbon/react components should use the internal/useId.js hook instead. Other projects can use React's `useId()` hook: https://react.dev/reference/react/useId";
|
|
7
2
|
export declare const uniqueId: (prefix?: string) => string;
|
|
@@ -37,7 +37,12 @@ const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
37
37
|
const prefix = usePrefix.usePrefix();
|
|
38
38
|
const hasAILabelActions = React__default["default"].Children.toArray(children).some(child => {
|
|
39
39
|
const item = child;
|
|
40
|
-
|
|
40
|
+
// TODO: Is there supposed to be a `return` here? If so, this issue would
|
|
41
|
+
// have been caught by ESLint. It's concerning that this code is 7 months
|
|
42
|
+
// old and no one has noticed any issues with it. It also makes me question
|
|
43
|
+
// whether the code is necessary.
|
|
44
|
+
// https://github.com/carbon-design-system/carbon/issues/18991
|
|
45
|
+
item.type === AILabelActions;
|
|
41
46
|
});
|
|
42
47
|
const aiLabelContentClasses = cx__default["default"](className, {
|
|
43
48
|
[`${prefix}--ai-label-content`]: true,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
8
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type';
|
|
9
9
|
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
10
10
|
/**
|
|
@@ -19,6 +19,8 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
19
19
|
var iconsReact = require('@carbon/icons-react');
|
|
20
20
|
var useId = require('../../internal/useId.js');
|
|
21
21
|
var noopFn = require('../../internal/noopFn.js');
|
|
22
|
+
var index = require('../AILabel/index.js');
|
|
23
|
+
var utils = require('../../internal/utils.js');
|
|
22
24
|
var Text = require('../Text/Text.js');
|
|
23
25
|
|
|
24
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -65,13 +67,11 @@ const Checkbox = /*#__PURE__*/React__default["default"].forwardRef(({
|
|
|
65
67
|
const innerLabelClasses = cx__default["default"](`${prefix}--checkbox-label-text`, {
|
|
66
68
|
[`${prefix}--visually-hidden`]: hideLabel
|
|
67
69
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
}
|
|
70
|
+
const candidate = slug ?? decorator;
|
|
71
|
+
const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
|
|
72
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
73
|
+
size: candidate.props.kind === 'inline' ? 'md' : 'mini'
|
|
74
|
+
}) : null;
|
|
75
75
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
76
76
|
className: wrapperClasses
|
|
77
77
|
}, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { type ReactNode } from 'react';
|
|
8
8
|
export interface CheckboxGroupProps {
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
className?: string;
|
|
@@ -17,6 +17,8 @@ var deprecate = require('../../prop-types/deprecate.js');
|
|
|
17
17
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
19
|
var useId = require('../../internal/useId.js');
|
|
20
|
+
var index = require('../AILabel/index.js');
|
|
21
|
+
var utils = require('../../internal/utils.js');
|
|
20
22
|
|
|
21
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
24
|
|
|
@@ -59,13 +61,12 @@ const CheckboxGroup = ({
|
|
|
59
61
|
});
|
|
60
62
|
|
|
61
63
|
// AILabel always size `mini`
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
64
|
+
const candidate = slug ?? decorator;
|
|
65
|
+
const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
|
|
66
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
67
|
+
size: 'mini',
|
|
68
|
+
kind: 'default'
|
|
69
|
+
}) : null;
|
|
69
70
|
return /*#__PURE__*/React__default["default"].createElement("fieldset", _rollupPluginBabelHelpers["extends"]({
|
|
70
71
|
className: fieldsetClasses,
|
|
71
72
|
"data-invalid": invalid ? true : undefined,
|
|
@@ -19,7 +19,7 @@ var Copy = require('../Copy/Copy.js');
|
|
|
19
19
|
var Button = require('../Button/Button.js');
|
|
20
20
|
require('../Button/Button.Skeleton.js');
|
|
21
21
|
var CopyButton = require('../CopyButton/CopyButton.js');
|
|
22
|
-
var
|
|
22
|
+
var useId = require('../../internal/useId.js');
|
|
23
23
|
var copy = require('copy-to-clipboard');
|
|
24
24
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
25
25
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
@@ -67,7 +67,7 @@ function CodeSnippet({
|
|
|
67
67
|
const [shouldShowMoreLessBtn, setShouldShowMoreLessBtn] = React.useState(false);
|
|
68
68
|
const {
|
|
69
69
|
current: uid
|
|
70
|
-
} = React.useRef(
|
|
70
|
+
} = React.useRef(useId.useId());
|
|
71
71
|
const codeContentRef = React.useRef(null);
|
|
72
72
|
const codeContainerRef = React.useRef(null);
|
|
73
73
|
const innerCodeRef = React.useRef(null);
|
|
@@ -111,8 +111,6 @@ function CodeSnippet({
|
|
|
111
111
|
setHasRightOverflow(horizontalOverflow && codeScrollLeft + codeClientWidth !== codeScrollWidth);
|
|
112
112
|
}, [type, getCodeRefDimensions]);
|
|
113
113
|
useResizeObserver.useResizeObserver({
|
|
114
|
-
// Cast the ref until the hook supports React 19
|
|
115
|
-
// https://github.com/ZeeCoder/use-resize-observer/issues/108
|
|
116
114
|
ref: getCodeRef(),
|
|
117
115
|
onResize: () => {
|
|
118
116
|
if (codeContentRef?.current && type === 'multi') {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { UseComboboxProps, UseComboboxActions } from 'downshift';
|
|
8
|
-
import React, { type
|
|
8
|
+
import React, { type ComponentType, type InputHTMLAttributes, type MouseEvent, type PropsWithChildren, type PropsWithRef, type ReactElement, type ReactNode, type RefAttributes } from 'react';
|
|
9
9
|
import { type ListBoxSize } from '../ListBox';
|
|
10
10
|
import { TranslateWithId } from '../../types/common';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
@@ -17,7 +17,7 @@ var React = require('react');
|
|
|
17
17
|
require('../Text/index.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
19
|
var isEqual = require('react-fast-compare');
|
|
20
|
-
var index$
|
|
20
|
+
var index$2 = require('../ListBox/index.js');
|
|
21
21
|
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
22
22
|
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
23
23
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -30,6 +30,8 @@ require('../FluidForm/FluidForm.js');
|
|
|
30
30
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
31
31
|
var react = require('@floating-ui/react');
|
|
32
32
|
var index = require('../FeatureFlags/index.js');
|
|
33
|
+
var index$1 = require('../AILabel/index.js');
|
|
34
|
+
var utils = require('../../internal/utils.js');
|
|
33
35
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
34
36
|
var Text = require('../Text/Text.js');
|
|
35
37
|
|
|
@@ -448,12 +450,11 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
448
450
|
const ItemToElement = itemToElement;
|
|
449
451
|
|
|
450
452
|
// AILabel always size `mini`
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
453
|
+
const candidate = slug ?? decorator;
|
|
454
|
+
const candidateIsAILabel = utils.isComponentElement(candidate, index$1.AILabel);
|
|
455
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
456
|
+
size: 'mini'
|
|
457
|
+
}) : null;
|
|
457
458
|
const {
|
|
458
459
|
// Prop getters
|
|
459
460
|
getInputProps,
|
|
@@ -604,7 +605,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
604
605
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
605
606
|
as: "label",
|
|
606
607
|
className: titleClasses
|
|
607
|
-
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$
|
|
608
|
+
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$2["default"], {
|
|
608
609
|
onFocus: handleFocus,
|
|
609
610
|
onBlur: handleFocus,
|
|
610
611
|
className: className,
|
|
@@ -728,7 +729,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
728
729
|
translateWithId: translateWithId
|
|
729
730
|
}))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
730
731
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
731
|
-
}, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(index$
|
|
732
|
+
}, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(index$2["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
732
733
|
const isObject = item !== null && typeof item === 'object';
|
|
733
734
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
734
735
|
const itemProps = getItemProps({
|
|
@@ -746,7 +747,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
746
747
|
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
747
748
|
...modifiedItemProps
|
|
748
749
|
} = itemProps;
|
|
749
|
-
return /*#__PURE__*/React__default["default"].createElement(index$
|
|
750
|
+
return /*#__PURE__*/React__default["default"].createElement(index$2["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
750
751
|
key: itemProps.id,
|
|
751
752
|
isActive: selectedItem === item,
|
|
752
753
|
isHighlighted: highlightedIndex === index,
|
|
@@ -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, { type
|
|
7
|
+
import React, { type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject } from 'react';
|
|
8
8
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
9
|
/** Specify the content to be placed in the ModalBody. */
|
|
10
10
|
children?: ReactNode;
|
|
@@ -28,8 +28,10 @@ var match = require('../../internal/keyboard/match.js');
|
|
|
28
28
|
var index$1 = require('../FeatureFlags/index.js');
|
|
29
29
|
var events = require('../../tools/events.js');
|
|
30
30
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
31
|
-
var index$
|
|
31
|
+
var index$3 = require('../Dialog/index.js');
|
|
32
32
|
var warning = require('../../internal/warning.js');
|
|
33
|
+
var index$2 = require('../AILabel/index.js');
|
|
34
|
+
var utils = require('../../internal/utils.js');
|
|
33
35
|
var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
|
|
34
36
|
|
|
35
37
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -178,7 +180,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
178
180
|
} = evt;
|
|
179
181
|
const mouseDownTarget = onMouseDownTarget.current;
|
|
180
182
|
evt.stopPropagation();
|
|
181
|
-
|
|
183
|
+
const containsModalFooter = React.Children.toArray(childrenWithProps).some(child => utils.isComponentElement(child, ModalFooter.ModalFooter));
|
|
184
|
+
const isPassive = !containsModalFooter;
|
|
185
|
+
const shouldCloseOnOutsideClick = isPassive ? preventCloseOnClickOutside !== false : preventCloseOnClickOutside === true;
|
|
186
|
+
if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
|
|
182
187
|
closeModal(evt);
|
|
183
188
|
}
|
|
184
189
|
}
|
|
@@ -186,7 +191,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
186
191
|
target: oldActiveNode,
|
|
187
192
|
relatedTarget: currentActiveNode
|
|
188
193
|
}) {
|
|
189
|
-
if (open && currentActiveNode && oldActiveNode && innerModal.current) {
|
|
194
|
+
if (!enableDialogElement && !focusTrapWithoutSentinels && open && currentActiveNode && oldActiveNode && innerModal.current) {
|
|
190
195
|
const {
|
|
191
196
|
current: bodyNode
|
|
192
197
|
} = innerModal;
|
|
@@ -205,6 +210,23 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
205
210
|
selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean)
|
|
206
211
|
});
|
|
207
212
|
}
|
|
213
|
+
|
|
214
|
+
// Adjust scroll if needed so that element with focus is not obscured by gradient
|
|
215
|
+
const modalContent = document.querySelector(`.${prefix}--modal-content`);
|
|
216
|
+
if (!modalContent || !modalContent.classList.contains(`${prefix}--modal-scroll-content`) || !currentActiveNode || !modalContent.contains(currentActiveNode)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const lastContent = modalContent.children[modalContent.children.length - 1];
|
|
220
|
+
const gradientSpacing = modalContent.scrollHeight - lastContent.offsetTop - lastContent.clientHeight;
|
|
221
|
+
for (let elem of modalContent.children) {
|
|
222
|
+
if (elem.contains(currentActiveNode)) {
|
|
223
|
+
const spaceBelow = modalContent.clientHeight - elem.offsetTop + modalContent.scrollTop - elem.clientHeight;
|
|
224
|
+
if (spaceBelow < gradientSpacing) {
|
|
225
|
+
modalContent.scrollTop = modalContent.scrollTop + (gradientSpacing - spaceBelow);
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
208
230
|
}
|
|
209
231
|
function closeModal(evt) {
|
|
210
232
|
if (!onClose || onClose(evt) !== false) {
|
|
@@ -247,10 +269,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
247
269
|
React.useEffect(() => {
|
|
248
270
|
if (!enableDialogElement && !open && launcherButtonRef) {
|
|
249
271
|
setTimeout(() => {
|
|
250
|
-
launcherButtonRef
|
|
272
|
+
launcherButtonRef.current?.focus();
|
|
251
273
|
});
|
|
252
274
|
}
|
|
253
|
-
}, [open, launcherButtonRef]);
|
|
275
|
+
}, [enableDialogElement, open, launcherButtonRef]);
|
|
254
276
|
React.useEffect(() => {
|
|
255
277
|
if (!enableDialogElement) {
|
|
256
278
|
const initialFocus = focusContainerElement => {
|
|
@@ -277,14 +299,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
277
299
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
278
300
|
|
|
279
301
|
// AILabel is always size `sm`
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const modalBody = enableDialogElement ? /*#__PURE__*/React__default["default"].createElement(index$2.unstable__Dialog, {
|
|
302
|
+
const candidate = slug ?? decorator;
|
|
303
|
+
const candidateIsAILabel = utils.isComponentElement(candidate, index$2.AILabel);
|
|
304
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
305
|
+
size: 'sm'
|
|
306
|
+
}) : null;
|
|
307
|
+
const modalBody = enableDialogElement ? /*#__PURE__*/React__default["default"].createElement(index$3.unstable__Dialog, {
|
|
287
308
|
open: open,
|
|
309
|
+
focusAfterCloseRef: launcherButtonRef,
|
|
288
310
|
modal: true,
|
|
289
311
|
className: containerClass,
|
|
290
312
|
"aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
|
|
@@ -319,7 +341,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
319
341
|
role: "presentation",
|
|
320
342
|
ref: ref,
|
|
321
343
|
"aria-hidden": !open,
|
|
322
|
-
onBlur:
|
|
344
|
+
onBlur: handleBlur,
|
|
323
345
|
onClick: events.composeEventHandlers([rest?.onClick, handleOnClick]),
|
|
324
346
|
onMouseDown: events.composeEventHandlers([rest?.onMouseDown, handleOnMouseDown]),
|
|
325
347
|
onKeyDown: handleKeyDown,
|
|
@@ -17,6 +17,8 @@ var index = require('../Layout/index.js');
|
|
|
17
17
|
var useId = require('../../internal/useId.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
19
|
var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
|
|
20
|
+
var Search = require('../Search/Search.js');
|
|
21
|
+
require('../Search/Search.Skeleton.js');
|
|
20
22
|
|
|
21
23
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
24
|
|
|
@@ -37,13 +39,13 @@ function filterChildren(children) {
|
|
|
37
39
|
function renderChildren(children) {
|
|
38
40
|
if (Array.isArray(children)) {
|
|
39
41
|
children.map((child, index) => {
|
|
40
|
-
if (index === 0 && child.type
|
|
42
|
+
if (index === 0 && child.type === Search["default"]) {
|
|
41
43
|
return child;
|
|
42
44
|
}
|
|
43
45
|
return child;
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
|
-
if (children && children.type
|
|
48
|
+
if (children && children.type === Search["default"]) {
|
|
47
49
|
return children;
|
|
48
50
|
}
|
|
49
51
|
return children;
|
|
@@ -21,6 +21,8 @@ var match = require('../../internal/keyboard/match.js');
|
|
|
21
21
|
var navigation = require('../../internal/keyboard/navigation.js');
|
|
22
22
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
23
|
var noopFn = require('../../internal/noopFn.js');
|
|
24
|
+
require('../Switch/Switch.js');
|
|
25
|
+
var IconSwitch = require('../Switch/IconSwitch.js');
|
|
24
26
|
|
|
25
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
26
28
|
|
|
@@ -89,10 +91,9 @@ const ContentSwitcher = ({
|
|
|
89
91
|
onChange(event);
|
|
90
92
|
}
|
|
91
93
|
};
|
|
92
|
-
const isIconOnly =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
child => child.type.displayName === 'IconSwitch');
|
|
94
|
+
const isIconOnly = React.Children.map(children, child => {
|
|
95
|
+
return /*#__PURE__*/React.isValidElement(child) ? child.type === IconSwitch["default"] : null;
|
|
96
|
+
})?.every(val => val === true);
|
|
96
97
|
const classes = cx__default["default"](`${prefix}--content-switcher`, className, {
|
|
97
98
|
[`${prefix}--content-switcher--light`]: light,
|
|
98
99
|
[`${prefix}--content-switcher--${size}`]: size,
|
|
@@ -185,6 +185,7 @@ class DataTable extends React.Component {
|
|
|
185
185
|
return {
|
|
186
186
|
...rest,
|
|
187
187
|
key: row.id,
|
|
188
|
+
onClick,
|
|
188
189
|
// Compose the event handlers so we don't overwrite a consumer's `onClick`
|
|
189
190
|
// handler
|
|
190
191
|
onExpand: events.composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
|
|
@@ -307,6 +308,8 @@ class DataTable extends React.Component {
|
|
|
307
308
|
useStaticWidth
|
|
308
309
|
};
|
|
309
310
|
});
|
|
311
|
+
// TODO: `getHeaderProps` and `getRowProps` return `key` props. Would it be
|
|
312
|
+
// beneficial for this function to also return a `key` prop?
|
|
310
313
|
/**
|
|
311
314
|
* Get the props associated with the given table cell.
|
|
312
315
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { ReactNode } from 'react';
|
|
8
|
+
import { type ReactNode } from 'react';
|
|
9
9
|
export interface TableDecoratorRowProps {
|
|
10
10
|
/**
|
|
11
11
|
* The CSS class names of the cell that wraps the underlying input control
|
|
@@ -9,16 +9,18 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
+
var cx = require('classnames');
|
|
12
13
|
var PropTypes = require('prop-types');
|
|
13
14
|
var React = require('react');
|
|
14
|
-
var cx = require('classnames');
|
|
15
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
16
|
+
var index = require('../AILabel/index.js');
|
|
17
|
+
var utils = require('../../internal/utils.js');
|
|
16
18
|
|
|
17
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
20
|
|
|
21
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
19
22
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
20
23
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
22
24
|
|
|
23
25
|
const TableDecoratorRow = ({
|
|
24
26
|
className,
|
|
@@ -32,12 +34,10 @@ const TableDecoratorRow = ({
|
|
|
32
34
|
[`${prefix}--table-column-decorator`]: true,
|
|
33
35
|
[`${prefix}--table-column-decorator--active`]: decorator
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
}
|
|
37
|
+
const decoratorIsAILabel = utils.isComponentElement(decorator, index.AILabel);
|
|
38
|
+
const normalizedDecorator = decoratorIsAILabel ? /*#__PURE__*/React.cloneElement(decorator, {
|
|
39
|
+
size: 'mini'
|
|
40
|
+
}) : null;
|
|
41
41
|
return /*#__PURE__*/React__default["default"].createElement("td", {
|
|
42
42
|
className: TableDecoratorRowClasses
|
|
43
43
|
}, normalizedDecorator);
|