@carbon/react 1.79.0 → 1.80.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 +960 -904
- package/es/components/CodeSnippet/CodeSnippet.js +1 -1
- package/es/components/ComposedModal/ComposedModal.d.ts +6 -0
- package/es/components/ComposedModal/ModalFooter.d.ts +6 -0
- package/es/components/ContainedList/index.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +3 -1
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +6 -0
- package/es/components/Layer/LayerLevel.d.ts +6 -0
- package/es/components/Menu/Menu.d.ts +1 -1
- package/es/components/Menu/MenuItem.d.ts +1 -1
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/es/components/ModalWrapper/ModalWrapper.js +2 -1
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -3
- package/es/components/OverflowMenuV2/index.js +1 -1
- package/es/components/PageHeader/PageHeader.d.ts +101 -0
- package/es/components/PageHeader/PageHeader.js +241 -0
- package/es/components/PageHeader/index.d.ts +8 -0
- package/es/components/PageHeader/index.js +8 -0
- package/es/components/PasswordInput/index.d.ts +6 -0
- package/es/components/Popover/index.js +1 -1
- package/es/components/Slider/SliderHandles.d.ts +6 -0
- package/es/components/Tag/Tag.js +2 -2
- package/es/components/Text/createTextComponent.js +1 -1
- package/es/components/TextArea/TextArea.d.ts +3 -3
- package/es/components/TextArea/TextArea.js +5 -2
- package/es/components/TextInput/ControlledPasswordInput.d.ts +6 -0
- package/es/components/TextInput/ControlledPasswordInput.js +1 -1
- package/es/components/TextInput/PasswordInput.d.ts +6 -0
- package/es/components/TextInput/index.js +1 -1
- package/es/components/Tile/Tile.d.ts +1 -1
- package/es/components/Tile/Tile.js +1 -4
- package/es/components/UIShell/Switcher.d.ts +1 -7
- package/es/components/UIShell/SwitcherDivider.d.ts +6 -0
- package/es/components/UIShell/SwitcherItem.d.ts +6 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +3 -1
- package/es/internal/FloatingMenu.js +2 -2
- package/es/internal/PolymorphicProps.d.ts +6 -0
- package/es/internal/deprecateFieldOnObject.d.ts +12 -0
- package/es/internal/deprecateFieldOnObject.js +4 -4
- package/es/internal/useControllableState.js +2 -2
- package/es/internal/useEvent.js +1 -1
- package/es/internal/useMergedRefs.d.ts +9 -6
- package/es/internal/useMergedRefs.js +8 -9
- package/es/internal/useNoInteractiveChildren.js +2 -2
- package/es/internal/useSavedCallback.d.ts +15 -0
- package/es/internal/useSavedCallback.js +9 -12
- package/es/internal/warning.d.ts +17 -0
- package/es/internal/warning.js +16 -12
- package/es/internal/wrapFocus.js +1 -1
- package/es/prop-types/isRequiredOneOf.js +1 -1
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/es/tools/events.js +1 -6
- package/es/tools/toggleClass.js +6 -0
- package/es/types/common.d.ts +6 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.d.ts +6 -0
- package/lib/components/ComposedModal/ModalFooter.d.ts +6 -0
- package/lib/components/ContainedList/index.js +1 -1
- package/lib/components/DataTable/DataTable.d.ts +3 -1
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +6 -0
- package/lib/components/Layer/LayerLevel.d.ts +6 -0
- package/lib/components/Menu/Menu.d.ts +1 -1
- package/lib/components/Menu/MenuItem.d.ts +1 -1
- package/lib/components/Modal/Modal.js +1 -1
- package/lib/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -1
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -3
- package/lib/components/OverflowMenuV2/index.js +1 -1
- package/lib/components/PageHeader/PageHeader.d.ts +101 -0
- package/lib/components/PageHeader/PageHeader.js +260 -0
- package/lib/components/PageHeader/index.d.ts +8 -0
- package/lib/components/PageHeader/index.js +25 -0
- package/lib/components/PasswordInput/index.d.ts +6 -0
- package/lib/components/Popover/index.js +1 -1
- package/lib/components/Slider/SliderHandles.d.ts +6 -0
- package/lib/components/Tag/Tag.js +2 -2
- package/lib/components/Text/createTextComponent.js +1 -1
- package/lib/components/TextArea/TextArea.d.ts +3 -3
- package/lib/components/TextArea/TextArea.js +4 -1
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +6 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
- package/lib/components/TextInput/PasswordInput.d.ts +6 -0
- package/lib/components/TextInput/index.js +1 -1
- package/lib/components/Tile/Tile.d.ts +1 -1
- package/lib/components/Tile/Tile.js +1 -4
- package/lib/components/UIShell/Switcher.d.ts +1 -7
- package/lib/components/UIShell/SwitcherDivider.d.ts +6 -0
- package/lib/components/UIShell/SwitcherItem.d.ts +6 -0
- package/lib/index.d.ts +5 -1
- package/lib/index.js +62 -57
- package/lib/internal/FloatingMenu.js +2 -2
- package/lib/internal/PolymorphicProps.d.ts +6 -0
- package/lib/internal/deprecateFieldOnObject.d.ts +12 -0
- package/lib/internal/deprecateFieldOnObject.js +4 -4
- package/lib/internal/useControllableState.js +2 -2
- package/lib/internal/useEvent.js +1 -1
- package/lib/internal/useMergedRefs.d.ts +9 -6
- package/lib/internal/useMergedRefs.js +8 -9
- package/lib/internal/useNoInteractiveChildren.js +2 -2
- package/lib/internal/useSavedCallback.d.ts +15 -0
- package/lib/internal/useSavedCallback.js +9 -12
- package/lib/internal/warning.d.ts +17 -0
- package/lib/internal/warning.js +16 -12
- package/lib/internal/wrapFocus.js +1 -1
- package/lib/prop-types/isRequiredOneOf.js +1 -1
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/lib/tools/events.js +1 -6
- package/lib/tools/toggleClass.js +6 -0
- package/lib/types/common.d.ts +6 -0
- package/package.json +7 -7
- package/scss/components/page-header/_index.scss +9 -0
- package/scss/components/page-header/_page-header.scss +9 -0
- package/telemetry.yml +62 -23
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useContext, useRef, useState, useEffect } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
13
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
@@ -22,7 +22,10 @@ import { noopFn } from '../../internal/noopFn.js';
|
|
|
22
22
|
import '../Text/index.js';
|
|
23
23
|
import { Text } from '../Text/Text.js';
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// TODO: This type was added to prevent the formatter from changing the
|
|
26
|
+
// indentation of this entire function. Delete it in a future pull request.
|
|
27
|
+
|
|
28
|
+
const TextArea = /*#__PURE__*/forwardRef((props, forwardRef) => {
|
|
26
29
|
const {
|
|
27
30
|
className,
|
|
28
31
|
decorator,
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
|
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
7
|
import React from 'react';
|
|
2
8
|
import { ReactAttr } from '../../types/common';
|
|
3
9
|
export interface ControlledPasswordInputProps extends ReactAttr<HTMLInputElement> {
|
|
@@ -45,7 +45,7 @@ const ControlledPasswordInput = /*#__PURE__*/React__default.forwardRef(function
|
|
|
45
45
|
} = _ref;
|
|
46
46
|
const prefix = usePrefix();
|
|
47
47
|
const controlledPasswordInstanceId = useId();
|
|
48
|
-
if (process.env.NODE_ENV !==
|
|
48
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
49
49
|
process.env.NODE_ENV !== "production" ? warning(didWarnAboutDeprecation, '`<TextInput.ControlledPasswordInput>` has been deprecated in favor of `<TextInput.PasswordInput />` and will be removed in the next major release of `carbon-components-react`') : void 0;
|
|
50
50
|
didWarnAboutDeprecation = true;
|
|
51
51
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 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
7
|
import React, { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
8
|
type ExcludedAttributes = 'size';
|
|
3
9
|
export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
|
|
@@ -12,7 +12,7 @@ import TextInput from './TextInput.js';
|
|
|
12
12
|
export { default as TextInput, default } from './TextInput.js';
|
|
13
13
|
export { default as TextInputSkeleton } from './TextInput.Skeleton.js';
|
|
14
14
|
|
|
15
|
-
if (process.env.NODE_ENV !==
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
16
|
deprecateFieldOnObject(TextInput, 'ControlledPasswordInput', ControlledPasswordInput);
|
|
17
17
|
deprecateFieldOnObject(TextInput, 'PasswordInput', PasswordInput);
|
|
18
18
|
}
|
|
@@ -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 ChangeEvent, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react';
|
|
8
8
|
export interface TileProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
9
|
children?: ReactNode;
|
|
10
10
|
className?: string;
|
|
@@ -517,7 +517,6 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
return interactive ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
520
|
-
// @ts-expect-error: Needlesly strict & deep typing for the element type
|
|
521
520
|
ref: ref,
|
|
522
521
|
className: interactiveClassNames
|
|
523
522
|
}, rest), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -541,9 +540,7 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
541
540
|
className: `${prefix}--tile-content`,
|
|
542
541
|
id: belowTheFoldId
|
|
543
542
|
}, childrenAsArray[1]))) : /*#__PURE__*/React__default.createElement("button", _extends({
|
|
544
|
-
type: "button"
|
|
545
|
-
// @ts-expect-error: Needlesly strict & deep typing for the element type
|
|
546
|
-
,
|
|
543
|
+
type: "button",
|
|
547
544
|
ref: ref,
|
|
548
545
|
className: classNames,
|
|
549
546
|
"aria-expanded": isExpanded,
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
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
|
-
* Copyright IBM Corp. 2016, 2023
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
9
3
|
*
|
|
10
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
11
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 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
7
|
import React, { HTMLAttributeAnchorTarget, KeyboardEvent } from 'react';
|
|
2
8
|
export interface BaseSwitcherItemProps {
|
|
3
9
|
/**
|
package/es/index.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export * from './components/DatePickerInput';
|
|
|
31
31
|
export * from './components/Dropdown';
|
|
32
32
|
export * from './components/ErrorBoundary';
|
|
33
33
|
export * from './components/ExpandableSearch';
|
|
34
|
+
export { FeatureFlags, useFeatureFlag, useFeatureFlags, FeatureFlags as unstable_FeatureFlags, // this export can be removed in v12
|
|
35
|
+
useFeatureFlag as unstable_useFeatureFlag, // this export can be removed in v12
|
|
36
|
+
useFeatureFlags as unstable_useFeatureFlags, } from './components/FeatureFlags';
|
|
34
37
|
export * from './components/FileUploader';
|
|
35
38
|
export * from './components/FilterableMultiSelect';
|
|
36
39
|
export * from './components/FluidForm';
|
|
@@ -55,6 +58,7 @@ export * from './components/NumberInput';
|
|
|
55
58
|
export * from './components/OrderedList';
|
|
56
59
|
export * from './components/OverflowMenu';
|
|
57
60
|
export * from './components/OverflowMenuItem';
|
|
61
|
+
export * as unstable__PageHeader from './components/PageHeader';
|
|
58
62
|
export * from './components/Pagination';
|
|
59
63
|
export * from './components/Pagination/Pagination.Skeleton';
|
|
60
64
|
export * from './components/PaginationNav';
|
|
@@ -95,7 +99,6 @@ export * from './components/Toggletip';
|
|
|
95
99
|
export * from './components/TreeView';
|
|
96
100
|
export * from './components/UIShell';
|
|
97
101
|
export * from './components/UnorderedList';
|
|
98
|
-
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags, } from './components/FeatureFlags';
|
|
99
102
|
export { FluidComboBox as unstable__FluidComboBox, FluidComboBoxSkeleton as unstable__FluidComboBoxSkeleton, } from './components/FluidComboBox';
|
|
100
103
|
export { FluidDatePicker as unstable__FluidDatePicker, FluidDatePickerSkeleton as unstable__FluidDatePickerSkeleton, } from './components/FluidDatePicker';
|
|
101
104
|
export { FluidDatePickerInput as unstable__FluidDatePickerInput } from './components/FluidDatePickerInput';
|
|
@@ -263,6 +266,7 @@ export type { NumberInputSkeletonProps } from './components/NumberInput/NumberIn
|
|
|
263
266
|
export type { OrderedListProps } from './components/OrderedList/OrderedList';
|
|
264
267
|
export type { OverflowMenuProps } from './components/OverflowMenu/OverflowMenu';
|
|
265
268
|
export type { OverflowMenuItemProps } from './components/OverflowMenuItem/OverflowMenuItem';
|
|
269
|
+
export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderHeroImageProps, PageHeaderTabBarProps, } from './components/PageHeader';
|
|
266
270
|
export type { PaginationProps } from './components/Pagination/Pagination';
|
|
267
271
|
export type { PaginationSkeletonProps } from './components/Pagination/Pagination.Skeleton';
|
|
268
272
|
export type { DirectionButtonProps } from './components/PaginationNav/PaginationNav';
|
package/es/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { default as DropdownSkeleton } from './components/Dropdown/Dropdown.Skel
|
|
|
43
43
|
export { default as ErrorBoundary } from './components/ErrorBoundary/ErrorBoundary.js';
|
|
44
44
|
export { ErrorBoundaryContext } from './components/ErrorBoundary/ErrorBoundaryContext.js';
|
|
45
45
|
export { default as ExpandableSearch } from './components/ExpandableSearch/ExpandableSearch.js';
|
|
46
|
+
export { FeatureFlags, FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags, useFeatureFlag, useFeatureFlags } from './components/FeatureFlags/index.js';
|
|
46
47
|
export { default as FileUploader } from './components/FileUploader/FileUploader.js';
|
|
47
48
|
export { default as Filename } from './components/FileUploader/Filename.js';
|
|
48
49
|
export { default as FileUploaderSkeleton } from './components/FileUploader/FileUploader.Skeleton.js';
|
|
@@ -79,6 +80,8 @@ export { NumberInput } from './components/NumberInput/NumberInput.js';
|
|
|
79
80
|
export { default as OrderedList } from './components/OrderedList/OrderedList.js';
|
|
80
81
|
export { default as OverflowMenu } from './components/OverflowMenu/index.js';
|
|
81
82
|
export { default as OverflowMenuItem } from './components/OverflowMenuItem/OverflowMenuItem.js';
|
|
83
|
+
import * as index from './components/PageHeader/index.js';
|
|
84
|
+
export { index as unstable__PageHeader };
|
|
82
85
|
export { default as Pagination } from './components/Pagination/Pagination.js';
|
|
83
86
|
export { default as PaginationSkeleton } from './components/Pagination/Pagination.Skeleton.js';
|
|
84
87
|
export { default as PaginationNav } from './components/PaginationNav/PaginationNav.js';
|
|
@@ -160,7 +163,6 @@ export { default as SideNavMenu } from './components/UIShell/SideNavMenu.js';
|
|
|
160
163
|
export { default as SideNavMenuItem } from './components/UIShell/SideNavMenuItem.js';
|
|
161
164
|
export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher.js';
|
|
162
165
|
export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
|
|
163
|
-
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags } from './components/FeatureFlags/index.js';
|
|
164
166
|
export { default as unstable__FluidComboBox } from './components/FluidComboBox/FluidComboBox.js';
|
|
165
167
|
export { default as unstable__FluidComboBoxSkeleton } from './components/FluidComboBox/FluidComboBox.Skeleton.js';
|
|
166
168
|
export { default as unstable__FluidDatePicker } from './components/FluidDatePicker/FluidDatePicker.js';
|
|
@@ -104,7 +104,7 @@ const FloatingMenu = _ref2 => {
|
|
|
104
104
|
const updateMenuPosition = useCallback(isAdjustment => {
|
|
105
105
|
const menuBody = menuBodyRef.current;
|
|
106
106
|
if (!menuBody) {
|
|
107
|
-
process.env.NODE_ENV !== "production" ? warning(menuBody, 'The DOM node for menu body for calculating its position is not available. Skipping...') : void 0;
|
|
107
|
+
process.env.NODE_ENV !== "production" ? warning(!!menuBody, 'The DOM node for menu body for calculating its position is not available. Skipping...') : void 0;
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
const triggerEl = triggerRef.current;
|
|
@@ -174,7 +174,7 @@ const FloatingMenu = _ref2 => {
|
|
|
174
174
|
// First programmatic focusable node
|
|
175
175
|
menuBody;
|
|
176
176
|
focusTarget.focus();
|
|
177
|
-
if (focusTarget === menuBody
|
|
177
|
+
if (focusTarget === menuBody) {
|
|
178
178
|
process.env.NODE_ENV !== "production" ? warning(focusableNode === null, 'Floating Menus must have at least a programmatically focusable child. This can be accomplished by adding tabIndex="-1" to the content element.') : void 0;
|
|
179
179
|
}
|
|
180
180
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
*/
|
|
7
|
+
export declare const deprecateFieldOnObject: <T extends {
|
|
8
|
+
displayName?: string;
|
|
9
|
+
}>(object: T, field: string, Component: {
|
|
10
|
+
displayName?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}, message?: string) => void;
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import { warning } from './warning.js';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const deprecateFieldOnObject = (object, field, Component, message) => {
|
|
11
|
+
const didWarnAboutDeprecation = {};
|
|
12
12
|
Object.defineProperty(object, field, {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get() {
|
|
14
|
+
get: () => {
|
|
15
15
|
if (!didWarnAboutDeprecation[field]) {
|
|
16
16
|
process.env.NODE_ENV !== "production" ? warning(false, message || `The ${field} field has been deprecated on the ${object.displayName} object. ` + `Please import and use ${Component.displayName || Component.name || 'the field'} directly.`) : void 0;
|
|
17
17
|
didWarnAboutDeprecation[field] = true;
|
|
@@ -19,6 +19,6 @@ function deprecateFieldOnObject(object, field, Component, message) {
|
|
|
19
19
|
return Component;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
|
|
24
24
|
export { deprecateFieldOnObject };
|
|
@@ -56,13 +56,13 @@ function useControllableState(_ref) {
|
|
|
56
56
|
// Uncontrolled -> Controlled
|
|
57
57
|
// If the component prop is uncontrolled, the prop value should be undefined
|
|
58
58
|
if (controlled.current === false && controlledValue) {
|
|
59
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
59
|
+
process.env.NODE_ENV !== "production" ? warning(false, `A component is changing an uncontrolled ${name} component to be controlled. ` + 'This is likely caused by the value changing to a defined value ' + 'from undefined. Decide between using a controlled or uncontrolled ' + 'value for the lifetime of the component. ' + 'More info: https://reactjs.org/link/controlled-components') : void 0;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// Controlled -> Uncontrolled
|
|
63
63
|
// If the component prop is controlled, the prop value should be defined
|
|
64
64
|
if (controlled.current === true && !controlledValue) {
|
|
65
|
-
process.env.NODE_ENV !== "production" ? warning(false,
|
|
65
|
+
process.env.NODE_ENV !== "production" ? warning(false, `A component is changing a controlled ${name} component to be uncontrolled. ` + 'This is likely caused by the value changing to an undefined value ' + 'from a defined one. Decide between using a controlled or ' + 'uncontrolled value for the lifetime of the component. ' + 'More info: https://reactjs.org/link/controlled-components') : void 0;
|
|
66
66
|
}
|
|
67
67
|
}, [name, value]);
|
|
68
68
|
if (controlled.current === true) {
|
package/es/internal/useEvent.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
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 {
|
|
7
|
+
import { type ForwardedRef, type Ref } from 'react';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Merges multiple refs into a single callback ref.
|
|
10
|
+
*
|
|
11
|
+
* This hook is useful when you need to attach multiple refs (for example, a ref
|
|
12
|
+
* passed from `forwardRef` and a local ref from `useRef`) to the same node. It
|
|
13
|
+
* accepts an array of refs and returns a callback ref that, when attached to a
|
|
14
|
+
* node, assigns that node to every ref in the array.
|
|
12
15
|
*/
|
|
13
|
-
export declare const useMergedRefs: <T
|
|
16
|
+
export declare const useMergedRefs: <T>(refs: ForwardedRef<T>[]) => Ref<T>;
|
|
@@ -7,25 +7,24 @@
|
|
|
7
7
|
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
|
|
10
|
-
// TODO: Investigate updating this hook based on the following code from
|
|
11
|
-
// https://github.com/carbon-design-system/carbon/pull/18611:
|
|
12
|
-
// https://github.com/adamalston/carbon/blob/dd403b6b10de3d8a6ccd8d2e21174c908c1e890a/packages/react/src/components/ListBox/ListBoxMenuItem.tsx#L23-L46
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* Merges multiple refs into a single callback ref.
|
|
12
|
+
*
|
|
13
|
+
* This hook is useful when you need to attach multiple refs (for example, a ref
|
|
14
|
+
* passed from `forwardRef` and a local ref from `useRef`) to the same node. It
|
|
15
|
+
* accepts an array of refs and returns a callback ref that, when attached to a
|
|
16
|
+
* node, assigns that node to every ref in the array.
|
|
17
17
|
*/
|
|
18
18
|
const useMergedRefs = refs => {
|
|
19
19
|
return useCallback(node => {
|
|
20
20
|
refs.forEach(ref => {
|
|
21
21
|
if (typeof ref === 'function') {
|
|
22
22
|
ref(node);
|
|
23
|
-
} else if (ref
|
|
23
|
+
} else if (ref) {
|
|
24
24
|
ref.current = node;
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
}, refs);
|
|
27
|
+
}, [refs]);
|
|
29
28
|
};
|
|
30
29
|
|
|
31
30
|
export { useMergedRefs };
|
|
@@ -9,7 +9,7 @@ import { useEffect } from 'react';
|
|
|
9
9
|
|
|
10
10
|
function useNoInteractiveChildren(ref) {
|
|
11
11
|
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'component should have no interactive child nodes';
|
|
12
|
-
if (process.env.NODE_ENV !==
|
|
12
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
13
13
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
@@ -21,7 +21,7 @@ function useNoInteractiveChildren(ref) {
|
|
|
21
21
|
}
|
|
22
22
|
function useInteractiveChildrenNeedDescription(ref) {
|
|
23
23
|
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : `interactive child node(s) should have an \`aria-describedby\` property`;
|
|
24
|
-
if (process.env.NODE_ENV !==
|
|
24
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
25
25
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Returns a stable callback reference that always points to the latest version
|
|
9
|
+
* of a callback. This is useful when you want to avoid including the callback
|
|
10
|
+
* in dependency arrays while still ensuring the latest callback implementation
|
|
11
|
+
* is used.
|
|
12
|
+
*
|
|
13
|
+
* @param callback - The callback to track.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useSavedCallback: <T extends (...args: any[]) => any>(callback: T | undefined) => (...args: Parameters<T>) => ReturnType<T> | undefined;
|
|
@@ -8,24 +8,21 @@
|
|
|
8
8
|
import { useRef, useEffect, useCallback } from 'react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Returns a stable callback reference that always points to the latest version
|
|
12
|
+
* of a callback. This is useful when you want to avoid including the callback
|
|
13
|
+
* in dependency arrays while still ensuring the latest callback implementation
|
|
14
|
+
* is used.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns {Function}
|
|
16
|
+
* @param callback - The callback to track.
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
const useSavedCallback = callback => {
|
|
20
19
|
const savedCallback = useRef(callback);
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
savedCallback.current = callback;
|
|
23
|
-
});
|
|
22
|
+
}, [callback]);
|
|
24
23
|
return useCallback(function () {
|
|
25
|
-
|
|
26
|
-
return savedCallback.current(...arguments);
|
|
27
|
-
}
|
|
24
|
+
return savedCallback.current ? savedCallback.current(...arguments) : undefined;
|
|
28
25
|
}, []);
|
|
29
|
-
}
|
|
26
|
+
};
|
|
30
27
|
|
|
31
28
|
export { useSavedCallback };
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Logs a warning.
|
|
9
|
+
*
|
|
10
|
+
* The warning is only logged if the condition is not met and
|
|
11
|
+
* `process.env.NODE_ENV !== 'production'` is truthy.
|
|
12
|
+
*
|
|
13
|
+
* @param condition - Condition to evaluate.
|
|
14
|
+
* @param message - Warning message.
|
|
15
|
+
* @throws Error if no `message` is provided.
|
|
16
|
+
*/
|
|
17
|
+
export declare const warning: (condition: boolean, message: string) => void;
|
package/es/internal/warning.js
CHANGED
|
@@ -5,21 +5,25 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
import { noopFn } from './noopFn.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Logs a warning.
|
|
12
|
+
*
|
|
13
|
+
* The warning is only logged if the condition is not met and
|
|
14
|
+
* `process.env.NODE_ENV !== 'production'` is truthy.
|
|
15
|
+
*
|
|
16
|
+
* @param condition - Condition to evaluate.
|
|
17
|
+
* @param message - Warning message.
|
|
18
|
+
* @throws Error if no `message` is provided.
|
|
19
|
+
*/
|
|
20
|
+
const warning = process.env.NODE_ENV !== 'production' ? (condition, message) => {
|
|
21
|
+
if (typeof message === 'undefined') {
|
|
22
|
+
throw new Error('`warning(condition, message)` requires a warning ' + 'format argument');
|
|
15
23
|
}
|
|
16
24
|
if (!condition) {
|
|
17
|
-
let index = 0;
|
|
18
|
-
const message = format.replace(/%s/g, () => {
|
|
19
|
-
return args[index++];
|
|
20
|
-
});
|
|
21
25
|
console.warn('Warning: ' + message);
|
|
22
26
|
}
|
|
23
|
-
} :
|
|
27
|
+
} : noopFn;
|
|
24
28
|
|
|
25
29
|
export { warning };
|
package/es/internal/wrapFocus.js
CHANGED
|
@@ -75,7 +75,7 @@ function wrapFocusWithoutSentinels(_ref2) {
|
|
|
75
75
|
currentActiveNode,
|
|
76
76
|
event
|
|
77
77
|
} = _ref2;
|
|
78
|
-
if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !==
|
|
78
|
+
if (['blur', 'focusout', 'focusin', 'focus'].includes(event.type) && process.env.NODE_ENV !== 'production') {
|
|
79
79
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
80
80
|
useEffect(() => {
|
|
81
81
|
throw new Error(`Error: wrapFocusWithoutSentinels(...) called in unsupported ${event.type} event.\n\nCall wrapFocusWithoutSentinels(...) from onKeyDown instead.`);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
function isRequiredOneOf(propTypes) {
|
|
15
15
|
const names = Object.keys(propTypes);
|
|
16
16
|
const checker = propType => function (props, propName, componentName) {
|
|
17
|
-
if (process.env.NODE_ENV !==
|
|
17
|
+
if (process.env.NODE_ENV !== 'production' && names.every(name => typeof props[name] === 'undefined')) {
|
|
18
18
|
return new Error(`${componentName} requires one of the following props: ${names.join(', ')}`);
|
|
19
19
|
}
|
|
20
20
|
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
function requiredIfGivenPropIsTruthy(name, propType) {
|
|
16
16
|
return function check(props, propName, componentName) {
|
|
17
|
-
if (process.env.NODE_ENV !==
|
|
17
|
+
if (process.env.NODE_ENV !== 'production' && props[name] == true && props[propName] == null) {
|
|
18
18
|
return new Error(`You must provide a value for \`${propName}\` in \`${componentName}\` if \`${name}\` exists.`);
|
|
19
19
|
}
|
|
20
20
|
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
package/es/tools/events.js
CHANGED
|
@@ -5,12 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Copyright IBM Corp. 2016, 2023
|
|
10
|
-
*
|
|
11
|
-
* This source code is licensed under the Apache-2.0 license found in the
|
|
12
|
-
* LICENSE file in the root directory of this source tree.
|
|
13
|
-
*/
|
|
8
|
+
// @ts-check
|
|
14
9
|
|
|
15
10
|
/**
|
|
16
11
|
* Generic utility to compose event handlers so that consumers can supply their
|
package/es/tools/toggleClass.js
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Adds or removes a CSS class to an element.
|
|
10
|
+
* @param {Element} element An element.
|
|
11
|
+
* @param {string} name A CSS class name.
|
|
12
|
+
* @param {boolean} add `true` to add the given CSS class to given the element. Otherwise to remove.
|
|
13
|
+
*/
|
|
8
14
|
function toggleClass(element, name, add) {
|
|
9
15
|
if (element.classList.contains(name) === !add) {
|
|
10
16
|
element.classList[add ? 'add' : 'remove'](name);
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 2024
|
|
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
7
|
import * as React from 'react';
|
|
2
8
|
export type ReactAttr<T = HTMLElement> = React.HTMLAttributes<T>;
|
|
3
9
|
export type ForwardRefProps<T, P = unknown> = React.PropsWithoutRef<React.PropsWithChildren<P>> & React.RefAttributes<T>;
|
|
@@ -13,7 +13,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
|
-
var useResizeObserver = require('use-resize-observer
|
|
16
|
+
var useResizeObserver = require('use-resize-observer');
|
|
17
17
|
var iconsReact = require('@carbon/icons-react');
|
|
18
18
|
var Copy = require('../Copy/Copy.js');
|
|
19
19
|
var Button = require('../Button/Button.js');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 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
7
|
import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode, type RefObject } from 'react';
|
|
2
8
|
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
9
|
/** Specify the content to be placed in the ModalBody. */
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2023, 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
7
|
import React, { type ReactNode, type MouseEvent, type Ref } from 'react';
|
|
2
8
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
3
9
|
export interface SecondaryButtonProps {
|
|
@@ -14,7 +14,7 @@ var ContainedList = require('./ContainedList.js');
|
|
|
14
14
|
var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
|
|
15
15
|
|
|
16
16
|
ContainedList["default"].ContainedListItem = ContainedListItem["default"];
|
|
17
|
-
if (process.env.NODE_ENV !==
|
|
17
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
18
18
|
deprecateFieldOnObject.deprecateFieldOnObject(ContainedList["default"], 'ContainedListItem', ContainedListItem["default"]);
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -201,10 +201,12 @@ export interface DataTableProps<RowType, ColTypes extends any[]> extends Transla
|
|
|
201
201
|
render?: (renderProps: DataTableRenderProps<RowType, ColTypes>) => React.ReactElement;
|
|
202
202
|
rows: Array<Omit<DataTableRow<ColTypes>, 'cells'>>;
|
|
203
203
|
size?: DataTableSize;
|
|
204
|
-
sortRow?: (cellA:
|
|
204
|
+
sortRow?: (cellA: any, cellB: any, sortRowOptions: {
|
|
205
205
|
sortDirection: DataTableSortState;
|
|
206
206
|
sortStates: Record<DataTableSortState, DataTableSortState>;
|
|
207
207
|
locale: string;
|
|
208
|
+
key: string;
|
|
209
|
+
compare: (a: number | string, b: number | string, locale?: string) => number;
|
|
208
210
|
}) => number;
|
|
209
211
|
stickyHeader?: boolean;
|
|
210
212
|
useStaticWidth?: boolean;
|
|
@@ -369,7 +369,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
369
369
|
nextArrow: rightArrowHTML,
|
|
370
370
|
prevArrow: leftArrowHTML,
|
|
371
371
|
onChange: function () {
|
|
372
|
-
if (
|
|
372
|
+
if (!readOnly) {
|
|
373
373
|
savedOnChange(...arguments);
|
|
374
374
|
}
|
|
375
375
|
},
|