etendo-ui-library 1.0.74 → 1.0.75

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/SecondaryComponents/CustomImage.tsx +19 -0
  2. package/components/dropdown/Dropdown.tsx +16 -40
  3. package/components/dropdown/__snapshots__/Dropdown.test.tsx.snap +2 -3
  4. package/components/input/components/InputField.tsx +23 -25
  5. package/components/pagination/Pagination.tsx +43 -65
  6. package/components/pagination/__snapshots__/Pagination.test.tsx.snap +1 -5
  7. package/package.json +1 -1
  8. package/storybook-static/{0.cc5bf34b.iframe.bundle.js → 0.b0f8d4bf.iframe.bundle.js} +1 -1
  9. package/storybook-static/{4.dff405a5.iframe.bundle.js → 4.6cb78ce5.iframe.bundle.js} +3 -3
  10. package/storybook-static/4.6cb78ce5.iframe.bundle.js.map +1 -0
  11. package/storybook-static/{5.c649af4d.iframe.bundle.js → 5.1db9e2f6.iframe.bundle.js} +1 -1
  12. package/storybook-static/{6.80817eaa.iframe.bundle.js → 6.aac5ce84.iframe.bundle.js} +3 -3
  13. package/storybook-static/6.aac5ce84.iframe.bundle.js.map +1 -0
  14. package/storybook-static/{7.67735e8e.iframe.bundle.js → 7.79ff12bf.iframe.bundle.js} +1 -1
  15. package/storybook-static/iframe.html +1 -1
  16. package/storybook-static/main.f15a2174.iframe.bundle.js +1 -0
  17. package/storybook-static/{runtime~main.1aac69ee.iframe.bundle.js → runtime~main.f349476c.iframe.bundle.js} +1 -1
  18. package/storybook-static/vendors~main.a701dcc9.iframe.bundle.js +3 -0
  19. package/storybook-static/vendors~main.a701dcc9.iframe.bundle.js.map +1 -0
  20. package/storybook-static/4.dff405a5.iframe.bundle.js.map +0 -1
  21. package/storybook-static/6.80817eaa.iframe.bundle.js.map +0 -1
  22. package/storybook-static/main.8d59dfe7.iframe.bundle.js +0 -1
  23. package/storybook-static/vendors~main.7dcb87a4.iframe.bundle.js +0 -3
  24. package/storybook-static/vendors~main.7dcb87a4.iframe.bundle.js.map +0 -1
  25. /package/storybook-static/{4.dff405a5.iframe.bundle.js.LICENSE.txt → 4.6cb78ce5.iframe.bundle.js.LICENSE.txt} +0 -0
  26. /package/storybook-static/{6.80817eaa.iframe.bundle.js.LICENSE.txt → 6.aac5ce84.iframe.bundle.js.LICENSE.txt} +0 -0
  27. /package/storybook-static/{vendors~main.7dcb87a4.iframe.bundle.js.LICENSE.txt → vendors~main.a701dcc9.iframe.bundle.js.LICENSE.txt} +0 -0
@@ -0,0 +1,19 @@
1
+ import React, {FC} from 'react';
2
+ import {Image, Platform, ViewStyle} from 'react-native';
3
+
4
+ interface CustomImageProps {
5
+ src?: string;
6
+ alt?: string;
7
+ source?: {uri: string};
8
+ style?: ViewStyle;
9
+ }
10
+
11
+ const CustomImage: FC<CustomImageProps> = ({src, alt, source, style}) => {
12
+ return Platform.OS === 'web' ? (
13
+ <img src={src} alt={alt} style={style} />
14
+ ) : (
15
+ <Image source={source} style={style} />
16
+ );
17
+ };
18
+
19
+ export default CustomImage;
@@ -1,17 +1,11 @@
1
1
  import React, {useState, useRef, useEffect} from 'react';
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- Image,
7
- ScrollView,
8
- Platform,
9
- } from 'react-native';
2
+ import {View, Text, TouchableOpacity, ScrollView, Platform} from 'react-native';
10
3
 
11
4
  import DropdownItem from './DropdownItem';
12
5
  import {DropdownStyleVariant} from './Dropdown.styles';
13
6
  import {DropdownProps, Info} from './Dropdown.types';
14
7
  import {arrowPickerVerticalIcon} from '../../assets/images/icons';
8
+ import CustomImage from '../../SecondaryComponents/CustomImage';
15
9
 
16
10
  const Dropdown = ({
17
11
  data,
@@ -40,10 +34,9 @@ const Dropdown = ({
40
34
  }
41
35
  };
42
36
 
43
- const showOptionsIcon = (isWeb: boolean) => {
44
- return isWeb ? (
45
- <img
46
- src={arrowPickerVerticalIcon}
37
+ const showOptionsIcon = () => {
38
+ return (
39
+ <CustomImage
47
40
  style={{
48
41
  width: 10,
49
42
  height: 7,
@@ -51,43 +44,28 @@ const Dropdown = ({
51
44
  right: 15,
52
45
  rotate: '180deg',
53
46
  }}
54
- />
55
- ) : (
56
- <Image
47
+ src={arrowPickerVerticalIcon}
57
48
  source={{uri: arrowPickerVerticalIcon}}
58
- style={{
59
- width: 11,
60
- height: 9,
61
- resizeMode: 'stretch',
62
- position: 'absolute',
63
- right: 15,
64
- transform: [{rotate: '180deg'}],
65
- }}
66
49
  />
67
50
  );
68
51
  };
69
52
 
70
- const notShowOptionsIcon = (isWeb: boolean) => {
71
- return isWeb ? (
72
- <img
73
- src={arrowPickerVerticalIcon}
74
- style={{width: 10, height: 7, position: 'absolute', right: 15}}
75
- />
76
- ) : (
77
- <Image
78
- source={{uri: arrowPickerVerticalIcon}}
53
+ const notShowOptionsIcon = () => {
54
+ return (
55
+ <CustomImage
79
56
  style={{
80
- width: 11,
81
- height: 9,
82
- resizeMode: 'stretch',
57
+ width: 10,
58
+ height: 7,
83
59
  position: 'absolute',
84
60
  right: 15,
85
61
  }}
62
+ src={arrowPickerVerticalIcon}
63
+ source={{uri: arrowPickerVerticalIcon}}
86
64
  />
87
65
  );
88
66
  };
89
67
 
90
- if (Platform.OS === 'web') {
68
+ if (PLATFORM_IS_WEB) {
91
69
  document.addEventListener('mousedown', closeOpenMenus);
92
70
  }
93
71
 
@@ -103,14 +81,12 @@ const Dropdown = ({
103
81
  <Text style={DropdownStyleVariant.primary.dropDownButtonText}>
104
82
  {chooseOption}
105
83
  </Text>
106
- {showOptions
107
- ? showOptionsIcon(PLATFORM_IS_WEB)
108
- : notShowOptionsIcon(PLATFORM_IS_WEB)}
84
+ {showOptions ? showOptionsIcon() : notShowOptionsIcon()}
109
85
  </TouchableOpacity>
110
86
 
111
87
  {showOptions && (
112
88
  <ScrollView style={DropdownStyleVariant.primary.containerOptions}>
113
- {data.map((item: Info, index: number) => {
89
+ {data?.map((item: Info, index: number) => {
114
90
  return (
115
91
  <DropdownItem
116
92
  item={item}
@@ -50,11 +50,10 @@ exports[`Running Test for Pagination Check Pagination Disabled 1`] = `
50
50
  }
51
51
  style={
52
52
  Object {
53
- "height": 9,
53
+ "height": 7,
54
54
  "position": "absolute",
55
- "resizeMode": "stretch",
56
55
  "right": 15,
57
- "width": 11,
56
+ "width": 10,
58
57
  }
59
58
  }
60
59
  />
@@ -7,7 +7,6 @@ import {
7
7
  TouchableOpacity,
8
8
  KeyboardType,
9
9
  View,
10
- Platform,
11
10
  } from 'react-native';
12
11
  import addImageStyle from '../../../helpers/image_utils';
13
12
  import {styles} from '../Input.style';
@@ -17,6 +16,7 @@ import {
17
16
  disabledPasswordIcon,
18
17
  } from '../../../assets/images/icons';
19
18
  import {BLACK} from '../../../styles/colors';
19
+ import CustomImage from '../../../SecondaryComponents/CustomImage';
20
20
 
21
21
  const InputField = ({
22
22
  configField,
@@ -37,7 +37,6 @@ const InputField = ({
37
37
  }: InputFieldProps) => {
38
38
  const [showImg, setShowImg] = useState<boolean>(false);
39
39
  const regex = /^[0-9.,]+$/g;
40
- const PLATFORM_IS_WEB = Platform.OS === 'web';
41
40
 
42
41
  const getStyleText = (text: string | undefined, password?: boolean) => {
43
42
  let style: Array<TextStyle | TextStyle[]> = [];
@@ -97,7 +96,8 @@ const InputField = ({
97
96
  <TouchableOpacity
98
97
  style={styleField.field}
99
98
  onPress={onPress}
100
- disabled={disabled || configField.disabledField}>
99
+ disabled={disabled || configField.disabledField}
100
+ >
101
101
  {(() => {
102
102
  if (configField?.type === 'textInput') {
103
103
  return (
@@ -105,7 +105,8 @@ const InputField = ({
105
105
  style={{
106
106
  flexDirection: 'row',
107
107
  width: '100%',
108
- }}>
108
+ }}
109
+ >
109
110
  <TextInput
110
111
  editable={!disabled || !configField.disabledField}
111
112
  focusable={!disabled || !configField.disabledField}
@@ -122,26 +123,22 @@ const InputField = ({
122
123
  {password && (
123
124
  <TouchableOpacity
124
125
  onPress={() => setShowPassword(!showPassword)}
125
- style={styles.passwordContainer}>
126
- {PLATFORM_IS_WEB ? (
127
- <img
128
- src={
129
- !showPassword
130
- ? disabledPasswordIcon
131
- : activePasswordIcon
132
- }
133
- style={{width: 22, height: 22}}
134
- />
135
- ) : (
136
- <Image
137
- source={
138
- !showPassword
139
- ? {uri: disabledPasswordIcon}
140
- : {uri: activePasswordIcon}
141
- }
142
- style={styles.passwordImage}
143
- />
144
- )}
126
+ style={styles.passwordContainer}
127
+ >
128
+ <CustomImage
129
+ style={{
130
+ width: 22,
131
+ height: 22,
132
+ }}
133
+ src={
134
+ !showPassword ? disabledPasswordIcon : activePasswordIcon
135
+ }
136
+ source={
137
+ !showPassword
138
+ ? {uri: disabledPasswordIcon}
139
+ : {uri: activePasswordIcon}
140
+ }
141
+ />
145
142
  </TouchableOpacity>
146
143
  )}
147
144
  </View>
@@ -162,7 +159,8 @@ const InputField = ({
162
159
  <TouchableOpacity
163
160
  onPress={onSubmit}
164
161
  style={styles.buttonContainerInputField}
165
- disabled={configField?.disabledSubmit || disabled}>
162
+ disabled={configField?.disabledSubmit || disabled}
163
+ >
166
164
  {configField?.image?.imgRoute && (
167
165
  <Image
168
166
  source={{uri: configField.image.imgRoute}}
@@ -1,7 +1,7 @@
1
1
  /* Imports */
2
2
  import React, {useState} from 'react';
3
3
 
4
- import {Text, View, Image, TouchableOpacity, Platform} from 'react-native';
4
+ import {Text, View, TouchableOpacity} from 'react-native';
5
5
  import {PaginationStyleVariant} from './Pagination.styles';
6
6
  import {PaginationProps} from './Pagination.types';
7
7
  import {
@@ -9,6 +9,7 @@ import {
9
9
  arrowLast,
10
10
  arrowPickerHorizontalIcon,
11
11
  } from '../../assets/images/icons';
12
+ import CustomImage from '../../SecondaryComponents/CustomImage';
12
13
 
13
14
  /* Pagination component */
14
15
  export const Pagination = ({
@@ -17,7 +18,6 @@ export const Pagination = ({
17
18
  totalData,
18
19
  amountDataPerPage,
19
20
  pagination,
20
- isWeb,
21
21
  }: PaginationProps) => {
22
22
  // Will serve to set the page number where the user is
23
23
  const [page, setPage] = useState<number>(currentPage);
@@ -57,26 +57,16 @@ export const Pagination = ({
57
57
  onChangeSelected(1, 0);
58
58
  }}
59
59
  >
60
- {Platform.OS === 'web' && isWeb ? (
61
- <img
62
- src={arrowFirst}
63
- alt="back-double-button"
64
- style={{
65
- width: 10,
66
- height: 10,
67
- marginRight: 10,
68
- }}
69
- />
70
- ) : (
71
- <Image
72
- source={{uri: arrowFirst}}
73
- style={{
74
- width: 10,
75
- height: 10,
76
- marginRight: 10,
77
- }}
78
- />
79
- )}
60
+ <CustomImage
61
+ src={arrowFirst}
62
+ alt="back-double-button"
63
+ source={{uri: arrowFirst}}
64
+ style={{
65
+ width: 10,
66
+ height: 10,
67
+ marginRight: 10,
68
+ }}
69
+ />
80
70
  </TouchableOpacity>
81
71
 
82
72
  <TouchableOpacity
@@ -88,23 +78,17 @@ export const Pagination = ({
88
78
  }
89
79
  }}
90
80
  >
91
- {Platform.OS === 'web' && isWeb ? (
92
- <img
93
- src={arrowPickerHorizontalIcon}
94
- alt="back-button"
95
- style={{width: 10, height: 10, marginRight: 10, rotate: '180deg'}}
96
- />
97
- ) : (
98
- <Image
99
- source={{uri: arrowPickerHorizontalIcon}}
100
- style={{
101
- width: 10,
102
- height: 10,
103
- marginRight: 10,
104
- transform: [{rotate: '180deg'}],
105
- }}
106
- />
107
- )}
81
+ <CustomImage
82
+ src={arrowPickerHorizontalIcon}
83
+ alt="back-button"
84
+ source={{uri: arrowPickerHorizontalIcon}}
85
+ style={{
86
+ width: 10,
87
+ height: 10,
88
+ marginRight: 10,
89
+ rotate: '180deg',
90
+ }}
91
+ />
108
92
  </TouchableOpacity>
109
93
 
110
94
  {/* Text with layout to display the page number the user is on */}
@@ -123,20 +107,16 @@ export const Pagination = ({
123
107
  }
124
108
  }}
125
109
  >
126
- {Platform.OS === 'web' && isWeb ? (
127
- <div>
128
- <img
129
- src={arrowPickerHorizontalIcon}
130
- alt="next-button"
131
- style={{width: 10, height: 10, marginRight: 10}}
132
- />
133
- </div>
134
- ) : (
135
- <Image
136
- source={{uri: arrowPickerHorizontalIcon}}
137
- style={{width: 10, height: 10, marginRight: 10}}
138
- />
139
- )}
110
+ <CustomImage
111
+ style={{
112
+ width: 10,
113
+ height: 10,
114
+ marginRight: 10,
115
+ }}
116
+ src={arrowPickerHorizontalIcon}
117
+ alt="next-button"
118
+ source={{uri: arrowPickerHorizontalIcon}}
119
+ />
140
120
  </TouchableOpacity>
141
121
 
142
122
  <TouchableOpacity
@@ -151,18 +131,16 @@ export const Pagination = ({
151
131
  }
152
132
  }}
153
133
  >
154
- {Platform.OS === 'web' && isWeb ? (
155
- <img
156
- src={arrowLast}
157
- alt="next-double-button"
158
- style={{width: 10, height: 10, marginRight: 10}}
159
- />
160
- ) : (
161
- <Image
162
- source={{uri: arrowLast}}
163
- style={{width: 10, height: 10, marginRight: 10}}
164
- />
165
- )}
134
+ <CustomImage
135
+ style={{
136
+ width: 10,
137
+ height: 10,
138
+ marginRight: 10,
139
+ }}
140
+ src={arrowLast}
141
+ alt="next-double-button"
142
+ source={{uri: arrowLast}}
143
+ />
166
144
  </TouchableOpacity>
167
145
  </View>
168
146
  </View>
@@ -98,11 +98,7 @@ exports[`Running Test for Pagination Check Pagination Disabled 1`] = `
98
98
  Object {
99
99
  "height": 10,
100
100
  "marginRight": 10,
101
- "transform": Array [
102
- Object {
103
- "rotate": "180deg",
104
- },
105
- ],
101
+ "rotate": "180deg",
106
102
  "width": 10,
107
103
  }
108
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "etendo-ui-library",
3
- "version": "1.0.74",
3
+ "version": "1.0.75",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "android": "react-native run-android",