@tailor-platform/app-shell 0.9.0 → 0.9.1

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
@@ -174,7 +174,7 @@ type AppShellProps = {
174
174
  modules: Modules;
175
175
  };
176
176
  };
177
- declare const AppShell: (props: React.PropsWithChildren<AppShellProps>) => react_jsx_runtime.JSX.Element;
177
+ declare const AppShell: (props: React.PropsWithChildren<AppShellProps>) => react_jsx_runtime.JSX.Element | null;
178
178
 
179
179
  type SidebarLayoutContainerProps = {
180
180
  children?: (props: {
@@ -212,6 +212,7 @@ declare const useAppShell: () => AppShellContextType;
212
212
  type Theme = "dark" | "light" | "system";
213
213
  type ThemeProviderState = {
214
214
  theme: Theme;
215
+ resolvedTheme: Omit<Theme, "system">;
215
216
  setTheme: (theme: Theme) => void;
216
217
  };
217
218
  declare const useTheme: () => ThemeProviderState;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Table as ta}from"lucide-react";import{useMemo as aa}from"react";import{createContext as Wt,useContext as Ht}from"react";var W=Wt({navItems:[],configurations:{modules:[]}}),S=()=>Ht(W);import{createBrowserRouter as Ft,RouterProvider as Gt}from"react-router";import{Outlet as Vt}from"react-router";import{Toaster as jt}from"sonner";import{Fragment as Kt,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(Kt,{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}=S(),e=a.modules.reduce((r,n)=>{let c={index:!0,Component:n.component};return[...r,{path:n.path,...n.resources&&n.resources.length>0?{children:[c,...n.resources.map(tt)]}:{children:[c]}}]},[]),o=Ft([{path:a.basePath,element:t.children,children:[{index:!0,Component:J},{path:R,children:e}]}]);return Ut(Gt,{router:o})};import{createContext as qt,useContext as Xt,useEffect as Qt,useState as Yt}from"react";import{jsx as Zt}from"react/jsx-runtime";var Jt={theme:"system",setTheme:()=>null},et=qt(Jt);function rt({children:t,storageKey:a,defaultTheme:e="system",...o}){let[r,n]=Yt(()=>localStorage.getItem(a)||e);Qt(()=>{let s=window.document.documentElement;if(s.classList.remove("light","dark"),r==="system"){let w=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";s.classList.add(w);return}s.classList.add(r)},[r]);let c={theme:r,setTheme:s=>{localStorage.setItem(a,s),n(s)}};return Zt(et.Provider,{...o,value:c,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 L}from"react/jsx-runtime";var R="resources",ea=t=>{let a=t.configurations.basePath,e=r=>a?`/${a}/${R}/${r}`:`/${R}/${r}`,o=aa(()=>t.configurations.modules.map(n=>{let c=n.resources.map(s=>({title:s.meta.title,url:e(`${n.path}/${s.path}`)}));return{title:n.meta.title,url:n.meta.menuItemClickable?e(n.path):void 0,clickable:n.component,icon:n.meta.icon||L(ta,{}),isActive:!0,items:c}}),[t.configurations.modules]);return L(W.Provider,{value:{title:t.title,icon:t.icon,configurations:{...t.configurations,basePath:a},navItems:o},children:L(rt,{defaultTheme:"system",storageKey:"appshell-ui-theme",children:L(at,{children:t.children})})})};import*as T from"@radix-ui/react-collapsible";import{jsx as K}from"react/jsx-runtime";function ot({...t}){return K(T.Root,{"data-slot":"collapsible",...t})}function j({...t}){return K(T.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function st({...t}){return K(T.CollapsibleContent,{"data-slot":"collapsible-content",...t})}import{useLocation as Lt}from"react-router";import*as g from"react";import{Slot as q}from"@radix-ui/react-slot";import{cva as ga}from"class-variance-authority";import{PanelLeftIcon as ba}from"lucide-react";import*as O from"react";var F=768;function it(){let[t,a]=O.useState(void 0);return O.useEffect(()=>{let e=window.matchMedia(`(max-width: ${F-1}px)`),o=()=>{a(window.innerWidth<F)};return e.addEventListener("change",o),a(window.innerWidth<F),()=>e.removeEventListener("change",o)},[]),!!t}import{clsx as ra}from"clsx";import{twMerge as oa}from"tailwind-merge";function d(...t){return oa(ra(t))}import{Slot as sa}from"@radix-ui/react-slot";import{cva as ia}from"class-variance-authority";import{jsx as da}from"react/jsx-runtime";var na=ia("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:o=!1,...r}){return da(o?sa:"button",{"data-slot":"button",className:d(na({variant:a,size:e,className:t})),...r})}import{jsx as ke}from"react/jsx-runtime";import*as la from"@radix-ui/react-separator";import{jsx as Re}from"react/jsx-runtime";import*as p from"@radix-ui/react-dialog";import{XIcon as ca}from"lucide-react";import{jsx as v,jsxs as G}from"react/jsx-runtime";function nt({...t}){return v(p.Root,{"data-slot":"sheet",...t})}function wa({...t}){return v(p.Portal,{"data-slot":"sheet-portal",...t})}function pa({className:t,...a}){return v(p.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 dt({className:t,children:a,side:e="right",...o}){return G(wa,{children:[v(pa,{}),G(p.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(p.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(ca,{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:d("astw:flex astw:flex-col astw:gap-1.5 astw:p-4",t),...a})}function ct({className:t,...a}){return v(p.Title,{"data-slot":"sheet-title",className:d("astw:text-foreground astw:font-semibold",t),...a})}function wt({className:t,...a}){return v(p.Description,{"data-slot":"sheet-description",className:d("astw:text-muted-foreground astw:text-sm",t),...a})}import{jsx as Be}from"react/jsx-runtime";import*as f from"@radix-ui/react-tooltip";import{jsx as N,jsxs as ua}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,...o}){return N(f.Portal,{children:ua(f.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,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 l,jsxs as _}from"react/jsx-runtime";var ma="sidebar_state",fa=60*60*24*7,ha="16rem",va="18rem",xa="3rem",ya="b",bt=g.createContext(null);function I(){let t=g.useContext(bt);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function mt({defaultOpen:t=!0,open:a,onOpenChange:e,className:o,style:r,children:n,...c}){let s=it(),[w,m]=g.useState(!1),[b,k]=g.useState(t),x=a??b,C=g.useCallback(h=>{let y=typeof h=="function"?h(x):h;e?e(y):k(y),document.cookie=`${ma}=${y}; path=/; max-age=${fa}`},[e,x]),P=g.useCallback(()=>s?m(h=>!h):C(h=>!h),[s,C,m]);g.useEffect(()=>{let h=y=>{y.key===ya&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),P())};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[P]);let $=x?"expanded":"collapsed",B=g.useMemo(()=>({state:$,open:x,setOpen:C,isMobile:s,openMobile:w,setOpenMobile:m,toggleSidebar:P}),[$,x,C,s,w,m,P]);return l(bt.Provider,{value:B,children:l(U,{delayDuration:0,children:l("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":ha,"--sidebar-width-icon":xa,...r},className:d("astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:min-h-svh astw:w-full",o),...c,children:n})})})}function ft({side:t="left",variant:a="sidebar",collapsible:e="offcanvas",className:o,children:r,...n}){let{isMobile:c,state:s,openMobile:w,setOpenMobile:m}=I();return e==="none"?l("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}):c?l(nt,{open:w,onOpenChange:m,...n,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":va},side:t,children:[_(lt,{className:"sr-only",children:[l(ct,{children:"Sidebar"}),l(wt,{children:"Displays the mobile sidebar."})]}),l("div",{className:"flex h-full w-full flex-col",children:r})]})}):_("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:[l("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)")}),l("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:l("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 X({className:t,onClick:a,...e}){let{toggleSidebar:o}=I();return _(D,{"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:[l(ba,{className:"astw:size-4.5"}),l("span",{className:"astw:sr-only",children:"Toggle Sidebar"})]})}function ht({className:t,...a}){return l("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 vt({className:t,...a}){return l("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 xt({className:t,...a}){return l("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 yt({className:t,...a}){return l("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 kt({className:t,...a}){return l("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 Ct({className:t,...a}){return l("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:d("astw:group/menu-item astw:relative",t),...a})}var ka=ga("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,...c}){let s=t?q:"button",{isMobile:w,state:m}=I(),b=l(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":a,className:d(ka({variant:e,size:o}),n),...c});return r?(typeof r=="string"&&(r={children:r}),_(pt,{children:[l(ut,{asChild:!0,children:b}),l(gt,{side:"right",align:"center",hidden:m!=="collapsed"||w,...r})]})):b}function Y({className:t,asChild:a=!1,showOnHover:e=!1,...o}){return l(a?q:"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 Pt({className:t,...a}){return l("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 St({className:t,...a}){return l("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:d("astw:group/menu-sub-item astw:relative",t),...a})}function Rt({asChild:t=!1,size:a="md",isActive:e=!1,className:o,...r}){return l(t?q:"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 Bt,SunIcon as Na}from"lucide-react";import{Slot as Sa}from"@radix-ui/react-slot";import{ChevronRight as Ra,MoreHorizontal as nr}from"lucide-react";import{Link as Ca,useHref as Pa}from"react-router";import{jsx as Tt}from"react/jsx-runtime";function A({to:t,children:a,...e}){try{return Pa(t),Tt(Ca,{to:t,...e,children:a})}catch{return Tt("a",{href:t,...e,children:a})}}import{jsx as z,jsxs as wr}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: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 Mt({className:t,...a}){return z("li",{"data-slot":"breadcrumb-item",className:d("astw:inline-flex astw:items-center astw:gap-1.5",t),...a})}function _t({asChild:t,className:a,children:e,...o}){return z(t?Sa:A,{"data-slot":"breadcrumb-link",className:d("astw:hover:text-foreground astw:transition-colors",a),...o,children:e})}function It({children:t,className:a,...e}){return z("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:d("astw:[&>svg]:size-3.5",a),...e,children:t??z(Ra,{})})}var Ta=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(c=>{let s=`${n}/${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 At(t,a,e){let o=t.split("/").filter(s=>s!=="").slice(1),r=a?(()=>{let[s,...w]=o;return w})():o,n=Ta(e),c=r.map((s,w)=>{let m=r.slice(0,w+1).join("/"),b=n[m];if(!b){let x=Object.entries(n).find(([C])=>{let P=C.split("/").map(B=>B.startsWith(":")?"[^/]+":B).join("/");return new RegExp(`^${P}$`).test(m)})?.[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:m,title:k}});return{basePath:a||null,segments:c}}import{Fragment as Et,jsx as i,jsxs as u}from"react/jsx-runtime";var za=()=>{let{open:t}=I();return i("div",{className:t?"astw:md:hidden":void 0,children:i(X,{className:"astw:-ml-2.5"})})},Ma=t=>{let a=t.children?t.children({Outlet:H}):null,e=V(),o=()=>{e.setTheme(e.theme==="dark"?"light":"dark")};return i(mt,{className:"astw:flex astw:flex-col",children:u("div",{className:"astw:flex astw:flex-1",children:[t.sidebar??i(Ot,{}),u(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:u("div",{className:"astw:flex astw:w-full astw:items-center astw:justify-between",children:[u("div",{className:"astw:flex astw:items-center astw:gap-2",children:[i(za,{}),i(Ia,{})]}),i("div",{className:"astw:flex astw:items-center astw:gap-2",children:i(D,{variant:"outline",size:"icon",onClick:o,children:i(Na,{})})})]})}),i("div",{className:"astw:flex astw:flex-col astw:gap-4",children:a??i(H,{})})]})]})})},Ot=t=>{let{title:a,icon:e,navItems:o}=S(),{pathname:r}=Lt(),n=u(vt,{children:[e,i("h1",{className:"astw:text-sm astw:mb-2 astw:mt-2 astw:px-2",children:a})]});return u(ft,{variant:"inset",children:[u("div",{className:"astw:flex astw:justify-between astw:items-center",children:[t.header??n,i("div",{className:"astw:hidden astw:md:block",children:i(X,{className:"astw:-ml-1"})})]}),i(xt,{children:i(yt,{children:i(kt,{children:o.map(s=>i(ot,{asChild:!0,defaultOpen:s.isActive,children:u(Ct,{children:[s.url?u(Et,{children:[i(Q,{asChild:!0,tooltip:s.title,children:u(A,{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(j,{asChild:!0,children:u(Y,{className:"astw:data-[state=open]:rotate-90",children:[i(Bt,{}),i("span",{className:"sr-only",children:"Toggle"})]})})]}):i(Et,{children:u(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:u("span",{className:"astw:flex astw:w-[100%]",children:[s.icon,i("span",{children:s.title})]})}),!!s.items?.length&&u(Y,{className:"astw-rotate-target",children:[i(Bt,{}),i("span",{className:"sr-only",children:"Toggle"})]})]})}),!!s.items?.length&&i(st,{children:i(Pt,{children:s.items?.map(w=>i(St,{children:i(Rt,{asChild:!0,children:i(A,{to:w.url,className:w.url===r?"astw:bg-sidebar-accent astw:font-medium":void 0,children:i("span",{children:w.title})})})},w.title))})})]})},s.title))})})}),t.footer??null]})},_a=()=>{let{configurations:t}=S(),a=Lt();return At(a.pathname,t.basePath,t.modules)},Ia=()=>{let{basePath:t,segments:a}=_a();return i(Nt,{children:i(zt,{children:a.map((e,o)=>u("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})}),o<a.length-1&&i(It,{})]},o))})})};import{useEffect as Aa}from"react";import{capitalCase as Dt}from"change-case";import{useNavigate as Ba}from"react-router";import{jsx as $t}from"react/jsx-runtime";function Ea(t){let{path:a,meta:e,component:o,defaultResourceRedirectPath:r}=t,n=e?.title??Dt(a),c=o||function(){let w=Ba();return Aa(()=>{w(r)},[w]),null};return{path:a,type:"component",_type:"module",component:()=>$t(E,{contentBorder:e?.contentBorder??!1,children:c({title:n})}),meta:{title:n,...e?.breadcrumbTitle!==void 0?{breadcrumbTitle:e.breadcrumbTitle}:{},...e,menuItemClickable:!r,icon:t.meta?.icon},resources:t.resources}}function La(t){let{path:a,component:e,subResources:o,meta:r}=t,n=r?.title??Dt(a);return{_type:"resource",type:"component",path:a,meta:{title:n,...r?.breadcrumbTitle!==void 0?{breadcrumbTitle:r.breadcrumbTitle}:{}},component:()=>$t(E,{contentBorder:r?.contentBorder??!1,children:e({title:n})}),subResources:o}}import{useLocation as jr,useNavigate as Kr,useParams as Fr,useSearchParams as Gr,Link as Ur}from"react-router";export{ea as AppShell,Ot as DefaultSidebar,Ur as Link,Ma as SidebarLayoutContainer,Ea as defineModule,La as defineResource,S as useAppShell,jr as useLocation,Kr as useNavigate,Fr as useParams,Gr as useSearchParams,V as useTheme};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/app-shell",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./styles": "./dist/index.css",