@carbon/react 1.70.0-rc.0 → 1.71.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 +756 -756
- package/es/components/AILabel/index.js +15 -15
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/CodeSnippet/CodeSnippet.d.ts +5 -2
- package/es/components/CodeSnippet/CodeSnippet.js +40 -1
- package/es/components/ComboBox/ComboBox.js +28 -23
- package/es/components/ComboButton/index.js +40 -1
- package/es/components/ComposedModal/ComposedModal.js +6 -2
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
- package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
- package/es/components/Copy/Copy.d.ts +5 -2
- package/es/components/Copy/Copy.js +40 -1
- package/es/components/CopyButton/CopyButton.d.ts +5 -2
- package/es/components/CopyButton/CopyButton.js +40 -1
- package/es/components/DataTable/Table.d.ts +9 -1
- package/es/components/DataTable/Table.js +7 -2
- package/es/components/DataTable/TableSelectRow.js +14 -6
- package/es/components/DataTable/TableToolbarSearch.js +1 -1
- package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +0 -8
- package/es/components/DatePicker/plugins/appendToPlugin.js +2 -2
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +4 -4
- package/es/components/DatePicker/plugins/rangePlugin.js +2 -2
- package/es/components/DatePickerInput/DatePickerInput.d.ts +6 -1
- package/es/components/DatePickerInput/DatePickerInput.js +16 -10
- package/es/components/Dropdown/Dropdown.d.ts +5 -0
- package/es/components/Dropdown/Dropdown.js +132 -92
- package/es/components/FeatureFlags/index.js +1 -2
- package/es/components/IconButton/index.d.ts +4 -1
- package/es/components/IconButton/index.js +40 -1
- package/es/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -6
- package/es/components/InlineCheckbox/index.d.ts +9 -0
- package/es/components/LayoutDirection/LayoutDirection.d.ts +44 -0
- package/es/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
- package/es/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
- package/es/components/Menu/MenuItem.js +0 -3
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -2
- package/es/components/MultiSelect/MultiSelect.js +1 -1
- package/es/components/Notification/Notification.d.ts +9 -2
- package/es/components/Notification/Notification.js +16 -2
- package/es/components/NumberInput/NumberInput.d.ts +5 -0
- package/es/components/NumberInput/NumberInput.js +17 -9
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/OverflowMenu/next/index.js +40 -1
- package/es/components/Pagination/Pagination.js +2 -2
- package/es/components/Pagination/experimental/PageSelector.js +1 -1
- package/es/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/es/components/PaginationNav/PaginationNav.js +10 -5
- package/es/components/Popover/index.js +2 -2
- package/es/components/SkeletonText/SkeletonText.js +1 -1
- package/es/components/Tabs/Tabs.js +46 -29
- package/es/components/TextArea/TextArea.d.ts +5 -0
- package/es/components/TextArea/TextArea.js +15 -7
- package/es/components/TextInput/TextInput.d.ts +5 -0
- package/es/components/TextInput/TextInput.js +15 -7
- package/es/components/TreeView/TreeNode.js +1 -1
- package/es/components/TreeView/TreeView.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/SideNav.js +1 -1
- package/es/components/UIShell/SideNavItems.js +1 -1
- package/es/components/UIShell/SideNavMenu.js +1 -1
- package/es/components/UIShell/SideNavMenuItem.d.ts +5 -1
- package/es/components/UIShell/SideNavMenuItem.js +7 -2
- package/es/components/UIShell/Switcher.js +1 -1
- package/lib/components/AILabel/index.js +15 -15
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +5 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +40 -1
- package/lib/components/ComboBox/ComboBox.js +29 -23
- package/lib/components/ComboButton/index.js +40 -1
- package/lib/components/ComposedModal/ComposedModal.js +6 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
- package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
- package/lib/components/Copy/Copy.d.ts +5 -2
- package/lib/components/Copy/Copy.js +40 -1
- package/lib/components/CopyButton/CopyButton.d.ts +5 -2
- package/lib/components/CopyButton/CopyButton.js +40 -1
- package/lib/components/DataTable/Table.d.ts +9 -1
- package/lib/components/DataTable/Table.js +7 -2
- package/lib/components/DataTable/TableSelectRow.js +14 -6
- package/lib/components/DataTable/TableToolbarSearch.js +1 -1
- package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +0 -8
- package/lib/components/DatePicker/plugins/appendToPlugin.js +2 -2
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +4 -4
- package/lib/components/DatePicker/plugins/rangePlugin.js +2 -2
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +6 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +16 -10
- package/lib/components/Dropdown/Dropdown.d.ts +5 -0
- package/lib/components/Dropdown/Dropdown.js +131 -91
- package/lib/components/FeatureFlags/index.js +1 -2
- package/lib/components/IconButton/index.d.ts +4 -1
- package/lib/components/IconButton/index.js +40 -1
- package/lib/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -6
- package/lib/components/InlineCheckbox/index.d.ts +9 -0
- package/lib/components/LayoutDirection/LayoutDirection.d.ts +44 -0
- package/lib/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
- package/lib/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
- package/lib/components/Menu/MenuItem.js +0 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -2
- package/lib/components/MultiSelect/MultiSelect.js +1 -1
- package/lib/components/Notification/Notification.d.ts +9 -2
- package/lib/components/Notification/Notification.js +16 -2
- package/lib/components/NumberInput/NumberInput.d.ts +5 -0
- package/lib/components/NumberInput/NumberInput.js +17 -9
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/OverflowMenu/next/index.js +40 -1
- package/lib/components/Pagination/Pagination.js +2 -2
- package/lib/components/Pagination/experimental/PageSelector.js +1 -1
- package/lib/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/lib/components/PaginationNav/PaginationNav.js +10 -5
- package/lib/components/Popover/index.js +2 -2
- package/lib/components/SkeletonText/SkeletonText.js +1 -1
- package/lib/components/Tabs/Tabs.js +46 -29
- package/lib/components/TextArea/TextArea.d.ts +5 -0
- package/lib/components/TextArea/TextArea.js +15 -7
- package/lib/components/TextInput/TextInput.d.ts +5 -0
- package/lib/components/TextInput/TextInput.js +15 -7
- package/lib/components/TreeView/TreeNode.js +1 -1
- package/lib/components/TreeView/TreeView.js +1 -1
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/SideNav.js +1 -1
- package/lib/components/UIShell/SideNavItems.js +1 -1
- package/lib/components/UIShell/SideNavMenu.js +1 -1
- package/lib/components/UIShell/SideNavMenuItem.d.ts +5 -1
- package/lib/components/UIShell/SideNavMenuItem.js +7 -2
- package/lib/components/UIShell/Switcher.js +1 -1
- package/package.json +5 -5
|
@@ -11,7 +11,6 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
12
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
13
13
|
|
|
14
|
-
/** @type any */
|
|
15
14
|
const InlineCheckbox = /*#__PURE__*/React__default.forwardRef(function InlineCheckbox(props, forwardRef) {
|
|
16
15
|
const {
|
|
17
16
|
['aria-label']: ariaLabel,
|
|
@@ -48,15 +47,14 @@ const InlineCheckbox = /*#__PURE__*/React__default.forwardRef(function InlineChe
|
|
|
48
47
|
}
|
|
49
48
|
useEffect(() => {
|
|
50
49
|
if (inputRef?.current) {
|
|
51
|
-
inputRef.current.indeterminate = indeterminate;
|
|
50
|
+
inputRef.current.indeterminate = indeterminate || false;
|
|
52
51
|
}
|
|
53
52
|
}, [indeterminate]);
|
|
54
53
|
function onClickCheckBoxInput(evt) {
|
|
55
|
-
// If the previous "indeterminate" is true, change "checked" to false. If it is not undefined, we're working on `TableSelectAll`
|
|
56
54
|
if (indeterminate) {
|
|
57
55
|
evt.target.checked = false;
|
|
58
56
|
}
|
|
59
|
-
onClick(evt);
|
|
57
|
+
onClick?.(evt);
|
|
60
58
|
}
|
|
61
59
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
62
60
|
className: `${prefix}--checkbox--inline`
|
|
@@ -121,6 +119,5 @@ InlineCheckbox.propTypes = {
|
|
|
121
119
|
*/
|
|
122
120
|
title: PropTypes.string
|
|
123
121
|
};
|
|
124
|
-
var InlineCheckbox$1 = InlineCheckbox;
|
|
125
122
|
|
|
126
|
-
export { InlineCheckbox
|
|
123
|
+
export { InlineCheckbox as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import InlineCheckbox, { type InlineCheckboxProps } from './InlineCheckbox';
|
|
8
|
+
export default InlineCheckbox;
|
|
9
|
+
export { InlineCheckbox, type InlineCheckboxProps };
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { ElementType, ReactNode } from 'react';
|
|
9
|
+
import { LayoutDirectionContext } from './LayoutDirectionContext';
|
|
10
|
+
type Direction = 'ltr' | 'rtl';
|
|
11
|
+
interface LayoutDirectionProps {
|
|
12
|
+
/**
|
|
13
|
+
* Customize the element type used to render the outermost node
|
|
14
|
+
*/
|
|
15
|
+
as?: ElementType;
|
|
16
|
+
/**
|
|
17
|
+
* Provide child elements or components to be rendered inside of this
|
|
18
|
+
* component
|
|
19
|
+
*/
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* Specify the layout direction of this part of the page
|
|
23
|
+
*/
|
|
24
|
+
dir: Direction;
|
|
25
|
+
}
|
|
26
|
+
declare function LayoutDirection({ as: BaseComponent, children, dir, ...rest }: LayoutDirectionProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
declare namespace LayoutDirection {
|
|
28
|
+
var propTypes: {
|
|
29
|
+
/**
|
|
30
|
+
* Customize the element type used to render the outermost node
|
|
31
|
+
*/
|
|
32
|
+
as: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactComponentLike | null | undefined>>;
|
|
33
|
+
/**
|
|
34
|
+
* Provide child elements or components to be rendered inside of this
|
|
35
|
+
* component
|
|
36
|
+
*/
|
|
37
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
38
|
+
/**
|
|
39
|
+
* Specify the layout direction of this part of the page
|
|
40
|
+
*/
|
|
41
|
+
dir: PropTypes.Validator<string>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { LayoutDirectionContext, LayoutDirection };
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
import React from 'react';
|
|
8
|
+
export declare const LayoutDirectionContext: React.Context<{
|
|
9
|
+
direction: string;
|
|
10
|
+
}>;
|
|
@@ -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
|
+
* Get access to the current layout direction in context
|
|
9
|
+
*/
|
|
10
|
+
export declare function useLayoutDirection(): {
|
|
11
|
+
direction: string;
|
|
12
|
+
};
|
|
@@ -243,9 +243,6 @@ const MenuItemSelectable = /*#__PURE__*/forwardRef(function MenuItemSelectable(_
|
|
|
243
243
|
});
|
|
244
244
|
function handleClick(e) {
|
|
245
245
|
setChecked(!checked);
|
|
246
|
-
if (onChange) {
|
|
247
|
-
onChange(e);
|
|
248
|
-
}
|
|
249
246
|
}
|
|
250
247
|
useEffect(() => {
|
|
251
248
|
if (!context.state.hasIcons) {
|
|
@@ -61,7 +61,7 @@ export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSorting
|
|
|
61
61
|
*/
|
|
62
62
|
filterItems(items: readonly ItemType[], extra: {
|
|
63
63
|
inputValue: string | null;
|
|
64
|
-
itemToString: NonNullable<
|
|
64
|
+
itemToString: NonNullable<UseComboboxProps<ItemType>['itemToString']>;
|
|
65
65
|
}): ItemType[];
|
|
66
66
|
/**
|
|
67
67
|
* Specify whether the title text should be hidden or not
|
|
@@ -264,7 +264,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
264
264
|
inputValue,
|
|
265
265
|
stateReducer,
|
|
266
266
|
isItemDisabled(item, _index) {
|
|
267
|
-
return item
|
|
267
|
+
return item?.disabled;
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
function stateReducer(state, actionAndChanges) {
|
|
@@ -381,7 +381,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
381
381
|
activeIndex: highlightedIndex,
|
|
382
382
|
initialSelectedItems,
|
|
383
383
|
selectedItems: controlledSelectedItems,
|
|
384
|
-
itemToString,
|
|
385
384
|
onStateChange(changes) {
|
|
386
385
|
switch (changes.type) {
|
|
387
386
|
case SelectedItemKeyDownBackspace:
|
|
@@ -196,7 +196,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
196
196
|
selectedItem: controlledSelectedItems,
|
|
197
197
|
items: filteredItems,
|
|
198
198
|
isItemDisabled(item, _index) {
|
|
199
|
-
return item
|
|
199
|
+
return item?.disabled;
|
|
200
200
|
},
|
|
201
201
|
...downshiftProps
|
|
202
202
|
};
|
|
@@ -516,6 +516,13 @@ export declare namespace ActionableNotification {
|
|
|
516
516
|
* Callout
|
|
517
517
|
* ==================
|
|
518
518
|
*/
|
|
519
|
+
/**
|
|
520
|
+
* Deprecated callout kind values.
|
|
521
|
+
* @deprecated Use NewKindProps instead.
|
|
522
|
+
*/
|
|
523
|
+
export type DeprecatedKindProps = 'error' | 'info' | 'info-square' | 'success' | 'warning' | 'warning-alt';
|
|
524
|
+
export type NewKindProps = 'warning' | 'info';
|
|
525
|
+
export type KindProps = DeprecatedKindProps | NewKindProps;
|
|
519
526
|
export interface CalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
520
527
|
/**
|
|
521
528
|
* Pass in the action button label that will be rendered within the ActionableNotification.
|
|
@@ -532,7 +539,7 @@ export interface CalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
532
539
|
/**
|
|
533
540
|
* Specify what state the notification represents
|
|
534
541
|
*/
|
|
535
|
-
kind?:
|
|
542
|
+
kind?: KindProps;
|
|
536
543
|
/**
|
|
537
544
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
538
545
|
*/
|
|
@@ -576,7 +583,7 @@ export declare namespace Callout {
|
|
|
576
583
|
/**
|
|
577
584
|
* Specify what state the notification represents
|
|
578
585
|
*/
|
|
579
|
-
kind:
|
|
586
|
+
kind: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
580
587
|
/**
|
|
581
588
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
582
589
|
*/
|
|
@@ -22,6 +22,7 @@ import { noopFn } from '../../internal/noopFn.js';
|
|
|
22
22
|
import wrapFocus, { wrapFocusWithoutSentinels } from '../../internal/wrapFocus.js';
|
|
23
23
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
24
24
|
import { warning } from '../../internal/warning.js';
|
|
25
|
+
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
25
26
|
import { Text } from '../Text/Text.js';
|
|
26
27
|
import { match, matches } from '../../internal/keyboard/match.js';
|
|
27
28
|
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
@@ -693,6 +694,19 @@ ActionableNotification.propTypes = {
|
|
|
693
694
|
* ==================
|
|
694
695
|
*/
|
|
695
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Deprecated callout kind values.
|
|
699
|
+
* @deprecated Use NewKindProps instead.
|
|
700
|
+
*/
|
|
701
|
+
|
|
702
|
+
const propMappingFunction = deprecatedValue => {
|
|
703
|
+
const mapping = {
|
|
704
|
+
error: 'warning',
|
|
705
|
+
// only redirect error -> warning
|
|
706
|
+
success: 'info' // only redirect success -> info
|
|
707
|
+
};
|
|
708
|
+
return mapping[deprecatedValue];
|
|
709
|
+
};
|
|
696
710
|
function Callout(_ref8) {
|
|
697
711
|
let {
|
|
698
712
|
actionButtonLabel,
|
|
@@ -703,7 +717,7 @@ function Callout(_ref8) {
|
|
|
703
717
|
subtitle,
|
|
704
718
|
statusIconDescription,
|
|
705
719
|
className,
|
|
706
|
-
kind = '
|
|
720
|
+
kind = 'info',
|
|
707
721
|
lowContrast,
|
|
708
722
|
...rest
|
|
709
723
|
} = _ref8;
|
|
@@ -759,7 +773,7 @@ Callout.propTypes = {
|
|
|
759
773
|
/**
|
|
760
774
|
* Specify what state the notification represents
|
|
761
775
|
*/
|
|
762
|
-
kind: PropTypes.oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']),
|
|
776
|
+
kind: deprecateValuesWithin(PropTypes.oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']), ['warning', 'info'], propMappingFunction),
|
|
763
777
|
/**
|
|
764
778
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
765
779
|
*/
|
|
@@ -24,6 +24,10 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
24
24
|
* Specify an optional className to be applied to the wrapper node
|
|
25
25
|
*/
|
|
26
26
|
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TextInput` component
|
|
29
|
+
*/
|
|
30
|
+
decorator?: ReactNode;
|
|
27
31
|
/**
|
|
28
32
|
* Optional starting value for uncontrolled state
|
|
29
33
|
*/
|
|
@@ -113,6 +117,7 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
113
117
|
*/
|
|
114
118
|
size?: 'sm' | 'md' | 'lg';
|
|
115
119
|
/**
|
|
120
|
+
* @deprecated please use `decorator` instead.
|
|
116
121
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
117
122
|
*/
|
|
118
123
|
slug?: ReactNode;
|
|
@@ -37,6 +37,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
37
37
|
const {
|
|
38
38
|
allowEmpty = false,
|
|
39
39
|
className: customClassName,
|
|
40
|
+
decorator,
|
|
40
41
|
disabled = false,
|
|
41
42
|
disableWheel: disableWheelProp = false,
|
|
42
43
|
defaultValue = 0,
|
|
@@ -112,7 +113,8 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
112
113
|
const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
|
|
113
114
|
const wrapperClasses = cx(`${prefix}--number__input-wrapper`, {
|
|
114
115
|
[`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
|
|
115
|
-
[`${prefix}--number__input-wrapper--slug`]: slug
|
|
116
|
+
[`${prefix}--number__input-wrapper--slug`]: slug,
|
|
117
|
+
[`${prefix}--number__input-wrapper--decorator`]: decorator
|
|
116
118
|
});
|
|
117
119
|
const iconClasses = cx({
|
|
118
120
|
[`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
|
|
@@ -186,18 +188,18 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
|
|
189
|
-
//
|
|
190
|
-
let
|
|
191
|
-
if (
|
|
192
|
-
|
|
191
|
+
// AILabel always size `mini`
|
|
192
|
+
let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
193
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
194
|
+
normalizedDecorator = /*#__PURE__*/React__default.cloneElement(normalizedDecorator, {
|
|
193
195
|
size: 'mini'
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
|
|
197
199
|
// Need to update the internal value when the revert button is clicked
|
|
198
200
|
let isRevertActive;
|
|
199
|
-
if (
|
|
200
|
-
isRevertActive =
|
|
201
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
202
|
+
isRevertActive = normalizedDecorator.props.revertActive;
|
|
201
203
|
}
|
|
202
204
|
useEffect(() => {
|
|
203
205
|
if (!isRevertActive && slug && defaultValue) {
|
|
@@ -252,7 +254,9 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
252
254
|
step: step,
|
|
253
255
|
type: "number",
|
|
254
256
|
value: value
|
|
255
|
-
})),
|
|
257
|
+
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default.createElement("div", {
|
|
258
|
+
className: `${prefix}--number__input-inner-wrapper--decorator`
|
|
259
|
+
}, normalizedDecorator) : '', Icon ? /*#__PURE__*/React__default.createElement(Icon, {
|
|
256
260
|
className: iconClasses
|
|
257
261
|
}) : null, !hideSteppers && /*#__PURE__*/React__default.createElement("div", {
|
|
258
262
|
className: `${prefix}--number__controls`
|
|
@@ -297,6 +301,10 @@ NumberInput.propTypes = {
|
|
|
297
301
|
* Specify an optional className to be applied to the wrapper node
|
|
298
302
|
*/
|
|
299
303
|
className: PropTypes.string,
|
|
304
|
+
/**
|
|
305
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `NumberInput` component
|
|
306
|
+
*/
|
|
307
|
+
decorator: PropTypes.node,
|
|
300
308
|
/**
|
|
301
309
|
* Optional starting value for uncontrolled state
|
|
302
310
|
*/
|
|
@@ -379,7 +387,7 @@ NumberInput.propTypes = {
|
|
|
379
387
|
/**
|
|
380
388
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `NumberInput` component
|
|
381
389
|
*/
|
|
382
|
-
slug: PropTypes.node,
|
|
390
|
+
slug: deprecate(PropTypes.node, 'The `slug` prop for `NumberInput` is no longer needed and has ' + 'been deprecated in v11 in favor of the new `decorator` prop. It will be moved in the next major release.'),
|
|
383
391
|
/**
|
|
384
392
|
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
385
393
|
*/
|
|
@@ -206,7 +206,7 @@ class OverflowMenu extends React__default.Component {
|
|
|
206
206
|
direction
|
|
207
207
|
} = _ref;
|
|
208
208
|
const enabledIndices = React__default.Children.toArray(this.props.children).reduce((acc, curr, i) => {
|
|
209
|
-
if (
|
|
209
|
+
if (/*#__PURE__*/React__default.isValidElement(curr) && !curr.props.disabled) {
|
|
210
210
|
acc.push(i);
|
|
211
211
|
}
|
|
212
212
|
return acc;
|
|
@@ -19,8 +19,22 @@ import mergeRefs from '../../../tools/mergeRefs.js';
|
|
|
19
19
|
import { useId } from '../../../internal/useId.js';
|
|
20
20
|
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
21
21
|
import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
|
|
22
|
+
import deprecateValuesWithin from '../../../prop-types/deprecateValuesWithin.js';
|
|
22
23
|
|
|
23
24
|
const defaultSize = 'md';
|
|
25
|
+
const propMappingFunction = deprecatedValue => {
|
|
26
|
+
const mapping = {
|
|
27
|
+
'top-left': 'top-start',
|
|
28
|
+
'top-right': 'top-end',
|
|
29
|
+
'bottom-left': 'bottom-start',
|
|
30
|
+
'bottom-right': 'bottom-end',
|
|
31
|
+
'left-bottom': 'left-end',
|
|
32
|
+
'left-top': 'left-start',
|
|
33
|
+
'right-bottom': 'right-end',
|
|
34
|
+
'right-top': 'right-start'
|
|
35
|
+
};
|
|
36
|
+
return mapping[deprecatedValue];
|
|
37
|
+
};
|
|
24
38
|
const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMenu(_ref, forwardRef) {
|
|
25
39
|
let {
|
|
26
40
|
autoAlign = false,
|
|
@@ -162,7 +176,32 @@ OverflowMenu.propTypes = {
|
|
|
162
176
|
/**
|
|
163
177
|
* Specify how the trigger tooltip should be aligned.
|
|
164
178
|
*/
|
|
165
|
-
tooltipAlignment: PropTypes.oneOf(['top', 'top-left',
|
|
179
|
+
tooltipAlignment: deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
180
|
+
// deprecated use top-start instead
|
|
181
|
+
'top-right',
|
|
182
|
+
// deprecated use top-end instead
|
|
183
|
+
|
|
184
|
+
'bottom', 'bottom-left',
|
|
185
|
+
// deprecated use bottom-start instead
|
|
186
|
+
'bottom-right',
|
|
187
|
+
// deprecated use bottom-end instead
|
|
188
|
+
|
|
189
|
+
'left', 'left-bottom',
|
|
190
|
+
// deprecated use left-end instead
|
|
191
|
+
'left-top',
|
|
192
|
+
// deprecated use left-start instead
|
|
193
|
+
|
|
194
|
+
'right', 'right-bottom',
|
|
195
|
+
// deprecated use right-end instead
|
|
196
|
+
'right-top',
|
|
197
|
+
// deprecated use right-start instead
|
|
198
|
+
|
|
199
|
+
// new values to match floating-ui
|
|
200
|
+
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
201
|
+
//allowed prop values
|
|
202
|
+
['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
|
|
203
|
+
//optional mapper function
|
|
204
|
+
propMappingFunction),
|
|
166
205
|
/**
|
|
167
206
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
168
207
|
*/
|
|
@@ -29,7 +29,7 @@ function renderSelectItems(total) {
|
|
|
29
29
|
let counter = 1;
|
|
30
30
|
const itemArr = [];
|
|
31
31
|
while (counter <= total) {
|
|
32
|
-
itemArr.push(
|
|
32
|
+
itemArr.push(/*#__PURE__*/React__default.createElement(SelectItem, {
|
|
33
33
|
key: counter,
|
|
34
34
|
value: counter,
|
|
35
35
|
text: String(counter)
|
|
@@ -245,7 +245,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
245
245
|
onClick: decrementPage,
|
|
246
246
|
ref: backBtnRef
|
|
247
247
|
}, _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null))), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
248
|
-
align: "top-
|
|
248
|
+
align: "top-end",
|
|
249
249
|
disabled: forwardButtonDisabled || isLastPage,
|
|
250
250
|
kind: "ghost",
|
|
251
251
|
className: forwardButtonClasses,
|
|
@@ -30,7 +30,7 @@ function PageSelector(_ref) {
|
|
|
30
30
|
const renderPages = total => {
|
|
31
31
|
const pages = [];
|
|
32
32
|
for (let counter = 1; counter <= total; counter += 1) {
|
|
33
|
-
pages.push(
|
|
33
|
+
pages.push(/*#__PURE__*/React__default.createElement(SelectItem, {
|
|
34
34
|
key: counter,
|
|
35
35
|
value: counter,
|
|
36
36
|
text: String(counter)
|
|
@@ -28,7 +28,7 @@ interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'on
|
|
|
28
28
|
*/
|
|
29
29
|
disableOverflow?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
* The number of items to be shown.
|
|
31
|
+
* The number of items to be shown (minimum of 4 unless props.items < 4).
|
|
32
32
|
*/
|
|
33
33
|
itemsShown?: number;
|
|
34
34
|
/**
|
|
@@ -12,6 +12,8 @@ import cx from 'classnames';
|
|
|
12
12
|
import { CaretRight, CaretLeft, OverflowMenuHorizontal } from '@carbon/icons-react';
|
|
13
13
|
import { IconButton } from '../IconButton/index.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { breakpoints } from '@carbon/layout';
|
|
16
|
+
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
15
17
|
|
|
16
18
|
var _CaretRight, _CaretLeft, _option;
|
|
17
19
|
const translationIds = {
|
|
@@ -179,8 +181,10 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
179
181
|
translateWithId: t = translateWithId,
|
|
180
182
|
...rest
|
|
181
183
|
} = _ref4;
|
|
184
|
+
const smMediaQuery = `(max-width: ${breakpoints.sm.width})`;
|
|
185
|
+
const isSm = useMatchMedia(smMediaQuery);
|
|
182
186
|
const [currentPage, setCurrentPage] = useState(page);
|
|
183
|
-
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = useState(itemsShown >= 4 ? itemsShown : 4);
|
|
187
|
+
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = useState(itemsShown >= 4 && !isSm ? itemsShown : 4);
|
|
184
188
|
const [cuts, setCuts] = useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
|
|
185
189
|
const prevPage = usePrevious(currentPage);
|
|
186
190
|
const prefix = usePrefix();
|
|
@@ -225,9 +229,10 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
225
229
|
|
|
226
230
|
// re-calculate cuts if props.totalItems or props.itemsShown change
|
|
227
231
|
useEffect(() => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
232
|
+
const itemsToBeShown = itemsShown >= 4 && !isSm ? itemsShown : 4;
|
|
233
|
+
setItemsDisplayedOnPage(Math.max(itemsToBeShown, 4));
|
|
234
|
+
setCuts(calculateCuts(currentPage, totalItems, Math.max(itemsToBeShown, 4)));
|
|
235
|
+
}, [totalItems, itemsShown, isSm]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
231
236
|
|
|
232
237
|
// update cuts if necessary whenever currentPage changes
|
|
233
238
|
useEffect(() => {
|
|
@@ -386,7 +391,7 @@ PaginationNav.propTypes = {
|
|
|
386
391
|
// eslint-disable-line react/prop-types
|
|
387
392
|
|
|
388
393
|
/**
|
|
389
|
-
* The number of items to be shown.
|
|
394
|
+
* The number of items to be shown (minimum of 4 unless props.items < 4).
|
|
390
395
|
*/
|
|
391
396
|
itemsShown: PropTypes.number,
|
|
392
397
|
/**
|
|
@@ -213,7 +213,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
|
|
|
213
213
|
const isTriggerElement = item?.type === 'button';
|
|
214
214
|
const isTriggerComponent = enableFloatingStyles && displayName && ['ToggletipButton'].includes(displayName);
|
|
215
215
|
const isAllowedTriggerComponent = enableFloatingStyles && !['ToggletipContent', 'PopoverContent'].includes(displayName);
|
|
216
|
-
if (
|
|
216
|
+
if (/*#__PURE__*/React__default.isValidElement(item) && (isTriggerElement || isTriggerComponent || isAllowedTriggerComponent)) {
|
|
217
217
|
const className = item?.props?.className;
|
|
218
218
|
const ref = (item?.props).ref;
|
|
219
219
|
const tabTipClasses = cx(`${prefix}--popover--tab-tip__button`, className);
|
|
@@ -336,7 +336,7 @@ Popover.propTypes = {
|
|
|
336
336
|
*/
|
|
337
337
|
open: PropTypes.bool.isRequired
|
|
338
338
|
};
|
|
339
|
-
function PopoverContentRenderFunction(
|
|
339
|
+
function PopoverContentRenderFunction(// eslint-disable-next-line react/prop-types
|
|
340
340
|
_ref2, forwardRef) {
|
|
341
341
|
let {
|
|
342
342
|
className,
|
|
@@ -56,7 +56,7 @@ const SkeletonText = _ref => {
|
|
|
56
56
|
}, [lineCountNumber, paragraph, refs, width, widthNum, widthPercent, widthPx]);
|
|
57
57
|
const lines = [];
|
|
58
58
|
for (let i = 0; i < lineCountNumber; i++) {
|
|
59
|
-
lines.push(
|
|
59
|
+
lines.push(/*#__PURE__*/React__default.createElement("p", _extends({
|
|
60
60
|
className: skeletonTextClasses,
|
|
61
61
|
key: i,
|
|
62
62
|
ref: el => refs.current = [...refs.current, el]
|
|
@@ -346,6 +346,41 @@ function TabList(_ref4) {
|
|
|
346
346
|
setActiveIndex(selectedIndex);
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Scroll the tab into view if it is not already visible
|
|
352
|
+
* @param tab - The tab to scroll into view
|
|
353
|
+
* @returns {void}
|
|
354
|
+
*/
|
|
355
|
+
function scrollTabIntoView(tab) {
|
|
356
|
+
if (!isScrollable || !ref.current) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (tab) {
|
|
360
|
+
// The width of the "scroll buttons"
|
|
361
|
+
const {
|
|
362
|
+
width: tabWidth
|
|
363
|
+
} = tab.getBoundingClientRect();
|
|
364
|
+
|
|
365
|
+
// The start and end position of the selected tab
|
|
366
|
+
const start = tab.offsetLeft;
|
|
367
|
+
const end = tab.offsetLeft + tabWidth;
|
|
368
|
+
|
|
369
|
+
// The start and end of the visible area for the tabs
|
|
370
|
+
const visibleStart = ref.current.scrollLeft + buttonWidth;
|
|
371
|
+
const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
|
|
372
|
+
|
|
373
|
+
// The beginning of the tab is clipped and not visible
|
|
374
|
+
if (start < visibleStart) {
|
|
375
|
+
setScrollLeft(start - buttonWidth);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// The end of the tab is clipped and not visible
|
|
379
|
+
if (end > visibleEnd) {
|
|
380
|
+
setScrollLeft(end + buttonWidth - ref.current.clientWidth);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
349
384
|
useEffectOnce(() => {
|
|
350
385
|
const tab = tabs.current[selectedIndex];
|
|
351
386
|
if (scrollIntoView && tab) {
|
|
@@ -377,12 +412,12 @@ function TabList(_ref4) {
|
|
|
377
412
|
});
|
|
378
413
|
useIsomorphicEffect(() => {
|
|
379
414
|
if (ref.current) {
|
|
380
|
-
//adding 1 in calculation for firefox support
|
|
415
|
+
// adding 1 in calculation for firefox support
|
|
381
416
|
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
|
|
382
417
|
}
|
|
383
418
|
function handler() {
|
|
384
419
|
if (ref.current) {
|
|
385
|
-
//adding 1 in calculation for firefox support
|
|
420
|
+
// adding 1 in calculation for firefox support
|
|
386
421
|
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
|
|
387
422
|
}
|
|
388
423
|
}
|
|
@@ -400,36 +435,18 @@ function TabList(_ref4) {
|
|
|
400
435
|
ref.current.scrollLeft = scrollLeft;
|
|
401
436
|
}
|
|
402
437
|
}, [scrollLeft]);
|
|
438
|
+
|
|
439
|
+
// scroll manual tabs when active index changes (focus outline movement)
|
|
403
440
|
useIsomorphicEffect(() => {
|
|
404
|
-
if (!isScrollable || !ref.current) {
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
441
|
const tab = activation === 'manual' ? tabs.current[activeIndex] : tabs.current[selectedIndex];
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
// The start and end position of the selected tab
|
|
412
|
-
const {
|
|
413
|
-
width: tabWidth
|
|
414
|
-
} = tab.getBoundingClientRect();
|
|
415
|
-
const start = tab.offsetLeft;
|
|
416
|
-
const end = tab.offsetLeft + tabWidth;
|
|
417
|
-
|
|
418
|
-
// The start and end of the visible area for the tabs
|
|
419
|
-
const visibleStart = ref.current.scrollLeft + buttonWidth;
|
|
420
|
-
const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
|
|
421
|
-
|
|
422
|
-
// The beginning of the tab is clipped and not visible
|
|
423
|
-
if (start < visibleStart) {
|
|
424
|
-
setScrollLeft(start - buttonWidth);
|
|
425
|
-
}
|
|
442
|
+
scrollTabIntoView(tab);
|
|
443
|
+
}, [activation, activeIndex]);
|
|
426
444
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}, [activation, activeIndex, selectedIndex, isScrollable, children]);
|
|
445
|
+
// scroll tabs when selected index changes
|
|
446
|
+
useIsomorphicEffect(() => {
|
|
447
|
+
const tab = tabs.current[selectedIndex];
|
|
448
|
+
scrollTabIntoView(tab);
|
|
449
|
+
}, [selectedIndex, isScrollable, children]);
|
|
433
450
|
usePressable(previousButton, {
|
|
434
451
|
onPress(_ref6) {
|
|
435
452
|
let {
|
|
@@ -15,6 +15,10 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
15
15
|
* Specify the `cols` attribute for the underlying `<textarea>` node
|
|
16
16
|
*/
|
|
17
17
|
cols?: number;
|
|
18
|
+
/**
|
|
19
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TextArea` component
|
|
20
|
+
*/
|
|
21
|
+
decorator?: ReactNode;
|
|
18
22
|
/**
|
|
19
23
|
* Optionally provide the default value of the `<textarea>`
|
|
20
24
|
*/
|
|
@@ -90,6 +94,7 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
|
|
|
90
94
|
*/
|
|
91
95
|
rows?: number;
|
|
92
96
|
/**
|
|
97
|
+
* @deprecated please use `decorator` instead.
|
|
93
98
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
94
99
|
*/
|
|
95
100
|
slug?: ReactNode;
|