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.
- package/dist/cjs/cli/dev.native.js.map +1 -1
- package/dist/cjs/cli.cjs +0 -3
- package/dist/cjs/cli.native.js +0 -3
- package/dist/cjs/cli.native.js.map +1 -1
- package/dist/cjs/image/getImageData.cjs +1 -1
- package/dist/cjs/image/getImageData.native.js +1 -1
- package/dist/cjs/image/getImageData.native.js.map +1 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/layouts/Stack.cjs +5 -5
- package/dist/cjs/layouts/Stack.native.js +5 -5
- package/dist/cjs/layouts/Stack.native.js.map +1 -1
- package/dist/cjs/layouts/stack-utils/StackScreen.cjs +3 -0
- package/dist/cjs/layouts/stack-utils/StackScreen.native.js +3 -0
- package/dist/cjs/layouts/stack-utils/StackScreen.native.js.map +1 -1
- package/dist/cjs/layouts/stack-utils/StackToolbar.cjs +419 -0
- package/dist/cjs/layouts/stack-utils/StackToolbar.native.js +453 -0
- package/dist/cjs/layouts/stack-utils/StackToolbar.native.js.map +1 -0
- package/dist/cjs/layouts/stack-utils/StackToolbar.types.cjs +18 -0
- package/dist/cjs/layouts/stack-utils/StackToolbar.types.native.js +21 -0
- package/dist/cjs/layouts/stack-utils/StackToolbar.types.native.js.map +1 -0
- package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.cjs +63 -0
- package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js +73 -0
- package/dist/cjs/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js.map +1 -0
- package/dist/cjs/layouts/stack-utils/__tests__/composition.test.cjs +205 -0
- package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js +220 -0
- package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js.map +1 -1
- package/dist/cjs/layouts/stack-utils/index.cjs +2 -0
- package/dist/cjs/layouts/stack-utils/index.native.js +2 -0
- package/dist/cjs/layouts/stack-utils/index.native.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.cjs +39 -8
- package/dist/cjs/layouts/withLayoutContext.native.js +43 -8
- package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.test.cjs +96 -0
- package/dist/cjs/layouts/withLayoutContext.test.native.js +100 -0
- package/dist/cjs/layouts/withLayoutContext.test.native.js.map +1 -0
- package/dist/cjs/router/Route.cjs +3 -0
- package/dist/cjs/router/Route.native.js +3 -0
- package/dist/cjs/router/Route.native.js.map +1 -1
- package/dist/cjs/router/protectedRoutes.test.cjs +22 -0
- package/dist/cjs/router/protectedRoutes.test.native.js +25 -0
- package/dist/cjs/router/protectedRoutes.test.native.js.map +1 -0
- package/dist/cjs/router/router.cjs +26 -8
- package/dist/cjs/router/router.native.js +26 -8
- package/dist/cjs/router/router.native.js.map +1 -1
- package/dist/cjs/router/useScreens.cjs +38 -11
- package/dist/cjs/router/useScreens.native.js +39 -11
- package/dist/cjs/router/useScreens.native.js.map +1 -1
- package/dist/cjs/router/useScreens.test.cjs +134 -0
- package/dist/cjs/router/useScreens.test.native.js +163 -0
- package/dist/cjs/router/useScreens.test.native.js.map +1 -0
- package/dist/cjs/views/Navigator.cjs +14 -6
- package/dist/cjs/views/Navigator.native.js +14 -6
- package/dist/cjs/views/Navigator.native.js.map +1 -1
- package/dist/cjs/views/Protected.native.js.map +1 -1
- package/dist/cjs/views/SuspenseFallback.cjs +18 -0
- package/dist/cjs/views/SuspenseFallback.native.js +21 -0
- package/dist/cjs/views/SuspenseFallback.native.js.map +1 -0
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.cjs +47 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +47 -7
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.cjs +15 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js +15 -6
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
- package/dist/esm/cli/dev.mjs.map +1 -1
- package/dist/esm/cli/dev.native.js.map +1 -1
- package/dist/esm/cli.mjs +0 -3
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.native.js +0 -3
- package/dist/esm/cli.native.js.map +1 -1
- package/dist/esm/image/getImageData.mjs +1 -1
- package/dist/esm/image/getImageData.mjs.map +1 -1
- package/dist/esm/image/getImageData.native.js +1 -1
- package/dist/esm/image/getImageData.native.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/layouts/Stack.mjs +6 -6
- package/dist/esm/layouts/Stack.mjs.map +1 -1
- package/dist/esm/layouts/Stack.native.js +6 -6
- package/dist/esm/layouts/Stack.native.js.map +1 -1
- package/dist/esm/layouts/stack-utils/StackScreen.mjs +3 -0
- package/dist/esm/layouts/stack-utils/StackScreen.mjs.map +1 -1
- package/dist/esm/layouts/stack-utils/StackScreen.native.js +3 -0
- package/dist/esm/layouts/stack-utils/StackScreen.native.js.map +1 -1
- package/dist/esm/layouts/stack-utils/StackToolbar.mjs +384 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.mjs.map +1 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.native.js +416 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.native.js.map +1 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.types.mjs +2 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.types.mjs.map +1 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.types.native.js +2 -0
- package/dist/esm/layouts/stack-utils/StackToolbar.types.native.js.map +1 -0
- package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.mjs +40 -0
- package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.mjs.map +1 -0
- package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js +47 -0
- package/dist/esm/layouts/stack-utils/__tests__/StackToolbar.runtime.test.native.js.map +1 -0
- package/dist/esm/layouts/stack-utils/__tests__/composition.test.mjs +205 -0
- package/dist/esm/layouts/stack-utils/__tests__/composition.test.mjs.map +1 -1
- package/dist/esm/layouts/stack-utils/__tests__/composition.test.native.js +220 -0
- package/dist/esm/layouts/stack-utils/__tests__/composition.test.native.js.map +1 -1
- package/dist/esm/layouts/stack-utils/index.mjs +2 -1
- package/dist/esm/layouts/stack-utils/index.mjs.map +1 -1
- package/dist/esm/layouts/stack-utils/index.native.js +2 -1
- package/dist/esm/layouts/stack-utils/index.native.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs +41 -11
- package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js +45 -11
- package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.test.mjs +73 -0
- package/dist/esm/layouts/withLayoutContext.test.mjs.map +1 -0
- package/dist/esm/layouts/withLayoutContext.test.native.js +74 -0
- package/dist/esm/layouts/withLayoutContext.test.native.js.map +1 -0
- package/dist/esm/router/Route.mjs +3 -1
- package/dist/esm/router/Route.mjs.map +1 -1
- package/dist/esm/router/Route.native.js +3 -1
- package/dist/esm/router/Route.native.js.map +1 -1
- package/dist/esm/router/protectedRoutes.test.mjs +23 -0
- package/dist/esm/router/protectedRoutes.test.mjs.map +1 -0
- package/dist/esm/router/protectedRoutes.test.native.js +23 -0
- package/dist/esm/router/protectedRoutes.test.native.js.map +1 -0
- package/dist/esm/router/router.mjs +26 -9
- package/dist/esm/router/router.mjs.map +1 -1
- package/dist/esm/router/router.native.js +26 -9
- package/dist/esm/router/router.native.js.map +1 -1
- package/dist/esm/router/useScreens.mjs +39 -11
- package/dist/esm/router/useScreens.mjs.map +1 -1
- package/dist/esm/router/useScreens.native.js +40 -11
- package/dist/esm/router/useScreens.native.js.map +1 -1
- package/dist/esm/router/useScreens.test.mjs +105 -0
- package/dist/esm/router/useScreens.test.mjs.map +1 -0
- package/dist/esm/router/useScreens.test.native.js +130 -0
- package/dist/esm/router/useScreens.test.native.js.map +1 -0
- package/dist/esm/views/Navigator.mjs +15 -7
- package/dist/esm/views/Navigator.mjs.map +1 -1
- package/dist/esm/views/Navigator.native.js +15 -7
- package/dist/esm/views/Navigator.native.js.map +1 -1
- package/dist/esm/views/Protected.mjs.map +1 -1
- package/dist/esm/views/Protected.native.js.map +1 -1
- package/dist/esm/views/SuspenseFallback.mjs +2 -0
- package/dist/esm/views/SuspenseFallback.mjs.map +1 -0
- package/dist/esm/views/SuspenseFallback.native.js +2 -0
- package/dist/esm/views/SuspenseFallback.native.js.map +1 -0
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs +47 -7
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +47 -7
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs +15 -6
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js +15 -6
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.test.native.js.map +1 -1
- package/package.json +12 -11
- package/src/cli/dev.ts +0 -1
- package/src/cli.ts +0 -3
- package/src/image/getImageData.ts +2 -2
- package/src/index.ts +12 -0
- package/src/layouts/Stack.tsx +6 -4
- package/src/layouts/stack-utils/README.md +1 -0
- package/src/layouts/stack-utils/StackScreen.tsx +7 -0
- package/src/layouts/stack-utils/StackToolbar.tsx +550 -0
- package/src/layouts/stack-utils/StackToolbar.types.ts +98 -0
- package/src/layouts/stack-utils/__tests__/StackToolbar.runtime.test.tsx +46 -0
- package/src/layouts/stack-utils/__tests__/composition.test.tsx +176 -0
- package/src/layouts/stack-utils/index.tsx +16 -0
- package/src/layouts/withLayoutContext.test.tsx +74 -0
- package/src/layouts/withLayoutContext.tsx +71 -12
- package/src/router/Route.tsx +8 -0
- package/src/router/protectedRoutes.test.ts +35 -0
- package/src/router/router.ts +48 -20
- package/src/router/useScreens.test.tsx +139 -0
- package/src/router/useScreens.tsx +59 -13
- package/src/views/Navigator.tsx +25 -5
- package/src/views/Protected.tsx +3 -0
- package/src/views/SuspenseFallback.ts +7 -0
- package/src/vite/plugins/fileSystemRouterPlugin.test.ts +15 -6
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +52 -7
- package/types/cli/dev.d.ts +0 -1
- package/types/cli/dev.d.ts.map +1 -1
- package/types/image/getImageData.d.ts +1 -1
- package/types/image/getImageData.d.ts.map +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/layouts/Stack.d.ts +11 -0
- package/types/layouts/Stack.d.ts.map +1 -1
- package/types/layouts/stack-utils/StackScreen.d.ts.map +1 -1
- package/types/layouts/stack-utils/StackToolbar.d.ts +26 -0
- package/types/layouts/stack-utils/StackToolbar.d.ts.map +1 -0
- package/types/layouts/stack-utils/StackToolbar.types.d.ts +82 -0
- package/types/layouts/stack-utils/StackToolbar.types.d.ts.map +1 -0
- package/types/layouts/stack-utils/index.d.ts +3 -1
- package/types/layouts/stack-utils/index.d.ts.map +1 -1
- package/types/layouts/withLayoutContext.d.ts +7 -0
- package/types/layouts/withLayoutContext.d.ts.map +1 -1
- package/types/layouts/withLayoutContext.test.d.ts +2 -0
- package/types/layouts/withLayoutContext.test.d.ts.map +1 -0
- package/types/router/Route.d.ts +4 -0
- package/types/router/Route.d.ts.map +1 -1
- package/types/router/protectedRoutes.test.d.ts +2 -0
- package/types/router/protectedRoutes.test.d.ts.map +1 -0
- package/types/router/router.d.ts +4 -6
- package/types/router/router.d.ts.map +1 -1
- package/types/router/useScreens.d.ts.map +1 -1
- package/types/router/useScreens.test.d.ts +2 -0
- package/types/router/useScreens.test.d.ts.map +1 -0
- package/types/views/Navigator.d.ts.map +1 -1
- package/types/views/Protected.d.ts +3 -0
- package/types/views/Protected.d.ts.map +1 -1
- package/types/views/SuspenseFallback.d.ts +8 -0
- package/types/views/SuspenseFallback.d.ts.map +1 -0
- 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
|
+
});
|