@hoddy-ui/core 2.5.16 → 2.5.18
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/package.json +1 -1
- package/src/Components/Popup.tsx +1 -1
- package/src/Components/SelectMenu.tsx +29 -52
- package/src/Components/TextField.tsx +5 -3
- package/src/hooks.ts +0 -1
- package/src/types.ts +3 -0
package/package.json
CHANGED
package/src/Components/Popup.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MaterialIcons } from "@expo/vector-icons";
|
|
2
2
|
import React, { useCallback, useState } from "react";
|
|
3
|
-
import { FlatList,
|
|
3
|
+
import { FlatList, TouchableOpacity, View } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { ScaledSheet } from "react-native-size-matters";
|
|
6
6
|
import { useColors } from "../hooks";
|
|
7
7
|
import { SelectMenuProps } from "../types";
|
|
8
|
-
import
|
|
8
|
+
import { Popup } from "./Popup";
|
|
9
9
|
import TextField from "./TextField";
|
|
10
10
|
import Typography from "./Typography";
|
|
11
11
|
|
|
@@ -19,22 +19,15 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
19
19
|
label,
|
|
20
20
|
secondary,
|
|
21
21
|
helperText,
|
|
22
|
+
searchEnabled = false,
|
|
23
|
+
searchPlaceholder = "Search",
|
|
22
24
|
}) => {
|
|
23
25
|
const colors = useColors();
|
|
24
26
|
const { bottom } = useSafeAreaInsets();
|
|
25
27
|
|
|
26
28
|
const [search, setSearch] = useState("");
|
|
27
29
|
const styles: any = ScaledSheet.create({
|
|
28
|
-
root: {
|
|
29
|
-
backgroundColor: colors.white[1],
|
|
30
|
-
flex: 1,
|
|
31
|
-
},
|
|
32
|
-
content: {
|
|
33
|
-
flex: 1,
|
|
34
|
-
paddingHorizontal: "10@ms",
|
|
35
|
-
},
|
|
36
30
|
header: {
|
|
37
|
-
paddingTop: "80@ms",
|
|
38
31
|
marginBottom: "20@vs",
|
|
39
32
|
},
|
|
40
33
|
|
|
@@ -46,11 +39,6 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
46
39
|
alignItems: "center",
|
|
47
40
|
marginBottom: "10@vs",
|
|
48
41
|
},
|
|
49
|
-
footer: {
|
|
50
|
-
paddingBottom: bottom,
|
|
51
|
-
paddingHorizontal: "15@ms",
|
|
52
|
-
paddingTop: "15@ms",
|
|
53
|
-
},
|
|
54
42
|
});
|
|
55
43
|
|
|
56
44
|
const renderItem = useCallback(
|
|
@@ -70,6 +58,7 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
70
58
|
{item.start && <View style={{ marginRight: 10 }}>{item.start}</View>}
|
|
71
59
|
<View style={{ flex: 1 }}>
|
|
72
60
|
<Typography
|
|
61
|
+
variant="body2"
|
|
73
62
|
style={{
|
|
74
63
|
color: item.value === value ? colors.blue.light : colors.black[2],
|
|
75
64
|
}}
|
|
@@ -102,51 +91,39 @@ const SelectMenu: React.FC<SelectMenuProps> = ({
|
|
|
102
91
|
[value, colors]
|
|
103
92
|
);
|
|
104
93
|
return (
|
|
105
|
-
<
|
|
106
|
-
<View style={styles.
|
|
107
|
-
<View style={styles.
|
|
108
|
-
|
|
109
|
-
<Typography variant="
|
|
110
|
-
{
|
|
94
|
+
<Popup open={open} onClose={onClose} title={label}>
|
|
95
|
+
<View style={styles.content}>
|
|
96
|
+
<View style={styles.header}>
|
|
97
|
+
{helperText && (
|
|
98
|
+
<Typography variant="body2" color="textSecondary" gutterBottom={5}>
|
|
99
|
+
{helperText}
|
|
111
100
|
</Typography>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{helperText}
|
|
115
|
-
</Typography>
|
|
116
|
-
) : null}
|
|
117
|
-
|
|
101
|
+
)}
|
|
102
|
+
{searchEnabled && (
|
|
118
103
|
<TextField
|
|
119
|
-
label=
|
|
104
|
+
label={searchPlaceholder}
|
|
120
105
|
value={search}
|
|
121
106
|
type="search"
|
|
122
107
|
onChangeText={setSearch}
|
|
123
108
|
variant="outlined"
|
|
124
109
|
/>
|
|
125
|
-
|
|
126
|
-
<FlatList
|
|
127
|
-
removeClippedSubviews
|
|
128
|
-
keyExtractor={(item) => item.value}
|
|
129
|
-
renderItem={renderItem}
|
|
130
|
-
data={options
|
|
131
|
-
.filter((item) =>
|
|
132
|
-
search.length > 1
|
|
133
|
-
? item.label.toLowerCase().indexOf(search.toLowerCase()) > -1
|
|
134
|
-
: item
|
|
135
|
-
)
|
|
136
|
-
.sort((a, b) => a.label.localeCompare(b.label))}
|
|
137
|
-
/>
|
|
138
|
-
</View>
|
|
139
|
-
<View style={styles.footer}>
|
|
140
|
-
<Button
|
|
141
|
-
color="error"
|
|
142
|
-
variant="outlined"
|
|
143
|
-
fullWidth
|
|
144
|
-
title="Close"
|
|
145
|
-
onPress={onClose}
|
|
146
|
-
/>
|
|
110
|
+
)}
|
|
147
111
|
</View>
|
|
112
|
+
<FlatList
|
|
113
|
+
removeClippedSubviews
|
|
114
|
+
keyExtractor={(item) => item.value}
|
|
115
|
+
bounces={false}
|
|
116
|
+
renderItem={renderItem}
|
|
117
|
+
data={options
|
|
118
|
+
.filter((item) =>
|
|
119
|
+
search.length > 1
|
|
120
|
+
? item.label.toLowerCase().indexOf(search.toLowerCase()) > -1
|
|
121
|
+
: item
|
|
122
|
+
)
|
|
123
|
+
.sort((a, b) => a.label.localeCompare(b.label))}
|
|
124
|
+
/>
|
|
148
125
|
</View>
|
|
149
|
-
</
|
|
126
|
+
</Popup>
|
|
150
127
|
);
|
|
151
128
|
};
|
|
152
129
|
|
|
@@ -5,15 +5,13 @@ import {
|
|
|
5
5
|
ScaledSheet,
|
|
6
6
|
moderateScale,
|
|
7
7
|
ms,
|
|
8
|
-
mvs,
|
|
9
8
|
verticalScale,
|
|
10
9
|
} from "react-native-size-matters";
|
|
11
|
-
import { getConfig } from "../config/KeyManager";
|
|
12
10
|
import { useColors } from "../hooks";
|
|
13
11
|
import { TextFieldProps } from "../types";
|
|
12
|
+
import { getFontFamily } from "../utility";
|
|
14
13
|
import SelectMenu from "./SelectMenu";
|
|
15
14
|
import Typography from "./Typography";
|
|
16
|
-
import { getFontFamily } from "../utility";
|
|
17
15
|
|
|
18
16
|
const TextField: React.FC<TextFieldProps> = ({
|
|
19
17
|
label,
|
|
@@ -37,6 +35,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
37
35
|
gutterBottom = 0,
|
|
38
36
|
end,
|
|
39
37
|
options,
|
|
38
|
+
selectMenuProps,
|
|
40
39
|
...props
|
|
41
40
|
}) => {
|
|
42
41
|
const colors = useColors();
|
|
@@ -271,6 +270,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
271
270
|
label={label}
|
|
272
271
|
helperText={helperText}
|
|
273
272
|
onChange={onChangeText!}
|
|
273
|
+
{...selectMenuProps}
|
|
274
274
|
/>
|
|
275
275
|
)}
|
|
276
276
|
</>
|
|
@@ -302,6 +302,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
302
302
|
end,
|
|
303
303
|
options,
|
|
304
304
|
multiline,
|
|
305
|
+
selectMenuProps,
|
|
305
306
|
...props
|
|
306
307
|
},
|
|
307
308
|
ref
|
|
@@ -517,6 +518,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
|
|
|
517
518
|
label={label}
|
|
518
519
|
helperText={helperText}
|
|
519
520
|
onChange={onChangeText!}
|
|
521
|
+
{...selectMenuProps}
|
|
520
522
|
/>
|
|
521
523
|
)}
|
|
522
524
|
</>
|
package/src/hooks.ts
CHANGED
|
@@ -41,7 +41,6 @@ export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
|
|
|
41
41
|
tabBarStyle: {
|
|
42
42
|
borderTopColor: theme === "dark" ? colors.light.main : colors.white[2],
|
|
43
43
|
borderTopWidth: 1,
|
|
44
|
-
paddingBottom: bottom,
|
|
45
44
|
backgroundColor: colors.white[1],
|
|
46
45
|
},
|
|
47
46
|
tabBarActiveTintColor: colors.blue.main,
|
package/src/types.ts
CHANGED
|
@@ -253,6 +253,7 @@ export interface TextFieldProps extends TextInputProps {
|
|
|
253
253
|
}[];
|
|
254
254
|
onFocus?: () => void;
|
|
255
255
|
onBlur?: () => void;
|
|
256
|
+
selectMenuProps?: Partial<SelectMenuProps>;
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
export interface TypographyProps extends TextProps {
|
|
@@ -294,6 +295,8 @@ export interface SelectMenuProps {
|
|
|
294
295
|
label?: string;
|
|
295
296
|
secondary?: string;
|
|
296
297
|
helperText?: string;
|
|
298
|
+
searchEnabled?: boolean;
|
|
299
|
+
searchPlaceholder?: string;
|
|
297
300
|
}
|
|
298
301
|
|
|
299
302
|
export interface OTPInputProps {
|