@widergy/mobile-ui 1.14.2 → 1.14.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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.14.3](https://github.com/widergy/mobile-ui/compare/v1.14.2...v1.14.3) (2024-07-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * utmenu google attribution ([#320](https://github.com/widergy/mobile-ui/issues/320)) ([ea104e7](https://github.com/widergy/mobile-ui/commit/ea104e7237006a5e3c7d2c2345c48e18d35bcd4e))
7
+
1
8
  ## [1.14.2](https://github.com/widergy/mobile-ui/compare/v1.14.1...v1.14.2) (2024-07-22)
2
9
 
3
10
 
@@ -23,6 +23,7 @@ const UTAutocomplete = ({
23
23
  options,
24
24
  persistSelectedOption = false,
25
25
  variant,
26
+ withGoogleAttribution,
26
27
  styles: propStyles
27
28
  }) => {
28
29
  const [selectedOption, setSelectedOption] = useState();
@@ -55,8 +56,9 @@ const UTAutocomplete = ({
55
56
  onQueryChange={input.onQueryChange}
56
57
  options={options}
57
58
  selectedOption={selectedOption?.id}
58
- withAutocomplete
59
59
  styles={propStyles?.UTMenu}
60
+ withAutocomplete
61
+ withGoogleAttribution={withGoogleAttribution}
60
62
  >
61
63
  <UTTextInput
62
64
  disabled={disabled}
@@ -64,7 +66,7 @@ const UTAutocomplete = ({
64
66
  label={label}
65
67
  labelBackgroundColor={labelBackgroundColor}
66
68
  onChange={() => {}}
67
- RightIcon={{ type: 'font-awesome', name: 'caret-down' }}
69
+ RightIcon={{ name: 'caret-down', type: 'font-awesome' }}
68
70
  value={selectedOption?.label || ''}
69
71
  variant={variant}
70
72
  />
@@ -74,16 +76,16 @@ const UTAutocomplete = ({
74
76
  };
75
77
 
76
78
  UTAutocomplete.propTypes = {
77
- avoidOverlappingAnchor: bool,
78
79
  autoCompletePlaceholder: string,
80
+ avoidOverlappingAnchor: bool,
79
81
  disabled: bool,
80
82
  error: oneOf([bool, string]),
81
83
  filterOptions: bool,
82
84
  input: shape({
85
+ onBlur: func,
83
86
  onChange: func.isRequired,
84
- value: string.isRequired,
85
87
  onFocus: func,
86
- onBlur: func
88
+ value: string.isRequired
87
89
  }),
88
90
  label: string,
89
91
  labelBackgroundColor: string,
@@ -91,14 +93,15 @@ UTAutocomplete.propTypes = {
91
93
  MenuOptionComponent: element,
92
94
  options: arrayOf(
93
95
  shape({
94
- value: string,
95
96
  id: string,
96
- label: string
97
+ label: string,
98
+ value: string
97
99
  })
98
100
  ),
99
101
  persistSelectedOption: bool,
102
+ styles: ViewPropTypes.style,
100
103
  variant: string,
101
- styles: ViewPropTypes.style
104
+ withGoogleAttribution: bool
102
105
  };
103
106
 
104
107
  export default UTAutocomplete;
@@ -0,0 +1 @@
1
+ export const ATTRIBUTION = 'proporcionado por';
@@ -1,14 +1,25 @@
1
1
  import React, { Fragment, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
- import { Dimensions, Keyboard, KeyboardAvoidingView, Modal, TouchableOpacity, View } from 'react-native';
2
+ import {
3
+ Dimensions,
4
+ Keyboard,
5
+ KeyboardAvoidingView,
6
+ Modal,
7
+ TouchableOpacity,
8
+ View,
9
+ Image
10
+ } from 'react-native';
3
11
 
4
12
  import useKeyboardHeight from '../../hooks/useKeyboardHeight';
5
13
  import UTTextInput from '../UTTextInput';
14
+ import UTLabel from '../UTLabel';
6
15
  import Surface from '../Surface';
7
16
 
8
17
  import MenuOption from './components/MenuOption';
9
18
  import ListView from './components/ListView';
10
19
  import MenuTypes from './proptypes';
11
20
  import styles from './styles';
21
+ import GoogleLogo from './assets/google_on_white.png';
22
+ import { ATTRIBUTION } from './constants';
12
23
 
13
24
  const UTMenu = ({
14
25
  autoCompletePlaceholder,
@@ -32,14 +43,15 @@ const UTMenu = ({
32
43
  styles: propStyles,
33
44
  verticalOffset = 0,
34
45
  withAutocomplete,
35
- withoutOpacity
46
+ withoutOpacity,
47
+ withGoogleAttribution = false
36
48
  }) => {
37
49
  const [isOpen, setIsOpen] = useState(false);
38
50
  const anchorRef = useRef(null);
39
51
  const menuRef = useRef(null);
40
- const [position, setPosition] = useState({ top: 0, right: 0 });
41
- const [anchorMeasure, setAnchorMeasure] = useState({ x: 0, y: 0, width: 0, height: 0 });
42
- const [menuDimentions, setMenuDimentions] = useState({ width: 0, height: 0 });
52
+ const [position, setPosition] = useState({ right: 0, top: 0 });
53
+ const [anchorMeasure, setAnchorMeasure] = useState({ height: 0, width: 0, x: 0, y: 0 });
54
+ const [menuDimentions, setMenuDimentions] = useState({ height: 0, width: 0 });
43
55
  const [query, setQuery] = useState('');
44
56
  const searchTextInputRef = useRef();
45
57
  const filteredOptions = useMemo(() => {
@@ -55,13 +67,13 @@ const UTMenu = ({
55
67
 
56
68
  const handleAnchorLayout = () => {
57
69
  anchorRef.current.measureInWindow((x, y, width, height) => {
58
- setAnchorMeasure({ x, y, width, height });
70
+ setAnchorMeasure({ height, width, x, y });
59
71
  });
60
72
  };
61
73
 
62
74
  const handleMenuLayout = () =>
63
75
  menuRef.current?.measureInWindow((x, y, width, height) => {
64
- setMenuDimentions({ width, height });
76
+ setMenuDimentions({ height, width });
65
77
  });
66
78
 
67
79
  useLayoutEffect(() => {
@@ -84,7 +96,7 @@ const UTMenu = ({
84
96
  left = x - menuWidth + width - horizontalOffset;
85
97
  }
86
98
 
87
- setPosition({ top, left });
99
+ setPosition({ left, top });
88
100
  }, [
89
101
  anchorMeasure,
90
102
  avoidOverlappingAnchor,
@@ -123,60 +135,68 @@ const UTMenu = ({
123
135
  return (
124
136
  <Fragment>
125
137
  <TouchableOpacity
138
+ activeOpacity={withoutOpacity && 1}
126
139
  disabled={disabled}
127
140
  onPress={isOpen ? closeMenu : openMenu}
128
- activeOpacity={withoutOpacity && 1}
129
141
  >
130
- <View ref={anchorRef} onLayout={handleAnchorLayout} pointerEvents="box-only">
142
+ <View onLayout={handleAnchorLayout} pointerEvents="box-only" ref={anchorRef}>
131
143
  {children}
132
144
  </View>
133
145
  </TouchableOpacity>
134
146
  <Modal
135
147
  animationType="fade"
136
- transparent
137
- visible={isOpen}
138
148
  onRequestClose={closeMenu}
139
149
  onShow={focusSearchInput}
150
+ transparent
151
+ visible={isOpen}
140
152
  >
141
153
  <TouchableOpacity onPress={closeMenu} style={styles.overlayTouchable}>
142
154
  <View style={styles.overlay} />
143
155
  </TouchableOpacity>
144
156
  <Surface
145
- style={[styles.menu, position, fullWidth && { width: anchorMeasure?.width }, propStyles?.menu]}
146
- ref={menuRef}
147
157
  onLayout={handleMenuLayout}
158
+ ref={menuRef}
159
+ style={[styles.menu, position, fullWidth && { width: anchorMeasure?.width }, propStyles?.menu]}
148
160
  >
149
161
  <KeyboardAvoidingView behavior="height">
150
162
  {withAutocomplete && (
151
163
  <View style={[styles.searchContainer, propStyles?.searchContainer]}>
152
164
  <UTTextInput
153
165
  InputRef={searchTextInputRef}
154
- value={query}
155
166
  onChange={handleQueryChange}
156
- placeholder={autoCompletePlaceholder}
157
167
  onSubmitEditing={
158
168
  query && filteredOptions[0]
159
169
  ? () => handleOptionPress(() => onPress(filteredOptions[0]))
160
170
  : closeMenu
161
171
  }
172
+ placeholder={autoCompletePlaceholder}
173
+ value={query}
162
174
  />
163
175
  </View>
164
176
  )}
165
177
  <ListView
166
- maxHeight={maxHeight}
167
- windowHeight={windowHeight}
168
- usableWindowHeight={usableWindowHeight}
169
178
  filteredOptions={filteredOptions}
179
+ handleOptionPress={handleOptionPress}
180
+ isMultiple={isMultiple}
170
181
  ItemSeparatorComponent={ItemSeparatorComponent}
171
182
  ListEmptyComponent={ListEmptyComponent}
183
+ maxHeight={maxHeight}
172
184
  MenuOptionComponent={MenuOptionComponent}
173
- handleOptionPress={handleOptionPress}
174
185
  onPress={onPress}
175
186
  propStyles={propStyles}
176
- selectedOption={selectedOption}
177
187
  query={query}
178
- isMultiple={isMultiple}
188
+ selectedOption={selectedOption}
189
+ usableWindowHeight={usableWindowHeight}
190
+ windowHeight={windowHeight}
179
191
  />
192
+ {withGoogleAttribution && (
193
+ <View style={styles.attribution}>
194
+ <UTLabel colorTheme="gray" variant="small">
195
+ {ATTRIBUTION}
196
+ </UTLabel>
197
+ <Image source={GoogleLogo} />
198
+ </View>
199
+ )}
180
200
  </KeyboardAvoidingView>
181
201
  </Surface>
182
202
  </Modal>
@@ -1,21 +1,27 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
3
  export default StyleSheet.create({
4
+ attribution: {
5
+ flexDirection: 'row',
6
+ gap: 4,
7
+ justifyContent: 'flex-end',
8
+ paddingVertical: 8
9
+ },
4
10
  menu: {
5
- position: 'absolute',
6
- zIndex: 1000,
7
- left: 0,
8
11
  backgroundColor: 'white',
9
12
  borderRadius: 8,
10
- paddingVertical: 4
13
+ left: 0,
14
+ paddingVertical: 4,
15
+ position: 'absolute',
16
+ zIndex: 1000
11
17
  },
12
18
  overlay: {
13
- position: 'absolute',
14
- top: 0,
19
+ backgroundColor: 'transparent',
15
20
  bottom: 0,
16
21
  left: 0,
22
+ position: 'absolute',
17
23
  right: 0,
18
- backgroundColor: 'transparent'
24
+ top: 0
19
25
  },
20
26
  overlayTouchable: {
21
27
  flex: 1
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.14.2",
5
+ "version": "1.14.3",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [