UNPKG

antd-mobile

Version:

基于 React 的移动设计规范实现

81 lines (73 loc) 3.24 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 _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn'; import _inherits from 'babel-runtime/helpers/inherits'; 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) t[p[i]] = s[p[i]]; }return t; }; import React from 'react'; import classNames from 'classnames'; import Touchable from 'rc-touchable'; var Item = function (_React$Component) { _inherits(Item, _React$Component); function Item() { _classCallCheck(this, Item); return _possibleConstructorReturn(this, (Item.__proto__ || Object.getPrototypeOf(Item)).apply(this, arguments)); } _createClass(Item, [{ key: 'render', value: function render() { var _cls; var _a = this.props, children = _a.children, className = _a.className, prefixCls = _a.prefixCls, icon = _a.icon, disabled = _a.disabled, firstItem = _a.firstItem, activeStyle = _a.activeStyle, restProps = __rest(_a, ["children", "className", "prefixCls", "icon", "disabled", "firstItem", "activeStyle"]); var cls = (_cls = {}, _defineProperty(_cls, className, !!className), _defineProperty(_cls, prefixCls + '-item', true), _defineProperty(_cls, prefixCls + '-item-disabled', disabled), _cls); var activeClass = prefixCls + '-item-active '; if (firstItem) { activeClass += prefixCls + '-item-fix-active-arrow'; } return React.createElement( Touchable, { disabled: disabled, activeClassName: activeClass, activeStyle: activeStyle }, React.createElement( 'div', _extends({ className: classNames(cls) }, restProps), React.createElement( 'div', { className: prefixCls + '-item-container' }, icon ? React.createElement( 'span', { className: prefixCls + '-item-icon', 'aria-hidden': 'true' }, icon ) : null, React.createElement( 'span', { className: prefixCls + '-item-content' }, children ) ) ) ); } }]); return Item; }(React.Component); export default Item; Item.defaultProps = { prefixCls: 'am-popover', disabled: false }; Item.myName = 'PopoverItem';