docstra 1.9.9-next.5 → 1.9.9-next.7
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/client/index.d.mts
CHANGED
|
@@ -15,7 +15,6 @@ interface IDocstraProvider {
|
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
docstraConfig: DocstraConfig;
|
|
17
17
|
page: any;
|
|
18
|
-
sidebarItems: SidebarItem[];
|
|
19
18
|
}
|
|
20
19
|
interface DocstraConfig {
|
|
21
20
|
editOnGithub: {
|
|
@@ -61,11 +60,13 @@ interface DocsLinkGroup {
|
|
|
61
60
|
type SidebarItem = {
|
|
62
61
|
type: 'page';
|
|
63
62
|
title: string;
|
|
63
|
+
nav_title?: string;
|
|
64
64
|
href: string;
|
|
65
65
|
icon?: string;
|
|
66
66
|
} | {
|
|
67
67
|
type: 'section';
|
|
68
68
|
title: string;
|
|
69
|
+
nav_title?: string;
|
|
69
70
|
href: string;
|
|
70
71
|
children: SidebarItem[];
|
|
71
72
|
icon?: string;
|
|
@@ -77,20 +78,21 @@ type SidebarItem = {
|
|
|
77
78
|
} | {
|
|
78
79
|
type: 'link';
|
|
79
80
|
title: string;
|
|
81
|
+
nav_title?: string;
|
|
80
82
|
href: string;
|
|
81
83
|
external?: boolean;
|
|
82
84
|
};
|
|
83
85
|
|
|
84
|
-
declare function DocstraProvider({ children, docstraConfig, page
|
|
86
|
+
declare function DocstraProvider({ children, docstraConfig, page }: IDocstraProvider): react_jsx_runtime.JSX.Element;
|
|
85
87
|
declare function useDocstra(): DocstraContextType;
|
|
86
88
|
|
|
87
89
|
declare function DocstraHeader(): react_jsx_runtime.JSX.Element;
|
|
88
90
|
|
|
89
|
-
interface
|
|
91
|
+
interface DocstraLayoutProps {
|
|
90
92
|
children: React.ReactNode;
|
|
91
93
|
sidebarItems: SidebarItem[];
|
|
92
94
|
}
|
|
93
|
-
declare function DocstraLayout({ children, sidebarItems }:
|
|
95
|
+
declare function DocstraLayout({ children, sidebarItems }: DocstraLayoutProps): react_jsx_runtime.JSX.Element;
|
|
94
96
|
|
|
95
97
|
interface Props {
|
|
96
98
|
children: React.ReactNode;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ interface IDocstraProvider {
|
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
docstraConfig: DocstraConfig;
|
|
17
17
|
page: any;
|
|
18
|
-
sidebarItems: SidebarItem[];
|
|
19
18
|
}
|
|
20
19
|
interface DocstraConfig {
|
|
21
20
|
editOnGithub: {
|
|
@@ -61,11 +60,13 @@ interface DocsLinkGroup {
|
|
|
61
60
|
type SidebarItem = {
|
|
62
61
|
type: 'page';
|
|
63
62
|
title: string;
|
|
63
|
+
nav_title?: string;
|
|
64
64
|
href: string;
|
|
65
65
|
icon?: string;
|
|
66
66
|
} | {
|
|
67
67
|
type: 'section';
|
|
68
68
|
title: string;
|
|
69
|
+
nav_title?: string;
|
|
69
70
|
href: string;
|
|
70
71
|
children: SidebarItem[];
|
|
71
72
|
icon?: string;
|
|
@@ -77,20 +78,21 @@ type SidebarItem = {
|
|
|
77
78
|
} | {
|
|
78
79
|
type: 'link';
|
|
79
80
|
title: string;
|
|
81
|
+
nav_title?: string;
|
|
80
82
|
href: string;
|
|
81
83
|
external?: boolean;
|
|
82
84
|
};
|
|
83
85
|
|
|
84
|
-
declare function DocstraProvider({ children, docstraConfig, page
|
|
86
|
+
declare function DocstraProvider({ children, docstraConfig, page }: IDocstraProvider): react_jsx_runtime.JSX.Element;
|
|
85
87
|
declare function useDocstra(): DocstraContextType;
|
|
86
88
|
|
|
87
89
|
declare function DocstraHeader(): react_jsx_runtime.JSX.Element;
|
|
88
90
|
|
|
89
|
-
interface
|
|
91
|
+
interface DocstraLayoutProps {
|
|
90
92
|
children: React.ReactNode;
|
|
91
93
|
sidebarItems: SidebarItem[];
|
|
92
94
|
}
|
|
93
|
-
declare function DocstraLayout({ children, sidebarItems }:
|
|
95
|
+
declare function DocstraLayout({ children, sidebarItems }: DocstraLayoutProps): react_jsx_runtime.JSX.Element;
|
|
94
96
|
|
|
95
97
|
interface Props {
|
|
96
98
|
children: React.ReactNode;
|
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var He=Object.create;var K=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Ke=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var Qe=(e,r)=>{for(var t in r)K(e,t,{get:r[t],enumerable:!0})},de=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of Ke(r))!Ye.call(e,a)&&a!==t&&K(e,a,{get:()=>r[a],enumerable:!(o=qe(r,a))||o.enumerable});return e};var R=(e,r,t)=>(t=e!=null?He(Ve(e)):{},de(r||!e||!e.__esModule?K(t,"default",{value:e,enumerable:!0}):t,e)),_e=e=>de(K({},"__esModule",{value:!0}),e);var rt={};Qe(rt,{DocstraBody:()=>et,DocstraCodeBlock:()=>tt,DocstraHeader:()=>re,DocstraLayout:()=>je,DocstraProvider:()=>We,useDocstra:()=>f});module.exports=_e(rt);var T=require("react"),ye=require("react-toast-msg");var fe=require("lucide-react");var pe=require("tailwind-merge"),ue=R(require("clsx"));function g(...e){return(0,pe.twMerge)((0,ue.default)(e))}var O=require("react"),ge=R(require("fuse.js")),be=R(require("next/link")),he=require("next/navigation"),h=require("react/jsx-runtime");function xe(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=f(),[o,a]=(0,O.useState)(""),[n,s]=(0,O.useState)([]),c=(0,he.useRouter)();(0,O.useEffect)(()=>{let i=v=>{v.ctrlKey&&v.key==="k"&&(v.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,O.useMemo)(()=>!t||t.length===0?null:new ge.default(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);(0,O.useEffect)(()=>{if(o&&m){let i=m.search(o);s(i.map(v=>v.item))}else o||s([])},[o,m]);let y=i=>{if(i.preventDefault(),o){let v=n[0];v&&(c.push(`/docs/${v.slug}`),a(""),r(!1))}};return(0,O.useEffect)(()=>{let i=v=>{v.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{r(!1),a("")},className:g("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,h.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,h.jsx)("form",{onSubmit:y,className:g("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fe.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:g("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>(0,h.jsxs)(be.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var F=require("react/jsx-runtime"),ve=(0,T.createContext)(null);function We({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=(0,T.useState)(!1),[s,c]=(0,T.useState)(!1),[m,y]=(0,T.useState)("npm");return(0,F.jsxs)(ve.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:c,packageManager:m,setPackageManager:y,sidebarItems:o,page:t},children:[(0,F.jsx)(ye.ToastContainer,{}),(0,F.jsx)(xe,{}),e]})}function f(){let e=(0,T.useContext)(ve);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var Y=require("lucide-react"),we=require("react");var V=R(require("next/link")),k=require("react/jsx-runtime");function re(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=f(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,we.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(V.default,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:g("h-9.5 w-auto",t.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>(0,k.jsx)(V.default,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),(0,k.jsx)(V.default,{href:o||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(Y.XIcon,{className:"size-6.5"}):(0,k.jsx)(Y.TextAlignEnd,{className:"size-6.5"})})]})}var _=require("lucide-react"),Ne=require("next/navigation");var Xe=R(require("lucide-react"));function oe(e){if(e)return Xe[e]}var ae=R(require("next/link")),Q=require("react"),l=require("react/jsx-runtime");function Ze({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=(0,Q.useState)(e.defaultOpen??!0),s=e.collapsible??!0,c=oe(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>s&&n(m=>!m),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.title]}),s&&(0,l.jsx)(_.ChevronDownIcon,{className:g("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,y)=>(0,l.jsx)(ke,{item:m,pathname:r,openSidebar:t,setOpenSidebar:o},`${m.type}-${y}`))})]})}function Je({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=oe(e.icon);return(0,l.jsxs)(ae.default,{href:e.href,onClick:()=>t&&o(!1),className:g("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.title})]})}function ke({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(Je,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return(0,l.jsx)(Ze,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function Se({sidebarItems:e}){let[r,t]=(0,Q.useState)(!1),[o,a]=(0,Q.useState)(!1),n=(0,Ne.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:g("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),(0,l.jsxs)("aside",{className:g("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[(0,l.jsx)(_.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,c)=>(0,l.jsx)(ke,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${c}`))]})]})}var W=require("react/jsx-runtime");function je({children:e,sidebarItems:r}){return(0,W.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,W.jsx)(Se,{sidebarItems:r}),e]})}var Ce=require("next/navigation"),Ie=require("lucide-react"),ne=R(require("next/link")),I=require("react/jsx-runtime");function De(){let r=(0,Ce.usePathname)().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:n,title:s}});return(0,I.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,I.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,I.jsx)("li",{children:(0,I.jsx)(ne.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return(0,I.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,I.jsx)(Ie.ChevronRight,{className:"w-4 h-4 text-gray-400"}),n?(0,I.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,I.jsx)(ne.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var M=require("lucide-react"),Oe=require("next/navigation"),N=require("react");var w=require("react/jsx-runtime");function Pe(){let[e,r]=(0,N.useState)(null),[t,o]=(0,N.useState)("down"),[a,n]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),{docstraConfig:m,page:y}=f(),i=y?.path,v=y?.tableOfContents||[],B=(0,N.useRef)(0),C=(0,N.useRef)(null),H=(0,Oe.usePathname)(),te=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,N.useEffect)(()=>{let p=()=>{let b=window.scrollY;o(b>B.current?"down":"up"),n(b>100),B.current=b};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),(0,N.useEffect)(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(P=>{if(s)return;let L=P.filter($=>$.isIntersecting).sort(($,Ae)=>$.boundingClientRect.top-Ae.boundingClientRect.top);if(L.length>0){let $=t==="down"?L[0].target.id:L[L.length-1].target.id;r($)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[H,t,s]),(0,N.useEffect)(()=>{!(window.scrollY>100)&&r(v[0]?.id)},[v]),(0,N.useEffect)(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let b=p.querySelector(`a[href="#${e}"]`);if(!b)return;let P=p.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<P.top||L.bottom>P.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,N.useEffect)(()=>{if(!s)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[s]);let q=p=>{r(p),c(!0)};return(0,w.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,w.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,w.jsx)(M.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,w.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:v.map(p=>(0,w.jsxs)("li",{children:[(0,w.jsx)(Le,{heading:p,activeId:e,handleClick:q}),p.children.map(b=>(0,w.jsx)(Le,{heading:b,activeId:e,handleClick:q,className:"pl-8"},b.id))]},p.id))}),(0,w.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,w.jsxs)("a",{href:te,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,w.jsx)(M.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,w.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,w.jsx)(M.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Le({heading:e,activeId:r,handleClick:t,className:o}){return(0,w.jsx)("a",{href:`#${e.id}`,className:g("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}var U=require("react"),X=require("lucide-react");var z=require("react/jsx-runtime");function se({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:m="",optional:y=!1}){return(0,z.jsxs)("div",{className:g("flex flex-col mt-4 w-full",m),children:[e&&(0,z.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,y&&(0,z.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?(0,z.jsx)("textarea",{id:o,name:o,className:g("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:c,maxLength:500}):(0,z.jsx)("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:c,maxLength:500})]})}var Re=require("lucide-react");var ie=require("react/jsx-runtime");function le({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return(0,ie.jsx)("button",{type:t,disabled:a,className:g("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?(0,ie.jsx)(Re.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var Z=require("formsync"),d=require("react/jsx-runtime");function Te(){let[e,r]=(0,U.useState)(null),{docstraConfig:t}=f(),[o,a]=(0,U.useState)(""),[n,s]=(0,U.useState)(!1),[c,m]=(0,U.useState)(null),y="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(le,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(X.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(Z.FormSyncForm,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(se,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(Z.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${y}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Ee=require("react/jsx-runtime");function ze(){let{pageData:e}=f();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Ee.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}var J=require("lucide-react"),A=require("react");var E=require("react/jsx-runtime");function Be(){let{pageData:e}=f(),[r,t]=(0,A.useState)(!1),[o,a]=(0,A.useState)(null);(0,A.useEffect)(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return(0,E.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,E.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?(0,E.jsx)(J.CheckIcon,{className:"size-3.5"}):(0,E.jsx)(J.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,E.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var $e=require("next/navigation"),ce=R(require("next/link")),j=require("lucide-react");var S=require("react/jsx-runtime");function Me(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...Me(t.children));return r}function Ge(){let e=(0,$e.usePathname)(),{docstraConfig:r,sidebarItems:t}=f(),o=[];t&&t.length>0?o=Me(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?(0,S.jsxs)(ce.default,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(j.ArrowLeftIcon,{className:"size-5 mr-2"}),n.name]})]}):(0,S.jsx)("div",{}),s?(0,S.jsxs)(ce.default,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,S.jsx)(j.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var x=require("react/jsx-runtime");function et({children:e}){let{docstraConfig:r,page:t}=f();return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(re,{}),(0,x.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,x.jsx)(De,{}),(0,x.jsx)("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),(0,x.jsx)("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),(0,x.jsx)(Be,{}),(0,x.jsx)("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&(0,x.jsx)(Te,{}),(0,x.jsx)(ze,{}),(0,x.jsx)(Ge,{})]}),(0,x.jsx)(Pe,{})]})}var G=require("lucide-react"),ee=require("prism-react-renderer"),Fe=require("react");var Ue=require("react-toast-msg"),u=require("react/jsx-runtime"),me={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function tt(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=f(),c=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(c)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[y,i]=(0,Fe.useState)(!1),B=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=B==="package-install",H=()=>{let D=C?`${me[n]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(D),i(!0),Ue.toast.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!C&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||B}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(me).map(D=>(0,u.jsx)("button",{onClick:()=>s(D),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===D?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:D},D))}),t&&!C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(ee.Highlight,{theme:ee.themes.vsLight,code:m.trim(),language:C?"bash":B,children:({tokens:D,getLineProps:te,getTokenProps:q})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&C?"flex items-center justify-between":""}`,children:[D.map((p,b)=>(0,u.jsxs)("div",{...te({line:p}),children:[!C&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),C&&(0,u.jsx)("span",{className:"mr-2",children:me[n]}),p.map((P,L)=>(0,u.jsx)("span",{...q({token:P})},L))]},b)),t&&C&&(0,u.jsx)("button",{onClick:H,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:y?(0,u.jsx)(G.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(G.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
|
|
1
|
+
"use strict";"use client";var Ye=Object.create;var Y=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Xe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var Je=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},pe=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of We(t))!Ze.call(e,a)&&a!==r&&Y(e,a,{get:()=>t[a],enumerable:!(o=Qe(t,a))||o.enumerable});return e};var B=(e,t,r)=>(r=e!=null?Ye(Xe(e)):{},pe(t||!e||!e.__esModule?Y(r,"default",{value:e,enumerable:!0}):r,e)),je=e=>pe(Y({},"__esModule",{value:!0}),e);var it={};Je(it,{DocstraBody:()=>nt,DocstraCodeBlock:()=>st,DocstraHeader:()=>oe,DocstraLayout:()=>at,DocstraProvider:()=>et,useDocstra:()=>f});module.exports=je(it);var R=require("react"),ke=require("react-toast-msg");var xe=require("lucide-react");var ue=require("tailwind-merge"),fe=B(require("clsx"));function g(...e){return(0,ue.twMerge)((0,fe.default)(e))}var O=require("react"),ye=B(require("fuse.js")),ve=B(require("next/link")),we=require("next/navigation");var T=require("react"),he=require("react/jsx-runtime"),ge=(0,T.createContext)(null);function be({children:e}){let[t,r]=(0,T.useState)(!1),[o,a]=(0,T.useState)(!1);return(0,he.jsx)(ge.Provider,{value:{openSidebar:t,setOpenSidebar:r,openSearchBox:o,setOpenSearchBox:a},children:e})}function G(){let e=(0,T.useContext)(ge);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}var h=require("react/jsx-runtime");function Ne(){let{openSearchBox:e,setOpenSearchBox:t}=G(),{page:r}=f(),[o,a]=(0,O.useState)(""),[s,n]=(0,O.useState)([]),c=(0,we.useRouter)();(0,O.useEffect)(()=>{let i=y=>{y.ctrlKey&&y.key==="k"&&(y.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let m=(0,O.useMemo)(()=>!r||r.length===0?null:new ye.default(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);(0,O.useEffect)(()=>{if(o&&m){let i=m.search(o);n(i.map(y=>y.item))}else o||n([])},[o,m]);let N=i=>{if(i.preventDefault(),o){let y=s[0];y&&(c.push(`/docs/${y.slug}`),a(""),t(!1))}};return(0,O.useEffect)(()=>{let i=y=>{y.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),(0,h.jsx)("div",{onClick:()=>{t(!1),a("")},className:g("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:(0,h.jsxs)("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[(0,h.jsx)("form",{onSubmit:N,className:g("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(xe.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,h.jsx)("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),(0,h.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,h.jsxs)("div",{className:g("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[s.map(i=>(0,h.jsxs)(ve.default,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[(0,h.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,h.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&s.length===0&&(0,h.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var A=require("react/jsx-runtime"),Se=(0,R.createContext)(null);function et({children:e,docstraConfig:t,page:r}){let[o,a]=(0,R.useState)(!1),[s,n]=(0,R.useState)(!1),[c,m]=(0,R.useState)("npm");return(0,A.jsxs)(Se.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:c,setPackageManager:m,page:r},children:[(0,A.jsx)(ke.ToastContainer,{}),(0,A.jsx)(Ne,{}),e]})}function f(){let e=(0,R.useContext)(Se);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}var W=require("lucide-react"),Ce=require("react");var Q=B(require("next/link"));var k=require("react/jsx-runtime");function oe(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=G(),{docstraConfig:a}=f(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return(0,Ce.useEffect)(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),(0,k.jsxs)("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[(0,k.jsx)(Q.default,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,k.jsx)("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:g("h-9.5 w-auto",a.navbar?.logo?.className)})}),(0,k.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>(0,k.jsx)(Q.default,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),(0,k.jsx)(Q.default,{href:s||"https://github.com/sudhucodes/docstra",children:(0,k.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,k.jsx)("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),(0,k.jsx)("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?(0,k.jsx)(W.XIcon,{className:"size-6.5"}):(0,k.jsx)(W.TextAlignEnd,{className:"size-6.5"})})]})}var X=require("lucide-react"),Ie=require("next/navigation");var tt=B(require("lucide-react"));function ae(e){if(e)return tt[e]}var ne=B(require("next/link")),De=require("react");var l=require("react/jsx-runtime");function rt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,s]=(0,De.useState)(e.defaultOpen??!0),n=e.collapsible??!0,c=ae(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ne.default,{href:e.href,onClick:()=>n&&s(m=>!m),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[(0,l.jsxs)("span",{className:"flex items-center gap-2",children:[c&&(0,l.jsx)(c,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&(0,l.jsx)(X.ChevronDownIcon,{className:g("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!n||a)&&(0,l.jsx)("ul",{className:"mb-4 ml-2",children:e.children.map((m,N)=>(0,l.jsx)(Le,{item:m,pathname:t,openSidebar:r,setOpenSidebar:o},`${m.type}-${N}`))})]})}function ot({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=ae(e.icon);return(0,l.jsxs)(ne.default,{href:e.href,onClick:()=>r&&o(!1),className:g("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&(0,l.jsx)(a,{className:"size-4"}),(0,l.jsx)("span",{children:e.nav_title?e.nav_title:e.title})]})}function Le({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){switch(e.type){case"page":return(0,l.jsx)(ot,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});case"section":return(0,l.jsx)(rt,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});default:return null}}function Oe({sidebarItems:e}){let{openSidebar:t,setOpenSidebar:r,openSearchBox:o,setOpenSearchBox:a}=G(),s=(0,Ie.usePathname)();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:g("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",t&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),(0,l.jsxs)("aside",{className:g("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",t?"top-32":"top-full"),children:[(0,l.jsxs)("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(t&&!1),a(!0)},children:[(0,l.jsx)(X.SearchIcon,{className:"size-4.5"}),(0,l.jsx)("p",{children:"Search"}),(0,l.jsxs)("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),(0,l.jsx)("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((n,c)=>(0,l.jsx)(Le,{item:n,pathname:s,openSidebar:t,setOpenSidebar:r},`${n.type}-${c}`))]})]})}var H=require("react/jsx-runtime");function at({children:e,sidebarItems:t}){return(0,H.jsx)(be,{children:(0,H.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,H.jsx)(Oe,{sidebarItems:t}),e]})})}var Pe=require("next/navigation"),Be=require("lucide-react"),se=B(require("next/link")),I=require("react/jsx-runtime");function Re(){let t=(0,Pe.usePathname)().split("/").filter(Boolean),r=t.map((o,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=o.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase());return{href:s,title:n}});return(0,I.jsx)("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:(0,I.jsxs)("ol",{className:"flex items-center space-x-2",children:[(0,I.jsx)("li",{children:(0,I.jsx)(se.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let s=a===r.length-1;return(0,I.jsxs)("li",{className:"flex items-center space-x-2",children:[(0,I.jsx)(Be.ChevronRight,{className:"w-4 h-4 text-gray-400"}),s?(0,I.jsx)("span",{className:"text-gray-600 font-medium",children:o.title}):(0,I.jsx)(se.default,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}var F=require("lucide-react"),Ee=require("next/navigation"),w=require("react");var v=require("react/jsx-runtime");function ze(){let[e,t]=(0,w.useState)(null),[r,o]=(0,w.useState)("down"),[a,s]=(0,w.useState)(!1),[n,c]=(0,w.useState)(!1),{docstraConfig:m,page:N}=f(),i=N?.path,y=N?.tableOfContents||[],$=(0,w.useRef)(0),C=(0,w.useRef)(null),K=(0,Ee.usePathname)(),re=`${"https://github.com/"+m?.editOnGithub?.owner+"/"+m?.editOnGithub?.repo}/edit/main/${m?.editOnGithub?.path}/${i}`;(0,w.useEffect)(()=>{let p=()=>{let b=window.scrollY;o(b>$.current?"down":"up"),s(b>100),$.current=b};return window.addEventListener("scroll",p),()=>window.removeEventListener("scroll",p)},[]),(0,w.useEffect)(()=>{let p=document.querySelectorAll("h2[id], h3[id]"),b=new IntersectionObserver(P=>{if(n)return;let L=P.filter(M=>M.isIntersecting).sort((M,Ve)=>M.boundingClientRect.top-Ve.boundingClientRect.top);if(L.length>0){let M=r==="down"?L[0].target.id:L[L.length-1].target.id;t(M)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[K,r,n]),(0,w.useEffect)(()=>{!(window.scrollY>100)&&t(y[0]?.id)},[y]),(0,w.useEffect)(()=>{if(!e)return;let p=document.querySelector(".toc-scroll-container");if(!p)return;let b=p.querySelector(`a[href="#${e}"]`);if(!b)return;let P=p.getBoundingClientRect(),L=b.getBoundingClientRect();(L.top<P.top||L.bottom>P.bottom)&&b.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),(0,w.useEffect)(()=>{if(!n)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[n]);let V=p=>{t(p),c(!0)};return(0,v.jsxs)("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[(0,v.jsxs)("p",{className:"flex items-center gap-2 mb-5",children:[(0,v.jsx)(F.TextAlignStartIcon,{className:"size-4"}),"On this page"]}),(0,v.jsx)("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:y.map(p=>(0,v.jsxs)("li",{children:[(0,v.jsx)(Te,{heading:p,activeId:e,handleClick:V}),p.children.map(b=>(0,v.jsx)(Te,{heading:b,activeId:e,handleClick:V,className:"pl-8"},b.id))]},p.id))}),(0,v.jsx)("hr",{className:"my-6 border-gray-200"}),m.editOnGithub&&(0,v.jsxs)("a",{href:re,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",(0,v.jsx)(F.SquareArrowOutUpRightIcon,{className:"size-4"})]}),a&&(0,v.jsxs)("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",(0,v.jsx)(F.ArrowUpCircleIcon,{className:"size-4"})]})]})}function Te({heading:e,activeId:t,handleClick:r,className:o}){return(0,v.jsx)("a",{href:`#${e.id}`,className:g("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>r(e.id),children:e.text})}var q=require("react"),Z=require("lucide-react");var E=require("react/jsx-runtime");function ie({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:s,value:n,readOnly:c=!1,className:m="",optional:N=!1}){return(0,E.jsxs)("div",{className:g("flex flex-col mt-4 w-full",m),children:[e&&(0,E.jsxs)("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,N&&(0,E.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?(0,E.jsx)("textarea",{id:o,name:o,className:g("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",m),placeholder:r,required:a,onChange:s,rows:4,value:n,readOnly:c,maxLength:500}):(0,E.jsx)("input",{type:t,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:r,required:a,onChange:s,value:n,readOnly:c,maxLength:500})]})}var $e=require("lucide-react");var le=require("react/jsx-runtime");function ce({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:s}){return(0,le.jsx)("button",{type:r,disabled:a,className:g("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:s,children:t?(0,le.jsx)($e.Loader2Icon,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}var J=require("formsync"),d=require("react/jsx-runtime");function Me(){let[e,t]=(0,q.useState)(null),{docstraConfig:r}=f(),[o,a]=(0,q.useState)(""),[s,n]=(0,q.useState)(!1),[c,m]=(0,q.useState)(null),N="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return(0,d.jsx)("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),(0,d.jsx)(ce,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"font-medium",children:"How is this guide?"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsxs)("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(Z.ThumbsUp,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),(0,d.jsxs)("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[(0,d.jsx)(Z.ThumbsDown,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&(0,d.jsxs)(J.FormSyncForm,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{m(i.message)},children:[(0,d.jsx)(ie,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),c&&(0,d.jsx)("p",{className:"text-red-500",children:c}),(0,d.jsx)("input",{type:"hidden",name:"opinion",value:e}),(0,d.jsx)("input",{type:"hidden",name:"page",value:window.location.href}),(0,d.jsx)("input",{type:"hidden",name:"_redirect",value:window.location.href}),(0,d.jsx)(J.FormSyncButton,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),r?.feedback?.watermark!==!1&&(0,d.jsxs)("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",(0,d.jsx)("a",{href:`https://www.formsync.app?utm_source=${N}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}var Fe=require("react/jsx-runtime");function Ge(){let{pageData:e}=f();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return(0,Fe.jsxs)("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}var j=require("lucide-react"),_=require("react");var z=require("react/jsx-runtime");function Ue(){let{pageData:e}=f(),[t,r]=(0,_.useState)(!1),[o,a]=(0,_.useState)(null);(0,_.useEffect)(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${o} and explain it to me.`;return(0,z.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,z.jsxs)("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),r(!0),setTimeout(()=>r(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?(0,z.jsx)(j.CheckIcon,{className:"size-3.5"}):(0,z.jsx)(j.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,z.jsx)("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}var Ae=require("next/navigation"),me=B(require("next/link")),ee=require("lucide-react");var S=require("react/jsx-runtime");function He(e){let t=[];for(let r of e)r.type==="page"?t.push({name:r.title,href:r.href,icon:r.icon}):r.type==="section"&&t.push(...He(r.children));return t}function qe(){let e=(0,Ae.usePathname)(),{docstraConfig:t,sidebarItems:r}=f(),o=[];r&&r.length>0?o=He(r):t?.sidebar?.links&&(o=t.sidebar.links.flatMap(c=>c.items));let a=o.findIndex(c=>c.href===e),s=a>0?o[a-1]:null,n=a<o.length-1?o[a+1]:null;return(0,S.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?(0,S.jsxs)(me.default,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[(0,S.jsx)(ee.ArrowLeftIcon,{className:"size-5 mr-2"}),s.name]})]}):(0,S.jsx)("div",{}),n?(0,S.jsxs)(me.default,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[(0,S.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,S.jsxs)("p",{className:"flex items-center font-medium",children:[n.name,(0,S.jsx)(ee.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,S.jsx)("div",{})]})}var x=require("react/jsx-runtime");function nt({children:e}){let{docstraConfig:t,page:r}=f();return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(oe,{}),(0,x.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,x.jsx)(Re,{}),(0,x.jsx)("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),(0,x.jsx)("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),(0,x.jsx)(Ue,{}),(0,x.jsx)("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&(0,x.jsx)(Me,{}),(0,x.jsx)(Ge,{}),(0,x.jsx)(qe,{})]}),(0,x.jsx)(ze,{})]})}var U=require("lucide-react"),te=require("prism-react-renderer"),_e=require("react");var Ke=require("react-toast-msg"),u=require("react/jsx-runtime"),de={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function st(e){let{filename:t,copyable:r,children:o,className:a}=e,{packageManager:s,setPackageManager:n}=f(),c=!a?.includes("language-"),m=typeof o=="string"?o:o?.props?.children||"";if(c)return(0,u.jsx)("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:m});let[N,i]=(0,_e.useState)(!1),$=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=$==="package-install",K=()=>{let D=C?`${de[s]} ${m.trim()}`:m.trim();navigator.clipboard.writeText(D),i(!0),Ke.toast.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return(0,u.jsxs)("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!C&&(0,u.jsx)("span",{className:"text-xs text-gray-400 px-4 py-3",children:t||$}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(de).map(D=>(0,u.jsx)("button",{onClick:()=>n(D),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${s===D?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:D},D))}),r&&!C&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:N?(0,u.jsx)(U.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(U.CopyIcon,{className:"size-4"})})]}),(0,u.jsx)(te.Highlight,{theme:te.themes.vsLight,code:m.trim(),language:C?"bash":$,children:({tokens:D,getLineProps:re,getTokenProps:V})=>(0,u.jsxs)("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${r&&C?"flex items-center justify-between":""}`,children:[D.map((p,b)=>(0,u.jsxs)("div",{...re({line:p}),children:[!C&&(0,u.jsx)("span",{className:"text-gray-400 mr-4 select-none",children:b+1}),C&&(0,u.jsx)("span",{className:"mr-2",children:de[s]}),p.map((P,L)=>(0,u.jsx)("span",{...V({token:P})},L))]},b)),r&&C&&(0,u.jsx)("button",{onClick:K,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:N?(0,u.jsx)(U.CheckIcon,{className:"size-4 text-green-600"}):(0,u.jsx)(U.CopyIcon,{className:"size-4"})})]})})]})}0&&(module.exports={DocstraBody,DocstraCodeBlock,DocstraHeader,DocstraLayout,DocstraProvider,useDocstra});
|
package/dist/client/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{createContext as Me,useContext as Ge,useState as K}from"react";import{ToastContainer as Fe}from"react-toast-msg";import{SearchIcon as Re}from"lucide-react";import{twMerge as Oe}from"tailwind-merge";import Pe from"clsx";function d(...e){return Oe(Pe(e))}import{useEffect as q,useMemo as Te,useState as j}from"react";import ze from"fuse.js";import Ee from"next/link";import{useRouter as Be}from"next/navigation";import{Fragment as $e,jsx as C,jsxs as G}from"react/jsx-runtime";function ee(){let{openSearchBox:e,setOpenSearchBox:r,page:t}=p(),[o,a]=j(""),[n,s]=j([]),l=Be();q(()=>{let i=g=>{g.ctrlKey&&g.key==="k"&&(g.preventDefault(),r(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=Te(()=>!t||t.length===0?null:new ze(t,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[t]);q(()=>{if(o&&c){let i=c.search(o);s(i.map(g=>g.item))}else o||s([])},[o,c]);let f=i=>{if(i.preventDefault(),o){let g=n[0];g&&(l.push(`/docs/${g.slug}`),a(""),r(!1))}};return q(()=>{let i=g=>{g.key==="Escape"&&(r(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),C("div",{onClick:()=>{r(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:G("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[C("form",{onSubmit:f,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&G($e,{children:[C(Re,{className:"size-5.5 mx-3 shrink-0"}),C("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),C("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),G("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[n.map(i=>G(Ee,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{r(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[C("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),C("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&C("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as te,jsxs as Ue}from"react/jsx-runtime";var re=Me(null);function Ft({children:e,docstraConfig:r,page:t,sidebarItems:o}){let[a,n]=K(!1),[s,l]=K(!1),[c,f]=K("npm");return Ue(re.Provider,{value:{openSidebar:a,setOpenSidebar:n,docstraConfig:r,openSearchBox:s,setOpenSearchBox:l,packageManager:c,setPackageManager:f,sidebarItems:o,page:t},children:[te(Fe,{}),te(ee,{}),e]})}function p(){let e=Ge(re);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Ae,XIcon as He}from"lucide-react";import{useEffect as qe}from"react";import V from"next/link";import{jsx as k,jsxs as oe}from"react/jsx-runtime";function ae(){let{openSidebar:e,setOpenSidebar:r,docstraConfig:t}=p(),o="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return qe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),oe("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[k(V,{href:t.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:k("img",{src:t.navbar?.logo?.src||"/logo.png",alt:t.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",t.navbar?.logo?.className)})}),oe("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[t.navbar?.links?.map(a=>k(V,{href:a.href,className:"px-6 hover:text-gray-600",children:a.name},a.name)),k(V,{href:o||"https://github.com/sudhucodes/docstra",children:k("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:k("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),k("button",{onClick:()=>r(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?k(He,{className:"size-6.5"}):k(Ae,{className:"size-6.5"})})]})}import{ChevronDownIcon as Ve,SearchIcon as Ye}from"lucide-react";import{usePathname as Qe}from"next/navigation";import*as Ke from"lucide-react";function Y(e){if(e)return Ke[e]}import ne from"next/link";import{useState as Q}from"react";import{Fragment as Xe,jsx as b,jsxs as I}from"react/jsx-runtime";function _e({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let[a,n]=Q(e.defaultOpen??!0),s=e.collapsible??!0,l=Y(e.icon);return I("div",{children:[I(ne,{href:e.href,onClick:()=>s&&n(c=>!c),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[I("span",{className:"flex items-center gap-2",children:[l&&b(l,{className:"size-4 text-gray-400"}),e.title]}),s&&b(Ve,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&b("ul",{className:"mb-4 ml-2",children:e.children.map((c,f)=>b(se,{item:c,pathname:r,openSidebar:t,setOpenSidebar:o},`${c.type}-${f}`))})]})}function We({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){let a=Y(e.icon);return I(ne,{href:e.href,onClick:()=>t&&o(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",r===e.href&&"bg-gray-100 text-gray-800"),children:[a&&b(a,{className:"size-4"}),b("span",{children:e.title})]})}function se({item:e,pathname:r,openSidebar:t,setOpenSidebar:o}){switch(e.type){case"page":return b(We,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});case"section":return b(_e,{item:e,pathname:r,openSidebar:t,setOpenSidebar:o});default:return null}}function ie({sidebarItems:e}){let[r,t]=Q(!1),[o,a]=Q(!1),n=Qe();return I(Xe,{children:[b("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",r&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),I("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",r?"top-32":"top-full"),children:[I("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{t(r&&!1),a(!0)},children:[b(Ye,{className:"size-4.5"}),b("p",{children:"Search"}),I("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),b("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((s,l)=>b(se,{item:s,pathname:n,openSidebar:r,setOpenSidebar:t},`${s.type}-${l}`))]})]})}import{jsx as Ze,jsxs as Je}from"react/jsx-runtime";function nr({children:e,sidebarItems:r}){return Je("div",{className:"min-h-screen flex bg-white w-full",children:[Ze(ie,{sidebarItems:r}),e]})}import{usePathname as je}from"next/navigation";import{ChevronRight as et}from"lucide-react";import le from"next/link";import{jsx as R,jsxs as ce}from"react/jsx-runtime";function me(){let r=je().split("/").filter(Boolean),t=r.map((o,a)=>{let n="/"+r.slice(0,a+1).join("/"),s=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:n,title:s}});return R("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:ce("ol",{className:"flex items-center space-x-2",children:[R("li",{children:R(le,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),t.map((o,a)=>{let n=a===t.length-1;return ce("li",{className:"flex items-center space-x-2",children:[R(et,{className:"w-4 h-4 text-gray-400"}),n?R("span",{className:"text-gray-600 font-medium",children:o.title}):R(le,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{ArrowUpCircleIcon as tt,SquareArrowOutUpRightIcon as rt,TextAlignStartIcon as ot}from"lucide-react";import{usePathname as at}from"next/navigation";import{useEffect as z,useRef as de,useState as F}from"react";import{jsx as D,jsxs as E}from"react/jsx-runtime";function ue(){let[e,r]=F(null),[t,o]=F("down"),[a,n]=F(!1),[s,l]=F(!1),{docstraConfig:c,page:f}=p(),i=f?.path,g=f?.tableOfContents||[],O=de(0),y=de(null),$=at(),H=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;z(()=>{let m=()=>{let u=window.scrollY;o(u>O.current?"down":"up"),n(u>100),O.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),z(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(S=>{if(s)return;let N=S.filter(P=>P.isIntersecting).sort((P,Le)=>P.boundingClientRect.top-Le.boundingClientRect.top);if(N.length>0){let P=t==="down"?N[0].target.id:N[N.length-1].target.id;r(P)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(S=>u.observe(S)),y.current=u,()=>u.disconnect()},[$,t,s]),z(()=>{!(window.scrollY>100)&&r(g[0]?.id)},[g]),z(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let S=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<S.top||N.bottom>S.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),z(()=>{if(!s)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[s]);let M=m=>{r(m),l(!0)};return E("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[E("p",{className:"flex items-center gap-2 mb-5",children:[D(ot,{className:"size-4"}),"On this page"]}),D("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:g.map(m=>E("li",{children:[D(pe,{heading:m,activeId:e,handleClick:M}),m.children.map(u=>D(pe,{heading:u,activeId:e,handleClick:M,className:"pl-8"},u.id))]},m.id))}),D("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&E("a",{href:H,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",D(rt,{className:"size-4"})]}),a&&E("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",D(tt,{className:"size-4"})]})]})}function pe({heading:e,activeId:r,handleClick:t,className:o}){return D("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":r===e.id,"hover:text-gray-800 hover:border-gray-400":r!==e.id}),onClick:()=>t(e.id),children:e.text})}import{useState as U}from"react";import{ThumbsUp as st,ThumbsDown as it}from"lucide-react";import{jsx as _,jsxs as fe}from"react/jsx-runtime";function W({label:e,type:r,placeholder:t="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:c="",optional:f=!1}){return fe("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&fe("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,f&&_("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),r==="textarea"?_("textarea",{id:o,name:o,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:t,required:a,onChange:n,rows:4,value:s,readOnly:l,maxLength:500}):_("input",{type:r,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:t,required:a,onChange:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as nt}from"lucide-react";import{jsx as ge}from"react/jsx-runtime";function X({label:e,loading:r,type:t="submit",className:o="",disabled:a=!1,onClick:n}){return ge("button",{type:t,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:n,children:r?ge(nt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as lt,FormSyncForm as ct}from"formsync";import{Fragment as be,jsx as x,jsxs as L}from"react/jsx-runtime";function he(){let[e,r]=U(null),{docstraConfig:t}=p(),[o,a]=U(""),[n,s]=U(!1),[l,c]=U(null),f="https://github.com/"+t?.editOnGithub?.owner+"/"+t?.editOnGithub?.repo;return x("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?L(be,{children:[x("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),x(X,{onClick:()=>{s(!1),r(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(be,{children:[x("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>r("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(st,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>r("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(it,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(ct,{className:"flex flex-col gap-2",formId:t?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),r(null),a("")},onSubmitError:i=>{c(i.message)},children:[x(W,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&x("p",{className:"text-red-500",children:l}),x("input",{type:"hidden",name:"opinion",value:e}),x("input",{type:"hidden",name:"page",value:window.location.href}),x("input",{type:"hidden",name:"_redirect",value:window.location.href}),x(lt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),t?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",x("a",{href:`https://www.formsync.app?utm_source=${f}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as mt}from"react/jsx-runtime";function xe(){let{pageData:e}=p();if(!e?.data?.lastUpdated)return null;let r=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return mt("p",{className:"text-sm text-gray-500",children:["Last updated on ",r]})}import{CheckIcon as dt,CopyIcon as pt}from"lucide-react";import{useEffect as ut,useState as ye}from"react";import{jsx as Z,jsxs as ve}from"react/jsx-runtime";function we(){let{pageData:e}=p(),[r,t]=ye(!1),[o,a]=ye(null);ut(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ve("div",{className:"flex items-center gap-3 mt-6",children:[ve("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),t(!0),setTimeout(()=>t(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[r?Z(dt,{className:"size-3.5"}):Z(pt,{className:"size-3.5"}),"Copy Markdown"]}),Z("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(n)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as ft}from"next/navigation";import Ne from"next/link";import{ArrowLeftIcon as gt,ArrowRightIcon as bt}from"lucide-react";import{jsx as T,jsxs as B}from"react/jsx-runtime";function ke(e){let r=[];for(let t of e)t.type==="page"?r.push({name:t.title,href:t.href,icon:t.icon}):t.type==="section"&&r.push(...ke(t.children));return r}function Se(){let e=ft(),{docstraConfig:r,sidebarItems:t}=p(),o=[];t&&t.length>0?o=ke(t):r?.sidebar?.links&&(o=r.sidebar.links.flatMap(l=>l.items));let a=o.findIndex(l=>l.href===e),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return B("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?B(Ne,{href:n.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Previous"}),B("p",{className:"flex items-center font-medium",children:[T(gt,{className:"size-5 mr-2"}),n.name]})]}):T("div",{}),s?B(Ne,{href:s.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Next"}),B("p",{className:"flex items-center font-medium",children:[s.name,T(bt,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as ht,jsx as v,jsxs as Ce}from"react/jsx-runtime";function oo({children:e}){let{docstraConfig:r,page:t}=p();return Ce(ht,{children:[v(ae,{}),Ce("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[v(me,{}),v("h1",{className:"text-3xl font-bold",children:t?.metadata?.title}),v("p",{className:"my-4 text-gray-500",children:t?.metadata?.description}),v(we,{}),v("hr",{className:"my-10 border-gray-200"}),e,r?.feedback?.enabled&&v(he,{}),v(xe,{}),v(Se,{})]}),v(ue,{})]})}import{CheckIcon as Ie,CopyIcon as De}from"lucide-react";import{Highlight as xt,themes as yt}from"prism-react-renderer";import{useState as vt}from"react";import{toast as wt}from"react-toast-msg";import{jsx as h,jsxs as A}from"react/jsx-runtime";var J={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function po(e){let{filename:r,copyable:t,children:o,className:a}=e,{packageManager:n,setPackageManager:s}=p(),l=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(l)return h("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[f,i]=vt(!1),O=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=O==="package-install",$=()=>{let w=y?`${J[n]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(w),i(!0),wt.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return A("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[A("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!y&&h("span",{className:"text-xs text-gray-400 px-4 py-3",children:r||O}),y&&h("div",{className:"flex items-center px-3",children:Object.keys(J).map(w=>h("button",{onClick:()=>s(w),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${n===w?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:w},w))}),t&&!y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]}),h(xt,{theme:yt.vsLight,code:c.trim(),language:y?"bash":O,children:({tokens:w,getLineProps:H,getTokenProps:M})=>A("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${t&&y?"flex items-center justify-between":""}`,children:[w.map((m,u)=>A("div",{...H({line:m}),children:[!y&&h("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),y&&h("span",{className:"mr-2",children:J[n]}),m.map((S,N)=>h("span",{...M({token:S})},N))]},u)),t&&y&&h("button",{onClick:$,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:f?h(Ie,{className:"size-4 text-green-600"}):h(De,{className:"size-4"})})]})})]})}export{oo as DocstraBody,po as DocstraCodeBlock,ae as DocstraHeader,nr as DocstraLayout,Ft as DocstraProvider,p as useDocstra};
|
|
1
|
+
"use client";import{createContext as _e,useContext as Ke,useState as K}from"react";import{ToastContainer as Ve}from"react-toast-msg";import{SearchIcon as Ge}from"lucide-react";import{twMerge as Te}from"tailwind-merge";import Ee from"clsx";function d(...e){return Te(Ee(e))}import{useEffect as _,useMemo as Fe,useState as re}from"react";import Ue from"fuse.js";import Ae from"next/link";import{useRouter as He}from"next/navigation";import{createContext as ze,useContext as $e,useState as j}from"react";import{jsx as Me}from"react/jsx-runtime";var ee=ze(null);function te({children:e}){let[t,r]=j(!1),[o,a]=j(!1);return Me(ee.Provider,{value:{openSidebar:t,setOpenSidebar:r,openSearchBox:o,setOpenSearchBox:a},children:e})}function B(){let e=$e(ee);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}import{Fragment as qe,jsx as C,jsxs as F}from"react/jsx-runtime";function oe(){let{openSearchBox:e,setOpenSearchBox:t}=B(),{page:r}=p(),[o,a]=re(""),[s,n]=re([]),l=He();_(()=>{let i=f=>{f.ctrlKey&&f.key==="k"&&(f.preventDefault(),t(!0))};return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[]);let c=Fe(()=>!r||r.length===0?null:new Ue(r,{keys:["data.metadata.title","data.metadata.description"],threshold:.3}),[r]);_(()=>{if(o&&c){let i=c.search(o);n(i.map(f=>f.item))}else o||n([])},[o,c]);let h=i=>{if(i.preventDefault(),o){let f=s[0];f&&(l.push(`/docs/${f.slug}`),a(""),t(!1))}};return _(()=>{let i=f=>{f.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),C("div",{onClick:()=>{t(!1),a("")},className:d("fixed inset-0 z-25 flex items-start justify-center bg-white/40 backdrop-blur-md opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),children:F("div",{onClick:i=>i.stopPropagation(),className:"flex flex-col items-center mt-30 max-w-lg w-full max-md:px-4",children:[C("form",{onSubmit:h,className:d("relative flex items-center justify-between w-full bg-white border border-slate-200 text-gray-400 h-15 p-0.5 rounded-md",o&&"rounded-b-none border-b-0"),children:e&&F(qe,{children:[C(Ge,{className:"size-5.5 mx-3 shrink-0"}),C("input",{className:"w-full bg-transparent h-full outline-none text-gray-400 placeholder:text-gray-400",type:"text",placeholder:"Search docs...",spellCheck:"false",autoFocus:!0,value:o,onChange:i=>a(i.target.value),name:"searchQuery",required:!0}),C("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),F("div",{className:d("max-h-70 overflow-x-hidden overflow-y-auto scrollbar-y w-full bg-white text-slate-700 flex flex-col",o&&"rounded-b-md border border-slate-200"),children:[s.map(i=>F(Ae,{href:`/docs/${i.slug==="index"?"":i.slug}`,onClick:()=>{t(!1),a("")},className:"w-full hover:bg-gray-100/70 border-b border-slate-200 transition-all py-4 px-4 last:mb-2",children:[C("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),C("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&s.length===0&&C("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}import{jsx as ae,jsxs as Ye}from"react/jsx-runtime";var ne=_e(null);function Xt({children:e,docstraConfig:t,page:r}){let[o,a]=K(!1),[s,n]=K(!1),[l,c]=K("npm");return Ye(ne.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:s,setOpenSearchBox:n,packageManager:l,setPackageManager:c,page:r},children:[ae(Ve,{}),ae(oe,{}),e]})}function p(){let e=Ke(ne);if(!e)throw new Error("Please wrap your app with DocstraProvider");return e}import{TextAlignEnd as Qe,XIcon as We}from"lucide-react";import{useEffect as Xe}from"react";import V from"next/link";import{jsx as k,jsxs as se}from"react/jsx-runtime";function ie(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=B(),{docstraConfig:a}=p(),s="https://github.com/"+a?.editOnGithub?.owner+"/"+a?.editOnGithub?.repo;return Xe(()=>{e?document.body.classList.add("max-md:overflow-hidden"):document.body.classList.remove("max-md:overflow-hidden")},[e]),se("header",{className:"fixed w-full top-0 z-10 text-sm flex items-center justify-between border-b border-gray-100 h-18 px-4 md:px-6 bg-white",children:[k(V,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:k("img",{src:a.navbar?.logo?.src||"/logo.png",alt:a.navbar?.logo?.alt||"Logo",className:d("h-9.5 w-auto",a.navbar?.logo?.className)})}),se("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(n=>k(V,{href:n.href,className:"px-6 hover:text-gray-600",children:n.name},n.name)),k(V,{href:s||"https://github.com/sudhucodes/docstra",children:k("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:k("path",{d:"M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3"})})})]}),k("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?k(We,{className:"size-6.5"}):k(Qe,{className:"size-6.5"})})]})}import{ChevronDownIcon as Je,SearchIcon as je}from"lucide-react";import{usePathname as et}from"next/navigation";import*as Ze from"lucide-react";function Y(e){if(e)return Ze[e]}import le from"next/link";import{useState as tt}from"react";import{Fragment as at,jsx as g,jsxs as I}from"react/jsx-runtime";function rt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,s]=tt(e.defaultOpen??!0),n=e.collapsible??!0,l=Y(e.icon);return I("div",{children:[I(le,{href:e.href,onClick:()=>n&&s(c=>!c),className:"w-full flex items-center justify-between gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",children:[I("span",{className:"flex items-center gap-2",children:[l&&g(l,{className:"size-4 text-gray-400"}),e.nav_title?e.nav_title:e.title]}),n&&g(Je,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!n||a)&&g("ul",{className:"mb-4 ml-2",children:e.children.map((c,h)=>g(ce,{item:c,pathname:t,openSidebar:r,setOpenSidebar:o},`${c.type}-${h}`))})]})}function ot({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=Y(e.icon);return I(le,{href:e.href,onClick:()=>r&&o(!1),className:d("flex items-center gap-2 text-gray-500 hover:bg-gray-100 py-2 px-2.5 rounded-lg",t===e.href&&"bg-gray-100 text-gray-800"),children:[a&&g(a,{className:"size-4"}),g("span",{children:e.nav_title?e.nav_title:e.title})]})}function ce({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){switch(e.type){case"page":return g(ot,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});case"section":return g(rt,{item:e,pathname:t,openSidebar:r,setOpenSidebar:o});default:return null}}function me({sidebarItems:e}){let{openSidebar:t,setOpenSidebar:r,openSearchBox:o,setOpenSearchBox:a}=B(),s=et();return I(at,{children:[g("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",t&&"opacity-100 pointer-events-auto"),onClick:()=>r(!1)}),I("aside",{className:d("fixed md:top-18 h-[calc(100svh-72px)] scrollbar-y w-screen max-md:rounded-t-lg z-21 md:w-72 pb-10 text-base md:text-sm shrink-0 border-r border-gray-200 p-4 max-md:fixed bg-white overflow-y-auto transition-all duration-300",t?"top-32":"top-full"),children:[I("div",{className:"flex items-center select-none gap-2 cursor-pointer mt-6 mb-4 p-2.5 text-gray-500 border border-gray-200 rounded-lg hover:bg-gray-50",onClick:()=>{r(t&&!1),a(!0)},children:[g(je,{className:"size-4.5"}),g("p",{children:"Search"}),I("div",{className:"ms-auto font-mono inline-flex gap-0.5",children:[g("span",{className:"rounded-md border border-gray-200 px-1.5",children:"Ctrl"}),g("span",{className:"rounded-md border border-gray-200 px-1.5",children:"K"})]})]}),e.map((n,l)=>g(ce,{item:n,pathname:s,openSidebar:t,setOpenSidebar:r},`${n.type}-${l}`))]})]})}import{jsx as de,jsxs as nt}from"react/jsx-runtime";function yr({children:e,sidebarItems:t}){return de(te,{children:nt("div",{className:"min-h-screen flex bg-white w-full",children:[de(me,{sidebarItems:t}),e]})})}import{usePathname as st}from"next/navigation";import{ChevronRight as it}from"lucide-react";import pe from"next/link";import{jsx as R,jsxs as ue}from"react/jsx-runtime";function fe(){let t=st().split("/").filter(Boolean),r=t.map((o,a)=>{let s="/"+t.slice(0,a+1).join("/"),n=o.replace(/-/g," ").replace(/\b\w/g,l=>l.toUpperCase());return{href:s,title:n}});return R("nav",{"aria-label":"Breadcrumb",className:"flex text-sm items-center pb-4 text-gray-500 not-prose",children:ue("ol",{className:"flex items-center space-x-2",children:[R("li",{children:R(pe,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let s=a===r.length-1;return ue("li",{className:"flex items-center space-x-2",children:[R(it,{className:"w-4 h-4 text-gray-400"}),s?R("span",{className:"text-gray-600 font-medium",children:o.title}):R(pe,{href:o.href,className:"hover:text-gray-700 font-medium transition-colors",children:o.title})]},o.href)})]})})}import{ArrowUpCircleIcon as lt,SquareArrowOutUpRightIcon as ct,TextAlignStartIcon as mt}from"lucide-react";import{usePathname as dt}from"next/navigation";import{useEffect as E,useRef as ge,useState as U}from"react";import{jsx as D,jsxs as z}from"react/jsx-runtime";function he(){let[e,t]=U(null),[r,o]=U("down"),[a,s]=U(!1),[n,l]=U(!1),{docstraConfig:c,page:h}=p(),i=h?.path,f=h?.tableOfContents||[],O=ge(0),y=ge(null),M=dt(),q=`${"https://github.com/"+c?.editOnGithub?.owner+"/"+c?.editOnGithub?.repo}/edit/main/${c?.editOnGithub?.path}/${i}`;E(()=>{let m=()=>{let u=window.scrollY;o(u>O.current?"down":"up"),s(u>100),O.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),E(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(S=>{if(n)return;let N=S.filter(P=>P.isIntersecting).sort((P,Re)=>P.boundingClientRect.top-Re.boundingClientRect.top);if(N.length>0){let P=r==="down"?N[0].target.id:N[N.length-1].target.id;t(P)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(S=>u.observe(S)),y.current=u,()=>u.disconnect()},[M,r,n]),E(()=>{!(window.scrollY>100)&&t(f[0]?.id)},[f]),E(()=>{if(!e)return;let m=document.querySelector(".toc-scroll-container");if(!m)return;let u=m.querySelector(`a[href="#${e}"]`);if(!u)return;let S=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<S.top||N.bottom>S.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),E(()=>{if(!n)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[n]);let G=m=>{t(m),l(!0)};return z("aside",{className:"sticky top-18 text-sm hidden xl:block text-gray-500 shrink-0 h-[calc(100svh-72px)] w-64 border-l border-gray-200 p-6 overflow-y-auto",children:[z("p",{className:"flex items-center gap-2 mb-5",children:[D(mt,{className:"size-4"}),"On this page"]}),D("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:f.map(m=>z("li",{children:[D(be,{heading:m,activeId:e,handleClick:G}),m.children.map(u=>D(be,{heading:u,activeId:e,handleClick:G,className:"pl-8"},u.id))]},m.id))}),D("hr",{className:"my-6 border-gray-200"}),c.editOnGithub&&z("a",{href:q,rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-400 hover:text-gray-700 transition",children:["Edit this page on GitHub",D(ct,{className:"size-4"})]}),a&&z("button",{onClick:()=>scrollTo({top:0,behavior:"smooth"}),className:"flex items-center cursor-pointer gap-2 mt-3 text-gray-400 hover:text-gray-700 transition",children:["Scroll to top",D(lt,{className:"size-4"})]})]})}function be({heading:e,activeId:t,handleClick:r,className:o}){return D("a",{href:`#${e.id}`,className:d("border-l border-gray-200 block py-1.5 pl-4 transition-colors",o,{"border-gray-800 text-gray-900 font-medium":t===e.id,"hover:text-gray-800 hover:border-gray-400":t!==e.id}),onClick:()=>r(e.id),children:e.text})}import{useState as A}from"react";import{ThumbsUp as ut,ThumbsDown as ft}from"lucide-react";import{jsx as Q,jsxs as xe}from"react/jsx-runtime";function W({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:s,value:n,readOnly:l=!1,className:c="",optional:h=!1}){return xe("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&xe("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,h&&Q("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?Q("textarea",{id:o,name:o,className:d("mt-2 w-full p-3 border border-gray-300 resize-none not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",c),placeholder:r,required:a,onChange:s,rows:4,value:n,readOnly:l,maxLength:500}):Q("input",{type:t,id:o,name:o,className:"mt-2 w-full h-12 px-3 border border-gray-300 not-focus:hover:border-gray-500 read-only:text-gray-400/80 outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-all duration-200 rounded-lg",placeholder:r,required:a,onChange:s,value:n,readOnly:l,maxLength:500})]})}import{Loader2Icon as pt}from"lucide-react";import{jsx as ye}from"react/jsx-runtime";function X({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:s}){return ye("button",{type:r,disabled:a,className:d("relative w-full mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg",o),"aria-label":e,onClick:s,children:t?ye(pt,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 animate-spin mx-auto"}):e})}import{FormSyncButton as gt,FormSyncForm as bt}from"formsync";import{Fragment as ve,jsx as x,jsxs as L}from"react/jsx-runtime";function we(){let[e,t]=A(null),{docstraConfig:r}=p(),[o,a]=A(""),[s,n]=A(!1),[l,c]=A(null),h="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return x("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:s?L(ve,{children:[x("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),x(X,{onClick:()=>{n(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):L(ve,{children:[x("p",{className:"font-medium",children:"How is this guide?"}),L("div",{className:"flex gap-2",children:[L("button",{onClick:()=>t("good"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="good"?"bg-green-100 text-green-600 border-green-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(ut,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),L("button",{onClick:()=>t("bad"),className:`flex items-center cursor-pointer gap-1 px-3 py-2 rounded-full border text-sm ${e==="bad"?"bg-red-100 text-red-600 border-red-300":"border-gray-200 text-gray-600 hover:bg-gray-100"}`,children:[x(ft,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&L(bt,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{n(!0),t(null),a("")},onSubmitError:i=>{c(i.message)},children:[x(W,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&x("p",{className:"text-red-500",children:l}),x("input",{type:"hidden",name:"opinion",value:e}),x("input",{type:"hidden",name:"page",value:window.location.href}),x("input",{type:"hidden",name:"_redirect",value:window.location.href}),x(gt,{className:"relative mt-4 h-12 px-6 py-3 cursor-pointer font-medium bg-gray-900 hover:opacity-85 text-white rounded-lg w-max text-sm",children:"Submit"}),r?.feedback?.watermark!==!1&&L("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",x("a",{href:`https://www.formsync.app?utm_source=${h}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as ht}from"react/jsx-runtime";function Ne(){let{pageData:e}=p();if(!e?.data?.lastUpdated)return null;let t=new Date(e.data.lastUpdated).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"});return ht("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}import{CheckIcon as xt,CopyIcon as yt}from"lucide-react";import{useEffect as vt,useState as ke}from"react";import{jsx as Z,jsxs as Se}from"react/jsx-runtime";function Ce(){let{pageData:e}=p(),[t,r]=ke(!1),[o,a]=ke(null);vt(()=>{a(window.location.href)},[]);let s=`Read from this URL: ${o} and explain it to me.`;return Se("div",{className:"flex items-center gap-3 mt-6",children:[Se("button",{title:"Copy Markdown",onClick:()=>{navigator.clipboard.writeText(e?.data.raw||""),r(!0),setTimeout(()=>r(!1),3e3)},className:"flex items-center cursor-pointer gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",children:[t?Z(xt,{className:"size-3.5"}):Z(yt,{className:"size-3.5"}),"Copy Markdown"]}),Z("a",{title:"Ask ChatGPT",href:`https://chatgpt.com/?hints=search&q=${encodeURIComponent(s)}`,className:"flex not-prose items-center gap-2 bg-gray-50 hover:bg-gray-100 border border-gray-200 px-3 py-2 rounded-md text-xs",rel:"noreferrer noopener",children:"Ask ChatGPT"})]})}import{usePathname as wt}from"next/navigation";import Ie from"next/link";import{ArrowLeftIcon as Nt,ArrowRightIcon as kt}from"lucide-react";import{jsx as T,jsxs as $}from"react/jsx-runtime";function De(e){let t=[];for(let r of e)r.type==="page"?t.push({name:r.title,href:r.href,icon:r.icon}):r.type==="section"&&t.push(...De(r.children));return t}function Le(){let e=wt(),{docstraConfig:t,sidebarItems:r}=p(),o=[];r&&r.length>0?o=De(r):t?.sidebar?.links&&(o=t.sidebar.links.flatMap(l=>l.items));let a=o.findIndex(l=>l.href===e),s=a>0?o[a-1]:null,n=a<o.length-1?o[a+1]:null;return $("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[s?$(Ie,{href:s.href,className:"flex flex-col not-prose items-start gap-2 border border-gray-200 hover:bg-gray-50 py-3 md:min-w-62 pl-4 pr-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Previous"}),$("p",{className:"flex items-center font-medium",children:[T(Nt,{className:"size-5 mr-2"}),s.name]})]}):T("div",{}),n?$(Ie,{href:n.href,className:"flex flex-col not-prose items-end gap-2 border border-gray-200 hover:bg-gray-50 py-3 pr-4 md:min-w-62 pl-10 rounded-lg text-sm",children:[T("span",{className:"text-gray-500",children:"Next"}),$("p",{className:"flex items-center font-medium",children:[n.name,T(kt,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as St,jsx as v,jsxs as Oe}from"react/jsx-runtime";function xo({children:e}){let{docstraConfig:t,page:r}=p();return Oe(St,{children:[v(ie,{}),Oe("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[v(fe,{}),v("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),v("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),v(Ce,{}),v("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&v(we,{}),v(Ne,{}),v(Le,{})]}),v(he,{})]})}import{CheckIcon as Pe,CopyIcon as Be}from"lucide-react";import{Highlight as Ct,themes as It}from"prism-react-renderer";import{useState as Dt}from"react";import{toast as Lt}from"react-toast-msg";import{jsx as b,jsxs as H}from"react/jsx-runtime";var J={npm:"npm install",pnpm:"pnpm add",yarn:"yarn add",bun:"bun add"};function Io(e){let{filename:t,copyable:r,children:o,className:a}=e,{packageManager:s,setPackageManager:n}=p(),l=!a?.includes("language-"),c=typeof o=="string"?o:o?.props?.children||"";if(l)return b("code",{className:"not-prose px-1 py-0.5 rounded border border-gray-200 bg-gray-50 text-gray-800 text-sm",children:c});let[h,i]=Dt(!1),O=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=O==="package-install",M=()=>{let w=y?`${J[s]} ${c.trim()}`:c.trim();navigator.clipboard.writeText(w),i(!0),Lt.success("Code copied to clipboard"),setTimeout(()=>i(!1),2e3)};return H("div",{className:"max-w-2xl overflow-hidden rounded-lg text-sm text-gray-800 border border-gray-200 mt-4 bg-white",children:[H("div",{className:"flex items-center justify-between bg-gray-50 border-b border-gray-200",children:[!y&&b("span",{className:"text-xs text-gray-400 px-4 py-3",children:t||O}),y&&b("div",{className:"flex items-center px-3",children:Object.keys(J).map(w=>b("button",{onClick:()=>n(w),className:`px-3 pb-2.5 pt-3 text-sm font-medium border-b-2 transition-all ${s===w?"border-gray-900 text-gray-900":"border-transparent text-gray-500 hover:text-gray-800"}`,children:w},w))}),r&&!y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:h?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]}),b(Ct,{theme:It.vsLight,code:c.trim(),language:y?"bash":O,children:({tokens:w,getLineProps:q,getTokenProps:G})=>H("pre",{className:`p-4 font-mono whitespace-pre overflow-x-auto text-sm leading-relaxed ${r&&y?"flex items-center justify-between":""}`,children:[w.map((m,u)=>H("div",{...q({line:m}),children:[!y&&b("span",{className:"text-gray-400 mr-4 select-none",children:u+1}),y&&b("span",{className:"mr-2",children:J[s]}),m.map((S,N)=>b("span",{...G({token:S})},N))]},u)),r&&y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:h?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]})})]})}export{xo as DocstraBody,Io as DocstraCodeBlock,ie as DocstraHeader,yr as DocstraLayout,Xt as DocstraProvider,p as useDocstra};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstra",
|
|
3
|
-
"version": "1.9.9-next.
|
|
3
|
+
"version": "1.9.9-next.7",
|
|
4
4
|
"description": "The Modern Documentation Framework for Next.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"prism-react-renderer": "^2.4.1",
|
|
42
42
|
"react-toast-msg": "^2.5.5",
|
|
43
43
|
"tailwind-merge": "^3.4.0",
|
|
44
|
-
"docstra-mdx": "0.0.
|
|
44
|
+
"docstra-mdx": "0.0.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"next": ">=16.0.0",
|