UNPKG

990 BJavaScriptView Raw
1import React, { forwardRef, useImperativeHandle, useRef } from 'react';
2import classNames from 'classnames';
3import { withNativeProps } from '../../utils/native-props';
4import { mergeProps } from '../../utils/with-default-props';
5const classPrefix = `adm-list`;
6const defaultProps = {
7 mode: 'default'
8};
9export 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