@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,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 { TextClassContext } from './text';
|
|
5
|
+
import * as DropdownMenuPrimitive from '@rnr/dropdown-menu';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
13
|
+
|
|
14
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
15
|
+
|
|
16
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
17
|
+
|
|
18
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
19
|
+
|
|
20
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
21
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
23
|
+
inset?: boolean;
|
|
24
|
+
}
|
|
25
|
+
>(({ className, inset, children, ...props }, ref) => {
|
|
26
|
+
const { open } = DropdownMenuPrimitive.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
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
'flex flex-row web:cursor-default web:select-none gap-2 items-center web:focus:bg-accent web:hover:bg-accent active: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
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
48
|
+
</TextClassContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
|
52
|
+
|
|
53
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
54
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
55
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
|
|
56
|
+
>(({ className, ...props }, ref) => {
|
|
57
|
+
const { open } = DropdownMenuPrimitive.useSubContext();
|
|
58
|
+
return (
|
|
59
|
+
<DropdownMenuPrimitive.SubContent
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border border-border mt-1 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
|
+
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
|
73
|
+
|
|
74
|
+
const DropdownMenuContent = React.forwardRef<
|
|
75
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> & {
|
|
77
|
+
overlayStyle?: StyleProp<ViewStyle>;
|
|
78
|
+
overlayClassName?: string;
|
|
79
|
+
}
|
|
80
|
+
>(({ className, overlayClassName, overlayStyle, ...props }, ref) => {
|
|
81
|
+
const { open } = DropdownMenuPrimitive.useRootContext();
|
|
82
|
+
return (
|
|
83
|
+
<DropdownMenuPrimitive.Portal>
|
|
84
|
+
<DropdownMenuPrimitive.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
|
+
<DropdownMenuPrimitive.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
|
+
</DropdownMenuPrimitive.Overlay>
|
|
109
|
+
</DropdownMenuPrimitive.Portal>
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
113
|
+
|
|
114
|
+
const DropdownMenuItem = React.forwardRef<
|
|
115
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
116
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.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
|
+
<DropdownMenuPrimitive.Item
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={cn(
|
|
124
|
+
'relative flex flex-row web:cursor-default gap-2 items-center 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
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
134
|
+
|
|
135
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
136
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
137
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
138
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
139
|
+
<DropdownMenuPrimitive.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
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
151
|
+
<Check size={14} strokeWidth={3} className='text-foreground' />
|
|
152
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
153
|
+
</View>
|
|
154
|
+
<>{children}</>
|
|
155
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
156
|
+
));
|
|
157
|
+
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
158
|
+
|
|
159
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
162
|
+
>(({ className, children, ...props }, ref) => (
|
|
163
|
+
<DropdownMenuPrimitive.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
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
174
|
+
<View className='bg-foreground h-2 w-2 rounded-full' />
|
|
175
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
176
|
+
</View>
|
|
177
|
+
<>{children}</>
|
|
178
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
179
|
+
));
|
|
180
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
181
|
+
|
|
182
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
183
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
184
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
185
|
+
inset?: boolean;
|
|
186
|
+
}
|
|
187
|
+
>(({ className, inset, ...props }, ref) => (
|
|
188
|
+
<DropdownMenuPrimitive.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
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
199
|
+
|
|
200
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
201
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
202
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
203
|
+
>(({ className, ...props }, ref) => (
|
|
204
|
+
<DropdownMenuPrimitive.Separator
|
|
205
|
+
ref={ref}
|
|
206
|
+
className={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
207
|
+
{...props}
|
|
208
|
+
/>
|
|
209
|
+
));
|
|
210
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
211
|
+
|
|
212
|
+
const DropdownMenuShortcut = ({
|
|
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
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
DropdownMenu,
|
|
230
|
+
DropdownMenuCheckboxItem,
|
|
231
|
+
DropdownMenuContent,
|
|
232
|
+
DropdownMenuGroup,
|
|
233
|
+
DropdownMenuItem,
|
|
234
|
+
DropdownMenuLabel,
|
|
235
|
+
DropdownMenuPortal,
|
|
236
|
+
DropdownMenuRadioGroup,
|
|
237
|
+
DropdownMenuRadioItem,
|
|
238
|
+
DropdownMenuSeparator,
|
|
239
|
+
DropdownMenuShortcut,
|
|
240
|
+
DropdownMenuSub,
|
|
241
|
+
DropdownMenuSubContent,
|
|
242
|
+
DropdownMenuSubTrigger,
|
|
243
|
+
DropdownMenuTrigger,
|
|
244
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import Animated, { FadeIn } from 'react-native-reanimated';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
import * as HoverCardPrimitive from '@rnr/hover-card';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const HoverCardContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
15
|
+
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => {
|
|
16
|
+
const { open } = HoverCardPrimitive.useRootContext();
|
|
17
|
+
return (
|
|
18
|
+
<HoverCardPrimitive.Portal>
|
|
19
|
+
<HoverCardPrimitive.Overlay
|
|
20
|
+
style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}
|
|
21
|
+
>
|
|
22
|
+
<Animated.View entering={FadeIn}>
|
|
23
|
+
<TextClassContext.Provider value='text-popover-foreground'>
|
|
24
|
+
<HoverCardPrimitive.Content
|
|
25
|
+
ref={ref}
|
|
26
|
+
align={align}
|
|
27
|
+
sideOffset={sideOffset}
|
|
28
|
+
className={cn(
|
|
29
|
+
'z-50 w-64 rounded-md border border-border bg-popover p-4 shadow-md shadow-foreground/5 web:outline-none web:cursor-auto 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',
|
|
30
|
+
open
|
|
31
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
32
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out-95 ',
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
</TextClassContext.Provider>
|
|
38
|
+
</Animated.View>
|
|
39
|
+
</HoverCardPrimitive.Overlay>
|
|
40
|
+
</HoverCardPrimitive.Portal>
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
44
|
+
|
|
45
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
const Input = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof TextInput>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof TextInput>
|
|
9
|
+
>(({ className, placeholderClassName, ...props }, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<TextInput
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
'web:flex h-10 native:h-12 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
15
|
+
props.editable === false && 'opacity-50 web:cursor-not-allowed',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
Input.displayName = 'Input';
|
|
25
|
+
|
|
26
|
+
export { Input };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as LabelPrimitive from '@rnr/label';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Label = React.forwardRef<
|
|
6
|
+
React.ElementRef<typeof LabelPrimitive.Text>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Text>
|
|
8
|
+
>(({ className, onPress, onLongPress, onPressIn, onPressOut, ...props }, ref) => (
|
|
9
|
+
<LabelPrimitive.Root
|
|
10
|
+
className='web:cursor-default'
|
|
11
|
+
onPress={onPress}
|
|
12
|
+
onLongPress={onLongPress}
|
|
13
|
+
onPressIn={onPressIn}
|
|
14
|
+
onPressOut={onPressOut}
|
|
15
|
+
>
|
|
16
|
+
<LabelPrimitive.Text
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(
|
|
19
|
+
'text-sm text-foreground native:text-base font-medium leading-none web:peer-disabled:cursor-not-allowed web:peer-disabled:opacity-70',
|
|
20
|
+
className
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
</LabelPrimitive.Root>
|
|
25
|
+
));
|
|
26
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
27
|
+
|
|
28
|
+
export { Label };
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Check, ChevronDown, ChevronRight, ChevronUp } from '../../components/Icons';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Platform, Text, View } from 'react-native';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
import * as MenubarPrimitive from '@rnr/menubar';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const MenubarMenu = MenubarPrimitive.Menu;
|
|
9
|
+
|
|
10
|
+
const MenubarGroup = MenubarPrimitive.Group;
|
|
11
|
+
|
|
12
|
+
const MenubarPortal = MenubarPrimitive.Portal;
|
|
13
|
+
|
|
14
|
+
const MenubarSub = MenubarPrimitive.Sub;
|
|
15
|
+
|
|
16
|
+
const MenubarRadioGroup = MenubarPrimitive.RadioGroup;
|
|
17
|
+
|
|
18
|
+
const Menubar = React.forwardRef<
|
|
19
|
+
React.ElementRef<typeof MenubarPrimitive.Root>,
|
|
20
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root>
|
|
21
|
+
>(({ className, ...props }, ref) => (
|
|
22
|
+
<MenubarPrimitive.Root
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn(
|
|
25
|
+
'flex flex-row h-10 native:h-12 items-center space-x-1 rounded-md border border-border bg-background p-1',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
));
|
|
31
|
+
Menubar.displayName = MenubarPrimitive.Root.displayName;
|
|
32
|
+
|
|
33
|
+
const MenubarTrigger = React.forwardRef<
|
|
34
|
+
React.ElementRef<typeof MenubarPrimitive.Trigger>,
|
|
35
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger>
|
|
36
|
+
>(({ className, ...props }, ref) => {
|
|
37
|
+
const { value } = MenubarPrimitive.useRootContext();
|
|
38
|
+
const { value: itemValue } = MenubarPrimitive.useMenuContext();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<MenubarPrimitive.Trigger
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(
|
|
44
|
+
'flex flex-row web:cursor-default web:select-none items-center rounded-sm px-3 py-1.5 text-sm native:h-10 native:px-5 native:py-0 font-medium web:outline-none web:focus:bg-accent active:bg-accent web:focus:text-accent-foreground',
|
|
45
|
+
value === itemValue && 'bg-accent text-accent-foreground',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName;
|
|
53
|
+
|
|
54
|
+
const MenubarSubTrigger = React.forwardRef<
|
|
55
|
+
React.ElementRef<typeof MenubarPrimitive.SubTrigger>,
|
|
56
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & {
|
|
57
|
+
inset?: boolean;
|
|
58
|
+
}
|
|
59
|
+
>(({ className, inset, children, ...props }, ref) => {
|
|
60
|
+
const { open } = MenubarPrimitive.useSubContext();
|
|
61
|
+
const Icon = Platform.OS === 'web' ? ChevronRight : open ? ChevronUp : ChevronDown;
|
|
62
|
+
return (
|
|
63
|
+
<TextClassContext.Provider
|
|
64
|
+
value={cn(
|
|
65
|
+
'select-none text-sm native:text-lg text-primary',
|
|
66
|
+
open && 'native:text-accent-foreground'
|
|
67
|
+
)}
|
|
68
|
+
>
|
|
69
|
+
<MenubarPrimitive.SubTrigger
|
|
70
|
+
ref={ref}
|
|
71
|
+
className={cn(
|
|
72
|
+
'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',
|
|
73
|
+
open && 'bg-accent',
|
|
74
|
+
inset && 'pl-8',
|
|
75
|
+
className
|
|
76
|
+
)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
<>{children}</>
|
|
80
|
+
<Icon size={18} className='ml-auto text-foreground' />
|
|
81
|
+
</MenubarPrimitive.SubTrigger>
|
|
82
|
+
</TextClassContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName;
|
|
86
|
+
|
|
87
|
+
const MenubarSubContent = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof MenubarPrimitive.SubContent>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent>
|
|
90
|
+
>(({ className, ...props }, ref) => {
|
|
91
|
+
const { open } = MenubarPrimitive.useSubContext();
|
|
92
|
+
return (
|
|
93
|
+
<MenubarPrimitive.SubContent
|
|
94
|
+
ref={ref}
|
|
95
|
+
className={cn(
|
|
96
|
+
'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',
|
|
97
|
+
open
|
|
98
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
99
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out ',
|
|
100
|
+
className
|
|
101
|
+
)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName;
|
|
107
|
+
|
|
108
|
+
const MenubarContent = React.forwardRef<
|
|
109
|
+
React.ElementRef<typeof MenubarPrimitive.Content>,
|
|
110
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content>
|
|
111
|
+
>(({ className, ...props }, ref) => {
|
|
112
|
+
const { value } = MenubarPrimitive.useRootContext();
|
|
113
|
+
const { value: itemValue } = MenubarPrimitive.useMenuContext();
|
|
114
|
+
return (
|
|
115
|
+
<MenubarPrimitive.Portal>
|
|
116
|
+
<MenubarPrimitive.Content
|
|
117
|
+
ref={ref}
|
|
118
|
+
className={cn(
|
|
119
|
+
'z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 shadow-md shadow-foreground/5 ',
|
|
120
|
+
value === itemValue
|
|
121
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
122
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
123
|
+
className
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
</MenubarPrimitive.Portal>
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
MenubarContent.displayName = MenubarPrimitive.Content.displayName;
|
|
131
|
+
|
|
132
|
+
const MenubarItem = React.forwardRef<
|
|
133
|
+
React.ElementRef<typeof MenubarPrimitive.Item>,
|
|
134
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & {
|
|
135
|
+
inset?: boolean;
|
|
136
|
+
}
|
|
137
|
+
>(({ className, inset, ...props }, ref) => (
|
|
138
|
+
<TextClassContext.Provider value='select-none text-sm native:text-lg text-popover-foreground web:group-focus:text-accent-foreground'>
|
|
139
|
+
<MenubarPrimitive.Item
|
|
140
|
+
ref={ref}
|
|
141
|
+
className={cn(
|
|
142
|
+
'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',
|
|
143
|
+
inset && 'pl-8',
|
|
144
|
+
props.disabled && 'opacity-50 web:pointer-events-none',
|
|
145
|
+
className
|
|
146
|
+
)}
|
|
147
|
+
{...props}
|
|
148
|
+
/>
|
|
149
|
+
</TextClassContext.Provider>
|
|
150
|
+
));
|
|
151
|
+
MenubarItem.displayName = MenubarPrimitive.Item.displayName;
|
|
152
|
+
|
|
153
|
+
const MenubarCheckboxItem = React.forwardRef<
|
|
154
|
+
React.ElementRef<typeof MenubarPrimitive.CheckboxItem>,
|
|
155
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem>
|
|
156
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
157
|
+
<MenubarPrimitive.CheckboxItem
|
|
158
|
+
ref={ref}
|
|
159
|
+
className={cn(
|
|
160
|
+
'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',
|
|
161
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
162
|
+
className
|
|
163
|
+
)}
|
|
164
|
+
checked={checked}
|
|
165
|
+
{...props}
|
|
166
|
+
>
|
|
167
|
+
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
168
|
+
<MenubarPrimitive.ItemIndicator>
|
|
169
|
+
<Check size={14} strokeWidth={3} className='text-foreground' />
|
|
170
|
+
</MenubarPrimitive.ItemIndicator>
|
|
171
|
+
</View>
|
|
172
|
+
<>{children}</>
|
|
173
|
+
</MenubarPrimitive.CheckboxItem>
|
|
174
|
+
));
|
|
175
|
+
MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName;
|
|
176
|
+
|
|
177
|
+
const MenubarRadioItem = React.forwardRef<
|
|
178
|
+
React.ElementRef<typeof MenubarPrimitive.RadioItem>,
|
|
179
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem>
|
|
180
|
+
>(({ className, children, ...props }, ref) => (
|
|
181
|
+
<MenubarPrimitive.RadioItem
|
|
182
|
+
ref={ref}
|
|
183
|
+
className={cn(
|
|
184
|
+
'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',
|
|
185
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
186
|
+
className
|
|
187
|
+
)}
|
|
188
|
+
{...props}
|
|
189
|
+
>
|
|
190
|
+
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
191
|
+
<MenubarPrimitive.ItemIndicator>
|
|
192
|
+
<View className='bg-foreground h-2 w-2 rounded-full' />
|
|
193
|
+
</MenubarPrimitive.ItemIndicator>
|
|
194
|
+
</View>
|
|
195
|
+
<>{children}</>
|
|
196
|
+
</MenubarPrimitive.RadioItem>
|
|
197
|
+
));
|
|
198
|
+
MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName;
|
|
199
|
+
|
|
200
|
+
const MenubarLabel = React.forwardRef<
|
|
201
|
+
React.ElementRef<typeof MenubarPrimitive.Label>,
|
|
202
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & {
|
|
203
|
+
inset?: boolean;
|
|
204
|
+
}
|
|
205
|
+
>(({ className, inset, ...props }, ref) => (
|
|
206
|
+
<MenubarPrimitive.Label
|
|
207
|
+
ref={ref}
|
|
208
|
+
className={cn(
|
|
209
|
+
'px-2 py-1.5 text-sm native:text-base font-semibold text-foreground web:cursor-default',
|
|
210
|
+
inset && 'pl-8',
|
|
211
|
+
className
|
|
212
|
+
)}
|
|
213
|
+
{...props}
|
|
214
|
+
/>
|
|
215
|
+
));
|
|
216
|
+
MenubarLabel.displayName = MenubarPrimitive.Label.displayName;
|
|
217
|
+
|
|
218
|
+
const MenubarSeparator = React.forwardRef<
|
|
219
|
+
React.ElementRef<typeof MenubarPrimitive.Separator>,
|
|
220
|
+
React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator>
|
|
221
|
+
>(({ className, ...props }, ref) => (
|
|
222
|
+
<MenubarPrimitive.Separator
|
|
223
|
+
ref={ref}
|
|
224
|
+
className={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
225
|
+
{...props}
|
|
226
|
+
/>
|
|
227
|
+
));
|
|
228
|
+
MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName;
|
|
229
|
+
|
|
230
|
+
const MenubarShortcut = ({ className, ...props }: React.ComponentPropsWithoutRef<typeof Text>) => {
|
|
231
|
+
return (
|
|
232
|
+
<Text
|
|
233
|
+
className={cn(
|
|
234
|
+
'ml-auto text-xs native:text-sm tracking-widest text-muted-foreground',
|
|
235
|
+
className
|
|
236
|
+
)}
|
|
237
|
+
{...props}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
241
|
+
MenubarShortcut.displayName = 'MenubarShortcut';
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
Menubar,
|
|
245
|
+
MenubarCheckboxItem,
|
|
246
|
+
MenubarContent,
|
|
247
|
+
MenubarGroup,
|
|
248
|
+
MenubarItem,
|
|
249
|
+
MenubarLabel,
|
|
250
|
+
MenubarMenu,
|
|
251
|
+
MenubarPortal,
|
|
252
|
+
MenubarRadioGroup,
|
|
253
|
+
MenubarRadioItem,
|
|
254
|
+
MenubarSeparator,
|
|
255
|
+
MenubarShortcut,
|
|
256
|
+
MenubarSub,
|
|
257
|
+
MenubarSubContent,
|
|
258
|
+
MenubarSubTrigger,
|
|
259
|
+
MenubarTrigger,
|
|
260
|
+
};
|