@tamagui/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/Menu.cjs +156 -140
- package/dist/cjs/Menu.native.js +182 -164
- package/dist/cjs/Menu.native.js.map +1 -1
- package/dist/cjs/createNonNativeMenu.cjs +346 -330
- package/dist/cjs/createNonNativeMenu.native.js +359 -352
- package/dist/cjs/createNonNativeMenu.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/Menu.mjs +129 -115
- package/dist/esm/Menu.mjs.map +1 -1
- package/dist/esm/Menu.native.js +155 -139
- package/dist/esm/Menu.native.js.map +1 -1
- package/dist/esm/createNonNativeMenu.mjs +317 -303
- package/dist/esm/createNonNativeMenu.mjs.map +1 -1
- package/dist/esm/createNonNativeMenu.native.js +330 -325
- package/dist/esm/createNonNativeMenu.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/Menu.mjs +129 -115
- package/dist/jsx/Menu.mjs.map +1 -1
- package/dist/jsx/Menu.native.js +182 -164
- package/dist/jsx/Menu.native.js.map +1 -1
- package/dist/jsx/createNonNativeMenu.mjs +317 -303
- package/dist/jsx/createNonNativeMenu.mjs.map +1 -1
- package/dist/jsx/createNonNativeMenu.native.js +359 -352
- package/dist/jsx/createNonNativeMenu.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 +12 -14
- package/src/Menu.tsx +11 -3
- package/src/createNonNativeMenu.tsx +220 -290
- package/types/Menu.d.ts +81 -46
- package/types/Menu.d.ts.map +1 -1
- package/types/createNonNativeMenu.d.ts +116 -68
- package/types/createNonNativeMenu.d.ts.map +1 -1
- package/types/index.d.ts +81 -46
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/Menu.js +0 -137
- package/dist/cjs/Menu.js.map +0 -6
- package/dist/cjs/createNonNativeMenu.js +0 -334
- package/dist/cjs/createNonNativeMenu.js.map +0 -6
- package/dist/cjs/index.js +0 -32
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Menu.js +0 -119
- package/dist/esm/Menu.js.map +0 -6
- package/dist/esm/createNonNativeMenu.js +0 -325
- package/dist/esm/createNonNativeMenu.js.map +0 -6
- package/dist/jsx/Menu.js +0 -119
- package/dist/jsx/Menu.js.map +0 -6
- package/dist/jsx/createNonNativeMenu.js +0 -325
- package/dist/jsx/createNonNativeMenu.js.map +0 -6
|
@@ -2,378 +2,394 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var createNonNativeMenu_exports = {};
|
|
33
35
|
__export(createNonNativeMenu_exports, {
|
|
34
36
|
DROPDOWN_MENU_CONTEXT: () => DROPDOWN_MENU_CONTEXT,
|
|
35
37
|
createNonNativeMenu: () => createNonNativeMenu
|
|
36
38
|
});
|
|
37
39
|
module.exports = __toCommonJS(createNonNativeMenu_exports);
|
|
38
|
-
var import_create_menu = require("@tamagui/create-menu")
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
var import_create_menu = require("@tamagui/create-menu");
|
|
41
|
+
var import_popper = require("@tamagui/popper");
|
|
42
|
+
var import_scroll_view = require("@tamagui/scroll-view");
|
|
43
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
44
|
+
var import_web = require("@tamagui/web");
|
|
45
|
+
var React = __toESM(require("react"), 1);
|
|
46
|
+
var import_react = require("react");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
48
|
const DROPDOWN_MENU_CONTEXT = "MenuContext";
|
|
49
|
+
function useMenuTriggerSetup(open) {
|
|
50
|
+
const triggerStateSettersRef = React.useRef(/* @__PURE__ */new Map());
|
|
51
|
+
const activeTriggerIdRef = React.useRef(null);
|
|
52
|
+
const setActiveTrigger = (0, import_web.useEvent)(id => {
|
|
53
|
+
const prevId = activeTriggerIdRef.current;
|
|
54
|
+
if (prevId === id) return;
|
|
55
|
+
if (prevId) {
|
|
56
|
+
triggerStateSettersRef.current.get(prevId)?.(false);
|
|
57
|
+
}
|
|
58
|
+
activeTriggerIdRef.current = id;
|
|
59
|
+
if (id && open) {
|
|
60
|
+
triggerStateSettersRef.current.get(id)?.(true);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const registerTrigger = (0, import_web.useEvent)((id, setOpenState) => {
|
|
64
|
+
triggerStateSettersRef.current.set(id, setOpenState);
|
|
65
|
+
setOpenState(activeTriggerIdRef.current === id && open);
|
|
66
|
+
});
|
|
67
|
+
const unregisterTrigger = (0, import_web.useEvent)(id => {
|
|
68
|
+
triggerStateSettersRef.current.delete(id);
|
|
69
|
+
if (activeTriggerIdRef.current === id) {
|
|
70
|
+
activeTriggerIdRef.current = null;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
if (!open) {
|
|
75
|
+
setActiveTrigger(null);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const activeId = activeTriggerIdRef.current;
|
|
79
|
+
if (activeId) {
|
|
80
|
+
triggerStateSettersRef.current.get(activeId)?.(true);
|
|
81
|
+
}
|
|
82
|
+
}, [open, setActiveTrigger]);
|
|
83
|
+
return {
|
|
84
|
+
setActiveTrigger,
|
|
85
|
+
registerTrigger,
|
|
86
|
+
unregisterTrigger
|
|
87
|
+
};
|
|
88
|
+
}
|
|
45
89
|
function createNonNativeMenu(params) {
|
|
46
90
|
const {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
91
|
+
Menu
|
|
92
|
+
} = (0, import_create_menu.createBaseMenu)(params);
|
|
93
|
+
const DROPDOWN_MENU_NAME = "Menu";
|
|
94
|
+
const {
|
|
95
|
+
Provider: MenuProvider,
|
|
96
|
+
useStyledContext: useMenuContext
|
|
97
|
+
} = (0, import_web.createStyledContext)();
|
|
98
|
+
const MenuComp = props => {
|
|
99
|
+
const {
|
|
100
|
+
scope,
|
|
101
|
+
children,
|
|
102
|
+
dir,
|
|
103
|
+
open: openProp,
|
|
104
|
+
defaultOpen,
|
|
105
|
+
onOpenChange,
|
|
106
|
+
modal = true,
|
|
107
|
+
...rest
|
|
108
|
+
} = props;
|
|
109
|
+
const triggerRef = React.useRef(null);
|
|
110
|
+
const [open = false, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
111
|
+
prop: openProp,
|
|
112
|
+
defaultProp: defaultOpen,
|
|
113
|
+
onChange: onOpenChange
|
|
114
|
+
});
|
|
115
|
+
const openRef = React.useRef(open);
|
|
116
|
+
openRef.current = open;
|
|
117
|
+
const {
|
|
118
|
+
setActiveTrigger,
|
|
119
|
+
registerTrigger,
|
|
120
|
+
unregisterTrigger
|
|
121
|
+
} = useMenuTriggerSetup(open);
|
|
122
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuProvider, {
|
|
123
|
+
scope,
|
|
124
|
+
triggerId: (0, import_react.useId)(),
|
|
125
|
+
triggerRef,
|
|
126
|
+
contentId: (0, import_react.useId)(),
|
|
127
|
+
openRef,
|
|
128
|
+
onOpenChange: React.useCallback(nextOpen => setOpen(nextOpen), [setOpen]),
|
|
129
|
+
onOpenToggle: React.useCallback(() => setOpen(prevOpen => !prevOpen), [setOpen]),
|
|
130
|
+
modal,
|
|
131
|
+
setActiveTrigger,
|
|
132
|
+
registerTrigger,
|
|
133
|
+
unregisterTrigger,
|
|
134
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu, {
|
|
135
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
76
136
|
open,
|
|
77
137
|
onOpenChange: setOpen,
|
|
78
|
-
|
|
138
|
+
dir,
|
|
79
139
|
modal,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
modal,
|
|
86
|
-
...rest,
|
|
87
|
-
children
|
|
88
|
-
})
|
|
89
|
-
});
|
|
90
|
-
};
|
|
140
|
+
...rest,
|
|
141
|
+
children
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
};
|
|
91
145
|
MenuComp.displayName = DROPDOWN_MENU_NAME;
|
|
92
|
-
const TRIGGER_NAME = "MenuTrigger"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
146
|
+
const TRIGGER_NAME = "MenuTrigger";
|
|
147
|
+
const MenuTriggerFrame = Menu.Anchor;
|
|
148
|
+
const MenuTrigger = import_web.View.styleable((props, forwardedRef) => {
|
|
149
|
+
const {
|
|
150
|
+
scope,
|
|
151
|
+
asChild,
|
|
152
|
+
children,
|
|
153
|
+
disabled = false,
|
|
154
|
+
onKeydown,
|
|
155
|
+
...triggerProps
|
|
156
|
+
} = props;
|
|
157
|
+
const context = useMenuContext(scope);
|
|
158
|
+
const popperCtx = (0, import_popper.usePopperContextSlow)(scope || DROPDOWN_MENU_CONTEXT);
|
|
159
|
+
const Comp = asChild ? import_web.Slot : import_web.View;
|
|
160
|
+
const isTouchDevice = (0, import_web.useIsTouchDevice)();
|
|
161
|
+
const triggerElRef = React.useRef(null);
|
|
162
|
+
const triggerId = React.useId();
|
|
163
|
+
const [triggerOpen, setTriggerOpen] = React.useState(false);
|
|
164
|
+
const {
|
|
165
|
+
registerTrigger,
|
|
166
|
+
unregisterTrigger
|
|
167
|
+
} = context;
|
|
168
|
+
React.useEffect(() => {
|
|
169
|
+
registerTrigger(triggerId, setTriggerOpen);
|
|
170
|
+
return () => unregisterTrigger(triggerId);
|
|
171
|
+
}, [registerTrigger, unregisterTrigger, triggerId]);
|
|
172
|
+
const activateSelf = React.useCallback(() => {
|
|
173
|
+
context.setActiveTrigger(triggerId);
|
|
174
|
+
const el = triggerElRef.current;
|
|
175
|
+
if (el) {
|
|
176
|
+
context.triggerRef.current = el;
|
|
177
|
+
if (el instanceof HTMLElement) {
|
|
178
|
+
popperCtx.refs?.setReference(el);
|
|
179
|
+
requestAnimationFrame(() => popperCtx.update?.());
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}, [context, triggerId, popperCtx]);
|
|
183
|
+
const pressEvent = import_web.isWeb ? isTouchDevice ? "onClick" : "onPointerDown" : "onPress";
|
|
184
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuTriggerFrame, {
|
|
185
|
+
asChild: true,
|
|
186
|
+
componentName: TRIGGER_NAME,
|
|
187
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
188
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
|
|
189
|
+
role: "button",
|
|
190
|
+
id: context.triggerId,
|
|
191
|
+
"aria-haspopup": "menu",
|
|
192
|
+
"aria-expanded": triggerOpen,
|
|
193
|
+
"aria-controls": triggerOpen ? context.contentId : void 0,
|
|
194
|
+
"data-state": triggerOpen ? "open" : "closed",
|
|
195
|
+
"data-disabled": disabled ? "" : void 0,
|
|
196
|
+
"aria-disabled": disabled || void 0,
|
|
197
|
+
ref: (0, import_web.composeRefs)(forwardedRef, context.triggerRef, triggerElRef),
|
|
198
|
+
...{
|
|
121
199
|
[pressEvent]: (0, import_web.composeEventHandlers)(
|
|
122
200
|
//@ts-ignore
|
|
123
201
|
props[pressEvent], event => {
|
|
124
202
|
if (!disabled) {
|
|
125
|
-
if (import_web.isWeb && event instanceof PointerEvent && event.button !== 0 && event.ctrlKey ===
|
|
126
|
-
|
|
203
|
+
if (import_web.isWeb && event instanceof PointerEvent && event.button !== 0 && event.ctrlKey === true) return;
|
|
204
|
+
if (context.openRef.current) {
|
|
205
|
+
context.setActiveTrigger(null);
|
|
206
|
+
} else {
|
|
207
|
+
activateSelf();
|
|
208
|
+
}
|
|
209
|
+
context.onOpenToggle();
|
|
210
|
+
if (!context.openRef.current) event.preventDefault();
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
},
|
|
214
|
+
...(import_web.isWeb && {
|
|
215
|
+
onKeyDown: (0, import_web.composeEventHandlers)(onKeydown, event => {
|
|
216
|
+
if (disabled) return;
|
|
217
|
+
if (["Enter", " "].includes(event.key)) {
|
|
218
|
+
if (context.openRef.current) {
|
|
219
|
+
context.setActiveTrigger(null);
|
|
220
|
+
} else {
|
|
221
|
+
activateSelf();
|
|
222
|
+
}
|
|
223
|
+
context.onOpenToggle();
|
|
127
224
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
})
|
|
225
|
+
if (event.key === "ArrowDown") {
|
|
226
|
+
activateSelf();
|
|
227
|
+
context.onOpenChange(true);
|
|
228
|
+
}
|
|
229
|
+
if (["Enter", " ", "ArrowDown"].includes(event.key)) event.preventDefault();
|
|
230
|
+
})
|
|
231
|
+
}),
|
|
232
|
+
...triggerProps,
|
|
233
|
+
children
|
|
234
|
+
})
|
|
138
235
|
});
|
|
236
|
+
});
|
|
139
237
|
MenuTrigger.displayName = TRIGGER_NAME;
|
|
140
|
-
const PORTAL_NAME = "MenuPortal"
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
238
|
+
const PORTAL_NAME = "MenuPortal";
|
|
239
|
+
const MenuPortal = props => {
|
|
240
|
+
const {
|
|
241
|
+
scope,
|
|
242
|
+
children,
|
|
243
|
+
...portalProps
|
|
244
|
+
} = props;
|
|
245
|
+
const context = import_web.isAndroid ? useMenuContext(scope) : null;
|
|
246
|
+
const content = import_web.isAndroid ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuProvider, {
|
|
247
|
+
...context,
|
|
248
|
+
children
|
|
249
|
+
}) : children;
|
|
250
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Portal, {
|
|
251
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
252
|
+
...portalProps,
|
|
253
|
+
children: content
|
|
254
|
+
});
|
|
255
|
+
};
|
|
158
256
|
MenuPortal.displayName = PORTAL_NAME;
|
|
159
|
-
const CONTENT_NAME = "MenuContent"
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
257
|
+
const CONTENT_NAME = "MenuContent";
|
|
258
|
+
const MenuContent = React.forwardRef((props, forwardedRef) => {
|
|
259
|
+
const {
|
|
260
|
+
scope,
|
|
261
|
+
...contentProps
|
|
262
|
+
} = props;
|
|
263
|
+
const context = useMenuContext(scope);
|
|
264
|
+
const hasInteractedOutsideRef = React.useRef(false);
|
|
265
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Content, {
|
|
266
|
+
id: context.contentId,
|
|
267
|
+
"aria-labelledby": context.triggerId,
|
|
268
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
269
|
+
...contentProps,
|
|
270
|
+
ref: forwardedRef,
|
|
271
|
+
onCloseAutoFocus: (0, import_web.composeEventHandlers)(props.onCloseAutoFocus, event => {
|
|
272
|
+
if (!hasInteractedOutsideRef.current) {
|
|
273
|
+
requestAnimationFrame(() => {
|
|
274
|
+
const activeEl = document.activeElement;
|
|
275
|
+
if (!activeEl || activeEl === document.body) {
|
|
276
|
+
context.triggerRef.current?.focus();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
hasInteractedOutsideRef.current = false;
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
}),
|
|
283
|
+
onInteractOutside: (0, import_web.composeEventHandlers)(props.onInteractOutside, event => {
|
|
284
|
+
const originalEvent = event.detail.originalEvent;
|
|
285
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
286
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
287
|
+
if (!context.modal || isRightClick) hasInteractedOutsideRef.current = true;
|
|
288
|
+
}),
|
|
289
|
+
style: import_web.isWeb ? {
|
|
290
|
+
...props.style,
|
|
291
|
+
...{
|
|
292
|
+
"--tamagui-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
|
|
293
|
+
"--tamagui-menu-content-available-width": "var(--tamagui-popper-available-width)",
|
|
294
|
+
"--tamagui-menu-content-available-height": "var(--tamagui-popper-available-height)",
|
|
295
|
+
"--tamagui-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
|
|
296
|
+
"--tamagui-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
|
|
297
|
+
}
|
|
298
|
+
} : props.style
|
|
184
299
|
});
|
|
300
|
+
});
|
|
185
301
|
MenuContent.displayName = CONTENT_NAME;
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
componentName: ITEM_NAME,
|
|
201
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
202
|
-
...itemProps,
|
|
203
|
-
ref: forwardedRef
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
MenuItem.displayName = ITEM_NAME;
|
|
207
|
-
const ITEM_TITLE_NAME = "MenuItemTitle",
|
|
208
|
-
MenuItemTitle = Menu.ItemTitle;
|
|
209
|
-
MenuItemTitle.displayName = ITEM_TITLE_NAME;
|
|
210
|
-
const ITEM_SUB_TITLE_NAME = "MenuItemSubTitle",
|
|
211
|
-
MenuItemSubTitle = Menu.ItemSubtitle;
|
|
212
|
-
MenuItemSubTitle.displayName = ITEM_SUB_TITLE_NAME;
|
|
213
|
-
const ITEM_IMAGE_NAME = "MenuItemImage",
|
|
214
|
-
MenuItemImage = Menu.ItemImage;
|
|
215
|
-
MenuItemImage.displayName = ITEM_IMAGE_NAME;
|
|
216
|
-
const ITEM_ICON_NAME = "MenuItemIcon",
|
|
217
|
-
MenuItemIcon = Menu.ItemIcon;
|
|
218
|
-
MenuItemIcon.displayName = ITEM_ICON_NAME;
|
|
219
|
-
const CHECKBOX_ITEM_NAME = "MenuCheckboxItem",
|
|
220
|
-
MenuCheckboxItemFrame = Menu.CheckboxItem,
|
|
221
|
-
MenuCheckboxItem = React.forwardRef((props, forwardedRef) => {
|
|
222
|
-
const {
|
|
223
|
-
scope,
|
|
224
|
-
...checkboxItemProps
|
|
225
|
-
} = props;
|
|
226
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuCheckboxItemFrame, {
|
|
227
|
-
componentName: CHECKBOX_ITEM_NAME,
|
|
228
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
229
|
-
...checkboxItemProps,
|
|
230
|
-
ref: forwardedRef
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
MenuCheckboxItem.displayName = CHECKBOX_ITEM_NAME;
|
|
234
|
-
const RADIO_GROUP_NAME = "MenuRadioGroup",
|
|
235
|
-
MenuRadioGroup = React.forwardRef((props, forwardedRef) => {
|
|
236
|
-
const {
|
|
237
|
-
scope,
|
|
238
|
-
...radioGroupProps
|
|
239
|
-
} = props;
|
|
240
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.RadioGroup, {
|
|
241
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
242
|
-
...radioGroupProps,
|
|
243
|
-
ref: forwardedRef
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
MenuRadioGroup.displayName = RADIO_GROUP_NAME;
|
|
247
|
-
const RADIO_ITEM_NAME = "MenuRadioItem",
|
|
248
|
-
MenuRadioItemFrame = Menu.RadioItem,
|
|
249
|
-
MenuRadioItem = React.forwardRef((props, forwardedRef) => {
|
|
250
|
-
const {
|
|
251
|
-
scope,
|
|
252
|
-
...radioItemProps
|
|
253
|
-
} = props;
|
|
254
|
-
return (
|
|
255
|
-
// @ts-ignore explanation: deeply nested types typescript limitation
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
(0, import_jsx_runtime.jsx)(MenuRadioItemFrame, {
|
|
258
|
-
componentName: RADIO_ITEM_NAME,
|
|
259
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
260
|
-
...radioItemProps,
|
|
261
|
-
ref: forwardedRef
|
|
262
|
-
})
|
|
263
|
-
);
|
|
264
|
-
});
|
|
265
|
-
MenuRadioItem.displayName = RADIO_ITEM_NAME;
|
|
266
|
-
const INDICATOR_NAME = "MenuItemIndicator",
|
|
267
|
-
MenuItemIndicatorFrame = Menu.ItemIndicator,
|
|
268
|
-
MenuItemIndicator = MenuItemIndicatorFrame.styleable((props, forwardedRef) => {
|
|
269
|
-
const {
|
|
270
|
-
scope,
|
|
271
|
-
...itemIndicatorProps
|
|
272
|
-
} = props;
|
|
273
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(MenuItemIndicatorFrame, {
|
|
274
|
-
componentName: INDICATOR_NAME,
|
|
275
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
276
|
-
...itemIndicatorProps,
|
|
277
|
-
ref: forwardedRef
|
|
278
|
-
});
|
|
302
|
+
const DROPDOWN_MENU_SUB_NAME = "MenuSub";
|
|
303
|
+
const MenuSub = props => {
|
|
304
|
+
const {
|
|
305
|
+
scope,
|
|
306
|
+
children,
|
|
307
|
+
open: openProp,
|
|
308
|
+
onOpenChange,
|
|
309
|
+
defaultOpen,
|
|
310
|
+
...rest
|
|
311
|
+
} = props;
|
|
312
|
+
const [open = false, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
313
|
+
prop: openProp,
|
|
314
|
+
defaultProp: defaultOpen,
|
|
315
|
+
onChange: onOpenChange
|
|
279
316
|
});
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const {
|
|
287
|
-
scope,
|
|
288
|
-
...arrowProps
|
|
289
|
-
} = props;
|
|
290
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Arrow, {
|
|
291
|
-
componentName: ARROW_NAME,
|
|
292
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
293
|
-
...arrowProps,
|
|
294
|
-
ref: forwardedRef
|
|
295
|
-
});
|
|
317
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Sub, {
|
|
318
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
319
|
+
open,
|
|
320
|
+
onOpenChange: setOpen,
|
|
321
|
+
...rest,
|
|
322
|
+
children
|
|
296
323
|
});
|
|
297
|
-
|
|
298
|
-
const DROPDOWN_MENU_SUB_NAME = "MenuSub",
|
|
299
|
-
MenuSub = props => {
|
|
300
|
-
const {
|
|
301
|
-
scope,
|
|
302
|
-
children,
|
|
303
|
-
open: openProp,
|
|
304
|
-
onOpenChange,
|
|
305
|
-
defaultOpen,
|
|
306
|
-
...rest
|
|
307
|
-
} = props,
|
|
308
|
-
[open = !1, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
309
|
-
prop: openProp,
|
|
310
|
-
defaultProp: defaultOpen,
|
|
311
|
-
onChange: onOpenChange
|
|
312
|
-
});
|
|
313
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.Sub, {
|
|
314
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
315
|
-
open,
|
|
316
|
-
onOpenChange: setOpen,
|
|
317
|
-
...rest,
|
|
318
|
-
children
|
|
319
|
-
});
|
|
320
|
-
};
|
|
324
|
+
};
|
|
321
325
|
MenuSub.displayName = DROPDOWN_MENU_SUB_NAME;
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
});
|
|
336
|
-
MenuSubTrigger.displayName = SUB_TRIGGER_NAME;
|
|
337
|
-
const SUB_CONTENT_NAME = "MenuSubContent",
|
|
338
|
-
MenuSubContent = React.forwardRef((props, forwardedRef) => {
|
|
339
|
-
const {
|
|
340
|
-
scope,
|
|
341
|
-
...subContentProps
|
|
342
|
-
} = props;
|
|
343
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubContent, {
|
|
344
|
-
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
345
|
-
...subContentProps,
|
|
346
|
-
ref: forwardedRef,
|
|
347
|
-
style: import_web.isWeb ? {
|
|
348
|
-
...props.style,
|
|
326
|
+
const SUB_CONTENT_NAME = "MenuSubContent";
|
|
327
|
+
const MenuSubContent = React.forwardRef((props, forwardedRef) => {
|
|
328
|
+
const {
|
|
329
|
+
scope,
|
|
330
|
+
...subContentProps
|
|
331
|
+
} = props;
|
|
332
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Menu.SubContent, {
|
|
333
|
+
scope: scope || DROPDOWN_MENU_CONTEXT,
|
|
334
|
+
...subContentProps,
|
|
335
|
+
ref: forwardedRef,
|
|
336
|
+
style: import_web.isWeb ? {
|
|
337
|
+
...props.style,
|
|
338
|
+
...{
|
|
349
339
|
"--tamagui-menu-content-transform-origin": "var(--tamagui-popper-transform-origin)",
|
|
350
340
|
"--tamagui-menu-content-available-width": "var(--tamagui-popper-available-width)",
|
|
351
341
|
"--tamagui-menu-content-available-height": "var(--tamagui-popper-available-height)",
|
|
352
342
|
"--tamagui-menu-trigger-width": "var(--tamagui-popper-anchor-width)",
|
|
353
343
|
"--tamagui-menu-trigger-height": "var(--tamagui-popper-anchor-height)"
|
|
354
|
-
}
|
|
355
|
-
}
|
|
344
|
+
}
|
|
345
|
+
} : null
|
|
356
346
|
});
|
|
357
|
-
|
|
347
|
+
});
|
|
348
|
+
MenuSubContent.displayName = SUB_CONTENT_NAME;
|
|
349
|
+
const MenuScrollView = (0, import_web.styled)(import_scroll_view.ScrollView, {
|
|
350
|
+
flexShrink: 1,
|
|
351
|
+
alignSelf: "stretch",
|
|
352
|
+
showsHorizontalScrollIndicator: false,
|
|
353
|
+
showsVerticalScrollIndicator: false,
|
|
354
|
+
"$platform-web": {
|
|
355
|
+
maxHeight: "var(--tamagui-menu-content-available-height)"
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
const Group = Menu.Group;
|
|
359
|
+
const Label = Menu.Label;
|
|
360
|
+
const Item = Menu.Item;
|
|
361
|
+
const CheckboxItem = Menu.CheckboxItem;
|
|
362
|
+
const RadioGroup = Menu.RadioGroup;
|
|
363
|
+
const RadioItem = Menu.RadioItem;
|
|
364
|
+
const ItemIndicator = Menu.ItemIndicator;
|
|
365
|
+
const Separator = Menu.Separator;
|
|
366
|
+
const Arrow = Menu.Arrow;
|
|
367
|
+
const SubTrigger = Menu.SubTrigger;
|
|
368
|
+
const ItemTitle = Menu.ItemTitle;
|
|
369
|
+
const ItemSubtitle = Menu.ItemSubtitle;
|
|
370
|
+
const ItemImage = Menu.ItemImage;
|
|
371
|
+
const ItemIcon = Menu.ItemIcon;
|
|
372
|
+
return (0, import_web.withStaticProperties)(MenuComp, {
|
|
358
373
|
Root: MenuComp,
|
|
359
374
|
Trigger: MenuTrigger,
|
|
360
375
|
Portal: MenuPortal,
|
|
361
376
|
Content: MenuContent,
|
|
362
|
-
Group
|
|
363
|
-
Label
|
|
364
|
-
Item
|
|
365
|
-
CheckboxItem
|
|
366
|
-
RadioGroup
|
|
367
|
-
RadioItem
|
|
368
|
-
ItemIndicator
|
|
369
|
-
Separator
|
|
370
|
-
Arrow
|
|
377
|
+
Group,
|
|
378
|
+
Label,
|
|
379
|
+
Item,
|
|
380
|
+
CheckboxItem,
|
|
381
|
+
RadioGroup,
|
|
382
|
+
RadioItem,
|
|
383
|
+
ItemIndicator,
|
|
384
|
+
Separator,
|
|
385
|
+
Arrow,
|
|
371
386
|
Sub: MenuSub,
|
|
372
|
-
SubTrigger
|
|
387
|
+
SubTrigger,
|
|
373
388
|
SubContent: MenuSubContent,
|
|
374
|
-
ItemTitle
|
|
375
|
-
ItemSubtitle
|
|
376
|
-
ItemImage
|
|
377
|
-
ItemIcon
|
|
389
|
+
ItemTitle,
|
|
390
|
+
ItemSubtitle,
|
|
391
|
+
ItemImage,
|
|
392
|
+
ItemIcon,
|
|
393
|
+
ScrollView: MenuScrollView
|
|
378
394
|
});
|
|
379
395
|
}
|