@carbon/react 1.68.0 → 1.69.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 +871 -871
- package/README.md +3 -3
- package/es/components/Accordion/AccordionItem.js +0 -1
- package/es/components/Button/Button.js +6 -0
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/es/components/CheckboxGroup/index.d.ts +10 -0
- package/es/components/ComboBox/ComboBox.js +13 -18
- package/es/components/ComboButton/index.js +10 -3
- package/es/components/DataTable/TableCell.d.ts +1 -4
- package/es/components/DataTable/TableCell.js +3 -2
- package/es/components/Disclosure/index.d.ts +18 -0
- package/es/components/Dropdown/Dropdown.js +11 -9
- package/es/components/FileUploader/FileUploader.d.ts +8 -92
- package/es/components/FileUploader/FileUploader.js +116 -137
- package/es/components/Grid/CSSGrid.js +8 -1
- package/es/components/Grid/Grid.js +4 -0
- package/es/components/IdPrefix/index.d.ts +26 -0
- package/es/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/es/components/ListBox/next/ListBoxSelection.js +12 -5
- package/es/components/Menu/MenuItem.js +1 -4
- package/es/components/MenuButton/index.d.ts +4 -0
- package/es/components/MenuButton/index.js +19 -5
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/es/components/MultiSelect/MultiSelect.js +11 -9
- package/es/components/OverflowMenu/next/index.d.ts +4 -0
- package/es/components/OverflowMenu/next/index.js +19 -9
- package/es/components/PaginationNav/PaginationNav.js +1 -1
- package/es/components/Popover/index.js +18 -14
- package/es/components/Portal/index.d.ts +25 -0
- package/es/components/Slider/Slider.js +2 -2
- package/es/components/Tabs/Tabs.js +46 -20
- package/es/components/Tag/DismissibleTag.js +2 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -10
- package/es/components/Tag/OperationalTag.js +2 -14
- package/es/components/Tag/SelectableTag.d.ts +18 -10
- package/es/components/Tag/SelectableTag.js +22 -28
- package/es/components/Toggle/Toggle.js +2 -0
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/es/components/ToggleSmall/index.d.ts +7 -0
- package/es/components/TreeView/TreeNode.js +4 -2
- package/es/components/TreeView/TreeView.js +4 -4
- package/es/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/es/components/UIShell/SideNavMenuItem.js +1 -4
- package/es/index.js +1 -1
- package/es/internal/useIdPrefix.d.ts +9 -0
- package/lib/components/Accordion/AccordionItem.js +0 -1
- package/lib/components/Button/Button.js +6 -0
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -2
- package/lib/components/CheckboxGroup/index.d.ts +10 -0
- package/lib/components/ComboBox/ComboBox.js +18 -23
- package/lib/components/ComboButton/index.js +12 -5
- package/lib/components/DataTable/TableCell.d.ts +1 -4
- package/lib/components/DataTable/TableCell.js +3 -2
- package/lib/components/Disclosure/index.d.ts +18 -0
- package/lib/components/Dropdown/Dropdown.js +18 -16
- package/lib/components/FileUploader/FileUploader.d.ts +8 -92
- package/lib/components/FileUploader/FileUploader.js +113 -134
- package/lib/components/Grid/CSSGrid.js +8 -1
- package/lib/components/Grid/Grid.js +4 -0
- package/lib/components/IdPrefix/index.d.ts +26 -0
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +9 -1
- package/lib/components/ListBox/next/ListBoxSelection.js +12 -5
- package/lib/components/Menu/MenuItem.js +1 -4
- package/lib/components/MenuButton/index.d.ts +4 -0
- package/lib/components/MenuButton/index.js +19 -5
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +4 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +32 -6
- package/lib/components/MultiSelect/MultiSelect.js +18 -16
- package/lib/components/OverflowMenu/next/index.d.ts +4 -0
- package/lib/components/OverflowMenu/next/index.js +21 -11
- package/lib/components/PaginationNav/PaginationNav.js +1 -1
- package/lib/components/Popover/index.js +18 -14
- package/lib/components/Portal/index.d.ts +25 -0
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Tabs/Tabs.js +46 -20
- package/lib/components/Tag/DismissibleTag.js +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -10
- package/lib/components/Tag/OperationalTag.js +2 -14
- package/lib/components/Tag/SelectableTag.d.ts +18 -10
- package/lib/components/Tag/SelectableTag.js +22 -28
- package/lib/components/Toggle/Toggle.js +2 -0
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.d.ts +49 -0
- package/lib/components/ToggleSmall/index.d.ts +7 -0
- package/lib/components/TreeView/TreeNode.js +4 -2
- package/lib/components/TreeView/TreeView.js +4 -4
- package/lib/components/UIShell/SideNavMenuItem.d.ts +4 -3
- package/lib/components/UIShell/SideNavMenuItem.js +1 -4
- package/lib/index.js +2 -2
- package/lib/internal/useIdPrefix.d.ts +9 -0
- package/package.json +10 -9
- package/telemetry.yml +809 -809
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
9
9
|
import { PolymorphicProps } from '../../types/common';
|
|
10
10
|
import { SIZES } from './Tag';
|
|
11
11
|
export interface SelectableTagBaseProps {
|
|
@@ -26,6 +26,14 @@ export interface SelectableTagBaseProps {
|
|
|
26
26
|
* Can be a React component class
|
|
27
27
|
*/
|
|
28
28
|
renderIcon?: React.ElementType;
|
|
29
|
+
/**
|
|
30
|
+
* Provide an optional hook that is called when selected is changed
|
|
31
|
+
*/
|
|
32
|
+
onChange?: (selected: boolean) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
35
|
+
*/
|
|
36
|
+
onClick?: (e: Event) => void;
|
|
29
37
|
/**
|
|
30
38
|
* Specify the state of the selectable tag.
|
|
31
39
|
*/
|
|
@@ -35,10 +43,6 @@ export interface SelectableTagBaseProps {
|
|
|
35
43
|
* `md` (default) or `lg` sizes.
|
|
36
44
|
*/
|
|
37
45
|
size?: keyof typeof SIZES;
|
|
38
|
-
/**
|
|
39
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
40
|
-
*/
|
|
41
|
-
slug?: ReactNode;
|
|
42
46
|
/**
|
|
43
47
|
* Provide text to be rendered inside of a the tag.
|
|
44
48
|
*/
|
|
@@ -46,7 +50,7 @@ export interface SelectableTagBaseProps {
|
|
|
46
50
|
}
|
|
47
51
|
export type SelectableTagProps<T extends React.ElementType> = PolymorphicProps<T, SelectableTagBaseProps>;
|
|
48
52
|
declare const SelectableTag: {
|
|
49
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon,
|
|
53
|
+
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, onChange, onClick, selected, size, text, ...other }: SelectableTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
50
54
|
propTypes: {
|
|
51
55
|
/**
|
|
52
56
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -65,6 +69,14 @@ declare const SelectableTag: {
|
|
|
65
69
|
* Can be a React component class
|
|
66
70
|
*/
|
|
67
71
|
renderIcon: PropTypes.Requireable<object>;
|
|
72
|
+
/**
|
|
73
|
+
* Provide an optional hook that is called when selected is changed
|
|
74
|
+
*/
|
|
75
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
76
|
+
/**
|
|
77
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
78
|
+
*/
|
|
79
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
68
80
|
/**
|
|
69
81
|
* Specify the state of the selectable tag.
|
|
70
82
|
*/
|
|
@@ -74,10 +86,6 @@ declare const SelectableTag: {
|
|
|
74
86
|
* `md` (default) or `lg` sizes.
|
|
75
87
|
*/
|
|
76
88
|
size: PropTypes.Requireable<string>;
|
|
77
|
-
/**
|
|
78
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
79
|
-
*/
|
|
80
|
-
slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
81
89
|
/**
|
|
82
90
|
* Provide text to be rendered inside of a the tag.
|
|
83
91
|
*/
|
|
@@ -24,8 +24,9 @@ const SelectableTag = _ref => {
|
|
|
24
24
|
disabled,
|
|
25
25
|
id,
|
|
26
26
|
renderIcon,
|
|
27
|
+
onChange,
|
|
28
|
+
onClick,
|
|
27
29
|
selected = false,
|
|
28
|
-
slug,
|
|
29
30
|
size,
|
|
30
31
|
text,
|
|
31
32
|
...other
|
|
@@ -42,21 +43,12 @@ const SelectableTag = _ref => {
|
|
|
42
43
|
const newElement = tagRef.current?.getElementsByClassName(`${prefix}--tag__label`)[0];
|
|
43
44
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
44
45
|
}, [prefix, tagRef]);
|
|
45
|
-
let normalizedSlug;
|
|
46
|
-
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
47
|
-
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
48
|
-
size: 'sm',
|
|
49
|
-
kind: 'inline'
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
46
|
const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...otherProps
|
|
59
|
-
} = other;
|
|
47
|
+
const handleClick = e => {
|
|
48
|
+
setSelectedTag(!selectedTag);
|
|
49
|
+
onChange?.(!selectedTag);
|
|
50
|
+
onClick?.(e);
|
|
51
|
+
};
|
|
60
52
|
if (isEllipsisApplied) {
|
|
61
53
|
return /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
62
54
|
label: text,
|
|
@@ -65,31 +57,29 @@ const SelectableTag = _ref => {
|
|
|
65
57
|
leaveDelayMs: 0,
|
|
66
58
|
onMouseEnter: () => false
|
|
67
59
|
}, /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
68
|
-
"aria-pressed": selectedTag,
|
|
60
|
+
"aria-pressed": selectedTag !== false,
|
|
69
61
|
ref: tagRef,
|
|
70
|
-
slug: slug,
|
|
71
62
|
size: size,
|
|
72
63
|
renderIcon: renderIcon,
|
|
73
64
|
disabled: disabled,
|
|
74
65
|
className: tagClasses,
|
|
75
66
|
id: tagId,
|
|
76
|
-
onClick:
|
|
77
|
-
},
|
|
67
|
+
onClick: handleClick
|
|
68
|
+
}, other), /*#__PURE__*/React__default.createElement(Text, {
|
|
78
69
|
title: text,
|
|
79
70
|
className: `${prefix}--tag__label`
|
|
80
|
-
}, text)
|
|
71
|
+
}, text)));
|
|
81
72
|
}
|
|
82
73
|
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
83
|
-
"aria-pressed": selectedTag,
|
|
74
|
+
"aria-pressed": selectedTag !== false,
|
|
84
75
|
ref: tagRef,
|
|
85
|
-
slug: slug,
|
|
86
76
|
size: size,
|
|
87
77
|
renderIcon: renderIcon,
|
|
88
78
|
disabled: disabled,
|
|
89
79
|
className: tagClasses,
|
|
90
80
|
id: tagId,
|
|
91
|
-
onClick:
|
|
92
|
-
},
|
|
81
|
+
onClick: handleClick
|
|
82
|
+
}, other), /*#__PURE__*/React__default.createElement(Text, {
|
|
93
83
|
title: text,
|
|
94
84
|
className: `${prefix}--tag__label`
|
|
95
85
|
}, text));
|
|
@@ -112,6 +102,14 @@ SelectableTag.propTypes = {
|
|
|
112
102
|
* Can be a React component class
|
|
113
103
|
*/
|
|
114
104
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
105
|
+
/**
|
|
106
|
+
* Provide an optional hook that is called when selected is changed
|
|
107
|
+
*/
|
|
108
|
+
onChange: PropTypes.func,
|
|
109
|
+
/**
|
|
110
|
+
* Provide an optional function to be called when the tag is clicked.
|
|
111
|
+
*/
|
|
112
|
+
onClick: PropTypes.func,
|
|
115
113
|
/**
|
|
116
114
|
* Specify the state of the selectable tag.
|
|
117
115
|
*/
|
|
@@ -121,10 +119,6 @@ SelectableTag.propTypes = {
|
|
|
121
119
|
* `md` (default) or `lg` sizes.
|
|
122
120
|
*/
|
|
123
121
|
size: PropTypes.oneOf(Object.keys(SIZES)),
|
|
124
|
-
/**
|
|
125
|
-
* **Experimental:** Provide a `Slug` component to be rendered inside the `SelectableTag` component
|
|
126
|
-
*/
|
|
127
|
-
slug: PropTypes.node,
|
|
128
122
|
/**
|
|
129
123
|
* Provide text to be rendered inside of a the tag.
|
|
130
124
|
*/
|
|
@@ -103,6 +103,8 @@ function Toggle(_ref) {
|
|
|
103
103
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
104
104
|
className: switchClasses
|
|
105
105
|
}, isSm && /*#__PURE__*/React__default.createElement("svg", {
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
focusable: "false",
|
|
106
108
|
className: `${prefix}--toggle__check`,
|
|
107
109
|
width: "6px",
|
|
108
110
|
height: "5px",
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
interface ToggleSmallSkeletonProps {
|
|
10
|
+
['aria-label']: string;
|
|
11
|
+
/**
|
|
12
|
+
* Specify an optional className to add to the form item wrapper.
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Provide an id that unique represents the underlying `<input>`
|
|
17
|
+
*/
|
|
18
|
+
id?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
21
|
+
* control
|
|
22
|
+
* `aria-label` is always required but will be null if `labelText` is also
|
|
23
|
+
* provided
|
|
24
|
+
*/
|
|
25
|
+
labelText?: string;
|
|
26
|
+
}
|
|
27
|
+
declare class ToggleSmallSkeleton extends React.Component<ToggleSmallSkeletonProps> {
|
|
28
|
+
static propTypes: {
|
|
29
|
+
"aria-label": PropTypes.Validator<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Specify an optional className to add to the form item wrapper.
|
|
32
|
+
*/
|
|
33
|
+
className: PropTypes.Requireable<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Provide an id that unique represents the underlying `<input>`
|
|
36
|
+
*/
|
|
37
|
+
id: PropTypes.Requireable<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Provide the text that will be read by a screen reader when visiting this
|
|
40
|
+
* control
|
|
41
|
+
* `aria-label` is always required but will be null if `labelText` is also
|
|
42
|
+
* provided
|
|
43
|
+
*/
|
|
44
|
+
labelText: PropTypes.Requireable<string>;
|
|
45
|
+
};
|
|
46
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
}
|
|
48
|
+
export default ToggleSmallSkeleton;
|
|
49
|
+
export { ToggleSmallSkeleton };
|
|
@@ -271,9 +271,11 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, forwardedRef) =>
|
|
|
271
271
|
className: `${prefix}--tree-node__label__details`
|
|
272
272
|
}, Icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
273
273
|
className: `${prefix}--tree-node__icon`
|
|
274
|
-
}), label)),
|
|
274
|
+
}), label)), /*#__PURE__*/React__default.createElement("ul", {
|
|
275
275
|
role: "group",
|
|
276
|
-
className: `${prefix}--tree-node__children
|
|
276
|
+
className: cx(`${prefix}--tree-node__children`, {
|
|
277
|
+
[`${prefix}--tree-node--hidden`]: !expanded
|
|
278
|
+
})
|
|
277
279
|
}, nodesWithProps));
|
|
278
280
|
});
|
|
279
281
|
TreeNode.propTypes = {
|
|
@@ -151,12 +151,12 @@ const TreeView = _ref => {
|
|
|
151
151
|
}])) {
|
|
152
152
|
const nodeIds = [];
|
|
153
153
|
if (matches(event, [Home, End])) {
|
|
154
|
-
if (multiselect && event.shiftKey && event.ctrlKey && treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
|
|
154
|
+
if (multiselect && event.shiftKey && event.ctrlKey && treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled') && !treeWalker.current.currentNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
155
155
|
nodeIds.push(treeWalker.current.currentNode?.id);
|
|
156
156
|
}
|
|
157
157
|
while (match(event, Home) ? treeWalker.current.previousNode() : treeWalker.current.nextNode()) {
|
|
158
158
|
nextFocusNode = treeWalker.current.currentNode;
|
|
159
|
-
if (multiselect && event.shiftKey && event.ctrlKey && nextFocusNode instanceof Element && !nextFocusNode.getAttribute('aria-disabled')) {
|
|
159
|
+
if (multiselect && event.shiftKey && event.ctrlKey && nextFocusNode instanceof Element && !nextFocusNode.getAttribute('aria-disabled') && !nextFocusNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
160
160
|
nodeIds.push(nextFocusNode?.id);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
@@ -167,7 +167,7 @@ const TreeView = _ref => {
|
|
|
167
167
|
}) && event.ctrlKey) {
|
|
168
168
|
treeWalker.current.currentNode = treeWalker.current.root;
|
|
169
169
|
while (treeWalker.current.nextNode()) {
|
|
170
|
-
if (treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled')) {
|
|
170
|
+
if (treeWalker.current.currentNode instanceof Element && !treeWalker.current.currentNode.getAttribute('aria-disabled') && !treeWalker.current.currentNode.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
171
171
|
nodeIds.push(treeWalker.current.currentNode?.id);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -189,7 +189,7 @@ const TreeView = _ref => {
|
|
|
189
189
|
if (!(node instanceof Element)) {
|
|
190
190
|
return NodeFilter.FILTER_SKIP;
|
|
191
191
|
}
|
|
192
|
-
if (node.classList.contains(`${prefix}--tree-node--disabled`)) {
|
|
192
|
+
if (node.classList.contains(`${prefix}--tree-node--disabled`) || node.classList.contains(`${prefix}--tree-node--hidden`)) {
|
|
193
193
|
return NodeFilter.FILTER_REJECT;
|
|
194
194
|
}
|
|
195
195
|
if (node.matches(`li.${prefix}--tree-node`)) {
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {
|
|
8
|
-
|
|
7
|
+
import React, { ComponentProps } from 'react';
|
|
8
|
+
import Link from './Link';
|
|
9
|
+
interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
|
|
9
10
|
/**
|
|
10
11
|
* Specify the children to be rendered inside of the `SideNavMenuItem`
|
|
11
12
|
*/
|
|
@@ -25,5 +26,5 @@ interface SideNavMenuItemProps extends HTMLAttributes<HTMLElement> {
|
|
|
25
26
|
*/
|
|
26
27
|
href?: string;
|
|
27
28
|
}
|
|
28
|
-
declare const SideNavMenuItem: React.ForwardRefExoticComponent<SideNavMenuItemProps & React.RefAttributes<HTMLElement>>;
|
|
29
|
+
declare const SideNavMenuItem: React.ForwardRefExoticComponent<Omit<SideNavMenuItemProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
29
30
|
export default SideNavMenuItem;
|
|
@@ -19,7 +19,6 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
|
|
|
19
19
|
children,
|
|
20
20
|
className: customClassName,
|
|
21
21
|
isActive,
|
|
22
|
-
href,
|
|
23
22
|
...rest
|
|
24
23
|
} = props;
|
|
25
24
|
const className = cx(`${prefix}--side-nav__menu-item`, customClassName);
|
|
@@ -29,9 +28,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
|
|
|
29
28
|
});
|
|
30
29
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
31
30
|
className: className
|
|
32
|
-
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
33
|
-
href: href
|
|
34
|
-
}, rest, {
|
|
31
|
+
}, /*#__PURE__*/React__default.createElement(Link, _extends({}, rest, {
|
|
35
32
|
className: linkClassName,
|
|
36
33
|
ref: ref
|
|
37
34
|
}), /*#__PURE__*/React__default.createElement(SideNavLinkText, null, children)));
|
package/es/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { default as ButtonSkeleton } from './components/Button/Button.Skeleton.j
|
|
|
18
18
|
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
|
+
export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
|
|
21
22
|
export { ClassPrefix } from './components/ClassPrefix/index.js';
|
|
22
23
|
export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js';
|
|
23
24
|
export { default as CodeSnippetSkeleton } from './components/CodeSnippet/CodeSnippet.Skeleton.js';
|
|
@@ -211,7 +212,6 @@ export { LayoutDirection as unstable_LayoutDirection } from './components/Layout
|
|
|
211
212
|
export { useLayoutDirection as unstable_useLayoutDirection } from './components/LayoutDirection/useLayoutDirection.js';
|
|
212
213
|
export { Text as unstable_Text } from './components/Text/Text.js';
|
|
213
214
|
export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
|
|
214
|
-
export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
|
|
215
215
|
export { default as DataTable } from './components/DataTable/DataTable.js';
|
|
216
216
|
export { Table } from './components/DataTable/Table.js';
|
|
217
217
|
export { default as TableActionList } from './components/DataTable/TableActionList.js';
|
|
@@ -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 React from 'react';
|
|
8
|
+
export declare const IdPrefixContext: React.Context<string | null | undefined>;
|
|
9
|
+
export declare function useIdPrefix(): string | null | undefined;
|
|
@@ -118,7 +118,6 @@ function AccordionItem(_ref) {
|
|
|
118
118
|
className: `${prefix}--accordion__title`
|
|
119
119
|
}, title)), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
120
120
|
ref: content,
|
|
121
|
-
hidden: !isOpen,
|
|
122
121
|
className: `${prefix}--accordion__wrapper`,
|
|
123
122
|
onTransitionEnd: onAnimationEnd
|
|
124
123
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -35,6 +35,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
35
35
|
const tooltipRef = React.useRef(null);
|
|
36
36
|
const {
|
|
37
37
|
as,
|
|
38
|
+
autoAlign = false,
|
|
38
39
|
children,
|
|
39
40
|
hasIconOnly = false,
|
|
40
41
|
iconDescription,
|
|
@@ -93,6 +94,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
93
94
|
onMouseLeave: onMouseLeave,
|
|
94
95
|
onFocus: onFocus,
|
|
95
96
|
onBlur: onBlur,
|
|
97
|
+
autoAlign: autoAlign,
|
|
96
98
|
onClick: events.composeEventHandlers([onClick, handleClick]),
|
|
97
99
|
renderIcon: iconOnlyImage ? null : ButtonImageElement // avoid doubling the icon.
|
|
98
100
|
}), iconOnlyImage ?? children);
|
|
@@ -105,6 +107,10 @@ Button.propTypes = {
|
|
|
105
107
|
* Make sure to apply all props to the root node and render children appropriately
|
|
106
108
|
*/
|
|
107
109
|
as: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].string, PropTypes__default["default"].elementType]),
|
|
110
|
+
/**
|
|
111
|
+
* **Experimental**: Will attempt to automatically align the tooltip
|
|
112
|
+
*/
|
|
113
|
+
autoAlign: PropTypes__default["default"].bool,
|
|
108
114
|
/**
|
|
109
115
|
* Specify the content of your Button
|
|
110
116
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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 CheckboxGroup from './CheckboxGroup';
|
|
8
|
+
import { type CheckboxGroupProps, type CustomType } from './CheckboxGroup';
|
|
9
|
+
export default CheckboxGroup;
|
|
10
|
+
export { CheckboxGroup, type CheckboxGroupProps, type CustomType };
|
|
@@ -16,7 +16,7 @@ var PropTypes = require('prop-types');
|
|
|
16
16
|
var React = require('react');
|
|
17
17
|
require('../Text/index.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
|
-
var index = require('../ListBox/index.js');
|
|
19
|
+
var index$1 = require('../ListBox/index.js');
|
|
20
20
|
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
21
21
|
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
22
22
|
var useId = require('../../internal/useId.js');
|
|
@@ -27,6 +27,7 @@ require('../FluidForm/FluidForm.js');
|
|
|
27
27
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
28
28
|
var react = require('@floating-ui/react');
|
|
29
29
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
30
|
+
var index = require('../FeatureFlags/index.js');
|
|
30
31
|
var Text = require('../Text/Text.js');
|
|
31
32
|
var match = require('../../internal/keyboard/match.js');
|
|
32
33
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
@@ -119,7 +120,6 @@ const findHighlightedIndex = (_ref3, inputValue) => {
|
|
|
119
120
|
*/
|
|
120
121
|
|
|
121
122
|
const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
122
|
-
const [cursorPosition, setCursorPosition] = React.useState(0);
|
|
123
123
|
const prevInputLengthRef = React.useRef(0);
|
|
124
124
|
const inputRef = React.useRef(null);
|
|
125
125
|
const {
|
|
@@ -157,19 +157,20 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
157
157
|
slug,
|
|
158
158
|
...rest
|
|
159
159
|
} = props;
|
|
160
|
+
const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
|
|
160
161
|
const {
|
|
161
162
|
refs,
|
|
162
163
|
floatingStyles,
|
|
163
164
|
middlewareData
|
|
164
|
-
} = react.useFloating(
|
|
165
|
+
} = react.useFloating(enableFloatingStyles ? {
|
|
165
166
|
placement: direction,
|
|
166
167
|
strategy: 'fixed',
|
|
167
|
-
middleware: [react.flip(), floatingUi_dom.hide()],
|
|
168
|
+
middleware: autoAlign ? [react.flip(), floatingUi_dom.hide()] : undefined,
|
|
168
169
|
whileElementsMounted: react.autoUpdate
|
|
169
170
|
} : {});
|
|
170
171
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
171
172
|
React.useEffect(() => {
|
|
172
|
-
if (
|
|
173
|
+
if (enableFloatingStyles) {
|
|
173
174
|
const updatedFloatingStyles = {
|
|
174
175
|
...floatingStyles,
|
|
175
176
|
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
@@ -183,7 +184,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
183
184
|
refs.floating.current.style.width = parentWidth + 'px';
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
|
-
}, [
|
|
187
|
+
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
187
188
|
const [inputValue, setInputValue] = React.useState(getInputValue({
|
|
188
189
|
initialSelectedItem,
|
|
189
190
|
inputValue: '',
|
|
@@ -377,7 +378,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
377
378
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
378
379
|
[`${prefix}--combo-box--warning`]: showWarning,
|
|
379
380
|
[`${prefix}--combo-box--readonly`]: readOnly,
|
|
380
|
-
[`${prefix}--autoalign`]:
|
|
381
|
+
[`${prefix}--autoalign`]: enableFloatingStyles
|
|
381
382
|
});
|
|
382
383
|
const titleClasses = cx__default["default"](`${prefix}--label`, {
|
|
383
384
|
[`${prefix}--label--disabled`]: disabled
|
|
@@ -447,7 +448,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
447
448
|
});
|
|
448
449
|
}
|
|
449
450
|
setHighlightedIndex(indexToHighlight(normalizedInput));
|
|
450
|
-
setCursorPosition(inputValue === null ? 0 : normalizedInput.length);
|
|
451
451
|
},
|
|
452
452
|
onSelectedItemChange(_ref5) {
|
|
453
453
|
let {
|
|
@@ -496,11 +496,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
498
|
}, [closeMenu, openMenu, reset, selectItem, setHighlightedIndex, downshiftSetInputValue, toggleMenu]);
|
|
499
|
-
React.useEffect(() => {
|
|
500
|
-
if (inputRef.current) {
|
|
501
|
-
inputRef.current.setSelectionRange(cursorPosition, cursorPosition);
|
|
502
|
-
}
|
|
503
|
-
}, [inputValue, cursorPosition]);
|
|
504
499
|
const buttonProps = getToggleButtonProps({
|
|
505
500
|
disabled: disabled || readOnly,
|
|
506
501
|
onClick: handleToggleClick(isOpen),
|
|
@@ -544,9 +539,8 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
544
539
|
|
|
545
540
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
546
541
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}), [autoAlign, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
542
|
+
ref: enableFloatingStyles ? refs.setFloating : null
|
|
543
|
+
}), [enableFloatingStyles, deprecatedAriaLabel, ariaLabel, getMenuProps, refs.setFloating]);
|
|
550
544
|
React.useEffect(() => {
|
|
551
545
|
if (textInput.current) {
|
|
552
546
|
if (inputRef.current && typeaheadText) {
|
|
@@ -562,7 +556,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
562
556
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
563
557
|
as: "label",
|
|
564
558
|
className: titleClasses
|
|
565
|
-
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
559
|
+
}, getLabelProps()), titleText), /*#__PURE__*/React__default["default"].createElement(index$1["default"], {
|
|
566
560
|
onFocus: handleFocus,
|
|
567
561
|
onBlur: handleFocus,
|
|
568
562
|
className: className,
|
|
@@ -574,7 +568,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
574
568
|
light: light,
|
|
575
569
|
size: size,
|
|
576
570
|
warn: warn,
|
|
577
|
-
ref:
|
|
571
|
+
ref: enableFloatingStyles ? refs.setReference : null,
|
|
578
572
|
warnText: warnText,
|
|
579
573
|
warnTextId: warnTextId
|
|
580
574
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -587,11 +581,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
587
581
|
"aria-haspopup": "listbox",
|
|
588
582
|
title: textInput?.current?.value
|
|
589
583
|
}, getInputProps({
|
|
584
|
+
'aria-label': titleText ? undefined : deprecatedAriaLabel || ariaLabel,
|
|
590
585
|
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
591
586
|
placeholder,
|
|
592
587
|
value: inputValue,
|
|
593
588
|
onChange: e => {
|
|
594
589
|
const newValue = e.target.value;
|
|
590
|
+
setInputValue(newValue);
|
|
595
591
|
downshiftSetInputValue(newValue);
|
|
596
592
|
},
|
|
597
593
|
ref: mergeRefs["default"](textInput, ref, inputRef),
|
|
@@ -648,7 +644,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
648
644
|
if (matchingItem) {
|
|
649
645
|
const newValue = itemToString(matchingItem);
|
|
650
646
|
downshiftSetInputValue(newValue);
|
|
651
|
-
setCursorPosition(newValue.length);
|
|
652
647
|
selectItem(matchingItem);
|
|
653
648
|
}
|
|
654
649
|
}
|
|
@@ -671,12 +666,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
671
666
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
672
667
|
isOpen: isOpen,
|
|
673
668
|
translateWithId: translateWithId
|
|
674
|
-
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index
|
|
669
|
+
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index$1["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
675
670
|
const isObject = item !== null && typeof item === 'object';
|
|
676
671
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
677
672
|
const itemProps = getItemProps({
|
|
678
673
|
item,
|
|
679
|
-
index
|
|
674
|
+
index
|
|
680
675
|
});
|
|
681
676
|
|
|
682
677
|
// The initial implementation using <Downshift> would place the disabled attribute
|
|
@@ -689,10 +684,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
689
684
|
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
690
685
|
...modifiedItemProps
|
|
691
686
|
} = itemProps;
|
|
692
|
-
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
687
|
+
return /*#__PURE__*/React__default["default"].createElement(index$1["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
693
688
|
key: itemProps.id,
|
|
694
689
|
isActive: selectedItem === item,
|
|
695
|
-
isHighlighted: highlightedIndex === index
|
|
690
|
+
isHighlighted: highlightedIndex === index,
|
|
696
691
|
title: title,
|
|
697
692
|
disabled: disabled
|
|
698
693
|
}, modifiedItemProps), ItemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -14,7 +14,7 @@ var React = require('react');
|
|
|
14
14
|
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
|
-
var index = require('../IconButton/index.js');
|
|
17
|
+
var index$1 = require('../IconButton/index.js');
|
|
18
18
|
var Button = require('../Button/Button.js');
|
|
19
19
|
require('../Button/Button.Skeleton.js');
|
|
20
20
|
var Menu = require('../Menu/Menu.js');
|
|
@@ -24,6 +24,7 @@ var useId = require('../../internal/useId.js');
|
|
|
24
24
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
27
|
+
var index = require('../FeatureFlags/index.js');
|
|
27
28
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
28
29
|
|
|
29
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -57,12 +58,18 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
57
58
|
translateWithId: t = defaultTranslateWithId,
|
|
58
59
|
...rest
|
|
59
60
|
} = _ref;
|
|
61
|
+
// feature flag utilized to separate out only the dynamic styles from @floating-ui
|
|
62
|
+
// flag is turned on when collision detection (ie. flip, hide) logic is not desired
|
|
63
|
+
const enableOnlyFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles');
|
|
60
64
|
const id = useId.useId('combobutton');
|
|
61
65
|
const prefix = usePrefix.usePrefix();
|
|
62
66
|
const containerRef = React.useRef(null);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
let middlewares = [];
|
|
68
|
+
if (!enableOnlyFloatingStyles) {
|
|
69
|
+
middlewares = [react.flip({
|
|
70
|
+
crossAxis: false
|
|
71
|
+
}), floatingUi_dom.hide()];
|
|
72
|
+
}
|
|
66
73
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
67
74
|
middlewares.push(react.size({
|
|
68
75
|
apply(_ref2) {
|
|
@@ -137,7 +144,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
137
144
|
size: size,
|
|
138
145
|
disabled: disabled,
|
|
139
146
|
onClick: handlePrimaryActionClick
|
|
140
|
-
}, label)), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
147
|
+
}, label)), /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, {
|
|
141
148
|
ref: refs.setReference,
|
|
142
149
|
className: triggerClasses,
|
|
143
150
|
label: t('carbon.combo-button.additional-actions'),
|
|
@@ -28,8 +28,5 @@ interface TableCellProps extends ReactAttr<HTMLTableCellElement> {
|
|
|
28
28
|
*/
|
|
29
29
|
headers?: string;
|
|
30
30
|
}
|
|
31
|
-
declare const TableCell:
|
|
32
|
-
({ children, className, hasSlugHeader, colSpan, ...rest }: TableCellProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
displayName: string;
|
|
34
|
-
};
|
|
31
|
+
declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
|
|
35
32
|
export default TableCell;
|