secullum-react-native-ui 4.16.2-beta.9 → 4.17.0

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.
Files changed (97) hide show
  1. package/lib/components/AppShell.d.ts +52 -0
  2. package/lib/components/AppShell.js +82 -0
  3. package/lib/components/Button.d.ts +49 -0
  4. package/lib/components/Button.js +70 -0
  5. package/lib/components/Card.d.ts +66 -0
  6. package/lib/components/Card.js +131 -0
  7. package/lib/components/CheckBox.d.ts +36 -0
  8. package/lib/components/CheckBox.js +50 -0
  9. package/lib/components/DatePicker.d.ts +67 -0
  10. package/lib/components/DatePicker.js +106 -0
  11. package/lib/components/DatePicker.web.d.ts +64 -0
  12. package/lib/components/DatePicker.web.js +106 -0
  13. package/lib/components/Delay.d.ts +12 -0
  14. package/lib/components/Delay.js +22 -0
  15. package/lib/components/Details.d.ts +67 -0
  16. package/lib/components/Details.js +96 -0
  17. package/lib/components/DetailsHeader.d.ts +41 -0
  18. package/lib/components/DetailsHeader.js +65 -0
  19. package/lib/components/DimensionsMonitor.d.ts +21 -0
  20. package/lib/components/DimensionsMonitor.js +37 -0
  21. package/lib/components/DropDown.d.ts +53 -0
  22. package/lib/components/DropDown.js +351 -0
  23. package/lib/components/ErrorMessage.d.ts +16 -0
  24. package/lib/components/ErrorMessage.js +31 -0
  25. package/lib/components/FilePicker.d.ts +29 -0
  26. package/lib/components/FilePicker.js +46 -0
  27. package/lib/components/Header.d.ts +58 -0
  28. package/lib/components/Header.js +94 -0
  29. package/lib/components/HeaderDesktop.d.ts +59 -0
  30. package/lib/components/HeaderDesktop.js +83 -0
  31. package/lib/components/ImageButton.d.ts +14 -0
  32. package/lib/components/ImageButton.js +34 -0
  33. package/lib/components/KeyboardAvoidingView.d.ts +34 -0
  34. package/lib/components/KeyboardAvoidingView.js +106 -0
  35. package/lib/components/Link.d.ts +18 -0
  36. package/lib/components/Link.js +30 -0
  37. package/lib/components/Loading.d.ts +13 -0
  38. package/lib/components/Loading.js +45 -0
  39. package/lib/components/Menu.d.ts +42 -0
  40. package/lib/components/Menu.js +114 -0
  41. package/lib/components/MenuDesktop.d.ts +24 -0
  42. package/lib/components/MenuDesktop.js +39 -0
  43. package/lib/components/MenuMobile.d.ts +49 -0
  44. package/lib/components/MenuMobile.js +94 -0
  45. package/lib/components/Message.d.ts +37 -0
  46. package/lib/components/Message.js +52 -0
  47. package/lib/components/Modal.d.ts +18 -0
  48. package/lib/components/Modal.js +35 -0
  49. package/lib/components/MultiSelect.d.ts +51 -0
  50. package/lib/components/MultiSelect.js +377 -0
  51. package/lib/components/NoRecordMessage.d.ts +23 -0
  52. package/lib/components/NoRecordMessage.js +36 -0
  53. package/lib/components/Question.d.ts +57 -0
  54. package/lib/components/Question.js +79 -0
  55. package/lib/components/RadioButton.d.ts +43 -0
  56. package/lib/components/RadioButton.js +55 -0
  57. package/lib/components/RadioGroup.d.ts +45 -0
  58. package/lib/components/RadioGroup.js +71 -0
  59. package/lib/components/RangeDatePicker.d.ts +57 -0
  60. package/lib/components/RangeDatePicker.js +127 -0
  61. package/lib/components/RangeDatePicker.web.d.ts +61 -0
  62. package/lib/components/RangeDatePicker.web.js +146 -0
  63. package/lib/components/Space.d.ts +11 -0
  64. package/lib/components/Space.js +15 -0
  65. package/lib/components/StatusBar.d.ts +18 -0
  66. package/lib/components/StatusBar.js +33 -0
  67. package/lib/components/Switch.d.ts +34 -0
  68. package/lib/components/Switch.js +50 -0
  69. package/lib/components/Table.d.ts +30 -0
  70. package/lib/components/Table.js +79 -0
  71. package/lib/components/Table.web.d.ts +18 -0
  72. package/lib/components/Table.web.js +111 -0
  73. package/lib/components/Text.d.ts +29 -0
  74. package/lib/components/Text.js +38 -0
  75. package/lib/components/TextBox.d.ts +84 -0
  76. package/lib/components/TextBox.js +126 -0
  77. package/lib/components/TextBoxMask.d.ts +12 -0
  78. package/lib/components/TextBoxMask.js +34 -0
  79. package/lib/components/TimePicker.d.ts +63 -0
  80. package/lib/components/TimePicker.js +112 -0
  81. package/lib/components/TimePicker.web.d.ts +48 -0
  82. package/lib/components/TimePicker.web.js +88 -0
  83. package/lib/index.d.ts +40 -0
  84. package/lib/index.js +56 -0
  85. package/lib/modules/browser.d.ts +2 -0
  86. package/lib/modules/browser.js +51 -0
  87. package/lib/modules/format.d.ts +6 -0
  88. package/lib/modules/format.js +127 -0
  89. package/lib/modules/layout.d.ts +1 -0
  90. package/lib/modules/layout.js +12 -0
  91. package/lib/modules/test.d.ts +2 -0
  92. package/lib/modules/test.js +18 -0
  93. package/lib/modules/theme.d.ts +41 -0
  94. package/lib/modules/theme.js +52 -0
  95. package/lib/modules/validation.d.ts +3 -0
  96. package/lib/modules/validation.js +16 -0
  97. package/package.json +1 -1
@@ -0,0 +1,59 @@
1
+ import * as React from 'react';
2
+ import { HeaderButton } from '../components/Header';
3
+ import { StyleProp, TextStyle } from 'react-native';
4
+ export interface GreetingMessage {
5
+ message: string;
6
+ style?: StyleProp<TextStyle>;
7
+ }
8
+ export interface HeaderDesktopProperties {
9
+ logo: () => React.ReactNode;
10
+ title?: string;
11
+ greeting?: GreetingMessage;
12
+ rightButton?: HeaderButton;
13
+ headerStyle?: StyleProp<TextStyle>;
14
+ }
15
+ export declare class HeaderDesktop extends React.Component<HeaderDesktopProperties> {
16
+ static height: number;
17
+ getStyles: () => {
18
+ container: {
19
+ backgroundColor: string;
20
+ height: number;
21
+ flexDirection: "row";
22
+ alignItems: "center";
23
+ shadowOpacity: number;
24
+ shadowRadius: number;
25
+ shadowColor: string;
26
+ };
27
+ title: {
28
+ color: string;
29
+ fontSize: number;
30
+ fontFamily: string;
31
+ };
32
+ greeting: {
33
+ color: string;
34
+ fontSize: number;
35
+ fontFamily: string;
36
+ marginLeft: string;
37
+ marginRight: number;
38
+ };
39
+ button: {
40
+ padding: number;
41
+ };
42
+ counterContainer: {
43
+ position: "absolute";
44
+ backgroundColor: string;
45
+ height: number;
46
+ width: number;
47
+ top: number;
48
+ left: number;
49
+ borderRadius: number;
50
+ };
51
+ counterText: {
52
+ textAlign: "center";
53
+ color: string;
54
+ fontSize: number;
55
+ };
56
+ };
57
+ renderRightButton: (button: HeaderButton) => JSX.Element;
58
+ render(): JSX.Element;
59
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeaderDesktop = void 0;
4
+ const React = require("react");
5
+ const theme_1 = require("../modules/theme");
6
+ const FontAwesome_1 = require("react-native-vector-icons/FontAwesome");
7
+ const react_native_1 = require("react-native");
8
+ const layout_1 = require("../modules/layout");
9
+ class HeaderDesktop extends React.Component {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.getStyles = () => {
13
+ const theme = (0, theme_1.getTheme)();
14
+ const styles = react_native_1.StyleSheet.create({
15
+ container: {
16
+ backgroundColor: theme.backgroundColor3,
17
+ height: HeaderDesktop.height,
18
+ flexDirection: 'row',
19
+ alignItems: 'center',
20
+ shadowOpacity: 0.6,
21
+ shadowRadius: 20,
22
+ shadowColor: theme.shadowColor1
23
+ },
24
+ title: {
25
+ color: theme.textColor4,
26
+ fontSize: 24,
27
+ fontFamily: theme.fontFamily3
28
+ },
29
+ greeting: {
30
+ color: theme.textColor4,
31
+ fontSize: 18,
32
+ fontFamily: theme.fontFamily2,
33
+ marginLeft: 'auto',
34
+ marginRight: 20
35
+ },
36
+ button: {
37
+ padding: (0, layout_1.isTablet)() ? 14 : 10
38
+ },
39
+ counterContainer: {
40
+ position: 'absolute',
41
+ backgroundColor: theme.counterBackgroundColor,
42
+ height: (0, layout_1.isTablet)() ? 20 : 15,
43
+ width: (0, layout_1.isTablet)() ? 20 : 15,
44
+ top: 5,
45
+ left: 18,
46
+ borderRadius: 50
47
+ },
48
+ counterText: {
49
+ textAlign: 'center',
50
+ color: theme.counterTextColor,
51
+ fontSize: (0, layout_1.isTablet)() ? 15 : 10
52
+ }
53
+ });
54
+ return styles;
55
+ };
56
+ this.renderRightButton = (button) => {
57
+ const styles = this.getStyles();
58
+ const theme = (0, theme_1.getTheme)();
59
+ const icon = (React.createElement(React.Fragment, null,
60
+ React.createElement(FontAwesome_1.default, { nativeID: button.nativeID, name: button.icon, size: (0, layout_1.isTablet)() ? 30 : 20, color: button.disabled ? theme.textColor1 : theme.textColor4,
61
+ // @ts-ignore : The component uses a different version of typing
62
+ style: button.buttonStyle }),
63
+ button.counter ? (React.createElement(react_native_1.View, { style: styles.counterContainer },
64
+ React.createElement(react_native_1.Text, { nativeID: `${button.nativeID}-counter`, style: styles.counterText }, button.counter))) : null));
65
+ const style = [styles.button];
66
+ if (button.disabled) {
67
+ return React.createElement(react_native_1.View, { style: style }, icon);
68
+ }
69
+ return (React.createElement(react_native_1.TouchableOpacity, { onPress: button.onPress, style: style }, icon));
70
+ };
71
+ }
72
+ render() {
73
+ const { logo, title, greeting, rightButton, headerStyle } = this.props;
74
+ const styles = this.getStyles();
75
+ return (React.createElement(react_native_1.View, { style: [styles.container, headerStyle] },
76
+ logo(),
77
+ title && React.createElement(react_native_1.Text, { style: styles.title }, title),
78
+ greeting && (React.createElement(react_native_1.Text, { nativeID: "app-greeting-message", style: [styles.greeting, greeting.style] }, greeting.message)),
79
+ rightButton && this.renderRightButton(rightButton)));
80
+ }
81
+ }
82
+ exports.HeaderDesktop = HeaderDesktop;
83
+ HeaderDesktop.height = 60;
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { StyleProp, ViewStyle } from 'react-native';
3
+ export interface ImageButtonProperties {
4
+ icon: string;
5
+ style?: StyleProp<ViewStyle>;
6
+ iconColor?: string;
7
+ onPress: () => void;
8
+ iconSize?: number;
9
+ hitBoxSize?: number;
10
+ nativeID?: string;
11
+ }
12
+ export declare class ImageButton extends React.Component<ImageButtonProperties> {
13
+ render(): JSX.Element;
14
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageButton = void 0;
4
+ const React = require("react");
5
+ const FontAwesome_1 = require("react-native-vector-icons/FontAwesome");
6
+ const theme_1 = require("../modules/theme");
7
+ const test_1 = require("../modules/test");
8
+ const react_native_1 = require("react-native");
9
+ class ImageButton extends React.Component {
10
+ render() {
11
+ const { icon, style, iconColor, onPress, iconSize, hitBoxSize, nativeID } = this.props;
12
+ return (React.createElement(react_native_1.TouchableOpacity, { onPress: onPress, activeOpacity: 0.5, style: [styles.container, style], hitSlop: hitBoxSize
13
+ ? {
14
+ top: hitBoxSize,
15
+ bottom: hitBoxSize,
16
+ left: hitBoxSize,
17
+ right: hitBoxSize
18
+ }
19
+ : undefined },
20
+ React.createElement(FontAwesome_1.default, { nativeID: nativeID, testID: (0, test_1.getTestID)(nativeID), name: icon, size: iconSize || 20, color: iconColor || theme.textColor1 })));
21
+ }
22
+ }
23
+ exports.ImageButton = ImageButton;
24
+ const theme = (0, theme_1.getTheme)();
25
+ const styles = react_native_1.StyleSheet.create({
26
+ container: {
27
+ borderWidth: 1,
28
+ borderColor: theme.borderColor1,
29
+ alignItems: 'center',
30
+ justifyContent: 'center',
31
+ width: 40,
32
+ height: 40
33
+ }
34
+ });
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import { EmitterSubscription, KeyboardEvent, NativeScrollEvent, RefreshControlProps, ScrollView } from 'react-native';
3
+ export interface KeyboardAvoidingViewProperties {
4
+ extraFieldHeight: number;
5
+ extraWindowHeight: number;
6
+ refreshControl?: React.ReactElement<RefreshControlProps> | undefined;
7
+ children: (options: {
8
+ availableHeight: number;
9
+ }) => JSX.Element;
10
+ scrollEnabled?: boolean;
11
+ onScroll?: (event: NativeScrollEvent) => void;
12
+ keyBoardShow?: boolean;
13
+ }
14
+ export interface KeyboardAvoidingViewState {
15
+ keyboardHeight: number;
16
+ }
17
+ export declare class KeyboardAvoidingView extends React.Component<KeyboardAvoidingViewProperties, KeyboardAvoidingViewState> {
18
+ static defaultProps: {
19
+ extraFieldHeight: number;
20
+ extraWindowHeight: number;
21
+ scrollEnabled: boolean;
22
+ };
23
+ keyboardDidShowSubscription?: EmitterSubscription;
24
+ keyboardDidHideSubscription?: EmitterSubscription;
25
+ scrollViewRef: React.RefObject<ScrollView>;
26
+ state: KeyboardAvoidingViewState;
27
+ componentDidMount(): void;
28
+ componentWillUnmount(): void;
29
+ handleKeyboardShow: (event: KeyboardEvent) => void;
30
+ handleKeyboardHide: () => void;
31
+ scrollTo: (x: number, y: number) => void;
32
+ scrollToEnd: () => void;
33
+ render(): JSX.Element;
34
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KeyboardAvoidingView = void 0;
4
+ const React = require("react");
5
+ const react_native_1 = require("react-native");
6
+ class KeyboardAvoidingView extends React.Component {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.scrollViewRef = React.createRef();
10
+ this.state = {
11
+ keyboardHeight: 0
12
+ };
13
+ this.handleKeyboardShow = (event) => {
14
+ const keyboardHeight = event.endCoordinates.height;
15
+ const keyboardPosition = event.endCoordinates.screenY;
16
+ this.setState({
17
+ keyboardHeight
18
+ });
19
+ const scrollView = this.scrollViewRef.current;
20
+ if (!scrollView) {
21
+ return;
22
+ }
23
+ //@ts-ignore
24
+ const currentlyFocusedInput = react_native_1.TextInput.State.currentlyFocusedInput();
25
+ if (!currentlyFocusedInput) {
26
+ return;
27
+ }
28
+ const { extraFieldHeight, extraWindowHeight } = this.props;
29
+ const currentlyFocusedInputNode = (0, react_native_1.findNodeHandle)(currentlyFocusedInput);
30
+ // @ts-ignore: no types :(
31
+ react_native_1.UIManager.viewIsDescendantOf(currentlyFocusedInputNode, (0, react_native_1.findNodeHandle)(scrollView), (isDescendant) => {
32
+ if (!isDescendant) {
33
+ return;
34
+ }
35
+ currentlyFocusedInput.measure((x, y, width, height, pageX, pageY) => {
36
+ const fieldPosition = pageY + height + extraFieldHeight;
37
+ if (fieldPosition <= keyboardPosition) {
38
+ return;
39
+ }
40
+ scrollView.scrollResponderScrollNativeHandleToKeyboard(currentlyFocusedInputNode, extraWindowHeight + extraFieldHeight, true);
41
+ });
42
+ });
43
+ };
44
+ this.handleKeyboardHide = () => {
45
+ this.setState({
46
+ keyboardHeight: 0
47
+ });
48
+ };
49
+ this.scrollTo = (x, y) => {
50
+ if (!this.scrollViewRef.current) {
51
+ return;
52
+ }
53
+ this.scrollViewRef.current.scrollTo({ x, y });
54
+ };
55
+ this.scrollToEnd = () => {
56
+ if (!this.scrollViewRef.current) {
57
+ return;
58
+ }
59
+ this.scrollViewRef.current.scrollToEnd();
60
+ };
61
+ }
62
+ componentDidMount() {
63
+ // Android doesn't have 'will' events, but we can use 'did' there without any problem
64
+ // iOS on the other hand needs to use the 'will' events otherwise the screen would show some empty spaces during keyboard events
65
+ this.keyboardDidShowSubscription = react_native_1.Keyboard.addListener(react_native_1.Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow', this.handleKeyboardShow);
66
+ this.keyboardDidHideSubscription = react_native_1.Keyboard.addListener(react_native_1.Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide', this.handleKeyboardHide);
67
+ }
68
+ componentWillUnmount() {
69
+ this.keyboardDidShowSubscription.remove();
70
+ this.keyboardDidHideSubscription.remove();
71
+ }
72
+ render() {
73
+ const { refreshControl, scrollEnabled, onScroll, children, keyBoardShow, extraWindowHeight } = this.props;
74
+ const { keyboardHeight } = this.state;
75
+ // Android devices with notch will report less `availableHeight` than it should
76
+ // That's because of this: https://github.com/facebook/react-native/issues/23693
77
+ // If I change it to 'screen', Android devices with virtual buttons will report more than it should
78
+ const availableHeight = react_native_1.Dimensions.get('window').height - keyboardHeight - extraWindowHeight;
79
+ return (React.createElement(react_native_1.View, { style: [{ height: availableHeight }, !keyBoardShow && { flex: 1 }] },
80
+ React.createElement(react_native_1.ScrollView
81
+ // On Android 15 (API 35) devices, when the keyboard appears,
82
+ // the ScrollView does not resize correctly and may hide focused input fields.
83
+ // Related issue on GitLab: 11635
84
+ , {
85
+ // On Android 15 (API 35) devices, when the keyboard appears,
86
+ // the ScrollView does not resize correctly and may hide focused input fields.
87
+ // Related issue on GitLab: 11635
88
+ contentContainerStyle: react_native_1.Platform.OS === 'android' &&
89
+ react_native_1.Platform.Version === 35 &&
90
+ keyboardHeight > 0
91
+ ? { paddingBottom: keyboardHeight }
92
+ : undefined, ref: this.scrollViewRef,
93
+ // @ts-ignore: O react-native não tem auto, mas o react-native-web aceita
94
+ refreshControl: refreshControl, scrollEnabled: scrollEnabled, onScroll: (e) => {
95
+ if (onScroll) {
96
+ onScroll(e.nativeEvent);
97
+ }
98
+ }, scrollEventThrottle: 16 }, children({ availableHeight }))));
99
+ }
100
+ }
101
+ exports.KeyboardAvoidingView = KeyboardAvoidingView;
102
+ KeyboardAvoidingView.defaultProps = {
103
+ extraFieldHeight: 0,
104
+ extraWindowHeight: 0,
105
+ scrollEnabled: true
106
+ };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { StyleProp, TextStyle } from 'react-native';
3
+ export interface LinkProperties {
4
+ text: string;
5
+ style?: StyleProp<TextStyle>;
6
+ onPress: () => void;
7
+ nativeID?: string;
8
+ }
9
+ export declare class Link extends React.Component<LinkProperties> {
10
+ getStyles: () => {
11
+ link: {
12
+ fontFamily: string;
13
+ fontSize: number;
14
+ color: string;
15
+ };
16
+ };
17
+ render(): JSX.Element;
18
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Link = void 0;
4
+ const React = require("react");
5
+ const theme_1 = require("../modules/theme");
6
+ const react_native_1 = require("react-native");
7
+ const test_1 = require("../modules/test");
8
+ class Link extends React.Component {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.getStyles = () => {
12
+ const theme = (0, theme_1.getTheme)();
13
+ const styles = react_native_1.StyleSheet.create({
14
+ link: {
15
+ fontFamily: theme.fontFamily2,
16
+ fontSize: 14,
17
+ color: theme.textColor2
18
+ }
19
+ });
20
+ return styles;
21
+ };
22
+ }
23
+ render() {
24
+ const { text, style, onPress, nativeID } = this.props;
25
+ const styles = this.getStyles();
26
+ return (React.createElement(react_native_1.TouchableOpacity, { activeOpacity: 0.7, onPress: onPress, testID: (0, test_1.getTestID)(nativeID) },
27
+ React.createElement(react_native_1.Text, { nativeID: nativeID, style: [styles.link, style] }, text)));
28
+ }
29
+ }
30
+ exports.Link = Link;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ declare type Props = {
3
+ width?: number | string;
4
+ height?: number | string;
5
+ };
6
+ export declare class Loading extends React.Component<Props> {
7
+ getWidthAndHeight: () => {
8
+ width: string | number;
9
+ height: string | number;
10
+ };
11
+ render(): JSX.Element;
12
+ }
13
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Loading = void 0;
4
+ const React = require("react");
5
+ const react_native_1 = require("react-native");
6
+ class Loading extends React.Component {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.getWidthAndHeight = () => {
10
+ const dim = react_native_1.Platform.OS === 'web' ? 'window' : 'screen';
11
+ const { width, height } = this.props;
12
+ return {
13
+ width: width ? width : react_native_1.Dimensions.get(dim).width,
14
+ height: height ? height : react_native_1.Dimensions.get(dim).height
15
+ };
16
+ };
17
+ }
18
+ render() {
19
+ const { width, height } = this.getWidthAndHeight();
20
+ return (React.createElement(react_native_1.View, { style: [styles.backgroundView, { width, height }] },
21
+ React.createElement(react_native_1.ActivityIndicator, { size: "large", color: "#aaa", style: [styles.indicator, { width, height }] })));
22
+ }
23
+ }
24
+ exports.Loading = Loading;
25
+ const styles = react_native_1.StyleSheet.create({
26
+ backgroundView: {
27
+ zIndex: 9998,
28
+ position: 'absolute',
29
+ opacity: 0.6,
30
+ backgroundColor: '#ccc',
31
+ top: 0,
32
+ bottom: 0,
33
+ left: 0,
34
+ right: 0 // IE fix
35
+ },
36
+ indicator: {
37
+ zIndex: 9999,
38
+ position: 'absolute',
39
+ justifyContent: 'space-around',
40
+ top: 0,
41
+ bottom: 0,
42
+ left: 0,
43
+ right: 0 // IE fix
44
+ }
45
+ });
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { StyleProp, TextStyle } from 'react-native';
3
+ export interface MenuItemData {
4
+ path?: string;
5
+ text: string;
6
+ textStyle?: StyleProp<TextStyle>;
7
+ subText?: string;
8
+ subTextStyle?: StyleProp<TextStyle>;
9
+ disabled?: boolean;
10
+ nativeID?: string;
11
+ }
12
+ export interface MenuItemProperties {
13
+ menuItem: MenuItemData;
14
+ icon?: string;
15
+ textStyle?: StyleProp<TextStyle>;
16
+ onPress: () => void;
17
+ isCurrentMenuPath?: (path: string) => boolean;
18
+ }
19
+ export declare function MenuItem(props: MenuItemProperties): JSX.Element;
20
+ export interface MenuProperties {
21
+ menu: Array<MenuItemData & {
22
+ submenu?: Array<MenuItemData>;
23
+ }>;
24
+ onMenuPress: (path: string) => void;
25
+ isCurrentMenuPath?: (path: string) => boolean;
26
+ }
27
+ export interface MenuState {
28
+ indexMenuOpened: number;
29
+ }
30
+ export declare class Menu extends React.Component<MenuProperties, MenuState> {
31
+ state: MenuState;
32
+ componentDidMount(): void;
33
+ handleParentMenuPress: (index: number) => void;
34
+ handleMenuPress: (path?: string) => void;
35
+ getStyles: () => {
36
+ submenuText: {
37
+ paddingLeft: number;
38
+ paddingVertical: number;
39
+ };
40
+ };
41
+ render(): JSX.Element;
42
+ }
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Menu = exports.MenuItem = void 0;
4
+ const React = require("react");
5
+ const FontAwesome_1 = require("react-native-vector-icons/FontAwesome");
6
+ const theme_1 = require("../modules/theme");
7
+ const test_1 = require("../modules/test");
8
+ const layout_1 = require("../modules/layout");
9
+ const react_native_1 = require("react-native");
10
+ function MenuItem(props) {
11
+ const theme = (0, theme_1.getTheme)();
12
+ const styles = react_native_1.StyleSheet.create({
13
+ container: {
14
+ flexDirection: 'row',
15
+ justifyContent: 'space-between',
16
+ width: '100%',
17
+ paddingRight: 10
18
+ },
19
+ text: {
20
+ color: theme.textColor1,
21
+ fontFamily: theme.fontFamily1,
22
+ fontSize: (0, layout_1.isTablet)() ? 20 : 16,
23
+ paddingVertical: (0, layout_1.isTablet)() ? 15 : 14
24
+ },
25
+ textDisabled: {
26
+ color: theme.borderColor1
27
+ },
28
+ textSelected: {
29
+ color: theme.textColor2
30
+ },
31
+ subText: {
32
+ fontSize: 12,
33
+ marginLeft: 5
34
+ },
35
+ icon: {
36
+ paddingTop: 12,
37
+ paddingRight: 10,
38
+ color: theme.textColor1
39
+ }
40
+ });
41
+ const { menuItem, icon, textStyle, onPress, isCurrentMenuPath } = props;
42
+ const selected = isCurrentMenuPath != undefined &&
43
+ menuItem.path != undefined &&
44
+ isCurrentMenuPath(menuItem.path);
45
+ return (React.createElement(react_native_1.TouchableOpacity, { disabled: menuItem.disabled, style: styles.container, onPress: onPress },
46
+ React.createElement(react_native_1.Text, { nativeID: menuItem.nativeID, testID: (0, test_1.getTestID)(menuItem.nativeID), style: [
47
+ styles.text,
48
+ menuItem.disabled && styles.textDisabled,
49
+ selected && styles.textSelected,
50
+ textStyle,
51
+ menuItem.textStyle
52
+ ] },
53
+ menuItem.text,
54
+ menuItem.subText && (React.createElement(react_native_1.Text, { style: [styles.subText, menuItem.subTextStyle] }, menuItem.subText))),
55
+ icon && React.createElement(FontAwesome_1.default, { name: icon, style: styles.icon, size: 20 })));
56
+ }
57
+ exports.MenuItem = MenuItem;
58
+ class Menu extends React.Component {
59
+ constructor() {
60
+ super(...arguments);
61
+ this.state = {
62
+ indexMenuOpened: -1
63
+ };
64
+ this.handleParentMenuPress = (index) => {
65
+ this.setState({
66
+ indexMenuOpened: this.state.indexMenuOpened === index ? -1 : index
67
+ });
68
+ };
69
+ this.handleMenuPress = (path) => {
70
+ if (path != undefined) {
71
+ this.props.onMenuPress(path);
72
+ }
73
+ };
74
+ this.getStyles = () => {
75
+ const styles = react_native_1.StyleSheet.create({
76
+ submenuText: {
77
+ paddingLeft: 20,
78
+ paddingVertical: (0, layout_1.isTablet)() ? 10 : 8
79
+ }
80
+ });
81
+ return styles;
82
+ };
83
+ }
84
+ componentDidMount() {
85
+ const { menu, isCurrentMenuPath } = this.props;
86
+ const indexMenuOpened = menu.findIndex(menuItem => menuItem.submenu != undefined &&
87
+ menuItem.submenu.some(submenuItem => isCurrentMenuPath != undefined &&
88
+ submenuItem.path != undefined &&
89
+ isCurrentMenuPath(submenuItem.path)));
90
+ this.setState({ indexMenuOpened });
91
+ }
92
+ render() {
93
+ const { menu, isCurrentMenuPath } = this.props;
94
+ const styles = this.getStyles();
95
+ return (React.createElement(React.Fragment, null, menu.map((menuItem, menuItemIndex) => {
96
+ const menuItemIsOpen = this.state.indexMenuOpened === menuItemIndex;
97
+ const menuItemIcon = menuItem.submenu
98
+ ? menuItemIsOpen
99
+ ? 'caret-up'
100
+ : 'caret-down'
101
+ : undefined;
102
+ const menuItemOnPress = () => menuItem.submenu
103
+ ? this.handleParentMenuPress(menuItemIndex)
104
+ : this.handleMenuPress(menuItem.path);
105
+ return (React.createElement(react_native_1.View, { key: menuItemIndex },
106
+ React.createElement(MenuItem, { menuItem: menuItem, icon: menuItemIcon, onPress: menuItemOnPress, isCurrentMenuPath: isCurrentMenuPath }),
107
+ menuItem.submenu && (React.createElement(react_native_1.View, { style: {
108
+ height: menuItemIsOpen ? 'auto' : 0,
109
+ overflow: 'hidden'
110
+ } }, menuItem.submenu.map((submenuItem, submenuItemIndex) => (React.createElement(MenuItem, { key: submenuItemIndex, menuItem: submenuItem, textStyle: styles.submenuText, onPress: () => this.handleMenuPress(submenuItem.path), isCurrentMenuPath: isCurrentMenuPath })))))));
111
+ })));
112
+ }
113
+ }
114
+ exports.Menu = Menu;
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { MenuProperties } from './Menu';
3
+ export declare type MenuDesktopProperties = MenuProperties & {
4
+ headerHeight: number;
5
+ renderUserData?: () => React.ReactNode;
6
+ };
7
+ export declare class MenuDesktop extends React.Component<MenuDesktopProperties> {
8
+ static defaultProps: {
9
+ headerHeight: number;
10
+ };
11
+ getStyles: () => {
12
+ container: {
13
+ backgroundColor: string;
14
+ height: number;
15
+ width: number;
16
+ paddingHorizontal: number;
17
+ paddingVertical: number;
18
+ shadowOpacity: number;
19
+ shadowRadius: number;
20
+ shadowColor: string;
21
+ };
22
+ };
23
+ render(): JSX.Element;
24
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MenuDesktop = void 0;
4
+ const React = require("react");
5
+ const react_native_1 = require("react-native");
6
+ const theme_1 = require("../modules/theme");
7
+ const Menu_1 = require("./Menu");
8
+ class MenuDesktop extends React.Component {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.getStyles = () => {
12
+ const theme = (0, theme_1.getTheme)();
13
+ const styles = react_native_1.StyleSheet.create({
14
+ container: {
15
+ backgroundColor: theme.backgroundColor1,
16
+ height: react_native_1.Dimensions.get('window').height - this.props.headerHeight,
17
+ width: 250,
18
+ paddingHorizontal: 15,
19
+ paddingVertical: 15,
20
+ shadowOpacity: 0.31,
21
+ shadowRadius: 20,
22
+ shadowColor: theme.shadowColor1
23
+ }
24
+ });
25
+ return styles;
26
+ };
27
+ }
28
+ render() {
29
+ const { menu, onMenuPress, isCurrentMenuPath, renderUserData } = this.props;
30
+ const styles = this.getStyles();
31
+ return (React.createElement(react_native_1.View, { style: styles.container },
32
+ renderUserData ? React.createElement(react_native_1.View, null, renderUserData()) : null,
33
+ React.createElement(Menu_1.Menu, { menu: menu, isCurrentMenuPath: isCurrentMenuPath, onMenuPress: onMenuPress })));
34
+ }
35
+ }
36
+ exports.MenuDesktop = MenuDesktop;
37
+ MenuDesktop.defaultProps = {
38
+ headerHeight: 0
39
+ };