@carbon/react 1.39.0-rc.0 → 1.40.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 +2121 -857
- package/es/components/CodeSnippet/CodeSnippet.js +2 -2
- package/es/components/DataTable/TableSelectAll.js +1 -0
- package/es/components/DataTable/TableSelectRow.js +2 -1
- package/es/components/FileUploader/FileUploaderItem.d.ts +4 -0
- package/es/components/FileUploader/FileUploaderItem.js +32 -5
- package/es/components/FileUploader/Filename.js +2 -1
- package/es/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/es/components/MultiSelect/MultiSelect.js +26 -0
- package/es/components/Search/Search.js +1 -1
- package/es/components/StructuredList/StructuredList.Skeleton.d.ts +32 -0
- package/es/components/StructuredList/StructuredList.Skeleton.js +16 -26
- package/es/components/StructuredList/StructuredList.d.ts +271 -0
- package/es/components/StructuredList/StructuredList.js +14 -33
- package/es/components/StructuredList/index.d.ts +8 -0
- package/es/components/UIShell/SideNavDivider.js +2 -2
- package/es/components/UIShell/SideNavLinkText.d.ts +26 -0
- package/es/components/UIShell/SideNavLinkText.js +1 -1
- package/es/components/UIShell/SideNavMenu.d.ts +46 -0
- package/es/components/UIShell/SideNavMenu.js +23 -13
- package/es/index.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
- package/lib/components/DataTable/TableSelectAll.js +1 -0
- package/lib/components/DataTable/TableSelectRow.js +2 -1
- package/lib/components/FileUploader/FileUploaderItem.d.ts +4 -0
- package/lib/components/FileUploader/FileUploaderItem.js +31 -4
- package/lib/components/FileUploader/Filename.js +2 -1
- package/lib/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/lib/components/MultiSelect/MultiSelect.js +26 -0
- package/lib/components/Search/Search.js +1 -1
- package/lib/components/StructuredList/StructuredList.Skeleton.d.ts +32 -0
- package/lib/components/StructuredList/StructuredList.Skeleton.js +16 -26
- package/lib/components/StructuredList/StructuredList.d.ts +271 -0
- package/lib/components/StructuredList/StructuredList.js +14 -33
- package/lib/components/StructuredList/index.d.ts +8 -0
- package/lib/components/UIShell/SideNavDivider.js +2 -2
- package/lib/components/UIShell/SideNavLinkText.d.ts +26 -0
- package/lib/components/UIShell/SideNavLinkText.js +2 -2
- package/lib/components/UIShell/SideNavMenu.d.ts +46 -0
- package/lib/components/UIShell/SideNavMenu.js +23 -13
- package/lib/index.js +9 -9
- package/package.json +6 -5
|
@@ -0,0 +1,271 @@
|
|
|
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 { type HTMLAttributes, type ReactNode, type KeyboardEvent, type ChangeEvent, type MouseEvent } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
type DivAttrs = HTMLAttributes<HTMLDivElement>;
|
|
10
|
+
export interface StructuredListWrapperProps extends DivAttrs {
|
|
11
|
+
/**
|
|
12
|
+
* Specify a label to be read by screen readers on the container node
|
|
13
|
+
*/
|
|
14
|
+
'aria-label'?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Provide the contents of your StructuredListWrapper
|
|
17
|
+
*/
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Specify an optional className to be applied to the container node
|
|
21
|
+
*/
|
|
22
|
+
className?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specify if structured list is condensed, default is false
|
|
25
|
+
*/
|
|
26
|
+
isCondensed?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Specify if structured list is flush, default is false
|
|
29
|
+
*/
|
|
30
|
+
isFlush?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specify whether your StructuredListWrapper should have selections
|
|
33
|
+
*/
|
|
34
|
+
selection?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function StructuredListWrapper(props: StructuredListWrapperProps): JSX.Element;
|
|
37
|
+
export declare namespace StructuredListWrapper {
|
|
38
|
+
var propTypes: {
|
|
39
|
+
/**
|
|
40
|
+
* Specify a label to be read by screen readers on the container node
|
|
41
|
+
*/
|
|
42
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Deprecated, please use `aria-label` instead.
|
|
45
|
+
* Specify a label to be read by screen readers on the container note.
|
|
46
|
+
*/
|
|
47
|
+
ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
48
|
+
/**
|
|
49
|
+
* Provide the contents of your StructuredListWrapper
|
|
50
|
+
*/
|
|
51
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
52
|
+
/**
|
|
53
|
+
* Specify an optional className to be applied to the container node
|
|
54
|
+
*/
|
|
55
|
+
className: PropTypes.Requireable<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Specify if structured list is condensed, default is false
|
|
58
|
+
*/
|
|
59
|
+
isCondensed: PropTypes.Requireable<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Specify if structured list is flush, not valid for selection variant, default is false
|
|
62
|
+
*/
|
|
63
|
+
isFlush: PropTypes.Requireable<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Specify whether your StructuredListWrapper should have selections
|
|
66
|
+
*/
|
|
67
|
+
selection: PropTypes.Requireable<boolean>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface StructuredListHeadProps extends DivAttrs {
|
|
71
|
+
/**
|
|
72
|
+
* Provide the contents of your StructuredListHead
|
|
73
|
+
*/
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Specify an optional className to be applied to the node
|
|
77
|
+
*/
|
|
78
|
+
className?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare function StructuredListHead(props: any): JSX.Element;
|
|
81
|
+
export declare namespace StructuredListHead {
|
|
82
|
+
var propTypes: {
|
|
83
|
+
/**
|
|
84
|
+
* Provide the contents of your StructuredListHead
|
|
85
|
+
*/
|
|
86
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
87
|
+
/**
|
|
88
|
+
* Specify an optional className to be applied to the node
|
|
89
|
+
*/
|
|
90
|
+
className: PropTypes.Requireable<string>;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface StructuredListBodyProps extends DivAttrs {
|
|
94
|
+
/**
|
|
95
|
+
* Provide the contents of your StructuredListBody
|
|
96
|
+
*/
|
|
97
|
+
children?: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* Specify an optional className to be applied to the container node
|
|
100
|
+
*/
|
|
101
|
+
className?: string;
|
|
102
|
+
head?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Provide a handler that is invoked on the key down event for the control
|
|
105
|
+
*/
|
|
106
|
+
onKeyDown?(event: KeyboardEvent): void;
|
|
107
|
+
}
|
|
108
|
+
export declare function StructuredListBody(props: StructuredListBodyProps): JSX.Element;
|
|
109
|
+
export declare namespace StructuredListBody {
|
|
110
|
+
var propTypes: {
|
|
111
|
+
/**
|
|
112
|
+
* Provide the contents of your StructuredListBody
|
|
113
|
+
*/
|
|
114
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
115
|
+
/**
|
|
116
|
+
* Specify an optional className to be applied to the container node
|
|
117
|
+
*/
|
|
118
|
+
className: PropTypes.Requireable<string>;
|
|
119
|
+
head: PropTypes.Requireable<boolean>;
|
|
120
|
+
/**
|
|
121
|
+
* Provide a handler that is invoked on the key down event for the control
|
|
122
|
+
*/
|
|
123
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface StructuredListRowProps extends DivAttrs {
|
|
127
|
+
/**
|
|
128
|
+
* Provide the contents of your StructuredListRow
|
|
129
|
+
*/
|
|
130
|
+
children?: ReactNode;
|
|
131
|
+
/**
|
|
132
|
+
* Specify an optional className to be applied to the container node
|
|
133
|
+
*/
|
|
134
|
+
className?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Specify whether your StructuredListRow should be used as a header row
|
|
137
|
+
*/
|
|
138
|
+
head?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Provide a handler that is invoked on the click
|
|
141
|
+
*/
|
|
142
|
+
onClick?(event: MouseEvent): void;
|
|
143
|
+
/**
|
|
144
|
+
* Provide a handler that is invoked on the key down event for the control
|
|
145
|
+
*/
|
|
146
|
+
onKeyDown?(event: KeyboardEvent): void;
|
|
147
|
+
}
|
|
148
|
+
export declare function StructuredListRow(props: StructuredListRowProps): JSX.Element;
|
|
149
|
+
export declare namespace StructuredListRow {
|
|
150
|
+
var propTypes: {
|
|
151
|
+
/**
|
|
152
|
+
* Provide the contents of your StructuredListRow
|
|
153
|
+
*/
|
|
154
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
155
|
+
/**
|
|
156
|
+
* Specify an optional className to be applied to the container node
|
|
157
|
+
*/
|
|
158
|
+
className: PropTypes.Requireable<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Specify whether your StructuredListRow should be used as a header row
|
|
161
|
+
*/
|
|
162
|
+
head: PropTypes.Requireable<boolean>;
|
|
163
|
+
/**
|
|
164
|
+
* Specify whether a `<label>` should be used
|
|
165
|
+
*/
|
|
166
|
+
label: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
167
|
+
/**
|
|
168
|
+
* Provide a handler that is invoked on the click
|
|
169
|
+
*/
|
|
170
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
171
|
+
/**
|
|
172
|
+
* Provide a handler that is invoked on the key down event for the control,
|
|
173
|
+
*/
|
|
174
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
export interface StructuredListInputProps extends DivAttrs {
|
|
178
|
+
/**
|
|
179
|
+
* Specify an optional className to be applied to the input
|
|
180
|
+
*/
|
|
181
|
+
className?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Specify a custom `id` for the input
|
|
184
|
+
*/
|
|
185
|
+
id?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Provide a `name` for the input
|
|
188
|
+
*/
|
|
189
|
+
name?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Provide an optional hook that is called each time the input is updated
|
|
192
|
+
*/
|
|
193
|
+
onChange?(event: ChangeEvent<HTMLInputElement>): void;
|
|
194
|
+
/**
|
|
195
|
+
* Provide a `title` for the input
|
|
196
|
+
*/
|
|
197
|
+
title?: string;
|
|
198
|
+
}
|
|
199
|
+
export declare function StructuredListInput(props: StructuredListInputProps): JSX.Element;
|
|
200
|
+
export declare namespace StructuredListInput {
|
|
201
|
+
var propTypes: {
|
|
202
|
+
/**
|
|
203
|
+
* Specify an optional className to be applied to the input
|
|
204
|
+
*/
|
|
205
|
+
className: PropTypes.Requireable<string>;
|
|
206
|
+
/**
|
|
207
|
+
* Specify whether the underlying input should be checked by default
|
|
208
|
+
*/
|
|
209
|
+
defaultChecked: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
210
|
+
/**
|
|
211
|
+
* Specify a custom `id` for the input
|
|
212
|
+
*/
|
|
213
|
+
id: PropTypes.Requireable<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Provide a `name` for the input
|
|
216
|
+
*/
|
|
217
|
+
name: PropTypes.Requireable<string>;
|
|
218
|
+
/**
|
|
219
|
+
* Provide an optional hook that is called each time the input is updated
|
|
220
|
+
*/
|
|
221
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
222
|
+
/**
|
|
223
|
+
* Provide a `title` for the input
|
|
224
|
+
*/
|
|
225
|
+
title: PropTypes.Requireable<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Specify the value of the input
|
|
228
|
+
*/
|
|
229
|
+
value: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
export interface StructuredListCellProps extends DivAttrs {
|
|
233
|
+
/**
|
|
234
|
+
* Provide the contents of your StructuredListCell
|
|
235
|
+
*/
|
|
236
|
+
children?: ReactNode;
|
|
237
|
+
/**
|
|
238
|
+
* Specify an optional className to be applied to the container node
|
|
239
|
+
*/
|
|
240
|
+
className?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Specify whether your StructuredListCell should be used as a header cell
|
|
243
|
+
*/
|
|
244
|
+
head?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Specify whether your StructuredListCell should have text wrapping
|
|
247
|
+
*/
|
|
248
|
+
noWrap?: boolean;
|
|
249
|
+
}
|
|
250
|
+
export declare function StructuredListCell(props: StructuredListCellProps): JSX.Element;
|
|
251
|
+
export declare namespace StructuredListCell {
|
|
252
|
+
var propTypes: {
|
|
253
|
+
/**
|
|
254
|
+
* Provide the contents of your StructuredListCell
|
|
255
|
+
*/
|
|
256
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
257
|
+
/**
|
|
258
|
+
* Specify an optional className to be applied to the container node
|
|
259
|
+
*/
|
|
260
|
+
className: PropTypes.Requireable<string>;
|
|
261
|
+
/**
|
|
262
|
+
* Specify whether your StructuredListCell should be used as a header cell
|
|
263
|
+
*/
|
|
264
|
+
head: PropTypes.Requireable<boolean>;
|
|
265
|
+
/**
|
|
266
|
+
* Specify whether your StructuredListCell should have text wrapping
|
|
267
|
+
*/
|
|
268
|
+
noWrap: PropTypes.Requireable<boolean>;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
export {};
|
|
@@ -30,18 +30,19 @@ function StructuredListWrapper(props) {
|
|
|
30
30
|
children,
|
|
31
31
|
selection,
|
|
32
32
|
className,
|
|
33
|
-
['aria-label']: ariaLabel,
|
|
33
|
+
['aria-label']: ariaLabel = 'Structured list section',
|
|
34
|
+
// @ts-expect-error: Deprecated prop
|
|
34
35
|
ariaLabel: deprecatedAriaLabel,
|
|
35
36
|
isCondensed,
|
|
36
37
|
isFlush,
|
|
37
38
|
...other
|
|
38
39
|
} = props;
|
|
39
40
|
const prefix = usePrefix.usePrefix();
|
|
40
|
-
const classes = cx__default["default"](`${prefix}--structured-list`,
|
|
41
|
+
const classes = cx__default["default"](`${prefix}--structured-list`, {
|
|
41
42
|
[`${prefix}--structured-list--selection`]: selection,
|
|
42
43
|
[`${prefix}--structured-list--condensed`]: isCondensed,
|
|
43
44
|
[`${prefix}--structured-list--flush`]: isFlush && !selection
|
|
44
|
-
});
|
|
45
|
+
}, className);
|
|
45
46
|
const [selectedRow, setSelectedRow] = React__default["default"].useState(null);
|
|
46
47
|
return /*#__PURE__*/React__default["default"].createElement(GridSelectedRowStateContext.Provider, {
|
|
47
48
|
value: selectedRow
|
|
@@ -85,12 +86,6 @@ StructuredListWrapper.propTypes = {
|
|
|
85
86
|
*/
|
|
86
87
|
selection: PropTypes__default["default"].bool
|
|
87
88
|
};
|
|
88
|
-
StructuredListWrapper.defaultProps = {
|
|
89
|
-
selection: false,
|
|
90
|
-
isCondensed: false,
|
|
91
|
-
isFlush: false,
|
|
92
|
-
['aria-label']: 'Structured list section'
|
|
93
|
-
};
|
|
94
89
|
function StructuredListHead(props) {
|
|
95
90
|
const {
|
|
96
91
|
children,
|
|
@@ -142,9 +137,6 @@ StructuredListBody.propTypes = {
|
|
|
142
137
|
*/
|
|
143
138
|
onKeyDown: PropTypes__default["default"].func
|
|
144
139
|
};
|
|
145
|
-
StructuredListBody.defaultProps = {
|
|
146
|
-
onKeyDown: () => {}
|
|
147
|
-
};
|
|
148
140
|
const GridRowContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
149
141
|
function StructuredListRow(props) {
|
|
150
142
|
const {
|
|
@@ -163,11 +155,11 @@ function StructuredListRow(props) {
|
|
|
163
155
|
const value = {
|
|
164
156
|
id
|
|
165
157
|
};
|
|
166
|
-
const classes = cx__default["default"](`${prefix}--structured-list-row`,
|
|
158
|
+
const classes = cx__default["default"](`${prefix}--structured-list-row`, {
|
|
167
159
|
[`${prefix}--structured-list-row--header-row`]: head,
|
|
168
160
|
[`${prefix}--structured-list-row--focused-within`]: hasFocusWithin,
|
|
169
161
|
[`${prefix}--structured-list-row--selected`]: selectedRow === id
|
|
170
|
-
});
|
|
162
|
+
}, className);
|
|
171
163
|
return head ? /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({
|
|
172
164
|
role: "row"
|
|
173
165
|
}, other, {
|
|
@@ -181,9 +173,9 @@ function StructuredListRow(props) {
|
|
|
181
173
|
}, other, {
|
|
182
174
|
role: "row",
|
|
183
175
|
className: classes,
|
|
184
|
-
onClick:
|
|
185
|
-
setSelectedRow(id);
|
|
186
|
-
onClick && onClick();
|
|
176
|
+
onClick: event => {
|
|
177
|
+
setSelectedRow?.(id);
|
|
178
|
+
onClick && onClick(event);
|
|
187
179
|
},
|
|
188
180
|
onFocus: () => {
|
|
189
181
|
setHasFocusWithin(true);
|
|
@@ -214,7 +206,7 @@ StructuredListRow.propTypes = {
|
|
|
214
206
|
*/
|
|
215
207
|
label: deprecate["default"](PropTypes__default["default"].bool, `\nThe \`label\` prop is no longer needed and will be removed in the next major version of Carbon.`),
|
|
216
208
|
/**
|
|
217
|
-
* Provide a handler that is invoked on the click
|
|
209
|
+
* Provide a handler that is invoked on the click
|
|
218
210
|
*/
|
|
219
211
|
onClick: PropTypes__default["default"].func,
|
|
220
212
|
/**
|
|
@@ -222,10 +214,6 @@ StructuredListRow.propTypes = {
|
|
|
222
214
|
*/
|
|
223
215
|
onKeyDown: PropTypes__default["default"].func
|
|
224
216
|
};
|
|
225
|
-
StructuredListRow.defaultProps = {
|
|
226
|
-
head: false,
|
|
227
|
-
onKeyDown: () => {}
|
|
228
|
-
};
|
|
229
217
|
function StructuredListInput(props) {
|
|
230
218
|
const defaultId = useId.useId('structureListInput');
|
|
231
219
|
const {
|
|
@@ -244,10 +232,10 @@ function StructuredListInput(props) {
|
|
|
244
232
|
return /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({}, other, {
|
|
245
233
|
type: "radio",
|
|
246
234
|
tabIndex: 0,
|
|
247
|
-
checked: row && row.id === selectedRow,
|
|
235
|
+
checked: !!row && row.id === selectedRow,
|
|
248
236
|
value: row?.id ?? '',
|
|
249
237
|
onChange: event => {
|
|
250
|
-
setSelectedRow(event.target.value);
|
|
238
|
+
setSelectedRow?.(event.target.value);
|
|
251
239
|
onChange && onChange(event);
|
|
252
240
|
},
|
|
253
241
|
id: id ?? defaultId,
|
|
@@ -286,9 +274,6 @@ StructuredListInput.propTypes = {
|
|
|
286
274
|
*/
|
|
287
275
|
value: deprecate["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]).isRequired, `\nThe prop \`value\` will be removed in the next major version of Carbon.`)
|
|
288
276
|
};
|
|
289
|
-
StructuredListInput.defaultProps = {
|
|
290
|
-
title: 'title'
|
|
291
|
-
};
|
|
292
277
|
function StructuredListCell(props) {
|
|
293
278
|
const {
|
|
294
279
|
children,
|
|
@@ -298,11 +283,11 @@ function StructuredListCell(props) {
|
|
|
298
283
|
...other
|
|
299
284
|
} = props;
|
|
300
285
|
const prefix = usePrefix.usePrefix();
|
|
301
|
-
const classes = cx__default["default"](
|
|
286
|
+
const classes = cx__default["default"]({
|
|
302
287
|
[`${prefix}--structured-list-th`]: head,
|
|
303
288
|
[`${prefix}--structured-list-td`]: !head,
|
|
304
289
|
[`${prefix}--structured-list-content--nowrap`]: noWrap
|
|
305
|
-
});
|
|
290
|
+
}, className);
|
|
306
291
|
if (head) {
|
|
307
292
|
return /*#__PURE__*/React__default["default"].createElement("span", _rollupPluginBabelHelpers["extends"]({
|
|
308
293
|
className: classes,
|
|
@@ -332,10 +317,6 @@ StructuredListCell.propTypes = {
|
|
|
332
317
|
*/
|
|
333
318
|
noWrap: PropTypes__default["default"].bool
|
|
334
319
|
};
|
|
335
|
-
StructuredListCell.defaultProps = {
|
|
336
|
-
head: false,
|
|
337
|
-
noWrap: false
|
|
338
|
-
};
|
|
339
320
|
|
|
340
321
|
exports.StructuredListBody = StructuredListBody;
|
|
341
322
|
exports.StructuredListCell = StructuredListCell;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export * from './StructuredList';
|
|
8
|
+
export { default as StructuredListSkeleton, type StructuredListSkeletonProps, } from './StructuredList.Skeleton';
|
|
@@ -20,6 +20,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
20
20
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
21
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
22
|
|
|
23
|
+
var _hr;
|
|
23
24
|
function SideNavDivider(_ref) {
|
|
24
25
|
let {
|
|
25
26
|
className
|
|
@@ -27,9 +28,8 @@ function SideNavDivider(_ref) {
|
|
|
27
28
|
const prefix = usePrefix.usePrefix();
|
|
28
29
|
const classNames = cx__default["default"](`${prefix}--side-nav__divider`, className);
|
|
29
30
|
return /*#__PURE__*/React__default["default"].createElement("li", {
|
|
30
|
-
role: "separator",
|
|
31
31
|
className: classNames
|
|
32
|
-
});
|
|
32
|
+
}, _hr || (_hr = /*#__PURE__*/React__default["default"].createElement("hr", null)));
|
|
33
33
|
}
|
|
34
34
|
SideNavDivider.propTypes = {
|
|
35
35
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
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 { ReactNode } from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
export interface SideNavLinkTextProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
declare function SideNavLinkText({ className: customClassName, children, ...rest }: SideNavLinkTextProps): JSX.Element;
|
|
14
|
+
declare namespace SideNavLinkText {
|
|
15
|
+
var propTypes: {
|
|
16
|
+
/**
|
|
17
|
+
* Provide the content for the link text
|
|
18
|
+
*/
|
|
19
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
20
|
+
/**
|
|
21
|
+
* Provide an optional class to be applied to the containing node
|
|
22
|
+
*/
|
|
23
|
+
className: PropTypes.Requireable<string>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export default SideNavLinkText;
|
|
@@ -11,15 +11,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var cx = require('classnames');
|
|
14
|
-
var PropTypes = require('prop-types');
|
|
15
14
|
var React = require('react');
|
|
16
15
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
16
|
+
var PropTypes = require('prop-types');
|
|
17
17
|
|
|
18
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
19
|
|
|
20
20
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
22
21
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
23
23
|
|
|
24
24
|
function SideNavLinkText(_ref) {
|
|
25
25
|
let {
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
interface SideNavMenuProps {
|
|
9
|
+
/**
|
|
10
|
+
* An optional CSS class to apply to the component.
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The content to render within the SideNavMenu component.
|
|
15
|
+
*/
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Specifies whether the menu should be expanded by default.
|
|
19
|
+
*/
|
|
20
|
+
defaultExpanded?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates whether the SideNavMenu is active.
|
|
23
|
+
*/
|
|
24
|
+
isActive?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Specifies whether the SideNavMenu is in a large variation.
|
|
27
|
+
*/
|
|
28
|
+
large?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* A custom icon to render next to the SideNavMenu title. This can be a function returning JSX or JSX itself.
|
|
31
|
+
*/
|
|
32
|
+
renderIcon?: React.ComponentType;
|
|
33
|
+
/**
|
|
34
|
+
* Indicates if the side navigation container is expanded or collapsed.
|
|
35
|
+
*/
|
|
36
|
+
isSideNavExpanded?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The tabIndex for the button element.
|
|
39
|
+
* If not specified, the default validation will be applied.
|
|
40
|
+
*/
|
|
41
|
+
tabIndex?: number;
|
|
42
|
+
title: string;
|
|
43
|
+
}
|
|
44
|
+
declare const SideNavMenu: React.ForwardRefExoticComponent<SideNavMenuProps & React.RefAttributes<HTMLElement>>;
|
|
45
|
+
export default SideNavMenu;
|
|
46
|
+
export { SideNavMenu };
|
|
@@ -26,8 +26,8 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
26
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
27
27
|
|
|
28
28
|
var _ChevronDown;
|
|
29
|
-
const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function SideNavMenu(
|
|
30
|
-
|
|
29
|
+
const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function SideNavMenu(_ref, ref) {
|
|
30
|
+
let {
|
|
31
31
|
className: customClassName,
|
|
32
32
|
children,
|
|
33
33
|
defaultExpanded = false,
|
|
@@ -37,7 +37,7 @@ const SideNavMenu = /*#__PURE__*/React__default["default"].forwardRef(function S
|
|
|
37
37
|
isSideNavExpanded,
|
|
38
38
|
tabIndex,
|
|
39
39
|
title
|
|
40
|
-
} =
|
|
40
|
+
} = _ref;
|
|
41
41
|
const isRail = React.useContext(SideNav.SideNavContext);
|
|
42
42
|
const prefix = usePrefix.usePrefix();
|
|
43
43
|
const [isExpanded, setIsExpanded] = React.useState(defaultExpanded);
|
|
@@ -121,6 +121,7 @@ SideNavMenu.propTypes = {
|
|
|
121
121
|
/**
|
|
122
122
|
* Pass in a custom icon to render next to the `SideNavMenu` title
|
|
123
123
|
*/
|
|
124
|
+
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
124
125
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
125
126
|
/**
|
|
126
127
|
* Optional prop to specify the tabIndex of the button. If undefined, it will be applied default validation
|
|
@@ -131,30 +132,39 @@ SideNavMenu.propTypes = {
|
|
|
131
132
|
*/
|
|
132
133
|
title: PropTypes__default["default"].string.isRequired
|
|
133
134
|
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
Defining the children parameter with the type ReactNode | ReactNode[]. This allows for various possibilities:
|
|
138
|
+
a single element, an array of elements, or null or undefined.
|
|
139
|
+
**/
|
|
134
140
|
function hasActiveChild(children) {
|
|
135
|
-
// if we have children, either a single or multiple, find if it is active
|
|
136
141
|
if (Array.isArray(children)) {
|
|
137
142
|
return children.some(child => {
|
|
138
|
-
if (!child
|
|
143
|
+
if (! /*#__PURE__*/React__default["default"].isValidElement(child)) {
|
|
139
144
|
return false;
|
|
140
145
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
|
|
147
|
+
/** Explicitly defining the expected prop types (isActive and 'aria-current) for the children to ensure type
|
|
148
|
+
safety when accessing their props.
|
|
149
|
+
**/
|
|
150
|
+
const props = child.props;
|
|
151
|
+
if (props.isActive === true || props['aria-current']) {
|
|
145
152
|
return true;
|
|
146
153
|
}
|
|
147
154
|
return false;
|
|
148
155
|
});
|
|
149
156
|
}
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
|
|
158
|
+
// We use React.isValidElement(child) to check if the child is a valid React element before accessing its props
|
|
159
|
+
|
|
160
|
+
if ( /*#__PURE__*/React__default["default"].isValidElement(children)) {
|
|
161
|
+
const props = children.props;
|
|
162
|
+
if (props.isActive === true || props['aria-current']) {
|
|
152
163
|
return true;
|
|
153
164
|
}
|
|
154
165
|
}
|
|
155
166
|
return false;
|
|
156
167
|
}
|
|
157
|
-
var SideNavMenu$1 = SideNavMenu;
|
|
158
168
|
|
|
159
169
|
exports.SideNavMenu = SideNavMenu;
|
|
160
|
-
exports["default"] = SideNavMenu
|
|
170
|
+
exports["default"] = SideNavMenu;
|
package/lib/index.js
CHANGED
|
@@ -80,6 +80,8 @@ var SelectItemGroup = require('./components/SelectItemGroup/SelectItemGroup.js')
|
|
|
80
80
|
var SkeletonPlaceholder = require('./components/SkeletonPlaceholder/SkeletonPlaceholder.js');
|
|
81
81
|
var SkeletonText = require('./components/SkeletonText/SkeletonText.js');
|
|
82
82
|
var index$9 = require('./components/Slider/index.js');
|
|
83
|
+
var StructuredList = require('./components/StructuredList/StructuredList.js');
|
|
84
|
+
var StructuredList_Skeleton = require('./components/StructuredList/StructuredList.Skeleton.js');
|
|
83
85
|
var Tabs = require('./components/Tabs/Tabs.js');
|
|
84
86
|
var TabContent = require('./components/TabContent/TabContent.js');
|
|
85
87
|
var Tabs_Skeleton = require('./components/Tabs/Tabs.Skeleton.js');
|
|
@@ -219,8 +221,6 @@ var RadioTile = require('./components/RadioTile/RadioTile.js');
|
|
|
219
221
|
var SecondaryButton = require('./components/SecondaryButton/SecondaryButton.js');
|
|
220
222
|
var SkeletonIcon = require('./components/SkeletonIcon/SkeletonIcon.js');
|
|
221
223
|
var Slider_Skeleton = require('./components/Slider/Slider.Skeleton.js');
|
|
222
|
-
var StructuredList_Skeleton = require('./components/StructuredList/StructuredList.Skeleton.js');
|
|
223
|
-
var StructuredList = require('./components/StructuredList/StructuredList.js');
|
|
224
224
|
var Switch = require('./components/Switch/Switch.js');
|
|
225
225
|
var IconSwitch = require('./components/Switch/IconSwitch.js');
|
|
226
226
|
var Stack = require('./components/Stack/Stack.js');
|
|
@@ -305,6 +305,13 @@ exports.SelectItemGroup = SelectItemGroup["default"];
|
|
|
305
305
|
exports.SkeletonPlaceholder = SkeletonPlaceholder["default"];
|
|
306
306
|
exports.SkeletonText = SkeletonText["default"];
|
|
307
307
|
exports.Slider = index$9["default"];
|
|
308
|
+
exports.StructuredListBody = StructuredList.StructuredListBody;
|
|
309
|
+
exports.StructuredListCell = StructuredList.StructuredListCell;
|
|
310
|
+
exports.StructuredListHead = StructuredList.StructuredListHead;
|
|
311
|
+
exports.StructuredListInput = StructuredList.StructuredListInput;
|
|
312
|
+
exports.StructuredListRow = StructuredList.StructuredListRow;
|
|
313
|
+
exports.StructuredListWrapper = StructuredList.StructuredListWrapper;
|
|
314
|
+
exports.StructuredListSkeleton = StructuredList_Skeleton["default"];
|
|
308
315
|
exports.IconTab = Tabs.IconTab;
|
|
309
316
|
exports.Tab = Tabs.Tab;
|
|
310
317
|
exports.TabList = Tabs.TabList;
|
|
@@ -472,13 +479,6 @@ exports.RadioTile = RadioTile["default"];
|
|
|
472
479
|
exports.SecondaryButton = SecondaryButton["default"];
|
|
473
480
|
exports.SkeletonIcon = SkeletonIcon["default"];
|
|
474
481
|
exports.SliderSkeleton = Slider_Skeleton["default"];
|
|
475
|
-
exports.StructuredListSkeleton = StructuredList_Skeleton["default"];
|
|
476
|
-
exports.StructuredListBody = StructuredList.StructuredListBody;
|
|
477
|
-
exports.StructuredListCell = StructuredList.StructuredListCell;
|
|
478
|
-
exports.StructuredListHead = StructuredList.StructuredListHead;
|
|
479
|
-
exports.StructuredListInput = StructuredList.StructuredListInput;
|
|
480
|
-
exports.StructuredListRow = StructuredList.StructuredListRow;
|
|
481
|
-
exports.StructuredListWrapper = StructuredList.StructuredListWrapper;
|
|
482
482
|
exports.Switch = Switch["default"];
|
|
483
483
|
exports.IconSwitch = IconSwitch["default"];
|
|
484
484
|
exports.Stack = Stack.Stack;
|