@widergy/mobile-ui 1.12.4 → 1.12.6

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 (34) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/UTBadge/README.md +17 -26
  3. package/lib/components/UTBadge/index.js +6 -5
  4. package/lib/components/UTButton/README.md +78 -26
  5. package/lib/components/UTButton/index.js +4 -4
  6. package/lib/components/UTIcon/README.md +53 -51
  7. package/lib/components/UTIcon/index.js +5 -3
  8. package/lib/components/UTLabel/README.md +62 -39
  9. package/lib/components/UTLabel/index.js +14 -6
  10. package/lib/components/UTLabel/theme.js +24 -9
  11. package/lib/components/UTLoading/index.js +5 -1
  12. package/lib/components/UTPasswordField/index.js +9 -42
  13. package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/components/ErrorMessage/index.js +3 -3
  14. package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/components/Validation/index.js +3 -3
  15. package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/index.js +1 -1
  16. package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/styles.js +1 -2
  17. package/lib/components/UTPasswordField/versions/V0/index.js +49 -0
  18. package/lib/components/UTPasswordField/versions/V1/README.md +23 -0
  19. package/lib/components/UTPasswordField/versions/V1/constants.js +7 -0
  20. package/lib/components/UTPasswordField/versions/V1/index.js +32 -0
  21. package/lib/components/UTTextArea/README.md +32 -0
  22. package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +1 -1
  23. package/lib/components/UTTextInput/versions/V1/README.md +236 -0
  24. package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +179 -148
  25. package/lib/components/UTTextInput/versions/V1/components/TextInputField/theme.js +30 -27
  26. package/lib/components/UTTextInput/versions/V1/components/TextInputField/utils.js +7 -5
  27. package/lib/components/UTTextInput/versions/V1/index.js +13 -5
  28. package/lib/components/UTTextInput/versions/V1/proptypes.js +3 -0
  29. package/lib/components/UTValidation/README.md +33 -18
  30. package/lib/components/UTValidation/index.js +8 -6
  31. package/package.json +1 -1
  32. /package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/components/ErrorMessage/styles.js +0 -0
  33. /package/lib/components/UTPasswordField/{components → versions/V0/components}/PasswordValidations/components/Validation/styles.js +0 -0
  34. /package/lib/components/UTPasswordField/{proptypes.js → versions/V0/proptypes.js} +0 -0
@@ -30,7 +30,11 @@ const UTLoading = ({
30
30
  messageStyle={messageStyle}
31
31
  />
32
32
  )}
33
- {preventUnmount ? <View style={{ display: loading && 'none' }}>{children}</View> : !loading && children}
33
+ {preventUnmount ? (
34
+ <View style={{ display: loading ? 'none' : 'flex' }}>{children}</View>
35
+ ) : (
36
+ !loading && children
37
+ )}
34
38
  </Fragment>
35
39
  );
36
40
  };
@@ -1,49 +1,16 @@
1
1
  import React from 'react';
2
- import { View } from 'react-native';
2
+ import { string } from 'prop-types';
3
3
 
4
- import UTTextInput from '../UTTextInput';
4
+ import V0 from './versions/V0';
5
+ import V1 from './versions/V1';
5
6
 
6
- import PasswordValidations from './components/PasswordValidations';
7
- import passwordFieldProptypes from './proptypes';
8
-
9
- const UTPasswordField = ({
10
- style,
11
- disabled,
12
- input,
13
- error,
14
- disableCaptionLabel,
15
- passwordValidations,
16
- showValidations,
17
- shouldShowError,
18
- errorTextProps,
19
- ...props
20
- }) => {
21
- const { value, onChange } = input;
22
-
23
- return (
24
- <View>
25
- <UTTextInput
26
- {...props}
27
- value={value}
28
- onChange={onChange}
29
- error={showValidations ? !!error : error}
30
- errorTextProps={errorTextProps}
31
- hiddenInput
32
- />
33
- {!!showValidations && !!passwordValidations && (
34
- <PasswordValidations
35
- disabled={disabled}
36
- value={value}
37
- style={style}
38
- error={error}
39
- passwordValidations={passwordValidations}
40
- shouldShowError={shouldShowError}
41
- />
42
- )}
43
- </View>
44
- );
7
+ const UTPasswordField = ({ version = 'V0', ...props }) => {
8
+ const Component = { V0, V1 }[version];
9
+ return <Component {...props} />;
45
10
  };
46
11
 
47
- UTPasswordField.propTypes = passwordFieldProptypes;
12
+ UTPasswordField.propTypes = {
13
+ version: string
14
+ };
48
15
 
49
16
  export default UTPasswordField;
@@ -3,9 +3,9 @@ import { bool, string, func } from 'prop-types';
3
3
  import { View } from 'react-native';
4
4
  import _ from 'lodash';
5
5
 
6
- import Label from '../../../../../Label';
7
- import Icon from '../../../../../Icon';
8
- import { useTheme } from '../../../../../../theming';
6
+ import { useTheme } from '../../../../../../../../theming';
7
+ import Icon from '../../../../../../../Icon';
8
+ import Label from '../../../../../../../Label';
9
9
 
10
10
  import ownStyles from './styles';
11
11
 
@@ -3,9 +3,9 @@ import { string, bool, element } from 'prop-types';
3
3
  import { View } from 'react-native';
4
4
  import _ from 'lodash';
5
5
 
6
- import Label from '../../../../../Label';
7
- import Icon from '../../../../../Icon';
8
- import { useTheme } from '../../../../../../theming';
6
+ import { useTheme } from '../../../../../../../../theming';
7
+ import Icon from '../../../../../../../Icon';
8
+ import Label from '../../../../../../../Label';
9
9
 
10
10
  import ownStyles from './styles';
11
11
 
@@ -4,7 +4,7 @@ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
4
4
  import { View } from 'react-native';
5
5
  import _ from 'lodash';
6
6
 
7
- import { useTheme } from '../../../../theming';
7
+ import { useTheme } from '../../../../../../theming';
8
8
 
9
9
  import Validation from './components/Validation';
10
10
  import ErrorMessage from './components/ErrorMessage';
@@ -1,6 +1,5 @@
1
1
  import { StyleSheet } from 'react-native';
2
-
3
- import { moderateVerticalScale } from '../../../../utils/scaleUtils';
2
+ import { moderateVerticalScale } from '../../../../../../utils/scaleUtils';
4
3
 
5
4
  export default StyleSheet.create({
6
5
  errorsContainer: {
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+
4
+ import UTTextInput from '../../../UTTextInput';
5
+
6
+ import PasswordValidations from './components/PasswordValidations';
7
+ import passwordFieldProptypes from './proptypes';
8
+
9
+ const UTPasswordField = ({
10
+ style,
11
+ disabled,
12
+ input,
13
+ error,
14
+ disableCaptionLabel,
15
+ passwordValidations,
16
+ showValidations,
17
+ shouldShowError,
18
+ errorTextProps,
19
+ ...props
20
+ }) => {
21
+ const { value, onChange } = input;
22
+
23
+ return (
24
+ <View>
25
+ <UTTextInput
26
+ {...props}
27
+ value={value}
28
+ onChange={onChange}
29
+ error={showValidations ? !!error : error}
30
+ errorTextProps={errorTextProps}
31
+ hiddenInput
32
+ />
33
+ {!!showValidations && !!passwordValidations && (
34
+ <PasswordValidations
35
+ disabled={disabled}
36
+ value={value}
37
+ style={style}
38
+ error={error}
39
+ passwordValidations={passwordValidations}
40
+ shouldShowError={shouldShowError}
41
+ />
42
+ )}
43
+ </View>
44
+ );
45
+ };
46
+
47
+ UTPasswordField.propTypes = passwordFieldProptypes;
48
+
49
+ export default UTPasswordField;
@@ -0,0 +1,23 @@
1
+ # UTPasswordField
2
+
3
+ ## Description
4
+
5
+ `UTPasswordField` is a component that provides a password input field with an optional toggle to show or hide the password. It builds on the `UTTextInput` component and adds functionality specific to password inputs.
6
+
7
+ ## Props
8
+
9
+ `UTPasswordField` inherits all the props from `UTTextInput` and adds custom behavior for handling password visibility.
10
+
11
+ | Name | Type | Default | Description |
12
+ | ---- | ---- | ------- | -------------------------------------- |
13
+ | ... | ... | ... | Inherits all props from `UTTextInput`. |
14
+
15
+ ## Usage
16
+
17
+ ```javascript
18
+ <UTPasswordField placeholder="Enter your password" />
19
+ ```
20
+
21
+ ## Notes
22
+
23
+ For more detailed information on inherited props, refer to the documentation for `UTTextInput`.
@@ -0,0 +1,7 @@
1
+ export const INPUT_TYPE = {
2
+ PASSWORD: 'password',
3
+ TEXT: 'text'
4
+ };
5
+
6
+ export const ICON_EYE = 'IconEye';
7
+ export const ICON_EYE_OFF = 'IconEyeOff';
@@ -0,0 +1,32 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import propTypes from '../../../UTTextInput/versions/V1/proptypes';
4
+ import UTTextInput from '../../../UTTextInput';
5
+
6
+ import { ICON_EYE, ICON_EYE_OFF, INPUT_TYPE } from './constants';
7
+
8
+ const UTPasswordField = props => {
9
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
10
+
11
+ const toggleVisibility = () => {
12
+ setIsPasswordVisible(!isPasswordVisible);
13
+ };
14
+
15
+ const action = {
16
+ icon: isPasswordVisible ? ICON_EYE : ICON_EYE_OFF,
17
+ onPress: toggleVisibility
18
+ };
19
+
20
+ return (
21
+ <UTTextInput
22
+ action={action}
23
+ type={isPasswordVisible ? INPUT_TYPE.TEXT : INPUT_TYPE.PASSWORD}
24
+ version="V1"
25
+ {...props}
26
+ />
27
+ );
28
+ };
29
+
30
+ UTPasswordField.propTypes = propTypes;
31
+
32
+ export default UTPasswordField;
@@ -0,0 +1,32 @@
1
+ # UTTextArea
2
+
3
+ ## Description
4
+
5
+ `UTTextArea` is a component that provides a multi-line text input field, building on the `UTTextInput` component with additional customization for handling multiple rows of text.
6
+
7
+ ## Props
8
+
9
+ `UTTextArea` inherits all the props from `UTTextInput` and adds an additional prop specific to the number of rows.
10
+
11
+ | Name | Type | Default | Description |
12
+ | ------- | ------ | ------- | ----------------------------------------------------- |
13
+ | maxRows | number | 4 | The maximum number of rows the text area can display. |
14
+ | ... | ... | ... | Inherits all props from `UTTextInput`. |
15
+
16
+ ## Usage
17
+
18
+ ### Basic Example
19
+
20
+ ```javascript
21
+ <UTTextArea placeholder="Enter your text here..." />
22
+ ```
23
+
24
+ ### Example with Custom Rows
25
+
26
+ ```javascript
27
+ <UTTextArea maxRows={6} placeholder="Enter a longer text here..." />
28
+ ```
29
+
30
+ ## Notes
31
+
32
+ For more detailed information on inherited props, refer to the documentation for `UTTextInput`.
@@ -86,7 +86,7 @@ const BaseInput = forwardRef(
86
86
  select && disabled && { color: theme.fonts?.fontDisabledColor }
87
87
  ]}
88
88
  />
89
- {(RightIcon || hiddenInput) && (
89
+ {RightIcon && (
90
90
  <Touchable
91
91
  borderless
92
92
  onPress={hiddenInput ? toggleShowInput : onRightIconPress}
@@ -0,0 +1,236 @@
1
+ # UTTextInput
2
+
3
+ Component used for displaying a text input field with various customization options.
4
+
5
+ ## Props
6
+
7
+ | Name | Type | Default | Description |
8
+ | --------------------- | ----------- | --------- | -------------------------------------------------------------------------------------------------------- |
9
+ | action | object | | Action button configuration object. |
10
+ | alwaysShowPlaceholder | bool | false | Whether to always show the placeholder. |
11
+ | disabled | bool | false | Disables the input field. |
12
+ | error | string | | Error message to be displayed. |
13
+ | helpText | string | | Help text to be displayed below the input field. |
14
+ | InputRef | ref | | Reference to the input field. |
15
+ | inputSize | string | 'l' | Size of the input field. |
16
+ | label | string | | Label text for the input field. |
17
+ | labelVariant | string | 'l' | Variant of the label. |
18
+ | LeftIcon | elementType | | Icon to be displayed on the left side of the input field. |
19
+ | maxCount | number | | Maximum number of characters allowed in the input field. |
20
+ | maxRows | number | 1 | Maximum number of rows allowed in the input field. |
21
+ | onBlur | func | | Function to call when the input field loses focus. |
22
+ | onChange | func | | Function to call when the input field value changes. |
23
+ | onFocus | func | | Function to call when the input field gains focus. |
24
+ | onSubmitEditing | func | | Function to call when the input field is submitted. |
25
+ | placeholder | string | | Placeholder text for the input field. |
26
+ | prefix | string | | Prefix text to be displayed inside the input field. |
27
+ | readOnly | bool | false | Makes the input field read-only. |
28
+ | required | bool | false | Whether the input field is required. |
29
+ | returnKeyType | string | 'done' | Determines the return key type on the keyboard. |
30
+ | RightIcon | elementType | | Icon to be displayed on the right side of the input field. |
31
+ | style | object | | Style object to customize the input field. Can contain `root`, `container`, `input`, or `action` styles. |
32
+ | suffix | string | | Suffix text to be displayed inside the input field. |
33
+ | tooltip | string | | Tooltip text to be displayed. |
34
+ | type | string | 'default' | Type of input (e.g., 'text', 'password', 'email'). |
35
+ | validations | array | | Array of validation rules to be applied to the input field. |
36
+ | value | string | '' | Value of the input field. |
37
+
38
+ ### action
39
+
40
+ Configuration object for the action button.
41
+
42
+ | Name | Type | Description |
43
+ | ---------- | ----------- | --------------------------------------------------- |
44
+ | icon | elementType | Icon to be displayed in the action button. |
45
+ | onPress | func | Function to call when the action button is pressed. |
46
+ | colorTheme | string | Color theme of the action button. |
47
+ | text | string | Text to be displayed in the action button. |
48
+
49
+ ### labelVariant
50
+
51
+ It must be one of these:
52
+
53
+ - "s": small
54
+ - "l": large
55
+
56
+ ### inputSize
57
+
58
+ It must be one of these:
59
+
60
+ - "s": small
61
+ - "l": large
62
+
63
+ ### type
64
+
65
+ It must be one of these:
66
+
67
+ - "default"
68
+ - "email"
69
+ - "password"
70
+ - "numeric"
71
+
72
+ ### Methods via `InputRef`
73
+
74
+ | Name | Description |
75
+ | -------- | ------------------------------------ |
76
+ | focus | Focuses the input field. |
77
+ | blur | Blurs the input field. |
78
+ | setValue | Sets the value of the input field. |
79
+ | clear | Clears the value of the input field. |
80
+
81
+ ### style
82
+
83
+ The `style` prop is an object that can contain the following keys to customize the appearance of the input field:
84
+
85
+ - `root`: Style for the root of the component.
86
+ - `container`: Style for the container of the input field.
87
+ - `input`: Style for the input field itself.
88
+ - `action`: Style for the action button.
89
+
90
+ ### Right Icon
91
+
92
+ If a RightIcon is provided and an error occurs, the RightIcon will be replaced by an error icon.
93
+
94
+ ### Structure of validations
95
+
96
+ The validations prop expects an array of objects, where each object can have a title, status, and an items array. Each item in the items array represents a specific validation rule with a status and text.
97
+ It is no neccesary to indicate status value if it is "default".
98
+
99
+ #### Example structure:
100
+
101
+ ```jsx
102
+ const validationData = [
103
+ {
104
+ items: [
105
+ {
106
+ status: 'success',
107
+ text: 'Must be at least 8 characters long.'
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ items: [
113
+ {
114
+ status: 'error',
115
+ text: 'Must be at most 16 characters long.'
116
+ }
117
+ ]
118
+ },
119
+ {
120
+ title: 'Must meet at least one of the following conditions:',
121
+ status: 'error',
122
+ items: [
123
+ {
124
+ text: 'At least one lowercase letter.'
125
+ },
126
+ {
127
+ text: 'At least one uppercase letter.'
128
+ },
129
+ {
130
+ status: 'success',
131
+ text: 'At least one number.'
132
+ }
133
+ ]
134
+ }
135
+ ];
136
+ ```
137
+
138
+ ### Handling Errors
139
+
140
+ Errors can be displayed below the input field using either the `error` prop or the `validations` prop.
141
+
142
+ - **error**: A string that represents a general error message.
143
+ - **validations**: An array of validation rules, where each rule is an object containing a `rule` and a `message`.
144
+
145
+ If both `error` and `validations` are provided, `validations` will take precedence, and its messages will be displayed.
146
+
147
+ #### Example usage with `error`:
148
+
149
+ ```jsx
150
+ <UTTextInput
151
+ label="Username"
152
+ placeholder="Enter your username"
153
+ error="This username is already taken"
154
+ />
155
+ ```
156
+
157
+ #### Example usage with validations:
158
+
159
+ ```jsx
160
+ const validations = [
161
+ {
162
+ items: [
163
+ {
164
+ status: 'success',
165
+ text: 'Must be at least 8 characters long.'
166
+ }
167
+ ]
168
+ },
169
+ {
170
+ items: [
171
+ {
172
+ status: 'error',
173
+ text: 'Must be at most 16 characters long.'
174
+ }
175
+ ]
176
+ },
177
+ {
178
+ title: 'Must meet at least one of the following conditions:',
179
+ status: 'error',
180
+ items: [
181
+ {
182
+ text: 'At least one lowercase letter.'
183
+ },
184
+ {
185
+ text: 'At least one uppercase letter.'
186
+ },
187
+ {
188
+ status: 'success',
189
+ text: 'At least one number.'
190
+ }
191
+ ]
192
+ }
193
+ ];
194
+
195
+ <UTTextInput
196
+ label="Email"
197
+ placeholder="Enter your email"
198
+ validations={validations}
199
+ />
200
+
201
+ ```
202
+
203
+ ## Usage
204
+
205
+ ```jsx
206
+ <UTTextInput
207
+ label="Password"
208
+ placeholder="Enter your password"
209
+ type="password"
210
+ required
211
+ onChange={text => console.log(text)}
212
+ validations={[
213
+ {
214
+ title: 'Must meet at least two of the following conditions:',
215
+ items: [
216
+ {
217
+ text: 'At least one lowercase letter.'
218
+ },
219
+ {
220
+ text: 'At least one uppercase letter.'
221
+ },
222
+ {
223
+ status: 'success',
224
+ text: 'At least one number.'
225
+ }
226
+ ]
227
+ }
228
+ ]}
229
+ style={{
230
+ root: { padding: 5 },
231
+ container: { margin: 10 },
232
+ input: { borderColor: 'blue' },
233
+ action: { backgroundColor: 'green' }
234
+ }}
235
+ />
236
+ ```