secullum-react-native-ui 4.3.8-beta.2 → 4.3.10
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.
- package/lib/components/AppShell.d.ts +24 -0
- package/lib/components/AppShell.js +79 -0
- package/lib/components/Button.d.ts +47 -0
- package/lib/components/Button.js +65 -0
- package/lib/components/Card.d.ts +65 -0
- package/lib/components/Card.js +125 -0
- package/lib/components/CheckBox.d.ts +34 -0
- package/lib/components/CheckBox.js +46 -0
- package/lib/components/DatePicker.d.ts +67 -0
- package/lib/components/DatePicker.js +105 -0
- package/lib/components/DatePicker.web.d.ts +64 -0
- package/lib/components/DatePicker.web.js +105 -0
- package/lib/components/Delay.d.ts +12 -0
- package/lib/components/Delay.js +21 -0
- package/lib/components/Details.d.ts +66 -0
- package/lib/components/Details.js +94 -0
- package/lib/components/DetailsHeader.d.ts +37 -0
- package/lib/components/DetailsHeader.js +63 -0
- package/lib/components/DimensionsMonitor.d.ts +21 -0
- package/lib/components/DimensionsMonitor.js +35 -0
- package/lib/components/DropDown.d.ts +35 -0
- package/lib/components/DropDown.js +263 -0
- package/lib/components/ErrorMessage.d.ts +16 -0
- package/lib/components/ErrorMessage.js +29 -0
- package/lib/components/FilePicker.d.ts +28 -0
- package/lib/components/FilePicker.js +44 -0
- package/lib/components/Header.d.ts +56 -0
- package/lib/components/Header.js +89 -0
- package/lib/components/HeaderDesktop.d.ts +59 -0
- package/lib/components/HeaderDesktop.js +80 -0
- package/lib/components/ImageButton.d.ts +14 -0
- package/lib/components/ImageButton.js +32 -0
- package/lib/components/KeyboardAvoidingView.d.ts +34 -0
- package/lib/components/KeyboardAvoidingView.js +92 -0
- package/lib/components/Link.d.ts +17 -0
- package/lib/components/Link.js +28 -0
- package/lib/components/Loading.d.ts +4 -0
- package/lib/components/Loading.js +37 -0
- package/lib/components/Menu.d.ts +42 -0
- package/lib/components/Menu.js +112 -0
- package/lib/components/MenuDesktop.d.ts +24 -0
- package/lib/components/MenuDesktop.js +38 -0
- package/lib/components/MenuMobile.d.ts +47 -0
- package/lib/components/MenuMobile.js +85 -0
- package/lib/components/Message.d.ts +37 -0
- package/lib/components/Message.js +50 -0
- package/lib/components/Modal.d.ts +11 -0
- package/lib/components/Modal.js +20 -0
- package/lib/components/MultiSelect.d.ts +51 -0
- package/lib/components/MultiSelect.js +376 -0
- package/lib/components/NoRecordMessage.d.ts +23 -0
- package/lib/components/NoRecordMessage.js +35 -0
- package/lib/components/Question.d.ts +57 -0
- package/lib/components/Question.js +72 -0
- package/lib/components/RadioButton.d.ts +42 -0
- package/lib/components/RadioButton.js +53 -0
- package/lib/components/RadioGroup.d.ts +44 -0
- package/lib/components/RadioGroup.js +64 -0
- package/lib/components/RangeDatePicker.d.ts +57 -0
- package/lib/components/RangeDatePicker.js +126 -0
- package/lib/components/RangeDatePicker.web.d.ts +61 -0
- package/lib/components/RangeDatePicker.web.js +119 -0
- package/lib/components/Space.d.ts +11 -0
- package/lib/components/Space.js +14 -0
- package/lib/components/StatusBar.d.ts +11 -0
- package/lib/components/StatusBar.js +27 -0
- package/lib/components/Switch.d.ts +34 -0
- package/lib/components/Switch.js +49 -0
- package/lib/components/Table.d.ts +28 -0
- package/lib/components/Table.js +62 -0
- package/lib/components/Table.web.d.ts +18 -0
- package/lib/components/Table.web.js +108 -0
- package/lib/components/Text.d.ts +28 -0
- package/lib/components/Text.js +36 -0
- package/lib/components/TextBox.d.ts +115 -0
- package/lib/components/TextBox.js +103 -0
- package/lib/components/TextBoxMask.d.ts +12 -0
- package/lib/components/TextBoxMask.js +29 -0
- package/lib/components/TimePicker.d.ts +63 -0
- package/lib/components/TimePicker.js +111 -0
- package/lib/components/TimePicker.web.d.ts +48 -0
- package/lib/components/TimePicker.web.js +82 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.js +44 -0
- package/lib/modules/browser.d.ts +2 -0
- package/lib/modules/browser.js +50 -0
- package/lib/modules/format.d.ts +6 -0
- package/lib/modules/format.js +99 -0
- package/lib/modules/layout.d.ts +1 -0
- package/lib/modules/layout.js +10 -0
- package/lib/modules/theme.d.ts +41 -0
- package/lib/modules/theme.js +49 -0
- package/lib/modules/validation.d.ts +3 -0
- package/lib/modules/validation.js +12 -0
- package/package.json +1 -1
|
@@ -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,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const FontAwesome_1 = require("react-native-vector-icons/FontAwesome");
|
|
5
|
+
const theme_1 = require("../modules/theme");
|
|
6
|
+
const react_native_1 = require("react-native");
|
|
7
|
+
class ImageButton extends React.Component {
|
|
8
|
+
render() {
|
|
9
|
+
const { icon, style, iconColor, onPress, iconSize, hitBoxSize, nativeID } = this.props;
|
|
10
|
+
return (React.createElement(react_native_1.TouchableOpacity, { onPress: onPress, activeOpacity: 0.5, style: [styles.container, style], hitSlop: hitBoxSize
|
|
11
|
+
? {
|
|
12
|
+
top: hitBoxSize,
|
|
13
|
+
bottom: hitBoxSize,
|
|
14
|
+
left: hitBoxSize,
|
|
15
|
+
right: hitBoxSize
|
|
16
|
+
}
|
|
17
|
+
: undefined },
|
|
18
|
+
React.createElement(FontAwesome_1.default, { nativeID: nativeID, name: icon, size: iconSize || 20, color: iconColor || theme.textColor1 })));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ImageButton = ImageButton;
|
|
22
|
+
const theme = theme_1.getTheme();
|
|
23
|
+
const styles = react_native_1.StyleSheet.create({
|
|
24
|
+
container: {
|
|
25
|
+
borderWidth: 1,
|
|
26
|
+
borderColor: theme.borderColor1,
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
width: 40,
|
|
30
|
+
height: 40
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -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>;
|
|
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,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
class KeyboardAvoidingView extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.scrollViewRef = React.createRef();
|
|
9
|
+
this.state = {
|
|
10
|
+
keyboardHeight: 0
|
|
11
|
+
};
|
|
12
|
+
this.handleKeyboardShow = (event) => {
|
|
13
|
+
const keyboardHeight = event.endCoordinates.height;
|
|
14
|
+
const keyboardPosition = event.endCoordinates.screenY;
|
|
15
|
+
this.setState({
|
|
16
|
+
keyboardHeight
|
|
17
|
+
});
|
|
18
|
+
const scrollView = this.scrollViewRef.current;
|
|
19
|
+
if (!scrollView) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
const currentlyFocusedInput = react_native_1.TextInput.State.currentlyFocusedInput();
|
|
24
|
+
if (!currentlyFocusedInput) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { extraFieldHeight, extraWindowHeight } = this.props;
|
|
28
|
+
const currentlyFocusedInputNode = react_native_1.findNodeHandle(currentlyFocusedInput);
|
|
29
|
+
// @ts-ignore: no types :(
|
|
30
|
+
react_native_1.UIManager.viewIsDescendantOf(currentlyFocusedInputNode, react_native_1.findNodeHandle(scrollView), (isDescendant) => {
|
|
31
|
+
if (!isDescendant) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
currentlyFocusedInput.measure((x, y, width, height, pageX, pageY) => {
|
|
35
|
+
const fieldPosition = pageY + height + extraFieldHeight;
|
|
36
|
+
if (fieldPosition <= keyboardPosition) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
scrollView.scrollResponderScrollNativeHandleToKeyboard(currentlyFocusedInputNode, extraWindowHeight + extraFieldHeight, true);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
this.handleKeyboardHide = () => {
|
|
44
|
+
this.setState({
|
|
45
|
+
keyboardHeight: 0
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
this.scrollTo = (x, y) => {
|
|
49
|
+
if (!this.scrollViewRef.current) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.scrollViewRef.current.scrollTo({ x, y });
|
|
53
|
+
};
|
|
54
|
+
this.scrollToEnd = () => {
|
|
55
|
+
if (!this.scrollViewRef.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.scrollViewRef.current.scrollToEnd();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
componentDidMount() {
|
|
62
|
+
// Android doesn't have 'will' events, but we can use 'did' there without any problem
|
|
63
|
+
// iOS on the other hand needs to use the 'will' events otherwise the screen would show some empty spaces during keyboard events
|
|
64
|
+
this.keyboardDidShowSubscription = react_native_1.Keyboard.addListener(react_native_1.Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow', this.handleKeyboardShow);
|
|
65
|
+
this.keyboardDidHideSubscription = react_native_1.Keyboard.addListener(react_native_1.Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide', this.handleKeyboardHide);
|
|
66
|
+
}
|
|
67
|
+
componentWillUnmount() {
|
|
68
|
+
this.keyboardDidShowSubscription.remove();
|
|
69
|
+
this.keyboardDidHideSubscription.remove();
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
const { refreshControl, scrollEnabled, onScroll, children, keyBoardShow } = this.props;
|
|
73
|
+
// Android devices with notch will report less `availableHeight` than it should
|
|
74
|
+
// That's because of this: https://github.com/facebook/react-native/issues/23693
|
|
75
|
+
// If I change it to 'screen', Android devices with virtual buttons will report more than it should
|
|
76
|
+
const availableHeight = react_native_1.Dimensions.get('window').height -
|
|
77
|
+
this.state.keyboardHeight -
|
|
78
|
+
this.props.extraWindowHeight;
|
|
79
|
+
return (React.createElement(react_native_1.View, { style: [{ height: availableHeight }, !keyBoardShow && { flex: 1 }] },
|
|
80
|
+
React.createElement(react_native_1.ScrollView, { ref: this.scrollViewRef, refreshControl: refreshControl, scrollEnabled: scrollEnabled, onScroll: (e) => {
|
|
81
|
+
if (onScroll) {
|
|
82
|
+
onScroll(e.nativeEvent);
|
|
83
|
+
}
|
|
84
|
+
}, scrollEventThrottle: 16 }, children({ availableHeight }))));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
KeyboardAvoidingView.defaultProps = {
|
|
88
|
+
extraFieldHeight: 0,
|
|
89
|
+
extraWindowHeight: 0,
|
|
90
|
+
scrollEnabled: true
|
|
91
|
+
};
|
|
92
|
+
exports.KeyboardAvoidingView = KeyboardAvoidingView;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
8
|
+
export declare class Link extends React.Component<LinkProperties> {
|
|
9
|
+
getStyles: () => {
|
|
10
|
+
link: {
|
|
11
|
+
fontFamily: string;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
color: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
render(): JSX.Element;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const theme_1 = require("../modules/theme");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
class Link extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.getStyles = () => {
|
|
10
|
+
const theme = theme_1.getTheme();
|
|
11
|
+
const styles = react_native_1.StyleSheet.create({
|
|
12
|
+
link: {
|
|
13
|
+
fontFamily: theme.fontFamily2,
|
|
14
|
+
fontSize: 14,
|
|
15
|
+
color: theme.textColor2
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return styles;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const { text, style, onPress } = this.props;
|
|
23
|
+
const styles = this.getStyles();
|
|
24
|
+
return (React.createElement(react_native_1.TouchableOpacity, { activeOpacity: 0.7, onPress: onPress },
|
|
25
|
+
React.createElement(react_native_1.Text, { style: [styles.link, style] }, text)));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Link = Link;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
class Loading extends React.Component {
|
|
6
|
+
render() {
|
|
7
|
+
return (React.createElement(React.Fragment, null,
|
|
8
|
+
React.createElement(react_native_1.View, { style: styles.backgroundView }),
|
|
9
|
+
React.createElement(react_native_1.ActivityIndicator, { style: styles.indicator, size: "large", color: "#aaa" })));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Loading = Loading;
|
|
13
|
+
const styles = react_native_1.StyleSheet.create({
|
|
14
|
+
backgroundView: {
|
|
15
|
+
zIndex: 9998,
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
width: react_native_1.Dimensions.get('screen').width,
|
|
18
|
+
height: react_native_1.Dimensions.get('screen').height,
|
|
19
|
+
opacity: 0.6,
|
|
20
|
+
backgroundColor: '#ccc',
|
|
21
|
+
top: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
right: 0 // IE fix
|
|
25
|
+
},
|
|
26
|
+
indicator: {
|
|
27
|
+
zIndex: 9999,
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
width: react_native_1.Dimensions.get('screen').width,
|
|
30
|
+
height: react_native_1.Dimensions.get('screen').height,
|
|
31
|
+
justifyContent: 'space-around',
|
|
32
|
+
top: 0,
|
|
33
|
+
bottom: 0,
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0 // IE fix
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -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 | undefined) => void;
|
|
35
|
+
getStyles: () => {
|
|
36
|
+
submenuText: {
|
|
37
|
+
paddingLeft: number;
|
|
38
|
+
paddingVertical: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
render(): JSX.Element;
|
|
42
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const FontAwesome_1 = require("react-native-vector-icons/FontAwesome");
|
|
5
|
+
const theme_1 = require("../modules/theme");
|
|
6
|
+
const layout_1 = require("../modules/layout");
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
function MenuItem(props) {
|
|
9
|
+
const theme = theme_1.getTheme();
|
|
10
|
+
const styles = react_native_1.StyleSheet.create({
|
|
11
|
+
container: {
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
justifyContent: 'space-between',
|
|
14
|
+
width: '100%',
|
|
15
|
+
paddingRight: 10
|
|
16
|
+
},
|
|
17
|
+
text: {
|
|
18
|
+
color: theme.textColor1,
|
|
19
|
+
fontFamily: theme.fontFamily1,
|
|
20
|
+
fontSize: layout_1.isTablet() ? 20 : 16,
|
|
21
|
+
paddingVertical: layout_1.isTablet() ? 15 : 14
|
|
22
|
+
},
|
|
23
|
+
textDisabled: {
|
|
24
|
+
color: theme.borderColor1
|
|
25
|
+
},
|
|
26
|
+
textSelected: {
|
|
27
|
+
color: theme.textColor2
|
|
28
|
+
},
|
|
29
|
+
subText: {
|
|
30
|
+
fontSize: 12,
|
|
31
|
+
marginLeft: 5
|
|
32
|
+
},
|
|
33
|
+
icon: {
|
|
34
|
+
paddingTop: 12,
|
|
35
|
+
paddingRight: 10,
|
|
36
|
+
color: theme.textColor1
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const { menuItem, icon, textStyle, onPress, isCurrentMenuPath } = props;
|
|
40
|
+
const selected = isCurrentMenuPath != undefined &&
|
|
41
|
+
menuItem.path != undefined &&
|
|
42
|
+
isCurrentMenuPath(menuItem.path);
|
|
43
|
+
return (React.createElement(react_native_1.TouchableOpacity, { disabled: menuItem.disabled, style: styles.container, onPress: onPress },
|
|
44
|
+
React.createElement(react_native_1.Text, { nativeID: menuItem.nativeID, style: [
|
|
45
|
+
styles.text,
|
|
46
|
+
menuItem.disabled && styles.textDisabled,
|
|
47
|
+
selected && styles.textSelected,
|
|
48
|
+
textStyle,
|
|
49
|
+
menuItem.textStyle
|
|
50
|
+
] },
|
|
51
|
+
menuItem.text,
|
|
52
|
+
menuItem.subText && (React.createElement(react_native_1.Text, { style: [styles.subText, menuItem.subTextStyle] }, menuItem.subText))),
|
|
53
|
+
icon && React.createElement(FontAwesome_1.default, { name: icon, style: styles.icon, size: 20 })));
|
|
54
|
+
}
|
|
55
|
+
exports.MenuItem = MenuItem;
|
|
56
|
+
class Menu extends React.Component {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
this.state = {
|
|
60
|
+
indexMenuOpened: -1
|
|
61
|
+
};
|
|
62
|
+
this.handleParentMenuPress = (index) => {
|
|
63
|
+
this.setState({
|
|
64
|
+
indexMenuOpened: this.state.indexMenuOpened === index ? -1 : index
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
this.handleMenuPress = (path) => {
|
|
68
|
+
if (path != undefined) {
|
|
69
|
+
this.props.onMenuPress(path);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
this.getStyles = () => {
|
|
73
|
+
const styles = react_native_1.StyleSheet.create({
|
|
74
|
+
submenuText: {
|
|
75
|
+
paddingLeft: 20,
|
|
76
|
+
paddingVertical: layout_1.isTablet() ? 10 : 8
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return styles;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
componentDidMount() {
|
|
83
|
+
const { menu, isCurrentMenuPath } = this.props;
|
|
84
|
+
const indexMenuOpened = menu.findIndex(menuItem => menuItem.submenu != undefined &&
|
|
85
|
+
menuItem.submenu.some(submenuItem => isCurrentMenuPath != undefined &&
|
|
86
|
+
submenuItem.path != undefined &&
|
|
87
|
+
isCurrentMenuPath(submenuItem.path)));
|
|
88
|
+
this.setState({ indexMenuOpened });
|
|
89
|
+
}
|
|
90
|
+
render() {
|
|
91
|
+
const { menu, isCurrentMenuPath } = this.props;
|
|
92
|
+
const styles = this.getStyles();
|
|
93
|
+
return (React.createElement(React.Fragment, null, menu.map((menuItem, menuItemIndex) => {
|
|
94
|
+
const menuItemIsOpen = this.state.indexMenuOpened === menuItemIndex;
|
|
95
|
+
const menuItemIcon = menuItem.submenu
|
|
96
|
+
? menuItemIsOpen
|
|
97
|
+
? 'caret-up'
|
|
98
|
+
: 'caret-down'
|
|
99
|
+
: undefined;
|
|
100
|
+
const menuItemOnPress = () => menuItem.submenu
|
|
101
|
+
? this.handleParentMenuPress(menuItemIndex)
|
|
102
|
+
: this.handleMenuPress(menuItem.path);
|
|
103
|
+
return (React.createElement(react_native_1.View, { key: menuItemIndex },
|
|
104
|
+
React.createElement(MenuItem, { menuItem: menuItem, icon: menuItemIcon, onPress: menuItemOnPress, isCurrentMenuPath: isCurrentMenuPath }),
|
|
105
|
+
menuItem.submenu && (React.createElement(react_native_1.View, { style: {
|
|
106
|
+
height: menuItemIsOpen ? 'auto' : 0,
|
|
107
|
+
overflow: 'hidden'
|
|
108
|
+
} }, menuItem.submenu.map((submenuItem, submenuItemIndex) => (React.createElement(MenuItem, { key: submenuItemIndex, menuItem: submenuItem, textStyle: styles.submenuText, onPress: () => this.handleMenuPress(submenuItem.path), isCurrentMenuPath: isCurrentMenuPath })))))));
|
|
109
|
+
})));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
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,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const theme_1 = require("../modules/theme");
|
|
6
|
+
const Menu_1 = require("./Menu");
|
|
7
|
+
class MenuDesktop extends React.Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.getStyles = () => {
|
|
11
|
+
const theme = theme_1.getTheme();
|
|
12
|
+
const styles = react_native_1.StyleSheet.create({
|
|
13
|
+
container: {
|
|
14
|
+
backgroundColor: theme.backgroundColor1,
|
|
15
|
+
height: react_native_1.Dimensions.get('window').height - this.props.headerHeight,
|
|
16
|
+
width: 250,
|
|
17
|
+
paddingHorizontal: 15,
|
|
18
|
+
paddingVertical: 15,
|
|
19
|
+
shadowOpacity: 0.31,
|
|
20
|
+
shadowRadius: 20,
|
|
21
|
+
shadowColor: theme.shadowColor1
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return styles;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
const { menu, onMenuPress, isCurrentMenuPath, renderUserData } = this.props;
|
|
29
|
+
const styles = this.getStyles();
|
|
30
|
+
return (React.createElement(react_native_1.View, { style: styles.container },
|
|
31
|
+
renderUserData ? React.createElement(react_native_1.View, null, renderUserData()) : null,
|
|
32
|
+
React.createElement(Menu_1.Menu, { menu: menu, isCurrentMenuPath: isCurrentMenuPath, onMenuPress: onMenuPress })));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
MenuDesktop.defaultProps = {
|
|
36
|
+
headerHeight: 0
|
|
37
|
+
};
|
|
38
|
+
exports.MenuDesktop = MenuDesktop;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import DrawerLayout from 'react-native-drawer-layout';
|
|
3
|
+
import { MenuProperties } from './Menu';
|
|
4
|
+
export declare type MenuMobileProperties = MenuProperties & {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
drawerLockMode?: 'unlocked' | 'locked-closed' | 'locked-open';
|
|
7
|
+
renderLogo: () => React.ReactNode;
|
|
8
|
+
renderUserData?: () => React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export interface MenuMobileState {
|
|
11
|
+
opened: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class MenuMobile extends React.Component<MenuMobileProperties, MenuMobileState> {
|
|
14
|
+
state: MenuMobileState;
|
|
15
|
+
drawer: DrawerLayout | null;
|
|
16
|
+
componentDidMount(): void;
|
|
17
|
+
componentWillUnmount(): void;
|
|
18
|
+
handleBackButton: () => boolean;
|
|
19
|
+
handleMenuPress: (path: string) => void;
|
|
20
|
+
open: () => void;
|
|
21
|
+
close: () => void;
|
|
22
|
+
getStyles: () => {
|
|
23
|
+
container: {
|
|
24
|
+
flex: number;
|
|
25
|
+
};
|
|
26
|
+
logoContainer: {
|
|
27
|
+
paddingVertical: number;
|
|
28
|
+
paddingLeft: number;
|
|
29
|
+
borderBottomColor: string;
|
|
30
|
+
borderBottomWidth: number;
|
|
31
|
+
flexDirection: "row";
|
|
32
|
+
};
|
|
33
|
+
userContainer: {
|
|
34
|
+
paddingVertical: number;
|
|
35
|
+
paddingLeft: number;
|
|
36
|
+
paddingRight: number;
|
|
37
|
+
borderBottomColor: string;
|
|
38
|
+
borderBottomWidth: number;
|
|
39
|
+
};
|
|
40
|
+
menuContainer: {
|
|
41
|
+
paddingLeft: number;
|
|
42
|
+
flex: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
renderNavigationView: () => JSX.Element;
|
|
46
|
+
render(): JSX.Element;
|
|
47
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const react_native_drawer_layout_1 = require("react-native-drawer-layout");
|
|
6
|
+
const theme_1 = require("../modules/theme");
|
|
7
|
+
const layout_1 = require("../modules/layout");
|
|
8
|
+
const Menu_1 = require("./Menu");
|
|
9
|
+
class MenuMobile extends React.Component {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.state = {
|
|
13
|
+
opened: false
|
|
14
|
+
};
|
|
15
|
+
this.drawer = null;
|
|
16
|
+
this.handleBackButton = () => {
|
|
17
|
+
if (this.state.opened) {
|
|
18
|
+
this.close();
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
this.handleMenuPress = (path) => {
|
|
24
|
+
this.close();
|
|
25
|
+
this.props.onMenuPress(path);
|
|
26
|
+
};
|
|
27
|
+
this.open = () => {
|
|
28
|
+
if (this.drawer) {
|
|
29
|
+
this.drawer.openDrawer();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
this.close = () => {
|
|
33
|
+
if (this.drawer) {
|
|
34
|
+
this.drawer.closeDrawer();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
this.getStyles = () => {
|
|
38
|
+
const theme = theme_1.getTheme();
|
|
39
|
+
const styles = react_native_1.StyleSheet.create({
|
|
40
|
+
container: {
|
|
41
|
+
flex: 1
|
|
42
|
+
},
|
|
43
|
+
logoContainer: {
|
|
44
|
+
paddingVertical: 5,
|
|
45
|
+
paddingLeft: 10,
|
|
46
|
+
borderBottomColor: theme.borderColor1,
|
|
47
|
+
borderBottomWidth: 1,
|
|
48
|
+
flexDirection: 'row'
|
|
49
|
+
},
|
|
50
|
+
userContainer: {
|
|
51
|
+
paddingVertical: 10,
|
|
52
|
+
paddingLeft: 20,
|
|
53
|
+
paddingRight: 10,
|
|
54
|
+
borderBottomColor: theme.borderColor1,
|
|
55
|
+
borderBottomWidth: 1
|
|
56
|
+
},
|
|
57
|
+
menuContainer: {
|
|
58
|
+
paddingLeft: 20,
|
|
59
|
+
flex: 1
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return styles;
|
|
63
|
+
};
|
|
64
|
+
this.renderNavigationView = () => {
|
|
65
|
+
const { renderLogo, renderUserData, menu, isCurrentMenuPath } = this.props;
|
|
66
|
+
const styles = this.getStyles();
|
|
67
|
+
return (React.createElement(react_native_1.View, { style: styles.container },
|
|
68
|
+
React.createElement(react_native_1.View, { style: styles.logoContainer }, renderLogo()),
|
|
69
|
+
renderUserData && (React.createElement(react_native_1.View, { style: styles.userContainer }, renderUserData())),
|
|
70
|
+
React.createElement(react_native_1.ScrollView, { style: styles.menuContainer },
|
|
71
|
+
React.createElement(Menu_1.Menu, { menu: menu, isCurrentMenuPath: isCurrentMenuPath, onMenuPress: this.handleMenuPress }))));
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
componentDidMount() {
|
|
75
|
+
react_native_1.BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
|
|
76
|
+
}
|
|
77
|
+
componentWillUnmount() {
|
|
78
|
+
react_native_1.BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
|
|
79
|
+
}
|
|
80
|
+
render() {
|
|
81
|
+
const theme = theme_1.getTheme();
|
|
82
|
+
return (React.createElement(react_native_drawer_layout_1.default, { ref: drawer => (this.drawer = drawer), drawerLockMode: this.props.drawerLockMode, drawerBackgroundColor: theme.backgroundColor1, drawerWidth: layout_1.isTablet() ? 450 : 300, drawerPosition: react_native_drawer_layout_1.default.positions.Left, renderNavigationView: this.renderNavigationView, onDrawerOpen: () => this.setState({ opened: true }), onDrawerClose: () => this.setState({ opened: false }) }, this.props.children));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.MenuMobile = MenuMobile;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleProp, TextStyle } from 'react-native';
|
|
3
|
+
export interface MessageProperties {
|
|
4
|
+
message: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
type?: 'info' | 'warning';
|
|
7
|
+
onRequestClose?: () => void;
|
|
8
|
+
nativeID?: string;
|
|
9
|
+
textStyle?: StyleProp<TextStyle>;
|
|
10
|
+
}
|
|
11
|
+
export declare class Message extends React.Component<MessageProperties> {
|
|
12
|
+
static defaultProps: {
|
|
13
|
+
type: string;
|
|
14
|
+
};
|
|
15
|
+
getStyles: () => {
|
|
16
|
+
overlay: {
|
|
17
|
+
alignItems: "center";
|
|
18
|
+
};
|
|
19
|
+
container: {
|
|
20
|
+
backgroundColor: string;
|
|
21
|
+
borderRadius: number;
|
|
22
|
+
padding: number;
|
|
23
|
+
width: number;
|
|
24
|
+
marginTop: number;
|
|
25
|
+
alignItems: "center";
|
|
26
|
+
};
|
|
27
|
+
text: {
|
|
28
|
+
color: string;
|
|
29
|
+
fontFamily: string;
|
|
30
|
+
fontSize: number;
|
|
31
|
+
textAlign: "center";
|
|
32
|
+
marginTop: number;
|
|
33
|
+
width: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
render(): JSX.Element;
|
|
37
|
+
}
|