@widergy/mobile-ui 1.27.1 → 1.28.1

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 (27) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/components/MultipleFilePicker/components/Picker/index.js +66 -74
  3. package/lib/components/MultipleFilePicker/components/Picker/styles.js +26 -34
  4. package/lib/components/MultipleFilePicker/components/UploadedFiles/index.js +27 -129
  5. package/lib/components/MultipleFilePicker/components/UploadedFiles/styles.js +8 -57
  6. package/lib/components/MultipleFilePicker/constants.js +0 -14
  7. package/lib/components/MultipleFilePicker/index.js +196 -147
  8. package/lib/components/MultipleFilePicker/propTypes.js +15 -11
  9. package/lib/components/MultipleFilePicker/styles.js +9 -0
  10. package/lib/components/MultipleFilePicker/utils.js +22 -51
  11. package/lib/components/UTBaseInputField/index.js +4 -2
  12. package/lib/components/UTBaseInputField/theme.js +7 -4
  13. package/package.json +1 -1
  14. package/lib/components/MultipleFilePicker/components/Input/README.md +0 -77
  15. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/constants.js +0 -2
  16. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/index.js +0 -19
  17. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/propTypes.js +0 -8
  18. package/lib/components/MultipleFilePicker/components/Input/components/ShowPassword/styles.js +0 -11
  19. package/lib/components/MultipleFilePicker/components/Input/components/Title/index.js +0 -78
  20. package/lib/components/MultipleFilePicker/components/Input/components/Title/propTypes.js +0 -14
  21. package/lib/components/MultipleFilePicker/components/Input/components/Title/styles.js +0 -42
  22. package/lib/components/MultipleFilePicker/components/Input/components/Underline/index.js +0 -80
  23. package/lib/components/MultipleFilePicker/components/Input/components/Underline/styles.js +0 -39
  24. package/lib/components/MultipleFilePicker/components/Input/constants.js +0 -2
  25. package/lib/components/MultipleFilePicker/components/Input/index.js +0 -299
  26. package/lib/components/MultipleFilePicker/components/Input/propTypes.js +0 -43
  27. package/lib/components/MultipleFilePicker/components/Input/styles.js +0 -47
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.28.1](https://github.com/widergy/mobile-ui/compare/v1.28.0...v1.28.1) (2024-10-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [UGC-934] text area fix ([#368](https://github.com/widergy/mobile-ui/issues/368)) ([32bcffc](https://github.com/widergy/mobile-ui/commit/32bcffc0e4b91e5c049fc548f3596bc7599a90ce))
7
+
8
+ # [1.28.0](https://github.com/widergy/mobile-ui/compare/v1.27.1...v1.28.0) (2024-10-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * [EVE-4280] attachment list drawer ([#369](https://github.com/widergy/mobile-ui/issues/369)) ([c4570a7](https://github.com/widergy/mobile-ui/commit/c4570a79a683a758e581f537135137046f747064))
14
+
1
15
  ## [1.27.1](https://github.com/widergy/mobile-ui/compare/v1.27.0...v1.27.1) (2024-10-07)
2
16
 
3
17
 
@@ -1,95 +1,87 @@
1
- import React, { Fragment } from 'react';
2
- import { ImagePropTypes, ViewPropTypes } from 'deprecated-react-native-prop-types';
3
- import { Text, View } from 'react-native';
4
- import { arrayOf, string, bool, oneOfType, shape, func } from 'prop-types';
1
+ import { string, bool, func, number, object, array } from 'prop-types';
2
+ import { isEmpty } from 'lodash';
3
+ import { View } from 'react-native';
4
+ import React from 'react';
5
5
 
6
- import Label from '../../../Label';
7
- import Touchable from '../../../Touchable';
8
- import Input from '../Input';
9
- import { withTheme, themeType } from '../../../../theming';
6
+ import UTLabel from '../../../UTLabel';
7
+ import { withTheme } from '../../../../theming';
8
+ import UploadedFile from '../UploadedFiles';
9
+ import UTIcon from '../../../UTIcon';
10
+ import UTButton from '../../../UTButton';
10
11
 
11
12
  import styles from './styles';
12
13
 
13
14
  const Picker = ({
14
- icon,
15
+ maxFiles,
16
+ disabled = false,
15
17
  error,
16
- onAdd,
17
18
  filePlaceholder,
18
- uploadedFiles,
19
19
  helpText,
20
+ onAdd,
21
+ onDelete,
20
22
  pickerText,
21
- showButton,
22
- title,
23
23
  theme,
24
- withMarkdownTitle,
25
- markdownStyles,
26
- disabled = false,
27
- UploadIcon
24
+ title,
25
+ uploadedFiles
28
26
  }) => (
29
- <Fragment>
30
- {!!title && (
31
- <Label
32
- useMarkdown={withMarkdownTitle}
33
- {...theme.forms.fieldsTitleProps}
34
- markdownStyles={markdownStyles}
35
- >
36
- {title}
37
- </Label>
38
- )}
39
- <View style={[styles.fieldInput, { borderColor: theme.picker.accentColor }]}>
40
- <UploadIcon height={64} width={64} fill={theme.picker.trashIconColor} />
41
- <Touchable borderless style={styles.touchable} disabled={disabled} onPress={onAdd}>
42
- <Input
43
- backgroundColor={theme.picker.inputBackgroundColor}
44
- maxWidth={styles.containerInput.width}
45
- minHeight={styles.containerInput.height}
46
- value={uploadedFiles}
47
- editable={false}
48
- placeholder={filePlaceholder}
49
- placeholderTextColor={theme.picker.buttonTextColor}
50
- disabledTextStyles={{ color: theme.colors.disabled }}
51
- trailingIcon={
52
- showButton && {
53
- name: icon,
54
- color: theme.picker.buttonTextColor,
55
- onPress: onAdd,
56
- type: 'feather',
57
- disabled
58
- }
59
- }
60
- error={error}
61
- containerStyle={styles.containerStyle}
62
- containerPadding={18}
63
- textStyles={styles.textStyles}
64
- underlineHeight={0}
65
- />
66
- </Touchable>
67
- <Text style={styles.pickerText}>{pickerText}</Text>
27
+ <View style={styles.container}>
28
+ <UTLabel>{title}</UTLabel>
29
+ <View style={styles.pickerContainer(error, theme)}>
30
+ {isEmpty(uploadedFiles) ? (
31
+ <UTIcon colorTheme="accent" name="IconCloudUpload" shade="03" size={64} />
32
+ ) : (
33
+ uploadedFiles.map((file, index) => (
34
+ <UploadedFile
35
+ disabled={disabled}
36
+ file={file}
37
+ filePlaceholder={filePlaceholder}
38
+ key={file.name}
39
+ onDelete={() => onDelete(index)}
40
+ />
41
+ ))
42
+ )}
43
+
44
+ {uploadedFiles.length < maxFiles && (
45
+ <UTButton
46
+ colorTheme="primary"
47
+ disabled={disabled}
48
+ Icon="IconUpload"
49
+ onPress={onAdd}
50
+ variant="semitransparent"
51
+ >
52
+ Subir archivo
53
+ </UTButton>
54
+ )}
55
+ <UTLabel colorTheme="gray" style={styles.pickerText} weight="medium">
56
+ {pickerText}
57
+ </UTLabel>
68
58
  </View>
69
- <Text style={styles.helpText}>{helpText}</Text>
70
- </Fragment>
59
+ <UTLabel colorTheme="gray">{helpText}</UTLabel>
60
+ {error && (
61
+ <View style={styles.error}>
62
+ <View style={[styles.errorIcon(theme)]}>
63
+ <UTIcon colorTheme="error" name="IconX" size={16} />
64
+ </View>
65
+ <UTLabel colorTheme="error" style={styles.errorMessage} variant="small">
66
+ {error}
67
+ </UTLabel>
68
+ </View>
69
+ )}
70
+ </View>
71
71
  );
72
72
 
73
73
  Picker.propTypes = {
74
- icon: string.isRequired,
75
- error: oneOfType([string, bool]),
76
- onAdd: func.isRequired,
77
- onDelete: func.isRequired,
78
- filePlaceholder: string,
79
- uploadedFiles: arrayOf(string),
80
- title: string,
81
- showButton: bool,
82
- theme: themeType,
83
- withMarkdownTitle: bool,
84
- markdownStyles: shape({ ViewPropTypes }),
74
+ maxFiles: number,
85
75
  disabled: bool,
76
+ error: string,
77
+ filePlaceholder: string,
86
78
  helpText: string,
79
+ onAdd: func,
80
+ onDelete: func,
87
81
  pickerText: string,
88
- UploadIcon: ImagePropTypes
89
- };
90
-
91
- Picker.defaultProps = {
92
- showButton: true
82
+ theme: object,
83
+ title: string,
84
+ uploadedFiles: array
93
85
  };
94
86
 
95
87
  export default withTheme(Picker);
@@ -1,47 +1,39 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- import { portraitVerticalScale } from '../../../../utils/portraitScalingUtils';
4
-
5
3
  export default StyleSheet.create({
6
4
  container: {
7
- flexDirection: 'row'
5
+ display: 'flex',
6
+ flexDirection: 'column',
7
+ gap: 8
8
8
  },
9
- containerInput: {
10
- height: '100%',
9
+ pickerContainer: (error, theme) => ({
10
+ alignItems: 'center',
11
+ borderColor: error ? theme.Palette?.error?.['04'] : theme.Palette?.light?.['05'],
12
+ borderRadius: 4,
13
+ borderStyle: error ? 'solid' : 'dashed',
14
+ borderWidth: error ? 2 : 1,
15
+ gap: 16,
16
+ padding: 16,
11
17
  width: '100%'
18
+ }),
19
+ error: {
20
+ alignItems: 'center',
21
+ flexDirection: 'row',
22
+ marginTop: 4
12
23
  },
13
- containerStyle: {
14
- flex: 1
15
- },
16
- fieldInput: {
17
- flex: 1,
24
+ errorIcon: theme => ({
18
25
  alignItems: 'center',
19
- borderRadius: 5,
20
- borderStyle: 'dashed',
21
- borderWidth: 1,
22
- height: 'auto',
23
- marginVertical: 10,
24
- paddingBottom: portraitVerticalScale(24),
25
- paddingTop: portraitVerticalScale(16),
26
- width: '100%'
26
+ backgroundColor: theme.Palette?.error?.['01'],
27
+ borderRadius: 100,
28
+ height: 20,
29
+ justifyContent: 'center',
30
+ marginRight: 8,
31
+ width: 20
32
+ }),
33
+ errorMessage: {
34
+ flex: 1
27
35
  },
28
36
  pickerText: {
29
37
  textAlign: 'center'
30
- },
31
- helpText: {
32
- textAlign: 'center',
33
- marginBottom: 10
34
- },
35
- textStyles: {
36
- flex: 1,
37
- padding: 0,
38
- textAlignVertical: 'center',
39
- margin: 5
40
- },
41
- touchable: {
42
- borderRadius: 4,
43
- margin: 7,
44
- height: 38,
45
- width: '50%'
46
38
  }
47
39
  });
@@ -1,140 +1,38 @@
1
- import React, { Fragment } from 'react';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
- import { Text, View } from 'react-native';
4
- import { string, bool, oneOfType, shape, func, arrayOf } from 'prop-types';
1
+ import { string, bool, func, object } from 'prop-types';
2
+ import { View } from 'react-native';
3
+ import React from 'react';
5
4
 
6
- import { withTheme, themeType } from '../../../../theming';
7
- import Touchable from '../../../Touchable';
8
- import Input from '../Input';
9
- import Label from '../../../Label';
5
+ import { withTheme } from '../../../../theming';
6
+ import Surface from '../../../Surface';
7
+ import UTButton from '../../../UTButton';
8
+ import UTIcon from '../../../UTIcon';
9
+ import UTLabel from '../../../UTLabel';
10
10
 
11
11
  import { bytesFormater } from './utils';
12
12
  import styles from './styles';
13
13
 
14
- const UploadedFiles = ({
15
- disabled = false,
16
- error,
17
- filePlaceholder,
18
- helpText,
19
- icon,
20
- markdownStyles,
21
- onAdd,
22
- onDelete,
23
- pickerText,
24
- showButton,
25
- theme,
26
- title,
27
- uploadedFiles,
28
- withMarkdownTitle
29
- }) => (
30
- <Fragment>
31
- {!!title && (
32
- <Label
33
- useMarkdown={withMarkdownTitle}
34
- {...theme.forms.fieldsTitleProps}
35
- markdownStyles={markdownStyles}
36
- >
37
- {title}
38
- </Label>
39
- )}
40
- <View style={[styles.fieldInput, { borderColor: theme.picker.accentColor }]}>
41
- {uploadedFiles.map((file, index) => {
42
- return (
43
- <Touchable
44
- key={`${file.name}-${Math.random()}`}
45
- borderless
46
- style={styles.touchable}
47
- disabled={disabled}
48
- >
49
- <Input
50
- backgroundColor="transparent"
51
- maxWidth={styles.containerInput.width}
52
- minHeight={styles.containerInput.height}
53
- value={file.name}
54
- editable={false}
55
- fileSize={bytesFormater(file.size)}
56
- placeholder={filePlaceholder}
57
- disabledTextStyles={{ color: theme.colors.disabled }}
58
- trailingIcon={
59
- showButton && {
60
- name: 'check',
61
- color: theme.picker.accentColor,
62
- type: 'feather',
63
- disabled
64
- }
65
- }
66
- leadingIcon={
67
- showButton && {
68
- name: 'trash-2',
69
- color: theme.picker.trashIconColor,
70
- type: 'feather',
71
- onPress: () => onDelete(index),
72
- disabled
73
- }
74
- }
75
- error={error}
76
- containerStyle={styles.containerStyle}
77
- textStyles={styles.textStyles}
78
- containerPadding={styles.containerPadding.padding}
79
- underlineHeight={0}
80
- iconSize={32}
81
- textColor={theme.picker.dark05}
82
- />
83
- </Touchable>
84
- );
85
- })}
86
- <Touchable borderless style={styles.uploadTouchable} disabled={disabled} onPress={onAdd}>
87
- <Input
88
- backgroundColor={theme.picker.inputBackgroundColor}
89
- maxWidth={styles.containerInput.width}
90
- minHeight={38}
91
- value={uploadedFiles}
92
- editable={false}
93
- placeholder={filePlaceholder}
94
- placeholderTextColor={theme.picker.buttonTextColor}
95
- disabledTextStyles={{ color: theme.colors.disabled }}
96
- trailingIcon={
97
- showButton && {
98
- name: icon,
99
- type: 'feather',
100
- color: theme.picker.buttonTextColor,
101
- onPress: onAdd,
102
- disabled
103
- }
104
- }
105
- error={error}
106
- textStyles={styles.textButtonStyles}
107
- containerButtonPadding={styles.containerButtonPadding.padding}
108
- containerPadding={styles.containerPadding.padding}
109
- underlineHeight={0}
110
- iconSize={20}
111
- />
112
- </Touchable>
113
- <Text style={styles.pickerText}>{pickerText}</Text>
114
- </View>
115
- <Text style={styles.helpText}>{helpText}</Text>
116
- </Fragment>
117
- );
14
+ const UploadedFiles = ({ disabled = false, file, filePlaceholder, onDelete }) => {
15
+ return (
16
+ <Surface style={styles.container}>
17
+ <UTIcon name="IconCheck" size={32} colorTheme="accent" shade="04" />
18
+ <View style={styles.texts}>
19
+ <UTLabel numberOfLines={1} weight="medium">
20
+ {file.name || filePlaceholder}
21
+ </UTLabel>
22
+ <UTLabel colorTheme="gray" weight="medium">
23
+ {bytesFormater(file.size)}
24
+ </UTLabel>
25
+ </View>
26
+ {!disabled && <UTButton Icon="IconTrash" colorTheme="primary" variant="text" onPress={onDelete} />}
27
+ </Surface>
28
+ );
29
+ };
118
30
 
119
31
  UploadedFiles.propTypes = {
120
- icon: string.isRequired,
121
- error: oneOfType([string, bool]),
122
- onAdd: func.isRequired,
123
- onDelete: func.isRequired,
124
- filePlaceholder: string,
125
- uploadedFiles: arrayOf(string),
126
- title: string,
127
- showButton: bool,
128
- theme: themeType,
129
- withMarkdownTitle: bool,
130
- markdownStyles: shape({ ViewPropTypes }),
131
32
  disabled: bool,
132
- helpText: string,
133
- pickerText: string
134
- };
135
-
136
- UploadedFiles.defaultProps = {
137
- showButton: true
33
+ file: object,
34
+ filePlaceholder: string,
35
+ onDelete: func
138
36
  };
139
37
 
140
38
  export default withTheme(UploadedFiles);
@@ -1,65 +1,16 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- import { portraitHorizontalScale, portraitVerticalScale } from '../../../../utils/portraitScalingUtils';
4
-
5
3
  export default StyleSheet.create({
6
4
  container: {
7
- flexDirection: 'row'
8
- },
9
- containerInput: {
10
- height: '100%',
11
- width: '100%'
12
- },
13
- containerStyle: {
14
- flex: 1,
15
- shadowColor: '#E4E6EA',
16
- elevation: 4
17
- },
18
- containerButtonPadding: {
19
- padding: portraitHorizontalScale(65)
20
- },
21
- containerPadding: {
22
- padding: portraitHorizontalScale(18)
23
- },
24
- fieldInput: {
25
- borderRadius: 5,
26
- borderStyle: 'dashed',
27
- borderWidth: 1,
28
- flex: 1,
29
- height: 'auto',
30
- paddingBottom: portraitVerticalScale(24),
31
- paddingTop: portraitVerticalScale(16),
32
- width: '100%',
33
- marginVertical: 10
34
- },
35
- helpText: {
36
- textAlign: 'center',
37
- marginBottom: 10
38
- },
39
- pickerText: {
40
- textAlign: 'center'
41
- },
42
- textStyles: {
43
- marginLeft: 5,
44
- marginTop: 16
45
- },
46
- textButtonStyles: {
47
- flex: 1,
48
- padding: 0,
49
- textAlignVertical: 'center',
50
- margin: 15
51
- },
52
- touchable: {
5
+ alignItems: 'center',
53
6
  borderRadius: 4,
54
- paddingHorizontal: portraitHorizontalScale(12),
55
- height: 80,
56
- width: '100%'
7
+ flexDirection: 'row',
8
+ gap: 16,
9
+ padding: 16,
10
+ flexShrink: 1
57
11
  },
58
- uploadTouchable: {
59
- borderRadius: 4,
60
- marginHorizontal: 16,
61
- marginVertical: 10,
62
- height: 38,
63
- width: '90%'
12
+ texts: {
13
+ flex: 1,
14
+ flexGrow: 1
64
15
  }
65
16
  });
@@ -1,18 +1,4 @@
1
1
  // eslint-disable-next-line import/no-unresolved
2
- import DocumentPicker from 'react-native-document-picker';
3
-
4
2
  import { MEGABYTE } from '../../utils/fileUtils.js';
5
3
 
6
- export const FILE_UPLOAD_ICON = 'file-upload';
7
-
8
- export const UPLOAD_ICON = 'upload';
9
-
10
- export const CHECK_ICON = 'check';
11
-
12
- export const TRASH_ICON = 'trash-2';
13
-
14
- export const TYPE_ICON = 'feather';
15
-
16
- export const DEFAULT_ALLOWED_TYPES = [DocumentPicker.types.allFiles];
17
-
18
4
  export const DEFAULT_MAX_SIZE = 10 * MEGABYTE;