@gv-tech/ui-native 2.20.0 → 2.21.0
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/index.d.ts +627 -107
- package/dist/ui-native.cjs +2 -0
- package/dist/ui-native.mjs +2036 -1428
- package/package.json +10 -12
- package/src/aspect-ratio.tsx +9 -5
- package/src/breadcrumb.tsx +126 -4
- package/src/calendar.tsx +5 -7
- package/src/carousel.tsx +28 -8
- package/src/chart.tsx +30 -8
- package/src/command.tsx +48 -8
- package/src/context-menu.tsx +213 -5
- package/src/drawer.tsx +132 -6
- package/src/dropdown-menu.tsx +217 -5
- package/src/hooks/use-toast.ts +186 -0
- package/src/hover-card.tsx +26 -6
- package/src/index.ts +114 -11
- package/src/menubar.tsx +253 -5
- package/src/navigation-menu.tsx +175 -5
- package/src/pagination.tsx +107 -4
- package/src/resizable.tsx +9 -19
- package/src/scroll-area.tsx +24 -7
- package/src/slider.tsx +38 -5
- package/src/sonner.tsx +5 -7
- package/src/toaster.tsx +25 -6
package/src/pagination.tsx
CHANGED
|
@@ -1,9 +1,112 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
PaginationBaseProps,
|
|
3
|
+
PaginationContentBaseProps,
|
|
4
|
+
PaginationEllipsisBaseProps,
|
|
5
|
+
PaginationItemBaseProps,
|
|
6
|
+
PaginationLinkBaseProps,
|
|
7
|
+
PaginationNextBaseProps,
|
|
8
|
+
PaginationPreviousBaseProps,
|
|
9
|
+
} from '@gv-tech/ui-core';
|
|
10
|
+
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react-native';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { View } from 'react-native';
|
|
13
|
+
import { Button } from './button';
|
|
14
|
+
import { cn } from './lib/utils';
|
|
15
|
+
import { Text } from './text';
|
|
2
16
|
|
|
3
|
-
export const Pagination = () => {
|
|
17
|
+
export const Pagination = ({ className, children, ...props }: PaginationBaseProps) => {
|
|
4
18
|
return (
|
|
5
|
-
<View
|
|
6
|
-
|
|
19
|
+
<View
|
|
20
|
+
role="navigation"
|
|
21
|
+
aria-label="pagination"
|
|
22
|
+
className={cn('mx-auto flex w-full flex-row justify-center', className)}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
7
26
|
</View>
|
|
8
27
|
);
|
|
9
28
|
};
|
|
29
|
+
Pagination.displayName = 'Pagination';
|
|
30
|
+
|
|
31
|
+
export const PaginationContent = React.forwardRef<View, PaginationContentBaseProps>(
|
|
32
|
+
({ className, children, ...props }, ref) => (
|
|
33
|
+
<View ref={ref} className={cn('flex flex-row items-center gap-1', className)} {...props}>
|
|
34
|
+
{children}
|
|
35
|
+
</View>
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
PaginationContent.displayName = 'PaginationContent';
|
|
39
|
+
|
|
40
|
+
export const PaginationItem = React.forwardRef<View, PaginationItemBaseProps>(
|
|
41
|
+
({ className, children, ...props }, ref) => (
|
|
42
|
+
<View ref={ref} className={cn('', className)} {...props}>
|
|
43
|
+
{children}
|
|
44
|
+
</View>
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
PaginationItem.displayName = 'PaginationItem';
|
|
48
|
+
|
|
49
|
+
export type PaginationLinkProps = PaginationLinkBaseProps & {
|
|
50
|
+
onPress?: () => void;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const PaginationLink = ({
|
|
54
|
+
className,
|
|
55
|
+
isActive,
|
|
56
|
+
size = 'icon',
|
|
57
|
+
children,
|
|
58
|
+
onPress,
|
|
59
|
+
...props
|
|
60
|
+
}: PaginationLinkProps) => {
|
|
61
|
+
return (
|
|
62
|
+
<Button variant={isActive ? 'outline' : 'ghost'} size={size} onPress={onPress} className={className} {...props}>
|
|
63
|
+
{children}
|
|
64
|
+
</Button>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
PaginationLink.displayName = 'PaginationLink';
|
|
68
|
+
|
|
69
|
+
export const PaginationPrevious = ({
|
|
70
|
+
className,
|
|
71
|
+
children,
|
|
72
|
+
onPress,
|
|
73
|
+
...props
|
|
74
|
+
}: PaginationPreviousBaseProps & { onPress?: () => void }) => (
|
|
75
|
+
<PaginationLink
|
|
76
|
+
aria-label="Go to previous page"
|
|
77
|
+
size="default"
|
|
78
|
+
className={cn('flex flex-row items-center gap-1 pl-2.5', className)}
|
|
79
|
+
onPress={onPress}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<ChevronLeft size={16} className="text-foreground" />
|
|
83
|
+
<Text className="text-sm font-medium">Previous</Text>
|
|
84
|
+
</PaginationLink>
|
|
85
|
+
);
|
|
86
|
+
PaginationPrevious.displayName = 'PaginationPrevious';
|
|
87
|
+
|
|
88
|
+
export const PaginationNext = ({
|
|
89
|
+
className,
|
|
90
|
+
children,
|
|
91
|
+
onPress,
|
|
92
|
+
...props
|
|
93
|
+
}: PaginationNextBaseProps & { onPress?: () => void }) => (
|
|
94
|
+
<PaginationLink
|
|
95
|
+
aria-label="Go to next page"
|
|
96
|
+
size="default"
|
|
97
|
+
className={cn('flex flex-row items-center gap-1 pr-2.5', className)}
|
|
98
|
+
onPress={onPress}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<Text className="text-sm font-medium">Next</Text>
|
|
102
|
+
<ChevronRight size={16} className="text-foreground" />
|
|
103
|
+
</PaginationLink>
|
|
104
|
+
);
|
|
105
|
+
PaginationNext.displayName = 'PaginationNext';
|
|
106
|
+
|
|
107
|
+
export const PaginationEllipsis = ({ className, ...props }: PaginationEllipsisBaseProps) => (
|
|
108
|
+
<View aria-hidden className={cn('flex h-9 w-9 flex-row items-center justify-center', className)} {...props}>
|
|
109
|
+
<MoreHorizontal size={16} className="text-foreground" />
|
|
110
|
+
</View>
|
|
111
|
+
);
|
|
112
|
+
PaginationEllipsis.displayName = 'PaginationEllipsis';
|
package/src/resizable.tsx
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ResizableHandleBaseProps, ResizablePanelBaseProps, ResizablePanelGroupBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
2
4
|
|
|
3
|
-
export const ResizablePanelGroup = () => {
|
|
4
|
-
return
|
|
5
|
-
<View>
|
|
6
|
-
<Text>ResizablePanelGroup is not yet implemented for React Native</Text>
|
|
7
|
-
</View>
|
|
8
|
-
);
|
|
5
|
+
export const ResizablePanelGroup: React.FC<ResizablePanelGroupBaseProps> = ({ children, className }) => {
|
|
6
|
+
return <View className={className}>{children}</View>;
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
export const ResizablePanel = () => {
|
|
12
|
-
return
|
|
13
|
-
<View>
|
|
14
|
-
<Text>ResizablePanel is not yet implemented for React Native</Text>
|
|
15
|
-
</View>
|
|
16
|
-
);
|
|
9
|
+
export const ResizablePanel: React.FC<ResizablePanelBaseProps> = ({ children, className }) => {
|
|
10
|
+
return <View className={className}>{children}</View>;
|
|
17
11
|
};
|
|
18
12
|
|
|
19
|
-
export const ResizableHandle = () => {
|
|
20
|
-
return
|
|
21
|
-
<View>
|
|
22
|
-
<Text>ResizableHandle is not yet implemented for React Native</Text>
|
|
23
|
-
</View>
|
|
24
|
-
);
|
|
13
|
+
export const ResizableHandle: React.FC<ResizableHandleBaseProps> = ({ className }) => {
|
|
14
|
+
return <View className={className} />;
|
|
25
15
|
};
|
package/src/scroll-area.tsx
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ScrollAreaBaseProps, ScrollBarBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ScrollView, View } from 'react-native';
|
|
4
|
+
import { cn } from './lib/utils';
|
|
2
5
|
|
|
3
|
-
export const ScrollArea = (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const ScrollArea = React.forwardRef<ScrollView, ScrollAreaBaseProps>(
|
|
7
|
+
({ children, className, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<ScrollView
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn('flex-1', className)}
|
|
12
|
+
showsVerticalScrollIndicator={false}
|
|
13
|
+
showsHorizontalScrollIndicator={false}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
<View>{children}</View>
|
|
17
|
+
</ScrollView>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
ScrollArea.displayName = 'ScrollArea';
|
|
22
|
+
|
|
23
|
+
export const ScrollBar: React.FC<ScrollBarBaseProps> = () => {
|
|
24
|
+
return null;
|
|
9
25
|
};
|
|
26
|
+
ScrollBar.displayName = 'ScrollBar';
|
package/src/slider.tsx
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SliderBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as SliderPrimitive from '@rn-primitives/slider';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cn } from './lib/utils';
|
|
5
|
+
|
|
6
|
+
export const Slider: React.FC<SliderBaseProps> = ({
|
|
7
|
+
className,
|
|
8
|
+
value,
|
|
9
|
+
onValueChange: onValueChangeProp,
|
|
10
|
+
defaultValue,
|
|
11
|
+
min = 0,
|
|
12
|
+
max = 100,
|
|
13
|
+
step = 1,
|
|
14
|
+
disabled = false,
|
|
15
|
+
...props
|
|
16
|
+
}) => {
|
|
17
|
+
const numericValue = value !== undefined ? value[0] : min;
|
|
2
18
|
|
|
3
|
-
export const Slider = () => {
|
|
4
19
|
return (
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
20
|
+
<SliderPrimitive.Root
|
|
21
|
+
value={numericValue}
|
|
22
|
+
onValueChange={(val: number[]) => {
|
|
23
|
+
if (onValueChangeProp) {
|
|
24
|
+
const arrayVal = Array.isArray(val) ? val : [val];
|
|
25
|
+
onValueChangeProp(arrayVal);
|
|
26
|
+
}
|
|
27
|
+
}}
|
|
28
|
+
min={min}
|
|
29
|
+
max={max}
|
|
30
|
+
step={step}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
className={cn('relative flex w-full touch-none items-center select-none', disabled && 'opacity-50', className)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
<SliderPrimitive.Track className="bg-secondary relative h-2 w-full grow rounded-full">
|
|
36
|
+
<SliderPrimitive.Range className="bg-primary absolute h-full rounded-full" />
|
|
37
|
+
</SliderPrimitive.Track>
|
|
38
|
+
<SliderPrimitive.Thumb className="border-primary bg-background focus-visible:ring-ring block h-5 w-5 rounded-full border-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none" />
|
|
39
|
+
</SliderPrimitive.Root>
|
|
8
40
|
);
|
|
9
41
|
};
|
|
42
|
+
Slider.displayName = 'Slider';
|
package/src/sonner.tsx
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SonnerBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
2
4
|
|
|
3
|
-
export const Toaster = () => {
|
|
4
|
-
return
|
|
5
|
-
<View>
|
|
6
|
-
<Text>Toaster (Sonner) is not yet implemented for React Native</Text>
|
|
7
|
-
</View>
|
|
8
|
-
);
|
|
5
|
+
export const Toaster: React.FC<SonnerBaseProps> = ({ className }) => {
|
|
6
|
+
return <View className={className} />;
|
|
9
7
|
};
|
package/src/toaster.tsx
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ToasterBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { useToast } from './hooks/use-toast';
|
|
5
|
+
import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle } from './toast';
|
|
6
|
+
|
|
7
|
+
export const Toaster: React.FC<ToasterBaseProps> = () => {
|
|
8
|
+
const { toasts } = useToast();
|
|
2
9
|
|
|
3
|
-
export function Toaster() {
|
|
4
10
|
return (
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
11
|
+
<ToastProvider>
|
|
12
|
+
<View className="pointer-events-none absolute right-6 bottom-6 left-6 z-50 flex flex-col gap-2">
|
|
13
|
+
{toasts.map(({ id, title, description, action, ...props }) => (
|
|
14
|
+
<Toast key={id} {...props} className="pointer-events-auto">
|
|
15
|
+
<View className="flex flex-1 flex-col gap-1">
|
|
16
|
+
{title && <ToastTitle>{title}</ToastTitle>}
|
|
17
|
+
{description && <ToastDescription>{description}</ToastDescription>}
|
|
18
|
+
</View>
|
|
19
|
+
{action}
|
|
20
|
+
<ToastClose />
|
|
21
|
+
</Toast>
|
|
22
|
+
))}
|
|
23
|
+
</View>
|
|
24
|
+
</ToastProvider>
|
|
8
25
|
);
|
|
9
|
-
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default Toaster;
|