@widergy/mobile-ui 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/lib/components/Button/index.js +1 -1
- package/lib/components/UTBadge/index.js +2 -2
- package/lib/components/UTBadge/theme.js +9 -6
- package/lib/components/UTBaseInputField/README.md +45 -31
- package/lib/components/UTBaseInputField/components/ActionAdornment/index.js +5 -16
- package/lib/components/UTBaseInputField/components/BadgeAdornment/index.js +13 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/constants.js +2 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/index.js +20 -15
- package/lib/components/UTBaseInputField/components/IconAdornment/proptypes.js +20 -0
- package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +7 -2
- package/lib/components/UTBaseInputField/constants.js +12 -1
- package/lib/components/UTBaseInputField/index.js +69 -72
- package/lib/components/UTBaseInputField/proptypes.js +60 -0
- package/lib/components/UTBaseInputField/theme.js +72 -32
- package/lib/components/UTBottomSheet/README.md +53 -0
- package/lib/components/UTBottomSheet/index.js +139 -0
- package/lib/components/UTBottomSheet/styles.js +46 -0
- package/lib/components/UTButton/constants.js +5 -14
- package/lib/components/UTButton/index.js +6 -22
- package/lib/components/UTButton/proptypes.js +29 -0
- package/lib/components/UTButton/theme.js +6 -5
- package/lib/components/UTCheckBox/README.md +4 -30
- package/lib/components/UTCheckBox/constants.js +4 -1
- package/lib/components/UTCheckBox/index.js +33 -22
- package/lib/components/UTCheckBox/proptypes.js +12 -3
- package/lib/components/UTCheckBox/styles.js +7 -0
- package/lib/components/UTCheckBox/theme.js +98 -54
- package/lib/components/UTCheckList/README.MD +14 -10
- package/lib/components/UTCheckList/constants.js +6 -1
- package/lib/components/UTCheckList/index.js +44 -66
- package/lib/components/UTCheckList/proptypes.js +48 -0
- package/lib/components/UTCheckList/styles.js +10 -5
- package/lib/components/UTCheckList/utils.js +5 -0
- package/lib/components/UTFieldLabel/index.js +4 -3
- package/lib/components/UTIcon/README.md +46 -7
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCar.svg +17 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconCart.svg +6 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconHome.svg +5 -0
- package/lib/components/UTIcon/components/EnergyIcons/EnergyIconTruck.svg +7 -0
- package/lib/components/UTIcon/constants.js +14 -0
- package/lib/components/UTIcon/index.js +19 -8
- package/lib/components/UTIcon/utils.js +34 -0
- package/lib/components/UTLabel/constants.js +11 -11
- package/lib/components/UTLabel/index.js +3 -17
- package/lib/components/UTLabel/proptypes.js +19 -0
- package/lib/components/UTLabel/theme.js +2 -2
- package/lib/components/UTMenu/index.js +1 -1
- package/lib/components/UTPasswordField/versions/V0/components/PasswordValidations/styles.js +1 -0
- package/lib/components/UTPasswordField/versions/V1/index.js +3 -2
- package/lib/components/UTSearchField/README.md +42 -0
- package/lib/components/UTSearchField/index.js +59 -0
- package/lib/components/UTSearchField/proptypes.js +28 -0
- package/lib/components/UTSelect/index.js +10 -97
- package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/index.js +1 -1
- package/lib/components/UTSelect/versions/V0/index.js +103 -0
- package/lib/components/UTSelect/versions/V1/README.md +82 -0
- package/lib/components/UTSelect/versions/V1/index.js +171 -0
- package/lib/components/UTSelect/versions/V1/proptypes.js +45 -0
- package/lib/components/UTSelect/versions/V1/styles.js +18 -0
- package/lib/components/UTTextArea/index.js +1 -1
- package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +3 -3
- package/lib/components/UTTextInput/versions/V1/README.md +36 -35
- package/lib/components/UTTextInput/versions/V1/components/TextInputField/index.js +18 -12
- package/lib/components/UTTextInput/versions/V1/constants.js +3 -5
- package/lib/components/UTTextInput/versions/V1/index.js +21 -18
- package/lib/components/UTTextInput/versions/V1/proptypes.js +23 -6
- package/lib/index.js +47 -52
- package/package.json +2 -2
- /package/lib/components/UTSelect/{componentes → versions/V0/componentes}/MultipleItem/styles.js +0 -0
- /package/lib/components/UTSelect/{proptypes.js → versions/V0/proptypes.js} +0 -0
- /package/lib/components/UTSelect/{styles.js → versions/V0/styles.js} +0 -0
|
@@ -13,13 +13,14 @@ For a comprehensive list of available icons and their design specifications, ref
|
|
|
13
13
|
|
|
14
14
|
## Props
|
|
15
15
|
|
|
16
|
-
| Name | Type | Default | Description
|
|
17
|
-
| ---------- | ------ | ------- |
|
|
18
|
-
| colorTheme | string | 'dark' | The icon color, must be from the theme palette.
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
16
|
+
| Name | Type | Default | Description |
|
|
17
|
+
| ---------- | ------ | ------- | ------------------------------------------------------- |
|
|
18
|
+
| colorTheme | string | 'dark' | The icon color, must be from the theme palette. |
|
|
19
|
+
| fillTheme | string | | The internal fill color must be from the theme palette. |
|
|
20
|
+
| name | string | | The name of the icon from the Tabler Icons library. |
|
|
21
|
+
| shade | string | | The shade of the color theme to use. |
|
|
22
|
+
| size | number | | The size of the icon. |
|
|
23
|
+
| style | object | | Custom styles to apply to the icon. |
|
|
23
24
|
|
|
24
25
|
## Icon Names
|
|
25
26
|
|
|
@@ -39,6 +40,11 @@ Example:
|
|
|
39
40
|
|
|
40
41
|
Exceptions to these rules may exist.
|
|
41
42
|
|
|
43
|
+
###### Custom Widergy icons are now available.
|
|
44
|
+
|
|
45
|
+
The convection to use is: Energy + Icon + Name.
|
|
46
|
+
Example: EnergyIconDelivery
|
|
47
|
+
|
|
42
48
|
## Color Themes
|
|
43
49
|
|
|
44
50
|
The `colorTheme` prop must be one of these values:
|
|
@@ -72,6 +78,39 @@ For `gray`: `shade04`
|
|
|
72
78
|
For `light`: `shade01`
|
|
73
79
|
For all others: `shade05`
|
|
74
80
|
|
|
81
|
+
## Fill Theme (opcional)
|
|
82
|
+
|
|
83
|
+
The `fillTheme` prop could be one of these values:
|
|
84
|
+
|
|
85
|
+
- `accent`
|
|
86
|
+
- `dark`
|
|
87
|
+
- `error`
|
|
88
|
+
- `gray`
|
|
89
|
+
- `information`
|
|
90
|
+
- `light`
|
|
91
|
+
- `negative`
|
|
92
|
+
- `neutral`
|
|
93
|
+
- `success`
|
|
94
|
+
- `warning`
|
|
95
|
+
|
|
96
|
+
Clarifications:
|
|
97
|
+
|
|
98
|
+
- Note that not all icons look good with an internal fill color.
|
|
99
|
+
|
|
100
|
+
## Fill Shade (opcional)
|
|
101
|
+
|
|
102
|
+
The `fillShade` prop must be one of these:
|
|
103
|
+
|
|
104
|
+
- `01`
|
|
105
|
+
- `02`
|
|
106
|
+
- `03`
|
|
107
|
+
- `04`
|
|
108
|
+
- `05`
|
|
109
|
+
|
|
110
|
+
Clarifications:
|
|
111
|
+
|
|
112
|
+
- The default shade is '02' (if 'fillTheme' exists).
|
|
113
|
+
|
|
75
114
|
## Usage
|
|
76
115
|
|
|
77
116
|
```javascript
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<svg
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
3
|
+
width="24"
|
|
4
|
+
height="24"
|
|
5
|
+
viewBox="0 0 24 24"
|
|
6
|
+
fill="none"
|
|
7
|
+
stroke="currentColor"
|
|
8
|
+
stroke-width="1.5"
|
|
9
|
+
stroke-linecap="round"
|
|
10
|
+
stroke-linejoin="round"
|
|
11
|
+
class="icon icon-tabler icons-tabler-outline icon-tabler-car"
|
|
12
|
+
>
|
|
13
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
14
|
+
<path d="M5 17h-2v-6l2 -5h9l4 5h1a2 2 0 0 1 2 2v4h-2m-4 0h-6m-6 -6h15m-6 0v-5" />
|
|
15
|
+
<path d="M7 17m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
|
|
16
|
+
<path d="M17 17m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" />
|
|
17
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M4 19C4 19.5304 4.21071 20.0391 4.58579 20.4142C4.96086 20.7893 5.46957 21 6 21C6.53043 21 7.03914 20.7893 7.41421 20.4142C7.78929 20.0391 8 19.5304 8 19C8 18.4696 7.78929 17.9609 7.41421 17.5858C7.03914 17.2107 6.53043 17 6 17C5.46957 17 4.96086 17.2107 4.58579 17.5858C4.21071 17.9609 4 18.4696 4 19Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<path d="M15 19C15 19.5304 15.2107 20.0391 15.5858 20.4142C15.9609 20.7893 16.4696 21 17 21C17.5304 21 18.0391 20.7893 18.4142 20.4142C18.7893 20.0391 19 19.5304 19 19C19 18.4696 18.7893 17.9609 18.4142 17.5858C18.0391 17.2107 17.5304 17 17 17C16.4696 17 15.9609 17.2107 15.5858 17.5858C15.2107 17.9609 15 18.4696 15 19Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M6 5L20 6L19 13H6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M4 3H6V17H17" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M9.02 2.84016L3.63 7.04016C2.73 7.74016 2 9.23016 2 10.3602V17.7702C2 20.0902 3.89 21.9902 6.21 21.9902H17.79C20.11 21.9902 22 20.0902 22 17.7802V10.5002C22 9.29016 21.19 7.74016 20.2 7.05016L14.02 2.72016C12.62 1.74016 10.37 1.79016 9.02 2.84016Z" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<path d="M12 17.9902V14.9902V17.9902Z" />
|
|
4
|
+
<path d="M12 17.9902V14.9902" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg width="24" height="24" viewBox="0 0 64 64" fill="none" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M8 45.3333V13.3333H34.6667V16H48L56 29.3333V45.3333H52C49.8658 49.5691 48.3837 50.634 45.3333 50.6666C41.734 50.2423 40.547 49.0674 40 45.3333H24C23.6323 49.2151 22.3927 50.3076 18.6667 50.6666C14.9687 49.8222 13.6336 48.7628 13.3333 45.3333H8Z" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
<path d="M13.3333 45.3333C13.3333 46.7478 13.8952 48.1044 14.8954 49.1046C15.8956 50.1048 17.2522 50.6667 18.6667 50.6667C20.0812 50.6667 21.4377 50.1048 22.4379 49.1046C23.4381 48.1044 24 46.7478 24 45.3333C24 43.9188 23.4381 42.5623 22.4379 41.5621C21.4377 40.5619 20.0812 40 18.6667 40C17.2522 40 15.8956 40.5619 14.8954 41.5621C13.8952 42.5623 13.3333 43.9188 13.3333 45.3333Z" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
4
|
+
<path d="M40 45.3333C40 46.7478 40.5619 48.1044 41.5621 49.1046C42.5623 50.1048 43.9188 50.6667 45.3333 50.6667C46.7478 50.6667 48.1044 50.1048 49.1046 49.1046C50.1048 48.1044 50.6667 46.7478 50.6667 45.3333C50.6667 43.9188 50.1048 42.5623 49.1046 41.5621C48.1044 40.5619 46.7478 40 45.3333 40C43.9188 40 42.5623 40.5619 41.5621 41.5621C40.5619 42.5623 40 43.9188 40 45.3333Z" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<path d="M13.3333 45.3333H8V34.6666M5.33334 13.3333H34.6667V45.3333M24 45.3333H40M50.6667 45.3333H56V29.3333M56 29.3333H34.6667M56 29.3333L48 16H34.6667" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
6
|
+
<path d="M8 24H18.6667" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
|
7
|
+
</svg>
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import EnergyIconCar from './components/EnergyIcons/EnergyIconCar.svg';
|
|
2
|
+
import EnergyIconCart from './components/EnergyIcons/EnergyIconCart.svg';
|
|
3
|
+
import EnergyIconHome from './components/EnergyIcons/EnergyIconHome.svg';
|
|
4
|
+
import EnergyIconTruck from './components/EnergyIcons/EnergyIconTruck.svg';
|
|
5
|
+
|
|
1
6
|
export const SHADES = {
|
|
2
7
|
shade01: '01',
|
|
3
8
|
shade02: '02',
|
|
@@ -22,3 +27,12 @@ export const COLOR_THEMES = {
|
|
|
22
27
|
export const DEFAULT_PROPS = {
|
|
23
28
|
color: 'dark'
|
|
24
29
|
};
|
|
30
|
+
|
|
31
|
+
export const DEFAULT_INTERNAL_SHADE = SHADES.shade02;
|
|
32
|
+
|
|
33
|
+
export const ENERGY_ICONS = {
|
|
34
|
+
EnergyIconCar,
|
|
35
|
+
EnergyIconCart,
|
|
36
|
+
EnergyIconHome,
|
|
37
|
+
EnergyIconTruck
|
|
38
|
+
};
|
|
@@ -5,19 +5,28 @@ import * as TablerIcons from '@tabler/icons-react-native';
|
|
|
5
5
|
|
|
6
6
|
import { useTheme } from '../../theming';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { ENERGY_ICONS } from './constants';
|
|
9
|
+
import { getIconProps } from './utils';
|
|
9
10
|
|
|
10
|
-
const UTIcon = ({ color, colorTheme = 'dark', name, shade, size, style }) => {
|
|
11
|
+
const UTIcon = ({ color, colorTheme = 'dark', fillShade, fillTheme, name, shade, size, style }) => {
|
|
11
12
|
const theme = useTheme();
|
|
12
13
|
|
|
13
|
-
const IconComponent = TablerIcons[name];
|
|
14
|
+
const IconComponent = ENERGY_ICONS[name] || TablerIcons[name];
|
|
14
15
|
if (!IconComponent) return null;
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const iconProps = getIconProps({
|
|
18
|
+
color,
|
|
19
|
+
colorTheme,
|
|
20
|
+
fillShade,
|
|
21
|
+
fillTheme,
|
|
22
|
+
name,
|
|
23
|
+
shade,
|
|
24
|
+
size,
|
|
25
|
+
style,
|
|
26
|
+
theme
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return <IconComponent {...iconProps} />;
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
UTIcon.propTypes = {
|
|
@@ -26,6 +35,8 @@ UTIcon.propTypes = {
|
|
|
26
35
|
*/
|
|
27
36
|
color: string,
|
|
28
37
|
colorTheme: string,
|
|
38
|
+
fillShade: string,
|
|
39
|
+
fillTheme: string,
|
|
29
40
|
name: string,
|
|
30
41
|
shade: string,
|
|
31
42
|
size: number,
|
|
@@ -1 +1,35 @@
|
|
|
1
|
+
import { DEFAULT_INTERNAL_SHADE } from './constants';
|
|
2
|
+
import { retrieveColor } from './theme';
|
|
3
|
+
|
|
1
4
|
export const isUTIcon = icon => typeof icon === 'string';
|
|
5
|
+
|
|
6
|
+
export const getIconProps = ({
|
|
7
|
+
name,
|
|
8
|
+
theme,
|
|
9
|
+
color,
|
|
10
|
+
colorTheme,
|
|
11
|
+
shade,
|
|
12
|
+
fillTheme,
|
|
13
|
+
fillShade,
|
|
14
|
+
size,
|
|
15
|
+
style
|
|
16
|
+
}) => {
|
|
17
|
+
const themeColor = retrieveColor({ colorTheme: color || colorTheme, theme, shade });
|
|
18
|
+
const filled = name.endsWith('Filled');
|
|
19
|
+
const isEnergyIcon = name.startsWith('Energy');
|
|
20
|
+
const iconColor = filled ? 'transparent' : themeColor;
|
|
21
|
+
const internalFill =
|
|
22
|
+
fillTheme && retrieveColor({ colorTheme: fillTheme, theme, shade: fillShade || DEFAULT_INTERNAL_SHADE });
|
|
23
|
+
|
|
24
|
+
const defaultIconProps = { color: iconColor, size };
|
|
25
|
+
const energyIconProps = {
|
|
26
|
+
stroke: iconColor,
|
|
27
|
+
...(size && { width: size, height: size })
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
style: [filled && { color: themeColor }, style],
|
|
32
|
+
...(internalFill && { fill: internalFill }),
|
|
33
|
+
...(isEnergyIcon ? energyIconProps : defaultIconProps)
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -32,20 +32,20 @@ export const WEIGHTS = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const COLOR_THEMES = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
ACCENT: 'accent',
|
|
36
|
+
DARK: 'dark',
|
|
37
|
+
ERROR: 'error',
|
|
38
|
+
GRAY: 'gray',
|
|
39
|
+
INFORMATION: 'information',
|
|
40
|
+
LIGHT: 'light',
|
|
41
|
+
NEGATIVE: 'negative',
|
|
42
|
+
NEUTRAL: 'neutral',
|
|
43
|
+
SUCCESS: 'success',
|
|
44
|
+
WARNING: 'warning'
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
export const DEFAULT_PROPS = {
|
|
48
|
-
colorTheme:
|
|
48
|
+
colorTheme: COLOR_THEMES.DARK,
|
|
49
49
|
field: {},
|
|
50
50
|
style: {},
|
|
51
51
|
variant: 'body',
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { any, bool, func, number, objectOf, string } from 'prop-types';
|
|
3
2
|
import { Text } from 'react-native';
|
|
4
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
3
|
import Markdown from 'react-native-markdown-display';
|
|
6
4
|
|
|
7
5
|
import { useTheme } from '../../theming';
|
|
8
6
|
|
|
9
|
-
import { DEFAULT_PROPS } from './constants';
|
|
10
7
|
import { markdownFormat } from './utils';
|
|
11
8
|
import { retrieveStyle } from './theme';
|
|
9
|
+
import { defaultProps, propTypes } from './proptypes';
|
|
12
10
|
|
|
13
11
|
const UTLabel = ({
|
|
14
12
|
children,
|
|
@@ -44,19 +42,7 @@ const UTLabel = ({
|
|
|
44
42
|
);
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
UTLabel.defaultProps =
|
|
48
|
-
|
|
49
|
-
UTLabel.propTypes = {
|
|
50
|
-
colorTheme: string,
|
|
51
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
52
|
-
field: any,
|
|
53
|
-
markdownRenderers: objectOf(func),
|
|
54
|
-
numberOfLines: number,
|
|
55
|
-
shade: string,
|
|
56
|
-
style: ViewPropTypes.style,
|
|
57
|
-
variant: string,
|
|
58
|
-
weight: string,
|
|
59
|
-
withMarkdown: bool
|
|
60
|
-
};
|
|
45
|
+
UTLabel.defaultProps = defaultProps;
|
|
46
|
+
UTLabel.propTypes = propTypes;
|
|
61
47
|
|
|
62
48
|
export default UTLabel;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { any, bool, func, number, objectOf, string } from 'prop-types';
|
|
2
|
+
import { TextPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
|
+
|
|
4
|
+
import { DEFAULT_PROPS } from './constants';
|
|
5
|
+
|
|
6
|
+
export const propTypes = {
|
|
7
|
+
colorTheme: string,
|
|
8
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
9
|
+
field: any,
|
|
10
|
+
markdownRenderers: objectOf(func),
|
|
11
|
+
numberOfLines: number,
|
|
12
|
+
shade: string,
|
|
13
|
+
style: TextPropTypes.style,
|
|
14
|
+
variant: string,
|
|
15
|
+
weight: string,
|
|
16
|
+
withMarkdown: bool
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const defaultProps = DEFAULT_PROPS;
|
|
@@ -3,9 +3,9 @@ import { IS_IOS } from '../../utils/platformUtils/constants';
|
|
|
3
3
|
import { COLOR_THEMES, DEFAULT_PROPS, SHADES, VARIANTS_SIZES, WEIGHTS } from './constants';
|
|
4
4
|
|
|
5
5
|
const getDefaultColorShade = colorTheme =>
|
|
6
|
-
colorTheme === COLOR_THEMES.
|
|
6
|
+
colorTheme === COLOR_THEMES.GRAY
|
|
7
7
|
? SHADES.shade04
|
|
8
|
-
: colorTheme === COLOR_THEMES.
|
|
8
|
+
: colorTheme === COLOR_THEMES.LIGHT
|
|
9
9
|
? SHADES.shade01
|
|
10
10
|
: SHADES.shade05;
|
|
11
11
|
|
|
@@ -162,7 +162,7 @@ const UTMenu = ({
|
|
|
162
162
|
{withAutocomplete && (
|
|
163
163
|
<View style={[styles.searchContainer, propStyles?.searchContainer]}>
|
|
164
164
|
<UTTextInput
|
|
165
|
-
|
|
165
|
+
inputRef={searchTextInputRef}
|
|
166
166
|
onChange={handleQueryChange}
|
|
167
167
|
onSubmitEditing={
|
|
168
168
|
query && filteredOptions[0]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import propTypes from '../../../UTTextInput/versions/V1/proptypes';
|
|
3
|
+
import { propTypes, defaultProps } from '../../../UTTextInput/versions/V1/proptypes';
|
|
4
4
|
import UTTextInput from '../../../UTTextInput';
|
|
5
5
|
|
|
6
6
|
import { ICON_EYE, ICON_EYE_OFF, INPUT_TYPE } from './constants';
|
|
@@ -13,7 +13,7 @@ const UTPasswordField = props => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const action = {
|
|
16
|
-
|
|
16
|
+
Icon: isPasswordVisible ? ICON_EYE : ICON_EYE_OFF,
|
|
17
17
|
onPress: toggleVisibility
|
|
18
18
|
};
|
|
19
19
|
|
|
@@ -27,6 +27,7 @@ const UTPasswordField = props => {
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
UTPasswordField.defaultProps = defaultProps;
|
|
30
31
|
UTPasswordField.propTypes = propTypes;
|
|
31
32
|
|
|
32
33
|
export default UTPasswordField;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# UTSearchField
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTSearchField` is a customizable search field component that includes a search icon on the left and an optional clear button on the right.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
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`. |
|
|
22
|
+
|
|
23
|
+
## Example
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import React, { useState } from 'react';
|
|
27
|
+
import { View, Text } from 'react-native';
|
|
28
|
+
import UTSearchField from './UTSearchField';
|
|
29
|
+
|
|
30
|
+
const UTSearchFieldExample = () => {
|
|
31
|
+
const [searchValue, setSearchValue] = useState('');
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View style={{ padding: 20 }}>
|
|
35
|
+
<UTSearchField placeholder="Search..." value={searchValue} onChange={setSearchValue} />
|
|
36
|
+
<Text>Search Value: {searchValue}</Text>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default UTSearchFieldExample;
|
|
42
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { COMPONENT_KEYS } from '../UTBaseInputField/constants';
|
|
4
|
+
import UTBaseInputField from '../UTBaseInputField';
|
|
5
|
+
|
|
6
|
+
import { defaultProps, propTypes } from './proptypes';
|
|
7
|
+
|
|
8
|
+
const UTSearchField = ({
|
|
9
|
+
disabled,
|
|
10
|
+
input,
|
|
11
|
+
inputRef,
|
|
12
|
+
onBlur,
|
|
13
|
+
onFocus,
|
|
14
|
+
onSubmitEditing,
|
|
15
|
+
placeholder,
|
|
16
|
+
returnKeyType,
|
|
17
|
+
size,
|
|
18
|
+
style,
|
|
19
|
+
type,
|
|
20
|
+
variant
|
|
21
|
+
}) => {
|
|
22
|
+
const clearText = () => {
|
|
23
|
+
input.onChange('');
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const action = { Icon: 'IconX', onPress: clearText, size: 'small' };
|
|
27
|
+
|
|
28
|
+
const leftAdornments = [
|
|
29
|
+
{ name: COMPONENT_KEYS.ICON, props: { Icon: 'IconSearch', changeOnFocus: true, shade: '02' } }
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const rightAdornments = input.value ? [{ name: COMPONENT_KEYS.ACTION, props: { action } }] : [];
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<UTBaseInputField
|
|
36
|
+
alwaysShowPlaceholder
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
input={input}
|
|
39
|
+
inputSize={size}
|
|
40
|
+
leftAdornments={leftAdornments}
|
|
41
|
+
onBlur={onBlur}
|
|
42
|
+
onFocus={onFocus}
|
|
43
|
+
onSubmitEditing={onSubmitEditing}
|
|
44
|
+
placeholder={placeholder}
|
|
45
|
+
ref={inputRef}
|
|
46
|
+
returnKeyType={returnKeyType}
|
|
47
|
+
rightAdornments={rightAdornments}
|
|
48
|
+
style={{ container: style }}
|
|
49
|
+
type={type}
|
|
50
|
+
variant={variant}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
UTSearchField.defaultProps = defaultProps;
|
|
56
|
+
|
|
57
|
+
UTSearchField.propTypes = propTypes;
|
|
58
|
+
|
|
59
|
+
export default UTSearchField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { func, oneOf, string, object, shape, instanceOf, oneOfType } from 'prop-types';
|
|
2
|
+
|
|
3
|
+
import { SIZES, VARIANT } from '../UTBaseInputField/constants';
|
|
4
|
+
|
|
5
|
+
export const defaultProps = {
|
|
6
|
+
input: {
|
|
7
|
+
value: [],
|
|
8
|
+
onChange: () => {}
|
|
9
|
+
},
|
|
10
|
+
variant: VARIANT.WHITE
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const propTypes = {
|
|
14
|
+
input: shape({
|
|
15
|
+
value: string,
|
|
16
|
+
onChange: func
|
|
17
|
+
}),
|
|
18
|
+
inputRef: oneOfType([func, instanceOf(Object)]),
|
|
19
|
+
onBlur: func,
|
|
20
|
+
onFocus: func,
|
|
21
|
+
onSubmitEditing: func,
|
|
22
|
+
placeholder: string,
|
|
23
|
+
returnKeyType: string,
|
|
24
|
+
size: oneOf(Object.values(SIZES)),
|
|
25
|
+
style: object,
|
|
26
|
+
type: string,
|
|
27
|
+
variant: oneOf(Object.values(VARIANT))
|
|
28
|
+
};
|
|
@@ -1,103 +1,16 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { View } from 'react-native';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { string } from 'prop-types';
|
|
4
3
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import UTTextInput from '../UTTextInput';
|
|
4
|
+
import V0 from './versions/V0';
|
|
5
|
+
import V1 from './versions/V1';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const UTSelect = ({
|
|
14
|
-
options = [],
|
|
15
|
-
value,
|
|
16
|
-
onChange,
|
|
17
|
-
error,
|
|
18
|
-
UTMenuProps,
|
|
19
|
-
label,
|
|
20
|
-
styles: propStyles,
|
|
21
|
-
variant,
|
|
22
|
-
disabled,
|
|
23
|
-
UTTextInputProps,
|
|
24
|
-
isMultiple,
|
|
25
|
-
verticalOffset = 5,
|
|
26
|
-
title,
|
|
27
|
-
titleProps,
|
|
28
|
-
changeOnClose
|
|
29
|
-
}) => {
|
|
30
|
-
const [focused, setFocused] = useState(false);
|
|
31
|
-
|
|
32
|
-
const selectedOption = useMemo(
|
|
33
|
-
() => (!isMultiple ? options.find(option => option.value === value) : value || []),
|
|
34
|
-
[isMultiple, options, value]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const handleChange = option => {
|
|
38
|
-
if (!changeOnClose) onChange(option.value);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleChangeMultiple = newValue => {
|
|
42
|
-
const newValues = !selectedOption?.find?.(elem => elem === newValue.value)
|
|
43
|
-
? [...(selectedOption || []), newValue.value]
|
|
44
|
-
: selectedOption?.filter(elem => elem !== newValue.value);
|
|
45
|
-
|
|
46
|
-
const finalValue = isEmpty(newValues) ? null : newValues;
|
|
47
|
-
if (!changeOnClose) {
|
|
48
|
-
onChange(finalValue);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const handleOpen = () => setFocused(true);
|
|
53
|
-
// eslint-disable-next-line consistent-return
|
|
54
|
-
const handleClose = () => {
|
|
55
|
-
setFocused(false);
|
|
56
|
-
if (changeOnClose) {
|
|
57
|
-
return isMultiple
|
|
58
|
-
? onChange(selectedOption)
|
|
59
|
-
: onChange(options.find(_option => _option.id === selectedOption.id).value);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<View style={[styles.container, propStyles]}>
|
|
65
|
-
{title && (
|
|
66
|
-
<Label medium primary {...titleProps}>
|
|
67
|
-
{title}
|
|
68
|
-
</Label>
|
|
69
|
-
)}
|
|
70
|
-
<UTMenu
|
|
71
|
-
options={options}
|
|
72
|
-
selectedOption={isMultiple ? selectedOption : selectedOption?.id}
|
|
73
|
-
fullWidth
|
|
74
|
-
verticalOffset={verticalOffset}
|
|
75
|
-
disabled={disabled}
|
|
76
|
-
onPress={isMultiple ? handleChangeMultiple : handleChange}
|
|
77
|
-
onOpen={handleOpen}
|
|
78
|
-
onClose={handleClose}
|
|
79
|
-
withoutOpacity
|
|
80
|
-
MenuOptionComponent={isMultiple && MultipleItem}
|
|
81
|
-
isMultiple={isMultiple}
|
|
82
|
-
{...UTMenuProps}
|
|
83
|
-
>
|
|
84
|
-
<UTTextInput
|
|
85
|
-
variant={variant}
|
|
86
|
-
value={isMultiple ? value?.join(', ') || '' : selectedOption?.label || selectedOption?.value || ''}
|
|
87
|
-
error={error}
|
|
88
|
-
label={label}
|
|
89
|
-
select
|
|
90
|
-
controlledFocus={focused}
|
|
91
|
-
disabled={disabled}
|
|
92
|
-
version="V0"
|
|
93
|
-
RightIcon={{ type: 'font-awesome', name: 'caret-down' }}
|
|
94
|
-
{...UTTextInputProps}
|
|
95
|
-
/>
|
|
96
|
-
</UTMenu>
|
|
97
|
-
</View>
|
|
98
|
-
);
|
|
7
|
+
const UTSelect = ({ version = 'V0', ...props }) => {
|
|
8
|
+
const Component = { V0, V1 }[version];
|
|
9
|
+
return <Component {...props} />;
|
|
99
10
|
};
|
|
100
11
|
|
|
101
|
-
UTSelect.propTypes =
|
|
12
|
+
UTSelect.propTypes = {
|
|
13
|
+
version: string
|
|
14
|
+
};
|
|
102
15
|
|
|
103
16
|
export default UTSelect;
|