@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.
Files changed (74) hide show
  1. package/LICENSE +1 -1
  2. package/bin.cjs +60513 -0
  3. package/package.json +7 -80
  4. package/README.md +0 -63
  5. package/__generated/components/ui/accordion.tsx +0 -134
  6. package/__generated/components/ui/alert-dialog.tsx +0 -172
  7. package/__generated/components/ui/alert.tsx +0 -71
  8. package/__generated/components/ui/aspect-ratio.tsx +0 -5
  9. package/__generated/components/ui/avatar.tsx +0 -47
  10. package/__generated/components/ui/badge.tsx +0 -52
  11. package/__generated/components/ui/button.tsx +0 -81
  12. package/__generated/components/ui/card.tsx +0 -82
  13. package/__generated/components/ui/checkbox.tsx +0 -33
  14. package/__generated/components/ui/collapsible.tsx +0 -9
  15. package/__generated/components/ui/context-menu.tsx +0 -264
  16. package/__generated/components/ui/dialog.tsx +0 -159
  17. package/__generated/components/ui/dropdown-menu.tsx +0 -274
  18. package/__generated/components/ui/hover-card.tsx +0 -47
  19. package/__generated/components/ui/input.tsx +0 -25
  20. package/__generated/components/ui/label.tsx +0 -34
  21. package/__generated/components/ui/menubar.tsx +0 -284
  22. package/__generated/components/ui/navigation-menu.tsx +0 -191
  23. package/__generated/components/ui/popover.tsx +0 -42
  24. package/__generated/components/ui/progress.tsx +0 -62
  25. package/__generated/components/ui/radio-group.tsx +0 -36
  26. package/__generated/components/ui/select.tsx +0 -191
  27. package/__generated/components/ui/separator.tsx +0 -27
  28. package/__generated/components/ui/skeleton.tsx +0 -39
  29. package/__generated/components/ui/switch.tsx +0 -98
  30. package/__generated/components/ui/table.tsx +0 -108
  31. package/__generated/components/ui/tabs.tsx +0 -69
  32. package/__generated/components/ui/text.tsx +0 -26
  33. package/__generated/components/ui/textarea.tsx +0 -30
  34. package/__generated/components/ui/toggle-group.tsx +0 -94
  35. package/__generated/components/ui/toggle.tsx +0 -90
  36. package/__generated/components/ui/tooltip.tsx +0 -43
  37. package/__generated/components/ui/typography.tsx +0 -148
  38. package/__generated/starter-base/README.md +0 -16
  39. package/__generated/starter-base/app/+not-found.tsx +0 -18
  40. package/__generated/starter-base/app/_layout.tsx +0 -71
  41. package/__generated/starter-base/app/index.tsx +0 -95
  42. package/__generated/starter-base/app.json +0 -40
  43. package/__generated/starter-base/assets/images/adaptive-icon.png +0 -0
  44. package/__generated/starter-base/assets/images/favicon.png +0 -0
  45. package/__generated/starter-base/assets/images/icon.png +0 -0
  46. package/__generated/starter-base/assets/images/splash.png +0 -0
  47. package/__generated/starter-base/babel.config.js +0 -6
  48. package/__generated/starter-base/components/ThemeToggle.tsx +0 -30
  49. package/__generated/starter-base/components/ui/avatar.tsx +0 -47
  50. package/__generated/starter-base/components/ui/button.tsx +0 -81
  51. package/__generated/starter-base/components/ui/card.tsx +0 -82
  52. package/__generated/starter-base/components/ui/progress.tsx +0 -62
  53. package/__generated/starter-base/components/ui/text.tsx +0 -26
  54. package/__generated/starter-base/components/ui/tooltip.tsx +0 -44
  55. package/__generated/starter-base/gitignore-template +0 -41
  56. package/__generated/starter-base/global.css +0 -49
  57. package/__generated/starter-base/index.js +0 -12
  58. package/__generated/starter-base/lib/android-navigation-bar.ts +0 -11
  59. package/__generated/starter-base/lib/constants.ts +0 -18
  60. package/__generated/starter-base/lib/icons/Info.tsx +0 -4
  61. package/__generated/starter-base/lib/icons/MoonStar.tsx +0 -4
  62. package/__generated/starter-base/lib/icons/Sun.tsx +0 -4
  63. package/__generated/starter-base/lib/icons/iconWithClassName.ts +0 -14
  64. package/__generated/starter-base/lib/useColorScheme.tsx +0 -11
  65. package/__generated/starter-base/lib/utils.ts +0 -6
  66. package/__generated/starter-base/metro.config.js +0 -6
  67. package/__generated/starter-base/nativewind-env.d.ts +0 -1
  68. package/__generated/starter-base/npmrc-template +0 -2
  69. package/__generated/starter-base/package.json +0 -51
  70. package/__generated/starter-base/tailwind.config.js +0 -65
  71. package/__generated/starter-base/tsconfig.json +0 -19
  72. package/dist/index.d.ts +0 -1
  73. package/dist/index.js +0 -22
  74. package/dist/index.js.map +0 -1
package/package.json CHANGED
@@ -1,87 +1,14 @@
1
1
  {
2
2
  "name": "@react-native-reusables/cli",
3
- "version": "0.4.1",
4
- "description": "Add react-native-reusables to your project.",
5
- "publishConfig": {
6
- "access": "public"
7
- },
8
- "license": "MIT",
9
- "author": {
10
- "name": "mrzachnugent",
11
- "url": "https://twitter.com/mrzachnugent"
12
- },
3
+ "version": "0.5.0-beta.2",
4
+ "type": "module",
5
+ "description": "A CLI for React Native Reusables",
6
+ "main": "bin.cjs",
7
+ "bin": "bin.cjs",
13
8
  "repository": {
14
9
  "type": "git",
15
10
  "url": "https://github.com/mrzachnugent/react-native-reusables.git",
16
- "directory": "packages/cli"
17
- },
18
- "files": [
19
- "dist",
20
- "__generated"
21
- ],
22
- "keywords": [
23
- "expo",
24
- "react-native",
25
- "universal-components",
26
- "components",
27
- "tailwind",
28
- "nativewind",
29
- "radix-ui",
30
- "shadcn"
31
- ],
32
- "type": "module",
33
- "exports": "./dist/index.js",
34
- "bin": "./dist/index.js",
35
- "dependencies": {
36
- "@antfu/ni": "^24.3.0",
37
- "@babel/core": "^7.26.0",
38
- "@babel/parser": "^7.22.6",
39
- "@babel/plugin-transform-typescript": "^7.22.5",
40
- "chalk": "5.2.0",
41
- "commander": "^10.0.0",
42
- "cosmiconfig": "^8.1.3",
43
- "diff": "^5.1.0",
44
- "execa": "^7.0.0",
45
- "fast-glob": "^3.3.2",
46
- "fs-extra": "^11.1.0",
47
- "https-proxy-agent": "^6.2.0",
48
- "lodash.template": "^4.5.0",
49
- "node-fetch": "^3.3.0",
50
- "ora": "^6.1.2",
51
- "prompts": "^2.4.2",
52
- "recast": "^0.23.2",
53
- "ts-morph": "^18.0.0",
54
- "tsconfig-paths": "^4.2.0",
55
- "zod": "^3.20.2"
56
- },
57
- "devDependencies": {
58
- "@types/babel__core": "^7.20.1",
59
- "@types/diff": "^5.0.3",
60
- "@types/fs-extra": "^11.0.1",
61
- "@types/lodash.template": "^4.5.1",
62
- "@types/prompts": "^2.4.2",
63
- "rimraf": "^4.1.3",
64
- "tsup": "^6.6.3",
65
- "tsx": "^4.7.1",
66
- "type-fest": "^3.8.0",
67
- "typescript": "^5.8.3",
68
- "@rnr/starter-base": "1.0.0",
69
- "@rnr/reusables": "0.0.0"
11
+ "directory": "apps/cli"
70
12
  },
71
- "scripts": {
72
- "gen": "rm -rf __generated && tsx scripts/generate-source-files.ts",
73
- "dev": "pnpm gen && tsup --watch",
74
- "build": "pnpm gen && tsup",
75
- "typecheck": "tsc --noEmit",
76
- "clean": "rm -rf node_modules && rm -rf dist && rm -rf __generated",
77
- "start:dev": "node dist/index.js",
78
- "start": "node dist/index.js",
79
- "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
80
- "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
81
- "release": "changeset version",
82
- "pub:beta": "pnpm publish --no-git-checks --access public --tag beta",
83
- "pub:next": "pnpm publish --no-git-checks --access public --tag next",
84
- "pub:release": "pnpm publish --access public",
85
- "test": "vitest run"
86
- }
13
+ "license": "MIT"
87
14
  }
package/README.md DELETED
@@ -1,63 +0,0 @@
1
- # React Native Reusables CLI
2
-
3
- > Please follow [the initial setup steps](https://rnr-docs.vercel.app/getting-started/initial-setup/) before using
4
-
5
- A CLI to add [react-native-reusables](https://rnr-docs.vercel.app/getting-started/introduction/) components to your project. When components depend on other components, they will also be added to your project.
6
-
7
- ## How to use
8
-
9
- Use the following command _(with optional arugments and flags)_:
10
-
11
- ```bash
12
- npx @react-native-reusables/cli@latest add
13
- ```
14
-
15
- ### Arguments
16
-
17
- If you do not add arguments, you will be prompted to select the `ui` components you would like to add to your project.
18
-
19
- #### UI Components
20
-
21
- - `accordion`
22
- - `alert`
23
- - `alert-dialog`
24
- - `aspect-ratio`
25
- - `avatar`
26
- - `badge`
27
- - `button`
28
- - `card`
29
- - `checkbox`
30
- - `collapsible`
31
- - `context-menu`
32
- - `dialog`
33
- - `dropdown-menu`
34
- - `hover-card`
35
- - `input`
36
- - `label`
37
- - `menubar`
38
- - `navigation-menu`
39
- - `popover`
40
- - `radio-group`
41
- - `select`
42
- - `separator`
43
- - `skeleton`
44
- - `switch`
45
- - `table`
46
- - `tabs`
47
- - `text`
48
- - `textarea`
49
- - `toggle`
50
- - `toggle-group`
51
- - `tooltip`
52
- - `typography`
53
-
54
- ### Flags
55
-
56
- - `-o` or `--overwrite`: Overwrite existing files. Default to `false`
57
- - `-c <cmd>` or `--cwd <cwd>`: The working directory. Defaults to the current directory.
58
-
59
- ```mdx
60
- This project uses code from shadcn.
61
- The code is licensed under the MIT License.
62
- https://github.com/shadcn-ui/ui
63
- ```
@@ -1,134 +0,0 @@
1
- import * as AccordionPrimitive from '@rn-primitives/accordion';
2
- import * as React from 'react';
3
- import { Platform, Pressable, View } from 'react-native';
4
- import Animated, {
5
- Extrapolation,
6
- FadeIn,
7
- FadeOutUp,
8
- LayoutAnimationConfig,
9
- LinearTransition,
10
- interpolate,
11
- useAnimatedStyle,
12
- useDerivedValue,
13
- withTiming,
14
- } from 'react-native-reanimated';
15
- import { ChevronDown } from '../../lib/icons/ChevronDown';
16
- import { cn } from '../../lib/utils';
17
- import { TextClassContext } from './text';
18
-
19
- function Accordion({
20
- children,
21
- ...props
22
- }: Omit<AccordionPrimitive.RootProps, 'asChild'> & {
23
- ref?: React.RefObject<AccordionPrimitive.RootRef>;
24
- }) {
25
- return (
26
- <LayoutAnimationConfig skipEntering>
27
- <AccordionPrimitive.Root
28
- {...(props as AccordionPrimitive.RootProps)}
29
- asChild={Platform.OS !== 'web'}
30
- >
31
- <Animated.View layout={LinearTransition.duration(200)}>{children}</Animated.View>
32
- </AccordionPrimitive.Root>
33
- </LayoutAnimationConfig>
34
- );
35
- }
36
-
37
- function AccordionItem({
38
- className,
39
- value,
40
- ...props
41
- }: AccordionPrimitive.ItemProps & {
42
- ref?: React.RefObject<AccordionPrimitive.ItemRef>;
43
- }) {
44
- return (
45
- <Animated.View className={'overflow-hidden'} layout={LinearTransition.duration(200)}>
46
- <AccordionPrimitive.Item
47
- className={cn('border-b border-border', className)}
48
- value={value}
49
- {...props}
50
- />
51
- </Animated.View>
52
- );
53
- }
54
-
55
- const Trigger = Platform.OS === 'web' ? View : Pressable;
56
-
57
- function AccordionTrigger({
58
- className,
59
- children,
60
- ...props
61
- }: AccordionPrimitive.TriggerProps & {
62
- children?: React.ReactNode;
63
- ref?: React.RefObject<AccordionPrimitive.TriggerRef>;
64
- }) {
65
- const { isExpanded } = AccordionPrimitive.useItemContext();
66
-
67
- const progress = useDerivedValue(() =>
68
- isExpanded ? withTiming(1, { duration: 250 }) : withTiming(0, { duration: 200 })
69
- );
70
- const chevronStyle = useAnimatedStyle(() => ({
71
- transform: [{ rotate: `${progress.value * 180}deg` }],
72
- opacity: interpolate(progress.value, [0, 1], [1, 0.8], Extrapolation.CLAMP),
73
- }));
74
-
75
- return (
76
- <TextClassContext.Provider value='native:text-lg font-medium web:group-hover:underline'>
77
- <AccordionPrimitive.Header className='flex'>
78
- <AccordionPrimitive.Trigger {...props} asChild>
79
- <Trigger
80
- className={cn(
81
- 'flex flex-row web:flex-1 items-center justify-between py-4 web:transition-all group web:focus-visible:outline-none web:focus-visible:ring-1 web:focus-visible:ring-muted-foreground',
82
- className
83
- )}
84
- >
85
- {children}
86
- <Animated.View style={chevronStyle}>
87
- <ChevronDown size={18} className={'text-foreground shrink-0'} />
88
- </Animated.View>
89
- </Trigger>
90
- </AccordionPrimitive.Trigger>
91
- </AccordionPrimitive.Header>
92
- </TextClassContext.Provider>
93
- );
94
- }
95
-
96
- function AccordionContent({
97
- className,
98
- children,
99
- ...props
100
- }: AccordionPrimitive.ContentProps & {
101
- ref?: React.RefObject<AccordionPrimitive.ContentRef>;
102
- }) {
103
- const { isExpanded } = AccordionPrimitive.useItemContext();
104
- return (
105
- <TextClassContext.Provider value='native:text-lg'>
106
- <AccordionPrimitive.Content
107
- className={cn(
108
- 'overflow-hidden text-sm web:transition-all',
109
- isExpanded ? 'web:animate-accordion-down' : 'web:animate-accordion-up'
110
- )}
111
- {...props}
112
- >
113
- <InnerContent className={cn('pb-4', className)}>{children}</InnerContent>
114
- </AccordionPrimitive.Content>
115
- </TextClassContext.Provider>
116
- );
117
- }
118
-
119
- function InnerContent({ children, className }: { children: React.ReactNode; className?: string }) {
120
- if (Platform.OS === 'web') {
121
- return <View className={cn('pb-4', className)}>{children}</View>;
122
- }
123
- return (
124
- <Animated.View
125
- entering={FadeIn}
126
- exiting={FadeOutUp.duration(200)}
127
- className={cn('pb-4', className)}
128
- >
129
- {children}
130
- </Animated.View>
131
- );
132
- }
133
-
134
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
@@ -1,172 +0,0 @@
1
- import * as AlertDialogPrimitive from '@rn-primitives/alert-dialog';
2
- import * as React from 'react';
3
- import { Platform, View, type ViewProps } from 'react-native';
4
- import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
5
- import { buttonTextVariants, buttonVariants } from '../../components/ui/button';
6
- import { cn } from '../../lib/utils';
7
- import { TextClassContext } from './text';
8
-
9
- const AlertDialog = AlertDialogPrimitive.Root;
10
-
11
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
12
-
13
- const AlertDialogPortal = AlertDialogPrimitive.Portal;
14
-
15
- function AlertDialogOverlayWeb({
16
- className,
17
- ...props
18
- }: AlertDialogPrimitive.OverlayProps & {
19
- ref?: React.RefObject<AlertDialogPrimitive.OverlayRef>;
20
- }) {
21
- const { open } = AlertDialogPrimitive.useRootContext();
22
- return (
23
- <AlertDialogPrimitive.Overlay
24
- className={cn(
25
- 'z-50 bg-black/80 flex justify-center items-center p-2 absolute top-0 right-0 bottom-0 left-0',
26
- open ? 'web:animate-in web:fade-in-0' : 'web:animate-out web:fade-out-0',
27
- className
28
- )}
29
- {...props}
30
- />
31
- );
32
- }
33
-
34
- function AlertDialogOverlayNative({
35
- className,
36
- children,
37
- ...props
38
- }: AlertDialogPrimitive.OverlayProps & {
39
- ref?: React.RefObject<AlertDialogPrimitive.OverlayRef>;
40
- }) {
41
- return (
42
- <AlertDialogPrimitive.Overlay
43
- className={cn(
44
- 'z-50 absolute top-0 right-0 bottom-0 left-0 bg-black/80 flex justify-center items-center p-2',
45
- className
46
- )}
47
- {...props}
48
- asChild
49
- >
50
- <Animated.View entering={FadeIn.duration(150)} exiting={FadeOut.duration(150)}>
51
- {children}
52
- </Animated.View>
53
- </AlertDialogPrimitive.Overlay>
54
- );
55
- }
56
-
57
- const AlertDialogOverlay = Platform.select({
58
- web: AlertDialogOverlayWeb,
59
- default: AlertDialogOverlayNative,
60
- });
61
-
62
- function AlertDialogContent({
63
- className,
64
- portalHost,
65
- ...props
66
- }: AlertDialogPrimitive.ContentProps & {
67
- ref?: React.RefObject<AlertDialogPrimitive.ContentRef>;
68
- portalHost?: string;
69
- }) {
70
- const { open } = AlertDialogPrimitive.useRootContext();
71
-
72
- return (
73
- <AlertDialogPortal hostName={portalHost}>
74
- <AlertDialogOverlay>
75
- <AlertDialogPrimitive.Content
76
- className={cn(
77
- 'z-50 max-w-lg gap-4 border border-border bg-background p-6 shadow-lg shadow-foreground/10 web:duration-200 rounded-lg',
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-95',
81
- className
82
- )}
83
- {...props}
84
- />
85
- </AlertDialogOverlay>
86
- </AlertDialogPortal>
87
- );
88
- }
89
-
90
- function AlertDialogHeader({ className, ...props }: ViewProps) {
91
- return <View className={cn('flex flex-col gap-2', className)} {...props} />;
92
- }
93
-
94
- function AlertDialogFooter({ className, ...props }: ViewProps) {
95
- return (
96
- <View
97
- className={cn('flex flex-col-reverse sm:flex-row sm:justify-end gap-2', className)}
98
- {...props}
99
- />
100
- );
101
- }
102
-
103
- function AlertDialogTitle({
104
- className,
105
- ...props
106
- }: AlertDialogPrimitive.TitleProps & {
107
- ref?: React.RefObject<AlertDialogPrimitive.TitleRef>;
108
- }) {
109
- return (
110
- <AlertDialogPrimitive.Title
111
- className={cn('text-lg native:text-xl text-foreground font-semibold', className)}
112
- {...props}
113
- />
114
- );
115
- }
116
-
117
- function AlertDialogDescription({
118
- className,
119
- ...props
120
- }: AlertDialogPrimitive.DescriptionProps & {
121
- ref?: React.RefObject<AlertDialogPrimitive.DescriptionRef>;
122
- }) {
123
- return (
124
- <AlertDialogPrimitive.Description
125
- className={cn('text-sm native:text-base text-muted-foreground', className)}
126
- {...props}
127
- />
128
- );
129
- }
130
-
131
- function AlertDialogAction({
132
- className,
133
- ...props
134
- }: AlertDialogPrimitive.ActionProps & {
135
- ref?: React.RefObject<AlertDialogPrimitive.ActionRef>;
136
- }) {
137
- return (
138
- <TextClassContext.Provider value={buttonTextVariants({ className })}>
139
- <AlertDialogPrimitive.Action className={cn(buttonVariants(), className)} {...props} />
140
- </TextClassContext.Provider>
141
- );
142
- }
143
-
144
- function AlertDialogCancel({
145
- className,
146
- ...props
147
- }: AlertDialogPrimitive.CancelProps & {
148
- ref?: React.RefObject<AlertDialogPrimitive.CancelRef>;
149
- }) {
150
- return (
151
- <TextClassContext.Provider value={buttonTextVariants({ className, variant: 'outline' })}>
152
- <AlertDialogPrimitive.Cancel
153
- className={cn(buttonVariants({ variant: 'outline', className }))}
154
- {...props}
155
- />
156
- </TextClassContext.Provider>
157
- );
158
- }
159
-
160
- export {
161
- AlertDialog,
162
- AlertDialogAction,
163
- AlertDialogCancel,
164
- AlertDialogContent,
165
- AlertDialogDescription,
166
- AlertDialogFooter,
167
- AlertDialogHeader,
168
- AlertDialogOverlay,
169
- AlertDialogPortal,
170
- AlertDialogTitle,
171
- AlertDialogTrigger,
172
- };
@@ -1,71 +0,0 @@
1
- import { useTheme } from '@react-navigation/native';
2
- import { cva, type VariantProps } from 'class-variance-authority';
3
- import type { LucideIcon } from 'lucide-react-native';
4
- import * as React from 'react';
5
- import { View, type ViewProps } from 'react-native';
6
- import { cn } from '../../lib/utils';
7
- import { Text } from './text';
8
-
9
- const alertVariants = cva(
10
- 'relative bg-background w-full rounded-lg border border-border p-4 shadow shadow-foreground/10',
11
- {
12
- variants: {
13
- variant: {
14
- default: '',
15
- destructive: 'border-destructive',
16
- },
17
- },
18
- defaultVariants: {
19
- variant: 'default',
20
- },
21
- }
22
- );
23
-
24
- function Alert({
25
- className,
26
- variant,
27
- children,
28
- icon: Icon,
29
- iconSize = 16,
30
- iconClassName,
31
- ...props
32
- }: ViewProps &
33
- VariantProps<typeof alertVariants> & {
34
- ref?: React.RefObject<View>;
35
- icon: LucideIcon;
36
- iconSize?: number;
37
- iconClassName?: string;
38
- }) {
39
- const { colors } = useTheme();
40
- return (
41
- <View role='alert' className={alertVariants({ variant, className })} {...props}>
42
- <View className='absolute left-3.5 top-4 -translate-y-0.5'>
43
- <Icon
44
- size={iconSize}
45
- color={variant === 'destructive' ? colors.notification : colors.text}
46
- />
47
- </View>
48
- {children}
49
- </View>
50
- );
51
- }
52
-
53
- function AlertTitle({ className, ...props }: React.ComponentProps<typeof Text>) {
54
- return (
55
- <Text
56
- className={cn(
57
- 'pl-7 mb-1 font-medium text-base leading-none tracking-tight text-foreground',
58
- className
59
- )}
60
- {...props}
61
- />
62
- );
63
- }
64
-
65
- function AlertDescription({ className, ...props }: React.ComponentProps<typeof Text>) {
66
- return (
67
- <Text className={cn('pl-7 text-sm leading-relaxed text-foreground', className)} {...props} />
68
- );
69
- }
70
-
71
- export { Alert, AlertDescription, AlertTitle };
@@ -1,5 +0,0 @@
1
- import * as AspectRatioPrimitive from '@rn-primitives/aspect-ratio';
2
-
3
- const AspectRatio = AspectRatioPrimitive.Root;
4
-
5
- export { AspectRatio };
@@ -1,47 +0,0 @@
1
- import * as AvatarPrimitive from '@rn-primitives/avatar';
2
- import * as React from 'react';
3
- import { cn } from '../../lib/utils';
4
-
5
- function Avatar({
6
- className,
7
- ...props
8
- }: AvatarPrimitive.RootProps & {
9
- ref?: React.RefObject<AvatarPrimitive.RootRef>;
10
- }) {
11
- return (
12
- <AvatarPrimitive.Root
13
- className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
14
- {...props}
15
- />
16
- );
17
- }
18
-
19
- function AvatarImage({
20
- className,
21
- ...props
22
- }: AvatarPrimitive.ImageProps & {
23
- ref?: React.RefObject<AvatarPrimitive.ImageRef>;
24
- }) {
25
- return (
26
- <AvatarPrimitive.Image className={cn('aspect-square h-full w-full', className)} {...props} />
27
- );
28
- }
29
-
30
- function AvatarFallback({
31
- className,
32
- ...props
33
- }: AvatarPrimitive.FallbackProps & {
34
- ref?: React.RefObject<AvatarPrimitive.FallbackRef>;
35
- }) {
36
- return (
37
- <AvatarPrimitive.Fallback
38
- className={cn(
39
- 'flex h-full w-full items-center justify-center rounded-full bg-muted',
40
- className
41
- )}
42
- {...props}
43
- />
44
- );
45
- }
46
-
47
- export { Avatar, AvatarFallback, AvatarImage };
@@ -1,52 +0,0 @@
1
- import * as Slot from '@rn-primitives/slot';
2
- import { cva, type VariantProps } from 'class-variance-authority';
3
- import { View, ViewProps } from 'react-native';
4
- import { cn } from '../../lib/utils';
5
- import { TextClassContext } from './text';
6
-
7
- const badgeVariants = cva(
8
- 'web:inline-flex items-center rounded-full border border-border px-2.5 py-0.5 web:transition-colors web:focus:outline-none web:focus:ring-2 web:focus:ring-ring web:focus:ring-offset-2',
9
- {
10
- variants: {
11
- variant: {
12
- default: 'border-transparent bg-primary web:hover:opacity-80 active:opacity-80',
13
- secondary: 'border-transparent bg-secondary web:hover:opacity-80 active:opacity-80',
14
- destructive: 'border-transparent bg-destructive web:hover:opacity-80 active:opacity-80',
15
- outline: 'text-foreground',
16
- },
17
- },
18
- defaultVariants: {
19
- variant: 'default',
20
- },
21
- }
22
- );
23
-
24
- const badgeTextVariants = cva('text-xs font-semibold ', {
25
- variants: {
26
- variant: {
27
- default: 'text-primary-foreground',
28
- secondary: 'text-secondary-foreground',
29
- destructive: 'text-destructive-foreground',
30
- outline: 'text-foreground',
31
- },
32
- },
33
- defaultVariants: {
34
- variant: 'default',
35
- },
36
- });
37
-
38
- type BadgeProps = ViewProps & {
39
- asChild?: boolean;
40
- } & VariantProps<typeof badgeVariants>;
41
-
42
- function Badge({ className, variant, asChild, ...props }: BadgeProps) {
43
- const Component = asChild ? Slot.View : View;
44
- return (
45
- <TextClassContext.Provider value={badgeTextVariants({ variant })}>
46
- <Component className={cn(badgeVariants({ variant }), className)} {...props} />
47
- </TextClassContext.Provider>
48
- );
49
- }
50
-
51
- export { Badge, badgeTextVariants, badgeVariants };
52
- export type { BadgeProps };