@carbon/react 1.30.0 → 1.31.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/Accordion/Accordion.js +3 -1
- package/es/components/Button/Button.js +6 -1
- package/es/components/Checkbox/Checkbox.js +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +6 -5
- package/es/components/ContainedList/ContainedList.js +12 -4
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/es/components/CopyButton/CopyButton.js +8 -2
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/es/components/DataTableSkeleton/index.d.ts +9 -0
- package/es/components/FileUploader/FileUploaderButton.js +2 -1
- package/es/components/IconButton/index.js +10 -2
- package/es/components/Layout/index.js +118 -0
- package/es/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +2 -1
- package/es/components/MenuButton/index.js +7 -4
- package/es/components/OverflowMenu/index.js +9 -1
- package/es/components/OverflowMenu/next/index.js +98 -0
- package/es/components/OverflowMenuV2/index.js +15 -73
- package/es/components/Tabs/Tabs.js +5 -1
- package/es/components/Tag/Tag.js +2 -0
- package/es/components/TextArea/TextArea.Skeleton.js +1 -2
- package/es/components/TextArea/TextArea.js +1 -2
- package/es/components/TextArea/index.d.ts +10 -0
- package/es/components/TextInput/PasswordInput.js +1 -2
- package/es/components/TextInput/TextInput.Skeleton.js +1 -2
- package/es/components/TextInput/TextInput.js +5 -4
- package/es/components/TextInput/index.d.ts +4 -0
- package/es/components/TimePicker/TimePicker.d.ts +8 -0
- package/es/components/TimePicker/TimePicker.js +26 -6
- package/es/components/Tooltip/Tooltip.js +4 -2
- package/es/components/UIShell/SideNav.d.ts +2 -1
- package/es/components/UIShell/SideNav.js +25 -7
- package/es/index.d.ts +21 -20
- package/es/index.js +28 -26
- package/lib/components/Accordion/Accordion.js +3 -1
- package/lib/components/Button/Button.js +6 -1
- package/lib/components/Checkbox/Checkbox.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +6 -5
- package/lib/components/ContainedList/ContainedList.js +12 -4
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/lib/components/CopyButton/CopyButton.js +8 -2
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/lib/components/DataTableSkeleton/index.d.ts +9 -0
- package/lib/components/FileUploader/FileUploaderButton.js +2 -1
- package/lib/components/IconButton/index.js +10 -2
- package/lib/components/Layout/index.js +129 -0
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +2 -1
- package/lib/components/MenuButton/index.js +7 -4
- package/lib/components/OverflowMenu/index.js +13 -1
- package/lib/components/OverflowMenu/next/index.js +108 -0
- package/lib/components/OverflowMenuV2/index.js +14 -74
- package/lib/components/Tabs/Tabs.js +5 -1
- package/lib/components/Tag/Tag.js +2 -0
- package/lib/components/TextArea/TextArea.Skeleton.js +1 -2
- package/lib/components/TextArea/TextArea.js +1 -2
- package/lib/components/TextArea/index.d.ts +10 -0
- package/lib/components/TextInput/PasswordInput.js +1 -2
- package/lib/components/TextInput/TextInput.Skeleton.js +1 -2
- package/lib/components/TextInput/TextInput.js +5 -4
- package/lib/components/TextInput/index.d.ts +4 -0
- package/lib/components/TimePicker/TimePicker.d.ts +8 -0
- package/lib/components/TimePicker/TimePicker.js +26 -6
- package/lib/components/Tooltip/Tooltip.js +4 -2
- package/lib/components/UIShell/SideNav.d.ts +2 -1
- package/lib/components/UIShell/SideNav.js +24 -6
- package/lib/index.d.ts +21 -20
- package/lib/index.js +88 -85
- package/package.json +8 -8
- /package/es/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
|
@@ -18,13 +18,15 @@ function Accordion(_ref) {
|
|
|
18
18
|
className: customClassName,
|
|
19
19
|
disabled = false,
|
|
20
20
|
isFlush = false,
|
|
21
|
-
size
|
|
21
|
+
size,
|
|
22
22
|
...rest
|
|
23
23
|
} = _ref;
|
|
24
24
|
const prefix = usePrefix();
|
|
25
25
|
const className = cx(`${prefix}--accordion`, customClassName, {
|
|
26
26
|
[`${prefix}--accordion--${align}`]: align,
|
|
27
27
|
[`${prefix}--accordion--${size}`]: size,
|
|
28
|
+
// TODO: V12 - Remove this class
|
|
29
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
28
30
|
[`${prefix}--accordion--flush`]: isFlush && align !== 'start'
|
|
29
31
|
});
|
|
30
32
|
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
@@ -34,7 +34,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
|
|
|
34
34
|
onMouseEnter,
|
|
35
35
|
onMouseLeave,
|
|
36
36
|
renderIcon: ButtonImageElement,
|
|
37
|
-
size
|
|
37
|
+
size,
|
|
38
38
|
tabIndex,
|
|
39
39
|
tooltipAlignment = 'center',
|
|
40
40
|
tooltipPosition = 'top',
|
|
@@ -53,9 +53,14 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
|
|
|
53
53
|
const buttonClasses = cx(className, {
|
|
54
54
|
[`${prefix}--btn`]: true,
|
|
55
55
|
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
56
|
+
// TODO: V12 - Remove this class
|
|
56
57
|
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
58
|
+
// TODO: V12 - Remove this class
|
|
57
59
|
[`${prefix}--btn--xl`]: size === 'xl',
|
|
60
|
+
// TODO: V12 - Remove this class
|
|
58
61
|
[`${prefix}--btn--2xl`]: size === '2xl',
|
|
62
|
+
// TODO: V12 - Remove this class
|
|
63
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
59
64
|
[`${prefix}--btn--${kind}`]: kind,
|
|
60
65
|
[`${prefix}--btn--disabled`]: disabled,
|
|
61
66
|
[`${prefix}--btn--expressive`]: isExpressive,
|
|
@@ -67,8 +67,8 @@ const Checkbox = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
67
67
|
className: `${prefix}--checkbox`,
|
|
68
68
|
id: id,
|
|
69
69
|
ref: el => {
|
|
70
|
-
if (el
|
|
71
|
-
el.indeterminate = indeterminate;
|
|
70
|
+
if (el) {
|
|
71
|
+
el.indeterminate = indeterminate ?? false;
|
|
72
72
|
}
|
|
73
73
|
if (typeof ref === 'function') {
|
|
74
74
|
ref(el);
|
|
@@ -199,6 +199,7 @@ function CodeSnippet(_ref) {
|
|
|
199
199
|
}), hasRightOverflow && type !== 'multi' && /*#__PURE__*/React__default.createElement("div", {
|
|
200
200
|
className: `${prefix}--snippet__overflow-indicator--right`
|
|
201
201
|
}), !hideCopyButton && /*#__PURE__*/React__default.createElement(CopyButton, {
|
|
202
|
+
size: type === 'multi' ? 'sm' : 'md',
|
|
202
203
|
disabled: disabled,
|
|
203
204
|
onClick: handleCopyClick,
|
|
204
205
|
feedback: feedback,
|
|
@@ -34,7 +34,7 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
34
34
|
label,
|
|
35
35
|
onClick,
|
|
36
36
|
size = 'lg',
|
|
37
|
-
|
|
37
|
+
tooltipAlignment,
|
|
38
38
|
translateWithId: t = defaultTranslateWithId,
|
|
39
39
|
...rest
|
|
40
40
|
} = _ref;
|
|
@@ -76,7 +76,8 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
76
76
|
const triggerClasses = cx(`${prefix}--combo-button__trigger`);
|
|
77
77
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
78
78
|
className: containerClasses,
|
|
79
|
-
ref: ref
|
|
79
|
+
ref: ref,
|
|
80
|
+
"aria-owns": open ? id : null
|
|
80
81
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
81
82
|
className: primaryActionClasses
|
|
82
83
|
}, /*#__PURE__*/React__default.createElement(Button, {
|
|
@@ -88,12 +89,12 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
88
89
|
label: t('carbon.combo-button.additional-actions'),
|
|
89
90
|
size: size,
|
|
90
91
|
disabled: disabled,
|
|
91
|
-
align:
|
|
92
|
+
align: tooltipAlignment,
|
|
92
93
|
"aria-haspopup": true,
|
|
93
94
|
"aria-expanded": open,
|
|
94
95
|
onClick: handleTriggerClick,
|
|
95
96
|
onMouseDown: handleTriggerMousedown,
|
|
96
|
-
"aria-
|
|
97
|
+
"aria-controls": open ? id : null
|
|
97
98
|
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null))), /*#__PURE__*/React__default.createElement(Menu, {
|
|
98
99
|
ref: menuRef,
|
|
99
100
|
id: id,
|
|
@@ -134,7 +135,7 @@ ComboButton.propTypes = {
|
|
|
134
135
|
/**
|
|
135
136
|
* Specify how the trigger tooltip should be aligned.
|
|
136
137
|
*/
|
|
137
|
-
|
|
138
|
+
tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
138
139
|
/**
|
|
139
140
|
* Optional method that takes in a message id and returns an
|
|
140
141
|
* internationalized string.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import React__default from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
+
import { LayoutConstraint } from '../Layout/index.js';
|
|
11
12
|
import { useId } from '../../internal/useId.js';
|
|
12
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
14
|
|
|
@@ -43,13 +44,16 @@ function ContainedList(_ref) {
|
|
|
43
44
|
isInset,
|
|
44
45
|
kind = variants[0],
|
|
45
46
|
label,
|
|
46
|
-
size
|
|
47
|
+
size
|
|
47
48
|
} = _ref;
|
|
48
49
|
const labelId = `${useId('contained-list')}-header`;
|
|
49
50
|
const prefix = usePrefix();
|
|
50
51
|
const classes = cx(`${prefix}--contained-list`, {
|
|
51
|
-
[`${prefix}--contained-list--inset-rulers`]: isInset
|
|
52
|
-
|
|
52
|
+
[`${prefix}--contained-list--inset-rulers`]: isInset,
|
|
53
|
+
[`${prefix}--contained-list--${size}`]: size,
|
|
54
|
+
// TODO: V12 - Remove this class
|
|
55
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
56
|
+
}, `${prefix}--contained-list--${kind}`, className);
|
|
53
57
|
const filteredChildren = filterChildren(children);
|
|
54
58
|
const isActionSearch = ['Search', 'ExpandableSearch'].includes(action?.type?.displayName);
|
|
55
59
|
const renderedChildren = renderChildren(children);
|
|
@@ -60,7 +64,11 @@ function ContainedList(_ref) {
|
|
|
60
64
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
61
65
|
id: labelId,
|
|
62
66
|
className: `${prefix}--contained-list__label`
|
|
63
|
-
}, label), /*#__PURE__*/React__default.createElement(
|
|
67
|
+
}, label), /*#__PURE__*/React__default.createElement(LayoutConstraint, {
|
|
68
|
+
size: {
|
|
69
|
+
min: 'sm',
|
|
70
|
+
max: 'xl'
|
|
71
|
+
},
|
|
64
72
|
className: `${prefix}--contained-list__action`
|
|
65
73
|
}, action)), children && /*#__PURE__*/React__default.createElement("ul", {
|
|
66
74
|
"aria-labelledby": labelId
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import React__default from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
+
import { LayoutConstraint } from '../../Layout/index.js';
|
|
11
12
|
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
12
13
|
|
|
13
14
|
function ContainedListItem(_ref) {
|
|
@@ -38,7 +39,11 @@ function ContainedListItem(_ref) {
|
|
|
38
39
|
onClick: onClick
|
|
39
40
|
}, content) : /*#__PURE__*/React__default.createElement("div", {
|
|
40
41
|
className: `${prefix}--contained-list-item__content`
|
|
41
|
-
}, content), action && /*#__PURE__*/React__default.createElement(
|
|
42
|
+
}, content), action && /*#__PURE__*/React__default.createElement(LayoutConstraint, {
|
|
43
|
+
size: {
|
|
44
|
+
min: 'sm',
|
|
45
|
+
max: 'lg'
|
|
46
|
+
},
|
|
42
47
|
className: `${prefix}--contained-list-item__action`
|
|
43
48
|
}, action));
|
|
44
49
|
}
|
|
@@ -10,6 +10,7 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import React__default from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
|
+
import { LayoutConstraint } from '../Layout/index.js';
|
|
13
14
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
14
15
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
15
16
|
import { matches } from '../../internal/keyboard/match.js';
|
|
@@ -107,9 +108,17 @@ class ContentSwitcher extends React__default.Component {
|
|
|
107
108
|
const classes = cx(`${prefix}--content-switcher`, className, {
|
|
108
109
|
[`${prefix}--content-switcher--light`]: light,
|
|
109
110
|
[`${prefix}--content-switcher--${size}`]: size,
|
|
111
|
+
// TODO: V12 - Remove this class
|
|
112
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
110
113
|
[`${prefix}--content-switcher--icon-only`]: isIconOnly
|
|
111
114
|
});
|
|
112
|
-
return /*#__PURE__*/React__default.createElement(
|
|
115
|
+
return /*#__PURE__*/React__default.createElement(LayoutConstraint, _extends({
|
|
116
|
+
size: {
|
|
117
|
+
default: 'md',
|
|
118
|
+
min: 'sm',
|
|
119
|
+
max: 'lg'
|
|
120
|
+
}
|
|
121
|
+
}, other, {
|
|
113
122
|
className: classes,
|
|
114
123
|
role: "tablist"
|
|
115
124
|
}), React__default.Children.map(children, (child, index) => /*#__PURE__*/React__default.cloneElement(child, {
|
|
@@ -11,6 +11,7 @@ import React__default from 'react';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Copy as Copy$1 } from '@carbon/icons-react';
|
|
13
13
|
import Copy from '../Copy/Copy.js';
|
|
14
|
+
import { LayoutConstraint } from '../Layout/index.js';
|
|
14
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
16
|
|
|
16
17
|
function CopyButton(_ref) {
|
|
@@ -20,12 +21,17 @@ function CopyButton(_ref) {
|
|
|
20
21
|
...other
|
|
21
22
|
} = _ref;
|
|
22
23
|
const prefix = usePrefix();
|
|
23
|
-
return /*#__PURE__*/React__default.createElement(
|
|
24
|
+
return /*#__PURE__*/React__default.createElement(LayoutConstraint, {
|
|
25
|
+
size: {
|
|
26
|
+
default: 'md',
|
|
27
|
+
max: 'lg'
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React__default.createElement(Copy, _extends({
|
|
24
30
|
className: cx(className, `${prefix}--copy-btn`),
|
|
25
31
|
"aria-label": iconDescription
|
|
26
32
|
}, other), /*#__PURE__*/React__default.createElement(Copy$1, {
|
|
27
33
|
className: `${prefix}--snippet__icon`
|
|
28
|
-
}));
|
|
34
|
+
})));
|
|
29
35
|
}
|
|
30
36
|
CopyButton.propTypes = {
|
|
31
37
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import DataTableSkeleton from './DataTableSkeleton';
|
|
8
|
+
export default DataTableSkeleton;
|
|
9
|
+
export { DataTableSkeleton };
|
|
@@ -46,7 +46,8 @@ function FileUploaderButton(_ref) {
|
|
|
46
46
|
[`${prefix}--btn--disabled`]: disabled,
|
|
47
47
|
// V11: remove field, small
|
|
48
48
|
[`${prefix}--btn--md`]: size === 'field' || size === 'md',
|
|
49
|
-
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm'
|
|
49
|
+
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm',
|
|
50
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
// Adjust label text state based on changes to the labelText prop
|
|
@@ -21,16 +21,19 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(pr
|
|
|
21
21
|
className,
|
|
22
22
|
closeOnActivation = true,
|
|
23
23
|
defaultOpen = false,
|
|
24
|
+
disabled,
|
|
24
25
|
enterDelayMs,
|
|
25
26
|
kind,
|
|
26
27
|
label,
|
|
27
28
|
leaveDelayMs,
|
|
28
29
|
wrapperClasses,
|
|
29
|
-
size
|
|
30
|
+
size,
|
|
30
31
|
...rest
|
|
31
32
|
} = props;
|
|
32
33
|
const prefix = usePrefix();
|
|
33
|
-
const tooltipClasses = cx(wrapperClasses, `${prefix}--icon-tooltip
|
|
34
|
+
const tooltipClasses = cx(wrapperClasses, `${prefix}--icon-tooltip`, {
|
|
35
|
+
[`${prefix}--icon-tooltip--disabled`]: disabled
|
|
36
|
+
});
|
|
34
37
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
35
38
|
align: align,
|
|
36
39
|
closeOnActivation: closeOnActivation,
|
|
@@ -40,6 +43,7 @@ const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(pr
|
|
|
40
43
|
label: label,
|
|
41
44
|
leaveDelayMs: leaveDelayMs
|
|
42
45
|
}, /*#__PURE__*/React__default.createElement(Button, _extends({}, rest, {
|
|
46
|
+
disabled: disabled,
|
|
43
47
|
kind: kind,
|
|
44
48
|
ref: ref,
|
|
45
49
|
size: size,
|
|
@@ -67,6 +71,10 @@ IconButton.propTypes = {
|
|
|
67
71
|
* Specify whether the tooltip should be open when it first renders
|
|
68
72
|
*/
|
|
69
73
|
defaultOpen: PropTypes.bool,
|
|
74
|
+
/**
|
|
75
|
+
* Specify whether the Button should be disabled, or not
|
|
76
|
+
*/
|
|
77
|
+
disabled: PropTypes.bool,
|
|
70
78
|
/**
|
|
71
79
|
* Specify the duration in milliseconds to delay before displaying the tooltip
|
|
72
80
|
*/
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import cx from 'classnames';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import React__default from 'react';
|
|
12
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
|
|
14
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl'];
|
|
15
|
+
const densities = ['condensed', 'normal'];
|
|
16
|
+
const Layout = /*#__PURE__*/React__default.forwardRef(function Layout(_ref, forwardRef) {
|
|
17
|
+
let {
|
|
18
|
+
as: BaseComponent = 'div',
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
density,
|
|
22
|
+
size,
|
|
23
|
+
...rest
|
|
24
|
+
} = _ref;
|
|
25
|
+
const prefix = usePrefix();
|
|
26
|
+
const classes = cx(className, `${prefix}--layout`, {
|
|
27
|
+
[`${prefix}--layout--size-${size}`]: sizes.includes(size),
|
|
28
|
+
[`${prefix}--layout--density-${density}`]: densities.includes(density)
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
31
|
+
ref: forwardRef,
|
|
32
|
+
className: classes
|
|
33
|
+
}), children);
|
|
34
|
+
});
|
|
35
|
+
Layout.propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* Specify a custom component or element to be rendered as the top-level
|
|
38
|
+
* element in the component
|
|
39
|
+
*/
|
|
40
|
+
as: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.elementType]),
|
|
41
|
+
/**
|
|
42
|
+
* Provide child elements to be rendered inside of `Layout`
|
|
43
|
+
*/
|
|
44
|
+
children: PropTypes.node,
|
|
45
|
+
/**
|
|
46
|
+
* Provide a custom class name to be used on the outermost element rendered by
|
|
47
|
+
* the component
|
|
48
|
+
*/
|
|
49
|
+
className: PropTypes.string,
|
|
50
|
+
/**
|
|
51
|
+
* Specify the desired density of components within this layout
|
|
52
|
+
*/
|
|
53
|
+
density: PropTypes.oneOf(densities),
|
|
54
|
+
/**
|
|
55
|
+
* Specify the desired size of components within this layout
|
|
56
|
+
*/
|
|
57
|
+
size: PropTypes.oneOf(sizes)
|
|
58
|
+
};
|
|
59
|
+
const LayoutConstraint = /*#__PURE__*/React__default.forwardRef(function Layout(_ref2, forwardRef) {
|
|
60
|
+
let {
|
|
61
|
+
as: BaseComponent = 'div',
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
density,
|
|
65
|
+
size,
|
|
66
|
+
...rest
|
|
67
|
+
} = _ref2;
|
|
68
|
+
const prefix = usePrefix();
|
|
69
|
+
const classes = cx(className, Object.entries({
|
|
70
|
+
size,
|
|
71
|
+
density
|
|
72
|
+
}).map(_ref3 => {
|
|
73
|
+
let [group, constraints] = _ref3;
|
|
74
|
+
return {
|
|
75
|
+
[`${prefix}--layout-constraint--${group}:default-${constraints?.default}`]: constraints?.default,
|
|
76
|
+
[`${prefix}--layout-constraint--${group}:min-${constraints?.min}`]: constraints?.min,
|
|
77
|
+
[`${prefix}--layout-constraint--${group}:max-${constraints?.max}`]: constraints?.max
|
|
78
|
+
};
|
|
79
|
+
}));
|
|
80
|
+
return /*#__PURE__*/React__default.createElement(BaseComponent, _extends({}, rest, {
|
|
81
|
+
ref: forwardRef,
|
|
82
|
+
className: classes
|
|
83
|
+
}), children);
|
|
84
|
+
});
|
|
85
|
+
LayoutConstraint.propTypes = {
|
|
86
|
+
/**
|
|
87
|
+
* Specify a custom component or element to be rendered as the top-level
|
|
88
|
+
* element in the component
|
|
89
|
+
*/
|
|
90
|
+
as: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.elementType]),
|
|
91
|
+
/**
|
|
92
|
+
* Provide child elements to be rendered inside of `LayoutConstraint`
|
|
93
|
+
*/
|
|
94
|
+
children: PropTypes.node,
|
|
95
|
+
/**
|
|
96
|
+
* Provide a custom class name to be used on the outermost element rendered by
|
|
97
|
+
* the component
|
|
98
|
+
*/
|
|
99
|
+
className: PropTypes.string,
|
|
100
|
+
/**
|
|
101
|
+
* Specify the desired layout density constraints of this element's children
|
|
102
|
+
*/
|
|
103
|
+
density: PropTypes.shape({
|
|
104
|
+
min: PropTypes.oneOf(densities),
|
|
105
|
+
default: PropTypes.oneOf(densities),
|
|
106
|
+
max: PropTypes.oneOf(densities)
|
|
107
|
+
}),
|
|
108
|
+
/**
|
|
109
|
+
* Specify the desired layout size constraints of this element's children
|
|
110
|
+
*/
|
|
111
|
+
size: PropTypes.shape({
|
|
112
|
+
min: PropTypes.oneOf(sizes),
|
|
113
|
+
default: PropTypes.oneOf(sizes),
|
|
114
|
+
max: PropTypes.oneOf(sizes)
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export { Layout, LayoutConstraint };
|
|
@@ -10,5 +10,5 @@ declare const listBoxSizes: readonly ["sm", "md", "lg"];
|
|
|
10
10
|
export type ListBoxType = (typeof listBoxTypes)[number];
|
|
11
11
|
export type ListBoxSize = (typeof listBoxSizes)[number];
|
|
12
12
|
export declare const ListBoxType: PropTypes.Requireable<"default" | "inline">;
|
|
13
|
-
export declare const ListBoxSize: PropTypes.Requireable<"
|
|
13
|
+
export declare const ListBoxSize: PropTypes.Requireable<"sm" | "md" | "lg">;
|
|
14
14
|
export {};
|
|
@@ -280,12 +280,13 @@ MenuItemGroup.propTypes = {
|
|
|
280
280
|
*/
|
|
281
281
|
label: PropTypes.string.isRequired
|
|
282
282
|
};
|
|
283
|
+
const defaultItemToString = item => item.toString();
|
|
283
284
|
const MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuItemRadioGroup(_ref4, forwardRef) {
|
|
284
285
|
let {
|
|
285
286
|
className,
|
|
286
287
|
defaultSelectedItem,
|
|
287
288
|
items,
|
|
288
|
-
itemToString =
|
|
289
|
+
itemToString = defaultItemToString,
|
|
289
290
|
label,
|
|
290
291
|
onChange,
|
|
291
292
|
selectedItem,
|
|
@@ -58,10 +58,13 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
|
|
|
58
58
|
}
|
|
59
59
|
const triggerClasses = cx(`${prefix}--menu-button__trigger`, {
|
|
60
60
|
[`${prefix}--menu-button__trigger--open`]: open
|
|
61
|
-
}
|
|
61
|
+
});
|
|
62
62
|
const buttonKind = validButtonKinds.includes(kind) ? kind : defaultButtonKind;
|
|
63
|
-
return /*#__PURE__*/React__default.createElement(
|
|
63
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
64
64
|
ref: ref,
|
|
65
|
+
"aria-owns": open ? id : null,
|
|
66
|
+
className: className
|
|
67
|
+
}), /*#__PURE__*/React__default.createElement(Button, {
|
|
65
68
|
className: triggerClasses,
|
|
66
69
|
size: size,
|
|
67
70
|
kind: buttonKind,
|
|
@@ -71,8 +74,8 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
|
|
|
71
74
|
"aria-expanded": open,
|
|
72
75
|
onClick: handleClick,
|
|
73
76
|
onMouseDown: handleMousedown,
|
|
74
|
-
"aria-
|
|
75
|
-
}
|
|
77
|
+
"aria-controls": open ? id : null
|
|
78
|
+
}, label), /*#__PURE__*/React__default.createElement(Menu, {
|
|
76
79
|
ref: menuRef,
|
|
77
80
|
id: id,
|
|
78
81
|
label: label,
|
|
@@ -5,9 +5,17 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import React__default from 'react';
|
|
9
|
+
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
10
|
+
import { OverflowMenu as OverflowMenu$2 } from './next/index.js';
|
|
8
11
|
import { OverflowMenu as OverflowMenu$1 } from './OverflowMenu.js';
|
|
9
12
|
import { createClassWrapper } from '../../internal/createClassWrapper.js';
|
|
10
13
|
|
|
11
|
-
const
|
|
14
|
+
const OverflowMenuV11 = createClassWrapper(OverflowMenu$1);
|
|
15
|
+
function OverflowMenu(props) {
|
|
16
|
+
const enableV12OverflowMenu = useFeatureFlag('enable-v12-overflowmenu');
|
|
17
|
+
return enableV12OverflowMenu ? /*#__PURE__*/React__default.createElement(OverflowMenu$2, props) : /*#__PURE__*/React__default.createElement(OverflowMenuV11, props);
|
|
18
|
+
}
|
|
19
|
+
OverflowMenu.displayName = 'OverflowMenu';
|
|
12
20
|
|
|
13
21
|
export { OverflowMenu, OverflowMenu as default };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import React__default, { useRef } from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
13
|
+
import { IconButton } from '../../IconButton/index.js';
|
|
14
|
+
import { Menu } from '../../Menu/Menu.js';
|
|
15
|
+
import { useId } from '../../../internal/useId.js';
|
|
16
|
+
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
17
|
+
import { useAttachedMenu } from '../../../internal/useAttachedMenu.js';
|
|
18
|
+
|
|
19
|
+
const defaultSize = 'md';
|
|
20
|
+
const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMenu(_ref, forwardRef) {
|
|
21
|
+
let {
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
label = 'Options',
|
|
25
|
+
renderIcon: IconElement = OverflowMenuVertical,
|
|
26
|
+
size = defaultSize,
|
|
27
|
+
tooltipAlignment,
|
|
28
|
+
...rest
|
|
29
|
+
} = _ref;
|
|
30
|
+
const id = useId('overflowmenu');
|
|
31
|
+
const prefix = usePrefix();
|
|
32
|
+
const triggerRef = useRef(null);
|
|
33
|
+
const {
|
|
34
|
+
open,
|
|
35
|
+
x,
|
|
36
|
+
y,
|
|
37
|
+
handleClick,
|
|
38
|
+
handleMousedown,
|
|
39
|
+
handleClose
|
|
40
|
+
} = useAttachedMenu(triggerRef);
|
|
41
|
+
const containerClasses = cx(className, `${prefix}--overflow-menu__container`);
|
|
42
|
+
const triggerClasses = cx(`${prefix}--overflow-menu`, {
|
|
43
|
+
[`${prefix}--overflow-menu--open`]: open
|
|
44
|
+
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
45
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
|
|
46
|
+
className: containerClasses,
|
|
47
|
+
"aria-owns": open ? id : null,
|
|
48
|
+
ref: forwardRef
|
|
49
|
+
}), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
50
|
+
"aria-controls": open ? id : null,
|
|
51
|
+
"aria-haspopup": true,
|
|
52
|
+
"aria-expanded": open,
|
|
53
|
+
className: triggerClasses,
|
|
54
|
+
onClick: handleClick,
|
|
55
|
+
onMouseDown: handleMousedown,
|
|
56
|
+
ref: triggerRef,
|
|
57
|
+
label: label,
|
|
58
|
+
align: tooltipAlignment
|
|
59
|
+
}, /*#__PURE__*/React__default.createElement(IconElement, {
|
|
60
|
+
className: `${prefix}--overflow-menu__icon`
|
|
61
|
+
})), /*#__PURE__*/React__default.createElement(Menu, {
|
|
62
|
+
id: id,
|
|
63
|
+
size: size,
|
|
64
|
+
open: open,
|
|
65
|
+
onClose: handleClose,
|
|
66
|
+
x: x,
|
|
67
|
+
y: y,
|
|
68
|
+
label: label
|
|
69
|
+
}, children));
|
|
70
|
+
});
|
|
71
|
+
OverflowMenu.propTypes = {
|
|
72
|
+
/**
|
|
73
|
+
* A collection of MenuItems to be rendered within this OverflowMenu.
|
|
74
|
+
*/
|
|
75
|
+
children: PropTypes.node,
|
|
76
|
+
/**
|
|
77
|
+
* Additional CSS class names for the trigger button.
|
|
78
|
+
*/
|
|
79
|
+
className: PropTypes.string,
|
|
80
|
+
/**
|
|
81
|
+
* A label describing the options available. Is used in the trigger tooltip and as the menu's accessible label.
|
|
82
|
+
*/
|
|
83
|
+
label: PropTypes.string,
|
|
84
|
+
/**
|
|
85
|
+
* Otionally provide a custom icon to be rendered on the trigger button.
|
|
86
|
+
*/
|
|
87
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
88
|
+
/**
|
|
89
|
+
* Specify the size of the menu, from a list of available sizes.
|
|
90
|
+
*/
|
|
91
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
92
|
+
/**
|
|
93
|
+
* Specify how the trigger tooltip should be aligned.
|
|
94
|
+
*/
|
|
95
|
+
tooltipAlignment: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right'])
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { OverflowMenu };
|