secullum-react-native-ui 4.16.2-beta.0 → 4.16.2-beta.2
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,15 +1,14 @@
|
|
|
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
|
-
};
|
|
10
4
|
export interface DropDownProperties {
|
|
11
5
|
label?: string;
|
|
12
|
-
items:
|
|
6
|
+
items: Array<{
|
|
7
|
+
label: string;
|
|
8
|
+
value: any;
|
|
9
|
+
icon?: string;
|
|
10
|
+
nativeID?: string;
|
|
11
|
+
}>;
|
|
13
12
|
value: any | null;
|
|
14
13
|
onChange: (value: any) => void;
|
|
15
14
|
onPress?: () => void | boolean | Promise<void> | Promise<boolean>;
|
|
@@ -24,17 +23,11 @@ export interface DropDownProperties {
|
|
|
24
23
|
icon?: string | undefined;
|
|
25
24
|
arrowColor?: string | undefined;
|
|
26
25
|
searchable?: SearchableProps;
|
|
27
|
-
virtualized?: true | VirtualizedProps | null;
|
|
28
26
|
}
|
|
29
27
|
export interface SearchableProps {
|
|
30
28
|
placeHolder: string;
|
|
31
29
|
minItemsToSearch?: number;
|
|
32
30
|
}
|
|
33
|
-
export interface VirtualizedProps {
|
|
34
|
-
initialNumToRender?: number;
|
|
35
|
-
maxToRenderPerBatch?: number;
|
|
36
|
-
windowSize?: number;
|
|
37
|
-
}
|
|
38
31
|
export interface DropDownState {
|
|
39
32
|
modalOpen: boolean;
|
|
40
33
|
searchText: string;
|
|
@@ -42,11 +35,14 @@ export interface DropDownState {
|
|
|
42
35
|
export declare class DropDown extends React.Component<DropDownProperties, DropDownState> {
|
|
43
36
|
state: DropDownState;
|
|
44
37
|
handleItemPress: (value: any) => void;
|
|
45
|
-
filterItems: () =>
|
|
38
|
+
filterItems: () => {
|
|
39
|
+
label: string;
|
|
40
|
+
value: any;
|
|
41
|
+
icon?: string | undefined;
|
|
42
|
+
nativeID?: string | undefined;
|
|
43
|
+
}[];
|
|
46
44
|
shouldDisplaySearchField: () => boolean | undefined;
|
|
47
45
|
renderClosedDropDown: (item: any, inputStyle: any) => JSX.Element | null;
|
|
48
46
|
getStyles: () => any;
|
|
49
|
-
renderItemsList: (filteredItems: DropDownItemData[]) => JSX.Element;
|
|
50
47
|
render(): JSX.Element;
|
|
51
48
|
}
|
|
52
|
-
export {};
|
|
@@ -93,11 +93,6 @@ class DropDownItem extends React.PureComponent {
|
|
|
93
93
|
} }, this.renderOpenDropDownItem()));
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const DEFAULT_VIRTUALIZED = {
|
|
97
|
-
initialNumToRender: 20,
|
|
98
|
-
maxToRenderPerBatch: 30,
|
|
99
|
-
windowSize: 10
|
|
100
|
-
};
|
|
101
96
|
class DropDown extends React.Component {
|
|
102
97
|
constructor() {
|
|
103
98
|
super(...arguments);
|
|
@@ -292,20 +287,10 @@ class DropDown extends React.Component {
|
|
|
292
287
|
});
|
|
293
288
|
return styles;
|
|
294
289
|
};
|
|
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 = virtualized === true
|
|
302
|
-
? Object.assign({}, DEFAULT_VIRTUALIZED) : Object.assign(Object.assign({}, DEFAULT_VIRTUALIZED), virtualized);
|
|
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
|
-
};
|
|
305
290
|
}
|
|
306
291
|
render() {
|
|
307
292
|
const { modalOpen, searchText } = this.state;
|
|
308
|
-
const { label, items, value, emptyMessage, style, disabledStyle, disabled, labelStyle, inputStyle, nativeID, onPress, icon, searchable } = this.props;
|
|
293
|
+
const { label, items, value, emptyMessage, style, disabledStyle, disabled, labelStyle, inputStyle, iconComponent, nativeID, onPress, icon, searchable } = this.props;
|
|
309
294
|
const selectedItem = items.find(x => x.value === value);
|
|
310
295
|
const styles = this.getStyles();
|
|
311
296
|
const theme = (0, theme_1.getTheme)();
|
|
@@ -343,7 +328,9 @@ class DropDown extends React.Component {
|
|
|
343
328
|
React.createElement(react_native_1.View, { style: styles.inputWrapper },
|
|
344
329
|
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 }) }),
|
|
345
330
|
React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
|
|
346
|
-
filteredItems.length > 0 ? (
|
|
331
|
+
filteredItems.length > 0 ? (React.createElement(react_native_1.FlatList, { data: filteredItems, initialNumToRender: filteredItems.length, keyExtractor: item => item.value.toString(), renderItem: ({ item, index }) => {
|
|
332
|
+
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 }));
|
|
333
|
+
} })) : (React.createElement(react_native_1.View, { style: styles.emptyMessageContainer },
|
|
347
334
|
React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
|
|
348
335
|
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage)))))))));
|
|
349
336
|
}
|
|
@@ -22,6 +22,7 @@ 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>, nextState: Readonly<RangeDatePickerState>): boolean;
|
|
25
26
|
handleClick: (event: MouseEvent) => void;
|
|
26
27
|
handleDatePickerPress: () => void;
|
|
27
28
|
handleRangeDateConfirm: (ranges: SelectedRanges) => void;
|
|
@@ -85,6 +85,13 @@ class RangeDatePicker extends React.Component {
|
|
|
85
85
|
componentWillUnmount() {
|
|
86
86
|
document.removeEventListener('mousedown', this.handleClick, false);
|
|
87
87
|
}
|
|
88
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
89
|
+
console.log('teste2');
|
|
90
|
+
return (nextProps.startDate !== this.props.startDate ||
|
|
91
|
+
nextProps.endDate !== this.props.endDate ||
|
|
92
|
+
nextState.showStartDateModal !== this.state.showStartDateModal ||
|
|
93
|
+
nextState.count !== this.state.count);
|
|
94
|
+
}
|
|
88
95
|
render() {
|
|
89
96
|
const { label, startDate, endDate, style, nativeID } = this.props;
|
|
90
97
|
const { showStartDateModal } = this.state;
|