@carbon/react 1.36.0 → 1.37.0-rc.1
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/es/components/Button/Button.js +12 -12
- package/es/components/ComboBox/ComboBox.js +2 -4
- package/es/components/DataTable/DataTable.d.ts +30 -0
- package/es/components/DataTable/DataTable.js +27 -0
- package/es/components/DataTable/TableBatchActions.d.ts +51 -0
- package/es/components/DataTable/TableBatchActions.js +39 -8
- package/es/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/es/components/DataTable/TableExpandHeader.js +17 -3
- package/es/components/DataTable/TableExpandRow.d.ts +24 -3
- package/es/components/DataTable/TableExpandRow.js +18 -3
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +176 -0
- package/es/components/DataTable/TableToolbarSearch.js +9 -4
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +40 -40
- package/es/components/FileUploader/FileUploader.Skeleton.d.ts +1 -4
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +9 -17
- package/es/components/FileUploader/FileUploaderDropContainer.js +21 -17
- package/es/components/FileUploader/FileUploaderItem.d.ts +3 -14
- package/es/components/FileUploader/FileUploaderItem.js +4 -4
- package/es/components/FormLabel/FormLabel.d.ts +40 -0
- package/es/components/FormLabel/index.d.ts +9 -0
- package/es/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/es/components/ListBox/ListBoxMenu.js +1 -1
- package/es/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/es/components/ListBox/ListBoxMenuItem.js +6 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -3
- package/es/components/MultiSelect/MultiSelect.js +77 -56
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +18 -44
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +24 -0
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +3 -5
- package/es/components/SkeletonPlaceholder/index.d.ts +9 -0
- package/es/components/Slider/Slider.d.ts +6 -0
- package/es/components/Slider/Slider.js +17 -2
- package/es/components/StructuredList/StructuredList.js +5 -2
- package/es/components/Tag/Tag.Skeleton.d.ts +35 -0
- package/es/components/Tag/Tag.d.ts +122 -0
- package/es/components/Tag/Tag.js +6 -6
- package/es/components/Tag/index.d.ts +11 -0
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/Tile/Tile.js +5 -5
- package/es/components/TimePicker/TimePicker.js +8 -6
- package/es/components/Toggle/Toggle.Skeleton.js +1 -4
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -3
- package/es/components/UIShell/HeaderMenuItem.js +1 -2
- package/es/components/UIShell/Link.js +1 -2
- package/es/components/UIShell/SideNav.js +1 -3
- package/es/components/UIShell/index.d.ts +35 -0
- package/es/index.js +32 -32
- package/es/types/common.d.ts +7 -0
- package/lib/components/Button/Button.js +12 -12
- package/lib/components/ComboBox/ComboBox.js +2 -4
- package/lib/components/DataTable/DataTable.d.ts +30 -0
- package/lib/components/DataTable/DataTable.js +27 -0
- package/lib/components/DataTable/TableBatchActions.d.ts +51 -0
- package/lib/components/DataTable/TableBatchActions.js +39 -8
- package/lib/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/lib/components/DataTable/TableExpandHeader.js +17 -3
- package/lib/components/DataTable/TableExpandRow.d.ts +24 -3
- package/lib/components/DataTable/TableExpandRow.js +18 -3
- package/lib/components/DataTable/TableRow.js +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +176 -0
- package/lib/components/DataTable/TableToolbarSearch.js +9 -4
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +39 -39
- package/lib/components/FileUploader/FileUploader.Skeleton.d.ts +1 -4
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +9 -17
- package/lib/components/FileUploader/FileUploaderDropContainer.js +21 -17
- package/lib/components/FileUploader/FileUploaderItem.d.ts +3 -14
- package/lib/components/FileUploader/FileUploaderItem.js +4 -4
- package/lib/components/FormLabel/FormLabel.d.ts +40 -0
- package/lib/components/FormLabel/index.d.ts +9 -0
- package/lib/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/lib/components/ListBox/ListBoxMenu.js +1 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/lib/components/ListBox/ListBoxMenuItem.js +6 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -3
- package/lib/components/MultiSelect/MultiSelect.js +75 -55
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +18 -44
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +24 -0
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +3 -5
- package/lib/components/SkeletonPlaceholder/index.d.ts +9 -0
- package/lib/components/Slider/Slider.d.ts +6 -0
- package/lib/components/Slider/Slider.js +17 -2
- package/lib/components/StructuredList/StructuredList.js +5 -2
- package/lib/components/Tag/Tag.Skeleton.d.ts +35 -0
- package/lib/components/Tag/Tag.d.ts +122 -0
- package/lib/components/Tag/Tag.js +6 -6
- package/lib/components/Tag/index.d.ts +11 -0
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/Tile/Tile.js +5 -5
- package/lib/components/TimePicker/TimePicker.js +8 -6
- package/lib/components/Toggle/Toggle.Skeleton.js +1 -4
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/ToggleSmall/ToggleSmall.Skeleton.js +0 -3
- package/lib/components/UIShell/HeaderMenuItem.js +1 -2
- package/lib/components/UIShell/Link.js +1 -2
- package/lib/components/UIShell/SideNav.js +1 -3
- package/lib/components/UIShell/index.d.ts +35 -0
- package/lib/index.js +65 -65
- package/lib/types/common.d.ts +7 -0
- package/package.json +5 -5
|
@@ -113,17 +113,18 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
|
|
|
113
113
|
component = 'a';
|
|
114
114
|
otherProps = anchorProps;
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
116
|
+
if (!hasIconOnly) {
|
|
117
|
+
return /*#__PURE__*/React__default.createElement(component, {
|
|
118
|
+
onMouseEnter,
|
|
119
|
+
onMouseLeave,
|
|
120
|
+
onFocus,
|
|
121
|
+
onBlur,
|
|
122
|
+
onClick,
|
|
123
|
+
...rest,
|
|
124
|
+
...commonProps,
|
|
125
|
+
...otherProps
|
|
126
|
+
}, assistiveText, children, buttonImage);
|
|
127
|
+
} else {
|
|
127
128
|
let align = undefined;
|
|
128
129
|
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
129
130
|
if (tooltipAlignment === 'center') {
|
|
@@ -152,7 +153,6 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
|
|
|
152
153
|
onClick: composeEventHandlers([onClick, handleClick])
|
|
153
154
|
}, rest, commonProps, otherProps), iconOnlyImage ? iconOnlyImage : children);
|
|
154
155
|
}
|
|
155
|
-
return Button;
|
|
156
156
|
});
|
|
157
157
|
Button.displayName = 'Button';
|
|
158
158
|
Button.propTypes = {
|
|
@@ -208,7 +208,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
208
208
|
}
|
|
209
209
|
if (event.target === textInput.current && isOpen) {
|
|
210
210
|
event.preventDownshiftDefault = true;
|
|
211
|
-
event
|
|
211
|
+
event?.persist?.();
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
const showWarning = !invalid && warn;
|
|
@@ -289,8 +289,6 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
291
|
const inputProps = getInputProps({
|
|
292
|
-
// Remove excess aria `aria-labelledby`. HTML <label for> provides this aria information.
|
|
293
|
-
'aria-labelledby': null,
|
|
294
292
|
disabled,
|
|
295
293
|
placeholder,
|
|
296
294
|
onClick() {
|
|
@@ -307,7 +305,7 @@ const ComboBox = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
|
307
305
|
if (event.target === textInput.current && isOpen) {
|
|
308
306
|
toggleMenu();
|
|
309
307
|
event.preventDownshiftDefault = true;
|
|
310
|
-
event
|
|
308
|
+
event?.persist?.();
|
|
311
309
|
}
|
|
312
310
|
}
|
|
313
311
|
if (match(event, Home)) {
|
|
@@ -99,6 +99,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
99
99
|
[key: string]: unknown;
|
|
100
100
|
}) => {
|
|
101
101
|
ariaLabel: string;
|
|
102
|
+
['aria-label']: string;
|
|
102
103
|
isExpanded: boolean;
|
|
103
104
|
onExpand: (e: MouseEvent) => void;
|
|
104
105
|
[key: string]: unknown;
|
|
@@ -109,6 +110,7 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
109
110
|
[key: string]: unknown;
|
|
110
111
|
}) => {
|
|
111
112
|
ariaLabel: string;
|
|
113
|
+
['aria-label']: string;
|
|
112
114
|
disabled: boolean | undefined;
|
|
113
115
|
isExpanded?: boolean;
|
|
114
116
|
isSelected?: boolean;
|
|
@@ -116,6 +118,13 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
116
118
|
onExpand: (e: MouseEvent) => void;
|
|
117
119
|
[key: string]: unknown;
|
|
118
120
|
};
|
|
121
|
+
getExpandedRowProps: (getExpandedRowPropsArgs: {
|
|
122
|
+
row: DataTableRow<ColTypes>;
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}) => {
|
|
125
|
+
['id']: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
};
|
|
119
128
|
getSelectionProps: (getSelectionPropsArgs: {
|
|
120
129
|
onClick?: (e: MouseEvent) => void;
|
|
121
130
|
row: DataTableRow<ColTypes>;
|
|
@@ -141,7 +150,9 @@ export interface DataTableRenderProps<RowType, ColTypes extends any[]> {
|
|
|
141
150
|
[key: string]: unknown;
|
|
142
151
|
}) => {
|
|
143
152
|
onCancel: () => void;
|
|
153
|
+
onSelectAll?: () => void | undefined;
|
|
144
154
|
shouldShowBatchActions: boolean;
|
|
155
|
+
totalCount: number;
|
|
145
156
|
totalSelected: number;
|
|
146
157
|
[key: string]: unknown;
|
|
147
158
|
};
|
|
@@ -375,6 +386,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
375
386
|
onExpand?: ((e: MouseEvent) => void) | undefined;
|
|
376
387
|
}) => {
|
|
377
388
|
ariaLabel: string;
|
|
389
|
+
'aria-label': string;
|
|
390
|
+
'aria-controls': string;
|
|
378
391
|
isExpanded: boolean;
|
|
379
392
|
onExpand: any;
|
|
380
393
|
};
|
|
@@ -411,9 +424,24 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
411
424
|
onExpand: any;
|
|
412
425
|
isExpanded: boolean | undefined;
|
|
413
426
|
ariaLabel: string;
|
|
427
|
+
'aria-label': string;
|
|
428
|
+
'aria-controls': string;
|
|
414
429
|
isSelected: boolean | undefined;
|
|
415
430
|
disabled: boolean | undefined;
|
|
416
431
|
};
|
|
432
|
+
/**
|
|
433
|
+
* Get the props associated with an expanded row
|
|
434
|
+
*
|
|
435
|
+
* @param {object} config
|
|
436
|
+
* @param {object} config.row the parent row we want the props for
|
|
437
|
+
* @returns {object}
|
|
438
|
+
*/
|
|
439
|
+
getExpandedRowProps: ({ row, ...rest }: {
|
|
440
|
+
[key: string]: unknown;
|
|
441
|
+
row: DataTableRow<ColTypes>;
|
|
442
|
+
}) => {
|
|
443
|
+
id: string;
|
|
444
|
+
};
|
|
417
445
|
/**
|
|
418
446
|
* Gets the props associated with selection for a header or a row, where
|
|
419
447
|
* applicable. Most often used to indicate selection status of the table or
|
|
@@ -452,6 +480,8 @@ declare class DataTable<RowType, ColTypes extends any[]> extends React.Component
|
|
|
452
480
|
shouldShowBatchActions: boolean;
|
|
453
481
|
totalSelected: number;
|
|
454
482
|
onCancel: () => void;
|
|
483
|
+
onSelectAll: undefined;
|
|
484
|
+
totalCount: number;
|
|
455
485
|
};
|
|
456
486
|
/**
|
|
457
487
|
* Helper utility to get the Table Props.
|
|
@@ -151,6 +151,10 @@ class DataTable extends React__default.Component {
|
|
|
151
151
|
return {
|
|
152
152
|
...rest,
|
|
153
153
|
ariaLabel: t(translationKey),
|
|
154
|
+
// TODO: remove in v12
|
|
155
|
+
'aria-label': t(translationKey),
|
|
156
|
+
// Provide a string of all the expanded row id's, separated by a space.
|
|
157
|
+
'aria-controls': rowIds.map(id => `expanded-row-${id}`).join(' '),
|
|
154
158
|
isExpanded,
|
|
155
159
|
// Compose the event handlers so we don't overwrite a consumer's `onClick`
|
|
156
160
|
// handler
|
|
@@ -205,10 +209,30 @@ class DataTable extends React__default.Component {
|
|
|
205
209
|
onExpand: composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
|
|
206
210
|
isExpanded: row.isExpanded,
|
|
207
211
|
ariaLabel: t(translationKey),
|
|
212
|
+
// TODO remove in v12
|
|
213
|
+
'aria-label': t(translationKey),
|
|
214
|
+
'aria-controls': `expanded-row-${row.id}`,
|
|
208
215
|
isSelected: row.isSelected,
|
|
209
216
|
disabled: row.disabled
|
|
210
217
|
};
|
|
211
218
|
});
|
|
219
|
+
/**
|
|
220
|
+
* Get the props associated with an expanded row
|
|
221
|
+
*
|
|
222
|
+
* @param {object} config
|
|
223
|
+
* @param {object} config.row the parent row we want the props for
|
|
224
|
+
* @returns {object}
|
|
225
|
+
*/
|
|
226
|
+
_defineProperty(this, "getExpandedRowProps", _ref3 => {
|
|
227
|
+
let {
|
|
228
|
+
row,
|
|
229
|
+
...rest
|
|
230
|
+
} = _ref3;
|
|
231
|
+
return {
|
|
232
|
+
...rest,
|
|
233
|
+
id: `expanded-row-${row.id}`
|
|
234
|
+
};
|
|
235
|
+
});
|
|
212
236
|
/**
|
|
213
237
|
* Gets the props associated with selection for a header or a row, where
|
|
214
238
|
* applicable. Most often used to indicate selection status of the table or
|
|
@@ -279,6 +303,8 @@ class DataTable extends React__default.Component {
|
|
|
279
303
|
} = _this.state;
|
|
280
304
|
const totalSelected = _this.getSelectedRows().length;
|
|
281
305
|
return {
|
|
306
|
+
onSelectAll: undefined,
|
|
307
|
+
totalCount: _this.state.rowIds.length || 0,
|
|
282
308
|
...props,
|
|
283
309
|
shouldShowBatchActions: shouldShowBatchActions && totalSelected > 0,
|
|
284
310
|
totalSelected,
|
|
@@ -586,6 +612,7 @@ class DataTable extends React__default.Component {
|
|
|
586
612
|
getHeaderProps: this.getHeaderProps,
|
|
587
613
|
getExpandHeaderProps: this.getExpandHeaderProps,
|
|
588
614
|
getRowProps: this.getRowProps,
|
|
615
|
+
getExpandedRowProps: this.getExpandedRowProps,
|
|
589
616
|
getSelectionProps: this.getSelectionProps,
|
|
590
617
|
getToolbarProps: this.getToolbarProps,
|
|
591
618
|
getBatchActionProps: this.getBatchActionProps,
|
|
@@ -0,0 +1,51 @@
|
|
|
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, { type MouseEventHandler } from 'react';
|
|
8
|
+
import type { InternationalProps } from '../../types/common';
|
|
9
|
+
declare const TableBatchActionsTranslationKeys: readonly ["carbon.table.batch.cancel", "carbon.table.batch.items.selected", "carbon.table.batch.item.selected", "carbon.table.batch.selectAll"];
|
|
10
|
+
export type TableBatchActionsTranslationKey = (typeof TableBatchActionsTranslationKeys)[number];
|
|
11
|
+
export interface TableBatchActionsTranslationArgs {
|
|
12
|
+
totalSelected?: number;
|
|
13
|
+
totalCount?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TableBatchActionsProps extends React.HTMLAttributes<HTMLDivElement>, InternationalProps<TableBatchActionsTranslationKey, TableBatchActionsTranslationArgs> {
|
|
16
|
+
/**
|
|
17
|
+
* Provide elements to be rendered inside of the component.
|
|
18
|
+
*/
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Hook required to listen for when the user initiates a cancel request
|
|
22
|
+
* through this component.
|
|
23
|
+
*/
|
|
24
|
+
onCancel: MouseEventHandler<HTMLButtonElement>;
|
|
25
|
+
/**
|
|
26
|
+
* Hook to listen for when the user initiates a select all
|
|
27
|
+
* request through this component. This _only_ controls the rendering
|
|
28
|
+
* of the `Select All` button and does not include built in functionality
|
|
29
|
+
*/
|
|
30
|
+
onSelectAll?: MouseEventHandler<HTMLButtonElement>;
|
|
31
|
+
/**
|
|
32
|
+
* Boolean specifier for whether or not the batch action bar should be
|
|
33
|
+
* displayed.
|
|
34
|
+
*/
|
|
35
|
+
shouldShowBatchActions?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Numeric representation of the total number of items selected in a table.
|
|
38
|
+
* This number is used to derive the selection message.
|
|
39
|
+
*/
|
|
40
|
+
totalSelected: number;
|
|
41
|
+
/**
|
|
42
|
+
* Numeric representation of the total number of items in a table.
|
|
43
|
+
* This number is used in the select all button text
|
|
44
|
+
*/
|
|
45
|
+
totalCount?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface TableBatchActionsComponent extends React.FC<TableBatchActionsProps> {
|
|
48
|
+
translationKeys: ReadonlyArray<TableBatchActionsTranslationKey>;
|
|
49
|
+
}
|
|
50
|
+
declare const TableBatchActions: TableBatchActionsComponent;
|
|
51
|
+
export default TableBatchActions;
|
|
@@ -16,16 +16,28 @@ import '../Text/index.js';
|
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { Text } from '../Text/Text.js';
|
|
18
18
|
|
|
19
|
+
const TableBatchActionsTranslationKeys = ['carbon.table.batch.cancel', 'carbon.table.batch.items.selected', 'carbon.table.batch.item.selected', 'carbon.table.batch.selectAll'];
|
|
19
20
|
const translationKeys = {
|
|
20
21
|
'carbon.table.batch.cancel': 'Cancel',
|
|
21
22
|
'carbon.table.batch.items.selected': 'items selected',
|
|
22
|
-
'carbon.table.batch.item.selected': 'item selected'
|
|
23
|
+
'carbon.table.batch.item.selected': 'item selected',
|
|
24
|
+
'carbon.table.batch.selectAll': 'Select all'
|
|
23
25
|
};
|
|
24
|
-
const translateWithId = (id
|
|
26
|
+
const translateWithId = function (id) {
|
|
27
|
+
let {
|
|
28
|
+
totalSelected,
|
|
29
|
+
totalCount
|
|
30
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
31
|
+
totalSelected: 0,
|
|
32
|
+
totalCount: 0
|
|
33
|
+
};
|
|
25
34
|
if (id === 'carbon.table.batch.cancel') {
|
|
26
35
|
return translationKeys[id];
|
|
27
36
|
}
|
|
28
|
-
|
|
37
|
+
if (id === 'carbon.table.batch.selectAll') {
|
|
38
|
+
return `${translationKeys[id]} (${totalCount})`;
|
|
39
|
+
}
|
|
40
|
+
return `${totalSelected} ${translationKeys[id]}`;
|
|
29
41
|
};
|
|
30
42
|
const TableBatchActions = _ref => {
|
|
31
43
|
let {
|
|
@@ -33,11 +45,13 @@ const TableBatchActions = _ref => {
|
|
|
33
45
|
children,
|
|
34
46
|
shouldShowBatchActions,
|
|
35
47
|
totalSelected,
|
|
48
|
+
totalCount,
|
|
36
49
|
onCancel,
|
|
37
|
-
|
|
50
|
+
onSelectAll,
|
|
51
|
+
translateWithId: t = translateWithId,
|
|
38
52
|
...rest
|
|
39
53
|
} = _ref;
|
|
40
|
-
const [isScrolling, setIsScrolling] = React__default.useState();
|
|
54
|
+
const [isScrolling, setIsScrolling] = React__default.useState(false);
|
|
41
55
|
const prefix = usePrefix();
|
|
42
56
|
const batchActionsClasses = cx({
|
|
43
57
|
[`${prefix}--batch-actions`]: true,
|
|
@@ -62,13 +76,20 @@ const TableBatchActions = _ref => {
|
|
|
62
76
|
totalSelected
|
|
63
77
|
}) : t('carbon.table.batch.item.selected', {
|
|
64
78
|
totalSelected
|
|
79
|
+
}))), onSelectAll && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
|
80
|
+
className: `${prefix}--batch-summary__divider`
|
|
81
|
+
}, "|"), /*#__PURE__*/React__default.createElement(Button, {
|
|
82
|
+
onClick: onSelectAll,
|
|
83
|
+
tabIndex: shouldShowBatchActions ? 0 : -1
|
|
84
|
+
}, t('carbon.table.batch.selectAll', {
|
|
85
|
+
totalCount
|
|
65
86
|
})))), /*#__PURE__*/React__default.createElement(TableActionList, null, children, /*#__PURE__*/React__default.createElement(Button, {
|
|
66
87
|
className: `${prefix}--batch-summary__cancel`,
|
|
67
88
|
tabIndex: shouldShowBatchActions ? 0 : -1,
|
|
68
89
|
onClick: onCancel
|
|
69
90
|
}, t('carbon.table.batch.cancel'))));
|
|
70
91
|
};
|
|
71
|
-
TableBatchActions.translationKeys =
|
|
92
|
+
TableBatchActions.translationKeys = TableBatchActionsTranslationKeys;
|
|
72
93
|
TableBatchActions.propTypes = {
|
|
73
94
|
children: PropTypes.node,
|
|
74
95
|
className: PropTypes.string,
|
|
@@ -77,11 +98,22 @@ TableBatchActions.propTypes = {
|
|
|
77
98
|
* through this component
|
|
78
99
|
*/
|
|
79
100
|
onCancel: PropTypes.func.isRequired,
|
|
101
|
+
/**
|
|
102
|
+
* Hook to listen for when the user initiates a select all
|
|
103
|
+
* request through this component. This _only_ controls the rendering
|
|
104
|
+
* of the `Select All` button and does not include built in functionality
|
|
105
|
+
*/
|
|
106
|
+
onSelectAll: PropTypes.func,
|
|
80
107
|
/**
|
|
81
108
|
* Boolean specifier for whether or not the batch action bar should be
|
|
82
109
|
* displayed
|
|
83
110
|
*/
|
|
84
111
|
shouldShowBatchActions: PropTypes.bool,
|
|
112
|
+
/**
|
|
113
|
+
* Numeric representation of the total number of items in a table.
|
|
114
|
+
* This number is used in the select all button text
|
|
115
|
+
*/
|
|
116
|
+
totalCount: PropTypes.number,
|
|
85
117
|
/**
|
|
86
118
|
* Numeric representation of the total number of items selected in a table.
|
|
87
119
|
* This number is used to derive the selection message
|
|
@@ -97,6 +129,5 @@ TableBatchActions.propTypes = {
|
|
|
97
129
|
TableBatchActions.defaultProps = {
|
|
98
130
|
translateWithId
|
|
99
131
|
};
|
|
100
|
-
var TableBatchActions$1 = TableBatchActions;
|
|
101
132
|
|
|
102
|
-
export { TableBatchActions
|
|
133
|
+
export { TableBatchActions as default };
|
|
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ReactAttr } from '../../types/common';
|
|
10
10
|
type TableExpandHeaderPropsBase = {
|
|
11
|
+
/**
|
|
12
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
13
|
+
*/
|
|
14
|
+
['aria-controls']: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This prop has been deprecated and will be
|
|
17
|
+
* removed in the next major release of Carbon. Use the
|
|
18
|
+
* `aria-label` prop instead.
|
|
19
|
+
*/
|
|
20
|
+
ariaLabel?: string;
|
|
11
21
|
/**
|
|
12
22
|
* Specify the string read by a voice reader when the expand trigger is
|
|
13
23
|
* focused
|
|
14
24
|
*/
|
|
15
|
-
|
|
25
|
+
['aria-label']: string;
|
|
16
26
|
/**
|
|
17
27
|
* @deprecated The enableExpando prop is being replaced by `enableToggle`
|
|
18
28
|
*/
|
|
@@ -35,25 +45,37 @@ type TableExpandHeaderPropsBase = {
|
|
|
35
45
|
*/
|
|
36
46
|
onExpand?(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
37
47
|
} & ReactAttr<HTMLTableCellElement>;
|
|
38
|
-
type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableToggle' | 'onExpand'> & {
|
|
48
|
+
type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableToggle' | 'onExpand'> & {
|
|
39
49
|
enableToggle: true;
|
|
40
50
|
ariaLabel: string;
|
|
51
|
+
['aria-label']: string;
|
|
41
52
|
onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
42
53
|
};
|
|
43
|
-
type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableExpando' | 'onExpand'> & {
|
|
54
|
+
type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableExpando' | 'onExpand'> & {
|
|
44
55
|
enableExpando: true;
|
|
45
56
|
ariaLabel: string;
|
|
57
|
+
['aria-label']: string;
|
|
46
58
|
onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
47
59
|
};
|
|
48
60
|
export type TableExpandHeaderProps = TableExpandHeaderPropsWithToggle | TableExpandHeaderPropsWithExpando | TableExpandHeaderPropsBase;
|
|
49
61
|
declare const TableExpandHeader: {
|
|
50
|
-
({ ariaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
|
|
62
|
+
({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
|
|
51
63
|
propTypes: {
|
|
52
64
|
/**
|
|
65
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
66
|
+
*/
|
|
67
|
+
"aria-controls": PropTypes.Requireable<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
70
|
+
* focused
|
|
71
|
+
*/
|
|
72
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Deprecated, please use `aria-label` instead.
|
|
53
75
|
* Specify the string read by a voice reader when the expand trigger is
|
|
54
76
|
* focused
|
|
55
77
|
*/
|
|
56
|
-
ariaLabel: PropTypes.Requireable<
|
|
78
|
+
ariaLabel: PropTypes.Requireable<string>;
|
|
57
79
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
58
80
|
className: PropTypes.Requireable<string>;
|
|
59
81
|
/**
|
|
@@ -16,7 +16,9 @@ import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsT
|
|
|
16
16
|
|
|
17
17
|
const TableExpandHeader = _ref => {
|
|
18
18
|
let {
|
|
19
|
-
|
|
19
|
+
['aria-controls']: ariaControls,
|
|
20
|
+
['aria-label']: ariaLabel,
|
|
21
|
+
ariaLabel: deprecatedAriaLabel,
|
|
20
22
|
className: headerClassName,
|
|
21
23
|
enableExpando,
|
|
22
24
|
enableToggle,
|
|
@@ -40,7 +42,9 @@ const TableExpandHeader = _ref => {
|
|
|
40
42
|
className: `${prefix}--table-expand__button`,
|
|
41
43
|
onClick: onExpand,
|
|
42
44
|
title: expandIconDescription,
|
|
43
|
-
"aria-label": ariaLabel
|
|
45
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
46
|
+
"aria-expanded": isExpanded,
|
|
47
|
+
"aria-controls": ariaControls
|
|
44
48
|
}, /*#__PURE__*/React__default.createElement(ChevronRight, {
|
|
45
49
|
className: `${prefix}--table-expand__svg`,
|
|
46
50
|
"aria-label": expandIconDescription
|
|
@@ -48,10 +52,20 @@ const TableExpandHeader = _ref => {
|
|
|
48
52
|
};
|
|
49
53
|
TableExpandHeader.propTypes = {
|
|
50
54
|
/**
|
|
55
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
56
|
+
*/
|
|
57
|
+
['aria-controls']: PropTypes.string,
|
|
58
|
+
/**
|
|
59
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
60
|
+
* focused
|
|
61
|
+
*/
|
|
62
|
+
['aria-label']: PropTypes.string,
|
|
63
|
+
/**
|
|
64
|
+
* Deprecated, please use `aria-label` instead.
|
|
51
65
|
* Specify the string read by a voice reader when the expand trigger is
|
|
52
66
|
* focused
|
|
53
67
|
*/
|
|
54
|
-
ariaLabel: PropTypes.
|
|
68
|
+
ariaLabel: PropTypes.string,
|
|
55
69
|
children: PropTypes.node,
|
|
56
70
|
className: PropTypes.string,
|
|
57
71
|
/**
|
|
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { MouseEventHandler, PropsWithChildren } from 'react';
|
|
9
9
|
import { TableRowProps } from './TableRow';
|
|
10
10
|
interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
11
|
+
/**
|
|
12
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
13
|
+
*/
|
|
14
|
+
['aria-controls']: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This prop has been deprecated and will be
|
|
17
|
+
* removed in the next major release of Carbon. Use the
|
|
18
|
+
* `aria-label` prop instead.
|
|
19
|
+
*/
|
|
20
|
+
ariaLabel?: string;
|
|
11
21
|
/**
|
|
12
22
|
* Specify the string read by a voice reader when the expand trigger is
|
|
13
23
|
* focused
|
|
14
24
|
*/
|
|
15
|
-
|
|
25
|
+
['aria-label']: string;
|
|
16
26
|
/**
|
|
17
27
|
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
18
28
|
*/
|
|
@@ -32,13 +42,24 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
|
32
42
|
onExpand: MouseEventHandler<HTMLButtonElement>;
|
|
33
43
|
}
|
|
34
44
|
declare const TableExpandRow: {
|
|
35
|
-
({ ariaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
|
|
45
|
+
({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
|
|
36
46
|
propTypes: {
|
|
37
47
|
/**
|
|
48
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
49
|
+
* TODO: make this required in v12
|
|
50
|
+
*/
|
|
51
|
+
"aria-controls": PropTypes.Requireable<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
54
|
+
* focused
|
|
55
|
+
*/
|
|
56
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Deprecated, please use `aria-label` instead.
|
|
38
59
|
* Specify the string read by a voice reader when the expand trigger is
|
|
39
60
|
* focused
|
|
40
61
|
*/
|
|
41
|
-
ariaLabel: PropTypes.
|
|
62
|
+
ariaLabel: PropTypes.Requireable<string>;
|
|
42
63
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
43
64
|
className: PropTypes.Requireable<string>;
|
|
44
65
|
/**
|
|
@@ -15,7 +15,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
15
15
|
|
|
16
16
|
const TableExpandRow = _ref => {
|
|
17
17
|
let {
|
|
18
|
-
|
|
18
|
+
['aria-controls']: ariaControls,
|
|
19
|
+
['aria-label']: ariaLabel,
|
|
20
|
+
ariaLabel: deprecatedAriaLabel,
|
|
19
21
|
className: rowClassName,
|
|
20
22
|
children,
|
|
21
23
|
isExpanded,
|
|
@@ -44,7 +46,9 @@ const TableExpandRow = _ref => {
|
|
|
44
46
|
className: `${prefix}--table-expand__button`,
|
|
45
47
|
onClick: onExpand,
|
|
46
48
|
title: expandIconDescription,
|
|
47
|
-
"aria-label": ariaLabel
|
|
49
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
50
|
+
"aria-expanded": isExpanded,
|
|
51
|
+
"aria-controls": ariaControls
|
|
48
52
|
}, /*#__PURE__*/React__default.createElement(ChevronRight, {
|
|
49
53
|
className: `${prefix}--table-expand__svg`,
|
|
50
54
|
"aria-label": expandIconDescription
|
|
@@ -52,10 +56,21 @@ const TableExpandRow = _ref => {
|
|
|
52
56
|
};
|
|
53
57
|
TableExpandRow.propTypes = {
|
|
54
58
|
/**
|
|
59
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
60
|
+
* TODO: make this required in v12
|
|
61
|
+
*/
|
|
62
|
+
['aria-controls']: PropTypes.string,
|
|
63
|
+
/**
|
|
64
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
65
|
+
* focused
|
|
66
|
+
*/
|
|
67
|
+
['aria-label']: PropTypes.string,
|
|
68
|
+
/**
|
|
69
|
+
* Deprecated, please use `aria-label` instead.
|
|
55
70
|
* Specify the string read by a voice reader when the expand trigger is
|
|
56
71
|
* focused
|
|
57
72
|
*/
|
|
58
|
-
ariaLabel: PropTypes.string
|
|
73
|
+
ariaLabel: PropTypes.string,
|
|
59
74
|
children: PropTypes.node,
|
|
60
75
|
className: PropTypes.string,
|
|
61
76
|
/**
|
|
@@ -19,7 +19,7 @@ const TableRow = props => {
|
|
|
19
19
|
[`${prefix}--data-table--selected`]: props.isSelected
|
|
20
20
|
});
|
|
21
21
|
const cleanProps = {
|
|
22
|
-
...omit(props, ['ariaLabel', 'onExpand', 'isExpanded', 'isSelected']),
|
|
22
|
+
...omit(props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
|
|
23
23
|
className: className || undefined
|
|
24
24
|
};
|
|
25
25
|
return /*#__PURE__*/React__default.createElement("tr", cleanProps);
|