@tamagui/native 2.7.0 → 2.7.1
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/.turbo/turbo-build.log +1 -1
- package/dist/cjs/expoUIMenuAdapter.cjs +12 -6
- package/dist/cjs/expoUIMenuAdapter.native.js +12 -6
- package/dist/cjs/expoUIMenuAdapter.native.js.map +1 -1
- package/dist/esm/expoUIMenuAdapter.mjs +12 -6
- package/dist/esm/expoUIMenuAdapter.mjs.map +1 -1
- package/dist/esm/expoUIMenuAdapter.native.js +12 -6
- package/dist/esm/expoUIMenuAdapter.native.js.map +1 -1
- package/package.json +2 -2
- package/src/expoUIMenuAdapter.tsx +22 -6
- package/types/expoUIMenuAdapter.d.ts.map +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
$ tamagui-build
|
|
2
|
-
built @tamagui/native in
|
|
2
|
+
built @tamagui/native in 668 ms
|
|
@@ -43,9 +43,15 @@ function marker(name) {
|
|
|
43
43
|
Marker.displayName = `ExpoUI${name}`;
|
|
44
44
|
return Marker;
|
|
45
45
|
}
|
|
46
|
+
function isMarkerType(candidate, type) {
|
|
47
|
+
if (candidate === type) return true;
|
|
48
|
+
const wanted = type.displayName;
|
|
49
|
+
if (!wanted) return false;
|
|
50
|
+
return typeof candidate === "function" && candidate.displayName === wanted;
|
|
51
|
+
}
|
|
46
52
|
function elementOfType(children, type) {
|
|
47
53
|
for (const child of import_react.default.Children.toArray(children)) {
|
|
48
|
-
if (import_react.default.isValidElement(child) && child.type
|
|
54
|
+
if (import_react.default.isValidElement(child) && isMarkerType(child.type, type)) {
|
|
49
55
|
return child;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
@@ -149,12 +155,12 @@ function createExpoUIMenuAdapter({
|
|
|
149
155
|
}
|
|
150
156
|
for (const child of import_react.default.Children.toArray(childrenToParse)) {
|
|
151
157
|
if (!import_react.default.isValidElement(child)) continue;
|
|
152
|
-
if (child.type
|
|
158
|
+
if (isMarkerType(child.type, Separator)) {
|
|
153
159
|
if (!section) section = actions.splice(0);
|
|
154
160
|
flushSection();
|
|
155
161
|
continue;
|
|
156
162
|
}
|
|
157
|
-
if (child.type
|
|
163
|
+
if (isMarkerType(child.type, Group)) {
|
|
158
164
|
const label2 = elementOfType(child.props.children, Label);
|
|
159
165
|
append({
|
|
160
166
|
id: actionId(child),
|
|
@@ -164,7 +170,7 @@ function createExpoUIMenuAdapter({
|
|
|
164
170
|
});
|
|
165
171
|
continue;
|
|
166
172
|
}
|
|
167
|
-
if (child.type
|
|
173
|
+
if (isMarkerType(child.type, Sub)) {
|
|
168
174
|
const subTrigger = elementOfType(child.props.children, SubTrigger);
|
|
169
175
|
const subContent = elementOfType(child.props.children, SubContent);
|
|
170
176
|
if (!subTrigger || !subContent) {
|
|
@@ -179,12 +185,12 @@ function createExpoUIMenuAdapter({
|
|
|
179
185
|
});
|
|
180
186
|
continue;
|
|
181
187
|
}
|
|
182
|
-
if (child.type
|
|
188
|
+
if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem)) continue;
|
|
183
189
|
if (elementOfType(child.props.children, ItemSubtitle)) {
|
|
184
190
|
throw new Error("@expo/ui/community/menu does not support menu item subtitles");
|
|
185
191
|
}
|
|
186
192
|
const id = actionId(child);
|
|
187
|
-
if (child.type
|
|
193
|
+
if (isMarkerType(child.type, CheckboxItem)) {
|
|
188
194
|
const current = child.props.value === true || child.props.value === "on" || child.props.checked === true;
|
|
189
195
|
const onValueChange = child.props.onValueChange;
|
|
190
196
|
const onCheckedChange = child.props.onCheckedChange;
|
|
@@ -52,6 +52,12 @@ function marker(name) {
|
|
|
52
52
|
Marker.displayName = `ExpoUI${name}`;
|
|
53
53
|
return Marker;
|
|
54
54
|
}
|
|
55
|
+
function isMarkerType(candidate, type) {
|
|
56
|
+
if (candidate === type) return true;
|
|
57
|
+
var wanted = type.displayName;
|
|
58
|
+
if (!wanted) return false;
|
|
59
|
+
return typeof candidate === "function" && candidate.displayName === wanted;
|
|
60
|
+
}
|
|
55
61
|
function elementOfType(children, type) {
|
|
56
62
|
var _iteratorNormalCompletion = true,
|
|
57
63
|
_didIteratorError = false,
|
|
@@ -59,7 +65,7 @@ function elementOfType(children, type) {
|
|
|
59
65
|
try {
|
|
60
66
|
for (var _iterator = import_react.default.Children.toArray(children)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
61
67
|
var child = _step.value;
|
|
62
|
-
if (/* @__PURE__ */import_react.default.isValidElement(child) && child.type
|
|
68
|
+
if (/* @__PURE__ */import_react.default.isValidElement(child) && isMarkerType(child.type, type)) {
|
|
63
69
|
return child;
|
|
64
70
|
}
|
|
65
71
|
}
|
|
@@ -184,12 +190,12 @@ function createExpoUIMenuAdapter(param) {
|
|
|
184
190
|
var _loop = function () {
|
|
185
191
|
var child = _step.value;
|
|
186
192
|
if (! /* @__PURE__ */import_react.default.isValidElement(child)) return "continue";
|
|
187
|
-
if (child.type
|
|
193
|
+
if (isMarkerType(child.type, Separator)) {
|
|
188
194
|
if (!section) section = actions.splice(0);
|
|
189
195
|
flushSection();
|
|
190
196
|
return "continue";
|
|
191
197
|
}
|
|
192
|
-
if (child.type
|
|
198
|
+
if (isMarkerType(child.type, Group)) {
|
|
193
199
|
var label2 = elementOfType(child.props.children, Label);
|
|
194
200
|
append({
|
|
195
201
|
id: actionId(child),
|
|
@@ -199,7 +205,7 @@ function createExpoUIMenuAdapter(param) {
|
|
|
199
205
|
});
|
|
200
206
|
return "continue";
|
|
201
207
|
}
|
|
202
|
-
if (child.type
|
|
208
|
+
if (isMarkerType(child.type, Sub)) {
|
|
203
209
|
var subTrigger = elementOfType(child.props.children, SubTrigger);
|
|
204
210
|
var subContent = elementOfType(child.props.children, SubContent);
|
|
205
211
|
if (!subTrigger || !subContent) {
|
|
@@ -214,12 +220,12 @@ function createExpoUIMenuAdapter(param) {
|
|
|
214
220
|
});
|
|
215
221
|
return "continue";
|
|
216
222
|
}
|
|
217
|
-
if (child.type
|
|
223
|
+
if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem)) return "continue";
|
|
218
224
|
if (elementOfType(child.props.children, ItemSubtitle)) {
|
|
219
225
|
throw new Error("@expo/ui/community/menu does not support menu item subtitles");
|
|
220
226
|
}
|
|
221
227
|
var id = actionId(child);
|
|
222
|
-
if (child.type
|
|
228
|
+
if (isMarkerType(child.type, CheckboxItem)) {
|
|
223
229
|
var current = child.props.value === true || child.props.value === "on" || child.props.checked === true;
|
|
224
230
|
var onValueChange = child.props.onValueChange;
|
|
225
231
|
var onCheckedChange = child.props.onCheckedChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","expoUIMenuAdapter_exports","__export","createExpoUIMenuAdapter","module","exports","import_jsx_runtime","require","import_react","__toESM","_type_of","obj","Symbol","constructor","marker","name","Marker","displayName","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","expoUIMenuAdapter_exports","__export","createExpoUIMenuAdapter","module","exports","import_jsx_runtime","require","import_react","__toESM","_type_of","obj","Symbol","constructor","marker","name","Marker","displayName","isMarkerType","candidate","type","wanted","elementOfType","children","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","default","Children","toArray","iterator","_step","next","done","child","isValidElement","err","return","textFromNode","node","String","props","map","join","param","MenuView","NativeMenuView","createModule","isContextMenu","Trigger","Content","Item","ItemTitle","ItemSubtitle","ItemIcon","ItemImage","ItemIndicator","Group","Label","Separator","Sub","SubTrigger","SubContent","CheckboxItem","Preview","Auxiliary","Root","param2","onOpenChange","onOpenWillChange","trigger","content","preview","auxiliary","Error","nextId","handlers","Map","actionId","element","key","replace","itemTitle","textValue","title","actionImage","image","source","icon","ios","iosIconName","attributes","destructive","disabled","hidden","actionsFrom","childrenToParse","actions","section","append","action","push","flushSection","length","id","subactions","displayInline","_loop","splice","label2","subTrigger","subContent","current","checked","onValueChange","onCheckedChange","set","state","onSelect","label","triggerAction","jsx","shouldOpenOnLongPress","onPressAction","event","_handlers_get","get","nativeEvent","onOpenMenu"],"sources":["../../src/expoUIMenuAdapter.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,uBAAA,EAAAA,CAAA,KAAAA;AAAA;AACAC,MAAA,CAAAC,OAAA,GAAAT,YAAkB,CAAAK,yBAAA;AA8RV,IAAAK,kBAAA,GAAAC,OAAA;AAzPR,IAAAC,YAAgB,GAAAC,OAA0C,CAAAF,OAAA;AACxD,SAAMG,QAASA,CAAAC,GAAA,EAAM;EACrB,uBAAqB;;EACrB,OAAOA,GAAA,WAAAC,MAAA,oBAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACT;AAEA,SAASG,OAAAC,IAAA,EAAa;EACpB,IAAIC,MAAA,YAAAA,CAAA,EAAoB;IAMxB,OAAM;EACN;EACAA,MAAA,CACEC,WAAO,YAAcF,IAAA;EAGzB,OAAAC,MAAA;AAEA;AAIE,SAAAE,YAAWA,CAASC,SAAA,EAAAC,IAAA;EAClB,IAAAD,SAAI,KAAAC,IAAA,SAAM;EACR,IAAAC,MAAA,GAAOD,IAAA,CAAAH,WAAA;EAAA,IACT,CAAAI,MAAA;EACF,cAAAF,SAAA,mBAAAA,SAAA,CAAAF,WAAA,KAAAI,MAAA;AACA;AACF,SAAAC,cAAAC,QAAA,EAAAH,IAAA;EAEA,IAAAI,yBAA+C;IAAAC,iBAAA;IAAAC,cAAA;EAC7C,IAAI;IACJ,KAAK,IAAAC,SAAA,GAAAnB,YAAM,CAAAoB,OAA4B,CAAAC,QAAO,CAAAC,OAAO,C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D,OAAA,CAAA9B,KAAA,CAAAnB,QAAA,EAAAoC,KAAA;MACA,IAAA8D,aAAA,GAAAlD,OAAA,CAAA7B,KAAA,CAAA2D,MAAA;MACA,0BAAA/F,kBAAA,CAAAoH,GAAA,EAAA3E,cAAA;QACFmD,OAAA,EAAAF,WAAA,CAAAxB,OAAA,CAAA9B,KAAA,CAAAnB,QAAA;QACF8D,KAAA,EAAAmC,KAAA,GAAAjF,YAAA,CAAAiF,KAAA,CAAA9E,KAAA,CAAAnB,QAAA;QAEAoG,qBAAO,EAAAF,aAAA,oBAAAA,aAAA,gBAAAxE,aAAA;QACL2E,aAAM,WAAAA,CAAAC,KAAA;UACA,IAAAC,aAAa;UACnB,OAAa,CAAAA,aAAa,GAAIjD,QAAA,CAAAkD,GAAA,CAAAF,KAAA,CAAAG,WAAA,CAAAH,KAAA,eAAAC,aAAA,uBAAAA,aAAA;QAChC;QACFG,UAAA,WAAAA,CAAA","ignoreList":[]}
|
|
@@ -5,9 +5,15 @@ function marker(name) {
|
|
|
5
5
|
Marker.displayName = `ExpoUI${name}`;
|
|
6
6
|
return Marker;
|
|
7
7
|
}
|
|
8
|
+
function isMarkerType(candidate, type) {
|
|
9
|
+
if (candidate === type) return true;
|
|
10
|
+
const wanted = type.displayName;
|
|
11
|
+
if (!wanted) return false;
|
|
12
|
+
return typeof candidate === "function" && candidate.displayName === wanted;
|
|
13
|
+
}
|
|
8
14
|
function elementOfType(children, type) {
|
|
9
15
|
for (const child of React.Children.toArray(children)) {
|
|
10
|
-
if (React.isValidElement(child) && child.type
|
|
16
|
+
if (React.isValidElement(child) && isMarkerType(child.type, type)) {
|
|
11
17
|
return child;
|
|
12
18
|
}
|
|
13
19
|
}
|
|
@@ -111,12 +117,12 @@ function createExpoUIMenuAdapter({
|
|
|
111
117
|
}
|
|
112
118
|
for (const child of React.Children.toArray(childrenToParse)) {
|
|
113
119
|
if (!React.isValidElement(child)) continue;
|
|
114
|
-
if (child.type
|
|
120
|
+
if (isMarkerType(child.type, Separator)) {
|
|
115
121
|
if (!section) section = actions.splice(0);
|
|
116
122
|
flushSection();
|
|
117
123
|
continue;
|
|
118
124
|
}
|
|
119
|
-
if (child.type
|
|
125
|
+
if (isMarkerType(child.type, Group)) {
|
|
120
126
|
const label2 = elementOfType(child.props.children, Label);
|
|
121
127
|
append({
|
|
122
128
|
id: actionId(child),
|
|
@@ -126,7 +132,7 @@ function createExpoUIMenuAdapter({
|
|
|
126
132
|
});
|
|
127
133
|
continue;
|
|
128
134
|
}
|
|
129
|
-
if (child.type
|
|
135
|
+
if (isMarkerType(child.type, Sub)) {
|
|
130
136
|
const subTrigger = elementOfType(child.props.children, SubTrigger);
|
|
131
137
|
const subContent = elementOfType(child.props.children, SubContent);
|
|
132
138
|
if (!subTrigger || !subContent) {
|
|
@@ -141,12 +147,12 @@ function createExpoUIMenuAdapter({
|
|
|
141
147
|
});
|
|
142
148
|
continue;
|
|
143
149
|
}
|
|
144
|
-
if (child.type
|
|
150
|
+
if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem)) continue;
|
|
145
151
|
if (elementOfType(child.props.children, ItemSubtitle)) {
|
|
146
152
|
throw new Error("@expo/ui/community/menu does not support menu item subtitles");
|
|
147
153
|
}
|
|
148
154
|
const id = actionId(child);
|
|
149
|
-
if (child.type
|
|
155
|
+
if (isMarkerType(child.type, CheckboxItem)) {
|
|
150
156
|
const current = child.props.value === true || child.props.value === "on" || child.props.checked === true;
|
|
151
157
|
const onValueChange = child.props.onValueChange;
|
|
152
158
|
const onCheckedChange = child.props.onCheckedChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","jsx","marker","name","Marker","displayName","
|
|
1
|
+
{"version":3,"names":["React","jsx","marker","name","Marker","displayName","isMarkerType","candidate","type","wanted","elementOfType","children","child","Children","toArray","isValidElement","textFromNode","node","String","props","map","join","createExpoUIMenuAdapter","MenuView","NativeMenuView","createModule","isContextMenu","Trigger","Content","Item","ItemTitle","ItemSubtitle","ItemIcon","ItemImage","ItemIndicator","Group","Label","Separator","Sub","SubTrigger","SubContent","CheckboxItem","Preview","Auxiliary","Root","onOpenChange","onOpenWillChange","trigger","content","preview","auxiliary","Error","nextId","handlers","Map","actionId","element","key","replace","itemTitle","textValue","title","actionImage","image","source","icon","ios","iosIconName","attributes","destructive","disabled","hidden","actionsFrom","childrenToParse","actions","section","append","action","push","flushSection","length","id","subactions","displayInline","splice","label","label2","subTrigger","subContent","current","value","checked","onValueChange","onCheckedChange","set","state","onSelect","triggerAction","shouldOpenOnLongPress","onPressAction","event","get","nativeEvent","onOpenMenu","onCloseMenu","Menu","ContextMenu"],"sources":["../../src/expoUIMenuAdapter.tsx"],"sourcesContent":[null],"mappings":"AACA,OAAOA,KAAA,MAAW;AA8RV,SAAAC,GAAA;AAzPR,SAASC,OAAOC,IAAA,EAA0C;EACxD,MAAMC,MAAA,GAASA,CAAA,KAAM;EACrBA,MAAA,CAAOC,WAAA,GAAc,SAASF,IAAI;EAClC,OAAOC,MAAA;AACT;AAEA,SAASE,aAAaC,SAAA,EAAoBC,IAAA,EAA2C;EACnF,IAAID,SAAA,KAAcC,IAAA,EAAM,OAAO;EAM/B,MAAMC,MAAA,GAAUD,IAAA,CAAkCH,WAAA;EAClD,IAAI,CAACI,MAAA,EAAQ,OAAO;EACpB,OACE,OAAOF,SAAA,KAAc,cACpBA,SAAA,CAAuCF,WAAA,KAAgBI,MAAA;AAE5D;AAEA,SAASC,cACPC,QAAA,EACAH,IAAA,EACkC;EAClC,WAAWI,KAAA,IAASZ,KAAA,CAAMa,QAAA,CAASC,OAAA,CAAQH,QAAQ,GAAG;IACpD,IAAIX,KAAA,CAAMe,cAAA,CAA4BH,KAAK,KAAKN,YAAA,CAAaM,KAAA,CAAMJ,IAAA,EAAMA,IAAI,GAAG;MAC9E,OAAOI,KAAA;IACT;EACF;EACA,OAAO;AACT;AAEA,SAASI,aAAaC,IAAA,EAAyB;EAC7C,IAAI,OAAOA,IAAA,KAAS,YAA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AK;UACxBD,YAAA,GAAe,KAAK;QACtB;QAEClC,QAAA,EAAAoC,OAAA,CAAQ5B,KAAA,CAAMR;MAAA,CACjB;IAEJ;IAEA,OAAO;MACLiC,IAAA;MACAjB,OAAA;MACAC,OAAA;MACAC,IAAA;MACAC,SAAA;MACAC,YAAA;MACAC,QAAA;MACAC,SAAA;MACAC,aAAA;MACAC,KAAA;MACAC,KAAA;MACAC,SAAA;MACAC,GAAA;MACAC,UAAA;MACAC,UAAA;MACAC,YAAA;MACAC,OAAA;MACAC;IACF;EACF;EAEA,OAAO;IACLxC,IAAA,EAAM;IACNsG,IAAA,EAAMhF,YAAA,CAAa,KAAK;IACxBiF,WAAA,EAAajF,YAAA,CAAa,IAAI;EAChC;AACF","ignoreList":[]}
|
|
@@ -12,6 +12,12 @@ function marker(name) {
|
|
|
12
12
|
Marker.displayName = `ExpoUI${name}`;
|
|
13
13
|
return Marker;
|
|
14
14
|
}
|
|
15
|
+
function isMarkerType(candidate, type) {
|
|
16
|
+
if (candidate === type) return true;
|
|
17
|
+
var wanted = type.displayName;
|
|
18
|
+
if (!wanted) return false;
|
|
19
|
+
return typeof candidate === "function" && candidate.displayName === wanted;
|
|
20
|
+
}
|
|
15
21
|
function elementOfType(children, type) {
|
|
16
22
|
var _iteratorNormalCompletion = true,
|
|
17
23
|
_didIteratorError = false,
|
|
@@ -19,7 +25,7 @@ function elementOfType(children, type) {
|
|
|
19
25
|
try {
|
|
20
26
|
for (var _iterator = React.Children.toArray(children)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
21
27
|
var child = _step.value;
|
|
22
|
-
if (/* @__PURE__ */React.isValidElement(child) && child.type
|
|
28
|
+
if (/* @__PURE__ */React.isValidElement(child) && isMarkerType(child.type, type)) {
|
|
23
29
|
return child;
|
|
24
30
|
}
|
|
25
31
|
}
|
|
@@ -144,12 +150,12 @@ function createExpoUIMenuAdapter(param) {
|
|
|
144
150
|
var _loop = function () {
|
|
145
151
|
var child = _step.value;
|
|
146
152
|
if (! /* @__PURE__ */React.isValidElement(child)) return "continue";
|
|
147
|
-
if (child.type
|
|
153
|
+
if (isMarkerType(child.type, Separator)) {
|
|
148
154
|
if (!section) section = actions.splice(0);
|
|
149
155
|
flushSection();
|
|
150
156
|
return "continue";
|
|
151
157
|
}
|
|
152
|
-
if (child.type
|
|
158
|
+
if (isMarkerType(child.type, Group)) {
|
|
153
159
|
var label2 = elementOfType(child.props.children, Label);
|
|
154
160
|
append({
|
|
155
161
|
id: actionId(child),
|
|
@@ -159,7 +165,7 @@ function createExpoUIMenuAdapter(param) {
|
|
|
159
165
|
});
|
|
160
166
|
return "continue";
|
|
161
167
|
}
|
|
162
|
-
if (child.type
|
|
168
|
+
if (isMarkerType(child.type, Sub)) {
|
|
163
169
|
var subTrigger = elementOfType(child.props.children, SubTrigger);
|
|
164
170
|
var subContent = elementOfType(child.props.children, SubContent);
|
|
165
171
|
if (!subTrigger || !subContent) {
|
|
@@ -174,12 +180,12 @@ function createExpoUIMenuAdapter(param) {
|
|
|
174
180
|
});
|
|
175
181
|
return "continue";
|
|
176
182
|
}
|
|
177
|
-
if (child.type
|
|
183
|
+
if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem)) return "continue";
|
|
178
184
|
if (elementOfType(child.props.children, ItemSubtitle)) {
|
|
179
185
|
throw new Error("@expo/ui/community/menu does not support menu item subtitles");
|
|
180
186
|
}
|
|
181
187
|
var id = actionId(child);
|
|
182
|
-
if (child.type
|
|
188
|
+
if (isMarkerType(child.type, CheckboxItem)) {
|
|
183
189
|
var current = child.props.value === true || child.props.value === "on" || child.props.checked === true;
|
|
184
190
|
var onValueChange = child.props.onValueChange;
|
|
185
191
|
var onCheckedChange = child.props.onCheckedChange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","React","_type_of","obj","Symbol","constructor","marker","name","Marker","displayName","
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","React","_type_of","obj","Symbol","constructor","marker","name","Marker","displayName","isMarkerType","candidate","type","wanted","elementOfType","children","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Children","toArray","iterator","_step","next","done","child","value","isValidElement","err","return","textFromNode","node","String","props","map","join","createExpoUIMenuAdapter","param","MenuView","NativeMenuView","createModule","isContextMenu","Trigger","Content","Item","ItemTitle","ItemSubtitle","ItemIcon","ItemImage","ItemIndicator","Group","Label","Separator","Sub","SubTrigger","SubContent","CheckboxItem","Preview","Auxiliary","Root","param2","onOpenChange","onOpenWillChange","trigger","content","preview","auxiliary","Error","nextId","handlers","Map","actionId","element","key","replace","itemTitle","textValue","title","actionImage","image","source","icon","ios","iosIconName","attributes","destructive","disabled","hidden","actionsFrom","childrenToParse","actions","section","append","action","push","flushSection","length","id","subactions","displayInline","_loop","splice","label2","subTrigger","subContent","current","checked","onValueChange","onCheckedChange","set","state","onSelect","label","triggerAction","shouldOpenOnLongPress","onPressAction","event","_handlers_get","get","nativeEvent","onOpenMenu"],"sources":["../../src/expoUIMenuAdapter.tsx"],"sourcesContent":[null],"mappings":"AACA,SAAOA,GAAA,IAAAC,IAAW;AA8RV,OAAAC,KAAA;AAzPR,SAASC,QAAOA,CAAAC,GAAA,EAA0C;EACxD,uBAAqB;;EACrB,OAAOA,GAAA,WAAcC,MAAA,KAAS,WAAI,IAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAClC;AACF,SAAAG,OAAAC,IAAA;EAEA,IAAAC,MAAS,YAAAA,CAAA,EAAa;IACpB,OAAI;EAMJ;EACAA,MAAK,CAAAC,WAAQ,GAAO,SAAAF,IAAA;EACpB,OACEC,MAAA;AAGJ;AAEA,SAASE,aAAAC,SACP,EACAC,IAAA,EACkC;EAClC,IAAAD,SAAW,KAAAC,IAAS,SAAM,IAAS;EACjC,IAAAC,MAAI,GAAMD,IAAA,CAAAH,WAA4B;EACpC,KAAAI,MAAO;EAAA,OACT,OAAAF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Ab,iBAAA;cACA,MAAAC,cAAA;YACA;UACA;QACA;QACA,IAAA0E,OAAA,EAAAI,YAAA;QACA,OAAAL,OAAA;MACA;MACA,IAAAsB,KAAA,GAAAnG,aAAA,CAAAmD,OAAA,CAAA/B,KAAA,CAAAnB,QAAA,EAAAqC,KAAA;MACA,IAAA8D,aAAA,GAAAlD,OAAA,CAAA9B,KAAA,CAAA4D,MAAA;MACA,sBAAA9F,IAAA,CAAAwC,cAAA;QACAmD,OAAA,EAAAF,WAAA,CAAAxB,OAAA,CAAA/B,KAAA,CAAAnB,QAAA;QACF+D,KAAA,EAAAmC,KAAA,GAAAlF,YAAA,CAAAkF,KAAA,CAAA/E,KAAA,CAAAnB,QAAA;QACFoG,qBAAA,EAAAD,aAAA,oBAAAA,aAAA,gBAAAxE,aAAA;QAEA0E,aAAO,WAAAA,CAAAC,KAAA;UACC,IAAAC,aAAA;UACA,QAAAA,aAAkB,GAAAhD,QAAA,CAAAiD,GAAA,CAAAF,KAAA,CAAAG,WAAA,CAAAH,KAAA,eAAAC,aAAA,uBAAAA,aAAA;QACxB;QACFG,UAAA,WAAAA,CAAA;UACF1D,gBAAA,aAAAA,gBAAA,uBAAAA,gBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/native",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Native setup modules for Tamagui - portals, gesture handler, worklets, and more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"clean:build": "tamagui-build clean:build"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@tamagui/build": "2.7.
|
|
159
|
+
"@tamagui/build": "2.7.1",
|
|
160
160
|
"burnt": "^0.12.2",
|
|
161
161
|
"react": ">=19",
|
|
162
162
|
"react-native": "0.83.2",
|
|
@@ -42,12 +42,27 @@ function marker(name: string): ComponentType<MarkerProps> {
|
|
|
42
42
|
return Marker
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
function isMarkerType(candidate: unknown, type: ComponentType<MarkerProps>): boolean {
|
|
46
|
+
if (candidate === type) return true
|
|
47
|
+
// createMenu runs every native component through withNativeMenu, which wraps
|
|
48
|
+
// it in a new function component and copies the marker's displayName onto the
|
|
49
|
+
// wrapper. that wrapper is a different reference, so an identity-only check
|
|
50
|
+
// matches nothing and every item silently comes back with an empty title, no
|
|
51
|
+
// icon, and no submenu. fall back to the (unique, ExpoUI-prefixed) name.
|
|
52
|
+
const wanted = (type as { displayName?: string }).displayName
|
|
53
|
+
if (!wanted) return false
|
|
54
|
+
return (
|
|
55
|
+
typeof candidate === 'function' &&
|
|
56
|
+
(candidate as { displayName?: string }).displayName === wanted
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
function elementOfType(
|
|
46
61
|
children: ReactNode,
|
|
47
62
|
type: ComponentType<MarkerProps>
|
|
48
63
|
): ReactElement<MarkerProps> | null {
|
|
49
64
|
for (const child of React.Children.toArray(children)) {
|
|
50
|
-
if (React.isValidElement<MarkerProps>(child) && child.type
|
|
65
|
+
if (React.isValidElement<MarkerProps>(child) && isMarkerType(child.type, type)) {
|
|
51
66
|
return child
|
|
52
67
|
}
|
|
53
68
|
}
|
|
@@ -181,13 +196,13 @@ export function createExpoUIMenuAdapter({
|
|
|
181
196
|
for (const child of React.Children.toArray(childrenToParse)) {
|
|
182
197
|
if (!React.isValidElement<MarkerProps>(child)) continue
|
|
183
198
|
|
|
184
|
-
if (child.type
|
|
199
|
+
if (isMarkerType(child.type, Separator)) {
|
|
185
200
|
if (!section) section = actions.splice(0)
|
|
186
201
|
flushSection()
|
|
187
202
|
continue
|
|
188
203
|
}
|
|
189
204
|
|
|
190
|
-
if (child.type
|
|
205
|
+
if (isMarkerType(child.type, Group)) {
|
|
191
206
|
const label = elementOfType(child.props.children, Label)
|
|
192
207
|
append({
|
|
193
208
|
id: actionId(child),
|
|
@@ -198,7 +213,7 @@ export function createExpoUIMenuAdapter({
|
|
|
198
213
|
continue
|
|
199
214
|
}
|
|
200
215
|
|
|
201
|
-
if (child.type
|
|
216
|
+
if (isMarkerType(child.type, Sub)) {
|
|
202
217
|
const subTrigger = elementOfType(child.props.children, SubTrigger)
|
|
203
218
|
const subContent = elementOfType(child.props.children, SubContent)
|
|
204
219
|
if (!subTrigger || !subContent) {
|
|
@@ -216,7 +231,8 @@ export function createExpoUIMenuAdapter({
|
|
|
216
231
|
continue
|
|
217
232
|
}
|
|
218
233
|
|
|
219
|
-
if (child.type
|
|
234
|
+
if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem))
|
|
235
|
+
continue
|
|
220
236
|
|
|
221
237
|
if (elementOfType(child.props.children, ItemSubtitle)) {
|
|
222
238
|
throw new Error(
|
|
@@ -225,7 +241,7 @@ export function createExpoUIMenuAdapter({
|
|
|
225
241
|
}
|
|
226
242
|
|
|
227
243
|
const id = actionId(child)
|
|
228
|
-
if (child.type
|
|
244
|
+
if (isMarkerType(child.type, CheckboxItem)) {
|
|
229
245
|
const current =
|
|
230
246
|
child.props.value === true ||
|
|
231
247
|
child.props.value === 'on' ||
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "AAAA,cAAc,qBAA8C;AAG5D,cAAc,yBAA2C;AA0BzD,YAAY,2BAA2B;CACrC,UAAU;;
|
|
2
|
+
"mappings": "AAAA,cAAc,qBAA8C;AAG5D,cAAc,yBAA2C;AA0BzD,YAAY,2BAA2B;CACrC,UAAU;;AA+CZ,OAAO,iBAAS,wBAAwB,EACtC,YACC,2BAA2B",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/expoUIMenuAdapter.tsx"
|
|
6
6
|
],
|
|
7
7
|
"version": 3,
|
|
8
8
|
"sourcesContent": [
|
|
9
|
-
"import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport React from 'react'\n\nimport type { NativeMenuAdapter, NativeMenuModule } from './nativeMenuState'\n\ntype ExpoMenuAction = {\n id: string\n title: string\n image?: unknown\n state?: 'on' | 'off'\n attributes?: {\n destructive?: boolean\n disabled?: boolean\n hidden?: boolean\n }\n subactions?: ExpoMenuAction[]\n displayInline?: boolean\n}\n\ntype ExpoMenuViewProps = {\n actions: ExpoMenuAction[]\n title?: string\n shouldOpenOnLongPress?: boolean\n onPressAction?: (event: { nativeEvent: { event: string } }) => void\n onOpenMenu?: () => void\n onCloseMenu?: () => void\n children?: ReactNode\n}\n\nexport type ExpoUIMenuAdapterOptions = {\n MenuView: ComponentType<any>\n}\n\ntype MarkerProps = {\n children?: ReactNode\n [key: string]: unknown\n}\n\nfunction marker(name: string): ComponentType<MarkerProps> {\n const Marker = () => null\n Marker.displayName = `ExpoUI${name}`\n return Marker\n}\n\nfunction elementOfType(\n children: ReactNode,\n type: ComponentType<MarkerProps>\n): ReactElement<MarkerProps> | null {\n for (const child of React.Children.toArray(children)) {\n if (React.isValidElement<MarkerProps>(child) && child.type === type) {\n return child\n }\n }\n return null\n}\n\nfunction textFromNode(node: ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') return String(node)\n if (!React.isValidElement<MarkerProps>(node)) return ''\n return React.Children.toArray(node.props.children).map(textFromNode).join('')\n}\n\nexport function createExpoUIMenuAdapter({\n MenuView,\n}: ExpoUIMenuAdapterOptions): NativeMenuAdapter {\n const NativeMenuView: ComponentType<ExpoMenuViewProps> = MenuView\n\n function createModule(isContextMenu: boolean): NativeMenuModule {\n const Trigger = marker('Trigger')\n const Content = marker('Content')\n const Item = marker('Item')\n const ItemTitle = marker('ItemTitle')\n const ItemSubtitle = marker('ItemSubtitle')\n const ItemIcon = marker('ItemIcon')\n const ItemImage = marker('ItemImage')\n const ItemIndicator = marker('ItemIndicator')\n const Group = marker('Group')\n const Label = marker('Label')\n const Separator = marker('Separator')\n const Sub = marker('Sub')\n const SubTrigger = marker('SubTrigger')\n const SubContent = marker('SubContent')\n const CheckboxItem = marker('CheckboxItem')\n const Preview = marker('Preview')\n const Auxiliary = marker('Auxiliary')\n\n function Root({\n children,\n onOpenChange,\n onOpenWillChange,\n }: {\n children?: ReactNode\n onOpenChange?: (open: boolean) => void\n onOpenWillChange?: (open: boolean) => void\n }) {\n const trigger = elementOfType(children, Trigger)\n const content = elementOfType(children, Content)\n const preview = elementOfType(children, Preview)\n const auxiliary = elementOfType(children, Auxiliary)\n\n if (preview || auxiliary) {\n throw new Error(\n '@expo/ui/community/menu does not support Tamagui context-menu previews or auxiliary views'\n )\n }\n if (!trigger || !content) {\n throw new Error('Tamagui native menus require one Trigger and one Content')\n }\n\n let nextId = 0\n const handlers = new Map<string, () => void>()\n\n function actionId(element: ReactElement<MarkerProps>): string {\n return element.key == null\n ? `tamagui-menu-${nextId++}`\n : String(element.key).replace(/^\\.\\$/, '')\n }\n\n function itemTitle(element: ReactElement<MarkerProps>): string {\n if (typeof element.props.textValue === 'string') return element.props.textValue\n const title = elementOfType(element.props.children, ItemTitle)\n return title ? textFromNode(title.props.children) : ''\n }\n\n function actionImage(element: ReactElement<MarkerProps>): unknown {\n const image = elementOfType(element.props.children, ItemImage)\n if (image?.props.source) return image.props.source\n const icon = elementOfType(element.props.children, ItemIcon)\n if (!icon) return undefined\n const ios = icon.props.ios\n if (\n typeof ios === 'object' &&\n ios &&\n 'name' in ios &&\n typeof ios.name === 'string'\n ) {\n return ios.name\n }\n return typeof icon.props.iosIconName === 'string'\n ? icon.props.iosIconName\n : undefined\n }\n\n function attributes(\n element: ReactElement<MarkerProps>\n ): ExpoMenuAction['attributes'] {\n const destructive = element.props.destructive === true\n const disabled = element.props.disabled === true\n const hidden = element.props.hidden === true\n return destructive || disabled || hidden\n ? { destructive, disabled, hidden }\n : undefined\n }\n\n function actionsFrom(childrenToParse: ReactNode): ExpoMenuAction[] {\n const actions: ExpoMenuAction[] = []\n let section: ExpoMenuAction[] | null = null\n\n function append(action: ExpoMenuAction) {\n if (section) {\n section.push(action)\n } else {\n actions.push(action)\n }\n }\n\n function flushSection() {\n if (!section?.length) {\n section = []\n return\n }\n actions.push({\n id: `tamagui-menu-section-${nextId++}`,\n title: '',\n subactions: section,\n displayInline: true,\n })\n section = []\n }\n\n for (const child of React.Children.toArray(childrenToParse)) {\n if (!React.isValidElement<MarkerProps>(child)) continue\n\n if (child.type === Separator) {\n if (!section) section = actions.splice(0)\n flushSection()\n continue\n }\n\n if (child.type === Group) {\n const label = elementOfType(child.props.children, Label)\n append({\n id: actionId(child),\n title: label ? textFromNode(label.props.children) : '',\n subactions: actionsFrom(child.props.children),\n displayInline: true,\n })\n continue\n }\n\n if (child.type === Sub) {\n const subTrigger = elementOfType(child.props.children, SubTrigger)\n const subContent = elementOfType(child.props.children, SubContent)\n if (!subTrigger || !subContent) {\n throw new Error(\n 'Tamagui native submenus require one SubTrigger and SubContent'\n )\n }\n append({\n id: actionId(child),\n title: itemTitle(subTrigger),\n image: actionImage(subTrigger),\n attributes: attributes(subTrigger),\n subactions: actionsFrom(subContent.props.children),\n })\n continue\n }\n\n if (child.type !== Item && child.type !== CheckboxItem) continue\n\n if (elementOfType(child.props.children, ItemSubtitle)) {\n throw new Error(\n '@expo/ui/community/menu does not support menu item subtitles'\n )\n }\n\n const id = actionId(child)\n if (child.type === CheckboxItem) {\n const current =\n child.props.value === true ||\n child.props.value === 'on' ||\n child.props.checked === true\n const onValueChange = child.props.onValueChange\n const onCheckedChange = child.props.onCheckedChange\n handlers.set(id, () => {\n if (typeof onValueChange === 'function') {\n onValueChange(current ? 'off' : 'on', current ? 'on' : 'off')\n } else if (typeof onCheckedChange === 'function') {\n onCheckedChange(!current)\n }\n })\n append({\n id,\n title: itemTitle(child),\n image: actionImage(child),\n state: current ? 'on' : 'off',\n attributes: attributes(child),\n })\n continue\n }\n\n const onSelect = child.props.onSelect\n if (typeof onSelect === 'function') {\n handlers.set(id, () => onSelect())\n }\n append({\n id,\n title: itemTitle(child),\n image: actionImage(child),\n attributes: attributes(child),\n })\n }\n\n if (section) flushSection()\n return actions\n }\n\n const label = elementOfType(content.props.children, Label)\n const triggerAction = trigger.props.action\n\n return (\n <NativeMenuView\n actions={actionsFrom(content.props.children)}\n title={label ? textFromNode(label.props.children) : undefined}\n shouldOpenOnLongPress={\n triggerAction === 'longPress' || (triggerAction !== 'press' && isContextMenu)\n }\n onPressAction={(event) => handlers.get(event.nativeEvent.event)?.()}\n onOpenMenu={() => {\n onOpenWillChange?.(true)\n onOpenChange?.(true)\n }}\n onCloseMenu={() => {\n onOpenWillChange?.(false)\n onOpenChange?.(false)\n }}\n >\n {trigger.props.children}\n </NativeMenuView>\n )\n }\n\n return {\n Root,\n Trigger,\n Content,\n Item,\n ItemTitle,\n ItemSubtitle,\n ItemIcon,\n ItemImage,\n ItemIndicator,\n Group,\n Label,\n Separator,\n Sub,\n SubTrigger,\n SubContent,\n CheckboxItem,\n Preview,\n Auxiliary,\n }\n }\n\n return {\n name: 'expo-ui',\n Menu: createModule(false),\n ContextMenu: createModule(true),\n }\n}\n"
|
|
9
|
+
"import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport React from 'react'\n\nimport type { NativeMenuAdapter, NativeMenuModule } from './nativeMenuState'\n\ntype ExpoMenuAction = {\n id: string\n title: string\n image?: unknown\n state?: 'on' | 'off'\n attributes?: {\n destructive?: boolean\n disabled?: boolean\n hidden?: boolean\n }\n subactions?: ExpoMenuAction[]\n displayInline?: boolean\n}\n\ntype ExpoMenuViewProps = {\n actions: ExpoMenuAction[]\n title?: string\n shouldOpenOnLongPress?: boolean\n onPressAction?: (event: { nativeEvent: { event: string } }) => void\n onOpenMenu?: () => void\n onCloseMenu?: () => void\n children?: ReactNode\n}\n\nexport type ExpoUIMenuAdapterOptions = {\n MenuView: ComponentType<any>\n}\n\ntype MarkerProps = {\n children?: ReactNode\n [key: string]: unknown\n}\n\nfunction marker(name: string): ComponentType<MarkerProps> {\n const Marker = () => null\n Marker.displayName = `ExpoUI${name}`\n return Marker\n}\n\nfunction isMarkerType(candidate: unknown, type: ComponentType<MarkerProps>): boolean {\n if (candidate === type) return true\n // createMenu runs every native component through withNativeMenu, which wraps\n // it in a new function component and copies the marker's displayName onto the\n // wrapper. that wrapper is a different reference, so an identity-only check\n // matches nothing and every item silently comes back with an empty title, no\n // icon, and no submenu. fall back to the (unique, ExpoUI-prefixed) name.\n const wanted = (type as { displayName?: string }).displayName\n if (!wanted) return false\n return (\n typeof candidate === 'function' &&\n (candidate as { displayName?: string }).displayName === wanted\n )\n}\n\nfunction elementOfType(\n children: ReactNode,\n type: ComponentType<MarkerProps>\n): ReactElement<MarkerProps> | null {\n for (const child of React.Children.toArray(children)) {\n if (React.isValidElement<MarkerProps>(child) && isMarkerType(child.type, type)) {\n return child\n }\n }\n return null\n}\n\nfunction textFromNode(node: ReactNode): string {\n if (typeof node === 'string' || typeof node === 'number') return String(node)\n if (!React.isValidElement<MarkerProps>(node)) return ''\n return React.Children.toArray(node.props.children).map(textFromNode).join('')\n}\n\nexport function createExpoUIMenuAdapter({\n MenuView,\n}: ExpoUIMenuAdapterOptions): NativeMenuAdapter {\n const NativeMenuView: ComponentType<ExpoMenuViewProps> = MenuView\n\n function createModule(isContextMenu: boolean): NativeMenuModule {\n const Trigger = marker('Trigger')\n const Content = marker('Content')\n const Item = marker('Item')\n const ItemTitle = marker('ItemTitle')\n const ItemSubtitle = marker('ItemSubtitle')\n const ItemIcon = marker('ItemIcon')\n const ItemImage = marker('ItemImage')\n const ItemIndicator = marker('ItemIndicator')\n const Group = marker('Group')\n const Label = marker('Label')\n const Separator = marker('Separator')\n const Sub = marker('Sub')\n const SubTrigger = marker('SubTrigger')\n const SubContent = marker('SubContent')\n const CheckboxItem = marker('CheckboxItem')\n const Preview = marker('Preview')\n const Auxiliary = marker('Auxiliary')\n\n function Root({\n children,\n onOpenChange,\n onOpenWillChange,\n }: {\n children?: ReactNode\n onOpenChange?: (open: boolean) => void\n onOpenWillChange?: (open: boolean) => void\n }) {\n const trigger = elementOfType(children, Trigger)\n const content = elementOfType(children, Content)\n const preview = elementOfType(children, Preview)\n const auxiliary = elementOfType(children, Auxiliary)\n\n if (preview || auxiliary) {\n throw new Error(\n '@expo/ui/community/menu does not support Tamagui context-menu previews or auxiliary views'\n )\n }\n if (!trigger || !content) {\n throw new Error('Tamagui native menus require one Trigger and one Content')\n }\n\n let nextId = 0\n const handlers = new Map<string, () => void>()\n\n function actionId(element: ReactElement<MarkerProps>): string {\n return element.key == null\n ? `tamagui-menu-${nextId++}`\n : String(element.key).replace(/^\\.\\$/, '')\n }\n\n function itemTitle(element: ReactElement<MarkerProps>): string {\n if (typeof element.props.textValue === 'string') return element.props.textValue\n const title = elementOfType(element.props.children, ItemTitle)\n return title ? textFromNode(title.props.children) : ''\n }\n\n function actionImage(element: ReactElement<MarkerProps>): unknown {\n const image = elementOfType(element.props.children, ItemImage)\n if (image?.props.source) return image.props.source\n const icon = elementOfType(element.props.children, ItemIcon)\n if (!icon) return undefined\n const ios = icon.props.ios\n if (\n typeof ios === 'object' &&\n ios &&\n 'name' in ios &&\n typeof ios.name === 'string'\n ) {\n return ios.name\n }\n return typeof icon.props.iosIconName === 'string'\n ? icon.props.iosIconName\n : undefined\n }\n\n function attributes(\n element: ReactElement<MarkerProps>\n ): ExpoMenuAction['attributes'] {\n const destructive = element.props.destructive === true\n const disabled = element.props.disabled === true\n const hidden = element.props.hidden === true\n return destructive || disabled || hidden\n ? { destructive, disabled, hidden }\n : undefined\n }\n\n function actionsFrom(childrenToParse: ReactNode): ExpoMenuAction[] {\n const actions: ExpoMenuAction[] = []\n let section: ExpoMenuAction[] | null = null\n\n function append(action: ExpoMenuAction) {\n if (section) {\n section.push(action)\n } else {\n actions.push(action)\n }\n }\n\n function flushSection() {\n if (!section?.length) {\n section = []\n return\n }\n actions.push({\n id: `tamagui-menu-section-${nextId++}`,\n title: '',\n subactions: section,\n displayInline: true,\n })\n section = []\n }\n\n for (const child of React.Children.toArray(childrenToParse)) {\n if (!React.isValidElement<MarkerProps>(child)) continue\n\n if (isMarkerType(child.type, Separator)) {\n if (!section) section = actions.splice(0)\n flushSection()\n continue\n }\n\n if (isMarkerType(child.type, Group)) {\n const label = elementOfType(child.props.children, Label)\n append({\n id: actionId(child),\n title: label ? textFromNode(label.props.children) : '',\n subactions: actionsFrom(child.props.children),\n displayInline: true,\n })\n continue\n }\n\n if (isMarkerType(child.type, Sub)) {\n const subTrigger = elementOfType(child.props.children, SubTrigger)\n const subContent = elementOfType(child.props.children, SubContent)\n if (!subTrigger || !subContent) {\n throw new Error(\n 'Tamagui native submenus require one SubTrigger and SubContent'\n )\n }\n append({\n id: actionId(child),\n title: itemTitle(subTrigger),\n image: actionImage(subTrigger),\n attributes: attributes(subTrigger),\n subactions: actionsFrom(subContent.props.children),\n })\n continue\n }\n\n if (!isMarkerType(child.type, Item) && !isMarkerType(child.type, CheckboxItem))\n continue\n\n if (elementOfType(child.props.children, ItemSubtitle)) {\n throw new Error(\n '@expo/ui/community/menu does not support menu item subtitles'\n )\n }\n\n const id = actionId(child)\n if (isMarkerType(child.type, CheckboxItem)) {\n const current =\n child.props.value === true ||\n child.props.value === 'on' ||\n child.props.checked === true\n const onValueChange = child.props.onValueChange\n const onCheckedChange = child.props.onCheckedChange\n handlers.set(id, () => {\n if (typeof onValueChange === 'function') {\n onValueChange(current ? 'off' : 'on', current ? 'on' : 'off')\n } else if (typeof onCheckedChange === 'function') {\n onCheckedChange(!current)\n }\n })\n append({\n id,\n title: itemTitle(child),\n image: actionImage(child),\n state: current ? 'on' : 'off',\n attributes: attributes(child),\n })\n continue\n }\n\n const onSelect = child.props.onSelect\n if (typeof onSelect === 'function') {\n handlers.set(id, () => onSelect())\n }\n append({\n id,\n title: itemTitle(child),\n image: actionImage(child),\n attributes: attributes(child),\n })\n }\n\n if (section) flushSection()\n return actions\n }\n\n const label = elementOfType(content.props.children, Label)\n const triggerAction = trigger.props.action\n\n return (\n <NativeMenuView\n actions={actionsFrom(content.props.children)}\n title={label ? textFromNode(label.props.children) : undefined}\n shouldOpenOnLongPress={\n triggerAction === 'longPress' || (triggerAction !== 'press' && isContextMenu)\n }\n onPressAction={(event) => handlers.get(event.nativeEvent.event)?.()}\n onOpenMenu={() => {\n onOpenWillChange?.(true)\n onOpenChange?.(true)\n }}\n onCloseMenu={() => {\n onOpenWillChange?.(false)\n onOpenChange?.(false)\n }}\n >\n {trigger.props.children}\n </NativeMenuView>\n )\n }\n\n return {\n Root,\n Trigger,\n Content,\n Item,\n ItemTitle,\n ItemSubtitle,\n ItemIcon,\n ItemImage,\n ItemIndicator,\n Group,\n Label,\n Separator,\n Sub,\n SubTrigger,\n SubContent,\n CheckboxItem,\n Preview,\n Auxiliary,\n }\n }\n\n return {\n name: 'expo-ui',\n Menu: createModule(false),\n ContextMenu: createModule(true),\n }\n}\n"
|
|
10
10
|
]
|
|
11
11
|
}
|