secullum-react-native-ui 4.16.2-beta.5 → 4.16.2-beta.7
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 | null;
|
|
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 = {
|
|
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 = 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
|
+
};
|
|
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)();
|
|
@@ -328,9 +343,7 @@ class DropDown extends React.Component {
|
|
|
328
343
|
React.createElement(react_native_1.View, { style: styles.inputWrapper },
|
|
329
344
|
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 }) }),
|
|
330
345
|
React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
|
|
331
|
-
filteredItems.length > 0 ? (React.createElement(react_native_1.
|
|
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 },
|
|
346
|
+
filteredItems.length > 0 ? (this.renderItemsList(filteredItems)) : (React.createElement(react_native_1.View, { style: styles.emptyMessageContainer },
|
|
334
347
|
React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
|
|
335
348
|
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage)))))))));
|
|
336
349
|
}
|
|
@@ -20,7 +20,7 @@ export interface RangeDatePickerState {
|
|
|
20
20
|
export declare class RangeDatePicker extends React.Component<RangeDatePickerProperties, RangeDatePickerState> {
|
|
21
21
|
state: RangeDatePickerState;
|
|
22
22
|
private calendarRef;
|
|
23
|
-
|
|
23
|
+
componentWillMount(): void;
|
|
24
24
|
componentWillUnmount(): void;
|
|
25
25
|
handleClick: (event: MouseEvent) => void;
|
|
26
26
|
handleDatePickerPress: () => void;
|
|
@@ -11,38 +11,6 @@ const layout_1 = require("../modules/layout");
|
|
|
11
11
|
require("react-date-range/dist/styles.css");
|
|
12
12
|
const react_native_1 = require("react-native");
|
|
13
13
|
require("../../styles/RangeDatePicker.css");
|
|
14
|
-
function compareDates(date1, date2) {
|
|
15
|
-
if (date1 instanceof Date && date2 instanceof Date) {
|
|
16
|
-
return date1.getTime() === date2.getTime();
|
|
17
|
-
}
|
|
18
|
-
return date1 === date2;
|
|
19
|
-
}
|
|
20
|
-
class PureDateRange extends React.Component {
|
|
21
|
-
// Without this check, every time the parent re-renders it would
|
|
22
|
-
// recreate the DateRange with the initial startDate value,
|
|
23
|
-
// even if the date hasn't actually changed.
|
|
24
|
-
// This causes the calendar to reset and the user loses the current
|
|
25
|
-
// selection while interacting.
|
|
26
|
-
// Related issue on GitLab 12293
|
|
27
|
-
shouldComponentUpdate(nextProps) {
|
|
28
|
-
if (nextProps.onChange !== this.props.onChange) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return (!compareDates(nextProps.startDate, this.props.startDate) ||
|
|
32
|
-
!compareDates(nextProps.endDate, this.props.endDate));
|
|
33
|
-
}
|
|
34
|
-
render() {
|
|
35
|
-
const { startDate, endDate, onChange } = this.props;
|
|
36
|
-
const theme = (0, theme_1.getTheme)();
|
|
37
|
-
return (React.createElement(react_date_range_1.DateRange, { locale: (0, format_1.getDateFnsLocale)(), showDateDisplay: false, ranges: [
|
|
38
|
-
{
|
|
39
|
-
startDate,
|
|
40
|
-
endDate,
|
|
41
|
-
key: 'selection'
|
|
42
|
-
}
|
|
43
|
-
], rangeColors: [theme.backgroundColor3], onChange: onChange, weekdayDisplayFormat: (0, format_1.getLocale)() === 'pt' ? 'EEEEEE' : 'E' }));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
14
|
class RangeDatePicker extends React.Component {
|
|
47
15
|
constructor() {
|
|
48
16
|
super(...arguments);
|
|
@@ -111,7 +79,7 @@ class RangeDatePicker extends React.Component {
|
|
|
111
79
|
return styles;
|
|
112
80
|
};
|
|
113
81
|
}
|
|
114
|
-
|
|
82
|
+
componentWillMount() {
|
|
115
83
|
document.addEventListener('mousedown', this.handleClick, false);
|
|
116
84
|
}
|
|
117
85
|
componentWillUnmount() {
|
|
@@ -140,7 +108,13 @@ class RangeDatePicker extends React.Component {
|
|
|
140
108
|
marginTop: '-150px',
|
|
141
109
|
fontFamily: theme.fontFamily1
|
|
142
110
|
} },
|
|
143
|
-
React.createElement(
|
|
111
|
+
React.createElement(react_date_range_1.DateRange, { locale: (0, format_1.getDateFnsLocale)(), showDateDisplay: false, ranges: [
|
|
112
|
+
{
|
|
113
|
+
startDate: startDate,
|
|
114
|
+
endDate: endDate,
|
|
115
|
+
key: 'selection'
|
|
116
|
+
}
|
|
117
|
+
], rangeColors: [theme.backgroundColor3], onChange: this.handleRangeDateConfirm, weekdayDisplayFormat: (0, format_1.getLocale)() === 'pt' ? 'EEEEEE' : 'E' }))))));
|
|
144
118
|
}
|
|
145
119
|
}
|
|
146
120
|
exports.RangeDatePicker = RangeDatePicker;
|