@widergy/mobile-ui 1.18.1 → 1.18.3

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 (43) hide show
  1. package/CHANGELOG.md +14 -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/UTAutocomplete/index.js +5 -11
  5. package/lib/components/UTBadge/index.js +2 -3
  6. package/lib/components/UTBaseInputField/README.md +31 -22
  7. package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +6 -3
  8. package/lib/components/UTBaseInputField/constants.js +3 -1
  9. package/lib/components/UTBaseInputField/index.js +17 -6
  10. package/lib/components/UTBaseInputField/proptypes.js +10 -20
  11. package/lib/components/UTBaseInputField/theme.js +1 -2
  12. package/lib/components/UTButton/proptypes.js +4 -5
  13. package/lib/components/UTCBUInput/index.js +11 -12
  14. package/lib/components/UTCheckBox/README.md +14 -14
  15. package/lib/components/UTCheckBox/index.js +11 -6
  16. package/lib/components/UTCheckBox/proptypes.js +3 -4
  17. package/lib/components/UTCheckBox/theme.js +11 -4
  18. package/lib/components/UTCheckList/README.MD +22 -32
  19. package/lib/components/UTCheckList/index.js +6 -7
  20. package/lib/components/UTCheckList/proptypes.js +12 -24
  21. package/lib/components/UTFieldLabel/index.js +11 -13
  22. package/lib/components/UTIcon/index.js +2 -3
  23. package/lib/components/UTPasswordField/versions/V1/constants.js +4 -0
  24. package/lib/components/UTPasswordField/versions/V1/index.js +12 -13
  25. package/lib/components/UTPhoneInput/index.js +26 -27
  26. package/lib/components/UTProductItem/index.js +3 -3
  27. package/lib/components/UTSearchField/README.md +14 -13
  28. package/lib/components/UTSearchField/index.js +6 -4
  29. package/lib/components/UTSearchField/proptypes.js +5 -9
  30. package/lib/components/UTSelect/versions/V1/README.md +29 -35
  31. package/lib/components/UTSelect/versions/V1/index.js +73 -44
  32. package/lib/components/UTSelect/versions/V1/proptypes.js +17 -16
  33. package/lib/components/UTSelect/versions/V1/styles.js +3 -0
  34. package/lib/components/UTSelect/versions/V1/utils.js +21 -0
  35. package/lib/components/UTSelectableCard/index.js +5 -2
  36. package/lib/components/UTTextInput/versions/V1/README.md +35 -34
  37. package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +13 -14
  38. package/lib/components/UTTextInput/versions/V1/index.js +12 -10
  39. package/lib/components/UTTextInput/versions/V1/proptypes.js +20 -19
  40. package/lib/components/UTValidation/index.js +3 -3
  41. package/lib/components/UTValidation/styles.js +3 -0
  42. package/lib/constants/inputs.js +1 -1
  43. package/package.json +1 -1
@@ -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
  />
@@ -14,20 +14,19 @@ import { BUTTON_VARIANT, SPACING } from './constants';
14
14
  const UTCheckList = ({
15
15
  error,
16
16
  horizontalSpacing,
17
- input,
18
17
  isSimple,
19
- label,
18
+ onChange,
20
19
  options,
21
20
  required,
22
21
  reversed,
23
22
  selectAllLabel,
24
23
  showSelectAll,
25
24
  style,
25
+ title,
26
+ value,
26
27
  variant,
27
28
  verticalSpacing
28
29
  }) => {
29
- const { value, onChange } = input;
30
-
31
30
  const reversedBasedOnVariant = getPropValueBasedOnVariant(variant, reversed, true);
32
31
  const verticalSpacingBasedOnVariant = getPropValueBasedOnVariant(variant, verticalSpacing, SPACING.SMALL);
33
32
 
@@ -77,7 +76,7 @@ const UTCheckList = ({
77
76
  style={[styles.container, verticalSpacing === SPACING.SMALL && styles.smallVerticalSpacing, style.root]}
78
77
  >
79
78
  <View style={[styles.headerContainer, style.header]}>
80
- {label && <UTFieldLabel required={required}>{label}</UTFieldLabel>}
79
+ {title && <UTFieldLabel required={required}>{title}</UTFieldLabel>}
81
80
  {validationData && <UTValidation validationData={validationData} />}
82
81
  </View>
83
82
  <View
@@ -92,7 +91,7 @@ const UTCheckList = ({
92
91
  <UTCheckBox
93
92
  checked={areAllSelected}
94
93
  indeterminate={isIndeterminate}
95
- label={selectAllLabel}
94
+ title={selectAllLabel}
96
95
  onPress={handleCheckAll}
97
96
  reversed={reversedBasedOnVariant}
98
97
  spacing={horizontalSpacing}
@@ -106,7 +105,7 @@ const UTCheckList = ({
106
105
  checked={isChecked(item, value)}
107
106
  disabled={item.disabled}
108
107
  key={keyExtractor(item, index)}
109
- label={item.label}
108
+ title={item.label}
110
109
  onPress={handleChange(item.value)}
111
110
  reversed={reversedBasedOnVariant}
112
111
  spacing={horizontalSpacing}
@@ -1,48 +1,36 @@
1
- import { arrayOf, bool, func, shape, string } from 'prop-types';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
1
+ import { arrayOf, bool, func, object, shape, string } from 'prop-types';
3
2
 
4
3
  import { SPACING } from './constants';
5
4
 
6
5
  export const defaultProps = {
7
6
  horizontalSpacing: SPACING.LARGE,
8
- input: {
9
- value: [],
10
- onChange: () => {}
11
- },
12
7
  isSimple: false,
8
+ onChange: () => {},
13
9
  showSelectAll: true,
14
10
  style: {},
11
+ value: null,
15
12
  verticalSpacing: SPACING.LARGE
16
13
  };
17
14
 
18
15
  export const propTypes = {
19
16
  error: string,
20
17
  horizontalSpacing: string,
21
- input: shape({
22
- value: arrayOf(string),
23
- onChange: func
24
- }),
25
18
  isSimple: bool,
26
- label: string,
27
- options: arrayOf(
28
- shape({
29
- checked: bool,
30
- disabled: bool,
31
- label: string,
32
- value: string
33
- })
34
- ),
19
+ title: string,
20
+ onChange: func,
21
+ options: arrayOf(shape({ checked: bool, disabled: bool, title: string, value: string })),
35
22
  required: bool,
36
23
  reversed: bool,
37
24
  selectAllLabel: string,
38
25
  showSelectAll: bool,
39
26
  style: shape({
40
- checkboxesContainer: ViewPropTypes.style,
41
- header: ViewPropTypes.style,
42
- item: ViewPropTypes.style,
43
- root: ViewPropTypes.style,
44
- selectAll: ViewPropTypes.style
27
+ checkboxesContainer: object,
28
+ header: object,
29
+ item: object,
30
+ root: object,
31
+ selectAll: object
45
32
  }),
33
+ value: arrayOf(string),
46
34
  variant: string,
47
35
  verticalSpacing: string
48
36
  };
@@ -7,20 +7,18 @@ 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, weight }) => {
11
- return (
12
- <View style={styles.label}>
13
- <UTLabel colorTheme={colorTheme} variant={variant}>
14
- {children}
10
+ const UTFieldLabel = ({ children, colorTheme, required, style, variant, weight }) => (
11
+ <View style={[styles.label, style]}>
12
+ <UTLabel colorTheme={colorTheme} variant={variant}>
13
+ {children}
14
+ </UTLabel>
15
+ {required && (
16
+ <UTLabel colorTheme="error" shade="04" variant={variant} weight={weight}>
17
+ {REQUIRED_LABEL}
15
18
  </UTLabel>
16
- {required && (
17
- <UTLabel colorTheme="error" shade="04" variant={variant} weight={weight}>
18
- {REQUIRED_LABEL}
19
- </UTLabel>
20
- )}
21
- </View>
22
- );
23
- };
19
+ )}
20
+ </View>
21
+ );
24
22
 
25
23
  UTFieldLabel.propTypes = {
26
24
  colorTheme: string,
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { number, string } from 'prop-types';
3
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
2
+ import { number, object, string } from 'prop-types';
4
3
  import * as TablerIcons from '@tabler/icons-react-native';
5
4
 
6
5
  import { useTheme } from '../../theming';
@@ -40,7 +39,7 @@ UTIcon.propTypes = {
40
39
  name: string,
41
40
  shade: string,
42
41
  size: number,
43
- style: ViewPropTypes.style
42
+ style: object
44
43
  };
45
44
 
46
45
  export default UTIcon;
@@ -1,7 +1,11 @@
1
1
  export const INPUT_TYPE = {
2
+ NUMERIC: 'numeric',
2
3
  PASSWORD: 'password',
4
+ PASSWORD_NUMERIC: 'password_numeric',
3
5
  TEXT: 'text'
4
6
  };
5
7
 
8
+ export const KEYBOARD_TYPE_NUMERIC = 'numeric';
9
+
6
10
  export const ICON_EYE = 'IconEye';
7
11
  export const ICON_EYE_OFF = 'IconEyeOff';
@@ -3,28 +3,27 @@ import React, { useState } from 'react';
3
3
  import { propTypes, defaultProps } from '../../../UTTextInput/versions/V1/proptypes';
4
4
  import UTTextInput from '../../../UTTextInput';
5
5
 
6
- import { ICON_EYE, ICON_EYE_OFF, INPUT_TYPE } from './constants';
6
+ import { ICON_EYE, ICON_EYE_OFF, INPUT_TYPE, KEYBOARD_TYPE_NUMERIC } from './constants';
7
7
 
8
- const UTPasswordField = props => {
8
+ const UTPasswordField = ({ keyboardType, ...props }) => {
9
9
  const [isPasswordVisible, setIsPasswordVisible] = useState(false);
10
10
 
11
- const toggleVisibility = () => {
12
- setIsPasswordVisible(!isPasswordVisible);
13
- };
11
+ const toggleVisibility = () => setIsPasswordVisible(!isPasswordVisible);
14
12
 
15
13
  const action = {
16
14
  Icon: isPasswordVisible ? ICON_EYE : ICON_EYE_OFF,
17
15
  onPress: toggleVisibility
18
16
  };
19
17
 
20
- return (
21
- <UTTextInput
22
- action={action}
23
- type={isPasswordVisible ? INPUT_TYPE.TEXT : INPUT_TYPE.PASSWORD}
24
- version="V1"
25
- {...props}
26
- />
27
- );
18
+ const textInputType = isPasswordVisible
19
+ ? keyboardType === KEYBOARD_TYPE_NUMERIC
20
+ ? INPUT_TYPE.NUMERIC
21
+ : INPUT_TYPE.TEXT
22
+ : keyboardType === KEYBOARD_TYPE_NUMERIC
23
+ ? INPUT_TYPE.PASSWORD_NUMERIC
24
+ : INPUT_TYPE.PASSWORD;
25
+
26
+ return <UTTextInput {...props} action={action} type={textInputType} version="V1" />;
28
27
  };
29
28
 
30
29
  UTPasswordField.defaultProps = defaultProps;
@@ -1,4 +1,4 @@
1
- import React, { PureComponent } from 'react';
1
+ import React, { PureComponent, createRef } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { bool, elementType, func, number, shape, string } from 'prop-types';
4
4
 
@@ -7,7 +7,7 @@ import UTFieldLabel from '../UTFieldLabel';
7
7
  import UTLabel from '../UTLabel';
8
8
  import UTValidation from '../UTValidation';
9
9
  import { formatErrorToValidation } from '../UTValidation/utils';
10
- import { LABEL_VARIANTS } from '../../constants/inputs';
10
+ import { TITLE_VARIANTS } from '../../constants/inputs';
11
11
  import { COMPONENT_KEYS } from '../UTBaseInputField/constants';
12
12
  import { validationDataProptypes } from '../UTValidation/constants';
13
13
 
@@ -24,7 +24,6 @@ class UTPhoneInput extends PureComponent {
24
24
  firstFocus: false,
25
25
  isValidCode: false,
26
26
  phoneNumber: '',
27
- phoneRef: null,
28
27
  secondFocus: false
29
28
  };
30
29
 
@@ -32,6 +31,7 @@ class UTPhoneInput extends PureComponent {
32
31
  this.handleSecondBlur = this.handleBlur('secondFocus');
33
32
  this.handleFirstFocus = this.handleFocus('firstFocus');
34
33
  this.handleSecondFocus = this.handleFocus('secondFocus');
34
+ this.phoneInputRef = createRef();
35
35
  }
36
36
 
37
37
  componentDidMount() {
@@ -122,14 +122,12 @@ class UTPhoneInput extends PureComponent {
122
122
  };
123
123
 
124
124
  handleSubmitEditing = () => {
125
- const { phoneRef, areaCodeError } = this.state;
125
+ const { areaCodeError } = this.state;
126
126
  if (!areaCodeError) {
127
- phoneRef.focus();
127
+ this.phoneInputRef.current?.focus();
128
128
  }
129
129
  };
130
130
 
131
- phoneInputRef = ref => this.setState({ phoneRef: ref });
132
-
133
131
  updateValue = () => {
134
132
  const { value, withAreaCode } = this.props;
135
133
  if (value) {
@@ -159,12 +157,12 @@ class UTPhoneInput extends PureComponent {
159
157
  const {
160
158
  areaCodePlaceholder,
161
159
  countryCode,
162
- editable,
163
- formError,
160
+ disabled,
161
+ error,
164
162
  helpText,
165
163
  InputRef,
166
- label,
167
- labelVariant,
164
+ title,
165
+ titleVariant,
168
166
  maxLength,
169
167
  onSubmitEditing,
170
168
  placeholder,
@@ -176,31 +174,31 @@ class UTPhoneInput extends PureComponent {
176
174
  } = this.props;
177
175
  const { areaCode, areaCodeError, isValidCode, phoneNumber } = this.state;
178
176
 
179
- const labelColorTheme = readOnly ? 'gray' : 'dark';
177
+ const titleColorTheme = readOnly ? 'gray' : 'dark';
180
178
 
181
- const validationErrors =
179
+ const validationData =
182
180
  validations ||
183
181
  (areaCodeError && formatErrorToValidation(areaCodeError)) ||
184
- (formError && formatErrorToValidation(formError));
182
+ (error && formatErrorToValidation(error));
185
183
 
186
- const hasError = validationErrors?.length > 0;
184
+ const hasError = validationData?.length > 0;
187
185
 
188
186
  return (
189
187
  <View style={styles.container}>
190
- {label && (
188
+ {title && (
191
189
  <UTFieldLabel
192
- colorTheme={labelColorTheme}
190
+ colorTheme={titleColorTheme}
193
191
  required={required}
194
- variant={LABEL_VARIANTS[labelVariant]}
192
+ variant={TITLE_VARIANTS[titleVariant]}
195
193
  >
196
- {label}
194
+ {title}
197
195
  </UTFieldLabel>
198
196
  )}
199
197
  <View style={styles.inputsContainer}>
200
198
  {withAreaCode ? (
201
199
  <UTBaseInputField
202
200
  alwaysShowPlaceholder
203
- disabled={!editable || readOnly}
201
+ disabled={disabled}
204
202
  error={hasError}
205
203
  leftAdornments={[]}
206
204
  maxLength={4}
@@ -209,6 +207,7 @@ class UTPhoneInput extends PureComponent {
209
207
  onFocus={this.handleFirstFocus}
210
208
  onSubmitEditing={this.handleSubmitEditing}
211
209
  placeholder={areaCodePlaceholder}
210
+ readOnly={readOnly}
212
211
  ref={InputRef}
213
212
  returnKeyType="next"
214
213
  rightAdornments={[
@@ -222,7 +221,7 @@ class UTPhoneInput extends PureComponent {
222
221
  <View style={styles.phoneNumber}>
223
222
  <UTBaseInputField
224
223
  alwaysShowPlaceholder
225
- disabled={(withAreaCode && !isValidCode) || !editable || readOnly}
224
+ disabled={(withAreaCode && !isValidCode) || disabled || readOnly}
226
225
  error={hasError && !areaCodeError}
227
226
  leftAdornments={
228
227
  countryCode && !withAreaCode
@@ -250,15 +249,15 @@ class UTPhoneInput extends PureComponent {
250
249
  {helpText}
251
250
  </UTLabel>
252
251
  )}
253
- {validationErrors && <UTValidation validationData={validationErrors} />}
252
+ {validationData && <UTValidation validationData={validationData} />}
254
253
  </View>
255
254
  );
256
255
  }
257
256
  }
258
257
 
259
258
  UTPhoneInput.defaultProps = {
260
- labelVariant: 'large',
261
259
  maxLength: 10,
260
+ titleVariant: 'large',
262
261
  translations: {
263
262
  areaCodeWithoutZeroError: 'Ingrese el código sin 0',
264
263
  invalidAreaCodeError: 'Código de área inválido'
@@ -269,12 +268,10 @@ UTPhoneInput.defaultProps = {
269
268
  UTPhoneInput.propTypes = {
270
269
  areaCodePlaceholder: string,
271
270
  countryCode: string,
272
- editable: bool,
273
- formError: string,
271
+ disabled: bool,
272
+ error: string,
274
273
  helpText: string,
275
274
  InputRef: func,
276
- label: string,
277
- labelVariant: string,
278
275
  maxLength: number,
279
276
  onBlur: func,
280
277
  onChange: func,
@@ -284,6 +281,8 @@ UTPhoneInput.propTypes = {
284
281
  readOnly: bool,
285
282
  required: bool,
286
283
  RightIcon: elementType,
284
+ title: string,
285
+ titleVariant: string,
287
286
  translations: shape({
288
287
  areaCodeWithoutZeroError: string,
289
288
  invalidAreaCodeError: string
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
3
  import merge from 'lodash/merge';
4
- import { bool, element, number, oneOf, shape, string } from 'prop-types';
4
+ import { bool, element, number, object, oneOf, shape, string } from 'prop-types';
5
5
  import isEmpty from 'lodash/isEmpty';
6
6
 
7
7
  import ImageIcon from '../ImageIcon';
@@ -81,13 +81,13 @@ UTProductItem.propTypes = {
81
81
  additionalInfo: string,
82
82
  amount: number,
83
83
  counter: shape({ current: number, limit: number }),
84
- counterLabelProps: shape({}),
84
+ counterLabelProps: object,
85
85
  discount: number,
86
86
  elevation: number,
87
87
  imageProps: shape({ image: oneOf([string, element]), withUri: bool }),
88
88
  previousAmount: number,
89
89
  quantity: number,
90
- quantityLabelProps: shape({}),
90
+ quantityLabelProps: object,
91
91
  secondaryAction: ActionPropTypes,
92
92
  selectedQuantity: number,
93
93
  title: string
@@ -6,19 +6,20 @@
6
6
 
7
7
  ## Props
8
8
 
9
- | Name | Type | Default | Description |
10
- | --------------- | -------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------ |
11
- | inputRef | func | | Reference to the input field. |
12
- | input | shape({ value: string.isRequired, onChange: func.isRequired }) | { value: '', onChange: () => {} } | Input object containing the value and onChange handler. |
13
- | onBlur | func | | Function to call when the input field loses focus. |
14
- | onFocus | func | | Function to call when the input field gains focus. |
15
- | onSubmitEditing | func | | Function to call when the input field is submitted. |
16
- | placeholder | string | | Placeholder text for the input field. |
17
- | returnKeyType | string | | Determines the return key type on the keyboard. |
18
- | size | string | medium | Size of the input field. One of: `small`, `medium`, `large`. |
19
- | style | object | | Style object to customize the input field. |
20
- | type | string | | Type of input (e.g., 'text', 'password', 'email'). |
21
- | variant | string | white | Variant of the input field. One of: `white`, `gray`. |
9
+ | Name | Type | Default | Description |
10
+ | --------------- | ------ | ------- | ------------------------------------------------------------ |
11
+ | inputRef | func | | Reference to the input field. |
12
+ | onBlur | func | | Function to call when the input field loses focus. |
13
+ | onChange | func | | Function to call when the input field value changes. |
14
+ | onFocus | func | | Function to call when the input field gains focus. |
15
+ | onSubmitEditing | func | | Function to call when the input field is submitted. |
16
+ | placeholder | string | | Placeholder text for the input field. |
17
+ | returnKeyType | string | | Determines the return key type on the keyboard. |
18
+ | size | string | medium | Size of the input field. One of: `small`, `medium`, `large`. |
19
+ | style | object | | Style object to customize the input field. |
20
+ | type | string | | Type of input (e.g., 'text', 'password', 'email'). |
21
+ | value | string | '' | The value of the input field. |
22
+ | variant | string | white | Variant of the input field. One of: `white`, `gray`. |
22
23
 
23
24
  ## Example
24
25
 
@@ -7,9 +7,9 @@ import { defaultProps, propTypes } from './proptypes';
7
7
 
8
8
  const UTSearchField = ({
9
9
  disabled,
10
- input,
11
10
  inputRef,
12
11
  onBlur,
12
+ onChange,
13
13
  onFocus,
14
14
  onSubmitEditing,
15
15
  placeholder,
@@ -17,10 +17,11 @@ const UTSearchField = ({
17
17
  size,
18
18
  style,
19
19
  type,
20
+ value,
20
21
  variant
21
22
  }) => {
22
23
  const clearText = () => {
23
- input.onChange('');
24
+ onChange('');
24
25
  };
25
26
 
26
27
  const action = { Icon: 'IconX', onPress: clearText, size: 'small' };
@@ -29,16 +30,16 @@ const UTSearchField = ({
29
30
  { name: COMPONENT_KEYS.ICON, props: { Icon: 'IconSearch', changeOnFocus: true, shade: '02' } }
30
31
  ];
31
32
 
32
- const rightAdornments = input.value ? [{ name: COMPONENT_KEYS.ACTION, props: { action } }] : [];
33
+ const rightAdornments = value ? [{ name: COMPONENT_KEYS.ACTION, props: { action } }] : [];
33
34
 
34
35
  return (
35
36
  <UTBaseInputField
36
37
  alwaysShowPlaceholder
37
38
  disabled={disabled}
38
- input={input}
39
39
  inputSize={size}
40
40
  leftAdornments={leftAdornments}
41
41
  onBlur={onBlur}
42
+ onChange={onChange}
42
43
  onFocus={onFocus}
43
44
  onSubmitEditing={onSubmitEditing}
44
45
  placeholder={placeholder}
@@ -47,6 +48,7 @@ const UTSearchField = ({
47
48
  rightAdornments={rightAdornments}
48
49
  style={{ container: style }}
49
50
  type={type}
51
+ value={value}
50
52
  variant={variant}
51
53
  />
52
54
  );
@@ -1,22 +1,17 @@
1
- import { func, oneOf, string, object, shape, instanceOf, oneOfType } from 'prop-types';
1
+ import { func, oneOf, string, object, instanceOf, oneOfType } from 'prop-types';
2
2
 
3
3
  import { SIZES, VARIANT } from '../UTBaseInputField/constants';
4
4
 
5
5
  export const defaultProps = {
6
- input: {
7
- value: [],
8
- onChange: () => {}
9
- },
6
+ onChange: () => {},
7
+ value: '',
10
8
  variant: VARIANT.WHITE
11
9
  };
12
10
 
13
11
  export const propTypes = {
14
- input: shape({
15
- value: string,
16
- onChange: func
17
- }),
18
12
  inputRef: oneOfType([func, instanceOf(Object)]),
19
13
  onBlur: func,
14
+ onChange: func,
20
15
  onFocus: func,
21
16
  onSubmitEditing: func,
22
17
  placeholder: string,
@@ -24,5 +19,6 @@ export const propTypes = {
24
19
  size: oneOf(Object.values(SIZES)),
25
20
  style: object,
26
21
  type: string,
22
+ value: string,
27
23
  variant: oneOf(Object.values(VARIANT))
28
24
  };