@carbon/react 1.24.0 → 1.26.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/es/components/Button/Button.js +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +13 -115
- package/es/components/ComboBox/ComboBox.d.ts +6 -0
- package/es/components/ComboBox/ComboBox.js +19 -172
- package/es/components/ComboButton/index.js +164 -0
- package/es/components/ComposedModal/ComposedModal.js +1 -2
- package/es/components/DataTable/Table.d.ts +74 -0
- package/es/components/DataTable/Table.js +4 -2
- package/es/components/DataTable/TableCell.d.ts +10 -0
- package/es/components/DataTable/TableContext.d.ts +13 -0
- package/es/components/DataTable/TableContext.js +2 -2
- package/es/components/DataTable/TableExpandRow.d.ts +67 -0
- package/es/components/DataTable/TableExpandedRow.d.ts +32 -0
- package/es/components/DataTable/TableHead.d.ts +10 -0
- package/es/components/DataTable/TableHeader.d.ts +64 -0
- package/es/components/DataTable/TableHeader.js +23 -28
- package/es/components/DataTable/TableRow.d.ts +32 -0
- package/es/components/DataTable/TableSelectAll.js +1 -1
- package/es/components/DataTable/TableSelectRow.js +1 -3
- package/es/components/DataTable/TableToolbar.d.ts +19 -0
- package/es/components/DataTable/TableToolbar.js +1 -1
- package/es/components/DataTable/TableToolbarAction.d.ts +21 -0
- package/es/components/DataTable/TableToolbarContent.d.ts +19 -0
- package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -3
- package/es/components/DataTable/TableToolbarSearch.js +1 -0
- package/es/components/DataTable/tools/sorting.js +2 -1
- package/es/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
- package/es/components/Dropdown/Dropdown.d.ts +6 -0
- package/es/components/Dropdown/Dropdown.js +8 -145
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/es/components/FileUploader/FileUploader.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +2 -0
- package/es/components/FileUploader/FileUploaderDropContainer.js +30 -18
- package/es/components/FileUploader/FileUploaderItem.js +2 -1
- package/es/components/FileUploader/Filename.js +8 -2
- package/es/components/FluidTextArea/FluidTextArea.js +12 -1
- package/es/components/IconButton/index.js +1 -0
- package/es/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/es/components/ListBox/ListBoxSelection.js +4 -23
- package/es/components/ListBox/next/ListBoxSelection.js +2 -23
- package/es/components/Menu/Menu.js +50 -29
- package/es/components/Menu/MenuItem.js +1 -0
- package/es/components/MenuButton/index.js +127 -0
- package/es/components/Modal/Modal.js +4 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +46 -144
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +48 -28
- package/es/components/Notification/Notification.js +27 -264
- package/es/components/NumberInput/NumberInput.js +9 -1
- package/es/components/OverflowMenu/OverflowMenu.js +13 -139
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
- package/es/components/OverflowMenuV2/index.js +15 -51
- package/es/components/Popover/index.d.ts +5 -1
- package/es/components/Popover/index.js +37 -9
- package/es/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
- package/es/components/RadioButton/RadioButton.Skeleton.js +3 -3
- package/es/components/RadioButton/RadioButton.d.ts +64 -0
- package/es/components/RadioButton/RadioButton.js +19 -17
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +88 -26
- package/es/components/RadioTile/RadioTile.js +6 -6
- package/es/components/Search/Search.Skeleton.d.ts +36 -0
- package/es/components/Search/Search.js +3 -2
- package/es/components/Search/index.js +1 -0
- package/es/components/Select/Select.d.ts +89 -0
- package/es/components/SelectItem/SelectItem.d.ts +62 -0
- package/es/components/SelectItem/SelectItem.js +2 -4
- package/es/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
- package/es/components/SkeletonText/SkeletonText.js +1 -1
- package/es/components/StructuredList/StructuredList.js +11 -39
- package/es/components/Tabs/Tabs.js +29 -6
- package/es/components/TextArea/TextArea.Skeleton.d.ts +33 -0
- package/es/components/TextArea/TextArea.Skeleton.js +5 -5
- package/es/components/TextArea/TextArea.d.ts +9 -2
- package/es/components/TextArea/TextArea.js +31 -8
- package/es/components/TextArea/index.js +1 -0
- package/es/components/TextInput/TextInput.Skeleton.d.ts +33 -0
- package/es/components/TextInput/index.js +1 -0
- package/es/components/Tile/Tile.js +15 -8
- package/es/components/Toggle/Toggle.js +8 -19
- package/es/components/Tooltip/DefinitionTooltip.d.ts +52 -0
- package/es/components/Tooltip/DefinitionTooltip.js +2 -2
- package/es/components/Tooltip/Tooltip.d.ts +117 -0
- package/es/components/Tooltip/Tooltip.js +6 -4
- package/es/components/Tooltip/index.d.ts +9 -0
- package/es/components/UIShell/HeaderMenu.js +13 -4
- package/es/components/UIShell/HeaderMenuItem.js +17 -4
- package/es/index.d.ts +2 -0
- package/es/index.js +5 -3
- package/es/internal/ClickListener.js +1 -2
- package/es/internal/keyboard/match.js +1 -1
- package/es/internal/useAttachedMenu.js +85 -0
- package/es/internal/useDelayedState.d.ts +19 -0
- package/es/internal/useDelayedState.js +7 -3
- package/es/internal/useId.js +1 -1
- package/es/tools/wrapComponent.js +9 -0
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +13 -115
- package/lib/components/ComboBox/ComboBox.d.ts +6 -0
- package/lib/components/ComboBox/ComboBox.js +18 -171
- package/lib/components/ComboButton/index.js +174 -0
- package/lib/components/ComposedModal/ComposedModal.js +1 -2
- package/lib/components/DataTable/Table.d.ts +74 -0
- package/lib/components/DataTable/Table.js +4 -2
- package/lib/components/DataTable/TableCell.d.ts +10 -0
- package/lib/components/DataTable/TableContext.d.ts +13 -0
- package/lib/components/DataTable/TableContext.js +2 -2
- package/lib/components/DataTable/TableExpandRow.d.ts +67 -0
- package/lib/components/DataTable/TableExpandedRow.d.ts +32 -0
- package/lib/components/DataTable/TableHead.d.ts +10 -0
- package/lib/components/DataTable/TableHeader.d.ts +64 -0
- package/lib/components/DataTable/TableHeader.js +23 -28
- package/lib/components/DataTable/TableRow.d.ts +32 -0
- package/lib/components/DataTable/TableSelectAll.js +1 -1
- package/lib/components/DataTable/TableSelectRow.js +1 -3
- package/lib/components/DataTable/TableToolbar.d.ts +19 -0
- package/lib/components/DataTable/TableToolbar.js +1 -1
- package/lib/components/DataTable/TableToolbarAction.d.ts +21 -0
- package/lib/components/DataTable/TableToolbarContent.d.ts +19 -0
- package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -3
- package/lib/components/DataTable/TableToolbarSearch.js +1 -0
- package/lib/components/DataTable/tools/sorting.js +2 -1
- package/lib/components/DataTableSkeleton/DataTableSkeleton.d.ts +107 -0
- package/lib/components/Dropdown/Dropdown.d.ts +6 -0
- package/lib/components/Dropdown/Dropdown.js +7 -144
- package/lib/components/ExpandableSearch/ExpandableSearch.js +1 -0
- package/lib/components/FileUploader/FileUploader.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -0
- package/lib/components/FileUploader/FileUploaderDropContainer.js +30 -18
- package/lib/components/FileUploader/FileUploaderItem.js +2 -1
- package/lib/components/FileUploader/Filename.js +8 -2
- package/lib/components/FluidTextArea/FluidTextArea.js +12 -1
- package/lib/components/IconButton/index.js +1 -0
- package/lib/components/InlineCheckbox/InlineCheckbox.js +7 -53
- package/lib/components/ListBox/ListBoxSelection.js +4 -23
- package/lib/components/ListBox/next/ListBoxSelection.js +2 -23
- package/lib/components/Menu/Menu.js +50 -29
- package/lib/components/Menu/MenuItem.js +1 -0
- package/lib/components/MenuButton/index.js +137 -0
- package/lib/components/Modal/Modal.js +4 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +43 -141
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +47 -27
- package/lib/components/Notification/Notification.js +27 -264
- package/lib/components/NumberInput/NumberInput.js +9 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +13 -139
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +58 -0
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +12 -7
- package/lib/components/OverflowMenuV2/index.js +13 -49
- package/lib/components/Popover/index.d.ts +5 -1
- package/lib/components/Popover/index.js +37 -9
- package/lib/components/RadioButton/RadioButton.Skeleton.d.ts +25 -0
- package/lib/components/RadioButton/RadioButton.Skeleton.js +3 -3
- package/lib/components/RadioButton/RadioButton.d.ts +64 -0
- package/lib/components/RadioButton/RadioButton.js +18 -16
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +80 -0
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +86 -24
- package/lib/components/RadioTile/RadioTile.js +6 -6
- package/lib/components/Search/Search.Skeleton.d.ts +36 -0
- package/lib/components/Search/Search.js +3 -2
- package/lib/components/Search/index.js +2 -0
- package/lib/components/Select/Select.d.ts +89 -0
- package/lib/components/SelectItem/SelectItem.d.ts +62 -0
- package/lib/components/SelectItem/SelectItem.js +1 -3
- package/lib/components/SelectItemGroup/SelectItemGroup.d.ts +52 -0
- package/lib/components/SkeletonText/SkeletonText.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +11 -39
- package/lib/components/Tabs/Tabs.js +29 -6
- package/lib/components/TextArea/TextArea.Skeleton.d.ts +33 -0
- package/lib/components/TextArea/TextArea.Skeleton.js +5 -5
- package/lib/components/TextArea/TextArea.d.ts +9 -2
- package/lib/components/TextArea/TextArea.js +30 -7
- package/lib/components/TextArea/index.js +2 -0
- package/lib/components/TextInput/TextInput.Skeleton.d.ts +33 -0
- package/lib/components/TextInput/index.js +2 -0
- package/lib/components/Tile/Tile.js +15 -8
- package/lib/components/Toggle/Toggle.js +8 -19
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +52 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
- package/lib/components/Tooltip/Tooltip.d.ts +117 -0
- package/lib/components/Tooltip/Tooltip.js +6 -4
- package/lib/components/Tooltip/index.d.ts +9 -0
- package/lib/components/UIShell/HeaderMenu.js +13 -4
- package/lib/components/UIShell/HeaderMenuItem.js +17 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +50 -46
- package/lib/internal/ClickListener.js +1 -2
- package/lib/internal/keyboard/match.js +1 -1
- package/lib/internal/useAttachedMenu.js +89 -0
- package/lib/internal/useDelayedState.d.ts +19 -0
- package/lib/internal/useDelayedState.js +7 -3
- package/lib/internal/useId.js +1 -1
- package/lib/tools/wrapComponent.js +9 -0
- package/package.json +3 -3
|
@@ -0,0 +1,117 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { PopoverAlignment } from '../Popover';
|
|
10
|
+
import { PolymorphicProps } from '../../types/common';
|
|
11
|
+
interface TooltipBaseProps {
|
|
12
|
+
/**
|
|
13
|
+
* Specify how the trigger should align with the tooltip
|
|
14
|
+
*/
|
|
15
|
+
align?: PopoverAlignment;
|
|
16
|
+
/**
|
|
17
|
+
* Pass in the child to which the tooltip will be applied
|
|
18
|
+
*/
|
|
19
|
+
children?: React.ReactElement;
|
|
20
|
+
/**
|
|
21
|
+
* Specify an optional className to be applied to the container node
|
|
22
|
+
*/
|
|
23
|
+
className?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
|
|
26
|
+
*/
|
|
27
|
+
closeOnActivation?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Specify whether the tooltip should be open when it first renders
|
|
30
|
+
*/
|
|
31
|
+
defaultOpen?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Provide the description to be rendered inside of the Tooltip. The
|
|
34
|
+
* description will use `aria-describedby` and will describe the child node
|
|
35
|
+
* in addition to the text rendered inside of the child. This means that if you
|
|
36
|
+
* have text in the child node, that it will be announced alongside the
|
|
37
|
+
* description to the screen reader.
|
|
38
|
+
*
|
|
39
|
+
* Note: if label and description are both provided, label will be used and
|
|
40
|
+
* description will not be used
|
|
41
|
+
*/
|
|
42
|
+
description?: React.ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Specify the duration in milliseconds to delay before displaying the tooltip
|
|
45
|
+
*/
|
|
46
|
+
enterDelayMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Provide the label to be rendered inside of the Tooltip. The label will use
|
|
49
|
+
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
50
|
+
* This means that if you have text in the child node, that it will not be
|
|
51
|
+
* announced to the screen reader.
|
|
52
|
+
*
|
|
53
|
+
* Note: if label and description are both provided, description will not be
|
|
54
|
+
* used
|
|
55
|
+
*/
|
|
56
|
+
label?: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Specify the duration in milliseconds to delay before hiding the tooltip
|
|
59
|
+
*/
|
|
60
|
+
leaveDelayMs?: number;
|
|
61
|
+
}
|
|
62
|
+
export type TooltipProps<T extends React.ElementType> = PolymorphicProps<T, TooltipBaseProps>;
|
|
63
|
+
declare function Tooltip<T extends React.ElementType>({ align, className: customClassName, children, label, description, enterDelayMs, leaveDelayMs, defaultOpen, closeOnActivation, ...rest }: TooltipProps<T>): JSX.Element;
|
|
64
|
+
declare namespace Tooltip {
|
|
65
|
+
var propTypes: {
|
|
66
|
+
/**
|
|
67
|
+
* Specify how the trigger should align with the tooltip
|
|
68
|
+
*/
|
|
69
|
+
align: PropTypes.Requireable<string>;
|
|
70
|
+
/**
|
|
71
|
+
* Pass in the child to which the tooltip will be applied
|
|
72
|
+
*/
|
|
73
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
74
|
+
/**
|
|
75
|
+
* Specify an optional className to be applied to the container node
|
|
76
|
+
*/
|
|
77
|
+
className: PropTypes.Requireable<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Determines wether the tooltip should close when inner content is activated (click, Enter or Space)
|
|
80
|
+
*/
|
|
81
|
+
closeOnActivation: PropTypes.Requireable<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Specify whether the tooltip should be open when it first renders
|
|
84
|
+
*/
|
|
85
|
+
defaultOpen: PropTypes.Requireable<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Provide the description to be rendered inside of the Tooltip. The
|
|
88
|
+
* description will use `aria-describedby` and will describe the child node
|
|
89
|
+
* in addition to the text rendered inside of the child. This means that if you
|
|
90
|
+
* have text in the child node, that it will be announced alongside the
|
|
91
|
+
* description to the screen reader.
|
|
92
|
+
*
|
|
93
|
+
* Note: if label and description are both provided, label will be used and
|
|
94
|
+
* description will not be used
|
|
95
|
+
*/
|
|
96
|
+
description: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
97
|
+
/**
|
|
98
|
+
* Specify the duration in milliseconds to delay before displaying the tooltip
|
|
99
|
+
*/
|
|
100
|
+
enterDelayMs: PropTypes.Requireable<number>;
|
|
101
|
+
/**
|
|
102
|
+
* Provide the label to be rendered inside of the Tooltip. The label will use
|
|
103
|
+
* `aria-labelledby` and will fully describe the child node that is provided.
|
|
104
|
+
* This means that if you have text in the child node, that it will not be
|
|
105
|
+
* announced to the screen reader.
|
|
106
|
+
*
|
|
107
|
+
* Note: if label and description are both provided, description will not be
|
|
108
|
+
* used
|
|
109
|
+
*/
|
|
110
|
+
label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
111
|
+
/**
|
|
112
|
+
* Specify the duration in milliseconds to delay before hiding the tooltip
|
|
113
|
+
*/
|
|
114
|
+
leaveDelayMs: PropTypes.Requireable<number>;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export { Tooltip };
|
|
@@ -103,10 +103,12 @@ function Tooltip(_ref) {
|
|
|
103
103
|
|
|
104
104
|
useNoInteractiveChildren(tooltipRef, 'The Tooltip component must have no interactive content rendered by the' + '`label` or `description` prop');
|
|
105
105
|
useEffect(function () {
|
|
106
|
-
|
|
106
|
+
if (containerRef !== null && containerRef.current) {
|
|
107
|
+
var interactiveContent = getInteractiveContent(containerRef.current);
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
if (!interactiveContent) {
|
|
110
|
+
setOpen(false);
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
});
|
|
112
114
|
return /*#__PURE__*/React__default.createElement(Popover, _extends({}, rest, {
|
|
@@ -118,7 +120,7 @@ function Tooltip(_ref) {
|
|
|
118
120
|
onMouseLeave: onMouseLeave,
|
|
119
121
|
open: open,
|
|
120
122
|
ref: containerRef
|
|
121
|
-
}), /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
123
|
+
}), child !== undefined ? /*#__PURE__*/React__default.cloneElement(child, _objectSpread2(_objectSpread2({}, triggerProps), getChildEventHandlers(child.props))) : null, /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
122
124
|
"aria-hidden": "true",
|
|
123
125
|
className: "".concat(prefix, "--tooltip-content"),
|
|
124
126
|
id: id,
|
|
@@ -0,0 +1,9 @@
|
|
|
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 { DefinitionTooltip } from './DefinitionTooltip';
|
|
8
|
+
import { Tooltip } from './Tooltip';
|
|
9
|
+
export { DefinitionTooltip, Tooltip };
|
|
@@ -12,10 +12,11 @@ import React__default from 'react';
|
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
14
14
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
15
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
15
16
|
import { matches } from '../../internal/keyboard/match.js';
|
|
16
17
|
import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
|
|
17
18
|
|
|
18
|
-
var _excluded = ["isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
|
|
19
|
+
var _excluded = ["isActive", "isCurrentPage", "aria-label", "aria-labelledby", "className", "children", "renderMenuContent", "menuLinkName", "focusRef"];
|
|
19
20
|
/**
|
|
20
21
|
* `HeaderMenu` is used to render submenu's in the `Header`. Most often children
|
|
21
22
|
* will be a `HeaderMenuItem`. It handles certain keyboard events to help
|
|
@@ -149,6 +150,7 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
149
150
|
var prefix = this.context;
|
|
150
151
|
|
|
151
152
|
var _this$props = this.props,
|
|
153
|
+
isActive = _this$props.isActive,
|
|
152
154
|
isCurrentPage = _this$props.isCurrentPage,
|
|
153
155
|
ariaLabel = _this$props['aria-label'],
|
|
154
156
|
ariaLabelledBy = _this$props['aria-labelledby'],
|
|
@@ -164,7 +166,8 @@ var HeaderMenu = /*#__PURE__*/function (_React$Component) {
|
|
|
164
166
|
'aria-labelledby': ariaLabelledBy
|
|
165
167
|
};
|
|
166
168
|
var itemClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__submenu"), true), _defineProperty(_cx, customClassName, !!customClassName), _cx));
|
|
167
|
-
var
|
|
169
|
+
var isActivePage = isActive ? isActive : isCurrentPage;
|
|
170
|
+
var linkClassName = cx((_cx2 = {}, _defineProperty(_cx2, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-title"), true), _defineProperty(_cx2, "".concat(prefix, "--header__menu-item--current"), isActivePage), _cx2)); // Notes on eslint comments and based on the examples in:
|
|
168
171
|
// https://www.w3.org/TR/wai-aria-practices/examples/menubar/menubar-1/menubar-1.html#
|
|
169
172
|
// - The focus is handled by the <a> menuitem, onMouseOver is for mouse
|
|
170
173
|
// users
|
|
@@ -218,9 +221,15 @@ _defineProperty(HeaderMenu, "propTypes", _objectSpread2(_objectSpread2({}, AriaL
|
|
|
218
221
|
focusRef: PropTypes.func,
|
|
219
222
|
|
|
220
223
|
/**
|
|
221
|
-
* Applies selected styles to the item if a user sets this to true and aria-current !== 'page'
|
|
224
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
222
225
|
*/
|
|
223
|
-
|
|
226
|
+
isActive: PropTypes.bool,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
230
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
231
|
+
*/
|
|
232
|
+
isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenu` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
|
|
224
233
|
|
|
225
234
|
/**
|
|
226
235
|
* Provide a label for the link text
|
|
@@ -11,12 +11,14 @@ import React__default from 'react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import Link, { LinkPropTypes } from './Link.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import deprecate from '../../prop-types/deprecate.js';
|
|
14
15
|
|
|
15
|
-
var _excluded = ["className", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
|
|
16
|
+
var _excluded = ["className", "isActive", "isCurrentPage", "aria-current", "children", "role", "tabIndex"];
|
|
16
17
|
var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuItem(_ref, ref) {
|
|
17
18
|
var _cx;
|
|
18
19
|
|
|
19
20
|
var className = _ref.className,
|
|
21
|
+
isActive = _ref.isActive,
|
|
20
22
|
isCurrentPage = _ref.isCurrentPage,
|
|
21
23
|
ariaCurrent = _ref['aria-current'],
|
|
22
24
|
children = _ref.children,
|
|
@@ -26,7 +28,12 @@ var HeaderMenuItem = /*#__PURE__*/React__default.forwardRef(function HeaderMenuI
|
|
|
26
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
29
|
|
|
28
30
|
var prefix = usePrefix();
|
|
29
|
-
|
|
31
|
+
|
|
32
|
+
if (isCurrentPage) {
|
|
33
|
+
isActive = isCurrentPage;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var linkClassName = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--header__menu-item"), true), _defineProperty(_cx, "".concat(prefix, "--header__menu-item--current"), isActive && ariaCurrent !== 'page'), _cx));
|
|
30
37
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
31
38
|
className: className,
|
|
32
39
|
role: role
|
|
@@ -53,9 +60,15 @@ HeaderMenuItem.propTypes = _objectSpread2(_objectSpread2({}, LinkPropTypes), {},
|
|
|
53
60
|
className: PropTypes.string,
|
|
54
61
|
|
|
55
62
|
/**
|
|
56
|
-
* Applies selected styles to the item if a user sets this to true and aria-current !== 'page'
|
|
63
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
64
|
+
*/
|
|
65
|
+
isActive: PropTypes.bool,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
69
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
57
70
|
*/
|
|
58
|
-
isCurrentPage: PropTypes.bool,
|
|
71
|
+
isCurrentPage: deprecate(PropTypes.bool, 'The `isCurrentPage` prop for `HeaderMenuItem` has ' + 'been deprecated. Please use `isActive` instead. This will be removed in the next major release.'),
|
|
59
72
|
|
|
60
73
|
/**
|
|
61
74
|
* Optionally supply a role for the underlying `<li>` node. Useful for resetting
|
package/es/index.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ export * from './components/Layer';
|
|
|
107
107
|
export { LayoutDirection as unstable_LayoutDirection, useLayoutDirection as unstable_useLayoutDirection, } from './components/Layout';
|
|
108
108
|
export { Menu as unstable_Menu, MenuItem as unstable_MenuItem, MenuItemDivider as unstable_MenuItemDivider, MenuItemGroup as unstable_MenuItemGroup, MenuItemRadioGroup as unstable_MenuItemRadioGroup, MenuItemSelectable as unstable_MenuItemSelectable, } from './components/Menu';
|
|
109
109
|
export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2';
|
|
110
|
+
export { ComboButton as unstable_ComboButton } from './components/ComboButton';
|
|
111
|
+
export { MenuButton as unstable_MenuButton } from './components/MenuButton';
|
|
110
112
|
export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
|
|
111
113
|
export * from './components/Popover';
|
|
112
114
|
export * from './components/ProgressBar';
|
package/es/index.js
CHANGED
|
@@ -37,10 +37,13 @@ export { Heading, Section } from './components/Heading/index.js';
|
|
|
37
37
|
export { IconButton } from './components/IconButton/index.js';
|
|
38
38
|
export { Layer, useLayer } from './components/Layer/index.js';
|
|
39
39
|
export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2/index.js';
|
|
40
|
+
export { ComboButton as unstable_ComboButton } from './components/ComboButton/index.js';
|
|
41
|
+
export { MenuButton as unstable_MenuButton } from './components/MenuButton/index.js';
|
|
40
42
|
export { Popover, PopoverContent } from './components/Popover/index.js';
|
|
41
43
|
export { HStack, VStack } from './components/Stack/index.js';
|
|
42
|
-
import './components/Text/index.js';
|
|
43
44
|
export { DefinitionTooltip } from './components/Tooltip/DefinitionTooltip.js';
|
|
45
|
+
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
46
|
+
import './components/Text/index.js';
|
|
44
47
|
export { GlobalTheme, Theme, ThemeContext, useTheme } from './components/Theme/index.js';
|
|
45
48
|
export { PrefixContext, usePrefix } from './internal/usePrefix.js';
|
|
46
49
|
export { useIdPrefix } from './internal/useIdPrefix.js';
|
|
@@ -76,7 +79,6 @@ export { default as NumberInputSkeleton } from './components/NumberInput/NumberI
|
|
|
76
79
|
export { default as ProgressIndicatorSkeleton } from './components/ProgressIndicator/ProgressIndicator.Skeleton.js';
|
|
77
80
|
export { default as ExpandableSearch } from './components/ExpandableSearch/ExpandableSearch.js';
|
|
78
81
|
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
79
|
-
export { default as RadioTile } from './components/RadioTile/RadioTile.js';
|
|
80
82
|
export { Toggle } from './components/Toggle/Toggle.js';
|
|
81
83
|
export { default as TreeNode } from './components/TreeView/TreeNode.js';
|
|
82
84
|
export { default as TreeView } from './components/TreeView/TreeView.js';
|
|
@@ -185,6 +187,7 @@ export { default as TextArea } from './components/TextArea/TextArea.js';
|
|
|
185
187
|
export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
|
|
186
188
|
export { default as TextInput } from './components/TextInput/TextInput.js';
|
|
187
189
|
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent } from './components/Tile/Tile.js';
|
|
190
|
+
export { default as RadioTile } from './components/RadioTile/RadioTile.js';
|
|
188
191
|
export { default as TimePicker } from './components/TimePicker/TimePicker.js';
|
|
189
192
|
export { default as UnorderedList } from './components/UnorderedList/UnorderedList.js';
|
|
190
193
|
export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
|
|
@@ -212,4 +215,3 @@ export { default as SideNavMenu } from './components/UIShell/SideNavMenu.js';
|
|
|
212
215
|
export { default as SideNavMenuItem } from './components/UIShell/SideNavMenuItem.js';
|
|
213
216
|
export { default as SideNavSwitcher } from './components/UIShell/SideNavSwitcher.js';
|
|
214
217
|
export { Stack } from './components/Stack/Stack.js';
|
|
215
|
-
export { Tooltip } from './components/Tooltip/Tooltip.js';
|
|
@@ -25,8 +25,7 @@ var ClickListener = /*#__PURE__*/function (_React$Component) {
|
|
|
25
25
|
_classCallCheck(this, ClickListener);
|
|
26
26
|
|
|
27
27
|
_this = _super.call(this, props); // We manually bind handlers in this Component, versus using class
|
|
28
|
-
// properties, so that we can properly test the `handleRef` handler
|
|
29
|
-
// enzyme.
|
|
28
|
+
// properties, so that we can properly test the `handleRef` handler.
|
|
30
29
|
|
|
31
30
|
_this.handleRef = _this.handleRef.bind(_assertThisInitialized(_this));
|
|
32
31
|
_this.handleDocumentClick = _this.handleDocumentClick.bind(_assertThisInitialized(_this));
|
|
@@ -0,0 +1,85 @@
|
|
|
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 { slicedToArray as _slicedToArray } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {object} useAttachedMenuReturn
|
|
13
|
+
* @property {boolean} open Whether the menu is open or not
|
|
14
|
+
* @property {[number, number]} x The x position of the menu
|
|
15
|
+
* @property {[number, number]} y The y position of the menu
|
|
16
|
+
* @property {Function} handleClick A function to be called when the trigger element receives a click event
|
|
17
|
+
* @property {Function} handleMousedown A function to be called when the trigger element recives a mousedown event
|
|
18
|
+
* @property {Function} handleClose A function to be called when the menu emits onClose
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This hook contains common code to be used when a menu should be visually attached to an anchor based on a click event.
|
|
23
|
+
*
|
|
24
|
+
* @param {Element|object} anchor The element or ref the menu should visually be attached to.
|
|
25
|
+
* @returns {useAttachedMenuReturn}
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
function useAttachedMenu(anchor) {
|
|
29
|
+
var _useState = useState(false),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
open = _useState2[0],
|
|
32
|
+
setOpen = _useState2[1];
|
|
33
|
+
|
|
34
|
+
var _useState3 = useState([[-1, -1], [-1, -1]]),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
position = _useState4[0],
|
|
37
|
+
setPosition = _useState4[1];
|
|
38
|
+
|
|
39
|
+
function openMenu() {
|
|
40
|
+
var anchorEl = (anchor === null || anchor === void 0 ? void 0 : anchor.current) || anchor;
|
|
41
|
+
|
|
42
|
+
if (anchorEl) {
|
|
43
|
+
var _anchorEl$getBounding = anchorEl.getBoundingClientRect(),
|
|
44
|
+
left = _anchorEl$getBounding.left,
|
|
45
|
+
top = _anchorEl$getBounding.top,
|
|
46
|
+
right = _anchorEl$getBounding.right,
|
|
47
|
+
bottom = _anchorEl$getBounding.bottom;
|
|
48
|
+
|
|
49
|
+
setPosition([[left, right], [top, bottom]]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setOpen(true);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function closeMenu() {
|
|
56
|
+
setOpen(false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function handleClick() {
|
|
60
|
+
if (open) {
|
|
61
|
+
closeMenu();
|
|
62
|
+
} else {
|
|
63
|
+
openMenu();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function handleMousedown(e) {
|
|
68
|
+
// prevent default for mousedown on trigger element to avoid
|
|
69
|
+
// the "blur" event from firing on the menu as this would close
|
|
70
|
+
// it and immediately re-open since "click" event is fired after
|
|
71
|
+
// "blur" event.
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
open: open,
|
|
77
|
+
x: position[0],
|
|
78
|
+
y: position[1],
|
|
79
|
+
handleClick: handleClick,
|
|
80
|
+
handleMousedown: handleMousedown,
|
|
81
|
+
handleClose: closeMenu
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { useAttachedMenu };
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { SetStateAction } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* `useDelayedState` mirrors `useState` but also allows you to add a delay to
|
|
10
|
+
* when your state updates. You can provide a second argument to `setState`,
|
|
11
|
+
* `delayMs`, which will be the time in milliseconds after which the state is
|
|
12
|
+
* updated.
|
|
13
|
+
*
|
|
14
|
+
* This hook will clean up pending timers in `useEffect` and will cancel any
|
|
15
|
+
* pending timers when a `setState` is called before the state is updated from
|
|
16
|
+
* a previous call
|
|
17
|
+
*/
|
|
18
|
+
export type DispatchWithDelay<A> = (value: A, delayMS?: number) => void;
|
|
19
|
+
export declare function useDelayedState<S>(initialState: S): [S, DispatchWithDelay<SetStateAction<S>>];
|
|
@@ -29,8 +29,10 @@ function useDelayedState(initialState) {
|
|
|
29
29
|
// always return the same reference for the `setState` updater
|
|
30
30
|
|
|
31
31
|
var setStateWithDelay = useCallback(function (stateToSet) {
|
|
32
|
+
var _timeoutId$current;
|
|
33
|
+
|
|
32
34
|
var delayMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
33
|
-
clearTimeout(timeoutId.current);
|
|
35
|
+
window.clearTimeout((_timeoutId$current = timeoutId.current) !== null && _timeoutId$current !== void 0 ? _timeoutId$current : undefined);
|
|
34
36
|
timeoutId.current = null;
|
|
35
37
|
|
|
36
38
|
if (delayMs === 0) {
|
|
@@ -38,14 +40,16 @@ function useDelayedState(initialState) {
|
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
timeoutId.current = setTimeout(function () {
|
|
43
|
+
timeoutId.current = window.setTimeout(function () {
|
|
42
44
|
setState(stateToSet);
|
|
43
45
|
timeoutId.current = null;
|
|
44
46
|
}, delayMs);
|
|
45
47
|
}, []);
|
|
46
48
|
useEffect(function () {
|
|
47
49
|
return function () {
|
|
48
|
-
|
|
50
|
+
var _timeoutId$current2;
|
|
51
|
+
|
|
52
|
+
window.clearTimeout((_timeoutId$current2 = timeoutId.current) !== null && _timeoutId$current2 !== void 0 ? _timeoutId$current2 : undefined);
|
|
49
53
|
};
|
|
50
54
|
}, []);
|
|
51
55
|
return [state, setStateWithDelay];
|
package/es/internal/useId.js
CHANGED
|
@@ -12,12 +12,21 @@ import cx from 'classnames';
|
|
|
12
12
|
import { usePrefix } from '../internal/usePrefix.js';
|
|
13
13
|
|
|
14
14
|
var _excluded = ["className"];
|
|
15
|
+
/**
|
|
16
|
+
* @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
15
19
|
|
|
16
20
|
var wrapComponent = function wrapComponent(_ref) {
|
|
17
21
|
var name = _ref.name,
|
|
18
22
|
getClassName = _ref.className,
|
|
19
23
|
type = _ref.type;
|
|
20
24
|
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {{ className?: string, [x: string]: any}} param0
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
21
30
|
function Component(_ref2) {
|
|
22
31
|
var baseClassName = _ref2.className,
|
|
23
32
|
other = _objectWithoutProperties(_ref2, _excluded);
|
|
@@ -27,7 +27,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
27
27
|
|
|
28
28
|
var _excluded = ["as", "children", "className", "dangerDescription", "disabled", "hasIconOnly", "href", "iconDescription", "isExpressive", "isSelected", "kind", "onBlur", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "renderIcon", "size", "tabIndex", "tooltipAlignment", "tooltipPosition", "type"];
|
|
29
29
|
var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
|
|
30
|
-
var _classNames;
|
|
30
|
+
var _classNames, _rest$ariaPressed;
|
|
31
31
|
|
|
32
32
|
var as = _ref.as,
|
|
33
33
|
children = _ref.children,
|
|
@@ -92,7 +92,7 @@ var Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_
|
|
|
92
92
|
disabled: disabled,
|
|
93
93
|
type: type,
|
|
94
94
|
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : null,
|
|
95
|
-
'aria-pressed': hasIconOnly && kind === 'ghost' ? isSelected : null
|
|
95
|
+
'aria-pressed': (_rest$ariaPressed = rest['aria-pressed']) !== null && _rest$ariaPressed !== void 0 ? _rest$ariaPressed : hasIconOnly && kind === 'ghost' ? isSelected : null
|
|
96
96
|
};
|
|
97
97
|
var anchorProps = {
|
|
98
98
|
href: href
|