@carbon/react 1.77.0 → 1.78.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 +1038 -916
- 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 +19 -15
- package/es/components/ComboButton/index.js +0 -1
- package/es/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/es/components/ContextMenu/useContextMenu.js +1 -2
- 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/Menu.d.ts +1 -0
- package/es/components/Menu/Menu.js +5 -7
- package/es/components/Menu/MenuContext.d.ts +4 -4
- package/es/components/Menu/MenuContext.js +6 -1
- package/es/components/Menu/MenuItem.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +15 -23
- package/es/components/MenuButton/index.js +14 -2
- 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/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 +5 -6
- 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/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 +19 -15
- package/lib/components/ComboButton/index.js +0 -1
- package/lib/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/lib/components/ContextMenu/useContextMenu.js +1 -2
- 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/Menu.d.ts +1 -0
- package/lib/components/Menu/Menu.js +5 -7
- package/lib/components/Menu/MenuContext.d.ts +4 -4
- package/lib/components/Menu/MenuContext.js +6 -1
- package/lib/components/Menu/MenuItem.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +14 -22
- package/lib/components/MenuButton/index.js +14 -2
- 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/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 +5 -6
- 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/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 +5 -5
- package/scss/components/badge-indicator/_badge-indicator.scss +9 -0
- package/scss/components/badge-indicator/_index.scss +9 -0
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 }; }
|
|
@@ -226,7 +226,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
226
226
|
const textInput = React.useRef(null);
|
|
227
227
|
const comboBoxInstanceId = useId.useId();
|
|
228
228
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
229
|
-
const
|
|
229
|
+
const prevInputValue = React.useRef(inputValue);
|
|
230
230
|
const prevSelectedItemProp = React.useRef(selectedItemProp);
|
|
231
231
|
|
|
232
232
|
// fully controlled combobox: handle changes to selectedItemProp
|
|
@@ -257,12 +257,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
257
257
|
itemToString,
|
|
258
258
|
inputValue
|
|
259
259
|
}) : defaultShouldFilterItem());
|
|
260
|
+
|
|
261
|
+
// call onInputChange whenever inputValue is updated
|
|
260
262
|
React.useEffect(() => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if (savedOnInputChange.current) {
|
|
265
|
-
savedOnInputChange.current(inputValue);
|
|
263
|
+
if (prevInputValue.current !== inputValue) {
|
|
264
|
+
prevInputValue.current = inputValue;
|
|
265
|
+
onInputChange && onInputChange(inputValue);
|
|
266
266
|
}
|
|
267
267
|
}, [inputValue]);
|
|
268
268
|
const handleSelectionClear = () => {
|
|
@@ -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
|
/**
|
|
@@ -27,6 +27,7 @@ export interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
27
27
|
*/
|
|
28
28
|
menuAlignment?: string;
|
|
29
29
|
/**
|
|
30
|
+
* @deprecated Menus now always support both icons as well as selectable items and nesting.
|
|
30
31
|
* The mode of this menu. Defaults to full.
|
|
31
32
|
* `full` supports nesting and selectable menu items, but no icons.
|
|
32
33
|
* `basic` supports icons but no nesting or selectable menu items.
|
|
@@ -16,7 +16,7 @@ var React = require('react');
|
|
|
16
16
|
var ReactDOM = require('react-dom');
|
|
17
17
|
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
-
var
|
|
19
|
+
var deprecate = require('../../prop-types/deprecate.js');
|
|
20
20
|
var MenuContext = require('./MenuContext.js');
|
|
21
21
|
var environment = require('../../internal/environment.js');
|
|
22
22
|
var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
|
|
@@ -38,7 +38,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
38
38
|
containerRef,
|
|
39
39
|
label,
|
|
40
40
|
menuAlignment,
|
|
41
|
-
mode
|
|
41
|
+
mode,
|
|
42
42
|
onClose,
|
|
43
43
|
onOpen,
|
|
44
44
|
open,
|
|
@@ -54,14 +54,10 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
54
54
|
const focusReturn = React.useRef(null);
|
|
55
55
|
const context = React.useContext(MenuContext.MenuContext);
|
|
56
56
|
const isRoot = context.state.isRoot;
|
|
57
|
-
if (context.state.mode === 'basic' && !isRoot) {
|
|
58
|
-
process.env.NODE_ENV !== "production" ? warning.warning(false, 'Nested menus are not supported when the menu is in "basic" mode.') : void 0;
|
|
59
|
-
}
|
|
60
57
|
const menuSize = isRoot ? size : context.state.size;
|
|
61
58
|
const [childState, childDispatch] = React.useReducer(MenuContext.menuReducer, {
|
|
62
59
|
...context.state,
|
|
63
60
|
isRoot: false,
|
|
64
|
-
mode,
|
|
65
61
|
size,
|
|
66
62
|
requestCloseRoot: isRoot ? handleClose : context.state.requestCloseRoot
|
|
67
63
|
});
|
|
@@ -293,6 +289,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
293
289
|
[`${prefix}--menu--open`]: open,
|
|
294
290
|
[`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
|
|
295
291
|
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
|
|
292
|
+
[`${prefix}--menu--with-selectable-items`]: childContext.state.hasSelectableItems,
|
|
296
293
|
[`${prefix}--autoalign`]: !legacyAutoalign
|
|
297
294
|
});
|
|
298
295
|
const rendered = /*#__PURE__*/React__default["default"].createElement(MenuContext.MenuContext.Provider, {
|
|
@@ -330,13 +327,14 @@ Menu.propTypes = {
|
|
|
330
327
|
*/
|
|
331
328
|
menuAlignment: PropTypes__default["default"].string,
|
|
332
329
|
/**
|
|
330
|
+
* **Deprecated**: Menus now always support both icons as well as selectable items and nesting.
|
|
333
331
|
* The mode of this menu. Defaults to full.
|
|
334
332
|
* `full` supports nesting and selectable menu items, but no icons.
|
|
335
333
|
* `basic` supports icons but no nesting or selectable menu items.
|
|
336
334
|
*
|
|
337
335
|
* **This prop is not intended for use and will be set by the respective implementation (like useContextMenu, MenuButton, and ComboButton).**
|
|
338
336
|
*/
|
|
339
|
-
mode: PropTypes__default["default"].oneOf(['full', 'basic']),
|
|
337
|
+
mode: deprecate["default"](PropTypes__default["default"].oneOf(['full', 'basic']), 'Menus now always support both icons as well as selectable items and nesting.'),
|
|
340
338
|
/**
|
|
341
339
|
* Provide an optional function to be called when the Menu should be closed.
|
|
342
340
|
*/
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { KeyboardEvent, RefObject } from 'react';
|
|
8
8
|
type ActionType = {
|
|
9
|
-
type: 'enableIcons' | 'registerItem';
|
|
9
|
+
type: 'enableIcons' | 'enableSelectableItems' | 'registerItem';
|
|
10
10
|
payload: any;
|
|
11
11
|
};
|
|
12
12
|
type StateType = {
|
|
13
13
|
isRoot: boolean;
|
|
14
|
-
mode: 'full' | 'basic';
|
|
15
14
|
hasIcons: boolean;
|
|
15
|
+
hasSelectableItems: boolean;
|
|
16
16
|
size: 'xs' | 'sm' | 'md' | 'lg' | null;
|
|
17
17
|
items: any[];
|
|
18
18
|
requestCloseRoot: (e: Pick<KeyboardEvent<HTMLUListElement>, 'type'>) => void;
|
|
@@ -20,13 +20,13 @@ type StateType = {
|
|
|
20
20
|
declare function menuReducer(state: StateType, action: ActionType): {
|
|
21
21
|
hasIcons: boolean;
|
|
22
22
|
isRoot: boolean;
|
|
23
|
-
|
|
23
|
+
hasSelectableItems: boolean;
|
|
24
24
|
size: "xs" | "sm" | "md" | "lg" | null;
|
|
25
25
|
items: any[];
|
|
26
26
|
requestCloseRoot: (e: Pick<KeyboardEvent<HTMLUListElement>, "type">) => void;
|
|
27
27
|
};
|
|
28
28
|
type DispatchFuncProps = {
|
|
29
|
-
type: '
|
|
29
|
+
type: ActionType['type'];
|
|
30
30
|
payload: {
|
|
31
31
|
ref: RefObject<HTMLLIElement>;
|
|
32
32
|
disabled: boolean;
|
|
@@ -13,8 +13,8 @@ var React = require('react');
|
|
|
13
13
|
|
|
14
14
|
const menuDefaultState = {
|
|
15
15
|
isRoot: true,
|
|
16
|
-
mode: 'full',
|
|
17
16
|
hasIcons: false,
|
|
17
|
+
hasSelectableItems: false,
|
|
18
18
|
size: null,
|
|
19
19
|
items: [],
|
|
20
20
|
requestCloseRoot: () => {}
|
|
@@ -26,6 +26,11 @@ function menuReducer(state, action) {
|
|
|
26
26
|
...state,
|
|
27
27
|
hasIcons: true
|
|
28
28
|
};
|
|
29
|
+
case 'enableSelectableItems':
|
|
30
|
+
return {
|
|
31
|
+
...state,
|
|
32
|
+
hasSelectableItems: true
|
|
33
|
+
};
|
|
29
34
|
case 'registerItem':
|
|
30
35
|
return {
|
|
31
36
|
...state,
|
|
@@ -31,7 +31,7 @@ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
|
31
31
|
*/
|
|
32
32
|
onClick?: (event: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => void;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Sets the menu item's icon.
|
|
35
35
|
*/
|
|
36
36
|
renderIcon?: FC;
|
|
37
37
|
/**
|