@brand-map/primitives 0.0.0-broken.0 → 0.0.0-broken.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -9
- package/src/accordion/accordion.tsx +17 -17
- package/src/accordion/accordion.web.tsx +13 -13
- package/src/alert-dialog/alert-dialog.tsx +28 -28
- package/src/alert-dialog/alert-dialog.web.tsx +18 -18
- package/src/alert-dialog/types.ts +3 -3
- package/src/aspect-ratio/aspect-ratio.tsx +3 -3
- package/src/avatar/avatar.tsx +10 -10
- package/src/avatar/types.ts +2 -2
- package/src/checkbox/checkbox.tsx +9 -9
- package/src/checkbox/checkbox.web.tsx +8 -8
- package/src/collapsible/collapsible.tsx +33 -35
- package/src/collapsible/collapsible.web.tsx +9 -9
- package/src/context-menu/context-menu.tsx +45 -45
- package/src/context-menu/context-menu.web.tsx +44 -44
- package/src/dialog/dialog.tsx +11 -11
- package/src/dialog/dialog.web.tsx +15 -15
- package/src/dialog/types.ts +5 -5
- package/src/dropdown-menu/dropdown-menu.tsx +43 -43
- package/src/dropdown-menu/dropdown-menu.web.tsx +45 -45
- package/src/hooks/use-Isomorphic-layout-effect.tsx +1 -2
- package/src/hooks/use-relative-position.tsx +2 -2
- package/src/hover-card/hover-card.tsx +40 -42
- package/src/hover-card/hover-card.web.tsx +9 -9
- package/src/label/label.tsx +3 -4
- package/src/label/label.web.tsx +5 -5
- package/src/menubar/menubar.tsx +45 -45
- package/src/menubar/menubar.web.tsx +47 -47
- package/src/navigation-menu/navigation-menu.tsx +23 -23
- package/src/navigation-menu/navigation-menu.web.tsx +26 -26
- package/src/popover/popover.tsx +20 -20
- package/src/popover/popover.web.tsx +14 -14
- package/src/progress/progress.tsx +4 -4
- package/src/progress/progress.web.tsx +5 -5
- package/src/radio-group/radio-group.tsx +11 -11
- package/src/radio-group/radio-group.web.tsx +9 -9
- package/src/render/index.ts +1 -0
- package/src/{slot/slot.tsx → render/render.tsx} +26 -27
- package/src/select/select.tsx +28 -28
- package/src/select/select.web.tsx +22 -22
- package/src/separator/separator.tsx +3 -3
- package/src/slider/slider.tsx +8 -8
- package/src/slider/slider.web.tsx +6 -6
- package/src/switch/switch.context.ts +16 -0
- package/src/switch/switch.tsx +68 -38
- package/src/switch/switch.web.tsx +9 -9
- package/src/switch/types.ts +27 -6
- package/src/table/table.tsx +9 -9
- package/src/tabs/tabs.tsx +13 -13
- package/src/tabs/tabs.web.tsx +10 -10
- package/src/toast/toast.tsx +14 -14
- package/src/toggle/toggle.tsx +5 -5
- package/src/toggle/toggle.web.tsx +5 -5
- package/src/toggle-group/toggle-group.tsx +11 -11
- package/src/toggle-group/toggle-group.web.tsx +10 -10
- package/src/toolbar/toolbar.tsx +12 -12
- package/src/toolbar/toolbar.web.tsx +12 -12
- package/src/tooltip/tooltip.tsx +17 -17
- package/src/tooltip/tooltip.web.tsx +11 -11
- package/src/types/index.ts +5 -15
- package/tsconfig.json +1 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.oxfmtrc.json +0 -35
- package/.oxlintrc.json +0 -166
- package/README.md +0 -78
- package/bun.lock +0 -904
- package/mise.toml +0 -3
- package/src/slot/index.ts +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// import * as Menubar from "@radix-ui/react-menubar";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { GestureResponderEvent, Pressable, Text, View } from "react-native";
|
|
4
4
|
|
|
5
5
|
// import { useAugmentedRef, useControllableState, useIsomorphicLayoutEffect } from "../hooks";
|
|
6
|
-
// import * as
|
|
6
|
+
// import * as Render from "../render";
|
|
7
7
|
// import { EmptyGestureResponderEvent } from "../utils";
|
|
8
8
|
|
|
9
9
|
// import type {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
// TriggerRef,
|
|
43
43
|
// } from "./types";
|
|
44
44
|
|
|
45
|
-
// const RootContext =
|
|
45
|
+
// const RootContext = createContext<RootProps | null>(null);
|
|
46
46
|
|
|
47
|
-
// const Root =
|
|
47
|
+
// const Root = forwardRef<RootRef, RootProps>(({ value, onValueChange, ...viewProps }, ref) => {
|
|
48
48
|
//
|
|
49
49
|
// return (
|
|
50
50
|
// <RootContext.Provider value={{ value, onValueChange }}>
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
// Root.displayName = "RootWebMenubar";
|
|
65
65
|
|
|
66
66
|
// function useRootContext() {
|
|
67
|
-
// const context =
|
|
67
|
+
// const context = useContext(RootContext);
|
|
68
68
|
// if (!context) {
|
|
69
69
|
// throw new Error("Menubar compound components cannot be rendered outside the Menubar component");
|
|
70
70
|
// }
|
|
71
71
|
// return context;
|
|
72
72
|
// }
|
|
73
73
|
|
|
74
|
-
// const MenuContext =
|
|
74
|
+
// const MenuContext = createContext<MenuProps | null>(null);
|
|
75
75
|
|
|
76
|
-
// const Menu =
|
|
76
|
+
// const Menu = forwardRef<MenuRef, MenuProps>(({ value, ...viewProps }, ref) => {
|
|
77
77
|
//
|
|
78
78
|
// return (
|
|
79
79
|
// <MenuContext.Provider value={{ value }}>
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
// Menu.displayName = "MenuWebMenubar";
|
|
91
91
|
|
|
92
92
|
// function useMenuContext() {
|
|
93
|
-
// const context =
|
|
93
|
+
// const context = useContext(MenuContext);
|
|
94
94
|
// if (!context) {
|
|
95
95
|
// throw new Error("Menubar compound components cannot be rendered outside the Menubar component");
|
|
96
96
|
// }
|
|
97
97
|
// return context;
|
|
98
98
|
// }
|
|
99
99
|
|
|
100
|
-
// const Trigger =
|
|
100
|
+
// const Trigger = forwardRef<TriggerRef, TriggerProps>(({ disabled = false, ...props }, ref) => {
|
|
101
101
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
102
102
|
// const { value: menuValue } = useMenuContext();
|
|
103
103
|
// const { value } = useRootContext();
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
// );
|
|
148
148
|
// }
|
|
149
149
|
|
|
150
|
-
// const Backdrop =
|
|
150
|
+
// const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ ...props }, ref) => {
|
|
151
151
|
//
|
|
152
152
|
// return (
|
|
153
153
|
// <Component
|
|
@@ -159,11 +159,11 @@
|
|
|
159
159
|
|
|
160
160
|
// Backdrop.displayName = "BackdropWebMenubar";
|
|
161
161
|
|
|
162
|
-
// const MenubarContentContext =
|
|
162
|
+
// const MenubarContentContext = createContext<{
|
|
163
163
|
// close: () => void;
|
|
164
164
|
// } | null>(null);
|
|
165
165
|
|
|
166
|
-
// const Content =
|
|
166
|
+
// const Content = forwardRef<ContentRef, ContentProps>(
|
|
167
167
|
// (
|
|
168
168
|
// {
|
|
169
169
|
// render = false,
|
|
@@ -235,20 +235,20 @@
|
|
|
235
235
|
// Content.displayName = "ContentWebMenubar";
|
|
236
236
|
|
|
237
237
|
// function useMenubarContentContext() {
|
|
238
|
-
// const context =
|
|
238
|
+
// const context = useContext(MenubarContentContext);
|
|
239
239
|
// if (!context) {
|
|
240
240
|
// throw new Error("MenubarContent compound components cannot be rendered outside the MenubarContent component");
|
|
241
241
|
// }
|
|
242
242
|
// return context;
|
|
243
243
|
// }
|
|
244
244
|
|
|
245
|
-
// const Item =
|
|
245
|
+
// const Item = forwardRef<ItemRef, ItemProps>(
|
|
246
246
|
// ({ render, textValue, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
247
247
|
// const { close } = useMenubarContentContext();
|
|
248
248
|
|
|
249
|
-
// function onKeyDown(
|
|
250
|
-
// onKeyDownProp?.(
|
|
251
|
-
// if (
|
|
249
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
250
|
+
// onKeyDownProp?.(event);
|
|
251
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
252
252
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
253
253
|
// if (closeOnPress) {
|
|
254
254
|
// close();
|
|
@@ -256,8 +256,8 @@
|
|
|
256
256
|
// }
|
|
257
257
|
// }
|
|
258
258
|
|
|
259
|
-
// function onPress(
|
|
260
|
-
// onPressProp?.(
|
|
259
|
+
// function onPress(event: GestureResponderEvent) {
|
|
260
|
+
// onPressProp?.(event);
|
|
261
261
|
// if (closeOnPress) {
|
|
262
262
|
// close();
|
|
263
263
|
// }
|
|
@@ -285,7 +285,7 @@
|
|
|
285
285
|
|
|
286
286
|
// Item.displayName = "ItemWebMenubar";
|
|
287
287
|
|
|
288
|
-
// const Group =
|
|
288
|
+
// const Group = forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
289
289
|
//
|
|
290
290
|
// return (
|
|
291
291
|
// <Menubar.Group render>
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
|
|
300
300
|
// Group.displayName = "GroupWebMenubar";
|
|
301
301
|
|
|
302
|
-
// const Label =
|
|
302
|
+
// const Label = forwardRef<LabelRef, LabelProps>(({ ...props }, ref) => {
|
|
303
303
|
//
|
|
304
304
|
// return (
|
|
305
305
|
// <Menubar.Label render>
|
|
@@ -313,11 +313,11 @@
|
|
|
313
313
|
|
|
314
314
|
// Label.displayName = "LabelWebMenubar";
|
|
315
315
|
|
|
316
|
-
// const CheckboxItem =
|
|
316
|
+
// const CheckboxItem = forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
317
317
|
// ({ render, checked, onCheckedChange, textValue, disabled = false, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
318
|
-
// function onKeyDown(
|
|
319
|
-
// onKeyDownProp?.(
|
|
320
|
-
// if (
|
|
318
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
319
|
+
// onKeyDownProp?.(event);
|
|
320
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
321
321
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
322
322
|
// onCheckedChange?.(!checked);
|
|
323
323
|
// if (closeOnPress) {
|
|
@@ -326,8 +326,8 @@
|
|
|
326
326
|
// }
|
|
327
327
|
// }
|
|
328
328
|
|
|
329
|
-
// function onPress(
|
|
330
|
-
// onPressProp?.(
|
|
329
|
+
// function onPress(event: GestureResponderEvent) {
|
|
330
|
+
// onPressProp?.(event);
|
|
331
331
|
// onCheckedChange?.(!checked);
|
|
332
332
|
// if (closeOnPress) {
|
|
333
333
|
// close();
|
|
@@ -358,12 +358,12 @@
|
|
|
358
358
|
|
|
359
359
|
// CheckboxItem.displayName = "CheckboxItemWebMenubar";
|
|
360
360
|
|
|
361
|
-
// const MenubarRadioGroupContext =
|
|
361
|
+
// const MenubarRadioGroupContext = createContext<{
|
|
362
362
|
// value?: string;
|
|
363
363
|
// onValueChange?: (value: string) => void;
|
|
364
364
|
// } | null>(null);
|
|
365
365
|
|
|
366
|
-
// const RadioGroup =
|
|
366
|
+
// const RadioGroup = forwardRef<RadioGroupRef, RadioGroupProps>(({ value, onValueChange, ...props }, ref) => {
|
|
367
367
|
//
|
|
368
368
|
// return (
|
|
369
369
|
// <MenubarRadioGroupContext.Provider value={{ value, onValueChange }}>
|
|
@@ -384,21 +384,21 @@
|
|
|
384
384
|
// RadioGroup.displayName = "RadioGroupWebMenubar";
|
|
385
385
|
|
|
386
386
|
// function useMenubarRadioGroupContext() {
|
|
387
|
-
// const context =
|
|
387
|
+
// const context = useContext(MenubarRadioGroupContext);
|
|
388
388
|
// if (!context) {
|
|
389
389
|
// throw new Error("MenubarRadioGroup compound components cannot be rendered outside the MenubarRadioGroup component");
|
|
390
390
|
// }
|
|
391
391
|
// return context;
|
|
392
392
|
// }
|
|
393
393
|
|
|
394
|
-
// const RadioItem =
|
|
394
|
+
// const RadioItem = forwardRef<RadioItemRef, RadioItemProps>(
|
|
395
395
|
// ({ render, value, textValue, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
396
396
|
// const { onValueChange } = useMenubarRadioGroupContext();
|
|
397
397
|
// const { close } = useMenubarContentContext();
|
|
398
398
|
|
|
399
|
-
// function onKeyDown(
|
|
400
|
-
// onKeyDownProp?.(
|
|
401
|
-
// if (
|
|
399
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
400
|
+
// onKeyDownProp?.(event);
|
|
401
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
402
402
|
// onValueChange?.(value);
|
|
403
403
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
404
404
|
// if (closeOnPress) {
|
|
@@ -407,9 +407,9 @@
|
|
|
407
407
|
// }
|
|
408
408
|
// }
|
|
409
409
|
|
|
410
|
-
// function onPress(
|
|
410
|
+
// function onPress(event: GestureResponderEvent) {
|
|
411
411
|
// onValueChange?.(value);
|
|
412
|
-
// onPressProp?.(
|
|
412
|
+
// onPressProp?.(event);
|
|
413
413
|
// if (closeOnPress) {
|
|
414
414
|
// close();
|
|
415
415
|
// }
|
|
@@ -437,7 +437,7 @@
|
|
|
437
437
|
|
|
438
438
|
// RadioItem.displayName = "RadioItemWebMenubar";
|
|
439
439
|
|
|
440
|
-
// const ItemIndicator =
|
|
440
|
+
// const ItemIndicator = forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
441
441
|
//
|
|
442
442
|
// return (
|
|
443
443
|
// <Menubar.ItemIndicator
|
|
@@ -454,7 +454,7 @@
|
|
|
454
454
|
|
|
455
455
|
// ItemIndicator.displayName = "ItemIndicatorWebMenubar";
|
|
456
456
|
|
|
457
|
-
// const Separator =
|
|
457
|
+
// const Separator = forwardRef<SeparatorRef, SeparatorProps>(({ decorative, ...props }, ref) => {
|
|
458
458
|
//
|
|
459
459
|
// return (
|
|
460
460
|
// <Menubar.Separator render>
|
|
@@ -468,12 +468,12 @@
|
|
|
468
468
|
|
|
469
469
|
// Separator.displayName = "SeparatorWebMenubar";
|
|
470
470
|
|
|
471
|
-
// const MenubarSubContext =
|
|
471
|
+
// const MenubarSubContext = createContext<{
|
|
472
472
|
// open: boolean;
|
|
473
473
|
// onOpenChange: (open: boolean) => void;
|
|
474
474
|
// } | null>(null);
|
|
475
475
|
|
|
476
|
-
// const Sub =
|
|
476
|
+
// const Sub = forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, onOpenChange: onOpenChangeProp, ...props }, ref) => {
|
|
477
477
|
// const [open = false, onOpenChange] = useControllableState({
|
|
478
478
|
// prop: openProp,
|
|
479
479
|
// defaultProp: defaultOpen,
|
|
@@ -498,19 +498,19 @@
|
|
|
498
498
|
// Sub.displayName = "SubWebMenubar";
|
|
499
499
|
|
|
500
500
|
// function useSubContext() {
|
|
501
|
-
// const context =
|
|
501
|
+
// const context = useContext(MenubarSubContext);
|
|
502
502
|
// if (!context) {
|
|
503
503
|
// throw new Error("MenubarSub compound components cannot be rendered outside the MenubarSub component");
|
|
504
504
|
// }
|
|
505
505
|
// return context;
|
|
506
506
|
// }
|
|
507
507
|
|
|
508
|
-
// const SubTrigger =
|
|
508
|
+
// const SubTrigger = forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue, disabled = false, onPress: onPressProp, ...props }, ref) => {
|
|
509
509
|
// const { onOpenChange } = useSubContext();
|
|
510
510
|
|
|
511
|
-
// function onPress(
|
|
511
|
+
// function onPress(event: GestureResponderEvent) {
|
|
512
512
|
// onOpenChange(true);
|
|
513
|
-
// onPressProp?.(
|
|
513
|
+
// onPressProp?.(event);
|
|
514
514
|
// }
|
|
515
515
|
|
|
516
516
|
//
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
|
|
532
532
|
// SubTrigger.displayName = "SubTriggerWebMenubar";
|
|
533
533
|
|
|
534
|
-
// const SubContent =
|
|
534
|
+
// const SubContent = forwardRef<SubContentRef, SubContentProps>(({ render = false, keepMounted, ...props }, ref) => {
|
|
535
535
|
//
|
|
536
536
|
// return (
|
|
537
537
|
// <Menubar.Portal>
|
|
@@ -570,6 +570,6 @@
|
|
|
570
570
|
// useSubContext,
|
|
571
571
|
// };
|
|
572
572
|
|
|
573
|
-
// function onSelected(
|
|
574
|
-
//
|
|
573
|
+
// function onSelected(event: Event) {
|
|
574
|
+
// event.preventDefault();
|
|
575
575
|
// }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useId, useState, useContext, useRef, useImperativeHandle, useEffect } from "react";
|
|
2
2
|
import { BackHandler, Pressable, View, type GestureResponderEvent, type LayoutChangeEvent, type LayoutRectangle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useRelativePosition, type LayoutPosition } from "../hooks";
|
|
5
5
|
import { Portal as RNPPortal } from "../portal";
|
|
6
|
-
import * as
|
|
6
|
+
import * as Render from "../render";
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
9
|
ContentProps,
|
|
@@ -33,12 +33,12 @@ interface INavigationMenuRootContext extends RootProps {
|
|
|
33
33
|
nativeID: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const RootContext =
|
|
36
|
+
const RootContext = createContext<INavigationMenuRootContext | null>(null);
|
|
37
37
|
|
|
38
|
-
const Root =
|
|
39
|
-
const nativeID =
|
|
40
|
-
const [triggerPosition, setTriggerPosition] =
|
|
41
|
-
const [contentLayout, setContentLayout] =
|
|
38
|
+
const Root = forwardRef<RootRef, RootProps>(({ value, onValueChange, ...viewProps }, ref) => {
|
|
39
|
+
const nativeID = useId();
|
|
40
|
+
const [triggerPosition, setTriggerPosition] = useState<LayoutPosition | null>(null);
|
|
41
|
+
const [contentLayout, setContentLayout] = useState<LayoutRectangle | null>(null);
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<RootContext.Provider
|
|
@@ -64,14 +64,14 @@ const Root = React.forwardRef<RootRef, RootProps>(({ value, onValueChange, ...vi
|
|
|
64
64
|
Root.displayName = "RootNativeNavigationMenu";
|
|
65
65
|
|
|
66
66
|
function useRootContext() {
|
|
67
|
-
const context =
|
|
67
|
+
const context = useContext(RootContext);
|
|
68
68
|
if (!context) {
|
|
69
69
|
throw new Error("NavigationMenu compound components cannot be rendered outside the NavigationMenu component");
|
|
70
70
|
}
|
|
71
71
|
return context;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const List =
|
|
74
|
+
const List = forwardRef<ListRef, ListProps>(({ ...viewProps }, ref) => {
|
|
75
75
|
return (
|
|
76
76
|
<Component
|
|
77
77
|
ref={ref}
|
|
@@ -83,10 +83,10 @@ const List = React.forwardRef<ListRef, ListProps>(({ ...viewProps }, ref) => {
|
|
|
83
83
|
|
|
84
84
|
List.displayName = "ListNativeNavigationMenu";
|
|
85
85
|
|
|
86
|
-
const ItemContext =
|
|
86
|
+
const ItemContext = createContext<(ItemProps & { nativeID: string }) | null>(null);
|
|
87
87
|
|
|
88
|
-
const Item =
|
|
89
|
-
const nativeID =
|
|
88
|
+
const Item = forwardRef<ItemRef, ItemProps>(({ value, ...viewProps }, ref) => {
|
|
89
|
+
const nativeID = useId();
|
|
90
90
|
|
|
91
91
|
return (
|
|
92
92
|
<ItemContext.Provider
|
|
@@ -107,33 +107,33 @@ const Item = React.forwardRef<ItemRef, ItemProps>(({ value, ...viewProps }, ref)
|
|
|
107
107
|
Item.displayName = "ItemNativeNavigationMenu";
|
|
108
108
|
|
|
109
109
|
function useItemContext() {
|
|
110
|
-
const context =
|
|
110
|
+
const context = useContext(ItemContext);
|
|
111
111
|
if (!context) {
|
|
112
112
|
throw new Error("NavigationMenu compound components cannot be rendered outside the NavigationMenu component");
|
|
113
113
|
}
|
|
114
114
|
return context;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const Trigger =
|
|
118
|
-
const triggerRef =
|
|
117
|
+
const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
118
|
+
const triggerRef = useRef<View>(null);
|
|
119
119
|
const { value, onValueChange, setTriggerPosition } = useRootContext();
|
|
120
120
|
const { value: menuValue } = useItemContext();
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
useImperativeHandle(ref, () => {
|
|
123
123
|
if (!triggerRef.current) {
|
|
124
124
|
return new View({});
|
|
125
125
|
}
|
|
126
126
|
return triggerRef.current;
|
|
127
127
|
}, [triggerRef.current]);
|
|
128
128
|
|
|
129
|
-
function onPress(
|
|
129
|
+
function onPress(event: GestureResponderEvent) {
|
|
130
130
|
if (disabled) return;
|
|
131
131
|
triggerRef.current?.measure((_x, _y, width, height, pageX, pageY) => {
|
|
132
132
|
setTriggerPosition({ width, pageX, pageY: pageY, height });
|
|
133
133
|
});
|
|
134
134
|
|
|
135
135
|
onValueChange(menuValue === value ? "" : menuValue);
|
|
136
|
-
onPressProp?.(
|
|
136
|
+
onPressProp?.(event);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
return (
|
|
@@ -186,7 +186,7 @@ function Portal({ keepMounted, hostName, children }: PortalProps) {
|
|
|
186
186
|
/**
|
|
187
187
|
* @info `position`, `top`, `left`, and `maxWidth` style properties are controlled internally. Opt out of this behavior by setting `disablePositioningStyle` to `true`.
|
|
188
188
|
*/
|
|
189
|
-
const Content =
|
|
189
|
+
const Content = forwardRef<ContentRef, ContentProps>(
|
|
190
190
|
(
|
|
191
191
|
{
|
|
192
192
|
render = false,
|
|
@@ -207,7 +207,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
207
207
|
const { value, onValueChange, triggerPosition, setTriggerPosition, contentLayout, setContentLayout } = useRootContext();
|
|
208
208
|
const { value: menuValue, nativeID } = useItemContext();
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
useEffect(() => {
|
|
211
211
|
const backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
212
212
|
setTriggerPosition(null);
|
|
213
213
|
setContentLayout(null);
|
|
@@ -261,7 +261,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
261
261
|
|
|
262
262
|
Content.displayName = "ContentNativeNavigationMenu";
|
|
263
263
|
|
|
264
|
-
const Link =
|
|
264
|
+
const Link = forwardRef<LinkRef, LinkProps>(({ ...props }, ref) => {
|
|
265
265
|
return (
|
|
266
266
|
<Component
|
|
267
267
|
ref={ref}
|
|
@@ -273,7 +273,7 @@ const Link = React.forwardRef<LinkRef, LinkProps>(({ ...props }, ref) => {
|
|
|
273
273
|
|
|
274
274
|
Link.displayName = "LinkNativeNavigationMenu";
|
|
275
275
|
|
|
276
|
-
const Viewport =
|
|
276
|
+
const Viewport = forwardRef<ViewportRef, ViewportProps>((props, ref) => {
|
|
277
277
|
return (
|
|
278
278
|
<View
|
|
279
279
|
ref={ref}
|
|
@@ -284,7 +284,7 @@ const Viewport = React.forwardRef<ViewportRef, ViewportProps>((props, ref) => {
|
|
|
284
284
|
|
|
285
285
|
Viewport.displayName = "ViewportNativeNavigationMenu";
|
|
286
286
|
|
|
287
|
-
const Indicator =
|
|
287
|
+
const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ ...props }, ref) => {
|
|
288
288
|
return (
|
|
289
289
|
<Component
|
|
290
290
|
ref={ref}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// import * as NavigationMenu from "@radix-ui/react-navigation-menu";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
4
4
|
|
|
5
5
|
// import { useAugmentedRef, useIsomorphicLayoutEffect } from "../hooks";
|
|
6
|
-
// import * as
|
|
6
|
+
// import * as Render from "../render";
|
|
7
7
|
// import { EmptyGestureResponderEvent } from "../utils";
|
|
8
8
|
|
|
9
9
|
// import type {
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
// ViewportRef,
|
|
27
27
|
// } from "./types";
|
|
28
28
|
|
|
29
|
-
// const NavigationMenuContext =
|
|
29
|
+
// const NavigationMenuContext = createContext<RootProps | null>(null);
|
|
30
30
|
|
|
31
|
-
// const Root =
|
|
31
|
+
// const Root = forwardRef<RootRef, RootProps>(
|
|
32
32
|
// ({ render, value, onValueChange, delayDuration, skipDelayDuration, dir, orientation, ...viewProps }, ref) => {
|
|
33
33
|
//
|
|
34
34
|
// return (
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
// Root.displayName = "RootWebNavigationMenu";
|
|
55
55
|
|
|
56
56
|
// function useRootContext() {
|
|
57
|
-
// const context =
|
|
57
|
+
// const context = useContext(NavigationMenuContext);
|
|
58
58
|
// if (!context) {
|
|
59
59
|
// throw new Error("NavigationMenu compound components cannot be rendered outside the NavigationMenu component");
|
|
60
60
|
// }
|
|
61
61
|
// return context;
|
|
62
62
|
// }
|
|
63
63
|
|
|
64
|
-
// const List =
|
|
64
|
+
// const List = forwardRef<ListRef, ListProps>(({ ...viewProps }, ref) => {
|
|
65
65
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
66
66
|
// const { orientation } = useRootContext();
|
|
67
67
|
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
|
|
86
86
|
// List.displayName = "ListWebNavigationMenu";
|
|
87
87
|
|
|
88
|
-
// const ItemContext =
|
|
88
|
+
// const ItemContext = createContext<ItemProps | null>(null);
|
|
89
89
|
|
|
90
|
-
// const Item =
|
|
90
|
+
// const Item = forwardRef<ItemRef, ItemProps>(({ value, ...props }, ref) => {
|
|
91
91
|
//
|
|
92
92
|
// return (
|
|
93
93
|
// <ItemContext.Provider value={{ value }}>
|
|
@@ -107,26 +107,26 @@
|
|
|
107
107
|
// Item.displayName = "ItemWebNavigationMenu";
|
|
108
108
|
|
|
109
109
|
// function useItemContext() {
|
|
110
|
-
// const context =
|
|
110
|
+
// const context = useContext(ItemContext);
|
|
111
111
|
// if (!context) {
|
|
112
112
|
// throw new Error("NavigationMenu compound components cannot be rendered outside the NavigationMenu component");
|
|
113
113
|
// }
|
|
114
114
|
// return context;
|
|
115
115
|
// }
|
|
116
116
|
|
|
117
|
-
// const Trigger =
|
|
117
|
+
// const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled = false, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
118
118
|
// const { value: rootValue, onValueChange } = useRootContext();
|
|
119
119
|
// const { value } = useItemContext();
|
|
120
|
-
// function onKeyDown(
|
|
121
|
-
// onKeyDownProp?.(
|
|
122
|
-
// if (
|
|
120
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
121
|
+
// onKeyDownProp?.(event);
|
|
122
|
+
// if (event.key === " ") {
|
|
123
123
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
124
124
|
// onValueChange(value === rootValue ? "" : value);
|
|
125
125
|
// }
|
|
126
126
|
// }
|
|
127
127
|
|
|
128
|
-
// function onPress(
|
|
129
|
-
// onPressProp?.(
|
|
128
|
+
// function onPress(event: GestureResponderEvent) {
|
|
129
|
+
// onPressProp?.(event);
|
|
130
130
|
// onValueChange(value === rootValue ? "" : value);
|
|
131
131
|
// }
|
|
132
132
|
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
// return <>{children}</>;
|
|
154
154
|
// }
|
|
155
155
|
|
|
156
|
-
// const Content =
|
|
156
|
+
// const Content = forwardRef<ContentRef, ContentProps>(
|
|
157
157
|
// (
|
|
158
158
|
// {
|
|
159
159
|
// render = false,
|
|
@@ -194,18 +194,18 @@
|
|
|
194
194
|
|
|
195
195
|
// Content.displayName = "ContentWebNavigationMenu";
|
|
196
196
|
|
|
197
|
-
// const Link =
|
|
197
|
+
// const Link = forwardRef<LinkRef, LinkProps>(({ active, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
198
198
|
// const { onValueChange } = useRootContext();
|
|
199
|
-
// function onKeyDown(
|
|
200
|
-
// onKeyDownProp?.(
|
|
201
|
-
// if (
|
|
199
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
200
|
+
// onKeyDownProp?.(event);
|
|
201
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
202
202
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
203
203
|
// onValueChange("");
|
|
204
204
|
// }
|
|
205
205
|
// }
|
|
206
206
|
|
|
207
|
-
// function onPress(
|
|
208
|
-
// onPressProp?.(
|
|
207
|
+
// function onPress(event: GestureResponderEvent) {
|
|
208
|
+
// onPressProp?.(event);
|
|
209
209
|
// onValueChange("");
|
|
210
210
|
// }
|
|
211
211
|
|
|
@@ -229,20 +229,20 @@
|
|
|
229
229
|
|
|
230
230
|
// Link.displayName = "LinkWebNavigationMenu";
|
|
231
231
|
|
|
232
|
-
// const Viewport =
|
|
232
|
+
// const Viewport = forwardRef<ViewportRef, ViewportProps>((props, ref) => {
|
|
233
233
|
// return (
|
|
234
|
-
// <
|
|
234
|
+
// <Render.View
|
|
235
235
|
// ref={ref}
|
|
236
236
|
// {...props}
|
|
237
237
|
// >
|
|
238
238
|
// <NavigationMenu.Viewport />
|
|
239
|
-
// </
|
|
239
|
+
// </Render.View>
|
|
240
240
|
// );
|
|
241
241
|
// });
|
|
242
242
|
|
|
243
243
|
// Viewport.displayName = "ViewportWebNavigationMenu";
|
|
244
244
|
|
|
245
|
-
// const Indicator =
|
|
245
|
+
// const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ ...props }, ref) => {
|
|
246
246
|
//
|
|
247
247
|
// return (
|
|
248
248
|
// <NavigationMenu.Indicator render>
|