@widergy/mobile-ui 1.11.3 → 1.11.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 +7 -0
- package/lib/components/UTAutocomplete/index.js +36 -33
- package/lib/components/UTMenu/index.js +30 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [1.11.4](https://github.com/widergy/mobile-ui/compare/v1.11.3...v1.11.4) (2024-06-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* configurable avoid utmenu overlapping anchor ([#296](https://github.com/widergy/mobile-ui/issues/296)) ([6ab50ba](https://github.com/widergy/mobile-ui/commit/6ab50babc59deb019947c79067a010e4ddf047dc))
|
|
7
|
+
|
|
1
8
|
## [1.11.3](https://github.com/widergy/mobile-ui/compare/v1.11.2...v1.11.3) (2024-06-12)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -9,18 +9,19 @@ import UTTextInput from '../UTTextInput';
|
|
|
9
9
|
import styles from './styles';
|
|
10
10
|
|
|
11
11
|
const UTAutocomplete = ({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
autoCompletePlaceholder,
|
|
13
|
+
avoidOverlappingAnchor,
|
|
14
14
|
disabled,
|
|
15
|
+
error,
|
|
16
|
+
filterOptions,
|
|
17
|
+
input,
|
|
15
18
|
label,
|
|
16
19
|
labelBackgroundColor,
|
|
17
|
-
error,
|
|
18
|
-
variant,
|
|
19
|
-
autoCompletePlaceholder,
|
|
20
|
-
MenuOptionComponent,
|
|
21
20
|
ListEmptyComponent,
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
MenuOptionComponent,
|
|
22
|
+
options,
|
|
23
|
+
persistSelectedOption = false,
|
|
24
|
+
variant
|
|
24
25
|
}) => {
|
|
25
26
|
const [selectedOption, setSelectedOption] = useState();
|
|
26
27
|
|
|
@@ -38,30 +39,31 @@ const UTAutocomplete = ({
|
|
|
38
39
|
return (
|
|
39
40
|
<View style={styles.container}>
|
|
40
41
|
<UTMenu
|
|
41
|
-
options={options}
|
|
42
|
-
fullWidth
|
|
43
|
-
selectedOption={selectedOption?.id}
|
|
44
|
-
withAutocomplete
|
|
45
|
-
onPress={handleOnPress}
|
|
46
|
-
onOpen={input.onFocus}
|
|
47
|
-
onClose={input.onBlur}
|
|
48
|
-
disabled={disabled}
|
|
49
|
-
onQueryChange={input.onQueryChange}
|
|
50
42
|
autoCompletePlaceholder={autoCompletePlaceholder}
|
|
43
|
+
avoidOverlappingAnchor={avoidOverlappingAnchor}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
filterOptions={filterOptions}
|
|
46
|
+
fullWidth
|
|
47
|
+
ListEmptyComponent={ListEmptyComponent}
|
|
51
48
|
maxHeight={WINDOW_HEIGHT * 0.25}
|
|
52
49
|
MenuOptionComponent={MenuOptionComponent}
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
onClose={input.onBlur}
|
|
51
|
+
onOpen={input.onFocus}
|
|
52
|
+
onPress={handleOnPress}
|
|
53
|
+
onQueryChange={input.onQueryChange}
|
|
54
|
+
options={options}
|
|
55
|
+
selectedOption={selectedOption?.id}
|
|
56
|
+
withAutocomplete
|
|
55
57
|
>
|
|
56
58
|
<UTTextInput
|
|
57
|
-
|
|
58
|
-
value={selectedOption?.label || ''}
|
|
59
|
+
disabled={disabled}
|
|
59
60
|
error={error}
|
|
60
61
|
label={label}
|
|
61
62
|
labelBackgroundColor={labelBackgroundColor}
|
|
62
|
-
RightIcon={{ type: 'font-awesome', name: 'caret-down' }}
|
|
63
63
|
onChange={() => {}}
|
|
64
|
-
|
|
64
|
+
RightIcon={{ type: 'font-awesome', name: 'caret-down' }}
|
|
65
|
+
value={selectedOption?.label || ''}
|
|
66
|
+
variant={variant}
|
|
65
67
|
/>
|
|
66
68
|
</UTMenu>
|
|
67
69
|
</View>
|
|
@@ -69,12 +71,21 @@ const UTAutocomplete = ({
|
|
|
69
71
|
};
|
|
70
72
|
|
|
71
73
|
UTAutocomplete.propTypes = {
|
|
74
|
+
avoidOverlappingAnchor: bool,
|
|
75
|
+
autoCompletePlaceholder: string,
|
|
76
|
+
disabled: bool,
|
|
77
|
+
error: oneOf([bool, string]),
|
|
78
|
+
filterOptions: bool,
|
|
72
79
|
input: shape({
|
|
73
80
|
onChange: func.isRequired,
|
|
74
81
|
value: string.isRequired,
|
|
75
82
|
onFocus: func,
|
|
76
83
|
onBlur: func
|
|
77
84
|
}),
|
|
85
|
+
label: string,
|
|
86
|
+
labelBackgroundColor: string,
|
|
87
|
+
ListEmptyComponent: element,
|
|
88
|
+
MenuOptionComponent: element,
|
|
78
89
|
options: arrayOf(
|
|
79
90
|
shape({
|
|
80
91
|
value: string,
|
|
@@ -82,16 +93,8 @@ UTAutocomplete.propTypes = {
|
|
|
82
93
|
label: string
|
|
83
94
|
})
|
|
84
95
|
),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
labelBackgroundColor: string,
|
|
88
|
-
error: oneOf([bool, string]),
|
|
89
|
-
variant: string,
|
|
90
|
-
autoCompletePlaceholder: string,
|
|
91
|
-
MenuOptionComponent: element,
|
|
92
|
-
ListEmptyComponent: element,
|
|
93
|
-
filterOptions: bool,
|
|
94
|
-
persistSelectedOption: bool
|
|
96
|
+
persistSelectedOption: bool,
|
|
97
|
+
variant: string
|
|
95
98
|
};
|
|
96
99
|
|
|
97
100
|
export default UTAutocomplete;
|
|
@@ -10,27 +10,28 @@ import MenuTypes from './proptypes';
|
|
|
10
10
|
import styles from './styles';
|
|
11
11
|
|
|
12
12
|
const UTMenu = ({
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
autoCompletePlaceholder,
|
|
14
|
+
avoidOverlappingAnchor = true,
|
|
15
15
|
children,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
disabled,
|
|
17
|
+
filterOptions = true,
|
|
18
18
|
fullWidth,
|
|
19
|
-
verticalOffset = 0,
|
|
20
19
|
horizontalOffset = 0,
|
|
21
|
-
|
|
22
|
-
disabled,
|
|
23
|
-
withoutOpacity,
|
|
24
|
-
styles: propStyles,
|
|
25
|
-
MenuOptionComponent = MenuOption,
|
|
20
|
+
isMultiple,
|
|
26
21
|
ItemSeparatorComponent,
|
|
27
22
|
ListEmptyComponent,
|
|
28
23
|
maxHeight,
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
MenuOptionComponent = MenuOption,
|
|
25
|
+
onClose,
|
|
26
|
+
onOpen,
|
|
27
|
+
onPress,
|
|
31
28
|
onQueryChange,
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
options = [],
|
|
30
|
+
selectedOption,
|
|
31
|
+
styles: propStyles,
|
|
32
|
+
verticalOffset = 0,
|
|
33
|
+
withAutocomplete,
|
|
34
|
+
withoutOpacity
|
|
34
35
|
}) => {
|
|
35
36
|
const [isOpen, setIsOpen] = useState(false);
|
|
36
37
|
const anchorRef = useRef(null);
|
|
@@ -70,8 +71,12 @@ const UTMenu = ({
|
|
|
70
71
|
let left = x + horizontalOffset;
|
|
71
72
|
|
|
72
73
|
if (top + menuHeight + height / 2 > usableWindowHeight) {
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (avoidOverlappingAnchor) {
|
|
75
|
+
const upPosition = y - menuHeight - verticalOffset;
|
|
76
|
+
top = upPosition > 0 ? upPosition : top - (top + menuHeight - usableWindowHeight + height / 2);
|
|
77
|
+
} else {
|
|
78
|
+
top = usableWindowHeight - menuHeight - 10;
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
if (left - width + menuWidth > windowWidth) {
|
|
@@ -79,7 +84,15 @@ const UTMenu = ({
|
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
setPosition({ top, left });
|
|
82
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
anchorMeasure,
|
|
89
|
+
avoidOverlappingAnchor,
|
|
90
|
+
horizontalOffset,
|
|
91
|
+
menuDimentions,
|
|
92
|
+
usableWindowHeight,
|
|
93
|
+
verticalOffset,
|
|
94
|
+
windowWidth
|
|
95
|
+
]);
|
|
83
96
|
|
|
84
97
|
const openMenu = () => {
|
|
85
98
|
Keyboard.dismiss();
|
package/package.json
CHANGED