@widergy/mobile-ui 0.35.2 → 0.35.4

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,18 @@
1
+ ## [0.35.4](https://github.com/widergy/mobile-ui/compare/v0.35.3...v0.35.4) (2022-10-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * added label to tooltip content ([#228](https://github.com/widergy/mobile-ui/issues/228)) ([dee88d6](https://github.com/widergy/mobile-ui/commit/dee88d6e9cc0e306d0efabae284b29dcb2869b9f))
7
+
8
+ ## [0.35.3](https://github.com/widergy/mobile-ui/compare/v0.35.2...v0.35.3) (2022-08-29)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * pr corrections ([b5a48ff](https://github.com/widergy/mobile-ui/commit/b5a48ff9748b20a6c1f4d50eb0be9a3bee5e4882))
14
+ * re-rendering of utmenu ([b0bd3eb](https://github.com/widergy/mobile-ui/commit/b0bd3eb868b8183a52cfd54186d6992c63966c4e))
15
+
1
16
  ## [0.35.2](https://github.com/widergy/mobile-ui/compare/v0.35.1...v0.35.2) (2022-08-12)
2
17
 
3
18
 
@@ -0,0 +1,65 @@
1
+ import React, { PureComponent } from 'react';
2
+ import { FlatList } from 'react-native';
3
+
4
+ import propTypes from './proptypes';
5
+
6
+ class ListView extends PureComponent {
7
+ constructor(props) {
8
+ super(props);
9
+ this.state = {
10
+ style: {
11
+ maxHeight: Math.min(props.maxHeight || props.windowHeight / 3, props.usableWindowHeight)
12
+ }
13
+ };
14
+ }
15
+
16
+ isSelected = item => {
17
+ const { filteredOptions, selectedOption, query, isMultiple } = this.props;
18
+ return isMultiple
19
+ ? !!selectedOption?.find?.(elem => elem === item.value)
20
+ : !query
21
+ ? item.id === selectedOption
22
+ : item.id === filteredOptions[0].id;
23
+ };
24
+
25
+ handleOnPress = item => {
26
+ const { handleOptionPress, onPress } = this.props;
27
+ return handleOptionPress(item.action || (() => onPress(item)));
28
+ };
29
+
30
+ renderItem = ({ item }) => {
31
+ const { MenuOptionComponent, propStyles } = this.props;
32
+
33
+ return (
34
+ <MenuOptionComponent
35
+ selected={this.isSelected(item)}
36
+ label={item.label}
37
+ onPress={this.handleOnPress}
38
+ styles={propStyles}
39
+ item={item}
40
+ />
41
+ );
42
+ };
43
+
44
+ keyExtractor = (option, index) => option.id?.toString() || index.toString();
45
+
46
+ render() {
47
+ const { filteredOptions, ItemSeparatorComponent } = this.props;
48
+ const { style } = this.state;
49
+
50
+ return (
51
+ <FlatList
52
+ style={style}
53
+ data={filteredOptions}
54
+ keyExtractor={this.keyExtractor}
55
+ keyboardShouldPersistTaps="always"
56
+ renderItem={this.renderItem}
57
+ ItemSeparatorComponent={ItemSeparatorComponent}
58
+ />
59
+ );
60
+ }
61
+ }
62
+
63
+ ListView.propTypes = propTypes;
64
+
65
+ export default ListView;
@@ -0,0 +1,16 @@
1
+ import { bool, number, string, any, func } from 'prop-types';
2
+
3
+ export default {
4
+ filteredOptions: any,
5
+ selectedOption: any,
6
+ query: string,
7
+ isMultiple: bool,
8
+ handleOptionPress: func,
9
+ onPress: func,
10
+ MenuOptionComponent: any,
11
+ propStyles: any,
12
+ maxHeight: number,
13
+ windowHeight: number,
14
+ usableWindowHeight: number,
15
+ ItemSeparatorComponent: any
16
+ };
@@ -1,12 +1,12 @@
1
- import { bool, func, string } from 'prop-types';
2
- import React from 'react';
1
+ import { any, shape, bool, func, string } from 'prop-types';
2
+ import React, { memo } from 'react';
3
3
  import { TouchableOpacity, Text, ViewPropTypes } from 'react-native';
4
4
 
5
5
  import styles from './styles';
6
6
 
7
- const MenuOption = ({ onPress, label, selected, styles: propStyles }) => (
7
+ const MenuOption = ({ onPress, label, selected, styles: propStyles, item }) => (
8
8
  <TouchableOpacity
9
- onPress={onPress}
9
+ onPress={() => onPress(item)}
10
10
  style={[
11
11
  styles.option,
12
12
  propStyles?.menuOptionBase,
@@ -22,7 +22,8 @@ MenuOption.propTypes = {
22
22
  onPress: func,
23
23
  label: string,
24
24
  selected: bool,
25
- styles: ViewPropTypes.style
25
+ styles: ViewPropTypes.style,
26
+ item: shape(any)
26
27
  };
27
28
 
28
- export default MenuOption;
29
+ export default memo(MenuOption);
@@ -1,18 +1,11 @@
1
1
  import React, { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
- import {
3
- Dimensions,
4
- FlatList,
5
- Keyboard,
6
- KeyboardAvoidingView,
7
- Modal,
8
- TouchableOpacity,
9
- View
10
- } from 'react-native';
2
+ import { Dimensions, Keyboard, KeyboardAvoidingView, Modal, TouchableOpacity, View } from 'react-native';
11
3
 
12
4
  import useKeyboardHeight from '../../hooks/useKeyboardHeight';
13
5
  import UTTextInput from '../UTTextInput';
14
6
 
15
7
  import MenuOption from './components/MenuOption';
8
+ import ListView from './components/ListView';
16
9
  import MenuTypes from './proptypes';
17
10
  import styles from './styles';
18
11
 
@@ -97,20 +90,11 @@ const UTMenu = ({
97
90
  if (onClose) onClose();
98
91
  };
99
92
 
100
- const handleOptionPress = action => () => {
93
+ const handleOptionPress = action => {
101
94
  action();
102
95
  if (!isMultiple) closeMenu();
103
96
  };
104
97
 
105
- const defaultMaxHeight = windowHeight / 3;
106
-
107
- const isSelected = item =>
108
- isMultiple
109
- ? !!selectedOption?.find?.(elem => elem === item.value)
110
- : !query
111
- ? item.id === selectedOption
112
- : item.id === filteredOptions[0].id;
113
-
114
98
  const focusSearchInput = () => withAutocomplete && searchTextInputRef.current?.focus();
115
99
 
116
100
  return (
@@ -155,23 +139,19 @@ const UTMenu = ({
155
139
  />
156
140
  </View>
157
141
  )}
158
- <FlatList
159
- style={{
160
- maxHeight: Math.min(maxHeight || defaultMaxHeight, usableWindowHeight)
161
- }}
162
- data={filteredOptions}
163
- keyExtractor={(option, index) => option.id?.toString() || index.toString()}
164
- keyboardShouldPersistTaps="always"
165
- renderItem={({ item }) => (
166
- <MenuOptionComponent
167
- selected={isSelected(item)}
168
- label={item.label}
169
- onPress={handleOptionPress(item.action || (() => onPress(item)))}
170
- styles={propStyles}
171
- item={item}
172
- />
173
- )}
142
+ <ListView
143
+ maxHeight={maxHeight}
144
+ windowHeight={windowHeight}
145
+ usableWindowHeight={usableWindowHeight}
146
+ filteredOptions={filteredOptions}
174
147
  ItemSeparatorComponent={ItemSeparatorComponent}
148
+ MenuOptionComponent={MenuOptionComponent}
149
+ handleOptionPress={handleOptionPress}
150
+ onPress={onPress}
151
+ propStyles={propStyles}
152
+ selectedOption={selectedOption}
153
+ query={query}
154
+ isMultiple={isMultiple}
175
155
  />
176
156
  </KeyboardAvoidingView>
177
157
  </View>
@@ -1,19 +1,26 @@
1
1
  import { any, bool, func, shape, string } from 'prop-types';
2
- import React from 'react';
2
+ import React, { memo } from 'react';
3
3
 
4
4
  import Checkbox from '../../../Checkbox';
5
5
 
6
6
  import styles from './styles';
7
7
 
8
- const MultipleItem = ({ onPress, label, selected, checkboxProps }) => (
9
- <Checkbox label={label} onPress={onPress} checked={selected} style={styles.checkbox} {...checkboxProps} />
8
+ const MultipleItem = ({ onPress, label, selected, checkboxProps, item }) => (
9
+ <Checkbox
10
+ label={label}
11
+ onPress={() => onPress(item)}
12
+ checked={selected}
13
+ style={styles.checkbox}
14
+ {...checkboxProps}
15
+ />
10
16
  );
11
17
 
12
18
  MultipleItem.propTypes = {
13
19
  onPress: func,
14
20
  label: string,
15
21
  selected: bool,
16
- checkboxProps: shape(any)
22
+ checkboxProps: shape(any),
23
+ item: shape(any)
17
24
  };
18
25
 
19
- export default MultipleItem;
26
+ export default memo(MultipleItem);
@@ -8,6 +8,7 @@ import InputLabel from '../../components/InputLabel';
8
8
  import InputTypes from '../../proptypes';
9
9
  import Icon from '../../../Icon';
10
10
  import UTTooltip from '../../../UTTooltip';
11
+ import Label from '../../../Label';
11
12
 
12
13
  import ownStyles, { CONTAINER_PADDINGS } from './styles';
13
14
 
@@ -69,7 +70,13 @@ const OutlinedInput = ({
69
70
  disabled && themeStyles?.containerDisabled,
70
71
  // eslint-disable-next-line react-native/no-inline-styles
71
72
  {
72
- borderWidth: borderless ? 0 : focused ? 2 : disabled ? themeStyles?.inactive?.disabledBorderWidth ?? 1 : 1,
73
+ borderWidth: borderless
74
+ ? 0
75
+ : focused
76
+ ? 2
77
+ : disabled
78
+ ? themeStyles?.inactive?.disabledBorderWidth ?? 1
79
+ : 1,
73
80
  borderColor: active ? activeColor : inactiveColor
74
81
  },
75
82
  styles?.inputContainer
@@ -129,7 +136,7 @@ const OutlinedInput = ({
129
136
  </View>
130
137
  {!!tooltip && (
131
138
  <View style={[ownStyles.tooltipContainer, multiline && { height: initialHeight }]}>
132
- <UTTooltip content={tooltip} position="left" {...tooltipProps}>
139
+ <UTTooltip content={<Label>tooltip</Label>} position="left" {...tooltipProps}>
133
140
  <Icon
134
141
  name="questioncircleo"
135
142
  type="antdesign"
@@ -9,7 +9,14 @@ export default StyleSheet.create({
9
9
  zIndex: 0,
10
10
  backgroundColor: 'white',
11
11
  borderRadius: 8,
12
- elevation: 2,
12
+ shadowColor: '#000',
13
+ shadowOffset: {
14
+ width: 0,
15
+ height: 2
16
+ },
17
+ shadowOpacity: 0.23,
18
+ shadowRadius: 2.62,
19
+ elevation: 4,
13
20
  paddingVertical: 4,
14
21
  padding: 10,
15
22
  maxWidth: 250
@@ -82,5 +89,5 @@ export default StyleSheet.create({
82
89
  bottomArrowRotation: {
83
90
  transform: [{ rotate: '0deg' }]
84
91
  },
85
- arrowContainer: { position: 'absolute', elevation: 5 }
92
+ arrowContainer: { position: 'absolute' }
86
93
  });
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": "0.35.2",
5
+ "version": "0.35.4",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [