@carbon/react 1.23.0 → 1.23.1
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/Dropdown/Dropdown.Skeleton.d.ts +15 -0
- package/es/components/Dropdown/Dropdown.Skeleton.js +1 -2
- package/es/components/Dropdown/index.js +1 -0
- package/es/components/FluidDropdown/FluidDropdown.js +1 -0
- package/es/components/Heading/index.js +11 -4
- package/es/components/Menu/Menu.js +164 -216
- package/es/components/Menu/MenuContext.js +44 -0
- package/es/components/Menu/MenuItem.js +401 -23
- package/es/components/MultiSelect/MultiSelect.js +6 -0
- package/es/components/OverflowMenu/OverflowMenu.js +2 -2
- package/es/components/OverflowMenuV2/index.js +4 -14
- package/es/components/Search/Search.js +3 -3
- package/es/index.d.ts +1 -1
- package/es/index.js +2 -6
- package/es/prop-types/isRequiredOneOf.js +2 -2
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +15 -0
- package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -2
- package/lib/components/Dropdown/index.js +2 -0
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -0
- package/lib/components/Heading/index.js +11 -4
- package/lib/components/Menu/Menu.js +163 -216
- package/lib/components/Menu/MenuContext.js +53 -0
- package/lib/components/Menu/MenuItem.js +406 -23
- package/lib/components/MultiSelect/MultiSelect.js +6 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
- package/lib/components/OverflowMenuV2/index.js +5 -15
- package/lib/components/Search/Search.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -11
- package/lib/prop-types/isRequiredOneOf.js +2 -2
- package/package.json +4 -4
- package/es/components/Menu/MenuDivider.js +0 -19
- package/es/components/Menu/MenuGroup.js +0 -34
- package/es/components/Menu/MenuOption.js +0 -250
- package/es/components/Menu/MenuRadioGroup.js +0 -50
- package/es/components/Menu/MenuRadioGroupOptions.js +0 -64
- package/es/components/Menu/MenuSelectableItem.js +0 -57
- package/es/components/Menu/_utils.js +0 -177
- package/es/components/Menu/index.js +0 -25
- package/lib/components/Menu/MenuDivider.js +0 -27
- package/lib/components/Menu/MenuGroup.js +0 -43
- package/lib/components/Menu/MenuOption.js +0 -260
- package/lib/components/Menu/MenuRadioGroup.js +0 -59
- package/lib/components/Menu/MenuRadioGroupOptions.js +0 -73
- package/lib/components/Menu/MenuSelectableItem.js +0 -66
- package/lib/components/Menu/_utils.js +0 -191
- package/lib/components/Menu/index.js +0 -31
|
@@ -5,54 +5,432 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import
|
|
11
|
+
import React__default, { useContext, useRef, useState, useEffect } from 'react';
|
|
12
|
+
import { CaretRight, Checkmark } from '@carbon/react/icons';
|
|
13
|
+
import { useControllableState } from '../../internal/useControllableState.js';
|
|
14
|
+
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
+
import { Menu } from './Menu.js';
|
|
17
|
+
import { MenuContext } from './MenuContext.js';
|
|
18
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
19
|
+
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
12
20
|
|
|
13
|
-
var
|
|
21
|
+
var _CaretRight;
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
var _excluded = ["children", "className", "disabled", "kind", "label", "onClick", "renderIcon", "shortcut"],
|
|
24
|
+
_excluded2 = ["className", "defaultSelected", "label", "onChange", "selected"],
|
|
25
|
+
_excluded3 = ["children", "className", "label"],
|
|
26
|
+
_excluded4 = ["className", "defaultSelectedItem", "items", "itemToString", "label", "onChange", "selectedItem"],
|
|
27
|
+
_excluded5 = ["className"];
|
|
28
|
+
var hoverIntentDelay = 150; // in ms
|
|
29
|
+
|
|
30
|
+
var MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref, forwardRef) {
|
|
31
|
+
var _cx;
|
|
32
|
+
|
|
33
|
+
var children = _ref.children,
|
|
34
|
+
className = _ref.className,
|
|
18
35
|
disabled = _ref.disabled,
|
|
19
|
-
kind = _ref.kind,
|
|
36
|
+
_ref$kind = _ref.kind,
|
|
37
|
+
kind = _ref$kind === void 0 ? 'default' : _ref$kind,
|
|
38
|
+
label = _ref.label,
|
|
39
|
+
onClick = _ref.onClick,
|
|
40
|
+
IconElement = _ref.renderIcon,
|
|
20
41
|
shortcut = _ref.shortcut,
|
|
21
42
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
22
43
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
var prefix = usePrefix();
|
|
45
|
+
var context = useContext(MenuContext);
|
|
46
|
+
var menuItem = useRef();
|
|
47
|
+
var ref = useMergedRefs([forwardRef, menuItem]);
|
|
48
|
+
|
|
49
|
+
var _useState = useState({
|
|
50
|
+
x: -1,
|
|
51
|
+
y: -1
|
|
52
|
+
}),
|
|
53
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
+
boundaries = _useState2[0],
|
|
55
|
+
setBoundaries = _useState2[1];
|
|
56
|
+
|
|
57
|
+
var hasChildren = Boolean(children);
|
|
58
|
+
|
|
59
|
+
var _useState3 = useState(false),
|
|
60
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
+
submenuOpen = _useState4[0],
|
|
62
|
+
setSubmenuOpen = _useState4[1];
|
|
63
|
+
|
|
64
|
+
var hoverIntentTimeout = useRef(null);
|
|
65
|
+
|
|
66
|
+
function registerItem() {
|
|
67
|
+
context.dispatch({
|
|
68
|
+
type: 'registerItem',
|
|
69
|
+
payload: {
|
|
70
|
+
ref: menuItem,
|
|
71
|
+
disabled: Boolean(disabled)
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function openSubmenu() {
|
|
77
|
+
var _menuItem$current$get = menuItem.current.getBoundingClientRect(),
|
|
78
|
+
x = _menuItem$current$get.x,
|
|
79
|
+
y = _menuItem$current$get.y,
|
|
80
|
+
width = _menuItem$current$get.width,
|
|
81
|
+
height = _menuItem$current$get.height;
|
|
82
|
+
|
|
83
|
+
setBoundaries({
|
|
84
|
+
x: [x, x + width],
|
|
85
|
+
y: [y, y + height]
|
|
86
|
+
});
|
|
87
|
+
setSubmenuOpen(true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function closeSubmenu() {
|
|
91
|
+
setSubmenuOpen(false);
|
|
92
|
+
setBoundaries({
|
|
93
|
+
x: -1,
|
|
94
|
+
y: -1
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function handleClick(e) {
|
|
99
|
+
if (hasChildren) {
|
|
100
|
+
openSubmenu();
|
|
101
|
+
} else {
|
|
102
|
+
context.state.requestCloseRoot(e);
|
|
30
103
|
|
|
104
|
+
if (onClick) {
|
|
105
|
+
onClick(e);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function handleMouseEnter() {
|
|
111
|
+
hoverIntentTimeout.current = setTimeout(function () {
|
|
112
|
+
openSubmenu();
|
|
113
|
+
}, hoverIntentDelay);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handleMouseLeave() {
|
|
117
|
+
clearTimeout(hoverIntentTimeout.current);
|
|
118
|
+
closeSubmenu();
|
|
119
|
+
menuItem.current.focus();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function handleKeyDown(e) {
|
|
123
|
+
if (hasChildren && match(e, ArrowRight)) {
|
|
124
|
+
openSubmenu();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (match(e, Enter) || match(e, Space)) {
|
|
128
|
+
handleClick(e);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (rest.onKeyDown) {
|
|
132
|
+
rest.onKeyDown(e);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var classNames = cx(className, "".concat(prefix, "--menu-item"), (_cx = {}, _defineProperty(_cx, "".concat(prefix, "--menu-item--disabled"), disabled), _defineProperty(_cx, "".concat(prefix, "--menu-item--").concat(kind), kind !== 'default'), _cx)); // on first render, register this menuitem in the context's state
|
|
137
|
+
// (used for keyboard navigation)
|
|
138
|
+
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
registerItem(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
+
}, []);
|
|
142
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
|
143
|
+
role: "menuitem"
|
|
144
|
+
}, rest, {
|
|
145
|
+
ref: ref,
|
|
146
|
+
className: classNames,
|
|
147
|
+
tabIndex: "-1",
|
|
148
|
+
"aria-disabled": disabled,
|
|
149
|
+
"aria-haspopup": hasChildren || null,
|
|
150
|
+
"aria-expanded": hasChildren ? submenuOpen : null,
|
|
151
|
+
onClick: handleClick,
|
|
152
|
+
onMouseEnter: hasChildren ? handleMouseEnter : null,
|
|
153
|
+
onMouseLeave: hasChildren ? handleMouseLeave : null,
|
|
154
|
+
onKeyDown: handleKeyDown
|
|
155
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
156
|
+
className: "".concat(prefix, "--menu-item__icon")
|
|
157
|
+
}, IconElement && /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement("div", {
|
|
158
|
+
className: "".concat(prefix, "--menu-item__label")
|
|
159
|
+
}, label), shortcut && !hasChildren && /*#__PURE__*/React__default.createElement("div", {
|
|
160
|
+
className: "".concat(prefix, "--menu-item__shortcut")
|
|
161
|
+
}, shortcut), hasChildren && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
162
|
+
className: "".concat(prefix, "--menu-item__shortcut")
|
|
163
|
+
}, _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))), /*#__PURE__*/React__default.createElement(Menu, {
|
|
164
|
+
label: label,
|
|
165
|
+
open: submenuOpen,
|
|
166
|
+
onClose: function onClose() {
|
|
167
|
+
closeSubmenu();
|
|
168
|
+
menuItem.current.focus();
|
|
169
|
+
},
|
|
170
|
+
x: boundaries.x,
|
|
171
|
+
y: boundaries.y
|
|
172
|
+
}, children)));
|
|
173
|
+
});
|
|
31
174
|
MenuItem.propTypes = {
|
|
32
175
|
/**
|
|
33
|
-
*
|
|
176
|
+
* Optionally provide another Menu to create a submenu. props.children can't be used to specify the content of the MenuItem itself. Use props.label instead.
|
|
34
177
|
*/
|
|
35
178
|
children: PropTypes.node,
|
|
36
179
|
|
|
37
180
|
/**
|
|
38
|
-
*
|
|
181
|
+
* Additional CSS class names.
|
|
182
|
+
*/
|
|
183
|
+
className: PropTypes.string,
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Specify whether the MenuItem is disabled or not.
|
|
39
187
|
*/
|
|
40
188
|
disabled: PropTypes.bool,
|
|
41
189
|
|
|
42
190
|
/**
|
|
43
|
-
*
|
|
191
|
+
* Specify the kind of the MenuItem.
|
|
44
192
|
*/
|
|
45
193
|
kind: PropTypes.oneOf(['default', 'danger']),
|
|
46
194
|
|
|
47
195
|
/**
|
|
48
|
-
*
|
|
196
|
+
* A required label titling the MenuItem. Will be rendered as its text content.
|
|
49
197
|
*/
|
|
50
|
-
label: PropTypes.
|
|
198
|
+
label: PropTypes.string.isRequired,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Provide an optional function to be called when the MenuItem is clicked.
|
|
202
|
+
*/
|
|
203
|
+
onClick: PropTypes.func,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* This prop is not intended for use. The only supported icons are Checkmarks to depict single- and multi-selects. This prop is used by MenuItemSelectable and MenuItemRadioGroup automatically.
|
|
207
|
+
*/
|
|
208
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Provide a shortcut for the action of this MenuItem. Note that the component will only render it as a hint but not actually register the shortcut.
|
|
212
|
+
*/
|
|
213
|
+
shortcut: PropTypes.string
|
|
214
|
+
};
|
|
215
|
+
var MenuItemSelectable = /*#__PURE__*/React__default.forwardRef(function MenuItemSelectable(_ref2, forwardRef) {
|
|
216
|
+
var className = _ref2.className,
|
|
217
|
+
defaultSelected = _ref2.defaultSelected,
|
|
218
|
+
label = _ref2.label,
|
|
219
|
+
onChange = _ref2.onChange,
|
|
220
|
+
selected = _ref2.selected,
|
|
221
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
222
|
+
|
|
223
|
+
var prefix = usePrefix();
|
|
224
|
+
var context = useContext(MenuContext);
|
|
225
|
+
|
|
226
|
+
var _useControllableState = useControllableState({
|
|
227
|
+
value: selected,
|
|
228
|
+
onChange: onChange,
|
|
229
|
+
defaultValue: defaultSelected
|
|
230
|
+
}),
|
|
231
|
+
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
|
232
|
+
checked = _useControllableState2[0],
|
|
233
|
+
setChecked = _useControllableState2[1];
|
|
234
|
+
|
|
235
|
+
function handleClick(e) {
|
|
236
|
+
setChecked(!checked);
|
|
237
|
+
|
|
238
|
+
if (onChange) {
|
|
239
|
+
onChange(e);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
useEffect(function () {
|
|
244
|
+
if (!context.state.hasIcons) {
|
|
245
|
+
context.dispatch({
|
|
246
|
+
type: 'enableIcons'
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}, [context.state.hasIcons, context]);
|
|
250
|
+
var classNames = cx(className, "".concat(prefix, "--menu-item-selectable--selected"));
|
|
251
|
+
return /*#__PURE__*/React__default.createElement(MenuItem, _extends({}, rest, {
|
|
252
|
+
ref: forwardRef,
|
|
253
|
+
label: label,
|
|
254
|
+
className: classNames,
|
|
255
|
+
role: "menuitemcheckbox",
|
|
256
|
+
"aria-checked": checked,
|
|
257
|
+
renderIcon: checked && Checkmark,
|
|
258
|
+
onClick: handleClick
|
|
259
|
+
}));
|
|
260
|
+
});
|
|
261
|
+
MenuItemSelectable.propTypes = {
|
|
262
|
+
/**
|
|
263
|
+
* Additional CSS class names.
|
|
264
|
+
*/
|
|
265
|
+
className: PropTypes.string,
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Specify whether the option should be selected by default.
|
|
269
|
+
*/
|
|
270
|
+
defaultSelected: PropTypes.bool,
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* A required label titling this option.
|
|
274
|
+
*/
|
|
275
|
+
label: PropTypes.string.isRequired,
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Provide an optional function to be called when the selection state changes.
|
|
279
|
+
*/
|
|
280
|
+
onChange: PropTypes.func,
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Pass a bool to props.selected to control the state of this option.
|
|
284
|
+
*/
|
|
285
|
+
selected: PropTypes.bool
|
|
286
|
+
};
|
|
287
|
+
var MenuItemGroup = /*#__PURE__*/React__default.forwardRef(function MenuItemGroup(_ref3, forwardRef) {
|
|
288
|
+
var children = _ref3.children,
|
|
289
|
+
className = _ref3.className,
|
|
290
|
+
label = _ref3.label,
|
|
291
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
292
|
+
|
|
293
|
+
var prefix = usePrefix();
|
|
294
|
+
var classNames = cx(className, "".concat(prefix, "--menu-item-group"));
|
|
295
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
296
|
+
className: classNames,
|
|
297
|
+
role: "none",
|
|
298
|
+
ref: forwardRef
|
|
299
|
+
}, /*#__PURE__*/React__default.createElement("ul", _extends({}, rest, {
|
|
300
|
+
role: "group",
|
|
301
|
+
"aria-label": label
|
|
302
|
+
}), children));
|
|
303
|
+
});
|
|
304
|
+
MenuItemGroup.propTypes = {
|
|
305
|
+
/**
|
|
306
|
+
* A collection of MenuItems to be rendered within this group.
|
|
307
|
+
*/
|
|
308
|
+
children: PropTypes.node,
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Additional CSS class names.
|
|
312
|
+
*/
|
|
313
|
+
className: PropTypes.string,
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* A required label titling this group.
|
|
317
|
+
*/
|
|
318
|
+
label: PropTypes.string.isRequired
|
|
319
|
+
};
|
|
320
|
+
var MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuItemRadioGroup(_ref4, forwardRef) {
|
|
321
|
+
var className = _ref4.className,
|
|
322
|
+
defaultSelectedItem = _ref4.defaultSelectedItem,
|
|
323
|
+
items = _ref4.items,
|
|
324
|
+
_ref4$itemToString = _ref4.itemToString,
|
|
325
|
+
itemToString = _ref4$itemToString === void 0 ? function (item) {
|
|
326
|
+
return item.toString();
|
|
327
|
+
} : _ref4$itemToString,
|
|
328
|
+
label = _ref4.label,
|
|
329
|
+
onChange = _ref4.onChange,
|
|
330
|
+
selectedItem = _ref4.selectedItem,
|
|
331
|
+
rest = _objectWithoutProperties(_ref4, _excluded4);
|
|
332
|
+
|
|
333
|
+
var prefix = usePrefix();
|
|
334
|
+
var context = useContext(MenuContext);
|
|
335
|
+
|
|
336
|
+
var _useControllableState3 = useControllableState({
|
|
337
|
+
value: selectedItem,
|
|
338
|
+
onChange: onChange,
|
|
339
|
+
defaultValue: defaultSelectedItem
|
|
340
|
+
}),
|
|
341
|
+
_useControllableState4 = _slicedToArray(_useControllableState3, 2),
|
|
342
|
+
selection = _useControllableState4[0],
|
|
343
|
+
setSelection = _useControllableState4[1];
|
|
344
|
+
|
|
345
|
+
function handleClick(item, e) {
|
|
346
|
+
setSelection(item);
|
|
347
|
+
|
|
348
|
+
if (onChange) {
|
|
349
|
+
onChange(e);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
useEffect(function () {
|
|
354
|
+
if (!context.state.hasIcons) {
|
|
355
|
+
context.dispatch({
|
|
356
|
+
type: 'enableIcons'
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}, [context.state.hasIcons, context]);
|
|
360
|
+
var classNames = cx(className, "".concat(prefix, "--menu-item-radio-group"));
|
|
361
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
362
|
+
className: classNames,
|
|
363
|
+
role: "none",
|
|
364
|
+
ref: forwardRef
|
|
365
|
+
}, /*#__PURE__*/React__default.createElement("ul", _extends({}, rest, {
|
|
366
|
+
role: "group",
|
|
367
|
+
"aria-label": label
|
|
368
|
+
}), items.map(function (item, i) {
|
|
369
|
+
return /*#__PURE__*/React__default.createElement(MenuItem, {
|
|
370
|
+
key: i,
|
|
371
|
+
label: itemToString(item),
|
|
372
|
+
role: "menuitemradio",
|
|
373
|
+
"aria-checked": item === selection,
|
|
374
|
+
renderIcon: item === selection && Checkmark,
|
|
375
|
+
onClick: function onClick(e) {
|
|
376
|
+
handleClick(item, e);
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
})));
|
|
380
|
+
});
|
|
381
|
+
MenuItemRadioGroup.propTypes = {
|
|
382
|
+
/**
|
|
383
|
+
* Additional CSS class names.
|
|
384
|
+
*/
|
|
385
|
+
className: PropTypes.string,
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Specify the default selected item. Must match the type of props.items.
|
|
389
|
+
*/
|
|
390
|
+
defaultSelectedItem: PropTypes.any,
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Provide a function to convert an item to the string that will be rendered. Defaults to item.toString().
|
|
394
|
+
*/
|
|
395
|
+
itemToString: PropTypes.func,
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Provide the options for this radio group. Can be of any type, as long as you provide an appropriate props.itemToString function.
|
|
399
|
+
*/
|
|
400
|
+
items: PropTypes.array,
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* A required label titling this radio group.
|
|
404
|
+
*/
|
|
405
|
+
label: PropTypes.string.isRequired,
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Provide an optional function to be called when the selection changes.
|
|
409
|
+
*/
|
|
410
|
+
onChange: PropTypes.func,
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Provide props.selectedItem to control the state of this radio group. Must match the type of props.items.
|
|
414
|
+
*/
|
|
415
|
+
selectedItem: PropTypes.any
|
|
416
|
+
};
|
|
417
|
+
var MenuItemDivider = /*#__PURE__*/React__default.forwardRef(function MenuItemDivider(_ref5, forwardRef) {
|
|
418
|
+
var className = _ref5.className,
|
|
419
|
+
rest = _objectWithoutProperties(_ref5, _excluded5);
|
|
51
420
|
|
|
421
|
+
var prefix = usePrefix();
|
|
422
|
+
var classNames = cx(className, "".concat(prefix, "--menu-item-divider"));
|
|
423
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({}, rest, {
|
|
424
|
+
className: classNames,
|
|
425
|
+
role: "separator",
|
|
426
|
+
ref: forwardRef
|
|
427
|
+
}));
|
|
428
|
+
});
|
|
429
|
+
MenuItemDivider.propTypes = {
|
|
52
430
|
/**
|
|
53
|
-
*
|
|
431
|
+
* Additional CSS class names.
|
|
54
432
|
*/
|
|
55
|
-
|
|
433
|
+
className: PropTypes.string
|
|
56
434
|
};
|
|
57
435
|
|
|
58
|
-
export { MenuItem
|
|
436
|
+
export { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable };
|
|
@@ -327,6 +327,12 @@ var MultiSelect = /*#__PURE__*/React__default.forwardRef(function MultiSelect(_r
|
|
|
327
327
|
});
|
|
328
328
|
MultiSelect.displayName = 'MultiSelect';
|
|
329
329
|
MultiSelect.propTypes = _objectSpread2(_objectSpread2({}, sortingPropTypes), {}, {
|
|
330
|
+
/**
|
|
331
|
+
* Provide a custom class name to be added to the outermost node in the
|
|
332
|
+
* component
|
|
333
|
+
*/
|
|
334
|
+
className: PropTypes.string,
|
|
335
|
+
|
|
330
336
|
/**
|
|
331
337
|
* Specify the text that should be read for screen readers that describes total items selected
|
|
332
338
|
*/
|
|
@@ -39,14 +39,14 @@ var on = function on(element) {
|
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
41
|
* The CSS property names of the arrow keyed by the floating menu direction.
|
|
42
|
-
* @type {
|
|
42
|
+
* @type {Object<string, string>}
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
var triggerButtonPositionProps = (_triggerButtonPositio = {}, _defineProperty(_triggerButtonPositio, DIRECTION_TOP, 'bottom'), _defineProperty(_triggerButtonPositio, DIRECTION_BOTTOM, 'top'), _triggerButtonPositio);
|
|
47
47
|
/**
|
|
48
48
|
* Determines how the position of arrow should affect the floating menu position.
|
|
49
|
-
* @type {
|
|
49
|
+
* @type {Object<string, number>}
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
52
|
var triggerButtonPositionFactors = (_triggerButtonPositio2 = {}, _defineProperty(_triggerButtonPositio2, DIRECTION_TOP, -2), _defineProperty(_triggerButtonPositio2, DIRECTION_BOTTOM, -1), _triggerButtonPositio2);
|
|
@@ -11,11 +11,8 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
13
13
|
import { useId } from '../../internal/useId.js';
|
|
14
|
-
import '../Menu/
|
|
14
|
+
import { Menu } from '../Menu/Menu.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
-
import Menu from '../Menu/Menu.js';
|
|
17
|
-
import { matches } from '../../internal/keyboard/match.js';
|
|
18
|
-
import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft } from '../../internal/keyboard/keys.js';
|
|
19
16
|
|
|
20
17
|
var _excluded = ["children", "className", "renderIcon", "size"];
|
|
21
18
|
var defaultSize = 'md';
|
|
@@ -80,12 +77,6 @@ function OverflowMenuV2(_ref) {
|
|
|
80
77
|
e.preventDefault();
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
function handleKeyPress(e) {
|
|
84
|
-
if (open && matches(e, [ArrowUp, ArrowRight, ArrowDown, ArrowLeft])) {
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
80
|
var containerClasses = cx("".concat(prefix, "--overflow-menu__container"));
|
|
90
81
|
var triggerClasses = cx("".concat(prefix, "--overflow-menu"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--overflow-menu--open"), open), _defineProperty(_classNames, className, className), _classNames), size !== defaultSize && "".concat(prefix, "--overflow-menu--").concat(size));
|
|
91
82
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -98,7 +89,6 @@ function OverflowMenuV2(_ref) {
|
|
|
98
89
|
className: triggerClasses,
|
|
99
90
|
onClick: handleClick,
|
|
100
91
|
onMouseDown: handleMousedown,
|
|
101
|
-
onKeyDown: handleKeyPress,
|
|
102
92
|
ref: triggerRef
|
|
103
93
|
}), /*#__PURE__*/React__default.createElement(IconElement, {
|
|
104
94
|
className: "".concat(prefix, "--overflow-menu__icon")
|
|
@@ -114,17 +104,17 @@ function OverflowMenuV2(_ref) {
|
|
|
114
104
|
|
|
115
105
|
OverflowMenuV2.propTypes = {
|
|
116
106
|
/**
|
|
117
|
-
*
|
|
107
|
+
* A collection of MenuItems to be rendered within this OverflowMenu.
|
|
118
108
|
*/
|
|
119
109
|
children: PropTypes.node,
|
|
120
110
|
|
|
121
111
|
/**
|
|
122
|
-
*
|
|
112
|
+
* Additional CSS class names for the trigger button.
|
|
123
113
|
*/
|
|
124
114
|
className: PropTypes.string,
|
|
125
115
|
|
|
126
116
|
/**
|
|
127
|
-
*
|
|
117
|
+
* Otionally provide a custom icon to be rendered on the trigger button.
|
|
128
118
|
*/
|
|
129
119
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
130
120
|
|
|
@@ -247,11 +247,11 @@ Search.propTypes = {
|
|
|
247
247
|
};
|
|
248
248
|
|
|
249
249
|
function CustomSearchIcon(_ref2) {
|
|
250
|
-
var
|
|
250
|
+
var Icon = _ref2.icon;
|
|
251
251
|
var prefix = usePrefix();
|
|
252
252
|
|
|
253
|
-
if (
|
|
254
|
-
return /*#__PURE__*/React__default.
|
|
253
|
+
if (Icon) {
|
|
254
|
+
return /*#__PURE__*/React__default.createElement(Icon, {
|
|
255
255
|
className: "".concat(prefix, "--search-magnifier-icon")
|
|
256
256
|
});
|
|
257
257
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ export * from './components/Heading';
|
|
|
105
105
|
export * from './components/IconButton';
|
|
106
106
|
export * from './components/Layer';
|
|
107
107
|
export { LayoutDirection as unstable_LayoutDirection, useLayoutDirection as unstable_useLayoutDirection, } from './components/Layout';
|
|
108
|
-
export { Menu as unstable_Menu,
|
|
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
110
|
export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
|
|
111
111
|
export * from './components/Popover';
|
package/es/index.js
CHANGED
|
@@ -50,11 +50,6 @@ export { default as unstable__FluidTextArea } from './components/FluidTextArea/F
|
|
|
50
50
|
export { default as unstable__FluidTextAreaSkeleton } from './components/FluidTextArea/FluidTextArea.Skeleton.js';
|
|
51
51
|
export { default as unstable__FluidTextInput } from './components/FluidTextInput/FluidTextInput.js';
|
|
52
52
|
export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
|
|
53
|
-
export { default as unstable_MenuDivider } from './components/Menu/MenuDivider.js';
|
|
54
|
-
export { default as unstable_MenuGroup } from './components/Menu/MenuGroup.js';
|
|
55
|
-
export { default as unstable_MenuItem } from './components/Menu/MenuItem.js';
|
|
56
|
-
export { default as unstable_MenuRadioGroup } from './components/Menu/MenuRadioGroup.js';
|
|
57
|
-
export { default as unstable_MenuSelectableItem } from './components/Menu/MenuSelectableItem.js';
|
|
58
53
|
export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
|
|
59
54
|
export { default as unstable_Pagination } from './components/Pagination/experimental/Pagination.js';
|
|
60
55
|
export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
|
|
@@ -110,7 +105,8 @@ export { default as unstable__FluidTimePickerSkeleton } from './components/Fluid
|
|
|
110
105
|
export { default as unstable__FluidTimePickerSelect } from './components/FluidTimePickerSelect/FluidTimePickerSelect.js';
|
|
111
106
|
export { LayoutDirection as unstable_LayoutDirection } from './components/Layout/LayoutDirection.js';
|
|
112
107
|
export { useLayoutDirection as unstable_useLayoutDirection } from './components/Layout/useLayoutDirection.js';
|
|
113
|
-
export {
|
|
108
|
+
export { Menu as unstable_Menu } from './components/Menu/Menu.js';
|
|
109
|
+
export { MenuItem as unstable_MenuItem, MenuItemDivider as unstable_MenuItemDivider, MenuItemGroup as unstable_MenuItemGroup, MenuItemRadioGroup as unstable_MenuItemRadioGroup, MenuItemSelectable as unstable_MenuItemSelectable } from './components/Menu/MenuItem.js';
|
|
114
110
|
export { Text as unstable_Text } from './components/Text/Text.js';
|
|
115
111
|
export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
|
|
116
112
|
export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
|
|
@@ -15,8 +15,8 @@ import { objectSpread2 as _objectSpread2, defineProperty as _defineProperty } fr
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @param {
|
|
19
|
-
* @returns {
|
|
18
|
+
* @param {Object<string, Function>} propTypes The list of type checkers, keyed by prop names.
|
|
19
|
+
* @returns {Object<string, Function>}
|
|
20
20
|
* The new prop type checkers that checks if one of the given props exist,
|
|
21
21
|
* in addition to the original type checkings.
|
|
22
22
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import { ListBoxSize } from '../ListBox';
|
|
9
|
+
import { ReactAttr } from '../../types/common';
|
|
10
|
+
export interface DropdownSkeletonProps extends ReactAttr<HTMLDivElement> {
|
|
11
|
+
size?: ListBoxSize;
|
|
12
|
+
}
|
|
13
|
+
declare const DropdownSkeleton: React.FC<DropdownSkeletonProps>;
|
|
14
|
+
export default DropdownSkeleton;
|
|
15
|
+
export { DropdownSkeleton };
|
|
@@ -52,7 +52,6 @@ DropdownSkeleton.propTypes = {
|
|
|
52
52
|
*/
|
|
53
53
|
size: ListBoxPropTypes.ListBoxSize
|
|
54
54
|
};
|
|
55
|
-
var DropdownSkeleton$1 = DropdownSkeleton;
|
|
56
55
|
|
|
57
56
|
exports.DropdownSkeleton = DropdownSkeleton;
|
|
58
|
-
exports["default"] = DropdownSkeleton
|
|
57
|
+
exports["default"] = DropdownSkeleton;
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var Dropdown = require('./Dropdown.js');
|
|
13
|
+
var Dropdown_Skeleton = require('./Dropdown.Skeleton.js');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
exports.Dropdown = Dropdown["default"];
|
|
17
18
|
exports["default"] = Dropdown["default"];
|
|
19
|
+
exports.DropdownSkeleton = Dropdown_Skeleton["default"];
|
|
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
|
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var Dropdown = require('../Dropdown/Dropdown.js');
|
|
17
|
+
require('../Dropdown/Dropdown.Skeleton.js');
|
|
17
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
18
19
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
19
20
|
|