@korsolutions/ui 0.0.85 → 0.0.86
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/AGENTS.md +3 -3
- package/dist/module/components/alert-dialog/components/alert-dialog-root.js +1 -1
- package/dist/module/components/alert-dialog/components/alert-dialog-root.js.map +1 -1
- package/dist/module/components/alert-dialog/variants/default.js +93 -85
- package/dist/module/components/alert-dialog/variants/default.js.map +1 -1
- package/dist/module/components/button/button.js +1 -1
- package/dist/module/components/button/button.js.map +1 -1
- package/dist/module/components/button/variants/default.js +48 -44
- package/dist/module/components/button/variants/default.js.map +1 -1
- package/dist/module/components/button/variants/ghost.js +64 -60
- package/dist/module/components/button/variants/ghost.js.map +1 -1
- package/dist/module/components/button/variants/secondary.js +66 -62
- package/dist/module/components/button/variants/secondary.js.map +1 -1
- package/dist/module/components/combobox/components/combobox-root.js +1 -1
- package/dist/module/components/combobox/components/combobox-root.js.map +1 -1
- package/dist/module/components/combobox/variants/default.js +91 -88
- package/dist/module/components/combobox/variants/default.js.map +1 -1
- package/dist/module/components/icon-button/icon-button.js +4 -5
- package/dist/module/components/icon-button/icon-button.js.map +1 -1
- package/dist/module/components/icon-button/variants/default.js +31 -24
- package/dist/module/components/icon-button/variants/default.js.map +1 -1
- package/dist/module/components/icon-button/variants/ghost.js +32 -25
- package/dist/module/components/icon-button/variants/ghost.js.map +1 -1
- package/dist/module/components/icon-button/variants/secondary.js +34 -27
- package/dist/module/components/icon-button/variants/secondary.js.map +1 -1
- package/dist/module/components/input/input.js +1 -1
- package/dist/module/components/input/input.js.map +1 -1
- package/dist/module/components/input/variants/default.js +39 -37
- package/dist/module/components/input/variants/default.js.map +1 -1
- package/dist/module/components/input/variants/secondary.js +39 -37
- package/dist/module/components/input/variants/secondary.js.map +1 -1
- package/dist/module/components/phone-input/components/phone-input-root.js +2 -1
- package/dist/module/components/phone-input/components/phone-input-root.js.map +1 -1
- package/dist/module/components/phone-input/variants/default.js +115 -112
- package/dist/module/components/phone-input/variants/default.js.map +1 -1
- package/dist/module/components/select/components/select-root.js +1 -1
- package/dist/module/components/select/components/select-root.js.map +1 -1
- package/dist/module/components/select/variants/default.js +75 -73
- package/dist/module/components/select/variants/default.js.map +1 -1
- package/dist/module/themes/default/index.js +1 -0
- package/dist/module/themes/default/index.js.map +1 -1
- package/dist/module/themes/provider.js +1 -0
- package/dist/module/themes/provider.js.map +1 -1
- package/dist/module/themes/utils.js +2 -1
- package/dist/module/themes/utils.js.map +1 -1
- package/dist/module/utils/size-scale.js +42 -0
- package/dist/module/utils/size-scale.js.map +1 -0
- package/dist/module/utils/use-themed-styles.js +4 -1
- package/dist/module/utils/use-themed-styles.js.map +1 -1
- package/dist/typescript/src/components/alert-dialog/components/alert-dialog-root.d.ts +2 -0
- package/dist/typescript/src/components/alert-dialog/components/alert-dialog-root.d.ts.map +1 -1
- package/dist/typescript/src/components/alert-dialog/variants/default.d.ts +3 -2
- package/dist/typescript/src/components/alert-dialog/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/alert-dialog/variants/index.d.ts +1 -1
- package/dist/typescript/src/components/button/button.d.ts +2 -0
- package/dist/typescript/src/components/button/button.d.ts.map +1 -1
- package/dist/typescript/src/components/button/variants/default.d.ts +2 -1
- package/dist/typescript/src/components/button/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/button/variants/ghost.d.ts +2 -1
- package/dist/typescript/src/components/button/variants/ghost.d.ts.map +1 -1
- package/dist/typescript/src/components/button/variants/index.d.ts +3 -3
- package/dist/typescript/src/components/button/variants/secondary.d.ts +2 -1
- package/dist/typescript/src/components/button/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts +2 -0
- package/dist/typescript/src/components/combobox/components/combobox-root.d.ts.map +1 -1
- package/dist/typescript/src/components/combobox/variants/default.d.ts +2 -1
- package/dist/typescript/src/components/combobox/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/icon-button/icon-button.d.ts +2 -1
- package/dist/typescript/src/components/icon-button/icon-button.d.ts.map +1 -1
- package/dist/typescript/src/components/icon-button/variants/default.d.ts +2 -1
- package/dist/typescript/src/components/icon-button/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/icon-button/variants/ghost.d.ts +2 -1
- package/dist/typescript/src/components/icon-button/variants/ghost.d.ts.map +1 -1
- package/dist/typescript/src/components/icon-button/variants/index.d.ts +3 -3
- package/dist/typescript/src/components/icon-button/variants/secondary.d.ts +2 -1
- package/dist/typescript/src/components/icon-button/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/input/input.d.ts +2 -0
- package/dist/typescript/src/components/input/input.d.ts.map +1 -1
- package/dist/typescript/src/components/input/variants/default.d.ts +2 -1
- package/dist/typescript/src/components/input/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/input/variants/secondary.d.ts +3 -2
- package/dist/typescript/src/components/input/variants/secondary.d.ts.map +1 -1
- package/dist/typescript/src/components/phone-input/components/phone-input-root.d.ts +3 -1
- package/dist/typescript/src/components/phone-input/components/phone-input-root.d.ts.map +1 -1
- package/dist/typescript/src/components/phone-input/variants/default.d.ts +2 -1
- package/dist/typescript/src/components/phone-input/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/select/components/select-root.d.ts +2 -0
- package/dist/typescript/src/components/select/components/select-root.d.ts.map +1 -1
- package/dist/typescript/src/components/select/variants/default.d.ts +3 -2
- package/dist/typescript/src/components/select/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/index.d.ts +2 -0
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/themes/default/index.d.ts.map +1 -1
- package/dist/typescript/src/themes/provider.d.ts +1 -0
- package/dist/typescript/src/themes/provider.d.ts.map +1 -1
- package/dist/typescript/src/themes/types.d.ts +1 -0
- package/dist/typescript/src/themes/types.d.ts.map +1 -1
- package/dist/typescript/src/themes/utils.d.ts.map +1 -1
- package/dist/typescript/src/utils/size-scale.d.ts +20 -0
- package/dist/typescript/src/utils/size-scale.d.ts.map +1 -0
- package/dist/typescript/src/utils/use-themed-styles.d.ts +5 -0
- package/dist/typescript/src/utils/use-themed-styles.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/alert-dialog/components/alert-dialog-root.tsx +3 -1
- package/src/components/alert-dialog/variants/default.tsx +88 -79
- package/src/components/button/button.tsx +3 -1
- package/src/components/button/variants/default.tsx +14 -10
- package/src/components/button/variants/ghost.tsx +14 -10
- package/src/components/button/variants/secondary.tsx +14 -10
- package/src/components/combobox/components/combobox-root.tsx +3 -1
- package/src/components/combobox/variants/default.tsx +17 -14
- package/src/components/icon-button/icon-button.tsx +6 -6
- package/src/components/icon-button/variants/default.tsx +12 -6
- package/src/components/icon-button/variants/ghost.tsx +12 -6
- package/src/components/icon-button/variants/secondary.tsx +12 -6
- package/src/components/input/input.tsx +3 -1
- package/src/components/input/variants/default.tsx +11 -9
- package/src/components/input/variants/secondary.tsx +12 -10
- package/src/components/phone-input/components/phone-input-root.tsx +4 -1
- package/src/components/phone-input/variants/default.tsx +21 -18
- package/src/components/select/components/select-root.tsx +3 -1
- package/src/components/select/variants/default.tsx +16 -14
- package/src/index.tsx +2 -0
- package/src/themes/default/index.ts +1 -0
- package/src/themes/provider.tsx +2 -0
- package/src/themes/types.ts +1 -0
- package/src/themes/utils.ts +1 -0
- package/src/utils/size-scale.ts +45 -0
- package/src/utils/use-themed-styles.ts +8 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import { type ComboboxStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export function useComboboxVariantDefault(): ComboboxStyles {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export function useComboboxVariantDefault(size: Size): ComboboxStyles {
|
|
7
|
+
return useThemedStyles(({ colors, radius, fontFamily, sizeScale }): ComboboxStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
root: {
|
|
9
12
|
default: {},
|
|
10
13
|
disabled: {},
|
|
@@ -20,10 +23,10 @@ export function useComboboxVariantDefault(): ComboboxStyles {
|
|
|
20
23
|
backgroundColor: colors.surface,
|
|
21
24
|
justifyContent: "center",
|
|
22
25
|
paddingVertical: 4,
|
|
23
|
-
paddingHorizontal:
|
|
24
|
-
minHeight:
|
|
26
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
27
|
+
minHeight: s.height,
|
|
25
28
|
fontFamily,
|
|
26
|
-
fontSize,
|
|
29
|
+
fontSize: s.fontSize,
|
|
27
30
|
color: colors.foreground,
|
|
28
31
|
outlineWidth: 0,
|
|
29
32
|
pointerEvents: "auto",
|
|
@@ -69,10 +72,10 @@ export function useComboboxVariantDefault(): ComboboxStyles {
|
|
|
69
72
|
},
|
|
70
73
|
option: {
|
|
71
74
|
default: {
|
|
72
|
-
paddingVertical:
|
|
73
|
-
paddingHorizontal:
|
|
75
|
+
paddingVertical: s.paddingVertical,
|
|
76
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
74
77
|
fontFamily,
|
|
75
|
-
fontSize,
|
|
78
|
+
fontSize: s.fontSize,
|
|
76
79
|
color: colors.foreground,
|
|
77
80
|
borderRadius: radius / 2,
|
|
78
81
|
},
|
|
@@ -88,15 +91,15 @@ export function useComboboxVariantDefault(): ComboboxStyles {
|
|
|
88
91
|
},
|
|
89
92
|
empty: {
|
|
90
93
|
default: {
|
|
91
|
-
paddingVertical:
|
|
92
|
-
paddingHorizontal:
|
|
94
|
+
paddingVertical: s.paddingVertical,
|
|
95
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
93
96
|
fontFamily,
|
|
94
|
-
fontSize,
|
|
97
|
+
fontSize: s.fontSize,
|
|
95
98
|
color: colors.mutedForeground,
|
|
96
99
|
textAlign: "center",
|
|
97
100
|
},
|
|
98
101
|
disabled: {},
|
|
99
102
|
},
|
|
100
|
-
}
|
|
101
|
-
);
|
|
103
|
+
};
|
|
104
|
+
});
|
|
102
105
|
}
|
|
@@ -9,14 +9,15 @@ import {
|
|
|
9
9
|
import { useComponentConfig } from "../../themes/provider";
|
|
10
10
|
import type { SvgProps } from "../../types/props.types";
|
|
11
11
|
import { mergeStyles } from "../../utils/calculate-styles";
|
|
12
|
+
import type { Size } from "../../utils/size-scale";
|
|
12
13
|
import type { IconButtonState } from "./types";
|
|
13
14
|
import { IconButtonVariants } from "./variants";
|
|
14
15
|
|
|
15
16
|
export interface IconButtonProps extends Omit<PressableProps, "disabled" | "children"> {
|
|
16
17
|
render: (props: SvgProps) => React.ReactNode;
|
|
17
18
|
variant?: keyof typeof IconButtonVariants;
|
|
19
|
+
size?: Size;
|
|
18
20
|
isDisabled?: boolean;
|
|
19
|
-
size?: number;
|
|
20
21
|
color?: SvgProps["color"];
|
|
21
22
|
strokeWidth?: number;
|
|
22
23
|
style?: StyleProp<ViewStyle>;
|
|
@@ -37,15 +38,15 @@ export function IconButton(props: IconButtonProps) {
|
|
|
37
38
|
const {
|
|
38
39
|
render: IconComponent,
|
|
39
40
|
variant = "default",
|
|
41
|
+
size = "md",
|
|
40
42
|
isDisabled,
|
|
41
|
-
size,
|
|
42
43
|
color,
|
|
43
44
|
strokeWidth,
|
|
44
45
|
style,
|
|
45
46
|
...rest
|
|
46
47
|
} = props;
|
|
47
48
|
|
|
48
|
-
const variantStyles = IconButtonVariants[variant]();
|
|
49
|
+
const variantStyles = IconButtonVariants[variant](size);
|
|
49
50
|
const componentConfig = useComponentConfig("iconButton");
|
|
50
51
|
const mergedStyles = mergeStyles(variantStyles, componentConfig?.styles);
|
|
51
52
|
|
|
@@ -61,10 +62,9 @@ export function IconButton(props: IconButtonProps) {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
const iconProps: SvgProps = {
|
|
64
|
-
size:
|
|
65
|
+
size: mergedStyles.icon?.default?.size,
|
|
65
66
|
color: color ?? mergedStyles.icon?.[state]?.color ?? mergedStyles.icon?.default?.color,
|
|
66
|
-
strokeWidth,
|
|
67
|
-
absoluteStrokeWidth: true,
|
|
67
|
+
strokeWidth: strokeWidth ?? mergedStyles.icon?.default?.strokeWidth,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
return (
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { hslaSetRelativeLightness } from "../../../utils/hsla-utils";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import type { IconButtonStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export const useIconButtonVariantDefault = (): IconButtonStyles => {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export const useIconButtonVariantDefault = (size: Size): IconButtonStyles => {
|
|
7
|
+
return useThemedStyles(({ colors, radius, sizeScale }): IconButtonStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
root: {
|
|
9
12
|
default: {
|
|
10
13
|
alignItems: "center",
|
|
11
14
|
justifyContent: "center",
|
|
12
|
-
|
|
15
|
+
height: s.height,
|
|
16
|
+
width: s.height,
|
|
13
17
|
borderRadius: radius,
|
|
14
18
|
backgroundColor: colors.primary,
|
|
15
19
|
borderWidth: 1,
|
|
@@ -25,8 +29,10 @@ export const useIconButtonVariantDefault = (): IconButtonStyles => {
|
|
|
25
29
|
icon: {
|
|
26
30
|
default: {
|
|
27
31
|
color: colors.primaryForeground,
|
|
32
|
+
size: s.iconSize,
|
|
33
|
+
strokeWidth: s.strokeWidth,
|
|
28
34
|
},
|
|
29
35
|
},
|
|
30
|
-
}
|
|
31
|
-
);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
32
38
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { hslaSetRelativeLightness } from "../../../utils/hsla-utils";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import type { IconButtonStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export const useIconButtonVariantGhost = (): IconButtonStyles => {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export const useIconButtonVariantGhost = (size: Size): IconButtonStyles => {
|
|
7
|
+
return useThemedStyles(({ colors, radius, sizeScale }): IconButtonStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
root: {
|
|
9
12
|
default: {
|
|
10
13
|
alignItems: "center",
|
|
11
14
|
justifyContent: "center",
|
|
12
|
-
|
|
15
|
+
height: s.height,
|
|
16
|
+
width: s.height,
|
|
13
17
|
borderRadius: radius,
|
|
14
18
|
backgroundColor: "transparent",
|
|
15
19
|
},
|
|
@@ -23,11 +27,13 @@ export const useIconButtonVariantGhost = (): IconButtonStyles => {
|
|
|
23
27
|
icon: {
|
|
24
28
|
default: {
|
|
25
29
|
color: colors.foreground,
|
|
30
|
+
size: s.iconSize,
|
|
31
|
+
strokeWidth: s.strokeWidth,
|
|
26
32
|
},
|
|
27
33
|
disabled: {
|
|
28
34
|
color: colors.mutedForeground,
|
|
29
35
|
},
|
|
30
36
|
},
|
|
31
|
-
}
|
|
32
|
-
);
|
|
37
|
+
};
|
|
38
|
+
});
|
|
33
39
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { hslaSetRelativeLightness } from "../../../utils/hsla-utils";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import type { IconButtonStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export const useIconButtonVariantSecondary = (): IconButtonStyles => {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export const useIconButtonVariantSecondary = (size: Size): IconButtonStyles => {
|
|
7
|
+
return useThemedStyles(({ colors, radius, sizeScale }): IconButtonStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
root: {
|
|
9
12
|
default: {
|
|
10
13
|
alignItems: "center",
|
|
11
14
|
justifyContent: "center",
|
|
12
|
-
|
|
15
|
+
height: s.height,
|
|
16
|
+
width: s.height,
|
|
13
17
|
borderRadius: radius,
|
|
14
18
|
borderWidth: 1,
|
|
15
19
|
borderColor: colors.border,
|
|
@@ -25,11 +29,13 @@ export const useIconButtonVariantSecondary = (): IconButtonStyles => {
|
|
|
25
29
|
icon: {
|
|
26
30
|
default: {
|
|
27
31
|
color: colors.secondaryForeground,
|
|
32
|
+
size: s.iconSize,
|
|
33
|
+
strokeWidth: s.strokeWidth,
|
|
28
34
|
},
|
|
29
35
|
disabled: {
|
|
30
36
|
color: colors.mutedForeground,
|
|
31
37
|
},
|
|
32
38
|
},
|
|
33
|
-
}
|
|
34
|
-
);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
35
41
|
};
|
|
@@ -3,12 +3,14 @@ import { StyleSheet, TextInput, type TextInputProps } from "react-native";
|
|
|
3
3
|
import { useComponentConfig } from "../../themes/provider";
|
|
4
4
|
import type { TextInputRef } from "../../types/element.types";
|
|
5
5
|
import { mergeStyles } from "../../utils/calculate-styles";
|
|
6
|
+
import type { Size } from "../../utils/size-scale";
|
|
6
7
|
import { useFieldOptional } from "../field/context";
|
|
7
8
|
import type { InputState } from "./types";
|
|
8
9
|
import { InputVariants } from "./variants";
|
|
9
10
|
|
|
10
11
|
export type InputProps = Omit<TextInputProps, "onChange" | "onChangeText"> & {
|
|
11
12
|
variant?: keyof typeof InputVariants;
|
|
13
|
+
size?: Size;
|
|
12
14
|
|
|
13
15
|
ref?: React.Ref<TextInputRef>;
|
|
14
16
|
onChange?: TextInputProps["onChangeText"];
|
|
@@ -26,7 +28,7 @@ const calculateState = (props: InputProps, isFocused: boolean): InputState => {
|
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export const Input = forwardRef<TextInputRef, InputProps>((props, ref) => {
|
|
29
|
-
const variantStyles = InputVariants[props.variant || "default"]();
|
|
31
|
+
const variantStyles = InputVariants[props.variant || "default"](props.size ?? "md");
|
|
30
32
|
const componentConfig = useComponentConfig("input");
|
|
31
33
|
const mergedStyles = mergeStyles(variantStyles, componentConfig?.styles);
|
|
32
34
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import { type InputStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export function useInputVariantDefault(): InputStyles {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export function useInputVariantDefault(size: Size): InputStyles {
|
|
7
|
+
return useThemedStyles(({ colors, radius, fontFamily, sizeScale }): InputStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
default: {
|
|
9
12
|
placeholderTextColor: colors.mutedForeground,
|
|
10
13
|
selectionColor: colors.primary,
|
|
@@ -13,11 +16,10 @@ export function useInputVariantDefault(): InputStyles {
|
|
|
13
16
|
borderColor: colors.border,
|
|
14
17
|
borderRadius: radius,
|
|
15
18
|
backgroundColor: colors.surface,
|
|
16
|
-
|
|
17
|
-
paddingHorizontal: 16,
|
|
19
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
18
20
|
fontFamily,
|
|
19
|
-
fontSize,
|
|
20
|
-
height:
|
|
21
|
+
fontSize: s.fontSize,
|
|
22
|
+
height: s.height,
|
|
21
23
|
color: colors.foreground,
|
|
22
24
|
outlineWidth: 0,
|
|
23
25
|
...Platform.select({
|
|
@@ -39,6 +41,6 @@ export function useInputVariantDefault(): InputStyles {
|
|
|
39
41
|
backgroundColor: colors.muted,
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
44
46
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
|
-
import {
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
3
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
4
|
+
import { type InputStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export function useInputVariantSecondary(): InputStyles {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export function useInputVariantSecondary(size: Size): InputStyles {
|
|
7
|
+
return useThemedStyles(({ colors, radius, fontFamily, sizeScale }): InputStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
default: {
|
|
9
12
|
placeholderTextColor: colors.mutedForeground,
|
|
10
13
|
selectionColor: colors.primary,
|
|
@@ -13,11 +16,10 @@ export function useInputVariantSecondary(): InputStyles {
|
|
|
13
16
|
borderColor: colors.border,
|
|
14
17
|
borderRadius: radius,
|
|
15
18
|
backgroundColor: colors.background,
|
|
16
|
-
|
|
17
|
-
paddingHorizontal: 16,
|
|
19
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
18
20
|
fontFamily,
|
|
19
|
-
fontSize,
|
|
20
|
-
height:
|
|
21
|
+
fontSize: s.fontSize,
|
|
22
|
+
height: s.height,
|
|
21
23
|
color: colors.foreground,
|
|
22
24
|
outlineWidth: 0,
|
|
23
25
|
...Platform.select({
|
|
@@ -39,6 +41,6 @@ export function useInputVariantSecondary(): InputStyles {
|
|
|
39
41
|
backgroundColor: colors.muted,
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
44
46
|
}
|
|
@@ -5,6 +5,7 @@ import { usePhoneMask } from "../../../hooks/use-phone-mask";
|
|
|
5
5
|
import { useComponentConfig } from "../../../themes/provider";
|
|
6
6
|
import type { ViewRef } from "../../../types/element.types";
|
|
7
7
|
import { mergeStyles } from "../../../utils/calculate-styles";
|
|
8
|
+
import type { Size } from "../../../utils/size-scale";
|
|
8
9
|
import { PhoneInputContext } from "../context";
|
|
9
10
|
import type { PhoneInputState } from "../types";
|
|
10
11
|
import { PhoneInputVariants } from "../variants";
|
|
@@ -17,6 +18,7 @@ export interface PhoneInputRootProps {
|
|
|
17
18
|
countryCodes?: CountryCode[];
|
|
18
19
|
isDisabled?: boolean;
|
|
19
20
|
variant?: keyof typeof PhoneInputVariants;
|
|
21
|
+
size?: Size;
|
|
20
22
|
placeholder?: string;
|
|
21
23
|
style?: StyleProp<ViewStyle>;
|
|
22
24
|
}
|
|
@@ -35,9 +37,10 @@ export function PhoneInputRoot({
|
|
|
35
37
|
countryCodes = ["US"],
|
|
36
38
|
isDisabled = false,
|
|
37
39
|
variant = "default",
|
|
40
|
+
size = "md",
|
|
38
41
|
style,
|
|
39
42
|
}: PhoneInputRootProps) {
|
|
40
|
-
const variantStyles = PhoneInputVariants[variant]();
|
|
43
|
+
const variantStyles = PhoneInputVariants[variant](size);
|
|
41
44
|
const componentConfig = useComponentConfig("phoneInput");
|
|
42
45
|
const mergedStyles = mergeStyles(variantStyles, componentConfig?.styles);
|
|
43
46
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
3
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
4
|
import type { PhoneInputStyles } from "../types";
|
|
4
5
|
|
|
5
|
-
export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
6
|
-
return useThemedStyles(
|
|
7
|
-
|
|
6
|
+
export function usePhoneInputVariantDefault(size: Size): PhoneInputStyles {
|
|
7
|
+
return useThemedStyles(({ colors, radius, fontFamily, sizeScale }): PhoneInputStyles => {
|
|
8
|
+
const s = sizeScale(size);
|
|
9
|
+
|
|
10
|
+
return {
|
|
8
11
|
root: {
|
|
9
12
|
default: {
|
|
10
13
|
flexDirection: "row",
|
|
@@ -13,7 +16,7 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
13
16
|
borderColor: colors.border,
|
|
14
17
|
borderRadius: radius,
|
|
15
18
|
backgroundColor: colors.surface,
|
|
16
|
-
height:
|
|
19
|
+
height: s.height,
|
|
17
20
|
overflow: "hidden",
|
|
18
21
|
outlineWidth: 0,
|
|
19
22
|
},
|
|
@@ -26,18 +29,18 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
26
29
|
},
|
|
27
30
|
countryButton: {
|
|
28
31
|
default: {
|
|
29
|
-
paddingHorizontal:
|
|
32
|
+
paddingHorizontal: s.paddingHorizontal * 0.75,
|
|
30
33
|
height: "100%",
|
|
31
34
|
justifyContent: "center",
|
|
32
35
|
alignItems: "center",
|
|
33
36
|
flexDirection: "row",
|
|
34
|
-
gap:
|
|
37
|
+
gap: s.gap * 0.5,
|
|
35
38
|
},
|
|
36
39
|
},
|
|
37
40
|
countryButtonText: {
|
|
38
41
|
default: {
|
|
39
42
|
fontFamily,
|
|
40
|
-
fontSize,
|
|
43
|
+
fontSize: s.fontSize,
|
|
41
44
|
color: colors.foreground,
|
|
42
45
|
},
|
|
43
46
|
disabled: {
|
|
@@ -55,9 +58,9 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
55
58
|
input: {
|
|
56
59
|
default: {
|
|
57
60
|
flex: 1,
|
|
58
|
-
paddingHorizontal:
|
|
61
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
59
62
|
fontFamily,
|
|
60
|
-
fontSize,
|
|
63
|
+
fontSize: s.fontSize,
|
|
61
64
|
color: colors.foreground,
|
|
62
65
|
height: "100%",
|
|
63
66
|
outlineWidth: 0,
|
|
@@ -87,12 +90,12 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
87
90
|
},
|
|
88
91
|
pickerOption: {
|
|
89
92
|
default: {
|
|
90
|
-
paddingVertical:
|
|
91
|
-
paddingHorizontal:
|
|
93
|
+
paddingVertical: s.paddingVertical * 0.75,
|
|
94
|
+
paddingHorizontal: s.paddingHorizontal * 0.75,
|
|
92
95
|
borderRadius: radius / 2,
|
|
93
96
|
flexDirection: "row",
|
|
94
97
|
alignItems: "center",
|
|
95
|
-
gap:
|
|
98
|
+
gap: s.gap,
|
|
96
99
|
},
|
|
97
100
|
selected: {
|
|
98
101
|
backgroundColor: colors.muted,
|
|
@@ -101,7 +104,7 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
101
104
|
pickerOptionText: {
|
|
102
105
|
default: {
|
|
103
106
|
fontFamily,
|
|
104
|
-
fontSize,
|
|
107
|
+
fontSize: s.fontSize,
|
|
105
108
|
color: colors.foreground,
|
|
106
109
|
},
|
|
107
110
|
},
|
|
@@ -110,15 +113,15 @@ export function usePhoneInputVariantDefault(): PhoneInputStyles {
|
|
|
110
113
|
borderWidth: 1,
|
|
111
114
|
borderColor: colors.border,
|
|
112
115
|
borderRadius: radius,
|
|
113
|
-
paddingVertical:
|
|
114
|
-
paddingHorizontal:
|
|
116
|
+
paddingVertical: s.paddingVertical * 0.5,
|
|
117
|
+
paddingHorizontal: s.paddingHorizontal * 0.75,
|
|
115
118
|
fontFamily,
|
|
116
|
-
fontSize: fontSize * 0.875,
|
|
119
|
+
fontSize: s.fontSize * 0.875,
|
|
117
120
|
color: colors.foreground,
|
|
118
121
|
marginBottom: 4,
|
|
119
122
|
outlineWidth: 0,
|
|
120
123
|
},
|
|
121
124
|
},
|
|
122
|
-
}
|
|
123
|
-
);
|
|
125
|
+
};
|
|
126
|
+
});
|
|
124
127
|
}
|
|
@@ -3,6 +3,7 @@ import { type LayoutRectangle, type StyleProp, View, type ViewStyle } from "reac
|
|
|
3
3
|
import { DEFAULT_LAYOUT, DEFAULT_POSITION, type LayoutPosition } from "../../../hooks";
|
|
4
4
|
import { useComponentConfig } from "../../../themes/provider";
|
|
5
5
|
import { calculateComposedStyles, mergeStyles } from "../../../utils/calculate-styles";
|
|
6
|
+
import type { Size } from "../../../utils/size-scale";
|
|
6
7
|
import { SelectContext } from "../context";
|
|
7
8
|
import type { SelectOption, SelectState } from "../types";
|
|
8
9
|
import { SelectVariants } from "../variants";
|
|
@@ -13,6 +14,7 @@ interface SelectRootInjectedProps {
|
|
|
13
14
|
|
|
14
15
|
export interface SelectRootBaseProps {
|
|
15
16
|
variant?: keyof typeof SelectVariants;
|
|
17
|
+
size?: Size;
|
|
16
18
|
|
|
17
19
|
value?: string;
|
|
18
20
|
onChange?: (value: string) => void;
|
|
@@ -36,7 +38,7 @@ const calculateState = (props: SelectRootProps): SelectState => {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export function SelectRoot(props: SelectRootProps) {
|
|
39
|
-
const variantStyles = SelectVariants[props.variant ?? "default"]();
|
|
41
|
+
const variantStyles = SelectVariants[props.variant ?? "default"](props.size ?? "md");
|
|
40
42
|
const componentConfig = useComponentConfig("select");
|
|
41
43
|
const mergedStyles = mergeStyles(variantStyles, componentConfig?.styles);
|
|
42
44
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Size } from "../../../utils/size-scale";
|
|
2
2
|
import { useThemedStyles } from "../../../utils/use-themed-styles";
|
|
3
|
+
import { type SelectStyles } from "../types";
|
|
3
4
|
|
|
4
|
-
export function useSelectVariantDefault(): SelectStyles {
|
|
5
|
-
return useThemedStyles(
|
|
6
|
-
|
|
5
|
+
export function useSelectVariantDefault(size: Size): SelectStyles {
|
|
6
|
+
return useThemedStyles(({ colors, radius, fontFamily, sizeScale }): SelectStyles => {
|
|
7
|
+
const s = sizeScale(size);
|
|
8
|
+
|
|
9
|
+
return {
|
|
7
10
|
root: {
|
|
8
11
|
default: {},
|
|
9
12
|
disabled: {},
|
|
@@ -15,9 +18,8 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
15
18
|
borderRadius: radius,
|
|
16
19
|
backgroundColor: colors.surface,
|
|
17
20
|
justifyContent: "center",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
minHeight: 48,
|
|
21
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
22
|
+
minHeight: s.height,
|
|
21
23
|
},
|
|
22
24
|
disabled: {
|
|
23
25
|
backgroundColor: colors.muted,
|
|
@@ -26,7 +28,7 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
26
28
|
value: {
|
|
27
29
|
default: {
|
|
28
30
|
fontFamily,
|
|
29
|
-
fontSize,
|
|
31
|
+
fontSize: s.fontSize,
|
|
30
32
|
color: colors.foreground,
|
|
31
33
|
},
|
|
32
34
|
disabled: {
|
|
@@ -36,7 +38,7 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
36
38
|
placeholder: {
|
|
37
39
|
default: {
|
|
38
40
|
fontFamily,
|
|
39
|
-
fontSize,
|
|
41
|
+
fontSize: s.fontSize,
|
|
40
42
|
color: colors.mutedForeground,
|
|
41
43
|
},
|
|
42
44
|
disabled: {
|
|
@@ -63,10 +65,10 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
63
65
|
},
|
|
64
66
|
option: {
|
|
65
67
|
default: {
|
|
66
|
-
paddingVertical:
|
|
67
|
-
paddingHorizontal:
|
|
68
|
+
paddingVertical: s.paddingVertical,
|
|
69
|
+
paddingHorizontal: s.paddingHorizontal,
|
|
68
70
|
fontFamily,
|
|
69
|
-
fontSize,
|
|
71
|
+
fontSize: s.fontSize,
|
|
70
72
|
color: colors.foreground,
|
|
71
73
|
borderRadius: radius / 2,
|
|
72
74
|
},
|
|
@@ -80,6 +82,6 @@ export function useSelectVariantDefault(): SelectStyles {
|
|
|
80
82
|
backgroundColor: colors.muted,
|
|
81
83
|
},
|
|
82
84
|
},
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
+
};
|
|
86
|
+
});
|
|
85
87
|
}
|
package/src/index.tsx
CHANGED
package/src/themes/provider.tsx
CHANGED
|
@@ -21,6 +21,7 @@ interface ThemeContext {
|
|
|
21
21
|
colorScheme: ColorScheme;
|
|
22
22
|
letterSpacing: LetterSpacing;
|
|
23
23
|
fontSize: FontSize;
|
|
24
|
+
spacing: number;
|
|
24
25
|
setColorScheme: (scheme: ColorScheme) => void;
|
|
25
26
|
components?: ComponentsConfig;
|
|
26
27
|
}
|
|
@@ -52,6 +53,7 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
|
|
|
52
53
|
fontFamily: themeAssets.fontFamily,
|
|
53
54
|
letterSpacing: themeAssets.letterSpacing,
|
|
54
55
|
fontSize: themeAssets.fontSize,
|
|
56
|
+
spacing: themeAssets.spacing,
|
|
55
57
|
components,
|
|
56
58
|
}}
|
|
57
59
|
>
|
package/src/themes/types.ts
CHANGED
package/src/themes/utils.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type Size = "sm" | "md" | "lg";
|
|
2
|
+
|
|
3
|
+
interface SizeScaleValues {
|
|
4
|
+
/** spacing * 1 | 1.5 | 2 */
|
|
5
|
+
paddingVertical: number;
|
|
6
|
+
/** spacing * 1.5 | 2 | 3 */
|
|
7
|
+
paddingHorizontal: number;
|
|
8
|
+
/** spacing * 0.75 | 1 | 1.25 */
|
|
9
|
+
gap: number;
|
|
10
|
+
/** fontSize * 0.875 | 1 | 1.125 */
|
|
11
|
+
fontSize: number;
|
|
12
|
+
/** fontSize * 0.875 | 1 | 1.125 (alias for icon sizing) */
|
|
13
|
+
iconSize: number;
|
|
14
|
+
/** 1.75 | 2 | 2.25 */
|
|
15
|
+
strokeWidth: number;
|
|
16
|
+
/** spacing * 4.5 | 6 | 7.5 */
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const scales: Record<
|
|
21
|
+
Size,
|
|
22
|
+
{ pv: number; ph: number; gap: number; fontScale: number; sw: number; h: number }
|
|
23
|
+
> = {
|
|
24
|
+
sm: { pv: 1, ph: 1.5, gap: 0.75, fontScale: 0.875, sw: 1.75, h: 4.5 },
|
|
25
|
+
md: { pv: 1.5, ph: 2, gap: 1, fontScale: 1, sw: 2, h: 6 },
|
|
26
|
+
lg: { pv: 2, ph: 3, gap: 1.25, fontScale: 1.125, sw: 2.25, h: 7.5 },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function getSizeScale(
|
|
30
|
+
size: Size = "md",
|
|
31
|
+
spacing: number,
|
|
32
|
+
fontSize: number,
|
|
33
|
+
): SizeScaleValues {
|
|
34
|
+
const s = scales[size] ?? scales.md;
|
|
35
|
+
const scaledFontSize = fontSize * s.fontScale;
|
|
36
|
+
return {
|
|
37
|
+
paddingVertical: spacing * s.pv,
|
|
38
|
+
paddingHorizontal: spacing * s.ph,
|
|
39
|
+
gap: spacing * s.gap,
|
|
40
|
+
fontSize: scaledFontSize,
|
|
41
|
+
iconSize: scaledFontSize,
|
|
42
|
+
strokeWidth: s.sw,
|
|
43
|
+
height: spacing * s.h,
|
|
44
|
+
};
|
|
45
|
+
}
|