@widergy/mobile-ui 1.13.3 → 1.13.5
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 +4 -0
- package/lib/components/Icon/index.js +4 -0
- package/lib/components/IconButton/index.js +4 -0
- package/lib/components/Label/index.js +4 -0
- package/lib/components/UTCheckBox/README.md +66 -0
- package/lib/components/UTCheckBox/constants.js +2 -0
- package/lib/components/UTCheckBox/index.js +45 -0
- package/lib/components/UTCheckBox/proptypes.js +21 -0
- package/lib/components/UTCheckBox/theme.js +72 -0
- package/lib/components/UTCheckList/README.MD +101 -0
- package/lib/components/UTCheckList/index.js +150 -0
- package/lib/components/UTCheckList/styles.js +23 -0
- package/lib/components/UTCheckList/utils.js +4 -0
- package/lib/components/UTLoading/components/Spinner/styles.js +3 -0
- package/lib/components/UTRequiredLabel/constants.js +1 -0
- package/lib/components/UTRequiredLabel/index.js +31 -0
- package/lib/components/UTRequiredLabel/styles.js +7 -0
- package/lib/components/UTTextInput/versions/V0/components/BaseInput/index.js +13 -5
- package/lib/components/UTTextInput/versions/V1/constants.js +0 -2
- package/lib/components/UTTextInput/versions/V1/index.js +5 -11
- package/lib/components/UTTextInput/versions/V1/styles.js +0 -3
- package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/index.js +5 -3
- package/lib/index.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.13.5](https://github.com/widergy/mobile-ui/compare/v1.13.4...v1.13.5) (2024-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* next button color ([7934791](https://github.com/widergy/mobile-ui/commit/79347911efb36f70c4a7055e85237d3c0a7ca2a5))
|
|
7
|
+
|
|
8
|
+
## [1.13.4](https://github.com/widergy/mobile-ui/compare/v1.13.3...v1.13.4) (2024-07-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add UTCheckBox and UTCheckList ([#304](https://github.com/widergy/mobile-ui/issues/304)) ([edf9c95](https://github.com/widergy/mobile-ui/commit/edf9c95122a765b41e3b8f1031f6c8a34b8e8085))
|
|
14
|
+
|
|
1
15
|
## [1.13.3](https://github.com/widergy/mobile-ui/compare/v1.13.2...v1.13.3) (2024-07-17)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -105,4 +105,8 @@ Button.displayName = 'Button';
|
|
|
105
105
|
|
|
106
106
|
Button.propTypes = propTypes;
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated The Button component is deprecated and will be removed in a future release.
|
|
110
|
+
* Please use the UTButton component instead.
|
|
111
|
+
*/
|
|
108
112
|
export default withTheme(Button);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# UTCheckBox
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTCheckBox` is a checkbox component used within the `UTCheckList` component. It supports various states such as checked, indeterminate, and disabled, and can be customized with labels and styles.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Name | Type | Default | Description |
|
|
10
|
+
| ------------- | ------------ | ------- | ------------------------------------------------------- |
|
|
11
|
+
| checked | bool | false | Indicates if the checkbox is checked. |
|
|
12
|
+
| disabled | bool | false | Disables the checkbox, making it unclickable. |
|
|
13
|
+
| indeterminate | bool | false | Indicates if the checkbox is in an indeterminate state. |
|
|
14
|
+
| label | string | | Label to display next to the checkbox. |
|
|
15
|
+
| onPress | func | | Function to call when the checkbox is pressed. |
|
|
16
|
+
| reversed | bool | false | If true, reverses the order of label and checkbox. |
|
|
17
|
+
| style | shape | {} | Custom styles to apply to the checkbox. Can contain `root`, `icon`, `touchable`. |
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Basic Example
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import React from 'react';
|
|
25
|
+
import UTCheckBox from './UTCheckBox';
|
|
26
|
+
|
|
27
|
+
const Example = () => {
|
|
28
|
+
const [checked, setChecked] = React.useState(false);
|
|
29
|
+
|
|
30
|
+
return <UTCheckBox checked={checked} label="Check me" onPress={() => setChecked(!checked)} />;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default Example;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Custom Styles Example
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import UTCheckBox from './UTCheckBox';
|
|
41
|
+
|
|
42
|
+
const customStyles = {
|
|
43
|
+
root: { padding: 10 },
|
|
44
|
+
icon: { backgroundColor: 'lightgrey' },
|
|
45
|
+
touchable: {
|
|
46
|
+
root: { margin: 5 },
|
|
47
|
+
pressed: { opacity: 0.5 }
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const Example = () => {
|
|
52
|
+
const [checked, setChecked] = React.useState(false);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<UTCheckBox
|
|
56
|
+
checked={checked}
|
|
57
|
+
label="Check me"
|
|
58
|
+
onPress={() => setChecked(!checked)}
|
|
59
|
+
style={customStyles}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default Example;
|
|
65
|
+
|
|
66
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View, Pressable } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme } from '../../theming';
|
|
5
|
+
import UTIcon from '../UTIcon';
|
|
6
|
+
import UTLabel from '../UTLabel';
|
|
7
|
+
|
|
8
|
+
import { CHECKED_ICON, INDETERMINATE_ICON } from './constants';
|
|
9
|
+
import { retrieveStyle } from './theme';
|
|
10
|
+
import propTypes from './proptypes';
|
|
11
|
+
|
|
12
|
+
const UTCheckBox = ({ checked, disabled, indeterminate, label, onPress, reversed, style }) => {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const { containerStyles, iconContainerStyles, touchableStyles } = retrieveStyle({
|
|
15
|
+
checked,
|
|
16
|
+
disabled,
|
|
17
|
+
indeterminate,
|
|
18
|
+
reversed,
|
|
19
|
+
style,
|
|
20
|
+
theme
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const combinedTouchableStyles = ({ pressed }) => [touchableStyles.root, pressed && touchableStyles.pressed];
|
|
24
|
+
|
|
25
|
+
const iconName = indeterminate ? INDETERMINATE_ICON : checked ? CHECKED_ICON : '';
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View style={containerStyles}>
|
|
29
|
+
<Pressable disabled={disabled} onPress={onPress} style={combinedTouchableStyles}>
|
|
30
|
+
<View style={iconContainerStyles}>
|
|
31
|
+
<UTIcon color="light" name={iconName} size={16} />
|
|
32
|
+
</View>
|
|
33
|
+
</Pressable>
|
|
34
|
+
<UTLabel>{label}</UTLabel>
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
UTCheckBox.defaultProps = {
|
|
40
|
+
style: {}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
UTCheckBox.propTypes = propTypes;
|
|
44
|
+
|
|
45
|
+
export default UTCheckBox;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { bool, func, shape, string } from 'prop-types';
|
|
2
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
3
|
+
|
|
4
|
+
export const styleProptypes = shape({
|
|
5
|
+
root: ViewPropTypes.style,
|
|
6
|
+
icon: ViewPropTypes.style,
|
|
7
|
+
touchable: shape({
|
|
8
|
+
root: ViewPropTypes.style,
|
|
9
|
+
pressed: ViewPropTypes.style
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
checked: bool,
|
|
15
|
+
disabled: bool,
|
|
16
|
+
indeterminate: bool,
|
|
17
|
+
label: string,
|
|
18
|
+
onPress: func,
|
|
19
|
+
reversed: bool,
|
|
20
|
+
style: styleProptypes
|
|
21
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const baseCheckBoxTheme = theme => ({
|
|
2
|
+
container: {
|
|
3
|
+
alignItems: 'center',
|
|
4
|
+
columnGap: 16,
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
justifyContent: 'flex-start'
|
|
7
|
+
},
|
|
8
|
+
iconContainer: {
|
|
9
|
+
borderColor: theme.Palette.gray['04'],
|
|
10
|
+
borderRadius: 5,
|
|
11
|
+
borderWidth: 2,
|
|
12
|
+
height: 20,
|
|
13
|
+
width: 20
|
|
14
|
+
},
|
|
15
|
+
touchable: {
|
|
16
|
+
root: {
|
|
17
|
+
borderRadius: 25,
|
|
18
|
+
padding: 6
|
|
19
|
+
},
|
|
20
|
+
pressed: {
|
|
21
|
+
backgroundColor: theme.Palette.accent['02'],
|
|
22
|
+
borderColor: theme.Palette.accent['03'],
|
|
23
|
+
borderWidth: 1,
|
|
24
|
+
padding: 5
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const conditionalContainerStyle = (reversed, disabled) => ({
|
|
30
|
+
...(reversed && {
|
|
31
|
+
flexDirection: 'row-reverse'
|
|
32
|
+
}),
|
|
33
|
+
...(disabled && {
|
|
34
|
+
opacity: 0.5
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const conditionalIconContainerStyle = (checked, indeterminate, theme) => ({
|
|
39
|
+
...((checked || indeterminate) && {
|
|
40
|
+
backgroundColor: theme.Palette.accent['04'],
|
|
41
|
+
borderColor: theme.Palette.accent['04']
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const retrieveStyle = ({ checked, disabled, indeterminate, reversed, style = {}, theme }) => {
|
|
46
|
+
const baseTheme = baseCheckBoxTheme(theme);
|
|
47
|
+
|
|
48
|
+
const containerStyles = {
|
|
49
|
+
...baseTheme.container,
|
|
50
|
+
...conditionalContainerStyle(reversed, disabled),
|
|
51
|
+
...style.root
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const iconContainerStyles = {
|
|
55
|
+
...baseTheme.iconContainer,
|
|
56
|
+
...conditionalIconContainerStyle(checked, indeterminate, theme),
|
|
57
|
+
...style.icon
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const touchableStyles = {
|
|
61
|
+
root: {
|
|
62
|
+
...baseTheme.touchable.root,
|
|
63
|
+
...style.touchable?.root
|
|
64
|
+
},
|
|
65
|
+
pressed: {
|
|
66
|
+
...baseTheme.touchable.pressed,
|
|
67
|
+
...style.touchable?.pressed
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return { containerStyles, iconContainerStyles, touchableStyles };
|
|
72
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# UTCheckList
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`UTCheckList` is a customizable component that renders a list of checkboxes, allowing users to select multiple options from a provided list. It supports features like select all, indeterminate state, error display, and dynamic options. The "Select All" checkbox only affects options that are not disabled.
|
|
6
|
+
|
|
7
|
+
## Props
|
|
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
|
+
| style | shape | {} | Custom styles to apply to the checklist. Can contain `root`, `header`, `checkboxesContainer`, `item`, and `selectAll`. |
|
|
19
|
+
|
|
20
|
+
### Input Object
|
|
21
|
+
|
|
22
|
+
The `input` prop is an object that should contain the following keys:
|
|
23
|
+
|
|
24
|
+
| Name | Type | Description |
|
|
25
|
+
| -------- | --------------- | -------------------------------------------- |
|
|
26
|
+
| value | arrayOf(string) | Array of selected values. |
|
|
27
|
+
| onChange | func | Function to call when the selection changes. |
|
|
28
|
+
|
|
29
|
+
### Option Object
|
|
30
|
+
|
|
31
|
+
The `options` prop is an array of objects, each representing an option:
|
|
32
|
+
|
|
33
|
+
| Name | Type | Description |
|
|
34
|
+
| -------- | ------ | ------------------------------------ |
|
|
35
|
+
| checked | bool | Indicates if the option is checked. |
|
|
36
|
+
| disabled | bool | Indicates if the option is disabled. |
|
|
37
|
+
| label | string | Label to display for the option. |
|
|
38
|
+
| value | string | Value of the option. |
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
### Basic Example
|
|
43
|
+
|
|
44
|
+
```jsx
|
|
45
|
+
import React from 'react';
|
|
46
|
+
import UTCheckList from './UTCheckList';
|
|
47
|
+
|
|
48
|
+
const options = [
|
|
49
|
+
{ label: 'Option 1', value: '1' },
|
|
50
|
+
{ label: 'Option 2', value: '2' },
|
|
51
|
+
{ label: 'Option 3', value: '3', disabled: true, checked: true }
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const Example = () => {
|
|
55
|
+
const [selectedOptions, setSelectedOptions] = React.useState([]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<UTCheckList
|
|
59
|
+
label="Select Options"
|
|
60
|
+
options={options}
|
|
61
|
+
input={{
|
|
62
|
+
value: selectedOptions,
|
|
63
|
+
onChange: setSelectedOptions
|
|
64
|
+
}}
|
|
65
|
+
selectAllLabel="Select All"
|
|
66
|
+
required
|
|
67
|
+
error="Please select at least one option"
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default Example;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Custom Styles Example
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
import React from 'react';
|
|
79
|
+
import UTCheckBox from './UTCheckBox';
|
|
80
|
+
|
|
81
|
+
const customStyles = {
|
|
82
|
+
root: { padding: 10 },
|
|
83
|
+
iconContainer: { backgroundColor: 'lightgrey' },
|
|
84
|
+
label: { color: 'blue' }
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const Example = () => {
|
|
88
|
+
const [checked, setChecked] = React.useState(false);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<UTCheckBox
|
|
92
|
+
checked={checked}
|
|
93
|
+
label="Check me"
|
|
94
|
+
onPress={() => setChecked(!checked)}
|
|
95
|
+
style={customStyles}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export default Example;
|
|
101
|
+
```
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useEffect, useCallback, useMemo, Fragment } from 'react';
|
|
2
|
+
import { arrayOf, bool, func, shape, string } from 'prop-types';
|
|
3
|
+
import { isEmpty } from '@widergy/web-utils/lib/array';
|
|
4
|
+
import { isString } from 'lodash';
|
|
5
|
+
import { View } from 'react-native';
|
|
6
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
7
|
+
|
|
8
|
+
import { styleProptypes as checboxStyleProptypes } from '../UTCheckBox/proptypes';
|
|
9
|
+
import UTCheckBox from '../UTCheckBox';
|
|
10
|
+
import UTLabel from '../UTLabel';
|
|
11
|
+
import UTRequiredLabel from '../UTRequiredLabel';
|
|
12
|
+
|
|
13
|
+
import { keyExtractor, isChecked } from './utils';
|
|
14
|
+
import styles from './styles';
|
|
15
|
+
|
|
16
|
+
const UTCheckList = ({
|
|
17
|
+
error,
|
|
18
|
+
input,
|
|
19
|
+
label,
|
|
20
|
+
options,
|
|
21
|
+
required,
|
|
22
|
+
reversed,
|
|
23
|
+
selectAllLabel,
|
|
24
|
+
showSelectAll,
|
|
25
|
+
style
|
|
26
|
+
}) => {
|
|
27
|
+
const convertIfIsString = value =>
|
|
28
|
+
isString(value) ? (value.length === 0 ? [] : JSON.parse(value.replace(/'/g, '"'))) : value;
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const convertedValue = convertIfIsString(input.value);
|
|
32
|
+
if (JSON.stringify(convertedValue) !== JSON.stringify(input.value)) {
|
|
33
|
+
input.onChange(convertedValue);
|
|
34
|
+
}
|
|
35
|
+
}, [input.value, input]);
|
|
36
|
+
|
|
37
|
+
const enabledOptions = useMemo(() => options.filter(option => !option.disabled), [options]);
|
|
38
|
+
|
|
39
|
+
const areAllSelected = useMemo(
|
|
40
|
+
() => enabledOptions.every(option => input.value?.includes(option.value)),
|
|
41
|
+
[enabledOptions, input.value]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const isIndeterminate = useMemo(
|
|
45
|
+
() => enabledOptions.some(option => input.value?.includes(option.value)) && !areAllSelected,
|
|
46
|
+
[enabledOptions, input.value, areAllSelected]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const handleChange = useCallback(
|
|
50
|
+
receivedValue => () => {
|
|
51
|
+
const { onChange, value } = input;
|
|
52
|
+
const newValues = !value?.find?.(elem => elem === receivedValue)
|
|
53
|
+
? [...(value || []), receivedValue]
|
|
54
|
+
: value?.filter(elem => elem !== receivedValue);
|
|
55
|
+
if (onChange) onChange(isEmpty(newValues) ? [] : newValues);
|
|
56
|
+
},
|
|
57
|
+
[input]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const handleCheckAll = () => {
|
|
61
|
+
if (!areAllSelected && options) {
|
|
62
|
+
input.onChange(enabledOptions.map(item => item.value));
|
|
63
|
+
} else {
|
|
64
|
+
input.onChange([]);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<View style={[styles.container, style.root]}>
|
|
70
|
+
<View style={[styles.headerContainer, style.header]}>
|
|
71
|
+
{label && <UTRequiredLabel required={required}>{label}</UTRequiredLabel>}
|
|
72
|
+
{error && (
|
|
73
|
+
<UTLabel colorTheme="error" variant="small">
|
|
74
|
+
{error}
|
|
75
|
+
</UTLabel>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
<View
|
|
79
|
+
style={[
|
|
80
|
+
styles.checkboxesContainer,
|
|
81
|
+
reversed && styles.reversedCheckBoxesContainer,
|
|
82
|
+
style.checkboxesContainer
|
|
83
|
+
]}
|
|
84
|
+
>
|
|
85
|
+
{showSelectAll && (
|
|
86
|
+
<UTCheckBox
|
|
87
|
+
checked={areAllSelected}
|
|
88
|
+
indeterminate={isIndeterminate}
|
|
89
|
+
label={selectAllLabel}
|
|
90
|
+
onPress={handleCheckAll}
|
|
91
|
+
reversed={reversed}
|
|
92
|
+
style={style.selectAll}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
{!!options?.length &&
|
|
96
|
+
options.map((item, index) => {
|
|
97
|
+
const { label: itemLabel, disabled, value } = item;
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Fragment key={keyExtractor(item, index)}>
|
|
101
|
+
<UTCheckBox
|
|
102
|
+
checked={isChecked(item, input.value)}
|
|
103
|
+
disabled={disabled}
|
|
104
|
+
label={itemLabel}
|
|
105
|
+
onPress={handleChange(value)}
|
|
106
|
+
reversed={reversed}
|
|
107
|
+
style={style.item}
|
|
108
|
+
/>
|
|
109
|
+
</Fragment>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
112
|
+
</View>
|
|
113
|
+
</View>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
UTCheckList.defaultProps = {
|
|
118
|
+
showSelectAll: true,
|
|
119
|
+
style: {}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
UTCheckList.propTypes = {
|
|
123
|
+
error: string,
|
|
124
|
+
label: string,
|
|
125
|
+
input: shape({
|
|
126
|
+
value: arrayOf(string),
|
|
127
|
+
onChange: func
|
|
128
|
+
}),
|
|
129
|
+
options: arrayOf(
|
|
130
|
+
shape({
|
|
131
|
+
checked: bool,
|
|
132
|
+
disabled: bool,
|
|
133
|
+
label: string,
|
|
134
|
+
value: string
|
|
135
|
+
})
|
|
136
|
+
),
|
|
137
|
+
required: bool,
|
|
138
|
+
reversed: bool,
|
|
139
|
+
selectAllLabel: string,
|
|
140
|
+
showSelectAll: bool,
|
|
141
|
+
style: shape({
|
|
142
|
+
checkboxesContainer: ViewPropTypes.style,
|
|
143
|
+
header: ViewPropTypes.style,
|
|
144
|
+
item: checboxStyleProptypes,
|
|
145
|
+
root: ViewPropTypes.style,
|
|
146
|
+
selectAll: ViewPropTypes.style
|
|
147
|
+
})
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default UTCheckList;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
checkboxesContainer: {
|
|
5
|
+
rowGap: 16
|
|
6
|
+
},
|
|
7
|
+
container: {
|
|
8
|
+
rowGap: 16,
|
|
9
|
+
flexGrow: 1
|
|
10
|
+
},
|
|
11
|
+
headerContainer: {
|
|
12
|
+
rowGap: 8
|
|
13
|
+
},
|
|
14
|
+
itemSeparator: {
|
|
15
|
+
height: 16
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
flexDirection: 'row'
|
|
19
|
+
},
|
|
20
|
+
reversedCheckBoxesContainer: {
|
|
21
|
+
alignItems: 'flex-end'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const REQUIRED_LABEL = ' *';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { bool, string } from 'prop-types';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
|
|
5
|
+
import UTLabel from '../UTLabel';
|
|
6
|
+
|
|
7
|
+
import { REQUIRED_LABEL } from './constants';
|
|
8
|
+
import styles from './styles';
|
|
9
|
+
|
|
10
|
+
const UTRequiredLabel = ({ children, colorTheme, required, variant }) => {
|
|
11
|
+
return (
|
|
12
|
+
<View style={styles.label}>
|
|
13
|
+
<UTLabel colorTheme={colorTheme} variant={variant}>
|
|
14
|
+
{children}
|
|
15
|
+
</UTLabel>
|
|
16
|
+
{required && (
|
|
17
|
+
<UTLabel colorTheme="error" shade="04" variant={variant}>
|
|
18
|
+
{REQUIRED_LABEL}
|
|
19
|
+
</UTLabel>
|
|
20
|
+
)}
|
|
21
|
+
</View>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
UTRequiredLabel.propTypes = {
|
|
26
|
+
colorTheme: string,
|
|
27
|
+
required: bool,
|
|
28
|
+
variant: string
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default UTRequiredLabel;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
useRef,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
Fragment
|
|
9
|
+
} from 'react';
|
|
10
|
+
import _ from 'lodash';
|
|
1
11
|
import { bool, elementType, func, oneOf, shape, string } from 'prop-types';
|
|
2
|
-
import React, { useState, forwardRef, useImperativeHandle, useRef, useEffect, useMemo } from 'react';
|
|
3
|
-
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
4
12
|
import { TextInput } from 'react-native';
|
|
5
|
-
import
|
|
13
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
6
14
|
|
|
7
15
|
import { withTheme } from '../../../../../../theming';
|
|
8
16
|
import Icon from '../../../../../Icon';
|
|
@@ -70,7 +78,7 @@ const BaseInput = forwardRef(
|
|
|
70
78
|
: {};
|
|
71
79
|
|
|
72
80
|
return (
|
|
73
|
-
|
|
81
|
+
<Fragment>
|
|
74
82
|
<TextInput
|
|
75
83
|
autoCorrect={false}
|
|
76
84
|
ref={textInputRef}
|
|
@@ -108,7 +116,7 @@ const BaseInput = forwardRef(
|
|
|
108
116
|
)}
|
|
109
117
|
</Touchable>
|
|
110
118
|
)}
|
|
111
|
-
|
|
119
|
+
</Fragment>
|
|
112
120
|
);
|
|
113
121
|
}
|
|
114
122
|
);
|
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import UTLabel from '../../../UTLabel';
|
|
5
|
+
import UTRequiredLabel from '../../../UTRequiredLabel';
|
|
5
6
|
import UTValidation from '../../../UTValidation';
|
|
6
7
|
|
|
7
|
-
import { DEFAULT_PROPS,
|
|
8
|
+
import { DEFAULT_PROPS, SMALL } from './constants';
|
|
8
9
|
import { formatErrorToValidation } from './utils';
|
|
9
10
|
import propTypes from './proptypes';
|
|
10
11
|
import styles from './styles';
|
|
@@ -47,16 +48,9 @@ const UTTextInput = ({
|
|
|
47
48
|
return (
|
|
48
49
|
<View style={[styles.container, style.root]}>
|
|
49
50
|
{label && (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</UTLabel>
|
|
54
|
-
{required && (
|
|
55
|
-
<UTLabel colorTheme="error" shade="04" variant={labelComponentVariant}>
|
|
56
|
-
{REQUIRED_LABEL}
|
|
57
|
-
</UTLabel>
|
|
58
|
-
)}
|
|
59
|
-
</View>
|
|
51
|
+
<UTRequiredLabel colorTheme={labelColorTheme} required={required} variant={labelComponentVariant}>
|
|
52
|
+
{label}
|
|
53
|
+
</UTRequiredLabel>
|
|
60
54
|
)}
|
|
61
55
|
<TextInputField
|
|
62
56
|
action={action}
|
|
@@ -8,13 +8,14 @@ import { useTheme } from '../../../../../../../../theming';
|
|
|
8
8
|
|
|
9
9
|
import ownStyles from './styles';
|
|
10
10
|
|
|
11
|
-
const ActionButton = ({
|
|
11
|
+
const ActionButton = ({ colorTheme, disabled, hidden, label, onPress, style, variant }) => {
|
|
12
12
|
const theme = useTheme();
|
|
13
13
|
const themedStyles = merge({}, ownStyles, theme?.UTWorkflowContainer?.actionButton, style);
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<View style={themedStyles.actionButton}>
|
|
17
17
|
<UTButton
|
|
18
|
+
colorTheme={colorTheme}
|
|
18
19
|
disabled={disabled || hidden}
|
|
19
20
|
onPress={onPress}
|
|
20
21
|
size="large"
|
|
@@ -28,11 +29,12 @@ const ActionButton = ({ hidden, disabled, onPress, label, variant, style }) => {
|
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
ActionButton.propTypes = {
|
|
32
|
+
colorTheme: string,
|
|
31
33
|
disabled: bool,
|
|
32
34
|
hidden: bool,
|
|
33
35
|
label: string,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
onPress: func,
|
|
37
|
+
variant: string
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export default ActionButton;
|
package/lib/index.js
CHANGED
|
@@ -27,6 +27,8 @@ export { default as ImageLabel } from './components/ImageLabel';
|
|
|
27
27
|
export { default as CheckList } from './components/CheckList';
|
|
28
28
|
export { default as UTCBUInput } from './components/UTCBUInput';
|
|
29
29
|
export { default as UTPasswordField } from './components/UTPasswordField';
|
|
30
|
+
export { default as UTCheckList } from './components/UTCheckList';
|
|
31
|
+
export { default as UTCheckBox } from './components/UTCheckBox';
|
|
30
32
|
|
|
31
33
|
// Icons
|
|
32
34
|
export { default as Icon } from './components/Icon';
|
package/package.json
CHANGED