@react-native-reusables/cli 0.4.1 → 0.5.0-beta.2
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/LICENSE +1 -1
- package/bin.cjs +60513 -0
- package/package.json +7 -80
- package/README.md +0 -63
- package/__generated/components/ui/accordion.tsx +0 -134
- package/__generated/components/ui/alert-dialog.tsx +0 -172
- package/__generated/components/ui/alert.tsx +0 -71
- package/__generated/components/ui/aspect-ratio.tsx +0 -5
- package/__generated/components/ui/avatar.tsx +0 -47
- package/__generated/components/ui/badge.tsx +0 -52
- package/__generated/components/ui/button.tsx +0 -81
- package/__generated/components/ui/card.tsx +0 -82
- package/__generated/components/ui/checkbox.tsx +0 -33
- package/__generated/components/ui/collapsible.tsx +0 -9
- package/__generated/components/ui/context-menu.tsx +0 -264
- package/__generated/components/ui/dialog.tsx +0 -159
- package/__generated/components/ui/dropdown-menu.tsx +0 -274
- package/__generated/components/ui/hover-card.tsx +0 -47
- package/__generated/components/ui/input.tsx +0 -25
- package/__generated/components/ui/label.tsx +0 -34
- package/__generated/components/ui/menubar.tsx +0 -284
- package/__generated/components/ui/navigation-menu.tsx +0 -191
- package/__generated/components/ui/popover.tsx +0 -42
- package/__generated/components/ui/progress.tsx +0 -62
- package/__generated/components/ui/radio-group.tsx +0 -36
- package/__generated/components/ui/select.tsx +0 -191
- package/__generated/components/ui/separator.tsx +0 -27
- package/__generated/components/ui/skeleton.tsx +0 -39
- package/__generated/components/ui/switch.tsx +0 -98
- package/__generated/components/ui/table.tsx +0 -108
- package/__generated/components/ui/tabs.tsx +0 -69
- package/__generated/components/ui/text.tsx +0 -26
- package/__generated/components/ui/textarea.tsx +0 -30
- package/__generated/components/ui/toggle-group.tsx +0 -94
- package/__generated/components/ui/toggle.tsx +0 -90
- package/__generated/components/ui/tooltip.tsx +0 -43
- package/__generated/components/ui/typography.tsx +0 -148
- package/__generated/starter-base/README.md +0 -16
- package/__generated/starter-base/app/+not-found.tsx +0 -18
- package/__generated/starter-base/app/_layout.tsx +0 -71
- package/__generated/starter-base/app/index.tsx +0 -95
- package/__generated/starter-base/app.json +0 -40
- package/__generated/starter-base/assets/images/adaptive-icon.png +0 -0
- package/__generated/starter-base/assets/images/favicon.png +0 -0
- package/__generated/starter-base/assets/images/icon.png +0 -0
- package/__generated/starter-base/assets/images/splash.png +0 -0
- package/__generated/starter-base/babel.config.js +0 -6
- package/__generated/starter-base/components/ThemeToggle.tsx +0 -30
- package/__generated/starter-base/components/ui/avatar.tsx +0 -47
- package/__generated/starter-base/components/ui/button.tsx +0 -81
- package/__generated/starter-base/components/ui/card.tsx +0 -82
- package/__generated/starter-base/components/ui/progress.tsx +0 -62
- package/__generated/starter-base/components/ui/text.tsx +0 -26
- package/__generated/starter-base/components/ui/tooltip.tsx +0 -44
- package/__generated/starter-base/gitignore-template +0 -41
- package/__generated/starter-base/global.css +0 -49
- package/__generated/starter-base/index.js +0 -12
- package/__generated/starter-base/lib/android-navigation-bar.ts +0 -11
- package/__generated/starter-base/lib/constants.ts +0 -18
- package/__generated/starter-base/lib/icons/Info.tsx +0 -4
- package/__generated/starter-base/lib/icons/MoonStar.tsx +0 -4
- package/__generated/starter-base/lib/icons/Sun.tsx +0 -4
- package/__generated/starter-base/lib/icons/iconWithClassName.ts +0 -14
- package/__generated/starter-base/lib/useColorScheme.tsx +0 -11
- package/__generated/starter-base/lib/utils.ts +0 -6
- package/__generated/starter-base/metro.config.js +0 -6
- package/__generated/starter-base/nativewind-env.d.ts +0 -1
- package/__generated/starter-base/npmrc-template +0 -2
- package/__generated/starter-base/package.json +0 -51
- package/__generated/starter-base/tailwind.config.js +0 -65
- package/__generated/starter-base/tsconfig.json +0 -19
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
Platform,
|
|
5
|
-
type StyleProp,
|
|
6
|
-
StyleSheet,
|
|
7
|
-
Text,
|
|
8
|
-
type TextProps,
|
|
9
|
-
View,
|
|
10
|
-
type ViewStyle,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
import { Check } from '../../lib/icons/Check';
|
|
13
|
-
import { ChevronDown } from '../../lib/icons/ChevronDown';
|
|
14
|
-
import { ChevronRight } from '../../lib/icons/ChevronRight';
|
|
15
|
-
import { ChevronUp } from '../../lib/icons/ChevronUp';
|
|
16
|
-
import { cn } from '../../lib/utils';
|
|
17
|
-
import { TextClassContext } from './text';
|
|
18
|
-
|
|
19
|
-
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
20
|
-
|
|
21
|
-
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
22
|
-
|
|
23
|
-
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
24
|
-
|
|
25
|
-
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
26
|
-
|
|
27
|
-
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
28
|
-
|
|
29
|
-
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
30
|
-
|
|
31
|
-
function DropdownMenuSubTrigger({
|
|
32
|
-
className,
|
|
33
|
-
inset,
|
|
34
|
-
children,
|
|
35
|
-
...props
|
|
36
|
-
}: DropdownMenuPrimitive.SubTriggerProps & {
|
|
37
|
-
ref?: React.RefObject<DropdownMenuPrimitive.SubTriggerRef>;
|
|
38
|
-
className?: string;
|
|
39
|
-
inset?: boolean;
|
|
40
|
-
children?: React.ReactNode;
|
|
41
|
-
}) {
|
|
42
|
-
const { open } = DropdownMenuPrimitive.useSubContext();
|
|
43
|
-
const Icon = Platform.OS === 'web' ? ChevronRight : open ? ChevronUp : ChevronDown;
|
|
44
|
-
return (
|
|
45
|
-
<TextClassContext.Provider
|
|
46
|
-
value={cn(
|
|
47
|
-
'select-none text-sm native:text-lg text-primary',
|
|
48
|
-
open && 'native:text-accent-foreground'
|
|
49
|
-
)}
|
|
50
|
-
>
|
|
51
|
-
<DropdownMenuPrimitive.SubTrigger
|
|
52
|
-
className={cn(
|
|
53
|
-
'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',
|
|
54
|
-
open && 'bg-accent',
|
|
55
|
-
inset && 'pl-8',
|
|
56
|
-
className
|
|
57
|
-
)}
|
|
58
|
-
{...props}
|
|
59
|
-
>
|
|
60
|
-
{children}
|
|
61
|
-
<Icon size={18} className='ml-auto text-foreground' />
|
|
62
|
-
</DropdownMenuPrimitive.SubTrigger>
|
|
63
|
-
</TextClassContext.Provider>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function DropdownMenuSubContent({
|
|
68
|
-
className,
|
|
69
|
-
...props
|
|
70
|
-
}: DropdownMenuPrimitive.SubContentProps & {
|
|
71
|
-
ref?: React.RefObject<DropdownMenuPrimitive.SubContentRef>;
|
|
72
|
-
}) {
|
|
73
|
-
const { open } = DropdownMenuPrimitive.useSubContext();
|
|
74
|
-
return (
|
|
75
|
-
<DropdownMenuPrimitive.SubContent
|
|
76
|
-
className={cn(
|
|
77
|
-
'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',
|
|
78
|
-
open
|
|
79
|
-
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
80
|
-
: 'web:animate-out web:fade-out-0 web:zoom-out',
|
|
81
|
-
className
|
|
82
|
-
)}
|
|
83
|
-
{...props}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function DropdownMenuContent({
|
|
89
|
-
className,
|
|
90
|
-
overlayClassName,
|
|
91
|
-
overlayStyle,
|
|
92
|
-
portalHost,
|
|
93
|
-
...props
|
|
94
|
-
}: DropdownMenuPrimitive.ContentProps & {
|
|
95
|
-
ref?: React.RefObject<DropdownMenuPrimitive.ContentRef>;
|
|
96
|
-
overlayStyle?: StyleProp<ViewStyle>;
|
|
97
|
-
overlayClassName?: string;
|
|
98
|
-
portalHost?: string;
|
|
99
|
-
}) {
|
|
100
|
-
const { open } = DropdownMenuPrimitive.useRootContext();
|
|
101
|
-
return (
|
|
102
|
-
<DropdownMenuPrimitive.Portal hostName={portalHost}>
|
|
103
|
-
<DropdownMenuPrimitive.Overlay
|
|
104
|
-
style={
|
|
105
|
-
overlayStyle
|
|
106
|
-
? StyleSheet.flatten([
|
|
107
|
-
Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined,
|
|
108
|
-
overlayStyle as typeof StyleSheet.absoluteFill,
|
|
109
|
-
])
|
|
110
|
-
: Platform.OS !== 'web'
|
|
111
|
-
? StyleSheet.absoluteFill
|
|
112
|
-
: undefined
|
|
113
|
-
}
|
|
114
|
-
className={overlayClassName}
|
|
115
|
-
>
|
|
116
|
-
<DropdownMenuPrimitive.Content
|
|
117
|
-
className={cn(
|
|
118
|
-
'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',
|
|
119
|
-
open
|
|
120
|
-
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
121
|
-
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
122
|
-
className
|
|
123
|
-
)}
|
|
124
|
-
{...props}
|
|
125
|
-
/>
|
|
126
|
-
</DropdownMenuPrimitive.Overlay>
|
|
127
|
-
</DropdownMenuPrimitive.Portal>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function DropdownMenuItem({
|
|
132
|
-
className,
|
|
133
|
-
inset,
|
|
134
|
-
...props
|
|
135
|
-
}: DropdownMenuPrimitive.ItemProps & {
|
|
136
|
-
ref?: React.RefObject<DropdownMenuPrimitive.ItemRef>;
|
|
137
|
-
className?: string;
|
|
138
|
-
inset?: boolean;
|
|
139
|
-
}) {
|
|
140
|
-
return (
|
|
141
|
-
<TextClassContext.Provider value='select-none text-sm native:text-lg text-popover-foreground web:group-focus:text-accent-foreground'>
|
|
142
|
-
<DropdownMenuPrimitive.Item
|
|
143
|
-
className={cn(
|
|
144
|
-
'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',
|
|
145
|
-
inset && 'pl-8',
|
|
146
|
-
props.disabled && 'opacity-50 web:pointer-events-none',
|
|
147
|
-
className
|
|
148
|
-
)}
|
|
149
|
-
{...props}
|
|
150
|
-
/>
|
|
151
|
-
</TextClassContext.Provider>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function DropdownMenuCheckboxItem({
|
|
156
|
-
className,
|
|
157
|
-
children,
|
|
158
|
-
checked,
|
|
159
|
-
...props
|
|
160
|
-
}: DropdownMenuPrimitive.CheckboxItemProps & {
|
|
161
|
-
ref?: React.RefObject<DropdownMenuPrimitive.CheckboxItemRef>;
|
|
162
|
-
children?: React.ReactNode;
|
|
163
|
-
}) {
|
|
164
|
-
return (
|
|
165
|
-
<DropdownMenuPrimitive.CheckboxItem
|
|
166
|
-
className={cn(
|
|
167
|
-
'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',
|
|
168
|
-
props.disabled && 'web:pointer-events-none opacity-50',
|
|
169
|
-
className
|
|
170
|
-
)}
|
|
171
|
-
checked={checked}
|
|
172
|
-
{...props}
|
|
173
|
-
>
|
|
174
|
-
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
175
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
176
|
-
<Check size={14} strokeWidth={3} className='text-foreground' />
|
|
177
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
178
|
-
</View>
|
|
179
|
-
{children}
|
|
180
|
-
</DropdownMenuPrimitive.CheckboxItem>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function DropdownMenuRadioItem({
|
|
185
|
-
className,
|
|
186
|
-
children,
|
|
187
|
-
...props
|
|
188
|
-
}: DropdownMenuPrimitive.RadioItemProps & {
|
|
189
|
-
ref?: React.RefObject<DropdownMenuPrimitive.RadioItemRef>;
|
|
190
|
-
children?: React.ReactNode;
|
|
191
|
-
}) {
|
|
192
|
-
return (
|
|
193
|
-
<DropdownMenuPrimitive.RadioItem
|
|
194
|
-
className={cn(
|
|
195
|
-
'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',
|
|
196
|
-
props.disabled && 'web:pointer-events-none opacity-50',
|
|
197
|
-
className
|
|
198
|
-
)}
|
|
199
|
-
{...props}
|
|
200
|
-
>
|
|
201
|
-
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
202
|
-
<DropdownMenuPrimitive.ItemIndicator>
|
|
203
|
-
<View className='bg-foreground h-2 w-2 rounded-full' />
|
|
204
|
-
</DropdownMenuPrimitive.ItemIndicator>
|
|
205
|
-
</View>
|
|
206
|
-
{children}
|
|
207
|
-
</DropdownMenuPrimitive.RadioItem>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function DropdownMenuLabel({
|
|
212
|
-
className,
|
|
213
|
-
inset,
|
|
214
|
-
...props
|
|
215
|
-
}: DropdownMenuPrimitive.LabelProps & {
|
|
216
|
-
ref?: React.RefObject<DropdownMenuPrimitive.LabelRef>;
|
|
217
|
-
className?: string;
|
|
218
|
-
inset?: boolean;
|
|
219
|
-
}) {
|
|
220
|
-
return (
|
|
221
|
-
<DropdownMenuPrimitive.Label
|
|
222
|
-
className={cn(
|
|
223
|
-
'px-2 py-1.5 text-sm native:text-base font-semibold text-foreground web:cursor-default',
|
|
224
|
-
inset && 'pl-8',
|
|
225
|
-
className
|
|
226
|
-
)}
|
|
227
|
-
{...props}
|
|
228
|
-
/>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function DropdownMenuSeparator({
|
|
233
|
-
className,
|
|
234
|
-
...props
|
|
235
|
-
}: DropdownMenuPrimitive.SeparatorProps & {
|
|
236
|
-
ref?: React.RefObject<DropdownMenuPrimitive.SeparatorRef>;
|
|
237
|
-
}) {
|
|
238
|
-
return (
|
|
239
|
-
<DropdownMenuPrimitive.Separator
|
|
240
|
-
className={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
241
|
-
{...props}
|
|
242
|
-
/>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function DropdownMenuShortcut({ className, ...props }: TextProps) {
|
|
247
|
-
return (
|
|
248
|
-
<Text
|
|
249
|
-
className={cn(
|
|
250
|
-
'ml-auto text-xs native:text-sm tracking-widest text-muted-foreground',
|
|
251
|
-
className
|
|
252
|
-
)}
|
|
253
|
-
{...props}
|
|
254
|
-
/>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export {
|
|
259
|
-
DropdownMenu,
|
|
260
|
-
DropdownMenuCheckboxItem,
|
|
261
|
-
DropdownMenuContent,
|
|
262
|
-
DropdownMenuGroup,
|
|
263
|
-
DropdownMenuItem,
|
|
264
|
-
DropdownMenuLabel,
|
|
265
|
-
DropdownMenuPortal,
|
|
266
|
-
DropdownMenuRadioGroup,
|
|
267
|
-
DropdownMenuRadioItem,
|
|
268
|
-
DropdownMenuSeparator,
|
|
269
|
-
DropdownMenuShortcut,
|
|
270
|
-
DropdownMenuSub,
|
|
271
|
-
DropdownMenuSubContent,
|
|
272
|
-
DropdownMenuSubTrigger,
|
|
273
|
-
DropdownMenuTrigger,
|
|
274
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as HoverCardPrimitive from '@rn-primitives/hover-card';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Platform, StyleSheet } from 'react-native';
|
|
4
|
-
import Animated, { FadeIn } from 'react-native-reanimated';
|
|
5
|
-
import { cn } from '../../lib/utils';
|
|
6
|
-
import { TextClassContext } from './text';
|
|
7
|
-
|
|
8
|
-
const HoverCard = HoverCardPrimitive.Root;
|
|
9
|
-
|
|
10
|
-
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
11
|
-
|
|
12
|
-
function HoverCardContent({
|
|
13
|
-
className,
|
|
14
|
-
align = 'center',
|
|
15
|
-
sideOffset = 4,
|
|
16
|
-
...props
|
|
17
|
-
}: HoverCardPrimitive.ContentProps & {
|
|
18
|
-
ref?: React.RefObject<HoverCardPrimitive.ContentRef>;
|
|
19
|
-
}) {
|
|
20
|
-
const { open } = HoverCardPrimitive.useRootContext();
|
|
21
|
-
return (
|
|
22
|
-
<HoverCardPrimitive.Portal>
|
|
23
|
-
<HoverCardPrimitive.Overlay
|
|
24
|
-
style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}
|
|
25
|
-
>
|
|
26
|
-
<Animated.View entering={FadeIn}>
|
|
27
|
-
<TextClassContext.Provider value='text-popover-foreground'>
|
|
28
|
-
<HoverCardPrimitive.Content
|
|
29
|
-
align={align}
|
|
30
|
-
sideOffset={sideOffset}
|
|
31
|
-
className={cn(
|
|
32
|
-
'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',
|
|
33
|
-
open
|
|
34
|
-
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
35
|
-
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
36
|
-
className
|
|
37
|
-
)}
|
|
38
|
-
{...props}
|
|
39
|
-
/>
|
|
40
|
-
</TextClassContext.Provider>
|
|
41
|
-
</Animated.View>
|
|
42
|
-
</HoverCardPrimitive.Overlay>
|
|
43
|
-
</HoverCardPrimitive.Portal>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { TextInput, type TextInputProps } from 'react-native';
|
|
3
|
-
import { cn } from '../../lib/utils';
|
|
4
|
-
|
|
5
|
-
function Input({
|
|
6
|
-
className,
|
|
7
|
-
placeholderClassName,
|
|
8
|
-
...props
|
|
9
|
-
}: TextInputProps & {
|
|
10
|
-
ref?: React.RefObject<TextInput>;
|
|
11
|
-
}) {
|
|
12
|
-
return (
|
|
13
|
-
<TextInput
|
|
14
|
-
className={cn(
|
|
15
|
-
'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',
|
|
16
|
-
props.editable === false && 'opacity-50 web:cursor-not-allowed',
|
|
17
|
-
className
|
|
18
|
-
)}
|
|
19
|
-
placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
|
|
20
|
-
{...props}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { Input };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as LabelPrimitive from '@rn-primitives/label';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { cn } from '../../lib/utils';
|
|
4
|
-
|
|
5
|
-
function Label({
|
|
6
|
-
className,
|
|
7
|
-
onPress,
|
|
8
|
-
onLongPress,
|
|
9
|
-
onPressIn,
|
|
10
|
-
onPressOut,
|
|
11
|
-
...props
|
|
12
|
-
}: LabelPrimitive.TextProps & {
|
|
13
|
-
ref?: React.RefObject<LabelPrimitive.TextRef>;
|
|
14
|
-
}) {
|
|
15
|
-
return (
|
|
16
|
-
<LabelPrimitive.Root
|
|
17
|
-
className='web:cursor-default'
|
|
18
|
-
onPress={onPress}
|
|
19
|
-
onLongPress={onLongPress}
|
|
20
|
-
onPressIn={onPressIn}
|
|
21
|
-
onPressOut={onPressOut}
|
|
22
|
-
>
|
|
23
|
-
<LabelPrimitive.Text
|
|
24
|
-
className={cn(
|
|
25
|
-
'text-sm text-foreground native:text-base font-medium leading-none web:peer-disabled:cursor-not-allowed web:peer-disabled:opacity-70',
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
{...props}
|
|
29
|
-
/>
|
|
30
|
-
</LabelPrimitive.Root>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { Label };
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import * as MenubarPrimitive from '@rn-primitives/menubar';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { Platform, Text, type TextProps, View } from 'react-native';
|
|
4
|
-
import { Check } from '../../lib/icons/Check';
|
|
5
|
-
import { ChevronDown } from '../../lib/icons/ChevronDown';
|
|
6
|
-
import { ChevronRight } from '../../lib/icons/ChevronRight';
|
|
7
|
-
import { ChevronUp } from '../../lib/icons/ChevronUp';
|
|
8
|
-
import { cn } from '../../lib/utils';
|
|
9
|
-
import { TextClassContext } from './text';
|
|
10
|
-
|
|
11
|
-
const MenubarMenu = MenubarPrimitive.Menu;
|
|
12
|
-
|
|
13
|
-
const MenubarGroup = MenubarPrimitive.Group;
|
|
14
|
-
|
|
15
|
-
const MenubarPortal = MenubarPrimitive.Portal;
|
|
16
|
-
|
|
17
|
-
const MenubarSub = MenubarPrimitive.Sub;
|
|
18
|
-
|
|
19
|
-
const MenubarRadioGroup = MenubarPrimitive.RadioGroup;
|
|
20
|
-
|
|
21
|
-
function Menubar({
|
|
22
|
-
className,
|
|
23
|
-
...props
|
|
24
|
-
}: MenubarPrimitive.RootProps & {
|
|
25
|
-
ref?: React.RefObject<MenubarPrimitive.RootRef>;
|
|
26
|
-
}) {
|
|
27
|
-
return (
|
|
28
|
-
<MenubarPrimitive.Root
|
|
29
|
-
className={cn(
|
|
30
|
-
'flex flex-row h-10 native:h-12 items-center space-x-1 rounded-md border border-border bg-background p-1',
|
|
31
|
-
className
|
|
32
|
-
)}
|
|
33
|
-
{...props}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function MenubarTrigger({
|
|
39
|
-
className,
|
|
40
|
-
...props
|
|
41
|
-
}: MenubarPrimitive.TriggerProps & {
|
|
42
|
-
ref?: React.RefObject<MenubarPrimitive.TriggerRef>;
|
|
43
|
-
}) {
|
|
44
|
-
const { value } = MenubarPrimitive.useRootContext();
|
|
45
|
-
const { value: itemValue } = MenubarPrimitive.useMenuContext();
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<MenubarPrimitive.Trigger
|
|
49
|
-
className={cn(
|
|
50
|
-
'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',
|
|
51
|
-
value === itemValue && 'bg-accent text-accent-foreground',
|
|
52
|
-
className
|
|
53
|
-
)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function MenubarSubTrigger({
|
|
60
|
-
className,
|
|
61
|
-
inset,
|
|
62
|
-
children,
|
|
63
|
-
...props
|
|
64
|
-
}: MenubarPrimitive.SubTriggerProps & {
|
|
65
|
-
ref?: React.RefObject<MenubarPrimitive.SubTriggerRef>;
|
|
66
|
-
className?: string;
|
|
67
|
-
inset?: boolean;
|
|
68
|
-
children?: React.ReactNode;
|
|
69
|
-
}) {
|
|
70
|
-
const { open } = MenubarPrimitive.useSubContext();
|
|
71
|
-
const Icon = Platform.OS === 'web' ? ChevronRight : open ? ChevronUp : ChevronDown;
|
|
72
|
-
return (
|
|
73
|
-
<TextClassContext.Provider
|
|
74
|
-
value={cn(
|
|
75
|
-
'select-none text-sm native:text-lg text-primary',
|
|
76
|
-
open && 'native:text-accent-foreground'
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
<MenubarPrimitive.SubTrigger
|
|
80
|
-
className={cn(
|
|
81
|
-
'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',
|
|
82
|
-
open && 'bg-accent',
|
|
83
|
-
inset && 'pl-8',
|
|
84
|
-
className
|
|
85
|
-
)}
|
|
86
|
-
{...props}
|
|
87
|
-
>
|
|
88
|
-
{children}
|
|
89
|
-
<Icon size={18} className='ml-auto text-foreground' />
|
|
90
|
-
</MenubarPrimitive.SubTrigger>
|
|
91
|
-
</TextClassContext.Provider>
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function MenubarSubContent({
|
|
96
|
-
className,
|
|
97
|
-
...props
|
|
98
|
-
}: MenubarPrimitive.SubContentProps & {
|
|
99
|
-
ref?: React.RefObject<MenubarPrimitive.SubContentRef>;
|
|
100
|
-
}) {
|
|
101
|
-
const { open } = MenubarPrimitive.useSubContext();
|
|
102
|
-
return (
|
|
103
|
-
<MenubarPrimitive.SubContent
|
|
104
|
-
className={cn(
|
|
105
|
-
'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',
|
|
106
|
-
open
|
|
107
|
-
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
108
|
-
: 'web:animate-out web:fade-out-0 web:zoom-out ',
|
|
109
|
-
className
|
|
110
|
-
)}
|
|
111
|
-
{...props}
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function MenubarContent({
|
|
117
|
-
className,
|
|
118
|
-
portalHost,
|
|
119
|
-
...props
|
|
120
|
-
}: MenubarPrimitive.ContentProps & {
|
|
121
|
-
ref?: React.RefObject<MenubarPrimitive.ContentRef>;
|
|
122
|
-
className?: string;
|
|
123
|
-
portalHost?: string;
|
|
124
|
-
}) {
|
|
125
|
-
const { value } = MenubarPrimitive.useRootContext();
|
|
126
|
-
const { value: itemValue } = MenubarPrimitive.useMenuContext();
|
|
127
|
-
return (
|
|
128
|
-
<MenubarPrimitive.Portal hostName={portalHost}>
|
|
129
|
-
<MenubarPrimitive.Content
|
|
130
|
-
className={cn(
|
|
131
|
-
'z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-1 shadow-md shadow-foreground/5',
|
|
132
|
-
value === itemValue
|
|
133
|
-
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
134
|
-
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
135
|
-
className
|
|
136
|
-
)}
|
|
137
|
-
{...props}
|
|
138
|
-
/>
|
|
139
|
-
</MenubarPrimitive.Portal>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function MenubarItem({
|
|
144
|
-
className,
|
|
145
|
-
inset,
|
|
146
|
-
...props
|
|
147
|
-
}: MenubarPrimitive.ItemProps & {
|
|
148
|
-
ref?: React.RefObject<MenubarPrimitive.ItemRef>;
|
|
149
|
-
className?: string;
|
|
150
|
-
inset?: boolean;
|
|
151
|
-
}) {
|
|
152
|
-
return (
|
|
153
|
-
<TextClassContext.Provider value='select-none text-sm native:text-lg text-popover-foreground web:group-focus:text-accent-foreground'>
|
|
154
|
-
<MenubarPrimitive.Item
|
|
155
|
-
className={cn(
|
|
156
|
-
'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',
|
|
157
|
-
inset && 'pl-8',
|
|
158
|
-
props.disabled && 'opacity-50 web:pointer-events-none',
|
|
159
|
-
className
|
|
160
|
-
)}
|
|
161
|
-
{...props}
|
|
162
|
-
/>
|
|
163
|
-
</TextClassContext.Provider>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function MenubarCheckboxItem({
|
|
168
|
-
className,
|
|
169
|
-
children,
|
|
170
|
-
checked,
|
|
171
|
-
...props
|
|
172
|
-
}: MenubarPrimitive.CheckboxItemProps & {
|
|
173
|
-
ref?: React.RefObject<MenubarPrimitive.CheckboxItemRef>;
|
|
174
|
-
children?: React.ReactNode;
|
|
175
|
-
}) {
|
|
176
|
-
return (
|
|
177
|
-
<MenubarPrimitive.CheckboxItem
|
|
178
|
-
className={cn(
|
|
179
|
-
'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',
|
|
180
|
-
props.disabled && 'web:pointer-events-none opacity-50',
|
|
181
|
-
className
|
|
182
|
-
)}
|
|
183
|
-
checked={checked}
|
|
184
|
-
{...props}
|
|
185
|
-
>
|
|
186
|
-
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
187
|
-
<MenubarPrimitive.ItemIndicator>
|
|
188
|
-
<Check size={14} strokeWidth={3} className='text-foreground' />
|
|
189
|
-
</MenubarPrimitive.ItemIndicator>
|
|
190
|
-
</View>
|
|
191
|
-
{children}
|
|
192
|
-
</MenubarPrimitive.CheckboxItem>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function MenubarRadioItem({
|
|
197
|
-
className,
|
|
198
|
-
children,
|
|
199
|
-
...props
|
|
200
|
-
}: MenubarPrimitive.RadioItemProps & {
|
|
201
|
-
ref?: React.RefObject<MenubarPrimitive.RadioItemRef>;
|
|
202
|
-
children?: React.ReactNode;
|
|
203
|
-
}) {
|
|
204
|
-
return (
|
|
205
|
-
<MenubarPrimitive.RadioItem
|
|
206
|
-
className={cn(
|
|
207
|
-
'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',
|
|
208
|
-
props.disabled && 'web:pointer-events-none opacity-50',
|
|
209
|
-
className
|
|
210
|
-
)}
|
|
211
|
-
{...props}
|
|
212
|
-
>
|
|
213
|
-
<View className='absolute left-2 flex h-3.5 w-3.5 items-center justify-center'>
|
|
214
|
-
<MenubarPrimitive.ItemIndicator>
|
|
215
|
-
<View className='bg-foreground h-2 w-2 rounded-full' />
|
|
216
|
-
</MenubarPrimitive.ItemIndicator>
|
|
217
|
-
</View>
|
|
218
|
-
{children}
|
|
219
|
-
</MenubarPrimitive.RadioItem>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
function MenubarLabel({
|
|
224
|
-
className,
|
|
225
|
-
inset,
|
|
226
|
-
...props
|
|
227
|
-
}: MenubarPrimitive.LabelProps & {
|
|
228
|
-
ref?: React.RefObject<MenubarPrimitive.LabelRef>;
|
|
229
|
-
className?: string;
|
|
230
|
-
inset?: boolean;
|
|
231
|
-
}) {
|
|
232
|
-
return (
|
|
233
|
-
<MenubarPrimitive.Label
|
|
234
|
-
className={cn(
|
|
235
|
-
'px-2 py-1.5 text-sm native:text-base font-semibold text-foreground web:cursor-default',
|
|
236
|
-
inset && 'pl-8',
|
|
237
|
-
className
|
|
238
|
-
)}
|
|
239
|
-
{...props}
|
|
240
|
-
/>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function MenubarSeparator({
|
|
245
|
-
className,
|
|
246
|
-
...props
|
|
247
|
-
}: MenubarPrimitive.SeparatorProps & {
|
|
248
|
-
ref?: React.RefObject<MenubarPrimitive.SeparatorRef>;
|
|
249
|
-
}) {
|
|
250
|
-
return (
|
|
251
|
-
<MenubarPrimitive.Separator className={cn('-mx-1 my-1 h-px bg-border', className)} {...props} />
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function MenubarShortcut({ className, ...props }: TextProps) {
|
|
256
|
-
return (
|
|
257
|
-
<Text
|
|
258
|
-
className={cn(
|
|
259
|
-
'ml-auto text-xs native:text-sm tracking-widest text-muted-foreground',
|
|
260
|
-
className
|
|
261
|
-
)}
|
|
262
|
-
{...props}
|
|
263
|
-
/>
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export {
|
|
268
|
-
Menubar,
|
|
269
|
-
MenubarCheckboxItem,
|
|
270
|
-
MenubarContent,
|
|
271
|
-
MenubarGroup,
|
|
272
|
-
MenubarItem,
|
|
273
|
-
MenubarLabel,
|
|
274
|
-
MenubarMenu,
|
|
275
|
-
MenubarPortal,
|
|
276
|
-
MenubarRadioGroup,
|
|
277
|
-
MenubarRadioItem,
|
|
278
|
-
MenubarSeparator,
|
|
279
|
-
MenubarShortcut,
|
|
280
|
-
MenubarSub,
|
|
281
|
-
MenubarSubContent,
|
|
282
|
-
MenubarSubTrigger,
|
|
283
|
-
MenubarTrigger,
|
|
284
|
-
};
|