@tailor-platform/app-shell 0.9.1 → 0.9.2

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, PropsWithChildren } from 'react';
3
3
  export { Link, useLocation, useNavigate, useParams, useSearchParams } from 'react-router';
4
4
 
5
5
  type CommonPageResource = {
@@ -217,4 +217,14 @@ type ThemeProviderState = {
217
217
  };
218
218
  declare const useTheme: () => ThemeProviderState;
219
219
 
220
- export { AppShell, type AppShellProps, DefaultSidebar, type ResourceComponentProps, SidebarLayoutContainer, defineModule, defineResource, useAppShell, useTheme };
220
+ type BuiltinIdPAuthContextType = {
221
+ login: () => Promise<void>;
222
+ };
223
+ declare const useBuiltinIdpAuth: () => BuiltinIdPAuthContextType;
224
+ type Props = {
225
+ idpEndpoint: string;
226
+ clientId: string;
227
+ } & PropsWithChildren;
228
+ declare const BuiltinIdPAuthProvider: ({ idpEndpoint, clientId, children }: Props) => react_jsx_runtime.JSX.Element;
229
+
230
+ export { AppShell, type AppShellProps, BuiltinIdPAuthProvider, DefaultSidebar, type ResourceComponentProps, SidebarLayoutContainer, defineModule, defineResource, useAppShell, useBuiltinIdpAuth, useTheme };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Table as aa}from"lucide-react";import{useEffect as ea,useMemo as ra,useState as oa}from"react";import{createContext as Wt,useContext as Ht}from"react";var W=Wt({navItems:[],configurations:{modules:[]}}),P=()=>Ht(W);import{createBrowserRouter as Kt,RouterProvider as Gt}from"react-router";import{Outlet as Vt}from"react-router";import{Toaster as jt}from"sonner";import{Fragment as Ft,jsx as M,jsxs as Z}from"react/jsx-runtime";var E=({contentBorder:t,children:a})=>M("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),J=()=>Z(E,{contentBorder:!0,children:[M("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),M("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),H=()=>Z(Ft,{children:[M(Vt,{}),M(jt,{})]});import{jsx as Ut}from"react/jsx-runtime";var tt=t=>{let a={index:!0,Component:t.component};return{path:t.path,...t.subResources&&t.subResources.length>0?{children:[a,...t.subResources.map(tt)]}:{children:[a]}}},at=t=>{let{configurations:a}=P(),e=a.modules.reduce((o,d)=>{let l={index:!0,Component:d.component};return[...o,{path:d.path,...d.resources&&d.resources.length>0?{children:[l,...d.resources.map(tt)]}:{children:[l]}}]},[]),r=Kt([{path:a.basePath,element:t.children,children:[{index:!0,Component:J},{path:R,children:e}]}]);return Ut(Gt,{router:r})};import{createContext as qt,useContext as Xt,useEffect as Qt,useMemo as Yt,useState as Jt}from"react";import{jsx as ta}from"react/jsx-runtime";var Zt={resolvedTheme:"light",theme:"system",setTheme:()=>null},et=qt(Zt);function rt({children:t,storageKey:a,defaultTheme:e="system",...r}){let[o,d]=Jt(()=>localStorage.getItem(a)||e),l=Yt(()=>o!=="system"?o:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[o]);Qt(()=>{let c=window.document.documentElement;c.classList.remove("light","dark"),c.classList.add(l)},[l]);let s={resolvedTheme:l,theme:o,setTheme:c=>{localStorage.setItem(a,c),d(c)}};return ta(et.Provider,{...r,value:s,children:t})}var V=()=>{let t=Xt(et);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as O}from"react/jsx-runtime";var R="resources",sa=t=>{let[a,e]=oa(!1);ea(function(){e(!0)},[]);let r=t.configurations.basePath,o=l=>r?`/${r}/${R}/${l}`:`/${R}/${l}`,d=ra(()=>t.configurations.modules.map(s=>{let c=s.resources.map(p=>({title:p.meta.title,url:o(`${s.path}/${p.path}`)}));return{title:s.meta.title,url:s.meta.menuItemClickable?o(s.path):void 0,clickable:s.component,icon:s.meta.icon||O(aa,{}),isActive:!0,items:c}}),[t.configurations.modules]);return a?O(W.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:r},navItems:d},children:O(rt,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:O(at,{children:t.children})})}):null};import*as T from"@radix-ui/react-collapsible";import{jsx as F}from"react/jsx-runtime";function ot({...t}){return F(T.Root,{"data-slot":"collapsible",...t})}function j({...t}){return F(T.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function st({...t}){return F(T.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Ot}from"react-router";import*as m from"react";import{Slot as q}from"@radix-ui/react-slot";import{cva as fa}from"class-variance-authority";import{PanelLeftIcon as ha}from"lucide-react";import*as L from"react";var K=768;function it(){let[t,a]=L.useState(void 0);return L.useEffect(()=>{let e=window.matchMedia(`(max-width: ${K-1}px)`),r=()=>{a(window.innerWidth<K)};return e.addEventListener("change",r),a(window.innerWidth<K),()=>e.removeEventListener("change",r)},[]),!!t}import{clsx as ia}from"clsx";import{twMerge as na}from"tailwind-merge";function n(...t){return na(ia(t))}import{Slot as da}from"@radix-ui/react-slot";import{cva as la}from"class-variance-authority";import{jsx as wa}from"react/jsx-runtime";var ca=la("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 D({className:t,variant:a,size:e,asChild:r=!1,...o}){return wa(r?da:"button",{"data-slot":"button",className:n(ca({variant:a,size:e,className:t})),...o})}import{jsx as Pe}from"react/jsx-runtime";import*as pa from"@radix-ui/react-separator";import{jsx as ze}from"react/jsx-runtime";import*as u from"@radix-ui/react-dialog";import{XIcon as ua}from"lucide-react";import{jsx as v,jsxs as G}from"react/jsx-runtime";function nt({...t}){return v(u.Root,{"data-slot":"sheet",...t})}function ga({...t}){return v(u.Portal,{"data-slot":"sheet-portal",...t})}function ma({className:t,...a}){return v(u.Overlay,{"data-slot":"sheet-overlay",className:n("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 dt({className:t,children:a,side:e="right",...r}){return G(ga,{children:[v(ma,{}),G(u.Content,{"data-slot":"sheet-content",className:n("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,G(u.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:[v(ua,{className:"astw:size-4"}),v("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function lt({className:t,...a}){return v("div",{"data-slot":"sheet-header",className:n("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function ct({className:t,...a}){return v(u.Title,{"data-slot":"sheet-title",className:n("astw:text-foreground astw:font-semibold",t),...a})}function wt({className:t,...a}){return v(u.Description,{"data-slot":"sheet-description",className:n("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Le}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as N,jsxs as ba}from"react/jsx-runtime";function U({delayDuration:t=0,...a}){return N(f.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function pt({...t}){return N(U,{children:N(f.Root,{"data-slot":"tooltip",...t})})}function ut({...t}){return N(f.Trigger,{"data-slot":"tooltip-trigger",...t})}function gt({className:t,sideOffset:a=0,children:e,...r}){return N(f.Portal,{children:ba(f.Content,{"data-slot":"tooltip-content",sideOffset:a,className:n("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,N(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 w,jsxs as _}from"react/jsx-runtime";var va="sidebar_state",xa=60*60*24*7,ya="16rem",ka="18rem",Ca="3rem",Sa="b",mt=m.createContext(null);function I(){let t=m.useContext(mt);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function bt({defaultOpen:t=!0,open:a,onOpenChange:e,className:r,style:o,children:d,...l}){let s=it(),[c,p]=m.useState(!1),[b,k]=m.useState(t),x=a??b,C=m.useCallback(h=>{let y=typeof h=="function"?h(x):h;e?e(y):k(y),document.cookie=`${va}=${y}; path=/; max-age=${xa}`},[e,x]),S=m.useCallback(()=>s?p(h=>!h):C(h=>!h),[s,C,p]);m.useEffect(()=>{let h=y=>{y.key===Sa&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),S())};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[S]);let $=x?"expanded":"collapsed",B=m.useMemo(()=>({state:$,open:x,setOpen:C,isMobile:s,openMobile:c,setOpenMobile:p,toggleSidebar:S}),[$,x,C,s,c,p,S]);return w(mt.Provider,{value:B,children:w(U,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":ya,"--sidebar-width-icon":Ca,...o},className:n("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",r),...l,children:d})})})}function ft({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:r,children:o,...d}){let{isMobile:l,state:s,openMobile:c,setOpenMobile:p}=I();return e==="none"?w("div",{"data-slot":"sidebar",className:n("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",r),...d,children:o}):l?w(nt,{open:c,onOpenChange:p,...d,children:_(dt,{"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":ka},side:t,children:[_(lt,{className:"sr-only",children:[w(ct,{children:"Sidebar"}),w(wt,{children:"Displays the mobile sidebar."})]}),w("div",{className:"flex h-full w-full flex-col",children:o})]})}):_("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:[w("div",{"data-slot":"sidebar-gap",className:n("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)")}),w("div",{"data-slot":"sidebar-container",className:n("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),...d,children:w("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 X({className:t,onClick:a,...e}){let{toggleSidebar:r}=I();return _(D,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:n("astw:text-muted-foreground",t),onClick:o=>{a?.(o),r()},...e,children:[w(ha,{className:"astw:size-4.5"}),w("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function ht({className:t,...a}){return w("main",{"data-slot":"sidebar-inset",className:n("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 vt({className:t,...a}){return w("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:n("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function xt({className:t,...a}){return w("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:n("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 yt({className:t,...a}){return w("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:n("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function kt({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:n("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function Ct({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:n("astw:group/menu-item astw:relative",t),...a})}var Pa=fa("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 Q({asChild:t=!1,isActive:a=!1,variant:e="default",size:r="default",tooltip:o,className:d,...l}){let s=t?q:"button",{isMobile:c,state:p}=I(),b=w(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":r,"data-active":a,className:n(Pa({variant:e,size:r}),d),...l});return o?(typeof o=="string"&&(o={children:o}),_(pt,{children:[w(ut,{asChild:!0,children:b}),w(gt,{side:"right",align:"center",hidden:p!=="collapsed"||c,...o})]})):b}function Y({className:t,asChild:a=!1,showOnHover:e=!1,...r}){return w(a?q:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:n("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 St({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:n("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 Pt({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:n("astw:group/menu-sub-item astw:relative",t),...a})}function Rt({asChild:t=!1,size:a="md",isActive:e=!1,className:r,...o}){return w(t?q:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:n("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 Bt,SunIcon as _a}from"lucide-react";import{Slot as Na}from"@radix-ui/react-slot";import{ChevronRight as za,MoreHorizontal as cr}from"lucide-react";import{Link as Ra,useHref as Ta}from"react-router";import{jsx as Tt}from"react/jsx-runtime";function A({to:t,children:a,...e}){try{return Ta(t),Tt(Ra,{to:t,...e,children:a})}catch{return Tt("a",{href:t,...e,children:a})}}import{jsx as z,jsxs as gr}from"react/jsx-runtime";function Nt({...t}){return z("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function zt({className:t,...a}){return z("ol",{"data-slot":"breadcrumb-list",className:n("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 Mt({className:t,...a}){return z("li",{"data-slot":"breadcrumb-item",className:n("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function _t({asChild:t,className:a,children:e,...r}){return z(t?Na:A,{"data-slot":"breadcrumb-link",className:n("astw:hover:text-foreground astw:transition-colors",a),...r,children:e})}function It({children:t,className:a,...e}){return z("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:n("astw:[&>svg]:size-3.5",a),...e,children:t??z(za,{})})}var Ma=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let r=(o,d)=>{!o||o.length===0||o.forEach(l=>{let s=`${d}/${l.path}`;a[s]={title:l.meta.title,breadcrumbTitle:l.meta.breadcrumbTitle},l.subResources&&l.subResources.length>0&&r(l.subResources,s)})};return e.resources&&e.resources.length>0&&r(e.resources,e.path),a},{});function At(t,a,e){let r=t.split("/").filter(s=>s!=="").slice(1),o=a?(()=>{let[s,...c]=r;return c})():r,d=Ma(e),l=o.map((s,c)=>{let p=o.slice(0,c+1).join("/"),b=d[p];if(!b){let x=Object.entries(d).find(([C])=>{let S=C.split("/").map(B=>B.startsWith(":")?"[^/]+":B).join("/");return new RegExp(`^${S}$`).test(p)})?.[1];x&&(b=x)}let k;return b?typeof b.breadcrumbTitle=="function"?k=b.breadcrumbTitle(s):typeof b.breadcrumbTitle=="string"?k=b.breadcrumbTitle:k=b.title:k=decodeURIComponent(s),{segment:s,path:p,title:k}});return{basePath:a||null,segments:l}}import{Fragment as Et,jsx as i,jsxs as g}from"react/jsx-runtime";var Ia=()=>{let{open:t}=I();return i("div",{className:t?"astw:md:hidden":void 0,children:i(X,{className:"astw:-ml-2.5"})})},Aa=t=>{let a=t.children?t.children({Outlet:H}):null,e=V(),r=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return i(bt,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??i(Lt,{}),g(ht,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[i("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:g("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[g("div",{className:"astw:flex astw:items-center astw:gap-2",children:[i(Ia,{}),i(Ea,{})]}),i("div",{className:"astw:flex astw:items-center astw:gap-2",children:i(D,{variant:"outline",size:"icon",onClick:r,children:i(_a,{})})})]})}),i("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??i(H,{})})]})]})})},Lt=t=>{let{title:a,icon:e,navItems:r}=P(),{pathname:o}=Ot(),d=g(vt,{children:[e,i("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(ft,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??d,i("div",{className:"astw:hidden astw:md:block",children:i(X,{className:"astw:-ml-1"})})]}),i(xt,{children:i(yt,{children:i(kt,{children:r.map(s=>i(ot,{asChild:!0,defaultOpen:s.isActive,children:g(Ct,{children:[s.url?g(Et,{children:[i(Q,{asChild:!0,tooltip:s.title,children:g(A,{to:s.url,className:s.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,i("span",{children:s.title})]})}),!!s.items?.length&&i(j,{asChild:!0,children:g(Y,{className:"astw:data-[state=open]:rotate-90",children:[i(Bt,{}),i("span",{className:"sr-only",children:"Toggle"})]})})]}):i(Et,{children:g(j,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[i(Q,{asChild:!0,tooltip:s.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,i("span",{children:s.title})]})}),!!s.items?.length&&i(Y,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[i(Bt,{}),i("span",{className:"sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&i(st,{children:i(St,{children:s.items?.map(c=>i(Pt,{children:i(Rt,{asChild:!0,children:i(A,{to:c.url,className:c.url===o?"astw:bg-sidebar-accent astw:font-medium":void 0,children:i("span",{children:c.title})})})},c.title))})})]})},s.title))})})}),t.footer??null]})},Ba=()=>{let{configurations:t}=P(),a=Ot();return At(a.pathname,t.basePath,t.modules)},Ea=()=>{let{basePath:t,segments:a}=Ba();return i(Nt,{children:i(zt,{children:a.map((e,r)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[i(Mt,{children:i(_t,{to:`${t?`/${t}`:""}/${R}/${e.path}`,children:e.title})}),r<a.length-1&&i(It,{})]},r))})})};import{useEffect as Oa}from"react";import{capitalCase as Dt}from"change-case";import{useNavigate as La}from"react-router";import{jsx as $t}from"react/jsx-runtime";function Da(t){let{path:a,meta:e,component:r,defaultResourceRedirectPath:o}=t,d=e?.title??Dt(a),l=r||function(){let c=La();return Oa(()=>{c(o)},[c]),null};return{path:a,type:"component",_type:"module",component:()=>$t(E,{contentBorder:e?.contentBorder??!1,children:l({title:d})}),meta:{title:d,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!o,icon:t.meta?.icon},resources:t.resources}}function $a(t){let{path:a,component:e,subResources:r,meta:o}=t,d=o?.title??Dt(a);return{_type:"resource",type:"component",path:a,meta:{title:d,...o?.breadcrumbTitle!==void 0?{breadcrumbTitle:o.breadcrumbTitle}:{}},component:()=>$t(E,{contentBorder:o?.contentBorder??!1,children:e({title:d})}),subResources:r}}import{useLocation as Gr,useNavigate as Ur,useParams as qr,useSearchParams as Xr,Link as Qr}from"react-router";export{sa as AppShell,Lt as DefaultSidebar,Qr as Link,Aa as SidebarLayoutContainer,Da as defineModule,$a as defineResource,P as useAppShell,Gr as useLocation,Ur as useNavigate,qr as useParams,Xr as useSearchParams,V as useTheme};
1
+ import{Table as da}from"lucide-react";import{useEffect as la,useMemo as ca,useState as wa}from"react";import{createContext as Gt,useContext as qt}from"react";var H=Gt({navItems:[],configurations:{modules:[]}}),S=()=>qt(H);import{createBrowserRouter as Jt,RouterProvider as Zt}from"react-router";import{Outlet as Xt}from"react-router";import{Toaster as Yt}from"sonner";import{Fragment as Qt,jsx as _,jsxs as et}from"react/jsx-runtime";var L=({contentBorder:t,children:a})=>_("div",{className:t?"astw:p-4 astw:rounded-sm astw:border astw:shadow-xs":"",children:a}),at=()=>et(L,{contentBorder:!0,children:[_("p",{className:"astw:font-semibold astw:leading-none astw:tracking-tight",children:"Welcome to AppShell"}),_("p",{className:"pt-4",children:"Add your GraphQL resources from configuration at first!"})]}),V=()=>et(Qt,{children:[_(Xt,{}),_(Yt,{})]});import{jsx as ta}from"react/jsx-runtime";var rt=t=>{let a={index:!0,Component:t.component};return{path:t.path,...t.subResources&&t.subResources.length>0?{children:[a,...t.subResources.map(rt)]}:{children:[a]}}},ot=t=>{let{configurations:a}=S(),e=a.modules.reduce((r,n)=>{let l={index:!0,Component:n.component};return[...r,{path:n.path,...n.resources&&n.resources.length>0?{children:[l,...n.resources.map(rt)]}:{children:[l]}}]},[]),o=Jt([{path:a.basePath,element:t.children,children:[{index:!0,Component:at},{path:R,children:e}]}]);return ta(Zt,{router:o})};import{createContext as aa,useContext as ea,useEffect as ra,useMemo as oa,useState as sa}from"react";import{jsx as na}from"react/jsx-runtime";var ia={resolvedTheme:"light",theme:"system",setTheme:()=>null},st=aa(ia);function it({children:t,storageKey:a,defaultTheme:e="system",...o}){let[r,n]=sa(()=>localStorage.getItem(a)||e),l=oa(()=>r!=="system"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[r]);ra(()=>{let c=window.document.documentElement;c.classList.remove("light","dark"),c.classList.add(l)},[l]);let s={resolvedTheme:l,theme:r,setTheme:c=>{localStorage.setItem(a,c),n(c)}};return na(st.Provider,{...o,value:s,children:t})}var F=()=>{let t=ea(st);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};import{jsx as O}from"react/jsx-runtime";var R="resources",pa=t=>{let[a,e]=wa(!1);la(function(){e(!0)},[]);let o=t.configurations.basePath,r=l=>o?`/${o}/${R}/${l}`:`/${R}/${l}`,n=ca(()=>t.configurations.modules.map(s=>{let c=s.resources.map(p=>({title:p.meta.title,url:r(`${s.path}/${p.path}`)}));return{title:s.meta.title,url:s.meta.menuItemClickable?r(s.path):void 0,clickable:s.component,icon:s.meta.icon||O(da,{}),isActive:!0,items:c}}),[t.configurations.modules]);return a?O(H.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:o},navItems:n},children:O(it,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:O(ot,{children:t.children})})}):null};import*as T from"@radix-ui/react-collapsible";import{jsx as j}from"react/jsx-runtime";function nt({...t}){return j(T.Root,{"data-slot":"collapsible",...t})}function U({...t}){return j(T.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function dt({...t}){return j(T.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as $t}from"react-router";import*as m from"react";import{Slot as X}from"@radix-ui/react-slot";import{cva as Ca}from"class-variance-authority";import{PanelLeftIcon as Sa}from"lucide-react";import*as D from"react";var K=768;function lt(){let[t,a]=D.useState(void 0);return D.useEffect(()=>{let e=window.matchMedia(`(max-width: ${K-1}px)`),o=()=>{a(window.innerWidth<K)};return e.addEventListener("change",o),a(window.innerWidth<K),()=>e.removeEventListener("change",o)},[]),!!t}import{clsx as ua}from"clsx";import{twMerge as ga}from"tailwind-merge";function d(...t){return ga(ua(t))}import{Slot as ma}from"@radix-ui/react-slot";import{cva as ba}from"class-variance-authority";import{jsx as fa}from"react/jsx-runtime";var ha=ba("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 $({className:t,variant:a,size:e,asChild:o=!1,...r}){return fa(o?ma:"button",{"data-slot":"button",className:d(ha({variant:a,size:e,className:t})),...r})}import{jsx as We}from"react/jsx-runtime";import*as va from"@radix-ui/react-separator";import{jsx as Ue}from"react/jsx-runtime";import*as u from"@radix-ui/react-dialog";import{XIcon as xa}from"lucide-react";import{jsx as v,jsxs as G}from"react/jsx-runtime";function ct({...t}){return v(u.Root,{"data-slot":"sheet",...t})}function ya({...t}){return v(u.Portal,{"data-slot":"sheet-portal",...t})}function ka({className:t,...a}){return v(u.Overlay,{"data-slot":"sheet-overlay",className:d("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 wt({className:t,children:a,side:e="right",...o}){return G(ya,{children:[v(ka,{}),G(u.Content,{"data-slot":"sheet-content",className:d("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,G(u.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:[v(xa,{className:"astw:size-4"}),v("span",{className:"astw:sr-only",children:"Close"})]})]})]})}function pt({className:t,...a}){return v("div",{"data-slot":"sheet-header",className:d("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function ut({className:t,...a}){return v(u.Title,{"data-slot":"sheet-title",className:d("astw:text-foreground astw:font-semibold",t),...a})}function gt({className:t,...a}){return v(u.Description,{"data-slot":"sheet-description",className:d("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Je}from"react/jsx-runtime";import*as h from"@radix-ui/react-tooltip";import{jsx as z,jsxs as Pa}from"react/jsx-runtime";function q({delayDuration:t=0,...a}){return z(h.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...a})}function mt({...t}){return z(q,{children:z(h.Root,{"data-slot":"tooltip",...t})})}function bt({...t}){return z(h.Trigger,{"data-slot":"tooltip-trigger",...t})}function ht({className:t,sideOffset:a=0,children:e,...o}){return z(h.Portal,{children:Pa(h.Content,{"data-slot":"tooltip-content",sideOffset:a,className:d("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,z(h.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 w,jsxs as I}from"react/jsx-runtime";var Ra="sidebar_state",Ta=60*60*24*7,za="16rem",Na="18rem",Ma="3rem",_a="b",ft=m.createContext(null);function A(){let t=m.useContext(ft);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function vt({defaultOpen:t=!0,open:a,onOpenChange:e,className:o,style:r,children:n,...l}){let s=lt(),[c,p]=m.useState(!1),[b,k]=m.useState(t),x=a??b,P=m.useCallback(f=>{let y=typeof f=="function"?f(x):f;e?e(y):k(y),document.cookie=`${Ra}=${y}; path=/; max-age=${Ta}`},[e,x]),C=m.useCallback(()=>s?p(f=>!f):P(f=>!f),[s,P,p]);m.useEffect(()=>{let f=y=>{y.key===_a&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),C())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[C]);let W=x?"expanded":"collapsed",E=m.useMemo(()=>({state:W,open:x,setOpen:P,isMobile:s,openMobile:c,setOpenMobile:p,toggleSidebar:C}),[W,x,P,s,c,p,C]);return w(ft.Provider,{value:E,children:w(q,{delayDuration:0,children:w("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":za,"--sidebar-width-icon":Ma,...r},className:d("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",o),...l,children:n})})})}function xt({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:o,children:r,...n}){let{isMobile:l,state:s,openMobile:c,setOpenMobile:p}=A();return e==="none"?w("div",{"data-slot":"sidebar",className:d("astw:bg-sidebar astw:text-sidebar-foreground astw:flex astw:h-full astw:w-(--sidebar-width) astw:flex-col",o),...n,children:r}):l?w(ct,{open:c,onOpenChange:p,...n,children:I(wt,{"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":Na},side:t,children:[I(pt,{className:"sr-only",children:[w(ut,{children:"Sidebar"}),w(gt,{children:"Displays the mobile sidebar."})]}),w("div",{className:"flex h-full w-full flex-col",children:r})]})}):I("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:[w("div",{"data-slot":"sidebar-gap",className:d("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)")}),w("div",{"data-slot":"sidebar-container",className:d("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),...n,children:w("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 Y({className:t,onClick:a,...e}){let{toggleSidebar:o}=A();return I($,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon",className:d("astw:text-muted-foreground",t),onClick:r=>{a?.(r),o()},...e,children:[w(Sa,{className:"astw:size-4.5"}),w("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function yt({className:t,...a}){return w("main",{"data-slot":"sidebar-inset",className:d("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 kt({className:t,...a}){return w("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:d("astw:flex astw:flex-row astw:items-center astw:gap-0.5 astw:p-2",t),...a})}function Pt({className:t,...a}){return w("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:d("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 Ct({className:t,...a}){return w("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:d("astw:relative astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:p-2",t),...a})}function St({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:d("astw:flex astw:w-full astw:min-w-0 astw:flex-col astw:gap-1",t),...a})}function Rt({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:d("astw:group/menu-item astw:relative",t),...a})}var Ia=Ca("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 Q({asChild:t=!1,isActive:a=!1,variant:e="default",size:o="default",tooltip:r,className:n,...l}){let s=t?X:"button",{isMobile:c,state:p}=A(),b=w(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":a,className:d(Ia({variant:e,size:o}),n),...l});return r?(typeof r=="string"&&(r={children:r}),I(mt,{children:[w(bt,{asChild:!0,children:b}),w(ht,{side:"right",align:"center",hidden:p!=="collapsed"||c,...r})]})):b}function J({className:t,asChild:a=!1,showOnHover:e=!1,...o}){return w(a?X:"button",{"data-slot":"sidebar-menu-action","data-sidebar":"menu-action",className:d("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 Tt({className:t,...a}){return w("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:d("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 zt({className:t,...a}){return w("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:d("astw:group/menu-sub-item astw:relative",t),...a})}function Nt({asChild:t=!1,size:a="md",isActive:e=!1,className:o,...r}){return w(t?X:"a",{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":a,"data-active":e,className:d("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 Ot,SunIcon as Da}from"lucide-react";import{Slot as Ea}from"@radix-ui/react-slot";import{ChevronRight as La,MoreHorizontal as Sr}from"lucide-react";import{Link as Aa,useHref as Ba}from"react-router";import{jsx as Mt}from"react/jsx-runtime";function B({to:t,children:a,...e}){try{return Ba(t),Mt(Aa,{to:t,...e,children:a})}catch{return Mt("a",{href:t,...e,children:a})}}import{jsx as N,jsxs as Nr}from"react/jsx-runtime";function _t({...t}){return N("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...t})}function It({className:t,...a}){return N("ol",{"data-slot":"breadcrumb-list",className:d("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 At({className:t,...a}){return N("li",{"data-slot":"breadcrumb-item",className:d("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function Bt({asChild:t,className:a,children:e,...o}){return N(t?Ea:B,{"data-slot":"breadcrumb-link",className:d("astw:hover:text-foreground astw:transition-colors",a),...o,children:e})}function Et({children:t,className:a,...e}){return N("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:d("astw:[&>svg]:size-3.5",a),...e,children:t??N(La,{})})}var Oa=t=>t.reduce((a,e)=>{a[e.path]={title:e.meta.title,breadcrumbTitle:e.meta.breadcrumbTitle};let o=(r,n)=>{!r||r.length===0||r.forEach(l=>{let s=`${n}/${l.path}`;a[s]={title:l.meta.title,breadcrumbTitle:l.meta.breadcrumbTitle},l.subResources&&l.subResources.length>0&&o(l.subResources,s)})};return e.resources&&e.resources.length>0&&o(e.resources,e.path),a},{});function Lt(t,a,e){let o=t.split("/").filter(s=>s!=="").slice(1),r=a?(()=>{let[s,...c]=o;return c})():o,n=Oa(e),l=r.map((s,c)=>{let p=r.slice(0,c+1).join("/"),b=n[p];if(!b){let x=Object.entries(n).find(([P])=>{let C=P.split("/").map(E=>E.startsWith(":")?"[^/]+":E).join("/");return new RegExp(`^${C}$`).test(p)})?.[1];x&&(b=x)}let k;return b?typeof b.breadcrumbTitle=="function"?k=b.breadcrumbTitle(s):typeof b.breadcrumbTitle=="string"?k=b.breadcrumbTitle:k=b.title:k=decodeURIComponent(s),{segment:s,path:p,title:k}});return{basePath:a||null,segments:l}}import{Fragment as Dt,jsx as i,jsxs as g}from"react/jsx-runtime";var $a=()=>{let{open:t}=A();return i("div",{className:t?"astw:md:hidden":void 0,children:i(Y,{className:"astw:-ml-2.5"})})},Wa=t=>{let a=t.children?t.children({Outlet:V}):null,e=F(),o=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return i(vt,{className:"astw:flex astw:flex-col",children:g("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??i(Wt,{}),g(yt,{className:"astw:w-[calc(100%-var(--sidebar-width))]",children:[i("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:g("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[g("div",{className:"astw:flex astw:items-center astw:gap-2",children:[i($a,{}),i(Va,{})]}),i("div",{className:"astw:flex astw:items-center astw:gap-2",children:i($,{variant:"outline",size:"icon",onClick:o,children:i(Da,{})})})]})}),i("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??i(V,{})})]})]})})},Wt=t=>{let{title:a,icon:e,navItems:o}=S(),{pathname:r}=$t(),n=g(kt,{children:[e,i("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return g(xt,{variant:"inset",children:[g("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??n,i("div",{className:"astw:hidden astw:md:block",children:i(Y,{className:"astw:-ml-1"})})]}),i(Pt,{children:i(Ct,{children:i(St,{children:o.map(s=>i(nt,{asChild:!0,defaultOpen:s.isActive,children:g(Rt,{children:[s.url?g(Dt,{children:[i(Q,{asChild:!0,tooltip:s.title,children:g(B,{to:s.url,className:s.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:[s.icon,i("span",{children:s.title})]})}),!!s.items?.length&&i(U,{asChild:!0,children:g(J,{className:"astw:data-[state=open]:rotate-90",children:[i(Ot,{}),i("span",{className:"sr-only",children:"Toggle"})]})})]}):i(Dt,{children:g(U,{className:"astw:flex astw:w-[100%] astw:[&[data-state=open]_.astw-rotate-target]:rotate-90",children:[i(Q,{asChild:!0,tooltip:s.title,children:g("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,i("span",{children:s.title})]})}),!!s.items?.length&&i(J,{className:"astw-rotate-target",asChild:!0,children:g("span",{children:[i(Ot,{}),i("span",{className:"sr-only",children:"Toggle"})]})})]})}),!!s.items?.length&&i(dt,{children:i(Tt,{children:s.items?.map(c=>i(zt,{children:i(Nt,{asChild:!0,children:i(B,{to:c.url,className:c.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:i("span",{children:c.title})})})},c.title))})})]})},s.title))})})}),t.footer??null]})},Ha=()=>{let{configurations:t}=S(),a=$t();return Lt(a.pathname,t.basePath,t.modules)},Va=()=>{let{basePath:t,segments:a}=Ha();return i(_t,{children:i(It,{children:a.map((e,o)=>g("div",{className:"astw:inline-flex astw:items-center astw:gap-3 astw:last:text-foreground",children:[i(At,{children:i(Bt,{to:`${t?`/${t}`:""}/${R}/${e.path}`,children:e.title})}),o<a.length-1&&i(Et,{})]},o))})})};import{useEffect as Fa}from"react";import{capitalCase as Ht}from"change-case";import{useNavigate as Ua}from"react-router";import{jsx as Vt}from"react/jsx-runtime";function ja(t){let{path:a,meta:e,component:o,defaultResourceRedirectPath:r}=t,n=e?.title??Ht(a),l=o||function(){let c=Ua();return Fa(()=>{c(r)},[c]),null};return{path:a,type:"component",_type:"module",component:()=>Vt(L,{contentBorder:e?.contentBorder??!1,children:l({title:n})}),meta:{title:n,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!r,icon:t.meta?.icon},resources:t.resources}}function Ka(t){let{path:a,component:e,subResources:o,meta:r}=t,n=r?.title??Ht(a);return{_type:"resource",type:"component",path:a,meta:{title:n,...r?.breadcrumbTitle!==void 0?{breadcrumbTitle:r.breadcrumbTitle}:{}},component:()=>Vt(L,{contentBorder:r?.contentBorder??!1,children:e({title:n})}),subResources:o}}import{useLocation as go,useNavigate as mo,useParams as bo,useSearchParams as ho,Link as fo}from"react-router";import{createContext as qa,useCallback as Xa,useContext as Ya,useEffect as Qa}from"react";import*as M from"oauth4webapi";var Z="oauth_pkce_verifier",tt="oauth_state",Ft=({idpEndpoint:t,clientId:a,state:e,codeChallenge:o})=>{let r=new URL(`${t}/oauth2/authorize`);return r.searchParams.set("response_type","code"),r.searchParams.set("client_id",a),r.searchParams.set("redirect_uri","http://localhost:3000"),r.searchParams.set("scope","openid profile email"),r.searchParams.set("state",e),r.searchParams.set("code_challenge",o),r.searchParams.set("code_challenge_method","S256"),r.toString()},Ga=async({code:t,returnedState:a,idpEndpoint:e,clientId:o})=>{let r=sessionStorage.getItem(Z),n=sessionStorage.getItem(tt);if(!t||!a||!r||!n){let s=[];throw t||s.push("code"),a||s.push("returnedState"),r||s.push("code_verifier"),n||s.push("expectedState"),new Error(`Missing params: ${s.join(", ")}`)}if(a!==n)throw new Error("State mismatch: possible CSRF attack");let l=new URLSearchParams({grant_type:"authorization_code",client_id:o,code:t,redirect_uri:"http://localhost:3000",code_verifier:r});try{let s=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:l.toString()}),{access_token:c}=await s.json();return c}catch(s){throw new Error(`Token exchange failed: ${s instanceof Error?s.message:String(s)}`)}},Ut=async()=>{let t=M.generateRandomCodeVerifier(),a=await M.calculatePKCECodeChallenge(t),e=M.generateRandomState();return sessionStorage.setItem(Z,t),sessionStorage.setItem(tt,e),{codeChallenge:a,state:e}},jt=async({currentUrl:t,idpEndpoint:a,clientId:e})=>{try{let o=t.searchParams.get("code"),r=t.searchParams.get("state");await Ga({idpEndpoint:a,clientId:e,code:o,returnedState:r})}catch(o){console.error(o)}finally{sessionStorage.removeItem(Z),sessionStorage.removeItem(tt),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 te}from"react/jsx-runtime";var Kt=qa(void 0),Ja=()=>{let t=Ya(Kt);if(t===void 0)throw new Error("useBuiltinIdpAuth must be used within an BuiltinIdPAuthContextProvider");return t},Za=({idpEndpoint:t,clientId:a,children:e})=>{let o=Xa(async()=>{let{codeChallenge:r,state:n}=await Ut(),l=Ft({idpEndpoint:t,clientId:a,codeChallenge:r,state:n});window.location.href=l},[t,a]);return Qa(()=>{let r=new URL(window.location.href);if(r.searchParams.has("error")&&r.searchParams.has("error_description"))throw new Error(r.searchParams.get("error_description")||"Authentication Error");r.searchParams.has("code")&&r.searchParams.has("state")&&jt({currentUrl:r,idpEndpoint:t,clientId:a})},[t,a]),te(Kt.Provider,{value:{login:o},children:e})};export{pa as AppShell,Za as BuiltinIdPAuthProvider,Wt as DefaultSidebar,fo as Link,Wa as SidebarLayoutContainer,ja as defineModule,Ka as defineResource,S as useAppShell,Ja as useBuiltinIdpAuth,go as useLocation,mo as useNavigate,bo as useParams,ho 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.9.1",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./styles": "./dist/index.css",
@@ -19,8 +19,8 @@
19
19
  "react-dom": ">= 19"
20
20
  },
21
21
  "dependencies": {
22
- "@badgateway/oauth2-client": "^2.4.2",
23
- "@hookform/resolvers": "^4.1.1",
22
+ "@badgateway/oauth2-client": "^3.3.0",
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
26
  "@radix-ui/react-dialog": "^1.1.6",
@@ -41,12 +41,13 @@
41
41
  "es-toolkit": "^1.34.1",
42
42
  "lucide-react": "^0.487.0",
43
43
  "next-themes": "^0.4.6",
44
- "react": "^19.1.0",
44
+ "oauth4webapi": "^3.8.1",
45
+ "react": "^19.1.1",
45
46
  "react-day-picker": "8.10.1",
46
- "react-dom": "^19.1.0",
47
+ "react-dom": "^19.1.1",
47
48
  "react-hook-form": "^7.54.2",
48
49
  "react-router": "^7.4.0",
49
- "sonner": "^1.7.4",
50
+ "sonner": "^2.0.7",
50
51
  "tailwind-merge": "^3.0.1",
51
52
  "zod": "^3.24.2"
52
53
  },