@widergy/mobile-ui 1.4.4 → 1.4.6

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,20 @@
1
+ ## [1.4.6](https://github.com/widergy/mobile-ui/compare/v1.4.5...v1.4.6) (2024-04-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * allow autocomplete custom behaviour ([#273](https://github.com/widergy/mobile-ui/issues/273)) ([775faf0](https://github.com/widergy/mobile-ui/commit/775faf02c9ed0f184a150d735735dd0a40cd8753))
7
+
8
+ ## [1.4.5](https://github.com/widergy/mobile-ui/compare/v1.4.4...v1.4.5) (2024-04-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * goback ([1f85d68](https://github.com/widergy/mobile-ui/commit/1f85d682b0966087e7273a8bfa3d859eeabcb5c5))
14
+ * margin password field ([de3c51a](https://github.com/widergy/mobile-ui/commit/de3c51a8d4dc38e67754dfdb9e1420cef3776ea5))
15
+ * topbar ([f49a436](https://github.com/widergy/mobile-ui/commit/f49a436235a4635ae24e59df39984231ff8d2d73))
16
+ * utheader styles ([926250f](https://github.com/widergy/mobile-ui/commit/926250ff3ceccac50b75eb861b5b4fc1cecab23e))
17
+
1
18
  ## [1.4.4](https://github.com/widergy/mobile-ui/compare/v1.4.3...v1.4.4) (2024-04-18)
2
19
 
3
20
 
@@ -1,4 +1,4 @@
1
- import { arrayOf, bool, func, oneOf, shape, string } from 'prop-types';
1
+ import { arrayOf, bool, element, func, oneOf, shape, string } from 'prop-types';
2
2
  import React, { useMemo } from 'react';
3
3
  import { View } from 'react-native';
4
4
 
@@ -8,9 +8,19 @@ import UTTextInput from '../UTTextInput';
8
8
 
9
9
  import styles from './styles';
10
10
 
11
- const UTAutocomplete = ({ input, options, disabled, label, error, variant, autoCompletePlaceholder }) => {
11
+ const UTAutocomplete = ({
12
+ input,
13
+ options,
14
+ disabled,
15
+ label,
16
+ error,
17
+ variant,
18
+ autoCompletePlaceholder,
19
+ MenuOptionComponent,
20
+ filterOptions
21
+ }) => {
12
22
  const selectedOption = useMemo(
13
- () => options.find(option => option.value === input.value),
23
+ () => options?.find(option => option.value === input.value),
14
24
  [options, input.value]
15
25
  );
16
26
 
@@ -29,8 +39,11 @@ const UTAutocomplete = ({ input, options, disabled, label, error, variant, autoC
29
39
  onOpen={input.onFocus}
30
40
  onClose={input.onBlur}
31
41
  disabled={disabled}
42
+ onQueryChange={input.onQueryChange}
32
43
  autoCompletePlaceholder={autoCompletePlaceholder}
33
44
  maxHeight={WINDOW_HEIGHT * 0.25}
45
+ MenuOptionComponent={MenuOptionComponent}
46
+ filterOptions={filterOptions}
34
47
  >
35
48
  <UTTextInput
36
49
  variant={variant}
@@ -64,7 +77,9 @@ UTAutocomplete.propTypes = {
64
77
  label: string,
65
78
  error: oneOf([bool, string]),
66
79
  variant: string,
67
- autoCompletePlaceholder: string
80
+ autoCompletePlaceholder: string,
81
+ MenuOptionComponent: element,
82
+ filterOptions: bool
68
83
  };
69
84
 
70
85
  export default UTAutocomplete;
@@ -18,35 +18,52 @@ const UTHeader = ({ tagline, title, subtitle, requiredFieldInfo, helpText, useMa
18
18
 
19
19
  const Tagline = renderComponent(
20
20
  tagline,
21
- <Label disabled bold useMarkdown={useMarkdown} style={themedStyles.child}>
21
+ <Label
22
+ color={themedStyles.taglineColor || theme.colors.disabled}
23
+ bold
24
+ useMarkdown={useMarkdown}
25
+ style={[themedStyles.child, themedStyles.tagline]}
26
+ >
22
27
  {tagline?.toUpperCase?.()}
23
28
  </Label>
24
29
  );
25
30
 
26
31
  const Title = renderComponent(
27
32
  title,
28
- <Label big bold style={themedStyles.title} useMarkdown={useMarkdown}>
33
+ <Label color={themedStyles.titleColor} big bold style={themedStyles.title} useMarkdown={useMarkdown}>
29
34
  {title}
30
35
  </Label>
31
36
  );
32
37
 
33
38
  const Subtitle = renderComponent(
34
39
  subtitle,
35
- <Label disabled useMarkdown={useMarkdown} style={themedStyles.child}>
40
+ <Label
41
+ color={themedStyles.subtitleColor || theme.colors.disabled}
42
+ useMarkdown={useMarkdown}
43
+ style={[themedStyles.child, themedStyles.subtitle]}
44
+ >
36
45
  {subtitle}
37
46
  </Label>
38
47
  );
39
48
 
40
49
  const RequiredFieldInfo = renderComponent(
41
50
  requiredFieldInfo,
42
- <Label disabled useMarkdown={useMarkdown} style={themedStyles.child}>
51
+ <Label
52
+ color={themedStyles.requiredFieldInfoColor || theme.colors.disabled}
53
+ useMarkdown={useMarkdown}
54
+ style={[themedStyles.child, themedStyles.requiredFieldInfo]}
55
+ >
43
56
  {requiredFieldInfo}
44
57
  </Label>
45
58
  );
46
59
 
47
60
  const HelpText = renderComponent(
48
61
  helpText,
49
- <Label disabled useMarkdown={useMarkdown} style={themedStyles.child}>
62
+ <Label
63
+ color={themedStyles.helpTextColor || theme.colors.disabled}
64
+ useMarkdown={useMarkdown}
65
+ style={[themedStyles.child, themedStyles.helpText]}
66
+ >
50
67
  {helpText}
51
68
  </Label>
52
69
  );
@@ -27,6 +27,8 @@ const UTMenu = ({
27
27
  maxHeight,
28
28
  isMultiple,
29
29
  autoCompletePlaceholder,
30
+ onQueryChange,
31
+ filterOptions = true,
30
32
  withAutocomplete
31
33
  }) => {
32
34
  const [isOpen, setIsOpen] = useState(false);
@@ -37,10 +39,11 @@ const UTMenu = ({
37
39
  const [menuDimentions, setMenuDimentions] = useState({ width: 0, height: 0 });
38
40
  const [query, setQuery] = useState('');
39
41
  const searchTextInputRef = useRef();
40
- const filteredOptions = useMemo(
41
- () => options.filter(option => !query || option.label.toUpperCase().includes(query.toUpperCase())),
42
- [query, options]
43
- );
42
+ const filteredOptions = useMemo(() => {
43
+ return filterOptions
44
+ ? options.filter(option => !query || option.label.toUpperCase().includes(query.toUpperCase()))
45
+ : options;
46
+ }, [query, options, filterOptions]);
44
47
 
45
48
  const { height: windowHeight, width: windowWidth } = Dimensions.get('window');
46
49
 
@@ -97,6 +100,11 @@ const UTMenu = ({
97
100
 
98
101
  const focusSearchInput = () => withAutocomplete && searchTextInputRef.current?.focus();
99
102
 
103
+ const handleQueryChange = value => {
104
+ setQuery(value);
105
+ onQueryChange(value);
106
+ };
107
+
100
108
  return (
101
109
  <>
102
110
  <TouchableOpacity
@@ -129,7 +137,7 @@ const UTMenu = ({
129
137
  <UTTextInput
130
138
  InputRef={searchTextInputRef}
131
139
  value={query}
132
- onChange={setQuery}
140
+ onChange={handleQueryChange}
133
141
  placeholder={autoCompletePlaceholder}
134
142
  onSubmitEditing={
135
143
  query && filteredOptions[0]
@@ -6,6 +6,7 @@ export default StyleSheet.create({
6
6
  alignItems: 'center'
7
7
  },
8
8
  label: {
9
+ marginBottom: 8,
9
10
  marginLeft: 10
10
11
  }
11
12
  });
@@ -1,7 +1,6 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { BackHandler, View } from 'react-native';
3
3
  import { number } from 'prop-types';
4
- // eslint-disable-next-line import/no-extraneous-dependencies
5
4
  import { useFocusEffect } from '@react-navigation/native';
6
5
 
7
6
  import IconButton from '../IconButton';
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.4.4",
5
+ "version": "1.4.6",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [