@momo-kits/swipe 0.0.74-beta → 0.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,146 +1,162 @@
1
- import React, { Component } from 'react';
2
- import {
3
- View,
4
- FlatList
5
- } from 'react-native';
1
+ import React, {Component} from 'react';
2
+ import {View, FlatList} from 'react-native';
6
3
 
7
4
  import PropTypes from 'prop-types';
8
5
  import SwipeAction from './SwipeAction';
9
6
 
10
7
  class SwipeActionList extends Component {
11
- constructor(props) {
12
- super(props);
13
- this._rows = {};
14
- this.openCellId = null;
15
- }
8
+ constructor(props) {
9
+ super(props);
10
+ this._rows = {};
11
+ this.openCellId = null;
12
+ }
16
13
 
17
- setScrollEnabled(enable) {
18
- this._listView?.setNativeProps?.({ scrollEnabled: enable });
19
- }
14
+ setScrollEnabled(enable) {
15
+ this._listView?.setNativeProps?.({scrollEnabled: enable});
16
+ }
20
17
 
21
- closeOpeningRow() {
22
- // if the openCellId is stale due to deleting a row this could be undefined
23
- if (this._rows[this.openCellId]) {
24
- this._rows[this.openCellId].closeRow();
25
- }
18
+ closeOpeningRow() {
19
+ // if the openCellId is stale due to deleting a row this could be undefined
20
+ if (this._rows[this.openCellId]) {
21
+ this._rows[this.openCellId].closeRow();
26
22
  }
23
+ }
27
24
 
28
- isRowOpen() {
29
- return this.openCellId != null;
30
- }
25
+ isRowOpen() {
26
+ return this.openCellId != null;
27
+ }
31
28
 
32
- onOpen(id, rowData) {
33
- const { onOpen } = this.props;
34
- if (this.openCellId && this.openCellId !== id) {
35
- this.closeOpeningRow();
36
- }
37
- this.openCellId = id;
38
- if (onOpen) onOpen(rowData);
29
+ onOpen(id, rowData) {
30
+ const {onOpen} = this.props;
31
+ if (this.openCellId && this.openCellId !== id) {
32
+ this.closeOpeningRow();
39
33
  }
34
+ this.openCellId = id;
35
+ if (onOpen) onOpen(rowData);
36
+ }
40
37
 
41
- onScroll(e) {
42
- const { closeOnScroll, onScroll } = this.props;
43
- if (this.openCellId) {
44
- if (closeOnScroll) {
45
- this.closeOpeningRow();
46
- this.openCellId = null;
47
- }
48
- }
49
- if (onScroll) onScroll(e);
38
+ onScroll(e) {
39
+ const {closeOnScroll, onScroll} = this.props;
40
+ if (this.openCellId) {
41
+ if (closeOnScroll) {
42
+ this.closeOpeningRow();
43
+ this.openCellId = null;
44
+ }
50
45
  }
46
+ if (onScroll) onScroll(e);
47
+ }
51
48
 
52
- renderRow = ({ item, index }) => {
53
- const {
54
- renderItem,
55
- renderItemNonSwipe,
56
- separator,
57
- leftAction,
58
- rightAction,
59
- renderLeftAction,
60
- renderRightAction,
61
- disableRightAction,
62
- disableLeftAction,
63
- closeOnPress,
64
- actionTextStyle,
65
- actionIconStyle,
66
- onPress,
67
- onClose,
68
- actionBackground,
69
- swipeGestureBegan,
70
- swipeGestureEnd,
71
- } = this.props;
72
- return (
73
- <View>
74
- <SwipeAction
75
- ref={(row) => this._rows[`${item}${index}`] = row}
76
- disableRightAction={disableRightAction}
77
- disableLeftAction={disableLeftAction}
78
- leftAction={leftAction}
79
- rightAction={rightAction}
80
- onPress={() => onPress && onPress(item)}
81
- onOpen={() => this.onOpen(`${item}${index}`, item)}
82
- onClose={onClose}
83
- setScrollEnabled={(enable) => this.setScrollEnabled(enable)}
84
- closeOnPress={closeOnPress}
85
- actionTextStyle={actionTextStyle}
86
- actionIconStyle={actionIconStyle}
87
- actionBackground={actionBackground}
88
- rowIndex={index}
89
- renderLeftAction={renderLeftAction}
90
- renderRightAction={renderRightAction}
91
- swipeGestureBegan={swipeGestureBegan}
92
- swipeGestureEnd={swipeGestureEnd}
93
- >
94
- {renderItem?.(item, index)}
95
- </SwipeAction>
96
- {renderItemNonSwipe?.(item, index)}
97
- {separator}
98
- </View>
99
- );
100
- };
49
+ renderRow = ({item, index}) => {
50
+ const {
51
+ renderItem,
52
+ renderItemNonSwipe,
53
+ separator,
54
+ leftAction,
55
+ rightAction,
56
+ renderLeftAction,
57
+ renderRightAction,
58
+ disableRightAction,
59
+ disableLeftAction,
60
+ closeOnPress,
61
+ actionTextStyle,
62
+ actionIconStyle,
63
+ onPress,
64
+ onClose,
65
+ actionBackground,
66
+ swipeGestureBegan,
67
+ swipeGestureEnd,
68
+ } = this.props;
69
+ return (
70
+ <View>
71
+ <SwipeAction
72
+ ref={row => (this._rows[`${item}${index}`] = row)}
73
+ disableRightAction={disableRightAction}
74
+ disableLeftAction={disableLeftAction}
75
+ leftAction={leftAction}
76
+ rightAction={rightAction}
77
+ onPress={() => onPress && onPress(item)}
78
+ onOpen={() => this.onOpen(`${item}${index}`, item)}
79
+ onClose={onClose}
80
+ setScrollEnabled={enable => this.setScrollEnabled(enable)}
81
+ closeOnPress={closeOnPress}
82
+ actionTextStyle={actionTextStyle}
83
+ actionIconStyle={actionIconStyle}
84
+ actionBackground={actionBackground}
85
+ rowIndex={index}
86
+ renderLeftAction={renderLeftAction}
87
+ renderRightAction={renderRightAction}
88
+ swipeGestureBegan={swipeGestureBegan}
89
+ swipeGestureEnd={swipeGestureEnd}>
90
+ {renderItem?.(item, index)}
91
+ </SwipeAction>
92
+ {renderItemNonSwipe?.(item, index)}
93
+ {separator}
94
+ </View>
95
+ );
96
+ };
101
97
 
102
- render() {
103
- const { data } = this.props;
104
- return (
105
- <FlatList
106
- {...this.props}
107
- removeClippedSubviews={false}
108
- ref={(c) => this._listView = c}
109
- onScroll={(e) => this.onScroll(e)}
110
- data={data}
111
- keyExtractor={(item, index) => index.toString()}
112
- renderItem={this.renderRow}
113
- />
114
- );
115
- }
98
+ render() {
99
+ const {data} = this.props;
100
+ return (
101
+ <FlatList
102
+ {...this.props}
103
+ removeClippedSubviews={false}
104
+ ref={c => (this._listView = c)}
105
+ onScroll={e => this.onScroll(e)}
106
+ data={data}
107
+ keyExtractor={(item, index) => index.toString()}
108
+ renderItem={this.renderRow}
109
+ />
110
+ );
111
+ }
116
112
  }
117
113
 
118
114
  SwipeActionList.propTypes = {
119
- data: PropTypes.array.isRequired,
120
- renderItem: PropTypes.oneOfType([PropTypes.func, PropTypes.node, PropTypes.element]).isRequired,
121
- renderItemNonSwipe: PropTypes.oneOfType([PropTypes.func, PropTypes.node, PropTypes.element]),
122
- separator: PropTypes.oneOfType([PropTypes.func, PropTypes.node, PropTypes.element]),
123
- leftAction: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.element]),
124
- rightAction: PropTypes.oneOfType([PropTypes.array, PropTypes.func, PropTypes.element]),
125
- actionTextStyle: PropTypes.object,
126
- actionIconStyle: PropTypes.object,
127
- closeOnScroll: PropTypes.bool,
128
- closeOnPress: PropTypes.bool,
129
- disableRightAction: PropTypes.bool,
130
- disableLeftAction: PropTypes.bool,
131
- onOpen: PropTypes.func,
132
- onClose: PropTypes.func,
133
- onPress: PropTypes.func,
134
- actionBackground: PropTypes.string,
135
- swipeGestureBegan: PropTypes.func,
136
- swipeGestureEnd: PropTypes.func,
115
+ data: PropTypes.array.isRequired,
116
+ renderItem: PropTypes.oneOfType([
117
+ PropTypes.func,
118
+ PropTypes.node,
119
+ PropTypes.element,
120
+ ]).isRequired,
121
+ renderItemNonSwipe: PropTypes.oneOfType([
122
+ PropTypes.func,
123
+ PropTypes.node,
124
+ PropTypes.element,
125
+ ]),
126
+ separator: PropTypes.oneOfType([
127
+ PropTypes.func,
128
+ PropTypes.node,
129
+ PropTypes.element,
130
+ ]),
131
+ leftAction: PropTypes.oneOfType([
132
+ PropTypes.array,
133
+ PropTypes.func,
134
+ PropTypes.element,
135
+ ]),
136
+ rightAction: PropTypes.oneOfType([
137
+ PropTypes.array,
138
+ PropTypes.func,
139
+ PropTypes.element,
140
+ ]),
141
+ actionTextStyle: PropTypes.object,
142
+ actionIconStyle: PropTypes.object,
143
+ closeOnScroll: PropTypes.bool,
144
+ closeOnPress: PropTypes.bool,
145
+ disableRightAction: PropTypes.bool,
146
+ disableLeftAction: PropTypes.bool,
147
+ onOpen: PropTypes.func,
148
+ onClose: PropTypes.func,
149
+ onPress: PropTypes.func,
150
+ actionBackground: PropTypes.string,
151
+ swipeGestureBegan: PropTypes.func,
152
+ swipeGestureEnd: PropTypes.func,
137
153
  };
138
154
 
139
155
  SwipeActionList.defaultProps = {
140
- closeOnScroll: true,
141
- closeOnPress: true,
142
- disableRightAction: true,
143
- disableLeftAction: true
156
+ closeOnScroll: true,
157
+ closeOnPress: true,
158
+ disableRightAction: true,
159
+ disableLeftAction: true,
144
160
  };
145
161
 
146
162
  export default SwipeActionList;