@carbon/react 1.32.0 → 1.33.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/README.md +22 -7
- package/es/components/ComboBox/ComboBox.js +43 -10
- package/es/components/ContentSwitcher/ContentSwitcher.js +5 -5
- package/es/components/DataTable/DataTable.js +110 -130
- package/es/components/DataTable/Table.js +1 -1
- package/es/components/DatePicker/DatePicker.d.ts +14 -13
- package/es/components/DatePicker/DatePicker.js +3 -0
- package/es/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/es/components/Dropdown/Dropdown.js +31 -6
- package/es/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
- package/es/components/FileUploader/FileUploader.d.ts +175 -0
- package/es/components/FileUploader/FileUploader.js +3 -3
- package/es/components/FileUploader/FileUploaderButton.d.ts +140 -0
- package/es/components/FileUploader/FileUploaderButton.js +11 -7
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
- package/es/components/FileUploader/FileUploaderDropContainer.js +3 -3
- package/es/components/FileUploader/FileUploaderItem.d.ts +110 -0
- package/es/components/FileUploader/Filename.d.ts +71 -0
- package/es/components/FileUploader/Filename.js +6 -4
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -1
- package/es/components/Loading/Loading.d.ts +65 -0
- package/es/components/Notification/Notification.d.ts +4 -4
- package/es/components/Notification/Notification.js +3 -3
- package/es/components/OverflowMenu/OverflowMenu.js +36 -41
- package/es/components/Slider/Slider.js +59 -68
- package/es/components/Toggle/Toggle.d.ts +129 -0
- package/es/components/Toggle/Toggle.js +2 -2
- package/es/components/Toggle/index.d.ts +11 -0
- package/es/components/UIShell/HeaderMenu.js +29 -36
- package/es/components/UIShell/HeaderName.d.ts +39 -0
- package/es/components/UIShell/HeaderName.js +2 -7
- package/es/components/UIShell/HeaderPanel.js +1 -1
- package/es/components/UIShell/Link.js +2 -1
- package/es/index.js +1 -1
- package/es/internal/FloatingMenu.js +47 -51
- package/es/internal/useControllableState.js +1 -1
- package/es/internal/useId.js +10 -1
- package/lib/components/ComboBox/ComboBox.js +43 -10
- package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -5
- package/lib/components/DataTable/DataTable.js +110 -130
- package/lib/components/DataTable/Table.js +1 -1
- package/lib/components/DatePicker/DatePicker.d.ts +14 -13
- package/lib/components/DatePicker/DatePicker.js +3 -0
- package/lib/components/DatePickerInput/DatePickerInput.d.ts +2 -2
- package/lib/components/Dropdown/Dropdown.js +30 -5
- package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +29 -0
- package/lib/components/FileUploader/FileUploader.d.ts +175 -0
- package/lib/components/FileUploader/FileUploader.js +3 -3
- package/lib/components/FileUploader/FileUploaderButton.d.ts +140 -0
- package/lib/components/FileUploader/FileUploaderButton.js +11 -7
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +139 -0
- package/lib/components/FileUploader/FileUploaderDropContainer.js +3 -3
- package/lib/components/FileUploader/FileUploaderItem.d.ts +110 -0
- package/lib/components/FileUploader/Filename.d.ts +71 -0
- package/lib/components/FileUploader/Filename.js +6 -4
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -1
- package/lib/components/Loading/Loading.d.ts +65 -0
- package/lib/components/Notification/Notification.d.ts +4 -4
- package/lib/components/Notification/Notification.js +3 -3
- package/lib/components/OverflowMenu/OverflowMenu.js +36 -41
- package/lib/components/Slider/Slider.js +59 -68
- package/lib/components/Toggle/Toggle.d.ts +129 -0
- package/lib/components/Toggle/Toggle.js +2 -2
- package/lib/components/Toggle/index.d.ts +11 -0
- package/lib/components/UIShell/HeaderMenu.js +29 -36
- package/lib/components/UIShell/HeaderName.d.ts +39 -0
- package/lib/components/UIShell/HeaderName.js +2 -7
- package/lib/components/UIShell/HeaderPanel.js +1 -1
- package/lib/components/UIShell/Link.js +2 -1
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.js +47 -51
- package/lib/internal/useControllableState.js +1 -1
- package/lib/internal/useId.js +9 -0
- package/package.json +22 -19
|
@@ -88,7 +88,7 @@ function Toggle(_ref) {
|
|
|
88
88
|
handleClick(e);
|
|
89
89
|
buttonElement.current.focus();
|
|
90
90
|
}
|
|
91
|
-
} :
|
|
91
|
+
} : undefined
|
|
92
92
|
}, /*#__PURE__*/React__default["default"].createElement("button", _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
93
93
|
ref: buttonElement,
|
|
94
94
|
id: id,
|
|
@@ -100,7 +100,7 @@ function Toggle(_ref) {
|
|
|
100
100
|
disabled: disabled,
|
|
101
101
|
onClick: handleClick
|
|
102
102
|
})), /*#__PURE__*/React__default["default"].createElement(LabelComponent, {
|
|
103
|
-
htmlFor: ariaLabelledby ?
|
|
103
|
+
htmlFor: ariaLabelledby ? undefined : id,
|
|
104
104
|
className: `${prefix}--toggle__label`
|
|
105
105
|
}, labelText && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
106
106
|
className: labelTextClasses
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { default as Toggle, ToggleProps } from './Toggle';
|
|
8
|
+
export * from './Toggle.Skeleton';
|
|
9
|
+
export default Toggle;
|
|
10
|
+
export { Toggle };
|
|
11
|
+
export type { ToggleProps };
|
|
@@ -36,6 +36,9 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
36
36
|
constructor(props) {
|
|
37
37
|
super(props);
|
|
38
38
|
_rollupPluginBabelHelpers.defineProperty(this, "_subMenus", /*#__PURE__*/React__default["default"].createRef());
|
|
39
|
+
/**
|
|
40
|
+
* Toggle the expanded state of the menu on click.
|
|
41
|
+
*/
|
|
39
42
|
_rollupPluginBabelHelpers.defineProperty(this, "handleOnClick", e => {
|
|
40
43
|
const {
|
|
41
44
|
current: subMenusNode
|
|
@@ -47,6 +50,9 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
47
50
|
expanded: !prevState.expanded
|
|
48
51
|
}));
|
|
49
52
|
});
|
|
53
|
+
/**
|
|
54
|
+
* Keyboard event handler for the entire menu.
|
|
55
|
+
*/
|
|
50
56
|
_rollupPluginBabelHelpers.defineProperty(this, "handleOnKeyDown", event => {
|
|
51
57
|
// Handle enter or space key for toggling the expanded state of the menu.
|
|
52
58
|
if (match.matches(event, [keys.Enter, keys.Space])) {
|
|
@@ -58,6 +64,11 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
58
64
|
return;
|
|
59
65
|
}
|
|
60
66
|
});
|
|
67
|
+
/**
|
|
68
|
+
* Handle our blur event from our underlying menuitems. Will mostly be used
|
|
69
|
+
* for toggling the expansion status of our menu in response to a user
|
|
70
|
+
* clicking off of the menu or menubar.
|
|
71
|
+
*/
|
|
61
72
|
_rollupPluginBabelHelpers.defineProperty(this, "handleOnBlur", event => {
|
|
62
73
|
// Rough guess for a blur event that is triggered outside of our menu or
|
|
63
74
|
// menubar context
|
|
@@ -70,12 +81,24 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
70
81
|
selectedIndex: null
|
|
71
82
|
});
|
|
72
83
|
});
|
|
84
|
+
/**
|
|
85
|
+
* ref handler for our menu button. If we are supplied a `focusRef` prop, we also
|
|
86
|
+
* forward along the node.
|
|
87
|
+
*
|
|
88
|
+
* This is useful when this component is a child in a
|
|
89
|
+
* menu or menubar as it will allow the parent to explicitly focus the menu
|
|
90
|
+
* button node when that child should receive focus.
|
|
91
|
+
*/
|
|
73
92
|
_rollupPluginBabelHelpers.defineProperty(this, "handleMenuButtonRef", node => {
|
|
74
93
|
if (this.props.focusRef) {
|
|
75
94
|
this.props.focusRef(node);
|
|
76
95
|
}
|
|
77
96
|
this.menuButtonRef = node;
|
|
78
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* Handles individual menuitem refs. We assign them to a class instance
|
|
100
|
+
* property so that we can properly manage focus of our children.
|
|
101
|
+
*/
|
|
79
102
|
_rollupPluginBabelHelpers.defineProperty(this, "handleItemRef", index => node => {
|
|
80
103
|
this.items[index] = node;
|
|
81
104
|
});
|
|
@@ -94,6 +117,12 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
94
117
|
return;
|
|
95
118
|
}
|
|
96
119
|
});
|
|
120
|
+
/**
|
|
121
|
+
* We capture the `ref` for each child inside of `this.items` to properly
|
|
122
|
+
* manage focus. In addition to this focus management, all items receive a
|
|
123
|
+
* `tabIndex: -1` so the user won't hit a large number of items in their tab
|
|
124
|
+
* sequence when they might not want to go through all the items.
|
|
125
|
+
*/
|
|
97
126
|
_rollupPluginBabelHelpers.defineProperty(this, "_renderMenuItem", (item, index) => {
|
|
98
127
|
if ( /*#__PURE__*/React__default["default"].isValidElement(item)) {
|
|
99
128
|
return /*#__PURE__*/React__default["default"].cloneElement(item, {
|
|
@@ -110,35 +139,6 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
110
139
|
};
|
|
111
140
|
this.items = [];
|
|
112
141
|
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Toggle the expanded state of the menu on click.
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Keyboard event handler for the entire menu.
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Handle our blur event from our underlying menuitems. Will mostly be used
|
|
124
|
-
* for toggling the expansion status of our menu in response to a user
|
|
125
|
-
* clicking off of the menu or menubar.
|
|
126
|
-
*/
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* ref handler for our menu button. If we are supplied a `focusRef` prop, we also
|
|
130
|
-
* forward along the node.
|
|
131
|
-
*
|
|
132
|
-
* This is useful when this component is a child in a
|
|
133
|
-
* menu or menubar as it will allow the parent to explicitly focus the menu
|
|
134
|
-
* button node when that child should receive focus.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Handles individual menuitem refs. We assign them to a class instance
|
|
139
|
-
* property so that we can properly manage focus of our children.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
142
|
render() {
|
|
143
143
|
const prefix = this.context;
|
|
144
144
|
const {
|
|
@@ -201,13 +201,6 @@ class HeaderMenu extends React__default["default"].Component {
|
|
|
201
201
|
className: `${prefix}--header__menu`
|
|
202
202
|
}), React__default["default"].Children.map(children, this._renderMenuItem)));
|
|
203
203
|
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* We capture the `ref` for each child inside of `this.items` to properly
|
|
207
|
-
* manage focus. In addition to this focus management, all items receive a
|
|
208
|
-
* `tabIndex: -1` so the user won't hit a large number of items in their tab
|
|
209
|
-
* sequence when they might not want to go through all the items.
|
|
210
|
-
*/
|
|
211
204
|
}
|
|
212
205
|
_rollupPluginBabelHelpers.defineProperty(HeaderMenu, "propTypes", {
|
|
213
206
|
/**
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { type ElementType } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { type LinkProps } from './Link';
|
|
10
|
+
type HeaderNameProps<E extends ElementType> = LinkProps<E> & {
|
|
11
|
+
prefix?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
declare function HeaderName<E extends ElementType = 'a'>({ children, className: customClassName, prefix, ...rest }: HeaderNameProps<E>): JSX.Element;
|
|
14
|
+
declare namespace HeaderName {
|
|
15
|
+
var propTypes: {
|
|
16
|
+
/**
|
|
17
|
+
* Pass in children that are either a string or can be read as a string by
|
|
18
|
+
* screen readers
|
|
19
|
+
*/
|
|
20
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
21
|
+
/**
|
|
22
|
+
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
23
|
+
*/
|
|
24
|
+
className: PropTypes.Requireable<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Provide an href for the name to link to
|
|
27
|
+
*/
|
|
28
|
+
href: PropTypes.Requireable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Optionally specify a prefix to your header name. Useful for companies, for
|
|
31
|
+
* example: IBM [Product Name] versus solely [Product Name]
|
|
32
|
+
*/
|
|
33
|
+
prefix: PropTypes.Requireable<string>;
|
|
34
|
+
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
35
|
+
element: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
36
|
+
isSideNavExpanded: PropTypes.Requireable<boolean>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export default HeaderName;
|
|
@@ -26,15 +26,13 @@ function HeaderName(_ref) {
|
|
|
26
26
|
let {
|
|
27
27
|
children,
|
|
28
28
|
className: customClassName,
|
|
29
|
-
prefix,
|
|
30
|
-
href,
|
|
29
|
+
prefix = 'IBM',
|
|
31
30
|
...rest
|
|
32
31
|
} = _ref;
|
|
33
32
|
const selectorPrefix = usePrefix.usePrefix();
|
|
34
33
|
const className = cx__default["default"](`${selectorPrefix}--header__name`, customClassName);
|
|
35
34
|
return /*#__PURE__*/React__default["default"].createElement(Link["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
36
|
-
className: className
|
|
37
|
-
href: href
|
|
35
|
+
className: className
|
|
38
36
|
}), prefix && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
39
37
|
className: `${selectorPrefix}--header__name--prefix`
|
|
40
38
|
}, prefix), "\xA0"), children);
|
|
@@ -64,8 +62,5 @@ HeaderName.propTypes = {
|
|
|
64
62
|
*/
|
|
65
63
|
prefix: PropTypes__default["default"].string
|
|
66
64
|
};
|
|
67
|
-
HeaderName.defaultProps = {
|
|
68
|
-
prefix: 'IBM'
|
|
69
|
-
};
|
|
70
65
|
|
|
71
66
|
exports["default"] = HeaderName;
|
|
@@ -70,7 +70,7 @@ const HeaderPanel = /*#__PURE__*/React__default["default"].forwardRef(function H
|
|
|
70
70
|
useEvent.useWindowEvent('click', () => {
|
|
71
71
|
const focusedElement = document.activeElement;
|
|
72
72
|
setLastClickedElement(focusedElement);
|
|
73
|
-
if (children.type
|
|
73
|
+
if (children.type?.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelRef?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
74
74
|
setExpandedState(false);
|
|
75
75
|
onHeaderPanelFocus();
|
|
76
76
|
}
|
package/lib/index.js
CHANGED
|
@@ -63,6 +63,7 @@ var TextArea_Skeleton = require('./components/TextArea/TextArea.Skeleton.js');
|
|
|
63
63
|
require('./components/TextInput/index.js');
|
|
64
64
|
var Tile = require('./components/Tile/Tile.js');
|
|
65
65
|
var index$a = require('./components/TileGroup/index.js');
|
|
66
|
+
var Toggle = require('./components/Toggle/Toggle.js');
|
|
66
67
|
var Toggle_Skeleton = require('./components/Toggle/Toggle.Skeleton.js');
|
|
67
68
|
var ToggleSmall_Skeleton = require('./components/ToggleSmall/ToggleSmall.Skeleton.js');
|
|
68
69
|
var index$b = require('./components/Toggletip/index.js');
|
|
@@ -114,7 +115,6 @@ var NumberInput_Skeleton = require('./components/NumberInput/NumberInput.Skeleto
|
|
|
114
115
|
var ProgressIndicator_Skeleton = require('./components/ProgressIndicator/ProgressIndicator.Skeleton.js');
|
|
115
116
|
var TextInput_Skeleton = require('./components/TextInput/TextInput.Skeleton.js');
|
|
116
117
|
var TextInput = require('./components/TextInput/TextInput.js');
|
|
117
|
-
var Toggle = require('./components/Toggle/Toggle.js');
|
|
118
118
|
var TreeNode = require('./components/TreeView/TreeNode.js');
|
|
119
119
|
var TreeView = require('./components/TreeView/TreeView.js');
|
|
120
120
|
var HeaderContainer = require('./components/UIShell/HeaderContainer.js');
|
|
@@ -296,6 +296,7 @@ exports.Tile = Tile.Tile;
|
|
|
296
296
|
exports.TileAboveTheFoldContent = Tile.TileAboveTheFoldContent;
|
|
297
297
|
exports.TileBelowTheFoldContent = Tile.TileBelowTheFoldContent;
|
|
298
298
|
exports.TileGroup = index$a["default"];
|
|
299
|
+
exports.Toggle = Toggle.Toggle;
|
|
299
300
|
exports.ToggleSkeleton = Toggle_Skeleton["default"];
|
|
300
301
|
exports.ToggleSmallSkeleton = ToggleSmall_Skeleton["default"];
|
|
301
302
|
exports.Toggletip = index$b.Toggletip;
|
|
@@ -360,7 +361,6 @@ exports.NumberInputSkeleton = NumberInput_Skeleton["default"];
|
|
|
360
361
|
exports.ProgressIndicatorSkeleton = ProgressIndicator_Skeleton["default"];
|
|
361
362
|
exports.TextInputSkeleton = TextInput_Skeleton["default"];
|
|
362
363
|
exports.TextInput = TextInput["default"];
|
|
363
|
-
exports.Toggle = Toggle.Toggle;
|
|
364
364
|
exports.TreeNode = TreeNode["default"];
|
|
365
365
|
exports.TreeView = TreeView["default"];
|
|
366
366
|
exports.HeaderContainer = HeaderContainer["default"];
|
|
@@ -153,6 +153,7 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
153
153
|
var _this;
|
|
154
154
|
super(...arguments);
|
|
155
155
|
_this = this;
|
|
156
|
+
// `true` if the menu body is mounted and calculation of the position is in progress.
|
|
156
157
|
_rollupPluginBabelHelpers.defineProperty(this, "_placeInProgress", false);
|
|
157
158
|
_rollupPluginBabelHelpers.defineProperty(this, "state", {
|
|
158
159
|
/**
|
|
@@ -161,10 +162,36 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
161
162
|
*/
|
|
162
163
|
floatingPosition: undefined
|
|
163
164
|
});
|
|
165
|
+
/**
|
|
166
|
+
* The cached reference to the menu container.
|
|
167
|
+
* Only used if React portal API is not available.
|
|
168
|
+
* @type {Element}
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
164
171
|
_rollupPluginBabelHelpers.defineProperty(this, "_menuContainer", null);
|
|
172
|
+
/**
|
|
173
|
+
* The cached reference to the menu body.
|
|
174
|
+
* The reference is set via callback ref instead of object ref,
|
|
175
|
+
* in order to hook the event when the element ref gets available,
|
|
176
|
+
* which can be at a different timing from `cDM()`, presumably with SSR scenario.
|
|
177
|
+
* @type {Element}
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
165
180
|
_rollupPluginBabelHelpers.defineProperty(this, "_menuBody", null);
|
|
181
|
+
/**
|
|
182
|
+
* Focus sentinel refs for focus trap behavior
|
|
183
|
+
*/
|
|
166
184
|
_rollupPluginBabelHelpers.defineProperty(this, "startSentinel", /*#__PURE__*/React__default["default"].createRef());
|
|
167
185
|
_rollupPluginBabelHelpers.defineProperty(this, "endSentinel", /*#__PURE__*/React__default["default"].createRef());
|
|
186
|
+
/**
|
|
187
|
+
* Calculates the position in the viewport of floating menu,
|
|
188
|
+
* once this component is mounted or updated upon change in the following props:
|
|
189
|
+
*
|
|
190
|
+
* * `menuOffset` (The adjustment that should be applied to the calculated floating menu's position)
|
|
191
|
+
* * `menuDirection` (Where the floating menu menu should be placed relative to the trigger button)
|
|
192
|
+
*
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
168
195
|
_rollupPluginBabelHelpers.defineProperty(this, "_updateMenuSize", function () {
|
|
169
196
|
let prevProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
170
197
|
let isAdjustment = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -238,6 +265,11 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
238
265
|
}
|
|
239
266
|
}
|
|
240
267
|
});
|
|
268
|
+
/**
|
|
269
|
+
* Set focus on floating menu content after menu placement.
|
|
270
|
+
* @param {Element} menuBody The DOM element of the menu body.
|
|
271
|
+
* @private
|
|
272
|
+
*/
|
|
241
273
|
_rollupPluginBabelHelpers.defineProperty(this, "_focusMenuContent", menuBody => {
|
|
242
274
|
const primaryFocusNode = menuBody.querySelector(this.props.selectorPrimaryFocus || null);
|
|
243
275
|
const tabbableNode = menuBody.querySelector(navigation.selectorTabbable);
|
|
@@ -254,6 +286,10 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
254
286
|
process.env.NODE_ENV !== "production" ? warning.warning(focusableNode === null, 'Floating Menus must have at least a programmatically focusable child. ' + 'This can be accomplished by adding tabIndex="-1" to the content element.') : void 0;
|
|
255
287
|
}
|
|
256
288
|
});
|
|
289
|
+
/**
|
|
290
|
+
* A callback for called when menu body is mounted or unmounted.
|
|
291
|
+
* @param {Element} menuBody The menu body being mounted. `null` if the menu body is being unmounted.
|
|
292
|
+
*/
|
|
257
293
|
_rollupPluginBabelHelpers.defineProperty(this, "_menuRef", menuBody => {
|
|
258
294
|
const {
|
|
259
295
|
menuRef
|
|
@@ -264,6 +300,10 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
264
300
|
this._updateMenuSize();
|
|
265
301
|
}
|
|
266
302
|
});
|
|
303
|
+
/**
|
|
304
|
+
* @returns The child nodes, with styles containing the floating menu position.
|
|
305
|
+
* @private
|
|
306
|
+
*/
|
|
267
307
|
_rollupPluginBabelHelpers.defineProperty(this, "_getChildrenWithProps", () => {
|
|
268
308
|
const {
|
|
269
309
|
styles,
|
|
@@ -292,6 +332,12 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
292
332
|
}
|
|
293
333
|
});
|
|
294
334
|
});
|
|
335
|
+
/**
|
|
336
|
+
* Blur handler for when focus wrap behavior is enabled
|
|
337
|
+
* @param {Event} event
|
|
338
|
+
* @param {Element} event.target previously focused node
|
|
339
|
+
* @param {Element} event.relatedTarget current focused node
|
|
340
|
+
*/
|
|
295
341
|
_rollupPluginBabelHelpers.defineProperty(this, "handleBlur", _ref2 => {
|
|
296
342
|
let {
|
|
297
343
|
target: oldActiveNode,
|
|
@@ -313,33 +359,7 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
313
359
|
});
|
|
314
360
|
}
|
|
315
361
|
});
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* The cached reference to the menu container.
|
|
319
|
-
* Only used if React portal API is not available.
|
|
320
|
-
* @type {Element}
|
|
321
|
-
* @private
|
|
322
|
-
*/
|
|
323
|
-
/**
|
|
324
|
-
* The cached reference to the menu body.
|
|
325
|
-
* The reference is set via callback ref instead of object ref,
|
|
326
|
-
* in order to hook the event when the element ref gets available,
|
|
327
|
-
* which can be at a different timing from `cDM()`, presumably with SSR scenario.
|
|
328
|
-
* @type {Element}
|
|
329
|
-
* @private
|
|
330
|
-
*/
|
|
331
|
-
/**
|
|
332
|
-
* Focus sentinel refs for focus trap behavior
|
|
333
|
-
*/
|
|
334
|
-
/**
|
|
335
|
-
* Calculates the position in the viewport of floating menu,
|
|
336
|
-
* once this component is mounted or updated upon change in the following props:
|
|
337
|
-
*
|
|
338
|
-
* * `menuOffset` (The adjustment that should be applied to the calculated floating menu's position)
|
|
339
|
-
* * `menuDirection` (Where the floating menu menu should be placed relative to the trigger button)
|
|
340
|
-
*
|
|
341
|
-
* @private
|
|
342
|
-
*/
|
|
362
|
+
}
|
|
343
363
|
componentWillUnmount() {
|
|
344
364
|
this.hResize.release();
|
|
345
365
|
}
|
|
@@ -348,12 +368,6 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
348
368
|
this._updateMenuSize();
|
|
349
369
|
});
|
|
350
370
|
}
|
|
351
|
-
/**
|
|
352
|
-
* Set focus on floating menu content after menu placement.
|
|
353
|
-
* @param {Element} menuBody The DOM element of the menu body.
|
|
354
|
-
* @private
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
371
|
componentDidUpdate(prevProps) {
|
|
358
372
|
this._updateMenuSize(prevProps);
|
|
359
373
|
const {
|
|
@@ -369,24 +383,6 @@ class FloatingMenu extends React__default["default"].Component {
|
|
|
369
383
|
}
|
|
370
384
|
}
|
|
371
385
|
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* A callback for called when menu body is mounted or unmounted.
|
|
375
|
-
* @param {Element} menuBody The menu body being mounted. `null` if the menu body is being unmounted.
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @returns The child nodes, with styles containing the floating menu position.
|
|
380
|
-
* @private
|
|
381
|
-
*/
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Blur handler for when focus wrap behavior is enabled
|
|
385
|
-
* @param {Event} event
|
|
386
|
-
* @param {Element} event.target previously focused node
|
|
387
|
-
* @param {Element} event.relatedTarget current focused node
|
|
388
|
-
*/
|
|
389
|
-
|
|
390
386
|
render() {
|
|
391
387
|
const {
|
|
392
388
|
context: prefix
|
|
@@ -26,7 +26,7 @@ var warning = require('./warning.js');
|
|
|
26
26
|
* @param {string} [config.name] - the name of the custom component
|
|
27
27
|
* @param {any} config.defaultValue - the default value used for the state. This will be
|
|
28
28
|
* the fallback value used if `value` is not defined.
|
|
29
|
-
* @param {Function} config.onChange - an optional function that is called when
|
|
29
|
+
* @param {Function|undefined} config.onChange - an optional function that is called when
|
|
30
30
|
* the value of the state changes. This is useful for communicating to parents of
|
|
31
31
|
* controlled components that the value is requesting to be changed.
|
|
32
32
|
* @param {any} config.value - a controlled value. Omitting this means that the state is
|
package/lib/internal/useId.js
CHANGED
|
@@ -43,6 +43,15 @@ function useId() {
|
|
|
43
43
|
serverHandoffCompleted = true;
|
|
44
44
|
}
|
|
45
45
|
}, []);
|
|
46
|
+
if (React.useId) {
|
|
47
|
+
const id = nativeReactUseId(_prefix, prefix);
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
return id;
|
|
51
|
+
}
|
|
52
|
+
function nativeReactUseId(_prefix, prefix) {
|
|
53
|
+
const getId = React.useId();
|
|
54
|
+
const id = `${_prefix ? `${_prefix}-` : ``}${prefix}-${getId}`;
|
|
46
55
|
return id;
|
|
47
56
|
}
|
|
48
57
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.33.0-rc.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"build": "yarn clean && node tasks/build-styles.js && node tasks/build.js",
|
|
35
35
|
"clean": "rimraf es lib icons/index.js icons/index.esm.js storybook-static",
|
|
36
36
|
"postinstall": "carbon-telemetry collect --install",
|
|
37
|
-
"storybook": "
|
|
37
|
+
"storybook": "storybook dev -p 3000",
|
|
38
|
+
"storybook:build": "storybook build"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"react": "^16.8.6 || ^17.0.1 || ^18.2.0",
|
|
@@ -44,9 +45,9 @@
|
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@babel/runtime": "^7.18.3",
|
|
46
47
|
"@carbon/feature-flags": "^0.15.0",
|
|
47
|
-
"@carbon/icons-react": "^11.
|
|
48
|
-
"@carbon/layout": "^11.
|
|
49
|
-
"@carbon/styles": "^1.
|
|
48
|
+
"@carbon/icons-react": "^11.22.0-rc.0",
|
|
49
|
+
"@carbon/layout": "^11.16.0-rc.0",
|
|
50
|
+
"@carbon/styles": "^1.33.0-rc.0",
|
|
50
51
|
"@carbon/telemetry": "0.1.0",
|
|
51
52
|
"classnames": "2.3.2",
|
|
52
53
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -70,25 +71,25 @@
|
|
|
70
71
|
"@babel/plugin-proposal-export-default-from": "^7.17.12",
|
|
71
72
|
"@babel/plugin-proposal-export-namespace-from": "^7.17.12",
|
|
72
73
|
"@babel/plugin-transform-react-constant-elements": "^7.17.12",
|
|
73
|
-
"@babel/preset-env": "^7.
|
|
74
|
-
"@babel/preset-react": "^7.
|
|
74
|
+
"@babel/preset-env": "^7.22.4",
|
|
75
|
+
"@babel/preset-react": "^7.22.3",
|
|
76
|
+
"@babel/preset-typescript": "^7.21.5",
|
|
75
77
|
"@carbon/test-utils": "^10.30.0",
|
|
76
|
-
"@carbon/themes": "^11.
|
|
78
|
+
"@carbon/themes": "^11.21.0-rc.0",
|
|
77
79
|
"@rollup/plugin-babel": "^6.0.0",
|
|
78
80
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
79
81
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
80
82
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
81
|
-
"@storybook/addon-a11y": "^
|
|
82
|
-
"@storybook/addon-actions": "^
|
|
83
|
-
"@storybook/addon-docs": "^
|
|
84
|
-
"@storybook/addon-essentials": "^
|
|
85
|
-
"@storybook/addon-knobs": "^
|
|
83
|
+
"@storybook/addon-a11y": "^7.0.23",
|
|
84
|
+
"@storybook/addon-actions": "^7.0.23",
|
|
85
|
+
"@storybook/addon-docs": "^7.0.23",
|
|
86
|
+
"@storybook/addon-essentials": "^7.0.23",
|
|
87
|
+
"@storybook/addon-knobs": "^7.0.2",
|
|
86
88
|
"@storybook/addon-notes": "^5.3.21",
|
|
87
|
-
"@storybook/addon-storysource": "^
|
|
88
|
-
"@storybook/
|
|
89
|
-
"@storybook/
|
|
90
|
-
"@storybook/
|
|
91
|
-
"@storybook/theming": "^6.5.6",
|
|
89
|
+
"@storybook/addon-storysource": "^7.0.23",
|
|
90
|
+
"@storybook/react": "^7.0.23",
|
|
91
|
+
"@storybook/react-webpack5": "^7.0.23",
|
|
92
|
+
"@storybook/theming": "^7.0.23",
|
|
92
93
|
"@types/react-is": "~18.2.0",
|
|
93
94
|
"autoprefixer": "^10.4.0",
|
|
94
95
|
"babel-loader": "^9.0.0",
|
|
@@ -109,6 +110,7 @@
|
|
|
109
110
|
"prop-types": "^15.7.2",
|
|
110
111
|
"react": "^18.2.0",
|
|
111
112
|
"react-dom": "^18.2.0",
|
|
113
|
+
"remark-gfm": "^3.0.1",
|
|
112
114
|
"requestanimationframe": "^0.0.23",
|
|
113
115
|
"rimraf": "^5.0.0",
|
|
114
116
|
"rollup": "^2.79.1",
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
"rtlcss": "^4.0.0",
|
|
117
119
|
"sass": "^1.51.0",
|
|
118
120
|
"sass-loader": "^13.0.0",
|
|
121
|
+
"storybook": "^7.0.23",
|
|
119
122
|
"storybook-readme": "^5.0.9",
|
|
120
123
|
"stream-browserify": "^3.0.0",
|
|
121
124
|
"style-loader": "^3.3.1",
|
|
@@ -134,5 +137,5 @@
|
|
|
134
137
|
"**/*.scss",
|
|
135
138
|
"**/*.css"
|
|
136
139
|
],
|
|
137
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "b9e28c4e35eeddf4ecc3261630a8f3fecc7012d4"
|
|
138
141
|
}
|