@react-native-reusables/cli 0.0.9 → 0.0.11
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/README.md +95 -5
- 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,177 @@
|
|
|
1
|
+
import * as NavigationMenuPrimitive from '@rnr/navigation-menu';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Platform, View } from 'react-native';
|
|
5
|
+
import Animated, {
|
|
6
|
+
Extrapolation,
|
|
7
|
+
FadeInLeft,
|
|
8
|
+
FadeOutLeft,
|
|
9
|
+
interpolate,
|
|
10
|
+
useAnimatedStyle,
|
|
11
|
+
useDerivedValue,
|
|
12
|
+
withTiming,
|
|
13
|
+
} from 'react-native-reanimated';
|
|
14
|
+
import { ChevronDown } from '../../components/Icons';
|
|
15
|
+
import { cn } from '../../lib/utils';
|
|
16
|
+
|
|
17
|
+
const NavigationMenu = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
|
|
20
|
+
>(({ className, children, ...props }, ref) => (
|
|
21
|
+
<NavigationMenuPrimitive.Root
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn('relative z-10 flex flex-row max-w-max items-center justify-center', className)}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
{Platform.OS === 'web' && <NavigationMenuViewport />}
|
|
28
|
+
</NavigationMenuPrimitive.Root>
|
|
29
|
+
));
|
|
30
|
+
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
|
31
|
+
|
|
32
|
+
const NavigationMenuList = React.forwardRef<
|
|
33
|
+
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<NavigationMenuPrimitive.List
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
'web:group flex flex-1 flex-row web:list-none items-center justify-center gap-1',
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
));
|
|
45
|
+
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
|
46
|
+
|
|
47
|
+
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
|
48
|
+
|
|
49
|
+
const navigationMenuTriggerStyle = cva(
|
|
50
|
+
'web:group web:inline-flex flex-row h-10 native:h-12 native:px-3 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium web:transition-colors web:hover:bg-accent active:bg-accent web:hover:text-accent-foreground web:focus:bg-accent web:focus:text-accent-foreground web:focus:outline-none web:disabled:pointer-events-none disabled:opacity-50 web:data-[active]:bg-accent/50 web:data-[state=open]:bg-accent/50'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const NavigationMenuTrigger = React.forwardRef<
|
|
54
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
55
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
|
|
56
|
+
>(({ className, children, ...props }, ref) => {
|
|
57
|
+
const { value } = NavigationMenuPrimitive.useRootContext();
|
|
58
|
+
const { value: itemValue } = NavigationMenuPrimitive.useItemContext();
|
|
59
|
+
|
|
60
|
+
const progress = useDerivedValue(() =>
|
|
61
|
+
value === itemValue ? withTiming(1, { duration: 250 }) : withTiming(0, { duration: 200 })
|
|
62
|
+
);
|
|
63
|
+
const chevronStyle = useAnimatedStyle(() => ({
|
|
64
|
+
transform: [{ rotate: `${progress.value * 180}deg` }],
|
|
65
|
+
opacity: interpolate(progress.value, [0, 1], [1, 0.8], Extrapolation.CLAMP),
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<NavigationMenuPrimitive.Trigger
|
|
70
|
+
ref={ref}
|
|
71
|
+
className={cn(
|
|
72
|
+
navigationMenuTriggerStyle(),
|
|
73
|
+
'web:group gap-1.5',
|
|
74
|
+
value === itemValue && 'bg-accent',
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
<>{children}</>
|
|
80
|
+
<Animated.View style={chevronStyle}>
|
|
81
|
+
<ChevronDown
|
|
82
|
+
size={12}
|
|
83
|
+
className={cn('relative text-foreground h-3 w-3 web:transition web:duration-200')}
|
|
84
|
+
aria-hidden={true}
|
|
85
|
+
/>
|
|
86
|
+
</Animated.View>
|
|
87
|
+
</NavigationMenuPrimitive.Trigger>
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
|
91
|
+
|
|
92
|
+
const NavigationMenuContent = React.forwardRef<
|
|
93
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
|
94
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
|
|
95
|
+
>(({ className, children, ...props }, ref) => {
|
|
96
|
+
const { value } = NavigationMenuPrimitive.useRootContext();
|
|
97
|
+
const { value: itemValue } = NavigationMenuPrimitive.useItemContext();
|
|
98
|
+
return (
|
|
99
|
+
<NavigationMenuPrimitive.Portal>
|
|
100
|
+
<NavigationMenuPrimitive.Content
|
|
101
|
+
ref={ref}
|
|
102
|
+
className={cn(
|
|
103
|
+
'left-0 top-0 w-full native:border native:border-border native:rounded-lg native:shadow-lg native:bg-popover native:text-popover-foreground native:overflow-hidden',
|
|
104
|
+
value === itemValue
|
|
105
|
+
? 'web:animate-in web:fade-in web:slide-in-from-right-20'
|
|
106
|
+
: 'web:animate-out web:fade-out web:slide-out-to-left-20',
|
|
107
|
+
className
|
|
108
|
+
)}
|
|
109
|
+
{...props}
|
|
110
|
+
>
|
|
111
|
+
<Animated.View
|
|
112
|
+
entering={Platform.OS !== 'web' ? FadeInLeft : undefined}
|
|
113
|
+
exiting={Platform.OS !== 'web' ? FadeOutLeft : undefined}
|
|
114
|
+
>
|
|
115
|
+
{children}
|
|
116
|
+
</Animated.View>
|
|
117
|
+
</NavigationMenuPrimitive.Content>
|
|
118
|
+
</NavigationMenuPrimitive.Portal>
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
|
122
|
+
|
|
123
|
+
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
|
124
|
+
|
|
125
|
+
const NavigationMenuViewport = React.forwardRef<
|
|
126
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
|
127
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
|
128
|
+
>(({ className, ...props }, ref) => {
|
|
129
|
+
return (
|
|
130
|
+
<View className={cn('absolute left-0 top-full flex justify-center')}>
|
|
131
|
+
<NavigationMenuPrimitive.Viewport
|
|
132
|
+
className={cn(
|
|
133
|
+
'web:origin-top-center relative mt-1.5 web:h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-lg web:animate-in web:zoom-in-90',
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
ref={ref}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
</View>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
|
143
|
+
|
|
144
|
+
const NavigationMenuIndicator = React.forwardRef<
|
|
145
|
+
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
|
146
|
+
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
|
|
147
|
+
>(({ className, ...props }, ref) => {
|
|
148
|
+
const { value } = NavigationMenuPrimitive.useRootContext();
|
|
149
|
+
const { value: itemValue } = NavigationMenuPrimitive.useItemContext();
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<NavigationMenuPrimitive.Indicator
|
|
153
|
+
ref={ref}
|
|
154
|
+
className={cn(
|
|
155
|
+
'top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
|
|
156
|
+
value === itemValue ? 'web:animate-in web:fade-in' : 'web:animate-out web:fade-out',
|
|
157
|
+
className
|
|
158
|
+
)}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
<View className='relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md shadow-foreground/5' />
|
|
162
|
+
</NavigationMenuPrimitive.Indicator>
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
|
166
|
+
|
|
167
|
+
export {
|
|
168
|
+
NavigationMenu,
|
|
169
|
+
NavigationMenuContent,
|
|
170
|
+
NavigationMenuIndicator,
|
|
171
|
+
NavigationMenuItem,
|
|
172
|
+
NavigationMenuLink,
|
|
173
|
+
NavigationMenuList,
|
|
174
|
+
NavigationMenuTrigger,
|
|
175
|
+
NavigationMenuViewport,
|
|
176
|
+
navigationMenuTriggerStyle,
|
|
177
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
import * as PopoverPrimitive from '@rnr/popover';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const Popover = PopoverPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const PopoverContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
|
|
15
|
+
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => {
|
|
16
|
+
return (
|
|
17
|
+
<PopoverPrimitive.Portal>
|
|
18
|
+
<PopoverPrimitive.Overlay style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}>
|
|
19
|
+
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut}>
|
|
20
|
+
<TextClassContext.Provider value='text-popover-foreground'>
|
|
21
|
+
<PopoverPrimitive.Content
|
|
22
|
+
ref={ref}
|
|
23
|
+
align={align}
|
|
24
|
+
sideOffset={sideOffset}
|
|
25
|
+
className={cn(
|
|
26
|
+
'z-50 w-72 rounded-md web:cursor-auto border border-border bg-popover p-4 shadow-md shadow-foreground/5 web:outline-none 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 web:animate-in web:zoom-in-95 web:fade-in-0',
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
</TextClassContext.Provider>
|
|
32
|
+
</Animated.View>
|
|
33
|
+
</PopoverPrimitive.Overlay>
|
|
34
|
+
</PopoverPrimitive.Portal>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
38
|
+
|
|
39
|
+
export { Popover, PopoverContent, PopoverTrigger };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import * as RadioGroupPrimitive from '@rnr/radio-group';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
const RadioGroup = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<RadioGroupPrimitive.Root className={cn('web:grid gap-2', className)} {...props} ref={ref} />
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
15
|
+
|
|
16
|
+
const RadioGroupItem = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
19
|
+
>(({ className, ...props }, ref) => {
|
|
20
|
+
return (
|
|
21
|
+
<RadioGroupPrimitive.Item
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn(
|
|
24
|
+
'aspect-square h-4 w-4 native:h-5 native:w-5 rounded-full justify-center items-center border border-primary text-primary web:ring-offset-background web:focus:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
25
|
+
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
<RadioGroupPrimitive.Indicator className='flex items-center justify-center'>
|
|
31
|
+
<View className='aspect-square h-[9px] w-[9px] native:h-[10] native:w-[10] bg-primary rounded-full' />
|
|
32
|
+
</RadioGroupPrimitive.Indicator>
|
|
33
|
+
</RadioGroupPrimitive.Item>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
37
|
+
|
|
38
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
4
|
+
import { Check, ChevronDown, ChevronUp } from '../../components/Icons';
|
|
5
|
+
import * as SelectPrimitive from '@rnr/select';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
type Option = SelectPrimitive.Option;
|
|
9
|
+
|
|
10
|
+
const Select = SelectPrimitive.Root;
|
|
11
|
+
|
|
12
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
13
|
+
|
|
14
|
+
const SelectValue = SelectPrimitive.Value;
|
|
15
|
+
|
|
16
|
+
const SelectTrigger = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
19
|
+
>(({ className, children, ...props }, ref) => (
|
|
20
|
+
<SelectPrimitive.Trigger
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn(
|
|
23
|
+
'flex flex-row h-10 native:h-12 items-center text-sm justify-between rounded-md border border-input bg-background px-3 py-2 web:ring-offset-background text-muted-foreground web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2 [&>span]:line-clamp-1',
|
|
24
|
+
props.disabled && 'web:cursor-not-allowed opacity-50',
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
<>{children}</>
|
|
30
|
+
<ChevronDown size={16} aria-hidden={true} className='text-foreground opacity-50' />
|
|
31
|
+
</SelectPrimitive.Trigger>
|
|
32
|
+
));
|
|
33
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Platform: WEB ONLY
|
|
37
|
+
*/
|
|
38
|
+
const SelectScrollUpButton = ({
|
|
39
|
+
className,
|
|
40
|
+
...props
|
|
41
|
+
}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>) => {
|
|
42
|
+
if (Platform.OS !== 'web') {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return (
|
|
46
|
+
<SelectPrimitive.ScrollUpButton
|
|
47
|
+
className={cn('flex web:cursor-default items-center justify-center py-1', className)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
<ChevronUp size={14} className='text-foreground' />
|
|
51
|
+
</SelectPrimitive.ScrollUpButton>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Platform: WEB ONLY
|
|
57
|
+
*/
|
|
58
|
+
const SelectScrollDownButton = ({
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>) => {
|
|
62
|
+
if (Platform.OS !== 'web') {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return (
|
|
66
|
+
<SelectPrimitive.ScrollDownButton
|
|
67
|
+
className={cn('flex web:cursor-default items-center justify-center py-1', className)}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
<ChevronDown size={14} className='text-foreground' />
|
|
71
|
+
</SelectPrimitive.ScrollDownButton>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const SelectContent = React.forwardRef<
|
|
76
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
77
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
78
|
+
>(({ className, children, position = 'popper', ...props }, ref) => {
|
|
79
|
+
const { open } = SelectPrimitive.useRootContext();
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<SelectPrimitive.Portal>
|
|
83
|
+
<SelectPrimitive.Overlay style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}>
|
|
84
|
+
<Animated.View entering={FadeIn} exiting={FadeOut}>
|
|
85
|
+
<SelectPrimitive.Content
|
|
86
|
+
ref={ref}
|
|
87
|
+
className={cn(
|
|
88
|
+
'relative z-50 max-h-96 min-w-[8rem] rounded-md border border-border bg-popover shadow-md shadow-foreground/10 py-2 px-1 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',
|
|
89
|
+
position === 'popper' &&
|
|
90
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
91
|
+
open
|
|
92
|
+
? 'web:zoom-in-95 web:animate-in web:fade-in-0'
|
|
93
|
+
: 'web:zoom-out-95 web:animate-out web:fade-out-0',
|
|
94
|
+
className
|
|
95
|
+
)}
|
|
96
|
+
position={position}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
<SelectScrollUpButton />
|
|
100
|
+
<SelectPrimitive.Viewport
|
|
101
|
+
className={cn(
|
|
102
|
+
'p-1',
|
|
103
|
+
position === 'popper' &&
|
|
104
|
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]'
|
|
105
|
+
)}
|
|
106
|
+
>
|
|
107
|
+
{children}
|
|
108
|
+
</SelectPrimitive.Viewport>
|
|
109
|
+
<SelectScrollDownButton />
|
|
110
|
+
</SelectPrimitive.Content>
|
|
111
|
+
</Animated.View>
|
|
112
|
+
</SelectPrimitive.Overlay>
|
|
113
|
+
</SelectPrimitive.Portal>
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
117
|
+
|
|
118
|
+
const SelectLabel = React.forwardRef<
|
|
119
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
120
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
121
|
+
>(({ className, ...props }, ref) => (
|
|
122
|
+
<SelectPrimitive.Label
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={cn(
|
|
125
|
+
'py-1.5 native:pb-2 pl-8 native:pl-10 pr-2 text-popover-foreground text-sm native:text-base font-semibold',
|
|
126
|
+
className
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
));
|
|
131
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
132
|
+
|
|
133
|
+
const SelectItem = React.forwardRef<
|
|
134
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
135
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
136
|
+
>(({ className, children, ...props }, ref) => (
|
|
137
|
+
<SelectPrimitive.Item
|
|
138
|
+
ref={ref}
|
|
139
|
+
className={cn(
|
|
140
|
+
'relative web:group flex flex-row w-full web:cursor-default web:select-none items-center rounded-sm py-1.5 native:py-2 pl-8 native:pl-10 pr-2 active:bg-accent web:outline-none web:focus:bg-accent',
|
|
141
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
142
|
+
className
|
|
143
|
+
)}
|
|
144
|
+
{...props}
|
|
145
|
+
>
|
|
146
|
+
<View className='absolute left-2 native:left-3.5 flex h-3.5 native:pt-px w-3.5 items-center justify-center'>
|
|
147
|
+
<SelectPrimitive.ItemIndicator>
|
|
148
|
+
<Check size={16} strokeWidth={3} className='text-popover-foreground' />
|
|
149
|
+
</SelectPrimitive.ItemIndicator>
|
|
150
|
+
</View>
|
|
151
|
+
|
|
152
|
+
<SelectPrimitive.ItemText className='text-sm native:text-lg text-popover-foreground native:text-base web:group-focus:text-accent-foreground' />
|
|
153
|
+
</SelectPrimitive.Item>
|
|
154
|
+
));
|
|
155
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
156
|
+
|
|
157
|
+
const SelectSeparator = React.forwardRef<
|
|
158
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
159
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
160
|
+
>(({ className, ...props }, ref) => (
|
|
161
|
+
<SelectPrimitive.Separator
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
|
164
|
+
{...props}
|
|
165
|
+
/>
|
|
166
|
+
));
|
|
167
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
168
|
+
|
|
169
|
+
export {
|
|
170
|
+
Select,
|
|
171
|
+
SelectContent,
|
|
172
|
+
SelectGroup,
|
|
173
|
+
SelectItem,
|
|
174
|
+
SelectLabel,
|
|
175
|
+
SelectScrollDownButton,
|
|
176
|
+
SelectScrollUpButton,
|
|
177
|
+
SelectSeparator,
|
|
178
|
+
SelectTrigger,
|
|
179
|
+
SelectValue,
|
|
180
|
+
type Option,
|
|
181
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as SeparatorPrimitive from '@rnr/separator';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Separator = React.forwardRef<
|
|
6
|
+
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
|
8
|
+
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
|
|
9
|
+
<SeparatorPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
decorative={decorative}
|
|
12
|
+
orientation={orientation}
|
|
13
|
+
className={cn(
|
|
14
|
+
'shrink-0 bg-border',
|
|
15
|
+
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
22
|
+
|
|
23
|
+
export { Separator };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Animated, {
|
|
3
|
+
useAnimatedStyle,
|
|
4
|
+
useSharedValue,
|
|
5
|
+
withRepeat,
|
|
6
|
+
withSequence,
|
|
7
|
+
withTiming,
|
|
8
|
+
} from 'react-native-reanimated';
|
|
9
|
+
import { cn } from '../../lib/utils';
|
|
10
|
+
|
|
11
|
+
const duration = 1000;
|
|
12
|
+
|
|
13
|
+
function Skeleton({
|
|
14
|
+
className,
|
|
15
|
+
...props
|
|
16
|
+
}: Omit<React.ComponentPropsWithoutRef<typeof Animated.View>, 'style'>) {
|
|
17
|
+
const sv = useSharedValue(1);
|
|
18
|
+
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
sv.value = withRepeat(
|
|
21
|
+
withSequence(withTiming(0.5, { duration }), withTiming(1, { duration })),
|
|
22
|
+
-1
|
|
23
|
+
);
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
const style = useAnimatedStyle(() => ({
|
|
27
|
+
opacity: sv.value,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Animated.View
|
|
32
|
+
style={style}
|
|
33
|
+
className={cn('rounded-md bg-secondary dark:bg-muted', className)}
|
|
34
|
+
{...props}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Skeleton };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import Animated, {
|
|
4
|
+
interpolateColor,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
useDerivedValue,
|
|
7
|
+
withTiming,
|
|
8
|
+
} from 'react-native-reanimated';
|
|
9
|
+
import * as SwitchPrimitives from '@rnr/switch';
|
|
10
|
+
import { useColorScheme } from '../../lib/useColorScheme';
|
|
11
|
+
|
|
12
|
+
import { cn } from '../../lib/utils';
|
|
13
|
+
|
|
14
|
+
const SwitchWeb = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
17
|
+
>(({ className, ...props }, ref) => (
|
|
18
|
+
<SwitchPrimitives.Root
|
|
19
|
+
className={cn(
|
|
20
|
+
'peer flex-row h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed',
|
|
21
|
+
props.checked ? 'bg-primary' : 'bg-input',
|
|
22
|
+
props.disabled && 'opacity-50',
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
ref={ref}
|
|
27
|
+
>
|
|
28
|
+
<SwitchPrimitives.Thumb
|
|
29
|
+
className={cn(
|
|
30
|
+
'pointer-events-none block h-5 w-5 rounded-full bg-background shadow-md shadow-foreground/5 ring-0 transition-transform',
|
|
31
|
+
props.checked ? 'translate-x-5' : 'translate-x-0'
|
|
32
|
+
)}
|
|
33
|
+
/>
|
|
34
|
+
</SwitchPrimitives.Root>
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
SwitchWeb.displayName = 'SwitchWeb';
|
|
38
|
+
|
|
39
|
+
const RGB_COLORS = {
|
|
40
|
+
light: {
|
|
41
|
+
primary: 'rgb(24, 24, 27)',
|
|
42
|
+
input: 'rgb(228, 228, 231)',
|
|
43
|
+
},
|
|
44
|
+
dark: {
|
|
45
|
+
primary: 'rgb(250, 250, 250)',
|
|
46
|
+
input: 'rgb(39, 39, 42)',
|
|
47
|
+
},
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
const SwitchNative = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
53
|
+
>(({ className, ...props }, ref) => {
|
|
54
|
+
const { colorScheme } = useColorScheme();
|
|
55
|
+
const translateX = useDerivedValue(() => (props.checked ? 18 : 0));
|
|
56
|
+
const animatedRootStyle = useAnimatedStyle(() => {
|
|
57
|
+
return {
|
|
58
|
+
backgroundColor: interpolateColor(
|
|
59
|
+
translateX.value,
|
|
60
|
+
[0, 18],
|
|
61
|
+
[RGB_COLORS[colorScheme].input, RGB_COLORS[colorScheme].primary]
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
const animatedThumbStyle = useAnimatedStyle(() => ({
|
|
66
|
+
transform: [{ translateX: withTiming(translateX.value, { duration: 200 }) }],
|
|
67
|
+
}));
|
|
68
|
+
return (
|
|
69
|
+
<Animated.View
|
|
70
|
+
style={animatedRootStyle}
|
|
71
|
+
className={cn('h-8 w-[46px] rounded-full', props.disabled && 'opacity-50')}
|
|
72
|
+
>
|
|
73
|
+
<SwitchPrimitives.Root
|
|
74
|
+
className={cn(
|
|
75
|
+
'flex-row h-8 w-[46px] shrink-0 items-center rounded-full border-2 border-transparent',
|
|
76
|
+
className
|
|
77
|
+
)}
|
|
78
|
+
{...props}
|
|
79
|
+
ref={ref}
|
|
80
|
+
>
|
|
81
|
+
<Animated.View style={animatedThumbStyle}>
|
|
82
|
+
<SwitchPrimitives.Thumb
|
|
83
|
+
className={'h-7 w-7 rounded-full bg-background shadow-md shadow-foreground/25 ring-0'}
|
|
84
|
+
/>
|
|
85
|
+
</Animated.View>
|
|
86
|
+
</SwitchPrimitives.Root>
|
|
87
|
+
</Animated.View>
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
SwitchNative.displayName = 'SwitchNative';
|
|
91
|
+
|
|
92
|
+
const Switch = Platform.select({
|
|
93
|
+
web: SwitchWeb,
|
|
94
|
+
default: SwitchNative,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export { Switch };
|