UNPKG

@baseplate-dev/project-builder-web

Version:

Web interface for constructing project builder JSON

3 lines (2 loc) 4.69 kB
import{i}from"./_virtual___federation_fn_import-C4el_tlG.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{a as g}from"./index-BsqYBobW.js";import{c as u,A as b,B as y}from"./index--XHV4ygU.js";import{N as S}from"./new-enum-dialog-BBIjPlSZ.js";import{s as w}from"./sortBy-C9bvycg5.js";import{N as L}from"./new-model-dialog-Cck1KtiW.js";function k(c,o){let a=c[0],n=-1/0;for(let r=0;r<c.length;r++){const l=c[r],s=o(l);s>n&&(n=s,a=l)}return a}const{modelEnumEntityType:C}=await i("@baseplate-dev/project-builder-lib"),{useProjectDefinition:M}=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:c}){const{definition:{enums:o=[]}}=M(),[a,n]=x(""),r=o.filter(t=>t.name.toLowerCase().includes(a.toLowerCase())),l=w(r,[t=>t.name]),[s,m]=x(!1);return e.jsxs("div",{className:u(c,"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",s&&"border-t"),onScrollCapture:t=>{const d=t.currentTarget.scrollTop>0;d!==s&&m(d)},children:[l.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:l.map(t=>e.jsx("li",{children:e.jsx(I,{asChild:!0,children:e.jsx(B,{to:"/data/enums/edit/$key",params:{key:C.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:c}){const{definition:{models:o}}=P(),[a,n]=j(""),r=o.filter(t=>t.name.toLowerCase().includes(a.toLowerCase())),l=w(r,[t=>t.name]),[s,m]=j(!1);return e.jsxs("div",{className:u(c,"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",s&&"border-t"),onScrollCapture:t=>{const d=t.currentTarget.scrollTop>0;d!==s&&m(d)},children:[l.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:l.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"),ie=function(){const{definition:{models:o=[],enums:a=[]}}=H(),n=k([...o,...a],s=>s.name.length)?.name,r=N({select:s=>s.location.pathname.startsWith("/data/models")}),l=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:n}),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"})})]})}),r?e.jsx(G,{}):null,l?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-DbNdyGjX.js.map