UNPKG

2.08 kBJavaScriptView Raw
1import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
2import _createClass from 'babel-runtime/helpers/createClass';
3import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
4import _inherits from 'babel-runtime/helpers/inherits';
5import classnames from 'classnames';
6import Swipeout from 'rc-swipeout';
7import React from 'react';
8
9var SwipeAction = function (_React$Component) {
10 _inherits(SwipeAction, _React$Component);
11
12 function SwipeAction() {
13 _classCallCheck(this, SwipeAction);
14
15 return _possibleConstructorReturn(this, (SwipeAction.__proto__ || Object.getPrototypeOf(SwipeAction)).apply(this, arguments));
16 }
17
18 _createClass(SwipeAction, [{
19 key: 'render',
20 value: function render() {
21 var _props = this.props,
22 className = _props.className,
23 style = _props.style,
24 prefixCls = _props.prefixCls,
25 _props$left = _props.left,
26 left = _props$left === undefined ? [] : _props$left,
27 _props$right = _props.right,
28 right = _props$right === undefined ? [] : _props$right,
29 autoClose = _props.autoClose,
30 disabled = _props.disabled,
31 onOpen = _props.onOpen,
32 onClose = _props.onClose,
33 children = _props.children;
34
35 var wrapClass = classnames(prefixCls, className);
36 return left.length || right.length ? React.createElement(
37 'div',
38 { style: style, className: className },
39 React.createElement(
40 Swipeout,
41 { prefixCls: prefixCls, left: left, right: right, autoClose: autoClose, disabled: disabled, onOpen: onOpen, onClose: onClose },
42 children
43 )
44 ) : React.createElement(
45 'div',
46 { style: style, className: wrapClass },
47 children
48 );
49 }
50 }]);
51
52 return SwipeAction;
53}(React.Component);
54
55SwipeAction.defaultProps = {
56 prefixCls: 'am-swipe',
57 autoClose: false,
58 disabled: false,
59 left: [],
60 right: [],
61 onOpen: function onOpen() {},
62 onClose: function onClose() {}
63};
64export default SwipeAction;
\No newline at end of file