@momo-kits/swipe 0.77.2 → 0.77.3
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.
- package/index.tsx +109 -0
- package/package.json +5 -5
- package/publish.sh +1 -1
- package/styles.ts +16 -0
- package/types.ts +23 -0
- package/SwipeAction.js +0 -708
- package/SwipeActionList.js +0 -162
- package/Swiper.js +0 -845
- package/index.js +0 -7
package/SwipeActionList.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import React, {Component} from 'react';
|
|
2
|
-
import {View, FlatList} from 'react-native';
|
|
3
|
-
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import SwipeAction from './SwipeAction';
|
|
6
|
-
|
|
7
|
-
class SwipeActionList extends Component {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super(props);
|
|
10
|
-
this._rows = {};
|
|
11
|
-
this.openCellId = null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
setScrollEnabled(enable) {
|
|
15
|
-
this._listView?.setNativeProps?.({scrollEnabled: enable});
|
|
16
|
-
}
|
|
17
|
-
|
|
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();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
isRowOpen() {
|
|
26
|
-
return this.openCellId != null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
onOpen(id, rowData) {
|
|
30
|
-
const {onOpen} = this.props;
|
|
31
|
-
if (this.openCellId && this.openCellId !== id) {
|
|
32
|
-
this.closeOpeningRow();
|
|
33
|
-
}
|
|
34
|
-
this.openCellId = id;
|
|
35
|
-
if (onOpen) onOpen(rowData);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
onScroll(e) {
|
|
39
|
-
const {closeOnScroll, onScroll} = this.props;
|
|
40
|
-
if (this.openCellId) {
|
|
41
|
-
if (closeOnScroll) {
|
|
42
|
-
this.closeOpeningRow();
|
|
43
|
-
this.openCellId = null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (onScroll) onScroll(e);
|
|
47
|
-
}
|
|
48
|
-
|
|
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
|
-
};
|
|
97
|
-
|
|
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
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
SwipeActionList.propTypes = {
|
|
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,
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
SwipeActionList.defaultProps = {
|
|
156
|
-
closeOnScroll: true,
|
|
157
|
-
closeOnPress: true,
|
|
158
|
-
disableRightAction: true,
|
|
159
|
-
disableLeftAction: true,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export default SwipeActionList;
|