@momo-kits/auto-complete 0.0.73-beta → 0.0.74-beta.30
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/AutoComplete.js +324 -292
- package/package.json +15 -15
- package/publish.sh +2 -2
package/AutoComplete.js
CHANGED
|
@@ -1,342 +1,374 @@
|
|
|
1
1
|
/* eslint-disable no-extra-boolean-cast */
|
|
2
2
|
/* eslint-disable no-param-reassign */
|
|
3
|
-
import React, {
|
|
3
|
+
import React, {Component} from 'react';
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
findNodeHandle,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
UIManager,
|
|
8
|
+
View,
|
|
9
|
+
Platform,
|
|
10
10
|
} from 'react-native';
|
|
11
|
-
import { get
|
|
11
|
+
import {debounce, get} from 'lodash';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import {
|
|
14
|
-
|
|
14
|
+
ValueUtil,
|
|
15
|
+
NumberUtils,
|
|
16
|
+
Colors,
|
|
17
|
+
Text,
|
|
18
|
+
RNGestureHandler,
|
|
19
|
+
Spacing,
|
|
20
|
+
Shadow,
|
|
21
|
+
Radius,
|
|
15
22
|
} from '@momo-kits/core';
|
|
16
23
|
|
|
17
|
-
const {
|
|
24
|
+
const {TouchableOpacity} = RNGestureHandler;
|
|
18
25
|
export default class AutoComplete extends Component {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.hashmapRefs = {};
|
|
29
|
+
this.hashmapPosition = {};
|
|
30
|
+
this.hashmapInputValue = {};
|
|
31
|
+
this.selectedItem = null;
|
|
32
|
+
this.childrenWithProps = null;
|
|
33
|
+
}
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
/**
|
|
36
|
+
* func measure all component have keyAutoComplete to get it's position
|
|
37
|
+
*/
|
|
38
|
+
measure() {
|
|
39
|
+
try {
|
|
40
|
+
Object.keys(this.hashmapRefs)?.forEach(key => {
|
|
41
|
+
const node = findNodeHandle(this.hashmapRefs[key]);
|
|
42
|
+
if (node) {
|
|
43
|
+
if (Platform.OS === 'android') {
|
|
44
|
+
UIManager.measureLayoutRelativeToParent(
|
|
45
|
+
node,
|
|
46
|
+
e => {
|
|
47
|
+
console.error(e);
|
|
48
|
+
},
|
|
49
|
+
(x, y, width, height) => {
|
|
50
|
+
this.hashmapPosition[key] = {
|
|
51
|
+
x,
|
|
52
|
+
y: y + height - 26,
|
|
53
|
+
width,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
UIManager.measure(node, (x, y, width, height) => {
|
|
59
|
+
this.hashmapPosition[key] = {
|
|
60
|
+
x,
|
|
61
|
+
y: y + height - 26,
|
|
62
|
+
width,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
57
66
|
}
|
|
67
|
+
});
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.log(`try catch :: ${e}`);
|
|
58
70
|
}
|
|
71
|
+
}
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
componentDidMount() {
|
|
74
|
+
// setTimeout to fix async
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
this.measure();
|
|
77
|
+
}, 500);
|
|
78
|
+
}
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
getValueByKey = (key, value) => {
|
|
81
|
+
const splitKey = key.split('-');
|
|
82
|
+
return splitKey.length > 1
|
|
83
|
+
? splitKey.reduce(
|
|
84
|
+
(result, item, index) =>
|
|
85
|
+
(result =
|
|
86
|
+
result +
|
|
87
|
+
value[item] +
|
|
88
|
+
(index === splitKey.length - 1 ? '' : !!value[item] ? ' ' : '')),
|
|
89
|
+
'',
|
|
90
|
+
)
|
|
91
|
+
: key === 'phone'
|
|
92
|
+
? NumberUtils.formatPhoneNumberVN(value[key])
|
|
93
|
+
: value[key];
|
|
94
|
+
};
|
|
72
95
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
/**
|
|
97
|
+
* loop all child components
|
|
98
|
+
* @param {"Children"} components ;
|
|
99
|
+
*/
|
|
100
|
+
cloneChildren(components) {
|
|
101
|
+
if (components) {
|
|
102
|
+
return React.Children.map(components, child => {
|
|
103
|
+
if (!child?.props) return child;
|
|
104
|
+
if (
|
|
105
|
+
child?.props?.children &&
|
|
106
|
+
React.Children.count(child?.props?.children) > 0 &&
|
|
107
|
+
child.type.name !== Text
|
|
108
|
+
) {
|
|
109
|
+
// component have children -> clone it and all it's children
|
|
110
|
+
return React.cloneElement(child, {
|
|
111
|
+
children: this.cloneChildren(child.props.children),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
87
114
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return React.cloneElement(child, {
|
|
107
|
-
ref: (view) => this.hashmapRefs[keyAutoComplete] = view,
|
|
108
|
-
onChangeText: (text) => this.changeTextHandle(child, text, onChangeText),
|
|
109
|
-
onFocus: (e) => this.focusHandle(e, child, onFocus),
|
|
110
|
-
onEndEditing: (e) => this.endFocusHandle(e, onEndEditing)
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return child;
|
|
115
|
+
const {onChangeText, keyAutoComplete, onFocus, onEndEditing} =
|
|
116
|
+
child.props;
|
|
117
|
+
if (keyAutoComplete) {
|
|
118
|
+
// Update props when component have keyAutoComplete
|
|
119
|
+
if (this.selectedItem) {
|
|
120
|
+
this.hashmapInputValue[keyAutoComplete] = this.getValueByKey(
|
|
121
|
+
keyAutoComplete,
|
|
122
|
+
this.selectedItem,
|
|
123
|
+
); // this.selectedItem[keyAutoComplete];
|
|
124
|
+
return React.cloneElement(child, {
|
|
125
|
+
ref: view => (this.hashmapRefs[keyAutoComplete] = view),
|
|
126
|
+
onChangeText: text =>
|
|
127
|
+
this.changeTextHandle(child, text, onChangeText),
|
|
128
|
+
onFocus: e => this.focusHandle(e, child, onFocus),
|
|
129
|
+
// value: this.getValueByKey(keyAutoComplete, this.selectedItem),
|
|
130
|
+
onEndEditing: e => this.endFocusHandle(e, onEndEditing),
|
|
114
131
|
});
|
|
132
|
+
}
|
|
133
|
+
return React.cloneElement(child, {
|
|
134
|
+
ref: view => (this.hashmapRefs[keyAutoComplete] = view),
|
|
135
|
+
onChangeText: text =>
|
|
136
|
+
this.changeTextHandle(child, text, onChangeText),
|
|
137
|
+
onFocus: e => this.focusHandle(e, child, onFocus),
|
|
138
|
+
onEndEditing: e => this.endFocusHandle(e, onEndEditing),
|
|
139
|
+
});
|
|
115
140
|
}
|
|
116
|
-
|
|
117
|
-
|
|
141
|
+
return child;
|
|
142
|
+
});
|
|
118
143
|
}
|
|
119
144
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
style = {},
|
|
123
|
-
} = this.props;
|
|
124
|
-
const suggest = get(this.state, 'suggest', {});
|
|
125
|
-
const childrenWithProps = this.cloneChildren(get(this.props, 'children', null));
|
|
126
|
-
return (
|
|
127
|
-
<View style={[{ zIndex: 1 }, style]}>
|
|
128
|
-
{childrenWithProps}
|
|
129
|
-
{this.renderSuggest(suggest)}
|
|
130
|
-
</View>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
145
|
+
return components;
|
|
146
|
+
}
|
|
133
147
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
};
|
|
148
|
+
render() {
|
|
149
|
+
const {style = {}} = this.props;
|
|
150
|
+
const suggest = get(this.state, 'suggest', {});
|
|
151
|
+
const childrenWithProps = this.cloneChildren(
|
|
152
|
+
get(this.props, 'children', null),
|
|
153
|
+
);
|
|
154
|
+
return (
|
|
155
|
+
<View style={[{zIndex: 1}, style]}>
|
|
156
|
+
{childrenWithProps}
|
|
157
|
+
{this.renderSuggest(suggest)}
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
162
|
+
querySearch = (child, text) => {
|
|
163
|
+
const keyAutoComplete = get(child.props, 'keyAutoComplete', '');
|
|
164
|
+
const isShowAutoComplete = get(child.props, 'isShowAutoComplete', true);
|
|
165
|
+
const {data} = this.props;
|
|
166
|
+
const dataOutput =
|
|
167
|
+
data && data.length > 0 && this.filter(data, keyAutoComplete, text);
|
|
168
|
+
if (this.hashmapRefs[keyAutoComplete]) {
|
|
169
|
+
this.setState({
|
|
170
|
+
suggest: {
|
|
171
|
+
data: dataOutput,
|
|
172
|
+
position: this.hashmapPosition[keyAutoComplete],
|
|
173
|
+
isShowAutoComplete,
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
156
178
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
changeTextHandle = (child, text, onChangeText) => {
|
|
180
|
+
this.querySearch(child, text);
|
|
181
|
+
if (onChangeText && typeof onChangeText === 'function') {
|
|
182
|
+
onChangeText(text);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
162
185
|
|
|
163
|
-
|
|
186
|
+
focusHandle = (e, child, onFocus) => {
|
|
187
|
+
let text = '';
|
|
188
|
+
if (child && typeof child.getText === 'function') {
|
|
189
|
+
text = child.getText();
|
|
190
|
+
}
|
|
164
191
|
|
|
165
|
-
|
|
166
|
-
onFocus(e);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
192
|
+
this.querySearch(child, text);
|
|
169
193
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (onEndEditing && typeof onEndEditing === 'function') {
|
|
175
|
-
onEndEditing(e);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
194
|
+
if (onFocus && typeof onFocus === 'function') {
|
|
195
|
+
onFocus(e);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
178
198
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
199
|
+
endFocusHandle = (e, onEndEditing) => {
|
|
200
|
+
if (this.isShowingSuggest()) {
|
|
201
|
+
this.hideSuggest();
|
|
202
|
+
}
|
|
203
|
+
if (onEndEditing && typeof onEndEditing === 'function') {
|
|
204
|
+
onEndEditing(e);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
186
207
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
.toLowerCase()
|
|
195
|
-
.trim()
|
|
196
|
-
.replace(/\s/g, '');
|
|
197
|
-
return (
|
|
198
|
-
valueStrFormated.indexOf(queryFormated) !== -1
|
|
199
|
-
);
|
|
200
|
-
});
|
|
201
|
-
};
|
|
208
|
+
filter = (data, key, query) => {
|
|
209
|
+
if (!data || !key) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
if (query === '') {
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
202
215
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
return data.filter(item => {
|
|
217
|
+
const valueStr = item ? this.getValueByKey(key, item) : '';
|
|
218
|
+
const valueStrFormated = ValueUtil.removeAlias(valueStr)
|
|
219
|
+
.toLowerCase()
|
|
220
|
+
.trim()
|
|
221
|
+
.replace(/\s/g, '');
|
|
222
|
+
const queryFormated = ValueUtil.removeAlias(query)
|
|
223
|
+
.toLowerCase()
|
|
224
|
+
.trim()
|
|
225
|
+
.replace(/\s/g, '');
|
|
226
|
+
return valueStrFormated.indexOf(queryFormated) !== -1;
|
|
227
|
+
});
|
|
228
|
+
};
|
|
208
229
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
sliceData.map((item, index) => (
|
|
220
|
-
<View key={index.toString()}>
|
|
221
|
-
{this.renderItem({ item, index })}
|
|
222
|
-
{index !== sliceData.length - 1 && this.renderSeparator()}
|
|
223
|
-
</View>
|
|
224
|
-
))
|
|
225
|
-
}
|
|
226
|
-
</View>
|
|
230
|
+
renderSuggest(suggest) {
|
|
231
|
+
const {numSuggest} = this.props;
|
|
232
|
+
if (
|
|
233
|
+
suggest &&
|
|
234
|
+
suggest.data &&
|
|
235
|
+
suggest.data.length > 0 &&
|
|
236
|
+
suggest.isShowAutoComplete
|
|
237
|
+
) {
|
|
238
|
+
const {x = 0, y = 0, width = 0} = suggest.position || {};
|
|
239
|
+
const sliceData = suggest.data.slice(0, numSuggest);
|
|
227
240
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
241
|
+
return (
|
|
242
|
+
<View
|
|
243
|
+
style={[
|
|
244
|
+
styles.containerSuggest,
|
|
245
|
+
Shadow.Light,
|
|
246
|
+
{
|
|
247
|
+
left: x,
|
|
248
|
+
top: y,
|
|
249
|
+
width,
|
|
250
|
+
},
|
|
251
|
+
]}>
|
|
252
|
+
{sliceData.map((item, index) => (
|
|
253
|
+
<View key={index.toString()}>
|
|
254
|
+
{this.renderItem({item, index})}
|
|
255
|
+
{index !== sliceData.length - 1 && this.renderSeparator()}
|
|
256
|
+
</View>
|
|
257
|
+
))}
|
|
258
|
+
</View>
|
|
259
|
+
);
|
|
231
260
|
}
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
232
263
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
</TouchableOpacity>
|
|
245
|
-
);
|
|
246
|
-
};
|
|
264
|
+
renderItem = ({item, index}) => {
|
|
265
|
+
const {renderSuggestItem} = this.props;
|
|
266
|
+
return (
|
|
267
|
+
<TouchableOpacity onPress={() => this.onPressItemSuggest(item)}>
|
|
268
|
+
{renderSuggestItem && typeof renderSuggestItem === 'function'
|
|
269
|
+
? renderSuggestItem({item, index})
|
|
270
|
+
: this.renderSuggestItemDefault({item, index})}
|
|
271
|
+
</TouchableOpacity>
|
|
272
|
+
);
|
|
273
|
+
};
|
|
247
274
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
275
|
+
renderSeparator = () => <View style={styles.separator} />;
|
|
276
|
+
|
|
277
|
+
renderSuggestItemDefault = ({item}) => {
|
|
278
|
+
const {title, value} = item;
|
|
279
|
+
return (
|
|
280
|
+
<View style={[styles.viewSuggest]}>
|
|
281
|
+
<Text.Title>{title}</Text.Title>
|
|
282
|
+
<Text.Title>{value}</Text.Title>
|
|
283
|
+
</View>
|
|
252
284
|
);
|
|
285
|
+
};
|
|
253
286
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
287
|
+
onPressItemSuggest = item => {
|
|
288
|
+
this.selectedItem = item;
|
|
289
|
+
// Loop hashRef to update value of child
|
|
290
|
+
Object.keys(this.hashmapRefs).forEach(key => {
|
|
291
|
+
if (
|
|
292
|
+
this.hashmapRefs[key].setText &&
|
|
293
|
+
typeof this.hashmapRefs[key].setText === 'function'
|
|
294
|
+
)
|
|
295
|
+
this.hashmapRefs[key].setText(
|
|
296
|
+
this.getValueByKey(key, this.selectedItem),
|
|
261
297
|
);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
});
|
|
298
|
+
if (
|
|
299
|
+
this.hashmapRefs[key].setValue &&
|
|
300
|
+
typeof this.hashmapRefs[key].setValue === 'function'
|
|
301
|
+
)
|
|
302
|
+
this.hashmapRefs[key].setValue(
|
|
303
|
+
this.getValueByKey(key, this.selectedItem),
|
|
304
|
+
);
|
|
305
|
+
});
|
|
271
306
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
307
|
+
const {onSelected} = this.props;
|
|
308
|
+
this.setState(
|
|
309
|
+
{
|
|
310
|
+
suggest: {},
|
|
311
|
+
},
|
|
312
|
+
() => {
|
|
313
|
+
if (onSelected && typeof onSelected === 'function') {
|
|
314
|
+
onSelected(item);
|
|
315
|
+
}
|
|
316
|
+
this.selectedItem = null;
|
|
317
|
+
},
|
|
318
|
+
);
|
|
319
|
+
};
|
|
284
320
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
321
|
+
isShowingSuggest = () => {
|
|
322
|
+
const {suggest} = this.state;
|
|
323
|
+
return suggest && suggest.data && suggest.data.length > 0;
|
|
324
|
+
};
|
|
289
325
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
326
|
+
hideSuggest = () => {
|
|
327
|
+
this.setState(
|
|
328
|
+
{
|
|
329
|
+
suggest: {},
|
|
330
|
+
},
|
|
331
|
+
() => {
|
|
332
|
+
this.selectedItem = null;
|
|
333
|
+
},
|
|
334
|
+
);
|
|
335
|
+
};
|
|
297
336
|
}
|
|
298
337
|
|
|
299
338
|
const styles = StyleSheet.create({
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
},
|
|
320
|
-
shadowRadius: 1,
|
|
321
|
-
elevation: 2,
|
|
322
|
-
shadowOpacity: 0.5,
|
|
323
|
-
},
|
|
324
|
-
separator: {
|
|
325
|
-
height: 1,
|
|
326
|
-
width: '100%',
|
|
327
|
-
backgroundColor: Colors.placeholder,
|
|
328
|
-
marginVertical: 10
|
|
329
|
-
}
|
|
339
|
+
viewSuggest: {
|
|
340
|
+
flexDirection: 'row',
|
|
341
|
+
justifyContent: 'space-between',
|
|
342
|
+
alignItems: 'center',
|
|
343
|
+
paddingVertical: 5,
|
|
344
|
+
},
|
|
345
|
+
containerSuggest: {
|
|
346
|
+
backgroundColor: 'white',
|
|
347
|
+
padding: Spacing.M,
|
|
348
|
+
position: 'absolute',
|
|
349
|
+
maxHeight: 240,
|
|
350
|
+
borderRadius: Radius.S,
|
|
351
|
+
},
|
|
352
|
+
separator: {
|
|
353
|
+
height: 1,
|
|
354
|
+
width: '100%',
|
|
355
|
+
backgroundColor: Colors.background_default,
|
|
356
|
+
marginVertical: 10,
|
|
357
|
+
},
|
|
330
358
|
});
|
|
331
359
|
|
|
332
360
|
AutoComplete.propTypes = {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
361
|
+
style: PropTypes.oneOfType([
|
|
362
|
+
PropTypes.array,
|
|
363
|
+
PropTypes.object,
|
|
364
|
+
PropTypes.number,
|
|
365
|
+
]),
|
|
366
|
+
data: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
367
|
+
renderSuggestItem: PropTypes.func,
|
|
368
|
+
onSelected: PropTypes.func.isRequired,
|
|
369
|
+
numSuggest: PropTypes.number,
|
|
338
370
|
};
|
|
339
371
|
|
|
340
372
|
AutoComplete.defaultProps = {
|
|
341
|
-
|
|
373
|
+
numSuggest: 2,
|
|
342
374
|
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
2
|
+
"name": "@momo-kits/auto-complete",
|
|
3
|
+
"version": "0.0.74-beta.30",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"react": "16.9.0",
|
|
9
|
+
"react-native": ">=0.55",
|
|
10
|
+
"@momo-kits/core": ">=0.0.4-beta",
|
|
11
|
+
"lodash": "^4.17.15",
|
|
12
|
+
"prop-types": "^15.7.2"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {},
|
|
15
|
+
"license": "MoMo"
|
|
16
|
+
}
|
package/publish.sh
CHANGED
|
@@ -21,9 +21,9 @@ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type
|
|
|
21
21
|
#npm login
|
|
22
22
|
#publish dist to npm
|
|
23
23
|
cd dist
|
|
24
|
-
npm publish --access=public
|
|
24
|
+
npm publish --tag beta --access=public
|
|
25
25
|
cd ..
|
|
26
26
|
rm -rf dist
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/auto-complete new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/auto-complete"}'
|
|
29
|
+
#curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/auto-complete new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/auto-complete"}'
|