@carbon/react 1.54.0 → 1.55.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 +1065 -1012
- 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.d.ts +1 -1
- package/es/components/ComposedModal/ComposedModal.js +6 -6
- package/es/components/DataTable/TableBatchAction.d.ts +1 -5
- package/es/components/Dropdown/Dropdown.js +3 -1
- package/es/components/Modal/Modal.js +3 -3
- 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/Tabs/Tabs.js +44 -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/HeaderMenu.d.ts +219 -0
- package/es/components/UIShell/HeaderMenu.js +22 -10
- 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.d.ts +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +5 -5
- package/lib/components/DataTable/TableBatchAction.d.ts +1 -5
- package/lib/components/Dropdown/Dropdown.js +3 -1
- package/lib/components/Modal/Modal.js +3 -3
- 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/Tabs/Tabs.js +44 -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/HeaderMenu.d.ts +219 -0
- package/lib/components/UIShell/HeaderMenu.js +22 -10
- 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 +4 -4
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
/**
|
|
10
|
+
* `HeaderMenu` is used to render submenu's in the `Header`. Most often children
|
|
11
|
+
* will be a `HeaderMenuItem`. It handles certain keyboard events to help
|
|
12
|
+
* with managing focus. It also passes along refs to each child so that it can
|
|
13
|
+
* help manage focus state of its children.
|
|
14
|
+
*/
|
|
15
|
+
interface HeaderMenuProps {
|
|
16
|
+
/**
|
|
17
|
+
* Required props for the accessibility label of the menu
|
|
18
|
+
*/
|
|
19
|
+
'aria-label'?: string;
|
|
20
|
+
'aria-labelledby'?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Provide a custom ref handler for the menu button
|
|
27
|
+
*/
|
|
28
|
+
focusRef?: React.Ref<any>;
|
|
29
|
+
/**
|
|
30
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
31
|
+
*/
|
|
32
|
+
isActive?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
35
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
36
|
+
*/
|
|
37
|
+
isCurrentPage?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Provide a label for the link text
|
|
40
|
+
*/
|
|
41
|
+
menuLinkName: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optionally provide an onBlur handler that is called when the underlying
|
|
44
|
+
* button fires it's onblur event
|
|
45
|
+
*/
|
|
46
|
+
onBlur?: (event: React.FocusEvent<HTMLLIElement>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Optionally provide an onClick handler that is called when the underlying
|
|
49
|
+
* button fires it's onclick event
|
|
50
|
+
*/
|
|
51
|
+
onClick?: (event: React.MouseEvent<HTMLLIElement, MouseEvent>) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Optionally provide an onKeyDown handler that is called when the underlying
|
|
54
|
+
* button fires it's onkeydown event
|
|
55
|
+
*/
|
|
56
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLLIElement>) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Optional component to render instead of string
|
|
59
|
+
*/
|
|
60
|
+
renderMenuContent?: () => JSX.Element;
|
|
61
|
+
/**
|
|
62
|
+
* Optionally provide a tabIndex for the underlying menu button
|
|
63
|
+
*/
|
|
64
|
+
tabIndex?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The children should be a series of `HeaderMenuItem` components.
|
|
67
|
+
*/
|
|
68
|
+
children?: React.ReactNode;
|
|
69
|
+
}
|
|
70
|
+
interface HeaderMenuState {
|
|
71
|
+
expanded: boolean;
|
|
72
|
+
selectedIndex: number | null;
|
|
73
|
+
}
|
|
74
|
+
declare class HeaderMenu extends React.Component<HeaderMenuProps, HeaderMenuState> {
|
|
75
|
+
static propTypes: {
|
|
76
|
+
/**
|
|
77
|
+
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
78
|
+
*/
|
|
79
|
+
className: PropTypes.Requireable<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Provide a custom ref handler for the menu button
|
|
82
|
+
*/
|
|
83
|
+
focusRef: PropTypes.Requireable<(...args: any[]) => any>;
|
|
84
|
+
/**
|
|
85
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
86
|
+
*/
|
|
87
|
+
isActive: PropTypes.Requireable<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* Applies selected styles to the item if a user sets this to true and `aria-current !== 'page'`.
|
|
90
|
+
* @deprecated Please use `isActive` instead. This will be removed in the next major release.
|
|
91
|
+
*/
|
|
92
|
+
isCurrentPage: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
93
|
+
/**
|
|
94
|
+
* Provide a label for the link text
|
|
95
|
+
*/
|
|
96
|
+
menuLinkName: PropTypes.Validator<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Optionally provide an onBlur handler that is called when the underlying
|
|
99
|
+
* button fires it's onblur event
|
|
100
|
+
*/
|
|
101
|
+
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
102
|
+
/**
|
|
103
|
+
* Optionally provide an onClick handler that is called when the underlying
|
|
104
|
+
* button fires it's onclick event
|
|
105
|
+
*/
|
|
106
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
107
|
+
/**
|
|
108
|
+
* Optionally provide an onKeyDown handler that is called when the underlying
|
|
109
|
+
* button fires it's onkeydown event
|
|
110
|
+
*/
|
|
111
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
112
|
+
/**
|
|
113
|
+
* Optional component to render instead of string
|
|
114
|
+
*/
|
|
115
|
+
renderMenuContent: PropTypes.Requireable<(...args: any[]) => any>;
|
|
116
|
+
/**
|
|
117
|
+
* Optionally provide a tabIndex for the underlying menu button
|
|
118
|
+
*/
|
|
119
|
+
tabIndex: PropTypes.Requireable<number>;
|
|
120
|
+
0: string;
|
|
121
|
+
length: 1;
|
|
122
|
+
toString(): string;
|
|
123
|
+
toLocaleString(): string;
|
|
124
|
+
pop(): string | undefined;
|
|
125
|
+
push(...items: string[]): number;
|
|
126
|
+
concat(...items: ConcatArray<string>[]): string[];
|
|
127
|
+
concat(...items: (string | ConcatArray<string>)[]): string[];
|
|
128
|
+
join(separator?: string | undefined): string;
|
|
129
|
+
reverse(): string[];
|
|
130
|
+
shift(): string | undefined;
|
|
131
|
+
slice(start?: number | undefined, end?: number | undefined): string[];
|
|
132
|
+
sort(compareFn?: ((a: string, b: string) => number) | undefined): [key: string];
|
|
133
|
+
splice(start: number, deleteCount?: number | undefined): string[];
|
|
134
|
+
splice(start: number, deleteCount: number, ...items: string[]): string[];
|
|
135
|
+
unshift(...items: string[]): number;
|
|
136
|
+
indexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
137
|
+
lastIndexOf(searchElement: string, fromIndex?: number | undefined): number;
|
|
138
|
+
every<S extends string>(predicate: (value: string, index: number, array: string[]) => value is S, thisArg?: any): this is S[];
|
|
139
|
+
every(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
140
|
+
some(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): boolean;
|
|
141
|
+
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
|
|
142
|
+
map<U>(callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];
|
|
143
|
+
filter<S_1 extends string>(predicate: (value: string, index: number, array: string[]) => value is S_1, thisArg?: any): S_1[];
|
|
144
|
+
filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[];
|
|
145
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
146
|
+
reduce(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
147
|
+
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: string, currentIndex: number, array: string[]) => U_1, initialValue: U_1): U_1;
|
|
148
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string): string;
|
|
149
|
+
reduceRight(callbackfn: (previousValue: string, currentValue: string, currentIndex: number, array: string[]) => string, initialValue: string): string;
|
|
150
|
+
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: string, currentIndex: number, array: string[]) => U_2, initialValue: U_2): U_2;
|
|
151
|
+
find<S_2 extends string>(predicate: (this: void, value: string, index: number, obj: string[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
152
|
+
find(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): string | undefined;
|
|
153
|
+
findIndex(predicate: (value: string, index: number, obj: string[]) => unknown, thisArg?: any): number;
|
|
154
|
+
fill(value: string, start?: number | undefined, end?: number | undefined): [key: string];
|
|
155
|
+
copyWithin(target: number, start: number, end?: number | undefined): [key: string];
|
|
156
|
+
entries(): IterableIterator<[number, string]>;
|
|
157
|
+
keys(): IterableIterator<number>;
|
|
158
|
+
values(): IterableIterator<string>;
|
|
159
|
+
includes(searchElement: string, fromIndex?: number | undefined): boolean;
|
|
160
|
+
flatMap<U_3, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
161
|
+
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
162
|
+
at(index: number): string | undefined;
|
|
163
|
+
[Symbol.iterator](): IterableIterator<string>;
|
|
164
|
+
[Symbol.unscopables](): {
|
|
165
|
+
copyWithin: boolean;
|
|
166
|
+
entries: boolean;
|
|
167
|
+
fill: boolean;
|
|
168
|
+
find: boolean;
|
|
169
|
+
findIndex: boolean;
|
|
170
|
+
keys: boolean;
|
|
171
|
+
values: boolean;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
static contextType: React.Context<string>;
|
|
175
|
+
_subMenus: React.RefObject<HTMLUListElement>;
|
|
176
|
+
private items;
|
|
177
|
+
private menuButtonRef;
|
|
178
|
+
constructor(props: any);
|
|
179
|
+
/**
|
|
180
|
+
* Toggle the expanded state of the menu on click.
|
|
181
|
+
*/
|
|
182
|
+
handleOnClick: (e: any) => void;
|
|
183
|
+
/**
|
|
184
|
+
* Keyboard event handler for the entire menu.
|
|
185
|
+
*/
|
|
186
|
+
handleOnKeyDown: (event: any) => void;
|
|
187
|
+
/**
|
|
188
|
+
* Handle our blur event from our underlying menuitems. Will mostly be used
|
|
189
|
+
* for closing our menu in response to a user clicking off or tabbing out of
|
|
190
|
+
* the menu or menubar.
|
|
191
|
+
*/
|
|
192
|
+
handleOnBlur: (event: any) => void;
|
|
193
|
+
/**
|
|
194
|
+
* ref handler for our menu button. If we are supplied a `focusRef` prop, we also
|
|
195
|
+
* forward along the node.
|
|
196
|
+
*
|
|
197
|
+
* This is useful when this component is a child in a
|
|
198
|
+
* menu or menubar as it will allow the parent to explicitly focus the menu
|
|
199
|
+
* button node when that child should receive focus.
|
|
200
|
+
*/
|
|
201
|
+
handleMenuButtonRef: (node: any) => void;
|
|
202
|
+
/**
|
|
203
|
+
* Handles individual menuitem refs. We assign them to a class instance
|
|
204
|
+
* property so that we can properly manage focus of our children.
|
|
205
|
+
*/
|
|
206
|
+
handleItemRef: (index: any) => (node: any) => void;
|
|
207
|
+
handleMenuClose: (event: any) => void;
|
|
208
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
209
|
+
/**
|
|
210
|
+
* We capture the `ref` for each child inside of `this.items` to properly
|
|
211
|
+
* manage focus. In addition to this focus management, all items receive a
|
|
212
|
+
* `tabIndex: -1` so the user won't hit a large number of items in their tab
|
|
213
|
+
* sequence when they might not want to go through all the items.
|
|
214
|
+
*/
|
|
215
|
+
_renderMenuItem: (item: React.ReactNode, index: number) => React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
216
|
+
}
|
|
217
|
+
declare const HeaderMenuForwardRef: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
|
|
218
|
+
export { HeaderMenu };
|
|
219
|
+
export default HeaderMenuForwardRef;
|
|
@@ -23,10 +23,13 @@ import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
|
|
|
23
23
|
* with managing focus. It also passes along refs to each child so that it can
|
|
24
24
|
* help manage focus state of its children.
|
|
25
25
|
*/
|
|
26
|
+
|
|
26
27
|
class HeaderMenu extends React__default.Component {
|
|
27
28
|
constructor(props) {
|
|
28
29
|
super(props);
|
|
29
30
|
_defineProperty(this, "_subMenus", /*#__PURE__*/React__default.createRef());
|
|
31
|
+
_defineProperty(this, "items", []);
|
|
32
|
+
_defineProperty(this, "menuButtonRef", null);
|
|
30
33
|
/**
|
|
31
34
|
* Toggle the expanded state of the menu on click.
|
|
32
35
|
*/
|
|
@@ -81,8 +84,12 @@ class HeaderMenu extends React__default.Component {
|
|
|
81
84
|
* button node when that child should receive focus.
|
|
82
85
|
*/
|
|
83
86
|
_defineProperty(this, "handleMenuButtonRef", node => {
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const {
|
|
88
|
+
focusRef
|
|
89
|
+
} = this.props;
|
|
90
|
+
// Check if focusRef is a function before calling it
|
|
91
|
+
if (typeof focusRef === 'function') {
|
|
92
|
+
focusRef(node);
|
|
86
93
|
}
|
|
87
94
|
this.menuButtonRef = node;
|
|
88
95
|
});
|
|
@@ -104,7 +111,9 @@ class HeaderMenu extends React__default.Component {
|
|
|
104
111
|
}));
|
|
105
112
|
|
|
106
113
|
// Return focus to menu button when the user hits ESC.
|
|
107
|
-
this.menuButtonRef
|
|
114
|
+
if (this.menuButtonRef !== null) {
|
|
115
|
+
this.menuButtonRef.focus();
|
|
116
|
+
}
|
|
108
117
|
return;
|
|
109
118
|
}
|
|
110
119
|
});
|
|
@@ -141,23 +150,25 @@ class HeaderMenu extends React__default.Component {
|
|
|
141
150
|
children,
|
|
142
151
|
renderMenuContent: MenuContent,
|
|
143
152
|
menuLinkName,
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
144
154
|
focusRef,
|
|
145
|
-
// eslint-disable-line no-unused-vars
|
|
146
155
|
onBlur,
|
|
147
156
|
onClick,
|
|
148
157
|
onKeyDown,
|
|
149
158
|
...rest
|
|
150
159
|
} = this.props;
|
|
151
|
-
const hasActiveDescendant = childrenArg => React__default.Children.toArray(childrenArg).some(child =>
|
|
160
|
+
const hasActiveDescendant = childrenArg => React__default.Children.toArray(childrenArg).some(child => /*#__PURE__*/React__default.isValidElement(child) && (
|
|
161
|
+
// This is the type guard
|
|
162
|
+
child.props.isActive || child.props.isCurrentPage || Array.isArray(child.props.children) && hasActiveDescendant(child.props.children)));
|
|
152
163
|
const accessibilityLabel = {
|
|
153
164
|
'aria-label': ariaLabel,
|
|
154
165
|
'aria-labelledby': ariaLabelledBy
|
|
155
166
|
};
|
|
156
167
|
const itemClassName = cx({
|
|
157
168
|
[`${prefix}--header__submenu`]: true,
|
|
158
|
-
[customClassName]: !!customClassName
|
|
169
|
+
[`${customClassName}`]: !!customClassName
|
|
159
170
|
});
|
|
160
|
-
|
|
171
|
+
const isActivePage = isActive ? isActive : isCurrentPage;
|
|
161
172
|
const linkClassName = cx({
|
|
162
173
|
[`${prefix}--header__menu-item`]: true,
|
|
163
174
|
[`${prefix}--header__menu-title`]: true,
|
|
@@ -248,11 +259,12 @@ _defineProperty(HeaderMenu, "propTypes", {
|
|
|
248
259
|
});
|
|
249
260
|
_defineProperty(HeaderMenu, "contextType", PrefixContext);
|
|
250
261
|
const HeaderMenuForwardRef = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
251
|
-
return /*#__PURE__*/React__default.createElement(HeaderMenu, _extends({
|
|
262
|
+
return /*#__PURE__*/React__default.createElement(HeaderMenu, _extends({
|
|
263
|
+
menuLinkName: "link"
|
|
264
|
+
}, props, {
|
|
252
265
|
focusRef: ref
|
|
253
266
|
}));
|
|
254
267
|
});
|
|
255
268
|
HeaderMenuForwardRef.displayName = 'HeaderMenu';
|
|
256
|
-
var HeaderMenuForwardRef$1 = HeaderMenuForwardRef;
|
|
257
269
|
|
|
258
|
-
export { HeaderMenu, HeaderMenuForwardRef
|
|
270
|
+
export { HeaderMenu, HeaderMenuForwardRef as default };
|
|
@@ -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 };
|
|
@@ -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;
|