@tamagui/menu 1.138.2 → 1.138.4

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