docstra 1.9.9-next.9 → 2.0.0
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.js +1 -1
- package/dist/client/index.mjs +1 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 E=require("react"),Se=require("react-toast-msg");var he=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 R=require("react"),xe=require("react/jsx-runtime"),ge=(0,R.createContext)(null);function be({children:e,initialSidebarItems:t}){let[r,o]=(0,R.useState)(t),[a,n]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1);return(0,xe.jsx)(ge.Provider,{value:{openSidebar:a,setOpenSidebar:n,openSearchBox:s,setOpenSearchBox:c,sidebarItems:r,setSiderbarItems:o},children:e})}function T(){let e=(0,R.useContext)(ge);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}var x=require("react/jsx-runtime");function Ne(){let{openSearchBox:e,setOpenSearchBox:t}=T(),{page:r}=f(),[o,a]=(0,O.useState)(""),[n,s]=(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);s(i.map(y=>y.item))}else o||s([])},[o,m]);let N=i=>{if(i.preventDefault(),o){let y=n[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,x.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,x.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,x.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,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(he.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,x.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,x.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,x.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,x.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,x.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,x.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,x.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var A=require("react/jsx-runtime"),ke=(0,E.createContext)(null);function et({children:e,docstraConfig:t,page:r}){let[o,a]=(0,E.useState)(!1),[n,s]=(0,E.useState)(!1),[c,m]=(0,E.useState)("npm");return(0,A.jsxs)(ke.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:n,setOpenSearchBox:s,packageManager:c,setPackageManager:m,page:r},children:[(0,A.jsx)(Se.ToastContainer,{}),(0,A.jsx)(Ne,{}),e]})}function f(){let e=(0,E.useContext)(ke);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 S=require("react/jsx-runtime");function oe(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=T(),{docstraConfig:a}=f(),n="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,S.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,S.jsx)(Q.default,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,S.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,S.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(s=>(0,S.jsx)(Q.default,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),(0,S.jsx)(Q.default,{href:n||"https://github.com/sudhucodes/docstra",children:(0,S.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,S.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,S.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,S.jsx)(W.XIcon,{className:"size-6.5"}):(0,S.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,n]=(0,De.useState)(e.defaultOpen??!0),s=e.collapsible??!0,c=ae(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ne.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.nav_title?e.nav_title:e.title]}),s&&(0,l.jsx)(X.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,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(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=T(),a=(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",e&&"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",e?"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(e&&!1),o(!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"})]})]}),r.map((n,s)=>(0,l.jsx)(Le,{item:n,pathname:a,openSidebar:e,setOpenSidebar:t},`${n.type}-${s}`))]})]})}var H=require("react/jsx-runtime");function at({children:e,sidebarItems:t}){return(0,H.jsx)(be,{initialSidebarItems:t,children:(0,H.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,H.jsx)(Oe,{}),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 n="/"+t.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)(se.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let n=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"}),n?(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,n]=(0,w.useState)(!1),[s,c]=(0,w.useState)(!1),{docstraConfig:m,page:N}=f(),i=N?.path,y=N?.tableOfContents||[],M=(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>M.current?"down":"up"),n(b>100),M.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(s)return;let L=P.filter(G=>G.isIntersecting).sort((G,Ve)=>G.boundingClientRect.top-Ve.boundingClientRect.top);if(L.length>0){let G=r==="down"?L[0].target.id:L[L.length-1].target.id;t(G)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[K,r,s]),(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(!s)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[s]);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 z=require("react/jsx-runtime");function ie({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:m="",optional:N=!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,N&&(0,z.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="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:r,required:a,onChange:n,rows:4,value:s,readOnly:c,maxLength:500}):(0,z.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:n,value:s,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:n}){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:n,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)(""),[n,s]=(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: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)(ce,{onClick:()=>{s(!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=>{s(!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 $=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 n=`Read from this URL: ${o} and explain it to me.`;return(0,$.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,$.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,$.jsx)(j.CheckIcon,{className:"size-3.5"}):(0,$.jsx)(j.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,$.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 Ae=require("next/navigation"),me=B(require("next/link")),ee=require("lucide-react");var k=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}=f(),{sidebarItems:r}=T(),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),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return(0,k.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?(0,k.jsxs)(me.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,k.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[(0,k.jsx)(ee.ArrowLeftIcon,{className:"size-5 mr-2"}),n.name]})]}):(0,k.jsx)("div",{}),s?(0,k.jsxs)(me.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,k.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,k.jsx)(ee.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,k.jsx)("div",{})]})}var h=require("react/jsx-runtime");function nt({children:e}){let{docstraConfig:t,page:r}=f();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(oe,{}),(0,h.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,h.jsx)(Re,{}),(0,h.jsx)("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),(0,h.jsx)("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),(0,h.jsx)(Ue,{}),(0,h.jsx)("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&(0,h.jsx)(Me,{}),(0,h.jsx)(Ge,{}),(0,h.jsx)(qe,{})]}),(0,h.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: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[N,i]=(0,_e.useState)(!1),M=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=M==="package-install",K=()=>{let D=C?`${de[n]} ${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||M}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(de).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))}),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":M,children:({tokens:D,getLineProps:re,getTokenProps:V})=>(0,u.jsxs)("pre",{className:`p-4 font-mono scrollbar-x max-md:max-w-[calc(100vw-34px)] 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[n]}),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});
|
|
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 E=require("react"),Se=require("react-toast-msg");var he=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 R=require("react"),xe=require("react/jsx-runtime"),ge=(0,R.createContext)(null);function be({children:e,initialSidebarItems:t}){let[r,o]=(0,R.useState)(t),[a,n]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1);return(0,xe.jsx)(ge.Provider,{value:{openSidebar:a,setOpenSidebar:n,openSearchBox:s,setOpenSearchBox:c,sidebarItems:r,setSiderbarItems:o},children:e})}function T(){let e=(0,R.useContext)(ge);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}var x=require("react/jsx-runtime");function Ne(){let{openSearchBox:e,setOpenSearchBox:t}=T(),{page:r}=f(),[o,a]=(0,O.useState)(""),[n,s]=(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);s(i.map(y=>y.item))}else o||s([])},[o,m]);let N=i=>{if(i.preventDefault(),o){let y=n[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,x.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,x.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,x.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,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(he.SearchIcon,{className:"size-5.5 mx-3 shrink-0"}),(0,x.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,x.jsx)("span",{className:"border border-gray-200 px-2 mr-3 py-1 rounded text-xs",children:"Esc"})]})}),(0,x.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,x.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,x.jsx)("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),(0,x.jsx)("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&(0,x.jsx)("div",{className:"text-gray-500 text-center py-20",children:"No results found"})]})]})})}var A=require("react/jsx-runtime"),ke=(0,E.createContext)(null);function et({children:e,docstraConfig:t,page:r}){let[o,a]=(0,E.useState)(!1),[n,s]=(0,E.useState)(!1),[c,m]=(0,E.useState)("npm");return(0,A.jsxs)(ke.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:n,setOpenSearchBox:s,packageManager:c,setPackageManager:m,page:r},children:[(0,A.jsx)(Se.ToastContainer,{}),(0,A.jsx)(Ne,{}),e]})}function f(){let e=(0,E.useContext)(ke);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 S=require("react/jsx-runtime");function oe(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=T(),{docstraConfig:a}=f(),n="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,S.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,S.jsx)(Q.default,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:(0,S.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,S.jsxs)("div",{className:"hidden divide-x divide-gray-200 md:flex items-center",children:[a.navbar?.links?.map(s=>(0,S.jsx)(Q.default,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),(0,S.jsx)(Q.default,{href:n||"https://github.com/sudhucodes/docstra",children:(0,S.jsx)("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,S.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,S.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,S.jsx)(W.XIcon,{className:"size-6.5"}):(0,S.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,n]=(0,De.useState)(e.defaultOpen??!0),s=e.collapsible??!0,c=ae(e.icon);return(0,l.jsxs)("div",{children:[(0,l.jsxs)(ne.default,{href:e.href,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]}),s&&(0,l.jsx)("div",{onClick:()=>s&&n(m=>!m),className:"pl-3",children:(0,l.jsx)(X.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,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(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=T(),a=(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",e&&"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",e?"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(e&&!1),o(!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"})]})]}),r.map((n,s)=>(0,l.jsx)(Le,{item:n,pathname:a,openSidebar:e,setOpenSidebar:t},`${n.type}-${s}`))]})]})}var H=require("react/jsx-runtime");function at({children:e,sidebarItems:t}){return(0,H.jsx)(be,{initialSidebarItems:t,children:(0,H.jsxs)("div",{className:"min-h-screen flex bg-white w-full",children:[(0,H.jsx)(Oe,{}),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 n="/"+t.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)(se.default,{href:"/",className:"hover:text-gray-700 transition-colors font-medium",children:"Home"})}),r.map((o,a)=>{let n=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"}),n?(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,n]=(0,w.useState)(!1),[s,c]=(0,w.useState)(!1),{docstraConfig:m,page:N}=f(),i=N?.path,y=N?.tableOfContents||[],M=(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>M.current?"down":"up"),n(b>100),M.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(s)return;let L=P.filter(G=>G.isIntersecting).sort((G,Ve)=>G.boundingClientRect.top-Ve.boundingClientRect.top);if(L.length>0){let G=r==="down"?L[0].target.id:L[L.length-1].target.id;t(G)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return p.forEach(P=>b.observe(P)),C.current=b,()=>b.disconnect()},[K,r,s]),(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(!s)return;let p=setTimeout(()=>c(!1),800);return()=>clearTimeout(p)},[s]);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 z=require("react/jsx-runtime");function ie({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:n,value:s,readOnly:c=!1,className:m="",optional:N=!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,N&&(0,z.jsx)("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="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:r,required:a,onChange:n,rows:4,value:s,readOnly:c,maxLength:500}):(0,z.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:n,value:s,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:n}){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:n,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)(""),[n,s]=(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: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)(ce,{onClick:()=>{s(!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=>{s(!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 $=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 n=`Read from this URL: ${o} and explain it to me.`;return(0,$.jsxs)("div",{className:"flex items-center gap-3 mt-6",children:[(0,$.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,$.jsx)(j.CheckIcon,{className:"size-3.5"}):(0,$.jsx)(j.CopyIcon,{className:"size-3.5"}),"Copy Markdown"]}),(0,$.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 Ae=require("next/navigation"),me=B(require("next/link")),ee=require("lucide-react");var k=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}=f(),{sidebarItems:r}=T(),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),n=a>0?o[a-1]:null,s=a<o.length-1?o[a+1]:null;return(0,k.jsxs)("div",{className:"flex flex-col lg:flex-row gap-2 justify-between py-10 mt-10",children:[n?(0,k.jsxs)(me.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,k.jsx)("span",{className:"text-gray-500",children:"Previous"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[(0,k.jsx)(ee.ArrowLeftIcon,{className:"size-5 mr-2"}),n.name]})]}):(0,k.jsx)("div",{}),s?(0,k.jsxs)(me.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,k.jsx)("span",{className:"text-gray-500",children:"Next"}),(0,k.jsxs)("p",{className:"flex items-center font-medium",children:[s.name,(0,k.jsx)(ee.ArrowRightIcon,{className:"size-5 ml-2"})]})]}):(0,k.jsx)("div",{})]})}var h=require("react/jsx-runtime");function nt({children:e}){let{docstraConfig:t,page:r}=f();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(oe,{}),(0,h.jsxs)("main",{className:"flex-1 px-4 md:px-8 md:pl-80 pt-28 py-10 prose max-w-none",children:[(0,h.jsx)(Re,{}),(0,h.jsx)("h1",{className:"text-3xl font-bold",children:r?.metadata?.title}),(0,h.jsx)("p",{className:"my-4 text-gray-500",children:r?.metadata?.description}),(0,h.jsx)(Ue,{}),(0,h.jsx)("hr",{className:"my-10 border-gray-200"}),e,t?.feedback?.enabled&&(0,h.jsx)(Me,{}),(0,h.jsx)(Ge,{}),(0,h.jsx)(qe,{})]}),(0,h.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: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[N,i]=(0,_e.useState)(!1),M=a?.match(/language-([\w-]+)/)?.[1]??"txt",C=M==="package-install",K=()=>{let D=C?`${de[n]} ${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||M}),C&&(0,u.jsx)("div",{className:"flex items-center px-3",children:Object.keys(de).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))}),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":M,children:({tokens:D,getLineProps:re,getTokenProps:V})=>(0,u.jsxs)("pre",{className:`p-4 font-mono scrollbar-x max-md:max-w-[calc(100vw-34px)] 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[n]}),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 _e,useContext as Ke,useState as V}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 K,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 _}from"react";import{jsx as Me}from"react/jsx-runtime";var ee=ze(null);function te({children:e,initialSidebarItems:t}){let[r,o]=_(t),[a,n]=_(!1),[s,l]=_(!1);return Me(ee.Provider,{value:{openSidebar:a,setOpenSidebar:n,openSearchBox:s,setOpenSearchBox:l,sidebarItems:r,setSiderbarItems:o},children:e})}function C(){let e=$e(ee);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}import{Fragment as qe,jsx as I,jsxs as F}from"react/jsx-runtime";function oe(){let{openSearchBox:e,setOpenSearchBox:t}=C(),{page:r}=p(),[o,a]=re(""),[n,s]=re([]),l=He();K(()=>{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]);K(()=>{if(o&&c){let i=c.search(o);s(i.map(f=>f.item))}else o||s([])},[o,c]);let x=i=>{if(i.preventDefault(),o){let f=n[0];f&&(l.push(`/docs/${f.slug}`),a(""),t(!1))}};return K(()=>{let i=f=>{f.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),I("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:[I("form",{onSubmit:x,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:[I(Ge,{className:"size-5.5 mx-3 shrink-0"}),I("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}),I("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:[n.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:[I("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),I("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&I("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]=V(!1),[n,s]=V(!1),[l,c]=V("npm");return Ye(ne.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:n,setOpenSearchBox:s,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 Y from"next/link";import{jsx as S,jsxs as se}from"react/jsx-runtime";function ie(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=C(),{docstraConfig:a}=p(),n="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:[S(Y,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:S("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(s=>S(Y,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),S(Y,{href:n||"https://github.com/sudhucodes/docstra",children:S("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:S("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"})})})]}),S("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?S(We,{className:"size-6.5"}):S(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 Q(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 D}from"react/jsx-runtime";function rt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,n]=tt(e.defaultOpen??!0),s=e.collapsible??!0,l=Q(e.icon);return D("div",{children:[D(le,{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:[D("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]}),s&&g(Je,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})]}),(!s||a)&&g("ul",{className:"mb-4 ml-2",children:e.children.map((c,x)=>g(ce,{item:c,pathname:t,openSidebar:r,setOpenSidebar:o},`${c.type}-${x}`))})]})}function ot({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=Q(e.icon);return D(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(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=C(),a=et();return D(at,{children:[g("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),D("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",e?"top-32":"top-full"),children:[D("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(e&&!1),o(!0)},children:[g(je,{className:"size-4.5"}),g("p",{children:"Search"}),D("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"})]})]}),r.map((n,s)=>g(ce,{item:n,pathname:a,openSidebar:e,setOpenSidebar:t},`${n.type}-${s}`))]})]})}import{jsx as de,jsxs as nt}from"react/jsx-runtime";function yr({children:e,sidebarItems:t}){return de(te,{initialSidebarItems:t,children:nt("div",{className:"min-h-screen flex bg-white w-full",children:[de(me,{}),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 n="/"+t.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: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 n=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"}),n?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 L,jsxs as z}from"react/jsx-runtime";function xe(){let[e,t]=U(null),[r,o]=U("down"),[a,n]=U(!1),[s,l]=U(!1),{docstraConfig:c,page:x}=p(),i=x?.path,f=x?.tableOfContents||[],P=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>P.current?"down":"up"),n(u>100),P.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),E(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(k=>{if(s)return;let N=k.filter(B=>B.isIntersecting).sort((B,Re)=>B.boundingClientRect.top-Re.boundingClientRect.top);if(N.length>0){let B=r==="down"?N[0].target.id:N[N.length-1].target.id;t(B)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(k=>u.observe(k)),y.current=u,()=>u.disconnect()},[M,r,s]),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 k=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<k.top||N.bottom>k.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),E(()=>{if(!s)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[s]);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:[L(mt,{className:"size-4"}),"On this page"]}),L("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:f.map(m=>z("li",{children:[L(be,{heading:m,activeId:e,handleClick:G}),m.children.map(u=>L(be,{heading:u,activeId:e,handleClick:G,className:"pl-8"},u.id))]},m.id))}),L("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",L(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",L(lt,{className:"size-4"})]})]})}function be({heading:e,activeId:t,handleClick:r,className:o}){return L("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 W,jsxs as he}from"react/jsx-runtime";function X({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:c="",optional:x=!1}){return he("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&he("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,x&&W("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?W("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:n,rows:4,value:s,readOnly:l,maxLength:500}):W("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:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as pt}from"lucide-react";import{jsx as ye}from"react/jsx-runtime";function Z({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:n}){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:n,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 h,jsxs as O}from"react/jsx-runtime";function we(){let[e,t]=A(null),{docstraConfig:r}=p(),[o,a]=A(""),[n,s]=A(!1),[l,c]=A(null),x="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?O(ve,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(Z,{onClick:()=>{s(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):O(ve,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),O("div",{className:"flex gap-2",children:[O("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:[h(ut,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),O("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:[h(ft,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&O(bt,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),t(null),a("")},onSubmitError:i=>{c(i.message)},children:[h(X,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&h("p",{className:"text-red-500",children:l}),h("input",{type:"hidden",name:"opinion",value:e}),h("input",{type:"hidden",name:"page",value:window.location.href}),h("input",{type:"hidden",name:"_redirect",value:window.location.href}),h(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&&O("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${x}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as xt}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 xt("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}import{CheckIcon as ht,CopyIcon as yt}from"lucide-react";import{useEffect as vt,useState as Se}from"react";import{jsx as J,jsxs as ke}from"react/jsx-runtime";function Ce(){let{pageData:e}=p(),[t,r]=Se(!1),[o,a]=Se(null);vt(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ke("div",{className:"flex items-center gap-3 mt-6",children:[ke("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?J(ht,{className:"size-3.5"}):J(yt,{className:"size-3.5"}),"Copy Markdown"]}),J("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 wt}from"next/navigation";import Ie from"next/link";import{ArrowLeftIcon as Nt,ArrowRightIcon as St}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}=p(),{sidebarItems:r}=C(),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),n=a>0?o[a-1]:null,s=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:[n?$(Ie,{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"}),$("p",{className:"flex items-center font-medium",children:[T(Nt,{className:"size-5 mr-2"}),n.name]})]}):T("div",{}),s?$(Ie,{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"}),$("p",{className:"flex items-center font-medium",children:[s.name,T(St,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as kt,jsx as v,jsxs as Oe}from"react/jsx-runtime";function yo({children:e}){let{docstraConfig:t,page:r}=p();return Oe(kt,{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(xe,{})]})}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 Do(e){let{filename:t,copyable:r,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 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[x,i]=Dt(!1),P=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=P==="package-install",M=()=>{let w=y?`${j[n]} ${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||P}),y&&b("div",{className:"flex items-center px-3",children:Object.keys(j).map(w=>b("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))}),r&&!y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:x?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]}),b(Ct,{theme:It.vsLight,code:c.trim(),language:y?"bash":P,children:({tokens:w,getLineProps:q,getTokenProps:G})=>H("pre",{className:`p-4 font-mono scrollbar-x max-md:max-w-[calc(100vw-34px)] 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[n]}),m.map((k,N)=>b("span",{...G({token:k})},N))]},u)),r&&y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:x?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]})})]})}export{yo as DocstraBody,Do as DocstraCodeBlock,ie as DocstraHeader,yr as DocstraLayout,Xt as DocstraProvider,p as useDocstra};
|
|
1
|
+
"use client";import{createContext as _e,useContext as Ke,useState as V}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 K,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 _}from"react";import{jsx as Me}from"react/jsx-runtime";var ee=ze(null);function te({children:e,initialSidebarItems:t}){let[r,o]=_(t),[a,n]=_(!1),[s,l]=_(!1);return Me(ee.Provider,{value:{openSidebar:a,setOpenSidebar:n,openSearchBox:s,setOpenSearchBox:l,sidebarItems:r,setSiderbarItems:o},children:e})}function C(){let e=$e(ee);if(!e)throw new Error("Please wrap your layout with SidebarProvider");return e}import{Fragment as qe,jsx as I,jsxs as F}from"react/jsx-runtime";function oe(){let{openSearchBox:e,setOpenSearchBox:t}=C(),{page:r}=p(),[o,a]=re(""),[n,s]=re([]),l=He();K(()=>{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]);K(()=>{if(o&&c){let i=c.search(o);s(i.map(f=>f.item))}else o||s([])},[o,c]);let x=i=>{if(i.preventDefault(),o){let f=n[0];f&&(l.push(`/docs/${f.slug}`),a(""),t(!1))}};return K(()=>{let i=f=>{f.key==="Escape"&&(t(!1),a(""))};return e&&window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[e]),I("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:[I("form",{onSubmit:x,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:[I(Ge,{className:"size-5.5 mx-3 shrink-0"}),I("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}),I("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:[n.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:[I("h4",{className:"font-medium",children:i.data?.metadata?.title||i.slug}),I("p",{className:"text-sm mt-1 text-gray-500",children:i.data?.metadata?.description})]},i.slug)),o&&n.length===0&&I("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]=V(!1),[n,s]=V(!1),[l,c]=V("npm");return Ye(ne.Provider,{value:{openSidebar:o,setOpenSidebar:a,docstraConfig:t,openSearchBox:n,setOpenSearchBox:s,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 Y from"next/link";import{jsx as S,jsxs as se}from"react/jsx-runtime";function ie(){let{openSidebar:e,setOpenSidebar:t,openSearchBox:r,setOpenSearchBox:o}=C(),{docstraConfig:a}=p(),n="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:[S(Y,{href:a.navbar?.logo?.link||"/",className:"hover:opacity-80 transition",children:S("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(s=>S(Y,{href:s.href,className:"px-6 hover:text-gray-600",children:s.name},s.name)),S(Y,{href:n||"https://github.com/sudhucodes/docstra",children:S("svg",{className:"size-6 mx-6",width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:S("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"})})})]}),S("button",{onClick:()=>t(!e),className:"md:hidden transition text-gray-600 active:ring-2 ring-gray-200 p-1.5 rounded-md",children:e?S(We,{className:"size-6.5"}):S(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 Q(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 D}from"react/jsx-runtime";function rt({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let[a,n]=tt(e.defaultOpen??!0),s=e.collapsible??!0,l=Q(e.icon);return D("div",{children:[D(le,{href:e.href,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:[D("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]}),s&&g("div",{onClick:()=>s&&n(c=>!c),className:"pl-3",children:g(Je,{className:d("size-4 text-black/50 transition-transform duration-300",a&&"rotate-180")})})]}),(!s||a)&&g("ul",{className:"mb-4 ml-2",children:e.children.map((c,x)=>g(ce,{item:c,pathname:t,openSidebar:r,setOpenSidebar:o},`${c.type}-${x}`))})]})}function ot({item:e,pathname:t,openSidebar:r,setOpenSidebar:o}){let a=Q(e.icon);return D(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(){let{openSidebar:e,setOpenSidebar:t,sidebarItems:r,setOpenSearchBox:o}=C(),a=et();return D(at,{children:[g("div",{className:d("fixed inset-0 z-20 bg-black/50 opacity-0 pointer-events-none transition-all duration-300",e&&"opacity-100 pointer-events-auto"),onClick:()=>t(!1)}),D("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",e?"top-32":"top-full"),children:[D("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(e&&!1),o(!0)},children:[g(je,{className:"size-4.5"}),g("p",{children:"Search"}),D("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"})]})]}),r.map((n,s)=>g(ce,{item:n,pathname:a,openSidebar:e,setOpenSidebar:t},`${n.type}-${s}`))]})]})}import{jsx as de,jsxs as nt}from"react/jsx-runtime";function yr({children:e,sidebarItems:t}){return de(te,{initialSidebarItems:t,children:nt("div",{className:"min-h-screen flex bg-white w-full",children:[de(me,{}),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 n="/"+t.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: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 n=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"}),n?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 L,jsxs as z}from"react/jsx-runtime";function xe(){let[e,t]=U(null),[r,o]=U("down"),[a,n]=U(!1),[s,l]=U(!1),{docstraConfig:c,page:x}=p(),i=x?.path,f=x?.tableOfContents||[],P=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>P.current?"down":"up"),n(u>100),P.current=u};return window.addEventListener("scroll",m),()=>window.removeEventListener("scroll",m)},[]),E(()=>{let m=document.querySelectorAll("h2[id], h3[id]"),u=new IntersectionObserver(k=>{if(s)return;let N=k.filter(B=>B.isIntersecting).sort((B,Re)=>B.boundingClientRect.top-Re.boundingClientRect.top);if(N.length>0){let B=r==="down"?N[0].target.id:N[N.length-1].target.id;t(B)}},{rootMargin:"-40% 0px -50% 0px",threshold:[0,.2,.6,1]});return m.forEach(k=>u.observe(k)),y.current=u,()=>u.disconnect()},[M,r,s]),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 k=m.getBoundingClientRect(),N=u.getBoundingClientRect();(N.top<k.top||N.bottom>k.bottom)&&u.scrollIntoView({behavior:"smooth",block:"nearest"})},[e]),E(()=>{if(!s)return;let m=setTimeout(()=>l(!1),800);return()=>clearTimeout(m)},[s]);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:[L(mt,{className:"size-4"}),"On this page"]}),L("ul",{className:"toc-scroll-container max-h-3/4 overflow-y-auto scrollbar-none",children:f.map(m=>z("li",{children:[L(be,{heading:m,activeId:e,handleClick:G}),m.children.map(u=>L(be,{heading:u,activeId:e,handleClick:G,className:"pl-8"},u.id))]},m.id))}),L("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",L(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",L(lt,{className:"size-4"})]})]})}function be({heading:e,activeId:t,handleClick:r,className:o}){return L("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 W,jsxs as he}from"react/jsx-runtime";function X({label:e,type:t,placeholder:r="",id:o,required:a=!1,onChange:n,value:s,readOnly:l=!1,className:c="",optional:x=!1}){return he("div",{className:d("flex flex-col mt-4 w-full",c),children:[e&&he("label",{htmlFor:o,className:"font-medium w-max cursor-pointer",children:[e,x&&W("span",{className:"text-xs font-normal text-gray-400 ml-1 mt-1",children:"(Optional)"})]}),t==="textarea"?W("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:n,rows:4,value:s,readOnly:l,maxLength:500}):W("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:n,value:s,readOnly:l,maxLength:500})]})}import{Loader2Icon as pt}from"lucide-react";import{jsx as ye}from"react/jsx-runtime";function Z({label:e,loading:t,type:r="submit",className:o="",disabled:a=!1,onClick:n}){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:n,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 h,jsxs as O}from"react/jsx-runtime";function we(){let[e,t]=A(null),{docstraConfig:r}=p(),[o,a]=A(""),[n,s]=A(!1),[l,c]=A(null),x="https://github.com/"+r?.editOnGithub?.owner+"/"+r?.editOnGithub?.repo;return h("div",{className:"border-y border-gray-200 mt-10 py-10 space-y-4",children:n?O(ve,{children:[h("p",{className:"font-medium text-gray-900",children:"We appreciate your feedback, Thank you!"}),h(Z,{onClick:()=>{s(!1),t(null),a("")},label:"Submit Again",className:"w-max text-sm"})]}):O(ve,{children:[h("p",{className:"font-medium",children:"How is this guide?"}),O("div",{className:"flex gap-2",children:[O("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:[h(ut,{className:`size-4 ${e==="good"?"fill-green-600":"text-gray-500"}`}),"Good"]}),O("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:[h(ft,{className:`size-4 pt-0.5 ${e==="bad"?"fill-red-600":"text-gray-500"}`}),"Bad"]})]}),e&&O(bt,{className:"flex flex-col gap-2",formId:r?.feedback?.formSyncFormID||"",onSuccess:i=>{s(!0),t(null),a("")},onSubmitError:i=>{c(i.message)},children:[h(X,{value:o,id:"message",onChange:i=>a(i.target.value),placeholder:"Leave your feedback...",required:!0,type:"textarea"}),l&&h("p",{className:"text-red-500",children:l}),h("input",{type:"hidden",name:"opinion",value:e}),h("input",{type:"hidden",name:"page",value:window.location.href}),h("input",{type:"hidden",name:"_redirect",value:window.location.href}),h(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&&O("p",{className:"text-left text-sm text-gray-500 mt-6",children:["Powered by"," ",h("a",{href:`https://www.formsync.app?utm_source=${x}`,className:"text-gray-800 not-prose",children:"FormSync"})]})]})]})})}import{jsxs as xt}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 xt("p",{className:"text-sm text-gray-500",children:["Last updated on ",t]})}import{CheckIcon as ht,CopyIcon as yt}from"lucide-react";import{useEffect as vt,useState as Se}from"react";import{jsx as J,jsxs as ke}from"react/jsx-runtime";function Ce(){let{pageData:e}=p(),[t,r]=Se(!1),[o,a]=Se(null);vt(()=>{a(window.location.href)},[]);let n=`Read from this URL: ${o} and explain it to me.`;return ke("div",{className:"flex items-center gap-3 mt-6",children:[ke("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?J(ht,{className:"size-3.5"}):J(yt,{className:"size-3.5"}),"Copy Markdown"]}),J("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 wt}from"next/navigation";import Ie from"next/link";import{ArrowLeftIcon as Nt,ArrowRightIcon as St}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}=p(),{sidebarItems:r}=C(),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),n=a>0?o[a-1]:null,s=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:[n?$(Ie,{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"}),$("p",{className:"flex items-center font-medium",children:[T(Nt,{className:"size-5 mr-2"}),n.name]})]}):T("div",{}),s?$(Ie,{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"}),$("p",{className:"flex items-center font-medium",children:[s.name,T(St,{className:"size-5 ml-2"})]})]}):T("div",{})]})}import{Fragment as kt,jsx as v,jsxs as Oe}from"react/jsx-runtime";function yo({children:e}){let{docstraConfig:t,page:r}=p();return Oe(kt,{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(xe,{})]})}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 Do(e){let{filename:t,copyable:r,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 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[x,i]=Dt(!1),P=a?.match(/language-([\w-]+)/)?.[1]??"txt",y=P==="package-install",M=()=>{let w=y?`${j[n]} ${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||P}),y&&b("div",{className:"flex items-center px-3",children:Object.keys(j).map(w=>b("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))}),r&&!y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 m-2 text-gray-500 hover:bg-gray-200 transition",children:x?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]}),b(Ct,{theme:It.vsLight,code:c.trim(),language:y?"bash":P,children:({tokens:w,getLineProps:q,getTokenProps:G})=>H("pre",{className:`p-4 font-mono scrollbar-x max-md:max-w-[calc(100vw-34px)] 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[n]}),m.map((k,N)=>b("span",{...G({token:k})},N))]},u)),r&&y&&b("button",{onClick:M,className:"rounded-lg cursor-pointer p-2 text-gray-500 hover:bg-gray-100 transition",children:x?b(Pe,{className:"size-4 text-green-600"}):b(Be,{className:"size-4"})})]})})]})}export{yo as DocstraBody,Do as DocstraCodeBlock,ie as DocstraHeader,yr as DocstraLayout,Xt as DocstraProvider,p as useDocstra};
|