@widergy/mobile-ui 1.30.0 → 1.30.2

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.30.2](https://github.com/widergy/mobile-ui/compare/v1.30.1...v1.30.2) (2024-11-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * [UG-2037] ut action card fixes ([#377](https://github.com/widergy/mobile-ui/issues/377)) ([ff1022f](https://github.com/widergy/mobile-ui/commit/ff1022fa3962aac5832c7657f7582ab4ac0598eb))
7
+
8
+ ## [1.30.1](https://github.com/widergy/mobile-ui/compare/v1.30.0...v1.30.1) (2024-11-01)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * [EVE-4316] attachment list fix ([055a2c5](https://github.com/widergy/mobile-ui/commit/055a2c508c266b763777d8c13a13f6d8f07265ab))
14
+
1
15
  # [1.30.0](https://github.com/widergy/mobile-ui/compare/v1.29.5...v1.30.0) (2024-10-30)
2
16
 
3
17
 
@@ -13,7 +13,13 @@ import UTBottomSheet from '../UTBottomSheet';
13
13
  import UTButton from '../UTButton';
14
14
 
15
15
  import { DEFAULT_MAX_SIZE } from './constants';
16
- import { getInitialValuesFrom, isFileFormatInvalid, isFileSizeInvaid, isFileTypeInvalid } from './utils';
16
+ import {
17
+ getDocumentPickerType,
18
+ getInitialValuesFrom,
19
+ isFileFormatInvalid,
20
+ isFileSizeInvaid,
21
+ isFileTypeInvalid
22
+ } from './utils';
17
23
  import filePickerPropTypes from './propTypes';
18
24
  import Picker from './components/Picker';
19
25
  import styles from './styles';
@@ -70,7 +76,7 @@ const MultipleFilePicker = ({
70
76
  const onPickFiles = async () => {
71
77
  const documents = await DocumentPicker.pick({
72
78
  allowMultiSelection: true,
73
- type: allowedTypes ?? DocumentPicker.types.allFiles
79
+ type: isEmpty(allowedTypes) ? DocumentPicker.types.allFiles : allowedTypes.map(getDocumentPickerType)
74
80
  });
75
81
 
76
82
  if (uploadedFiles.length + documents.length > maxFiles)
@@ -1,5 +1,44 @@
1
- import { PDFDocument } from 'pdf-lib';
2
1
  import { isEmpty } from 'lodash';
2
+ import { PDFDocument } from 'pdf-lib';
3
+ // eslint-disable-next-line import/no-unresolved
4
+ import DocumentPicker from 'react-native-document-picker';
5
+
6
+ const mimeTypes = {
7
+ allFiles: '*/*',
8
+ audio: 'audio/*',
9
+ csv: 'text/csv',
10
+ doc: 'application/msword',
11
+ docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
12
+ images: 'image/*',
13
+ json: 'application/json',
14
+ pdf: 'application/pdf',
15
+ plainText: 'text/plain',
16
+ ppt: 'application/vnd.ms-powerpoint',
17
+ pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
18
+ video: 'video/*',
19
+ xls: 'application/vnd.ms-excel',
20
+ xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
21
+ zip: 'application/zip'
22
+ };
23
+
24
+ const extensions = {
25
+ allFiles: '*',
26
+ audio:
27
+ '.3g2 .3gp .aac .adt .adts .aif .aifc .aiff .asf .au .m3u .m4a .m4b .mid .midi .mp2 .mp3 .rmi .snd .wav .wax .wma',
28
+ csv: '.csv',
29
+ doc: '.doc',
30
+ docx: '.docx',
31
+ images: '.jpeg .jpg .png .gif .bmp .svg .heic .heif',
32
+ json: '.json',
33
+ pdf: '.pdf',
34
+ plainText: '.txt',
35
+ ppt: '.ppt',
36
+ pptx: '.pptx',
37
+ video: '.mp4 .avi .mov .wmv',
38
+ xls: '.xls',
39
+ xlsx: '.xlsx',
40
+ zip: '.zip .gz'
41
+ };
3
42
 
4
43
  const lengthMatches = (length1, length2, toleranceInPercentage) => {
5
44
  const delta = length1 * (toleranceInPercentage / 100);
@@ -39,11 +78,19 @@ const pdfAspectRatioValidation = async (file, allowedPDFUploadSizes) => {
39
78
  });
40
79
  };
41
80
 
81
+ export const getFileType = extension =>
82
+ Object.entries(extensions).find(([, value]) => value.includes(extension))[0];
83
+
84
+ export const getMimeType = extension => {
85
+ const fileType = getFileType(extension);
86
+ const mimeType = mimeTypes[fileType];
87
+ return mimeType.replace('*', extension.replace(/\./g, ''));
88
+ };
89
+
90
+ export const getDocumentPickerType = extension => DocumentPicker.types[getFileType(extension)];
91
+
42
92
  export const isFileTypeInvalid = (document, allowedTypes, fileTypeError, onError) => {
43
- const isInvalid = !(
44
- allowedTypes.includes(document.type) ||
45
- (document.type.includes('image') && allowedTypes.includes('image/*'))
46
- );
93
+ const isInvalid = !allowedTypes.map(getMimeType).includes(document.type);
47
94
  if (isInvalid) onError(fileTypeError || 'Tipo de archivo inválido.');
48
95
  return isInvalid;
49
96
  };
@@ -26,8 +26,12 @@ const HeaderActions = ({ headerActions, headerActionsProps }) => {
26
26
  !buttonProps.onPress ? (
27
27
  <UTIcon
28
28
  name={buttonProps.Icon}
29
- style={styles.notClickableIconContainer}
30
29
  {...buttonProps}
30
+ style={[
31
+ styles.notClickableIconContainer,
32
+ buttonProps.disabled && styles.disabledIcon,
33
+ buttonProps?.style
34
+ ]}
31
35
  key={buttonProps?.id || i}
32
36
  />
33
37
  ) : (
@@ -17,5 +17,8 @@ export default StyleSheet.create({
17
17
  },
18
18
  notClickableIconContainer: {
19
19
  padding: 8
20
+ },
21
+ disabledIcon: {
22
+ opacity: 0.5
20
23
  }
21
24
  });
@@ -1,5 +1,5 @@
1
1
  import React, { memo } from 'react';
2
- import { View } from 'react-native';
2
+ import { TouchableOpacity, View } from 'react-native';
3
3
  import {
4
4
  arrayOf,
5
5
  bool,
@@ -16,7 +16,6 @@ import {
16
16
  import { isEmpty } from 'lodash';
17
17
 
18
18
  import Surface from '../Surface';
19
- import Touchable from '../Touchable';
20
19
 
21
20
  import { ACTION_TYPES, HEADER_ACTIONS_VARIANTS, PLACE_SELF_TYPES, SIZES } from './constants';
22
21
  import Header from './components/Header';
@@ -49,7 +48,9 @@ const UTActionCard = ({
49
48
  }) => {
50
49
  return (
51
50
  <Surface elevation={1} style={[styles.cardContainer, classNames.container]}>
52
- <Touchable
51
+ <TouchableOpacity
52
+ activeOpacity={0.6}
53
+ disabled={!mainAction}
53
54
  onPress={mainAction && (() => mainAction?.())}
54
55
  style={[styles.innerContainer, classNames.innerContainer, mainAction && styles.withMainAction]}
55
56
  >
@@ -90,7 +91,7 @@ const UTActionCard = ({
90
91
  )}
91
92
  </View>
92
93
  </View>
93
- </Touchable>
94
+ </TouchableOpacity>
94
95
  {!isEmpty(additionalMessage) && <AdditionalMessage {...additionalMessage} size={size} />}
95
96
  {!isEmpty(bottomActions) && (
96
97
  <BottomActions actions={bottomActions} bottomActionsVariant={bottomActionsVariant} />
@@ -50,7 +50,7 @@ const UTIcon = ({
50
50
  style
51
51
  ]}
52
52
  >
53
- <IconComponent {...iconProps} />
53
+ <IconComponent {...{ ...iconProps, ...iconStyles }} />
54
54
  </View>
55
55
  );
56
56
  };
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.30.0",
5
+ "version": "1.30.2",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [