-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
TableToolbar.tsx
89 lines (78 loc) · 2.13 KB
/
TableToolbar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { usePrefix } from '../../internal/usePrefix';
import deprecate from '../../prop-types/deprecate';
export interface TableToolbarProps
extends React.HTMLAttributes<HTMLDivElement> {
/**
* Specify a label to be read by screen readers on the container node
* 'aria-label' of the TableToolbar component.
*/
['aria-label']?: string;
/**
* @deprecated please use `aria-label` instead.
* 'aria-label' of the TableToolbar component.
*/
ariaLabel?: string;
/**
* Pass in the children that will be rendered inside the TableToolbar
*/
children: React.ReactNode;
/**
* `lg` Change the row height of table
*/
size?: 'sm' | 'lg';
}
const TableToolbar: React.FC<TableToolbarProps> = ({
['aria-label']: ariaLabel = 'data table toolbar',
ariaLabel: deprecatedAriaLabel,
children,
size,
...rest
}) => {
const prefix = usePrefix();
const className = cx({
[`${prefix}--table-toolbar`]: true,
[`${prefix}--table-toolbar--${size}`]: size,
});
return (
<section
aria-label={deprecatedAriaLabel || ariaLabel}
{...rest}
className={className}>
{children}
</section>
);
};
TableToolbar.propTypes = {
/**
* 'aria-label' of the TableToolbar component.
* Specify a label to be read by screen readers on the container node
*/
['aria-label']: PropTypes.string,
/**
* Deprecated, please use `aria-label` instead.
* Specify a label to be read by screen readers on the container node.
* 'aria-label' of the TableToolbar component.
*/
ariaLabel: deprecate(
PropTypes.string,
'This prop syntax has been deprecated. Please use the new `aria-label`.'
),
/**
* Pass in the children that will be rendered inside the TableToolbar
*/
children: PropTypes.node,
/**
* `lg` Change the row height of table
*/
size: PropTypes.oneOf(['sm', 'lg']),
};
export default TableToolbar;