@hievilmath/browser-formidavim 1.4.15 → 1.4.16

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.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/index.mjs +2 -2
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -3358,4 +3358,4 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
3358
3358
  position: relative;
3359
3359
  `,Cw=({$isPreview:e,children:r})=>L.jsx(Fu.Provider,{store:cU,children:L.jsx(xe.ThemeProvider,{theme:uU,children:L.jsx(fU,{$isPreview:e,children:L.jsx(dU,{children:r})})})}),QA=({flowForm:e,isPreview:r,evaluatedFormComponents:i,formidavimHost:s})=>!e||!e.form?null:L.jsx(KA,{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={...Kj};let q0=ww;const XA=({formComponent:e,isPreview:r,boundary:i,isVisible:s=!0,formidavimHost:c})=>{var f;const p=v=>{const b=v.componentId;if(!b)return L.jsx(Cp,{errors:["Missing componentId"]});const S=q0.getComponent(b);return S?L.jsx(S,{formComponent:v,formidavimHost:c}):L.jsx(Cp,{errors:[`Unknown component type: ${b}`]})};return L.jsx(Q0,{children:L.jsx(lv,{$span:"12",children:L.jsx(nM,{$margin:(f=e.props)==null?void 0:f.margin,$boundary:i,children:p(e)})})})},KA=({form:e,isPreview:r,evaluatedFormComponents:i,formidavimHost:s})=>{const c=r?i:i.filter(f=>f.shouldRender),p=c.length;return L.jsx(L.Fragment,{children:c.map((f,v)=>{const b=v===0?"first":p===v+1?"last":null,S=f.isVisible;return L.jsx(XA,{formComponent:f,isPreview:r,boundary:b,isVisible:S,formidavimHost:s},f.id)})})},pU=xe.form`
3360
3360
  padding: 20px 0px 20px;
3361
- `,ZA=({children:e,$bgColor:r})=>L.jsx(bp,{$overflow:"visible",$position:"static",$xSmall:!0,id:"MainFlowContainer",$bgColor:r||"white",$bRad:"0px",$marginBottom:"80px",$marginBottomMd:"0px",children:L.jsx(pU,{onSubmit:i=>i.preventDefault(),children:e})}),JA=({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 M=uv(p),[k,j]=Ve.useState({config:null,data:null}),[G,W]=Ve.useState(!0);if(Ve.useEffect(()=>{(i?i():M.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(!k.config)return A&&A(),L.jsx(L.Fragment,{children:r});const P=async(V,N)=>{const z=await c(V,N);if(z&&typeof z=="function"){z();return}};return L.jsx(Cw,{children:L.jsx(Sw,{data:k.data,isPreview:s,config:k.config,onSubmit:P,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})})},hU=({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:M,onFormidavimFallback:k})=>{const j=uv(f),[G,W]=Ve.useState({config:null,data:null}),[P,V]=Ve.useState([]),[N,z]=Ve.useState({}),[Z,ie]=Ve.useState(!0),[ae,I]=Ve.useState(!1);Ve.useEffect(()=>{(s?s():j.pipelineControllerGetBySlug(b,v).then(({data:pe})=>pe)).then(async pe=>{const le=e?await e("pipeline"):null;if(W({config:pe,data:le}),pe!=null&&pe.pipelineFlows&&(await ve(pe.pipelineFlows,le.data)).length===0){A&&A();return}R&&R(pe),ie(!1)}).catch(pe=>{console.warn("configFetcher failed",pe),M&&M(pe),ie(!1)})},[b,v]),Ve.useEffect(()=>{var pe;console.log("visiblePipelineFlows",P);const de=((pe=P==null?void 0:P[0])==null?void 0:pe.flow)||{};z(de)},[P]);const ve=async(de,pe)=>{var se;const le=[],he=ee=>pe==null?void 0:pe[ee],Te=()=>pe,we=(ee,Re)=>{const B=pe==null?void 0:pe.flow_submissions;return!(!B||!B[ee])};for(const ee of de)we(ee.flowSlug,(se=ee.flow)==null?void 0:se.version)||ee.condition&&!await YA(ee.condition,he,Te)||le.push(ee);return V(le),le};if(Z)return null;if(!G.config)return L.jsx(JA,{dataFetcher:e,configFetcher:i,flowName:b,formidavimHost:f,onSubmit:p,isPreview:!1,onNextStep:S,onPrevStep:T,onFlowInit:w,onFormidavimFallback:k,children:r});const Ee=async de=>{var pe;if(!ae){I(!0);try{const le=await p(de,N),he=e?await e("pipeline"):null;if(W(Te=>({...Te,data:he})),(pe=G.config)!=null&&pe.pipelineFlows){const Te=await ve(G.config.pipelineFlows,he.data);if(Object.keys(Te).length===0&&le&&typeof le=="function"){le();return}}else if(le&&typeof le=="function"){le();return}}finally{I(!1)}}};return L.jsx(Cw,{children:L.jsx(Sw,{data:G.data,isPreview:c,config:N,onSubmit:Ee,onNextStep:S,onPrevStep:T,onFlowInit:w,shouldRedirect:!1,formidavimHost:f})})};exports.ComponentFactory=q0;exports.DataRenderer=JA;exports.FlowFormRenderer=QA;exports.FlowProgressTracker=e3;exports.FlowRenderer=qA;exports.FormComponentRenderer=XA;exports.FormRenderer=KA;exports.FormWrapper=ZA;exports.PipelineProcessor=hU;exports.Renderer=Sw;exports.RendererWrapper=Cw;
3361
+ `,ZA=({children:e,$bgColor:r})=>L.jsx(bp,{$overflow:"visible",$position:"static",$xSmall:!0,id:"MainFlowContainer",$bgColor:r||"white",$bRad:"0px",$marginBottom:"80px",$marginBottomMd:"0px",children:L.jsx(pU,{onSubmit:i=>i.preventDefault(),children:e})}),JA=({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 M=uv(p),[k,j]=Ve.useState({config:null,data:null}),[G,W]=Ve.useState(!0);if(Ve.useEffect(()=>{W(!0),(i?i():M.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(!k.config)return A&&A(),L.jsx(L.Fragment,{children:r});const P=async(V,N)=>{const z=await c(V,N);if(z&&typeof z=="function"){z();return}};return L.jsx(Cw,{children:L.jsx(Sw,{data:k.data,isPreview:s,config:k.config,onSubmit:P,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})})},hU=({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:M,onFormidavimFallback:k})=>{const j=uv(f),[G,W]=Ve.useState({config:null,data:null}),[P,V]=Ve.useState([]),[N,z]=Ve.useState({}),[Z,ie]=Ve.useState(!0),[ae,I]=Ve.useState(!1);Ve.useEffect(()=>{ie(!0),(s?s():j.pipelineControllerGetBySlug(b,v).then(({data:pe})=>pe)).then(async pe=>{const le=e?await e("pipeline"):null;if(W({config:pe,data:le}),pe!=null&&pe.pipelineFlows&&(await ve(pe.pipelineFlows,le.data)).length===0){A&&A();return}R&&R(pe),ie(!1)}).catch(pe=>{console.warn("configFetcher failed",pe),M&&M(pe),ie(!1)})},[b,v]),Ve.useEffect(()=>{var pe;console.log("visiblePipelineFlows",P);const de=((pe=P==null?void 0:P[0])==null?void 0:pe.flow)||{};z(de)},[P]);const ve=async(de,pe)=>{var se;const le=[],he=ee=>pe==null?void 0:pe[ee],Te=()=>pe,we=(ee,Re)=>{const B=pe==null?void 0:pe.flow_submissions;return!(!B||!B[ee])};for(const ee of de)we(ee.flowSlug,(se=ee.flow)==null?void 0:se.version)||ee.condition&&!await YA(ee.condition,he,Te)||le.push(ee);return V(le),le};if(Z)return null;if(!G.config)return L.jsx(JA,{dataFetcher:e,configFetcher:i,flowName:b,formidavimHost:f,onSubmit:p,isPreview:!1,onNextStep:S,onPrevStep:T,onFlowInit:w,onFormidavimFallback:k,children:r});const Ee=async de=>{var pe;if(!ae){I(!0);try{const le=await p(de,N),he=e?await e("pipeline"):null;if(W(Te=>({...Te,data:he})),(pe=G.config)!=null&&pe.pipelineFlows){const Te=await ve(G.config.pipelineFlows,he.data);if(Object.keys(Te).length===0&&le&&typeof le=="function"){le();return}}else if(le&&typeof le=="function"){le();return}}finally{I(!1)}}};return L.jsx(Cw,{children:L.jsx(Sw,{data:G.data,isPreview:c,config:N,onSubmit:Ee,onNextStep:S,onPrevStep:T,onFlowInit:w,shouldRedirect:!1,formidavimHost:f})})};exports.ComponentFactory=q0;exports.DataRenderer=JA;exports.FlowFormRenderer=QA;exports.FlowProgressTracker=e3;exports.FlowRenderer=qA;exports.FormComponentRenderer=XA;exports.FormRenderer=KA;exports.FormWrapper=ZA;exports.PipelineProcessor=hU;exports.Renderer=Sw;exports.RendererWrapper=Cw;
package/index.mjs CHANGED
@@ -48185,7 +48185,7 @@ const gU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48185
48185
  }, children: o, configFetcher: i, isPreview: s = !1, onSubmit: c = () => Promise.resolve(), formidavimHost: p, version: d, flowName: v = "", onNextStep: b, onPrevStep: S, onFlowInit: T, onConfigFetchError: w, shouldRedirect: R, onFormidavimFallback: A }) => {
48186
48186
  const M = hv(p), [k, j] = Zt({ config: null, data: null }), [G, W] = Zt(!0);
48187
48187
  if (Tn(() => {
48188
- (i ? i() : M.flowControllerGetBySlug(v, d).then(({ data: N }) => N)).then(async (N) => {
48188
+ W(!0), (i ? i() : M.flowControllerGetBySlug(v, d).then(({ data: N }) => N)).then(async (N) => {
48189
48189
  const z = e ? await e("flow") : null;
48190
48190
  j({ config: N, data: z }), W(!1);
48191
48191
  }).catch((N) => {
@@ -48219,7 +48219,7 @@ const gU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48219
48219
  }, NU = ({ dataFetcher: e = () => Promise.resolve(null), children: o, configFetcher: i, pipelineFetcher: s, isPreview: c = !1, onSubmit: p = () => Promise.resolve(), formidavimHost: d, version: v, flowName: b = "", onNextStep: S, onPrevStep: T, onFlowInit: w, onPipelineInit: R, onNoFlowsAvailable: A, onConfigFetchError: M, onFormidavimFallback: k }) => {
48220
48220
  const j = hv(d), [G, W] = Zt({ config: null, data: null }), [P, V] = Zt([]), [N, z] = Zt({}), [Z, ie] = Zt(!0), [ae, I] = Zt(!1);
48221
48221
  Tn(() => {
48222
- (s ? s() : j.pipelineControllerGetBySlug(b, v).then(({ data: pe }) => pe)).then(async (pe) => {
48222
+ ie(!0), (s ? s() : j.pipelineControllerGetBySlug(b, v).then(({ data: pe }) => pe)).then(async (pe) => {
48223
48223
  const le = e ? await e("pipeline") : null;
48224
48224
  if (W({ config: pe, data: le }), pe != null && pe.pipelineFlows && (await ve(pe.pipelineFlows, le.data)).length === 0) {
48225
48225
  A && A();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hievilmath/browser-formidavim",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
6
  "typings": "./index.d.ts",