@tamagui/menu 1.79.11 → 1.79.13
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.js +2 -2
- package/dist/cjs/Menu.js.map +1 -1
- package/dist/cjs/Menu.native.js +2 -2
- package/dist/cjs/Menu.native.js.map +1 -1
- package/dist/cjs/createNativeMenu/createNativeMenu.android.js +263 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.android.js.map +6 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.ios.js +336 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.ios.js.map +6 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.js +46 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.js.map +6 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.native.js +47 -0
- package/dist/cjs/createNativeMenu/createNativeMenu.native.js.map +6 -0
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.js +14 -0
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.js.map +6 -0
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.native.js +15 -0
- package/dist/cjs/createNativeMenu/createNativeMenuTypes.native.js.map +6 -0
- package/dist/cjs/createNativeMenu/index.js +21 -0
- package/dist/cjs/createNativeMenu/index.js.map +6 -0
- package/dist/cjs/createNativeMenu/index.native.js +22 -0
- package/dist/cjs/createNativeMenu/index.native.js.map +6 -0
- package/dist/cjs/createNativeMenu/utils.js +78 -0
- package/dist/cjs/createNativeMenu/utils.js.map +6 -0
- package/dist/cjs/createNativeMenu/utils.native.js +79 -0
- package/dist/cjs/createNativeMenu/utils.native.js.map +6 -0
- package/dist/cjs/createNativeMenu/withNativeMenu.js +40 -0
- package/dist/cjs/createNativeMenu/withNativeMenu.js.map +6 -0
- package/dist/cjs/createNativeMenu/withNativeMenu.native.js +41 -0
- package/dist/cjs/createNativeMenu/withNativeMenu.native.js.map +6 -0
- package/dist/esm/Menu.js +2 -1
- package/dist/esm/Menu.js.map +1 -1
- package/dist/esm/Menu.native.js +2 -1
- package/dist/esm/Menu.native.js.map +1 -1
- package/dist/esm/createNativeMenu/createNativeMenu.android.js +251 -0
- package/dist/esm/createNativeMenu/createNativeMenu.android.js.map +6 -0
- package/dist/esm/createNativeMenu/createNativeMenu.ios.js +323 -0
- package/dist/esm/createNativeMenu/createNativeMenu.ios.js.map +6 -0
- package/dist/esm/createNativeMenu/createNativeMenu.js +26 -0
- package/dist/esm/createNativeMenu/createNativeMenu.js.map +6 -0
- package/dist/esm/createNativeMenu/createNativeMenu.native.js +26 -0
- package/dist/esm/createNativeMenu/createNativeMenu.native.js.map +6 -0
- package/dist/esm/createNativeMenu/createNativeMenuTypes.js +1 -0
- package/dist/esm/createNativeMenu/createNativeMenuTypes.js.map +6 -0
- package/dist/esm/createNativeMenu/createNativeMenuTypes.native.js +1 -0
- package/dist/esm/createNativeMenu/createNativeMenuTypes.native.js.map +6 -0
- package/dist/esm/createNativeMenu/index.js +3 -0
- package/dist/esm/createNativeMenu/index.js.map +6 -0
- package/dist/esm/createNativeMenu/index.native.js +3 -0
- package/dist/esm/createNativeMenu/index.native.js.map +6 -0
- package/dist/esm/createNativeMenu/utils.js +47 -0
- package/dist/esm/createNativeMenu/utils.js.map +6 -0
- package/dist/esm/createNativeMenu/utils.native.js +47 -0
- package/dist/esm/createNativeMenu/utils.native.js.map +6 -0
- package/dist/esm/createNativeMenu/withNativeMenu.js +21 -0
- package/dist/esm/createNativeMenu/withNativeMenu.js.map +6 -0
- package/dist/esm/createNativeMenu/withNativeMenu.native.js +21 -0
- package/dist/esm/createNativeMenu/withNativeMenu.native.js.map +6 -0
- package/dist/jsx/Menu.js +2 -1
- package/dist/jsx/Menu.js.map +1 -1
- package/dist/jsx/Menu.native.js +2 -1
- package/dist/jsx/Menu.native.js.map +1 -1
- package/dist/jsx/createNativeMenu/createNativeMenu.android.js +245 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.android.js.map +6 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.ios.js +322 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.ios.js.map +6 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.js +26 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.js.map +6 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.native.js +26 -0
- package/dist/jsx/createNativeMenu/createNativeMenu.native.js.map +6 -0
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.js +1 -0
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.js.map +6 -0
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.native.js +1 -0
- package/dist/jsx/createNativeMenu/createNativeMenuTypes.native.js.map +6 -0
- package/dist/jsx/createNativeMenu/index.js +3 -0
- package/dist/jsx/createNativeMenu/index.js.map +6 -0
- package/dist/jsx/createNativeMenu/index.native.js +3 -0
- package/dist/jsx/createNativeMenu/index.native.js.map +6 -0
- package/dist/jsx/createNativeMenu/utils.js +46 -0
- package/dist/jsx/createNativeMenu/utils.js.map +6 -0
- package/dist/jsx/createNativeMenu/utils.native.js +49 -0
- package/dist/jsx/createNativeMenu/utils.native.js.map +6 -0
- package/dist/jsx/createNativeMenu/withNativeMenu.js +20 -0
- package/dist/jsx/createNativeMenu/withNativeMenu.js.map +6 -0
- package/dist/jsx/createNativeMenu/withNativeMenu.native.js +20 -0
- package/dist/jsx/createNativeMenu/withNativeMenu.native.js.map +6 -0
- package/package.json +5 -4
- package/src/Menu.tsx +3 -2
- package/types/Menu.d.ts.map +1 -1
- package/types/createNativeMenu/createNativeMenu.android.d.ts.map +1 -0
- package/types/createNativeMenu/createNativeMenu.d.ts.map +1 -0
- package/types/createNativeMenu/createNativeMenu.ios.d.ts.map +1 -0
- package/types/createNativeMenu/createNativeMenuTypes.d.ts.map +1 -0
- package/types/createNativeMenu/index.d.ts.map +1 -0
- package/types/createNativeMenu/utils.d.ts.map +1 -0
- package/types/createNativeMenu/withNativeMenu.d.ts.map +1 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { withStaticProperties } from "@tamagui/core";
|
|
2
|
+
import { Children, cloneElement, useRef } from "react";
|
|
3
|
+
import { Image } from "react-native";
|
|
4
|
+
import {
|
|
5
|
+
ContextMenuButton,
|
|
6
|
+
ContextMenuView
|
|
7
|
+
} from "react-native-ios-context-menu";
|
|
8
|
+
import { View } from "tamagui";
|
|
9
|
+
import { NativePropProvider } from "../Menu";
|
|
10
|
+
import {
|
|
11
|
+
create,
|
|
12
|
+
filterNull,
|
|
13
|
+
flattenChildren,
|
|
14
|
+
isInstanceOfComponent,
|
|
15
|
+
pickChildren
|
|
16
|
+
} from "./utils";
|
|
17
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
18
|
+
const COMPONENTS_TO_IGNORE = ["Portal", "Radio"], createIosMenu = (MenuType) => {
|
|
19
|
+
const Trigger = create(({ children, asChild, ...rest }) => asChild ? cloneElement(children, {
|
|
20
|
+
...rest
|
|
21
|
+
}) : /* @__PURE__ */ jsx(View, { ...rest, children }), `${MenuType}Trigger`), Auxiliary = create(({ children }) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}Auxiliary`), Group = create(({ children }) => /* @__PURE__ */ jsx(Fragment, { children }), `${MenuType}Group`), Content = create(({ children }) => (children || console.error(`Menu <Content /> children must be written directly inline.
|
|
22
|
+
|
|
23
|
+
You cannot wrap this component into its own component. It should look like this:
|
|
24
|
+
|
|
25
|
+
<Menu>
|
|
26
|
+
<Content>
|
|
27
|
+
<Item />
|
|
28
|
+
<Item />
|
|
29
|
+
</Content>
|
|
30
|
+
</Menu>
|
|
31
|
+
|
|
32
|
+
Notice that the <Item /> are all children of the <Content /> component. That's important.
|
|
33
|
+
|
|
34
|
+
If you want to use a custom component as your <Content />, you can use the create() method. But you still need to pass all items as children of <Content />.`), /* @__PURE__ */ jsx(Fragment, { children })), `${MenuType}Content`), ItemTitle = create(({ children }) => {
|
|
35
|
+
if (typeof children != "string")
|
|
36
|
+
throw new Error("Menu <ItemTitle /> child must be a string");
|
|
37
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
38
|
+
}, `${MenuType}ItemTitle`), ItemIcon = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}ItemIcon`), ItemImage = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}ItemImage`), ItemSubtitle = create(({ children }) => {
|
|
39
|
+
if (children && typeof children != "string")
|
|
40
|
+
throw new Error("Menu <ItemSubtitle /> child must be a string");
|
|
41
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
42
|
+
}, `${MenuType}ItemSubtitle`), Item = create(({ children }) => {
|
|
43
|
+
const titleChild = pickChildren(children, ItemTitle).targetChildren;
|
|
44
|
+
return typeof children != "string" && !titleChild?.length && console.error(
|
|
45
|
+
`Menu Invalid <Item />. It either needs <ItemTitle /> in the children.
|
|
46
|
+
|
|
47
|
+
<Item>
|
|
48
|
+
<ItemTitle>
|
|
49
|
+
Title here
|
|
50
|
+
</ItemTitle>
|
|
51
|
+
</Item>
|
|
52
|
+
`
|
|
53
|
+
), /* @__PURE__ */ jsx(Fragment, { children });
|
|
54
|
+
}, `${MenuType}Item`), SubTrigger = create(({ children }) => {
|
|
55
|
+
const titleChild = pickChildren(children, ItemTitle).targetChildren;
|
|
56
|
+
return typeof children != "string" && !titleChild?.length && console.error(
|
|
57
|
+
`Menu Invalid <SubTrigger />. It either needs a string as the children, or a <ItemTitle /> in the children. However, it got neither.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
<SubTrigger>
|
|
61
|
+
<ItemTitle>
|
|
62
|
+
Title here
|
|
63
|
+
</ItemTitle>
|
|
64
|
+
</SubTrigger>
|
|
65
|
+
`
|
|
66
|
+
), /* @__PURE__ */ jsx(Fragment, { children });
|
|
67
|
+
}, `${MenuType}SubTrigger`), Sub = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}Sub`), SubContent = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}SubContent`), Preview = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}Preview`);
|
|
68
|
+
Preview.defaultProps = {
|
|
69
|
+
isResizeAnimated: !0
|
|
70
|
+
};
|
|
71
|
+
const CheckboxItem = create(({ children }) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}CheckboxItem`), Label = create(({ children }) => (typeof children != "string" && console.error("Menu <Label /> children must be a string."), /* @__PURE__ */ jsx(Fragment, {})), `${MenuType}Label`), Menu = create((props) => {
|
|
72
|
+
const trigger = pickChildren(props.children, Trigger), content = pickChildren(
|
|
73
|
+
props.children,
|
|
74
|
+
Content,
|
|
75
|
+
COMPONENTS_TO_IGNORE
|
|
76
|
+
).targetChildren?.[0], callbacks = {}, getItemFromChild = (child, index) => {
|
|
77
|
+
let title;
|
|
78
|
+
const key = child.key ? `${child.key}` : `item-${index}`;
|
|
79
|
+
let subtitle;
|
|
80
|
+
const menuAttributes = [];
|
|
81
|
+
child.props.disabled && menuAttributes.push("disabled"), child.props.destructive && menuAttributes.push("destructive"), child.props.hidden && menuAttributes.push("hidden");
|
|
82
|
+
let icon;
|
|
83
|
+
if (typeof child.props.children == "string")
|
|
84
|
+
title = child.props.children;
|
|
85
|
+
else {
|
|
86
|
+
const titleChild = pickChildren(
|
|
87
|
+
child.props.children,
|
|
88
|
+
ItemTitle
|
|
89
|
+
).targetChildren, maybeTitle = child.props.textValue ?? titleChild?.[0]?.props.children;
|
|
90
|
+
typeof maybeTitle == "string" ? title = maybeTitle : console.error(
|
|
91
|
+
`Menu Invalid <${Menu}.Item key="${key}" /> Missing valid title. Make sure you do one of the following:
|
|
92
|
+
|
|
93
|
+
1. pass a string as the child of <${Menu}.ItemTitle />, nested directly inside of <${Menu}.Item />.
|
|
94
|
+
2. OR, use the textValue prop on <${Menu}.Item textValue="Some value" />`
|
|
95
|
+
);
|
|
96
|
+
const subtitleChild = pickChildren(
|
|
97
|
+
child.props.children,
|
|
98
|
+
ItemSubtitle
|
|
99
|
+
).targetChildren;
|
|
100
|
+
typeof subtitleChild?.[0]?.props.children == "string" && (subtitle = subtitleChild[0].props.children);
|
|
101
|
+
const iconChildren = pickChildren(
|
|
102
|
+
child.props.children,
|
|
103
|
+
ItemIcon
|
|
104
|
+
).targetChildren;
|
|
105
|
+
if (iconChildren?.[0]?.props.iosIconName || iconChildren?.[0]?.props.ios) {
|
|
106
|
+
const iconConfiguration = iconChildren?.[0]?.props.ios;
|
|
107
|
+
icon = {
|
|
108
|
+
type: "IMAGE_SYSTEM",
|
|
109
|
+
imageValue: {
|
|
110
|
+
...iconConfiguration,
|
|
111
|
+
systemName: iconConfiguration?.name ?? iconChildren[0].props.iosIconName
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
} else {
|
|
115
|
+
const imageChild = pickChildren(
|
|
116
|
+
child.props.children,
|
|
117
|
+
ItemImage
|
|
118
|
+
).targetChildren?.[0];
|
|
119
|
+
if (imageChild && imageChild.props.source) {
|
|
120
|
+
const { source, ios: { lazy = !0, style } = {} } = imageChild.props;
|
|
121
|
+
typeof source == "object" && "uri" in source && source.uri ? icon = {
|
|
122
|
+
type: "IMAGE_REMOTE_URL",
|
|
123
|
+
imageValue: {
|
|
124
|
+
url: source.uri
|
|
125
|
+
},
|
|
126
|
+
imageLoadingConfig: {
|
|
127
|
+
shouldLazyLoad: lazy ?? !0
|
|
128
|
+
},
|
|
129
|
+
imageOptions: style
|
|
130
|
+
} : icon = {
|
|
131
|
+
type: "IMAGE_REQUIRE",
|
|
132
|
+
imageValue: Image.resolveAssetSource(imageChild.props.source)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (title) {
|
|
138
|
+
const maybeIndexKey = typeof child.key == "string" && child.key.startsWith(".") ? child.key.substring(1) : void 0;
|
|
139
|
+
if (
|
|
140
|
+
// if the key doesn't exist as a string
|
|
141
|
+
(typeof child.key != "string" || // or if flattenChildren assigned the key as `.${key}${index}`
|
|
142
|
+
child.key.startsWith(".") && !isNaN(Number(maybeIndexKey))) && console.warn(
|
|
143
|
+
`Menu <Item /> is missing a unique key. Pass a unique key string for each item, such as: <Item key="${title.toLowerCase().replace(/ /g, "-") || `action-${index}`}" />. Falling back to index (${key}) instead, but this may have negative consequences.`
|
|
144
|
+
), "onSelect" in child.props && child.props.onSelect
|
|
145
|
+
)
|
|
146
|
+
callbacks[key] = child.props.onSelect;
|
|
147
|
+
else if ("onValueChange" in child.props) {
|
|
148
|
+
const menuState = child.props.value, currentState = menuState === !0 ? "on" : menuState === !1 ? "off" : menuState, nextState = currentState === "mixed" || currentState === "on" ? "off" : "on", { onValueChange } = child.props;
|
|
149
|
+
callbacks[key] = () => {
|
|
150
|
+
onValueChange?.(nextState, currentState);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
key,
|
|
155
|
+
title,
|
|
156
|
+
subtitle,
|
|
157
|
+
menuAttributes,
|
|
158
|
+
icon
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, mapItemsChildren = (children) => Children.map(flattenChildren(children), (_child, index) => {
|
|
162
|
+
if (isInstanceOfComponent(_child, Item)) {
|
|
163
|
+
const item = getItemFromChild(_child, index);
|
|
164
|
+
if (item) {
|
|
165
|
+
const { icon, title, key, menuAttributes, subtitle } = item;
|
|
166
|
+
return {
|
|
167
|
+
actionKey: key,
|
|
168
|
+
actionTitle: title,
|
|
169
|
+
icon,
|
|
170
|
+
menuAttributes,
|
|
171
|
+
discoverabilityTitle: subtitle
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
} else if (isInstanceOfComponent(_child, CheckboxItem)) {
|
|
175
|
+
const child = _child, item = getItemFromChild(child, index);
|
|
176
|
+
if (item) {
|
|
177
|
+
const { icon, title, key, menuAttributes, subtitle } = item, menuState = child.props.value;
|
|
178
|
+
return {
|
|
179
|
+
actionKey: key,
|
|
180
|
+
actionTitle: title,
|
|
181
|
+
icon,
|
|
182
|
+
menuAttributes,
|
|
183
|
+
discoverabilityTitle: subtitle,
|
|
184
|
+
menuState: menuState === !0 ? "on" : menuState === !1 ? "off" : menuState
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
} else if (isInstanceOfComponent(_child, Sub)) {
|
|
188
|
+
const child = _child, triggerItemChild = pickChildren(
|
|
189
|
+
child.props.children,
|
|
190
|
+
SubTrigger
|
|
191
|
+
).targetChildren?.[0], triggerItem2 = triggerItemChild && getItemFromChild(triggerItemChild, index);
|
|
192
|
+
if (triggerItem2) {
|
|
193
|
+
const nestedContent = pickChildren(child.props.children, SubContent, COMPONENTS_TO_IGNORE).targetChildren?.[0];
|
|
194
|
+
if (nestedContent) {
|
|
195
|
+
const nestedItems = mapItemsChildren(nestedContent.props.children).filter(
|
|
196
|
+
filterNull
|
|
197
|
+
);
|
|
198
|
+
if (nestedItems.length) {
|
|
199
|
+
const menuOptions = [];
|
|
200
|
+
return new Set(triggerItem2.menuAttributes || []).has("destructive") && menuOptions.push("destructive"), {
|
|
201
|
+
menuTitle: triggerItem2?.title,
|
|
202
|
+
icon: triggerItem2?.icon,
|
|
203
|
+
menuItems: nestedItems,
|
|
204
|
+
menuOptions,
|
|
205
|
+
menuAttributes: triggerItem2.menuAttributes
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
} else if (isInstanceOfComponent(_child, Group))
|
|
211
|
+
return {
|
|
212
|
+
menuTitle: "",
|
|
213
|
+
menuItems: mapItemsChildren(_child.props.children).filter(filterNull),
|
|
214
|
+
menuOptions: ["displayInline"]
|
|
215
|
+
};
|
|
216
|
+
return null;
|
|
217
|
+
}), menuItems = mapItemsChildren(content?.props.children).filter(filterNull), labelComp = pickChildren(content?.props.children, Label).targetChildren?.[0];
|
|
218
|
+
let menuTitle = "";
|
|
219
|
+
typeof labelComp?.props.children == "string" ? menuTitle = labelComp.props.children : labelComp?.props.textValue && (menuTitle = labelComp.props.textValue);
|
|
220
|
+
const Component = MenuType === "ContextMenu" ? ContextMenuView : ContextMenuButton, preview = pickChildren(content?.props.children, Preview).targetChildren?.[0], previewProps = preview?.props, onMenuDidHide = props.onOpenChange && (() => {
|
|
221
|
+
props.onOpenChange?.(!1);
|
|
222
|
+
}), onMenuDidShow = props.onOpenChange && (() => {
|
|
223
|
+
props.onOpenChange?.(!0);
|
|
224
|
+
}), onMenuWillShow = props.onOpenWillChange && (() => {
|
|
225
|
+
props.onOpenWillChange?.(!0);
|
|
226
|
+
}), onMenuWillHide = props.onOpenWillChange && (() => {
|
|
227
|
+
props.onOpenWillChange?.(!1);
|
|
228
|
+
}), triggerItem = trigger.targetChildren?.[0];
|
|
229
|
+
let shouldOpenOnSingleTap = MenuType === "DropdownMenu";
|
|
230
|
+
triggerItem?.props.action && (shouldOpenOnSingleTap = triggerItem.props.action === "press");
|
|
231
|
+
const auxiliaryProps = (MenuType === "ContextMenu" ? pickChildren(content?.props.children, Auxiliary)?.targetChildren : void 0)?.[0]?.props, menuRef = useRef();
|
|
232
|
+
return /* @__PURE__ */ jsx(
|
|
233
|
+
NativePropProvider,
|
|
234
|
+
{
|
|
235
|
+
native: !0,
|
|
236
|
+
scope: MenuType === "DropdownMenu" ? "DropdownMenuContext" : "ContextMenuContext",
|
|
237
|
+
children: /* @__PURE__ */ jsx(
|
|
238
|
+
Component,
|
|
239
|
+
{
|
|
240
|
+
ref: menuRef,
|
|
241
|
+
onPressMenuItem: ({ nativeEvent }) => {
|
|
242
|
+
callbacks[nativeEvent.actionKey] && callbacks[nativeEvent.actionKey]();
|
|
243
|
+
},
|
|
244
|
+
isMenuPrimaryAction: shouldOpenOnSingleTap,
|
|
245
|
+
style: [{ flexGrow: 0 }, props.style],
|
|
246
|
+
menuConfig: {
|
|
247
|
+
menuTitle,
|
|
248
|
+
menuItems
|
|
249
|
+
},
|
|
250
|
+
renderPreview: MenuType === "ContextMenu" && preview && previewProps?.children ? () => /* @__PURE__ */ jsx(Fragment, { children: typeof previewProps?.children == "function" ? previewProps.children() : previewProps?.children }) : void 0,
|
|
251
|
+
lazyPreview: MenuType === "ContextMenu" ? typeof previewProps?.children == "function" : void 0,
|
|
252
|
+
onPressMenuPreview: MenuType === "ContextMenu" ? previewProps?.onPress : void 0,
|
|
253
|
+
auxiliaryPreviewConfig: auxiliaryProps?.children ? {
|
|
254
|
+
alignmentHorizontal: auxiliaryProps?.alignmentHorizontal,
|
|
255
|
+
anchorPosition: auxiliaryProps?.anchorPosition,
|
|
256
|
+
height: auxiliaryProps?.height,
|
|
257
|
+
marginAuxiliaryPreview: auxiliaryProps?.marginWithScreenEdge,
|
|
258
|
+
marginPreview: auxiliaryProps?.marginPreview,
|
|
259
|
+
transitionConfigEntrance: auxiliaryProps?.transitionConfigEntrance,
|
|
260
|
+
transitionEntranceDelay: auxiliaryProps?.transitionEntranceDelay,
|
|
261
|
+
width: auxiliaryProps?.width
|
|
262
|
+
} : void 0,
|
|
263
|
+
isAuxiliaryPreviewEnabled: !!auxiliaryProps?.children,
|
|
264
|
+
onMenuAuxiliaryPreviewDidShow: auxiliaryProps?.onDidShow,
|
|
265
|
+
onMenuAuxiliaryPreviewWillShow: auxiliaryProps?.onWillShow,
|
|
266
|
+
renderAuxiliaryPreview: auxiliaryProps?.children ? () => {
|
|
267
|
+
const child = typeof auxiliaryProps?.children == "function" ? auxiliaryProps?.children({
|
|
268
|
+
dismissMenu() {
|
|
269
|
+
menuRef.current?.dismissMenu();
|
|
270
|
+
}
|
|
271
|
+
}) : auxiliaryProps?.children;
|
|
272
|
+
return /* @__PURE__ */ jsx(Fragment, { children: child });
|
|
273
|
+
} : void 0,
|
|
274
|
+
previewConfig: preview ? {
|
|
275
|
+
// ...previewProps,
|
|
276
|
+
previewType: "CUSTOM",
|
|
277
|
+
previewSize: previewProps?.size,
|
|
278
|
+
backgroundColor: previewProps?.backgroundColor,
|
|
279
|
+
borderRadius: previewProps?.borderRadius,
|
|
280
|
+
isResizeAnimated: previewProps?.isResizeAnimated,
|
|
281
|
+
preferredCommitStyle: previewProps?.preferredCommitStyle
|
|
282
|
+
} : void 0,
|
|
283
|
+
onMenuDidHide,
|
|
284
|
+
onMenuDidShow,
|
|
285
|
+
onMenuWillHide,
|
|
286
|
+
onMenuWillShow,
|
|
287
|
+
...props.__unsafeIosProps,
|
|
288
|
+
children: triggerItem
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}, `${MenuType}`), Separator = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}Separator`), ItemIndicator = create(
|
|
294
|
+
(_) => /* @__PURE__ */ jsx(Fragment, {}),
|
|
295
|
+
`${MenuType}ItemIndicator`
|
|
296
|
+
), Arrow = create((_) => /* @__PURE__ */ jsx(Fragment, {}), `${MenuType}Arrow`);
|
|
297
|
+
return {
|
|
298
|
+
Menu: withStaticProperties(Menu, {
|
|
299
|
+
Trigger,
|
|
300
|
+
Content,
|
|
301
|
+
Item,
|
|
302
|
+
ItemTitle,
|
|
303
|
+
ItemSubtitle,
|
|
304
|
+
SubTrigger,
|
|
305
|
+
Group,
|
|
306
|
+
Separator,
|
|
307
|
+
ItemIcon,
|
|
308
|
+
ItemIndicator,
|
|
309
|
+
CheckboxItem,
|
|
310
|
+
ItemImage,
|
|
311
|
+
Label,
|
|
312
|
+
Preview,
|
|
313
|
+
Arrow,
|
|
314
|
+
Sub,
|
|
315
|
+
SubContent,
|
|
316
|
+
Auxiliary
|
|
317
|
+
})
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
export {
|
|
321
|
+
createIosMenu as createNativeMenu
|
|
322
|
+
};
|
|
323
|
+
//# sourceMappingURL=createNativeMenu.ios.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/createNativeMenu.ios.tsx"],
|
|
4
|
+
"mappings": "AAGA,SAAS,4BAA4B;AACrC,SAAgB,UAAwB,cAAc,cAAc;AACpE,SAAS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AAG,iBAAM;AAAA,YAClB,IACA;AAAA,YAEN,eACE,UACI;AAAA;AAAA,cAEE,aAAa;AAAA,cACb,aAAa,cAAc;AAAA,cAC3B,iBAAiB,cAAc;AAAA,cAC/B,cAAc,cAAc;AAAA,cAC5B,kBAAkB,cAAc;AAAA,cAChC,sBAAsB,cAAc;AAAA,YACtC,IACA;AAAA,YAEN;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAG,MAAM;AAAA,YAET;AAAA;AAAA,QACH;AAAA;AAAA,IACF;AAAA,EAEJ,GAAG,GAAG,QAAQ,EAAE,GAEV,YAAY,OAAO,CAAC,MACjB,gCAAE,GACR,GAAG,QAAQ,WAAW,GAEnB,gBAAgB;AAAA,IACpB,CAAC,MAA8B,gCAAE;AAAA,IACjC,GAAG,QAAQ;AAAA,EACb,GAEM,QAAQ,OAAO,CAAC,MAAsB,gCAAE,GAAK,GAAG,QAAQ,OAAO;AAErE,SAAO;AAAA,IACL,MAAM,qBAAqB,MAAM;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
|
|
5
|
+
"names": ["triggerItem"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withStaticProperties } from "@tamagui/core";
|
|
2
|
+
const createNativeMenu = (MenuType) => ({
|
|
3
|
+
Menu: withStaticProperties({}, {
|
|
4
|
+
Trigger: {},
|
|
5
|
+
Content: {},
|
|
6
|
+
Item: {},
|
|
7
|
+
ItemTitle: {},
|
|
8
|
+
ItemSubtitle: {},
|
|
9
|
+
SubTrigger: {},
|
|
10
|
+
Group: {},
|
|
11
|
+
ItemIcon: {},
|
|
12
|
+
Separator: {},
|
|
13
|
+
CheckboxItem: {},
|
|
14
|
+
ItemIndicator: {},
|
|
15
|
+
ItemImage: {},
|
|
16
|
+
Label: {},
|
|
17
|
+
Arrow: {},
|
|
18
|
+
Sub: {},
|
|
19
|
+
SubContent: {},
|
|
20
|
+
Preview: {}
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
createNativeMenu
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=createNativeMenu.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/createNativeMenu.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,4BAA4B;AAwB9B,MAAM,mBAAmB,CAAC,cAoCxB;AAAA,EACL,MAAM,qBApCK,CAAC,GAoCqB;AAAA,IAC/B,SAnCY,CAAC;AAAA,IAoCb,SAlCY,CAAC;AAAA,IAmCb,MAhCS,CAAC;AAAA,IAiCV,WAzBc,CAAC;AAAA,IA0Bf,cAxBiB,CAAC;AAAA,IAyBlB,YA7Be,CAAC;AAAA,IA8BhB,OAxBU,CAAC;AAAA,IAyBX,UAnCa,CAAC;AAAA,IAoCd,WAxBc,CAAC;AAAA,IAyBf,cAvBiB,CAAC;AAAA,IAwBlB,eAtBkB,CAAC;AAAA,IAuBnB,WArCc,CAAC;AAAA,IAsCf,OAtBU,CAAC;AAAA,IAuBX,OArBU,CAAC;AAAA,IAsBX,KApBQ,CAAC;AAAA,IAqBT,YAnBe,CAAC;AAAA,IAoBhB,SAhDY,CAAC;AAAA,EAiDf,CAAC;AACH;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withStaticProperties } from "@tamagui/core";
|
|
2
|
+
const createNativeMenu = (MenuType) => ({
|
|
3
|
+
Menu: withStaticProperties({}, {
|
|
4
|
+
Trigger: {},
|
|
5
|
+
Content: {},
|
|
6
|
+
Item: {},
|
|
7
|
+
ItemTitle: {},
|
|
8
|
+
ItemSubtitle: {},
|
|
9
|
+
SubTrigger: {},
|
|
10
|
+
Group: {},
|
|
11
|
+
ItemIcon: {},
|
|
12
|
+
Separator: {},
|
|
13
|
+
CheckboxItem: {},
|
|
14
|
+
ItemIndicator: {},
|
|
15
|
+
ItemImage: {},
|
|
16
|
+
Label: {},
|
|
17
|
+
Arrow: {},
|
|
18
|
+
Sub: {},
|
|
19
|
+
SubContent: {},
|
|
20
|
+
Preview: {}
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
createNativeMenu
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=createNativeMenu.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/createNativeMenu.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,4BAA4B;AAwB9B,MAAM,mBAAmB,CAAC,cAoCxB;AAAA,EACL,MAAM,qBApCK,CAAC,GAoCqB;AAAA,IAC/B,SAnCY,CAAC;AAAA,IAoCb,SAlCY,CAAC;AAAA,IAmCb,MAhCS,CAAC;AAAA,IAiCV,WAzBc,CAAC;AAAA,IA0Bf,cAxBiB,CAAC;AAAA,IAyBlB,YA7Be,CAAC;AAAA,IA8BhB,OAxBU,CAAC;AAAA,IAyBX,UAnCa,CAAC;AAAA,IAoCd,WAxBc,CAAC;AAAA,IAyBf,cAvBiB,CAAC;AAAA,IAwBlB,eAtBkB,CAAC;AAAA,IAuBnB,WArCc,CAAC;AAAA,IAsCf,OAtBU,CAAC;AAAA,IAuBX,OArBU,CAAC;AAAA,IAsBX,KApBQ,CAAC;AAAA,IAqBT,YAnBe,CAAC;AAAA,IAoBhB,SAhDY,CAAC;AAAA,EAiDf,CAAC;AACH;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=createNativeMenuTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=createNativeMenuTypes.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
isValidElement
|
|
5
|
+
} from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function flattenChildrenKeyless(children) {
|
|
8
|
+
return React.Children.toArray(children).reduce((flatChildren, child) => child.type === React.Fragment ? flatChildren.concat(
|
|
9
|
+
flattenChildren(child.props.children)
|
|
10
|
+
) : (flatChildren.push(child), flatChildren), []);
|
|
11
|
+
}
|
|
12
|
+
function flattenChildren(children, componentNamesToIgnore, depth = 0, keys = []) {
|
|
13
|
+
return Children.toArray(children).flatMap((elem) => isValidElement(elem) && typeof elem?.type == "function" && componentNamesToIgnore?.some(
|
|
14
|
+
(skipComponentName) => elem.type.displayName.includes(skipComponentName)
|
|
15
|
+
) ? elem.props.children : elem).reduce((acc, node, nodeIndex) => (node.type === React.Fragment ? acc.push.apply(
|
|
16
|
+
acc,
|
|
17
|
+
flattenChildren(
|
|
18
|
+
node.props.children,
|
|
19
|
+
componentNamesToIgnore,
|
|
20
|
+
depth + 1,
|
|
21
|
+
keys.concat(node.key || nodeIndex)
|
|
22
|
+
)
|
|
23
|
+
) : isValidElement(node) ? acc.push(
|
|
24
|
+
cloneElement(node, {
|
|
25
|
+
key: keys.concat(String(node.key)).join(".")
|
|
26
|
+
})
|
|
27
|
+
) : (typeof node == "string" || typeof node == "number") && acc.push(node), acc), []);
|
|
28
|
+
}
|
|
29
|
+
const pickChildren = (_children, targetChild, componentNamesToIgnore) => {
|
|
30
|
+
const children = flattenChildren(_children, componentNamesToIgnore), target = [], withoutTargetChildren = React.Children.map(children, (item) => isValidElement(item) && isInstanceOfComponent(item, targetChild) ? (target.push(cloneElement(item)), null) : item);
|
|
31
|
+
return {
|
|
32
|
+
targetChildren: target.length >= 0 ? target : void 0,
|
|
33
|
+
withoutTargetChildren
|
|
34
|
+
};
|
|
35
|
+
}, isInstanceOfComponent = (element, targetElement) => element?.type === targetElement || typeof element?.type == "function" && (element?.type?.displayName === targetElement.displayName || element?.type?.displayName === targetElement.displayName + "Wrapper"), filterNull = (t) => t != null, create = (Component, displayName) => {
|
|
36
|
+
const MenuComponent = (props) => /* @__PURE__ */ jsx(Component, { ...props });
|
|
37
|
+
return MenuComponent.displayName = displayName, MenuComponent;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
create,
|
|
41
|
+
filterNull,
|
|
42
|
+
flattenChildren,
|
|
43
|
+
flattenChildrenKeyless,
|
|
44
|
+
isInstanceOfComponent,
|
|
45
|
+
pickChildren
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/utils.tsx"],
|
|
4
|
+
"mappings": "AAIA,OAAO;AAAA,EACL;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AAgHI;AA5GJ,SAAS,uBAAuB,UAA4C;AAEjF,SADsB,MAAM,SAAS,QAAQ,QAAQ,EAChC,OAAO,CAAC,cAA+B,UACrD,MAAkC,SAAS,MAAM,WAC7C,aAAa;AAAA,IAClB,gBAAiB,MAAkC,MAAM,QAAQ;AAAA,EACnE,KAEF,aAAa,KAAK,KAAK,GAChB,eACN,CAAC,CAAC;AACP;AAEO,SAAS,gBACd,UACA,wBACA,QAAQ,GACR,OAA4B,CAAC,GACf;AACd,SAAO,SAAS,QAAQ,QAAQ,EAC7B,QAAQ,CAAC,SACJ,eAAe,IAAI,KAEnB,OAAQ,MAAc,QAAQ,cAC9B,wBAAwB;AAAA,IAAK,CAAC,sBAC3B,KAAK,KAAa,YAAY,SAAS,iBAAiB;AAAA,EAC3D,IAEO,KAAK,MAAM,WAGf,IACR,EACA,OAAO,CAAC,KAAmB,MAAW,eACjC,KAAK,SAAS,MAAM,WACtB,IAAI,KAAK;AAAA,IACP;AAAA,IACA;AAAA,MACE,KAAK,MAAM;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR,KAAK,OAAO,KAAK,OAAO,SAAS;AAAA,IACnC;AAAA,EACF,IAEI,eAAe,IAAI,IACrB,IAAI;AAAA,IACF,aAAa,MAAM;AAAA,MACjB,KAAK,KAAK,OAAO,OAAO,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG;AAAA,IAC7C,CAAC;AAAA,EACH,KACS,OAAO,QAAS,YAAY,OAAO,QAAS,aACrD,IAAI,KAAK,IAAI,GAGV,MACN,CAAC,CAAC;AACT;AAEO,MAAM,eAAe,CAC1B,WACA,aACA,2BACG;AACH,QAAM,WAAW,gBAAgB,WAAW,sBAAsB,GAC5D,SAAgC,CAAC,GACjC,wBAAwB,MAAM,SAAS,IAAI,UAAU,CAAC,SACrD,eAAe,IAAI,KACpB,sBAAsB,MAAM,WAAW,KAEzC,OAAO,KAAK,aAAa,IAAI,CAAC,GACvB,QAJyB,IAOnC;AAID,SAAO;AAAA,IACL,gBAHqB,OAAO,UAAU,IAAI,SAAS;AAAA,IAInD;AAAA,EACF;AACF,GAEa,wBAAwB,CACnC,SACA,kBAGG,SAAiB,SAAS,iBAC1B,OAAQ,SAAiB,QAAQ,eAC9B,SAAiB,MAAM,gBAAiB,cAAsB,eAC7D,SAAiB,MAAM,gBACrB,cAAsB,cAAc,YAIlC,aAAa,CACxB,MAEO,KAAK,MAGD,SAAS,CACpB,WACA,gBACG;AACH,QAAM,gBAAiC,CAAC,UAC/B,oBAAC,aAAW,GAAI,OAAe;AAExC,uBAAc,cAAc,aAErB;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
isValidElement
|
|
5
|
+
} from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function flattenChildrenKeyless(children) {
|
|
8
|
+
return React.Children.toArray(children).reduce((flatChildren, child) => child.type === React.Fragment ? flatChildren.concat(
|
|
9
|
+
flattenChildren(child.props.children)
|
|
10
|
+
) : (flatChildren.push(child), flatChildren), []);
|
|
11
|
+
}
|
|
12
|
+
function flattenChildren(children, componentNamesToIgnore, depth = 0, keys = []) {
|
|
13
|
+
return Children.toArray(children).flatMap((elem) => isValidElement(elem) && typeof elem?.type == "function" && componentNamesToIgnore?.some(
|
|
14
|
+
(skipComponentName) => elem.type.displayName.includes(skipComponentName)
|
|
15
|
+
) ? elem.props.children : elem).reduce((acc, node, nodeIndex) => (node.type === React.Fragment ? acc.push.apply(
|
|
16
|
+
acc,
|
|
17
|
+
flattenChildren(
|
|
18
|
+
node.props.children,
|
|
19
|
+
componentNamesToIgnore,
|
|
20
|
+
depth + 1,
|
|
21
|
+
keys.concat(node.key || nodeIndex)
|
|
22
|
+
)
|
|
23
|
+
) : isValidElement(node) ? acc.push(
|
|
24
|
+
cloneElement(node, {
|
|
25
|
+
key: keys.concat(String(node.key)).join(".")
|
|
26
|
+
})
|
|
27
|
+
) : (typeof node == "string" || typeof node == "number") && acc.push(node), acc), []);
|
|
28
|
+
}
|
|
29
|
+
const pickChildren = (_children, targetChild, componentNamesToIgnore) => {
|
|
30
|
+
const children = flattenChildren(_children, componentNamesToIgnore), target = [], withoutTargetChildren = React.Children.map(children, (item) => isValidElement(item) && isInstanceOfComponent(item, targetChild) ? (target.push(cloneElement(item)), null) : item);
|
|
31
|
+
return {
|
|
32
|
+
targetChildren: target.length >= 0 ? target : void 0,
|
|
33
|
+
withoutTargetChildren
|
|
34
|
+
};
|
|
35
|
+
}, isInstanceOfComponent = (element, targetElement) => element?.type === targetElement || typeof element?.type == "function" && (element?.type?.displayName === targetElement.displayName || element?.type?.displayName === targetElement.displayName + "Wrapper"), filterNull = (t) => t != null, create = (Component, displayName) => {
|
|
36
|
+
const MenuComponent = (props) => /* @__PURE__ */ jsx(Component, { ...props });
|
|
37
|
+
return MenuComponent.displayName = displayName, MenuComponent;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
create,
|
|
41
|
+
filterNull,
|
|
42
|
+
flattenChildren,
|
|
43
|
+
flattenChildrenKeyless,
|
|
44
|
+
isInstanceOfComponent,
|
|
45
|
+
pickChildren
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/utils.tsx"],
|
|
4
|
+
"mappings": "AAIA,OAAO;AAAA,EACL;AAAA,EAIA;AAAA,EACA;AAAA,OACK;AAgHI;AA5GJ,SAAS,uBAAuB,UAA4C;AAEjF,SADsB,MAAM,SAAS,QAAQ,QAAQ,EAChC,OAAO,CAAC,cAA+B,UACrD,MAAkC,SAAS,MAAM,WAC7C,aAAa;AAAA,IAClB,gBAAiB,MAAkC,MAAM,QAAQ;AAAA,EACnE,KAEF,aAAa,KAAK,KAAK,GAChB,eACN,CAAC,CAAC;AACP;AAEO,SAAS,gBACd,UACA,wBACA,QAAQ,GACR,OAA4B,CAAC,GACf;AACd,SAAO,SAAS,QAAQ,QAAQ,EAC7B,QAAQ,CAAC,SACJ,eAAe,IAAI,KAEnB,OAAQ,MAAc,QAAQ,cAC9B,wBAAwB;AAAA,IAAK,CAAC,sBAC3B,KAAK,KAAa,YAAY,SAAS,iBAAiB;AAAA,EAC3D,IAEO,KAAK,MAAM,WAGf,IACR,EACA,OAAO,CAAC,KAAmB,MAAW,eACjC,KAAK,SAAS,MAAM,WACtB,IAAI,KAAK;AAAA,IACP;AAAA,IACA;AAAA,MACE,KAAK,MAAM;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR,KAAK,OAAO,KAAK,OAAO,SAAS;AAAA,IACnC;AAAA,EACF,IAEI,eAAe,IAAI,IACrB,IAAI;AAAA,IACF,aAAa,MAAM;AAAA,MACjB,KAAK,KAAK,OAAO,OAAO,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG;AAAA,IAC7C,CAAC;AAAA,EACH,KACS,OAAO,QAAS,YAAY,OAAO,QAAS,aACrD,IAAI,KAAK,IAAI,GAGV,MACN,CAAC,CAAC;AACT;AAEO,MAAM,eAAe,CAC1B,WACA,aACA,2BACG;AACH,QAAM,WAAW,gBAAgB,WAAW,sBAAsB,GAC5D,SAAgC,CAAC,GACjC,wBAAwB,MAAM,SAAS,IAAI,UAAU,CAAC,SACrD,eAAe,IAAI,KACpB,sBAAsB,MAAM,WAAW,KAEzC,OAAO,KAAK,aAAa,IAAI,CAAC,GACvB,QAJyB,IAOnC;AAID,SAAO;AAAA,IACL,gBAHqB,OAAO,UAAU,IAAI,SAAS;AAAA,IAInD;AAAA,EACF;AACF,GAEa,wBAAwB,CACnC,SACA,kBAGG,SAAiB,SAAS,iBAC1B,OAAQ,SAAiB,QAAQ,eAC9B,SAAiB,MAAM,gBAAiB,cAAsB,eAC7D,SAAiB,MAAM,gBACrB,cAAsB,cAAc,YAIlC,aAAa,CACxB,MAEO,KAAK,MAGD,SAAS,CACpB,WACA,gBACG;AACH,QAAM,gBAAiC,CAAC,UAC/B,oBAAC,aAAW,GAAI,OAAe;AAExC,uBAAc,cAAc,aAErB;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function withNativeMenu({
|
|
4
|
+
Component,
|
|
5
|
+
NativeComponent,
|
|
6
|
+
useNativeProp,
|
|
7
|
+
useNativePropScope,
|
|
8
|
+
isRoot = !1
|
|
9
|
+
}) {
|
|
10
|
+
if (isWeb)
|
|
11
|
+
return Component;
|
|
12
|
+
const Menu = (props) => {
|
|
13
|
+
let isNative = !0;
|
|
14
|
+
return isRoot ? isNative = props.native : isNative = useNativeProp(useNativePropScope).native, isNative ? /* @__PURE__ */ jsx(NativeComponent, { ...props }) : /* @__PURE__ */ jsx(Component, { ...props });
|
|
15
|
+
};
|
|
16
|
+
return Menu.displayName = `${Component.displayName}Wrapper`, Menu;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
withNativeMenu
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=withNativeMenu.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/withNativeMenu.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AA6BT;AA3BN,SAAS,eAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AACX,GAMG;AACD,MAAI;AAAO,WAAO;AAClB,QAAM,OAAO,CACX,UACG;AACH,QAAI,WAAW;AAMf,WALI,SACF,WAAW,MAAM,SAEjB,WAAW,cAAc,kBAAkB,EAAE,QAE3C,WACK,oBAAC,mBAAiB,GAAI,OAAmC,IAG3D,oBAAC,aAAW,GAAI,OAAmC;AAAA,EAC5D;AAEA,cAAK,cAAc,GAAG,UAAU,WAAW,WAEpC;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isWeb } from "@tamagui/core";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function withNativeMenu({
|
|
4
|
+
Component,
|
|
5
|
+
NativeComponent,
|
|
6
|
+
useNativeProp,
|
|
7
|
+
useNativePropScope,
|
|
8
|
+
isRoot = !1
|
|
9
|
+
}) {
|
|
10
|
+
if (isWeb)
|
|
11
|
+
return Component;
|
|
12
|
+
const Menu = (props) => {
|
|
13
|
+
let isNative = !0;
|
|
14
|
+
return isRoot ? isNative = props.native : isNative = useNativeProp(useNativePropScope).native, isNative ? /* @__PURE__ */ jsx(NativeComponent, { ...props }) : /* @__PURE__ */ jsx(Component, { ...props });
|
|
15
|
+
};
|
|
16
|
+
return Menu.displayName = `${Component.displayName}Wrapper`, Menu;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
withNativeMenu
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=withNativeMenu.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/createNativeMenu/withNativeMenu.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAAS,aAAa;AA6BT;AA3BN,SAAS,eAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AACX,GAMG;AACD,MAAI;AAAO,WAAO;AAClB,QAAM,OAAO,CACX,UACG;AACH,QAAI,WAAW;AAMf,WALI,SACF,WAAW,MAAM,SAEjB,WAAW,cAAc,kBAAkB,EAAE,QAE3C,WACK,oBAAC,mBAAiB,GAAI,OAAmC,IAG3D,oBAAC,aAAW,GAAI,OAAmC;AAAA,EAC5D;AAEA,cAAK,cAAc,GAAG,UAAU,WAAW,WAEpC;AACT;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/dist/jsx/Menu.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useMedia
|
|
1
|
+
import { useMedia } from "@tamagui/core";
|
|
2
|
+
import { withStaticProperties } from "@tamagui/helpers";
|
|
2
3
|
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
3
4
|
import { useMemo } from "react";
|
|
4
5
|
const MenuItem = (props) => props.children, Menu = withStaticProperties(
|