@widergy/mobile-ui 1.15.0 → 1.16.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/CHANGELOG.md +14 -0
- package/lib/components/Button/index.js +1 -1
- package/lib/components/UTBadge/index.js +2 -2
- package/lib/components/UTBadge/theme.js +9 -6
- package/lib/components/UTBaseInputField/README.md +45 -31
- package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +5 -16
- package/lib/components/UTBaseInputField/components/BadgeAdornment/index.js +13 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/constants.js +2 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/index.js +20 -15
- package/lib/components/UTBaseInputField/components/IconAdornment/proptypes.js +20 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +7 -2
- package/lib/components/UTBaseInputField/constants.js +12 -1
- package/lib/components/UTBaseInputField/index.js +69 -72
- package/lib/components/UTBaseInputField/proptypes.js +60 -0
- package/lib/components/UTBaseInputField/theme.js +72 -32
- package/lib/components/UTBottomSheet/README.md +53 -0
- package/lib/components/UTBottomSheet/index.js +139 -0
- package/lib/components/UTBottomSheet/styles.js +46 -0
- package/lib/components/UTButton/constants.js +5 -14
- package/lib/components/UTButton/index.js +6 -22
- package/lib/components/UTButton/proptypes.js +29 -0
- package/lib/components/UTButton/theme.js +6 -5
- package/lib/components/UTCheckBox/README.md +4 -30
- package/lib/components/UTCheckBox/constants.js +4 -1
- package/lib/components/UTCheckBox/index.js +33 -22
- package/lib/components/UTCheckBox/proptypes.js +12 -3
- package/lib/components/UTCheckBox/styles.js +7 -0
- package/lib/components/UTCheckBox/theme.js +98 -54
- package/lib/components/UTCheckList/README.MD +14 -10
- package/lib/components/UTCheckList/constants.js +6 -1
- package/lib/components/UTCheckList/index.js +44 -66
- package/lib/components/UTCheckList/proptypes.js +48 -0
- package/lib/components/UTCheckList/styles.js +10 -5
- package/lib/components/UTCheckList/utils.js +5 -0
- package/lib/components/UTFieldLabel/index.js +4 -3
- package/lib/components/UTIcon/README.md +46 -7
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCar.svg +17 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCart.svg +6 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconHome.svg +5 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconTruck.svg +7 -0
- package/lib/components/UTIcon/constants.js +14 -0
- package/lib/components/UTIcon/index.js +19 -8
- package/lib/components/UTIcon/utils.js +34 -0
- package/lib/components/UTLabel/constants.js +11 -11
- package/lib/components/UTLabel/index.js +3 -17
- package/lib/components/UTLabel/proptypes.js +19 -0
- package/lib/components/UTLabel/theme.js +2 -2
- package/lib/components/UTMenu/index.js +1 -1
- package/lib/components/UTPasswordField/versions/V0/components/PasswordValidations/styles.js +1 -0
- package/lib/components/UTPasswordField/versions/V1/index.js +3 -2
- package/lib/components/UTSearchField/README.md +42 -0
- package/lib/components/UTSearchField/index.js +59 -0
- package/lib/components/UTSearchField/proptypes.js +28 -0
- package/lib/components/UTSelect/index.js +10 -97
- package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/index.js +1 -1
- package/lib/components/UTSelect/versions/V0/index.js +103 -0
- package/lib/components/UTSelect/versions/V1/README.md +82 -0
- package/lib/components/UTSelect/versions/V1/index.js +171 -0
- package/lib/components/UTSelect/versions/V1/proptypes.js +45 -0
- package/lib/components/UTSelect/versions/V1/styles.js +18 -0
- package/lib/components/UTTextArea/index.js +1 -1
- package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +3 -3
- package/lib/components/UTTextInput/versions/V1/README.md +36 -35
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +18 -12
- package/lib/components/UTTextInput/versions/V1/constants.js +3 -5
- package/lib/components/UTTextInput/versions/V1/index.js +21 -18
- package/lib/components/UTTextInput/versions/V1/proptypes.js +23 -6
- package/lib/index.js +47 -52
- package/package.json +2 -2
- /package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/styles.js +0 -0
- /package/lib/components/UTSelect/{proptypes.js → versions/V0/proptypes.js} +0 -0
- /package/lib/components/UTSelect/{styles.js → versions/V0/styles.js} +0 -0
|
@@ -1,11 +1,46 @@
|
|
|
1
1
|
import { getFontStyles } from '../UTLabel/theme';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { SIZES, VARIANT } from './constants';
|
|
4
4
|
|
|
5
|
-
const LINE_HEIGHT = 22;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const LINE_HEIGHT = 22;
|
|
6
|
+
|
|
7
|
+
const CONTAINER = {
|
|
8
|
+
PADDING: {
|
|
9
|
+
HORIZONTAL: 16,
|
|
10
|
+
VERTICAL: 12
|
|
11
|
+
},
|
|
12
|
+
BORDER: {
|
|
13
|
+
RADIUS: 4,
|
|
14
|
+
WIDTH: 1,
|
|
15
|
+
WIDTH_FOCUSED: 2
|
|
16
|
+
},
|
|
17
|
+
ROW_GAP: 16
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const SMALL_INPUT_PADDING = {
|
|
21
|
+
HORIZONTAL: 12,
|
|
22
|
+
VERTICAL: 8
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const COLORS = {
|
|
26
|
+
BACKGROUND: {
|
|
27
|
+
DEFAULT: theme => theme.Palette.light['01'],
|
|
28
|
+
DISABLED: theme => theme.Palette.light['03'],
|
|
29
|
+
GRAY_VARIANT: theme => theme.Palette.light['04'],
|
|
30
|
+
READ_ONLY: 'transparent'
|
|
31
|
+
},
|
|
32
|
+
BORDER: {
|
|
33
|
+
DEFAULT: theme => theme.Palette.light['05'],
|
|
34
|
+
ERROR: theme => theme.Palette.error['04'],
|
|
35
|
+
FOCUSED: theme => theme.Palette.accent['04'],
|
|
36
|
+
GRAY_VARIANT: 'transparent',
|
|
37
|
+
READ_ONLY: 'transparent'
|
|
38
|
+
},
|
|
39
|
+
TEXT: {
|
|
40
|
+
INPUT: theme => theme.Palette.dark['05'],
|
|
41
|
+
PLACEHOLDER: theme => theme.Palette.gray['02'],
|
|
42
|
+
SELECTION: theme => theme.Palette.accent['04']
|
|
43
|
+
}
|
|
9
44
|
};
|
|
10
45
|
|
|
11
46
|
const baseTextInputTheme = theme => ({
|
|
@@ -17,21 +52,20 @@ const baseTextInputTheme = theme => ({
|
|
|
17
52
|
},
|
|
18
53
|
container: {
|
|
19
54
|
alignItems: 'center',
|
|
20
|
-
backgroundColor:
|
|
21
|
-
borderColor:
|
|
22
|
-
borderRadius:
|
|
23
|
-
borderWidth:
|
|
24
|
-
flex: 1,
|
|
55
|
+
backgroundColor: COLORS.BACKGROUND.DEFAULT(theme),
|
|
56
|
+
borderColor: COLORS.BORDER.DEFAULT(theme),
|
|
57
|
+
borderRadius: CONTAINER.BORDER.RADIUS,
|
|
58
|
+
borderWidth: CONTAINER.BORDER.WIDTH,
|
|
25
59
|
flexDirection: 'column',
|
|
26
|
-
paddingHorizontal:
|
|
27
|
-
paddingVertical:
|
|
28
|
-
rowGap:
|
|
60
|
+
paddingHorizontal: CONTAINER.PADDING.HORIZONTAL,
|
|
61
|
+
paddingVertical: CONTAINER.PADDING.VERTICAL,
|
|
62
|
+
rowGap: CONTAINER.ROW_GAP,
|
|
29
63
|
width: '100%'
|
|
30
64
|
},
|
|
31
65
|
input: {
|
|
32
66
|
root: {
|
|
33
67
|
...getFontStyles({ theme, variant: 'body', weight: 'regular' }),
|
|
34
|
-
color:
|
|
68
|
+
color: COLORS.TEXT.INPUT(theme),
|
|
35
69
|
flex: 1,
|
|
36
70
|
includeFontPadding: false,
|
|
37
71
|
padding: 0,
|
|
@@ -39,12 +73,12 @@ const baseTextInputTheme = theme => ({
|
|
|
39
73
|
textAlignVertical: 'center',
|
|
40
74
|
zIndex: 4
|
|
41
75
|
},
|
|
42
|
-
placeholderTextColor:
|
|
43
|
-
selectionColor:
|
|
76
|
+
placeholderTextColor: COLORS.TEXT.PLACEHOLDER(theme),
|
|
77
|
+
selectionColor: COLORS.TEXT.SELECTION(theme)
|
|
44
78
|
},
|
|
45
79
|
inputRow: {
|
|
46
80
|
alignItems: 'center',
|
|
47
|
-
columnGap:
|
|
81
|
+
columnGap: CONTAINER.ROW_GAP,
|
|
48
82
|
flex: 1,
|
|
49
83
|
flexDirection: 'row',
|
|
50
84
|
justifyContent: 'space-between',
|
|
@@ -57,28 +91,33 @@ const baseTextInputTheme = theme => ({
|
|
|
57
91
|
}
|
|
58
92
|
});
|
|
59
93
|
|
|
60
|
-
const conditionalContainerStyle = (
|
|
94
|
+
const conditionalContainerStyle = (disabled, error, focused, inputSize, readOnly, theme, variant) => ({
|
|
95
|
+
...(variant === VARIANT.GRAY && {
|
|
96
|
+
backgroundColor: COLORS.BACKGROUND.GRAY_VARIANT(theme),
|
|
97
|
+
borderColor: COLORS.BORDER.GRAY_VARIANT
|
|
98
|
+
}),
|
|
61
99
|
...(focused && {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
100
|
+
backgroundColor: COLORS.BACKGROUND.DEFAULT(theme),
|
|
101
|
+
borderColor: COLORS.BORDER.FOCUSED(theme),
|
|
102
|
+
borderWidth: CONTAINER.BORDER.WIDTH_FOCUSED,
|
|
103
|
+
paddingHorizontal: CONTAINER.PADDING.HORIZONTAL - 1,
|
|
104
|
+
paddingVertical: CONTAINER.PADDING.VERTICAL - 1
|
|
66
105
|
}),
|
|
67
106
|
...(error && {
|
|
68
|
-
borderColor:
|
|
107
|
+
borderColor: COLORS.BORDER.ERROR(theme)
|
|
69
108
|
}),
|
|
70
109
|
...(readOnly && {
|
|
71
|
-
backgroundColor:
|
|
72
|
-
borderColor:
|
|
110
|
+
backgroundColor: COLORS.BACKGROUND.READ_ONLY,
|
|
111
|
+
borderColor: COLORS.BORDER.READ_ONLY,
|
|
73
112
|
paddingHorizontal: 0
|
|
74
113
|
}),
|
|
75
114
|
...(disabled && {
|
|
76
|
-
backgroundColor:
|
|
77
|
-
borderColor:
|
|
115
|
+
backgroundColor: COLORS.BACKGROUND.DISABLED(theme),
|
|
116
|
+
borderColor: COLORS.BORDER.READ_ONLY
|
|
78
117
|
}),
|
|
79
|
-
...(inputSize === SMALL && {
|
|
80
|
-
paddingHorizontal:
|
|
81
|
-
paddingVertical:
|
|
118
|
+
...(inputSize === SIZES.SMALL && {
|
|
119
|
+
paddingHorizontal: SMALL_INPUT_PADDING.HORIZONTAL,
|
|
120
|
+
paddingVertical: SMALL_INPUT_PADDING.VERTICAL
|
|
82
121
|
})
|
|
83
122
|
});
|
|
84
123
|
|
|
@@ -98,13 +137,14 @@ export const retrieveStyle = ({
|
|
|
98
137
|
multiline,
|
|
99
138
|
readOnly,
|
|
100
139
|
style = {},
|
|
101
|
-
theme
|
|
140
|
+
theme,
|
|
141
|
+
variant
|
|
102
142
|
}) => {
|
|
103
143
|
const baseTheme = baseTextInputTheme(theme);
|
|
104
144
|
|
|
105
145
|
const containerStyle = {
|
|
106
146
|
...baseTheme.container,
|
|
107
|
-
...conditionalContainerStyle(
|
|
147
|
+
...conditionalContainerStyle(disabled, error, focused, inputSize, readOnly, theme, variant),
|
|
108
148
|
...style.container
|
|
109
149
|
};
|
|
110
150
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# UTBottomSheet
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTBottomSheet` is a bottom sheet component that can be customized with various button texts, descriptions, and content. It allows swipe to close and adjusts its height based on user interaction.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ----------- | ------ | ------- | ----------------------------------------------------------------------- |
|
|
11
|
+
| buttonText | string | | Text for the button that appears in the top right corner of the header. |
|
|
12
|
+
| description | string | | Description that appears below the title in the header. |
|
|
13
|
+
| onClose | func | | Function called when the bottom sheet is closed. |
|
|
14
|
+
| required | bool | | Indicates if the field is required, showing an asterisk in the title. |
|
|
15
|
+
| title | string | | Title that appears in the bottom sheet header. |
|
|
16
|
+
| visible | bool | | Controls the visibility of the bottom sheet. |
|
|
17
|
+
| scrolleable | bool | false | Determines if the content inside the bottom sheet should be scrollable. |
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import React, { useState } from 'react';
|
|
23
|
+
import { View, Button, Text } from 'react-native';
|
|
24
|
+
import UTBottomSheet from './UTBottomSheet';
|
|
25
|
+
|
|
26
|
+
const Example = () => {
|
|
27
|
+
const [visible, setVisible] = useState(false);
|
|
28
|
+
|
|
29
|
+
const toggleBottomSheet = () => {
|
|
30
|
+
setVisible(!visible);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View style={{ flex: 1 }}>
|
|
35
|
+
<Button title="Show Bottom Sheet" onPress={toggleBottomSheet} />
|
|
36
|
+
<UTBottomSheet
|
|
37
|
+
buttonText="Close"
|
|
38
|
+
description="This is a description"
|
|
39
|
+
onClose={toggleBottomSheet}
|
|
40
|
+
required={true}
|
|
41
|
+
title="Bottom Sheet Title"
|
|
42
|
+
visible={visible}
|
|
43
|
+
>
|
|
44
|
+
<View>
|
|
45
|
+
<Text>Your content goes here</Text>
|
|
46
|
+
</View>
|
|
47
|
+
</UTBottomSheet>
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default Example;
|
|
53
|
+
```
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import { SafeAreaView, View, PanResponder, Animated, Dimensions, ScrollView, Keyboard } from 'react-native';
|
|
3
|
+
import Modal from 'react-native-modal';
|
|
4
|
+
import { bool, func, string } from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import { useTheme } from '../../theming';
|
|
7
|
+
import UTButton from '../UTButton';
|
|
8
|
+
import UTFieldLabel from '../UTFieldLabel';
|
|
9
|
+
import UTLabel from '../UTLabel';
|
|
10
|
+
|
|
11
|
+
import styles from './styles';
|
|
12
|
+
|
|
13
|
+
const screenHeight = Dimensions.get('window').height;
|
|
14
|
+
|
|
15
|
+
const UTBottomSheet = ({
|
|
16
|
+
buttonText,
|
|
17
|
+
children,
|
|
18
|
+
description,
|
|
19
|
+
onClose,
|
|
20
|
+
required,
|
|
21
|
+
scrolleable,
|
|
22
|
+
title,
|
|
23
|
+
visible
|
|
24
|
+
}) => {
|
|
25
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
26
|
+
const [modalHeight, setModalHeight] = useState('70%');
|
|
27
|
+
const pan = useRef(new Animated.ValueXY()).current;
|
|
28
|
+
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
|
|
31
|
+
const panResponder = useMemo(
|
|
32
|
+
() =>
|
|
33
|
+
PanResponder.create({
|
|
34
|
+
onMoveShouldSetPanResponder: (_, gestureState) => gestureState.dy > 0,
|
|
35
|
+
onPanResponderMove: (_, gestureState) => {
|
|
36
|
+
if (gestureState.dy > 0) {
|
|
37
|
+
pan.setValue({ x: 0, y: gestureState.dy });
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
41
|
+
if (gestureState.dy > 50) {
|
|
42
|
+
setIsFullScreen(true);
|
|
43
|
+
pan.flattenOffset();
|
|
44
|
+
} else {
|
|
45
|
+
Animated.spring(pan, {
|
|
46
|
+
toValue: { x: 0, y: 0 },
|
|
47
|
+
useNativeDriver: false
|
|
48
|
+
}).start();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
[pan]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const handleKeyboardDidShow = useCallback(e => {
|
|
56
|
+
setModalHeight(screenHeight - e.endCoordinates.height);
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
const handleKeyboardDidHide = useCallback(() => {
|
|
60
|
+
setModalHeight(isFullScreen ? screenHeight : '70%');
|
|
61
|
+
}, [isFullScreen]);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', handleKeyboardDidShow);
|
|
65
|
+
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', handleKeyboardDidHide);
|
|
66
|
+
|
|
67
|
+
return () => {
|
|
68
|
+
keyboardDidHideListener.remove();
|
|
69
|
+
keyboardDidShowListener.remove();
|
|
70
|
+
};
|
|
71
|
+
}, [handleKeyboardDidShow, handleKeyboardDidHide]);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
setModalHeight(isFullScreen ? screenHeight : '70%');
|
|
75
|
+
}, [isFullScreen]);
|
|
76
|
+
|
|
77
|
+
const ChildrenContainer = scrolleable ? ScrollView : View;
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Modal
|
|
81
|
+
animationIn="slideInUp"
|
|
82
|
+
animationInTiming={600}
|
|
83
|
+
animationOut="slideOutDown"
|
|
84
|
+
animationOutTiming={600}
|
|
85
|
+
isVisible={visible}
|
|
86
|
+
onBackdropPress={onClose}
|
|
87
|
+
onSwipeComplete={onClose}
|
|
88
|
+
propagateSwipe
|
|
89
|
+
style={styles.modal}
|
|
90
|
+
swipeDirection="down"
|
|
91
|
+
>
|
|
92
|
+
<Animated.View style={[styles.animatedContainer, { height: modalHeight }, pan.getLayout()]}>
|
|
93
|
+
<SafeAreaView style={styles.safeArea}>
|
|
94
|
+
<View style={styles.dragHandle} {...panResponder.panHandlers}>
|
|
95
|
+
<View style={styles.handleIndicator(theme)} />
|
|
96
|
+
</View>
|
|
97
|
+
<View style={styles.content}>
|
|
98
|
+
<View style={styles.header}>
|
|
99
|
+
<View style={styles.headerTopRow}>
|
|
100
|
+
<UTFieldLabel required={required} variant="subtitle1" weight="medium">
|
|
101
|
+
{title}
|
|
102
|
+
</UTFieldLabel>
|
|
103
|
+
{buttonText && (
|
|
104
|
+
<UTButton colorTheme="primary" onPress={onClose} variant="semitransparent">
|
|
105
|
+
{buttonText}
|
|
106
|
+
</UTButton>
|
|
107
|
+
)}
|
|
108
|
+
</View>
|
|
109
|
+
{description && (
|
|
110
|
+
<UTLabel colorTheme="gray" variant="small">
|
|
111
|
+
{description}
|
|
112
|
+
</UTLabel>
|
|
113
|
+
)}
|
|
114
|
+
</View>
|
|
115
|
+
<ChildrenContainer keyboardShouldPersistTaps="handled" style={styles.childrenContainer}>
|
|
116
|
+
{children}
|
|
117
|
+
</ChildrenContainer>
|
|
118
|
+
</View>
|
|
119
|
+
</SafeAreaView>
|
|
120
|
+
</Animated.View>
|
|
121
|
+
</Modal>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
UTBottomSheet.defaultProps = {
|
|
126
|
+
scrolleable: false
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
UTBottomSheet.propTypes = {
|
|
130
|
+
buttonText: string,
|
|
131
|
+
description: string,
|
|
132
|
+
onClose: func,
|
|
133
|
+
required: bool,
|
|
134
|
+
scrolleable: bool,
|
|
135
|
+
title: string,
|
|
136
|
+
visible: bool
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default UTBottomSheet;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
animatedContainer: {
|
|
5
|
+
backgroundColor: 'white', // When the component is standardized, should change to palette color
|
|
6
|
+
borderTopLeftRadius: 20,
|
|
7
|
+
borderTopRightRadius: 20,
|
|
8
|
+
overflow: 'hidden'
|
|
9
|
+
},
|
|
10
|
+
content: {
|
|
11
|
+
flex: 1,
|
|
12
|
+
padding: 16,
|
|
13
|
+
rowGap: 16
|
|
14
|
+
},
|
|
15
|
+
header: {
|
|
16
|
+
rowGap: 8
|
|
17
|
+
},
|
|
18
|
+
headerTopRow: {
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
flexDirection: 'row',
|
|
21
|
+
justifyContent: 'space-between'
|
|
22
|
+
},
|
|
23
|
+
modal: {
|
|
24
|
+
justifyContent: 'flex-end',
|
|
25
|
+
margin: 0
|
|
26
|
+
},
|
|
27
|
+
safeArea: {
|
|
28
|
+
flex: 1
|
|
29
|
+
},
|
|
30
|
+
dragHandle: {
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
backgroundColor: 'transparent',
|
|
33
|
+
padding: 16
|
|
34
|
+
},
|
|
35
|
+
handleIndicator: theme => ({
|
|
36
|
+
backgroundColor: theme.Palette.light['04'], // When the component is standardized, should change to palette color: light 04
|
|
37
|
+
borderRadius: 2.5,
|
|
38
|
+
height: 5,
|
|
39
|
+
width: 40
|
|
40
|
+
}),
|
|
41
|
+
childrenContainer: {
|
|
42
|
+
flexShrink: 1
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export default styles;
|
|
@@ -2,23 +2,14 @@ export const ELEVATION = 2;
|
|
|
2
2
|
export const PRESSED_ELEVATION = 2;
|
|
3
3
|
|
|
4
4
|
export const SIZES = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
SMALL: 'small',
|
|
6
|
+
MEDIUM: 'medium',
|
|
7
|
+
LARGE: 'large'
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export const ICON_PLACEMENTS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const DEFAULT_PROPS = {
|
|
16
|
-
colorTheme: 'secondary',
|
|
17
|
-
disabled: false,
|
|
18
|
-
iconPlacement: ICON_PLACEMENTS.left,
|
|
19
|
-
loading: false,
|
|
20
|
-
size: SIZES.medium,
|
|
21
|
-
variant: 'filled'
|
|
11
|
+
LEFT: 'left',
|
|
12
|
+
RIGHT: 'right'
|
|
22
13
|
};
|
|
23
14
|
|
|
24
15
|
export const COLORS_MAPPER = {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { bool, func, elementType, string, shape } from 'prop-types';
|
|
3
2
|
import { Pressable, View } from 'react-native';
|
|
4
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
3
|
|
|
6
4
|
import { isUTIcon } from '../UTIcon/utils';
|
|
7
5
|
import { useTheme } from '../../theming';
|
|
@@ -9,7 +7,8 @@ import UTIcon from '../UTIcon';
|
|
|
9
7
|
import UTLabel from '../UTLabel';
|
|
10
8
|
import UTLoading from '../UTLoading';
|
|
11
9
|
|
|
12
|
-
import {
|
|
10
|
+
import { defaultProps, propTypes } from './proptypes';
|
|
11
|
+
import { ICON_PLACEMENTS } from './constants';
|
|
13
12
|
import { retrieveStyle } from './theme';
|
|
14
13
|
|
|
15
14
|
const UTButton = ({
|
|
@@ -70,13 +69,13 @@ const UTButton = ({
|
|
|
70
69
|
|
|
71
70
|
const RenderedChildren = (
|
|
72
71
|
<View style={themeChildrenContainerStyles}>
|
|
73
|
-
{iconPlacement === ICON_PLACEMENTS.
|
|
72
|
+
{iconPlacement === ICON_PLACEMENTS.LEFT && IconToShow}
|
|
74
73
|
{children && (
|
|
75
74
|
<UTLabel colorTheme={textStyles.colorTheme} variant={textStyles.variant} weight={textStyles.weight}>
|
|
76
75
|
{children}
|
|
77
76
|
</UTLabel>
|
|
78
77
|
)}
|
|
79
|
-
{iconPlacement !== ICON_PLACEMENTS.
|
|
78
|
+
{iconPlacement !== ICON_PLACEMENTS.LEFT && IconToShow}
|
|
80
79
|
</View>
|
|
81
80
|
);
|
|
82
81
|
|
|
@@ -89,22 +88,7 @@ const UTButton = ({
|
|
|
89
88
|
);
|
|
90
89
|
};
|
|
91
90
|
|
|
92
|
-
UTButton.defaultProps =
|
|
93
|
-
|
|
94
|
-
UTButton.propTypes = {
|
|
95
|
-
colorTheme: string,
|
|
96
|
-
disabled: bool,
|
|
97
|
-
Icon: elementType,
|
|
98
|
-
iconPlacement: string,
|
|
99
|
-
loading: bool,
|
|
100
|
-
onPress: func,
|
|
101
|
-
size: string,
|
|
102
|
-
style: shape({
|
|
103
|
-
childrenContainer: ViewPropTypes.style,
|
|
104
|
-
icon: ViewPropTypes.style,
|
|
105
|
-
root: ViewPropTypes.style
|
|
106
|
-
}),
|
|
107
|
-
variant: string
|
|
108
|
-
};
|
|
91
|
+
UTButton.defaultProps = defaultProps;
|
|
92
|
+
UTButton.propTypes = propTypes;
|
|
109
93
|
|
|
110
94
|
export default UTButton;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { bool, func, elementType, string, shape } from 'prop-types';
|
|
2
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
|
+
|
|
4
|
+
import { ICON_PLACEMENTS, SIZES } from './constants';
|
|
5
|
+
|
|
6
|
+
export const defaultProps = {
|
|
7
|
+
colorTheme: 'secondary',
|
|
8
|
+
disabled: false,
|
|
9
|
+
iconPlacement: ICON_PLACEMENTS.LEFT,
|
|
10
|
+
loading: false,
|
|
11
|
+
size: SIZES.MEDIUM,
|
|
12
|
+
variant: 'filled'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const propTypes = {
|
|
16
|
+
colorTheme: string,
|
|
17
|
+
disabled: bool,
|
|
18
|
+
Icon: elementType,
|
|
19
|
+
iconPlacement: string,
|
|
20
|
+
loading: bool,
|
|
21
|
+
onPress: func,
|
|
22
|
+
size: string,
|
|
23
|
+
style: shape({
|
|
24
|
+
childrenContainer: ViewPropTypes.style,
|
|
25
|
+
icon: ViewPropTypes.style,
|
|
26
|
+
root: ViewPropTypes.style
|
|
27
|
+
}),
|
|
28
|
+
variant: string
|
|
29
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getShadow } from '../../utils/styleUtils';
|
|
2
2
|
import { COLOR_THEMES } from '../UTLabel/constants';
|
|
3
3
|
|
|
4
|
-
import { COLORS_MAPPER,
|
|
4
|
+
import { COLORS_MAPPER, ELEVATION, PRESSED_ELEVATION } from './constants';
|
|
5
|
+
import { defaultProps } from './proptypes';
|
|
5
6
|
|
|
6
7
|
const baseButtonTheme = () => ({
|
|
7
8
|
text: {
|
|
@@ -35,7 +36,7 @@ const baseButtonTheme = () => ({
|
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
38
|
-
const colorName = COLORS_MAPPER[colorTheme] || COLORS_MAPPER[
|
|
39
|
+
const colorName = COLORS_MAPPER[colorTheme] || COLORS_MAPPER[defaultProps.colorTheme];
|
|
39
40
|
const actionTheme = theme.Palette[colorName];
|
|
40
41
|
const negativeTheme = theme.Palette[COLORS_MAPPER.negative];
|
|
41
42
|
const neutralTheme = theme.Palette[COLORS_MAPPER.secondary];
|
|
@@ -54,7 +55,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
text: {
|
|
57
|
-
colorTheme: colorTheme === COLORS_MAPPER.negative ? COLOR_THEMES.
|
|
58
|
+
colorTheme: colorTheme === COLORS_MAPPER.negative ? COLOR_THEMES.NEUTRAL : COLOR_THEMES.NEGATIVE
|
|
58
59
|
},
|
|
59
60
|
icon: {
|
|
60
61
|
color: colorTheme === COLORS_MAPPER.negative ? neutralTheme['05'] : negativeTheme['05']
|
|
@@ -130,7 +131,7 @@ const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
|
130
131
|
}
|
|
131
132
|
};
|
|
132
133
|
|
|
133
|
-
return definition[variant] || definition[
|
|
134
|
+
return definition[variant] || definition[defaultProps.variant];
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
const sizeButtonTheme = size => {
|
|
@@ -164,7 +165,7 @@ const sizeButtonTheme = size => {
|
|
|
164
165
|
fontSize: 20
|
|
165
166
|
},
|
|
166
167
|
iconOnly: {
|
|
167
|
-
fontSize:
|
|
168
|
+
fontSize: 20
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
`UTCheckBox` is a checkbox component used within the `UTCheckList` component. It supports various states such as checked, indeterminate, and disabled
|
|
5
|
+
`UTCheckBox` is a customizable checkbox component used within the `UTCheckList` component. It supports various states such as checked, indeterminate, and disabled.
|
|
6
6
|
|
|
7
7
|
## Props
|
|
8
8
|
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
| checked | bool | false | Indicates if the checkbox is checked. |
|
|
12
12
|
| disabled | bool | false | Disables the checkbox, making it unclickable. |
|
|
13
13
|
| indeterminate | bool | false | Indicates if the checkbox is in an indeterminate state. |
|
|
14
|
+
| isSimple | bool | false | **Deprecated**: Use standard checkboxes instead. |
|
|
14
15
|
| label | string | | Label to display next to the checkbox. |
|
|
15
16
|
| onPress | func | | Function to call when the checkbox is pressed. |
|
|
16
17
|
| required | bool | false | Indicates if the checkbox is required. |
|
|
17
18
|
| reversed | bool | false | If true, reverses the order of label and checkbox. |
|
|
18
|
-
| spacing | string |
|
|
19
|
+
| spacing | string | large | If "small", reduces the column gap from 16 to 8. |
|
|
19
20
|
| style | shape | {} | Custom styles to apply to the checkbox container. |
|
|
21
|
+
| variant | string | | The variant to use for styling the checkbox. |
|
|
20
22
|
|
|
21
23
|
## Usage
|
|
22
24
|
|
|
@@ -34,31 +36,3 @@ const Example = () => {
|
|
|
34
36
|
|
|
35
37
|
export default Example;
|
|
36
38
|
```
|
|
37
|
-
|
|
38
|
-
### Custom Styles Example
|
|
39
|
-
|
|
40
|
-
```jsx
|
|
41
|
-
import React from 'react';
|
|
42
|
-
import UTCheckBox from './UTCheckBox';
|
|
43
|
-
|
|
44
|
-
const customStyles = {
|
|
45
|
-
padding: 10,
|
|
46
|
-
backgroundColor: 'lightgrey'
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const Example = () => {
|
|
50
|
-
const [checked, setChecked] = React.useState(false);
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<UTCheckBox
|
|
54
|
-
checked={checked}
|
|
55
|
-
label="Check me"
|
|
56
|
-
onPress={() => setChecked(!checked)}
|
|
57
|
-
style={customStyles}
|
|
58
|
-
spacing="small"
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default Example;
|
|
64
|
-
```
|