@gv-tech/ui-native 2.29.0 → 2.29.2
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/__contracts.d.ts +0 -1
- package/dist/__contracts.d.ts.map +1 -1
- package/dist/alert-dialog.d.ts +51 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert.d.ts +10 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/breadcrumb.d.ts +6 -25
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/button-group.d.ts +3 -3
- package/dist/button-group.d.ts.map +1 -1
- package/dist/button.d.ts +2 -5
- package/dist/button.d.ts.map +1 -1
- package/dist/calendar.d.ts +7 -10
- package/dist/calendar.d.ts.map +1 -1
- package/dist/card.d.ts +13 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/carousel.d.ts +6 -29
- package/dist/carousel.d.ts.map +1 -1
- package/dist/checkbox.d.ts +15 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/combobox.d.ts +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/context-menu.d.ts +61 -0
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/dialog.d.ts +61 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/direction.d.ts +1 -1
- package/dist/drawer.d.ts +33 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/dropdown-menu.d.ts +60 -0
- package/dist/dropdown-menu.d.ts.map +1 -0
- package/dist/empty.d.ts +1 -1
- package/dist/empty.d.ts.map +1 -1
- package/dist/field.d.ts +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/form.d.ts +33 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/hooks/use-theme.d.ts +52 -52
- package/dist/hooks/use-theme.d.ts.map +1 -1
- package/dist/hooks/use-toast.d.ts.map +1 -1
- package/dist/hover-card.d.ts +23 -0
- package/dist/hover-card.d.ts.map +1 -0
- package/dist/input-group.d.ts +2 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-otp.d.ts +1 -1
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input.d.ts +8 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/item.d.ts +10 -10
- package/dist/item.d.ts.map +1 -1
- package/dist/kbd.d.ts.map +1 -1
- package/dist/label.d.ts +9 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/menubar.d.ts +53 -0
- package/dist/menubar.d.ts.map +1 -0
- package/dist/native-select.d.ts +1 -1
- package/dist/native-select.d.ts.map +1 -1
- package/dist/navigation-menu.d.ts +14 -0
- package/dist/navigation-menu.d.ts.map +1 -0
- package/dist/pagination.d.ts +5 -12
- package/dist/pagination.d.ts.map +1 -1
- package/dist/popover.d.ts +9 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/progress.d.ts +6 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/radio-group.d.ts +11 -0
- package/dist/radio-group.d.ts.map +1 -0
- package/dist/scroll-area.d.ts +2 -9
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-to-top.d.ts +6 -5
- package/dist/scroll-to-top.d.ts.map +1 -1
- package/dist/search.d.ts +2 -5
- package/dist/search.d.ts.map +1 -1
- package/dist/select.d.ts +59 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/separator.d.ts +9 -0
- package/dist/separator.d.ts.map +1 -0
- package/dist/sheet.d.ts +59 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sidebar.d.ts +8 -8
- package/dist/sidebar.d.ts.map +1 -1
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/slider.d.ts.map +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/spinner.d.ts +1 -1
- package/dist/spinner.d.ts.map +1 -1
- package/dist/switch.d.ts +8 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/table-of-contents.d.ts +5 -13
- package/dist/table-of-contents.d.ts.map +1 -1
- package/dist/table.d.ts +12 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/tabs.d.ts +24 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/text.d.ts +13 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/textarea.d.ts +6 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/theme-provider.d.ts.map +1 -1
- package/dist/theme-toggle.d.ts +1 -1
- package/dist/theme-toggle.d.ts.map +1 -1
- package/dist/toast.d.ts +35 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toaster.d.ts.map +1 -1
- package/dist/toggle-group.d.ts +11 -0
- package/dist/toggle-group.d.ts.map +1 -0
- package/dist/toggle.d.ts +8 -0
- package/dist/toggle.d.ts.map +1 -0
- package/dist/tooltip.d.ts +30 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/ui-native.cjs +2 -2
- package/dist/ui-native.esm.js +365 -429
- package/package.json +19 -19
- package/src/__contracts.ts +321 -324
- package/src/aspect-ratio.tsx +1 -0
- package/src/badge.tsx +3 -3
- package/src/breadcrumb.tsx +2 -8
- package/src/button-group.tsx +8 -3
- package/src/button.tsx +4 -3
- package/src/calendar.tsx +8 -5
- package/src/card.tsx +1 -1
- package/src/carousel.tsx +6 -23
- package/src/collapsible.tsx +1 -1
- package/src/combobox.tsx +8 -8
- package/src/command.tsx +1 -0
- package/src/context-menu.tsx +1 -0
- package/src/dialog.tsx +1 -1
- package/src/drawer.tsx +1 -0
- package/src/dropdown-menu.tsx +1 -0
- package/src/empty.tsx +6 -1
- package/src/field.tsx +2 -1
- package/src/form.tsx +9 -9
- package/src/hooks/use-theme.ts +1 -0
- package/src/hooks/use-toast.ts +1 -0
- package/src/hover-card.tsx +1 -0
- package/src/input-group.tsx +7 -2
- package/src/input-otp.tsx +6 -1
- package/src/input.tsx +1 -1
- package/src/item.tsx +9 -3
- package/src/kbd.tsx +1 -0
- package/src/menubar.tsx +1 -0
- package/src/native-select.tsx +2 -1
- package/src/navigation-menu.tsx +18 -6
- package/src/pagination.tsx +5 -2
- package/src/popover.tsx +1 -1
- package/src/progress.tsx +1 -2
- package/src/radio-group.tsx +1 -1
- package/src/scroll-area.tsx +1 -0
- package/src/scroll-to-top.tsx +10 -9
- package/src/search.tsx +2 -1
- package/src/select.tsx +1 -1
- package/src/sidebar.tsx +20 -19
- package/src/skeleton.tsx +4 -2
- package/src/slider.tsx +2 -1
- package/src/sonner.tsx +1 -0
- package/src/spinner.tsx +4 -1
- package/src/switch.tsx +1 -1
- package/src/table-of-contents.tsx +9 -25
- package/src/tabs.tsx +2 -2
- package/src/text.tsx +3 -3
- package/src/theme-provider.tsx +3 -1
- package/src/theme-toggle.tsx +32 -29
- package/src/toaster.tsx +1 -0
- package/src/toggle-group.tsx +2 -2
- package/src/toggle.tsx +3 -2
package/src/scroll-to-top.tsx
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import type { ScrollToTopBaseProps } from '@gv-tech/ui-core';
|
|
3
4
|
import { ArrowUp } from 'lucide-react-native';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import {
|
|
7
|
+
type ScrollView,
|
|
6
8
|
AccessibilityInfo,
|
|
7
9
|
Animated,
|
|
8
10
|
type FlatList,
|
|
9
11
|
type NativeScrollEvent,
|
|
10
12
|
type NativeSyntheticEvent,
|
|
11
13
|
Platform,
|
|
12
|
-
ScrollView,
|
|
13
14
|
View,
|
|
14
15
|
} from 'react-native';
|
|
15
16
|
|
|
16
|
-
import type { ScrollToTopBaseProps } from '@gv-tech/ui-core';
|
|
17
17
|
import { Button } from './button';
|
|
18
18
|
import { cn } from './lib/utils';
|
|
19
19
|
|
|
20
20
|
export interface ScrollToTopProps extends ScrollToTopBaseProps {
|
|
21
21
|
/**
|
|
22
|
-
* For Native: The scroll target is typically a ref to a ScrollView or FlatList.
|
|
23
|
-
*
|
|
22
|
+
* For Native: The scroll target is typically a ref to a ScrollView or FlatList. This is required unless you manually
|
|
23
|
+
* call the scroll handler.
|
|
24
24
|
*/
|
|
25
25
|
scrollRef?: React.RefObject<ScrollView | FlatList | null>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Custom duration specifically for Native animations (opacity/transform).
|
|
29
|
+
*
|
|
29
30
|
* @default 300
|
|
30
31
|
*/
|
|
31
32
|
animationDuration?: number;
|
|
@@ -34,8 +35,8 @@ export interface ScrollToTopProps extends ScrollToTopBaseProps {
|
|
|
34
35
|
/**
|
|
35
36
|
* GV Tech Animated Scroll To Top (Native)
|
|
36
37
|
*
|
|
37
|
-
* A floating action button that appears when scrolling down and allows the user
|
|
38
|
-
*
|
|
38
|
+
* A floating action button that appears when scrolling down and allows the user to quickly return to the top of a
|
|
39
|
+
* ScrollView, FlatList, or SectionList.
|
|
39
40
|
*
|
|
40
41
|
* Reuses the internal GV Tech Button primitive for consistent styling.
|
|
41
42
|
*/
|
|
@@ -61,9 +62,9 @@ export const ScrollToTop = React.forwardRef<ScrollToTopHandle, ScrollToTopProps>
|
|
|
61
62
|
const [isVisible, setIsVisible] = React.useState(false);
|
|
62
63
|
const [isExiting, setIsExiting] = React.useState(false);
|
|
63
64
|
|
|
64
|
-
// Animation states
|
|
65
|
-
const opacity = React.
|
|
66
|
-
const translateY = React.
|
|
65
|
+
// Animation states (lazy state initializers keep stable instances without render-time ref reads)
|
|
66
|
+
const [opacity] = React.useState(() => new Animated.Value(0));
|
|
67
|
+
const [translateY] = React.useState(() => new Animated.Value(20));
|
|
67
68
|
|
|
68
69
|
const animateIn = () => {
|
|
69
70
|
Animated.parallel([
|
package/src/search.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { SearchBaseProps, SearchTriggerBaseProps } from '@gv-tech/ui-core';
|
|
1
|
+
import type { SearchBaseProps, SearchTriggerBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import { Search as SearchIcon } from 'lucide-react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { Platform, Text, View } from 'react-native';
|
|
5
|
+
|
|
5
6
|
import { Button } from './button';
|
|
6
7
|
import { Dialog } from './dialog';
|
|
7
8
|
import { cn } from './lib/utils';
|
package/src/select.tsx
CHANGED
package/src/sidebar.tsx
CHANGED
|
@@ -25,13 +25,14 @@ import type {
|
|
|
25
25
|
} from '@gv-tech/ui-core';
|
|
26
26
|
import * as React from 'react';
|
|
27
27
|
import { Pressable, Text, View } from 'react-native';
|
|
28
|
+
|
|
28
29
|
import { cn } from './lib/utils';
|
|
29
30
|
|
|
30
31
|
function SidebarProvider({
|
|
31
32
|
className,
|
|
32
|
-
defaultOpen,
|
|
33
|
-
open,
|
|
34
|
-
onOpenChange,
|
|
33
|
+
defaultOpen: _defaultOpen,
|
|
34
|
+
open: _open,
|
|
35
|
+
onOpenChange: _onOpenChange,
|
|
35
36
|
...props
|
|
36
37
|
}: React.ComponentProps<typeof View> & SidebarProviderBaseProps) {
|
|
37
38
|
return <View className={className} {...props} />;
|
|
@@ -39,9 +40,9 @@ function SidebarProvider({
|
|
|
39
40
|
|
|
40
41
|
function Sidebar({
|
|
41
42
|
className,
|
|
42
|
-
side,
|
|
43
|
-
variant,
|
|
44
|
-
collapsible,
|
|
43
|
+
side: _side,
|
|
44
|
+
variant: _variant,
|
|
45
|
+
collapsible: _collapsible,
|
|
45
46
|
...props
|
|
46
47
|
}: React.ComponentProps<typeof View> & SidebarBaseProps) {
|
|
47
48
|
return (
|
|
@@ -89,7 +90,7 @@ function SidebarGroup({ className, ...props }: React.ComponentProps<typeof View>
|
|
|
89
90
|
|
|
90
91
|
function SidebarGroupLabel({
|
|
91
92
|
className,
|
|
92
|
-
asChild,
|
|
93
|
+
asChild: _asChild,
|
|
93
94
|
...props
|
|
94
95
|
}: React.ComponentProps<typeof View> & SidebarGroupLabelBaseProps) {
|
|
95
96
|
return <View className={className} {...props} />;
|
|
@@ -97,7 +98,7 @@ function SidebarGroupLabel({
|
|
|
97
98
|
|
|
98
99
|
function SidebarGroupAction({
|
|
99
100
|
className,
|
|
100
|
-
asChild,
|
|
101
|
+
asChild: _asChild,
|
|
101
102
|
...props
|
|
102
103
|
}: React.ComponentProps<typeof Pressable> & SidebarGroupActionBaseProps) {
|
|
103
104
|
return <Pressable className={className} {...(props as Record<string, unknown>)} />;
|
|
@@ -120,11 +121,11 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<typeof Vi
|
|
|
120
121
|
|
|
121
122
|
function SidebarMenuButton({
|
|
122
123
|
className,
|
|
123
|
-
asChild,
|
|
124
|
-
isActive,
|
|
125
|
-
variant,
|
|
126
|
-
size,
|
|
127
|
-
tooltip,
|
|
124
|
+
asChild: _asChild,
|
|
125
|
+
isActive: _isActive,
|
|
126
|
+
variant: _variant,
|
|
127
|
+
size: _size,
|
|
128
|
+
tooltip: _tooltip,
|
|
128
129
|
...props
|
|
129
130
|
}: React.ComponentProps<typeof Pressable> & SidebarMenuButtonBaseProps) {
|
|
130
131
|
return <Pressable className={className} {...(props as Record<string, unknown>)} />;
|
|
@@ -132,8 +133,8 @@ function SidebarMenuButton({
|
|
|
132
133
|
|
|
133
134
|
function SidebarMenuAction({
|
|
134
135
|
className,
|
|
135
|
-
asChild,
|
|
136
|
-
showOnHover,
|
|
136
|
+
asChild: _asChild,
|
|
137
|
+
showOnHover: _showOnHover,
|
|
137
138
|
...props
|
|
138
139
|
}: React.ComponentProps<typeof Pressable> & SidebarMenuActionBaseProps) {
|
|
139
140
|
return <Pressable className={className} {...(props as Record<string, unknown>)} />;
|
|
@@ -145,7 +146,7 @@ function SidebarMenuBadge({ className, ...props }: React.ComponentProps<typeof V
|
|
|
145
146
|
|
|
146
147
|
function SidebarMenuSkeleton({
|
|
147
148
|
className,
|
|
148
|
-
showIcon,
|
|
149
|
+
showIcon: _showIcon,
|
|
149
150
|
...props
|
|
150
151
|
}: React.ComponentProps<typeof View> & SidebarMenuSkeletonBaseProps) {
|
|
151
152
|
return <View className={className} {...props} />;
|
|
@@ -161,9 +162,9 @@ function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<typeof
|
|
|
161
162
|
|
|
162
163
|
function SidebarMenuSubButton({
|
|
163
164
|
className,
|
|
164
|
-
asChild,
|
|
165
|
-
size,
|
|
166
|
-
isActive,
|
|
165
|
+
asChild: _asChild,
|
|
166
|
+
size: _size,
|
|
167
|
+
isActive: _isActive,
|
|
167
168
|
...props
|
|
168
169
|
}: React.ComponentProps<typeof Pressable> & SidebarMenuSubButtonBaseProps) {
|
|
169
170
|
return <Pressable className={className} {...(props as Record<string, unknown>)} />;
|
package/src/skeleton.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
2
|
+
import type { View } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
useAnimatedStyle,
|
|
5
5
|
useSharedValue,
|
|
@@ -14,12 +14,14 @@ function Skeleton({ className, ...props }: React.ComponentPropsWithoutRef<typeof
|
|
|
14
14
|
const opacity = useSharedValue(0.5);
|
|
15
15
|
|
|
16
16
|
React.useEffect(() => {
|
|
17
|
+
// Shared values are stable across renders; mutation here drives the Reanimated loop
|
|
18
|
+
// eslint-disable-next-line react/immutability
|
|
17
19
|
opacity.value = withRepeat(
|
|
18
20
|
withSequence(withTiming(0.2, { duration: 500 }), withTiming(0.5, { duration: 500 })),
|
|
19
21
|
-1,
|
|
20
22
|
true,
|
|
21
23
|
);
|
|
22
|
-
}, []);
|
|
24
|
+
}, [opacity]);
|
|
23
25
|
|
|
24
26
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
25
27
|
opacity: opacity.value,
|
package/src/slider.tsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { SliderBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import * as SliderPrimitive from '@rn-primitives/slider';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
|
|
4
5
|
import { cn } from './lib/utils';
|
|
5
6
|
|
|
6
7
|
export const Slider: React.FC<SliderBaseProps> = ({
|
|
7
8
|
className,
|
|
8
9
|
value,
|
|
9
10
|
onValueChange: onValueChangeProp,
|
|
10
|
-
defaultValue,
|
|
11
|
+
defaultValue: _defaultValue,
|
|
11
12
|
min = 0,
|
|
12
13
|
max = 100,
|
|
13
14
|
step = 1,
|
package/src/sonner.tsx
CHANGED
package/src/spinner.tsx
CHANGED
|
@@ -2,7 +2,10 @@ import type { SpinnerBaseProps } from '@gv-tech/ui-core';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ActivityIndicator } from 'react-native';
|
|
4
4
|
|
|
5
|
-
function Spinner({
|
|
5
|
+
function Spinner({
|
|
6
|
+
className: _className,
|
|
7
|
+
...props
|
|
8
|
+
}: React.ComponentProps<typeof ActivityIndicator> & SpinnerBaseProps) {
|
|
6
9
|
return <ActivityIndicator size="small" {...props} />;
|
|
7
10
|
}
|
|
8
11
|
|
package/src/switch.tsx
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
LayoutChangeEvent,
|
|
4
|
-
NativeScrollEvent,
|
|
5
|
-
NativeSyntheticEvent,
|
|
6
|
-
Platform,
|
|
7
|
-
Text as RNText,
|
|
8
|
-
ScrollView,
|
|
9
|
-
TouchableOpacity,
|
|
10
|
-
View,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
|
|
13
|
-
import {
|
|
1
|
+
import type {
|
|
14
2
|
HeadingItem as BaseHeadingItem,
|
|
15
3
|
TableOfContentsContentBaseProps,
|
|
16
4
|
TableOfContentsRootBaseProps,
|
|
17
5
|
} from '@gv-tech/ui-core';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent } from 'react-native';
|
|
8
|
+
import { Platform, Text as RNText, ScrollView, TouchableOpacity, View } from 'react-native';
|
|
9
|
+
|
|
18
10
|
import { cn, slugify } from './lib/utils';
|
|
19
11
|
import { Text } from './text';
|
|
20
12
|
|
|
@@ -43,9 +35,7 @@ export function useTOC() {
|
|
|
43
35
|
return context;
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
/**
|
|
47
|
-
* Native Table of Contents Provider
|
|
48
|
-
*/
|
|
38
|
+
/** Native Table of Contents Provider */
|
|
49
39
|
export function TableOfContents({ children, activeId: activeIdOverride }: TableOfContentsRootBaseProps) {
|
|
50
40
|
const [headings, setHeadings] = React.useState<HeadingItem[]>([]);
|
|
51
41
|
const [activeId, setActiveId] = React.useState<string | null>(null);
|
|
@@ -136,9 +126,7 @@ export function TableOfContents({ children, activeId: activeIdOverride }: TableO
|
|
|
136
126
|
);
|
|
137
127
|
}
|
|
138
128
|
|
|
139
|
-
/**
|
|
140
|
-
* Heading component that registers itself with the TOC provider
|
|
141
|
-
*/
|
|
129
|
+
/** Heading component that registers itself with the TOC provider */
|
|
142
130
|
export function TableOfContentsHeader({
|
|
143
131
|
children,
|
|
144
132
|
level = 2,
|
|
@@ -174,9 +162,7 @@ export function TableOfContentsHeader({
|
|
|
174
162
|
);
|
|
175
163
|
}
|
|
176
164
|
|
|
177
|
-
/**
|
|
178
|
-
* Renders the TOC list of links
|
|
179
|
-
*/
|
|
165
|
+
/** Renders the TOC list of links */
|
|
180
166
|
export function TableOfContentsList({ className }: { className?: string }) {
|
|
181
167
|
const { headings, activeId, scrollToHeading } = useTOC();
|
|
182
168
|
|
|
@@ -217,9 +203,7 @@ export function TableOfContentsList({ className }: { className?: string }) {
|
|
|
217
203
|
);
|
|
218
204
|
}
|
|
219
205
|
|
|
220
|
-
/**
|
|
221
|
-
* Wrapper for content that handles scrolling
|
|
222
|
-
*/
|
|
206
|
+
/** Wrapper for content that handles scrolling */
|
|
223
207
|
export function TableOfContentsContent({ children, className }: TableOfContentsContentBaseProps) {
|
|
224
208
|
const { scrollViewRef, onScroll } = useTOC();
|
|
225
209
|
|
package/src/tabs.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TabsBaseProps, TabsContentBaseProps, TabsListBaseProps, TabsTriggerBaseProps } from '@gv-tech/ui-core';
|
|
1
|
+
import type { TabsBaseProps, TabsContentBaseProps, TabsListBaseProps, TabsTriggerBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import * as TabsPrimitive from '@rn-primitives/tabs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
@@ -51,7 +51,7 @@ const TabsTrigger = React.forwardRef<React.ComponentRef<typeof TabsPrimitive.Tri
|
|
|
51
51
|
return (
|
|
52
52
|
<TextClassContext.Provider
|
|
53
53
|
value={cn(
|
|
54
|
-
'
|
|
54
|
+
'native:text-base text-muted-foreground web:transition-all text-sm font-medium',
|
|
55
55
|
value === props.value && 'text-foreground',
|
|
56
56
|
)}
|
|
57
57
|
>
|
package/src/text.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { TextBaseProps } from '@gv-tech/ui-core';
|
|
1
2
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { Text as RNText } from 'react-native';
|
|
4
5
|
|
|
5
|
-
import type { TextBaseProps } from '@gv-tech/ui-core';
|
|
6
6
|
import { cn } from './lib/utils';
|
|
7
7
|
|
|
8
8
|
const TextClassContext = React.createContext<string | undefined>(undefined);
|
|
@@ -16,9 +16,9 @@ const textVariants = cva('text-foreground', {
|
|
|
16
16
|
h4: 'text-xl font-semibold tracking-tight',
|
|
17
17
|
body: 'text-base leading-7',
|
|
18
18
|
bodySmall: 'text-sm leading-6',
|
|
19
|
-
caption: 'text-
|
|
19
|
+
caption: 'text-muted-foreground text-xs',
|
|
20
20
|
label: 'text-sm font-medium',
|
|
21
|
-
overline: 'text-xs font-semibold
|
|
21
|
+
overline: 'text-muted-foreground text-xs font-semibold tracking-widest uppercase',
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
defaultVariants: {
|
package/src/theme-provider.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { theme as designTokens } from '@gv-tech/design-tokens';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import type { ViewProps } from 'react-native';
|
|
4
|
+
import { Appearance, useColorScheme, View } from 'react-native';
|
|
5
|
+
|
|
4
6
|
import { cn } from './lib/utils';
|
|
5
7
|
|
|
6
8
|
export interface ThemeContextValue {
|
package/src/theme-toggle.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ThemeToggleBaseProps } from '@gv-tech/ui-core';
|
|
1
|
+
import type { ThemeToggleBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import { Moon, Sun, SunMoon } from 'lucide-react-native';
|
|
3
3
|
import { Appearance, View } from 'react-native';
|
|
4
|
+
|
|
4
5
|
import { Button } from './button';
|
|
5
6
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './dropdown-menu';
|
|
6
7
|
import { useTheme } from './hooks/use-theme';
|
|
@@ -14,29 +15,8 @@ iconWithClassName(SunMoon);
|
|
|
14
15
|
|
|
15
16
|
export type ThemeToggleProps = ThemeToggleBaseProps;
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const currentTheme = (customTheme ?? theme) as 'light' | 'dark' | 'system';
|
|
21
|
-
|
|
22
|
-
// Determine the effective theme for icon rendering
|
|
23
|
-
const effectiveTheme = customTheme === 'system' || !customTheme ? resolvedTheme : customTheme;
|
|
24
|
-
const isDark = effectiveTheme === 'dark';
|
|
25
|
-
const isSystem = currentTheme === 'system';
|
|
26
|
-
|
|
27
|
-
const handleThemeChange = (newTheme: 'light' | 'dark' | 'system') => {
|
|
28
|
-
if (onThemeChange) {
|
|
29
|
-
onThemeChange(newTheme);
|
|
30
|
-
} else {
|
|
31
|
-
if (newTheme === 'system') {
|
|
32
|
-
Appearance.setColorScheme('unspecified');
|
|
33
|
-
} else {
|
|
34
|
-
Appearance.setColorScheme(newTheme);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const IconToggle = () => (
|
|
18
|
+
function ThemeIcons({ isDark, isSystem, foreground }: { isDark: boolean; isSystem: boolean; foreground: string }) {
|
|
19
|
+
return (
|
|
40
20
|
<View className="flex h-6 w-6 items-center justify-center">
|
|
41
21
|
<View
|
|
42
22
|
className={cn(
|
|
@@ -44,7 +24,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
|
|
|
44
24
|
!isSystem && !isDark ? 'rotate-0 opacity-100' : 'absolute -rotate-90 opacity-0',
|
|
45
25
|
)}
|
|
46
26
|
>
|
|
47
|
-
<Sun size={18} color={
|
|
27
|
+
<Sun size={18} color={foreground} />
|
|
48
28
|
</View>
|
|
49
29
|
<View
|
|
50
30
|
className={cn(
|
|
@@ -52,7 +32,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
|
|
|
52
32
|
!isSystem && isDark ? 'rotate-0 opacity-100' : 'absolute rotate-90 opacity-0',
|
|
53
33
|
)}
|
|
54
34
|
>
|
|
55
|
-
<Moon size={18} color={
|
|
35
|
+
<Moon size={18} color={foreground} />
|
|
56
36
|
</View>
|
|
57
37
|
<View
|
|
58
38
|
className={cn(
|
|
@@ -60,10 +40,33 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
|
|
|
60
40
|
isSystem ? 'rotate-0 opacity-100' : 'absolute rotate-90 opacity-0',
|
|
61
41
|
)}
|
|
62
42
|
>
|
|
63
|
-
<SunMoon size={18} color={
|
|
43
|
+
<SunMoon size={18} color={foreground} />
|
|
64
44
|
</View>
|
|
65
45
|
</View>
|
|
66
46
|
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, className }: ThemeToggleProps) {
|
|
50
|
+
const { theme, resolvedTheme, tokens } = useTheme();
|
|
51
|
+
|
|
52
|
+
const currentTheme = (customTheme ?? theme) as 'light' | 'dark' | 'system';
|
|
53
|
+
|
|
54
|
+
// Determine the effective theme for icon rendering
|
|
55
|
+
const effectiveTheme = customTheme === 'system' || !customTheme ? resolvedTheme : customTheme;
|
|
56
|
+
const isDark = effectiveTheme === 'dark';
|
|
57
|
+
const isSystem = currentTheme === 'system';
|
|
58
|
+
|
|
59
|
+
const handleThemeChange = (newTheme: 'light' | 'dark' | 'system') => {
|
|
60
|
+
if (onThemeChange) {
|
|
61
|
+
onThemeChange(newTheme);
|
|
62
|
+
} else {
|
|
63
|
+
if (newTheme === 'system') {
|
|
64
|
+
Appearance.setColorScheme('unspecified');
|
|
65
|
+
} else {
|
|
66
|
+
Appearance.setColorScheme(newTheme);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
67
70
|
|
|
68
71
|
if (variant === 'ternary') {
|
|
69
72
|
return (
|
|
@@ -74,7 +77,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
|
|
|
74
77
|
className,
|
|
75
78
|
)}
|
|
76
79
|
>
|
|
77
|
-
<
|
|
80
|
+
<ThemeIcons isDark={isDark} isSystem={isSystem} foreground={tokens.foreground} />
|
|
78
81
|
</DropdownMenuTrigger>
|
|
79
82
|
<DropdownMenuContent align="end">
|
|
80
83
|
<DropdownMenuItem onSelect={() => handleThemeChange('light')}>
|
|
@@ -101,7 +104,7 @@ export function ThemeToggle({ variant = 'binary', onThemeChange, customTheme, cl
|
|
|
101
104
|
className={cn('relative h-9 w-9', className)}
|
|
102
105
|
onPress={() => handleThemeChange(currentTheme === 'dark' ? 'light' : 'dark')}
|
|
103
106
|
>
|
|
104
|
-
<
|
|
107
|
+
<ThemeIcons isDark={isDark} isSystem={isSystem} foreground={tokens.foreground} />
|
|
105
108
|
</Button>
|
|
106
109
|
);
|
|
107
110
|
}
|
package/src/toaster.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ToasterBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
|
+
|
|
4
5
|
import { useToast } from './hooks/use-toast';
|
|
5
6
|
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle } from './toast';
|
|
6
7
|
|
package/src/toggle-group.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToggleGroupBaseProps, ToggleGroupItemBaseProps } from '@gv-tech/ui-core';
|
|
1
|
+
import type { ToggleGroupBaseProps, ToggleGroupItemBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import * as ToggleGroupPrimitive from '@rn-primitives/toggle-group';
|
|
3
3
|
import { type VariantProps } from 'class-variance-authority';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -48,7 +48,7 @@ const ToggleGroupItem = React.forwardRef<React.ComponentRef<typeof ToggleGroupPr
|
|
|
48
48
|
return (
|
|
49
49
|
<TextClassContext.Provider
|
|
50
50
|
value={cn(
|
|
51
|
-
'
|
|
51
|
+
'native:text-base text-foreground text-sm font-medium',
|
|
52
52
|
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
53
53
|
value === '' && 'text-accent-foreground',
|
|
54
54
|
className,
|
package/src/toggle.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ToggleBaseProps
|
|
1
|
+
import type { ToggleBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import { toggleVariants } from '@gv-tech/ui-core';
|
|
2
3
|
import * as TogglePrimitive from '@rn-primitives/toggle';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
|
|
@@ -14,7 +15,7 @@ const Toggle = React.forwardRef<React.ComponentRef<typeof TogglePrimitive.Root>,
|
|
|
14
15
|
({ className, variant, size, ...props }, ref) => (
|
|
15
16
|
<TextClassContext.Provider
|
|
16
17
|
value={cn(
|
|
17
|
-
'
|
|
18
|
+
'native:text-base text-foreground text-sm font-medium',
|
|
18
19
|
props.pressed && 'text-accent-foreground',
|
|
19
20
|
className,
|
|
20
21
|
)}
|