@hoddy-ui/core 2.5.5 → 2.5.7

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/next/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/next",
3
- "version": "2.0.47",
3
+ "version": "2.0.48",
4
4
  "description": "Core rich react native components written in typescript, with support for expo-router",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -19,8 +19,9 @@
19
19
  },
20
20
  "peerDependencies": {
21
21
  "@expo/vector-icons": ">=13.0.0",
22
+ "@react-native-async-storage/async-storage": ">=1.18.1",
22
23
  "@types/react": ">=18.2.6",
23
- "@types/react-native": "^0.72.0",
24
+ "@types/react-native": ">=0.72.0",
24
25
  "expo-haptics": ">=12.4.0",
25
26
  "expo-location": ">=15.1.1",
26
27
  "expo-navigation-bar": ">=2.1.1",
@@ -28,6 +29,7 @@
28
29
  "expo-system-ui": ">=2.2.1",
29
30
  "react": ">=18.2.0",
30
31
  "react-native": ">=0.71.8",
32
+ "react-native-reanimated": ">=3.17.4",
31
33
  "react-native-safe-area-context": ">=4.5.3",
32
34
  "typescript": ">=5.0.4"
33
35
  },
@@ -39,7 +41,6 @@
39
41
  "kinghoddy"
40
42
  ],
41
43
  "dependencies": {
42
- "@react-native-async-storage/async-storage": "^1.18.1",
43
44
  "react-native-size-matters": "^0.4.0"
44
45
  },
45
46
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -13,6 +13,7 @@
13
13
  "private": false,
14
14
  "peerDependencies": {
15
15
  "@expo/vector-icons": ">=13.0.0",
16
+ "@react-native-async-storage/async-storage": ">=1.18.1",
16
17
  "@react-navigation/native": ">=6.1.6",
17
18
  "@types/react": ">=18.2.6",
18
19
  "@types/react-native": ">=0.72.0",
@@ -34,7 +35,6 @@
34
35
  "kinghoddy"
35
36
  ],
36
37
  "dependencies": {
37
- "@react-native-async-storage/async-storage": "^1.18.1",
38
38
  "react-native-size-matters": "^0.4.2"
39
39
  },
40
40
  "publishConfig": {
@@ -1,7 +1,7 @@
1
1
  import { MaterialIcons } from "@expo/vector-icons";
2
2
  import React from "react";
3
3
  import { View } from "react-native";
4
- import { ScaledSheet } from "react-native-size-matters";
4
+ import { ms, ScaledSheet } from "react-native-size-matters";
5
5
  import { useColors } from "../hooks";
6
6
  import { AlertXProps } from "../types";
7
7
  import Typography from "./Typography";
@@ -16,7 +16,7 @@ const AlertX: React.FC<AlertXProps> = ({
16
16
  }) => {
17
17
  const colors = useColors();
18
18
 
19
- const styles: any = ScaledSheet.create({
19
+ const styles = ScaledSheet.create({
20
20
  container: {
21
21
  padding: 20,
22
22
  paddingTop: 10,
@@ -24,7 +24,7 @@ const AlertX: React.FC<AlertXProps> = ({
24
24
  borderRadius: 8,
25
25
  alignItems: "center",
26
26
  flexDirection: "row",
27
- marginBottom: gutterBottom + "@ms",
27
+ marginBottom: ms(gutterBottom),
28
28
  backgroundColor: colors[type].main + (variant === "contained" ? "" : "3"),
29
29
  },
30
30
  title: {
@@ -35,7 +35,7 @@ const AlertX: React.FC<AlertXProps> = ({
35
35
  },
36
36
  });
37
37
  return (
38
- <View style={{ ...styles.container, ...style }}>
38
+ <View style={[styles.container, style]}>
39
39
  <View style={{ width: "80%" }}>
40
40
  <Typography style={styles.title} gutterBottom={3} fontWeight={700}>
41
41
  {title}
@@ -1,7 +1,7 @@
1
1
  import { AntDesign } from "@expo/vector-icons";
2
2
  import React from "react";
3
3
  import { Image, View } from "react-native";
4
- import { ScaledSheet } from "react-native-size-matters";
4
+ import { ms, ScaledSheet } from "react-native-size-matters";
5
5
  import { useColors } from "../hooks";
6
6
  import { AvatarProps } from "../types";
7
7
  import Typography from "./Typography";
@@ -18,8 +18,8 @@ const Avatar: React.FC<AvatarProps> = ({
18
18
  const styles: any = ScaledSheet.create({
19
19
  root: {
20
20
  borderRadius: 150,
21
- height: size + "@ms",
22
- width: size + "@ms",
21
+ height: ms(size),
22
+ width: ms(size),
23
23
  alignItems: "center",
24
24
  justifyContent: "center",
25
25
  overflow: "hidden",
@@ -27,7 +27,7 @@ const Avatar: React.FC<AvatarProps> = ({
27
27
  borderColor: variant === "outlined" ? "#fff" : "#0000",
28
28
  backgroundColor:
29
29
  variant === "outlined"
30
- ? null
30
+ ? undefined
31
31
  : label
32
32
  ? colors[color].main
33
33
  : colors.white[4],
@@ -5,13 +5,14 @@ import { ScaledSheet, moderateScale, ms } from "react-native-size-matters";
5
5
  import { getConfig } from "../config/KeyManager";
6
6
  import { useColors, useTheme } from "../hooks";
7
7
  import { ButtonProps, IconButtonProps, LinkButtonProps } from "../types";
8
+ import { getFontFamily } from "../utility";
8
9
 
9
10
  export const LinkButton: React.FC<LinkButtonProps> = ({
10
11
  title,
11
12
  style = {},
12
13
  color = "blue",
13
14
  fontSize = 12,
14
- fontWeight = "400",
15
+ fontWeight = 400,
15
16
  disabled,
16
17
  onPress = () => {},
17
18
  }) => {
@@ -20,8 +21,8 @@ export const LinkButton: React.FC<LinkButtonProps> = ({
20
21
  const styles: any = ScaledSheet.create({
21
22
  text: {
22
23
  fontSize: moderateScale(fontSize),
23
- fontWeight: fontWeight as any,
24
- fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
24
+ fontWeight: fontWeight.toString() as any,
25
+ fontFamily: getFontFamily(fontWeight),
25
26
  color: disabled ? "#777" : colors[color].main,
26
27
  },
27
28
  });
@@ -156,7 +157,7 @@ const Button: React.FC<ButtonProps> = forwardRef(
156
157
  ],
157
158
  fontWeight: variant === "outlined" ? "700" : "500",
158
159
  fontSize: size === "small" ? "12@ms" : "13@ms",
159
- fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
160
+ fontFamily: getFontFamily(variant === "outlined" ? 700 : 500),
160
161
  },
161
162
  });
162
163
 
@@ -1,6 +1,6 @@
1
- import { View, Text } from "react-native";
2
1
  import React from "react";
3
- import { ScaledSheet } from "react-native-size-matters";
2
+ import { View } from "react-native";
3
+ import { ms, ScaledSheet } from "react-native-size-matters";
4
4
  import { GridItemProps, GridProps } from "../types";
5
5
 
6
6
  export const GridItem: React.FC<GridItemProps> = ({
@@ -12,8 +12,8 @@ export const GridItem: React.FC<GridItemProps> = ({
12
12
  }) => {
13
13
  const styles = ScaledSheet.create({
14
14
  gridItem: {
15
- width: 100 / col + "%",
16
- padding: spacing * 10 + "@ms",
15
+ width: `${100 / col}%`,
16
+ padding: ms(spacing * 10),
17
17
  alignItems: alignItems,
18
18
  },
19
19
  });
@@ -27,7 +27,7 @@ export const Grid: React.FC<GridProps> = ({
27
27
  const styles = ScaledSheet.create({
28
28
  grid: {
29
29
  flexWrap: "wrap",
30
- margin: -spacing * 10 + "@ms",
30
+ margin: `${-spacing * 10}@ms`,
31
31
  flexDirection: "row",
32
32
  },
33
33
  });
@@ -115,6 +115,7 @@ export const Locator: React.FC<LocatorProps> = ({
115
115
  shadowRadius: float ? 15 : 0,
116
116
  shadowOffset: {
117
117
  height: 10,
118
+ width: 0,
118
119
  },
119
120
  borderRadius: 10,
120
121
  marginBottom: 10,
@@ -11,6 +11,7 @@ import {
11
11
 
12
12
  import React, { useEffect, useState } from "react";
13
13
  import Animated, {
14
+ LinearTransition,
14
15
  runOnJS,
15
16
  useAnimatedStyle,
16
17
  useSharedValue,
@@ -27,7 +28,7 @@ export const Popup: React.FC<PopupProps> = ({
27
28
  title,
28
29
  sheet,
29
30
  bare = false,
30
- keyboardVerticalOffset,
31
+ keyboardVerticalOffset = -10,
31
32
  children,
32
33
  open,
33
34
  onClose = () => {},
@@ -81,9 +82,12 @@ export const Popup: React.FC<PopupProps> = ({
81
82
  width: "100%",
82
83
  justifyContent: sheet ? "flex-end" : "center",
83
84
  },
85
+ keyboardView: {
86
+ flex: 1,
87
+ },
84
88
  avoidingView: {
85
89
  minHeight: typeof sheet === "number" ? sheet : undefined,
86
- maxHeight: "80%",
90
+ maxHeight: "90%",
87
91
  zIndex: 1000,
88
92
  alignSelf: "center",
89
93
  maxWidth: sheet ? undefined : "90%",
@@ -91,7 +95,7 @@ export const Popup: React.FC<PopupProps> = ({
91
95
  },
92
96
  container: {
93
97
  paddingBottom: sheet ? "30@ms" : undefined,
94
- backgroundColor: theme === "dark" ? "#111" : colors.white[2],
98
+ backgroundColor: theme === "dark" ? "#111" : colors.white[1],
95
99
  borderTopLeftRadius: 20,
96
100
  borderTopRightRadius: 20,
97
101
  borderBottomRightRadius: sheet ? 0 : 20,
@@ -134,22 +138,29 @@ export const Popup: React.FC<PopupProps> = ({
134
138
  onRequestClose={closeAction}
135
139
  >
136
140
  <UIThemeProvider>
137
- <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
138
- <View style={styles.root}>
139
- <Animated.View style={[styles.backdrop, backdropAnimatedStyle]} />
140
- {open && (
141
- <Pressable
142
- style={[StyleSheet.absoluteFill, { zIndex: 2 }]}
143
- onPress={closeAction}
144
- />
145
- )}
141
+ <KeyboardAvoidingView
142
+ style={styles.keyboardView}
143
+ behavior={Platform.OS === "ios" ? "padding" : undefined}
144
+ keyboardVerticalOffset={keyboardVerticalOffset}
145
+ >
146
+ <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
147
+ <View style={styles.root}>
148
+ <Animated.View style={[styles.backdrop, backdropAnimatedStyle]} />
149
+ {open && (
150
+ <Pressable
151
+ style={[StyleSheet.absoluteFill, { zIndex: 2 }]}
152
+ onPress={closeAction}
153
+ />
154
+ )}
146
155
 
147
- <Animated.View style={[styles.avoidingView, contentAnimatedStyle]}>
148
- <KeyboardAvoidingView
149
- keyboardVerticalOffset={keyboardVerticalOffset}
150
- behavior={Platform.OS === "ios" ? "position" : "padding"}
156
+ <Animated.View
157
+ style={[styles.avoidingView, contentAnimatedStyle]}
158
+ layout={LinearTransition}
151
159
  >
152
- <View style={styles.container}>
160
+ <Animated.View
161
+ layout={LinearTransition}
162
+ style={styles.container}
163
+ >
153
164
  {!bare && (
154
165
  <View style={styles.title}>
155
166
  <View style={styles.titleIcon}>
@@ -166,11 +177,11 @@ export const Popup: React.FC<PopupProps> = ({
166
177
  )}
167
178
 
168
179
  <View style={styles.content}>{children}</View>
169
- </View>
170
- </KeyboardAvoidingView>
171
- </Animated.View>
172
- </View>
173
- </TouchableWithoutFeedback>
180
+ </Animated.View>
181
+ </Animated.View>
182
+ </View>
183
+ </TouchableWithoutFeedback>
184
+ </KeyboardAvoidingView>
174
185
  </UIThemeProvider>
175
186
  </Modal>
176
187
  );
@@ -5,6 +5,7 @@ import {
5
5
  ScaledSheet,
6
6
  moderateScale,
7
7
  ms,
8
+ mvs,
8
9
  verticalScale,
9
10
  } from "react-native-size-matters";
10
11
  import { getConfig } from "../config/KeyManager";
@@ -12,6 +13,7 @@ import { useColors } from "../hooks";
12
13
  import { TextFieldProps } from "../types";
13
14
  import SelectMenu from "./SelectMenu";
14
15
  import Typography from "./Typography";
16
+ import { getFontFamily } from "../utility";
15
17
 
16
18
  const TextField: React.FC<TextFieldProps> = ({
17
19
  label,
@@ -64,7 +66,7 @@ const TextField: React.FC<TextFieldProps> = ({
64
66
  }, [focused, value]);
65
67
  const styles: any = ScaledSheet.create({
66
68
  root: {
67
- marginBottom: gutterBottom + "@vs",
69
+ marginBottom: ms(gutterBottom),
68
70
  width: "100%",
69
71
  ...style,
70
72
  },
@@ -98,7 +100,7 @@ const TextField: React.FC<TextFieldProps> = ({
98
100
  paddingLeft: variant === "text" ? 0 : moderateScale(15),
99
101
  paddingRight: moderateScale(10),
100
102
  paddingTop: "11@vs",
101
- fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
103
+ fontFamily: getFontFamily(400),
102
104
  color: colors.black[1],
103
105
  zIndex: 10,
104
106
  // backgroundColor: "#284",
@@ -110,7 +112,7 @@ const TextField: React.FC<TextFieldProps> = ({
110
112
  paddingTop: "13@ms",
111
113
  },
112
114
  label: {
113
- fontFamily: getConfig().DEFAULT_FONT_FAMILY || "System",
115
+ fontFamily: getFontFamily(400),
114
116
  position: "absolute",
115
117
  left: variant === "text" ? 0 : moderateScale(15),
116
118
  fontSize: focused || value ? "10@s" : "13@s",
@@ -279,6 +281,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
279
281
  (
280
282
  {
281
283
  label,
284
+ labelProps,
282
285
  keyboardType,
283
286
  color = "primary",
284
287
  value,
@@ -317,7 +320,7 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
317
320
 
318
321
  const styles: any = ScaledSheet.create({
319
322
  root: {
320
- marginBottom: gutterBottom + "@vs",
323
+ marginBottom: ms(gutterBottom),
321
324
  ...style,
322
325
  },
323
326
  container: {
@@ -409,7 +412,12 @@ export const TextField2 = React.forwardRef<TextInput, TextFieldProps>(
409
412
  <>
410
413
  <View style={styles.root}>
411
414
  {label && (
412
- <Typography variant="body1" color="textSecondary" gutterBottom={7}>
415
+ <Typography
416
+ variant="body2"
417
+ color="textSecondary"
418
+ gutterBottom={7}
419
+ {...labelProps}
420
+ >
413
421
  {label}
414
422
  </Typography>
415
423
  )}
@@ -4,6 +4,7 @@ import { moderateScale, ms, verticalScale } from "react-native-size-matters";
4
4
  import { useColors } from "../hooks";
5
5
  import { TypographyProps } from "../types";
6
6
  import { getConfig } from "../config/KeyManager";
7
+ import { getFontFamily } from "../utility";
7
8
 
8
9
  const Typography: React.FC<TypographyProps> = forwardRef(
9
10
  (
@@ -45,11 +46,7 @@ const Typography: React.FC<TypographyProps> = forwardRef(
45
46
  alignItems: "center",
46
47
  textAlign: align,
47
48
  fontWeight: fontWeight,
48
- fontFamily:
49
- fontFamily ||
50
- getConfig().TYPOGRAPHY?.fontWeights?.[fontWeight] ||
51
- getConfig().TYPOGRAPHY?.fontFamily ||
52
- undefined, // Use custom font if provided, else default
49
+ fontFamily: fontFamily || getFontFamily(fontWeight),
53
50
  },
54
51
  });
55
52
 
package/src/types.ts CHANGED
@@ -2,6 +2,7 @@ import { ReactNode } from "react";
2
2
  import {
3
3
  NativeScrollEvent,
4
4
  NativeSyntheticEvent,
5
+ StyleProp,
5
6
  TextInputProps,
6
7
  TextProps,
7
8
  TextStyle,
@@ -117,7 +118,7 @@ export interface LinkButtonProps {
117
118
  style?: TextStyle & ViewStyle;
118
119
  color?: colorTypes;
119
120
  fontSize?: number;
120
- fontWeight?: string;
121
+ fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
121
122
  disabled?: boolean;
122
123
  onPress?: () => void;
123
124
  }
@@ -229,6 +230,7 @@ export interface SpinnerProps {
229
230
 
230
231
  export interface TextFieldProps extends TextInputProps {
231
232
  label?: string;
233
+ labelProps?: TypographyProps;
232
234
  variant?: "outlined" | "text" | "contained";
233
235
  color?: colorTypes;
234
236
  size?: "small" | "normal" | "large";
@@ -256,7 +258,7 @@ export interface TextFieldProps extends TextInputProps {
256
258
  export interface TypographyProps extends TextProps {
257
259
  children: ReactNode;
258
260
  color?: colorTypes | (string & {});
259
- style?: TextStyle | ViewStyle;
261
+ style?: StyleProp<TextStyle | ViewStyle>;
260
262
  textCase?: "capitalize" | "uppercase" | "lowercase" | undefined;
261
263
  variant?:
262
264
  | "caption"
package/src/utility.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { getConfig } from "./config/KeyManager";
2
+
3
+ export const getFontFamily = (
4
+ fontWeight: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
5
+ ) => {
6
+ return (
7
+ getConfig().TYPOGRAPHY?.fontWeights?.[fontWeight] ||
8
+ getConfig().TYPOGRAPHY?.fontFamily ||
9
+ undefined
10
+ );
11
+ };