@hoddy-ui/core 2.5.40 → 2.5.43
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/dist/index.d.mts +13 -2
- package/next/dist/index.d.ts +13 -2
- package/next/dist/index.js +64 -58
- package/next/dist/index.js.map +1 -1
- package/next/dist/index.mjs +82 -76
- package/next/dist/index.mjs.map +1 -1
- package/next/package.json +1 -1
- package/package.json +1 -1
- package/src/Components/FormWrapper.tsx +51 -44
- package/src/Components/Typography.tsx +22 -14
- package/src/config/KeyManager.ts +14 -0
- package/src/config/index.ts +21 -0
package/next/package.json
CHANGED
package/package.json
CHANGED
|
@@ -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,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
|
{
|
|
@@ -25,18 +38,13 @@ const Typography: React.FC<TypographyProps> = forwardRef(
|
|
|
25
38
|
ref
|
|
26
39
|
) => {
|
|
27
40
|
const colors: any = useColors();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
body1: ms(15),
|
|
36
|
-
body2: ms(12),
|
|
37
|
-
caption: ms(10),
|
|
38
|
-
};
|
|
39
|
-
const f = fontSize || _fontSize[variant];
|
|
41
|
+
const config = getConfig();
|
|
42
|
+
const customFontSizes = config.TYPOGRAPHY?.fontSizes;
|
|
43
|
+
|
|
44
|
+
// Get font size: prop > config > default, then apply ms() scaling
|
|
45
|
+
const baseFontSize =
|
|
46
|
+
customFontSizes?.[variant] ?? DEFAULT_FONT_SIZES[variant];
|
|
47
|
+
const f = fontSize || baseFontSize;
|
|
40
48
|
const styles: any = StyleSheet.create({
|
|
41
49
|
text: {
|
|
42
50
|
lineHeight: f * 1.2,
|
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
|
|