Skip to content

Commit 75646c0

Browse files
Alessandra Davilakodiakhq[bot]
andauthored
feat(props): update table expand header props (#9659)
* feat(props): update accordion and table expand header props * chore(acordion-item): remove prop changes from accordion item * chore(data-table): remove changes * test(snapshot): update snapshots * chore(date-table): fix typo in table expand header Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 61b5aaa commit 75646c0

3 files changed

Lines changed: 85 additions & 15 deletions

File tree

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,21 +1212,46 @@ Map {
12121212
},
12131213
"TableExpandHeader": Object {
12141214
"propTypes": Object {
1215-
"ariaLabel": [Function],
1215+
"ariaLabel": Object {
1216+
"args": Array [
1217+
Array [
1218+
[Function],
1219+
[Function],
1220+
],
1221+
],
1222+
"type": "oneOfType",
1223+
},
12161224
"children": Object {
12171225
"type": "node",
12181226
},
12191227
"className": Object {
12201228
"type": "string",
12211229
},
1222-
"enableExpando": Object {
1230+
"enableExpando": [Function],
1231+
"enableToggle": Object {
12231232
"type": "bool",
12241233
},
12251234
"expandIconDescription": Object {
12261235
"type": "string",
12271236
},
1228-
"isExpanded": [Function],
1229-
"onExpand": [Function],
1237+
"isExpanded": Object {
1238+
"args": Array [
1239+
Array [
1240+
[Function],
1241+
[Function],
1242+
],
1243+
],
1244+
"type": "oneOfType",
1245+
},
1246+
"onExpand": Object {
1247+
"args": Array [
1248+
Array [
1249+
[Function],
1250+
[Function],
1251+
],
1252+
],
1253+
"type": "oneOfType",
1254+
},
12301255
},
12311256
},
12321257
"TableExpandRow": Object {
@@ -1852,21 +1877,46 @@ Map {
18521877
},
18531878
"TableExpandHeader" => Object {
18541879
"propTypes": Object {
1855-
"ariaLabel": [Function],
1880+
"ariaLabel": Object {
1881+
"args": Array [
1882+
Array [
1883+
[Function],
1884+
[Function],
1885+
],
1886+
],
1887+
"type": "oneOfType",
1888+
},
18561889
"children": Object {
18571890
"type": "node",
18581891
},
18591892
"className": Object {
18601893
"type": "string",
18611894
},
1862-
"enableExpando": Object {
1895+
"enableExpando": [Function],
1896+
"enableToggle": Object {
18631897
"type": "bool",
18641898
},
18651899
"expandIconDescription": Object {
18661900
"type": "string",
18671901
},
1868-
"isExpanded": [Function],
1869-
"onExpand": [Function],
1902+
"isExpanded": Object {
1903+
"args": Array [
1904+
Array [
1905+
[Function],
1906+
[Function],
1907+
],
1908+
],
1909+
"type": "oneOfType",
1910+
},
1911+
"onExpand": Object {
1912+
"args": Array [
1913+
Array [
1914+
[Function],
1915+
[Function],
1916+
],
1917+
],
1918+
"type": "oneOfType",
1919+
},
18701920
},
18711921
},
18721922
"TableExpandRow" => Object {

packages/react/src/components/Accordion/AccordionItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import React, { useState } from 'react';
1313
import { Text } from '../Text';
1414
import { match, keys } from '../../internal/keyboard';
1515
import { useId } from '../../internal/useId';
16-
import deprecate from '../../prop-types/deprecate.js';
16+
import deprecate from '../../prop-types/deprecate';
1717

1818
const { prefix } = settings;
1919
const defaultRenderExpando = (props) => <button type="button" {...props} />;

packages/react/src/components/DataTable/TableExpandHeader.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import cx from 'classnames';
99
import PropTypes from 'prop-types';
1010
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy';
11+
import deprecate from '../../prop-types/deprecate';
1112
import React from 'react';
1213
import { ChevronRight16 } from '@carbon/icons-react';
1314
import { settings } from 'carbon-components';
@@ -18,6 +19,7 @@ const TableExpandHeader = ({
1819
ariaLabel,
1920
className: headerClassName,
2021
enableExpando,
22+
enableToggle,
2123
isExpanded,
2224
onExpand,
2325
expandIconDescription,
@@ -33,7 +35,7 @@ const TableExpandHeader = ({
3335
className={className}
3436
data-previous-value={previousValue}
3537
{...rest}>
36-
{!enableExpando ? null : (
38+
{enableExpando || enableToggle ? (
3739
<button
3840
type="button"
3941
className={`${prefix}--table-expand__button`}
@@ -45,7 +47,7 @@ const TableExpandHeader = ({
4547
aria-label={expandIconDescription}
4648
/>
4749
</button>
48-
)}
50+
) : null}
4951
{children}
5052
</th>
5153
);
@@ -56,15 +58,27 @@ TableExpandHeader.propTypes = {
5658
* Specify the string read by a voice reader when the expand trigger is
5759
* focused
5860
*/
59-
ariaLabel: requiredIfGivenPropIsTruthy('enableExpando', PropTypes.string),
61+
ariaLabel: PropTypes.oneOfType([
62+
requiredIfGivenPropIsTruthy('enableExpando', PropTypes.string),
63+
requiredIfGivenPropIsTruthy('enableToggle', PropTypes.string),
64+
]),
65+
6066
children: PropTypes.node,
6167

6268
className: PropTypes.string,
6369

70+
/**
71+
* The enableExpando prop is being replaced by enableToggle
72+
*/
73+
enableExpando: deprecate(
74+
PropTypes.bool,
75+
'The `enableExpando` prop has been deprecated in favor of `enableToggle`. This prop will be removed in the next major release.'
76+
),
77+
6478
/**
6579
* Specify whether an expand all button should be displayed
6680
*/
67-
enableExpando: PropTypes.bool,
81+
enableToggle: PropTypes.bool,
6882

6983
/**
7084
* The description of the chevron right icon, to be put in its SVG `<title>` element.
@@ -75,12 +89,18 @@ TableExpandHeader.propTypes = {
7589
* Specify whether this row is expanded or not. This helps coordinate data
7690
* attributes so that `TableExpandRow` and `TableExpandedRow` work together
7791
*/
78-
isExpanded: requiredIfGivenPropIsTruthy('enableExpando', PropTypes.bool),
92+
isExpanded: PropTypes.oneOfType([
93+
requiredIfGivenPropIsTruthy('enableExpando', PropTypes.bool),
94+
requiredIfGivenPropIsTruthy('enableToggle', PropTypes.bool),
95+
]),
7996

8097
/**
8198
* Hook for when a listener initiates a request to expand the given row
8299
*/
83-
onExpand: requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func),
100+
onExpand: PropTypes.oneOfType([
101+
requiredIfGivenPropIsTruthy('enableExpando', PropTypes.func),
102+
requiredIfGivenPropIsTruthy('enableToggle', PropTypes.func),
103+
]),
84104
};
85105

86106
export default TableExpandHeader;

0 commit comments

Comments
 (0)