1 | import React, { forwardRef } from 'react';
|
2 | import PropTypes from 'prop-types';
|
3 | import classNames from 'classnames';
|
4 | import { mapToCssModules, tagPropType } from './utils';
|
5 |
|
6 | const propTypes = {
|
7 |
|
8 | className: PropTypes.string,
|
9 |
|
10 | cssModule: PropTypes.object,
|
11 |
|
12 | tag: tagPropType,
|
13 |
|
14 | type: PropTypes.string,
|
15 | };
|
16 |
|
17 | const List = forwardRef((props, ref) => {
|
18 | const { className, cssModule, tag: Tag = 'ul', type, ...attributes } = props;
|
19 | const classes = mapToCssModules(
|
20 | classNames(className, type ? `list-${type}` : false),
|
21 | cssModule,
|
22 | );
|
23 |
|
24 | return <Tag {...attributes} className={classes} ref={ref} />;
|
25 | });
|
26 |
|
27 | List.name = 'List';
|
28 | List.propTypes = propTypes;
|
29 |
|
30 | export default List;
|
31 |
|
\ | No newline at end of file |