yylib-quick-mobile
Version:
yylib-quick-mobile
127 lines (104 loc) • 5.45 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _swipeAction = require('antd-mobile/lib/swipe-action');
var _swipeAction2 = _interopRequireDefault(_swipeAction);
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/swipe-action/style/css');
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
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 YYSwipeAction = function (_Component) {
_inherits(YYSwipeAction, _Component);
function YYSwipeAction() {
var _ref;
var _temp, _this, _ret;
_classCallCheck(this, YYSwipeAction);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = YYSwipeAction.__proto__ || Object.getPrototypeOf(YYSwipeAction)).call.apply(_ref, [this].concat(args))), _this), _this.firstPress = function (event) {
event.stopPropagation();
if (_this.props.firstPress) {
_this.props.firstPress();
}
}, _this.secondPress = function (event) {
event.stopPropagation();
if (_this.props.secondPress) {
_this.props.secondPress();
}
}, _this.onOpen = function () {
if (_this.props.onOpen) {
_this.props.onOpen();
}
}, _this.onClose = function () {
if (_this.props.onClose) {
_this.props.onClose();
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
_createClass(YYSwipeAction, [{
key: 'render',
value: function render() {
var _props = this.props,
first = _props.first,
second = _props.second,
autoClose = _props.autoClose,
disabled = _props.disabled,
disabledFirst = _props.disabledFirst,
disabledSecond = _props.disabledSecond,
children = _props.children,
left = _props.left,
right = _props.right,
visible = _props.visible,
restProps = _objectWithoutProperties(_props, ['first', 'second', 'autoClose', 'disabled', 'disabledFirst', 'disabledSecond', 'children', 'left', 'right', 'visible']);
var rightButtons = [];
if (disabledFirst) {
rightButtons.push({
text: first || '取消',
onPress: this.firstPress.bind(this),
style: { backgroundColor: '#ddd', color: 'white' }
});
}
if (disabledSecond) {
rightButtons.push({
text: second || '删除',
onPress: this.secondPress.bind(this),
style: { backgroundColor: '#F4333C', color: 'white' }
});
}
return _react2.default.createElement(
_swipeAction2.default,
_extends({}, restProps, {
className: !visible && 'hidden',
autoClose: true,
left: left && left.length > 0,
right: right && right.length > 0 || rightButtons,
onOpen: this.onOpen.bind(this),
onClose: this.onClose.bind(this),
disabled: disabled
}),
this.props.RunInDesign && !children ? _react2.default.createElement(
'div',
null,
'\u6D4B\u8BD5\u6ED1\u52A8-\u53EA\u6709\u53F3\u4FA7\u6309\u94AE-\u4E24\u4E2A'
) : children
);
}
}]);
return YYSwipeAction;
}(_react.Component);
YYSwipeAction.defaultProps = {
left: [],
right: [],
disabled: false,
autoClose: true,
visible: true
};
exports.default = YYSwipeAction;
;