@widergy/mobile-ui 1.27.0 → 1.28.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/CheckList/index.js +4 -0
  3. package/lib/components/Checkbox/index.js +4 -0
  4. package/lib/components/MultipleFilePicker/components/Picker/index.js +66 -74
  5. package/lib/components/MultipleFilePicker/components/Picker/styles.js +26 -34
  6. package/lib/components/MultipleFilePicker/components/UploadedFiles/index.js +27 -129
  7. package/lib/components/MultipleFilePicker/components/UploadedFiles/styles.js +8 -57
  8. package/lib/components/MultipleFilePicker/constants.js +0 -14
  9. package/lib/components/MultipleFilePicker/index.js +196 -147
  10. package/lib/components/MultipleFilePicker/propTypes.js +15 -11
  11. package/lib/components/MultipleFilePicker/styles.js +9 -0
  12. package/lib/components/MultipleFilePicker/utils.js +22 -51
  13. package/lib/components/UTBaseInputField/components/IconAdornment/utils.js +2 -3
  14. package/lib/components/UTCheckBox/constants.js +2 -0
  15. package/lib/components/UTCheckBox/index.js +25 -16
  16. package/lib/components/UTCheckBox/theme.js +1 -3
  17. package/lib/components/UTCheckList/constants.js +0 -2
  18. package/lib/components/UTCheckList/index.js +7 -6
  19. package/lib/components/UTCheckList/styles.js +2 -1
  20. package/lib/components/UTCheckList/utils.js +2 -2
  21. package/lib/components/UTFieldLabel/index.js +4 -3
  22. package/package.json +1 -1
  23. package/lib/components/MultipleFilePicker/components/Input/README.md +0 -77
  24. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/constants.js +0 -2
  25. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/index.js +0 -19
  26. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/propTypes.js +0 -8
  27. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/styles.js +0 -11
  28. package/lib/components/MultipleFilePicker/components/Input/components/Title/index.js +0 -78
  29. package/lib/components/MultipleFilePicker/components/Input/components/Title/propTypes.js +0 -14
  30. package/lib/components/MultipleFilePicker/components/Input/components/Title/styles.js +0 -42
  31. package/lib/components/MultipleFilePicker/components/Input/components/Underline/index.js +0 -80
  32. package/lib/components/MultipleFilePicker/components/Input/components/Underline/styles.js +0 -39
  33. package/lib/components/MultipleFilePicker/components/Input/constants.js +0 -2
  34. package/lib/components/MultipleFilePicker/components/Input/index.js +0 -299
  35. package/lib/components/MultipleFilePicker/components/Input/propTypes.js +0 -43
  36. package/lib/components/MultipleFilePicker/components/Input/styles.js +0 -47
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useCallback, useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
3
 
4
+ import { BUTTON_VARIANT } from '../UTCheckBox/constants';
4
5
  import { formatErrorToValidation } from '../UTValidation/utils';
5
6
  import UTCheckBox from '../UTCheckBox';
6
7
  import UTFieldLabel from '../UTFieldLabel';
@@ -9,7 +10,7 @@ import UTValidation from '../UTValidation';
9
10
  import { keyExtractor, isChecked, convertIfIsString, getPropValueBasedOnVariant } from './utils';
10
11
  import styles from './styles';
11
12
  import { defaultProps, propTypes } from './proptypes';
12
- import { BUTTON_VARIANT, SPACING } from './constants';
13
+ import { SPACING } from './constants';
13
14
 
14
15
  const UTCheckList = ({
15
16
  error,
@@ -54,7 +55,7 @@ const UTCheckList = ({
54
55
  );
55
56
 
56
57
  const handleChange = useCallback(
57
- receivedValue => () => {
58
+ receivedValue => {
58
59
  if (isSimple) {
59
60
  onChange([receivedValue]);
60
61
  } else {
@@ -89,10 +90,10 @@ const UTCheckList = ({
89
90
  >
90
91
  {showSelectAll && !isSimple && (
91
92
  <UTCheckBox
92
- checked={areAllSelected}
93
+ value={areAllSelected}
93
94
  indeterminate={isIndeterminate}
94
95
  title={selectAllLabel}
95
- onPress={handleCheckAll}
96
+ onChange={handleCheckAll}
96
97
  reversed={reversedBasedOnVariant}
97
98
  spacing={horizontalSpacing}
98
99
  style={style.selectAll}
@@ -102,11 +103,11 @@ const UTCheckList = ({
102
103
  {options?.map((item, index) => (
103
104
  <UTCheckBox
104
105
  isSimple={isSimple}
105
- checked={isChecked(item, value)}
106
+ value={isChecked(item, value)}
106
107
  disabled={item.disabled}
107
108
  key={keyExtractor(item, index)}
108
109
  title={item.label}
109
- onPress={handleChange(item.value)}
110
+ onChange={() => handleChange(item.value)}
110
111
  reversed={reversedBasedOnVariant}
111
112
  spacing={horizontalSpacing}
112
113
  style={style.item}
@@ -11,7 +11,8 @@ export default StyleSheet.create({
11
11
  },
12
12
  checkboxesContainer: {
13
13
  alignSelf: 'flex-start',
14
- rowGap: SPACING.LARGE
14
+ rowGap: SPACING.LARGE,
15
+ width: '100%'
15
16
  },
16
17
  container: {
17
18
  rowGap: SPACING.LARGE
@@ -1,11 +1,11 @@
1
1
  import { isString } from 'lodash';
2
2
 
3
- import { BUTTON_VARIANT } from './constants';
3
+ import { BUTTON_VARIANT } from '../UTCheckBox/constants';
4
4
 
5
5
  export const keyExtractor = (_, index) => `CB-${index}`;
6
6
 
7
7
  export const isChecked = (item, inputValue) =>
8
- !!inputValue?.find(elem => elem === item.value) || (item.disabled && item.checked);
8
+ (inputValue && !!inputValue?.find(elem => elem === item.value)) || (item.disabled && item.checked);
9
9
 
10
10
  export const convertIfIsString = value =>
11
11
  isString(value) ? (value.length === 0 ? [] : JSON.parse(value.replace(/'/g, '"'))) : value;
@@ -7,9 +7,9 @@ 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, style, variant, weight }) => (
10
+ const UTFieldLabel = ({ children, colorTheme, required, style, variant, weight, withMarkdown }) => (
11
11
  <View style={[styles.label, style]}>
12
- <UTLabel colorTheme={colorTheme} variant={variant}>
12
+ <UTLabel colorTheme={colorTheme} variant={variant} withMarkdown={withMarkdown}>
13
13
  {children}
14
14
  </UTLabel>
15
15
  {required && (
@@ -24,7 +24,8 @@ UTFieldLabel.propTypes = {
24
24
  colorTheme: string,
25
25
  required: bool,
26
26
  variant: string,
27
- weight: string
27
+ weight: string,
28
+ withMarkdown: bool
28
29
  };
29
30
 
30
31
  export default UTFieldLabel;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "1.27.0",
5
+ "version": "1.28.0",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [
@@ -1,77 +0,0 @@
1
- # Input
2
-
3
- ## Input
4
-
5
- Material Text Input with Title and Underline.
6
-
7
- ### Props
8
-
9
-
10
- | NAME | TYPE | REQUIRED | DESCRIPTION | DEFAULT VALUE |
11
- | --- | --- | --- | --- | --- |
12
- | [TextInput](https://facebook.github.io/react-native/docs/textinput#props) props. | TextInput props | No | | - |
13
- | activeColor | string | No | The color the input will have when active. If this prop is not specified, the color defaults to `theme.colors.primary`. | - |
14
- | backgroundColor | string | No | Background color for the input. Defaults to `theme.colors.inputBackground`. | - |
15
- | caption | string | No | Helper text to show below the input if no error is present. | - |
16
- | captionProps | CaptionType | No | Additional props for caption. | - |
17
- | containerStyle | ViewStyle | No | Style for the outer container of the input. | - |
18
- | disabled | bool | No | If `true` sets all styles to disabled and disables interactions with the input. | - |
19
- | error | string | No | Error to display instead of the caption. Also sets colors to the error color. | - |
20
- | errorColor | string | No | The color that errors will be displayed in. Defaults to `theme.colors.error`. | - |
21
- | iconSize | number | No | The size that applies to all icons. | DEFAULT ICON SIZE |
22
- | inactiveColor | string | No | The color the input will have when inactive. If this prop is not specified, the color defaults to `theme.fonts.fontColor`. | - |
23
- | inputRef | func | No | A way to pass a `ref` from outside the component to the input. | - |
24
- | leadingIcon | IconType | No | Icon to display on the left side. | - |
25
- | showEye | bool | No | Show eye icon to show `secureTextEntry` text if that prop is enabled. | - |
26
- | textStyles | TextStyle | No | Style for the input. | - |
27
- | title | string | No | Input title to show when the input is not active. Will float to the top once it is active. | - |
28
- | trailingIcon | IconButtonType | No | Icon button to display on the right side. | - |
29
- | underlineHeight | number | No | The underline component height (reminder: underline is scaled twice as big when active). | `portraitVerticalScale(1)` |
30
- | withValueColor | string | No | The color of the title when it has values, but is not focused. | - |
31
-
32
-
33
- #### Example
34
- ```js
35
- import React, { PureComponent } from 'react';
36
- import { Input } from '@widergy/mobile-ui';
37
-
38
- class InputShowcase extends PureComponent {
39
- state = {
40
- value: '',
41
- error: ''
42
- };
43
-
44
- changeValue = value => this.setState({ value });
45
-
46
- handleBlur = () => {
47
- const { value } = this.state;
48
- this.validate(value);
49
- };
50
-
51
- handleFocus = () => {
52
- this.setState({ error: '' });
53
- };
54
-
55
- validate = text => {
56
- const error =
57
- text && text.length < 5 ? 'Debe tener más de 5 caracteres y este mensaje es de dos líneas' : '';
58
-
59
- this.setState({ error });
60
- };
61
-
62
- render() {
63
- return (
64
- <Input
65
- {...this.state}
66
- {...this.props}
67
- onBlur={this.handleBlur}
68
- onFocus={this.handleFocus}
69
- onChange={this.changeValue}
70
- onSubmit={this.validate}
71
- containerStyle={styles.input}
72
- />
73
- );
74
- }
75
- }
76
-
77
- ```
@@ -1,2 +0,0 @@
1
- export const VISIBILITY = 'eye';
2
- export const VISIBILITY_OFF = 'eye-off';
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
-
4
- import UTButton from '../../../../../UTButton';
5
-
6
- import propTypes from './propTypes';
7
- import styles from './styles';
8
-
9
- const ShowPassword = ({ onShowPassword, passwordVisible }) => (
10
- <View style={styles.container}>
11
- <UTButton Icon={passwordVisible ? 'IconEye' : 'IconEyeOff'} onPress={onShowPassword} variant="text" />
12
- </View>
13
- );
14
-
15
- ShowPassword.displayName = 'ShowPassword';
16
-
17
- ShowPassword.propTypes = propTypes;
18
-
19
- export default ShowPassword;
@@ -1,8 +0,0 @@
1
- import { bool, func, number, string } from 'prop-types';
2
-
3
- export default {
4
- color: string,
5
- onShowPassword: func.isRequired,
6
- passwordVisible: bool.isRequired,
7
- size: number
8
- };
@@ -1,11 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- import { INPUT_ICON_MARGIN } from '../../styles';
4
-
5
- export default StyleSheet.create({
6
- container: {
7
- alignItems: 'flex-end',
8
- flexDirection: 'row',
9
- marginLeft: INPUT_ICON_MARGIN
10
- }
11
- });
@@ -1,78 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { Animated, View } from 'react-native';
3
-
4
- import Label from '../../../../../Label';
5
- import { DURATION } from '../../constants';
6
-
7
- import propTypes from './propTypes';
8
- import styles, { getLabelStyle } from './styles';
9
-
10
- class Title extends Component {
11
- constructor(props) {
12
- super(props);
13
-
14
- this.state = {
15
- translate: new Animated.Value(props.active ? 1 : 0),
16
- width: 0
17
- };
18
- }
19
-
20
- componentDidUpdate(prevProps) {
21
- const { active } = this.props;
22
- if (!prevProps.active && active) this.translate(1);
23
- else if (prevProps.active && !active) this.translate(0);
24
- }
25
-
26
- handleLayout = ({
27
- nativeEvent: {
28
- layout: { width }
29
- }
30
- }) =>
31
- this.setState({
32
- width
33
- });
34
-
35
- translate = toValue => {
36
- const { onAnimationEnd } = this.props;
37
- const { translate } = this.state;
38
- Animated.timing(translate, {
39
- toValue,
40
- duration: DURATION
41
- }).start(onAnimationEnd);
42
- };
43
-
44
- render() {
45
- const {
46
- active,
47
- activeColor,
48
- children,
49
- disabled,
50
- error,
51
- errorColor,
52
- focused,
53
- fontSize,
54
- inactiveColor,
55
- withValueColor
56
- } = this.props;
57
- const { translate, width } = this.state;
58
- const color =
59
- (active && !error && (focused ? activeColor : withValueColor || inactiveColor)) ||
60
- (error && errorColor) ||
61
- inactiveColor;
62
- const labelStyle = getLabelStyle(translate, width, fontSize);
63
-
64
- return (
65
- <View style={styles.container}>
66
- <Animated.View onLayout={this.handleLayout} style={[styles.label, labelStyle]}>
67
- <Label color={color} disabled={disabled} error={error && !errorColor} style={{ fontSize }}>
68
- {children}
69
- </Label>
70
- </Animated.View>
71
- </View>
72
- );
73
- }
74
- }
75
-
76
- Title.propTypes = propTypes;
77
-
78
- export default Title;
@@ -1,14 +0,0 @@
1
- import { bool, func, number, string } from 'prop-types';
2
-
3
- export default {
4
- active: bool,
5
- activeColor: string,
6
- disabled: bool,
7
- error: bool,
8
- errorColor: string,
9
- focused: bool,
10
- fontSize: number,
11
- inactiveColor: string,
12
- onAnimationEnd: func,
13
- withValueColor: string
14
- };
@@ -1,42 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- import { RATIO } from '../../constants';
4
-
5
- export const getLabelStyle = (translate, width, fontSize) => ({
6
- transform: [
7
- {
8
- translateY: translate.interpolate({
9
- inputRange: [0, 1],
10
- outputRange: [fontSize / (2 - RATIO), -fontSize / 3]
11
- })
12
- },
13
- {
14
- translateX: translate.interpolate({
15
- inputRange: [0, 1],
16
- outputRange: [0, (-width * (1 - RATIO)) / 2]
17
- })
18
- },
19
- {
20
- scale: translate.interpolate({
21
- inputRange: [0, 1],
22
- outputRange: [1, RATIO]
23
- })
24
- }
25
- ]
26
- });
27
-
28
- const styles = StyleSheet.create({
29
- container: {
30
- ...StyleSheet.absoluteFillObject,
31
- flex: 1,
32
- alignItems: 'flex-start',
33
- justifyContent: 'flex-start'
34
- },
35
- label: {
36
- textAlignVertical: 'top',
37
- justifyContent: 'flex-start',
38
- alignItems: 'flex-start'
39
- }
40
- });
41
-
42
- export default styles;
@@ -1,80 +0,0 @@
1
- import React, { Component } from 'react';
2
- import { Animated, PixelRatio, View } from 'react-native';
3
- import PropTypes from 'prop-types';
4
-
5
- import { withTheme, themeType } from '../../../../../../theming';
6
- import { DURATION } from '../../constants';
7
-
8
- import styles, { getAnimatedStyles, getUnderlineBaseStyle } from './styles';
9
-
10
- class Underline extends Component {
11
- constructor(props) {
12
- super(props);
13
- this.state = {
14
- color: new Animated.Value(props.error ? 0 : 1),
15
- scale: new Animated.Value(0)
16
- };
17
- }
18
-
19
- componentDidMount() {
20
- const { active } = this.props;
21
- const { scale } = this.state;
22
-
23
- if (active) {
24
- scale.setValue(1);
25
- }
26
- }
27
-
28
- componentDidUpdate(prevProps) {
29
- const { active, error } = this.props;
30
-
31
- if (prevProps.active && !active) this.scale(0);
32
- else if (!prevProps.active && active) this.scale(1);
33
- if (error && !prevProps.error) this.color(0);
34
- else if (!error && prevProps.error) this.color(1);
35
- }
36
-
37
- color = toValue => {
38
- const { color } = this.state;
39
- Animated.timing(color, {
40
- duration: 115,
41
- toValue
42
- }).start();
43
- };
44
-
45
- scale = toValue => {
46
- const { scale } = this.state;
47
- Animated.timing(scale, {
48
- toValue,
49
- duration: DURATION
50
- }).start();
51
- };
52
-
53
- render() {
54
- const { activeColor, errorColor, inactiveColor, height, theme, disabled } = this.props;
55
- const { color, scale } = this.state;
56
-
57
- const animatedStyle = getAnimatedStyles(color, scale, theme, activeColor, errorColor);
58
- const baseUnderlineStyle = getUnderlineBaseStyle(theme, disabled, inactiveColor);
59
-
60
- return (
61
- <View style={[styles.baseSytle, { height: PixelRatio.roundToNearestPixel(height) }]}>
62
- <View style={[styles.expand, baseUnderlineStyle]} />
63
- <Animated.View style={[styles.absolute, animatedStyle]} />
64
- </View>
65
- );
66
- }
67
- }
68
-
69
- Underline.propTypes = {
70
- activeColor: PropTypes.string,
71
- error: PropTypes.bool,
72
- errorColor: PropTypes.string,
73
- inactiveColor: PropTypes.string,
74
- height: PropTypes.number,
75
- theme: themeType,
76
- disabled: PropTypes.bool,
77
- active: PropTypes.bool
78
- };
79
-
80
- export default withTheme(Underline);
@@ -1,39 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- const styles = StyleSheet.create({
4
- baseSytle: {
5
- position: 'absolute',
6
- bottom: 0,
7
- left: 0,
8
- right: 0
9
- },
10
- expand: {
11
- flex: 1
12
- },
13
- absolute: {
14
- ...StyleSheet.absoluteFillObject
15
- }
16
- });
17
-
18
- export const getAnimatedStyles = (color, value, theme, activeColor, errorColor) => ({
19
- backgroundColor: color.interpolate({
20
- inputRange: [0, 1],
21
- outputRange: [errorColor || theme.colors.error, activeColor || theme.colors.primary]
22
- }),
23
- transform: [
24
- { scaleX: value },
25
- {
26
- scaleY: value.interpolate({
27
- inputRange: [0, 1],
28
- outputRange: [1, 2]
29
- })
30
- }
31
- ],
32
- opacity: value
33
- });
34
-
35
- export const getUnderlineBaseStyle = (theme, disabled, inactiveColor) => ({
36
- backgroundColor: disabled ? theme.colors.disabled : inactiveColor
37
- });
38
-
39
- export default styles;
@@ -1,2 +0,0 @@
1
- export const DURATION = 200;
2
- export const RATIO = 0.8;