@carbon/react 1.54.0-rc.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 +994 -1023
- package/es/components/Button/Button.d.ts +1 -1
- package/es/components/Button/Button.js +13 -89
- package/es/components/Button/ButtonBase.d.ts +10 -0
- package/es/components/Button/ButtonBase.js +110 -0
- 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 -18
- 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/IconButton/index.js +2 -3
- package/es/components/Menu/Menu.js +2 -0
- package/es/components/Modal/Modal.js +2 -2
- package/es/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +31 -0
- package/es/components/MultiSelect/MultiSelect.js +37 -7
- package/es/components/Slider/Slider.Skeleton.js +6 -2
- package/es/components/Slug/index.js +8 -13
- package/es/components/StructuredList/StructuredList.d.ts +8 -0
- package/es/components/StructuredList/StructuredList.js +28 -10
- 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/feature-flags.js +2 -1
- package/es/index.js +5 -2
- package/es/internal/environment.js +5 -1
- package/es/internal/keyboard/navigation.js +6 -2
- package/es/internal/useOutsideClick.js +31 -0
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/Button.js +13 -90
- package/lib/components/Button/ButtonBase.d.ts +10 -0
- package/lib/components/Button/ButtonBase.js +119 -0
- 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 -18
- 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/IconButton/index.js +2 -3
- package/lib/components/Menu/Menu.js +2 -0
- package/lib/components/Modal/Modal.js +2 -2
- package/lib/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +31 -0
- package/lib/components/MultiSelect/MultiSelect.js +37 -7
- package/lib/components/Slider/Slider.Skeleton.js +5 -1
- package/lib/components/Slug/index.js +8 -13
- package/lib/components/StructuredList/StructuredList.d.ts +8 -0
- package/lib/components/StructuredList/StructuredList.js +27 -9
- 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/feature-flags.js +2 -1
- package/lib/index.js +10 -4
- package/lib/internal/environment.js +5 -1
- package/lib/internal/keyboard/navigation.js +6 -2
- package/lib/internal/useOutsideClick.js +35 -0
- package/package.json +6 -6
|
@@ -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
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var cx = require('classnames');
|
|
14
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
15
|
+
var useId = require('../../internal/useId.js');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
|
+
|
|
22
|
+
const ButtonBase = /*#__PURE__*/React__default["default"].forwardRef(function ButtonBase(_ref, ref) {
|
|
23
|
+
let {
|
|
24
|
+
as,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
dangerDescription = 'danger',
|
|
28
|
+
disabled = false,
|
|
29
|
+
hasIconOnly = false,
|
|
30
|
+
href,
|
|
31
|
+
iconDescription,
|
|
32
|
+
isExpressive = false,
|
|
33
|
+
isSelected,
|
|
34
|
+
kind = 'primary',
|
|
35
|
+
onBlur,
|
|
36
|
+
onClick,
|
|
37
|
+
onFocus,
|
|
38
|
+
onMouseEnter,
|
|
39
|
+
onMouseLeave,
|
|
40
|
+
renderIcon: ButtonImageElement,
|
|
41
|
+
size,
|
|
42
|
+
tabIndex,
|
|
43
|
+
type = 'button',
|
|
44
|
+
...rest
|
|
45
|
+
} = _ref;
|
|
46
|
+
const prefix = usePrefix.usePrefix();
|
|
47
|
+
const buttonClasses = cx__default["default"](className, {
|
|
48
|
+
[`${prefix}--btn`]: true,
|
|
49
|
+
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
50
|
+
// TODO: V12 - Remove this class
|
|
51
|
+
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
52
|
+
// TODO: V12 - Remove this class
|
|
53
|
+
[`${prefix}--btn--xl`]: size === 'xl',
|
|
54
|
+
// TODO: V12 - Remove this class
|
|
55
|
+
[`${prefix}--btn--2xl`]: size === '2xl',
|
|
56
|
+
// TODO: V12 - Remove this class
|
|
57
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
58
|
+
[`${prefix}--btn--${kind}`]: kind,
|
|
59
|
+
[`${prefix}--btn--disabled`]: disabled,
|
|
60
|
+
[`${prefix}--btn--expressive`]: isExpressive,
|
|
61
|
+
[`${prefix}--btn--icon-only`]: hasIconOnly && !className?.includes(`${prefix}--btn--icon-only`),
|
|
62
|
+
[`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost'
|
|
63
|
+
});
|
|
64
|
+
const commonProps = {
|
|
65
|
+
tabIndex,
|
|
66
|
+
className: buttonClasses,
|
|
67
|
+
ref
|
|
68
|
+
};
|
|
69
|
+
const buttonImage = !ButtonImageElement ? null : /*#__PURE__*/React__default["default"].createElement(ButtonImageElement, {
|
|
70
|
+
"aria-label": iconDescription,
|
|
71
|
+
className: `${prefix}--btn__icon`,
|
|
72
|
+
"aria-hidden": "true"
|
|
73
|
+
});
|
|
74
|
+
const dangerButtonVariants = ['danger', 'danger--tertiary', 'danger--ghost'];
|
|
75
|
+
let component = 'button';
|
|
76
|
+
const assistiveId = useId.useId('danger-description');
|
|
77
|
+
const {
|
|
78
|
+
'aria-pressed': ariaPressed,
|
|
79
|
+
'aria-describedby': ariaDescribedBy
|
|
80
|
+
} = rest;
|
|
81
|
+
let otherProps = {
|
|
82
|
+
disabled,
|
|
83
|
+
type,
|
|
84
|
+
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : ariaDescribedBy || undefined,
|
|
85
|
+
'aria-pressed': ariaPressed ?? (hasIconOnly && kind === 'ghost' ? isSelected : undefined)
|
|
86
|
+
};
|
|
87
|
+
const anchorProps = {
|
|
88
|
+
href
|
|
89
|
+
};
|
|
90
|
+
let assistiveText = null;
|
|
91
|
+
if (dangerButtonVariants.includes(kind)) {
|
|
92
|
+
assistiveText = /*#__PURE__*/React__default["default"].createElement("span", {
|
|
93
|
+
id: assistiveId,
|
|
94
|
+
className: `${prefix}--visually-hidden`
|
|
95
|
+
}, dangerDescription);
|
|
96
|
+
}
|
|
97
|
+
if (as) {
|
|
98
|
+
component = as;
|
|
99
|
+
otherProps = {
|
|
100
|
+
...otherProps,
|
|
101
|
+
...anchorProps
|
|
102
|
+
};
|
|
103
|
+
} else if (href && !disabled) {
|
|
104
|
+
component = 'a';
|
|
105
|
+
otherProps = anchorProps;
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React__default["default"].createElement(component, {
|
|
108
|
+
onMouseEnter,
|
|
109
|
+
onMouseLeave,
|
|
110
|
+
onFocus,
|
|
111
|
+
onBlur,
|
|
112
|
+
onClick,
|
|
113
|
+
...rest,
|
|
114
|
+
...commonProps,
|
|
115
|
+
...otherProps
|
|
116
|
+
}, assistiveText, children, buttonImage);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
exports["default"] = ButtonBase;
|
|
@@ -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 };
|
|
@@ -0,0 +1,196 @@
|
|
|
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 { PropsWithChildren } from 'react';
|
|
9
|
+
export interface CodeSnippetProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specify how the trigger should align with the tooltip
|
|
12
|
+
*/
|
|
13
|
+
align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
|
14
|
+
/**
|
|
15
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
16
|
+
* node
|
|
17
|
+
*/
|
|
18
|
+
['aria-label']?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Deprecated, please use `aria-label` instead.
|
|
21
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
22
|
+
* node
|
|
23
|
+
*/
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Specify an optional className to be applied to the container node
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Specify the description for the Copy Button
|
|
31
|
+
*/
|
|
32
|
+
copyButtonDescription?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional text to copy. If not specified, the `children` node's `innerText`
|
|
35
|
+
* will be used as the copy value.
|
|
36
|
+
*/
|
|
37
|
+
copyText?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Specify whether or not the CodeSnippet should be disabled
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify the string displayed when the snippet is copied
|
|
44
|
+
*/
|
|
45
|
+
feedback?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Specify the time it takes for the feedback message to timeout
|
|
48
|
+
*/
|
|
49
|
+
feedbackTimeout?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Specify whether or not a copy button should be used/rendered.
|
|
52
|
+
*/
|
|
53
|
+
hideCopyButton?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Specify whether you are using the light variant of the Code Snippet,
|
|
56
|
+
* typically used for inline snippet to display an alternate color
|
|
57
|
+
*/
|
|
58
|
+
light?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Specify the maximum number of rows to be shown when in collapsed view
|
|
61
|
+
*/
|
|
62
|
+
maxCollapsedNumberOfRows?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Specify the maximum number of rows to be shown when in expanded view
|
|
65
|
+
*/
|
|
66
|
+
maxExpandedNumberOfRows?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Specify the minimum number of rows to be shown when in collapsed view
|
|
69
|
+
*/
|
|
70
|
+
minCollapsedNumberOfRows?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Specify the minimum number of rows to be shown when in expanded view
|
|
73
|
+
*/
|
|
74
|
+
minExpandedNumberOfRows?: number;
|
|
75
|
+
/**
|
|
76
|
+
* An optional handler to listen to the `onClick` even fired by the Copy
|
|
77
|
+
* Button
|
|
78
|
+
*/
|
|
79
|
+
onClick?: (e: MouseEvent) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Specify a string that is displayed when the Code Snippet has been
|
|
82
|
+
* interacted with to show more lines
|
|
83
|
+
*/
|
|
84
|
+
showLessText?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Specify a string that is displayed when the Code Snippet text is more
|
|
87
|
+
* than 15 lines
|
|
88
|
+
*/
|
|
89
|
+
showMoreText?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Provide the type of Code Snippet
|
|
92
|
+
*/
|
|
93
|
+
type?: 'single' | 'inline' | 'multi';
|
|
94
|
+
/**
|
|
95
|
+
* Specify whether or not to wrap the text.
|
|
96
|
+
*/
|
|
97
|
+
wrapText?: boolean;
|
|
98
|
+
}
|
|
99
|
+
declare function CodeSnippet({ align, className, type, children, disabled, feedback, feedbackTimeout, onClick, ['aria-label']: ariaLabel, ariaLabel: deprecatedAriaLabel, copyText, copyButtonDescription, light, showMoreText, showLessText, hideCopyButton, wrapText, maxCollapsedNumberOfRows, maxExpandedNumberOfRows, minCollapsedNumberOfRows, minExpandedNumberOfRows, ...rest }: PropsWithChildren<CodeSnippetProps>): import("react/jsx-runtime").JSX.Element;
|
|
100
|
+
declare namespace CodeSnippet {
|
|
101
|
+
var propTypes: {
|
|
102
|
+
/**
|
|
103
|
+
* Specify how the trigger should align with the tooltip
|
|
104
|
+
*/
|
|
105
|
+
align: PropTypes.Requireable<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
108
|
+
* node
|
|
109
|
+
*/
|
|
110
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
111
|
+
/**
|
|
112
|
+
* Deprecated, please use `aria-label` instead.
|
|
113
|
+
* Specify a label to be read by screen readers on the containing textbox
|
|
114
|
+
* node
|
|
115
|
+
*/
|
|
116
|
+
ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
117
|
+
/**
|
|
118
|
+
* Provide the content of your CodeSnippet as a node or string
|
|
119
|
+
*/
|
|
120
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
121
|
+
/**
|
|
122
|
+
* Specify an optional className to be applied to the container node
|
|
123
|
+
*/
|
|
124
|
+
className: PropTypes.Requireable<string>;
|
|
125
|
+
/**
|
|
126
|
+
* Specify the description for the Copy Button
|
|
127
|
+
*/
|
|
128
|
+
copyButtonDescription: PropTypes.Requireable<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Optional text to copy. If not specified, the `children` node's `innerText`
|
|
131
|
+
* will be used as the copy value.
|
|
132
|
+
*/
|
|
133
|
+
copyText: PropTypes.Requireable<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Specify whether or not the CodeSnippet should be disabled
|
|
136
|
+
*/
|
|
137
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
138
|
+
/**
|
|
139
|
+
* Specify the string displayed when the snippet is copied
|
|
140
|
+
*/
|
|
141
|
+
feedback: PropTypes.Requireable<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Specify the time it takes for the feedback message to timeout
|
|
144
|
+
*/
|
|
145
|
+
feedbackTimeout: PropTypes.Requireable<number>;
|
|
146
|
+
/**
|
|
147
|
+
* Specify whether or not a copy button should be used/rendered.
|
|
148
|
+
*/
|
|
149
|
+
hideCopyButton: PropTypes.Requireable<boolean>;
|
|
150
|
+
/**
|
|
151
|
+
* Specify whether you are using the light variant of the Code Snippet,
|
|
152
|
+
* typically used for inline snippet to display an alternate color
|
|
153
|
+
*/
|
|
154
|
+
light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
155
|
+
/**
|
|
156
|
+
* Specify the maximum number of rows to be shown when in collapsed view
|
|
157
|
+
*/
|
|
158
|
+
maxCollapsedNumberOfRows: PropTypes.Requireable<number>;
|
|
159
|
+
/**
|
|
160
|
+
* Specify the maximum number of rows to be shown when in expanded view
|
|
161
|
+
*/
|
|
162
|
+
maxExpandedNumberOfRows: PropTypes.Requireable<number>;
|
|
163
|
+
/**
|
|
164
|
+
* Specify the minimum number of rows to be shown when in collapsed view
|
|
165
|
+
*/
|
|
166
|
+
minCollapsedNumberOfRows: PropTypes.Requireable<number>;
|
|
167
|
+
/**
|
|
168
|
+
* Specify the minimum number of rows to be shown when in expanded view
|
|
169
|
+
*/
|
|
170
|
+
minExpandedNumberOfRows: PropTypes.Requireable<number>;
|
|
171
|
+
/**
|
|
172
|
+
* An optional handler to listen to the `onClick` even fired by the Copy
|
|
173
|
+
* Button
|
|
174
|
+
*/
|
|
175
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
176
|
+
/**
|
|
177
|
+
* Specify a string that is displayed when the Code Snippet has been
|
|
178
|
+
* interacted with to show more lines
|
|
179
|
+
*/
|
|
180
|
+
showLessText: PropTypes.Requireable<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Specify a string that is displayed when the Code Snippet text is more
|
|
183
|
+
* than 15 lines
|
|
184
|
+
*/
|
|
185
|
+
showMoreText: PropTypes.Requireable<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Provide the type of Code Snippet
|
|
188
|
+
*/
|
|
189
|
+
type: PropTypes.Requireable<string>;
|
|
190
|
+
/**
|
|
191
|
+
* Specify whether or not to wrap the text.
|
|
192
|
+
*/
|
|
193
|
+
wrapText: PropTypes.Requireable<boolean>;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export default CodeSnippet;
|
|
@@ -36,7 +36,7 @@ const rowHeightInPixels = 16;
|
|
|
36
36
|
const defaultMaxCollapsedNumberOfRows = 15;
|
|
37
37
|
const defaultMaxExpandedNumberOfRows = 0;
|
|
38
38
|
const defaultMinCollapsedNumberOfRows = 3;
|
|
39
|
-
const defaultMinExpandedNumberOfRows =
|
|
39
|
+
const defaultMinExpandedNumberOfRows = 16;
|
|
40
40
|
function CodeSnippet(_ref) {
|
|
41
41
|
let {
|
|
42
42
|
align = 'bottom',
|
|
@@ -67,9 +67,9 @@ function CodeSnippet(_ref) {
|
|
|
67
67
|
const {
|
|
68
68
|
current: uid
|
|
69
69
|
} = React.useRef(uniqueId["default"]());
|
|
70
|
-
const codeContentRef = React.useRef();
|
|
71
|
-
const codeContainerRef = React.useRef();
|
|
72
|
-
const innerCodeRef = React.useRef();
|
|
70
|
+
const codeContentRef = React.useRef(null);
|
|
71
|
+
const codeContainerRef = React.useRef(null);
|
|
72
|
+
const innerCodeRef = React.useRef(null);
|
|
73
73
|
const [hasLeftOverflow, setHasLeftOverflow] = React.useState(false);
|
|
74
74
|
const [hasRightOverflow, setHasRightOverflow] = React.useState(false);
|
|
75
75
|
const getCodeRef = React.useCallback(() => {
|
|
@@ -78,15 +78,17 @@ function CodeSnippet(_ref) {
|
|
|
78
78
|
}
|
|
79
79
|
if (type === 'multi') {
|
|
80
80
|
return codeContentRef;
|
|
81
|
+
} else {
|
|
82
|
+
return innerCodeRef;
|
|
81
83
|
}
|
|
82
84
|
}, [type]);
|
|
83
85
|
const prefix = usePrefix.usePrefix();
|
|
84
86
|
const getCodeRefDimensions = React.useCallback(() => {
|
|
85
87
|
const {
|
|
86
|
-
clientWidth: codeClientWidth,
|
|
87
|
-
scrollLeft: codeScrollLeft,
|
|
88
|
-
scrollWidth: codeScrollWidth
|
|
89
|
-
} = getCodeRef().current;
|
|
88
|
+
clientWidth: codeClientWidth = 0,
|
|
89
|
+
scrollLeft: codeScrollLeft = 0,
|
|
90
|
+
scrollWidth: codeScrollWidth = 0
|
|
91
|
+
} = getCodeRef().current || {};
|
|
90
92
|
return {
|
|
91
93
|
horizontalOverflow: codeScrollWidth > codeClientWidth,
|
|
92
94
|
codeClientWidth,
|
|
@@ -113,7 +115,7 @@ function CodeSnippet(_ref) {
|
|
|
113
115
|
if (codeContentRef?.current && type === 'multi') {
|
|
114
116
|
const {
|
|
115
117
|
height
|
|
116
|
-
} =
|
|
118
|
+
} = codeContentRef.current.getBoundingClientRect();
|
|
117
119
|
if (maxCollapsedNumberOfRows > 0 && (maxExpandedNumberOfRows <= 0 || maxExpandedNumberOfRows > maxCollapsedNumberOfRows) && height > maxCollapsedNumberOfRows * rowHeightInPixels) {
|
|
118
120
|
setShouldShowMoreLessBtn(true);
|
|
119
121
|
} else {
|
|
@@ -127,13 +129,13 @@ function CodeSnippet(_ref) {
|
|
|
127
129
|
handleScroll();
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
}
|
|
132
|
+
});
|
|
131
133
|
React.useEffect(() => {
|
|
132
134
|
handleScroll();
|
|
133
135
|
}, [handleScroll]);
|
|
134
136
|
const handleCopyClick = evt => {
|
|
135
137
|
if (copyText || innerCodeRef?.current) {
|
|
136
|
-
copy__default["default"](copyText ?? innerCodeRef?.current?.innerText);
|
|
138
|
+
copy__default["default"](copyText ?? innerCodeRef?.current?.innerText ?? '');
|
|
137
139
|
}
|
|
138
140
|
if (onClick) {
|
|
139
141
|
onClick(evt);
|
|
@@ -171,7 +173,7 @@ function CodeSnippet(_ref) {
|
|
|
171
173
|
ref: innerCodeRef
|
|
172
174
|
}, children));
|
|
173
175
|
}
|
|
174
|
-
|
|
176
|
+
const containerStyle = {};
|
|
175
177
|
if (type === 'multi') {
|
|
176
178
|
const styles = {};
|
|
177
179
|
if (expandedCode) {
|
|
@@ -197,16 +199,16 @@ function CodeSnippet(_ref) {
|
|
|
197
199
|
className: codeSnippetClasses
|
|
198
200
|
}), /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
199
201
|
ref: codeContainerRef,
|
|
200
|
-
role: type === 'single' || type === 'multi' ? 'textbox' :
|
|
201
|
-
tabIndex: (type === 'single' || type === 'multi') && !disabled ? 0 :
|
|
202
|
+
role: type === 'single' || type === 'multi' ? 'textbox' : undefined,
|
|
203
|
+
tabIndex: (type === 'single' || type === 'multi') && !disabled ? 0 : undefined,
|
|
202
204
|
className: `${prefix}--snippet-container`,
|
|
203
205
|
"aria-label": deprecatedAriaLabel || ariaLabel || 'code-snippet',
|
|
204
|
-
"aria-readonly": type === 'single' || type === 'multi' ? true :
|
|
205
|
-
"aria-multiline": type === 'multi' ? true :
|
|
206
|
-
onScroll: type === 'single' && handleScroll ||
|
|
206
|
+
"aria-readonly": type === 'single' || type === 'multi' ? true : undefined,
|
|
207
|
+
"aria-multiline": type === 'multi' ? true : undefined,
|
|
208
|
+
onScroll: type === 'single' && handleScroll || undefined
|
|
207
209
|
}, containerStyle), /*#__PURE__*/React__default["default"].createElement("pre", {
|
|
208
210
|
ref: codeContentRef,
|
|
209
|
-
onScroll: type === 'multi' && handleScroll ||
|
|
211
|
+
onScroll: type === 'multi' && handleScroll || undefined
|
|
210
212
|
}, /*#__PURE__*/React__default["default"].createElement("code", {
|
|
211
213
|
ref: innerCodeRef
|
|
212
214
|
}, children))), hasLeftOverflow && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -0,0 +1,10 @@
|
|
|
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 CodeSnippet from './CodeSnippet';
|
|
8
|
+
export default CodeSnippet;
|
|
9
|
+
export { CodeSnippet };
|
|
10
|
+
export { default as CodeSnippetSkeleton } from './CodeSnippet.Skeleton';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import Downshift from 'downshift';
|
|
8
8
|
import { ReactNodeLike } from 'prop-types';
|
|
9
|
-
import { type ComponentProps, type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type
|
|
9
|
+
import { type ComponentProps, type ReactNode, type ComponentType, type ReactElement, type RefAttributes, type PropsWithChildren, type PropsWithRef, type InputHTMLAttributes, type MouseEvent } from 'react';
|
|
10
10
|
import { ListBoxSize } from '../ListBox';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
12
12
|
interface OnChangeData<ItemType> {
|
|
@@ -159,7 +159,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
159
159
|
*/
|
|
160
160
|
warnText?: ReactNode;
|
|
161
161
|
}
|
|
162
|
-
type ComboboxComponentProps<ItemType> =
|
|
162
|
+
type ComboboxComponentProps<ItemType> = PropsWithRef<PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>>;
|
|
163
163
|
interface ComboBoxComponent {
|
|
164
164
|
<ItemType>(props: ComboboxComponentProps<ItemType>): ReactElement | null;
|
|
165
165
|
}
|
|
@@ -42,9 +42,11 @@ const {
|
|
|
42
42
|
keyDownArrowUp,
|
|
43
43
|
keyDownEscape,
|
|
44
44
|
clickButton,
|
|
45
|
+
clickItem,
|
|
45
46
|
blurButton,
|
|
46
47
|
changeInput,
|
|
47
|
-
blurInput
|
|
48
|
+
blurInput,
|
|
49
|
+
unknown
|
|
48
50
|
} = Downshift__default["default"].stateChangeTypes;
|
|
49
51
|
const defaultItemToString = item => {
|
|
50
52
|
if (typeof item === 'string') {
|
|
@@ -206,15 +208,16 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
206
208
|
switch (type) {
|
|
207
209
|
case keyDownArrowDown:
|
|
208
210
|
case keyDownArrowUp:
|
|
209
|
-
|
|
211
|
+
if (changes.isOpen) {
|
|
212
|
+
updateHighlightedIndex(getHighlightedIndex(changes));
|
|
213
|
+
} else {
|
|
214
|
+
setHighlightedIndex(changes.highlightedIndex);
|
|
215
|
+
}
|
|
210
216
|
break;
|
|
211
217
|
case blurButton:
|
|
212
218
|
case keyDownEscape:
|
|
213
219
|
setHighlightedIndex(changes.highlightedIndex);
|
|
214
220
|
break;
|
|
215
|
-
case clickButton:
|
|
216
|
-
setHighlightedIndex(changes.highlightedIndex);
|
|
217
|
-
break;
|
|
218
221
|
case changeInput:
|
|
219
222
|
updateHighlightedIndex(getHighlightedIndex(changes));
|
|
220
223
|
break;
|
|
@@ -229,6 +232,11 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
break;
|
|
235
|
+
case clickButton:
|
|
236
|
+
case clickItem:
|
|
237
|
+
case unknown:
|
|
238
|
+
setHighlightedIndex(getHighlightedIndex(changes));
|
|
239
|
+
break;
|
|
232
240
|
}
|
|
233
241
|
};
|
|
234
242
|
const handleToggleClick = isOpen => event => {
|
|
@@ -0,0 +1,51 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import { IconButton } from '../IconButton';
|
|
9
|
+
import Button from '../Button';
|
|
10
|
+
import { Menu } from '../Menu';
|
|
11
|
+
interface ComboButtonProps {
|
|
12
|
+
/**
|
|
13
|
+
* A collection of `MenuItems` to be rendered as additional actions for this `ComboButton`.
|
|
14
|
+
*/
|
|
15
|
+
children: React.ComponentProps<typeof Menu>['children'];
|
|
16
|
+
/**
|
|
17
|
+
* Additional CSS class names.
|
|
18
|
+
*/
|
|
19
|
+
className?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Specify whether the `ComboButton` should be disabled, or not.
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Provide the label to be rendered on the primary action button.
|
|
26
|
+
*/
|
|
27
|
+
label: React.ComponentProps<typeof Button>['title'];
|
|
28
|
+
/**
|
|
29
|
+
* Experimental property. Specify how the menu should align with the button element
|
|
30
|
+
*/
|
|
31
|
+
menuAlignment?: React.ComponentProps<typeof Menu>['menuAlignment'];
|
|
32
|
+
/**
|
|
33
|
+
* Provide an optional function to be called when the primary action element is clicked.
|
|
34
|
+
*/
|
|
35
|
+
onClick?: React.ComponentProps<typeof Button>['onClick'];
|
|
36
|
+
/**
|
|
37
|
+
* Specify the size of the buttons and menu.
|
|
38
|
+
*/
|
|
39
|
+
size?: 'sm' | 'md' | 'lg';
|
|
40
|
+
/**
|
|
41
|
+
* Specify how the trigger tooltip should be aligned.
|
|
42
|
+
*/
|
|
43
|
+
tooltipAlignment?: React.ComponentProps<typeof IconButton>['align'];
|
|
44
|
+
/**
|
|
45
|
+
* Optional method that takes in a message `id` and returns an
|
|
46
|
+
* internationalized string.
|
|
47
|
+
*/
|
|
48
|
+
translateWithId?: (id: string) => string;
|
|
49
|
+
}
|
|
50
|
+
declare const ComboButton: React.ForwardRefExoticComponent<ComboButtonProps & React.RefAttributes<HTMLDivElement>>;
|
|
51
|
+
export { ComboButton, type ComboButtonProps };
|
|
@@ -80,10 +80,12 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
function handleOpen() {
|
|
83
|
-
menuRef.current
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
if (menuRef.current) {
|
|
84
|
+
menuRef.current.style.inlineSize = `${width}px`;
|
|
85
|
+
menuRef.current.style.minInlineSize = `${width}px`;
|
|
86
|
+
if (menuAlignment !== 'bottom' && menuAlignment !== 'top') {
|
|
87
|
+
menuRef.current.style.inlineSize = `fit-content`;
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
const containerClasses = cx__default["default"](`${prefix}--combo-button__container`, `${prefix}--combo-button__container--${size}`, {
|
|
@@ -95,7 +97,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
95
97
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
96
98
|
className: containerClasses,
|
|
97
99
|
ref: ref,
|
|
98
|
-
"aria-owns": open ? id :
|
|
100
|
+
"aria-owns": open ? id : undefined
|
|
99
101
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
100
102
|
className: primaryActionClasses
|
|
101
103
|
}, /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
@@ -113,7 +115,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
113
115
|
"aria-expanded": open,
|
|
114
116
|
onClick: handleTriggerClick,
|
|
115
117
|
onMouseDown: handleTriggerMousedown,
|
|
116
|
-
"aria-controls": open ? id :
|
|
118
|
+
"aria-controls": open ? id : undefined
|
|
117
119
|
}, _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, null))), /*#__PURE__*/React__default["default"].createElement(Menu.Menu, {
|
|
118
120
|
containerRef: containerRef,
|
|
119
121
|
menuAlignment: menuAlignment,
|
|
@@ -144,7 +146,7 @@ ComboButton.propTypes = {
|
|
|
144
146
|
*/
|
|
145
147
|
disabled: PropTypes__default["default"].bool,
|
|
146
148
|
/**
|
|
147
|
-
* Provide the label to be
|
|
149
|
+
* Provide the label to be rendered on the primary action button.
|
|
148
150
|
*/
|
|
149
151
|
label: PropTypes__default["default"].string.isRequired,
|
|
150
152
|
/**
|
|
@@ -253,11 +253,11 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
253
253
|
}
|
|
254
254
|
}, [open, selectorPrimaryFocus, isOpen]);
|
|
255
255
|
|
|
256
|
-
// Slug is always size `
|
|
256
|
+
// Slug is always size `sm`
|
|
257
257
|
let normalizedSlug;
|
|
258
258
|
if (slug && slug['type']?.displayName === 'Slug') {
|
|
259
259
|
normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
|
|
260
|
-
size: '
|
|
260
|
+
size: 'sm'
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
263
|
return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
@@ -22,11 +22,7 @@ export interface TableBatchActionProps extends React.ButtonHTMLAttributes<HTMLBu
|
|
|
22
22
|
renderIcon?: React.ElementType;
|
|
23
23
|
}
|
|
24
24
|
declare const TableBatchAction: {
|
|
25
|
-
({ renderIcon, iconDescription, ...props }:
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
renderIcon?: import("@carbon/icons-react").CarbonIconType | undefined;
|
|
28
|
-
iconDescription?: string | undefined;
|
|
29
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
({ renderIcon, iconDescription, ...props }: TableBatchActionProps): import("react/jsx-runtime").JSX.Element;
|
|
30
26
|
propTypes: {
|
|
31
27
|
/**
|
|
32
28
|
* Specify if the button is an icon-only button
|
|
@@ -36,7 +36,8 @@ const {
|
|
|
36
36
|
ToggleButtonKeyDownArrowUp,
|
|
37
37
|
ToggleButtonKeyDownHome,
|
|
38
38
|
ToggleButtonKeyDownEnd,
|
|
39
|
-
ItemMouseMove
|
|
39
|
+
ItemMouseMove,
|
|
40
|
+
MenuMouseLeave
|
|
40
41
|
} = Downshift.useSelect.stateChangeTypes;
|
|
41
42
|
const defaultItemToString = item => {
|
|
42
43
|
if (typeof item === 'string') {
|
|
@@ -121,6 +122,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
121
122
|
}
|
|
122
123
|
return changes;
|
|
123
124
|
case ItemMouseMove:
|
|
125
|
+
case MenuMouseLeave:
|
|
124
126
|
return {
|
|
125
127
|
...changes,
|
|
126
128
|
highlightedIndex: state.highlightedIndex
|