@widergy/mobile-ui 1.14.0 → 1.14.1
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 +7 -0
- package/lib/components/Surface/propTypes.js +3 -2
- package/lib/components/UTBaseInputField/README.md +179 -0
- package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +41 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/constants.js +1 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/index.js +32 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +2 -0
- package/lib/components/UTBaseInputField/components/PrefixAdornment/index.js +16 -0
- package/lib/components/UTBaseInputField/components/SuffixAdornment/index.js +12 -0
- package/lib/components/UTBaseInputField/components/TooltipAdornment/index.js +19 -0
- package/lib/components/UTBaseInputField/constants.js +34 -0
- package/lib/components/UTBaseInputField/index.js +191 -0
- package/lib/components/{UTTextInput/versions/V1/components/TextInputField → UTBaseInputField}/theme.js +3 -2
- package/lib/components/UTButton/README.md +1 -1
- package/lib/components/UTButton/index.js +8 -2
- package/lib/components/UTCheckBox/README.md +15 -17
- package/lib/components/UTCheckBox/constants.js +2 -0
- package/lib/components/UTCheckBox/index.js +50 -24
- package/lib/components/UTCheckBox/proptypes.js +7 -10
- package/lib/components/UTCheckBox/theme.js +26 -15
- package/lib/components/UTCheckList/constants.js +1 -0
- package/lib/components/UTCheckList/index.js +43 -46
- package/lib/components/UTCheckList/styles.js +8 -11
- package/lib/components/UTCheckList/utils.js +5 -0
- package/lib/components/{UTRequiredLabel → UTFieldLabel}/index.js +3 -3
- package/lib/components/UTIcon/README.md +10 -10
- package/lib/components/UTIcon/index.js +6 -8
- package/lib/components/UTIcon/theme.js +1 -5
- package/lib/components/UTSelect/index.js +5 -4
- package/lib/components/UTTextArea/constants.js +3 -1
- package/lib/components/UTTextArea/index.js +4 -4
- package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +1 -1
- package/lib/components/UTTextInput/versions/V1/README.md +6 -15
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +67 -201
- package/lib/components/UTTextInput/versions/V1/constants.js +1 -1
- package/lib/components/UTTextInput/versions/V1/index.js +5 -5
- package/lib/components/UTValidation/README.md +9 -6
- package/lib/components/UTValidation/index.js +8 -6
- package/lib/components/UTValidation/utils.js +4 -0
- package/package.json +1 -1
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/constants.js +0 -12
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/utils.js +0 -13
- package/lib/components/UTTextInput/versions/V1/utils.js +0 -1
- /package/lib/components/{UTRequiredLabel → UTFieldLabel}/constants.js +0 -0
- /package/lib/components/{UTRequiredLabel → UTFieldLabel}/styles.js +0 -0
- /package/lib/components/{UTButton → UTIcon}/utils.js +0 -0
|
@@ -1,44 +1,70 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
2
|
import { View, Pressable } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../../theming';
|
|
5
5
|
import UTIcon from '../UTIcon';
|
|
6
|
-
import
|
|
6
|
+
import UTFieldLabel from '../UTFieldLabel';
|
|
7
7
|
|
|
8
8
|
import { CHECKED_ICON, INDETERMINATE_ICON } from './constants';
|
|
9
9
|
import { retrieveStyle } from './theme';
|
|
10
|
-
import propTypes from './proptypes';
|
|
10
|
+
import propTypes, { DEFAULT_PROPS } from './proptypes';
|
|
11
11
|
|
|
12
|
-
const UTCheckBox = ({
|
|
12
|
+
const UTCheckBox = ({
|
|
13
|
+
checked,
|
|
14
|
+
disabled,
|
|
15
|
+
indeterminate,
|
|
16
|
+
label,
|
|
17
|
+
onPress,
|
|
18
|
+
required,
|
|
19
|
+
reversed,
|
|
20
|
+
spacing,
|
|
21
|
+
style
|
|
22
|
+
}) => {
|
|
13
23
|
const theme = useTheme();
|
|
14
|
-
const
|
|
15
|
-
checked,
|
|
16
|
-
disabled,
|
|
17
|
-
indeterminate,
|
|
18
|
-
reversed,
|
|
19
|
-
style,
|
|
20
|
-
theme
|
|
21
|
-
});
|
|
24
|
+
const [pressed, setPressed] = useState(false);
|
|
22
25
|
|
|
23
|
-
const
|
|
26
|
+
const { containerStyles, iconContainerStyles, touchableStyles } = useMemo(
|
|
27
|
+
() =>
|
|
28
|
+
retrieveStyle({
|
|
29
|
+
checked,
|
|
30
|
+
disabled,
|
|
31
|
+
indeterminate,
|
|
32
|
+
reversed,
|
|
33
|
+
spacing,
|
|
34
|
+
style,
|
|
35
|
+
theme
|
|
36
|
+
}),
|
|
37
|
+
[checked, disabled, indeterminate, reversed, spacing, style, theme]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const combinedTouchableStyles = useMemo(
|
|
41
|
+
() => [touchableStyles.root, pressed && touchableStyles.pressed],
|
|
42
|
+
[pressed, touchableStyles]
|
|
43
|
+
);
|
|
24
44
|
|
|
25
|
-
const iconName =
|
|
45
|
+
const iconName = useMemo(
|
|
46
|
+
() => (indeterminate ? INDETERMINATE_ICON : checked ? CHECKED_ICON : ''),
|
|
47
|
+
[indeterminate, checked]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const handlePressIn = () => setPressed(true);
|
|
51
|
+
const handlePressOut = () => setPressed(false);
|
|
26
52
|
|
|
27
53
|
return (
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
<View style={
|
|
31
|
-
<
|
|
54
|
+
<Pressable disabled={disabled} onPress={onPress} onPressIn={handlePressIn} onPressOut={handlePressOut}>
|
|
55
|
+
<View style={containerStyles}>
|
|
56
|
+
<View style={combinedTouchableStyles}>
|
|
57
|
+
<View style={iconContainerStyles}>
|
|
58
|
+
<UTIcon colorTheme="light" name={iconName} size={16} />
|
|
59
|
+
</View>
|
|
32
60
|
</View>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
</
|
|
61
|
+
<UTFieldLabel required={required}>{label}</UTFieldLabel>
|
|
62
|
+
</View>
|
|
63
|
+
</Pressable>
|
|
36
64
|
);
|
|
37
65
|
};
|
|
38
66
|
|
|
39
|
-
UTCheckBox.defaultProps =
|
|
40
|
-
style: {}
|
|
41
|
-
};
|
|
67
|
+
UTCheckBox.defaultProps = DEFAULT_PROPS;
|
|
42
68
|
|
|
43
69
|
UTCheckBox.propTypes = propTypes;
|
|
44
70
|
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { bool, func,
|
|
1
|
+
import { bool, func, string } from 'prop-types';
|
|
2
2
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
touchable: shape({
|
|
8
|
-
root: ViewPropTypes.style,
|
|
9
|
-
pressed: ViewPropTypes.style
|
|
10
|
-
})
|
|
11
|
-
});
|
|
4
|
+
export const DEFAULT_PROPS = {
|
|
5
|
+
style: {}
|
|
6
|
+
};
|
|
12
7
|
|
|
13
8
|
export default {
|
|
14
9
|
checked: bool,
|
|
@@ -16,6 +11,8 @@ export default {
|
|
|
16
11
|
indeterminate: bool,
|
|
17
12
|
label: string,
|
|
18
13
|
onPress: func,
|
|
14
|
+
required: bool,
|
|
19
15
|
reversed: bool,
|
|
20
|
-
|
|
16
|
+
spacing: string,
|
|
17
|
+
style: ViewPropTypes.style
|
|
21
18
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { SMALL } from './constants';
|
|
2
|
+
|
|
3
|
+
const NORMAL_SPACING = 16;
|
|
4
|
+
const SMALL_SPACING = 8;
|
|
5
|
+
|
|
1
6
|
const baseCheckBoxTheme = theme => ({
|
|
2
7
|
container: {
|
|
3
8
|
alignItems: 'center',
|
|
4
|
-
|
|
5
|
-
flexDirection: 'row',
|
|
6
|
-
justifyContent: 'flex-start'
|
|
9
|
+
flexDirection: 'row'
|
|
7
10
|
},
|
|
8
11
|
iconContainer: {
|
|
9
12
|
borderColor: theme.Palette.gray['04'],
|
|
@@ -26,9 +29,10 @@ const baseCheckBoxTheme = theme => ({
|
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
|
|
29
|
-
const conditionalContainerStyle = (
|
|
32
|
+
const conditionalContainerStyle = (disabled, reversed) => ({
|
|
30
33
|
...(reversed && {
|
|
31
|
-
flexDirection: 'row-reverse'
|
|
34
|
+
flexDirection: 'row-reverse',
|
|
35
|
+
justifyContent: 'space-between'
|
|
32
36
|
}),
|
|
33
37
|
...(disabled && {
|
|
34
38
|
opacity: 0.5
|
|
@@ -42,29 +46,36 @@ const conditionalIconContainerStyle = (checked, indeterminate, theme) => ({
|
|
|
42
46
|
})
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
const conditionalTouchableStyle = (reversed, spacing) => {
|
|
50
|
+
const spacingValue = spacing === SMALL ? SMALL_SPACING : NORMAL_SPACING;
|
|
51
|
+
return {
|
|
52
|
+
marginRight: spacingValue,
|
|
53
|
+
...(reversed && {
|
|
54
|
+
marginLeft: spacingValue,
|
|
55
|
+
marginRight: 0
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const retrieveStyle = ({ checked, disabled, indeterminate, reversed, spacing, style, theme }) => {
|
|
46
61
|
const baseTheme = baseCheckBoxTheme(theme);
|
|
47
62
|
|
|
48
63
|
const containerStyles = {
|
|
49
64
|
...baseTheme.container,
|
|
50
|
-
...conditionalContainerStyle(
|
|
51
|
-
...style
|
|
65
|
+
...conditionalContainerStyle(disabled, reversed),
|
|
66
|
+
...style
|
|
52
67
|
};
|
|
53
68
|
|
|
54
69
|
const iconContainerStyles = {
|
|
55
70
|
...baseTheme.iconContainer,
|
|
56
|
-
...conditionalIconContainerStyle(checked, indeterminate, theme)
|
|
57
|
-
...style.icon
|
|
71
|
+
...conditionalIconContainerStyle(checked, indeterminate, theme)
|
|
58
72
|
};
|
|
59
73
|
|
|
60
74
|
const touchableStyles = {
|
|
75
|
+
pressed: baseTheme.touchable.pressed,
|
|
61
76
|
root: {
|
|
62
77
|
...baseTheme.touchable.root,
|
|
63
|
-
...
|
|
64
|
-
},
|
|
65
|
-
pressed: {
|
|
66
|
-
...baseTheme.touchable.pressed,
|
|
67
|
-
...style.touchable?.pressed
|
|
78
|
+
...conditionalTouchableStyle(reversed, spacing)
|
|
68
79
|
}
|
|
69
80
|
};
|
|
70
81
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SMALL = 'small';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import React, { useEffect, useCallback, useMemo
|
|
1
|
+
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { arrayOf, bool, func, shape, string } from 'prop-types';
|
|
3
3
|
import { isEmpty } from '@widergy/web-utils/lib/array';
|
|
4
|
-
import { isString } from 'lodash';
|
|
5
4
|
import { View } from 'react-native';
|
|
6
5
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { formatErrorToValidation } from '../UTValidation/utils';
|
|
9
8
|
import UTCheckBox from '../UTCheckBox';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import UTFieldLabel from '../UTFieldLabel';
|
|
10
|
+
import UTValidation from '../UTValidation';
|
|
12
11
|
|
|
13
|
-
import { keyExtractor, isChecked } from './utils';
|
|
12
|
+
import { keyExtractor, isChecked, convertIfIsString } from './utils';
|
|
14
13
|
import styles from './styles';
|
|
14
|
+
import { SMALL } from './constants';
|
|
15
15
|
|
|
16
16
|
const UTCheckList = ({
|
|
17
17
|
error,
|
|
18
|
+
horizontalSpacing,
|
|
18
19
|
input,
|
|
19
20
|
label,
|
|
20
21
|
options,
|
|
@@ -22,17 +23,19 @@ const UTCheckList = ({
|
|
|
22
23
|
reversed,
|
|
23
24
|
selectAllLabel,
|
|
24
25
|
showSelectAll,
|
|
25
|
-
style
|
|
26
|
+
style,
|
|
27
|
+
verticalSpacing
|
|
26
28
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
isString(value) ? (value.length === 0 ? [] : JSON.parse(value.replace(/'/g, '"'))) : value;
|
|
29
|
+
const validationData = useMemo(() => error && formatErrorToValidation(error, { withIcon: false }), [error]);
|
|
29
30
|
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (input && input.value) {
|
|
33
|
+
const convertedValue = convertIfIsString(input.value);
|
|
34
|
+
if (JSON.stringify(convertedValue) !== JSON.stringify(input.value)) {
|
|
35
|
+
input.onChange(convertedValue);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
|
-
}, [input
|
|
38
|
+
}, [input]);
|
|
36
39
|
|
|
37
40
|
const enabledOptions = useMemo(() => options.filter(option => !option.disabled), [options]);
|
|
38
41
|
|
|
@@ -49,36 +52,32 @@ const UTCheckList = ({
|
|
|
49
52
|
const handleChange = useCallback(
|
|
50
53
|
receivedValue => () => {
|
|
51
54
|
const { onChange, value } = input;
|
|
52
|
-
const newValues = !value?.
|
|
55
|
+
const newValues = !value?.includes(receivedValue)
|
|
53
56
|
? [...(value || []), receivedValue]
|
|
54
|
-
: value
|
|
55
|
-
|
|
57
|
+
: value.filter(elem => elem !== receivedValue);
|
|
58
|
+
onChange(isEmpty(newValues) ? [] : newValues);
|
|
56
59
|
},
|
|
57
60
|
[input]
|
|
58
61
|
);
|
|
59
62
|
|
|
60
|
-
const handleCheckAll = () => {
|
|
63
|
+
const handleCheckAll = useCallback(() => {
|
|
61
64
|
if (!areAllSelected && options) {
|
|
62
65
|
input.onChange(enabledOptions.map(item => item.value));
|
|
63
66
|
} else {
|
|
64
67
|
input.onChange([]);
|
|
65
68
|
}
|
|
66
|
-
};
|
|
69
|
+
}, [areAllSelected, enabledOptions, input, options]);
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
|
-
<View style={[styles.container, style.root]}>
|
|
72
|
+
<View style={[styles.container, verticalSpacing === SMALL && styles.smallVerticalSpacing, style.root]}>
|
|
70
73
|
<View style={[styles.headerContainer, style.header]}>
|
|
71
|
-
{label && <
|
|
72
|
-
{
|
|
73
|
-
<UTLabel colorTheme="error" variant="small">
|
|
74
|
-
{error}
|
|
75
|
-
</UTLabel>
|
|
76
|
-
)}
|
|
74
|
+
{label && <UTFieldLabel required={required}>{label}</UTFieldLabel>}
|
|
75
|
+
{validationData && <UTValidation validationData={validationData} />}
|
|
77
76
|
</View>
|
|
78
77
|
<View
|
|
79
78
|
style={[
|
|
80
79
|
styles.checkboxesContainer,
|
|
81
|
-
|
|
80
|
+
verticalSpacing === SMALL && styles.smallVerticalSpacing,
|
|
82
81
|
style.checkboxesContainer
|
|
83
82
|
]}
|
|
84
83
|
>
|
|
@@ -89,26 +88,22 @@ const UTCheckList = ({
|
|
|
89
88
|
label={selectAllLabel}
|
|
90
89
|
onPress={handleCheckAll}
|
|
91
90
|
reversed={reversed}
|
|
91
|
+
spacing={horizontalSpacing}
|
|
92
92
|
style={style.selectAll}
|
|
93
93
|
/>
|
|
94
94
|
)}
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
style={style.item}
|
|
108
|
-
/>
|
|
109
|
-
</Fragment>
|
|
110
|
-
);
|
|
111
|
-
})}
|
|
95
|
+
{options?.map((item, index) => (
|
|
96
|
+
<UTCheckBox
|
|
97
|
+
checked={isChecked(item, input.value)}
|
|
98
|
+
disabled={item.disabled}
|
|
99
|
+
key={keyExtractor(item, index)}
|
|
100
|
+
label={item.label}
|
|
101
|
+
onPress={handleChange(item.value)}
|
|
102
|
+
reversed={reversed}
|
|
103
|
+
spacing={horizontalSpacing}
|
|
104
|
+
style={style.item}
|
|
105
|
+
/>
|
|
106
|
+
))}
|
|
112
107
|
</View>
|
|
113
108
|
</View>
|
|
114
109
|
);
|
|
@@ -121,11 +116,12 @@ UTCheckList.defaultProps = {
|
|
|
121
116
|
|
|
122
117
|
UTCheckList.propTypes = {
|
|
123
118
|
error: string,
|
|
124
|
-
|
|
119
|
+
horizontalSpacing: string,
|
|
125
120
|
input: shape({
|
|
126
121
|
value: arrayOf(string),
|
|
127
122
|
onChange: func
|
|
128
123
|
}),
|
|
124
|
+
label: string,
|
|
129
125
|
options: arrayOf(
|
|
130
126
|
shape({
|
|
131
127
|
checked: bool,
|
|
@@ -141,10 +137,11 @@ UTCheckList.propTypes = {
|
|
|
141
137
|
style: shape({
|
|
142
138
|
checkboxesContainer: ViewPropTypes.style,
|
|
143
139
|
header: ViewPropTypes.style,
|
|
144
|
-
item:
|
|
140
|
+
item: ViewPropTypes.style,
|
|
145
141
|
root: ViewPropTypes.style,
|
|
146
142
|
selectAll: ViewPropTypes.style
|
|
147
|
-
})
|
|
143
|
+
}),
|
|
144
|
+
verticalSpacing: string
|
|
148
145
|
};
|
|
149
146
|
|
|
150
147
|
export default UTCheckList;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
2
|
|
|
3
|
+
const NORMAL_SPACING = 16;
|
|
4
|
+
const SMALL_SPACING = 8;
|
|
5
|
+
|
|
3
6
|
export default StyleSheet.create({
|
|
4
7
|
checkboxesContainer: {
|
|
5
|
-
|
|
8
|
+
alignSelf: 'flex-start',
|
|
9
|
+
rowGap: NORMAL_SPACING
|
|
6
10
|
},
|
|
7
11
|
container: {
|
|
8
|
-
rowGap:
|
|
9
|
-
flexGrow: 1
|
|
12
|
+
rowGap: NORMAL_SPACING
|
|
10
13
|
},
|
|
11
14
|
headerContainer: {
|
|
12
15
|
rowGap: 8
|
|
13
16
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
label: {
|
|
18
|
-
flexDirection: 'row'
|
|
19
|
-
},
|
|
20
|
-
reversedCheckBoxesContainer: {
|
|
21
|
-
alignItems: 'flex-end'
|
|
17
|
+
smallVerticalSpacing: {
|
|
18
|
+
rowGap: SMALL_SPACING
|
|
22
19
|
}
|
|
23
20
|
});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { isString } from 'lodash';
|
|
2
|
+
|
|
1
3
|
export const keyExtractor = (_, index) => `CB-${index}`;
|
|
2
4
|
|
|
3
5
|
export const isChecked = (item, inputValue) =>
|
|
4
6
|
!!inputValue?.find(elem => elem === item.value) || (item.disabled && item.checked);
|
|
7
|
+
|
|
8
|
+
export const convertIfIsString = value =>
|
|
9
|
+
isString(value) ? (value.length === 0 ? [] : JSON.parse(value.replace(/'/g, '"'))) : value;
|
|
@@ -7,7 +7,7 @@ import UTLabel from '../UTLabel';
|
|
|
7
7
|
import { REQUIRED_LABEL } from './constants';
|
|
8
8
|
import styles from './styles';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const UTFieldLabel = ({ children, colorTheme, required, variant }) => {
|
|
11
11
|
return (
|
|
12
12
|
<View style={styles.label}>
|
|
13
13
|
<UTLabel colorTheme={colorTheme} variant={variant}>
|
|
@@ -22,10 +22,10 @@ const UTRequiredLabel = ({ children, colorTheme, required, variant }) => {
|
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
UTFieldLabel.propTypes = {
|
|
26
26
|
colorTheme: string,
|
|
27
27
|
required: bool,
|
|
28
28
|
variant: string
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export default
|
|
31
|
+
export default UTFieldLabel;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
`UTIcon` is an icon component that uses the Tabler Icons library.
|
|
5
|
+
`UTIcon` is an icon component that uses the Tabler Icons library.
|
|
6
6
|
|
|
7
7
|
## UX/UI Icon Lists
|
|
8
8
|
|
|
@@ -13,13 +13,13 @@ For a comprehensive list of available icons and their design specifications, ref
|
|
|
13
13
|
|
|
14
14
|
## Props
|
|
15
15
|
|
|
16
|
-
| Name
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
| name
|
|
20
|
-
| shade
|
|
21
|
-
| size
|
|
22
|
-
| style
|
|
16
|
+
| Name | Type | Default | Description |
|
|
17
|
+
| ---------- | ------ | ------- | --------------------------------------------------- |
|
|
18
|
+
| colorTheme | string | 'dark' | The icon color, must be from the theme palette. |
|
|
19
|
+
| name | string | | The name of the icon from the Tabler Icons library. |
|
|
20
|
+
| shade | string | | The shade of the color theme to use. |
|
|
21
|
+
| size | number | | The size of the icon. |
|
|
22
|
+
| style | object | | Custom styles to apply to the icon. |
|
|
23
23
|
|
|
24
24
|
## Icon Names
|
|
25
25
|
|
|
@@ -41,7 +41,7 @@ Exceptions to these rules may exist.
|
|
|
41
41
|
|
|
42
42
|
## Color Themes
|
|
43
43
|
|
|
44
|
-
The `
|
|
44
|
+
The `colorTheme` prop must be one of these values:
|
|
45
45
|
|
|
46
46
|
- `accent`
|
|
47
47
|
- `dark`
|
|
@@ -75,5 +75,5 @@ For all others: `shade05`
|
|
|
75
75
|
## Usage
|
|
76
76
|
|
|
77
77
|
```javascript
|
|
78
|
-
<UTIcon
|
|
78
|
+
<UTIcon colorTheme="primary" name="IconTruckDelivery" size={48} />
|
|
79
79
|
```
|
|
@@ -5,25 +5,23 @@ import * as TablerIcons from '@tabler/icons-react-native';
|
|
|
5
5
|
|
|
6
6
|
import { useTheme } from '../../theming';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { retrieveColor } from './theme';
|
|
9
9
|
|
|
10
|
-
const UTIcon = ({
|
|
10
|
+
const UTIcon = ({ colorTheme = 'dark', name, shade, size, style }) => {
|
|
11
11
|
const theme = useTheme();
|
|
12
12
|
|
|
13
13
|
const IconComponent = TablerIcons[name];
|
|
14
14
|
if (!IconComponent) return null;
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const themeColor = retrieveColor({ colorTheme, theme, shade });
|
|
17
17
|
const filled = name.endsWith('Filled');
|
|
18
|
-
const iconColor = filled ? 'transparent' :
|
|
18
|
+
const iconColor = filled ? 'transparent' : themeColor;
|
|
19
19
|
|
|
20
|
-
return
|
|
21
|
-
<IconComponent color={iconColor} size={size} style={[filled && { color: themeStyles.color }, style]} />
|
|
22
|
-
);
|
|
20
|
+
return <IconComponent color={iconColor} size={size} style={[filled && { color: themeColor }, style]} />;
|
|
23
21
|
};
|
|
24
22
|
|
|
25
23
|
UTIcon.propTypes = {
|
|
26
|
-
|
|
24
|
+
colorTheme: string,
|
|
27
25
|
name: string,
|
|
28
26
|
shade: string,
|
|
29
27
|
size: number,
|
|
@@ -7,12 +7,8 @@ const getDefaultColorShade = colorTheme =>
|
|
|
7
7
|
? SHADES.shade01
|
|
8
8
|
: SHADES.shade05;
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
export const retrieveColor = ({ colorTheme, shade, theme }) => {
|
|
11
11
|
const colorThemeDefinition = theme.Palette[colorTheme] || theme.Palette[DEFAULT_PROPS.color];
|
|
12
12
|
const colorShade = shade || getDefaultColorShade(colorTheme);
|
|
13
13
|
return colorThemeDefinition[colorShade] || '#000';
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
export const retrieveStyle = ({ color: colorTheme, shade, theme }) => ({
|
|
17
|
-
color: variantsColorTheme(colorTheme, shade, theme)
|
|
18
|
-
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
2
|
import { isEmpty } from '@widergy/web-utils/lib/array';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import UTTextInput from '../UTTextInput';
|
|
6
|
-
import UTMenu from '../UTMenu';
|
|
7
5
|
import Label from '../Label';
|
|
6
|
+
import UTMenu from '../UTMenu';
|
|
7
|
+
import UTTextInput from '../UTTextInput';
|
|
8
8
|
|
|
9
|
+
import MultipleItem from './componentes/MultipleItem';
|
|
9
10
|
import styles from './styles';
|
|
10
11
|
import UTSelectTypes from './proptypes';
|
|
11
|
-
import MultipleItem from './componentes/MultipleItem';
|
|
12
12
|
|
|
13
13
|
const UTSelect = ({
|
|
14
14
|
options = [],
|
|
@@ -89,6 +89,7 @@ const UTSelect = ({
|
|
|
89
89
|
select
|
|
90
90
|
controlledFocus={focused}
|
|
91
91
|
disabled={disabled}
|
|
92
|
+
version="V0"
|
|
92
93
|
RightIcon={{ type: 'font-awesome', name: 'caret-down' }}
|
|
93
94
|
{...UTTextInputProps}
|
|
94
95
|
/>
|
|
@@ -3,11 +3,11 @@ import React from 'react';
|
|
|
3
3
|
import UTTextInput from '../UTTextInput';
|
|
4
4
|
import propTypes from '../UTTextInput/versions/V1/proptypes';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_PROPS } from './constants';
|
|
7
7
|
|
|
8
|
-
const UTTextArea = ({ maxRows
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const UTTextArea = ({ maxRows, ...props }) => <UTTextInput maxRows={maxRows} version="V1" {...props} />;
|
|
9
|
+
|
|
10
|
+
UTTextArea.defaultProps = DEFAULT_PROPS;
|
|
11
11
|
|
|
12
12
|
UTTextArea.propTypes = propTypes;
|
|
13
13
|
|
|
@@ -50,15 +50,15 @@ Configuration object for the action button.
|
|
|
50
50
|
|
|
51
51
|
It must be one of these:
|
|
52
52
|
|
|
53
|
-
- "
|
|
54
|
-
- "
|
|
53
|
+
- "small": small
|
|
54
|
+
- "large": large
|
|
55
55
|
|
|
56
56
|
### inputSize
|
|
57
57
|
|
|
58
58
|
It must be one of these:
|
|
59
59
|
|
|
60
|
-
- "
|
|
61
|
-
- "
|
|
60
|
+
- "small": small
|
|
61
|
+
- "large": large
|
|
62
62
|
|
|
63
63
|
### type
|
|
64
64
|
|
|
@@ -147,11 +147,7 @@ If both `error` and `validations` are provided, `validations` will take preceden
|
|
|
147
147
|
#### Example usage with `error`:
|
|
148
148
|
|
|
149
149
|
```jsx
|
|
150
|
-
<UTTextInput
|
|
151
|
-
label="Username"
|
|
152
|
-
placeholder="Enter your username"
|
|
153
|
-
error="This username is already taken"
|
|
154
|
-
/>
|
|
150
|
+
<UTTextInput label="Username" placeholder="Enter your username" error="This username is already taken" />
|
|
155
151
|
```
|
|
156
152
|
|
|
157
153
|
#### Example usage with validations:
|
|
@@ -192,12 +188,7 @@ const validations = [
|
|
|
192
188
|
}
|
|
193
189
|
];
|
|
194
190
|
|
|
195
|
-
<UTTextInput
|
|
196
|
-
label="Email"
|
|
197
|
-
placeholder="Enter your email"
|
|
198
|
-
validations={validations}
|
|
199
|
-
/>
|
|
200
|
-
|
|
191
|
+
<UTTextInput label="Email" placeholder="Enter your email" validations={validations} />;
|
|
201
192
|
```
|
|
202
193
|
|
|
203
194
|
## Usage
|