@hievilmath/browser-formidavim 1.4.20 → 1.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Quick notes about changes made to this package for each version.
4
4
 
5
- ## Version 1.4.20
5
+ ## Version 1.4.20-21
6
6
  - Testing pipeline rendering optimizations.
7
7
 
8
8
  ---
package/index.js CHANGED
@@ -3379,4 +3379,4 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
3379
3379
  position: relative;
3380
3380
  `,Cw=({$isPreview:e,children:r})=>I.jsx(Fu.Provider,{store:dU,children:I.jsx(ge.ThemeProvider,{theme:fU,children:I.jsx(pU,{$isPreview:e,children:I.jsx(hU,{children:r})})})}),qA=({flowForm:e,isPreview:r,evaluatedFormComponents:i,formidavimHost:s})=>!e||!e.form?null:I.jsx(XA,{form:e.form,isPreview:r,evaluatedFormComponents:i,formidavimHost:s}),ww=class ww{static register(r,i){this.registry[r]=i}static getComponent(r){return this.registry[r]||null}static hasComponent(r){return r in this.registry}static getRegisteredComponents(){return Object.keys(this.registry)}};ww.registry={...Jj};let q0=ww;const QA=({formComponent:e,isPreview:r,boundary:i,isVisible:s=!0,formidavimHost:c})=>{var f;const p=v=>{const b=v.componentId;if(!b)return I.jsx(Cp,{errors:["Missing componentId"]});const S=q0.getComponent(b);return S?I.jsx(S,{formComponent:v,formidavimHost:c}):I.jsx(Cp,{errors:[`Unknown component type: ${b}`]})};return I.jsx(Q0,{children:I.jsx(lv,{$span:"12",children:I.jsx(tM,{$margin:(f=e.props)==null?void 0:f.margin,$boundary:i,children:p(e)})})})},XA=({form:e,isPreview:r,evaluatedFormComponents:i,formidavimHost:s})=>{const c=r?i:i.filter(f=>f.shouldRender),p=c.length;return I.jsx(I.Fragment,{children:c.map((f,v)=>{const b=v===0?"first":p===v+1?"last":null,S=f.isVisible;return I.jsx(QA,{formComponent:f,isPreview:r,boundary:b,isVisible:S,formidavimHost:s},f.id)})})},mU=ge.form`
3381
3381
  padding: 20px 0px 20px;
3382
- `,KA=({children:e,$bgColor:r})=>I.jsx(bp,{$overflow:"visible",$position:"static",$xSmall:!0,id:"MainFlowContainer",$bgColor:r||"white",$bRad:"0px",$marginBottom:"80px",$marginBottomMd:"0px",children:I.jsx(mU,{onSubmit:i=>i.preventDefault(),children:e})}),ZA=({dataFetcher:e=()=>{},children:r,configFetcher:i,isPreview:s=!1,onSubmit:c=()=>Promise.resolve(),formidavimHost:p,version:f,flowName:v="",onNextStep:b,onPrevStep:S,onFlowInit:T,onConfigFetchError:w,shouldRedirect:R,onFormidavimFallback:A})=>{const L=uv(p),[P,j]=Ve.useState({config:null,data:null}),[G,W]=Ve.useState(!0);if(Ve.useEffect(()=>{W(!0),(i?i():L.flowControllerGetBySlug(v,f).then(({data:N})=>N)).then(async N=>{const z=e?await e("flow"):null;j({config:N,data:z}),W(!1)}).catch(N=>{console.warn("configFetcher failed",N),w&&w(N),W(!1)})},[v,f]),G)return null;if(!P.config)return A&&A(),I.jsx(I.Fragment,{children:r});const k=async(V,N)=>{const z=await c(V,N);if(z&&typeof z=="function"){z();return}};return I.jsx(Cw,{children:I.jsx(Sw,{data:P.data,isPreview:s,config:P.config,onSubmit:k,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})})},vU=({dataFetcher:e=()=>Promise.resolve(null),children:r,configFetcher:i,pipelineFetcher:s,isPreview:c=!1,onSubmit:p=()=>Promise.resolve(),formidavimHost:f,version:v,flowName:b="",onNextStep:S,onPrevStep:T,onFlowInit:w,onPipelineInit:R,onNoFlowsAvailable:A,onConfigFetchError:L,onFormidavimFallback:P})=>{const j=uv(f),[G,W]=Ve.useState({config:null,data:null}),[k,V]=Ve.useState([]),[N,z]=Ve.useState({}),[Z,ie]=Ve.useState(!0),[me,M]=Ve.useState(!1);Ve.useEffect(()=>{console.log("pipeline render flowName",b),ie(!0),(s?s():j.pipelineControllerGetBySlug(b,v).then(({data:ne})=>ne)).then(async ne=>{const de=e?await e("pipeline"):null;if(W({config:ne,data:de}),ne!=null&&ne.pipelineFlows&&(await ue(ne.pipelineFlows,de.data)).length===0){A&&A();return}R&&R(ne),ie(!1)}).catch(ne=>{console.warn("configFetcher failed",ne),L&&L(ne),ie(!1)})},[b,v]),Ve.useEffect(()=>{var ne;console.log("useeffect visiblePipelineFlows",k);const ye=((ne=k==null?void 0:k[0])==null?void 0:ne.flow)||{};z(ye)},[k]);const ue=async(ye,ne)=>{var te;console.log("evaluatePipelineFlows - pipelineFlows",ye),console.log("evaluatePipelineFlows - patientData",ne);const de=[],Re=Te=>ne==null?void 0:ne[Te],Se=()=>ne,le=(Te,B)=>{const Y=ne==null?void 0:ne.flow_submissions;return!(!Y||!Y[Te])};for(const Te of ye)le(Te.flowSlug,(te=Te.flow)==null?void 0:te.version)||Te.condition&&!await WA(Te.condition,Re,Se)||de.push(Te);return console.log("evaluatedFlows",de),V(de),de};if(Z)return console.log("pipeline is loading"),null;if(!G.config)return console.log("flow datarender fallback"),I.jsx(ZA,{dataFetcher:e,configFetcher:i,flowName:b,formidavimHost:f,onSubmit:p,isPreview:!1,onNextStep:S,onPrevStep:T,onFlowInit:w,onFormidavimFallback:P,children:r});const Ee=async ye=>{var ne;if(!me){M(!0);try{const de=await p(ye,N),Re=e?await e("pipeline"):null;if(W(Se=>({...Se,data:Re})),(ne=G.config)!=null&&ne.pipelineFlows){const Se=await ue(G.config.pipelineFlows,Re.data);if(Object.keys(Se).length===0&&de&&typeof de=="function"){M(!1),de(G.config);return}}else if(de&&typeof de=="function"){M(!1),de(G.config);return}}finally{M(!1)}}},pe=ye=>{console.log("wrappedOnFlowInit",ye),w&&w(ye,G.config)};return I.jsx(Cw,{children:I.jsx(Sw,{data:G.data,isPreview:c,config:N,onSubmit:Ee,onNextStep:S,onPrevStep:T,onFlowInit:pe,shouldRedirect:!1,formidavimHost:f})})};exports.ComponentFactory=q0;exports.DataRenderer=ZA;exports.FlowFormRenderer=qA;exports.FlowProgressTracker=J$;exports.FlowRenderer=YA;exports.FormComponentRenderer=QA;exports.FormRenderer=XA;exports.FormWrapper=KA;exports.PipelineProcessor=vU;exports.Renderer=Sw;exports.RendererWrapper=Cw;
3382
+ `,KA=({children:e,$bgColor:r})=>I.jsx(bp,{$overflow:"visible",$position:"static",$xSmall:!0,id:"MainFlowContainer",$bgColor:r||"white",$bRad:"0px",$marginBottom:"80px",$marginBottomMd:"0px",children:I.jsx(mU,{onSubmit:i=>i.preventDefault(),children:e})}),ZA=({dataFetcher:e=()=>{},children:r,configFetcher:i,isPreview:s=!1,onSubmit:c=()=>Promise.resolve(),formidavimHost:p,version:f,flowName:v="",onNextStep:b,onPrevStep:S,onFlowInit:T,onConfigFetchError:w,shouldRedirect:R,onFormidavimFallback:A})=>{const L=uv(p),[P,j]=Ve.useState({config:null,data:null}),[G,W]=Ve.useState(!0);if(Ve.useEffect(()=>{W(!0),(i?i():L.flowControllerGetBySlug(v,f).then(({data:N})=>N)).then(async N=>{const z=e?await e("flow"):null;j({config:N,data:z}),W(!1)}).catch(N=>{console.warn("configFetcher failed",N),w&&w(N),W(!1)})},[v,f]),G)return null;if(!P.config)return A&&A(),I.jsx(I.Fragment,{children:r});const k=async(V,N)=>{const z=await c(V,N);if(z&&typeof z=="function"){z();return}};return I.jsx(Cw,{children:I.jsx(Sw,{data:P.data,isPreview:s,config:P.config,onSubmit:k,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})})},vU=({dataFetcher:e=()=>Promise.resolve(null),children:r,configFetcher:i,pipelineFetcher:s,isPreview:c=!1,onSubmit:p=()=>Promise.resolve(),formidavimHost:f,version:v,flowName:b="",onNextStep:S,onPrevStep:T,onFlowInit:w,onPipelineInit:R,onNoFlowsAvailable:A,onConfigFetchError:L,onFormidavimFallback:P})=>{const j=uv(f),[G,W]=Ve.useState({config:null,data:null}),[k,V]=Ve.useState([]),[N,z]=Ve.useState({}),[Z,ie]=Ve.useState(!0),[me,M]=Ve.useState(!1);Ve.useEffect(()=>{console.log("pipeline render flowName",b),ie(!0),(s?s():j.pipelineControllerGetBySlug(b,v).then(({data:ne})=>ne)).then(async ne=>{const de=e?await e("pipeline"):null;if(W({config:ne,data:de}),ne!=null&&ne.pipelineFlows&&(await ue(ne.pipelineFlows,de.data)).length===0){A&&A();return}R&&R(ne),ie(!1)}).catch(ne=>{console.warn("configFetcher failed",ne),L&&L(ne),ie(!1)})},[b,v]),Ve.useEffect(()=>{var ne;console.log("useeffect visiblePipelineFlows",k);const ye=((ne=k==null?void 0:k[0])==null?void 0:ne.flow)||{};z(ye)},[k]);const ue=async(ye,ne)=>{var te;console.log("evaluatePipelineFlows - pipelineFlows",ye),console.log("evaluatePipelineFlows - patientData",ne);const de=[],Re=Te=>ne==null?void 0:ne[Te],Se=()=>ne,le=(Te,B)=>{const Y=ne==null?void 0:ne.flow_submissions;return!(!Y||!Y[Te])};for(const Te of ye)le(Te.flowSlug,(te=Te.flow)==null?void 0:te.version)||Te.condition&&!await WA(Te.condition,Re,Se)||de.push(Te);return console.log("evaluatedFlows",de),V(de),de};if(Z)return console.log("pipeline is loading"),null;if(!G.config)return console.log("flow datarender fallback"),I.jsx(ZA,{dataFetcher:e,configFetcher:i,flowName:b,formidavimHost:f,onSubmit:p,isPreview:!1,onNextStep:S,onPrevStep:T,onFlowInit:w,onFormidavimFallback:P,children:r});const Ee=async ye=>{var ne;if(!me){M(!0);try{const de=await p(ye,N),Re=e?await e("pipeline"):null;if(W(Se=>({...Se,data:Re})),(ne=G.config)!=null&&ne.pipelineFlows){const Se=await ue(G.config.pipelineFlows,Re.data);if(Object.keys(Se).length===0&&de&&typeof de=="function"){M(!1),await de(G.config);return}}else if(de&&typeof de=="function"){M(!1),await de(G.config);return}}finally{M(!1)}}},pe=ye=>{console.log("wrappedOnFlowInit",ye),w&&w(ye,G.config)};return I.jsx(Cw,{children:I.jsx(Sw,{data:G.data,isPreview:c,config:N,onSubmit:Ee,onNextStep:S,onPrevStep:T,onFlowInit:pe,shouldRedirect:!1,formidavimHost:f})})};exports.ComponentFactory=q0;exports.DataRenderer=ZA;exports.FlowFormRenderer=qA;exports.FlowProgressTracker=J$;exports.FlowRenderer=YA;exports.FormComponentRenderer=QA;exports.FormRenderer=XA;exports.FormWrapper=KA;exports.PipelineProcessor=vU;exports.Renderer=Sw;exports.RendererWrapper=Cw;
package/index.mjs CHANGED
@@ -48319,11 +48319,11 @@ const xU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48319
48319
  if (W((xe) => ({ ...xe, data: Te })), (ne = G.config) != null && ne.pipelineFlows) {
48320
48320
  const xe = await ue(G.config.pipelineFlows, Te.data);
48321
48321
  if (Object.keys(xe).length === 0 && fe && typeof fe == "function") {
48322
- M(!1), fe(G.config);
48322
+ M(!1), await fe(G.config);
48323
48323
  return;
48324
48324
  }
48325
48325
  } else if (fe && typeof fe == "function") {
48326
- M(!1), fe(G.config);
48326
+ M(!1), await fe(G.config);
48327
48327
  return;
48328
48328
  }
48329
48329
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hievilmath/browser-formidavim",
3
- "version": "1.4.20",
3
+ "version": "1.4.21",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
6
  "typings": "./index.d.ts",