secullum-react-native-ui 4.16.2-beta.1 → 4.16.2-beta.12
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,14 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IconProps } from 'react-native-vector-icons/Icon';
|
|
3
3
|
import { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
4
|
+
declare type DropDownItemData = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: any;
|
|
7
|
+
icon?: string;
|
|
8
|
+
nativeID?: string;
|
|
9
|
+
};
|
|
4
10
|
export interface DropDownProperties {
|
|
5
11
|
label?: string;
|
|
6
|
-
items:
|
|
7
|
-
label: string;
|
|
8
|
-
value: any;
|
|
9
|
-
icon?: string;
|
|
10
|
-
nativeID?: string;
|
|
11
|
-
}>;
|
|
12
|
+
items: DropDownItemData[];
|
|
12
13
|
value: any | null;
|
|
13
14
|
onChange: (value: any) => void;
|
|
14
15
|
onPress?: () => void | boolean | Promise<void> | Promise<boolean>;
|
|
@@ -23,11 +24,17 @@ export interface DropDownProperties {
|
|
|
23
24
|
icon?: string | undefined;
|
|
24
25
|
arrowColor?: string | undefined;
|
|
25
26
|
searchable?: SearchableProps;
|
|
27
|
+
virtualized?: true | VirtualizedProps;
|
|
26
28
|
}
|
|
27
29
|
export interface SearchableProps {
|
|
28
30
|
placeHolder: string;
|
|
29
31
|
minItemsToSearch?: number;
|
|
30
32
|
}
|
|
33
|
+
export interface VirtualizedProps {
|
|
34
|
+
initialNumToRender?: number;
|
|
35
|
+
maxToRenderPerBatch?: number;
|
|
36
|
+
windowSize?: number;
|
|
37
|
+
}
|
|
31
38
|
export interface DropDownState {
|
|
32
39
|
modalOpen: boolean;
|
|
33
40
|
searchText: string;
|
|
@@ -35,14 +42,11 @@ export interface DropDownState {
|
|
|
35
42
|
export declare class DropDown extends React.Component<DropDownProperties, DropDownState> {
|
|
36
43
|
state: DropDownState;
|
|
37
44
|
handleItemPress: (value: any) => void;
|
|
38
|
-
filterItems: () =>
|
|
39
|
-
label: string;
|
|
40
|
-
value: any;
|
|
41
|
-
icon?: string | undefined;
|
|
42
|
-
nativeID?: string | undefined;
|
|
43
|
-
}[];
|
|
45
|
+
filterItems: () => DropDownItemData[];
|
|
44
46
|
shouldDisplaySearchField: () => boolean | undefined;
|
|
45
47
|
renderClosedDropDown: (item: any, inputStyle: any) => JSX.Element | null;
|
|
46
48
|
getStyles: () => any;
|
|
49
|
+
renderItemsList: (filteredItems: DropDownItemData[]) => JSX.Element;
|
|
47
50
|
render(): JSX.Element;
|
|
48
51
|
}
|
|
52
|
+
export {};
|
|
@@ -93,6 +93,11 @@ class DropDownItem extends React.PureComponent {
|
|
|
93
93
|
} }, this.renderOpenDropDownItem()));
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
const DEFAULT_VIRTUALIZED_PROPS = {
|
|
97
|
+
initialNumToRender: 20,
|
|
98
|
+
maxToRenderPerBatch: 30,
|
|
99
|
+
windowSize: 10
|
|
100
|
+
};
|
|
96
101
|
class DropDown extends React.Component {
|
|
97
102
|
constructor() {
|
|
98
103
|
super(...arguments);
|
|
@@ -287,10 +292,20 @@ class DropDown extends React.Component {
|
|
|
287
292
|
});
|
|
288
293
|
return styles;
|
|
289
294
|
};
|
|
295
|
+
this.renderItemsList = (filteredItems) => {
|
|
296
|
+
const { iconComponent, virtualized } = this.props;
|
|
297
|
+
const renderItem = ({ item, index }) => (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 }));
|
|
298
|
+
if (virtualized == null) {
|
|
299
|
+
return (React.createElement(react_native_1.FlatList, { data: filteredItems, initialNumToRender: filteredItems.length, keyExtractor: item => item.value.toString(), renderItem: renderItem }));
|
|
300
|
+
}
|
|
301
|
+
const virtualizedProps = typeof virtualized === 'object'
|
|
302
|
+
? Object.assign(Object.assign({}, DEFAULT_VIRTUALIZED_PROPS), virtualized) : DEFAULT_VIRTUALIZED_PROPS;
|
|
303
|
+
return (React.createElement(react_native_1.VirtualizedList, { getItem: (_, index) => filteredItems[index], getItemCount: () => filteredItems.length, keyExtractor: item => item.value.toString(), renderItem: renderItem, initialNumToRender: virtualizedProps.initialNumToRender, maxToRenderPerBatch: virtualizedProps.maxToRenderPerBatch, windowSize: virtualizedProps.windowSize }));
|
|
304
|
+
};
|
|
290
305
|
}
|
|
291
306
|
render() {
|
|
292
307
|
const { modalOpen, searchText } = this.state;
|
|
293
|
-
const { label, items, value, emptyMessage, style, disabledStyle, disabled, labelStyle, inputStyle,
|
|
308
|
+
const { label, items, value, emptyMessage, style, disabledStyle, disabled, labelStyle, inputStyle, nativeID, onPress, icon, searchable } = this.props;
|
|
294
309
|
const selectedItem = items.find(x => x.value === value);
|
|
295
310
|
const styles = this.getStyles();
|
|
296
311
|
const theme = (0, theme_1.getTheme)();
|
|
@@ -312,27 +327,26 @@ class DropDown extends React.Component {
|
|
|
312
327
|
icon ? (React.createElement(FontAwesome_1.default, { name: icon, style: styles.iconOnLine })) : (React.createElement(react_native_1.Text, { style: [styles.label, labelStyle] }, label)),
|
|
313
328
|
this.renderClosedDropDown(selectedItem, inputStyle),
|
|
314
329
|
React.createElement(Modal_1.Modal, { visible: modalOpen, onRequestClose: () => this.setState({ modalOpen: false }), overlayStyle: styles.modalOverlay },
|
|
315
|
-
React.createElement(react_native_1.
|
|
316
|
-
React.createElement(react_native_1.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
React.createElement(react_native_1.View, { style: styles.
|
|
329
|
-
React.createElement(react_native_1.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage)))))))));
|
|
330
|
+
React.createElement(react_native_1.KeyboardAvoidingView, { behavior: react_native_1.Platform.OS === 'ios' ? 'padding' : 'height' },
|
|
331
|
+
React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: react_native_1.Keyboard.dismiss },
|
|
332
|
+
React.createElement(react_native_1.View, { style: [
|
|
333
|
+
styles.modalContainer,
|
|
334
|
+
react_native_1.Platform.OS === 'web' && {
|
|
335
|
+
marginVertical: '10px',
|
|
336
|
+
marginHorizontal: 'auto',
|
|
337
|
+
width: '90%',
|
|
338
|
+
maxWidth: 450,
|
|
339
|
+
maxHeight: 300,
|
|
340
|
+
justifyContent: 'center'
|
|
341
|
+
}
|
|
342
|
+
] },
|
|
343
|
+
this.shouldDisplaySearchField() && (React.createElement(react_native_1.View, { style: styles.searchContainer },
|
|
344
|
+
React.createElement(react_native_1.View, { style: styles.inputWrapper },
|
|
345
|
+
React.createElement(react_native_1.TextInput, { nativeID: nativeID + '-text-search', style: styles.searchInput, value: searchText, placeholder: searchable && searchable.placeHolder, onChangeText: text => this.setState({ searchText: text }) }),
|
|
346
|
+
React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
|
|
347
|
+
filteredItems.length > 0 ? (this.renderItemsList(filteredItems)) : (React.createElement(react_native_1.View, { style: styles.emptyMessageContainer },
|
|
348
|
+
React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
|
|
349
|
+
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage))))))))));
|
|
336
350
|
}
|
|
337
351
|
}
|
|
338
352
|
exports.DropDown = DropDown;
|
|
@@ -22,7 +22,6 @@ export declare class RangeDatePicker extends React.Component<RangeDatePickerProp
|
|
|
22
22
|
private calendarRef;
|
|
23
23
|
componentWillMount(): void;
|
|
24
24
|
componentWillUnmount(): void;
|
|
25
|
-
shouldComponentUpdate(nextProps: Readonly<RangeDatePickerProperties>): boolean;
|
|
26
25
|
handleClick: (event: MouseEvent) => void;
|
|
27
26
|
handleDatePickerPress: () => void;
|
|
28
27
|
handleRangeDateConfirm: (ranges: SelectedRanges) => void;
|
|
@@ -85,11 +85,6 @@ class RangeDatePicker extends React.Component {
|
|
|
85
85
|
componentWillUnmount() {
|
|
86
86
|
document.removeEventListener('mousedown', this.handleClick, false);
|
|
87
87
|
}
|
|
88
|
-
shouldComponentUpdate(nextProps) {
|
|
89
|
-
console.log('teste');
|
|
90
|
-
return (nextProps.startDate !== this.props.startDate ||
|
|
91
|
-
nextProps.endDate !== this.props.endDate);
|
|
92
|
-
}
|
|
93
88
|
render() {
|
|
94
89
|
const { label, startDate, endDate, style, nativeID } = this.props;
|
|
95
90
|
const { showStartDateModal } = this.state;
|