@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
|
@@ -15,8 +15,8 @@ import { useId } from '../../internal/useId.js';
|
|
|
15
15
|
import deprecate from '../../prop-types/deprecate.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { AccordionContext } from './AccordionProvider.js';
|
|
18
|
-
import { Text } from '../Text/Text.js';
|
|
19
18
|
import { match } from '../../internal/keyboard/match.js';
|
|
19
|
+
import { Text } from '../Text/Text.js';
|
|
20
20
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
21
21
|
|
|
22
22
|
const defaultRenderToggle = props => /*#__PURE__*/React__default.createElement("button", _extends({
|
|
@@ -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,45 @@
|
|
|
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
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
|
|
14
|
+
const BadgeIndicator = /*#__PURE__*/React__default.forwardRef(function BadgeIndicatorContent(_ref, ref) {
|
|
15
|
+
let {
|
|
16
|
+
className: customClassName,
|
|
17
|
+
count,
|
|
18
|
+
...rest
|
|
19
|
+
} = _ref;
|
|
20
|
+
const prefix = usePrefix();
|
|
21
|
+
const classNames = cx(`${prefix}--badge-indicator`, customClassName, {
|
|
22
|
+
[`${prefix}--badge-indicator--count`]: count
|
|
23
|
+
});
|
|
24
|
+
const displayCount = count && count > 999 ? '999+' : count;
|
|
25
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
26
|
+
className: classNames,
|
|
27
|
+
ref: ref
|
|
28
|
+
}, rest), displayCount);
|
|
29
|
+
});
|
|
30
|
+
BadgeIndicator.propTypes = {
|
|
31
|
+
/**
|
|
32
|
+
* Specify an optional className to add.
|
|
33
|
+
*/
|
|
34
|
+
className: PropTypes.string,
|
|
35
|
+
/**
|
|
36
|
+
* Count of badge indicator
|
|
37
|
+
*/
|
|
38
|
+
count: PropTypes.number,
|
|
39
|
+
/**
|
|
40
|
+
* Provide an `id` to uniquely identify the BadgeIndidcator
|
|
41
|
+
*/
|
|
42
|
+
id: PropTypes.string
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { BadgeIndicator, BadgeIndicator as default };
|
|
@@ -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;
|
|
@@ -17,12 +17,14 @@ const Breadcrumb = /*#__PURE__*/React__default.forwardRef(function Breadcrumb(_r
|
|
|
17
17
|
children,
|
|
18
18
|
className: customClassNameNav,
|
|
19
19
|
noTrailingSlash,
|
|
20
|
+
size,
|
|
20
21
|
...rest
|
|
21
22
|
} = _ref;
|
|
22
23
|
const prefix = usePrefix();
|
|
23
24
|
const className = cx({
|
|
24
25
|
[`${prefix}--breadcrumb`]: true,
|
|
25
|
-
[`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash
|
|
26
|
+
[`${prefix}--breadcrumb--no-trailing-slash`]: noTrailingSlash,
|
|
27
|
+
[`${prefix}--breadcrumb--sm`]: size === 'sm'
|
|
26
28
|
});
|
|
27
29
|
return /*#__PURE__*/React__default.createElement("nav", _extends({
|
|
28
30
|
className: customClassNameNav,
|
|
@@ -49,7 +51,11 @@ Breadcrumb.propTypes = {
|
|
|
49
51
|
/**
|
|
50
52
|
* Optional prop to omit the trailing slash for the breadcrumbs
|
|
51
53
|
*/
|
|
52
|
-
noTrailingSlash: PropTypes.bool
|
|
54
|
+
noTrailingSlash: PropTypes.bool,
|
|
55
|
+
/**
|
|
56
|
+
* Specify the size of the Breadcrumb. Currently supports the following:
|
|
57
|
+
*/
|
|
58
|
+
size: PropTypes.oneOf(['sm', 'md'])
|
|
53
59
|
};
|
|
54
60
|
|
|
55
61
|
export { Breadcrumb as default };
|
|
@@ -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.
|
|
@@ -29,6 +29,8 @@ const Button = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
29
29
|
autoAlign = false,
|
|
30
30
|
children,
|
|
31
31
|
hasIconOnly = false,
|
|
32
|
+
tooltipHighContrast = true,
|
|
33
|
+
tooltipDropShadow = false,
|
|
32
34
|
iconDescription,
|
|
33
35
|
kind = 'primary',
|
|
34
36
|
onBlur,
|
|
@@ -81,6 +83,8 @@ const Button = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
81
83
|
label: iconDescription,
|
|
82
84
|
kind: kind,
|
|
83
85
|
size: size,
|
|
86
|
+
highContrast: tooltipHighContrast,
|
|
87
|
+
dropShadow: tooltipDropShadow,
|
|
84
88
|
onMouseEnter: onMouseEnter,
|
|
85
89
|
onMouseLeave: onMouseLeave,
|
|
86
90
|
onFocus: onFocus,
|
|
@@ -215,6 +219,15 @@ Button.propTypes = {
|
|
|
215
219
|
* Can be one of: start, center, or end.
|
|
216
220
|
*/
|
|
217
221
|
tooltipAlignment: PropTypes.oneOf(['start', 'center', 'end']),
|
|
222
|
+
/**
|
|
223
|
+
* Enable drop shadow for tooltips for icon-only buttons.
|
|
224
|
+
*/
|
|
225
|
+
tooltipDropShadow: PropTypes.bool,
|
|
226
|
+
/**
|
|
227
|
+
* Enable high-contrast theme for tooltips for icon-only buttons.
|
|
228
|
+
* Defaults to true.
|
|
229
|
+
*/
|
|
230
|
+
tooltipHighContrast: PropTypes.bool,
|
|
218
231
|
/**
|
|
219
232
|
* Specify the direction of the tooltip for icon-only buttons.
|
|
220
233
|
* Can be either top, right, bottom, or left.
|
|
@@ -24,9 +24,9 @@ import '../FluidForm/FluidForm.js';
|
|
|
24
24
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
25
25
|
import { useFloating, flip, hide, autoUpdate } from '@floating-ui/react';
|
|
26
26
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
27
|
-
import { Text } from '../Text/Text.js';
|
|
28
27
|
import { match } from '../../internal/keyboard/match.js';
|
|
29
28
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
29
|
+
import { Text } from '../Text/Text.js';
|
|
30
30
|
import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
|
|
31
31
|
|
|
32
32
|
const {
|
|
@@ -215,7 +215,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
215
215
|
const textInput = useRef(null);
|
|
216
216
|
const comboBoxInstanceId = useId();
|
|
217
217
|
const [isFocused, setIsFocused] = useState(false);
|
|
218
|
-
const
|
|
218
|
+
const prevInputValue = useRef(inputValue);
|
|
219
219
|
const prevSelectedItemProp = useRef(selectedItemProp);
|
|
220
220
|
|
|
221
221
|
// fully controlled combobox: handle changes to selectedItemProp
|
|
@@ -246,12 +246,12 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
246
246
|
itemToString,
|
|
247
247
|
inputValue
|
|
248
248
|
}) : defaultShouldFilterItem());
|
|
249
|
+
|
|
250
|
+
// call onInputChange whenever inputValue is updated
|
|
249
251
|
useEffect(() => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (savedOnInputChange.current) {
|
|
254
|
-
savedOnInputChange.current(inputValue);
|
|
252
|
+
if (prevInputValue.current !== inputValue) {
|
|
253
|
+
prevInputValue.current = inputValue;
|
|
254
|
+
onInputChange && onInputChange(inputValue);
|
|
255
255
|
}
|
|
256
256
|
}, [inputValue]);
|
|
257
257
|
const handleSelectionClear = () => {
|
|
@@ -465,11 +465,22 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
467
|
},
|
|
468
|
+
initialSelectedItem: initialSelectedItem,
|
|
469
|
+
inputId: id,
|
|
470
|
+
stateReducer,
|
|
471
|
+
isItemDisabled(item, _index) {
|
|
472
|
+
return item?.disabled;
|
|
473
|
+
},
|
|
474
|
+
...downshiftProps,
|
|
468
475
|
onStateChange: _ref6 => {
|
|
469
476
|
let {
|
|
470
477
|
type,
|
|
471
478
|
selectedItem: newSelectedItem
|
|
472
479
|
} = _ref6;
|
|
480
|
+
downshiftProps?.onStateChange?.({
|
|
481
|
+
type,
|
|
482
|
+
selectedItem: newSelectedItem
|
|
483
|
+
});
|
|
473
484
|
if (type === useCombobox.stateChangeTypes.ItemClick && !isEqual(selectedItemProp, newSelectedItem)) {
|
|
474
485
|
onChange({
|
|
475
486
|
selectedItem: newSelectedItem
|
|
@@ -481,14 +492,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
481
492
|
selectedItem: newSelectedItem
|
|
482
493
|
});
|
|
483
494
|
}
|
|
484
|
-
}
|
|
485
|
-
initialSelectedItem: initialSelectedItem,
|
|
486
|
-
inputId: id,
|
|
487
|
-
stateReducer,
|
|
488
|
-
isItemDisabled(item, _index) {
|
|
489
|
-
return item?.disabled;
|
|
490
|
-
},
|
|
491
|
-
...downshiftProps
|
|
495
|
+
}
|
|
492
496
|
});
|
|
493
497
|
useEffect(() => {
|
|
494
498
|
// Used to expose the downshift actions to consumers for use with downshiftProps
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useEffect, useContext, useCallback, useMemo, useState } from 'react';
|
|
9
|
+
import React__default, { useEffect, useContext, useCallback, useMemo, useState, isValidElement } from 'react';
|
|
10
10
|
import { useSelect } from 'downshift';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
@@ -320,11 +320,12 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
320
320
|
}
|
|
321
321
|
return /*#__PURE__*/React__default.isValidElement(element) ? element : null;
|
|
322
322
|
}, [slug, decorator]);
|
|
323
|
+
const labelProps = ! /*#__PURE__*/isValidElement(titleText) ? getLabelProps() : null;
|
|
323
324
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
324
325
|
className: wrapperClasses
|
|
325
326
|
}, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
|
|
326
327
|
className: titleClasses
|
|
327
|
-
},
|
|
328
|
+
}, labelProps), titleText), /*#__PURE__*/React__default.createElement(ListBox, {
|
|
328
329
|
onFocus: handleFocus,
|
|
329
330
|
onBlur: handleFocus,
|
|
330
331
|
size: size$1,
|
|
@@ -15,8 +15,8 @@ import { ButtonKinds } from '../Button/Button.js';
|
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import '../Text/index.js';
|
|
17
17
|
import { useId } from '../../internal/useId.js';
|
|
18
|
-
import { Text } from '../Text/Text.js';
|
|
19
18
|
import { matches } from '../../internal/keyboard/match.js';
|
|
19
|
+
import { Text } from '../Text/Text.js';
|
|
20
20
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
21
21
|
|
|
22
22
|
const FileUploader = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
@@ -16,8 +16,8 @@ import { noopFn } from '../../internal/noopFn.js';
|
|
|
16
16
|
import '../Text/index.js';
|
|
17
17
|
import '../Tooltip/DefinitionTooltip.js';
|
|
18
18
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
19
|
-
import { Text } from '../Text/Text.js';
|
|
20
19
|
import { matches } from '../../internal/keyboard/match.js';
|
|
20
|
+
import { Text } from '../Text/Text.js';
|
|
21
21
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
23
|
function FileUploaderItem(_ref) {
|
|
@@ -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
|
/**
|
|
@@ -11,9 +11,11 @@ import React__default from 'react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import '../Tooltip/DefinitionTooltip.js';
|
|
13
13
|
import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
14
|
+
import { useId } from '../../internal/useId.js';
|
|
14
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
16
|
import ButtonBase from '../Button/ButtonBase.js';
|
|
16
17
|
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
18
|
+
import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
17
19
|
|
|
18
20
|
const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
|
|
19
21
|
const propMappingFunction = deprecatedValue => {
|
|
@@ -33,6 +35,7 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
|
|
|
33
35
|
let {
|
|
34
36
|
align,
|
|
35
37
|
autoAlign = false,
|
|
38
|
+
badgeCount,
|
|
36
39
|
children,
|
|
37
40
|
className,
|
|
38
41
|
closeOnActivation = true,
|
|
@@ -53,6 +56,10 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
|
|
|
53
56
|
const tooltipClasses = cx(wrapperClasses, `${prefix}--icon-tooltip`, {
|
|
54
57
|
[`${prefix}--icon-tooltip--disabled`]: disabled
|
|
55
58
|
});
|
|
59
|
+
if (badgeCount && (kind !== 'ghost' || size !== 'lg')) {
|
|
60
|
+
console.warn("The prop BadgeCount must be used with hasIconOnly=true, kind='ghost' and size='lg'");
|
|
61
|
+
}
|
|
62
|
+
const badgeId = useId('badge-indicator');
|
|
56
63
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
57
64
|
align: align,
|
|
58
65
|
autoAlign: autoAlign,
|
|
@@ -71,8 +78,12 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_r
|
|
|
71
78
|
size: size,
|
|
72
79
|
className: cx(`${prefix}--btn--icon-only`, {
|
|
73
80
|
[`${prefix}--btn--selected`]: isSelected
|
|
74
|
-
}, className)
|
|
75
|
-
|
|
81
|
+
}, className),
|
|
82
|
+
"aria-describedby": badgeCount && badgeId
|
|
83
|
+
}), children, !disabled && badgeCount !== undefined && /*#__PURE__*/React__default.createElement(BadgeIndicator, {
|
|
84
|
+
id: badgeId,
|
|
85
|
+
count: badgeCount > 0 ? badgeCount : undefined
|
|
86
|
+
})));
|
|
76
87
|
});
|
|
77
88
|
IconButton.propTypes = {
|
|
78
89
|
/**
|
|
@@ -108,6 +119,11 @@ IconButton.propTypes = {
|
|
|
108
119
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
109
120
|
*/
|
|
110
121
|
autoAlign: PropTypes.bool,
|
|
122
|
+
/**
|
|
123
|
+
* **Experimental**: Display a badge on the button. An empty/dot badge if 0, a numbered badge if > 0.
|
|
124
|
+
* Must be used with size="lg", kind="ghost" and hasIconOnly=true
|
|
125
|
+
*/
|
|
126
|
+
badgeCount: PropTypes.number,
|
|
111
127
|
/**
|
|
112
128
|
* Optionally specify an href for your IconButton to become an `<a>` element
|
|
113
129
|
*/
|
|
@@ -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
|
*/
|
|
@@ -66,10 +66,7 @@ const InlineLoading = _ref => {
|
|
|
66
66
|
}
|
|
67
67
|
return undefined;
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
// TODO: Should this element only be constructed, similar to
|
|
71
|
-
// `loadingAnimation`, if `description` is specified?
|
|
72
|
-
const loadingText = /*#__PURE__*/React__default.createElement("div", {
|
|
69
|
+
const loadingText = description && /*#__PURE__*/React__default.createElement("div", {
|
|
73
70
|
className: `${prefix}--inline-loading__text`
|
|
74
71
|
}, description);
|
|
75
72
|
const loading = getLoading();
|
|
@@ -80,7 +77,7 @@ const InlineLoading = _ref => {
|
|
|
80
77
|
className: loadingClasses
|
|
81
78
|
}, rest, {
|
|
82
79
|
"aria-live": rest['aria-live'] ?? 'assertive'
|
|
83
|
-
}), loadingAnimation,
|
|
80
|
+
}), loadingAnimation, loadingText);
|
|
84
81
|
};
|
|
85
82
|
InlineLoading.propTypes = {
|
|
86
83
|
/**
|
|
@@ -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.
|
|
@@ -12,7 +12,7 @@ import React__default, { forwardRef, useRef, useContext, useReducer, useMemo, us
|
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
-
import
|
|
15
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
16
16
|
import { MenuContext, menuReducer } from './MenuContext.js';
|
|
17
17
|
import { canUseDOM } from '../../internal/environment.js';
|
|
18
18
|
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
@@ -28,7 +28,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
28
28
|
containerRef,
|
|
29
29
|
label,
|
|
30
30
|
menuAlignment,
|
|
31
|
-
mode
|
|
31
|
+
mode,
|
|
32
32
|
onClose,
|
|
33
33
|
onOpen,
|
|
34
34
|
open,
|
|
@@ -44,14 +44,10 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
44
44
|
const focusReturn = useRef(null);
|
|
45
45
|
const context = useContext(MenuContext);
|
|
46
46
|
const isRoot = context.state.isRoot;
|
|
47
|
-
if (context.state.mode === 'basic' && !isRoot) {
|
|
48
|
-
process.env.NODE_ENV !== "production" ? warning(false, 'Nested menus are not supported when the menu is in "basic" mode.') : void 0;
|
|
49
|
-
}
|
|
50
47
|
const menuSize = isRoot ? size : context.state.size;
|
|
51
48
|
const [childState, childDispatch] = useReducer(menuReducer, {
|
|
52
49
|
...context.state,
|
|
53
50
|
isRoot: false,
|
|
54
|
-
mode,
|
|
55
51
|
size,
|
|
56
52
|
requestCloseRoot: isRoot ? handleClose : context.state.requestCloseRoot
|
|
57
53
|
});
|
|
@@ -283,6 +279,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
283
279
|
[`${prefix}--menu--open`]: open,
|
|
284
280
|
[`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
|
|
285
281
|
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
|
|
282
|
+
[`${prefix}--menu--with-selectable-items`]: childContext.state.hasSelectableItems,
|
|
286
283
|
[`${prefix}--autoalign`]: !legacyAutoalign
|
|
287
284
|
});
|
|
288
285
|
const rendered = /*#__PURE__*/React__default.createElement(MenuContext.Provider, {
|
|
@@ -320,13 +317,14 @@ Menu.propTypes = {
|
|
|
320
317
|
*/
|
|
321
318
|
menuAlignment: PropTypes.string,
|
|
322
319
|
/**
|
|
320
|
+
* **Deprecated**: Menus now always support both icons as well as selectable items and nesting.
|
|
323
321
|
* The mode of this menu. Defaults to full.
|
|
324
322
|
* `full` supports nesting and selectable menu items, but no icons.
|
|
325
323
|
* `basic` supports icons but no nesting or selectable menu items.
|
|
326
324
|
*
|
|
327
325
|
* **This prop is not intended for use and will be set by the respective implementation (like useContextMenu, MenuButton, and ComboButton).**
|
|
328
326
|
*/
|
|
329
|
-
mode: PropTypes.oneOf(['full', 'basic']),
|
|
327
|
+
mode: deprecate(PropTypes.oneOf(['full', 'basic']), 'Menus now always support both icons as well as selectable items and nesting.'),
|
|
330
328
|
/**
|
|
331
329
|
* Provide an optional function to be called when the Menu should be closed.
|
|
332
330
|
*/
|
|
@@ -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;
|
|
@@ -9,8 +9,8 @@ import { createContext } from 'react';
|
|
|
9
9
|
|
|
10
10
|
const menuDefaultState = {
|
|
11
11
|
isRoot: true,
|
|
12
|
-
mode: 'full',
|
|
13
12
|
hasIcons: false,
|
|
13
|
+
hasSelectableItems: false,
|
|
14
14
|
size: null,
|
|
15
15
|
items: [],
|
|
16
16
|
requestCloseRoot: () => {}
|
|
@@ -22,6 +22,11 @@ function menuReducer(state, action) {
|
|
|
22
22
|
...state,
|
|
23
23
|
hasIcons: true
|
|
24
24
|
};
|
|
25
|
+
case 'enableSelectableItems':
|
|
26
|
+
return {
|
|
27
|
+
...state,
|
|
28
|
+
hasSelectableItems: true
|
|
29
|
+
};
|
|
25
30
|
case 'registerItem':
|
|
26
31
|
return {
|
|
27
32
|
...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
|
/**
|