@dropins/storefront-auth 3.1.0 → 3.2.0-alpha002

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/chunks/Button.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as A,jsxs as q}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as g,useState as B,useCallback as S,useEffect as k}from"@dropins/tools/preact-hooks.js";import{initReCaptcha as j}from"@dropins/tools/recaptcha.js";import{useText as v}from"@dropins/tools/i18n.js";import{memo as m}from"@dropins/tools/preact-compat.js";import{Field as y,Input as z,Picker as w,InputDate as K,Checkbox as V,TextArea as Y}from"@dropins/tools/components.js";import{classes as Q,Slot as J}from"@dropins/tools/lib.js";var f=(r=>(r.REQUIRED_FIELD_ERROR="requiredFieldError",r.NUMERIC_ERROR="numericError",r.ALPHA_NUM_WITH_SPACES_ERROR="alphaNumWithSpacesError",r.ALPHA_NUMERIC_ERROR="alphaNumericError",r.ALPHA_ERROR="alphaError",r.EMAIL_ERROR="emailError",r.DATE_ERROR="dateError",r.DATE_RANGE_ERROR="dateRangeError",r.DATE_MAX_ERROR="dateMaxError",r.DATE_MIN_ERROR="dateMinError",r.URL_ERROR="urlError",r.LENGTH_TEXT_ERROR="lengthTextError",r))(f||{});const M="/",rr=r=>{const e=v(r),t=Object.entries(e).filter(([u,l])=>l===null&&Object.values(f).includes(u)).map(([u])=>u),a=t.reduce((u,l)=>(u[l]=`Auth.FormText.${l}`,u),{}),o=v(a);return{...e,...t.reduce((u,l)=>(u[l]=o[l],u),{})}},er=r=>r.reduce((e,t)=>({...e,[t.name]:t.value}),{}),tr=r=>/^\d+$/.test(r),ar=r=>/^[a-zA-Z0-9\s]+$/.test(r),nr=r=>/^[a-zA-Z0-9]+$/.test(r),or=r=>/^[a-zA-Z]+$/.test(r),ur=r=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(r),lr=r=>/^\d{4}-\d{2}-\d{2}$/.test(r)&&!isNaN(Date.parse(r)),sr=(r,e,t)=>{const a=new Date(r).getTime()/1e3;return!(isNaN(a)||a<0||typeof e<"u"&&a<e||typeof t<"u"&&a>t)},L=r=>{if(!r||r.trim()==="")return"";const e=parseInt(r,10);if(!isNaN(e)){const o=new Date(e*1e3);return isNaN(o.getTime())?"":o.toISOString().split("T")[0]}const t=new Date(r);if(isNaN(t.getTime()))return"";const a=parseInt(r.split("-")[1],10);return a>12||a<1?"":t.toISOString().split("T")[0]},cr=r=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(r),dr=(r,e,t)=>{const a=r.length;return a>=e&&a<=t},P=(r,e,t,a)=>{var G,H;const{requiredFieldError:o,lengthTextError:u,numericError:l,alphaNumWithSpacesError:s,alphaNumericError:p,alphaError:_,emailError:O,dateError:I,urlError:D,dateRangeError:b,dateMaxError:d,dateMinError:c}=t,n=e==null?void 0:e.customUpperCode,E={[n]:""};if(a[n]&&delete a[n],e!=null&&e.required&&(!r||r==="false"))return{[n]:`${f.REQUIRED_FIELD_ERROR}${M}${o}`};if(!(e!=null&&e.required)&&!r||!((G=e==null?void 0:e.validateRules)!=null&&G.length))return E;const T=er(e==null?void 0:e.validateRules),i=T.MIN_TEXT_LENGTH??1,$=T.MAX_TEXT_LENGTH??255,R=T.DATE_RANGE_MIN,h=T.DATE_RANGE_MAX;if(!dr(r,+i,+$)&&!(R||h)){const N=u.replace("{min}",i).replace("{max}",$);return{[n]:`${f.LENGTH_TEXT_ERROR}${M}${N}`}}if(!sr(r,+R,+h)&&(R||h)){if(R&&R){const N=b.replace("{min}",L(R)).replace("{max}",L(h));return{[n]:`${f.DATE_RANGE_ERROR}${M}${N}`}}if(typeof R>"u"&&typeof h<"u"){const N=d.replace("{max}",L(h));return{[n]:`${f.DATE_MAX_ERROR}${M}${N}`}}if(typeof h>"u"&&typeof R<"u"){const N=c.replace("{min}",L(R));return{[n]:`${f.DATE_MIN_ERROR}${M}${N}`}}}const C={numeric:{validate:tr,error:`${f.NUMERIC_ERROR}${M}${l}`},"alphanum-with-spaces":{validate:ar,error:`${f.ALPHA_NUM_WITH_SPACES_ERROR}${M}${s}`},alphanumeric:{validate:nr,error:`${f.ALPHA_NUMERIC_ERROR}${M}${p}`},alpha:{validate:or,error:`${f.ALPHA_ERROR}${M}${_}`},email:{validate:ur,error:`${f.EMAIL_ERROR}${M}${O}`},date:{validate:lr,error:`${f.DATE_ERROR}${M}${I}`},url:{validate:cr,error:`${f.URL_ERROR}${M}${D}`}}[T.INPUT_VALIDATION];return C&&!C.validate(r)&&!((H=a[n])!=null&&H.length)?{[n]:C.error}:E},Er=r=>r.reduce((e,{customUpperCode:t,required:a,defaultValue:o})=>(a&&t&&(e.initialData[t]=o||"",e.errorList[t]=""),e),{initialData:{},errorList:{}}),Rr=["auth-reset-password-form__buttons--signin","auth-sign-up-form-buttons--signin","auth-sign-in-form__button--forgot","auth-sign-in-form__button--signup"],hr=({fieldsConfig:r,onSubmit:e})=>{const t=rr({requiredFieldError:"Auth.FormText.requiredFieldError.default",lengthTextError:"Auth.FormText.lengthTextError.default",numericError:"Auth.FormText.numericError.default",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError.default",alphaNumericError:"Auth.FormText.alphaNumericError.default",alphaError:"Auth.FormText.alphaError.default",emailError:"Auth.FormText.emailError.default",dateError:"Auth.FormText.dateError.default",dateRangeError:"Auth.FormText.dateRangeError.default",dateMaxError:"Auth.FormText.dateMaxError.default",dateMinError:"Auth.FormText.dateMinError.default",urlError:"Auth.FormText.urlError.default"}),a=g(null),o=g(!1),[u,l]=B({}),[s,p]=B({}),_=S(()=>{let d=!0;const c={...s};let n=null;for(const[E,T]of Object.entries(u)){const i=r==null?void 0:r.find(R=>{var h;return(h=R==null?void 0:R.customUpperCode)==null?void 0:h.includes(E)}),$=P(T.toString(),i,t,c);$[E]&&(Object.assign(c,$),d=!1),n||(n=Object.keys(c).find(R=>c[R])??null)}if(p(c),n&&a.current){const E=a.current.elements.namedItem(n);E==null||E.focus()}return d},[s,r,u,t]);k(()=>{if(r!=null&&r.length){const{initialData:d,errorList:c}=Er(r);l(n=>({...d,...n})),p(c)}},[JSON.stringify(r)]);const O=S(async d=>{const c=d.target,n=!Rr.some(E=>c.classList.contains(E));!o.current&&n&&(await j(0),o.current=!0)},[]),I=S(d=>{const{name:c,value:n,type:E,checked:T}=d==null?void 0:d.target,i=E==="checkbox"?T:n;l(h=>({...h,[c]:i}));const $=r==null?void 0:r.find(h=>{var F;return(F=h==null?void 0:h.customUpperCode)==null?void 0:F.includes(c)});let R={...s};if($){const h=P(i.toString(),$,t,R);h&&Object.assign(R,h),p(R)}},[r,s,t]),D=S(d=>{const{name:c,value:n,type:E,checked:T}=d==null?void 0:d.target,i=E==="checkbox"?T:n,$=r==null?void 0:r.find(R=>R.customUpperCode===c);if($){const R={...s},h=P(i.toString(),$,t,R);h&&Object.assign(R,h),p(R)}},[s,r,t]),b=S(d=>{d.preventDefault();const c=_();e==null||e(d,c)},[_,e]);return{formData:u,errors:s,formRef:a,handleChange:I,handleBlur:D,handleSubmit:b,handleFocus:O}};var x=(r=>(r.BOOLEAN="BOOLEAN",r.DATE="DATE",r.DATETIME="DATETIME",r.DROPDOWN="DROPDOWN",r.FILE="FILE",r.GALLERY="GALLERY",r.HIDDEN="HIDDEN",r.IMAGE="IMAGE",r.MEDIA_IMAGE="MEDIA_IMAGE",r.MULTILINE="MULTILINE",r.MULTISELECT="MULTISELECT",r.PRICE="PRICE",r.SELECT="SELECT",r.TEXT="TEXT",r.TEXTAREA="TEXTAREA",r.UNDEFINED="UNDEFINED",r.VISUAL="VISUAL",r.WEIGHT="WEIGHT",r.EMPTY="",r))(x||{});const Z=r=>{const e={errorKey:"",defaultErrorMessage:""};if(!r)return e;const t=r.indexOf(M);return t===-1?e:{errorKey:r.substring(0,t).trim(),defaultErrorMessage:r.substring(t+M.length).trim()}},U=m(({item:r,errorConfig:e,className:t,itemClassName:a,loading:o,children:u})=>{const{errorKey:l,defaultErrorMessage:s}=Z(e),p=v(`Auth.FormText.${l}.${r.code}`)[r.code];let _="";return s.length&&(_=p||s),A(y,{error:_,className:Q([a,`${a}--${r.id}`,[`${a}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${t}--${r.id}`,disabled:o||r.disabled,children:u},r.id)}),X=m(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:o,onFocus:u,className:l,itemClassName:s,loading:p})=>A(U,{item:r,errorConfig:t,className:l,itemClassName:s,loading:p,children:A(z,{type:"text",name:r.customUpperCode,value:e??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,autocomplete:r.autocomplete,onBlur:a,onChange:o,onFocus:u})})),W=m(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:o,className:u,itemClassName:l,loading:s})=>{var _;const p=(_=r.options.find(O=>O.isDefault))==null?void 0:_.value;return A(U,{item:r,errorConfig:t,className:u,itemClassName:l,loading:s,children:A(w,{name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,"aria-label":r.label,options:r.options,onBlur:a,handleSelect:o,defaultValue:p??e??r.defaultValue,value:p??e??r.defaultValue})})}),pr=m(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:o,className:u,itemClassName:l,loading:s})=>A(U,{item:r,errorConfig:t,className:u,itemClassName:l,loading:s,children:A(K,{type:"text",name:r.customUpperCode,value:e||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:o,disabled:s||r.disabled})})),Ar=m(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:o,className:u,itemClassName:l,loading:s})=>A(U,{item:r,errorConfig:t,className:u,itemClassName:l,loading:s,children:A(V,{name:r.customUpperCode,checked:e||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:o})})),Tr=m(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:o,className:u,itemClassName:l,loading:s})=>A(U,{item:r,errorConfig:t,className:u,itemClassName:l,loading:s,children:A(Y,{name:r.customUpperCode,value:e??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:o})})),$r=({slots:r,item:e,handleOnChange:t,handleOnBlur:a,handleOnFocus:o,errorConfig:u,errors:l})=>{const{errorKey:s,defaultErrorMessage:p}=Z(u),_=v(`Auth.FormText.${s}.${e.code}`)[e.code];let O="";p.length&&(O=_||p);const I={inputName:e.customUpperCode,handleOnChange:t,handleOnBlur:a,handleOnFocus:o,errorMessage:O,errors:l,config:e};return A(J,{"data-testid":`signUpFormInput_${e.code}`,name:`SignUpFormInput_${e.code}`,slot:r==null?void 0:r[`SignUpFormInput_${e.code}`],context:I},e.id)},Nr=m(({slots:r,name:e,loading:t,children:a,className:o="defaultForm",fieldsConfig:u=[],onSubmit:l,...s})=>{const{formData:p,errors:_,formRef:O,handleChange:I,handleBlur:D,handleSubmit:b,handleFocus:d}=hr({onSubmit:l,fieldsConfig:u}),c=`${o}__field`;return q("form",{className:o,onSubmit:b,name:e,ref:O,onFocus:d,...s,children:[u.map(n=>{const E=_==null?void 0:_[n.customUpperCode],T=p==null?void 0:p[n.customUpperCode],i=!!(r!=null&&r[`SignUpFormInput_${n.code}`]),$=A($r,{slots:r,item:n,handleOnChange:I,handleOnBlur:D,handleOnFocus:d,errorConfig:E,errors:_});switch(n.fieldType){case x.TEXT:return i?$:n.options.length?A(W,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,onFocus:d,itemClassName:c,className:o,loading:t}):A(X,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,onFocus:d,itemClassName:c,className:o,loading:t});case x.MULTILINE:return i?$:A(X,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,onFocus:d,itemClassName:c,className:o,loading:t});case x.SELECT:return i?$:A(W,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,itemClassName:c,className:o,loading:t});case x.DATE:return i?$:A(pr,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,itemClassName:c,className:o,loading:t});case x.BOOLEAN:return i?$:A(Ar,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,itemClassName:c,className:o,loading:t});case x.TEXTAREA:return i?$:A(Tr,{item:n,valueMessage:T,errorConfig:E,onBlur:D,onChange:I,itemClassName:c,className:o,loading:t});default:return null}}),a]})});export{Nr as F,rr as u,ur as v};
3
+ import{jsx as h,jsxs as j,Fragment as q}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as H,useState as B,useCallback as S,useEffect as k}from"@dropins/tools/preact-hooks.js";import{initReCaptcha as z}from"@dropins/tools/recaptcha.js";import{useText as v}from"@dropins/tools/i18n.js";import{classes as w,Slot as W}from"@dropins/tools/lib.js";import{memo as F}from"@dropins/tools/preact-compat.js";import{Field as K,Input as V,Picker as J,InputDate as Y,Checkbox as Q,TextArea as rr}from"@dropins/tools/components.js";var I=(r=>(r.REQUIRED_FIELD_ERROR="requiredFieldError",r.NUMERIC_ERROR="numericError",r.ALPHA_NUM_WITH_SPACES_ERROR="alphaNumWithSpacesError",r.ALPHA_NUMERIC_ERROR="alphaNumericError",r.ALPHA_ERROR="alphaError",r.EMAIL_ERROR="emailError",r.DATE_ERROR="dateError",r.DATE_RANGE_ERROR="dateRangeError",r.DATE_MAX_ERROR="dateMaxError",r.DATE_MIN_ERROR="dateMinError",r.URL_ERROR="urlError",r.LENGTH_TEXT_ERROR="lengthTextError",r))(I||{});const f="/",er=r=>{const e=v(r),t=Object.entries(e).filter(([o,d])=>d===null&&Object.values(I).includes(o)).map(([o])=>o),a=t.reduce((o,d)=>(o[d]=`Auth.FormText.${d}`,o),{}),n=v(a);return{...e,...t.reduce((o,d)=>(o[d]=n[d],o),{})}},tr=r=>r.reduce((e,t)=>({...e,[t.name]:t.value}),{}),ar=r=>/^\d+$/.test(r),nr=r=>/^[a-zA-Z0-9\s]+$/.test(r),or=r=>/^[a-zA-Z0-9]+$/.test(r),ur=r=>/^[a-zA-Z]+$/.test(r),lr=r=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(r),sr=r=>/^\d{4}-\d{2}-\d{2}$/.test(r)&&!isNaN(Date.parse(r)),cr=(r,e,t)=>{const a=new Date(r).getTime()/1e3;return!(isNaN(a)||a<0||typeof e<"u"&&a<e||typeof t<"u"&&a>t)},L=r=>{if(!r||r.trim()==="")return"";const e=parseInt(r,10);if(!isNaN(e)){const n=new Date(e*1e3);return isNaN(n.getTime())?"":n.toISOString().split("T")[0]}const t=new Date(r);if(isNaN(t.getTime()))return"";const a=parseInt(r.split("-")[1],10);return a>12||a<1?"":t.toISOString().split("T")[0]},dr=r=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(r),Er=(r,e,t)=>{const a=r.length;return a>=e&&a<=t},P=(r,e,t,a)=>{var g,G;const{requiredFieldError:n,lengthTextError:o,numericError:d,alphaNumWithSpacesError:s,alphaNumericError:T,alphaError:i,emailError:$,dateError:x,urlError:O,dateRangeError:D,dateMaxError:p,dateMinError:R}=t,l=e==null?void 0:e.customUpperCode,_={[l]:""};if(a[l]&&delete a[l],e!=null&&e.required&&(!r||r==="false"))return{[l]:`${I.REQUIRED_FIELD_ERROR}${f}${n}`};if(!(e!=null&&e.required)&&!r||!((g=e==null?void 0:e.validateRules)!=null&&g.length))return _;const M=tr(e==null?void 0:e.validateRules),E=M.MIN_TEXT_LENGTH??1,A=M.MAX_TEXT_LENGTH??255,u=M.DATE_RANGE_MIN,c=M.DATE_RANGE_MAX;if(!Er(r,+E,+A)&&!(u||c)){const m=o.replace("{min}",E).replace("{max}",A);return{[l]:`${I.LENGTH_TEXT_ERROR}${f}${m}`}}if(!cr(r,+u,+c)&&(u||c)){if(u&&u){const m=D.replace("{min}",L(u)).replace("{max}",L(c));return{[l]:`${I.DATE_RANGE_ERROR}${f}${m}`}}if(typeof u>"u"&&typeof c<"u"){const m=p.replace("{max}",L(c));return{[l]:`${I.DATE_MAX_ERROR}${f}${m}`}}if(typeof c>"u"&&typeof u<"u"){const m=R.replace("{min}",L(u));return{[l]:`${I.DATE_MIN_ERROR}${f}${m}`}}}const C={numeric:{validate:ar,error:`${I.NUMERIC_ERROR}${f}${d}`},"alphanum-with-spaces":{validate:nr,error:`${I.ALPHA_NUM_WITH_SPACES_ERROR}${f}${s}`},alphanumeric:{validate:or,error:`${I.ALPHA_NUMERIC_ERROR}${f}${T}`},alpha:{validate:ur,error:`${I.ALPHA_ERROR}${f}${i}`},email:{validate:lr,error:`${I.EMAIL_ERROR}${f}${$}`},date:{validate:sr,error:`${I.DATE_ERROR}${f}${x}`},url:{validate:dr,error:`${I.URL_ERROR}${f}${O}`}}[M.INPUT_VALIDATION];return C&&!C.validate(r)&&!((G=a[l])!=null&&G.length)?{[l]:C.error}:_},Rr=r=>r.reduce((e,{customUpperCode:t,required:a,defaultValue:n})=>(a&&t&&(e.initialData[t]=n||"",e.errorList[t]=""),e),{initialData:{},errorList:{}}),hr=["auth-reset-password-form__buttons--signin","auth-sign-up-form-buttons--signin","auth-sign-in-form__button--forgot","auth-sign-in-form__button--signup"],pr=({fieldsConfig:r,onSubmit:e})=>{const t=er({requiredFieldError:"Auth.FormText.requiredFieldError.default",lengthTextError:"Auth.FormText.lengthTextError.default",numericError:"Auth.FormText.numericError.default",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError.default",alphaNumericError:"Auth.FormText.alphaNumericError.default",alphaError:"Auth.FormText.alphaError.default",emailError:"Auth.FormText.emailError.default",dateError:"Auth.FormText.dateError.default",dateRangeError:"Auth.FormText.dateRangeError.default",dateMaxError:"Auth.FormText.dateMaxError.default",dateMinError:"Auth.FormText.dateMinError.default",urlError:"Auth.FormText.urlError.default"}),a=H(null),n=H(!1),[o,d]=B({}),[s,T]=B({}),i=S(()=>{let p=!0;const R={...s};let l=null;for(const[_,M]of Object.entries(o)){const E=r==null?void 0:r.find(u=>{var c;return(c=u==null?void 0:u.customUpperCode)==null?void 0:c.includes(_)}),A=P(M.toString(),E,t,R);A[_]&&(Object.assign(R,A),p=!1),l||(l=Object.keys(R).find(u=>R[u])??null)}if(T(R),l&&a.current){const _=a.current.elements.namedItem(l);_==null||_.focus()}return p},[s,r,o,t]);k(()=>{if(r!=null&&r.length){const{initialData:p,errorList:R}=Rr(r);d(l=>({...p,...l})),T(R)}},[JSON.stringify(r)]);const $=S(async p=>{const R=p.target,l=!hr.some(_=>R.classList.contains(_));!n.current&&l&&(await z(0),n.current=!0)},[]),x=S(p=>{const{name:R,value:l,type:_,checked:M}=p==null?void 0:p.target,E=_==="checkbox"?M:l;d(c=>({...c,[R]:E}));const A=r==null?void 0:r.find(c=>{var N;return(N=c==null?void 0:c.customUpperCode)==null?void 0:N.includes(R)});let u={...s};if(A){const c=P(E.toString(),A,t,u);c&&Object.assign(u,c),T(u)}},[r,s,t]),O=S(p=>{const{name:R,value:l,type:_,checked:M}=p==null?void 0:p.target,E=_==="checkbox"?M:l,A=r==null?void 0:r.find(u=>u.customUpperCode===R);if(A){const u={...s},c=P(E.toString(),A,t,u);c&&Object.assign(u,c),T(u)}},[s,r,t]),D=S(p=>{p.preventDefault();const R=i();e==null||e(p,R)},[i,e]);return{formData:o,errors:s,formRef:a,handleChange:x,handleBlur:O,handleSubmit:D,handleFocus:$}};var b=(r=>(r.BOOLEAN="BOOLEAN",r.DATE="DATE",r.DATETIME="DATETIME",r.DROPDOWN="DROPDOWN",r.FILE="FILE",r.GALLERY="GALLERY",r.HIDDEN="HIDDEN",r.IMAGE="IMAGE",r.MEDIA_IMAGE="MEDIA_IMAGE",r.MULTILINE="MULTILINE",r.MULTISELECT="MULTISELECT",r.PRICE="PRICE",r.SELECT="SELECT",r.TEXT="TEXT",r.TEXTAREA="TEXTAREA",r.UNDEFINED="UNDEFINED",r.VISUAL="VISUAL",r.WEIGHT="WEIGHT",r.EMPTY="",r))(b||{});const Z=r=>{const e={errorKey:"",defaultErrorMessage:""};if(!r)return e;const t=r.indexOf(f);return t===-1?e:{errorKey:r.substring(0,t).trim(),defaultErrorMessage:r.substring(t+f.length).trim()}},U=F(({item:r,errorConfig:e,className:t,itemClassName:a,loading:n,children:o})=>{const{errorKey:d,defaultErrorMessage:s}=Z(e),T=v(`Auth.FormText.${d}.${r.code}`)[r.code];let i="";return s.length&&(i=T||s),h(K,{error:i,className:w([a,`${a}--${r.id}`,[`${a}--${r.id}-hidden`,r.isHidden],r.className]),"data-testid":`${t}--${r.id}`,disabled:n||r.disabled,children:o},r.id)}),X=F(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:n,onFocus:o,className:d,itemClassName:s,loading:T})=>h(U,{item:r,errorConfig:t,className:d,itemClassName:s,loading:T,children:h(V,{type:"text",name:r.customUpperCode,value:e??r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,autocomplete:r.autocomplete,onBlur:a,onChange:n,onFocus:o})})),y=F(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:n,className:o,itemClassName:d,loading:s})=>{var i;const T=(i=r.options.find($=>$.isDefault))==null?void 0:i.value;return h(U,{item:r,errorConfig:t,className:o,itemClassName:d,loading:s,children:h(J,{name:r.customUpperCode,floatingLabel:`${r.label} ${r.required?"*":""}`,placeholder:r.label,"aria-label":r.label,options:r.options,onBlur:a,handleSelect:n,defaultValue:T??e??r.defaultValue,value:T??e??r.defaultValue})})}),Ar=F(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:n,className:o,itemClassName:d,loading:s})=>h(U,{item:r,errorConfig:t,className:o,itemClassName:d,loading:s,children:h(Y,{type:"text",name:r.customUpperCode,value:e||r.defaultValue,placeholder:r.label,floatingLabel:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:n,disabled:s||r.disabled})})),Tr=F(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:n,className:o,itemClassName:d,loading:s})=>h(U,{item:r,errorConfig:t,className:o,itemClassName:d,loading:s,children:h(Q,{name:r.customUpperCode,checked:e||r.defaultValue,placeholder:r.label,label:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:n})})),_r=F(({item:r,valueMessage:e,errorConfig:t,onBlur:a,onChange:n,className:o,itemClassName:d,loading:s})=>h(U,{item:r,errorConfig:t,className:o,itemClassName:d,loading:s,children:h(rr,{name:r.customUpperCode,value:e??r.defaultValue,label:`${r.label} ${r.required?"*":""}`,onBlur:a,onChange:n})})),ir=({slots:r,item:e,handleOnChange:t,handleOnBlur:a,handleOnFocus:n,errorConfig:o,errors:d})=>{const{errorKey:s,defaultErrorMessage:T}=Z(o),i=v(`Auth.FormText.${s}.${e.code}`)[e.code];let $="";T.length&&($=i||T);const x={inputName:e.customUpperCode,handleOnChange:t,handleOnBlur:a,handleOnFocus:n,errorMessage:$,errors:d,config:e};return h(W,{"data-testid":`signUpFormInput_${e.code}`,name:`SignUpFormInput_${e.code}`,slot:r==null?void 0:r[`SignUpFormInput_${e.code}`],context:x},e.id)},xr=F(({slots:r,name:e,loading:t,children:a,className:n="defaultForm",fieldsConfig:o=[],onSubmit:d,formSlot:s,...T})=>{const{formData:i,errors:$,formRef:x,handleChange:O,handleBlur:D,handleSubmit:p,handleFocus:R}=pr({onSubmit:d,fieldsConfig:o}),l=`${n}__field`,_=j(q,{children:[o.map(E=>{const A=$==null?void 0:$[E.customUpperCode],u=i==null?void 0:i[E.customUpperCode],c=!!(r!=null&&r[`SignUpFormInput_${E.code}`]),N=h(ir,{slots:r,item:E,handleOnChange:O,handleOnBlur:D,handleOnFocus:R,errorConfig:A,errors:$});switch(E.fieldType){case b.TEXT:return c?N:E.options.length?h(y,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,onFocus:R,itemClassName:l,className:n,loading:t}):h(X,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,onFocus:R,itemClassName:l,className:n,loading:t});case b.MULTILINE:return c?N:h(X,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,onFocus:R,itemClassName:l,className:n,loading:t});case b.SELECT:return c?N:h(y,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,itemClassName:l,className:n,loading:t});case b.DATE:return c?N:h(Ar,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,itemClassName:l,className:n,loading:t});case b.BOOLEAN:return c?N:h(Tr,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,itemClassName:l,className:n,loading:t});case b.TEXTAREA:return c?N:h(_r,{item:E,valueMessage:u,errorConfig:A,onBlur:D,onChange:O,itemClassName:l,className:n,loading:t});default:return null}}),a]}),M={...s.context||{},__formContentKey:[o.map(E=>E.id||E.code).join(","),JSON.stringify($),JSON.stringify(i)].join("|")};return h("form",{onSubmit:p,name:e,ref:x,onFocus:R,...T,children:h(W,{name:s.name,slot:s.slot,context:M,className:n,"data-testid":s.dataTestId,children:_})})});export{xr as F,er as u,lr as v};
4
4
  //# sourceMappingURL=Button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","sources":["/@dropins/storefront-auth/src/types/validationErrors.types.ts","/@dropins/storefront-auth/src/hooks/useCustomTranslations.tsx","/@dropins/storefront-auth/src/lib/validationFields.ts","/@dropins/storefront-auth/src/lib/initializeFormDataAndErrors.ts","/@dropins/storefront-auth/src/configs/excludedFocusClasses.ts","/@dropins/storefront-auth/src/hooks/components/useForm.tsx","/@dropins/storefront-auth/src/data/models/attributes-form.ts","/@dropins/storefront-auth/src/lib/extractErrorKeyAndMessage.tsx","/@dropins/storefront-auth/src/components/Form/Elements/FieldElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/SelectElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputDateElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputCheckBoxElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/TextAreaElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/FormSlot.tsx","/@dropins/storefront-auth/src/components/Form/Form.tsx"],"sourcesContent":["/**\n * Error types in this enum are used to provide custom i18n translations for specific validation errors.\n * Each key corresponds to an error type that maps to the `Auth.FormText` i18n values in `src/i18n/en_US.json`.\n */\nexport enum ValidationErrorTypes {\n REQUIRED_FIELD_ERROR = 'requiredFieldError',\n NUMERIC_ERROR = 'numericError',\n ALPHA_NUM_WITH_SPACES_ERROR = 'alphaNumWithSpacesError',\n ALPHA_NUMERIC_ERROR = 'alphaNumericError',\n ALPHA_ERROR = 'alphaError',\n EMAIL_ERROR = 'emailError',\n DATE_ERROR = 'dateError',\n DATE_RANGE_ERROR = 'dateRangeError',\n DATE_MAX_ERROR = 'dateMaxError',\n DATE_MIN_ERROR = 'dateMinError',\n URL_ERROR = 'urlError',\n LENGTH_TEXT_ERROR = 'lengthTextError',\n}\n\n/**\n * `ERROR_CONFIG_SEPARATOR` uses the ASCII 31 (Unit Separator) character,\n * a rarely used control character, to avoid conflicts with custom i18n error messages.\n *\n * Learn more: https://theasciicode.com.ar/ascii-control-characters/unit-separator-ascii-code-31.html\n */\nexport const ERROR_CONFIG_SEPARATOR = `${String.fromCharCode(\n 31\n)}/${String.fromCharCode(31)}`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from 'preact-i18n';\nimport { ValidationErrorTypes } from '@/auth/types';\n\n/**\n * A custom hook for handling translations with support for extensible error messages.\n *\n * @param defaultKeys - A mapping of keys to their translation paths.\n * @returns A complete set of translations, including dynamically updated values for null error keys.\n */\nexport const useCustomTranslations = (\n defaultKeys: Record<string, string>\n): Record<string, string> => {\n /**\n * Step 1: Fetch initial translations using the provided keys\n * Translations are fetched from the i18n system based on the provided defaultKeys.\n */\n const translations = useText(defaultKeys);\n\n /**\n * Step 2: Identify keys that require updates\n * - These keys correspond to validation errors (defined in ValidationErrorTypes).\n * - A key needs an update if:\n * 1. Its value in the initial translations is `null`.\n * 2. The key exists in ValidationErrorTypes (indicating it’s a known error type).\n *\n * Null values typically occur when translations for the given error key are not overridden\n * and instead rely on a plain structure, e.g., \"requiredFieldError\": \"This is a required field.\"\n */\n const keysToUpdate = Object.entries(translations)\n .filter(\n ([key, value]) =>\n value === null &&\n (Object.values(ValidationErrorTypes) as string[]).includes(key)\n )\n .map(([key]) => key);\n\n /**\n * Step 3: Prepare paths for fetching updated translations\n * - For each key needing an update, create a path to its extended translation.\n * - Example: For the key \"requiredFieldError\", the updated path would be \"Auth.FormText.requiredFieldError\".\n */\n const translationKeys = keysToUpdate.reduce((acc, key) => {\n acc[key] = `Auth.FormText.${key}`; // Build the updated translation path\n return acc;\n }, {} as Record<string, string>);\n\n // Step 4: Fetch updated translations for the keys identified in Step 2\n const updatedTranslations = useText(translationKeys);\n\n /**\n * Step 5: Merge updated translations back into the initial translations\n * - Replace `null` values with the fetched updated translations.\n * - Preserve all other original translations.\n */\n return {\n ...translations, // Include original translations\n ...keysToUpdate.reduce<Record<string, string>>((acc, key) => {\n acc[key] = updatedTranslations[key]; // Overwrite `null` values with updated translations\n return acc;\n }, {}),\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ValidationErrorTypes, ERROR_CONFIG_SEPARATOR } from '@/auth/types';\n\n/* eslint-disable no-useless-escape */\ntype ValidationConfig = Record<string, string>;\ntype TranslationList = Record<string, string>;\ntype ErrorsList = Record<string, string>;\nexport type ValidationFieldsConfig = {\n validateRules: Record<string, string>[];\n code?: string;\n customUpperCode: string;\n required: boolean;\n};\n\nenum ConfigEnumLength {\n MIN_TEXT_LENGTH = 'MIN_TEXT_LENGTH',\n MAX_TEXT_LENGTH = 'MAX_TEXT_LENGTH',\n DATE_RANGE_MIN = 'DATE_RANGE_MIN',\n DATE_RANGE_MAX = 'DATE_RANGE_MAX',\n}\n\nexport enum InputValidation {\n Numeric = 'numeric',\n AlphanumWithSpaces = 'alphanum-with-spaces',\n Alphanumeric = 'alphanumeric',\n Alpha = 'alpha',\n Email = 'email',\n Length = 'length',\n Date = 'date',\n Url = 'url',\n}\n\nconst flattenObjectsArray = (arr: ValidationConfig[]): ValidationConfig => {\n return arr.reduce((acc, obj) => {\n return { ...acc, [obj.name]: obj.value };\n }, {});\n};\n\n//The basic material for the functions responsible for validation was taken from https://github.com/magento/magento2/blob/2.4/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js\nexport const validateNumeric = (value: string): boolean => /^\\d+$/.test(value);\n\nexport const validateAlphanumWithSpaces = (value: string): boolean =>\n /^[a-zA-Z0-9\\s]+$/.test(value);\n\nexport const validateAlphanumeric = (value: string): boolean =>\n /^[a-zA-Z0-9]+$/.test(value);\n\nexport const validateAlpha = (value: string): boolean =>\n /^[a-zA-Z]+$/.test(value);\n\nexport const validateEmail = (value: string): boolean =>\n /^[a-z0-9,!\\#\\$%&'\\*\\+\\/=\\?\\^_`\\{\\|\\}~-]+(\\.[a-z0-9,!\\#\\$%&'\\*\\+\\/=\\?\\^_`\\{\\|\\}~-]+)*@([a-z0-9-]+\\.)+[a-z]{2,}$/i.test(\n value\n );\n\nexport const validateDate = (value: string): boolean =>\n /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && !isNaN(Date.parse(value));\n\nexport const isDateWithinRange = (\n date: string,\n minTimestamp?: number,\n maxTimestamp?: number\n): boolean => {\n const dateTimestamp = new Date(date).getTime() / 1000;\n\n if (isNaN(dateTimestamp) || dateTimestamp < 0) {\n return false;\n }\n\n if (typeof minTimestamp !== 'undefined' && dateTimestamp < minTimestamp) {\n return false;\n }\n\n if (typeof maxTimestamp !== 'undefined' && dateTimestamp > maxTimestamp) {\n return false;\n }\n\n return true;\n};\n\nexport const convertTimestampToDate = (\n timestamp: string | undefined | null\n): string => {\n if (!timestamp || timestamp.trim() === '') return '';\n\n const parsedTimestamp = parseInt(timestamp, 10);\n\n if (!isNaN(parsedTimestamp)) {\n const date = new Date(parsedTimestamp * 1000);\n\n if (isNaN(date.getTime())) return '';\n\n return date.toISOString().split('T')[0];\n }\n\n const isoDate = new Date(timestamp);\n\n if (isNaN(isoDate.getTime())) return '';\n\n const month = parseInt(timestamp.split('-')[1], 10);\n\n if (month > 12 || month < 1) return '';\n\n return isoDate.toISOString().split('T')[0];\n};\n\nexport const validateUrl = (url: string) => {\n const urlPattern =\n /^(https?|ftp):\\/\\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\\d+))?(\\/[A-Z0-9~](([A-Z0-9_~-]|\\.)*[A-Z0-9~]|))*\\/?(.*)?$/i;\n return urlPattern.test(url);\n};\n\nexport const validateLength = (\n value: string,\n minLength: number,\n maxLength: number\n): boolean => {\n const length = value.length;\n return length >= minLength && length <= maxLength;\n};\n\nexport const validationFields = (\n value: string,\n configs: ValidationFieldsConfig,\n translations: TranslationList,\n errorsList: ErrorsList\n) => {\n const {\n requiredFieldError,\n lengthTextError,\n numericError,\n alphaNumWithSpacesError,\n alphaNumericError,\n alphaError,\n emailError,\n dateError,\n urlError,\n dateRangeError,\n dateMaxError,\n dateMinError,\n } = translations;\n\n const fieldName = configs?.customUpperCode as string;\n\n const defaultFields = { [fieldName]: '' };\n\n if (errorsList[fieldName]) {\n delete errorsList[fieldName];\n }\n\n if (configs?.required && (!value || value === 'false')) {\n return {\n [fieldName]: `${ValidationErrorTypes.REQUIRED_FIELD_ERROR}${ERROR_CONFIG_SEPARATOR}${requiredFieldError}`,\n };\n }\n\n if (!configs?.required && !value) {\n return defaultFields;\n }\n\n if (!configs?.validateRules?.length) return defaultFields;\n\n const validateRulesConfig = flattenObjectsArray(configs?.validateRules);\n\n const min = validateRulesConfig[ConfigEnumLength.MIN_TEXT_LENGTH] ?? 1;\n const max = validateRulesConfig[ConfigEnumLength.MAX_TEXT_LENGTH] ?? 255;\n const dateMin = validateRulesConfig[ConfigEnumLength.DATE_RANGE_MIN];\n const dateMax = validateRulesConfig[ConfigEnumLength.DATE_RANGE_MAX];\n\n if (!validateLength(value, +min, +max) && !(dateMin || dateMax)) {\n const parsedErrorMessage = lengthTextError\n .replace('{min}', min)\n .replace('{max}', max);\n\n return {\n [fieldName]: `${ValidationErrorTypes.LENGTH_TEXT_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (!isDateWithinRange(value, +dateMin, +dateMax) && (dateMin || dateMax)) {\n if (dateMin && dateMin) {\n const parsedErrorMessage = dateRangeError\n .replace('{min}', convertTimestampToDate(dateMin))\n .replace('{max}', convertTimestampToDate(dateMax));\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_RANGE_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (typeof dateMin === 'undefined' && typeof dateMax !== 'undefined') {\n const parsedErrorMessage = dateMaxError.replace(\n '{max}',\n convertTimestampToDate(dateMax)\n );\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_MAX_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (typeof dateMax === 'undefined' && typeof dateMin !== 'undefined') {\n const parsedErrorMessage = dateMinError.replace(\n '{min}',\n convertTimestampToDate(dateMin)\n );\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_MIN_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n }\n\n const validationMap = {\n [InputValidation.Numeric]: {\n validate: validateNumeric,\n error: `${ValidationErrorTypes.NUMERIC_ERROR}${ERROR_CONFIG_SEPARATOR}${numericError}`,\n },\n [InputValidation.AlphanumWithSpaces]: {\n validate: validateAlphanumWithSpaces,\n error: `${ValidationErrorTypes.ALPHA_NUM_WITH_SPACES_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaNumWithSpacesError}`,\n },\n [InputValidation.Alphanumeric]: {\n validate: validateAlphanumeric,\n error: `${ValidationErrorTypes.ALPHA_NUMERIC_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaNumericError}`,\n },\n [InputValidation.Alpha]: {\n validate: validateAlpha,\n error: `${ValidationErrorTypes.ALPHA_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaError}`,\n },\n [InputValidation.Email]: {\n validate: validateEmail,\n error: `${ValidationErrorTypes.EMAIL_ERROR}${ERROR_CONFIG_SEPARATOR}${emailError}`,\n },\n [InputValidation.Date]: {\n validate: validateDate,\n error: `${ValidationErrorTypes.DATE_ERROR}${ERROR_CONFIG_SEPARATOR}${dateError}`,\n },\n [InputValidation.Url]: {\n validate: validateUrl,\n error: `${ValidationErrorTypes.URL_ERROR}${ERROR_CONFIG_SEPARATOR}${urlError}`,\n },\n };\n\n const validation =\n validationMap[\n validateRulesConfig['INPUT_VALIDATION'] as keyof typeof validationMap\n ];\n\n if (\n validation &&\n !validation.validate(value) &&\n !errorsList[fieldName]?.length\n ) {\n return { [fieldName]: validation.error };\n }\n\n return defaultFields;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport default (\n fieldsConfig: Array<{\n customUpperCode?: string;\n required?: boolean;\n defaultValue?: unknown;\n }>\n): {\n initialData: Record<string, unknown>;\n errorList: Record<string, string>;\n} => {\n return fieldsConfig.reduce(\n (\n acc: {\n initialData: Record<string, unknown>;\n errorList: Record<string, string>;\n },\n { customUpperCode, required, defaultValue }\n ) => {\n if (required && customUpperCode) {\n acc.initialData[customUpperCode] = defaultValue || '';\n acc.errorList[customUpperCode] = '';\n }\n\n return acc;\n },\n {\n initialData: {},\n errorList: {},\n }\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/**\n * This file defines an array of class names that should be excluded\n * from specific init Recaptcha logic.\n *\n * The array contains class names representing elements that should be\n * ignored when certain operations, such as focusing or applying event\n * handlers, are executed.\n *\n * By checking if an element's class matches any class in this array,\n * you can easily bypass unwanted logic for those elements, ensuring\n * precise and predictable behavior in your application.\n *\n */\n\nexport const excludedFocusClasses = [\n 'auth-reset-password-form__buttons--signin',\n 'auth-sign-up-form-buttons--signin',\n 'auth-sign-in-form__button--forgot',\n 'auth-sign-in-form__button--signup',\n];\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, useRef, useState, useEffect } from 'preact/hooks';\nimport { FieldsProps, useFormProps } from '@/auth/types';\nimport { initReCaptcha } from '@adobe-commerce/recaptcha';\nimport initializeFormDataAndErrors from '@/auth/lib/initializeFormDataAndErrors';\nimport {\n validationFields,\n ValidationFieldsConfig,\n} from '@/auth/lib/validationFields';\nimport { excludedFocusClasses } from '@/auth/configs/excludedFocusClasses';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const useForm = ({ fieldsConfig, onSubmit }: useFormProps) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n lengthTextError: 'Auth.FormText.lengthTextError.default',\n numericError: 'Auth.FormText.numericError.default',\n alphaNumWithSpacesError: 'Account.FormText.alphaNumWithSpacesError.default',\n alphaNumericError: 'Auth.FormText.alphaNumericError.default',\n alphaError: 'Auth.FormText.alphaError.default',\n emailError: 'Auth.FormText.emailError.default',\n dateError: 'Auth.FormText.dateError.default',\n dateRangeError: 'Auth.FormText.dateRangeError.default',\n dateMaxError: 'Auth.FormText.dateMaxError.default',\n dateMinError: 'Auth.FormText.dateMinError.default',\n urlError: 'Auth.FormText.urlError.default',\n });\n\n const formRef = useRef<HTMLFormElement>(null);\n const focusExecutedRef = useRef<boolean>(false);\n const [formData, setFormData] = useState<\n Record<string, string | boolean | number>\n >({});\n const [errors, setErrors] = useState<Record<string, string>>({});\n\n const handleValidationSubmit = useCallback(() => {\n let formValid = true;\n const errorsList = { ...errors };\n let firstErrorField: string | null = null;\n\n for (const [name, value] of Object.entries(formData)) {\n const fieldConfig = fieldsConfig?.find((config: FieldsProps) =>\n config?.customUpperCode?.includes(name)\n );\n\n const validationResult = validationFields(\n value.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult[name]) {\n Object.assign(errorsList, validationResult);\n formValid = false;\n }\n\n if (!firstErrorField) {\n firstErrorField =\n Object.keys(errorsList).find((key) => errorsList[key]) ?? null;\n }\n }\n\n setErrors(errorsList);\n\n if (firstErrorField && formRef.current) {\n const input = formRef.current.elements.namedItem(\n firstErrorField\n ) as HTMLElement;\n input?.focus();\n }\n\n return formValid;\n }, [errors, fieldsConfig, formData, translations]);\n\n useEffect(() => {\n if (fieldsConfig?.length) {\n const { initialData, errorList } =\n initializeFormDataAndErrors(fieldsConfig);\n\n setFormData((prev) => ({\n ...(initialData as Record<string, string | number>),\n ...prev,\n }));\n\n setErrors(errorList);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(fieldsConfig)]);\n\n const handleFocus = useCallback(async (event: FocusEvent) => {\n const target = event.target as HTMLInputElement;\n const isFocusable = !excludedFocusClasses.some((className) =>\n target.classList.contains(className)\n );\n\n if (!focusExecutedRef.current && isFocusable) {\n await initReCaptcha(0);\n focusExecutedRef.current = true;\n }\n }, []);\n\n const handleChange = useCallback(\n (event: Event) => {\n const { name, value, type, checked } = event?.target as HTMLInputElement;\n const fieldValue = type === 'checkbox' ? checked : value;\n\n setFormData((prev) => {\n const updatedFormData = {\n ...prev,\n [name]: fieldValue,\n };\n\n return updatedFormData as Record<string, string | number>;\n });\n\n const fieldConfig = fieldsConfig?.find((config: FieldsProps) =>\n config?.customUpperCode?.includes(name)\n );\n\n let errorsList = { ...errors };\n\n if (fieldConfig) {\n const validationResult = validationFields(\n fieldValue.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult) {\n Object.assign(errorsList, validationResult);\n }\n\n setErrors(errorsList);\n }\n },\n [fieldsConfig, errors, translations]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const { name, value, type, checked } = event?.target as HTMLInputElement;\n const fieldValue = type === 'checkbox' ? checked : value;\n\n const fieldConfig = fieldsConfig?.find(\n (config: FieldsProps) => config.customUpperCode === name\n );\n\n if (fieldConfig) {\n const errorsList = { ...errors };\n\n const validationResult = validationFields(\n fieldValue.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult) {\n Object.assign(errorsList, validationResult);\n }\n\n setErrors(errorsList);\n }\n },\n [errors, fieldsConfig, translations]\n );\n\n const handleSubmit = useCallback(\n (event: SubmitEvent) => {\n event.preventDefault();\n\n const formValid = handleValidationSubmit();\n\n onSubmit?.(event, formValid);\n },\n [handleValidationSubmit, onSubmit]\n );\n\n return {\n formData,\n errors,\n formRef,\n handleChange,\n handleBlur,\n handleSubmit,\n handleFocus,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport enum FieldEnumList {\n BOOLEAN = 'BOOLEAN',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n DROPDOWN = 'DROPDOWN',\n FILE = 'FILE',\n GALLERY = 'GALLERY',\n HIDDEN = 'HIDDEN',\n IMAGE = 'IMAGE',\n MEDIA_IMAGE = 'MEDIA_IMAGE',\n MULTILINE = 'MULTILINE',\n MULTISELECT = 'MULTISELECT',\n PRICE = 'PRICE',\n SELECT = 'SELECT',\n TEXT = 'TEXT',\n TEXTAREA = 'TEXTAREA',\n UNDEFINED = 'UNDEFINED',\n VISUAL = 'VISUAL',\n WEIGHT = 'WEIGHT',\n EMPTY = '',\n}\n\nexport interface AttributesFormItemsProps {\n code?: string;\n name?: string;\n id?: string;\n defaultValue?: string | boolean | number;\n entityType?: string;\n className?: string;\n fieldType?: FieldEnumList;\n multilineCount: number;\n required?: boolean;\n unique?: boolean;\n label?: string;\n orderNumber: number;\n options?: { is_default: boolean; label: string; value: string }[];\n hidden?: boolean;\n customUpperCode: string;\n}\n\nexport interface AttributesFormModel extends AttributesFormItemsProps {}\n","import { ERROR_CONFIG_SEPARATOR } from '@/auth/types';\n\ntype ExtractErrorKeyAndMessage = {\n errorKey: string;\n defaultErrorMessage: string;\n};\n\nexport const extractErrorKeyAndMessage = (\n errorConfig: string\n): ExtractErrorKeyAndMessage => {\n const fallbackData = { errorKey: '', defaultErrorMessage: '' };\n\n if (!errorConfig) return fallbackData;\n\n const index = errorConfig.indexOf(ERROR_CONFIG_SEPARATOR);\n\n if (index === -1) return fallbackData;\n\n return {\n errorKey: errorConfig.substring(0, index).trim(),\n defaultErrorMessage: errorConfig\n .substring(index + ERROR_CONFIG_SEPARATOR.length)\n .trim(),\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FieldElementProps } from '@/auth/types';\nimport { Field } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { memo } from 'preact/compat';\nimport { extractErrorKeyAndMessage } from '@/auth/lib/extractErrorKeyAndMessage';\nimport { VNode } from 'preact';\n\nexport const FieldElement = memo(\n ({\n item,\n errorConfig,\n className,\n itemClassName,\n loading,\n children,\n }: FieldElementProps) => {\n const { errorKey, defaultErrorMessage } =\n extractErrorKeyAndMessage(errorConfig);\n const customErrorMessage = useText(\n `Auth.FormText.${errorKey}.${item.code}`\n )[item.code];\n\n let errorMessage = '';\n\n // This check indicates that validation identified an error\n if (defaultErrorMessage.length) {\n errorMessage = customErrorMessage || defaultErrorMessage;\n }\n\n return (\n <Field\n key={item.id}\n error={errorMessage}\n className={classes([\n itemClassName,\n `${itemClassName}--${item.id}`,\n [`${itemClassName}--${item.id}-hidden`, item.isHidden],\n item.className,\n ])}\n data-testid={`${className}--${item.id}`}\n disabled={loading || item.disabled}\n >\n {children as VNode<{}>}\n </Field>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Input } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n onFocus,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Input\n type=\"text\"\n name={item.customUpperCode}\n value={valueMessage ?? item.defaultValue}\n placeholder={item.label}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n autocomplete={item.autocomplete}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Picker } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const SelectElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n const defaultSelectValue = item.options.find(\n (option: { isDefault: boolean; value: string; text: string }) =>\n option.isDefault\n )?.value;\n\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Picker\n name={item.customUpperCode}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n placeholder={item.label}\n aria-label={item.label}\n options={item.options}\n onBlur={onBlur}\n handleSelect={onChange}\n defaultValue={defaultSelectValue ?? valueMessage ?? item.defaultValue}\n value={defaultSelectValue ?? valueMessage ?? item.defaultValue}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { InputDate } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputDateElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <InputDate\n // @ts-ignore\n type=\"text\"\n name={item.customUpperCode}\n value={valueMessage || item.defaultValue}\n placeholder={item.label}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n disabled={loading || item.disabled}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Checkbox } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputCheckBoxElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Checkbox\n name={item.customUpperCode}\n checked={valueMessage || item.defaultValue}\n placeholder={item.label}\n label={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { TextArea } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const TextAreaElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <TextArea\n name={item.customUpperCode}\n value={valueMessage ?? item.defaultValue}\n label={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { extractErrorKeyAndMessage } from '@/auth/lib/extractErrorKeyAndMessage';\nimport { FormSlotProps } from '@/auth/types';\nimport { useText } from 'preact-i18n';\nimport { Slot } from '@adobe-commerce/elsie/lib';\n\nexport const FormSlot = ({\n slots,\n item,\n handleOnChange,\n handleOnBlur,\n handleOnFocus,\n errorConfig,\n errors,\n}: FormSlotProps) => {\n const { errorKey, defaultErrorMessage } =\n extractErrorKeyAndMessage(errorConfig);\n const customErrorMessage = useText(`Auth.FormText.${errorKey}.${item.code}`)[\n item.code\n ];\n\n let errorMessage = '';\n\n // This check indicates that validation identified an error\n if (defaultErrorMessage.length) {\n errorMessage = customErrorMessage || defaultErrorMessage;\n }\n\n const contextValue = {\n inputName: item.customUpperCode,\n handleOnChange,\n handleOnBlur,\n handleOnFocus,\n errorMessage,\n errors,\n config: item,\n };\n\n return (\n <Slot\n data-testid={`signUpFormInput_${item.code}`}\n name={`SignUpFormInput_${item.code}`}\n slot={slots?.[`SignUpFormInput_${item.code}`]}\n context={contextValue}\n key={item.id}\n />\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FieldsProps, FormProps } from '@/auth/types';\nimport { useForm } from '@/auth/hooks/components/useForm';\nimport { FieldEnumList } from '@/auth/data/models';\nimport {\n SelectElement,\n InputElement,\n InputDateElement,\n InputCheckBoxElement,\n TextAreaElement,\n FormSlot,\n} from './Elements';\nimport { memo } from 'preact/compat';\n\nexport const Form = memo(\n ({\n slots,\n name,\n loading,\n children,\n className = 'defaultForm',\n fieldsConfig = [],\n onSubmit,\n ...props\n }: FormProps) => {\n const {\n formData,\n errors,\n formRef,\n handleChange,\n handleBlur,\n handleSubmit,\n handleFocus,\n } = useForm({\n onSubmit,\n fieldsConfig,\n });\n\n const itemClassName = `${className}__field`;\n\n return (\n <form\n className={className}\n onSubmit={handleSubmit}\n name={name}\n ref={formRef}\n onFocus={handleFocus}\n {...props}\n >\n {fieldsConfig.map((item: FieldsProps) => {\n const errorConfig = errors?.[item.customUpperCode];\n const valueMessage = formData?.[item.customUpperCode] as string;\n const isSlot = !!slots?.[`SignUpFormInput_${item.code}`];\n\n const renderSlot = (\n <FormSlot\n slots={slots}\n item={item}\n handleOnChange={handleChange}\n handleOnBlur={handleBlur}\n handleOnFocus={handleFocus}\n errorConfig={errorConfig}\n errors={errors}\n />\n );\n\n switch (item.fieldType) {\n case FieldEnumList.TEXT: {\n if (isSlot) return renderSlot;\n\n if (item.options.length) {\n return (\n <SelectElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n return (\n <InputElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.MULTILINE: {\n if (isSlot) return renderSlot;\n\n return (\n <InputElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.SELECT: {\n if (isSlot) return renderSlot;\n\n return (\n <SelectElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.DATE: {\n if (isSlot) return renderSlot;\n\n return (\n <InputDateElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.BOOLEAN: {\n if (isSlot) return renderSlot;\n\n return (\n <InputCheckBoxElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.TEXTAREA: {\n if (isSlot) return renderSlot;\n\n return (\n <TextAreaElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n default:\n return null;\n }\n })}\n\n {children}\n </form>\n );\n }\n);\n"],"names":["ValidationErrorTypes","ERROR_CONFIG_SEPARATOR","useCustomTranslations","defaultKeys","translations","useText","keysToUpdate","key","value","translationKeys","acc","updatedTranslations","flattenObjectsArray","arr","obj","validateNumeric","validateAlphanumWithSpaces","validateAlphanumeric","validateAlpha","validateEmail","validateDate","isDateWithinRange","date","minTimestamp","maxTimestamp","dateTimestamp","convertTimestampToDate","timestamp","parsedTimestamp","isoDate","month","validateUrl","url","validateLength","minLength","maxLength","length","validationFields","configs","errorsList","requiredFieldError","lengthTextError","numericError","alphaNumWithSpacesError","alphaNumericError","alphaError","emailError","dateError","urlError","dateRangeError","dateMaxError","dateMinError","fieldName","defaultFields","_a","validateRulesConfig","min","max","dateMin","dateMax","parsedErrorMessage","validation","_b","initializeFormDataAndErrors","fieldsConfig","customUpperCode","required","defaultValue","excludedFocusClasses","useForm","onSubmit","formRef","useRef","focusExecutedRef","formData","setFormData","useState","errors","setErrors","handleValidationSubmit","useCallback","formValid","firstErrorField","name","fieldConfig","config","validationResult","input","useEffect","initialData","errorList","prev","handleFocus","event","target","isFocusable","className","initReCaptcha","handleChange","type","checked","fieldValue","handleBlur","handleSubmit","FieldEnumList","extractErrorKeyAndMessage","errorConfig","fallbackData","index","FieldElement","memo","item","itemClassName","loading","children","errorKey","defaultErrorMessage","customErrorMessage","errorMessage","jsx","Field","classes","InputElement","valueMessage","onBlur","onChange","onFocus","Input","SelectElement","defaultSelectValue","option","Picker","InputDateElement","InputDate","InputCheckBoxElement","Checkbox","TextAreaElement","TextArea","FormSlot","slots","handleOnChange","handleOnBlur","handleOnFocus","contextValue","Slot","Form","props","jsxs","isSlot","renderSlot"],"mappings":"ggBAIO,IAAKA,GAAAA,IACVA,EAAA,qBAAuB,qBACvBA,EAAA,cAAgB,eAChBA,EAAA,4BAA8B,0BAC9BA,EAAA,oBAAsB,oBACtBA,EAAA,YAAc,aACdA,EAAA,YAAc,aACdA,EAAA,WAAa,YACbA,EAAA,iBAAmB,iBACnBA,EAAA,eAAiB,eACjBA,EAAA,eAAiB,eACjBA,EAAA,UAAY,WACZA,EAAA,kBAAoB,kBAZVA,IAAAA,GAAA,CAAA,CAAA,EAqBL,MAAMC,EAAyB,MCCzBC,GACXC,GAC2B,CAK3B,MAAMC,EAAeC,EAAQF,CAAW,EAYlCG,EAAe,OAAO,QAAQF,CAAY,EAC7C,OACC,CAAC,CAACG,EAAKC,CAAK,IACVA,IAAU,MACT,OAAO,OAAOR,CAAoB,EAAe,SAASO,CAAG,CAAA,EAEjE,IAAI,CAAC,CAACA,CAAG,IAAMA,CAAG,EAOfE,EAAkBH,EAAa,OAAO,CAACI,EAAKH,KAChDG,EAAIH,CAAG,EAAI,iBAAiBA,CAAG,GACxBG,GACN,CAAA,CAA4B,EAGzBC,EAAsBN,EAAQI,CAAe,EAOnD,MAAO,CACL,GAAGL,EACH,GAAGE,EAAa,OAA+B,CAACI,EAAKH,KACnDG,EAAIH,CAAG,EAAII,EAAoBJ,CAAG,EAC3BG,GACN,CAAA,CAAE,CAAA,CAET,EC9BME,GAAuBC,GACpBA,EAAI,OAAO,CAACH,EAAKI,KACf,CAAE,GAAGJ,EAAK,CAACI,EAAI,IAAI,EAAGA,EAAI,KAAA,GAChC,CAAA,CAAE,EAIMC,GAAmBP,GAA2B,QAAQ,KAAKA,CAAK,EAEhE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jB,OAAI4C,EAAeC,EAGjB9B,EAACiB,GAAA,CACC,KAAAzB,EACA,aAAAY,EACA,YAAAjB,EACA,OAAQJ,EACR,SAAUJ,EACV,cAAAc,EACA,UAAAhB,EACA,QAAAiB,CAAA,CAAA,EAKN,QACE,OAAO,IAAA,CAEb,CAAC,EAEAC,CAAA,CAAA,CAAA,CAGP,CACF"}
1
+ {"version":3,"file":"Button.js","sources":["/@dropins/storefront-auth/src/types/validationErrors.types.ts","/@dropins/storefront-auth/src/hooks/useCustomTranslations.tsx","/@dropins/storefront-auth/src/lib/validationFields.ts","/@dropins/storefront-auth/src/lib/initializeFormDataAndErrors.ts","/@dropins/storefront-auth/src/configs/excludedFocusClasses.ts","/@dropins/storefront-auth/src/hooks/components/useForm.tsx","/@dropins/storefront-auth/src/data/models/attributes-form.ts","/@dropins/storefront-auth/src/lib/extractErrorKeyAndMessage.tsx","/@dropins/storefront-auth/src/components/Form/Elements/FieldElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/SelectElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputDateElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/InputCheckBoxElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/TextAreaElement.tsx","/@dropins/storefront-auth/src/components/Form/Elements/FormSlot.tsx","/@dropins/storefront-auth/src/components/Form/Form.tsx"],"sourcesContent":["/**\n * Error types in this enum are used to provide custom i18n translations for specific validation errors.\n * Each key corresponds to an error type that maps to the `Auth.FormText` i18n values in `src/i18n/en_US.json`.\n */\nexport enum ValidationErrorTypes {\n REQUIRED_FIELD_ERROR = 'requiredFieldError',\n NUMERIC_ERROR = 'numericError',\n ALPHA_NUM_WITH_SPACES_ERROR = 'alphaNumWithSpacesError',\n ALPHA_NUMERIC_ERROR = 'alphaNumericError',\n ALPHA_ERROR = 'alphaError',\n EMAIL_ERROR = 'emailError',\n DATE_ERROR = 'dateError',\n DATE_RANGE_ERROR = 'dateRangeError',\n DATE_MAX_ERROR = 'dateMaxError',\n DATE_MIN_ERROR = 'dateMinError',\n URL_ERROR = 'urlError',\n LENGTH_TEXT_ERROR = 'lengthTextError',\n}\n\n/**\n * `ERROR_CONFIG_SEPARATOR` uses the ASCII 31 (Unit Separator) character,\n * a rarely used control character, to avoid conflicts with custom i18n error messages.\n *\n * Learn more: https://theasciicode.com.ar/ascii-control-characters/unit-separator-ascii-code-31.html\n */\nexport const ERROR_CONFIG_SEPARATOR = `${String.fromCharCode(\n 31\n)}/${String.fromCharCode(31)}`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from 'preact-i18n';\nimport { ValidationErrorTypes } from '@/auth/types';\n\n/**\n * A custom hook for handling translations with support for extensible error messages.\n *\n * @param defaultKeys - A mapping of keys to their translation paths.\n * @returns A complete set of translations, including dynamically updated values for null error keys.\n */\nexport const useCustomTranslations = (\n defaultKeys: Record<string, string>\n): Record<string, string> => {\n /**\n * Step 1: Fetch initial translations using the provided keys\n * Translations are fetched from the i18n system based on the provided defaultKeys.\n */\n const translations = useText(defaultKeys);\n\n /**\n * Step 2: Identify keys that require updates\n * - These keys correspond to validation errors (defined in ValidationErrorTypes).\n * - A key needs an update if:\n * 1. Its value in the initial translations is `null`.\n * 2. The key exists in ValidationErrorTypes (indicating it’s a known error type).\n *\n * Null values typically occur when translations for the given error key are not overridden\n * and instead rely on a plain structure, e.g., \"requiredFieldError\": \"This is a required field.\"\n */\n const keysToUpdate = Object.entries(translations)\n .filter(\n ([key, value]) =>\n value === null &&\n (Object.values(ValidationErrorTypes) as string[]).includes(key)\n )\n .map(([key]) => key);\n\n /**\n * Step 3: Prepare paths for fetching updated translations\n * - For each key needing an update, create a path to its extended translation.\n * - Example: For the key \"requiredFieldError\", the updated path would be \"Auth.FormText.requiredFieldError\".\n */\n const translationKeys = keysToUpdate.reduce((acc, key) => {\n acc[key] = `Auth.FormText.${key}`; // Build the updated translation path\n return acc;\n }, {} as Record<string, string>);\n\n // Step 4: Fetch updated translations for the keys identified in Step 2\n const updatedTranslations = useText(translationKeys);\n\n /**\n * Step 5: Merge updated translations back into the initial translations\n * - Replace `null` values with the fetched updated translations.\n * - Preserve all other original translations.\n */\n return {\n ...translations, // Include original translations\n ...keysToUpdate.reduce<Record<string, string>>((acc, key) => {\n acc[key] = updatedTranslations[key]; // Overwrite `null` values with updated translations\n return acc;\n }, {}),\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ValidationErrorTypes, ERROR_CONFIG_SEPARATOR } from '@/auth/types';\n\n/* eslint-disable no-useless-escape */\ntype ValidationConfig = Record<string, string>;\ntype TranslationList = Record<string, string>;\ntype ErrorsList = Record<string, string>;\nexport type ValidationFieldsConfig = {\n validateRules: Record<string, string>[];\n code?: string;\n customUpperCode: string;\n required: boolean;\n};\n\nenum ConfigEnumLength {\n MIN_TEXT_LENGTH = 'MIN_TEXT_LENGTH',\n MAX_TEXT_LENGTH = 'MAX_TEXT_LENGTH',\n DATE_RANGE_MIN = 'DATE_RANGE_MIN',\n DATE_RANGE_MAX = 'DATE_RANGE_MAX',\n}\n\nexport enum InputValidation {\n Numeric = 'numeric',\n AlphanumWithSpaces = 'alphanum-with-spaces',\n Alphanumeric = 'alphanumeric',\n Alpha = 'alpha',\n Email = 'email',\n Length = 'length',\n Date = 'date',\n Url = 'url',\n}\n\nconst flattenObjectsArray = (arr: ValidationConfig[]): ValidationConfig => {\n return arr.reduce((acc, obj) => {\n return { ...acc, [obj.name]: obj.value };\n }, {});\n};\n\n//The basic material for the functions responsible for validation was taken from https://github.com/magento/magento2/blob/2.4/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js\nexport const validateNumeric = (value: string): boolean => /^\\d+$/.test(value);\n\nexport const validateAlphanumWithSpaces = (value: string): boolean =>\n /^[a-zA-Z0-9\\s]+$/.test(value);\n\nexport const validateAlphanumeric = (value: string): boolean =>\n /^[a-zA-Z0-9]+$/.test(value);\n\nexport const validateAlpha = (value: string): boolean =>\n /^[a-zA-Z]+$/.test(value);\n\nexport const validateEmail = (value: string): boolean =>\n /^[a-z0-9,!\\#\\$%&'\\*\\+\\/=\\?\\^_`\\{\\|\\}~-]+(\\.[a-z0-9,!\\#\\$%&'\\*\\+\\/=\\?\\^_`\\{\\|\\}~-]+)*@([a-z0-9-]+\\.)+[a-z]{2,}$/i.test(\n value\n );\n\nexport const validateDate = (value: string): boolean =>\n /^\\d{4}-\\d{2}-\\d{2}$/.test(value) && !isNaN(Date.parse(value));\n\nexport const isDateWithinRange = (\n date: string,\n minTimestamp?: number,\n maxTimestamp?: number\n): boolean => {\n const dateTimestamp = new Date(date).getTime() / 1000;\n\n if (isNaN(dateTimestamp) || dateTimestamp < 0) {\n return false;\n }\n\n if (typeof minTimestamp !== 'undefined' && dateTimestamp < minTimestamp) {\n return false;\n }\n\n if (typeof maxTimestamp !== 'undefined' && dateTimestamp > maxTimestamp) {\n return false;\n }\n\n return true;\n};\n\nexport const convertTimestampToDate = (\n timestamp: string | undefined | null\n): string => {\n if (!timestamp || timestamp.trim() === '') return '';\n\n const parsedTimestamp = parseInt(timestamp, 10);\n\n if (!isNaN(parsedTimestamp)) {\n const date = new Date(parsedTimestamp * 1000);\n\n if (isNaN(date.getTime())) return '';\n\n return date.toISOString().split('T')[0];\n }\n\n const isoDate = new Date(timestamp);\n\n if (isNaN(isoDate.getTime())) return '';\n\n const month = parseInt(timestamp.split('-')[1], 10);\n\n if (month > 12 || month < 1) return '';\n\n return isoDate.toISOString().split('T')[0];\n};\n\nexport const validateUrl = (url: string) => {\n const urlPattern =\n /^(https?|ftp):\\/\\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\\d+))?(\\/[A-Z0-9~](([A-Z0-9_~-]|\\.)*[A-Z0-9~]|))*\\/?(.*)?$/i;\n return urlPattern.test(url);\n};\n\nexport const validateLength = (\n value: string,\n minLength: number,\n maxLength: number\n): boolean => {\n const length = value.length;\n return length >= minLength && length <= maxLength;\n};\n\nexport const validationFields = (\n value: string,\n configs: ValidationFieldsConfig,\n translations: TranslationList,\n errorsList: ErrorsList\n) => {\n const {\n requiredFieldError,\n lengthTextError,\n numericError,\n alphaNumWithSpacesError,\n alphaNumericError,\n alphaError,\n emailError,\n dateError,\n urlError,\n dateRangeError,\n dateMaxError,\n dateMinError,\n } = translations;\n\n const fieldName = configs?.customUpperCode as string;\n\n const defaultFields = { [fieldName]: '' };\n\n if (errorsList[fieldName]) {\n delete errorsList[fieldName];\n }\n\n if (configs?.required && (!value || value === 'false')) {\n return {\n [fieldName]: `${ValidationErrorTypes.REQUIRED_FIELD_ERROR}${ERROR_CONFIG_SEPARATOR}${requiredFieldError}`,\n };\n }\n\n if (!configs?.required && !value) {\n return defaultFields;\n }\n\n if (!configs?.validateRules?.length) return defaultFields;\n\n const validateRulesConfig = flattenObjectsArray(configs?.validateRules);\n\n const min = validateRulesConfig[ConfigEnumLength.MIN_TEXT_LENGTH] ?? 1;\n const max = validateRulesConfig[ConfigEnumLength.MAX_TEXT_LENGTH] ?? 255;\n const dateMin = validateRulesConfig[ConfigEnumLength.DATE_RANGE_MIN];\n const dateMax = validateRulesConfig[ConfigEnumLength.DATE_RANGE_MAX];\n\n if (!validateLength(value, +min, +max) && !(dateMin || dateMax)) {\n const parsedErrorMessage = lengthTextError\n .replace('{min}', min)\n .replace('{max}', max);\n\n return {\n [fieldName]: `${ValidationErrorTypes.LENGTH_TEXT_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (!isDateWithinRange(value, +dateMin, +dateMax) && (dateMin || dateMax)) {\n if (dateMin && dateMin) {\n const parsedErrorMessage = dateRangeError\n .replace('{min}', convertTimestampToDate(dateMin))\n .replace('{max}', convertTimestampToDate(dateMax));\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_RANGE_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (typeof dateMin === 'undefined' && typeof dateMax !== 'undefined') {\n const parsedErrorMessage = dateMaxError.replace(\n '{max}',\n convertTimestampToDate(dateMax)\n );\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_MAX_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n\n if (typeof dateMax === 'undefined' && typeof dateMin !== 'undefined') {\n const parsedErrorMessage = dateMinError.replace(\n '{min}',\n convertTimestampToDate(dateMin)\n );\n\n return {\n [fieldName]: `${ValidationErrorTypes.DATE_MIN_ERROR}${ERROR_CONFIG_SEPARATOR}${parsedErrorMessage}`,\n };\n }\n }\n\n const validationMap = {\n [InputValidation.Numeric]: {\n validate: validateNumeric,\n error: `${ValidationErrorTypes.NUMERIC_ERROR}${ERROR_CONFIG_SEPARATOR}${numericError}`,\n },\n [InputValidation.AlphanumWithSpaces]: {\n validate: validateAlphanumWithSpaces,\n error: `${ValidationErrorTypes.ALPHA_NUM_WITH_SPACES_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaNumWithSpacesError}`,\n },\n [InputValidation.Alphanumeric]: {\n validate: validateAlphanumeric,\n error: `${ValidationErrorTypes.ALPHA_NUMERIC_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaNumericError}`,\n },\n [InputValidation.Alpha]: {\n validate: validateAlpha,\n error: `${ValidationErrorTypes.ALPHA_ERROR}${ERROR_CONFIG_SEPARATOR}${alphaError}`,\n },\n [InputValidation.Email]: {\n validate: validateEmail,\n error: `${ValidationErrorTypes.EMAIL_ERROR}${ERROR_CONFIG_SEPARATOR}${emailError}`,\n },\n [InputValidation.Date]: {\n validate: validateDate,\n error: `${ValidationErrorTypes.DATE_ERROR}${ERROR_CONFIG_SEPARATOR}${dateError}`,\n },\n [InputValidation.Url]: {\n validate: validateUrl,\n error: `${ValidationErrorTypes.URL_ERROR}${ERROR_CONFIG_SEPARATOR}${urlError}`,\n },\n };\n\n const validation =\n validationMap[\n validateRulesConfig['INPUT_VALIDATION'] as keyof typeof validationMap\n ];\n\n if (\n validation &&\n !validation.validate(value) &&\n !errorsList[fieldName]?.length\n ) {\n return { [fieldName]: validation.error };\n }\n\n return defaultFields;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport default (\n fieldsConfig: Array<{\n customUpperCode?: string;\n required?: boolean;\n defaultValue?: unknown;\n }>\n): {\n initialData: Record<string, unknown>;\n errorList: Record<string, string>;\n} => {\n return fieldsConfig.reduce(\n (\n acc: {\n initialData: Record<string, unknown>;\n errorList: Record<string, string>;\n },\n { customUpperCode, required, defaultValue }\n ) => {\n if (required && customUpperCode) {\n acc.initialData[customUpperCode] = defaultValue || '';\n acc.errorList[customUpperCode] = '';\n }\n\n return acc;\n },\n {\n initialData: {},\n errorList: {},\n }\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\n/**\n * This file defines an array of class names that should be excluded\n * from specific init Recaptcha logic.\n *\n * The array contains class names representing elements that should be\n * ignored when certain operations, such as focusing or applying event\n * handlers, are executed.\n *\n * By checking if an element's class matches any class in this array,\n * you can easily bypass unwanted logic for those elements, ensuring\n * precise and predictable behavior in your application.\n *\n */\n\nexport const excludedFocusClasses = [\n 'auth-reset-password-form__buttons--signin',\n 'auth-sign-up-form-buttons--signin',\n 'auth-sign-in-form__button--forgot',\n 'auth-sign-in-form__button--signup',\n];\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useCallback, useRef, useState, useEffect } from 'preact/hooks';\nimport { FieldsProps, useFormProps } from '@/auth/types';\nimport { initReCaptcha } from '@adobe-commerce/recaptcha';\nimport initializeFormDataAndErrors from '@/auth/lib/initializeFormDataAndErrors';\nimport {\n validationFields,\n ValidationFieldsConfig,\n} from '@/auth/lib/validationFields';\nimport { excludedFocusClasses } from '@/auth/configs/excludedFocusClasses';\nimport { useCustomTranslations } from '@/auth/hooks/useCustomTranslations';\n\nexport const useForm = ({ fieldsConfig, onSubmit }: useFormProps) => {\n /**\n * useCustomTranslations is required to support extensibility of error messages.\n * Ensure all error-related translation paths include \".default\"\n * to allow future handling of dynamic or nested error messages.\n */\n const translations = useCustomTranslations({\n requiredFieldError: 'Auth.FormText.requiredFieldError.default',\n lengthTextError: 'Auth.FormText.lengthTextError.default',\n numericError: 'Auth.FormText.numericError.default',\n alphaNumWithSpacesError: 'Account.FormText.alphaNumWithSpacesError.default',\n alphaNumericError: 'Auth.FormText.alphaNumericError.default',\n alphaError: 'Auth.FormText.alphaError.default',\n emailError: 'Auth.FormText.emailError.default',\n dateError: 'Auth.FormText.dateError.default',\n dateRangeError: 'Auth.FormText.dateRangeError.default',\n dateMaxError: 'Auth.FormText.dateMaxError.default',\n dateMinError: 'Auth.FormText.dateMinError.default',\n urlError: 'Auth.FormText.urlError.default',\n });\n\n const formRef = useRef<HTMLFormElement>(null);\n const focusExecutedRef = useRef<boolean>(false);\n const [formData, setFormData] = useState<\n Record<string, string | boolean | number>\n >({});\n const [errors, setErrors] = useState<Record<string, string>>({});\n\n const handleValidationSubmit = useCallback(() => {\n let formValid = true;\n const errorsList = { ...errors };\n let firstErrorField: string | null = null;\n\n for (const [name, value] of Object.entries(formData)) {\n const fieldConfig = fieldsConfig?.find((config: FieldsProps) =>\n config?.customUpperCode?.includes(name)\n );\n\n const validationResult = validationFields(\n value.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult[name]) {\n Object.assign(errorsList, validationResult);\n formValid = false;\n }\n\n if (!firstErrorField) {\n firstErrorField =\n Object.keys(errorsList).find((key) => errorsList[key]) ?? null;\n }\n }\n\n setErrors(errorsList);\n\n if (firstErrorField && formRef.current) {\n const input = formRef.current.elements.namedItem(\n firstErrorField\n ) as HTMLElement;\n input?.focus();\n }\n\n return formValid;\n }, [errors, fieldsConfig, formData, translations]);\n\n useEffect(() => {\n if (fieldsConfig?.length) {\n const { initialData, errorList } =\n initializeFormDataAndErrors(fieldsConfig);\n\n setFormData((prev) => ({\n ...(initialData as Record<string, string | number>),\n ...prev,\n }));\n\n setErrors(errorList);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(fieldsConfig)]);\n\n const handleFocus = useCallback(async (event: FocusEvent) => {\n const target = event.target as HTMLInputElement;\n const isFocusable = !excludedFocusClasses.some((className) =>\n target.classList.contains(className)\n );\n\n if (!focusExecutedRef.current && isFocusable) {\n await initReCaptcha(0);\n focusExecutedRef.current = true;\n }\n }, []);\n\n const handleChange = useCallback(\n (event: Event) => {\n const { name, value, type, checked } = event?.target as HTMLInputElement;\n const fieldValue = type === 'checkbox' ? checked : value;\n\n setFormData((prev) => {\n const updatedFormData = {\n ...prev,\n [name]: fieldValue,\n };\n\n return updatedFormData as Record<string, string | number>;\n });\n\n const fieldConfig = fieldsConfig?.find((config: FieldsProps) =>\n config?.customUpperCode?.includes(name)\n );\n\n let errorsList = { ...errors };\n\n if (fieldConfig) {\n const validationResult = validationFields(\n fieldValue.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult) {\n Object.assign(errorsList, validationResult);\n }\n\n setErrors(errorsList);\n }\n },\n [fieldsConfig, errors, translations]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const { name, value, type, checked } = event?.target as HTMLInputElement;\n const fieldValue = type === 'checkbox' ? checked : value;\n\n const fieldConfig = fieldsConfig?.find(\n (config: FieldsProps) => config.customUpperCode === name\n );\n\n if (fieldConfig) {\n const errorsList = { ...errors };\n\n const validationResult = validationFields(\n fieldValue.toString(),\n fieldConfig as ValidationFieldsConfig,\n translations,\n errorsList\n );\n\n if (validationResult) {\n Object.assign(errorsList, validationResult);\n }\n\n setErrors(errorsList);\n }\n },\n [errors, fieldsConfig, translations]\n );\n\n const handleSubmit = useCallback(\n (event: SubmitEvent) => {\n event.preventDefault();\n\n const formValid = handleValidationSubmit();\n\n onSubmit?.(event, formValid);\n },\n [handleValidationSubmit, onSubmit]\n );\n\n return {\n formData,\n errors,\n formRef,\n handleChange,\n handleBlur,\n handleSubmit,\n handleFocus,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport enum FieldEnumList {\n BOOLEAN = 'BOOLEAN',\n DATE = 'DATE',\n DATETIME = 'DATETIME',\n DROPDOWN = 'DROPDOWN',\n FILE = 'FILE',\n GALLERY = 'GALLERY',\n HIDDEN = 'HIDDEN',\n IMAGE = 'IMAGE',\n MEDIA_IMAGE = 'MEDIA_IMAGE',\n MULTILINE = 'MULTILINE',\n MULTISELECT = 'MULTISELECT',\n PRICE = 'PRICE',\n SELECT = 'SELECT',\n TEXT = 'TEXT',\n TEXTAREA = 'TEXTAREA',\n UNDEFINED = 'UNDEFINED',\n VISUAL = 'VISUAL',\n WEIGHT = 'WEIGHT',\n EMPTY = '',\n}\n\nexport interface AttributesFormItemsProps {\n code?: string;\n name?: string;\n id?: string;\n defaultValue?: string | boolean | number;\n entityType?: string;\n className?: string;\n fieldType?: FieldEnumList;\n multilineCount: number;\n required?: boolean;\n unique?: boolean;\n label?: string;\n orderNumber: number;\n options?: { is_default: boolean; label: string; value: string }[];\n hidden?: boolean;\n customUpperCode: string;\n}\n\nexport interface AttributesFormModel extends AttributesFormItemsProps {}\n","import { ERROR_CONFIG_SEPARATOR } from '@/auth/types';\n\ntype ExtractErrorKeyAndMessage = {\n errorKey: string;\n defaultErrorMessage: string;\n};\n\nexport const extractErrorKeyAndMessage = (\n errorConfig: string\n): ExtractErrorKeyAndMessage => {\n const fallbackData = { errorKey: '', defaultErrorMessage: '' };\n\n if (!errorConfig) return fallbackData;\n\n const index = errorConfig.indexOf(ERROR_CONFIG_SEPARATOR);\n\n if (index === -1) return fallbackData;\n\n return {\n errorKey: errorConfig.substring(0, index).trim(),\n defaultErrorMessage: errorConfig\n .substring(index + ERROR_CONFIG_SEPARATOR.length)\n .trim(),\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FieldElementProps } from '@/auth/types';\nimport { Field } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { memo } from 'preact/compat';\nimport { extractErrorKeyAndMessage } from '@/auth/lib/extractErrorKeyAndMessage';\nimport { VNode } from 'preact';\n\nexport const FieldElement = memo(\n ({\n item,\n errorConfig,\n className,\n itemClassName,\n loading,\n children,\n }: FieldElementProps) => {\n const { errorKey, defaultErrorMessage } =\n extractErrorKeyAndMessage(errorConfig);\n const customErrorMessage = useText(\n `Auth.FormText.${errorKey}.${item.code}`\n )[item.code];\n\n let errorMessage = '';\n\n // This check indicates that validation identified an error\n if (defaultErrorMessage.length) {\n errorMessage = customErrorMessage || defaultErrorMessage;\n }\n\n return (\n <Field\n key={item.id}\n error={errorMessage}\n className={classes([\n itemClassName,\n `${itemClassName}--${item.id}`,\n [`${itemClassName}--${item.id}-hidden`, item.isHidden],\n item.className,\n ])}\n data-testid={`${className}--${item.id}`}\n disabled={loading || item.disabled}\n >\n {children as VNode<{}>}\n </Field>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Input } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n onFocus,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Input\n type=\"text\"\n name={item.customUpperCode}\n value={valueMessage ?? item.defaultValue}\n placeholder={item.label}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n autocomplete={item.autocomplete}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Picker } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const SelectElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n const defaultSelectValue = item.options.find(\n (option: { isDefault: boolean; value: string; text: string }) =>\n option.isDefault\n )?.value;\n\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Picker\n name={item.customUpperCode}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n placeholder={item.label}\n aria-label={item.label}\n options={item.options}\n onBlur={onBlur}\n handleSelect={onChange}\n defaultValue={defaultSelectValue ?? valueMessage ?? item.defaultValue}\n value={defaultSelectValue ?? valueMessage ?? item.defaultValue}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { InputDate } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputDateElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <InputDate\n // @ts-ignore\n type=\"text\"\n name={item.customUpperCode}\n value={valueMessage || item.defaultValue}\n placeholder={item.label}\n floatingLabel={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n disabled={loading || item.disabled}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { Checkbox } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const InputCheckBoxElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <Checkbox\n name={item.customUpperCode}\n checked={valueMessage || item.defaultValue}\n placeholder={item.label}\n label={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FormElementProps } from '@/auth/types';\nimport { TextArea } from '@adobe-commerce/elsie/components';\nimport { memo } from 'preact/compat';\nimport { FieldElement } from './FieldElement';\n\nexport const TextAreaElement = memo(\n ({\n item,\n valueMessage,\n errorConfig,\n onBlur,\n onChange,\n className,\n itemClassName,\n loading,\n }: FormElementProps) => {\n return (\n <FieldElement\n item={item}\n errorConfig={errorConfig}\n className={className}\n itemClassName={itemClassName}\n loading={loading}\n >\n <TextArea\n name={item.customUpperCode}\n value={valueMessage ?? item.defaultValue}\n label={`${item.label} ${item.required ? '*' : ''}`}\n onBlur={onBlur}\n onChange={onChange}\n />\n </FieldElement>\n );\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { extractErrorKeyAndMessage } from '@/auth/lib/extractErrorKeyAndMessage';\nimport { FormSlotProps } from '@/auth/types';\nimport { useText } from 'preact-i18n';\nimport { Slot } from '@adobe-commerce/elsie/lib';\n\nexport const FormSlot = ({\n slots,\n item,\n handleOnChange,\n handleOnBlur,\n handleOnFocus,\n errorConfig,\n errors,\n}: FormSlotProps) => {\n const { errorKey, defaultErrorMessage } =\n extractErrorKeyAndMessage(errorConfig);\n const customErrorMessage = useText(`Auth.FormText.${errorKey}.${item.code}`)[\n item.code\n ];\n\n let errorMessage = '';\n\n // This check indicates that validation identified an error\n if (defaultErrorMessage.length) {\n errorMessage = customErrorMessage || defaultErrorMessage;\n }\n\n const contextValue = {\n inputName: item.customUpperCode,\n handleOnChange,\n handleOnBlur,\n handleOnFocus,\n errorMessage,\n errors,\n config: item,\n };\n\n return (\n <Slot\n data-testid={`signUpFormInput_${item.code}`}\n name={`SignUpFormInput_${item.code}`}\n slot={slots?.[`SignUpFormInput_${item.code}`]}\n context={contextValue}\n key={item.id}\n />\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FieldsProps, FormProps } from '@/auth/types';\nimport { useForm } from '@/auth/hooks/components/useForm';\nimport { FieldEnumList } from '@/auth/data/models';\nimport { Slot } from '@adobe-commerce/elsie/lib';\nimport {\n SelectElement,\n InputElement,\n InputDateElement,\n InputCheckBoxElement,\n TextAreaElement,\n FormSlot,\n} from './Elements';\nimport { memo } from 'preact/compat';\n\nexport const Form = memo(\n ({\n slots,\n name,\n loading,\n children,\n className = 'defaultForm',\n fieldsConfig = [],\n onSubmit,\n formSlot,\n ...props\n }: FormProps) => {\n const {\n formData,\n errors,\n formRef,\n handleChange,\n handleBlur,\n handleSubmit,\n handleFocus,\n } = useForm({\n onSubmit,\n fieldsConfig,\n });\n\n const itemClassName = `${className}__field`;\n\n const formContent = (\n <>\n {fieldsConfig.map((item: FieldsProps) => {\n const errorConfig = errors?.[item.customUpperCode];\n const valueMessage = formData?.[item.customUpperCode] as string;\n const isSlot = !!slots?.[`SignUpFormInput_${item.code}`];\n\n const renderSlot = (\n <FormSlot\n slots={slots}\n item={item}\n handleOnChange={handleChange}\n handleOnBlur={handleBlur}\n handleOnFocus={handleFocus}\n errorConfig={errorConfig}\n errors={errors}\n />\n );\n\n switch (item.fieldType) {\n case FieldEnumList.TEXT: {\n if (isSlot) return renderSlot;\n\n if (item.options.length) {\n return (\n <SelectElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n return (\n <InputElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.MULTILINE: {\n if (isSlot) return renderSlot;\n\n return (\n <InputElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.SELECT: {\n if (isSlot) return renderSlot;\n\n return (\n <SelectElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.DATE: {\n if (isSlot) return renderSlot;\n\n return (\n <InputDateElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.BOOLEAN: {\n if (isSlot) return renderSlot;\n\n return (\n <InputCheckBoxElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n case FieldEnumList.TEXTAREA: {\n if (isSlot) return renderSlot;\n\n return (\n <TextAreaElement\n item={item}\n valueMessage={valueMessage}\n errorConfig={errorConfig}\n onBlur={handleBlur}\n onChange={handleChange}\n itemClassName={itemClassName}\n className={className}\n loading={loading}\n />\n );\n }\n\n default:\n return null;\n }\n })}\n {children}\n </>\n );\n\n const slotContext = {\n ...(formSlot.context || {}),\n __formContentKey: [\n fieldsConfig.map((f: FieldsProps) => f.id || f.code).join(','),\n JSON.stringify(errors),\n JSON.stringify(formData),\n ].join('|'),\n };\n\n return (\n <form\n onSubmit={handleSubmit}\n name={name}\n ref={formRef}\n onFocus={handleFocus}\n {...props}\n >\n <Slot\n name={formSlot.name}\n slot={formSlot.slot}\n context={slotContext}\n className={className}\n data-testid={formSlot.dataTestId}\n >\n {formContent}\n </Slot>\n </form>\n );\n }\n);\n"],"names":["ValidationErrorTypes","ERROR_CONFIG_SEPARATOR","useCustomTranslations","defaultKeys","translations","useText","keysToUpdate","key","value","translationKeys","acc","updatedTranslations","flattenObjectsArray","arr","obj","validateNumeric","validateAlphanumWithSpaces","validateAlphanumeric","validateAlpha","validateEmail","validateDate","isDateWithinRange","date","minTimestamp","maxTimestamp","dateTimestamp","convertTimestampToDate","timestamp","parsedTimestamp","isoDate","month","validateUrl","url","validateLength","minLength","maxLength","length","validationFields","configs","errorsList","requiredFieldError","lengthTextError","numericError","alphaNumWithSpacesError","alphaNumericError","alphaError","emailError","dateError","urlError","dateRangeError","dateMaxError","dateMinError","fieldName","defaultFields","_a","validateRulesConfig","min","max","dateMin","dateMax","parsedErrorMessage","validation","_b","initializeFormDataAndErrors","fieldsConfig","customUpperCode","required","defaultValue","excludedFocusClasses","useForm","onSubmit","formRef","useRef","focusExecutedRef","formData","setFormData","useState","errors","setErrors","handleValidationSubmit","useCallback","formValid","firstErrorField","name","fieldConfig","config","validationResult","input","useEffect","initialData","errorList","prev","handleFocus","event","target","isFocusable","className","initReCaptcha","handleChange","type","checked","fieldValue","handleBlur","handleSubmit","FieldEnumList","extractErrorKeyAndMessage","errorConfig","fallbackData","index","FieldElement","memo","item","itemClassName","loading","children","errorKey","defaultErrorMessage","customErrorMessage","errorMessage","jsx","Field","classes","InputElement","valueMessage","onBlur","onChange","onFocus","Input","SelectElement","defaultSelectValue","option","Picker","InputDateElement","InputDate","InputCheckBoxElement","Checkbox","TextAreaElement","TextArea","FormSlot","slots","handleOnChange","handleOnBlur","handleOnFocus","contextValue","Slot","Form","formSlot","props","formContent","jsxs","Fragment","isSlot","renderSlot","slotContext","f"],"mappings":"+gBAIO,IAAKA,GAAAA,IACVA,EAAA,qBAAuB,qBACvBA,EAAA,cAAgB,eAChBA,EAAA,4BAA8B,0BAC9BA,EAAA,oBAAsB,oBACtBA,EAAA,YAAc,aACdA,EAAA,YAAc,aACdA,EAAA,WAAa,YACbA,EAAA,iBAAmB,iBACnBA,EAAA,eAAiB,eACjBA,EAAA,eAAiB,eACjBA,EAAA,UAAY,WACZA,EAAA,kBAAoB,kBAZVA,IAAAA,GAAA,CAAA,CAA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AAS,KACf,QAASO,EACT,UAAAzD,EACA,cAAakD,EAAS,WAErB,SAAAE,CAAA,CAAA,CACH,CAAA,CAGN,CACF"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as l,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{v as _,F}from"./Button.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as P}from"./requestPasswordResetEmail.js";import{g as v,c as p,u as x,B as g}from"./Button2.js";import{useState as N,useCallback as y}from"@dropins/tools/preact-hooks.js";import{useText as b}from"@dropins/tools/i18n.js";import{Header as E,InLineAlert as L}from"@dropins/tools/components.js";import{s as T,D}from"./simplifyTransformAttributesForm.js";import*as R from"@dropins/tools/preact-compat.js";const A=s=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},R.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round"})),j=({routeSignIn:s,onErrorCallback:a,onSuccessCallback:m,setActiveComponent:n,handleSetInLineAlertProps:t})=>{const c=b({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[i,e]=N(!1),f=y(async d=>{d.preventDefault();const r=v(d.target);if(!_(r==null?void 0:r.email))return;e(!0);const w=await P(r.email);if(e(!1),!w.success){a==null||a(w),t==null||t({type:"error",text:w.message});return}if(m){await m();return}t==null||t({type:"success",text:c.successPasswordResetEmailNotification.replace("{email}",r.email)})},[t,a,m,c.successPasswordResetEmailNotification]),u=y(()=>{if(p(n)){n("signInForm");return}p(s)&&(window.location.href=s())},[n,s]);return{isLoading:i,submitResetPassword:f,redirectToSignInPage:u}},J=({formSize:s="default",routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:t,...c})=>{const i=b({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:e,handleSetInLineAlertProps:f}=x(),{isLoading:u,submitResetPassword:d,redirectToSignInPage:r}=j({routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:t,handleSetInLineAlertProps:f});return l("div",{...c,className:h(["auth-reset-password-form",`auth-reset-password-form--${s}`]),"data-testid":"resetPasswordForm",children:[o(E,{title:i.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(L,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(F,{"aria-labelledby":i.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:d,loading:u,fieldsConfig:T(D),children:l("div",{className:"auth-reset-password-form__buttons",children:[o(g,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:o(A,{style:{transform:"rotate(90deg)"}}),buttonText:i.buttonSecondary,enableLoader:!1,onClick:r}),o(g,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:u})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{J as R};
3
+ import{jsxs as p,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as x,Slot as g}from"@dropins/tools/lib.js";import{v as _,F as P}from"./Button.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as v}from"./requestPasswordResetEmail.js";import{g as N,c as y,u as T,B as b}from"./Button2.js";import{useState as E,useCallback as R}from"@dropins/tools/preact-hooks.js";import{useText as F}from"@dropins/tools/i18n.js";import{Header as L,InLineAlert as D}from"@dropins/tools/components.js";import{s as B,D as A}from"./simplifyTransformAttributesForm.js";import*as h from"@dropins/tools/preact-compat.js";const j=a=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1,strokeLinecap:"square",strokeLinejoin:"round"})),q=({routeSignIn:a,onErrorCallback:i,onSuccessCallback:c,setActiveComponent:d,handleSetInLineAlertProps:e})=>{const t=F({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[f,r]=E(!1),m=R(async n=>{n.preventDefault();const o=N(n.target);if(!_(o==null?void 0:o.email))return;r(!0);const u=await v(o.email);if(r(!1),!u.success){i==null||i(u),e==null||e({type:"error",text:u.message});return}if(c){await c();return}e==null||e({type:"success",text:t.successPasswordResetEmailNotification.replace("{email}",o.email)})},[e,i,c,t.successPasswordResetEmailNotification]),w=R(()=>{if(y(d)){d("signInForm");return}y(a)&&(window.location.href=a())},[d,a]);return{isLoading:f,submitResetPassword:m,redirectToSignInPage:w}},Q=({formSize:a="default",routeSignIn:i,setActiveComponent:c,onErrorCallback:d,onSuccessCallback:e,slots:t,...f})=>{const r=F({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:m,handleSetInLineAlertProps:w}=T(),{isLoading:n,submitResetPassword:o,redirectToSignInPage:u}=q({routeSignIn:i,setActiveComponent:c,onErrorCallback:d,onSuccessCallback:e,handleSetInLineAlertProps:w}),l={isLoading:n};return p("div",{...f,className:x(["auth-reset-password-form",`auth-reset-password-form--${a}`]),"data-testid":"resetPasswordForm",children:[s(g,{name:"Title","data-testid":"title",slot:t==null?void 0:t.Title,context:{...l},children:s(L,{title:r.title,divider:!1,className:"auth-reset-password-form__title"})}),m.text?s(D,{className:"auth-reset-password-form__notification",type:m.type,variant:"secondary",heading:m.text,icon:m.icon}):null,s(P,{"aria-labelledby":r.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:o,loading:n,fieldsConfig:B(A),formSlot:{name:"Form",slot:t==null?void 0:t.Form,context:l,dataTestId:"form"},children:p(g,{name:"Buttons",className:"auth-reset-password-form__buttons","data-testid":"buttons",slot:t==null?void 0:t.Buttons,context:{...l},children:[s(b,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:s(j,{style:{transform:"rotate(90deg)"}}),buttonText:r.buttonSecondary,enableLoader:!1,onClick:u}),s(b,{type:"submit",buttonText:r.buttonPrimary,variant:"primary",enableLoader:n})]})}),s("div",{id:"requestPasswordResetEmail"})]})};export{Q as R};
4
4
  //# sourceMappingURL=ResetPasswordForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResetPasswordForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/ChevronDown.svg","/@dropins/storefront-auth/src/hooks/components/useResetPasswordForm.tsx","/@dropins/storefront-auth/src/components/ResetPasswordForm/ResetPasswordForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgChevronDown = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"square\", strokeLinejoin: \"round\" }));\nexport default SvgChevronDown;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { requestPasswordResetEmail } from '@/auth/api';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { UseResetPasswordFormProps } from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useCallback, useState } from 'preact/hooks';\nimport { validateEmail } from '@/auth/lib/validationFields';\n\nexport const useResetPasswordForm = ({\n routeSignIn,\n onErrorCallback,\n onSuccessCallback,\n setActiveComponent,\n handleSetInLineAlertProps,\n}: UseResetPasswordFormProps) => {\n const translations = useText({\n successPasswordResetEmailNotification:\n 'Auth.Notification.successPasswordResetEmailNotification',\n });\n const [isLoading, setIsLoading] = useState(false);\n\n const submitResetPassword = useCallback(\n async (event: any): Promise<void> => {\n event.preventDefault();\n\n const formValues = getFormValues(event.target);\n\n if (!validateEmail(formValues?.email)) {\n return;\n }\n\n setIsLoading(true);\n\n const response = await requestPasswordResetEmail(formValues.email);\n\n setIsLoading(false);\n\n if (!response.success) {\n onErrorCallback?.(response);\n handleSetInLineAlertProps?.({\n type: 'error',\n text: response.message,\n });\n return;\n }\n\n if (onSuccessCallback) {\n await onSuccessCallback();\n return;\n }\n\n handleSetInLineAlertProps?.({\n type: 'success',\n text: translations.successPasswordResetEmailNotification.replace(\n '{email}',\n formValues.email\n ),\n });\n },\n [\n handleSetInLineAlertProps,\n onErrorCallback,\n onSuccessCallback,\n translations.successPasswordResetEmailNotification,\n ]\n );\n\n const redirectToSignInPage = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signInForm');\n return;\n }\n\n if (checkIsFunction(routeSignIn)) {\n window.location.href = routeSignIn();\n }\n }, [setActiveComponent, routeSignIn]);\n\n return {\n isLoading,\n submitResetPassword,\n redirectToSignInPage,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/auth/components/ResetPasswordForm/ResetPasswordForm.css';\nimport { useResetPasswordForm } from '@/auth/hooks/components/useResetPasswordForm';\nimport { ResetPasswordFormProps } from '@/auth/types';\nimport { ChevronDown as ChevronLeft } from '@adobe-commerce/elsie/icons';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { DEFAULT__RESET_PASSWORD_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\n\nexport const ResetPasswordForm: FunctionComponent<\n ResetPasswordFormProps & HTMLAttributes<HTMLDivElement>\n> = ({\n formSize = 'default',\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n ...props\n}) => {\n const translations = useText({\n title: 'Auth.ResetPasswordForm.title',\n buttonPrimary: 'Auth.ResetPasswordForm.buttonPrimary',\n buttonSecondary: 'Auth.ResetPasswordForm.buttonSecondary',\n formAriaLabel: 'Auth.ResetPasswordForm.formAriaLabel',\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const { isLoading, submitResetPassword, redirectToSignInPage } =\n useResetPasswordForm({\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n });\n\n return (\n <div\n {...props}\n className={classes([\n 'auth-reset-password-form',\n `auth-reset-password-form--${formSize}`,\n ])}\n data-testid=\"resetPasswordForm\"\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-reset-password-form__title\"\n />\n {inLineAlertProps.text ? (\n <InLineAlert\n className=\"auth-reset-password-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n />\n ) : null}\n <Form\n aria-labelledby={translations.formAriaLabel}\n name=\"resetPassword_form\"\n className=\"auth-reset-password-form__form\"\n onSubmit={submitResetPassword}\n loading={isLoading}\n fieldsConfig={simplifyTransformAttributesForm(\n DEFAULT__RESET_PASSWORD_EMAIL_FIELD\n )}\n >\n <div className=\"auth-reset-password-form__buttons\">\n <Button\n className=\"auth-reset-password-form__buttons--signin\"\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: '0' }}\n icon={<ChevronLeft style={{ transform: 'rotate(90deg)' }} />}\n buttonText={translations.buttonSecondary}\n enableLoader={false}\n onClick={redirectToSignInPage}\n />\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </div>\n </Form>\n <div id=\"requestPasswordResetEmail\" />\n </div>\n );\n};\n"],"names":["SvgChevronDown","props","React","useResetPasswordForm","routeSignIn","onErrorCallback","onSuccessCallback","setActiveComponent","handleSetInLineAlertProps","translations","useText","isLoading","setIsLoading","useState","submitResetPassword","useCallback","event","formValues","getFormValues","validateEmail","response","requestPasswordResetEmail","redirectToSignInPage","checkIsFunction","ResetPasswordForm","formSize","inLineAlertProps","useInLineAlert","jsxs","classes","jsx","Header","InLineAlert","Form","simplifyTransformAttributesForm","DEFAULT__RESET_PASSWORD_EMAIL_FIELD","Button","ChevronLeft"],"mappings":"wnBACA,MAAMA,EAAkBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAs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":"ResetPasswordForm.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/ChevronDown.svg","/@dropins/storefront-auth/src/hooks/components/useResetPasswordForm.tsx","/@dropins/storefront-auth/src/components/ResetPasswordForm/ResetPasswordForm.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgChevronDown = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"square\", strokeLinejoin: \"round\" }));\nexport default SvgChevronDown;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { requestPasswordResetEmail } from '@/auth/api';\nimport { checkIsFunction } from '@/auth/lib/checkIsFunction';\nimport { getFormValues } from '@/auth/lib/getFormValues';\nimport { UseResetPasswordFormProps } from '@/auth/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { useCallback, useState } from 'preact/hooks';\nimport { validateEmail } from '@/auth/lib/validationFields';\n\nexport const useResetPasswordForm = ({\n routeSignIn,\n onErrorCallback,\n onSuccessCallback,\n setActiveComponent,\n handleSetInLineAlertProps,\n}: UseResetPasswordFormProps) => {\n const translations = useText({\n successPasswordResetEmailNotification:\n 'Auth.Notification.successPasswordResetEmailNotification',\n });\n const [isLoading, setIsLoading] = useState(false);\n\n const submitResetPassword = useCallback(\n async (event: any): Promise<void> => {\n event.preventDefault();\n\n const formValues = getFormValues(event.target);\n\n if (!validateEmail(formValues?.email)) {\n return;\n }\n\n setIsLoading(true);\n\n const response = await requestPasswordResetEmail(formValues.email);\n\n setIsLoading(false);\n\n if (!response.success) {\n onErrorCallback?.(response);\n handleSetInLineAlertProps?.({\n type: 'error',\n text: response.message,\n });\n return;\n }\n\n if (onSuccessCallback) {\n await onSuccessCallback();\n return;\n }\n\n handleSetInLineAlertProps?.({\n type: 'success',\n text: translations.successPasswordResetEmailNotification.replace(\n '{email}',\n formValues.email\n ),\n });\n },\n [\n handleSetInLineAlertProps,\n onErrorCallback,\n onSuccessCallback,\n translations.successPasswordResetEmailNotification,\n ]\n );\n\n const redirectToSignInPage = useCallback(() => {\n if (checkIsFunction(setActiveComponent)) {\n setActiveComponent('signInForm');\n return;\n }\n\n if (checkIsFunction(routeSignIn)) {\n window.location.href = routeSignIn();\n }\n }, [setActiveComponent, routeSignIn]);\n\n return {\n isLoading,\n submitResetPassword,\n redirectToSignInPage,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, Slot } from '@adobe-commerce/elsie/lib';\nimport '@/auth/components/ResetPasswordForm/ResetPasswordForm.css';\nimport { useResetPasswordForm } from '@/auth/hooks/components/useResetPasswordForm';\nimport { ResetPasswordFormProps } from '@/auth/types';\nimport { ChevronDown as ChevronLeft } from '@adobe-commerce/elsie/icons';\nimport { Form, Button } from '@/auth/components';\nimport { useInLineAlert } from '@/auth/hooks/useInLineAlert';\nimport { Header, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { simplifyTransformAttributesForm } from '@/auth/lib/simplifyTransformAttributesForm';\nimport { DEFAULT__RESET_PASSWORD_EMAIL_FIELD } from '@/auth/configs/defaultCreateUserConfigs';\n\nexport const ResetPasswordForm: FunctionComponent<\n ResetPasswordFormProps & HTMLAttributes<HTMLDivElement>\n> = ({\n formSize = 'default',\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n slots,\n ...props\n}) => {\n const translations = useText({\n title: 'Auth.ResetPasswordForm.title',\n buttonPrimary: 'Auth.ResetPasswordForm.buttonPrimary',\n buttonSecondary: 'Auth.ResetPasswordForm.buttonSecondary',\n formAriaLabel: 'Auth.ResetPasswordForm.formAriaLabel',\n });\n\n const { inLineAlertProps, handleSetInLineAlertProps } = useInLineAlert();\n\n const { isLoading, submitResetPassword, redirectToSignInPage } =\n useResetPasswordForm({\n routeSignIn,\n setActiveComponent,\n onErrorCallback,\n onSuccessCallback,\n handleSetInLineAlertProps,\n });\n\n const slotContext = { isLoading };\n\n return (\n <div\n {...props}\n className={classes([\n 'auth-reset-password-form',\n `auth-reset-password-form--${formSize}`,\n ])}\n data-testid=\"resetPasswordForm\"\n >\n <Slot\n name=\"Title\"\n data-testid=\"title\"\n slot={slots?.Title}\n context={{ ...slotContext }}\n >\n <Header\n title={translations.title}\n divider={false}\n className=\"auth-reset-password-form__title\"\n />\n </Slot>\n {inLineAlertProps.text ? (\n <InLineAlert\n className=\"auth-reset-password-form__notification\"\n type={inLineAlertProps.type}\n variant=\"secondary\"\n heading={inLineAlertProps.text}\n icon={inLineAlertProps.icon}\n />\n ) : null}\n <Form\n aria-labelledby={translations.formAriaLabel}\n name=\"resetPassword_form\"\n className=\"auth-reset-password-form__form\"\n onSubmit={submitResetPassword}\n loading={isLoading}\n fieldsConfig={simplifyTransformAttributesForm(\n DEFAULT__RESET_PASSWORD_EMAIL_FIELD\n )}\n formSlot={{\n name: 'Form',\n slot: slots?.Form,\n context: slotContext,\n dataTestId: 'form',\n }}\n >\n <Slot\n name=\"Buttons\"\n className=\"auth-reset-password-form__buttons\"\n data-testid=\"buttons\"\n slot={slots?.Buttons}\n context={{ ...slotContext }}\n >\n <Button\n className=\"auth-reset-password-form__buttons--signin\"\n type=\"button\"\n variant=\"tertiary\"\n style={{ padding: '0' }}\n icon={<ChevronLeft style={{ transform: 'rotate(90deg)' }} />}\n buttonText={translations.buttonSecondary}\n enableLoader={false}\n onClick={redirectToSignInPage}\n />\n <Button\n type=\"submit\"\n buttonText={translations.buttonPrimary}\n variant=\"primary\"\n enableLoader={isLoading}\n />\n </Slot>\n </Form>\n <div id=\"requestPasswordResetEmail\" />\n </div>\n );\n };\n"],"names":["SvgChevronDown","props","React","useResetPasswordForm","routeSignIn","onErrorCallback","onSuccessCallback","setActiveComponent","handleSetInLineAlertProps","translations","useText","isLoading","setIsLoading","useState","submitResetPassword","useCallback","event","formValues","getFormValues","validateEmail","response","requestPasswordResetEmail","redirectToSignInPage","checkIsFunction","ResetPasswordForm","formSize","slots","inLineAlertProps","useInLineAlert","slotContext","jsxs","classes","jsx","Slot","Header","InLineAlert","Form","simplifyTransformAttributesForm","DEFAULT__RESET_PASSWORD_EMAIL_FIELD","Button","ChevronLeft"],"mappings":"4oBACA,MAAMA,EAAkBC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,CAAK,EAAoBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,kDAAmD,OAAQ,eAAgB,YAAa,EAAG,cAAe,SAAU,eAAgB,OAAO,CAAE,CAAC,ECwBjZC,EAAuB,CAAC,CACnC,YAAAC,EACA,gBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,0BAAAC,CACF,IAAiC,CAC/B,MAAMC,EAAeC,EAAQ,CAC3B,sCACE,yDAAA,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,EAEFqB,EAAC,MAAA,CAAI,GAAG,2BAAA,CAA4B,CAAA,CAAA,CAAA,CAG1C","x_google_ignoreList":[0]}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2026 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as m,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as O,classes as R}from"@dropins/tools/lib.js";import{c as E,g as tt,u as rt,B as $}from"./Button2.js";import{useState as y,useCallback as c,useEffect as Q,useMemo as at}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as ot}from"./getCustomerToken.js";import{r as et}from"./resendConfirmationEmail.js";import{s as it,a as st}from"./simplifyTransformAttributesForm.js";import{f as nt,E as ut}from"./focusOnEmptyPasswordField.js";import{c as mt}from"./confirmEmail.js";import{useText as ct}from"@dropins/tools/i18n.js";import{Header as ft,InLineAlert as dt,InputPassword as lt}from"@dropins/tools/components.js";import{u as ht,F as gt}from"./Button.js";const wt=({emailConfirmationStatusMessage:t,translations:o,initialEmailValue:s,routeSignUp:l,routeForgotPassword:u,routeRedirectOnSignIn:F,onErrorCallback:_,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:i,routeRedirectOnEmailConfirmationClose:b,apiErrorMessageOverride:A})=>{const[M,v]=y(""),[U,n]=y(!1),[g,d]=y(""),[P,w]=y(!1),[j,q]=y({userName:"",status:!1}),[V,x]=y(!1),[k,N]=y([]),p=c(async r=>{i(),n(!0),w(!1),N([]),await et(r)},[i]),D=c(r=>{r.length?w(!1):w(!0),d(r)},[]);Q(()=>{t!=null&&t.text&&i({text:t.text,type:t.status?t.status:void 0})},[t,i]);const G=c(()=>{g.length||w(!0)},[g]),B=c((r,e)=>g.length?!1:(w(!0),e&&nt(r,g,""),!0),[g]),C=c((r,e)=>{e!=null&&e.userName&&(r.target.reset(),E(F)?window.location.href=F():(f==null||f({userName:e==null?void 0:e.userName,status:!0}),q({userName:e==null?void 0:e.userName,status:!0})))},[f,F]),S=c((r,e)=>{var I;if((I=r==null?void 0:r.errorMessage)!=null&&I.length){v(e);const K=r.errorMessage.includes("This account isn't confirmed. Verify and try again."),T=K?o.resendEmailInformationText:r.displayErrorMessage;N(K?[{label:o.resendEmailButtonText,onClick:()=>{p(e)}}]:[]),i({text:T,type:"error"}),d("")}},[p,i,o.resendEmailButtonText,o.resendEmailInformationText]),H=c(async(r,e)=>{if(i(),B(r,e))return;x(!0);const I=tt(r.target);if(Object.values(I).every(T=>T)){const{email:T,password:z}=I,J=await ot({email:T,password:z,handleSetInLineAlertProps:i,onErrorCallback:_,translations:o,apiErrorMessageOverride:A});S(J,T),C(r,J),w(!1)}x(!1)},[o,_,B,S,C,i,A]),W=c(()=>{if(E(a)){a("resetPasswordForm");return}E(u)&&(window.location.href=u())},[u,a]),X=c(()=>{if(E(h)&&h(),E(a)){a("signUpForm");return}E(l)&&(window.location.href=l())},[h,l,a]),Y=at(()=>{const r=it(st);return s!=null&&s.length?r==null?void 0:r.map(e=>({...e,defaultValue:s})):r},[s]),Z=c(()=>{i(),E(b)?window.location.href=b():n(!1)},[i,b]);return{additionalActionsAlert:k,userEmail:M,defaultEnhancedEmailFields:Y,passwordError:P,isSuccessful:j,isLoading:V,signInPasswordValue:g,showEmailConfirmationForm:U,setShowEmailConfirmationForm:n,setSignInPasswordValue:d,submitLogInUser:H,forgotPasswordCallback:W,onSignUpLinkClickCallback:X,handledOnPrimaryButtonClick:Z,handleSetPassword:D,onBlurPassword:G}},yt=()=>{let t=new URL(window.location.href),o=t.searchParams.get("email"),s=t.searchParams.get("key");o&&s&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},_t=({enableEmailConfirmation:t})=>{const o=ct({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[s,l]=y({text:"",status:""});return Q(()=>{if(t){const{search:u}=window.location;u.includes("email=")&&u.includes("key=")&&(async()=>{var f,h,i;const _=new URLSearchParams(u),a=await mt({customerEmail:_.get("email"),customerConfirmationKey:_.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?o.accountConfirmationEmailSuccessMessage.replace("{email}",(i=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:i.email):o.accountConfirmMessage,status:"success"}),yt())})()}},[t,o]),{emailConfirmationStatusMessage:s}},Lt=({slots:t,labels:o,formSize:s="default",initialEmailValue:l="",renderSignUpLink:u=!1,enableEmailConfirmation:F=!1,hideCloseBtnOnEmailConfirmation:_=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:i,onSuccessCallback:b,setActiveComponent:A,onErrorCallback:M,onSignUpLinkClick:v,apiErrorMessageOverride:U})=>{const n=ht({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{emailConfirmationStatusMessage:g}=_t({enableEmailConfirmation:F}),{inLineAlertProps:d,handleSetInLineAlertProps:P}=rt(),{userEmail:w,additionalActionsAlert:j,defaultEnhancedEmailFields:q,passwordError:V,isSuccessful:x,isLoading:k,signInPasswordValue:N,showEmailConfirmationForm:p,submitLogInUser:D,forgotPasswordCallback:G,onSignUpLinkClickCallback:B,handledOnPrimaryButtonClick:C,handleSetPassword:S,onBlurPassword:H}=wt({translations:n,emailConfirmationStatusMessage:g,initialEmailValue:l,routeSignUp:i,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:A,onErrorCallback:M,onSuccessCallback:b,onSignUpLinkClick:v,handleSetInLineAlertProps:P,routeRedirectOnEmailConfirmationClose:a,apiErrorMessageOverride:U});return x.status&&(t!=null&&t.SuccessNotification)?m(O,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:x}}):p?m(ut,{formSize:s,userEmail:w,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:_,handleSetInLineAlertProps:P,onPrimaryButtonClick:C}):L("div",{className:R(["auth-sign-in-form",`auth-sign-in-form--${s}`]),"data-testid":"signInForm",children:[m(ft,{title:(o==null?void 0:o.formTitleText)??n.title,divider:!1,className:"auth-sign-in-form__title"}),d.text?m(dt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:j}):null,L(gt,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:D,loading:k,fieldsConfig:q,children:[m(lt,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:V?n.requiredFieldError:void 0,defaultValue:N,onValue:S,onBlur:H,placeholder:n.placeholder,floatingLabel:n.floatingLabel}),L("div",{className:"auth-sign-in-form__form__buttons",children:[L("div",{className:"auth-sign-in-form__form__buttons__combine",children:[m($,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:G,"data-testid":"switchToSignUp"}),u?m("span",{}):null,u?m($,{type:"button",variant:"tertiary",style:{padding:0},buttonText:n.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:B}):null]}),m($,{type:"submit",buttonText:(o==null?void 0:o.primaryButtonText)??n.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:k})]})]}),m("div",{id:"generateCustomerToken"})]})};export{Lt as S};
3
+ import{jsx as u,jsxs as k,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as J,classes as tt}from"@dropins/tools/lib.js";import{c as E,g as rt,u as at,B as Q}from"./Button2.js";import{useState as _,useCallback as m,useEffect as X,useMemo as et}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as ot}from"./getCustomerToken.js";import{r as it}from"./resendConfirmationEmail.js";import{s as nt,a as st}from"./simplifyTransformAttributesForm.js";import{f as ut,E as mt}from"./focusOnEmptyPasswordField.js";import{c as ct}from"./confirmEmail.js";import{useText as ft}from"@dropins/tools/i18n.js";import{Header as dt,InLineAlert as lt,InputPassword as ht}from"@dropins/tools/components.js";import{u as gt,F as wt}from"./Button.js";const _t=({emailConfirmationStatusMessage:t,translations:e,initialEmailValue:n,routeSignUp:l,routeForgotPassword:c,routeRedirectOnSignIn:F,onErrorCallback:y,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:i,routeRedirectOnEmailConfirmationClose:b,apiErrorMessageOverride:p})=>{const[v,j]=_(""),[q,s]=_(!1),[g,d]=_(""),[B,w]=_(!1),[V,D]=_({userName:"",status:!1}),[C,x]=_(!1),[N,I]=_([]),S=m(async r=>{i(),s(!0),w(!1),I([]),await it(r)},[i]),G=m(r=>{r.length?w(!1):w(!0),d(r)},[]);X(()=>{t!=null&&t.text&&i({text:t.text,type:t.status?t.status:void 0})},[t,i]);const H=m(()=>{g.length||w(!0)},[g]),L=m((r,o)=>g.length?!1:(w(!0),o&&ut(r,g,""),!0),[g]),M=m((r,o)=>{o!=null&&o.userName&&(r.target.reset(),E(F)?window.location.href=F():(f==null||f({userName:o==null?void 0:o.userName,status:!0}),D({userName:o==null?void 0:o.userName,status:!0})))},[f,F]),U=m((r,o)=>{var P;if((P=r==null?void 0:r.errorMessage)!=null&&P.length){j(o);const $=r.errorMessage.includes("This account isn't confirmed. Verify and try again."),T=$?e.resendEmailInformationText:r.displayErrorMessage;I($?[{label:e.resendEmailButtonText,onClick:()=>{S(o)}}]:[]),i({text:T,type:"error"}),d("")}},[S,i,e.resendEmailButtonText,e.resendEmailInformationText]),K=m(async(r,o)=>{if(i(),L(r,o))return;x(!0);const P=rt(r.target);if(Object.values(P).every(T=>T)){const{email:T,password:O}=P,W=await ot({email:T,password:O,handleSetInLineAlertProps:i,onErrorCallback:y,translations:e,apiErrorMessageOverride:p});U(W,T),M(r,W),w(!1)}x(!1)},[e,y,L,U,M,i,p]),A=m(()=>{if(E(a)){a("resetPasswordForm");return}E(c)&&(window.location.href=c())},[c,a]),Y=m(()=>{if(E(h)&&h(),E(a)){a("signUpForm");return}E(l)&&(window.location.href=l())},[h,l,a]),Z=et(()=>{const r=nt(st);return n!=null&&n.length?r==null?void 0:r.map(o=>({...o,defaultValue:n})):r},[n]),z=m(()=>{i(),E(b)?window.location.href=b():s(!1)},[i,b]);return{additionalActionsAlert:N,userEmail:v,defaultEnhancedEmailFields:Z,passwordError:B,isSuccessful:V,isLoading:C,signInPasswordValue:g,showEmailConfirmationForm:q,setShowEmailConfirmationForm:s,setSignInPasswordValue:d,submitLogInUser:K,forgotPasswordCallback:A,onSignUpLinkClickCallback:Y,handledOnPrimaryButtonClick:z,handleSetPassword:G,onBlurPassword:H}},yt=()=>{let t=new URL(window.location.href),e=t.searchParams.get("email"),n=t.searchParams.get("key");e&&n&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},Et=({enableEmailConfirmation:t})=>{const e=ft({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[n,l]=_({text:"",status:""});return X(()=>{if(t){const{search:c}=window.location;c.includes("email=")&&c.includes("key=")&&(async()=>{var f,h,i;const y=new URLSearchParams(c),a=await ct({customerEmail:y.get("email"),customerConfirmationKey:y.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?e.accountConfirmationEmailSuccessMessage.replace("{email}",(i=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:i.email):e.accountConfirmMessage,status:"success"}),yt())})()}},[t,e]),{emailConfirmationStatusMessage:n}},Mt=({slots:t,labels:e,formSize:n="default",initialEmailValue:l="",renderSignUpLink:c=!1,enableEmailConfirmation:F=!1,hideCloseBtnOnEmailConfirmation:y=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:i,onSuccessCallback:b,setActiveComponent:p,onErrorCallback:v,onSignUpLinkClick:j,apiErrorMessageOverride:q})=>{const s=gt({title:"Auth.SignInForm.title",buttonPrimary:"Auth.SignInForm.buttonPrimary",buttonSecondary:"Auth.SignInForm.buttonSecondary",buttonTertiary:"Auth.SignInForm.buttonTertiary",resendEmailInformationText:"Auth.Notification.resendEmailNotification.informationText",resendEmailButtonText:"Auth.Notification.resendEmailNotification.buttonText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError.default"}),{emailConfirmationStatusMessage:g}=Et({enableEmailConfirmation:F}),{inLineAlertProps:d,handleSetInLineAlertProps:B}=at(),{userEmail:w,additionalActionsAlert:V,defaultEnhancedEmailFields:D,passwordError:C,isSuccessful:x,isLoading:N,signInPasswordValue:I,showEmailConfirmationForm:S,submitLogInUser:G,forgotPasswordCallback:H,onSignUpLinkClickCallback:L,handledOnPrimaryButtonClick:M,handleSetPassword:U,onBlurPassword:K}=_t({translations:s,emailConfirmationStatusMessage:g,initialEmailValue:l,routeSignUp:i,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:p,onErrorCallback:v,onSuccessCallback:b,onSignUpLinkClick:j,handleSetInLineAlertProps:B,routeRedirectOnEmailConfirmationClose:a,apiErrorMessageOverride:q});if(x.status&&(t!=null&&t.SuccessNotification))return u(J,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:x}});if(S)return u(mt,{formSize:n,userEmail:w,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:y,handleSetInLineAlertProps:B,onPrimaryButtonClick:M});const A={isLoading:N,passwordError:C,isSuccessful:x};return k("div",{className:tt(["auth-sign-in-form",`auth-sign-in-form--${n}`]),"data-testid":"signInForm",children:[u(J,{name:"Title","data-testid":"title",slot:t==null?void 0:t.Title,context:{...A},children:u(dt,{title:(e==null?void 0:e.formTitleText)??s.title,divider:!1,className:"auth-sign-in-form__title"})}),d.text?u(lt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:V}):null,k(wt,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:G,loading:N,fieldsConfig:D,formSlot:{name:"Form",slot:t==null?void 0:t.Form,context:A,dataTestId:"form"},children:[u(ht,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:C?s.requiredFieldError:void 0,defaultValue:I,onValue:U,onBlur:K,placeholder:s.placeholder,floatingLabel:s.floatingLabel}),u("div",{className:"auth-sign-in-form__form__buttons__wrapper",children:k(J,{name:"Buttons",className:"auth-sign-in-form__form__buttons","data-testid":"buttons",slot:t==null?void 0:t.Buttons,context:{...A},children:[k("div",{className:"auth-sign-in-form__form__buttons__combine",children:[u(Q,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:H,"data-testid":"switchToSignUp"}),c?k(R,{children:[u("span",{}),u(Q,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:L})]}):null]}),u(Q,{type:"submit",buttonText:(e==null?void 0:e.primaryButtonText)??s.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:N})]})})]}),u("div",{id:"generateCustomerToken"})]})};export{Mt as S};
4
4
  //# sourceMappingURL=SignInForm.js.map