@react-native-reusables/cli 0.0.8 → 0.0.10
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/generated/components/primitives/accordion/accordion.tsx +216 -0
- package/dist/generated/components/primitives/accordion/accordion.web.tsx +295 -0
- package/dist/generated/components/primitives/accordion/index.ts +1 -0
- package/dist/generated/components/primitives/accordion/types.ts +45 -0
- package/dist/generated/components/primitives/alert-dialog/alert-dialog.tsx +237 -0
- package/dist/generated/components/primitives/alert-dialog/alert-dialog.web.tsx +256 -0
- package/dist/generated/components/primitives/alert-dialog/index.ts +1 -0
- package/dist/generated/components/primitives/alert-dialog/types.ts +48 -0
- package/dist/generated/components/primitives/aspect-ratio.tsx +23 -0
- package/dist/generated/components/primitives/avatar/ types.ts +10 -0
- package/dist/generated/components/primitives/avatar/index.tsx +95 -0
- package/dist/generated/components/primitives/checkbox/checkbox.tsx +101 -0
- package/dist/generated/components/primitives/checkbox/checkbox.web.tsx +114 -0
- package/dist/generated/components/primitives/checkbox/index.ts +1 -0
- package/dist/generated/components/primitives/checkbox/types.ts +11 -0
- package/dist/generated/components/primitives/collapsible/collapsible.tsx +119 -0
- package/dist/generated/components/primitives/collapsible/collapsible.web.tsx +157 -0
- package/dist/generated/components/primitives/collapsible/index.ts +1 -0
- package/dist/generated/components/primitives/collapsible/types.ts +18 -0
- package/dist/generated/components/primitives/context-menu/context-menu.tsx +626 -0
- package/dist/generated/components/primitives/context-menu/context-menu.web.tsx +504 -0
- package/dist/generated/components/primitives/context-menu/index.ts +1 -0
- package/dist/generated/components/primitives/context-menu/types.ts +82 -0
- package/dist/generated/components/primitives/dialog/dialog.tsx +211 -0
- package/dist/generated/components/primitives/dialog/dialog.web.tsx +197 -0
- package/dist/generated/components/primitives/dialog/index.ts +1 -0
- package/dist/generated/components/primitives/dialog/types.ts +60 -0
- package/dist/generated/components/primitives/dropdown-menu/dropdown-menu.tsx +584 -0
- package/dist/generated/components/primitives/dropdown-menu/dropdown-menu.web.tsx +521 -0
- package/dist/generated/components/primitives/dropdown-menu/index.ts +1 -0
- package/dist/generated/components/primitives/dropdown-menu/types.ts +71 -0
- package/dist/generated/components/primitives/hooks/index.ts +3 -0
- package/dist/generated/components/primitives/hooks/useAugmentedRef.tsx +29 -0
- package/dist/generated/components/primitives/hooks/useControllableState.tsx +75 -0
- package/dist/generated/components/primitives/hooks/useRelativePosition.tsx +227 -0
- package/dist/generated/components/primitives/hover-card/hover-card.tsx +271 -0
- package/dist/generated/components/primitives/hover-card/hover-card.web.tsx +145 -0
- package/dist/generated/components/primitives/hover-card/index.ts +1 -0
- package/dist/generated/components/primitives/hover-card/types.ts +42 -0
- package/dist/generated/components/primitives/label/index.ts +1 -0
- package/dist/generated/components/primitives/label/label.tsx +31 -0
- package/dist/generated/components/primitives/label/label.web.tsx +36 -0
- package/dist/generated/components/primitives/label/types.ts +15 -0
- package/dist/generated/components/primitives/menubar/index.ts +1 -0
- package/dist/generated/components/primitives/menubar/menubar.tsx +624 -0
- package/dist/generated/components/primitives/menubar/menubar.web.tsx +543 -0
- package/dist/generated/components/primitives/menubar/types.ts +76 -0
- package/dist/generated/components/primitives/navigation-menu/index.ts +1 -0
- package/dist/generated/components/primitives/navigation-menu/navigation-menu.tsx +315 -0
- package/dist/generated/components/primitives/navigation-menu/navigation-menu.web.tsx +264 -0
- package/dist/generated/components/primitives/navigation-menu/types.ts +49 -0
- package/dist/generated/components/primitives/popover/index.ts +1 -0
- package/dist/generated/components/primitives/popover/popover.tsx +286 -0
- package/dist/generated/components/primitives/popover/popover.web.tsx +179 -0
- package/dist/generated/components/primitives/popover/types.ts +30 -0
- package/dist/generated/components/primitives/portal.tsx +67 -0
- package/dist/generated/components/primitives/progress/index.ts +1 -0
- package/dist/generated/components/primitives/progress/progress.tsx +59 -0
- package/dist/generated/components/primitives/progress/progress.web.tsx +36 -0
- package/dist/generated/components/primitives/progress/types.ts +7 -0
- package/dist/generated/components/primitives/radio-group/index.ts +1 -0
- package/dist/generated/components/primitives/radio-group/radio-group.tsx +116 -0
- package/dist/generated/components/primitives/radio-group/radio-group.web.tsx +78 -0
- package/dist/generated/components/primitives/radio-group/types.ts +15 -0
- package/dist/generated/components/primitives/select/index.ts +1 -0
- package/dist/generated/components/primitives/select/select.tsx +455 -0
- package/dist/generated/components/primitives/select/select.web.tsx +319 -0
- package/dist/generated/components/primitives/select/types.ts +87 -0
- package/dist/generated/components/primitives/separator/ types.ts +6 -0
- package/dist/generated/components/primitives/separator/index.tsx +23 -0
- package/dist/generated/components/primitives/slider/index.ts +1 -0
- package/dist/generated/components/primitives/slider/slider.tsx +89 -0
- package/dist/generated/components/primitives/slider/slider.web.tsx +67 -0
- package/dist/generated/components/primitives/slider/types.ts +24 -0
- package/dist/generated/components/primitives/slot.tsx +187 -0
- package/dist/generated/components/primitives/switch/index.ts +1 -0
- package/dist/generated/components/primitives/switch/switch.tsx +65 -0
- package/dist/generated/components/primitives/switch/switch.web.tsx +67 -0
- package/dist/generated/components/primitives/switch/types.ts +11 -0
- package/dist/generated/components/primitives/table.tsx +55 -0
- package/dist/generated/components/primitives/tabs/index.ts +1 -0
- package/dist/generated/components/primitives/tabs/tabs.tsx +133 -0
- package/dist/generated/components/primitives/tabs/tabs.web.tsx +97 -0
- package/dist/generated/components/primitives/tabs/types.ts +24 -0
- package/dist/generated/components/primitives/toast/ types.ts +7 -0
- package/dist/generated/components/primitives/toast/index.tsx +128 -0
- package/dist/generated/components/primitives/toggle/index.ts +1 -0
- package/dist/generated/components/primitives/toggle/toggle.tsx +37 -0
- package/dist/generated/components/primitives/toggle/toggle.web.tsx +26 -0
- package/dist/generated/components/primitives/toggle/types.ts +7 -0
- package/dist/generated/components/primitives/toggle-group/index.ts +1 -0
- package/dist/generated/components/primitives/toggle-group/toggle-group.tsx +125 -0
- package/dist/generated/components/primitives/toggle-group/toggle-group.web.tsx +124 -0
- package/dist/generated/components/primitives/toggle-group/types.ts +37 -0
- package/dist/generated/components/primitives/toolbar/index.ts +1 -0
- package/dist/generated/components/primitives/toolbar/toolbar.tsx +125 -0
- package/dist/generated/components/primitives/toolbar/toolbar.web.tsx +129 -0
- package/dist/generated/components/primitives/toolbar/types.ts +39 -0
- package/dist/generated/components/primitives/tooltip/index.ts +1 -0
- package/dist/generated/components/primitives/tooltip/tooltip.tsx +271 -0
- package/dist/generated/components/primitives/tooltip/tooltip.web.tsx +167 -0
- package/dist/generated/components/primitives/tooltip/types.ts +44 -0
- package/dist/generated/components/primitives/types.ts +105 -0
- package/dist/generated/components/primitives/utils.ts +61 -0
- package/dist/generated/components/ui/accordion.tsx +127 -0
- package/dist/generated/components/ui/alert-dialog.tsx +167 -0
- package/dist/generated/components/ui/aspect-ratio.tsx +5 -0
- package/dist/generated/components/ui/avatar.tsx +44 -0
- package/dist/generated/components/ui/badge.tsx +51 -0
- package/dist/generated/components/ui/button.tsx +88 -0
- package/dist/generated/components/ui/card.tsx +67 -0
- package/dist/generated/components/ui/checkbox.tsx +34 -0
- package/dist/generated/components/ui/collapsible.tsx +9 -0
- package/dist/generated/components/ui/context-menu.tsx +244 -0
- package/dist/generated/components/ui/dialog.tsx +150 -0
- package/dist/generated/components/ui/dropdown-menu.tsx +244 -0
- package/dist/generated/components/ui/hover-card.tsx +45 -0
- package/dist/generated/components/ui/input.tsx +26 -0
- package/dist/generated/components/ui/label.tsx +28 -0
- package/dist/generated/components/ui/menubar.tsx +260 -0
- package/dist/generated/components/ui/navigation-menu.tsx +177 -0
- package/dist/generated/components/ui/popover.tsx +39 -0
- package/dist/generated/components/ui/radio-group.tsx +38 -0
- package/dist/generated/components/ui/select.tsx +181 -0
- package/dist/generated/components/ui/separator.tsx +23 -0
- package/dist/generated/components/ui/skeleton.tsx +39 -0
- package/dist/generated/components/ui/switch.tsx +97 -0
- package/dist/generated/components/ui/table.tsx +99 -0
- package/dist/generated/components/ui/tabs.tsx +65 -0
- package/dist/generated/components/ui/text.tsx +24 -0
- package/dist/generated/components/ui/textarea.tsx +28 -0
- package/dist/generated/components/ui/toggle-group.tsx +86 -0
- package/dist/generated/components/ui/toggle.tsx +85 -0
- package/dist/generated/components/ui/tooltip.tsx +36 -0
- package/dist/generated/components/ui/typography.tsx +204 -0
- package/package.json +8 -8
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import { TextClassContext } from './text';
|
|
4
|
+
import { TextRef, ViewRef } from '@rnr/types';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const Card = React.forwardRef<ViewRef, React.ComponentPropsWithoutRef<typeof View>>(
|
|
8
|
+
({ className, ...props }, ref) => (
|
|
9
|
+
<View
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
'rounded-lg border border-border bg-card shadow-sm shadow-foreground/10',
|
|
13
|
+
className
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
);
|
|
19
|
+
Card.displayName = 'Card';
|
|
20
|
+
|
|
21
|
+
const CardHeader = React.forwardRef<ViewRef, React.ComponentPropsWithoutRef<typeof View>>(
|
|
22
|
+
({ className, ...props }, ref) => (
|
|
23
|
+
<View ref={ref} className={cn('flex flex-col space-y-1.5 p-6', className)} {...props} />
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
CardHeader.displayName = 'CardHeader';
|
|
27
|
+
|
|
28
|
+
const CardTitle = React.forwardRef<TextRef, React.ComponentPropsWithoutRef<typeof Text>>(
|
|
29
|
+
({ className, ...props }, ref) => (
|
|
30
|
+
<Text
|
|
31
|
+
role='heading'
|
|
32
|
+
aria-level={3}
|
|
33
|
+
ref={ref}
|
|
34
|
+
className={cn(
|
|
35
|
+
'text-2xl text-card-foreground font-semibold leading-none tracking-tight',
|
|
36
|
+
className
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
CardTitle.displayName = 'CardTitle';
|
|
43
|
+
|
|
44
|
+
const CardDescription = React.forwardRef<TextRef, React.ComponentPropsWithoutRef<typeof Text>>(
|
|
45
|
+
({ className, ...props }, ref) => (
|
|
46
|
+
<Text ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
CardDescription.displayName = 'CardDescription';
|
|
50
|
+
|
|
51
|
+
const CardContent = React.forwardRef<ViewRef, React.ComponentPropsWithoutRef<typeof View>>(
|
|
52
|
+
({ className, ...props }, ref) => (
|
|
53
|
+
<TextClassContext.Provider value='text-card-foreground'>
|
|
54
|
+
<View ref={ref} className={cn('p-6 pt-0', className)} {...props} />
|
|
55
|
+
</TextClassContext.Provider>
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
CardContent.displayName = 'CardContent';
|
|
59
|
+
|
|
60
|
+
const CardFooter = React.forwardRef<ViewRef, React.ComponentPropsWithoutRef<typeof View>>(
|
|
61
|
+
({ className, ...props }, ref) => (
|
|
62
|
+
<View ref={ref} className={cn('flex flex-row items-center p-6 pt-0', className)} {...props} />
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
CardFooter.displayName = 'CardFooter';
|
|
66
|
+
|
|
67
|
+
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Check } from '../../components/Icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as CheckboxPrimitive from '@rnr/checkbox';
|
|
4
|
+
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const Checkbox = React.forwardRef<
|
|
9
|
+
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
|
11
|
+
>(({ className, ...props }, ref) => {
|
|
12
|
+
return (
|
|
13
|
+
<CheckboxPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
className={cn(
|
|
16
|
+
'web:peer h-4 w-4 native:h-[20] native:w-[20] shrink-0 rounded-sm native:rounded border border-primary web:ring-offset-background web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
|
|
17
|
+
props.checked && 'bg-primary',
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<CheckboxPrimitive.Indicator className={cn('items-center justify-center h-full w-full')}>
|
|
23
|
+
<Check
|
|
24
|
+
size={12}
|
|
25
|
+
strokeWidth={Platform.OS === 'web' ? 2.5 : 3.5}
|
|
26
|
+
className='text-primary-foreground'
|
|
27
|
+
/>
|
|
28
|
+
</CheckboxPrimitive.Indicator>
|
|
29
|
+
</CheckboxPrimitive.Root>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
33
|
+
|
|
34
|
+
export { Checkbox };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from '@rnr/collapsible';
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.Trigger;
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.Content;
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Check, ChevronDown, ChevronRight, ChevronUp } from '../../components/Icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Platform, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native';
|
|
4
|
+
import * as ContextMenuPrimitive from '@rnr/context-menu';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { TextClassContext } from './text';
|
|
7
|
+
|
|
8
|
+
const ContextMenu = ContextMenuPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
13
|
+
|
|
14
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
15
|
+
|
|
16
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
17
|
+
|
|
18
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
19
|
+
|
|
20
|
+
const ContextMenuSubTrigger = React.forwardRef<
|
|
21
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
23
|
+
inset?: boolean;
|
|
24
|
+
}
|
|
25
|
+
>(({ className, inset, children, ...props }, ref) => {
|
|
26
|
+
const { open } = ContextMenuPrimitive.useSubContext();
|
|
27
|
+
const Icon = Platform.OS === 'web' ? ChevronRight : open ? ChevronUp : ChevronDown;
|
|
28
|
+
return (
|
|
29
|
+
<TextClassContext.Provider
|
|
30
|
+
value={cn(
|
|
31
|
+
'select-none text-sm native:text-lg text-primary',
|
|
32
|
+
open && 'native:text-accent-foreground'
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
<ContextMenuPrimitive.SubTrigger
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
'flex flex-row web:cursor-default web:select-none items-center gap-2 web:focus:bg-accent active:bg-accent web:hover:bg-accent rounded-sm px-2 py-1.5 native:py-2 web:outline-none',
|
|
39
|
+
open && 'bg-accent',
|
|
40
|
+
inset && 'pl-8',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
45
|
+
<>{children}</>
|
|
46
|
+
<Icon size={18} className='ml-auto text-foreground' />
|
|
47
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
48
|
+
</TextClassContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
52
|
+
|
|
53
|
+
const ContextMenuSubContent = React.forwardRef<
|
|
54
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
55
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
56
|
+
>(({ className, ...props }, ref) => {
|
|
57
|
+
const { open } = ContextMenuPrimitive.useSubContext();
|
|
58
|
+
return (
|
|
59
|
+
<ContextMenuPrimitive.SubContent
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border mt-1 border-border bg-popover p-1 shadow-md shadow-foreground/5 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',
|
|
63
|
+
open
|
|
64
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
65
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out ',
|
|
66
|
+
className
|
|
67
|
+
)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
73
|
+
|
|
74
|
+
const ContextMenuContent = React.forwardRef<
|
|
75
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> & {
|
|
77
|
+
overlayStyle?: StyleProp<ViewStyle>;
|
|
78
|
+
overlayClassName?: string;
|
|
79
|
+
}
|
|
80
|
+
>(({ className, overlayClassName, overlayStyle, ...props }, ref) => {
|
|
81
|
+
const { open } = ContextMenuPrimitive.useRootContext();
|
|
82
|
+
return (
|
|
83
|
+
<ContextMenuPrimitive.Portal>
|
|
84
|
+
<ContextMenuPrimitive.Overlay
|
|
85
|
+
style={
|
|
86
|
+
overlayStyle
|
|
87
|
+
? StyleSheet.flatten([
|
|
88
|
+
Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined,
|
|
89
|
+
overlayStyle,
|
|
90
|
+
])
|
|
91
|
+
: Platform.OS !== 'web'
|
|
92
|
+
? StyleSheet.absoluteFill
|
|
93
|
+
: undefined
|
|
94
|
+
}
|
|
95
|
+
className={overlayClassName}
|
|
96
|
+
>
|
|
97
|
+
<ContextMenuPrimitive.Content
|
|
98
|
+
ref={ref}
|
|
99
|
+
className={cn(
|
|
100
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 shadow-md shadow-foreground/5 web:data-[side=bottom]:slide-in-from-top-2 web:data-[side=left]:slide-in-from-right-2 web:data-[side=right]:slide-in-from-left-2 web:data-[side=top]:slide-in-from-bottom-2',
|
|
101
|
+
open
|
|
102
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
103
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
</ContextMenuPrimitive.Overlay>
|
|
109
|
+
</ContextMenuPrimitive.Portal>
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
113
|
+
|
|
114
|
+
const ContextMenuItem = React.forwardRef<
|
|
115
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
116
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
|
117
|
+
inset?: boolean;
|
|
118
|
+
}
|
|
119
|
+
>(({ className, inset, ...props }, ref) => (
|
|
120
|
+
<TextClassContext.Provider value='select-none text-sm native:text-lg text-popover-foreground web:group-focus:text-accent-foreground'>
|
|
121
|
+
<ContextMenuPrimitive.Item
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={cn(
|
|
124
|
+
'relative flex flex-row web:cursor-default items-center gap-2 rounded-sm px-2 py-1.5 native:py-2 web:outline-none web:focus:bg-accent active:bg-accent web:hover:bg-accent group',
|
|
125
|
+
inset && 'pl-8',
|
|
126
|
+
props.disabled && 'opacity-50 web:pointer-events-none',
|
|
127
|
+
className
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
</TextClassContext.Provider>
|
|
132
|
+
));
|
|
133
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
134
|
+
|
|
135
|
+
const ContextMenuCheckboxItem = React.forwardRef<
|
|
136
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
137
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
138
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
139
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
140
|
+
ref={ref}
|
|
141
|
+
className={cn(
|
|
142
|
+
'relative flex flex-row web:cursor-default items-center web:group rounded-sm py-1.5 native:py-2 pl-8 pr-2 web:outline-none web:focus:bg-accent active:bg-accent',
|
|
143
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
144
|
+
className
|
|
145
|
+
)}
|
|
146
|
+
checked={checked}
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
150
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
151
|
+
<Check size={14} strokeWidth={3} className='text-foreground' />
|
|
152
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
153
|
+
</View>
|
|
154
|
+
<>{children}</>
|
|
155
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
156
|
+
));
|
|
157
|
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
|
158
|
+
|
|
159
|
+
const ContextMenuRadioItem = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
162
|
+
>(({ className, children, ...props }, ref) => (
|
|
163
|
+
<ContextMenuPrimitive.RadioItem
|
|
164
|
+
ref={ref}
|
|
165
|
+
className={cn(
|
|
166
|
+
'relative flex flex-row web:cursor-default web:group items-center rounded-sm py-1.5 native:py-2 pl-8 pr-2 web:outline-none web:focus:bg-accent active:bg-accent',
|
|
167
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
168
|
+
className
|
|
169
|
+
)}
|
|
170
|
+
{...props}
|
|
171
|
+
>
|
|
172
|
+
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
173
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
174
|
+
<View className='bg-foreground h-2 w-2 rounded-full' />
|
|
175
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
176
|
+
</View>
|
|
177
|
+
<>{children}</>
|
|
178
|
+
</ContextMenuPrimitive.RadioItem>
|
|
179
|
+
));
|
|
180
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
181
|
+
|
|
182
|
+
const ContextMenuLabel = React.forwardRef<
|
|
183
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
184
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
|
185
|
+
inset?: boolean;
|
|
186
|
+
}
|
|
187
|
+
>(({ className, inset, ...props }, ref) => (
|
|
188
|
+
<ContextMenuPrimitive.Label
|
|
189
|
+
ref={ref}
|
|
190
|
+
className={cn(
|
|
191
|
+
'px-2 py-1.5 text-sm native:text-base font-semibold text-foreground web:cursor-default',
|
|
192
|
+
inset && 'pl-8',
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
{...props}
|
|
196
|
+
/>
|
|
197
|
+
));
|
|
198
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
199
|
+
|
|
200
|
+
const ContextMenuSeparator = React.forwardRef<
|
|
201
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
202
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
203
|
+
>(({ className, ...props }, ref) => (
|
|
204
|
+
<ContextMenuPrimitive.Separator
|
|
205
|
+
ref={ref}
|
|
206
|
+
className={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
207
|
+
{...props}
|
|
208
|
+
/>
|
|
209
|
+
));
|
|
210
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
211
|
+
|
|
212
|
+
const ContextMenuShortcut = ({
|
|
213
|
+
className,
|
|
214
|
+
...props
|
|
215
|
+
}: React.ComponentPropsWithoutRef<typeof Text>) => {
|
|
216
|
+
return (
|
|
217
|
+
<Text
|
|
218
|
+
className={cn(
|
|
219
|
+
'ml-auto text-xs native:text-sm tracking-widest text-muted-foreground',
|
|
220
|
+
className
|
|
221
|
+
)}
|
|
222
|
+
{...props}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
ContextMenuShortcut.displayName = 'ContextMenuShortcut';
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
ContextMenu,
|
|
230
|
+
ContextMenuCheckboxItem,
|
|
231
|
+
ContextMenuContent,
|
|
232
|
+
ContextMenuGroup,
|
|
233
|
+
ContextMenuItem,
|
|
234
|
+
ContextMenuLabel,
|
|
235
|
+
ContextMenuPortal,
|
|
236
|
+
ContextMenuRadioGroup,
|
|
237
|
+
ContextMenuRadioItem,
|
|
238
|
+
ContextMenuSeparator,
|
|
239
|
+
ContextMenuShortcut,
|
|
240
|
+
ContextMenuSub,
|
|
241
|
+
ContextMenuSubContent,
|
|
242
|
+
ContextMenuSubTrigger,
|
|
243
|
+
ContextMenuTrigger,
|
|
244
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { X } from '../../components/Icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
4
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
5
|
+
import * as DialogPrimitive from '@rnr/dialog';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const Dialog = DialogPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
13
|
+
|
|
14
|
+
const DialogClose = DialogPrimitive.Close;
|
|
15
|
+
|
|
16
|
+
const DialogOverlayWeb = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
19
|
+
>(({ className, ...props }, ref) => {
|
|
20
|
+
const { open } = DialogPrimitive.useRootContext();
|
|
21
|
+
return (
|
|
22
|
+
<DialogPrimitive.Overlay
|
|
23
|
+
style={StyleSheet.absoluteFill}
|
|
24
|
+
className={cn(
|
|
25
|
+
'z-50 bg-black/80 flex justify-center items-center p-2',
|
|
26
|
+
open ? 'web:animate-in web:fade-in-0' : 'web:animate-out web:fade-out-0',
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
{...props}
|
|
30
|
+
ref={ref}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
DialogOverlayWeb.displayName = 'DialogOverlayWeb';
|
|
36
|
+
|
|
37
|
+
const DialogOverlayNative = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
40
|
+
>(({ className, children, ...props }, ref) => {
|
|
41
|
+
return (
|
|
42
|
+
<DialogPrimitive.Overlay
|
|
43
|
+
style={StyleSheet.absoluteFill}
|
|
44
|
+
className={cn('z-50 flex bg-black/80 justify-center items-center p-2', className)}
|
|
45
|
+
{...props}
|
|
46
|
+
ref={ref}
|
|
47
|
+
>
|
|
48
|
+
<Animated.View entering={FadeIn.duration(150)} exiting={FadeOut.duration(150)}>
|
|
49
|
+
<>{children}</>
|
|
50
|
+
</Animated.View>
|
|
51
|
+
</DialogPrimitive.Overlay>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
DialogOverlayNative.displayName = 'DialogOverlayNative';
|
|
56
|
+
|
|
57
|
+
const DialogOverlay = Platform.select({
|
|
58
|
+
web: DialogOverlayWeb,
|
|
59
|
+
default: DialogOverlayNative,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const DialogContent = React.forwardRef<
|
|
63
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
64
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
65
|
+
>(({ className, children, ...props }, ref) => {
|
|
66
|
+
const { open } = DialogPrimitive.useRootContext();
|
|
67
|
+
return (
|
|
68
|
+
<DialogPortal>
|
|
69
|
+
<DialogOverlay>
|
|
70
|
+
<DialogPrimitive.Content
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={cn(
|
|
73
|
+
'z-50 max-w-lg gap-4 border border-border web:cursor-default bg-background p-6 shadow-lg web:duration-200 rounded-lg',
|
|
74
|
+
open
|
|
75
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
76
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
>
|
|
81
|
+
{children}
|
|
82
|
+
<DialogPrimitive.Close
|
|
83
|
+
className={
|
|
84
|
+
'absolute right-4 top-4 p-0.5 web:group rounded-sm opacity-70 web:ring-offset-background web:transition-opacity web:hover:opacity-100 web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2 web:disabled:pointer-events-none'
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
<X
|
|
88
|
+
size={Platform.OS === 'web' ? 16 : 18}
|
|
89
|
+
className={cn('text-muted-foreground', open && 'text-accent-foreground')}
|
|
90
|
+
/>
|
|
91
|
+
</DialogPrimitive.Close>
|
|
92
|
+
</DialogPrimitive.Content>
|
|
93
|
+
</DialogOverlay>
|
|
94
|
+
</DialogPortal>
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
98
|
+
|
|
99
|
+
const DialogHeader = ({ className, ...props }: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
100
|
+
<View className={cn('flex flex-col gap-1.5 text-center sm:text-left', className)} {...props} />
|
|
101
|
+
);
|
|
102
|
+
DialogHeader.displayName = 'DialogHeader';
|
|
103
|
+
|
|
104
|
+
const DialogFooter = ({ className, ...props }: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
105
|
+
<View
|
|
106
|
+
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end gap-2', className)}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
DialogFooter.displayName = 'DialogFooter';
|
|
111
|
+
|
|
112
|
+
const DialogTitle = React.forwardRef<
|
|
113
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
114
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
115
|
+
>(({ className, ...props }, ref) => (
|
|
116
|
+
<DialogPrimitive.Title
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn(
|
|
119
|
+
'text-lg native:text-xl text-foreground font-semibold leading-none tracking-tight',
|
|
120
|
+
className
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
));
|
|
125
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
126
|
+
|
|
127
|
+
const DialogDescription = React.forwardRef<
|
|
128
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
129
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
130
|
+
>(({ className, ...props }, ref) => (
|
|
131
|
+
<DialogPrimitive.Description
|
|
132
|
+
ref={ref}
|
|
133
|
+
className={cn('text-sm native:text-base text-muted-foreground', className)}
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
));
|
|
137
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
Dialog,
|
|
141
|
+
DialogClose,
|
|
142
|
+
DialogContent,
|
|
143
|
+
DialogDescription,
|
|
144
|
+
DialogFooter,
|
|
145
|
+
DialogHeader,
|
|
146
|
+
DialogOverlay,
|
|
147
|
+
DialogPortal,
|
|
148
|
+
DialogTitle,
|
|
149
|
+
DialogTrigger,
|
|
150
|
+
};
|