@hanzogui/context-menu 3.0.2 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) 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 +370 -344
  5. package/dist/cjs/createNonNativeContextMenu.native.js +391 -364
  6. package/dist/cjs/createNonNativeContextMenu.native.js.map +1 -1
  7. package/dist/cjs/index.cjs +24 -22
  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 +340 -316
  15. package/dist/esm/createNonNativeContextMenu.mjs.map +1 -1
  16. package/dist/esm/createNonNativeContextMenu.native.js +361 -336
  17. package/dist/esm/createNonNativeContextMenu.native.js.map +1 -1
  18. package/dist/jsx/ContextMenu.mjs +114 -113
  19. package/dist/jsx/ContextMenu.mjs.map +1 -1
  20. package/dist/jsx/ContextMenu.native.js +172 -170
  21. package/dist/jsx/ContextMenu.native.js.map +1 -1
  22. package/dist/jsx/createNonNativeContextMenu.mjs +340 -316
  23. package/dist/jsx/createNonNativeContextMenu.mjs.map +1 -1
  24. package/dist/jsx/createNonNativeContextMenu.native.js +391 -364
  25. package/dist/jsx/createNonNativeContextMenu.native.js.map +1 -1
  26. package/dist/jsx/index.native.js +26 -24
  27. package/dist/jsx/index.native.js.map +1 -1
  28. package/package.json +14 -12
  29. package/types/ContextMenu.d.ts +59 -59
  30. package/types/ContextMenu.d.ts.map +1 -0
  31. package/types/createNonNativeContextMenu.d.ts +53 -53
  32. package/types/createNonNativeContextMenu.d.ts.map +1 -0
  33. package/types/index.d.ts +59 -59
  34. package/types/index.d.ts.map +1 -0
@@ -6,354 +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, event) => {
28
- onOpenChange?.(open2, event), !event?.defaultPrevented && setOpen(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
- createOpenChangeEvent = () => {
95
- let defaultPrevented = !1;
96
80
  return {
97
- get defaultPrevented() {
98
- return defaultPrevented;
99
- },
100
- preventDefault() {
101
- defaultPrevented = !0;
102
- }
81
+ width: 0,
82
+ height: 0,
83
+ top: 0,
84
+ left: 0,
85
+ ...pointRef.current
103
86
  };
104
87
  },
105
- handleOpen = event => {
106
- isWeb && (event instanceof MouseEvent || event instanceof PointerEvent) ? pointRef.current = {
107
- x: event.clientX,
108
- y: event.clientY
109
- } : pointRef.current = {
110
- x: event.nativeEvent.pageX,
111
- y: event.nativeEvent.pageY
112
- };
113
- const openChangeEvent = createOpenChangeEvent();
114
- return context.onOpenChange(!0, openChangeEvent), openChangeEvent;
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
115
117
  };
116
- React.useEffect(() => clearLongPress, [clearLongPress]), React.useEffect(() => {
117
- disabled && clearLongPress();
118
- }, [disabled, clearLongPress]);
119
- const Comp = asChild ? Slot : View;
120
- return /* @__PURE__ */jsxs(Fragment, {
121
- children: [/* @__PURE__ */jsx(Menu.Anchor, {
122
- scope: scope || CONTEXTMENU_CONTEXT,
123
- virtualRef
124
- }), /* @__PURE__ */jsx(Comp, {
125
- render: "span",
126
- componentName: TRIGGER_NAME,
127
- id: context.triggerId,
128
- "data-state": context.open ? "open" : "closed",
129
- "data-disabled": disabled ? "" : void 0,
130
- ...triggerProps,
131
- ref: composeRefs(forwardedRef, context.triggerRef),
132
- style: isWeb ? {
133
- WebkitTouchCallout: "none",
134
- ...style
135
- } : null,
136
- ...(isWeb && {
137
- onContextMenu: disabled ? props.onContextMenu : composeEventHandlers(props.onContextMenu, event => {
138
- clearLongPress(), handleOpen(event).defaultPrevented || event.preventDefault();
139
- }),
140
- onPointerDown: disabled ? props.onPointerDown : composeEventHandlers(props.onPointerDown, event => {
141
- event.pointerType !== "mouse" && (clearLongPress(), longPressTimerRef.current = window.setTimeout(() => handleOpen(event), 700));
142
- }),
143
- onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, event => {
144
- event.pointerType !== "mouse" && clearLongPress();
145
- }),
146
- onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
147
- event.pointerType !== "mouse" && clearLongPress();
148
- }),
149
- onPointerUp: disabled ? props.onPointerUp : composeEventHandlers(props.onPointerUp, event => {
150
- event.pointerType !== "mouse" && clearLongPress();
151
- })
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
+ }
152
149
  }),
153
- ...(!isWeb && {
154
- onLongPress: disabled ? props.onLongPress : composeEventHandlers(props.onLongPress, event => {
155
- clearLongPress(), handleOpen(event).defaultPrevented || event.preventDefault();
156
- })
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);
157
154
  }),
158
- children
159
- })]
160
- });
155
+ onPointerMove: disabled ? props.onPointerMove : composeEventHandlers(props.onPointerMove, event => {
156
+ if (event.pointerType === "mouse") return;
157
+ clearLongPress();
158
+ }),
159
+ onPointerCancel: disabled ? props.onPointerCancel : composeEventHandlers(props.onPointerCancel, event => {
160
+ if (event.pointerType === "mouse") return;
161
+ clearLongPress();
162
+ }),
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
+ })]
161
179
  });
180
+ });
162
181
  ContextMenuTrigger.displayName = TRIGGER_NAME;
163
- const PORTAL_NAME = "ContextMenuPortal",
164
- ContextMenuPortal = props => {
165
- const {
166
- scope,
167
- children,
168
- ...portalProps
169
- } = props,
170
- context = isAndroid ? useContextMenuContext(scope) : null,
171
- content = isAndroid ? /* @__PURE__ */jsx(ContextMenuProvider, {
172
- ...context,
173
- children
174
- }) : children;
175
- return /* @__PURE__ */jsx(Menu.Portal, {
176
- scope: scope || CONTEXTMENU_CONTEXT,
177
- ...portalProps,
178
- children: content
179
- });
180
- };
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
+ };
181
200
  ContextMenuPortal.displayName = PORTAL_NAME;
182
- const CONTENT_NAME = "ContextMenuContent",
183
- ContextMenuContent = React.forwardRef((props, forwardedRef) => {
184
- const {
185
- scope,
186
- ...contentProps
187
- } = props,
188
- context = useContextMenuContext(scope),
189
- hasInteractedOutsideRef = React.useRef(!1);
190
- return /* @__PURE__ */jsx(Menu.Content, {
191
- id: context.contentId,
192
- "aria-labelledby": context.triggerId,
193
- scope: scope || CONTEXTMENU_CONTEXT,
194
- ...contentProps,
195
- ref: forwardedRef,
196
- onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, event => {
197
- hasInteractedOutsideRef.current || context.triggerRef.current?.focus(), hasInteractedOutsideRef.current = !1, event.preventDefault();
198
- }),
199
- onInteractOutside: composeEventHandlers(props.onInteractOutside, event => {
200
- const originalEvent = event.detail.originalEvent,
201
- ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0,
202
- isRightClick = originalEvent.button === 2 || ctrlLeftClick;
203
- (!context.modal || isRightClick) && (hasInteractedOutsideRef.current = !0);
204
- })
205
- });
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
+ })
206
226
  });
227
+ });
207
228
  ContextMenuContent.displayName = CONTENT_NAME;
208
- const ITEM_NAME = "ContextMenuItem",
209
- ContextMenuItem = React.forwardRef((props, forwardedRef) => {
210
- const {
211
- scope,
212
- ...itemProps
213
- } = props;
214
- return /* @__PURE__ */jsx(Menu.Item, {
215
- componentName: ITEM_NAME,
216
- scope: scope || CONTEXTMENU_CONTEXT,
217
- ...itemProps,
218
- ref: forwardedRef
219
- });
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
220
240
  });
241
+ });
221
242
  ContextMenuItem.displayName = ITEM_NAME;
222
- const CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem",
223
- ContextMenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
224
- const {
225
- scope,
226
- ...checkboxItemProps
227
- } = props;
228
- return /* @__PURE__ */jsx(Menu.CheckboxItem, {
229
- componentName: CHECKBOX_ITEM_NAME,
230
- scope: scope || CONTEXTMENU_CONTEXT,
231
- ...checkboxItemProps,
232
- ref: forwardedRef
233
- });
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
234
254
  });
255
+ });
235
256
  ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
236
- const RADIO_GROUP_NAME = "ContextMenuRadioGroup",
237
- ContextMenuRadioGroup = React.forwardRef((props, forwardedRef) => {
238
- const {
239
- scope,
240
- ...radioGroupProps
241
- } = props;
242
- return /* @__PURE__ */jsx(Menu.RadioGroup, {
243
- scope: scope || CONTEXTMENU_CONTEXT,
244
- ...radioGroupProps,
245
- ref: forwardedRef
246
- });
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
247
267
  });
268
+ });
248
269
  ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;
249
- const RADIO_ITEM_NAME = "ContextMenuRadioItem",
250
- ContextMenuRadioItem = React.forwardRef((props, forwardedRef) => {
251
- const {
252
- scope,
253
- ...radioItemProps
254
- } = props;
255
- return /* @__PURE__ */jsx(Menu.RadioItem, {
256
- componentName: RADIO_ITEM_NAME,
257
- scope: scope || CONTEXTMENU_CONTEXT,
258
- ...radioItemProps,
259
- ref: forwardedRef
260
- });
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
261
281
  });
282
+ });
262
283
  ContextMenuRadioItem.displayName = RADIO_ITEM_NAME;
263
- const INDICATOR_NAME = "ContextMenuItemIndicator",
264
- ContextMenuItemIndicator = Menu.ItemIndicator.styleable((props, forwardedRef) => {
265
- const {
266
- scope,
267
- ...itemIndicatorProps
268
- } = props;
269
- return /* @__PURE__ */jsx(Menu.ItemIndicator, {
270
- componentName: INDICATOR_NAME,
271
- scope: scope || CONTEXTMENU_CONTEXT,
272
- ...itemIndicatorProps,
273
- ref: forwardedRef
274
- });
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
275
295
  });
296
+ });
276
297
  ContextMenuItemIndicator.displayName = INDICATOR_NAME;
277
- const SUB_NAME = "ContextMenuSub",
278
- ContextMenuSub = props => {
279
- const {
280
- scope,
281
- children,
282
- onOpenChange,
283
- open: openProp,
284
- defaultOpen,
285
- ...rest
286
- } = props,
287
- [open, setOpen] = useControllableState({
288
- prop: openProp,
289
- defaultProp: defaultOpen,
290
- onChange: onOpenChange
291
- });
292
- return /* @__PURE__ */jsx(Menu.Sub, {
293
- scope: scope || CONTEXTMENU_CONTEXT,
294
- open,
295
- onOpenChange: setOpen,
296
- ...rest,
297
- children
298
- });
299
- };
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
+ };
300
321
  ContextMenuSub.displayName = SUB_NAME;
301
- const SUB_TRIGGER_NAME = "ContextMenuSubTrigger",
302
- ContextMenuSubTrigger = View.styleable((props, forwardedRef) => {
303
- const {
304
- scope,
305
- ...subTriggerProps
306
- } = props;
307
- return /* @__PURE__ */jsx(Menu.SubTrigger, {
308
- componentName: SUB_TRIGGER_NAME,
309
- scope: scope || CONTEXTMENU_CONTEXT,
310
- ...subTriggerProps,
311
- ref: forwardedRef
312
- });
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
313
333
  });
334
+ });
314
335
  ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
315
- const SUB_CONTENT_NAME = "ContextMenuSubContent",
316
- ContextMenuSubContent = React.forwardRef((props, forwardedRef) => {
317
- const {
318
- scope,
319
- ...subContentProps
320
- } = props;
321
- return /* @__PURE__ */jsx(Menu.SubContent, {
322
- scope: scope || CONTEXTMENU_CONTEXT,
323
- ...subContentProps,
324
- ref: forwardedRef,
325
- style: isWeb ? {
326
- ...props.style,
327
- "--tamagui-context-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
328
- "--tamagui-context-menu-content-available-width": "var(--tamagui-popper-available-width)",
329
- "--tamagui-context-menu-content-available-height": "var(--tamagui-popper-available-height)",
330
- "--tamagui-context-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
331
- "--tamagui-context-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
332
- } : null
333
- });
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
+ ...{
349
+ "--gui-context-menu-content-transform-origin": "var(--gui-popper-transform-origin)",
350
+ "--gui-context-menu-content-available-width": "var(--gui-popper-available-width)",
351
+ "--gui-context-menu-content-available-height": "var(--gui-popper-available-height)",
352
+ "--gui-context-menu-trigger-width": "var(--gui-popper-anchor-width)",
353
+ "--gui-context-menu-trigger-height": "var(--gui-popper-anchor-height)"
354
+ }
355
+ } : null
334
356
  });
357
+ });
335
358
  ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
336
- const ARROW_NAME = "ContextMenuArrow",
337
- ContextMenuArrow = React.forwardRef((props, forwardedRef) => {
338
- const {
339
- scope,
340
- ...arrowProps
341
- } = props;
342
- return /* @__PURE__ */jsx(Menu.Arrow, {
343
- componentName: ARROW_NAME,
344
- scope: scope || CONTEXTMENU_CONTEXT,
345
- ...arrowProps,
346
- ref: forwardedRef
347
- });
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
348
370
  });
371
+ });
349
372
  ContextMenuArrow.displayName = ARROW_NAME;
350
- const ContextMenuGroup = Menu.Group,
351
- ContextMenuLabel = Menu.Label,
352
- ContextMenuSeparator = Menu.Separator,
353
- ContextMenuItemTitle = Menu.ItemTitle,
354
- ContextMenuItemSubTitle = Menu.ItemSubtitle,
355
- ContextMenuItemImage = Menu.ItemImage,
356
- 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;
357
381
  return withStaticProperties(ContextMenuComp, {
358
382
  Root: ContextMenuComp,
359
383
  Trigger: ContextMenuTrigger,
@@ -375,7 +399,7 @@ function createNonNativeContextMenu(params) {
375
399
  ItemSubtitle: ContextMenuItemSubTitle,
376
400
  ItemIcon: ContextMenuItemIcon,
377
401
  ItemImage: ContextMenuItemImage,
378
- Preview: () => null
402
+ Preview: ContextMenuPreview
379
403
  });
380
404
  }
381
405
  export { CONTEXTMENU_CONTEXT, createNonNativeContextMenu };