@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.
Files changed (72) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/Button/index.js +1 -1
  3. package/lib/components/UTBadge/index.js +2 -2
  4. package/lib/components/UTBadge/theme.js +9 -6
  5. package/lib/components/UTBaseInputField/README.md +45 -31
  6. package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +5 -16
  7. package/lib/components/UTBaseInputField/components/BadgeAdornment/index.js +13 -0
  8. package/lib/components/UTBaseInputField/components/IconAdornment/constants.js +2 -0
  9. package/lib/components/UTBaseInputField/components/IconAdornment/index.js +20 -15
  10. package/lib/components/UTBaseInputField/components/IconAdornment/proptypes.js +20 -0
  11. package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +7 -2
  12. package/lib/components/UTBaseInputField/constants.js +12 -1
  13. package/lib/components/UTBaseInputField/index.js +69 -72
  14. package/lib/components/UTBaseInputField/proptypes.js +60 -0
  15. package/lib/components/UTBaseInputField/theme.js +72 -32
  16. package/lib/components/UTBottomSheet/README.md +53 -0
  17. package/lib/components/UTBottomSheet/index.js +139 -0
  18. package/lib/components/UTBottomSheet/styles.js +46 -0
  19. package/lib/components/UTButton/constants.js +5 -14
  20. package/lib/components/UTButton/index.js +6 -22
  21. package/lib/components/UTButton/proptypes.js +29 -0
  22. package/lib/components/UTButton/theme.js +6 -5
  23. package/lib/components/UTCheckBox/README.md +4 -30
  24. package/lib/components/UTCheckBox/constants.js +4 -1
  25. package/lib/components/UTCheckBox/index.js +33 -22
  26. package/lib/components/UTCheckBox/proptypes.js +12 -3
  27. package/lib/components/UTCheckBox/styles.js +7 -0
  28. package/lib/components/UTCheckBox/theme.js +98 -54
  29. package/lib/components/UTCheckList/README.MD +14 -10
  30. package/lib/components/UTCheckList/constants.js +6 -1
  31. package/lib/components/UTCheckList/index.js +44 -66
  32. package/lib/components/UTCheckList/proptypes.js +48 -0
  33. package/lib/components/UTCheckList/styles.js +10 -5
  34. package/lib/components/UTCheckList/utils.js +5 -0
  35. package/lib/components/UTFieldLabel/index.js +4 -3
  36. package/lib/components/UTIcon/README.md +46 -7
  37. package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCar.svg +17 -0
  38. package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCart.svg +6 -0
  39. package/lib/components/UTIcon/components/EnergyIcons/EnergyIconHome.svg +5 -0
  40. package/lib/components/UTIcon/components/EnergyIcons/EnergyIconTruck.svg +7 -0
  41. package/lib/components/UTIcon/constants.js +14 -0
  42. package/lib/components/UTIcon/index.js +19 -8
  43. package/lib/components/UTIcon/utils.js +34 -0
  44. package/lib/components/UTLabel/constants.js +11 -11
  45. package/lib/components/UTLabel/index.js +3 -17
  46. package/lib/components/UTLabel/proptypes.js +19 -0
  47. package/lib/components/UTLabel/theme.js +2 -2
  48. package/lib/components/UTMenu/index.js +1 -1
  49. package/lib/components/UTPasswordField/versions/V0/components/PasswordValidations/styles.js +1 -0
  50. package/lib/components/UTPasswordField/versions/V1/index.js +3 -2
  51. package/lib/components/UTSearchField/README.md +42 -0
  52. package/lib/components/UTSearchField/index.js +59 -0
  53. package/lib/components/UTSearchField/proptypes.js +28 -0
  54. package/lib/components/UTSelect/index.js +10 -97
  55. package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/index.js +1 -1
  56. package/lib/components/UTSelect/versions/V0/index.js +103 -0
  57. package/lib/components/UTSelect/versions/V1/README.md +82 -0
  58. package/lib/components/UTSelect/versions/V1/index.js +171 -0
  59. package/lib/components/UTSelect/versions/V1/proptypes.js +45 -0
  60. package/lib/components/UTSelect/versions/V1/styles.js +18 -0
  61. package/lib/components/UTTextArea/index.js +1 -1
  62. package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +3 -3
  63. package/lib/components/UTTextInput/versions/V1/README.md +36 -35
  64. package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +18 -12
  65. package/lib/components/UTTextInput/versions/V1/constants.js +3 -5
  66. package/lib/components/UTTextInput/versions/V1/index.js +21 -18
  67. package/lib/components/UTTextInput/versions/V1/proptypes.js +23 -6
  68. package/lib/index.js +47 -52
  69. package/package.json +2 -2
  70. /package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/styles.js +0 -0
  71. /package/lib/components/UTSelect/{proptypes.js → versions/V0/proptypes.js} +0 -0
  72. /package/lib/components/UTSelect/{styles.js → versions/V0/styles.js} +0 -0
@@ -1,45 +1,45 @@
1
- import React, { useState, useMemo } from 'react';
1
+ import React, { useState, useMemo, useCallback } from 'react';
2
2
  import { View, Pressable } from 'react-native';
3
3
 
4
4
  import { useTheme } from '../../theming';
5
- import UTIcon from '../UTIcon';
6
5
  import UTFieldLabel from '../UTFieldLabel';
6
+ import UTIcon from '../UTIcon';
7
7
 
8
8
  import { CHECKED_ICON, INDETERMINATE_ICON } from './constants';
9
+ import { propTypes, defaultProps } from './proptypes';
9
10
  import { retrieveStyle } from './theme';
10
- import propTypes, { DEFAULT_PROPS } from './proptypes';
11
+ import styles from './styles';
11
12
 
12
13
  const UTCheckBox = ({
13
14
  checked,
14
15
  disabled,
16
+ isSimple,
15
17
  indeterminate,
16
18
  label,
17
19
  onPress,
18
20
  required,
19
21
  reversed,
20
22
  spacing,
21
- style
23
+ style,
24
+ variant
22
25
  }) => {
23
26
  const theme = useTheme();
24
27
  const [pressed, setPressed] = useState(false);
25
28
 
26
- const { containerStyles, iconContainerStyles, touchableStyles } = useMemo(
29
+ const { containerStyles, iconContainerStyles, boxStyles, pressableStyles } = useMemo(
27
30
  () =>
28
31
  retrieveStyle({
29
32
  checked,
30
33
  disabled,
31
34
  indeterminate,
35
+ pressed,
32
36
  reversed,
33
37
  spacing,
34
38
  style,
35
- theme
39
+ theme,
40
+ variant
36
41
  }),
37
- [checked, disabled, indeterminate, reversed, spacing, style, theme]
38
- );
39
-
40
- const combinedTouchableStyles = useMemo(
41
- () => [touchableStyles.root, pressed && touchableStyles.pressed],
42
- [pressed, touchableStyles]
42
+ [checked, disabled, indeterminate, reversed, spacing, style, theme, variant, pressed]
43
43
  );
44
44
 
45
45
  const iconName = useMemo(
@@ -47,25 +47,36 @@ const UTCheckBox = ({
47
47
  [indeterminate, checked]
48
48
  );
49
49
 
50
- const handlePressIn = () => setPressed(true);
51
- const handlePressOut = () => setPressed(false);
50
+ const handlePressIn = useCallback(() => setPressed(true), []);
51
+ const handlePressOut = useCallback(() => setPressed(false), []);
52
52
 
53
53
  return (
54
- <Pressable disabled={disabled} onPress={onPress} onPressIn={handlePressIn} onPressOut={handlePressOut}>
54
+ <Pressable
55
+ style={pressableStyles}
56
+ disabled={disabled}
57
+ onPress={onPress}
58
+ onPressIn={handlePressIn}
59
+ onPressOut={handlePressOut}
60
+ >
55
61
  <View style={containerStyles}>
56
- <View style={combinedTouchableStyles}>
57
- <View style={iconContainerStyles}>
58
- <UTIcon colorTheme="light" name={iconName} size={16} />
62
+ {isSimple ? (
63
+ <UTIcon name="IconCheck" shade="04" colorTheme="accent" style={!checked && styles.hidden} />
64
+ ) : (
65
+ <View style={boxStyles}>
66
+ <View style={iconContainerStyles}>
67
+ <UTIcon colorTheme="light" name={iconName} size={16} />
68
+ </View>
59
69
  </View>
60
- </View>
61
- <UTFieldLabel required={required}>{label}</UTFieldLabel>
70
+ )}
71
+ <UTFieldLabel required={required} colorTheme={checked && 'accent'} shade={checked && '05'}>
72
+ {label}
73
+ </UTFieldLabel>
62
74
  </View>
63
75
  </Pressable>
64
76
  );
65
77
  };
66
78
 
67
- UTCheckBox.defaultProps = DEFAULT_PROPS;
68
-
79
+ UTCheckBox.defaultProps = defaultProps;
69
80
  UTCheckBox.propTypes = propTypes;
70
81
 
71
82
  export default UTCheckBox;
@@ -1,18 +1,27 @@
1
1
  import { bool, func, string } from 'prop-types';
2
2
  import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
3
 
4
- export const DEFAULT_PROPS = {
4
+ import { SPACING } from './constants';
5
+
6
+ export const defaultProps = {
7
+ /**
8
+ * @deprecated The "isSimple" prop is deprecated and will be removed in a future release. Please do not use it.
9
+ */
10
+ isSimple: false,
11
+ spacing: SPACING.LARGE,
5
12
  style: {}
6
13
  };
7
14
 
8
- export default {
15
+ export const propTypes = {
9
16
  checked: bool,
10
17
  disabled: bool,
11
18
  indeterminate: bool,
19
+ isSimple: bool,
12
20
  label: string,
13
21
  onPress: func,
14
22
  required: bool,
15
23
  reversed: bool,
16
24
  spacing: string,
17
- style: ViewPropTypes.style
25
+ style: ViewPropTypes.style,
26
+ variant: string
18
27
  };
@@ -0,0 +1,7 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ hidden: {
5
+ opacity: 0
6
+ }
7
+ });
@@ -1,4 +1,6 @@
1
- import { SMALL } from './constants';
1
+ import { BUTTON_VARIANT } from '../UTCheckList/constants';
2
+
3
+ import { SPACING } from './constants';
2
4
 
3
5
  const NORMAL_SPACING = 16;
4
6
  const SMALL_SPACING = 8;
@@ -15,69 +17,111 @@ const baseCheckBoxTheme = theme => ({
15
17
  height: 20,
16
18
  width: 20
17
19
  },
18
- touchable: {
19
- root: {
20
- borderRadius: 25,
21
- padding: 6
22
- },
23
- pressed: {
24
- backgroundColor: theme.Palette.accent['02'],
25
- borderColor: theme.Palette.accent['03'],
26
- borderWidth: 1,
27
- padding: 5
28
- }
20
+ box: {
21
+ borderRadius: 25,
22
+ overflow: 'hidden',
23
+ padding: 6
29
24
  }
30
25
  });
31
26
 
32
- const conditionalContainerStyle = (disabled, reversed) => ({
33
- ...(reversed && {
34
- flexDirection: 'row-reverse',
35
- justifyContent: 'space-between'
36
- }),
37
- ...(disabled && {
38
- opacity: 0.5
39
- })
40
- });
27
+ const conditionalStyles = ({
28
+ checked,
29
+ disabled,
30
+ indeterminate,
31
+ reversed,
32
+ spacing,
33
+ variant,
34
+ pressed,
35
+ theme
36
+ }) => {
37
+ const spacingValue = spacing === SPACING.SMALL ? SMALL_SPACING : NORMAL_SPACING;
41
38
 
42
- const conditionalIconContainerStyle = (checked, indeterminate, theme) => ({
43
- ...((checked || indeterminate) && {
44
- backgroundColor: theme.Palette.accent['04'],
45
- borderColor: theme.Palette.accent['04']
46
- })
47
- });
39
+ const pressable =
40
+ variant === BUTTON_VARIANT
41
+ ? {
42
+ borderRadius: 8,
43
+ paddingHorizontal: 16,
44
+ paddingVertical: 12,
45
+ ...(pressed && {
46
+ backgroundColor: theme.Palette.light['04']
47
+ })
48
+ }
49
+ : {};
48
50
 
49
- const conditionalTouchableStyle = (reversed, spacing) => {
50
- const spacingValue = spacing === SMALL ? SMALL_SPACING : NORMAL_SPACING;
51
51
  return {
52
- marginRight: spacingValue,
53
- ...(reversed && {
54
- marginLeft: spacingValue,
55
- marginRight: 0
56
- })
52
+ container: {
53
+ ...(reversed && {
54
+ flexDirection: 'row-reverse',
55
+ justifyContent: 'space-between'
56
+ }),
57
+ ...(disabled && {
58
+ opacity: 0.5
59
+ })
60
+ },
61
+ iconContainer: {
62
+ ...((checked || indeterminate) && {
63
+ backgroundColor: theme.Palette.accent['04'],
64
+ borderColor: theme.Palette.accent['04']
65
+ })
66
+ },
67
+ box: {
68
+ ...(reversed
69
+ ? {
70
+ marginLeft: spacingValue,
71
+ marginRight: 0
72
+ }
73
+ : { marginRight: spacingValue }),
74
+ ...(pressed &&
75
+ variant !== BUTTON_VARIANT && {
76
+ backgroundColor: theme.Palette.accent['02'],
77
+ borderColor: theme.Palette.accent['03'],
78
+ borderWidth: 1,
79
+ overflow: 'hidden',
80
+ padding: 5
81
+ })
82
+ },
83
+ pressable
57
84
  };
58
85
  };
59
86
 
60
- export const retrieveStyle = ({ checked, disabled, indeterminate, reversed, spacing, style, theme }) => {
61
- const baseTheme = baseCheckBoxTheme(theme);
87
+ export const retrieveStyle = ({
88
+ checked,
89
+ disabled,
90
+ indeterminate,
91
+ reversed,
92
+ spacing,
93
+ style,
94
+ theme,
95
+ variant,
96
+ pressed
97
+ }) => {
98
+ const baseThemeStyles = baseCheckBoxTheme(theme);
62
99
 
63
- const containerStyles = {
64
- ...baseTheme.container,
65
- ...conditionalContainerStyle(disabled, reversed),
66
- ...style
67
- };
100
+ const { container, iconContainer, box, pressable } = conditionalStyles({
101
+ checked,
102
+ disabled,
103
+ indeterminate,
104
+ reversed,
105
+ spacing,
106
+ variant,
107
+ pressed,
108
+ theme
109
+ });
68
110
 
69
- const iconContainerStyles = {
70
- ...baseTheme.iconContainer,
71
- ...conditionalIconContainerStyle(checked, indeterminate, theme)
72
- };
73
-
74
- const touchableStyles = {
75
- pressed: baseTheme.touchable.pressed,
76
- root: {
77
- ...baseTheme.touchable.root,
78
- ...conditionalTouchableStyle(reversed, spacing)
79
- }
111
+ return {
112
+ containerStyles: {
113
+ ...baseThemeStyles.container,
114
+ ...container,
115
+ ...style
116
+ },
117
+ iconContainerStyles: {
118
+ ...baseThemeStyles.iconContainer,
119
+ ...iconContainer
120
+ },
121
+ boxStyles: {
122
+ ...baseThemeStyles.box,
123
+ ...box
124
+ },
125
+ pressableStyles: pressable
80
126
  };
81
-
82
- return { containerStyles, iconContainerStyles, touchableStyles };
83
127
  };
@@ -6,16 +6,20 @@
6
6
 
7
7
  ## Props
8
8
 
9
- | Name | Type | Default | Description |
10
- | -------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
11
- | error | string | | Error message to display. |
12
- | input | shape | | Input configuration object containing `value` and `onChange`. |
13
- | label | string | | Label for the checklist. |
14
- | options | array | | Array of options to be displayed as checkboxes. Each option is an object with `label` and `value`. |
15
- | required | bool | false | Indicates if the checklist is required. |
16
- | reversed | bool | false | If true, reverses the order of label and checkbox. |
17
- | selectAllLabel | string | | Label for the "Select All" checkbox. |
18
- | style | shape | {} | Custom styles to apply to the checklist. Can contain `root`, `header`, `checkboxesContainer`, `item`, and `selectAll`. |
9
+ | Name | Type | Default | Description |
10
+ | ----------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------- |
11
+ | error | string | | Error message to display. |
12
+ | input | shape | | Input configuration object containing `value` and `onChange`. |
13
+ | label | string | | Label for the checklist. |
14
+ | options | array | | Array of options to be displayed as checkboxes. Each option is an object with `label` and `value`. |
15
+ | required | bool | false | Indicates if the checklist is required. |
16
+ | reversed | bool | false | If true, reverses the order of label and checkbox. |
17
+ | selectAllLabel | string | | Label for the "Select All" checkbox. |
18
+ | showSelectAll | bool | true | Determines whether to show the "Select All" checkbox. |
19
+ | style | shape | {} | Custom styles to apply to the checklist. Can contain `root`, `header`, `checkboxesContainer`, `item`, and `selectAll`. |
20
+ | variant | string | | Variant style for the checklist. |
21
+ | horizontalSpacing | string | large | Spacing between the checkbox and the label horizontally. |
22
+ | verticalSpacing | string | large | Spacing between the checkbox items vertically. |
19
23
 
20
24
  ### Input Object
21
25
 
@@ -1 +1,6 @@
1
- export const SMALL = 'small';
1
+ export const SPACING = {
2
+ SMALL: 'small',
3
+ LARGE: 'large'
4
+ };
5
+
6
+ export const BUTTON_VARIANT = 'button';
@@ -1,22 +1,21 @@
1
1
  import React, { useEffect, useCallback, useMemo } from 'react';
2
- import { arrayOf, bool, func, shape, string } from 'prop-types';
3
- import { isEmpty } from '@widergy/web-utils/lib/array';
4
2
  import { View } from 'react-native';
5
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
6
3
 
7
4
  import { formatErrorToValidation } from '../UTValidation/utils';
8
5
  import UTCheckBox from '../UTCheckBox';
9
6
  import UTFieldLabel from '../UTFieldLabel';
10
7
  import UTValidation from '../UTValidation';
11
8
 
12
- import { keyExtractor, isChecked, convertIfIsString } from './utils';
9
+ import { keyExtractor, isChecked, convertIfIsString, getPropValueBasedOnVariant } from './utils';
13
10
  import styles from './styles';
14
- import { SMALL } from './constants';
11
+ import { defaultProps, propTypes } from './proptypes';
12
+ import { BUTTON_VARIANT, SPACING } from './constants';
15
13
 
16
14
  const UTCheckList = ({
17
15
  error,
18
16
  horizontalSpacing,
19
17
  input,
18
+ isSimple,
20
19
  label,
21
20
  options,
22
21
  required,
@@ -24,52 +23,59 @@ const UTCheckList = ({
24
23
  selectAllLabel,
25
24
  showSelectAll,
26
25
  style,
26
+ variant,
27
27
  verticalSpacing
28
28
  }) => {
29
+ const { value, onChange } = input;
30
+
31
+ const reversedBasedOnVariant = getPropValueBasedOnVariant(variant, reversed, true);
32
+ const verticalSpacingBasedOnVariant = getPropValueBasedOnVariant(variant, verticalSpacing, SPACING.SMALL);
33
+
29
34
  const validationData = useMemo(() => error && formatErrorToValidation(error, { withIcon: false }), [error]);
30
35
 
31
36
  useEffect(() => {
32
- if (input && input.value) {
33
- const convertedValue = convertIfIsString(input.value);
34
- if (JSON.stringify(convertedValue) !== JSON.stringify(input.value)) {
35
- input.onChange(convertedValue);
37
+ if (value) {
38
+ const convertedValue = convertIfIsString(value);
39
+ if (JSON.stringify(convertedValue) !== JSON.stringify(value)) {
40
+ onChange(convertedValue);
36
41
  }
37
42
  }
38
- }, [input]);
43
+ }, [value, onChange]);
39
44
 
40
45
  const enabledOptions = useMemo(() => options.filter(option => !option.disabled), [options]);
41
46
 
42
47
  const areAllSelected = useMemo(
43
- () => enabledOptions.every(option => input.value?.includes(option.value)),
44
- [enabledOptions, input.value]
48
+ () => enabledOptions.every(option => value?.includes(option.value)),
49
+ [enabledOptions, value]
45
50
  );
46
51
 
47
52
  const isIndeterminate = useMemo(
48
- () => enabledOptions.some(option => input.value?.includes(option.value)) && !areAllSelected,
49
- [enabledOptions, input.value, areAllSelected]
53
+ () => enabledOptions.some(option => value?.includes(option.value)) && !areAllSelected,
54
+ [enabledOptions, value, areAllSelected]
50
55
  );
51
56
 
52
57
  const handleChange = useCallback(
53
58
  receivedValue => () => {
54
- const { onChange, value } = input;
55
- const newValues = !value?.includes(receivedValue)
56
- ? [...(value || []), receivedValue]
57
- : value.filter(elem => elem !== receivedValue);
58
- onChange(isEmpty(newValues) ? [] : newValues);
59
+ if (isSimple) {
60
+ onChange([receivedValue]);
61
+ } else {
62
+ const newValues = !value?.includes(receivedValue)
63
+ ? [...(value || []), receivedValue]
64
+ : value.filter(elem => elem !== receivedValue);
65
+ onChange(newValues);
66
+ }
59
67
  },
60
- [input]
68
+ [value, onChange, isSimple]
61
69
  );
62
70
 
63
71
  const handleCheckAll = useCallback(() => {
64
- if (!areAllSelected && options) {
65
- input.onChange(enabledOptions.map(item => item.value));
66
- } else {
67
- input.onChange([]);
68
- }
69
- }, [areAllSelected, enabledOptions, input, options]);
72
+ onChange(areAllSelected ? [] : enabledOptions.map(item => item.value));
73
+ }, [areAllSelected, enabledOptions, onChange]);
70
74
 
71
75
  return (
72
- <View style={[styles.container, verticalSpacing === SMALL && styles.smallVerticalSpacing, style.root]}>
76
+ <View
77
+ style={[styles.container, verticalSpacing === SPACING.SMALL && styles.smallVerticalSpacing, style.root]}
78
+ >
73
79
  <View style={[styles.headerContainer, style.header]}>
74
80
  {label && <UTFieldLabel required={required}>{label}</UTFieldLabel>}
75
81
  {validationData && <UTValidation validationData={validationData} />}
@@ -77,31 +83,35 @@ const UTCheckList = ({
77
83
  <View
78
84
  style={[
79
85
  styles.checkboxesContainer,
80
- verticalSpacing === SMALL && styles.smallVerticalSpacing,
86
+ verticalSpacingBasedOnVariant === SPACING.SMALL && styles.smallVerticalSpacing,
87
+ variant === BUTTON_VARIANT && styles.buttonVariant,
81
88
  style.checkboxesContainer
82
89
  ]}
83
90
  >
84
- {showSelectAll && (
91
+ {showSelectAll && !isSimple && (
85
92
  <UTCheckBox
86
93
  checked={areAllSelected}
87
94
  indeterminate={isIndeterminate}
88
95
  label={selectAllLabel}
89
96
  onPress={handleCheckAll}
90
- reversed={reversed}
97
+ reversed={reversedBasedOnVariant}
91
98
  spacing={horizontalSpacing}
92
99
  style={style.selectAll}
100
+ variant={variant}
93
101
  />
94
102
  )}
95
103
  {options?.map((item, index) => (
96
104
  <UTCheckBox
97
- checked={isChecked(item, input.value)}
105
+ isSimple={isSimple}
106
+ checked={isChecked(item, value)}
98
107
  disabled={item.disabled}
99
108
  key={keyExtractor(item, index)}
100
109
  label={item.label}
101
110
  onPress={handleChange(item.value)}
102
- reversed={reversed}
111
+ reversed={reversedBasedOnVariant}
103
112
  spacing={horizontalSpacing}
104
113
  style={style.item}
114
+ variant={variant}
105
115
  />
106
116
  ))}
107
117
  </View>
@@ -109,39 +119,7 @@ const UTCheckList = ({
109
119
  );
110
120
  };
111
121
 
112
- UTCheckList.defaultProps = {
113
- showSelectAll: true,
114
- style: {}
115
- };
116
-
117
- UTCheckList.propTypes = {
118
- error: string,
119
- horizontalSpacing: string,
120
- input: shape({
121
- value: arrayOf(string),
122
- onChange: func
123
- }),
124
- label: string,
125
- options: arrayOf(
126
- shape({
127
- checked: bool,
128
- disabled: bool,
129
- label: string,
130
- value: string
131
- })
132
- ),
133
- required: bool,
134
- reversed: bool,
135
- selectAllLabel: string,
136
- showSelectAll: bool,
137
- style: shape({
138
- checkboxesContainer: ViewPropTypes.style,
139
- header: ViewPropTypes.style,
140
- item: ViewPropTypes.style,
141
- root: ViewPropTypes.style,
142
- selectAll: ViewPropTypes.style
143
- }),
144
- verticalSpacing: string
145
- };
122
+ UTCheckList.defaultProps = defaultProps;
123
+ UTCheckList.propTypes = propTypes;
146
124
 
147
125
  export default UTCheckList;
@@ -0,0 +1,48 @@
1
+ import { arrayOf, bool, func, shape, string } from 'prop-types';
2
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
+
4
+ import { SPACING } from './constants';
5
+
6
+ export const defaultProps = {
7
+ horizontalSpacing: SPACING.LARGE,
8
+ input: {
9
+ value: [],
10
+ onChange: () => {}
11
+ },
12
+ isSimple: false,
13
+ showSelectAll: true,
14
+ style: {},
15
+ verticalSpacing: SPACING.LARGE
16
+ };
17
+
18
+ export const propTypes = {
19
+ error: string,
20
+ horizontalSpacing: string,
21
+ input: shape({
22
+ value: arrayOf(string),
23
+ onChange: func
24
+ }),
25
+ isSimple: bool,
26
+ label: string,
27
+ options: arrayOf(
28
+ shape({
29
+ checked: bool,
30
+ disabled: bool,
31
+ label: string,
32
+ value: string
33
+ })
34
+ ),
35
+ required: bool,
36
+ reversed: bool,
37
+ selectAllLabel: string,
38
+ showSelectAll: bool,
39
+ style: shape({
40
+ checkboxesContainer: ViewPropTypes.style,
41
+ header: ViewPropTypes.style,
42
+ item: ViewPropTypes.style,
43
+ root: ViewPropTypes.style,
44
+ selectAll: ViewPropTypes.style
45
+ }),
46
+ variant: string,
47
+ verticalSpacing: string
48
+ };
@@ -1,20 +1,25 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- const NORMAL_SPACING = 16;
4
- const SMALL_SPACING = 8;
3
+ const SPACING = {
4
+ LARGE: 16,
5
+ SMALL: 8
6
+ };
5
7
 
6
8
  export default StyleSheet.create({
9
+ buttonVariant: {
10
+ width: '100%'
11
+ },
7
12
  checkboxesContainer: {
8
13
  alignSelf: 'flex-start',
9
- rowGap: NORMAL_SPACING
14
+ rowGap: SPACING.LARGE
10
15
  },
11
16
  container: {
12
- rowGap: NORMAL_SPACING
17
+ rowGap: SPACING.LARGE
13
18
  },
14
19
  headerContainer: {
15
20
  rowGap: 8
16
21
  },
17
22
  smallVerticalSpacing: {
18
- rowGap: SMALL_SPACING
23
+ rowGap: SPACING.SMALL
19
24
  }
20
25
  });
@@ -1,5 +1,7 @@
1
1
  import { isString } from 'lodash';
2
2
 
3
+ import { BUTTON_VARIANT } from './constants';
4
+
3
5
  export const keyExtractor = (_, index) => `CB-${index}`;
4
6
 
5
7
  export const isChecked = (item, inputValue) =>
@@ -7,3 +9,6 @@ export const isChecked = (item, inputValue) =>
7
9
 
8
10
  export const convertIfIsString = value =>
9
11
  isString(value) ? (value.length === 0 ? [] : JSON.parse(value.replace(/'/g, '"'))) : value;
12
+
13
+ export const getPropValueBasedOnVariant = (variant, prop, defaultValue) =>
14
+ variant === BUTTON_VARIANT ? (prop ?? defaultValue) : prop;
@@ -7,14 +7,14 @@ import UTLabel from '../UTLabel';
7
7
  import { REQUIRED_LABEL } from './constants';
8
8
  import styles from './styles';
9
9
 
10
- const UTFieldLabel = ({ children, colorTheme, required, variant }) => {
10
+ const UTFieldLabel = ({ children, colorTheme, required, variant, weight }) => {
11
11
  return (
12
12
  <View style={styles.label}>
13
13
  <UTLabel colorTheme={colorTheme} variant={variant}>
14
14
  {children}
15
15
  </UTLabel>
16
16
  {required && (
17
- <UTLabel colorTheme="error" shade="04" variant={variant}>
17
+ <UTLabel colorTheme="error" shade="04" variant={variant} weight={weight}>
18
18
  {REQUIRED_LABEL}
19
19
  </UTLabel>
20
20
  )}
@@ -25,7 +25,8 @@ const UTFieldLabel = ({ children, colorTheme, required, variant }) => {
25
25
  UTFieldLabel.propTypes = {
26
26
  colorTheme: string,
27
27
  required: bool,
28
- variant: string
28
+ variant: string,
29
+ weight: string
29
30
  };
30
31
 
31
32
  export default UTFieldLabel;