one 1.21.6 → 1.21.8

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 (209) hide show
  1. package/dist/cjs/cli/dev.native.js.map +1 -1
  2. package/dist/cjs/cli.cjs +0 -3
  3. package/dist/cjs/cli.native.js +0 -3
  4. package/dist/cjs/cli.native.js.map +1 -1
  5. package/dist/cjs/image/getImageData.cjs +1 -1
  6. package/dist/cjs/image/getImageData.native.js +1 -1
  7. package/dist/cjs/image/getImageData.native.js.map +1 -1
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/layouts/Stack.cjs +5 -5
  10. package/dist/cjs/layouts/Stack.native.js +5 -5
  11. package/dist/cjs/layouts/Stack.native.js.map +1 -1
  12. package/dist/cjs/layouts/stack-utils/StackScreen.cjs +3 -0
  13. package/dist/cjs/layouts/stack-utils/StackScreen.native.js +3 -0
  14. package/dist/cjs/layouts/stack-utils/StackScreen.native.js.map +1 -1
  15. package/dist/cjs/layouts/stack-utils/StackToolbar.cjs +419 -0
  16. package/dist/cjs/layouts/stack-utils/StackToolbar.native.js +453 -0
  17. package/dist/cjs/layouts/stack-utils/StackToolbar.native.js.map +1 -0
  18. package/dist/cjs/layouts/stack-utils/StackToolbar.types.cjs +18 -0
  19. package/dist/cjs/layouts/stack-utils/StackToolbar.types.native.js +21 -0
  20. package/dist/cjs/layouts/stack-utils/StackToolbar.types.native.js.map +1 -0
  21. package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.cjs +63 -0
  22. package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js +73 -0
  23. package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js.map +1 -0
  24. package/dist/cjs/layouts/stack-utils/__tests__/composition.test.cjs +205 -0
  25. package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js +220 -0
  26. package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js.map +1 -1
  27. package/dist/cjs/layouts/stack-utils/index.cjs +2 -0
  28. package/dist/cjs/layouts/stack-utils/index.native.js +2 -0
  29. package/dist/cjs/layouts/stack-utils/index.native.js.map +1 -1
  30. package/dist/cjs/layouts/withLayoutContext.cjs +39 -8
  31. package/dist/cjs/layouts/withLayoutContext.native.js +43 -8
  32. package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
  33. package/dist/cjs/layouts/withLayoutContext.test.cjs +96 -0
  34. package/dist/cjs/layouts/withLayoutContext.test.native.js +100 -0
  35. package/dist/cjs/layouts/withLayoutContext.test.native.js.map +1 -0
  36. package/dist/cjs/router/Route.cjs +3 -0
  37. package/dist/cjs/router/Route.native.js +3 -0
  38. package/dist/cjs/router/Route.native.js.map +1 -1
  39. package/dist/cjs/router/protectedRoutes.test.cjs +22 -0
  40. package/dist/cjs/router/protectedRoutes.test.native.js +25 -0
  41. package/dist/cjs/router/protectedRoutes.test.native.js.map +1 -0
  42. package/dist/cjs/router/router.cjs +26 -8
  43. package/dist/cjs/router/router.native.js +26 -8
  44. package/dist/cjs/router/router.native.js.map +1 -1
  45. package/dist/cjs/router/useScreens.cjs +38 -11
  46. package/dist/cjs/router/useScreens.native.js +39 -11
  47. package/dist/cjs/router/useScreens.native.js.map +1 -1
  48. package/dist/cjs/router/useScreens.test.cjs +134 -0
  49. package/dist/cjs/router/useScreens.test.native.js +163 -0
  50. package/dist/cjs/router/useScreens.test.native.js.map +1 -0
  51. package/dist/cjs/views/Navigator.cjs +14 -6
  52. package/dist/cjs/views/Navigator.native.js +14 -6
  53. package/dist/cjs/views/Navigator.native.js.map +1 -1
  54. package/dist/cjs/views/Protected.native.js.map +1 -1
  55. package/dist/cjs/views/SuspenseFallback.cjs +18 -0
  56. package/dist/cjs/views/SuspenseFallback.native.js +21 -0
  57. package/dist/cjs/views/SuspenseFallback.native.js.map +1 -0
  58. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +47 -7
  59. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +47 -7
  60. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  61. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +15 -6
  62. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +15 -6
  63. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
  64. package/dist/esm/cli/dev.mjs.map +1 -1
  65. package/dist/esm/cli/dev.native.js.map +1 -1
  66. package/dist/esm/cli.mjs +0 -3
  67. package/dist/esm/cli.mjs.map +1 -1
  68. package/dist/esm/cli.native.js +0 -3
  69. package/dist/esm/cli.native.js.map +1 -1
  70. package/dist/esm/image/getImageData.mjs +1 -1
  71. package/dist/esm/image/getImageData.mjs.map +1 -1
  72. package/dist/esm/image/getImageData.native.js +1 -1
  73. package/dist/esm/image/getImageData.native.js.map +1 -1
  74. package/dist/esm/index.js.map +1 -1
  75. package/dist/esm/index.mjs.map +1 -1
  76. package/dist/esm/index.native.js.map +1 -1
  77. package/dist/esm/layouts/Stack.mjs +6 -6
  78. package/dist/esm/layouts/Stack.mjs.map +1 -1
  79. package/dist/esm/layouts/Stack.native.js +6 -6
  80. package/dist/esm/layouts/Stack.native.js.map +1 -1
  81. package/dist/esm/layouts/stack-utils/StackScreen.mjs +3 -0
  82. package/dist/esm/layouts/stack-utils/StackScreen.mjs.map +1 -1
  83. package/dist/esm/layouts/stack-utils/StackScreen.native.js +3 -0
  84. package/dist/esm/layouts/stack-utils/StackScreen.native.js.map +1 -1
  85. package/dist/esm/layouts/stack-utils/StackToolbar.mjs +384 -0
  86. package/dist/esm/layouts/stack-utils/StackToolbar.mjs.map +1 -0
  87. package/dist/esm/layouts/stack-utils/StackToolbar.native.js +416 -0
  88. package/dist/esm/layouts/stack-utils/StackToolbar.native.js.map +1 -0
  89. package/dist/esm/layouts/stack-utils/StackToolbar.types.mjs +2 -0
  90. package/dist/esm/layouts/stack-utils/StackToolbar.types.mjs.map +1 -0
  91. package/dist/esm/layouts/stack-utils/StackToolbar.types.native.js +2 -0
  92. package/dist/esm/layouts/stack-utils/StackToolbar.types.native.js.map +1 -0
  93. package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.mjs +40 -0
  94. package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.mjs.map +1 -0
  95. package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js +47 -0
  96. package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js.map +1 -0
  97. package/dist/esm/layouts/stack-utils/__tests__/composition.test.mjs +205 -0
  98. package/dist/esm/layouts/stack-utils/__tests__/composition.test.mjs.map +1 -1
  99. package/dist/esm/layouts/stack-utils/__tests__/composition.test.native.js +220 -0
  100. package/dist/esm/layouts/stack-utils/__tests__/composition.test.native.js.map +1 -1
  101. package/dist/esm/layouts/stack-utils/index.mjs +2 -1
  102. package/dist/esm/layouts/stack-utils/index.mjs.map +1 -1
  103. package/dist/esm/layouts/stack-utils/index.native.js +2 -1
  104. package/dist/esm/layouts/stack-utils/index.native.js.map +1 -1
  105. package/dist/esm/layouts/withLayoutContext.mjs +41 -11
  106. package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
  107. package/dist/esm/layouts/withLayoutContext.native.js +45 -11
  108. package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
  109. package/dist/esm/layouts/withLayoutContext.test.mjs +73 -0
  110. package/dist/esm/layouts/withLayoutContext.test.mjs.map +1 -0
  111. package/dist/esm/layouts/withLayoutContext.test.native.js +74 -0
  112. package/dist/esm/layouts/withLayoutContext.test.native.js.map +1 -0
  113. package/dist/esm/router/Route.mjs +3 -1
  114. package/dist/esm/router/Route.mjs.map +1 -1
  115. package/dist/esm/router/Route.native.js +3 -1
  116. package/dist/esm/router/Route.native.js.map +1 -1
  117. package/dist/esm/router/protectedRoutes.test.mjs +23 -0
  118. package/dist/esm/router/protectedRoutes.test.mjs.map +1 -0
  119. package/dist/esm/router/protectedRoutes.test.native.js +23 -0
  120. package/dist/esm/router/protectedRoutes.test.native.js.map +1 -0
  121. package/dist/esm/router/router.mjs +26 -9
  122. package/dist/esm/router/router.mjs.map +1 -1
  123. package/dist/esm/router/router.native.js +26 -9
  124. package/dist/esm/router/router.native.js.map +1 -1
  125. package/dist/esm/router/useScreens.mjs +39 -11
  126. package/dist/esm/router/useScreens.mjs.map +1 -1
  127. package/dist/esm/router/useScreens.native.js +40 -11
  128. package/dist/esm/router/useScreens.native.js.map +1 -1
  129. package/dist/esm/router/useScreens.test.mjs +105 -0
  130. package/dist/esm/router/useScreens.test.mjs.map +1 -0
  131. package/dist/esm/router/useScreens.test.native.js +130 -0
  132. package/dist/esm/router/useScreens.test.native.js.map +1 -0
  133. package/dist/esm/views/Navigator.mjs +15 -7
  134. package/dist/esm/views/Navigator.mjs.map +1 -1
  135. package/dist/esm/views/Navigator.native.js +15 -7
  136. package/dist/esm/views/Navigator.native.js.map +1 -1
  137. package/dist/esm/views/Protected.mjs.map +1 -1
  138. package/dist/esm/views/Protected.native.js.map +1 -1
  139. package/dist/esm/views/SuspenseFallback.mjs +2 -0
  140. package/dist/esm/views/SuspenseFallback.mjs.map +1 -0
  141. package/dist/esm/views/SuspenseFallback.native.js +2 -0
  142. package/dist/esm/views/SuspenseFallback.native.js.map +1 -0
  143. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +47 -7
  144. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  145. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +47 -7
  146. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  147. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +15 -6
  148. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -1
  149. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +15 -6
  150. package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
  151. package/package.json +12 -11
  152. package/src/cli/dev.ts +0 -1
  153. package/src/cli.ts +0 -3
  154. package/src/image/getImageData.ts +2 -2
  155. package/src/index.ts +12 -0
  156. package/src/layouts/Stack.tsx +6 -4
  157. package/src/layouts/stack-utils/README.md +1 -0
  158. package/src/layouts/stack-utils/StackScreen.tsx +7 -0
  159. package/src/layouts/stack-utils/StackToolbar.tsx +550 -0
  160. package/src/layouts/stack-utils/StackToolbar.types.ts +98 -0
  161. package/src/layouts/stack-utils/__tests__/StackToolbar.runtime.test.tsx +46 -0
  162. package/src/layouts/stack-utils/__tests__/composition.test.tsx +176 -0
  163. package/src/layouts/stack-utils/index.tsx +16 -0
  164. package/src/layouts/withLayoutContext.test.tsx +74 -0
  165. package/src/layouts/withLayoutContext.tsx +71 -12
  166. package/src/router/Route.tsx +8 -0
  167. package/src/router/protectedRoutes.test.ts +35 -0
  168. package/src/router/router.ts +48 -20
  169. package/src/router/useScreens.test.tsx +139 -0
  170. package/src/router/useScreens.tsx +59 -13
  171. package/src/views/Navigator.tsx +25 -5
  172. package/src/views/Protected.tsx +3 -0
  173. package/src/views/SuspenseFallback.ts +7 -0
  174. package/src/vite/plugins/fileSystemRouterPlugin.test.ts +15 -6
  175. package/src/vite/plugins/fileSystemRouterPlugin.tsx +52 -7
  176. package/types/cli/dev.d.ts +0 -1
  177. package/types/cli/dev.d.ts.map +1 -1
  178. package/types/image/getImageData.d.ts +1 -1
  179. package/types/image/getImageData.d.ts.map +1 -1
  180. package/types/index.d.ts +2 -1
  181. package/types/index.d.ts.map +1 -1
  182. package/types/layouts/Stack.d.ts +11 -0
  183. package/types/layouts/Stack.d.ts.map +1 -1
  184. package/types/layouts/stack-utils/StackScreen.d.ts.map +1 -1
  185. package/types/layouts/stack-utils/StackToolbar.d.ts +26 -0
  186. package/types/layouts/stack-utils/StackToolbar.d.ts.map +1 -0
  187. package/types/layouts/stack-utils/StackToolbar.types.d.ts +82 -0
  188. package/types/layouts/stack-utils/StackToolbar.types.d.ts.map +1 -0
  189. package/types/layouts/stack-utils/index.d.ts +3 -1
  190. package/types/layouts/stack-utils/index.d.ts.map +1 -1
  191. package/types/layouts/withLayoutContext.d.ts +7 -0
  192. package/types/layouts/withLayoutContext.d.ts.map +1 -1
  193. package/types/layouts/withLayoutContext.test.d.ts +2 -0
  194. package/types/layouts/withLayoutContext.test.d.ts.map +1 -0
  195. package/types/router/Route.d.ts +4 -0
  196. package/types/router/Route.d.ts.map +1 -1
  197. package/types/router/protectedRoutes.test.d.ts +2 -0
  198. package/types/router/protectedRoutes.test.d.ts.map +1 -0
  199. package/types/router/router.d.ts +4 -6
  200. package/types/router/router.d.ts.map +1 -1
  201. package/types/router/useScreens.d.ts.map +1 -1
  202. package/types/router/useScreens.test.d.ts +2 -0
  203. package/types/router/useScreens.test.d.ts.map +1 -0
  204. package/types/views/Navigator.d.ts.map +1 -1
  205. package/types/views/Protected.d.ts +3 -0
  206. package/types/views/Protected.d.ts.map +1 -1
  207. package/types/views/SuspenseFallback.d.ts +8 -0
  208. package/types/views/SuspenseFallback.d.ts.map +1 -0
  209. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
@@ -0,0 +1,419 @@
1
+ "use client";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: () => from[key],
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
+ value: true
24
+ }), mod);
25
+ var StackToolbar_exports = {};
26
+ __export(StackToolbar_exports, {
27
+ StackToolbar: () => StackToolbar,
28
+ StackToolbarBadge: () => StackToolbarBadge,
29
+ StackToolbarButton: () => StackToolbarButton,
30
+ StackToolbarIcon: () => StackToolbarIcon,
31
+ StackToolbarLabel: () => StackToolbarLabel,
32
+ StackToolbarMenu: () => StackToolbarMenu,
33
+ StackToolbarMenuAction: () => StackToolbarMenuAction,
34
+ StackToolbarSearchBarSlot: () => StackToolbarSearchBarSlot,
35
+ StackToolbarSpacer: () => StackToolbarSpacer,
36
+ StackToolbarView: () => StackToolbarView,
37
+ appendStackToolbarPropsToOptions: () => appendStackToolbarPropsToOptions
38
+ });
39
+ module.exports = __toCommonJS(StackToolbar_exports);
40
+ var import_native = require("@vxrn/native");
41
+ var import_react = require("react");
42
+ var import_react_native = require("react-native-web");
43
+ var import_use_isomorphic_layout_effect = require("@vxrn/use-isomorphic-layout-effect");
44
+ var import_useNavigation = require("../../router/useNavigation.cjs");
45
+ var import_children = require("../../utils/children.cjs");
46
+ var import_jsx_runtime = require("react/jsx-runtime");
47
+ const StackToolbarPlacementContext = (0, import_react.createContext)(null);
48
+ function StackToolbarLabel(_props) {
49
+ return null;
50
+ }
51
+ function StackToolbarIcon(_props) {
52
+ return null;
53
+ }
54
+ function StackToolbarBadge(_props) {
55
+ return null;
56
+ }
57
+ function getToolbarContent(children, icon, iconRenderingMode) {
58
+ let label = "";
59
+ let iconProps = typeof icon === "string" ? {
60
+ sf: icon
61
+ } : icon ? {
62
+ src: icon,
63
+ renderingMode: iconRenderingMode
64
+ } : void 0;
65
+ let badge;
66
+ import_react.Children.forEach(children, child => {
67
+ if (typeof child === "string" || typeof child === "number") {
68
+ label += String(child);
69
+ } else if ((0, import_children.isChildOfType)(child, StackToolbarLabel)) {
70
+ label = child.props.children ?? "";
71
+ } else if ((0, import_children.isChildOfType)(child, StackToolbarIcon)) {
72
+ iconProps = child.props;
73
+ } else if ((0, import_children.isChildOfType)(child, StackToolbarBadge)) {
74
+ badge = child.props;
75
+ }
76
+ });
77
+ return {
78
+ label,
79
+ icon: iconProps,
80
+ badge
81
+ };
82
+ }
83
+ function getHeaderIcon(content, tintColor) {
84
+ if (content.icon?.sf) {
85
+ return {
86
+ type: "sfSymbol",
87
+ name: content.icon.sf
88
+ };
89
+ }
90
+ if (content.icon?.src) {
91
+ return {
92
+ type: "image",
93
+ source: content.icon.src,
94
+ tinted: (content.icon.renderingMode ?? (tintColor ? "template" : "original")) === "template"
95
+ };
96
+ }
97
+ if (content.icon?.xcasset) {
98
+ return {
99
+ type: "image",
100
+ source: {
101
+ uri: content.icon.xcasset
102
+ },
103
+ tinted: (content.icon.renderingMode ?? (tintColor ? "template" : "original")) === "template"
104
+ };
105
+ }
106
+ return void 0;
107
+ }
108
+ function getHeaderItemSharedProps(props, content) {
109
+ const labelStyle = import_react_native.StyleSheet.flatten(props.style);
110
+ const badgeStyle = import_react_native.StyleSheet.flatten(content.badge?.style);
111
+ return {
112
+ label: content.label,
113
+ labelStyle,
114
+ icon: getHeaderIcon(content, props.tintColor),
115
+ variant: props.variant,
116
+ tintColor: props.tintColor,
117
+ disabled: props.disabled,
118
+ hidesSharedBackground: props.hidesSharedBackground,
119
+ sharesBackground: !props.separateBackground,
120
+ accessibilityLabel: props.accessibilityLabel ?? content.label,
121
+ accessibilityHint: props.accessibilityHint,
122
+ badge: content.badge ? {
123
+ value: content.badge.children ?? "",
124
+ style: badgeStyle
125
+ } : void 0
126
+ };
127
+ }
128
+ function getMenuItems(children) {
129
+ return import_react.Children.toArray(children).map(child => {
130
+ if ((0, import_children.isChildOfType)(child, StackToolbarMenuAction)) {
131
+ const content = getToolbarContent(child.props.children, child.props.icon, child.props.iconRenderingMode);
132
+ return {
133
+ type: "action",
134
+ label: content.label,
135
+ description: child.props.subtitle,
136
+ icon: getHeaderIcon(content, child.props.tintColor),
137
+ onPress: child.props.onPress ?? (() => {}),
138
+ state: child.props.isOn ? "on" : "off",
139
+ disabled: child.props.disabled,
140
+ destructive: child.props.destructive,
141
+ hidden: child.props.hidden,
142
+ keepsMenuPresented: child.props.unstable_keepPresented,
143
+ discoverabilityLabel: child.props.discoverabilityLabel
144
+ };
145
+ }
146
+ if ((0, import_children.isChildOfType)(child, StackToolbarMenu)) {
147
+ const content = getToolbarContent(child.props.children, child.props.icon, child.props.iconRenderingMode);
148
+ return {
149
+ type: "submenu",
150
+ label: content.label || child.props.title || "",
151
+ icon: getHeaderIcon(content, child.props.tintColor),
152
+ inline: child.props.inline,
153
+ layout: child.props.palette ? "palette" : "default",
154
+ destructive: child.props.destructive,
155
+ multiselectable: child.props.singleSelection === false,
156
+ items: getMenuItems(child.props.children)
157
+ };
158
+ }
159
+ return null;
160
+ }).filter(item => Boolean(item));
161
+ }
162
+ function convertToolbarChildToHeaderItem(child) {
163
+ if ((0, import_children.isChildOfType)(child, StackToolbarButton)) {
164
+ if (child.props.hidden) return null;
165
+ const content = getToolbarContent(child.props.children, child.props.icon, child.props.iconRenderingMode);
166
+ return {
167
+ ...getHeaderItemSharedProps(child.props, content),
168
+ type: "button",
169
+ onPress: child.props.onPress ?? (() => {}),
170
+ selected: child.props.selected
171
+ };
172
+ }
173
+ if ((0, import_children.isChildOfType)(child, StackToolbarMenu)) {
174
+ if (child.props.hidden) return null;
175
+ const content = getToolbarContent(child.props.children, child.props.icon, child.props.iconRenderingMode);
176
+ const contentWithTitle = {
177
+ ...content,
178
+ label: content.label || child.props.title || ""
179
+ };
180
+ return {
181
+ ...getHeaderItemSharedProps(child.props, contentWithTitle),
182
+ type: "menu",
183
+ menu: {
184
+ title: child.props.title,
185
+ multiselectable: child.props.singleSelection === false,
186
+ layout: child.props.palette ? "palette" : "default",
187
+ items: getMenuItems(child.props.children)
188
+ }
189
+ };
190
+ }
191
+ if ((0, import_children.isChildOfType)(child, StackToolbarSpacer)) {
192
+ if (child.props.hidden) return null;
193
+ if (child.props.width === void 0) {
194
+ if (process.env.NODE_ENV !== "production") {
195
+ console.warn("Stack.Toolbar.Spacer requires a width in header placements.");
196
+ }
197
+ return null;
198
+ }
199
+ return {
200
+ type: "spacing",
201
+ spacing: child.props.width
202
+ };
203
+ }
204
+ if ((0, import_children.isChildOfType)(child, StackToolbarView)) {
205
+ if (child.props.hidden) return null;
206
+ return {
207
+ type: "custom",
208
+ element: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react.Fragment, {
209
+ children: child.props.children
210
+ }),
211
+ hidesSharedBackground: child.props.hidesSharedBackground
212
+ };
213
+ }
214
+ return null;
215
+ }
216
+ function appendStackToolbarPropsToOptions(options, props) {
217
+ if (import_react_native.Platform.OS !== "ios") return options;
218
+ const placement = props.placement ?? "bottom";
219
+ if (placement === "bottom") {
220
+ if (process.env.NODE_ENV !== "production") {
221
+ console.warn("Stack.Toolbar with bottom placement must be rendered in a page component, not inside Stack.Screen.");
222
+ }
223
+ return options;
224
+ }
225
+ if (placement !== "left" && placement !== "right") {
226
+ throw new Error(`Invalid placement "${placement}" for Stack.Toolbar. Expected "left", "right", or "bottom".`);
227
+ }
228
+ if (props.asChild) {
229
+ return placement === "left" ? {
230
+ ...options,
231
+ headerShown: true,
232
+ headerLeft: () => props.children
233
+ } : {
234
+ ...options,
235
+ headerShown: true,
236
+ headerRight: () => props.children
237
+ };
238
+ }
239
+ const allChildren = import_react.Children.toArray(props.children);
240
+ const items = allChildren.map(convertToolbarChildToHeaderItem).filter(item => Boolean(item));
241
+ if (process.env.NODE_ENV !== "production" && items.length !== allChildren.length) {
242
+ const invalidChildren = allChildren.filter(child => !(0, import_children.isChildOfType)(child, StackToolbarButton) && !(0, import_children.isChildOfType)(child, StackToolbarMenu) && !(0, import_children.isChildOfType)(child, StackToolbarSpacer) && !(0, import_children.isChildOfType)(child, StackToolbarView));
243
+ if (invalidChildren.length) {
244
+ console.warn(`Stack.Toolbar with placement="${placement}" only accepts Stack.Toolbar.Button, Menu, Spacer, and View children.`);
245
+ }
246
+ }
247
+ const getItems = () => items;
248
+ return placement === "left" ? {
249
+ ...options,
250
+ headerShown: true,
251
+ unstable_headerLeftItems: getItems
252
+ } : {
253
+ ...options,
254
+ headerShown: true,
255
+ unstable_headerRightItems: getItems
256
+ };
257
+ }
258
+ function StackToolbarComponent(props) {
259
+ const parentPlacement = (0, import_react.useContext)(StackToolbarPlacementContext);
260
+ const navigation = (0, import_useNavigation.useNavigation)();
261
+ const placement = props.placement ?? "bottom";
262
+ const options = (0, import_react.useMemo)(() => placement === "bottom" ? {} : appendStackToolbarPropsToOptions({}, props), [placement, props.asChild, props.children]);
263
+ if (parentPlacement) {
264
+ throw new Error("Stack.Toolbar cannot be nested inside another Stack.Toolbar.");
265
+ }
266
+ (0, import_use_isomorphic_layout_effect.useIsomorphicLayoutEffect)(() => {
267
+ if (import_react_native.Platform.OS !== "ios" || placement === "bottom") return;
268
+ navigation.setOptions(options);
269
+ }, [navigation, options, placement]);
270
+ if (import_react_native.Platform.OS !== "ios" || placement !== "bottom") return null;
271
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(StackToolbarPlacementContext.Provider, {
272
+ value: "bottom",
273
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.ToolbarHost, {
274
+ children: props.children
275
+ })
276
+ });
277
+ }
278
+ function StackToolbarButton(props) {
279
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
280
+ const identifier = (0, import_react.useId)();
281
+ if (import_react_native.Platform.OS !== "ios") return null;
282
+ if (!placement) throw new Error("Stack.Toolbar.Button must be used inside Stack.Toolbar.");
283
+ const content = getToolbarContent(props.children, props.icon, props.iconRenderingMode);
284
+ const badgeStyle = import_react_native.StyleSheet.flatten(content.badge?.style);
285
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.ToolbarItem, {
286
+ identifier,
287
+ title: content.label,
288
+ systemImageName: content.icon?.sf,
289
+ xcassetName: content.icon?.xcasset,
290
+ image: props.image ?? content.icon?.src,
291
+ imageRenderingMode: content.icon?.renderingMode ?? props.iconRenderingMode ?? (props.tintColor ? "template" : "original"),
292
+ tintColor: props.tintColor,
293
+ hidesSharedBackground: props.hidesSharedBackground,
294
+ sharesBackground: !props.separateBackground,
295
+ barButtonItemStyle: props.variant === "done" ? "prominent" : props.variant,
296
+ hidden: props.hidden,
297
+ selected: props.selected,
298
+ badgeConfiguration: content.badge ? {
299
+ value: content.badge.children,
300
+ backgroundColor: badgeStyle?.backgroundColor,
301
+ color: badgeStyle?.color,
302
+ fontFamily: badgeStyle?.fontFamily,
303
+ fontSize: badgeStyle?.fontSize,
304
+ fontWeight: badgeStyle?.fontWeight
305
+ } : void 0,
306
+ titleStyle: import_react_native.StyleSheet.flatten(props.style),
307
+ accessibilityLabel: props.accessibilityLabel ?? content.label,
308
+ accessibilityHint: props.accessibilityHint,
309
+ disabled: props.disabled,
310
+ onSelected: props.onPress
311
+ });
312
+ }
313
+ function StackToolbarMenu(props) {
314
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
315
+ const identifier = (0, import_react.useId)();
316
+ if (import_react_native.Platform.OS !== "ios") return null;
317
+ if (!placement) throw new Error("Stack.Toolbar.Menu must be used inside Stack.Toolbar.");
318
+ const content = getToolbarContent(props.children, props.icon, props.iconRenderingMode);
319
+ const actions = import_react.Children.toArray(props.children).filter(child => (0, import_children.isChildOfType)(child, StackToolbarMenu) || (0, import_children.isChildOfType)(child, StackToolbarMenuAction));
320
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.MenuAction, {
321
+ identifier,
322
+ title: props.title ?? "",
323
+ label: content.label || props.title,
324
+ icon: content.icon?.sf,
325
+ xcassetName: content.icon?.xcasset,
326
+ image: props.image ?? content.icon?.src,
327
+ imageRenderingMode: content.icon?.renderingMode ?? props.iconRenderingMode ?? (props.tintColor ? "template" : "original"),
328
+ disabled: props.disabled,
329
+ destructive: props.destructive,
330
+ hidden: props.hidden,
331
+ accessibilityLabel: props.accessibilityLabel ?? (content.label || props.title),
332
+ accessibilityHint: props.accessibilityHint,
333
+ displayInline: props.inline,
334
+ displayAsPalette: props.palette,
335
+ singleSelection: props.singleSelection,
336
+ preferredElementSize: props.elementSize,
337
+ tintColor: props.tintColor,
338
+ barButtonItemStyle: props.variant === "done" ? "prominent" : props.variant,
339
+ sharesBackground: !props.separateBackground,
340
+ hidesSharedBackground: props.hidesSharedBackground,
341
+ titleStyle: import_react_native.StyleSheet.flatten(props.style),
342
+ children: actions
343
+ });
344
+ }
345
+ function StackToolbarMenuAction(props) {
346
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
347
+ const identifier = (0, import_react.useId)();
348
+ if (import_react_native.Platform.OS !== "ios") return null;
349
+ if (!placement) throw new Error("Stack.Toolbar.MenuAction must be used inside Stack.Toolbar.Menu.");
350
+ const content = getToolbarContent(props.children, props.icon, props.iconRenderingMode);
351
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.MenuAction, {
352
+ identifier,
353
+ title: content.label,
354
+ icon: content.icon?.sf,
355
+ xcassetName: content.icon?.xcasset,
356
+ image: props.image ?? content.icon?.src,
357
+ imageRenderingMode: content.icon?.renderingMode ?? props.iconRenderingMode ?? (props.tintColor ? "template" : "original"),
358
+ disabled: props.disabled,
359
+ destructive: props.destructive,
360
+ discoverabilityLabel: props.discoverabilityLabel,
361
+ subtitle: props.subtitle,
362
+ accessibilityLabel: props.accessibilityLabel ?? content.label,
363
+ accessibilityHint: props.accessibilityHint,
364
+ isOn: props.isOn,
365
+ keepPresented: props.unstable_keepPresented,
366
+ hidden: props.hidden,
367
+ onSelected: props.onPress
368
+ });
369
+ }
370
+ function StackToolbarSpacer(props) {
371
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
372
+ const identifier = (0, import_react.useId)();
373
+ if (import_react_native.Platform.OS !== "ios") return null;
374
+ if (!placement) throw new Error("Stack.Toolbar.Spacer must be used inside Stack.Toolbar.");
375
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.ToolbarItem, {
376
+ identifier,
377
+ type: props.width === void 0 ? "fluidSpacer" : "fixedSpacer",
378
+ width: props.width,
379
+ hidden: props.hidden,
380
+ sharesBackground: props.sharesBackground
381
+ });
382
+ }
383
+ function StackToolbarSearchBarSlot(props) {
384
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
385
+ const identifier = (0, import_react.useId)();
386
+ if (import_react_native.Platform.OS !== "ios") return null;
387
+ if (!placement) throw new Error("Stack.Toolbar.SearchBarSlot must be used inside Stack.Toolbar.");
388
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.ToolbarItem, {
389
+ identifier,
390
+ type: "searchBar",
391
+ hidden: props.hidden,
392
+ hidesSharedBackground: props.hidesSharedBackground,
393
+ sharesBackground: !props.separateBackground
394
+ });
395
+ }
396
+ function StackToolbarView(props) {
397
+ const placement = (0, import_react.useContext)(StackToolbarPlacementContext);
398
+ const identifier = (0, import_react.useId)();
399
+ if (import_react_native.Platform.OS !== "ios") return null;
400
+ if (!placement) throw new Error("Stack.Toolbar.View must be used inside Stack.Toolbar.");
401
+ if (props.hidden) return null;
402
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_native.ToolbarItem, {
403
+ identifier,
404
+ hidesSharedBackground: props.hidesSharedBackground,
405
+ sharesBackground: !props.separateBackground,
406
+ children: props.children
407
+ });
408
+ }
409
+ const StackToolbar = Object.assign(StackToolbarComponent, {
410
+ Button: StackToolbarButton,
411
+ Menu: StackToolbarMenu,
412
+ MenuAction: StackToolbarMenuAction,
413
+ Spacer: StackToolbarSpacer,
414
+ SearchBarSlot: StackToolbarSearchBarSlot,
415
+ View: StackToolbarView,
416
+ Label: StackToolbarLabel,
417
+ Icon: StackToolbarIcon,
418
+ Badge: StackToolbarBadge
419
+ });