UNPKG

@jdcfe/yep-react

Version:

一套移动端的React组件库

124 lines (108 loc) 5.72 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; } if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import * as React from 'react'; import classNames from 'classnames'; import TouchFeedback from '../touch-feedback'; import RightOutlined from '@jdcfe/icons-react/RightOutlined'; var ListItem = /*#__PURE__*/function (_React$PureComponent) { _inherits(ListItem, _React$PureComponent); var _super = _createSuper(ListItem); function ListItem() { _classCallCheck(this, ListItem); return _super.apply(this, arguments); } _createClass(ListItem, [{ key: "render", value: function render() { var _classNames, _classNames2; var _a = this.props, prefixCls = _a.prefixCls, className = _a.className, activeStyle = _a.activeStyle, error = _a.error, align = _a.align, wrap = _a.wrap, disabled = _a.disabled, children = _a.children, multipleLine = _a.multipleLine, thumb = _a.thumb, extra = _a.extra, icon = _a.icon, onClick = _a.onClick, restProps = __rest(_a, ["prefixCls", "className", "activeStyle", "error", "align", "wrap", "disabled", "children", "multipleLine", "thumb", "extra", "icon", "onClick"]); var wrapCls = classNames("".concat(prefixCls, "-item"), className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-item-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-item-error"), error), _defineProperty(_classNames, "".concat(prefixCls, "-item-top"), align === 'top'), _defineProperty(_classNames, "".concat(prefixCls, "-item-middle"), align === 'middle'), _defineProperty(_classNames, "".concat(prefixCls, "-item-bottom"), align === 'bottom'), _classNames)); var lineCls = classNames("".concat(prefixCls, "-line"), (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-line-multiple"), multipleLine), _defineProperty(_classNames2, "".concat(prefixCls, "-line-wrap"), wrap), _classNames2)); var arrowCls = classNames("".concat(prefixCls, "-arrow"), "".concat(prefixCls, "-arrow-horizontal")); var touchProps = {}; Object.keys(restProps).forEach(function (key) { if (/onTouch/i.test(key)) { // @ts-ignore touchProps[key] = restProps[key]; // @ts-ignore delete restProps[key]; } }); return /*#__PURE__*/React.createElement(TouchFeedback, _extends({}, touchProps, { disabled: disabled || !onClick, activeStyle: activeStyle, activeClassName: "".concat(prefixCls, "-item-active") }), /*#__PURE__*/React.createElement("div", _extends({}, restProps, { onClick: onClick, className: wrapCls }), thumb && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-thumb") }, typeof thumb === 'string' ? /*#__PURE__*/React.createElement("img", { src: thumb }) : thumb), /*#__PURE__*/React.createElement("div", { className: lineCls }, children !== undefined && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-content") }, children), extra !== undefined && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-extra") }, extra), icon && /*#__PURE__*/React.createElement("div", { className: arrowCls, "aria-hidden": "true" }, typeof icon === 'boolean' ? /*#__PURE__*/React.createElement(RightOutlined, { className: "Yep-icon-xxs" }) : icon)))); } }]); return ListItem; }(React.PureComponent); export { ListItem as default }; ListItem.defaultProps = { prefixCls: 'Yep-list', align: 'middle', error: false, multipleLine: false, wrap: false }; export var Brief = function Brief(_ref) { var prefixCls = _ref.prefixCls, style = _ref.style, children = _ref.children; return /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-brief"), style: style }, children); }; Brief.defaultProps = { prefixCls: 'Yep-list', style: {} };