UNPKG

2.11 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { Theme } from '..';
4import { ExtendButtonBase, ExtendButtonBaseTypeMap } from '../ButtonBase';
5import { OverrideProps } from '../OverridableComponent';
6import { TableSortLabelClasses } from './tableSortLabelClasses';
7
8export interface TableSortLabelOwnProps {
9 /**
10 * If `true`, the label will have the active styling (should be true for the sorted column).
11 * @default false
12 */
13 active?: boolean;
14 /**
15 * Label contents, the arrow will be appended automatically.
16 */
17 children?: React.ReactNode;
18 /**
19 * Override or extend the styles applied to the component.
20 */
21 classes?: Partial<TableSortLabelClasses>;
22 /**
23 * The current sort direction.
24 * @default 'asc'
25 */
26 direction?: 'asc' | 'desc';
27 /**
28 * Hide sort icon when active is false.
29 * @default false
30 */
31 hideSortIcon?: boolean;
32 /**
33 * Sort icon to use.
34 * @default ArrowDownwardIcon
35 */
36 IconComponent?: React.JSXElementConstructor<{
37 className: string;
38 }>;
39 /**
40 * The system prop that allows defining system overrides as well as additional CSS styles.
41 */
42 sx?: SxProps<Theme>;
43}
44
45export type TableSortLabelTypeMap<
46 AdditionalProps = {},
47 RootComponent extends React.ElementType = 'span',
48> = ExtendButtonBaseTypeMap<{
49 props: AdditionalProps & TableSortLabelOwnProps;
50 defaultComponent: RootComponent;
51}>;
52
53/**
54 * A button based label for placing inside `TableCell` for column sorting.
55 *
56 * Demos:
57 *
58 * - [Table](https://mui.com/material-ui/react-table/)
59 *
60 * API:
61 *
62 * - [TableSortLabel API](https://mui.com/material-ui/api/table-sort-label/)
63 * - inherits [ButtonBase API](https://mui.com/material-ui/api/button-base/)
64 */
65declare const TableSortLabel: ExtendButtonBase<TableSortLabelTypeMap>;
66
67export type TableSortLabelProps<
68 RootComponent extends React.ElementType = TableSortLabelTypeMap['defaultComponent'],
69 AdditionalProps = {},
70> = OverrideProps<TableSortLabelTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
71 component?: React.ElementType;
72};
73
74export default TableSortLabel;