1 | import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
2 | import classNames from 'classnames';
|
3 | import { withNativeProps } from '../../utils/native-props';
|
4 | import { mergeProps } from '../../utils/with-default-props';
|
5 | const classPrefix = `adm-list`;
|
6 | const defaultProps = {
|
7 | mode: 'default'
|
8 | };
|
9 | export const List = forwardRef((p, ref) => {
|
10 | const props = mergeProps(defaultProps, p);
|
11 | const nativeElementRef = useRef(null);
|
12 | useImperativeHandle(ref, () => ({
|
13 | get nativeElement() {
|
14 | return nativeElementRef.current;
|
15 | }
|
16 | }));
|
17 | return withNativeProps(props, React.createElement("div", {
|
18 | className: classNames(classPrefix, `${classPrefix}-${props.mode}`),
|
19 | ref: nativeElementRef
|
20 | }, props.header && React.createElement("div", {
|
21 | className: `${classPrefix}-header`
|
22 | }, props.header), React.createElement("div", {
|
23 | className: `${classPrefix}-body`
|
24 | }, React.createElement("div", {
|
25 | className: `${classPrefix}-body-inner`
|
26 | }, props.children))));
|
27 | }); |
\ | No newline at end of file |