@hievilmath/browser-formidavim 1.4.30 → 1.4.33

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 (4) hide show
  1. package/README.md +6 -0
  2. package/index.js +2 -2
  3. package/index.mjs +209 -207
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  Quick notes about changes made to this package for each version.
4
4
 
5
+ ## Version 1.4.32
6
+ - Change hidden input to use setFlowAndPatientValue instead of setFlowValue
7
+ - Modify Address component style
8
+
9
+ ---
10
+
5
11
  ## Version 1.4.30
6
12
  - Move hipaa error message
7
13
  - Fix input autocomplete
package/index.js CHANGED
@@ -2972,7 +2972,7 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
2972
2972
  background-color: ${e=>e.theme.colors.neutral20};
2973
2973
  min-width: 100%;
2974
2974
  min-height: 60px;
2975
- line-height: 75px;
2975
+ line-height: 75px !important;
2976
2976
  transition: all 0.2s;
2977
2977
 
2978
2978
  &:hover, &:focus {
@@ -2980,7 +2980,7 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
2980
2980
  transition: all 0.2s;
2981
2981
  }
2982
2982
  }
2983
- `,dj=({formComponent:e})=>{const r=e.props,{required:i,propertyId:s,label:c="Address",inlineCopy:p}=r||{},{getFlowValue:d,setFlowAndPatientValue:v,getFlowValue:b,getFlowError:S,setFlowError:T}=Nr(),w=b(s)||{},[R,A]=Ve.useState({address1:w.address1||"",address2:w.address2||"",city:w.city||"",state:w.state||"",postcode:w.postcode||"",coordinates:w.coordinates}),[L,P]=Ve.useState([]),[j,G]=Ve.useState(!1),[Y,k]=Ve.useState(!1),[V,N]=Ve.useState(!1),[z,Z]=Ve.useState("prompt"),ie=Ve.useRef(),ge="pk.eyJ1IjoiYW50aG9ueS1pdmltIiwiYSI6ImNsdXY4M245OTAwcmoya3BiY3RwOHU2aGoifQ.WKeVR5UV446JNt1PxJgccg",M=(ve,pe)=>{const ne={...R,[ve]:pe};A(ne),v(s,ne),ve==="address1"&&pe.length>1&&se(pe)},se=async ve=>{ie.current&&clearTimeout(ie.current),ie.current=setTimeout(async()=>{if(console.log(ve.length),ve.length<1)return;console.log("Searching for address:",ve),k(!0);const pe=()=>new Promise(ne=>{if(!navigator.geolocation){ne(null);return}navigator.geolocation.getCurrentPosition(ee=>{ne({lat:ee.coords.latitude,lng:ee.coords.longitude})},()=>ne(null),{timeout:5e3,enableHighAccuracy:!1})});try{const ne=await pe();let ee=`https://api.mapbox.com/search/geocode/v6/forward?q=${encodeURIComponent(ve)}&access_token=${ge}&country=US&types=address&limit=5&language=en`;ne&&(ee+=`&proximity=${ne.lng},${ne.lat}`,console.log("Using proximity bias:",ne));const Re=await fetch(ee);if(Re.ok){const B=await Re.json();console.log("Mapbox v6 response:",B),P(B.features||[]),G(!0)}else{console.error("Mapbox API error:",Re.status,Re.statusText);const B=await Re.text();console.error("Error details:",B)}}catch(ne){console.error("Error fetching address suggestions:",ne)}finally{k(!1)}},300)},Te=ve=>{var oe,K,Ee,te,De,Ce,Fe,rt,Lt;console.log("Selected feature:",ve);const pe=((oe=ve.properties)==null?void 0:oe.context)||{},ne=ve.properties||{};let ee="",Re="",B="",W="";const $e=((K=pe.address)==null?void 0:K.address_number)||"",Be=((Ee=pe.address)==null?void 0:Ee.street_name)||((te=pe.street)==null?void 0:te.name)||"";$e&&Be?ee=`${$e} ${Be}`.trim():ne.full_address?ee=ne.full_address.split(",")[0].trim():(De=pe.address)!=null&&De.name?ee=pe.address.name:ee=ve.text||"",Re=((Ce=pe.place)==null?void 0:Ce.name)||"";const Qe=((Fe=pe.region)==null?void 0:Fe.region_code)||"",We=((rt=pe.region)==null?void 0:rt.name)||"";if(B=Qe||(We?H$(We):""),W=((Lt=pe.postcode)==null?void 0:Lt.name)||"",!ee||!Re||!B||!W){const Dt=ve.place_name.split(", ");if(!ee&&Dt.length>=1&&(ee=Dt[0]),!Re&&Dt.length>=2&&(Re=Dt[1]),(!B||!W)&&Dt.length>=3){const yt=Dt[2].trim().split(/\s+/);if(!W&&yt.length>=2&&(W=yt[yt.length-1]),!B){const St=yt.slice(0,Math.max(1,yt.length-1)).join(" ");B=H$(St)}}}const X={address1:ee.trim(),address2:R.address2||"",city:Re.trim(),state:B.trim(),postcode:W.trim(),coordinates:{lat:ve.geometry.coordinates[1],lng:ve.geometry.coordinates[0]}};console.log("Parsed address:",X),A(X),v(s,X),G(!1),P([])},he=()=>!!(R.address1&&R.city&&R.state&&R.postcode);Ve.useEffect(()=>{const ve=pe=>{pe.target.closest(".address-autofill-container")||G(!1)};return document.addEventListener("click",ve),()=>document.removeEventListener("click",ve)},[]),Ve.useEffect(()=>{console.log("Suggestions state changed:",{showSuggestions:j,suggestionsCount:L.length,isAddress1Focused:V,isLoading:Y})},[j,L.length,V,Y]),Ve.useEffect(()=>{i&&!he()?T(s,"Required"):T(s,null)},[R.address1,R.city,R.state,R.postcode,i,s,T]),d(s);const we=S(s),ce=!!we&&we!=="Required",fe=he();return I.jsxs(ai,{$visible:!0,$type:"address",$hasError:ce,children:[I.jsx(dl,{$color:ce?"danger":void 0,children:c}),I.jsxs(oj,{children:[I.jsx(ai,{$visible:!0,children:I.jsxs(aj,{className:"address-autofill-container",children:[I.jsx("input",{type:"text",value:R.address1,onInput:ve=>M("address1",ve.target.value),onFocus:()=>{console.log("Address1 input focused"),N(!0)},onBlur:()=>{console.log("Address1 input blurred"),setTimeout(()=>{console.log("Hiding suggestions after blur timeout"),N(!1)},200)},id:`${s}-address1`,name:"address1",autoComplete:"address-line1"}),I.jsx(Mi,{htmlFor:`${s}-address1`,children:"Address Line 1"}),I.jsx(ij,{$show:V&&(j||Y),children:Y?I.jsx(sj,{children:"Loading suggestions..."}):L.length===0?I.jsx(uj,{children:"No suggestions found."}):L.map((ve,pe)=>{var ne;return I.jsx(lj,{onClick:ee=>{ee.stopPropagation(),Te(ve)},children:((ne=ve.properties)==null?void 0:ne.full_address)||ve.place_name||ve.text},pe)})})]})}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.address2,onInput:ve=>M("address2",ve.target.value),id:`${s}-address2`,name:"address2",autoComplete:"address-line2"}),I.jsx(Mi,{htmlFor:`${s}-address2`,children:"Address Line 2"})]}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.city,onInput:ve=>M("city",ve.target.value),id:`${s}-city`,name:"city",autoComplete:"address-level2"}),I.jsx(Mi,{htmlFor:`${s}-city`,children:"City"})]}),I.jsxs(qC,{$visible:!0,$hasError:ce,$height:"auto",$marginBottom:"0px",children:[I.jsxs(cj,{value:R.state,onChange:ve=>M("state",ve.target.value),id:`${s}-state`,name:"state",autoComplete:"address-level1",children:[I.jsx("option",{value:"",disabled:!0,children:"Select State"}),Object.entries(zA).map(([ve,pe],ne)=>I.jsx("option",{value:ve,children:pe},ve+ne))]}),I.jsx(Mi,{htmlFor:`${s}-state`,children:"State / Region"})]}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.postcode,onInput:ve=>M("postcode",ve.target.value),id:`${s}-postcode`,name:"postal-code",autoComplete:"postal-code",maxLength:10}),I.jsx(Mi,{htmlFor:`${s}-postcode`,children:"ZIP / Postcode"})]})]}),p&&I.jsx(dl,{children:p}),r!=null&&r.required&&!fe&&!ce?I.jsx(ao,{$bottom:"-30px",$visible:!0,children:"Required"}):ce?I.jsxs(Yo,{$bottom:"-30px",$visible:!0,children:[I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",children:I.jsx("path",{d:"M0.331707 7.50001C0.331707 11.1819 3.31647 14.1667 6.99837 14.1667C10.6803 14.1667 13.665 11.1819 13.665 7.50001C13.665 3.81811 10.6803 0.833344 6.99837 0.833344C3.31647 0.833344 0.331707 3.81811 0.331707 7.50001ZM3.8603 5.30475L4.80311 4.36194L10.1364 9.69527L9.19363 10.6381L3.8603 5.30475Z",fill:"#B94E36"})}),we]}):null]})},fj=({formComponent:e,formidavimHost:r})=>{const i=e.props,{propertyId:s,label:c="Hidden Field",jsonataExpression:p}=i||{},{getFlowValue:d,setFlowAndPatientValue:v,getFlowError:b,setFlowError:S,setDisableSubmitValue:T,setFlowValue:w}=Nr(),R=Sp(d(s)),[A,L]=Ve.useState("");Ve.useEffect(()=>{L(R)},[R]),Ve.useEffect(()=>{R||w(s,""),T(!1)},[s,w,T]),Ve.useEffect(()=>{console.log("Hidden component - jsonataExpression (evaluated value):",p),console.log("Hidden component - propertyId:",s),p!=null?(w(s,String(p)),S(s,null),T(!1),console.log("Hidden component - stored evaluated value:",p)):(console.log("Hidden component - no value, setting default"),w(s,""),S(s,null),T(!1))},[p,s,w,S,T]);const j=!!b(s);return I.jsxs(ai,{$visible:!1,$hasError:j,children:[I.jsx("input",{id:s,name:s,type:"text",value:A,readOnly:!0,className:j?"error":"",style:{position:"absolute",left:"-9999px",opacity:0,pointerEvents:"none",width:"1px",height:"1px",overflow:"hidden"},"aria-hidden":"true",tabIndex:-1}),I.jsx("label",{htmlFor:s,style:{display:"none"},children:c})]})},pj=({formComponent:e})=>{const r=e.props,{propertyId:i,label:s="Input Label",required:c,lastPrescribedDose:p,concentration:d}=r||{},{getFlowValue:v,setFlowAndPatientValue:b,getFlowError:S,setFlowError:T}=Nr(),w=Ve.useRef(null),R=Ve.useRef(!1),L=(N=>N?typeof N=="number"?N:parseFloat(String(N).replace(" mg",""))||0:0)(v(i)),P=parseFloat((d==null?void 0:d.split(" ")[0])||"0"),j=100;Ve.useEffect(()=>{!R.current&&p&&(!L&&p&&b(i,p+" mg"),R.current=!0)},[p]);const G=N=>P===0?0:Math.round(N/P*100),Y=N=>P===0?0:N/100*P,k=G(L),V=N=>{const z=Y(N);Number(N)===0?(b(i,0),T(i,"Units must be greater than 0")):(T(i,""),b(i,z+" mg"))};return I.jsxs(rM,{$visible:!0,children:[I.jsx(dl,{children:s}),I.jsxs(hM,{children:[I.jsx(mM,{children:I.jsx(vM,{$width:`${k}%`})}),I.jsx(Z$,{src:"http://media-s3-cdn.ivimhealth.com/assets/images/formidavim/dosing-variable-units-vial.webp"})]}),I.jsxs(yM,{children:[I.jsx(dO,{onClick:()=>V(Math.max(0,k-1)),children:I.jsx("svg",{width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M31.998 23H11.998V21H31.998V23Z",fill:"#32312D"})})}),I.jsxs(gM,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.focus()},children:[I.jsx(bM,{ref:w,type:"number",min:"0",max:j,value:k,onChange:N=>V(Math.max(0,Math.min(j,parseInt(N.target.value)||0)))}),I.jsx(xM,{children:"units"})]}),I.jsx(dO,{onClick:()=>V(Math.min(j,k+1)),children:I.jsx("svg",{width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",children:I.jsx("path",{d:"M22 15V29M15 22H29",stroke:"#32312D",strokeWidth:"2"})})})]}),I.jsx(ao,{$bottom:"-30px",$visible:!0,children:S(i)||(c?"Required":"")})]})},hj=({formComponent:e})=>{const r=e.props,{required:i,propertyId:s,label:c="File Upload",accepted:p="pdf,jpg,jpeg,png",maxSize:d=5,maxWidth:v=800,multiple:b=!1,inlineCopy:S}=r||{},T=typeof v=="string"?parseInt(v,10):v;console.log("maxWidthRaw:",v,"maxWidth:",T);const w=typeof p=="string"?p.split(",").map(ie=>ie.trim()):Array.isArray(p)?p:["pdf","jpg","jpeg","png"],{getFlowValue:R,setFlowAndPatientValue:A,getFlowError:L,setFlowError:P,setDisableSubmitValue:j}=Nr(),G=R(s),Y=L(s),k=!!Y&&Y!=="Required",[V,N]=Ve.useState(""),z=i==="true";Ve.useEffect(()=>{G?b&&Array.isArray(G)?N(`${G.length} file(s) selected`):!b&&G&&N("File selected"):N("")},[G,b]);const Z=ie=>{const{files:ge}=ie.target;if(!ge||ge.length===0){z?(P(s,"Required"),j(!0)):(P(s,null),j(!1)),A(s,b?[]:null),N("");return}N(b?`${ge.length} file(s) selected`:ge[0].name);const M=d*1024*1024;let se=[],Te=[],he=[],we=0;Array.from(ge).forEach((ce,fe)=>{const ve=new FileReader;ve.onload=pe=>{var W;let ne="";const ee=((W=pe.target)==null?void 0:W.result)||"",Re=!w.some($e=>ce.type.endsWith("/"+$e));if(ce.type.startsWith("image/")){const $e=new Image;$e.onload=()=>{const Be=document.createElement("canvas"),Qe=T/$e.width,We=T,X=$e.height*Qe;Be.width=We,Be.height=X;const oe=Be.getContext("2d");oe&&We>0&&X>0&&(oe.drawImage($e,0,0,We,X),ne=Be.toDataURL("image/jpeg",.8)),(!ne||ne==="data:,")&&(ne=ee),we++,B()},$e.onerror=()=>{ne=ee,we++,B()},$e.src=ee}else ce.type==="application/pdf"?(ne=ee,we++,B()):(Te.push(!0),we++,B());function B(){Re&&Te.push(!0),ce.size>M?se.push(!0):Re||(ne&&ne!=="data:,"?he.push(ne):ee&&ee!=="data:,"&&he.push(ee)),we===(ge==null?void 0:ge.length)&&(Te.includes(!0)?(P(s,`File types allowed are ${w.join(", ")}`),A(s,b?[]:null),j(!0)):se.includes(!0)?(P(s,`File(s) exceeds the maximum of ${d}MB.`),A(s,b?[]:null),j(!0)):(P(s,null),A(s,b?he:he[0]||null),j(!1)))}},ve.readAsDataURL(ce)})};return I.jsxs(oM,{$visible:"true",$hasError:k,$req:z?"true":"false",$isMultiple:b,children:[I.jsx("input",{type:"file",id:s,name:s,onChange:Z,accept:w.map(ie=>`.${ie}`).join(", "),multiple:b,style:{display:"none"}}),I.jsx("label",{style:{cursor:"pointer"},onClick:()=>{const ie=document.getElementById(s);ie&&ie.click()},children:"Browse"}),c&&c!==""&&I.jsx("span",{children:c}),V&&I.jsx("p",{className:"fileName",children:V}),z&&!G&&!k?I.jsx(ao,{$bottom:"-20px",$margin:"19% 0 0 15px",$visible:!0,children:"Required"}):k?I.jsxs(Yo,{$bottom:"-20px",$margin:"19% 0 0 15px",$visible:!0,children:[I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",children:I.jsx("path",{d:"M0.331707 7.50001C0.331707 11.1819 3.31647 14.1667 6.99837 14.1667C10.665 11.1819 13.665 7.50001C13.665 3.81811 10.6803 0.833344 6.99837 0.833344C3.31647 0.833344 0.331707 3.81811 0.331707 7.50001ZM3.8603 5.30475L4.80311 4.36194L10.1364 9.69527L9.19363 10.6381L3.8603 5.30475Z",fill:"#B94E36"})}),Y]}):null,S&&I.jsx("div",{style:{position:"absolute",bottom:k?"-32px":"-21px",left:"15px",fontSize:"12px",color:"#666"},children:S})]})},mj=({formComponent:e})=>{const r=e.props;return r!=null&&r.text?I.jsx(G6,{$margin:"0px",$color:r.color,$align:r["text-align"],dangerouslySetInnerHTML:{__html:r.text}}):null},vj=({formComponent:e})=>{const r=e.props;return r!=null&&r.src?I.jsx(Z$,{src:r.src}):I.jsx(Cp,{errors:["Image form component is missing valid image src"]})},yj=({formComponent:e})=>I.jsx(gj,{children:I.jsx(bj,{children:I.jsx(xj,{children:I.jsxs("svg",{width:"352",height:"243",viewBox:"0 0 352 243",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsxs("g",{"clip-path":"url(#clip0_356_13948)",children:[I.jsxs("g",{"clip-path":"url(#clip1_356_13948)",children:[I.jsx("path",{d:"M351 195C151.369 195 32.4675 102 0 22V230H351V195Z",fill:"url(#paint0_linear_356_13948)"}),I.jsx("path",{d:"M0 22C32.4675 102 151.369 195 351 195",stroke:"#86AF61","stroke-width":"2","stroke-linecap":"round"})]}),I.jsx("circle",{cx:"294.5",cy:"191.5",r:"22.5",fill:"#6F9351","fill-opacity":"0.16"}),I.jsx("circle",{cx:"294.5",cy:"191.5",r:"6.5",fill:"white",stroke:"#6F9351","stroke-width":"4"}),I.jsx("path",{d:"M0 22C32.56 75.1792 151.8 137 352 137",stroke:"#D9D8D8","stroke-width":"2","stroke-linecap":"round"})]}),I.jsxs("defs",{children:[I.jsxs("linearGradient",{id:"paint0_linear_356_13948",x1:"58.654",y1:"230",x2:"58.654",y2:"22",gradientUnits:"userSpaceOnUse",children:[I.jsx("stop",{"stop-color":"#86AF61","stop-opacity":"0"}),I.jsx("stop",{offset:"1","stop-color":"#86AF61"})]}),I.jsx("clipPath",{id:"clip0_356_13948",children:I.jsx("rect",{width:"352",height:"242",fill:"white",transform:"translate(0 0.5)"})}),I.jsx("clipPath",{id:"clip1_356_13948",children:I.jsx("rect",{width:"351",height:"220",fill:"white",transform:"translate(0 22)"})})]})]})})})}),gj=be.div`
2983
+ `,dj=({formComponent:e})=>{const r=e.props,{required:i,propertyId:s,label:c="Address",inlineCopy:p}=r||{},{getFlowValue:d,setFlowAndPatientValue:v,getFlowValue:b,getFlowError:S,setFlowError:T}=Nr(),w=b(s)||{},[R,A]=Ve.useState({address1:w.address1||"",address2:w.address2||"",city:w.city||"",state:w.state||"",postcode:w.postcode||"",coordinates:w.coordinates}),[L,P]=Ve.useState([]),[j,G]=Ve.useState(!1),[Y,k]=Ve.useState(!1),[V,N]=Ve.useState(!1),[z,Z]=Ve.useState("prompt"),ie=Ve.useRef(),ge="pk.eyJ1IjoiYW50aG9ueS1pdmltIiwiYSI6ImNsdXY4M245OTAwcmoya3BiY3RwOHU2aGoifQ.WKeVR5UV446JNt1PxJgccg",M=(ve,pe)=>{const ne={...R,[ve]:pe};A(ne),v(s,ne),ve==="address1"&&pe.length>1&&se(pe)},se=async ve=>{ie.current&&clearTimeout(ie.current),ie.current=setTimeout(async()=>{if(console.log(ve.length),ve.length<1)return;console.log("Searching for address:",ve),k(!0);const pe=()=>new Promise(ne=>{if(!navigator.geolocation){ne(null);return}navigator.geolocation.getCurrentPosition(ee=>{ne({lat:ee.coords.latitude,lng:ee.coords.longitude})},()=>ne(null),{timeout:5e3,enableHighAccuracy:!1})});try{const ne=await pe();let ee=`https://api.mapbox.com/search/geocode/v6/forward?q=${encodeURIComponent(ve)}&access_token=${ge}&country=US&types=address&limit=5&language=en`;ne&&(ee+=`&proximity=${ne.lng},${ne.lat}`,console.log("Using proximity bias:",ne));const Re=await fetch(ee);if(Re.ok){const B=await Re.json();console.log("Mapbox v6 response:",B),P(B.features||[]),G(!0)}else{console.error("Mapbox API error:",Re.status,Re.statusText);const B=await Re.text();console.error("Error details:",B)}}catch(ne){console.error("Error fetching address suggestions:",ne)}finally{k(!1)}},300)},Te=ve=>{var oe,K,Ee,te,De,Ce,Fe,rt,Lt;console.log("Selected feature:",ve);const pe=((oe=ve.properties)==null?void 0:oe.context)||{},ne=ve.properties||{};let ee="",Re="",B="",W="";const $e=((K=pe.address)==null?void 0:K.address_number)||"",Be=((Ee=pe.address)==null?void 0:Ee.street_name)||((te=pe.street)==null?void 0:te.name)||"";$e&&Be?ee=`${$e} ${Be}`.trim():ne.full_address?ee=ne.full_address.split(",")[0].trim():(De=pe.address)!=null&&De.name?ee=pe.address.name:ee=ve.text||"",Re=((Ce=pe.place)==null?void 0:Ce.name)||"";const Qe=((Fe=pe.region)==null?void 0:Fe.region_code)||"",We=((rt=pe.region)==null?void 0:rt.name)||"";if(B=Qe||(We?H$(We):""),W=((Lt=pe.postcode)==null?void 0:Lt.name)||"",!ee||!Re||!B||!W){const Dt=ve.place_name.split(", ");if(!ee&&Dt.length>=1&&(ee=Dt[0]),!Re&&Dt.length>=2&&(Re=Dt[1]),(!B||!W)&&Dt.length>=3){const yt=Dt[2].trim().split(/\s+/);if(!W&&yt.length>=2&&(W=yt[yt.length-1]),!B){const St=yt.slice(0,Math.max(1,yt.length-1)).join(" ");B=H$(St)}}}const X={address1:ee.trim(),address2:R.address2||"",city:Re.trim(),state:B.trim(),postcode:W.trim(),coordinates:{lat:ve.geometry.coordinates[1],lng:ve.geometry.coordinates[0]}};console.log("Parsed address:",X),A(X),v(s,X),G(!1),P([])},he=()=>!!(R.address1&&R.city&&R.state&&R.postcode);Ve.useEffect(()=>{const ve=pe=>{pe.target.closest(".address-autofill-container")||G(!1)};return document.addEventListener("click",ve),()=>document.removeEventListener("click",ve)},[]),Ve.useEffect(()=>{console.log("Suggestions state changed:",{showSuggestions:j,suggestionsCount:L.length,isAddress1Focused:V,isLoading:Y})},[j,L.length,V,Y]),Ve.useEffect(()=>{i&&!he()?T(s,"Required"):T(s,null)},[R.address1,R.city,R.state,R.postcode,i,s,T]),d(s);const we=S(s),ce=!!we&&we!=="Required",fe=he();return I.jsxs(ai,{$visible:!0,$type:"address",$hasError:ce,children:[I.jsx(dl,{$color:ce?"danger":void 0,children:c}),I.jsxs(oj,{children:[I.jsx(ai,{$visible:!0,children:I.jsxs(aj,{className:"address-autofill-container",children:[I.jsx("input",{type:"text",value:R.address1,onInput:ve=>M("address1",ve.target.value),onFocus:()=>{console.log("Address1 input focused"),N(!0)},onBlur:()=>{console.log("Address1 input blurred"),setTimeout(()=>{console.log("Hiding suggestions after blur timeout"),N(!1)},200)},id:`${s}-address1`,name:"address1",autoComplete:"address-line1"}),I.jsx(Mi,{htmlFor:`${s}-address1`,children:"Address Line 1"}),I.jsx(ij,{$show:V&&(j||Y),children:Y?I.jsx(sj,{children:"Loading suggestions..."}):L.length===0?I.jsx(uj,{children:"No suggestions found."}):L.map((ve,pe)=>{var ne;return I.jsx(lj,{onClick:ee=>{ee.stopPropagation(),Te(ve)},children:((ne=ve.properties)==null?void 0:ne.full_address)||ve.place_name||ve.text},pe)})})]})}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.address2,onInput:ve=>M("address2",ve.target.value),id:`${s}-address2`,name:"address2",autoComplete:"address-line2"}),I.jsx(Mi,{htmlFor:`${s}-address2`,children:"Address Line 2"})]}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.city,onInput:ve=>M("city",ve.target.value),id:`${s}-city`,name:"city",autoComplete:"address-level2"}),I.jsx(Mi,{htmlFor:`${s}-city`,children:"City"})]}),I.jsxs(qC,{$visible:!0,$hasError:ce,$height:"auto",$marginBottom:"0px",children:[I.jsxs(cj,{value:R.state,onChange:ve=>M("state",ve.target.value),id:`${s}-state`,name:"state",autoComplete:"address-level1",children:[I.jsx("option",{value:"",disabled:!0,children:"Select State"}),Object.entries(zA).map(([ve,pe],ne)=>I.jsx("option",{value:ve,children:pe},ve+ne))]}),I.jsx(Mi,{htmlFor:`${s}-state`,children:"State / Region"})]}),I.jsxs(ai,{$visible:!0,children:[I.jsx("input",{type:"text",value:R.postcode,onInput:ve=>M("postcode",ve.target.value),id:`${s}-postcode`,name:"postal-code",autoComplete:"postal-code",maxLength:10}),I.jsx(Mi,{htmlFor:`${s}-postcode`,children:"ZIP / Postcode"})]})]}),p&&I.jsx(dl,{children:p}),r!=null&&r.required&&!fe&&!ce?I.jsx(ao,{$bottom:"-30px",$visible:!0,children:"Required"}):ce?I.jsxs(Yo,{$bottom:"-30px",$visible:!0,children:[I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",children:I.jsx("path",{d:"M0.331707 7.50001C0.331707 11.1819 3.31647 14.1667 6.99837 14.1667C10.6803 14.1667 13.665 11.1819 13.665 7.50001C13.665 3.81811 10.6803 0.833344 6.99837 0.833344C3.31647 0.833344 0.331707 3.81811 0.331707 7.50001ZM3.8603 5.30475L4.80311 4.36194L10.1364 9.69527L9.19363 10.6381L3.8603 5.30475Z",fill:"#B94E36"})}),we]}):null]})},fj=({formComponent:e,formidavimHost:r})=>{const i=e.props,{propertyId:s,label:c="Hidden Field",jsonataExpression:p}=i||{},{getFlowValue:d,setFlowAndPatientValue:v,getFlowError:b,setFlowError:S,setDisableSubmitValue:T,setFlowValue:w}=Nr(),R=Sp(d(s)),[A,L]=Ve.useState("");Ve.useEffect(()=>{R?L(R):(v(s,""),L("")),T(!1)},[s,v,T]),Ve.useEffect(()=>{if(p!=null){const G=String(p);v(s,G),L(G),S(s,null),T(!1),console.log("Hidden component - stored evaluated value:",p)}else console.log("Hidden component - no value, setting default"),v(s,""),L(""),S(s,null),T(!1)},[p,s,v,S,T]);const j=!!b(s);return I.jsxs(ai,{$visible:!1,$hasError:j,children:[I.jsx("input",{id:s,name:s,type:"text",value:A,readOnly:!0,className:j?"error":"",style:{position:"absolute",left:"-9999px",opacity:0,pointerEvents:"none",width:"1px",height:"1px",overflow:"hidden"},"aria-hidden":"true",tabIndex:-1}),I.jsx("label",{htmlFor:s,style:{display:"none"},children:c})]})},pj=({formComponent:e})=>{const r=e.props,{propertyId:i,label:s="Input Label",required:c,lastPrescribedDose:p,concentration:d}=r||{},{getFlowValue:v,setFlowAndPatientValue:b,getFlowError:S,setFlowError:T}=Nr(),w=Ve.useRef(null),R=Ve.useRef(!1),L=(N=>N?typeof N=="number"?N:parseFloat(String(N).replace(" mg",""))||0:0)(v(i)),P=parseFloat((d==null?void 0:d.split(" ")[0])||"0"),j=100;Ve.useEffect(()=>{!R.current&&p&&(!L&&p&&b(i,p+" mg"),R.current=!0)},[p]);const G=N=>P===0?0:Math.round(N/P*100),Y=N=>P===0?0:N/100*P,k=G(L),V=N=>{const z=Y(N);Number(N)===0?(b(i,0),T(i,"Units must be greater than 0")):(T(i,""),b(i,z+" mg"))};return I.jsxs(rM,{$visible:!0,children:[I.jsx(dl,{children:s}),I.jsxs(hM,{children:[I.jsx(mM,{children:I.jsx(vM,{$width:`${k}%`})}),I.jsx(Z$,{src:"http://media-s3-cdn.ivimhealth.com/assets/images/formidavim/dosing-variable-units-vial.webp"})]}),I.jsxs(yM,{children:[I.jsx(dO,{onClick:()=>V(Math.max(0,k-1)),children:I.jsx("svg",{width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",children:I.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M31.998 23H11.998V21H31.998V23Z",fill:"#32312D"})})}),I.jsxs(gM,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.focus()},children:[I.jsx(bM,{ref:w,type:"number",min:"0",max:j,value:k,onChange:N=>V(Math.max(0,Math.min(j,parseInt(N.target.value)||0)))}),I.jsx(xM,{children:"units"})]}),I.jsx(dO,{onClick:()=>V(Math.min(j,k+1)),children:I.jsx("svg",{width:"44",height:"44",viewBox:"0 0 44 44",fill:"none",children:I.jsx("path",{d:"M22 15V29M15 22H29",stroke:"#32312D",strokeWidth:"2"})})})]}),I.jsx(ao,{$bottom:"-30px",$visible:!0,children:S(i)||(c?"Required":"")})]})},hj=({formComponent:e})=>{const r=e.props,{required:i,propertyId:s,label:c="File Upload",accepted:p="pdf,jpg,jpeg,png",maxSize:d=5,maxWidth:v=800,multiple:b=!1,inlineCopy:S}=r||{},T=typeof v=="string"?parseInt(v,10):v;console.log("maxWidthRaw:",v,"maxWidth:",T);const w=typeof p=="string"?p.split(",").map(ie=>ie.trim()):Array.isArray(p)?p:["pdf","jpg","jpeg","png"],{getFlowValue:R,setFlowAndPatientValue:A,getFlowError:L,setFlowError:P,setDisableSubmitValue:j}=Nr(),G=R(s),Y=L(s),k=!!Y&&Y!=="Required",[V,N]=Ve.useState(""),z=i==="true";Ve.useEffect(()=>{G?b&&Array.isArray(G)?N(`${G.length} file(s) selected`):!b&&G&&N("File selected"):N("")},[G,b]);const Z=ie=>{const{files:ge}=ie.target;if(!ge||ge.length===0){z?(P(s,"Required"),j(!0)):(P(s,null),j(!1)),A(s,b?[]:null),N("");return}N(b?`${ge.length} file(s) selected`:ge[0].name);const M=d*1024*1024;let se=[],Te=[],he=[],we=0;Array.from(ge).forEach((ce,fe)=>{const ve=new FileReader;ve.onload=pe=>{var W;let ne="";const ee=((W=pe.target)==null?void 0:W.result)||"",Re=!w.some($e=>ce.type.endsWith("/"+$e));if(ce.type.startsWith("image/")){const $e=new Image;$e.onload=()=>{const Be=document.createElement("canvas"),Qe=T/$e.width,We=T,X=$e.height*Qe;Be.width=We,Be.height=X;const oe=Be.getContext("2d");oe&&We>0&&X>0&&(oe.drawImage($e,0,0,We,X),ne=Be.toDataURL("image/jpeg",.8)),(!ne||ne==="data:,")&&(ne=ee),we++,B()},$e.onerror=()=>{ne=ee,we++,B()},$e.src=ee}else ce.type==="application/pdf"?(ne=ee,we++,B()):(Te.push(!0),we++,B());function B(){Re&&Te.push(!0),ce.size>M?se.push(!0):Re||(ne&&ne!=="data:,"?he.push(ne):ee&&ee!=="data:,"&&he.push(ee)),we===(ge==null?void 0:ge.length)&&(Te.includes(!0)?(P(s,`File types allowed are ${w.join(", ")}`),A(s,b?[]:null),j(!0)):se.includes(!0)?(P(s,`File(s) exceeds the maximum of ${d}MB.`),A(s,b?[]:null),j(!0)):(P(s,null),A(s,b?he:he[0]||null),j(!1)))}},ve.readAsDataURL(ce)})};return I.jsxs(oM,{$visible:"true",$hasError:k,$req:z?"true":"false",$isMultiple:b,children:[I.jsx("input",{type:"file",id:s,name:s,onChange:Z,accept:w.map(ie=>`.${ie}`).join(", "),multiple:b,style:{display:"none"}}),I.jsx("label",{style:{cursor:"pointer"},onClick:()=>{const ie=document.getElementById(s);ie&&ie.click()},children:"Browse"}),c&&c!==""&&I.jsx("span",{children:c}),V&&I.jsx("p",{className:"fileName",children:V}),z&&!G&&!k?I.jsx(ao,{$bottom:"-20px",$margin:"19% 0 0 15px",$visible:!0,children:"Required"}):k?I.jsxs(Yo,{$bottom:"-20px",$margin:"19% 0 0 15px",$visible:!0,children:[I.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",children:I.jsx("path",{d:"M0.331707 7.50001C0.331707 11.1819 3.31647 14.1667 6.99837 14.1667C10.665 11.1819 13.665 7.50001C13.665 3.81811 10.6803 0.833344 6.99837 0.833344C3.31647 0.833344 0.331707 3.81811 0.331707 7.50001ZM3.8603 5.30475L4.80311 4.36194L10.1364 9.69527L9.19363 10.6381L3.8603 5.30475Z",fill:"#B94E36"})}),Y]}):null,S&&I.jsx("div",{style:{position:"absolute",bottom:k?"-32px":"-21px",left:"15px",fontSize:"12px",color:"#666"},children:S})]})},mj=({formComponent:e})=>{const r=e.props;return r!=null&&r.text?I.jsx(G6,{$margin:"0px",$color:r.color,$align:r["text-align"],dangerouslySetInnerHTML:{__html:r.text}}):null},vj=({formComponent:e})=>{const r=e.props;return r!=null&&r.src?I.jsx(Z$,{src:r.src}):I.jsx(Cp,{errors:["Image form component is missing valid image src"]})},yj=({formComponent:e})=>I.jsx(gj,{children:I.jsx(bj,{children:I.jsx(xj,{children:I.jsxs("svg",{width:"352",height:"243",viewBox:"0 0 352 243",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsxs("g",{"clip-path":"url(#clip0_356_13948)",children:[I.jsxs("g",{"clip-path":"url(#clip1_356_13948)",children:[I.jsx("path",{d:"M351 195C151.369 195 32.4675 102 0 22V230H351V195Z",fill:"url(#paint0_linear_356_13948)"}),I.jsx("path",{d:"M0 22C32.4675 102 151.369 195 351 195",stroke:"#86AF61","stroke-width":"2","stroke-linecap":"round"})]}),I.jsx("circle",{cx:"294.5",cy:"191.5",r:"22.5",fill:"#6F9351","fill-opacity":"0.16"}),I.jsx("circle",{cx:"294.5",cy:"191.5",r:"6.5",fill:"white",stroke:"#6F9351","stroke-width":"4"}),I.jsx("path",{d:"M0 22C32.56 75.1792 151.8 137 352 137",stroke:"#D9D8D8","stroke-width":"2","stroke-linecap":"round"})]}),I.jsxs("defs",{children:[I.jsxs("linearGradient",{id:"paint0_linear_356_13948",x1:"58.654",y1:"230",x2:"58.654",y2:"22",gradientUnits:"userSpaceOnUse",children:[I.jsx("stop",{"stop-color":"#86AF61","stop-opacity":"0"}),I.jsx("stop",{offset:"1","stop-color":"#86AF61"})]}),I.jsx("clipPath",{id:"clip0_356_13948",children:I.jsx("rect",{width:"352",height:"242",fill:"white",transform:"translate(0 0.5)"})}),I.jsx("clipPath",{id:"clip1_356_13948",children:I.jsx("rect",{width:"351",height:"220",fill:"white",transform:"translate(0 22)"})})]})]})})})}),gj=be.div`
2984
2984
  && {
2985
2985
  display: flex;
2986
2986
  flex-direction: column;