@baseplate-dev/project-builder-web
Version:
Web interface for constructing project builder JSON
3 lines (2 loc) • 3.08 kB
JavaScript
import{i as c}from"./_virtual___federation_fn_import-C4el_tlG.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{S,v as j,a as v}from"./index-BsqYBobW.js";import{u as f}from"./use-enum-form-TZs3gWw7.js";import{L,c as y}from"./index--XHV4ygU.js";import{f as C,e as N}from"./index.esm-C5MSuOl4.js";const{SectionListSection:b,SectionListSectionContent:g,SectionListSectionHeader:w,SectionListSectionTitle:E,SwitchFieldController:V}=await c("@baseplate-dev/ui-components");function F({control:s}){return e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(E,{children:"GraphQL"})}),e.jsx(g,{className:"space-y-4",children:e.jsx(V,{label:"Expose in GraphQL schema",control:s,name:"isExposed",description:"Whether to expose this enum in the GraphQL schema"})})]})}function A(s){return s.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join(" ")}const{modelEnumValueEntityType:T}=await c("@baseplate-dev/project-builder-lib"),{Button:d,InputFieldController:u,Label:p,SectionListSection:$,SectionListSectionContent:I,SectionListSectionDescription:k,SectionListSectionHeader:B,SectionListSectionTitle:D}=await c("@baseplate-dev/ui-components");function G({control:s,setValue:r}){const{fields:t,remove:i,append:l,move:a}=C({control:s,name:"values"}),o=N({control:s,name:"values"}),m="grid grid-cols-[repeat(2,minmax(130px,1fr))_80px] gap-3",x=t.map((h,n)=>({id:h.id,element:e.jsxs("div",{className:m,children:[e.jsx(u,{control:s,name:`values.${n}.name`}),e.jsx(u,{control:s,name:`values.${n}.friendlyName`,onFocus:()=>{!o[n].friendlyName&&o[n].name&&r(`values.${n}.friendlyName`,A(o[n].name))}}),e.jsxs(d,{variant:"ghost",size:"icon",onClick:()=>{i(n)},children:[e.jsx(L,{}),e.jsx("div",{className:"sr-only",children:"Delete Enum"})]})]})}));return e.jsxs($,{children:[e.jsxs(B,{children:[e.jsx(D,{children:"Values"}),e.jsx(k,{children:"Configure the allowed values for this enum."})]}),e.jsxs(I,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:y(m,"pl-12"),children:[e.jsx(p,{children:"Value Name, e.g. ACTIVE"}),e.jsx(p,{children:"Value Friendly Name, e.g. Active"}),e.jsx("div",{})]}),t.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"Add some values to get started"}):e.jsx(S,{listItems:x,sortItems:a})]}),e.jsx(d,{size:"sm",variant:"secondary",onClick:()=>{l({id:T.generateNewId(),name:"",friendlyName:""})},children:"Add Value"})]})]})}const{useBlockUnsavedChangesNavigate:Q}=await c("@baseplate-dev/project-builder-lib/web"),{FormActionBar:H,SectionList:R}=await c("@baseplate-dev/ui-components"),M=function(){const{key:r}=j.useParams(),{form:t,onSubmit:i,isSavingDefinition:l}=f({omit:["name","featureRef"],enumKey:r}),{control:a,setValue:o}=t;return Q({control:a,reset:t.reset,onSubmit:i}),e.jsx(v,{children:e.jsxs("form",{onSubmit:i,className:"mx-4 max-w-7xl min-w-[700px] flex-1 space-y-4 pb-4",children:[e.jsxs(R,{children:[e.jsx(F,{control:a}),e.jsx(G,{control:a,setValue:o})]}),e.jsx(H,{form:t,disabled:l})]})})};export{M as component};
//# sourceMappingURL=index-BIUEM94A.js.map