@carbon/react 1.90.0 → 1.91.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 +921 -921
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +1 -1
- package/es/components/ComboBox/ComboBox.js +1 -12
- package/es/components/ComboButton/index.js +1 -1
- package/es/components/ComposedModal/ComposedModal.js +1 -1
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +60 -15
- package/es/components/DataTable/DataTable.js +106 -179
- package/es/components/DataTable/Table.d.ts +2 -2
- package/es/components/DataTable/Table.js +1 -1
- package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/es/components/DataTable/TableExpandHeader.js +1 -1
- package/es/components/DatePicker/DatePicker.d.ts +0 -12
- package/es/components/DatePicker/DatePicker.js +3 -3
- package/es/components/DatePicker/plugins/rangePlugin.d.ts +19 -2
- package/es/components/DatePicker/plugins/rangePlugin.js +18 -14
- package/es/components/Dropdown/Dropdown.js +1 -12
- package/es/components/FeatureFlags/index.js +1 -0
- package/es/components/IconButton/index.js +1 -1
- package/es/components/Menu/MenuItem.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +5 -5
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/MultiSelect/MultiSelect.js +1 -12
- package/es/components/Notification/Notification.d.ts +6 -6
- package/es/components/Notification/Notification.js +6 -6
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/OverflowMenu/next/index.js +1 -1
- package/es/components/Popover/index.js +1 -1
- package/es/components/Search/Search.d.ts +4 -2
- package/es/components/Search/Search.js +5 -4
- package/es/components/Slider/Slider.d.ts +144 -188
- package/es/components/Slider/Slider.js +787 -710
- package/es/components/Slider/index.d.ts +2 -2
- package/es/components/Tabs/Tabs.d.ts +4 -0
- package/es/components/TextArea/TextArea.js +13 -6
- package/es/components/TextInput/ControlledPasswordInput.js +2 -2
- package/es/components/TextInput/PasswordInput.js +2 -2
- package/es/components/TextInput/TextInput.js +2 -2
- package/es/components/TextInput/util.d.ts +17 -5
- package/es/components/TextInput/util.js +2 -7
- package/es/components/UIShell/HeaderPanel.d.ts +1 -1
- package/es/index.d.ts +12 -13
- package/es/index.js +25 -24
- package/es/internal/defaultItemToString.d.ts +7 -0
- package/es/internal/defaultItemToString.js +17 -0
- package/es/internal/index.d.ts +1 -0
- package/es/prop-types/deprecateValuesWithin.d.ts +8 -1
- package/es/prop-types/deprecateValuesWithin.js +6 -6
- package/es/prop-types/requiredIfGivenPropIsTruthy.d.ts +8 -7
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +10 -10
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +3 -14
- package/lib/components/ComboButton/index.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +1 -1
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/Copy/Copy.js +1 -1
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.js +1 -1
- package/lib/components/DataTable/DataTable.d.ts +60 -15
- package/lib/components/DataTable/DataTable.js +106 -179
- package/lib/components/DataTable/Table.d.ts +2 -2
- package/lib/components/DataTable/Table.js +1 -1
- package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/lib/components/DataTable/TableExpandHeader.js +3 -3
- package/lib/components/DatePicker/DatePicker.d.ts +0 -12
- package/lib/components/DatePicker/DatePicker.js +2 -2
- package/lib/components/DatePicker/plugins/rangePlugin.d.ts +19 -2
- package/lib/components/DatePicker/plugins/rangePlugin.js +18 -16
- package/lib/components/Dropdown/Dropdown.js +3 -14
- package/lib/components/FeatureFlags/index.js +1 -0
- package/lib/components/IconButton/index.js +1 -1
- package/lib/components/Menu/MenuItem.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +6 -6
- package/lib/components/Modal/Modal.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +8 -8
- package/lib/components/MultiSelect/MultiSelect.js +2 -13
- package/lib/components/Notification/Notification.d.ts +6 -6
- package/lib/components/Notification/Notification.js +6 -6
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/OverflowMenu/next/index.js +1 -1
- package/lib/components/Popover/index.js +1 -1
- package/lib/components/Search/Search.d.ts +4 -2
- package/lib/components/Search/Search.js +5 -4
- package/lib/components/Slider/Slider.d.ts +144 -188
- package/lib/components/Slider/Slider.js +784 -709
- package/lib/components/Slider/index.d.ts +2 -2
- package/lib/components/Tabs/Tabs.d.ts +4 -0
- package/lib/components/TextArea/TextArea.js +13 -6
- package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +1 -1
- package/lib/components/TextInput/TextInput.js +1 -1
- package/lib/components/TextInput/util.d.ts +17 -5
- package/lib/components/TextInput/util.js +2 -7
- package/lib/components/UIShell/HeaderPanel.d.ts +1 -1
- package/lib/index.d.ts +12 -13
- package/lib/index.js +51 -28
- package/lib/internal/defaultItemToString.d.ts +7 -0
- package/lib/internal/defaultItemToString.js +19 -0
- package/lib/internal/index.d.ts +1 -0
- package/lib/prop-types/deprecateValuesWithin.d.ts +8 -1
- package/lib/prop-types/deprecateValuesWithin.js +6 -8
- package/lib/prop-types/requiredIfGivenPropIsTruthy.d.ts +8 -7
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +10 -12
- package/package.json +8 -7
- package/es/components/MultiSelect/tools/itemToString.d.ts +0 -1
- package/es/components/MultiSelect/tools/itemToString.js +0 -21
- package/es/components/Slider/index.js +0 -14
- package/es/internal/createClassWrapper.js +0 -23
- package/lib/components/MultiSelect/tools/itemToString.d.ts +0 -1
- package/lib/components/MultiSelect/tools/itemToString.js +0 -23
- package/lib/components/Slider/index.js +0 -20
- package/lib/internal/createClassWrapper.js +0 -25
|
@@ -7,38 +7,40 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var rangePlugin = require('flatpickr/dist/plugins/rangePlugin');
|
|
10
|
+
var baseRangePlugin = require('flatpickr/dist/plugins/rangePlugin');
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
|
-
* @param
|
|
16
|
-
* @returns
|
|
13
|
+
* @param config Plugin configuration.
|
|
14
|
+
* @returns An extension of Flatpickr `rangePlugin` that does the following:
|
|
17
15
|
* * Better ensures the calendar dropdown is always aligned to the `<input>` for the starting date.
|
|
18
16
|
* Workaround for: https://github.com/flatpickr/flatpickr/issues/1944
|
|
19
17
|
* * A logic to ensure `fp.setDate()` call won't end up with "startDate to endDate" set to the first `<input>`
|
|
20
18
|
*/
|
|
21
|
-
|
|
22
|
-
const factory =
|
|
19
|
+
const rangePlugin = (config = {}) => {
|
|
20
|
+
const factory = baseRangePlugin(Object.assign({
|
|
23
21
|
position: 'left'
|
|
24
22
|
}, config));
|
|
25
23
|
return fp => {
|
|
26
|
-
const
|
|
24
|
+
const {
|
|
25
|
+
setDate: origSetDate
|
|
26
|
+
} = fp;
|
|
27
27
|
const init = () => {
|
|
28
|
-
fp.setDate =
|
|
29
|
-
origSetDate
|
|
28
|
+
fp.setDate = (dates, triggerChange, format) => {
|
|
29
|
+
origSetDate(dates, triggerChange, format);
|
|
30
30
|
// If `triggerChange` is `true`, `onValueUpdate` Flatpickr event is fired
|
|
31
31
|
// where Flatpickr's range plugin takes care of fixing the first `<input>`
|
|
32
|
-
if (!triggerChange && dates.length === 2) {
|
|
32
|
+
if (!triggerChange && Array.isArray(dates) && dates.length === 2) {
|
|
33
33
|
const {
|
|
34
|
+
formatDate,
|
|
34
35
|
_input: inputFrom
|
|
35
36
|
} = fp;
|
|
36
37
|
const {
|
|
37
38
|
input: inputTo
|
|
38
39
|
} = config;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const inputToElement = typeof inputTo === 'string' ? document.querySelector(inputTo) : inputTo;
|
|
41
|
+
[inputFrom, inputToElement].forEach((input, i) => {
|
|
42
|
+
if (input && input instanceof HTMLInputElement) {
|
|
43
|
+
input.value = !dates[i] ? '' : formatDate(new Date(dates[i]), fp.config.dateFormat);
|
|
42
44
|
}
|
|
43
45
|
});
|
|
44
46
|
}
|
|
@@ -50,9 +52,9 @@ var carbonFlatpickrRangePlugin = config => {
|
|
|
50
52
|
} = origRangePlugin;
|
|
51
53
|
return Object.assign(origRangePlugin, {
|
|
52
54
|
onReady: [init, origOnReady],
|
|
53
|
-
onPreCalendarPosition() {}
|
|
55
|
+
onPreCalendarPosition: () => {}
|
|
54
56
|
});
|
|
55
57
|
};
|
|
56
58
|
};
|
|
57
59
|
|
|
58
|
-
exports.
|
|
60
|
+
exports.rangePlugin = rangePlugin;
|
|
@@ -25,6 +25,7 @@ var useId = require('../../internal/useId.js');
|
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var index = require('../FeatureFlags/index.js');
|
|
27
27
|
var index$1 = require('../AILabel/index.js');
|
|
28
|
+
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
28
29
|
var utils = require('../../internal/utils.js');
|
|
29
30
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
30
31
|
|
|
@@ -32,18 +33,6 @@ const {
|
|
|
32
33
|
ItemMouseMove,
|
|
33
34
|
MenuMouseLeave
|
|
34
35
|
} = Downshift.useSelect.stateChangeTypes;
|
|
35
|
-
const defaultItemToString = item => {
|
|
36
|
-
if (typeof item === 'string') {
|
|
37
|
-
return item;
|
|
38
|
-
}
|
|
39
|
-
if (typeof item === 'number') {
|
|
40
|
-
return `${item}`;
|
|
41
|
-
}
|
|
42
|
-
if (item !== null && typeof item === 'object' && 'label' in item && typeof item['label'] === 'string') {
|
|
43
|
-
return item['label'];
|
|
44
|
-
}
|
|
45
|
-
return '';
|
|
46
|
-
};
|
|
47
36
|
/**
|
|
48
37
|
* Custom state reducer for `useSelect` in Downshift, providing control over
|
|
49
38
|
* state changes.
|
|
@@ -90,7 +79,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
90
79
|
label,
|
|
91
80
|
['aria-label']: ariaLabel,
|
|
92
81
|
ariaLabel: deprecatedAriaLabel,
|
|
93
|
-
itemToString = defaultItemToString,
|
|
82
|
+
itemToString = defaultItemToString.defaultItemToString,
|
|
94
83
|
itemToElement = null,
|
|
95
84
|
renderSelectedItem,
|
|
96
85
|
type = 'default',
|
|
@@ -363,7 +352,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
363
352
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
364
353
|
,
|
|
365
354
|
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
366
|
-
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
|
|
355
|
+
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString.defaultItemToString(label)
|
|
367
356
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
368
357
|
ref: mergedRef
|
|
369
358
|
}), /*#__PURE__*/React.createElement("span", {
|
|
@@ -12,6 +12,7 @@ var PropTypes = require('prop-types');
|
|
|
12
12
|
var React = require('react');
|
|
13
13
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
14
14
|
|
|
15
|
+
// TODO: Can this variable be deleted now? It isn't used anywhere.
|
|
15
16
|
/**
|
|
16
17
|
* Our FeatureFlagContext is used alongside the FeatureFlags component to enable
|
|
17
18
|
* or disable feature flags in a given React tree
|
|
@@ -80,7 +80,7 @@ IconButton.propTypes = {
|
|
|
80
80
|
/**
|
|
81
81
|
* Specify how the trigger should align with the tooltip
|
|
82
82
|
*/
|
|
83
|
-
align: deprecateValuesWithin.
|
|
83
|
+
align: deprecateValuesWithin.deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
84
84
|
// deprecated use top-start instead
|
|
85
85
|
'top-right',
|
|
86
86
|
// deprecated use top-end instead
|
|
@@ -80,7 +80,7 @@ export interface MenuItemRadioGroupProps<Item> extends Omit<ComponentProps<'ul'>
|
|
|
80
80
|
*/
|
|
81
81
|
defaultSelectedItem?: Item;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* Converts an item into a string for display.
|
|
84
84
|
*/
|
|
85
85
|
itemToString?: (item: Item) => string;
|
|
86
86
|
/**
|
|
@@ -23,6 +23,7 @@ var MenuContext = require('./MenuContext.js');
|
|
|
23
23
|
require('../LayoutDirection/LayoutDirection.js');
|
|
24
24
|
var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
|
|
25
25
|
require('../Text/index.js');
|
|
26
|
+
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
26
27
|
var Text = require('../Text/Text.js');
|
|
27
28
|
|
|
28
29
|
var _Checkmark, _CaretLeft, _CaretRight;
|
|
@@ -180,15 +181,15 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
180
181
|
"aria-expanded": hasChildren ? submenuOpen : undefined,
|
|
181
182
|
onClick: handleClick,
|
|
182
183
|
onKeyDown: handleKeyDown,
|
|
183
|
-
onKeyUp: handleKeyUp
|
|
184
|
+
onKeyUp: handleKeyUp,
|
|
185
|
+
title: label
|
|
184
186
|
}, getReferenceProps()), /*#__PURE__*/React.createElement("div", {
|
|
185
187
|
className: `${prefix}--menu-item__selection-icon`
|
|
186
188
|
}, rest['aria-checked'] && (_Checkmark || (_Checkmark = /*#__PURE__*/React.createElement(iconsReact.Checkmark, null)))), /*#__PURE__*/React.createElement("div", {
|
|
187
189
|
className: `${prefix}--menu-item__icon`
|
|
188
190
|
}, IconElement && /*#__PURE__*/React.createElement(IconElement, null)), /*#__PURE__*/React.createElement(Text.Text, {
|
|
189
191
|
as: "div",
|
|
190
|
-
className: `${prefix}--menu-item__label
|
|
191
|
-
title: label
|
|
192
|
+
className: `${prefix}--menu-item__label`
|
|
192
193
|
}, label), shortcut && !hasChildren && /*#__PURE__*/React.createElement("div", {
|
|
193
194
|
className: `${prefix}--menu-item__shortcut`
|
|
194
195
|
}, shortcut), hasChildren && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -326,12 +327,11 @@ MenuItemGroup.propTypes = {
|
|
|
326
327
|
*/
|
|
327
328
|
label: PropTypes.string.isRequired
|
|
328
329
|
};
|
|
329
|
-
const defaultItemToString = item => item.toString();
|
|
330
330
|
const MenuItemRadioGroup = /*#__PURE__*/React.forwardRef(function MenuItemRadioGroup({
|
|
331
331
|
className,
|
|
332
332
|
defaultSelectedItem,
|
|
333
333
|
items,
|
|
334
|
-
itemToString = defaultItemToString,
|
|
334
|
+
itemToString = defaultItemToString.defaultItemToString,
|
|
335
335
|
label,
|
|
336
336
|
onChange,
|
|
337
337
|
selectedItem,
|
|
@@ -384,7 +384,7 @@ MenuItemRadioGroup.propTypes = {
|
|
|
384
384
|
*/
|
|
385
385
|
defaultSelectedItem: PropTypes.any,
|
|
386
386
|
/**
|
|
387
|
-
*
|
|
387
|
+
* Converts an item into a string for display.
|
|
388
388
|
*/
|
|
389
389
|
itemToString: PropTypes.func,
|
|
390
390
|
/**
|
|
@@ -474,7 +474,7 @@ Modal.propTypes = {
|
|
|
474
474
|
/**
|
|
475
475
|
* Required props for the accessibility label of the header
|
|
476
476
|
*/
|
|
477
|
-
['aria-label']: requiredIfGivenPropIsTruthy.
|
|
477
|
+
['aria-label']: requiredIfGivenPropIsTruthy.requiredIfGivenPropIsTruthy('hasScrollingContent', PropTypes.string),
|
|
478
478
|
/**
|
|
479
479
|
* Provide the contents of your Modal
|
|
480
480
|
*/
|
|
@@ -23,7 +23,6 @@ var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
|
23
23
|
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
24
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
25
25
|
var match = require('../../internal/keyboard/match.js');
|
|
26
|
-
var itemToString = require('./tools/itemToString.js');
|
|
27
26
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
28
27
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
29
28
|
var useId = require('../../internal/useId.js');
|
|
@@ -34,6 +33,7 @@ var FormContext = require('../FluidForm/FormContext.js');
|
|
|
34
33
|
var Selection = require('../../internal/Selection.js');
|
|
35
34
|
var react = require('@floating-ui/react');
|
|
36
35
|
var index = require('../AILabel/index.js');
|
|
36
|
+
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
37
37
|
var utils = require('../../internal/utils.js');
|
|
38
38
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
39
39
|
|
|
@@ -87,7 +87,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
87
87
|
items,
|
|
88
88
|
itemToElement: ItemToElement,
|
|
89
89
|
// needs to be capitalized for react to render it correctly
|
|
90
|
-
itemToString
|
|
90
|
+
itemToString = defaultItemToString.defaultItemToString,
|
|
91
91
|
light,
|
|
92
92
|
locale = 'en',
|
|
93
93
|
onInputValueChange,
|
|
@@ -121,9 +121,9 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
121
121
|
const [topItems, setTopItems] = React.useState(initialSelectedItems ?? []);
|
|
122
122
|
const [inputFocused, setInputFocused] = React.useState(false);
|
|
123
123
|
const filteredItems = React.useMemo(() => filterItems(items, {
|
|
124
|
-
itemToString
|
|
124
|
+
itemToString,
|
|
125
125
|
inputValue
|
|
126
|
-
}), [items, inputValue, itemToString
|
|
126
|
+
}), [items, inputValue, itemToString, filterItems]);
|
|
127
127
|
const nonSelectAllItems = React.useMemo(
|
|
128
128
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
129
129
|
() => filteredItems.filter(item => !item.isSelectAll), [filteredItems]);
|
|
@@ -236,7 +236,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
236
236
|
fixed: [],
|
|
237
237
|
'top-after-reopen': topItems
|
|
238
238
|
}[selectionFeedback],
|
|
239
|
-
itemToString
|
|
239
|
+
itemToString,
|
|
240
240
|
compareItems,
|
|
241
241
|
locale
|
|
242
242
|
});
|
|
@@ -247,7 +247,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
247
247
|
}
|
|
248
248
|
return sortedReal;
|
|
249
249
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
250
|
-
}, [items, inputValue, controlledSelectedItems, topItems, selectionFeedback, itemToString
|
|
250
|
+
}, [items, inputValue, controlledSelectedItems, topItems, selectionFeedback, itemToString, compareItems, locale, sortItems, nonSelectAllItems]);
|
|
251
251
|
const inline = type === 'inline';
|
|
252
252
|
const showWarning = !invalid && warn;
|
|
253
253
|
const wrapperClasses = cx(`${prefix}--multi-select__wrapper`, `${prefix}--multi-select--filterable__wrapper`, `${prefix}--list-box__wrapper`, containerClassName, {
|
|
@@ -346,7 +346,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
346
346
|
isOpen,
|
|
347
347
|
items: sortedItems,
|
|
348
348
|
// defaultHighlightedIndex: 0, // after selection, highlight the first item.
|
|
349
|
-
itemToString
|
|
349
|
+
itemToString,
|
|
350
350
|
id,
|
|
351
351
|
labelId,
|
|
352
352
|
menuId,
|
|
@@ -720,7 +720,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
720
720
|
item,
|
|
721
721
|
['aria-selected']: isChecked
|
|
722
722
|
});
|
|
723
|
-
const itemText = itemToString
|
|
723
|
+
const itemText = itemToString(item);
|
|
724
724
|
|
|
725
725
|
// The initial implementation using <Downshift> would place the disabled attribute
|
|
726
726
|
// on disabled menu items. Conversely, useCombobox places aria-disabled instead.
|
|
@@ -32,6 +32,7 @@ var noopFn = require('../../internal/noopFn.js');
|
|
|
32
32
|
var react = require('@floating-ui/react');
|
|
33
33
|
var index = require('../FeatureFlags/index.js');
|
|
34
34
|
var index$1 = require('../AILabel/index.js');
|
|
35
|
+
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
35
36
|
var utils = require('../../internal/utils.js');
|
|
36
37
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
37
38
|
|
|
@@ -50,18 +51,6 @@ const {
|
|
|
50
51
|
ToggleButtonKeyDownPageUp,
|
|
51
52
|
FunctionSetHighlightedIndex
|
|
52
53
|
} = Downshift.useSelect.stateChangeTypes;
|
|
53
|
-
const defaultItemToString = item => {
|
|
54
|
-
if (typeof item === 'string') {
|
|
55
|
-
return item;
|
|
56
|
-
}
|
|
57
|
-
if (typeof item === 'number') {
|
|
58
|
-
return `${item}`;
|
|
59
|
-
}
|
|
60
|
-
if (item !== null && typeof item === 'object' && 'label' in item && typeof item['label'] === 'string') {
|
|
61
|
-
return item['label'];
|
|
62
|
-
}
|
|
63
|
-
return '';
|
|
64
|
-
};
|
|
65
54
|
const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
66
55
|
autoAlign = false,
|
|
67
56
|
className: containerClassName,
|
|
@@ -69,7 +58,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
69
58
|
id,
|
|
70
59
|
items,
|
|
71
60
|
itemToElement,
|
|
72
|
-
itemToString = defaultItemToString,
|
|
61
|
+
itemToString = defaultItemToString.defaultItemToString,
|
|
73
62
|
titleText = false,
|
|
74
63
|
hideLabel,
|
|
75
64
|
helperText,
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { type ReactNode, type MouseEvent, type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
|
|
9
|
-
import { type ButtonProps } from '../Button';
|
|
8
|
+
import React, { type ReactNode, type MouseEvent, type ButtonHTMLAttributes, type HTMLAttributes, type ComponentProps } from 'react';
|
|
9
|
+
import Button, { type ButtonProps } from '../Button';
|
|
10
10
|
export interface NotificationActionButtonProps extends ButtonProps<'button'> {
|
|
11
11
|
/**
|
|
12
12
|
* Specify the content of the notification action button.
|
|
@@ -23,7 +23,7 @@ export interface NotificationActionButtonProps extends ButtonProps<'button'> {
|
|
|
23
23
|
/**
|
|
24
24
|
* Optionally specify a click handler for the notification action button.
|
|
25
25
|
*/
|
|
26
|
-
onClick
|
|
26
|
+
onClick?: ComponentProps<typeof Button>['onClick'];
|
|
27
27
|
}
|
|
28
28
|
export declare function NotificationActionButton({ children, className: customClassName, onClick, inline, ...rest }: NotificationActionButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
29
29
|
export declare namespace NotificationActionButton {
|
|
@@ -404,7 +404,7 @@ export interface ActionableNotificationProps extends HTMLAttributes<HTMLDivEleme
|
|
|
404
404
|
/**
|
|
405
405
|
* Provide a function that is called when the action is clicked
|
|
406
406
|
*/
|
|
407
|
-
onActionButtonClick
|
|
407
|
+
onActionButtonClick?: ComponentProps<typeof NotificationActionButton>['onClick'];
|
|
408
408
|
/**
|
|
409
409
|
* Provide a function that is called when menu is closed.
|
|
410
410
|
* Default behavior of hiding the notification is prevented if this function returns false.
|
|
@@ -551,7 +551,7 @@ export interface CalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
551
551
|
/**
|
|
552
552
|
* Provide a function that is called when the action is clicked
|
|
553
553
|
*/
|
|
554
|
-
onActionButtonClick
|
|
554
|
+
onActionButtonClick?: ComponentProps<typeof NotificationActionButton>['onClick'];
|
|
555
555
|
/**
|
|
556
556
|
* Provide a description for "status" icon that can be read by screen readers
|
|
557
557
|
*/
|
|
@@ -587,7 +587,7 @@ export declare namespace Callout {
|
|
|
587
587
|
/**
|
|
588
588
|
* Specify what state the notification represents
|
|
589
589
|
*/
|
|
590
|
-
kind:
|
|
590
|
+
kind: PropTypes.Requireable<string> | PropTypes.Validator<string>;
|
|
591
591
|
/**
|
|
592
592
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
593
593
|
*/
|
|
@@ -701,12 +701,12 @@ ActionableNotification.propTypes = {
|
|
|
701
701
|
* @deprecated Use NewKindProps instead.
|
|
702
702
|
*/
|
|
703
703
|
|
|
704
|
+
const mapping = {
|
|
705
|
+
error: 'warning',
|
|
706
|
+
// only redirect error -> warning
|
|
707
|
+
success: 'info' // only redirect success -> info
|
|
708
|
+
};
|
|
704
709
|
const propMappingFunction = deprecatedValue => {
|
|
705
|
-
const mapping = {
|
|
706
|
-
error: 'warning',
|
|
707
|
-
// only redirect error -> warning
|
|
708
|
-
success: 'info' // only redirect success -> info
|
|
709
|
-
};
|
|
710
710
|
return mapping[deprecatedValue];
|
|
711
711
|
};
|
|
712
712
|
function Callout({
|
|
@@ -773,7 +773,7 @@ Callout.propTypes = {
|
|
|
773
773
|
/**
|
|
774
774
|
* Specify what state the notification represents
|
|
775
775
|
*/
|
|
776
|
-
kind: deprecateValuesWithin.
|
|
776
|
+
kind: deprecateValuesWithin.deprecateValuesWithin(PropTypes.oneOf(['error', 'info', 'info-square', 'success', 'warning', 'warning-alt']), ['warning', 'info'], propMappingFunction),
|
|
777
777
|
/**
|
|
778
778
|
* Specify whether you are using the low contrast variant of the Callout.
|
|
779
779
|
*/
|
|
@@ -348,7 +348,7 @@ OverflowMenu.propTypes = {
|
|
|
348
348
|
/**
|
|
349
349
|
* Specify how the trigger should align with the tooltip
|
|
350
350
|
*/
|
|
351
|
-
align: deprecateValuesWithin.
|
|
351
|
+
align: deprecateValuesWithin.deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
352
352
|
// deprecated use top-start instead
|
|
353
353
|
'top-right',
|
|
354
354
|
// deprecated use top-end instead
|
|
@@ -168,7 +168,7 @@ OverflowMenu.propTypes = {
|
|
|
168
168
|
/**
|
|
169
169
|
* Specify how the trigger tooltip should be aligned.
|
|
170
170
|
*/
|
|
171
|
-
tooltipAlignment: deprecateValuesWithin.
|
|
171
|
+
tooltipAlignment: deprecateValuesWithin.deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
172
172
|
// deprecated use top-start instead
|
|
173
173
|
'top-right',
|
|
174
174
|
// deprecated use top-end instead
|
|
@@ -290,7 +290,7 @@ Popover.propTypes = {
|
|
|
290
290
|
/**
|
|
291
291
|
* Specify how the popover should align with the trigger element
|
|
292
292
|
*/
|
|
293
|
-
align: deprecateValuesWithin.
|
|
293
|
+
align: deprecateValuesWithin.deprecateValuesWithin(PropTypes.oneOf(['top', 'top-left',
|
|
294
294
|
// deprecated use top-start instead
|
|
295
295
|
'top-right',
|
|
296
296
|
// deprecated use top-end instead
|
|
@@ -63,7 +63,9 @@ export interface SearchProps extends InputPropsBase {
|
|
|
63
63
|
*/
|
|
64
64
|
renderIcon?: ComponentType | FunctionComponent;
|
|
65
65
|
/**
|
|
66
|
-
* Specify the role for the underlying `<input
|
|
66
|
+
* @deprecated Specify the role for the underlying `<input>`.
|
|
67
|
+
* No longer needed since `<input type="search">` already provides the correct semantics.
|
|
68
|
+
* This prop will be removed in the next major release of Carbon.
|
|
67
69
|
*/
|
|
68
70
|
role?: string;
|
|
69
71
|
/**
|
|
@@ -71,7 +73,7 @@ export interface SearchProps extends InputPropsBase {
|
|
|
71
73
|
*/
|
|
72
74
|
size?: 'sm' | 'md' | 'lg';
|
|
73
75
|
/**
|
|
74
|
-
*
|
|
76
|
+
* Specify the type of the `<input>`
|
|
75
77
|
*/
|
|
76
78
|
type?: string;
|
|
77
79
|
/**
|
|
@@ -43,9 +43,9 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
43
43
|
onExpand,
|
|
44
44
|
placeholder = 'Search',
|
|
45
45
|
renderIcon,
|
|
46
|
-
role
|
|
46
|
+
role,
|
|
47
47
|
size = 'md',
|
|
48
|
-
type = '
|
|
48
|
+
type = 'search',
|
|
49
49
|
value,
|
|
50
50
|
...rest
|
|
51
51
|
}, forwardRef) => {
|
|
@@ -242,15 +242,16 @@ Search.propTypes = {
|
|
|
242
242
|
*/
|
|
243
243
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
244
244
|
/**
|
|
245
|
+
* Deprecated, since <input type="search"> already provides correct semantics.
|
|
245
246
|
* Specify the role for the underlying `<input>`, defaults to `searchbox`
|
|
246
247
|
*/
|
|
247
|
-
role: PropTypes.string,
|
|
248
|
+
role: deprecate.deprecate(PropTypes.string, 'The `role` prop has been deprecated since <input type="search"> already provides correct semantics. ' + 'It will be removed in the next major release of Carbon.'),
|
|
248
249
|
/**
|
|
249
250
|
* Specify the size of the Search
|
|
250
251
|
*/
|
|
251
252
|
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
252
253
|
/**
|
|
253
|
-
*
|
|
254
|
+
* Specify the type of the `<input>`
|
|
254
255
|
*/
|
|
255
256
|
type: PropTypes.string,
|
|
256
257
|
/**
|