@carbon/react 1.24.0 → 1.25.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/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/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 +21 -0
- package/es/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -3
- 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/FileUploader/FileUploader.js +1 -1
- 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/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 +31 -137
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +48 -26
- package/es/components/Notification/Notification.js +27 -264
- 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/RadioButtonGroup/RadioButtonGroup.js +7 -4
- package/es/components/RadioTile/RadioTile.js +6 -6
- 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 +10 -38
- package/es/components/Tabs/Tabs.js +3 -1
- 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/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/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/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/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 +21 -0
- package/lib/components/DataTable/TableToolbarMenu.d.ts +24 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -3
- 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/FileUploader/FileUploader.js +1 -1
- 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/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 +29 -135
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +47 -25
- package/lib/components/Notification/Notification.js +27 -264
- 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/RadioButtonGroup/RadioButtonGroup.js +6 -3
- package/lib/components/RadioTile/RadioTile.js +6 -6
- 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 +10 -38
- package/lib/components/Tabs/Tabs.js +3 -1
- 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/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/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/package.json +3 -3
|
@@ -20,9 +20,9 @@ import { IconButton } from '../IconButton/index.js';
|
|
|
20
20
|
import { matches } from '../../internal/keyboard/match.js';
|
|
21
21
|
import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft, Escape } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["id", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
|
|
23
|
+
var _excluded = ["id", "aria-label", "ariaLabel", "children", "iconDescription", "direction", "flipped", "focusTrap", "menuOffset", "menuOffsetFlip", "iconClass", "onClick", "onOpen", "selectorPrimaryFocus", "renderIcon", "innerRef", "menuOptionsClass", "light", "size"];
|
|
24
24
|
|
|
25
|
-
var _triggerButtonPositio, _triggerButtonPositio2;
|
|
25
|
+
var _triggerButtonPositio, _triggerButtonPositio2, _defineProperty2, _defineProperty3;
|
|
26
26
|
|
|
27
27
|
var on = function on(element) {
|
|
28
28
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -288,7 +288,8 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
288
288
|
|
|
289
289
|
var _this$props = this.props,
|
|
290
290
|
id = _this$props.id,
|
|
291
|
-
ariaLabel = _this$props
|
|
291
|
+
ariaLabel = _this$props['aria-label'],
|
|
292
|
+
deprecatedAriaLabel = _this$props.ariaLabel,
|
|
292
293
|
children = _this$props.children,
|
|
293
294
|
iconDescription = _this$props.iconDescription,
|
|
294
295
|
direction = _this$props.direction,
|
|
@@ -328,7 +329,7 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
328
329
|
className: overflowMenuOptionsClasses,
|
|
329
330
|
tabIndex: "-1",
|
|
330
331
|
role: "menu",
|
|
331
|
-
"aria-label": ariaLabel,
|
|
332
|
+
"aria-label": ariaLabel || deprecatedAriaLabel,
|
|
332
333
|
onKeyDown: this.handleKeyPress
|
|
333
334
|
}, childrenWithProps);
|
|
334
335
|
var wrappedMenuBody = /*#__PURE__*/React__default.createElement(FloatingMenu, {
|
|
@@ -378,144 +379,17 @@ var OverflowMenu = /*#__PURE__*/function (_Component) {
|
|
|
378
379
|
return OverflowMenu;
|
|
379
380
|
}(Component);
|
|
380
381
|
|
|
381
|
-
_defineProperty(OverflowMenu, "propTypes", {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
* The child nodes.
|
|
389
|
-
*/
|
|
390
|
-
children: PropTypes.node,
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* The CSS class names.
|
|
394
|
-
*/
|
|
395
|
-
className: PropTypes.string,
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* The menu direction.
|
|
399
|
-
*/
|
|
400
|
-
direction: PropTypes.oneOf([DIRECTION_TOP, DIRECTION_BOTTOM]),
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* `true` if the menu alignment should be flipped.
|
|
404
|
-
*/
|
|
405
|
-
flipped: PropTypes.bool,
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Enable or disable focus trap behavior
|
|
409
|
-
*/
|
|
410
|
-
focusTrap: PropTypes.bool,
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* The CSS class for the icon.
|
|
414
|
-
*/
|
|
415
|
-
iconClass: PropTypes.string,
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* The icon description.
|
|
419
|
-
*/
|
|
420
|
-
iconDescription: PropTypes.string.isRequired,
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* The element ID.
|
|
424
|
-
*/
|
|
425
|
-
id: PropTypes.string,
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* `true` to use the light version. For use on $ui-01 backgrounds only.
|
|
429
|
-
* Don't use this to make OverflowMenu background color same as container background color.
|
|
430
|
-
*/
|
|
431
|
-
light: deprecate(PropTypes.bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.'),
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* The adjustment in position applied to the floating menu.
|
|
435
|
-
*/
|
|
436
|
-
menuOffset: PropTypes.oneOfType([PropTypes.shape({
|
|
437
|
-
top: PropTypes.number,
|
|
438
|
-
left: PropTypes.number
|
|
439
|
-
}), PropTypes.func]),
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* The adjustment in position applied to the floating menu.
|
|
443
|
-
*/
|
|
444
|
-
menuOffsetFlip: PropTypes.oneOfType([PropTypes.shape({
|
|
445
|
-
top: PropTypes.number,
|
|
446
|
-
left: PropTypes.number
|
|
447
|
-
}), PropTypes.func]),
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* The class to apply to the menu options
|
|
451
|
-
*/
|
|
452
|
-
menuOptionsClass: PropTypes.string,
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* The event handler for the `click` event.
|
|
456
|
-
*/
|
|
457
|
-
onClick: PropTypes.func,
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Function called when menu is closed
|
|
461
|
-
*/
|
|
462
|
-
onClose: PropTypes.func,
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* The event handler for the `focus` event.
|
|
466
|
-
*/
|
|
467
|
-
onFocus: PropTypes.func,
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* The event handler for the `keydown` event.
|
|
471
|
-
*/
|
|
472
|
-
onKeyDown: PropTypes.func,
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Function called when menu is opened
|
|
476
|
-
*/
|
|
477
|
-
onOpen: PropTypes.func,
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* `true` if the menu should be open.
|
|
481
|
-
*/
|
|
482
|
-
open: PropTypes.bool,
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Function called to override icon rendering.
|
|
486
|
-
*/
|
|
487
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Specify a CSS selector that matches the DOM element that should
|
|
491
|
-
* be focused when the OverflowMenu opens
|
|
492
|
-
*/
|
|
493
|
-
selectorPrimaryFocus: PropTypes.string,
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Specify the size of the OverflowMenu. Currently supports either `sm`, 'md' (default) or 'lg` as an option.
|
|
497
|
-
*/
|
|
498
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
499
|
-
});
|
|
382
|
+
_defineProperty(OverflowMenu, "propTypes", (_defineProperty2 = {}, _defineProperty(_defineProperty2, 'aria-label', PropTypes.string), _defineProperty(_defineProperty2, "ariaLabel", deprecate(PropTypes.string, 'This prop syntax has been deprecated. Please use the new `aria-label`.')), _defineProperty(_defineProperty2, "children", PropTypes.node), _defineProperty(_defineProperty2, "className", PropTypes.string), _defineProperty(_defineProperty2, "direction", PropTypes.oneOf([DIRECTION_TOP, DIRECTION_BOTTOM])), _defineProperty(_defineProperty2, "flipped", PropTypes.bool), _defineProperty(_defineProperty2, "focusTrap", PropTypes.bool), _defineProperty(_defineProperty2, "iconClass", PropTypes.string), _defineProperty(_defineProperty2, "iconDescription", PropTypes.string.isRequired), _defineProperty(_defineProperty2, "id", PropTypes.string), _defineProperty(_defineProperty2, "light", deprecate(PropTypes.bool, 'The `light` prop for `OverflowMenu` is no longer needed and has been deprecated. It will be removed in the next major release. Use the Layer component instead.')), _defineProperty(_defineProperty2, "menuOffset", PropTypes.oneOfType([PropTypes.shape({
|
|
383
|
+
top: PropTypes.number,
|
|
384
|
+
left: PropTypes.number
|
|
385
|
+
}), PropTypes.func])), _defineProperty(_defineProperty2, "menuOffsetFlip", PropTypes.oneOfType([PropTypes.shape({
|
|
386
|
+
top: PropTypes.number,
|
|
387
|
+
left: PropTypes.number
|
|
388
|
+
}), PropTypes.func])), _defineProperty(_defineProperty2, "menuOptionsClass", PropTypes.string), _defineProperty(_defineProperty2, "onClick", PropTypes.func), _defineProperty(_defineProperty2, "onClose", PropTypes.func), _defineProperty(_defineProperty2, "onFocus", PropTypes.func), _defineProperty(_defineProperty2, "onKeyDown", PropTypes.func), _defineProperty(_defineProperty2, "onOpen", PropTypes.func), _defineProperty(_defineProperty2, "open", PropTypes.bool), _defineProperty(_defineProperty2, "renderIcon", PropTypes.oneOfType([PropTypes.func, PropTypes.object])), _defineProperty(_defineProperty2, "selectorPrimaryFocus", PropTypes.string), _defineProperty(_defineProperty2, "size", PropTypes.oneOf(['sm', 'md', 'lg'])), _defineProperty2));
|
|
500
389
|
|
|
501
390
|
_defineProperty(OverflowMenu, "contextType", PrefixContext);
|
|
502
391
|
|
|
503
|
-
_defineProperty(OverflowMenu, "defaultProps", {
|
|
504
|
-
ariaLabel: null,
|
|
505
|
-
iconDescription: 'Options',
|
|
506
|
-
open: false,
|
|
507
|
-
direction: DIRECTION_BOTTOM,
|
|
508
|
-
flipped: false,
|
|
509
|
-
focusTrap: true,
|
|
510
|
-
renderIcon: OverflowMenuVertical,
|
|
511
|
-
onClick: function onClick() {},
|
|
512
|
-
onKeyDown: function onKeyDown() {},
|
|
513
|
-
onClose: function onClose() {},
|
|
514
|
-
onOpen: function onOpen() {},
|
|
515
|
-
menuOffset: getMenuOffset,
|
|
516
|
-
menuOffsetFlip: getMenuOffset,
|
|
517
|
-
selectorPrimaryFocus: '[data-overflow-menu-primary-focus]'
|
|
518
|
-
});
|
|
392
|
+
_defineProperty(OverflowMenu, "defaultProps", (_defineProperty3 = {}, _defineProperty(_defineProperty3, 'aria-label', null), _defineProperty(_defineProperty3, "iconDescription", 'Options'), _defineProperty(_defineProperty3, "open", false), _defineProperty(_defineProperty3, "direction", DIRECTION_BOTTOM), _defineProperty(_defineProperty3, "flipped", false), _defineProperty(_defineProperty3, "focusTrap", true), _defineProperty(_defineProperty3, "renderIcon", OverflowMenuVertical), _defineProperty(_defineProperty3, "onClick", function onClick() {}), _defineProperty(_defineProperty3, "onKeyDown", function onKeyDown() {}), _defineProperty(_defineProperty3, "onClose", function onClose() {}), _defineProperty(_defineProperty3, "onOpen", function onOpen() {}), _defineProperty(_defineProperty3, "menuOffset", getMenuOffset), _defineProperty(_defineProperty3, "menuOffsetFlip", getMenuOffset), _defineProperty(_defineProperty3, "selectorPrimaryFocus", '[data-overflow-menu-primary-focus]'), _defineProperty3));
|
|
519
393
|
((function () {
|
|
520
394
|
var forwardRef = function forwardRef(props, ref) {
|
|
521
395
|
return /*#__PURE__*/React__default.createElement(OverflowMenu, _extends({}, props, {
|
|
@@ -0,0 +1,58 @@
|
|
|
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 { ForwardRefReturn } from '../../types/common';
|
|
9
|
+
export interface OverflowMenuItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
10
|
+
/**
|
|
11
|
+
* The CSS class name to be placed on the button element
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* A callback to tell the parent menu component that the menu should be closed.
|
|
16
|
+
*/
|
|
17
|
+
closeMenu?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* `true` to make this menu item disabled.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
handleOverflowMenuItemFocus?: (options: {
|
|
23
|
+
currentIndex?: number;
|
|
24
|
+
direction: number;
|
|
25
|
+
}) => void;
|
|
26
|
+
/**
|
|
27
|
+
* `true` to make this menu item a divider.
|
|
28
|
+
*/
|
|
29
|
+
hasDivider?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If given, overflow item will render as a link with the given href
|
|
32
|
+
*/
|
|
33
|
+
href?: string;
|
|
34
|
+
index?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The text to show for the menu item
|
|
37
|
+
*/
|
|
38
|
+
itemText?: React.ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* `true` to make this menu item a danger button.
|
|
41
|
+
*/
|
|
42
|
+
isDelete?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* `true` to require the title attribute.
|
|
45
|
+
*/
|
|
46
|
+
requireTitle?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The title attribute.
|
|
49
|
+
*/
|
|
50
|
+
title?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The CSS class name to be placed on the wrapper element
|
|
53
|
+
*/
|
|
54
|
+
wrapperClassName?: string;
|
|
55
|
+
}
|
|
56
|
+
export type OverflowMenuItemComponent = ForwardRefReturn<HTMLElement, OverflowMenuItemProps>;
|
|
57
|
+
declare const OverflowMenuItem: OverflowMenuItemComponent;
|
|
58
|
+
export default OverflowMenuItem;
|
|
@@ -9,8 +9,8 @@ import { objectWithoutProperties as _objectWithoutProperties, defineProperty as
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default from 'react';
|
|
12
|
-
import { warning } from '../../internal/warning.js';
|
|
13
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import { warning } from '../../internal/warning.js';
|
|
14
14
|
import { match } from '../../internal/keyboard/match.js';
|
|
15
15
|
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
16
16
|
|
|
@@ -44,14 +44,14 @@ var OverflowMenuItem = /*#__PURE__*/React__default.forwardRef(function OverflowM
|
|
|
44
44
|
|
|
45
45
|
function setTabFocus(evt) {
|
|
46
46
|
if (match(evt, ArrowDown)) {
|
|
47
|
-
handleOverflowMenuItemFocus({
|
|
47
|
+
handleOverflowMenuItemFocus === null || handleOverflowMenuItemFocus === void 0 ? void 0 : handleOverflowMenuItemFocus({
|
|
48
48
|
currentIndex: index,
|
|
49
49
|
direction: 1
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (match(evt, ArrowUp)) {
|
|
54
|
-
handleOverflowMenuItemFocus({
|
|
54
|
+
handleOverflowMenuItemFocus === null || handleOverflowMenuItemFocus === void 0 ? void 0 : handleOverflowMenuItemFocus({
|
|
55
55
|
currentIndex: index,
|
|
56
56
|
direction: -1
|
|
57
57
|
});
|
|
@@ -91,17 +91,22 @@ var OverflowMenuItem = /*#__PURE__*/React__default.forwardRef(function OverflowM
|
|
|
91
91
|
className: overflowMenuBtnClasses,
|
|
92
92
|
disabled: disabled,
|
|
93
93
|
href: href,
|
|
94
|
-
index: index,
|
|
95
94
|
onClick: handleClick,
|
|
96
95
|
onKeyDown: function onKeyDown(evt) {
|
|
97
96
|
setTabFocus(evt);
|
|
98
97
|
|
|
99
98
|
_onKeyDown(evt);
|
|
100
99
|
},
|
|
101
|
-
role: "menuitem"
|
|
100
|
+
role: "menuitem" // ref as any: the type of `ref` is `ForwardedRef<HTMLButtonElement>` in `Button` component
|
|
101
|
+
// but `OverflowMenuItem` can be rendered as `a` tag as well, which is `HTMLAnchorElement`
|
|
102
|
+
// so we have to use `any` here
|
|
103
|
+
,
|
|
102
104
|
ref: ref,
|
|
103
|
-
tabIndex:
|
|
104
|
-
|
|
105
|
+
tabIndex: -1 // itemText as any: itemText may be a ReactNode, but `title` only accepts string
|
|
106
|
+
// to avoid compatibility issue, we use `any` here. Consider to enforce `itemText` to be `string?`
|
|
107
|
+
// in the next major release
|
|
108
|
+
,
|
|
109
|
+
title: requireTitle ? title || itemText : undefined
|
|
105
110
|
}, rest), OverflowMenuItemContent));
|
|
106
111
|
});
|
|
107
112
|
OverflowMenuItem.propTypes = {
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { objectWithoutProperties as _objectWithoutProperties,
|
|
9
|
-
import React__default, {
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { useRef } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
13
|
-
import { useId } from '../../internal/useId.js';
|
|
14
13
|
import { Menu } from '../Menu/Menu.js';
|
|
14
|
+
import { useId } from '../../internal/useId.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
+
import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
|
|
16
17
|
|
|
17
18
|
var _excluded = ["children", "className", "renderIcon", "size"];
|
|
18
19
|
var defaultSize = 'md';
|
|
@@ -29,53 +30,16 @@ function OverflowMenuV2(_ref) {
|
|
|
29
30
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
30
31
|
|
|
31
32
|
var id = useId('overflowmenu');
|
|
32
|
-
|
|
33
|
-
var _useState = useState(false),
|
|
34
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
-
open = _useState2[0],
|
|
36
|
-
setOpen = _useState2[1];
|
|
37
|
-
|
|
38
|
-
var _useState3 = useState([[0, 0], [0, 0]]),
|
|
39
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
-
position = _useState4[0],
|
|
41
|
-
setPosition = _useState4[1];
|
|
42
|
-
|
|
43
|
-
var triggerRef = useRef(null);
|
|
44
33
|
var prefix = usePrefix();
|
|
34
|
+
var triggerRef = useRef(null);
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setPosition([[left, right], [top, bottom]]);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
setOpen(true);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function closeMenu() {
|
|
61
|
-
setOpen(false);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function handleClick() {
|
|
65
|
-
if (open) {
|
|
66
|
-
closeMenu();
|
|
67
|
-
} else {
|
|
68
|
-
openMenu();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function handleMousedown(e) {
|
|
73
|
-
// prevent default for mousedown on trigger element to avoid
|
|
74
|
-
// the "blur" event from firing on the menu as this would close
|
|
75
|
-
// it and immediately re-open since "click" event is fired after
|
|
76
|
-
// "blur" event.
|
|
77
|
-
e.preventDefault();
|
|
78
|
-
}
|
|
36
|
+
var _useAttachedMenu = useAttachedMenu(triggerRef),
|
|
37
|
+
open = _useAttachedMenu.open,
|
|
38
|
+
x = _useAttachedMenu.x,
|
|
39
|
+
y = _useAttachedMenu.y,
|
|
40
|
+
handleClick = _useAttachedMenu.handleClick,
|
|
41
|
+
handleMousedown = _useAttachedMenu.handleMousedown,
|
|
42
|
+
handleClose = _useAttachedMenu.handleClose;
|
|
79
43
|
|
|
80
44
|
var containerClasses = cx("".concat(prefix, "--overflow-menu__container"));
|
|
81
45
|
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));
|
|
@@ -96,9 +60,9 @@ function OverflowMenuV2(_ref) {
|
|
|
96
60
|
id: id,
|
|
97
61
|
size: size,
|
|
98
62
|
open: open,
|
|
99
|
-
onClose:
|
|
100
|
-
x:
|
|
101
|
-
y:
|
|
63
|
+
onClose: handleClose,
|
|
64
|
+
x: x,
|
|
65
|
+
y: y
|
|
102
66
|
}, children));
|
|
103
67
|
}
|
|
104
68
|
|
|
@@ -13,7 +13,7 @@ interface PopoverBaseProps {
|
|
|
13
13
|
*/
|
|
14
14
|
align?: PopoverAlignment;
|
|
15
15
|
/**
|
|
16
|
-
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to
|
|
16
|
+
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
|
|
17
17
|
*/
|
|
18
18
|
autoAlign?: boolean;
|
|
19
19
|
/**
|
|
@@ -37,6 +37,10 @@ interface PopoverBaseProps {
|
|
|
37
37
|
* Render the component using the high-contrast variant
|
|
38
38
|
*/
|
|
39
39
|
highContrast?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Render the component using the tab tip variant
|
|
42
|
+
*/
|
|
43
|
+
isTabTip?: boolean;
|
|
40
44
|
/**
|
|
41
45
|
* Specify whether the component is currently open or closed
|
|
42
46
|
*/
|
|
@@ -13,7 +13,7 @@ import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
|
13
13
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["align", "as", "autoAlign", "caret", "className", "children", "dropShadow", "highContrast", "open"],
|
|
16
|
+
var _excluded = ["isTabTip", "align", "as", "autoAlign", "caret", "className", "children", "dropShadow", "highContrast", "open"],
|
|
17
17
|
_excluded2 = ["className", "children"];
|
|
18
18
|
var PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
19
19
|
floating: {
|
|
@@ -23,13 +23,14 @@ var PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
|
23
23
|
var Popover = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardRef) {
|
|
24
24
|
var _cx;
|
|
25
25
|
|
|
26
|
-
var
|
|
27
|
-
|
|
26
|
+
var isTabTip = _ref.isTabTip,
|
|
27
|
+
_ref$align = _ref.align,
|
|
28
|
+
align = _ref$align === void 0 ? isTabTip ? 'bottom-left' : 'bottom' : _ref$align,
|
|
28
29
|
as = _ref.as,
|
|
29
30
|
_ref$autoAlign = _ref.autoAlign,
|
|
30
31
|
autoAlign = _ref$autoAlign === void 0 ? false : _ref$autoAlign,
|
|
31
32
|
_ref$caret = _ref.caret,
|
|
32
|
-
caret = _ref$caret === void 0 ? true : _ref$caret,
|
|
33
|
+
caret = _ref$caret === void 0 ? isTabTip ? false : true : _ref$caret,
|
|
33
34
|
customClassName = _ref.className,
|
|
34
35
|
children = _ref.children,
|
|
35
36
|
_ref$dropShadow = _ref.dropShadow,
|
|
@@ -47,6 +48,15 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardRef)
|
|
|
47
48
|
floating: floating
|
|
48
49
|
};
|
|
49
50
|
}, []);
|
|
51
|
+
|
|
52
|
+
if (isTabTip) {
|
|
53
|
+
var tabTipAlignments = ['bottom-left', 'bottom-right'];
|
|
54
|
+
|
|
55
|
+
if (!tabTipAlignments.includes(align)) {
|
|
56
|
+
align = 'bottom-left';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
50
60
|
var ref = useMergedRefs([forwardRef, popover]);
|
|
51
61
|
|
|
52
62
|
var _useState = useState(false),
|
|
@@ -59,13 +69,13 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardRef)
|
|
|
59
69
|
autoAlignment = _useState4[0],
|
|
60
70
|
setAutoAlignment = _useState4[1];
|
|
61
71
|
|
|
62
|
-
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned), _cx), customClassName);
|
|
72
|
+
var className = cx((_cx = {}, _defineProperty(_cx, "".concat(prefix, "--popover-container"), true), _defineProperty(_cx, "".concat(prefix, "--popover--caret"), caret), _defineProperty(_cx, "".concat(prefix, "--popover--drop-shadow"), dropShadow), _defineProperty(_cx, "".concat(prefix, "--popover--high-contrast"), highContrast), _defineProperty(_cx, "".concat(prefix, "--popover--open"), open), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(autoAlignment), autoAligned && !isTabTip), _defineProperty(_cx, "".concat(prefix, "--popover--").concat(align), !autoAligned), _defineProperty(_cx, "".concat(prefix, "--popover--tab-tip"), isTabTip), _cx), customClassName);
|
|
63
73
|
useIsomorphicEffect(function () {
|
|
64
74
|
if (!open) {
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
67
77
|
|
|
68
|
-
if (!autoAlign) {
|
|
78
|
+
if (!autoAlign || isTabTip) {
|
|
69
79
|
setAutoAligned(false);
|
|
70
80
|
return;
|
|
71
81
|
}
|
|
@@ -156,14 +166,27 @@ var Popover = /*#__PURE__*/React__default.forwardRef(function (_ref, forwardRef)
|
|
|
156
166
|
setAutoAligned(true);
|
|
157
167
|
setAutoAlignment(alignment);
|
|
158
168
|
}
|
|
159
|
-
}, [autoAligned, align, autoAlign, prefix, open]);
|
|
169
|
+
}, [autoAligned, align, autoAlign, prefix, open, isTabTip]);
|
|
160
170
|
var BaseComponent = as !== null && as !== void 0 ? as : 'span';
|
|
171
|
+
var mappedChildren = React__default.Children.map(children, function (child) {
|
|
172
|
+
var item = child;
|
|
173
|
+
|
|
174
|
+
if ((item === null || item === void 0 ? void 0 : item.type) === 'button') {
|
|
175
|
+
var _className = item.props.className;
|
|
176
|
+
var tabTipClasses = cx("".concat(prefix, "--popover--tab-tip__button"), _className);
|
|
177
|
+
return /*#__PURE__*/React__default.cloneElement(item, {
|
|
178
|
+
className: tabTipClasses
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
return item;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
161
184
|
return /*#__PURE__*/React__default.createElement(PopoverContext.Provider, {
|
|
162
185
|
value: value
|
|
163
186
|
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
164
187
|
className: className,
|
|
165
188
|
ref: ref
|
|
166
|
-
}), children));
|
|
189
|
+
}), isTabTip ? mappedChildren : children));
|
|
167
190
|
}); // Note: this displayName is temporarily set so that Storybook ArgTable
|
|
168
191
|
// correctly displays the name of this component
|
|
169
192
|
|
|
@@ -184,7 +207,7 @@ Popover.propTypes = {
|
|
|
184
207
|
as: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
185
208
|
|
|
186
209
|
/**
|
|
187
|
-
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to
|
|
210
|
+
* Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
|
|
188
211
|
*/
|
|
189
212
|
autoAlign: PropTypes.bool,
|
|
190
213
|
|
|
@@ -214,6 +237,11 @@ Popover.propTypes = {
|
|
|
214
237
|
*/
|
|
215
238
|
highContrast: PropTypes.bool,
|
|
216
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Render the component using the tab tip variant
|
|
242
|
+
*/
|
|
243
|
+
isTabTip: PropTypes.bool,
|
|
244
|
+
|
|
217
245
|
/**
|
|
218
246
|
* Specify whether the component is currently open or closed
|
|
219
247
|
*/
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
8
|
+
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, defineProperty as _defineProperty, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React__default, { useState } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Legend } from '../Text/index.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
|
|
15
|
+
var _excluded = ["children", "className", "defaultSelected", "disabled", "labelPosition", "legendText", "name", "onChange", "orientation", "readOnly", "valueSelected"];
|
|
15
16
|
var RadioButtonGroup = /*#__PURE__*/React__default.forwardRef(function RadioButtonGroup(_ref, ref) {
|
|
16
17
|
var _classNames;
|
|
17
18
|
|
|
@@ -28,7 +29,9 @@ var RadioButtonGroup = /*#__PURE__*/React__default.forwardRef(function RadioButt
|
|
|
28
29
|
_ref$orientation = _ref.orientation,
|
|
29
30
|
orientation = _ref$orientation === void 0 ? 'horizontal' : _ref$orientation,
|
|
30
31
|
readOnly = _ref.readOnly,
|
|
31
|
-
valueSelected = _ref.valueSelected
|
|
32
|
+
valueSelected = _ref.valueSelected,
|
|
33
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
|
|
32
35
|
var prefix = usePrefix();
|
|
33
36
|
|
|
34
37
|
var _useState = useState(valueSelected !== null && valueSelected !== void 0 ? valueSelected : defaultSelected),
|
|
@@ -85,11 +88,11 @@ var RadioButtonGroup = /*#__PURE__*/React__default.forwardRef(function RadioButt
|
|
|
85
88
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
86
89
|
className: wrapperClasses,
|
|
87
90
|
ref: ref
|
|
88
|
-
}, /*#__PURE__*/React__default.createElement("fieldset", {
|
|
91
|
+
}, /*#__PURE__*/React__default.createElement("fieldset", _extends({
|
|
89
92
|
className: fieldsetClasses,
|
|
90
93
|
disabled: disabled,
|
|
91
94
|
"aria-readonly": readOnly
|
|
92
|
-
}, legendText && /*#__PURE__*/React__default.createElement(Legend, {
|
|
95
|
+
}, rest), legendText && /*#__PURE__*/React__default.createElement(Legend, {
|
|
93
96
|
className: "".concat(prefix, "--label")
|
|
94
97
|
}, legendText), getRadioButtons()));
|
|
95
98
|
});
|
|
@@ -19,8 +19,7 @@ import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
|
19
19
|
var _CheckmarkFilled;
|
|
20
20
|
|
|
21
21
|
var _excluded = ["children", "className", "disabled", "light", "checked", "name", "value", "id", "onChange", "tabIndex"];
|
|
22
|
-
|
|
23
|
-
function RadioTile(_ref) {
|
|
22
|
+
var RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref, ref) {
|
|
24
23
|
var _cx;
|
|
25
24
|
|
|
26
25
|
var children = _ref.children,
|
|
@@ -60,7 +59,8 @@ function RadioTile(_ref) {
|
|
|
60
59
|
onKeyDown: !disabled ? handleOnKeyDown : null,
|
|
61
60
|
tabIndex: !disabled ? tabIndex : null,
|
|
62
61
|
type: "radio",
|
|
63
|
-
value: value
|
|
62
|
+
value: value,
|
|
63
|
+
ref: ref
|
|
64
64
|
}), /*#__PURE__*/React__default.createElement("label", _extends({}, rest, {
|
|
65
65
|
htmlFor: inputId,
|
|
66
66
|
className: className
|
|
@@ -69,8 +69,7 @@ function RadioTile(_ref) {
|
|
|
69
69
|
}, _CheckmarkFilled || (_CheckmarkFilled = /*#__PURE__*/React__default.createElement(CheckmarkFilled, null))), /*#__PURE__*/React__default.createElement("span", {
|
|
70
70
|
className: "".concat(prefix, "--tile-content")
|
|
71
71
|
}, children)));
|
|
72
|
-
}
|
|
73
|
-
|
|
72
|
+
});
|
|
74
73
|
RadioTile.propTypes = {
|
|
75
74
|
/**
|
|
76
75
|
* `true` if this tile should be selected.
|
|
@@ -127,5 +126,6 @@ RadioTile.defaultProps = {
|
|
|
127
126
|
onChange: function onChange() {},
|
|
128
127
|
tabIndex: 0
|
|
129
128
|
};
|
|
129
|
+
var RadioTile$1 = RadioTile;
|
|
130
130
|
|
|
131
|
-
export { RadioTile as default };
|
|
131
|
+
export { RadioTile$1 as default };
|