@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
|
@@ -161,6 +161,10 @@ class DataTable extends React__default["default"].Component {
|
|
|
161
161
|
return {
|
|
162
162
|
...rest,
|
|
163
163
|
ariaLabel: t(translationKey),
|
|
164
|
+
// TODO: remove in v12
|
|
165
|
+
'aria-label': t(translationKey),
|
|
166
|
+
// Provide a string of all the expanded row id's, separated by a space.
|
|
167
|
+
'aria-controls': rowIds.map(id => `expanded-row-${id}`).join(' '),
|
|
164
168
|
isExpanded,
|
|
165
169
|
// Compose the event handlers so we don't overwrite a consumer's `onClick`
|
|
166
170
|
// handler
|
|
@@ -215,10 +219,30 @@ class DataTable extends React__default["default"].Component {
|
|
|
215
219
|
onExpand: events.composeEventHandlers([this.handleOnExpandRow(row.id), onClick]),
|
|
216
220
|
isExpanded: row.isExpanded,
|
|
217
221
|
ariaLabel: t(translationKey),
|
|
222
|
+
// TODO remove in v12
|
|
223
|
+
'aria-label': t(translationKey),
|
|
224
|
+
'aria-controls': `expanded-row-${row.id}`,
|
|
218
225
|
isSelected: row.isSelected,
|
|
219
226
|
disabled: row.disabled
|
|
220
227
|
};
|
|
221
228
|
});
|
|
229
|
+
/**
|
|
230
|
+
* Get the props associated with an expanded row
|
|
231
|
+
*
|
|
232
|
+
* @param {object} config
|
|
233
|
+
* @param {object} config.row the parent row we want the props for
|
|
234
|
+
* @returns {object}
|
|
235
|
+
*/
|
|
236
|
+
_rollupPluginBabelHelpers.defineProperty(this, "getExpandedRowProps", _ref3 => {
|
|
237
|
+
let {
|
|
238
|
+
row,
|
|
239
|
+
...rest
|
|
240
|
+
} = _ref3;
|
|
241
|
+
return {
|
|
242
|
+
...rest,
|
|
243
|
+
id: `expanded-row-${row.id}`
|
|
244
|
+
};
|
|
245
|
+
});
|
|
222
246
|
/**
|
|
223
247
|
* Gets the props associated with selection for a header or a row, where
|
|
224
248
|
* applicable. Most often used to indicate selection status of the table or
|
|
@@ -289,6 +313,8 @@ class DataTable extends React__default["default"].Component {
|
|
|
289
313
|
} = _this.state;
|
|
290
314
|
const totalSelected = _this.getSelectedRows().length;
|
|
291
315
|
return {
|
|
316
|
+
onSelectAll: undefined,
|
|
317
|
+
totalCount: _this.state.rowIds.length || 0,
|
|
292
318
|
...props,
|
|
293
319
|
shouldShowBatchActions: shouldShowBatchActions && totalSelected > 0,
|
|
294
320
|
totalSelected,
|
|
@@ -596,6 +622,7 @@ class DataTable extends React__default["default"].Component {
|
|
|
596
622
|
getHeaderProps: this.getHeaderProps,
|
|
597
623
|
getExpandHeaderProps: this.getExpandHeaderProps,
|
|
598
624
|
getRowProps: this.getRowProps,
|
|
625
|
+
getExpandedRowProps: this.getExpandedRowProps,
|
|
599
626
|
getSelectionProps: this.getSelectionProps,
|
|
600
627
|
getToolbarProps: this.getToolbarProps,
|
|
601
628
|
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;
|
|
@@ -26,16 +26,28 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
26
26
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
27
27
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
28
|
|
|
29
|
+
const TableBatchActionsTranslationKeys = ['carbon.table.batch.cancel', 'carbon.table.batch.items.selected', 'carbon.table.batch.item.selected', 'carbon.table.batch.selectAll'];
|
|
29
30
|
const translationKeys = {
|
|
30
31
|
'carbon.table.batch.cancel': 'Cancel',
|
|
31
32
|
'carbon.table.batch.items.selected': 'items selected',
|
|
32
|
-
'carbon.table.batch.item.selected': 'item selected'
|
|
33
|
+
'carbon.table.batch.item.selected': 'item selected',
|
|
34
|
+
'carbon.table.batch.selectAll': 'Select all'
|
|
33
35
|
};
|
|
34
|
-
const translateWithId = (id
|
|
36
|
+
const translateWithId = function (id) {
|
|
37
|
+
let {
|
|
38
|
+
totalSelected,
|
|
39
|
+
totalCount
|
|
40
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
41
|
+
totalSelected: 0,
|
|
42
|
+
totalCount: 0
|
|
43
|
+
};
|
|
35
44
|
if (id === 'carbon.table.batch.cancel') {
|
|
36
45
|
return translationKeys[id];
|
|
37
46
|
}
|
|
38
|
-
|
|
47
|
+
if (id === 'carbon.table.batch.selectAll') {
|
|
48
|
+
return `${translationKeys[id]} (${totalCount})`;
|
|
49
|
+
}
|
|
50
|
+
return `${totalSelected} ${translationKeys[id]}`;
|
|
39
51
|
};
|
|
40
52
|
const TableBatchActions = _ref => {
|
|
41
53
|
let {
|
|
@@ -43,11 +55,13 @@ const TableBatchActions = _ref => {
|
|
|
43
55
|
children,
|
|
44
56
|
shouldShowBatchActions,
|
|
45
57
|
totalSelected,
|
|
58
|
+
totalCount,
|
|
46
59
|
onCancel,
|
|
47
|
-
|
|
60
|
+
onSelectAll,
|
|
61
|
+
translateWithId: t = translateWithId,
|
|
48
62
|
...rest
|
|
49
63
|
} = _ref;
|
|
50
|
-
const [isScrolling, setIsScrolling] = React__default["default"].useState();
|
|
64
|
+
const [isScrolling, setIsScrolling] = React__default["default"].useState(false);
|
|
51
65
|
const prefix = usePrefix.usePrefix();
|
|
52
66
|
const batchActionsClasses = cx__default["default"]({
|
|
53
67
|
[`${prefix}--batch-actions`]: true,
|
|
@@ -72,13 +86,20 @@ const TableBatchActions = _ref => {
|
|
|
72
86
|
totalSelected
|
|
73
87
|
}) : t('carbon.table.batch.item.selected', {
|
|
74
88
|
totalSelected
|
|
89
|
+
}))), onSelectAll && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
90
|
+
className: `${prefix}--batch-summary__divider`
|
|
91
|
+
}, "|"), /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
92
|
+
onClick: onSelectAll,
|
|
93
|
+
tabIndex: shouldShowBatchActions ? 0 : -1
|
|
94
|
+
}, t('carbon.table.batch.selectAll', {
|
|
95
|
+
totalCount
|
|
75
96
|
})))), /*#__PURE__*/React__default["default"].createElement(TableActionList["default"], null, children, /*#__PURE__*/React__default["default"].createElement(Button["default"], {
|
|
76
97
|
className: `${prefix}--batch-summary__cancel`,
|
|
77
98
|
tabIndex: shouldShowBatchActions ? 0 : -1,
|
|
78
99
|
onClick: onCancel
|
|
79
100
|
}, t('carbon.table.batch.cancel'))));
|
|
80
101
|
};
|
|
81
|
-
TableBatchActions.translationKeys =
|
|
102
|
+
TableBatchActions.translationKeys = TableBatchActionsTranslationKeys;
|
|
82
103
|
TableBatchActions.propTypes = {
|
|
83
104
|
children: PropTypes__default["default"].node,
|
|
84
105
|
className: PropTypes__default["default"].string,
|
|
@@ -87,11 +108,22 @@ TableBatchActions.propTypes = {
|
|
|
87
108
|
* through this component
|
|
88
109
|
*/
|
|
89
110
|
onCancel: PropTypes__default["default"].func.isRequired,
|
|
111
|
+
/**
|
|
112
|
+
* Hook to listen for when the user initiates a select all
|
|
113
|
+
* request through this component. This _only_ controls the rendering
|
|
114
|
+
* of the `Select All` button and does not include built in functionality
|
|
115
|
+
*/
|
|
116
|
+
onSelectAll: PropTypes__default["default"].func,
|
|
90
117
|
/**
|
|
91
118
|
* Boolean specifier for whether or not the batch action bar should be
|
|
92
119
|
* displayed
|
|
93
120
|
*/
|
|
94
121
|
shouldShowBatchActions: PropTypes__default["default"].bool,
|
|
122
|
+
/**
|
|
123
|
+
* Numeric representation of the total number of items in a table.
|
|
124
|
+
* This number is used in the select all button text
|
|
125
|
+
*/
|
|
126
|
+
totalCount: PropTypes__default["default"].number,
|
|
95
127
|
/**
|
|
96
128
|
* Numeric representation of the total number of items selected in a table.
|
|
97
129
|
* This number is used to derive the selection message
|
|
@@ -107,6 +139,5 @@ TableBatchActions.propTypes = {
|
|
|
107
139
|
TableBatchActions.defaultProps = {
|
|
108
140
|
translateWithId
|
|
109
141
|
};
|
|
110
|
-
var TableBatchActions$1 = TableBatchActions;
|
|
111
142
|
|
|
112
|
-
exports["default"] = TableBatchActions
|
|
143
|
+
exports["default"] = TableBatchActions;
|
|
@@ -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
|
/**
|
|
@@ -26,7 +26,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
26
26
|
|
|
27
27
|
const TableExpandHeader = _ref => {
|
|
28
28
|
let {
|
|
29
|
-
|
|
29
|
+
['aria-controls']: ariaControls,
|
|
30
|
+
['aria-label']: ariaLabel,
|
|
31
|
+
ariaLabel: deprecatedAriaLabel,
|
|
30
32
|
className: headerClassName,
|
|
31
33
|
enableExpando,
|
|
32
34
|
enableToggle,
|
|
@@ -50,7 +52,9 @@ const TableExpandHeader = _ref => {
|
|
|
50
52
|
className: `${prefix}--table-expand__button`,
|
|
51
53
|
onClick: onExpand,
|
|
52
54
|
title: expandIconDescription,
|
|
53
|
-
"aria-label": ariaLabel
|
|
55
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
56
|
+
"aria-expanded": isExpanded,
|
|
57
|
+
"aria-controls": ariaControls
|
|
54
58
|
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
|
|
55
59
|
className: `${prefix}--table-expand__svg`,
|
|
56
60
|
"aria-label": expandIconDescription
|
|
@@ -58,10 +62,20 @@ const TableExpandHeader = _ref => {
|
|
|
58
62
|
};
|
|
59
63
|
TableExpandHeader.propTypes = {
|
|
60
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__default["default"].string,
|
|
68
|
+
/**
|
|
69
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
70
|
+
* focused
|
|
71
|
+
*/
|
|
72
|
+
['aria-label']: PropTypes__default["default"].string,
|
|
73
|
+
/**
|
|
74
|
+
* Deprecated, please use `aria-label` instead.
|
|
61
75
|
* Specify the string read by a voice reader when the expand trigger is
|
|
62
76
|
* focused
|
|
63
77
|
*/
|
|
64
|
-
ariaLabel: PropTypes__default["default"].
|
|
78
|
+
ariaLabel: PropTypes__default["default"].string,
|
|
65
79
|
children: PropTypes__default["default"].node,
|
|
66
80
|
className: PropTypes__default["default"].string,
|
|
67
81
|
/**
|
|
@@ -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
|
/**
|
|
@@ -25,7 +25,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
25
25
|
|
|
26
26
|
const TableExpandRow = _ref => {
|
|
27
27
|
let {
|
|
28
|
-
|
|
28
|
+
['aria-controls']: ariaControls,
|
|
29
|
+
['aria-label']: ariaLabel,
|
|
30
|
+
ariaLabel: deprecatedAriaLabel,
|
|
29
31
|
className: rowClassName,
|
|
30
32
|
children,
|
|
31
33
|
isExpanded,
|
|
@@ -54,7 +56,9 @@ const TableExpandRow = _ref => {
|
|
|
54
56
|
className: `${prefix}--table-expand__button`,
|
|
55
57
|
onClick: onExpand,
|
|
56
58
|
title: expandIconDescription,
|
|
57
|
-
"aria-label": ariaLabel
|
|
59
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
60
|
+
"aria-expanded": isExpanded,
|
|
61
|
+
"aria-controls": ariaControls
|
|
58
62
|
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
|
|
59
63
|
className: `${prefix}--table-expand__svg`,
|
|
60
64
|
"aria-label": expandIconDescription
|
|
@@ -62,10 +66,21 @@ const TableExpandRow = _ref => {
|
|
|
62
66
|
};
|
|
63
67
|
TableExpandRow.propTypes = {
|
|
64
68
|
/**
|
|
69
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
70
|
+
* TODO: make this required in v12
|
|
71
|
+
*/
|
|
72
|
+
['aria-controls']: PropTypes__default["default"].string,
|
|
73
|
+
/**
|
|
74
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
75
|
+
* focused
|
|
76
|
+
*/
|
|
77
|
+
['aria-label']: PropTypes__default["default"].string,
|
|
78
|
+
/**
|
|
79
|
+
* Deprecated, please use `aria-label` instead.
|
|
65
80
|
* Specify the string read by a voice reader when the expand trigger is
|
|
66
81
|
* focused
|
|
67
82
|
*/
|
|
68
|
-
ariaLabel: PropTypes__default["default"].string
|
|
83
|
+
ariaLabel: PropTypes__default["default"].string,
|
|
69
84
|
children: PropTypes__default["default"].node,
|
|
70
85
|
className: PropTypes__default["default"].string,
|
|
71
86
|
/**
|
|
@@ -30,7 +30,7 @@ const TableRow = props => {
|
|
|
30
30
|
[`${prefix}--data-table--selected`]: props.isSelected
|
|
31
31
|
});
|
|
32
32
|
const cleanProps = {
|
|
33
|
-
...omit__default["default"](props, ['ariaLabel', 'onExpand', 'isExpanded', 'isSelected']),
|
|
33
|
+
...omit__default["default"](props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
|
|
34
34
|
className: className || undefined
|
|
35
35
|
};
|
|
36
36
|
return /*#__PURE__*/React__default["default"].createElement("tr", cleanProps);
|
|
@@ -0,0 +1,176 @@
|
|
|
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, { FocusEvent, ReactNode } from 'react';
|
|
9
|
+
export interface TableToolbarSearchProps {
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Provide an optional class name for the search container
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Specifies if the search should initially render in an expanded state
|
|
17
|
+
*/
|
|
18
|
+
defaultExpanded?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Provide an optional default value for the Search component
|
|
21
|
+
*/
|
|
22
|
+
defaultValue?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies if the search should be disabled
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Specifies if the search should expand
|
|
29
|
+
*/
|
|
30
|
+
expanded?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Provide an optional id for the search container
|
|
33
|
+
*/
|
|
34
|
+
id?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Provide an optional label text for the Search component icon
|
|
37
|
+
*/
|
|
38
|
+
labelText?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Provide an optional function to be called when the search input loses focus, this will be
|
|
41
|
+
* passed the event as the first parameter and a function to handle the expanding of the search
|
|
42
|
+
* input as the second
|
|
43
|
+
*/
|
|
44
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>, handleExpand: (event: FocusEvent<HTMLInputElement>, value: boolean) => void) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Provide an optional hook that is called each time the input is updated
|
|
47
|
+
*/
|
|
48
|
+
onChange?: (event: '' | Partial<React.ChangeEventHandler<HTMLInputElement>>, value?: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Optional callback called when the search value is cleared.
|
|
51
|
+
*/
|
|
52
|
+
onClear?: () => void;
|
|
53
|
+
/**
|
|
54
|
+
* Provide an optional hook that is called each time the input is expanded
|
|
55
|
+
*/
|
|
56
|
+
onExpand?: (event: FocusEvent<HTMLInputElement>, value: boolean) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Provide an optional function to be called when the search input gains focus, this will be
|
|
59
|
+
* passed the event as the first parameter and a function to handle the expanding of the search
|
|
60
|
+
* input as the second.
|
|
61
|
+
*/
|
|
62
|
+
onFocus?: (event: FocusEvent<HTMLInputElement>, handleExpand: (event: FocusEvent<HTMLInputElement>, value: boolean) => void) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the search should be allowed to expand
|
|
65
|
+
*/
|
|
66
|
+
persistent?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Provide an optional placeholder text for the Search component
|
|
69
|
+
*/
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Provide an optional className for the overall container of the Search
|
|
73
|
+
*/
|
|
74
|
+
searchContainerClass?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Specify the size of the Search
|
|
77
|
+
*/
|
|
78
|
+
size?: 'sm' | 'md' | 'lg';
|
|
79
|
+
/**
|
|
80
|
+
* Optional prop to specify the tabIndex of the <Search> (in expanded state) or the container (in collapsed state)
|
|
81
|
+
*/
|
|
82
|
+
tabIndex?: number | string;
|
|
83
|
+
/**
|
|
84
|
+
* Provide custom text for the component for each translation id
|
|
85
|
+
*/
|
|
86
|
+
translateWithId: (id: string) => string;
|
|
87
|
+
}
|
|
88
|
+
declare const TableToolbarSearch: {
|
|
89
|
+
({ className, searchContainerClass, onChange: onChangeProp, onClear, translateWithId: t, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent, id, onBlur, onFocus, size, tabIndex, ...rest }: TableToolbarSearchProps): JSX.Element;
|
|
90
|
+
propTypes: {
|
|
91
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
92
|
+
/**
|
|
93
|
+
* Provide an optional class name for the search container
|
|
94
|
+
*/
|
|
95
|
+
className: PropTypes.Requireable<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Specifies if the search should initially render in an expanded state
|
|
98
|
+
*/
|
|
99
|
+
defaultExpanded: PropTypes.Requireable<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* Provide an optional default value for the Search component
|
|
102
|
+
*/
|
|
103
|
+
defaultValue: PropTypes.Requireable<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Specifies if the search should be disabled
|
|
106
|
+
*/
|
|
107
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Specifies if the search should expand
|
|
110
|
+
*/
|
|
111
|
+
expanded: PropTypes.Requireable<boolean>;
|
|
112
|
+
/**
|
|
113
|
+
* Provide an optional id for the search container
|
|
114
|
+
*/
|
|
115
|
+
id: PropTypes.Requireable<string>;
|
|
116
|
+
/**
|
|
117
|
+
* Provide an optional label text for the Search component icon
|
|
118
|
+
*/
|
|
119
|
+
labelText: PropTypes.Requireable<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Provide an optional function to be called when the search input loses focus, this will be
|
|
122
|
+
* passed the event as the first parameter and a function to handle the expanding of the search
|
|
123
|
+
* input as the second
|
|
124
|
+
*/
|
|
125
|
+
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
126
|
+
/**
|
|
127
|
+
* Provide an optional hook that is called each time the input is updated
|
|
128
|
+
*/
|
|
129
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
130
|
+
/**
|
|
131
|
+
* Optional callback called when the search value is cleared.
|
|
132
|
+
*/
|
|
133
|
+
onClear: PropTypes.Requireable<(...args: any[]) => any>;
|
|
134
|
+
/**
|
|
135
|
+
* Provide an optional hook that is called each time the input is expanded
|
|
136
|
+
*/
|
|
137
|
+
onExpand: PropTypes.Requireable<(...args: any[]) => any>;
|
|
138
|
+
/**
|
|
139
|
+
* Provide an optional function to be called when the search input gains focus, this will be
|
|
140
|
+
* passed the event as the first parameter and a function to handle the expanding of the search
|
|
141
|
+
* input as the second.
|
|
142
|
+
*/
|
|
143
|
+
onFocus: PropTypes.Requireable<(...args: any[]) => any>;
|
|
144
|
+
/**
|
|
145
|
+
* Whether the search should be allowed to expand
|
|
146
|
+
*/
|
|
147
|
+
persistent: PropTypes.Requireable<boolean>;
|
|
148
|
+
/**
|
|
149
|
+
* Provide an optional placeholder text for the Search component
|
|
150
|
+
*/
|
|
151
|
+
placeholder: PropTypes.Requireable<string>;
|
|
152
|
+
/**
|
|
153
|
+
* Provide an optional className for the overall container of the Search
|
|
154
|
+
*/
|
|
155
|
+
searchContainerClass: PropTypes.Requireable<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Specify the size of the Search
|
|
158
|
+
*/
|
|
159
|
+
size: PropTypes.Requireable<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Optional prop to specify the tabIndex of the <Search> (in expanded state) or the container (in collapsed state)
|
|
162
|
+
*/
|
|
163
|
+
tabIndex: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
164
|
+
/**
|
|
165
|
+
* Provide custom text for the component for each translation id
|
|
166
|
+
*/
|
|
167
|
+
translateWithId: PropTypes.Validator<(...args: any[]) => any>;
|
|
168
|
+
};
|
|
169
|
+
defaultProps: {
|
|
170
|
+
tabIndex: string;
|
|
171
|
+
translateWithId: (id: string) => string;
|
|
172
|
+
persistent: boolean;
|
|
173
|
+
onClear: () => void;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
export default TableToolbarSearch;
|
|
@@ -51,6 +51,7 @@ const TableToolbarSearch = _ref => {
|
|
|
51
51
|
onBlur,
|
|
52
52
|
onFocus,
|
|
53
53
|
size = 'lg',
|
|
54
|
+
tabIndex,
|
|
54
55
|
...rest
|
|
55
56
|
} = _ref;
|
|
56
57
|
const {
|
|
@@ -64,18 +65,19 @@ const TableToolbarSearch = _ref => {
|
|
|
64
65
|
const prefix = usePrefix.usePrefix();
|
|
65
66
|
React.useEffect(() => {
|
|
66
67
|
if (focusTarget) {
|
|
67
|
-
focusTarget.current
|
|
68
|
+
focusTarget.current?.querySelector?.('input')?.focus();
|
|
68
69
|
setFocusTarget(null);
|
|
69
70
|
}
|
|
70
71
|
}, [focusTarget]);
|
|
71
72
|
React.useEffect(() => {
|
|
72
73
|
if (defaultValue) {
|
|
73
|
-
onChangeProp('', defaultValue);
|
|
74
|
+
onChangeProp?.('', defaultValue);
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
77
|
//eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
78
|
[]);
|
|
78
79
|
const searchClasses = cx__default["default"](className, {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
79
81
|
[searchContainerClass]: searchContainerClass,
|
|
80
82
|
[`${prefix}--toolbar-search-container-active`]: expanded,
|
|
81
83
|
[`${prefix}--toolbar-search-container-disabled`]: disabled,
|
|
@@ -113,6 +115,10 @@ const TableToolbarSearch = _ref => {
|
|
|
113
115
|
onFocus: onFocus ? event => onFocus(event, handleExpand) : handleOnFocus,
|
|
114
116
|
onBlur: onBlur ? event => onBlur(event, handleExpand) : handleOnBlur,
|
|
115
117
|
size: size
|
|
118
|
+
// HTMLAttributes defines tabIndex as number | undefined but in reality it
|
|
119
|
+
// also accepts a string, so we cast here to convince Typescript this is okay.
|
|
120
|
+
,
|
|
121
|
+
tabIndex: tabIndex
|
|
116
122
|
}, rest));
|
|
117
123
|
};
|
|
118
124
|
TableToolbarSearch.propTypes = {
|
|
@@ -200,6 +206,5 @@ TableToolbarSearch.defaultProps = {
|
|
|
200
206
|
persistent: false,
|
|
201
207
|
onClear: () => {}
|
|
202
208
|
};
|
|
203
|
-
var TableToolbarSearch$1 = TableToolbarSearch;
|
|
204
209
|
|
|
205
|
-
exports["default"] = TableToolbarSearch
|
|
210
|
+
exports["default"] = TableToolbarSearch;
|
|
@@ -71,7 +71,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
71
71
|
* given item to a string label. By default, it extracts the `label` field
|
|
72
72
|
* from a given item to serve as the item label in the list.
|
|
73
73
|
*/
|
|
74
|
-
itemToString?(item: ItemType): string;
|
|
74
|
+
itemToString?(item: ItemType | null): string;
|
|
75
75
|
/**
|
|
76
76
|
* We try to stay as generic as possible here to allow individuals to pass
|
|
77
77
|
* in a collection of whatever kind of data structure they prefer
|