@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.
Files changed (59) hide show
  1. package/dist/cjs/ContextMenu.cjs +142 -139
  2. package/dist/cjs/ContextMenu.native.js +172 -170
  3. package/dist/cjs/ContextMenu.native.js.map +1 -1
  4. package/dist/cjs/createNonNativeContextMenu.cjs +367 -328
  5. package/dist/cjs/createNonNativeContextMenu.native.js +388 -344
  6. package/dist/cjs/createNonNativeContextMenu.native.js.map +1 -1
  7. package/dist/cjs/index.cjs +15 -13
  8. package/dist/cjs/index.native.js +26 -24
  9. package/dist/cjs/index.native.js.map +1 -1
  10. package/dist/esm/ContextMenu.mjs +114 -113
  11. package/dist/esm/ContextMenu.mjs.map +1 -1
  12. package/dist/esm/ContextMenu.native.js +141 -141
  13. package/dist/esm/ContextMenu.native.js.map +1 -1
  14. package/dist/esm/createNonNativeContextMenu.mjs +338 -301
  15. package/dist/esm/createNonNativeContextMenu.mjs.map +1 -1
  16. package/dist/esm/createNonNativeContextMenu.native.js +359 -317
  17. package/dist/esm/createNonNativeContextMenu.native.js.map +1 -1
  18. package/dist/esm/index.js +2 -5
  19. package/dist/esm/index.js.map +1 -6
  20. package/dist/esm/index.mjs +0 -1
  21. package/dist/esm/index.mjs.map +1 -1
  22. package/dist/esm/index.native.js +0 -1
  23. package/dist/esm/index.native.js.map +1 -1
  24. package/dist/jsx/ContextMenu.mjs +114 -113
  25. package/dist/jsx/ContextMenu.mjs.map +1 -1
  26. package/dist/jsx/ContextMenu.native.js +172 -170
  27. package/dist/jsx/ContextMenu.native.js.map +1 -1
  28. package/dist/jsx/createNonNativeContextMenu.mjs +338 -301
  29. package/dist/jsx/createNonNativeContextMenu.mjs.map +1 -1
  30. package/dist/jsx/createNonNativeContextMenu.native.js +388 -344
  31. package/dist/jsx/createNonNativeContextMenu.native.js.map +1 -1
  32. package/dist/jsx/index.js +2 -5
  33. package/dist/jsx/index.js.map +1 -6
  34. package/dist/jsx/index.mjs +0 -1
  35. package/dist/jsx/index.mjs.map +1 -1
  36. package/dist/jsx/index.native.js +26 -24
  37. package/dist/jsx/index.native.js.map +1 -1
  38. package/package.json +11 -12
  39. package/src/createNonNativeContextMenu.tsx +34 -9
  40. package/types/ContextMenu.d.ts +68 -32
  41. package/types/ContextMenu.d.ts.map +1 -1
  42. package/types/createNonNativeContextMenu.d.ts +79 -22
  43. package/types/createNonNativeContextMenu.d.ts.map +1 -1
  44. package/types/index.d.ts +68 -32
  45. package/types/index.d.ts.map +1 -1
  46. package/dist/cjs/ContextMenu.js +0 -145
  47. package/dist/cjs/ContextMenu.js.map +0 -6
  48. package/dist/cjs/createNonNativeContextMenu.js +0 -331
  49. package/dist/cjs/createNonNativeContextMenu.js.map +0 -6
  50. package/dist/cjs/index.js +0 -32
  51. package/dist/cjs/index.js.map +0 -6
  52. package/dist/esm/ContextMenu.js +0 -127
  53. package/dist/esm/ContextMenu.js.map +0 -6
  54. package/dist/esm/createNonNativeContextMenu.js +0 -320
  55. package/dist/esm/createNonNativeContextMenu.js.map +0 -6
  56. package/dist/jsx/ContextMenu.js +0 -127
  57. package/dist/jsx/ContextMenu.js.map +0 -6
  58. package/dist/jsx/createNonNativeContextMenu.js +0 -320
  59. 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
- Menu
10
- } = createBaseMenu(params),
11
- CONTEXT_MENU_NAME = "ContextMenu",
12
- {
13
- Provider: ContextMenuProvider,
14
- useStyledContext: useContextMenuContext
15
- } = createStyledContext(),
16
- ContextMenuComp = props => {
17
- const {
18
- scope,
19
- children,
20
- onOpenChange,
21
- dir,
22
- modal = !0,
23
- ...rest
24
- } = props,
25
- [open, setOpen] = React.useState(!1),
26
- triggerRef = React.useRef(null),
27
- handleOpenChange = React.useCallback(open2 => {
28
- setOpen(open2), onOpenChange?.(open2);
29
- }, [onOpenChange]);
30
- return /* @__PURE__ */jsx(ContextMenuProvider, {
31
- scope,
32
- triggerId: useId(),
33
- triggerRef,
34
- contentId: useId(),
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
- children: /* @__PURE__ */jsx(Menu, {
39
- scope: scope || CONTEXTMENU_CONTEXT,
40
- dir,
41
- open,
42
- onOpenChange: handleOpenChange,
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
- ContextMenuTrigger = View.styleable((props, forwardedRef) => {
52
- const {
53
- scope,
54
- style,
55
- disabled = !1,
56
- asChild,
57
- children,
58
- ...triggerProps
59
- } = props,
60
- context = useContextMenuContext(scope),
61
- pointRef = React.useRef({
62
- x: 0,
63
- y: 0
64
- }),
65
- virtualRef = React.useMemo(() => ({
66
- current: {
67
- getBoundingClientRect: () => {
68
- if (isWeb) {
69
- const scrollX = window.scrollX || document.documentElement.scrollLeft,
70
- scrollY = window.scrollY || document.documentElement.scrollTop;
71
- return DOMRect.fromRect({
72
- width: 0,
73
- height: 0,
74
- x: pointRef.current.x - scrollX,
75
- y: pointRef.current.y - scrollY
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
- }), [pointRef.current.x, pointRef.current.y]),
92
- longPressTimerRef = React.useRef(0),
93
- clearLongPress = React.useCallback(() => window.clearTimeout(longPressTimerRef.current), []),
94
- handleOpen = event => {
95
- isWeb && (event instanceof MouseEvent || event instanceof PointerEvent) ? pointRef.current = {
96
- x: event.clientX,
97
- y: event.clientY
98
- } : pointRef.current = {
99
- x: event.nativeEvent.pageX,
100
- y: event.nativeEvent.pageY
101
- }, context.onOpenChange(!0);
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
- React.useEffect(() => clearLongPress, [clearLongPress]), React.useEffect(() => {
104
- disabled && clearLongPress();
105
- }, [disabled, clearLongPress]);
106
- const Comp = asChild ? Slot : View;
107
- return /* @__PURE__ */jsxs(Fragment, {
108
- children: [/* @__PURE__ */jsx(Menu.Anchor, {
109
- scope: scope || CONTEXTMENU_CONTEXT,
110
- virtualRef
111
- }), /* @__PURE__ */jsx(Comp, {
112
- render: "span",
113
- componentName: TRIGGER_NAME,
114
- id: context.triggerId,
115
- "data-state": context.open ? "open" : "closed",
116
- "data-disabled": disabled ? "" : void 0,
117
- ...triggerProps,
118
- ref: composeRefs(forwardedRef, context.triggerRef),
119
- style: isWeb ? {
120
- WebkitTouchCallout: "none",
121
- ...style
122
- } : null,
123
- ...(isWeb && {
124
- onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, event => {
125
- clearLongPress(), handleOpen(event), event.preventDefault();
126
- }),
127
- onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, event => {
128
- event.pointerType !== "mouse" && (clearLongPress(), longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700));
129
- }),
130
- onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, event => {
131
- event.pointerType !== "mouse" && clearLongPress();
132
- }),
133
- onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
134
- event.pointerType !== "mouse" && clearLongPress();
135
- }),
136
- onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, event => {
137
- event.pointerType !== "mouse" && clearLongPress();
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
- ...(!isWeb && {
141
- onLongPress: disabled ? props.onLongPress : composeEventHandlers(props.onLongPress, event => {
142
- clearLongPress(), handleOpen(event), event.preventDefault();
143
- })
159
+ onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
160
+ if (event.pointerType === "mouse") return;
161
+ clearLongPress();
144
162
  }),
145
- children
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
- ContextMenuPortal = props => {
152
- const {
153
- scope,
154
- children,
155
- ...portalProps
156
- } = props,
157
- context = isAndroid ? useContextMenuContext(scope) : null,
158
- content = isAndroid ? /* @__PURE__ */jsx(ContextMenuProvider, {
159
- ...context,
160
- children
161
- }) : children;
162
- return /* @__PURE__ */jsx(Menu.Portal, {
163
- scope: scope || CONTEXTMENU_CONTEXT,
164
- ...portalProps,
165
- children: content
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
- ContextMenuContent = React.forwardRef((props, forwardedRef) => {
171
- const {
172
- scope,
173
- ...contentProps
174
- } = props,
175
- context = useContextMenuContext(scope),
176
- hasInteractedOutsideRef = React.useRef(!1);
177
- return /* @__PURE__ */jsx(Menu.Content, {
178
- id: context.contentId,
179
- "aria-labelledby": context.triggerId,
180
- scope: scope || CONTEXTMENU_CONTEXT,
181
- ...contentProps,
182
- ref: forwardedRef,
183
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, event => {
184
- hasInteractedOutsideRef.current || context.triggerRef.current?.focus(), hasInteractedOutsideRef.current = !1, event.preventDefault();
185
- }),
186
- onInteractOutside: composeEventHandlers(props.onInteractOutside, event => {
187
- const originalEvent = event.detail.originalEvent,
188
- ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0,
189
- isRightClick = originalEvent.button === 2 || ctrlLeftClick;
190
- (!context.modal || isRightClick) && (hasInteractedOutsideRef.current = !0);
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
- ContextMenuItem = React.forwardRef((props, forwardedRef) => {
197
- const {
198
- scope,
199
- ...itemProps
200
- } = props;
201
- return /* @__PURE__ */jsx(Menu.Item, {
202
- componentName: ITEM_NAME,
203
- scope: scope || CONTEXTMENU_CONTEXT,
204
- ...itemProps,
205
- ref: forwardedRef
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
- ContextMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
211
- const {
212
- scope,
213
- ...checkboxItemProps
214
- } = props;
215
- return /* @__PURE__ */jsx(Menu.CheckboxItem, {
216
- componentName: CHECKBOX_ITEM_NAME,
217
- scope: scope || CONTEXTMENU_CONTEXT,
218
- ...checkboxItemProps,
219
- ref: forwardedRef
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
- ContextMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
225
- const {
226
- scope,
227
- ...radioGroupProps
228
- } = props;
229
- return /* @__PURE__ */jsx(Menu.RadioGroup, {
230
- scope: scope || CONTEXTMENU_CONTEXT,
231
- ...radioGroupProps,
232
- ref: forwardedRef
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
- ContextMenuRadioItem = React.forwardRef((props, forwardedRef) => {
238
- const {
239
- scope,
240
- ...radioItemProps
241
- } = props;
242
- return /* @__PURE__ */jsx(Menu.RadioItem, {
243
- componentName: RADIO_ITEM_NAME,
244
- scope: scope || CONTEXTMENU_CONTEXT,
245
- ...radioItemProps,
246
- ref: forwardedRef
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
- ContextMenuItemIndicator = Menu.ItemIndicator.styleable((props, forwardedRef) => {
252
- const {
253
- scope,
254
- ...itemIndicatorProps
255
- } = props;
256
- return /* @__PURE__ */jsx(Menu.ItemIndicator, {
257
- componentName: INDICATOR_NAME,
258
- scope: scope || CONTEXTMENU_CONTEXT,
259
- ...itemIndicatorProps,
260
- ref: forwardedRef
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
- ContextMenuSub = props => {
266
- const {
267
- scope,
268
- children,
269
- onOpenChange,
270
- open: openProp,
271
- defaultOpen,
272
- ...rest
273
- } = props,
274
- [open, setOpen] = useControllableState({
275
- prop: openProp,
276
- defaultProp: defaultOpen,
277
- onChange: onOpenChange
278
- });
279
- return /* @__PURE__ */jsx(Menu.Sub, {
280
- scope: scope || CONTEXTMENU_CONTEXT,
281
- open,
282
- onOpenChange: setOpen,
283
- ...rest,
284
- children
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
- ContextMenuSubTrigger = View.styleable((props, forwardedRef) => {
290
- const {
291
- scope,
292
- ...subTriggerProps
293
- } = props;
294
- return /* @__PURE__ */jsx(Menu.SubTrigger, {
295
- componentName: SUB_TRIGGER_NAME,
296
- scope: scope || CONTEXTMENU_CONTEXT,
297
- ...subTriggerProps,
298
- ref: forwardedRef
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
- ContextMenuSubContent = React.forwardRef((props, forwardedRef) => {
304
- const {
305
- scope,
306
- ...subContentProps
307
- } = props;
308
- return /* @__PURE__ */jsx(Menu.SubContent, {
309
- scope: scope || CONTEXTMENU_CONTEXT,
310
- ...subContentProps,
311
- ref: forwardedRef,
312
- style: isWeb ? {
313
- ...props.style,
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
- } : null
320
- });
354
+ }
355
+ } : null
321
356
  });
357
+ });
322
358
  ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
323
- const ARROW_NAME = "ContextMenuArrow",
324
- ContextMenuArrow = React.forwardRef((props, forwardedRef) => {
325
- const {
326
- scope,
327
- ...arrowProps
328
- } = props;
329
- return /* @__PURE__ */jsx(Menu.Arrow, {
330
- componentName: ARROW_NAME,
331
- scope: scope || CONTEXTMENU_CONTEXT,
332
- ...arrowProps,
333
- ref: forwardedRef
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
- ContextMenuLabel = Menu.Label,
339
- ContextMenuSeparator = Menu.Separator,
340
- ContextMenuItemTitle = Menu.ItemTitle,
341
- ContextMenuItemSubTitle = Menu.ItemSubtitle,
342
- ContextMenuItemImage = Menu.ItemImage,
343
- ContextMenuItemIcon = Menu.ItemIcon;
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: () => null
402
+ Preview: ContextMenuPreview
366
403
  });
367
404
  }
368
405
  export { CONTEXTMENU_CONTEXT, createNonNativeContextMenu };