UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

67 lines (66 loc) 1.91 kB
import { BottomTabBar, createBottomTabNavigator } from "@react-navigation/bottom-tabs"; import { Platform, Pressable } from "react-native-web"; import { Link } from "../link/Link.mjs"; import { Protected } from "../views/Protected.mjs"; import { withLayoutContext } from "./withLayoutContext.mjs"; import { jsx } from "react/jsx-runtime"; const TabBar = ({ state, ...restProps }) => { const filteredRoutes = state.routes.filter(r => r.name !== "+not-found" && !r.name.startsWith("_sitemap")); return /* @__PURE__ */jsx(BottomTabBar, { state: { ...state, routes: filteredRoutes }, ...restProps }); }; const BottomTabNavigator = createBottomTabNavigator().Navigator; const Tabs = Object.assign(withLayoutContext(BottomTabNavigator, screens => { return screens.map(screen => { if (typeof screen.options !== "function" && screen.options?.href !== void 0) { const { href, ...options } = screen.options; if (options.tabBarButton) { throw new Error("Cannot use `href` and `tabBarButton` together."); } return { ...screen, options: { ...options, tabBarButton: props => { if (href == null) { return null; } const children = Platform.OS === "web" ? props.children : /* @__PURE__ */jsx(Pressable, { children: props.children }); return /* @__PURE__ */jsx(Link, { ...props, style: [{ display: "flex" }, props.style], href, asChild: Platform.OS !== "web", children }); } } }; } return screen; }); }, { props: { tabBar: TabBar } }), { Protected }); var Tabs_default = Tabs; export { Tabs, Tabs_default as default }; //# sourceMappingURL=Tabs.mjs.map