one
Version:
One is a new React Framework that makes Vite serve both native and web.
1 lines • 4.27 kB
Source Map (JSON)
{"version":3,"names":["Activity","Fragment","useState","useNavigatorContext","TabContext","jsx","useTabSlot","detachInactiveScreens","renderFn","defaultTabsSlotRender","state","descriptorsRef","descriptors","current","focusedRouteKey","routes","index","key","loaded","setLoaded","children","map","route","descriptor","Provider","value","options","isFocused","TabSlot","props","lazy","unmountOnBlur","mode","render","isTabSlot","child","type"],"sources":["TabSlot.mjs"],"sourcesContent":["import {\n Activity,\n Fragment,\n useState\n} from \"react\";\nimport { useNavigatorContext } from \"../views/Navigator\";\nimport { TabContext } from \"./TabContext\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction useTabSlot({\n detachInactiveScreens = true,\n renderFn = defaultTabsSlotRender\n} = {}) {\n const { state, descriptorsRef } = useNavigatorContext();\n const descriptors = descriptorsRef.current;\n const focusedRouteKey = state.routes[state.index].key;\n const [loaded, setLoaded] = useState({ [focusedRouteKey]: true });\n if (!loaded[focusedRouteKey]) {\n setLoaded({ ...loaded, [focusedRouteKey]: true });\n }\n return /* @__PURE__ */ jsx(Fragment, { children: state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n return /* @__PURE__ */ jsx(TabContext.Provider, { value: descriptor.options, children: renderFn(descriptor, {\n index,\n isFocused: state.index === index,\n loaded: loaded[route.key],\n detachInactiveScreens\n }) }, descriptor.route.key);\n }) });\n}\nfunction TabSlot(props) {\n return useTabSlot(props);\n}\nfunction defaultTabsSlotRender(descriptor, { isFocused, loaded, detachInactiveScreens }) {\n const { lazy = true, unmountOnBlur } = descriptor.options;\n if ((unmountOnBlur || detachInactiveScreens) && !isFocused) return null;\n if (lazy && !loaded && !isFocused) return null;\n if (!isFocused) {\n return /* @__PURE__ */ jsx(Activity, { mode: \"hidden\", children: descriptor.render() }, descriptor.route.key);\n }\n return /* @__PURE__ */ jsx(Fragment, { children: descriptor.render() }, descriptor.route.key);\n}\nfunction isTabSlot(child) {\n return child.type === TabSlot;\n}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