@hoddy-ui/core 2.5.40 → 2.5.45
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/index.ts +1 -2
- package/next/dist/index.d.mts +165 -6
- package/next/dist/index.d.ts +165 -6
- package/next/dist/index.js +628 -83
- package/next/dist/index.js.map +1 -1
- package/next/dist/index.mjs +679 -97
- package/next/dist/index.mjs.map +1 -1
- package/next/index.ts +3 -0
- package/next/package.json +1 -1
- package/package.json +1 -1
- package/src/Components/Animators/hooks/useFloatAnimation.ts +16 -13
- package/src/Components/FormWrapper.tsx +51 -44
- package/src/Components/SafeAreaView.tsx +18 -15
- package/src/Components/Typography.tsx +25 -15
- package/src/config/KeyManager.ts +14 -0
- package/src/config/index.ts +21 -0
- package/src/types.ts +3 -2
package/next/index.ts
CHANGED
|
@@ -27,6 +27,9 @@ export * from "../src/hooks";
|
|
|
27
27
|
export * from "../src/theme";
|
|
28
28
|
export * from "../src/types";
|
|
29
29
|
|
|
30
|
+
export * from "../src/Components/Animators/hooks";
|
|
31
|
+
export * from "../src/Components/Animators/Animator";
|
|
32
|
+
|
|
30
33
|
const HoddyUI = {
|
|
31
34
|
initialize: initialize,
|
|
32
35
|
};
|
package/next/package.json
CHANGED
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { useEffect, useRef } from "react";
|
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
Easing,
|
|
5
|
+
runOnJS,
|
|
5
6
|
useAnimatedStyle,
|
|
6
7
|
useSharedValue,
|
|
7
8
|
withDelay,
|
|
@@ -76,22 +77,24 @@ export const useFloatAnimation = ({
|
|
|
76
77
|
opacity.value = withDelay(
|
|
77
78
|
delay,
|
|
78
79
|
withTiming(1, { duration }, () => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (closeAfter) {
|
|
82
|
-
opacity.value = withDelay(
|
|
83
|
-
closeAfter,
|
|
84
|
-
withTiming(0, { duration: closeDuration })
|
|
85
|
-
);
|
|
86
|
-
translateY.value = withDelay(
|
|
87
|
-
closeAfter,
|
|
88
|
-
withTiming(0, { duration: closeDuration })
|
|
89
|
-
);
|
|
90
|
-
isFloating.current = false;
|
|
91
|
-
}
|
|
80
|
+
"worklet";
|
|
81
|
+
runOnJS(startFloating)();
|
|
92
82
|
})
|
|
93
83
|
);
|
|
94
84
|
|
|
85
|
+
// Handle auto-close
|
|
86
|
+
if (closeAfter) {
|
|
87
|
+
const totalDelay = delay + duration + closeAfter;
|
|
88
|
+
opacity.value = withDelay(
|
|
89
|
+
totalDelay,
|
|
90
|
+
withTiming(0, { duration: closeDuration })
|
|
91
|
+
);
|
|
92
|
+
translateY.value = withDelay(
|
|
93
|
+
totalDelay,
|
|
94
|
+
withTiming(0, { duration: closeDuration })
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
95
98
|
return () => {
|
|
96
99
|
opacity.value = 0;
|
|
97
100
|
translateY.value = 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Keyboard,
|
|
4
4
|
KeyboardAvoidingView,
|
|
@@ -6,56 +6,63 @@ import {
|
|
|
6
6
|
ScrollView,
|
|
7
7
|
TouchableWithoutFeedback,
|
|
8
8
|
} from "react-native";
|
|
9
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
9
10
|
import { ScaledSheet } from "react-native-size-matters";
|
|
10
11
|
import { FormWrapperProps } from "../types";
|
|
11
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
12
|
-
export const FormWrapper: React.FC<FormWrapperProps> = ({
|
|
13
|
-
children,
|
|
14
|
-
behavior = Platform.OS === "ios" ? "padding" : "height",
|
|
15
|
-
contentContainerStyle,
|
|
16
|
-
mode = "scroll",
|
|
17
|
-
keyboardVerticalOffset = 10,
|
|
18
|
-
style = {},
|
|
19
|
-
onScroll,
|
|
20
|
-
}) => {
|
|
21
|
-
const { bottom } = useSafeAreaInsets();
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
export const FormWrapper = forwardRef<ScrollView, FormWrapperProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
children,
|
|
17
|
+
behavior = Platform.OS === "ios" ? "padding" : "height",
|
|
18
|
+
contentContainerStyle,
|
|
19
|
+
mode = "scroll",
|
|
20
|
+
keyboardVerticalOffset = 10,
|
|
21
|
+
style = {},
|
|
22
|
+
onScroll,
|
|
29
23
|
},
|
|
30
|
-
|
|
24
|
+
ref
|
|
25
|
+
) => {
|
|
26
|
+
const { bottom } = useSafeAreaInsets();
|
|
27
|
+
|
|
28
|
+
const defaultOffset = Platform.OS === "ios" ? -bottom : -bottom * 2;
|
|
29
|
+
const styles = ScaledSheet.create({
|
|
30
|
+
root: {
|
|
31
|
+
width: "100%",
|
|
32
|
+
flex: 1,
|
|
33
|
+
...style,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
return mode === "static" ? (
|
|
38
|
+
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
|
|
39
|
+
<KeyboardAvoidingView
|
|
40
|
+
style={styles.root}
|
|
41
|
+
behavior={behavior}
|
|
42
|
+
contentContainerStyle={styles.root}
|
|
43
|
+
keyboardVerticalOffset={keyboardVerticalOffset || defaultOffset}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</KeyboardAvoidingView>
|
|
47
|
+
</TouchableWithoutFeedback>
|
|
48
|
+
) : (
|
|
34
49
|
<KeyboardAvoidingView
|
|
35
|
-
style={styles.root}
|
|
36
50
|
behavior={behavior}
|
|
37
|
-
|
|
51
|
+
style={styles.root}
|
|
38
52
|
keyboardVerticalOffset={keyboardVerticalOffset || defaultOffset}
|
|
39
53
|
>
|
|
40
|
-
|
|
54
|
+
<ScrollView
|
|
55
|
+
ref={ref}
|
|
56
|
+
onScroll={onScroll}
|
|
57
|
+
showsVerticalScrollIndicator={false}
|
|
58
|
+
scrollEventThrottle={40}
|
|
59
|
+
keyboardDismissMode="interactive"
|
|
60
|
+
contentContainerStyle={contentContainerStyle}
|
|
61
|
+
keyboardShouldPersistTaps="handled"
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</ScrollView>
|
|
41
65
|
</KeyboardAvoidingView>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
behavior={behavior}
|
|
46
|
-
style={styles.root}
|
|
47
|
-
keyboardVerticalOffset={keyboardVerticalOffset || defaultOffset}
|
|
48
|
-
>
|
|
49
|
-
<ScrollView
|
|
50
|
-
onScroll={onScroll}
|
|
51
|
-
showsVerticalScrollIndicator={false}
|
|
52
|
-
scrollEventThrottle={40}
|
|
53
|
-
keyboardDismissMode="interactive"
|
|
54
|
-
contentContainerStyle={contentContainerStyle}
|
|
55
|
-
keyboardShouldPersistTaps="handled"
|
|
56
|
-
>
|
|
57
|
-
{children}
|
|
58
|
-
</ScrollView>
|
|
59
|
-
</KeyboardAvoidingView>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
);
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
3
|
|
|
4
4
|
import { StyleSheet, View } from "react-native";
|
|
5
5
|
import { SafeAreaViewProps } from "../types";
|
|
6
6
|
|
|
7
|
-
export const SafeAreaView
|
|
8
|
-
children,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
export const SafeAreaView = forwardRef<View, SafeAreaViewProps>(
|
|
8
|
+
({ children, style, ...rest }, ref) => {
|
|
9
|
+
const { top, bottom } = useSafeAreaInsets();
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
root: {
|
|
12
|
+
paddingTop: top,
|
|
13
|
+
paddingBottom: bottom,
|
|
14
|
+
flex: 1,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
return (
|
|
18
|
+
<View ref={ref} style={[styles.root, style]} {...rest}>
|
|
19
|
+
{children}
|
|
20
|
+
</View>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import React, { forwardRef } from "react";
|
|
2
2
|
import { StyleSheet, Text } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { ms } from "react-native-size-matters";
|
|
4
|
+
import { getConfig } from "../config/KeyManager";
|
|
4
5
|
import { useColors } from "../hooks";
|
|
5
6
|
import { TypographyProps } from "../types";
|
|
6
|
-
import { getConfig } from "../config/KeyManager";
|
|
7
7
|
import { getFontFamily } from "../utility";
|
|
8
8
|
|
|
9
|
+
// Default font sizes (used as fallback)
|
|
10
|
+
const DEFAULT_FONT_SIZES = {
|
|
11
|
+
h1: ms(42),
|
|
12
|
+
h2: ms(37),
|
|
13
|
+
h3: ms(32),
|
|
14
|
+
h4: ms(27),
|
|
15
|
+
h5: ms(22),
|
|
16
|
+
h6: ms(17),
|
|
17
|
+
body1: ms(15),
|
|
18
|
+
body2: ms(12),
|
|
19
|
+
caption: ms(10),
|
|
20
|
+
};
|
|
21
|
+
|
|
9
22
|
const Typography: React.FC<TypographyProps> = forwardRef(
|
|
10
23
|
(
|
|
11
24
|
{
|
|
@@ -20,26 +33,23 @@ const Typography: React.FC<TypographyProps> = forwardRef(
|
|
|
20
33
|
fontWeight = 400,
|
|
21
34
|
fontFamily, // NEW PROP ADDED
|
|
22
35
|
fontSize,
|
|
36
|
+
lineHeight,
|
|
23
37
|
...props
|
|
24
38
|
},
|
|
25
39
|
ref
|
|
26
40
|
) => {
|
|
27
41
|
const colors: any = useColors();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
body2: ms(12),
|
|
37
|
-
caption: ms(10),
|
|
38
|
-
};
|
|
39
|
-
const f = fontSize || _fontSize[variant];
|
|
42
|
+
const config = getConfig();
|
|
43
|
+
const customFontSizes = config.TYPOGRAPHY?.fontSizes;
|
|
44
|
+
|
|
45
|
+
// Get font size: prop > config > default, then apply ms() scaling
|
|
46
|
+
const baseFontSize =
|
|
47
|
+
customFontSizes?.[variant] ?? DEFAULT_FONT_SIZES[variant];
|
|
48
|
+
const f = fontSize || baseFontSize;
|
|
49
|
+
const lh = lineHeight || f * 1.2;
|
|
40
50
|
const styles: any = StyleSheet.create({
|
|
41
51
|
text: {
|
|
42
|
-
lineHeight:
|
|
52
|
+
lineHeight: lh,
|
|
43
53
|
fontSize: f,
|
|
44
54
|
marginBottom: ms(gutterBottom) || 0,
|
|
45
55
|
color: colors[color]?.main || color,
|
package/src/config/KeyManager.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
type TypographyVariant =
|
|
2
|
+
| "h1"
|
|
3
|
+
| "h2"
|
|
4
|
+
| "h3"
|
|
5
|
+
| "h4"
|
|
6
|
+
| "h5"
|
|
7
|
+
| "h6"
|
|
8
|
+
| "body1"
|
|
9
|
+
| "body2"
|
|
10
|
+
| "caption";
|
|
11
|
+
|
|
1
12
|
type configTypes = {
|
|
2
13
|
GOOGLE_MAP_API_KEY?: string;
|
|
3
14
|
TYPOGRAPHY?: {
|
|
@@ -5,6 +16,9 @@ type configTypes = {
|
|
|
5
16
|
fontWeights?: {
|
|
6
17
|
[K in 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900]?: string;
|
|
7
18
|
};
|
|
19
|
+
fontSizes?: {
|
|
20
|
+
[K in TypographyVariant]?: number;
|
|
21
|
+
};
|
|
8
22
|
};
|
|
9
23
|
EDGE_TO_EDGE?: boolean;
|
|
10
24
|
};
|
package/src/config/index.ts
CHANGED
|
@@ -3,6 +3,17 @@ import { setExtraColors } from "../theme/colors";
|
|
|
3
3
|
import { extraColorTypes } from "../types";
|
|
4
4
|
import { setConfig } from "./KeyManager";
|
|
5
5
|
|
|
6
|
+
type TypographyVariant =
|
|
7
|
+
| "h1"
|
|
8
|
+
| "h2"
|
|
9
|
+
| "h3"
|
|
10
|
+
| "h4"
|
|
11
|
+
| "h5"
|
|
12
|
+
| "h6"
|
|
13
|
+
| "body1"
|
|
14
|
+
| "body2"
|
|
15
|
+
| "caption";
|
|
16
|
+
|
|
6
17
|
/**
|
|
7
18
|
* Configuration options for the Hoddy UI library
|
|
8
19
|
*
|
|
@@ -22,6 +33,12 @@ import { setConfig } from "./KeyManager";
|
|
|
22
33
|
* 500: "Inter-Medium",
|
|
23
34
|
* 600: "Inter-SemiBold",
|
|
24
35
|
* 700: "Inter-Bold"
|
|
36
|
+
* },
|
|
37
|
+
* fontSizes: {
|
|
38
|
+
* h1: 48,
|
|
39
|
+
* h2: 40,
|
|
40
|
+
* body1: 16,
|
|
41
|
+
* caption: 12
|
|
25
42
|
* }
|
|
26
43
|
* }
|
|
27
44
|
* });
|
|
@@ -42,6 +59,10 @@ type configProps = {
|
|
|
42
59
|
fontWeights?: {
|
|
43
60
|
[K in 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900]?: string;
|
|
44
61
|
};
|
|
62
|
+
/** Custom font sizes for each typography variant (values in pixels, will be scaled with ms()) */
|
|
63
|
+
fontSizes?: {
|
|
64
|
+
[K in TypographyVariant]?: number;
|
|
65
|
+
};
|
|
45
66
|
};
|
|
46
67
|
};
|
|
47
68
|
|
package/src/types.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TextInputProps,
|
|
7
7
|
TextProps,
|
|
8
8
|
TextStyle,
|
|
9
|
+
ViewProps,
|
|
9
10
|
ViewStyle,
|
|
10
11
|
} from "react-native";
|
|
11
12
|
|
|
@@ -261,6 +262,7 @@ export interface TypographyProps extends TextProps {
|
|
|
261
262
|
color?: colorTypes | (string & {});
|
|
262
263
|
style?: StyleProp<TextStyle | ViewStyle>;
|
|
263
264
|
textCase?: "capitalize" | "uppercase" | "lowercase" | undefined;
|
|
265
|
+
lineHeight?: number;
|
|
264
266
|
variant?:
|
|
265
267
|
| "caption"
|
|
266
268
|
| "body1"
|
|
@@ -280,9 +282,8 @@ export interface TypographyProps extends TextProps {
|
|
|
280
282
|
fontWeight?: 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
281
283
|
}
|
|
282
284
|
|
|
283
|
-
export interface SafeAreaViewProps {
|
|
285
|
+
export interface SafeAreaViewProps extends ViewProps {
|
|
284
286
|
children: ReactNode;
|
|
285
|
-
style?: ViewStyle;
|
|
286
287
|
}
|
|
287
288
|
|
|
288
289
|
export interface SelectMenuProps {
|