@gv-tech/ui-native 2.30.0 → 2.31.0
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/button.d.ts +4 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/select-event.d.ts +6 -0
- package/dist/lib/select-event.d.ts.map +1 -0
- package/dist/lib/touch-target.d.ts +9 -0
- package/dist/lib/touch-target.d.ts.map +1 -0
- package/dist/menubar.d.ts.map +1 -1
- package/dist/portal-slot.d.ts +11 -0
- package/dist/portal-slot.d.ts.map +1 -0
- package/dist/select.d.ts +8 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/text.d.ts.map +1 -1
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle.d.ts +8 -1
- package/dist/toggle.d.ts.map +1 -1
- package/dist/ui-native.cjs +2 -2
- package/dist/ui-native.esm.js +915 -1084
- package/package.json +1 -1
- package/src/__contracts.ts +0 -104
- package/src/button.tsx +39 -3
- package/src/context-menu.tsx +14 -11
- package/src/dropdown-menu.tsx +17 -31
- package/src/dropdown-menu.web.tsx +229 -0
- package/src/index.ts +3 -36
- package/src/lib/select-event.ts +10 -0
- package/src/lib/touch-target.ts +16 -0
- package/src/menubar.tsx +14 -11
- package/src/portal-slot.tsx +13 -0
- package/src/portal-slot.web.tsx +16 -0
- package/src/select.tsx +33 -48
- package/src/sheet.tsx +2 -5
- package/src/text.tsx +2 -1
- package/src/toggle-group.tsx +17 -6
- package/src/toggle.tsx +45 -18
- package/dist/__contracts.d.ts +0 -260
- package/dist/__contracts.d.ts.map +0 -1
- package/dist/accordion.test.d.ts +0 -2
- package/dist/accordion.test.d.ts.map +0 -1
- package/dist/alert.test.d.ts +0 -2
- package/dist/alert.test.d.ts.map +0 -1
- package/dist/avatar.test.d.ts +0 -2
- package/dist/avatar.test.d.ts.map +0 -1
- package/dist/badge.test.d.ts +0 -2
- package/dist/badge.test.d.ts.map +0 -1
- package/dist/button-group.test.d.ts +0 -2
- package/dist/button-group.test.d.ts.map +0 -1
- package/dist/button.test.d.ts +0 -2
- package/dist/button.test.d.ts.map +0 -1
- package/dist/card.test.d.ts +0 -2
- package/dist/card.test.d.ts.map +0 -1
- package/dist/carousel.test.d.ts +0 -2
- package/dist/carousel.test.d.ts.map +0 -1
- package/dist/checkbox.test.d.ts +0 -2
- package/dist/checkbox.test.d.ts.map +0 -1
- package/dist/collapsible.test.d.ts +0 -2
- package/dist/collapsible.test.d.ts.map +0 -1
- package/dist/dialog.test.d.ts +0 -2
- package/dist/dialog.test.d.ts.map +0 -1
- package/dist/form.test.d.ts +0 -2
- package/dist/form.test.d.ts.map +0 -1
- package/dist/hooks/use-theme.test.d.ts +0 -2
- package/dist/hooks/use-theme.test.d.ts.map +0 -1
- package/dist/input.test.d.ts +0 -2
- package/dist/input.test.d.ts.map +0 -1
- package/dist/label.test.d.ts +0 -2
- package/dist/label.test.d.ts.map +0 -1
- package/dist/popover.test.d.ts +0 -2
- package/dist/popover.test.d.ts.map +0 -1
- package/dist/progress.test.d.ts +0 -2
- package/dist/progress.test.d.ts.map +0 -1
- package/dist/radio-group.test.d.ts +0 -2
- package/dist/radio-group.test.d.ts.map +0 -1
- package/dist/search.test.d.ts +0 -2
- package/dist/search.test.d.ts.map +0 -1
- package/dist/select.test.d.ts +0 -2
- package/dist/select.test.d.ts.map +0 -1
- package/dist/separator.test.d.ts +0 -2
- package/dist/separator.test.d.ts.map +0 -1
- package/dist/sheet.test.d.ts +0 -2
- package/dist/sheet.test.d.ts.map +0 -1
- package/dist/skeleton.test.d.ts +0 -2
- package/dist/skeleton.test.d.ts.map +0 -1
- package/dist/switch.test.d.ts +0 -2
- package/dist/switch.test.d.ts.map +0 -1
- package/dist/table-of-contents.test.d.ts +0 -2
- package/dist/table-of-contents.test.d.ts.map +0 -1
- package/dist/table.test.d.ts +0 -2
- package/dist/table.test.d.ts.map +0 -1
- package/dist/tabs.test.d.ts +0 -2
- package/dist/tabs.test.d.ts.map +0 -1
- package/dist/text.test.d.ts +0 -2
- package/dist/text.test.d.ts.map +0 -1
- package/dist/textarea.test.d.ts +0 -2
- package/dist/textarea.test.d.ts.map +0 -1
- package/dist/theme-toggle.test.d.ts +0 -2
- package/dist/theme-toggle.test.d.ts.map +0 -1
- package/dist/toast.test.d.ts +0 -2
- package/dist/toast.test.d.ts.map +0 -1
- package/dist/toggle-group.test.d.ts +0 -2
- package/dist/toggle-group.test.d.ts.map +0 -1
- package/dist/toggle.test.d.ts +0 -2
- package/dist/toggle.test.d.ts.map +0 -1
- package/dist/tooltip.test.d.ts +0 -2
- package/dist/tooltip.test.d.ts.map +0 -1
package/package.json
CHANGED
package/src/__contracts.ts
CHANGED
|
@@ -123,10 +123,6 @@ import type {
|
|
|
123
123
|
InputGroupInputBaseProps,
|
|
124
124
|
InputGroupTextBaseProps,
|
|
125
125
|
InputGroupTextareaBaseProps,
|
|
126
|
-
InputOTPBaseProps,
|
|
127
|
-
InputOTPGroupBaseProps,
|
|
128
|
-
InputOTPSeparatorBaseProps,
|
|
129
|
-
InputOTPSlotBaseProps,
|
|
130
126
|
ItemActionsBaseProps,
|
|
131
127
|
ItemBaseProps,
|
|
132
128
|
ItemContentBaseProps,
|
|
@@ -153,9 +149,6 @@ import type {
|
|
|
153
149
|
MenubarSubContentBaseProps,
|
|
154
150
|
MenubarSubTriggerBaseProps,
|
|
155
151
|
MenubarTriggerBaseProps,
|
|
156
|
-
NativeSelectBaseProps,
|
|
157
|
-
NativeSelectOptGroupBaseProps,
|
|
158
|
-
NativeSelectOptionBaseProps,
|
|
159
152
|
NavigationMenuBaseProps,
|
|
160
153
|
NavigationMenuContentBaseProps,
|
|
161
154
|
NavigationMenuIndicatorBaseProps,
|
|
@@ -202,29 +195,6 @@ import type {
|
|
|
202
195
|
SheetPortalBaseProps,
|
|
203
196
|
SheetTitleBaseProps,
|
|
204
197
|
SheetTriggerBaseProps,
|
|
205
|
-
SidebarBaseProps,
|
|
206
|
-
SidebarContentBaseProps,
|
|
207
|
-
SidebarFooterBaseProps,
|
|
208
|
-
SidebarGroupActionBaseProps,
|
|
209
|
-
SidebarGroupBaseProps,
|
|
210
|
-
SidebarGroupContentBaseProps,
|
|
211
|
-
SidebarGroupLabelBaseProps,
|
|
212
|
-
SidebarHeaderBaseProps,
|
|
213
|
-
SidebarInputBaseProps,
|
|
214
|
-
SidebarInsetBaseProps,
|
|
215
|
-
SidebarMenuActionBaseProps,
|
|
216
|
-
SidebarMenuBadgeBaseProps,
|
|
217
|
-
SidebarMenuBaseProps,
|
|
218
|
-
SidebarMenuButtonBaseProps,
|
|
219
|
-
SidebarMenuItemBaseProps,
|
|
220
|
-
SidebarMenuSkeletonBaseProps,
|
|
221
|
-
SidebarMenuSubBaseProps,
|
|
222
|
-
SidebarMenuSubButtonBaseProps,
|
|
223
|
-
SidebarMenuSubItemBaseProps,
|
|
224
|
-
SidebarProviderBaseProps,
|
|
225
|
-
SidebarRailBaseProps,
|
|
226
|
-
SidebarSeparatorBaseProps,
|
|
227
|
-
SidebarTriggerBaseProps,
|
|
228
198
|
SkeletonBaseProps,
|
|
229
199
|
SliderBaseProps,
|
|
230
200
|
SpinnerBaseProps,
|
|
@@ -387,10 +357,6 @@ import type {
|
|
|
387
357
|
InputGroupInput,
|
|
388
358
|
InputGroupText,
|
|
389
359
|
InputGroupTextarea,
|
|
390
|
-
InputOTP,
|
|
391
|
-
InputOTPGroup,
|
|
392
|
-
InputOTPSeparator,
|
|
393
|
-
InputOTPSlot,
|
|
394
360
|
Item,
|
|
395
361
|
ItemActions,
|
|
396
362
|
ItemContent,
|
|
@@ -417,9 +383,6 @@ import type {
|
|
|
417
383
|
MenubarSubContent,
|
|
418
384
|
MenubarSubTrigger,
|
|
419
385
|
MenubarTrigger,
|
|
420
|
-
NativeSelect,
|
|
421
|
-
NativeSelectOptGroup,
|
|
422
|
-
NativeSelectOption,
|
|
423
386
|
NavigationMenu,
|
|
424
387
|
NavigationMenuContent,
|
|
425
388
|
NavigationMenuIndicator,
|
|
@@ -466,29 +429,6 @@ import type {
|
|
|
466
429
|
SheetPortal,
|
|
467
430
|
SheetTitle,
|
|
468
431
|
SheetTrigger,
|
|
469
|
-
Sidebar,
|
|
470
|
-
SidebarContent,
|
|
471
|
-
SidebarFooter,
|
|
472
|
-
SidebarGroup,
|
|
473
|
-
SidebarGroupAction,
|
|
474
|
-
SidebarGroupContent,
|
|
475
|
-
SidebarGroupLabel,
|
|
476
|
-
SidebarHeader,
|
|
477
|
-
SidebarInput,
|
|
478
|
-
SidebarInset,
|
|
479
|
-
SidebarMenu,
|
|
480
|
-
SidebarMenuAction,
|
|
481
|
-
SidebarMenuBadge,
|
|
482
|
-
SidebarMenuButton,
|
|
483
|
-
SidebarMenuItem,
|
|
484
|
-
SidebarMenuSkeleton,
|
|
485
|
-
SidebarMenuSub,
|
|
486
|
-
SidebarMenuSubButton,
|
|
487
|
-
SidebarMenuSubItem,
|
|
488
|
-
SidebarProvider,
|
|
489
|
-
SidebarRail,
|
|
490
|
-
SidebarSeparator,
|
|
491
|
-
SidebarTrigger,
|
|
492
432
|
Skeleton,
|
|
493
433
|
Slider,
|
|
494
434
|
Spinner,
|
|
@@ -810,13 +750,6 @@ export const _test_InputGroupText: InputGroupTextBaseProps = {} as React.Compone
|
|
|
810
750
|
export const _test_InputGroupTextarea: InputGroupTextareaBaseProps = {} as React.ComponentProps<
|
|
811
751
|
typeof InputGroupTextarea
|
|
812
752
|
>;
|
|
813
|
-
export const _test_NativeSelect: NativeSelectBaseProps = {} as React.ComponentProps<typeof NativeSelect>;
|
|
814
|
-
export const _test_NativeSelectOptGroup: NativeSelectOptGroupBaseProps = {} as React.ComponentProps<
|
|
815
|
-
typeof NativeSelectOptGroup
|
|
816
|
-
>;
|
|
817
|
-
export const _test_NativeSelectOption: NativeSelectOptionBaseProps = {} as React.ComponentProps<
|
|
818
|
-
typeof NativeSelectOption
|
|
819
|
-
>;
|
|
820
753
|
export const _test_Kbd: KbdBaseProps = {} as React.ComponentProps<typeof Kbd>;
|
|
821
754
|
export const _test_KbdGroup: KbdGroupBaseProps = {} as React.ComponentProps<typeof KbdGroup>;
|
|
822
755
|
export const _test_ItemActions: ItemActionsBaseProps = {} as React.ComponentProps<typeof ItemActions>;
|
|
@@ -848,40 +781,3 @@ export const _test_ComboboxList: ComboboxListBaseProps = {} as React.ComponentPr
|
|
|
848
781
|
export const _test_ComboboxSeparator: ComboboxSeparatorBaseProps = {} as React.ComponentProps<typeof ComboboxSeparator>;
|
|
849
782
|
export const _test_ComboboxTrigger: ComboboxTriggerBaseProps = {} as React.ComponentProps<typeof ComboboxTrigger>;
|
|
850
783
|
export const _test_ComboboxValue: ComboboxValueBaseProps = {} as React.ComponentProps<typeof ComboboxValue>;
|
|
851
|
-
export const _test_InputOTP: InputOTPBaseProps = {} as React.ComponentProps<typeof InputOTP>;
|
|
852
|
-
export const _test_InputOTPGroup: InputOTPGroupBaseProps = {} as React.ComponentProps<typeof InputOTPGroup>;
|
|
853
|
-
export const _test_InputOTPSeparator: InputOTPSeparatorBaseProps = {} as React.ComponentProps<typeof InputOTPSeparator>;
|
|
854
|
-
export const _test_InputOTPSlot: InputOTPSlotBaseProps = {} as React.ComponentProps<typeof InputOTPSlot>;
|
|
855
|
-
export const _test_Sidebar: SidebarBaseProps = {} as React.ComponentProps<typeof Sidebar>;
|
|
856
|
-
export const _test_SidebarContent: SidebarContentBaseProps = {} as React.ComponentProps<typeof SidebarContent>;
|
|
857
|
-
export const _test_SidebarFooter: SidebarFooterBaseProps = {} as React.ComponentProps<typeof SidebarFooter>;
|
|
858
|
-
export const _test_SidebarGroupAction: SidebarGroupActionBaseProps = {} as React.ComponentProps<
|
|
859
|
-
typeof SidebarGroupAction
|
|
860
|
-
>;
|
|
861
|
-
export const _test_SidebarGroup: SidebarGroupBaseProps = {} as React.ComponentProps<typeof SidebarGroup>;
|
|
862
|
-
export const _test_SidebarGroupContent: SidebarGroupContentBaseProps = {} as React.ComponentProps<
|
|
863
|
-
typeof SidebarGroupContent
|
|
864
|
-
>;
|
|
865
|
-
export const _test_SidebarGroupLabel: SidebarGroupLabelBaseProps = {} as React.ComponentProps<typeof SidebarGroupLabel>;
|
|
866
|
-
export const _test_SidebarHeader: SidebarHeaderBaseProps = {} as React.ComponentProps<typeof SidebarHeader>;
|
|
867
|
-
export const _test_SidebarInput: SidebarInputBaseProps = {} as React.ComponentProps<typeof SidebarInput>;
|
|
868
|
-
export const _test_SidebarInset: SidebarInsetBaseProps = {} as React.ComponentProps<typeof SidebarInset>;
|
|
869
|
-
export const _test_SidebarMenuAction: SidebarMenuActionBaseProps = {} as React.ComponentProps<typeof SidebarMenuAction>;
|
|
870
|
-
export const _test_SidebarMenuBadge: SidebarMenuBadgeBaseProps = {} as React.ComponentProps<typeof SidebarMenuBadge>;
|
|
871
|
-
export const _test_SidebarMenu: SidebarMenuBaseProps = {} as React.ComponentProps<typeof SidebarMenu>;
|
|
872
|
-
export const _test_SidebarMenuButton: SidebarMenuButtonBaseProps = {} as React.ComponentProps<typeof SidebarMenuButton>;
|
|
873
|
-
export const _test_SidebarMenuItem: SidebarMenuItemBaseProps = {} as React.ComponentProps<typeof SidebarMenuItem>;
|
|
874
|
-
export const _test_SidebarMenuSkeleton: SidebarMenuSkeletonBaseProps = {} as React.ComponentProps<
|
|
875
|
-
typeof SidebarMenuSkeleton
|
|
876
|
-
>;
|
|
877
|
-
export const _test_SidebarMenuSub: SidebarMenuSubBaseProps = {} as React.ComponentProps<typeof SidebarMenuSub>;
|
|
878
|
-
export const _test_SidebarMenuSubButton: SidebarMenuSubButtonBaseProps = {} as React.ComponentProps<
|
|
879
|
-
typeof SidebarMenuSubButton
|
|
880
|
-
>;
|
|
881
|
-
export const _test_SidebarMenuSubItem: SidebarMenuSubItemBaseProps = {} as React.ComponentProps<
|
|
882
|
-
typeof SidebarMenuSubItem
|
|
883
|
-
>;
|
|
884
|
-
export const _test_SidebarProvider: SidebarProviderBaseProps = {} as React.ComponentProps<typeof SidebarProvider>;
|
|
885
|
-
export const _test_SidebarRail: SidebarRailBaseProps = {} as React.ComponentProps<typeof SidebarRail>;
|
|
886
|
-
export const _test_SidebarSeparator: SidebarSeparatorBaseProps = {} as React.ComponentProps<typeof SidebarSeparator>;
|
|
887
|
-
export const _test_SidebarTrigger: SidebarTriggerBaseProps = {} as React.ComponentProps<typeof SidebarTrigger>;
|
package/src/button.tsx
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import type { ButtonBaseProps } from '@gv-tech/ui-core';
|
|
2
2
|
import { cva } from 'class-variance-authority';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import type { View } from 'react-native';
|
|
4
|
+
import type { AccessibilityState, Insets, View } from 'react-native';
|
|
5
5
|
import { Pressable, Text } from 'react-native';
|
|
6
6
|
|
|
7
7
|
import { wrapTextChildren } from './lib/render-native';
|
|
8
|
+
import { hitSlopBelow44 } from './lib/touch-target';
|
|
8
9
|
import { cn } from './lib/utils';
|
|
9
10
|
|
|
11
|
+
/** Visual box for `xs` and `icon-xs` (`h-7` / `w-7`). The press area grows around it. */
|
|
12
|
+
const COMPACT_BUTTON_PX = 28;
|
|
13
|
+
|
|
14
|
+
function compactButtonHitSlop(size: ButtonProps['size']): Insets | undefined {
|
|
15
|
+
if (size === 'xs' || size === 'icon-xs') {
|
|
16
|
+
return hitSlopBelow44(COMPACT_BUTTON_PX);
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
const buttonVariants = cva(
|
|
11
22
|
'flex-row items-center justify-center gap-2 rounded-md transition-colors active:opacity-80',
|
|
12
23
|
{
|
|
@@ -57,15 +68,40 @@ export interface ButtonProps extends ButtonBaseProps {
|
|
|
57
68
|
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | null;
|
|
58
69
|
size?: 'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg' | null;
|
|
59
70
|
onPress?: () => void;
|
|
71
|
+
accessibilityLabel?: string;
|
|
72
|
+
accessibilityState?: AccessibilityState;
|
|
73
|
+
hitSlop?: Insets;
|
|
60
74
|
}
|
|
61
75
|
|
|
62
76
|
const Button = React.forwardRef<View, ButtonProps>(
|
|
63
|
-
(
|
|
77
|
+
(
|
|
78
|
+
{
|
|
79
|
+
className,
|
|
80
|
+
variant,
|
|
81
|
+
size,
|
|
82
|
+
onPress,
|
|
83
|
+
children,
|
|
84
|
+
disabled,
|
|
85
|
+
accessibilityLabel,
|
|
86
|
+
accessibilityState,
|
|
87
|
+
hitSlop,
|
|
88
|
+
...props
|
|
89
|
+
},
|
|
90
|
+
ref,
|
|
91
|
+
) => {
|
|
64
92
|
return (
|
|
65
93
|
<Pressable
|
|
66
94
|
ref={ref}
|
|
67
|
-
onPress={onPress}
|
|
95
|
+
onPress={disabled ? undefined : onPress}
|
|
68
96
|
disabled={disabled}
|
|
97
|
+
hitSlop={hitSlop ?? compactButtonHitSlop(size)}
|
|
98
|
+
accessibilityRole="button"
|
|
99
|
+
accessibilityLabel={accessibilityLabel}
|
|
100
|
+
accessibilityState={{
|
|
101
|
+
...accessibilityState,
|
|
102
|
+
...(disabled ? { disabled: true } : {}),
|
|
103
|
+
}}
|
|
104
|
+
aria-busy={accessibilityState?.busy ? true : undefined}
|
|
69
105
|
className={cn(buttonVariants({ variant, size, className }), disabled && 'opacity-50')}
|
|
70
106
|
{...props}
|
|
71
107
|
>
|
package/src/context-menu.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
|
17
17
|
|
|
18
18
|
import { wrapTextChildren } from './lib/render-native';
|
|
19
19
|
import { cn } from './lib/utils';
|
|
20
|
+
import { PortalSlot } from './portal-slot';
|
|
20
21
|
import { Text } from './text';
|
|
21
22
|
|
|
22
23
|
export const ContextMenu = ContextMenuPrimitive.Root;
|
|
@@ -57,17 +58,19 @@ export const ContextMenuContent = React.forwardRef<
|
|
|
57
58
|
>(({ className, children, ...props }, ref) => {
|
|
58
59
|
return (
|
|
59
60
|
<ContextMenuPortal>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
<PortalSlot>
|
|
62
|
+
<ContextMenuOverlay />
|
|
63
|
+
<ContextMenuPrimitive.Content
|
|
64
|
+
ref={ref}
|
|
65
|
+
className={cn(
|
|
66
|
+
'bg-popover border-border z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md',
|
|
67
|
+
className,
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</ContextMenuPrimitive.Content>
|
|
73
|
+
</PortalSlot>
|
|
71
74
|
</ContextMenuPortal>
|
|
72
75
|
);
|
|
73
76
|
});
|
package/src/dropdown-menu.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
DropdownMenuSubContentBaseProps,
|
|
10
10
|
DropdownMenuSubTriggerBaseProps,
|
|
11
11
|
} from '@gv-tech/ui-core';
|
|
12
|
-
import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
13
12
|
import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
|
|
14
13
|
import { Check, ChevronRight, Circle } from 'lucide-react-native';
|
|
15
14
|
import * as React from 'react';
|
|
@@ -17,7 +16,9 @@ import { Platform, StyleSheet, View } from 'react-native';
|
|
|
17
16
|
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
18
17
|
|
|
19
18
|
import { wrapTextChildren } from './lib/render-native';
|
|
19
|
+
import { selectEvent } from './lib/select-event';
|
|
20
20
|
import { cn } from './lib/utils';
|
|
21
|
+
import { PortalSlot } from './portal-slot';
|
|
21
22
|
import { Text } from './text';
|
|
22
23
|
|
|
23
24
|
export const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
@@ -59,18 +60,20 @@ export const DropdownMenuContent = React.forwardRef<
|
|
|
59
60
|
const nativeSide = side === 'left' || side === 'right' ? 'bottom' : side;
|
|
60
61
|
return (
|
|
61
62
|
<DropdownMenuPortal>
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
<PortalSlot>
|
|
64
|
+
<DropdownMenuOverlay />
|
|
65
|
+
<DropdownMenuPrimitive.Content
|
|
66
|
+
ref={ref}
|
|
67
|
+
side={nativeSide}
|
|
68
|
+
className={cn(
|
|
69
|
+
'bg-popover border-border z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md',
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
{...props}
|
|
73
|
+
>
|
|
74
|
+
{children}
|
|
75
|
+
</DropdownMenuPrimitive.Content>
|
|
76
|
+
</PortalSlot>
|
|
74
77
|
</DropdownMenuPortal>
|
|
75
78
|
);
|
|
76
79
|
});
|
|
@@ -80,27 +83,10 @@ export const DropdownMenuItem = React.forwardRef<
|
|
|
80
83
|
React.ComponentRef<typeof DropdownMenuPrimitive.Item>,
|
|
81
84
|
DropdownMenuItemBaseProps
|
|
82
85
|
>(({ className, children, inset, onSelect, ...props }, ref) => {
|
|
83
|
-
if (Platform.OS === 'web') {
|
|
84
|
-
return (
|
|
85
|
-
<RadixDropdownMenu.Item
|
|
86
|
-
ref={ref as React.Ref<HTMLDivElement>}
|
|
87
|
-
onSelect={onSelect}
|
|
88
|
-
className={cn(
|
|
89
|
-
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex cursor-default flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none',
|
|
90
|
-
inset && 'pl-8',
|
|
91
|
-
className,
|
|
92
|
-
)}
|
|
93
|
-
{...props}
|
|
94
|
-
>
|
|
95
|
-
{children}
|
|
96
|
-
</RadixDropdownMenu.Item>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
86
|
return (
|
|
101
87
|
<DropdownMenuPrimitive.Item
|
|
102
88
|
ref={ref}
|
|
103
|
-
onPress={() => onSelect?.(
|
|
89
|
+
onPress={() => onSelect?.(selectEvent())}
|
|
104
90
|
className={cn(
|
|
105
91
|
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none',
|
|
106
92
|
inset && 'pl-8',
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Metro loads this file on web instead of dropdown-menu.tsx.
|
|
2
|
+
// The native module must not import Radix. Keep the exports aligned with that file.
|
|
3
|
+
import type {
|
|
4
|
+
DropdownMenuCheckboxItemBaseProps,
|
|
5
|
+
DropdownMenuContentBaseProps,
|
|
6
|
+
DropdownMenuItemBaseProps,
|
|
7
|
+
DropdownMenuLabelBaseProps,
|
|
8
|
+
DropdownMenuRadioItemBaseProps,
|
|
9
|
+
DropdownMenuSeparatorBaseProps,
|
|
10
|
+
DropdownMenuShortcutBaseProps,
|
|
11
|
+
DropdownMenuSubContentBaseProps,
|
|
12
|
+
DropdownMenuSubTriggerBaseProps,
|
|
13
|
+
} from '@gv-tech/ui-core';
|
|
14
|
+
import * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';
|
|
15
|
+
import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
|
|
16
|
+
import { Check, ChevronRight, Circle } from 'lucide-react-native';
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
19
|
+
import Animated, { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
20
|
+
|
|
21
|
+
import { wrapTextChildren } from './lib/render-native';
|
|
22
|
+
import { cn } from './lib/utils';
|
|
23
|
+
import { PortalSlot } from './portal-slot';
|
|
24
|
+
import { Text } from './text';
|
|
25
|
+
|
|
26
|
+
export const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
27
|
+
|
|
28
|
+
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
29
|
+
|
|
30
|
+
export const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
31
|
+
|
|
32
|
+
export const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
33
|
+
|
|
34
|
+
export const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
35
|
+
|
|
36
|
+
export const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
37
|
+
|
|
38
|
+
const DropdownMenuOverlay = React.forwardRef<
|
|
39
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Overlay>,
|
|
40
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Overlay>
|
|
41
|
+
>(({ className, ...props }, ref) => {
|
|
42
|
+
return (
|
|
43
|
+
<DropdownMenuPrimitive.Overlay
|
|
44
|
+
style={Platform.OS !== 'web' ? StyleSheet.absoluteFill : undefined}
|
|
45
|
+
ref={ref}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
<Animated.View
|
|
49
|
+
entering={FadeIn.duration(100)}
|
|
50
|
+
exiting={FadeOut.duration(100)}
|
|
51
|
+
className={cn('absolute inset-0 z-50 bg-black/30 backdrop-blur-md', className)}
|
|
52
|
+
/>
|
|
53
|
+
</DropdownMenuPrimitive.Overlay>
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
DropdownMenuOverlay.displayName = 'DropdownMenuOverlay';
|
|
57
|
+
|
|
58
|
+
export const DropdownMenuContent = React.forwardRef<
|
|
59
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Content>,
|
|
60
|
+
DropdownMenuContentBaseProps
|
|
61
|
+
>(({ className, children, side, ...props }, ref) => {
|
|
62
|
+
const nativeSide = side === 'left' || side === 'right' ? 'bottom' : side;
|
|
63
|
+
return (
|
|
64
|
+
<DropdownMenuPortal>
|
|
65
|
+
<PortalSlot>
|
|
66
|
+
<DropdownMenuOverlay />
|
|
67
|
+
<DropdownMenuPrimitive.Content
|
|
68
|
+
ref={ref}
|
|
69
|
+
side={nativeSide}
|
|
70
|
+
className={cn(
|
|
71
|
+
'bg-popover border-border z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md',
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</DropdownMenuPrimitive.Content>
|
|
78
|
+
</PortalSlot>
|
|
79
|
+
</DropdownMenuPortal>
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
DropdownMenuContent.displayName = 'DropdownMenuContent';
|
|
83
|
+
|
|
84
|
+
export const DropdownMenuItem = React.forwardRef<
|
|
85
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Item>,
|
|
86
|
+
DropdownMenuItemBaseProps
|
|
87
|
+
>(({ className, children, inset, onSelect, ...props }, ref) => {
|
|
88
|
+
return (
|
|
89
|
+
<RadixDropdownMenu.Item
|
|
90
|
+
ref={ref as React.Ref<HTMLDivElement>}
|
|
91
|
+
onSelect={onSelect}
|
|
92
|
+
className={cn(
|
|
93
|
+
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex cursor-default flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none select-none',
|
|
94
|
+
inset && 'pl-8',
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
{...props}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</RadixDropdownMenu.Item>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
DropdownMenuItem.displayName = 'DropdownMenuItem';
|
|
104
|
+
|
|
105
|
+
export const DropdownMenuCheckboxItem = React.forwardRef<
|
|
106
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
107
|
+
DropdownMenuCheckboxItemBaseProps
|
|
108
|
+
>(({ className, children, checked, onCheckedChange, ...props }, ref) => {
|
|
109
|
+
return (
|
|
110
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
111
|
+
ref={ref}
|
|
112
|
+
checked={!!checked}
|
|
113
|
+
onCheckedChange={onCheckedChange || (() => {})}
|
|
114
|
+
className={cn(
|
|
115
|
+
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex flex-row items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none',
|
|
116
|
+
className,
|
|
117
|
+
)}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
<View className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
121
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
122
|
+
<Check size={14} className="text-foreground" />
|
|
123
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
124
|
+
</View>
|
|
125
|
+
{wrapTextChildren(children, Text)}
|
|
126
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
DropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';
|
|
130
|
+
|
|
131
|
+
export const DropdownMenuRadioItem = React.forwardRef<
|
|
132
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
133
|
+
DropdownMenuRadioItemBaseProps
|
|
134
|
+
>(({ className, children, value, ...props }, ref) => {
|
|
135
|
+
return (
|
|
136
|
+
<DropdownMenuPrimitive.RadioItem
|
|
137
|
+
ref={ref}
|
|
138
|
+
value={value}
|
|
139
|
+
className={cn(
|
|
140
|
+
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground relative flex flex-row items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none',
|
|
141
|
+
className,
|
|
142
|
+
)}
|
|
143
|
+
{...props}
|
|
144
|
+
>
|
|
145
|
+
<View className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
146
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
147
|
+
<Circle size={8} className="text-foreground fill-current" />
|
|
148
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
149
|
+
</View>
|
|
150
|
+
{wrapTextChildren(children, Text)}
|
|
151
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
DropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';
|
|
155
|
+
|
|
156
|
+
export const DropdownMenuLabel = React.forwardRef<
|
|
157
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Label>,
|
|
158
|
+
DropdownMenuLabelBaseProps
|
|
159
|
+
>(({ className, children, inset, ...props }, ref) => {
|
|
160
|
+
return (
|
|
161
|
+
<DropdownMenuPrimitive.Label
|
|
162
|
+
ref={ref}
|
|
163
|
+
className={cn('text-foreground px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
|
|
164
|
+
{...props}
|
|
165
|
+
>
|
|
166
|
+
{wrapTextChildren(children as React.ReactNode, Text)}
|
|
167
|
+
</DropdownMenuPrimitive.Label>
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
DropdownMenuLabel.displayName = 'DropdownMenuLabel';
|
|
171
|
+
|
|
172
|
+
export const DropdownMenuSeparator = React.forwardRef<
|
|
173
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.Separator>,
|
|
174
|
+
DropdownMenuSeparatorBaseProps
|
|
175
|
+
>(({ className, ...props }, ref) => {
|
|
176
|
+
return (
|
|
177
|
+
<DropdownMenuPrimitive.Separator ref={ref} className={cn('bg-border -mx-1 my-1 h-px', className)} {...props} />
|
|
178
|
+
);
|
|
179
|
+
});
|
|
180
|
+
DropdownMenuSeparator.displayName = 'DropdownMenuSeparator';
|
|
181
|
+
|
|
182
|
+
export const DropdownMenuShortcut = ({ className, children, ...props }: DropdownMenuShortcutBaseProps) => {
|
|
183
|
+
return (
|
|
184
|
+
<Text className={cn('text-muted-foreground ml-auto text-xs tracking-widest', className)} {...props}>
|
|
185
|
+
{children}
|
|
186
|
+
</Text>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
|
190
|
+
|
|
191
|
+
export const DropdownMenuSubTrigger = React.forwardRef<
|
|
192
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
193
|
+
DropdownMenuSubTriggerBaseProps
|
|
194
|
+
>(({ className, children, inset, ...props }, ref) => {
|
|
195
|
+
return (
|
|
196
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
197
|
+
ref={ref}
|
|
198
|
+
className={cn(
|
|
199
|
+
'focus:bg-accent focus:text-accent-foreground active:bg-accent active:text-accent-foreground flex flex-row items-center rounded-sm px-2 py-1.5 text-sm outline-none',
|
|
200
|
+
inset && 'pl-8',
|
|
201
|
+
className,
|
|
202
|
+
)}
|
|
203
|
+
{...props}
|
|
204
|
+
>
|
|
205
|
+
<View className="flex flex-row items-center gap-1.5">{wrapTextChildren(children as React.ReactNode, Text)}</View>
|
|
206
|
+
<ChevronRight size={14} className="text-foreground ml-auto" />
|
|
207
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
DropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';
|
|
211
|
+
|
|
212
|
+
export const DropdownMenuSubContent = React.forwardRef<
|
|
213
|
+
React.ComponentRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
214
|
+
DropdownMenuSubContentBaseProps
|
|
215
|
+
>(({ className, children, ...props }, ref) => {
|
|
216
|
+
return (
|
|
217
|
+
<DropdownMenuPrimitive.SubContent
|
|
218
|
+
ref={ref}
|
|
219
|
+
className={cn(
|
|
220
|
+
'bg-popover border-border z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md',
|
|
221
|
+
className,
|
|
222
|
+
)}
|
|
223
|
+
{...props}
|
|
224
|
+
>
|
|
225
|
+
{children}
|
|
226
|
+
</DropdownMenuPrimitive.SubContent>
|
|
227
|
+
);
|
|
228
|
+
});
|
|
229
|
+
DropdownMenuSubContent.displayName = 'DropdownMenuSubContent';
|
package/src/index.ts
CHANGED
|
@@ -336,9 +336,6 @@ export {
|
|
|
336
336
|
InputGroupTextarea,
|
|
337
337
|
} from './input-group';
|
|
338
338
|
|
|
339
|
-
// Native Select
|
|
340
|
-
export { NativeSelect, NativeSelectOptGroup, NativeSelectOption } from './native-select';
|
|
341
|
-
|
|
342
339
|
// Kbd
|
|
343
340
|
export { Kbd, KbdGroup } from './kbd';
|
|
344
341
|
|
|
@@ -377,38 +374,8 @@ export {
|
|
|
377
374
|
useComboboxAnchor,
|
|
378
375
|
} from './combobox';
|
|
379
376
|
|
|
380
|
-
// Input OTP
|
|
381
|
-
export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from './input-otp';
|
|
382
|
-
|
|
383
|
-
// Sidebar
|
|
384
|
-
export {
|
|
385
|
-
Sidebar,
|
|
386
|
-
SidebarContent,
|
|
387
|
-
SidebarFooter,
|
|
388
|
-
SidebarGroup,
|
|
389
|
-
SidebarGroupAction,
|
|
390
|
-
SidebarGroupContent,
|
|
391
|
-
SidebarGroupLabel,
|
|
392
|
-
SidebarHeader,
|
|
393
|
-
SidebarInput,
|
|
394
|
-
SidebarInset,
|
|
395
|
-
SidebarMenu,
|
|
396
|
-
SidebarMenuAction,
|
|
397
|
-
SidebarMenuBadge,
|
|
398
|
-
SidebarMenuButton,
|
|
399
|
-
SidebarMenuItem,
|
|
400
|
-
SidebarMenuSkeleton,
|
|
401
|
-
SidebarMenuSub,
|
|
402
|
-
SidebarMenuSubButton,
|
|
403
|
-
SidebarMenuSubItem,
|
|
404
|
-
SidebarProvider,
|
|
405
|
-
SidebarRail,
|
|
406
|
-
SidebarSeparator,
|
|
407
|
-
SidebarTrigger,
|
|
408
|
-
useSidebar,
|
|
409
|
-
} from './sidebar';
|
|
410
|
-
|
|
411
377
|
// Chart, Command, Resizable, and Sonner are web-only and are not exported.
|
|
412
|
-
// Attachment, Bubble, Marker, Message, Message Scroller,
|
|
413
|
-
//
|
|
378
|
+
// Attachment, Bubble, Marker, Message, Message Scroller, Questionnaire,
|
|
379
|
+
// Sidebar, Input OTP, and Native Select stay unexported until the native
|
|
380
|
+
// behavior is real. Contracts remain in ui-core.
|
|
414
381
|
// See docs/reference/parity-matrix.md.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event passed to menu `onSelect` callbacks.
|
|
3
|
+
* The contract types that argument as a DOM `Event`. Hermes does not always provide the constructor.
|
|
4
|
+
*/
|
|
5
|
+
export function selectEvent(): Event {
|
|
6
|
+
if (typeof Event === 'function') {
|
|
7
|
+
return new Event('select');
|
|
8
|
+
}
|
|
9
|
+
return { type: 'select' } as Event;
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Insets } from 'react-native';
|
|
2
|
+
|
|
3
|
+
/** Smallest recommended touch target on a phone, in pixels. */
|
|
4
|
+
export const MIN_TOUCH_TARGET_PX = 44;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Insets that grow a visual box up to {@link MIN_TOUCH_TARGET_PX} without changing its layout.
|
|
8
|
+
* Returns undefined when the visual box is already large enough.
|
|
9
|
+
*/
|
|
10
|
+
export function hitSlopBelow44(visualPx: number): Insets | undefined {
|
|
11
|
+
if (visualPx >= MIN_TOUCH_TARGET_PX) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const inset = Math.ceil((MIN_TOUCH_TARGET_PX - visualPx) / 2);
|
|
15
|
+
return { top: inset, right: inset, bottom: inset, left: inset };
|
|
16
|
+
}
|