@carbon/react 1.54.0 → 1.55.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +981 -1010
- package/es/components/CodeSnippet/CodeSnippet.Skeleton.d.ts +37 -0
- package/es/components/CodeSnippet/CodeSnippet.d.ts +196 -0
- package/es/components/CodeSnippet/CodeSnippet.js +20 -19
- package/es/components/CodeSnippet/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.d.ts +2 -2
- package/es/components/ComboBox/ComboBox.js +13 -5
- package/es/components/ComboButton/index.d.ts +51 -0
- package/es/components/ComboButton/index.js +9 -7
- package/es/components/ComposedModal/ComposedModal.js +2 -2
- package/es/components/DataTable/TableBatchAction.d.ts +1 -5
- package/es/components/Dropdown/Dropdown.js +3 -1
- package/es/components/Modal/Modal.js +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +31 -0
- package/es/components/MultiSelect/MultiSelect.js +37 -7
- package/es/components/Slug/index.js +8 -13
- package/es/components/Tag/DismissibleTag.js +119 -0
- package/es/components/Tag/OperationalTag.js +99 -0
- package/es/components/Tag/SelectableTag.js +98 -0
- package/es/components/Tag/index.d.ts +4 -1
- package/es/components/TreeView/TreeNode.js +1 -1
- package/es/components/UIShell/SideNavMenu.js +11 -1
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -0
- package/es/components/UIShell/SideNavMenuItem.js +8 -1
- package/es/components/UIShell/SwitcherItem.d.ts +4 -0
- package/es/components/UIShell/SwitcherItem.js +6 -0
- package/es/index.js +5 -2
- package/lib/components/CodeSnippet/CodeSnippet.Skeleton.d.ts +37 -0
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +196 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +20 -19
- package/lib/components/CodeSnippet/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.d.ts +2 -2
- package/lib/components/ComboBox/ComboBox.js +13 -5
- package/lib/components/ComboButton/index.d.ts +51 -0
- package/lib/components/ComboButton/index.js +9 -7
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/components/DataTable/TableBatchAction.d.ts +1 -5
- package/lib/components/Dropdown/Dropdown.js +3 -1
- package/lib/components/Modal/Modal.js +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +31 -0
- package/lib/components/MultiSelect/MultiSelect.js +37 -7
- package/lib/components/Slug/index.js +8 -13
- package/lib/components/Tag/DismissibleTag.js +129 -0
- package/lib/components/Tag/OperationalTag.js +109 -0
- package/lib/components/Tag/SelectableTag.js +108 -0
- package/lib/components/Tag/index.d.ts +4 -1
- package/lib/components/TreeView/TreeNode.js +1 -1
- package/lib/components/UIShell/SideNavMenu.js +11 -1
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -0
- package/lib/components/UIShell/SideNavMenuItem.js +8 -1
- package/lib/components/UIShell/SwitcherItem.d.ts +4 -0
- package/lib/components/UIShell/SwitcherItem.js +6 -0
- package/lib/index.js +10 -4
- package/package.json +3 -3
|
@@ -37,9 +37,11 @@ const {
|
|
|
37
37
|
ToggleButtonKeyDownEscape,
|
|
38
38
|
ToggleButtonKeyDownSpaceButton,
|
|
39
39
|
ItemMouseMove,
|
|
40
|
+
MenuMouseLeave,
|
|
40
41
|
ToggleButtonClick,
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
ToggleButtonKeyDownPageDown,
|
|
43
|
+
ToggleButtonKeyDownPageUp,
|
|
44
|
+
FunctionSetHighlightedIndex
|
|
43
45
|
} = useSelect.stateChangeTypes;
|
|
44
46
|
const defaultItemToString = item => {
|
|
45
47
|
if (typeof item === 'string') {
|
|
@@ -135,7 +137,8 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
135
137
|
getMenuProps,
|
|
136
138
|
getItemProps,
|
|
137
139
|
selectedItem,
|
|
138
|
-
highlightedIndex
|
|
140
|
+
highlightedIndex,
|
|
141
|
+
setHighlightedIndex
|
|
139
142
|
} = useSelect(selectProps);
|
|
140
143
|
const toggleButtonProps = getToggleButtonProps({
|
|
141
144
|
onFocus: () => {
|
|
@@ -154,6 +157,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
154
157
|
setItemsCleared(true);
|
|
155
158
|
}
|
|
156
159
|
if ((match(e, Space) || match(e, ArrowDown) || match(e, Enter)) && !isOpen) {
|
|
160
|
+
setHighlightedIndex(0);
|
|
157
161
|
setItemsCleared(false);
|
|
158
162
|
setIsOpenWrapper(true);
|
|
159
163
|
}
|
|
@@ -237,7 +241,6 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
237
241
|
setTopItems(controlledSelectedItems);
|
|
238
242
|
}
|
|
239
243
|
switch (type) {
|
|
240
|
-
case ItemClick:
|
|
241
244
|
case ToggleButtonKeyDownSpaceButton:
|
|
242
245
|
case ToggleButtonKeyDownEnter:
|
|
243
246
|
if (changes.selectedItem === undefined) {
|
|
@@ -257,11 +260,38 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
257
260
|
break;
|
|
258
261
|
case ToggleButtonClick:
|
|
259
262
|
setIsOpenWrapper(changes.isOpen || false);
|
|
260
|
-
|
|
263
|
+
return {
|
|
264
|
+
...changes,
|
|
265
|
+
highlightedIndex: 0
|
|
266
|
+
};
|
|
267
|
+
case ItemClick:
|
|
268
|
+
setHighlightedIndex(changes.selectedItem);
|
|
269
|
+
onItemChange(changes.selectedItem);
|
|
270
|
+
return {
|
|
271
|
+
...changes,
|
|
272
|
+
highlightedIndex: state.highlightedIndex
|
|
273
|
+
};
|
|
274
|
+
case MenuMouseLeave:
|
|
275
|
+
return {
|
|
276
|
+
...changes,
|
|
277
|
+
highlightedIndex: state.highlightedIndex
|
|
278
|
+
};
|
|
279
|
+
case FunctionSetHighlightedIndex:
|
|
280
|
+
if (!isOpen) {
|
|
281
|
+
return {
|
|
282
|
+
...changes,
|
|
283
|
+
highlightedIndex: 0
|
|
284
|
+
};
|
|
285
|
+
} else {
|
|
286
|
+
return {
|
|
287
|
+
...changes,
|
|
288
|
+
highlightedIndex: props.items.indexOf(highlightedIndex)
|
|
289
|
+
};
|
|
290
|
+
}
|
|
261
291
|
case ToggleButtonKeyDownArrowDown:
|
|
262
292
|
case ToggleButtonKeyDownArrowUp:
|
|
263
|
-
case
|
|
264
|
-
case
|
|
293
|
+
case ToggleButtonKeyDownPageDown:
|
|
294
|
+
case ToggleButtonKeyDownPageUp:
|
|
265
295
|
if (highlightedIndex > -1) {
|
|
266
296
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
267
297
|
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
@@ -138,26 +138,21 @@ Slug.propTypes = {
|
|
|
138
138
|
*/
|
|
139
139
|
align: PropTypes.oneOf(['top', 'top-left',
|
|
140
140
|
// deprecated use top-start instead
|
|
141
|
-
'top-right',
|
|
141
|
+
'top-start', 'top-right',
|
|
142
142
|
// deprecated use top-end instead
|
|
143
|
-
|
|
144
|
-
'bottom', 'bottom-left',
|
|
143
|
+
'top-end', 'bottom', 'bottom-left',
|
|
145
144
|
// deprecated use bottom-start instead
|
|
146
|
-
'bottom-right',
|
|
145
|
+
'bottom-start', 'bottom-right',
|
|
147
146
|
// deprecated use bottom-end instead
|
|
148
|
-
|
|
149
|
-
'left', 'left-bottom',
|
|
147
|
+
'bottom-end', 'left', 'left-bottom',
|
|
150
148
|
// deprecated use left-end instead
|
|
151
|
-
'left-top',
|
|
149
|
+
'left-end', 'left-top',
|
|
152
150
|
// deprecated use left-start instead
|
|
153
|
-
|
|
154
|
-
'right', 'right-bottom',
|
|
151
|
+
'left-start', 'right', 'right-bottom',
|
|
155
152
|
// deprecated use right-end instead
|
|
156
|
-
'right-top',
|
|
153
|
+
'right-end', 'right-top',
|
|
157
154
|
// deprecated use right-start instead
|
|
158
|
-
|
|
159
|
-
// new values to match floating-ui
|
|
160
|
-
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
155
|
+
'right-start']),
|
|
161
156
|
/**
|
|
162
157
|
* Will auto-align the popover. This prop is currently experimental and is subject to future changes.
|
|
163
158
|
*/
|
|
@@ -0,0 +1,119 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
13
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import Tag, { SIZES, TYPES } from './Tag.js';
|
|
15
|
+
import { Close } from '@carbon/icons-react';
|
|
16
|
+
|
|
17
|
+
var _Close;
|
|
18
|
+
const getInstanceId = setupGetInstanceId();
|
|
19
|
+
const DismissibleTag = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
disabled,
|
|
24
|
+
id,
|
|
25
|
+
renderIcon,
|
|
26
|
+
title = 'Clear filter',
|
|
27
|
+
onClose,
|
|
28
|
+
slug,
|
|
29
|
+
size,
|
|
30
|
+
type,
|
|
31
|
+
...other
|
|
32
|
+
} = _ref;
|
|
33
|
+
const prefix = usePrefix();
|
|
34
|
+
const tagId = id || `tag-${getInstanceId()}`;
|
|
35
|
+
const tagClasses = cx(`${prefix}--tag--filter`, className);
|
|
36
|
+
const handleClose = event => {
|
|
37
|
+
if (onClose) {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
onClose(event);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
let normalizedSlug;
|
|
43
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
44
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
45
|
+
size: 'sm',
|
|
46
|
+
kind: 'inline'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Removing onClick from the spread operator
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
const {
|
|
53
|
+
onClick,
|
|
54
|
+
...otherProps
|
|
55
|
+
} = other;
|
|
56
|
+
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
57
|
+
type: type,
|
|
58
|
+
size: size,
|
|
59
|
+
renderIcon: renderIcon,
|
|
60
|
+
disabled: disabled,
|
|
61
|
+
className: tagClasses,
|
|
62
|
+
id: tagId
|
|
63
|
+
}, otherProps), /*#__PURE__*/React__default.createElement("div", {
|
|
64
|
+
className: `${prefix}--interactive--tag-children`
|
|
65
|
+
}, children, normalizedSlug, /*#__PURE__*/React__default.createElement("button", {
|
|
66
|
+
type: "button",
|
|
67
|
+
className: `${prefix}--tag__close-icon`,
|
|
68
|
+
onClick: handleClose,
|
|
69
|
+
disabled: disabled,
|
|
70
|
+
"aria-label": title,
|
|
71
|
+
title: title
|
|
72
|
+
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)))));
|
|
73
|
+
};
|
|
74
|
+
DismissibleTag.propTypes = {
|
|
75
|
+
/**
|
|
76
|
+
* Provide content to be rendered inside of a `DismissibleTag`
|
|
77
|
+
*/
|
|
78
|
+
children: PropTypes.node,
|
|
79
|
+
/**
|
|
80
|
+
* Provide a custom className that is applied to the containing <span>
|
|
81
|
+
*/
|
|
82
|
+
className: PropTypes.string,
|
|
83
|
+
/**
|
|
84
|
+
* Specify if the `DismissibleTag` is disabled
|
|
85
|
+
*/
|
|
86
|
+
disabled: PropTypes.bool,
|
|
87
|
+
/**
|
|
88
|
+
* Specify the id for the tag.
|
|
89
|
+
*/
|
|
90
|
+
id: PropTypes.string,
|
|
91
|
+
/**
|
|
92
|
+
* Click handler for filter tag close button.
|
|
93
|
+
*/
|
|
94
|
+
onClose: PropTypes.func,
|
|
95
|
+
/**
|
|
96
|
+
* Optional prop to render a custom icon.
|
|
97
|
+
* Can be a React component class
|
|
98
|
+
*/
|
|
99
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
100
|
+
/**
|
|
101
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
102
|
+
* `md` (default) or `lg` sizes.
|
|
103
|
+
*/
|
|
104
|
+
size: PropTypes.oneOf(Object.keys(SIZES)),
|
|
105
|
+
/**
|
|
106
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
|
|
107
|
+
*/
|
|
108
|
+
slug: PropTypes.node,
|
|
109
|
+
/**
|
|
110
|
+
* Text to show on clear filters
|
|
111
|
+
*/
|
|
112
|
+
title: PropTypes.string,
|
|
113
|
+
/**
|
|
114
|
+
* Specify the type of the `Tag`
|
|
115
|
+
*/
|
|
116
|
+
type: PropTypes.oneOf(Object.keys(TYPES))
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { DismissibleTag as default };
|
|
@@ -0,0 +1,99 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
10
|
+
import React__default from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
13
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import Tag, { SIZES } from './Tag.js';
|
|
15
|
+
|
|
16
|
+
const getInstanceId = setupGetInstanceId();
|
|
17
|
+
const TYPES = {
|
|
18
|
+
red: 'Red',
|
|
19
|
+
magenta: 'Magenta',
|
|
20
|
+
purple: 'Purple',
|
|
21
|
+
blue: 'Blue',
|
|
22
|
+
cyan: 'Cyan',
|
|
23
|
+
teal: 'Teal',
|
|
24
|
+
green: 'Green',
|
|
25
|
+
gray: 'Gray',
|
|
26
|
+
'cool-gray': 'Cool-Gray',
|
|
27
|
+
'warm-gray': 'Warm-Gray'
|
|
28
|
+
};
|
|
29
|
+
const OperationalTag = _ref => {
|
|
30
|
+
let {
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
disabled,
|
|
34
|
+
id,
|
|
35
|
+
renderIcon,
|
|
36
|
+
slug,
|
|
37
|
+
size,
|
|
38
|
+
type = 'gray',
|
|
39
|
+
...other
|
|
40
|
+
} = _ref;
|
|
41
|
+
const prefix = usePrefix();
|
|
42
|
+
const tagId = id || `tag-${getInstanceId()}`;
|
|
43
|
+
const tagClasses = cx(`${prefix}--tag--operational`, className);
|
|
44
|
+
let normalizedSlug;
|
|
45
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
46
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
47
|
+
size: 'sm',
|
|
48
|
+
kind: 'inline'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
52
|
+
type: type,
|
|
53
|
+
size: size,
|
|
54
|
+
renderIcon: renderIcon,
|
|
55
|
+
disabled: disabled,
|
|
56
|
+
className: tagClasses,
|
|
57
|
+
id: tagId
|
|
58
|
+
}, other), /*#__PURE__*/React__default.createElement("div", {
|
|
59
|
+
className: `${prefix}--interactive--tag-children`
|
|
60
|
+
}, children, normalizedSlug));
|
|
61
|
+
};
|
|
62
|
+
OperationalTag.propTypes = {
|
|
63
|
+
/**
|
|
64
|
+
* Provide content to be rendered inside of a `OperationalTag`
|
|
65
|
+
*/
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
/**
|
|
68
|
+
* Provide a custom className that is applied to the containing <span>
|
|
69
|
+
*/
|
|
70
|
+
className: PropTypes.string,
|
|
71
|
+
/**
|
|
72
|
+
* Specify if the `OperationalTag` is disabled
|
|
73
|
+
*/
|
|
74
|
+
disabled: PropTypes.bool,
|
|
75
|
+
/**
|
|
76
|
+
* Specify the id for the tag.
|
|
77
|
+
*/
|
|
78
|
+
id: PropTypes.string,
|
|
79
|
+
/**
|
|
80
|
+
* Optional prop to render a custom icon.
|
|
81
|
+
* Can be a React component class
|
|
82
|
+
*/
|
|
83
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
84
|
+
/**
|
|
85
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
86
|
+
* `md` (default) or `lg` sizes.
|
|
87
|
+
*/
|
|
88
|
+
size: PropTypes.oneOf(Object.keys(SIZES)),
|
|
89
|
+
/**
|
|
90
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `OperationalTag` component
|
|
91
|
+
*/
|
|
92
|
+
slug: PropTypes.node,
|
|
93
|
+
/**
|
|
94
|
+
* Specify the type of the `Tag`
|
|
95
|
+
*/
|
|
96
|
+
type: PropTypes.oneOf(Object.keys(TYPES))
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export { OperationalTag 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 PropTypes from 'prop-types';
|
|
10
|
+
import React__default, { useState } from 'react';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
|
|
13
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import Tag, { SIZES } from './Tag.js';
|
|
15
|
+
|
|
16
|
+
const getInstanceId = setupGetInstanceId();
|
|
17
|
+
const SelectableTag = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
children,
|
|
20
|
+
className,
|
|
21
|
+
disabled,
|
|
22
|
+
id,
|
|
23
|
+
renderIcon,
|
|
24
|
+
selected = false,
|
|
25
|
+
slug,
|
|
26
|
+
size,
|
|
27
|
+
...other
|
|
28
|
+
} = _ref;
|
|
29
|
+
const prefix = usePrefix();
|
|
30
|
+
const tagId = id || `tag-${getInstanceId()}`;
|
|
31
|
+
const [selectedTag, setSelectedTag] = useState(selected);
|
|
32
|
+
const tagClasses = cx(`${prefix}--tag--selectable`, className, {
|
|
33
|
+
[`${prefix}--tag--selectable-selected`]: selectedTag
|
|
34
|
+
});
|
|
35
|
+
let normalizedSlug;
|
|
36
|
+
if (slug && slug['type']?.displayName === 'Slug') {
|
|
37
|
+
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
38
|
+
size: 'sm',
|
|
39
|
+
kind: 'inline'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Removing onClick from the spread operator
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
+
const {
|
|
46
|
+
onClick,
|
|
47
|
+
...otherProps
|
|
48
|
+
} = other;
|
|
49
|
+
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
50
|
+
slug: slug,
|
|
51
|
+
size: size,
|
|
52
|
+
renderIcon: renderIcon,
|
|
53
|
+
disabled: disabled,
|
|
54
|
+
className: tagClasses,
|
|
55
|
+
id: tagId,
|
|
56
|
+
onClick: () => setSelectedTag(!selectedTag)
|
|
57
|
+
}, otherProps), /*#__PURE__*/React__default.createElement("div", {
|
|
58
|
+
className: `${prefix}--interactive--tag-children`
|
|
59
|
+
}, children, normalizedSlug));
|
|
60
|
+
};
|
|
61
|
+
SelectableTag.propTypes = {
|
|
62
|
+
/**
|
|
63
|
+
* Provide content to be rendered inside of a `SelectableTag`
|
|
64
|
+
*/
|
|
65
|
+
children: PropTypes.node,
|
|
66
|
+
/**
|
|
67
|
+
* Provide a custom className that is applied to the containing <span>
|
|
68
|
+
*/
|
|
69
|
+
className: PropTypes.string,
|
|
70
|
+
/**
|
|
71
|
+
* Specify if the `SelectableTag` is disabled
|
|
72
|
+
*/
|
|
73
|
+
disabled: PropTypes.bool,
|
|
74
|
+
/**
|
|
75
|
+
* Specify the id for the tag.
|
|
76
|
+
*/
|
|
77
|
+
id: PropTypes.string,
|
|
78
|
+
/**
|
|
79
|
+
* Optional prop to render a custom icon.
|
|
80
|
+
* Can be a React component class
|
|
81
|
+
*/
|
|
82
|
+
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
83
|
+
/**
|
|
84
|
+
* Specify the state of the selectable tag.
|
|
85
|
+
*/
|
|
86
|
+
selected: PropTypes.bool,
|
|
87
|
+
/**
|
|
88
|
+
* Specify the size of the Tag. Currently supports either `sm`,
|
|
89
|
+
* `md` (default) or `lg` sizes.
|
|
90
|
+
*/
|
|
91
|
+
size: PropTypes.oneOf(Object.keys(SIZES)),
|
|
92
|
+
/**
|
|
93
|
+
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
94
|
+
*/
|
|
95
|
+
slug: PropTypes.node
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export { SelectableTag as default };
|
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import Tag from './Tag';
|
|
8
|
+
import DismissibleTag from './DismissibleTag';
|
|
9
|
+
import OperationalTag from './OperationalTag';
|
|
10
|
+
import SelectableTag from './SelectableTag';
|
|
8
11
|
export * from './Tag.Skeleton';
|
|
9
12
|
export default Tag;
|
|
10
|
-
export { Tag };
|
|
13
|
+
export { Tag, DismissibleTag, OperationalTag, SelectableTag };
|
|
@@ -56,7 +56,7 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
56
56
|
return /*#__PURE__*/React__default.cloneElement(node, {
|
|
57
57
|
active,
|
|
58
58
|
depth: depth + 1,
|
|
59
|
-
disabled,
|
|
59
|
+
disabled: disabled || node.props.disabled,
|
|
60
60
|
onTreeSelect,
|
|
61
61
|
selected,
|
|
62
62
|
tabIndex: !node.props.disabled && -1 || null
|
|
@@ -28,9 +28,12 @@ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(
|
|
|
28
28
|
tabIndex,
|
|
29
29
|
title
|
|
30
30
|
} = _ref;
|
|
31
|
-
const
|
|
31
|
+
const {
|
|
32
|
+
isRail
|
|
33
|
+
} = useContext(SideNavContext);
|
|
32
34
|
const prefix = usePrefix();
|
|
33
35
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
36
|
+
const [prevExpanded, setPrevExpanded] = useState(defaultExpanded);
|
|
34
37
|
const className = cx({
|
|
35
38
|
[`${prefix}--side-nav__item`]: true,
|
|
36
39
|
[`${prefix}--side-nav__item--active`]: isActive || hasActiveDescendant(children) && !isExpanded,
|
|
@@ -38,6 +41,13 @@ const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(
|
|
|
38
41
|
[`${prefix}--side-nav__item--large`]: large,
|
|
39
42
|
[customClassName]: !!customClassName
|
|
40
43
|
});
|
|
44
|
+
if (!isSideNavExpanded && isExpanded && isRail) {
|
|
45
|
+
setIsExpanded(false);
|
|
46
|
+
setPrevExpanded(true);
|
|
47
|
+
} else if (isSideNavExpanded && prevExpanded && isRail) {
|
|
48
|
+
setIsExpanded(true);
|
|
49
|
+
setPrevExpanded(false);
|
|
50
|
+
}
|
|
41
51
|
return (
|
|
42
52
|
/*#__PURE__*/
|
|
43
53
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
@@ -20,6 +20,10 @@ interface SideNavMenuItemProps extends HTMLAttributes<HTMLElement> {
|
|
|
20
20
|
* `aria-current="page"`, as well.
|
|
21
21
|
*/
|
|
22
22
|
isActive?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optionally provide an href for the underlying li`
|
|
25
|
+
*/
|
|
26
|
+
href?: string;
|
|
23
27
|
}
|
|
24
28
|
declare const SideNavMenuItem: React.ForwardRefExoticComponent<SideNavMenuItemProps & React.RefAttributes<HTMLElement>>;
|
|
25
29
|
export default SideNavMenuItem;
|
|
@@ -19,6 +19,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
|
|
|
19
19
|
children,
|
|
20
20
|
className: customClassName,
|
|
21
21
|
isActive,
|
|
22
|
+
href,
|
|
22
23
|
...rest
|
|
23
24
|
} = props;
|
|
24
25
|
const className = cx(`${prefix}--side-nav__menu-item`, customClassName);
|
|
@@ -28,7 +29,9 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
|
|
|
28
29
|
});
|
|
29
30
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
30
31
|
className: className
|
|
31
|
-
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
32
|
+
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
33
|
+
href: href
|
|
34
|
+
}, rest, {
|
|
32
35
|
className: linkClassName,
|
|
33
36
|
ref: ref
|
|
34
37
|
}), /*#__PURE__*/React__default.createElement(SideNavLinkText, null, children)));
|
|
@@ -43,6 +46,10 @@ SideNavMenuItem.propTypes = {
|
|
|
43
46
|
* Provide an optional class to be applied to the containing node
|
|
44
47
|
*/
|
|
45
48
|
className: PropTypes.string,
|
|
49
|
+
/**
|
|
50
|
+
* Optionally provide an href for the underlying li`
|
|
51
|
+
*/
|
|
52
|
+
href: PropTypes.string,
|
|
46
53
|
/**
|
|
47
54
|
* Optionally specify whether the link is "active". An active link is one that
|
|
48
55
|
* has an href that is the same as the current page. Can also pass in
|
|
@@ -39,6 +39,10 @@ interface BaseSwitcherItemProps {
|
|
|
39
39
|
* Specify whether the panel is selected
|
|
40
40
|
*/
|
|
41
41
|
isSelected?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Optionally provide an href for the underlying li`
|
|
44
|
+
*/
|
|
45
|
+
href?: string;
|
|
42
46
|
}
|
|
43
47
|
interface SwitcherItemWithAriaLabel extends BaseSwitcherItemProps {
|
|
44
48
|
'aria-label': string;
|
|
@@ -27,6 +27,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
|
|
|
27
27
|
index,
|
|
28
28
|
handleSwitcherItemFocus,
|
|
29
29
|
onKeyDown = () => {},
|
|
30
|
+
href,
|
|
30
31
|
...rest
|
|
31
32
|
} = props;
|
|
32
33
|
const prefix = usePrefix();
|
|
@@ -63,6 +64,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwar
|
|
|
63
64
|
setTabFocus(evt);
|
|
64
65
|
onKeyDown(evt);
|
|
65
66
|
},
|
|
67
|
+
href: href,
|
|
66
68
|
ref: forwardRef
|
|
67
69
|
}, rest, {
|
|
68
70
|
className: linkClassName,
|
|
@@ -84,6 +86,10 @@ SwitcherItem.propTypes = {
|
|
|
84
86
|
* event handlers
|
|
85
87
|
*/
|
|
86
88
|
handleSwitcherItemFocus: PropTypes.func,
|
|
89
|
+
/**
|
|
90
|
+
* Optionally provide an href for the underlying li`
|
|
91
|
+
*/
|
|
92
|
+
href: PropTypes.string,
|
|
87
93
|
/**
|
|
88
94
|
* Specify the index of the SwitcherItem
|
|
89
95
|
*/
|
package/es/index.js
CHANGED
|
@@ -19,6 +19,8 @@ export { default as ButtonSet } from './components/ButtonSet/ButtonSet.js';
|
|
|
19
19
|
export { default as Checkbox } from './components/Checkbox/Checkbox.js';
|
|
20
20
|
export { default as CheckboxSkeleton } from './components/Checkbox/Checkbox.Skeleton.js';
|
|
21
21
|
export { ClassPrefix } from './components/ClassPrefix/index.js';
|
|
22
|
+
export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js';
|
|
23
|
+
export { default as CodeSnippetSkeleton } from './components/CodeSnippet/CodeSnippet.Skeleton.js';
|
|
22
24
|
export { default as ComboBox } from './components/ComboBox/ComboBox.js';
|
|
23
25
|
export { ComboButton } from './components/ComboButton/index.js';
|
|
24
26
|
export { default as ComposedModal, ModalBody } from './components/ComposedModal/ComposedModal.js';
|
|
@@ -105,6 +107,9 @@ export { IconTab, Tab, TabList, TabPanel, TabPanels, Tabs } from './components/T
|
|
|
105
107
|
export { default as TabContent } from './components/TabContent/TabContent.js';
|
|
106
108
|
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
107
109
|
export { default as Tag } from './components/Tag/Tag.js';
|
|
110
|
+
export { default as DismissibleTag } from './components/Tag/DismissibleTag.js';
|
|
111
|
+
export { default as OperationalTag } from './components/Tag/OperationalTag.js';
|
|
112
|
+
export { default as SelectableTag } from './components/Tag/SelectableTag.js';
|
|
108
113
|
export { default as TagSkeleton } from './components/Tag/Tag.Skeleton.js';
|
|
109
114
|
export { default as TextArea } from './components/TextArea/TextArea.js';
|
|
110
115
|
export { default as TextAreaSkeleton } from './components/TextArea/TextArea.Skeleton.js';
|
|
@@ -173,8 +178,6 @@ export { default as unstable__FluidTextInputSkeleton } from './components/FluidT
|
|
|
173
178
|
export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
|
|
174
179
|
export { default as unstable_Pagination } from './components/Pagination/experimental/Pagination.js';
|
|
175
180
|
export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
|
|
176
|
-
export { default as CodeSnippetSkeleton } from './components/CodeSnippet/CodeSnippet.Skeleton.js';
|
|
177
|
-
export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js';
|
|
178
181
|
export { default as ContainedListItem } from './components/ContainedList/ContainedListItem/ContainedListItem.js';
|
|
179
182
|
export { default as ContainedList } from './components/ContainedList/ContainedList.js';
|
|
180
183
|
export { default as useContextMenu } from './components/ContextMenu/useContextMenu.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export interface CodeSnippetSkeletonProps extends React.HTMLAttributes<Omit<HTMLDivElement, 'children'>> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify an optional className to be applied to the container node
|
|
12
|
+
*/
|
|
13
|
+
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The type of the code snippet, including single or multi
|
|
16
|
+
*/
|
|
17
|
+
type?: 'single' | 'multi' | undefined;
|
|
18
|
+
}
|
|
19
|
+
declare function CodeSnippetSkeleton({ className: containerClassName, type, ...rest }: {
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
className: any;
|
|
22
|
+
type?: string | undefined;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
24
|
+
declare namespace CodeSnippetSkeleton {
|
|
25
|
+
var propTypes: {
|
|
26
|
+
/**
|
|
27
|
+
* Specify an optional className to be applied to the container node
|
|
28
|
+
*/
|
|
29
|
+
className: PropTypes.Requireable<string>;
|
|
30
|
+
/**
|
|
31
|
+
* The type of the code snippet, including single or multi
|
|
32
|
+
*/
|
|
33
|
+
type: PropTypes.Requireable<string>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export default CodeSnippetSkeleton;
|
|
37
|
+
export { CodeSnippetSkeleton };
|