secullum-react-native-ui 4.16.2 → 4.17.1
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,19 @@ export interface DropDownProperties {
|
|
|
23
24
|
icon?: string | undefined;
|
|
24
25
|
arrowColor?: string | undefined;
|
|
25
26
|
searchable?: SearchableProps;
|
|
27
|
+
virtualized?: true | VirtualizedProps;
|
|
28
|
+
useKeyboardAvoidingView?: boolean;
|
|
29
|
+
animation?: 'none' | 'fade' | 'slide';
|
|
26
30
|
}
|
|
27
31
|
export interface SearchableProps {
|
|
28
32
|
placeHolder: string;
|
|
29
33
|
minItemsToSearch?: number;
|
|
30
34
|
}
|
|
35
|
+
export interface VirtualizedProps {
|
|
36
|
+
initialNumToRender?: number;
|
|
37
|
+
maxToRenderPerBatch?: number;
|
|
38
|
+
windowSize?: number;
|
|
39
|
+
}
|
|
31
40
|
export interface DropDownState {
|
|
32
41
|
modalOpen: boolean;
|
|
33
42
|
searchText: string;
|
|
@@ -35,14 +44,11 @@ export interface DropDownState {
|
|
|
35
44
|
export declare class DropDown extends React.Component<DropDownProperties, DropDownState> {
|
|
36
45
|
state: DropDownState;
|
|
37
46
|
handleItemPress: (value: any) => void;
|
|
38
|
-
filterItems: () =>
|
|
39
|
-
label: string;
|
|
40
|
-
value: any;
|
|
41
|
-
icon?: string | undefined;
|
|
42
|
-
nativeID?: string | undefined;
|
|
43
|
-
}[];
|
|
47
|
+
filterItems: () => DropDownItemData[];
|
|
44
48
|
shouldDisplaySearchField: () => boolean | undefined;
|
|
45
49
|
renderClosedDropDown: (item: any, inputStyle: any) => JSX.Element | null;
|
|
46
50
|
getStyles: () => any;
|
|
51
|
+
renderItemsList: (filteredItems: DropDownItemData[]) => JSX.Element;
|
|
47
52
|
render(): JSX.Element;
|
|
48
53
|
}
|
|
54
|
+
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,14 +292,43 @@ 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, useKeyboardAvoidingView, animation } = 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)();
|
|
297
312
|
const filteredItems = searchable ? this.filterItems() : items;
|
|
313
|
+
const conteudoModal = (React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: react_native_1.Keyboard.dismiss },
|
|
314
|
+
React.createElement(react_native_1.View, { style: [
|
|
315
|
+
styles.modalContainer,
|
|
316
|
+
react_native_1.Platform.OS === 'web' && {
|
|
317
|
+
marginVertical: '10px',
|
|
318
|
+
marginHorizontal: 'auto',
|
|
319
|
+
width: '90%',
|
|
320
|
+
maxWidth: 450,
|
|
321
|
+
maxHeight: 300,
|
|
322
|
+
justifyContent: 'center'
|
|
323
|
+
}
|
|
324
|
+
] },
|
|
325
|
+
this.shouldDisplaySearchField() && (React.createElement(react_native_1.View, { style: styles.searchContainer },
|
|
326
|
+
React.createElement(react_native_1.View, { style: styles.inputWrapper },
|
|
327
|
+
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 }) }),
|
|
328
|
+
React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
|
|
329
|
+
filteredItems.length > 0 ? (this.renderItemsList(filteredItems)) : (React.createElement(react_native_1.View, { style: styles.emptyMessageContainer },
|
|
330
|
+
React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
|
|
331
|
+
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage))))));
|
|
298
332
|
return (React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: () => __awaiter(this, void 0, void 0, function* () {
|
|
299
333
|
if (onPress) {
|
|
300
334
|
const result = yield onPress();
|
|
@@ -311,28 +345,7 @@ class DropDown extends React.Component {
|
|
|
311
345
|
] },
|
|
312
346
|
icon ? (React.createElement(FontAwesome_1.default, { name: icon, style: styles.iconOnLine })) : (React.createElement(react_native_1.Text, { style: [styles.label, labelStyle] }, label)),
|
|
313
347
|
this.renderClosedDropDown(selectedItem, inputStyle),
|
|
314
|
-
React.createElement(Modal_1.Modal, { visible: modalOpen, onRequestClose: () => this.setState({ modalOpen: false }), overlayStyle: styles.modalOverlay },
|
|
315
|
-
React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: react_native_1.Keyboard.dismiss },
|
|
316
|
-
React.createElement(react_native_1.View, { style: [
|
|
317
|
-
styles.modalContainer,
|
|
318
|
-
react_native_1.Platform.OS === 'web' && {
|
|
319
|
-
marginVertical: '10px',
|
|
320
|
-
marginHorizontal: 'auto',
|
|
321
|
-
width: '90%',
|
|
322
|
-
maxWidth: 450,
|
|
323
|
-
maxHeight: 300,
|
|
324
|
-
justifyContent: 'center'
|
|
325
|
-
}
|
|
326
|
-
] },
|
|
327
|
-
this.shouldDisplaySearchField() && (React.createElement(react_native_1.View, { style: styles.searchContainer },
|
|
328
|
-
React.createElement(react_native_1.View, { style: styles.inputWrapper },
|
|
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 }) }),
|
|
330
|
-
React.createElement(FontAwesome_1.default, { name: "search", size: 16, color: "gray", style: styles.searchIcon })))),
|
|
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 },
|
|
334
|
-
React.createElement(FontAwesome_1.default, { name: "warning", color: theme.warningColor, size: 24 }),
|
|
335
|
-
React.createElement(react_native_1.Text, { style: styles.modalItem }, emptyMessage)))))))));
|
|
348
|
+
React.createElement(Modal_1.Modal, { visible: modalOpen, onRequestClose: () => this.setState({ modalOpen: false }), overlayStyle: styles.modalOverlay, animation: animation !== null && animation !== void 0 ? animation : 'fade' }, useKeyboardAvoidingView ? (React.createElement(react_native_1.KeyboardAvoidingView, { behavior: react_native_1.Platform.OS === 'ios' ? 'padding' : 'height' }, conteudoModal)) : (conteudoModal)))));
|
|
336
349
|
}
|
|
337
350
|
}
|
|
338
351
|
exports.DropDown = DropDown;
|
|
@@ -7,6 +7,7 @@ export interface MessageProperties {
|
|
|
7
7
|
onRequestClose?: () => void;
|
|
8
8
|
nativeID?: string;
|
|
9
9
|
textStyle?: StyleProp<TextStyle>;
|
|
10
|
+
animation?: 'none' | 'fade' | 'slide';
|
|
10
11
|
}
|
|
11
12
|
export declare class Message extends React.Component<MessageProperties> {
|
|
12
13
|
static defaultProps: {
|
|
@@ -37,10 +37,10 @@ class Message extends React.Component {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
render() {
|
|
40
|
-
const { message, visible, type, onRequestClose, nativeID, textStyle } = this.props;
|
|
40
|
+
const { message, visible, type, onRequestClose, nativeID, textStyle, animation } = this.props;
|
|
41
41
|
const styles = this.getStyles();
|
|
42
42
|
const theme = (0, theme_1.getTheme)();
|
|
43
|
-
return (React.createElement(Modal_1.Modal, { visible: visible, onRequestClose: onRequestClose, overlayStyle: styles.overlay },
|
|
43
|
+
return (React.createElement(Modal_1.Modal, { visible: visible, onRequestClose: onRequestClose, overlayStyle: styles.overlay, animation: animation !== null && animation !== void 0 ? animation : 'fade' },
|
|
44
44
|
React.createElement(react_native_1.View, { nativeID: nativeID, style: styles.container },
|
|
45
45
|
React.createElement(FontAwesome_1.default, { name: type === 'warning' ? 'warning' : 'check-circle', color: type === 'warning' ? theme.warningColor : theme.successColor, size: (0, layout_1.isTablet)() ? 52 : 42 }),
|
|
46
46
|
React.createElement(react_native_1.Text, { style: [styles.text, textStyle], testID: (0, test_1.getTestID)(nativeID) }, message))));
|
package/lib/components/Modal.js
CHANGED
|
@@ -19,9 +19,9 @@ class Modal extends React.Component {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
|
-
const { children, visible, overlayStyle, onRequestClose } = this.props;
|
|
22
|
+
const { children, visible, overlayStyle, onRequestClose, animation } = this.props;
|
|
23
23
|
const { isMounted } = this.state;
|
|
24
|
-
return (React.createElement(react_native_1.Modal, { animationType:
|
|
24
|
+
return (React.createElement(react_native_1.Modal, { animationType: animation !== null && animation !== void 0 ? animation : 'fade', transparent: true, visible: visible, supportedOrientations: ['landscape', 'portrait'], onRequestClose: onRequestClose, onShow: this.handleShow },
|
|
25
25
|
React.createElement(react_native_1.TouchableWithoutFeedback, { onPress: onRequestClose },
|
|
26
26
|
React.createElement(react_native_1.View, { style: [styles.overlay, overlayStyle] }, react_native_1.Platform.OS !== 'android' || isMounted ? children : React.createElement(react_native_1.View, null)))));
|
|
27
27
|
}
|