UNPKG

2.14 kBTypeScriptView Raw
1import * as React from 'react';
2import { SxProps } from '@mui/system';
3import { Theme } from '..';
4import { OverridableComponent, OverridableTypeMap, OverrideProps } from '../OverridableComponent';
5import { ListClasses } from './listClasses';
6
7export interface ListOwnProps {
8 /**
9 * The content of the component.
10 */
11 children?: React.ReactNode;
12 /**
13 * Override or extend the styles applied to the component.
14 */
15 classes?: Partial<ListClasses>;
16 /**
17 * If `true`, compact vertical padding designed for keyboard and mouse input is used for
18 * the list and list items.
19 * The prop is available to descendant components as the `dense` context.
20 * @default false
21 */
22 dense?: boolean;
23 /**
24 * If `true`, vertical padding is removed from the list.
25 * @default false
26 */
27 disablePadding?: boolean;
28 /**
29 * The content of the subheader, normally `ListSubheader`.
30 */
31 subheader?: React.ReactNode;
32 /**
33 * The system prop that allows defining system overrides as well as additional CSS styles.
34 */
35 sx?: SxProps<Theme>;
36}
37
38export interface ListTypeMap<AdditionalProps = {}, RootComponent extends React.ElementType = 'ul'> {
39 props: AdditionalProps & ListOwnProps;
40 defaultComponent: RootComponent;
41}
42
43/**
44 * utility to create component types that inherit props from List.
45 */
46export interface ExtendListTypeMap<TypeMap extends OverridableTypeMap> {
47 props: TypeMap['props'] & ListTypeMap['props'];
48 defaultComponent: TypeMap['defaultComponent'];
49}
50
51export type ExtendList<TypeMap extends OverridableTypeMap> = OverridableComponent<
52 ExtendListTypeMap<TypeMap>
53>;
54
55/**
56 *
57 * Demos:
58 *
59 * - [Lists](https://mui.com/material-ui/react-list/)
60 * - [Transfer List](https://mui.com/material-ui/react-transfer-list/)
61 *
62 * API:
63 *
64 * - [List API](https://mui.com/material-ui/api/list/)
65 */
66declare const List: ExtendList<ListTypeMap>;
67
68export type ListProps<
69 RootComponent extends React.ElementType = ListTypeMap['defaultComponent'],
70 AdditionalProps = {},
71> = OverrideProps<ListTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
72 component?: React.ElementType;
73};
74
75export default List;