UNPKG

antd-mobile-taro-ui

Version:

以antd-mobile为设计标准,基于taro框架的微信小程序组件库

32 lines (31 loc) 1.69 kB
import { View } from '@tarojs/components'; import classNames from 'classnames'; import React from 'react'; import { isNodeWithContent } from 'antd-mobile/es/utils/is-node-with-content'; import { withNativeProps } from 'antd-mobile/es/utils/native-props'; import { RightIcon } from 'antd-mobile-taro-icons'; const classPrefix = `adm-list-item`; export const ListItem = props => { var _a; const clickable = (_a = props.clickable) !== null && _a !== void 0 ? _a : !!props.onClick; const arrow = props.arrow === undefined ? clickable : props.arrow; const content = React.createElement(View, { className: `${classPrefix}-content` }, isNodeWithContent(props.prefix) && React.createElement(View, { className: `${classPrefix}-content-prefix` }, props.prefix), React.createElement(View, { className: `${classPrefix}-content-main` }, isNodeWithContent(props.title) && React.createElement(View, { className: `${classPrefix}-title` }, props.title), props.children, isNodeWithContent(props.description) && React.createElement(View, { className: `${classPrefix}-description` }, props.description)), isNodeWithContent(props.extra) && React.createElement(View, { className: `${classPrefix}-content-extra` }, props.extra), isNodeWithContent(arrow) && React.createElement(View, { className: `${classPrefix}-content-arrow` }, arrow === true ? React.createElement(RightIcon, null) : arrow)); return withNativeProps(props, React.createElement(View, { className: classNames(`${classPrefix}`, clickable ? ['adm-plain-anchor'] : [], props.disabled && `${classPrefix}-disabled`), onClick: props.disabled ? undefined : props.onClick }, content)); };