@widergy/mobile-ui 0.35.0 → 0.35.3
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 +22 -0
- package/lib/components/UTMenu/components/ListView/index.js +65 -0
- package/lib/components/UTMenu/components/ListView/proptypes.js +16 -0
- package/lib/components/UTMenu/components/MenuOption/index.js +7 -6
- package/lib/components/UTMenu/index.js +15 -35
- package/lib/components/UTModal/index.js +11 -1
- package/lib/components/UTModal/styles.js +7 -2
- package/lib/components/UTSelect/componentes/MultipleItem/index.js +12 -5
- package/lib/components/UTSwitch/index.js +6 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [0.35.3](https://github.com/widergy/mobile-ui/compare/v0.35.2...v0.35.3) (2022-08-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* pr corrections ([b5a48ff](https://github.com/widergy/mobile-ui/commit/b5a48ff9748b20a6c1f4d50eb0be9a3bee5e4882))
|
|
7
|
+
* re-rendering of utmenu ([b0bd3eb](https://github.com/widergy/mobile-ui/commit/b0bd3eb868b8183a52cfd54186d6992c63966c4e))
|
|
8
|
+
|
|
9
|
+
## [0.35.2](https://github.com/widergy/mobile-ui/compare/v0.35.1...v0.35.2) (2022-08-12)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* added subtitle and separator bar ([#225](https://github.com/widergy/mobile-ui/issues/225)) ([29dc57e](https://github.com/widergy/mobile-ui/commit/29dc57e9b777228ce22f3edadf3dffb3d568a06e))
|
|
15
|
+
|
|
16
|
+
## [0.35.1](https://github.com/widergy/mobile-ui/compare/v0.35.0...v0.35.1) (2022-07-14)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* adding a parameter to utswitch ([#223](https://github.com/widergy/mobile-ui/issues/223)) ([2c3bb48](https://github.com/widergy/mobile-ui/commit/2c3bb480da94325c20480f834ffa1f166be9b135))
|
|
22
|
+
|
|
1
23
|
# [0.35.0](https://github.com/widergy/mobile-ui/compare/v0.34.3...v0.35.0) (2022-06-03)
|
|
2
24
|
|
|
3
25
|
|
|
@@ -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
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
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>
|
|
@@ -8,6 +8,7 @@ import Touchable from '../Touchable';
|
|
|
8
8
|
import Icon from '../Icon';
|
|
9
9
|
import { useTheme } from '../../theming';
|
|
10
10
|
import UTLoading from '../UTLoading';
|
|
11
|
+
import SeparatorBar from '../SeparatorBar';
|
|
11
12
|
|
|
12
13
|
import ModalTypes from './proptypes';
|
|
13
14
|
import ownStyles from './styles';
|
|
@@ -20,6 +21,8 @@ const UTModal = ({
|
|
|
20
21
|
cancelButton,
|
|
21
22
|
visible,
|
|
22
23
|
title,
|
|
24
|
+
subtitle,
|
|
25
|
+
subtitleProps = {},
|
|
23
26
|
loading,
|
|
24
27
|
backgroundStyles,
|
|
25
28
|
imageStyles,
|
|
@@ -30,7 +33,8 @@ const UTModal = ({
|
|
|
30
33
|
imageComponent,
|
|
31
34
|
labelProps,
|
|
32
35
|
modalStyles,
|
|
33
|
-
backgroundImg
|
|
36
|
+
backgroundImg,
|
|
37
|
+
hideSeparatorBar
|
|
34
38
|
}) => {
|
|
35
39
|
const theme = useTheme();
|
|
36
40
|
const themeStyles = theme.simpleButton;
|
|
@@ -85,9 +89,15 @@ const UTModal = ({
|
|
|
85
89
|
{title}
|
|
86
90
|
</Label>
|
|
87
91
|
)}
|
|
92
|
+
{!!subtitle && (
|
|
93
|
+
<Label midGray {...subtitleProps} style={styles.subtitle}>
|
|
94
|
+
{subtitle}
|
|
95
|
+
</Label>
|
|
96
|
+
)}
|
|
88
97
|
|
|
89
98
|
{children}
|
|
90
99
|
</View>
|
|
100
|
+
{!hideSeparatorBar && <SeparatorBar />}
|
|
91
101
|
<View style={styles.buttonsContainer}>
|
|
92
102
|
{!!cancelButton && (
|
|
93
103
|
<Button
|
|
@@ -43,7 +43,11 @@ export default StyleSheet.create({
|
|
|
43
43
|
alignItems: 'center'
|
|
44
44
|
},
|
|
45
45
|
title: {
|
|
46
|
-
marginBottom:
|
|
46
|
+
marginBottom: 12
|
|
47
|
+
},
|
|
48
|
+
subtitle: {
|
|
49
|
+
marginHorizontal: '4%',
|
|
50
|
+
marginBottom: 12
|
|
47
51
|
},
|
|
48
52
|
buttonText: {
|
|
49
53
|
fontWeight: 'normal',
|
|
@@ -51,7 +55,8 @@ export default StyleSheet.create({
|
|
|
51
55
|
margin: 0
|
|
52
56
|
},
|
|
53
57
|
content: {
|
|
54
|
-
padding: 15
|
|
58
|
+
padding: 15,
|
|
59
|
+
paddingBottom: 5
|
|
55
60
|
},
|
|
56
61
|
closeIcon: {
|
|
57
62
|
alignItems: 'center',
|
|
@@ -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
|
|
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);
|
|
@@ -20,7 +20,8 @@ const UTSwitch = ({
|
|
|
20
20
|
trackSize = 20,
|
|
21
21
|
input,
|
|
22
22
|
thumbSize = 10,
|
|
23
|
-
rippleSize = 3
|
|
23
|
+
rippleSize = 3,
|
|
24
|
+
movingStartPosition
|
|
24
25
|
}) => {
|
|
25
26
|
const theme = useTheme();
|
|
26
27
|
|
|
@@ -122,7 +123,10 @@ const UTSwitch = ({
|
|
|
122
123
|
{
|
|
123
124
|
translateX: switchPosition.interpolate({
|
|
124
125
|
inputRange: [0, 1],
|
|
125
|
-
outputRange: [
|
|
126
|
+
outputRange: [
|
|
127
|
+
movingStartPosition ? thumpInitPosition - movingStartPosition : thumpInitPosition,
|
|
128
|
+
thumpFinishPosition
|
|
129
|
+
]
|
|
126
130
|
})
|
|
127
131
|
}
|
|
128
132
|
]
|
package/package.json
CHANGED