@kanso-labs/react-native-kanso-ui 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +4 -1
  2. package/dist/autocomplete/index.js +39 -0
  3. package/dist/autocomplete/index.js.map +1 -0
  4. package/dist/badge/index.js +74 -0
  5. package/dist/badge/index.js.map +1 -0
  6. package/dist/badge/styles.js +51 -0
  7. package/dist/badge/styles.js.map +1 -0
  8. package/dist/button/index.d.ts +2 -1
  9. package/dist/button/index.js +35 -2
  10. package/dist/button/index.js.map +1 -1
  11. package/dist/button/slots.d.ts +2 -1
  12. package/dist/button/slots.js.map +1 -1
  13. package/dist/chip/index.js +2 -2
  14. package/dist/components/app-bar/index.d.ts +111 -0
  15. package/dist/components/app-bar/index.js +341 -0
  16. package/dist/components/app-bar/index.js.map +1 -0
  17. package/dist/components/autocomplete/index.d.ts +49 -0
  18. package/dist/components/autocomplete/index.js +87 -0
  19. package/dist/components/autocomplete/index.js.map +1 -0
  20. package/dist/components/button/index.d.ts +1 -1
  21. package/dist/components/button/index.js +197 -151
  22. package/dist/components/button/index.js.map +1 -1
  23. package/dist/components/card/index.js +2 -2
  24. package/dist/components/checkbox/index.js +106 -193
  25. package/dist/components/checkbox/index.js.map +1 -1
  26. package/dist/components/chip/index.js +1 -1
  27. package/dist/components/chip-group/index.js +3 -3
  28. package/dist/components/dialog/index.js +4 -3
  29. package/dist/components/dialog/index.js.map +1 -1
  30. package/dist/components/icon-button/index.d.ts +1 -1
  31. package/dist/components/icon-button/index.js +206 -160
  32. package/dist/components/icon-button/index.js.map +1 -1
  33. package/dist/components/link/index.js +2 -2
  34. package/dist/components/list/index.d.ts +216 -0
  35. package/dist/components/list/index.js +1118 -0
  36. package/dist/components/list/index.js.map +1 -0
  37. package/dist/components/list-detail/index.d.ts +56 -0
  38. package/dist/components/list-detail/index.js +169 -0
  39. package/dist/components/list-detail/index.js.map +1 -0
  40. package/dist/components/list-item/index.d.ts +63 -0
  41. package/dist/components/list-item/index.js +275 -0
  42. package/dist/components/list-item/index.js.map +1 -0
  43. package/dist/components/menu/index.d.ts +309 -0
  44. package/dist/components/menu/index.js +1283 -0
  45. package/dist/components/menu/index.js.map +1 -0
  46. package/dist/components/navigation-bar/index.d.ts +170 -0
  47. package/dist/components/navigation-bar/index.js +494 -0
  48. package/dist/components/navigation-bar/index.js.map +1 -0
  49. package/dist/components/number-field/index.js +3 -3
  50. package/dist/components/popover/index.d.ts +140 -0
  51. package/dist/components/popover/index.js +704 -0
  52. package/dist/components/popover/index.js.map +1 -0
  53. package/dist/components/progress-indicator/index.js +3 -3
  54. package/dist/components/radio-group/index.js +2 -2
  55. package/dist/components/search-field/index.d.ts +11 -3
  56. package/dist/components/search-field/index.js +66 -60
  57. package/dist/components/search-field/index.js.map +1 -1
  58. package/dist/components/segmented-button/index.js +4 -4
  59. package/dist/components/sheet/index.js +5 -4
  60. package/dist/components/sheet/index.js.map +1 -1
  61. package/dist/components/snackbar/index.js +4 -4
  62. package/dist/components/switch/index.js +3 -3
  63. package/dist/control/checkbox-box.js +137 -0
  64. package/dist/control/checkbox-box.js.map +1 -0
  65. package/dist/field/index.d.ts +1 -1
  66. package/dist/field/index.js +3 -3
  67. package/dist/form/index.d.ts +1 -1
  68. package/dist/glyphs/index.js +22 -3
  69. package/dist/glyphs/index.js.map +1 -1
  70. package/dist/hooks/useAppBarScroll.d.ts +56 -0
  71. package/dist/hooks/useAppBarScroll.js +87 -0
  72. package/dist/hooks/useAppBarScroll.js.map +1 -0
  73. package/dist/i18n/index.js +16 -1
  74. package/dist/i18n/index.js.map +1 -1
  75. package/dist/i18n/messages.js +272 -34
  76. package/dist/i18n/messages.js.map +1 -1
  77. package/dist/index.d.ts +12 -3
  78. package/dist/index.js +12 -3
  79. package/dist/indicator/index.d.ts +2 -2
  80. package/dist/indicator/index.js +1 -1
  81. package/dist/indicator/motion.js +1 -1
  82. package/dist/mark/index.js +1 -1
  83. package/dist/modal/index.d.ts +1 -1
  84. package/dist/modal/index.js +2 -9
  85. package/dist/modal/index.js.map +1 -1
  86. package/dist/navigation/index.d.ts +29 -0
  87. package/dist/navigation/index.js +405 -0
  88. package/dist/navigation/index.js.map +1 -0
  89. package/dist/navigation/styles.js +61 -0
  90. package/dist/navigation/styles.js.map +1 -0
  91. package/dist/overlay/anchored.d.ts +2 -0
  92. package/dist/overlay/anchored.js +182 -0
  93. package/dist/overlay/anchored.js.map +1 -0
  94. package/dist/overlay/host.d.ts +2 -0
  95. package/dist/overlay/index.d.ts +4 -0
  96. package/dist/overlay/panel.js +215 -0
  97. package/dist/overlay/panel.js.map +1 -0
  98. package/dist/overlay/placement.d.ts +8 -0
  99. package/dist/overlay/placement.js +87 -0
  100. package/dist/overlay/placement.js.map +1 -0
  101. package/dist/press/index.js +74 -68
  102. package/dist/press/index.js.map +1 -1
  103. package/dist/ref/index.js +15 -0
  104. package/dist/ref/index.js.map +1 -0
  105. package/dist/row/index.js +158 -0
  106. package/dist/row/index.js.map +1 -0
  107. package/dist/row/styles.js +51 -0
  108. package/dist/row/styles.js.map +1 -0
  109. package/package.json +3 -3
@@ -0,0 +1,1283 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { usePressFeedback } from "../../press/index.js";
4
+ import { useTypeRole } from "../../typography/roles.js";
5
+ import { rowContentColor, rowStyles } from "../../row/styles.js";
6
+ import { RowContent, rowStyleOf } from "../../row/index.js";
7
+ import { CheckGlyph, ChevronEndGlyph } from "../../glyphs/index.js";
8
+ import { refsOf } from "../../ref/index.js";
9
+ import { useOpenLink } from "../../router/index.js";
10
+ import { ButtonSlotContext } from "../../button/slots.js";
11
+ import { ProgressIndicator } from "../progress-indicator/index.js";
12
+ import { messagesFor } from "../../i18n/index.js";
13
+ import { Overlay } from "../../overlay/host.js";
14
+ import { useAnchoredPlacement } from "../../overlay/anchored.js";
15
+ import { DismissLayer, PANEL_ORIGINS, useBackToClose, useFocusOnPlaced, usePanelMotion, useReturnFocus } from "../../overlay/panel.js";
16
+ import { Separator } from "../separator/index.js";
17
+ import { c } from "react/compiler-runtime";
18
+ import { I18nManager, Platform, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
19
+ import Animated from "react-native-reanimated";
20
+ import { Children, createContext, use, useEffect, useId, useRef, useState } from "react";
21
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
22
+ import { useMenuTriggerState, useSubmenuTriggerState } from "react-stately/useMenuTriggerState";
23
+ import { useTreeState } from "react-stately/useTreeState";
24
+ //#region src/components/menu/index.tsx
25
+ const MENU_MIN = 112;
26
+ const MENU_MAX = 280;
27
+ const CHECK_SIZE = 24;
28
+ const CHEVRON_SIZE = 20;
29
+ const LOADING_DIAMETER = "20px";
30
+ const HAS_SUBMENU = { "aria-haspopup": "menu" };
31
+ const styles = StyleSheet.create({
32
+ scroll: { flexGrow: 0 },
33
+ sentinel: { height: 0 }
34
+ });
35
+ const stylesOf = themedStyles(({ colors, radii, shadows, sizing, spacing }) => StyleSheet.create({
36
+ content: { paddingVertical: spacing.sm },
37
+ empty: { color: colors.onSurfaceVariant },
38
+ header: {
39
+ color: colors.onSurfaceVariant,
40
+ paddingBottom: spacing.xxs,
41
+ paddingHorizontal: spacing.lg,
42
+ paddingTop: spacing.md
43
+ },
44
+ loading: {
45
+ alignItems: "center",
46
+ justifyContent: "center",
47
+ minHeight: sizing.rowXs
48
+ },
49
+ separator: { marginVertical: spacing.sm },
50
+ surface: {
51
+ backgroundColor: colors.surfaceContainerLow,
52
+ borderRadius: radii.xs,
53
+ boxShadow: shadows.elevation2,
54
+ maxWidth: MENU_MAX,
55
+ minWidth: MENU_MIN,
56
+ overflow: "hidden"
57
+ }
58
+ }));
59
+ const LevelContext = createContext(null);
60
+ /**
61
+ * A list of actions or choices opened from a control. Pass `isOpen` with
62
+ * `onOpenChange` to hold the open state, or `defaultOpen` to let it keep its
63
+ * own.
64
+ *
65
+ * ```tsx
66
+ * <Menu>
67
+ * <Button variant="outlined">Open</Button>
68
+ * <Menu.Content>
69
+ * <Menu.Item id="first">First item</Menu.Item>
70
+ * </Menu.Content>
71
+ * </Menu>
72
+ * ```
73
+ *
74
+ * A `Button` or `IconButton` placed directly inside `Menu` is its trigger,
75
+ * and a press on it toggles the menu. Everything the menu shows goes in
76
+ * `Menu.Content`, since the trigger lives in the screen while the menu is
77
+ * drawn above it.
78
+ */
79
+ function Menu(t0) {
80
+ const $ = c(20);
81
+ const { children, defaultOpen, isOpen, onOpenChange, trigger: t1 } = t0;
82
+ const trigger = t1 === void 0 ? "press" : t1;
83
+ let t2;
84
+ if ($[0] !== defaultOpen || $[1] !== isOpen || $[2] !== onOpenChange || $[3] !== trigger) {
85
+ t2 = {
86
+ defaultOpen,
87
+ isOpen,
88
+ onOpenChange,
89
+ trigger
90
+ };
91
+ $[0] = defaultOpen;
92
+ $[1] = isOpen;
93
+ $[2] = onOpenChange;
94
+ $[3] = trigger;
95
+ $[4] = t2;
96
+ } else t2 = $[4];
97
+ const state = useMenuTriggerState(t2);
98
+ const anchor = useRef(null);
99
+ const openLink = useOpenLink();
100
+ let t3;
101
+ if ($[5] !== state) {
102
+ t3 = () => {
103
+ state.close();
104
+ };
105
+ $[5] = state;
106
+ $[6] = t3;
107
+ } else t3 = $[6];
108
+ const close = useLatest(t3);
109
+ let t4;
110
+ if ($[7] !== state || $[8] !== trigger) {
111
+ t4 = trigger === "longPress" ? { trigger: {
112
+ expanded: state.isOpen,
113
+ onLongPress: () => {
114
+ state.open();
115
+ },
116
+ ref: anchor
117
+ } } : {
118
+ default: () => {
119
+ state.toggle();
120
+ },
121
+ trigger: {
122
+ expanded: state.isOpen,
123
+ ref: anchor
124
+ }
125
+ };
126
+ $[7] = state;
127
+ $[8] = trigger;
128
+ $[9] = t4;
129
+ } else t4 = $[9];
130
+ const slots = t4;
131
+ let t5;
132
+ if ($[10] !== close || $[11] !== openLink || $[12] !== state) {
133
+ t5 = {
134
+ anchor,
135
+ close,
136
+ isOpen: state.isOpen,
137
+ openLink,
138
+ root: state,
139
+ submenu: false
140
+ };
141
+ $[10] = close;
142
+ $[11] = openLink;
143
+ $[12] = state;
144
+ $[13] = t5;
145
+ } else t5 = $[13];
146
+ const level = t5;
147
+ let t6;
148
+ if ($[14] !== children || $[15] !== slots) {
149
+ t6 = /* @__PURE__ */ jsx(ButtonSlotContext, {
150
+ value: slots,
151
+ children
152
+ });
153
+ $[14] = children;
154
+ $[15] = slots;
155
+ $[16] = t6;
156
+ } else t6 = $[16];
157
+ let t7;
158
+ if ($[17] !== level || $[18] !== t6) {
159
+ t7 = /* @__PURE__ */ jsx(LevelContext, {
160
+ value: level,
161
+ children: t6
162
+ });
163
+ $[17] = level;
164
+ $[18] = t6;
165
+ $[19] = t7;
166
+ } else t7 = $[19];
167
+ return t7;
168
+ }
169
+ /**
170
+ * The menu itself, and the surface it is drawn on. Its items scroll when they
171
+ * run past the room the window leaves on the side it opened on.
172
+ *
173
+ * A menu with nothing in it shows a muted "No results" row in place of its
174
+ * items; pass `renderEmptyState` to draw something else.
175
+ *
176
+ * `style`, `ref` and `testID` land on the surface.
177
+ */
178
+ function MenuContent(props) {
179
+ const $ = c(3);
180
+ const level = use(LevelContext);
181
+ if (level === null) throw new Error("Menu.Content is drawn inside Menu or Menu.Submenu.");
182
+ const { anchor, isOpen } = level;
183
+ const [present, setPresent] = useState(isOpen);
184
+ if (isOpen && !present) setPresent(true);
185
+ useReturnFocus(present, false, anchor);
186
+ if (!present) return null;
187
+ let t0;
188
+ if ($[0] !== level || $[1] !== props) {
189
+ t0 = /* @__PURE__ */ jsx(Overlay, { children: /* @__PURE__ */ jsx(MenuPanel, {
190
+ ...props,
191
+ level,
192
+ setPresent
193
+ }) });
194
+ $[0] = level;
195
+ $[1] = props;
196
+ $[2] = t0;
197
+ } else t0 = $[2];
198
+ return t0;
199
+ }
200
+ /**
201
+ * One action or choice. Its slots are the row's: `leading` before the label,
202
+ * the label as children, and `trailing` after it. A selected item draws the
203
+ * check, in place of `leading` where it has one and at the end of the row
204
+ * where it has none, so choosing an item moves nothing in the menu. An item
205
+ * that opens a submenu draws the chevron itself.
206
+ *
207
+ * The menu draws it from its entry in the collection, so it renders nothing
208
+ * on its own. `style`, `ref` and `testID` land on the row.
209
+ */
210
+ function MenuItem(_props) {
211
+ return null;
212
+ }
213
+ MenuItem.getCollectionNode = function* getCollectionNode(props) {
214
+ yield {
215
+ "aria-label": props["aria-label"],
216
+ hasChildNodes: false,
217
+ key: props.id,
218
+ props,
219
+ rendered: props.children,
220
+ textValue: props.textValue ?? (typeof props.children === "string" ? props.children : ""),
221
+ type: "item"
222
+ };
223
+ };
224
+ /**
225
+ * The row shown while more items are being fetched. `onLoadMore` is called
226
+ * when it comes near the visible end of the menu, and the ring is drawn only
227
+ * while `isLoading`. It goes last, after the items it loads more of.
228
+ */
229
+ function MenuLoadMore(_props) {
230
+ return null;
231
+ }
232
+ MenuLoadMore.getCollectionNode = function* getCollectionNode(props) {
233
+ yield {
234
+ hasChildNodes: false,
235
+ props,
236
+ rendered: null,
237
+ type: "loader"
238
+ };
239
+ };
240
+ /**
241
+ * A named group of items. `header` names it, and is what a screen reader
242
+ * reads before the items inside.
243
+ */
244
+ function MenuSection(_props) {
245
+ return null;
246
+ }
247
+ MenuSection.getCollectionNode = function* getCollectionNode(props) {
248
+ const children = [];
249
+ Children.forEach(props.children, (child) => {
250
+ if (child !== null && child !== void 0 && child !== false) children.push(child);
251
+ });
252
+ yield {
253
+ "aria-label": props["aria-label"],
254
+ *childNodes() {
255
+ for (const element of children) yield { element };
256
+ },
257
+ hasChildNodes: true,
258
+ key: props.id,
259
+ props,
260
+ rendered: props.header,
261
+ type: "section"
262
+ };
263
+ };
264
+ /** A rule between groups of items, with the menus page's 8dp either side. */
265
+ function MenuSeparator(_props) {
266
+ return null;
267
+ }
268
+ MenuSeparator.getCollectionNode = function* getCollectionNode(props) {
269
+ yield {
270
+ hasChildNodes: false,
271
+ props,
272
+ rendered: null,
273
+ type: "separator"
274
+ };
275
+ };
276
+ /**
277
+ * An item that opens a menu of its own. Takes exactly two children: the
278
+ * `Menu.Item` that opens it, then the `Menu.Content` it opens. A press on
279
+ * the item opens it, and a second press closes it.
280
+ */
281
+ function MenuSubmenu(_props) {
282
+ return null;
283
+ }
284
+ MenuSubmenu.getCollectionNode = function* getCollectionNode(props) {
285
+ const [trigger, content] = props.children;
286
+ yield* MenuItem.getCollectionNode({
287
+ ...trigger.props,
288
+ submenu: content
289
+ });
290
+ };
291
+ /** Runs a press on an item, from its entry. Built by a call, as below. */
292
+ function activationOf(panel, node) {
293
+ return () => {
294
+ panel.activate(node);
295
+ };
296
+ }
297
+ /**
298
+ * The muted row a menu shows when nothing is in it: an item's box and label
299
+ * in on surface variant, with no press of its own.
300
+ */
301
+ function EmptyRow() {
302
+ const $ = c(10);
303
+ const theme = useTheme();
304
+ const own = stylesOf(theme);
305
+ const label = useTypeRole("labelLarge");
306
+ const T0 = View;
307
+ let t0;
308
+ if ($[0] !== theme) {
309
+ t0 = rowStyleOf(theme, { variant: "menu" });
310
+ $[0] = theme;
311
+ $[1] = t0;
312
+ } else t0 = $[1];
313
+ const T1 = Text;
314
+ const t1 = composeStyles(label, own.empty);
315
+ let t2;
316
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
317
+ t2 = messagesFor();
318
+ $[2] = t2;
319
+ } else t2 = $[2];
320
+ let t3;
321
+ if ($[3] !== T1 || $[4] !== t1) {
322
+ t3 = /* @__PURE__ */ jsx(T1, {
323
+ style: t1,
324
+ children: t2.noResults
325
+ });
326
+ $[3] = T1;
327
+ $[4] = t1;
328
+ $[5] = t3;
329
+ } else t3 = $[5];
330
+ let t4;
331
+ if ($[6] !== T0 || $[7] !== t0 || $[8] !== t3) {
332
+ t4 = /* @__PURE__ */ jsx(T0, {
333
+ style: t0,
334
+ children: t3
335
+ });
336
+ $[6] = T0;
337
+ $[7] = t0;
338
+ $[8] = t3;
339
+ $[9] = t4;
340
+ } else t4 = $[9];
341
+ return t4;
342
+ }
343
+ function emptyState() {
344
+ return /* @__PURE__ */ jsx(EmptyRow, {});
345
+ }
346
+ /** The first item a press reaches, which a screen reader is sent to. */
347
+ function firstItemKey(state) {
348
+ for (const key of state.collection.getKeys()) if (state.collection.getItem(key)?.type === "item" && !state.selectionManager.isDisabled(key)) return key;
349
+ return null;
350
+ }
351
+ /**
352
+ * The role a row reports. React Native's roles stop at `menuitem`, which iOS
353
+ * and Android read with the checked state beside it. Web's checkable items
354
+ * are roles of their own, which React Native Web writes from
355
+ * `accessibilityRole`, typed as any string.
356
+ */
357
+ function itemRoleOf(mode) {
358
+ if (Platform.OS !== "web" || mode === "none") return { role: "menuitem" };
359
+ return { accessibilityRole: mode === "single" ? "menuitemradio" : "menuitemcheckbox" };
360
+ }
361
+ /**
362
+ * The row `Menu.LoadMore` draws: nothing while idle, and the ring while
363
+ * loading. Each time it is laid out, and each time the menu scrolls, it asks
364
+ * whether it has come within `scrollOffset` of the visible end, and calls
365
+ * `onLoadMore` once for each place it is found there, so a load that adds
366
+ * nothing does not start another.
367
+ */
368
+ function LoaderRow(t0) {
369
+ const $ = c(32);
370
+ const { props, viewport } = t0;
371
+ const own = stylesOf(useTheme());
372
+ const { isLoading: t1, label, onLoadMore, scrollOffset: t2, style, testID } = props;
373
+ const isLoading = t1 === void 0 ? false : t1;
374
+ const scrollOffset = t2 === void 0 ? 1 : t2;
375
+ const top = useRef(null);
376
+ const loadedAt = useRef(null);
377
+ let t3;
378
+ if ($[0] !== isLoading || $[1] !== onLoadMore || $[2] !== scrollOffset) {
379
+ t3 = {
380
+ isLoading,
381
+ onLoadMore,
382
+ scrollOffset
383
+ };
384
+ $[0] = isLoading;
385
+ $[1] = onLoadMore;
386
+ $[2] = scrollOffset;
387
+ $[3] = t3;
388
+ } else t3 = $[3];
389
+ const latest = useRef(t3);
390
+ let t4;
391
+ if ($[4] !== isLoading || $[5] !== onLoadMore || $[6] !== scrollOffset) {
392
+ t4 = () => {
393
+ latest.current = {
394
+ isLoading,
395
+ onLoadMore,
396
+ scrollOffset
397
+ };
398
+ };
399
+ $[4] = isLoading;
400
+ $[5] = onLoadMore;
401
+ $[6] = scrollOffset;
402
+ $[7] = t4;
403
+ } else t4 = $[7];
404
+ useEffect(t4);
405
+ let t5;
406
+ if ($[8] !== viewport) {
407
+ t5 = () => {
408
+ const y = top.current;
409
+ const { height, offset } = viewport.read();
410
+ const now = latest.current;
411
+ if (y === null || height === 0 || now.isLoading || now.onLoadMore === void 0 || loadedAt.current === y || y > offset + height * (1 + now.scrollOffset)) return;
412
+ loadedAt.current = y;
413
+ now.onLoadMore();
414
+ };
415
+ $[8] = viewport;
416
+ $[9] = t5;
417
+ } else t5 = $[9];
418
+ const check = t5;
419
+ let t6;
420
+ let t7;
421
+ if ($[10] !== check || $[11] !== viewport) {
422
+ t6 = () => viewport.subscribe(check);
423
+ t7 = [check, viewport];
424
+ $[10] = check;
425
+ $[11] = viewport;
426
+ $[12] = t6;
427
+ $[13] = t7;
428
+ } else {
429
+ t6 = $[12];
430
+ t7 = $[13];
431
+ }
432
+ useEffect(t6, t7);
433
+ let t8;
434
+ if ($[14] !== check) {
435
+ t8 = (event) => {
436
+ top.current = event.nativeEvent.layout.y;
437
+ check();
438
+ };
439
+ $[14] = check;
440
+ $[15] = t8;
441
+ } else t8 = $[15];
442
+ const onLayout = t8;
443
+ if (!isLoading) {
444
+ let t9;
445
+ if ($[16] !== style) {
446
+ t9 = composeStyles(styles.sentinel, style);
447
+ $[16] = style;
448
+ $[17] = t9;
449
+ } else t9 = $[17];
450
+ let t10;
451
+ if ($[18] !== onLayout || $[19] !== t9 || $[20] !== testID) {
452
+ t10 = /* @__PURE__ */ jsx(View, {
453
+ onLayout,
454
+ style: t9,
455
+ testID
456
+ });
457
+ $[18] = onLayout;
458
+ $[19] = t9;
459
+ $[20] = testID;
460
+ $[21] = t10;
461
+ } else t10 = $[21];
462
+ return t10;
463
+ }
464
+ const T0 = View;
465
+ const t9 = "menuitem";
466
+ const t10 = composeStyles(own.loading, style);
467
+ let t11;
468
+ if ($[22] !== label) {
469
+ t11 = label ?? messagesFor().loadingMore;
470
+ $[22] = label;
471
+ $[23] = t11;
472
+ } else t11 = $[23];
473
+ let t12;
474
+ if ($[24] !== t11) {
475
+ t12 = /* @__PURE__ */ jsx(ProgressIndicator, {
476
+ "aria-label": t11,
477
+ diameter: LOADING_DIAMETER,
478
+ isIndeterminate: true,
479
+ variant: "circular"
480
+ });
481
+ $[24] = t11;
482
+ $[25] = t12;
483
+ } else t12 = $[25];
484
+ let t13;
485
+ if ($[26] !== T0 || $[27] !== onLayout || $[28] !== t10 || $[29] !== t12 || $[30] !== testID) {
486
+ t13 = /* @__PURE__ */ jsx(T0, {
487
+ onLayout,
488
+ role: t9,
489
+ style: t10,
490
+ testID,
491
+ children: t12
492
+ });
493
+ $[26] = T0;
494
+ $[27] = onLayout;
495
+ $[28] = t10;
496
+ $[29] = t12;
497
+ $[30] = testID;
498
+ $[31] = t13;
499
+ } else t13 = $[31];
500
+ return t13;
501
+ }
502
+ function MenuNode(t0) {
503
+ const $ = c(10);
504
+ const { node, panel } = t0;
505
+ const own = stylesOf(useTheme());
506
+ switch (node.type) {
507
+ case "loader": {
508
+ const props_0 = node.props;
509
+ let t1;
510
+ if ($[0] !== panel.viewport || $[1] !== props_0) {
511
+ t1 = /* @__PURE__ */ jsx(LoaderRow, {
512
+ props: props_0,
513
+ viewport: panel.viewport
514
+ });
515
+ $[0] = panel.viewport;
516
+ $[1] = props_0;
517
+ $[2] = t1;
518
+ } else t1 = $[2];
519
+ return t1;
520
+ }
521
+ case "section": {
522
+ let t1;
523
+ if ($[3] !== node || $[4] !== panel) {
524
+ t1 = /* @__PURE__ */ jsx(SectionNode, {
525
+ node,
526
+ panel
527
+ });
528
+ $[3] = node;
529
+ $[4] = panel;
530
+ $[5] = t1;
531
+ } else t1 = $[5];
532
+ return t1;
533
+ }
534
+ case "separator": {
535
+ const { style, testID } = node.props;
536
+ return /* @__PURE__ */ jsx(Separator, {
537
+ style: composeStyles(own.separator, style),
538
+ testID
539
+ });
540
+ }
541
+ default: {
542
+ const props = node.props;
543
+ let t1;
544
+ if ($[6] !== node || $[7] !== panel || $[8] !== props.submenu) {
545
+ t1 = props.submenu === void 0 ? /* @__PURE__ */ jsx(MenuRow, {
546
+ node,
547
+ onActivate: activationOf(panel, node),
548
+ panel
549
+ }) : /* @__PURE__ */ jsx(SubmenuRow, {
550
+ content: props.submenu,
551
+ node,
552
+ panel
553
+ });
554
+ $[6] = node;
555
+ $[7] = panel;
556
+ $[8] = props.submenu;
557
+ $[9] = t1;
558
+ } else t1 = $[9];
559
+ return t1;
560
+ }
561
+ }
562
+ }
563
+ function MenuPanel(t0) {
564
+ const $ = c(79);
565
+ let alignOffset;
566
+ let children;
567
+ let defaultSelectedKeys;
568
+ let disabledKeys;
569
+ let disallowEmptySelection;
570
+ let items;
571
+ let level;
572
+ let onAction;
573
+ let onClose;
574
+ let onSelectionChange;
575
+ let props;
576
+ let ref;
577
+ let selectedKeys;
578
+ let setPresent;
579
+ let shouldCloseOnSelect;
580
+ let side;
581
+ let sideOffset;
582
+ let style;
583
+ let t1;
584
+ let t2;
585
+ let t3;
586
+ if ($[0] !== t0) {
587
+ ({align: t1, alignOffset, children, defaultSelectedKeys, disabledKeys, disallowEmptySelection, items, level, onAction, onClose, onSelectionChange, ref, renderEmptyState: t2, selectedKeys, selectionMode: t3, setPresent, shouldCloseOnSelect, side, sideOffset, style, ...props} = t0);
588
+ $[0] = t0;
589
+ $[1] = alignOffset;
590
+ $[2] = children;
591
+ $[3] = defaultSelectedKeys;
592
+ $[4] = disabledKeys;
593
+ $[5] = disallowEmptySelection;
594
+ $[6] = items;
595
+ $[7] = level;
596
+ $[8] = onAction;
597
+ $[9] = onClose;
598
+ $[10] = onSelectionChange;
599
+ $[11] = props;
600
+ $[12] = ref;
601
+ $[13] = selectedKeys;
602
+ $[14] = setPresent;
603
+ $[15] = shouldCloseOnSelect;
604
+ $[16] = side;
605
+ $[17] = sideOffset;
606
+ $[18] = style;
607
+ $[19] = t1;
608
+ $[20] = t2;
609
+ $[21] = t3;
610
+ } else {
611
+ alignOffset = $[1];
612
+ children = $[2];
613
+ defaultSelectedKeys = $[3];
614
+ disabledKeys = $[4];
615
+ disallowEmptySelection = $[5];
616
+ items = $[6];
617
+ level = $[7];
618
+ onAction = $[8];
619
+ onClose = $[9];
620
+ onSelectionChange = $[10];
621
+ props = $[11];
622
+ ref = $[12];
623
+ selectedKeys = $[13];
624
+ setPresent = $[14];
625
+ shouldCloseOnSelect = $[15];
626
+ side = $[16];
627
+ sideOffset = $[17];
628
+ style = $[18];
629
+ t1 = $[19];
630
+ t2 = $[20];
631
+ t3 = $[21];
632
+ }
633
+ const align = t1 === void 0 ? "start" : t1;
634
+ const renderEmptyState = t2 === void 0 ? emptyState : t2;
635
+ const selectionMode = t3 === void 0 ? "none" : t3;
636
+ const theme = useTheme();
637
+ const own = stylesOf(theme);
638
+ const { anchor, close, isOpen, openLink, root, submenu } = level;
639
+ const t4 = children;
640
+ let t5;
641
+ if ($[22] !== defaultSelectedKeys || $[23] !== disabledKeys || $[24] !== disallowEmptySelection || $[25] !== items || $[26] !== onSelectionChange || $[27] !== selectedKeys || $[28] !== selectionMode || $[29] !== t4) {
642
+ t5 = {
643
+ children: t4,
644
+ defaultSelectedKeys,
645
+ disabledKeys,
646
+ disallowEmptySelection,
647
+ items,
648
+ onSelectionChange,
649
+ selectedKeys,
650
+ selectionMode
651
+ };
652
+ $[22] = defaultSelectedKeys;
653
+ $[23] = disabledKeys;
654
+ $[24] = disallowEmptySelection;
655
+ $[25] = items;
656
+ $[26] = onSelectionChange;
657
+ $[27] = selectedKeys;
658
+ $[28] = selectionMode;
659
+ $[29] = t4;
660
+ $[30] = t5;
661
+ } else t5 = $[30];
662
+ const state = useTreeState(t5);
663
+ const t6 = alignOffset ?? (submenu ? -theme.spacing.sm : void 0);
664
+ const t7 = side ?? (submenu ? I18nManager.isRTL ? "left" : "right" : "bottom");
665
+ const t8 = sideOffset ?? (submenu ? 0 : void 0);
666
+ let t9;
667
+ if ($[31] !== align || $[32] !== anchor || $[33] !== t6 || $[34] !== t7 || $[35] !== t8) {
668
+ t9 = {
669
+ align,
670
+ alignOffset: t6,
671
+ anchor,
672
+ side: t7,
673
+ sideOffset: t8
674
+ };
675
+ $[31] = align;
676
+ $[32] = anchor;
677
+ $[33] = t6;
678
+ $[34] = t7;
679
+ $[35] = t8;
680
+ $[36] = t9;
681
+ } else t9 = $[36];
682
+ const placement = useAnchoredPlacement(t9);
683
+ const motion = usePanelMotion(isOpen, placement.placed, setPresent);
684
+ const [focusTarget, setFocusTarget] = useState(null);
685
+ const scroll = useViewport();
686
+ let t10;
687
+ if ($[37] !== state) {
688
+ t10 = firstItemKey(state);
689
+ $[37] = state;
690
+ $[38] = t10;
691
+ } else t10 = $[38];
692
+ const focusKey = t10;
693
+ useBackToClose(close, isOpen);
694
+ useFocusOnPlaced(placement.placed, focusTarget);
695
+ let t11;
696
+ if ($[39] !== onAction || $[40] !== onClose || $[41] !== openLink || $[42] !== root || $[43] !== selectionMode || $[44] !== shouldCloseOnSelect || $[45] !== state.selectionManager) {
697
+ t11 = (node) => {
698
+ const item = node.props;
699
+ const closes = shouldCloseOnSelect ?? (selectionMode !== "multiple" || item.href !== void 0);
700
+ if (selectionMode !== "none") state.selectionManager.select(node.key);
701
+ if (item.onAction === void 0) onAction?.(node.key);
702
+ else item.onAction();
703
+ if (item.href !== void 0) openLink(item.href);
704
+ if (closes) {
705
+ onClose?.();
706
+ root.close();
707
+ }
708
+ };
709
+ $[39] = onAction;
710
+ $[40] = onClose;
711
+ $[41] = openLink;
712
+ $[42] = root;
713
+ $[43] = selectionMode;
714
+ $[44] = shouldCloseOnSelect;
715
+ $[45] = state.selectionManager;
716
+ $[46] = t11;
717
+ } else t11 = $[46];
718
+ const activate = t11;
719
+ let t12;
720
+ if ($[47] !== activate || $[48] !== focusKey || $[49] !== level || $[50] !== scroll.viewport || $[51] !== state) {
721
+ t12 = {
722
+ activate,
723
+ focusKey,
724
+ level,
725
+ setFocusTarget,
726
+ state,
727
+ viewport: scroll.viewport
728
+ };
729
+ $[47] = activate;
730
+ $[48] = focusKey;
731
+ $[49] = level;
732
+ $[50] = scroll.viewport;
733
+ $[51] = state;
734
+ $[52] = t12;
735
+ } else t12 = $[52];
736
+ const panel = t12;
737
+ let t13;
738
+ if ($[53] !== state.collection) {
739
+ t13 = [...state.collection];
740
+ $[53] = state.collection;
741
+ $[54] = t13;
742
+ } else t13 = $[54];
743
+ const nodes = t13;
744
+ let t14;
745
+ if ($[55] !== close || $[56] !== isOpen || $[57] !== submenu) {
746
+ t14 = submenu || !isOpen ? null : /* @__PURE__ */ jsx(DismissLayer, { onPress: close });
747
+ $[55] = close;
748
+ $[56] = isOpen;
749
+ $[57] = submenu;
750
+ $[58] = t14;
751
+ } else t14 = $[58];
752
+ const t15 = Animated;
753
+ const t16 = "menu";
754
+ const t17 = placement.onLayout;
755
+ const t18 = composeStyles(own.surface, placement.style, { transformOrigin: PANEL_ORIGINS[placement.side] }, motion, style);
756
+ let t19;
757
+ if ($[59] !== nodes || $[60] !== panel || $[61] !== renderEmptyState) {
758
+ t19 = nodes.length === 0 ? /* @__PURE__ */ jsx(View, {
759
+ role: "menuitem",
760
+ children: renderEmptyState()
761
+ }) : nodes.map((node_0) => /* @__PURE__ */ jsx(MenuNode, {
762
+ node: node_0,
763
+ panel
764
+ }, node_0.key));
765
+ $[59] = nodes;
766
+ $[60] = panel;
767
+ $[61] = renderEmptyState;
768
+ $[62] = t19;
769
+ } else t19 = $[62];
770
+ let t20;
771
+ if ($[63] !== own.content || $[64] !== scroll.onLayout || $[65] !== scroll.onScroll || $[66] !== t19) {
772
+ t20 = /* @__PURE__ */ jsx(ScrollView, {
773
+ contentContainerStyle: own.content,
774
+ onLayout: scroll.onLayout,
775
+ onScroll: scroll.onScroll,
776
+ scrollEventThrottle: 16,
777
+ style: styles.scroll,
778
+ children: t19
779
+ });
780
+ $[63] = own.content;
781
+ $[64] = scroll.onLayout;
782
+ $[65] = scroll.onScroll;
783
+ $[66] = t19;
784
+ $[67] = t20;
785
+ } else t20 = $[67];
786
+ let t21;
787
+ if ($[68] !== close || $[69] !== placement.onLayout || $[70] !== props || $[71] !== ref || $[72] !== t15.View || $[73] !== t18 || $[74] !== t20) {
788
+ t21 = /* @__PURE__ */ jsx(t15.View, {
789
+ onAccessibilityEscape: close,
790
+ role: t16,
791
+ ...props,
792
+ onLayout: t17,
793
+ ref,
794
+ style: t18,
795
+ children: t20
796
+ });
797
+ $[68] = close;
798
+ $[69] = placement.onLayout;
799
+ $[70] = props;
800
+ $[71] = ref;
801
+ $[72] = t15.View;
802
+ $[73] = t18;
803
+ $[74] = t20;
804
+ $[75] = t21;
805
+ } else t21 = $[75];
806
+ let t22;
807
+ if ($[76] !== t14 || $[77] !== t21) {
808
+ t22 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t14, t21] });
809
+ $[76] = t14;
810
+ $[77] = t21;
811
+ $[78] = t22;
812
+ } else t22 = $[78];
813
+ return t22;
814
+ }
815
+ /**
816
+ * An item's row: the state layer, the ripple and the focus ring over the
817
+ * leading slot, the label and the trailing slot, on tertiary container while
818
+ * selected.
819
+ */
820
+ function MenuRow(t0) {
821
+ const $ = c(46);
822
+ const { anchor, expanded, node, onActivate, panel } = t0;
823
+ const theme = useTheme();
824
+ let children;
825
+ let leading;
826
+ let onBlur;
827
+ let onFocus;
828
+ let onHoverIn;
829
+ let onHoverOut;
830
+ let onPress;
831
+ let onPressIn;
832
+ let onPressOut;
833
+ let props;
834
+ let ref;
835
+ let style;
836
+ let submenu;
837
+ let trailing;
838
+ if ($[0] !== node.props) {
839
+ const { children: t1, href: _href, id: _id, isDisabled: _isDisabled, leading: t2, onAction: _onAction, onBlur: t3, onFocus: t4, onHoverIn: t5, onHoverOut: t6, onPress: t7, onPressIn: t8, onPressOut: t9, ref: t10, style: t11, submenu: t12, textValue: _textValue, trailing: t13, ...t14 } = node.props;
840
+ children = t1;
841
+ leading = t2;
842
+ onBlur = t3;
843
+ onFocus = t4;
844
+ onHoverIn = t5;
845
+ onHoverOut = t6;
846
+ onPress = t7;
847
+ onPressIn = t8;
848
+ onPressOut = t9;
849
+ ref = t10;
850
+ style = t11;
851
+ submenu = t12;
852
+ trailing = t13;
853
+ props = t14;
854
+ $[0] = node.props;
855
+ $[1] = children;
856
+ $[2] = leading;
857
+ $[3] = onBlur;
858
+ $[4] = onFocus;
859
+ $[5] = onHoverIn;
860
+ $[6] = onHoverOut;
861
+ $[7] = onPress;
862
+ $[8] = onPressIn;
863
+ $[9] = onPressOut;
864
+ $[10] = props;
865
+ $[11] = ref;
866
+ $[12] = style;
867
+ $[13] = submenu;
868
+ $[14] = trailing;
869
+ } else {
870
+ children = $[1];
871
+ leading = $[2];
872
+ onBlur = $[3];
873
+ onFocus = $[4];
874
+ onHoverIn = $[5];
875
+ onHoverOut = $[6];
876
+ onPress = $[7];
877
+ onPressIn = $[8];
878
+ onPressOut = $[9];
879
+ props = $[10];
880
+ ref = $[11];
881
+ style = $[12];
882
+ submenu = $[13];
883
+ trailing = $[14];
884
+ }
885
+ const { selectionManager } = panel.state;
886
+ const disabled = selectionManager.isDisabled(node.key);
887
+ const selectable = selectionManager.selectionMode !== "none";
888
+ const selected = selectable && selectionManager.isSelected(node.key);
889
+ const content = rowContentColor(theme, {
890
+ isDisabled: disabled,
891
+ isSelected: selected,
892
+ variant: "menu"
893
+ });
894
+ const feedback = usePressFeedback({
895
+ color: content,
896
+ disabled,
897
+ onBlur,
898
+ onFocus,
899
+ onHoverIn,
900
+ onHoverOut,
901
+ onPressIn,
902
+ onPressOut
903
+ });
904
+ const hasLeading = leading !== void 0 && leading !== null;
905
+ const check = selected ? /* @__PURE__ */ jsx(CheckGlyph, {
906
+ color: content,
907
+ size: CHECK_SIZE
908
+ }) : null;
909
+ const lead = hasLeading ? check ?? leading : null;
910
+ const end = submenu === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [trailing, hasLeading ? null : check] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [trailing, /* @__PURE__ */ jsx(ChevronEndGlyph, {
911
+ color: content,
912
+ size: CHEVRON_SIZE
913
+ })] });
914
+ const hasEnd = submenu !== void 0 || trailing !== void 0 && trailing !== null || !hasLeading && check !== null;
915
+ const T0 = Pressable;
916
+ let t1;
917
+ if ($[15] !== selectionManager.selectionMode) {
918
+ t1 = itemRoleOf(selectionManager.selectionMode);
919
+ $[15] = selectionManager.selectionMode;
920
+ $[16] = t1;
921
+ } else t1 = $[16];
922
+ const t2 = selectable ? { "aria-checked": selected } : void 0;
923
+ let t3;
924
+ if ($[17] !== expanded || $[18] !== submenu) {
925
+ t3 = submenu === void 0 ? void 0 : {
926
+ ...HAS_SUBMENU,
927
+ "aria-expanded": expanded
928
+ };
929
+ $[17] = expanded;
930
+ $[18] = submenu;
931
+ $[19] = t3;
932
+ } else t3 = $[19];
933
+ const t4 = feedback.handlers;
934
+ let t5;
935
+ if ($[20] !== onActivate || $[21] !== onPress) {
936
+ t5 = pressThen(onPress, onActivate);
937
+ $[20] = onActivate;
938
+ $[21] = onPress;
939
+ $[22] = t5;
940
+ } else t5 = $[22];
941
+ const t6 = node.key === panel.focusKey ? panel.setFocusTarget : void 0;
942
+ let t7;
943
+ if ($[23] !== anchor || $[24] !== ref || $[25] !== t6) {
944
+ t7 = refsOf(anchor, t6, ref);
945
+ $[23] = anchor;
946
+ $[24] = ref;
947
+ $[25] = t6;
948
+ $[26] = t7;
949
+ } else t7 = $[26];
950
+ const t8 = composeStyles(rowStyleOf(theme, {
951
+ isSelected: selected,
952
+ variant: "menu"
953
+ }), feedback.ring, feedback.ring === void 0 ? void 0 : rowStyles.ring, style);
954
+ const t9 = hasEnd ? end : void 0;
955
+ let t10;
956
+ if ($[27] !== children || $[28] !== disabled || $[29] !== lead || $[30] !== selected || $[31] !== t9) {
957
+ t10 = /* @__PURE__ */ jsx(RowContent, {
958
+ isDisabled: disabled,
959
+ isSelected: selected,
960
+ leading: lead,
961
+ trailing: t9,
962
+ variant: "menu",
963
+ children
964
+ });
965
+ $[27] = children;
966
+ $[28] = disabled;
967
+ $[29] = lead;
968
+ $[30] = selected;
969
+ $[31] = t9;
970
+ $[32] = t10;
971
+ } else t10 = $[32];
972
+ let t11;
973
+ if ($[33] !== T0 || $[34] !== disabled || $[35] !== feedback.handlers || $[36] !== feedback.layer || $[37] !== props || $[38] !== t1 || $[39] !== t10 || $[40] !== t2 || $[41] !== t3 || $[42] !== t5 || $[43] !== t7 || $[44] !== t8) {
974
+ t11 = /* @__PURE__ */ jsxs(T0, {
975
+ ...t1,
976
+ ...t2,
977
+ ...t3,
978
+ ...props,
979
+ ...t4,
980
+ disabled,
981
+ onPress: t5,
982
+ ref: t7,
983
+ style: t8,
984
+ children: [feedback.layer, t10]
985
+ });
986
+ $[33] = T0;
987
+ $[34] = disabled;
988
+ $[35] = feedback.handlers;
989
+ $[36] = feedback.layer;
990
+ $[37] = props;
991
+ $[38] = t1;
992
+ $[39] = t10;
993
+ $[40] = t2;
994
+ $[41] = t3;
995
+ $[42] = t5;
996
+ $[43] = t7;
997
+ $[44] = t8;
998
+ $[45] = t11;
999
+ } else t11 = $[45];
1000
+ return t11;
1001
+ }
1002
+ /**
1003
+ * The press handler of a row: the call site's own `onPress`, then the row's
1004
+ * activation. Built by a call rather than written inline at the prop, which
1005
+ * is what react-perf's no-new-function-as-prop is after.
1006
+ */
1007
+ function pressThen(onPress, onActivate) {
1008
+ return (event) => {
1009
+ onPress?.(event);
1010
+ onActivate();
1011
+ };
1012
+ }
1013
+ /** A section: its heading, then its items, as a group named by the heading. */
1014
+ function SectionNode(t0) {
1015
+ const $ = c(15);
1016
+ const { node, panel } = t0;
1017
+ const own = stylesOf(useTheme());
1018
+ const titleRole = useTypeRole("titleSmall");
1019
+ const id = useId();
1020
+ const header = node.rendered;
1021
+ const named = header !== void 0 && header !== null;
1022
+ let t1;
1023
+ if ($[0] !== node.childNodes || $[1] !== node.key || $[2] !== panel.state.collection) {
1024
+ t1 = panel.state.collection.getChildren?.(node.key) ?? node.childNodes;
1025
+ $[0] = node.childNodes;
1026
+ $[1] = node.key;
1027
+ $[2] = panel.state.collection;
1028
+ $[3] = t1;
1029
+ } else t1 = $[3];
1030
+ const children = t1;
1031
+ const T0 = View;
1032
+ const t2 = named ? void 0 : node["aria-label"];
1033
+ const t3 = named ? id : void 0;
1034
+ const t4 = "group";
1035
+ const t5 = named ? /* @__PURE__ */ jsx(Text, {
1036
+ nativeID: id,
1037
+ style: composeStyles(titleRole, own.header),
1038
+ children: header
1039
+ }) : null;
1040
+ let t6;
1041
+ if ($[4] !== children) {
1042
+ t6 = [...children];
1043
+ $[4] = children;
1044
+ $[5] = t6;
1045
+ } else t6 = $[5];
1046
+ let t7;
1047
+ if ($[6] !== panel || $[7] !== t6) {
1048
+ t7 = t6.map((child) => /* @__PURE__ */ jsx(MenuNode, {
1049
+ node: child,
1050
+ panel
1051
+ }, child.key));
1052
+ $[6] = panel;
1053
+ $[7] = t6;
1054
+ $[8] = t7;
1055
+ } else t7 = $[8];
1056
+ let t8;
1057
+ if ($[9] !== T0 || $[10] !== t2 || $[11] !== t3 || $[12] !== t5 || $[13] !== t7) {
1058
+ t8 = /* @__PURE__ */ jsxs(T0, {
1059
+ "aria-label": t2,
1060
+ "aria-labelledby": t3,
1061
+ role: t4,
1062
+ children: [t5, t7]
1063
+ });
1064
+ $[9] = T0;
1065
+ $[10] = t2;
1066
+ $[11] = t3;
1067
+ $[12] = t5;
1068
+ $[13] = t7;
1069
+ $[14] = t8;
1070
+ } else t8 = $[14];
1071
+ return t8;
1072
+ }
1073
+ /**
1074
+ * An item that opens a submenu: its row, and the submenu's content, drawn
1075
+ * under the submenu's own level so it opens beside the row and closes on its
1076
+ * own. A press on the row toggles it.
1077
+ */
1078
+ function SubmenuRow(t0) {
1079
+ const $ = c(22);
1080
+ const { content, node, panel } = t0;
1081
+ const { openLink, root } = panel.level;
1082
+ const anchor = useRef(null);
1083
+ let t1;
1084
+ if ($[0] !== node.key) {
1085
+ t1 = { triggerKey: node.key };
1086
+ $[0] = node.key;
1087
+ $[1] = t1;
1088
+ } else t1 = $[1];
1089
+ const submenuState = useSubmenuTriggerState(t1, root);
1090
+ let t2;
1091
+ if ($[2] !== submenuState) {
1092
+ t2 = () => {
1093
+ submenuState.close();
1094
+ };
1095
+ $[2] = submenuState;
1096
+ $[3] = t2;
1097
+ } else t2 = $[3];
1098
+ const close = useLatest(t2);
1099
+ let t3;
1100
+ if ($[4] !== submenuState) {
1101
+ t3 = () => {
1102
+ submenuState.toggle();
1103
+ };
1104
+ $[4] = submenuState;
1105
+ $[5] = t3;
1106
+ } else t3 = $[5];
1107
+ const toggle = t3;
1108
+ let t4;
1109
+ if ($[6] !== close || $[7] !== openLink || $[8] !== root || $[9] !== submenuState.isOpen) {
1110
+ t4 = {
1111
+ anchor,
1112
+ close,
1113
+ isOpen: submenuState.isOpen,
1114
+ openLink,
1115
+ root,
1116
+ submenu: true
1117
+ };
1118
+ $[6] = close;
1119
+ $[7] = openLink;
1120
+ $[8] = root;
1121
+ $[9] = submenuState.isOpen;
1122
+ $[10] = t4;
1123
+ } else t4 = $[10];
1124
+ const level = t4;
1125
+ let t5;
1126
+ if ($[11] !== node || $[12] !== panel || $[13] !== submenuState.isOpen || $[14] !== toggle) {
1127
+ t5 = /* @__PURE__ */ jsx(MenuRow, {
1128
+ anchor,
1129
+ expanded: submenuState.isOpen,
1130
+ node,
1131
+ onActivate: toggle,
1132
+ panel
1133
+ });
1134
+ $[11] = node;
1135
+ $[12] = panel;
1136
+ $[13] = submenuState.isOpen;
1137
+ $[14] = toggle;
1138
+ $[15] = t5;
1139
+ } else t5 = $[15];
1140
+ let t6;
1141
+ if ($[16] !== content || $[17] !== level) {
1142
+ t6 = /* @__PURE__ */ jsx(LevelContext, {
1143
+ value: level,
1144
+ children: content
1145
+ });
1146
+ $[16] = content;
1147
+ $[17] = level;
1148
+ $[18] = t6;
1149
+ } else t6 = $[18];
1150
+ let t7;
1151
+ if ($[19] !== t5 || $[20] !== t6) {
1152
+ t7 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t5, t6] });
1153
+ $[19] = t5;
1154
+ $[20] = t6;
1155
+ $[21] = t7;
1156
+ } else t7 = $[21];
1157
+ return t7;
1158
+ }
1159
+ /**
1160
+ * A callback of one identity for the life of the component, which calls the
1161
+ * latest `callback` it was rendered with. A menu's state is a new object on
1162
+ * every render, and the back gesture's listener is added again whenever the
1163
+ * callback it closes through changes: added again after a submenu's, the
1164
+ * menu's own would be the one Android calls first, and the gesture would
1165
+ * close the whole menu rather than the submenu.
1166
+ */
1167
+ function useLatest(callback) {
1168
+ const $ = c(3);
1169
+ const latest = useRef(callback);
1170
+ let t0;
1171
+ if ($[0] !== callback) {
1172
+ t0 = () => {
1173
+ latest.current = callback;
1174
+ };
1175
+ $[0] = callback;
1176
+ $[1] = t0;
1177
+ } else t0 = $[1];
1178
+ useEffect(t0);
1179
+ let t1;
1180
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1181
+ t1 = () => {
1182
+ latest.current();
1183
+ };
1184
+ $[2] = t1;
1185
+ } else t1 = $[2];
1186
+ return t1;
1187
+ }
1188
+ /**
1189
+ * Keeps track of the part of the menu's scroll view in view, for
1190
+ * `Menu.LoadMore`, and tells it whenever that changes.
1191
+ */
1192
+ function useViewport() {
1193
+ const $ = c(13);
1194
+ let t0;
1195
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1196
+ t0 = {
1197
+ height: 0,
1198
+ offset: 0
1199
+ };
1200
+ $[0] = t0;
1201
+ } else t0 = $[0];
1202
+ const seen = useRef(t0);
1203
+ const [listeners] = useState(_temp);
1204
+ let t1;
1205
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1206
+ t1 = () => seen.current;
1207
+ $[1] = t1;
1208
+ } else t1 = $[1];
1209
+ let t2;
1210
+ if ($[2] !== listeners) {
1211
+ t2 = {
1212
+ read: t1,
1213
+ subscribe: (listener) => {
1214
+ listeners.add(listener);
1215
+ return () => {
1216
+ listeners.delete(listener);
1217
+ };
1218
+ }
1219
+ };
1220
+ $[2] = listeners;
1221
+ $[3] = t2;
1222
+ } else t2 = $[3];
1223
+ const viewport = t2;
1224
+ let t3;
1225
+ if ($[4] !== listeners) {
1226
+ t3 = function notify() {
1227
+ for (const listener_0 of listeners) listener_0();
1228
+ };
1229
+ $[4] = listeners;
1230
+ $[5] = t3;
1231
+ } else t3 = $[5];
1232
+ const notify = t3;
1233
+ let t4;
1234
+ let t5;
1235
+ if ($[6] !== notify) {
1236
+ t4 = (event) => {
1237
+ seen.current = {
1238
+ ...seen.current,
1239
+ height: event.nativeEvent.layout.height
1240
+ };
1241
+ notify();
1242
+ };
1243
+ t5 = (event_0) => {
1244
+ seen.current = {
1245
+ ...seen.current,
1246
+ offset: event_0.nativeEvent.contentOffset.y
1247
+ };
1248
+ notify();
1249
+ };
1250
+ $[6] = notify;
1251
+ $[7] = t4;
1252
+ $[8] = t5;
1253
+ } else {
1254
+ t4 = $[7];
1255
+ t5 = $[8];
1256
+ }
1257
+ let t6;
1258
+ if ($[9] !== t4 || $[10] !== t5 || $[11] !== viewport) {
1259
+ t6 = {
1260
+ onLayout: t4,
1261
+ onScroll: t5,
1262
+ viewport
1263
+ };
1264
+ $[9] = t4;
1265
+ $[10] = t5;
1266
+ $[11] = viewport;
1267
+ $[12] = t6;
1268
+ } else t6 = $[12];
1269
+ return t6;
1270
+ }
1271
+ function _temp() {
1272
+ return /* @__PURE__ */ new Set();
1273
+ }
1274
+ Menu.Content = MenuContent;
1275
+ Menu.Item = MenuItem;
1276
+ Menu.LoadMore = MenuLoadMore;
1277
+ Menu.Section = MenuSection;
1278
+ Menu.Separator = MenuSeparator;
1279
+ Menu.Submenu = MenuSubmenu;
1280
+ //#endregion
1281
+ export { Menu, MenuContent, MenuItem, MenuLoadMore, MenuSection, MenuSeparator, MenuSubmenu };
1282
+
1283
+ //# sourceMappingURL=index.js.map