@gv-tech/ui-native 2.6.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/package.json +80 -0
- package/src/accordion.tsx +93 -0
- package/src/alert-dialog.tsx +123 -0
- package/src/alert.tsx +50 -0
- package/src/aspect-ratio.tsx +9 -0
- package/src/avatar.tsx +38 -0
- package/src/badge.tsx +51 -0
- package/src/breadcrumb.tsx +9 -0
- package/src/button.tsx +75 -0
- package/src/calendar.tsx +9 -0
- package/src/card.tsx +56 -0
- package/src/carousel.tsx +9 -0
- package/src/chart.tsx +9 -0
- package/src/checkbox.tsx +31 -0
- package/src/collapsible.tsx +15 -0
- package/src/command.tsx +9 -0
- package/src/context-menu.tsx +9 -0
- package/src/dialog.tsx +121 -0
- package/src/drawer.tsx +9 -0
- package/src/dropdown-menu.tsx +9 -0
- package/src/form.tsx +9 -0
- package/src/hover-card.tsx +9 -0
- package/src/index.ts +209 -0
- package/src/input.tsx +27 -0
- package/src/label.tsx +29 -0
- package/src/lib/render-native.tsx +17 -0
- package/src/lib/utils.ts +6 -0
- package/src/menubar.tsx +9 -0
- package/src/nativewind-env.d.ts +1 -0
- package/src/navigation-menu.tsx +9 -0
- package/src/pagination.tsx +9 -0
- package/src/popover.tsx +9 -0
- package/src/progress.tsx +9 -0
- package/src/radio-group.tsx +42 -0
- package/src/resizable.tsx +25 -0
- package/src/scroll-area.tsx +9 -0
- package/src/search.tsx +17 -0
- package/src/select.tsx +229 -0
- package/src/separator.tsx +20 -0
- package/src/sheet.tsx +127 -0
- package/src/skeleton.tsx +31 -0
- package/src/slider.tsx +9 -0
- package/src/sonner.tsx +9 -0
- package/src/switch.tsx +34 -0
- package/src/table.tsx +73 -0
- package/src/tabs.tsx +74 -0
- package/src/text.tsx +43 -0
- package/src/textarea.tsx +29 -0
- package/src/theme-provider.tsx +6 -0
- package/src/theme-toggle.tsx +11 -0
- package/src/toast.tsx +88 -0
- package/src/toaster.tsx +9 -0
- package/src/toggle-group.tsx +78 -0
- package/src/toggle.tsx +35 -0
- package/src/tooltip.tsx +44 -0
package/src/textarea.tsx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { cn } from './lib/utils';
|
|
5
|
+
|
|
6
|
+
export type TextareaProps = React.ComponentPropsWithoutRef<typeof TextInput>;
|
|
7
|
+
|
|
8
|
+
const Textarea = React.forwardRef<React.ElementRef<typeof TextInput>, TextareaProps>(
|
|
9
|
+
({ className, placeholderClassName, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<TextInput
|
|
12
|
+
ref={ref}
|
|
13
|
+
multiline
|
|
14
|
+
numberOfLines={props.numberOfLines || 3}
|
|
15
|
+
className={cn(
|
|
16
|
+
'flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base text-foreground shadow-sm transition-colors placeholder:text-muted-foreground focus:border-ring disabled:opacity-50',
|
|
17
|
+
className,
|
|
18
|
+
)}
|
|
19
|
+
placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
|
|
20
|
+
textAlignVertical="top"
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
Textarea.displayName = 'Textarea';
|
|
28
|
+
|
|
29
|
+
export { Textarea };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Text, TouchableOpacity, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export function ThemeToggle() {
|
|
4
|
+
return (
|
|
5
|
+
<TouchableOpacity onPress={() => {}}>
|
|
6
|
+
<View style={{ padding: 10, backgroundColor: '#eee', borderRadius: 5 }}>
|
|
7
|
+
<Text>Toggle Theme</Text>
|
|
8
|
+
</View>
|
|
9
|
+
</TouchableOpacity>
|
|
10
|
+
);
|
|
11
|
+
}
|
package/src/toast.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as ToastPrimitive from '@rn-primitives/toast';
|
|
2
|
+
import { X } from 'lucide-react-native';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import Animated, { FadeInUp, FadeOutDown, Layout } from 'react-native-reanimated';
|
|
5
|
+
|
|
6
|
+
import { cn } from './lib/utils';
|
|
7
|
+
|
|
8
|
+
// Toast for native doesn't use a Provider or Viewport in the same way as web.
|
|
9
|
+
// We export fragments if they are needed for structural parity in shared components.
|
|
10
|
+
const ToastProvider = ({ children }: { children: React.ReactNode }) => <>{children}</>;
|
|
11
|
+
const ToastViewport = () => null;
|
|
12
|
+
|
|
13
|
+
const Toast = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof ToastPrimitive.Root>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitive.Root> & { variant?: 'default' | 'destructive' }
|
|
16
|
+
>(({ className, variant = 'default', ...props }, ref) => {
|
|
17
|
+
return (
|
|
18
|
+
<ToastPrimitive.Root
|
|
19
|
+
ref={ref}
|
|
20
|
+
className={cn(
|
|
21
|
+
'group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg',
|
|
22
|
+
variant === 'default' ? 'border-border bg-background' : 'border-destructive bg-destructive',
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
>
|
|
27
|
+
<Animated.View entering={FadeInUp} exiting={FadeOutDown} layout={Layout} className="flex-row items-center w-full">
|
|
28
|
+
{props.children}
|
|
29
|
+
</Animated.View>
|
|
30
|
+
</ToastPrimitive.Root>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
Toast.displayName = ToastPrimitive.Root.displayName;
|
|
34
|
+
|
|
35
|
+
const ToastTitle = React.forwardRef<
|
|
36
|
+
React.ElementRef<typeof ToastPrimitive.Title>,
|
|
37
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitive.Title>
|
|
38
|
+
>(({ className, ...props }, ref) => (
|
|
39
|
+
<ToastPrimitive.Title ref={ref} className={cn('text-sm font-semibold text-foreground', className)} {...props} />
|
|
40
|
+
));
|
|
41
|
+
ToastTitle.displayName = ToastPrimitive.Title.displayName;
|
|
42
|
+
|
|
43
|
+
const ToastDescription = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof ToastPrimitive.Description>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitive.Description>
|
|
46
|
+
>(({ className, ...props }, ref) => (
|
|
47
|
+
<ToastPrimitive.Description
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn('text-sm opacity-90 text-muted-foreground', className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
));
|
|
53
|
+
ToastDescription.displayName = ToastPrimitive.Description.displayName;
|
|
54
|
+
|
|
55
|
+
const ToastClose = React.forwardRef<
|
|
56
|
+
React.ElementRef<typeof ToastPrimitive.Close>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitive.Close>
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<ToastPrimitive.Close
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
'absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100',
|
|
63
|
+
className,
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
<X size={16} className="text-muted-foreground" />
|
|
68
|
+
</ToastPrimitive.Close>
|
|
69
|
+
));
|
|
70
|
+
ToastClose.displayName = ToastPrimitive.Close.displayName;
|
|
71
|
+
|
|
72
|
+
const ToastAction = React.forwardRef<
|
|
73
|
+
React.ElementRef<typeof ToastPrimitive.Action>,
|
|
74
|
+
React.ComponentPropsWithoutRef<typeof ToastPrimitive.Action>
|
|
75
|
+
>(({ className, ...props }, ref) => (
|
|
76
|
+
<ToastPrimitive.Action
|
|
77
|
+
ref={ref}
|
|
78
|
+
className={cn(
|
|
79
|
+
'inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50',
|
|
80
|
+
className,
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
));
|
|
85
|
+
ToastAction.displayName = ToastPrimitive.Action.displayName;
|
|
86
|
+
|
|
87
|
+
export type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
88
|
+
export { Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport };
|
package/src/toaster.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ToggleGroupBaseProps, ToggleGroupItemBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as ToggleGroupPrimitive from '@rn-primitives/toggle-group';
|
|
3
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { cn } from './lib/utils';
|
|
7
|
+
import { TextClassContext } from './text';
|
|
8
|
+
import { toggleVariants } from './toggle';
|
|
9
|
+
|
|
10
|
+
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({
|
|
11
|
+
size: 'default',
|
|
12
|
+
variant: 'default',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export interface ToggleGroupProps
|
|
16
|
+
extends
|
|
17
|
+
Omit<React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root>, 'value' | 'onValueChange' | 'type'>,
|
|
18
|
+
ToggleGroupBaseProps {}
|
|
19
|
+
|
|
20
|
+
const ToggleGroup = React.forwardRef<React.ElementRef<typeof ToggleGroupPrimitive.Root>, ToggleGroupProps>(
|
|
21
|
+
({ className, variant, size, children, type, value, onValueChange, ...props }, ref) => (
|
|
22
|
+
<ToggleGroupPrimitive.Root
|
|
23
|
+
ref={ref}
|
|
24
|
+
{...({
|
|
25
|
+
type,
|
|
26
|
+
value,
|
|
27
|
+
onValueChange,
|
|
28
|
+
} as unknown as React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root>)}
|
|
29
|
+
className={cn('flex flex-row items-center justify-center gap-1', className)}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
|
|
33
|
+
</ToggleGroupPrimitive.Root>
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root?.displayName || 'ToggleGroup';
|
|
38
|
+
|
|
39
|
+
export interface ToggleGroupItemProps
|
|
40
|
+
extends
|
|
41
|
+
Omit<React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item>, 'children' | 'disabled'>,
|
|
42
|
+
ToggleGroupItemBaseProps {}
|
|
43
|
+
|
|
44
|
+
const ToggleGroupItem = React.forwardRef<React.ElementRef<typeof ToggleGroupPrimitive.Item>, ToggleGroupItemProps>(
|
|
45
|
+
({ className, children, variant, size, value, ...props }, ref) => {
|
|
46
|
+
const context = React.useContext(ToggleGroupContext);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<TextClassContext.Provider
|
|
50
|
+
value={cn(
|
|
51
|
+
'text-sm native:text-base text-foreground font-medium',
|
|
52
|
+
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
53
|
+
value === '' && 'text-accent-foreground',
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
<ToggleGroupPrimitive.Item
|
|
58
|
+
ref={ref}
|
|
59
|
+
value={value}
|
|
60
|
+
className={cn(
|
|
61
|
+
toggleVariants({
|
|
62
|
+
variant: context.variant || variant,
|
|
63
|
+
size: context.size || size,
|
|
64
|
+
}),
|
|
65
|
+
className,
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</ToggleGroupPrimitive.Item>
|
|
71
|
+
</TextClassContext.Provider>
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item?.displayName || 'ToggleGroupItem';
|
|
77
|
+
|
|
78
|
+
export { ToggleGroup, ToggleGroupItem };
|
package/src/toggle.tsx
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ToggleBaseProps, toggleVariants } from '@gv-tech/ui-core';
|
|
2
|
+
import * as TogglePrimitive from '@rn-primitives/toggle';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { cn } from './lib/utils';
|
|
6
|
+
import { TextClassContext } from './text';
|
|
7
|
+
|
|
8
|
+
export interface ToggleProps
|
|
9
|
+
extends
|
|
10
|
+
Omit<React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root>, 'pressed' | 'onPressedChange' | 'children'>,
|
|
11
|
+
ToggleBaseProps {}
|
|
12
|
+
|
|
13
|
+
const Toggle = React.forwardRef<React.ElementRef<typeof TogglePrimitive.Root>, ToggleProps>(
|
|
14
|
+
({ className, variant, size, ...props }, ref) => (
|
|
15
|
+
<TextClassContext.Provider
|
|
16
|
+
value={cn(
|
|
17
|
+
'text-sm native:text-base text-foreground font-medium',
|
|
18
|
+
props.pressed && 'text-accent-foreground',
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
>
|
|
22
|
+
<TogglePrimitive.Root
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
25
|
+
{...props}
|
|
26
|
+
pressed={props.pressed || false}
|
|
27
|
+
onPressedChange={props.onPressedChange || (() => {})}
|
|
28
|
+
/>
|
|
29
|
+
</TextClassContext.Provider>
|
|
30
|
+
),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
Toggle.displayName = TogglePrimitive.Root?.displayName || 'Toggle';
|
|
34
|
+
|
|
35
|
+
export { Toggle, toggleVariants };
|
package/src/tooltip.tsx
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as TooltipPrimitive from '@rn-primitives/tooltip';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
4
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
5
|
+
|
|
6
|
+
import { cn } from './lib/utils';
|
|
7
|
+
import { Text } from './text';
|
|
8
|
+
|
|
9
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
10
|
+
|
|
11
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
12
|
+
|
|
13
|
+
const TooltipContent = React.forwardRef<
|
|
14
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
15
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
|
|
16
|
+
portalHost?: string;
|
|
17
|
+
}
|
|
18
|
+
>(
|
|
19
|
+
(
|
|
20
|
+
{ className, portalHost, ...props },
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
_ref,
|
|
23
|
+
) => (
|
|
24
|
+
<TooltipPrimitive.Portal hostName={portalHost}>
|
|
25
|
+
<TooltipPrimitive.Overlay style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}>
|
|
26
|
+
<Animated.View
|
|
27
|
+
entering={FadeIn}
|
|
28
|
+
exiting={FadeOut}
|
|
29
|
+
className={cn(
|
|
30
|
+
'z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 shadow-md web:animate-in web:fade-in-0 web:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
<Text className="text-sm text-popover-foreground native:text-base">{props.children}</Text>
|
|
35
|
+
</Animated.View>
|
|
36
|
+
</TooltipPrimitive.Overlay>
|
|
37
|
+
</TooltipPrimitive.Portal>
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
TooltipContent.displayName = TooltipPrimitive.Content?.displayName || 'TooltipContent';
|
|
41
|
+
|
|
42
|
+
const TooltipProvider = ({ children }: { children: React.ReactNode }) => <>{children}</>;
|
|
43
|
+
|
|
44
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|