UNPKG

@alifd/meet-react

Version:

Fusion Mobile React UI System Component

62 lines 4.04 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { __rest } from "tslib"; import React, { createElement, forwardRef } from "react"; import classNames from 'classnames'; import View from '../../view'; import Icon from '../../icon'; import ListItemCaption from './caption'; import ItemContent from './content'; import { ListItemAction, ListItemMedia } from './media'; import ItemTitle from './title'; import { isFunction, isString } from '../../utils'; var arrowIconMap = { right: 'arrow-right', up: 'arrow-up', down: 'arrow-down', loading: 'loading' }; var renderExtra = function renderExtra(ext) { if (isString(ext)) { return /*#__PURE__*/React.createElement(ListItemCaption, null, ext); } else if (ext) { return ext; } return null; }; var ListItem = function ListItem(props, ref) { var children = props.children, _props$prefix = props.prefix, prefix = _props$prefix === void 0 ? 'mt-' : _props$prefix, arrow = props.arrow, media = props.media, title = props.title, subTitle = props.subTitle, description = props.description, extra = props.extra, className = props.className, _onClick = props.onClick, _props$disabled = props.disabled, disabled = _props$disabled === void 0 ? false : _props$disabled, others = __rest(props, ["children", "prefix", "arrow", "media", "title", "subTitle", "description", "extra", "className", "onClick", "disabled"]); return /*#__PURE__*/React.createElement(View, _extends({}, others, { className: classNames("".concat(prefix, "list-item"), _defineProperty(_defineProperty({}, "".concat(prefix, "list-item--clickable"), isFunction(_onClick)), "".concat(prefix, "list-item--disabled"), disabled), className), ref: ref, onClick: function onClick() { if (!disabled && _onClick) { _onClick.apply(void 0, arguments); } } }), media ? /*#__PURE__*/React.createElement(ListItemMedia, null, media) : null, /*#__PURE__*/React.createElement(View, { className: "".concat(prefix, "list-item-container") }, title || description ? /*#__PURE__*/React.createElement(ItemContent, null, title ? /*#__PURE__*/React.createElement(ItemTitle, null, title) : null, subTitle ? /*#__PURE__*/React.createElement(ListItemCaption, null, subTitle) : null, description ? /*#__PURE__*/React.createElement(ListItemCaption, null, description) : null) : null, extra || isString(arrow) ? /*#__PURE__*/React.createElement(ListItemAction, null, renderExtra(extra), isString(arrow) ? /*#__PURE__*/React.createElement(Icon, { size: "xs", className: "".concat(prefix, "list-item-icon"), name: arrowIconMap[arrow] }) : null) : null, children)); }; ListItem.displayName = 'ListItem'; export default /*#__PURE__*/forwardRef(ListItem);