@carbon/react 1.70.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 +895 -895
- package/es/components/AILabel/index.js +15 -15
- package/es/components/CodeSnippet/CodeSnippet.d.ts +5 -2
- package/es/components/CodeSnippet/CodeSnippet.js +40 -1
- package/es/components/ComboBox/ComboBox.js +19 -22
- package/es/components/ComboButton/index.js +40 -1
- 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/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/plugins/fixEventsPlugin.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/next/index.js +40 -1
- package/es/components/Pagination/Pagination.js +1 -1
- package/es/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/es/components/PaginationNav/PaginationNav.js +10 -5
- 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/UIShell/SideNavMenuItem.d.ts +5 -1
- package/es/components/UIShell/SideNavMenuItem.js +7 -2
- package/lib/components/AILabel/index.js +15 -15
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +5 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +40 -1
- package/lib/components/ComboBox/ComboBox.js +19 -22
- package/lib/components/ComboButton/index.js +40 -1
- 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/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/plugins/fixEventsPlugin.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/next/index.js +40 -1
- package/lib/components/Pagination/Pagination.js +1 -1
- package/lib/components/PaginationNav/PaginationNav.d.ts +1 -1
- package/lib/components/PaginationNav/PaginationNav.js +10 -5
- 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/UIShell/SideNavMenuItem.d.ts +5 -1
- package/lib/components/UIShell/SideNavMenuItem.js +7 -2
- package/package.json +4 -4
|
@@ -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
|
|
@@ -276,7 +276,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
276
276
|
inputValue,
|
|
277
277
|
stateReducer,
|
|
278
278
|
isItemDisabled(item, _index) {
|
|
279
|
-
return item
|
|
279
|
+
return item?.disabled;
|
|
280
280
|
}
|
|
281
281
|
});
|
|
282
282
|
function stateReducer(state, actionAndChanges) {
|
|
@@ -393,7 +393,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
393
393
|
activeIndex: highlightedIndex,
|
|
394
394
|
initialSelectedItems,
|
|
395
395
|
selectedItems: controlledSelectedItems,
|
|
396
|
-
itemToString: itemToString$1,
|
|
397
396
|
onStateChange(changes) {
|
|
398
397
|
switch (changes.type) {
|
|
399
398
|
case SelectedItemKeyDownBackspace:
|
|
@@ -207,7 +207,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
207
207
|
selectedItem: controlledSelectedItems,
|
|
208
208
|
items: filteredItems,
|
|
209
209
|
isItemDisabled(item, _index) {
|
|
210
|
-
return item
|
|
210
|
+
return item?.disabled;
|
|
211
211
|
},
|
|
212
212
|
...downshiftProps
|
|
213
213
|
};
|
|
@@ -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
|
*/
|
|
@@ -26,6 +26,7 @@ var noopFn = require('../../internal/noopFn.js');
|
|
|
26
26
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
27
27
|
var index = require('../FeatureFlags/index.js');
|
|
28
28
|
var warning = require('../../internal/warning.js');
|
|
29
|
+
var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
|
|
29
30
|
var Text = require('../Text/Text.js');
|
|
30
31
|
var match = require('../../internal/keyboard/match.js');
|
|
31
32
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -703,6 +704,19 @@ ActionableNotification.propTypes = {
|
|
|
703
704
|
* ==================
|
|
704
705
|
*/
|
|
705
706
|
|
|
707
|
+
/**
|
|
708
|
+
* Deprecated callout kind values.
|
|
709
|
+
* @deprecated Use NewKindProps instead.
|
|
710
|
+
*/
|
|
711
|
+
|
|
712
|
+
const propMappingFunction = deprecatedValue => {
|
|
713
|
+
const mapping = {
|
|
714
|
+
error: 'warning',
|
|
715
|
+
// only redirect error -> warning
|
|
716
|
+
success: 'info' // only redirect success -> info
|
|
717
|
+
};
|
|
718
|
+
return mapping[deprecatedValue];
|
|
719
|
+
};
|
|
706
720
|
function Callout(_ref8) {
|
|
707
721
|
let {
|
|
708
722
|
actionButtonLabel,
|
|
@@ -713,7 +727,7 @@ function Callout(_ref8) {
|
|
|
713
727
|
subtitle,
|
|
714
728
|
statusIconDescription,
|
|
715
729
|
className,
|
|
716
|
-
kind = '
|
|
730
|
+
kind = 'info',
|
|
717
731
|
lowContrast,
|
|
718
732
|
...rest
|
|
719
733
|
} = _ref8;
|
|
@@ -769,7 +783,7 @@ Callout.propTypes = {
|
|
|
769
783
|
/**
|
|
770
784
|
* Specify what state the notification represents
|
|
771
785
|
*/
|
|
772
|
-
kind: PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']),
|
|
786
|
+
kind: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']), ['warning', 'info'], propMappingFunction),
|
|
773
787
|
/**
|
|
774
788
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
775
789
|
*/
|
|
@@ -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;
|
|
@@ -47,6 +47,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
47
47
|
const {
|
|
48
48
|
allowEmpty = false,
|
|
49
49
|
className: customClassName,
|
|
50
|
+
decorator,
|
|
50
51
|
disabled = false,
|
|
51
52
|
disableWheel: disableWheelProp = false,
|
|
52
53
|
defaultValue = 0,
|
|
@@ -122,7 +123,8 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
122
123
|
const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
|
|
123
124
|
const wrapperClasses = cx__default["default"](`${prefix}--number__input-wrapper`, {
|
|
124
125
|
[`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
|
|
125
|
-
[`${prefix}--number__input-wrapper--slug`]: slug
|
|
126
|
+
[`${prefix}--number__input-wrapper--slug`]: slug,
|
|
127
|
+
[`${prefix}--number__input-wrapper--decorator`]: decorator
|
|
126
128
|
});
|
|
127
129
|
const iconClasses = cx__default["default"]({
|
|
128
130
|
[`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
|
|
@@ -196,18 +198,18 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
196
198
|
}
|
|
197
199
|
}
|
|
198
200
|
|
|
199
|
-
//
|
|
200
|
-
let
|
|
201
|
-
if (
|
|
202
|
-
|
|
201
|
+
// AILabel always size `mini`
|
|
202
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
203
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
204
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
203
205
|
size: 'mini'
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
// Need to update the internal value when the revert button is clicked
|
|
208
210
|
let isRevertActive;
|
|
209
|
-
if (
|
|
210
|
-
isRevertActive =
|
|
211
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
212
|
+
isRevertActive = normalizedDecorator.props.revertActive;
|
|
211
213
|
}
|
|
212
214
|
React.useEffect(() => {
|
|
213
215
|
if (!isRevertActive && slug && defaultValue) {
|
|
@@ -262,7 +264,9 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
262
264
|
step: step,
|
|
263
265
|
type: "number",
|
|
264
266
|
value: value
|
|
265
|
-
})),
|
|
267
|
+
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
268
|
+
className: `${prefix}--number__input-inner-wrapper--decorator`
|
|
269
|
+
}, normalizedDecorator) : '', Icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
266
270
|
className: iconClasses
|
|
267
271
|
}) : null, !hideSteppers && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
268
272
|
className: `${prefix}--number__controls`
|
|
@@ -307,6 +311,10 @@ NumberInput.propTypes = {
|
|
|
307
311
|
* Specify an optional className to be applied to the wrapper node
|
|
308
312
|
*/
|
|
309
313
|
className: PropTypes__default["default"].string,
|
|
314
|
+
/**
|
|
315
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `NumberInput` component
|
|
316
|
+
*/
|
|
317
|
+
decorator: PropTypes__default["default"].node,
|
|
310
318
|
/**
|
|
311
319
|
* Optional starting value for uncontrolled state
|
|
312
320
|
*/
|
|
@@ -389,7 +397,7 @@ NumberInput.propTypes = {
|
|
|
389
397
|
/**
|
|
390
398
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `NumberInput` component
|
|
391
399
|
*/
|
|
392
|
-
slug: PropTypes__default["default"].node,
|
|
400
|
+
slug: deprecate["default"](PropTypes__default["default"].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.'),
|
|
393
401
|
/**
|
|
394
402
|
* Specify how much the values should increase/decrease upon clicking on up/down button
|
|
395
403
|
*/
|
|
@@ -23,6 +23,7 @@ var mergeRefs = require('../../../tools/mergeRefs.js');
|
|
|
23
23
|
var useId = require('../../../internal/useId.js');
|
|
24
24
|
var usePrefix = require('../../../internal/usePrefix.js');
|
|
25
25
|
var useAttachedMenu = require('../../../internal/useAttachedMenu.js');
|
|
26
|
+
var deprecateValuesWithin = require('../../../prop-types/deprecateValuesWithin.js');
|
|
26
27
|
|
|
27
28
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
28
29
|
|
|
@@ -31,6 +32,19 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
31
32
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
32
33
|
|
|
33
34
|
const defaultSize = 'md';
|
|
35
|
+
const propMappingFunction = deprecatedValue => {
|
|
36
|
+
const mapping = {
|
|
37
|
+
'top-left': 'top-start',
|
|
38
|
+
'top-right': 'top-end',
|
|
39
|
+
'bottom-left': 'bottom-start',
|
|
40
|
+
'bottom-right': 'bottom-end',
|
|
41
|
+
'left-bottom': 'left-end',
|
|
42
|
+
'left-top': 'left-start',
|
|
43
|
+
'right-bottom': 'right-end',
|
|
44
|
+
'right-top': 'right-start'
|
|
45
|
+
};
|
|
46
|
+
return mapping[deprecatedValue];
|
|
47
|
+
};
|
|
34
48
|
const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function OverflowMenu(_ref, forwardRef) {
|
|
35
49
|
let {
|
|
36
50
|
autoAlign = false,
|
|
@@ -172,7 +186,32 @@ OverflowMenu.propTypes = {
|
|
|
172
186
|
/**
|
|
173
187
|
* Specify how the trigger tooltip should be aligned.
|
|
174
188
|
*/
|
|
175
|
-
tooltipAlignment: PropTypes__default["default"].oneOf(['top', 'top-left',
|
|
189
|
+
tooltipAlignment: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['top', 'top-left',
|
|
190
|
+
// deprecated use top-start instead
|
|
191
|
+
'top-right',
|
|
192
|
+
// deprecated use top-end instead
|
|
193
|
+
|
|
194
|
+
'bottom', 'bottom-left',
|
|
195
|
+
// deprecated use bottom-start instead
|
|
196
|
+
'bottom-right',
|
|
197
|
+
// deprecated use bottom-end instead
|
|
198
|
+
|
|
199
|
+
'left', 'left-bottom',
|
|
200
|
+
// deprecated use left-end instead
|
|
201
|
+
'left-top',
|
|
202
|
+
// deprecated use left-start instead
|
|
203
|
+
|
|
204
|
+
'right', 'right-bottom',
|
|
205
|
+
// deprecated use right-end instead
|
|
206
|
+
'right-top',
|
|
207
|
+
// deprecated use right-start instead
|
|
208
|
+
|
|
209
|
+
// new values to match floating-ui
|
|
210
|
+
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
211
|
+
//allowed prop values
|
|
212
|
+
['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
|
|
213
|
+
//optional mapper function
|
|
214
|
+
propMappingFunction),
|
|
176
215
|
/**
|
|
177
216
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
178
217
|
*/
|
|
@@ -255,7 +255,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
255
255
|
onClick: decrementPage,
|
|
256
256
|
ref: backBtnRef
|
|
257
257
|
}, _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default["default"].createElement(iconsReact.CaretLeft, null))), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
258
|
-
align: "top-
|
|
258
|
+
align: "top-end",
|
|
259
259
|
disabled: forwardButtonDisabled || isLastPage,
|
|
260
260
|
kind: "ghost",
|
|
261
261
|
className: forwardButtonClasses,
|
|
@@ -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
|
/**
|
|
@@ -16,6 +16,8 @@ var cx = require('classnames');
|
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
17
|
var index = require('../IconButton/index.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var layout = require('@carbon/layout');
|
|
20
|
+
var useMatchMedia = require('../../internal/useMatchMedia.js');
|
|
19
21
|
|
|
20
22
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
23
|
|
|
@@ -189,8 +191,10 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
189
191
|
translateWithId: t = translateWithId,
|
|
190
192
|
...rest
|
|
191
193
|
} = _ref4;
|
|
194
|
+
const smMediaQuery = `(max-width: ${layout.breakpoints.sm.width})`;
|
|
195
|
+
const isSm = useMatchMedia.useMatchMedia(smMediaQuery);
|
|
192
196
|
const [currentPage, setCurrentPage] = React.useState(page);
|
|
193
|
-
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 ? itemsShown : 4);
|
|
197
|
+
const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 && !isSm ? itemsShown : 4);
|
|
194
198
|
const [cuts, setCuts] = React.useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
|
|
195
199
|
const prevPage = usePrevious(currentPage);
|
|
196
200
|
const prefix = usePrefix.usePrefix();
|
|
@@ -235,9 +239,10 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
235
239
|
|
|
236
240
|
// re-calculate cuts if props.totalItems or props.itemsShown change
|
|
237
241
|
React.useEffect(() => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
const itemsToBeShown = itemsShown >= 4 && !isSm ? itemsShown : 4;
|
|
243
|
+
setItemsDisplayedOnPage(Math.max(itemsToBeShown, 4));
|
|
244
|
+
setCuts(calculateCuts(currentPage, totalItems, Math.max(itemsToBeShown, 4)));
|
|
245
|
+
}, [totalItems, itemsShown, isSm]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
241
246
|
|
|
242
247
|
// update cuts if necessary whenever currentPage changes
|
|
243
248
|
React.useEffect(() => {
|
|
@@ -396,7 +401,7 @@ PaginationNav.propTypes = {
|
|
|
396
401
|
// eslint-disable-line react/prop-types
|
|
397
402
|
|
|
398
403
|
/**
|
|
399
|
-
* The number of items to be shown.
|
|
404
|
+
* The number of items to be shown (minimum of 4 unless props.items < 4).
|
|
400
405
|
*/
|
|
401
406
|
itemsShown: PropTypes__default["default"].number,
|
|
402
407
|
/**
|
|
@@ -357,6 +357,41 @@ function TabList(_ref4) {
|
|
|
357
357
|
setActiveIndex(selectedIndex);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Scroll the tab into view if it is not already visible
|
|
363
|
+
* @param tab - The tab to scroll into view
|
|
364
|
+
* @returns {void}
|
|
365
|
+
*/
|
|
366
|
+
function scrollTabIntoView(tab) {
|
|
367
|
+
if (!isScrollable || !ref.current) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
if (tab) {
|
|
371
|
+
// The width of the "scroll buttons"
|
|
372
|
+
const {
|
|
373
|
+
width: tabWidth
|
|
374
|
+
} = tab.getBoundingClientRect();
|
|
375
|
+
|
|
376
|
+
// The start and end position of the selected tab
|
|
377
|
+
const start = tab.offsetLeft;
|
|
378
|
+
const end = tab.offsetLeft + tabWidth;
|
|
379
|
+
|
|
380
|
+
// The start and end of the visible area for the tabs
|
|
381
|
+
const visibleStart = ref.current.scrollLeft + buttonWidth;
|
|
382
|
+
const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
|
|
383
|
+
|
|
384
|
+
// The beginning of the tab is clipped and not visible
|
|
385
|
+
if (start < visibleStart) {
|
|
386
|
+
setScrollLeft(start - buttonWidth);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// The end of the tab is clipped and not visible
|
|
390
|
+
if (end > visibleEnd) {
|
|
391
|
+
setScrollLeft(end + buttonWidth - ref.current.clientWidth);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
360
395
|
useEffectOnce.useEffectOnce(() => {
|
|
361
396
|
const tab = tabs.current[selectedIndex];
|
|
362
397
|
if (scrollIntoView && tab) {
|
|
@@ -388,12 +423,12 @@ function TabList(_ref4) {
|
|
|
388
423
|
});
|
|
389
424
|
useIsomorphicEffect["default"](() => {
|
|
390
425
|
if (ref.current) {
|
|
391
|
-
//adding 1 in calculation for firefox support
|
|
426
|
+
// adding 1 in calculation for firefox support
|
|
392
427
|
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
|
|
393
428
|
}
|
|
394
429
|
function handler() {
|
|
395
430
|
if (ref.current) {
|
|
396
|
-
//adding 1 in calculation for firefox support
|
|
431
|
+
// adding 1 in calculation for firefox support
|
|
397
432
|
setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
|
|
398
433
|
}
|
|
399
434
|
}
|
|
@@ -411,36 +446,18 @@ function TabList(_ref4) {
|
|
|
411
446
|
ref.current.scrollLeft = scrollLeft;
|
|
412
447
|
}
|
|
413
448
|
}, [scrollLeft]);
|
|
449
|
+
|
|
450
|
+
// scroll manual tabs when active index changes (focus outline movement)
|
|
414
451
|
useIsomorphicEffect["default"](() => {
|
|
415
|
-
if (!isScrollable || !ref.current) {
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
452
|
const tab = activation === 'manual' ? tabs.current[activeIndex] : tabs.current[selectedIndex];
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
// The start and end position of the selected tab
|
|
423
|
-
const {
|
|
424
|
-
width: tabWidth
|
|
425
|
-
} = tab.getBoundingClientRect();
|
|
426
|
-
const start = tab.offsetLeft;
|
|
427
|
-
const end = tab.offsetLeft + tabWidth;
|
|
428
|
-
|
|
429
|
-
// The start and end of the visible area for the tabs
|
|
430
|
-
const visibleStart = ref.current.scrollLeft + buttonWidth;
|
|
431
|
-
const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
|
|
432
|
-
|
|
433
|
-
// The beginning of the tab is clipped and not visible
|
|
434
|
-
if (start < visibleStart) {
|
|
435
|
-
setScrollLeft(start - buttonWidth);
|
|
436
|
-
}
|
|
453
|
+
scrollTabIntoView(tab);
|
|
454
|
+
}, [activation, activeIndex]);
|
|
437
455
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}, [activation, activeIndex, selectedIndex, isScrollable, children]);
|
|
456
|
+
// scroll tabs when selected index changes
|
|
457
|
+
useIsomorphicEffect["default"](() => {
|
|
458
|
+
const tab = tabs.current[selectedIndex];
|
|
459
|
+
scrollTabIntoView(tab);
|
|
460
|
+
}, [selectedIndex, isScrollable, children]);
|
|
444
461
|
usePressable.usePressable(previousButton, {
|
|
445
462
|
onPress(_ref6) {
|
|
446
463
|
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;
|
|
@@ -35,6 +35,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
35
35
|
const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwardRef) => {
|
|
36
36
|
const {
|
|
37
37
|
className,
|
|
38
|
+
decorator,
|
|
38
39
|
disabled = false,
|
|
39
40
|
id,
|
|
40
41
|
labelText,
|
|
@@ -164,7 +165,8 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
164
165
|
[`${prefix}--text-area__wrapper--cols`]: other.cols,
|
|
165
166
|
[`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
|
|
166
167
|
[`${prefix}--text-area__wrapper--warn`]: warn,
|
|
167
|
-
[`${prefix}--text-area__wrapper--slug`]: slug
|
|
168
|
+
[`${prefix}--text-area__wrapper--slug`]: slug,
|
|
169
|
+
[`${prefix}--text-area__wrapper--decorator`]: decorator
|
|
168
170
|
});
|
|
169
171
|
const labelClasses = cx__default["default"](`${prefix}--label`, {
|
|
170
172
|
[`${prefix}--visually-hidden`]: hideLabel && !isFluid,
|
|
@@ -263,10 +265,10 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
263
265
|
ref: ref
|
|
264
266
|
}));
|
|
265
267
|
|
|
266
|
-
//
|
|
267
|
-
let
|
|
268
|
-
if (
|
|
269
|
-
|
|
268
|
+
// AILabel is always size `mini`
|
|
269
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
270
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
271
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
270
272
|
size: 'mini'
|
|
271
273
|
});
|
|
272
274
|
}
|
|
@@ -281,7 +283,9 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
|
|
|
281
283
|
className: `${prefix}--text-area__invalid-icon`
|
|
282
284
|
}), warn && !invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
283
285
|
className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
|
|
284
|
-
}), input,
|
|
286
|
+
}), input, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
287
|
+
className: `${prefix}--text-area__inner-wrapper--decorator`
|
|
288
|
+
}, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement("span", {
|
|
285
289
|
className: `${prefix}--text-area__counter-alert`,
|
|
286
290
|
role: "alert",
|
|
287
291
|
"aria-live": "assertive",
|
|
@@ -306,6 +310,10 @@ TextArea.propTypes = {
|
|
|
306
310
|
* Specify the method used for calculating the counter number
|
|
307
311
|
*/
|
|
308
312
|
counterMode: PropTypes__default["default"].oneOf(['character', 'word']),
|
|
313
|
+
/**
|
|
314
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TextArea` component
|
|
315
|
+
*/
|
|
316
|
+
decorator: PropTypes__default["default"].node,
|
|
309
317
|
/**
|
|
310
318
|
* Optionally provide the default value of the `<textarea>`
|
|
311
319
|
*/
|
|
@@ -382,7 +390,7 @@ TextArea.propTypes = {
|
|
|
382
390
|
/**
|
|
383
391
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
|
|
384
392
|
*/
|
|
385
|
-
slug: PropTypes__default["default"].node,
|
|
393
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop for `TextArea` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
|
|
386
394
|
/**
|
|
387
395
|
* Provide the current value of the `<textarea>`
|
|
388
396
|
*/
|
|
@@ -11,6 +11,10 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
11
11
|
* Specify an optional className to be applied to the `<input>` node
|
|
12
12
|
*/
|
|
13
13
|
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TextInput` component
|
|
16
|
+
*/
|
|
17
|
+
decorator?: ReactNode;
|
|
14
18
|
/**
|
|
15
19
|
* Optionally provide the default value of the `<input>`
|
|
16
20
|
*/
|
|
@@ -86,6 +90,7 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
|
|
|
86
90
|
*/
|
|
87
91
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
88
92
|
/**
|
|
93
|
+
* @deprecated please use `decorator` instead.
|
|
89
94
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
90
95
|
*/
|
|
91
96
|
slug?: ReactNode;
|
|
@@ -33,6 +33,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
33
33
|
const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function TextInput(_ref, ref) {
|
|
34
34
|
let {
|
|
35
35
|
className,
|
|
36
|
+
decorator,
|
|
36
37
|
disabled = false,
|
|
37
38
|
helperText,
|
|
38
39
|
hideLabel,
|
|
@@ -125,7 +126,8 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
125
126
|
});
|
|
126
127
|
const fieldWrapperClasses = cx__default["default"](`${prefix}--text-input__field-wrapper`, {
|
|
127
128
|
[`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
|
|
128
|
-
[`${prefix}--text-input__field-wrapper--slug`]: slug
|
|
129
|
+
[`${prefix}--text-input__field-wrapper--slug`]: slug,
|
|
130
|
+
[`${prefix}--text-input__field-wrapper--decorator`]: decorator
|
|
129
131
|
});
|
|
130
132
|
const iconClasses = cx__default["default"]({
|
|
131
133
|
[`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
|
|
@@ -189,10 +191,10 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
189
191
|
}, [ariaAnnouncement, prevAnnouncement]);
|
|
190
192
|
const Icon = normalizedProps.icon;
|
|
191
193
|
|
|
192
|
-
//
|
|
193
|
-
let
|
|
194
|
-
if (
|
|
195
|
-
|
|
194
|
+
// AILabel is always size `mini`
|
|
195
|
+
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|
|
196
|
+
if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
|
|
197
|
+
normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
|
|
196
198
|
size: 'mini'
|
|
197
199
|
});
|
|
198
200
|
}
|
|
@@ -207,7 +209,9 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
|
|
|
207
209
|
"data-invalid": normalizedProps.invalid || null
|
|
208
210
|
}, Icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
|
|
209
211
|
className: iconClasses
|
|
210
|
-
}), input,
|
|
212
|
+
}), input, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
|
|
213
|
+
className: `${prefix}--text-input__field-inner-wrapper--decorator`
|
|
214
|
+
}, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement("span", {
|
|
211
215
|
className: `${prefix}--text-input__counter-alert`,
|
|
212
216
|
role: "alert",
|
|
213
217
|
"aria-live": "assertive",
|
|
@@ -225,6 +229,10 @@ TextInput.propTypes = {
|
|
|
225
229
|
* Specify an optional className to be applied to the `<input>` node
|
|
226
230
|
*/
|
|
227
231
|
className: PropTypes__default["default"].string,
|
|
232
|
+
/**
|
|
233
|
+
* **Experimental**: Provide a `decorator` component to be rendered inside the `TextInput` component
|
|
234
|
+
*/
|
|
235
|
+
decorator: PropTypes__default["default"].node,
|
|
228
236
|
/**
|
|
229
237
|
* Optionally provide the default value of the `<input>`
|
|
230
238
|
*/
|
|
@@ -300,7 +308,7 @@ TextInput.propTypes = {
|
|
|
300
308
|
/**
|
|
301
309
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
|
|
302
310
|
*/
|
|
303
|
-
slug: PropTypes__default["default"].node,
|
|
311
|
+
slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop for `TextInput` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
|
|
304
312
|
/**
|
|
305
313
|
* Specify the type of the `<input>`
|
|
306
314
|
*/
|
|
@@ -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, { ComponentProps } from 'react';
|
|
7
|
+
import React, { ElementType, ComponentProps } from 'react';
|
|
8
8
|
import Link from './Link';
|
|
9
9
|
interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
|
|
10
10
|
/**
|
|
@@ -25,6 +25,10 @@ interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
|
|
|
25
25
|
* Optionally provide an href for the underlying li`
|
|
26
26
|
*/
|
|
27
27
|
href?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional component to render instead of default Link
|
|
30
|
+
*/
|
|
31
|
+
as?: ElementType;
|
|
28
32
|
}
|
|
29
33
|
declare const SideNavMenuItem: React.ForwardRefExoticComponent<Omit<SideNavMenuItemProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
30
34
|
export default SideNavMenuItem;
|
|
@@ -28,6 +28,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
28
28
|
const {
|
|
29
29
|
children,
|
|
30
30
|
className: customClassName,
|
|
31
|
+
as: Component = Link["default"],
|
|
31
32
|
isActive,
|
|
32
33
|
...rest
|
|
33
34
|
} = props;
|
|
@@ -38,7 +39,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
38
39
|
});
|
|
39
40
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
40
41
|
className: className
|
|
41
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
42
|
+
}, /*#__PURE__*/React__default["default"].createElement(Component, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
42
43
|
className: linkClassName,
|
|
43
44
|
ref: ref
|
|
44
45
|
}), /*#__PURE__*/React__default["default"].createElement(SideNavLinkText["default"], null, children)));
|
|
@@ -62,7 +63,11 @@ SideNavMenuItem.propTypes = {
|
|
|
62
63
|
* has an href that is the same as the current page. Can also pass in
|
|
63
64
|
* `aria-current="page"`, as well.
|
|
64
65
|
*/
|
|
65
|
-
isActive: PropTypes__default["default"].bool
|
|
66
|
+
isActive: PropTypes__default["default"].bool,
|
|
67
|
+
/**
|
|
68
|
+
* Optional component to render instead of default Link
|
|
69
|
+
*/
|
|
70
|
+
as: PropTypes__default["default"].elementType
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
exports["default"] = SideNavMenuItem;
|