@dropins/storefront-auth 2.0.2 → 2.0.3

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.
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as l,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import{F as h}from"./Button.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as _}from"./requestPasswordResetEmail.js";import{g as F,c as w,u as P,B as p}from"./Button2.js";import{useState as x,useCallback as g}from"@dropins/tools/preact-hooks.js";import{useText as R}from"@dropins/tools/i18n.js";import{Header as N,InLineAlert as v}from"@dropins/tools/components.js";import{s as E,D as L}from"./simplifyTransformAttributesForm.js";import*as y from"@dropins/tools/preact-compat.js";const T=t=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},y.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),D=({routeSignIn:t,onErrorCallback:a,setActiveComponent:m,handleSetInLineAlertProps:s})=>{const n=R({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[r,e]=x(!1),d=g(async u=>{u.preventDefault(),e(!0);const i=F(u.target);if(i&&i.email){const f=await _(i.email);f.success?s==null||s({type:"success",text:n.successPasswordResetEmailNotification.replace("{email}",i.email)}):(a==null||a(f),s==null||s({type:"error",text:f.message}))}e(!1)},[s,a,n.successPasswordResetEmailNotification]),c=g(()=>{if(w(m)){m("signInForm");return}w(t)&&(window.location.href=t())},[m,t]);return{isLoading:r,submitResetPassword:d,redirectToSignInPage:c}},$=({formSize:t="default",routeSignIn:a,setActiveComponent:m,onErrorCallback:s,...n})=>{const r=R({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary",formAriaLabel:"Auth.ResetPasswordForm.formAriaLabel"}),{inLineAlertProps:e,handleSetInLineAlertProps:d}=P(),{isLoading:c,submitResetPassword:u,redirectToSignInPage:i}=D({routeSignIn:a,setActiveComponent:m,onErrorCallback:s,handleSetInLineAlertProps:d});return l("div",{...n,className:b(["auth-reset-password-form",`auth-reset-password-form--${t}`]),"data-testid":"resetPasswordForm",children:[o(N,{title:r.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(v,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(h,{"aria-labelledby":r.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:u,loading:c,fieldsConfig:E(L),children:l("div",{className:"auth-reset-password-form__buttons",children:[o(p,{className:"auth-reset-password-form__buttons--signin",type:"button",variant:"tertiary",style:{padding:"0"},icon:o(T,{style:{transform:"rotate(90deg)"}}),buttonText:r.buttonSecondary,enableLoader:!1,onClick:i}),o(p,{type:"submit",buttonText:r.buttonPrimary,variant:"primary",enableLoader:c})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{$ as R};
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{F as _}from"./Button.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as F}from"./requestPasswordResetEmail.js";import{g as P,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 v,InLineAlert as L}from"@dropins/tools/components.js";import{s as E,D as T}from"./simplifyTransformAttributesForm.js";import*as R from"@dropins/tools/preact-compat.js";const D=t=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},R.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),A=({routeSignIn:t,onErrorCallback:a,onSuccessCallback:m,setActiveComponent:n,handleSetInLineAlertProps:s})=>{const u=b({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[i,e]=N(!1),f=y(async d=>{d.preventDefault();const r=P(d.target);if(!(r!=null&&r.email))return;e(!0);const w=await F(r.email);if(e(!1),!w.success){a==null||a(w),s==null||s({type:"error",text:w.message});return}if(m){await m();return}s==null||s({type:"success",text:u.successPasswordResetEmailNotification.replace("{email}",r.email)})},[s,a,m,u.successPasswordResetEmailNotification]),c=y(()=>{if(p(n)){n("signInForm");return}p(t)&&(window.location.href=t())},[n,t]);return{isLoading:i,submitResetPassword:f,redirectToSignInPage:c}},G=({formSize:t="default",routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:s,...u})=>{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:c,submitResetPassword:d,redirectToSignInPage:r}=A({routeSignIn:a,setActiveComponent:m,onErrorCallback:n,onSuccessCallback:s,handleSetInLineAlertProps:f});return l("div",{...u,className:h(["auth-reset-password-form",`auth-reset-password-form--${t}`]),"data-testid":"resetPasswordForm",children:[o(v,{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(_,{"aria-labelledby":i.formAriaLabel,name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:d,loading:c,fieldsConfig:E(T),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(D,{style:{transform:"rotate(90deg)"}}),buttonText:i.buttonSecondary,enableLoader:!1,onClick:r}),o(g,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:c})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{G as R};
@@ -1,3 +1,3 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{R as i}from"../chunks/ResetPasswordForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/requestPasswordResetEmail.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/Button2.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";const F=({formSize:o,routeSignIn:t,onErrorCallback:m})=>r("div",{className:"auth-reset-password",children:r(i,{formSize:o,routeSignIn:t,onErrorCallback:m})});export{F as ResetPassword,F as default};
3
+ import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/preact-hooks.js";import"../chunks/Button.js";import"@dropins/tools/i18n.js";import{R as p}from"../chunks/ResetPasswordForm.js";import"@dropins/tools/preact-compat.js";import"../chunks/requestPasswordResetEmail.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/Button2.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";const N=({formSize:o,routeSignIn:t,onErrorCallback:m,onSuccessCallback:i})=>r("div",{className:"auth-reset-password",children:r(p,{formSize:o,routeSignIn:t,onErrorCallback:m,onSuccessCallback:i})});export{N as ResetPassword,N as default};
@@ -1,6 +1,6 @@
1
1
  import { UseResetPasswordFormProps } from '../../types';
2
2
 
3
- export declare const useResetPasswordForm: ({ routeSignIn, onErrorCallback, setActiveComponent, handleSetInLineAlertProps, }: UseResetPasswordFormProps) => {
3
+ export declare const useResetPasswordForm: ({ routeSignIn, onErrorCallback, onSuccessCallback, setActiveComponent, handleSetInLineAlertProps, }: UseResetPasswordFormProps) => {
4
4
  isLoading: boolean;
5
5
  submitResetPassword: (event: any) => Promise<void>;
6
6
  redirectToSignInPage: () => void;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-auth", "version": "2.0.2", "@dropins/tools": "~1.2.0", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-auth", "version": "2.0.3", "@dropins/tools": "~1.2.0", "license": "SEE LICENSE IN LICENSE.md"}
@@ -5,6 +5,7 @@ export interface ResetPasswordProps {
5
5
  formSize?: 'default' | 'small';
6
6
  routeSignIn?: () => string;
7
7
  onErrorCallback?: (value?: unknown) => void;
8
+ onSuccessCallback?: () => void | Promise<void>;
8
9
  }
9
10
  export interface ResetPasswordFormProps extends ResetPasswordProps {
10
11
  setActiveComponent?: (componentName: activeComponentType) => void;