From ae5e5ffccaefac59494d034e180791376502d024 Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Thu, 19 Sep 2024 23:57:04 +0300 Subject: [PATCH] updated --- .../storefront-order/chunks/CustomerDetailsContent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/__dropins__/storefront-order/chunks/CustomerDetailsContent.js b/scripts/__dropins__/storefront-order/chunks/CustomerDetailsContent.js index 9704e89a0b..98ed0562ca 100644 --- a/scripts/__dropins__/storefront-order/chunks/CustomerDetailsContent.js +++ b/scripts/__dropins__/storefront-order/chunks/CustomerDetailsContent.js @@ -1 +1 @@ -import{jsx as $,Fragment as V,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as _,useState as T,useEffect as C,useCallback as w}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as v from"@dropins/tools/preact-compat.js";import{memo as D,useCallback as L}from"@dropins/tools/preact-compat.js";import{classes as k}from"@dropins/tools/lib.js";import{Field as q,Picker as A,Input as I,InputDate as R,Checkbox as O,TextArea as N}from"@dropins/tools/components.js";const S=t=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.8052 14.4968C10.8552 14.4968 9.9752 14.0268 9.4452 13.2368L9.4152 13.1868L9.3852 13.1268C8.1352 11.2268 7.5352 8.96681 7.6852 6.68681C7.7552 4.42681 9.6052 2.61681 11.8652 2.60681H12.0052C14.2752 2.47681 16.2152 4.21681 16.3452 6.47681C16.3452 6.55681 16.3452 6.62681 16.3452 6.70681C16.4852 8.94681 15.9052 11.1768 14.6852 13.0568L14.6052 13.1768C14.0552 13.9868 13.1352 14.4668 12.1652 14.4768H12.0052C11.9352 14.4768 11.8652 14.4868 11.7952 14.4868L11.8052 14.4968Z",stroke:"currentColor"}),v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M4.3252 21.5469C4.3552 20.4169 4.4752 19.2869 4.6752 18.1769C4.8952 17.1669 6.4752 16.0269 8.9052 15.1569C9.2352 15.0369 9.4852 14.7869 9.5952 14.4569L9.8052 14.0269",stroke:"currentColor"}),v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.425 14.4069L14.165 14.1569C14.375 14.5969 14.725 14.9569 15.155 15.1869C16.945 15.7969 19.125 16.9569 19.375 18.2069C19.585 19.3069 19.685 20.4269 19.675 21.5369",stroke:"currentColor"})),j=t=>t.reduce((u,{code:i,required:h,defaultValue:n})=>(h&&(u[i]=n),u),{}),H=({fieldsConfig:t,onSubmit:u})=>{const{requiredFieldError:i}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),h=_(null),[n,c]=T({}),[o,l]=T({});C(()=>{if(c({}),!t||!t.length)return;const s=j(t);c(s)},[t==null?void 0:t.length]),C(()=>{const s=()=>{var e;c({}),(e=h.current)==null||e.reset()};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]);const f=w((s,e)=>{const r=t.find(d=>d.code===s);return r!=null&&r.required&&!e?i:""},[t,i]),b=w(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,p=a==="checkbox"?d:r;c(E=>({...E,[e]:p}))},[]),x=w(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,p=a==="checkbox"?d:r;l(E=>({...E,[e]:f(e,p)}))},[f]),F=w(s=>{s.preventDefault();let e=!0,r={},a=null;for(const[d,p]of Object.entries(n)){const E=f(d,p);E&&(r[d]=E,e=!1,a||(a=d))}if(l(r),a&&h.current){const d=h.current.elements.namedItem(a);d==null||d.focus()}u==null||u(s,e)},[n,f,u]);return{formData:n,errors:o,formRef:h,handleChange:b,handleBlur:x,handleSubmit:F}},P=D(({loading:t,values:u,fields:i=[],errors:h,className:n="",onChange:c,onBlur:o})=>{const l=`${n}__item`,f=L((e,r,a)=>{const d=e.options.map(p=>({text:p.label,value:p.value}));return $(q,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:$(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:c,value:r||e.defaultValue})},e.id)},[n,t,l,o,c]),b=L((e,r,a)=>{const d=e.id==="email",p=d?$(S,{}):void 0,E=d?"username":"";return $(q,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:$(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:p,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id)},[n,t,l,o,c]),x=L((e,r,a)=>$(q,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:$(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]),F=L((e,r,a)=>$(q,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:$(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]),s=L((e,r,a)=>$(q,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:$(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]);return i.length?$(V,{children:i.map(e=>{var d;const r=(h==null?void 0:h[e.id])??"",a=(u==null?void 0:u[e.id])??"";switch(e.fieldType){case"TEXT":return(d=e==null?void 0:e.options)!=null&&d.length?f(e,a,r):b(e,a,r);case"MULTILINE":return b(e,a,r);case"SELECT":return f(e,a,r);case"DATE":return x(e,a,r);case"BOOLEAN":return F(e,a,r);case"TEXTAREA":return s(e,a,r);default:return null}})}):null}),K=D(({name:t,loading:u,children:i,className:h="defaultForm",fieldsConfig:n,onSubmit:c})=>{const{formData:o,errors:l,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=H({fieldsConfig:n,onSubmit:c});return M("form",{className:k(["dropin-form",h]),onSubmit:F,name:t,ref:f,children:[$(P,{className:h,loading:u,fields:n,onChange:b,onBlur:x,errors:l,values:o}),i]})});export{K as F}; +import{jsx as h,Fragment as V,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as _,useState as T,useEffect as C,useCallback as q}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as v from"@dropins/tools/preact-compat.js";import{memo as D,useCallback as L}from"@dropins/tools/preact-compat.js";import{classes as k}from"@dropins/tools/lib.js";import{Field as w,Picker as A,Input as I,InputDate as R,Checkbox as O,TextArea as N}from"@dropins/tools/components.js";const S=t=>v.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.8052 14.4968C10.8552 14.4968 9.9752 14.0268 9.4452 13.2368L9.4152 13.1868L9.3852 13.1268C8.1352 11.2268 7.5352 8.96681 7.6852 6.68681C7.7552 4.42681 9.6052 2.61681 11.8652 2.60681H12.0052C14.2752 2.47681 16.2152 4.21681 16.3452 6.47681C16.3452 6.55681 16.3452 6.62681 16.3452 6.70681C16.4852 8.94681 15.9052 11.1768 14.6852 13.0568L14.6052 13.1768C14.0552 13.9868 13.1352 14.4668 12.1652 14.4768H12.0052C11.9352 14.4768 11.8652 14.4868 11.7952 14.4868L11.8052 14.4968Z",stroke:"currentColor"}),v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M4.3252 21.5469C4.3552 20.4169 4.4752 19.2869 4.6752 18.1769C4.8952 17.1669 6.4752 16.0269 8.9052 15.1569C9.2352 15.0369 9.4852 14.7869 9.5952 14.4569L9.8052 14.0269",stroke:"currentColor"}),v.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.425 14.4069L14.165 14.1569C14.375 14.5969 14.725 14.9569 15.155 15.1869C16.945 15.7969 19.125 16.9569 19.375 18.2069C19.585 19.3069 19.685 20.4269 19.675 21.5369",stroke:"currentColor"})),j=t=>t.reduce((u,{code:p,required:i,defaultValue:n})=>(i&&(u[p]=n),u),{}),H=({fieldsConfig:t,onSubmit:u})=>{const{requiredFieldError:p}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),i=_(null),[n,c]=T({}),[o,l]=T({});C(()=>{if(c({}),!t||!t.length)return;const s=j(t);c(s)},[t==null?void 0:t.length]),C(()=>{const s=()=>{window.location.reload()};return window.addEventListener("popstate",s),()=>{window.removeEventListener("popstate",s)}},[]);const f=q((s,e)=>{const r=t.find(d=>d.code===s);return r!=null&&r.required&&!e?p:""},[t,p]),b=q(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,$=a==="checkbox"?d:r;c(E=>({...E,[e]:$}))},[]),x=q(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,$=a==="checkbox"?d:r;l(E=>({...E,[e]:f(e,$)}))},[f]),F=q(s=>{s.preventDefault();let e=!0,r={},a=null;for(const[d,$]of Object.entries(n)){const E=f(d,$);E&&(r[d]=E,e=!1,a||(a=d))}if(l(r),a&&i.current){const d=i.current.elements.namedItem(a);d==null||d.focus()}u==null||u(s,e)},[n,f,u]);return{formData:n,errors:o,formRef:i,handleChange:b,handleBlur:x,handleSubmit:F}},P=D(({loading:t,values:u,fields:p=[],errors:i,className:n="",onChange:c,onBlur:o})=>{const l=`${n}__item`,f=L((e,r,a)=>{const d=e.options.map($=>({text:$.label,value:$.value}));return h(w,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:h(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:c,value:r||e.defaultValue})},e.id)},[n,t,l,o,c]),b=L((e,r,a)=>{const d=e.id==="email",$=d?h(S,{}):void 0,E=d?"username":"";return h(w,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:h(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:$,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id)},[n,t,l,o,c]),x=L((e,r,a)=>h(w,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:h(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]),F=L((e,r,a)=>h(w,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:h(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]),s=L((e,r,a)=>h(w,{error:a,className:k([l,`${l}--${e.id}`,[`${l}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${n}--${e.id}`,disabled:t,children:h(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:c})},e.id),[n,t,l,o,c]);return p.length?h(V,{children:p.map(e=>{var d;const r=(i==null?void 0:i[e.id])??"",a=(u==null?void 0:u[e.id])??"";switch(e.fieldType){case"TEXT":return(d=e==null?void 0:e.options)!=null&&d.length?f(e,a,r):b(e,a,r);case"MULTILINE":return b(e,a,r);case"SELECT":return f(e,a,r);case"DATE":return x(e,a,r);case"BOOLEAN":return F(e,a,r);case"TEXTAREA":return s(e,a,r);default:return null}})}):null}),K=D(({name:t,loading:u,children:p,className:i="defaultForm",fieldsConfig:n,onSubmit:c})=>{const{formData:o,errors:l,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=H({fieldsConfig:n,onSubmit:c});return M("form",{className:k(["dropin-form",i]),onSubmit:F,name:t,ref:f,children:[h(P,{className:i,loading:u,fields:n,onChange:b,onBlur:x,errors:l,values:o}),p]})});export{K as F};