@gv-tech/ui-native 2.25.2 → 2.25.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-tech/ui-native",
3
- "version": "2.25.2",
3
+ "version": "2.25.3",
4
4
  "description": "React Native implementations of the GV Tech design system components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,6 +37,7 @@
37
37
  "@gv-tech/design-tokens": "^2.12.0",
38
38
  "@gv-tech/ui-core": "^2.12.0",
39
39
  "@react-native-community/datetimepicker": "^9.1.0",
40
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
40
41
  "@rn-primitives/accordion": "^1.2.0",
41
42
  "@rn-primitives/alert-dialog": "^1.2.0",
42
43
  "@rn-primitives/aspect-ratio": "^1.2.0",
@@ -9,6 +9,7 @@ import type {
9
9
  DropdownMenuSubContentBaseProps,
10
10
  DropdownMenuSubTriggerBaseProps,
11
11
  } from '@gv-tech/ui-core';
12
+ import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
12
13
  import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
13
14
  import { Check, ChevronRight, Circle } from 'lucide-react-native';
14
15
  import * as React from 'react';
@@ -78,6 +79,23 @@ export const DropdownMenuItem = React.forwardRef<
78
79
  React.ComponentRef<typeof DropdownMenuPrimitive.Item>,
79
80
  DropdownMenuItemBaseProps
80
81
  >(({ className, children, inset, onSelect, ...props }, ref) => {
82
+ if (Platform.OS === 'web') {
83
+ return (
84
+ <RadixDropdownMenu.Item
85
+ ref={ref as React.Ref<HTMLDivElement>}
86
+ onSelect={onSelect}
87
+ className={cn(
88
+ 'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex cursor-default flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none',
89
+ inset && 'pl-8',
90
+ className,
91
+ )}
92
+ {...props}
93
+ >
94
+ {children}
95
+ </RadixDropdownMenu.Item>
96
+ );
97
+ }
98
+
81
99
  return (
82
100
  <DropdownMenuPrimitive.Item
83
101
  ref={ref}
@@ -1,7 +1,14 @@
1
1
  import { theme as designTokens } from '@gv-tech/design-tokens';
2
+ import * as React from 'react';
2
3
  import { useColorScheme } from 'react-native';
4
+ import { ThemeContext } from '../theme-provider';
3
5
 
4
6
  export function useTheme() {
7
+ const context = React.useContext(ThemeContext);
8
+ if (context) {
9
+ return context;
10
+ }
11
+
5
12
  const colorScheme = useColorScheme();
6
13
 
7
14
  const resolvedTheme = colorScheme as 'light' | 'dark';
@@ -1,24 +1,48 @@
1
+ import { theme as designTokens } from '@gv-tech/design-tokens';
1
2
  import * as React from 'react';
2
- import { View, ViewProps } from 'react-native';
3
- import { useTheme } from './hooks/use-theme';
3
+ import { useColorScheme, View, ViewProps } from 'react-native';
4
4
  import { cn } from './lib/utils';
5
5
 
6
+ export interface ThemeContextValue {
7
+ theme: 'light' | 'dark' | 'system';
8
+ resolvedTheme: 'light' | 'dark';
9
+ tokens: typeof designTokens.light | typeof designTokens.dark;
10
+ }
11
+
12
+ export const ThemeContext = React.createContext<ThemeContextValue | null>(null);
13
+
6
14
  export interface ThemeProviderProps extends ViewProps {
7
15
  children: React.ReactNode;
16
+ value?: 'light' | 'dark' | 'system';
8
17
  [key: string]: unknown;
9
18
  }
10
19
 
11
- export function ThemeProvider({ children, className, style, ...props }: ThemeProviderProps) {
12
- const { theme, tokens } = useTheme();
13
- const isDark = theme === 'dark';
20
+ export function ThemeProvider({ children, className, style, value, ...props }: ThemeProviderProps) {
21
+ const systemScheme = useColorScheme();
22
+ const theme = value || 'system';
23
+ const resolvedTheme = theme === 'system' ? (systemScheme === 'dark' ? 'dark' : 'light') : theme;
24
+ const tokens = resolvedTheme === 'dark' ? designTokens.dark : designTokens.light;
25
+
26
+ const isDark = resolvedTheme === 'dark';
27
+
28
+ const contextValue = React.useMemo<ThemeContextValue>(
29
+ () => ({
30
+ theme,
31
+ resolvedTheme,
32
+ tokens,
33
+ }),
34
+ [theme, resolvedTheme, tokens],
35
+ );
14
36
 
15
37
  return (
16
- <View
17
- className={cn('flex-1', isDark ? 'dark' : '', className)}
18
- style={[{ backgroundColor: tokens.background }, style]}
19
- {...props}
20
- >
21
- {children}
22
- </View>
38
+ <ThemeContext.Provider value={contextValue}>
39
+ <View
40
+ className={cn('flex-1', isDark ? 'dark' : '', className)}
41
+ style={[{ backgroundColor: tokens.background }, style]}
42
+ {...props}
43
+ >
44
+ {children}
45
+ </View>
46
+ </ThemeContext.Provider>
23
47
  );
24
48
  }
@@ -69,10 +69,13 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
69
69
  if (variant === 'ternary') {
70
70
  return (
71
71
  <DropdownMenu>
72
- <DropdownMenuTrigger asChild>
73
- <Button variant="ghost" size="icon" className={cn('relative h-9 w-9', className)}>
74
- <IconToggle />
75
- </Button>
72
+ <DropdownMenuTrigger
73
+ className={cn(
74
+ 'relative h-9 w-9 flex-row items-center justify-center rounded-md bg-transparent transition-colors active:opacity-80',
75
+ className,
76
+ )}
77
+ >
78
+ <IconToggle />
76
79
  </DropdownMenuTrigger>
77
80
  <DropdownMenuContent align="end">
78
81
  <DropdownMenuItem onSelect={() => handleThemeChange('light')}>