UNPKG

2.04 kBJavaScriptView Raw
1import { RightOutline } from 'antd-mobile-icons';
2import classNames from 'classnames';
3import React from 'react';
4import { isNodeWithContent } from '../../utils/is-node-with-content';
5import { withNativeProps } from '../../utils/native-props';
6import { mergeProp } from '../../utils/with-default-props';
7import { useConfig } from '../config-provider';
8const classPrefix = `adm-list-item`;
9export const ListItem = props => {
10 var _a, _b;
11 const {
12 arrow,
13 arrowIcon
14 } = props;
15 const {
16 list: componentConfig = {}
17 } = useConfig();
18 const clickable = (_a = props.clickable) !== null && _a !== void 0 ? _a : !!props.onClick;
19 const showArrow = (_b = arrow !== null && arrow !== void 0 ? arrow : arrowIcon) !== null && _b !== void 0 ? _b : clickable;
20 const mergedArrowIcon = mergeProp(componentConfig.arrowIcon, arrow !== true ? arrow : null, arrowIcon !== true ? arrowIcon : null);
21 const content = React.createElement("div", {
22 className: `${classPrefix}-content`
23 }, isNodeWithContent(props.prefix) && React.createElement("div", {
24 className: `${classPrefix}-content-prefix`
25 }, props.prefix), React.createElement("div", {
26 className: `${classPrefix}-content-main`
27 }, isNodeWithContent(props.title) && React.createElement("div", {
28 className: `${classPrefix}-title`
29 }, props.title), props.children, isNodeWithContent(props.description) && React.createElement("div", {
30 className: `${classPrefix}-description`
31 }, props.description)), isNodeWithContent(props.extra) && React.createElement("div", {
32 className: `${classPrefix}-content-extra`
33 }, props.extra), showArrow && React.createElement("div", {
34 className: `${classPrefix}-content-arrow`
35 }, mergedArrowIcon || React.createElement(RightOutline, null)));
36 return withNativeProps(props, React.createElement(clickable ? 'a' : 'div', {
37 className: classNames(`${classPrefix}`, clickable ? ['adm-plain-anchor'] : [], props.disabled && `${classPrefix}-disabled`),
38 onClick: props.disabled ? undefined : props.onClick
39 }, content));
40};
\No newline at end of file