@dropins/storefront-auth 0.0.1-alpha17 → 0.0.1-alpha19
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/useInLineAlert.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as v,jsx as d,Fragment as S}from"@dropins/tools/preact-jsx-runtime.js";import{useCallback as D,useRef as g,useState as k,useEffect as V}from"@dropins/tools/preact-hooks.js";import{classes as L}from"@dropins/tools/lib.js";import{Button as R,Field as N,Picker as O,Input as y,InputDate as H,Checkbox as P,TextArea as q}from"@dropins/tools/components.js";import{initReCaptcha as U}from"@dropins/tools/recaptcha.js";import{useText as W}from"@dropins/tools/i18n.js";import*as f from"@dropins/tools/preact-compat.js";import{memo as G,useCallback as _}from"@dropins/tools/preact-compat.js";const te=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{}},ne=r=>typeof r=="function",ae=({type:r,buttonText:c,variant:u,className:l="",enableLoader:o=!1,onClick:s,style:h,icon:a,...p})=>{const I=D(A=>{s==null||s(A)},[s]);return v(R,{icon:a,style:h,type:r,variant:u,className:L(["auth-button",l,o?"enableLoader":""]),onClick:I,...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]})},C=r=>r.reduce((c,{code:u,required:l,defaultValue:o})=>(l&&(c[u]=o),c),{}),F=({fieldsConfig:r,submitCallback:c})=>{const{requiredFieldError:u}=W({requiredFieldError:"Auth.FormText.requiredFieldError"}),l=g(null),o=g(!1),[s,h]=k({}),[a,p]=k({}),I=D(async()=>{o.current||(await U(0),o.current=!0)},[]);V(()=>{if(!r.length)return;const t=C(r);h(t)},[r==null?void 0:r.length]);const $=D((t,n)=>{const E=r.find(i=>i.code===t);return E!=null&&E.required&&!n?u:""},[r,u]),A=D(t=>{const{name:n,value:E,type:T,checked:i}=t==null?void 0:t.target,M=T==="checkbox"?i:E;h(b=>({...b,[n]:M}))},[]),x=D(t=>{const{name:n,value:E,type:T,checked:i}=t==null?void 0:t.target,M=T==="checkbox"?i:E;p(b=>({...b,[n]:$(n,M)}))},[$]),e=D(t=>{t.preventDefault();let n=!0,E={},T=null;for(const[i,M]of Object.entries(s)){const b=$(i,M);b&&(E[i]=b,n=!1,T||(T=i))}if(p(E),T&&l.current){const i=l.current.elements.namedItem(T);i==null||i.focus()}c==null||c(t,n)},[s,$,c]);return{formData:s,errors:a,formRef:l,handleChange:A,handleBlur:x,handleSubmit:e,handleFocus:I}};var w=(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))(w||{});const Z=G(({loading:r,values:c,fields:u=[],errors:l,className:o="",onChange:s,onBlur:h})=>{const a=`${o}__field`,p=_((e,t,n)=>d(N,{error:n,className:L([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(O,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options.map(E=>({...E,text:E.label})),onBlur:h,handleSelect:s,value:t||e.defaultValue})},e.id),[o,r,a,h,s]),I=_((e,t,n)=>d(N,{error:n,className:L([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(y,{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,a,h,s]),$=_((e,t,n)=>d(N,{error:n,className:L([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(H,{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,a,h,s]),A=_((e,t,n)=>d(N,{error:n,className:L([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(P,{name:e.id,checked:t||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:h,onChange:s})},e.id),[o,r,a,h,s]),x=_((e,t,n)=>d(N,{error:n,className:L([a,`${a}--${e.id}`,[`${a}--${e.id}-hidden`,e.hidden],e.className]),"data-testid":`${o}--${e.id}`,disabled:r,children:d(q,{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,a,h,s]);return u.length?d(S,{children:u.map(e=>{const t=(l==null?void 0:l[e.id])??void 0,n=(c==null?void 0:c[e.id])??void 0;switch(e.fieldType){case w.TEXT:return e.options.length?p(e,n,t):I(e,n,t);case w.MULTILINE:return I(e,n,t);case w.SELECT:return p(e,n,t);case w.DATE:return $(e,n,t);case w.BOOLEAN:return A(e,n,t);case"TEXTAREA":return x(e,n,t);default:return null}})}):null}),ce=({name:r,isLoading:c,children:u,className:l="defaultForm",fieldsConfig:o=[],submitCallback:s})=>{const{formData:h,errors:a,formRef:p,handleChange:I,handleBlur:$,handleSubmit:A,handleFocus:x}=F({submitCallback:s,fieldsConfig:o});return v("form",{onSubmit:A,className:l,name:r,ref:p,onFocus:x,children:[d(Z,{fields:o,onChange:I,onBlur:$,errors:a,values:h,className:l,isLoading:c}),u]})},oe=({children:r,text:c,bottomLine:u=!0,className:l})=>v("div",{className:L(["auth-title",l]),"data-testid":"auth-title_id",children:[v("div",{className:"auth-title__text",children:[d("h1",{className:"auth-title__heading",children:c}),r]}),u?d("div",{className:"auth-title__hr"}):null]}),B=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)"})))),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:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),j=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"})),Y={success:d(X,{}),warning:d(B,{}),error:d(j,{})},le=()=>{const[r,c]=k({}),u=D(l=>{if(!l||!l.type){c({});return}const o=Y[l.type];c({...l,icon:o})},[]);return{inLineAlertProps:r,handleSetInLineAlertProps:u}};export{ae as B,ce as F,oe as T,ne as c,te as g,le as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as a,jsx as o,Fragment as r}from"@dropins/tools/preact-jsx-runtime.js";import{classes as u,Slot as m}from"@dropins/tools/lib.js";import{Button as s}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as d}from"../chunks/revokeCustomerToken.js";import{useText as f}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";const h=({formSize:e="default",className:n="",slots:t,labels:i})=>{const c=f({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return a("div",{className:u(["auth-successNotificationForm",e,n]),children:[o("p",{className:"auth-successNotificationForm__title","data-testid":"notification-title",children:(i==null?void 0:i.headingText)||c.headingText}),o("p",{className:"auth-successNotificationForm__content-text","data-testid":"notification-content",children:(i==null?void 0:i.messageText)||c.messageText}),t!=null&&t.SuccessNotificationActions?o(m,{"data-testid":"successNotificationActions",name:"SuccessNotificationActions",slot:t==null?void 0:t.SuccessNotificationActions,context:{}}):a(r,{children:[o(s,{"data-testid":"primaryButton",type:"button",className:"auth-successNotificationForm__button auth-successNotificationForm__button--top",onClick:()=>window.location.href="/",children:c.primaryButtonText}),o(s,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await d(),window.location.href="/"},children:c.secondaryButtonText})]})]})},F=({formSize:e="default",slots:n,className:t,labels:i})=>o("div",{className:"auth-success-notification",children:o(h,{formSize:e,className:t,slots:n,labels:i})});export{F as SuccessNotification,F as default};
|
package/hooks/ui/useForm.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare const useForm: ({ fieldsConfig, submitCallback }: useFormProps) =
|
|
|
7
7
|
handleChange: (event: Event) => void;
|
|
8
8
|
handleBlur: (event: Event) => void;
|
|
9
9
|
handleSubmit: (event: SubmitEvent) => void;
|
|
10
|
+
handleFocus: () => Promise<void>;
|
|
10
11
|
};
|
|
11
12
|
//# sourceMappingURL=useForm.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-auth", "version": "0.0.1-
|
|
1
|
+
{"name": "@dropins/storefront-auth", "version": "0.0.1-alpha19", "@dropins/elsie": "0.28.2"}
|
|
@@ -6,8 +6,10 @@ export interface SuccessNotificationProps {
|
|
|
6
6
|
};
|
|
7
7
|
formSize?: 'default' | 'small';
|
|
8
8
|
className?: string;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
labels?: {
|
|
10
|
+
headingText: string;
|
|
11
|
+
messageText: string;
|
|
12
|
+
};
|
|
11
13
|
}
|
|
12
14
|
export interface SuccessNotificationFormProps extends SuccessNotificationProps {
|
|
13
15
|
}
|