UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

137 lines (107 loc) 6.02 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _button = require('antd-mobile/lib/button'); var _button2 = _interopRequireDefault(_button); var _extends = Object.assign || 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; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); require('antd-mobile/lib/button/style/css'); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames); var _YYIcon = require('./../icon/YYIcon'); var _YYIcon2 = _interopRequireDefault(_YYIcon); require('./YYButton.css'); var _FunctionUtil = require('../../utils/FunctionUtil'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var YYButton = function (_React$Component) { _inherits(YYButton, _React$Component); function YYButton() { var _ref; var _temp, _this, _ret; _classCallCheck(this, YYButton); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = YYButton.__proto__ || Object.getPrototypeOf(YYButton)).call.apply(_ref, [this].concat(args))), _this), _this.onHandleClick = function (e) { if ((0, _FunctionUtil.isFunction)(_this.props.onClick)) { _this.props.onClick(e); } }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(YYButton, [{ key: 'render', value: function render() { var _props = this.props, uititle = _props.uititle, type = _props.type, size = _props.size, disabled = _props.disabled, visible = _props.visible, onClick = _props.onClick, inline = _props.inline, loading = _props.loading, icon = _props.icon, radius = _props.radius, wingBlank = _props.wingBlank, children = _props.children, className = _props.className, offline = _props.offline, parentType = _props.parentType, uiorigin = _props.uiorigin, RunInDesign = _props.RunInDesign, uitype = _props.uitype, uikey = _props.uikey, nid = _props.nid, control_event = _props.control_event, findUI = _props.findUI, restProps = _objectWithoutProperties(_props, ['uititle', 'type', 'size', 'disabled', 'visible', 'onClick', 'inline', 'loading', 'icon', 'radius', 'wingBlank', 'children', 'className', 'offline', 'parentType', 'uiorigin', 'RunInDesign', 'uitype', 'uikey', 'nid', 'control_event', 'findUI']); var wrapClz = (0, _classnames2.default)('yy-button', !radius && 'yy-button-no-radius', wingBlank && 'yy-button-wing-blank', !visible && 'hidden', className); var iconCom = icon ? _react2.default.createElement(_YYIcon2.default, { type: icon }) : null; return _react2.default.createElement( _button2.default, _extends({}, restProps, { className: wrapClz, type: type, size: size, disabled: disabled, inline: inline, loading: loading, icon: iconCom, onClick: this.onHandleClick }), uititle || children ); } }]); return YYButton; }(_react2.default.Component); YYButton.defaultProps = { uititle: null, type: null, size: 'large', disabled: false, visible: true, inline: false, onClick: null, loading: false, icon: "", radius: true, wingBlank: false, offline: false, parentType: '', uiorigin: '', RunInDesign: false, uitype: '', uikey: '', nid: '', control_event: {}, findUI: '' }; exports.default = YYButton;