@carbon/react 1.101.0-rc.0 → 1.102.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 +1009 -974
- package/es/components/Accordion/AccordionItem.js +8 -6
- package/es/components/ComboBox/ComboBox.js +10 -5
- package/es/components/ComposedModal/ComposedModal.js +0 -1
- package/es/components/ContainedList/ContainedList.d.ts +1 -1
- package/es/components/ContainedList/ContainedList.js +9 -34
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +3 -3
- package/es/components/ContentSwitcher/ContentSwitcher.js +1 -2
- package/es/components/DataTable/DataTable.d.ts +6 -2
- package/es/components/DataTable/DataTable.js +3 -1
- package/es/components/DataTable/Table.js +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +11 -2
- package/es/components/DataTable/TableToolbarSearch.js +10 -3
- package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +3 -0
- package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +2 -12
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -8
- package/es/components/DatePicker/DatePicker.js +4 -1
- package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -5
- package/es/components/DatePickerInput/DatePickerInput.js +2 -13
- package/es/components/Dropdown/Dropdown.js +5 -4
- package/es/components/ExpandableSearch/ExpandableSearch.js +2 -1
- package/es/components/ExpandableSearch/index.js +12 -0
- package/es/components/FluidSelect/FluidSelect.d.ts +3 -3
- package/es/components/FluidTextArea/FluidTextArea.d.ts +2 -4
- package/es/components/FluidTextArea/FluidTextArea.js +1 -2
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +3 -3
- package/es/components/Grid/Column.d.ts +1 -1
- package/es/components/Grid/Column.js +2 -2
- package/es/components/ListBox/test-helpers.d.ts +71 -0
- package/es/components/Loading/Loading.d.ts +1 -1
- package/es/components/Loading/Loading.js +3 -1
- package/es/components/Menu/Menu.d.ts +1 -1
- package/es/components/Menu/Menu.js +6 -2
- package/es/components/Menu/MenuItem.js +2 -2
- package/es/components/Modal/Modal.js +0 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +5 -4
- package/es/components/MultiSelect/MultiSelect.js +6 -9
- package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +6 -8
- package/es/components/MultiSelect/tools/sorting.d.ts +16 -9
- package/es/components/MultiSelect/tools/sorting.js +10 -14
- package/es/components/NumberInput/NumberInput.js +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +1 -0
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +5 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -2
- package/es/components/Popover/index.js +4 -4
- package/es/components/ProgressIndicator/ProgressIndicator.d.ts +1 -1
- package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -11
- package/es/components/Search/Search.d.ts +1 -1
- package/es/components/Search/Search.js +3 -2
- package/es/components/Search/utils.d.ts +7 -0
- package/es/components/Search/utils.js +10 -0
- package/es/components/Select/Select.d.ts +2 -2
- package/es/components/Select/Select.js +2 -2
- package/es/components/SelectItem/SelectItem.d.ts +3 -3
- package/es/components/StructuredList/StructuredList.js +2 -2
- package/es/components/Tabs/Tabs.js +9 -4
- package/es/components/Tag/DismissibleTag.d.ts +1 -1
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +1 -1
- package/es/components/Tag/OperationalTag.js +2 -2
- package/es/components/Tag/SelectableTag.d.ts +1 -1
- package/es/components/Tag/SelectableTag.js +2 -2
- package/es/components/Tag/Tag.d.ts +1 -1
- package/es/components/Tag/Tag.js +2 -2
- package/es/components/TextArea/TextArea.d.ts +2 -3
- package/es/components/TextArea/TextArea.js +4 -5
- package/es/components/TextInput/ControlledPasswordInput.js +1 -1
- package/es/components/TimePickerSelect/TimePickerSelect.d.ts +4 -4
- package/es/components/Toggletip/index.js +1 -2
- package/es/components/TreeView/TreeNode.js +2 -2
- package/es/components/TreeView/TreeView.d.ts +1 -1
- package/es/components/UIShell/HeaderPanel.d.ts +1 -1
- package/es/components/UIShell/HeaderPanel.js +4 -2
- package/es/components/UIShell/SideNav.js +3 -3
- package/es/components/UIShell/Switcher.d.ts +1 -1
- package/es/components/UIShell/Switcher.js +1 -1
- package/es/feature-flags.js +2 -2
- package/es/internal/FloatingMenu.js +3 -3
- package/lib/components/Accordion/AccordionItem.js +7 -5
- package/lib/components/ComboBox/ComboBox.js +10 -5
- package/lib/components/ComposedModal/ComposedModal.js +0 -1
- package/lib/components/ContainedList/ContainedList.d.ts +1 -1
- package/lib/components/ContainedList/ContainedList.js +9 -34
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +3 -3
- package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -2
- package/lib/components/DataTable/DataTable.d.ts +6 -2
- package/lib/components/DataTable/DataTable.js +3 -1
- package/lib/components/DataTable/Table.js +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +11 -2
- package/lib/components/DataTable/TableToolbarSearch.js +10 -3
- package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +3 -0
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +2 -12
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -8
- package/lib/components/DatePicker/DatePicker.js +4 -1
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -5
- package/lib/components/DatePickerInput/DatePickerInput.js +2 -13
- package/lib/components/Dropdown/Dropdown.js +5 -4
- package/lib/components/ExpandableSearch/ExpandableSearch.js +2 -1
- package/lib/components/ExpandableSearch/index.js +17 -0
- package/lib/components/FeatureFlags/index.js +5 -5
- package/lib/components/FluidSelect/FluidSelect.d.ts +3 -3
- package/lib/components/FluidTextArea/FluidTextArea.d.ts +2 -4
- package/lib/components/FluidTextArea/FluidTextArea.js +1 -2
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +3 -3
- package/lib/components/Grid/Column.d.ts +1 -1
- package/lib/components/Grid/Column.js +2 -21
- package/lib/components/ListBox/test-helpers.d.ts +71 -0
- package/lib/components/Loading/Loading.d.ts +1 -1
- package/lib/components/Loading/Loading.js +3 -1
- package/lib/components/Menu/Menu.d.ts +1 -1
- package/lib/components/Menu/Menu.js +6 -2
- package/lib/components/Menu/MenuItem.js +2 -2
- package/lib/components/Modal/Modal.js +0 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +5 -4
- package/lib/components/MultiSelect/MultiSelect.js +6 -9
- package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +6 -8
- package/lib/components/MultiSelect/tools/sorting.d.ts +16 -9
- package/lib/components/MultiSelect/tools/sorting.js +10 -14
- package/lib/components/NumberInput/NumberInput.js +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -0
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +5 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -2
- package/lib/components/Popover/index.js +4 -4
- package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +1 -1
- package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -10
- package/lib/components/Search/Search.d.ts +1 -1
- package/lib/components/Search/Search.js +3 -2
- package/lib/components/Search/utils.d.ts +7 -0
- package/lib/components/Search/utils.js +12 -0
- package/lib/components/Select/Select.d.ts +2 -2
- package/lib/components/Select/Select.js +2 -2
- package/lib/components/SelectItem/SelectItem.d.ts +3 -3
- package/lib/components/StructuredList/StructuredList.js +2 -2
- package/lib/components/Tabs/Tabs.js +9 -4
- package/lib/components/Tag/DismissibleTag.d.ts +1 -1
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +1 -1
- package/lib/components/Tag/OperationalTag.js +2 -2
- package/lib/components/Tag/SelectableTag.d.ts +1 -1
- package/lib/components/Tag/SelectableTag.js +2 -2
- package/lib/components/Tag/Tag.d.ts +1 -1
- package/lib/components/Tag/Tag.js +2 -2
- package/lib/components/TextArea/TextArea.d.ts +2 -3
- package/lib/components/TextArea/TextArea.js +4 -5
- package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
- package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +4 -4
- package/lib/components/Toggletip/index.js +1 -2
- package/lib/components/TreeView/TreeNode.js +2 -2
- package/lib/components/TreeView/TreeView.d.ts +1 -1
- package/lib/components/UIShell/HeaderPanel.d.ts +1 -1
- package/lib/components/UIShell/HeaderPanel.js +4 -2
- package/lib/components/UIShell/SideNav.js +3 -3
- package/lib/components/UIShell/Switcher.d.ts +1 -1
- package/lib/components/UIShell/Switcher.js +1 -1
- package/lib/feature-flags.js +2 -21
- package/lib/internal/FloatingMenu.js +3 -22
- package/package.json +10 -10
- package/telemetry.yml +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 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.
|
|
@@ -34,17 +34,15 @@ export declare const sortingPropTypes: {
|
|
|
34
34
|
*/
|
|
35
35
|
sortItems: PropTypes.Requireable<(...args: any[]) => any>;
|
|
36
36
|
};
|
|
37
|
-
interface DownshiftTypedProps<ItemType> {
|
|
38
|
-
itemToString?(item: ItemType): string;
|
|
39
|
-
}
|
|
40
37
|
interface SharedOptions {
|
|
41
38
|
locale: string;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
export interface SortItemsOptions<ItemType> extends SharedOptions
|
|
40
|
+
export type CompareItems = (itemA: string, itemB: string, options: {
|
|
41
|
+
locale: string;
|
|
42
|
+
}) => number;
|
|
43
|
+
export interface SortItemsOptions<ItemType> extends SharedOptions {
|
|
47
44
|
compareItems: CompareItems;
|
|
45
|
+
itemToString: (item: ItemType) => string;
|
|
48
46
|
selectedItems: ItemType[];
|
|
49
47
|
}
|
|
50
48
|
export interface MultiSelectSortingProps<ItemType> {
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
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 { CompareItems, SortItemsOptions } from '../MultiSelectPropTypes';
|
|
8
|
+
/**
|
|
9
|
+
* Use `localeCompare` with the `numeric` option enabled to sort two
|
|
10
|
+
* alphanumeric strings.
|
|
11
|
+
*/
|
|
12
|
+
export declare const defaultCompareItems: CompareItems;
|
|
13
|
+
/**
|
|
14
|
+
* Default sorting function for options in a selection control.
|
|
15
|
+
*/
|
|
16
|
+
export declare const defaultSortItems: <T>(items: T[], { selectedItems, itemToString, compareItems, locale }: SortItemsOptions<T>) => T[];
|
|
@@ -7,16 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
+
const isSelectAllItem = item => typeof item === 'object' && item !== null && 'isSelectAll' in item;
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
|
-
* Use
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @param {string} itemA - The first string to compare.
|
|
15
|
-
* @param {string} itemB - The second string to compare.
|
|
16
|
-
* @param {object} options - Options for comparing.
|
|
17
|
-
* @param {string} options.locale - The locale to use for comparison.
|
|
18
|
-
* @returns {number} A negative number if itemA comes before itemB, a positive
|
|
19
|
-
* number if itemA comes after itemB, or 0 if they are equal.
|
|
13
|
+
* Use `localeCompare` with the `numeric` option enabled to sort two
|
|
14
|
+
* alphanumeric strings.
|
|
20
15
|
*/
|
|
21
16
|
const defaultCompareItems = (itemA, itemB, {
|
|
22
17
|
locale
|
|
@@ -25,18 +20,19 @@ const defaultCompareItems = (itemA, itemB, {
|
|
|
25
20
|
});
|
|
26
21
|
|
|
27
22
|
/**
|
|
28
|
-
* Default sorting
|
|
23
|
+
* Default sorting function for options in a selection control.
|
|
29
24
|
*/
|
|
30
25
|
const defaultSortItems = (items, {
|
|
31
|
-
selectedItems
|
|
26
|
+
selectedItems,
|
|
32
27
|
itemToString,
|
|
33
28
|
compareItems,
|
|
34
|
-
locale
|
|
29
|
+
locale
|
|
35
30
|
}) => {
|
|
31
|
+
// TODO: Should this util mutate items or should that be avoided?
|
|
36
32
|
return items.sort((itemA, itemB) => {
|
|
37
33
|
// Always place "select all" option at the beginning
|
|
38
|
-
if (itemA.isSelectAll) return -1;
|
|
39
|
-
if (itemB.isSelectAll) return 1;
|
|
34
|
+
if (isSelectAllItem(itemA) && itemA.isSelectAll) return -1;
|
|
35
|
+
if (isSelectAllItem(itemB) && itemB.isSelectAll) return 1;
|
|
40
36
|
const hasItemA = selectedItems.includes(itemA);
|
|
41
37
|
const hasItemB = selectedItems.includes(itemB);
|
|
42
38
|
if (hasItemA && !hasItemB) return -1;
|
|
@@ -447,7 +447,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
447
447
|
if ('type' in evt.target && evt.target.type === 'button') {
|
|
448
448
|
setIsFocused(false);
|
|
449
449
|
} else {
|
|
450
|
-
setIsFocused(evt.type === 'focus'
|
|
450
|
+
setIsFocused(evt.type === 'focus');
|
|
451
451
|
}
|
|
452
452
|
};
|
|
453
453
|
const outerElementClasses = cx(`${prefix}--form-item`, {
|
|
@@ -259,6 +259,7 @@ const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
|
259
259
|
const focusinEventName = hasFocusin ? 'focusin' : 'focus';
|
|
260
260
|
hFocusIn.current = on(menuBody.ownerDocument, focusinEventName, event => {
|
|
261
261
|
const target = event.target;
|
|
262
|
+
if (!(target instanceof Element)) return;
|
|
262
263
|
const triggerEl = triggerRef.current;
|
|
263
264
|
if (typeof target.matches === 'function') {
|
|
264
265
|
if (!menuBody.contains(target) && triggerEl && !target.matches(`.${prefix}--overflow-menu:first-child, .${prefix}--overflow-menu-options:first-child`)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 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.
|
|
@@ -14,6 +14,10 @@ export interface OverflowMenuItemProps extends React.HTMLAttributes<HTMLElement>
|
|
|
14
14
|
* A callback to tell the parent menu component that the menu should be closed.
|
|
15
15
|
*/
|
|
16
16
|
closeMenu?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Specify the message read by screen readers for the danger overflow menu item variant
|
|
19
|
+
*/
|
|
20
|
+
dangerDescription?: string;
|
|
17
21
|
/**
|
|
18
22
|
* `true` to make this menu item disabled.
|
|
19
23
|
*/
|
|
@@ -19,12 +19,14 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
19
19
|
var warning = require('../../internal/warning.js');
|
|
20
20
|
var Text = require('../Text/Text.js');
|
|
21
21
|
require('../Text/TextDirection.js');
|
|
22
|
+
var useId = require('../../internal/useId.js');
|
|
22
23
|
|
|
23
24
|
const frFn = React.forwardRef;
|
|
24
25
|
const OverflowMenuItem = frFn((props, ref) => {
|
|
25
26
|
const {
|
|
26
27
|
className,
|
|
27
28
|
closeMenu,
|
|
29
|
+
dangerDescription = 'danger',
|
|
28
30
|
disabled = false,
|
|
29
31
|
handleOverflowMenuItemFocus,
|
|
30
32
|
hasDivider = false,
|
|
@@ -68,13 +70,17 @@ const OverflowMenuItem = frFn((props, ref) => {
|
|
|
68
70
|
[`${prefix}--overflow-menu-options__option--disabled`]: disabled
|
|
69
71
|
}, wrapperClassName);
|
|
70
72
|
const TagToUse = href ? 'a' : 'button';
|
|
73
|
+
const assistiveId = useId.useId('danger-description');
|
|
71
74
|
const OverflowMenuItemContent = (() => {
|
|
72
75
|
if (typeof itemText !== 'string') {
|
|
73
76
|
return itemText;
|
|
74
77
|
}
|
|
75
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
76
79
|
className: `${prefix}--overflow-menu-options__option-content`
|
|
77
|
-
}, itemText)
|
|
80
|
+
}, itemText), isDelete && /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
id: assistiveId,
|
|
82
|
+
className: `${prefix}--visually-hidden`
|
|
83
|
+
}, dangerDescription));
|
|
78
84
|
})();
|
|
79
85
|
return /*#__PURE__*/React.createElement(Text.Text, {
|
|
80
86
|
as: "li",
|
|
@@ -114,6 +120,10 @@ OverflowMenuItem.propTypes = {
|
|
|
114
120
|
* A callback to tell the parent menu component that the menu should be closed.
|
|
115
121
|
*/
|
|
116
122
|
closeMenu: PropTypes.func,
|
|
123
|
+
/**
|
|
124
|
+
* Specify the message read by screen readers for the danger overflow menu item variant
|
|
125
|
+
*/
|
|
126
|
+
dangerDescription: PropTypes.string,
|
|
117
127
|
/**
|
|
118
128
|
* `true` to make this menu item disabled.
|
|
119
129
|
*/
|
|
@@ -42,7 +42,7 @@ const Popover = /*#__PURE__*/React.forwardRef(function PopoverRenderFunction({
|
|
|
42
42
|
autoAlign = false,
|
|
43
43
|
autoAlignBoundary,
|
|
44
44
|
backgroundToken = 'layer',
|
|
45
|
-
caret = isTabTip
|
|
45
|
+
caret = !isTabTip,
|
|
46
46
|
className: customClassName,
|
|
47
47
|
children,
|
|
48
48
|
border = false,
|
|
@@ -162,7 +162,8 @@ forwardRef) {
|
|
|
162
162
|
// Middleware order matters, arrow should be last
|
|
163
163
|
middleware: [react.offset(!isTabTip ? {
|
|
164
164
|
alignmentAxis: alignmentAxisOffset,
|
|
165
|
-
|
|
165
|
+
// Use 4px spacing when no caret, otherwise use the caret offset
|
|
166
|
+
mainAxis: caret ? popoverDimensions?.current?.offset : 4
|
|
166
167
|
} : 0), autoAlign && react.flip({
|
|
167
168
|
fallbackPlacements: isTabTip ? align.includes('bottom') ? ['bottom-start', 'bottom-end', 'top-start', 'top-end'] : ['top-start', 'top-end', 'bottom-start', 'bottom-end'] : align.includes('bottom') ? ['bottom', 'bottom-start', 'bottom-end', 'right', 'right-start', 'right-end', 'left', 'left-start', 'left-end', 'top', 'top-start', 'top-end'] : ['top', 'top-start', 'top-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end'],
|
|
168
169
|
fallbackStrategy: 'initialPlacement',
|
|
@@ -299,10 +300,9 @@ forwardRef) {
|
|
|
299
300
|
return item;
|
|
300
301
|
}
|
|
301
302
|
});
|
|
302
|
-
const BaseComponentAsAny = BaseComponent;
|
|
303
303
|
return /*#__PURE__*/React.createElement(PopoverContext.Provider, {
|
|
304
304
|
value: value
|
|
305
|
-
}, /*#__PURE__*/React.createElement(
|
|
305
|
+
}, /*#__PURE__*/React.createElement(BaseComponent, _rollupPluginBabelHelpers.extends({}, rest, {
|
|
306
306
|
className: className,
|
|
307
307
|
ref: ref
|
|
308
308
|
}), enableFloatingStyles || isTabTip ? mappedChildren : children));
|
|
@@ -47,17 +47,14 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
47
47
|
} = props;
|
|
48
48
|
const prefix = usePrefix.usePrefix();
|
|
49
49
|
const [selected, setSelected] = React.useState(valueSelected ?? defaultSelected);
|
|
50
|
-
const
|
|
50
|
+
const prevValueSelected = React.useRef(valueSelected);
|
|
51
51
|
const radioButtonGroupInstanceId = useId.useId();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
setSelected(valueSelected);
|
|
59
|
-
setPrevValueSelected(valueSelected);
|
|
60
|
-
}
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (valueSelected !== prevValueSelected.current) {
|
|
54
|
+
setSelected(valueSelected);
|
|
55
|
+
prevValueSelected.current = valueSelected;
|
|
56
|
+
}
|
|
57
|
+
}, [valueSelected]);
|
|
61
58
|
function getRadioButtons() {
|
|
62
59
|
const mappedChildren = React.Children.map(children, radioButton => {
|
|
63
60
|
if (!radioButton) {
|
|
@@ -26,6 +26,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
26
26
|
var noopFn = require('../../internal/noopFn.js');
|
|
27
27
|
require('../Tooltip/DefinitionTooltip.js');
|
|
28
28
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
29
|
+
var utils = require('./utils.js');
|
|
29
30
|
|
|
30
31
|
var _Close;
|
|
31
32
|
const Search = /*#__PURE__*/React.forwardRef(({
|
|
@@ -51,7 +52,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
51
52
|
value,
|
|
52
53
|
...rest
|
|
53
54
|
}, forwardRef) => {
|
|
54
|
-
const hasPropValue = value || defaultValue
|
|
55
|
+
const hasPropValue = utils.isSearchValuePresent(value) || utils.isSearchValuePresent(defaultValue);
|
|
55
56
|
const prefix = usePrefix.usePrefix();
|
|
56
57
|
const {
|
|
57
58
|
isFluid
|
|
@@ -78,7 +79,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
78
79
|
[`${prefix}--search-close--hidden`]: !hasContent || !isExpanded
|
|
79
80
|
});
|
|
80
81
|
if (value !== prevValue) {
|
|
81
|
-
setHasContent(
|
|
82
|
+
setHasContent(utils.isSearchValuePresent(value));
|
|
82
83
|
setPrevValue(value);
|
|
83
84
|
}
|
|
84
85
|
function clearInput() {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
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
|
+
export declare const isSearchValuePresent: (value: string | number | undefined) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const isSearchValuePresent = value => value !== '' && typeof value !== 'undefined';
|
|
11
|
+
|
|
12
|
+
exports.isSearchValuePresent = isSearchValuePresent;
|
|
@@ -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 ChangeEventHandler, type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
7
|
+
import React, { type ChangeEventHandler, type ComponentPropsWithRef, type ReactNode, type SelectHTMLAttributes } from 'react';
|
|
8
8
|
type ExcludedAttributes = 'size';
|
|
9
9
|
export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
|
|
10
10
|
/**
|
|
@@ -22,7 +22,7 @@ export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, Exclu
|
|
|
22
22
|
/**
|
|
23
23
|
* Optionally provide the default value of the `<select>`
|
|
24
24
|
*/
|
|
25
|
-
defaultValue?:
|
|
25
|
+
defaultValue?: SelectHTMLAttributes<HTMLSelectElement>['defaultValue'];
|
|
26
26
|
/**
|
|
27
27
|
* Specify whether the control is disabled
|
|
28
28
|
*/
|
|
@@ -38,7 +38,7 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
38
38
|
hideLabel = false,
|
|
39
39
|
invalid = false,
|
|
40
40
|
invalidText = '',
|
|
41
|
-
helperText
|
|
41
|
+
helperText,
|
|
42
42
|
light = false,
|
|
43
43
|
readOnly,
|
|
44
44
|
size,
|
|
@@ -111,7 +111,7 @@ const Select = /*#__PURE__*/React.forwardRef(({
|
|
|
111
111
|
ariaProps['aria-describedby'] = helper ? normalizedProps.helperId : undefined;
|
|
112
112
|
}
|
|
113
113
|
const handleFocus = evt => {
|
|
114
|
-
setIsFocused(evt.type === 'focus'
|
|
114
|
+
setIsFocused(evt.type === 'focus');
|
|
115
115
|
};
|
|
116
116
|
const handleChange = evt => {
|
|
117
117
|
const selectedOption = evt?.target?.options[evt.target.selectedIndex];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 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.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import { HTMLAttributes } from 'react';
|
|
8
|
+
import { type HTMLAttributes, type OptionHTMLAttributes } from 'react';
|
|
9
9
|
export interface SelectItemProps extends HTMLAttributes<HTMLOptionElement> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify an optional className to be applied to the node
|
|
@@ -26,7 +26,7 @@ export interface SelectItemProps extends HTMLAttributes<HTMLOptionElement> {
|
|
|
26
26
|
/**
|
|
27
27
|
* Specify the value of the <SelectItem>
|
|
28
28
|
*/
|
|
29
|
-
value:
|
|
29
|
+
value: OptionHTMLAttributes<HTMLOptionElement>['value'];
|
|
30
30
|
}
|
|
31
31
|
declare const SelectItem: {
|
|
32
32
|
({ className, value, disabled, hidden, text, ...other }: SelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -152,8 +152,8 @@ function StructuredListRow(props) {
|
|
|
152
152
|
...other
|
|
153
153
|
} = props;
|
|
154
154
|
const [hasFocusWithin, setHasFocusWithin] = React.useState(false);
|
|
155
|
-
|
|
156
|
-
const rowId = id ??
|
|
155
|
+
const generatedRowId = useId.useId('grid-input');
|
|
156
|
+
const rowId = id ?? generatedRowId;
|
|
157
157
|
const selectedRow = React.useContext(GridSelectedRowStateContext);
|
|
158
158
|
const setSelectedRow = React.useContext(GridSelectedRowDispatchContext);
|
|
159
159
|
const prefix = usePrefix.usePrefix();
|
|
@@ -850,8 +850,8 @@ const Tab = /*#__PURE__*/React.forwardRef(({
|
|
|
850
850
|
if (tabRef.current && tabRef.current.parentElement) {
|
|
851
851
|
// determine number of tabs, excluding disabled
|
|
852
852
|
const tabCount = Array.from(tabRef.current.parentElement.childNodes).filter(node => {
|
|
853
|
-
|
|
854
|
-
return
|
|
853
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
854
|
+
return node.classList.contains(`${prefix}--tabs__nav-link`) && !node.classList.contains(`${prefix}--tabs__nav-item--disabled`);
|
|
855
855
|
}).length;
|
|
856
856
|
|
|
857
857
|
// if not removing last tab focus on next tab
|
|
@@ -861,7 +861,10 @@ const Tab = /*#__PURE__*/React.forwardRef(({
|
|
|
861
861
|
// if removing last tab focus on previous tab
|
|
862
862
|
else {
|
|
863
863
|
const prevTabIndex = (tabCount - 2) * 2;
|
|
864
|
-
tabRef.current.parentElement.childNodes[prevTabIndex]
|
|
864
|
+
const previousTab = tabRef.current.parentElement.childNodes[prevTabIndex];
|
|
865
|
+
if (previousTab instanceof HTMLElement) {
|
|
866
|
+
previousTab.focus();
|
|
867
|
+
}
|
|
865
868
|
}
|
|
866
869
|
}
|
|
867
870
|
};
|
|
@@ -1162,7 +1165,9 @@ function TabPanels({
|
|
|
1162
1165
|
// set max height to TabList
|
|
1163
1166
|
const heights = refs.current.map(ref => ref?.offsetHeight || 0);
|
|
1164
1167
|
const max = Math.max(...heights);
|
|
1165
|
-
tabContainer
|
|
1168
|
+
if (tabContainer instanceof HTMLElement) {
|
|
1169
|
+
tabContainer.style.height = max + 'px';
|
|
1170
|
+
}
|
|
1166
1171
|
|
|
1167
1172
|
// re-hide hidden Tab Panels
|
|
1168
1173
|
refs.current.forEach((ref, index) => {
|
|
@@ -49,8 +49,8 @@ const DismissibleTag = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
}, forwardRef) => {
|
|
50
50
|
const prefix = usePrefix.usePrefix();
|
|
51
51
|
const tagLabelRef = React.useRef(null);
|
|
52
|
-
|
|
53
|
-
const tagId = id
|
|
52
|
+
const generatedTagId = useId.useId();
|
|
53
|
+
const tagId = id ?? `tag-${generatedTagId}`;
|
|
54
54
|
const tagClasses = cx(`${prefix}--tag--filter`, className);
|
|
55
55
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
56
56
|
useIsomorphicEffect.default(() => {
|
|
@@ -49,8 +49,8 @@ const OperationalTag = /*#__PURE__*/React.forwardRef(({
|
|
|
49
49
|
}, forwardRef) => {
|
|
50
50
|
const prefix = usePrefix.usePrefix();
|
|
51
51
|
const tagRef = React.useRef(null);
|
|
52
|
-
|
|
53
|
-
const tagId = id
|
|
52
|
+
const generatedTagId = useId.useId();
|
|
53
|
+
const tagId = id ?? `tag-${generatedTagId}`;
|
|
54
54
|
const tagClasses = cx(`${prefix}--tag--operational`, className);
|
|
55
55
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
56
56
|
useIsomorphicEffect.default(() => {
|
|
@@ -41,8 +41,8 @@ const SelectableTag = /*#__PURE__*/React.forwardRef(({
|
|
|
41
41
|
}, forwardRef) => {
|
|
42
42
|
const prefix = usePrefix.usePrefix();
|
|
43
43
|
const tagRef = React.useRef(null);
|
|
44
|
-
|
|
45
|
-
const tagId = id
|
|
44
|
+
const generatedTagId = useId.useId();
|
|
45
|
+
const tagId = id ?? `tag-${generatedTagId}`;
|
|
46
46
|
const [selectedTag, setSelectedTag] = useControllableState.useControllableState({
|
|
47
47
|
value: selected,
|
|
48
48
|
onChange: onChange,
|
|
@@ -78,8 +78,8 @@ const TagBase = /*#__PURE__*/React.forwardRef(({
|
|
|
78
78
|
console.warn('The `onClose` prop for Tag has been deprecated and will be removed in the next major version. Use DismissibleTag instead.');
|
|
79
79
|
}
|
|
80
80
|
const ref = useMergedRefs.useMergedRefs([forwardRef, tagRef]);
|
|
81
|
-
|
|
82
|
-
const tagId = id
|
|
81
|
+
const generatedTagId = useId.useId();
|
|
82
|
+
const tagId = id ?? `tag-${generatedTagId}`;
|
|
83
83
|
const [isEllipsisApplied, setIsEllipsisApplied] = React.useState(false);
|
|
84
84
|
useIsomorphicEffect.default(() => {
|
|
85
85
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 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.
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
import React, { type ReactNode } from 'react';
|
|
8
8
|
export interface TextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
9
9
|
/**
|
|
10
|
-
* Provide a custom className that is applied
|
|
11
|
-
* `<textarea>` node
|
|
10
|
+
* Provide a custom className that is applied to the wrapper node
|
|
12
11
|
*/
|
|
13
12
|
className?: string;
|
|
14
13
|
/**
|
|
@@ -42,7 +42,7 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
42
42
|
onKeyDown = noopFn.noopFn,
|
|
43
43
|
invalid = false,
|
|
44
44
|
invalidText = '',
|
|
45
|
-
helperText
|
|
45
|
+
helperText,
|
|
46
46
|
light,
|
|
47
47
|
placeholder = '',
|
|
48
48
|
enableCounter = false,
|
|
@@ -243,7 +243,7 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
243
243
|
ariaDescribedBy = warnId;
|
|
244
244
|
} else {
|
|
245
245
|
const ids = [];
|
|
246
|
-
if (!isFluid &&
|
|
246
|
+
if (!isFluid && hasHelper && helperId) ids.push(helperId);
|
|
247
247
|
if (counterDescriptionId) ids.push(counterDescriptionId);
|
|
248
248
|
ariaDescribedBy = ids.length > 0 ? ids.join(' ') : undefined;
|
|
249
249
|
}
|
|
@@ -282,7 +282,7 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
282
282
|
}, [ariaAnnouncement, prevAnnouncement, counterMode]);
|
|
283
283
|
const input = /*#__PURE__*/React.createElement("textarea", _rollupPluginBabelHelpers.extends({}, other, textareaProps, {
|
|
284
284
|
placeholder: placeholder,
|
|
285
|
-
"aria-readonly": other.readOnly
|
|
285
|
+
"aria-readonly": other.readOnly,
|
|
286
286
|
className: textareaClasses,
|
|
287
287
|
"aria-invalid": invalid,
|
|
288
288
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -328,8 +328,7 @@ const TextArea = frFn((props, forwardRef) => {
|
|
|
328
328
|
TextArea.displayName = 'TextArea';
|
|
329
329
|
TextArea.propTypes = {
|
|
330
330
|
/**
|
|
331
|
-
* Provide a custom className that is applied
|
|
332
|
-
* `<textarea>` node
|
|
331
|
+
* Provide a custom className that is applied to the wrapper node
|
|
333
332
|
*/
|
|
334
333
|
className: PropTypes.string,
|
|
335
334
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 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.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { type SelectHTMLAttributes } from 'react';
|
|
8
8
|
export type TimePickerSelectProps = {
|
|
9
9
|
/**
|
|
10
10
|
* Provide the contents of your TimePickerSelect
|
|
@@ -17,7 +17,7 @@ export type TimePickerSelectProps = {
|
|
|
17
17
|
/**
|
|
18
18
|
* Optionally provide the default value of the `<select>`
|
|
19
19
|
*/
|
|
20
|
-
defaultValue?:
|
|
20
|
+
defaultValue?: SelectHTMLAttributes<HTMLSelectElement>['defaultValue'];
|
|
21
21
|
/**
|
|
22
22
|
* Specify whether the control is disabled
|
|
23
23
|
*/
|
|
@@ -39,7 +39,7 @@ declare const TimePickerSelect: React.ForwardRefExoticComponent<{
|
|
|
39
39
|
/**
|
|
40
40
|
* Optionally provide the default value of the `<select>`
|
|
41
41
|
*/
|
|
42
|
-
defaultValue?:
|
|
42
|
+
defaultValue?: SelectHTMLAttributes<HTMLSelectElement>["defaultValue"];
|
|
43
43
|
/**
|
|
44
44
|
* Specify whether the control is disabled
|
|
45
45
|
*/
|
|
@@ -138,8 +138,7 @@ function Toggletip({
|
|
|
138
138
|
const eventType = 'PointerEvent' in window ? 'pointerdown' : 'mousedown';
|
|
139
139
|
const handleOutsideClick = event => {
|
|
140
140
|
const node = event.target;
|
|
141
|
-
|
|
142
|
-
if (open && node && !ref.current.contains(node)) {
|
|
141
|
+
if (open && node && !ref.current?.contains(node)) {
|
|
143
142
|
setOpen(false);
|
|
144
143
|
}
|
|
145
144
|
};
|