@gv-tech/ui-native 2.22.0 → 2.22.1

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.22.0",
3
+ "version": "2.22.1",
4
4
  "description": "React Native implementations of the GV Tech design system components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,10 +77,11 @@ DropdownMenuContent.displayName = 'DropdownMenuContent';
77
77
  export const DropdownMenuItem = React.forwardRef<
78
78
  React.ElementRef<typeof DropdownMenuPrimitive.Item>,
79
79
  DropdownMenuItemBaseProps
80
- >(({ className, children, inset, ...props }, ref) => {
80
+ >(({ className, children, inset, onSelect, ...props }, ref) => {
81
81
  return (
82
82
  <DropdownMenuPrimitive.Item
83
83
  ref={ref}
84
+ onPress={() => onSelect?.(new Event('select'))}
84
85
  className={cn(
85
86
  'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none',
86
87
  inset && 'pl-8',
@@ -0,0 +1,18 @@
1
+ import { theme as designTokens } from '@gv-tech/design-tokens';
2
+ import { useColorScheme } from 'nativewind';
3
+
4
+ export function useTheme() {
5
+ const { colorScheme, setColorScheme } = useColorScheme();
6
+
7
+ const resolvedTheme = colorScheme as 'light' | 'dark';
8
+
9
+ // Default to light theme tokens if resolvedTheme is dark or invalid
10
+ const activeTokens = resolvedTheme === 'dark' ? designTokens.dark : designTokens.light;
11
+
12
+ return {
13
+ theme: colorScheme,
14
+ setTheme: setColorScheme,
15
+ resolvedTheme,
16
+ tokens: activeTokens,
17
+ };
18
+ }
package/src/index.ts CHANGED
@@ -314,6 +314,7 @@ export type { ToastProps } from './toast';
314
314
  export { ThemeProvider } from './theme-provider';
315
315
 
316
316
  // Theme Toggle
317
+ export { useTheme } from './hooks/use-theme';
317
318
  export { ThemeToggle } from './theme-toggle';
318
319
 
319
320
  // Toaster
@@ -1,28 +1,29 @@
1
1
  import { ThemeToggleBaseProps } from '@gv-tech/ui-core';
2
2
  import { Moon, Sun, SunMoon } from 'lucide-react-native';
3
- import { useColorScheme } from 'nativewind';
4
3
  import { View } from 'react-native';
5
4
  import { Button } from './button';
6
5
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './dropdown-menu';
6
+ import { useTheme } from './hooks/use-theme';
7
7
  import { cn } from './lib/utils';
8
8
  import { Text } from './text';
9
9
 
10
10
  export type ThemeToggleProps = ThemeToggleBaseProps;
11
11
 
12
12
  export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, className }: ThemeToggleProps) {
13
- const { colorScheme, setColorScheme } = useColorScheme();
13
+ const { theme, setTheme, resolvedTheme } = useTheme();
14
14
 
15
- const currentTheme = (customTheme ?? colorScheme) as 'light' | 'dark' | 'system';
15
+ const currentTheme = (customTheme ?? theme) as 'light' | 'dark' | 'system';
16
16
 
17
- // Determine if dark based on currentTheme
18
- const isDark = currentTheme === 'dark';
17
+ // Determine the effective theme for icon rendering
18
+ const effectiveTheme = customTheme ? customTheme : resolvedTheme;
19
+ const isDark = effectiveTheme === 'dark';
19
20
  const isSystem = currentTheme === 'system';
20
21
 
21
22
  const handleThemeChange = (newTheme: 'light' | 'dark' | 'system') => {
22
23
  if (onThemeChange) {
23
24
  onThemeChange(newTheme);
24
25
  } else {
25
- setColorScheme(newTheme);
26
+ setTheme(newTheme);
26
27
  }
27
28
  };
28
29
 
@@ -61,15 +62,15 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
61
62
  </Button>
62
63
  </DropdownMenuTrigger>
63
64
  <DropdownMenuContent align="end">
64
- <DropdownMenuItem onPress={() => handleThemeChange('light')}>
65
+ <DropdownMenuItem onSelect={() => handleThemeChange('light')}>
65
66
  <Sun size={14} className="text-foreground mr-2" />
66
67
  <Text>Light</Text>
67
68
  </DropdownMenuItem>
68
- <DropdownMenuItem onPress={() => handleThemeChange('dark')}>
69
+ <DropdownMenuItem onSelect={() => handleThemeChange('dark')}>
69
70
  <Moon size={14} className="text-foreground mr-2" />
70
71
  <Text>Dark</Text>
71
72
  </DropdownMenuItem>
72
- <DropdownMenuItem onPress={() => handleThemeChange('system')}>
73
+ <DropdownMenuItem onSelect={() => handleThemeChange('system')}>
73
74
  <SunMoon size={14} className="text-foreground mr-2" />
74
75
  <Text>System</Text>
75
76
  </DropdownMenuItem>