@tamagui/context-menu 2.0.0-rc.4 → 2.0.0-rc.40
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/cjs/ContextMenu.cjs +142 -139
- package/dist/cjs/ContextMenu.native.js +172 -170
- package/dist/cjs/ContextMenu.native.js.map +1 -1
- package/dist/cjs/createNonNativeContextMenu.cjs +367 -328
- package/dist/cjs/createNonNativeContextMenu.native.js +388 -344
- package/dist/cjs/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/cjs/index.cjs +15 -13
- package/dist/cjs/index.native.js +26 -24
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/ContextMenu.mjs +114 -113
- package/dist/esm/ContextMenu.mjs.map +1 -1
- package/dist/esm/ContextMenu.native.js +141 -141
- package/dist/esm/ContextMenu.native.js.map +1 -1
- package/dist/esm/createNonNativeContextMenu.mjs +338 -301
- package/dist/esm/createNonNativeContextMenu.mjs.map +1 -1
- package/dist/esm/createNonNativeContextMenu.native.js +359 -317
- package/dist/esm/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/esm/index.js +2 -5
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +0 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/ContextMenu.mjs +114 -113
- package/dist/jsx/ContextMenu.mjs.map +1 -1
- package/dist/jsx/ContextMenu.native.js +172 -170
- package/dist/jsx/ContextMenu.native.js.map +1 -1
- package/dist/jsx/createNonNativeContextMenu.mjs +338 -301
- package/dist/jsx/createNonNativeContextMenu.mjs.map +1 -1
- package/dist/jsx/createNonNativeContextMenu.native.js +388 -344
- package/dist/jsx/createNonNativeContextMenu.native.js.map +1 -1
- package/dist/jsx/index.js +2 -5
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.mjs +0 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +26 -24
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +11 -12
- package/src/createNonNativeContextMenu.tsx +34 -9
- package/types/ContextMenu.d.ts +68 -32
- package/types/ContextMenu.d.ts.map +1 -1
- package/types/createNonNativeContextMenu.d.ts +79 -22
- package/types/createNonNativeContextMenu.d.ts.map +1 -1
- package/types/index.d.ts +68 -32
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/ContextMenu.js +0 -145
- package/dist/cjs/ContextMenu.js.map +0 -6
- package/dist/cjs/createNonNativeContextMenu.js +0 -331
- package/dist/cjs/createNonNativeContextMenu.js.map +0 -6
- package/dist/cjs/index.js +0 -32
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/ContextMenu.js +0 -127
- package/dist/esm/ContextMenu.js.map +0 -6
- package/dist/esm/createNonNativeContextMenu.js +0 -320
- package/dist/esm/createNonNativeContextMenu.js.map +0 -6
- package/dist/jsx/ContextMenu.js +0 -127
- package/dist/jsx/ContextMenu.js.map +0 -6
- package/dist/jsx/createNonNativeContextMenu.js +0 -320
- package/dist/jsx/createNonNativeContextMenu.js.map +0 -6
|
@@ -6,341 +6,378 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
const CONTEXTMENU_CONTEXT = "ContextMenuContext";
|
|
7
7
|
function createNonNativeContextMenu(params) {
|
|
8
8
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
9
|
+
Menu
|
|
10
|
+
} = createBaseMenu(params);
|
|
11
|
+
const CONTEXT_MENU_NAME = "ContextMenu";
|
|
12
|
+
const {
|
|
13
|
+
Provider: ContextMenuProvider,
|
|
14
|
+
useStyledContext: useContextMenuContext
|
|
15
|
+
} = createStyledContext();
|
|
16
|
+
const ContextMenuComp = props => {
|
|
17
|
+
const {
|
|
18
|
+
scope,
|
|
19
|
+
children,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
dir,
|
|
22
|
+
modal = true,
|
|
23
|
+
...rest
|
|
24
|
+
} = props;
|
|
25
|
+
const [open, setOpen] = React.useState(false);
|
|
26
|
+
const triggerRef = React.useRef(null);
|
|
27
|
+
const handleOpenChange = React.useCallback((open2, event) => {
|
|
28
|
+
onOpenChange?.(open2, event);
|
|
29
|
+
if (event?.defaultPrevented) return;
|
|
30
|
+
setOpen(open2);
|
|
31
|
+
}, [onOpenChange]);
|
|
32
|
+
return /* @__PURE__ */jsx(ContextMenuProvider, {
|
|
33
|
+
scope,
|
|
34
|
+
triggerId: useId(),
|
|
35
|
+
triggerRef,
|
|
36
|
+
contentId: useId(),
|
|
37
|
+
open,
|
|
38
|
+
onOpenChange: handleOpenChange,
|
|
39
|
+
modal,
|
|
40
|
+
children: /* @__PURE__ */jsx(Menu, {
|
|
41
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
42
|
+
dir,
|
|
35
43
|
open,
|
|
36
44
|
onOpenChange: handleOpenChange,
|
|
37
45
|
modal,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
modal,
|
|
44
|
-
...rest,
|
|
45
|
-
children
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
};
|
|
46
|
+
...rest,
|
|
47
|
+
children
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
};
|
|
49
51
|
ContextMenuComp.displayName = CONTEXT_MENU_NAME;
|
|
50
|
-
const TRIGGER_NAME = "ContextMenuTrigger"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
width: 0,
|
|
80
|
-
height: 0,
|
|
81
|
-
top: 0,
|
|
82
|
-
left: 0,
|
|
83
|
-
...pointRef.current
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
...(!isWeb && {
|
|
87
|
-
measure: c => c(pointRef.current.x, pointRef.current.y, 0, 0),
|
|
88
|
-
measureInWindow: c => c(pointRef.current.x, pointRef.current.y, 0, 0)
|
|
89
|
-
})
|
|
52
|
+
const TRIGGER_NAME = "ContextMenuTrigger";
|
|
53
|
+
const ContextMenuTrigger = View.styleable((props, forwardedRef) => {
|
|
54
|
+
const {
|
|
55
|
+
scope,
|
|
56
|
+
style,
|
|
57
|
+
disabled = false,
|
|
58
|
+
asChild,
|
|
59
|
+
children,
|
|
60
|
+
...triggerProps
|
|
61
|
+
} = props;
|
|
62
|
+
const context = useContextMenuContext(scope);
|
|
63
|
+
const pointRef = React.useRef({
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0
|
|
66
|
+
});
|
|
67
|
+
const virtualRef = React.useMemo(() => ({
|
|
68
|
+
current: {
|
|
69
|
+
getBoundingClientRect: () => {
|
|
70
|
+
if (isWeb) {
|
|
71
|
+
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
72
|
+
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
73
|
+
return DOMRect.fromRect({
|
|
74
|
+
width: 0,
|
|
75
|
+
height: 0,
|
|
76
|
+
x: pointRef.current.x - scrollX,
|
|
77
|
+
y: pointRef.current.y - scrollY
|
|
78
|
+
});
|
|
90
79
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
80
|
+
return {
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
top: 0,
|
|
84
|
+
left: 0,
|
|
85
|
+
...pointRef.current
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
...(!isWeb && {
|
|
89
|
+
measure: c => c(pointRef.current.x, pointRef.current.y, 0, 0),
|
|
90
|
+
measureInWindow: c => c(pointRef.current.x, pointRef.current.y, 0, 0)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
}), [pointRef.current.x, pointRef.current.y]);
|
|
94
|
+
const longPressTimerRef = React.useRef(0);
|
|
95
|
+
const clearLongPress = React.useCallback(() => window.clearTimeout(longPressTimerRef.current), []);
|
|
96
|
+
const createOpenChangeEvent = () => {
|
|
97
|
+
let defaultPrevented = false;
|
|
98
|
+
return {
|
|
99
|
+
get defaultPrevented() {
|
|
100
|
+
return defaultPrevented;
|
|
101
|
+
},
|
|
102
|
+
preventDefault() {
|
|
103
|
+
defaultPrevented = true;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const handleOpen = event => {
|
|
108
|
+
if (isWeb && (event instanceof MouseEvent || event instanceof PointerEvent)) {
|
|
109
|
+
pointRef.current = {
|
|
110
|
+
x: event.clientX,
|
|
111
|
+
y: event.clientY
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
pointRef.current = {
|
|
115
|
+
x: event.nativeEvent.pageX,
|
|
116
|
+
y: event.nativeEvent.pageY
|
|
102
117
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
}
|
|
119
|
+
const openChangeEvent = createOpenChangeEvent();
|
|
120
|
+
context.onOpenChange(true, openChangeEvent);
|
|
121
|
+
return openChangeEvent;
|
|
122
|
+
};
|
|
123
|
+
React.useEffect(() => clearLongPress, [clearLongPress]);
|
|
124
|
+
React.useEffect(() => void (disabled && clearLongPress()), [disabled, clearLongPress]);
|
|
125
|
+
const Comp = asChild ? Slot : View;
|
|
126
|
+
return /* @__PURE__ */jsxs(Fragment, {
|
|
127
|
+
children: [/* @__PURE__ */jsx(Menu.Anchor, {
|
|
128
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
129
|
+
virtualRef
|
|
130
|
+
}), /* @__PURE__ */jsx(Comp, {
|
|
131
|
+
render: "span",
|
|
132
|
+
componentName: TRIGGER_NAME,
|
|
133
|
+
id: context.triggerId,
|
|
134
|
+
"data-state": context.open ? "open" : "closed",
|
|
135
|
+
"data-disabled": disabled ? "" : void 0,
|
|
136
|
+
...triggerProps,
|
|
137
|
+
ref: composeRefs(forwardedRef, context.triggerRef),
|
|
138
|
+
style: isWeb ? {
|
|
139
|
+
WebkitTouchCallout: "none",
|
|
140
|
+
...style
|
|
141
|
+
} : null,
|
|
142
|
+
...(isWeb && {
|
|
143
|
+
onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, event => {
|
|
144
|
+
clearLongPress();
|
|
145
|
+
const openChangeEvent = handleOpen(event);
|
|
146
|
+
if (!openChangeEvent.defaultPrevented) {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, event => {
|
|
151
|
+
if (event.pointerType === "mouse") return;
|
|
152
|
+
clearLongPress();
|
|
153
|
+
longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700);
|
|
154
|
+
}),
|
|
155
|
+
onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, event => {
|
|
156
|
+
if (event.pointerType === "mouse") return;
|
|
157
|
+
clearLongPress();
|
|
139
158
|
}),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
})
|
|
159
|
+
onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
|
|
160
|
+
if (event.pointerType === "mouse") return;
|
|
161
|
+
clearLongPress();
|
|
144
162
|
}),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, event => {
|
|
164
|
+
if (event.pointerType === "mouse") return;
|
|
165
|
+
clearLongPress();
|
|
166
|
+
})
|
|
167
|
+
}),
|
|
168
|
+
...(!isWeb && {
|
|
169
|
+
onLongPress: disabled ? props.onLongPress : composeEventHandlers(props.onLongPress, event => {
|
|
170
|
+
clearLongPress();
|
|
171
|
+
const openChangeEvent = handleOpen(event);
|
|
172
|
+
if (!openChangeEvent.defaultPrevented) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}),
|
|
177
|
+
children
|
|
178
|
+
})]
|
|
148
179
|
});
|
|
180
|
+
});
|
|
149
181
|
ContextMenuTrigger.displayName = TRIGGER_NAME;
|
|
150
|
-
const PORTAL_NAME = "ContextMenuPortal"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
const PORTAL_NAME = "ContextMenuPortal";
|
|
183
|
+
const ContextMenuPortal = props => {
|
|
184
|
+
const {
|
|
185
|
+
scope,
|
|
186
|
+
children,
|
|
187
|
+
...portalProps
|
|
188
|
+
} = props;
|
|
189
|
+
const context = isAndroid ? useContextMenuContext(scope) : null;
|
|
190
|
+
const content = isAndroid ? /* @__PURE__ */jsx(ContextMenuProvider, {
|
|
191
|
+
...context,
|
|
192
|
+
children
|
|
193
|
+
}) : children;
|
|
194
|
+
return /* @__PURE__ */jsx(Menu.Portal, {
|
|
195
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
196
|
+
...portalProps,
|
|
197
|
+
children: content
|
|
198
|
+
});
|
|
199
|
+
};
|
|
168
200
|
ContextMenuPortal.displayName = PORTAL_NAME;
|
|
169
|
-
const CONTENT_NAME = "ContextMenuContent"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
201
|
+
const CONTENT_NAME = "ContextMenuContent";
|
|
202
|
+
const ContextMenuContent = React.forwardRef((props, forwardedRef) => {
|
|
203
|
+
const {
|
|
204
|
+
scope,
|
|
205
|
+
...contentProps
|
|
206
|
+
} = props;
|
|
207
|
+
const context = useContextMenuContext(scope);
|
|
208
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
209
|
+
return /* @__PURE__ */jsx(Menu.Content, {
|
|
210
|
+
id: context.contentId,
|
|
211
|
+
"aria-labelledby": context.triggerId,
|
|
212
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
213
|
+
...contentProps,
|
|
214
|
+
ref: forwardedRef,
|
|
215
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, event => {
|
|
216
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
217
|
+
hasInteractedOutsideRef.current = false;
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
}),
|
|
220
|
+
onInteractOutside: composeEventHandlers(props.onInteractOutside, event => {
|
|
221
|
+
const originalEvent = event.detail.originalEvent;
|
|
222
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
223
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
224
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
225
|
+
})
|
|
193
226
|
});
|
|
227
|
+
});
|
|
194
228
|
ContextMenuContent.displayName = CONTENT_NAME;
|
|
195
|
-
const ITEM_NAME = "ContextMenuItem"
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
229
|
+
const ITEM_NAME = "ContextMenuItem";
|
|
230
|
+
const ContextMenuItem = React.forwardRef((props, forwardedRef) => {
|
|
231
|
+
const {
|
|
232
|
+
scope,
|
|
233
|
+
...itemProps
|
|
234
|
+
} = props;
|
|
235
|
+
return /* @__PURE__ */jsx(Menu.Item, {
|
|
236
|
+
componentName: ITEM_NAME,
|
|
237
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
238
|
+
...itemProps,
|
|
239
|
+
ref: forwardedRef
|
|
207
240
|
});
|
|
241
|
+
});
|
|
208
242
|
ContextMenuItem.displayName = ITEM_NAME;
|
|
209
|
-
const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
243
|
+
const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem";
|
|
244
|
+
const ContextMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
|
|
245
|
+
const {
|
|
246
|
+
scope,
|
|
247
|
+
...checkboxItemProps
|
|
248
|
+
} = props;
|
|
249
|
+
return /* @__PURE__ */jsx(Menu.CheckboxItem, {
|
|
250
|
+
componentName: CHECKBOX_ITEM_NAME,
|
|
251
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
252
|
+
...checkboxItemProps,
|
|
253
|
+
ref: forwardedRef
|
|
221
254
|
});
|
|
255
|
+
});
|
|
222
256
|
ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
223
|
-
const RADIO_GROUP_NAME = "ContextMenuRadioGroup"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
257
|
+
const RADIO_GROUP_NAME = "ContextMenuRadioGroup";
|
|
258
|
+
const ContextMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
|
|
259
|
+
const {
|
|
260
|
+
scope,
|
|
261
|
+
...radioGroupProps
|
|
262
|
+
} = props;
|
|
263
|
+
return /* @__PURE__ */jsx(Menu.RadioGroup, {
|
|
264
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
265
|
+
...radioGroupProps,
|
|
266
|
+
ref: forwardedRef
|
|
234
267
|
});
|
|
268
|
+
});
|
|
235
269
|
ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
236
|
-
const RADIO_ITEM_NAME = "ContextMenuRadioItem"
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});
|
|
270
|
+
const RADIO_ITEM_NAME = "ContextMenuRadioItem";
|
|
271
|
+
const ContextMenuRadioItem = React.forwardRef((props, forwardedRef) => {
|
|
272
|
+
const {
|
|
273
|
+
scope,
|
|
274
|
+
...radioItemProps
|
|
275
|
+
} = props;
|
|
276
|
+
return /* @__PURE__ */jsx(Menu.RadioItem, {
|
|
277
|
+
componentName: RADIO_ITEM_NAME,
|
|
278
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
279
|
+
...radioItemProps,
|
|
280
|
+
ref: forwardedRef
|
|
248
281
|
});
|
|
282
|
+
});
|
|
249
283
|
ContextMenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
250
|
-
const INDICATOR_NAME = "ContextMenuItemIndicator"
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
284
|
+
const INDICATOR_NAME = "ContextMenuItemIndicator";
|
|
285
|
+
const ContextMenuItemIndicator = Menu.ItemIndicator.styleable((props, forwardedRef) => {
|
|
286
|
+
const {
|
|
287
|
+
scope,
|
|
288
|
+
...itemIndicatorProps
|
|
289
|
+
} = props;
|
|
290
|
+
return /* @__PURE__ */jsx(Menu.ItemIndicator, {
|
|
291
|
+
componentName: INDICATOR_NAME,
|
|
292
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
293
|
+
...itemIndicatorProps,
|
|
294
|
+
ref: forwardedRef
|
|
262
295
|
});
|
|
296
|
+
});
|
|
263
297
|
ContextMenuItemIndicator.displayName = INDICATOR_NAME;
|
|
264
|
-
const SUB_NAME = "ContextMenuSub"
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
298
|
+
const SUB_NAME = "ContextMenuSub";
|
|
299
|
+
const ContextMenuSub = props => {
|
|
300
|
+
const {
|
|
301
|
+
scope,
|
|
302
|
+
children,
|
|
303
|
+
onOpenChange,
|
|
304
|
+
open: openProp,
|
|
305
|
+
defaultOpen,
|
|
306
|
+
...rest
|
|
307
|
+
} = props;
|
|
308
|
+
const [open, setOpen] = useControllableState({
|
|
309
|
+
prop: openProp,
|
|
310
|
+
defaultProp: defaultOpen,
|
|
311
|
+
onChange: onOpenChange
|
|
312
|
+
});
|
|
313
|
+
return /* @__PURE__ */jsx(Menu.Sub, {
|
|
314
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
315
|
+
open,
|
|
316
|
+
onOpenChange: setOpen,
|
|
317
|
+
...rest,
|
|
318
|
+
children
|
|
319
|
+
});
|
|
320
|
+
};
|
|
287
321
|
ContextMenuSub.displayName = SUB_NAME;
|
|
288
|
-
const SUB_TRIGGER_NAME = "ContextMenuSubTrigger"
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
});
|
|
322
|
+
const SUB_TRIGGER_NAME = "ContextMenuSubTrigger";
|
|
323
|
+
const ContextMenuSubTrigger = View.styleable((props, forwardedRef) => {
|
|
324
|
+
const {
|
|
325
|
+
scope,
|
|
326
|
+
...subTriggerProps
|
|
327
|
+
} = props;
|
|
328
|
+
return /* @__PURE__ */jsx(Menu.SubTrigger, {
|
|
329
|
+
componentName: SUB_TRIGGER_NAME,
|
|
330
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
331
|
+
...subTriggerProps,
|
|
332
|
+
ref: forwardedRef
|
|
300
333
|
});
|
|
334
|
+
});
|
|
301
335
|
ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
302
|
-
const SUB_CONTENT_NAME = "ContextMenuSubContent"
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
336
|
+
const SUB_CONTENT_NAME = "ContextMenuSubContent";
|
|
337
|
+
const ContextMenuSubContent = React.forwardRef((props, forwardedRef) => {
|
|
338
|
+
const {
|
|
339
|
+
scope,
|
|
340
|
+
...subContentProps
|
|
341
|
+
} = props;
|
|
342
|
+
return /* @__PURE__ */jsx(Menu.SubContent, {
|
|
343
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
344
|
+
...subContentProps,
|
|
345
|
+
ref: forwardedRef,
|
|
346
|
+
style: isWeb ? {
|
|
347
|
+
...props.style,
|
|
348
|
+
...{
|
|
314
349
|
"--tamagui-context-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
|
|
315
350
|
"--tamagui-context-menu-content-available-width": "var(--tamagui-popper-available-width)",
|
|
316
351
|
"--tamagui-context-menu-content-available-height": "var(--tamagui-popper-available-height)",
|
|
317
352
|
"--tamagui-context-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
|
|
318
353
|
"--tamagui-context-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
|
|
319
|
-
}
|
|
320
|
-
}
|
|
354
|
+
}
|
|
355
|
+
} : null
|
|
321
356
|
});
|
|
357
|
+
});
|
|
322
358
|
ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
323
|
-
const ARROW_NAME = "ContextMenuArrow"
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
});
|
|
359
|
+
const ARROW_NAME = "ContextMenuArrow";
|
|
360
|
+
const ContextMenuArrow = React.forwardRef((props, forwardedRef) => {
|
|
361
|
+
const {
|
|
362
|
+
scope,
|
|
363
|
+
...arrowProps
|
|
364
|
+
} = props;
|
|
365
|
+
return /* @__PURE__ */jsx(Menu.Arrow, {
|
|
366
|
+
componentName: ARROW_NAME,
|
|
367
|
+
scope: scope || CONTEXTMENU_CONTEXT,
|
|
368
|
+
...arrowProps,
|
|
369
|
+
ref: forwardedRef
|
|
335
370
|
});
|
|
371
|
+
});
|
|
336
372
|
ContextMenuArrow.displayName = ARROW_NAME;
|
|
337
|
-
const ContextMenuGroup = Menu.Group
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
373
|
+
const ContextMenuGroup = Menu.Group;
|
|
374
|
+
const ContextMenuLabel = Menu.Label;
|
|
375
|
+
const ContextMenuSeparator = Menu.Separator;
|
|
376
|
+
const ContextMenuItemTitle = Menu.ItemTitle;
|
|
377
|
+
const ContextMenuItemSubTitle = Menu.ItemSubtitle;
|
|
378
|
+
const ContextMenuItemImage = Menu.ItemImage;
|
|
379
|
+
const ContextMenuItemIcon = Menu.ItemIcon;
|
|
380
|
+
const ContextMenuPreview = () => null;
|
|
344
381
|
return withStaticProperties(ContextMenuComp, {
|
|
345
382
|
Root: ContextMenuComp,
|
|
346
383
|
Trigger: ContextMenuTrigger,
|
|
@@ -362,7 +399,7 @@ function createNonNativeContextMenu(params) {
|
|
|
362
399
|
ItemSubtitle: ContextMenuItemSubTitle,
|
|
363
400
|
ItemIcon: ContextMenuItemIcon,
|
|
364
401
|
ItemImage: ContextMenuItemImage,
|
|
365
|
-
Preview:
|
|
402
|
+
Preview: ContextMenuPreview
|
|
366
403
|
});
|
|
367
404
|
}
|
|
368
405
|
export { CONTEXTMENU_CONTEXT, createNonNativeContextMenu };
|