easy_flow 0.46.0 → 0.48.0
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.
- checksums.yaml +4 -4
- data/app/assets/builds/easy_flow/canvas.js +1 -1
- data/app/controllers/concerns/easy_flow/manage/draws_canvas.rb +2 -1
- data/app/javascript/easy_flow/canvas/Canvas.jsx +56 -51
- data/app/javascript/easy_flow/canvas/Control.jsx +8 -1
- data/app/javascript/easy_flow/canvas/Details.jsx +37 -0
- data/app/javascript/easy_flow/canvas/Drawer.jsx +49 -0
- data/app/javascript/easy_flow/canvas/Inspector.jsx +22 -7
- data/app/javascript/easy_flow/canvas/Panel.jsx +3 -9
- data/app/models/easy_flow/canvas.rb +3 -3
- data/app/models/easy_flow/check_list.rb +47 -0
- data/app/models/easy_flow/settings.rb +5 -1
- data/app/models/easy_flow/step_type/declaration.rb +15 -2
- data/app/models/easy_flow/step_type/shown_code.rb +9 -0
- data/app/models/easy_flow/step_type/shown_values.rb +10 -0
- data/app/models/easy_flow/step_type.rb +11 -1
- data/lib/easy_flow/host.rb +11 -1
- data/lib/easy_flow/version.rb +1 -1
- data/lib/easy_flow.rb +1 -1
- data/the_local/agents/easy_flow-develop.md +5 -1
- data/the_local/agents/easy_flow-info.md +7 -5
- data/the_local/agents/easy_flow-install.md +2 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ee73e25b94df6a0b978b07ec0c4770a592182ccba5673fa778c4aa8b97ab10d
|
|
4
|
+
data.tar.gz: acfbd9706813c21dd957ee45f1548afa081c1f1d39c0a093d120b686e385e73f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7de86983c7f99ab9a282c8969921efc770a233c3dcf636e5e8a6d8befc7f1dac97d4f485c8809bb00b0d7788ba594f5a38ba1fa40125bb75c774083995dcb74f
|
|
7
|
+
data.tar.gz: 9e3c18a7ac8329fa0cf1d3415e9275468183c256571490d560345b1825553abdf21361f29fcd7ae069c0766029344d9455255e1dd7d37f35025d9c891f33a144
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var Ce=globalThis.ReactDOM;var{createPortal:Zo,createRoot:ft,flushSync:Ro,hydrateRoot:tr,preconnect:er,prefetchDNS:or,preinit:rr,preinitModule:nr,preload:sr,preloadModule:ar,requestFormReset:ir,unstable_batchedUpdates:lr,useFormState:dr,useFormStatus:cr,version:pr}=Ce;var gt=globalThis.React,o=gt,{Children:mr,Component:fr,Fragment:gr,PureComponent:hr,StrictMode:yr,Suspense:xr,cloneElement:br,createContext:vr,createElement:wr,createRef:kr,forwardRef:Sr,isValidElement:Cr,lazy:Nr,memo:zr,startTransition:Br,useCallback:Tr,useContext:Er,useDebugValue:_r,useDeferredValue:Dr,useEffect:L,useId:Ar,useImperativeHandle:Or,useLayoutEffect:ht,useMemo:j,useReducer:Pr,useRef:et,useState:S,useSyncExternalStore:$r,useTransition:Lr}=gt;var yt=new Map,V=new Map,ot=(t,e)=>yt.set(t,e),xt=()=>{V.forEach(t=>t.unmount()),V.clear()},bt=(t,e)=>t.querySelectorAll("[data-react-ui]").forEach(n=>{if(V.has(n))return;let r=yt.get(n.dataset.reactUi),a=e(n);V.set(n,a),a.render(o.createElement(r,JSON.parse(n.dataset.props)))});var vt=(t,e)=>{let n=()=>bt(t,e);t.addEventListener("turbo:load",n),t.addEventListener("turbo:frame-load",n),t.addEventListener("turbo:before-cache",xt),t.readyState==="loading"?t.addEventListener("DOMContentLoaded",n):n()};var E=(...t)=>t.filter(Boolean).join(" ");var Ne={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},ze={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Be=({variant:t="primary",size:e="md",className:n,children:r,...a})=>{let l=a.href?"a":"button";return o.createElement(l,{...a,className:E("ks-button",Ne[t],ze[e],n)},r)},v=Be;var Te="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ee="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",_e="border border-accent-600 bg-accent-600 text-white",De=({name:t,connected:e,armed:n,onArm:r,connecting:a})=>o.createElement("button",{onClick:l=>{a||(l.stopPropagation(),r(l))},title:n?"Now choose a step to connect to":"Connect this branch",className:n?_e:e?Ee:Te,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},t||"next"),wt=De;var Ae={width:240,boxSizing:"border-box",borderRadius:8},Oe={minWidth:120,boxSizing:"border-box",borderRadius:6},Pe={padding:"8px 14px",textAlign:"center",fontWeight:600},$e={fontWeight:600,lineHeight:1.3},Le={fontSize:12,fontWeight:500,lineHeight:1.3},Ie=(t,e,n)=>{let r=n?"ring-4 ring-accent-600/15":"shadow-sm";return t||n&&!e?`border-accent-600 ${r}`:e?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Me=(t,e)=>e&&t.label===t.id&&t.type_name||t.label,je=(t,e,n)=>n?e===t.type_name?null:t.type_name:t.type,He=({node:t,selected:e,armed:n,connecting:r,onSelect:a,onOpen:l,onArm:d,onDragEnd:i,onDragStart:p,hideStepTypeCodes:h,branches:b=[],compact:m=!1,typeAbove:g=m})=>{let f=t.begins_here||t.ends_here,u=t.begins_here,k=t.ends_here?[]:t.ports,w=r&&!u,C=Me(t,h),T=je(t,C,h);return o.createElement("div",{ref:t.ref,"data-step":t.id,draggable:!u,onDragStart:x=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",t.id),p()},onDragEnd:i,onClick:t.opens&&!r?()=>l(t.opens):a,className:`bg-white ${m&&!e?"border":"border-2"} dark:bg-zinc-900 ${Ie(w,t.violations.length>0,e)}`,style:{...m?Oe:Ae,padding:f?0:m?"8px 10px":"12px 14px",cursor:u?"default":r?"crosshair":"grab"}},!f&&g&&T&&o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},T),f&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Pe},C),!f&&o.createElement("div",{style:m?Le:$e},C),t.violations.length>0&&o.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${t.violations.length} error${t.violations.length===1?"":"s"}`),!f&&t.summary&&t.violations.length===0&&o.createElement("div",{className:e?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},t.summary),!f&&!g&&T&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},T),t.picture_url&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),t.starts_a_flow&&o.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),t.opens&&o.createElement(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:x=>{x.stopPropagation(),a()}},"Settings"),b.map(x=>o.createElement("div",{key:x,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},x)),k.length>0&&o.createElement("div",{style:{padding:t.begins_here?"0 14px 8px":"10px 0 0"}},k.map(x=>o.createElement(wt,{key:x,name:x,connected:t.connected.includes(x),connecting:r,armed:n===x,onArm:y=>d(x,y)}))))},rt=He;var kt={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},We={...kt,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},Fe=({node:t,header:e,onSelect:n,compact:r=!1})=>o.createElement("div",{ref:t.ref,"data-group-header":t.id,onClick:n,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?We:kt,...n?{}:{cursor:"default"}}},e),Y=Fe;var Ve=({id:t,bounds:e,onDrop:n})=>o.createElement("div",{"data-group-box":t,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),n()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...e}}),St=Ve;var Ye=t=>t!=null&&t!==""&&typeof t!="object",Ue=["integer","float"],Ge=(t,e,n)=>n&&e.labels?.[t]||t,U=(t,e,n)=>{let r=Object.keys(e?.fields||{}).filter(a=>Ye(t.config[a])).map(a=>`${Ge(a,e,n)}${Ue.includes(e.fields[a])?"":":"} ${t.config[a]}`);return[n&&t.type_name||t.type,...r].join(" \xB7 ")};var Ct=(t,e,n)=>{let r=Math.min(...t.map(i=>i.left))-e.left+n.scrollLeft-12,a=Math.min(...t.map(i=>i.top))-e.top+n.scrollTop-10,l=Math.max(...t.map(i=>i.left+i.width))-e.left+n.scrollLeft+12,d=Math.max(...t.map(i=>i.top+i.height))-e.top+n.scrollTop+10;return{left:r,top:a,width:l-r,height:d-a}},Xe=({left:t,top:e,width:n,height:r},a)=>a.x>=t&&a.x<=t+n&&a.y>=e&&a.y<=e+r,Nt=(t,e)=>t.find(n=>Xe(n.bounds,e))?.id||null,zt=(t,e)=>t.filter(n=>!e.some(r=>r.id===n.source&&r.holds?.includes(n.target))),Bt=(t,e)=>e.some(n=>n.holds?.includes(t.id)&&!n.loose&&n.row===t.row-1);var nt=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],Tt=(t,e)=>({...e?.choices||{},...t?.choices||{}});var qe=({as:t="input",disabled:e,className:n,...r})=>o.createElement(t,{...r,disabled:e,className:E("ks-input",e&&"ks-input-disabled",n)}),A=qe;var Je=t=>o.createElement(A,{...t,as:"select"}),Et=Je;var Ke=({className:t,...e})=>o.createElement("input",{type:"checkbox",...e,className:E("ks-checkbox",t)}),G=Ke;var _t=t=>(t||[]).map(e=>typeof e=="object"?e:{value:e,label:e}),Qe=({type:t,value:e,choices:n,onChange:r,onSettle:a,onPick:l,pictureUrl:d})=>{if(t==="picture")return o.createElement("div",{className:"mb-3"},e&&d&&o.createElement("img",{src:d,alt:"The step's picture",style:{maxWidth:"100%"}}),e&&o.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>a("")},"Remove picture"),o.createElement("input",{type:"file",accept:"image/*",onChange:i=>i.target.files[0]&&l(i.target.files[0])}));if(t==="boolean")return o.createElement(G,{checked:!!e,onChange:i=>a(i.target.checked)});if(t==="select"||t==="previous_step"||t==="from_step"||t==="flow")return o.createElement(Et,{className:"mb-3",value:e??"",onChange:i=>a(i.target.value)},o.createElement("option",{value:""}),_t(n).map(i=>o.createElement("option",{key:i.value,value:i.value},i.label)));if(t==="multi_select"){let i=Array.isArray(e)?e:[],p=h=>a(nt(i,h));return o.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(n||[]).map(h=>o.createElement("label",{key:h,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(G,{checked:i.includes(h),onChange:()=>p(h)}),o.createElement("span",null,h))))}if(t==="flows"){let i=Array.isArray(e)?e:[];return o.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},_t(n).map(p=>o.createElement("label",{key:p.value,style:{display:"inline-flex",alignItems:"center",gap:4}},o.createElement(G,{checked:i.includes(p.value),onChange:()=>a(nt(i,p.value))}),o.createElement("span",null,p.label))))}return t==="integer"||t==="float"?o.createElement(A,{className:"mb-3",type:"number",step:t==="integer"?"1":"any",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)}):o.createElement(A,{className:"mb-3",type:"text",value:e??"",onChange:i=>r(i.target.value),onBlur:i=>a(i.target.value)})},X=Qe;var Dt=(t,e,n,r)=>t.map((a,l)=>l===e?{...a,[n]:r}:a);var Ze=({text:t})=>o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},t),q=Ze;var Re=(t,e,n,r)=>{let a=(t||{})[n],l=(e||{})[n];return l?(a||{})[r[l]]:a},to=({holds:t,labels:e,explanations:n,rows:r,choices:a,outputsOf:l,onChange:d,onSettle:i})=>{let p=Array.isArray(r)?r:[],h=(b,m,g,f)=>{let u=Dt(p,b,m,g);f?i(u):d(u)};return o.createElement("div",{style:{marginBottom:12}},p.map((b,m)=>o.createElement("div",{key:m,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(t).map(([g,f])=>o.createElement("label",{key:g,style:{display:"block"}},o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(e||{})[g]||g),o.createElement(X,{type:f,value:b[g],choices:Re(a,l,g,b),onChange:u=>h(m,g,u,!1),onSettle:u=>h(m,g,u,!0)}),(n||{})[g]&&o.createElement(q,{text:n[g]}))),o.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>i(p.filter((g,f)=>f!==m))},"Remove"))),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>i([...p,{}])},"Add"))},At=to;var eo=({as:t="div",className:e,children:n,...r})=>o.createElement(t,{...r,className:E("ks-panel",e)},n),$=eo;var J=(t,e)=>({className:n,children:r,...a})=>o.createElement(t,{...a,className:E(e,n)},r),W=J("label","ks-label"),In=J("p","ks-hint"),Mn=J("p","ks-error"),jn=J("span","ks-required");var oo={width:280,padding:20,overflowY:"auto"},ro=({node:t,fields:e,holds:n,labels:r,explanations:a,recordLabels:l,recordExplanations:d,recordChoices:i,recordOutputsOf:p,choices:h,onSave:b,onDelete:m,onClose:g,onPickPicture:f,refusal:u})=>{let[k,w]=S(t.config),[C,T]=S(t.picture_url);L(()=>T(t.picture_url),[t.id,t.picture_url]),L(()=>w(t.config),[t.id,t.config]);let x=y=>{w(y),JSON.stringify(y)!==JSON.stringify(t.config)&&b(y)};return o.createElement($,{as:"aside",style:oo,"data-inspector":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600,marginBottom:2}},t.label),o.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:16}},t.id," \xB7 ",t.type),u&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},u),Object.entries(e).map(([y,O])=>o.createElement(W,{key:y},o.createElement("span",{style:{display:"block",marginBottom:3}},r[y]||y),O==="list"?o.createElement(At,{holds:n[y]||{},labels:l[y]||{},explanations:(d||{})[y],rows:k[y],choices:{...(i||{})[y],...(t.record_choices||{})[y]},outputsOf:(p||{})[y],onChange:z=>w({...k,[y]:z}),onSettle:z=>x({...k,[y]:z})}):o.createElement(X,{type:O,value:k[y],choices:h[y],pictureUrl:C,onChange:z=>w({...k,[y]:z}),onSettle:z=>x({...k,[y]:z}),onPick:async z=>{let B=await f(z);B&&(T(B.url),x({...k,[y]:B.reference}))}}),(a||{})[y]&&o.createElement(q,{text:a[y]}))),o.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:m},"Delete step"))},Ot=ro;var no={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},so={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},ao="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",io="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",lo=({node:t,dragging:e,onFill:n,onDrop:r,compact:a=!1})=>o.createElement("div",{ref:t.ref,"data-placeholder":t.id,title:`Choose the step \u201C${t.label}\u201D should lead to`,onClick:n,onDragOver:l=>{e&&(l.preventDefault(),l.dataTransfer.dropEffect="move")},onDrop:l=>{l.preventDefault(),r()},className:e?io:ao,style:a?so:no},o.createElement("div",{style:{fontWeight:600}},t.label),o.createElement("div",{style:{fontSize:11}},e?"drop a step here":"leads nowhere yet \u2014 click to choose")),Pt=lo;var co=({entries:t,at:e,onPick:n,onConnect:r,onDismiss:a,hideStepTypeCodes:l})=>o.createElement($,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:e.y,left:e.x,width:210,padding:8,borderRadius:8}},o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),t.map(d=>o.createElement(v,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>n(d)},d.label,!l&&o.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:a},"Cancel")),$t=co;var po=t=>e=>e.label.toLowerCase().includes(t.trim().toLowerCase()),uo=(t,e,n="")=>{let r=Object.values(e).flat(),a=Object.entries(e).map(([l,d])=>({heading:l,entries:d.map(i=>t.find(p=>p.type===i)).filter(Boolean)}));return[{heading:null,entries:t.filter(l=>!r.includes(l.type))},...a].map(l=>({...l,entries:l.entries.filter(po(n))})).filter(l=>l.entries.length>0)},mo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},fo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},go={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},ho=({entries:t,groups:e,onPick:n,onCarry:r,onDrop:a})=>{let[l,d]=S("");return o.createElement($,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:mo},o.createElement(A,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:l,onChange:i=>d(i.target.value),style:{marginBottom:6,fontSize:12}}),uo(t,e,l).map(i=>o.createElement(o.Fragment,{key:i.heading||""},i.heading&&o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:fo},i.heading),i.entries.map(p=>o.createElement($,{as:"button",type:"button",key:p.type,"data-step-type":p.type,className:"bg-surface-50 dark:bg-surface-950",style:go,draggable:!0,onClick:()=>n(p),onDragStart:h=>{h.dataTransfer.effectAllowed="copyMove",h.dataTransfer.setData("text/plain",p.type),r(p)},onDragEnd:a},p.label)))))},Lt=ho;var yo={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},It=({label:t,title:e,idle:n,enabled:r,onUse:a})=>o.createElement(v,{variant:"secondary",size:"sm",title:r?e:n,disabled:!r,onClick:a,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},t),xo=({undoable:t,redoable:e,onAdd:n,onUndo:r,onRedo:a})=>o.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},o.createElement(v,{variant:"secondary",className:"rounded-full",style:yo,title:"Add a step",onClick:n},"+"),o.createElement(It,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:t,onUse:r}),o.createElement(It,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:e,onUse:a})),Mt=xo;var bo=({type:t="info",title:e,message:n,onDismiss:r,className:a})=>o.createElement("div",{className:E("ks-alert",`ks-alert-${t}`,a),role:"alert"},o.createElement("div",{className:"ks-alert-body"},o.createElement("div",{className:"ks-alert-content"},e&&o.createElement("p",{className:"ks-alert-title"},e),o.createElement("p",{className:e?"ks-alert-message-titled":"ks-alert-message"},n)),r&&o.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),jt=bo;var Ht=t=>{let e=t.map(n=>`\u201C${n.name}\u201D`).join(", ");return t.length===1?`${e} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${e} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var Wt=({version:t,published:e})=>t?e?e===t?`Version ${t} \xB7 live`:`Version ${t} \xB7 visitors still on ${e}`:`Version ${t} \xB7 never published`:"No version yet";var vo={width:280,padding:20,overflowY:"auto"},st={fontWeight:600,marginBottom:6,marginTop:14},K={fontSize:12,marginBottom:4,lineHeight:1.4},Ft={display:"block",marginBottom:3},Vt=(t,e,n)=>r=>{r.target.value!==(t[e]??"")&&n({[e]:r.target.value})},wo=({flow:t,changes:e,problems:n,refusal:r,notice:a,publishNote:l,warning:d,onCreate:i,onPublish:p,onAccept:h,onDecline:b,onSaveDetails:m,onClose:g})=>o.createElement($,{as:"aside",style:vo,"data-builder-panel":!0},o.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},o.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},t.title||t.slug),o.createElement("button",{title:"Close",onClick:g,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),o.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:t.history_url,"data-history":!0},Wt(t)),d?o.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},o.createElement(jt,{type:"warning",className:"mb-1.5",message:Ht(d.steps)}),o.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:h,"data-accept-removal":!0},d.path==="/publish"?"Remove and publish":"Remove and create version"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:b,"data-decline-removal":!0},"Cancel")):o.createElement("div",{style:{marginTop:14}},o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:i,"data-create-version":!0},"Create version"),o.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:p,"data-publish":!0},"Publish"),l&&o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},l)),o.createElement("h2",{style:st},"Problems"),r&&o.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...K,fontWeight:600},"data-refusal":!0},r),a&&!r&&o.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...K,fontWeight:600},"data-notice":!0},a),n.length===0&&!r?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing wrong with this flow."):n.map(f=>o.createElement("p",{key:`${f.node}-${f.problem}`,className:"text-amber-700 dark:text-amber-400",style:K,"data-problem":!0},"\u26A0 ",f.sentence)),o.createElement("h2",{style:st},"Changes since the last version"),e.length===0?o.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):e.map((f,u)=>o.createElement("p",{key:u,style:K,"data-change":!0},f)),o.createElement("h2",{style:st},"Details"),o.createElement(W,null,o.createElement("span",{style:Ft},"Title"),o.createElement(A,{className:"mb-3",defaultValue:t.title??"",onBlur:Vt(t,"title",m),"data-flow-title":!0})),o.createElement(W,null,o.createElement("span",{style:Ft},"Start label"),o.createElement(A,{className:"mb-3",defaultValue:t.start_label??"",onBlur:Vt(t,"start_label",m),"data-flow-start-label":!0})),o.createElement("div",{style:{marginTop:16}},o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.definition_url,"data-definition":!0},"Definition"),o.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:t.details_url,"data-details":!0},"Edit details"))),Yt=wo;var Ut={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Gt=t=>({opacity:t?1:0,transition:"opacity .12s"}),ko=({link:t,onInsert:e,onRemove:n,onDrop:r,dragging:a,alwaysShowInsertButtons:l})=>{let[d,i]=S(!1),p=d||a;return o.createElement("div",{"data-connector":`${t.source}-${t.target}`,style:{position:"absolute",left:t.midX-34,top:t.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onDragEnter:()=>i(!0),onDragLeave:()=>i(!1),onDragOver:h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},onDrop:h=>{h.preventDefault(),i(!1),r()}},o.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},o.createElement(v,{variant:"secondary",title:a?"Move the step here":"Insert a step here",onClick:e,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(a&&d),style:{...Ut,...Gt(p||l)}},"+"),!a&&o.createElement(v,{variant:"danger",title:"Remove this connection",onClick:n,className:"rounded-full",style:{...Ut,...Gt(p)}},"\xD7")))},Xt=ko;var So=({links:t,extent:e,dragging:n,onInsert:r,onRemove:a,onDrop:l,alwaysShowInsertButtons:d})=>o.createElement(o.Fragment,null,o.createElement("svg",{width:e.width,height:e.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},o.createElement("defs",null,o.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},o.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),t.map(i=>o.createElement("path",{key:i.id,"data-link":i.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:i.path}))),t.filter(i=>i.label).map(i=>o.createElement("div",{key:`${i.id}-label`,"data-link-label":i.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:i.midX+(d?2:-10),top:i.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},i.label)),t.filter(i=>!i.placeholder).map(i=>o.createElement(Xt,{key:i.id,link:i,dragging:!!n,alwaysShowInsertButtons:d,onInsert:()=>r(i),onRemove:()=>a(i),onDrop:()=>l(i)}))),qt=So;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Jt="opacity-0 transition-opacity group-data-[over=true]:opacity-100",Co=({link:t,onInsert:e,onRemove:n,onDrop:r,alwaysShowInsertButtons:a,dragging:l})=>o.createElement("div",{"data-joint":t?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:d=>{d.currentTarget.dataset.over="true"},onMouseLeave:d=>{delete d.currentTarget.dataset.over},onDragOver:d=>{t&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{t&&(d.preventDefault(),r(t))}},t&&o.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),t&&e&&o.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},o.createElement(v,{variant:"secondary",title:"Insert a step here",onClick:d=>e(t,d),className:`rounded-full ${a?"opacity-100":Jt}`,style:l?{...at,opacity:1}:at},"+"),o.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>n(t),className:`rounded-full ${Jt}`,style:at},"\xD7"))),Kt=Co;var No=(t,e)=>t.row-e.row||t.column-e.column,Qt=t=>{let e=[...t].sort(No),n=e.filter(r=>t.some(a=>a.holds?.includes(r.id)));return e.filter(r=>!n.includes(r)).flatMap(r=>[r,...n.filter(a=>r.holds?.includes(a.id))])},Zt=t=>{let e=Qt(t),n=r=>e.some(a=>a.holds?.includes(r.id));return e.filter(r=>!n(r)).reduce((r,a)=>{if(a.holds)return[...r,{group:a,steps:e.filter(d=>a.holds.includes(d.id))}];let l=r[r.length-1];return l&&!l.group?[...r.slice(0,-1),{steps:[...l.steps,a]}]:[...r,{steps:[a]}]},[])},zo=(t,e)=>t[t.findIndex(n=>n.id===e.id)+1]?.id,Rt=(t,e,n)=>{let r=zo(Qt(n),t);return e.filter(a=>a.source===t.id&&(a.label||a.target!==r))},Bo=t=>t?.placeholder?"nowhere yet":t?.label,te=(t,e)=>[t.label,"\u2192",Bo(e.find(n=>n.id===t.target))].filter(Boolean).join(" "),ee=(t,e,n)=>t.find(r=>r.source===e.id&&r.target===n.id);var To={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},oe=({steps:t,edges:e,draw:n,joints:r})=>o.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},t.map((a,l)=>o.createElement("div",{key:a.id,className:"flex flex-col sm:flex-row sm:items-center"},l>0&&o.createElement(Kt,{link:ee(e,t[l-1],a),...r}),n(a)))),Eo={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},_o=({group:t,steps:e,edges:n,draw:r,joints:a})=>o.createElement("div",{"data-group-box":t.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:Eo},r(t),o.createElement(oe,{steps:e,edges:n,draw:r,joints:a})),Do=({nodes:t,edges:e,draw:n,joints:r,children:a,style:l})=>o.createElement("div",{"data-flow-rows":!0,style:{...To,...l}},a,Zt(t).map(d=>d.group?o.createElement(_o,{key:d.group.id,group:d.group,steps:d.steps,edges:e,draw:n,joints:r}):o.createElement(oe,{key:d.steps[0].id,steps:d.steps,edges:e,draw:n,joints:r}))),Q=Do;var re="Your change was not saved because the server could not be reached.",ne=({base:t,token:e,fetch:n,onFlow:r,onError:a,onNotice:l,onWarning:d=()=>{}})=>async(i,p,h)=>{let b=await n(t+i,{method:p,headers:{"Content-Type":"application/json","X-CSRF-Token":e},body:h&&JSON.stringify(h)}).catch(()=>null);if(!b)return l(null),a(re);let m=await b.json().catch(()=>({}));if(m.unconnected)return l(null),a(null),d({path:i,steps:m.unconnected}),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!b.ok)return l(null),a(m.error||"That change was refused");a(null),l(m.notice||null),r(await(await n(t+".json",{headers:{Accept:"application/json"}})).json())},se=({base:t,token:e,fetch:n,onError:r})=>async a=>{let l=new FormData;l.append("picture",a);let d=await n(t+"/pictures",{method:"POST",headers:{"X-CSRF-Token":e},body:l}).catch(()=>null);if(!d)return r(re),null;let i=await d.json().catch(()=>({}));return d.ok?(r(null),i):(r(i.error||"That picture was refused"),null)};var Ao=(t,e,n)=>{let[r,a]=S(n),[l,d]=S(null),[i,p]=S(null),[h,b]=S(null),m=j(()=>ne({base:t,token:e,fetch:(...f)=>window.fetch(...f),onFlow:a,onError:d,onNotice:p,onWarning:b}),[t,e]),g=j(()=>se({base:t,token:e,fetch:(...f)=>window.fetch(...f),onError:d}),[t,e]);return{flow:r,error:l,notice:i,warning:h,setWarning:b,send:m,pickPicture:g}},ae=Ao;var Z=(t,e,n,r)=>{let a=t.left-n.left+r.scrollLeft,l=t.top-n.top+r.scrollTop;return e==="left"?{x:a,y:l+t.height/2}:e==="right"?{x:a+t.width,y:l+t.height/2}:e==="top"?{x:a+t.width/2,y:l}:{x:a+t.width/2,y:l+t.height}},Oo=(t,e,n)=>n&&e==="top"?{x:t.x,y:n.top}:t,Po=(t,e)=>e==="top"?{x:t.x,y:t.y-3}:e==="left"?{x:t.x-3,y:t.y}:e==="right"?{x:t.x+3,y:t.y}:{x:t.x,y:t.y+3},$o=(t,e,n,r,a)=>{let l={straight:`M ${e.x} ${e.y} L ${n.x} ${n.y}`,turn:`M ${e.x} ${e.y} H ${n.x} V ${n.y}`,lane:`M ${e.x} ${e.y} V ${r} H ${n.x} V ${n.y}`,detour:`M ${e.x} ${e.y} H ${a} V ${n.y} H ${n.x}`}[t.route];return{...t,path:l,midX:t.route==="detour"?a:(e.x+n.x)/2,midY:t.route==="lane"?r:(e.y+n.y)/2}},Lo=(t,e,n,r)=>{let[a,l]=S([]),[d,i]=S({width:"100%",height:"100%"}),[p,h]=S([]);return ht(()=>{let b=()=>{let g=e.current?.getBoundingClientRect();if(!g)return;i({width:e.current.scrollWidth,height:e.current.scrollHeight});let f=t.nodes.filter(u=>u.holds&&!u.loose&&n.current[u.id]).map(u=>{let k=n.current[u.id],w=k.getBoundingClientRect(),C=u.holds.flatMap(x=>n.current[x]?[n.current[x].getBoundingClientRect()]:[]),T=[{left:w.left,top:w.top,width:Math.max(w.width,k.scrollWidth),height:w.height},...C];return{id:u.id,bounds:Ct(T,g,e.current)}});h(f),l(t.edges.flatMap(u=>{let k=n.current[u.source]?.getBoundingClientRect(),w=n.current[u.target]?.getBoundingClientRect();if(!k||!w)return[];let C=Z(k,u.leaves,g,e.current),T=f.find(z=>z.id===u.target)?.bounds,x=Po(Oo(Z(w,u.enters,g,e.current),u.enters,T),u.enters),y=(Z(k,"bottom",g,e.current).y+Z(w,"top",g,e.current).y)/2,O=u.leaves==="left"?Math.min(C.x,x.x)-28:Math.max(C.x,x.x)+28;return[$o(u,C,x,y,O)]}))};b(),window.addEventListener("resize",b);let m=new ResizeObserver(b);return e.current&&m.observe(e.current),()=>{window.removeEventListener("resize",b),m.disconnect()}},r),{links:a,extent:d,boxes:p}},ie=Lo;var le=(t,e)=>{let n=new Set(e),r=t,a=2;for(;n.has(r);)r=`${t}_${a++}`;return r};var Mo=8,jo={display:"flex",height:"100%",minHeight:0,fontSize:13},Ho={flex:1,overflow:"auto",position:"relative"},ce={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},Wo={...ce,position:"static",alignSelf:"flex-start"},Fo={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Vo={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Yo=({port:t,onCancel:e})=>o.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Vo},"Choose the step \u201C",t||"next","\u201D should lead to \u2014 ",o.createElement("button",{onClick:e,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),Uo=({base:t,token:e,initial:n})=>{let{flow:r,error:a,notice:l,warning:d,setWarning:i,send:p,pickPicture:h}=ae(t,e,n),[b,m]=S(null),[g,f]=S(null),[u,k]=S(null),[w,C]=S(null),[T,x]=S(null),[y,O]=S(!1),z=et({}),B=et(null);L(()=>{let s={open:null,publish:"/publish",save_draft:"/versions"},c=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in s))return;D.closest("details")?.removeAttribute("open"),m(null),O(!0);let F=s[D.dataset.barAction];F&&p(F,"POST")};return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[p]),L(()=>{if(!y){i(null);return}let s=c=>{c.target.isConnected&&!c.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[y]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),L(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let he=j(()=>Object.fromEntries(r.nodes.map(s=>[s.id,s])),[r.nodes]),{links:ye,extent:xe,boxes:it}=ie(r,B,z,[r,b,he]),lt=j(()=>{let s={};return r.violations.forEach(c=>{var N;return(s[N=c.node]||(s[N]=[])).push(c)}),s},[r.violations]),_=r.direction==="left_to_right",H=r.nodes.filter(s=>!s.loose),dt=r.nodes.filter(s=>s.loose),be=Math.max(0,...H.map(s=>s.row))+1,ve=Math.max(0,...H.map(s=>s.column))+1,R=s=>{if(!u)return;let[c,N]=u;k(null),c!==s&&p("/edges","POST",{from:c,to:s,on:N||null})},we=s=>{if(s.isDefaultPrevented()||!w)return;s.preventDefault();let c=w;C(null);let N=B.current.getBoundingClientRect(),D=Nt(it,{x:s.clientX-N.left+B.current.scrollLeft,y:s.clientY-N.top+B.current.scrollTop}),F=r.nodes.find(Se=>Se.holds?.includes(c))?.id||null;D!==F&&p(`/steps/${c}/group`,"PATCH",{group:D})},ct=s=>[...r.palette,...r.unoffered||[]].find(c=>c.type===s?.type),M=r.nodes.find(s=>s.id===b),P=ct(M),tt=(s,c={})=>p("/steps","POST",{id:le(s.type,r.nodes.map(N=>N.id)),type:s.type,from:c.from,to:c.to,on:c.on}),pt=s=>{let[c,N]=[T,w];x(null),C(null),c?tt(c,{from:s.source,to:s.target}):N&&p("/steps/"+N+"/move","PATCH",{from:s.source,to:s.target})},ke=s=>{let c=B.current.getBoundingClientRect();return{x:s.clientX-c.left+B.current.scrollLeft+8,y:s.clientY-c.top+B.current.scrollTop+8}},ut=s=>o.createElement(o.Fragment,null,s.placeholder&&o.createElement(Pt,{node:{...s,ref:c=>{z.current[s.id]=c}},dragging:!!w,compact:_,onFill:()=>f({from:s.from,on:s.on,at:{x:16,y:52}}),onDrop:()=>{let c=w;C(null),c&&p("/edges","POST",{from:s.from,to:c,on:s.on})}}),s.holds&&o.createElement(Y,{node:{...s,ref:c=>{z.current[s.id]=c}},header:U(s,ct(s),r.hide_step_type_codes),compact:_,onSelect:()=>u?R(s.id):m(s.id)}),!s.placeholder&&!s.holds&&o.createElement(rt,{node:{...s,ref:c=>{z.current[s.id]=c},violations:lt[s.id]||[],connected:r.edges.filter(c=>c.source===s.id).map(c=>c.label||null)},selected:s.id===b,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u&&u[0]!==s.id,onSelect:()=>u?R(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,N)=>{let D=B.current.getBoundingClientRect();f({from:s.id,on:c,at:{x:N.clientX-D.left+B.current.scrollLeft+8,y:N.clientY-D.top+B.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(s.id),hideStepTypeCodes:r.hide_step_type_codes,compact:_,branches:_?Rt(s,r.edges,H).map(c=>te(c,r.nodes)):[]})),mt=dt.length>0&&o.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:_?Wo:ce},o.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),dt.map(s=>o.createElement("div",{key:s.id,style:{marginBottom:8}},o.createElement(rt,{node:{...s,ref:c=>{z.current[s.id]=c},violations:lt[s.id]||[],connected:[]},selected:b===s.id,armed:u&&u[0]===s.id?u[1]:null,connecting:!!u,onSelect:()=>u?R(s.id):m(s.id),onOpen:c=>window.location.assign(c),onArm:(c,N)=>{N.stopPropagation(),k([s.id,c])},onDragStart:()=>C(s.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return o.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:jo,onMouseUp:()=>C(null),onKeyDown:s=>{s.key==="Escape"&&(m(null),k(null),f(null))},tabIndex:-1},o.createElement(Lt,{entries:r.palette,groups:r.step_groups||{},onPick:s=>tt(s),onCarry:x,onDrop:()=>x(null)}),o.createElement("div",{ref:B,className:"bg-surface-50 dark:bg-surface-950",style:Ho,onClick:s=>{s.target===B.current&&(m(null),k(null),O(!1))},onDragOver:s=>{w&&s.preventDefault()},onDrop:we},u&&o.createElement(Yo,{port:u[1],onCancel:()=>k(null)}),o.createElement(Mt,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>f({at:{x:16,y:52}}),onUndo:()=>{m(null),p("/undo","POST")},onRedo:()=>{m(null),p("/redo","POST")}}),!_&&it.map(s=>o.createElement(St,{key:s.id,id:s.id,bounds:s.bounds,onDrop:()=>{let c=w;C(null),c&&p(`/steps/${c}/group`,"PATCH",{group:s.id})}})),!_&&o.createElement(qt,{links:zt(ye,r.nodes),extent:xe,dragging:w||T,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:s=>f({from:s.source,to:s.target,at:{x:s.midX+30,y:s.midY}}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}),!_&&mt,_&&o.createElement(Q,{nodes:H,edges:r.edges,draw:ut,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(w||T),onInsert:(s,c)=>f({from:s.source,to:s.target,at:ke(c)}),onRemove:s=>{m(null),p("/edges","DELETE",{from:s.source,to:s.target})},onDrop:pt}},mt),!_&&o.createElement("div",{style:{...Fo,gridTemplateColumns:`repeat(${ve+1}, ${280/2}px)`,gridTemplateRows:`repeat(${be}, auto)`}},H.map(s=>o.createElement("div",{key:s.id,style:{gridRow:s.row+1,gridColumn:`${s.column+1} / span 2`,zIndex:2,marginTop:Bt(s,r.nodes)?Mo-64:0}},ut(s)))),g&&o.createElement($t,{entries:r.palette,at:g.at,onDismiss:()=>f(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:g.on!==void 0?()=>{k([g.from,g.on]),f(null)}:null,onPick:s=>{let c=g;f(null),tt(s,c)}})),y&&!M&&o.createElement(Yt,{flow:r.flow||{},changes:r.changes||[],problems:r.violations,refusal:a,notice:l,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>p("/versions","POST"),onPublish:()=>p("/publish","POST"),onAccept:()=>p(d.path,"POST",{remove_unconnected:d.steps.map(s=>s.id)}),onDecline:()=>i(null),onSaveDetails:s=>p("/details","PATCH",{flow:s})}),M&&o.createElement(Ot,{node:M,fields:P?.fields||{},holds:P?.records||{},labels:P?.labels||{},explanations:P?.explanations||{},recordLabels:P?.record_labels||{},recordExplanations:P?.record_explanations||{},recordChoices:P?.record_choices||{},recordOutputsOf:P?.record_outputs_of||{},choices:Tt(M,P),onClose:()=>m(null),onSave:s=>p(`/steps/${M.id}`,"PATCH",{config:s}),onPickPicture:h,refusal:a,onDelete:()=>{m(null),p(`/steps/${M.id}`,"DELETE")}}))},pe=Uo;var Go={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Xo={fontSize:12,fontWeight:500,lineHeight:1.3},ue={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},me={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},qo="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Jo=({node:t,selected:e=!1})=>{let n=t.address?"a":"div";return o.createElement(n,{"data-step":t.id,href:t.address||void 0,className:`${t.state==="paused"?"border-2":"border"} ${ue[t.state]||ue.pending}${e?` ${qo}`:""}`,style:Go},o.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},t.type),o.createElement("div",{style:Xo},t.label,t.version&&o.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},t.version)),t.status&&o.createElement("div",{className:me[t.state]||me.pending,style:{fontSize:11}},t.status))},fe=Jo;var Ko={gap:12,padding:0},Qo=({nodes:t,edges:e,selected:n})=>o.createElement(Q,{nodes:t,edges:e,joints:{},style:Ko,draw:r=>r.holds?o.createElement(Y,{node:r,header:U(r,r,!1),compact:!0}):o.createElement(fe,{node:r,selected:r.id===n})}),ge=Qo;ot("easy_flow/flow-editor",pe);ot("easy_flow/run-view",ge);document.addEventListener("easy_flow:flow-named",t=>{let e=document.querySelector("[data-flow-heading]");e&&(e.textContent=t.detail)});document.addEventListener("easy_flow:flow-status",({detail:t})=>{t.status&&document.querySelectorAll("[data-version-status]").forEach(e=>{e.textContent=t.status}),t.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(e=>{e.textContent=`Publish v${t.publishes}`})});vt(document,ft);})();
|
|
1
|
+
(()=>{var jt=globalThis.ReactDOM;var{createPortal:Yr,createRoot:fe,flushSync:Xr,hydrateRoot:qr,preconnect:Jr,prefetchDNS:Kr,preinit:Zr,preinitModule:Qr,preload:Rr,preloadModule:es,requestFormReset:ts,unstable_batchedUpdates:os,useFormState:rs,useFormStatus:ss,version:ns}=jt;var ge=globalThis.React,t=ge,{Children:is,Component:ls,Fragment:ds,PureComponent:cs,StrictMode:ps,Suspense:ms,cloneElement:us,createContext:fs,createElement:gs,createRef:xs,forwardRef:hs,isValidElement:ys,lazy:bs,memo:vs,startTransition:ks,useCallback:ws,useContext:Ss,useDebugValue:Cs,useDeferredValue:Ns,useEffect:P,useId:_s,useImperativeHandle:zs,useLayoutEffect:xe,useMemo:j,useReducer:Es,useRef:ee,useState:w,useSyncExternalStore:Bs,useTransition:Ts}=ge;var he=new Map,F=new Map,te=(e,o)=>he.set(e,o),ye=()=>{F.forEach(e=>e.unmount()),F.clear()},be=(e,o)=>e.querySelectorAll("[data-react-ui]").forEach(s=>{if(F.has(s))return;let r=he.get(s.dataset.reactUi),n=o(s);F.set(s,n),n.render(t.createElement(r,JSON.parse(s.dataset.props)))});var ve=(e,o)=>{let s=()=>be(e,o);e.addEventListener("turbo:load",s),e.addEventListener("turbo:frame-load",s),e.addEventListener("turbo:before-cache",ye),e.readyState==="loading"?e.addEventListener("DOMContentLoaded",s):s()};var _=(...e)=>e.filter(Boolean).join(" ");var Ht={primary:"ks-button-primary",secondary:"ks-button-secondary",danger:"ks-button-danger"},Wt={sm:"ks-button-sm",md:"ks-button-md",lg:"ks-button-lg"},Vt=({variant:e="primary",size:o="md",className:s,children:r,...n})=>{let i=n.href?"a":"button";return t.createElement(i,{...n,className:_("ks-button",Ht[e],Wt[o],s)},r)},v=Vt;var Ft="border border-amber-500 bg-white text-amber-700 dark:bg-zinc-900 dark:text-amber-400",Ut="border border-gray-300 bg-white text-gray-500 dark:border-zinc-600 dark:bg-zinc-900 dark:text-gray-400",Gt="border border-accent-600 bg-accent-600 text-white",Yt=({name:e,connected:o,armed:s,onArm:r,connecting:n})=>t.createElement("button",{onClick:i=>{n||(i.stopPropagation(),r(i))},title:s?"Now choose a step to connect to":"Connect this branch",className:s?Gt:o?Ut:Ft,style:{padding:"1px 8px",marginRight:4,borderRadius:999,fontSize:11,cursor:"pointer"}},e||"next"),ke=Yt;var Xt={width:240,boxSizing:"border-box",borderRadius:8},qt={minWidth:120,boxSizing:"border-box",borderRadius:6},Jt={padding:"8px 14px",textAlign:"center",fontWeight:600},Kt={fontWeight:600,lineHeight:1.3},Zt={fontSize:12,fontWeight:500,lineHeight:1.3},Qt=(e,o,s)=>{let r=s?"ring-4 ring-accent-600/15":"shadow-sm";return e||s&&!o?`border-accent-600 ${r}`:o?`border-red-600 ${r}`:"border-gray-300 shadow-sm dark:border-zinc-700"},Rt=(e,o)=>o&&e.label===e.id&&e.type_name||e.label,eo=(e,o,s)=>s?o===e.type_name?null:e.type_name:e.type,to=({node:e,selected:o,armed:s,connecting:r,onSelect:n,onOpen:i,onArm:d,onDragEnd:c,onDragStart:l,hideStepTypeCodes:h,branches:g=[],compact:u=!1,typeAbove:x=u})=>{let y=e.begins_here||e.ends_here,m=e.begins_here,S=e.ends_here?[]:e.ports,k=r&&!m,C=Rt(e,h),B=eo(e,C,h);return t.createElement("div",{ref:e.ref,"data-step":e.id,draggable:!m,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",e.id),l()},onDragEnd:c,onClick:e.opens&&!r?()=>i(e.opens):n,className:`bg-white ${u&&!o?"border":"border-2"} dark:bg-zinc-900 ${Qt(k,e.violations.length>0,o)}`,style:{...u?qt:Xt,padding:y?0:u?"8px 10px":"12px 14px",cursor:m?"default":r?"crosshair":"grab"}},!y&&x&&B&&t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},B),y&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Jt},C),!y&&t.createElement("div",{style:u?Zt:Kt},C),e.violations.length>0&&t.createElement("div",{"data-error-count":!0,className:"text-red-600 dark:text-red-400",style:{fontSize:10}},`${e.violations.length} error${e.violations.length===1?"":"s"}`),!y&&e.summary&&e.violations.length===0&&t.createElement("div",{className:o?"text-accent-600 dark:text-accent-400":"text-gray-500 dark:text-gray-400",style:{fontSize:10}},e.summary),!y&&!x&&B&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginTop:2}},B),e.picture_url&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Has a picture"),e.starts_a_flow&&t.createElement("div",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:11,marginTop:2}},"Runs a flow"),e.opens&&t.createElement(v,{variant:"secondary",size:"sm",className:"mt-2",onClick:b=>{b.stopPropagation(),n()}},"Settings"),g.map(b=>t.createElement("div",{key:b,className:"text-gray-500 dark:text-gray-400",style:{fontSize:10}},b)),S.length>0&&t.createElement("div",{style:{padding:e.begins_here?"0 14px 8px":"10px 0 0"}},S.map(b=>t.createElement(ke,{key:b,name:b,connected:e.connected.includes(b),connecting:r,armed:s===b,onArm:f=>d(b,f)}))))},oe=to;var we={position:"relative",zIndex:2,width:240,fontSize:11,whiteSpace:"nowrap",cursor:"pointer"},oo={...we,width:"auto",whiteSpace:"normal",overflowWrap:"anywhere"},ro=({node:e,header:o,onSelect:s,compact:r=!1})=>t.createElement("div",{ref:e.ref,"data-group-header":e.id,onClick:s,className:"font-mono text-gray-500 dark:text-gray-400",style:{...r?oo:we,...s?{}:{cursor:"default"}}},o),U=ro;var so=({id:e,bounds:o,onDrop:s})=>t.createElement("div",{"data-group-box":e,onDragOver:r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},onDrop:r=>{r.preventDefault(),s()},className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:{position:"absolute",zIndex:1,borderRadius:8,boxSizing:"border-box",...o}}),Se=so;var no=e=>e!=null&&e!==""&&typeof e!="object",ao=["integer","float"],io=(e,o,s)=>s&&o.labels?.[e]||e,G=(e,o,s)=>{let r=Object.keys(o?.fields||{}).filter(n=>no(e.config[n])).map(n=>`${io(n,o,s)}${ao.includes(o.fields[n])?"":":"} ${e.config[n]}`);return[s&&e.type_name||e.type,...r].join(" \xB7 ")};var Ce=(e,o,s)=>{let r=Math.min(...e.map(c=>c.left))-o.left+s.scrollLeft-12,n=Math.min(...e.map(c=>c.top))-o.top+s.scrollTop-10,i=Math.max(...e.map(c=>c.left+c.width))-o.left+s.scrollLeft+12,d=Math.max(...e.map(c=>c.top+c.height))-o.top+s.scrollTop+10;return{left:r,top:n,width:i-r,height:d-n}},lo=({left:e,top:o,width:s,height:r},n)=>n.x>=e&&n.x<=e+s&&n.y>=o&&n.y<=o+r,Ne=(e,o)=>e.find(s=>lo(s.bounds,o))?.id||null,_e=(e,o)=>e.filter(s=>!o.some(r=>r.id===s.source&&r.holds?.includes(s.target))),ze=(e,o)=>o.some(s=>s.holds?.includes(e.id)&&!s.loose&&s.row===e.row-1);var re=(e,o)=>e.includes(o)?e.filter(s=>s!==o):[...e,o],Ee=(e,o)=>({...o?.choices||{},...e?.choices||{}});var co=({as:e="input",disabled:o,className:s,...r})=>t.createElement(e,{...r,disabled:o,className:_("ks-input",o&&"ks-input-disabled",s)}),L=co;var po=e=>t.createElement(L,{...e,as:"select"}),Be=po;var mo=({className:e,...o})=>t.createElement("input",{type:"checkbox",...o,className:_("ks-checkbox",e)}),Y=mo;var uo=({name:e,value:o,label:s,hint:r,...n})=>t.createElement("label",{className:"inline-block cursor-pointer relative"},t.createElement("input",{type:"radio",name:e,value:o,...n,className:"peer sr-only"}),t.createElement("span",{className:"ks-radio-card inline-flex flex-col cursor-pointer transition ks-radio-card-highlight"},t.createElement("span",{className:"ks-radio-card-header flex items-start justify-between"},t.createElement("span",{className:"ks-radio-card-label block"},s)),r!=null&&t.createElement("span",{className:"ks-radio-card-hint block text-sm"},r))),Te=uo;var fo=({name:e,options:o,value:s,onChange:r})=>t.createElement("div",{className:"flex flex-wrap ks-grid-gap-sm"},o.map(n=>t.createElement(Te,{key:n.value,name:e,...n,checked:n.value===s,onChange:r}))),Ae=fo;var De=e=>(e||[]).map(o=>typeof o=="object"?o:{value:o,label:o}),go=({name:e,type:o,value:s,choices:r,onChange:n,onSettle:i,onPick:d,pictureUrl:c})=>{if(o==="picture")return t.createElement("div",{className:"mb-3"},s&&c&&t.createElement("img",{src:c,alt:"The step's picture",style:{maxWidth:"100%"}}),s&&t.createElement("button",{type:"button","data-remove-picture":!0,className:"ks-button ks-button-secondary ks-button-sm",onClick:()=>i("")},"Remove picture"),t.createElement("input",{type:"file",accept:"image/*",onChange:l=>l.target.files[0]&&d(l.target.files[0])}));if(o==="boolean")return t.createElement(Y,{checked:!!s,onChange:l=>i(l.target.checked)});if(o==="select"||o==="previous_step"||o==="from_step"||o==="flow")return t.createElement(Be,{className:"mb-3",value:s??"",onChange:l=>i(l.target.value)},t.createElement("option",{value:""}),De(r).map(l=>t.createElement("option",{key:l.value,value:l.value},l.label)));if(o==="radio_cards")return t.createElement("div",{"data-radio-cards":!0,className:"mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full"},t.createElement(Ae,{name:e,value:s,options:r||[],onChange:l=>i(l.target.value)}));if(o==="multi_select"){let l=Array.isArray(s)?s:[],h=g=>i(re(l,g));return t.createElement("div",{style:{display:"flex",flexWrap:"wrap",gap:8}},(r||[]).map(g=>t.createElement("label",{key:g,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(g),onChange:()=>h(g)}),t.createElement("span",null,g))))}if(o==="flows"){let l=Array.isArray(s)?s:[];return t.createElement("div",{style:{display:"flex",flexDirection:"column",gap:4},className:"mb-3"},De(r).map(h=>t.createElement("label",{key:h.value,style:{display:"inline-flex",alignItems:"center",gap:4}},t.createElement(Y,{checked:l.includes(h.value),onChange:()=>i(re(l,h.value))}),t.createElement("span",null,h.label))))}return o==="integer"||o==="float"?t.createElement(L,{className:"mb-3",type:"number",step:o==="integer"?"1":"any",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)}):t.createElement(L,{className:"mb-3",type:"text",value:s??"",onChange:l=>n(l.target.value),onBlur:l=>i(l.target.value)})},X=go;var Le=(e,o,s,r)=>e.map((n,i)=>i===o?{...n,[s]:r}:n);var xo=({text:e})=>t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",fontSize:11,lineHeight:1.4,marginBottom:12},"data-setting-explanation":!0},e),q=xo;var ho=(e,o,s,r)=>{let n=(e||{})[s],i=(o||{})[s];return i?(n||{})[r[i]]:n},yo=({holds:e,labels:o,explanations:s,rows:r,choices:n,outputsOf:i,onChange:d,onSettle:c})=>{let l=Array.isArray(r)?r:[],h=(g,u,x,y)=>{let m=Le(l,g,u,x);y?c(m):d(m)};return t.createElement("div",{style:{marginBottom:12}},l.map((g,u)=>t.createElement("div",{key:u,className:"rounded-md border border-gray-200 dark:border-zinc-700",style:{padding:"8px 8px 2px",marginBottom:6}},Object.entries(e).map(([x,y])=>t.createElement("label",{key:x,style:{display:"block"}},t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{display:"block",marginBottom:2,fontSize:11}},(o||{})[x]||x),t.createElement(X,{type:y,value:g[x],choices:ho(n,i,x,g),onChange:m=>h(u,x,m,!1),onSettle:m=>h(u,x,m,!0)}),(s||{})[x]&&t.createElement(q,{text:s[x]}))),t.createElement(v,{variant:"secondary",size:"sm",className:"mb-1.5",onClick:()=>c(l.filter((x,y)=>y!==u))},"Remove"))),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:()=>c([...l,{}])},"Add"))},Oe=yo;var bo={start:null,end:"ks-value-list-end"},vo="grid grid-cols-1 sm:grid-cols-2 ks-grid-gap-sm",ko="flex flex-col min-w-0",wo="ks-value-list-label basis-auto text-xs",So=()=>t.createElement("svg",{"aria-label":"Right",role:"img",className:"ks-tone-success inline size-5 align-text-bottom",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},t.createElement("path",{fillRule:"evenodd",d:"M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z",clipRule:"evenodd"})),Co=({value:e,fallback:o})=>String(e??"")===""?o:e,No=({rows:e,align:o="start",columns:s=!1})=>t.createElement("dl",{className:_("ks-value-list",bo[o],s&&vo)},e.map((r,n)=>t.createElement("div",{key:n,className:_(s?ko:"ks-value-list-row",r.total&&"ks-value-list-total")},t.createElement("dt",{className:s?wo:"ks-value-list-label"},r.label,r.note!=null&&t.createElement(t.Fragment,null," ",t.createElement("span",{className:"ks-value-list-note"},r.note))),t.createElement("dd",{className:"ks-value-list-value"},Co(r),r.right&&t.createElement(t.Fragment,null," ",t.createElement(So,null)))))),$e=No;var _o=()=>t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2"},t.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})),zo=({summary:e,open:o=!1,children:s})=>t.createElement("details",{className:"ks-disclosure group",open:o},t.createElement("summary",{className:"ks-disclosure-summary flex cursor-pointer list-none items-center justify-between [&::-webkit-details-marker]:hidden"},t.createElement("span",null,e),t.createElement("span",{className:"ks-disclosure-icon h-4 w-4 shrink-0 transition-transform group-open:rotate-180"},t.createElement(_o,null))),t.createElement("div",{className:"ks-disclosure-body text-sm"},s)),Pe=zo;var Eo=({language:e,caption:o,children:s})=>t.createElement("div",{className:"ks-code overflow-hidden"},o!=null&&t.createElement("div",{className:"ks-code-caption font-mono text-xs"},o),t.createElement("pre",{className:"ks-code-block overflow-x-auto font-mono text-sm leading-relaxed"},t.createElement("code",{className:e==null?"":`language-${e}`},s))),Me=Eo;var se="flex flex-col gap-1 mb-3",Ie="[&_dd]:font-mono",Bo="[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2",To="[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]",Ao="border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]",Do=e=>e.values?e.columns?`${se} ${Ie} ${Bo}`:`${se} ${Ie} ${To}`:`${se} ${Ao}`,Lo=({details:e})=>t.createElement(t.Fragment,null,e.map((o,s)=>t.createElement("section",{key:s,className:Do(o)},o.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400"},o.heading),o.values&&t.createElement($e,{rows:o.values,columns:o.columns}),o.code&&o.code.map(r=>t.createElement(Pe,{key:r.summary,summary:r.summary},t.createElement(Me,null,r.code)))))),je=Lo;var Oo=({as:e="div",className:o,children:s,...r})=>t.createElement(e,{...r,className:_("ks-panel",o)},s),T=Oo;var J=(e,o)=>({className:s,children:r,...n})=>t.createElement(e,{...n,className:_(o,s)},r),W=J("label","ks-label"),Jn=J("p","ks-hint"),Kn=J("p","ks-error"),Zn=J("span","ks-required");var $o={width:320,padding:"14px 16px",overflowY:"auto",display:"flex",flexDirection:"column",fontSize:12},Po={marginTop:"auto",paddingTop:12,display:"flex",flexDirection:"column",gap:8},Mo=({node:e,fields:o,holds:s,labels:r,explanations:n,recordLabels:i,recordExplanations:d,recordChoices:c,recordOutputsOf:l,choices:h,onSave:g,onDelete:u,onClose:x,onPickPicture:y,refusal:m})=>{let[S,k]=w(e.config),[C,B]=w(e.picture_url);P(()=>B(e.picture_url),[e.id,e.picture_url]),P(()=>k(e.config),[e.id,e.config]);let b=f=>{k(f),JSON.stringify(f)!==JSON.stringify(e.config)&&g(f)};return t.createElement(T,{as:"aside",style:$o,className:"max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto","data-inspector":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8,marginBottom:12}},t.createElement("div",null,t.createElement("p",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.id," \xB7 ",e.type),t.createElement("h2",{style:{fontSize:15,fontWeight:600}},e.label)),t.createElement("button",{title:"Close",onClick:x,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),m&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{fontWeight:600,marginBottom:12},"data-refusal":!0},m),Object.entries(o).map(([f,O])=>t.createElement(W,{key:f},t.createElement("span",{style:{display:"block",marginBottom:3}},r[f]||f),O==="list"?t.createElement(Oe,{holds:s[f]||{},labels:i[f]||{},explanations:(d||{})[f],rows:S[f],choices:{...(c||{})[f],...(e.record_choices||{})[f]},outputsOf:(l||{})[f],onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z})}):t.createElement(X,{name:f,type:O,value:S[f],choices:h[f],pictureUrl:C,onChange:z=>k({...S,[f]:z}),onSettle:z=>b({...S,[f]:z}),onPick:async z=>{let E=await y(z);E&&(B(E.url),b({...S,[f]:E.reference}))}}),(n||{})[f]&&t.createElement(q,{text:n[f]}))),t.createElement(je,{details:e.details||[]}),t.createElement("div",{style:Po},(e.links||[]).length>0&&t.createElement("div",{style:{display:"flex",gap:8}},e.links.map(f=>t.createElement(v,{key:f.address,variant:"secondary",size:"sm",className:"flex-1",href:f.address},f.label))),t.createElement(v,{variant:"danger",size:"sm",className:"w-full",onClick:u},"Delete step")))},He=Mo;var Io={width:240,boxSizing:"border-box",padding:"10px 14px",borderRadius:8,textAlign:"center",fontSize:12,cursor:"pointer"},jo={minWidth:120,boxSizing:"border-box",padding:"8px 10px",borderRadius:6,textAlign:"center",fontSize:12,cursor:"pointer"},Ho="border-2 border-dashed border-amber-500 bg-amber-50 text-amber-700 dark:bg-amber-950 dark:text-amber-300",Wo="border-2 border-dashed border-accent-600 bg-accent-50 text-accent-800 dark:bg-accent-950 dark:text-accent-200",Vo=({node:e,dragging:o,onFill:s,onDrop:r,compact:n=!1})=>t.createElement("div",{ref:e.ref,"data-placeholder":e.id,title:`Choose the step \u201C${e.label}\u201D should lead to`,onClick:s,onDragOver:i=>{o&&(i.preventDefault(),i.dataTransfer.dropEffect="move")},onDrop:i=>{i.preventDefault(),r()},className:o?Wo:Ho,style:n?jo:Io},t.createElement("div",{style:{fontWeight:600}},e.label),t.createElement("div",{style:{fontSize:11}},o?"drop a step here":"leads nowhere yet \u2014 click to choose")),We=Vo;var Fo=({entries:e,at:o,onPick:s,onConnect:r,onDismiss:n,hideStepTypeCodes:i})=>t.createElement(T,{className:"shadow-lg",style:{position:"absolute",zIndex:9,top:o.y,left:o.x,width:210,padding:8,borderRadius:8}},t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{margin:"0 0 6px",fontSize:11}},"Add a step"),e.map(d=>t.createElement(v,{key:d.type,variant:"secondary",size:"sm",className:"w-full mb-1.5 flex-col",onClick:()=>s(d)},d.label,!i&&t.createElement("span",{className:"opacity-75",style:{display:"block",fontSize:11}},d.type))),r&&t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:r},"Connect to a step already here"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full",onClick:n},"Cancel")),Ve=Fo;var Uo=e=>o=>o.label.toLowerCase().includes(e.trim().toLowerCase()),Go=(e,o,s="")=>{let r=Object.values(o).flat(),n=Object.entries(o).map(([i,d])=>({heading:i,entries:d.map(c=>e.find(l=>l.type===c)).filter(Boolean)}));return[{heading:null,entries:e.filter(i=>!r.includes(i.type))},...n].map(i=>({...i,entries:i.entries.filter(Uo(s))})).filter(i=>i.entries.length>0)},Yo={width:200,flex:"none",boxSizing:"border-box",padding:"14px 12px",gap:6,fontSize:12,overflowY:"auto",borderWidth:"0 1px 0 0"},Xo={fontSize:11,textTransform:"uppercase",letterSpacing:".04em",padding:"8px 4px 2px"},qo={textAlign:"left",padding:"7px 9px",borderRadius:6,fontSize:12,cursor:"grab"},Jo=({entries:e,groups:o,onPick:s,onCarry:r,onDrop:n})=>{let[i,d]=w("");return t.createElement(T,{as:"aside","aria-label":"Steps","data-step-list":!0,className:"hidden flex-col sm:flex",style:Yo},t.createElement(L,{type:"search","aria-label":"Search steps",placeholder:"Search steps",value:i,onChange:c=>d(c.target.value),style:{marginBottom:6,fontSize:12}}),Go(e,o,i).map(c=>t.createElement(t.Fragment,{key:c.heading||""},c.heading&&t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:Xo},c.heading),c.entries.map(l=>t.createElement(T,{as:"button",type:"button",key:l.type,"data-step-type":l.type,className:"bg-surface-50 dark:bg-surface-950",style:qo,draggable:!0,onClick:()=>s(l),onDragStart:h=>{h.dataTransfer.effectAllowed="copyMove",h.dataTransfer.setData("text/plain",l.type),r(l)},onDragEnd:n},l.label)))))},Fe=Jo;var Ko={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},Ue=({label:e,title:o,idle:s,enabled:r,onUse:n})=>t.createElement(v,{variant:"secondary",size:"sm",title:r?o:s,disabled:!r,onClick:n,style:{opacity:r?1:.4,cursor:r?"pointer":"default"}},e),Zo=({undoable:e,redoable:o,onAdd:s,onUndo:r,onRedo:n})=>t.createElement("div",{style:{position:"absolute",top:16,left:16,zIndex:5,display:"flex",gap:8}},t.createElement(v,{variant:"secondary",className:"rounded-full",style:Ko,title:"Add a step",onClick:s},"+"),t.createElement(Ue,{label:"\u21B6 Undo",title:"Undo the last change",idle:"Nothing to undo",enabled:e,onUse:r}),t.createElement(Ue,{label:"\u21B7 Redo",title:"Redo the change you undid",idle:"Nothing to redo",enabled:o,onUse:n})),Ge=Zo;var Qo=({type:e="info",title:o,message:s,onDismiss:r,className:n})=>t.createElement("div",{className:_("ks-alert",`ks-alert-${e}`,n),role:"alert"},t.createElement("div",{className:"ks-alert-body"},t.createElement("div",{className:"ks-alert-content"},o&&t.createElement("p",{className:"ks-alert-title"},o),t.createElement("p",{className:o?"ks-alert-message-titled":"ks-alert-message"},s)),r&&t.createElement("button",{type:"button",className:"ks-alert-dismiss","aria-label":"Dismiss",onClick:r},"\xD7"))),Ye=Qo;var Xe=e=>{let o=e.map(s=>`\u201C${s.name}\u201D`).join(", ");return e.length===1?`${o} is not connected to the flow and will be removed. Remove it to go on, or cancel and connect it first.`:`${o} are not connected to the flow and will be removed. Remove them to go on, or cancel and connect them first.`};var qe=({version:e,published:o})=>e?o?o===e?`Version ${e} \xB7 live`:`Version ${e} \xB7 visitors still on ${o}`:`Version ${e} \xB7 never published`:"No version yet";var Ro={width:280,padding:20,overflowY:"auto"},Je={fontWeight:600,marginBottom:6,marginTop:14},ne={fontSize:12,marginBottom:4,lineHeight:1.4},Ke={display:"block",marginBottom:3},Ze=(e,o,s)=>r=>{r.target.value!==(e[o]??"")&&s({[o]:r.target.value})},er=({flow:e,changes:o,refusal:s,notice:r,publishNote:n,warning:i,onCreate:d,onPublish:c,onAccept:l,onDecline:h,onSaveDetails:g,onClose:u})=>t.createElement(T,{as:"aside",style:Ro,"data-builder-panel":!0},t.createElement("div",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:8}},t.createElement("h2",{style:{fontWeight:600},"data-flow-name":!0},e.title||e.slug),t.createElement("button",{title:"Close",onClick:u,className:"text-gray-500 dark:text-gray-400",style:{border:"none",background:"none",cursor:"pointer",fontSize:18,lineHeight:1}},"\xD7")),t.createElement("a",{className:"text-accent-600 dark:text-accent-400",style:{fontSize:12,display:"block"},href:e.history_url,"data-history":!0},qe(e)),i?t.createElement("div",{style:{marginTop:14},"data-unconnected-warning":!0},t.createElement(Ye,{type:"warning",className:"mb-1.5",message:Xe(i.steps)}),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:l,"data-accept-removal":!0},i.path==="/publish"?"Remove and publish":"Remove and create version"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:h,"data-decline-removal":!0},"Cancel")):t.createElement("div",{style:{marginTop:14}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",onClick:d,"data-create-version":!0},"Create version"),t.createElement(v,{size:"sm",className:"w-full mb-1.5",onClick:c,"data-publish":!0},"Publish"),n&&t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12,lineHeight:1.4},"data-publish-note":!0},n)),s&&t.createElement("p",{className:"text-red-800 dark:text-red-400",style:{...ne,fontWeight:600,marginTop:8},"data-refusal":!0},s),r&&!s&&t.createElement("p",{className:"text-emerald-800 dark:text-emerald-400",style:{...ne,fontWeight:600,marginTop:8},"data-notice":!0},r),t.createElement("h2",{style:Je},"Changes since the last version"),o.length===0?t.createElement("p",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:12}},"Nothing has changed."):o.map((x,y)=>t.createElement("p",{key:y,style:ne,"data-change":!0},x)),t.createElement("h2",{style:Je},"Details"),t.createElement(W,null,t.createElement("span",{style:Ke},"Title"),t.createElement(L,{className:"mb-3",defaultValue:e.title??"",onBlur:Ze(e,"title",g),"data-flow-title":!0})),t.createElement(W,null,t.createElement("span",{style:Ke},"Start label"),t.createElement(L,{className:"mb-3",defaultValue:e.start_label??"",onBlur:Ze(e,"start_label",g),"data-flow-start-label":!0})),t.createElement("div",{style:{marginTop:16}},t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.definition_url,"data-definition":!0},"Definition"),t.createElement(v,{variant:"secondary",size:"sm",className:"w-full mb-1.5",href:e.details_url,"data-details":!0},"Edit details"))),Qe=er;var tr=({variant:e="neutral",className:o,children:s,...r})=>t.createElement("span",{...r,className:_("ks-badge",`ks-badge-${e}`,o)},s),Re=tr;var or={center:"ks-tab-bar flex flex-wrap justify-center max-sm:flex-nowrap max-sm:overflow-x-auto max-sm:justify-start",start:"ks-tab-bar flex flex-wrap justify-start max-sm:flex-nowrap max-sm:overflow-x-auto"},rr={pills:"ks-tab-bar-pills",underline:"ks-tab-bar-underline"},sr="ks-tab text-sm transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",nr="ks-tab transition max-sm:shrink-0 max-sm:whitespace-nowrap ks-tab-active",ar=({shape:e,count:o})=>e?t.createElement("span",{className:"ks-tab-count"},o):t.createElement(Re,{variant:"info"},o),ir=e=>typeof e=="string"?e!=="":e>0,lr=({tabs:e,value:o,onChange:s,align:r="center",shape:n})=>t.createElement("div",null,t.createElement("div",{className:_(or[r],rr[n])},e.map(i=>t.createElement("button",{key:i.value,type:"button",className:n?nr:sr,"data-active":i.value===o?"":void 0,onClick:()=>s(i.value)},i.label,ir(i.count)&&t.createElement(t.Fragment,null," ",t.createElement(ar,{shape:n,count:i.count}))))),e.find(i=>i.value===o)?.content),et=lr;var dr={error:"text-red-800 dark:text-red-400",ok:"text-emerald-800 dark:text-emerald-400"},tt="mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2",cr="max-sm:absolute max-sm:inset-0 max-sm:z-20",st={padding:"10px 14px",fontSize:12,display:"flex",flexDirection:"column",gap:6},ot={display:"flex",gap:8,textAlign:"left"},rt={flexShrink:0,whiteSpace:"nowrap"},pr=({check:e,onSelect:o})=>{let s=t.createElement(t.Fragment,null,t.createElement("span",{className:dr[e.level],style:{...rt,fontWeight:500}},e.level),e.node&&t.createElement("span",{className:"font-mono",style:rt},e.node),t.createElement("span",null,e.sentence));return e.node?t.createElement("button",{type:"button","data-check-row":!0,"data-step-id":e.node,style:{...ot,border:"none",background:"none",padding:0,cursor:"pointer",font:"inherit",color:"inherit"},onClick:()=>o(e.node)},s):t.createElement("div",{"data-check-row":!0,style:ot},s)},mr=({checks:e,onSelect:o})=>t.createElement("div",{style:st},e.map((s,r)=>t.createElement(pr,{key:r,check:s,onSelect:o}))),ur=()=>typeof window<"u"&&!!window.matchMedia?.("(max-width: 639px)").matches,fr=({checks:e,tabs:o,onSelect:s,opened:r=ur()?null:"validation"})=>{let[n,i]=w(r);return t.createElement(T,{as:"section","aria-label":"Validation and tests","data-drawer":!0,className:n?`${tt} ${cr}`:tt},t.createElement(et,{align:"start",shape:"underline",value:n,onChange:d=>i(d===n?null:d),tabs:[{value:"validation",label:"Validation",count:e.filter(d=>d.level==="error").length,content:t.createElement(mr,{checks:e,onSelect:s})},...o.map(d=>({value:d.label,label:d.label,count:d.count??"",content:t.createElement("div",{"data-drawer-content":!0,style:st,dangerouslySetInnerHTML:{__html:d.content}})}))]}))},nt=fr;var at={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},it=e=>({opacity:e?1:0,transition:"opacity .12s"}),gr=({link:e,onInsert:o,onRemove:s,onDrop:r,dragging:n,alwaysShowInsertButtons:i})=>{let[d,c]=w(!1),l=d||n;return t.createElement("div",{"data-connector":`${e.source}-${e.target}`,style:{position:"absolute",left:e.midX-34,top:e.midY-20,width:68,height:40,zIndex:4},onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onDragEnter:()=>c(!0),onDragLeave:()=>c(!1),onDragOver:h=>{h.preventDefault(),h.dataTransfer.dropEffect="move"},onDrop:h=>{h.preventDefault(),c(!1),r()}},t.createElement("div",{style:{display:"flex",gap:4,justifyContent:"center",alignItems:"center",height:"100%"}},t.createElement(v,{variant:"secondary",title:n?"Move the step here":"Insert a step here",onClick:o,className:"rounded-full data-[over=true]:ring-2 data-[over=true]:ring-accent-600","data-over":!!(n&&d),style:{...at,...it(l||i)}},"+"),!n&&t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:s,className:"rounded-full",style:{...at,...it(l)}},"\xD7")))},lt=gr;var xr=({links:e,extent:o,dragging:s,onInsert:r,onRemove:n,onDrop:i,alwaysShowInsertButtons:d})=>t.createElement(t.Fragment,null,t.createElement("svg",{width:o.width,height:o.height,style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1}},t.createElement("defs",null,t.createElement("marker",{id:"easy_flow-arrow",viewBox:"0 0 10 10",refX:"8",refY:"5",markerWidth:"5",markerHeight:"5",orient:"auto"},t.createElement("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-gray-400 dark:fill-zinc-500"}))),e.map(c=>t.createElement("path",{key:c.id,"data-link":c.id,className:"stroke-gray-400 dark:stroke-zinc-500",fill:"none",strokeWidth:"1.5",markerEnd:"url(#easy_flow-arrow)",d:c.path}))),e.filter(c=>c.label).map(c=>t.createElement("div",{key:`${c.id}-label`,"data-link-label":c.id,className:"bg-surface-50 text-gray-500 dark:bg-surface-950 dark:text-gray-400",style:{position:"absolute",left:c.midX+(d?2:-10),top:c.midY-18,zIndex:3,fontSize:11,padding:"0 3px"}},c.label)),e.filter(c=>!c.placeholder).map(c=>t.createElement(lt,{key:c.id,link:c,dragging:!!s,alwaysShowInsertButtons:d,onInsert:()=>r(c),onRemove:()=>n(c),onDrop:()=>i(c)}))),dt=xr;var ae={width:24,height:24,padding:0,fontSize:15,lineHeight:"15px"},ct="opacity-0 transition-opacity group-data-[over=true]:opacity-100",hr=({link:e,onInsert:o,onRemove:s,onDrop:r,alwaysShowInsertButtons:n,dragging:i})=>t.createElement("div",{"data-joint":e?.id,className:"group relative h-7 w-full sm:h-auto sm:w-7 sm:self-stretch",onMouseEnter:d=>{d.currentTarget.dataset.over="true"},onMouseLeave:d=>{delete d.currentTarget.dataset.over},onDragOver:d=>{e&&r&&(d.preventDefault(),d.dataTransfer.dropEffect="move")},onDrop:d=>{e&&(d.preventDefault(),r(e))}},e&&t.createElement("div",{className:"absolute left-1/2 top-0 h-full w-px bg-gray-400 sm:left-0 sm:top-1/2 sm:h-px sm:w-full dark:bg-zinc-500"}),e&&o&&t.createElement("div",{className:"absolute inset-0 flex items-center justify-center gap-1 sm:flex-col",style:{zIndex:4}},t.createElement(v,{variant:"secondary",title:"Insert a step here",onClick:d=>o(e,d),className:`rounded-full ${n?"opacity-100":ct}`,style:i?{...ae,opacity:1}:ae},"+"),t.createElement(v,{variant:"danger",title:"Remove this connection",onClick:()=>s(e),className:`rounded-full ${ct}`,style:ae},"\xD7"))),pt=hr;var yr=(e,o)=>e.row-o.row||e.column-o.column,mt=e=>{let o=[...e].sort(yr),s=o.filter(r=>e.some(n=>n.holds?.includes(r.id)));return o.filter(r=>!s.includes(r)).flatMap(r=>[r,...s.filter(n=>r.holds?.includes(n.id))])},ut=e=>{let o=mt(e),s=r=>o.some(n=>n.holds?.includes(r.id));return o.filter(r=>!s(r)).reduce((r,n)=>{if(n.holds)return[...r,{group:n,steps:o.filter(d=>n.holds.includes(d.id))}];let i=r[r.length-1];return i&&!i.group?[...r.slice(0,-1),{steps:[...i.steps,n]}]:[...r,{steps:[n]}]},[])},br=(e,o)=>e[e.findIndex(s=>s.id===o.id)+1]?.id,ft=(e,o,s)=>{let r=br(mt(s),e);return o.filter(n=>n.source===e.id&&(n.label||n.target!==r))},vr=e=>e?.placeholder?"nowhere yet":e?.label,gt=(e,o)=>[e.label,"\u2192",vr(o.find(s=>s.id===e.target))].filter(Boolean).join(" "),xt=(e,o,s)=>e.find(r=>r.source===o.id&&r.target===s.id);var kr={display:"flex",flexDirection:"column",gap:14,padding:"64px 24px 24px"},ht=({steps:e,edges:o,draw:s,joints:r})=>t.createElement("div",{"data-flow-row":!0,className:"flex flex-col sm:flex-row sm:flex-wrap sm:items-center sm:gap-y-3.5"},e.map((n,i)=>t.createElement("div",{key:n.id,className:"flex flex-col sm:flex-row sm:items-center"},i>0&&t.createElement(pt,{link:xt(o,e[i-1],n),...r}),s(n)))),wr={display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",borderRadius:8},Sr=({group:e,steps:o,edges:s,draw:r,joints:n})=>t.createElement("div",{"data-group-box":e.id,className:"border border-dashed border-gray-400 bg-white/60 dark:border-zinc-600 dark:bg-zinc-900/60",style:wr},r(e),t.createElement(ht,{steps:o,edges:s,draw:r,joints:n})),Cr=({nodes:e,edges:o,draw:s,joints:r,children:n,style:i})=>t.createElement("div",{"data-flow-rows":!0,style:{...kr,...i}},n,ut(e).map(d=>d.group?t.createElement(Sr,{key:d.group.id,group:d.group,steps:d.steps,edges:o,draw:s,joints:r}):t.createElement(ht,{key:d.steps[0].id,steps:d.steps,edges:o,draw:s,joints:r}))),K=Cr;var yt="Your change was not saved because the server could not be reached.",bt=({base:e,token:o,fetch:s,onFlow:r,onError:n,onNotice:i,onWarning:d=()=>{}})=>async(c,l,h)=>{let g=await s(e+c,{method:l,headers:{"Content-Type":"application/json","X-CSRF-Token":o},body:h&&JSON.stringify(h)}).catch(()=>null);if(!g)return i(null),n(yt);let u=await g.json().catch(()=>({}));if(u.unconnected)return i(null),n(null),d({path:c,steps:u.unconnected}),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json());if(d(null),!g.ok)return i(null),n(u.error||"That change was refused");n(null),i(u.notice||null),r(await(await s(e+".json",{headers:{Accept:"application/json"}})).json())},vt=({base:e,token:o,fetch:s,onError:r})=>async n=>{let i=new FormData;i.append("picture",n);let d=await s(e+"/pictures",{method:"POST",headers:{"X-CSRF-Token":o},body:i}).catch(()=>null);if(!d)return r(yt),null;let c=await d.json().catch(()=>({}));return d.ok?(r(null),c):(r(c.error||"That picture was refused"),null)};var Nr=(e,o,s)=>{let[r,n]=w(s),[i,d]=w(null),[c,l]=w(null),[h,g]=w(null),u=j(()=>bt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onFlow:n,onError:d,onNotice:l,onWarning:g}),[e,o]),x=j(()=>vt({base:e,token:o,fetch:(...y)=>window.fetch(...y),onError:d}),[e,o]);return{flow:r,error:i,notice:c,warning:h,setWarning:g,send:u,pickPicture:x}},kt=Nr;var Z=(e,o,s,r)=>{let n=e.left-s.left+r.scrollLeft,i=e.top-s.top+r.scrollTop;return o==="left"?{x:n,y:i+e.height/2}:o==="right"?{x:n+e.width,y:i+e.height/2}:o==="top"?{x:n+e.width/2,y:i}:{x:n+e.width/2,y:i+e.height}},_r=(e,o,s)=>s&&o==="top"?{x:e.x,y:s.top}:e,zr=(e,o)=>o==="top"?{x:e.x,y:e.y-3}:o==="left"?{x:e.x-3,y:e.y}:o==="right"?{x:e.x+3,y:e.y}:{x:e.x,y:e.y+3},Er=(e,o,s,r,n)=>{let i={straight:`M ${o.x} ${o.y} L ${s.x} ${s.y}`,turn:`M ${o.x} ${o.y} H ${s.x} V ${s.y}`,lane:`M ${o.x} ${o.y} V ${r} H ${s.x} V ${s.y}`,detour:`M ${o.x} ${o.y} H ${n} V ${s.y} H ${s.x}`}[e.route];return{...e,path:i,midX:e.route==="detour"?n:(o.x+s.x)/2,midY:e.route==="lane"?r:(o.y+s.y)/2}},Br=(e,o,s,r)=>{let[n,i]=w([]),[d,c]=w({width:"100%",height:"100%"}),[l,h]=w([]);return xe(()=>{let g=()=>{let x=o.current?.getBoundingClientRect();if(!x)return;c({width:o.current.scrollWidth,height:o.current.scrollHeight});let y=e.nodes.filter(m=>m.holds&&!m.loose&&s.current[m.id]).map(m=>{let S=s.current[m.id],k=S.getBoundingClientRect(),C=m.holds.flatMap(b=>s.current[b]?[s.current[b].getBoundingClientRect()]:[]),B=[{left:k.left,top:k.top,width:Math.max(k.width,S.scrollWidth),height:k.height},...C];return{id:m.id,bounds:Ce(B,x,o.current)}});h(y),i(e.edges.flatMap(m=>{let S=s.current[m.source]?.getBoundingClientRect(),k=s.current[m.target]?.getBoundingClientRect();if(!S||!k)return[];let C=Z(S,m.leaves,x,o.current),B=y.find(z=>z.id===m.target)?.bounds,b=zr(_r(Z(k,m.enters,x,o.current),m.enters,B),m.enters),f=(Z(S,"bottom",x,o.current).y+Z(k,"top",x,o.current).y)/2,O=m.leaves==="left"?Math.min(C.x,b.x)-28:Math.max(C.x,b.x)+28;return[Er(m,C,b,f,O)]}))};g(),window.addEventListener("resize",g);let u=new ResizeObserver(g);return o.current&&u.observe(o.current),()=>{window.removeEventListener("resize",g),u.disconnect()}},r),{links:n,extent:d,boxes:l}},wt=Br;var St=(e,o)=>{let s=new Set(o),r=e,n=2;for(;s.has(r);)r=`${e}_${n++}`;return r};var Ar=8,Dr={display:"flex",height:"100%",minHeight:0,fontSize:13,position:"relative"},Lr={flex:1,minWidth:0,display:"flex",flexDirection:"column",position:"relative"},Or={flex:1,minHeight:0,overflow:"auto",position:"relative"},Nt={position:"absolute",top:56,left:16,zIndex:5,width:264,padding:12,borderRadius:8},$r={...Nt,position:"static",alignSelf:"flex-start"},Pr={display:"grid",rowGap:64,columnGap:0,padding:40,justifyContent:"center",position:"relative"},Mr={position:"sticky",zIndex:8,top:8,margin:"8px auto 0",width:"fit-content",padding:"6px 12px",borderRadius:6,fontSize:12},Ir=({port:e,onCancel:o})=>t.createElement("div",{className:"bg-accent-100 text-accent-800 dark:bg-accent-900 dark:text-accent-100",style:Mr},"Choose the step \u201C",e||"next","\u201D should lead to \u2014 ",t.createElement("button",{onClick:o,className:"text-accent-800 underline dark:text-accent-100",style:{border:"none",background:"none",cursor:"pointer",fontSize:12,padding:0}},"cancel")),jr=({base:e,token:o,initial:s})=>{let{flow:r,error:n,notice:i,warning:d,setWarning:c,send:l,pickPicture:h}=kt(e,o,s),[g,u]=w(null),[x,y]=w(null),[m,S]=w(null),[k,C]=w(null),[B,b]=w(null),[f,O]=w(!1),z=ee({}),E=ee(null);P(()=>{let a={open:null,publish:"/publish",save_draft:"/versions"},p=N=>{let D=N.target.closest?.("[data-bar-action]");if(!D||!(D.dataset.barAction in a))return;D.closest("details")?.removeAttribute("open"),u(null),O(!0);let V=a[D.dataset.barAction];V&&l(V,"POST")};return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[l]),P(()=>{if(!f){c(null);return}let a=p=>{p.target.isConnected&&!p.target.closest("[data-builder-panel], [data-open-panel], [data-bar-action]")&&O(!1)};return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[f]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-named",{detail:r.flow?.title||r.flow?.slug}))},[r.flow?.title,r.flow?.slug]),P(()=>{document.dispatchEvent(new CustomEvent("easy_flow:flow-status",{detail:{status:r.flow?.status,publishes:r.flow?.publishes}}))},[r.flow?.status,r.flow?.publishes]);let At=j(()=>Object.fromEntries(r.nodes.map(a=>[a.id,a])),[r.nodes]),{links:Dt,extent:Lt,boxes:ie}=wt(r,E,z,[r,g,At]),le=j(()=>{let a={};return r.violations.forEach(p=>{var N;return(a[N=p.node]||(a[N]=[])).push(p)}),a},[r.violations]),A=r.direction==="left_to_right",H=r.nodes.filter(a=>!a.loose),de=r.nodes.filter(a=>a.loose),Ot=Math.max(0,...H.map(a=>a.row))+1,$t=Math.max(0,...H.map(a=>a.column))+1,Q=a=>{if(!m)return;let[p,N]=m;S(null),p!==a&&l("/edges","POST",{from:p,to:a,on:N||null})},Pt=a=>{if(a.isDefaultPrevented()||!k)return;a.preventDefault();let p=k;C(null);let N=E.current.getBoundingClientRect(),D=Ne(ie,{x:a.clientX-N.left+E.current.scrollLeft,y:a.clientY-N.top+E.current.scrollTop}),V=r.nodes.find(It=>It.holds?.includes(p))?.id||null;D!==V&&l(`/steps/${p}/group`,"PATCH",{group:D})},ce=a=>[...r.palette,...r.unoffered||[]].find(p=>p.type===a?.type),I=r.nodes.find(a=>a.id===g),$=ce(I),R=(a,p={})=>l("/steps","POST",{id:St(a.type,r.nodes.map(N=>N.id)),type:a.type,from:p.from,to:p.to,on:p.on}),pe=a=>{let[p,N]=[B,k];b(null),C(null),p?R(p,{from:a.source,to:a.target}):N&&l("/steps/"+N+"/move","PATCH",{from:a.source,to:a.target})},Mt=a=>{let p=E.current.getBoundingClientRect();return{x:a.clientX-p.left+E.current.scrollLeft+8,y:a.clientY-p.top+E.current.scrollTop+8}},me=a=>t.createElement(t.Fragment,null,a.placeholder&&t.createElement(We,{node:{...a,ref:p=>{z.current[a.id]=p}},dragging:!!k,compact:A,onFill:()=>y({from:a.from,on:a.on,at:{x:16,y:52}}),onDrop:()=>{let p=k;C(null),p&&l("/edges","POST",{from:a.from,to:p,on:a.on})}}),a.holds&&t.createElement(U,{node:{...a,ref:p=>{z.current[a.id]=p}},header:G(a,ce(a),r.hide_step_type_codes),compact:A,onSelect:()=>m?Q(a.id):u(a.id)}),!a.placeholder&&!a.holds&&t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:r.edges.filter(p=>p.source===a.id).map(p=>p.label||null)},selected:a.id===g,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m&&m[0]!==a.id,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{let D=E.current.getBoundingClientRect();y({from:a.id,on:p,at:{x:N.clientX-D.left+E.current.scrollLeft+8,y:N.clientY-D.top+E.current.scrollTop+8}})},onDragEnd:()=>C(null),onDragStart:()=>C(a.id),hideStepTypeCodes:r.hide_step_type_codes,compact:A,branches:A?ft(a,r.edges,H).map(p=>gt(p,r.nodes)):[]})),ue=de.length>0&&t.createElement("div",{"data-loose":!0,className:"border border-dashed border-gray-300 bg-gray-50 dark:border-zinc-700 dark:bg-zinc-900",style:A?$r:Nt},t.createElement("div",{className:"text-gray-500 dark:text-gray-400",style:{fontSize:11,marginBottom:6}},"Not in the flow yet \u2014 drag one onto a connection"),de.map(a=>t.createElement("div",{key:a.id,style:{marginBottom:8}},t.createElement(oe,{node:{...a,ref:p=>{z.current[a.id]=p},violations:le[a.id]||[],connected:[]},selected:g===a.id,armed:m&&m[0]===a.id?m[1]:null,connecting:!!m,onSelect:()=>m?Q(a.id):u(a.id),onOpen:p=>window.location.assign(p),onArm:(p,N)=>{N.stopPropagation(),S([a.id,p])},onDragStart:()=>C(a.id),onDragEnd:()=>C(null),hideStepTypeCodes:r.hide_step_type_codes}))));return t.createElement("div",{className:"text-gray-900 dark:text-gray-100",style:Dr,onMouseUp:()=>C(null),onKeyDown:a=>{a.key==="Escape"&&(u(null),S(null),y(null))},tabIndex:-1},t.createElement(Fe,{entries:r.palette,groups:r.step_groups||{},onPick:a=>R(a),onCarry:b,onDrop:()=>b(null)}),t.createElement("div",{className:"bg-surface-50 dark:bg-surface-950",style:Lr},t.createElement("div",{ref:E,style:Or,onClick:a=>{a.target===E.current&&(u(null),S(null),O(!1))},onDragOver:a=>{k&&a.preventDefault()},onDrop:Pt},m&&t.createElement(Ir,{port:m[1],onCancel:()=>S(null)}),t.createElement(Ge,{undoable:r.undoable,redoable:r.redoable,onAdd:()=>y({at:{x:16,y:52}}),onUndo:()=>{u(null),l("/undo","POST")},onRedo:()=>{u(null),l("/redo","POST")}}),!A&&ie.map(a=>t.createElement(Se,{key:a.id,id:a.id,bounds:a.bounds,onDrop:()=>{let p=k;C(null),p&&l(`/steps/${p}/group`,"PATCH",{group:a.id})}})),!A&&t.createElement(dt,{links:_e(Dt,r.nodes),extent:Lt,dragging:k||B,alwaysShowInsertButtons:r.always_show_insert_buttons,onInsert:a=>y({from:a.source,to:a.target,at:{x:a.midX+30,y:a.midY}}),onRemove:a=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}),!A&&ue,A&&t.createElement(K,{nodes:H,edges:r.edges,draw:me,joints:{alwaysShowInsertButtons:r.always_show_insert_buttons,dragging:!!(k||B),onInsert:(a,p)=>y({from:a.source,to:a.target,at:Mt(p)}),onRemove:a=>{u(null),l("/edges","DELETE",{from:a.source,to:a.target})},onDrop:pe}},ue),!A&&t.createElement("div",{style:{...Pr,gridTemplateColumns:`repeat(${$t+1}, ${280/2}px)`,gridTemplateRows:`repeat(${Ot}, auto)`}},H.map(a=>t.createElement("div",{key:a.id,style:{gridRow:a.row+1,gridColumn:`${a.column+1} / span 2`,zIndex:2,marginTop:ze(a,r.nodes)?Ar-64:0}},me(a)))),x&&t.createElement(Ve,{entries:r.palette,at:x.at,onDismiss:()=>y(null),hideStepTypeCodes:r.hide_step_type_codes,onConnect:x.on!==void 0?()=>{S([x.from,x.on]),y(null)}:null,onPick:a=>{let p=x;y(null),R(a,p)}})),t.createElement(nt,{checks:r.checks||[],tabs:r.drawer_tabs||[],onSelect:u})),f&&!I&&t.createElement(Qe,{flow:r.flow||{},changes:r.changes||[],refusal:n,notice:i,publishNote:r.publish_note,warning:d,onClose:()=>O(!1),onCreate:()=>l("/versions","POST"),onPublish:()=>l("/publish","POST"),onAccept:()=>l(d.path,"POST",{remove_unconnected:d.steps.map(a=>a.id)}),onDecline:()=>c(null),onSaveDetails:a=>l("/details","PATCH",{flow:a})}),I&&t.createElement(He,{node:I,fields:$?.fields||{},holds:$?.records||{},labels:$?.labels||{},explanations:$?.explanations||{},recordLabels:$?.record_labels||{},recordExplanations:$?.record_explanations||{},recordChoices:$?.record_choices||{},recordOutputsOf:$?.record_outputs_of||{},choices:Ee(I,$),onClose:()=>u(null),onSave:a=>l(`/steps/${I.id}`,"PATCH",{config:a}),onPickPicture:h,refusal:n,onDelete:()=>{u(null),l(`/steps/${I.id}`,"DELETE")}}))},_t=jr;var Hr={display:"block",minWidth:118,boxSizing:"border-box",borderRadius:6,padding:"8px 10px",textDecoration:"none"},Wr={fontSize:12,fontWeight:500,lineHeight:1.3},zt={done:"border-green-600 bg-green-50 dark:border-green-500 dark:bg-green-950",paused:"border-amber-500 bg-amber-50 dark:border-amber-400 dark:bg-amber-950",pending:"border-gray-300 bg-white text-gray-500 dark:border-zinc-700 dark:bg-zinc-900 dark:text-gray-400",failed:"border-red-600 bg-red-50 dark:border-red-500 dark:bg-red-950"},Et={done:"text-green-700 dark:text-green-400",paused:"text-amber-800 dark:text-amber-300",pending:"text-gray-500 dark:text-gray-400",failed:"text-red-700 dark:text-red-400"},Vr="ring-2 ring-accent-600 ring-offset-2 dark:ring-offset-zinc-950",Fr=({node:e,selected:o=!1})=>{let s=e.address?"a":"div";return t.createElement(s,{"data-step":e.id,href:e.address||void 0,className:`${e.state==="paused"?"border-2":"border"} ${zt[e.state]||zt.pending}${o?` ${Vr}`:""}`,style:Hr},t.createElement("div",{className:"font-mono text-gray-500 dark:text-gray-400",style:{fontSize:11}},e.type),t.createElement("div",{style:Wr},e.label,e.version&&t.createElement("span",{className:"text-gray-500 dark:text-gray-400",style:{fontWeight:400,marginLeft:4}},e.version)),e.status&&t.createElement("div",{className:Et[e.state]||Et.pending,style:{fontSize:11}},e.status))},Bt=Fr;var Ur={gap:12,padding:0},Gr=({nodes:e,edges:o,selected:s})=>t.createElement(K,{nodes:e,edges:o,joints:{},style:Ur,draw:r=>r.holds?t.createElement(U,{node:r,header:G(r,r,!1),compact:!0}):t.createElement(Bt,{node:r,selected:r.id===s})}),Tt=Gr;te("easy_flow/flow-editor",_t);te("easy_flow/run-view",Tt);document.addEventListener("easy_flow:flow-named",e=>{let o=document.querySelector("[data-flow-heading]");o&&(o.textContent=e.detail)});document.addEventListener("easy_flow:flow-status",({detail:e})=>{e.status&&document.querySelectorAll("[data-version-status]").forEach(o=>{o.textContent=e.status}),e.publishes&&document.querySelectorAll("[data-bar-action=publish]").forEach(o=>{o.textContent=`Publish v${e.publishes}`})});ve(document,fe);})();
|
|
@@ -13,7 +13,8 @@ module EasyFlow
|
|
|
13
13
|
"hide_step_type_codes" => flow_host.hide_step_type_codes?,
|
|
14
14
|
"direction" => flow_host.canvas_direction.to_s,
|
|
15
15
|
"step_groups" => flow_host.step_groups,
|
|
16
|
-
"publish_note" => flow_host.publish_note
|
|
16
|
+
"publish_note" => flow_host.publish_note,
|
|
17
|
+
"drawer_tabs" => flow_host.drawer_tabs_for(flow).map(&:to_h))
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def canvas_document(flow)
|
|
@@ -10,6 +10,7 @@ import TypePicker from "./TypePicker"
|
|
|
10
10
|
import StepList from "./StepList"
|
|
11
11
|
import Toolbar from "./Toolbar"
|
|
12
12
|
import Panel from "./Panel"
|
|
13
|
+
import Drawer from "./Drawer"
|
|
13
14
|
import ConnectorLayer from "./ConnectorLayer"
|
|
14
15
|
import LeftToRight from "./LeftToRight"
|
|
15
16
|
import useFlow from "./useFlow"
|
|
@@ -20,8 +21,9 @@ import { branchLine, branchesOf } from "./reading"
|
|
|
20
21
|
|
|
21
22
|
const HEADER_GAP = 8
|
|
22
23
|
|
|
23
|
-
const page = { display: "flex", height: "100%", minHeight: 0, fontSize: 13 }
|
|
24
|
-
const
|
|
24
|
+
const page = { display: "flex", height: "100%", minHeight: 0, fontSize: 13, position: "relative" }
|
|
25
|
+
const column = { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", position: "relative" }
|
|
26
|
+
const scroll = { flex: 1, minHeight: 0, overflow: "auto", position: "relative" }
|
|
25
27
|
const waiting = { position: "absolute", top: 56, left: 16, zIndex: 5, width: CARD + 24, padding: 12, borderRadius: 8 }
|
|
26
28
|
|
|
27
29
|
const waitingInRows = { ...waiting, position: "static", alignSelf: "flex-start" }
|
|
@@ -215,59 +217,62 @@ const Canvas = ({ base, token, initial }) => {
|
|
|
215
217
|
tabIndex={-1}>
|
|
216
218
|
<StepList entries={flow.palette} groups={flow.step_groups || {}}
|
|
217
219
|
onPick={(entry) => addStep(entry)} onCarry={setCarrying} onDrop={() => setCarrying(null)} />
|
|
218
|
-
<div
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{!leftToRight && <ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging || carrying} alwaysShowInsertButtons={flow.always_show_insert_buttons}
|
|
236
|
-
onInsert={(link) => setAdding({ from: link.source, to: link.target, at: { x: link.midX + 30, y: link.midY } })}
|
|
237
|
-
onRemove={(link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) }}
|
|
238
|
-
onDrop={dropOnLink} />}
|
|
239
|
-
|
|
240
|
-
{!leftToRight && waitingSteps}
|
|
241
|
-
|
|
242
|
-
{leftToRight && <LeftToRight nodes={attached} edges={flow.edges} draw={draw} joints={{
|
|
243
|
-
alwaysShowInsertButtons: flow.always_show_insert_buttons,
|
|
244
|
-
dragging: Boolean(dragging || carrying),
|
|
245
|
-
onInsert: (link, event) => setAdding({ from: link.source, to: link.target, at: pointed(event) }),
|
|
246
|
-
onRemove: (link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) },
|
|
247
|
-
onDrop: dropOnLink
|
|
248
|
-
}}>{waitingSteps}</LeftToRight>}
|
|
249
|
-
|
|
250
|
-
{!leftToRight && <div style={{ ...grid, gridTemplateColumns: `repeat(${columns + 1}, ${(CARD + GAP_X) / 2}px)`, gridTemplateRows: `repeat(${rows}, auto)` }}>
|
|
251
|
-
{attached.map((node) => (
|
|
252
|
-
<div key={node.id} style={{ gridRow: node.row + 1, gridColumn: `${node.column + 1} / span 2`, zIndex: 2, marginTop: underHeader(node, flow.nodes) ? HEADER_GAP - GAP_Y : 0 }}>
|
|
253
|
-
{draw(node)}
|
|
254
|
-
</div>
|
|
220
|
+
<div className="bg-surface-50 dark:bg-surface-950" style={column}>
|
|
221
|
+
<div ref={surface} style={scroll}
|
|
222
|
+
onClick={(event) => { if (event.target === surface.current) { setSelected(null); setArmed(null); setShowing(false) } }}
|
|
223
|
+
onDragOver={(event) => { if (dragging) event.preventDefault() }}
|
|
224
|
+
onDrop={regroup}>
|
|
225
|
+
{armed && (
|
|
226
|
+
<Choosing port={armed[1]} onCancel={() => setArmed(null)} />
|
|
227
|
+
)}
|
|
228
|
+
<Toolbar undoable={flow.undoable} redoable={flow.redoable}
|
|
229
|
+
onAdd={() => setAdding({ at: { x: 16, y: 52 } })}
|
|
230
|
+
onUndo={() => { setSelected(null); send("/undo", "POST") }}
|
|
231
|
+
onRedo={() => { setSelected(null); send("/redo", "POST") }} />
|
|
232
|
+
|
|
233
|
+
{!leftToRight && boxes.map((box) => (
|
|
234
|
+
<GroupBox key={box.id} id={box.id} bounds={box.bounds}
|
|
235
|
+
onDrop={() => { const held = dragging; setDragging(null); if (held) send(`/steps/${held}/group`, "PATCH", { group: box.id }) }} />
|
|
255
236
|
))}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
237
|
+
|
|
238
|
+
{!leftToRight && <ConnectorLayer links={linksOutside(links, flow.nodes)} extent={extent} dragging={dragging || carrying} alwaysShowInsertButtons={flow.always_show_insert_buttons}
|
|
239
|
+
onInsert={(link) => setAdding({ from: link.source, to: link.target, at: { x: link.midX + 30, y: link.midY } })}
|
|
240
|
+
onRemove={(link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) }}
|
|
241
|
+
onDrop={dropOnLink} />}
|
|
242
|
+
|
|
243
|
+
{!leftToRight && waitingSteps}
|
|
244
|
+
|
|
245
|
+
{leftToRight && <LeftToRight nodes={attached} edges={flow.edges} draw={draw} joints={{
|
|
246
|
+
alwaysShowInsertButtons: flow.always_show_insert_buttons,
|
|
247
|
+
dragging: Boolean(dragging || carrying),
|
|
248
|
+
onInsert: (link, event) => setAdding({ from: link.source, to: link.target, at: pointed(event) }),
|
|
249
|
+
onRemove: (link) => { setSelected(null); send("/edges", "DELETE", { from: link.source, to: link.target }) },
|
|
250
|
+
onDrop: dropOnLink
|
|
251
|
+
}}>{waitingSteps}</LeftToRight>}
|
|
252
|
+
|
|
253
|
+
{!leftToRight && <div style={{ ...grid, gridTemplateColumns: `repeat(${columns + 1}, ${(CARD + GAP_X) / 2}px)`, gridTemplateRows: `repeat(${rows}, auto)` }}>
|
|
254
|
+
{attached.map((node) => (
|
|
255
|
+
<div key={node.id} style={{ gridRow: node.row + 1, gridColumn: `${node.column + 1} / span 2`, zIndex: 2, marginTop: underHeader(node, flow.nodes) ? HEADER_GAP - GAP_Y : 0 }}>
|
|
256
|
+
{draw(node)}
|
|
257
|
+
</div>
|
|
258
|
+
))}
|
|
259
|
+
</div>}
|
|
260
|
+
|
|
261
|
+
{adding && (
|
|
262
|
+
<TypePicker entries={flow.palette} at={adding.at} onDismiss={() => setAdding(null)} hideStepTypeCodes={flow.hide_step_type_codes}
|
|
263
|
+
onConnect={adding.on !== undefined ? () => { setArmed([ adding.from, adding.on ]); setAdding(null) } : null}
|
|
264
|
+
onPick={(entry) => {
|
|
265
|
+
const where = adding
|
|
266
|
+
setAdding(null)
|
|
267
|
+
addStep(entry, where)
|
|
268
|
+
}} />
|
|
269
|
+
)}
|
|
270
|
+
</div>
|
|
271
|
+
<Drawer checks={flow.checks || []} tabs={flow.drawer_tabs || []} onSelect={setSelected} />
|
|
267
272
|
</div>
|
|
268
273
|
|
|
269
274
|
{showing && !selectedNode && (
|
|
270
|
-
<Panel flow={flow.flow || {}} changes={flow.changes || []}
|
|
275
|
+
<Panel flow={flow.flow || {}} changes={flow.changes || []} refusal={error} notice={notice} publishNote={flow.publish_note} warning={warning}
|
|
271
276
|
onClose={() => setShowing(false)}
|
|
272
277
|
onCreate={() => send("/versions", "POST")}
|
|
273
278
|
onPublish={() => send("/publish", "POST")}
|
|
@@ -3,11 +3,12 @@ import { toggled } from "./choices"
|
|
|
3
3
|
import Input from "keystone_ui-react/src/Input.jsx"
|
|
4
4
|
import Select from "keystone_ui-react/src/Select.jsx"
|
|
5
5
|
import Checkbox from "keystone_ui-react/src/Checkbox.jsx"
|
|
6
|
+
import RadioCards from "keystone_ui-react/src/RadioCards.jsx"
|
|
6
7
|
|
|
7
8
|
const offered = (choices) =>
|
|
8
9
|
(choices || []).map((choice) => (typeof choice === "object" ? choice : { value: choice, label: choice }))
|
|
9
10
|
|
|
10
|
-
const Control = ({ type, value, choices, onChange, onSettle, onPick, pictureUrl }) => {
|
|
11
|
+
const Control = ({ name, type, value, choices, onChange, onSettle, onPick, pictureUrl }) => {
|
|
11
12
|
if (type === "picture") {
|
|
12
13
|
return <div className="mb-3">
|
|
13
14
|
{value && pictureUrl && <img src={pictureUrl} alt="The step's picture" style={{ maxWidth: "100%" }} />}
|
|
@@ -25,6 +26,12 @@ const Control = ({ type, value, choices, onChange, onSettle, onPick, pictureUrl
|
|
|
25
26
|
</Select>
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
if (type === "radio_cards") {
|
|
30
|
+
return <div data-radio-cards className="mb-3 [&_label]:flex-[1_1_7rem] [&_.ks-radio-card]:flex [&_.ks-radio-card]:h-full">
|
|
31
|
+
<RadioCards name={name} value={value} options={choices || []} onChange={(e) => onSettle(e.target.value)} />
|
|
32
|
+
</div>
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
if (type === "multi_select") {
|
|
29
36
|
const chosen = Array.isArray(value) ? value : []
|
|
30
37
|
const toggle = (choice) => onSettle(toggled(chosen, choice))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import ValueList from "keystone_ui-react/src/ValueList.jsx"
|
|
3
|
+
import Disclosure from "keystone_ui-react/src/Disclosure.jsx"
|
|
4
|
+
import Code from "keystone_ui-react/src/Code.jsx"
|
|
5
|
+
|
|
6
|
+
const SECTION = "flex flex-col gap-1 mb-3"
|
|
7
|
+
|
|
8
|
+
const VALUES = "[&_dd]:font-mono"
|
|
9
|
+
|
|
10
|
+
const COLUMNS = "[&_.ks-value-list]:grid-cols-2 [&_.ks-value-list]:gap-2"
|
|
11
|
+
|
|
12
|
+
const ROWS = "[&_.ks-value-list]:font-mono [&_.ks-value-list]:flex [&_.ks-value-list]:flex-col [&_.ks-value-list]:gap-1 [&_.ks-value-list-row]:gap-2 [&_.ks-value-list-row]:py-0 [&_.ks-value-list-row]:border-0 [&_.ks-value-list-label]:basis-[90px]"
|
|
13
|
+
|
|
14
|
+
const CODE = "border-t border-gray-200 pt-2.5 dark:border-zinc-700 [&_.ks-disclosure]:border-0 [&_.ks-disclosure-summary]:flex-row-reverse [&_.ks-disclosure-summary]:justify-end [&_.ks-disclosure-summary]:gap-1 [&_.ks-disclosure-summary]:p-0 [&_.ks-disclosure-summary]:font-normal [&_.ks-disclosure-body]:p-0 [&_.ks-disclosure-body]:pt-1.5 [&_.ks-code-block]:p-2 [&_.ks-code-block]:text-[11px]"
|
|
15
|
+
|
|
16
|
+
const looks = (section) => {
|
|
17
|
+
if (!section.values) return `${SECTION} ${CODE}`
|
|
18
|
+
return section.columns ? `${SECTION} ${VALUES} ${COLUMNS}` : `${SECTION} ${VALUES} ${ROWS}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Details = ({ details }) => (
|
|
22
|
+
<>
|
|
23
|
+
{details.map((section, at) => (
|
|
24
|
+
<section key={at} className={looks(section)}>
|
|
25
|
+
{section.heading && <div className="text-gray-500 dark:text-gray-400">{section.heading}</div>}
|
|
26
|
+
{section.values && <ValueList rows={section.values} columns={section.columns} />}
|
|
27
|
+
{section.code && section.code.map((block) => (
|
|
28
|
+
<Disclosure key={block.summary} summary={block.summary}>
|
|
29
|
+
<Code>{block.code}</Code>
|
|
30
|
+
</Disclosure>
|
|
31
|
+
))}
|
|
32
|
+
</section>
|
|
33
|
+
))}
|
|
34
|
+
</>
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export default Details
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import Panel from "keystone_ui-react/src/Panel.jsx"
|
|
3
|
+
import Tabs from "keystone_ui-react/src/Tabs.jsx"
|
|
4
|
+
|
|
5
|
+
const LEVELS = { error: "text-red-800 dark:text-red-400", ok: "text-emerald-800 dark:text-emerald-400" }
|
|
6
|
+
|
|
7
|
+
const LOOK = "mx-6 mb-6 flex max-h-[45%] flex-none flex-col overflow-y-auto rounded-lg max-sm:m-0 max-sm:max-h-none max-sm:rounded-none [&_.ks-tab-bar]:mb-0 [&_.ks-tab-bar]:px-2"
|
|
8
|
+
|
|
9
|
+
const COVERING = "max-sm:absolute max-sm:inset-0 max-sm:z-20"
|
|
10
|
+
|
|
11
|
+
const body = { padding: "10px 14px", fontSize: 12, display: "flex", flexDirection: "column", gap: 6 }
|
|
12
|
+
|
|
13
|
+
const row = { display: "flex", gap: 8, textAlign: "left" }
|
|
14
|
+
|
|
15
|
+
const whole = { flexShrink: 0, whiteSpace: "nowrap" }
|
|
16
|
+
|
|
17
|
+
const Row = ({ check, onSelect }) => {
|
|
18
|
+
const shown = <>
|
|
19
|
+
<span className={LEVELS[check.level]} style={{ ...whole, fontWeight: 500 }}>{check.level}</span>
|
|
20
|
+
{check.node && <span className="font-mono" style={whole}>{check.node}</span>}
|
|
21
|
+
<span>{check.sentence}</span>
|
|
22
|
+
</>
|
|
23
|
+
|
|
24
|
+
return check.node
|
|
25
|
+
? <button type="button" data-check-row data-step-id={check.node} style={{ ...row, border: "none", background: "none", padding: 0, cursor: "pointer", font: "inherit", color: "inherit" }} onClick={() => onSelect(check.node)}>{shown}</button>
|
|
26
|
+
: <div data-check-row style={row}>{shown}</div>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Rows = ({ checks, onSelect }) => (
|
|
30
|
+
<div style={body}>
|
|
31
|
+
{checks.map((check, at) => <Row key={at} check={check} onSelect={onSelect} />)}
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const onAPhone = () => typeof window !== "undefined" && Boolean(window.matchMedia?.("(max-width: 639px)").matches)
|
|
36
|
+
|
|
37
|
+
const Drawer = ({ checks, tabs, onSelect, opened = onAPhone() ? null : "validation" }) => {
|
|
38
|
+
const [ open, setOpen ] = useState(opened)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Panel as="section" aria-label="Validation and tests" data-drawer className={open ? `${LOOK} ${COVERING}` : LOOK}>
|
|
42
|
+
<Tabs align="start" shape="underline" value={open} onChange={(chosen) => setOpen(chosen === open ? null : chosen)}
|
|
43
|
+
tabs={[ { value: "validation", label: "Validation", count: checks.filter((check) => check.level === "error").length, content: <Rows checks={checks} onSelect={onSelect} /> },
|
|
44
|
+
...tabs.map((tab) => ({ value: tab.label, label: tab.label, count: tab.count ?? "", content: <div data-drawer-content style={body} dangerouslySetInnerHTML={{ __html: tab.content }} /> })) ]} />
|
|
45
|
+
</Panel>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default Drawer
|
|
@@ -2,11 +2,14 @@ import React, { useEffect, useState } from "react"
|
|
|
2
2
|
import Control from "./Control"
|
|
3
3
|
import Records from "./Records"
|
|
4
4
|
import Explanation from "./Explanation"
|
|
5
|
+
import Details from "./Details"
|
|
5
6
|
import Panel from "keystone_ui-react/src/Panel.jsx"
|
|
6
7
|
import Button from "keystone_ui-react/src/Button.jsx"
|
|
7
8
|
import { Label } from "keystone_ui-react/src/FieldText.jsx"
|
|
8
9
|
|
|
9
|
-
const panel = { width:
|
|
10
|
+
const panel = { width: 320, padding: "14px 16px", overflowY: "auto", display: "flex", flexDirection: "column", fontSize: 12 }
|
|
11
|
+
|
|
12
|
+
const foot = { marginTop: "auto", paddingTop: 12, display: "flex", flexDirection: "column", gap: 8 }
|
|
10
13
|
|
|
11
14
|
const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, recordExplanations, recordChoices, recordOutputsOf, choices, onSave, onDelete, onClose, onPickPicture, refusal }) => {
|
|
12
15
|
const [ draft, setDraft ] = useState(node.config)
|
|
@@ -20,13 +23,15 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
|
-
<Panel as="aside" style={panel} data-inspector>
|
|
24
|
-
<div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8 }}>
|
|
25
|
-
<
|
|
26
|
+
<Panel as="aside" style={panel} className="max-sm:absolute max-sm:inset-0 max-sm:z-30 max-sm:!w-auto" data-inspector>
|
|
27
|
+
<div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8, marginBottom: 12 }}>
|
|
28
|
+
<div>
|
|
29
|
+
<p className="font-mono text-gray-500 dark:text-gray-400" style={{ fontSize: 11 }}>{node.id} · {node.type}</p>
|
|
30
|
+
<h2 style={{ fontSize: 15, fontWeight: 600 }}>{node.label}</h2>
|
|
31
|
+
</div>
|
|
26
32
|
<button title="Close" onClick={onClose} className="text-gray-500 dark:text-gray-400"
|
|
27
33
|
style={{ border: "none", background: "none", cursor: "pointer", fontSize: 18, lineHeight: 1 }}>×</button>
|
|
28
34
|
</div>
|
|
29
|
-
<p className="text-gray-500 dark:text-gray-400" style={{ fontSize: 11, marginBottom: 16 }}>{node.id} · {node.type}</p>
|
|
30
35
|
{refusal && <p className="text-red-800 dark:text-red-400" style={{ fontWeight: 600, marginBottom: 12 }} data-refusal>{refusal}</p>}
|
|
31
36
|
{Object.entries(fields).map(([ name, type ]) => (
|
|
32
37
|
<Label key={name}>
|
|
@@ -37,7 +42,7 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
|
|
|
37
42
|
outputsOf={(recordOutputsOf || {})[name]}
|
|
38
43
|
onChange={(next) => setDraft({ ...draft, [name]: next })}
|
|
39
44
|
onSettle={(next) => settle({ ...draft, [name]: next })} />
|
|
40
|
-
: <Control type={type} value={draft[name]} choices={choices[name]} pictureUrl={pictureUrl}
|
|
45
|
+
: <Control name={name} type={type} value={draft[name]} choices={choices[name]} pictureUrl={pictureUrl}
|
|
41
46
|
onChange={(next) => setDraft({ ...draft, [name]: next })}
|
|
42
47
|
onSettle={(next) => settle({ ...draft, [name]: next })}
|
|
43
48
|
onPick={async (file) => {
|
|
@@ -49,7 +54,17 @@ const Inspector = ({ node, fields, holds, labels, explanations, recordLabels, re
|
|
|
49
54
|
{(explanations || {})[name] && <Explanation text={explanations[name]} />}
|
|
50
55
|
</Label>
|
|
51
56
|
))}
|
|
52
|
-
<
|
|
57
|
+
<Details details={node.details || []} />
|
|
58
|
+
<div style={foot}>
|
|
59
|
+
{(node.links || []).length > 0 && (
|
|
60
|
+
<div style={{ display: "flex", gap: 8 }}>
|
|
61
|
+
{node.links.map((link) => (
|
|
62
|
+
<Button key={link.address} variant="secondary" size="sm" className="flex-1" href={link.address}>{link.label}</Button>
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
<Button variant="danger" size="sm" className="w-full" onClick={onDelete}>Delete step</Button>
|
|
67
|
+
</div>
|
|
53
68
|
</Panel>
|
|
54
69
|
)
|
|
55
70
|
}
|
|
@@ -16,7 +16,7 @@ const settling = (flow, name, onSaveDetails) => (event) => {
|
|
|
16
16
|
if (event.target.value !== (flow[name] ?? "")) onSaveDetails({ [name]: event.target.value })
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const Panel = ({ flow, changes,
|
|
19
|
+
const Panel = ({ flow, changes, refusal, notice, publishNote, warning, onCreate, onPublish, onAccept, onDecline, onSaveDetails, onClose }) => (
|
|
20
20
|
<KeystonePanel as="aside" style={sheet} data-builder-panel>
|
|
21
21
|
<div style={{ display: "flex", alignItems: "start", justifyContent: "space-between", gap: 8 }}>
|
|
22
22
|
<h2 style={{ fontWeight: 600 }} data-flow-name>{flow.title || flow.slug}</h2>
|
|
@@ -41,14 +41,8 @@ const Panel = ({ flow, changes, problems, refusal, notice, publishNote, warning,
|
|
|
41
41
|
</div>
|
|
42
42
|
)}
|
|
43
43
|
|
|
44
|
-
<
|
|
45
|
-
{refusal && <p className="text-
|
|
46
|
-
{notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ ...item, fontWeight: 600 }} data-notice>{notice}</p>}
|
|
47
|
-
{problems.length === 0 && !refusal
|
|
48
|
-
? <p className="text-gray-500 dark:text-gray-400" style={{ fontSize: 12 }}>Nothing wrong with this flow.</p>
|
|
49
|
-
: problems.map((problem) => (
|
|
50
|
-
<p key={`${problem.node}-${problem.problem}`} className="text-amber-700 dark:text-amber-400" style={item} data-problem>⚠ {problem.sentence}</p>
|
|
51
|
-
))}
|
|
44
|
+
{refusal && <p className="text-red-800 dark:text-red-400" style={{ ...item, fontWeight: 600, marginTop: 8 }} data-refusal>{refusal}</p>}
|
|
45
|
+
{notice && !refusal && <p className="text-emerald-800 dark:text-emerald-400" style={{ ...item, fontWeight: 600, marginTop: 8 }} data-notice>{notice}</p>}
|
|
52
46
|
|
|
53
47
|
<h2 style={heading}>Changes since the last version</h2>
|
|
54
48
|
{changes.length === 0
|
|
@@ -10,7 +10,7 @@ module EasyFlow
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def to_h
|
|
13
|
-
{ "nodes" => nodes, "edges" => edges, "palette" => palette, "unoffered" => unoffered, "violations" => violations }
|
|
13
|
+
{ "nodes" => nodes, "edges" => edges, "palette" => palette, "unoffered" => unoffered, "violations" => violations, "checks" => CheckList.new(violations).rows }
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
@@ -20,7 +20,7 @@ module EasyFlow
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def drawn_step(node)
|
|
23
|
-
{ "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => step_type_for(node)&.summary_of(node),
|
|
23
|
+
{ "id" => node.id, "type" => node.type, "type_name" => step_type_for(node)&.step_name, "label" => label_for(node), "summary" => step_type_for(node)&.summary_of(node), "details" => step_type_for(node)&.details_of(node).to_a, "links" => step_type_for(node)&.links_of(node).to_a,
|
|
24
24
|
"config" => node.config.merge(kept_values(node)), "ports" => [], "ends_here" => ends_here?(node), "begins_here" => begins_here?(node),
|
|
25
25
|
"starts_a_flow" => starts_a_flow?(node), "holds" => holds(node), "opens" => opens(node), "loose" => loose?(node), "choices" => choices_for(node), "record_choices" => record_choices_for(node), "placeholder" => false, "picture_url" => picture_url(node), **placed[node.id] }
|
|
26
26
|
end
|
|
@@ -138,7 +138,7 @@ module EasyFlow
|
|
|
138
138
|
end
|
|
139
139
|
|
|
140
140
|
def violations
|
|
141
|
-
Validator.new(@document, registry: @registry, flow: @flow).violations.map do |violation|
|
|
141
|
+
@violations ||= Validator.new(@document, registry: @registry, flow: @flow).violations.map do |violation|
|
|
142
142
|
{ "node" => violation.node, "problem" => violation.problem.to_s, "detail" => violation.detail, "sentence" => sentences.of(violation) }
|
|
143
143
|
end
|
|
144
144
|
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module EasyFlow
|
|
2
|
+
class CheckList
|
|
3
|
+
ALWAYS = {
|
|
4
|
+
"Every connection joins two steps that exist." => %w[missing_edge_target missing_edge_source],
|
|
5
|
+
"Every step has an id of its own that a flow can use." => %w[duplicate_id reserved_id],
|
|
6
|
+
"The flow has one start step, and nothing leads into it." => %w[no_beginning many_beginnings before_the_beginning],
|
|
7
|
+
"Every step can be reached from the start." => %w[unreachable],
|
|
8
|
+
"Every step comes after the steps it reads." => %w[unmet_requirement reading_an_unconnected_step],
|
|
9
|
+
"Every step has the settings it needs." => %w[missing_setting missing_value],
|
|
10
|
+
"Every flow a step starts can run and does not lead back here." => %w[missing_flow unrunnable_version owned_by_another_owner circular]
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
OPTIONAL = {
|
|
14
|
+
unrouted_value: { "Every answer leads to a next step." => %w[unrouted_value] },
|
|
15
|
+
unfollowed_path: { "Every path out of a step is connected." => %w[unfollowed_path] },
|
|
16
|
+
dead_end: { "Every path ends at an End step." => %w[dead_end past_the_end] }
|
|
17
|
+
}.freeze
|
|
18
|
+
|
|
19
|
+
def initialize(violations, checks: EasyFlow.checks)
|
|
20
|
+
@violations = violations
|
|
21
|
+
@checks = checks
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def rows
|
|
25
|
+
errors + passed
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def errors
|
|
31
|
+
@violations.map { |violation| { "level" => "error", "node" => violation["node"], "sentence" => violation["sentence"] } }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def passed
|
|
35
|
+
made.reject { |_sentence, problems| problems.intersect?(found) }.keys
|
|
36
|
+
.map { |sentence| { "level" => "ok", "node" => nil, "sentence" => sentence } }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def made
|
|
40
|
+
ALWAYS.merge(*@checks.map { |name| OPTIONAL.fetch(name) })
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def found
|
|
44
|
+
@violations.map { |violation| violation["problem"] }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -79,10 +79,14 @@ module EasyFlow
|
|
|
79
79
|
offered = choices[name]
|
|
80
80
|
return unless offered
|
|
81
81
|
|
|
82
|
-
stray = Array(value).find { |chosen| offered.exclude?(chosen) }
|
|
82
|
+
stray = Array(value).find { |chosen| values_of(offered).exclude?(chosen) }
|
|
83
83
|
"#{labels[name]} does not offer #{stray}" if stray
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
+
def values_of(offered)
|
|
87
|
+
offered.map { |choice| choice.is_a?(Hash) ? choice.stringify_keys["value"] : choice }
|
|
88
|
+
end
|
|
89
|
+
|
|
86
90
|
def over_limit(name, value)
|
|
87
91
|
allowed = @limits[name]
|
|
88
92
|
return unless allowed && Array(value).size > allowed
|
|
@@ -20,6 +20,7 @@ module EasyFlow
|
|
|
20
20
|
@outputs_of = {}
|
|
21
21
|
@kept = {}
|
|
22
22
|
@declared_outputs = []
|
|
23
|
+
@details = []
|
|
23
24
|
@required = []
|
|
24
25
|
@optional = []
|
|
25
26
|
@awaits_input = false
|
|
@@ -119,6 +120,18 @@ module EasyFlow
|
|
|
119
120
|
@summarizing = summarizing
|
|
120
121
|
end
|
|
121
122
|
|
|
123
|
+
def shows_values(heading = nil, columns: false, &values)
|
|
124
|
+
@details += [ ShownValues.new(heading: heading, columns: columns, values: values) ]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def shows_code(heading = nil, &code)
|
|
128
|
+
@details += [ ShownCode.new(heading: heading, code: code) ]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def links_to(&linking)
|
|
132
|
+
@linking = linking
|
|
133
|
+
end
|
|
134
|
+
|
|
122
135
|
def setting(name, type: nil, from: nil, outputs_of: nil, label: nil, explanation: nil, options: nil, limit: nil, check: nil, required: false, optional: false, kept_on: nil, attribute: nil, &entries)
|
|
123
136
|
type ||= :from_step if from
|
|
124
137
|
type ||= :from_step if outputs_of
|
|
@@ -147,7 +160,7 @@ module EasyFlow
|
|
|
147
160
|
|
|
148
161
|
def declare_choices(name, type, options)
|
|
149
162
|
return @choices[name] = options if options.present?
|
|
150
|
-
raise UnknownFieldType, "a #{type} must offer options" if %i[select multi_select].include?(type)
|
|
163
|
+
raise UnknownFieldType, "a #{type} must offer options" if %i[select multi_select radio_cards].include?(type)
|
|
151
164
|
end
|
|
152
165
|
|
|
153
166
|
def declare_entries(name, entries)
|
|
@@ -167,7 +180,7 @@ module EasyFlow
|
|
|
167
180
|
def to_step_type
|
|
168
181
|
StepType.new(id: @id, step_name: @step_name, settings: settings, awaits_input: @awaits_input,
|
|
169
182
|
ends_here: @ends_here, begins_here: @begins_here, starts_a_flow: @starts_a_flow, plays_the_picked_flow: @plays_the_picked_flow, holds_steps: @holds_steps, flow_chooser: @flow_chooser, run_chooser: @run_chooser, behaviour: @behaviour, routing: @routing,
|
|
170
|
-
display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming, summarizing: @summarizing,
|
|
183
|
+
display: @display, drawn_by: @drawn_by, naming_field: @naming_field, naming: @naming, summarizing: @summarizing, details: @details, linking: @linking,
|
|
171
184
|
outputs: @declared_outputs, outputs_named_by: @outputs_named_by, answer_check: @answer_check, answer_labelling: @answer_labelling, readiness: @readiness, return_rule: @return_rule, unsaved_refusal: @unsaved_refusal)
|
|
172
185
|
end
|
|
173
186
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module EasyFlow
|
|
2
|
+
class StepType
|
|
3
|
+
ShownValues = Data.define(:heading, :columns, :values) do
|
|
4
|
+
def drawn(node)
|
|
5
|
+
{ "heading" => heading, "columns" => columns,
|
|
6
|
+
"values" => values.call(node).to_h.map { |label, value| { "label" => label.to_s, "value" => value.to_s } } }
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -12,7 +12,7 @@ module EasyFlow
|
|
|
12
12
|
|
|
13
13
|
def initialize(id:, step_name:, settings:, awaits_input:, behaviour:, routing:,
|
|
14
14
|
ends_here: false, begins_here: false, starts_a_flow: false, plays_the_picked_flow: false, holds_steps: false, flow_chooser: nil, run_chooser: nil, display: nil, drawn_by: nil,
|
|
15
|
-
naming_field: nil, naming: nil, summarizing: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
|
|
15
|
+
naming_field: nil, naming: nil, summarizing: nil, details: [], linking: nil, outputs: [], outputs_named_by: nil, answer_check: nil, answer_labelling: nil, readiness: nil, return_rule: nil, unsaved_refusal: nil)
|
|
16
16
|
@id = id
|
|
17
17
|
@step_name = step_name
|
|
18
18
|
@settings = settings
|
|
@@ -31,6 +31,8 @@ module EasyFlow
|
|
|
31
31
|
@naming_field = naming_field
|
|
32
32
|
@naming = naming
|
|
33
33
|
@summarizing = summarizing
|
|
34
|
+
@details = details
|
|
35
|
+
@linking = linking
|
|
34
36
|
@outputs = outputs
|
|
35
37
|
@outputs_named_by = outputs_named_by
|
|
36
38
|
@answer_check = answer_check
|
|
@@ -84,6 +86,14 @@ module EasyFlow
|
|
|
84
86
|
@summarizing&.call(node).presence
|
|
85
87
|
end
|
|
86
88
|
|
|
89
|
+
def details_of(node)
|
|
90
|
+
@details.map { |detail| detail.drawn(node) }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def links_of(node)
|
|
94
|
+
Array(@linking&.call(node)).map { |link| link.to_h.symbolize_keys.then { |given| { "label" => given[:label].to_s, "address" => given[:address].to_s } } }
|
|
95
|
+
end
|
|
96
|
+
|
|
87
97
|
def acts?
|
|
88
98
|
@behaviour.present?
|
|
89
99
|
end
|
data/lib/easy_flow/host.rb
CHANGED
|
@@ -2,9 +2,14 @@ module EasyFlow
|
|
|
2
2
|
class Host
|
|
3
3
|
BackLink = Data.define(:label, :address)
|
|
4
4
|
Button = Data.define(:label, :address)
|
|
5
|
+
Tab = Data.define(:label, :count, :content) do
|
|
6
|
+
def initialize(label:, content:, count: nil)
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
end
|
|
5
10
|
|
|
6
11
|
attr_reader :name, :back_link
|
|
7
|
-
attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction, :editor_buttons
|
|
12
|
+
attr_writer :layout, :admin_layout, :offers, :allowed_answers, :always_show_insert_buttons, :hide_step_type_codes, :marks_ends, :on_publish, :canvas_direction, :editor_buttons, :drawer_tabs
|
|
8
13
|
attr_accessor :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method, :finds_flows_across_owners, :publish_note
|
|
9
14
|
|
|
10
15
|
def initialize(name)
|
|
@@ -24,6 +29,11 @@ module EasyFlow
|
|
|
24
29
|
Array(listed).map { |button| Button.new(**button) }
|
|
25
30
|
end
|
|
26
31
|
|
|
32
|
+
def drawer_tabs_for(flow)
|
|
33
|
+
listed = @drawer_tabs.respond_to?(:call) ? @drawer_tabs.call(flow) : @drawer_tabs
|
|
34
|
+
Array(listed).map { |tab| Tab.new(**tab) }
|
|
35
|
+
end
|
|
36
|
+
|
|
27
37
|
def setting_explanations=(explanations)
|
|
28
38
|
explained = explanations.to_h.deep_stringify_keys
|
|
29
39
|
raise ArgumentError, "an explanation must be text, and a list entry's setting is named like answers.weight" unless explained.values.flat_map(&:values).all? { |text| text.nil? || text.is_a?(String) }
|
data/lib/easy_flow/version.rb
CHANGED
data/lib/easy_flow.rb
CHANGED
|
@@ -7,7 +7,7 @@ require "easy_flow/host_routes"
|
|
|
7
7
|
require "easy_flow/engine"
|
|
8
8
|
|
|
9
9
|
module EasyFlow
|
|
10
|
-
FIELD_TYPES = %i[string integer float boolean select multi_select previous_step from_step list flow flows picture].freeze
|
|
10
|
+
FIELD_TYPES = %i[string integer float boolean select multi_select radio_cards previous_step from_step list flow flows picture].freeze
|
|
11
11
|
|
|
12
12
|
OUTPUT_TYPES = %i[string integer float boolean].freeze
|
|
13
13
|
OPTIONAL_CHECKS = %i[unrouted_value unfollowed_path dead_end].freeze
|
|
@@ -83,7 +83,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
83
83
|
4. Ask the developer which hosts' admins should be able to add the type. A registered type is in a host's palette, the step types an admin can add on that host's canvas, only when the host names no list of offered step types or its list includes the type's id. A type that declares `ends_here` is in every host's palette, and a type that declares `begins_here` is in none. When a host that names a list should offer the new type, add the type's id to that host's list through `easy_flow-install`. Leaving a type off a host's list only keeps admins from adding it there, and a step of that type already in one of the host's flows is still drawn and run, and still opens with all its settings and can be saved.
|
|
84
84
|
5. Use these words to declare the type. Each is called once at class level (or inside the `EasyFlow.step` block):
|
|
85
85
|
- `step_name "<label>"` — the name admins see on the canvas. Defaults to the id.
|
|
86
|
-
- `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select` or `:
|
|
86
|
+
- `setting :name, type:, label:, explanation:, options:, required:, optional:, limit:, check:, from:, outputs_of:, kept_on:, attribute:` — a field the admin fills in on the canvas. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, `:select`, `:multi_select`, `:radio_cards`, `:previous_step`, `:from_step`, `:list`, `:flow`, or boot raises `EasyFlow::UnknownFieldType`. A `:select`, `:multi_select` or `:radio_cards` must pass `options:`, or boot raises the same error. A `:radio_cards` setting is drawn in the step's settings as one keystone radio card per option, side by side with each card taking an equal share of the row, and one card per row when the panel is too narrow; its `options:` are hashes `{ value:, label:, hint: }`, as a fixed array or a lambda that works them out from the app's records (`options: -> { Release.aliases.map { |release| { value: release.alias, label: "#{release.alias} → #{release.version}", hint: release.stats_line } } }`), the chosen card's `value` is stored in `node.config`, and a saved value that is not one of the options' values is refused. `options:` is either an array of strings, or a lambda taking no arguments that returns one; the lambda is called each time the canvas is opened and each time an admin saves the step's settings, so the options follow the app's data without a restart (`options: -> { Region.order(:name).pluck(:code) }`). A saved setting whose value is no longer among the options is refused the next time the admin saves that step. When the options come from the app's records, ask the developer which records, which column is stored as the value, and whether the list must differ by account or host, since the lambda is passed nothing and the same list is offered everywhere the type is used. A `:list` must take a block of `setting` calls describing one entry. `:previous_step` lets the admin pick an earlier step, and is required unless declared with `optional: true`. Ask the developer whether a step of the type may be left without that earlier step, and when it may, declare `optional: true` and handle a blank value in the type's code. `outputs_of: :<setting>` offers the outputs of the step chosen in that setting, and `from: :<setting>` offers the values of the output chosen in that setting; either one makes the type `:from_step`. A required setting left blank shows a warning on the step's card that the step `needs a value for <label>`, and saving the flow as a new version and publishing it are refused until the admin fills it in. An `outputs_of:` setting left blank is flagged and refused the same way once the setting it reads names a step, whether or not it is declared `required:`. Inside a `:list` entry, a blank required setting, or a blank `outputs_of:` setting whose step is picked, shows `needs a value for <label> in <list label> entry <n>` for the entry at position `n` counting from 1. `optional:` has no effect inside a `:list` entry, where a `:previous_step` is required only when declared `required: true`. `:flow` lets the admin pick one of the flows the admin's list shows on the same host, offered by title, and is stored in `node.config` as that flow's id as a string. A `:flow` setting is not checked on save against the flows offered, so code that reads it looks the flow up through the host and handles a blank or unknown id. `limit:` is the most values a `:multi_select` takes. `check:` is a lambda given the value that returns an error message, or `nil` when the value is acceptable. `label:` defaults to the name humanized. `explanation:` is an optional sentence shown under the setting in the step's settings, inside a `:list` entry as well, and a setting with none shows nothing there. A host can replace it with its own through `setting_explanations`, set through `easy_flow-install`. `kept_on:` and `attribute:` keep the setting's value on one of the app's own records instead of in the flow; see "Keep a setting on one of the app's records".
|
|
87
87
|
- `output :name, type:, label:, values:, from:` — a value the step records. `type` is one of `:string`, `:integer`, `:float`, `:boolean`, or boot raises `EasyFlow::UnknownOutputType`. `values:` is an array or a lambda taking the node, listing the values the output can take; the canvas offers these as the connections leaving the step, so a type that routes must declare them. `from: :<setting>` takes the values from the step chosen in that setting. A Condition step requires the admin to pick one of the earlier step's outputs, so a type whose answer admins should test with a Condition declares at least one `output`, with `values:` so the Condition offers answers to pick.
|
|
88
88
|
- `outputs_named_by :<list setting>` — adds one output for each entry an admin enters in that `:list` setting, named by the entry's `name`, so the setting's entry block must declare `setting :name, type: :string`. Ask the developer whether the admin or the type decides the names of the values the step records. Do not pick.
|
|
89
89
|
- The named outputs follow any outputs the type declares with `output`, in the order the admin entered them. An entry with a blank `name` adds none.
|
|
@@ -106,6 +106,10 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
106
106
|
Here `CheckResult.for` is the app's own lookup.
|
|
107
107
|
- `names_by :setting` or `names_by { |node| ... }` — what the step is called on the canvas, from a setting or computed.
|
|
108
108
|
- `summarizes_by { |node| ... }` — the one line the step's card shows under its name on the canvas, worked out from the step's settings, such as `summarizes_by { |node| "role: #{node.config['role']} · #{node.config['hours']}h" }`. Return a short phrase, or `nil` or `""` to show no line. Without it the card shows no summary, and a step with problems shows its error count in the summary's place. The block is called every time the canvas is drawn, so it must not be slow and must not change anything, and like `names_by` its `node.config` holds no kept setting. Ask the developer what an admin should read about a step of this type without opening it.
|
|
109
|
+
- `shows_values(heading = nil, columns: false) { |node| ... }` — a read-only section of the step settings panel, shown under the step's editable settings. The block returns a hash of labels to values, such as `shows_values("Inputs") { |node| { "brief" => "load_brief.out.brief" } }`, and each value is shown as text in a monospace font. Without `columns:` each label sits beside its value with the labels in one column. With `columns: true` the pairs sit two to a row, each label above its value, such as `shows_values(columns: true) { |node| { "Timeout" => "90s", "Retry" => "3" } }`. Declare it several times for several sections, which are shown in the order declared. Nothing in a section can be edited from the panel.
|
|
110
|
+
- `shows_code(heading = nil) { |node| ... }` — a read-only section of the step settings panel holding code blocks. The block returns a hash of summary lines to code, such as `shows_code("Schemas") { |node| { "input_schema" => node.config["input_schema"].to_s } }`. Each block is closed until its summary line is clicked, and a line wider than the panel scrolls sideways inside its block.
|
|
111
|
+
- `links_to { |node| ... }` — buttons at the foot of the step settings panel, side by side above Delete step. The block returns a list of hashes each with a `label` and an `address`, such as `links_to { |node| [ { label: "Open agent", address: "/agents/#{node.config['agent']}" } ] }`. Each address is used as written.
|
|
112
|
+
- The blocks of `shows_values`, `shows_code` and `links_to` are called every time the canvas is drawn, so they must not be slow and must not change anything. Ask the developer what an admin should read about a step of this type in its settings without being able to change it, and which pages it should link to.
|
|
109
113
|
- `awaits_input` — the visitor is shown this step and submits an answer to it.
|
|
110
114
|
- `waits_until { |node, state| ... }` or `waits_until { |node, state, times| ... }` — the run stops at this step until the block returns a truthy value. See step 8.
|
|
111
115
|
- `answer_check { |node, value| ... }` — checks a submitted answer before it is recorded. `value` is the submitted string, an array of strings when the input submits several values, or `nil` or `""` when the input sent nothing. An array may hold blank strings. Return a message to refuse the answer, or `nil` to accept it. Without it every answer is accepted, including a blank one. For a file input, see step 7.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: easy_flow-info
|
|
3
|
-
description: Use to learn what easy_flow offers — guided flows an admin draws on a canvas and a visitor runs one step at a time, versioned documents of steps and connections, flows that loop back to ask a step again, a loop that stops a run when nothing new was answered and the step it came back to, whether a run ended at an End step, hosts and the step types each offers its admins, runs and the published version each starts on, each visit a run records with its value and the time the step was completed, and the output a flow gives when it ends, the built-in step types including questions and checklists that can require an answer and explain each answer behind an info button, file upload steps that hand a visitor's file to the app's file store and read it back by its name, and branching on an answer, including one named output of a step that recorded several, on comparing a number with an amount, or on comparing two earlier answers or one earlier answer with an amount alone, steps flagged when they name an earlier step without choosing which of its outputs to read, branching on a list of such comparisons that must all hold or of which any one must hold, branching on the hour, weekday or minute a step was completed, Wait steps that hold a run until a number of minutes or a time of day after an earlier step was completed, or until a date, and are named after what they wait for, the Check again button a visitor sees at a waiting step in a flow that keeps nothing, Count steps that count how often an earlier step was answered so a loop can give up after a number of tries, Flow steps that name another flow, open its canvas when their card is clicked with a button back to the flow it was opened from, start a run of it for the same owner when a stored run reaches them, are flagged when the flow or version they name cannot run or leads back to the flow they sit in, let the waiting run name that inner run, move that run on along the output it ends with, leave it waiting when the inner run is stopped by a loop, and fail with an error naming the step when its version was taken out of service or its inner run ended with no output, removing a flow and why it is refused while a waiting run depends on it, step types the host app registers, including ones whose outputs are named by the entries an admin lists in one of their settings, ones that start another flow and work out which flow and version to run from their own settings and are named after that flow, or choose it from the run they are in, the answers a host allows a step in a run and the steps it fills in or passes over, the checks they make on an answer, what a step shows a visitor and how that can depend on the visitor's run, and steps that hold a run until something outside the flow has happened, group steps drawn as a box an admin drags steps into and out of, and the settings an admin fills in, including picks whose options come from the app's data and settings kept on one of the app's own records.
|
|
3
|
+
description: Use to learn what easy_flow offers — guided flows an admin draws on a canvas and a visitor runs one step at a time, versioned documents of steps and connections, flows that loop back to ask a step again, a loop that stops a run when nothing new was answered and the step it came back to, whether a run ended at an End step, hosts and the step types each offers its admins, runs and the published version each starts on, each visit a run records with its value and the time the step was completed, and the output a flow gives when it ends, the built-in step types including questions and checklists that can require an answer and explain each answer behind an info button, file upload steps that hand a visitor's file to the app's file store and read it back by its name, and branching on an answer, including one named output of a step that recorded several, on comparing a number with an amount, or on comparing two earlier answers or one earlier answer with an amount alone, steps flagged when they name an earlier step without choosing which of its outputs to read, branching on a list of such comparisons that must all hold or of which any one must hold, branching on the hour, weekday or minute a step was completed, Wait steps that hold a run until a number of minutes or a time of day after an earlier step was completed, or until a date, and are named after what they wait for, the Check again button a visitor sees at a waiting step in a flow that keeps nothing, Count steps that count how often an earlier step was answered so a loop can give up after a number of tries, Flow steps that name another flow, open its canvas when their card is clicked with a button back to the flow it was opened from, start a run of it for the same owner when a stored run reaches them, are flagged when the flow or version they name cannot run or leads back to the flow they sit in, let the waiting run name that inner run, move that run on along the output it ends with, leave it waiting when the inner run is stopped by a loop, and fail with an error naming the step when its version was taken out of service or its inner run ended with no output, removing a flow and why it is refused while a waiting run depends on it, step types the host app registers, including ones whose outputs are named by the entries an admin lists in one of their settings, ones that start another flow and work out which flow and version to run from their own settings and are named after that flow, or choose it from the run they are in, the answers a host allows a step in a run and the steps it fills in or passes over, the checks they make on an answer, what a step shows a visitor and how that can depend on the visitor's run, and steps that hold a run until something outside the flow has happened, group steps drawn as a box an admin drags steps into and out of, and the settings an admin fills in, including picks whose options come from the app's data, choices drawn as radio cards with a hint under each, and settings kept on one of the app's own records.
|
|
4
4
|
tools: Read
|
|
5
5
|
scope: guided flows — versioned documents of steps and the connections between them, drawn on a canvas by an admin and run by a visitor one step at a time, with step types the host registers
|
|
6
6
|
---
|
|
@@ -54,8 +54,8 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
54
54
|
- **Step type** — what a kind of step is: its display name, its settings (the fields an admin fills in), its outputs (the values it records), and whether it waits for the visitor, acts on its own, or waits for something outside the flow. A step that acts on its own may record a value worked out from the answers so far, pick which connection to follow, or both.
|
|
55
55
|
- **Display** — what a step type hands the visitor's page to draw a step, such as its question text and its answers. A step type may build its display from the step alone, or from the step and the visitor's stored run, so the same step can show something different to each visitor. There is no stored run in an admin's preview or in a flow that carries its answers in the page, and the display is then built without one. A host can draw a single-choice, multiple-select or fill-in-the-blank step with an answer already chosen by passing it as `chosen`, and the step is drawn blank when none is passed.
|
|
56
56
|
- **Answer check** — a rule a step type may carry that looks at a visitor's answer and, when the answer is not acceptable, returns the message the visitor sees. A step type with no such rule accepts every answer.
|
|
57
|
-
- **Setting** — one field an admin fills in when configuring a step on the canvas. A step type may give a setting a one-sentence explanation, which shows under it in the step's settings. It is text, a whole number, a decimal, a yes or no, a pick from a list, several picks from a list, an earlier step, an earlier step's output, another flow of the same host, or a list of entries that each hold their own fields. A setting can be required, limited to a number of picks, or checked by a rule the step type supplies.
|
|
58
|
-
- **Options** — the values a pick-from-a-list setting offers. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A saved value that is not among the options is refused.
|
|
57
|
+
- **Setting** — one field an admin fills in when configuring a step on the canvas. A step type may give a setting a one-sentence explanation, which shows under it in the step's settings. It is text, a whole number, a decimal, a yes or no, a pick from a list, a pick from a few choices drawn as radio cards side by side with a hint under each, several picks from a list, an earlier step, an earlier step's output, another flow of the same host, or a list of entries that each hold their own fields. A setting can be required, limited to a number of picks, or checked by a rule the step type supplies.
|
|
58
|
+
- **Options** — the values a pick-from-a-list setting offers, and for a radio card setting each value's label and hint. They are either a fixed list written into the step type, or a lookup the app provides that is read each time the canvas or a save asks for them, so they can come from the app's own data. A saved value that is not among the options is refused.
|
|
59
59
|
- **Kept setting** — a setting whose value lives on one of the app's own records rather than in the flow. The step type says how to find that record from the step's other settings and which of its attributes holds the value. The canvas shows the value read from the record, and saving the step's settings writes it straight to the record, so the flow's document and its versions never hold it and undo or publishing does not change it. When no record is found, nothing is written. When the record refuses a value, the save is refused with the record's own error and none of the step's kept settings are written.
|
|
60
60
|
- **Output** — a value a step records into the run, with a type and a label. Later steps read outputs, and a setting that points at an earlier step offers that step's known values on the canvas. A step type may also take further outputs from a list setting, one for each entry the admin gives a name, labelled with that name written as a phrase, such as "First reading" for `first_reading`. An entry left without a name adds no output. Those outputs are offered wherever the step's declared outputs are, such as when a Condition, Compare, Compare two values, All of or Any of or Count step picks which output to read.
|
|
61
61
|
- **Chosen output** — which of an earlier step's outputs a step reads. Every built-in step that names an earlier step and then reads one of its outputs asks the admin to pick that output, as does a step type of the app's own whose output setting points at a step setting. Once the earlier step is named, a step with no output picked is reported as missing that setting, and the same holds for each comparison in an All of or Any of list, for its first step and for its second step. A step that names no earlier step, such as a Compare two values step with its second step left empty, is not asked for that step's output.
|
|
@@ -102,7 +102,7 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
102
102
|
- **Offered step types** — the list of step types a host names for its admins to add. A host that names no list offers every registered step type. The list only narrows the palette.
|
|
103
103
|
- **Allowed answers** — a rule a host may carry that looks at a step and the answers given so far in a run and names the answer values that step allows. When it names nothing for a step, the step offers every answer. When it names several, a question or checklist offers only those. When it names exactly one, the step records that answer without being shown, and when it names none, the step is passed over and records a blank answer. This holds in a stored run, a run moved on outside a visitor's request, a flow that carries its answers in the page, and an admin's preview. Going back skips the steps the host filled in and returns to the last step the visitor was shown.
|
|
104
104
|
- **Always-visible insert buttons** — a setting a host may turn on, `always_show_insert_buttons`, that shows each connection's button for inserting a step on its canvas without the pointer over the connection, with the connection's label moved to the right of the line. It is off by default, and with it off the button shows only with the pointer over the connection.
|
|
105
|
-
- **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the
|
|
105
|
+
- **Step card** — the box that draws one step on the canvas. It shows the step's name, the one-line summary the step's type works out from its settings under the name when the type declares one, and the step's type code under those, or above the name on a left-to-right canvas. A step with problems is bordered in red and its card counts them under the name, such as "1 error" or "2 errors", in place of the summary, and the sentence for each problem is in the Validation tab of the drawer under the canvas rather than on the card.
|
|
106
106
|
- **Hidden step type codes** — a setting a host may turn on, `hide_step_type_codes`, that hides step type code names on its canvas. The add menu lists each step type by its name alone, and a step's box shows its step type's name in place of the code name, with a step that has no name of its own headed by its step type's name. It is off by default, and with it off the add menu and step boxes show the code names. The settings panel shows a step's id and code name either way.
|
|
107
107
|
- **Canvas direction** — a setting a host may set, `canvas_direction`, to `:left_to_right` to lay its canvas out left to right in place of top to bottom. Steps sit as compact cards in rows joined by short lines, a row that reaches the edge of the canvas goes on in a new row, each branch or loop that leads anywhere but the step beside it is written on its step's card with the step it leads to, a group step's box takes a row of its own, and a phone-width screen shows one step per row. Top to bottom is the default.
|
|
108
108
|
- **Step list** — a list beside the editing canvas, on screens 640 pixels and wider, of every step type the host offers, with a search field that keeps only the types whose name holds what was typed. A host may set `step_groups`, a hash of headings each with the step types listed under it, in the host's order, and the types it puts in no group are listed above the first heading. Clicking a type adds the step unconnected, as the add menu does, and dragging a type onto a connection inserts the step on that connection. On a phone the list is hidden and the add menu is the way to add steps.
|
|
@@ -113,7 +113,9 @@ easy_flow declares no commands of its own for this local. Its surface is split b
|
|
|
113
113
|
- **Editor buttons** — a setting a host may set, `editor_buttons`, holding a list of buttons each with a label and an address, or a callable that takes the flow being shown and returns that list, whose buttons the top bar shows before `Save draft`, such as Run tests and Dry-run. The app decides what each address does. With none set, the bar shows no extra buttons.
|
|
114
114
|
- **On publish** — a setting a host may set, `on_publish`, holding a callable that takes a flow. easy_flow calls it each time a new version of one of that host's flows goes live, from the canvas's Publish button or from the app calling publish. Publishing a version that is already live does not call it. With none set, nothing is called.
|
|
115
115
|
- **Host setting explanations** — a setting a host may set, `setting_explanations`, giving its own explanation for one setting of one step type, including a setting inside a list. It shows in place of the step type's own. A setting it gives none for shows the step type's own, and with none set nothing changes.
|
|
116
|
-
- **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish
|
|
116
|
+
- **Flow panel** — the panel the top bar's `This flow`, `Save draft` and `Publish` buttons open on the canvas, on every host. It shows Create version and Publish, the message saying what the last of them did or why it was refused, and the list of changes since the last version. Several saves to the same step in a row show as one line in the changes list, named by the step's latest name. A save, a move and any other change each keep their own line, and the history of versions still lists every change a version captured.
|
|
117
|
+
- **Drawer** — the panel under the editing canvas, on every host, with a row of tabs. Its first tab is Validation, followed by the number of problems the flow has when it has any. Validation lists one row per check: an `error` row for each problem with the step's id and a sentence naming the step by its name, or by its step type's name when it has none, and saying what to do to clear it, then an `ok` row for each check that found nothing. Clicking a row that names a step selects that step and opens its settings. A host may set `drawer_tabs` to add its own tabs after Validation, each with a label, an optional count such as `12/12` and its own content. On a phone the drawer shows only its tabs until one is tapped, an open drawer covers the canvas, and tapping the open tab again closes it.
|
|
118
|
+
- **Step settings panel** — the panel on the right of the canvas that opens when a step is selected. It is 320 pixels wide and shows the step's id and type, its name, its editable settings, then the read-only sections its step type declares with `shows_values` and `shows_code`, and at its foot the buttons the type declares with `links_to` above Delete step. On a phone it covers the canvas from edge to edge.
|
|
117
119
|
- **Picture mark** — the words `Has a picture` on the box of a step with a picture on the canvas, on every host.
|
|
118
120
|
- **Palette** — the step types an admin can add on a host's canvas. It never holds the start step, always holds the end step, and otherwise holds the step types the host offers. A step already in a flow whose type the host does not offer is still drawn and run, and still opens with all its settings and can be saved.
|
|
119
121
|
- **Run** — one visitor's pass through a flow. A run may belong to one of the app's own records, its owner, which the app sets. A run is pinned to the version it started on, so publishing a new version does not change a run already under way. A run starts on the live version unless the app chooses another of the flow's published versions. A run is refused when the chosen version is a draft, is retired or withdrawn, or belongs to another flow. It records each visit, and going back discards the last visit on the path.
|
|
@@ -66,6 +66,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
66
66
|
- `publish_note` — a sentence shown directly under the Publish button in this host's flow panel. It is shown as plain text. With none set, the panel shows no note.
|
|
67
67
|
- `back_link` — a hash with a `label` and an `address`, such as `{ label: "Games", address: "/admin/games" }`, that shows a link with that label and address at the start of this host's editor top bar in place of `All flows`. The bar then has no `All flows` link. A hash missing either key raises `ArgumentError` when the host is declared, and a blank value is not refused. The address is used as written and is not checked, so it comes from the app's own configuration and never from a request. It may instead be a callable that takes the flow being shown and returns that hash, such as `->(flow) { { label: "Funnel", address: "/funnels/#{flow.owner_id}" } }`, so each flow's canvas links to a page of its own, such as its owner record's page. A returned hash missing either key raises `ArgumentError` when that flow's canvas is opened. With none set, the bar shows `All flows`.
|
|
68
68
|
- `editor_buttons` — a list of hashes each with a `label` and an `address`, such as `[ { label: "Run tests", address: "/admin/flow_tests" }, { label: "Dry-run", address: "/admin/dry_runs" } ]`, shown as buttons in this host's editor top bar before `Save draft`, on the canvas and on the definition text page. On a phone they are reached from the bar's actions menu. It may instead be a callable that takes the flow being shown and returns that list, such as `->(flow) { [ { label: "Run tests", address: "/admin/flow_tests/#{flow.slug}" } ] }`, so each flow's buttons lead to pages of its own. A hash missing either key raises `ArgumentError` when the canvas is opened. Each address is used as written, so it comes from the app's own configuration and never from a request. The app decides what each address does. With none set, the bar shows no extra buttons. Ask the developer which buttons each host's editor needs.
|
|
69
|
+
- `drawer_tabs` — a list of hashes each with a `label`, an optional `count` and its `content` as HTML, such as `[ { label: "Fixtures", count: "12/12", content: "<p>12 of 12 fixtures pass.</p>" }, { label: "Dry-run", content: "<p>No dry-run yet.</p>" } ]`, shown as tabs after Validation in the drawer under this host's canvas. The count is written after the label, and a tab with no count shows only its label. It may instead be a callable that takes the flow being edited and returns that list, such as `->(flow) { [ { label: "Fixtures", count: FixtureRun.score(flow), content: ApplicationController.render(partial: "flows/fixtures", locals: { flow: flow }) } ] }`. The content is put on the page as given, so it is built by the app and any value from a record in it is escaped. The list is worked out each time the canvas is drawn, so a slow lookup slows the canvas. A hash missing `label` or `content` raises `ArgumentError` when the canvas is opened. With none set, the drawer shows only Validation. Ask the developer which tabs each host's drawer needs and what each shows.
|
|
69
70
|
- `on_publish` — a callable that takes a flow, such as `->(flow) { RecountJob.perform_later(flow.id) }`, that easy_flow calls each time a new version of one of this host's flows goes live, whether an admin pressed Publish on the canvas or the app called `publish` on the flow. It runs inside the publish request, so slow work belongs in a job it starts. Publishing a version that is already live does not call it. With none set, nothing is called. Ask the developer what the app must do when a flow goes live.
|
|
70
71
|
- `setting_explanations` — this host's own explanations for step type settings, as a hash of step type name to setting name to a sentence, such as `{ multiple_select: { category: "The round this question counts toward.", "answers.weight" => "Points this answer adds to the score." } }`. A setting inside a list is named by the list and the setting joined with a dot, and a list setting's own explanation is named by the list alone. The sentence is shown as plain text under the setting in the step's settings, in place of the step type's own. A setting with none, or with a blank one, shows the step type's own, if it has one. A step type or setting name that matches nothing is ignored. A value that is not text, such as a nested hash, raises `ArgumentError` when the host is declared. With none set, every setting shows the step type's own explanation.
|
|
71
72
|
|
|
@@ -169,6 +170,7 @@ A Rails engine for flows an admin draws on a canvas and a visitor runs one step
|
|
|
169
170
|
- A page of the app that calls `easy_flow_run_view` needs the `keystone_ui/react` and `easy_flow/canvas` scripts in its head, the same two the canvas page loads. The helper needs no setting in the initializer, and it is available in every view of the app. After adding one, check that the page shows each step's card with the state and status line the app supplied, and that a phone-width screen shows one card per row.
|
|
170
171
|
- After setting `step_groups` on a host, check that its canvas shows the step list beside the canvas with each step type under its heading, that typing in its search field narrows the list, that clicking a type adds an unconnected step, that dragging a type onto a connection inserts it there, and that a phone-width screen shows no step list.
|
|
171
172
|
- After setting `editor_buttons` on a host, check that its canvas's top bar shows each button between `Try it` and `Save draft` with the label given, that each opens its address, and that on a phone-width screen the buttons are listed in the bar's actions menu.
|
|
173
|
+
- After setting `drawer_tabs` on a host, check that the drawer under its canvas shows each tab after Validation with its count, that choosing a tab shows its content, and that on a phone-width screen the drawer shows only its tabs until one is tapped.
|
|
172
174
|
- Every stored run keeps each step's value together with the time the step was completed. An app upgrading from a version that kept values alone runs `bin/rails easy_flow:install:migrations` and `bin/rails db:migrate` before any stored run takes an answer. The migration wraps each value its existing runs already hold, and those values carry no completion time. Running the migration back drops every completion time.
|
|
173
175
|
- After install, check that a Compare step, a Compare two values step, or a comparison of an All of or Any of step, once its earlier step is picked, offers "Hour completed", "Weekday completed" and "Minutes since 1970 when completed" beside that step's own outputs. They need no setting in the initializer.
|
|
174
176
|
- After install, check that a Wait step placed on the canvas asks for the earlier step it counts from, minutes after it, a time of day as HH:MM and a date as YYYY-MM-DD. It needs no migration beyond the one that keeps each step's completion time with its value and no setting in the initializer beyond being listed in a host's `offers` when that host sets `offers`.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: easy_flow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.48.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -82,6 +82,8 @@ files:
|
|
|
82
82
|
- app/javascript/easy_flow/canvas/Connector.jsx
|
|
83
83
|
- app/javascript/easy_flow/canvas/ConnectorLayer.jsx
|
|
84
84
|
- app/javascript/easy_flow/canvas/Control.jsx
|
|
85
|
+
- app/javascript/easy_flow/canvas/Details.jsx
|
|
86
|
+
- app/javascript/easy_flow/canvas/Drawer.jsx
|
|
85
87
|
- app/javascript/easy_flow/canvas/Explanation.jsx
|
|
86
88
|
- app/javascript/easy_flow/canvas/GroupBox.jsx
|
|
87
89
|
- app/javascript/easy_flow/canvas/GroupHeader.jsx
|
|
@@ -116,6 +118,7 @@ files:
|
|
|
116
118
|
- app/models/easy_flow/asked.rb
|
|
117
119
|
- app/models/easy_flow/canvas.rb
|
|
118
120
|
- app/models/easy_flow/change.rb
|
|
121
|
+
- app/models/easy_flow/check_list.rb
|
|
119
122
|
- app/models/easy_flow/choice.rb
|
|
120
123
|
- app/models/easy_flow/chosen_flow.rb
|
|
121
124
|
- app/models/easy_flow/compare.rb
|
|
@@ -152,6 +155,8 @@ files:
|
|
|
152
155
|
- app/models/easy_flow/step.rb
|
|
153
156
|
- app/models/easy_flow/step_type.rb
|
|
154
157
|
- app/models/easy_flow/step_type/declaration.rb
|
|
158
|
+
- app/models/easy_flow/step_type/shown_code.rb
|
|
159
|
+
- app/models/easy_flow/step_type/shown_values.rb
|
|
155
160
|
- app/models/easy_flow/steps/checklist.rb
|
|
156
161
|
- app/models/easy_flow/steps/file_upload.rb
|
|
157
162
|
- app/models/easy_flow/steps/fill_in_the_blank.rb
|