@janiscommerce/ui-native 1.5.0 → 1.7.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/components/BaseButton/index.d.ts +6 -12
- package/dist/components/BaseButton/index.js +9 -43
- package/dist/components/Button/index.d.ts +50 -0
- package/dist/components/Button/index.js +54 -0
- package/dist/components/Button/types/index.d.ts +45 -0
- package/dist/components/Button/types/index.js +1 -0
- package/dist/components/Button/utils/getButtonStyles/index.d.ts +3 -0
- package/dist/components/Button/utils/getButtonStyles/index.js +84 -0
- package/dist/components/Button/utils/getButtonStyles/utils/constants/index.d.ts +5 -0
- package/dist/components/Button/utils/getButtonStyles/utils/constants/index.js +5 -0
- package/dist/components/Button/utils/getButtonStyles/utils/defaultValues/index.d.ts +5 -0
- package/dist/components/Button/utils/getButtonStyles/utils/defaultValues/index.js +5 -0
- package/dist/components/Button/utils/getButtonStyles/utils/styleConfigs/index.d.ts +118 -0
- package/dist/components/Button/utils/getButtonStyles/utils/styleConfigs/index.js +121 -0
- package/dist/components/FullScreenMessage/index.d.ts +21 -0
- package/dist/components/FullScreenMessage/index.js +66 -0
- package/dist/components/Select/Components/Modal/index.js +3 -9
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/package.json +4 -4
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PressableProps
|
|
3
|
-
interface BaseButtonProps extends PressableProps {
|
|
4
|
-
title?: string | null;
|
|
5
|
-
icon?: string;
|
|
6
|
-
iconRight?: boolean;
|
|
7
|
-
disabled?: boolean;
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { PressableProps } from 'react-native';
|
|
3
|
+
export interface BaseButtonProps extends PressableProps {
|
|
8
4
|
borderRadius?: number;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
textStyle?: TextStyle;
|
|
13
|
-
children?: React.ReactNode;
|
|
5
|
+
children?: ReactNode | null;
|
|
6
|
+
pressedStyle?: ReactNode;
|
|
7
|
+
style?: any;
|
|
14
8
|
}
|
|
15
9
|
declare const BaseButton: FC<BaseButtonProps>;
|
|
16
10
|
export default BaseButton;
|
|
@@ -1,58 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Pressable, StyleSheet } from 'react-native';
|
|
3
|
-
import { moderateScale,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import Icon from '../Icon';
|
|
7
|
-
const BaseButton = ({ title = null, icon = null, iconRight = false, disabled = false, borderRadius = 0, pressedColor, style, iconStyle, textStyle, children = null, ...props }) => {
|
|
8
|
-
if (!title && !icon && !children) {
|
|
3
|
+
import { moderateScale, scaledForDevice } from '../../scale';
|
|
4
|
+
const BaseButton = ({ borderRadius = 0, children = null, style, pressedStyle, ...props }) => {
|
|
5
|
+
if (!children) {
|
|
9
6
|
return null;
|
|
10
7
|
}
|
|
11
|
-
const bgColor = !disabled ? palette.primary.main : palette.grey[200];
|
|
12
|
-
const iconPaddingLeft = iconRight && title ? 8 : 0;
|
|
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
8
|
const validateBorderRadius = scaledForDevice(borderRadius, moderateScale);
|
|
18
|
-
const validatePaddingRightIcon = scaledForDevice(iconPaddingRight, horizontalScale);
|
|
19
|
-
const validatePaddingLeftIcon = scaledForDevice(iconPaddingLeft, horizontalScale);
|
|
20
9
|
const styles = StyleSheet.create({
|
|
21
10
|
container: {
|
|
22
|
-
display: 'flex',
|
|
23
|
-
flexDirection: 'row',
|
|
24
11
|
alignItems: 'center',
|
|
25
12
|
justifyContent: 'center',
|
|
26
|
-
paddingHorizontal: validatePaddingHorizontal,
|
|
27
|
-
paddingVertical: validatePaddingVertical,
|
|
28
13
|
borderRadius: validateBorderRadius,
|
|
29
|
-
backgroundColor: bgColor,
|
|
30
|
-
},
|
|
31
|
-
icon: {
|
|
32
|
-
color: palette.base.white,
|
|
33
|
-
paddingRight: validatePaddingRightIcon,
|
|
34
|
-
paddingLeft: validatePaddingLeftIcon,
|
|
35
|
-
},
|
|
36
|
-
title: {
|
|
37
|
-
fontSize: validateFontSize,
|
|
38
|
-
fontWeight: '500',
|
|
39
|
-
textAlign: 'center',
|
|
40
|
-
color: palette.base.white,
|
|
41
14
|
},
|
|
42
15
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const PressableStyle = ({ pressed }) => {
|
|
50
|
-
const backgroundColor = pressedColor ?? palette.primary.dark;
|
|
51
|
-
const pressedBgColor = pressed ? [{ backgroundColor }] : [];
|
|
52
|
-
return [styles.container, style, ...pressedBgColor];
|
|
53
|
-
};
|
|
54
|
-
return (<Pressable style={PressableStyle} disabled={disabled} {...props}>
|
|
55
|
-
{children ?? noChildren}
|
|
16
|
+
return (<Pressable style={({ pressed }) => [
|
|
17
|
+
styles.container,
|
|
18
|
+
style,
|
|
19
|
+
pressed && /* istanbul ignore next */ pressedStyle,
|
|
20
|
+
]} {...props}>
|
|
21
|
+
{children}
|
|
56
22
|
</Pressable>);
|
|
57
23
|
};
|
|
58
24
|
export default BaseButton;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ViewStyle, TextStyle } from 'react-native';
|
|
3
|
+
import { BaseButtonProps } from '../BaseButton';
|
|
4
|
+
export declare const types: {
|
|
5
|
+
main: string;
|
|
6
|
+
secondary: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const variant: {
|
|
9
|
+
contained: string;
|
|
10
|
+
outlined: string;
|
|
11
|
+
text: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const color: {
|
|
14
|
+
primary: string;
|
|
15
|
+
black: string;
|
|
16
|
+
success: string;
|
|
17
|
+
error: string;
|
|
18
|
+
warning: string;
|
|
19
|
+
alert: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const iconPosition: {
|
|
22
|
+
top: string;
|
|
23
|
+
bottom: string;
|
|
24
|
+
left: string;
|
|
25
|
+
right: string;
|
|
26
|
+
};
|
|
27
|
+
export type buttonType = typeof types;
|
|
28
|
+
export type keyType = keyof buttonType;
|
|
29
|
+
export type buttonVariant = typeof variant;
|
|
30
|
+
export type keyVariant = keyof buttonVariant;
|
|
31
|
+
export type buttonColor = typeof color;
|
|
32
|
+
export type keyColor = keyof buttonColor;
|
|
33
|
+
export type buttonIconPosition = typeof iconPosition;
|
|
34
|
+
export type keyIconPosition = keyof buttonIconPosition;
|
|
35
|
+
interface ButtonProps extends BaseButtonProps {
|
|
36
|
+
type?: keyType;
|
|
37
|
+
variant?: keyVariant;
|
|
38
|
+
color?: keyColor;
|
|
39
|
+
isLoading?: boolean;
|
|
40
|
+
value?: string | null;
|
|
41
|
+
icon?: string;
|
|
42
|
+
iconPosition?: keyIconPosition;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
style?: ViewStyle;
|
|
45
|
+
pressedStyle?: ViewStyle;
|
|
46
|
+
iconStyle?: TextStyle;
|
|
47
|
+
textStyle?: TextStyle;
|
|
48
|
+
}
|
|
49
|
+
declare const Button: FC<ButtonProps>;
|
|
50
|
+
export default Button;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import BaseButton from '../BaseButton';
|
|
4
|
+
import getButtonStyles from './utils/getButtonStyles';
|
|
5
|
+
import Loading from '../Loading';
|
|
6
|
+
import Text from '../Text';
|
|
7
|
+
import Icon from '../Icon';
|
|
8
|
+
export const types = {
|
|
9
|
+
main: 'main',
|
|
10
|
+
secondary: 'secondary',
|
|
11
|
+
};
|
|
12
|
+
export const variant = {
|
|
13
|
+
contained: 'contained',
|
|
14
|
+
outlined: 'outlined',
|
|
15
|
+
text: 'text',
|
|
16
|
+
};
|
|
17
|
+
export const color = {
|
|
18
|
+
primary: 'primary',
|
|
19
|
+
black: 'black',
|
|
20
|
+
success: 'success',
|
|
21
|
+
error: 'error',
|
|
22
|
+
warning: 'warning',
|
|
23
|
+
alert: 'alert',
|
|
24
|
+
};
|
|
25
|
+
export const iconPosition = {
|
|
26
|
+
top: 'top',
|
|
27
|
+
bottom: 'bottom',
|
|
28
|
+
left: 'left',
|
|
29
|
+
right: 'right',
|
|
30
|
+
};
|
|
31
|
+
const Button = ({ type = 'main', variant = 'contained', color = 'primary', iconPosition = 'left', isLoading = false, value = 'Button', icon = null, disabled = false, style, iconStyle, textStyle, ...props }) => {
|
|
32
|
+
const validDisabled = disabled || isLoading;
|
|
33
|
+
const hasIconAndText = !!icon && !!value;
|
|
34
|
+
const borderRadius = variant === 'text' ? 6 : 50;
|
|
35
|
+
const buttonStyles = getButtonStyles({
|
|
36
|
+
type,
|
|
37
|
+
variant,
|
|
38
|
+
color,
|
|
39
|
+
iconPosition,
|
|
40
|
+
isLoading,
|
|
41
|
+
isDisabled: disabled,
|
|
42
|
+
hasIconAndText,
|
|
43
|
+
});
|
|
44
|
+
const styles = StyleSheet.create(buttonStyles);
|
|
45
|
+
const LoadingCompontent = <Loading isLoading={isLoading} color={styles.loadingColor} size={24}/>;
|
|
46
|
+
const WrapperComponent = (<View style={styles.direction}>
|
|
47
|
+
{icon && <Icon name={icon} style={[styles.icon, iconStyle]} size={24}/>}
|
|
48
|
+
{value && <Text style={[styles.text, textStyle]}>{value}</Text>}
|
|
49
|
+
</View>);
|
|
50
|
+
return (<BaseButton style={[styles.container, style]} pressedStyle={!validDisabled && styles.pressed} borderRadius={borderRadius} disabled={validDisabled} {...props}>
|
|
51
|
+
{isLoading ? LoadingCompontent : WrapperComponent}
|
|
52
|
+
</BaseButton>);
|
|
53
|
+
};
|
|
54
|
+
export default Button;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { keyColor, keyIconPosition, keyType, keyVariant } from '../';
|
|
2
|
+
export interface SelectedColor {
|
|
3
|
+
main: string;
|
|
4
|
+
dark: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Params {
|
|
7
|
+
type: keyType;
|
|
8
|
+
variant: keyVariant;
|
|
9
|
+
color: keyColor;
|
|
10
|
+
iconPosition: keyIconPosition;
|
|
11
|
+
isLoading: Boolean;
|
|
12
|
+
isDisabled: Boolean;
|
|
13
|
+
hasIconAndText?: Boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ReturnStyles {
|
|
16
|
+
container: object;
|
|
17
|
+
direction: object;
|
|
18
|
+
pressed: object;
|
|
19
|
+
icon: object;
|
|
20
|
+
text: object;
|
|
21
|
+
loadingColor: any;
|
|
22
|
+
}
|
|
23
|
+
export interface ContainerStyle {
|
|
24
|
+
isDisabled: Boolean;
|
|
25
|
+
isLoading: Boolean;
|
|
26
|
+
color: keyColor;
|
|
27
|
+
variant: keyVariant;
|
|
28
|
+
type: keyType;
|
|
29
|
+
iconPosition: keyIconPosition;
|
|
30
|
+
}
|
|
31
|
+
export interface TextStyle {
|
|
32
|
+
type: keyType;
|
|
33
|
+
variant: keyVariant;
|
|
34
|
+
color: keyColor;
|
|
35
|
+
isDisabled: Boolean;
|
|
36
|
+
isLoading: Boolean;
|
|
37
|
+
hasIconAndText?: Boolean;
|
|
38
|
+
iconPosition: keyIconPosition;
|
|
39
|
+
}
|
|
40
|
+
export interface LoadingStyle {
|
|
41
|
+
color: keyColor;
|
|
42
|
+
}
|
|
43
|
+
export interface DirectionStyle {
|
|
44
|
+
iconPosition: keyIconPosition;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { moderateScale, scaledForDevice } from '../../../../scale';
|
|
2
|
+
import { palette } from '../../../../theme/palette';
|
|
3
|
+
import { colorConfig, styleConfig } from './utils/styleConfigs';
|
|
4
|
+
import { validTypes, validVariants, validIconPositions, verticalHeights } from './utils/constants';
|
|
5
|
+
import { defaultColor, defaultIconPosition, defaultType, defaultVariant, } from './utils/defaultValues';
|
|
6
|
+
const containerStyle = ({ isDisabled, isLoading, color, variant, type, iconPosition, }) => {
|
|
7
|
+
const selectedColor = palette[color] || palette[defaultColor];
|
|
8
|
+
const { main, disabled } = colorConfig(selectedColor);
|
|
9
|
+
const { container } = styleConfig;
|
|
10
|
+
const validType = validTypes.includes(type) ? type : defaultType;
|
|
11
|
+
const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
|
|
12
|
+
const mainBgColor = main.background[validVariant];
|
|
13
|
+
const mainBorderColor = main.border[validVariant];
|
|
14
|
+
const disabledBgColor = disabled.background[validVariant];
|
|
15
|
+
const disabledBorderColor = disabled.border[validType][validVariant];
|
|
16
|
+
const containerHeight = container.height[validType];
|
|
17
|
+
// validation of height
|
|
18
|
+
const hasVerticalHeight = verticalHeights.includes(iconPosition);
|
|
19
|
+
return {
|
|
20
|
+
borderWidth: 1,
|
|
21
|
+
borderColor: isDisabled || isLoading ? disabledBorderColor : mainBorderColor,
|
|
22
|
+
backgroundColor: isDisabled || isLoading ? disabledBgColor : mainBgColor,
|
|
23
|
+
paddingHorizontal: scaledForDevice(type === 'main' ? 12 : 8, moderateScale),
|
|
24
|
+
...(hasVerticalHeight && { paddingVertical: scaledForDevice(10, moderateScale) }),
|
|
25
|
+
...(!hasVerticalHeight && {
|
|
26
|
+
height: variant !== 'text' ? containerHeight : scaledForDevice(35, moderateScale),
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const pressedStyle = ({ variant, color }) => {
|
|
31
|
+
const selectedColor = palette[color] || palette[defaultColor];
|
|
32
|
+
const { pressed } = colorConfig(selectedColor);
|
|
33
|
+
const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
|
|
34
|
+
return {
|
|
35
|
+
borderColor: pressed.border[validVariant],
|
|
36
|
+
backgroundColor: pressed.background[validVariant],
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const directionWrapperStyle = ({ iconPosition }) => {
|
|
40
|
+
const { directionWrapper } = styleConfig;
|
|
41
|
+
const flexCenter = directionWrapper.center;
|
|
42
|
+
const validIconPosition = validIconPositions.includes(iconPosition)
|
|
43
|
+
? iconPosition
|
|
44
|
+
: defaultIconPosition;
|
|
45
|
+
const flexDirection = directionWrapper.flexDirection[validIconPosition];
|
|
46
|
+
return {
|
|
47
|
+
...flexCenter,
|
|
48
|
+
flexDirection,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const baseTextStyle = ({ isDisabled, type, variant, color, isLoading }) => {
|
|
52
|
+
const selectedColor = palette[color] || palette[defaultColor];
|
|
53
|
+
const { main, disabled } = colorConfig(selectedColor);
|
|
54
|
+
const { text: textStyle } = styleConfig;
|
|
55
|
+
const validType = validTypes.includes(type) ? type : defaultType;
|
|
56
|
+
const validVariant = validVariants.includes(variant) ? variant : defaultVariant;
|
|
57
|
+
const mainTextColor = main.text[validType][validVariant];
|
|
58
|
+
const disabledTextColor = disabled.text[validType][validVariant];
|
|
59
|
+
return {
|
|
60
|
+
...textStyle,
|
|
61
|
+
color: isDisabled || isLoading ? disabledTextColor : mainTextColor,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const textStyle = (params) => ({
|
|
65
|
+
...baseTextStyle(params),
|
|
66
|
+
fontSize: scaledForDevice(14, moderateScale),
|
|
67
|
+
});
|
|
68
|
+
const iconStyle = (params) => {
|
|
69
|
+
const { hasIconAndText, iconPosition } = params;
|
|
70
|
+
const { icon } = styleConfig;
|
|
71
|
+
return {
|
|
72
|
+
...baseTextStyle(params),
|
|
73
|
+
...((!!hasIconAndText && icon.margin[iconPosition]) || {}),
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
const getButtonStyles = (params) => ({
|
|
77
|
+
container: containerStyle(params),
|
|
78
|
+
pressed: pressedStyle(params),
|
|
79
|
+
direction: directionWrapperStyle(params),
|
|
80
|
+
text: textStyle(params),
|
|
81
|
+
icon: iconStyle(params),
|
|
82
|
+
loadingColor: palette.primary.main,
|
|
83
|
+
});
|
|
84
|
+
export default getButtonStyles;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const verticalHeights = ['top', 'bottom'];
|
|
2
|
+
const validTypes = ['main', 'secondary'];
|
|
3
|
+
const validVariants = ['contained', 'outlined', 'text'];
|
|
4
|
+
const validIconPositions = ['top', 'bottom', 'left', 'right'];
|
|
5
|
+
export { verticalHeights, validTypes, validVariants, validIconPositions };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { SelectedColor } from '../../../../types';
|
|
2
|
+
export declare const colorConfig: (selectedColor: SelectedColor) => {
|
|
3
|
+
main: {
|
|
4
|
+
background: {
|
|
5
|
+
contained: string;
|
|
6
|
+
outlined: string;
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
border: {
|
|
10
|
+
contained: string;
|
|
11
|
+
outlined: string;
|
|
12
|
+
text: string;
|
|
13
|
+
};
|
|
14
|
+
text: {
|
|
15
|
+
main: {
|
|
16
|
+
contained: string;
|
|
17
|
+
outlined: string;
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
secondary: {
|
|
21
|
+
contained: string;
|
|
22
|
+
outlined: string;
|
|
23
|
+
text: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
pressed: {
|
|
28
|
+
background: {
|
|
29
|
+
contained: string;
|
|
30
|
+
outlined: string;
|
|
31
|
+
text: string;
|
|
32
|
+
};
|
|
33
|
+
border: {
|
|
34
|
+
contained: string;
|
|
35
|
+
outlined: string;
|
|
36
|
+
text: string;
|
|
37
|
+
};
|
|
38
|
+
text: {
|
|
39
|
+
main: {
|
|
40
|
+
contained: string;
|
|
41
|
+
outlined: string;
|
|
42
|
+
text: string;
|
|
43
|
+
};
|
|
44
|
+
secondary: {
|
|
45
|
+
contained: string;
|
|
46
|
+
outlined: string;
|
|
47
|
+
text: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
disabled: {
|
|
52
|
+
background: {
|
|
53
|
+
contained: string;
|
|
54
|
+
outlined: string;
|
|
55
|
+
text: string;
|
|
56
|
+
};
|
|
57
|
+
border: {
|
|
58
|
+
main: {
|
|
59
|
+
contained: string;
|
|
60
|
+
outlined: string;
|
|
61
|
+
text: string;
|
|
62
|
+
};
|
|
63
|
+
secondary: {
|
|
64
|
+
contained: string;
|
|
65
|
+
outlined: string;
|
|
66
|
+
text: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
text: {
|
|
70
|
+
main: {
|
|
71
|
+
contained: string;
|
|
72
|
+
outlined: string;
|
|
73
|
+
text: string;
|
|
74
|
+
};
|
|
75
|
+
secondary: {
|
|
76
|
+
contained: string;
|
|
77
|
+
outlined: string;
|
|
78
|
+
text: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export declare const styleConfig: {
|
|
84
|
+
container: {
|
|
85
|
+
height: {
|
|
86
|
+
main: number;
|
|
87
|
+
secondary: number;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
directionWrapper: {
|
|
91
|
+
center: {
|
|
92
|
+
justifyContent: string;
|
|
93
|
+
alignItems: string;
|
|
94
|
+
};
|
|
95
|
+
flexDirection: {
|
|
96
|
+
left: string;
|
|
97
|
+
right: string;
|
|
98
|
+
top: string;
|
|
99
|
+
bottom: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
text: {
|
|
103
|
+
fontWeight: string;
|
|
104
|
+
textAlign: string;
|
|
105
|
+
};
|
|
106
|
+
icon: {
|
|
107
|
+
margin: {
|
|
108
|
+
top: {};
|
|
109
|
+
bottom: {};
|
|
110
|
+
left: {
|
|
111
|
+
marginRight: number;
|
|
112
|
+
};
|
|
113
|
+
right: {
|
|
114
|
+
marginLeft: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { moderateScale, scaledForDevice } from '../../../../../../scale';
|
|
2
|
+
import { base, black, grey, white } from '../../../../../../theme/palette';
|
|
3
|
+
export const colorConfig = (selectedColor) => {
|
|
4
|
+
return {
|
|
5
|
+
main: {
|
|
6
|
+
background: {
|
|
7
|
+
contained: selectedColor.main,
|
|
8
|
+
outlined: base.white,
|
|
9
|
+
text: 'transparent',
|
|
10
|
+
},
|
|
11
|
+
border: {
|
|
12
|
+
contained: 'transparent',
|
|
13
|
+
outlined: grey[300],
|
|
14
|
+
text: 'transparent',
|
|
15
|
+
},
|
|
16
|
+
text: {
|
|
17
|
+
main: {
|
|
18
|
+
contained: base.white,
|
|
19
|
+
outlined: black.main,
|
|
20
|
+
text: black.main,
|
|
21
|
+
},
|
|
22
|
+
secondary: {
|
|
23
|
+
contained: base.white,
|
|
24
|
+
outlined: selectedColor.main,
|
|
25
|
+
text: selectedColor.main,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
pressed: {
|
|
30
|
+
background: {
|
|
31
|
+
contained: selectedColor.dark,
|
|
32
|
+
outlined: base.white,
|
|
33
|
+
text: white.main,
|
|
34
|
+
},
|
|
35
|
+
border: {
|
|
36
|
+
contained: 'transparent',
|
|
37
|
+
outlined: selectedColor.main,
|
|
38
|
+
text: 'transparent',
|
|
39
|
+
},
|
|
40
|
+
text: {
|
|
41
|
+
main: {
|
|
42
|
+
contained: base.white,
|
|
43
|
+
outlined: black.main,
|
|
44
|
+
text: black.main,
|
|
45
|
+
},
|
|
46
|
+
secondary: {
|
|
47
|
+
contained: base.white,
|
|
48
|
+
outlined: selectedColor.main,
|
|
49
|
+
text: selectedColor.dark,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
disabled: {
|
|
54
|
+
background: {
|
|
55
|
+
contained: grey[200],
|
|
56
|
+
outlined: grey[100],
|
|
57
|
+
text: 'transparent',
|
|
58
|
+
},
|
|
59
|
+
border: {
|
|
60
|
+
main: {
|
|
61
|
+
contained: 'transparent',
|
|
62
|
+
outlined: 'transparent',
|
|
63
|
+
text: 'transparent',
|
|
64
|
+
},
|
|
65
|
+
secondary: {
|
|
66
|
+
contained: 'transparent',
|
|
67
|
+
outlined: grey[300],
|
|
68
|
+
text: 'transparent',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
text: {
|
|
72
|
+
main: {
|
|
73
|
+
contained: grey[400],
|
|
74
|
+
outlined: grey[300],
|
|
75
|
+
text: grey[300],
|
|
76
|
+
},
|
|
77
|
+
secondary: {
|
|
78
|
+
contained: grey[400],
|
|
79
|
+
outlined: grey[300],
|
|
80
|
+
text: grey[300],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export const styleConfig = {
|
|
87
|
+
container: {
|
|
88
|
+
height: {
|
|
89
|
+
main: scaledForDevice(50, moderateScale),
|
|
90
|
+
secondary: scaledForDevice(42, moderateScale),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
directionWrapper: {
|
|
94
|
+
center: {
|
|
95
|
+
justifyContent: 'center',
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
},
|
|
98
|
+
flexDirection: {
|
|
99
|
+
left: 'row',
|
|
100
|
+
right: 'row-reverse',
|
|
101
|
+
top: 'column',
|
|
102
|
+
bottom: 'column-reverse',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
text: {
|
|
106
|
+
fontWeight: '500',
|
|
107
|
+
textAlign: 'center',
|
|
108
|
+
},
|
|
109
|
+
icon: {
|
|
110
|
+
margin: {
|
|
111
|
+
top: {},
|
|
112
|
+
bottom: {},
|
|
113
|
+
left: {
|
|
114
|
+
marginRight: scaledForDevice(8, moderateScale),
|
|
115
|
+
},
|
|
116
|
+
right: {
|
|
117
|
+
marginLeft: scaledForDevice(8, moderateScale),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC, ReactElement } from 'react';
|
|
2
|
+
export declare enum animationTypes {
|
|
3
|
+
Slide = "slide",
|
|
4
|
+
Fade = "fade",
|
|
5
|
+
None = "none"
|
|
6
|
+
}
|
|
7
|
+
interface Props {
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
isVisible?: boolean;
|
|
10
|
+
title?: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
iconName?: string;
|
|
13
|
+
textsColor?: string;
|
|
14
|
+
iconColor?: string;
|
|
15
|
+
animationType?: animationTypes;
|
|
16
|
+
duration?: number;
|
|
17
|
+
onEndDuration?: () => void;
|
|
18
|
+
children?: ReactElement | null;
|
|
19
|
+
}
|
|
20
|
+
declare const FullScreenMessage: FC<Props>;
|
|
21
|
+
export default FullScreenMessage;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Modal, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { moderateScale, scaledForDevice } from '../../scale';
|
|
4
|
+
import { base, primary } from '../../theme/palette';
|
|
5
|
+
import Icon from '../Icon';
|
|
6
|
+
import Text from '../Text';
|
|
7
|
+
export var animationTypes;
|
|
8
|
+
(function (animationTypes) {
|
|
9
|
+
animationTypes["Slide"] = "slide";
|
|
10
|
+
animationTypes["Fade"] = "fade";
|
|
11
|
+
animationTypes["None"] = "none";
|
|
12
|
+
})(animationTypes || (animationTypes = {}));
|
|
13
|
+
const FullScreenMessage = ({ backgroundColor = primary.main, title = '', isVisible = false, subtitle = '', iconName = '', textsColor = base.white, iconColor = base.white, animationType = animationTypes.Slide, duration = 3000, onEndDuration = () => { }, children = null, ...props }) => {
|
|
14
|
+
const validTitle = !!title && typeof title === 'string';
|
|
15
|
+
const validSubtitle = !!subtitle && typeof subtitle === 'string';
|
|
16
|
+
const validIconName = !!iconName && typeof iconName === 'string';
|
|
17
|
+
const validPaddingHorizontal = scaledForDevice(50, moderateScale);
|
|
18
|
+
const validMarginBottomTitle = scaledForDevice(30, moderateScale);
|
|
19
|
+
const validMarginBottomSubtitle = scaledForDevice(50, moderateScale);
|
|
20
|
+
const validFontTitle = scaledForDevice(32, moderateScale);
|
|
21
|
+
const validFontSubtitle = scaledForDevice(16, moderateScale);
|
|
22
|
+
const validLineHeightTitle = scaledForDevice(40, moderateScale);
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
container: {
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
width: '100%',
|
|
28
|
+
height: '100%',
|
|
29
|
+
backgroundColor: backgroundColor,
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
fontWeight: 'bold',
|
|
33
|
+
textAlign: 'center',
|
|
34
|
+
color: textsColor,
|
|
35
|
+
paddingHorizontal: validPaddingHorizontal,
|
|
36
|
+
marginBottom: validMarginBottomTitle,
|
|
37
|
+
fontSize: validFontTitle,
|
|
38
|
+
lineHeight: validLineHeightTitle,
|
|
39
|
+
},
|
|
40
|
+
subtitle: {
|
|
41
|
+
textAlign: 'center',
|
|
42
|
+
color: textsColor,
|
|
43
|
+
paddingHorizontal: validPaddingHorizontal,
|
|
44
|
+
marginBottom: validMarginBottomSubtitle,
|
|
45
|
+
fontSize: validFontSubtitle,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (isVisible) {
|
|
50
|
+
setTimeout(() => {
|
|
51
|
+
onEndDuration();
|
|
52
|
+
}, duration);
|
|
53
|
+
}
|
|
54
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
|
+
}, [isVisible]);
|
|
56
|
+
return (<Modal visible={isVisible} animationType={animationType} transparent {...props}>
|
|
57
|
+
<View style={styles.container}>
|
|
58
|
+
{children ?? (<>
|
|
59
|
+
{validTitle && <Text style={styles.title}>{title}</Text>}
|
|
60
|
+
{validSubtitle && <Text style={styles.subtitle}>{subtitle}</Text>}
|
|
61
|
+
{validIconName && <Icon color={iconColor} size={130} name={iconName}/>}
|
|
62
|
+
</>)}
|
|
63
|
+
</View>
|
|
64
|
+
</Modal>);
|
|
65
|
+
};
|
|
66
|
+
export default FullScreenMessage;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Modal as ModalComponent, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { base
|
|
4
|
-
import BaseButton from '../../../BaseButton';
|
|
3
|
+
import { base } from '../../../../theme/palette';
|
|
5
4
|
import { moderateScale, scaledForDevice } from '../../../../scale';
|
|
5
|
+
import Button from '../../../Button';
|
|
6
6
|
const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
7
7
|
const validBottom = scaledForDevice(20, moderateScale);
|
|
8
8
|
const validMinWidth = scaledForDevice(270, moderateScale);
|
|
@@ -11,7 +11,6 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
|
11
11
|
const validPaddingHorizontal = scaledForDevice(20, moderateScale);
|
|
12
12
|
const validLeft = scaledForDevice(8, moderateScale);
|
|
13
13
|
const validTop = scaledForDevice(4, moderateScale);
|
|
14
|
-
const validFontSize = scaledForDevice(13, moderateScale);
|
|
15
14
|
const styles = StyleSheet.create({
|
|
16
15
|
background: {
|
|
17
16
|
display: 'flex',
|
|
@@ -41,12 +40,7 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
|
41
40
|
left: validLeft,
|
|
42
41
|
top: validTop,
|
|
43
42
|
},
|
|
44
|
-
button: {
|
|
45
|
-
backgroundColor: base.white,
|
|
46
|
-
},
|
|
47
43
|
buttonText: {
|
|
48
|
-
color: primary.main,
|
|
49
|
-
fontSize: validFontSize,
|
|
50
44
|
fontWeight: '700',
|
|
51
45
|
textTransform: 'uppercase',
|
|
52
46
|
},
|
|
@@ -56,7 +50,7 @@ const Modal = ({ show, setShow, isMulti, modalAcceptText, children }) => {
|
|
|
56
50
|
<View style={styles.contentWrapper}>
|
|
57
51
|
<View style={styles.containerModal}>{children}</View>
|
|
58
52
|
{isMulti && (<View style={styles.buttonWrapper}>
|
|
59
|
-
<
|
|
53
|
+
<Button value={modalAcceptText} variant={'text'} type={'secondary'} textStyle={styles.buttonText} onPress={() => setShow(false)}/>
|
|
60
54
|
</View>)}
|
|
61
55
|
</View>
|
|
62
56
|
</View>
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import Carousel from './components/Carousel';
|
|
|
17
17
|
import ProgressBar from './components/ProgressBar';
|
|
18
18
|
import List from './components/List';
|
|
19
19
|
import BaseButton from './components/BaseButton';
|
|
20
|
+
import Button from './components/Button/index';
|
|
21
|
+
import FullScreenMessage from './components/FullScreenMessage';
|
|
20
22
|
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
21
23
|
import * as getScale from './scale';
|
|
22
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, getScale, LayoutWithBottomButtons, };
|
|
24
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, };
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,8 @@ import Carousel from './components/Carousel';
|
|
|
17
17
|
import ProgressBar from './components/ProgressBar';
|
|
18
18
|
import List from './components/List';
|
|
19
19
|
import BaseButton from './components/BaseButton';
|
|
20
|
+
import Button from './components/Button/index';
|
|
21
|
+
import FullScreenMessage from './components/FullScreenMessage';
|
|
20
22
|
import LayoutWithBottomButtons from './components/LayoutWithBottomButtons';
|
|
21
23
|
import * as getScale from './scale';
|
|
22
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, getScale, LayoutWithBottomButtons, };
|
|
24
|
+
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@janiscommerce/ui-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "components library for Janis app",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/janis-commerce/ui-native#readme",
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"react": ">=17.0.2
|
|
47
|
-
"react-native": ">=0.67.5
|
|
48
|
-
"react-native-gesture-handler": ">=2.9.0
|
|
46
|
+
"react": ">=17.0.2",
|
|
47
|
+
"react-native": ">=0.67.5",
|
|
48
|
+
"react-native-gesture-handler": ">=2.9.0",
|
|
49
49
|
"react-native-reanimated": "2.17.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|