@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
@@ -4,401 +4,445 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
18
  get: () => from[key],
18
19
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
20
  });
20
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
34
36
  var createNonNativeContextMenu_exports = {};
35
37
  __export(createNonNativeContextMenu_exports, {
36
38
  CONTEXTMENU_CONTEXT: () => CONTEXTMENU_CONTEXT,
37
39
  createNonNativeContextMenu: () => createNonNativeContextMenu
38
40
  });
39
41
  module.exports = __toCommonJS(createNonNativeContextMenu_exports);
40
- var import_jsx_runtime = require("react/jsx-runtime"),
41
- import_create_menu = require("@tamagui/create-menu"),
42
- import_use_controllable_state = require("@tamagui/use-controllable-state"),
43
- import_web = require("@tamagui/web"),
44
- import_react = __toESM(require("react"));
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var import_create_menu = require("@tamagui/create-menu");
44
+ var import_use_controllable_state = require("@tamagui/use-controllable-state");
45
+ var import_web = require("@tamagui/web");
46
+ var import_react = __toESM(require("react"), 1);
45
47
  function _instanceof(left, right) {
46
- return right != null && typeof Symbol < "u" && right[Symbol.hasInstance] ? !!right[Symbol.hasInstance](left) : left instanceof right;
48
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
49
+ return !!right[Symbol.hasInstance](left);
50
+ } else {
51
+ return left instanceof right;
52
+ }
47
53
  }
48
54
  var CONTEXTMENU_CONTEXT = "ContextMenuContext";
49
55
  function createNonNativeContextMenu(params) {
50
56
  var {
51
- Menu
52
- } = (0, import_create_menu.createBaseMenu)(params),
53
- CONTEXT_MENU_NAME = "ContextMenu",
54
- {
55
- Provider: ContextMenuProvider,
56
- useStyledContext: useContextMenuContext
57
- } = (0, import_web.createStyledContext)(),
58
- ContextMenuComp = function (props) {
59
- var {
60
- scope,
61
- children,
62
- onOpenChange,
63
- dir,
64
- modal = !0,
65
- ...rest
66
- } = props,
67
- [open, setOpen] = import_react.default.useState(!1),
68
- triggerRef = import_react.default.useRef(null),
69
- handleOpenChange = import_react.default.useCallback(function (open2) {
70
- setOpen(open2), onOpenChange?.(open2);
71
- }, [onOpenChange]);
72
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContextMenuProvider, {
73
- scope,
74
- triggerId: (0, import_react.useId)(),
75
- triggerRef,
76
- contentId: (0, import_react.useId)(),
57
+ Menu
58
+ } = (0, import_create_menu.createBaseMenu)(params);
59
+ var CONTEXT_MENU_NAME = "ContextMenu";
60
+ var {
61
+ Provider: ContextMenuProvider,
62
+ useStyledContext: useContextMenuContext
63
+ } = (0, import_web.createStyledContext)();
64
+ var ContextMenuComp = function (props) {
65
+ var {
66
+ scope,
67
+ children,
68
+ onOpenChange,
69
+ dir,
70
+ modal = true,
71
+ ...rest
72
+ } = props;
73
+ var [open, setOpen] = import_react.default.useState(false);
74
+ var triggerRef = import_react.default.useRef(null);
75
+ var handleOpenChange = import_react.default.useCallback(function (open2, event) {
76
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(open2, event);
77
+ if (event === null || event === void 0 ? void 0 : event.defaultPrevented) return;
78
+ setOpen(open2);
79
+ }, [onOpenChange]);
80
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContextMenuProvider, {
81
+ scope,
82
+ triggerId: (0, import_react.useId)(),
83
+ triggerRef,
84
+ contentId: (0, import_react.useId)(),
85
+ open,
86
+ onOpenChange: handleOpenChange,
87
+ modal,
88
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu, {
89
+ scope: scope || CONTEXTMENU_CONTEXT,
90
+ dir,
77
91
  open,
78
92
  onOpenChange: handleOpenChange,
79
93
  modal,
80
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu, {
81
- scope: scope || CONTEXTMENU_CONTEXT,
82
- dir,
83
- open,
84
- onOpenChange: handleOpenChange,
85
- modal,
86
- ...rest,
87
- children
88
- })
89
- });
90
- };
94
+ ...rest,
95
+ children
96
+ })
97
+ });
98
+ };
91
99
  ContextMenuComp.displayName = CONTEXT_MENU_NAME;
92
- var TRIGGER_NAME = "ContextMenuTrigger",
93
- ContextMenuTrigger = import_web.View.styleable(function (props, forwardedRef) {
94
- var {
95
- scope,
96
- style,
97
- disabled = !1,
98
- asChild,
99
- children,
100
- ...triggerProps
101
- } = props,
102
- context = useContextMenuContext(scope),
103
- pointRef = import_react.default.useRef({
104
- x: 0,
105
- y: 0
106
- }),
107
- virtualRef = import_react.default.useMemo(function () {
108
- return {
109
- current: {
110
- getBoundingClientRect: function () {
111
- if (import_web.isWeb) {
112
- var scrollX = window.scrollX || document.documentElement.scrollLeft,
113
- scrollY = window.scrollY || document.documentElement.scrollTop;
114
- return DOMRect.fromRect({
115
- width: 0,
116
- height: 0,
117
- x: pointRef.current.x - scrollX,
118
- y: pointRef.current.y - scrollY
119
- });
120
- }
121
- return {
122
- width: 0,
123
- height: 0,
124
- top: 0,
125
- left: 0,
126
- ...pointRef.current
127
- };
128
- },
129
- ...(!import_web.isWeb && {
130
- measure: function (c) {
131
- return c(pointRef.current.x, pointRef.current.y, 0, 0);
132
- },
133
- measureInWindow: function (c) {
134
- return c(pointRef.current.x, pointRef.current.y, 0, 0);
135
- }
136
- })
100
+ var TRIGGER_NAME = "ContextMenuTrigger";
101
+ var ContextMenuTrigger = import_web.View.styleable(function (props, forwardedRef) {
102
+ var {
103
+ scope,
104
+ style,
105
+ disabled = false,
106
+ asChild,
107
+ children,
108
+ ...triggerProps
109
+ } = props;
110
+ var context = useContextMenuContext(scope);
111
+ var pointRef = import_react.default.useRef({
112
+ x: 0,
113
+ y: 0
114
+ });
115
+ var virtualRef = import_react.default.useMemo(function () {
116
+ return {
117
+ current: {
118
+ getBoundingClientRect: function () {
119
+ if (import_web.isWeb) {
120
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
121
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
122
+ return DOMRect.fromRect({
123
+ width: 0,
124
+ height: 0,
125
+ x: pointRef.current.x - scrollX,
126
+ y: pointRef.current.y - scrollY
127
+ });
137
128
  }
138
- };
139
- }, [pointRef.current.x, pointRef.current.y]),
140
- longPressTimerRef = import_react.default.useRef(0),
141
- clearLongPress = import_react.default.useCallback(function () {
142
- return window.clearTimeout(longPressTimerRef.current);
143
- }, []),
144
- handleOpen = function (event) {
145
- import_web.isWeb && (_instanceof(event, MouseEvent) || _instanceof(event, PointerEvent)) ? pointRef.current = {
146
- x: event.clientX,
147
- y: event.clientY
148
- } : pointRef.current = {
149
- x: event.nativeEvent.pageX,
150
- y: event.nativeEvent.pageY
151
- }, context.onOpenChange(!0);
129
+ return {
130
+ width: 0,
131
+ height: 0,
132
+ top: 0,
133
+ left: 0,
134
+ ...pointRef.current
135
+ };
136
+ },
137
+ ...(!import_web.isWeb && {
138
+ measure: function (c) {
139
+ return c(pointRef.current.x, pointRef.current.y, 0, 0);
140
+ },
141
+ measureInWindow: function (c) {
142
+ return c(pointRef.current.x, pointRef.current.y, 0, 0);
143
+ }
144
+ })
145
+ }
146
+ };
147
+ }, [pointRef.current.x, pointRef.current.y]);
148
+ var longPressTimerRef = import_react.default.useRef(0);
149
+ var clearLongPress = import_react.default.useCallback(function () {
150
+ return window.clearTimeout(longPressTimerRef.current);
151
+ }, []);
152
+ var createOpenChangeEvent = function () {
153
+ var defaultPrevented = false;
154
+ return {
155
+ get defaultPrevented() {
156
+ return defaultPrevented;
157
+ },
158
+ preventDefault() {
159
+ defaultPrevented = true;
160
+ }
161
+ };
162
+ };
163
+ var handleOpen = function (event) {
164
+ if (import_web.isWeb && (_instanceof(event, MouseEvent) || _instanceof(event, PointerEvent))) {
165
+ pointRef.current = {
166
+ x: event.clientX,
167
+ y: event.clientY
168
+ };
169
+ } else {
170
+ pointRef.current = {
171
+ x: event.nativeEvent.pageX,
172
+ y: event.nativeEvent.pageY
152
173
  };
153
- import_react.default.useEffect(function () {
154
- return clearLongPress;
155
- }, [clearLongPress]), import_react.default.useEffect(function () {
156
- disabled && clearLongPress();
157
- }, [disabled, clearLongPress]);
158
- var Comp = asChild ? import_web.Slot : import_web.View;
159
- return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
160
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Anchor, {
161
- scope: scope || CONTEXTMENU_CONTEXT,
162
- virtualRef
163
- }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
164
- render: "span",
165
- componentName: TRIGGER_NAME,
166
- id: context.triggerId,
167
- "data-state": context.open ? "open" : "closed",
168
- "data-disabled": disabled ? "" : void 0,
169
- ...triggerProps,
170
- ref: (0, import_web.composeRefs)(forwardedRef, context.triggerRef),
171
- style: import_web.isWeb ? {
172
- WebkitTouchCallout: "none",
173
- ...style
174
- } : null,
175
- ...(import_web.isWeb && {
176
- onContextMenu: disabled ? props.onContextMenu : (0, import_web.composeEventHandlers)(props.onContextMenu, function (event) {
177
- clearLongPress(), handleOpen(event), event.preventDefault();
178
- }),
179
- onPointerDown: disabled ? props.onPointerDown : (0, import_web.composeEventHandlers)(props.onPointerDown, function (event) {
180
- event.pointerType !== "mouse" && (clearLongPress(), longPressTimerRef.current = window.setTimeout(function () {
181
- return handleOpen(event);
182
- }, 700));
183
- }),
184
- onPointerMove: disabled ? props.onPointerMove : (0, import_web.composeEventHandlers)(props.onPointerMove, function (event) {
185
- event.pointerType !== "mouse" && clearLongPress();
186
- }),
187
- onPointerCancel: disabled ? props.onPointerCancel : (0, import_web.composeEventHandlers)(props.onPointerCancel, function (event) {
188
- event.pointerType !== "mouse" && clearLongPress();
189
- }),
190
- onPointerUp: disabled ? props.onPointerUp : (0, import_web.composeEventHandlers)(props.onPointerUp, function (event) {
191
- event.pointerType !== "mouse" && clearLongPress();
192
- })
174
+ }
175
+ var openChangeEvent = createOpenChangeEvent();
176
+ context.onOpenChange(true, openChangeEvent);
177
+ return openChangeEvent;
178
+ };
179
+ import_react.default.useEffect(function () {
180
+ return clearLongPress;
181
+ }, [clearLongPress]);
182
+ import_react.default.useEffect(function () {
183
+ return void (disabled && clearLongPress());
184
+ }, [disabled, clearLongPress]);
185
+ var Comp = asChild ? import_web.Slot : import_web.View;
186
+ return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
187
+ children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Anchor, {
188
+ scope: scope || CONTEXTMENU_CONTEXT,
189
+ virtualRef
190
+ }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
191
+ render: "span",
192
+ componentName: TRIGGER_NAME,
193
+ id: context.triggerId,
194
+ "data-state": context.open ? "open" : "closed",
195
+ "data-disabled": disabled ? "" : void 0,
196
+ ...triggerProps,
197
+ ref: (0, import_web.composeRefs)(forwardedRef, context.triggerRef),
198
+ style: import_web.isWeb ? {
199
+ WebkitTouchCallout: "none",
200
+ ...style
201
+ } : null,
202
+ ...(import_web.isWeb && {
203
+ onContextMenu: disabled ? props.onContextMenu : (0, import_web.composeEventHandlers)(props.onContextMenu, function (event) {
204
+ clearLongPress();
205
+ var openChangeEvent = handleOpen(event);
206
+ if (!openChangeEvent.defaultPrevented) {
207
+ event.preventDefault();
208
+ }
193
209
  }),
194
- ...(!import_web.isWeb && {
195
- onLongPress: disabled ? props.onLongPress : (0, import_web.composeEventHandlers)(props.onLongPress, function (event) {
196
- clearLongPress(), handleOpen(event), event.preventDefault();
197
- })
210
+ onPointerDown: disabled ? props.onPointerDown : (0, import_web.composeEventHandlers)(props.onPointerDown, function (event) {
211
+ if (event.pointerType === "mouse") return;
212
+ clearLongPress();
213
+ longPressTimerRef.current = window.setTimeout(function () {
214
+ return handleOpen(event);
215
+ }, 700);
216
+ }),
217
+ onPointerMove: disabled ? props.onPointerMove : (0, import_web.composeEventHandlers)(props.onPointerMove, function (event) {
218
+ if (event.pointerType === "mouse") return;
219
+ clearLongPress();
198
220
  }),
199
- children
200
- })]
201
- });
221
+ onPointerCancel: disabled ? props.onPointerCancel : (0, import_web.composeEventHandlers)(props.onPointerCancel, function (event) {
222
+ if (event.pointerType === "mouse") return;
223
+ clearLongPress();
224
+ }),
225
+ onPointerUp: disabled ? props.onPointerUp : (0, import_web.composeEventHandlers)(props.onPointerUp, function (event) {
226
+ if (event.pointerType === "mouse") return;
227
+ clearLongPress();
228
+ })
229
+ }),
230
+ ...(!import_web.isWeb && {
231
+ onLongPress: disabled ? props.onLongPress : (0, import_web.composeEventHandlers)(props.onLongPress, function (event) {
232
+ clearLongPress();
233
+ var openChangeEvent = handleOpen(event);
234
+ if (!openChangeEvent.defaultPrevented) {
235
+ event.preventDefault();
236
+ }
237
+ })
238
+ }),
239
+ children
240
+ })]
202
241
  });
242
+ });
203
243
  ContextMenuTrigger.displayName = TRIGGER_NAME;
204
- var PORTAL_NAME = "ContextMenuPortal",
205
- ContextMenuPortal = function (props) {
206
- var {
207
- scope,
208
- children,
209
- ...portalProps
210
- } = props,
211
- context = import_web.isAndroid ? useContextMenuContext(scope) : null,
212
- content = import_web.isAndroid ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContextMenuProvider, {
213
- ...context,
214
- children
215
- }) : children;
216
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Portal, {
217
- scope: scope || CONTEXTMENU_CONTEXT,
218
- ...portalProps,
219
- children: content
220
- });
221
- };
244
+ var PORTAL_NAME = "ContextMenuPortal";
245
+ var ContextMenuPortal = function (props) {
246
+ var {
247
+ scope,
248
+ children,
249
+ ...portalProps
250
+ } = props;
251
+ var context = import_web.isAndroid ? useContextMenuContext(scope) : null;
252
+ var content = import_web.isAndroid ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContextMenuProvider, {
253
+ ...context,
254
+ children
255
+ }) : children;
256
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Portal, {
257
+ scope: scope || CONTEXTMENU_CONTEXT,
258
+ ...portalProps,
259
+ children: content
260
+ });
261
+ };
222
262
  ContextMenuPortal.displayName = PORTAL_NAME;
223
- var CONTENT_NAME = "ContextMenuContent",
224
- ContextMenuContent = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
225
- var {
226
- scope,
227
- ...contentProps
228
- } = props,
229
- context = useContextMenuContext(scope),
230
- hasInteractedOutsideRef = import_react.default.useRef(!1);
231
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Content, {
232
- id: context.contentId,
233
- "aria-labelledby": context.triggerId,
234
- scope: scope || CONTEXTMENU_CONTEXT,
235
- ...contentProps,
236
- ref: forwardedRef,
237
- onCloseAutoFocus: (0, import_web.composeEventHandlers)(props.onCloseAutoFocus, function (event) {
238
- var _context_triggerRef_current;
239
- hasInteractedOutsideRef.current || (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 || _context_triggerRef_current.focus(), hasInteractedOutsideRef.current = !1, event.preventDefault();
240
- }),
241
- onInteractOutside: (0, import_web.composeEventHandlers)(props.onInteractOutside, function (event) {
242
- var originalEvent = event.detail.originalEvent,
243
- ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0,
244
- isRightClick = originalEvent.button === 2 || ctrlLeftClick;
245
- (!context.modal || isRightClick) && (hasInteractedOutsideRef.current = !0);
246
- })
247
- });
263
+ var CONTENT_NAME = "ContextMenuContent";
264
+ var ContextMenuContent = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
265
+ var {
266
+ scope,
267
+ ...contentProps
268
+ } = props;
269
+ var context = useContextMenuContext(scope);
270
+ var hasInteractedOutsideRef = import_react.default.useRef(false);
271
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Content, {
272
+ id: context.contentId,
273
+ "aria-labelledby": context.triggerId,
274
+ scope: scope || CONTEXTMENU_CONTEXT,
275
+ ...contentProps,
276
+ ref: forwardedRef,
277
+ onCloseAutoFocus: (0, import_web.composeEventHandlers)(props.onCloseAutoFocus, function (event) {
278
+ var _context_triggerRef_current;
279
+ if (!hasInteractedOutsideRef.current) (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 ? void 0 : _context_triggerRef_current.focus();
280
+ hasInteractedOutsideRef.current = false;
281
+ event.preventDefault();
282
+ }),
283
+ onInteractOutside: (0, import_web.composeEventHandlers)(props.onInteractOutside, function (event) {
284
+ var originalEvent = event.detail.originalEvent;
285
+ var ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
286
+ var isRightClick = originalEvent.button === 2 || ctrlLeftClick;
287
+ if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
288
+ })
248
289
  });
290
+ });
249
291
  ContextMenuContent.displayName = CONTENT_NAME;
250
- var ITEM_NAME = "ContextMenuItem",
251
- ContextMenuItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
252
- var {
253
- scope,
254
- ...itemProps
255
- } = props;
256
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Item, {
257
- componentName: ITEM_NAME,
258
- scope: scope || CONTEXTMENU_CONTEXT,
259
- ...itemProps,
260
- ref: forwardedRef
261
- });
292
+ var ITEM_NAME = "ContextMenuItem";
293
+ var ContextMenuItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
294
+ var {
295
+ scope,
296
+ ...itemProps
297
+ } = props;
298
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Item, {
299
+ componentName: ITEM_NAME,
300
+ scope: scope || CONTEXTMENU_CONTEXT,
301
+ ...itemProps,
302
+ ref: forwardedRef
262
303
  });
304
+ });
263
305
  ContextMenuItem.displayName = ITEM_NAME;
264
- var CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem",
265
- ContextMenuCheckboxItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
266
- var {
267
- scope,
268
- ...checkboxItemProps
269
- } = props;
270
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.CheckboxItem, {
271
- componentName: CHECKBOX_ITEM_NAME,
272
- scope: scope || CONTEXTMENU_CONTEXT,
273
- ...checkboxItemProps,
274
- ref: forwardedRef
275
- });
306
+ var CHECKBOX_ITEM_NAME = "ContextMenuCheckboxItem";
307
+ var ContextMenuCheckboxItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
308
+ var {
309
+ scope,
310
+ ...checkboxItemProps
311
+ } = props;
312
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.CheckboxItem, {
313
+ componentName: CHECKBOX_ITEM_NAME,
314
+ scope: scope || CONTEXTMENU_CONTEXT,
315
+ ...checkboxItemProps,
316
+ ref: forwardedRef
276
317
  });
318
+ });
277
319
  ContextMenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
278
- var RADIO_GROUP_NAME = "ContextMenuRadioGroup",
279
- ContextMenuRadioGroup = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
280
- var {
281
- scope,
282
- ...radioGroupProps
283
- } = props;
284
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.RadioGroup, {
285
- scope: scope || CONTEXTMENU_CONTEXT,
286
- ...radioGroupProps,
287
- ref: forwardedRef
288
- });
320
+ var RADIO_GROUP_NAME = "ContextMenuRadioGroup";
321
+ var ContextMenuRadioGroup = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
322
+ var {
323
+ scope,
324
+ ...radioGroupProps
325
+ } = props;
326
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.RadioGroup, {
327
+ scope: scope || CONTEXTMENU_CONTEXT,
328
+ ...radioGroupProps,
329
+ ref: forwardedRef
289
330
  });
331
+ });
290
332
  ContextMenuRadioGroup.displayName = RADIO_GROUP_NAME;
291
- var RADIO_ITEM_NAME = "ContextMenuRadioItem",
292
- ContextMenuRadioItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
293
- var {
294
- scope,
295
- ...radioItemProps
296
- } = props;
297
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.RadioItem, {
298
- componentName: RADIO_ITEM_NAME,
299
- scope: scope || CONTEXTMENU_CONTEXT,
300
- ...radioItemProps,
301
- ref: forwardedRef
302
- });
333
+ var RADIO_ITEM_NAME = "ContextMenuRadioItem";
334
+ var ContextMenuRadioItem = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
335
+ var {
336
+ scope,
337
+ ...radioItemProps
338
+ } = props;
339
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.RadioItem, {
340
+ componentName: RADIO_ITEM_NAME,
341
+ scope: scope || CONTEXTMENU_CONTEXT,
342
+ ...radioItemProps,
343
+ ref: forwardedRef
303
344
  });
345
+ });
304
346
  ContextMenuRadioItem.displayName = RADIO_ITEM_NAME;
305
- var INDICATOR_NAME = "ContextMenuItemIndicator",
306
- ContextMenuItemIndicator = Menu.ItemIndicator.styleable(function (props, forwardedRef) {
307
- var {
308
- scope,
309
- ...itemIndicatorProps
310
- } = props;
311
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.ItemIndicator, {
312
- componentName: INDICATOR_NAME,
313
- scope: scope || CONTEXTMENU_CONTEXT,
314
- ...itemIndicatorProps,
315
- ref: forwardedRef
316
- });
347
+ var INDICATOR_NAME = "ContextMenuItemIndicator";
348
+ var ContextMenuItemIndicator = Menu.ItemIndicator.styleable(function (props, forwardedRef) {
349
+ var {
350
+ scope,
351
+ ...itemIndicatorProps
352
+ } = props;
353
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.ItemIndicator, {
354
+ componentName: INDICATOR_NAME,
355
+ scope: scope || CONTEXTMENU_CONTEXT,
356
+ ...itemIndicatorProps,
357
+ ref: forwardedRef
317
358
  });
359
+ });
318
360
  ContextMenuItemIndicator.displayName = INDICATOR_NAME;
319
- var SUB_NAME = "ContextMenuSub",
320
- ContextMenuSub = function (props) {
321
- var {
322
- scope,
323
- children,
324
- onOpenChange,
325
- open: openProp,
326
- defaultOpen,
327
- ...rest
328
- } = props,
329
- [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
330
- prop: openProp,
331
- defaultProp: defaultOpen,
332
- onChange: onOpenChange
333
- });
334
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Sub, {
335
- scope: scope || CONTEXTMENU_CONTEXT,
336
- open,
337
- onOpenChange: setOpen,
338
- ...rest,
339
- children
340
- });
341
- };
361
+ var SUB_NAME = "ContextMenuSub";
362
+ var ContextMenuSub = function (props) {
363
+ var {
364
+ scope,
365
+ children,
366
+ onOpenChange,
367
+ open: openProp,
368
+ defaultOpen,
369
+ ...rest
370
+ } = props;
371
+ var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
372
+ prop: openProp,
373
+ defaultProp: defaultOpen,
374
+ onChange: onOpenChange
375
+ });
376
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Sub, {
377
+ scope: scope || CONTEXTMENU_CONTEXT,
378
+ open,
379
+ onOpenChange: setOpen,
380
+ ...rest,
381
+ children
382
+ });
383
+ };
342
384
  ContextMenuSub.displayName = SUB_NAME;
343
- var SUB_TRIGGER_NAME = "ContextMenuSubTrigger",
344
- ContextMenuSubTrigger = import_web.View.styleable(function (props, forwardedRef) {
345
- var {
346
- scope,
347
- ...subTriggerProps
348
- } = props;
349
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubTrigger, {
350
- componentName: SUB_TRIGGER_NAME,
351
- scope: scope || CONTEXTMENU_CONTEXT,
352
- ...subTriggerProps,
353
- ref: forwardedRef
354
- });
385
+ var SUB_TRIGGER_NAME = "ContextMenuSubTrigger";
386
+ var ContextMenuSubTrigger = import_web.View.styleable(function (props, forwardedRef) {
387
+ var {
388
+ scope,
389
+ ...subTriggerProps
390
+ } = props;
391
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubTrigger, {
392
+ componentName: SUB_TRIGGER_NAME,
393
+ scope: scope || CONTEXTMENU_CONTEXT,
394
+ ...subTriggerProps,
395
+ ref: forwardedRef
355
396
  });
397
+ });
356
398
  ContextMenuSubTrigger.displayName = SUB_TRIGGER_NAME;
357
- var SUB_CONTENT_NAME = "ContextMenuSubContent",
358
- ContextMenuSubContent = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
359
- var {
360
- scope,
361
- ...subContentProps
362
- } = props;
363
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubContent, {
364
- scope: scope || CONTEXTMENU_CONTEXT,
365
- ...subContentProps,
366
- ref: forwardedRef,
367
- style: import_web.isWeb ? {
368
- ...props.style,
399
+ var SUB_CONTENT_NAME = "ContextMenuSubContent";
400
+ var ContextMenuSubContent = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
401
+ var {
402
+ scope,
403
+ ...subContentProps
404
+ } = props;
405
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubContent, {
406
+ scope: scope || CONTEXTMENU_CONTEXT,
407
+ ...subContentProps,
408
+ ref: forwardedRef,
409
+ style: import_web.isWeb ? {
410
+ ...props.style,
411
+ ...{
369
412
  "--tamagui-context-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
370
413
  "--tamagui-context-menu-content-available-width": "var(--tamagui-popper-available-width)",
371
414
  "--tamagui-context-menu-content-available-height": "var(--tamagui-popper-available-height)",
372
415
  "--tamagui-context-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
373
416
  "--tamagui-context-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
374
- } : null
375
- });
417
+ }
418
+ } : null
376
419
  });
420
+ });
377
421
  ContextMenuSubContent.displayName = SUB_CONTENT_NAME;
378
- var ARROW_NAME = "ContextMenuArrow",
379
- ContextMenuArrow = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
380
- var {
381
- scope,
382
- ...arrowProps
383
- } = props;
384
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Arrow, {
385
- componentName: ARROW_NAME,
386
- scope: scope || CONTEXTMENU_CONTEXT,
387
- ...arrowProps,
388
- ref: forwardedRef
389
- });
422
+ var ARROW_NAME = "ContextMenuArrow";
423
+ var ContextMenuArrow = /* @__PURE__ */import_react.default.forwardRef(function (props, forwardedRef) {
424
+ var {
425
+ scope,
426
+ ...arrowProps
427
+ } = props;
428
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Arrow, {
429
+ componentName: ARROW_NAME,
430
+ scope: scope || CONTEXTMENU_CONTEXT,
431
+ ...arrowProps,
432
+ ref: forwardedRef
390
433
  });
434
+ });
391
435
  ContextMenuArrow.displayName = ARROW_NAME;
392
- var ContextMenuGroup = Menu.Group,
393
- ContextMenuLabel = Menu.Label,
394
- ContextMenuSeparator = Menu.Separator,
395
- ContextMenuItemTitle = Menu.ItemTitle,
396
- ContextMenuItemSubTitle = Menu.ItemSubtitle,
397
- ContextMenuItemImage = Menu.ItemImage,
398
- ContextMenuItemIcon = Menu.ItemIcon,
399
- ContextMenuPreview = function () {
400
- return null;
401
- };
436
+ var ContextMenuGroup = Menu.Group;
437
+ var ContextMenuLabel = Menu.Label;
438
+ var ContextMenuSeparator = Menu.Separator;
439
+ var ContextMenuItemTitle = Menu.ItemTitle;
440
+ var ContextMenuItemSubTitle = Menu.ItemSubtitle;
441
+ var ContextMenuItemImage = Menu.ItemImage;
442
+ var ContextMenuItemIcon = Menu.ItemIcon;
443
+ var ContextMenuPreview = function () {
444
+ return null;
445
+ };
402
446
  return (0, import_web.withStaticProperties)(ContextMenuComp, {
403
447
  Root: ContextMenuComp,
404
448
  Trigger: ContextMenuTrigger,