@notmrabhi/flowforge 0.1.44 → 0.1.46
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/{SchemaBuilderDrawer-KUOXc7K_.js → SchemaBuilderDrawer-CmSfZyyx.js} +2 -2
- package/dist/{SchemaBuilderDrawer-KUOXc7K_.js.map → SchemaBuilderDrawer-CmSfZyyx.js.map} +1 -1
- package/dist/{SchemaBuilderDrawer-DlmInnSC.js → SchemaBuilderDrawer-DTDPHHoR.js} +2 -2
- package/dist/{SchemaBuilderDrawer-DlmInnSC.js.map → SchemaBuilderDrawer-DTDPHHoR.js.map} +1 -1
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +2 -2
- package/dist/{index-BDDJrQn0.js → index-C39URw6S.js} +5 -5
- package/dist/index-C39URw6S.js.map +1 -0
- package/dist/{index-DU-niBi3.js → index-CXMgesuG.js} +2 -2
- package/dist/{index-DU-niBi3.js.map → index-CXMgesuG.js.map} +1 -1
- package/dist/{index-CbdFoSw3.js → index-C_bOLGwq.js} +2 -2
- package/dist/{index-CbdFoSw3.js.map → index-C_bOLGwq.js.map} +1 -1
- package/dist/{index-AISQhG1t.js → index-D0Qlgyc5.js} +2 -2
- package/dist/{index-AISQhG1t.js.map → index-D0Qlgyc5.js.map} +1 -1
- package/dist/{index-CBJiDDQc.js → index-DjpT0QMv.js} +2 -2
- package/dist/{index-CBJiDDQc.js.map → index-DjpT0QMv.js.map} +1 -1
- package/dist/{index-y_v8Qog1.js → index-gTlJrrQs.js} +24 -15
- package/dist/index-gTlJrrQs.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/{templateSkeletons-CHrd4Z5h.js → templateSkeletons-C235ahaA.js} +2 -2
- package/dist/{templateSkeletons-CHrd4Z5h.js.map → templateSkeletons-C235ahaA.js.map} +1 -1
- package/dist/{templateSkeletons-CtknKiGO.js → templateSkeletons-CzKWnn4a.js} +2 -2
- package/dist/{templateSkeletons-CtknKiGO.js.map → templateSkeletons-CzKWnn4a.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BDDJrQn0.js.map +0 -1
- package/dist/index-y_v8Qog1.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const h=require("react"),re=require("formik"),N=require("./index-BDDJrQn0.js"),e=require("react/jsx-runtime"),o=require("@mui/material"),S=require("react-icons/md"),ie=require("react-icons/fa6");function ae({schema:l,initialValues:s,onSubmit:d,showErrorsImmediately:a=!1}){const r=l.fields??[],t=h.useMemo(()=>N.buildValidationSchema(r),[r]),p=h.useMemo(()=>{if(a)return r.reduce((u,v)=>{const g=N.resolveFieldKey(v);return g&&(u[g]=!0),u},{})},[r,a]),[i,c]=h.useState({}),[m,y]=h.useState({}),B=h.useRef(s);h.useEffect(()=>{B.current!==s&&(B.current=s,c({}),y({}))},[s]);const x=re.useFormik({initialValues:s,validationSchema:t,initialTouched:p,validateOnMount:a,validateOnChange:!0,validateOnBlur:!0,enableReinitialize:!0,onSubmit:async u=>{const v=N.buildEvaluationPayload({values:u,conditionConfig:m});await d(u,v)}}),n=h.useCallback(()=>{x.submitForm()},[x]),f=h.useCallback(u=>{x.resetForm(u?{values:u}:void 0),c({}),y({})},[x]);return{values:x.values,errors:x.errors,isValid:x.isValid,isDirty:x.dirty,isSubmitting:x.isSubmitting,formulaConfig:i,conditionConfig:m,submit:n,reset:f,setFieldValue:x.setFieldValue,_schema:l,_formik:x,_formulaConfig:i,_onFormulaConfigChange:c,_conditionConfig:m,_onConditionConfigChange:y}}const Z=N.FlowForgeRegistry.getTypeOptions(),j="form-control font-14",b="text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1",F={fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:.6,marginBottom:8,display:"block"},ce=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object (sub-fields)"},{value:"array",label:"Array (nested)"}],de=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}];function xe({value:l,onChange:s}){const d=l??12;return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Column width"}),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:de.map(a=>e.jsx(o.Tooltip,{title:`colSpan: ${a.value}`,placement:"top",children:e.jsx(o.Box,{component:"button",onClick:()=>s(a.value),sx:{flex:1,border:"1px solid",borderColor:d===a.value?"#6366f1":"#dee2e6",borderRadius:"6px",cursor:"pointer",bgcolor:d===a.value?"#eef2ff":"#fff",color:d===a.value?"#6366f1":"#6c757d",fontSize:11,fontWeight:600,py:.6,px:0,"&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:a.label})},a.value))}),e.jsx(o.Box,{sx:{display:"flex",gap:"3px",mt:.75},children:Array.from({length:12}).map((a,r)=>e.jsx(o.Box,{sx:{flex:1,height:4,borderRadius:"2px",bgcolor:r<d?"#6366f1":"#e2e8f0",transition:"background 0.12s"}},r))})]})}function Q({options:l=[],onChange:s}){function d(a,r,t){s(l.map((p,i)=>i===a?{...p,[r]:t}:p))}return e.jsxs(o.Box,{children:[e.jsxs("span",{className:b,children:["Options ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((a,r)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:a.label,onChange:t=>d(r,"label",t.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"Value",value:a.value,onChange:t=>d(r,"value",t.target.value)}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((t,p)=>p!==r)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},r))}),e.jsxs(o.Box,{component:"button",onClick:()=>s([...l,{label:"",value:""}]),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add option"]})]})}const ee=[{value:"operator",label:"Operator (predefined)"},{value:"select",label:"Select"},{value:"text",label:"Text"}];function pe({col:l,onChange:s,onDelete:d}){const a=l.type==="select",r=l.type==="operator";return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"7px",p:1.25,bgcolor:"#fff",display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:r?"#fef9c3":"#eef2ff",color:r?"#92400e":"#6366f1",flexShrink:0},children:r?"OPERATOR":l.type.toUpperCase()}),e.jsx(o.Box,{sx:{fontSize:12,fontWeight:600,color:"#0f172a",flex:1},children:l.label||l.id||"Unnamed"}),e.jsx(o.Box,{component:"button",onClick:d,sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Column type"}),e.jsx("select",{value:l.type,onChange:t=>s({...l,type:t.target.value,options:void 0}),className:j,style:{cursor:"pointer"},children:ee.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Column key ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:`${j} ${l.id?"":"border-danger"}`,value:l.id,onChange:t=>s({...l,id:t.target.value}),placeholder:"e.g. field, operator, value"}),!l.id&&e.jsx("span",{style:{fontSize:10,color:"#dc3545"},children:"Required — used as data key"})]})]}),!r&&e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Label"}),e.jsx("input",{className:j,value:l.label??"",onChange:t=>s({...l,label:t.target.value||void 0}),placeholder:"Column label"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:t=>s({...l,placeholder:t.target.value||void 0}),placeholder:"Hint…"})]})]}),a&&e.jsx(Q,{options:l.options??[],onChange:t=>s({...l,options:t})}),r&&e.jsx(o.Box,{sx:{bgcolor:"#fefce8",border:"1px solid #fef08a",borderRadius:"6px",px:1.25,py:.75},children:e.jsx(o.Box,{sx:{fontSize:11,color:"#78350f"},children:"Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…"})}),!r&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:`formula-${l.id}`,checked:!!l.formula,onChange:t=>s({...l,formula:t.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:`formula-${l.id}`,className:b,style:{margin:0,cursor:"pointer"},children:"Formula input (chip editor)"})]})]})}function ue({condition:l,onChange:s}){const d=!!l;function a(){s(d?void 0:{fields:[]})}function r(i){if(!l)return;const c=i==="operator"?"operator":l.fields.filter(m=>m.type!=="operator").length===0?"field":"value";s({...l,fields:[...l.fields,{id:c,type:i}]})}function t(i,c){if(!l)return;const m=[...l.fields];m[i]=c,s({...l,fields:m})}function p(i){l&&s({...l,fields:l.fields.filter((c,m)=>m!==i)})}return e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:d?1.25:0},children:[e.jsx("input",{type:"checkbox",id:"enable-condition",checked:d,onChange:a,style:{cursor:"pointer",width:14,height:14}}),e.jsx("span",{style:{...F,margin:0,color:d?"#6366f1":"#94a3b8"},children:"Condition row"})]}),d&&l&&e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[l.fields.map((i,c)=>e.jsx(pe,{col:i,onChange:m=>t(c,m),onDelete:()=>p(c)},c)),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:ee.map(i=>e.jsxs(o.Box,{component:"button",onClick:()=>r(i.value),sx:{flex:1,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,py:.5,borderRadius:"6px",color:i.value==="operator"?"#92400e":"#6366f1","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:["+ ",i.value==="operator"?"Operator":i.label.split(" ")[0]]},i.value))}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:"allow-groups",checked:!!l.allowGroups,onChange:i=>s({...l,allowGroups:i.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:"allow-groups",className:b,style:{margin:0,cursor:"pointer"},children:"Allow nested groups"})]}),l.allowGroups&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("label",{className:b,style:{margin:0},children:"Max depth"}),e.jsx("input",{type:"number",min:1,max:5,className:j,style:{width:60,textAlign:"center"},value:l.maxGroupDepth??"",onChange:i=>s({...l,maxGroupDepth:i.target.value?Number(i.target.value):void 0}),placeholder:"∞"})]})]})]})]})}function E({id:l,label:s,checked:d,onChange:a}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:l,checked:d,onChange:r=>a(r.target.checked),style:{cursor:"pointer",width:14,height:14,flexShrink:0}}),e.jsx("label",{htmlFor:l,className:b,style:{margin:0,cursor:"pointer"},children:s})]})}function he({views:l=[],onChange:s}){function d(r,t,p){s(l.map((i,c)=>c===r?{...i,[t]:p}:i))}function a(){const r=`tab${l.length+1}`;s([...l,{id:r,label:`Tab ${l.length+1}`}])}return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Views"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((r,t)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:r.label,onChange:p=>d(t,"label",p.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"ID (no spaces)",value:r.id,onChange:p=>d(t,"id",p.target.value.replace(/\s/g,"_"))}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((p,i)=>i!==t)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},t))}),e.jsxs(o.Box,{component:"button",onClick:a,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add view"]})]})}function _({label:l,value:s,options:d,onChange:a}){return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:l}),e.jsx(o.Box,{sx:{display:"flex",border:"1px solid #dee2e6",borderRadius:"7px",overflow:"hidden"},children:d.map(r=>e.jsx(o.Box,{component:"button",onClick:()=>a(r.value),sx:{flex:1,border:"none",borderRight:"1px solid #dee2e6",cursor:"pointer",fontSize:12,fontWeight:600,py:.6,bgcolor:s===r.value?"#eef2ff":"#fff",color:s===r.value?"#6366f1":"#6c757d","&:last-child":{borderRight:"none"},"&:hover":{bgcolor:"#f5f3ff"}},children:r.label},r.value))})]})}function le({field:l,onChange:s,onSave:d,onCancel:a,noFooter:r}){const[t,p]=h.useState(!1),i=l.id??l.name??"",c=l,m=l.type==="select"||l.type==="descriptive-select"||l.type==="radio-group",y=N.FlowForgeRegistry.get(l.type),B=y==null?void 0:y.configSchema;function x(n,f){s({...l,[n]:f})}return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.Box,{children:[e.jsx("span",{style:F,children:"Required"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Type"}),e.jsx("select",{value:l.type,onChange:n=>x("type",n.target.value),className:j,style:{cursor:"pointer"},children:Z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:l.type==="tabs"?"1fr":"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Field ID ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.id??l.name??"",onChange:n=>x("id",n.target.value),placeholder:"e.g. email"})]}),l.type!=="tabs"&&e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Label ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.label??"",onChange:n=>x("label",n.target.value),placeholder:"Display label"})]})]}),l.type!=="tabs"&&e.jsx(xe,{value:l.colSpan,onChange:n=>x("colSpan",n===12?void 0:n)})]})]}),B&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Specific Settings"}),e.jsx(N.FlowForm,{schema:{layout:"flat",compact:!0,fields:B.fields},initialValues:l,onValuesChange:n=>s({...l,...n}),onSubmit:()=>{}})]}),l.type==="tabs"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx("span",{style:F,children:"Content"}),e.jsx(he,{views:(c.tabs??[]).map(n=>({id:n.id,label:n.label})),onChange:n=>{const f=c.tabs??[],u=n.map(v=>{const g=f.find(w=>w.id===v.id);return g?{...g,...v}:{...v,fields:[]}});s({...l,tabs:u})}}),e.jsx("span",{style:{...F,marginTop:4},children:"Interaction"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Disabled"}),e.jsx("input",{className:j,value:c.disabledExpr??"",onChange:n=>s({...l,disabledExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Appearance"}),e.jsx(_,{label:"Alignment",value:c.alignment??"left",options:[{value:"left",label:"|←"},{value:"center-left",label:"←|"},{value:"center",label:"|·|"},{value:"center-right",label:"|→"},{value:"right",label:"→|"}],onChange:n=>s({...l,alignment:n})}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Hidden"}),e.jsx("input",{className:j,value:c.hiddenExpr??"",onChange:n=>s({...l,hiddenExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx(_,{label:"Variant",value:c.variant??"line",options:[{value:"pill",label:"Pill"},{value:"line",label:"Line"}],onChange:n=>s({...l,variant:n})}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active color"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeColor??"#6366f1",onChange:n=>s({...l,activeColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeColor??"",onChange:n=>s({...l,activeColor:n.target.value||void 0}),placeholder:"#6366f1",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeTextColor??"#ffffff",onChange:n=>s({...l,activeTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeTextColor??"",onChange:n=>s({...l,activeTextColor:n.target.value||void 0}),placeholder:"auto",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Inactive text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.inactiveTextColor??"#64748b",onChange:n=>s({...l,inactiveTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.inactiveTextColor??"",onChange:n=>s({...l,inactiveTextColor:n.target.value||void 0}),placeholder:"#64748b",style:{flex:1}})]})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Styles"}),e.jsx("input",{className:j,value:c.styles??"",onChange:n=>s({...l,styles:n.target.value||void 0}),placeholder:"None"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Spacing"}),e.jsx(_,{label:"Height",value:c.height??"auto",options:[{value:"auto",label:"Auto"},{value:"fixed",label:"Fixed"}],onChange:n=>s({...l,height:n})}),e.jsx(_,{label:"Margin",value:c.margin??"normal",options:[{value:"normal",label:"Normal"},{value:"none",label:"None"}],onChange:n=>s({...l,margin:n})})]}),m&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Options"}),e.jsx(Q,{options:c.options??[],onChange:n=>s({...l,options:n})})]}),l.type==="array"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{style:F,children:"Array settings"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item type"}),e.jsx("select",{className:j,style:{cursor:"pointer"},value:c.itemType??"text",onChange:n=>s({...l,itemType:n.target.value}),children:ce.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item label"}),e.jsx("input",{className:j,value:c.itemLabel??"",onChange:n=>s({...l,itemLabel:n.target.value||void 0}),placeholder:'e.g. "Member"'})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Add button label"}),e.jsx("input",{className:j,value:c.addLabel??"",onChange:n=>s({...l,addLabel:n.target.value||void 0}),placeholder:"Add item"})]})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Min items"}),e.jsx("input",{type:"number",min:0,className:j,value:c.minItems??"",onChange:n=>s({...l,minItems:n.target.value?Number(n.target.value):void 0}),placeholder:"0"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Max items"}),e.jsx("input",{type:"number",min:1,className:j,value:c.maxItems??"",onChange:n=>s({...l,maxItems:n.target.value?Number(n.target.value):void 0}),placeholder:"∞"})]})]}),!["object","array","select"].includes(c.itemType??"text")&&e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item placeholder"}),e.jsx("input",{className:j,value:c.itemPlaceholder??"",onChange:n=>s({...l,itemPlaceholder:n.target.value||void 0}),placeholder:"Enter value…"})]})]}),e.jsx(ue,{condition:l.condition,onChange:n=>s({...l,condition:n})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx(o.Box,{component:"button",onClick:()=>p(n=>!n),sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:.5,p:0,mb:t?1.25:0},children:e.jsxs("span",{style:{...F,margin:0,color:t?"#6366f1":"#94a3b8"},children:[t?"▾":"▸"," Optional settings"]})}),e.jsx(o.Collapse,{in:t,children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:n=>x("placeholder",n.target.value||void 0),placeholder:"Hint text…"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Helper text"}),e.jsx("input",{className:j,value:l.helperText??"",onChange:n=>x("helperText",n.target.value||void 0),placeholder:"Description…"})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Info tooltip"}),e.jsx("input",{className:j,value:l.info??"",onChange:n=>x("info",n.target.value||void 0),placeholder:"Shown in ℹ tooltip"})]}),e.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5},children:[e.jsx(E,{id:`${i}-req`,label:"Required",checked:!!l.required,onChange:n=>x("required",n||void 0)}),e.jsx(E,{id:`${i}-dis`,label:"Disabled",checked:!!l.disabled,onChange:n=>x("disabled",n||void 0)}),e.jsx(E,{id:`${i}-hid`,label:"Hidden",checked:!!l.hidden,onChange:n=>x("hidden",n||void 0)}),e.jsx(E,{id:`${i}-opt`,label:"Show optional",checked:!!l.showOptional,onChange:n=>x("showOptional",n||void 0)}),e.jsx(E,{id:`${i}-div`,label:"Divider after",checked:!!l.dividerAfter,onChange:n=>x("dividerAfter",n||void 0)}),e.jsx(E,{id:`${i}-frm`,label:"Formula input",checked:!!l.formula,onChange:n=>x("formula",n||void 0)})]})]})})]})]}),!r&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",gap:1,justifyContent:"flex-end",bgcolor:"#f8fafc",flexShrink:0},children:[e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:d,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Save"]})]})]})}const L={text:"#0f172a",textMuted:"#64748b",borderInput:"rgba(0,0,0,0.23)",bg:"#ffffff"},fe={md:"6px"},oe={sm:11,md:13},G={width:"100%",fontSize:oe.md,fontFamily:"inherit",padding:"8px 12px",border:`1px solid ${L.borderInput}`,borderRadius:fe.md,outline:"none",background:L.bg,color:L.text,boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s"};function X(){return{type:"text",id:"",label:"",colSpan:12}}function be(l){return l.type==="object"||l.type==="array"||l.type==="schema"}function me(l){if(l.type==="object")return"Child Fields";if(l.type==="schema")return"Schema Fields";const s=l.itemType??"text";return s==="object"?"Item Fields":s==="select"?"Item Options":"Item Config"}function ge({field:l,onChange:s}){var r;const d=l,a=d.itemType??"text";if(l.type==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields nested inside this object. Each child field can itself be an object or array."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Child fields"})]});if(l.type==="schema")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Schema fields"})]});if(l.type==="array"){if(a==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields for each item in the array. Each item will be an object with these fields."}),e.jsx(W,{value:d.itemFields??[],onChange:t=>s({...l,itemFields:t}),label:"Item fields"})]});if(a==="select"){const t=d.itemOptions??[];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Options available in each select item."}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:t.map((p,i)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Label",value:p.label,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,label:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Value",value:p.value,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,value:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:t.filter((c,m)=>m!==i)}),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:"✕"})]},i))}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:[...t,{label:"",value:""}]}),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%",justifyContent:"center","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:"+ Add option"})]})}if(a==="array"){const t=((r=d.itemSchema)==null?void 0:r.itemType)??"text",p=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object"}];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Each item is itself an array. Configure the type of items inside the nested array."}),e.jsx("label",{style:{fontSize:oe.sm,fontWeight:600,color:L.textMuted,display:"block",marginBottom:3},children:"Nested item type"}),e.jsx("select",{style:{...G,padding:"6px 10px",cursor:"pointer"},value:t,onChange:i=>s({...l,itemSchema:{...d.itemSchema??{},itemType:i.target.value}}),children:p.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]})}return e.jsx(o.Box,{sx:{p:2.5},children:e.jsxs(o.Box,{sx:{border:"1.5px dashed #e2e8f0",borderRadius:"8px",py:3,textAlign:"center"},children:[e.jsxs(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:["No extra configuration needed for ",e.jsx("strong",{children:a})," items."]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#cbd5e1",mt:.5},children:"Item placeholder and labels are set in the previous step."})]})})}return null}function je({field:l}){var p;const[s,d]=h.useState({}),a=l.id??l.name??"preview",r=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}],t=l.colSpan&&l.colSpan<12?((p=r.find(i=>i.value===l.colSpan))==null?void 0:p.label)??l.colSpan:"Full";return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:2,px:1.25,py:.75,bgcolor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"7px"},children:[e.jsx(o.Typography,{sx:{fontSize:11,color:"#15803d",fontWeight:500,flex:1},children:"Live preview — interact to test the field"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#64748b"},children:["Width: ",t]})]}),e.jsx(N.FlowForm,{schema:{layout:"flat",fields:[l]},initialValues:{[a]:l.type==="array"?[]:l.type==="object"||l.type==="schema"?{}:""},onSubmit:()=>{},conditionConfig:s,onConditionConfigChange:d})]})}function J({open:l,initial:s,onSave:d,onClose:a,editMode:r=!1}){const[t,p]=h.useState(1),[i,c]=h.useState(()=>s??X());function m(){c(s??X()),p(1)}const y=be(i),B=y?3:2,x=y?["Configure",me(i),"Preview"]:["Configure","Preview"],n=!!(i.id||i.name)&&!!i.type;function f(){p(k=>Math.min(k+1,B))}function u(){p(k=>Math.max(k-1,1))}function v(){d(i),a()}const g=t-1,w=t===B,T=y&&t===3||!y&&t===2;return e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:m},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"90vh"}},children:[e.jsxs(o.Box,{sx:{px:2.5,pt:1.75,pb:0,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a",flex:1},children:r?"Edit Field":"Add Field"}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Stepper,{activeStep:g,sx:{pb:1.5},children:x.map((k,R)=>e.jsx(o.Step,{completed:g>R,children:e.jsx(o.StepLabel,{children:k})},k))})]}),e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto"},children:[t===1&&e.jsx(le,{field:i,onChange:c,onSave:f,onCancel:a,noFooter:!0}),t===2&&y&&e.jsx(ge,{field:i,onChange:c}),T&&e.jsx(je,{field:i})]}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[t>1&&e.jsxs(o.Box,{component:"button",onClick:u,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:500,color:"#6c757d",px:0,"&:hover":{color:"#0f172a"}},children:[e.jsx(S.MdArrowBack,{size:14})," Back"]}),e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),w?e.jsxs(o.Box,{component:"button",onClick:v,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," ",r?"Save changes":"Add field"]}):e.jsx(o.Box,{component:"button",onClick:f,disabled:!n,sx:{border:"none",cursor:n?"pointer":"not-allowed",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:n?"#6366f1":"#c7d2fe",color:"#fff","&:hover":{bgcolor:n?"#4f46e5":"#c7d2fe"}},children:"Next →"})]})]})}function ye({field:l,index:s,total:d,onEdit:a,onDelete:r,onMoveUp:t,onMoveDown:p}){const i=l.label||l.id||l.name||"Untitled",c=l.id??l.name??"";return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:1,border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff"},children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.25,color:"#cbd5e1"},children:[e.jsx(o.Box,{component:"button",onClick:t,disabled:s===0,sx:{background:"none",border:"none",p:0,cursor:s===0?"default":"pointer",color:s===0?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===0?"#e2e8f0":"#475569"}},children:"▲"}),e.jsx(o.Box,{component:"button",onClick:p,disabled:s===d-1,sx:{background:"none",border:"none",p:0,cursor:s===d-1?"default":"pointer",color:s===d-1?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===d-1?"#e2e8f0":"#475569"}},children:"▼"})]}),e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:"#eef2ff",color:"#6366f1",flexShrink:0},children:l.type}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsxs(o.Typography,{sx:{fontSize:13,fontWeight:600,color:"#0f172a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i,l.required&&e.jsx(o.Box,{component:"span",sx:{color:"#dc3545",ml:.25},children:"*"})]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8",fontFamily:"monospace"},children:c})]}),e.jsx(o.Tooltip,{title:"Edit field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#f1f5f9",color:"#475569"}},children:e.jsx(S.MdEdit,{size:14})})}),e.jsx(o.Tooltip,{title:"Remove field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:r,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#fee2e2",color:"#dc2626"}},children:e.jsx(S.MdDeleteOutline,{size:16})})})]})}function ve({open:l,value:s,onSave:d,onClose:a}){const[r,t]=h.useState(s),[p,i]=h.useState(null);function c(){t(s),i(null)}function m(f){t(u=>u.filter((v,g)=>g!==f))}function y(f,u){t(v=>{const g=[...v],w=f+u;return w<0||w>=g.length?v:([g[f],g[w]]=[g[w],g[f]],g)})}function B(f){p!==null&&(t(u=>{const v=[...u];return v[p]=f,v}),i(null))}function x(){d(r),a()}const n=JSON.stringify(r)!==JSON.stringify(s);return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:c},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"85vh"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2.5,py:1.75,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:"Edit Schema"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:[r.length," field",r.length!==1?"s":""," defined"]})]}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:r.length===0?e.jsx(o.Box,{sx:{border:"1.5px dashed rgba(0,0,0,0.12)",borderRadius:"8px",py:4,textAlign:"center"},children:e.jsx(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:"No fields defined yet"})}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:r.map((f,u)=>e.jsx(ye,{field:f,index:u,total:r.length,onEdit:()=>i(u),onDelete:()=>m(u),onMoveUp:()=>y(u,-1),onMoveDown:()=>y(u,1)},`${f.id??f.name}-${u}`))})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[n?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:x,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),p!==null&&e.jsx(J,{open:p!==null,initial:r[p],onSave:B,onClose:()=>i(null),editMode:!0})]})}function se(l){const s={};for(const d of l){const a=d.id??d.name??"";a&&(d.type==="array"?s[a]=[]:d.type==="object"||d.type==="schema"?s[a]=se(d.children??[]):s[a]="")}return s}function W({value:l,onChange:s,suggestions:d,label:a="Fields",onPayload:r,validate:t=!0,onValidityChange:p,variableGroups:i,initialValues:c,initialFormulaConfig:m,initialConditionConfig:y}){const[B,x]=h.useState(!1),[n,f]=h.useState(!1),[u,v]=h.useState(null),[g,w]=h.useState(m??{}),[T,k]=h.useState(y??{}),R=h.useRef(c??{}),A=h.useMemo(()=>se(l),[l]),$=h.useMemo(()=>c&&Object.keys(c).length>0?{...A,...c}:A,[A,c]),M=h.useMemo(()=>t?N.buildValidationSchema(l):void 0,[t,l]);h.useEffect(()=>{r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:R.current,evaluationPayload:N.buildEvaluationPayload({values:R.current,conditionConfig:T})})},[T,g,l]);const V=h.useCallback(z=>{R.current=z,r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:z,evaluationPayload:N.buildEvaluationPayload({values:z,conditionConfig:T})})},[l,g,T,r]);function P(z){s([...l,z])}function q(z){if(!u)return;const{containerFieldId:D,tabId:H}=u,U=l.map(I=>{if((I.id??I.name)!==D)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===H?{...O,fields:[...O.fields??[],z]}:O)}});s(U),v(null)}function C(z,D,H){const U=l.map(I=>{if((I.id??I.name)!==z)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===D?{...O,fields:(O.fields??[]).filter((Be,te)=>te!==H)}:O)}});s(U)}const ne=h.useMemo(()=>({openAddFieldDialog:(z,D)=>v({containerFieldId:z,tabId:D}),removeFieldFromTab:C}),[l,s]),K=e.jsxs("div",{className:"schema-builder-root",children:[l.length>0&&e.jsx("div",{className:"schema-builder-header",children:e.jsxs("div",{className:"schema-builder-actions",children:[e.jsx(o.Tooltip,{title:"Edit schema",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-outline",onClick:()=>f(!0),children:[e.jsx(S.MdSettings,{size:13})," Edit Schema"]})}),e.jsx(o.Tooltip,{title:"Add a new field",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-primary",onClick:()=>x(!0),children:[e.jsx(S.MdAdd,{size:14})," Add Field"]})})]})}),l.length>0?e.jsx(N.TabsEditContext.Provider,{value:ne,children:e.jsx(N.FlowForm,{schema:{layout:"flat",fields:l},initialValues:$,onSubmit:()=>{},validationSchema:M,onValidityChange:p,onValuesChange:r?V:void 0,formulaConfig:g,onFormulaConfigChange:w,conditionConfig:T,onConditionConfigChange:k})}):e.jsxs("div",{className:"schema-builder-empty-state",children:[e.jsx(ie.FaWpforms,{size:40,className:"schema-builder-empty-icon"}),e.jsx("p",{className:"schema-builder-empty-title",children:"Tell us what fields should be in the list, and assign values to them."}),e.jsx("div",{className:"schema-builder-empty-actions",children:e.jsx("button",{className:"btn",onClick:()=>x(!0),children:"Add field"})})]}),e.jsx(J,{open:B,onSave:P,onClose:()=>x(!1)}),e.jsx(ve,{open:n,value:l,onSave:s,onClose:()=>f(!1)}),e.jsx(J,{open:!!u,onSave:q,onClose:()=>v(null)})]});return i?e.jsxs(N.VariablePickerProvider,{groups:i,children:[e.jsx(N.VariablePicker,{width:260,mode:"popover"}),K]}):K}function Ce({fields:l,onOpen:s}){return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff",overflow:"hidden"},children:[l.length>0?e.jsx(o.Box,{sx:{px:1.5,py:1.25,display:"flex",flexWrap:"wrap",gap:.5},children:l.map((d,a)=>{const r=d.id??d.name??"";return e.jsx(o.Tooltip,{title:`${d.type} · ${r}`,placement:"top",children:e.jsx(o.Chip,{label:d.label||r,size:"small",sx:{fontSize:11,fontWeight:500,height:22,bgcolor:"#f1f5f9",color:"#334155",border:"1px solid #e2e8f0","& .MuiChip-label":{px:1}}})},a)})}):e.jsx(o.Box,{sx:{px:1.5,py:1.5},children:e.jsx(o.Typography,{sx:{fontSize:12,color:"#94a3b8"},children:"No fields defined yet"})}),e.jsx(o.Divider,{sx:{borderColor:"#f1f5f9"}}),e.jsxs(o.Box,{onClick:s,sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1,cursor:"pointer","&:hover":{bgcolor:"#f8fafc"},transition:"background 0.12s"},children:[l.length===0?e.jsx(S.MdAdd,{size:14,color:"#6366f1"}):e.jsx(S.MdSettings,{size:13,color:"#6366f1"}),e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:600,color:"#6366f1",flex:1},children:l.length===0?"Add fields":"Configure fields"}),e.jsx(S.MdArrowForward,{size:13,color:"#94a3b8"})]})]})}function Se({value:l,onChange:s,suggestions:d,onPayload:a,onDone:r,validate:t,onValidityChange:p,label:i="Fields",drawerTitle:c="Configure Fields",drawerWidth:m=580}){const[y,B]=h.useState(!1),[x,n]=h.useState({type:"list"}),[f,u]=h.useState(l),v=h.useRef(null),g=h.useRef(void 0),w=h.useRef(void 0),T=h.useRef(void 0),[k,R]=h.useState(null);function A(){u(l),n({type:"list"}),B(!0)}function $(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),s(f),B(!1),r==null||r(f,C)}function M(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),u(l),B(!1)}function V(){if(x.type!=="edit"||!k)return;const C=[...f];C[x.index]=k,u(C),n({type:"list"}),R(null)}function P(){n({type:"list"}),R(null)}const q=JSON.stringify(f)!==JSON.stringify(l);return x.type==="edit"&&f[x.index],e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:.5,mb:.75},children:i}),e.jsx(Ce,{fields:l,onOpen:A})]}),e.jsxs(o.Drawer,{anchor:"right",open:y,onClose:M,PaperProps:{sx:{width:m,display:"flex",flexDirection:"column",boxShadow:"-4px 0 24px rgba(0,0,0,0.12)",overflow:"hidden"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2,py:1.5,borderBottom:"1px solid #e2e8f0",flexShrink:0,gap:1},children:[x.type==="edit"&&e.jsx(o.Tooltip,{title:"Back to fields",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:P,sx:{color:"#64748b"},children:e.jsx(S.MdArrowBack,{size:17})})}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:x.type==="edit"?(k==null?void 0:k.label)||(k==null?void 0:k.id)||"Edit field":c}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:x.type==="edit"?"Configure field properties":`${f.length} field${f.length!==1?"s":""} defined`})]}),x.type==="list"&&e.jsx(o.Tooltip,{title:"Close",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:M,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})})]}),x.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:e.jsx(W,{value:f,onChange:u,suggestions:d,onPayload:C=>{v.current=C,g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig,a==null||a(C)},validate:t,onValidityChange:p,label:i,initialValues:g.current,initialFormulaConfig:w.current,initialConditionConfig:T.current})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[q?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:M,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:$,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),x.type==="edit"&&k&&e.jsx(le,{field:k,onChange:R,onSave:V,onCancel:P})]})]})}exports.FIELD_TYPE_OPTIONS=Z;exports.SchemaBuilder=W;exports.SchemaBuilderDrawer=Se;exports.useFlowForm=ae;
|
|
2
|
-
//# sourceMappingURL=SchemaBuilderDrawer-
|
|
1
|
+
"use strict";const h=require("react"),re=require("formik"),N=require("./index-C39URw6S.js"),e=require("react/jsx-runtime"),o=require("@mui/material"),S=require("react-icons/md"),ie=require("react-icons/fa6");function ae({schema:l,initialValues:s,onSubmit:d,showErrorsImmediately:a=!1}){const r=l.fields??[],t=h.useMemo(()=>N.buildValidationSchema(r),[r]),p=h.useMemo(()=>{if(a)return r.reduce((u,v)=>{const g=N.resolveFieldKey(v);return g&&(u[g]=!0),u},{})},[r,a]),[i,c]=h.useState({}),[m,y]=h.useState({}),B=h.useRef(s);h.useEffect(()=>{B.current!==s&&(B.current=s,c({}),y({}))},[s]);const x=re.useFormik({initialValues:s,validationSchema:t,initialTouched:p,validateOnMount:a,validateOnChange:!0,validateOnBlur:!0,enableReinitialize:!0,onSubmit:async u=>{const v=N.buildEvaluationPayload({values:u,conditionConfig:m});await d(u,v)}}),n=h.useCallback(()=>{x.submitForm()},[x]),f=h.useCallback(u=>{x.resetForm(u?{values:u}:void 0),c({}),y({})},[x]);return{values:x.values,errors:x.errors,isValid:x.isValid,isDirty:x.dirty,isSubmitting:x.isSubmitting,formulaConfig:i,conditionConfig:m,submit:n,reset:f,setFieldValue:x.setFieldValue,_schema:l,_formik:x,_formulaConfig:i,_onFormulaConfigChange:c,_conditionConfig:m,_onConditionConfigChange:y}}const Z=N.FlowForgeRegistry.getTypeOptions(),j="form-control font-14",b="text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1",F={fontSize:10,fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:.6,marginBottom:8,display:"block"},ce=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object (sub-fields)"},{value:"array",label:"Array (nested)"}],de=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}];function xe({value:l,onChange:s}){const d=l??12;return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Column width"}),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:de.map(a=>e.jsx(o.Tooltip,{title:`colSpan: ${a.value}`,placement:"top",children:e.jsx(o.Box,{component:"button",onClick:()=>s(a.value),sx:{flex:1,border:"1px solid",borderColor:d===a.value?"#6366f1":"#dee2e6",borderRadius:"6px",cursor:"pointer",bgcolor:d===a.value?"#eef2ff":"#fff",color:d===a.value?"#6366f1":"#6c757d",fontSize:11,fontWeight:600,py:.6,px:0,"&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:a.label})},a.value))}),e.jsx(o.Box,{sx:{display:"flex",gap:"3px",mt:.75},children:Array.from({length:12}).map((a,r)=>e.jsx(o.Box,{sx:{flex:1,height:4,borderRadius:"2px",bgcolor:r<d?"#6366f1":"#e2e8f0",transition:"background 0.12s"}},r))})]})}function Q({options:l=[],onChange:s}){function d(a,r,t){s(l.map((p,i)=>i===a?{...p,[r]:t}:p))}return e.jsxs(o.Box,{children:[e.jsxs("span",{className:b,children:["Options ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((a,r)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:a.label,onChange:t=>d(r,"label",t.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"Value",value:a.value,onChange:t=>d(r,"value",t.target.value)}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((t,p)=>p!==r)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},r))}),e.jsxs(o.Box,{component:"button",onClick:()=>s([...l,{label:"",value:""}]),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add option"]})]})}const ee=[{value:"operator",label:"Operator (predefined)"},{value:"select",label:"Select"},{value:"text",label:"Text"}];function pe({col:l,onChange:s,onDelete:d}){const a=l.type==="select",r=l.type==="operator";return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"7px",p:1.25,bgcolor:"#fff",display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:r?"#fef9c3":"#eef2ff",color:r?"#92400e":"#6366f1",flexShrink:0},children:r?"OPERATOR":l.type.toUpperCase()}),e.jsx(o.Box,{sx:{fontSize:12,fontWeight:600,color:"#0f172a",flex:1},children:l.label||l.id||"Unnamed"}),e.jsx(o.Box,{component:"button",onClick:d,sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Column type"}),e.jsx("select",{value:l.type,onChange:t=>s({...l,type:t.target.value,options:void 0}),className:j,style:{cursor:"pointer"},children:ee.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))})]}),e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Column key ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:`${j} ${l.id?"":"border-danger"}`,value:l.id,onChange:t=>s({...l,id:t.target.value}),placeholder:"e.g. field, operator, value"}),!l.id&&e.jsx("span",{style:{fontSize:10,color:"#dc3545"},children:"Required — used as data key"})]})]}),!r&&e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Label"}),e.jsx("input",{className:j,value:l.label??"",onChange:t=>s({...l,label:t.target.value||void 0}),placeholder:"Column label"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:t=>s({...l,placeholder:t.target.value||void 0}),placeholder:"Hint…"})]})]}),a&&e.jsx(Q,{options:l.options??[],onChange:t=>s({...l,options:t})}),r&&e.jsx(o.Box,{sx:{bgcolor:"#fefce8",border:"1px solid #fef08a",borderRadius:"6px",px:1.25,py:.75},children:e.jsx(o.Box,{sx:{fontSize:11,color:"#78350f"},children:"Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…"})}),!r&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:`formula-${l.id}`,checked:!!l.formula,onChange:t=>s({...l,formula:t.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:`formula-${l.id}`,className:b,style:{margin:0,cursor:"pointer"},children:"Formula input (chip editor)"})]})]})}function ue({condition:l,onChange:s}){const d=!!l;function a(){s(d?void 0:{fields:[]})}function r(i){if(!l)return;const c=i==="operator"?"operator":l.fields.filter(m=>m.type!=="operator").length===0?"field":"value";s({...l,fields:[...l.fields,{id:c,type:i}]})}function t(i,c){if(!l)return;const m=[...l.fields];m[i]=c,s({...l,fields:m})}function p(i){l&&s({...l,fields:l.fields.filter((c,m)=>m!==i)})}return e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:d?1.25:0},children:[e.jsx("input",{type:"checkbox",id:"enable-condition",checked:d,onChange:a,style:{cursor:"pointer",width:14,height:14}}),e.jsx("span",{style:{...F,margin:0,color:d?"#6366f1":"#94a3b8"},children:"Condition row"})]}),d&&l&&e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[l.fields.map((i,c)=>e.jsx(pe,{col:i,onChange:m=>t(c,m),onDelete:()=>p(c)},c)),e.jsx(o.Box,{sx:{display:"flex",gap:.5},children:ee.map(i=>e.jsxs(o.Box,{component:"button",onClick:()=>r(i.value),sx:{flex:1,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,py:.5,borderRadius:"6px",color:i.value==="operator"?"#92400e":"#6366f1","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:["+ ",i.value==="operator"?"Operator":i.label.split(" ")[0]]},i.value))}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap"},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:"allow-groups",checked:!!l.allowGroups,onChange:i=>s({...l,allowGroups:i.target.checked||void 0}),style:{cursor:"pointer",width:14,height:14}}),e.jsx("label",{htmlFor:"allow-groups",className:b,style:{margin:0,cursor:"pointer"},children:"Allow nested groups"})]}),l.allowGroups&&e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("label",{className:b,style:{margin:0},children:"Max depth"}),e.jsx("input",{type:"number",min:1,max:5,className:j,style:{width:60,textAlign:"center"},value:l.maxGroupDepth??"",onChange:i=>s({...l,maxGroupDepth:i.target.value?Number(i.target.value):void 0}),placeholder:"∞"})]})]})]})]})}function E({id:l,label:s,checked:d,onChange:a}){return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx("input",{type:"checkbox",id:l,checked:d,onChange:r=>a(r.target.checked),style:{cursor:"pointer",width:14,height:14,flexShrink:0}}),e.jsx("label",{htmlFor:l,className:b,style:{margin:0,cursor:"pointer"},children:s})]})}function he({views:l=[],onChange:s}){function d(r,t,p){s(l.map((i,c)=>c===r?{...i,[t]:p}:i))}function a(){const r=`tab${l.length+1}`;s([...l,{id:r,label:`Tab ${l.length+1}`}])}return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:"Views"}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:l.map((r,t)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{className:j,style:{flex:1},placeholder:"Label",value:r.label,onChange:p=>d(t,"label",p.target.value)}),e.jsx("input",{className:j,style:{flex:1},placeholder:"ID (no spaces)",value:r.id,onChange:p=>d(t,"id",p.target.value.replace(/\s/g,"_"))}),e.jsx(o.Box,{component:"button",onClick:()=>s(l.filter((p,i)=>i!==t)),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:e.jsx(S.MdClose,{size:13})})]},t))}),e.jsxs(o.Box,{component:"button",onClick:a,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:[e.jsx(S.MdAdd,{size:13})," Add view"]})]})}function _({label:l,value:s,options:d,onChange:a}){return e.jsxs(o.Box,{children:[e.jsx("span",{className:b,children:l}),e.jsx(o.Box,{sx:{display:"flex",border:"1px solid #dee2e6",borderRadius:"7px",overflow:"hidden"},children:d.map(r=>e.jsx(o.Box,{component:"button",onClick:()=>a(r.value),sx:{flex:1,border:"none",borderRight:"1px solid #dee2e6",cursor:"pointer",fontSize:12,fontWeight:600,py:.6,bgcolor:s===r.value?"#eef2ff":"#fff",color:s===r.value?"#6366f1":"#6c757d","&:last-child":{borderRight:"none"},"&:hover":{bgcolor:"#f5f3ff"}},children:r.label},r.value))})]})}function le({field:l,onChange:s,onSave:d,onCancel:a,noFooter:r}){const[t,p]=h.useState(!1),i=l.id??l.name??"",c=l,m=l.type==="select"||l.type==="descriptive-select"||l.type==="radio-group",y=N.FlowForgeRegistry.get(l.type),B=y==null?void 0:y.configSchema;function x(n,f){s({...l,[n]:f})}return e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto",px:2.5,py:2,display:"flex",flexDirection:"column",gap:1.75},children:[e.jsxs(o.Box,{children:[e.jsx("span",{style:F,children:"Required"}),e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Type"}),e.jsx("select",{value:l.type,onChange:n=>x("type",n.target.value),className:j,style:{cursor:"pointer"},children:Z.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:l.type==="tabs"?"1fr":"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Field ID ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.id??l.name??"",onChange:n=>x("id",n.target.value),placeholder:"e.g. email"})]}),l.type!=="tabs"&&e.jsxs(o.Box,{children:[e.jsxs("label",{className:b,children:["Label ",e.jsx("span",{style:{color:"#dc3545"},children:"*"})]}),e.jsx("input",{className:j,value:l.label??"",onChange:n=>x("label",n.target.value),placeholder:"Display label"})]})]}),l.type!=="tabs"&&e.jsx(xe,{value:l.colSpan,onChange:n=>x("colSpan",n===12?void 0:n)})]})]}),B&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Specific Settings"}),e.jsx(N.FlowForm,{schema:{layout:"flat",compact:!0,fields:B.fields},initialValues:l,onValuesChange:n=>s({...l,...n}),onSubmit:()=>{}})]}),l.type==="tabs"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1.5},children:[e.jsx("span",{style:F,children:"Content"}),e.jsx(he,{views:(c.tabs??[]).map(n=>({id:n.id,label:n.label})),onChange:n=>{const f=c.tabs??[],u=n.map(v=>{const g=f.find(w=>w.id===v.id);return g?{...g,...v}:{...v,fields:[]}});s({...l,tabs:u})}}),e.jsx("span",{style:{...F,marginTop:4},children:"Interaction"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Disabled"}),e.jsx("input",{className:j,value:c.disabledExpr??"",onChange:n=>s({...l,disabledExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Appearance"}),e.jsx(_,{label:"Alignment",value:c.alignment??"left",options:[{value:"left",label:"|←"},{value:"center-left",label:"←|"},{value:"center",label:"|·|"},{value:"center-right",label:"|→"},{value:"right",label:"→|"}],onChange:n=>s({...l,alignment:n})}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Hidden"}),e.jsx("input",{className:j,value:c.hiddenExpr??"",onChange:n=>s({...l,hiddenExpr:n.target.value||void 0}),placeholder:"false"})]}),e.jsx(_,{label:"Variant",value:c.variant??"line",options:[{value:"pill",label:"Pill"},{value:"line",label:"Line"}],onChange:n=>s({...l,variant:n})}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active color"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeColor??"#6366f1",onChange:n=>s({...l,activeColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeColor??"",onChange:n=>s({...l,activeColor:n.target.value||void 0}),placeholder:"#6366f1",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Active text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.activeTextColor??"#ffffff",onChange:n=>s({...l,activeTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.activeTextColor??"",onChange:n=>s({...l,activeTextColor:n.target.value||void 0}),placeholder:"auto",style:{flex:1}})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Inactive text"}),e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx("input",{type:"color",value:c.inactiveTextColor??"#64748b",onChange:n=>s({...l,inactiveTextColor:n.target.value}),style:{width:28,height:28,border:"1px solid #dee2e6",borderRadius:6,cursor:"pointer",padding:2,background:"#fff"}}),e.jsx("input",{className:j,value:c.inactiveTextColor??"",onChange:n=>s({...l,inactiveTextColor:n.target.value||void 0}),placeholder:"#64748b",style:{flex:1}})]})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Styles"}),e.jsx("input",{className:j,value:c.styles??"",onChange:n=>s({...l,styles:n.target.value||void 0}),placeholder:"None"})]}),e.jsx("span",{style:{...F,marginTop:4},children:"Spacing"}),e.jsx(_,{label:"Height",value:c.height??"auto",options:[{value:"auto",label:"Auto"},{value:"fixed",label:"Fixed"}],onChange:n=>s({...l,height:n})}),e.jsx(_,{label:"Margin",value:c.margin??"normal",options:[{value:"normal",label:"Normal"},{value:"none",label:"None"}],onChange:n=>s({...l,margin:n})})]}),m&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx("span",{style:F,children:"Options"}),e.jsx(Q,{options:c.options??[],onChange:n=>s({...l,options:n})})]}),l.type==="array"&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5,display:"flex",flexDirection:"column",gap:1},children:[e.jsx("span",{style:F,children:"Array settings"}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item type"}),e.jsx("select",{className:j,style:{cursor:"pointer"},value:c.itemType??"text",onChange:n=>s({...l,itemType:n.target.value}),children:ce.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item label"}),e.jsx("input",{className:j,value:c.itemLabel??"",onChange:n=>s({...l,itemLabel:n.target.value||void 0}),placeholder:'e.g. "Member"'})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Add button label"}),e.jsx("input",{className:j,value:c.addLabel??"",onChange:n=>s({...l,addLabel:n.target.value||void 0}),placeholder:"Add item"})]})]}),e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Min items"}),e.jsx("input",{type:"number",min:0,className:j,value:c.minItems??"",onChange:n=>s({...l,minItems:n.target.value?Number(n.target.value):void 0}),placeholder:"0"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Max items"}),e.jsx("input",{type:"number",min:1,className:j,value:c.maxItems??"",onChange:n=>s({...l,maxItems:n.target.value?Number(n.target.value):void 0}),placeholder:"∞"})]})]}),!["object","array","select"].includes(c.itemType??"text")&&e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Item placeholder"}),e.jsx("input",{className:j,value:c.itemPlaceholder??"",onChange:n=>s({...l,itemPlaceholder:n.target.value||void 0}),placeholder:"Enter value…"})]})]}),e.jsx(ue,{condition:l.condition,onChange:n=>s({...l,condition:n})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",pt:1.5},children:[e.jsx(o.Box,{component:"button",onClick:()=>p(n=>!n),sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:.5,p:0,mb:t?1.25:0},children:e.jsxs("span",{style:{...F,margin:0,color:t?"#6366f1":"#94a3b8"},children:[t?"▾":"▸"," Optional settings"]})}),e.jsx(o.Collapse,{in:t,children:e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1},children:[e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Placeholder"}),e.jsx("input",{className:j,value:l.placeholder??"",onChange:n=>x("placeholder",n.target.value||void 0),placeholder:"Hint text…"})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Helper text"}),e.jsx("input",{className:j,value:l.helperText??"",onChange:n=>x("helperText",n.target.value||void 0),placeholder:"Description…"})]})]}),e.jsxs(o.Box,{children:[e.jsx("label",{className:b,children:"Info tooltip"}),e.jsx("input",{className:j,value:l.info??"",onChange:n=>x("info",n.target.value||void 0),placeholder:"Shown in ℹ tooltip"})]}),e.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5},children:[e.jsx(E,{id:`${i}-req`,label:"Required",checked:!!l.required,onChange:n=>x("required",n||void 0)}),e.jsx(E,{id:`${i}-dis`,label:"Disabled",checked:!!l.disabled,onChange:n=>x("disabled",n||void 0)}),e.jsx(E,{id:`${i}-hid`,label:"Hidden",checked:!!l.hidden,onChange:n=>x("hidden",n||void 0)}),e.jsx(E,{id:`${i}-opt`,label:"Show optional",checked:!!l.showOptional,onChange:n=>x("showOptional",n||void 0)}),e.jsx(E,{id:`${i}-div`,label:"Divider after",checked:!!l.dividerAfter,onChange:n=>x("dividerAfter",n||void 0)}),e.jsx(E,{id:`${i}-frm`,label:"Formula input",checked:!!l.formula,onChange:n=>x("formula",n||void 0)})]})]})})]})]}),!r&&e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",gap:1,justifyContent:"flex-end",bgcolor:"#f8fafc",flexShrink:0},children:[e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:d,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Save"]})]})]})}const L={text:"#0f172a",textMuted:"#64748b",borderInput:"rgba(0,0,0,0.23)",bg:"#ffffff"},fe={md:"6px"},oe={sm:11,md:13},G={width:"100%",fontSize:oe.md,fontFamily:"inherit",padding:"8px 12px",border:`1px solid ${L.borderInput}`,borderRadius:fe.md,outline:"none",background:L.bg,color:L.text,boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s"};function X(){return{type:"text",id:"",label:"",colSpan:12}}function be(l){return l.type==="object"||l.type==="array"||l.type==="schema"}function me(l){if(l.type==="object")return"Child Fields";if(l.type==="schema")return"Schema Fields";const s=l.itemType??"text";return s==="object"?"Item Fields":s==="select"?"Item Options":"Item Config"}function ge({field:l,onChange:s}){var r;const d=l,a=d.itemType??"text";if(l.type==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields nested inside this object. Each child field can itself be an object or array."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Child fields"})]});if(l.type==="schema")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value."}),e.jsx(W,{value:l.children??[],onChange:t=>s({...l,children:t}),label:"Schema fields"})]});if(l.type==="array"){if(a==="object")return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Define the fields for each item in the array. Each item will be an object with these fields."}),e.jsx(W,{value:d.itemFields??[],onChange:t=>s({...l,itemFields:t}),label:"Item fields"})]});if(a==="select"){const t=d.itemOptions??[];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Options available in each select item."}),e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5,mb:.75},children:t.map((p,i)=>e.jsxs(o.Box,{sx:{display:"flex",gap:.5,alignItems:"center"},children:[e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Label",value:p.label,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,label:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx("input",{style:{...G,flex:1,padding:"6px 10px"},placeholder:"Value",value:p.value,onChange:c=>{const m=t.map((y,B)=>B===i?{...y,value:c.target.value}:y);s({...l,itemOptions:m})}}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:t.filter((c,m)=>m!==i)}),sx:{background:"none",border:"none",cursor:"pointer",color:"#94a3b8",display:"flex",p:.25,"&:hover":{color:"#dc2626"}},children:"✕"})]},i))}),e.jsx(o.Box,{component:"button",onClick:()=>s({...l,itemOptions:[...t,{label:"",value:""}]}),sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"1px dashed #dee2e6",cursor:"pointer",fontSize:11,fontWeight:600,px:1,py:.5,borderRadius:"6px",color:"#6366f1",width:"100%",justifyContent:"center","&:hover":{borderColor:"#6366f1",bgcolor:"#f5f3ff"}},children:"+ Add option"})]})}if(a==="array"){const t=((r=d.itemSchema)==null?void 0:r.itemType)??"text",p=[{value:"text",label:"Text"},{value:"number",label:"Number"},{value:"email",label:"Email"},{value:"url",label:"URL"},{value:"password",label:"Password"},{value:"select",label:"Select"},{value:"object",label:"Object"}];return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsx(o.Typography,{sx:{fontSize:12,color:"#64748b",mb:2},children:"Each item is itself an array. Configure the type of items inside the nested array."}),e.jsx("label",{style:{fontSize:oe.sm,fontWeight:600,color:L.textMuted,display:"block",marginBottom:3},children:"Nested item type"}),e.jsx("select",{style:{...G,padding:"6px 10px",cursor:"pointer"},value:t,onChange:i=>s({...l,itemSchema:{...d.itemSchema??{},itemType:i.target.value}}),children:p.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))})]})}return e.jsx(o.Box,{sx:{p:2.5},children:e.jsxs(o.Box,{sx:{border:"1.5px dashed #e2e8f0",borderRadius:"8px",py:3,textAlign:"center"},children:[e.jsxs(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:["No extra configuration needed for ",e.jsx("strong",{children:a})," items."]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#cbd5e1",mt:.5},children:"Item placeholder and labels are set in the previous step."})]})})}return null}function je({field:l}){var p;const[s,d]=h.useState({}),a=l.id??l.name??"preview",r=[{value:3,label:"1/4"},{value:4,label:"1/3"},{value:6,label:"1/2"},{value:8,label:"2/3"},{value:12,label:"Full"}],t=l.colSpan&&l.colSpan<12?((p=r.find(i=>i.value===l.colSpan))==null?void 0:p.label)??l.colSpan:"Full";return e.jsxs(o.Box,{sx:{p:2.5},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:2,px:1.25,py:.75,bgcolor:"#f0fdf4",border:"1px solid #bbf7d0",borderRadius:"7px"},children:[e.jsx(o.Typography,{sx:{fontSize:11,color:"#15803d",fontWeight:500,flex:1},children:"Live preview — interact to test the field"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#64748b"},children:["Width: ",t]})]}),e.jsx(N.FlowForm,{schema:{layout:"flat",fields:[l]},initialValues:{[a]:l.type==="array"?[]:l.type==="object"||l.type==="schema"?{}:""},onSubmit:()=>{},conditionConfig:s,onConditionConfigChange:d})]})}function J({open:l,initial:s,onSave:d,onClose:a,editMode:r=!1}){const[t,p]=h.useState(1),[i,c]=h.useState(()=>s??X());function m(){c(s??X()),p(1)}const y=be(i),B=y?3:2,x=y?["Configure",me(i),"Preview"]:["Configure","Preview"],n=!!(i.id||i.name)&&!!i.type;function f(){p(k=>Math.min(k+1,B))}function u(){p(k=>Math.max(k-1,1))}function v(){d(i),a()}const g=t-1,w=t===B,T=y&&t===3||!y&&t===2;return e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:m},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"90vh"}},children:[e.jsxs(o.Box,{sx:{px:2.5,pt:1.75,pb:0,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mb:1.5},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a",flex:1},children:r?"Edit Field":"Add Field"}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Stepper,{activeStep:g,sx:{pb:1.5},children:x.map((k,R)=>e.jsx(o.Step,{completed:g>R,children:e.jsx(o.StepLabel,{children:k})},k))})]}),e.jsxs(o.Box,{sx:{flex:1,overflowY:"auto"},children:[t===1&&e.jsx(le,{field:i,onChange:c,onSave:f,onCancel:a,noFooter:!0}),t===2&&y&&e.jsx(ge,{field:i,onChange:c}),T&&e.jsx(je,{field:i})]}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[t>1&&e.jsxs(o.Box,{component:"button",onClick:u,sx:{display:"flex",alignItems:"center",gap:.5,background:"none",border:"none",cursor:"pointer",fontSize:13,fontWeight:500,color:"#6c757d",px:0,"&:hover":{color:"#0f172a"}},children:[e.jsx(S.MdArrowBack,{size:14})," Back"]}),e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),w?e.jsxs(o.Box,{component:"button",onClick:v,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," ",r?"Save changes":"Add field"]}):e.jsx(o.Box,{component:"button",onClick:f,disabled:!n,sx:{border:"none",cursor:n?"pointer":"not-allowed",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:n?"#6366f1":"#c7d2fe",color:"#fff","&:hover":{bgcolor:n?"#4f46e5":"#c7d2fe"}},children:"Next →"})]})]})}function ye({field:l,index:s,total:d,onEdit:a,onDelete:r,onMoveUp:t,onMoveDown:p}){const i=l.label||l.id||l.name||"Untitled",c=l.id??l.name??"";return e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:1.5,py:1,border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff"},children:[e.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.25,color:"#cbd5e1"},children:[e.jsx(o.Box,{component:"button",onClick:t,disabled:s===0,sx:{background:"none",border:"none",p:0,cursor:s===0?"default":"pointer",color:s===0?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===0?"#e2e8f0":"#475569"}},children:"▲"}),e.jsx(o.Box,{component:"button",onClick:p,disabled:s===d-1,sx:{background:"none",border:"none",p:0,cursor:s===d-1?"default":"pointer",color:s===d-1?"#e2e8f0":"#94a3b8",lineHeight:1,fontSize:10,"&:hover":{color:s===d-1?"#e2e8f0":"#475569"}},children:"▼"})]}),e.jsx(o.Box,{sx:{fontSize:10,fontWeight:700,px:.75,py:.2,borderRadius:"4px",bgcolor:"#eef2ff",color:"#6366f1",flexShrink:0},children:l.type}),e.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[e.jsxs(o.Typography,{sx:{fontSize:13,fontWeight:600,color:"#0f172a",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i,l.required&&e.jsx(o.Box,{component:"span",sx:{color:"#dc3545",ml:.25},children:"*"})]}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8",fontFamily:"monospace"},children:c})]}),e.jsx(o.Tooltip,{title:"Edit field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#f1f5f9",color:"#475569"}},children:e.jsx(S.MdEdit,{size:14})})}),e.jsx(o.Tooltip,{title:"Remove field",placement:"top",children:e.jsx(o.Box,{component:"button",onClick:r,sx:{background:"none",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:"6px",p:0,color:"#94a3b8","&:hover":{bgcolor:"#fee2e2",color:"#dc2626"}},children:e.jsx(S.MdDeleteOutline,{size:16})})})]})}function ve({open:l,value:s,onSave:d,onClose:a}){const[r,t]=h.useState(s),[p,i]=h.useState(null);function c(){t(s),i(null)}function m(f){t(u=>u.filter((v,g)=>g!==f))}function y(f,u){t(v=>{const g=[...v],w=f+u;return w<0||w>=g.length?v:([g[f],g[w]]=[g[w],g[f]],g)})}function B(f){p!==null&&(t(u=>{const v=[...u];return v[p]=f,v}),i(null))}function x(){d(r),a()}const n=JSON.stringify(r)!==JSON.stringify(s);return e.jsxs(e.Fragment,{children:[e.jsxs(o.Dialog,{open:l,onClose:a,TransitionProps:{onEnter:c},maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column",maxHeight:"85vh"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2.5,py:1.75,borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:"Edit Schema"}),e.jsxs(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:[r.length," field",r.length!==1?"s":""," defined"]})]}),e.jsx(o.IconButton,{size:"small",onClick:a,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})]}),e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:r.length===0?e.jsx(o.Box,{sx:{border:"1.5px dashed rgba(0,0,0,0.12)",borderRadius:"8px",py:4,textAlign:"center"},children:e.jsx(o.Typography,{sx:{fontSize:13,color:"#94a3b8"},children:"No fields defined yet"})}):e.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:r.map((f,u)=>e.jsx(ye,{field:f,index:u,total:r.length,onEdit:()=>i(u),onDelete:()=>m(u),onMoveUp:()=>y(u,-1),onMoveDown:()=>y(u,1)},`${f.id??f.name}-${u}`))})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[n?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:a,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:x,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),p!==null&&e.jsx(J,{open:p!==null,initial:r[p],onSave:B,onClose:()=>i(null),editMode:!0})]})}function se(l){const s={};for(const d of l){const a=d.id??d.name??"";a&&(d.type==="array"?s[a]=[]:d.type==="object"||d.type==="schema"?s[a]=se(d.children??[]):s[a]="")}return s}function W({value:l,onChange:s,suggestions:d,label:a="Fields",onPayload:r,validate:t=!0,onValidityChange:p,variableGroups:i,initialValues:c,initialFormulaConfig:m,initialConditionConfig:y}){const[B,x]=h.useState(!1),[n,f]=h.useState(!1),[u,v]=h.useState(null),[g,w]=h.useState(m??{}),[T,k]=h.useState(y??{}),R=h.useRef(c??{}),A=h.useMemo(()=>se(l),[l]),$=h.useMemo(()=>c&&Object.keys(c).length>0?{...A,...c}:A,[A,c]),M=h.useMemo(()=>t?N.buildValidationSchema(l):void 0,[t,l]);h.useEffect(()=>{r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:R.current,evaluationPayload:N.buildEvaluationPayload({values:R.current,conditionConfig:T})})},[T,g,l]);const V=h.useCallback(z=>{R.current=z,r&&r({schema:l,formulaConfig:g,conditionConfig:T,conditionExpressions:N.serializeConditionExpressions(T),values:z,evaluationPayload:N.buildEvaluationPayload({values:z,conditionConfig:T})})},[l,g,T,r]);function P(z){s([...l,z])}function q(z){if(!u)return;const{containerFieldId:D,tabId:H}=u,U=l.map(I=>{if((I.id??I.name)!==D)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===H?{...O,fields:[...O.fields??[],z]}:O)}});s(U),v(null)}function C(z,D,H){const U=l.map(I=>{if((I.id??I.name)!==z)return I;const Y=I.tabs??[];return{...I,tabs:Y.map(O=>O.id===D?{...O,fields:(O.fields??[]).filter((Be,te)=>te!==H)}:O)}});s(U)}const ne=h.useMemo(()=>({openAddFieldDialog:(z,D)=>v({containerFieldId:z,tabId:D}),removeFieldFromTab:C}),[l,s]),K=e.jsxs("div",{className:"schema-builder-root",children:[l.length>0&&e.jsx("div",{className:"schema-builder-header",children:e.jsxs("div",{className:"schema-builder-actions",children:[e.jsx(o.Tooltip,{title:"Edit schema",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-outline",onClick:()=>f(!0),children:[e.jsx(S.MdSettings,{size:13})," Edit Schema"]})}),e.jsx(o.Tooltip,{title:"Add a new field",placement:"top",children:e.jsxs("button",{className:"sb-btn sb-btn-primary",onClick:()=>x(!0),children:[e.jsx(S.MdAdd,{size:14})," Add Field"]})})]})}),l.length>0?e.jsx(N.TabsEditContext.Provider,{value:ne,children:e.jsx(N.FlowForm,{schema:{layout:"flat",fields:l},initialValues:$,onSubmit:()=>{},validationSchema:M,onValidityChange:p,onValuesChange:r?V:void 0,formulaConfig:g,onFormulaConfigChange:w,conditionConfig:T,onConditionConfigChange:k})}):e.jsxs("div",{className:"schema-builder-empty-state",children:[e.jsx(ie.FaWpforms,{size:40,className:"schema-builder-empty-icon"}),e.jsx("p",{className:"schema-builder-empty-title",children:"Tell us what fields should be in the list, and assign values to them."}),e.jsx("div",{className:"schema-builder-empty-actions",children:e.jsx("button",{className:"btn",onClick:()=>x(!0),children:"Add field"})})]}),e.jsx(J,{open:B,onSave:P,onClose:()=>x(!1)}),e.jsx(ve,{open:n,value:l,onSave:s,onClose:()=>f(!1)}),e.jsx(J,{open:!!u,onSave:q,onClose:()=>v(null)})]});return i?e.jsxs(N.VariablePickerProvider,{groups:i,children:[e.jsx(N.VariablePicker,{width:260,mode:"popover"}),K]}):K}function Ce({fields:l,onOpen:s}){return e.jsxs(o.Box,{sx:{border:"1px solid #e2e8f0",borderRadius:"8px",bgcolor:"#fff",overflow:"hidden"},children:[l.length>0?e.jsx(o.Box,{sx:{px:1.5,py:1.25,display:"flex",flexWrap:"wrap",gap:.5},children:l.map((d,a)=>{const r=d.id??d.name??"";return e.jsx(o.Tooltip,{title:`${d.type} · ${r}`,placement:"top",children:e.jsx(o.Chip,{label:d.label||r,size:"small",sx:{fontSize:11,fontWeight:500,height:22,bgcolor:"#f1f5f9",color:"#334155",border:"1px solid #e2e8f0","& .MuiChip-label":{px:1}}})},a)})}):e.jsx(o.Box,{sx:{px:1.5,py:1.5},children:e.jsx(o.Typography,{sx:{fontSize:12,color:"#94a3b8"},children:"No fields defined yet"})}),e.jsx(o.Divider,{sx:{borderColor:"#f1f5f9"}}),e.jsxs(o.Box,{onClick:s,sx:{display:"flex",alignItems:"center",gap:.75,px:1.5,py:1,cursor:"pointer","&:hover":{bgcolor:"#f8fafc"},transition:"background 0.12s"},children:[l.length===0?e.jsx(S.MdAdd,{size:14,color:"#6366f1"}):e.jsx(S.MdSettings,{size:13,color:"#6366f1"}),e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:600,color:"#6366f1",flex:1},children:l.length===0?"Add fields":"Configure fields"}),e.jsx(S.MdArrowForward,{size:13,color:"#94a3b8"})]})]})}function Se({value:l,onChange:s,suggestions:d,onPayload:a,onDone:r,validate:t,onValidityChange:p,label:i="Fields",drawerTitle:c="Configure Fields",drawerWidth:m=580}){const[y,B]=h.useState(!1),[x,n]=h.useState({type:"list"}),[f,u]=h.useState(l),v=h.useRef(null),g=h.useRef(void 0),w=h.useRef(void 0),T=h.useRef(void 0),[k,R]=h.useState(null);function A(){u(l),n({type:"list"}),B(!0)}function $(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),s(f),B(!1),r==null||r(f,C)}function M(){const C=v.current;C&&(g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig),u(l),B(!1)}function V(){if(x.type!=="edit"||!k)return;const C=[...f];C[x.index]=k,u(C),n({type:"list"}),R(null)}function P(){n({type:"list"}),R(null)}const q=JSON.stringify(f)!==JSON.stringify(l);return x.type==="edit"&&f[x.index],e.jsxs(e.Fragment,{children:[e.jsxs(o.Box,{children:[e.jsx(o.Typography,{sx:{fontSize:12,fontWeight:700,color:"#64748b",textTransform:"uppercase",letterSpacing:.5,mb:.75},children:i}),e.jsx(Ce,{fields:l,onOpen:A})]}),e.jsxs(o.Drawer,{anchor:"right",open:y,onClose:M,PaperProps:{sx:{width:m,display:"flex",flexDirection:"column",boxShadow:"-4px 0 24px rgba(0,0,0,0.12)",overflow:"hidden"}},children:[e.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:2,py:1.5,borderBottom:"1px solid #e2e8f0",flexShrink:0,gap:1},children:[x.type==="edit"&&e.jsx(o.Tooltip,{title:"Back to fields",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:P,sx:{color:"#64748b"},children:e.jsx(S.MdArrowBack,{size:17})})}),e.jsxs(o.Box,{sx:{flex:1},children:[e.jsx(o.Typography,{sx:{fontSize:14,fontWeight:700,color:"#0f172a"},children:x.type==="edit"?(k==null?void 0:k.label)||(k==null?void 0:k.id)||"Edit field":c}),e.jsx(o.Typography,{sx:{fontSize:11,color:"#94a3b8"},children:x.type==="edit"?"Configure field properties":`${f.length} field${f.length!==1?"s":""} defined`})]}),x.type==="list"&&e.jsx(o.Tooltip,{title:"Close",placement:"bottom",children:e.jsx(o.IconButton,{size:"small",onClick:M,sx:{color:"#94a3b8"},children:e.jsx(S.MdClose,{size:17})})})]}),x.type==="list"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{sx:{flex:1,overflowY:"auto",p:2.5},children:e.jsx(W,{value:f,onChange:u,suggestions:d,onPayload:C=>{v.current=C,g.current=C.values,w.current=C.formulaConfig,T.current=C.conditionConfig,a==null||a(C)},validate:t,onValidityChange:p,label:i,initialValues:g.current,initialFormulaConfig:w.current,initialConditionConfig:T.current})}),e.jsxs(o.Box,{sx:{borderTop:"1px solid #e2e8f0",px:2.5,py:1.5,display:"flex",alignItems:"center",gap:1,flexShrink:0,bgcolor:"#f8fafc"},children:[q?e.jsx(o.Typography,{sx:{fontSize:11,color:"#f59e0b",fontWeight:500,flex:1},children:"Unsaved changes"}):e.jsx(o.Box,{sx:{flex:1}}),e.jsx(o.Box,{component:"button",onClick:M,sx:{background:"none",border:"1px solid #dee2e6",cursor:"pointer",fontSize:13,fontWeight:500,px:2,py:.75,borderRadius:"7px",color:"#6c757d","&:hover":{bgcolor:"#f8f9fa"}},children:"Cancel"}),e.jsxs(o.Box,{component:"button",onClick:$,sx:{border:"none",cursor:"pointer",fontSize:13,fontWeight:600,px:2.5,py:.75,borderRadius:"7px",bgcolor:"#6366f1",color:"#fff",display:"flex",alignItems:"center",gap:.75,"&:hover":{bgcolor:"#4f46e5"}},children:[e.jsx(S.MdCheck,{size:15})," Done"]})]})]}),x.type==="edit"&&k&&e.jsx(le,{field:k,onChange:R,onSave:V,onCancel:P})]})]})}exports.FIELD_TYPE_OPTIONS=Z;exports.SchemaBuilder=W;exports.SchemaBuilderDrawer=Se;exports.useFlowForm=ae;
|
|
2
|
+
//# sourceMappingURL=SchemaBuilderDrawer-CmSfZyyx.js.map
|