@janiscommerce/ui-native 1.11.0 → 1.13.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/atoms/BaseInput/index.d.ts +1 -1
- package/dist/components/atoms/BaseInput/index.js +2 -15
- package/dist/components/atoms/RadioButton/index.js +2 -2
- package/dist/components/atoms/StatusChip/index.js +2 -2
- package/dist/components/atoms/Text/index.d.ts +1 -1
- package/dist/components/atoms/Text/index.js +5 -0
- package/dist/components/atoms/Typography/index.d.ts +12 -0
- package/dist/components/atoms/Typography/index.js +13 -0
- package/dist/components/atoms/Typography/utils/getStyleByTypography/index.d.ts +17 -0
- package/dist/components/atoms/Typography/utils/getStyleByTypography/index.js +54 -0
- package/dist/components/molecules/Avatar/index.js +4 -2
- package/dist/components/molecules/Button/index.js +2 -2
- package/dist/components/molecules/Carousel/utils/index.d.ts +1 -1
- package/dist/components/molecules/Input/index.d.ts +26 -0
- package/dist/components/molecules/Input/index.js +84 -0
- package/dist/components/molecules/Input/utils/handleChangeText/index.d.ts +4 -0
- package/dist/components/molecules/Input/utils/handleChangeText/index.js +19 -0
- package/dist/components/molecules/Tabs/index.js +3 -3
- package/dist/components/molecules/Toast/index.js +4 -4
- package/dist/components/organisms/FullScreenMessage/index.js +7 -3
- package/dist/components/organisms/SwipeItemSelectionList/index.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/theme/typography.d.ts +35 -0
- package/dist/theme/typography.js +29 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +5 -0
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextInput, TextInputProps } from 'react-native';
|
|
3
|
-
interface BaseInputProps extends TextInputProps {
|
|
3
|
+
export interface BaseInputProps extends TextInputProps {
|
|
4
4
|
placeholder?: string;
|
|
5
5
|
onChangeText?: (text: string) => void;
|
|
6
6
|
style?: any;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
3
3
|
import { palette } from '../../../theme/palette';
|
|
4
|
-
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
5
4
|
const BaseInput = forwardRef(({ value, placeholder, onChangeText, style, textAlign, ...props }, ref) => {
|
|
6
|
-
|
|
7
|
-
input: {
|
|
8
|
-
padding: 0,
|
|
9
|
-
height: scaledForDevice(70, moderateScale),
|
|
10
|
-
borderColor: palette.primary.main,
|
|
11
|
-
borderWidth: 2,
|
|
12
|
-
borderRadius: 8,
|
|
13
|
-
fontSize: scaledForDevice(42, moderateScale),
|
|
14
|
-
backgroundColor: palette.white.light,
|
|
15
|
-
color: palette.black.main,
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
return (<TextInput style={[styles.input, style]} ref={ref} value={value} placeholder={placeholder} textAlign={textAlign || 'center'} onChangeText={onChangeText} selectionColor={palette.primary.main} placeholderTextColor={palette.grey[500]} {...props}/>);
|
|
5
|
+
return (<TextInput style={[style]} ref={ref} value={value} placeholder={placeholder} textAlign={textAlign || 'center'} onChangeText={onChangeText} selectionColor={palette.primary.main} placeholderTextColor={palette.grey[500]} {...props}/>);
|
|
19
6
|
});
|
|
20
7
|
export default BaseInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import Typography from '../Typography';
|
|
4
4
|
import CheckBox from '../CheckBox';
|
|
5
5
|
import { horizontalScale, moderateScale, scaledForDevice } from '../../../scale';
|
|
6
6
|
const checkLocation = ['left', 'right'];
|
|
@@ -45,7 +45,7 @@ const RadioButton = ({ children, onPress, selected = false, checkPosition = 'lef
|
|
|
45
45
|
return (<TouchableOpacity style={[container, checkLeft ? row : reverseRow, style]} disabled={disabled} onPress={onPress} {...props}>
|
|
46
46
|
<CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2} onPress={onPress}/>
|
|
47
47
|
<View style={checkLeft ? checkToLeft : checkToRight}>
|
|
48
|
-
{isStringChild ? <
|
|
48
|
+
{isStringChild ? <Typography>{children}</Typography> : children}
|
|
49
49
|
</View>
|
|
50
50
|
</TouchableOpacity>);
|
|
51
51
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { isValidElement } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import { base, grey, primary } from '../../../theme/palette';
|
|
4
|
-
import
|
|
4
|
+
import Typography from '../Typography';
|
|
5
5
|
import { horizontalScale, moderateScale, scaledForDevice } from '../../../scale';
|
|
6
6
|
const validHeight = scaledForDevice(24, moderateScale);
|
|
7
7
|
const validPadding = scaledForDevice(12, horizontalScale);
|
|
@@ -38,7 +38,7 @@ const StatusChip = ({ children, ...props }) => {
|
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
return (<View style={styles(props).ViewStyles} {...props}>
|
|
41
|
-
{isCustomComponent ? children : <
|
|
41
|
+
{isCustomComponent ? (children) : (<Typography style={styles(props).TextStyles}>{children}</Typography>)}
|
|
42
42
|
</View>);
|
|
43
43
|
};
|
|
44
44
|
export default StatusChip;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
import { StyleProp, TextProps as TextComponentProps, TextStyle } from 'react-native';
|
|
3
|
-
interface TextProps extends TextComponentProps {
|
|
3
|
+
export interface TextProps extends TextComponentProps {
|
|
4
4
|
children?: ReactElement | string;
|
|
5
5
|
style?: StyleProp<TextStyle>;
|
|
6
6
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleSheet, Text as TextComponent, } from 'react-native';
|
|
3
3
|
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
4
|
+
import { isDevEnv } from '../../../utils/index';
|
|
4
5
|
const Text = ({ children, style, ...props }) => {
|
|
5
6
|
if (!children) {
|
|
6
7
|
return null;
|
|
@@ -12,6 +13,10 @@ const Text = ({ children, style, ...props }) => {
|
|
|
12
13
|
fontFamily: 'Roboto',
|
|
13
14
|
},
|
|
14
15
|
});
|
|
16
|
+
// istanbul ignore next
|
|
17
|
+
if (isDevEnv()) {
|
|
18
|
+
console.warn('This component is going to be deprecated soon.');
|
|
19
|
+
}
|
|
15
20
|
return (<TextComponent style={[styles.TextStyles, style]} {...props}>
|
|
16
21
|
{children}
|
|
17
22
|
</TextComponent>);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { StyleProp, TextStyle, TextProps } from 'react-native';
|
|
3
|
+
export type TypographyType = 'display' | 'heading' | 'title' | 'label' | 'body' | 'overline';
|
|
4
|
+
export type TypographySize = 'large' | 'medium' | 'small';
|
|
5
|
+
interface TypographyProps extends TextProps {
|
|
6
|
+
children?: ReactElement | string;
|
|
7
|
+
style?: StyleProp<TextStyle>;
|
|
8
|
+
type?: TypographyType;
|
|
9
|
+
size?: TypographySize;
|
|
10
|
+
}
|
|
11
|
+
declare const Typography: ({ children, style, type, size, ...props }: TypographyProps) => React.JSX.Element | null;
|
|
12
|
+
export default Typography;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import getStyleByTypography from './utils/getStyleByTypography';
|
|
4
|
+
const Typography = ({ children, style, type, size, ...props }) => {
|
|
5
|
+
if (!children) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const typographyStyles = getStyleByTypography(type, size);
|
|
9
|
+
return (<Text style={[style, typographyStyles.typography]} {...props}>
|
|
10
|
+
{children}
|
|
11
|
+
</Text>);
|
|
12
|
+
};
|
|
13
|
+
export default Typography;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TextStyle } from 'react-native';
|
|
2
|
+
import { Typography } from '../../../../../theme/typography';
|
|
3
|
+
type TypographyType = keyof Typography;
|
|
4
|
+
type TypographySize = 'large' | 'medium' | 'small';
|
|
5
|
+
export declare const defaultStyles: {
|
|
6
|
+
typography: TextStyle;
|
|
7
|
+
};
|
|
8
|
+
declare const getStyleByTypography: (type: TypographyType | string, size: TypographySize | string) => {
|
|
9
|
+
typography: TextStyle;
|
|
10
|
+
} | {
|
|
11
|
+
typography: {
|
|
12
|
+
fontWeight: "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
|
|
13
|
+
fontSize: number;
|
|
14
|
+
lineHeight: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default getStyleByTypography;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import typography from '../../../../../theme/typography';
|
|
3
|
+
const validTypes = Object.keys(typography);
|
|
4
|
+
const validSizes = ['large', 'medium', 'small'];
|
|
5
|
+
export const defaultStyles = StyleSheet.create({
|
|
6
|
+
typography: {
|
|
7
|
+
fontWeight: typography.body.medium.weight,
|
|
8
|
+
fontSize: typography.body.medium.size,
|
|
9
|
+
lineHeight: typography.body.medium.lineHeight,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const getStyleByTypography = (type, size) => {
|
|
13
|
+
if (!validTypes.includes(type) ||
|
|
14
|
+
!validSizes.includes(size)) {
|
|
15
|
+
return defaultStyles;
|
|
16
|
+
}
|
|
17
|
+
const typographyType = type;
|
|
18
|
+
const typographySize = size;
|
|
19
|
+
if (typographyType === 'display') {
|
|
20
|
+
return StyleSheet.create({
|
|
21
|
+
typography: {
|
|
22
|
+
fontWeight: typography.display.weight,
|
|
23
|
+
fontSize: typography.display.size,
|
|
24
|
+
lineHeight: typography.display.lineHeight,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (typographyType === 'overline' && typographySize === 'medium') {
|
|
29
|
+
return StyleSheet.create({
|
|
30
|
+
typography: {
|
|
31
|
+
fontWeight: typography.overline.large.weight,
|
|
32
|
+
fontSize: typography.overline.large.size,
|
|
33
|
+
lineHeight: typography.overline.large.lineHeight,
|
|
34
|
+
letterSpacing: typography.overline.large.spacing,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const typographyObject = typography[typographyType];
|
|
39
|
+
// istanbul ignore next
|
|
40
|
+
if (typographyObject && typographySize in typographyObject) {
|
|
41
|
+
const typographyStyle = typographyObject[typographySize];
|
|
42
|
+
return StyleSheet.create({
|
|
43
|
+
typography: {
|
|
44
|
+
fontWeight: typographyStyle.weight,
|
|
45
|
+
fontSize: typographyStyle.size,
|
|
46
|
+
lineHeight: typographyStyle.lineHeight,
|
|
47
|
+
letterSpacing: typographyStyle.spacing,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// istanbul ignore next
|
|
52
|
+
return defaultStyles;
|
|
53
|
+
};
|
|
54
|
+
export default getStyleByTypography;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { StyleSheet, View } from 'react-native';
|
|
3
3
|
import Image from '../../atoms/Image';
|
|
4
|
-
import
|
|
4
|
+
import Typography from '../../atoms/Typography';
|
|
5
5
|
import { formatPlaceholder } from './utils/formatPlaceholder/index';
|
|
6
6
|
import { horizontalScale, moderateScale, scaledForDevice } from '../../../scale';
|
|
7
7
|
export const sizeValues = {
|
|
@@ -56,7 +56,9 @@ const Avatar = ({ size = 'sm', textColor = '#FFFFFF', bgColor = '#E8EAF6', image
|
|
|
56
56
|
width: validWidth,
|
|
57
57
|
}}/>)}
|
|
58
58
|
|
|
59
|
-
{(showInitials || !imageUrl) && !!initials.length && (<
|
|
59
|
+
{(showInitials || !imageUrl) && !!initials.length && (<Typography style={[styles.text, { color: textColor, fontSize: validFontSize }]}>
|
|
60
|
+
{initials}
|
|
61
|
+
</Typography>)}
|
|
60
62
|
</View>);
|
|
61
63
|
};
|
|
62
64
|
export default Avatar;
|
|
@@ -3,7 +3,7 @@ import { StyleSheet, View } from 'react-native';
|
|
|
3
3
|
import BaseButton from '../../atoms/BaseButton';
|
|
4
4
|
import getButtonStyles from './utils/getButtonStyles';
|
|
5
5
|
import Loading from '../../atoms/Loading';
|
|
6
|
-
import
|
|
6
|
+
import Typography from '../../atoms/Typography';
|
|
7
7
|
import Icon from '../../atoms/Icon';
|
|
8
8
|
export const types = {
|
|
9
9
|
main: 'main',
|
|
@@ -48,7 +48,7 @@ const Button = ({ type = 'main', variant = 'contained', color = 'primary', iconP
|
|
|
48
48
|
const LoadingComponent = <Loading isLoading={isLoading} color={styles.loadingColor} size={24}/>;
|
|
49
49
|
const WrapperComponent = (<View style={styles.direction}>
|
|
50
50
|
{icon && <Icon name={icon} style={[styles.icon, iconStyle]} size={24}/>}
|
|
51
|
-
{!!value && <
|
|
51
|
+
{!!value && <Typography style={[styles.text, textStyle]}>{value}</Typography>}
|
|
52
52
|
</View>);
|
|
53
53
|
return (<BaseButton style={[styles.container, style]} pressedStyle={!validDisabled && styles.pressed} borderRadius={borderRadius} disabled={validDisabled} {...props}>
|
|
54
54
|
{isLoading ? LoadingComponent : WrapperComponent}
|
|
@@ -4,7 +4,7 @@ import { CarouselProps } from '../';
|
|
|
4
4
|
declare const useCarouselControls: ({ pages, isLoop, autoplay, autoPlayReverse, intervalTime, customWidth, buttonsCallback, pagesCallback, }: CarouselProps) => {
|
|
5
5
|
activePage: number;
|
|
6
6
|
slider: import("react").MutableRefObject<ScrollView | null>;
|
|
7
|
-
intervalId: import("react").MutableRefObject<
|
|
7
|
+
intervalId: import("react").MutableRefObject<any>;
|
|
8
8
|
width: number;
|
|
9
9
|
goPrev: () => void;
|
|
10
10
|
goNext: () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
3
|
+
import { BaseInputProps } from '../../atoms/BaseInput';
|
|
4
|
+
export type InputVariant = 'default' | 'weightable' | 'amountTotal' | 'currency' | 'numeric';
|
|
5
|
+
interface BaseInputPropsExtended extends BaseInputProps {
|
|
6
|
+
type?: 'currency' | 'number' | 'text' | 'email' | 'phone';
|
|
7
|
+
variant?: InputVariant;
|
|
8
|
+
onChangeText?: (text: string) => void;
|
|
9
|
+
totalValue?: number;
|
|
10
|
+
}
|
|
11
|
+
type AmountTotalProps = BaseInputPropsExtended & {
|
|
12
|
+
variant: 'amountTotal';
|
|
13
|
+
totalValue: number;
|
|
14
|
+
};
|
|
15
|
+
type OtherVariantProps = BaseInputPropsExtended & {
|
|
16
|
+
variant: Exclude<InputVariant, 'amountTotal'>;
|
|
17
|
+
totalValue?: never;
|
|
18
|
+
};
|
|
19
|
+
type DefaultProps = BaseInputPropsExtended & {
|
|
20
|
+
variant?: never;
|
|
21
|
+
type: 'currency' | 'number' | 'text' | 'email' | 'phone';
|
|
22
|
+
totalValue?: never;
|
|
23
|
+
};
|
|
24
|
+
export type InputProps = AmountTotalProps | OtherVariantProps | DefaultProps;
|
|
25
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<TextInput>>;
|
|
26
|
+
export default Input;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { forwardRef, useState, useRef } from 'react';
|
|
2
|
+
import { StyleSheet, View, TouchableWithoutFeedback, Keyboard } from 'react-native';
|
|
3
|
+
import BaseInput from '../../atoms/BaseInput';
|
|
4
|
+
import { palette } from '../../../theme/palette';
|
|
5
|
+
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
6
|
+
import handleChangeText from './utils/handleChangeText';
|
|
7
|
+
import Typography from '../../atoms/Typography';
|
|
8
|
+
var InputType;
|
|
9
|
+
(function (InputType) {
|
|
10
|
+
InputType["currency"] = "numeric";
|
|
11
|
+
InputType["number"] = "numeric";
|
|
12
|
+
InputType["default"] = "default";
|
|
13
|
+
InputType["text"] = "default";
|
|
14
|
+
InputType["email"] = "email-address";
|
|
15
|
+
InputType["phone"] = "phone-pad";
|
|
16
|
+
InputType["weightable"] = "numeric";
|
|
17
|
+
InputType["amountTotal"] = "numeric";
|
|
18
|
+
InputType["numeric"] = "numeric";
|
|
19
|
+
})(InputType || (InputType = {}));
|
|
20
|
+
const setRef = (ref, value) => {
|
|
21
|
+
if (typeof ref === 'function') {
|
|
22
|
+
ref(value);
|
|
23
|
+
}
|
|
24
|
+
else if (ref && 'current' in ref) {
|
|
25
|
+
ref.current = value;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const Input = forwardRef(({ style, type, variant = 'default', totalValue, onChangeText, ...props }, ref) => {
|
|
29
|
+
const [value, setValue] = useState('');
|
|
30
|
+
const isAmountTotalVariant = variant === 'amountTotal';
|
|
31
|
+
const inputRef = useRef(null);
|
|
32
|
+
if (isAmountTotalVariant && typeof totalValue !== 'number') {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
container: {
|
|
37
|
+
padding: 0,
|
|
38
|
+
height: scaledForDevice(70, moderateScale),
|
|
39
|
+
borderColor: palette.primary.main,
|
|
40
|
+
borderWidth: 2,
|
|
41
|
+
borderRadius: 8,
|
|
42
|
+
backgroundColor: palette.white.light,
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
},
|
|
47
|
+
input: {
|
|
48
|
+
color: palette.black.main,
|
|
49
|
+
fontSize: scaledForDevice(42, moderateScale),
|
|
50
|
+
},
|
|
51
|
+
totalValue: {
|
|
52
|
+
color: palette.primary.main,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const changeTextCb = (text) => handleChangeText(text, setValue, variant, onChangeText);
|
|
56
|
+
const handlePress = () => {
|
|
57
|
+
// istanbul ignore next
|
|
58
|
+
if (inputRef.current) {
|
|
59
|
+
Keyboard.dismiss();
|
|
60
|
+
inputRef.current.focus();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const resolvedKeyboardType = (() => {
|
|
64
|
+
if (type && type in InputType) {
|
|
65
|
+
return InputType[type];
|
|
66
|
+
}
|
|
67
|
+
if (variant && variant in InputType) {
|
|
68
|
+
return InputType[variant];
|
|
69
|
+
}
|
|
70
|
+
return InputType.default;
|
|
71
|
+
})();
|
|
72
|
+
return (<TouchableWithoutFeedback onPress={handlePress}>
|
|
73
|
+
<View style={styles.container}>
|
|
74
|
+
<BaseInput style={[styles.input, style]} ref={(instance) => {
|
|
75
|
+
setRef(inputRef, instance);
|
|
76
|
+
setRef(ref, instance);
|
|
77
|
+
}} value={value} keyboardType={resolvedKeyboardType} onChangeText={changeTextCb} {...props}/>
|
|
78
|
+
{isAmountTotalVariant && (<Typography style={styles.totalValue} type="display" size="medium">
|
|
79
|
+
{`/${totalValue?.toString()}`}
|
|
80
|
+
</Typography>)}
|
|
81
|
+
</View>
|
|
82
|
+
</TouchableWithoutFeedback>);
|
|
83
|
+
});
|
|
84
|
+
export default Input;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InputVariant } from '../../../Input';
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
declare const handleChangeText: (text: string, setValue: Dispatch<SetStateAction<string>>, variant: InputVariant, onChangeText?: ((text: string) => void) | undefined) => void;
|
|
4
|
+
export default handleChangeText;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const variantLogicMapper = {
|
|
2
|
+
default: (value) => value,
|
|
3
|
+
weightable: (value) => value.replace(',', '.').replace(/[^0-9.]/g, ''),
|
|
4
|
+
amountTotal: (value) => value.replace(',', '.').replace(/[^0-9.]/g, ''),
|
|
5
|
+
currency: (value) => value.replace(/[^0-9.,]/g, ''),
|
|
6
|
+
numeric: (value) => value.replace(/[^0-9.,]/g, ''),
|
|
7
|
+
};
|
|
8
|
+
const transformText = (text, variant) => {
|
|
9
|
+
const transform = variantLogicMapper[variant] || variantLogicMapper.default;
|
|
10
|
+
return transform(text);
|
|
11
|
+
};
|
|
12
|
+
const handleChangeText = (text, setValue, variant, onChangeText) => {
|
|
13
|
+
const transformedText = transformText(text, variant);
|
|
14
|
+
setValue(transformedText);
|
|
15
|
+
if (onChangeText) {
|
|
16
|
+
onChangeText(transformedText);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export default handleChangeText;
|
|
@@ -4,7 +4,7 @@ import { StyleSheet, View, ScrollView, FlatList } from 'react-native';
|
|
|
4
4
|
import { moderateScale, scaledForDevice, viewportWidth } from '../../../scale';
|
|
5
5
|
import { base, black, grey, primary } from '../../../theme/palette';
|
|
6
6
|
import BaseButton from '../../atoms/BaseButton';
|
|
7
|
-
import
|
|
7
|
+
import Typography from '../../atoms/Typography';
|
|
8
8
|
import { isObject } from '../../../utils';
|
|
9
9
|
export const positions = {
|
|
10
10
|
top: 'top',
|
|
@@ -90,9 +90,9 @@ const Tabs = ({ scenes, initialTab = null, position = positions.top, onPressTabC
|
|
|
90
90
|
return onPressTabCb(idx);
|
|
91
91
|
};
|
|
92
92
|
return (<BaseButton key={title + index} style={{ ...styles.tabButton, borderBottomColor }} disabled={disabled} onPress={() => handleOnPress(index)}>
|
|
93
|
-
<
|
|
93
|
+
<Typography style={{ ...styles.title, color: textColor }} selectable={false} numberOfLines={1}>
|
|
94
94
|
{title}
|
|
95
|
-
</
|
|
95
|
+
</Typography>
|
|
96
96
|
</BaseButton>);
|
|
97
97
|
};
|
|
98
98
|
const renderItem = ({ item, index }) => (<TitleTab title={item.title} disabled={item.disabled} index={index}/>);
|
|
@@ -6,7 +6,7 @@ import { defaultIcon } from './utils';
|
|
|
6
6
|
import { base, black } from '../../../theme/palette';
|
|
7
7
|
import BaseToast from '../../atoms/BaseToast';
|
|
8
8
|
import ToastAction from 'react-native-toast-message';
|
|
9
|
-
import
|
|
9
|
+
import Typography from '../../atoms/Typography';
|
|
10
10
|
import Icon from '../../atoms/Icon';
|
|
11
11
|
const Toast = ({ type, text1, text2, style, props }) => {
|
|
12
12
|
const validType = type && typeof type === 'string';
|
|
@@ -78,13 +78,13 @@ const Toast = ({ type, text1, text2, style, props }) => {
|
|
|
78
78
|
{showIcon && (<Icon name={selectedIconName} color={validColor} size={24} style={{ ...styles.icon, ...iconStyle }}/>)}
|
|
79
79
|
|
|
80
80
|
<View style={styles.textWrapper}>
|
|
81
|
-
{validTitle && <
|
|
82
|
-
{validMessage && <
|
|
81
|
+
{validTitle && <Typography style={styles.title}>{text1}</Typography>}
|
|
82
|
+
{validMessage && <Typography style={styles.message}>{text2}</Typography>}
|
|
83
83
|
</View>
|
|
84
84
|
|
|
85
85
|
<View style={styles.feedbackWrapper}>
|
|
86
86
|
{actionTitle && (<TouchableOpacity style={styles.actionWrapper} onPress={handleActionCb} activeOpacity={0.6}>
|
|
87
|
-
<
|
|
87
|
+
<Typography style={styles.actionTitle}>{actionTitle}</Typography>
|
|
88
88
|
</TouchableOpacity>)}
|
|
89
89
|
{showCloseIcon && (<TouchableOpacity style={styles.closeIconWrapper} onPress={handleCloseCb} activeOpacity={0.6}>
|
|
90
90
|
<Icon name="cross_light" color={validColor} size={24}/>
|
|
@@ -3,7 +3,7 @@ import { Modal, StyleSheet, View } from 'react-native';
|
|
|
3
3
|
import { moderateScale, scaledForDevice } from '../../../scale';
|
|
4
4
|
import { base, primary } from '../../../theme/palette';
|
|
5
5
|
import Icon from '../../atoms/Icon';
|
|
6
|
-
import
|
|
6
|
+
import Typography from '../../atoms/Typography';
|
|
7
7
|
export var animationTypes;
|
|
8
8
|
(function (animationTypes) {
|
|
9
9
|
animationTypes["Slide"] = "slide";
|
|
@@ -59,8 +59,12 @@ const FullScreenMessage = ({ backgroundColor = primary.main, title = '', isVisib
|
|
|
59
59
|
return (<Modal visible={isVisible} animationType={animationType} transparent {...props}>
|
|
60
60
|
<View style={styles.container}>
|
|
61
61
|
{children ?? (<>
|
|
62
|
-
{validTitle && <
|
|
63
|
-
|
|
62
|
+
{validTitle && (<Typography style={styles.title} type="heading" size="large">
|
|
63
|
+
{title}
|
|
64
|
+
</Typography>)}
|
|
65
|
+
{validSubtitle && (<Typography style={styles.subtitle} type="body" size="large">
|
|
66
|
+
{subtitle}
|
|
67
|
+
</Typography>)}
|
|
64
68
|
{validIconName && <Icon color={iconColor} size={130} name={iconName}/>}
|
|
65
69
|
</>)}
|
|
66
70
|
</View>
|
|
@@ -28,7 +28,7 @@ const SwipeItemSelectionList = React.forwardRef(({ data, radioButton = false, mu
|
|
|
28
28
|
checkIfElementIsSelected(id, isElementSelected);
|
|
29
29
|
return onSelection(id);
|
|
30
30
|
};
|
|
31
|
-
return (<ItemSelectionButton radioButton={radioButton} leftSelection={leftSelection} rightSelection={rightSelection} selected={isElementSelected} onSelection={onSelectElement} name={name}/>);
|
|
31
|
+
return (<ItemSelectionButton key={id} radioButton={radioButton} leftSelection={leftSelection} rightSelection={rightSelection} selected={isElementSelected} onSelection={onSelectElement} name={name}/>);
|
|
32
32
|
};
|
|
33
33
|
return (<SwipeList ref={ref} {...props}>
|
|
34
34
|
{data.map((element) => renderItem(element))}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import BaseButton from './components/atoms/BaseButton';
|
|
|
2
2
|
import CheckBox from './components/atoms/CheckBox';
|
|
3
3
|
import Icon from './components/atoms/Icon';
|
|
4
4
|
import Image from './components/atoms/Image';
|
|
5
|
-
import Input from './components/atoms/Input';
|
|
6
5
|
import List from './components/atoms/List';
|
|
7
6
|
import Loading from './components/atoms/Loading';
|
|
8
7
|
import RadioButton from './components/atoms/RadioButton';
|
|
@@ -12,6 +11,7 @@ import SwipeUp from './components/atoms/SwipeUp';
|
|
|
12
11
|
import { SwipeUpFlatList, SwipeUpScrollView, SwipeUpView } from './components/atoms/SwipeUp/childComponents';
|
|
13
12
|
import Text from './components/atoms/Text';
|
|
14
13
|
import BaseInput from './components/atoms/BaseInput';
|
|
14
|
+
import Typography from './components/atoms/Typography';
|
|
15
15
|
import Avatar from './components/molecules/Avatar';
|
|
16
16
|
import Button from './components/molecules/Button';
|
|
17
17
|
import Carousel from './components/molecules/Carousel';
|
|
@@ -23,9 +23,10 @@ import { configToast } from './components/molecules/Toast/utils';
|
|
|
23
23
|
import SwipeList from './components/molecules/SwipeList';
|
|
24
24
|
import ItemSelectionButton from './components/molecules/ItemSelectionButton';
|
|
25
25
|
import MainCardList from './components/molecules/MainCardList';
|
|
26
|
+
import Input from './components/molecules/Input';
|
|
26
27
|
import LoadingFullScreen from './components/organisms/LoadingFullScreen';
|
|
27
28
|
import FullScreenMessage from './components/organisms/FullScreenMessage';
|
|
28
29
|
import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionList';
|
|
29
30
|
import { palette } from './theme/palette';
|
|
30
31
|
import * as getScale from './scale';
|
|
31
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip,
|
|
32
|
+
export { Text, Avatar, CheckBox, Icon, Image, Input, Loading, Svg, StatusChip, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, SwipeList, ItemSelectionButton, SwipeItemSelectionList, MainCardList, BaseInput, Typography, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import BaseButton from './components/atoms/BaseButton';
|
|
|
3
3
|
import CheckBox from './components/atoms/CheckBox';
|
|
4
4
|
import Icon from './components/atoms/Icon';
|
|
5
5
|
import Image from './components/atoms/Image';
|
|
6
|
-
import Input from './components/atoms/Input';
|
|
7
6
|
import List from './components/atoms/List';
|
|
8
7
|
import Loading from './components/atoms/Loading';
|
|
9
8
|
import RadioButton from './components/atoms/RadioButton';
|
|
@@ -13,6 +12,7 @@ import SwipeUp from './components/atoms/SwipeUp';
|
|
|
13
12
|
import { SwipeUpFlatList, SwipeUpScrollView, SwipeUpView } from './components/atoms/SwipeUp/childComponents';
|
|
14
13
|
import Text from './components/atoms/Text';
|
|
15
14
|
import BaseInput from './components/atoms/BaseInput';
|
|
15
|
+
import Typography from './components/atoms/Typography';
|
|
16
16
|
// Molecules
|
|
17
17
|
import Avatar from './components/molecules/Avatar';
|
|
18
18
|
import Button from './components/molecules/Button';
|
|
@@ -25,6 +25,7 @@ import { configToast } from './components/molecules/Toast/utils';
|
|
|
25
25
|
import SwipeList from './components/molecules/SwipeList';
|
|
26
26
|
import ItemSelectionButton from './components/molecules/ItemSelectionButton';
|
|
27
27
|
import MainCardList from './components/molecules/MainCardList';
|
|
28
|
+
import Input from './components/molecules/Input';
|
|
28
29
|
// Organisms
|
|
29
30
|
import LoadingFullScreen from './components/organisms/LoadingFullScreen';
|
|
30
31
|
import FullScreenMessage from './components/organisms/FullScreenMessage';
|
|
@@ -32,4 +33,4 @@ import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionLis
|
|
|
32
33
|
// Misc
|
|
33
34
|
import { palette } from './theme/palette';
|
|
34
35
|
import * as getScale from './scale';
|
|
35
|
-
export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip,
|
|
36
|
+
export { Text, Avatar, CheckBox, Icon, Image, Input, Loading, Svg, StatusChip, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, Button, getScale, LayoutWithBottomButtons, FullScreenMessage, Toast, configToast, SwipeList, ItemSelectionButton, SwipeItemSelectionList, MainCardList, BaseInput, Typography, };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type TypographyItem = {
|
|
2
|
+
weight: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
3
|
+
size: number;
|
|
4
|
+
lineHeight: number;
|
|
5
|
+
spacing?: number;
|
|
6
|
+
};
|
|
7
|
+
export type Typography = {
|
|
8
|
+
display: TypographyItem;
|
|
9
|
+
heading: {
|
|
10
|
+
large: TypographyItem;
|
|
11
|
+
medium: TypographyItem;
|
|
12
|
+
small: TypographyItem;
|
|
13
|
+
};
|
|
14
|
+
title: {
|
|
15
|
+
large: TypographyItem;
|
|
16
|
+
medium: TypographyItem;
|
|
17
|
+
small: TypographyItem;
|
|
18
|
+
};
|
|
19
|
+
label: {
|
|
20
|
+
large: TypographyItem;
|
|
21
|
+
medium: TypographyItem;
|
|
22
|
+
small: TypographyItem;
|
|
23
|
+
};
|
|
24
|
+
body: {
|
|
25
|
+
large: TypographyItem;
|
|
26
|
+
medium: TypographyItem;
|
|
27
|
+
small: TypographyItem;
|
|
28
|
+
};
|
|
29
|
+
overline: {
|
|
30
|
+
large: TypographyItem;
|
|
31
|
+
small: TypographyItem;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
declare const typography: Typography;
|
|
35
|
+
export default typography;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { moderateScale, scaledForDevice } from '../scale';
|
|
2
|
+
const typography = {
|
|
3
|
+
display: { weight: '400', size: scaledForDevice(42, moderateScale), lineHeight: 50 },
|
|
4
|
+
heading: {
|
|
5
|
+
large: { weight: '500', size: scaledForDevice(34, moderateScale), lineHeight: 40 },
|
|
6
|
+
medium: { weight: '500', size: scaledForDevice(26, moderateScale), lineHeight: 32 },
|
|
7
|
+
small: { weight: '400', size: scaledForDevice(24, moderateScale), lineHeight: 28 },
|
|
8
|
+
},
|
|
9
|
+
title: {
|
|
10
|
+
large: { weight: '400', size: scaledForDevice(20, moderateScale), lineHeight: 24 },
|
|
11
|
+
medium: { weight: '700', size: scaledForDevice(18, moderateScale), lineHeight: 22 },
|
|
12
|
+
small: { weight: '700', size: scaledForDevice(14, moderateScale), lineHeight: 16 },
|
|
13
|
+
},
|
|
14
|
+
label: {
|
|
15
|
+
large: { weight: '500', size: scaledForDevice(16, moderateScale), lineHeight: 18 },
|
|
16
|
+
medium: { weight: '500', size: scaledForDevice(14, moderateScale), lineHeight: 16 },
|
|
17
|
+
small: { weight: '500', size: scaledForDevice(12, moderateScale), lineHeight: 14 },
|
|
18
|
+
},
|
|
19
|
+
body: {
|
|
20
|
+
large: { weight: '400', size: scaledForDevice(16, moderateScale), lineHeight: 20 },
|
|
21
|
+
medium: { weight: '400', size: scaledForDevice(14, moderateScale), lineHeight: 18 },
|
|
22
|
+
small: { weight: '400', size: scaledForDevice(12, moderateScale), lineHeight: 16 },
|
|
23
|
+
},
|
|
24
|
+
overline: {
|
|
25
|
+
large: { weight: '500', size: scaledForDevice(14, moderateScale), lineHeight: 16, spacing: 1 },
|
|
26
|
+
small: { weight: '500', size: scaledForDevice(12, moderateScale), lineHeight: 14, spacing: 0.7 },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export default typography;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@janiscommerce/ui-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "components library for Janis app",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@testing-library/react-hooks": "^8.0.1",
|
|
69
69
|
"@testing-library/react-native": "^7.2.0",
|
|
70
70
|
"@types/jest": "^25.2.3",
|
|
71
|
+
"@types/node": "^22.9.0",
|
|
71
72
|
"@types/react": "^17.0.2",
|
|
72
73
|
"@types/react-native": "^0.63.2",
|
|
73
74
|
"@types/react-native-vector-icons": "^6.4.14",
|