1 | var _class, _temp;
|
2 |
|
3 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
4 |
|
5 | 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; }
|
6 |
|
7 | 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; }
|
8 |
|
9 | import React, { Component } from 'react';
|
10 | import PropTypes from 'prop-types';
|
11 | import Instance from './instance';
|
12 | import Button from './../Button';
|
13 |
|
14 | var ListPull = (_temp = _class = function (_Component) {
|
15 | _inherits(ListPull, _Component);
|
16 |
|
17 | function ListPull(props) {
|
18 | _classCallCheck(this, ListPull);
|
19 |
|
20 | return _possibleConstructorReturn(this, _Component.call(this, props));
|
21 | }
|
22 |
|
23 | ListPull.prototype.componentDidMount = function componentDidMount() {
|
24 | var _this2 = this;
|
25 |
|
26 | var instance = new Instance(this.$el, {
|
27 | onClick: function onClick(e) {
|
28 | var index = e.target.getAttribute('data-index');
|
29 | var item = _this2.props.list[index];
|
30 | var btn = null;
|
31 | var i = e.target.getAttribute('data-i');
|
32 | var direction = e.target.getAttribute('data-direction');
|
33 | if (i && direction) {
|
34 | if (direction === 'left') {
|
35 | btn = item.lButtons[i];
|
36 | } else {
|
37 | btn = item.rButtons[i];
|
38 | }
|
39 | }
|
40 | if (_this2.props.onClick) _this2.props.onClick(item, index, btn);
|
41 | },
|
42 | onShowedLeft: this.props.onShowedLeft,
|
43 | onShowedRight: this.props.onShowedRight
|
44 | });
|
45 | this.instance = instance;
|
46 | };
|
47 |
|
48 | ListPull.prototype.render = function render() {
|
49 | var _this3 = this;
|
50 |
|
51 | var _props = this.props,
|
52 | list = _props.list,
|
53 | style = _props.style,
|
54 | className = _props.className;
|
55 |
|
56 | return React.createElement(
|
57 | 'ul',
|
58 | { ref: function ref(el) {
|
59 | _this3.$el = el;
|
60 | }, className: 'list-pull' + (className ? ' ' + className : ''), style: style },
|
61 | list.map(function (item, index) {
|
62 | return React.createElement(
|
63 | 'li',
|
64 | { key: 'button' + index, 'data-index': '' + index, className: 'border-b list-pull-li' },
|
65 | item.lButtons && item.lButtons.length && React.createElement(
|
66 | 'div',
|
67 | { className: 'list-pull-left' },
|
68 | item.lButtons.map(function (button, i) {
|
69 | return React.createElement(
|
70 | Button,
|
71 | { key: 'button' + i, 'data-index': '' + index, 'data-i': '' + i, 'data-direction': 'left', className: 'list-pull-button' + (button.className ? ' ' + button.className : ''), style: button.style },
|
72 | button.value
|
73 | );
|
74 | })
|
75 | ),
|
76 | React.createElement(
|
77 | 'div',
|
78 | { className: 'list-pull-handler', 'data-index': '' + index },
|
79 | item.container
|
80 | ),
|
81 | item.rButtons && item.rButtons.length && React.createElement(
|
82 | 'div',
|
83 | { className: 'list-pull-right' },
|
84 | item.rButtons.map(function (button, i) {
|
85 | return React.createElement(
|
86 | Button,
|
87 | { key: 'button' + i, 'data-index': '' + index, 'data-i': '' + i, 'data-direction': 'right', className: 'list-pull-button' + (button.className ? ' ' + button.className : ''), style: button.style },
|
88 | button.value
|
89 | );
|
90 | })
|
91 | )
|
92 | );
|
93 | })
|
94 | );
|
95 | };
|
96 |
|
97 | return ListPull;
|
98 | }(Component), _class.defaultProps = {}, _temp);
|
99 | export { ListPull as default };
|
100 | ListPull.propTypes = process.env.NODE_ENV !== "production" ? {
|
101 | list: PropTypes.array,
|
102 | style: PropTypes.object,
|
103 | className: PropTypes.string,
|
104 | onClick: PropTypes.func,
|
105 | onShowedLeft: PropTypes.func,
|
106 | onShowedRight: PropTypes.func
|
107 | } : {}; |
\ | No newline at end of file |