@carbon/react 1.77.0-rc.0 → 1.78.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 +945 -858
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/BadgeIndicator/index.d.ts +23 -0
- package/es/components/BadgeIndicator/index.js +45 -0
- package/es/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/es/components/Breadcrumb/Breadcrumb.js +8 -2
- package/es/components/Button/Button.d.ts +9 -0
- package/es/components/Button/Button.js +13 -0
- package/es/components/ComboBox/ComboBox.js +13 -9
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +3 -2
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +1 -1
- package/es/components/IconButton/index.d.ts +7 -1
- package/es/components/IconButton/index.js +18 -2
- package/es/components/IconIndicator/index.d.ts +1 -1
- package/es/components/InlineLoading/InlineLoading.js +2 -5
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/Modal/Modal.d.ts +3 -3
- package/es/components/Modal/Modal.js +9 -3
- package/es/components/Modal/next/index.d.ts +1 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +11 -3
- package/es/components/MultiSelect/MultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/es/components/MultiSelect/tools/sorting.js +8 -7
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +12 -12
- package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/es/components/OverflowMenu/OverflowMenu.js +7 -9
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/es/components/Pagination/Pagination.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +11 -2
- package/es/components/ShapeIndicator/index.d.ts +29 -0
- package/es/components/ShapeIndicator/index.js +92 -0
- package/es/components/Tabs/Tabs.d.ts +6 -4
- package/es/components/Tabs/Tabs.js +27 -8
- package/es/components/Tag/OperationalTag.d.ts +1 -36
- package/es/components/Tag/OperationalTag.js +7 -5
- package/es/components/Text/Text.d.ts +11 -9
- package/es/components/Text/Text.js +6 -6
- package/es/components/Text/TextDirection.d.ts +7 -9
- package/es/components/Text/TextDirection.js +5 -2
- package/es/components/Text/TextDirectionContext.d.ts +14 -0
- package/es/components/Text/TextDirectionContext.js +6 -2
- package/es/components/Text/createTextComponent.d.ts +5 -5
- package/es/components/Text/createTextComponent.js +5 -4
- package/es/components/Text/index.d.ts +6 -7
- package/es/components/Text/index.js +3 -2
- package/es/components/Tile/Tile.d.ts +6 -0
- package/es/components/Tile/Tile.js +5 -9
- package/es/components/Toggletip/index.d.ts +3 -2
- package/es/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/es/components/Tooltip/DefinitionTooltip.js +7 -1
- package/es/components/Tooltip/Tooltip.d.ts +5 -66
- package/es/components/Tooltip/Tooltip.js +26 -26
- package/es/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/es/components/UIShell/HeaderGlobalAction.js +16 -1
- package/es/index.d.ts +4 -1
- package/es/index.js +2 -1
- package/es/internal/FloatingMenu.d.ts +83 -0
- package/es/internal/FloatingMenu.js +216 -408
- package/es/internal/wrapFocus.js +1 -1
- package/lib/components/Accordion/AccordionItem.js +1 -1
- package/lib/components/BadgeIndicator/index.d.ts +23 -0
- package/lib/components/BadgeIndicator/index.js +56 -0
- package/lib/components/Breadcrumb/Breadcrumb.d.ts +5 -0
- package/lib/components/Breadcrumb/Breadcrumb.js +8 -2
- package/lib/components/Button/Button.d.ts +9 -0
- package/lib/components/Button/Button.js +13 -0
- package/lib/components/ComboBox/ComboBox.js +13 -9
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +2 -1
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +1 -1
- package/lib/components/IconButton/index.d.ts +7 -1
- package/lib/components/IconButton/index.js +18 -2
- package/lib/components/IconIndicator/index.d.ts +1 -1
- package/lib/components/InlineLoading/InlineLoading.js +2 -5
- package/lib/components/Menu/MenuItem.js +1 -1
- package/lib/components/Modal/Modal.d.ts +3 -3
- package/lib/components/Modal/Modal.js +9 -3
- package/lib/components/Modal/next/index.d.ts +1 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +10 -2
- package/lib/components/MultiSelect/MultiSelect.js +2 -1
- package/lib/components/MultiSelect/MultiSelectPropTypes.d.ts +5 -2
- package/lib/components/MultiSelect/tools/sorting.js +8 -7
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.js +12 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -20
- package/lib/components/OverflowMenu/OverflowMenu.js +7 -9
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +1 -1
- package/lib/components/Pagination/Pagination.js +3 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +11 -2
- package/lib/components/ShapeIndicator/index.d.ts +29 -0
- package/lib/components/ShapeIndicator/index.js +104 -0
- package/lib/components/Tabs/Tabs.d.ts +6 -4
- package/lib/components/Tabs/Tabs.js +42 -23
- package/lib/components/Tag/OperationalTag.d.ts +1 -36
- package/lib/components/Tag/OperationalTag.js +6 -4
- package/lib/components/Text/Text.d.ts +11 -9
- package/lib/components/Text/Text.js +5 -5
- package/lib/components/Text/TextDirection.d.ts +7 -9
- package/lib/components/Text/TextDirection.js +5 -2
- package/lib/components/Text/TextDirectionContext.d.ts +14 -0
- package/lib/components/Text/TextDirectionContext.js +6 -2
- package/lib/components/Text/createTextComponent.d.ts +5 -5
- package/lib/components/Text/createTextComponent.js +5 -4
- package/lib/components/Text/index.d.ts +6 -7
- package/lib/components/Text/index.js +4 -3
- package/lib/components/Tile/Tile.d.ts +6 -0
- package/lib/components/Tile/Tile.js +5 -9
- package/lib/components/Toggletip/index.d.ts +3 -2
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +4 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +7 -1
- package/lib/components/Tooltip/Tooltip.d.ts +5 -66
- package/lib/components/Tooltip/Tooltip.js +26 -26
- package/lib/components/UIShell/HeaderGlobalAction.d.ts +9 -0
- package/lib/components/UIShell/HeaderGlobalAction.js +16 -1
- package/lib/index.d.ts +4 -1
- package/lib/index.js +42 -40
- package/lib/internal/FloatingMenu.d.ts +83 -0
- package/lib/internal/FloatingMenu.js +216 -409
- package/lib/internal/wrapFocus.js +1 -1
- package/package.json +7 -7
- package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
- package/scss/components/badge-indicator/_index.scss +9 -0
- package/es/tools/array.js +0 -29
- package/lib/tools/array.js +0 -33
package/es/internal/wrapFocus.js
CHANGED
|
@@ -67,7 +67,7 @@ function wrapFocus(_ref) {
|
|
|
67
67
|
* @param {object} options The options.
|
|
68
68
|
* @param {Node|null} options.containerNode
|
|
69
69
|
* @param {EventTarget} options.currentActiveNode The DOM node that has focus.
|
|
70
|
-
* @param {KeyboardEvent} options.event The DOM event
|
|
70
|
+
* @param {React.KeyboardEvent} options.event The DOM event
|
|
71
71
|
*/
|
|
72
72
|
function wrapFocusWithoutSentinels(_ref2) {
|
|
73
73
|
let {
|
|
@@ -19,8 +19,8 @@ var useId = require('../../internal/useId.js');
|
|
|
19
19
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
21
|
var AccordionProvider = require('./AccordionProvider.js');
|
|
22
|
-
var Text = require('../Text/Text.js');
|
|
23
22
|
var match = require('../../internal/keyboard/match.js');
|
|
23
|
+
var Text = require('../Text/Text.js');
|
|
24
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
25
25
|
|
|
26
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
interface BadgeIndicatorProps {
|
|
9
|
+
/**
|
|
10
|
+
* Specify an optional className to add.
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Count of badge indicator
|
|
15
|
+
*/
|
|
16
|
+
count?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Provide an `id` to uniquely identify the BadgeIndidcator
|
|
19
|
+
*/
|
|
20
|
+
id?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const BadgeIndicator: React.ForwardRefExoticComponent<BadgeIndicatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
export default BadgeIndicator;
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var cx = require('classnames');
|
|
16
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
23
|
+
|
|
24
|
+
const BadgeIndicator = /*#__PURE__*/React__default["default"].forwardRef(function BadgeIndicatorContent(_ref, ref) {
|
|
25
|
+
let {
|
|
26
|
+
className: customClassName,
|
|
27
|
+
count,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
const prefix = usePrefix.usePrefix();
|
|
31
|
+
const classNames = cx__default["default"](`${prefix}--badge-indicator`, customClassName, {
|
|
32
|
+
[`${prefix}--badge-indicator--count`]: count
|
|
33
|
+
});
|
|
34
|
+
const displayCount = count && count > 999 ? '999+' : count;
|
|
35
|
+
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
36
|
+
className: classNames,
|
|
37
|
+
ref: ref
|
|
38
|
+
}, rest), displayCount);
|
|
39
|
+
});
|
|
40
|
+
BadgeIndicator.propTypes = {
|
|
41
|
+
/**
|
|
42
|
+
* Specify an optional className to add.
|
|
43
|
+
*/
|
|
44
|
+
className: PropTypes__default["default"].string,
|
|
45
|
+
/**
|
|
46
|
+
* Count of badge indicator
|
|
47
|
+
*/
|
|
48
|
+
count: PropTypes__default["default"].number,
|
|
49
|
+
/**
|
|
50
|
+
* Provide an `id` to uniquely identify the BadgeIndidcator
|
|
51
|
+
*/
|
|
52
|
+
id: PropTypes__default["default"].string
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.BadgeIndicator = BadgeIndicator;
|
|
56
|
+
exports["default"] = BadgeIndicator;
|
|
@@ -19,6 +19,11 @@ export interface BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
19
19
|
* Optional prop to omit the trailing slash for the breadcrumbs
|
|
20
20
|
*/
|
|
21
21
|
noTrailingSlash?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Specify the size of the Breadcrumb. Currently
|
|
24
|
+
* supports the following: `sm` & `md` (default: 'md')
|
|
25
|
+
*/
|
|
26
|
+
size?: 'sm' | 'md';
|
|
22
27
|
}
|
|
23
28
|
declare const Breadcrumb: ForwardRefReturn<HTMLElement, BreadcrumbProps>;
|
|
24
29
|
export default Breadcrumb;
|
|
@@ -27,12 +27,14 @@ const Breadcrumb = /*#__PURE__*/React__default["default"].forwardRef(function Br
|
|
|
27
27
|
children,
|
|
28
28
|
className: customClassNameNav,
|
|
29
29
|
noTrailingSlash,
|
|
30
|
+
size,
|
|
30
31
|
...rest
|
|
31
32
|
} = _ref;
|
|
32
33
|
const prefix = usePrefix.usePrefix();
|
|
33
34
|
const className = cx__default["default"]({
|
|
34
35
|
[`${prefix}--breadcrumb`]: true,
|
|
35
|
-
[`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash
|
|
36
|
+
[`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash,
|
|
37
|
+
[`${prefix}--breadcrumb--sm`]: size === 'sm'
|
|
36
38
|
});
|
|
37
39
|
return /*#__PURE__*/React__default["default"].createElement("nav", _rollupPluginBabelHelpers["extends"]({
|
|
38
40
|
className: customClassNameNav,
|
|
@@ -59,7 +61,11 @@ Breadcrumb.propTypes = {
|
|
|
59
61
|
/**
|
|
60
62
|
* Optional prop to omit the trailing slash for the breadcrumbs
|
|
61
63
|
*/
|
|
62
|
-
noTrailingSlash: PropTypes__default["default"].bool
|
|
64
|
+
noTrailingSlash: PropTypes__default["default"].bool,
|
|
65
|
+
/**
|
|
66
|
+
* Specify the size of the Breadcrumb. Currently supports the following:
|
|
67
|
+
*/
|
|
68
|
+
size: PropTypes__default["default"].oneOf(['sm', 'md'])
|
|
63
69
|
};
|
|
64
70
|
|
|
65
71
|
exports["default"] = Breadcrumb;
|
|
@@ -67,6 +67,15 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
67
67
|
* Can be one of: start, center, or end.
|
|
68
68
|
*/
|
|
69
69
|
tooltipAlignment?: ButtonTooltipAlignment;
|
|
70
|
+
/**
|
|
71
|
+
* Enable drop shadow for tooltips for icon-only buttons.
|
|
72
|
+
*/
|
|
73
|
+
tooltipDropShadow?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Enable high-contrast theme for tooltips on icon-only buttons.
|
|
76
|
+
* Defaults to true.
|
|
77
|
+
*/
|
|
78
|
+
tooltipHighContrast?: boolean;
|
|
70
79
|
/**
|
|
71
80
|
* Specify the direction of the tooltip for icon-only buttons.
|
|
72
81
|
* Can be either top, right, bottom, or left.
|
|
@@ -38,6 +38,8 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((props, ref) =>
|
|
|
38
38
|
autoAlign = false,
|
|
39
39
|
children,
|
|
40
40
|
hasIconOnly = false,
|
|
41
|
+
tooltipHighContrast = true,
|
|
42
|
+
tooltipDropShadow = false,
|
|
41
43
|
iconDescription,
|
|
42
44
|
kind = 'primary',
|
|
43
45
|
onBlur,
|
|
@@ -90,6 +92,8 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef((props, ref) =>
|
|
|
90
92
|
label: iconDescription,
|
|
91
93
|
kind: kind,
|
|
92
94
|
size: size,
|
|
95
|
+
highContrast: tooltipHighContrast,
|
|
96
|
+
dropShadow: tooltipDropShadow,
|
|
93
97
|
onMouseEnter: onMouseEnter,
|
|
94
98
|
onMouseLeave: onMouseLeave,
|
|
95
99
|
onFocus: onFocus,
|
|
@@ -224,6 +228,15 @@ Button.propTypes = {
|
|
|
224
228
|
* Can be one of: start, center, or end.
|
|
225
229
|
*/
|
|
226
230
|
tooltipAlignment: PropTypes__default["default"].oneOf(['start', 'center', 'end']),
|
|
231
|
+
/**
|
|
232
|
+
* Enable drop shadow for tooltips for icon-only buttons.
|
|
233
|
+
*/
|
|
234
|
+
tooltipDropShadow: PropTypes__default["default"].bool,
|
|
235
|
+
/**
|
|
236
|
+
* Enable high-contrast theme for tooltips for icon-only buttons.
|
|
237
|
+
* Defaults to true.
|
|
238
|
+
*/
|
|
239
|
+
tooltipHighContrast: PropTypes__default["default"].bool,
|
|
227
240
|
/**
|
|
228
241
|
* Specify the direction of the tooltip for icon-only buttons.
|
|
229
242
|
* Can be either top, right, bottom, or left.
|
|
@@ -28,9 +28,9 @@ require('../FluidForm/FluidForm.js');
|
|
|
28
28
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
29
29
|
var react = require('@floating-ui/react');
|
|
30
30
|
var index = require('../FeatureFlags/index.js');
|
|
31
|
-
var Text = require('../Text/Text.js');
|
|
32
31
|
var match = require('../../internal/keyboard/match.js');
|
|
33
32
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
33
|
+
var Text = require('../Text/Text.js');
|
|
34
34
|
var keys = require('../../internal/keyboard/keys.js');
|
|
35
35
|
|
|
36
36
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -476,11 +476,22 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
},
|
|
479
|
+
initialSelectedItem: initialSelectedItem,
|
|
480
|
+
inputId: id,
|
|
481
|
+
stateReducer,
|
|
482
|
+
isItemDisabled(item, _index) {
|
|
483
|
+
return item?.disabled;
|
|
484
|
+
},
|
|
485
|
+
...downshiftProps,
|
|
479
486
|
onStateChange: _ref6 => {
|
|
480
487
|
let {
|
|
481
488
|
type,
|
|
482
489
|
selectedItem: newSelectedItem
|
|
483
490
|
} = _ref6;
|
|
491
|
+
downshiftProps?.onStateChange?.({
|
|
492
|
+
type,
|
|
493
|
+
selectedItem: newSelectedItem
|
|
494
|
+
});
|
|
484
495
|
if (type === Downshift.useCombobox.stateChangeTypes.ItemClick && !isEqual__default["default"](selectedItemProp, newSelectedItem)) {
|
|
485
496
|
onChange({
|
|
486
497
|
selectedItem: newSelectedItem
|
|
@@ -492,14 +503,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
492
503
|
selectedItem: newSelectedItem
|
|
493
504
|
});
|
|
494
505
|
}
|
|
495
|
-
}
|
|
496
|
-
initialSelectedItem: initialSelectedItem,
|
|
497
|
-
inputId: id,
|
|
498
|
-
stateReducer,
|
|
499
|
-
isItemDisabled(item, _index) {
|
|
500
|
-
return item?.disabled;
|
|
501
|
-
},
|
|
502
|
-
...downshiftProps
|
|
506
|
+
}
|
|
503
507
|
});
|
|
504
508
|
React.useEffect(() => {
|
|
505
509
|
// Used to expose the downshift actions to consumers for use with downshiftProps
|
|
@@ -330,11 +330,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
330
330
|
}
|
|
331
331
|
return /*#__PURE__*/React__default["default"].isValidElement(element) ? element : null;
|
|
332
332
|
}, [slug, decorator]);
|
|
333
|
+
const labelProps = ! /*#__PURE__*/React.isValidElement(titleText) ? getLabelProps() : null;
|
|
333
334
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
334
335
|
className: wrapperClasses
|
|
335
336
|
}, other), titleText && /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
336
337
|
className: titleClasses
|
|
337
|
-
},
|
|
338
|
+
}, labelProps), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
338
339
|
onFocus: handleFocus,
|
|
339
340
|
onBlur: handleFocus,
|
|
340
341
|
size: size,
|
|
@@ -19,8 +19,8 @@ var Button = require('../Button/Button.js');
|
|
|
19
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
20
20
|
require('../Text/index.js');
|
|
21
21
|
var useId = require('../../internal/useId.js');
|
|
22
|
-
var Text = require('../Text/Text.js');
|
|
23
22
|
var match = require('../../internal/keyboard/match.js');
|
|
23
|
+
var Text = require('../Text/Text.js');
|
|
24
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
25
25
|
|
|
26
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -20,8 +20,8 @@ var noopFn = require('../../internal/noopFn.js');
|
|
|
20
20
|
require('../Text/index.js');
|
|
21
21
|
require('../Tooltip/DefinitionTooltip.js');
|
|
22
22
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
23
|
-
var Text = require('../Text/Text.js');
|
|
24
23
|
var match = require('../../internal/keyboard/match.js');
|
|
24
|
+
var Text = require('../Text/Text.js');
|
|
25
25
|
var keys = require('../../internal/keyboard/keys.js');
|
|
26
26
|
|
|
27
27
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -20,6 +20,11 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
20
20
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
21
21
|
*/
|
|
22
22
|
autoAlign?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* **Experimental**: Display a badge on the button. An empty/dot badge if 0, a numbered badge if > 0.
|
|
25
|
+
* Must be used with size="lg" and kind="ghost"
|
|
26
|
+
*/
|
|
27
|
+
badgeCount?: number;
|
|
23
28
|
/**
|
|
24
29
|
* Optionally specify an href for your IconButton to become an `<a>` element
|
|
25
30
|
*/
|
|
@@ -68,7 +73,8 @@ export interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
68
73
|
* Provide the label to be rendered inside of the Tooltip. The label will use
|
|
69
74
|
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
70
75
|
* This means that if you have text in the child node it will not be
|
|
71
|
-
* announced to the screen reader.
|
|
76
|
+
* announced to the screen reader. If using the badgeCount = 0 then provide a
|
|
77
|
+
* label with describing there is a new notification.
|
|
72
78
|
*/
|
|
73
79
|
label: ReactNode;
|
|
74
80
|
/**
|
|
@@ -15,9 +15,11 @@ var React = require('react');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
require('../Tooltip/DefinitionTooltip.js');
|
|
17
17
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
18
|
+
var useId = require('../../internal/useId.js');
|
|
18
19
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
20
|
var ButtonBase = require('../Button/ButtonBase.js');
|
|
20
21
|
var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
|
|
22
|
+
var index = require('../BadgeIndicator/index.js');
|
|
21
23
|
|
|
22
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
25
|
|
|
@@ -43,6 +45,7 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
43
45
|
let {
|
|
44
46
|
align,
|
|
45
47
|
autoAlign = false,
|
|
48
|
+
badgeCount,
|
|
46
49
|
children,
|
|
47
50
|
className,
|
|
48
51
|
closeOnActivation = true,
|
|
@@ -63,6 +66,10 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
63
66
|
const tooltipClasses = cx__default["default"](wrapperClasses, `${prefix}--icon-tooltip`, {
|
|
64
67
|
[`${prefix}--icon-tooltip--disabled`]: disabled
|
|
65
68
|
});
|
|
69
|
+
if (badgeCount && (kind !== 'ghost' || size !== 'lg')) {
|
|
70
|
+
console.warn("The prop BadgeCount must be used with hasIconOnly=true, kind='ghost' and size='lg'");
|
|
71
|
+
}
|
|
72
|
+
const badgeId = useId.useId('badge-indicator');
|
|
66
73
|
return /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
|
|
67
74
|
align: align,
|
|
68
75
|
autoAlign: autoAlign,
|
|
@@ -81,8 +88,12 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
81
88
|
size: size,
|
|
82
89
|
className: cx__default["default"](`${prefix}--btn--icon-only`, {
|
|
83
90
|
[`${prefix}--btn--selected`]: isSelected
|
|
84
|
-
}, className)
|
|
85
|
-
|
|
91
|
+
}, className),
|
|
92
|
+
"aria-describedby": badgeCount && badgeId
|
|
93
|
+
}), children, !disabled && badgeCount !== undefined && /*#__PURE__*/React__default["default"].createElement(index.BadgeIndicator, {
|
|
94
|
+
id: badgeId,
|
|
95
|
+
count: badgeCount > 0 ? badgeCount : undefined
|
|
96
|
+
})));
|
|
86
97
|
});
|
|
87
98
|
IconButton.propTypes = {
|
|
88
99
|
/**
|
|
@@ -118,6 +129,11 @@ IconButton.propTypes = {
|
|
|
118
129
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
119
130
|
*/
|
|
120
131
|
autoAlign: PropTypes__default["default"].bool,
|
|
132
|
+
/**
|
|
133
|
+
* **Experimental**: Display a badge on the button. An empty/dot badge if 0, a numbered badge if > 0.
|
|
134
|
+
* Must be used with size="lg", kind="ghost" and hasIconOnly=true
|
|
135
|
+
*/
|
|
136
|
+
badgeCount: PropTypes__default["default"].number,
|
|
121
137
|
/**
|
|
122
138
|
* Optionally specify an href for your IconButton to become an `<a>` element
|
|
123
139
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
export declare const IconIndicatorKinds: string[];
|
|
9
9
|
export type IconIndicatorKind = (typeof IconIndicatorKinds)[number];
|
|
10
|
-
interface IconIndicatorProps {
|
|
10
|
+
export interface IconIndicatorProps {
|
|
11
11
|
/**
|
|
12
12
|
* Specify an optional className to add.
|
|
13
13
|
*/
|
|
@@ -76,10 +76,7 @@ const InlineLoading = _ref => {
|
|
|
76
76
|
}
|
|
77
77
|
return undefined;
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
// TODO: Should this element only be constructed, similar to
|
|
81
|
-
// `loadingAnimation`, if `description` is specified?
|
|
82
|
-
const loadingText = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
79
|
+
const loadingText = description && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
83
80
|
className: `${prefix}--inline-loading__text`
|
|
84
81
|
}, description);
|
|
85
82
|
const loading = getLoading();
|
|
@@ -90,7 +87,7 @@ const InlineLoading = _ref => {
|
|
|
90
87
|
className: loadingClasses
|
|
91
88
|
}, rest, {
|
|
92
89
|
"aria-live": rest['aria-live'] ?? 'assertive'
|
|
93
|
-
}), loadingAnimation,
|
|
90
|
+
}), loadingAnimation, loadingText);
|
|
94
91
|
};
|
|
95
92
|
InlineLoading.propTypes = {
|
|
96
93
|
/**
|
|
@@ -23,8 +23,8 @@ var Menu = require('./Menu.js');
|
|
|
23
23
|
var MenuContext = require('./MenuContext.js');
|
|
24
24
|
require('../Text/index.js');
|
|
25
25
|
var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
|
|
26
|
-
var Text = require('../Text/Text.js');
|
|
27
26
|
var match = require('../../internal/keyboard/match.js');
|
|
27
|
+
var Text = require('../Text/Text.js');
|
|
28
28
|
var keys = require('../../internal/keyboard/keys.js');
|
|
29
29
|
|
|
30
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { type ReactNode, type Ref } from 'react';
|
|
8
8
|
import { ReactAttr } from '../../types/common';
|
|
9
9
|
import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
|
|
10
10
|
export declare const ModalSizes: readonly ["xs", "sm", "md", "lg"];
|
|
@@ -58,7 +58,7 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
58
58
|
/**
|
|
59
59
|
* Provide a ref to return focus to once the modal is closed.
|
|
60
60
|
*/
|
|
61
|
-
launcherButtonRef?:
|
|
61
|
+
launcherButtonRef?: Ref<HTMLButtonElement>;
|
|
62
62
|
/**
|
|
63
63
|
* Specify the description for the loading text
|
|
64
64
|
*/
|
|
@@ -32,8 +32,8 @@ var index = require('../FeatureFlags/index.js');
|
|
|
32
32
|
var events = require('../../tools/events.js');
|
|
33
33
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
34
34
|
var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
|
|
35
|
-
var Text = require('../Text/Text.js');
|
|
36
35
|
var match = require('../../internal/keyboard/match.js');
|
|
36
|
+
var Text = require('../Text/Text.js');
|
|
37
37
|
var keys = require('../../internal/keyboard/keys.js');
|
|
38
38
|
|
|
39
39
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -200,7 +200,9 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
|
|
|
200
200
|
React.useEffect(() => {
|
|
201
201
|
if (!open && launcherButtonRef) {
|
|
202
202
|
setTimeout(() => {
|
|
203
|
-
launcherButtonRef
|
|
203
|
+
if ('current' in launcherButtonRef) {
|
|
204
|
+
launcherButtonRef.current?.focus();
|
|
205
|
+
}
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
208
|
}, [open, launcherButtonRef]);
|
|
@@ -383,7 +385,11 @@ Modal.propTypes = {
|
|
|
383
385
|
* Provide a ref to return focus to once the modal is closed.
|
|
384
386
|
*/
|
|
385
387
|
launcherButtonRef: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].shape({
|
|
386
|
-
current: PropTypes__default["default"].
|
|
388
|
+
current: PropTypes__default["default"].oneOfType([
|
|
389
|
+
// `PropTypes.instanceOf(HTMLButtonElement)` alone won't work because
|
|
390
|
+
// `HTMLButtonElement` is not defined in the test environment even
|
|
391
|
+
// though `testEnvironment` is set to `jsdom`.
|
|
392
|
+
typeof HTMLButtonElement !== 'undefined' ? PropTypes__default["default"].instanceOf(HTMLButtonElement) : PropTypes__default["default"].any, PropTypes__default["default"].oneOf([null])]).isRequired
|
|
387
393
|
})]),
|
|
388
394
|
/**
|
|
389
395
|
* Specify the description for the loading text
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -50,10 +50,6 @@ export interface BaseModalProps extends ReactAttr<HTMLDivElement> {
|
|
|
50
50
|
* Specify whether or not the Modal content should have any inner padding.
|
|
51
51
|
*/
|
|
52
52
|
isFullWidth?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Provide a ref to return focus to once the modal is closed.
|
|
55
|
-
*/
|
|
56
|
-
launcherButtonRef?: any;
|
|
57
53
|
/**
|
|
58
54
|
* Specify the description for the loading text
|
|
59
55
|
*/
|
|
@@ -118,6 +118,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
118
118
|
const {
|
|
119
119
|
isFluid
|
|
120
120
|
} = React.useContext(FormContext.FormContext);
|
|
121
|
+
const isFirstRender = React.useRef(true);
|
|
121
122
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
122
123
|
const [isOpen, setIsOpen] = React.useState(!!open);
|
|
123
124
|
const [prevOpen, setPrevOpen] = React.useState(!!open);
|
|
@@ -252,8 +253,15 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
React.useEffect(() => {
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
if (isFirstRender.current) {
|
|
257
|
+
isFirstRender.current = false;
|
|
258
|
+
if (open) {
|
|
259
|
+
onMenuChange?.(isOpen);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
onMenuChange?.(isOpen);
|
|
263
|
+
}
|
|
264
|
+
}, [isOpen, onMenuChange, open]);
|
|
257
265
|
const {
|
|
258
266
|
getToggleButtonProps,
|
|
259
267
|
getLabelProps,
|
|
@@ -435,11 +435,12 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
435
435
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
436
436
|
ref: enableFloatingStyles ? refs.setFloating : null
|
|
437
437
|
}), [enableFloatingStyles, getMenuProps, refs.setFloating]);
|
|
438
|
+
const labelProps = ! /*#__PURE__*/React.isValidElement(titleText) ? getLabelProps() : null;
|
|
438
439
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
439
440
|
className: wrapperClasses
|
|
440
441
|
}, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
441
442
|
className: titleClasses
|
|
442
|
-
},
|
|
443
|
+
}, labelProps), titleText && titleText, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
443
444
|
className: `${prefix}--visually-hidden`
|
|
444
445
|
}, clearSelectionDescription, " ", selectedItems.length, ' ', itemsSelectedText, ",", clearSelectionText)), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
445
446
|
onFocus: isFluid ? handleFocus : undefined,
|
|
@@ -40,8 +40,11 @@ interface DownshiftTypedProps<ItemType> {
|
|
|
40
40
|
interface SharedOptions {
|
|
41
41
|
locale: string;
|
|
42
42
|
}
|
|
43
|
+
interface CompareItems {
|
|
44
|
+
(itemA: string, itemB: string, options: SharedOptions): number;
|
|
45
|
+
}
|
|
43
46
|
export interface SortItemsOptions<ItemType> extends SharedOptions, DownshiftTypedProps<ItemType> {
|
|
44
|
-
compareItems
|
|
47
|
+
compareItems: CompareItems;
|
|
45
48
|
selectedItems: ItemType[];
|
|
46
49
|
}
|
|
47
50
|
export interface MultiSelectSortingProps<ItemType> {
|
|
@@ -49,7 +52,7 @@ export interface MultiSelectSortingProps<ItemType> {
|
|
|
49
52
|
* Provide a compare function that is used to determine the ordering of
|
|
50
53
|
* options. See 'sortItems' for more control.
|
|
51
54
|
*/
|
|
52
|
-
compareItems
|
|
55
|
+
compareItems?: CompareItems;
|
|
53
56
|
/**
|
|
54
57
|
* Provide a method that sorts all options in the control. Overriding this
|
|
55
58
|
* prop means that you also have to handle the sort logic for selected versus
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Use the
|
|
14
|
-
*
|
|
13
|
+
* Use the locale `localeCompare` with the `numeric` option to sort two
|
|
14
|
+
* alpha-numeric strings.
|
|
15
15
|
*
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {object} options
|
|
19
|
-
* @param {string} options.locale
|
|
20
|
-
* @returns {number}
|
|
16
|
+
* @param {string} itemA - The first string to compare.
|
|
17
|
+
* @param {string} itemB - The second string to compare.
|
|
18
|
+
* @param {object} options - Options for comparing.
|
|
19
|
+
* @param {string} options.locale - The locale to use for comparison.
|
|
20
|
+
* @returns {number} A negative number if itemA comes before itemB, a positive
|
|
21
|
+
* number if itemA comes after itemB, or 0 if they are equal.
|
|
21
22
|
*/
|
|
22
23
|
const defaultCompareItems = (itemA, itemB, _ref) => {
|
|
23
24
|
let {
|
|
@@ -27,8 +27,8 @@ var wrapFocus = require('../../internal/wrapFocus.js');
|
|
|
27
27
|
var index = require('../FeatureFlags/index.js');
|
|
28
28
|
var warning = require('../../internal/warning.js');
|
|
29
29
|
var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
|
|
30
|
-
var Text = require('../Text/Text.js');
|
|
31
30
|
var match = require('../../internal/keyboard/match.js');
|
|
31
|
+
var Text = require('../Text/Text.js');
|
|
32
32
|
var keys = require('../../internal/keyboard/keys.js');
|
|
33
33
|
|
|
34
34
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -173,20 +173,20 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
173
173
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
174
174
|
});
|
|
175
175
|
const Icon = normalizedProps.icon;
|
|
176
|
-
|
|
176
|
+
const getDecimalPlaces = num => {
|
|
177
|
+
const parts = num.toString().split('.');
|
|
178
|
+
return parts[1] ? parts[1].length : 0;
|
|
179
|
+
};
|
|
180
|
+
const handleStepperClick = (event, direction) => {
|
|
177
181
|
if (inputRef.current) {
|
|
178
182
|
const currentValue = Number(inputRef.current.value);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (max !== undefined) {
|
|
184
|
-
newValue = Math.min(newValue, max);
|
|
185
|
-
}
|
|
186
|
-
const currentInputValue = inputRef.current ? inputRef.current.value : '';
|
|
183
|
+
const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
|
|
184
|
+
const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
|
|
185
|
+
const floatValue = parseFloat(rawValue.toFixed(precision));
|
|
186
|
+
const newValue = typeof min !== 'undefined' && typeof max !== 'undefined' ? Math.min(Math.max(floatValue, min), max) : floatValue;
|
|
187
187
|
const state = {
|
|
188
|
-
value: allowEmpty &&
|
|
189
|
-
direction
|
|
188
|
+
value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
|
|
189
|
+
direction
|
|
190
190
|
};
|
|
191
191
|
setValue(state.value);
|
|
192
192
|
if (onChange) {
|
|
@@ -196,7 +196,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
196
196
|
onClick(event, state);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
}
|
|
199
|
+
};
|
|
200
200
|
|
|
201
201
|
// AILabel always size `mini`
|
|
202
202
|
let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
|