@hievilmath/browser-formidavim 1.4.12 → 1.4.14

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
@@ -4,6 +4,16 @@ Quick notes about changes made to this package for each version.
4
4
 
5
5
  ---
6
6
 
7
+ ## Version 1.4.14
8
+ - Fix pipeline condition evaluator evalutating data at the correct level in patient profile AGAIN
9
+
10
+ ---
11
+
12
+ ## Version 1.4.13
13
+ - Fix pipeline condition evaluator evalutating data at the correct level in patient profile
14
+
15
+ ---
16
+
7
17
  ## Version 1.4.12
8
18
  - Add flow and form to flowSlice. Currently will use in admin preview.
9
19
  - Rework onpipelineinit and onflowinit
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);return Ve.useEffect(()=>{(i?i():M.flowControllerGetBySlug(v,f).then(({data:V})=>V)).then(async V=>{const D=e?await e("flow"):null;j({config:V,data:D}),W(!1)}).catch(V=>{console.warn("configFetcher failed",V),w&&w(V),W(!1)})},[v,f]),G?null:k.config?L.jsx(Cw,{children:L.jsx(Sw,{data:k.data,isPreview:s,config:k.config,onSubmit:c,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})}):(A&&A(),L.jsx(L.Fragment,{children:r}))},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([]),[D,H]=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)).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;const de=((pe=P==null?void 0:P[0])==null?void 0:pe.flow)||{};H(de)},[P]);const ve=async(de,pe)=>{var se;const le=[],he=ee=>{var Re;return(Re=pe==null?void 0:pe.data)==null?void 0:Re[ee]},Te=()=>pe,we=(ee,Re)=>{var Y;const B=(Y=pe==null?void 0:pe.data)==null?void 0:Y.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,D),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);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:D,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);return Ve.useEffect(()=>{(i?i():M.flowControllerGetBySlug(v,f).then(({data:V})=>V)).then(async V=>{const D=e?await e("flow"):null;j({config:V,data:D}),W(!1)}).catch(V=>{console.warn("configFetcher failed",V),w&&w(V),W(!1)})},[v,f]),G?null:k.config?L.jsx(Cw,{children:L.jsx(Sw,{data:k.data,isPreview:s,config:k.config,onSubmit:c,onNextStep:b,onPrevStep:S,onFlowInit:T,shouldRedirect:R,formidavimHost:p})}):(A&&A(),L.jsx(L.Fragment,{children:r}))},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([]),[D,H]=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)||{};H(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,D),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:D,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
@@ -48210,7 +48210,7 @@ const gU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48210
48210
  Tn(() => {
48211
48211
  (s ? s() : j.pipelineControllerGetBySlug(b, v).then(({ data: pe }) => pe)).then(async (pe) => {
48212
48212
  const le = e ? await e("pipeline") : null;
48213
- if (W({ config: pe, data: le }), pe != null && pe.pipelineFlows && (await ve(pe.pipelineFlows, le)).length === 0) {
48213
+ if (W({ config: pe, data: le }), pe != null && pe.pipelineFlows && (await ve(pe.pipelineFlows, le.data)).length === 0) {
48214
48214
  A && A();
48215
48215
  return;
48216
48216
  }
@@ -48220,17 +48220,14 @@ const gU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48220
48220
  });
48221
48221
  }, [b, v]), Tn(() => {
48222
48222
  var pe;
48223
+ console.log("visiblePipelineFlows", P);
48223
48224
  const fe = ((pe = P == null ? void 0 : P[0]) == null ? void 0 : pe.flow) || {};
48224
48225
  H(fe);
48225
48226
  }, [P]);
48226
48227
  const ve = async (fe, pe) => {
48227
48228
  var se;
48228
- const le = [], he = (ee) => {
48229
- var Te;
48230
- return (Te = pe == null ? void 0 : pe.data) == null ? void 0 : Te[ee];
48231
- }, Ee = () => pe, Ce = (ee, Te) => {
48232
- var Y;
48233
- const B = (Y = pe == null ? void 0 : pe.data) == null ? void 0 : Y.flow_submissions;
48229
+ const le = [], he = (ee) => pe == null ? void 0 : pe[ee], Ee = () => pe, Ce = (ee, Te) => {
48230
+ const B = pe == null ? void 0 : pe.flow_submissions;
48234
48231
  return !(!B || !B[ee]);
48235
48232
  };
48236
48233
  for (const ee of fe)
@@ -48267,7 +48264,7 @@ const gU = ({ formComponent: e, isPreview: o, boundary: i, isVisible: s = !0, fo
48267
48264
  try {
48268
48265
  const le = await p(fe, D), he = e ? await e("pipeline") : null;
48269
48266
  if (W((Ee) => ({ ...Ee, data: he })), (pe = G.config) != null && pe.pipelineFlows) {
48270
- const Ee = await ve(G.config.pipelineFlows, he);
48267
+ const Ee = await ve(G.config.pipelineFlows, he.data);
48271
48268
  if (Object.keys(Ee).length === 0 && le && typeof le == "function") {
48272
48269
  le();
48273
48270
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hievilmath/browser-formidavim",
3
- "version": "1.4.12",
3
+ "version": "1.4.14",
4
4
  "main": "./index.js",
5
5
  "module": "./index.mjs",
6
6
  "typings": "./index.d.ts",