@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,99 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TablePrimitive from '@rnr/table';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
|
|
6
|
+
const Table = React.forwardRef<
|
|
7
|
+
React.ElementRef<typeof TablePrimitive.Root>,
|
|
8
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Root>
|
|
9
|
+
>(({ className, ...props }, ref) => (
|
|
10
|
+
<TablePrimitive.Root
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn('w-full caption-bottom text-sm', className)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
));
|
|
16
|
+
Table.displayName = 'Table';
|
|
17
|
+
|
|
18
|
+
const TableHeader = React.forwardRef<
|
|
19
|
+
React.ElementRef<typeof TablePrimitive.Header>,
|
|
20
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Header>
|
|
21
|
+
>(({ className, ...props }, ref) => (
|
|
22
|
+
<TablePrimitive.Header
|
|
23
|
+
ref={ref}
|
|
24
|
+
className={cn('border-border [&_tr]:border-b', className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
));
|
|
28
|
+
TableHeader.displayName = 'TableHeader';
|
|
29
|
+
|
|
30
|
+
const TableBody = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof TablePrimitive.Body>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Body>
|
|
33
|
+
>(({ className, style, ...props }, ref) => (
|
|
34
|
+
<TablePrimitive.Body
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn('flex-1 border-border [&_tr:last-child]:border-0', className)}
|
|
37
|
+
style={[{ minHeight: 2 }, style]}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
));
|
|
41
|
+
TableBody.displayName = 'TableBody';
|
|
42
|
+
|
|
43
|
+
const TableFooter = React.forwardRef<
|
|
44
|
+
React.ElementRef<typeof TablePrimitive.Footer>,
|
|
45
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Footer>
|
|
46
|
+
>(({ className, ...props }, ref) => (
|
|
47
|
+
<TablePrimitive.Footer
|
|
48
|
+
ref={ref}
|
|
49
|
+
className={cn('bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
));
|
|
53
|
+
TableFooter.displayName = 'TableFooter';
|
|
54
|
+
|
|
55
|
+
const TableRow = React.forwardRef<
|
|
56
|
+
React.ElementRef<typeof TablePrimitive.Row>,
|
|
57
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Row>
|
|
58
|
+
>(({ className, ...props }, ref) => (
|
|
59
|
+
<TablePrimitive.Row
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
'flex-row border-border border-b web:transition-colors web:hover:bg-muted/50 web:data-[state=selected]:bg-muted',
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
/>
|
|
67
|
+
));
|
|
68
|
+
TableRow.displayName = 'TableRow';
|
|
69
|
+
|
|
70
|
+
const TableHead = React.forwardRef<
|
|
71
|
+
React.ElementRef<typeof TablePrimitive.Head>,
|
|
72
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Head>
|
|
73
|
+
>(({ className, ...props }, ref) => (
|
|
74
|
+
<TextClassContext.Provider value='text-muted-foreground'>
|
|
75
|
+
<TablePrimitive.Head
|
|
76
|
+
ref={ref}
|
|
77
|
+
className={cn(
|
|
78
|
+
'h-12 px-4 text-left justify-center font-medium [&:has([role=checkbox])]:pr-0',
|
|
79
|
+
className
|
|
80
|
+
)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
</TextClassContext.Provider>
|
|
84
|
+
));
|
|
85
|
+
TableHead.displayName = 'TableHead';
|
|
86
|
+
|
|
87
|
+
const TableCell = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof TablePrimitive.Cell>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof TablePrimitive.Cell>
|
|
90
|
+
>(({ className, ...props }, ref) => (
|
|
91
|
+
<TablePrimitive.Cell
|
|
92
|
+
ref={ref}
|
|
93
|
+
className={cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
));
|
|
97
|
+
TableCell.displayName = 'TableCell';
|
|
98
|
+
|
|
99
|
+
export { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextClassContext } from './text';
|
|
3
|
+
import * as TabsPrimitive from '@rnr/tabs';
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
const Tabs = TabsPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const TabsList = React.forwardRef<
|
|
9
|
+
React.ElementRef<typeof TabsPrimitive.List>,
|
|
10
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
11
|
+
>(({ className, ...props }, ref) => (
|
|
12
|
+
<TabsPrimitive.List
|
|
13
|
+
ref={ref}
|
|
14
|
+
className={cn(
|
|
15
|
+
'web:inline-flex h-10 native:h-12 items-center justify-center rounded-md bg-muted p-1 native:px-1.5',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
22
|
+
|
|
23
|
+
const TabsTrigger = React.forwardRef<
|
|
24
|
+
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
25
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
26
|
+
>(({ className, ...props }, ref) => {
|
|
27
|
+
const { value } = TabsPrimitive.useRootContext();
|
|
28
|
+
return (
|
|
29
|
+
<TextClassContext.Provider
|
|
30
|
+
value={cn(
|
|
31
|
+
'text-sm native:text-base font-medium text-muted-foreground web:transition-all',
|
|
32
|
+
value === props.value && 'text-foreground'
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
<TabsPrimitive.Trigger
|
|
36
|
+
ref={ref}
|
|
37
|
+
className={cn(
|
|
38
|
+
'inline-flex items-center justify-center web:whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium web:ring-offset-background web:transition-all web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
39
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
40
|
+
props.value === value && 'bg-background shadow-lg shadow-foreground/10',
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
</TextClassContext.Provider>
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
49
|
+
|
|
50
|
+
const TabsContent = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
53
|
+
>(({ className, ...props }, ref) => (
|
|
54
|
+
<TabsPrimitive.Content
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(
|
|
57
|
+
'web:ring-offset-background web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
58
|
+
className
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
));
|
|
63
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
64
|
+
|
|
65
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as Slot from '@rnr/slot';
|
|
2
|
+
import { SlottableTextProps, TextRef } from '@rnr/types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Text as RNText } from 'react-native';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const TextClassContext = React.createContext<string | undefined>(undefined);
|
|
8
|
+
|
|
9
|
+
const Text = React.forwardRef<TextRef, SlottableTextProps>(
|
|
10
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
11
|
+
const textClass = React.useContext(TextClassContext);
|
|
12
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
13
|
+
return (
|
|
14
|
+
<Component
|
|
15
|
+
className={cn('text-base text-foreground web:select-text', textClass, className)}
|
|
16
|
+
ref={ref}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
Text.displayName = 'Text';
|
|
23
|
+
|
|
24
|
+
export { Text, TextClassContext };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { TextInput } from 'react-native';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Textarea = React.forwardRef<
|
|
6
|
+
React.ElementRef<typeof TextInput>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof TextInput>
|
|
8
|
+
>(({ className, multiline = true, numberOfLines = 4, placeholderClassName, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<TextInput
|
|
11
|
+
ref={ref}
|
|
12
|
+
className={cn(
|
|
13
|
+
'web:flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base lg:text-sm native:text-lg native:leading-[1.25] text-foreground web:ring-offset-background placeholder:text-muted-foreground web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
14
|
+
props.editable === false && 'opacity-50 web:cursor-not-allowed',
|
|
15
|
+
className
|
|
16
|
+
)}
|
|
17
|
+
placeholderClassName={cn('text-muted-foreground', placeholderClassName)}
|
|
18
|
+
multiline={multiline}
|
|
19
|
+
numberOfLines={numberOfLines}
|
|
20
|
+
textAlignVertical='top'
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
Textarea.displayName = 'Textarea';
|
|
27
|
+
|
|
28
|
+
export { Textarea };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { LucideIcon } from 'lucide-react-native';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { toggleTextVariants, toggleVariants } from '../../components/ui/toggle';
|
|
5
|
+
import { TextClassContext } from './text';
|
|
6
|
+
import * as ToggleGroupPrimitive from '@rnr/toggle-group';
|
|
7
|
+
import { cn } from '../../lib/utils';
|
|
8
|
+
|
|
9
|
+
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants> | null>(null);
|
|
10
|
+
|
|
11
|
+
const ToggleGroup = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof toggleVariants>
|
|
15
|
+
>(({ className, variant, size, children, ...props }, ref) => (
|
|
16
|
+
<ToggleGroupPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn('flex flex-row items-center justify-center gap-1', className)}
|
|
19
|
+
{...props}
|
|
20
|
+
>
|
|
21
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
|
|
22
|
+
</ToggleGroupPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
|
|
26
|
+
|
|
27
|
+
function useToggleGroupContext() {
|
|
28
|
+
const context = React.useContext(ToggleGroupContext);
|
|
29
|
+
if (context === null) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'ToggleGroup compound components cannot be rendered outside the ToggleGroup component'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ToggleGroupItem = React.forwardRef<
|
|
38
|
+
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
|
|
39
|
+
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
|
|
40
|
+
VariantProps<typeof toggleVariants>
|
|
41
|
+
>(({ className, children, variant, size, ...props }, ref) => {
|
|
42
|
+
const context = useToggleGroupContext();
|
|
43
|
+
const { value } = ToggleGroupPrimitive.useRootContext();
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<TextClassContext.Provider
|
|
47
|
+
value={cn(
|
|
48
|
+
toggleTextVariants({ variant, size }),
|
|
49
|
+
ToggleGroupPrimitive.utils.getIsSelected(value, props.value)
|
|
50
|
+
? 'text-accent-foreground'
|
|
51
|
+
: 'web:group-hover:text-muted-foreground'
|
|
52
|
+
)}
|
|
53
|
+
>
|
|
54
|
+
<ToggleGroupPrimitive.Item
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(
|
|
57
|
+
toggleVariants({
|
|
58
|
+
variant: context.variant || variant,
|
|
59
|
+
size: context.size || size,
|
|
60
|
+
}),
|
|
61
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
62
|
+
ToggleGroupPrimitive.utils.getIsSelected(value, props.value) && 'bg-accent',
|
|
63
|
+
className
|
|
64
|
+
)}
|
|
65
|
+
{...props}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</ToggleGroupPrimitive.Item>
|
|
69
|
+
</TextClassContext.Provider>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
74
|
+
|
|
75
|
+
function ToggleGroupIcon({
|
|
76
|
+
className,
|
|
77
|
+
icon: Icon,
|
|
78
|
+
...props
|
|
79
|
+
}: React.ComponentPropsWithoutRef<LucideIcon> & {
|
|
80
|
+
icon: LucideIcon;
|
|
81
|
+
}) {
|
|
82
|
+
const textClass = React.useContext(TextClassContext);
|
|
83
|
+
return <Icon className={cn(textClass, className)} {...props} />;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { ToggleGroup, ToggleGroupIcon, ToggleGroupItem };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import type { LucideIcon } from 'lucide-react-native';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
import * as TogglePrimitive from '@rnr/toggle';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const toggleVariants = cva(
|
|
9
|
+
'web:group web:inline-flex items-center justify-center rounded-md web:ring-offset-background web:transition-colors web:hover:bg-muted active:bg-muted web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: 'bg-transparent',
|
|
14
|
+
outline:
|
|
15
|
+
'border border-input bg-transparent web:hover:bg-accent active:bg-accent active:bg-accent',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: 'h-10 px-3 native:h-12 native:px-[12]',
|
|
19
|
+
sm: 'h-9 px-2.5 native:h-10 native:px-[9]',
|
|
20
|
+
lg: 'h-11 px-5 native:h-14 native:px-6',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: 'default',
|
|
25
|
+
size: 'default',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const toggleTextVariants = cva('text-sm native:text-base text-foreground font-medium', {
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
default: '',
|
|
34
|
+
outline: 'web:group-hover:text-accent-foreground web:group-active:text-accent-foreground',
|
|
35
|
+
},
|
|
36
|
+
size: {
|
|
37
|
+
default: '',
|
|
38
|
+
sm: '',
|
|
39
|
+
lg: '',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
variant: 'default',
|
|
44
|
+
size: 'default',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const Toggle = React.forwardRef<
|
|
49
|
+
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
50
|
+
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>
|
|
51
|
+
>(({ className, variant, size, ...props }, ref) => (
|
|
52
|
+
<TextClassContext.Provider
|
|
53
|
+
value={cn(
|
|
54
|
+
toggleTextVariants({ variant, size }),
|
|
55
|
+
props.pressed ? 'text-accent-foreground' : 'web:group-hover:text-muted-foreground',
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
<TogglePrimitive.Root
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={cn(
|
|
62
|
+
toggleVariants({ variant, size }),
|
|
63
|
+
props.disabled && 'web:pointer-events-none opacity-50',
|
|
64
|
+
props.pressed && 'bg-accent',
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
</TextClassContext.Provider>
|
|
70
|
+
));
|
|
71
|
+
|
|
72
|
+
Toggle.displayName = TogglePrimitive.Root.displayName;
|
|
73
|
+
|
|
74
|
+
function ToggleIcon({
|
|
75
|
+
className,
|
|
76
|
+
icon: Icon,
|
|
77
|
+
...props
|
|
78
|
+
}: React.ComponentPropsWithoutRef<LucideIcon> & {
|
|
79
|
+
icon: LucideIcon;
|
|
80
|
+
}) {
|
|
81
|
+
const textClass = React.useContext(TextClassContext);
|
|
82
|
+
return <Icon className={cn(textClass, className)} {...props} />;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { Toggle, ToggleIcon, toggleTextVariants, toggleVariants };
|
|
@@ -0,0 +1,36 @@
|
|
|
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 TooltipPrimitive from '@rnr/tooltip';
|
|
6
|
+
import { cn } from '../../lib/utils';
|
|
7
|
+
|
|
8
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
9
|
+
|
|
10
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
11
|
+
|
|
12
|
+
const TooltipContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof TooltipPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
|
|
15
|
+
>(({ className, sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<TooltipPrimitive.Portal>
|
|
17
|
+
<TooltipPrimitive.Overlay style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}>
|
|
18
|
+
<Animated.View entering={FadeIn} exiting={FadeOut}>
|
|
19
|
+
<TextClassContext.Provider value='text-sm native:text-base text-popover-foreground'>
|
|
20
|
+
<TooltipPrimitive.Content
|
|
21
|
+
ref={ref}
|
|
22
|
+
sideOffset={sideOffset}
|
|
23
|
+
className={cn(
|
|
24
|
+
'z-50 overflow-hidden rounded-md border border-border bg-popover px-3 py-1.5 shadow-md shadow-foreground/5 web:animate-in web:fade-in-0 web:zoom-in-95 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',
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
</TextClassContext.Provider>
|
|
30
|
+
</Animated.View>
|
|
31
|
+
</TooltipPrimitive.Overlay>
|
|
32
|
+
</TooltipPrimitive.Portal>
|
|
33
|
+
));
|
|
34
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
35
|
+
|
|
36
|
+
export { Tooltip, TooltipContent, TooltipTrigger };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import * as Slot from '@rnr/slot';
|
|
2
|
+
import { SlottableTextProps, TextRef } from '@rnr/types';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Platform, Text as RNText } from 'react-native';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const H1 = React.forwardRef<TextRef, SlottableTextProps>(
|
|
8
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
9
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
10
|
+
return (
|
|
11
|
+
<Component
|
|
12
|
+
role='heading'
|
|
13
|
+
aria-level='1'
|
|
14
|
+
className={cn(
|
|
15
|
+
'web:scroll-m-20 text-4xl text-foreground font-extrabold tracking-tight lg:text-5xl web:select-text',
|
|
16
|
+
className
|
|
17
|
+
)}
|
|
18
|
+
ref={ref}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
H1.displayName = 'H1';
|
|
26
|
+
|
|
27
|
+
const H2 = React.forwardRef<TextRef, SlottableTextProps>(
|
|
28
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
29
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
30
|
+
return (
|
|
31
|
+
<Component
|
|
32
|
+
role='heading'
|
|
33
|
+
aria-level='2'
|
|
34
|
+
className={cn(
|
|
35
|
+
'web:scroll-m-20 border-b border-border pb-2 text-3xl text-foreground font-semibold tracking-tight first:mt-0 web:select-text',
|
|
36
|
+
className
|
|
37
|
+
)}
|
|
38
|
+
ref={ref}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
H2.displayName = 'H2';
|
|
46
|
+
|
|
47
|
+
const H3 = React.forwardRef<TextRef, SlottableTextProps>(
|
|
48
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
49
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
50
|
+
return (
|
|
51
|
+
<Component
|
|
52
|
+
role='heading'
|
|
53
|
+
aria-level='3'
|
|
54
|
+
className={cn(
|
|
55
|
+
'web:scroll-m-20 text-2xl text-foreground font-semibold tracking-tight web:select-text',
|
|
56
|
+
className
|
|
57
|
+
)}
|
|
58
|
+
ref={ref}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
H3.displayName = 'H3';
|
|
66
|
+
|
|
67
|
+
const H4 = React.forwardRef<TextRef, SlottableTextProps>(
|
|
68
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
69
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
70
|
+
return (
|
|
71
|
+
<Component
|
|
72
|
+
role='heading'
|
|
73
|
+
aria-level='4'
|
|
74
|
+
className={cn(
|
|
75
|
+
'web:scroll-m-20 text-xl text-foreground font-semibold tracking-tight web:select-text',
|
|
76
|
+
className
|
|
77
|
+
)}
|
|
78
|
+
ref={ref}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
H4.displayName = 'H4';
|
|
86
|
+
|
|
87
|
+
const P = React.forwardRef<TextRef, SlottableTextProps>(
|
|
88
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
89
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
90
|
+
return (
|
|
91
|
+
<Component
|
|
92
|
+
className={cn('text-base text-foreground web:select-text', className)}
|
|
93
|
+
ref={ref}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
P.displayName = 'P';
|
|
100
|
+
|
|
101
|
+
const BlockQuote = React.forwardRef<TextRef, SlottableTextProps>(
|
|
102
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
103
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
104
|
+
return (
|
|
105
|
+
<Component
|
|
106
|
+
// @ts-ignore - role of blockquote renders blockquote element on the web
|
|
107
|
+
role={Platform.OS === 'web' ? 'blockquote' : undefined}
|
|
108
|
+
className={cn(
|
|
109
|
+
'mt-6 native:mt-4 border-l-2 border-border pl-6 native:pl-3 text-base text-foreground italic web:select-text',
|
|
110
|
+
className
|
|
111
|
+
)}
|
|
112
|
+
ref={ref}
|
|
113
|
+
{...props}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
BlockQuote.displayName = 'BlockQuote';
|
|
120
|
+
|
|
121
|
+
const Code = React.forwardRef<TextRef, SlottableTextProps>(
|
|
122
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
123
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
124
|
+
return (
|
|
125
|
+
<Component
|
|
126
|
+
// @ts-ignore - role of code renders code element on the web
|
|
127
|
+
role={Platform.OS === 'web' ? 'code' : undefined}
|
|
128
|
+
className={cn(
|
|
129
|
+
'relative rounded-md bg-muted px-[0.3rem] py-[0.2rem] text-sm text-foreground font-semibold web:select-text',
|
|
130
|
+
className
|
|
131
|
+
)}
|
|
132
|
+
ref={ref}
|
|
133
|
+
{...props}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
Code.displayName = 'Code';
|
|
140
|
+
|
|
141
|
+
const Lead = React.forwardRef<TextRef, SlottableTextProps>(
|
|
142
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
143
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
144
|
+
return (
|
|
145
|
+
<Component
|
|
146
|
+
className={cn('text-xl text-muted-foreground web:select-text', className)}
|
|
147
|
+
ref={ref}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
Lead.displayName = 'Lead';
|
|
155
|
+
|
|
156
|
+
const Large = React.forwardRef<TextRef, SlottableTextProps>(
|
|
157
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
158
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
159
|
+
return (
|
|
160
|
+
<Component
|
|
161
|
+
className={cn('text-xl text-foreground font-semibold web:select-text', className)}
|
|
162
|
+
ref={ref}
|
|
163
|
+
{...props}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
Large.displayName = 'Large';
|
|
170
|
+
|
|
171
|
+
const Small = React.forwardRef<TextRef, SlottableTextProps>(
|
|
172
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
173
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
174
|
+
return (
|
|
175
|
+
<Component
|
|
176
|
+
className={cn(
|
|
177
|
+
'text-sm text-foreground font-medium leading-none web:select-text',
|
|
178
|
+
className
|
|
179
|
+
)}
|
|
180
|
+
ref={ref}
|
|
181
|
+
{...props}
|
|
182
|
+
/>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
Small.displayName = 'Small';
|
|
188
|
+
|
|
189
|
+
const Muted = React.forwardRef<TextRef, SlottableTextProps>(
|
|
190
|
+
({ className, asChild = false, ...props }, ref) => {
|
|
191
|
+
const Component = asChild ? Slot.Text : RNText;
|
|
192
|
+
return (
|
|
193
|
+
<Component
|
|
194
|
+
className={cn('text-sm text-muted-foreground web:select-text', className)}
|
|
195
|
+
ref={ref}
|
|
196
|
+
{...props}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
Muted.displayName = 'Muted';
|
|
203
|
+
|
|
204
|
+
export { BlockQuote, Code, H1, H2, H3, H4, Large, Lead, Muted, P, Small };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-reusables/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Add Universal components and primitives to your React-Native project.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -100,18 +100,18 @@
|
|
|
100
100
|
},
|
|
101
101
|
"scripts": {
|
|
102
102
|
"gen": "tsx src/scripts/write-components.ts",
|
|
103
|
-
"dev": "
|
|
104
|
-
"build": "
|
|
103
|
+
"dev": "tsup --watch",
|
|
104
|
+
"build": "tsup",
|
|
105
105
|
"typecheck": "tsc --noEmit",
|
|
106
106
|
"clean": "rimraf dist && rimraf components",
|
|
107
|
-
"start:dev": "
|
|
108
|
-
"start": "
|
|
107
|
+
"start:dev": "node dist/index.js",
|
|
108
|
+
"start": "node dist/index.js",
|
|
109
109
|
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
|
|
110
110
|
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache",
|
|
111
111
|
"release": "changeset version",
|
|
112
|
-
"pub:beta": "pnpm
|
|
113
|
-
"pub:next": "pnpm
|
|
114
|
-
"pub:release": "pnpm
|
|
112
|
+
"pub:beta": "pnpm publish --no-git-checks --access public --tag beta",
|
|
113
|
+
"pub:next": "pnpm publish --no-git-checks --access public --tag next",
|
|
114
|
+
"pub:release": "pnpm publish --access public",
|
|
115
115
|
"test": "vitest run"
|
|
116
116
|
}
|
|
117
117
|
}
|