UNPKG

@baseplate-dev/project-builder-web

Version:

Web interface for constructing project builder JSON

3 lines (2 loc) 3.08 kB
import{i as r}from"./_virtual___federation_fn_import-DOo8C-zl.js";import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{S as j,A as S,a as v}from"./index-DiAhmW9l.js";import{u as f}from"./use-enum-form-b35DnR3I.js";import{L,c as y}from"./index-G5ZRloOW.js";import{i as N,e as b}from"./index.esm-DImnoN58.js";const{SectionListSection:C,SectionListSectionContent:g,SectionListSectionHeader:w,SectionListSectionTitle:E,SwitchFieldController:V}=await r("@baseplate-dev/ui-components");function A({control:s}){return e.jsxs(C,{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 F(s){return s.split("_").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" ")}const{modelEnumValueEntityType:T}=await r("@baseplate-dev/project-builder-lib"),{Button:d,InputFieldController:u,Label:p,SectionListSection:$,SectionListSectionContent:I,SectionListSectionDescription:k,SectionListSectionHeader:B,SectionListSectionTitle:D}=await r("@baseplate-dev/ui-components");function G({control:s,setValue:i}){const{fields:n,remove:a,append:o,move:c}=N({control:s,name:"values"}),l=b({control:s,name:"values"}),m="grid grid-cols-[repeat(2,minmax(130px,1fr))_80px] gap-3",x=n.map((h,t)=>({id:h.id,element:e.jsxs("div",{className:m,children:[e.jsx(u,{control:s,name:`values.${t}.name`}),e.jsx(u,{control:s,name:`values.${t}.friendlyName`,onFocus:()=>{!l[t].friendlyName&&l[t].name&&i(`values.${t}.friendlyName`,F(l[t].name))}}),e.jsxs(d,{variant:"ghost",size:"icon",onClick:()=>{a(t)},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",{})]}),n.length===0?e.jsx("p",{className:"pt-4 text-style-muted",children:"Add some values to get started"}):e.jsx(j,{listItems:x,sortItems:c})]}),e.jsx(d,{size:"sm",variant:"secondary",onClick:()=>{o({id:T.generateNewId(),name:"",friendlyName:""})},children:"Add Value"})]})]})}const{useBlockUnsavedChangesNavigate:Q}=await r("@baseplate-dev/project-builder-lib/web"),{FormActionBar:H,SectionList:R}=await r("@baseplate-dev/ui-components");function M(){const{key:s}=S.useParams(),{form:i,onSubmit:n,isSavingDefinition:a}=f({omit:["name","featureRef"],enumKey:s}),{control:o,setValue:c}=i;return Q({control:o,reset:i.reset,onSubmit:n}),e.jsx(v,{children:e.jsxs("form",{onSubmit:n,className:"mx-4 max-w-7xl min-w-[700px] flex-1 space-y-4 pb-4",children:[e.jsxs(R,{children:[e.jsx(A,{control:o}),e.jsx(G,{control:o,setValue:c})]}),e.jsx(H,{form:i,disabled:a})]})})}export{M as component}; //# sourceMappingURL=index-Cwg06NVC.js.map