From 264968edc9d69e0f5565af011aaab534fef65bfe Mon Sep 17 00:00:00 2001 From: Konstantin Fandelyuk Date: Thu, 19 Sep 2024 23:27:31 +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 8c3e42d783..62055575c1 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 v}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as M,useState as D,useEffect as _,useCallback as T}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as C from"@dropins/tools/preact-compat.js";import{memo as w,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 j=l=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},C.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"}),C.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"}),C.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"})),H=l=>l.reduce((u,{code:p,required:h,defaultValue:c})=>(h&&(u[p]=c),u),{}),S=({fieldsConfig:l,onSubmit:u})=>{const{requiredFieldError:p}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),h=M(null),[c,s]=D({}),[o,t]=D({});_(()=>{if(s({}),!l||!l.length)return;const n=H(l);s(n)},[l==null?void 0:l.length]);const f=T((n,e)=>{const r=l.find(d=>d.code===n);return r!=null&&r.required&&!e?p:""},[l,p]),b=T(n=>{const{name:e,value:r,type:a,checked:d}=n==null?void 0:n.target,i=a==="checkbox"?d:r;s(E=>({...E,[e]:i}))},[]),x=T(n=>{const{name:e,value:r,type:a,checked:d}=n==null?void 0:n.target,i=a==="checkbox"?d:r;t(E=>({...E,[e]:f(e,i)}))},[f]),F=T(n=>{n.preventDefault();let e=!0,r={},a=null;for(const[d,i]of Object.entries(c)){const E=f(d,i);E&&(r[d]=E,e=!1,a||(a=d))}if(t(r),a&&h.current){const d=h.current.elements.namedItem(a);d==null||d.focus()}u==null||u(n,e)},[c,f,u]);return{formData:c,errors:o,formRef:h,handleChange:b,handleBlur:x,handleSubmit:F}},U=w(({loading:l,values:u,fields:p=[],errors:h,className:c="",onChange:s,onBlur:o})=>{const t=`${c}__item`,f=L((e,r,a)=>{const d=e.options.map(i=>({text:i.label,value:i.value}));return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:s,value:r||e.defaultValue})},e.id)},[c,l,t,o,s]),b=L((e,r,a)=>{const d=e.id==="email",i=d?$(j,{}):void 0,E=d?"username":"";return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:i,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id)},[c,l,t,o,s]),x=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]),F=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]),n=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]);return p.length?$(V,{children:p.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 n(e,a,r);default:return null}})}):null}),K=w(({name:l,loading:u,children:p,className:h="defaultForm",fieldsConfig:c,onSubmit:s})=>{const{formData:o,errors:t,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=S({fieldsConfig:c,onSubmit:s});return v("form",{className:k(["dropin-form",h]),onSubmit:F,name:l,ref:f,children:[$(U,{className:h,loading:u,fields:c,onChange:b,onBlur:x,errors:t,values:o}),p]})});export{K as F}; +import{jsx as $,Fragment as V,jsxs as v}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as M,useState as D,useEffect as _,useCallback as T}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as C from"@dropins/tools/preact-compat.js";import{memo as w,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 j=l=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},C.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"}),C.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"}),C.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"})),H=l=>l.reduce((u,{code:p,required:h,defaultValue:c})=>(h&&(u[p]=c),u),{}),S=({fieldsConfig:l,onSubmit:u})=>{const{requiredFieldError:p}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),h=M(null),[c,s]=D({}),[o,t]=D({});_(()=>{if(s({}),!l||!l.length)return;const n=H(l);return s(n),()=>{s({})}},[l==null?void 0:l.length]);const f=T((n,e)=>{const r=l.find(d=>d.code===n);return r!=null&&r.required&&!e?p:""},[l,p]),b=T(n=>{const{name:e,value:r,type:a,checked:d}=n==null?void 0:n.target,i=a==="checkbox"?d:r;s(E=>({...E,[e]:i}))},[]),x=T(n=>{const{name:e,value:r,type:a,checked:d}=n==null?void 0:n.target,i=a==="checkbox"?d:r;t(E=>({...E,[e]:f(e,i)}))},[f]),F=T(n=>{n.preventDefault();let e=!0,r={},a=null;for(const[d,i]of Object.entries(c)){const E=f(d,i);E&&(r[d]=E,e=!1,a||(a=d))}if(t(r),a&&h.current){const d=h.current.elements.namedItem(a);d==null||d.focus()}u==null||u(n,e)},[c,f,u]);return{formData:c,errors:o,formRef:h,handleChange:b,handleBlur:x,handleSubmit:F}},U=w(({loading:l,values:u,fields:p=[],errors:h,className:c="",onChange:s,onBlur:o})=>{const t=`${c}__item`,f=L((e,r,a)=>{const d=e.options.map(i=>({text:i.label,value:i.value}));return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:s,value:r||e.defaultValue})},e.id)},[c,l,t,o,s]),b=L((e,r,a)=>{const d=e.id==="email",i=d?$(j,{}):void 0,E=d?"username":"";return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:i,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id)},[c,l,t,o,s]),x=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]),F=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]),n=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:s})},e.id),[c,l,t,o,s]);return p.length?$(V,{children:p.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 n(e,a,r);default:return null}})}):null}),K=w(({name:l,loading:u,children:p,className:h="defaultForm",fieldsConfig:c,onSubmit:s})=>{const{formData:o,errors:t,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=S({fieldsConfig:c,onSubmit:s});return v("form",{className:k(["dropin-form",h]),onSubmit:F,name:l,ref:f,children:[$(U,{className:h,loading:u,fields:c,onChange:b,onBlur:x,errors:t,values:o}),p]})});export{K as F};