@janiscommerce/ui-native 1.2.0 → 1.4.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.
- package/dist/env.json +1 -0
- package/dist/{components → src/components}/Avatar/index.js +14 -8
- package/dist/{components → src/components}/BaseButton/index.d.ts +2 -2
- package/dist/{components → src/components}/BaseButton/index.js +13 -6
- package/dist/{components → src/components}/CheckBox/index.js +16 -9
- package/dist/{components → src/components}/Icon/index.js +3 -1
- package/dist/{components → src/components}/Input/index.js +15 -8
- package/dist/{components → src/components}/Loading/index.js +7 -3
- package/dist/{components → src/components}/LoadingFullScreen/index.js +10 -4
- package/dist/{components → src/components}/ProgressBar/index.js +10 -5
- package/dist/{components → src/components}/RadioButton/index.js +9 -5
- package/dist/src/components/Select/Components/Dropdown/index.d.ts +10 -0
- package/dist/src/components/Select/Components/Dropdown/index.js +23 -0
- package/dist/src/components/Select/Components/Modal/index.d.ts +8 -0
- package/dist/src/components/Select/Components/Modal/index.js +65 -0
- package/dist/src/components/Select/Components/Options/index.d.ts +18 -0
- package/dist/{components/Select/Components/Dropdown → src/components/Select/Components/Options}/index.js +16 -14
- package/dist/src/components/Select/Components/SwitcherComponent/index.d.ts +13 -0
- package/dist/src/components/Select/Components/SwitcherComponent/index.js +8 -0
- package/dist/{components → src/components}/Select/index.d.ts +12 -2
- package/dist/src/components/Select/index.js +178 -0
- package/dist/{components → src/components}/Select/utils/index.d.ts +1 -1
- package/dist/src/components/Select/utils/index.js +7 -0
- package/dist/{components → src/components}/StatusChip/index.js +14 -7
- package/dist/{components → src/components}/Svg/index.js +8 -1
- package/dist/{components → src/components}/Text/index.js +3 -1
- package/dist/{index.d.ts → src/index.d.ts} +2 -1
- package/dist/{index.js → src/index.js} +2 -1
- package/dist/src/scale/index.d.ts +8 -0
- package/dist/src/scale/index.js +13 -0
- package/dist/{theme → src/theme}/palette.js +2 -1
- package/dist/{ts → src/ts}/interfaces/colors.d.ts +3 -2
- package/package.json +3 -3
- package/dist/components/Select/Components/Dropdown/index.d.ts +0 -13
- package/dist/components/Select/Components/Icons/Chevron/index.d.ts +0 -18
- package/dist/components/Select/Components/Icons/Chevron/index.js +0 -19
- package/dist/components/Select/Components/Icons/Delete/index.d.ts +0 -18
- package/dist/components/Select/Components/Icons/Delete/index.js +0 -19
- package/dist/components/Select/index.js +0 -148
- package/dist/components/Select/utils/index.js +0 -8
- /package/dist/{components → src/components}/Avatar/index.d.ts +0 -0
- /package/dist/{components → src/components}/Avatar/utils/formatPlaceholder/index.d.ts +0 -0
- /package/dist/{components → src/components}/Avatar/utils/formatPlaceholder/index.js +0 -0
- /package/dist/{components → src/components}/Carousel/index.d.ts +0 -0
- /package/dist/{components → src/components}/Carousel/index.js +0 -0
- /package/dist/{components → src/components}/Carousel/utils/index.d.ts +0 -0
- /package/dist/{components → src/components}/Carousel/utils/index.js +0 -0
- /package/dist/{components → src/components}/CheckBox/icon/CheckedIcon.d.ts +0 -0
- /package/dist/{components → src/components}/CheckBox/icon/CheckedIcon.js +0 -0
- /package/dist/{components → src/components}/CheckBox/index.d.ts +0 -0
- /package/dist/{components → src/components}/Icon/assets/fonts/selection.json +0 -0
- /package/dist/{components → src/components}/Icon/index.d.ts +0 -0
- /package/dist/{components → src/components}/Image/index.d.ts +0 -0
- /package/dist/{components → src/components}/Image/index.js +0 -0
- /package/dist/{components → src/components}/Input/index.d.ts +0 -0
- /package/dist/{components → src/components}/Input/utils/index.d.ts +0 -0
- /package/dist/{components → src/components}/Input/utils/index.js +0 -0
- /package/dist/{components → src/components}/List/index.d.ts +0 -0
- /package/dist/{components → src/components}/List/index.js +0 -0
- /package/dist/{components → src/components}/Loading/LoadingSvg/index.d.ts +0 -0
- /package/dist/{components → src/components}/Loading/LoadingSvg/index.js +0 -0
- /package/dist/{components → src/components}/Loading/index.d.ts +0 -0
- /package/dist/{components → src/components}/LoadingFullScreen/index.d.ts +0 -0
- /package/dist/{components → src/components}/ProgressBar/index.d.ts +0 -0
- /package/dist/{components → src/components}/ProgressBar/utils/index.d.ts +0 -0
- /package/dist/{components → src/components}/ProgressBar/utils/index.js +0 -0
- /package/dist/{components → src/components}/RadioButton/index.d.ts +0 -0
- /package/dist/{components → src/components}/StatusChip/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/EmptyIllustration/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/EmptyIllustration/index.js +0 -0
- /package/dist/{components → src/components}/Svg/svgs/EmptyListIllustration/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/EmptyListIllustration/index.js +0 -0
- /package/dist/{components → src/components}/Svg/svgs/JanisLogo/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/JanisLogo/index.js +0 -0
- /package/dist/{components → src/components}/Svg/svgs/JanisLogoColor/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/JanisLogoColor/index.js +0 -0
- /package/dist/{components → src/components}/Svg/svgs/LoginIllustration/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/LoginIllustration/index.js +0 -0
- /package/dist/{components → src/components}/Svg/svgs/NoNotifications/index.d.ts +0 -0
- /package/dist/{components → src/components}/Svg/svgs/NoNotifications/index.js +0 -0
- /package/dist/{components → src/components}/SwipeUp/childComponents/index.d.ts +0 -0
- /package/dist/{components → src/components}/SwipeUp/childComponents/index.js +0 -0
- /package/dist/{components → src/components}/SwipeUp/index.d.ts +0 -0
- /package/dist/{components → src/components}/SwipeUp/index.js +0 -0
- /package/dist/{components → src/components}/Text/index.d.ts +0 -0
- /package/dist/{theme → src/theme}/palette.d.ts +0 -0
- /package/dist/{ts → src/ts}/interfaces/colors.js +0 -0
- /package/dist/{ts → src/ts}/interfaces/svgs.d.ts +0 -0
- /package/dist/{ts → src/ts}/interfaces/svgs.js +0 -0
package/dist/env.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "LOAD_STORYBOOK": true, "WEB_MODE": false }
|
|
@@ -3,6 +3,7 @@ import { StyleSheet, View } from 'react-native';
|
|
|
3
3
|
import Image from '../Image';
|
|
4
4
|
import Text from '../Text';
|
|
5
5
|
import { formatPlaceholder } from './utils/formatPlaceholder/index';
|
|
6
|
+
import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
|
|
6
7
|
export const sizeValues = {
|
|
7
8
|
sm: 24,
|
|
8
9
|
md: 36,
|
|
@@ -25,6 +26,13 @@ const Avatar = ({ size = 'sm', textColor = '#FFFFFF', bgColor = '#E8EAF6', image
|
|
|
25
26
|
return null;
|
|
26
27
|
}
|
|
27
28
|
const initials = formatPlaceholder(String(placeholder));
|
|
29
|
+
const calculateBorderRadius = getSize(size, customSize) / 2;
|
|
30
|
+
const calculateSize = getSize(size, customSize);
|
|
31
|
+
const calculateFontSize = getSize(size, customSize) * 0.4;
|
|
32
|
+
const validBorderRadius = scaledForDevice(calculateBorderRadius, moderateScale);
|
|
33
|
+
const validWidth = scaledForDevice(calculateSize, horizontalScale);
|
|
34
|
+
const validHeight = scaledForDevice(calculateSize, moderateScale);
|
|
35
|
+
const validFontSize = scaledForDevice(calculateFontSize, moderateScale);
|
|
28
36
|
const handleOnErrorImage = () => {
|
|
29
37
|
setShowInitials(true);
|
|
30
38
|
if (onErrorImg) {
|
|
@@ -35,22 +43,20 @@ const Avatar = ({ size = 'sm', textColor = '#FFFFFF', bgColor = '#E8EAF6', image
|
|
|
35
43
|
styles.container,
|
|
36
44
|
{
|
|
37
45
|
backgroundColor: bgColor,
|
|
38
|
-
borderRadius:
|
|
39
|
-
height:
|
|
40
|
-
width:
|
|
46
|
+
borderRadius: validBorderRadius,
|
|
47
|
+
height: validHeight,
|
|
48
|
+
width: validWidth,
|
|
41
49
|
},
|
|
42
50
|
style,
|
|
43
51
|
]} {...props}>
|
|
44
52
|
{!!imageUrl && !showInitials && (<Image accessibilityRole="image" onError={handleOnErrorImage} onLoad={() => setShowInitials(false)} source={{
|
|
45
53
|
uri: imageUrl,
|
|
46
54
|
}} style={{
|
|
47
|
-
height:
|
|
48
|
-
width:
|
|
55
|
+
height: validHeight,
|
|
56
|
+
width: validWidth,
|
|
49
57
|
}}/>)}
|
|
50
58
|
|
|
51
|
-
{(showInitials || !imageUrl) && !!initials.length && (<Text style={[styles.text, { color: textColor, fontSize:
|
|
52
|
-
{initials}
|
|
53
|
-
</Text>)}
|
|
59
|
+
{(showInitials || !imageUrl) && !!initials.length && (<Text style={[styles.text, { color: textColor, fontSize: validFontSize }]}>{initials}</Text>)}
|
|
54
60
|
</View>);
|
|
55
61
|
};
|
|
56
62
|
export default Avatar;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { PressableProps, ViewStyle } from 'react-native';
|
|
2
|
+
import { PressableProps, ViewStyle, TextStyle } from 'react-native';
|
|
3
3
|
interface BaseButtonProps extends PressableProps {
|
|
4
4
|
title?: string | null;
|
|
5
5
|
icon?: string;
|
|
@@ -9,7 +9,7 @@ interface BaseButtonProps extends PressableProps {
|
|
|
9
9
|
pressedColor?: string;
|
|
10
10
|
style?: ViewStyle;
|
|
11
11
|
iconStyle?: ViewStyle;
|
|
12
|
-
textStyle?:
|
|
12
|
+
textStyle?: TextStyle;
|
|
13
13
|
children?: React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
declare const BaseButton: FC<BaseButtonProps>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Pressable, StyleSheet } from 'react-native';
|
|
3
|
+
import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
|
|
3
4
|
import { palette } from '../../theme/palette';
|
|
4
5
|
import Text from '../Text';
|
|
5
6
|
import Icon from '../Icon';
|
|
@@ -10,24 +11,30 @@ const BaseButton = ({ title = null, icon = null, iconRight = false, disabled = f
|
|
|
10
11
|
const bgColor = !disabled ? palette.primary.main : palette.grey[200];
|
|
11
12
|
const iconPaddingLeft = iconRight && title ? 8 : 0;
|
|
12
13
|
const iconPaddingRight = !iconRight && title ? 8 : 0;
|
|
14
|
+
const validatePaddingVertical = scaledForDevice(10, moderateScale);
|
|
15
|
+
const validatePaddingHorizontal = scaledForDevice(16, horizontalScale);
|
|
16
|
+
const validateFontSize = scaledForDevice(14, moderateScale);
|
|
17
|
+
const validateBorderRadius = scaledForDevice(borderRadius, moderateScale);
|
|
18
|
+
const validatePaddingRightIcon = scaledForDevice(iconPaddingRight, horizontalScale);
|
|
19
|
+
const validatePaddingLeftIcon = scaledForDevice(iconPaddingLeft, horizontalScale);
|
|
13
20
|
const styles = StyleSheet.create({
|
|
14
21
|
container: {
|
|
15
22
|
display: 'flex',
|
|
16
23
|
flexDirection: 'row',
|
|
17
24
|
alignItems: 'center',
|
|
18
25
|
justifyContent: 'center',
|
|
19
|
-
paddingHorizontal:
|
|
20
|
-
paddingVertical:
|
|
21
|
-
borderRadius,
|
|
26
|
+
paddingHorizontal: validatePaddingHorizontal,
|
|
27
|
+
paddingVertical: validatePaddingVertical,
|
|
28
|
+
borderRadius: validateBorderRadius,
|
|
22
29
|
backgroundColor: bgColor,
|
|
23
30
|
},
|
|
24
31
|
icon: {
|
|
25
32
|
color: palette.base.white,
|
|
26
|
-
paddingRight:
|
|
27
|
-
paddingLeft:
|
|
33
|
+
paddingRight: validatePaddingRightIcon,
|
|
34
|
+
paddingLeft: validatePaddingLeftIcon,
|
|
28
35
|
},
|
|
29
36
|
title: {
|
|
30
|
-
fontSize:
|
|
37
|
+
fontSize: validateFontSize,
|
|
31
38
|
fontWeight: '500',
|
|
32
39
|
textAlign: 'center',
|
|
33
40
|
color: palette.base.white,
|
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
3
|
import { base, grey, primary } from '../../theme/palette';
|
|
4
|
+
import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
|
|
4
5
|
import Icon from './icon/CheckedIcon';
|
|
5
6
|
const getCheckBoxScale = (size, divisor) => size / divisor;
|
|
6
7
|
const CheckBox = ({ checked, customSize = 16, checkOnColor = primary.main, checkOffColor = grey[500], iconCheckColor = base.white, borderRadius, disabled = false, style, ...props }) => {
|
|
7
8
|
const hasBorderRadius = !borderRadius ? getCheckBoxScale(customSize, 4) : borderRadius;
|
|
9
|
+
const validateIconSize = scaledForDevice(customSize, moderateScale);
|
|
10
|
+
const validWidth = scaledForDevice(customSize, horizontalScale);
|
|
11
|
+
const validHeight = scaledForDevice(customSize, moderateScale);
|
|
12
|
+
const validBorderRadius = scaledForDevice(hasBorderRadius, moderateScale);
|
|
8
13
|
const styles = StyleSheet.create({
|
|
9
14
|
touchableOpacity: {
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
12
|
-
borderRadius:
|
|
15
|
+
width: validWidth,
|
|
16
|
+
height: validHeight,
|
|
17
|
+
borderRadius: validBorderRadius,
|
|
13
18
|
},
|
|
14
19
|
checkOn: {
|
|
15
20
|
display: 'flex',
|
|
16
21
|
justifyContent: 'center',
|
|
17
22
|
alignItems: 'center',
|
|
18
23
|
backgroundColor: !disabled ? checkOnColor : grey[200],
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
21
|
-
borderRadius:
|
|
24
|
+
width: validWidth,
|
|
25
|
+
height: validHeight,
|
|
26
|
+
borderRadius: validBorderRadius,
|
|
22
27
|
},
|
|
23
28
|
checkOff: {
|
|
24
29
|
borderWidth: getCheckBoxScale(customSize, 16),
|
|
25
30
|
borderColor: !disabled ? checkOffColor : grey[200],
|
|
26
|
-
width:
|
|
27
|
-
height:
|
|
31
|
+
width: validWidth,
|
|
32
|
+
height: validHeight,
|
|
28
33
|
borderRadius: hasBorderRadius,
|
|
29
34
|
},
|
|
30
35
|
});
|
|
31
36
|
const isChecked = checked ? styles.checkOn : styles.checkOff;
|
|
32
37
|
return (<TouchableOpacity disabled={disabled} activeOpacity={0.6} style={[styles.touchableOpacity, style]} {...props}>
|
|
33
|
-
<View style={isChecked}>
|
|
38
|
+
<View style={isChecked}>
|
|
39
|
+
{checked && <Icon color={iconCheckColor} size={validateIconSize}/>}
|
|
40
|
+
</View>
|
|
34
41
|
</TouchableOpacity>);
|
|
35
42
|
};
|
|
36
43
|
export default CheckBox;
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
|
|
3
3
|
import icoMoonConfig from './assets/fonts/selection.json';
|
|
4
4
|
import { primary } from '../../theme/palette';
|
|
5
|
+
import { moderateScale, scaledForDevice } from '../../scale';
|
|
5
6
|
const IconComponent = createIconSetFromIcoMoon(icoMoonConfig, 'janis-font-icon', 'janis-font-icon.ttf');
|
|
6
7
|
const Icon = ({ name, color = primary.main, size = 16, ...props }) => {
|
|
7
8
|
if (!name) {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
+
const validateSize = scaledForDevice(size, moderateScale);
|
|
12
|
+
return <IconComponent name={name} color={color} size={validateSize} {...props}/>;
|
|
11
13
|
};
|
|
12
14
|
export default Icon;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { TextInput, StyleSheet, View, Text, } from 'react-native';
|
|
3
3
|
import { getBorderColor, getInputInitialState, getLabelColor, getStatusMessageColor, raiseLabel, showStatusMessage, } from './utils';
|
|
4
|
+
import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
|
|
4
5
|
export var keyboardTypes;
|
|
5
6
|
(function (keyboardTypes) {
|
|
6
7
|
keyboardTypes["default"] = "default";
|
|
@@ -44,34 +45,40 @@ const Input = React.forwardRef(({ disabled = false, readOnly = false, label, pla
|
|
|
44
45
|
status,
|
|
45
46
|
});
|
|
46
47
|
const validStatusMessageColor = getStatusMessageColor(status);
|
|
48
|
+
const validBottom = scaledForDevice(25, moderateScale);
|
|
49
|
+
const validHeight = scaledForDevice(50, moderateScale);
|
|
50
|
+
const validBorderBottomWidth = scaledForDevice(1, horizontalScale);
|
|
51
|
+
const validLineHeight = scaledForDevice(19, moderateScale);
|
|
52
|
+
const validFontSize = scaledForDevice(16, moderateScale);
|
|
53
|
+
const validateMarginTop = scaledForDevice(5, moderateScale);
|
|
47
54
|
const styles = StyleSheet.create({
|
|
48
55
|
container: {
|
|
49
56
|
width: '100%',
|
|
50
57
|
},
|
|
51
58
|
inputWrapper: {
|
|
52
|
-
height:
|
|
59
|
+
height: validHeight,
|
|
53
60
|
borderBottomColor: validBorderColor,
|
|
54
|
-
borderBottomWidth:
|
|
61
|
+
borderBottomWidth: validBorderBottomWidth,
|
|
55
62
|
justifyContent: 'flex-end',
|
|
56
63
|
},
|
|
57
64
|
label: {
|
|
58
65
|
color: validLabelColor,
|
|
59
|
-
fontSize:
|
|
66
|
+
fontSize: validFontSize,
|
|
60
67
|
letterSpacing: 0,
|
|
61
|
-
lineHeight:
|
|
68
|
+
lineHeight: validLineHeight,
|
|
62
69
|
position: 'absolute',
|
|
63
|
-
bottom: raiseLabel({ disabled, hasMessage, inputState }) ?
|
|
70
|
+
bottom: raiseLabel({ disabled, hasMessage, inputState }) ? validBottom : 0,
|
|
64
71
|
},
|
|
65
72
|
input: {
|
|
66
73
|
color: valueColor,
|
|
67
|
-
fontSize:
|
|
74
|
+
fontSize: validFontSize,
|
|
68
75
|
letterSpacing: 0,
|
|
69
|
-
lineHeight:
|
|
76
|
+
lineHeight: validLineHeight,
|
|
70
77
|
padding: 0,
|
|
71
78
|
},
|
|
72
79
|
statusMessage: {
|
|
73
80
|
color: validStatusMessageColor,
|
|
74
|
-
marginTop:
|
|
81
|
+
marginTop: validateMarginTop,
|
|
75
82
|
},
|
|
76
83
|
});
|
|
77
84
|
return (<View style={styles.container}>
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { StyleSheet, View, Animated, Easing } from 'react-native';
|
|
3
3
|
import LoadingSvg from './LoadingSvg';
|
|
4
4
|
import { primary } from '../../theme/palette';
|
|
5
|
+
import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
|
|
5
6
|
const startRotationAnimation = ({ duration, rotationDegree, timingAnimation }) => Animated.loop(Animated.timing(rotationDegree, {
|
|
6
7
|
duration,
|
|
7
8
|
toValue: 360,
|
|
@@ -10,13 +11,16 @@ const startRotationAnimation = ({ duration, rotationDegree, timingAnimation }) =
|
|
|
10
11
|
})).start();
|
|
11
12
|
const Loading = ({ isLoading, color = primary.main, size = 64, duration = 1000, children = null, style, ...props }) => {
|
|
12
13
|
const rotationDegree = useRef(new Animated.Value(0)).current;
|
|
14
|
+
const validWidth = scaledForDevice(size, horizontalScale);
|
|
15
|
+
const validHeight = scaledForDevice(size, moderateScale);
|
|
16
|
+
const validSize = scaledForDevice(size, moderateScale);
|
|
13
17
|
const styles = StyleSheet.create({
|
|
14
18
|
container: {
|
|
15
19
|
position: 'relative',
|
|
16
20
|
justifyContent: 'center',
|
|
17
21
|
alignItems: 'center',
|
|
18
|
-
width:
|
|
19
|
-
height:
|
|
22
|
+
width: validWidth,
|
|
23
|
+
height: validHeight,
|
|
20
24
|
},
|
|
21
25
|
spinner: {
|
|
22
26
|
position: 'absolute',
|
|
@@ -49,7 +53,7 @@ const Loading = ({ isLoading, color = primary.main, size = 64, duration = 1000,
|
|
|
49
53
|
return <></>;
|
|
50
54
|
}
|
|
51
55
|
return (<View style={[styles.container, style]} {...props}>
|
|
52
|
-
<LoadingSvg style={[styles.spinner, { ...animationSpinnerStyle }]} size={
|
|
56
|
+
<LoadingSvg style={[styles.spinner, { ...animationSpinnerStyle }]} size={validSize} color={color}/>
|
|
53
57
|
{children}
|
|
54
58
|
</View>);
|
|
55
59
|
};
|
|
@@ -3,6 +3,12 @@ import { StyleSheet, Modal, Text, View } from 'react-native';
|
|
|
3
3
|
import Loading from '../Loading';
|
|
4
4
|
import Svg from '../Svg';
|
|
5
5
|
import { grey, white } from '../../theme/palette';
|
|
6
|
+
import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
|
|
7
|
+
const validFontSize = scaledForDevice(16, moderateScale);
|
|
8
|
+
const validLineHeight = scaledForDevice(24, moderateScale);
|
|
9
|
+
const validMarginTop = scaledForDevice(25, moderateScale);
|
|
10
|
+
const validWidth = scaledForDevice(36, horizontalScale);
|
|
11
|
+
const validHeight = scaledForDevice(25, moderateScale);
|
|
6
12
|
const styles = StyleSheet.create({
|
|
7
13
|
ContainerStyles: {
|
|
8
14
|
flex: 1,
|
|
@@ -11,14 +17,14 @@ const styles = StyleSheet.create({
|
|
|
11
17
|
backgroundColor: white.semiTransparent,
|
|
12
18
|
},
|
|
13
19
|
TextStyles: {
|
|
14
|
-
fontSize:
|
|
15
|
-
lineHeight:
|
|
20
|
+
fontSize: validFontSize,
|
|
21
|
+
lineHeight: validLineHeight,
|
|
16
22
|
fontFamily: 'Roboto',
|
|
17
23
|
color: grey[700],
|
|
18
24
|
textAlign: 'center',
|
|
19
25
|
fontWeight: '500',
|
|
20
26
|
width: '50%',
|
|
21
|
-
marginTop:
|
|
27
|
+
marginTop: validMarginTop,
|
|
22
28
|
},
|
|
23
29
|
});
|
|
24
30
|
const LoadingFullScreen = ({ text, isLoading, svgName = 'janis-logo', spinnerDuration = 2000, style, ...props }) => {
|
|
@@ -26,7 +32,7 @@ const LoadingFullScreen = ({ text, isLoading, svgName = 'janis-logo', spinnerDur
|
|
|
26
32
|
return (<Modal visible={isLoading} transparent animationType="fade" testID="loading modal" {...props}>
|
|
27
33
|
<View style={[styles.ContainerStyles, style]}>
|
|
28
34
|
<Loading isLoading={isLoading} duration={spinnerDuration}>
|
|
29
|
-
<Svg name={svgName} width={
|
|
35
|
+
<Svg name={svgName} width={validWidth} height={validHeight}/>
|
|
30
36
|
</Loading>
|
|
31
37
|
{hasTextPassed && <Text style={styles.TextStyles}>{text}</Text>}
|
|
32
38
|
</View>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
1
2
|
import React, { useEffect, useRef } from 'react';
|
|
2
3
|
import { View, StyleSheet, Animated, Easing } from 'react-native';
|
|
3
4
|
import { palette } from '../../theme/palette';
|
|
4
5
|
import { getBarColor, getPercentage } from './utils';
|
|
6
|
+
import { moderateScale, scaledForDevice } from '../../scale';
|
|
5
7
|
const ProgressBar = ({ value, totalValue, isAnimated = false, duration = 300, style, ...props }) => {
|
|
6
8
|
const { white } = palette;
|
|
7
9
|
const widthAnimation = useRef(new Animated.Value(0)).current;
|
|
@@ -22,20 +24,23 @@ const ProgressBar = ({ value, totalValue, isAnimated = false, duration = 300, st
|
|
|
22
24
|
widthAnimation.setValue(percentValue);
|
|
23
25
|
}
|
|
24
26
|
}, [isAnimated, percentValue, timeDuration, widthAnimation]);
|
|
27
|
+
const validHeight = scaledForDevice(4, moderateScale);
|
|
28
|
+
const validBorderRadius = scaledForDevice(2, moderateScale);
|
|
29
|
+
const validMarginTop = scaledForDevice(12, moderateScale);
|
|
25
30
|
const styles = StyleSheet.create({
|
|
26
31
|
container: {
|
|
27
32
|
position: 'relative',
|
|
28
33
|
width: '100%',
|
|
29
|
-
height:
|
|
30
|
-
marginTop:
|
|
31
|
-
borderRadius:
|
|
34
|
+
height: validHeight,
|
|
35
|
+
marginTop: validMarginTop,
|
|
36
|
+
borderRadius: validBorderRadius,
|
|
32
37
|
backgroundColor: white.main,
|
|
33
38
|
},
|
|
34
39
|
fill: {
|
|
35
40
|
position: 'absolute',
|
|
36
41
|
left: 0,
|
|
37
|
-
height:
|
|
38
|
-
borderRadius:
|
|
42
|
+
height: validHeight,
|
|
43
|
+
borderRadius: validBorderRadius,
|
|
39
44
|
zIndex: 10,
|
|
40
45
|
backgroundColor: colorValue,
|
|
41
46
|
},
|
|
@@ -2,17 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import CheckBox from '../CheckBox';
|
|
5
|
+
import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
|
|
5
6
|
const checkLocation = ['left', 'right'];
|
|
6
7
|
const CheckSizeValues = {
|
|
7
8
|
sm: 16,
|
|
8
9
|
md: 24,
|
|
9
10
|
lg: 32,
|
|
10
11
|
};
|
|
12
|
+
const validPaddingHorizontal = scaledForDevice(16, horizontalScale);
|
|
13
|
+
const validMarginVertical = scaledForDevice(10, moderateScale);
|
|
14
|
+
const validMarginHorizontal = scaledForDevice(15, horizontalScale);
|
|
11
15
|
const styles = StyleSheet.create({
|
|
12
16
|
container: {
|
|
13
17
|
alignItems: 'center',
|
|
14
|
-
paddingHorizontal:
|
|
15
|
-
marginVertical:
|
|
18
|
+
paddingHorizontal: validPaddingHorizontal,
|
|
19
|
+
marginVertical: validMarginVertical,
|
|
16
20
|
height: 'auto',
|
|
17
21
|
},
|
|
18
22
|
row: {
|
|
@@ -24,10 +28,10 @@ const styles = StyleSheet.create({
|
|
|
24
28
|
justifyContent: 'space-between',
|
|
25
29
|
},
|
|
26
30
|
checkToLeft: {
|
|
27
|
-
marginLeft:
|
|
31
|
+
marginLeft: validMarginHorizontal,
|
|
28
32
|
},
|
|
29
33
|
checkToRight: {
|
|
30
|
-
marginRight:
|
|
34
|
+
marginRight: validMarginHorizontal,
|
|
31
35
|
},
|
|
32
36
|
});
|
|
33
37
|
const RadioButton = ({ children, onPress, selected = false, checkPosition = 'left', checkSize = 'sm', disabled = false, style, ...props }) => {
|
|
@@ -39,7 +43,7 @@ const RadioButton = ({ children, onPress, selected = false, checkPosition = 'lef
|
|
|
39
43
|
const checkLeft = checkPosition === 'left';
|
|
40
44
|
const customSize = CheckSizeValues[checkSize];
|
|
41
45
|
return (<TouchableOpacity style={[container, checkLeft ? row : reverseRow, style]} disabled={disabled} onPress={onPress} {...props}>
|
|
42
|
-
<CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2}/>
|
|
46
|
+
<CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2} onPress={onPress}/>
|
|
43
47
|
<View style={checkLeft ? checkToLeft : checkToRight}>
|
|
44
48
|
{isStringChild ? <Text>{children}</Text> : children}
|
|
45
49
|
</View>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { DropdownMeasures } from '../..';
|
|
3
|
+
export interface DropdownProps {
|
|
4
|
+
show: boolean;
|
|
5
|
+
setShow: (isShowed: boolean) => void;
|
|
6
|
+
children: React.Component | React.ReactNode;
|
|
7
|
+
measures: DropdownMeasures;
|
|
8
|
+
}
|
|
9
|
+
declare const Dropdown: FC<DropdownProps>;
|
|
10
|
+
export default Dropdown;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
const Dropdown = ({ show, setShow, children, measures }) => {
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
background: {
|
|
6
|
+
width: '100%',
|
|
7
|
+
height: '100%',
|
|
8
|
+
},
|
|
9
|
+
dropdown: {
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
height: '100%',
|
|
12
|
+
width: measures.width,
|
|
13
|
+
top: measures.pageY,
|
|
14
|
+
left: measures.pageX,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return (<Modal animationType="fade" transparent visible={show}>
|
|
18
|
+
<Pressable style={styles.background} onPress={() => setShow(false)}>
|
|
19
|
+
<View style={styles.dropdown}>{children}</View>
|
|
20
|
+
</Pressable>
|
|
21
|
+
</Modal>);
|
|
22
|
+
};
|
|
23
|
+
export default Dropdown;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal as ModalComponent, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { base, primary, white } from '../../../../theme/palette';
|
|
4
|
+
import BaseButton from '../../../BaseButton';
|
|
5
|
+
import { moderateScale, scaledForDevice } from '../../../../scale';
|
|
6
|
+
const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
7
|
+
const validBottom = scaledForDevice(20, moderateScale);
|
|
8
|
+
const validMinWidth = scaledForDevice(270, moderateScale);
|
|
9
|
+
const validPaddingTop = scaledForDevice(24, moderateScale);
|
|
10
|
+
const validPaddingBottom = scaledForDevice(12, moderateScale);
|
|
11
|
+
const validPaddingHorizontal = scaledForDevice(20, moderateScale);
|
|
12
|
+
const validLeft = scaledForDevice(8, moderateScale);
|
|
13
|
+
const validTop = scaledForDevice(4, moderateScale);
|
|
14
|
+
const validFontSize = scaledForDevice(13, moderateScale);
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
background: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
backgroundColor: '#0009',
|
|
23
|
+
},
|
|
24
|
+
containerModal: {
|
|
25
|
+
justifyContent: 'space-between',
|
|
26
|
+
},
|
|
27
|
+
contentWrapper: {
|
|
28
|
+
bottom: validBottom,
|
|
29
|
+
minWidth: validMinWidth,
|
|
30
|
+
paddingTop: validPaddingTop,
|
|
31
|
+
paddingBottom: validPaddingBottom,
|
|
32
|
+
paddingLeft: validPaddingHorizontal,
|
|
33
|
+
paddingRight: validPaddingHorizontal,
|
|
34
|
+
backgroundColor: base.white,
|
|
35
|
+
elevation: 5,
|
|
36
|
+
},
|
|
37
|
+
buttonWrapper: {
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
justifyContent: 'flex-end',
|
|
40
|
+
flexWrap: 'wrap',
|
|
41
|
+
left: validLeft,
|
|
42
|
+
top: validTop,
|
|
43
|
+
},
|
|
44
|
+
button: {
|
|
45
|
+
backgroundColor: base.white,
|
|
46
|
+
},
|
|
47
|
+
buttonText: {
|
|
48
|
+
color: primary.main,
|
|
49
|
+
fontSize: validFontSize,
|
|
50
|
+
fontWeight: '700',
|
|
51
|
+
textTransform: 'uppercase',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return (<ModalComponent animationType="fade" transparent visible={show}>
|
|
55
|
+
<View style={styles.background}>
|
|
56
|
+
<View style={styles.contentWrapper}>
|
|
57
|
+
<View style={styles.containerModal}>{children}</View>
|
|
58
|
+
{isMulti && (<View style={styles.buttonWrapper}>
|
|
59
|
+
<BaseButton title={modalAcceptText} iconRight={false} pressedColor={white.main} style={styles.button} textStyle={styles.buttonText} onPress={() => setShow(false)}/>
|
|
60
|
+
</View>)}
|
|
61
|
+
</View>
|
|
62
|
+
</View>
|
|
63
|
+
</ModalComponent>);
|
|
64
|
+
};
|
|
65
|
+
export default Modal;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CustomOptionComponent, DropdownMeasures, Option, VariantOptions } from '../..';
|
|
3
|
+
interface OptionsProps {
|
|
4
|
+
variantOptions: VariantOptions;
|
|
5
|
+
dropdownMeasures: DropdownMeasures;
|
|
6
|
+
isShowedOptions: boolean;
|
|
7
|
+
setIsShowedOptions: (isShowed: boolean) => void;
|
|
8
|
+
filteredOptions: Option[];
|
|
9
|
+
selectedOptions: Option[];
|
|
10
|
+
noOptionsMessage: string;
|
|
11
|
+
optionStyles?: {};
|
|
12
|
+
callbackOption: (option: Option) => void;
|
|
13
|
+
customOptionComponent?: CustomOptionComponent | null;
|
|
14
|
+
isMulti: boolean;
|
|
15
|
+
modalAcceptText: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Options: FC<OptionsProps>;
|
|
18
|
+
export default Options;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, StyleSheet, TouchableOpacity, ScrollView, Text } from 'react-native';
|
|
3
3
|
import { base, black, grey, primary, white } from '../../../../theme/palette';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
4
|
+
import SwitcherComponent from '../SwitcherComponent';
|
|
5
|
+
const Options = (props) => {
|
|
6
|
+
const { variantOptions, dropdownMeasures, isShowedOptions, setIsShowedOptions, filteredOptions, callbackOption, selectedOptions, noOptionsMessage, optionStyles, customOptionComponent = null, isMulti, modalAcceptText, } = props;
|
|
9
7
|
const handleSelectedOption = (option) => callbackOption(option);
|
|
8
|
+
const isModal = variantOptions === 'Modal';
|
|
10
9
|
const styles = StyleSheet.create({
|
|
11
10
|
container: {
|
|
11
|
+
position: 'relative',
|
|
12
12
|
width: '100%',
|
|
13
|
-
padding: 8,
|
|
13
|
+
padding: !isModal ? 8 : 0,
|
|
14
14
|
},
|
|
15
15
|
optionWrapper: {
|
|
16
|
-
position: 'absolute',
|
|
16
|
+
position: !isModal ? 'absolute' : 'relative',
|
|
17
17
|
maxHeight: 168,
|
|
18
|
+
minHeight: 'auto',
|
|
18
19
|
borderColor: grey[200],
|
|
19
20
|
backgroundColor: base.white,
|
|
20
21
|
width: '100%',
|
|
21
|
-
top: 60,
|
|
22
|
+
top: !isModal ? 60 : 0,
|
|
22
23
|
marginBottom: 20,
|
|
23
|
-
elevation: 5,
|
|
24
|
-
zIndex: 10,
|
|
24
|
+
elevation: !isModal ? 5 : 0,
|
|
25
25
|
flex: 1,
|
|
26
26
|
},
|
|
27
27
|
option: {
|
|
@@ -66,8 +66,10 @@ const Dropdown = (props) => {
|
|
|
66
66
|
const noRenderOptions = (<View aria-disabled>
|
|
67
67
|
<Text style={styles.noOptionText}> {noOptionsMessage}</Text>
|
|
68
68
|
</View>);
|
|
69
|
-
return (<
|
|
70
|
-
{
|
|
71
|
-
|
|
69
|
+
return (<SwitcherComponent measures={dropdownMeasures} variant={variantOptions} show={isShowedOptions} setShow={setIsShowedOptions} isMulti={isMulti} modalAcceptText={modalAcceptText}>
|
|
70
|
+
<ScrollView style={styles.optionWrapper} contentContainerStyle={styles.container}>
|
|
71
|
+
{filteredOptions?.length ? renderOptions : noRenderOptions}
|
|
72
|
+
</ScrollView>
|
|
73
|
+
</SwitcherComponent>);
|
|
72
74
|
};
|
|
73
|
-
export default
|
|
75
|
+
export default Options;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { DropdownMeasures, VariantOptions } from '../..';
|
|
3
|
+
interface SwitcherProps {
|
|
4
|
+
show: boolean;
|
|
5
|
+
isMulti: boolean;
|
|
6
|
+
variant: VariantOptions;
|
|
7
|
+
measures: DropdownMeasures;
|
|
8
|
+
children: React.Component | React.ReactNode;
|
|
9
|
+
modalAcceptText: string;
|
|
10
|
+
setShow: (isShowed: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const SwitcherComponent: FC<SwitcherProps>;
|
|
13
|
+
export default SwitcherComponent;
|
|
@@ -9,6 +9,15 @@ declare enum KeyboardTypes {
|
|
|
9
9
|
PhonePad = "phone-pad",
|
|
10
10
|
URL = "url"
|
|
11
11
|
}
|
|
12
|
+
export declare enum VariantOptions {
|
|
13
|
+
Dropdown = "Dropdown",
|
|
14
|
+
Modal = "Modal"
|
|
15
|
+
}
|
|
16
|
+
export interface DropdownMeasures {
|
|
17
|
+
width: number;
|
|
18
|
+
pageY: number;
|
|
19
|
+
pageX: number;
|
|
20
|
+
}
|
|
12
21
|
export interface Option {
|
|
13
22
|
label: string;
|
|
14
23
|
value: string | number;
|
|
@@ -23,11 +32,11 @@ export type CustomOptionComponent = (props: CustomOptionComponentProps) => React
|
|
|
23
32
|
interface SelectProps {
|
|
24
33
|
options: Option[];
|
|
25
34
|
label: string;
|
|
26
|
-
value?:
|
|
35
|
+
value?: Option[];
|
|
36
|
+
variantOptions?: VariantOptions;
|
|
27
37
|
optionStyles?: {};
|
|
28
38
|
placeholder?: string;
|
|
29
39
|
inputProps?: TextInput;
|
|
30
|
-
isSearchable?: boolean;
|
|
31
40
|
isMulti?: boolean;
|
|
32
41
|
isDisabled?: boolean;
|
|
33
42
|
noOptionsMessage?: string;
|
|
@@ -36,6 +45,7 @@ interface SelectProps {
|
|
|
36
45
|
onFocus?: () => void;
|
|
37
46
|
onSelectOption?: (selectedOptions: Option[]) => void;
|
|
38
47
|
customOptionComponent?: CustomOptionComponent | null;
|
|
48
|
+
modalAcceptText?: string;
|
|
39
49
|
}
|
|
40
50
|
declare const Select: FC<SelectProps>;
|
|
41
51
|
export default Select;
|