@widergy/mobile-ui 1.18.1 → 1.18.2

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 (41) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/lib/components/CheckList/components/CheckBoxRenderer/index.js +8 -10
  3. package/lib/components/Label/propTypes.js +2 -5
  4. package/lib/components/UTBadge/index.js +2 -3
  5. package/lib/components/UTBaseInputField/README.md +31 -22
  6. package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +6 -3
  7. package/lib/components/UTBaseInputField/constants.js +3 -1
  8. package/lib/components/UTBaseInputField/index.js +17 -6
  9. package/lib/components/UTBaseInputField/proptypes.js +10 -20
  10. package/lib/components/UTBaseInputField/theme.js +1 -2
  11. package/lib/components/UTButton/proptypes.js +4 -5
  12. package/lib/components/UTCBUInput/index.js +11 -12
  13. package/lib/components/UTCheckBox/README.md +14 -14
  14. package/lib/components/UTCheckBox/index.js +11 -6
  15. package/lib/components/UTCheckBox/proptypes.js +3 -4
  16. package/lib/components/UTCheckBox/theme.js +11 -4
  17. package/lib/components/UTCheckList/README.MD +22 -32
  18. package/lib/components/UTCheckList/index.js +6 -7
  19. package/lib/components/UTCheckList/proptypes.js +12 -24
  20. package/lib/components/UTFieldLabel/index.js +11 -13
  21. package/lib/components/UTIcon/index.js +2 -3
  22. package/lib/components/UTPasswordField/versions/V1/constants.js +4 -0
  23. package/lib/components/UTPasswordField/versions/V1/index.js +12 -13
  24. package/lib/components/UTPhoneInput/index.js +26 -27
  25. package/lib/components/UTProductItem/index.js +3 -3
  26. package/lib/components/UTSearchField/README.md +14 -13
  27. package/lib/components/UTSearchField/index.js +6 -4
  28. package/lib/components/UTSearchField/proptypes.js +5 -9
  29. package/lib/components/UTSelect/versions/V1/README.md +29 -35
  30. package/lib/components/UTSelect/versions/V1/index.js +73 -44
  31. package/lib/components/UTSelect/versions/V1/proptypes.js +17 -16
  32. package/lib/components/UTSelect/versions/V1/styles.js +3 -0
  33. package/lib/components/UTSelect/versions/V1/utils.js +21 -0
  34. package/lib/components/UTSelectableCard/index.js +5 -2
  35. package/lib/components/UTTextInput/versions/V1/README.md +35 -34
  36. package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +13 -14
  37. package/lib/components/UTTextInput/versions/V1/index.js +12 -10
  38. package/lib/components/UTTextInput/versions/V1/proptypes.js +20 -19
  39. package/lib/components/UTValidation/index.js +2 -2
  40. package/lib/constants/inputs.js +1 -1
  41. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.18.2](https://github.com/widergy/mobile-ui/compare/v1.18.1...v1.18.2) (2024-08-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * select V1 fixes ([#327](https://github.com/widergy/mobile-ui/issues/327)) ([94b61d6](https://github.com/widergy/mobile-ui/commit/94b61d6145e2a9477c50ad2a8a522734c5aa0307))
7
+
1
8
  ## [1.18.1](https://github.com/widergy/mobile-ui/compare/v1.18.0...v1.18.1) (2024-08-12)
2
9
 
3
10
 
@@ -1,7 +1,5 @@
1
- /* eslint-disable react/forbid-prop-types */
2
1
  import React, { memo } from 'react';
3
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
4
- import { bool, string, func, number, shape, any } from 'prop-types';
2
+ import { bool, string, func, number, object } from 'prop-types';
5
3
 
6
4
  import Checkbox from '../../../Checkbox/index';
7
5
 
@@ -48,18 +46,18 @@ const CheckBoxRenderer = ({
48
46
  };
49
47
 
50
48
  CheckBoxRenderer.propTypes = {
51
- labelsContainerStyle: ViewPropTypes.style,
52
- checkboxContainerStyle: ViewPropTypes.style,
49
+ labelsContainerStyle: object,
50
+ checkboxContainerStyle: object,
53
51
  index: number,
54
52
  checkedColor: string,
55
53
  reversed: bool,
56
- item: shape(any),
57
- alternateColors: ViewPropTypes.style,
54
+ item: object,
55
+ alternateColors: object,
58
56
  disabledStyleEnabled: bool,
59
- disabledStyle: ViewPropTypes.style,
60
- coloredStyle: ViewPropTypes.style,
57
+ disabledStyle: object,
58
+ coloredStyle: object,
61
59
  disabledCheckedColor: string,
62
- textProps: shape(any),
60
+ textProps: object,
63
61
  isChecked: bool,
64
62
  handleChange: func
65
63
  };
@@ -1,13 +1,10 @@
1
- /* eslint-disable react/forbid-foreign-prop-types */
2
-
3
- import { Text } from 'react-native';
4
- import { bool, oneOfType, string } from 'prop-types';
1
+ import { bool, object, oneOfType, string } from 'prop-types';
5
2
 
6
3
  import { themeType } from '../../theming';
7
4
 
8
5
  export default {
9
6
  color: oneOfType([bool, string]),
10
- textProps: Text.propTypes,
7
+ textProps: object,
11
8
  theme: themeType,
12
9
  allowFontScaling: bool,
13
10
  useMarkdown: bool
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { number, oneOfType, string } from 'prop-types';
2
+ import { number, object, oneOfType, string } from 'prop-types';
3
3
  import { View } from 'react-native';
4
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
5
4
 
6
5
  import { useTheme } from '../../theming';
7
6
  import UTLabel from '../UTLabel';
@@ -31,7 +30,7 @@ UTBadge.defaultProps = DEFAULT_PROPS;
31
30
  UTBadge.propTypes = {
32
31
  children: oneOfType([string, number]),
33
32
  colorTheme: string,
34
- style: ViewPropTypes.style
33
+ style: object
35
34
  };
36
35
 
37
36
  export default UTBadge;
@@ -1,25 +1,34 @@
1
- | Name | Type | Default | Description |
2
- | --------------------- | -------------------------------------------------------------- | --------------------------------- | --------------------------------------------------------- |
3
- | alwaysShowPlaceholder | bool | false | Whether to always show the placeholder text. |
4
- | disabled | bool | | Whether the input field is disabled. |
5
- | error | string | | Error message to display. |
6
- | id | oneOfType([number, string]) | | Unique identifier for the input field. |
7
- | input | shape({ value: string.isRequired, onChange: func.isRequired }) | { value: '', onChange: () => {} } | Input object containing the value and onChange handler. |
8
- | inputSize | string | 'large' | Size of the input field. One of: `small`, `large`. |
9
- | leftAdornments | arrayOf(shape({ name: string, props: object })) | | Elements to display on the left side of the input field. |
10
- | maxCount | number | | Maximum number of characters allowed. |
11
- | maxRows | number | | Maximum number of rows for multiline input. |
12
- | onBlur | func | | Callback function to handle blur event. |
13
- | onFocus | func | | Callback function to handle focus event. |
14
- | onSubmitEditing | func | | Callback function to handle submit editing event. |
15
- | placeholder | string | | Placeholder text for the input field. |
16
- | readOnly | bool | | Whether the input field is read-only. |
17
- | returnKeyType | string | | Type of return key to display on the keyboard. |
18
- | rightAdornments | arrayOf(shape({ name: string, props: object })) | | Elements to display on the right side of the input field. |
19
- | style | shape({ container: object, input: object, root: object }) | {} | Custom styles to apply to the component. |
20
- | type | string | | Type of the input field (e.g., email, numeric, password). |
21
- | variant | string | 'white' | Variant of the input field. One of: `white`, `gray`. |
22
- | editable | bool | true | Whether the input field is editable. |
1
+ # UTBaseInputField
2
+
3
+ ## Description
4
+
5
+ `UTBaseInputField` is a flexible and customizable input field component that supports various input types, adornments, and styles. It can be used to create text inputs with additional functionality such as icons, prefixes, suffixes, and action buttons.
6
+
7
+ ## Props
8
+
9
+ | Name | Type | Default | Description |
10
+ | --------------------- | --------------------------------------------------------- | -------- | --------------------------------------------------------- |
11
+ | alwaysShowPlaceholder | bool | false | Whether to always show the placeholder text. |
12
+ | disabled | bool | | Whether the input field is disabled. |
13
+ | error | string | | Error message to display. |
14
+ | id | oneOfType([number, string]) | | Unique identifier for the input field. |
15
+ | value | string | '' | The value of the input field. |
16
+ | onChange | func.isRequired | () => {} | Callback function to handle change event. |
17
+ | inputSize | string | 'large' | Size of the input field. One of: `small`, `large`. |
18
+ | leftAdornments | arrayOf(shape({ name: string, props: object })) | | Elements to display on the left side of the input field. |
19
+ | maxCount | number | | Maximum number of characters allowed. |
20
+ | maxRows | number | | Maximum number of rows for multiline input. |
21
+ | onBlur | func | | Callback function to handle blur event. |
22
+ | onFocus | func | | Callback function to handle focus event. |
23
+ | onSubmitEditing | func | | Callback function to handle submit editing event. |
24
+ | placeholder | string | | Placeholder text for the input field. |
25
+ | readOnly | bool | | Whether the input field is read-only. |
26
+ | returnKeyType | string | | Type of return key to display on the keyboard. |
27
+ | rightAdornments | arrayOf(shape({ name: string, props: object })) | | Elements to display on the right side of the input field. |
28
+ | style | shape({ container: object, input: object, root: object }) | {} | Custom styles to apply to the component. |
29
+ | type | string | | Type of the input field (e.g., email, numeric, password). |
30
+ | variant | string | 'white' | Variant of the input field. One of: `white`, `gray`. |
31
+ | editable | bool | true | Whether the input field is editable. |
23
32
 
24
33
  ## Input Types
25
34
 
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { bool, shape } from 'prop-types';
3
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
2
+ import { bool, object, shape } from 'prop-types';
4
3
 
5
4
  import UTButton from '../../../UTButton';
6
5
  import { propTypes as utbuttonProptypes } from '../../../UTButton/proptypes';
@@ -17,7 +16,11 @@ const ActionAdornment = ({ action, disabled, actionStyle }) => {
17
16
 
18
17
  ActionAdornment.propTypes = {
19
18
  action: shape(utbuttonProptypes),
20
- actionStyle: shape({ object: ViewPropTypes.style }),
19
+ actionStyle: shape({
20
+ childrenContainer: object,
21
+ icon: object,
22
+ root: object
23
+ }),
21
24
  disabled: bool
22
25
  };
23
26
 
@@ -10,6 +10,7 @@ export const TYPES = {
10
10
  NUMBER: 'number',
11
11
  NUMERIC: 'numeric',
12
12
  PASSWORD: 'password',
13
+ PASSWORD_NUMERIC: 'password_numeric',
13
14
  PHONE: 'phone'
14
15
  };
15
16
 
@@ -17,7 +18,8 @@ export const KEYBOARD_BY_TYPE = {
17
18
  [TYPES.EMAIL]: 'email-address',
18
19
  [TYPES.NUMBER]: 'number-pad',
19
20
  [TYPES.NUMERIC]: 'numeric',
20
- [TYPES.PHONE]: 'phone-pad'
21
+ [TYPES.PHONE]: 'phone-pad',
22
+ [TYPES.PASSWORD_NUMERIC]: 'numeric'
21
23
  };
22
24
 
23
25
  export const COMPONENT_KEYS = {
@@ -25,12 +25,12 @@ const UTBaseInputField = forwardRef(
25
25
  editable,
26
26
  error,
27
27
  id,
28
- input,
29
28
  inputSize,
30
29
  leftAdornments,
31
30
  maxLength,
32
31
  maxRows,
33
32
  onBlur,
33
+ onChange,
34
34
  onFocus,
35
35
  onSubmitEditing,
36
36
  placeholder,
@@ -40,11 +40,11 @@ const UTBaseInputField = forwardRef(
40
40
  showCharacterCount,
41
41
  style,
42
42
  type,
43
+ value,
43
44
  variant
44
45
  },
45
46
  ref
46
47
  ) => {
47
- const { value, onChange } = input;
48
48
  const [displayValue, setDisplayValue] = useState(value);
49
49
  const [focused, setFocused] = useState(false);
50
50
  const inputWidthRef = useRef(null);
@@ -93,7 +93,7 @@ const UTBaseInputField = forwardRef(
93
93
  };
94
94
 
95
95
  const { actionStyle, containerStyle, inputRowStyle, inputStyle, textLengthRowStyle } = retrieveStyle({
96
- disabled,
96
+ disabled: disabled && !readOnly,
97
97
  error,
98
98
  focused,
99
99
  inputSize,
@@ -112,10 +112,21 @@ const UTBaseInputField = forwardRef(
112
112
  useImperativeHandle(ref, () => ({
113
113
  truncate: () => {
114
114
  setDisplayValue(truncateText(value));
115
- }
115
+ },
116
+ focus: () => {
117
+ if (inputRef.current) {
118
+ handleFocus();
119
+ }
120
+ },
121
+ blur: () => {
122
+ if (inputRef.current) {
123
+ handleBlur();
124
+ }
125
+ },
126
+ ...inputRef.current
116
127
  }));
117
128
 
118
- const secureTextEntry = type === TYPES.PASSWORD;
129
+ const secureTextEntry = [TYPES.PASSWORD, TYPES.PASSWORD_NUMERIC].includes(type);
119
130
  const autoCapitalize = type === TYPES.EMAIL ? 'none' : 'sentences';
120
131
  const keyboardType = KEYBOARD_BY_TYPE[type] || 'default';
121
132
 
@@ -129,7 +140,7 @@ const UTBaseInputField = forwardRef(
129
140
  error={error}
130
141
  focused={focused}
131
142
  inputStyle={inputStyle}
132
- key={element.name}
143
+ key={element.key || element.name}
133
144
  {...element.props}
134
145
  />
135
146
  ) : null;
@@ -1,19 +1,16 @@
1
- import { bool, func, number, string, arrayOf, shape, oneOfType } from 'prop-types';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
1
+ import { arrayOf, bool, func, number, object, oneOfType, shape, string } from 'prop-types';
3
2
 
4
3
  import { VARIANT, SIZES } from './constants';
5
4
 
6
5
  export const defaultProps = {
7
6
  alwaysShowPlaceholder: false,
8
7
  editable: true,
9
- maxRows: 1,
10
- input: {
11
- value: [],
12
- onChange: () => {}
13
- },
14
8
  inputSize: SIZES.LARGE,
15
9
  leftAdornments: [],
10
+ maxRows: 1,
11
+ onChange: () => {},
16
12
  rightAdornments: [],
13
+ value: null,
17
14
  variant: VARIANT.WHITE
18
15
  };
19
16
 
@@ -24,17 +21,10 @@ export const propTypes = {
24
21
  editable: bool,
25
22
  error: oneOfType([bool, string]),
26
23
  id: oneOfType([number, string]),
27
- input: shape({
28
- value: oneOfType([string, number]),
29
- onChange: func
30
- }),
24
+ value: oneOfType([string, number]),
25
+ onChange: func,
31
26
  inputSize: string,
32
- leftAdornments: arrayOf(
33
- shape({
34
- name: string.isRequired,
35
- props: shape({})
36
- })
37
- ),
27
+ leftAdornments: arrayOf(shape({ name: string.isRequired, props: shape({}) })),
38
28
  maxLength: number,
39
29
  maxRows: number,
40
30
  onBlur: func,
@@ -51,9 +41,9 @@ export const propTypes = {
51
41
  ),
52
42
  showCharacterCount: bool,
53
43
  style: shape({
54
- container: ViewPropTypes.style,
55
- input: ViewPropTypes.style,
56
- root: ViewPropTypes.style
44
+ container: object,
45
+ input: object,
46
+ root: object
57
47
  }),
58
48
  type: string,
59
49
  variant: string
@@ -81,8 +81,7 @@ const baseTextInputTheme = theme => ({
81
81
  columnGap: CONTAINER.ROW_GAP,
82
82
  flex: 1,
83
83
  flexDirection: 'row',
84
- justifyContent: 'space-between',
85
- width: '100%'
84
+ justifyContent: 'space-between'
86
85
  },
87
86
  textLengthRow: {
88
87
  flexDirection: 'row',
@@ -1,5 +1,4 @@
1
- import { bool, func, elementType, string, shape, number } from 'prop-types';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
1
+ import { bool, elementType, func, number, object, shape, string } from 'prop-types';
3
2
 
4
3
  import { ICON_PLACEMENTS, SIZES } from './constants';
5
4
 
@@ -22,9 +21,9 @@ export const propTypes = {
22
21
  onPress: func,
23
22
  size: string,
24
23
  style: shape({
25
- childrenContainer: ViewPropTypes.style,
26
- icon: ViewPropTypes.style,
27
- root: ViewPropTypes.style
24
+ childrenContainer: object,
25
+ icon: object,
26
+ root: object
28
27
  }),
29
28
  variant: string
30
29
  };
@@ -1,12 +1,11 @@
1
- /* eslint-disable camelcase */
2
1
  import React from 'react';
3
- import { shape, func, any, elementType, oneOfType, number, string } from 'prop-types';
2
+ import { shape, func, object, elementType, oneOfType, number, string } from 'prop-types';
4
3
 
5
4
  import UTTextInput from '../UTTextInput';
6
5
 
7
- const UTCBUInput = ({ input, configuration, ...props }) => {
6
+ const UTCBUInput = ({ input, field, ...props }) => {
8
7
  const { onChange, value, onBlur } = input;
9
- const { entities, cbu_number_key, cbu_entity_key } = configuration;
8
+ const { entities, cbu_number_key: cbuNumberKey, cbu_entity_key: cbuEntityKey } = field?.configuration || {};
10
9
 
11
10
  const findEntity = inputNumber => {
12
11
  const entityObject = entities?.find(entity => new RegExp(entity.expression).test(inputNumber));
@@ -15,7 +14,7 @@ const UTCBUInput = ({ input, configuration, ...props }) => {
15
14
 
16
15
  const handleOnChange = inputValue => {
17
16
  const newValue = inputValue
18
- ? { [cbu_number_key]: inputValue, [cbu_entity_key]: findEntity(inputValue) }
17
+ ? { [cbuNumberKey]: inputValue, [cbuEntityKey]: findEntity(inputValue) }
19
18
  : null;
20
19
  onChange(newValue);
21
20
  };
@@ -28,20 +27,20 @@ const UTCBUInput = ({ input, configuration, ...props }) => {
28
27
  return (
29
28
  <UTTextInput
30
29
  {...props}
31
- value={value?.[cbu_number_key]}
32
- captionLabel={value?.[cbu_entity_key]}
33
- onChange={handleOnChange}
34
- onBlur={handleOnBlur}
30
+ helpText={value?.[cbuEntityKey]}
35
31
  maxLength={22}
32
+ onBlur={handleOnBlur}
33
+ onChange={handleOnChange}
34
+ value={value?.[cbuNumberKey]}
35
+ version="V1"
36
36
  />
37
37
  );
38
38
  };
39
39
 
40
40
  UTCBUInput.propTypes = {
41
+ field: shape({ configuration: object }),
41
42
  input: shape({ onChange: func.isRequired, value: oneOfType([number, string]) }),
42
- InputComponent: elementType,
43
- // eslint-disable-next-line react/forbid-prop-types
44
- configuration: any
43
+ InputComponent: elementType
45
44
  };
46
45
 
47
46
  export default UTCBUInput;
@@ -6,19 +6,19 @@
6
6
 
7
7
  ## Props
8
8
 
9
- | Name | Type | Default | Description |
10
- | ------------- | ------ | ------- | ------------------------------------------------------- |
11
- | checked | bool | false | Indicates if the checkbox is checked. |
12
- | disabled | bool | false | Disables the checkbox, making it unclickable. |
13
- | indeterminate | bool | false | Indicates if the checkbox is in an indeterminate state. |
14
- | isSimple | bool | false | **Deprecated**: Use standard checkboxes instead. |
15
- | label | string | | Label to display next to the checkbox. |
16
- | onPress | func | | Function to call when the checkbox is pressed. |
17
- | required | bool | false | Indicates if the checkbox is required. |
18
- | reversed | bool | false | If true, reverses the order of label and checkbox. |
19
- | spacing | string | large | If "small", reduces the column gap from 16 to 8. |
20
- | style | shape | {} | Custom styles to apply to the checkbox container. |
21
- | variant | string | | The variant to use for styling the checkbox. |
9
+ | Name | Type | Default | Description |
10
+ | ------------- | ------ | ------- | --------------------------------------------------------------------------- |
11
+ | checked | bool | false | Indicates if the checkbox is checked. |
12
+ | disabled | bool | false | Disables the checkbox, making it unclickable. |
13
+ | indeterminate | bool | false | Indicates if the checkbox is in an indeterminate state. |
14
+ | isSimple | bool | false | **Deprecated**: Use standard checkboxes instead. |
15
+ | onPress | func | | Function to call when the checkbox is pressed. |
16
+ | required | bool | false | Indicates if the checkbox is required. |
17
+ | reversed | bool | false | If true, reverses the order of title and checkbox. |
18
+ | spacing | string | large | If "small", reduces the column gap from 16 to 8. |
19
+ | style | shape | {} | Custom styles to apply to the checkbox container. Can contain root or title |
20
+ | title | string | | Title to display next to the checkbox. |
21
+ | variant | string | | The variant to use for styling the checkbox. |
22
22
 
23
23
  ## Usage
24
24
 
@@ -31,7 +31,7 @@ import UTCheckBox from './UTCheckBox';
31
31
  const Example = () => {
32
32
  const [checked, setChecked] = React.useState(false);
33
33
 
34
- return <UTCheckBox checked={checked} label="Check me" onPress={() => setChecked(!checked)} />;
34
+ return <UTCheckBox checked={checked} title="Check me" onPress={() => setChecked(!checked)} />;
35
35
  };
36
36
 
37
37
  export default Example;
@@ -13,20 +13,20 @@ import styles from './styles';
13
13
  const UTCheckBox = ({
14
14
  checked,
15
15
  disabled,
16
- isSimple,
17
16
  indeterminate,
18
- label,
17
+ isSimple,
19
18
  onPress,
20
19
  required,
21
20
  reversed,
22
21
  spacing,
23
22
  style,
23
+ title,
24
24
  variant
25
25
  }) => {
26
26
  const theme = useTheme();
27
27
  const [pressed, setPressed] = useState(false);
28
28
 
29
- const { containerStyles, iconContainerStyles, boxStyles, pressableStyles } = useMemo(
29
+ const { containerStyles, iconContainerStyles, boxStyles, pressableStyles, titleStyles } = useMemo(
30
30
  () =>
31
31
  retrieveStyle({
32
32
  checked,
@@ -60,7 +60,12 @@ const UTCheckBox = ({
60
60
  >
61
61
  <View style={containerStyles}>
62
62
  {isSimple ? (
63
- <UTIcon name="IconCheck" shade="04" colorTheme="accent" style={!checked && styles.hidden} />
63
+ <UTIcon
64
+ name="IconCheck"
65
+ shade="04"
66
+ colorTheme="accent"
67
+ style={checked ? undefined : styles.hidden}
68
+ />
64
69
  ) : (
65
70
  <View style={boxStyles}>
66
71
  <View style={iconContainerStyles}>
@@ -68,8 +73,8 @@ const UTCheckBox = ({
68
73
  </View>
69
74
  </View>
70
75
  )}
71
- <UTFieldLabel required={required} colorTheme={checked && 'accent'} shade={checked && '05'}>
72
- {label}
76
+ <UTFieldLabel colorTheme={checked ? 'accent' : 'dark'} required={required} style={titleStyles}>
77
+ {title}
73
78
  </UTFieldLabel>
74
79
  </View>
75
80
  </Pressable>
@@ -1,5 +1,4 @@
1
- import { bool, func, string } from 'prop-types';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
1
+ import { bool, func, object, string } from 'prop-types';
3
2
 
4
3
  import { SPACING } from './constants';
5
4
 
@@ -17,11 +16,11 @@ export const propTypes = {
17
16
  disabled: bool,
18
17
  indeterminate: bool,
19
18
  isSimple: bool,
20
- label: string,
21
19
  onPress: func,
22
20
  required: bool,
23
21
  reversed: bool,
24
22
  spacing: string,
25
- style: ViewPropTypes.style,
23
+ style: object,
24
+ title: string,
26
25
  variant: string
27
26
  };
@@ -21,6 +21,9 @@ const baseCheckBoxTheme = theme => ({
21
21
  borderRadius: 25,
22
22
  overflow: 'hidden',
23
23
  padding: 6
24
+ },
25
+ title: {
26
+ maxWidth: '80%'
24
27
  }
25
28
  });
26
29
 
@@ -109,18 +112,22 @@ export const retrieveStyle = ({
109
112
  });
110
113
 
111
114
  return {
115
+ boxStyles: {
116
+ ...baseThemeStyles.box,
117
+ ...box
118
+ },
112
119
  containerStyles: {
113
120
  ...baseThemeStyles.container,
114
121
  ...container,
115
- ...style
122
+ ...style.root
116
123
  },
117
124
  iconContainerStyles: {
118
125
  ...baseThemeStyles.iconContainer,
119
126
  ...iconContainer
120
127
  },
121
- boxStyles: {
122
- ...baseThemeStyles.box,
123
- ...box
128
+ titleStyles: {
129
+ ...baseThemeStyles.title,
130
+ ...style.title
124
131
  },
125
132
  pressableStyles: pressable
126
133
  };
@@ -6,29 +6,21 @@
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
- | 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. |
23
-
24
- ### Input Object
25
-
26
- The `input` prop is an object that should contain the following keys:
27
-
28
- | Name | Type | Description |
29
- | -------- | --------------- | -------------------------------------------- |
30
- | value | arrayOf(string) | Array of selected values. |
31
- | onChange | func | Function to call when the selection changes. |
9
+ | Name | Type | Default | Description |
10
+ | ----------------- | --------------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
11
+ | error | string | | Error message to display. |
12
+ | horizontalSpacing | string | large | Spacing between the checkbox and the title horizontally. |
13
+ | title | string | | Title for the checklist. |
14
+ | onChange | func.isRequired | | Function to call when the selection changes. |
15
+ | options | array | | Array of options to be displayed as checkboxes. Each option is an object with `label` and `value`. |
16
+ | required | bool | false | Indicates if the checklist is required. |
17
+ | reversed | bool | false | If true, reverses the order of title and checkbox. |
18
+ | selectAllLabel | string | | Label for the "Select All" checkbox. |
19
+ | showSelectAll | bool | true | Determines whether to show the "Select All" checkbox. |
20
+ | style | shape | {} | Custom styles to apply to the checklist. Can contain `root`, `header`, `checkboxesContainer`, `item`, and `selectAll`. |
21
+ | value | arrayOf(string) | [] | Array of selected values. |
22
+ | variant | string | | Variant style for the checklist. |
23
+ | verticalSpacing | string | large | Spacing between the checkbox items vertically. |
32
24
 
33
25
  ### Option Object
34
26
 
@@ -60,15 +52,13 @@ const Example = () => {
60
52
 
61
53
  return (
62
54
  <UTCheckList
63
- label="Select Options"
55
+ error="Please select at least one option"
56
+ title="Select Options"
57
+ onChange={setSelectedOptions}
64
58
  options={options}
65
- input={{
66
- value: selectedOptions,
67
- onChange: setSelectedOptions
68
- }}
69
- selectAllLabel="Select All"
70
59
  required
71
- error="Please select at least one option"
60
+ selectAllLabel="Select All"
61
+ value={selectedOptions}
72
62
  />
73
63
  );
74
64
  };
@@ -85,7 +75,7 @@ import UTCheckBox from './UTCheckBox';
85
75
  const customStyles = {
86
76
  root: { padding: 10 },
87
77
  iconContainer: { backgroundColor: 'lightgrey' },
88
- label: { color: 'blue' }
78
+ title: { color: 'blue' }
89
79
  };
90
80
 
91
81
  const Example = () => {
@@ -94,7 +84,7 @@ const Example = () => {
94
84
  return (
95
85
  <UTCheckBox
96
86
  checked={checked}
97
- label="Check me"
87
+ title="Check me"
98
88
  onPress={() => setChecked(!checked)}
99
89
  style={customStyles}
100
90
  />