@baseplate-dev/project-builder-web
Version:
Web interface for constructing project builder JSON
3 lines (2 loc) • 4.69 kB
JavaScript
import{i}from"./_virtual___federation_fn_import-DOo8C-zl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{a as g}from"./index-DiAhmW9l.js";import{c as u,A as b,B as y}from"./index-G5ZRloOW.js";import{N as S}from"./new-enum-dialog-CbZ0j_YF.js";import{s as w}from"./sortBy-C9bvycg5.js";import{N as L}from"./new-model-dialog-D7nZ2Q8c.js";function k(l,o){let a=l[0],n=-1/0;for(let r=0;r<l.length;r++){const s=l[r],c=o(s);c>n&&(n=c,a=s)}return a}const{modelEnumEntityType:M}=await i("@baseplate-dev/project-builder-lib"),{useProjectDefinition:C}=await i("@baseplate-dev/project-builder-lib/web"),{Button:h,InputField:$,NavigationMenu:E,NavigationMenuItemWithLink:I,NavigationMenuList:T,ScrollArea:A}=await i("@baseplate-dev/ui-components"),{Link:B}=await i("@tanstack/react-router"),{useState:x}=await i("react");function F({className:l}){const{definition:{enums:o=[]}}=C(),[a,n]=x(""),r=o.filter(t=>t.name.toLowerCase().includes(a.toLowerCase())),s=w(r,[t=>t.name]),[c,m]=x(!1);return e.jsxs("div",{className:u(l,"flex flex-1 flex-col space-y-4 overflow-y-auto"),children:[e.jsxs("div",{className:"space-y-4 px-4",children:[e.jsx(S,{children:e.jsxs(h,{variant:"secondary",className:"w-full",children:[e.jsx(b,{}),"New Enum"]})}),o.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx($,{value:a,onChange:t=>{n(t)},placeholder:"Search"}),a&&e.jsx(h,{variant:"ghost",className:"absolute top-1/2 right-4 -translate-y-1/2",size:"icon",onClick:()=>{n("")},children:e.jsx(y,{})})]})]}),e.jsxs(A,{className:u("flex-1 px-2",c&&"border-t"),onScrollCapture:t=>{const d=t.currentTarget.scrollTop>0;d!==c&&m(d)},children:[s.length===0&&a&&e.jsx("div",{className:"py-4 text-center text-style-muted",children:"No enums found"}),e.jsx(E,{orientation:"vertical",children:e.jsx(T,{children:s.map(t=>e.jsx("li",{children:e.jsx(I,{asChild:!0,children:e.jsx(B,{to:"/data/enums/edit/$key",params:{key:M.keyFromId(t.id)},children:t.name})})},t.id))})})]})]})}const{modelEntityType:D}=await i("@baseplate-dev/project-builder-lib"),{useProjectDefinition:P}=await i("@baseplate-dev/project-builder-lib/web"),{Button:p,InputField:W,NavigationMenu:Q,NavigationMenuItemWithLink:z,NavigationMenuList:R,ScrollArea:O}=await i("@baseplate-dev/ui-components"),{Link:q}=await i("@tanstack/react-router"),{useState:j}=await i("react");function G({className:l}){const{definition:{models:o}}=P(),[a,n]=j(""),r=o.filter(t=>t.name.toLowerCase().includes(a.toLowerCase())),s=w(r,[t=>t.name]),[c,m]=j(!1);return e.jsxs("div",{className:u(l,"flex flex-1 flex-col space-y-4 overflow-y-auto"),children:[e.jsxs("div",{className:"space-y-4 px-4",children:[e.jsx(L,{children:e.jsxs(p,{variant:"secondary",className:"w-full",children:[e.jsx(b,{}),"New Model"]})}),o.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(W,{value:a,onChange:t=>{n(t)},placeholder:"Search"}),a&&e.jsx(p,{variant:"ghost",className:"absolute top-1/2 right-4 -translate-y-1/2",onClick:()=>{n("")},size:"icon",children:e.jsx(y,{})})]})]}),e.jsxs(O,{className:u("flex-1 px-2",c&&"border-t"),onScrollCapture:t=>{const d=t.currentTarget.scrollTop>0;d!==c&&m(d)},children:[s.length===0&&a&&e.jsx("div",{className:"py-4 text-center text-style-muted",children:"No models found"}),e.jsx(Q,{orientation:"vertical",children:e.jsx(R,{children:s.map(t=>e.jsx(z,{asChild:!0,children:e.jsx(q,{to:"/data/models/edit/$key",params:{key:D.keyFromId(t.id)},children:t.name})},t.id))})})]})]})}const{useProjectDefinition:H}=await i("@baseplate-dev/project-builder-lib/web"),{NavigationTabs:J,NavigationTabsItem:f,SidebarLayout:K,SidebarLayoutContent:U,SidebarLayoutSidebar:V}=await i("@baseplate-dev/ui-components"),{Link:v,Outlet:X,useRouterState:N}=await i("@tanstack/react-router");function ie(){const{definition:{models:l=[],enums:o=[]}}=H(),a=k([...l,...o],s=>s.name.length)?.name,n=N({select:s=>s.location.pathname.startsWith("/data/models")}),r=N({select:s=>s.location.pathname.startsWith("/data/enums")});return e.jsxs(K,{className:"flex-1",children:[e.jsxs(V,{className:"flex h-[calc(100vh-var(--topbar-height)-1px)] max-w-sm min-w-[230px] flex-col space-y-4",width:"auto",noPadding:!0,children:[e.jsx("div",{className:"invisible block h-1 overflow-hidden font-semibold text-transparent",children:a}),e.jsx("div",{className:"px-4",children:e.jsxs(J,{className:"w-full",children:[e.jsx(f,{asChild:!0,children:e.jsx(v,{to:"/data/models",children:"Models"})}),e.jsx(f,{asChild:!0,children:e.jsx(v,{to:"/data/enums",children:"Enums"})})]})}),n?e.jsx(G,{}):null,r?e.jsx(F,{}):null]}),e.jsx(U,{className:"h-[calc(100vh-var(--topbar-height)-1px)]",children:e.jsx(g,{children:e.jsx(X,{})})})]})}export{ie as component};
//# sourceMappingURL=route-DpHlVxJn.js.map