@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.
- package/CHANGELOG.md +7 -0
- package/lib/components/CheckList/components/CheckBoxRenderer/index.js +8 -10
- package/lib/components/Label/propTypes.js +2 -5
- package/lib/components/UTBadge/index.js +2 -3
- package/lib/components/UTBaseInputField/README.md +31 -22
- package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +6 -3
- package/lib/components/UTBaseInputField/constants.js +3 -1
- package/lib/components/UTBaseInputField/index.js +17 -6
- package/lib/components/UTBaseInputField/proptypes.js +10 -20
- package/lib/components/UTBaseInputField/theme.js +1 -2
- package/lib/components/UTButton/proptypes.js +4 -5
- package/lib/components/UTCBUInput/index.js +11 -12
- package/lib/components/UTCheckBox/README.md +14 -14
- package/lib/components/UTCheckBox/index.js +11 -6
- package/lib/components/UTCheckBox/proptypes.js +3 -4
- package/lib/components/UTCheckBox/theme.js +11 -4
- package/lib/components/UTCheckList/README.MD +22 -32
- package/lib/components/UTCheckList/index.js +6 -7
- package/lib/components/UTCheckList/proptypes.js +12 -24
- package/lib/components/UTFieldLabel/index.js +11 -13
- package/lib/components/UTIcon/index.js +2 -3
- package/lib/components/UTPasswordField/versions/V1/constants.js +4 -0
- package/lib/components/UTPasswordField/versions/V1/index.js +12 -13
- package/lib/components/UTPhoneInput/index.js +26 -27
- package/lib/components/UTProductItem/index.js +3 -3
- package/lib/components/UTSearchField/README.md +14 -13
- package/lib/components/UTSearchField/index.js +6 -4
- package/lib/components/UTSearchField/proptypes.js +5 -9
- package/lib/components/UTSelect/versions/V1/README.md +29 -35
- package/lib/components/UTSelect/versions/V1/index.js +73 -44
- package/lib/components/UTSelect/versions/V1/proptypes.js +17 -16
- package/lib/components/UTSelect/versions/V1/styles.js +3 -0
- package/lib/components/UTSelect/versions/V1/utils.js +21 -0
- package/lib/components/UTSelectableCard/index.js +5 -2
- package/lib/components/UTTextInput/versions/V1/README.md +35 -34
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +13 -14
- package/lib/components/UTTextInput/versions/V1/index.js +12 -10
- package/lib/components/UTTextInput/versions/V1/proptypes.js +20 -19
- package/lib/components/UTValidation/index.js +2 -2
- package/lib/constants/inputs.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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:
|
|
41
|
-
header:
|
|
42
|
-
item:
|
|
43
|
-
root:
|
|
44
|
-
selectAll:
|
|
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
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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 {
|
|
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 {
|
|
125
|
+
const { areaCodeError } = this.state;
|
|
126
126
|
if (!areaCodeError) {
|
|
127
|
-
|
|
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
|
-
|
|
163
|
-
|
|
160
|
+
disabled,
|
|
161
|
+
error,
|
|
164
162
|
helpText,
|
|
165
163
|
InputRef,
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
177
|
+
const titleColorTheme = readOnly ? 'gray' : 'dark';
|
|
180
178
|
|
|
181
|
-
const
|
|
179
|
+
const validationData =
|
|
182
180
|
validations ||
|
|
183
181
|
(areaCodeError && formatErrorToValidation(areaCodeError)) ||
|
|
184
|
-
(
|
|
182
|
+
(error && formatErrorToValidation(error));
|
|
185
183
|
|
|
186
|
-
const hasError =
|
|
184
|
+
const hasError = validationData?.length > 0;
|
|
187
185
|
|
|
188
186
|
return (
|
|
189
187
|
<View style={styles.container}>
|
|
190
|
-
{
|
|
188
|
+
{title && (
|
|
191
189
|
<UTFieldLabel
|
|
192
|
-
colorTheme={
|
|
190
|
+
colorTheme={titleColorTheme}
|
|
193
191
|
required={required}
|
|
194
|
-
variant={
|
|
192
|
+
variant={TITLE_VARIANTS[titleVariant]}
|
|
195
193
|
>
|
|
196
|
-
{
|
|
194
|
+
{title}
|
|
197
195
|
</UTFieldLabel>
|
|
198
196
|
)}
|
|
199
197
|
<View style={styles.inputsContainer}>
|
|
200
198
|
{withAreaCode ? (
|
|
201
199
|
<UTBaseInputField
|
|
202
200
|
alwaysShowPlaceholder
|
|
203
|
-
disabled={
|
|
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) ||
|
|
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
|
-
{
|
|
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
|
-
|
|
273
|
-
|
|
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:
|
|
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:
|
|
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
|
|
10
|
-
| --------------- |
|
|
11
|
-
| inputRef | func
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
| onFocus | func
|
|
15
|
-
| onSubmitEditing | func
|
|
16
|
-
| placeholder | string
|
|
17
|
-
| returnKeyType | string
|
|
18
|
-
| size | string
|
|
19
|
-
| style | object
|
|
20
|
-
| type | string
|
|
21
|
-
|
|
|
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
|
-
|
|
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 =
|
|
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,
|
|
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
|
-
|
|
7
|
-
|
|
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
|
};
|
|
@@ -4,35 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
`UTSelect` is a customizable dropdown select component that allows users to select single or multiple options from a provided list. It includes features like search, select all, and dynamic option filtering.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
28
|
-
### Input Object
|
|
29
|
-
|
|
30
|
-
The `input` prop is an object that should contain the following keys:
|
|
31
|
-
|
|
32
|
-
| Name | Type | Description |
|
|
33
|
-
| -------- | ----------------------- | -------------------------------------------- |
|
|
34
|
-
| value | arrayOf(string, number) | Array of selected values. |
|
|
35
|
-
| onChange | func | Function to call when the selection changes. |
|
|
7
|
+
| Name | Type | Default | Description |
|
|
8
|
+
| --------------------- | -------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| action | shape | | Action object containing `Icon`, `onPress`, and `size` for the action button. |
|
|
10
|
+
| alwaysShowPlaceholder | bool | true | Determines if the placeholder should always be shown. |
|
|
11
|
+
| clearable | bool | false | Determines whether a button to clear the current selection should be shown. |
|
|
12
|
+
| helpText | string | | Help text displayed below the input field. |
|
|
13
|
+
| title | string | | Title for the select field. |
|
|
14
|
+
| multiple | bool | false | Allows multiple selection if true. |
|
|
15
|
+
| noMatchesText | string | | Text to display when no matches are found in the search. |
|
|
16
|
+
| onChange | func | | Function to call when the input field value changes. |
|
|
17
|
+
| options | array | | Array of options to be displayed in the dropdown. Each option is an object with `label` and `value`. |
|
|
18
|
+
| placeholder | string | | Placeholder text for the select field. |
|
|
19
|
+
| prefix | string | | Text to display as a prefix inside the input field. |
|
|
20
|
+
| required | bool | false | Indicates if the select field is required. |
|
|
21
|
+
| searchPlaceholder | string | | Placeholder text for the search field. |
|
|
22
|
+
| selectAllLabel | string | | Label for the "Select All" checkbox. |
|
|
23
|
+
| showSelectAll | bool | false | Determines whether to show the "Select All" checkbox. |
|
|
24
|
+
| style | shape | {} | Custom styles to apply to the select field. Applies styles to the root container of the select field. |
|
|
25
|
+
| suffix | string | | Text to display as a suffix inside the input field. |
|
|
26
|
+
| value | oneOfType([string, array]) | null | The value of the input field. It can be a string for single selection or an array for multiple selection. |
|
|
27
|
+
| withAutoReset | bool | true | Determines whether the select should automatically reset when the selected value is no longer available in the options. |
|
|
36
28
|
|
|
37
29
|
### Option Object
|
|
38
30
|
|
|
@@ -43,6 +35,10 @@ The `options` prop is an array of objects, each representing an option:
|
|
|
43
35
|
| label | string | Label to display for the option. |
|
|
44
36
|
| value | string, number | Value of the option. |
|
|
45
37
|
|
|
38
|
+
### `withAutoReset`
|
|
39
|
+
|
|
40
|
+
`withAutoReset` is a prop that controls the behavior of the `UTSelect` component when the selected value is no longer available in the current options. This is useful in scenarios where the available options can change dynamically, for example, due to filtering or other user interactions.
|
|
41
|
+
|
|
46
42
|
## Usage
|
|
47
43
|
|
|
48
44
|
```jsx
|
|
@@ -62,16 +58,14 @@ const UTSelectExample = () => {
|
|
|
62
58
|
return (
|
|
63
59
|
<View style={{ padding: 20 }}>
|
|
64
60
|
<UTSelect
|
|
65
|
-
|
|
61
|
+
title="Select Options"
|
|
62
|
+
noMatchesText="No matches found"
|
|
63
|
+
onChange={setSelectedOptions}
|
|
66
64
|
options={options}
|
|
67
|
-
input={{
|
|
68
|
-
value: selectedOptions,
|
|
69
|
-
onChange: setSelectedOptions
|
|
70
|
-
}}
|
|
71
65
|
placeholder="Select an option"
|
|
72
66
|
searchPlaceholder="Search options"
|
|
73
67
|
selectAllLabel="Select All"
|
|
74
|
-
|
|
68
|
+
value={selectedOptions}
|
|
75
69
|
/>
|
|
76
70
|
<Text>Selected Options: {selectedOptions.join(', ')}</Text>
|
|
77
71
|
</View>
|