one
Version:
One is a React framework for web, iOS, and Android apps.
1 lines • 1.86 kB
Source Map (JSON)
{"version":3,"file":"useTabs.js","names":[],"sources":["esm/headless/useTabs.js"],"sourcesContent":["\"use client\";\nimport { use, useMemo } from \"react\";\nimport { appendBaseUrl } from \"../fork/getPathFromState-mods\";\nimport { stripGroupSegmentsFromPath } from \"../router/matchers\";\nimport { TabTriggerMapContext } from \"../ui/TabContext\";\nimport { useNavigatorContext } from \"../views/Navigator\";\nfunction useTabs() {\n const { state, descriptorsRef } = useNavigatorContext();\n const triggerMap = use(TabTriggerMapContext);\n const descriptors = descriptorsRef.current;\n return useMemo(() => {\n const screens = state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const config = triggerMap[route.name];\n return {\n key: route.key,\n name: route.name,\n params: route.params ?? {},\n href: config ? stripGroupSegmentsFromPath(appendBaseUrl(config.href)) : \"\",\n isFocused: index === state.index,\n keepMounted: descriptor.options.keepMounted === true,\n options: descriptor.options,\n element: descriptor.render()\n };\n });\n return { screens, focused: screens[state.index] };\n }, [descriptors, state, triggerMap]);\n}\nexport {\n useTabs\n};\n//# sourceMappingURL=useTabs.js.map\n"],"mappings":";;;;;;;;;AAMA,SAAS,UAAU;CACjB,MAAM,EAAE,OAAO,mBAAmB,oBAAoB;CACtD,MAAM,aAAa,IAAI,oBAAoB;CAC3C,MAAM,cAAc,eAAe;CACnC,OAAO,cAAc;EACnB,MAAM,UAAU,MAAM,OAAO,KAAK,OAAO,UAAU;GACjD,MAAM,aAAa,YAAY,MAAM;GACrC,MAAM,SAAS,WAAW,MAAM;GAChC,OAAO;IACL,KAAK,MAAM;IACX,MAAM,MAAM;IACZ,QAAQ,MAAM,UAAU,CAAC;IACzB,MAAM,SAAS,2BAA2B,cAAc,OAAO,IAAI,CAAC,IAAI;IACxE,WAAW,UAAU,MAAM;IAC3B,aAAa,WAAW,QAAQ,gBAAgB;IAChD,SAAS,WAAW;IACpB,SAAS,WAAW,OAAO;GAC7B;EACF,CAAC;EACD,OAAO;GAAE;GAAS,SAAS,QAAQ,MAAM;EAAO;CAClD,GAAG;EAAC;EAAa;EAAO;CAAU,CAAC;AACrC"}