@tailor-platform/app-shell 0.11.1 → 0.12.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/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/package.json +4 -7
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,10 @@ type DefineResourceProps = CommonProps & ReactResourceProps & {
|
|
|
156
156
|
*/
|
|
157
157
|
declare function defineResource(props: DefineResourceProps): Resource;
|
|
158
158
|
|
|
159
|
+
type RouterContainerProps = {
|
|
160
|
+
rootComponent?: () => React.ReactNode;
|
|
161
|
+
};
|
|
162
|
+
|
|
159
163
|
type AppShellProps = {
|
|
160
164
|
/**
|
|
161
165
|
* App shell title
|
|
@@ -173,6 +177,12 @@ type AppShellProps = {
|
|
|
173
177
|
* Base path for the app shell
|
|
174
178
|
*/
|
|
175
179
|
basePath?: string;
|
|
180
|
+
/**
|
|
181
|
+
* A component to be rendered at the root level of AppShell
|
|
182
|
+
*
|
|
183
|
+
* If not provided, defaults to the builtin empty outlet component
|
|
184
|
+
*/
|
|
185
|
+
rootComponent?: RouterContainerProps["rootComponent"];
|
|
176
186
|
/**
|
|
177
187
|
* Navigation configuration
|
|
178
188
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Table as va}from"lucide-react";import{useEffect as xa,useMemo as ya,useState as ka}from"react";import{createContext as Qt,useContext as Jt}from"react";var j=Qt({navItems:[],configurations:{modules:[]}}),P=()=>Jt(j);import{createBrowserRouter as da,RouterProvider as la,Navigate as ca}from"react-router";import{NavLink as sa,Outlet as nt}from"react-router";import{Toaster as ia}from"sonner";import{Slot as aa}from"@radix-ui/react-slot";import{cva as ea}from"class-variance-authority";import{clsx as Zt}from"clsx";import{twMerge as ta}from"tailwind-merge";function l(...t){return ta(Zt(t))}import{jsx as oa}from"react/jsx-runtime";var ra=ea("astw:inline-flex astw:items-center astw:justify-center astw:gap-2 astw:whitespace-nowrap astw:rounded-md astw:text-sm astw:font-medium astw:transition-all astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:[&_svg]:pointer-events-none astw:[&_svg:not([class*='size-'])]:size-4 astw:shrink-0 astw:[&_svg]:shrink-0 astw:outline-none astw:focus-visible:border-ring astw:focus-visible:ring-ring/50 astw:focus-visible:ring-[3px] astw:aria-invalid:ring-destructive/20 astw:dark:aria-invalid:ring-destructive/40 astw:aria-invalid:border-destructive",{variants:{variant:{default:"astw:bg-primary astw:text-primary-foreground astw:shadow-xs astw:hover:bg-primary/90",destructive:"astw:bg-destructive astw:text-white astw:shadow-xs astw:hover:bg-destructive/90 astw:focus-visible:ring-destructive/20 astw:dark:focus-visible:ring-destructive/40 astw:dark:bg-destructive/60",outline:"astw:border astw:bg-background astw:shadow-xs astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:bg-input/30 astw:dark:border-input astw:dark:hover:bg-input/50",secondary:"astw:bg-secondary astw:text-secondary-foreground astw:shadow-xs astw:hover:bg-secondary/80",ghost:"astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:hover:bg-accent/50",link:"astw:text-primary astw:underline-offset-4 astw:hover:underline"},size:{default:"astw:h-9 astw:px-4 astw:py-2 astw:has-[>svg]:px-3",sm:"astw:h-8 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-10 astw:rounded-md astw:px-6 astw:has-[>svg]:px-4",icon:"astw:size-9"}},defaultVariants:{variant:"default",size:"default"}});function T({className:t,variant:a,size:e,asChild:r=!1,...o}){return oa(r?aa:"button",{"data-slot":"button",className:l(ra({variant:a,size:e,className:t})),...o})}import{Fragment as na,jsx as h,jsxs as A}from"react/jsx-runtime";var W=({contentBorder:t,children:a})=>h("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),dt=()=>A(W,{contentBorder:!0,children:[h("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),h("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),K=()=>A(na,{children:[h(nt,{}),h(ia,{})]}),lt=()=>{let{configurations:t}=P();return A("div",{className:"astw:mx-auto astw:flex-col astw:flex astw:md:flex-row astw:max-w-5xl astw:gap-[10px] astw:w-full",children:[h("div",{children:A("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[h("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),h("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources?.map(a=>h("li",{children:h(sa,{to:`./${a.path}`,children:({isActive:e})=>A(T,{variant:e?"secondary":"ghost",className:"astw:w-full astw:justify-start",children:[a.meta.icon,a.meta.title]})})},a.path))})]})}),h("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:h(nt,{})})]})};import{jsx as ct}from"react/jsx-runtime";var wa=t=>t.reduce((a,e)=>{let r={index:!0,Component:e.component};return[...a,{path:e.path,...e.resources&&e.resources.length>0?{children:[r,...e.resources.map(wt)]}:{children:[r]}}]},[]),wt=t=>{let a={index:!0,Component:t.component};return{path:t.path,...t.subResources&&t.subResources.length>0?{children:[a,...t.subResources.map(wt)]}:{children:[a]}}},pt=t=>{let{configurations:a}=P(),e=da([{path:a.basePath,element:t.children,children:[{index:!0,Component:dt},{path:N,children:wa(a.modules)},{path:"settings",index:!0,Component:()=>ct(ca,{to:(a.settingsResources??[])[0].path,relative:"path",replace:!0})},{path:"settings",Component:lt,children:a.settingsResources?.map(r=>({path:r.path,Component:r.component}))}]}]);return ct(la,{router:e})};import{createContext as pa,useContext as ua,useEffect as ga,useMemo as ma,useState as ba}from"react";import{jsx as fa}from"react/jsx-runtime";var ha={resolvedTheme:"light",theme:"system",setTheme:()=>null},ut=pa(ha);function gt({children:t,storageKey:a,defaultTheme:e="system",...r}){let[o,i]=ba(()=>localStorage.getItem(a)||e),c=ma(()=>o!=="system"?o:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[o]);ga(()=>{let d=window.document.documentElement;d.classList.remove("light","dark"),d.classList.add(c)},[c]);let s={resolvedTheme:c,theme:o,setTheme:d=>{localStorage.setItem(a,d),i(d)}};return fa(ut.Provider,{...r,value:s,children:t})}var F=()=>{let t=ua(ut);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as U}from"react/jsx-runtime";var N="resources",Ca=t=>{let[a,e]=ka(!1);xa(function(){e(!0)},[]);let r=t.configurations.basePath,o=c=>r?`/${r}/${N}/${c}`:`/${N}/${c}`,i=ya(()=>t.configurations.modules.map(s=>{let d=s.resources.map(w=>({title:w.meta.title,url:o(`${s.path}/${w.path}`)}));return{title:s.meta.title,url:s.meta.menuItemClickable?o(s.path):void 0,clickable:s.component,icon:s.meta.icon||U(va,{}),isActive:!0,items:d}}),[t.configurations.modules]);return a?U(j.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:r},navItems:i},children:U(gt,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:U(pt,{children:t.children})})}):null};import*as z from"@radix-ui/react-collapsible";import{jsx as q}from"react/jsx-runtime";function mt({...t}){return q(z.Root,{"data-slot":"collapsible",...t})}function G({...t}){return q(z.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function bt({...t}){return q(z.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Vt,useMatch as Va}from"react-router";import*as b from"react";import{Slot as J}from"@radix-ui/react-slot";import{cva as za}from"class-variance-authority";import{PanelLeftIcon as Ma}from"lucide-react";import*as H from"react";var Y=768;function ht(){let[t,a]=H.useState(void 0);return H.useEffect(()=>{let e=window.matchMedia(`(max-width: ${Y-1}px)`),r=()=>{a(window.innerWidth<Y)};return e.addEventListener("change",r),a(window.innerWidth<Y),()=>e.removeEventListener("change",r)},[]),!!t}import{jsx as qe}from"react/jsx-runtime";import*as Pa from"@radix-ui/react-separator";import{jsx as Je}from"react/jsx-runtime";import*as g from"@radix-ui/react-dialog";import{XIcon as Sa}from"lucide-react";import{jsx as y,jsxs as X}from"react/jsx-runtime";function ft({...t}){return y(g.Root,{"data-slot":"sheet",...t})}function Ra({...t}){return y(g.Portal,{"data-slot":"sheet-portal",...t})}function Ta({className:t,...a}){return y(g.Overlay,{"data-slot":"sheet-overlay",className:l("astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=open]:fade-in-0 astw:fixed astw:inset-0 astw:z-50 astw:bg-black/50",t),...a})}function vt({className:t,children:a,side:e="right",...r}){return X(Ra,{children:[y(Ta,{}),X(g.Content,{"data-slot":"sheet-content",className:l("astw:bg-background astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:fixed astw:z-50 astw:flex astw:flex-col astw:gap-4 astw:shadow-lg astw:transition astw:ease-in-out astw:data-[state=closed]:duration-300 astw:data-[state=open]:duration-500",e==="right"&&"astw:data-[state=closed]:slide-out-to-right astw:data-[state=open]:slide-in-from-right astw:inset-y-0 astw:right-0 astw:h-full astw:w-3/4 astw:border-l astw:sm:max-w-sm",e==="left"&&"astw:data-[state=closed]:slide-out-to-left astw:data-[state=open]:slide-in-from-left astw:inset-y-0 astw:left-0 astw:h-full astw:w-3/4 astw:border-r astw:sm:max-w-sm",e==="top"&&"astw:data-[state=closed]:slide-out-to-top astw:data-[state=open]:slide-in-from-top astw:inset-x-0 astw:top-0 astw:h-auto astw:border-b",e==="bottom"&&"astw:data-[state=closed]:slide-out-to-bottom astw:data-[state=open]:slide-in-from-bottom astw:inset-x-0 astw:bottom-0 astw:h-auto astw:border-t",t),...r,children:[a,X(g.Close,{className:"astw:ring-offset-bg astw:focus:ring-ring astw:data-[state=open]:bg-secondary astw:absolute astw:top-4 astw:right-4 astw:rounded-xs astw:opacity-70 astw:transition-opacity astw:hover:opacity-100 astw:focus:ring-2 astw:focus:ring-offset-2 astw:focus:outline-hidden astw:disabled:pointer-events-none",children:[y(Sa,{className:"astw:size-4"}),y("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function xt({className:t,...a}){return y("div",{"data-slot":"sheet-header",className:l("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function yt({className:t,...a}){return y(g.Title,{"data-slot":"sheet-title",className:l("astw:text-foreground astw:font-semibold",t),...a})}function kt({className:t,...a}){return y(g.Description,{"data-slot":"sheet-description",className:l("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as ir}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as M,jsxs as Na}from"react/jsx-runtime";function Q({delayDuration:t=0,...a}){return M(f.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Ct({...t}){return M(Q,{children:M(f.Root,{"data-slot":"tooltip",...t})})}function Pt({...t}){return M(f.Trigger,{"data-slot":"tooltip-trigger",...t})}function St({className:t,sideOffset:a=0,children:e,...r}){return M(f.Portal,{children:Na(f.Content,{"data-slot":"tooltip-content",sideOffset:a,className:l("astw:bg-primary astw:text-primary-foreground astw:animate-in astw:fade-in-0 astw:zoom-in-95 astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=closed]:zoom-out-95 astw:data-[side=bottom]:slide-in-from-top-2 astw:data-[side=left]:slide-in-from-right-2 astw:data-[side=right]:slide-in-from-left-2 astw:data-[side=top]:slide-in-from-bottom-2 astw:z-50 astw:w-fit astw:origin-(--radix-tooltip-content-transform-origin) astw:rounded-md astw:px-3 astw:py-1.5 astw:text-xs astw:text-balance",t),...r,children:[e,M(f.Arrow,{className:"astw:bg-primary astw:fill-primary astw:z-50 astw:size-2.5 astw:translate-y-[calc(-50%_-_2px)] astw:rotate-45 astw:rounded-[2px]"})]})})}import{jsx as p,jsxs as B}from"react/jsx-runtime";var _a="sidebar_state",Ia=60*60*24*7,Aa="16rem",Ba="18rem",Ea="3rem",La="b",Rt=b.createContext(null);function E(){let t=b.useContext(Rt);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function Tt({defaultOpen:t=!0,open:a,onOpenChange:e,className:r,style:o,children:i,...c}){let s=ht(),[d,w]=b.useState(!1),[u,x]=b.useState(t),k=a??u,S=b.useCallback(v=>{let C=typeof v=="function"?v(k):v;e?e(C):x(C),document.cookie=`${_a}=${C}; path=/; max-age=${Ia}`},[e,k]),R=b.useCallback(()=>s?w(v=>!v):S(v=>!v),[s,S,w]);b.useEffect(()=>{let v=C=>{C.key===La&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),R())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[R]);let V=k?"expanded":"collapsed",$=b.useMemo(()=>({state:V,open:k,setOpen:S,isMobile:s,openMobile:d,setOpenMobile:w,toggleSidebar:R}),[V,k,S,s,d,w,R]);return p(Rt.Provider,{value:$,children:p(Q,{delayDuration:0,children:p("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Aa,"--sidebar-width-icon":Ea,...o},className:l("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",r),...c,children:i})})})}function Nt({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:r,children:o,...i}){let{isMobile:c,state:s,openMobile:d,setOpenMobile:w}=E();return e==="none"?p("div",{"data-slot":"sidebar",className:l("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",r),...i,children:o}):c?p(ft,{open:d,onOpenChange:w,...i,children:B(vt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",style:{"--sidebar-width":Ba},side:t,children:[B(xt,{className:"sr-only",children:[p(yt,{children:"Sidebar"}),p(kt,{children:"Displays the mobile sidebar."})]}),p("div",{className:"flex h-full w-full flex-col",children:o})]})}):B("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":s,"data-collapsible":s==="collapsed"?e:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[p("div",{"data-slot":"sidebar-gap",className:l("astw:relative astw:w-(--sidebar-width) astw:bg-transparent astw:transition-[width] astw:duration-200 astw:ease-linear","astw:group-data-[collapsible=offcanvas]:w-0","astw:group-data-[side=right]:rotate-180",a==="floating"||a==="inset"?"astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),p("div",{"data-slot":"sidebar-container",className:l("astw:fixed astw:inset-y-0 astw:z-10 astw:hidden astw:h-svh astw:w-(--sidebar-width) astw:transition-[left,right,width] astw:duration-200 astw:ease-linear astw:md:flex",t==="left"?"astw:left-0 astw:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"astw:right-0 astw:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",a==="floating"||a==="inset"?"astw:p-2 astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon) astw:group-data-[side=left]:border-r astw:group-data-[side=right]:border-l",a==="inset"&&"astw:border-x astw:border-x-border",r),...i,children:p("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"astw:bg-sidebar astw:group-data-[variant=floating]:border-sidebar-border astw:flex astw:h-full astw:w-full astw:flex-col astw:group-data-[variant=floating]:rounded-lg astw:group-data-[variant=floating]:border astw:group-data-[variant=floating]:shadow-sm",children:o})})]})}function Z({className:t,onClick:a,...e}){let{toggleSidebar:r}=E();return B(T,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:l("astw:text-muted-foreground",t),onClick:o=>{a?.(o),r()},...e,children:[p(Ma,{className:"astw:size-4.5"}),p("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function zt({className:t,...a}){return p("main",{"data-slot":"sidebar-inset",className:l("astw:bg-background astw:relative astw:flex astw:w-full astw:flex-1 astw:flex-col","astw:px-4 astw:md:peer-data-[variant=inset]:px-8 astw:md:peer-data-[variant=inset]:py-2",t),...a})}function Mt({className:t,...a}){return p("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:l("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function _t({className:t,...a}){return p("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:l("astw:flex astw:min-h-0 astw:flex-1 astw:flex-col astw:gap-2 astw:overflow-auto astw:group-data-[collapsible=icon]:overflow-hidden",t),...a})}function It({className:t,...a}){return p("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:l("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function At({className:t,...a}){return p("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:l("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function Bt({className:t,...a}){return p("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:l("astw:group/menu-item astw:relative",t),...a})}var Oa=za("astw:peer/menu-button astw:flex astw:w-full astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:p-2 astw:text-left astw:text-sm astw:outline-hidden astw:ring-sidebar-ring astw:transition-[width,height,padding] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:focus-visible:ring-2 astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:group-has-data-[sidebar=menu-action]/menu-item:pr-8 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:font-medium astw:data-[active=true]:text-sidebar-accent-foreground astw:data-[state=open]:hover:bg-sidebar-accent astw:data-[state=open]:hover:text-sidebar-accent-foreground astw:group-data-[collapsible=icon]:size-8! astw:group-data-[collapsible=icon]:p-2! astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",{variants:{variant:{default:"astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground",outline:"astw:bg-background astw:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"astw:h-8 astw:text-sm",sm:"astw:h-7 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-12 astw:text-sm astw:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function tt({asChild:t=!1,isActive:a=!1,variant:e="default",size:r="default",tooltip:o,className:i,...c}){let s=t?J:"button",{isMobile:d,state:w}=E(),u=p(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:l(Oa({variant:e,size:r}),i),...c});return o?(typeof o=="string"&&(o={children:o}),B(Ct,{children:[p(Pt,{asChild:!0,children:u}),p(St,{side:"right",align:"center",hidden:w!=="collapsed"||d,...o})]})):u}function at({className:t,asChild:a=!1,showOnHover:e=!1,...r}){return p(a?J:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:l("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:peer-hover/menu-button:text-sidebar-accent-foreground astw:absolute astw:top-1.5 astw:right-1 astw:flex astw:aspect-square astw:w-5 astw:items-center astw:justify-center astw:rounded-md astw:p-0 astw:outline-hidden astw:transition-transform astw:focus-visible:ring-2 astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:after:absolute astw:after:-inset-2 astw:md:after:hidden","astw:peer-data-[size=sm]/menu-button:top-1","astw:peer-data-[size=default]/menu-button:top-1.5","astw:peer-data-[size=lg]/menu-button:top-2.5","astw:group-data-[collapsible=icon]:hidden",e&&"astw:peer-data-[active=true]/menu-button:text-sidebar-accent-foreground astw:group-focus-within/menu-item:opacity-100 astw:group-hover/menu-item:opacity-100 astw:data-[state=open]:opacity-100 astw:md:opacity-0",t),...r})}function Et({className:t,...a}){return p("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:l("astw:border-sidebar-border astw:mx-3.5 astw:flex astw:min-w-0 astw:translate-x-px astw:flex-col astw:gap-1 astw:border-l astw:px-2.5 astw:py-0.5","astw:group-data-[collapsible=icon]:hidden",t),...a})}function Lt({className:t,...a}){return p("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:l("astw:group/menu-sub-item astw:relative",t),...a})}function Ot({asChild:t=!1,size:a="md",isActive:e=!1,className:r,...o}){return p(t?J:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:l("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:[&>svg]:text-sidebar-accent-foreground astw:flex astw:h-7 astw:min-w-0 astw:-translate-x-px astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:px-2 astw:outline-hidden astw:focus-visible:ring-2 astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:text-sidebar-accent-foreground",a==="sm"&&"astw:text-xs",a==="md"&&"astw:text-sm","astw:group-data-[collapsible=icon]:hidden",r),...o})}import{ChevronRight as Ut,SunIcon as ja}from"lucide-react";import{Slot as Wa}from"@radix-ui/react-slot";import{ChevronRight as Ua,MoreHorizontal as Ar}from"lucide-react";import{Link as Da,useHref as $a}from"react-router";import{jsx as Dt}from"react/jsx-runtime";function L({to:t,children:a,...e}){try{return $a(t),Dt(Da,{to:t,...e,children:a})}catch{return Dt("a",{href:t,...e,children:a})}}import{jsx as _,jsxs as Or}from"react/jsx-runtime";function et({...t}){return _("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function rt({className:t,...a}){return _("ol",{"data-slot":"breadcrumb-list",className:l("astw:text-muted-foreground astw:flex astw:flex-wrap astw:items-center astw:gap-1.5 astw:text-sm astw:break-words astw:sm:gap-2.5",t),...a})}function ot({className:t,...a}){return _("li",{"data-slot":"breadcrumb-item",className:l("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function st({asChild:t,className:a,children:e,...r}){return _(t?Wa:L,{"data-slot":"breadcrumb-link",className:l("astw:hover:text-foreground astw:transition-colors",a),...r,children:e})}function $t({children:t,className:a,...e}){return _("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:l("astw:[&>svg]:size-3.5",a),...e,children:t??_(Ua,{})})}var Ha=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let r=(o,i)=>{!o||o.length===0||o.forEach(c=>{let s=`${i}/${c.path}`;a[s]={title:c.meta.title,breadcrumbTitle:c.meta.breadcrumbTitle},c.subResources&&c.subResources.length>0&&r(c.subResources,s)})};return e.resources&&e.resources.length>0&&r(e.resources,e.path),a},{});function Wt(t,a,e){let r=t.split("/").filter(s=>s!=="").slice(1),o=a?(()=>{let[s,...d]=r;return d})():r,i=Ha(e),c=o.map((s,d)=>{let w=o.slice(0,d+1).join("/"),u=i[w];if(!u){let k=Object.entries(i).find(([S])=>{let R=S.split("/").map($=>$.startsWith(":")?"[^/]+":$).join("/");return new RegExp(`^${R}$`).test(w)})?.[1];k&&(u=k)}let x;return u?typeof u.breadcrumbTitle=="function"?x=u.breadcrumbTitle(s):typeof u.breadcrumbTitle=="string"?x=u.breadcrumbTitle:x=u.title:x=decodeURIComponent(s),{segment:s,path:w,title:x}});return{basePath:a||null,segments:c}}import{Fragment as Ht,jsx as n,jsxs as m}from"react/jsx-runtime";var Ka=()=>{let{open:t}=E();return n("div",{className:t?"astw:md:hidden":void 0,children:n(Z,{className:"astw:-ml-2.5"})})},Fa=t=>{let a=t.children?t.children({Outlet:K}):null,e=F(),r=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return n(Tt,{className:"astw:flex astw:flex-col",children:m("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??n(jt,{}),m(zt,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[n("header",{className:"astw:flex astw:h-14 astw:shrink-0 astw:items-center astw:gap-2 astw:transition-[width,height] astw:ease-linear astw:group-has-data-[collapsible=icon]/sidebar-wrapper:h-12",children:m("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[m("div",{className:"astw:flex astw:items-center astw:gap-2",children:[n(Ka,{}),n(qa,{})]}),n("div",{className:"astw:flex astw:items-center astw:gap-2",children:n(T,{variant:"outline",size:"icon",onClick:r,children:n(ja,{})})})]})}),n("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??n(K,{})})]})]})})},jt=t=>{let{title:a,icon:e,navItems:r}=P(),{pathname:o}=Vt(),i=m(Mt,{children:[e,n("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return m(Nt,{variant:"inset",children:[m("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??i,n("div",{className:"astw:hidden astw:md:block",children:n(Z,{className:"astw:-ml-1"})})]}),n(_t,{children:n(It,{children:n(At,{children:r.map(s=>n(mt,{asChild:!0,defaultOpen:s.isActive,children:m(Bt,{children:[s.url?m(Ht,{children:[n(tt,{asChild:!0,tooltip:s.title,children:m(L,{to:s.url,className:s.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,n("span",{children:s.title})]})}),!!s.items?.length&&n(G,{asChild:!0,children:m(at,{className:"astw:data-[state=open]:rotate-90",children:[n(Ut,{}),n("span",{className:"sr-only",children:"Toggle"})]})})]}):n(Ht,{children:m(G,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[n(tt,{asChild:!0,tooltip:s.title,children:m("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,n("span",{children:s.title})]})}),!!s.items?.length&&n(at,{className:"astw-rotate-target",asChild:!0,children:m("span",{children:[n(Ut,{}),n("span",{className:"sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&n(bt,{children:n(Et,{children:s.items?.map(d=>n(Lt,{children:n(Ot,{asChild:!0,children:n(L,{to:d.url,className:d.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:n("span",{children:d.title})})})},d.title))})})]})},s.title))})})}),t.footer??null]})},Ga=()=>{let{configurations:t}=P(),a=Vt();return Wt(a.pathname,t.basePath,t.modules)},qa=()=>{let{basePath:t,segments:a}=Ga(),e=Va("/:prefix/settings/:suffix");return e?n(et,{children:n(rt,{children:n("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:n(ot,{children:n(st,{to:`/${e.params.prefix}/settings`,children:"Settings"})})})})}):n(et,{children:n(rt,{children:a.map((r,o)=>m("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[n(ot,{children:n(st,{to:`${t?`/${t}`:""}/${N}/${r.path}`,children:r.title})}),o<a.length-1&&n($t,{})]},o))})})};import{useEffect as Ya}from"react";import{capitalCase as Kt}from"change-case";import{useNavigate as Xa}from"react-router";import{jsx as Ft}from"react/jsx-runtime";function Qa(t){let{path:a,meta:e,component:r,defaultResourceRedirectPath:o,resources:i}=t,c=e?.title??Kt(a),s=r||function(){let w=Xa();return Ya(()=>{w(o)},[w]),null};return{path:a,type:"component",_type:"module",component:()=>Ft(W,{contentBorder:e?.contentBorder??!1,children:s({title:c,resources:i})}),meta:{title:c,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!o,icon:t.meta?.icon},resources:i}}function Ja(t){let{path:a,component:e,subResources:r,meta:o}=t,i=o?.title??Kt(a);return{_type:"resource",type:"component",path:a,meta:{title:i,icon:o?.icon,...o?.breadcrumbTitle!==void 0?{breadcrumbTitle:o.breadcrumbTitle}:{}},component:()=>Ft(W,{contentBorder:o?.contentBorder??!1,children:e({title:i,resources:r})}),subResources:r}}import{useLocation as ko,useNavigate as Co,useParams as Po,useSearchParams as So,Link as Ro}from"react-router";import{createContext as te,useCallback as it,useContext as ae,useEffect as ee,useState as re}from"react";import*as I from"oauth4webapi";var O="oauth_pkce_verifier",D="oauth_state",Gt=({idpEndpoint:t,clientId:a,state:e,codeChallenge:r,redirectUri:o})=>{let i=new URL(`${t}/oauth2/authorize`);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",a),i.searchParams.set("redirect_uri",o||window.location.origin),i.searchParams.set("scope","openid profile email"),i.searchParams.set("state",e),i.searchParams.set("code_challenge",r),i.searchParams.set("code_challenge_method","S256"),i.toString()},Za=async({code:t,returnedState:a,idpEndpoint:e,clientId:r,redirectUri:o})=>{let i=sessionStorage.getItem(O),c=sessionStorage.getItem(D);if(!t||!a||!i||!c){let d=[];throw t||d.push("code"),a||d.push("returnedState"),i||d.push("code_verifier"),c||d.push("expectedState"),new Error(`Missing params: ${d.join(", ")}`)}if(a!==c)throw new Error("State mismatch: possible CSRF attack");let s=new URLSearchParams({grant_type:"authorization_code",client_id:r,code:t,redirect_uri:o||window.location.origin,code_verifier:i});try{let d=await fetch(`${e}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:s.toString()}),{access_token:w}=await d.json();return w}catch(d){throw new Error(`Token exchange failed: ${d instanceof Error?d.message:String(d)}`)}},qt=async()=>{let t=I.generateRandomCodeVerifier(),a=await I.calculatePKCECodeChallenge(t),e=I.generateRandomState();return sessionStorage.setItem(O,t),sessionStorage.setItem(D,e),{codeChallenge:a,state:e}},Yt=async({currentUrl:t,idpEndpoint:a,clientId:e,redirectUri:r})=>{try{let o=t.searchParams.get("code"),i=t.searchParams.get("state");await Za({idpEndpoint:a,clientId:e,code:o,returnedState:i,redirectUri:r})}catch(o){console.error(o)}finally{sessionStorage.removeItem(O),sessionStorage.removeItem(D),t.searchParams.delete("code"),t.searchParams.delete("state"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),window.history.replaceState({},document.title,t.toString())}};import{jsx as ie}from"react/jsx-runtime";var Xt=te(void 0),oe=()=>{let t=ae(Xt);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},se=({idpEndpoint:t,clientId:a,redirectUri:e,children:r})=>{let[o,i]=re(!0),c=it(async()=>{let{codeChallenge:w,state:u}=await qt(),x=Gt({idpEndpoint:t,clientId:a,codeChallenge:w,state:u,redirectUri:e});window.location.href=x},[t,a,e]),s=it(async()=>{sessionStorage.removeItem(O),sessionStorage.removeItem(D);try{await fetch(`${t}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:""}),window.location.href="/"}catch(w){console.error(w)}},[t]),d=it(async w=>{i(!0),await Yt({currentUrl:w,idpEndpoint:t,clientId:a,redirectUri:e}),i(!1)},[t,a,e]);return ee(()=>{let w=new URL(window.location.href);w.searchParams.has("error")&&w.searchParams.has("error_description")?(console.error(w.searchParams.get("error_description")||"Authentication Error"),i(!1)):w.searchParams.has("code")&&w.searchParams.has("state")?d(w):i(!1)},[]),ie(Xt.Provider,{value:{isLoading:o,login:c,logout:s},children:r})};export{Ca as AppShell,se as BuiltinIdPAuthProvider,jt as DefaultSidebar,Ro as Link,Fa as SidebarLayoutContainer,Qa as defineModule,Ja as defineResource,P as useAppShell,oe as useBuiltinIdpAuth,ko as useLocation,Co as useNavigate,Po as useParams,So as useSearchParams,F as useTheme};
|
|
1
|
+
import{Table as va}from"lucide-react";import{useEffect as xa,useMemo as ya,useState as ka}from"react";import{createContext as Qt,useContext as Jt}from"react";var j=Qt({navItems:[],configurations:{modules:[]}}),P=()=>Jt(j);import{createBrowserRouter as da,RouterProvider as la,Navigate as ca}from"react-router";import{NavLink as sa,Outlet as nt}from"react-router";import{Toaster as ia}from"sonner";import{Slot as aa}from"@radix-ui/react-slot";import{cva as ea}from"class-variance-authority";import{clsx as Zt}from"clsx";import{twMerge as ta}from"tailwind-merge";function l(...t){return ta(Zt(t))}import{jsx as oa}from"react/jsx-runtime";var ra=ea("astw:inline-flex astw:items-center astw:justify-center astw:gap-2 astw:whitespace-nowrap astw:rounded-md astw:text-sm astw:font-medium astw:transition-all astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:[&_svg]:pointer-events-none astw:[&_svg:not([class*='size-'])]:size-4 astw:shrink-0 astw:[&_svg]:shrink-0 astw:outline-none astw:focus-visible:border-ring astw:focus-visible:ring-ring/50 astw:focus-visible:ring-[3px] astw:aria-invalid:ring-destructive/20 astw:dark:aria-invalid:ring-destructive/40 astw:aria-invalid:border-destructive",{variants:{variant:{default:"astw:bg-primary astw:text-primary-foreground astw:shadow-xs astw:hover:bg-primary/90",destructive:"astw:bg-destructive astw:text-white astw:shadow-xs astw:hover:bg-destructive/90 astw:focus-visible:ring-destructive/20 astw:dark:focus-visible:ring-destructive/40 astw:dark:bg-destructive/60",outline:"astw:border astw:bg-background astw:shadow-xs astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:bg-input/30 astw:dark:border-input astw:dark:hover:bg-input/50",secondary:"astw:bg-secondary astw:text-secondary-foreground astw:shadow-xs astw:hover:bg-secondary/80",ghost:"astw:hover:bg-accent astw:hover:text-accent-foreground astw:dark:hover:bg-accent/50",link:"astw:text-primary astw:underline-offset-4 astw:hover:underline"},size:{default:"astw:h-9 astw:px-4 astw:py-2 astw:has-[>svg]:px-3",sm:"astw:h-8 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-10 astw:rounded-md astw:px-6 astw:has-[>svg]:px-4",icon:"astw:size-9"}},defaultVariants:{variant:"default",size:"default"}});function T({className:t,variant:a,size:e,asChild:o=!1,...r}){return oa(o?aa:"button",{"data-slot":"button",className:l(ra({variant:a,size:e,className:t})),...r})}import{Fragment as na,jsx as h,jsxs as A}from"react/jsx-runtime";var W=({contentBorder:t,children:a})=>h("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),dt=()=>A(W,{contentBorder:!0,children:[h("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),h("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),K=()=>A(na,{children:[h(nt,{}),h(ia,{})]}),lt=()=>{let{configurations:t}=P();return A("div",{className:"astw:mx-auto astw:flex-col astw:flex astw:md:flex-row astw:max-w-5xl astw:gap-[10px] astw:w-full",children:[h("div",{children:A("nav",{className:"astw:bg-card astw:md:w-xs astw:rounded-md astw:border astw:p-3 astw:shadow-xs",children:[h("h2",{className:"astw:text-sm astw:leading-[36px] astw:mb-2 astw:font-bold ",children:"Settings"}),h("ul",{className:"astw:flex astw:flex-col astw:gap-1",children:t.settingsResources?.map(a=>h("li",{children:h(sa,{to:`./${a.path}`,children:({isActive:e})=>A(T,{variant:e?"secondary":"ghost",className:"astw:w-full astw:justify-start",children:[a.meta.icon,a.meta.title]})})},a.path))})]})}),h("section",{className:"astw:bg-card astw:flex-1 astw:rounded-md astw:border astw:shadow-xs",children:h(nt,{})})]})};import{jsx as ct}from"react/jsx-runtime";var wa=t=>t.reduce((a,e)=>{let o={index:!0,Component:e.component};return[...a,{path:e.path,...e.resources&&e.resources.length>0?{children:[o,...e.resources.map(wt)]}:{children:[o]}}]},[]),wt=t=>{let a={index:!0,Component:t.component};return{path:t.path,...t.subResources&&t.subResources.length>0?{children:[a,...t.subResources.map(wt)]}:{children:[a]}}},pt=t=>{let{configurations:a}=P(),e=t.rootComponent??dt,o=da([{path:a.basePath,element:t.children,children:[{index:!0,Component:e},{path:N,children:wa(a.modules)},{path:"settings",index:!0,Component:()=>ct(ca,{to:(a.settingsResources??[])[0].path,relative:"path",replace:!0})},{path:"settings",Component:lt,children:a.settingsResources?.map(r=>({path:r.path,Component:r.component}))}]}]);return ct(la,{router:o})};import{createContext as pa,useContext as ua,useEffect as ga,useMemo as ma,useState as ba}from"react";import{jsx as fa}from"react/jsx-runtime";var ha={resolvedTheme:"light",theme:"system",setTheme:()=>null},ut=pa(ha);function gt({children:t,storageKey:a,defaultTheme:e="system",...o}){let[r,i]=ba(()=>localStorage.getItem(a)||e),c=ma(()=>r!=="system"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[r]);ga(()=>{let d=window.document.documentElement;d.classList.remove("light","dark"),d.classList.add(c)},[c]);let s={resolvedTheme:c,theme:r,setTheme:d=>{localStorage.setItem(a,d),i(d)}};return fa(ut.Provider,{...o,value:s,children:t})}var F=()=>{let t=ua(ut);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as U}from"react/jsx-runtime";var N="resources",Ca=t=>{let[a,e]=ka(!1);xa(function(){e(!0)},[]);let o=t.configurations.basePath,r=c=>o?`/${o}/${N}/${c}`:`/${N}/${c}`,i=ya(()=>t.configurations.modules.map(s=>{let d=s.resources.map(w=>({title:w.meta.title,url:r(`${s.path}/${w.path}`)}));return{title:s.meta.title,url:s.meta.menuItemClickable?r(s.path):void 0,clickable:s.component,icon:s.meta.icon||U(va,{}),isActive:!0,items:d}}),[t.configurations.modules]);return a?U(j.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:o},navItems:i},children:U(gt,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:U(pt,{rootComponent:t.configurations.rootComponent,children:t.children})})}):null};import*as z from"@radix-ui/react-collapsible";import{jsx as q}from"react/jsx-runtime";function mt({...t}){return q(z.Root,{"data-slot":"collapsible",...t})}function G({...t}){return q(z.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function bt({...t}){return q(z.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Vt,useMatch as Va}from"react-router";import*as b from"react";import{Slot as J}from"@radix-ui/react-slot";import{cva as za}from"class-variance-authority";import{PanelLeftIcon as Ma}from"lucide-react";import*as H from"react";var Y=768;function ht(){let[t,a]=H.useState(void 0);return H.useEffect(()=>{let e=window.matchMedia(`(max-width: ${Y-1}px)`),o=()=>{a(window.innerWidth<Y)};return e.addEventListener("change",o),a(window.innerWidth<Y),()=>e.removeEventListener("change",o)},[]),!!t}import{jsx as Ye}from"react/jsx-runtime";import*as Pa from"@radix-ui/react-separator";import{jsx as Ze}from"react/jsx-runtime";import*as g from"@radix-ui/react-dialog";import{XIcon as Sa}from"lucide-react";import{jsx as y,jsxs as X}from"react/jsx-runtime";function ft({...t}){return y(g.Root,{"data-slot":"sheet",...t})}function Ra({...t}){return y(g.Portal,{"data-slot":"sheet-portal",...t})}function Ta({className:t,...a}){return y(g.Overlay,{"data-slot":"sheet-overlay",className:l("astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=open]:fade-in-0 astw:fixed astw:inset-0 astw:z-50 astw:bg-black/50",t),...a})}function vt({className:t,children:a,side:e="right",...o}){return X(Ra,{children:[y(Ta,{}),X(g.Content,{"data-slot":"sheet-content",className:l("astw:bg-background astw:data-[state=open]:animate-in astw:data-[state=closed]:animate-out astw:fixed astw:z-50 astw:flex astw:flex-col astw:gap-4 astw:shadow-lg astw:transition astw:ease-in-out astw:data-[state=closed]:duration-300 astw:data-[state=open]:duration-500",e==="right"&&"astw:data-[state=closed]:slide-out-to-right astw:data-[state=open]:slide-in-from-right astw:inset-y-0 astw:right-0 astw:h-full astw:w-3/4 astw:border-l astw:sm:max-w-sm",e==="left"&&"astw:data-[state=closed]:slide-out-to-left astw:data-[state=open]:slide-in-from-left astw:inset-y-0 astw:left-0 astw:h-full astw:w-3/4 astw:border-r astw:sm:max-w-sm",e==="top"&&"astw:data-[state=closed]:slide-out-to-top astw:data-[state=open]:slide-in-from-top astw:inset-x-0 astw:top-0 astw:h-auto astw:border-b",e==="bottom"&&"astw:data-[state=closed]:slide-out-to-bottom astw:data-[state=open]:slide-in-from-bottom astw:inset-x-0 astw:bottom-0 astw:h-auto astw:border-t",t),...o,children:[a,X(g.Close,{className:"astw:ring-offset-bg astw:focus:ring-ring astw:data-[state=open]:bg-secondary astw:absolute astw:top-4 astw:right-4 astw:rounded-xs astw:opacity-70 astw:transition-opacity astw:hover:opacity-100 astw:focus:ring-2 astw:focus:ring-offset-2 astw:focus:outline-hidden astw:disabled:pointer-events-none",children:[y(Sa,{className:"astw:size-4"}),y("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function xt({className:t,...a}){return y("div",{"data-slot":"sheet-header",className:l("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function yt({className:t,...a}){return y(g.Title,{"data-slot":"sheet-title",className:l("astw:text-foreground astw:font-semibold",t),...a})}function kt({className:t,...a}){return y(g.Description,{"data-slot":"sheet-description",className:l("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as nr}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as M,jsxs as Na}from"react/jsx-runtime";function Q({delayDuration:t=0,...a}){return M(f.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function Ct({...t}){return M(Q,{children:M(f.Root,{"data-slot":"tooltip",...t})})}function Pt({...t}){return M(f.Trigger,{"data-slot":"tooltip-trigger",...t})}function St({className:t,sideOffset:a=0,children:e,...o}){return M(f.Portal,{children:Na(f.Content,{"data-slot":"tooltip-content",sideOffset:a,className:l("astw:bg-primary astw:text-primary-foreground astw:animate-in astw:fade-in-0 astw:zoom-in-95 astw:data-[state=closed]:animate-out astw:data-[state=closed]:fade-out-0 astw:data-[state=closed]:zoom-out-95 astw:data-[side=bottom]:slide-in-from-top-2 astw:data-[side=left]:slide-in-from-right-2 astw:data-[side=right]:slide-in-from-left-2 astw:data-[side=top]:slide-in-from-bottom-2 astw:z-50 astw:w-fit astw:origin-(--radix-tooltip-content-transform-origin) astw:rounded-md astw:px-3 astw:py-1.5 astw:text-xs astw:text-balance",t),...o,children:[e,M(f.Arrow,{className:"astw:bg-primary astw:fill-primary astw:z-50 astw:size-2.5 astw:translate-y-[calc(-50%_-_2px)] astw:rotate-45 astw:rounded-[2px]"})]})})}import{jsx as p,jsxs as B}from"react/jsx-runtime";var _a="sidebar_state",Ia=60*60*24*7,Aa="16rem",Ba="18rem",Ea="3rem",La="b",Rt=b.createContext(null);function E(){let t=b.useContext(Rt);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function Tt({defaultOpen:t=!0,open:a,onOpenChange:e,className:o,style:r,children:i,...c}){let s=ht(),[d,w]=b.useState(!1),[u,x]=b.useState(t),k=a??u,S=b.useCallback(v=>{let C=typeof v=="function"?v(k):v;e?e(C):x(C),document.cookie=`${_a}=${C}; path=/; max-age=${Ia}`},[e,k]),R=b.useCallback(()=>s?w(v=>!v):S(v=>!v),[s,S,w]);b.useEffect(()=>{let v=C=>{C.key===La&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),R())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[R]);let V=k?"expanded":"collapsed",$=b.useMemo(()=>({state:V,open:k,setOpen:S,isMobile:s,openMobile:d,setOpenMobile:w,toggleSidebar:R}),[V,k,S,s,d,w,R]);return p(Rt.Provider,{value:$,children:p(Q,{delayDuration:0,children:p("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Aa,"--sidebar-width-icon":Ea,...r},className:l("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",o),...c,children:i})})})}function Nt({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:o,children:r,...i}){let{isMobile:c,state:s,openMobile:d,setOpenMobile:w}=E();return e==="none"?p("div",{"data-slot":"sidebar",className:l("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",o),...i,children:r}):c?p(ft,{open:d,onOpenChange:w,...i,children:B(vt,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"astw:bg-sidebar astw:text-sidebar-foreground astw:w-(--sidebar-width) astw:p-0 astw:[&>button]:hidden",style:{"--sidebar-width":Ba},side:t,children:[B(xt,{className:"astw:sr-only",children:[p(yt,{children:"Sidebar"}),p(kt,{children:"Displays the mobile sidebar."})]}),p("div",{className:"flex h-full w-full flex-col",children:r})]})}):B("div",{className:"astw:group astw:peer astw:text-sidebar-foreground astw:hidden astw:md:block","data-state":s,"data-collapsible":s==="collapsed"?e:"","data-variant":a,"data-side":t,"data-slot":"sidebar",children:[p("div",{"data-slot":"sidebar-gap",className:l("astw:relative astw:w-(--sidebar-width) astw:bg-transparent astw:transition-[width] astw:duration-200 astw:ease-linear","astw:group-data-[collapsible=offcanvas]:w-0","astw:group-data-[side=right]:rotate-180",a==="floating"||a==="inset"?"astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),p("div",{"data-slot":"sidebar-container",className:l("astw:fixed astw:inset-y-0 astw:z-10 astw:hidden astw:h-svh astw:w-(--sidebar-width) astw:transition-[left,right,width] astw:duration-200 astw:ease-linear astw:md:flex",t==="left"?"astw:left-0 astw:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"astw:right-0 astw:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",a==="floating"||a==="inset"?"astw:p-2 astw:group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"astw:group-data-[collapsible=icon]:w-(--sidebar-width-icon) astw:group-data-[side=left]:border-r astw:group-data-[side=right]:border-l",a==="inset"&&"astw:border-x astw:border-x-border",o),...i,children:p("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"astw:bg-sidebar astw:group-data-[variant=floating]:border-sidebar-border astw:flex astw:h-full astw:w-full astw:flex-col astw:group-data-[variant=floating]:rounded-lg astw:group-data-[variant=floating]:border astw:group-data-[variant=floating]:shadow-sm",children:r})})]})}function Z({className:t,onClick:a,...e}){let{toggleSidebar:o}=E();return B(T,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:l("astw:text-muted-foreground",t),onClick:r=>{a?.(r),o()},...e,children:[p(Ma,{className:"astw:size-4.5"}),p("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function zt({className:t,...a}){return p("main",{"data-slot":"sidebar-inset",className:l("astw:bg-background astw:relative astw:flex astw:w-full astw:flex-1 astw:flex-col","astw:px-4 astw:md:peer-data-[variant=inset]:px-8 astw:md:peer-data-[variant=inset]:py-2",t),...a})}function Mt({className:t,...a}){return p("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:l("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function _t({className:t,...a}){return p("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:l("astw:flex astw:min-h-0 astw:flex-1 astw:flex-col astw:gap-2 astw:overflow-auto astw:group-data-[collapsible=icon]:overflow-hidden",t),...a})}function It({className:t,...a}){return p("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:l("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function At({className:t,...a}){return p("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:l("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function Bt({className:t,...a}){return p("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:l("astw:group/menu-item astw:relative",t),...a})}var Oa=za("astw:peer/menu-button astw:flex astw:w-full astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:p-2 astw:text-left astw:text-sm astw:outline-hidden astw:ring-sidebar-ring astw:transition-[width,height,padding] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:focus-visible:ring-2 astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:group-has-data-[sidebar=menu-action]/menu-item:pr-8 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:font-medium astw:data-[active=true]:text-sidebar-accent-foreground astw:data-[state=open]:hover:bg-sidebar-accent astw:data-[state=open]:hover:text-sidebar-accent-foreground astw:group-data-[collapsible=icon]:size-8! astw:group-data-[collapsible=icon]:p-2! astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0",{variants:{variant:{default:"astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground",outline:"astw:bg-background astw:shadow-[0_0_0_1px_hsl(var(--sidebar-border))] astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"astw:h-8 astw:text-sm",sm:"astw:h-7 astw:rounded-md astw:gap-1.5 astw:px-3 astw:has-[>svg]:px-2.5",lg:"astw:h-12 astw:text-sm astw:group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function tt({asChild:t=!1,isActive:a=!1,variant:e="default",size:o="default",tooltip:r,className:i,...c}){let s=t?J:"button",{isMobile:d,state:w}=E(),u=p(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":a,className:l(Oa({variant:e,size:o}),i),...c});return r?(typeof r=="string"&&(r={children:r}),B(Ct,{children:[p(Pt,{asChild:!0,children:u}),p(St,{side:"right",align:"center",hidden:w!=="collapsed"||d,...r})]})):u}function at({className:t,asChild:a=!1,showOnHover:e=!1,...o}){return p(a?J:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:l("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:peer-hover/menu-button:text-sidebar-accent-foreground astw:absolute astw:top-1.5 astw:right-1 astw:flex astw:aspect-square astw:w-5 astw:items-center astw:justify-center astw:rounded-md astw:p-0 astw:outline-hidden astw:transition-transform astw:focus-visible:ring-2 astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:after:absolute astw:after:-inset-2 astw:md:after:hidden","astw:peer-data-[size=sm]/menu-button:top-1","astw:peer-data-[size=default]/menu-button:top-1.5","astw:peer-data-[size=lg]/menu-button:top-2.5","astw:group-data-[collapsible=icon]:hidden",e&&"astw:peer-data-[active=true]/menu-button:text-sidebar-accent-foreground astw:group-focus-within/menu-item:opacity-100 astw:group-hover/menu-item:opacity-100 astw:data-[state=open]:opacity-100 astw:md:opacity-0",t),...o})}function Et({className:t,...a}){return p("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:l("astw:border-sidebar-border astw:mx-3.5 astw:flex astw:min-w-0 astw:translate-x-px astw:flex-col astw:gap-1 astw:border-l astw:px-2.5 astw:py-0.5","astw:group-data-[collapsible=icon]:hidden",t),...a})}function Lt({className:t,...a}){return p("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:l("astw:group/menu-sub-item astw:relative",t),...a})}function Ot({asChild:t=!1,size:a="md",isActive:e=!1,className:o,...r}){return p(t?J:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:l("astw:text-sidebar-foreground astw:ring-sidebar-ring astw:hover:bg-sidebar-accent astw:hover:text-sidebar-accent-foreground astw:active:bg-sidebar-accent astw:active:text-sidebar-accent-foreground astw:[&>svg]:text-sidebar-accent-foreground astw:flex astw:h-7 astw:min-w-0 astw:-translate-x-px astw:items-center astw:gap-2 astw:overflow-hidden astw:rounded-md astw:px-2 astw:outline-hidden astw:focus-visible:ring-2 astw:disabled:pointer-events-none astw:disabled:opacity-50 astw:aria-disabled:pointer-events-none astw:aria-disabled:opacity-50 astw:[&>span:last-child]:truncate astw:[&>svg]:size-4 astw:[&>svg]:shrink-0","astw:data-[active=true]:bg-sidebar-accent astw:data-[active=true]:text-sidebar-accent-foreground",a==="sm"&&"astw:text-xs",a==="md"&&"astw:text-sm","astw:group-data-[collapsible=icon]:hidden",o),...r})}import{ChevronRight as Ut,SunIcon as ja}from"lucide-react";import{Slot as Wa}from"@radix-ui/react-slot";import{ChevronRight as Ua,MoreHorizontal as Br}from"lucide-react";import{Link as Da,useHref as $a}from"react-router";import{jsx as Dt}from"react/jsx-runtime";function L({to:t,children:a,...e}){try{return $a(t),Dt(Da,{to:t,...e,children:a})}catch{return Dt("a",{href:t,...e,children:a})}}import{jsx as _,jsxs as Dr}from"react/jsx-runtime";function et({...t}){return _("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function rt({className:t,...a}){return _("ol",{"data-slot":"breadcrumb-list",className:l("astw:text-muted-foreground astw:flex astw:flex-wrap astw:items-center astw:gap-1.5 astw:text-sm astw:break-words astw:sm:gap-2.5",t),...a})}function ot({className:t,...a}){return _("li",{"data-slot":"breadcrumb-item",className:l("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function st({asChild:t,className:a,children:e,...o}){return _(t?Wa:L,{"data-slot":"breadcrumb-link",className:l("astw:hover:text-foreground astw:transition-colors",a),...o,children:e})}function $t({children:t,className:a,...e}){return _("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:l("astw:[&>svg]:size-3.5",a),...e,children:t??_(Ua,{})})}var Ha=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let o=(r,i)=>{!r||r.length===0||r.forEach(c=>{let s=`${i}/${c.path}`;a[s]={title:c.meta.title,breadcrumbTitle:c.meta.breadcrumbTitle},c.subResources&&c.subResources.length>0&&o(c.subResources,s)})};return e.resources&&e.resources.length>0&&o(e.resources,e.path),a},{});function Wt(t,a,e){let o=t.split("/").filter(s=>s!=="").slice(1),r=a?(()=>{let[s,...d]=o;return d})():o,i=Ha(e),c=r.map((s,d)=>{let w=r.slice(0,d+1).join("/"),u=i[w];if(!u){let k=Object.entries(i).find(([S])=>{let R=S.split("/").map($=>$.startsWith(":")?"[^/]+":$).join("/");return new RegExp(`^${R}$`).test(w)})?.[1];k&&(u=k)}let x;return u?typeof u.breadcrumbTitle=="function"?x=u.breadcrumbTitle(s):typeof u.breadcrumbTitle=="string"?x=u.breadcrumbTitle:x=u.title:x=decodeURIComponent(s),{segment:s,path:w,title:x}});return{basePath:a||null,segments:c}}import{Fragment as Ht,jsx as n,jsxs as m}from"react/jsx-runtime";var Ka=()=>{let{open:t}=E();return n("div",{className:t?"astw:md:hidden":void 0,children:n(Z,{className:"astw:-ml-2.5"})})},Fa=t=>{let a=t.children?t.children({Outlet:K}):null,e=F(),o=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return n(Tt,{className:"astw:flex astw:flex-col",children:m("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??n(jt,{}),m(zt,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[n("header",{className:"astw:flex astw:h-14 astw:shrink-0 astw:items-center astw:gap-2 astw:transition-[width,height] astw:ease-linear astw:group-has-data-[collapsible=icon]/sidebar-wrapper:h-12",children:m("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[m("div",{className:"astw:flex astw:items-center astw:gap-2",children:[n(Ka,{}),n(qa,{})]}),n("div",{className:"astw:flex astw:items-center astw:gap-2",children:n(T,{variant:"outline",size:"icon",onClick:o,children:n(ja,{})})})]})}),n("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??n(K,{})})]})]})})},jt=t=>{let{title:a,icon:e,navItems:o}=P(),{pathname:r}=Vt(),i=m(Mt,{children:[e,n("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return m(Nt,{variant:"inset",children:[m("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??i,n("div",{className:"astw:hidden astw:md:block",children:n(Z,{className:"astw:-ml-1"})})]}),n(_t,{children:n(It,{children:n(At,{children:o.map(s=>n(mt,{asChild:!0,defaultOpen:s.isActive,children:m(Bt,{children:[s.url?m(Ht,{children:[n(tt,{asChild:!0,tooltip:s.title,children:m(L,{to:s.url,className:s.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,n("span",{children:s.title})]})}),!!s.items?.length&&n(G,{asChild:!0,children:m(at,{className:"astw:data-[state=open]:rotate-90",children:[n(Ut,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]}):n(Ht,{children:m(G,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[n(tt,{asChild:!0,tooltip:s.title,children:m("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,n("span",{children:s.title})]})}),!!s.items?.length&&n(at,{className:"astw-rotate-target",asChild:!0,children:m("span",{children:[n(Ut,{}),n("span",{className:"astw:sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&n(bt,{children:n(Et,{children:s.items?.map(d=>n(Lt,{children:n(Ot,{asChild:!0,children:n(L,{to:d.url,className:d.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:n("span",{children:d.title})})})},d.title))})})]})},s.title))})})}),t.footer??null]})},Ga=()=>{let{configurations:t}=P(),a=Vt();return Wt(a.pathname,t.basePath,t.modules)},qa=()=>{let{basePath:t,segments:a}=Ga(),e=Va("/:prefix/settings/:suffix");return e?n(et,{children:n(rt,{children:n("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:n(ot,{children:n(st,{to:`/${e.params.prefix}/settings`,children:"Settings"})})})})}):n(et,{children:n(rt,{children:a.map((o,r)=>m("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[n(ot,{children:n(st,{to:`${t?`/${t}`:""}/${N}/${o.path}`,children:o.title})}),r<a.length-1&&n($t,{})]},r))})})};import{useEffect as Ya}from"react";import{capitalCase as Kt}from"change-case";import{useNavigate as Xa}from"react-router";import{jsx as Ft}from"react/jsx-runtime";function Qa(t){let{path:a,meta:e,component:o,defaultResourceRedirectPath:r,resources:i}=t,c=e?.title??Kt(a),s=o||function(){let w=Xa();return Ya(()=>{w(r)},[w]),null};return{path:a,type:"component",_type:"module",component:()=>Ft(W,{contentBorder:e?.contentBorder??!1,children:s({title:c,resources:i})}),meta:{title:c,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!r,icon:t.meta?.icon},resources:i}}function Ja(t){let{path:a,component:e,subResources:o,meta:r}=t,i=r?.title??Kt(a);return{_type:"resource",type:"component",path:a,meta:{title:i,icon:r?.icon,...r?.breadcrumbTitle!==void 0?{breadcrumbTitle:r.breadcrumbTitle}:{}},component:()=>Ft(W,{contentBorder:r?.contentBorder??!1,children:e({title:i,resources:o})}),subResources:o}}import{useLocation as Co,useNavigate as Po,useParams as So,useSearchParams as Ro,Link as To}from"react-router";import{createContext as te,useCallback as it,useContext as ae,useEffect as ee,useState as re}from"react";import*as I from"oauth4webapi";var O="oauth_pkce_verifier",D="oauth_state",Gt=({idpEndpoint:t,clientId:a,state:e,codeChallenge:o,redirectUri:r})=>{let i=new URL(`${t}/oauth2/authorize`);return i.searchParams.set("response_type","code"),i.searchParams.set("client_id",a),i.searchParams.set("redirect_uri",r||window.location.origin),i.searchParams.set("scope","openid profile email"),i.searchParams.set("state",e),i.searchParams.set("code_challenge",o),i.searchParams.set("code_challenge_method","S256"),i.toString()},Za=async({code:t,returnedState:a,idpEndpoint:e,clientId:o,redirectUri:r})=>{let i=sessionStorage.getItem(O),c=sessionStorage.getItem(D);if(!t||!a||!i||!c){let d=[];throw t||d.push("code"),a||d.push("returnedState"),i||d.push("code_verifier"),c||d.push("expectedState"),new Error(`Missing params: ${d.join(", ")}`)}if(a!==c)throw new Error("State mismatch: possible CSRF attack");let s=new URLSearchParams({grant_type:"authorization_code",client_id:o,code:t,redirect_uri:r||window.location.origin,code_verifier:i});try{let d=await fetch(`${e}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:s.toString()}),{access_token:w}=await d.json();return w}catch(d){throw new Error(`Token exchange failed: ${d instanceof Error?d.message:String(d)}`)}},qt=async()=>{let t=I.generateRandomCodeVerifier(),a=await I.calculatePKCECodeChallenge(t),e=I.generateRandomState();return sessionStorage.setItem(O,t),sessionStorage.setItem(D,e),{codeChallenge:a,state:e}},Yt=async({currentUrl:t,idpEndpoint:a,clientId:e,redirectUri:o})=>{try{let r=t.searchParams.get("code"),i=t.searchParams.get("state");await Za({idpEndpoint:a,clientId:e,code:r,returnedState:i,redirectUri:o})}catch(r){console.error(r)}finally{sessionStorage.removeItem(O),sessionStorage.removeItem(D),t.searchParams.delete("code"),t.searchParams.delete("state"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),window.history.replaceState({},document.title,t.toString())}};import{jsx as ie}from"react/jsx-runtime";var Xt=te(void 0),oe=()=>{let t=ae(Xt);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},se=({idpEndpoint:t,clientId:a,redirectUri:e,children:o})=>{let[r,i]=re(!0),c=it(async()=>{let{codeChallenge:w,state:u}=await qt(),x=Gt({idpEndpoint:t,clientId:a,codeChallenge:w,state:u,redirectUri:e});window.location.href=x},[t,a,e]),s=it(async()=>{sessionStorage.removeItem(O),sessionStorage.removeItem(D);try{await fetch(`${t}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Tailor-Nonce":crypto.randomUUID()},credentials:"include",body:""}),window.location.href="/"}catch(w){console.error(w)}},[t]),d=it(async w=>{i(!0),await Yt({currentUrl:w,idpEndpoint:t,clientId:a,redirectUri:e}),i(!1)},[t,a,e]);return ee(()=>{let w=new URL(window.location.href);w.searchParams.has("error")&&w.searchParams.has("error_description")?(console.error(w.searchParams.get("error_description")||"Authentication Error"),i(!1)):w.searchParams.has("code")&&w.searchParams.has("state")?d(w):i(!1)},[]),ie(Xt.Provider,{value:{isLoading:r,login:c,logout:s},children:o})};export{Ca as AppShell,se as BuiltinIdPAuthProvider,jt as DefaultSidebar,To as Link,Fa as SidebarLayoutContainer,Qa as defineModule,Ja as defineResource,P as useAppShell,oe as useBuiltinIdpAuth,Co as useLocation,Po as useNavigate,So as useParams,Ro as useSearchParams,F as useTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/app-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./styles": "./dist/index.css",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@hookform/resolvers": "^5.2.1",
|
|
24
24
|
"@radix-ui/react-checkbox": "^1.1.4",
|
|
25
25
|
"@radix-ui/react-collapsible": "^1.1.3",
|
|
26
|
-
"@radix-ui/react-dialog": "^1.1.
|
|
26
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
27
27
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
|
28
28
|
"@radix-ui/react-label": "^2.1.2",
|
|
29
29
|
"@radix-ui/react-navigation-menu": "^1.2.5",
|
|
@@ -38,20 +38,17 @@
|
|
|
38
38
|
"change-case": "^5.4.4",
|
|
39
39
|
"class-variance-authority": "^0.7.1",
|
|
40
40
|
"clsx": "^2.1.1",
|
|
41
|
-
"date-fns": "^4.1.0",
|
|
42
41
|
"es-toolkit": "^1.34.1",
|
|
43
42
|
"lucide-react": "^0.487.0",
|
|
44
43
|
"next-themes": "^0.4.6",
|
|
45
44
|
"oauth4webapi": "^3.8.1",
|
|
46
45
|
"react": "^19.1.1",
|
|
47
|
-
"react-day-picker": "8.10.1",
|
|
48
46
|
"react-dom": "^19.1.1",
|
|
49
47
|
"react-hook-form": "^7.54.2",
|
|
50
48
|
"react-router": "^7.4.0",
|
|
51
49
|
"sonner": "^2.0.7",
|
|
52
50
|
"tailwind-merge": "^3.0.1",
|
|
53
|
-
"urql": "^5.0.1"
|
|
54
|
-
"zod": "^3.24.2"
|
|
51
|
+
"urql": "^5.0.1"
|
|
55
52
|
},
|
|
56
53
|
"devDependencies": {
|
|
57
54
|
"@tailwindcss/postcss": "^4.1.2",
|
|
@@ -62,7 +59,7 @@
|
|
|
62
59
|
"jsdom": "^27.0.0",
|
|
63
60
|
"msw": "^2.11.2",
|
|
64
61
|
"postcss": "^8",
|
|
65
|
-
"prettier": "^3.
|
|
62
|
+
"prettier": "^3.6.2",
|
|
66
63
|
"tailwindcss": "^4.1.3",
|
|
67
64
|
"tsup": "^8.3.6",
|
|
68
65
|
"tw-animate-css": "^1.2.5",
|