@dropins/storefront-auth 0.0.1-alpha13 → 0.0.1-alpha15
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/SignInForm.js +1 -1
- package/chunks/SignUpForm.js +1 -1
- package/chunks/useInLineAlert.js +1 -1
- package/containers/AuthCombine.js +1 -1
- package/containers/UpdatePassword.js +1 -1
- package/hooks/components/useSignInForm.d.ts +1 -0
- package/hooks/components/useUpdatePasswordForm.d.ts +1 -1
- package/package.json +1 -1
- package/types/updatePassword.types.d.ts +1 -0
package/chunks/SignInForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as c,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as $,classes as z}from"@dropins/tools/lib.js";import{g as V,c as y,u as O,T as R,F as tt,B as K}from"./useInLineAlert.js";import{useState as h,useCallback as E,useEffect as J,useMemo as at}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as st}from"./getCustomerToken.js";import{r as rt}from"./resendConfirmationEmail.js";import{s as et,a as ot}from"./simplifyTransformAttributesForm.js";import{c as it}from"./confirmEmail.js";import{useText as Q}from"@dropins/tools/i18n.js";import{InLineAlert as nt,InputPassword as ct}from"@dropins/tools/components.js";import{E as mt}from"./EmailConfirmationForm.js";const ut=({emailConfirmationStatusMessage:t,translations:e,initialEmailValue:i,routeSignUp:m,routeForgotPassword:u,routeRedirectOnSignIn:F,onErrorCallback:g,setActiveComponent:a,onSuccessCallback:l,onSignUpLinkClick:d,handleSetInLineAlertProps:s,routeRedirectOnEmailConfirmationClose:N})=>{const[P,L]=h(""),[f,x]=h(!1),[w,_]=h(""),[C,b]=h(!1),[M,S]=h({userName:"",status:!1}),[p,I]=h(!1),[B,T]=h([]),k=E(async o=>{s(),x(!0),b(!1),T([]),await rt(o)},[s]),U=E(o=>{o.length?b(!1):b(!0),_(o)},[]);J(()=>{t!=null&&t.text&&s({text:t.text,type:t.status?t.status:void 0})},[t,s]);const v=E(async o=>{var q;s(),I(!0);const n=V(o.target);if(n.password||(b(!0),I(!1)),n!=null&&n.email&&(n!=null&&n.password)){const{email:G,password:Y}=n,r=await st({email:G,password:Y,handleSetInLineAlertProps:s,onErrorCallback:g,translations:e});if((q=r==null?void 0:r.errorMessage)!=null&&q.length){L(G);const H=r.errorMessage.includes("This account isn't confirmed. Verify and try again."),Z=H?e.resendEmailInformationText:r.errorMessage;T(H?[{label:e.resendEmailButtonText,onClick:()=>{k(G)}}]:[]),s({text:Z,type:"error"}),_("")}r!=null&&r.userName&&(o.target.reset(),y(F)?window.location.href=F():(l==null||l({userName:r==null?void 0:r.userName,status:!0}),S({userName:r==null?void 0:r.userName,status:!0}))),b(!1)}I(!1)},[s,g,e,k,F,l]),j=E(()=>{if(y(a)){a("resetPasswordForm");return}y(u)&&(window.location.href=u())},[u,a]),D=E(()=>{if(y(d)&&d(),y(a)){a("signUpForm");return}y(m)&&(window.location.href=m())},[d,m,a]),W=at(()=>{const o=et(ot);return i!=null&&i.length?o==null?void 0:o.map(n=>({...n,defaultValue:i})):o},[i]),X=E(()=>{s(),y(N)?window.location.href=N():x(!1)},[s,N]);return{additionalActionsAlert:B,userEmail:P,defaultEnhancedEmailFields:W,passwordError:C,isSuccessful:M,isLoading:p,signInPasswordValue:w,showEmailConfirmationForm:f,setShowEmailConfirmationForm:x,setSignInPasswordValue:_,submitLogInUser:v,forgotPasswordCallback:j,onSignUpLinkClickCallback:D,handledOnPrimaryButtonClick:X,handleSetPassword:U}},lt=()=>{let t=new URL(window.location.href),e=t.searchParams.get("email"),i=t.searchParams.get("key");e&&i&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},ft=({enableEmailConfirmation:t})=>{const e=Q({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[i,m]=h({text:"",status:""});return J(()=>{if(t){const{search:u}=window.location;u.includes("email=")&&u.includes("key=")&&(async()=>{var l,d,s;const g=new URLSearchParams(u),a=await it({customerEmail:g.get("email"),customerConfirmationKey:g.get("key")});if(!a)return null;(l=a==null?void 0:a.errors)!=null&&l.length?m({text:a==null?void 0:a.errors[0].message,status:"error"}):(m({text:a.data.confirmEmail.customer.email?e.accountConfirmationEmailSuccessMessage.replace("{email}",(s=(d=a==null?void 0:a.data)==null?void 0:d.confirmEmail.customer)==null?void 0:s.email):e.accountConfirmMessage,status:"success"}),lt())})()}},[t,e]),{emailConfirmationStatusMessage:i}},pt=({slots:t,formSize:e="default",initialEmailValue:i="",renderSignUpLink:m=!1,enableEmailConfirmation:u=!1,hideCloseBtnOnEmailConfirmation:F=!1,routeRedirectOnEmailConfirmationClose:g,routeRedirectOnSignIn:a,routeForgotPassword:l,routeSignUp:d,onSuccessCallback:s,setActiveComponent:N,onErrorCallback:P,onSignUpLinkClick:L})=>{const f=Q({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"}),{emailConfirmationStatusMessage:x}=ft({enableEmailConfirmation:u}),{inLineAlertProps:w,handleSetInLineAlertProps:_}=O(),{userEmail:C,additionalActionsAlert:b,defaultEnhancedEmailFields:M,passwordError:S,isSuccessful:p,isLoading:I,signInPasswordValue:B,showEmailConfirmationForm:T,submitLogInUser:k,forgotPasswordCallback:U,onSignUpLinkClickCallback:v,handledOnPrimaryButtonClick:j,handleSetPassword:D}=ut({translations:f,emailConfirmationStatusMessage:x,initialEmailValue:i,routeSignUp:d,routeForgotPassword:l,routeRedirectOnSignIn:a,setActiveComponent:N,onErrorCallback:P,onSuccessCallback:s,onSignUpLinkClick:L,handleSetInLineAlertProps:_,routeRedirectOnEmailConfirmationClose:g});return p.status&&(t!=null&&t.SuccessNotification)?c($,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:p}}):T?c(mt,{formSize:e,userEmail:C,inLineAlertProps:w,hideCloseBtnOnEmailConfirmation:F,handleSetInLineAlertProps:_,onPrimaryButtonClick:j}):A("div",{className:z(["auth-signInForm",e]),"data-testid":"signInForm",children:[c(R,{text:f.title,bottomLine:!1,className:"auth-signInForm__title"}),w.text?c(nt,{"data-testid":"authInLineAlert",className:"auth-signInForm__notification",type:w.type,variant:"secondary",heading:w.text,icon:w.icon,additionalActions:b}):null,A(tt,{name:"signIn_form",className:"auth-signInForm__form",submitCallback:k,isLoading:I,fieldsConfig:M,children:[c(ct,{hideStatusIndicator:!0,className:"auth-signInForm__form__password",autoComplete:"current-password",error:S,defaultValue:B,onValue:D,placeholder:f.placeholder,floatingLabel:f.floatingLabel}),A("div",{className:"auth-signInForm__form__buttons",children:[A("div",{className:"auth-signInForm__form__buttons--combine",children:[c(K,{type:"button",variant:"tertiary",style:{padding:0},buttonText:f.buttonTertiary,className:"auth-signInForm__button auth-signInForm__button--forgot",enableLoader:!1,onClick:U,"data-testid":"switchToSignUp"}),m?c("span",{}):null,m?c(K,{type:"button",variant:"tertiary",style:{padding:0},buttonText:f.buttonSecondary,className:"auth-signInForm__button auth-signInForm__button--signup",enableLoader:!1,onClick:v}):null]}),c(K,{type:"submit",buttonText:f.buttonPrimary,variant:"primary",className:"auth-signInForm__button auth-signInForm__button--submit",enableLoader:I})]})]}),c("div",{id:"generateCustomerToken"})]})};export{pt as S};
|
package/chunks/SignUpForm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as ce,classes as le}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as fe,c as de,a as ge}from"./createCustomerAddress.js";import{useState as b,useEffect as he,useCallback as G}from"@dropins/tools/preact-hooks.js";import{s as ee,b as pe,c as Fe}from"./simplifyTransformAttributesForm.js";import{v as Ue,u as be,a as ye}from"./usePasswordValidationMessage.js";import{a as _e}from"./getCustomerToken.js";import{p as te,E as re}from"./getStoreConfig.js";import{c as H,g as Te,u as Ne,T as Le,F as xe,B as ie}from"./useInLineAlert.js";import{InLineAlert as Pe,InputPassword as Ee,Field as Q,Checkbox as X}from"@dropins/tools/components.js";import{S as Se}from"./SkeletonLoader.js";import{E as we}from"./EmailConfirmationForm.js";import{useText as ve}from"@dropins/tools/i18n.js";const se=(e,t)=>t!=null&&t.length?e.map(s=>{var r;const a=(r=t.find(({code:y})=>y===s.code))==null?void 0:r.defaultValue;return a?{...s,defaultValue:a}:s}):e,Me=({inputsDefaultValueSet:e,fieldsConfigForApiVersion1:t,apiVersion2:s})=>{const[a,r]=b([]);return he(()=>{(async()=>{if(s){const u=await fe("customer_account_create");if(u!=null&&u.length)if(e!=null&&e.length){const m=se(u,e);r(m)}else r(u)}else{const u=ee(pe),m=ee(t),h=se(u,e);r(t&&t.length?m:h)}})()},[s,t,e]),{fieldsListConfigs:a}},Ae=e=>{switch(e){case"true":case"on":return!0;case"false":case"off":return!1;default:return e}},qe=(e,t)=>{if(!t)return e;const s={};s.custom_attributes=[];for(const a in e)Object.prototype.hasOwnProperty.call(Fe,a)?s[a]=e[a]:s.custom_attributes.push({attribute_code:a,value:Ae(e[a])});return s},Ce=({addressesData:e,translations:t,isEmailConfirmationRequired:s,apiVersion2:a=!0,passwordConfigs:r,isAutoSignInEnabled:y,routeRedirectOnSignIn:u,routeSignIn:m,onErrorCallback:h,onSuccessCallback:n,setActiveComponent:l,handleSetInLineAlertProps:f,routeRedirectOnEmailConfirmationClose:x})=>{const[O,w]=b(""),[p,o]=b(!1),[c,T]=b({userName:"",status:!1}),[v,d]=b(""),[M,A]=b(!1),[V,F]=b(!1),[q,C]=b(!0),P=G(({target:U})=>{C(U.checked)},[]),I=G(()=>{if(H(l)){l("signInForm");return}H(m)&&(window.location.href=m())},[l,m]),W=G(U=>{d(U)},[]),j=G(()=>{f(
|
|
1
|
+
import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as ce,classes as le}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as fe,c as de,a as ge}from"./createCustomerAddress.js";import{useState as b,useEffect as he,useCallback as G}from"@dropins/tools/preact-hooks.js";import{s as ee,b as pe,c as Fe}from"./simplifyTransformAttributesForm.js";import{v as Ue,u as be,a as ye}from"./usePasswordValidationMessage.js";import{a as _e}from"./getCustomerToken.js";import{p as te,E as re}from"./getStoreConfig.js";import{c as H,g as Te,u as Ne,T as Le,F as xe,B as ie}from"./useInLineAlert.js";import{InLineAlert as Pe,InputPassword as Ee,Field as Q,Checkbox as X}from"@dropins/tools/components.js";import{S as Se}from"./SkeletonLoader.js";import{E as we}from"./EmailConfirmationForm.js";import{useText as ve}from"@dropins/tools/i18n.js";const se=(e,t)=>t!=null&&t.length?e.map(s=>{var r;const a=(r=t.find(({code:y})=>y===s.code))==null?void 0:r.defaultValue;return a?{...s,defaultValue:a}:s}):e,Me=({inputsDefaultValueSet:e,fieldsConfigForApiVersion1:t,apiVersion2:s})=>{const[a,r]=b([]);return he(()=>{(async()=>{if(s){const u=await fe("customer_account_create");if(u!=null&&u.length)if(e!=null&&e.length){const m=se(u,e);r(m)}else r(u)}else{const u=ee(pe),m=ee(t),h=se(u,e);r(t&&t.length?m:h)}})()},[s,t,e]),{fieldsListConfigs:a}},Ae=e=>{switch(e){case"true":case"on":return!0;case"false":case"off":return!1;default:return e}},qe=(e,t)=>{if(!t)return e;const s={};s.custom_attributes=[];for(const a in e)Object.prototype.hasOwnProperty.call(Fe,a)?s[a]=e[a]:s.custom_attributes.push({attribute_code:a,value:Ae(e[a])});return s},Ce=({addressesData:e,translations:t,isEmailConfirmationRequired:s,apiVersion2:a=!0,passwordConfigs:r,isAutoSignInEnabled:y,routeRedirectOnSignIn:u,routeSignIn:m,onErrorCallback:h,onSuccessCallback:n,setActiveComponent:l,handleSetInLineAlertProps:f,routeRedirectOnEmailConfirmationClose:x})=>{const[O,w]=b(""),[p,o]=b(!1),[c,T]=b({userName:"",status:!1}),[v,d]=b(""),[M,A]=b(!1),[V,F]=b(!1),[q,C]=b(!0),P=G(({target:U})=>{C(U.checked)},[]),I=G(()=>{if(H(l)){l("signInForm");return}H(m)&&(window.location.href=m())},[l,m]),W=G(U=>{d(U)},[]),j=G(()=>{f(),d(""),H(x)?window.location.href=x():(o(!1),l==null||l("signInForm"))},[f,x,l]);return{isKeepMeLogged:q,userEmail:O,showEmailConfirmationForm:p,isSuccessful:c,isClickSubmit:M,signUpPasswordValue:v,isLoading:V,onSubmitSignUp:async(U,$)=>{var Z,z,D;if(f(),F(!0),!$){A(!0),F(!1);return}const B=a?"createCustomerV2":"createCustomer",_=Te(U.target),{email:E,password:S,is_subscribed:ae}=_,oe=(r==null?void 0:r.requiredCharacterClasses)||0,ue=(r==null?void 0:r.minLength)||1;if(!Ue(S,oe)||ue>(S==null?void 0:S.length)){A(!0),F(!1);return}const ne=qe({..._,is_subscribed:!!ae||!1},a),{data:N,errors:L}=await de(ne,a),K=((z=(Z=N==null?void 0:N.createCustomer)==null?void 0:Z.customer)==null?void 0:z.firstname)||"";if(L&&(L!=null&&L.length))f==null||f({type:"error",text:L[0].message}),h==null||h(L),te(re.CREATE_ACCOUNT_EVENT,{updateProfile:!1}),w(E);else{const J={email:"",...N==null?void 0:N[B]};if(te(re.CREATE_ACCOUNT_EVENT,{email:J==null?void 0:J.email,updateProfile:!0}),s||!y){if(n==null||n({userName:K,status:!0}),s){(D=U.target)==null||D.reset(),d(""),o(!0),w(E),F(!1);return}if(!y){F(!1),T({userName:K,status:!0});return}}const g=await _e({email:E,password:S,translations:t,handleSetInLineAlertProps:f,onErrorCallback:h});if(g!=null&&g.userName){if(e!=null&&e.length)for(const R of e)try{await ge(R)}catch(me){console.error(t.failedCreateCustomerAddress,R,me)}H(u)?window.location.href=u():(n==null||n({userName:g==null?void 0:g.userName,status:!0}),T({userName:g==null?void 0:g.userName,status:!0}))}else n==null||n({userName:K,status:!0}),T({userName:K,status:!0})}F(!1)},signInButton:I,handleSetSignUpPasswordValue:W,onKeepMeLoggedChange:P,handleHideEmailConfirmationForm:j}},Ze=({addressesData:e,formSize:t="default",inputsDefaultValueSet:s,fieldsConfigForApiVersion1:a,apiVersion2:r=!0,isAutoSignInEnabled:y=!0,displayTermsOfUseCheckbox:u=!1,displayNewsletterCheckbox:m=!1,hideCloseBtnOnEmailConfirmation:h=!1,routeRedirectOnEmailConfirmationClose:n,routeRedirectOnSignIn:l,routeSignIn:f,onErrorCallback:x,onSuccessCallback:O,setActiveComponent:w,slots:p})=>{const o=ve({title:"Auth.SignUpForm.title",buttonPrimary:"Auth.SignUpForm.buttonPrimary",buttonSecondary:"Auth.SignUpForm.buttonSecondary",privacyPolicyDefaultText:"Auth.SignUpForm.privacyPolicyDefaultText",subscribedDefaultText:"Auth.SignUpForm.subscribedDefaultText",keepMeLoggedText:"Auth.SignUpForm.keepMeLoggedText",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage",failedCreateCustomerAddress:"Auth.SignUpForm.failedCreateCustomerAddress",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel"}),{passwordConfigs:c,isEmailConfirmationRequired:T}=be(),{fieldsListConfigs:v}=Me({fieldsConfigForApiVersion1:a,apiVersion2:r,inputsDefaultValueSet:s}),{inLineAlertProps:d,handleSetInLineAlertProps:M}=Ne(),{isKeepMeLogged:A,userEmail:V,showEmailConfirmationForm:F,isSuccessful:q,isClickSubmit:C,signUpPasswordValue:P,isLoading:I,onSubmitSignUp:W,signInButton:j,handleSetSignUpPasswordValue:Y,onKeepMeLoggedChange:U,handleHideEmailConfirmationForm:$}=Ce({addressesData:e,translations:o,isEmailConfirmationRequired:T,apiVersion2:r,passwordConfigs:c,isAutoSignInEnabled:y,routeRedirectOnSignIn:l,routeSignIn:f,onErrorCallback:x,onSuccessCallback:O,setActiveComponent:w,handleSetInLineAlertProps:M,routeRedirectOnEmailConfirmationClose:n}),{isValidUniqueSymbols:B,defaultLengthMessage:_}=ye({password:P,isClickSubmit:C,passwordConfigs:c}),E=!T&&(e==null?void 0:e.length);return!v.length&&r?i("div",{className:`auth-signUpForm ${t} skeleton-loader`,"data-testid":"SignUpForm",children:i(Se,{activeSkeleton:"signUpForm"})}):q.status&&(p!=null&&p.SuccessNotification)?i(ce,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:p==null?void 0:p.SuccessNotification,context:{isSuccessful:q}}):F?i(we,{formSize:t,userEmail:V,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:h,handleSetInLineAlertProps:M,onPrimaryButtonClick:$}):k("div",{className:le(["auth-signUpForm",t]),"data-testid":"SignUpForm",children:[i(Le,{text:o.title,bottomLine:!1,className:"auth-signUpForm__title"}),d.text?i(Pe,{className:"auth-signUpForm__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon}):null,k(xe,{submitCallback:W,className:"auth-signUpForm__form",isLoading:I,name:"signUp_form",fieldsConfig:v,children:[i(Ee,{validateLengthConfig:_,className:"auth-signUpForm__form__field",autoComplete:"current-password",name:"password",minLength:c==null?void 0:c.minLength,error:B==="error"||(_==null?void 0:_.status)==="error"||C&&P.length<=0,defaultValue:P,uniqueSymbolsStatus:B,requiredCharacterClasses:c==null?void 0:c.requiredCharacterClasses,onValue:Y,placeholder:o.placeholder,floatingLabel:o.floatingLabel,children:E?i("div",{className:"auth-signUpForm__automatic-login",children:i(Q,{children:i(X,{name:"",placeholder:o.keepMeLoggedText,label:o.keepMeLoggedText,checked:A,onChange:U})})}):null}),m||u?k("div",{className:"auth-signUpForm__item auth-signUpForm__checkbox",children:[m?i(Q,{children:i(X,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:o.subscribedDefaultText,label:o.subscribedDefaultText})}):null,u?i(Q,{children:i(X,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:o.privacyPolicyDefaultText,label:o.privacyPolicyDefaultText})}):null]}):null,k("div",{className:"auth-signUpForm-buttons",children:[i(ie,{type:"button",variant:"tertiary",style:{padding:0},buttonText:o.buttonSecondary,enableLoader:!1,onClick:j}),i(ie,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:I})]})]}),i("div",{id:"createCustomerV2"})]})};export{Ze as S};
|
package/chunks/useInLineAlert.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as _,jsx as d,Fragment as k}from"@dropins/tools/preact-jsx-runtime.js";import{useCallback as b,useRef as g,useState as v,useEffect as x}from"@dropins/tools/preact-hooks.js";import{classes as I}from"@dropins/tools/lib.js";import{Button as S,Field as M,Picker as V,Input as O,InputDate as R,Checkbox as y,TextArea as H}from"@dropins/tools/components.js";import{initReCaptcha as P}from"@dropins/tools/recaptcha.js";import{useText as q}from"@dropins/tools/i18n.js";import*as f from"@dropins/tools/preact-compat.js";import{memo as U,useCallback as N}from"@dropins/tools/preact-compat.js";const ee=r=>{if(!r)return null;const c=new FormData(r);if(c&&typeof c.entries=="function"){const u=c.entries();if(u&&typeof u[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(u)))||{}}return{}},re=r=>typeof r=="function",te=({type:r,buttonText:c,variant:u,className:l="",enableLoader:o=!1,onClick:s,style:h,icon:n,...p})=>{const $=b(T=>{s==null||s(T)},[s]);return _(S,{icon:n,style:h,type:r,variant:u,className:I(["auth-button",l,o?"enableLoader":""]),onClick:$,...p,children:[d("span",{className:"auth-button__text",children:c}),o?d("div",{className:"auth-button__loader-wrapper",children:d("span",{className:"auth-button__loader"})}):null]})},W=r=>r.reduce((c,{code:u,required:l,defaultValue:o})=>(l&&(c[u]=o),c),{}),G=({fieldsConfig:r,submitCallback:c})=>{const{requiredFieldError:u}=q({requiredFieldError:"Auth.FormText.requiredFieldError"}),l=g(null),[o,s]=v({}),[h,n]=v({});x(()=>{if(!r.length)return;const E=W(r);s(E)},[r==null?void 0:r.length]);const p=b((E,e)=>{const t=r.find(i=>i.code===E);return t!=null&&t.required&&!e?u:""},[r,u]),$=b(E=>{const{name:e,value:t,type:a,checked:i}=E==null?void 0:E.target,w=a==="checkbox"?i:t;s(D=>({...D,[e]:w}))},[]);x(()=>{P()},[]);const A=b(E=>{const{name:e,value:t,type:a,checked:i}=E==null?void 0:E.target,w=a==="checkbox"?i:t;n(D=>({...D,[e]:p(e,w)}))},[p]),T=b(E=>{E.preventDefault();let e=!0,t={},a=null;for(const[i,w]of Object.entries(o)){const D=p(i,w);D&&(t[i]=D,e=!1,a||(a=i))}if(n(t),a&&l.current){const i=l.current.elements.namedItem(a);i==null||i.focus()}c==null||c(E,e)},[o,p,c]);return{formData:o,errors:h,formRef:l,handleChange:$,handleBlur:A,handleSubmit:T}};var L=(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))(L||{});const C=U(({loading:r,values:c,fields:u=[],errors:l,className:o="",onChange:s,onBlur:h})=>{const n=`${o}__field`,p=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(V,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:h,handleSelect:s,value:t||e.defaultValue})},e.id),[o,r,n,h,s]),$=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(O,{type:"text",name:e.id,value:t===void 0?e.defaultValue:t,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),A=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(R,{type:"text",name:e.id,value:t||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),T=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(y,{name:e.id,checked:t||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),E=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(H,{type:"text",name:e.id,value:t===void 0?e.defaultValue:t,label:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]);return u.length?d(k,{children:u.map(e=>{const t=(l==null?void 0:l[e.id])??void 0,a=(c==null?void 0:c[e.id])??void 0;switch(e.fieldType){case L.TEXT:return e.options.length?p(e,a,t):$(e,a,t);case L.MULTILINE:return $(e,a,t);case L.SELECT:return p(e,a,t);case L.DATE:return A(e,a,t);case L.BOOLEAN:return T(e,a,t);case"TEXTAREA":return E(e,a,t);default:return null}})}):null}),ne=({name:r,isLoading:c,children:u,className:l="defaultForm",fieldsConfig:o=[],submitCallback:s})=>{const{formData:h,errors:n,formRef:p,handleChange:$,handleBlur:A,handleSubmit:T}=G({submitCallback:s,fieldsConfig:o});return _("form",{onSubmit:T,className:l,name:r,ref:p,children:[d(C,{fields:o,onChange:$,onBlur:A,errors:n,values:h,className:l,isLoading:c}),u]})},ae=({children:r,text:c,bottomLine:u=!0,className:l})=>_("div",{className:I(["auth-title",l]),"data-testid":"auth-title_id",children:[_("div",{className:"auth-title__text",children:[d("h1",{className:"auth-title__heading",children:c}),r]}),u?d("div",{className:"auth-title__hr"}):null]}),Z=r=>f.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("g",{clipPath:"url(#clip0_841_1324)"},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),f.createElement("defs",null,f.createElement("clipPath",{id:"clip0_841_1324"},f.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),B=r=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),X=r=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),j={success:d(B,{}),warning:d(Z,{}),error:d(X,{})},oe=()=>{const[r,c]=v({}),u=b(l=>{if(!l||!l.type)return
|
|
1
|
+
import{jsxs as _,jsx as d,Fragment as k}from"@dropins/tools/preact-jsx-runtime.js";import{useCallback as b,useRef as g,useState as v,useEffect as x}from"@dropins/tools/preact-hooks.js";import{classes as I}from"@dropins/tools/lib.js";import{Button as S,Field as M,Picker as V,Input as O,InputDate as R,Checkbox as y,TextArea as H}from"@dropins/tools/components.js";import{initReCaptcha as P}from"@dropins/tools/recaptcha.js";import{useText as q}from"@dropins/tools/i18n.js";import*as f from"@dropins/tools/preact-compat.js";import{memo as U,useCallback as N}from"@dropins/tools/preact-compat.js";const ee=r=>{if(!r)return null;const c=new FormData(r);if(c&&typeof c.entries=="function"){const u=c.entries();if(u&&typeof u[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(u)))||{}}return{}},re=r=>typeof r=="function",te=({type:r,buttonText:c,variant:u,className:l="",enableLoader:o=!1,onClick:s,style:h,icon:n,...p})=>{const $=b(T=>{s==null||s(T)},[s]);return _(S,{icon:n,style:h,type:r,variant:u,className:I(["auth-button",l,o?"enableLoader":""]),onClick:$,...p,children:[d("span",{className:"auth-button__text",children:c}),o?d("div",{className:"auth-button__loader-wrapper",children:d("span",{className:"auth-button__loader"})}):null]})},W=r=>r.reduce((c,{code:u,required:l,defaultValue:o})=>(l&&(c[u]=o),c),{}),G=({fieldsConfig:r,submitCallback:c})=>{const{requiredFieldError:u}=q({requiredFieldError:"Auth.FormText.requiredFieldError"}),l=g(null),[o,s]=v({}),[h,n]=v({});x(()=>{if(!r.length)return;const E=W(r);s(E)},[r==null?void 0:r.length]);const p=b((E,e)=>{const t=r.find(i=>i.code===E);return t!=null&&t.required&&!e?u:""},[r,u]),$=b(E=>{const{name:e,value:t,type:a,checked:i}=E==null?void 0:E.target,w=a==="checkbox"?i:t;s(D=>({...D,[e]:w}))},[]);x(()=>{P()},[]);const A=b(E=>{const{name:e,value:t,type:a,checked:i}=E==null?void 0:E.target,w=a==="checkbox"?i:t;n(D=>({...D,[e]:p(e,w)}))},[p]),T=b(E=>{E.preventDefault();let e=!0,t={},a=null;for(const[i,w]of Object.entries(o)){const D=p(i,w);D&&(t[i]=D,e=!1,a||(a=i))}if(n(t),a&&l.current){const i=l.current.elements.namedItem(a);i==null||i.focus()}c==null||c(E,e)},[o,p,c]);return{formData:o,errors:h,formRef:l,handleChange:$,handleBlur:A,handleSubmit:T}};var L=(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))(L||{});const C=U(({loading:r,values:c,fields:u=[],errors:l,className:o="",onChange:s,onBlur:h})=>{const n=`${o}__field`,p=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(V,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:h,handleSelect:s,value:t||e.defaultValue})},e.id),[o,r,n,h,s]),$=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(O,{type:"text",name:e.id,value:t===void 0?e.defaultValue:t,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),A=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(R,{type:"text",name:e.id,value:t||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),T=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(y,{name:e.id,checked:t||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]),E=N((e,t,a)=>d(M,{error:a,className:I([n,`${n}--${e.id}`,[`${n}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(H,{type:"text",name:e.id,value:t===void 0?e.defaultValue:t,label:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,n,h,s]);return u.length?d(k,{children:u.map(e=>{const t=(l==null?void 0:l[e.id])??void 0,a=(c==null?void 0:c[e.id])??void 0;switch(e.fieldType){case L.TEXT:return e.options.length?p(e,a,t):$(e,a,t);case L.MULTILINE:return $(e,a,t);case L.SELECT:return p(e,a,t);case L.DATE:return A(e,a,t);case L.BOOLEAN:return T(e,a,t);case"TEXTAREA":return E(e,a,t);default:return null}})}):null}),ne=({name:r,isLoading:c,children:u,className:l="defaultForm",fieldsConfig:o=[],submitCallback:s})=>{const{formData:h,errors:n,formRef:p,handleChange:$,handleBlur:A,handleSubmit:T}=G({submitCallback:s,fieldsConfig:o});return _("form",{onSubmit:T,className:l,name:r,ref:p,children:[d(C,{fields:o,onChange:$,onBlur:A,errors:n,values:h,className:l,isLoading:c}),u]})},ae=({children:r,text:c,bottomLine:u=!0,className:l})=>_("div",{className:I(["auth-title",l]),"data-testid":"auth-title_id",children:[_("div",{className:"auth-title__text",children:[d("h1",{className:"auth-title__heading",children:c}),r]}),u?d("div",{className:"auth-title__hr"}):null]}),Z=r=>f.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("g",{clipPath:"url(#clip0_841_1324)"},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),f.createElement("defs",null,f.createElement("clipPath",{id:"clip0_841_1324"},f.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),B=r=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),X=r=>f.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),f.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),j={success:d(B,{}),warning:d(Z,{}),error:d(X,{})},oe=()=>{const[r,c]=v({}),u=b(l=>{if(!l||!l.type){c({});return}const o=j[l.type];c({...l,icon:o})},[]);return{inLineAlertProps:r,handleSetInLineAlertProps:u}};export{te as B,ne as F,ae as T,re as c,ee as g,oe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{lazy as u,Suspense as v}from"@dropins/tools/preact-compat.js";import{useState as E,useMemo as S}from"@dropins/tools/preact-hooks.js";import{S as y}from"../chunks/SkeletonLoader.js";import"@dropins/tools/components.js";const L=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),P=function(c){return"/"+c},p={},d=function(t,i,a){let l=Promise.resolve();if(i&&i.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),r=(e==null?void 0:e.nonce)||(e==null?void 0:e.getAttribute("nonce"));l=Promise.all(i.map(o=>{if(o=P(o),o in p)return;p[o]=!0;const m=o.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const n=document.createElement("link");if(n.rel=m?"stylesheet":L,m||(n.as="script",n.crossOrigin=""),n.href=o,r&&n.setAttribute("nonce",r),document.head.appendChild(n),m)return new Promise((h,_)=>{n.addEventListener("load",h),n.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}return l.then(()=>t()).catch(e=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=e,window.dispatchEvent(r),!r.defaultPrevented)throw e})},k=u(()=>d(()=>import("../chunks/index.js"),[])),b=u(()=>d(()=>import("../chunks/index2.js"),[])),w=u(()=>d(()=>import("../chunks/index3.js"),[])),F=({defaultView:c="signInForm",signInFormConfig:t,signUpFormConfig:i,resetPasswordFormConfig:a})=>{const[l,e]=E(c),r=S(()=>({signInForm:s(b,{setActiveComponent:e,...t}),signUpForm:s(w,{setActiveComponent:e,...i}),resetPasswordForm:s(k,{setActiveComponent:e,...a})}),[a,t,i,e]);return s("div",{children:s(v,{fallback:s(y,{activeSkeleton:l}),children:s("div",{className:"auth-combine",children:r[l]})})})};export{F as AuthCombine,F as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as E}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as $}from"@dropins/tools/lib.js";import{v as k,u as W,a as S}from"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as O}from"../chunks/getCustomerToken.js";import{r as g}from"../chunks/resetPassword.js";import{c as B,g as R,u as C,T as tt,F as et,B as at}from"../chunks/useInLineAlert.js";import{useState as h,useEffect as H,useCallback as I}from"@dropins/tools/preact-hooks.js";import{useText as K}from"@dropins/tools/i18n.js";import{InLineAlert as st,InputPassword as rt}from"@dropins/tools/components.js";import"../chunks/getStoreConfig.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../chunks/setReCaptchaToken.js";import"@dropins/tools/preact-compat.js";const J=(u,l)=>u.split("&").filter(r=>r.includes(l)).map(r=>r.split("=")[1])[0],it=({isEmailConfirmationRequired:u,signInOnSuccess:l,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:f,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:d,routeRedirectOnPasswordUpdate:w,routeSignInPage:m})=>{const s=K({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,y]=h({userName:"",status:!1}),[F,_]=h(""),[L,x]=h(!1),[P,T]=h(""),[N,b]=h(""),[M,n]=h(!1),[A,v]=h(!1),[q,D]=h([]);H(()=>{L&&!q.length&&(F.length?v(!1):v(!0))},[L,F,q]),H(()=>{const{search:p}=window.location;!p.includes("token=")&&!p.includes("email=")&&B(f)&&(window.location.href=f());const e=decodeURIComponent(p),V=J(e,"token"),j=J(e,"email");T(j),b(V)},[f]);const Q=I(async p=>{p.preventDefault(),n(!0),D([]);const e=R(p.target),V=(e==null?void 0:e.password)&&P&&N;e!=null&&e.password||(v(!0),n(!1));const j=(t==null?void 0:t.requiredCharacterClasses)??0,Y=(t==null?void 0:t.minLength)??0;if(!k(e==null?void 0:e.password,j)||e.password.length<+Y){x(!0),n(!1);return}if(!V){d({type:"error",text:s.errorNotification}),n(!1);return}const{message:G,success:z}=await g(P,N,e.password);if(z){if(u||!u&&!l){i==null||i(),B(w)&&(window.location.href=w()),x(!0),n(!1),v(!1),_(""),D([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=m==null?void 0:m()}}]),d({type:"success",text:s.updatePasswordMessage});return}const c=await O({email:P,password:e.password,handleSetInLineAlertProps:d,onErrorCallback:a,translations:s});c!=null&&c.userName&&(i==null||i(c==null?void 0:c.userName),B(r)?window.location.href=r():y({userName:c==null?void 0:c.userName,status:!0}))}else d({type:"error",text:G}),a==null||a({message:G,success:z});n(!1)},[P,N,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,u,l,m,a,i,r,d,w]),X=I(p=>{_(p)},[]);return{additionalActionsAlert:q,passwordError:A,isSuccessful:U,updatePasswordValue:F,isClickSubmit:L,isLoading:M,submitUpdatePassword:Q,handleSetUpdatePasswordValue:X}},ot=({signInOnSuccess:u=!0,formSize:l="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:f,slots:a,onErrorCallback:i,onSuccessCallback:d,routeRedirectOnPasswordUpdate:w})=>{const m=K({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=W(),{inLineAlertProps:y,handleSetInLineAlertProps:F}=C(),{additionalActionsAlert:_,passwordError:L,isSuccessful:x,updatePasswordValue:P,isClickSubmit:T,isLoading:N,submitUpdatePassword:b,handleSetUpdatePasswordValue:M}=it({isEmailConfirmationRequired:U,signInOnSuccess:u,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:d,handleSetInLineAlertProps:F,routeRedirectOnPasswordUpdate:w,routeSignInPage:f}),{isValidUniqueSymbols:n,defaultLengthMessage:A}=S({password:P,isClickSubmit:T,passwordConfigs:s});return x.status&&(a!=null&&a.SuccessNotification)?o(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:x}}):E("div",{className:$(["auth-updatePasswordForm",l]),children:[o(tt,{text:m.title,bottomLine:!1,className:"auth-updatePasswordForm__title"}),y.text?o(st,{className:"auth-updatePasswordForm__notification",variant:"secondary",heading:y.text,icon:y.icon,additionalActions:_}):null,E(et,{name:"updatePassword_form",className:"auth-updatePasswordForm__form",submitCallback:b,isLoading:N,fieldsConfig:[],children:[o("div",{style:"display: none;",children:o("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),o(rt,{defaultValue:P,onValue:M,className:"auth-updatePasswordForm__form__item",autoComplete:"new-password",name:"password",error:L||n==="error"||(A==null?void 0:A.status)==="error",minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:n,validateLengthConfig:A,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:m.placeholder,floatingLabel:m.floatingLabel}),o("div",{className:"auth-updatePasswordForm__button",children:o(at,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:N})})]})]})},_t=({slots:u,formSize:l,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:f,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:d,onSuccessCallback:w})=>o("div",{className:"auth-update-password",children:o(ot,{formSize:l,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:f,routeWrongUrlRedirect:i,onErrorCallback:d,onSuccessCallback:w,slots:u,routeRedirectOnPasswordUpdate:r})});export{_t as UpdatePassword,_t as default};
|
|
@@ -18,5 +18,6 @@ export declare const useSignInForm: ({ emailConfirmationStatusMessage, translati
|
|
|
18
18
|
forgotPasswordCallback: () => void;
|
|
19
19
|
onSignUpLinkClickCallback: () => void;
|
|
20
20
|
handledOnPrimaryButtonClick: () => void;
|
|
21
|
+
handleSetPassword: (value: string) => void;
|
|
21
22
|
};
|
|
22
23
|
//# sourceMappingURL=useSignInForm.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdditionalActionsAlertProps, UseUpdatePasswordFormProps } from '../../types';
|
|
2
2
|
|
|
3
|
-
export declare const useUpdatePasswordForm: ({ isEmailConfirmationRequired, signInOnSuccess, passwordConfigs, routeRedirectOnSignIn, routeWrongUrlRedirect, onErrorCallback, onSuccessCallback, handleSetInLineAlertProps, routeRedirectOnPasswordUpdate, }: UseUpdatePasswordFormProps) => {
|
|
3
|
+
export declare const useUpdatePasswordForm: ({ isEmailConfirmationRequired, signInOnSuccess, passwordConfigs, routeRedirectOnSignIn, routeWrongUrlRedirect, onErrorCallback, onSuccessCallback, handleSetInLineAlertProps, routeRedirectOnPasswordUpdate, routeSignInPage, }: UseUpdatePasswordFormProps) => {
|
|
4
4
|
additionalActionsAlert: AdditionalActionsAlertProps;
|
|
5
5
|
passwordError: boolean;
|
|
6
6
|
isSuccessful: {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-auth", "version": "0.0.1-
|
|
1
|
+
{"name": "@dropins/storefront-auth", "version": "0.0.1-alpha15", "@dropins/elsie": "0.28.0-beta2"}
|
|
@@ -12,6 +12,7 @@ export interface UpdatePasswordProps {
|
|
|
12
12
|
formSize?: 'default' | 'small';
|
|
13
13
|
routeRedirectOnPasswordUpdate?: () => string;
|
|
14
14
|
routeRedirectOnSignIn?: () => string;
|
|
15
|
+
routeSignInPage?: () => string;
|
|
15
16
|
routeWrongUrlRedirect?: () => string;
|
|
16
17
|
onErrorCallback?: (value: unknown) => void;
|
|
17
18
|
onSuccessCallback?: (value?: string) => void;
|