@carbon/react 1.84.0 → 1.85.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 +899 -829
- 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 +15 -10
- 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/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +2 -2
- package/es/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
- package/es/components/DatePicker/plugins/appendToPlugin.js +9 -12
- 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 +7 -8
- package/es/components/Menu/MenuItem.js +13 -2
- package/es/components/Modal/Modal.d.ts +2 -2
- package/es/components/Modal/Modal.js +20 -9
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +9 -8
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +8 -7
- package/es/components/MultiSelect/filter.d.ts +10 -0
- package/es/components/MultiSelect/filter.js +21 -0
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +9 -8
- package/es/components/PageHeader/PageHeader.js +2 -2
- 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/Select/Select.d.ts +2 -2
- package/es/components/Select/Select.js +8 -7
- package/es/components/Slider/Slider.d.ts +59 -198
- package/es/components/Slider/Slider.js +68 -120
- package/es/components/Tabs/usePressable.d.ts +19 -0
- package/es/components/Tabs/usePressable.js +19 -33
- 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 +8 -7
- 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/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/Tooltip/Tooltip.d.ts +2 -2
- package/es/components/Tooltip/Tooltip.js +2 -2
- package/es/components/TreeView/TreeNode.d.ts +22 -0
- package/es/components/TreeView/TreeNode.js +119 -12
- package/es/components/TreeView/TreeView.js +3 -3
- package/es/components/UIShell/Content.d.ts +5 -3
- package/es/components/UIShell/HeaderPanel.d.ts +2 -2
- package/es/components/UIShell/HeaderPanel.js +9 -5
- package/es/internal/Selection.js +8 -3
- package/es/internal/environment.js +1 -12
- package/{lib/internal/__mocks__/mockHTMLElement.d.ts → es/internal/index.d.ts} +2 -4
- 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 +16 -11
- 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/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/DatePicker/plugins/appendToPlugin.d.ts +12 -0
- package/lib/components/DatePicker/plugins/appendToPlugin.js +9 -12
- 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 +7 -8
- package/lib/components/Menu/MenuItem.js +13 -2
- package/lib/components/Modal/Modal.d.ts +2 -2
- package/lib/components/Modal/Modal.js +28 -17
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +13 -12
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +13 -12
- package/lib/components/MultiSelect/filter.d.ts +10 -0
- package/lib/components/MultiSelect/filter.js +25 -0
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +8 -7
- package/lib/components/PageHeader/PageHeader.js +2 -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/Select/Select.d.ts +2 -2
- package/lib/components/Select/Select.js +7 -6
- package/lib/components/Slider/Slider.d.ts +59 -198
- package/lib/components/Slider/Slider.js +67 -119
- package/lib/components/Tabs/usePressable.d.ts +19 -0
- package/lib/components/Tabs/usePressable.js +19 -33
- 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 +7 -6
- 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/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/Tooltip/Tooltip.d.ts +2 -2
- package/lib/components/Tooltip/Tooltip.js +2 -2
- package/lib/components/TreeView/TreeNode.d.ts +22 -0
- package/lib/components/TreeView/TreeNode.js +118 -11
- package/lib/components/TreeView/TreeView.js +3 -3
- package/lib/components/UIShell/Content.d.ts +5 -3
- package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
- package/lib/components/UIShell/HeaderPanel.js +8 -4
- package/lib/internal/Selection.js +8 -3
- package/lib/internal/environment.js +1 -12
- package/{es/internal/__mocks__/mockHTMLElement.d.ts → lib/internal/index.d.ts} +2 -4
- 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 +11 -20
- package/telemetry.yml +1 -0
- package/es/components/ComboBox/tools/filter.js +0 -18
- package/es/tools/uniqueId.js +0 -14
- package/lib/components/ComboBox/tools/filter.js +0 -22
- package/lib/tools/uniqueId.js +0 -18
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React, { useRef, useState } from 'react';
|
|
11
|
+
import React, { useRef, useState, isValidElement } from 'react';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { match } from '../../internal/keyboard/match.js';
|
|
15
15
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
16
16
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
17
|
+
import Switcher from './Switcher.js';
|
|
17
18
|
|
|
18
19
|
const noopFn = () => {};
|
|
19
20
|
const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel({
|
|
@@ -58,10 +59,13 @@ const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel({
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
useWindowEvent('click', () => {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (
|
|
62
|
+
const {
|
|
63
|
+
activeElement
|
|
64
|
+
} = document;
|
|
65
|
+
if (!(activeElement instanceof HTMLElement)) return;
|
|
66
|
+
setLastClickedElement(activeElement);
|
|
67
|
+
const isChildASwitcher = /*#__PURE__*/isValidElement(children) && typeof children.type !== 'string' && children.type === Switcher;
|
|
68
|
+
if (isChildASwitcher && !activeElement.closest(`.${prefix}--header-panel--expanded`) && !activeElement.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
65
69
|
setExpandedState(false);
|
|
66
70
|
onHeaderPanelFocus();
|
|
67
71
|
}
|
package/es/internal/Selection.js
CHANGED
|
@@ -17,9 +17,14 @@ const callOnChangeHandler = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
if (isControlled) {
|
|
19
19
|
if (isMounted && onChangeHandlerControlled) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// Use setTimeout to defer the controlled onChange call,
|
|
21
|
+
// avoiding React’s warning: "Cannot update a component while rendering a different component".
|
|
22
|
+
// This ensures the parent state updates after rendering completes.
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
onChangeHandlerControlled({
|
|
25
|
+
selectedItems
|
|
26
|
+
});
|
|
27
|
+
}, 0);
|
|
23
28
|
}
|
|
24
29
|
} else {
|
|
25
30
|
onChangeHandlerUncontrolled(selectedItems);
|
|
@@ -10,17 +10,6 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @see https://github.com/facebook/fbjs/blob/4d1751311d3f67af2dcce2e40df8512a23c7b9c6/packages/fbjs/src/core/ExecutionEnvironment.js#L12
|
|
12
12
|
*/
|
|
13
|
-
const canUseDOM = !!(typeof window !== 'undefined' &&
|
|
14
|
-
// TODO: `ssr-friendly` doesn't support ESLint v9.
|
|
15
|
-
// https://github.com/kopiro/eslint-plugin-ssr-friendly/issues/30
|
|
16
|
-
// https://github.com/carbon-design-system/carbon/issues/18991
|
|
17
|
-
/*
|
|
18
|
-
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
19
|
-
*/
|
|
20
|
-
window.document &&
|
|
21
|
-
/*
|
|
22
|
-
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
23
|
-
*/
|
|
24
|
-
window.document.createElement);
|
|
13
|
+
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
25
14
|
|
|
26
15
|
export { canUseDOM };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2025
|
|
2
|
+
* Copyright IBM Corp. 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
|
-
export
|
|
8
|
-
mockRestore: () => void;
|
|
9
|
-
};
|
|
7
|
+
export * from './utils';
|
|
@@ -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
|
}
|
|
@@ -264,10 +269,10 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
264
269
|
React.useEffect(() => {
|
|
265
270
|
if (!enableDialogElement && !open && launcherButtonRef) {
|
|
266
271
|
setTimeout(() => {
|
|
267
|
-
launcherButtonRef
|
|
272
|
+
launcherButtonRef.current?.focus();
|
|
268
273
|
});
|
|
269
274
|
}
|
|
270
|
-
}, [open, launcherButtonRef]);
|
|
275
|
+
}, [enableDialogElement, open, launcherButtonRef]);
|
|
271
276
|
React.useEffect(() => {
|
|
272
277
|
if (!enableDialogElement) {
|
|
273
278
|
const initialFocus = focusContainerElement => {
|
|
@@ -294,14 +299,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
294
299
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
295
300
|
|
|
296
301
|
// AILabel is always size `sm`
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
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, {
|
|
304
308
|
open: open,
|
|
309
|
+
focusAfterCloseRef: launcherButtonRef,
|
|
305
310
|
modal: true,
|
|
306
311
|
className: containerClass,
|
|
307
312
|
"aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
|
|
@@ -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);
|
|
@@ -16,6 +16,10 @@ var React = require('react');
|
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
17
|
var TableCell = require('./TableCell.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var TableSlugRow = require('./TableSlugRow.js');
|
|
20
|
+
var TableDecoratorRow = require('./TableDecoratorRow.js');
|
|
21
|
+
var index = require('../AILabel/index.js');
|
|
22
|
+
var utils = require('../../internal/utils.js');
|
|
19
23
|
|
|
20
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
25
|
|
|
@@ -40,16 +44,21 @@ const TableExpandRow = /*#__PURE__*/React__default["default"].forwardRef(({
|
|
|
40
44
|
|
|
41
45
|
// We need to put the AILabel and Decorator before the expansion arrow and all other table cells after the arrow.
|
|
42
46
|
let rowHasAILabel;
|
|
43
|
-
const decorator =
|
|
44
|
-
if (child
|
|
45
|
-
if (child.props.slug
|
|
47
|
+
const decorator = React.Children.toArray(children).map(child => {
|
|
48
|
+
if (utils.isComponentElement(child, TableSlugRow["default"])) {
|
|
49
|
+
if (child.props.slug) {
|
|
50
|
+
rowHasAILabel = true;
|
|
51
|
+
}
|
|
52
|
+
return child;
|
|
53
|
+
} else if (utils.isComponentElement(child, TableDecoratorRow["default"])) {
|
|
54
|
+
if (utils.isComponentElement(child.props.decorator, index.AILabel)) {
|
|
46
55
|
rowHasAILabel = true;
|
|
47
56
|
}
|
|
48
57
|
return child;
|
|
49
58
|
}
|
|
50
59
|
});
|
|
51
|
-
const normalizedChildren =
|
|
52
|
-
if (child.type
|
|
60
|
+
const normalizedChildren = React.Children.toArray(children).map(child => {
|
|
61
|
+
if (/*#__PURE__*/React.isValidElement(child) && child.type !== TableSlugRow["default"] && child.type !== TableDecoratorRow["default"]) {
|
|
53
62
|
return child;
|
|
54
63
|
}
|
|
55
64
|
});
|
|
@@ -17,6 +17,8 @@ var iconsReact = require('@carbon/icons-react');
|
|
|
17
17
|
require('./state/sorting.js');
|
|
18
18
|
var useId = require('../../internal/useId.js');
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
|
+
var index = require('../AILabel/index.js');
|
|
21
|
+
var utils = require('../../internal/utils.js');
|
|
20
22
|
var sortStates = require('./state/sortStates.js');
|
|
21
23
|
|
|
22
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -71,15 +73,13 @@ const TableHeader = /*#__PURE__*/React__default["default"].forwardRef(function T
|
|
|
71
73
|
|
|
72
74
|
// AILabel is always size `mini`
|
|
73
75
|
const AILableRef = React.useRef(null);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
}
|
|
76
|
+
const candidate = slug ?? decorator;
|
|
77
|
+
const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
|
|
78
|
+
const colHasAILabel = candidateIsAILabel;
|
|
79
|
+
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
80
|
+
size: 'mini',
|
|
81
|
+
ref: AILableRef
|
|
82
|
+
}) : null;
|
|
83
83
|
const headerLabelClassNames = cx__default["default"]({
|
|
84
84
|
[`${prefix}--table-header-label`]: true,
|
|
85
85
|
[`${prefix}--table-header-label--slug ${prefix}--table-header-label--ai-label`]: colHasAILabel,
|