@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,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useContext, Component } from "react";
|
|
2
2
|
import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import * as
|
|
4
|
+
import * as Render from "../render";
|
|
5
5
|
import type { PressableRef, RenderPressableProps } from "../types";
|
|
6
6
|
|
|
7
7
|
import type { IndicatorProps, IndicatorRef, RootProps, RootRef } from "./types";
|
|
@@ -10,9 +10,9 @@ interface RootContext extends RootProps {
|
|
|
10
10
|
nativeID?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const CheckboxContext =
|
|
13
|
+
const CheckboxContext = createContext<RootContext | null>(null);
|
|
14
14
|
|
|
15
|
-
const Root =
|
|
15
|
+
const Root = forwardRef<RootRef, RootProps>(({ disabled = false, checked, onCheckedChange, nativeID, ...props }, ref) => {
|
|
16
16
|
return (
|
|
17
17
|
<CheckboxContext.Provider
|
|
18
18
|
value={{
|
|
@@ -33,21 +33,21 @@ const Root = React.forwardRef<RootRef, RootProps>(({ disabled = false, checked,
|
|
|
33
33
|
Root.displayName = "RootNativeCheckbox";
|
|
34
34
|
|
|
35
35
|
function useCheckboxContext() {
|
|
36
|
-
const context =
|
|
36
|
+
const context = useContext(CheckboxContext);
|
|
37
37
|
if (!context) {
|
|
38
38
|
throw new Error("Checkbox compound components cannot be rendered outside the Checkbox component");
|
|
39
39
|
}
|
|
40
40
|
return context;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const Trigger =
|
|
43
|
+
const Trigger = forwardRef<PressableRef, RenderPressableProps>(({ onPress: onPressProp, ...props }, ref) => {
|
|
44
44
|
const { disabled, checked, onCheckedChange, nativeID } = useCheckboxContext();
|
|
45
45
|
|
|
46
|
-
function onPress(
|
|
46
|
+
function onPress(event: GestureResponderEvent) {
|
|
47
47
|
if (disabled) return;
|
|
48
48
|
const newValue = !checked;
|
|
49
49
|
onCheckedChange(newValue);
|
|
50
|
-
onPressProp?.(
|
|
50
|
+
onPressProp?.(event);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return (
|
|
@@ -70,7 +70,7 @@ const Trigger = React.forwardRef<PressableRef, RenderPressableProps>(({ onPress:
|
|
|
70
70
|
|
|
71
71
|
Trigger.displayName = "TriggerNativeCheckbox";
|
|
72
72
|
|
|
73
|
-
const Indicator =
|
|
73
|
+
const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
74
74
|
const { checked, disabled } = useCheckboxContext();
|
|
75
75
|
|
|
76
76
|
if (!keepMounted) {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// import * as Checkbox from "@radix-ui/react-checkbox";
|
|
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
|
|
|
8
8
|
// import type { IndicatorProps, IndicatorRef, RootProps, RootRef } from "./types";
|
|
9
9
|
|
|
10
|
-
// const CheckboxContext =
|
|
10
|
+
// const CheckboxContext = createContext<RootProps | null>(null);
|
|
11
11
|
|
|
12
|
-
// const Root =
|
|
12
|
+
// const Root = forwardRef<RootRef, RootProps>(({ disabled, checked, onCheckedChange, onPress: onPressProp, role: _role, ...props }, ref) => {
|
|
13
13
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
14
14
|
|
|
15
|
-
// function onPress(
|
|
16
|
-
// onPressProp?.(
|
|
15
|
+
// function onPress(event: GestureResponderEvent) {
|
|
16
|
+
// onPressProp?.(event);
|
|
17
17
|
// onCheckedChange(!checked);
|
|
18
18
|
// }
|
|
19
19
|
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
// Root.displayName = "RootWebCheckbox";
|
|
64
64
|
|
|
65
65
|
// function useCheckboxContext() {
|
|
66
|
-
// const context =
|
|
66
|
+
// const context = useContext(CheckboxContext);
|
|
67
67
|
// if (context === null) {
|
|
68
68
|
// throw new Error("Checkbox compound components cannot be rendered outside the Checkbox component");
|
|
69
69
|
// }
|
|
70
70
|
// return context;
|
|
71
71
|
// }
|
|
72
72
|
|
|
73
|
-
// const Indicator =
|
|
73
|
+
// const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
74
74
|
// const { checked, disabled } = useCheckboxContext();
|
|
75
75
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
76
76
|
|
|
@@ -1,57 +1,55 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useContext, useId } from "react";
|
|
2
2
|
import { Pressable, View, type GestureResponderEvent } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useControllableState } from "../hooks";
|
|
5
|
-
import * as
|
|
5
|
+
import * as Render from "../render";
|
|
6
6
|
|
|
7
7
|
import type { ContentProps, ContentRef, RootContext, RootProps, RootRef, TriggerProps, TriggerRef } from "./types";
|
|
8
8
|
|
|
9
|
-
const CollapsibleContext =
|
|
10
|
-
|
|
11
|
-
const Root =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
);
|
|
9
|
+
const CollapsibleContext = createContext<(RootContext & { nativeID: string }) | null>(null);
|
|
10
|
+
|
|
11
|
+
const Root = forwardRef<RootRef, RootProps>(({ render, disabled = false, open: openProp, defaultOpen, onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
12
|
+
const nativeID = useId();
|
|
13
|
+
const [open = false, onOpenChange] = useControllableState({
|
|
14
|
+
prop: openProp,
|
|
15
|
+
defaultProp: defaultOpen,
|
|
16
|
+
onChange: onOpenChangeProp,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<CollapsibleContext.Provider
|
|
21
|
+
value={{
|
|
22
|
+
disabled,
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
nativeID,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<Component
|
|
29
|
+
ref={ref}
|
|
30
|
+
{...viewProps}
|
|
31
|
+
/>
|
|
32
|
+
</CollapsibleContext.Provider>
|
|
33
|
+
);
|
|
34
|
+
});
|
|
37
35
|
|
|
38
36
|
Root.displayName = "RootNativeCollapsible";
|
|
39
37
|
|
|
40
38
|
function useCollapsibleContext() {
|
|
41
|
-
const context =
|
|
39
|
+
const context = useContext(CollapsibleContext);
|
|
42
40
|
if (!context) {
|
|
43
41
|
throw new Error("Collapsible compound components cannot be rendered outside the Collapsible component");
|
|
44
42
|
}
|
|
45
43
|
return context;
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
const Trigger =
|
|
46
|
+
const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled: disabledProp = false, ...props }, ref) => {
|
|
49
47
|
const { disabled, open, onOpenChange, nativeID } = useCollapsibleContext();
|
|
50
48
|
|
|
51
|
-
function onPress(
|
|
49
|
+
function onPress(event: GestureResponderEvent) {
|
|
52
50
|
if (disabled || disabledProp) return;
|
|
53
51
|
onOpenChange(!open);
|
|
54
|
-
onPressProp?.(
|
|
52
|
+
onPressProp?.(event);
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
return (
|
|
@@ -73,7 +71,7 @@ const Trigger = React.forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressPr
|
|
|
73
71
|
|
|
74
72
|
Trigger.displayName = "TriggerNativeCollapsible";
|
|
75
73
|
|
|
76
|
-
const Content =
|
|
74
|
+
const Content = forwardRef<ContentRef, ContentProps>(({ keepMounted, ...props }, ref) => {
|
|
77
75
|
const { nativeID, open } = useCollapsibleContext();
|
|
78
76
|
|
|
79
77
|
if (!keepMounted) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// import * as Collapsible from "@radix-ui/react-collapsible";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { Pressable, View, type GestureResponderEvent } from "react-native";
|
|
4
4
|
|
|
5
5
|
// import { useAugmentedRef, useControllableState, useIsomorphicLayoutEffect } from "../hooks";
|
|
6
|
-
// import * as
|
|
6
|
+
// import * as Render from "../render";
|
|
7
7
|
|
|
8
8
|
// import type { ContentProps, ContentRef, RootContext, RootProps, RootRef, TriggerProps, TriggerRef } from "./types";
|
|
9
9
|
|
|
10
|
-
// const CollapsibleContext =
|
|
10
|
+
// const CollapsibleContext = createContext<RootContext | null>(null);
|
|
11
11
|
|
|
12
|
-
// const Root =
|
|
12
|
+
// const Root = forwardRef<RootRef, RootProps>(
|
|
13
13
|
// ({ render, disabled = false, open: openProp, defaultOpen, onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
14
14
|
// const [open = false, onOpenChange] = useControllableState({
|
|
15
15
|
// prop: openProp,
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
// Root.displayName = "RootWebCollapsible";
|
|
65
65
|
|
|
66
66
|
// function useCollapsibleContext() {
|
|
67
|
-
// const context =
|
|
67
|
+
// const context = useContext(CollapsibleContext);
|
|
68
68
|
// if (!context) {
|
|
69
69
|
// throw new Error("Collapsible compound components cannot be rendered outside the Collapsible component");
|
|
70
70
|
// }
|
|
71
71
|
// return context;
|
|
72
72
|
// }
|
|
73
73
|
|
|
74
|
-
// const Trigger =
|
|
74
|
+
// const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled: disabledProp = false, ...props }, ref) => {
|
|
75
75
|
// const { disabled, open, onOpenChange } = useCollapsibleContext();
|
|
76
76
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
77
77
|
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
// }
|
|
96
96
|
// }, [disabled]);
|
|
97
97
|
|
|
98
|
-
// function onPress(
|
|
99
|
-
// onPressProp?.(
|
|
98
|
+
// function onPress(event: GestureResponderEvent) {
|
|
99
|
+
// onPressProp?.(event);
|
|
100
100
|
// onOpenChange(!open);
|
|
101
101
|
// }
|
|
102
102
|
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
|
|
120
120
|
// Trigger.displayName = "TriggerWebCollapsible";
|
|
121
121
|
|
|
122
|
-
// const Content =
|
|
122
|
+
// const Content = forwardRef<ContentRef, ContentProps>(({ keepMounted, ...props }, ref) => {
|
|
123
123
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
124
124
|
// const { open } = useCollapsibleContext();
|
|
125
125
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useId, useState, useContext, useEffect } from "react";
|
|
2
2
|
import {
|
|
3
3
|
BackHandler,
|
|
4
4
|
Pressable,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import { useAugmentedRef, useControllableState, useRelativePosition, type LayoutPosition } from "../hooks";
|
|
14
14
|
import { Portal as RNPPortal } from "../portal";
|
|
15
|
-
import * as
|
|
15
|
+
import * as Render from "../render";
|
|
16
16
|
|
|
17
17
|
import type {
|
|
18
18
|
CheckboxItemProps,
|
|
@@ -58,13 +58,13 @@ interface RootContextInterface extends RootProps {
|
|
|
58
58
|
nativeID: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const RootContext =
|
|
61
|
+
const RootContext = createContext<RootContextInterface | null>(null);
|
|
62
62
|
|
|
63
|
-
const Root =
|
|
64
|
-
const nativeID =
|
|
65
|
-
const [pressPosition, setPressPosition] =
|
|
66
|
-
const [contentLayout, setContentLayout] =
|
|
67
|
-
const [open, setOpen] =
|
|
63
|
+
const Root = forwardRef<RootRef, RootProps>(({ relativeTo = "longPress", onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
64
|
+
const nativeID = useId();
|
|
65
|
+
const [pressPosition, setPressPosition] = useState<LayoutPosition | null>(null);
|
|
66
|
+
const [contentLayout, setContentLayout] = useState<LayoutRectangle | null>(null);
|
|
67
|
+
const [open, setOpen] = useState(false);
|
|
68
68
|
|
|
69
69
|
function onOpenChange(value: boolean) {
|
|
70
70
|
setOpen(value);
|
|
@@ -95,7 +95,7 @@ const Root = React.forwardRef<RootRef, RootProps>(({ relativeTo = "longPress", o
|
|
|
95
95
|
Root.displayName = "RootNativeContextMenu";
|
|
96
96
|
|
|
97
97
|
function useRootContext() {
|
|
98
|
-
const context =
|
|
98
|
+
const context = useContext(RootContext);
|
|
99
99
|
if (!context) {
|
|
100
100
|
throw new Error("ContextMenu compound components cannot be rendered outside the ContextMenu component");
|
|
101
101
|
}
|
|
@@ -104,7 +104,7 @@ function useRootContext() {
|
|
|
104
104
|
|
|
105
105
|
const accessibilityActions = [{ name: "longpress" }];
|
|
106
106
|
|
|
107
|
-
const Trigger =
|
|
107
|
+
const Trigger = forwardRef<TriggerRef, TriggerProps>(
|
|
108
108
|
({ render, onLongPress: onLongPressProp, disabled = false, onAccessibilityAction: onAccessibilityActionProp, ...props }, ref) => {
|
|
109
109
|
const { open, onOpenChange, relativeTo, setPressPosition } = useRootContext();
|
|
110
110
|
const augmentedRef = useAugmentedRef({
|
|
@@ -123,13 +123,13 @@ const Trigger = React.forwardRef<TriggerRef, TriggerProps>(
|
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
function onLongPress(
|
|
126
|
+
function onLongPress(event: GestureResponderEvent) {
|
|
127
127
|
if (disabled) return;
|
|
128
128
|
if (relativeTo === "longPress") {
|
|
129
129
|
setPressPosition({
|
|
130
130
|
width: 0,
|
|
131
|
-
pageX:
|
|
132
|
-
pageY:
|
|
131
|
+
pageX: event.nativeEvent.pageX,
|
|
132
|
+
pageY: event.nativeEvent.pageY,
|
|
133
133
|
height: 0,
|
|
134
134
|
});
|
|
135
135
|
}
|
|
@@ -139,7 +139,7 @@ const Trigger = React.forwardRef<TriggerRef, TriggerProps>(
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
onOpenChange(!open);
|
|
142
|
-
onLongPressProp?.(
|
|
142
|
+
onLongPressProp?.(event);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
function onAccessibilityAction(event: AccessibilityActionEvent) {
|
|
@@ -201,16 +201,16 @@ function Portal({ keepMounted, hostName, children }: PortalProps) {
|
|
|
201
201
|
);
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
const Backdrop =
|
|
204
|
+
const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ keepMounted, onPress: onPressProp, closeOnPress = true, ...props }, ref) => {
|
|
205
205
|
const { open, onOpenChange, setContentLayout, setPressPosition } = useRootContext();
|
|
206
206
|
|
|
207
|
-
function onPress(
|
|
207
|
+
function onPress(event: GestureResponderEvent) {
|
|
208
208
|
if (closeOnPress) {
|
|
209
209
|
setPressPosition(null);
|
|
210
210
|
setContentLayout(null);
|
|
211
211
|
onOpenChange(false);
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
onPressProp?.(event);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
if (!keepMounted) {
|
|
@@ -230,7 +230,7 @@ const Backdrop = React.forwardRef<BackdropRef, BackdropProps>(({ keepMounted, on
|
|
|
230
230
|
|
|
231
231
|
Backdrop.displayName = "BackdropNativeContextMenu";
|
|
232
232
|
|
|
233
|
-
const Content =
|
|
233
|
+
const Content = forwardRef<ContentRef, ContentProps>(
|
|
234
234
|
(
|
|
235
235
|
{
|
|
236
236
|
render = false,
|
|
@@ -250,7 +250,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
250
250
|
) => {
|
|
251
251
|
const { open, onOpenChange, contentLayout, nativeID, pressPosition, setContentLayout, setPressPosition } = useRootContext();
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
useEffect(() => {
|
|
254
254
|
const backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
255
255
|
setPressPosition(null);
|
|
256
256
|
setContentLayout(null);
|
|
@@ -304,16 +304,16 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
304
304
|
|
|
305
305
|
Content.displayName = "ContentNativeContextMenu";
|
|
306
306
|
|
|
307
|
-
const Item =
|
|
307
|
+
const Item = forwardRef<ItemRef, ItemProps>(({ textValue, onPress: onPressProp, disabled = false, closeOnPress = true, ...props }, ref) => {
|
|
308
308
|
const { onOpenChange, setContentLayout, setPressPosition } = useRootContext();
|
|
309
309
|
|
|
310
|
-
function onPress(
|
|
310
|
+
function onPress(event: GestureResponderEvent) {
|
|
311
311
|
if (closeOnPress) {
|
|
312
312
|
setPressPosition(null);
|
|
313
313
|
setContentLayout(null);
|
|
314
314
|
onOpenChange(false);
|
|
315
315
|
}
|
|
316
|
-
onPressProp?.(
|
|
316
|
+
onPressProp?.(event);
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
return (
|
|
@@ -332,7 +332,7 @@ const Item = React.forwardRef<ItemRef, ItemProps>(({ textValue, onPress: onPress
|
|
|
332
332
|
|
|
333
333
|
Item.displayName = "ItemNativeContextMenu";
|
|
334
334
|
|
|
335
|
-
const Group =
|
|
335
|
+
const Group = forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
336
336
|
return (
|
|
337
337
|
<Component
|
|
338
338
|
ref={ref}
|
|
@@ -344,7 +344,7 @@ const Group = React.forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
|
344
344
|
|
|
345
345
|
Group.displayName = "GroupNativeContextMenu";
|
|
346
346
|
|
|
347
|
-
const Label =
|
|
347
|
+
const Label = forwardRef<LabelRef, LabelProps>(({ ...props }, ref) => {
|
|
348
348
|
return (
|
|
349
349
|
<Component
|
|
350
350
|
ref={ref}
|
|
@@ -362,20 +362,20 @@ type FormItemContext =
|
|
|
362
362
|
onValueChange: (value: string) => void;
|
|
363
363
|
};
|
|
364
364
|
|
|
365
|
-
const FormItemContext =
|
|
365
|
+
const FormItemContext = createContext<FormItemContext | null>(null);
|
|
366
366
|
|
|
367
|
-
const CheckboxItem =
|
|
367
|
+
const CheckboxItem = forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
368
368
|
({ render, checked, onCheckedChange, textValue, onPress: onPressProp, closeOnPress = true, disabled = false, ...props }, ref) => {
|
|
369
369
|
const { onOpenChange, setContentLayout, setPressPosition } = useRootContext();
|
|
370
370
|
|
|
371
|
-
function onPress(
|
|
371
|
+
function onPress(event: GestureResponderEvent) {
|
|
372
372
|
onCheckedChange(!checked);
|
|
373
373
|
if (closeOnPress) {
|
|
374
374
|
setPressPosition(null);
|
|
375
375
|
setContentLayout(null);
|
|
376
376
|
onOpenChange(false);
|
|
377
377
|
}
|
|
378
|
-
onPressProp?.(
|
|
378
|
+
onPressProp?.(event);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
return (
|
|
@@ -399,14 +399,14 @@ const CheckboxItem = React.forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
|
399
399
|
CheckboxItem.displayName = "CheckboxItemNativeContextMenu";
|
|
400
400
|
|
|
401
401
|
function useFormItemContext() {
|
|
402
|
-
const context =
|
|
402
|
+
const context = useContext(FormItemContext);
|
|
403
403
|
if (!context) {
|
|
404
404
|
throw new Error("CheckboxItem or RadioItem compound components cannot be rendered outside of a CheckboxItem or RadioItem component");
|
|
405
405
|
}
|
|
406
406
|
return context;
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
-
const RadioGroup =
|
|
409
|
+
const RadioGroup = forwardRef<RadioGroupRef, RadioGroupProps>(({ value, onValueChange, ...props }, ref) => {
|
|
410
410
|
return (
|
|
411
411
|
<FormItemContext.Provider value={{ value, onValueChange }}>
|
|
412
412
|
<Component
|
|
@@ -424,21 +424,21 @@ type BothFormItemContext = Exclude<FormItemContext, { checked: boolean }> & {
|
|
|
424
424
|
checked: boolean;
|
|
425
425
|
};
|
|
426
426
|
|
|
427
|
-
const RadioItemContext =
|
|
427
|
+
const RadioItemContext = createContext({} as { itemValue: string });
|
|
428
428
|
|
|
429
|
-
const RadioItem =
|
|
429
|
+
const RadioItem = forwardRef<RadioItemRef, RadioItemProps>(
|
|
430
430
|
({ render, value: itemValue, textValue, onPress: onPressProp, disabled = false, closeOnPress = true, ...props }, ref) => {
|
|
431
431
|
const { onOpenChange, setContentLayout, setPressPosition } = useRootContext();
|
|
432
432
|
|
|
433
433
|
const { value, onValueChange } = useFormItemContext() as BothFormItemContext;
|
|
434
|
-
function onPress(
|
|
434
|
+
function onPress(event: GestureResponderEvent) {
|
|
435
435
|
onValueChange(itemValue);
|
|
436
436
|
if (closeOnPress) {
|
|
437
437
|
setPressPosition(null);
|
|
438
438
|
setContentLayout(null);
|
|
439
439
|
onOpenChange(false);
|
|
440
440
|
}
|
|
441
|
-
onPressProp?.(
|
|
441
|
+
onPressProp?.(event);
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
return (
|
|
@@ -464,10 +464,10 @@ const RadioItem = React.forwardRef<RadioItemRef, RadioItemProps>(
|
|
|
464
464
|
RadioItem.displayName = "RadioItemNativeContextMenu";
|
|
465
465
|
|
|
466
466
|
function useItemIndicatorContext() {
|
|
467
|
-
return
|
|
467
|
+
return useContext(RadioItemContext);
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
const ItemIndicator =
|
|
470
|
+
const ItemIndicator = forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
471
471
|
const { itemValue } = useItemIndicatorContext();
|
|
472
472
|
const { checked, value } = useFormItemContext() as BothFormItemContext;
|
|
473
473
|
|
|
@@ -491,7 +491,7 @@ const ItemIndicator = React.forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({
|
|
|
491
491
|
|
|
492
492
|
ItemIndicator.displayName = "ItemIndicatorNativeContextMenu";
|
|
493
493
|
|
|
494
|
-
const Separator =
|
|
494
|
+
const Separator = forwardRef<SeparatorRef, SeparatorProps>(({ decorative, ...props }, ref) => {
|
|
495
495
|
return (
|
|
496
496
|
<Component
|
|
497
497
|
role={decorative ? "presentation" : "separator"}
|
|
@@ -503,14 +503,14 @@ const Separator = React.forwardRef<SeparatorRef, SeparatorProps>(({ decorative,
|
|
|
503
503
|
|
|
504
504
|
Separator.displayName = "SeparatorNativeContextMenu";
|
|
505
505
|
|
|
506
|
-
const SubContext =
|
|
506
|
+
const SubContext = createContext<{
|
|
507
507
|
nativeID: string;
|
|
508
508
|
open: boolean;
|
|
509
509
|
onOpenChange: (value: boolean) => void;
|
|
510
510
|
} | null>(null);
|
|
511
511
|
|
|
512
|
-
const Sub =
|
|
513
|
-
const nativeID =
|
|
512
|
+
const Sub = forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, onOpenChange: onOpenChangeProp, ...props }, ref) => {
|
|
513
|
+
const nativeID = useId();
|
|
514
514
|
const [open = false, onOpenChange] = useControllableState({
|
|
515
515
|
prop: openProp,
|
|
516
516
|
defaultProp: defaultOpen,
|
|
@@ -536,19 +536,19 @@ const Sub = React.forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, o
|
|
|
536
536
|
Sub.displayName = "SubNativeContextMenu";
|
|
537
537
|
|
|
538
538
|
function useSubContext() {
|
|
539
|
-
const context =
|
|
539
|
+
const context = useContext(SubContext);
|
|
540
540
|
if (!context) {
|
|
541
541
|
throw new Error("Sub compound components cannot be rendered outside of a Sub component");
|
|
542
542
|
}
|
|
543
543
|
return context;
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
const SubTrigger =
|
|
546
|
+
const SubTrigger = forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue, onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
547
547
|
const { nativeID, open, onOpenChange } = useSubContext();
|
|
548
548
|
|
|
549
|
-
function onPress(
|
|
549
|
+
function onPress(event: GestureResponderEvent) {
|
|
550
550
|
onOpenChange(!open);
|
|
551
|
-
onPressProp?.(
|
|
551
|
+
onPressProp?.(event);
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
return (
|
|
@@ -569,7 +569,7 @@ const SubTrigger = React.forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue
|
|
|
569
569
|
|
|
570
570
|
SubTrigger.displayName = "SubTriggerNativeContextMenu";
|
|
571
571
|
|
|
572
|
-
const SubContent =
|
|
572
|
+
const SubContent = forwardRef<SubContentRef, SubContentProps>(({ render = false, keepMounted, ...props }, ref) => {
|
|
573
573
|
const { open, nativeID } = useSubContext();
|
|
574
574
|
|
|
575
575
|
if (!keepMounted) {
|