@widergy/mobile-ui 1.13.5 → 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 +14 -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/UTRoundView/index.js +22 -9
- package/lib/components/UTRoundView/propTypes.js +4 -2
- package/lib/components/UTRoundView/styles.js +8 -0
- package/lib/components/UTRoundView/utils.js +14 -0
- 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 +4 -3
- 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,25 +1,38 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
2
|
import { View, Animated } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import merge from 'lodash/merge';
|
|
4
4
|
|
|
5
5
|
import { useTheme } from '../../theming';
|
|
6
6
|
import Surface from '../Surface';
|
|
7
7
|
|
|
8
8
|
import propTypes from './propTypes';
|
|
9
9
|
import ownStyles from './styles';
|
|
10
|
+
import { generateBackgroundGradient } from './utils';
|
|
10
11
|
|
|
11
|
-
const UTRoundView = ({ children, styles, withShadow = false }) => {
|
|
12
|
+
const UTRoundView = ({ children, styles, withShadow = false, startColor, endColor }) => {
|
|
12
13
|
const theme = useTheme();
|
|
13
|
-
const themedStyles =
|
|
14
|
+
const themedStyles = merge({}, theme?.roundView, styles);
|
|
15
|
+
const withBackgroundGradient = !!startColor && !!endColor;
|
|
14
16
|
|
|
15
17
|
const ChildrenContainer = withShadow ? Surface : View;
|
|
16
18
|
|
|
17
19
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<Fragment>
|
|
21
|
+
{withBackgroundGradient && (
|
|
22
|
+
<View style={ownStyles.backgroundGradient}>{generateBackgroundGradient(startColor, endColor)}</View>
|
|
23
|
+
)}
|
|
24
|
+
<Animated.View
|
|
25
|
+
style={[
|
|
26
|
+
ownStyles.container,
|
|
27
|
+
themedStyles?.outerContainer,
|
|
28
|
+
withBackgroundGradient && ownStyles?.outerWithBackground
|
|
29
|
+
]}
|
|
30
|
+
>
|
|
31
|
+
<ChildrenContainer position="top" style={[ownStyles.innerContainer, themedStyles?.innerContainer]}>
|
|
32
|
+
{children}
|
|
33
|
+
</ChildrenContainer>
|
|
34
|
+
</Animated.View>
|
|
35
|
+
</Fragment>
|
|
23
36
|
);
|
|
24
37
|
};
|
|
25
38
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
2
|
-
import { shape } from 'prop-types';
|
|
2
|
+
import { shape, string } from 'prop-types';
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
styles: shape({
|
|
6
6
|
outerContainer: ViewPropTypes.style,
|
|
7
7
|
innerContainer: ViewPropTypes.style
|
|
8
|
-
})
|
|
8
|
+
}),
|
|
9
|
+
startColor: string,
|
|
10
|
+
endColor: string
|
|
9
11
|
};
|
|
@@ -3,6 +3,11 @@ import { StyleSheet } from 'react-native';
|
|
|
3
3
|
export const ROUND_VIEW_BORDER_RADIUS = 25;
|
|
4
4
|
|
|
5
5
|
const styles = StyleSheet.create({
|
|
6
|
+
backgroundGradient: {
|
|
7
|
+
height: '100%',
|
|
8
|
+
position: 'absolute',
|
|
9
|
+
width: '100%'
|
|
10
|
+
},
|
|
6
11
|
container: {
|
|
7
12
|
flex: 1
|
|
8
13
|
},
|
|
@@ -13,6 +18,9 @@ const styles = StyleSheet.create({
|
|
|
13
18
|
borderTopLeftRadius: ROUND_VIEW_BORDER_RADIUS,
|
|
14
19
|
borderTopRightRadius: ROUND_VIEW_BORDER_RADIUS,
|
|
15
20
|
paddingTop: ROUND_VIEW_BORDER_RADIUS
|
|
21
|
+
},
|
|
22
|
+
outerWithBackground: {
|
|
23
|
+
backgroundColor: 'transparent'
|
|
16
24
|
}
|
|
17
25
|
});
|
|
18
26
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Svg, { Rect, LinearGradient, Defs, Stop } from 'react-native-svg';
|
|
3
|
+
|
|
4
|
+
export const generateBackgroundGradient = (startColor, endColor) => (
|
|
5
|
+
<Svg height="100%" width="100%">
|
|
6
|
+
<Defs>
|
|
7
|
+
<LinearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="0%">
|
|
8
|
+
<Stop offset="0%" stopColor={startColor} stopOpacity="1" />
|
|
9
|
+
<Stop offset="100%" stopColor={endColor} stopOpacity="1" />
|
|
10
|
+
</LinearGradient>
|
|
11
|
+
</Defs>
|
|
12
|
+
<Rect x="0" y="0" width="100%" height="100%" fill="url(#gradient1)" />
|
|
13
|
+
</Svg>
|
|
14
|
+
);
|
|
@@ -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
|
/>
|