@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.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/Surface/propTypes.js +3 -2
  3. package/lib/components/UTBaseInputField/README.md +179 -0
  4. package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +41 -0
  5. package/lib/components/UTBaseInputField/components/IconAdornment/constants.js +1 -0
  6. package/lib/components/UTBaseInputField/components/IconAdornment/index.js +32 -0
  7. package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +2 -0
  8. package/lib/components/UTBaseInputField/components/PrefixAdornment/index.js +16 -0
  9. package/lib/components/UTBaseInputField/components/SuffixAdornment/index.js +12 -0
  10. package/lib/components/UTBaseInputField/components/TooltipAdornment/index.js +19 -0
  11. package/lib/components/UTBaseInputField/constants.js +34 -0
  12. package/lib/components/UTBaseInputField/index.js +191 -0
  13. package/lib/components/{UTTextInput/versions/V1/components/TextInputField → UTBaseInputField}/theme.js +3 -2
  14. package/lib/components/UTButton/README.md +1 -1
  15. package/lib/components/UTButton/index.js +8 -2
  16. package/lib/components/UTCheckBox/README.md +15 -17
  17. package/lib/components/UTCheckBox/constants.js +2 -0
  18. package/lib/components/UTCheckBox/index.js +50 -24
  19. package/lib/components/UTCheckBox/proptypes.js +7 -10
  20. package/lib/components/UTCheckBox/theme.js +26 -15
  21. package/lib/components/UTCheckList/constants.js +1 -0
  22. package/lib/components/UTCheckList/index.js +43 -46
  23. package/lib/components/UTCheckList/styles.js +8 -11
  24. package/lib/components/UTCheckList/utils.js +5 -0
  25. package/lib/components/{UTRequiredLabel → UTFieldLabel}/index.js +3 -3
  26. package/lib/components/UTIcon/README.md +10 -10
  27. package/lib/components/UTIcon/index.js +6 -8
  28. package/lib/components/UTIcon/theme.js +1 -5
  29. package/lib/components/UTRoundView/index.js +22 -9
  30. package/lib/components/UTRoundView/propTypes.js +4 -2
  31. package/lib/components/UTRoundView/styles.js +8 -0
  32. package/lib/components/UTRoundView/utils.js +14 -0
  33. package/lib/components/UTSelect/index.js +5 -4
  34. package/lib/components/UTTextArea/constants.js +3 -1
  35. package/lib/components/UTTextArea/index.js +4 -4
  36. package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +1 -1
  37. package/lib/components/UTTextInput/versions/V1/README.md +6 -15
  38. package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +67 -201
  39. package/lib/components/UTTextInput/versions/V1/constants.js +1 -1
  40. package/lib/components/UTTextInput/versions/V1/index.js +5 -5
  41. package/lib/components/UTValidation/README.md +9 -6
  42. package/lib/components/UTValidation/index.js +8 -6
  43. package/lib/components/UTValidation/utils.js +4 -0
  44. package/package.json +4 -3
  45. package/lib/components/UTTextInput/versions/V1/components/TextInputField/constants.js +0 -12
  46. package/lib/components/UTTextInput/versions/V1/components/TextInputField/utils.js +0 -13
  47. package/lib/components/UTTextInput/versions/V1/utils.js +0 -1
  48. /package/lib/components/{UTRequiredLabel → UTFieldLabel}/constants.js +0 -0
  49. /package/lib/components/{UTRequiredLabel → UTFieldLabel}/styles.js +0 -0
  50. /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 UTLabel from '../UTLabel';
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 = ({ checked, disabled, indeterminate, label, onPress, reversed, style }) => {
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 { containerStyles, iconContainerStyles, touchableStyles } = retrieveStyle({
15
- checked,
16
- disabled,
17
- indeterminate,
18
- reversed,
19
- style,
20
- theme
21
- });
24
+ const [pressed, setPressed] = useState(false);
22
25
 
23
- const combinedTouchableStyles = ({ pressed }) => [touchableStyles.root, pressed && touchableStyles.pressed];
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 = indeterminate ? INDETERMINATE_ICON : checked ? CHECKED_ICON : '';
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
- <View style={containerStyles}>
29
- <Pressable disabled={disabled} onPress={onPress} style={combinedTouchableStyles}>
30
- <View style={iconContainerStyles}>
31
- <UTIcon color="light" name={iconName} size={16} />
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
- </Pressable>
34
- <UTLabel>{label}</UTLabel>
35
- </View>
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, shape, string } from 'prop-types';
1
+ import { bool, func, string } from 'prop-types';
2
2
  import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
3
 
4
- export const styleProptypes = shape({
5
- root: ViewPropTypes.style,
6
- icon: ViewPropTypes.style,
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
- style: styleProptypes
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
- columnGap: 16,
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 = (reversed, disabled) => ({
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
- export const retrieveStyle = ({ checked, disabled, indeterminate, reversed, style = {}, theme }) => {
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(reversed, disabled),
51
- ...style.root
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
- ...style.touchable?.root
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, Fragment } from 'react';
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 { styleProptypes as checboxStyleProptypes } from '../UTCheckBox/proptypes';
7
+ import { formatErrorToValidation } from '../UTValidation/utils';
9
8
  import UTCheckBox from '../UTCheckBox';
10
- import UTLabel from '../UTLabel';
11
- import UTRequiredLabel from '../UTRequiredLabel';
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 convertIfIsString = value =>
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
- const convertedValue = convertIfIsString(input.value);
32
- if (JSON.stringify(convertedValue) !== JSON.stringify(input.value)) {
33
- input.onChange(convertedValue);
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.value, 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?.find?.(elem => elem === receivedValue)
55
+ const newValues = !value?.includes(receivedValue)
53
56
  ? [...(value || []), receivedValue]
54
- : value?.filter(elem => elem !== receivedValue);
55
- if (onChange) onChange(isEmpty(newValues) ? [] : newValues);
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 && <UTRequiredLabel required={required}>{label}</UTRequiredLabel>}
72
- {error && (
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
- reversed && styles.reversedCheckBoxesContainer,
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
- {!!options?.length &&
96
- options.map((item, index) => {
97
- const { label: itemLabel, disabled, value } = item;
98
-
99
- return (
100
- <Fragment key={keyExtractor(item, index)}>
101
- <UTCheckBox
102
- checked={isChecked(item, input.value)}
103
- disabled={disabled}
104
- label={itemLabel}
105
- onPress={handleChange(value)}
106
- reversed={reversed}
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
- label: string,
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: checboxStyleProptypes,
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
- rowGap: 16
8
+ alignSelf: 'flex-start',
9
+ rowGap: NORMAL_SPACING
6
10
  },
7
11
  container: {
8
- rowGap: 16,
9
- flexGrow: 1
12
+ rowGap: NORMAL_SPACING
10
13
  },
11
14
  headerContainer: {
12
15
  rowGap: 8
13
16
  },
14
- itemSeparator: {
15
- height: 16
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 UTRequiredLabel = ({ children, colorTheme, required, variant }) => {
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
- UTRequiredLabel.propTypes = {
25
+ UTFieldLabel.propTypes = {
26
26
  colorTheme: string,
27
27
  required: bool,
28
28
  variant: string
29
29
  };
30
30
 
31
- export default UTRequiredLabel;
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. It allows for easy integration of vector icons in your application, providing various customization options such as color, size, and style.
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 | Type | Default | Description |
17
- | ----- | ------ | ------- | --------------------------------------------------- |
18
- | color | 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. |
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 `color` prop must be one of these values:
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 color="primary" name="IconTruckDelivery" size={48} />
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 { retrieveStyle } from './theme';
8
+ import { retrieveColor } from './theme';
9
9
 
10
- const UTIcon = ({ color = 'dark', name, shade, size, style }) => {
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 themeStyles = retrieveStyle({ color, theme, shade });
16
+ const themeColor = retrieveColor({ colorTheme, theme, shade });
17
17
  const filled = name.endsWith('Filled');
18
- const iconColor = filled ? 'transparent' : themeStyles.color;
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
- color: string,
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 variantsColorTheme = (colorTheme, shade, theme) => {
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 _ from 'lodash';
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 = _.merge({}, theme?.roundView, styles);
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
- <Animated.View style={[ownStyles.container, themedStyles?.outerContainer]}>
19
- <ChildrenContainer position="top" style={[ownStyles.innerContainer, themedStyles?.innerContainer]}>
20
- {children}
21
- </ChildrenContainer>
22
- </Animated.View>
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
  />
@@ -1 +1,3 @@
1
- export const DEFAULT_MAX_ROWS = 4;
1
+ const DEFAULT_MAX_ROWS = 4;
2
+
3
+ export const DEFAULT_PROPS = { maxRows: DEFAULT_MAX_ROWS };