import { Route, createBrowserRouter, createRoutesFromElements, RouterProvider, redirect, } from "react-router-dom"; import MainLayout from "./MainLayout"; import Home from "./Home"; import DocsLayout from "./DocsLayout"; import ErrorBoundary from "./ErrorHandler"; import DynamicLayout from "./DynamicLayout"; import DocsIntroduction, { tableOfContents as docsIntroductionToc, } from "./docs/docs/introduction.mdx"; import DocsInstallation, { tableOfContents as docsInstallationToc, } from "./docs/docs/installation.mdx"; import ComponentsButton, { tableOfContents as componentsButtonToc, } from "./docs/components/Button.mdx"; import ComponentsCheckbox, { tableOfContents as componentsCheckboxToc, } from "./docs/components/Checkbox.mdx"; import ComponentsDialog, { tableOfContents as componentsDialogToc, } from "./docs/components/Dialog.mdx"; import ComponentsDrawer, { tableOfContents as componentsDrawerToc, } from "./docs/components/Drawer.mdx"; import ComponentsTabs, { tableOfContents as componentsTabsToc, } from "./docs/components/Tabs.mdx"; import ComponentsToast, { tableOfContents as componentsToastToc, } from "./docs/components/Toast.mdx"; import { ForwardedRef, forwardRef, useContext, useEffect, useRef } from "react"; import { HeadingContext } from "./HeadingContext"; function buildThresholdList() { let thresholds = []; let numSteps = 20; for (let i = 1.0; i <= numSteps; i++) { let ratio = i / numSteps; thresholds.push(ratio); } thresholds.push(0); return thresholds; } function HashedHeaders(Level: `h${1 | 2 | 3 | 4 | 5 | 6}`) { return (prop: any, ref: ForwardedRef) => { const internalRef = useRef(null); const [_, setActiveHeadings] = useContext(HeadingContext); useEffect(() => { const observer = new IntersectionObserver( ([{ target, intersectionRatio }]) => { if (intersectionRatio > 0.5) { setActiveHeadings((prev) => [...prev, target.id]); } else { setActiveHeadings((prev) => prev.filter((id) => id !== target.id)); } }, { root: null, rootMargin: "0px", threshold: buildThresholdList(), } ); if (internalRef.current) { observer.observe(internalRef.current); } return () => { observer.disconnect(); }; }, [internalRef.current]); return ( { internalRef.current = el; if (typeof ref === "function") { ref(el); } else if (el && ref) { ref.current = el; } }} /> ); }; } const overrideComponents = { pre: forwardRef((props: any, ref) => (
  )),
  code: forwardRef((props: any, ref) => (
    
  )),
  table: forwardRef((props: any, ref) => (
    
)), h1: forwardRef(HashedHeaders("h1")), h2: forwardRef(HashedHeaders("h2")), h3: forwardRef(HashedHeaders("h3")), h4: forwardRef(HashedHeaders("h4")), h5: forwardRef(HashedHeaders("h5")), h6: forwardRef(HashedHeaders("h6")), }; const router = createBrowserRouter( createRoutesFromElements( } errorElement={}> } /> }> } /> } /> redirect("/docs/components/button")} /> } /> } /> } /> } /> } /> } /> ) ); function App() { return ( <> ); } export default App;