secullum-react-native-ui 4.15.1-beta.2 → 4.15.1-beta.4

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.
@@ -22,8 +22,11 @@ export interface DropDownProperties {
22
22
  nativeID?: string;
23
23
  icon?: string | undefined;
24
24
  arrowColor?: string | undefined;
25
- searchable?: boolean;
26
- minItemsToShowSearch: number;
25
+ searchable?: SearchableProps;
26
+ }
27
+ export interface SearchableProps {
28
+ placeHolder: string;
29
+ minItemsToSearch?: number;
27
30
  }
28
31
  export interface DropDownState {
29
32
  modalOpen: boolean;
@@ -32,7 +35,6 @@ export interface DropDownState {
32
35
  export declare class DropDown extends React.Component<DropDownProperties, DropDownState> {
33
36
  static defaultProps: {
34
37
  emptyMessage: string;
35
- minItemsToShowSearch: number;
36
38
  };
37
39
  state: DropDownState;
38
40
  handleItemPress: (value: any) => void;
@@ -111,8 +111,11 @@ class DropDown extends React.Component {
111
111
  return items.filter(item => item.label.toLowerCase().includes(searchText.toLowerCase()));
112
112
  };
113
113
  this.shouldDisplaySearchField = () => {
114
- const { items, searchable, minItemsToShowSearch } = this.props;
115
- return items.length >= minItemsToShowSearch && searchable;
114
+ var _a;
115
+ const { items, searchable } = this.props;
116
+ const defaultQuantityToSearch = 10;
117
+ return (searchable &&
118
+ items.length >= ((_a = searchable.minItemsToSearch) !== null && _a !== void 0 ? _a : defaultQuantityToSearch));
116
119
  };
117
120
  this.renderClosedDropDown = (item, inputStyle) => {
118
121
  const { iconComponent } = this.props;
@@ -151,8 +154,9 @@ class DropDown extends React.Component {
151
154
  return null;
152
155
  };
153
156
  this.getStyles = () => {
157
+ var _a;
154
158
  const theme = (0, theme_1.getTheme)();
155
- const { icon, arrowColor, minItemsToShowSearch } = this.props;
159
+ const { icon, arrowColor } = this.props;
156
160
  const styles = react_native_1.StyleSheet.create({
157
161
  container: Object.assign({ paddingHorizontal: 16, paddingVertical: 8, borderWidth: 1, borderColor: theme.borderColor1, borderRadius: 3 }, (icon
158
162
  ? {
@@ -196,10 +200,12 @@ class DropDown extends React.Component {
196
200
  right: 16
197
201
  },
198
202
  modalOverlay: {
199
- justifyContent: this.props.items.length >= minItemsToShowSearch &&
200
- this.props.searchable
203
+ justifyContent: this.shouldDisplaySearchField()
201
204
  ? 'flex-start'
202
- : 'center'
205
+ : 'center',
206
+ paddingTop: this.shouldDisplaySearchField()
207
+ ? (react_native_1.Platform.OS === 'ios' ? 44 : (_a = react_native_1.StatusBar.currentHeight) !== null && _a !== void 0 ? _a : 0)
208
+ : 0
203
209
  },
204
210
  modalContainer: {
205
211
  maxHeight: '95%',
@@ -292,8 +298,7 @@ class DropDown extends React.Component {
292
298
  const selectedItem = items.find(x => x.value === value);
293
299
  const styles = this.getStyles();
294
300
  const theme = (0, theme_1.getTheme)();
295
- const filteredItems = this.filterItems();
296
- const visibleItems = searchable ? filteredItems : items;
301
+ const filteredItems = searchable ? this.filterItems() : items;
297
302
  return (React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: () => __awaiter(this, void 0, void 0, function* () {
298
303
  if (onPress) {
299
304
  const result = yield onPress();
@@ -325,10 +330,10 @@ class DropDown extends React.Component {
325
330
  ] },
326
331
  this.shouldDisplaySearchField() && (React.createElement(react_native_1.View, { style: styles.searchContainer },
327
332
  React.createElement(react_native_1.View, { style: styles.inputWrapper },
328
- React.createElement(react_native_1.TextInput, { style: styles.searchInput, value: searchText, placeholder: "Buscar", onChangeText: text => this.setState({ searchText: text }) }),
333
+ React.createElement(react_native_1.TextInput, { style: styles.searchInput, value: searchText, placeholder: searchable === null || searchable === void 0 ? void 0 : searchable.placeHolder, onChangeText: text => this.setState({ searchText: text }) }),
329
334
  React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
330
- filteredItems.length > 0 ? (React.createElement(react_native_1.FlatList, { data: visibleItems, initialNumToRender: visibleItems.length, keyExtractor: item => item.value.toString(), renderItem: ({ item, index }) => {
331
- return (React.createElement(DropDownItem, { nativeID: item.nativeID, first: index === 0, last: index === visibleItems.length - 1, label: item.label, value: item.value, onPress: this.handleItemPress, icon: item.icon, iconComponent: iconComponent }));
335
+ filteredItems.length > 0 ? (React.createElement(react_native_1.FlatList, { data: filteredItems, initialNumToRender: filteredItems.length, keyExtractor: item => item.value.toString(), renderItem: ({ item, index }) => {
336
+ return (React.createElement(DropDownItem, { nativeID: item.nativeID, first: index === 0, last: index === filteredItems.length - 1, label: item.label, value: item.value, onPress: this.handleItemPress, icon: item.icon, iconComponent: iconComponent }));
332
337
  } })) : (React.createElement(react_native_1.View, { style: styles.emptyMessageContainer },
333
338
  React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
334
339
  React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage)))))))));
@@ -336,6 +341,5 @@ class DropDown extends React.Component {
336
341
  }
337
342
  exports.DropDown = DropDown;
338
343
  DropDown.defaultProps = {
339
- emptyMessage: 'Não há registros cadastrados',
340
- minItemsToShowSearch: 10
344
+ emptyMessage: 'Não há registros cadastrados'
341
345
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secullum-react-native-ui",
3
- "version": "4.15.1-beta.2",
3
+ "version": "4.15.1-beta.4",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [