@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,105 @@
|
|
|
1
|
+
import type { Pressable, Text, View, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
type ComponentPropsWithAsChild<T extends React.ElementType<any>> =
|
|
4
|
+
React.ComponentPropsWithoutRef<T> & { asChild?: boolean };
|
|
5
|
+
|
|
6
|
+
type ViewRef = React.ElementRef<typeof View>;
|
|
7
|
+
type PressableRef = React.ElementRef<typeof Pressable>;
|
|
8
|
+
type TextRef = React.ElementRef<typeof Text>;
|
|
9
|
+
|
|
10
|
+
type SlottableViewProps = ComponentPropsWithAsChild<typeof View>;
|
|
11
|
+
type SlottablePressableProps = ComponentPropsWithAsChild<typeof Pressable> & {
|
|
12
|
+
/**
|
|
13
|
+
* Platform: WEB ONLY
|
|
14
|
+
*/
|
|
15
|
+
onKeyDown?: (ev: React.KeyboardEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Platform: WEB ONLY
|
|
18
|
+
*/
|
|
19
|
+
onKeyUp?: (ev: React.KeyboardEvent) => void;
|
|
20
|
+
};
|
|
21
|
+
type SlottableTextProps = ComponentPropsWithAsChild<typeof Text>;
|
|
22
|
+
|
|
23
|
+
interface Insets {
|
|
24
|
+
top?: number;
|
|
25
|
+
bottom?: number;
|
|
26
|
+
left?: number;
|
|
27
|
+
right?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;
|
|
31
|
+
type FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Certain props are only available on the native version of the component.
|
|
35
|
+
* @docs For the web version, see the Radix documentation https://www.radix-ui.com/primitives
|
|
36
|
+
*/
|
|
37
|
+
interface PositionedContentProps {
|
|
38
|
+
forceMount?: true | undefined;
|
|
39
|
+
style?: ViewStyle;
|
|
40
|
+
alignOffset?: number;
|
|
41
|
+
insets?: Insets;
|
|
42
|
+
avoidCollisions?: boolean;
|
|
43
|
+
align?: 'start' | 'center' | 'end';
|
|
44
|
+
side?: 'top' | 'bottom';
|
|
45
|
+
sideOffset?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Platform: NATIVE ONLY
|
|
48
|
+
*/
|
|
49
|
+
disablePositioningStyle?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Platform: WEB ONLY
|
|
52
|
+
*/
|
|
53
|
+
loop?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Platform: WEB ONLY
|
|
56
|
+
*/
|
|
57
|
+
onCloseAutoFocus?: (event: Event) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Platform: WEB ONLY
|
|
60
|
+
*/
|
|
61
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Platform: WEB ONLY
|
|
64
|
+
*/
|
|
65
|
+
onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Platform: WEB ONLY
|
|
68
|
+
*/
|
|
69
|
+
onFocusOutside?: (event: FocusOutsideEvent) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Platform: WEB ONLY
|
|
72
|
+
*/
|
|
73
|
+
onInteractOutside?: (
|
|
74
|
+
event: PointerDownOutsideEvent | FocusOutsideEvent
|
|
75
|
+
) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Platform: WEB ONLY
|
|
78
|
+
*/
|
|
79
|
+
collisionBoundary?: Element | null | Array<Element | null>;
|
|
80
|
+
/**
|
|
81
|
+
* Platform: WEB ONLY
|
|
82
|
+
*/
|
|
83
|
+
sticky?: 'partial' | 'always';
|
|
84
|
+
/**
|
|
85
|
+
* Platform: WEB ONLY
|
|
86
|
+
*/
|
|
87
|
+
hideWhenDetached?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface ForceMountable {
|
|
91
|
+
forceMount?: true | undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type {
|
|
95
|
+
ComponentPropsWithAsChild,
|
|
96
|
+
ForceMountable,
|
|
97
|
+
Insets,
|
|
98
|
+
PositionedContentProps,
|
|
99
|
+
PressableRef,
|
|
100
|
+
SlottablePressableProps,
|
|
101
|
+
SlottableTextProps,
|
|
102
|
+
SlottableViewProps,
|
|
103
|
+
TextRef,
|
|
104
|
+
ViewRef,
|
|
105
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { GestureResponderEvent } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const ToggleGroupUtils = {
|
|
4
|
+
getIsSelected(value: string | string[] | undefined, itemValue: string) {
|
|
5
|
+
if (value === undefined) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
return value === itemValue;
|
|
10
|
+
}
|
|
11
|
+
return value.includes(itemValue);
|
|
12
|
+
},
|
|
13
|
+
getNewSingleValue(originalValue: string | string[] | undefined, itemValue: string) {
|
|
14
|
+
if (originalValue === itemValue) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return itemValue;
|
|
18
|
+
},
|
|
19
|
+
getNewMultipleValue(originalValue: string | string[] | undefined, itemValue: string) {
|
|
20
|
+
if (originalValue === undefined) {
|
|
21
|
+
return [itemValue];
|
|
22
|
+
}
|
|
23
|
+
if (typeof originalValue === 'string') {
|
|
24
|
+
return originalValue === itemValue ? [] : [originalValue, itemValue];
|
|
25
|
+
}
|
|
26
|
+
if (originalValue.includes(itemValue)) {
|
|
27
|
+
return originalValue.filter((v) => v !== itemValue);
|
|
28
|
+
}
|
|
29
|
+
return [...originalValue, itemValue];
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const EmptyGestureResponderEvent: GestureResponderEvent = {
|
|
34
|
+
nativeEvent: {
|
|
35
|
+
changedTouches: [],
|
|
36
|
+
identifier: '0',
|
|
37
|
+
locationX: 0,
|
|
38
|
+
locationY: 0,
|
|
39
|
+
pageX: 0,
|
|
40
|
+
pageY: 0,
|
|
41
|
+
target: '0',
|
|
42
|
+
timestamp: 0,
|
|
43
|
+
touches: [],
|
|
44
|
+
},
|
|
45
|
+
bubbles: false,
|
|
46
|
+
cancelable: false,
|
|
47
|
+
currentTarget: {} as any,
|
|
48
|
+
defaultPrevented: false,
|
|
49
|
+
eventPhase: 0,
|
|
50
|
+
persist: () => {},
|
|
51
|
+
isDefaultPrevented: () => false,
|
|
52
|
+
isPropagationStopped: () => false,
|
|
53
|
+
isTrusted: false,
|
|
54
|
+
preventDefault: () => {},
|
|
55
|
+
stopPropagation: () => {},
|
|
56
|
+
target: {} as any,
|
|
57
|
+
timeStamp: 0,
|
|
58
|
+
type: '',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { ToggleGroupUtils, EmptyGestureResponderEvent };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as AccordionPrimitive from '@rnr/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 { cn } from '../../lib/utils';
|
|
16
|
+
import { ChevronDown } from '../Icons';
|
|
17
|
+
import { TextClassContext } from './text';
|
|
18
|
+
|
|
19
|
+
const Accordion = React.forwardRef<
|
|
20
|
+
React.ElementRef<typeof AccordionPrimitive.Root>,
|
|
21
|
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Root>
|
|
22
|
+
>(({ children, ...props }, ref) => {
|
|
23
|
+
return (
|
|
24
|
+
<LayoutAnimationConfig skipEntering>
|
|
25
|
+
<AccordionPrimitive.Root ref={ref} {...props} asChild={Platform.OS !== 'web'}>
|
|
26
|
+
<Animated.View layout={LinearTransition.duration(200)}>{children}</Animated.View>
|
|
27
|
+
</AccordionPrimitive.Root>
|
|
28
|
+
</LayoutAnimationConfig>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
Accordion.displayName = AccordionPrimitive.Root.displayName;
|
|
33
|
+
|
|
34
|
+
const AccordionItem = React.forwardRef<
|
|
35
|
+
React.ElementRef<typeof AccordionPrimitive.Item>,
|
|
36
|
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
|
37
|
+
>(({ className, value, ...props }, ref) => {
|
|
38
|
+
return (
|
|
39
|
+
<Animated.View className={'overflow-hidden'} layout={LinearTransition.duration(200)}>
|
|
40
|
+
<AccordionPrimitive.Item
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={cn('border-b border-border', className)}
|
|
43
|
+
value={value}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
</Animated.View>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
AccordionItem.displayName = AccordionPrimitive.Item.displayName;
|
|
50
|
+
|
|
51
|
+
const Trigger = Platform.OS === 'web' ? View : Pressable;
|
|
52
|
+
|
|
53
|
+
const AccordionTrigger = React.forwardRef<
|
|
54
|
+
React.ElementRef<typeof Pressable>,
|
|
55
|
+
React.ComponentPropsWithoutRef<typeof Pressable>
|
|
56
|
+
>(({ className, children, ...props }, ref) => {
|
|
57
|
+
const { isExpanded } = AccordionPrimitive.useItemContext();
|
|
58
|
+
|
|
59
|
+
const progress = useDerivedValue(() =>
|
|
60
|
+
isExpanded ? withTiming(1, { duration: 250 }) : withTiming(0, { duration: 200 })
|
|
61
|
+
);
|
|
62
|
+
const chevronStyle = useAnimatedStyle(() => ({
|
|
63
|
+
transform: [{ rotate: `${progress.value * 180}deg` }],
|
|
64
|
+
opacity: interpolate(progress.value, [0, 1], [1, 0.8], Extrapolation.CLAMP),
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<TextClassContext.Provider value='native:text-lg font-medium web:group-hover:underline'>
|
|
69
|
+
<AccordionPrimitive.Header className='flex'>
|
|
70
|
+
<AccordionPrimitive.Trigger ref={ref} {...props} asChild>
|
|
71
|
+
<Trigger
|
|
72
|
+
className={cn(
|
|
73
|
+
'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',
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
<>{children}</>
|
|
78
|
+
<Animated.View style={chevronStyle}>
|
|
79
|
+
<ChevronDown size={18} className={'text-foreground shrink-0'} />
|
|
80
|
+
</Animated.View>
|
|
81
|
+
</Trigger>
|
|
82
|
+
</AccordionPrimitive.Trigger>
|
|
83
|
+
</AccordionPrimitive.Header>
|
|
84
|
+
</TextClassContext.Provider>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
|
88
|
+
|
|
89
|
+
const AccordionContent = React.forwardRef<
|
|
90
|
+
React.ElementRef<typeof AccordionPrimitive.Content>,
|
|
91
|
+
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
|
92
|
+
>(({ className, children, ...props }, ref) => {
|
|
93
|
+
const { isExpanded } = AccordionPrimitive.useItemContext();
|
|
94
|
+
return (
|
|
95
|
+
<TextClassContext.Provider value='native:text-lg'>
|
|
96
|
+
<AccordionPrimitive.Content
|
|
97
|
+
className={cn(
|
|
98
|
+
'overflow-hidden text-sm web:transition-all',
|
|
99
|
+
isExpanded ? 'web:animate-accordion-down' : 'web:animate-accordion-up'
|
|
100
|
+
)}
|
|
101
|
+
ref={ref}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
<InnerContent className={cn('pb-4', className)}>{children}</InnerContent>
|
|
105
|
+
</AccordionPrimitive.Content>
|
|
106
|
+
</TextClassContext.Provider>
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
function InnerContent({ children, className }: { children: React.ReactNode; className?: string }) {
|
|
111
|
+
if (Platform.OS === 'web') {
|
|
112
|
+
return <View className={cn('pb-4', className)}>{children}</View>;
|
|
113
|
+
}
|
|
114
|
+
return (
|
|
115
|
+
<Animated.View
|
|
116
|
+
entering={FadeIn}
|
|
117
|
+
exiting={FadeOutUp.duration(200)}
|
|
118
|
+
className={cn('pb-4', className)}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</Animated.View>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
|
126
|
+
|
|
127
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
4
|
+
import { buttonTextVariants, buttonVariants } from '../../components/ui/button';
|
|
5
|
+
import * as AlertDialogPrimitive from '@rnr/alert-dialog';
|
|
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
|
+
const AlertDialogOverlayWeb = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
18
|
+
>(({ className, ...props }, ref) => {
|
|
19
|
+
const { open } = AlertDialogPrimitive.useRootContext();
|
|
20
|
+
return (
|
|
21
|
+
<AlertDialogPrimitive.Overlay
|
|
22
|
+
style={StyleSheet.absoluteFill}
|
|
23
|
+
className={cn(
|
|
24
|
+
'z-50 bg-black/80 flex justify-center items-center p-2',
|
|
25
|
+
open ? 'web:animate-in web:fade-in-0' : 'web:animate-out web:fade-out-0',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
ref={ref}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
AlertDialogOverlayWeb.displayName = 'AlertDialogOverlayWeb';
|
|
35
|
+
|
|
36
|
+
const AlertDialogOverlayNative = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
39
|
+
>(({ className, children, ...props }, ref) => {
|
|
40
|
+
return (
|
|
41
|
+
<AlertDialogPrimitive.Overlay
|
|
42
|
+
style={StyleSheet.absoluteFill}
|
|
43
|
+
className={cn('z-50 bg-black/80 flex justify-center items-center p-2', className)}
|
|
44
|
+
{...props}
|
|
45
|
+
ref={ref}
|
|
46
|
+
asChild
|
|
47
|
+
>
|
|
48
|
+
<Animated.View entering={FadeIn.duration(150)} exiting={FadeOut.duration(150)}>
|
|
49
|
+
{children}
|
|
50
|
+
</Animated.View>
|
|
51
|
+
</AlertDialogPrimitive.Overlay>
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
AlertDialogOverlayNative.displayName = 'AlertDialogOverlayNative';
|
|
56
|
+
|
|
57
|
+
const AlertDialogOverlay = Platform.select({
|
|
58
|
+
web: AlertDialogOverlayWeb,
|
|
59
|
+
default: AlertDialogOverlayNative,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const AlertDialogContent = React.forwardRef<
|
|
63
|
+
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
64
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
65
|
+
>(({ className, ...props }, ref) => {
|
|
66
|
+
const { open } = AlertDialogPrimitive.useRootContext();
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<AlertDialogPortal>
|
|
70
|
+
<AlertDialogOverlay>
|
|
71
|
+
<AlertDialogPrimitive.Content
|
|
72
|
+
ref={ref}
|
|
73
|
+
className={cn(
|
|
74
|
+
'z-50 max-w-lg gap-4 border border-border bg-background p-6 shadow-lg shadow-foreground/10 web:duration-200 rounded-lg',
|
|
75
|
+
open
|
|
76
|
+
? 'web:animate-in web:fade-in-0 web:zoom-in-95'
|
|
77
|
+
: 'web:animate-out web:fade-out-0 web:zoom-out-95',
|
|
78
|
+
className
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
</AlertDialogOverlay>
|
|
83
|
+
</AlertDialogPortal>
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
87
|
+
|
|
88
|
+
const AlertDialogHeader = ({
|
|
89
|
+
className,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
92
|
+
<View className={cn('flex flex-col gap-2', className)} {...props} />
|
|
93
|
+
);
|
|
94
|
+
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
|
95
|
+
|
|
96
|
+
const AlertDialogFooter = ({
|
|
97
|
+
className,
|
|
98
|
+
...props
|
|
99
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
100
|
+
<View
|
|
101
|
+
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end gap-2', className)}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
|
106
|
+
|
|
107
|
+
const AlertDialogTitle = React.forwardRef<
|
|
108
|
+
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
109
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
110
|
+
>(({ className, ...props }, ref) => (
|
|
111
|
+
<AlertDialogPrimitive.Title
|
|
112
|
+
ref={ref}
|
|
113
|
+
className={cn('text-lg native:text-xl text-foreground font-semibold', className)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
));
|
|
117
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
118
|
+
|
|
119
|
+
const AlertDialogDescription = React.forwardRef<
|
|
120
|
+
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
121
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
122
|
+
>(({ className, ...props }, ref) => (
|
|
123
|
+
<AlertDialogPrimitive.Description
|
|
124
|
+
ref={ref}
|
|
125
|
+
className={cn('text-sm native:text-base text-muted-foreground', className)}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
));
|
|
129
|
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
130
|
+
|
|
131
|
+
const AlertDialogAction = React.forwardRef<
|
|
132
|
+
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
133
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
134
|
+
>(({ className, ...props }, ref) => (
|
|
135
|
+
<TextClassContext.Provider value={buttonTextVariants({ className })}>
|
|
136
|
+
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
|
137
|
+
</TextClassContext.Provider>
|
|
138
|
+
));
|
|
139
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
140
|
+
|
|
141
|
+
const AlertDialogCancel = React.forwardRef<
|
|
142
|
+
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
143
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
144
|
+
>(({ className, ...props }, ref) => (
|
|
145
|
+
<TextClassContext.Provider value={buttonTextVariants({ className, variant: 'outline' })}>
|
|
146
|
+
<AlertDialogPrimitive.Cancel
|
|
147
|
+
ref={ref}
|
|
148
|
+
className={cn(buttonVariants({ variant: 'outline', className }))}
|
|
149
|
+
{...props}
|
|
150
|
+
/>
|
|
151
|
+
</TextClassContext.Provider>
|
|
152
|
+
));
|
|
153
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
154
|
+
|
|
155
|
+
export {
|
|
156
|
+
AlertDialog,
|
|
157
|
+
AlertDialogAction,
|
|
158
|
+
AlertDialogCancel,
|
|
159
|
+
AlertDialogContent,
|
|
160
|
+
AlertDialogDescription,
|
|
161
|
+
AlertDialogFooter,
|
|
162
|
+
AlertDialogHeader,
|
|
163
|
+
AlertDialogOverlay,
|
|
164
|
+
AlertDialogPortal,
|
|
165
|
+
AlertDialogTitle,
|
|
166
|
+
AlertDialogTrigger,
|
|
167
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as AvatarPrimitive from '@rnr/avatar';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Avatar = React.forwardRef<
|
|
6
|
+
React.ElementRef<typeof AvatarPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<AvatarPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
));
|
|
15
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
16
|
+
|
|
17
|
+
const AvatarImage = React.forwardRef<
|
|
18
|
+
React.ElementRef<typeof AvatarPrimitive.Image>,
|
|
19
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
20
|
+
>(({ className, ...props }, ref) => (
|
|
21
|
+
<AvatarPrimitive.Image
|
|
22
|
+
ref={ref}
|
|
23
|
+
className={cn('aspect-square h-full w-full', className)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
));
|
|
27
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
28
|
+
|
|
29
|
+
const AvatarFallback = React.forwardRef<
|
|
30
|
+
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
32
|
+
>(({ className, ...props }, ref) => (
|
|
33
|
+
<AvatarPrimitive.Fallback
|
|
34
|
+
ref={ref}
|
|
35
|
+
className={cn(
|
|
36
|
+
'flex h-full w-full items-center justify-center rounded-full bg-muted',
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
));
|
|
42
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
43
|
+
|
|
44
|
+
export { Avatar, AvatarFallback, AvatarImage };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import * as Slot from '@rnr/slot';
|
|
4
|
+
import type { SlottableViewProps } from '@rnr/types';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
import { TextClassContext } from './text';
|
|
7
|
+
|
|
8
|
+
const badgeVariants = cva(
|
|
9
|
+
'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',
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: 'border-transparent bg-primary web:hover:opacity-80 active:opacity-80',
|
|
14
|
+
secondary: 'border-transparent bg-secondary web:hover:opacity-80 active:opacity-80',
|
|
15
|
+
destructive: 'border-transparent bg-destructive web:hover:opacity-80 active:opacity-80',
|
|
16
|
+
outline: 'text-foreground',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
variant: 'default',
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const badgeTextVariants = cva('text-xs font-semibold ', {
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: 'text-primary-foreground',
|
|
29
|
+
secondary: 'text-secondary-foreground',
|
|
30
|
+
destructive: 'text-destructive-foreground',
|
|
31
|
+
outline: 'text-foreground',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: 'default',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
type BadgeProps = SlottableViewProps & VariantProps<typeof badgeVariants>;
|
|
40
|
+
|
|
41
|
+
function Badge({ className, variant, asChild, ...props }: BadgeProps) {
|
|
42
|
+
const Component = asChild ? Slot.View : View;
|
|
43
|
+
return (
|
|
44
|
+
<TextClassContext.Provider value={badgeTextVariants({ variant })}>
|
|
45
|
+
<Component className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
46
|
+
</TextClassContext.Provider>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { Badge, badgeTextVariants, badgeVariants };
|
|
51
|
+
export type { BadgeProps };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Pressable } from 'react-native';
|
|
4
|
+
import { TextClassContext } from './text';
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
'group flex items-center justify-center rounded-md web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: 'bg-primary web:hover:opacity-90 active:opacity-90',
|
|
13
|
+
destructive: 'bg-destructive web:hover:opacity-90 active:opacity-90',
|
|
14
|
+
outline:
|
|
15
|
+
'border border-input bg-background web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent',
|
|
16
|
+
secondary: 'bg-secondary web:hover:opacity-80 active:opacity-80',
|
|
17
|
+
ghost: 'web:hover:bg-accent web:hover:text-accent-foreground active:bg-accent',
|
|
18
|
+
link: 'web:underline-offset-4 web:hover:underline web:focus:underline ',
|
|
19
|
+
},
|
|
20
|
+
size: {
|
|
21
|
+
default: 'h-10 px-4 py-2 native:h-12 native:px-5 native:py-3',
|
|
22
|
+
sm: 'h-9 rounded-md px-3',
|
|
23
|
+
lg: 'h-11 rounded-md px-8 native:h-14',
|
|
24
|
+
icon: 'h-10 w-10',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: 'default',
|
|
29
|
+
size: 'default',
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const buttonTextVariants = cva(
|
|
35
|
+
'web:whitespace-nowrap text-sm native:text-base font-medium text-foreground web:transition-colors',
|
|
36
|
+
{
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
default: 'text-primary-foreground',
|
|
40
|
+
destructive: 'text-destructive-foreground',
|
|
41
|
+
outline: 'group-active:text-accent-foreground',
|
|
42
|
+
secondary: 'text-secondary-foreground group-active:text-secondary-foreground',
|
|
43
|
+
ghost: 'group-active:text-accent-foreground',
|
|
44
|
+
link: 'text-primary group-active:underline',
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
default: '',
|
|
48
|
+
sm: '',
|
|
49
|
+
lg: 'native:text-lg',
|
|
50
|
+
icon: '',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
variant: 'default',
|
|
55
|
+
size: 'default',
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
type ButtonProps = React.ComponentPropsWithoutRef<typeof Pressable> &
|
|
61
|
+
VariantProps<typeof buttonVariants>;
|
|
62
|
+
|
|
63
|
+
const Button = React.forwardRef<React.ElementRef<typeof Pressable>, ButtonProps>(
|
|
64
|
+
({ className, variant, size, ...props }, ref) => {
|
|
65
|
+
return (
|
|
66
|
+
<TextClassContext.Provider
|
|
67
|
+
value={cn(
|
|
68
|
+
props.disabled && 'web:pointer-events-none',
|
|
69
|
+
buttonTextVariants({ variant, size })
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
<Pressable
|
|
73
|
+
className={cn(
|
|
74
|
+
props.disabled && 'opacity-50 web:pointer-events-none',
|
|
75
|
+
buttonVariants({ variant, size, className })
|
|
76
|
+
)}
|
|
77
|
+
ref={ref}
|
|
78
|
+
role='button'
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
</TextClassContext.Provider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
Button.displayName = 'Button';
|
|
86
|
+
|
|
87
|
+
export { Button, buttonTextVariants, buttonVariants };
|
|
88
|
+
export type { ButtonProps };
|