1 | import * as React from 'react';
|
2 | import * as PropTypes from 'prop-types';
|
3 | import { ListProps as ReakitListProps } from 'reakit/ts';
|
4 |
|
5 | import _List from './styled';
|
6 | import ListItem, { ListItemProps } from './ListItem';
|
7 |
|
8 | export type LocalListProps = {
|
9 | children: React.ReactNode;
|
10 | className?: string;
|
11 | isOrdered?: boolean;
|
12 | isHorizontal?: boolean;
|
13 | };
|
14 | export type ListProps = LocalListProps & ReakitListProps;
|
15 | export type ListComponents = {
|
16 | Item: React.FunctionComponent<ListItemProps>;
|
17 | };
|
18 |
|
19 | export const List: React.FunctionComponent<LocalListProps> & ListComponents = ({
|
20 | children,
|
21 | className,
|
22 | isOrdered,
|
23 | ...props
|
24 | }) => (
|
25 | <_List use={isOrdered ? 'ol' : undefined} className={className} isOrdered={isOrdered} {...props}>
|
26 | {children}
|
27 | </_List>
|
28 | );
|
29 |
|
30 | List.Item = ListItem;
|
31 |
|
32 | export const listPropTypes = {
|
33 | children: PropTypes.node.isRequired,
|
34 | className: PropTypes.string,
|
35 | isOrdered: PropTypes.bool,
|
36 | isHorizontal: PropTypes.bool
|
37 | };
|
38 | List.propTypes = listPropTypes;
|
39 |
|
40 | export const listDefaultProps = {
|
41 | className: undefined,
|
42 | isOrdered: false,
|
43 | isHorizontal: false
|
44 | };
|
45 | List.defaultProps = listDefaultProps;
|
46 |
|
47 | const C: React.FunctionComponent<ListProps> & ListComponents = List;
|
48 | export default C;
|