@korsolutions/ui 0.0.40 → 0.0.42
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/dist/module/components/autocomplete/variants/default.js +8 -5
- package/dist/module/components/autocomplete/variants/default.js.map +1 -1
- package/dist/module/components/button/variants/secondary.js +2 -2
- package/dist/module/components/button/variants/secondary.js.map +1 -1
- package/dist/module/components/toast/toast-manager.js +7 -4
- package/dist/module/components/toast/toast-manager.js.map +1 -1
- package/dist/module/index.js +14 -5
- package/dist/module/index.js.map +1 -1
- package/dist/module/primitives/autocomplete/autocomplete-input.js +4 -0
- package/dist/module/primitives/autocomplete/autocomplete-input.js.map +1 -1
- package/dist/module/primitives/avatar/avatar-fallback.js +2 -3
- package/dist/module/primitives/avatar/avatar-fallback.js.map +1 -1
- package/dist/module/safe-area/context.js +13 -0
- package/dist/module/safe-area/context.js.map +1 -0
- package/dist/module/safe-area/index.js +5 -0
- package/dist/module/safe-area/index.js.map +1 -0
- package/dist/module/safe-area/provider.js +26 -0
- package/dist/module/safe-area/provider.js.map +1 -0
- package/dist/module/safe-area/types.js +2 -0
- package/dist/module/safe-area/types.js.map +1 -0
- package/dist/module/themes/adapters/react-navigation.js +3 -2
- package/dist/module/themes/adapters/react-navigation.js.map +1 -1
- package/dist/module/themes/default/colors.js +28 -28
- package/dist/module/themes/default/colors.js.map +1 -1
- package/dist/module/themes/provider.js +13 -11
- package/dist/module/themes/provider.js.map +1 -1
- package/dist/module/themes/utils.js +21 -0
- package/dist/module/themes/utils.js.map +1 -0
- package/dist/typescript/src/components/autocomplete/variants/default.d.ts.map +1 -1
- package/dist/typescript/src/components/toast/toast-manager.d.ts.map +1 -1
- package/dist/typescript/src/index.d.ts +7 -1
- package/dist/typescript/src/index.d.ts.map +1 -1
- package/dist/typescript/src/primitives/autocomplete/autocomplete-input.d.ts.map +1 -1
- package/dist/typescript/src/primitives/autocomplete/types.d.ts +1 -1
- package/dist/typescript/src/primitives/autocomplete/types.d.ts.map +1 -1
- package/dist/typescript/src/primitives/avatar/avatar-fallback.d.ts +0 -1
- package/dist/typescript/src/primitives/avatar/avatar-fallback.d.ts.map +1 -1
- package/dist/typescript/src/safe-area/context.d.ts +5 -0
- package/dist/typescript/src/safe-area/context.d.ts.map +1 -0
- package/dist/typescript/src/safe-area/index.d.ts +4 -0
- package/dist/typescript/src/safe-area/index.d.ts.map +1 -0
- package/dist/typescript/src/safe-area/provider.d.ts +7 -0
- package/dist/typescript/src/safe-area/provider.d.ts.map +1 -0
- package/dist/typescript/src/safe-area/types.d.ts +10 -0
- package/dist/typescript/src/safe-area/types.d.ts.map +1 -0
- package/dist/typescript/src/themes/adapters/react-navigation.d.ts.map +1 -1
- package/dist/typescript/src/themes/provider.d.ts +5 -4
- package/dist/typescript/src/themes/provider.d.ts.map +1 -1
- package/dist/typescript/src/themes/types.d.ts +0 -1
- package/dist/typescript/src/themes/types.d.ts.map +1 -1
- package/dist/typescript/src/themes/utils.d.ts +3 -0
- package/dist/typescript/src/themes/utils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/autocomplete/variants/default.tsx +6 -3
- package/src/components/button/variants/secondary.tsx +3 -3
- package/src/components/toast/toast-manager.tsx +5 -4
- package/src/index.tsx +16 -9
- package/src/primitives/autocomplete/autocomplete-input.tsx +4 -0
- package/src/primitives/autocomplete/types.ts +1 -1
- package/src/primitives/avatar/avatar-fallback.tsx +2 -4
- package/src/safe-area/context.ts +14 -0
- package/src/safe-area/index.ts +3 -0
- package/src/safe-area/provider.tsx +28 -0
- package/src/safe-area/types.ts +10 -0
- package/src/themes/adapters/react-navigation.ts +4 -3
- package/src/themes/default/colors.ts +28 -28
- package/src/themes/provider.tsx +17 -15
- package/src/themes/types.ts +0 -1
- package/src/themes/utils.ts +14 -0
- package/dist/module/themes/themes.js +0 -7
- package/dist/module/themes/themes.js.map +0 -1
- package/dist/typescript/src/themes/themes.d.ts +0 -3
- package/dist/typescript/src/themes/themes.d.ts.map +0 -1
- package/src/themes/themes.ts +0 -6
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SafeAreaContextValue } from "./types";
|
|
2
|
+
declare const SafeAreaContext: import("react").Context<SafeAreaContextValue | null>;
|
|
3
|
+
export declare const useSafeAreaInsets: () => import("./types").SafeAreaInsets;
|
|
4
|
+
export { SafeAreaContext };
|
|
5
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/safe-area/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,QAAA,MAAM,eAAe,sDAAmD,CAAC;AAEzE,eAAO,MAAM,iBAAiB,wCAM7B,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/safe-area/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import type { SafeAreaInsets } from "./types";
|
|
3
|
+
export interface SafeAreaProviderProps extends PropsWithChildren {
|
|
4
|
+
insets?: SafeAreaInsets;
|
|
5
|
+
}
|
|
6
|
+
export declare const SafeAreaProvider: ({ children, insets }: SafeAreaProviderProps) => import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/safe-area/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,eAAO,MAAM,gBAAgB,GAAI,sBAAsB,qBAAqB,gCAmB3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/safe-area/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,cAAc,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-navigation.d.ts","sourceRoot":"","sources":["../../../../../src/themes/adapters/react-navigation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-navigation.d.ts","sourceRoot":"","sources":["../../../../../src/themes/adapters/react-navigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAKtD,wBAAgB,uBAAuB,IAAI,KAAK,CAgD/C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PropsWithChildren } from "react";
|
|
2
|
-
import type { Colors, ColorScheme, FontFamily, FontSize, LetterSpacing, Radius,
|
|
2
|
+
import type { Colors, ColorScheme, FontFamily, FontSize, LetterSpacing, Radius, ThemeAssets } from "./types";
|
|
3
3
|
interface ThemeContext {
|
|
4
4
|
colors: Colors;
|
|
5
5
|
radius: Radius;
|
|
@@ -8,11 +8,12 @@ interface ThemeContext {
|
|
|
8
8
|
letterSpacing: LetterSpacing;
|
|
9
9
|
fontSize: FontSize;
|
|
10
10
|
setColorScheme: (scheme: ColorScheme) => void;
|
|
11
|
-
setTheme: (themeName: ThemeName) => void;
|
|
12
|
-
themeName: ThemeName;
|
|
13
11
|
}
|
|
14
12
|
declare const ThemeContext: import("react").Context<ThemeContext | null>;
|
|
15
|
-
export
|
|
13
|
+
export interface ThemeProviderProps extends PropsWithChildren {
|
|
14
|
+
theme?: Partial<ThemeAssets>;
|
|
15
|
+
}
|
|
16
|
+
export declare const ThemeProvider: (props: ThemeProviderProps) => import("react").JSX.Element;
|
|
16
17
|
export declare const useTheme: () => ThemeContext;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/themes/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAG/F,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/themes/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,iBAAiB,EAAmC,MAAM,OAAO,CAAC;AAG/F,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG7G,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC/C;AAED,QAAA,MAAM,YAAY,8CAA2C,CAAC;AAE9D,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,aAAa,GAAI,OAAO,kBAAkB,gCA+BtD,CAAC;AAEF,eAAO,MAAM,QAAQ,oBAMpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/themes/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/themes/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,KAAK,KAAK,GAAG,QAAQ,MAAM,KAAK,MAAM,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC;AAElE,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,KAAK,CAAC;IAClB,UAAU,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,KAAK,CAAC;IACf,iBAAiB,EAAE,KAAK,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC;IACjB,mBAAmB,EAAE,KAAK,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,KAAK,CAAC;IACvB,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,KAAK,CAAC;CACb;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,QAAQ,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/themes/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAW/F"}
|
package/package.json
CHANGED
|
@@ -10,24 +10,27 @@ export function useAutocompleteVariantDefault(): AutocompleteStyles {
|
|
|
10
10
|
disabled: {},
|
|
11
11
|
},
|
|
12
12
|
input: {
|
|
13
|
+
placeholderTextColor: colors.mutedForeground,
|
|
14
|
+
selectionColor: colors.primary,
|
|
13
15
|
default: {
|
|
14
16
|
borderWidth: 1,
|
|
15
17
|
borderColor: colors.border,
|
|
16
18
|
borderRadius: radius,
|
|
19
|
+
backgroundColor: colors.surface,
|
|
17
20
|
paddingVertical: 12,
|
|
18
21
|
paddingHorizontal: 16,
|
|
19
|
-
|
|
22
|
+
outlineWidth: 0,
|
|
20
23
|
fontFamily,
|
|
21
24
|
fontSize,
|
|
25
|
+
height: 48,
|
|
22
26
|
color: colors.foreground,
|
|
23
|
-
backgroundColor: colors.background,
|
|
24
27
|
},
|
|
25
28
|
focused: {
|
|
26
29
|
borderColor: colors.primary,
|
|
27
30
|
},
|
|
28
31
|
disabled: {
|
|
29
|
-
backgroundColor: colors.muted,
|
|
30
32
|
color: colors.mutedForeground,
|
|
33
|
+
backgroundColor: colors.muted,
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
overlay: {
|
|
@@ -30,7 +30,7 @@ export const useButtonVariantSecondary = (): ButtonStyles => {
|
|
|
30
30
|
},
|
|
31
31
|
label: {
|
|
32
32
|
default: {
|
|
33
|
-
color: colors.
|
|
33
|
+
color: colors.secondaryForeground,
|
|
34
34
|
fontSize,
|
|
35
35
|
fontWeight: "bold",
|
|
36
36
|
fontFamily,
|
|
@@ -44,7 +44,7 @@ export const useButtonVariantSecondary = (): ButtonStyles => {
|
|
|
44
44
|
},
|
|
45
45
|
spinner: {
|
|
46
46
|
default: {
|
|
47
|
-
color: colors.
|
|
47
|
+
color: colors.secondaryForeground,
|
|
48
48
|
},
|
|
49
49
|
disabled: {
|
|
50
50
|
color: colors.mutedForeground,
|
|
@@ -53,6 +53,6 @@ export const useButtonVariantSecondary = (): ButtonStyles => {
|
|
|
53
53
|
color: colors.mutedForeground,
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
|
-
})
|
|
56
|
+
}),
|
|
57
57
|
);
|
|
58
58
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Portal } from "@/primitives/portal";
|
|
2
|
+
import { useSafeAreaInsets } from "@/safe-area";
|
|
1
3
|
import React, { useSyncExternalStore } from "react";
|
|
2
|
-
import {
|
|
4
|
+
import { StyleSheet, View } from "react-native";
|
|
3
5
|
import { ToastComponent } from "./toast";
|
|
4
6
|
import { ToastVariants } from "./variants";
|
|
5
|
-
import { Portal } from "@/primitives/portal";
|
|
6
7
|
|
|
7
8
|
export const TOAST_PORTAL_NAME = "toast-portal";
|
|
8
9
|
|
|
@@ -76,12 +77,13 @@ export const ToastAPI = {
|
|
|
76
77
|
|
|
77
78
|
export function ToastContainer() {
|
|
78
79
|
const toasts = useSyncExternalStore(subscribe, getSnapshot);
|
|
80
|
+
const insets = useSafeAreaInsets();
|
|
79
81
|
|
|
80
82
|
if (!toasts.length) return null;
|
|
81
83
|
|
|
82
84
|
return (
|
|
83
85
|
<Portal name={TOAST_PORTAL_NAME}>
|
|
84
|
-
<View style={s.wrapper}>
|
|
86
|
+
<View style={[s.wrapper, { top: insets.top + 24 }]}>
|
|
85
87
|
{toasts.map((toast) => (
|
|
86
88
|
<ToastComponent key={toast.id} title={toast.title} description={toast.description} variant={toast.variant} />
|
|
87
89
|
))}
|
|
@@ -95,7 +97,6 @@ const s = StyleSheet.create({
|
|
|
95
97
|
width: "100%",
|
|
96
98
|
alignItems: "center",
|
|
97
99
|
position: "absolute",
|
|
98
|
-
top: 24,
|
|
99
100
|
gap: 8,
|
|
100
101
|
},
|
|
101
102
|
});
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SafeAreaProvider, type SafeAreaInsets } from "@/safe-area";
|
|
2
|
+
import { ThemeProvider, type ThemeProviderProps } from "@/themes";
|
|
2
3
|
import { AsyncAlertDialogManager } from "./components/alert-dialog/async-alert-dialog";
|
|
3
4
|
import { ToastContainer } from "./components/toast/toast-manager";
|
|
4
5
|
import { PortalHost } from "./primitives/portal";
|
|
@@ -6,21 +7,27 @@ import { type PortalHostProps } from "./primitives/portal/portal.constants";
|
|
|
6
7
|
|
|
7
8
|
export interface ProviderProps {
|
|
8
9
|
children: React.ReactNode;
|
|
9
|
-
|
|
10
10
|
portalContainer?: PortalHostProps["container"];
|
|
11
|
+
theme?: ThemeProviderProps["theme"];
|
|
12
|
+
safeAreaInsets?: SafeAreaInsets;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export const UniversalUIProvider = ({ children, portalContainer }: ProviderProps) => {
|
|
15
|
+
export const UniversalUIProvider = ({ children, portalContainer, theme, safeAreaInsets }: ProviderProps) => {
|
|
14
16
|
return (
|
|
15
|
-
<
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<SafeAreaProvider insets={safeAreaInsets}>
|
|
18
|
+
<ThemeProvider theme={theme}>
|
|
19
|
+
<ToastContainer />
|
|
20
|
+
{children}
|
|
21
|
+
<PortalHost container={portalContainer} />
|
|
22
|
+
<AsyncAlertDialogManager />
|
|
23
|
+
</ThemeProvider>
|
|
24
|
+
</SafeAreaProvider>
|
|
21
25
|
);
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export * from "./themes/adapters";
|
|
29
|
+
export * from "./themes/default";
|
|
25
30
|
export { useTheme } from "./themes/provider";
|
|
26
31
|
export * from "./themes/types";
|
|
32
|
+
|
|
33
|
+
export * from "./safe-area";
|
|
@@ -17,6 +17,8 @@ export const AutocompleteInput = forwardRef<TextInputRef, AutocompleteInputProps
|
|
|
17
17
|
const blurTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);
|
|
18
18
|
|
|
19
19
|
const composedStyles = [autocomplete.styles?.input?.default, autocomplete.styles?.input?.[autocomplete.state], props.style];
|
|
20
|
+
const placeholderTextColor = autocomplete.styles?.input?.placeholderTextColor;
|
|
21
|
+
const selectionColor = autocomplete.styles?.input?.selectionColor;
|
|
20
22
|
|
|
21
23
|
const handleFocus: TextInputProps["onFocus"] = (e) => {
|
|
22
24
|
// Clear any pending blur timeout
|
|
@@ -74,6 +76,8 @@ export const AutocompleteInput = forwardRef<TextInputRef, AutocompleteInputProps
|
|
|
74
76
|
id={field?.id}
|
|
75
77
|
value={autocomplete.inputValue}
|
|
76
78
|
placeholder={autocomplete.placeholder}
|
|
79
|
+
placeholderTextColor={placeholderTextColor}
|
|
80
|
+
selectionColor={selectionColor}
|
|
77
81
|
onChangeText={handleChangeText}
|
|
78
82
|
onFocus={handleFocus}
|
|
79
83
|
onBlur={handleBlur}
|
|
@@ -10,7 +10,7 @@ export type AutocompleteOptionState = AutocompleteState | "hovered" | "selected"
|
|
|
10
10
|
|
|
11
11
|
export interface AutocompleteStyles {
|
|
12
12
|
root?: Partial<Record<AutocompleteState, AutocompleteRootProps["style"]>>;
|
|
13
|
-
input?: Partial<Record<AutocompleteState, AutocompleteInputProps["style"]
|
|
13
|
+
input?: Partial<Record<AutocompleteState, AutocompleteInputProps["style"]>> & Pick<AutocompleteInputProps, "placeholderTextColor" | "selectionColor">;
|
|
14
14
|
overlay?: Partial<Record<AutocompleteState, AutocompleteOverlayProps["style"]>>;
|
|
15
15
|
content?: Partial<Record<AutocompleteState, AutocompleteContentProps["style"]>>;
|
|
16
16
|
option?: Partial<Record<AutocompleteOptionState, AutocompleteOptionProps["style"]>>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type StyleProp, type TextStyle
|
|
2
|
+
import { Text, type StyleProp, type TextStyle } from "react-native";
|
|
3
3
|
import { useAvatar } from "./context";
|
|
4
4
|
|
|
5
5
|
export interface AvatarFallbackProps {
|
|
6
6
|
children: string;
|
|
7
|
-
render?: (props: AvatarFallbackProps) => React.ReactNode;
|
|
8
7
|
style?: StyleProp<TextStyle>;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export function AvatarFallback(props: AvatarFallbackProps) {
|
|
12
11
|
const avatar = useAvatar();
|
|
13
12
|
const composedStyles = [avatar.styles?.fallback, props.style];
|
|
14
|
-
|
|
15
|
-
return <Component {...props} style={composedStyles} />;
|
|
13
|
+
return <Text {...props} style={composedStyles} />;
|
|
16
14
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import type { SafeAreaContextValue } from "./types";
|
|
3
|
+
|
|
4
|
+
const SafeAreaContext = createContext<SafeAreaContextValue | null>(null);
|
|
5
|
+
|
|
6
|
+
export const useSafeAreaInsets = () => {
|
|
7
|
+
const context = useContext(SafeAreaContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useSafeAreaInsets must be used within SafeAreaProvider");
|
|
10
|
+
}
|
|
11
|
+
return context.insets;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { SafeAreaContext };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import { SafeAreaContext } from "./context";
|
|
3
|
+
import type { SafeAreaInsets } from "./types";
|
|
4
|
+
|
|
5
|
+
export interface SafeAreaProviderProps extends PropsWithChildren {
|
|
6
|
+
insets?: SafeAreaInsets;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SafeAreaProvider = ({ children, insets }: SafeAreaProviderProps) => {
|
|
10
|
+
const defaultInsets: SafeAreaInsets = {
|
|
11
|
+
top: 0,
|
|
12
|
+
bottom: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const calculatedInsets: SafeAreaInsets = { ...defaultInsets, ...insets };
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SafeAreaContext.Provider
|
|
21
|
+
value={{
|
|
22
|
+
insets: calculatedInsets,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</SafeAreaContext.Provider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
1
|
import type { Theme } from "@react-navigation/native";
|
|
3
|
-
import {
|
|
2
|
+
import { useEffect } from "react";
|
|
4
3
|
import { Platform } from "react-native";
|
|
4
|
+
import { useTheme } from "../provider";
|
|
5
5
|
|
|
6
6
|
export function useReactNavigationTheme(): Theme {
|
|
7
7
|
const theme = useTheme();
|
|
@@ -13,13 +13,14 @@ export function useReactNavigationTheme(): Theme {
|
|
|
13
13
|
styles.innerHTML = `
|
|
14
14
|
:root {
|
|
15
15
|
--expo-router-modal-border: 1px solid ${theme.colors.border};
|
|
16
|
+
--expo-router-modal-border-radius: ${theme.radius}px;
|
|
16
17
|
}
|
|
17
18
|
`;
|
|
18
19
|
document.head.appendChild(styles);
|
|
19
20
|
return () => {
|
|
20
21
|
document.head.removeChild(styles);
|
|
21
22
|
};
|
|
22
|
-
}, [theme.colors.border]);
|
|
23
|
+
}, [theme.colors.border, theme.radius]);
|
|
23
24
|
|
|
24
25
|
return {
|
|
25
26
|
dark: theme.colorScheme === "dark",
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import type { Colors } from "../types";
|
|
2
2
|
|
|
3
3
|
export const lightColors: Colors = {
|
|
4
|
-
background: "hsla(
|
|
5
|
-
foreground: "hsla(
|
|
4
|
+
background: "hsla(224, 0%, 100%, 1)",
|
|
5
|
+
foreground: "hsla(224, 0%, 4%, 1)",
|
|
6
6
|
|
|
7
|
-
primary: "hsla(
|
|
8
|
-
primaryForeground: "hsla(
|
|
7
|
+
primary: "hsla(224, 0%, 9%, 1)",
|
|
8
|
+
primaryForeground: "hsla(224, 0%, 98%, 1)",
|
|
9
9
|
|
|
10
|
-
secondary: "hsla(
|
|
11
|
-
secondaryForeground: "hsla(
|
|
10
|
+
secondary: "hsla(224, 0%, 96%, 1)",
|
|
11
|
+
secondaryForeground: "hsla(224, 0%, 9%, 1)",
|
|
12
12
|
|
|
13
|
-
muted: "hsla(
|
|
14
|
-
mutedForeground: "hsla(
|
|
13
|
+
muted: "hsla(224, 0%, 96%, 1)",
|
|
14
|
+
mutedForeground: "hsla(224, 0%, 45%, 1)",
|
|
15
15
|
|
|
16
|
-
border: "hsla(
|
|
17
|
-
surface: "hsla(
|
|
16
|
+
border: "hsla(224, 0%, 90%, 1)",
|
|
17
|
+
surface: "hsla(224, 0%, 100%, 1)",
|
|
18
18
|
|
|
19
|
-
danger: "hsla(
|
|
20
|
-
success: "hsla(
|
|
21
|
-
warning: "hsla(
|
|
22
|
-
info: "hsla(
|
|
19
|
+
danger: "hsla(352, 100%, 41%, 1)",
|
|
20
|
+
success: "hsla(227, 70%, 40%, 1)",
|
|
21
|
+
warning: "hsla(212, 100%, 79%, 1)",
|
|
22
|
+
info: "hsla(221, 86%, 54%, 1)",
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const darkColors: Colors = {
|
|
26
|
-
background: "hsla(
|
|
27
|
-
foreground: "hsla(
|
|
26
|
+
background: "hsla(224, 0%, 4%, 1)",
|
|
27
|
+
foreground: "hsla(224, 0%, 98%, 1)",
|
|
28
28
|
|
|
29
|
-
primary: "hsla(
|
|
30
|
-
primaryForeground: "hsla(
|
|
29
|
+
primary: "hsla(224, 0%, 90%, 1)",
|
|
30
|
+
primaryForeground: "hsla(224, 0%, 9%, 1)",
|
|
31
31
|
|
|
32
|
-
secondary: "hsla(
|
|
33
|
-
secondaryForeground: "hsla(
|
|
32
|
+
secondary: "hsla(224, 0%, 15%, 1)",
|
|
33
|
+
secondaryForeground: "hsla(224, 0%, 98%, 1)",
|
|
34
34
|
|
|
35
|
-
muted: "hsla(
|
|
36
|
-
mutedForeground: "hsla(
|
|
35
|
+
muted: "hsla(224, 0%, 15%, 1)",
|
|
36
|
+
mutedForeground: "hsla(224, 0%, 63%, 1)",
|
|
37
37
|
|
|
38
|
-
border: "hsla(
|
|
39
|
-
surface: "hsla(
|
|
38
|
+
border: "hsla(224, 0%, 16%, 1)",
|
|
39
|
+
surface: "hsla(224, 0%, 9%, 1)",
|
|
40
40
|
|
|
41
|
-
danger: "hsla(
|
|
42
|
-
success: "hsla(
|
|
43
|
-
warning: "hsla(
|
|
44
|
-
info: "hsla(
|
|
41
|
+
danger: "hsla(359, 100%, 70%, 1)",
|
|
42
|
+
success: "hsla(227, 70%, 40%, 1)",
|
|
43
|
+
warning: "hsla(212, 100%, 79%, 1)",
|
|
44
|
+
info: "hsla(221, 86%, 54%, 1)",
|
|
45
45
|
};
|
package/src/themes/provider.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createContext, type PropsWithChildren, useContext, useEffect, useState } from "react";
|
|
2
2
|
import { useColorScheme } from "react-native";
|
|
3
|
-
import {
|
|
4
|
-
import type { Colors, ColorScheme, FontFamily, FontSize, LetterSpacing, Radius,
|
|
3
|
+
import { defaultThemeAssets } from "./default";
|
|
4
|
+
import type { Colors, ColorScheme, FontFamily, FontSize, LetterSpacing, Radius, ThemeAssets } from "./types";
|
|
5
|
+
import { mergeThemeAssets } from "./utils";
|
|
5
6
|
|
|
6
7
|
interface ThemeContext {
|
|
7
8
|
colors: Colors;
|
|
@@ -11,20 +12,23 @@ interface ThemeContext {
|
|
|
11
12
|
letterSpacing: LetterSpacing;
|
|
12
13
|
fontSize: FontSize;
|
|
13
14
|
setColorScheme: (scheme: ColorScheme) => void;
|
|
14
|
-
setTheme: (themeName: ThemeName) => void;
|
|
15
|
-
themeName: ThemeName;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const ThemeContext = createContext<ThemeContext | null>(null);
|
|
19
18
|
|
|
20
|
-
export
|
|
21
|
-
|
|
19
|
+
export interface ThemeProviderProps extends PropsWithChildren {
|
|
20
|
+
theme?: Partial<ThemeAssets>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ThemeProvider = (props: ThemeProviderProps) => {
|
|
24
|
+
const { children, theme } = props;
|
|
22
25
|
|
|
23
26
|
const systemColorScheme = useColorScheme();
|
|
24
27
|
const [colorScheme, setColorScheme] = useState<ColorScheme>(systemColorScheme === "dark" ? "dark" : "light");
|
|
25
28
|
|
|
26
|
-
const
|
|
27
|
-
|
|
29
|
+
const themeAssets = theme ? mergeThemeAssets(defaultThemeAssets, theme) : defaultThemeAssets;
|
|
30
|
+
|
|
31
|
+
const colors = themeAssets.colors[colorScheme];
|
|
28
32
|
|
|
29
33
|
useEffect(() => {
|
|
30
34
|
if (systemColorScheme) {
|
|
@@ -35,18 +39,16 @@ export const ThemeProvider = (props: PropsWithChildren) => {
|
|
|
35
39
|
return (
|
|
36
40
|
<ThemeContext.Provider
|
|
37
41
|
value={{
|
|
38
|
-
themeName,
|
|
39
|
-
setTheme,
|
|
40
42
|
colorScheme,
|
|
41
43
|
setColorScheme,
|
|
42
44
|
colors,
|
|
43
|
-
radius:
|
|
44
|
-
fontFamily:
|
|
45
|
-
letterSpacing:
|
|
46
|
-
fontSize:
|
|
45
|
+
radius: themeAssets.radius,
|
|
46
|
+
fontFamily: themeAssets.fontFamily,
|
|
47
|
+
letterSpacing: themeAssets.letterSpacing,
|
|
48
|
+
fontSize: themeAssets.fontSize,
|
|
47
49
|
}}
|
|
48
50
|
>
|
|
49
|
-
{
|
|
51
|
+
{children}
|
|
50
52
|
</ThemeContext.Provider>
|
|
51
53
|
);
|
|
52
54
|
};
|
package/src/themes/types.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ThemeAssets } from "./types";
|
|
2
|
+
|
|
3
|
+
export function mergeThemeAssets(base: ThemeAssets, override: Partial<ThemeAssets>): ThemeAssets {
|
|
4
|
+
return {
|
|
5
|
+
colors: {
|
|
6
|
+
light: { ...base.colors.light, ...override.colors?.light },
|
|
7
|
+
dark: { ...base.colors.dark, ...override.colors?.dark },
|
|
8
|
+
},
|
|
9
|
+
radius: override.radius ?? base.radius,
|
|
10
|
+
fontFamily: override.fontFamily ?? base.fontFamily,
|
|
11
|
+
letterSpacing: override.letterSpacing ?? base.letterSpacing,
|
|
12
|
+
fontSize: override.fontSize ?? base.fontSize,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["defaultThemeAssets","themes","default"],"sourceRoot":"../../../src","sources":["themes/themes.ts"],"mappings":";;AAAA,SAASA,kBAAkB;AAG3B,OAAO,MAAMC,MAAsC,GAAG;EACpDC,OAAO,EAAEF;AACX,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../../../src/themes/themes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEtD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAEjD,CAAC"}
|